@king-design/intact 2.0.13 → 2.0.15

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.
Files changed (75) hide show
  1. package/components/cascader/index.md +1 -0
  2. package/components/cascader/useValue.ts +1 -1
  3. package/components/colorpicker/index.md +1 -0
  4. package/components/colorpicker/index.ts +2 -0
  5. package/components/colorpicker/index.vdt +1 -0
  6. package/components/datepicker/index.md +1 -0
  7. package/components/dialog/alert.vdt +5 -3
  8. package/components/dialog/index.md +3 -0
  9. package/components/dialog/index.spec.ts +35 -0
  10. package/components/dialog/staticMethods.ts +14 -1
  11. package/components/dialog/useFixBody.ts +3 -1
  12. package/components/form/styles.ts +5 -2
  13. package/components/icon/demos/icons.md +158 -0
  14. package/components/pagination/demos/disable.md +51 -0
  15. package/components/pagination/index.md +2 -0
  16. package/components/pagination/index.spec.ts +14 -0
  17. package/components/pagination/index.ts +8 -0
  18. package/components/pagination/index.vdt +13 -3
  19. package/components/pagination/styles.ts +3 -0
  20. package/components/portal.ts +38 -28
  21. package/components/select/base.ts +5 -7
  22. package/components/select/base.vdt +5 -7
  23. package/components/select/demos/basic.md +1 -1
  24. package/components/select/index.md +1 -0
  25. package/components/select/useEqualWidth.ts +1 -1
  26. package/components/select/useFocusout.ts +1 -1
  27. package/components/select/useInput.ts +1 -1
  28. package/components/treeSelect/index.md +1 -0
  29. package/components/wave/index.ts +1 -1
  30. package/components/wave/styles.ts +2 -1
  31. package/es/components/cascader/useValue.js +1 -1
  32. package/es/components/colorpicker/index.d.ts +1 -0
  33. package/es/components/colorpicker/index.js +2 -1
  34. package/es/components/colorpicker/index.vdt.js +5 -1
  35. package/es/components/dialog/alert.vdt.js +6 -4
  36. package/es/components/dialog/index.spec.js +61 -1
  37. package/es/components/dialog/staticMethods.d.ts +4 -2
  38. package/es/components/dialog/staticMethods.js +16 -0
  39. package/es/components/dialog/useFixBody.js +3 -1
  40. package/es/components/form/styles.js +1 -1
  41. package/es/components/pagination/index.d.ts +2 -0
  42. package/es/components/pagination/index.js +12 -1
  43. package/es/components/pagination/index.spec.js +28 -0
  44. package/es/components/pagination/index.vdt.js +18 -3
  45. package/es/components/pagination/styles.js +1 -1
  46. package/es/components/portal.js +23 -11
  47. package/es/components/select/base.d.ts +1 -1
  48. package/es/components/select/base.js +4 -4
  49. package/es/components/select/base.vdt.js +6 -6
  50. package/es/components/select/useEqualWidth.js +1 -1
  51. package/es/components/select/useFocusout.js +1 -1
  52. package/es/components/select/useInput.js +1 -1
  53. package/es/components/wave/styles.js +1 -1
  54. package/es/index.d.ts +2 -2
  55. package/es/index.js +2 -2
  56. package/es/packages/kpc-react/__tests__/components/dialog.spec.d.ts +1 -0
  57. package/es/packages/kpc-react/__tests__/components/dialog.spec.js +45 -0
  58. package/es/packages/kpc-react/__tests__/components/drawer.spec.js +65 -10
  59. package/es/site/data/components/icon/demos/icons/index.d.ts +9 -0
  60. package/es/site/data/components/icon/demos/icons/index.js +24 -0
  61. package/es/site/data/components/{menu/demos/size → icon/demos/icons}/react.d.ts +4 -2
  62. package/es/site/data/components/icon/demos/icons/react.js +63 -0
  63. package/es/site/data/components/pagination/demos/disable/index.d.ts +16 -0
  64. package/es/site/data/components/pagination/demos/disable/index.js +35 -0
  65. package/es/site/data/components/pagination/demos/disable/react.d.ts +16 -0
  66. package/es/site/data/components/pagination/demos/disable/react.js +65 -0
  67. package/es/site/data/components/select/demos/basic/react.js +2 -1
  68. package/es/styles/global.js +1 -1
  69. package/index.ts +2 -2
  70. package/package.json +2 -2
  71. package/styles/fonts/demo.css +370 -0
  72. package/styles/fonts/demo.html +29 -0
  73. package/styles/fonts/iconfont.css +477 -0
  74. package/styles/global.ts +1 -1
  75. package/es/site/data/components/menu/demos/collapse/react.d.ts +0 -11
