@telegraph/combobox 0.0.4 → 0.0.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/CHANGELOG.md +16 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.mjs +124 -122
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/Combobox/Combobox.d.ts +1 -1
- package/dist/types/Combobox/Combobox.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/esm/index.mjs
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { jsx as u, jsxs as
|
|
2
|
-
import { useControllableState as
|
|
3
|
-
import * as
|
|
1
|
+
import { jsx as u, jsxs as S, Fragment as W } from "react/jsx-runtime";
|
|
2
|
+
import { useControllableState as ge } from "@radix-ui/react-use-controllable-state";
|
|
3
|
+
import * as be from "@radix-ui/react-visually-hidden";
|
|
4
4
|
import { Icon as K, Lucide as j } from "@telegraph/icon";
|
|
5
|
-
import * as
|
|
5
|
+
import * as he from "react";
|
|
6
6
|
import p from "react";
|
|
7
7
|
import { Text as P } from "@telegraph/typography";
|
|
8
8
|
import { useComposedRefs as B } from "@telegraph/compose-refs";
|
|
9
|
-
import { RefToTgphRef as
|
|
9
|
+
import { RefToTgphRef as ye } from "@telegraph/helpers";
|
|
10
10
|
import { Input as fe } from "@telegraph/input";
|
|
11
11
|
import { Menu as N } from "@telegraph/menu";
|
|
12
12
|
import { Tag as z } from "@telegraph/tag";
|
|
13
13
|
import { motion as E, AnimatePresence as F } from "framer-motion";
|
|
14
|
-
function
|
|
14
|
+
function re(o) {
|
|
15
15
|
var t, e, a = "";
|
|
16
16
|
if (typeof o == "string" || typeof o == "number") a += o;
|
|
17
17
|
else if (typeof o == "object") if (Array.isArray(o)) {
|
|
18
18
|
var i = o.length;
|
|
19
|
-
for (t = 0; t < i; t++) o[t] && (e =
|
|
19
|
+
for (t = 0; t < i; t++) o[t] && (e = re(o[t])) && (a && (a += " "), a += e);
|
|
20
20
|
} else for (e in o) o[e] && (a && (a += " "), a += e);
|
|
21
21
|
return a;
|
|
22
22
|
}
|
|
23
23
|
function $() {
|
|
24
|
-
for (var o, t, e = 0, a = "", i = arguments.length; e < i; e++) (o = arguments[e]) && (t =
|
|
24
|
+
for (var o, t, e = 0, a = "", i = arguments.length; e < i; e++) (o = arguments[e]) && (t = re(o)) && (a && (a += " "), a += t);
|
|
25
25
|
return a;
|
|
26
26
|
}
|
|
27
27
|
function me(o, t) {
|
|
@@ -30,8 +30,8 @@ function me(o, t) {
|
|
|
30
30
|
function ve(...o) {
|
|
31
31
|
return (t) => o.forEach((e) => me(e, t));
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
return
|
|
33
|
+
function oe(...o) {
|
|
34
|
+
return he.useCallback(ve(...o), o);
|
|
35
35
|
}
|
|
36
36
|
const O = ["sm", "md", "lg", "xl", "2xl"], we = (o) => {
|
|
37
37
|
const t = [];
|
|
@@ -71,7 +71,7 @@ const O = ["sm", "md", "lg", "xl", "2xl"], we = (o) => {
|
|
|
71
71
|
right: 1,
|
|
72
72
|
bottom: 2,
|
|
73
73
|
left: 3
|
|
74
|
-
},
|
|
74
|
+
}, k = {
|
|
75
75
|
topLeft: 0,
|
|
76
76
|
topRight: 1,
|
|
77
77
|
bottomRight: 2,
|
|
@@ -88,31 +88,31 @@ const O = ["sm", "md", "lg", "xl", "2xl"], we = (o) => {
|
|
|
88
88
|
(r == null ? void 0 : r[2]) || 0,
|
|
89
89
|
(r == null ? void 0 : r[3]) || 0
|
|
90
90
|
];
|
|
91
|
-
return a === "all" ? f({ value: t, prop: e }) : (e.ordering === "clockwise" ? (a === "top" && (n[
|
|
91
|
+
return a === "all" ? f({ value: t, prop: e }) : (e.ordering === "clockwise" ? (a === "top" && (n[k.topLeft] = f({
|
|
92
92
|
value: t,
|
|
93
93
|
prop: e
|
|
94
|
-
}), n[
|
|
94
|
+
}), n[k.topRight] = f({
|
|
95
95
|
value: t,
|
|
96
96
|
prop: e
|
|
97
|
-
})), a === "right" && (n[
|
|
97
|
+
})), a === "right" && (n[k.topRight] = f({
|
|
98
98
|
value: t,
|
|
99
99
|
prop: e
|
|
100
|
-
}), n[
|
|
100
|
+
}), n[k.bottomRight] = f({
|
|
101
101
|
value: t,
|
|
102
102
|
prop: e
|
|
103
|
-
})), a === "bottom" && (n[
|
|
103
|
+
})), a === "bottom" && (n[k.bottomRight] = f({
|
|
104
104
|
value: t,
|
|
105
105
|
prop: e
|
|
106
|
-
}), n[
|
|
106
|
+
}), n[k.bottomLeft] = f({
|
|
107
107
|
value: t,
|
|
108
108
|
prop: e
|
|
109
|
-
})), a === "left" && (n[
|
|
109
|
+
})), a === "left" && (n[k.bottomLeft] = f({
|
|
110
110
|
value: t,
|
|
111
111
|
prop: e
|
|
112
|
-
}), n[
|
|
112
|
+
}), n[k.topLeft] = f({
|
|
113
113
|
value: t,
|
|
114
114
|
prop: e
|
|
115
|
-
})), (a === "topLeft" || a === "topRight" || a === "bottomRight" || a === "bottomLeft") && (n[
|
|
115
|
+
})), (a === "topLeft" || a === "topRight" || a === "bottomRight" || a === "bottomLeft") && (n[k[a]] = f({
|
|
116
116
|
value: t,
|
|
117
117
|
prop: e
|
|
118
118
|
}))) : (a === "x" && (n[I.left] = f({
|
|
@@ -141,7 +141,7 @@ const O = ["sm", "md", "lg", "xl", "2xl"], we = (o) => {
|
|
|
141
141
|
value: t,
|
|
142
142
|
direction: o.direction,
|
|
143
143
|
type: o.type
|
|
144
|
-
}) : f({ value: t, prop: o }),
|
|
144
|
+
}) : f({ value: t, prop: o }), ae = ({
|
|
145
145
|
props: o,
|
|
146
146
|
ref: t,
|
|
147
147
|
propsMap: e
|
|
@@ -377,7 +377,7 @@ const O = ["sm", "md", "lg", "xl", "2xl"], we = (o) => {
|
|
|
377
377
|
tgphRef: e,
|
|
378
378
|
...a
|
|
379
379
|
}) => {
|
|
380
|
-
const i = o || "div", r = p.useRef(null), n =
|
|
380
|
+
const i = o || "div", r = p.useRef(null), n = oe(e, r), l = p.useMemo(() => {
|
|
381
381
|
const c = { borderColor: !0, ...a };
|
|
382
382
|
return Object.keys(c).reduce(
|
|
383
383
|
(d, s) => (Object.keys(U).some((b) => b === s) ? d.box[s] = c[s] : d.rest[s] = c[s], d),
|
|
@@ -385,7 +385,7 @@ const O = ["sm", "md", "lg", "xl", "2xl"], we = (o) => {
|
|
|
385
385
|
);
|
|
386
386
|
}, [a]);
|
|
387
387
|
return p.useLayoutEffect(() => {
|
|
388
|
-
|
|
388
|
+
ae({
|
|
389
389
|
props: l.box,
|
|
390
390
|
ref: r,
|
|
391
391
|
propsMap: U
|
|
@@ -434,7 +434,7 @@ const O = ["sm", "md", "lg", "xl", "2xl"], we = (o) => {
|
|
|
434
434
|
tgphRef: t,
|
|
435
435
|
...e
|
|
436
436
|
}) => {
|
|
437
|
-
const a = p.useRef(null), i =
|
|
437
|
+
const a = p.useRef(null), i = oe(t, a), r = p.useMemo(
|
|
438
438
|
() => Object.keys(e).reduce(
|
|
439
439
|
(n, l) => (Object.keys(J).some((c) => c === l) ? n.stack[l] = e[l] : n.rest[l] = e[l], n),
|
|
440
440
|
{ stack: {}, rest: {} }
|
|
@@ -442,7 +442,7 @@ const O = ["sm", "md", "lg", "xl", "2xl"], we = (o) => {
|
|
|
442
442
|
[e]
|
|
443
443
|
);
|
|
444
444
|
return p.useLayoutEffect(() => {
|
|
445
|
-
|
|
445
|
+
ae({
|
|
446
446
|
props: r.stack,
|
|
447
447
|
ref: a,
|
|
448
448
|
propsMap: J
|
|
@@ -537,11 +537,11 @@ const O = ["sm", "md", "lg", "xl", "2xl"], we = (o) => {
|
|
|
537
537
|
px: "0"
|
|
538
538
|
}
|
|
539
539
|
}
|
|
540
|
-
},
|
|
540
|
+
}, Te = {
|
|
541
541
|
1: "1",
|
|
542
542
|
2: "2",
|
|
543
543
|
3: "3"
|
|
544
|
-
},
|
|
544
|
+
}, Se = {
|
|
545
545
|
solid: {
|
|
546
546
|
gray: "white",
|
|
547
547
|
red: "white",
|
|
@@ -637,7 +637,7 @@ const O = ["sm", "md", "lg", "xl", "2xl"], we = (o) => {
|
|
|
637
637
|
state: "default",
|
|
638
638
|
layout: "default",
|
|
639
639
|
active: !1
|
|
640
|
-
}),
|
|
640
|
+
}), ne = ({
|
|
641
641
|
as: o,
|
|
642
642
|
variant: t = "solid",
|
|
643
643
|
size: e = "2",
|
|
@@ -649,11 +649,11 @@ const O = ["sm", "md", "lg", "xl", "2xl"], we = (o) => {
|
|
|
649
649
|
...c
|
|
650
650
|
}) => {
|
|
651
651
|
const d = n ? "disabled" : i, s = d === "disabled" ? "disabled" : a, b = p.useMemo(() => {
|
|
652
|
-
var
|
|
652
|
+
var y;
|
|
653
653
|
const g = p.Children.toArray(c == null ? void 0 : c.children);
|
|
654
654
|
if ((g == null ? void 0 : g.length) === 1 && p.isValidElement(g[0])) {
|
|
655
|
-
const
|
|
656
|
-
if ((
|
|
655
|
+
const h = g[0];
|
|
656
|
+
if ((y = h == null ? void 0 : h.props) != null && y.icon)
|
|
657
657
|
return "icon-only";
|
|
658
658
|
}
|
|
659
659
|
return "default";
|
|
@@ -715,7 +715,7 @@ const O = ["sm", "md", "lg", "xl", "2xl"], we = (o) => {
|
|
|
715
715
|
...n
|
|
716
716
|
}
|
|
717
717
|
);
|
|
718
|
-
},
|
|
718
|
+
}, ie = ({
|
|
719
719
|
as: o,
|
|
720
720
|
color: t,
|
|
721
721
|
size: e,
|
|
@@ -728,8 +728,8 @@ const O = ["sm", "md", "lg", "xl", "2xl"], we = (o) => {
|
|
|
728
728
|
P,
|
|
729
729
|
{
|
|
730
730
|
as: o || "span",
|
|
731
|
-
color: t ??
|
|
732
|
-
size: e ??
|
|
731
|
+
color: t ?? Se[n.variant][n.color],
|
|
732
|
+
size: e ?? Te[n.size],
|
|
733
733
|
weight: a,
|
|
734
734
|
className: $("no-underline whitespace-nowrap", i),
|
|
735
735
|
internal_optionalAs: !0,
|
|
@@ -737,7 +737,7 @@ const O = ["sm", "md", "lg", "xl", "2xl"], we = (o) => {
|
|
|
737
737
|
...r
|
|
738
738
|
}
|
|
739
739
|
);
|
|
740
|
-
},
|
|
740
|
+
}, le = ({
|
|
741
741
|
leadingIcon: o,
|
|
742
742
|
trailingIcon: t,
|
|
743
743
|
icon: e,
|
|
@@ -745,18 +745,18 @@ const O = ["sm", "md", "lg", "xl", "2xl"], we = (o) => {
|
|
|
745
745
|
...i
|
|
746
746
|
}) => {
|
|
747
747
|
const r = o || e;
|
|
748
|
-
return /* @__PURE__ */
|
|
748
|
+
return /* @__PURE__ */ S(ne, { ...i, children: [
|
|
749
749
|
r && /* @__PURE__ */ u(H, { ...r }),
|
|
750
|
-
a && /* @__PURE__ */ u(
|
|
750
|
+
a && /* @__PURE__ */ u(ie, { children: a }),
|
|
751
751
|
t && /* @__PURE__ */ u(H, { ...t })
|
|
752
752
|
] });
|
|
753
753
|
};
|
|
754
|
-
Object.assign(
|
|
755
|
-
Root:
|
|
754
|
+
Object.assign(le, {
|
|
755
|
+
Root: ne,
|
|
756
756
|
Icon: H,
|
|
757
|
-
Text:
|
|
757
|
+
Text: ie
|
|
758
758
|
});
|
|
759
|
-
const D =
|
|
759
|
+
const D = le, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
760
760
|
const t = [];
|
|
761
761
|
let e = null;
|
|
762
762
|
for (let a = 0; a < _.length; a++) {
|
|
@@ -794,7 +794,7 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
794
794
|
right: 1,
|
|
795
795
|
bottom: 2,
|
|
796
796
|
left: 3
|
|
797
|
-
},
|
|
797
|
+
}, C = {
|
|
798
798
|
topLeft: 0,
|
|
799
799
|
topRight: 1,
|
|
800
800
|
bottomRight: 2,
|
|
@@ -811,31 +811,31 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
811
811
|
(r == null ? void 0 : r[2]) || 0,
|
|
812
812
|
(r == null ? void 0 : r[3]) || 0
|
|
813
813
|
];
|
|
814
|
-
return a === "all" ? m({ value: t, prop: e }) : (e.ordering === "clockwise" ? (a === "top" && (n[
|
|
814
|
+
return a === "all" ? m({ value: t, prop: e }) : (e.ordering === "clockwise" ? (a === "top" && (n[C.topLeft] = m({
|
|
815
815
|
value: t,
|
|
816
816
|
prop: e
|
|
817
|
-
}), n[
|
|
817
|
+
}), n[C.topRight] = m({
|
|
818
818
|
value: t,
|
|
819
819
|
prop: e
|
|
820
|
-
})), a === "right" && (n[
|
|
820
|
+
})), a === "right" && (n[C.topRight] = m({
|
|
821
821
|
value: t,
|
|
822
822
|
prop: e
|
|
823
|
-
}), n[
|
|
823
|
+
}), n[C.bottomRight] = m({
|
|
824
824
|
value: t,
|
|
825
825
|
prop: e
|
|
826
|
-
})), a === "bottom" && (n[
|
|
826
|
+
})), a === "bottom" && (n[C.bottomRight] = m({
|
|
827
827
|
value: t,
|
|
828
828
|
prop: e
|
|
829
|
-
}), n[
|
|
829
|
+
}), n[C.bottomLeft] = m({
|
|
830
830
|
value: t,
|
|
831
831
|
prop: e
|
|
832
|
-
})), a === "left" && (n[
|
|
832
|
+
})), a === "left" && (n[C.bottomLeft] = m({
|
|
833
833
|
value: t,
|
|
834
834
|
prop: e
|
|
835
|
-
}), n[
|
|
835
|
+
}), n[C.topLeft] = m({
|
|
836
836
|
value: t,
|
|
837
837
|
prop: e
|
|
838
|
-
})), (a === "topLeft" || a === "topRight" || a === "bottomRight" || a === "bottomLeft") && (n[
|
|
838
|
+
})), (a === "topLeft" || a === "topRight" || a === "bottomRight" || a === "bottomLeft") && (n[C[a]] = m({
|
|
839
839
|
value: t,
|
|
840
840
|
prop: e
|
|
841
841
|
}))) : (a === "x" && (n[A.left] = m({
|
|
@@ -864,7 +864,7 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
864
864
|
value: t,
|
|
865
865
|
direction: o.direction,
|
|
866
866
|
type: o.type
|
|
867
|
-
}) : m({ value: t, prop: o }),
|
|
867
|
+
}) : m({ value: t, prop: o }), ce = ({
|
|
868
868
|
props: o,
|
|
869
869
|
ref: t,
|
|
870
870
|
propsMap: e
|
|
@@ -1108,7 +1108,7 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
1108
1108
|
);
|
|
1109
1109
|
}, [a]);
|
|
1110
1110
|
return p.useLayoutEffect(() => {
|
|
1111
|
-
|
|
1111
|
+
ce({
|
|
1112
1112
|
props: l.box,
|
|
1113
1113
|
ref: r,
|
|
1114
1114
|
propsMap: ee
|
|
@@ -1152,7 +1152,7 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
1152
1152
|
type: "spacing",
|
|
1153
1153
|
valueType: "variable"
|
|
1154
1154
|
}
|
|
1155
|
-
},
|
|
1155
|
+
}, T = ({
|
|
1156
1156
|
className: o,
|
|
1157
1157
|
tgphRef: t,
|
|
1158
1158
|
...e
|
|
@@ -1165,7 +1165,7 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
1165
1165
|
[e]
|
|
1166
1166
|
);
|
|
1167
1167
|
return p.useLayoutEffect(() => {
|
|
1168
|
-
|
|
1168
|
+
ce({
|
|
1169
1169
|
props: r.stack,
|
|
1170
1170
|
ref: a,
|
|
1171
1171
|
propsMap: te
|
|
@@ -1178,7 +1178,7 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
1178
1178
|
...r.rest
|
|
1179
1179
|
}
|
|
1180
1180
|
);
|
|
1181
|
-
}, Q = (o) => Array.isArray(o), q = (o) => typeof o == "object" && !Array.isArray(o), Ve = ["ArrowDown", "PageUp", "Home"], Ae = ["ArrowUp", "PageDown", "End"],
|
|
1181
|
+
}, Q = (o) => Array.isArray(o), q = (o) => typeof o == "object" && !Array.isArray(o), Ve = ["ArrowDown", "PageUp", "Home"], Ae = ["ArrowUp", "PageDown", "End"], pe = ["Enter", " "], x = p.createContext({
|
|
1182
1182
|
onValueChange: () => {
|
|
1183
1183
|
},
|
|
1184
1184
|
contentId: "",
|
|
@@ -1201,32 +1201,32 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
1201
1201
|
layout: d,
|
|
1202
1202
|
...s
|
|
1203
1203
|
}) => {
|
|
1204
|
-
const b = p.useId(),
|
|
1204
|
+
const b = p.useId(), y = p.useId(), g = p.useRef(null), h = p.useRef(null), v = p.useRef(null), [w, L] = p.useState(""), [R = !1, M] = ge({
|
|
1205
1205
|
prop: e,
|
|
1206
1206
|
defaultProp: i,
|
|
1207
1207
|
onChange: a
|
|
1208
|
-
}),
|
|
1209
|
-
M((
|
|
1208
|
+
}), se = p.useCallback(() => {
|
|
1209
|
+
M((de) => !de);
|
|
1210
1210
|
}, [M]);
|
|
1211
1211
|
return p.useEffect(() => {
|
|
1212
|
-
|
|
1213
|
-
}, [
|
|
1214
|
-
|
|
1212
|
+
R || L("");
|
|
1213
|
+
}, [R]), /* @__PURE__ */ u(
|
|
1214
|
+
x.Provider,
|
|
1215
1215
|
{
|
|
1216
1216
|
value: {
|
|
1217
1217
|
contentId: b,
|
|
1218
|
-
triggerId:
|
|
1218
|
+
triggerId: y,
|
|
1219
1219
|
value: r,
|
|
1220
1220
|
onValueChange: n,
|
|
1221
1221
|
placeholder: c,
|
|
1222
|
-
open:
|
|
1222
|
+
open: R,
|
|
1223
1223
|
setOpen: M,
|
|
1224
|
-
onOpenToggle:
|
|
1224
|
+
onOpenToggle: se,
|
|
1225
1225
|
closeOnSelect: t,
|
|
1226
|
-
searchQuery:
|
|
1227
|
-
setSearchQuery:
|
|
1226
|
+
searchQuery: w,
|
|
1227
|
+
setSearchQuery: L,
|
|
1228
1228
|
triggerRef: g,
|
|
1229
|
-
searchRef:
|
|
1229
|
+
searchRef: h,
|
|
1230
1230
|
contentRef: v,
|
|
1231
1231
|
errored: l,
|
|
1232
1232
|
layout: d
|
|
@@ -1234,7 +1234,7 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
1234
1234
|
children: /* @__PURE__ */ u(
|
|
1235
1235
|
N.Root,
|
|
1236
1236
|
{
|
|
1237
|
-
open:
|
|
1237
|
+
open: R,
|
|
1238
1238
|
onOpenChange: M,
|
|
1239
1239
|
modal: o,
|
|
1240
1240
|
...s
|
|
@@ -1243,8 +1243,8 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
1243
1243
|
}
|
|
1244
1244
|
);
|
|
1245
1245
|
}, De = ({ label: o, value: t, ...e }) => {
|
|
1246
|
-
const a = p.useContext(
|
|
1247
|
-
return /* @__PURE__ */
|
|
1246
|
+
const a = p.useContext(x);
|
|
1247
|
+
return /* @__PURE__ */ S(
|
|
1248
1248
|
z.Root,
|
|
1249
1249
|
{
|
|
1250
1250
|
size: "1",
|
|
@@ -1283,11 +1283,11 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
1283
1283
|
size: o = "1"
|
|
1284
1284
|
}) => {
|
|
1285
1285
|
var a, i;
|
|
1286
|
-
const t = p.useContext(
|
|
1286
|
+
const t = p.useContext(x), e = o === "1" ? "6" : o === "2" ? "8" : "10";
|
|
1287
1287
|
if (t.value && Q(t.value)) {
|
|
1288
1288
|
const r = t.value, n = t.layout || "truncate", l = r.length - 2, c = l.toString().split("");
|
|
1289
|
-
return r.length === 0 ? /* @__PURE__ */ u(
|
|
1290
|
-
|
|
1289
|
+
return r.length === 0 ? /* @__PURE__ */ u(T, { h: e, align: "center", my: "1", children: /* @__PURE__ */ u(D.Text, { color: "gray", children: t.placeholder }) }) : /* @__PURE__ */ S(
|
|
1290
|
+
T,
|
|
1291
1291
|
{
|
|
1292
1292
|
gap: "1",
|
|
1293
1293
|
w: "full",
|
|
@@ -1301,10 +1301,10 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
1301
1301
|
children: [
|
|
1302
1302
|
/* @__PURE__ */ u(F, { initial: !1, mode: "popLayout", children: r.map((d, s) => {
|
|
1303
1303
|
if (n === "truncate" && s <= 1 || n === "wrap")
|
|
1304
|
-
return /* @__PURE__ */ u(
|
|
1304
|
+
return /* @__PURE__ */ u(ye, { children: /* @__PURE__ */ u(De, { ...d }) }, d.value);
|
|
1305
1305
|
}) }),
|
|
1306
1306
|
/* @__PURE__ */ u(F, { children: n === "truncate" && r.length > 2 && /* @__PURE__ */ u(
|
|
1307
|
-
|
|
1307
|
+
T,
|
|
1308
1308
|
{
|
|
1309
1309
|
as: E.div,
|
|
1310
1310
|
initial: { opacity: 0 },
|
|
@@ -1321,7 +1321,7 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
1321
1321
|
right: 0,
|
|
1322
1322
|
backgroundImage: "linear-gradient(to left, var(--tgph-surface-1) 0 60%, transparent 90% 100%)"
|
|
1323
1323
|
},
|
|
1324
|
-
children: /* @__PURE__ */
|
|
1324
|
+
children: /* @__PURE__ */ S(P, { as: "span", size: "1", style: { whiteSpace: "nowrap" }, children: [
|
|
1325
1325
|
"+",
|
|
1326
1326
|
/* @__PURE__ */ u(F, { mode: "wait", initial: !1, children: c.map((d) => /* @__PURE__ */ u(
|
|
1327
1327
|
X,
|
|
@@ -1353,14 +1353,14 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
1353
1353
|
}
|
|
1354
1354
|
);
|
|
1355
1355
|
}
|
|
1356
|
-
return /* @__PURE__ */ u(
|
|
1356
|
+
return /* @__PURE__ */ u(T, { h: e, align: "center", my: "1", children: /* @__PURE__ */ u(D.Text, { color: t.value ? "default" : "gray", children: ((a = t == null ? void 0 : t.value) == null ? void 0 : a.label) || ((i = t == null ? void 0 : t.value) == null ? void 0 : i.value) || t.placeholder }) });
|
|
1357
1357
|
}, Pe = ({ size: o = "1", ...t }) => {
|
|
1358
|
-
const e = p.useContext(
|
|
1358
|
+
const e = p.useContext(x), a = p.useCallback(() => {
|
|
1359
1359
|
var i, r, n;
|
|
1360
1360
|
return e.value ? q(e.value) ? ((i = e.value) == null ? void 0 : i.label) || ((r = e.value) == null ? void 0 : r.value) || e.placeholder : ((n = e.value) == null ? void 0 : n.map((l) => l.label).join(", ")) || e.placeholder : e.placeholder;
|
|
1361
1361
|
}, [e.value, e.placeholder]);
|
|
1362
1362
|
return /* @__PURE__ */ u(
|
|
1363
|
-
N.
|
|
1363
|
+
N.Trigger,
|
|
1364
1364
|
{
|
|
1365
1365
|
...t,
|
|
1366
1366
|
asChild: !0,
|
|
@@ -1373,7 +1373,7 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
1373
1373
|
i.stopPropagation();
|
|
1374
1374
|
return;
|
|
1375
1375
|
}
|
|
1376
|
-
if (
|
|
1376
|
+
if (pe.includes(i.key)) {
|
|
1377
1377
|
i.preventDefault();
|
|
1378
1378
|
return;
|
|
1379
1379
|
}
|
|
@@ -1383,7 +1383,7 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
1383
1383
|
}
|
|
1384
1384
|
},
|
|
1385
1385
|
tgphRef: e.triggerRef,
|
|
1386
|
-
children: /* @__PURE__ */
|
|
1386
|
+
children: /* @__PURE__ */ S(
|
|
1387
1387
|
D.Root,
|
|
1388
1388
|
{
|
|
1389
1389
|
id: e.triggerId,
|
|
@@ -1414,7 +1414,7 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
1414
1414
|
)
|
|
1415
1415
|
]
|
|
1416
1416
|
}
|
|
1417
|
-
)
|
|
1417
|
+
)
|
|
1418
1418
|
}
|
|
1419
1419
|
);
|
|
1420
1420
|
}, Be = ({
|
|
@@ -1423,22 +1423,22 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
1423
1423
|
children: e,
|
|
1424
1424
|
...a
|
|
1425
1425
|
}) => {
|
|
1426
|
-
const i = p.useContext(
|
|
1426
|
+
const i = p.useContext(x), r = p.useRef(!1), n = B(o, i.contentRef), l = p.useRef(null), [c, d] = p.useState(0), [s, b] = p.useState(!1), y = p.useCallback(
|
|
1427
1427
|
(g) => {
|
|
1428
|
-
const
|
|
1429
|
-
|
|
1428
|
+
const h = g.getBoundingClientRect();
|
|
1429
|
+
h && d(h.height), s || b(!0);
|
|
1430
1430
|
},
|
|
1431
1431
|
[s]
|
|
1432
1432
|
);
|
|
1433
1433
|
return p.useEffect(() => {
|
|
1434
|
-
const g = new ResizeObserver((
|
|
1435
|
-
for (const v of
|
|
1436
|
-
const
|
|
1437
|
-
|
|
1434
|
+
const g = new ResizeObserver((h) => {
|
|
1435
|
+
for (const v of h) {
|
|
1436
|
+
const w = v.target;
|
|
1437
|
+
y(w);
|
|
1438
1438
|
}
|
|
1439
1439
|
});
|
|
1440
1440
|
return l.current && s && g.observe(l.current), () => g.disconnect();
|
|
1441
|
-
}, [s,
|
|
1441
|
+
}, [s, y]), p.useEffect(() => {
|
|
1442
1442
|
s === !0 && i.open === !1 && b(!1);
|
|
1443
1443
|
}, [i.open, s]), /* @__PURE__ */ u(
|
|
1444
1444
|
N.Content,
|
|
@@ -1465,19 +1465,19 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
1465
1465
|
onAnimationComplete: () => {
|
|
1466
1466
|
if (!s && l) {
|
|
1467
1467
|
const g = l.current;
|
|
1468
|
-
|
|
1468
|
+
y(g);
|
|
1469
1469
|
}
|
|
1470
1470
|
},
|
|
1471
1471
|
onCloseAutoFocus: (g) => {
|
|
1472
|
-
var
|
|
1473
|
-
r.current || (v = (
|
|
1472
|
+
var h, v;
|
|
1473
|
+
r.current || (v = (h = i.triggerRef) == null ? void 0 : h.current) == null || v.focus(), r.current = !1, g.preventDefault();
|
|
1474
1474
|
},
|
|
1475
1475
|
onKeyDown: (g) => {
|
|
1476
|
-
var v,
|
|
1477
|
-
const
|
|
1476
|
+
var v, w, L, R;
|
|
1477
|
+
const h = (w = (v = i.contentRef) == null ? void 0 : v.current) == null ? void 0 : w.querySelectorAll(
|
|
1478
1478
|
"[data-tgph-combobox-option]"
|
|
1479
1479
|
);
|
|
1480
|
-
document.activeElement === (
|
|
1480
|
+
document.activeElement === (h == null ? void 0 : h[0]) && Ae.includes(g.key) && ((R = (L = i.searchRef) == null ? void 0 : L.current) == null || R.focus()), g.key === "Escape" && i.setOpen(!1), g.stopPropagation();
|
|
1481
1481
|
},
|
|
1482
1482
|
bg: "surface-1",
|
|
1483
1483
|
style: {
|
|
@@ -1495,13 +1495,13 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
1495
1495
|
"data-tgph-combobox-content-open": s,
|
|
1496
1496
|
role: void 0,
|
|
1497
1497
|
"aria-orientation": void 0,
|
|
1498
|
-
children: /* @__PURE__ */ u(
|
|
1498
|
+
children: /* @__PURE__ */ u(T, { direction: "column", gap: "1", tgphRef: l, children: e })
|
|
1499
1499
|
}
|
|
1500
1500
|
);
|
|
1501
1501
|
}, Ne = ({ ...o }) => {
|
|
1502
|
-
const t = p.useContext(
|
|
1502
|
+
const t = p.useContext(x);
|
|
1503
1503
|
return /* @__PURE__ */ u(
|
|
1504
|
-
|
|
1504
|
+
T,
|
|
1505
1505
|
{
|
|
1506
1506
|
id: t.contentId,
|
|
1507
1507
|
direction: "column",
|
|
@@ -1515,32 +1515,34 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
1515
1515
|
...o
|
|
1516
1516
|
}
|
|
1517
1517
|
);
|
|
1518
|
-
},
|
|
1518
|
+
}, ue = ({
|
|
1519
1519
|
value: o,
|
|
1520
1520
|
label: t,
|
|
1521
1521
|
selected: e,
|
|
1522
1522
|
onSelect: a,
|
|
1523
1523
|
...i
|
|
1524
1524
|
}) => {
|
|
1525
|
-
const r = p.useContext(
|
|
1526
|
-
var
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1525
|
+
const r = p.useContext(x), [n, l] = p.useState(!1), c = r.value ?? [], d = (Q(c), !r.searchQuery || o.toLowerCase().includes(r.searchQuery.toLowerCase())), s = Q(c) ? c.some((y) => y.value === o) : c.value === o, b = (y) => {
|
|
1526
|
+
var h, v;
|
|
1527
|
+
const g = y;
|
|
1528
|
+
if (!(g.key && !pe.includes(g.key))) {
|
|
1529
|
+
if (y.stopPropagation(), y.preventDefault(), r.closeOnSelect === !0 && r.setOpen(!1), a)
|
|
1530
|
+
return a(y);
|
|
1530
1531
|
if (Q(c)) {
|
|
1531
|
-
const
|
|
1532
|
-
|
|
1532
|
+
const w = r.onValueChange, L = s ? c.filter((R) => R.value !== o) : [...c, { value: o, label: t }];
|
|
1533
|
+
w(L);
|
|
1533
1534
|
} else if (q(c)) {
|
|
1534
|
-
const
|
|
1535
|
-
|
|
1535
|
+
const w = r.onValueChange;
|
|
1536
|
+
w({ value: o, label: t });
|
|
1536
1537
|
}
|
|
1537
|
-
(
|
|
1538
|
+
(v = (h = r.triggerRef) == null ? void 0 : h.current) == null || v.focus();
|
|
1538
1539
|
}
|
|
1539
1540
|
};
|
|
1540
1541
|
if (d)
|
|
1541
1542
|
return /* @__PURE__ */ u(
|
|
1542
1543
|
N.Button,
|
|
1543
1544
|
{
|
|
1545
|
+
type: "button",
|
|
1544
1546
|
onSelect: b,
|
|
1545
1547
|
onKeyDown: b,
|
|
1546
1548
|
selected: e === null ? null : e ?? s,
|
|
@@ -1563,19 +1565,19 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
1563
1565
|
...a
|
|
1564
1566
|
}) => {
|
|
1565
1567
|
var l;
|
|
1566
|
-
const i = p.useId(), r = p.useContext(
|
|
1568
|
+
const i = p.useId(), r = p.useContext(x), n = B(e, r.searchRef);
|
|
1567
1569
|
return p.useEffect(() => {
|
|
1568
1570
|
var s;
|
|
1569
1571
|
const c = (b) => {
|
|
1570
|
-
var
|
|
1571
|
-
Ve.includes(b.key) && ((g = (
|
|
1572
|
+
var y, g;
|
|
1573
|
+
Ve.includes(b.key) && ((g = (y = r.contentRef) == null ? void 0 : y.current) == null || g.focus({ preventScroll: !0 })), b.key === "Escape" && r.setOpen(!1), b.stopPropagation();
|
|
1572
1574
|
}, d = (s = r.searchRef) == null ? void 0 : s.current;
|
|
1573
1575
|
if (d)
|
|
1574
1576
|
return d.addEventListener("keydown", c), () => {
|
|
1575
1577
|
d.removeEventListener("keydown", c);
|
|
1576
1578
|
};
|
|
1577
|
-
}, [r]), /* @__PURE__ */
|
|
1578
|
-
/* @__PURE__ */ u(
|
|
1579
|
+
}, [r]), /* @__PURE__ */ S(X, { borderBottom: !0, px: "1", pb: "1", children: [
|
|
1580
|
+
/* @__PURE__ */ u(be.Root, { children: /* @__PURE__ */ u(P, { as: "label", htmlFor: i, children: o }) }),
|
|
1579
1581
|
/* @__PURE__ */ u(
|
|
1580
1582
|
fe,
|
|
1581
1583
|
{
|
|
@@ -1618,7 +1620,7 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
1618
1620
|
children: e,
|
|
1619
1621
|
...a
|
|
1620
1622
|
}) => {
|
|
1621
|
-
const i = p.useContext(
|
|
1623
|
+
const i = p.useContext(x), [r, n] = p.useState(!1);
|
|
1622
1624
|
if (p.useEffect(() => {
|
|
1623
1625
|
var c, d;
|
|
1624
1626
|
const l = (d = (c = i.contentRef) == null ? void 0 : c.current) == null ? void 0 : d.querySelectorAll(
|
|
@@ -1626,8 +1628,8 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
1626
1628
|
);
|
|
1627
1629
|
(l == null ? void 0 : l.length) === 0 ? n(!0) : n(!1);
|
|
1628
1630
|
}, [i.searchQuery, i.contentRef, e]), r)
|
|
1629
|
-
return /* @__PURE__ */
|
|
1630
|
-
|
|
1631
|
+
return /* @__PURE__ */ S(
|
|
1632
|
+
T,
|
|
1631
1633
|
{
|
|
1632
1634
|
as: E.div,
|
|
1633
1635
|
initial: { opacity: 0, scale: 0.8 },
|
|
@@ -1653,13 +1655,13 @@ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
|
|
|
1653
1655
|
selected: a = null,
|
|
1654
1656
|
...i
|
|
1655
1657
|
}) => {
|
|
1656
|
-
const r = p.useContext(
|
|
1658
|
+
const r = p.useContext(x), n = p.useCallback(
|
|
1657
1659
|
(l) => !t || (t == null ? void 0 : t.length) === 0 ? !1 : t.some((c) => c.value === l),
|
|
1658
1660
|
[t]
|
|
1659
1661
|
);
|
|
1660
1662
|
if (r.searchQuery && !n(r.searchQuery))
|
|
1661
1663
|
return /* @__PURE__ */ u(
|
|
1662
|
-
|
|
1664
|
+
ue,
|
|
1663
1665
|
{
|
|
1664
1666
|
leadingIcon: { icon: j.Plus, "aria-hidden": !0 },
|
|
1665
1667
|
mx: "1",
|
|
@@ -1679,7 +1681,7 @@ Object.assign(Ke, {
|
|
|
1679
1681
|
Trigger: Pe,
|
|
1680
1682
|
Content: Be,
|
|
1681
1683
|
Options: Ne,
|
|
1682
|
-
Option:
|
|
1684
|
+
Option: ue,
|
|
1683
1685
|
Search: ze,
|
|
1684
1686
|
Empty: Fe,
|
|
1685
1687
|
Create: He
|