@king-design/intact 3.1.1-beta.2 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,7 @@ describe('Collapse', () => {
11
11
  this.timeout(0);
12
12
  const [instance, element] = mount(BasicDemo);
13
13
 
14
- const [title1, title2, title3] = element.querySelectorAll<HTMLElement>('.k-collapse-title');
14
+ const [title1, title2, title3] = element.querySelectorAll<HTMLElement>(':scope > .k-collapse-title');
15
15
  title2.click();
16
16
  await wait(500);
17
17
  // the innerHTML is different on travis and local environment
@@ -29,6 +29,7 @@ sidebar: doc
29
29
  | htmlFor | 指定`label`的`for`属性 | `string` | `undefined` |
30
30
  | hideLabel | 是否隐藏`label`,默认会展示`label`,即使该属性为空,也会展示占位元素 | `boolean` | `false` |
31
31
  | fluid | `FormItem`的宽度默认是被子元素撑开的,添加该属性可以渲染`100%`的宽度 | `boolean` | `false` |
32
+ | validateOnStart | 是否组件一渲染就开始验证,而不是等用户输入完成再验证 | `boolean` | `false` |
32
33
 
33
34
  ```ts
34
35
  export declare type Method = (value: any, param: any) => boolean | string | Promise<boolean | string>
@@ -461,4 +461,21 @@ describe('Form', () => {
461
461
  await wait(500);
462
462
  expect(element.querySelector('.k-form-error')).to.be.null;
463
463
  });
464
+
465
+ it('should validate on init when setting validateOnStart prop', async () => {
466
+ class Demo extends Component {
467
+ static template = `
468
+ const {Form, FormItem} = this;
469
+ <Form ref="form">
470
+ <FormItem rules={{required: true}} validateOnStart />
471
+ </Form>
472
+ `;
473
+ Form = Form;
474
+ FormItem = FormItem;
475
+ }
476
+ const [instance, element] = mount(Demo);
477
+
478
+ await wait(500);
479
+ expect(element.querySelector('.k-form-error')).to.be.exist;
480
+ });
464
481
  });
@@ -20,6 +20,7 @@ export interface FormItemProps {
20
20
  htmlFor?: string
21
21
  hideLabel?: boolean
22
22
  fluid?: boolean
23
+ validateOnStart?: boolean
23
24
  }
24
25
 
25
26
  export interface FormItemEvents {
@@ -52,6 +53,7 @@ const typeDefs: Required<TypeDefs<FormItemProps>> = {
52
53
  htmlFor: String,
53
54
  hideLabel: Boolean,
54
55
  fluid: Boolean,
56
+ validateOnStart: Boolean,
55
57
  };
56
58
 
57
59
  export class FormItem extends Component<FormItemProps, FormItemEvents, FormItemBlocks> {
@@ -10,6 +10,10 @@ export function useDirty(
10
10
  const instance = useInstance() as FormItem;
11
11
  const isDirty = useState(false);
12
12
 
13
+ if (instance.get('validateOnStart')) {
14
+ dirty();
15
+ }
16
+
13
17
  function onChange(e: Event) {
14
18
  dirty();
15
19
  instance.trigger('change', e);
@@ -304,10 +304,11 @@ export function makeStyles(k: string) {
304
304
  .${k}-input-fake {
305
305
  left: 0;
306
306
  top: 0;
307
- right: 0;
308
307
  position: absolute;
309
308
  overflow: hidden;
310
- width: 100%;
309
+ // should not specify width
310
+ // right: 0;
311
+ // width: 100%;
311
312
  visibility: hidden;
312
313
  white-space: nowrap;
313
314
  }
@@ -14,6 +14,7 @@ import {Popover, Button} from 'kpc';
14
14
  ev-ok={this.ok}
15
15
  ev-cancel={this.cancel}
16
16
  ref="popover1"
17
+ size="small"
17
18
  >
18
19
  <Button>删除</Button>
19
20
  </Popover>
@@ -10,6 +10,9 @@ const defaults = {
10
10
  fontSize: '14px',
11
11
  lineHeight: '20px',
12
12
  fontWeight: 500,
13
+ },
14
+ small: {
15
+ width: '240px',
13
16
  }
14
17
  };
15
18
 
@@ -41,5 +44,10 @@ export default function makeStyles(k: string) {
41
44
  .${k}-tooltip-footer {
42
45
  text-align: right;
43
46
  }
47
+ &.${k}-small {
48
+ padding: ${popover.padding};
49
+ width: ${popover.small.width};
50
+ }
51
+ }
44
52
  `;
45
53
  }
@@ -16,7 +16,7 @@ describe('Collapse', function () {
16
16
  case 0:
17
17
  this.timeout(0);
18
18
  _mount = mount(BasicDemo), instance = _mount[0], element = _mount[1];
19
- _element$querySelecto = element.querySelectorAll('.k-collapse-title'), title1 = _element$querySelecto[0], title2 = _element$querySelecto[1], title3 = _element$querySelecto[2];
19
+ _element$querySelecto = element.querySelectorAll(':scope > .k-collapse-title'), title1 = _element$querySelecto[0], title2 = _element$querySelecto[1], title3 = _element$querySelecto[2];
20
20
  title2.click();
21
21
  _context.next = 6;
22
22
  return wait(500);
@@ -1362,4 +1362,47 @@ describe('Form', function () {
1362
1362
  }
1363
1363
  }, _callee8);
1364
1364
  })));
