Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cdk:forms): add use form control and vaalidators #121

Merged
merged 1 commit into from
Jan 10, 2021
Merged

feat(cdk:forms): add use form control and vaalidators #121

merged 1 commit into from
Jan 10, 2021

Conversation

danranVm
Copy link
Member

@danranVm danranVm commented Jan 7, 2021

  • feat(cdk:forms): add use form control

fix #115

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our guidelines
  • Tests for the changes have been added/updated or not needed
  • Docs and demo have been added/updated or not needed

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Component style update
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Application (the showcase website) / infrastructure changes
  • Other... Please describe:

What is the current behavior?

What is the new behavior?

Other information

@codecov
Copy link

codecov bot commented Jan 7, 2021

Codecov Report

Merging #121 (1f32f10) into main (552bd95) will increase coverage by 0.66%.
The diff coverage is 98.73%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #121      +/-   ##
==========================================
+ Coverage   95.52%   96.19%   +0.66%     
==========================================
  Files          45       49       +4     
  Lines         604      762     +158     
  Branches      104      141      +37     
==========================================
+ Hits          577      733     +156     
- Misses         10       11       +1     
- Partials       17       18       +1     
Impacted Files Coverage Δ
packages/cdk/breakpoint/src/breakpoints.ts 100.00% <ø> (ø)
packages/cdk/utils/convert.ts 83.33% <0.00%> (-16.67%) ⬇️
packages/cdk/forms/src/constant.ts 100.00% <100.00%> (ø)
packages/cdk/forms/src/typeof.ts 100.00% <100.00%> (ø)
packages/cdk/forms/src/useFormControl.ts 100.00% <100.00%> (ø)
packages/cdk/forms/src/validators.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 552bd95...1f32f10. Read the comment docs.

@IDuxFE IDuxFE deleted a comment from danranVm Jan 7, 2021
@danranVm danranVm changed the title WIP: feat(cdk:forms): add form validtors WIP: feat(cdk:forms): add reactive forms Jan 8, 2021
packages/cdk/forms/useFormControl.ts Outdated Show resolved Hide resolved
packages/cdk/forms/validators.ts Outdated Show resolved Hide resolved

