@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,2 @@
1
+ export declare const ANCHOR = "Anchor";
2
+ export declare const ANCHOR_LINK_LEVEL = "AnchorLinkLevel";
@@ -0,0 +1,2 @@
1
+ export var ANCHOR = 'Anchor';
2
+ export var ANCHOR_LINK_LEVEL = 'AnchorLinkLevel';
@@ -0,0 +1,41 @@
1
+ import { Component, TypeDefs } from 'intact-react';
2
+ import { Sizes } from '../../styles/utils';
3
+ import type { Events } from '../types';
4
+ import type { AnchorLinkProps } from './link';
5
+ export * from './link';
6
+ export interface AnchorProps {
7
+ value?: string;
8
+ offset?: number;
9
+ container?: string | HTMLElement;
10
+ threshold?: number;
11
+ vertical?: boolean;
12
+ size?: Sizes;
13
+ duration?: number;
14
+ }
15
+ export interface AnchorEvents {
16
+ change: [string];
17
+ click: [MouseEvent, AnchorLinkProps];
18
+ }
19
+ export declare class Anchor extends Component<AnchorProps, AnchorEvents> {
20
+ static template: string | import('intact-react').Template<any>;
21
+ static typeDefs: Required<TypeDefs<AnchorProps>>;
22
+ static defaults: () => Partial<AnchorProps>;
23
+ static events: Events<AnchorEvents>;
24
+ private scroll;
25
+ config: {
26
+ cls: (name: string) => string;
27
+ readonly k: string;
28
+ readonly disableWave: boolean;
29
+ };
30
+ private links;
31
+ private cleanup?;
32
+ private isSettingFromScroll;
33
+ private elementCache;
34
+ init(): void;
35
+ mounted(): void;
36
+ beforeUnmount(): void;
37
+ updated(): void;
38
+ private updateLinks;
39
+ getLinks(): string[];
40
+ getTargetElement(href: string): HTMLElement | null;
41
+ }
@@ -0,0 +1,141 @@
1
+ import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
2
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
3
+ import _Map from "@babel/runtime-corejs3/core-js/map";
4
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js/instance/includes";
5
+ import _startsWithInstanceProperty from "@babel/runtime-corejs3/core-js/instance/starts-with";
6
+ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/slice";
7
+ import { Component, provide } from 'intact-react';
8
+ import template from './index.vdt';
9
+ import { ANCHOR } from './constants';
10
+ import { sizes } from '../../styles/utils';
11
+ import { useScroll } from './useScroll';
12
+ import { useConfigContext } from '../config';
13
+ import { AnchorLink } from './link';
14
+ import { eachChildren, isComponentVNode } from '../utils';
15
+ export * from './link';
16
+ var typeDefs = {
17
+ value: String,
18
+ offset: Number,
19
+ container: [String, Object],
20
+ threshold: Number,
21
+ vertical: Boolean,
22
+ size: sizes,
23
+ duration: Number
24
+ };
25
+ var defaults = function defaults() {
26
+ return {
27
+ offset: 0,
28
+ threshold: 50,
29
+ vertical: true,
30
+ size: 'default',
31
+ duration: 700
32
+ };
33
+ };
34
+ var events = {
35
+ change: true,
36
+ click: true
37
+ };
38
+ export var Anchor = /*#__PURE__*/function (_Component) {
39
+ _inheritsLoose(Anchor, _Component);
40
+ function Anchor() {
41
+ var _context;
42
+ var _this;
43
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
44
+ args[_key] = arguments[_key];
45
+ }
46
+ _this = _Component.call.apply(_Component, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
47
+ _this.scroll = useScroll();
48
+ _this.config = useConfigContext();
49
+ _this.links = [];
50
+ _this.cleanup = void 0;
51
+ // 标记是否是滚动触发的 value 变化
52
+ _this.isSettingFromScroll = false;
53
+ // 元素引用缓存,避免重复的 getElementById 调用
54
+ _this.elementCache = new _Map();
55
+ return _this;
56
+ }
57
+ var _proto = Anchor.prototype;
58
+ _proto.init = function init() {
59
+ var _this2 = this;
60
+ provide(ANCHOR, this);
61
+ this.scroll.setIsSettingFromScroll = function (value) {
62
+ _this2.isSettingFromScroll = value;
63
+ };
64
+ this.watch('value', function (newValue, oldValue) {
65
+ if (newValue !== oldValue && newValue !== undefined && newValue !== null) {
66
+ _this2.trigger('change', newValue);
67
+ // 只有非滚动触发的 value 变化才 scrollTo
68
+ // 即:用户点击 tab 或外部 set 时才会 scrollTo
69
+ if (!_this2.isSettingFromScroll) {
70
+ var element = _this2.getTargetElement(newValue);
71
+ // 元素存在且可见
72
+ if (element && element.getClientRects().length > 0) {
73
+ _this2.scroll.scrollTo(element);
74
+ }
75
+ }
76
+ }
77
+ }, {
78
+ inited: true
79
+ });
80
+ };
81
+ _proto.mounted = function mounted() {
82
+ this.updateLinks();
83
+ this.cleanup = this.scroll.init();
84
+ };
85
+ _proto.beforeUnmount = function beforeUnmount() {
86
+ if (this.cleanup) {
87
+ this.cleanup();
88
+ }
89
+ // 清理元素缓存
90
+ this.elementCache.clear();
91
+ };
92
+ _proto.updated = function updated() {
93
+ this.updateLinks();
94
+ };
95
+ _proto.updateLinks = function updateLinks() {
96
+ var _this3 = this;
97
+ var links = [];
98
+ var children = this.get('children');
99
+ // 递归收集所有层级的 AnchorLink 的 href
100
+ var collectLinks = function collectLinks(children) {
101
+ if (!children) return;
102
+ eachChildren(children, function (vNode) {
103
+ if (isComponentVNode(vNode, AnchorLink)) {
104
+ var props = vNode.props || {};
105
+ if (props.href) {
106
+ links.push(props.href);
107
+ }
108
+ if (vNode.props && vNode.props.children) {
109
+ collectLinks(vNode.props.children);
110
+ }
111
+ }
112
+ });
113
+ };
114
+ collectLinks(children);
115
+ this.links = links;
116
+ // 清理不在当前链接列表中的缓存
117
+ this.elementCache.forEach(function (_, href) {
118
+ if (!_includesInstanceProperty(links).call(links, href)) {
119
+ _this3.elementCache.delete(href);
120
+ }
121
+ });
122
+ };
123
+ _proto.getLinks = function getLinks() {
124
+ return this.links;
125
+ };
126
+ _proto.getTargetElement = function getTargetElement(href) {
127
+ if (!href) return null;
128
+ if (this.elementCache.has(href)) {
129
+ return this.elementCache.get(href);
130
+ }
131
+ var id = _startsWithInstanceProperty(href).call(href, '#') ? _sliceInstanceProperty(href).call(href, 1) : href;
132
+ var element = document.getElementById(id);
133
+ this.elementCache.set(href, element);
134
+ return element;
135
+ };
136
+ return Anchor;
137
+ }(Component);
138
+ Anchor.template = template;
139
+ Anchor.typeDefs = typeDefs;
140
+ Anchor.defaults = defaults;
141
+ Anchor.events = events;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,230 @@
1
+ import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
2
+ import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
3
+ import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
4
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
5
+ import _Promise from "@babel/runtime-corejs3/core-js/promise";
6
+ import BasicDemo from '~/components/anchor/demos/basic';
7
+ import NestedDemo from '~/components/anchor/demos/nested';
8
+ import { mount, unmount, wait, dispatchEvent } from '../../test/utils';
9
+ import { Anchor, AnchorLink } from './';
10
+ import { Component } from 'intact-react';
11
+ // 基础 Demo
12
+ var BaseAnchorDemo = /*#__PURE__*/function (_Component) {
13
+ _inheritsLoose(BaseAnchorDemo, _Component);
14
+ function BaseAnchorDemo() {
15
+ var _context;
16
+ var _this;
17
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
18
+ args[_key] = arguments[_key];
19
+ }
20
+ _this = _Component.call.apply(_Component, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
21
+ _this.Anchor = Anchor;
22
+ _this.AnchorLink = AnchorLink;
23
+ return _this;
24
+ }
25
+ var _proto = BaseAnchorDemo.prototype;
26
+ _proto.getAnchorProps = function getAnchorProps() {
27
+ return {};
28
+ };
29
+ BaseAnchorDemo.defaults = function defaults() {
30
+ return {
31
+ value: 'section1'
32
+ };
33
+ };
34
+ return BaseAnchorDemo;
35
+ }(Component);
36
+ BaseAnchorDemo.template = "\n const {Anchor, AnchorLink} = this;\n <div style=\"display: flex; gap: 20px; align-items: flex-start;\">\n <div id=\"scroll-container-test\" style=\"flex: 1; height: 300px; overflow-y: auto;\">\n <div id=\"section1\" style=\"height: 300px; padding: 20px;\">Section 1</div>\n <div id=\"section2\" style=\"height: 300px; padding: 20px;\">Section 2</div>\n <div id=\"section3\" style=\"height: 300px; padding: 20px;\">Section 3</div>\n </div>\n <Anchor v-model=\"value\" container=\"#scroll-container-test\" {...this.getAnchorProps()}>\n <AnchorLink href=\"section1\" title=\"Section 1\" />\n <AnchorLink href=\"section2\" title=\"Section 2\" />\n <AnchorLink href=\"section3\" title=\"Section 3\" />\n </Anchor>\n </div>\n ";
37
+ describe('Anchor', function () {
38
+ afterEach(function () {
39
+ unmount();
40
+ });
41
+ it('should render basic anchor correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
42
+ var _mount, instance, element, anchor;
43
+ return _regeneratorRuntime.wrap(function _callee$(_context2) {
44
+ while (1) switch (_context2.prev = _context2.next) {
45
+ case 0:
46
+ _mount = mount(BasicDemo), instance = _mount[0], element = _mount[1];
47
+ _context2.next = 3;
48
+ return wait(200);
49
+ case 3:
50
+ anchor = element.querySelector('.k-anchor');
51
+ expect(anchor).to.exist;
52
+ expect(anchor.outerHTML).to.matchSnapshot();
53
+ case 6:
54
+ case "end":
55
+ return _context2.stop();
56
+ }
57
+ }, _callee);
58
+ })));
59
+ it('should scroll to target position when clicking anchor link', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
60
+ var Demo, _mount2, instance, element, container, anchor, secondLink, section2, initialScrollTop, finalScrollTop, rect, containerRect;
61
+ return _regeneratorRuntime.wrap(function _callee2$(_context3) {
62
+ while (1) switch (_context3.prev = _context3.next) {
63
+ case 0:
64
+ this.timeout(0);
65
+ Demo = /*#__PURE__*/function (_BaseAnchorDemo) {
66
+ _inheritsLoose(Demo, _BaseAnchorDemo);
67
+ function Demo() {
68
+ return _BaseAnchorDemo.apply(this, arguments) || this;
69
+ }
70
+ return Demo;
71
+ }(BaseAnchorDemo);
72
+ _mount2 = mount(Demo), instance = _mount2[0], element = _mount2[1];
73
+ _context3.next = 5;
74
+ return wait(300);
75
+ case 5:
76
+ container = document.querySelector('#scroll-container-test');
77
+ anchor = element.querySelector('.k-anchor');
78
+ secondLink = anchor.querySelectorAll('.k-tab')[1];
79
+ section2 = document.getElementById('section2'); // 先滚动到顶部
80
+ container.scrollTop = 0;
81
+ _context3.next = 12;
82
+ return wait(100);
83
+ case 12:
84
+ initialScrollTop = container.scrollTop; // 点击第二个锚点链接
85
+ secondLink.click();
86
+ // 等待滚动动画完成
87
+ _context3.next = 16;
88
+ return wait(800);
89
+ case 16:
90
+ // 检查容器是否滚动
91
+ finalScrollTop = container.scrollTop;
92
+ expect(finalScrollTop).to.be.greaterThan(initialScrollTop);
93
+ // 检查 section2 是否在视口内或接近视口顶部
94
+ rect = section2.getBoundingClientRect();
95
+ containerRect = container.getBoundingClientRect();
96
+ expect(rect.top).to.be.lessThan(containerRect.bottom);
97
+ case 21:
98
+ case "end":
99
+ return _context3.stop();
100
+ }
101
+ }, _callee2, this);
102
+ })));
103
+ it('should update value when scrolling', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
104
+ var Demo, _mount3, instance, element, container, targetScrollTop;
105
+ return _regeneratorRuntime.wrap(function _callee3$(_context4) {
106
+ while (1) switch (_context4.prev = _context4.next) {
107
+ case 0:
108
+ this.timeout(0);
109
+ Demo = /*#__PURE__*/function (_BaseAnchorDemo2) {
110
+ _inheritsLoose(Demo, _BaseAnchorDemo2);
111
+ function Demo() {
112
+ return _BaseAnchorDemo2.apply(this, arguments) || this;
113
+ }
114
+ return Demo;
115
+ }(BaseAnchorDemo);
116
+ _mount3 = mount(Demo), instance = _mount3[0], element = _mount3[1];
117
+ _context4.next = 5;
118
+ return wait(300);
119
+ case 5:
120
+ container = document.querySelector('#scroll-container-test');
121
+ targetScrollTop = 300;
122
+ container.scrollTop = targetScrollTop;
123
+ dispatchEvent(container, 'scroll');
124
+ _context4.next = 11;
125
+ return new _Promise(function (resolve) {
126
+ return requestAnimationFrame(resolve);
127
+ });
128
+ case 11:
129
+ _context4.next = 13;
130
+ return wait(100);
131
+ case 13:
132
+ expect(instance.get('value')).to.eql('section2');
133
+ case 14:
134
+ case "end":
135
+ return _context4.stop();
136
+ }
137
+ }, _callee3, this);
138
+ })));
139
+ it('should trigger change event', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
140
+ var Demo, _mount4, instance, element, anchor, secondLink;
141
+ return _regeneratorRuntime.wrap(function _callee4$(_context6) {
142
+ while (1) switch (_context6.prev = _context6.next) {
143
+ case 0:
144
+ this.timeout(0);
145
+ Demo = /*#__PURE__*/function (_BaseAnchorDemo3) {
146
+ _inheritsLoose(Demo, _BaseAnchorDemo3);
147
+ function Demo() {
148
+ var _context5;
149
+ var _this2;
150
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
151
+ args[_key2] = arguments[_key2];
152
+ }
153
+ _this2 = _BaseAnchorDemo3.call.apply(_BaseAnchorDemo3, _concatInstanceProperty(_context5 = [this]).call(_context5, args)) || this;
154
+ _this2.onChange = sinon.spy();
155
+ return _this2;
156
+ }
157
+ var _proto2 = Demo.prototype;
158
+ _proto2.getAnchorProps = function getAnchorProps() {
159
+ return {
160
+ 'ev-change': this.onChange
161
+ };
162
+ };
163
+ return Demo;
164
+ }(BaseAnchorDemo);
165
+ _mount4 = mount(Demo), instance = _mount4[0], element = _mount4[1];
166
+ _context6.next = 5;
167
+ return wait(300);
168
+ case 5:
169
+ anchor = element.querySelector('.k-anchor');
170
+ secondLink = anchor.querySelectorAll('.k-tab')[1];
171
+ secondLink.click();
172
+ _context6.next = 10;
173
+ return wait(300);
174
+ case 10:
175
+ expect(instance.onChange.calledOnce).to.be.true;
176
+ expect(instance.onChange.calledWith('section2')).to.be.true;
177
+ case 12:
178
+ case "end":
179
+ return _context6.stop();
180
+ }
181
+ }, _callee4, this);
182
+ })));
183
+ it('should render nested anchor links correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
184
+ var _mount5, instance, element, anchor, nestedLinks;
185
+ return _regeneratorRuntime.wrap(function _callee5$(_context7) {
186
+ while (1) switch (_context7.prev = _context7.next) {
187
+ case 0:
188
+ _mount5 = mount(NestedDemo), instance = _mount5[0], element = _mount5[1];
189
+ _context7.next = 3;
190
+ return wait(200);
191
+ case 3:
192
+ anchor = element.querySelector('.k-anchor');
193
+ expect(anchor).to.exist;
194
+ nestedLinks = anchor.querySelectorAll('.k-anchor-link-nested');
195
+ expect(nestedLinks.length).to.be.greaterThan(0);
196
+ expect(anchor.outerHTML).to.matchSnapshot();
197
+ case 8:
198
+ case "end":
199
+ return _context7.stop();
200
+ }
201
+ }, _callee5);
202
+ })));
203
+ it('should support disabled anchor link', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
204
+ var Demo, _mount6, instance, element, anchor, disabledLink;
205
+ return _regeneratorRuntime.wrap(function _callee6$(_context8) {
206
+ while (1) switch (_context8.prev = _context8.next) {
207
+ case 0:
208
+ Demo = /*#__PURE__*/function (_BaseAnchorDemo4) {
209
+ _inheritsLoose(Demo, _BaseAnchorDemo4);
210
+ function Demo() {
211
+ return _BaseAnchorDemo4.apply(this, arguments) || this;
212
+ }
213
+ return Demo;
214
+ }(BaseAnchorDemo);
215
+ Demo.template = "\n const {Anchor, AnchorLink} = this;\n <div style=\"display: flex; gap: 20px; align-items: flex-start;\">\n <div id=\"scroll-container-test\" style=\"flex: 1; height: 300px; overflow-y: auto;\">\n <div id=\"section1\" style=\"height: 300px; padding: 20px;\">Section 1</div>\n <div id=\"section2\" style=\"height: 300px; padding: 20px;\">Section 2</div>\n </div>\n <Anchor v-model=\"value\" container=\"#scroll-container-test\">\n <AnchorLink href=\"section1\" title=\"Section 1\" />\n <AnchorLink href=\"section2\" title=\"Section 2\" disabled={true} />\n </Anchor>\n </div>\n ";
216
+ _mount6 = mount(Demo), instance = _mount6[0], element = _mount6[1];
217
+ _context8.next = 5;
218
+ return wait(200);
219
+ case 5:
220
+ anchor = element.querySelector('.k-anchor');
221
+ disabledLink = anchor.querySelectorAll('.k-tab')[1];
222
+ expect(disabledLink.className).to.include('k-disabled');
223
+ expect(anchor.outerHTML).to.matchSnapshot();
224
+ case 9:
225
+ case "end":
226
+ return _context8.stop();
227
+ }
228
+ }, _callee6);
229
+ })));
230
+ });
@@ -0,0 +1,31 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/extends";
2
+ import { createVNode as _$cv, className as _$cn, createUnknownComponentVNode as _$cc } from 'intact-react';
3
+ import { Tabs } from '../tabs';
4
+ import { getRestProps } from '../utils';
5
+ import { makeStyles } from './styles';
6
+ export default function ($props, $blocks, $__proto__) {
7
+ var _classNameObj;
8
+ $blocks || ($blocks = {});
9
+ $props || ($props = {});
10
+ var $this = this;
11
+ var _this$get = this.get(),
12
+ className = _this$get.className,
13
+ children = _this$get.children,
14
+ vertical = _this$get.vertical,
15
+ size = _this$get.size,
16
+ value = _this$get.value;
17
+ var k = this.config.k;
18
+ var classNameObj = (_classNameObj = {}, _classNameObj[k + "-anchor"] = true, _classNameObj[className] = className, _classNameObj[k + "-anchor-vertical"] = vertical, _classNameObj[makeStyles(k, vertical)] = true, _classNameObj);
19
+ return _$cv('div', _extends({
20
+ 'className': _$cn(classNameObj)
21
+ }, getRestProps(this)), _$cc(Tabs, {
22
+ 'vertical': vertical,
23
+ 'size': size,
24
+ 'children': children,
25
+ 'ev-$model:value': function ev$modelValue($v) {
26
+ $this.set('value', $v);
27
+ },
28
+ 'value': $this.get('value')
29
+ }));
30
+ }
31
+ ;
@@ -0,0 +1,16 @@
1
+ import { Component, TypeDefs, VNode } from 'intact-react';
2
+ export interface AnchorLinkProps {
3
+ href?: string;
4
+ title?: string | VNode;
5
+ disabled?: boolean;
6
+ }
7
+ export declare class AnchorLink extends Component<AnchorLinkProps> {
8
+ static template: string | import('intact-react').Template<any>;
9
+ static typeDefs: Required<TypeDefs<AnchorLinkProps>>;
10
+ private anchor;
11
+ private config;
12
+ private level;
13
+ init(): void;
14
+ private onClick;
15
+ getLevel(): number;
16
+ }
@@ -0,0 +1,52 @@
1
+ import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
2
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
3
+ import { __decorate } from "tslib";
4
+ import { Component, inject, provide, VNode } from 'intact-react';
5
+ import template from './link.vdt';
6
+ import { ANCHOR, ANCHOR_LINK_LEVEL } from './constants';
7
+ import { bind } from '../utils';
8
+ import { useConfigContext } from '../config';
9
+ var typeDefs = {
10
+ href: String,
11
+ title: [String, VNode],
12
+ disabled: Boolean
13
+ };
14
+ export var AnchorLink = /*#__PURE__*/function (_Component) {
15
+ _inheritsLoose(AnchorLink, _Component);
16
+ function AnchorLink() {
17
+ var _context;
18
+ var _this;
19
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
20
+ args[_key] = arguments[_key];
21
+ }
22
+ _this = _Component.call.apply(_Component, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
23
+ _this.anchor = inject(ANCHOR);
24
+ _this.config = useConfigContext();
25
+ _this.level = inject(ANCHOR_LINK_LEVEL, 0);
26
+ return _this;
27
+ }
28
+ var _proto = AnchorLink.prototype;
29
+ _proto.init = function init() {
30
+ provide(ANCHOR_LINK_LEVEL, this.level + 1);
31
+ };
32
+ _proto.onClick = function onClick(e) {
33
+ var _this$get = this.get(),
34
+ title = _this$get.title,
35
+ href = _this$get.href,
36
+ disabled = _this$get.disabled;
37
+ if (href) {
38
+ this.anchor.trigger('click', e, {
39
+ title: title,
40
+ href: href,
41
+ disabled: disabled
42
+ });
43
+ }
44
+ };
45
+ _proto.getLevel = function getLevel() {
46
+ return this.level;
47
+ };
48
+ return AnchorLink;
49
+ }(Component);
50
+ AnchorLink.template = template;
51
+ AnchorLink.typeDefs = typeDefs;
52
+ __decorate([bind], AnchorLink.prototype, "onClick", null);
@@ -0,0 +1,49 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/extends";
2
+ import { createUnknownComponentVNode as _$cc, className as _$cn } from 'intact-react';
3
+ import { Tab } from '../tabs';
4
+ import { getRestProps, eachChildren, isComponentVNode } from '../utils';
5
+ import { isNullOrUndefined } from 'intact-shared';
6
+ import { AnchorLink } from './link';
7
+ export default function ($props, $blocks, $__proto__) {
8
+ var _classNameObj;
9
+ $blocks || ($blocks = {});
10
+ $props || ($props = {});
11
+ var $this = this;
12
+ var _this$get = this.get(),
13
+ href = _this$get.href,
14
+ title = _this$get.title,
15
+ children = _this$get.children,
16
+ className = _this$get.className,
17
+ disabled = _this$get.disabled;
18
+ var _this$anchor$get = this.anchor.get(),
19
+ currentValue = _this$anchor$get.value,
20
+ vertical = _this$anchor$get.vertical;
21
+ var k = this.config.k;
22
+ var level = this.level;
23
+ var verticalMode = vertical !== false; // 默认为 true
24
+
25
+ // 检查是否有嵌套的 AnchorLink 仅在 vertical 模式下支持嵌套
26
+ var nestedLinks = [];
27
+ var otherChildren = [];
28
+ if (children) {
29
+ eachChildren(children, function (vNode) {
30
+ if (isComponentVNode(vNode, AnchorLink)) {
31
+ nestedLinks.push(vNode);
32
+ } else {
33
+ otherChildren.push(vNode);
34
+ }
35
+ });
36
+ }
37
+ var hasNestedLinks = nestedLinks.length > 0 && verticalMode;
38
+ // 如果有嵌套的 AnchorLink,显示 title;否则显示 title 或 children
39
+ var displayTitle = title || (hasNestedLinks ? null : otherChildren.length > 0 ? otherChildren : null);
40
+ var classNameObj = (_classNameObj = {}, _classNameObj[k + "-anchor-link"] = true, _classNameObj[k + "-anchor-link-nested"] = hasNestedLinks, _classNameObj[k + "-anchor-link-level-" + level] = level > 0 && verticalMode, _classNameObj[className] = className, _classNameObj);
41
+ return [_$cc(Tab, _extends({}, getRestProps(this), {
42
+ 'className': _$cn(classNameObj),
43
+ 'value': href,
44
+ 'disabled': disabled,
45
+ 'ev-click': this.onClick,
46
+ 'children': displayTitle
47
+ })), hasNestedLinks ? nestedLinks : null];
48
+ }
49
+ ;
@@ -0,0 +1,5 @@
1
+ import '../../styles/global';
2
+ export declare const makeStyles: {
3
+ (k: string, vertical?: boolean | undefined): string;
4
+ clearCache(): {};
5
+ };
@@ -0,0 +1,30 @@
1
+ import _Array$from from "@babel/runtime-corejs3/core-js/array/from";
2
+ import { css } from '@emotion/css';
3
+ import { theme, setDefault } from '../../styles/theme';
4
+ import { deepDefaults } from '../../styles/utils';
5
+ import '../../styles/global';
6
+ import { cache } from '../utils';
7
+ var defaults = {
8
+ get transition() {
9
+ return theme.transition.middle;
10
+ },
11
+ link: {
12
+ padding: 16
13
+ }
14
+ };
15
+ var anchor;
16
+ setDefault(function () {
17
+ anchor = deepDefaults(theme, {
18
+ anchor: defaults
19
+ }).anchor;
20
+ makeStyles == null || makeStyles.clearCache();
21
+ });
22
+ export var makeStyles = cache(function makeStyles(k, vertical) {
23
+ return /*#__PURE__*/css("&.", k, "-anchor-vertical{.", k, "-tabs.", k, "-vertical{border-right:none;border-left:1px solid ", theme.color.border, ";.", k, "-tabs-active-bar{left:0;right:auto;}}}.", k, "-anchor-link{", _Array$from({
24
+ length: 10
25
+ }, function (_, i) {
26
+ var level = i + 1;
27
+ var paddingLeft = anchor.link.padding + anchor.link.padding * level;
28
+ return /*#__PURE__*/css("&.", k, "-anchor-link-level-", level, ".", k, "-tab{padding-left:", paddingLeft, "px;}");
29
+ }), ";&.", k, "-tab{transition:color ", anchor.transition, ";text-align:", vertical ? 'left' : 'center', ";}}");
30
+ });
@@ -0,0 +1,7 @@
1
+ export declare function useScroll(): {
2
+ scrollTo: (target: HTMLElement) => void;
3
+ updateActive: () => void;
4
+ init: () => () => void;
5
+ isScrolling: import("../../hooks/useState").State<boolean>;
6
+ setIsSettingFromScroll: (value: boolean) => void;
7
+ };