@choice-ui/react 1.5.3 → 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.
Files changed (77) hide show
  1. package/dist/components/calendar/dist/index.js +2 -2
  2. package/dist/components/calendar/src/time-calendar/time-calendar.js +2 -2
  3. package/dist/components/code-block/dist/index.js +13 -13
  4. package/dist/components/code-block/src/code-block.js +11 -11
  5. package/dist/components/code-block/src/hooks/use-line-count.js +3 -3
  6. package/dist/components/combobox/dist/index.d.ts +2 -1
  7. package/dist/components/combobox/dist/index.js +7 -6
  8. package/dist/components/combobox/src/combobox.d.ts +2 -1
  9. package/dist/components/combobox/src/combobox.js +7 -6
  10. package/dist/components/command/src/components/command-group.js +2 -2
  11. package/dist/components/command/src/components/command-item.js +3 -3
  12. package/dist/components/command/src/hooks/index.js +2 -2
  13. package/dist/components/command/src/hooks/use-command-state.js +3 -3
  14. package/dist/components/command/src/hooks/use-command.js +2 -2
  15. package/dist/components/command/src/utils/helpers.js +4 -4
  16. package/dist/components/comments/src/comment-item/comment-item.js +2 -2
  17. package/dist/components/comments/src/comment-item/components/comment-item-reactions.js +2 -2
  18. package/dist/components/conditions/src/hooks/use-drag-and-drop.js +3 -3
  19. package/dist/components/context-input/src/components/copy-button.js +2 -2
  20. package/dist/components/context-input/src/components/mention.js +2 -2
  21. package/dist/components/context-input/src/components/slate-editor.js +3 -3
  22. package/dist/components/context-input/src/context-input.js +5 -5
  23. package/dist/components/context-menu/dist/index.d.ts +2 -1
  24. package/dist/components/context-menu/src/context-menu.d.ts +2 -1
  25. package/dist/components/context-menu/src/context-menu.js +14 -13
  26. package/dist/components/dialog/dist/index.js +2 -2
  27. package/dist/components/dialog/src/dialog.js +2 -2
  28. package/dist/components/dropdown/dist/index.d.ts +2 -1
  29. package/dist/components/dropdown/dist/index.js +8 -7
  30. package/dist/components/dropdown/src/dropdown.d.ts +2 -1
  31. package/dist/components/dropdown/src/dropdown.js +8 -7
  32. package/dist/components/index.d.ts +1 -0
  33. package/dist/components/md-input/src/components/toolbar/toolbar.js +2 -2
  34. package/dist/components/md-input/src/md-input.js +3 -3
  35. package/dist/components/menus/dist/index.d.ts +6 -1
  36. package/dist/components/menus/dist/index.js +26 -2
  37. package/dist/components/menus/src/components/index.d.ts +1 -0
  38. package/dist/components/menus/src/components/menu-empty.d.ts +4 -0
  39. package/dist/components/menus/src/components/menu-empty.js +20 -0
  40. package/dist/components/menus/src/index.d.ts +1 -1
  41. package/dist/components/menus/src/menus.js +2 -2
  42. package/dist/components/menus/src/tv.d.ts +25 -0
  43. package/dist/components/menus/src/tv.js +11 -0
  44. package/dist/components/multi-select/dist/index.d.ts +2 -1
  45. package/dist/components/multi-select/dist/index.js +15 -8
  46. package/dist/components/multi-select/src/multi-select.d.ts +2 -1
  47. package/dist/components/multi-select/src/multi-select.js +8 -4
  48. package/dist/components/multi-select/src/utils/extract-options.d.ts +16 -2
  49. package/dist/components/multi-select/src/utils/extract-options.js +8 -5
  50. package/dist/components/otp-input/dist/index.d.ts +30 -0
  51. package/dist/components/otp-input/src/index.d.ts +2 -0
  52. package/dist/components/otp-input/src/otp-input.d.ts +27 -0
  53. package/dist/components/otp-input/src/otp-input.js +115 -0
  54. package/dist/components/otp-input/src/otp-input.module.css +15 -0
  55. package/dist/components/otp-input/src/otp-input.module.css.js +8 -0
  56. package/dist/components/otp-input/src/tv.d.ts +121 -0
  57. package/dist/components/otp-input/src/tv.js +150 -0
  58. package/dist/components/otp-input/tsup.config.d.ts +2 -0
  59. package/dist/components/panel/src/components/panel-sortable.js +3 -3
  60. package/dist/components/rich-input/src/hooks/use-editor-config.js +3 -3
  61. package/dist/components/rich-input/src/utils/custom-options.js +15 -15
  62. package/dist/components/select/dist/index.d.ts +2 -1
  63. package/dist/components/select/dist/index.js +15 -8
  64. package/dist/components/select/src/select.d.ts +2 -1
  65. package/dist/components/select/src/select.js +15 -8
  66. package/dist/components/slot/dist/index.d.ts +10 -10
  67. package/dist/components/slot/dist/index.js +7 -15
  68. package/dist/components/slot/src/slot.d.ts +12 -12
  69. package/dist/components/slot/src/slot.js +10 -18
  70. package/dist/components/textarea/dist/index.js +14 -14
  71. package/dist/components/textarea/src/components/autosize/hooks.js +5 -5
  72. package/dist/components/textarea/src/components/autosize/index.js +10 -10
  73. package/dist/components/tree-list/src/tree-list.js +3 -3
  74. package/dist/components/virtualized-grid/src/error-boundary.js +2 -2
  75. package/dist/index.js +4 -0
  76. 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
  77. package/package.json +1 -1
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@choice-ui/react",
3
- "version": "1.5.3",
3
+ "version": "1.5.5",
4
4
  "description": "A desktop-first React UI component library built for professional desktop applications with comprehensive documentation",
5
5
  "sideEffects": false,
6
6
  "type": "module",