@rainbow-oh/yee-c 0.8.4 → 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/Select/select.js +1 -1
- 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/Select/select.js +1 -1
- 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/Select/select.tsx +1 -1
- 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/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED
package/dist/esm/Alert/alert.js
CHANGED
|
@@ -94,6 +94,7 @@ var Alert = function Alert(baseprops) {
|
|
|
94
94
|
}, description) : null;
|
|
95
95
|
};
|
|
96
96
|
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
97
|
+
role: "alert",
|
|
97
98
|
className: clsx(prefixCls, ["".concat(prefixCls, "-").concat(mergedState)], ["".concat(prefixCls, "-").concat(sizeType)], _defineProperty({}, "".concat(prefixCls, "-banner"), banner), className),
|
|
98
99
|
style: style
|
|
99
100
|
}), closable && /*#__PURE__*/React.createElement(Button, {
|
|
@@ -21,6 +21,10 @@ import mergeContextToProps from "../utils/mergeContextToProps";
|
|
|
21
21
|
import AnchorItem from "./anchor-item";
|
|
22
22
|
import "./style/index.less";
|
|
23
23
|
export var AnchorContext = /*#__PURE__*/createContext({});
|
|
24
|
+
var NAVIGATION_LOCK_TIMEOUT = 5000;
|
|
25
|
+
var NAVIGATION_SETTLE_DELAY = 100;
|
|
26
|
+
var TARGET_POSITION_TOLERANCE = 2;
|
|
27
|
+
var SCROLL_KEYS = new Set(['ArrowUp', 'ArrowDown', 'PageUp', 'PageDown', 'Home', 'End', ' ', 'Spacebar']);
|
|
24
28
|
var Anchor = /*#__PURE__*/forwardRef(function (baseprops, ref) {
|
|
25
29
|
var _useContext = useContext(GlobalContext),
|
|
26
30
|
anchor = _useContext.anchor;
|
|
@@ -60,10 +64,67 @@ var Anchor = /*#__PURE__*/forwardRef(function (baseprops, ref) {
|
|
|
60
64
|
anchorList = _useState2[0],
|
|
61
65
|
setAnchorList = _useState2[1];
|
|
62
66
|
var containerRef = useRef(null);
|
|
67
|
+
var anchorRootRef = useRef(null);
|
|
63
68
|
var activeKeyRef = useRef(mergedActiveKey);
|
|
69
|
+
var handleScrollRef = useRef(function () {});
|
|
70
|
+
var pendingTargetKeyRef = useRef(undefined);
|
|
71
|
+
var navigationTimeoutRef = useRef(null);
|
|
72
|
+
var navigationSettleTimeoutRef = useRef(null);
|
|
64
73
|
useEffect(function () {
|
|
65
74
|
activeKeyRef.current = mergedActiveKey;
|
|
66
75
|
}, [mergedActiveKey]);
|
|
76
|
+
var setAnchorRootRef = useCallback(function (node) {
|
|
77
|
+
anchorRootRef.current = node;
|
|
78
|
+
if (typeof ref === 'function') {
|
|
79
|
+
ref(node);
|
|
80
|
+
} else if (ref) {
|
|
81
|
+
ref.current = node;
|
|
82
|
+
}
|
|
83
|
+
}, [ref]);
|
|
84
|
+
var clearNavigationSettleTimer = useCallback(function () {
|
|
85
|
+
if (navigationSettleTimeoutRef.current !== null) {
|
|
86
|
+
clearTimeout(navigationSettleTimeoutRef.current);
|
|
87
|
+
navigationSettleTimeoutRef.current = null;
|
|
88
|
+
}
|
|
89
|
+
}, []);
|
|
90
|
+
var clearNavigationLock = useCallback(function () {
|
|
91
|
+
pendingTargetKeyRef.current = undefined;
|
|
92
|
+
clearNavigationSettleTimer();
|
|
93
|
+
if (navigationTimeoutRef.current !== null) {
|
|
94
|
+
clearTimeout(navigationTimeoutRef.current);
|
|
95
|
+
navigationTimeoutRef.current = null;
|
|
96
|
+
}
|
|
97
|
+
}, [clearNavigationSettleTimer]);
|
|
98
|
+
var scheduleNavigationUnlock = useCallback(function (key) {
|
|
99
|
+
clearNavigationSettleTimer();
|
|
100
|
+
navigationSettleTimeoutRef.current = setTimeout(function () {
|
|
101
|
+
if (pendingTargetKeyRef.current === key) {
|
|
102
|
+
clearNavigationLock();
|
|
103
|
+
}
|
|
104
|
+
}, NAVIGATION_SETTLE_DELAY);
|
|
105
|
+
}, [clearNavigationLock, clearNavigationSettleTimer]);
|
|
106
|
+
var startNavigationLock = useCallback(function (key) {
|
|
107
|
+
clearNavigationLock();
|
|
108
|
+
pendingTargetKeyRef.current = key;
|
|
109
|
+
navigationTimeoutRef.current = setTimeout(function () {
|
|
110
|
+
if (pendingTargetKeyRef.current === key) {
|
|
111
|
+
clearNavigationLock();
|
|
112
|
+
handleScrollRef.current();
|
|
113
|
+
}
|
|
114
|
+
}, NAVIGATION_LOCK_TIMEOUT);
|
|
115
|
+
}, [clearNavigationLock]);
|
|
116
|
+
useEffect(function () {
|
|
117
|
+
return clearNavigationLock;
|
|
118
|
+
}, [clearNavigationLock]);
|
|
119
|
+
var commitActiveKey = useCallback(function (key) {
|
|
120
|
+
var forceNotify = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
121
|
+
var changed = activeKeyRef.current !== key;
|
|
122
|
+
activeKeyRef.current = key;
|
|
123
|
+
setMergedActiveKey(key);
|
|
124
|
+
if (changed || forceNotify) {
|
|
125
|
+
onChange === null || onChange === void 0 || onChange(key);
|
|
126
|
+
}
|
|
127
|
+
}, [onChange]);
|
|
67
128
|
|
|
68
129
|
// Auto-generate anchor list from DOM
|
|
69
130
|
var generateAnchorList = useCallback(function () {
|
|
@@ -98,11 +159,30 @@ var Anchor = /*#__PURE__*/forwardRef(function (baseprops, ref) {
|
|
|
98
159
|
var currentScroll = container === window ? window.scrollY : container.scrollTop;
|
|
99
160
|
return currentScroll + (target.getBoundingClientRect().top - containerTop);
|
|
100
161
|
}, []);
|
|
162
|
+
var hasReachedTarget = useCallback(function (key) {
|
|
163
|
+
var _document$body;
|
|
164
|
+
var container = containerRef.current;
|
|
165
|
+
var target = document.getElementById(key);
|
|
166
|
+
if (!container || !target) return false;
|
|
167
|
+
var currentScroll = container === window ? window.pageYOffset || document.documentElement.scrollTop : container.scrollTop;
|
|
168
|
+
var maxScroll = container === window ? Math.max(document.documentElement.scrollHeight, ((_document$body = document.body) === null || _document$body === void 0 ? void 0 : _document$body.scrollHeight) || 0) - window.innerHeight : container.scrollHeight - container.clientHeight;
|
|
169
|
+
var targetScroll = Math.min(Math.max(getTargetOffsetTop(target) - offsetTop, 0), Math.max(maxScroll, 0));
|
|
170
|
+
return Math.abs(currentScroll - targetScroll) <= TARGET_POSITION_TOLERANCE;
|
|
171
|
+
}, [getTargetOffsetTop, offsetTop]);
|
|
101
172
|
|
|
102
173
|
// Handle scroll to update active key
|
|
103
174
|
var handleScroll = useCallback(function () {
|
|
104
175
|
var container = containerRef.current;
|
|
105
176
|
if (!container) return;
|
|
177
|
+
var pendingTargetKey = pendingTargetKeyRef.current;
|
|
178
|
+
if (pendingTargetKey) {
|
|
179
|
+
if (hasReachedTarget(pendingTargetKey)) {
|
|
180
|
+
scheduleNavigationUnlock(pendingTargetKey);
|
|
181
|
+
} else {
|
|
182
|
+
clearNavigationSettleTimer();
|
|
183
|
+
}
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
106
186
|
var scrollTop = container === window ? window.pageYOffset || document.documentElement.scrollTop : container.scrollTop;
|
|
107
187
|
var currentItems = auto ? anchorList : items;
|
|
108
188
|
|
|
@@ -130,11 +210,13 @@ var Anchor = /*#__PURE__*/forwardRef(function (baseprops, ref) {
|
|
|
130
210
|
});
|
|
131
211
|
nextActiveKey = first === null || first === void 0 ? void 0 : first.key;
|
|
132
212
|
}
|
|
133
|
-
if (nextActiveKey
|
|
134
|
-
|
|
135
|
-
onChange === null || onChange === void 0 || onChange(nextActiveKey);
|
|
213
|
+
if (nextActiveKey) {
|
|
214
|
+
commitActiveKey(nextActiveKey);
|
|
136
215
|
}
|
|
137
|
-
}, [auto, anchorList, items, offsetTop,
|
|
216
|
+
}, [auto, anchorList, items, offsetTop, getTargetOffsetTop, hasReachedTarget, scheduleNavigationUnlock, clearNavigationSettleTimer, clearNavigationLock, commitActiveKey]);
|
|
217
|
+
useEffect(function () {
|
|
218
|
+
handleScrollRef.current = handleScroll;
|
|
219
|
+
}, [handleScroll]);
|
|
138
220
|
useEffect(function () {
|
|
139
221
|
// Resolve in a passive effect: parent-owned refs passed via `getContainer`
|
|
140
222
|
// aren't attached until after child layout effects run.
|
|
@@ -145,28 +227,60 @@ var Anchor = /*#__PURE__*/forwardRef(function (baseprops, ref) {
|
|
|
145
227
|
// rAF throttle so the active key tracks scroll live.
|
|
146
228
|
var rafId = null;
|
|
147
229
|
var onScroll = function onScroll() {
|
|
230
|
+
if (pendingTargetKeyRef.current) {
|
|
231
|
+
clearNavigationSettleTimer();
|
|
232
|
+
}
|
|
148
233
|
if (rafId !== null) return;
|
|
149
234
|
rafId = requestAnimationFrame(function () {
|
|
150
235
|
rafId = null;
|
|
151
236
|
handleScroll();
|
|
152
237
|
});
|
|
153
238
|
};
|
|
239
|
+
var onScrollEnd = function onScrollEnd() {
|
|
240
|
+
var pendingTargetKey = pendingTargetKeyRef.current;
|
|
241
|
+
if (pendingTargetKey && hasReachedTarget(pendingTargetKey)) {
|
|
242
|
+
scheduleNavigationUnlock(pendingTargetKey);
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
var onUserInterrupt = function onUserInterrupt(event) {
|
|
246
|
+
if (event.type === 'pointerdown' && event.target instanceof Element) {
|
|
247
|
+
var item = event.target.closest(".".concat(CSS.escape("".concat(prefixCls, "-item"))));
|
|
248
|
+
var owner = item === null || item === void 0 ? void 0 : item.closest(".".concat(CSS.escape(prefixCls)));
|
|
249
|
+
if (owner === anchorRootRef.current) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (event.type === 'keydown' && !SCROLL_KEYS.has(event.key)) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
clearNavigationLock();
|
|
257
|
+
};
|
|
154
258
|
container.addEventListener('scroll', onScroll);
|
|
259
|
+
container.addEventListener('scrollend', onScrollEnd);
|
|
260
|
+
container.addEventListener('wheel', onUserInterrupt);
|
|
261
|
+
container.addEventListener('touchstart', onUserInterrupt);
|
|
262
|
+
document.addEventListener('pointerdown', onUserInterrupt);
|
|
263
|
+
container.addEventListener('keydown', onUserInterrupt);
|
|
155
264
|
handleScroll();
|
|
156
265
|
return function () {
|
|
157
266
|
container.removeEventListener('scroll', onScroll);
|
|
267
|
+
container.removeEventListener('scrollend', onScrollEnd);
|
|
268
|
+
container.removeEventListener('wheel', onUserInterrupt);
|
|
269
|
+
container.removeEventListener('touchstart', onUserInterrupt);
|
|
270
|
+
document.removeEventListener('pointerdown', onUserInterrupt);
|
|
271
|
+
container.removeEventListener('keydown', onUserInterrupt);
|
|
158
272
|
if (rafId !== null) {
|
|
159
273
|
cancelAnimationFrame(rafId);
|
|
160
274
|
}
|
|
161
275
|
};
|
|
162
|
-
}, [getContainer, handleScroll]);
|
|
276
|
+
}, [getContainer, handleScroll, hasReachedTarget, scheduleNavigationUnlock, clearNavigationSettleTimer, clearNavigationLock, prefixCls]);
|
|
163
277
|
|
|
164
278
|
// Scroll to target when activeKey changes
|
|
165
279
|
var scrollToAnchor = useCallback(function (key) {
|
|
166
280
|
var target = document.getElementById(key);
|
|
167
|
-
if (!target) return;
|
|
281
|
+
if (!target) return false;
|
|
168
282
|
var container = containerRef.current;
|
|
169
|
-
if (!container) return;
|
|
283
|
+
if (!container) return false;
|
|
170
284
|
var targetTop = getTargetOffsetTop(target) - offsetTop;
|
|
171
285
|
if (container === window) {
|
|
172
286
|
window.scrollTo({
|
|
@@ -179,6 +293,7 @@ var Anchor = /*#__PURE__*/forwardRef(function (baseprops, ref) {
|
|
|
179
293
|
behavior: 'smooth'
|
|
180
294
|
});
|
|
181
295
|
}
|
|
296
|
+
return true;
|
|
182
297
|
}, [offsetTop, getTargetOffsetTop]);
|
|
183
298
|
useEffect(function () {
|
|
184
299
|
if (defaultActiveKey) {
|
|
@@ -188,10 +303,16 @@ var Anchor = /*#__PURE__*/forwardRef(function (baseprops, ref) {
|
|
|
188
303
|
}, [defaultActiveKey]); // Only execute when defaultActiveKey changes
|
|
189
304
|
|
|
190
305
|
var handleItemClick = useCallback(function (key) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
306
|
+
startNavigationLock(key);
|
|
307
|
+
commitActiveKey(key, true);
|
|
308
|
+
if (!scrollToAnchor(key)) {
|
|
309
|
+
clearNavigationLock();
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// Handles instant scrolling and targets that are already in position.
|
|
314
|
+
handleScroll();
|
|
315
|
+
}, [startNavigationLock, commitActiveKey, scrollToAnchor, clearNavigationLock, handleScroll]);
|
|
195
316
|
var cls = clsx(prefixCls, _defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-").concat(direction), direction), "".concat(prefixCls, "-affix"), affix), "".concat(prefixCls, "-static"), !affix), className);
|
|
196
317
|
var currentItems = auto ? anchorList : items;
|
|
197
318
|
var contextValue = {
|
|
@@ -214,7 +335,7 @@ var Anchor = /*#__PURE__*/forwardRef(function (baseprops, ref) {
|
|
|
214
335
|
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
215
336
|
className: cls,
|
|
216
337
|
style: style,
|
|
217
|
-
ref:
|
|
338
|
+
ref: setAnchorRootRef
|
|
218
339
|
}), renderNavArrow(), /*#__PURE__*/React.createElement(AnchorContext.Provider, {
|
|
219
340
|
value: contextValue
|
|
220
341
|
}, /*#__PURE__*/React.createElement("div", {
|
package/dist/esm/Input/input.js
CHANGED
|
@@ -86,6 +86,9 @@ var Input = /*#__PURE__*/forwardRef(function (baseprops, ref) {
|
|
|
86
86
|
}, showClear && /*#__PURE__*/React.createElement("span", {
|
|
87
87
|
className: clsx("".concat(prefixCls, "-clear"), classNames === null || classNames === void 0 ? void 0 : classNames.clear),
|
|
88
88
|
style: styles === null || styles === void 0 ? void 0 : styles.clear,
|
|
89
|
+
role: "button",
|
|
90
|
+
"aria-label": "clear",
|
|
91
|
+
tabIndex: 0,
|
|
89
92
|
onClick: onClear,
|
|
90
93
|
onKeyDown: function onKeyDown(event) {
|
|
91
94
|
if (event.key === 'Enter') {
|
|
@@ -32,7 +32,8 @@ var Option = function Option(props) {
|
|
|
32
32
|
var focused = looseMatch ? String(focusedKey) === String(value) : focusedKey === value;
|
|
33
33
|
return /*#__PURE__*/React.createElement("div", {
|
|
34
34
|
className: clsx("".concat(prefixCls, "-option"), _defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-option-selected"), selected), "".concat(prefixCls, "-option-focused"), focused), "".concat(prefixCls, "-option-disabled"), disabled)),
|
|
35
|
-
"aria-
|
|
35
|
+
"aria-selected": selected,
|
|
36
|
+
"aria-disabled": disabled || undefined,
|
|
36
37
|
onClick: handleClick,
|
|
37
38
|
onKeyDown: function onKeyDown(e) {
|
|
38
39
|
if (e.key === 'Enter') {
|
|
@@ -146,6 +146,8 @@ var Options = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
146
146
|
className: clsx("".concat(prefixCls, "-popup"), "".concat(prefixCls, "-popup-virtual"), popupClassName),
|
|
147
147
|
style: popupStyle,
|
|
148
148
|
ref: rootRef,
|
|
149
|
+
role: "listbox",
|
|
150
|
+
"aria-multiselectable": multiple || undefined,
|
|
149
151
|
tabIndex: -1
|
|
150
152
|
}), /*#__PURE__*/React.createElement(OptionsCtx.Provider, {
|
|
151
153
|
value: ctxValue
|
|
@@ -196,6 +198,8 @@ var Options = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
196
198
|
className: clsx("".concat(prefixCls, "-popup"), "".concat(prefixCls, "-popup-virtual"), popupClassName),
|
|
197
199
|
style: popupStyle,
|
|
198
200
|
ref: rootRef,
|
|
201
|
+
role: "listbox",
|
|
202
|
+
"aria-multiselectable": multiple || undefined,
|
|
199
203
|
tabIndex: -1
|
|
200
204
|
}), /*#__PURE__*/React.createElement(OptionsCtx.Provider, {
|
|
201
205
|
value: ctxValue
|
|
@@ -235,6 +239,8 @@ var Options = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
235
239
|
'--yee-select-columns': columns
|
|
236
240
|
} : undefined),
|
|
237
241
|
ref: rootRef,
|
|
242
|
+
role: "listbox",
|
|
243
|
+
"aria-multiselectable": multiple || undefined,
|
|
238
244
|
tabIndex: -1
|
|
239
245
|
}), isEmpty ? /*#__PURE__*/React.createElement("div", {
|
|
240
246
|
className: "".concat(prefixCls, "-empty")
|
|
@@ -74,7 +74,7 @@ var Select = function Select(baseprops) {
|
|
|
74
74
|
if (Array.isArray(value)) {
|
|
75
75
|
return value;
|
|
76
76
|
}
|
|
77
|
-
if (value !== undefined && _typeof(value) !== null) {
|
|
77
|
+
if (value !== undefined && _typeof(value) !== null && value !== '') {
|
|
78
78
|
return [value];
|
|
79
79
|
}
|
|
80
80
|
return [];
|
|
@@ -202,6 +202,10 @@ var Selector = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
202
202
|
tabIndex: disabled || searchable ? -1 : 0,
|
|
203
203
|
className: cls,
|
|
204
204
|
style: style,
|
|
205
|
+
role: "combobox",
|
|
206
|
+
"aria-expanded": open || false,
|
|
207
|
+
"aria-haspopup": "listbox",
|
|
208
|
+
"aria-disabled": disabled || undefined,
|
|
205
209
|
onKeyDown: function onKeyDown(event) {
|
|
206
210
|
if (disabled) return;
|
|
207
211
|
// For non-searchable single select, handle Enter to open dropdown
|
|
@@ -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/esm/Tag/tag.js
CHANGED
|
@@ -47,6 +47,7 @@ var Tag = /*#__PURE__*/forwardRef(function (baseprops, ref) {
|
|
|
47
47
|
style: styles === null || styles === void 0 ? void 0 : styles.close,
|
|
48
48
|
type: "text",
|
|
49
49
|
size: "small",
|
|
50
|
+
"aria-label": "close",
|
|
50
51
|
onClick: onClose
|
|
51
52
|
}, typeof closable === 'boolean' ? /*#__PURE__*/React.createElement(X, {
|
|
52
53
|
size: 14,
|
|
@@ -58,7 +59,11 @@ var Tag = /*#__PURE__*/forwardRef(function (baseprops, ref) {
|
|
|
58
59
|
className: cls,
|
|
59
60
|
onClick: handleClick,
|
|
60
61
|
ref: ref
|
|
61
|
-
}
|
|
62
|
+
}, checkable ? {
|
|
63
|
+
role: 'checkbox',
|
|
64
|
+
'aria-checked': checked || false,
|
|
65
|
+
tabIndex: 0
|
|
66
|
+
} : undefined), icon && /*#__PURE__*/React.createElement("span", {
|
|
62
67
|
className: clsx("".concat(prefixCls, "-icon"), classNames === null || classNames === void 0 ? void 0 : classNames.icon),
|
|
63
68
|
style: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
64
69
|
}, icon), icon || closeNode ? /*#__PURE__*/React.createElement("span", {
|
|
@@ -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
|
*/
|
|
@@ -134,7 +134,12 @@ var Node = function Node(props) {
|
|
|
134
134
|
} : {};
|
|
135
135
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
136
136
|
className: clsx("".concat(prefixCls, "-node"), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-node-with-line"), showLine), "".concat(prefixCls, "-leaf-node"), isLeaf), "".concat(prefixCls, "-last-node"), isLast), "".concat(prefixCls, "-node-dragging"), draggingUid === uid), "".concat(prefixCls, "-node-drag-over-before"), dropPosition === 'before'), "".concat(prefixCls, "-node-drag-over-after"), dropPosition === 'after'), "".concat(prefixCls, "-node-drag-over-inside"), dropPosition === 'inside')),
|
|
137
|
-
style: nodeStyle
|
|
137
|
+
style: nodeStyle,
|
|
138
|
+
role: "treeitem",
|
|
139
|
+
"aria-expanded": isLeaf ? undefined : expanded,
|
|
140
|
+
"aria-selected": selected,
|
|
141
|
+
"aria-level": depth + 1,
|
|
142
|
+
"aria-disabled": disabled || undefined
|
|
138
143
|
}, dragProps), renderEmptyNodes(depth), renderExpandedIcon(), renderCheckbox(), renderLabel());
|
|
139
144
|
};
|
|
140
145
|
export default Node;
|
package/dist/esm/Tree/tree.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _excluded = ["prefixCls", "className", "style", "dataSource", "fieldNames", "defaultExpandAll", "expandedKeys", "defaultExpandedKeys", "selectedKeys", "defaultSelectedKeys", "checkedKeys", "defaultCheckedKeys", "checkable", "multiple", "showIcon", "icon", "showLine", "switcherIcon", "draggable", "allowDrop", "onDrop", "onSelect", "onCheck", "onExpand", "virtual", "height", "itemHeight"];
|
|
2
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
5
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
6
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
7
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
7
9
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
10
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
11
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
@@ -12,6 +14,8 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
|
|
|
12
14
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
15
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
14
16
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
18
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
15
19
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function (_e) { function e(_x) { return _e.apply(this, arguments); } e.toString = function () { return _e.toString(); }; return e; }(function (e) { throw e; }), f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function (_e2) { function e(_x2) { return _e2.apply(this, arguments); } e.toString = function () { return _e2.toString(); }; return e; }(function (e) { didErr = true; err = e; }), f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
16
20
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(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); }
|
|
17
21
|
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; }
|
|
@@ -23,6 +27,7 @@ import useEvent from "../hooks/useEvent";
|
|
|
23
27
|
import useMergedState from "../hooks/useMergedState";
|
|
24
28
|
import useVirtualList from "../hooks/useVirtualList";
|
|
25
29
|
import mergeContextToProps from "../utils/mergeContextToProps";
|
|
30
|
+
import { pickDataAttrs } from "../utils/types";
|
|
26
31
|
import TreeNodeComp from "./tree-node";
|
|
27
32
|
import { getCheckedKeys, tree2array } from "./utils/tree-tools";
|
|
28
33
|
import "./style/index.less";
|
|
@@ -209,7 +214,9 @@ var Tree = function Tree(baseprops) {
|
|
|
209
214
|
virtual = _props$virtual === void 0 ? false : _props$virtual,
|
|
210
215
|
height = props.height,
|
|
211
216
|
_props$itemHeight = props.itemHeight,
|
|
212
|
-
itemHeight = _props$itemHeight === void 0 ? 28 : _props$itemHeight
|
|
217
|
+
itemHeight = _props$itemHeight === void 0 ? 28 : _props$itemHeight,
|
|
218
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
219
|
+
var dataAttrs = pickDataAttrs(rest);
|
|
213
220
|
|
|
214
221
|
// ======================== Data ========================
|
|
215
222
|
var _useMemo = useMemo(function () {
|
|
@@ -599,11 +606,12 @@ var Tree = function Tree(baseprops) {
|
|
|
599
606
|
// ==================== Render ====================
|
|
600
607
|
if (useVirtual) {
|
|
601
608
|
var slicedItems = visibleItems.slice(start, end);
|
|
602
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
609
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
603
610
|
className: clsx(prefixCls, className),
|
|
604
611
|
style: style,
|
|
612
|
+
role: "tree",
|
|
605
613
|
onDragEnd: handleDragEnd
|
|
606
|
-
}, /*#__PURE__*/React.createElement(TreeContext.Provider, {
|
|
614
|
+
}, dataAttrs), /*#__PURE__*/React.createElement(TreeContext.Provider, {
|
|
607
615
|
value: contextValue
|
|
608
616
|
}, /*#__PURE__*/React.createElement("div", {
|
|
609
617
|
ref: viewportRef,
|
|
@@ -684,11 +692,12 @@ var Tree = function Tree(baseprops) {
|
|
|
684
692
|
type: 'group'
|
|
685
693
|
}, currentGroup));
|
|
686
694
|
}
|
|
687
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
695
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
688
696
|
className: clsx(prefixCls, className),
|
|
689
697
|
style: style,
|
|
698
|
+
role: "tree",
|
|
690
699
|
onDragEnd: handleDragEnd
|
|
691
|
-
}, /*#__PURE__*/React.createElement(TreeContext.Provider, {
|
|
700
|
+
}, dataAttrs), /*#__PURE__*/React.createElement(TreeContext.Provider, {
|
|
692
701
|
value: contextValue
|
|
693
702
|
}, /*#__PURE__*/React.createElement(AnimatePresence, {
|
|
694
703
|
initial: false
|
|
@@ -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/esm/version.d.ts
CHANGED
package/dist/esm/version.js
CHANGED