@king-design/react 3.6.2-beta.1 → 3.7.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.
Files changed (89) hide show
  1. package/components/anchor/constants.d.ts +2 -0
  2. package/components/anchor/constants.js +2 -0
  3. package/components/anchor/index.d.ts +41 -0
  4. package/components/anchor/index.js +141 -0
  5. package/components/anchor/index.spec.d.ts +1 -0
  6. package/components/anchor/index.spec.js +230 -0
  7. package/components/anchor/index.vdt.js +31 -0
  8. package/components/anchor/link.d.ts +16 -0
  9. package/components/anchor/link.js +52 -0
  10. package/components/anchor/link.vdt.js +49 -0
  11. package/components/anchor/styles.d.ts +5 -0
  12. package/components/anchor/styles.js +30 -0
  13. package/components/anchor/useScroll.d.ts +7 -0
  14. package/components/anchor/useScroll.js +218 -0
  15. package/components/dialog/base.vdt.js +1 -1
  16. package/components/drawer/index.d.ts +3 -0
  17. package/components/drawer/index.js +22 -3
  18. package/components/drawer/index.spec.js +83 -0
  19. package/components/drawer/index.vdt.js +23 -3
  20. package/components/drawer/styles.js +1 -1
  21. package/components/drawer/useDrawerResizable.d.ts +10 -0
  22. package/components/drawer/useDrawerResizable.js +162 -0
  23. package/components/menu/styles.d.ts +1 -0
  24. package/components/menu/styles.js +4 -1
  25. package/components/notification/index.d.ts +1 -0
  26. package/components/notification/index.js +1 -0
  27. package/components/notification/index.spec.d.ts +1 -0
  28. package/components/notification/index.spec.js +317 -0
  29. package/components/notification/notification.d.ts +39 -0
  30. package/components/notification/notification.js +183 -0
  31. package/components/notification/notification.vdt.js +56 -0
  32. package/components/notification/notifications.d.ts +16 -0
  33. package/components/notification/notifications.js +51 -0
  34. package/components/notification/notifications.vdt.js +24 -0
  35. package/components/notification/styles.d.ts +9 -0
  36. package/components/notification/styles.js +110 -0
  37. package/components/select/styles.js +1 -1
  38. package/components/table/styles.js +1 -1
  39. package/components/tabs/useActiveBar.js +7 -3
  40. package/components/tag/base.d.ts +2 -0
  41. package/components/tag/base.js +3 -0
  42. package/components/tag/index.spec.js +17 -0
  43. package/components/tag/index.vdt.js +12 -5
  44. package/components/tag/styles.d.ts +9 -0
  45. package/components/tag/styles.js +14 -1
  46. package/components/tag/useColor.d.ts +7 -0
  47. package/components/tag/useColor.js +71 -0
  48. package/components/timepicker/index.spec.js +70 -42
  49. package/components/timepicker/useDefaultValue.js +12 -7
  50. package/components/timepicker/useStep.js +4 -2
  51. package/components/transfer/index.d.ts +13 -0
  52. package/components/transfer/index.js +6 -2
  53. package/components/transfer/index.spec.js +197 -0
  54. package/components/transfer/index.vdt.js +28 -5
  55. package/components/transfer/styles.js +4 -1
  56. package/components/transfer/useCheck.js +2 -1
  57. package/components/transfer/usePagination.d.ts +12 -0
  58. package/components/transfer/usePagination.js +79 -0
  59. package/dist/fonts/iconfont.eot +0 -0
  60. package/dist/fonts/iconfont.svg +235 -0
  61. package/dist/fonts/iconfont.ttf +0 -0
  62. package/dist/fonts/iconfont.woff +0 -0
  63. package/dist/fonts/iconfont.woff2 +0 -0
  64. package/dist/fonts/ionicons.eot +0 -0
  65. package/dist/fonts/ionicons.svg +2230 -0
  66. package/dist/fonts/ionicons.ttf +0 -0
  67. package/dist/fonts/ionicons.woff +0 -0
  68. package/dist/fonts/ionicons.woff2 +0 -0
  69. package/dist/i18n/en-US.js +1411 -0
  70. package/dist/i18n/en-US.js.map +1 -0
  71. package/dist/i18n/en-US.min.js +1 -0
  72. package/dist/i18n/index.js +283 -0
  73. package/dist/i18n/index.js.map +1 -0
  74. package/dist/i18n/index.min.js +1 -0
  75. package/dist/index.js +58380 -0
  76. package/dist/index.js.map +1 -0
  77. package/dist/index.min.js +1 -0
  78. package/index.d.ts +4 -2
  79. package/index.js +4 -2
  80. package/package.json +4 -2
  81. package/styles/fonts/iconfont.eot +0 -0
  82. package/styles/fonts/iconfont.js +1 -1
  83. package/styles/fonts/iconfont.svg +38 -0
  84. package/styles/fonts/iconfont.ttf +0 -0
  85. package/styles/fonts/iconfont.woff +0 -0
  86. package/styles/fonts/iconfont.woff2 +0 -0
  87. package/styles/theme.d.ts +8 -0
  88. package/styles/theme.js +5 -1
  89. package/yarn-error.log +0 -528
