@choice-ui/react 1.5.4 → 1.5.5
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/components/calendar/dist/index.js +2 -2
- package/dist/components/calendar/src/time-calendar/time-calendar.js +2 -2
- package/dist/components/code-block/dist/index.js +13 -13
- package/dist/components/code-block/src/code-block.js +11 -11
- package/dist/components/code-block/src/hooks/use-line-count.js +3 -3
- package/dist/components/command/src/components/command-group.js +2 -2
- package/dist/components/command/src/components/command-item.js +3 -3
- package/dist/components/command/src/hooks/index.js +2 -2
- package/dist/components/command/src/hooks/use-command-state.js +3 -3
- package/dist/components/command/src/hooks/use-command.js +2 -2
- package/dist/components/command/src/utils/helpers.js +4 -4
- package/dist/components/comments/src/comment-item/comment-item.js +2 -2
- package/dist/components/comments/src/comment-item/components/comment-item-reactions.js +2 -2
- package/dist/components/conditions/src/hooks/use-drag-and-drop.js +3 -3
- package/dist/components/context-input/src/components/copy-button.js +2 -2
- package/dist/components/context-input/src/components/mention.js +2 -2
- package/dist/components/context-input/src/components/slate-editor.js +3 -3
- package/dist/components/context-input/src/context-input.js +5 -5
- package/dist/components/context-menu/src/context-menu.js +6 -6
- package/dist/components/dialog/dist/index.js +2 -2
- package/dist/components/dialog/src/dialog.js +2 -2
- package/dist/components/index.d.ts +1 -0
- package/dist/components/md-input/src/components/toolbar/toolbar.js +2 -2
- package/dist/components/md-input/src/md-input.js +3 -3
- package/dist/components/menus/dist/index.js +2 -2
- package/dist/components/menus/src/menus.js +2 -2
- package/dist/components/multi-select/dist/index.js +2 -2
- package/dist/components/multi-select/src/utils/extract-options.js +2 -2
- package/dist/components/otp-input/dist/index.d.ts +30 -0
- package/dist/components/otp-input/src/index.d.ts +2 -0
- package/dist/components/otp-input/src/otp-input.d.ts +27 -0
- package/dist/components/otp-input/src/otp-input.js +115 -0
- package/dist/components/otp-input/src/otp-input.module.css +15 -0
- package/dist/components/otp-input/src/otp-input.module.css.js +8 -0
- package/dist/components/otp-input/src/tv.d.ts +121 -0
- package/dist/components/otp-input/src/tv.js +150 -0
- package/dist/components/otp-input/tsup.config.d.ts +2 -0
- package/dist/components/panel/src/components/panel-sortable.js +3 -3
- package/dist/components/rich-input/src/hooks/use-editor-config.js +3 -3
- package/dist/components/rich-input/src/utils/custom-options.js +15 -15
- package/dist/components/select/dist/index.js +2 -2
- package/dist/components/select/src/select.js +2 -2
- package/dist/components/slot/dist/index.d.ts +10 -10
- package/dist/components/slot/dist/index.js +7 -15
- package/dist/components/slot/src/slot.d.ts +12 -12
- package/dist/components/slot/src/slot.js +10 -18
- package/dist/components/textarea/dist/index.js +14 -14
- package/dist/components/textarea/src/components/autosize/hooks.js +5 -5
- package/dist/components/textarea/src/components/autosize/index.js +10 -10
- package/dist/components/tree-list/src/tree-list.js +3 -3
- package/dist/components/virtualized-grid/src/error-boundary.js +2 -2
- package/dist/index.js +2 -0
- package/dist/node_modules/.pnpm/input-otp@1.4.2_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/input-otp/dist/index.js +200 -0
- package/package.json +1 -1
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React__default, { forwardRef, useMemo } from "react";
|
|
2
2
|
import { jsx, Fragment } from "react/jsx-runtime";
|
|
3
|
-
var REACT_MAJOR = parseInt(React.version.split(".")[0], 10);
|
|
4
|
-
var IS_REACT_19 = REACT_MAJOR >= 19;
|
|
5
|
-
function getChildRef(children) {
|
|
6
|
-
if (IS_REACT_19) {
|
|
7
|
-
return children.props.ref;
|
|
8
|
-
}
|
|
9
|
-
return void 0;
|
|
10
|
-
}
|
|
11
3
|
var Slot = forwardRef(
|
|
12
4
|
({ children, ...slotProps }, forwardedRef) => {
|
|
13
5
|
const slottedChild = useMemo(() => {
|
|
14
|
-
if (!
|
|
6
|
+
if (!React__default.isValidElement(children)) {
|
|
15
7
|
return children;
|
|
16
8
|
}
|
|
17
|
-
const childRef =
|
|
9
|
+
const childRef = children.ref;
|
|
18
10
|
const mergedProps = mergeProps(slotProps, children.props);
|
|
19
|
-
return
|
|
11
|
+
return React__default.cloneElement(children, {
|
|
20
12
|
...mergedProps,
|
|
21
13
|
ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef
|
|
22
14
|
});
|
|
@@ -28,12 +20,12 @@ Slot.displayName = "Slot";
|
|
|
28
20
|
var SlotClone = forwardRef(
|
|
29
21
|
({ children, ...slotProps }, forwardedRef) => {
|
|
30
22
|
const slottedChild = useMemo(() => {
|
|
31
|
-
if (!
|
|
23
|
+
if (!React__default.isValidElement(children)) {
|
|
32
24
|
return children;
|
|
33
25
|
}
|
|
34
|
-
const childRef =
|
|
26
|
+
const childRef = children.ref;
|
|
35
27
|
const mergedProps = mergeProps(slotProps, children.props);
|
|
36
|
-
return
|
|
28
|
+
return React__default.cloneElement(children, {
|
|
37
29
|
...mergedProps,
|
|
38
30
|
ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef
|
|
39
31
|
});
|
|
@@ -6,28 +6,28 @@ interface SlotCloneProps {
|
|
|
6
6
|
children: React.ReactNode;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* 优化的 Slot 组件实现
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
* 1.
|
|
13
|
-
* 2.
|
|
14
|
-
* 3.
|
|
15
|
-
* 4.
|
|
11
|
+
* 相比 @radix-ui/react-slot 的性能优化:
|
|
12
|
+
* 1. 使用 useMemo 缓存 children 处理结果
|
|
13
|
+
* 2. 简化 props 合并逻辑
|
|
14
|
+
* 3. 避免不必要的深度遍历
|
|
15
|
+
* 4. 更好的类型安全
|
|
16
16
|
*/
|
|
17
17
|
export declare const Slot: React.ForwardRefExoticComponent<SlotProps & React.RefAttributes<HTMLElement>>;
|
|
18
18
|
/**
|
|
19
|
-
* SlotClone
|
|
20
|
-
*
|
|
19
|
+
* SlotClone 组件 - 用于深度克隆
|
|
20
|
+
* 当需要处理嵌套结构时使用
|
|
21
21
|
*/
|
|
22
22
|
export declare const SlotClone: React.ForwardRefExoticComponent<SlotCloneProps & React.RefAttributes<HTMLElement>>;
|
|
23
23
|
/**
|
|
24
|
-
* Hook
|
|
25
|
-
*
|
|
24
|
+
* Hook 版本的 Slot 逻辑
|
|
25
|
+
* 用于需要更细粒度控制的场景
|
|
26
26
|
*/
|
|
27
27
|
export declare function useSlot(children: React.ReactNode, slotProps: Record<string, unknown>, forwardedRef?: React.Ref<unknown>): string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
29
|
+
* 性能优化的 asChild 模式 Hook
|
|
30
|
+
* 用于替代 `const Component = asChild ? Slot : "button"` 模式
|
|
31
31
|
*/
|
|
32
32
|
export declare function useAsChild<T extends React.ElementType = "button">(asChild: boolean | undefined, defaultElement: T): T | typeof Slot;
|
|
33
33
|
export {};
|
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
const REACT_MAJOR = parseInt(React.version.split(".")[0], 10);
|
|
4
|
-
const IS_REACT_19 = REACT_MAJOR >= 19;
|
|
5
|
-
function getChildRef(children) {
|
|
6
|
-
if (IS_REACT_19) {
|
|
7
|
-
return children.props.ref;
|
|
8
|
-
}
|
|
9
|
-
return void 0;
|
|
10
|
-
}
|
|
2
|
+
import React__default, { forwardRef, useMemo } from "react";
|
|
11
3
|
const Slot = forwardRef(
|
|
12
4
|
({ children, ...slotProps }, forwardedRef) => {
|
|
13
5
|
const slottedChild = useMemo(() => {
|
|
14
|
-
if (!
|
|
6
|
+
if (!React__default.isValidElement(children)) {
|
|
15
7
|
return children;
|
|
16
8
|
}
|
|
17
|
-
const childRef =
|
|
9
|
+
const childRef = children.ref;
|
|
18
10
|
const mergedProps = mergeProps(slotProps, children.props);
|
|
19
|
-
return
|
|
11
|
+
return React__default.cloneElement(children, {
|
|
20
12
|
...mergedProps,
|
|
21
13
|
ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef
|
|
22
14
|
});
|
|
@@ -28,12 +20,12 @@ Slot.displayName = "Slot";
|
|
|
28
20
|
const SlotClone = forwardRef(
|
|
29
21
|
({ children, ...slotProps }, forwardedRef) => {
|
|
30
22
|
const slottedChild = useMemo(() => {
|
|
31
|
-
if (!
|
|
23
|
+
if (!React__default.isValidElement(children)) {
|
|
32
24
|
return children;
|
|
33
25
|
}
|
|
34
|
-
const childRef =
|
|
26
|
+
const childRef = children.ref;
|
|
35
27
|
const mergedProps = mergeProps(slotProps, children.props);
|
|
36
|
-
return
|
|
28
|
+
return React__default.cloneElement(children, {
|
|
37
29
|
...mergedProps,
|
|
38
30
|
ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef
|
|
39
31
|
});
|
|
@@ -86,12 +78,12 @@ function composeRefs(...refs) {
|
|
|
86
78
|
}
|
|
87
79
|
function useSlot(children, slotProps, forwardedRef) {
|
|
88
80
|
return useMemo(() => {
|
|
89
|
-
if (!
|
|
81
|
+
if (!React__default.isValidElement(children)) {
|
|
90
82
|
return children;
|
|
91
83
|
}
|
|
92
|
-
const childRef =
|
|
84
|
+
const childRef = children.ref;
|
|
93
85
|
const mergedProps = mergeProps(slotProps, children.props);
|
|
94
|
-
return
|
|
86
|
+
return React__default.cloneElement(children, {
|
|
95
87
|
...mergedProps,
|
|
96
88
|
ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef
|
|
97
89
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ScrollArea } from "../../scroll-area/dist/index.js";
|
|
2
|
-
import
|
|
2
|
+
import React__default, { forwardRef, useRef, useState, useImperativeHandle, useMemo, useEffect, Children, isValidElement, memo } from "react";
|
|
3
3
|
import { useUnmount, useEventCallback, useIsomorphicLayoutEffect } from "usehooks-ts";
|
|
4
4
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
5
5
|
import { mergeRefs } from "../../../shared/utils/merge-refs/merge-refs.js";
|
|
@@ -217,12 +217,12 @@ var getSizingData = (node) => {
|
|
|
217
217
|
};
|
|
218
218
|
var get_sizing_data_default = getSizingData;
|
|
219
219
|
function useLatest(value) {
|
|
220
|
-
const ref =
|
|
220
|
+
const ref = React__default.useRef(value);
|
|
221
221
|
ref.current = value;
|
|
222
222
|
return ref;
|
|
223
223
|
}
|
|
224
224
|
function useComposedRef(libRef, userRef) {
|
|
225
|
-
return
|
|
225
|
+
return React__default.useCallback(
|
|
226
226
|
(node) => {
|
|
227
227
|
libRef.current = node;
|
|
228
228
|
if (typeof userRef === "function") {
|
|
@@ -256,7 +256,7 @@ function useListener(target, type, listener) {
|
|
|
256
256
|
}, [target, type, latestListener]);
|
|
257
257
|
}
|
|
258
258
|
var useFormResetListener = (libRef, listener) => {
|
|
259
|
-
const stableListener =
|
|
259
|
+
const stableListener = React__default.useCallback(
|
|
260
260
|
(ev) => {
|
|
261
261
|
var _a;
|
|
262
262
|
if (((_a = libRef.current) == null ? void 0 : _a.form) === ev.target) {
|
|
@@ -271,7 +271,7 @@ var useWindowResizeListener = (listener) => {
|
|
|
271
271
|
useListener(isBrowser ? window : null, "resize", listener);
|
|
272
272
|
};
|
|
273
273
|
var useFontsLoadedListener = (listener) => {
|
|
274
|
-
const safeListener =
|
|
274
|
+
const safeListener = React__default.useCallback(
|
|
275
275
|
(event) => {
|
|
276
276
|
try {
|
|
277
277
|
listener(event);
|
|
@@ -334,14 +334,14 @@ var TextareaAutosize = forwardRef(
|
|
|
334
334
|
...props
|
|
335
335
|
}, userRef) {
|
|
336
336
|
const isControlled = props.value !== void 0;
|
|
337
|
-
const libRef =
|
|
337
|
+
const libRef = React__default.useRef(null);
|
|
338
338
|
const ref = useComposedRef(libRef, userRef);
|
|
339
|
-
const heightRef =
|
|
340
|
-
const measurementsCacheRef =
|
|
341
|
-
const lastValueRef =
|
|
339
|
+
const heightRef = React__default.useRef(0);
|
|
340
|
+
const measurementsCacheRef = React__default.useRef();
|
|
341
|
+
const lastValueRef = React__default.useRef("");
|
|
342
342
|
const normalizedMinRows = Math.max(minRows, 1);
|
|
343
343
|
const normalizedMaxRows = maxRows && maxRows >= normalizedMinRows ? maxRows : void 0;
|
|
344
|
-
const resizeTextarea =
|
|
344
|
+
const resizeTextarea = React__default.useCallback(() => {
|
|
345
345
|
const node = libRef.current;
|
|
346
346
|
if (!node || !isBrowser) return;
|
|
347
347
|
const currentValue = node.value || node.placeholder || "";
|
|
@@ -388,7 +388,7 @@ var TextareaAutosize = forwardRef(
|
|
|
388
388
|
}
|
|
389
389
|
}, [cacheMeasurements, normalizedMinRows, normalizedMaxRows, onHeightChange]);
|
|
390
390
|
const debouncedResize = useDebounce(resizeTextarea, debounceMs);
|
|
391
|
-
const handleChange =
|
|
391
|
+
const handleChange = React__default.useCallback(
|
|
392
392
|
(event) => {
|
|
393
393
|
if (!isControlled) {
|
|
394
394
|
if (debounceMs > 0) {
|
|
@@ -401,7 +401,7 @@ var TextareaAutosize = forwardRef(
|
|
|
401
401
|
},
|
|
402
402
|
[isControlled, debounceMs, debouncedResize, resizeTextarea, onChange]
|
|
403
403
|
);
|
|
404
|
-
const formResetCallback =
|
|
404
|
+
const formResetCallback = React__default.useCallback(() => {
|
|
405
405
|
var _a;
|
|
406
406
|
if (!isControlled) {
|
|
407
407
|
const currentValue = ((_a = libRef.current) == null ? void 0 : _a.value) || "";
|
|
@@ -417,7 +417,7 @@ var TextareaAutosize = forwardRef(
|
|
|
417
417
|
useFormResetListener(libRef, formResetCallback);
|
|
418
418
|
useWindowResizeListener(resizeTextarea);
|
|
419
419
|
useFontsLoadedListener(resizeTextarea);
|
|
420
|
-
|
|
420
|
+
React__default.useEffect(() => {
|
|
421
421
|
const node = libRef.current;
|
|
422
422
|
if (!node || !isBrowser || typeof IntersectionObserver === "undefined") {
|
|
423
423
|
return;
|
|
@@ -439,7 +439,7 @@ var TextareaAutosize = forwardRef(
|
|
|
439
439
|
observer.disconnect();
|
|
440
440
|
};
|
|
441
441
|
}, [resizeTextarea]);
|
|
442
|
-
|
|
442
|
+
React__default.useEffect(() => {
|
|
443
443
|
resizeTextarea();
|
|
444
444
|
}, [style == null ? void 0 : style.lineHeight, style == null ? void 0 : style.padding, resizeTextarea]);
|
|
445
445
|
const mergedStyle = useMemo(() => {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React__default from "react";
|
|
2
2
|
import { isBrowser } from "./utils.js";
|
|
3
3
|
import { useIsomorphicLayoutEffect } from "usehooks-ts";
|
|
4
4
|
function useLatest(value) {
|
|
5
|
-
const ref =
|
|
5
|
+
const ref = React__default.useRef(value);
|
|
6
6
|
ref.current = value;
|
|
7
7
|
return ref;
|
|
8
8
|
}
|
|
9
9
|
function useComposedRef(libRef, userRef) {
|
|
10
|
-
return
|
|
10
|
+
return React__default.useCallback(
|
|
11
11
|
(node) => {
|
|
12
12
|
libRef.current = node;
|
|
13
13
|
if (typeof userRef === "function") {
|
|
@@ -41,7 +41,7 @@ function useListener(target, type, listener) {
|
|
|
41
41
|
}, [target, type, latestListener]);
|
|
42
42
|
}
|
|
43
43
|
const useFormResetListener = (libRef, listener) => {
|
|
44
|
-
const stableListener =
|
|
44
|
+
const stableListener = React__default.useCallback(
|
|
45
45
|
(ev) => {
|
|
46
46
|
var _a;
|
|
47
47
|
if (((_a = libRef.current) == null ? void 0 : _a.form) === ev.target) {
|
|
@@ -56,7 +56,7 @@ const useWindowResizeListener = (listener) => {
|
|
|
56
56
|
useListener(isBrowser ? window : null, "resize", listener);
|
|
57
57
|
};
|
|
58
58
|
const useFontsLoadedListener = (listener) => {
|
|
59
|
-
const safeListener =
|
|
59
|
+
const safeListener = React__default.useCallback(
|
|
60
60
|
(event) => {
|
|
61
61
|
try {
|
|
62
62
|
listener(event);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import React__default, { forwardRef, useMemo, useRef } from "react";
|
|
3
3
|
import { isBrowser, noop } from "./utils.js";
|
|
4
4
|
import calculateNodeHeight from "./calculate-node-height.js";
|
|
5
5
|
import getSizingData from "./get-sizing-data.js";
|
|
@@ -53,14 +53,14 @@ const TextareaAutosize = forwardRef(
|
|
|
53
53
|
...props
|
|
54
54
|
}, userRef) {
|
|
55
55
|
const isControlled = props.value !== void 0;
|
|
56
|
-
const libRef =
|
|
56
|
+
const libRef = React__default.useRef(null);
|
|
57
57
|
const ref = useComposedRef(libRef, userRef);
|
|
58
|
-
const heightRef =
|
|
59
|
-
const measurementsCacheRef =
|
|
60
|
-
const lastValueRef =
|
|
58
|
+
const heightRef = React__default.useRef(0);
|
|
59
|
+
const measurementsCacheRef = React__default.useRef();
|
|
60
|
+
const lastValueRef = React__default.useRef("");
|
|
61
61
|
const normalizedMinRows = Math.max(minRows, 1);
|
|
62
62
|
const normalizedMaxRows = maxRows && maxRows >= normalizedMinRows ? maxRows : void 0;
|
|
63
|
-
const resizeTextarea =
|
|
63
|
+
const resizeTextarea = React__default.useCallback(() => {
|
|
64
64
|
const node = libRef.current;
|
|
65
65
|
if (!node || !isBrowser) return;
|
|
66
66
|
const currentValue = node.value || node.placeholder || "";
|
|
@@ -107,7 +107,7 @@ const TextareaAutosize = forwardRef(
|
|
|
107
107
|
}
|
|
108
108
|
}, [cacheMeasurements, normalizedMinRows, normalizedMaxRows, onHeightChange]);
|
|
109
109
|
const debouncedResize = useDebounce(resizeTextarea, debounceMs);
|
|
110
|
-
const handleChange =
|
|
110
|
+
const handleChange = React__default.useCallback(
|
|
111
111
|
(event) => {
|
|
112
112
|
if (!isControlled) {
|
|
113
113
|
if (debounceMs > 0) {
|
|
@@ -120,7 +120,7 @@ const TextareaAutosize = forwardRef(
|
|
|
120
120
|
},
|
|
121
121
|
[isControlled, debounceMs, debouncedResize, resizeTextarea, onChange]
|
|
122
122
|
);
|
|
123
|
-
const formResetCallback =
|
|
123
|
+
const formResetCallback = React__default.useCallback(() => {
|
|
124
124
|
var _a;
|
|
125
125
|
if (!isControlled) {
|
|
126
126
|
const currentValue = ((_a = libRef.current) == null ? void 0 : _a.value) || "";
|
|
@@ -136,7 +136,7 @@ const TextareaAutosize = forwardRef(
|
|
|
136
136
|
useFormResetListener(libRef, formResetCallback);
|
|
137
137
|
useWindowResizeListener(resizeTextarea);
|
|
138
138
|
useFontsLoadedListener(resizeTextarea);
|
|
139
|
-
|
|
139
|
+
React__default.useEffect(() => {
|
|
140
140
|
const node = libRef.current;
|
|
141
141
|
if (!node || !isBrowser || typeof IntersectionObserver === "undefined") {
|
|
142
142
|
return;
|
|
@@ -158,7 +158,7 @@ const TextareaAutosize = forwardRef(
|
|
|
158
158
|
observer.disconnect();
|
|
159
159
|
};
|
|
160
160
|
}, [resizeTextarea]);
|
|
161
|
-
|
|
161
|
+
React__default.useEffect(() => {
|
|
162
162
|
resizeTextarea();
|
|
163
163
|
}, [style == null ? void 0 : style.lineHeight, style == null ? void 0 : style.padding, resizeTextarea]);
|
|
164
164
|
const mergedStyle = useMemo(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { ScrollArea } from "../../scroll-area/dist/index.js";
|
|
3
3
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
4
|
-
import
|
|
4
|
+
import React__default, { useState, useRef, useCallback, useEffect, useImperativeHandle, useMemo, createContext } from "react";
|
|
5
5
|
import { flattenTree, findNodePathById } from "./utils/tree.js";
|
|
6
6
|
import { useSelection } from "./hooks/use-selection.js";
|
|
7
7
|
import { useRenaming } from "./hooks/use-renaming.js";
|
|
@@ -11,14 +11,14 @@ import { TreeNodeWrapper } from "./components/tree-node-wrapper.js";
|
|
|
11
11
|
import { tcx } from "../../../shared/utils/tcx/tcx.js";
|
|
12
12
|
const TreeContext = createContext(null);
|
|
13
13
|
const useTreeContext = () => {
|
|
14
|
-
const context =
|
|
14
|
+
const context = React__default.useContext(TreeContext);
|
|
15
15
|
if (!context) {
|
|
16
16
|
throw new Error("useTreeContext must be used within a TreeList");
|
|
17
17
|
}
|
|
18
18
|
return context;
|
|
19
19
|
};
|
|
20
20
|
const DEFAULT_NODE_HEIGHT = 32;
|
|
21
|
-
const TreeList =
|
|
21
|
+
const TreeList = React__default.forwardRef((props, ref) => {
|
|
22
22
|
const {
|
|
23
23
|
data,
|
|
24
24
|
selectedNodeIds,
|
|
@@ -3,8 +3,8 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { Button } from "../../button/dist/index.js";
|
|
6
|
-
import
|
|
7
|
-
class VirtualizedGridErrorBoundary extends
|
|
6
|
+
import React__default from "react";
|
|
7
|
+
class VirtualizedGridErrorBoundary extends React__default.Component {
|
|
8
8
|
constructor(props) {
|
|
9
9
|
super(props);
|
|
10
10
|
__publicField(this, "retry", () => {
|
package/dist/index.js
CHANGED
|
@@ -174,6 +174,7 @@ import { NumericInput } from "./components/numeric-input/src/numeric-input.js";
|
|
|
174
174
|
import { NumericInputElement } from "./components/numeric-input/src/components/numeric-input-element.js";
|
|
175
175
|
import { NumericInputMenuTrigger } from "./components/numeric-input/src/components/numeric-input-menu-trigger.js";
|
|
176
176
|
import { NumericInputVariable } from "./components/numeric-input/src/components/numeric-input-variable.js";
|
|
177
|
+
import { OtpInput } from "./components/otp-input/src/otp-input.js";
|
|
177
178
|
import { Pagination } from "./components/pagination/src/pagination.js";
|
|
178
179
|
import { Panel, PanelBase } from "./components/panel/src/panel.js";
|
|
179
180
|
import { PanelRow } from "./components/panel/src/components/panel-row.js";
|
|
@@ -379,6 +380,7 @@ export {
|
|
|
379
380
|
NumericInputMenuTrigger,
|
|
380
381
|
NumericInputVariable,
|
|
381
382
|
OPERATOR_CONFIGS,
|
|
383
|
+
OtpInput,
|
|
382
384
|
PRESET_EASINGS,
|
|
383
385
|
PREVIEW_KEYFRAMES,
|
|
384
386
|
Pagination,
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
var Bt = Object.defineProperty, At = Object.defineProperties;
|
|
3
|
+
var kt = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var Y = Object.getOwnPropertySymbols;
|
|
5
|
+
var gt = Object.prototype.hasOwnProperty, Et = Object.prototype.propertyIsEnumerable;
|
|
6
|
+
var vt = (r, s, e) => s in r ? Bt(r, s, { enumerable: true, configurable: true, writable: true, value: e }) : r[s] = e, St = (r, s) => {
|
|
7
|
+
for (var e in s || (s = {})) gt.call(s, e) && vt(r, e, s[e]);
|
|
8
|
+
if (Y) for (var e of Y(s)) Et.call(s, e) && vt(r, e, s[e]);
|
|
9
|
+
return r;
|
|
10
|
+
}, bt = (r, s) => At(r, kt(s));
|
|
11
|
+
var Pt = (r, s) => {
|
|
12
|
+
var e = {};
|
|
13
|
+
for (var u in r) gt.call(r, u) && s.indexOf(u) < 0 && (e[u] = r[u]);
|
|
14
|
+
if (r != null && Y) for (var u of Y(r)) s.indexOf(u) < 0 && Et.call(r, u) && (e[u] = r[u]);
|
|
15
|
+
return e;
|
|
16
|
+
};
|
|
17
|
+
function ht(r) {
|
|
18
|
+
let s = setTimeout(r, 0), e = setTimeout(r, 10), u = setTimeout(r, 50);
|
|
19
|
+
return [s, e, u];
|
|
20
|
+
}
|
|
21
|
+
function _t(r) {
|
|
22
|
+
let s = React.useRef();
|
|
23
|
+
return React.useEffect(() => {
|
|
24
|
+
s.current = r;
|
|
25
|
+
}), s.current;
|
|
26
|
+
}
|
|
27
|
+
var Ot = 18, wt = 40, Gt = `${wt}px`, xt = ["[data-lastpass-icon-root]", "com-1password-button", "[data-dashlanecreated]", '[style$="2147483647 !important;"]'].join(",");
|
|
28
|
+
function Tt({ containerRef: r, inputRef: s, pushPasswordManagerStrategy: e, isFocused: u }) {
|
|
29
|
+
let [P, D] = React.useState(false), [G, H] = React.useState(false), [F, W] = React.useState(false), Z = React.useMemo(() => e === "none" ? false : (e === "increase-width" || e === "experimental-no-flickering") && P && G, [P, G, e]), T = React.useCallback(() => {
|
|
30
|
+
let f = r.current, h = s.current;
|
|
31
|
+
if (!f || !h || F || e === "none") return;
|
|
32
|
+
let a = f, B = a.getBoundingClientRect().left + a.offsetWidth, A = a.getBoundingClientRect().top + a.offsetHeight / 2, z = B - Ot, q = A;
|
|
33
|
+
document.querySelectorAll(xt).length === 0 && document.elementFromPoint(z, q) === f || (D(true), W(true));
|
|
34
|
+
}, [r, s, F, e]);
|
|
35
|
+
return React.useEffect(() => {
|
|
36
|
+
let f = r.current;
|
|
37
|
+
if (!f || e === "none") return;
|
|
38
|
+
function h() {
|
|
39
|
+
let A = window.innerWidth - f.getBoundingClientRect().right;
|
|
40
|
+
H(A >= wt);
|
|
41
|
+
}
|
|
42
|
+
h();
|
|
43
|
+
let a = setInterval(h, 1e3);
|
|
44
|
+
return () => {
|
|
45
|
+
clearInterval(a);
|
|
46
|
+
};
|
|
47
|
+
}, [r, e]), React.useEffect(() => {
|
|
48
|
+
let f = u || document.activeElement === s.current;
|
|
49
|
+
if (e === "none" || !f) return;
|
|
50
|
+
let h = setTimeout(T, 0), a = setTimeout(T, 2e3), B = setTimeout(T, 5e3), A = setTimeout(() => {
|
|
51
|
+
W(true);
|
|
52
|
+
}, 6e3);
|
|
53
|
+
return () => {
|
|
54
|
+
clearTimeout(h), clearTimeout(a), clearTimeout(B), clearTimeout(A);
|
|
55
|
+
};
|
|
56
|
+
}, [s, u, e, T]), { hasPWMBadge: P, willPushPWMBadge: Z, PWM_BADGE_SPACE_WIDTH: Gt };
|
|
57
|
+
}
|
|
58
|
+
var jt = React.createContext({}), Lt = React.forwardRef((A, B) => {
|
|
59
|
+
var z = A, { value: r, onChange: s, maxLength: e, textAlign: u = "left", pattern: P, placeholder: D, inputMode: G = "numeric", onComplete: H, pushPasswordManagerStrategy: F = "increase-width", pasteTransformer: W, containerClassName: Z, noScriptCSSFallback: T = Nt, render: f, children: h } = z, a = Pt(z, ["value", "onChange", "maxLength", "textAlign", "pattern", "placeholder", "inputMode", "onComplete", "pushPasswordManagerStrategy", "pasteTransformer", "containerClassName", "noScriptCSSFallback", "render", "children"]);
|
|
60
|
+
var X, lt, ut, dt, ft;
|
|
61
|
+
let [q, nt] = React.useState(typeof a.defaultValue == "string" ? a.defaultValue : ""), i = r != null ? r : q, I = _t(i), x = React.useCallback((t) => {
|
|
62
|
+
s == null || s(t), nt(t);
|
|
63
|
+
}, [s]), m = React.useMemo(() => P ? typeof P == "string" ? new RegExp(P) : P : null, [P]), l = React.useRef(null), K = React.useRef(null), J = React.useRef({ value: i, onChange: x, isIOS: typeof window != "undefined" && ((lt = (X = window == null ? void 0 : window.CSS) == null ? void 0 : X.supports) == null ? void 0 : lt.call(X, "-webkit-touch-callout", "none")) }), V = React.useRef({ prev: [(ut = l.current) == null ? void 0 : ut.selectionStart, (dt = l.current) == null ? void 0 : dt.selectionEnd, (ft = l.current) == null ? void 0 : ft.selectionDirection] });
|
|
64
|
+
React.useImperativeHandle(B, () => l.current, []), React.useEffect(() => {
|
|
65
|
+
let t = l.current, o = K.current;
|
|
66
|
+
if (!t || !o) return;
|
|
67
|
+
J.current.value !== t.value && J.current.onChange(t.value), V.current.prev = [t.selectionStart, t.selectionEnd, t.selectionDirection];
|
|
68
|
+
function d() {
|
|
69
|
+
if (document.activeElement !== t) {
|
|
70
|
+
L(null), N(null);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
let c = t.selectionStart, b = t.selectionEnd, mt = t.selectionDirection, v = t.maxLength, C = t.value, _ = V.current.prev, g = -1, E = -1, w;
|
|
74
|
+
if (C.length !== 0 && c !== null && b !== null) {
|
|
75
|
+
let Dt = c === b, Ht = c === C.length && C.length < v;
|
|
76
|
+
if (Dt && !Ht) {
|
|
77
|
+
let y = c;
|
|
78
|
+
if (y === 0) g = 0, E = 1, w = "forward";
|
|
79
|
+
else if (y === v) g = y - 1, E = y, w = "backward";
|
|
80
|
+
else if (v > 1 && C.length > 1) {
|
|
81
|
+
let et = 0;
|
|
82
|
+
if (_[0] !== null && _[1] !== null) {
|
|
83
|
+
w = y < _[1] ? "backward" : "forward";
|
|
84
|
+
let Wt = _[0] === _[1] && _[0] < v;
|
|
85
|
+
w === "backward" && !Wt && (et = -1);
|
|
86
|
+
}
|
|
87
|
+
g = et + y, E = et + y + 1;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
g !== -1 && E !== -1 && g !== E && l.current.setSelectionRange(g, E, w);
|
|
91
|
+
}
|
|
92
|
+
let pt = g !== -1 ? g : c, Rt = E !== -1 ? E : b, yt = w != null ? w : mt;
|
|
93
|
+
L(pt), N(Rt), V.current.prev = [pt, Rt, yt];
|
|
94
|
+
}
|
|
95
|
+
if (document.addEventListener("selectionchange", d, { capture: true }), d(), document.activeElement === t && Q(true), !document.getElementById("input-otp-style")) {
|
|
96
|
+
let c = document.createElement("style");
|
|
97
|
+
if (c.id = "input-otp-style", document.head.appendChild(c), c.sheet) {
|
|
98
|
+
let b = "background: transparent !important; color: transparent !important; border-color: transparent !important; opacity: 0 !important; box-shadow: none !important; -webkit-box-shadow: none !important; -webkit-text-fill-color: transparent !important;";
|
|
99
|
+
$(c.sheet, "[data-input-otp]::selection { background: transparent !important; color: transparent !important; }"), $(c.sheet, `[data-input-otp]:autofill { ${b} }`), $(c.sheet, `[data-input-otp]:-webkit-autofill { ${b} }`), $(c.sheet, "@supports (-webkit-touch-callout: none) { [data-input-otp] { letter-spacing: -.6em !important; font-weight: 100 !important; font-stretch: ultra-condensed; font-optical-sizing: none !important; left: -1px !important; right: 1px !important; } }"), $(c.sheet, "[data-input-otp] + * { pointer-events: all !important; }");
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
let R = () => {
|
|
103
|
+
o && o.style.setProperty("--root-height", `${t.clientHeight}px`);
|
|
104
|
+
};
|
|
105
|
+
R();
|
|
106
|
+
let p = new ResizeObserver(R);
|
|
107
|
+
return p.observe(t), () => {
|
|
108
|
+
document.removeEventListener("selectionchange", d, { capture: true }), p.disconnect();
|
|
109
|
+
};
|
|
110
|
+
}, []);
|
|
111
|
+
let [ot, rt] = React.useState(false), [j, Q] = React.useState(false), [M, L] = React.useState(null), [k, N] = React.useState(null);
|
|
112
|
+
React.useEffect(() => {
|
|
113
|
+
ht(() => {
|
|
114
|
+
var R, p, c, b;
|
|
115
|
+
(R = l.current) == null || R.dispatchEvent(new Event("input"));
|
|
116
|
+
let t = (p = l.current) == null ? void 0 : p.selectionStart, o = (c = l.current) == null ? void 0 : c.selectionEnd, d = (b = l.current) == null ? void 0 : b.selectionDirection;
|
|
117
|
+
t !== null && o !== null && (L(t), N(o), V.current.prev = [t, o, d]);
|
|
118
|
+
});
|
|
119
|
+
}, [i, j]), React.useEffect(() => {
|
|
120
|
+
I !== void 0 && i !== I && I.length < e && i.length === e && (H == null || H(i));
|
|
121
|
+
}, [e, H, I, i]);
|
|
122
|
+
let O = Tt({ containerRef: K, inputRef: l, pushPasswordManagerStrategy: F, isFocused: j }), st = React.useCallback((t) => {
|
|
123
|
+
let o = t.currentTarget.value.slice(0, e);
|
|
124
|
+
if (o.length > 0 && m && !m.test(o)) {
|
|
125
|
+
t.preventDefault();
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
typeof I == "string" && o.length < I.length && document.dispatchEvent(new Event("selectionchange")), x(o);
|
|
129
|
+
}, [e, x, I, m]), at = React.useCallback(() => {
|
|
130
|
+
var t;
|
|
131
|
+
if (l.current) {
|
|
132
|
+
let o = Math.min(l.current.value.length, e - 1), d = l.current.value.length;
|
|
133
|
+
(t = l.current) == null || t.setSelectionRange(o, d), L(o), N(d);
|
|
134
|
+
}
|
|
135
|
+
Q(true);
|
|
136
|
+
}, [e]), ct = React.useCallback((t) => {
|
|
137
|
+
var g, E;
|
|
138
|
+
let o = l.current;
|
|
139
|
+
if (!W && (!J.current.isIOS || !t.clipboardData || !o)) return;
|
|
140
|
+
let d = t.clipboardData.getData("text/plain"), R = W ? W(d) : d;
|
|
141
|
+
t.preventDefault();
|
|
142
|
+
let p = (g = l.current) == null ? void 0 : g.selectionStart, c = (E = l.current) == null ? void 0 : E.selectionEnd, v = (p !== c ? i.slice(0, p) + R + i.slice(c) : i.slice(0, p) + R + i.slice(p)).slice(0, e);
|
|
143
|
+
if (v.length > 0 && m && !m.test(v)) return;
|
|
144
|
+
o.value = v, x(v);
|
|
145
|
+
let C = Math.min(v.length, e - 1), _ = v.length;
|
|
146
|
+
o.setSelectionRange(C, _), L(C), N(_);
|
|
147
|
+
}, [e, x, m, i]), It = React.useMemo(() => ({ position: "relative", cursor: a.disabled ? "default" : "text", userSelect: "none", WebkitUserSelect: "none", pointerEvents: "none" }), [a.disabled]), it = React.useMemo(() => ({ position: "absolute", inset: 0, width: O.willPushPWMBadge ? `calc(100% + ${O.PWM_BADGE_SPACE_WIDTH})` : "100%", clipPath: O.willPushPWMBadge ? `inset(0 ${O.PWM_BADGE_SPACE_WIDTH} 0 0)` : void 0, height: "100%", display: "flex", textAlign: u, opacity: "1", color: "transparent", pointerEvents: "all", background: "transparent", caretColor: "transparent", border: "0 solid transparent", outline: "0 solid transparent", boxShadow: "none", lineHeight: "1", letterSpacing: "-.5em", fontSize: "var(--root-height)", fontFamily: "monospace", fontVariantNumeric: "tabular-nums" }), [O.PWM_BADGE_SPACE_WIDTH, O.willPushPWMBadge, u]), Mt = React.useMemo(() => React.createElement("input", bt(St({ autoComplete: a.autoComplete || "one-time-code" }, a), { "data-input-otp": true, "data-input-otp-placeholder-shown": i.length === 0 || void 0, "data-input-otp-mss": M, "data-input-otp-mse": k, inputMode: G, pattern: m == null ? void 0 : m.source, "aria-placeholder": D, style: it, maxLength: e, value: i, ref: l, onPaste: (t) => {
|
|
148
|
+
var o;
|
|
149
|
+
ct(t), (o = a.onPaste) == null || o.call(a, t);
|
|
150
|
+
}, onChange: st, onMouseOver: (t) => {
|
|
151
|
+
var o;
|
|
152
|
+
rt(true), (o = a.onMouseOver) == null || o.call(a, t);
|
|
153
|
+
}, onMouseLeave: (t) => {
|
|
154
|
+
var o;
|
|
155
|
+
rt(false), (o = a.onMouseLeave) == null || o.call(a, t);
|
|
156
|
+
}, onFocus: (t) => {
|
|
157
|
+
var o;
|
|
158
|
+
at(), (o = a.onFocus) == null || o.call(a, t);
|
|
159
|
+
}, onBlur: (t) => {
|
|
160
|
+
var o;
|
|
161
|
+
Q(false), (o = a.onBlur) == null || o.call(a, t);
|
|
162
|
+
} })), [st, at, ct, G, it, e, k, M, a, m == null ? void 0 : m.source, i]), tt = React.useMemo(() => ({ slots: Array.from({ length: e }).map((t, o) => {
|
|
163
|
+
var c;
|
|
164
|
+
let d = j && M !== null && k !== null && (M === k && o === M || o >= M && o < k), R = i[o] !== void 0 ? i[o] : null, p = i[0] !== void 0 ? null : (c = D == null ? void 0 : D[o]) != null ? c : null;
|
|
165
|
+
return { char: R, placeholderChar: p, isActive: d, hasFakeCaret: d && R === null };
|
|
166
|
+
}), isFocused: j, isHovering: !a.disabled && ot }), [j, ot, e, k, M, a.disabled, i]), Ct = React.useMemo(() => f ? f(tt) : React.createElement(jt.Provider, { value: tt }, h), [h, tt, f]);
|
|
167
|
+
return React.createElement(React.Fragment, null, T !== null && React.createElement("noscript", null, React.createElement("style", null, T)), React.createElement("div", { ref: K, "data-input-otp-container": true, style: It, className: Z }, Ct, React.createElement("div", { style: { position: "absolute", inset: 0, pointerEvents: "none" } }, Mt)));
|
|
168
|
+
});
|
|
169
|
+
Lt.displayName = "Input";
|
|
170
|
+
function $(r, s) {
|
|
171
|
+
try {
|
|
172
|
+
r.insertRule(s);
|
|
173
|
+
} catch (e) {
|
|
174
|
+
console.error("input-otp could not insert CSS rule:", s);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
var Nt = `
|
|
178
|
+
[data-input-otp] {
|
|
179
|
+
--nojs-bg: white !important;
|
|
180
|
+
--nojs-fg: black !important;
|
|
181
|
+
|
|
182
|
+
background-color: var(--nojs-bg) !important;
|
|
183
|
+
color: var(--nojs-fg) !important;
|
|
184
|
+
caret-color: var(--nojs-fg) !important;
|
|
185
|
+
letter-spacing: .25em !important;
|
|
186
|
+
text-align: center !important;
|
|
187
|
+
border: 1px solid var(--nojs-fg) !important;
|
|
188
|
+
border-radius: 4px !important;
|
|
189
|
+
width: 100% !important;
|
|
190
|
+
}
|
|
191
|
+
@media (prefers-color-scheme: dark) {
|
|
192
|
+
[data-input-otp] {
|
|
193
|
+
--nojs-bg: black !important;
|
|
194
|
+
--nojs-fg: white !important;
|
|
195
|
+
}
|
|
196
|
+
}`;
|
|
197
|
+
export {
|
|
198
|
+
Lt as OTPInput,
|
|
199
|
+
jt as OTPInputContext
|
|
200
|
+
};
|
package/package.json
CHANGED