1365
+ it('should validate on init when setting validateOnStart prop', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
1366
+ var Demo, _mount9, instance, element;
1367
+
1368
+ return _regeneratorRuntime.wrap(function _callee9$(_context13) {
1369
+ while (1) {
1370
+ switch (_context13.prev = _context13.next) {
1371
+ case 0:
1372
+ Demo = /*#__PURE__*/function (_Component4) {
1373
+ _inheritsLoose(Demo, _Component4);
1374
+
1375
+ function Demo() {
1376
+ var _context12;
1377
+
1378
+ var _this4;
1379
+
1380
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
1381
+ args[_key4] = arguments[_key4];
1382
+ }
1383
+
1384
+ _this4 = _Component4.call.apply(_Component4, _concatInstanceProperty(_context12 = [this]).call(_context12, args)) || this;
1385
+ _this4.Form = Form;
1386
+ _this4.FormItem = FormItem;
1387
+ return _this4;
1388
+ }
1389
+
1390
+ return Demo;
1391
+ }(Component);
1392
+
1393
+ Demo.template = "\n const {Form, FormItem} = this;\n <Form ref=\"form\">\n <FormItem rules={{required: true}} validateOnStart />\n </Form>\n ";
1394
+ _mount9 = mount(Demo), instance = _mount9[0], element = _mount9[1];
1395
+ _context13.next = 5;
1396
+ return wait(500);
1397
+
1398
+ case 5:
1399
+ expect(element.querySelector('.k-form-error')).to.be.exist;
1400
+
1401
+ case 6:
1402
+ case "end":
1403
+ return _context13.stop();
1404
+ }
1405
+ }
1406
+ }, _callee9);
1407
+ })));
1365
1408
  });
@@ -10,6 +10,7 @@ export interface FormItemProps {
10
10
  htmlFor?: string;
11
11
  hideLabel?: boolean;
12
12
  fluid?: boolean;
13
+ validateOnStart?: boolean;
13
14
  }
14
15
  export interface FormItemEvents {
15
16
  change: [Event];
@@ -24,7 +24,8 @@ var typeDefs = {
24
24
  label: String,
25
25
  htmlFor: String,
26
26
  hideLabel: Boolean,
27
- fluid: Boolean
27
+ fluid: Boolean,
28
+ validateOnStart: Boolean
28
29
  };
29
30
  export var FormItem = /*#__PURE__*/function (_Component) {
30
31
  _inheritsLoose(FormItem, _Component);
@@ -4,6 +4,10 @@ export function useDirty(getValidate) {
4
4
  var instance = useInstance();
5
5
  var isDirty = useState(false);
6
6
 
7
+ if (instance.get('validateOnStart')) {
8
+ dirty();
9
+ }
10
+
7
11
  function onChange(e) {
8
12
  dirty();
9
13
  instance.trigger('change', e);
@@ -139,7 +139,7 @@ export function makeStyles(k) {
139
139
  return /*#__PURE__*/css("&.", k, "-", size, "{", sizeClassName, ";}");
140
140
  }), "&.", k, "-inline{.", k, "-input-wrapper{height:auto;border:none;border-radius:0;padding:0;}}&.", k, "-type-textarea{.", k, "-input-wrapper{display:inline-block;padding:0;height:auto;}.", k, "-textarea{width:100%;padding:", input.textareaPadding, ";line-height:1.5;vertical-align:top;}.", k, "-input-suffix{margin:0;justify-content:flex-end;}}", _mapInstanceProperty(_context = Input.typeDefs.resize).call(_context, function (type) {
141
141
  return /*#__PURE__*/css("&.", k, "-resize-", type, "{.", k, "-textarea{resize:", type, ";}}");
142
- }), ".", k, "-input-fake{left:0;top:0;right:0;position:absolute;overflow:hidden;width:100%;visibility:hidden;white-space:nowrap;}&.", k, "-auto-width{width:auto;max-width:100%;}.", k, "-input-count{color:", input.count.color, ";}");
142
+ }), ".", k, "-input-fake{left:0;top:0;position:absolute;overflow:hidden;visibility:hidden;white-space:nowrap;}&.", k, "-auto-width{width:auto;max-width:100%;}.", k, "-input-count{color:", input.count.color, ";}");
143
143
  }