@@ -0,0 +1,218 @@
1
+ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/slice";
2
+ import _Array$from from "@babel/runtime-corejs3/core-js/array/from";
3
+ import _Symbol from "@babel/runtime-corejs3/core-js/symbol";
4
+ import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-method";
5
+ 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."); }
6
+ function _unsupportedIterableToArray(o, minLen) { var _context; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context = Object.prototype.toString.call(o)).call(_context, 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); }
7
+ 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; }
8
+ import { useInstance } from 'intact-react';
9
+ import { useState } from '../../hooks/useState';
10
+ export function useScroll() {
11
+ var instance = useInstance();
12
+ var isScrolling = useState(false);
13
+ var scrollTimer = null;
14
+ var rafId = null;
15
+ var scrollContainer = window;
16
+ // 回调函数,用于通知外部这是滚动触发的 value 变化
17
+ var setIsSettingFromScroll = null;
18
+ function getScrollContainer() {
19
+ var _instance$get = instance.get(),
20
+ container = _instance$get.container;
21
+ if (!container) {
22
+ return window;
23
+ }
24
+ if (typeof container === 'string') {
25
+ var el = document.querySelector(container);
26
+ return el || window;
27
+ }
28
+ return container;
29
+ }
30
+ // 获取当前滚动距离
31
+ function getScrollTop() {
32
+ if (scrollContainer === window) {
33
+ return window.scrollY || document.documentElement.scrollTop;
34
+ }
35
+ return scrollContainer.scrollTop;
36
+ }
37
+ // 获取滚动容器的高度
38
+ function getScrollHeight() {
39
+ if (scrollContainer === window) {
40
+ return document.documentElement.scrollHeight;
41
+ }
42
+ return scrollContainer.scrollHeight;
43
+ }
44
+ // 获取视口高度
45
+ function getViewportHeight() {
46
+ if (scrollContainer === window) {
47
+ return window.innerHeight;
48
+ }
49
+ return scrollContainer.clientHeight;
50
+ }
51
+ function getElementTop(element, container) {
52
+ if (container === window) {
53
+ // window: 累加 offsetTop
54
+ var offsetTop = 0;
55
+ var currentElement = element;
56
+ while (currentElement && currentElement !== document.body) {
57
+ offsetTop += currentElement.offsetTop;
58
+ currentElement = currentElement.offsetParent;
59
+ }
60
+ return offsetTop;
61
+ }
62
+ // 自定义容器: 使用 getBoundingClientRect
63
+ var containerEl = container;
64
+ var elementRect = element.getBoundingClientRect();
65
+ var containerRect = containerEl.getBoundingClientRect();
66
+ // 元素相对于容器内容区的位置 =
67
+ // (元素到视口顶部的距离 - 容器到视口顶部的距离) + 容器已滚动的距离
68
+ return elementRect.top - containerRect.top + containerEl.scrollTop;
69
+ }
70
+ function scrollTo(target) {
71
+ var _instance$get2 = instance.get(),
72
+ _instance$get2$offset = _instance$get2.offset,
73
+ offset = _instance$get2$offset === void 0 ? 0 : _instance$get2$offset,
74
+ _instance$get2$durati = _instance$get2.duration,
75
+ duration = _instance$get2$durati === void 0 ? 700 : _instance$get2$durati;
76
+ // 目标位置
77
+ var targetTop = getElementTop(target, scrollContainer) - offset;
78
+ // 当前位置
79
+ var currentTop = getScrollTop();
80
+ if (Math.abs(currentTop - targetTop) < 1) return;
81
+ if (scrollTimer) {
82
+ clearTimeout(scrollTimer);
83
+ }
84
+ isScrolling.set(true);
85
+ if (scrollContainer === window) {
86
+ window.scrollTo({
87
+ top: targetTop,
88
+ behavior: 'smooth'
89
+ });
90
+ } else {
91
+ scrollContainer.scrollTo({
92
+ top: targetTop,
93
+ behavior: 'smooth'
94
+ });
95
+ }
96
+ scrollTimer = window.setTimeout(function () {
97
+ isScrolling.set(false);
98
+ }, duration);
99
+ }
100
+ // 滚动触发的 value 更新
101
+ function setValueFromScroll(href) {
102
+ if (setIsSettingFromScroll) {
103
+ setIsSettingFromScroll(true);
104
+ }
105
+ try {
106
+ instance.set('value', href);
107
+ } finally {
108
+ if (setIsSettingFromScroll) {
109
+ setIsSettingFromScroll(false);
110
+ }
111
+ }
112
+ }
113
+ // 更新当前激活的锚点
114
+ function updateActive() {
115
+ if (isScrolling.value) return;
116
+ var _instance$get3 = instance.get(),
117
+ _instance$get3$offset = _instance$get3.offset,
118
+ offset = _instance$get3$offset === void 0 ? 0 : _instance$get3$offset,
119
+ _instance$get3$thresh = _instance$get3.threshold,
120
+ threshold = _instance$get3$thresh === void 0 ? 50 : _instance$get3$thresh;
121
+ var links = instance.getLinks();
122
+ // 只处理当前存在且可见的锚点
123
+ var candidates = [];
124
+ for (var _iterator = _createForOfIteratorHelperLoose(links), _step; !(_step = _iterator()).done;) {
125
+ var _href = _step.value;
126
+ var _element = instance.getTargetElement(_href);
127
+ if (_element && _element.getClientRects().length > 0) {
128
+ candidates.push({
129
+ href: _href,
130
+ element: _element
131
+ });
132
+ }
133
+ }
134
+ if (candidates.length === 0) return;
135
+ var scrollTop = getScrollTop();
136
+ var viewportHeight = getViewportHeight();
137
+ var totalHeight = getScrollHeight();
138
+ var activeHref = candidates[0].href;
139
+ if (scrollTop + viewportHeight >= totalHeight - 10) {
140
+ // 接近底部,激活最后一个可见锚点
141
+ activeHref = candidates[candidates.length - 1].href;
142
+ } else if (scrollTop <= threshold) {
143
+ // 接近顶部,激活第一个可见锚点
144
+ activeHref = candidates[0].href;
145
+ } else {
146
+ // 正常滚动,寻找最后一个被“滚到”的锚点
147
+ for (var _iterator2 = _createForOfIteratorHelperLoose(candidates), _step2; !(_step2 = _iterator2()).done;) {
148
+ var _step2$value = _step2.value,
149
+ href = _step2$value.href,
150
+ element = _step2$value.element;
151
+ var sectionTop = getElementTop(element, scrollContainer) - offset - threshold;
152
+ if (scrollTop >= sectionTop) {
153
+ activeHref = href;
154
+ } else {
155
+ break;
156
+ }
157
+ }
158
+ }
159
+ if (activeHref !== instance.get('value')) {
160
+ setValueFromScroll(activeHref);
161
+ }
162
+ }
163
+ // 滚动事件处理
164
+ function onScroll() {
165
+ if (isScrolling.value) return;
166
+ if (rafId) {
167
+ cancelAnimationFrame(rafId);
168
+ }
169
+ // 使用 requestAnimationFrame 优化滚动性能
170
+ rafId = requestAnimationFrame(updateActive);
171
+ }
172
+ // 挂载后的初始化
173
+ function init() {
174
+ setTimeout(function () {
175
+ scrollContainer = getScrollContainer();
176
+ if (scrollContainer === window) {
177
+ window.addEventListener('scroll', onScroll, {
178
+ passive: true
179
+ });
180
+ } else {
181
+ scrollContainer.addEventListener('scroll', onScroll, {
182
+ passive: true
183
+ });
184
+ }
185
+ var initialValue = instance.get('value');
186
+ if (initialValue) {
187
+ var element = instance.getTargetElement(initialValue);
188
+ if (element) {
189
+ scrollTo(element);
190
+ return;
191
+ }
192
+ }
193
+ }, 100);
194
+ return function () {
195
+ if (scrollTimer) {
196
+ clearTimeout(scrollTimer);
197
+ }
198
+ if (rafId) {
199
+ cancelAnimationFrame(rafId);
200
+ }
201
+ var currentContainer = scrollContainer;
202
+ if (currentContainer === window) {
203
+ window.removeEventListener('scroll', onScroll);
204
+ } else {
205
+ currentContainer.removeEventListener('scroll', onScroll);
206
+ }
207
+ };
208
+ }
209
+ return {
210
+ scrollTo: scrollTo,
211
+ updateActive: updateActive,
212
+ init: init,
213
+ isScrolling: isScrolling,
214
+ set setIsSettingFromScroll(fn) {
215
+ setIsSettingFromScroll = fn;
216
+ }
217
+ };
218
+ }
@@ -19,7 +19,6 @@ export default function ($props, $blocks, $__proto__) {
19
19
  hideClose = _this$get.hideClose,
20
20
  overlay = _this$get.overlay,
21
21
  value = _this$get.value,
22
- width = _this$get.width,
23
22
  mode = _this$get.mode,
24
23
  className = _this$get.className,
25
24
  cancelText = _this$get.cancelText,
@@ -28,6 +27,7 @@ export default function ($props, $blocks, $__proto__) {
28
27
  disabledOk = _this$get.disabledOk,
29
28
  title = _this$get.title,
30
29
  children = _this$get.children;
30
+ var width = $props.width !== undefined ? $props.width : this.get('width');
31
31
  var isHide = mode === 'hide';
32
32
  var k = this.config.k;
33
33
  var classNameObj = (_classNameObj = {}, _classNameObj[k + "-dialog"] = true, _classNameObj[k + "-dragging"] = this.drag.dragging.value, _classNameObj[className] = className, _classNameObj[$props.className] = $props.className, _classNameObj[k + "-" + size] = size !== 'default', _classNameObj[makeDialogStyles(k)] = true, _classNameObj);
@@ -3,9 +3,12 @@ import { BaseDialog, BaseDialogProps } from '../dialog/base';
3
3
  import { Placement } from './styles';
4
4
  export interface DrawerProps extends BaseDialogProps {
5
5
  placement?: Placement;
6
+ resizable?: boolean;
6
7
  }
7
8
  export declare class Drawer extends BaseDialog<DrawerProps> {
8
9
  static template: string | import('intact-react').Template<any>;
9
10
  static typeDefs: Required<TypeDefs<DrawerProps>>;
10
11
  static defaults: () => Partial<DrawerProps>;
12
+ private _resizable;
13
+ init(): void;
11
14
  }
@@ -1,22 +1,41 @@
1
1
  import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
2
2
  import _extends from "@babel/runtime-corejs3/helpers/extends";
3
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
3
4
  import template from './index.vdt';
4
5
  import { BaseDialog } from '../dialog/base';
5
6
  import { placements } from './styles';
7
+ import { useDrawerResizable } from './useDrawerResizable';
6
8
  var typeDefs = _extends({}, BaseDialog.typeDefs, {
7
- placement: placements
9
+ placement: placements,
10
+ resizable: Boolean
8
11
  });
9
12
  var defaults = function defaults() {
10
13
  return _extends({}, BaseDialog.defaults(), {
11
14
  placement: 'right',
12
- draggable: false
15
+ draggable: false,
16
+ resizable: false
13
17
  });
14
18
  };
15
19
  export var Drawer = /*#__PURE__*/function (_BaseDialog) {
16
20
  _inheritsLoose(Drawer, _BaseDialog);
17
21
  function Drawer() {
18
- return _BaseDialog.apply(this, arguments) || this;
22
+ var _context;
23
+ var _this;
24
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
25
+ args[_key] = arguments[_key];
26
+ }
27
+ _this = _BaseDialog.call.apply(_BaseDialog, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
28
+ _this._resizable = useDrawerResizable(_this.dialogRef);
29
+ return _this;
19
30
  }
31
+ var _proto = Drawer.prototype;
32
+ _proto.init = function init() {
33
+ var _this2 = this;
34
+ _BaseDialog.prototype.init.call(this);
35
+ this.watch('width', function (v) {
36
+ _this2._resizable.drawerWidth.set(v || null);
37
+ });
38
+ };
20
39
  return Drawer;
21
40
  }(BaseDialog);
22
41
  Drawer.template = template;
@@ -167,4 +167,87 @@ describe('Drawer', function () {
167
167
  }
168
168
  }, _callee5);
169
169
  })));