@@ -14,9 +14,7 @@ const {
14
14
  size, hideIcon, fluid,
15
15
  clearable, filterable,
16
16
  className, container,
17
- inline, style, width,
18
-
19
- _show,
17
+ inline, style, width, show,
20
18
  } = this.get();
21
19
 
22
20
  const classNameObj = {
@@ -44,7 +42,7 @@ const {onFocusout, triggerRef} = this.focusout;
44
42
  ref={this.dropdownRef}
45
43
  disabled={disabled}
46
44
  container={container}
47
- v-model="_show"
45
+ v-model="show"
48
46
  >
49
47
  <div {...getRestProps(this)}
50
48
  class={classNameObj}
@@ -62,7 +60,7 @@ const {onFocusout, triggerRef} = this.focusout;
62
60
  {/* TODO: Need mode on Transition */}
63
61
  <TransitionGroup name="k-fade" appear={false}>
64
62
  <Input v-if={!multiple && filterable}
65
- value={_show ? keywords : label}
63
+ value={show ? keywords : label}
66
64
  ev-$change:value={onInput}
67
65
  disabled={disabled}
68
66
  placeholder={label || placeholder}
@@ -71,7 +69,7 @@ const {onFocusout, triggerRef} = this.focusout;
71
69
  fluid
72
70
  inline
73
71
  key="input"
74
- readonly={!_show}
72
+ readonly={!show}
75
73
  waveDisabled={true}
76
74
  />
77
75
  <div class="k-select-placeholder c-ellipsis"
@@ -128,7 +126,7 @@ const {onFocusout, triggerRef} = this.focusout;
128
126
  inline
129
127
  size={size}
130
128
  key="filter"
131
- readonly={!_show}
129
+ readonly={!show}
132
130
  waveDisabled={true}
133
131
  />
134
132
  </div>
@@ -11,7 +11,7 @@ import {Select, Option} from 'kpc';
11
11
 
12
12
  <div>
13
13
  <div style="margin-bottom: 16px;">
14
- <Select v-model="day">
14
+ <Select v-model="day" show={true}>
15
15
  <Option value="Monday">星期一</Option>
16
16
  <Option value="Tuesday">星期二</Option>
17
17
  <Option value="Wednesday">星期三</Option>
@@ -31,6 +31,7 @@ sidebar: doc
31
31
  | labelMap | 建立值`value`到展示标签`label`的映射,可以在`value`不在`Option`集合中时,依然能够正确展示相应的`label` | `Map<any, string>` | `new Map()` |
32
32
  | card | 是否展示`card`模式 | `boolean` | `false` |
33
33
  | autoDisableArrow | 是否在没有更多可选项时,给箭头一个`disabled`状态来提示用户 | `boolean` | `false` |
34
+ | show | 是否展示菜单项 | `boolean` | `false` |
34
35
 
35
36
  ```ts
36
37
  export type Container = string | ((parentDom: Element, anchor: Node | null) => Element)
@@ -4,7 +4,7 @@ import type {BaseSelect} from './base';
4
4
  export function useEqualWidth() {
5
5
  const instance = useInstance() as BaseSelect;
6
6
 
7
- instance.watch('_show', setWidth, {presented: true});
7
+ instance.watch('show', setWidth, {presented: true});
8
8
 
9
9
  function setWidth(v: boolean | undefined) {
10
10
  if (!v) return;
@@ -18,7 +18,7 @@ export function useFocusout() {
18
18
 
19
19
  function onFocusout(e: FocusEvent) {
20
20
  instance.trigger('focusout', e);
21
- if (instance.get('_show')) {
21
+ if (instance.get('show')) {
22
22
  e.stopPropagation();
23
23
  }
24
24
  }
@@ -42,7 +42,7 @@ export function useInput(resetKeywords: (keywords: State<string>) => void) {
42
42
  }
43
43
  }
44
44
 
45
- component.on('$changed:_show', show => {
45
+ component.on('$changed:show', show => {
46
46
  if (show) {
47
47
  focusInput();
48
48
  resetKeywords(keywords);
@@ -32,6 +32,7 @@ sidebar: doc
32
32
  | defaultExpandAll | 是否默认展开所有节点 | `boolean` | `true` |
33
33
  | checkbox | 是否展示复选框 | `boolean` | `false` |
34
34
  | filter | 当支持筛选时,可以自定义筛选规则 | `(keywords: string, data: TreeDataItem<K>) => boolean` | `undefined` |
35
+ | show | 是否展示菜单项 | `boolean` | `false` |
35
36
 
36
37
  ```ts
37
38
  import {Key, Children} from 'intact';
@@ -77,7 +77,7 @@ export class Wave extends Component<WaveProps> {
77
77
  this.resetAnimation();
78
78
 
79
79
  instance!.addEventListener('animationend', this.resetAnimation);
80
- this.timer = window.setTimeout(() => {
80
+ this.timer = window.setTimeout(() => {
81
81
  instance!.classList.add(this.className);
82
82
  });
83
83
  }
@@ -39,6 +39,7 @@ export function makeStyles(color: string, inset: string) {
39
39
  animation: ${waveEffect} .2s ease-in;
40
40
  animation-fill-mode: forwards;
41
41
  border: 2px solid ${color};
42
+ pointer-events: none;
42
43
  }
43
44
  &.k-circle,
44
45
  &.k-radio-wrapper {
@@ -47,4 +48,4 @@ export function makeStyles(color: string, inset: string) {
47
48
  }
48
49
  }
49
50
  `;
50
- }
51
+ }
@@ -36,7 +36,7 @@ export function useValue() {
36
36
  });
37
37
  }
38
38
  });
39
- instance.watch('_show', function (value) {
39
+ instance.watch('show', function (value) {
40
40
  if (value) {
41
41
  showedValue.set(last(values.value) || []);
42
42
  }
@@ -7,6 +7,7 @@ export interface ColorpickerProps {
7
7
  size?: Sizes;
8
8
  disabled?: boolean;
9
9
  container?: Container;
10
+ show?: boolean;
10
11
  }
11
12
  export interface ColorpickerEvents {
12
13
  }
@@ -10,7 +10,8 @@ var typeDefs = {
10
10
  presets: Array,
11
11
  size: sizes,
12
12
  disabled: Boolean,
13
- container: [Function, String]
13
+ container: [Function, String],
14
+ show: Boolean
14
15
  };
15
16
 
16
17
  var defaults = function defaults() {
@@ -48,7 +48,11 @@ export default function ($props, $blocks, $__proto__) {
48
48
  },
49
49
  'value': $this.get('value')
50
50
  })
51
- })]
51
+ })],
52
+ 'ev-$model:value': function ev$modelValue($v) {
53
+ $this.set('show', $v);
54
+ },
55
+ 'value': $this.get('show')
52
56
  }));
53
57
  }
54
58
  ;
@@ -15,7 +15,9 @@ export default function ($props, $blocks, $__proto__) {
15
15
  hideIcon = _this$get.hideIcon,
16
16
  hideFooter = _this$get.hideFooter,
17
17
  hideClose = _this$get.hideClose,
18
- title = _this$get.title;
18
+ title = _this$get.title,
19
+ iconClassName = _this$get.iconClassName,
20
+ icon = _this$get.icon;
19
21
 
20
22
  var classNameObj = (_classNameObj = {
21
23
  'k-alert-dialog': true
@@ -37,14 +39,14 @@ export default function ($props, $blocks, $__proto__) {
37
39
 
38
40
  return block ? block.call($this, callBlock, data) : callBlock();
39
41
  }), (_$blocks['body'] = function ($super) {
40
- return [_$ce(2, 'div', !hideIcon ? _$cc(Icon, {
41
- 'className': _$cn({
42
+ return [_$ce(2, 'div', [!hideIcon && !icon ? _$cc(Icon, {
43
+ 'className': _$cn(iconClassName || {
42
44
  "ion-ios-checkmark": type === 'success',
43
45
  "ion-ios-information": type === 'warning',
44
46
  "ion-ios-close": type === 'error',
45
47
  "ion-ios-help": type === 'confirm'
46
48
  })
47
- }) : undefined, 0, 'k-dialog-tip-icon'), _$ce(2, 'div', [title ? _$ce(2, 'div', title, 0, 'k-alert-dialog-title') : undefined, content], 0, 'k-alert-dialog-wrapper')];
49
+ }) : undefined, icon], 0, 'k-dialog-tip-icon'), _$ce(2, 'div', [title ? _$ce(2, 'div', title, 0, 'k-alert-dialog-title') : undefined, content], 0, 'k-alert-dialog-wrapper')];
48
50
  }, __$blocks['body'] = function ($super, data) {
49
51
  var block = $blocks['body'];
50
52
 
@@ -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 _context16; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context16 = Object.prototype.toString.call(o)).call(_context16, 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 _context18; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context18 = Object.prototype.toString.call(o)).call(_context18, 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
 
@@ -15,8 +15,10 @@ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/con
15
15
  import _keysInstanceProperty from "@babel/runtime-corejs3/core-js/instance/keys";
16
16
  import _startsWithInstanceProperty from "@babel/runtime-corejs3/core-js/instance/starts-with";
17
17
  import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
18
+ import { __decorate } from "tslib";
18
19
  import { Component } from 'intact';
19
20
  import { Dialog, BaseDialog } from './';
21
+ import { bind } from '../utils';
20
22
  import { getElement, mount, unmount, dispatchEvent, wait } from '../../test/utils';
21
23
  import BasicDemo from '~/components/dialog/demos/basic';
22
24
  import AsyncCloseDemo from '~/components/dialog/demos/asyncClose';
@@ -590,6 +592,64 @@ describe('Dialog', function () {
590
592
  }
591
593
  }
592
594
  }, _callee12);
595
+ })));
596
+ it('should remove body style when destroy', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
597
+ var Demo, _mount13, instance, element;
598
+
599
+ return _regeneratorRuntime.wrap(function _callee13$(_context17) {
600
+ while (1) {
601
+ switch (_context17.prev = _context17.next) {
602
+ case 0:
603
+ Demo = /*#__PURE__*/function (_Component4) {
604
+ _inheritsLoose(Demo, _Component4);
605
+
606
+ function Demo() {
607
+ var _context16;
608
+
609
+ var _this4;
610
+
611
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
612
+ args[_key4] = arguments[_key4];
613
+ }
614
+
615
+ _this4 = _Component4.call.apply(_Component4, _concatInstanceProperty(_context16 = [this]).call(_context16, args)) || this;
616
+ _this4.Dialog = Dialog;
617
+ return _this4;
618
+ }
619
+
620
+ Demo.defaults = function defaults() {
621
+ return {
622
+ show: true
623
+ };
624
+ };
625
+
626
+ var _proto = Demo.prototype;
627
+
628
+ _proto.onClose = function onClose() {
629
+ this.set('show', false);
630
+ };
631
+
632
+ return Demo;
633
+ }(Component);
634
+
635
+ Demo.template = "\n var Dialog = this.Dialog;\n <div>\n <Dialog v-if={this.get('show')}\n value={this.get('show')}\n ev-close={this.onClose}\n ref=\"dialog\"\n >test</Dialog>\n </div>\n ";
636
+
637
+ __decorate([bind], Demo.prototype, "onClose", null);
638
+
639
+ _mount13 = mount(Demo), instance = _mount13[0], element = _mount13[1];
640
+ instance.refs.dialog.close();
641
+ _context17.next = 7;
642
+ return wait();
643
+
644
+ case 7:
645
+ expect(document.body.getAttribute('style')).to.be.null;
646
+
647
+ case 8:
648
+ case "end":
649
+ return _context17.stop();
650
+ }
651
+ }
652
+ }, _callee13);
593
653
  }))); // it('should handle v-if and v-model at the same time correctly in Vue', async () => {
594
654
  // const Test = {
595
655
  // template: `<Dialog v-model="show" v-if="show" ref="dialog">test</Dialog>`,
@@ -1,11 +1,13 @@
1
- import { VNode } from 'intact';
2
1
  import type { Dialog, DialogProps } from './';
3
2
  export interface AlertDialogProps extends DialogProps {
4
- content?: string | VNode;
3
+ content?: string | object;
5
4
  type?: 'success' | 'warning' | 'error' | 'confirm';
6
5
  hideIcon?: boolean;
7
6
  hideFooter?: boolean;
8
7
  ref?: (i: Dialog) => void;
8
+ className?: string;
9
+ iconClassName?: string;
10
+ icon?: object;
9
11
  }
10
12
  export declare type StaticMethod = (options?: AlertDialogProps) => Promise<void>;
11
13
  export declare function addStaticMethods(Component: typeof Dialog): void;
@@ -29,6 +29,22 @@ export function addStaticMethods(Component) {
29
29
  options = {};
30
30
  }
31
31
 
32
+ var normalize = Component.normalize;
33
+
34
+ if (normalize) {
35
+ if (options.content) {
36
+ options = _extends({}, options, {
37
+ content: normalize(options.content)
38
+ });
39
+ }
40
+
41
+ if (options.icon) {
42
+ options = _extends({}, options, {
43
+ icon: normalize(options.icon)
44
+ });
45
+ }
46
+ }
47
+
32
48
  var dialog = new AlertDialog(options);
33
49
  dialog.show();
34
50
  if (options.ref) options.ref(dialog);
@@ -11,7 +11,9 @@ export function useFixBody(elementRef) {
11
11
  instance.on(SHOW, onEnter);
12
12
  instance.on('afterClose', onAfterLeave);
13
13
  onBeforeUnmount(function () {
14
- if (fixedBody && instance.get('value')) {
14
+ // should also remove body style when dialog is removed, #805
15
+ // if (fixedBody && instance.get('value')) {
16
+ if (fixedBody) {
15
17
  // maybe HIDE event has not triggered
16
18
  onClosed(instance);
17
19
  }
@@ -50,7 +50,7 @@ setDefault(function () {
50
50
  }).form;
51
51
  });
52
52
  export function makeItemStyles() {
53
- return /*#__PURE__*/css("display:table;position:relative;table-layout:fixed;&:not(:last-of-type){margin-bottom:", form.item.gap, ";}&.k-fluid{width:100%;}.k-form-label{display:table-cell;width:", form.item.labelWidth, ";text-align:", form.item.labelTextAlign, ";padding-right:", form.item.labelGap, ";line-height:", form.item.labelLineHeight, ";}.k-form-star{color:", form.item.starColor, ";margin-right:", form.item.starGap, ";}.k-form-content{display:table-cell;vertical-align:middle;position:relative;}.k-form-error{position:absolute;color:", form.item.errorColor, ";font-size:", form.item.errorFontSize, ";left:0;right:0;display:flex;align-items:center;&.k-ellipsis{.k-form-error-more{display:inline-block;}}}.k-form-error-more{line-height:", form.item.errorFontSize, ";display:none;}&.k-invalid{.k-input{.k-input-inner{border:", form.item.invalidBorder, ";position:relative;z-index:1;}}.k-select,.k-checkbox-wrapper,.k-radio-wrapper{border:", form.item.invalidBorder, "!important;}.k-select .k-input .k-input-inner{border:none;}}.k-form-item{display:block;width:auto;}.k-form-append{display:table-cell;padding:", form.item.appendPadding, ";vertical-align:middle;}");
53
+ return /*#__PURE__*/css("display:table;position:relative;table-layout:fixed;&:not(:last-of-type){margin-bottom:", form.item.gap, ";}&.k-fluid{width:100%;}.k-form-label{display:table-cell;width:", form.item.labelWidth, ";text-align:", form.item.labelTextAlign, ";padding-right:", form.item.labelGap, ";line-height:", form.item.labelLineHeight, ";}.k-form-star{color:", form.item.starColor, ";margin-right:", form.item.starGap, ";}.k-form-content{display:table-cell;vertical-align:middle;position:relative;}.k-form-error{position:absolute;color:", form.item.errorColor, ";font-size:", form.item.errorFontSize, ";left:0;right:0;display:flex;align-items:center;&.k-ellipsis{.k-form-error-more{display:inline-block;}}}.k-form-error-more{line-height:", form.item.errorFontSize, ";display:none;}&.k-invalid{.k-input{.k-input-inner{border:", form.item.invalidBorder, ";position:relative;z-index:1;}}.k-select,.k-checkbox-wrapper,.k-radio-wrapper{border:", form.item.invalidBorder, "!important;}.k-select .k-input .k-input-inner{border:none;}}.k-form-item{&,.k-form-content{display:block;width:auto;}}.k-form-append{display:table-cell;padding:", form.item.appendPadding, ";vertical-align:middle;}");
54
54
  }
55
55
  export function makeFormStyles() {
56
56
  var _context;
@@ -13,6 +13,8 @@ export interface PaginationProps {
13
13
  showTotal?: boolean;
14
14
  showGoto?: boolean;
15
15
  showLimits?: boolean;
16
+ disableBtn?: (page: number, limit: number) => boolean;
17
+ disablePage?: (page: number, limit: number) => boolean;
16
18
  }
17
19
  export interface PaginationEvents {
18
20
  change: [PaginationChangeData];
@@ -16,7 +16,9 @@ var typeDefs = {
16
16
  simple: Boolean,
17
17
  showTotal: Boolean,
18
18
  showGoto: Boolean,
19
- showLimits: Boolean
19
+ showLimits: Boolean,
20
+ disableBtn: Function,
21
+ disablePage: Function
20
22
  };
21
23
 
22
24
  var defaults = function defaults() {
@@ -141,7 +143,16 @@ export var Pagination = /*#__PURE__*/function (_Component) {
141
143
  };
142
144
 
143
145
  _proto.goto = function goto(e) {
146
+ var _this$get4 = this.get(),
147
+ disablePage = _this$get4.disablePage,
148
+ limit = _this$get4.limit;
149
+
144
150
  var value = parseInt(e.target.value) || 1;
151
+
152
+ if (disablePage && disablePage(value, limit)) {
153
+ return;
154
+ }
155
+
145
156
  this.changePage(value);
146
157
  };
147
158
 
@@ -3,6 +3,7 @@ import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
3
3
  import BasicDemo from '~/components/pagination/demos/basic';
4
4
  import GotoDemo from '~/components/pagination/demos/goto';
5
5
  import CurrentDemo from '~/components/pagination/demos/current';
6
+ import DisableDemo from '~/components/pagination/demos/disable';
6
7
  import { mount, unmount, dispatchEvent, wait } from '../../test/utils';
7
8
  describe('Pagination', function () {
8
9
  afterEach(function () {
@@ -141,4 +142,31 @@ describe('Pagination', function () {
141
142
  }
142
143
  }, _callee3);
143
144
  })));
145
+ it('should not goto disabled page', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
146
+ var _mount4, instance, element, input;
147
+
148
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
149
+ while (1) {
150
+ switch (_context4.prev = _context4.next) {
151
+ case 0:
152
+ _mount4 = mount(DisableDemo), instance = _mount4[0], element = _mount4[1];
153
+ input = element.querySelector('.k-input-inner');
154
+ dispatchEvent(input, 'focus');
155
+ input.value = '11';
156
+ dispatchEvent(input, 'change');
157
+ dispatchEvent(input, 'blur');
158
+ _context4.next = 8;
159
+ return wait();
160
+
161
+ case 8:
162
+ expect(input.value).to.eql('10');
163
+ expect(instance.get('value2')).to.eql(10);
164
+
165
+ case 10:
166
+ case "end":
167
+ return _context4.stop();
168
+ }
169
+ }
170
+ }, _callee4);
171
+ })));
144
172
  });
@@ -32,7 +32,9 @@ export default function ($props, $blocks, $__proto__) {
32
32
  value = _this$get.value,
33
33
  limit = _this$get.limit,
34
34
  limits = _this$get.limits,
35
- showLimits = _this$get.showLimits;
35
+ showLimits = _this$get.showLimits,
36
+ disableBtn = _this$get.disableBtn,
37
+ disablePage = _this$get.disablePage;
36
38
 
37
39
  if (!total) return _$ccv(' pagination ');
38
40
  var classNameObj = (_classNameObj = {
@@ -47,11 +49,24 @@ export default function ($props, $blocks, $__proto__) {
47
49
  var totalPages = Math.ceil(total / limit) || 0;
48
50
 
49
51
  var paginationButton = function paginationButton(page) {
52
+ var disabled = false;
53
+
54
+ if (page !== value) {
55
+ if (disablePage) {
56
+ disabled || (disabled = !!disablePage(page, limit));
57
+ }
58
+
59
+ if (disableBtn) {
60
+ disabled || (disabled = !!disableBtn(page, limit));
61
+ }
62
+ }
63
+
50
64
  return _$cc(Button, {
51
65
  'type': type,
52
66
  'size': size,
53
67
  'icon': true,
54
68
  'value': page,
69
+ 'disabled': disabled,
55
70
  'children': page
56
71
  });
57
72
  };
@@ -131,14 +146,14 @@ export default function ($props, $blocks, $__proto__) {
131
146
  'icon': true,
132
147
  'size': size,
133
148
  'type': type,
134
- 'disabled': value <= 1,
149
+ 'disabled': value <= 1 || !!(disablePage && disablePage(value - 1, limit)),
135
150
  'ev-click': this.prev,
136
151
  'children': _$cc(Icon, _$tmp0)
137
152
  }), paginationItems, _$cc(Button, {
138
153
  'icon': true,
139
154
  'size': size,
140
155
  'type': type,
141
- 'disabled': value >= totalPages,
156
+ 'disabled': value >= totalPages || !!(disablePage && disablePage(value + 1, limit)),
142
157
  'ev-click': this.next,
143
158
  'children': _$cc(Icon, _$tmp1)
144
159
  })],
@@ -55,7 +55,7 @@ setDefault(function () {
55
55
  }).pagination;
56
56
  });
57
57
  export function makeStyles() {
58
- return /*#__PURE__*/css("font-size:", pagination.fontSize, ";.k-pagination-limits,.k-pagination-goto,.k-pagination-total{margin-left:", pagination.gap, ";display:inline-block;vertical-align:middle;}.k-pagination-ellipsis{background-color:transparent;border-color:transparent;}.k-btns{.k-btn{width:auto!important;min-width:", button.height, ";padding:", pagination.btn.padding, ";margin-right:", pagination.btn.gap, ";&:last-of-type{margin:0!important;}}.k-icon{font-size:18px;}}.k-pagination-goto{.k-input{font-size:inherit;width:", pagination.goto.width, ";margin:", pagination.goto.gap, ";}}.k-select{width:auto;}", _mapInstanceProperty(sizes).call(sizes, function (size) {
58
+ return /*#__PURE__*/css("font-size:", pagination.fontSize, ";.k-pagination-limits,.k-pagination-goto,.k-pagination-total{margin-left:", pagination.gap, ";display:inline-block;vertical-align:middle;}.k-pagination-ellipsis{background-color:transparent;border-color:transparent;}.k-btns{.k-btn{width:auto!important;min-width:", button.height, ";padding:", pagination.btn.padding, ";margin-right:", pagination.btn.gap, ";&:last-of-type{margin:0!important;}}.k-icon{font-size:18px;}}.k-pagination-goto{.k-input{font-size:inherit;width:", pagination.goto.width, ";margin:", pagination.goto.gap, ";}.k-input-inner{text-align:center;}}.k-select{width:auto;}", _mapInstanceProperty(sizes).call(sizes, function (size) {
59
59
  var styles = pagination[size];
60
60
  var btnStyles = button[size];
61
61
  return /*#__PURE__*/css("&.k-", size, "{font-size:", styles.fontSize, ";.k-btn{margin-right:", styles.btnGap, ";min-width:", btnStyles.height, ";.k-icon{font-size:", styles.iconFontSize, ";}}}");
@@ -60,25 +60,37 @@ export var Portal = /*#__PURE__*/function (_Component) {
60
60
  };
61
61
 
62
62
  _proto.$update = function $update(lastVNode, nextVNode, parentDom, anchor, mountedQueue, force) {
63
+ var _this3 = this;
64
+
63
65
  // update container if it has changed
64
66
  var lastProps = lastVNode.props;
65
67
  var nextProps = nextVNode.props;
66
- var lastContainer = this.container;
67
68
 
68
- if (lastProps.container !== nextProps.container) {
69
- this.initContainer(nextProps.container, parentDom, anchor);
70
- }
69
+ var update = function update() {
70
+ var lastContainer = _this3.container;
71
+
72
+ if (lastProps.container !== nextProps.container) {
73
+ _this3.initContainer(nextProps.container, parentDom, anchor);
74
+ }
75
+
76
+ var nextContainer = _this3.container;
71
77
 
72
- var nextContainer = this.container;
78
+ if (lastContainer === nextContainer) {
79
+ patch(lastProps.children, nextProps.children, nextContainer, _this3, _this3.$SVG, anchor, mountedQueue, false);
80
+ } else {
81
+ remove(lastProps.children, lastContainer, false);
82
+ mount(nextProps.children, nextContainer, _this3, _this3.$SVG, anchor, mountedQueue);
83
+ }
84
+
85
+ _Component.prototype.$update.call(_this3, lastVNode, nextVNode, parentDom, anchor, mountedQueue, force);
86
+ };
73
87
 
74
- if (lastContainer === nextContainer) {
75
- patch(lastProps.children, nextProps.children, nextContainer, this, this.$SVG, anchor, mountedQueue, false);
88
+ if (!this.container) {
89
+ // in react, sometimes $update will be called before mountedQueue in $render
90
+ mountedQueue.push(update);
76
91
  } else {
77
- remove(lastProps.children, lastContainer, false);
78
- mount(nextProps.children, nextContainer, this, this.$SVG, anchor, mountedQueue);
92
+ update();
79
93
  }
80
-
81
- _Component.prototype.$update.call(this, lastVNode, nextVNode, parentDom, anchor, mountedQueue, force);
82
94
  };
83
95
 
84
96
  _proto.$unmount = function $unmount(vNode, nextVNode) {
@@ -20,7 +20,7 @@ export interface BaseSelectProps<V, Multipe extends boolean = boolean, Attach =
20
20
  placeholder?: Children;
21
21
  container?: Container;
22
22
  width?: string | number;
23
- _show?: boolean;
23
+ show?: boolean;
24
24
  }
25
25
  export interface BaseSelectEvents {
26
26
  keydown: [KeyboardEvent];
@@ -27,7 +27,7 @@ var typeDefs = {
27
27
  placeholder: [String, Number],
28
28
  container: [Function, String],
29
29
  width: [String, Number],
30
- _show: Boolean
30
+ show: Boolean
31
31
  };
32
32
 
33
33
  var defaults = function defaults() {
@@ -65,7 +65,7 @@ export var BaseSelect = /*#__PURE__*/function (_Component) {
65
65
 
66
66
  _proto.init = function init() {
67
67
  provide(SELECT, this);
68
- useShowHideEvents('_show'); // this.input = useInput();
68
+ useShowHideEvents('show'); // this.input = useInput();
69
69
 
70
70
  this.watch('value', this.position, {
71
71
  presented: true
@@ -81,11 +81,11 @@ export var BaseSelect = /*#__PURE__*/function (_Component) {
81
81
  };
82
82
 
83
83
  _proto.show = function show() {
84
- this.set('_show', true);
84
+ this.set('show', true);
85
85
  };
86
86
 
87
87
  _proto.hide = function hide() {
88
- this.set('_show', false);
88
+ this.set('show', false);
89
89
  };
90
90
 
91
91
  _proto.resetKeywords = function resetKeywords(keywords) {
@@ -40,7 +40,7 @@ export default function ($props, $blocks, $__proto__) {
40
40
  inline = _this$get.inline,
41
41
  style = _this$get.style,
42
42
  width = _this$get.width,
43
- _show = _this$get._show;
43
+ show = _this$get.show;
44
44
 
45
45
  var classNameObj = (_classNameObj = {
46
46
  'k-select': true,
@@ -94,7 +94,7 @@ export default function ($props, $blocks, $__proto__) {
94
94
  'name': 'k-fade',
95
95
  'appear': false,
96
96
  'children': !multiple && filterable ? _$cc(Input, {
97
- 'value': _show ? keywords : label,
97
+ 'value': show ? keywords : label,
98
98
  'ev-$change:value': onInput,
99
99
  'disabled': disabled,
100
100
  'placeholder': label || placeholder,
@@ -103,7 +103,7 @@ export default function ($props, $blocks, $__proto__) {
103
103
  'fluid': true,
104
104
  'inline': true,
105
105
  'key': 'input',
106
- 'readonly': !_show,
106
+ 'readonly': !show,
107
107
  'waveDisabled': true
108
108
  }, 'input', inputRef) : !filterable && !hasValue ? _$ce(2, 'div', placeholder, 0, 'k-select-placeholder c-ellipsis', null, 'placeholder') : !multiple ? _$ce(2, 'div', (_$blocks['value'] = function ($super) {
109
109
  return label;
@@ -155,7 +155,7 @@ export default function ($props, $blocks, $__proto__) {
155
155
  'inline': true,
156
156
  'size': size,
157
157
  'key': 'filter',
158
- 'readonly': !_show,
158
+ 'readonly': !show,
159
159
  'waveDisabled': true
160
160
  }, 'filter', inputRef) : undefined], 0, _$cn({
161
161
  "k-select-values": true,
@@ -195,9 +195,9 @@ export default function ($props, $blocks, $__proto__) {
195
195
  return block ? block.call($this, callBlock, data) : callBlock();
196
196
  }, __$blocks['base-menu'](_$no))],
197
197
  'ev-$model:value': function ev$modelValue($v) {
198
- $this.set('_show', $v);
198
+ $this.set('show', $v);
199
199
  },
200
- 'value': $this.get('_show')
200
+ 'value': $this.get('show')
201
201
  }, null, _this.dropdownRef)
202
202
  });
203
203
  }
@@ -1,7 +1,7 @@
1
1
  import { useInstance, findDomFromVNode } from 'intact';
2
2
  export function useEqualWidth() {
3
3
  var instance = useInstance();
4
- instance.watch('_show', setWidth, {
4
+ instance.watch('show', setWidth, {
5
5
  presented: true
6
6
  });
7
7