@king-design/react 3.1.2 → 3.1.4-beta.0

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.
@@ -17,13 +17,12 @@ describe('Cascader', () => {
17
17
 
18
18
  it('should hide all menu on selected', async () => {
19
19
  function App() {
20
- const [value, setValue] = useState<string[][]>([]);
20
+ const [value, setValue] = useState<string[]>([]);
21
21
  return (
22
22
  <div>
23
23
  <Cascader
24
24
  data={[{value: 'a', label: 'a', children: [{value: 'b', label: 'b'}]}]}
25
25
  value={value}
26
- multiple
27
26
  filterable
28
27
  onChangeValue={(v) => {
29
28
  setValue(v!);
@@ -60,7 +60,7 @@ export default function ($props, $blocks, $__proto__) {
60
60
  });
61
61
  }
62
62
 
63
- var classNameObj = (_classNameObj = {}, _classNameObj[cls('btn')] = true, _classNameObj[cls(type)] = type !== 'default', _classNameObj[cls(size)] = size !== 'default', _classNameObj[cls("btn-icon")] = icon, _classNameObj[className] = className, _classNameObj[cls('circle')] = circle, _classNameObj[cls('loading')] = loading, _classNameObj[cls('fluid')] = fluid, _classNameObj[cls('active')] = checked, _classNameObj[cls('disabled')] = disabled || loading, _classNameObj[cls('ghost')] = ghost, _classNameObj[makeButtonStyles(k, iconSide)] = true, _classNameObj);
63
+ var classNameObj = (_classNameObj = {}, _classNameObj[cls('btn')] = true, _classNameObj[cls(size)] = size !== 'default', _classNameObj[cls(type)] = true, _classNameObj[cls("btn-icon")] = icon, _classNameObj[className] = className, _classNameObj[cls('circle')] = circle, _classNameObj[cls('loading')] = loading, _classNameObj[cls('fluid')] = fluid, _classNameObj[cls('active')] = checked, _classNameObj[cls('disabled')] = disabled || loading, _classNameObj[cls('ghost')] = ghost, _classNameObj[makeButtonStyles(k, iconSide)] = true, _classNameObj);
64
64
 
65
65
  var loadingIcon = _$cc(Icon, {
66
66
  'className': _$cn("ion-load-c " + k + "-icon-loading"),
@@ -242,16 +242,16 @@ export var makeButtonStyles = cache(function makeButtonStyles(k, iconSide) {
242
242
  return cx(
243
243
  /*#__PURE__*/
244
244
  // extract static styles to individual css method for performance
245
- css("display:inline-flex;align-items:center;justify-content:center;cursor:pointer;height:", button.height, ";padding:", button.padding, ";outline:none;vertical-align:middle;color:", button.color, ";background:", button.bgColor, ";border-radius:", button.borderRadius, ";border:1px solid ", button.borderColor, ";font-size:", button.fontSize, ";white-space:nowrap;transition:all ", button.transition, ";line-height:", button.lineHeight, ";.", k, "-icon{color:inherit;}&:hover,&:focus{border-color:", button.hoverBorderColor, ";color:", button.hoverColor, ";}&:active{background:", palette(theme.color.primary, -4), ";}.", k, "-button-input{position:absolute;opacity:0;width:0;height:0;}", _mapInstanceProperty(types).call(types, function (type) {
245
+ css("display:inline-flex;align-items:center;justify-content:center;cursor:pointer;height:", button.height, ";padding:", button.padding, ";outline:none;vertical-align:middle;color:", button.color, ";background:", button.bgColor, ";border-radius:", button.borderRadius, ";border:1px solid ", button.borderColor, ";font-size:", button.fontSize, ";white-space:nowrap;transition:all ", button.transition, ";line-height:", button.lineHeight, ";.", k, "-icon{color:inherit;}&.", k, "-default,&.", k, "-none,&.", k, "-flat{.", k, "-icon{color:", theme.color.lightBlack, ";}&:hover{.", k, "-icon{color:inherit;}}}&:hover,&:focus{border-color:", button.hoverBorderColor, ";color:", button.hoverColor, ";}&:active{background:", palette(theme.color.primary, -4), ";}.", k, "-button-input{position:absolute;opacity:0;width:0;height:0;}", _mapInstanceProperty(types).call(types, function (type) {
246
246
  var typeStyles = button[type];
247
247
  return /*#__PURE__*/css("&.", k, "-", type, "{background:", typeStyles.bgColor, ";color:", typeStyles.color, ";border-color:", typeStyles.borderColor, ";&:hover,&:focus{background:", palette(typeStyles.bgColor, -1), ";border-color:", typeStyles.hoverBorderColor, ";color:", typeStyles.color, ";}&:active{background:", palette(typeStyles.bgColor, 1), ";border-color:", palette(typeStyles.borderColor, 1), ";}}");
248
- }), "&.", k, "-secondary{color:", secondary.color, ";border-color:", secondary.borderColor, ";&:hover,&:focus{background:", secondary.hoverBgColor, ";}&:active{background:", secondary.activeBgColor, ";}}&.", k, "-link{color:", link.color, ";&:hover{color:", link.hoverColor, ";background:", link.hoverBgColor, ";}}&.", k, "-none,&.", k, "-link,&.", k, "-flat{background:transparent;&,&:hover{border:none;}&.", k, "-active{color:", theme.color.primary, ";}}&.", k, "-none:hover{background:", button.none.hoverBgColor, ";}&.", k, "-flat{background:", button.none.hoverBgColor, ";}&.", k, "-disabled{&,&:hover{color:", button.disabled.color, ";background:", button.disabled.bgColor, ";border-color:", button.disabled.borderColor, ";cursor:not-allowed;}}&.", k, "-none.", k, "-disabled,&.", k, "-link.", k, "-disabled{&,&:hover{background:transparent;}}", _mapInstanceProperty(sizes).call(sizes, function (size) {
248
+ }), "&.", k, "-secondary{color:", secondary.color, ";border-color:", secondary.borderColor, ";&:hover,&:focus{background:", secondary.hoverBgColor, ";}&:active{background:", secondary.activeBgColor, ";}}&.", k, "-link{color:", link.color, ";&:hover{color:", link.hoverColor, ";background:", link.hoverBgColor, ";}}&.", k, "-none,&.", k, "-link,&.", k, "-flat{background:transparent;&,&:hover{border:none;}&.", k, "-active{color:", theme.color.primary, ";}}&.", k, "-none:hover{background:", button.none.hoverBgColor, ";}&.", k, "-flat{background:", button.none.hoverBgColor, ";}&.", k, "-disabled{.", k, "-icon{color:inherit;}&,&:hover{color:", button.disabled.color, ";background:", button.disabled.bgColor, ";border-color:", button.disabled.borderColor, ";cursor:not-allowed;}}&.", k, "-none.", k, "-disabled,&.", k, "-link.", k, "-disabled{&,&:hover{background:transparent;}}", _mapInstanceProperty(sizes).call(sizes, function (size) {
249
249
  var styles = button[size];
250
250
  return /*#__PURE__*/css("&.", k, "-", size, "{font-size:", styles.fontSize, ";height:", styles.height, ";padding:", styles.padding, ";&.", k, "-btn-icon{width:", styles.height, ";}}");
251
251
  }), "&.", k, "-btn-icon{width:", button.height, ";padding:0;.", k, "-icon{margin:0;}}&.", k, "-fluid{width:100%;padding:0;}&.", k, "-circle{border-radius:calc(", button.large.height, " / 2);}&.", k, "-loading{", _mapInstanceProperty(types).call(types, function (type) {
252
252
  var styles = button[type];
253
253
  return /*#__PURE__*/css("&.", k, "-", type, "{&,&:hover{background:", palette(styles.bgColor, -2), ";color:", palette(styles.color, -2), ";border-color:", palette(styles.borderColor, -2), ";}}");
254
- }), ";&,&:hover{background:", palette(button.bgColor, -2), ";color:", palette(button.color, -2), ";border-color:", palette(button.borderColor, -2), ";}.", k, "-icon:not(.", k, "-icon-loading){display:none;}}&:not(button){display:inline-flex;align-items:center;justify-content:center;}&.", k, "-ghost{background:transparent;color:", button.ghost.color, ";border-color:", button.ghost.borderColor, ";&:hover,&:active{background:transparent;}&:hover{color:", button.ghost.hoverColor, ";border-color:", button.ghost.hoverBorderColor, ";}&:active{color:", theme.color.primary, ";border-color:", theme.color.primary, ";}", _mapInstanceProperty(types).call(types, function (type) {
254
+ }), ";&,&:hover{background:", palette(button.bgColor, -2), ";color:", palette(button.color, -2), ";border-color:", palette(button.borderColor, -2), ";}.", k, "-icon:not(.", k, "-icon-loading){display:none;}}&:not(button){display:inline-flex;align-items:center;justify-content:center;}&.", k, "-ghost{background:transparent;color:", button.ghost.color, ";border-color:", button.ghost.borderColor, ";.", k, "-icon{color:inherit;}&:hover,&:active{background:transparent;}&:hover{color:", button.ghost.hoverColor, ";border-color:", button.ghost.hoverBorderColor, ";}&:active{color:", theme.color.primary, ";border-color:", theme.color.primary, ";}", _mapInstanceProperty(types).call(types, function (type) {
255
255
  var _button$type = button[type],
256
256
  ghostColor = _button$type.ghostColor,
257
257
  borderColor = _button$type.borderColor;
@@ -27,7 +27,7 @@ export default function ($props, $blocks, $__proto__) {
27
27
  var classNameObj = (_classNameObj = {}, _classNameObj[k + "-collapse-item"] = true, _classNameObj[makeItemStyles(k)] = true, _classNameObj[className] = className, _classNameObj[k + "-active"] = isActive, _classNameObj[k + "-disabled"] = disabled, _classNameObj);
28
28
  return _$cv('div', _extends({
29
29
  'className': _$cn(classNameObj)
30
- }, getRestProps(this)), [_$ce(2, 'div', [(_$blocks['title'] = function ($super) {
30
+ }, getRestProps(this)), [_$ce(2, 'div', [_$ce(2, 'div', (_$blocks['title'] = function ($super) {
31
31
  return title;
32
32
  }, __$blocks['title'] = function ($super, data) {
33
33
  var block = $blocks['title'];
@@ -37,11 +37,11 @@ export default function ($props, $blocks, $__proto__) {
37
37
  };
38
38
 
39
39
  return block ? block.call($this, callBlock, data) : callBlock();
40
- }, __$blocks['title'](_$no)), _$cc(Icon, {
40
+ }, __$blocks['title'](_$no)), 0, _$cn(k + "-collapse-title-wrapper")), _$cc(Icon, {
41
41
  'className': _$cn((_$cn2 = {}, _$cn2[k + "-collapse-arrow"] = true, _$cn2[k + "-icon-right"] = true, _$cn2)),
42
42
  'hoverable': true,
43
43
  'disabled': disabled
44
- })], 0, _$cn(k + "-collapse-title"), {
44
+ })], 4, _$cn(k + "-collapse-title"), {
45
45
  'ev-click': this.toggle
46
46
  }), _$cc(Transition, _extends({
47
47
  'show': isActive
@@ -9,7 +9,6 @@ var defaults = {
9
9
  },
10
10
 
11
11
  fontSize: '12px',
12
- titleMarginRight: '8px',
13
12
  borderPadding: '0 24px',
14
13
  collBorder: '1px solid #eee',
15
14
 
@@ -19,7 +18,8 @@ var defaults = {
19
18
 
20
19
  item: {
21
20
  borderBottom: '1px solid #e5e5e5',
22
- titleHeight: '40px'
21
+ titleHeight: '40px',
22
+ titleGap: '8px'
23
23
  }
24
24
  };
25
25
  var collapse;
@@ -31,9 +31,9 @@ setDefault(function () {
31
31
  makeItemStyles == null ? void 0 : makeItemStyles.clearCache();
32
32
  });
33
33
  export var makeStyles = cache(function makeStyles(k) {
34
- return /*#__PURE__*/css("font-size:", collapse.fontSize, ";&.", k, "-left{.", k, "-collapse-arrow{float:left;margin-right:", collapse.titleMarginRight, ";}}&.", k, "-border{border-radius:", collapse.borderRadius, ";padding:", collapse.borderPadding, ";border:", collapse.collBorder, ";}");
34
+ return /*#__PURE__*/css("font-size:", collapse.fontSize, ";&.", k, "-left{>.", k, "-collapse-item>.", k, "-collapse-title{flex-direction:row-reverse;}}&.", k, "-border{border-radius:", collapse.borderRadius, ";padding:", collapse.borderPadding, ";border:", collapse.collBorder, ";}");
35
35
  });
36
36
  export var makeItemStyles = cache(function makeItemStyles(k) {
37
37
  var collapseItem = collapse.item;
38
- return /*#__PURE__*/css("border-bottom:", collapseItem.borderBottom, ";&:last-of-type{border-bottom-color:transparent;}>.", k, "-collapse-title{cursor:pointer;font-weight:bold;height:", collapseItem.titleHeight, ";line-height:", collapseItem.titleHeight, ";transition:color ", collapse.transition, ";.", k, "-collapse-arrow{float:right;transition:transform ", collapse.transition, ";line-height:", collapseItem.titleHeight, ";height:", collapseItem.titleHeight, ";}}&:not(.", k, "-disabled){>.", k, "-collapse-title{&:hover{color:", theme.color.primary, ";}}}&.", k, "-active{>.", k, "-collapse-title .", k, "-collapse-arrow{transform:rotate(90deg);}}&.", k, "-disabled{color:", theme.color.disabledBorder, ";>.", k, "-collapse-title{cursor:not-allowed;}}");
38
+ return /*#__PURE__*/css("border-bottom:", collapseItem.borderBottom, ";&:last-of-type{border-bottom-color:transparent;}>.", k, "-collapse-title{cursor:pointer;font-weight:bold;height:", collapseItem.titleHeight, ";transition:color ", collapse.transition, ";display:flex;align-items:center;gap:", collapseItem.titleGap, ";.", k, "-collapse-title-wrapper{flex:1;}.", k, "-collapse-arrow{transition:transform ", collapse.transition, ";}}&:not(.", k, "-disabled){>.", k, "-collapse-title{&:hover{color:", theme.color.primary, ";}}}&.", k, "-active{>.", k, "-collapse-title .", k, "-collapse-arrow{transform:rotate(90deg);}}&.", k, "-disabled{color:", theme.color.disabledBorder, ";>.", k, "-collapse-title{cursor:not-allowed;}}");
39
39
  });
@@ -10,7 +10,7 @@ export * from './shapes/rectangle';
10
10
  export * from './shapes/square';
11
11
  export * from './shapes/text';
12
12
  export * from './shapes/line';
13
- declare const DDiamond: import("misstime").ComponentConstructor<import("./shapes/shape").DShape<import("./shapes/shape").DShapeProps>>, DTriangle: import("misstime").ComponentConstructor<import("./shapes/shape").DShape<import("./shapes/shape").DShapeProps>>, DCylinder: import("misstime").ComponentConstructor<import("./shapes/shape").DShape<import("./shapes/shape").DShapeProps>>, DCloud: import("misstime").ComponentConstructor<import("./shapes/shape").DShape<import("./shapes/shape").DShapeProps>>;
13
+ declare const DDiamond: import("vdt").ComponentConstructor<import("./shapes/shape").DShape<import("./shapes/shape").DShapeProps>>, DTriangle: import("vdt").ComponentConstructor<import("./shapes/shape").DShape<import("./shapes/shape").DShapeProps>>, DCylinder: import("vdt").ComponentConstructor<import("./shapes/shape").DShape<import("./shapes/shape").DShapeProps>>, DCloud: import("vdt").ComponentConstructor<import("./shapes/shape").DShape<import("./shapes/shape").DShapeProps>>;
14
14
  export { DDiamond, DTriangle, DCylinder, DCloud };
15
15
  export * from './layouts/layout';
16
16
  export * from './layouts/circle';
@@ -7,7 +7,7 @@ import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
7
7
 
8
8
  function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
9
 
10
- function _unsupportedIterableToArray(o, minLen) { var _context21; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context21 = Object.prototype.toString.call(o)).call(_context21, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
+ function _unsupportedIterableToArray(o, minLen) { var _context23; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context23 = Object.prototype.toString.call(o)).call(_context23, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
11
11
 
12
12
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
13
13
 
@@ -732,6 +732,66 @@ describe('Dialog', function () {
732
732
  }
733
733
  }
734
734
  }, _callee14);
735
+ })));
736
+ it('should update position when change container', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15() {
737
+ var Demo, _mount15, instance, element, dialogDom, style;
738
+
739
+ return _regeneratorRuntime.wrap(function _callee15$(_context22) {
740
+ while (1) {
741
+ switch (_context22.prev = _context22.next) {
742
+ case 0:
743
+ Demo = /*#__PURE__*/function (_Component7) {
744
+ _inheritsLoose(Demo, _Component7);
745
+
746
+ function Demo() {
747
+ var _context21;
748
+
749
+ var _this7;
750
+
751
+ for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
752
+ args[_key7] = arguments[_key7];
753
+ }
754
+
755
+ _this7 = _Component7.call.apply(_Component7, _concatInstanceProperty(_context21 = [this]).call(_context21, args)) || this;
756
+ _this7.Dialog = Dialog;
757
+ return _this7;
758
+ }
759
+
760
+ Demo.defaults = function defaults() {
761
+ return {
762
+ container: function container(parentDom) {
763
+ return parentDom;
764
+ }
765
+ };
766
+ };
767
+
768
+ return Demo;
769
+ }(Component);
770
+
771
+ Demo.template = "\n var Dialog = this.Dialog;\n <Dialog value={true} container={this.get('container')} ref=\"dialog\">test</Dialog>\n ";
772
+ _mount15 = mount(Demo), instance = _mount15[0], element = _mount15[1];
773
+ _context22.next = 5;
774
+ return wait();
775
+
776
+ case 5:
777
+ instance.set('container', undefined);
778
+ _context22.next = 8;
779
+ return wait();
780
+
781
+ case 8:
782
+ dialogDom = instance.refs.dialog.dialogRef.value;
783
+ style = dialogDom.style;
784
+ expect(style.left).not.eql('');
785
+ expect(style.top).not.eql(''); // should append to body
786
+
787
+ expect(dialogDom.closest('.k-dialog-wrapper').parentElement).to.eql(document.body);
788
+
789
+ case 13:
790
+ case "end":
791
+ return _context22.stop();
792
+ }
793
+ }
794
+ }, _callee15);
735
795
  }))); // it('should handle v-if and v-model at the same time correctly in Vue', async () => {
736
796
  // const Test = {
737
797
  // template: `<Dialog v-model="show" v-if="show" ref="dialog">test</Dialog>`,
@@ -5,6 +5,13 @@ export function usePosition(elementRef) {
5
5
  var instance = useInstance();
6
6
  instance.on(SHOW, center);
7
7
  instance.on('afterClose', onAfterLeave);
8
+ instance.watch('container', function () {
9
+ if (!instance.get('value')) return;
10
+ center();
11
+ }, {
12
+ presented: true,
13
+ inited: true
14
+ });
8
15
 
9
16
  function center() {
10
17
  position(elementRef.value, {
@@ -1,8 +1,7 @@
1
1
  import _extends from "@babel/runtime-corejs3/helpers/extends";
2
2
  import { useInstance, findDomFromVNode } from 'intact-react';
3
3
  import { position } from '../position';
4
- import { noop } from 'intact-shared';
5
- import { isObject } from 'intact-shared';
4
+ import { noop, isObject, isFunction } from 'intact-shared';
6
5
  import { isEqualObject } from '../utils';
7
6
  export function usePosition() {
8
7
  var instance = useInstance();
@@ -16,19 +15,23 @@ export function usePosition() {
16
15
  });
17
16
  ['of', 'position'].forEach(function (item) {
18
17
  instance.watch(item, function (newValue, oldValue) {
19
- // return if object is the same
20
- if (isObject(newValue) && isObject(oldValue) && // is not event object
21
- !(newValue instanceof Event) && isEqualObject(newValue, oldValue)) {
22
- return;
23
- }
24
-
25
- if (instance.get('value')) {
26
- handle(noop);
27
- }
18
+ if (!instance.get('value') || // return if object is the same
19
+ isObject(newValue) && isObject(oldValue) && // is not event object
20
+ !(newValue instanceof Event) && isEqualObject(newValue, oldValue)) return;
21
+ handle(noop);
28
22
  }, {
29
23
  presented: true,
30
24
  inited: true
31
25
  });
26
+ }); // watch container, it is not commonly used
27
+
28
+ instance.watch('container', function (newValue, oldValue) {
29
+ if (!instance.get('value') || // return if function is the same. Not rigorous!
30
+ isFunction(newValue) && isFunction(oldValue) && newValue.toString() === oldValue.toString()) return;
31
+ handle(noop);
32
+ }, {
33
+ presented: true,
34
+ inited: true
32
35
  }); // if the dropdown is nested, we must show child after parent has positioned
33
36
 
34
37
  function p(ofElement, parentFeedback) {
@@ -22,5 +22,5 @@ setDefault(function () {
22
22
  });
23
23
  export { editable };
24
24
  export var makeStyles = cache(function makeStyles(k) {
25
- return /*#__PURE__*/css("display:inline-flex;align-items:center;.", k, "-editable-icon{margin:", editable.iconGap, ";}&.", k, "-invalid{.", k, "-input-inner{border:", editable.invalid.border, "!important;}}");
25
+ return /*#__PURE__*/css("display:inline-flex;align-items:center;.", k, "-editable-icon{margin:", editable.iconGap, ";}&.", k, "-invalid{.", k, "-input-wrapper{border:", editable.invalid.border, "!important;}}");
26
26
  });
@@ -10,6 +10,7 @@ export declare class Message extends Component<MessageProps> {
10
10
  static template: string | import('intact-react').Template<any>;
11
11
  static typeDefs: Required<TypeDefs<MessageProps>>;
12
12
  static defaults: () => Partial<MessageProps>;
13
+ static classNamePrefix: string;
13
14
  static notice(content: Children | Partial<MessageProps>, duration?: number, type?: MessageProps['type']): void;
14
15
  static info(content: Children | Partial<MessageProps>, duration?: number): void;
15
16
  static error(content: Children | Partial<MessageProps>, duration?: number): void;
@@ -54,16 +54,6 @@ export var Message = /*#__PURE__*/function (_Component) {
54
54
  type = 'info';
55
55
  }
56
56
 
57
- if (!messages) {
58
- var container = document.createElement('div');
59
- document.body.append(container);
60
- render(h(Messages, {
61
- ref: function ref(i) {
62
- return messages = i;
63
- }
64
- }), container);
65
- }
66
-
67
57
  if (isObject(content) && !content.tag) {
68
58
  content = _extends({}, content, {
69
59
  type: type,
@@ -78,6 +68,17 @@ export var Message = /*#__PURE__*/function (_Component) {
78
68
  };
79
69
  }
80
70
 
71
+ if (!messages) {
72
+ var container = document.createElement('div');
73
+ document.body.append(container);
74
+ render(h(Messages, {
75
+ ref: function ref(i) {
76
+ return messages = i;
77
+ },
78
+ classNamePrefix: Message.classNamePrefix
79
+ }), container);
80
+ }
81
+
81
82
  messages.notice(h(Message, content));
82
83
  };
83
84
 
@@ -108,5 +109,6 @@ export var Message = /*#__PURE__*/function (_Component) {
108
109
  Message.template = template;
109
110
  Message.typeDefs = typeDefs;
110
111
  Message.defaults = defaults;
112
+ Message.classNamePrefix = void 0;
111
113
 
112
114
  __decorate([bind], Message.prototype, "close", null);
@@ -16,7 +16,8 @@ export default function ($props, $blocks, $__proto__) {
16
16
  content = _this$get.content,
17
17
  children = _this$get.children,
18
18
  closable = _this$get.closable,
19
- hideIcon = _this$get.hideIcon;
19
+ hideIcon = _this$get.hideIcon,
20
+ classNamePrefix = _this$get.classNamePrefix;
20
21
 
21
22
  var k = this.config.k;
22
23
  var classNameObj = (_classNameObj = {}, _classNameObj[k + "-message"] = true, _classNameObj[k + "-" + type] = type, _classNameObj[makeMessageStyles(k)] = true, _classNameObj);
@@ -1,7 +1,11 @@
1
- import { Component, VNodeComponentClass } from 'intact-react';
1
+ import { Component, VNodeComponentClass, TypeDefs } from 'intact-react';
2
2
  import type { Message } from './message';
3
+ export interface MessagesProps {
4
+ classNamePrefix?: string;
5
+ }
3
6
  export declare class Messages extends Component {
4
7
  static template: string | import('intact-react').Template<any>;
8
+ static typeDefs: Required<TypeDefs<MessagesProps>>;
5
9
  private messages;
6
10
  private config;
7
11
  notice(message: VNodeComponentClass<Message>): void;
@@ -5,6 +5,9 @@ import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/spl
5
5
  import { Component } from 'intact-react';
6
6
  import template from './messages.vdt';
7
7
  import { useConfigContext } from '../config';
8
+ var typeDefs = {
9
+ classNamePrefix: String
10
+ };
8
11
  export var Messages = /*#__PURE__*/function (_Component) {
9
12
  _inheritsLoose(Messages, _Component);
10
13
 
@@ -48,4 +51,5 @@ export var Messages = /*#__PURE__*/function (_Component) {
48
51
 
49
52
  return Messages;
50
53
  }(Component);
51
- Messages.template = template;
54
+ Messages.template = template;
55
+ Messages.typeDefs = typeDefs;
@@ -1,17 +1,23 @@
1
- import { createElementVNode as _$ce, createUnknownComponentVNode as _$cc, map as _$ma, className as _$cn } from 'intact-react';
1
+ import { createUnknownComponentVNode as _$cc, createElementVNode as _$ce, map as _$ma, className as _$cn } from 'intact-react';
2
2
  import { TransitionGroup, Transition } from 'intact-react';
3
3
  import { makeMessagesStyles } from './styles';
4
+ import { ConfigProvider } from '../config';
4
5
  export default function ($props, $blocks, $__proto__) {
5
6
  var _$cn2;
6
7
 
7
8
  $blocks || ($blocks = {});
8
9
  $props || ($props = {});
9
10
  var $this = this;
10
- var k = this.config.k;
11
- return _$ce(2, 'div', _$cc(TransitionGroup, {
12
- 'children': _$ma(this.messages, function ($value, $key) {
13
- return $value;
14
- }, $this)
15
- }), 2, _$cn((_$cn2 = {}, _$cn2[k + "-messages"] = true, _$cn2[makeMessagesStyles(k)] = true, _$cn2)));
11
+ var k = this.get('classNamePrefix') || this.config.k;
12
+ return _$cc(ConfigProvider, {
13
+ 'value': {
14
+ classNamePrefix: k
15
+ },
16
+ 'children': _$ce(2, 'div', _$cc(TransitionGroup, {
17
+ 'children': _$ma(this.messages, function ($value, $key) {
18
+ return $value;
19
+ }, $this)
20
+ }), 2, _$cn((_$cn2 = {}, _$cn2[k + "-messages"] = true, _$cn2[makeMessagesStyles(k)] = true, _$cn2)))
21
+ });
16
22
  }
17
23
  ;
@@ -1,6 +1,6 @@
1
1
  import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
2
2
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
3
- import { Component, createCommentVNode, createTextVNode, mount, patch, remove, inject } from 'intact-react';
3
+ import { Component, createCommentVNode, createTextVNode, mount, patch, remove, inject, unmount, removeVNodeDom } from 'intact-react';
4
4
  import { isString } from 'intact-shared';
5
5
  import { DIALOG } from './dialog/constants';
6
6
  import { BaseDialog } from './dialog/base';
@@ -51,7 +51,9 @@ export var Portal = /*#__PURE__*/function (_Component) {
51
51
  var nextProps = nextVNode.props;
52
52
  var fakeContainer = document.createDocumentFragment();
53
53
  (mountedQueue.priority || mountedQueue).push(function () {
54
- var parentDom = _this2.$lastInput.dom.parentElement;
54
+ var parentDom = _this2.$lastInput.dom.parentElement; // maybe the <!-- portal --> has been removed by react, #938
55
+
56
+ if (!parentDom) return;
55
57
 
56
58
  _this2.initContainer(nextProps.container, parentDom, anchor);
57
59
 
@@ -97,7 +99,14 @@ export var Portal = /*#__PURE__*/function (_Component) {
97
99
  };
98
100
 
99
101
  _proto.$unmount = function $unmount(vNode, nextVNode) {
100
- remove(vNode.props.children, this.container, false); // removeVNodeDom(vNode.props!.children as VNode, this.container!);
102
+ var children = vNode.props.children;
103
+ unmount(children, null);
104
+
105
+ if (this.container) {
106
+ // maybe the <!-- portal --> has been removed by react, #938
107
+ // remove(children, this.container, false);
108
+ removeVNodeDom(children, this.container);
109
+ }
101
110
 
102
111
  _Component.prototype.$unmount.call(this, vNode, nextVNode);
103
112
  };
@@ -109,6 +118,9 @@ export var Portal = /*#__PURE__*/function (_Component) {
109
118
  } else {
110
119
  this.container = container(parentDom, anchor);
111
120
  }
121
+ } else {
122
+ // let below logic to set container to default if container does not exist.
123
+ this.container = null;
112
124
  }
113
125
 
114
126
  if (!this.container) {
@@ -1,5 +1,5 @@
1
1
  export declare const context: {
2
- Provider: import("misstime").ComponentConstructor<import('intact-react').Component<import("../context").ProviderProps<any>, {}, {}, {}>>;
3
- Consumer: import("misstime").ComponentConstructor<import('intact-react').Component<import("../context").ConsumerProps<any>, {}, {}, {}>>;
4
- useContext: () => import("misstime").RefObject<any>;
2
+ Provider: import("vdt").ComponentConstructor<import('intact-react').Component<import("../context").ProviderProps<any>, {}, {}, {}>>;
3
+ Consumer: import("vdt").ComponentConstructor<import('intact-react').Component<import("../context").ConsumerProps<any>, {}, {}, {}>>;
4
+ useContext: () => import("vdt").RefObject<any>;
5
5
  };
@@ -9,6 +9,7 @@ import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/spl
9
9
  import { useInstance } from 'intact-react';
10
10
  import { _$ } from '../../i18n';
11
11
  import { UploadFileStatus } from './useUpload';
12
+ import { isEqualArray } from '../utils';
12
13
  var uid = 0;
13
14
  export function useFiles(isValidType, upload) {
14
15
  var instance = useInstance();
@@ -33,8 +34,8 @@ export function useFiles(isValidType, upload) {
33
34
  }
34
35
  }
35
36
 
36
- instance.on("$receive:files", function (files) {
37
- if (!files) return;
37
+ instance.on("$receive:files", function (files, oldFiles) {
38
+ if (!files || isEqualArray(files, oldFiles)) return;
38
39
  instance.set('files', _mapInstanceProperty(files).call(files, normalizeFile));
39
40
  });
40
41
 
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v3.1.2
2
+ * @king-design v3.1.4-beta.0
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -60,7 +60,7 @@ 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.2";
63
+ export declare const version = "3.1.4-beta.0";
64
64
 
65
65
 
66
66
  export {normalize} from 'intact-react';
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v3.1.2
2
+ * @king-design v3.1.4-beta.0
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -62,7 +62,7 @@ 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.2';
65
+ export var version = '3.1.4-beta.0';
66
66
  /* generate end */
67
67
 
68
68
  export {normalize} from 'intact-react';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@king-design/react",
3
- "version": "3.1.2",
3
+ "version": "3.1.4-beta.0",
4
4
  "description": "King-Design UI components for React.",
5
5
  "keywords": [
6
6
  "component",
@@ -36,7 +36,7 @@
36
36
  "@emotion/css": "^11.5.0",
37
37
  "dayjs": "^1.10.7",
38
38
  "enquire.js": "^2.1.6",
39
- "intact-react": "3.0.23",
39
+ "intact-react": "3.0.25",
40
40
  "monaco-editor": "^0.26.1",
41
41
  "mxgraphx": "^4.0.7",
42
42
  "resize-observer-polyfill": "^1.5.1",
package/styles/global.js CHANGED
@@ -10,8 +10,13 @@ var slideDirections = {
10
10
  up: 'center bottom 0',
11
11
  left: 'right center 0',
12
12
  right: 'left center 0'
13
- }; // TODO: update global when theme changed
13
+ };
14
14
 
15
- injectGlobal("html{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,SF Pro SC,SF Pro Text,Helvetica Neue,Helvetica,PingFang SC,Segoe UI,Roboto,Hiragino Sans GB,arial,microsoft yahei ui,Microsoft YaHei,sans-serif;}body{font-size:", theme.fontSize, ";line-height:", theme.lineHeight, ";margin:0;padding:0;color:", theme.color.text, ";}*,*:before,*:after{box-sizing:inherit;}::-webkit-scrollbar{width:10px;height:10px;background-color:#fff;}::-webkit-scrollbar-track{background-color:#fff;}::-webkit-scrollbar-thumb{background-color:#babac0;border-radius:16px;border:2px solid #fff;&:hover{background-color:#a0a0a5;}}::-webkit-scroll-button{display:none;}", _mapInstanceProperty(_context = _Object$keys(slideDirections)).call(_context, function (direction) {
15
+ if (!/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)) {
16
+ document.body.classList.add('k-customize-scrollbar');
17
+ } // TODO: update global when theme changed
18
+
19
+
20
+ injectGlobal("html{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,SF Pro SC,SF Pro Text,Helvetica Neue,Helvetica,PingFang SC,Segoe UI,Roboto,Hiragino Sans GB,arial,microsoft yahei ui,Microsoft YaHei,sans-serif;}body{font-size:", theme.fontSize, ";line-height:", theme.lineHeight, ";margin:0;padding:0;color:", theme.color.text, ";}*,*:before,*:after{box-sizing:inherit;}.k-customize-scrollbar{&::-webkit-scrollbar,*::-webkit-scrollbar{width:10px;height:10px;background-color:#fff;}&::-webkit-scrollbar-track,*::-webkit-scrollbar-track{background-color:#fff;}&::-webkit-scrollbar-thumb,*::-webkit-scrollbar-thumb{background-color:#babac0;border-radius:16px;border:2px solid #fff;&:hover{background-color:#a0a0a5;}}&::-webkit-scroll-button,*::-webkit-scroll-button{display:none;}}", _mapInstanceProperty(_context = _Object$keys(slideDirections)).call(_context, function (direction) {
16
21
  return /*#__PURE__*/css(".k-slide", direction, "-enter-from,.k-slide", direction, "-leave-to{transform-origin:", slideDirections[direction], ";opacity:0;transform:", direction === 'down' || direction === 'up' ? "scaleY(.8)" : 'scaleX(.8)', ";}.k-slide", direction, "-enter-active,.k-slide", direction, "-leave-active{transform-origin:", slideDirections[direction], ";transition:opacity ", theme.transition.large, ",transform ", theme.transition.large, "!important;}.k-slide", direction, "-leave-active{pointer-events:none;}");
17
22
  }), " .k-fade-enter-from,.k-fade-leave-to{opacity:0!important;}.k-fade-enter-active,.k-fade-leave-active{transition:opacity ", theme.transition.large, "!important;}.k-fade-leave-active:not(tr){position:absolute;}.k-fade-move{transition:transform ", theme.transition.large, "!important;}.k-scale-enter-from,.k-scale-leave-to{transform:scale(0);}.k-scale-enter-active,.k-scale-leave-active{transition:transform ", theme.transition.large, ";}.k-expand-enter-from,.k-expand-leave-to{opacity:0;overflow:hidden;}.k-expand-enter-active,.k-expand-leave-active{transition:all ", theme.transition.large, "!important;overflow:hidden;}.k-expand-move{transition:transform ", theme.transition.large, ";}.k-dropdown-enter-from,.k-dropdown-leave-to{opacity:0;transform:translateY(-20px);}.k-dropdown-enter-active,.k-dropdown-leave-active,.k-dropdown-move{transition:all ", theme.transition.large, ";}.k-dropdown-leave-active{position:absolute!important;}.k-dropdown-move{transition:transform ", theme.transition.large, ";}.k-fade-in-left-enter-from,.k-fade-in-left-leave-to{opacity:0;transform:translate3d(-15px, 0, 0);}.k-fade-in-left-enter-active,.k-fade-in-left-leave-active{transition:all ", theme.transition.large, ";}.k-fade-in-left-move{transition:transform ", theme.transition.large, ";}.k-fade-expand-enter-from,.k-fade-expand-leave-to{opacity:0;}.k-fade-expand-enter-active,.k-fade-expand-leave-active{transition:all ", theme.transition.large, ";}.c-ellipsis{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}.c-hidden{display:none!important;}.c-middle{display:inline-block;vertical-align:middle;}");
@@ -1,45 +0,0 @@
1
- import { TypeDefs } from 'intact-react';
2
- import { BaseSelect, BaseSelectProps, BaseSelectEvents, BaseSelectBlocks } from '../select/base';
3
- export interface CascaderProps<V = any, Multipe extends boolean = boolean, Data extends BaseCascaderData = CascaderData<V>> extends BaseSelectProps<V[], Multipe> {
4
- data?: Data[];
5
- trigger?: 'click' | 'hover';
6
- changeOnSelect?: boolean;
7
- format?: (labels: string[]) => string;
8
- loadData?: (data: Data) => any;
9
- filter?: (keywords: string, data: Data) => boolean;
10
- fields?: CascaderFields<Data>;
11
- }
12
- export declare type CascaderFields<Data> = {
13
- value?: keyof Data;
14
- label?: keyof Data;
15
- children?: keyof Data;
16
- disabled?: keyof Data;
17
- };
18
- export interface BaseCascaderData {
19
- loaded?: boolean;
20
- [key: string]: any;
21
- }
22
- export interface CascaderData<V> extends BaseCascaderData {
23
- value: V;
24
- label: string;
25
- children?: CascaderData<V>[];
26
- disabled?: boolean;
27
- }
28
- export interface CascaderEvents extends BaseSelectEvents {
29
- }
30
- export interface CascaderBlocks<V> extends BaseSelectBlocks<V> {
31
- }
32
- export declare class Cascader<V = any, Multipe extends boolean = false, Data extends BaseCascaderData = CascaderData<V>> extends BaseSelect<CascaderProps<V, Multipe, Data>, CascaderEvents, CascaderBlocks<V>> {
33
- static template: string | import('intact-react').Template<any>;
34
- static typeDefs: Required<TypeDefs<CascaderProps<any, boolean, CascaderData<any>>>>;
35
- static defaults: () => Partial<CascaderProps<any, boolean, CascaderData<any>>>;
36
- private fields;
37
- private value;
38
- private label;
39
- private load;
40
- private filterable;
41
- private positionObj;
42
- protected getPlaceholder(): string | number | boolean | import("misstime/dist/utils/types").VNode<any> | import('intact-react').Children[];
43
- protected getLabel(): import('intact-react').Children;
44
- protected hasValue(): any;
45
- }