144
144
  export function makeSearchStyles(k) {
145
145
  return /*#__PURE__*/css("position:relative;display:inline-block;.", k, "-input{transition:width ", input.transition, ";}.", k, "-btn{position:absolute;top:0;right:0;z-index:1;}&.", k, "-default .", k, "-btn:hover{background:transparent;}.", k, "-input-suffix{margin-right:", input.search.suffixMarginRight, ";}&.", k, "-hide{", _mapInstanceProperty(sizes).call(sizes, function (size) {
@@ -9,6 +9,9 @@ var defaults = {
9
9
  fontSize: '14px',
10
10
  lineHeight: '20px',
11
11
  fontWeight: 500
12
+ },
13
+ small: {
14
+ width: '240px'
12
15
  }
13
16
  };
14
17
  var popover;
@@ -18,5 +21,5 @@ setDefault(function () {
18
21
  }).popover;
19
22
  });
20
23
  export default function makeStyles(k) {
21
- return /*#__PURE__*/css("&.", k, "-tooltip-content.", k, "-popover{width:", popover.width, ";padding:", popover.padding, ";.", k, "-popover-title{display:flex;align-items:center;font-size:", popover.title.fontSize, ";line-height:", popover.title.lineHeight, ";font-weight:", popover.title.fontWeight, ";}.", k, "-popover-icon{margin-right:", popover.gap, ";}.", k, "-popover-content{margin-top:", popover.gap, ";}.", k, "-tooltip-footer{text-align:right;}}");
24
+ return /*#__PURE__*/css("&.", k, "-tooltip-content.", k, "-popover{width:", popover.width, ";padding:", popover.padding, ";.", k, "-popover-title{display:flex;align-items:center;font-size:", popover.title.fontSize, ";line-height:", popover.title.lineHeight, ";font-weight:", popover.title.fontWeight, ";}.", k, "-popover-icon{margin-right:", popover.gap, ";}.", k, "-popover-content{margin-top:", popover.gap, ";}.", k, "-tooltip-footer{text-align:right;}&.", k, "-small{padding:", popover.padding, ";width:", popover.small.width, ";}}");
22
25
  }
package/es/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v3.1.1-beta.2
2
+ * @king-design v3.1.1
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -60,4 +60,4 @@ export * from './components/tree';
60
60
  export * from './components/treeSelect';
61
61
  export * from './components/upload';
62
62
  export * from './components/wave';
63
- export declare const version = "3.1.1-beta.2";
63
+ export declare const version = "3.1.1";
package/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v3.1.1-beta.2
2
+ * @king-design v3.1.1
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -62,5 +62,5 @@ export * from './components/tree';
62
62
  export * from './components/treeSelect';
63
63
  export * from './components/upload';
64
64
  export * from './components/wave';
65
- export var version = '3.1.1-beta.2';
65
+ export var version = '3.1.1';
66
66
  /* generate end */
@@ -41,7 +41,8 @@ var Demo = /*#__PURE__*/function (_React$Component) {
41
41
  onCancel: this.cancel,
42
42
  ref: function ref(i) {
43
43
  return _this2.popover1 = i;
44
- }
44
+ },
45
+ size: "small"
45
46
  }, /*#__PURE__*/React.createElement(Button, null, "\u5220\u9664")), ' ', /*#__PURE__*/React.createElement(Popover, {
46
47
  title: "\u786E\u5B9A\u5220\u9664\uFF1F",
47
48
  content: "\u8FD9\u662F\u4E00\u6BB5\u63CF\u8FF0\u6587\u5B57",
package/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v3.1.1-beta.2
2
+ * @king-design v3.1.1
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -65,6 +65,6 @@ export * from './components/treeSelect';
65
65
  export * from './components/upload';
66
66
  export * from './components/wave';
67
67
 
68
- export const version = '3.1.1-beta.2';
68
+ export const version = '3.1.1';
69
69
 
70
70
  /* generate end */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@king-design/intact",
3
- "version": "3.1.1-beta.2",
3
+ "version": "3.1.1",
4
4
  "description": "A component library written in Intact for Intact, Vue, React and Angular",
5
5
  "main": "es/index.js",
6
6
  "engines": {
@@ -179,7 +179,7 @@
179
179
  "dependencies": {
180
180
  "@babel/runtime-corejs3": "^7.16.0",
181
181
  "@emotion/css": "^11.5.0",
182
- "@king-design/react": "^3.1.1-beta.2",
182
+ "@king-design/react": "^3.1.1",
183
183
  "dayjs": "^1.10.7",
184
184
  "enquire.js": "^2.1.6",
185
185
  "intact": "^3.0.19",