static minLength(minLength: number): ValidatorFn {
return (value: any): { minLength: ValidationError } | null => {
if (isEmpty(value) || !hasLength(value) || value.length >= minLength) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

关于长度的判断,是否要改成真实字符个数 与 字节长度两种形式

  1. 比如 emoji 按现在算的话,会算成长度 2 的,但实际只是一个字符啊
  2. 如果要算 2 ,那么是否要提供另外一个按字节计算的?比如utf-8可能是 2 3 4 个字节

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我认为我们 Cdk 内置的这些校验函数,应该尽可能的简单。
如果用户有特殊的场景,自己实现一个相关的验证函数也是很简单的。

if (pattern.charAt(0) !== '^') regexStr += '^'
regexStr += pattern
if (pattern.charAt(pattern.length - 1) !== '$') regexStr += '$'
regex = new RegExp(regexStr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里看下要不要用第三方的正则处理库,来专门处理下转码,要不会存在以下的问题:

比如我传入'\\w',我的本意是js本身对字符串处理的原因,\ 这个字符是需要转码的,需要\\ 这样的形式才可以表达出\这一个字符,我上面的意思是想匹配 \ w这两个字符的。但按现在实现方式,regex实际是/\w/,匹配的是单词,跟我的意图不一致。这里用户必须自己传成 \\\\w 才是对的,但这样就恶心了

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上条。

@danranVm danranVm changed the title WIP: feat(cdk:forms): add reactive forms feat(cdk:forms): add use form control and vaalidators Jan 8, 2021
@danranVm danranVm merged commit efb9c2f into IDuxFE:main Jan 10, 2021
@danranVm danranVm deleted the feat-cdk-forms branch January 10, 2021 12:29
qikong333 pushed a commit to qikong333/components that referenced this pull request Jan 11, 2021
* main:
  docs(cdk:forms): add validators docs (IDuxFE#128)
  feat(cdk:forms): add useFormControl and Validtors (IDuxFE#121)
  fix(comp: image): export type to fix vite error (IDuxFE#127)
  docs: contribution (IDuxFE#125)
  refactor(comp:all): export type declaration from current component (IDuxFE#124)
  style(scripts): add brace style eslint rule (IDuxFE#123)
  refactor: script gen types template (IDuxFE#119)
  refactor: script gen type structure (IDuxFE#118)
  fix: add engines to package.json (IDuxFE#117)
CruellyJoHn pushed a commit to CruellyJoHn/components that referenced this pull request Jan 22, 2021
fix IDuxFE#77

build: upgrade vite (IDuxFE#102)

refactor(comp:all): updalte all components ts definition (IDuxFE#103)

docs: update all components index.zh.md (IDuxFE#105)

* docs: update gen script

fix(comp: divider): dynamic slot (IDuxFE#104)

fix IDuxFE#76

feat(comp: spin): add spin component (IDuxFE#101)

fix IDuxFE#72

refactor(comp:core): useGlobalConfig (IDuxFE#107)

fix: vite traverse filename config (IDuxFE#106)

docs: update spin component demo (IDuxFE#109)

fix(comp: divider): slots rerender (IDuxFE#110)

refactor(comp:i18n): update useI18n to useLocale (IDuxFE#111)

feat(comp: space): add component space (IDuxFE#97)

fix IDuxFE#63

fix(comp:all): solot dynamic load (IDuxFE#114)

fix: add engines to package.json (IDuxFE#117)

yarn start error because of the low version of Node.js

fix IDuxFE#116

refactor: script gen type structure (IDuxFE#118)

refactor: script gen types template (IDuxFE#119)

* Update the template to make it more simpler.

style(scripts): add brace style eslint rule (IDuxFE#123)

fix IDuxFE#122

refactor(comp:all): export type declaration from current component (IDuxFE#124)

docs: contribution (IDuxFE#125)

update contributing.zh and add contributing.en

fix(comp: image): export type to fix vite error (IDuxFE#127)

feat(cdk:forms): add useFormControl and Validtors (IDuxFE#121)

* test(cdk:forms): add test

fix IDuxFE#115

docs(cdk:forms): add validators docs (IDuxFE#128)

re IDuxFE#115

docs: modify components' docs' type (IDuxFE#131)

feat(comp: empty): add component empty (IDuxFE#132)

* feat(comp:empty): update and add test

fix IDuxFE#54

feat(cdk:utils): add hasOwnProperty function (IDuxFE#137)

fix(comp: badge): overflowCount not work (IDuxFE#135)

fix IDuxFE#134

test(comp:badge,icon): fix warning (IDuxFE#140)

feat(comp: result): add result component (IDuxFE#136)

fix IDuxFE#112

feat(cdk:forms): add formGroup and formArray (IDuxFE#139)

* feat(cdk:forms): add test

re IDuxFE#115

feat(cdk:forms): add utils (IDuxFE#141)

re IDuxFE#115

refactor(cdk:forms): `modelRef` renamed to `valueRef` (IDuxFE#142)

re IDuxFE#115

feat(cdk:forms): add watchValue and watchStatus (IDuxFE#143)

re IDuxFE#115

refactor(cdk:forms): add dirty status and marks `valueRef` to readonly (IDuxFE#144)

re IDuxFE#115

feat(cdk:forms): setValue support configuration options (IDuxFE#146)

re IDuxFE#115

feat: add global types (IDuxFE#150)

docs(cdk:forms): add docs and demo (IDuxFE#149)

fix IDuxFE#115

refactor(cdk:forms): update typescript defintions (IDuxFE#151)

* docs(cdk:forms): update docs

feat(cdk: subject): add subject (IDuxFE#155)

fix IDuxFE#154

feat(comp: typography): add directive typography (IDuxFE#148)

* docs(comp: typography): modify docs

* feat(comp: typography): add type check

* feat(comp: typography): style

* test(comp: typography): add test

fix IDuxFE#130

feature(comp:card): 1.修改dom结构 2.补全css样式 3.重跑单测

feat(comp:card): 1.解决合并冲突

feat(comp:card): add card component
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[cdk: forms]: reactive forms system
3 participants