@rainbow-oh/yee-c 0.8.5 → 0.8.6
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.
- package/dist/cjs/Alert/alert.js +1 -0
- package/dist/cjs/Anchor/anchor.js +195 -12
- package/dist/cjs/Anchor/interface.d.ts +1 -1
- package/dist/cjs/Input/input.js +3 -0
- package/dist/cjs/Select/option.js +2 -1
- package/dist/cjs/Select/options.js +6 -0
- package/dist/cjs/Selector/selector.js +4 -0
- package/dist/cjs/Spin/style/index.less +11 -6
- package/dist/cjs/Tag/tag.js +23 -8
- package/dist/cjs/Tree/interface.d.ts +2 -1
- package/dist/cjs/Tree/tree-node.js +6 -1
- package/dist/cjs/Tree/tree.js +56 -12
- package/dist/cjs/Trigger/interface.d.ts +2 -1
- package/dist/cjs/style/themes.css +1 -1
- package/dist/cjs/style/variables.css +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Alert/alert.js +1 -0
- package/dist/esm/Anchor/anchor.js +133 -12
- package/dist/esm/Anchor/interface.d.ts +1 -1
- package/dist/esm/Input/input.js +3 -0
- package/dist/esm/Select/option.js +2 -1
- package/dist/esm/Select/options.js +6 -0
- package/dist/esm/Selector/selector.js +4 -0
- package/dist/esm/Spin/style/index.less +11 -6
- package/dist/esm/Tag/tag.js +6 -1
- package/dist/esm/Tree/interface.d.ts +2 -1
- package/dist/esm/Tree/tree-node.js +6 -1
- package/dist/esm/Tree/tree.js +14 -5
- package/dist/esm/Trigger/interface.d.ts +2 -1
- package/dist/esm/style/themes.css +1 -1
- package/dist/esm/style/variables.css +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/umd/yee-c.min.css +1 -1
- package/dist/umd/yee-c.min.js +1 -1
- package/package.json +1 -1
- package/src/Alert/alert.tsx +1 -0
- package/src/Anchor/anchor.tsx +224 -13
- package/src/Anchor/index.en-US.md +1 -1
- package/src/Anchor/index.zh-CN.md +1 -1
- package/src/Anchor/interface.ts +1 -1
- package/src/Input/input.tsx +3 -0
- package/src/Select/option.tsx +2 -1
- package/src/Select/options.tsx +6 -0
- package/src/Selector/selector.tsx +4 -0
- package/src/Spin/style/index.less +11 -6
- package/src/Tag/tag.tsx +14 -1
- package/src/Tree/interface.ts +3 -1
- package/src/Tree/tree-node.tsx +5 -0
- package/src/Tree/tree.tsx +8 -0
- package/src/Trigger/interface.ts +2 -1
- package/src/version.ts +1 -1
package/dist/cjs/Alert/alert.js
CHANGED
|
@@ -151,6 +151,7 @@ var Alert = (baseprops) => {
|
|
|
151
151
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
152
152
|
"div",
|
|
153
153
|
__spreadProps(__spreadValues({}, rest), {
|
|
154
|
+
role: "alert",
|
|
154
155
|
className: (0, import_clsx.default)(
|
|
155
156
|
prefixCls,
|
|
156
157
|
[`${prefixCls}-${mergedState}`],
|
|
@@ -73,6 +73,19 @@ var import_style = require("./style/index.less");
|
|
|
73
73
|
var AnchorContext = (0, import_react.createContext)(
|
|
74
74
|
{}
|
|
75
75
|
);
|
|
76
|
+
var NAVIGATION_LOCK_TIMEOUT = 5e3;
|
|
77
|
+
var NAVIGATION_SETTLE_DELAY = 100;
|
|
78
|
+
var TARGET_POSITION_TOLERANCE = 2;
|
|
79
|
+
var SCROLL_KEYS = /* @__PURE__ */ new Set([
|
|
80
|
+
"ArrowUp",
|
|
81
|
+
"ArrowDown",
|
|
82
|
+
"PageUp",
|
|
83
|
+
"PageDown",
|
|
84
|
+
"Home",
|
|
85
|
+
"End",
|
|
86
|
+
" ",
|
|
87
|
+
"Spacebar"
|
|
88
|
+
]);
|
|
76
89
|
var Anchor = (0, import_react.forwardRef)((baseprops, ref) => {
|
|
77
90
|
const { anchor } = (0, import_react.useContext)(import_Config_Provider.GlobalContext);
|
|
78
91
|
const props = (0, import_mergeContextToProps.default)(baseprops, anchor);
|
|
@@ -117,10 +130,79 @@ var Anchor = (0, import_react.forwardRef)((baseprops, ref) => {
|
|
|
117
130
|
});
|
|
118
131
|
const [anchorList, setAnchorList] = (0, import_react.useState)([]);
|
|
119
132
|
const containerRef = (0, import_react.useRef)(null);
|
|
133
|
+
const anchorRootRef = (0, import_react.useRef)(null);
|
|
120
134
|
const activeKeyRef = (0, import_react.useRef)(mergedActiveKey);
|
|
135
|
+
const handleScrollRef = (0, import_react.useRef)(() => {
|
|
136
|
+
});
|
|
137
|
+
const pendingTargetKeyRef = (0, import_react.useRef)(void 0);
|
|
138
|
+
const navigationTimeoutRef = (0, import_react.useRef)(
|
|
139
|
+
null
|
|
140
|
+
);
|
|
141
|
+
const navigationSettleTimeoutRef = (0, import_react.useRef)(null);
|
|
121
142
|
(0, import_react.useEffect)(() => {
|
|
122
143
|
activeKeyRef.current = mergedActiveKey;
|
|
123
144
|
}, [mergedActiveKey]);
|
|
145
|
+
const setAnchorRootRef = (0, import_react.useCallback)(
|
|
146
|
+
(node) => {
|
|
147
|
+
anchorRootRef.current = node;
|
|
148
|
+
if (typeof ref === "function") {
|
|
149
|
+
ref(node);
|
|
150
|
+
} else if (ref) {
|
|
151
|
+
ref.current = node;
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
[ref]
|
|
155
|
+
);
|
|
156
|
+
const clearNavigationSettleTimer = (0, import_react.useCallback)(() => {
|
|
157
|
+
if (navigationSettleTimeoutRef.current !== null) {
|
|
158
|
+
clearTimeout(navigationSettleTimeoutRef.current);
|
|
159
|
+
navigationSettleTimeoutRef.current = null;
|
|
160
|
+
}
|
|
161
|
+
}, []);
|
|
162
|
+
const clearNavigationLock = (0, import_react.useCallback)(() => {
|
|
163
|
+
pendingTargetKeyRef.current = void 0;
|
|
164
|
+
clearNavigationSettleTimer();
|
|
165
|
+
if (navigationTimeoutRef.current !== null) {
|
|
166
|
+
clearTimeout(navigationTimeoutRef.current);
|
|
167
|
+
navigationTimeoutRef.current = null;
|
|
168
|
+
}
|
|
169
|
+
}, [clearNavigationSettleTimer]);
|
|
170
|
+
const scheduleNavigationUnlock = (0, import_react.useCallback)(
|
|
171
|
+
(key) => {
|
|
172
|
+
clearNavigationSettleTimer();
|
|
173
|
+
navigationSettleTimeoutRef.current = setTimeout(() => {
|
|
174
|
+
if (pendingTargetKeyRef.current === key) {
|
|
175
|
+
clearNavigationLock();
|
|
176
|
+
}
|
|
177
|
+
}, NAVIGATION_SETTLE_DELAY);
|
|
178
|
+
},
|
|
179
|
+
[clearNavigationLock, clearNavigationSettleTimer]
|
|
180
|
+
);
|
|
181
|
+
const startNavigationLock = (0, import_react.useCallback)(
|
|
182
|
+
(key) => {
|
|
183
|
+
clearNavigationLock();
|
|
184
|
+
pendingTargetKeyRef.current = key;
|
|
185
|
+
navigationTimeoutRef.current = setTimeout(() => {
|
|
186
|
+
if (pendingTargetKeyRef.current === key) {
|
|
187
|
+
clearNavigationLock();
|
|
188
|
+
handleScrollRef.current();
|
|
189
|
+
}
|
|
190
|
+
}, NAVIGATION_LOCK_TIMEOUT);
|
|
191
|
+
},
|
|
192
|
+
[clearNavigationLock]
|
|
193
|
+
);
|
|
194
|
+
(0, import_react.useEffect)(() => clearNavigationLock, [clearNavigationLock]);
|
|
195
|
+
const commitActiveKey = (0, import_react.useCallback)(
|
|
196
|
+
(key, forceNotify = false) => {
|
|
197
|
+
const changed = activeKeyRef.current !== key;
|
|
198
|
+
activeKeyRef.current = key;
|
|
199
|
+
setMergedActiveKey(key);
|
|
200
|
+
if (changed || forceNotify) {
|
|
201
|
+
onChange == null ? void 0 : onChange(key);
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
[onChange]
|
|
205
|
+
);
|
|
124
206
|
const generateAnchorList = (0, import_react.useCallback)(() => {
|
|
125
207
|
if (!auto || !name)
|
|
126
208
|
return;
|
|
@@ -149,10 +231,39 @@ var Anchor = (0, import_react.forwardRef)((baseprops, ref) => {
|
|
|
149
231
|
const currentScroll = container === window ? window.scrollY : container.scrollTop;
|
|
150
232
|
return currentScroll + (target.getBoundingClientRect().top - containerTop);
|
|
151
233
|
}, []);
|
|
234
|
+
const hasReachedTarget = (0, import_react.useCallback)(
|
|
235
|
+
(key) => {
|
|
236
|
+
var _a2;
|
|
237
|
+
const container = containerRef.current;
|
|
238
|
+
const target = document.getElementById(key);
|
|
239
|
+
if (!container || !target)
|
|
240
|
+
return false;
|
|
241
|
+
const currentScroll = container === window ? window.pageYOffset || document.documentElement.scrollTop : container.scrollTop;
|
|
242
|
+
const maxScroll = container === window ? Math.max(
|
|
243
|
+
document.documentElement.scrollHeight,
|
|
244
|
+
((_a2 = document.body) == null ? void 0 : _a2.scrollHeight) || 0
|
|
245
|
+
) - window.innerHeight : container.scrollHeight - container.clientHeight;
|
|
246
|
+
const targetScroll = Math.min(
|
|
247
|
+
Math.max(getTargetOffsetTop(target) - offsetTop, 0),
|
|
248
|
+
Math.max(maxScroll, 0)
|
|
249
|
+
);
|
|
250
|
+
return Math.abs(currentScroll - targetScroll) <= TARGET_POSITION_TOLERANCE;
|
|
251
|
+
},
|
|
252
|
+
[getTargetOffsetTop, offsetTop]
|
|
253
|
+
);
|
|
152
254
|
const handleScroll = (0, import_react.useCallback)(() => {
|
|
153
255
|
const container = containerRef.current;
|
|
154
256
|
if (!container)
|
|
155
257
|
return;
|
|
258
|
+
const pendingTargetKey = pendingTargetKeyRef.current;
|
|
259
|
+
if (pendingTargetKey) {
|
|
260
|
+
if (hasReachedTarget(pendingTargetKey)) {
|
|
261
|
+
scheduleNavigationUnlock(pendingTargetKey);
|
|
262
|
+
} else {
|
|
263
|
+
clearNavigationSettleTimer();
|
|
264
|
+
}
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
156
267
|
const scrollTop = container === window ? window.pageYOffset || document.documentElement.scrollTop : container.scrollTop;
|
|
157
268
|
const currentItems2 = auto ? anchorList : items;
|
|
158
269
|
if (!currentItems2 || currentItems2.length === 0)
|
|
@@ -175,11 +286,24 @@ var Anchor = (0, import_react.forwardRef)((baseprops, ref) => {
|
|
|
175
286
|
);
|
|
176
287
|
nextActiveKey = first == null ? void 0 : first.key;
|
|
177
288
|
}
|
|
178
|
-
if (nextActiveKey
|
|
179
|
-
|
|
180
|
-
onChange == null ? void 0 : onChange(nextActiveKey);
|
|
289
|
+
if (nextActiveKey) {
|
|
290
|
+
commitActiveKey(nextActiveKey);
|
|
181
291
|
}
|
|
182
|
-
}, [
|
|
292
|
+
}, [
|
|
293
|
+
auto,
|
|
294
|
+
anchorList,
|
|
295
|
+
items,
|
|
296
|
+
offsetTop,
|
|
297
|
+
getTargetOffsetTop,
|
|
298
|
+
hasReachedTarget,
|
|
299
|
+
scheduleNavigationUnlock,
|
|
300
|
+
clearNavigationSettleTimer,
|
|
301
|
+
clearNavigationLock,
|
|
302
|
+
commitActiveKey
|
|
303
|
+
]);
|
|
304
|
+
(0, import_react.useEffect)(() => {
|
|
305
|
+
handleScrollRef.current = handleScroll;
|
|
306
|
+
}, [handleScroll]);
|
|
183
307
|
(0, import_react.useEffect)(() => {
|
|
184
308
|
const container = getContainer ? getContainer() : window;
|
|
185
309
|
containerRef.current = container;
|
|
@@ -187,6 +311,9 @@ var Anchor = (0, import_react.forwardRef)((baseprops, ref) => {
|
|
|
187
311
|
return;
|
|
188
312
|
let rafId = null;
|
|
189
313
|
const onScroll = () => {
|
|
314
|
+
if (pendingTargetKeyRef.current) {
|
|
315
|
+
clearNavigationSettleTimer();
|
|
316
|
+
}
|
|
190
317
|
if (rafId !== null)
|
|
191
318
|
return;
|
|
192
319
|
rafId = requestAnimationFrame(() => {
|
|
@@ -194,23 +321,68 @@ var Anchor = (0, import_react.forwardRef)((baseprops, ref) => {
|
|
|
194
321
|
handleScroll();
|
|
195
322
|
});
|
|
196
323
|
};
|
|
324
|
+
const onScrollEnd = () => {
|
|
325
|
+
const pendingTargetKey = pendingTargetKeyRef.current;
|
|
326
|
+
if (pendingTargetKey && hasReachedTarget(pendingTargetKey)) {
|
|
327
|
+
scheduleNavigationUnlock(pendingTargetKey);
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
const onUserInterrupt = (event) => {
|
|
331
|
+
if (event.type === "pointerdown" && event.target instanceof Element) {
|
|
332
|
+
const item = event.target.closest(
|
|
333
|
+
`.${CSS.escape(`${prefixCls}-item`)}`
|
|
334
|
+
);
|
|
335
|
+
const owner = item == null ? void 0 : item.closest(`.${CSS.escape(prefixCls)}`);
|
|
336
|
+
if (owner === anchorRootRef.current) {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
if (event.type === "keydown" && !SCROLL_KEYS.has(event.key)) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
clearNavigationLock();
|
|
344
|
+
};
|
|
197
345
|
container.addEventListener("scroll", onScroll);
|
|
346
|
+
container.addEventListener("scrollend", onScrollEnd);
|
|
347
|
+
container.addEventListener("wheel", onUserInterrupt);
|
|
348
|
+
container.addEventListener("touchstart", onUserInterrupt);
|
|
349
|
+
document.addEventListener("pointerdown", onUserInterrupt);
|
|
350
|
+
container.addEventListener("keydown", onUserInterrupt);
|
|
198
351
|
handleScroll();
|
|
199
352
|
return () => {
|
|
200
353
|
container.removeEventListener("scroll", onScroll);
|
|
354
|
+
container.removeEventListener("scrollend", onScrollEnd);
|
|
355
|
+
container.removeEventListener("wheel", onUserInterrupt);
|
|
356
|
+
container.removeEventListener(
|
|
357
|
+
"touchstart",
|
|
358
|
+
onUserInterrupt
|
|
359
|
+
);
|
|
360
|
+
document.removeEventListener(
|
|
361
|
+
"pointerdown",
|
|
362
|
+
onUserInterrupt
|
|
363
|
+
);
|
|
364
|
+
container.removeEventListener("keydown", onUserInterrupt);
|
|
201
365
|
if (rafId !== null) {
|
|
202
366
|
cancelAnimationFrame(rafId);
|
|
203
367
|
}
|
|
204
368
|
};
|
|
205
|
-
}, [
|
|
369
|
+
}, [
|
|
370
|
+
getContainer,
|
|
371
|
+
handleScroll,
|
|
372
|
+
hasReachedTarget,
|
|
373
|
+
scheduleNavigationUnlock,
|
|
374
|
+
clearNavigationSettleTimer,
|
|
375
|
+
clearNavigationLock,
|
|
376
|
+
prefixCls
|
|
377
|
+
]);
|
|
206
378
|
const scrollToAnchor = (0, import_react.useCallback)(
|
|
207
379
|
(key) => {
|
|
208
380
|
const target = document.getElementById(key);
|
|
209
381
|
if (!target)
|
|
210
|
-
return;
|
|
382
|
+
return false;
|
|
211
383
|
const container = containerRef.current;
|
|
212
384
|
if (!container)
|
|
213
|
-
return;
|
|
385
|
+
return false;
|
|
214
386
|
const targetTop = getTargetOffsetTop(target) - offsetTop;
|
|
215
387
|
if (container === window) {
|
|
216
388
|
window.scrollTo({ top: targetTop, behavior: "smooth" });
|
|
@@ -220,6 +392,7 @@ var Anchor = (0, import_react.forwardRef)((baseprops, ref) => {
|
|
|
220
392
|
behavior: "smooth"
|
|
221
393
|
});
|
|
222
394
|
}
|
|
395
|
+
return true;
|
|
223
396
|
},
|
|
224
397
|
[offsetTop, getTargetOffsetTop]
|
|
225
398
|
);
|
|
@@ -230,11 +403,21 @@ var Anchor = (0, import_react.forwardRef)((baseprops, ref) => {
|
|
|
230
403
|
}, [defaultActiveKey]);
|
|
231
404
|
const handleItemClick = (0, import_react.useCallback)(
|
|
232
405
|
(key) => {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
406
|
+
startNavigationLock(key);
|
|
407
|
+
commitActiveKey(key, true);
|
|
408
|
+
if (!scrollToAnchor(key)) {
|
|
409
|
+
clearNavigationLock();
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
handleScroll();
|
|
236
413
|
},
|
|
237
|
-
[
|
|
414
|
+
[
|
|
415
|
+
startNavigationLock,
|
|
416
|
+
commitActiveKey,
|
|
417
|
+
scrollToAnchor,
|
|
418
|
+
clearNavigationLock,
|
|
419
|
+
handleScroll
|
|
420
|
+
]
|
|
238
421
|
);
|
|
239
422
|
const cls = (0, import_clsx.default)(
|
|
240
423
|
prefixCls,
|
|
@@ -258,7 +441,7 @@ var Anchor = (0, import_react.forwardRef)((baseprops, ref) => {
|
|
|
258
441
|
return null;
|
|
259
442
|
return /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefixCls}-nav-arrow` }, /* @__PURE__ */ import_react.default.createElement("span", { className: `${prefixCls}-arrow-icon` }, /* @__PURE__ */ import_react.default.createElement(import_lucide_react.ChevronLeft, { size: 18 })));
|
|
260
443
|
};
|
|
261
|
-
return /* @__PURE__ */ import_react.default.createElement("div", __spreadProps(__spreadValues({}, rest), { className: cls, style, ref }), renderNavArrow(), /* @__PURE__ */ import_react.default.createElement(AnchorContext.Provider, { value: contextValue }, /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefixCls}-content-wrapper` }, /* @__PURE__ */ import_react.default.createElement(
|
|
444
|
+
return /* @__PURE__ */ import_react.default.createElement("div", __spreadProps(__spreadValues({}, rest), { className: cls, style, ref: setAnchorRootRef }), renderNavArrow(), /* @__PURE__ */ import_react.default.createElement(AnchorContext.Provider, { value: contextValue }, /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefixCls}-content-wrapper` }, /* @__PURE__ */ import_react.default.createElement(
|
|
262
445
|
"ul",
|
|
263
446
|
{
|
|
264
447
|
className: (0, import_clsx.default)(`${prefixCls}-content`, classNames == null ? void 0 : classNames.content),
|
package/dist/cjs/Input/input.js
CHANGED
|
@@ -159,6 +159,9 @@ var Input = (0, import_react.forwardRef)((baseprops, ref) => {
|
|
|
159
159
|
{
|
|
160
160
|
className: (0, import_clsx.default)(`${prefixCls}-clear`, classNames == null ? void 0 : classNames.clear),
|
|
161
161
|
style: styles == null ? void 0 : styles.clear,
|
|
162
|
+
role: "button",
|
|
163
|
+
"aria-label": "clear",
|
|
164
|
+
tabIndex: 0,
|
|
162
165
|
onClick: onClear,
|
|
163
166
|
onKeyDown: (event) => {
|
|
164
167
|
if (event.key === "Enter") {
|
|
@@ -62,7 +62,8 @@ var Option = (props) => {
|
|
|
62
62
|
[`${prefixCls}-option-focused`]: focused,
|
|
63
63
|
[`${prefixCls}-option-disabled`]: disabled
|
|
64
64
|
}),
|
|
65
|
-
"aria-
|
|
65
|
+
"aria-selected": selected,
|
|
66
|
+
"aria-disabled": disabled || void 0,
|
|
66
67
|
onClick: handleClick,
|
|
67
68
|
onKeyDown: (e) => {
|
|
68
69
|
if (e.key === "Enter") {
|
|
@@ -210,6 +210,8 @@ var Options = (0, import_react.forwardRef)(
|
|
|
210
210
|
),
|
|
211
211
|
style: popupStyle,
|
|
212
212
|
ref: rootRef,
|
|
213
|
+
role: "listbox",
|
|
214
|
+
"aria-multiselectable": multiple || void 0,
|
|
213
215
|
tabIndex: -1
|
|
214
216
|
}),
|
|
215
217
|
/* @__PURE__ */ import_react.default.createElement(OptionsCtx.Provider, { value: ctxValue }, /* @__PURE__ */ import_react.default.createElement(
|
|
@@ -259,6 +261,8 @@ var Options = (0, import_react.forwardRef)(
|
|
|
259
261
|
),
|
|
260
262
|
style: popupStyle,
|
|
261
263
|
ref: rootRef,
|
|
264
|
+
role: "listbox",
|
|
265
|
+
"aria-multiselectable": multiple || void 0,
|
|
262
266
|
tabIndex: -1
|
|
263
267
|
}),
|
|
264
268
|
/* @__PURE__ */ import_react.default.createElement(OptionsCtx.Provider, { value: ctxValue }, /* @__PURE__ */ import_react.default.createElement(
|
|
@@ -297,6 +301,8 @@ var Options = (0, import_react.forwardRef)(
|
|
|
297
301
|
),
|
|
298
302
|
style: __spreadValues(__spreadValues({}, popupStyle), multiColumn ? { "--yee-select-columns": columns } : void 0),
|
|
299
303
|
ref: rootRef,
|
|
304
|
+
role: "listbox",
|
|
305
|
+
"aria-multiselectable": multiple || void 0,
|
|
300
306
|
tabIndex: -1
|
|
301
307
|
}),
|
|
302
308
|
isEmpty ? /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefixCls}-empty` }, select.noData) : /* @__PURE__ */ import_react.default.createElement(OptionsCtx.Provider, { value: ctxValue }, options.map((option, index) => /* @__PURE__ */ import_react.default.createElement(
|
|
@@ -282,6 +282,10 @@ var Selector = import_react.default.forwardRef(
|
|
|
282
282
|
tabIndex: disabled || searchable ? -1 : 0,
|
|
283
283
|
className: cls,
|
|
284
284
|
style,
|
|
285
|
+
role: "combobox",
|
|
286
|
+
"aria-expanded": open || false,
|
|
287
|
+
"aria-haspopup": "listbox",
|
|
288
|
+
"aria-disabled": disabled || void 0,
|
|
285
289
|
onKeyDown: (event) => {
|
|
286
290
|
if (disabled)
|
|
287
291
|
return;
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
&-ring {
|
|
41
|
-
|
|
41
|
+
@{pls}-ring {
|
|
42
42
|
box-sizing: border-box;
|
|
43
43
|
display: block;
|
|
44
44
|
border-style: solid;
|
|
@@ -53,13 +53,13 @@
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
&-spokes {
|
|
56
|
-
|
|
56
|
+
@{pls}-spokes {
|
|
57
57
|
position: relative;
|
|
58
58
|
width: 100%;
|
|
59
59
|
height: 100%;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
@{pls}-spokes-line {
|
|
63
63
|
position: absolute;
|
|
64
64
|
top: 0;
|
|
65
65
|
left: 50%;
|
|
@@ -101,9 +101,14 @@
|
|
|
101
101
|
|
|
102
102
|
&-blur {
|
|
103
103
|
position: absolute;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
display: flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
justify-content: center;
|
|
107
|
+
width: 100%;
|
|
108
|
+
height: 100%;
|
|
109
|
+
// top: 50%;
|
|
110
|
+
// left: 50%;
|
|
111
|
+
// transform: translate(-50%, -50%);
|
|
107
112
|
background-color: var(--yee-color-bg-mask-light, rgba(255, 255, 255, 40%));
|
|
108
113
|
}
|
|
109
114
|
|
package/dist/cjs/Tag/tag.js
CHANGED
|
@@ -129,19 +129,34 @@ var Tag = (0, import_react.forwardRef)(
|
|
|
129
129
|
style: styles == null ? void 0 : styles.close,
|
|
130
130
|
type: "text",
|
|
131
131
|
size: "small",
|
|
132
|
+
"aria-label": "close",
|
|
132
133
|
onClick: onClose
|
|
133
134
|
},
|
|
134
135
|
typeof closable === "boolean" ? /* @__PURE__ */ import_react.default.createElement(import_lucide_react.X, { size: 14, strokeWidth: 1 }) : closable
|
|
135
136
|
) : null;
|
|
136
137
|
const closeNode = renderClose();
|
|
137
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
138
|
-
"
|
|
139
|
-
{
|
|
140
|
-
className:
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
138
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
139
|
+
"div",
|
|
140
|
+
__spreadValues(__spreadProps(__spreadValues({}, rest), {
|
|
141
|
+
className: cls,
|
|
142
|
+
onClick: handleClick,
|
|
143
|
+
ref
|
|
144
|
+
}), checkable ? {
|
|
145
|
+
role: "checkbox",
|
|
146
|
+
"aria-checked": checked || false,
|
|
147
|
+
tabIndex: 0
|
|
148
|
+
} : void 0),
|
|
149
|
+
icon && /* @__PURE__ */ import_react.default.createElement(
|
|
150
|
+
"span",
|
|
151
|
+
{
|
|
152
|
+
className: (0, import_clsx.default)(`${prefixCls}-icon`, classNames == null ? void 0 : classNames.icon),
|
|
153
|
+
style: styles == null ? void 0 : styles.icon
|
|
154
|
+
},
|
|
155
|
+
icon
|
|
156
|
+
),
|
|
157
|
+
icon || closeNode ? /* @__PURE__ */ import_react.default.createElement("span", { className: (0, import_clsx.default)(classNames == null ? void 0 : classNames.content), style: styles == null ? void 0 : styles.content }, children) : children,
|
|
158
|
+
closeNode
|
|
159
|
+
);
|
|
145
160
|
}
|
|
146
161
|
);
|
|
147
162
|
Tag.displayName = "Tag";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import type { DataAttributeProps } from '../utils/types';
|
|
2
3
|
export type SemanticType = '';
|
|
3
4
|
export type DragPosition = 'before' | 'after' | 'inside';
|
|
4
5
|
export type { MoveInfo } from './utils/tree-tools';
|
|
@@ -69,7 +70,7 @@ export interface TreeNodeProps<T> {
|
|
|
69
70
|
node: TreeNode<T>;
|
|
70
71
|
style?: React.CSSProperties;
|
|
71
72
|
}
|
|
72
|
-
export interface TreeProps<T> {
|
|
73
|
+
export interface TreeProps<T> extends DataAttributeProps {
|
|
73
74
|
/**
|
|
74
75
|
* Custom class name prefix
|
|
75
76
|
*/
|
|
@@ -191,7 +191,12 @@ var Node = (props) => {
|
|
|
191
191
|
[`${prefixCls}-node-drag-over-after`]: dropPosition === "after",
|
|
192
192
|
[`${prefixCls}-node-drag-over-inside`]: dropPosition === "inside"
|
|
193
193
|
}),
|
|
194
|
-
style: nodeStyle
|
|
194
|
+
style: nodeStyle,
|
|
195
|
+
role: "treeitem",
|
|
196
|
+
"aria-expanded": isLeaf ? void 0 : expanded,
|
|
197
|
+
"aria-selected": selected,
|
|
198
|
+
"aria-level": depth + 1,
|
|
199
|
+
"aria-disabled": disabled || void 0
|
|
195
200
|
}, dragProps),
|
|
196
201
|
renderEmptyNodes(depth),
|
|
197
202
|
renderExpandedIcon(),
|
package/dist/cjs/Tree/tree.js
CHANGED
|
@@ -18,6 +18,18 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
}
|
|
19
19
|
return a;
|
|
20
20
|
};
|
|
21
|
+
var __objRest = (source, exclude) => {
|
|
22
|
+
var target = {};
|
|
23
|
+
for (var prop in source)
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
if (source != null && __getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
21
33
|
var __export = (target, all) => {
|
|
22
34
|
for (var name in all)
|
|
23
35
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -55,6 +67,7 @@ var import_useEvent = __toESM(require("../hooks/useEvent"));
|
|
|
55
67
|
var import_useMergedState = __toESM(require("../hooks/useMergedState"));
|
|
56
68
|
var import_useVirtualList = __toESM(require("../hooks/useVirtualList"));
|
|
57
69
|
var import_mergeContextToProps = __toESM(require("../utils/mergeContextToProps"));
|
|
70
|
+
var import_types = require("../utils/types");
|
|
58
71
|
var import_tree_node = __toESM(require("./tree-node"));
|
|
59
72
|
var import_tree_tools = require("./utils/tree-tools");
|
|
60
73
|
var import_style = require("./style/index.less");
|
|
@@ -146,7 +159,7 @@ function setToArray(s) {
|
|
|
146
159
|
var Tree = (baseprops) => {
|
|
147
160
|
const { tree } = (0, import_react2.useContext)(import_Config_Provider.GlobalContext);
|
|
148
161
|
const props = (0, import_mergeContextToProps.default)(baseprops, tree);
|
|
149
|
-
const {
|
|
162
|
+
const _a = props, {
|
|
150
163
|
prefixCls = "yee-tree",
|
|
151
164
|
className,
|
|
152
165
|
style,
|
|
@@ -174,7 +187,36 @@ var Tree = (baseprops) => {
|
|
|
174
187
|
virtual = false,
|
|
175
188
|
height,
|
|
176
189
|
itemHeight = 28
|
|
177
|
-
} =
|
|
190
|
+
} = _a, rest = __objRest(_a, [
|
|
191
|
+
"prefixCls",
|
|
192
|
+
"className",
|
|
193
|
+
"style",
|
|
194
|
+
"dataSource",
|
|
195
|
+
"fieldNames",
|
|
196
|
+
"defaultExpandAll",
|
|
197
|
+
"expandedKeys",
|
|
198
|
+
"defaultExpandedKeys",
|
|
199
|
+
"selectedKeys",
|
|
200
|
+
"defaultSelectedKeys",
|
|
201
|
+
"checkedKeys",
|
|
202
|
+
"defaultCheckedKeys",
|
|
203
|
+
"checkable",
|
|
204
|
+
"multiple",
|
|
205
|
+
"showIcon",
|
|
206
|
+
"icon",
|
|
207
|
+
"showLine",
|
|
208
|
+
"switcherIcon",
|
|
209
|
+
"draggable",
|
|
210
|
+
"allowDrop",
|
|
211
|
+
"onDrop",
|
|
212
|
+
"onSelect",
|
|
213
|
+
"onCheck",
|
|
214
|
+
"onExpand",
|
|
215
|
+
"virtual",
|
|
216
|
+
"height",
|
|
217
|
+
"itemHeight"
|
|
218
|
+
]);
|
|
219
|
+
const dataAttrs = (0, import_types.pickDataAttrs)(rest);
|
|
178
220
|
const [flatItems, itemMap] = (0, import_react2.useMemo)(
|
|
179
221
|
() => (0, import_tree_tools.tree2array)(dataSource != null ? dataSource : [], fieldNames),
|
|
180
222
|
[dataSource, fieldNames]
|
|
@@ -265,8 +307,8 @@ var Tree = (baseprops) => {
|
|
|
265
307
|
const externalKeys = uidsToKeys(newUidArr, itemMap);
|
|
266
308
|
const nodes = [];
|
|
267
309
|
newUidSet.forEach((u) => {
|
|
268
|
-
var
|
|
269
|
-
const n = (
|
|
310
|
+
var _a2;
|
|
311
|
+
const n = (_a2 = itemMap.get(u)) == null ? void 0 : _a2.original;
|
|
270
312
|
if (n)
|
|
271
313
|
nodes.push(n);
|
|
272
314
|
});
|
|
@@ -279,7 +321,7 @@ var Tree = (baseprops) => {
|
|
|
279
321
|
}
|
|
280
322
|
);
|
|
281
323
|
const handleSelect = (0, import_useEvent.default)((uid) => {
|
|
282
|
-
var
|
|
324
|
+
var _a2;
|
|
283
325
|
const selected = selectedUidSet.has(uid);
|
|
284
326
|
let newUidArr;
|
|
285
327
|
if (multiple) {
|
|
@@ -297,7 +339,7 @@ var Tree = (baseprops) => {
|
|
|
297
339
|
const externalKeys = uidsToKeys(newUidArr, itemMap);
|
|
298
340
|
const nodes = [];
|
|
299
341
|
for (const u of newUidArr) {
|
|
300
|
-
const n = (
|
|
342
|
+
const n = (_a2 = itemMap.get(u)) == null ? void 0 : _a2.original;
|
|
301
343
|
if (n)
|
|
302
344
|
nodes.push(n);
|
|
303
345
|
}
|
|
@@ -309,7 +351,7 @@ var Tree = (baseprops) => {
|
|
|
309
351
|
}
|
|
310
352
|
});
|
|
311
353
|
const handleExpand = (0, import_useEvent.default)((uid) => {
|
|
312
|
-
var
|
|
354
|
+
var _a2;
|
|
313
355
|
const expanded = expandedUidSet.has(uid);
|
|
314
356
|
const newUidArr = expanded ? expandedUidArray.filter((u) => u !== uid) : [...expandedUidArray, uid];
|
|
315
357
|
setExpandedUidArray(newUidArr);
|
|
@@ -318,7 +360,7 @@ var Tree = (baseprops) => {
|
|
|
318
360
|
const treeNode = itemMap.get(uid);
|
|
319
361
|
const nodes = [];
|
|
320
362
|
for (const u of newUidArr) {
|
|
321
|
-
const n = (
|
|
363
|
+
const n = (_a2 = itemMap.get(u)) == null ? void 0 : _a2.original;
|
|
322
364
|
if (n)
|
|
323
365
|
nodes.push(n);
|
|
324
366
|
}
|
|
@@ -505,11 +547,12 @@ var Tree = (baseprops) => {
|
|
|
505
547
|
const slicedItems = visibleItems.slice(start, end);
|
|
506
548
|
return /* @__PURE__ */ import_react2.default.createElement(
|
|
507
549
|
"div",
|
|
508
|
-
{
|
|
550
|
+
__spreadValues({
|
|
509
551
|
className: (0, import_clsx.default)(prefixCls, className),
|
|
510
552
|
style,
|
|
553
|
+
role: "tree",
|
|
511
554
|
onDragEnd: handleDragEnd
|
|
512
|
-
},
|
|
555
|
+
}, dataAttrs),
|
|
513
556
|
/* @__PURE__ */ import_react2.default.createElement(TreeContext.Provider, { value: contextValue }, /* @__PURE__ */ import_react2.default.createElement(
|
|
514
557
|
"div",
|
|
515
558
|
{
|
|
@@ -560,11 +603,12 @@ var Tree = (baseprops) => {
|
|
|
560
603
|
}
|
|
561
604
|
return /* @__PURE__ */ import_react2.default.createElement(
|
|
562
605
|
"div",
|
|
563
|
-
{
|
|
606
|
+
__spreadValues({
|
|
564
607
|
className: (0, import_clsx.default)(prefixCls, className),
|
|
565
608
|
style,
|
|
609
|
+
role: "tree",
|
|
566
610
|
onDragEnd: handleDragEnd
|
|
567
|
-
},
|
|
611
|
+
}, dataAttrs),
|
|
568
612
|
/* @__PURE__ */ import_react2.default.createElement(TreeContext.Provider, { value: contextValue }, /* @__PURE__ */ import_react2.default.createElement(import_react.AnimatePresence, { initial: false }, segments.map((segment) => {
|
|
569
613
|
if (segment.type === "node") {
|
|
570
614
|
return /* @__PURE__ */ import_react2.default.createElement(import_tree_node.default, { node: segment.node, key: segment.node.uid });
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TriggerProps as RcTriggerProps } from '@rc-component/trigger';
|
|
3
|
+
import type { DataAttributeProps } from '../utils/types';
|
|
3
4
|
export type Placement = 'top' | 'bottom' | 'left' | 'right' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
|
|
4
5
|
export type Point = 'tl' | 'tc' | 'tr' | 'bl' | 'bc' | 'br' | 'lt' | 'lc' | 'lb' | 'rt' | 'rc' | 'rb' | 'cc' | 'cl' | 'cr';
|
|
5
|
-
export interface TriggerProps extends Omit<RcTriggerProps, 'children'
|
|
6
|
+
export interface TriggerProps extends Omit<RcTriggerProps, 'children'>, DataAttributeProps {
|
|
6
7
|
/**
|
|
7
8
|
* Custom class name prefix
|
|
8
9
|
*/
|
package/dist/cjs/version.d.ts
CHANGED