170
+ it('should show resize bar when resizable is true', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
171
+ var Demo, _mount5, instance, element;
172
+ return _regeneratorRuntime.wrap(function _callee6$(_context8) {
173
+ while (1) switch (_context8.prev = _context8.next) {
174
+ case 0:
175
+ Demo = /*#__PURE__*/function (_Component2) {
176
+ _inheritsLoose(Demo, _Component2);
177
+ function Demo() {
178
+ var _context7;
179
+ var _this2;
180
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
181
+ args[_key2] = arguments[_key2];
182
+ }
183
+ _this2 = _Component2.call.apply(_Component2, _concatInstanceProperty(_context7 = [this]).call(_context7, args)) || this;
184
+ _this2.Drawer = Drawer;
185
+ return _this2;
186
+ }
187
+ return Demo;
188
+ }(Component);
189
+ Demo.template = "\n const {Drawer} = this;\n <Drawer value={true} resizable={true} placement=\"right\">\n <div>Content</div>\n </Drawer>\n ";
190
+ _mount5 = mount(Demo), instance = _mount5[0], element = _mount5[1];
191
+ _context8.next = 5;
192
+ return wait();
193
+ case 5:
194
+ expect(getElement('.k-drawer-resize')).to.not.be.undefined;
195
+ case 6:
196
+ case "end":
197
+ return _context8.stop();
198
+ }
199
+ }, _callee6);
200
+ })));
201
+ it('should update width when dragging', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
202
+ var Demo, _mount6, instance, element, drawer, initialWidth, resizeBar, startX;
203
+ return _regeneratorRuntime.wrap(function _callee7$(_context10) {
204
+ while (1) switch (_context10.prev = _context10.next) {
205
+ case 0:
206
+ Demo = /*#__PURE__*/function (_Component3) {
207
+ _inheritsLoose(Demo, _Component3);
208
+ function Demo() {
209
+ var _context9;
210
+ var _this3;
211
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
212
+ args[_key3] = arguments[_key3];
213
+ }
214
+ _this3 = _Component3.call.apply(_Component3, _concatInstanceProperty(_context9 = [this]).call(_context9, args)) || this;
215
+ _this3.Drawer = Drawer;
216
+ return _this3;
217
+ }
218
+ return Demo;
219
+ }(Component);
220
+ Demo.template = "\n const {Drawer} = this;\n <Drawer value={true} resizable={true} placement=\"right\" ref=\"drawer\">\n <div>Content</div>\n </Drawer>\n ";
221
+ _mount6 = mount(Demo), instance = _mount6[0], element = _mount6[1];
222
+ _context10.next = 5;
223
+ return wait();
224
+ case 5:
225
+ drawer = instance.refs.drawer.dialogRef.value;
226
+ initialWidth = drawer.offsetWidth;
227
+ resizeBar = getElement('.k-drawer-resize');
228
+ startX = resizeBar.getBoundingClientRect().left;
229
+ dispatchEvent(resizeBar, 'mousedown', {
230
+ clientX: startX,
231
+ which: 1
232
+ });
233
+ _context10.next = 12;
234
+ return wait();
235
+ case 12:
236
+ dispatchEvent(document, 'mousemove', {
237
+ clientX: startX - 50
238
+ });
239
+ _context10.next = 15;
240
+ return wait();
241
+ case 15:
242
+ dispatchEvent(document, 'mouseup');
243
+ _context10.next = 18;
244
+ return wait(100);
245
+ case 18:
246
+ expect(drawer.offsetWidth).to.be.greaterThan(initialWidth);
247
+ case 19:
248
+ case "end":
249
+ return _context10.stop();
250
+ }
251
+ }, _callee7);
252
+ })));
170
253
  });
@@ -7,16 +7,36 @@ export default function ($props, $blocks, $__proto__) {
7
7
  var $this = this;
8
8
  var _this$get = this.get(),
9
9
  placement = _this$get.placement,
10
- overlay = _this$get.overlay;
10
+ overlay = _this$get.overlay,
11
+ resizable = _this$get.resizable,
12
+ width = _this$get.width;
13
+ var _this$_resizable = this._resizable,
14
+ getResizeBarPosition = _this$_resizable.getResizeBarPosition,
15
+ getHeightResizeBarPosition = _this$_resizable.getHeightResizeBarPosition,
16
+ drawerWidth = _this$_resizable.drawerWidth,
17
+ isResizing = _this$_resizable.isResizing,
18
+ drawerHeight = _this$_resizable.drawerHeight,
19
+ startWidth = _this$_resizable.startWidth,
20
+ startHeight = _this$_resizable.startHeight;
21
+ var shouldShowHeightResizeBar = !!(resizable && (placement === 'top' || placement === 'bottom'));
11
22
  var k = this.config.k;
12
23
  var classNameObj = (_classNameObj = {}, _classNameObj[k + "-drawer"] = true, _classNameObj[k + "-" + placement] = true, _classNameObj[makeStyles(overlay, k)] = true, _classNameObj);
13
24
  return _$su.call($this, {
14
- 'className': _$cn(classNameObj)
25
+ 'className': _$cn(classNameObj),
26
+ 'width': resizable ? drawerWidth.value || width : width
15
27
  }, function ($blocks) {
16
28
  var _$blocks = {},
17
29
  __$blocks = _$ex({}, $blocks);
18
30
  return (_$blocks['_content'] = function ($super) {
19
- return _$ce(2, 'div', $super(), 0, _$cn(k + "-drawer-content"));
31
+ return _$ce(2, 'div', [$super(), !!resizable ? _$ce(2, 'div', null, 1, _$cn(k + "-drawer-resize " + k + "-drawer-resize-" + getResizeBarPosition()), {
32
+ 'ev-mousedown': startWidth
33
+ }) : undefined, shouldShowHeightResizeBar ? _$ce(2, 'div', null, 1, _$cn(k + "-drawer-resize-horizontal " + k + "-drawer-resize-" + getHeightResizeBarPosition()), {
34
+ 'ev-mousedown': startHeight
35
+ }) : undefined], 0, _$cn(k + "-drawer-content " + (isResizing.value ? k + "-drawer-resizing" : '')), {
36
+ 'style': drawerHeight.value ? {
37
+ height: drawerHeight.value + "px"
38
+ } : null
39
+ });
20
40
  }, __$blocks['_content'] = function ($super, data) {
21
41
  var block = $blocks['_content'];
22
42
  var callBlock = function callBlock() {
@@ -21,7 +21,7 @@ setDefault(function () {
21
21
  });
22
22
  export var makeStyles = cache(function makeStyles(overlay, k) {
23
23
  var borderRadius = theme.largeBorderRadius;
24
- return /*#__PURE__*/css("&.k-drawer{position:fixed;background:transparent;box-shadow:none;border-radius:0;}&.transition-enter-active,&.transition-leave-active,&.transition-appear-active{transition:opacity ", drawer.transition, "!important;overflow:hidden;.", k, "-drawer-content{transition:transform ", drawer.transition, ";}}.", k, "-drawer-content{height:100%;display:flex;background:#fff;flex-direction:column;transform:translateX(0);box-shadow:", drawer.boxShadow, ";.", k, "-dialog-body{flex-grow:1;overflow:auto;}}", makePlacementStyles(k, 'right', "right: 0; height: 100%;", "translateX(100%)", borderRadius + " 0 0 " + borderRadius), " ", makePlacementStyles(k, 'left', 'left: 0; height: 100%;', "translateX(-100%)", "0 " + borderRadius + " " + borderRadius + " 0"), " ", makePlacementStyles(k, 'top', 'left: 50%; top: 0; transform: translateX(-50%);', "translateY(-100%)", "0 0 " + borderRadius + " " + borderRadius), " ", makePlacementStyles(k, 'bottom', 'left: 50%; bottom: 0; transform: translateX(-50%);', "translateY(100%)", "0 " + borderRadius + " " + borderRadius + " 0"), " &.", k, "-top,&.", k, "-bottom{width:100%;}");
24
+ return /*#__PURE__*/css("&.k-drawer{position:fixed;background:transparent;box-shadow:none;border-radius:0;max-height:100vh;}&.transition-enter-active,&.transition-leave-active,&.transition-appear-active{transition:opacity ", drawer.transition, "!important;overflow:hidden;.", k, "-drawer-content{transition:transform ", drawer.transition, ";}}.", k, "-drawer-content{height:100%;max-height:100vh;display:flex;background:#fff;flex-direction:column;transform:translateX(0);box-shadow:", drawer.boxShadow, ";position:relative;.", k, "-dialog-body{flex-grow:1;overflow:auto;}&.", k, "-drawer-resizing{transition:none!important;}}.", k, "-drawer-resize{position:absolute;top:0;bottom:0;width:5px;cursor:col-resize;z-index:10;user-select:none;&:hover{background:rgba(0, 0, 0, 0.1);}&.", k, "-drawer-resize-right{right:0;}&.", k, "-drawer-resize-left{left:0;}}.", k, "-drawer-resize-horizontal{position:absolute;left:0;right:0;height:5px;cursor:row-resize;z-index:10;user-select:none;&:hover{background:rgba(0, 0, 0, 0.1);}&.", k, "-drawer-resize-top{top:0;}&.", k, "-drawer-resize-bottom{bottom:0;}}", makePlacementStyles(k, 'right', "right: 0; height: 100%;", "translateX(100%)", borderRadius + " 0 0 " + borderRadius), " ", makePlacementStyles(k, 'left', 'left: 0; height: 100%;', "translateX(-100%)", "0 " + borderRadius + " " + borderRadius + " 0"), " ", makePlacementStyles(k, 'top', 'left: 50%; top: 0; transform: translateX(-50%);', "translateY(-100%)", "0 0 " + borderRadius + " " + borderRadius), " ", makePlacementStyles(k, 'bottom', 'left: 50%; bottom: 0; transform: translateX(-50%);', "translateY(100%)", "0 " + borderRadius + " " + borderRadius + " 0"), " &.", k, "-top,&.", k, "-bottom{width:100%;}");
25
25
  });
26
26
  function makePlacementStyles(k, placement, styles, transform, borderRadius) {
27
27
  return /*#__PURE__*/css("&.", k, "-drawer.", k, "-", placement, "{", styles, " &.transition-enter-from,&.transition-leave-to,&.transition-appear-from{.", k, "-drawer-content{transform:", transform, ";}}.", k, "-drawer-content{border-radius:", borderRadius, ";}}");
@@ -0,0 +1,10 @@
1
+ import { RefObject } from 'intact-react';
2
+ export declare function useDrawerResizable(drawerRef: RefObject<HTMLElement>): {
3
+ drawerWidth: import("../../hooks/useState").State<string | number | null>;
4
+ drawerHeight: import("../../hooks/useState").State<number | null>;
5
+ isResizing: import("../../hooks/useState").State<boolean>;
6
+ getResizeBarPosition: () => 'left' | 'right';
7
+ getHeightResizeBarPosition: () => 'top' | 'bottom';
8
+ startWidth: (e: MouseEvent) => void;
9
+ startHeight: (e: MouseEvent) => void;
10
+ };
@@ -0,0 +1,162 @@
1
+ import { useInstance, onMounted, onBeforeUnmount } from 'intact-react';
2
+ import { useState } from '../../hooks/useState';
3
+ import { useDraggable } from '../../hooks/useDraggable';
4
+ export function useDrawerResizable(drawerRef) {
5
+ var instance = useInstance();
6
+ var _instance$get = instance.get(),
7
+ width = _instance$get.width;
8
+ var drawerWidth = useState(width || null);
9
+ var drawerHeight = useState(null);
10
+ var isResizing = useState(false);
11
+ var startX = 0;
12
+ var startWidth = 0;
13
+ var startY = 0;
14
+ var startHeight = 0;
15
+ var minWidth = 200; // 最小宽度
16
+ var maxWidth = window.innerWidth; // 最大宽度
17
+ var minHeight = 200; // 最小高度
18
+ var maxHeight = window.innerHeight; // 最大高度
19
+ // 监听窗口大小变化,更新最大宽高
20
+ var handleResize = null;
21
+ onMounted(function () {
22
+ handleResize = function handleResize() {
23
+ maxWidth = window.innerWidth;
24
+ maxHeight = window.innerHeight;
25
+ };
26
+ window.addEventListener('resize', handleResize);
27
+ });
28
+ onBeforeUnmount(function () {
29
+ if (handleResize) {
30
+ window.removeEventListener('resize', handleResize);
31
+ }
32
+ });
33
+ // 宽度拖拽
34
+ function onStartWidth(e) {
35
+ var drawer = drawerRef.value;
36
+ if (!drawer) return;
37
+ startX = e.clientX;
38
+ startWidth = drawer.offsetWidth;
39
+ drawerWidth.set(startWidth);
40
+ isResizing.set(true);
41
+ // 锁定全局样式
42
+ document.body.style.cursor = 'col-resize';
43
+ document.body.style.userSelect = 'none';
44
+ }
45
+ function onMoveWidth(e) {
46
+ var drawer = drawerRef.value;
47
+ if (!drawer) return;
48
+ var _instance$get2 = instance.get(),
49
+ placement = _instance$get2.placement,
50
+ resizable = _instance$get2.resizable;
51
+ // 计算鼠标移动距离
52
+ var deltaX = e.clientX - startX;
53
+ var widthDelta = deltaX;
54
+ // 根据 placement 调整拖拽方向
55
+ if (placement === 'right') {
56
+ widthDelta = -deltaX;
57
+ } else if (placement === 'left') {
58
+ widthDelta = deltaX;
59
+ } else {
60
+ // top / bottom 模式:由于是居中(left: 50%, transform: translateX(-50%))对称增长
61
+ // 宽度变化量应该是位移的两倍才能保持鼠标跟随
62
+ widthDelta = deltaX * 2;
63
+ }
64
+ var newWidth = Math.max(minWidth, Math.min(maxWidth, startWidth + widthDelta));
65
+ drawerWidth.set(newWidth);
66
+ }
67
+ function onEndWidth() {
68
+ isResizing.set(false);
69
+ // 恢复全局样式
70
+ document.body.style.cursor = '';
71
+ document.body.style.userSelect = '';
72
+ }
73
+ var widthDrag = useDraggable({
74
+ onStart: onStartWidth,
75
+ onMove: onMoveWidth,
76
+ onEnd: onEndWidth,
77
+ disable: function disable() {
78
+ var _instance$get3 = instance.get(),
79
+ resizable = _instance$get3.resizable;
80
+ return !resizable;
81
+ }
82
+ });
83
+ // 高度拖拽,仅在 placement 为 top / bottom 时启用
84
+ function onStartHeight(e) {
85
+ var drawer = drawerRef.value;
86
+ if (!drawer) return;
87
+ var _instance$get4 = instance.get(),
88
+ placement = _instance$get4.placement,
89
+ resizable = _instance$get4.resizable;
90
+ if (!resizable || placement !== 'top' && placement !== 'bottom') return;
91
+ startY = e.clientY;
92
+ startHeight = drawer.offsetHeight;
93
+ drawerHeight.set(startHeight);
94
+ isResizing.set(true);
95
+ // 锁定全局样式
96
+ document.body.style.cursor = 'row-resize';
97
+ document.body.style.userSelect = 'none';
98
+ }
99
+ function onMoveHeight(e) {
100
+ var drawer = drawerRef.value;
101
+ if (!drawer) return;
102
+ var _instance$get5 = instance.get(),
103
+ placement = _instance$get5.placement;
104
+ if (placement !== 'top' && placement !== 'bottom') return;
105
+ var deltaY = e.clientY - startY;
106
+ var heightDelta = placement === 'top' ? deltaY : -deltaY;
107
+ var newHeight = Math.max(minHeight, Math.min(maxHeight, startHeight + heightDelta));
108
+ // 设置状态,由模板进行渲染
109
+ drawerHeight.set(newHeight);
110
+ }
111
+ function onEndHeight() {
112
+ isResizing.set(false);
113
+ // 恢复全局样式
114
+ document.body.style.cursor = '';
115
+ document.body.style.userSelect = '';
116
+ }
117
+ var heightDrag = useDraggable({
118
+ onStart: onStartHeight,
119
+ onMove: onMoveHeight,
120
+ onEnd: onEndHeight,
121
+ disable: function disable() {
122
+ var _instance$get6 = instance.get(),
123
+ placement = _instance$get6.placement,
124
+ resizable = _instance$get6.resizable;
125
+ return !resizable || placement !== 'top' && placement !== 'bottom';
126
+ }
127
+ });
128
+ // 重置 resize 状态
129
+ function resetResizeState() {
130
+ var _instance$get7 = instance.get(),
131
+ width = _instance$get7.width;
132
+ drawerWidth.set(width || null);
133
+ drawerHeight.set(null);
134
+ }
135
+ // 监听 placement 变化,切换时重置 resize 状态
136
+ instance.watch('placement', function (newPlacement, oldPlacement) {
137
+ if (oldPlacement !== undefined && newPlacement !== oldPlacement) {
138
+ resetResizeState();
139
+ }
140
+ });
141
+ // 获取宽度拖拽条位置
142
+ function getResizeBarPosition() {
143
+ var _instance$get8 = instance.get(),
144
+ placement = _instance$get8.placement;
145
+ return placement === 'right' ? 'left' : 'right';
146
+ }
147
+ // 获取高度拖拽条位置
148
+ function getHeightResizeBarPosition() {
149
+ var _instance$get9 = instance.get(),
150
+ placement = _instance$get9.placement;
151
+ return placement === 'top' ? 'bottom' : 'top';
152
+ }
153
+ return {
154
+ drawerWidth: drawerWidth,
155
+ drawerHeight: drawerHeight,
156
+ isResizing: isResizing,
157
+ getResizeBarPosition: getResizeBarPosition,
158
+ getHeightResizeBarPosition: getHeightResizeBarPosition,
159
+ startWidth: widthDrag.start,
160
+ startHeight: heightDrag.start
161
+ };
162
+ }
@@ -38,6 +38,7 @@ declare const defaults: {
38
38
  readonly border: string;
39
39
  item: {
40
40
  readonly color: string;
41
+ readonly arrowColor: string;
41
42
  readonly hoverColor: string;
42
43
  readonly hoverBg: string;
43
44
  disabledColor: string;
@@ -58,6 +58,9 @@ var defaults = {
58
58
  get color() {
59
59
  return theme.color.text;
60
60
  },
61
+ get arrowColor() {
62
+ return theme.color.lightBlack;
63
+ },
61
64
  get hoverColor() {
62
65
  return theme.color.primary;
63
66
  },
@@ -112,7 +115,7 @@ export { menu };
112
115
  export var makeMenuStyles = cache(function makeMenuStyles(k) {
113
116
  // we must increase the priority by adding &.${k}-menu
114
117
  // to override the css of dropdownMenu
115
- return /*#__PURE__*/css("&.", k, "-menu{width:", menu.width, ";transition:width ", menu.transition, ";background:", menu.bgColor, ";font-size:", menu.fontSize, ";position:relative;}.", k, "-icon{width:", menu.icon.width, ";margin-right:", menu.icon.gap, ";text-align:center;flex-shrink:0;}.", k, "-menu-header{height:", menu.header.height, ";padding:0 16px;color:", menu.header.color, ";font-size:", menu.header.fontSize, ";font-weight:bold;}.", k, "-menu-body{padding:", menu.item.bodyPadding, ";max-height:calc(100% - ", menu.header.height, ");overflow-y:auto;overflow-x:hidden;scrollbar-width:none;}.", k, "-menu-title{height:", menu.title.height, ";border-top:", menu.border, ";margin-top:4px;.", k, "-menu-name{transition:all ", menu.transition, ";height:", menu.title.height, ";color:", menu.title.color, ";font-weight:bold;}}.", k, "-menu-arrow-box{width:14px;height:60px;cursor:pointer;background:", menu.bgColor, ";border-radius:0 8px 8px 0;position:absolute;display:flex;align-items:center;justify-content:center;top:50%;left:calc(", menu.width, " - 2px);transition:left ", menu.transition, ";transform:translateY(-50%);border:", menu.border, ";border-left:none;.", k, "-icon{margin-right:0;}&:hover{.", k, "-menu-arrow:before{color:", menu.item.activeBgColor, ";}}}&.", k, "-light{border-right:1px solid ", theme.color.disabledBg, ";background:", menu.light.bgColor, ";.", k, "-menu-header{color:", menu.light.title.color, ";}.", k, "-menu-item{.", k, "-menu-item-title{color:", menu.light.item.color, ";&:hover{background:", menu.light.item.hoverBg, ";}}.", k, "-menu-item-arrow{color:", menu.light.item.color, ";}&.", k, "-highlighted{>.", k, "-menu-item-title{color:", menu.light.item.hoverColor, ";}}&.", k, "-disabled{>.", k, "-menu-item-title{color:", menu.light.item.disabledColor, "!important;}}}.", k, "-menu-title{border-top:", menu.light.border, ";.", k, "-menu-name{color:", menu.light.title.color, ";}}.", k, "-menu-arrow-box{background:", menu.light.bgColor, ";border:", menu.light.border, ";border-left:none;&:hover{.", k, "-menu-arrow:before{color:", menu.light.active.color, ";}}}.", k, "-menu:not(.", k, "-dropdown-menu){background:", menu.light.bgColor, ";}&.", k, "-horizontal{.", k, "-menu-header{border-right:", menu.light.border, ";}.", k, "-menu-body>.", k, "-menu-title{border-right:", menu.light.border, ";}}.", k, "-menu-item.", k, "-active{>.", k, "-menu-item-title{color:", menu.light.active.color, "!important;background:", menu.light.active.bgColor, ";}}.", k, "-sub-menu{.", k, "-menu-item-title,.", k, "-menu-item-arrow{color:", menu.light.item.subTitleColor, "!important;}}}", _mapInstanceProperty(sizes).call(sizes, function (size) {
118
+ return /*#__PURE__*/css("&.", k, "-menu{width:", menu.width, ";transition:width ", menu.transition, ";background:", menu.bgColor, ";font-size:", menu.fontSize, ";position:relative;}.", k, "-icon{width:", menu.icon.width, ";margin-right:", menu.icon.gap, ";text-align:center;flex-shrink:0;}.", k, "-menu-header{height:", menu.header.height, ";padding:0 16px;color:", menu.header.color, ";font-size:", menu.header.fontSize, ";font-weight:bold;}.", k, "-menu-body{padding:", menu.item.bodyPadding, ";max-height:calc(100% - ", menu.header.height, ");overflow-y:auto;overflow-x:hidden;scrollbar-width:none;}.", k, "-menu-title{height:", menu.title.height, ";border-top:", menu.border, ";margin-top:4px;.", k, "-menu-name{transition:all ", menu.transition, ";height:", menu.title.height, ";color:", menu.title.color, ";font-weight:bold;}}.", k, "-menu-arrow-box{width:14px;height:60px;cursor:pointer;background:", menu.bgColor, ";border-radius:0 8px 8px 0;position:absolute;display:flex;align-items:center;justify-content:center;top:50%;left:calc(", menu.width, " - 2px);transition:left ", menu.transition, ";transform:translateY(-50%);border:", menu.border, ";border-left:none;.", k, "-icon{margin-right:0;}&:hover{.", k, "-menu-arrow:before{color:", menu.item.activeBgColor, ";}}}&.", k, "-light{border-right:1px solid ", theme.color.disabledBg, ";background:", menu.light.bgColor, ";.", k, "-menu-header{color:", menu.light.title.color, ";}.", k, "-menu-item{.", k, "-menu-item-title{color:", menu.light.item.color, ";&:hover{background:", menu.light.item.hoverBg, ";}}.", k, "-menu-item-arrow{color:", menu.light.item.arrowColor, ";}&.", k, "-highlighted{>.", k, "-menu-item-title{color:", menu.light.item.hoverColor, ";}}&.", k, "-disabled{>.", k, "-menu-item-title{color:", menu.light.item.disabledColor, "!important;}}}.", k, "-menu-title{border-top:", menu.light.border, ";.", k, "-menu-name{color:", menu.light.title.color, ";}}.", k, "-menu-arrow-box{background:", menu.light.bgColor, ";border:", menu.light.border, ";border-left:none;&:hover{.", k, "-menu-arrow:before{color:", menu.light.active.color, ";}}}.", k, "-menu:not(.", k, "-dropdown-menu){background:", menu.light.bgColor, ";}&.", k, "-horizontal{.", k, "-menu-header{border-right:", menu.light.border, ";}.", k, "-menu-body>.", k, "-menu-title{border-right:", menu.light.border, ";}}.", k, "-menu-item.", k, "-active{>.", k, "-menu-item-title{color:", menu.light.active.color, "!important;background:", menu.light.active.bgColor, ";}}.", k, "-sub-menu{.", k, "-menu-item-title{color:", menu.light.item.subTitleColor, "!important;}.", k, "-menu-item-arrow{color:", menu.light.item.arrowColor, "!important;}}}", _mapInstanceProperty(sizes).call(sizes, function (size) {
116
119
  var styles = menu[size];
117
120
  return /*#__PURE__*/css("&.", k, "-", size, "{width:", styles.width, ";font-size:", styles.fontSize, ";.", k, "-menu{font-size:", styles.fontSize, ";}.", k, "-menu-arrow-box{left:calc(", styles.width, " - 2px);}}");
118
121
  }), "&.", k, "-collapsed{width:calc(", menu.icon.width, " + (", getLeft(menu.item.padding), " + ", getLeft(menu.item.bodyPadding), ") * 2);.", k, "-icon{margin-right:0;}.", k, "-menu-item-arrow{display:none;}}&.", k, "-collapsed-arrow{width:0px;border-left:none;.", k, "-menu-header{padding:0;}.", k, "-menu-body{overflow:hidden;padding:0;}.", k, "-menu-arrow-box{left:0;.", k, "-menu-arrow:before{transform:rotateY(180deg);}}}&.", k, "-dropdown-menu{width:fit-content;min-width:", menu.dropdown.minWidth, ";position:absolute;.", k, "-menu-item-arrow{transform:rotate(-90deg);}}&.", k, "-horizontal{width:auto;display:flex;.", k, "-menu-body{display:flex;align-items:center;.", k, "-menu-title{border-top:none;border-right:", menu.border, ";}}}");
@@ -0,0 +1 @@
1
+ export * from './notification';
@@ -0,0 +1 @@
1
+ export * from './notification';
@@ -0,0 +1 @@
1
+ export {};