@mieweb/ui 0.6.1-dev.174 → 0.6.1-dev.175
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/{chunk-O6MBLWAI.js → chunk-35VBGVMB.js} +3 -3
- package/dist/{chunk-O6MBLWAI.js.map → chunk-35VBGVMB.js.map} +1 -1
- package/dist/{chunk-CDMWZBDD.cjs → chunk-372IIHUA.cjs} +5 -5
- package/dist/{chunk-CDMWZBDD.cjs.map → chunk-372IIHUA.cjs.map} +1 -1
- package/dist/{chunk-X7J45FU5.cjs → chunk-4GXECTPS.cjs} +2 -2
- package/dist/{chunk-X7J45FU5.cjs.map → chunk-4GXECTPS.cjs.map} +1 -1
- package/dist/chunk-62ZOA6PX.js +31 -0
- package/dist/chunk-62ZOA6PX.js.map +1 -0
- package/dist/{chunk-ROXYP3BZ.cjs → chunk-AES2BKEW.cjs} +71 -56
- package/dist/chunk-AES2BKEW.cjs.map +1 -0
- package/dist/{chunk-GBRPZGSI.cjs → chunk-BLPCYP4D.cjs} +7 -7
- package/dist/{chunk-GBRPZGSI.cjs.map → chunk-BLPCYP4D.cjs.map} +1 -1
- package/dist/{chunk-YWHSQH7S.cjs → chunk-DAPZPT5N.cjs} +24 -55
- package/dist/chunk-DAPZPT5N.cjs.map +1 -0
- package/dist/{chunk-FJG7KUDJ.js → chunk-FJH7P5WG.js} +3 -3
- package/dist/{chunk-FJG7KUDJ.js.map → chunk-FJH7P5WG.js.map} +1 -1
- package/dist/chunk-FSGEDDF2.cjs +33 -0
- package/dist/chunk-FSGEDDF2.cjs.map +1 -0
- package/dist/{chunk-DZIUSGUF.js → chunk-HRS6W74P.js} +3 -3
- package/dist/{chunk-DZIUSGUF.js.map → chunk-HRS6W74P.js.map} +1 -1
- package/dist/{chunk-6Y727LPG.js → chunk-J7Z7467B.js} +24 -55
- package/dist/chunk-J7Z7467B.js.map +1 -0
- package/dist/{chunk-ETGZ5DSA.js → chunk-JHYFHEHS.js} +3 -3
- package/dist/{chunk-ETGZ5DSA.js.map → chunk-JHYFHEHS.js.map} +1 -1
- package/dist/{chunk-QPOTSLY6.cjs → chunk-JTBQNOSL.cjs} +4 -4
- package/dist/{chunk-QPOTSLY6.cjs.map → chunk-JTBQNOSL.cjs.map} +1 -1
- package/dist/{chunk-CB4JX5EJ.cjs → chunk-MAMY5HTT.cjs} +117 -93
- package/dist/chunk-MAMY5HTT.cjs.map +1 -0
- package/dist/{chunk-WFS6R2F5.js → chunk-MKWGKASO.js} +114 -101
- package/dist/chunk-MKWGKASO.js.map +1 -0
- package/dist/{chunk-2JQBPU3Y.cjs → chunk-MZPF2QGM.cjs} +95 -77
- package/dist/chunk-MZPF2QGM.cjs.map +1 -0
- package/dist/{chunk-5INNPOZZ.cjs → chunk-NAQ3ZALI.cjs} +5 -5
- package/dist/{chunk-5INNPOZZ.cjs.map → chunk-NAQ3ZALI.cjs.map} +1 -1
- package/dist/chunk-QA6ZDHFP.js +117 -0
- package/dist/chunk-QA6ZDHFP.js.map +1 -0
- package/dist/{chunk-7QZSJFYT.js → chunk-UM6NA7HL.js} +117 -93
- package/dist/chunk-UM6NA7HL.js.map +1 -0
- package/dist/{chunk-7BARESXI.cjs → chunk-VPNURIAY.cjs} +114 -101
- package/dist/chunk-VPNURIAY.cjs.map +1 -0
- package/dist/{chunk-GSOOPTGM.js → chunk-YZT62IMX.js} +95 -77
- package/dist/chunk-YZT62IMX.js.map +1 -0
- package/dist/{chunk-PI3KOYAT.js → chunk-ZAIEQWRA.js} +71 -56
- package/dist/chunk-ZAIEQWRA.js.map +1 -0
- package/dist/chunk-ZDEYV373.cjs +139 -0
- package/dist/chunk-ZDEYV373.cjs.map +1 -0
- package/dist/{chunk-6VGXX6L6.js → chunk-ZGSC2CB2.js} +2 -2
- package/dist/{chunk-6VGXX6L6.js.map → chunk-ZGSC2CB2.js.map} +1 -1
- package/dist/components/Autocomplete/index.cjs +4 -3
- package/dist/components/Autocomplete/index.js +3 -2
- package/dist/components/CountryCodeDropdown/index.cjs +6 -5
- package/dist/components/CountryCodeDropdown/index.js +3 -2
- package/dist/components/Dropdown/index.cjs +9 -8
- package/dist/components/Dropdown/index.d.cts +2 -1
- package/dist/components/Dropdown/index.d.ts +2 -1
- package/dist/components/Dropdown/index.js +3 -2
- package/dist/components/MediaEditor/index.cjs +9 -7
- package/dist/components/MediaEditor/index.js +4 -2
- package/dist/components/RichTextEditor/index.cjs +7 -6
- package/dist/components/RichTextEditor/index.js +4 -3
- package/dist/components/Select/index.cjs +5 -3
- package/dist/components/Select/index.js +3 -1
- package/dist/components/Sheet/index.d.cts +1 -1
- package/dist/components/Sheet/index.d.ts +1 -1
- package/dist/components/SuperChat/index.cjs +9 -8
- package/dist/components/SuperChat/index.cjs.map +1 -1
- package/dist/components/SuperChat/index.js +4 -3
- package/dist/components/SuperChat/index.js.map +1 -1
- package/dist/components/SuperChat/plugins/index.cjs +4 -3
- package/dist/components/SuperChat/plugins/index.cjs.map +1 -1
- package/dist/components/SuperChat/plugins/index.js +3 -2
- package/dist/components/SuperChat/plugins/index.js.map +1 -1
- package/dist/esheet.cjs +7 -5
- package/dist/esheet.cjs.map +1 -1
- package/dist/esheet.js +4 -2
- package/dist/esheet.js.map +1 -1
- package/dist/hooks/index.cjs +21 -16
- package/dist/hooks/index.d.cts +2 -1
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/index.js +3 -2
- package/dist/index.cjs +1072 -983
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +941 -855
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/useAnchoredPosition-nXdSFKHf.d.cts +65 -0
- package/dist/useAnchoredPosition-nXdSFKHf.d.ts +65 -0
- package/package.json +1 -1
- package/dist/chunk-2JQBPU3Y.cjs.map +0 -1
- package/dist/chunk-6Y727LPG.js.map +0 -1
- package/dist/chunk-7BARESXI.cjs.map +0 -1
- package/dist/chunk-7QZSJFYT.js.map +0 -1
- package/dist/chunk-CB4JX5EJ.cjs.map +0 -1
- package/dist/chunk-GSOOPTGM.js.map +0 -1
- package/dist/chunk-IKMR2ADM.cjs +0 -25
- package/dist/chunk-IKMR2ADM.cjs.map +0 -1
- package/dist/chunk-OKBR6PX4.js +0 -23
- package/dist/chunk-OKBR6PX4.js.map +0 -1
- package/dist/chunk-PI3KOYAT.js.map +0 -1
- package/dist/chunk-ROXYP3BZ.cjs.map +0 -1
- package/dist/chunk-WFS6R2F5.js.map +0 -1
- package/dist/chunk-YWHSQH7S.cjs.map +0 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { useClickOutside } from './chunk-OKBR6PX4.js';
|
|
2
1
|
import { useEscapeKey } from './chunk-T4ME7QCT.js';
|
|
2
|
+
import { useClickOutside } from './chunk-62ZOA6PX.js';
|
|
3
|
+
import { useAnchoredPosition } from './chunk-QA6ZDHFP.js';
|
|
3
4
|
import { cn } from './chunk-F3SOEIN2.js';
|
|
4
5
|
import * as React from 'react';
|
|
6
|
+
import { createPortal } from 'react-dom';
|
|
5
7
|
import * as libphonenumber from 'google-libphonenumber';
|
|
6
8
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
7
9
|
|
|
@@ -113,7 +115,12 @@ function CountryCodeDropdown({
|
|
|
113
115
|
setIsOpen(false);
|
|
114
116
|
setSearch("");
|
|
115
117
|
}, []);
|
|
116
|
-
|
|
118
|
+
const { anchorRef, floatingRef, style } = useAnchoredPosition({ open: isOpen, placement });
|
|
119
|
+
const outsideRefs = React.useMemo(
|
|
120
|
+
() => [containerRef, floatingRef],
|
|
121
|
+
[containerRef, floatingRef]
|
|
122
|
+
);
|
|
123
|
+
useClickOutside(outsideRefs, close, isOpen);
|
|
117
124
|
useEscapeKey(close, isOpen);
|
|
118
125
|
React.useEffect(() => {
|
|
119
126
|
if (isOpen) {
|
|
@@ -155,11 +162,13 @@ function CountryCodeDropdown({
|
|
|
155
162
|
},
|
|
156
163
|
[isOpen]
|
|
157
164
|
);
|
|
158
|
-
const placementClass = placement === "bottom-end" ? "top-full right-0 mt-1" : "top-full left-0 mt-1";
|
|
159
165
|
return /* @__PURE__ */ jsxs(
|
|
160
166
|
"div",
|
|
161
167
|
{
|
|
162
|
-
ref:
|
|
168
|
+
ref: (node) => {
|
|
169
|
+
containerRef.current = node;
|
|
170
|
+
anchorRef.current = node;
|
|
171
|
+
},
|
|
163
172
|
"data-slot": "country-dropdown",
|
|
164
173
|
className: "relative inline-flex",
|
|
165
174
|
children: [
|
|
@@ -219,103 +228,107 @@ function CountryCodeDropdown({
|
|
|
219
228
|
]
|
|
220
229
|
}
|
|
221
230
|
),
|
|
222
|
-
isOpen &&
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
/* @__PURE__ */ jsx(
|
|
240
|
-
"div",
|
|
241
|
-
{
|
|
242
|
-
"data-slot": "country-dropdown-search",
|
|
243
|
-
className: "border-b border-neutral-200 p-2 dark:border-neutral-700",
|
|
244
|
-
children: /* @__PURE__ */ jsx(
|
|
245
|
-
"input",
|
|
246
|
-
{
|
|
247
|
-
ref: searchInputRef,
|
|
248
|
-
type: "text",
|
|
249
|
-
"data-slot": "country-dropdown-search-input",
|
|
250
|
-
value: search,
|
|
251
|
-
onChange: (e) => setSearch(e.target.value),
|
|
252
|
-
placeholder: searchPlaceholder,
|
|
253
|
-
"aria-label": "Search countries",
|
|
254
|
-
className: cn(
|
|
255
|
-
"w-full rounded-lg border border-neutral-200 px-3 py-1.5 text-sm",
|
|
256
|
-
"text-foreground placeholder:text-muted-foreground bg-white",
|
|
257
|
-
"focus:ring-ring focus:border-transparent focus:ring-2 focus:outline-none",
|
|
258
|
-
"dark:border-neutral-600 dark:bg-neutral-700 dark:text-neutral-100"
|
|
259
|
-
)
|
|
260
|
-
}
|
|
261
|
-
)
|
|
262
|
-
}
|
|
231
|
+
isOpen && createPortal(
|
|
232
|
+
/* @__PURE__ */ jsxs(
|
|
233
|
+
"div",
|
|
234
|
+
{
|
|
235
|
+
ref: floatingRef,
|
|
236
|
+
style,
|
|
237
|
+
id: menuId,
|
|
238
|
+
role: "listbox",
|
|
239
|
+
"data-slot": "country-dropdown-panel",
|
|
240
|
+
"aria-label": ariaLabel,
|
|
241
|
+
tabIndex: -1,
|
|
242
|
+
onKeyDown: handleKeyDown,
|
|
243
|
+
className: cn(
|
|
244
|
+
"flex w-72 flex-col overflow-hidden",
|
|
245
|
+
"rounded-xl border border-neutral-200 bg-white shadow-lg",
|
|
246
|
+
"dark:border-neutral-700 dark:bg-neutral-800",
|
|
247
|
+
"animate-in fade-in zoom-in-95 duration-100"
|
|
263
248
|
),
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
"
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
children: [
|
|
286
|
-
/* @__PURE__ */ jsx(
|
|
287
|
-
"span",
|
|
288
|
-
{
|
|
289
|
-
"data-slot": "country-dropdown-option-flag",
|
|
290
|
-
className: "text-base leading-none",
|
|
291
|
-
"aria-hidden": "true",
|
|
292
|
-
children: country.flag
|
|
293
|
-
}
|
|
294
|
-
),
|
|
295
|
-
/* @__PURE__ */ jsx(
|
|
296
|
-
"span",
|
|
297
|
-
{
|
|
298
|
-
"data-slot": "country-dropdown-option-name",
|
|
299
|
-
className: "flex-1 truncate",
|
|
300
|
-
children: country.name
|
|
301
|
-
}
|
|
302
|
-
),
|
|
303
|
-
/* @__PURE__ */ jsx(
|
|
304
|
-
"span",
|
|
305
|
-
{
|
|
306
|
-
"data-slot": "country-dropdown-option-dialcode",
|
|
307
|
-
className: "text-muted-foreground shrink-0 text-xs",
|
|
308
|
-
children: country.dialCode
|
|
309
|
-
}
|
|
249
|
+
children: [
|
|
250
|
+
/* @__PURE__ */ jsx(
|
|
251
|
+
"div",
|
|
252
|
+
{
|
|
253
|
+
"data-slot": "country-dropdown-search",
|
|
254
|
+
className: "shrink-0 border-b border-neutral-200 p-2 dark:border-neutral-700",
|
|
255
|
+
children: /* @__PURE__ */ jsx(
|
|
256
|
+
"input",
|
|
257
|
+
{
|
|
258
|
+
ref: searchInputRef,
|
|
259
|
+
type: "text",
|
|
260
|
+
"data-slot": "country-dropdown-search-input",
|
|
261
|
+
value: search,
|
|
262
|
+
onChange: (e) => setSearch(e.target.value),
|
|
263
|
+
placeholder: searchPlaceholder,
|
|
264
|
+
"aria-label": "Search countries",
|
|
265
|
+
className: cn(
|
|
266
|
+
"w-full rounded-lg border border-neutral-200 px-3 py-1.5 text-sm",
|
|
267
|
+
"text-foreground placeholder:text-muted-foreground bg-white",
|
|
268
|
+
"focus:ring-ring focus:border-transparent focus:ring-2 focus:outline-none",
|
|
269
|
+
"dark:border-neutral-600 dark:bg-neutral-700 dark:text-neutral-100"
|
|
310
270
|
)
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
271
|
+
}
|
|
272
|
+
)
|
|
273
|
+
}
|
|
274
|
+
),
|
|
275
|
+
/* @__PURE__ */ jsx(
|
|
276
|
+
"div",
|
|
277
|
+
{
|
|
278
|
+
ref: listRef,
|
|
279
|
+
"data-slot": "country-dropdown-list",
|
|
280
|
+
className: "max-h-60 min-h-0 overflow-y-auto p-1",
|
|
281
|
+
children: filtered.length === 0 ? /* @__PURE__ */ jsx("div", { className: "text-muted-foreground px-3 py-4 text-center text-sm", children: "No countries found" }) : filtered.map((country) => /* @__PURE__ */ jsxs(
|
|
282
|
+
"button",
|
|
283
|
+
{
|
|
284
|
+
type: "button",
|
|
285
|
+
role: "option",
|
|
286
|
+
"data-slot": "country-dropdown-option",
|
|
287
|
+
"aria-selected": country.code === selected.code,
|
|
288
|
+
onClick: () => handleSelect(country),
|
|
289
|
+
className: cn(
|
|
290
|
+
"flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm",
|
|
291
|
+
"transition-colors duration-150",
|
|
292
|
+
"focus:outline-none",
|
|
293
|
+
country.code === selected.code ? "bg-neutral-100 font-medium text-neutral-900 dark:bg-neutral-700 dark:text-white" : "text-neutral-700 hover:bg-neutral-50 dark:text-neutral-300 dark:hover:bg-neutral-700/50",
|
|
294
|
+
"focus:bg-neutral-100 dark:focus:bg-neutral-700"
|
|
295
|
+
),
|
|
296
|
+
children: [
|
|
297
|
+
/* @__PURE__ */ jsx(
|
|
298
|
+
"span",
|
|
299
|
+
{
|
|
300
|
+
"data-slot": "country-dropdown-option-flag",
|
|
301
|
+
className: "text-base leading-none",
|
|
302
|
+
"aria-hidden": "true",
|
|
303
|
+
children: country.flag
|
|
304
|
+
}
|
|
305
|
+
),
|
|
306
|
+
/* @__PURE__ */ jsx(
|
|
307
|
+
"span",
|
|
308
|
+
{
|
|
309
|
+
"data-slot": "country-dropdown-option-name",
|
|
310
|
+
className: "flex-1 truncate",
|
|
311
|
+
children: country.name
|
|
312
|
+
}
|
|
313
|
+
),
|
|
314
|
+
/* @__PURE__ */ jsx(
|
|
315
|
+
"span",
|
|
316
|
+
{
|
|
317
|
+
"data-slot": "country-dropdown-option-dialcode",
|
|
318
|
+
className: "text-muted-foreground shrink-0 text-xs",
|
|
319
|
+
children: country.dialCode
|
|
320
|
+
}
|
|
321
|
+
)
|
|
322
|
+
]
|
|
323
|
+
},
|
|
324
|
+
country.code
|
|
325
|
+
))
|
|
326
|
+
}
|
|
327
|
+
)
|
|
328
|
+
]
|
|
329
|
+
}
|
|
330
|
+
),
|
|
331
|
+
document.body
|
|
319
332
|
)
|
|
320
333
|
]
|
|
321
334
|
}
|
|
@@ -324,5 +337,5 @@ function CountryCodeDropdown({
|
|
|
324
337
|
CountryCodeDropdown.displayName = "CountryCodeDropdown";
|
|
325
338
|
|
|
326
339
|
export { CountryCodeDropdown, formatE164, validatePhoneNumber };
|
|
327
|
-
//# sourceMappingURL=chunk-
|
|
328
|
-
//# sourceMappingURL=chunk-
|
|
340
|
+
//# sourceMappingURL=chunk-MKWGKASO.js.map
|
|
341
|
+
//# sourceMappingURL=chunk-MKWGKASO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/CountryCodeDropdown/CountryCodeDropdown.tsx"],"names":["PhoneNumberUtil","PhoneNumberFormat"],"mappings":";;;;;;;;;AAQA,IAAMA,gBAAAA,GAC+D,wBAC/D,eAAA,IAAkC,cAAA,CAAA,eAAA;AACxC,IAAMC,kBAAAA,GAC+D,wBAC/D,iBAAA,IAAoC,cAAA,CAAA,iBAAA;AAuC1C,SAAS,WAAW,IAAA,EAAsB;AACxC,EAAA,OAAO,CAAC,GAAG,IAAA,CAAK,WAAA,EAAa,CAAA,CAC1B,GAAA,CAAI,CAAC,CAAA,KAAM,MAAA,CAAO,cAAc,MAAA,GAAU,EAAA,GAAK,EAAE,UAAA,CAAW,CAAC,CAAC,CAAC,CAAA,CAC/D,KAAK,EAAE,CAAA;AACZ;AAGA,SAAS,gBAAA,GAAkC;AACzC,EAAA,MAAM,SAAA,GAAYD,iBAAgB,WAAA,EAAY;AAC9C,EAAA,MAAM,OAAA,GAAU,UAAU,mBAAA,EAAoB;AAC9C,EAAA,MAAM,IAAA,GAAsB,OAAA,CAAQ,GAAA,CAAI,CAAC,IAAA,KAAiB;AACxD,IAAA,MAAM,WAAA,GAAc,SAAA,CAAU,uBAAA,CAAwB,IAAI,CAAA;AAC1D,IAAA,OAAO;AAAA,MACL,IAAA;AAAA,MACA,IAAA,EAAM,kBAAkB,IAAI,CAA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EAAU,kCAAA;AAAA,8BACV,SAAA,EAAU,wCAAA;AAAA,8BAET,QAAA,EAAA,OAAA,CAAQ;AAAA;AAAA;AACX;AAAA,uBAAA;AAAA,sBAlCK,OAAA,CAAQ;AAAA,qBAoChB;AAAA;AAAA;AAEL;AAAA;AAAA,WACF;AAAA,UACA,QAAA,CAAS;AAAA;AACX;AAAA;AAAA,GACJ;AAEJ;AAEA,mBAAA,CAAoB,WAAA,GAAc,qBAAA","file":"chunk-MKWGKASO.js","sourcesContent":["import * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport * as libphonenumber from 'google-libphonenumber';\nimport { cn } from '../../utils/cn';\nimport { useClickOutside } from '../../hooks/useClickOutside';\nimport { useEscapeKey } from '../../hooks/useEscapeKey';\nimport { useAnchoredPosition } from '../../hooks/useAnchoredPosition';\n\nconst PhoneNumberUtil =\n (libphonenumber as unknown as { default?: typeof libphonenumber }).default\n ?.PhoneNumberUtil ?? libphonenumber.PhoneNumberUtil;\nconst PhoneNumberFormat =\n (libphonenumber as unknown as { default?: typeof libphonenumber }).default\n ?.PhoneNumberFormat ?? libphonenumber.PhoneNumberFormat;\n\n// =============================================================================\n// Types\n// =============================================================================\n\nexport interface CountryData {\n /** ISO 3166-1 alpha-2 country code (e.g. \"US\") */\n code: string;\n /** Country name (e.g. \"United States\") */\n name: string;\n /** Dial code (e.g. \"+1\") */\n dialCode: string;\n /** Emoji flag (e.g. \"🇺🇸\") */\n flag: string;\n}\n\nexport interface CountryCodeDropdownProps {\n /** The currently selected country code (ISO alpha-2, e.g. \"US\") */\n value?: string;\n /** Called when a country is selected */\n onChange?: (country: CountryData) => void;\n /** Whether the dropdown is disabled */\n disabled?: boolean;\n /** Additional class name for the trigger button */\n className?: string;\n /** Placement of the dropdown panel */\n placement?: 'bottom-start' | 'bottom-end';\n /** Placeholder text for the search field */\n searchPlaceholder?: string;\n /** Label for accessibility — visually hidden */\n 'aria-label'?: string;\n}\n\n// =============================================================================\n// Country Data (generated from libphonenumber)\n// =============================================================================\n\n/** Convert an ISO alpha-2 code to an emoji flag. */\nfunction isoToEmoji(code: string): string {\n return [...code.toUpperCase()]\n .map((c) => String.fromCodePoint(0x1f1e6 - 65 + c.charCodeAt(0)))\n .join('');\n}\n\n/** Build the full sorted list of countries from libphonenumber. */\nfunction buildCountryList(): CountryData[] {\n const phoneUtil = PhoneNumberUtil.getInstance();\n const regions = phoneUtil.getSupportedRegions() as string[];\n const list: CountryData[] = regions.map((code: string) => {\n const callingCode = phoneUtil.getCountryCodeForRegion(code);\n return {\n code,\n name: regionDisplayName(code),\n dialCode: `+${callingCode}`,\n flag: isoToEmoji(code),\n };\n });\n list.sort((a, b) => a.name.localeCompare(b.name));\n return list;\n}\n\n/** Lazy singleton so we only build the list once. */\nlet _countries: CountryData[] | null = null;\nfunction getCountries(): CountryData[] {\n if (!_countries) _countries = buildCountryList();\n return _countries;\n}\n\n// =============================================================================\n// Region display name mapping\n// =============================================================================\n\n/** Lazy singleton for Intl.DisplayNames so we only construct it once. */\nlet _regionDisplayNames: Intl.DisplayNames | null = null;\n\nfunction getRegionDisplayNames(): Intl.DisplayNames | null {\n if (_regionDisplayNames === null) {\n try {\n const locales =\n typeof navigator !== 'undefined' && navigator.languages?.length\n ? [...navigator.languages]\n : ['en'];\n _regionDisplayNames = new Intl.DisplayNames(locales, { type: 'region' });\n } catch {\n return null;\n }\n }\n return _regionDisplayNames;\n}\n\n/**\n * Use the browser Intl API for display names where available,\n * falling back to the raw ISO code.\n */\nfunction regionDisplayName(code: string): string {\n const dn = getRegionDisplayNames();\n if (!dn) return code;\n return dn.of(code) ?? code;\n}\n\n// =============================================================================\n// Validation helper (exported for consumers)\n// =============================================================================\n\n/**\n * Validate a phone number string for a given country code using libphonenumber.\n *\n * @param phoneNumber - The phone number (digits, may include formatting)\n * @param countryCode - ISO alpha-2 code (e.g. \"US\")\n * @returns Whether the number is valid for the given region.\n */\nexport function validatePhoneNumber(\n phoneNumber: string,\n countryCode: string\n): boolean {\n try {\n const phoneUtil = PhoneNumberUtil.getInstance();\n const parsed = phoneUtil.parse(phoneNumber, countryCode);\n return phoneUtil.isValidNumberForRegion(parsed, countryCode);\n } catch {\n return false;\n }\n}\n\n/**\n * Format a phone number into E.164 international format.\n *\n * @param phoneNumber - The phone number (digits, may include formatting)\n * @param countryCode - ISO alpha-2 code (e.g. \"US\")\n * @returns The formatted number (e.g. \"+15551234567\") or the original string if parsing fails.\n */\nexport function formatE164(phoneNumber: string, countryCode: string): string {\n try {\n const phoneUtil = PhoneNumberUtil.getInstance();\n const parsed = phoneUtil.parse(phoneNumber, countryCode);\n return phoneUtil.format(parsed, PhoneNumberFormat.E164);\n } catch {\n return phoneNumber;\n }\n}\n\n// =============================================================================\n// Component\n// =============================================================================\n\n/**\n * A country-code selector dropdown designed to sit beside a phone number input.\n *\n * Defaults to United States (+1) with the 🇺🇸 flag. Clicking the trigger opens\n * a searchable list of all supported countries with their dial codes and flags.\n *\n * Uses Google's libphonenumber for the canonical country/code list and provides\n * a `validatePhoneNumber` helper for phone validation.\n *\n * @example\n * ```tsx\n * const [country, setCountry] = useState<CountryData>();\n *\n * <div className=\"flex gap-2\">\n * <CountryCodeDropdown value={country?.code} onChange={setCountry} />\n * <Input placeholder=\"Phone number\" />\n * </div>\n * ```\n */\nfunction CountryCodeDropdown({\n value,\n onChange,\n disabled = false,\n className,\n placement = 'bottom-start',\n searchPlaceholder = 'Search countries…',\n 'aria-label': ariaLabel = 'Select country code',\n}: CountryCodeDropdownProps) {\n const [isOpen, setIsOpen] = React.useState(false);\n const [search, setSearch] = React.useState('');\n const [internalValue, setInternalValue] = React.useState(value ?? 'US');\n const containerRef = React.useRef<HTMLDivElement>(null);\n const searchInputRef = React.useRef<HTMLInputElement>(null);\n const listRef = React.useRef<HTMLDivElement>(null);\n const menuId = React.useId();\n\n const isControlled = value !== undefined;\n const activeValue = isControlled ? value : internalValue;\n\n // Defer building the full country list until the dropdown is first opened\n const [countriesLoaded, setCountriesLoaded] = React.useState(false);\n const countries = React.useMemo(\n () => (countriesLoaded ? getCountries() : []),\n [countriesLoaded]\n );\n\n React.useEffect(() => {\n if (isOpen && !countriesLoaded) setCountriesLoaded(true);\n }, [isOpen, countriesLoaded]);\n\n const selected = React.useMemo(() => {\n if (countries.length) {\n return (\n countries.find((c) => c.code === activeValue) ??\n countries.find((c) => c.code === 'US')!\n );\n }\n // Lightweight fallback while list hasn't loaded yet\n return {\n code: activeValue ?? 'US',\n name: regionDisplayName(activeValue ?? 'US'),\n dialCode: `+${PhoneNumberUtil.getInstance().getCountryCodeForRegion(activeValue ?? 'US')}`,\n flag: isoToEmoji(activeValue ?? 'US'),\n };\n }, [activeValue, countries]);\n\n const filtered = React.useMemo(() => {\n if (!search) return countries;\n const q = search.toLowerCase();\n return countries.filter(\n (c) =>\n c.name.toLowerCase().includes(q) ||\n c.dialCode.includes(q) ||\n c.code.toLowerCase().includes(q)\n );\n }, [search, countries]);\n\n // Close helpers\n const close = React.useCallback(() => {\n setIsOpen(false);\n setSearch('');\n }, []);\n\n // Portal + fixed positioning so the panel escapes overflow-hidden ancestors.\n const { anchorRef, floatingRef, style } = useAnchoredPosition<\n HTMLDivElement,\n HTMLDivElement\n >({ open: isOpen, placement });\n\n const outsideRefs = React.useMemo(\n () => [containerRef, floatingRef],\n [containerRef, floatingRef]\n );\n useClickOutside(outsideRefs, close, isOpen);\n useEscapeKey(close, isOpen);\n\n // Focus search input when opening\n React.useEffect(() => {\n if (isOpen) {\n // Defer to let the DOM render\n requestAnimationFrame(() => searchInputRef.current?.focus());\n }\n }, [isOpen]);\n\n const handleToggle = React.useCallback(() => {\n if (!disabled) setIsOpen((prev) => !prev);\n }, [disabled]);\n\n const handleSelect = React.useCallback(\n (country: CountryData) => {\n if (!isControlled) {\n setInternalValue(country.code);\n }\n onChange?.(country);\n close();\n },\n [isControlled, onChange, close]\n );\n\n // Keyboard navigation inside the list\n const handleKeyDown = React.useCallback(\n (e: React.KeyboardEvent) => {\n if (!isOpen) return;\n if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {\n e.preventDefault();\n const items =\n listRef.current?.querySelectorAll<HTMLButtonElement>(\n '[role=\"option\"]'\n );\n if (!items?.length) return;\n\n const current = document.activeElement as HTMLElement;\n const idx = Array.from(items).indexOf(current as HTMLButtonElement);\n let next: number;\n if (e.key === 'ArrowDown') {\n next = idx < items.length - 1 ? idx + 1 : 0;\n } else {\n next = idx > 0 ? idx - 1 : items.length - 1;\n }\n items[next].focus();\n }\n },\n [isOpen]\n );\n\n return (\n <div\n ref={(node) => {\n containerRef.current = node;\n anchorRef.current = node;\n }}\n data-slot=\"country-dropdown\"\n className=\"relative inline-flex\"\n >\n {/* Trigger button */}\n <button\n type=\"button\"\n data-slot=\"country-dropdown-trigger\"\n onClick={handleToggle}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-haspopup=\"listbox\"\n aria-expanded={isOpen}\n aria-controls={isOpen ? menuId : undefined}\n className={cn(\n 'inline-flex items-center gap-1.5 rounded-lg border px-3 py-2 text-sm',\n 'border-input bg-background text-foreground',\n 'transition-colors duration-200',\n 'hover:bg-neutral-50 dark:hover:bg-neutral-700',\n 'focus:ring-ring focus:ring-2 focus:outline-none',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n className\n )}\n >\n <span\n data-slot=\"country-dropdown-flag\"\n className=\"text-base leading-none\"\n aria-hidden=\"true\"\n >\n {selected.flag}\n </span>\n <span data-slot=\"country-dropdown-dialcode\">{selected.dialCode}</span>\n <svg\n data-slot=\"country-dropdown-chevron\"\n className={cn(\n 'h-4 w-4 shrink-0 text-neutral-500 transition-transform duration-200',\n isOpen && 'rotate-180'\n )}\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 20 20\"\n fill=\"currentColor\"\n aria-hidden=\"true\"\n >\n <path\n fillRule=\"evenodd\"\n d=\"M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z\"\n clipRule=\"evenodd\"\n />\n </svg>\n </button>\n\n {/* Dropdown panel */}\n {isOpen &&\n createPortal(\n <div\n ref={floatingRef}\n style={style}\n id={menuId}\n role=\"listbox\"\n data-slot=\"country-dropdown-panel\"\n aria-label={ariaLabel}\n tabIndex={-1}\n onKeyDown={handleKeyDown}\n className={cn(\n 'flex w-72 flex-col overflow-hidden',\n 'rounded-xl border border-neutral-200 bg-white shadow-lg',\n 'dark:border-neutral-700 dark:bg-neutral-800',\n 'animate-in fade-in zoom-in-95 duration-100'\n )}\n >\n {/* Search input */}\n <div\n data-slot=\"country-dropdown-search\"\n className=\"shrink-0 border-b border-neutral-200 p-2 dark:border-neutral-700\"\n >\n <input\n ref={searchInputRef}\n type=\"text\"\n data-slot=\"country-dropdown-search-input\"\n value={search}\n onChange={(e) => setSearch(e.target.value)}\n placeholder={searchPlaceholder}\n aria-label=\"Search countries\"\n className={cn(\n 'w-full rounded-lg border border-neutral-200 px-3 py-1.5 text-sm',\n 'text-foreground placeholder:text-muted-foreground bg-white',\n 'focus:ring-ring focus:border-transparent focus:ring-2 focus:outline-none',\n 'dark:border-neutral-600 dark:bg-neutral-700 dark:text-neutral-100'\n )}\n />\n </div>\n\n {/* Country list */}\n <div\n ref={listRef}\n data-slot=\"country-dropdown-list\"\n className=\"max-h-60 min-h-0 overflow-y-auto p-1\"\n >\n {filtered.length === 0 ? (\n <div className=\"text-muted-foreground px-3 py-4 text-center text-sm\">\n No countries found\n </div>\n ) : (\n filtered.map((country) => (\n <button\n key={country.code}\n type=\"button\"\n role=\"option\"\n data-slot=\"country-dropdown-option\"\n aria-selected={country.code === selected.code}\n onClick={() => handleSelect(country)}\n className={cn(\n 'flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm',\n 'transition-colors duration-150',\n 'focus:outline-none',\n country.code === selected.code\n ? 'bg-neutral-100 font-medium text-neutral-900 dark:bg-neutral-700 dark:text-white'\n : 'text-neutral-700 hover:bg-neutral-50 dark:text-neutral-300 dark:hover:bg-neutral-700/50',\n 'focus:bg-neutral-100 dark:focus:bg-neutral-700'\n )}\n >\n <span\n data-slot=\"country-dropdown-option-flag\"\n className=\"text-base leading-none\"\n aria-hidden=\"true\"\n >\n {country.flag}\n </span>\n <span\n data-slot=\"country-dropdown-option-name\"\n className=\"flex-1 truncate\"\n >\n {country.name}\n </span>\n <span\n data-slot=\"country-dropdown-option-dialcode\"\n className=\"text-muted-foreground shrink-0 text-xs\"\n >\n {country.dialCode}\n </span>\n </button>\n ))\n )}\n </div>\n </div>,\n document.body\n )}\n </div>\n );\n}\n\nCountryCodeDropdown.displayName = 'CountryCodeDropdown';\n\nexport { CountryCodeDropdown };\n"]}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkMSRU3XBH_cjs = require('./chunk-MSRU3XBH.cjs');
|
|
4
|
-
var chunkIKMR2ADM_cjs = require('./chunk-IKMR2ADM.cjs');
|
|
5
4
|
var chunkFHY3K6PL_cjs = require('./chunk-FHY3K6PL.cjs');
|
|
5
|
+
var chunkFSGEDDF2_cjs = require('./chunk-FSGEDDF2.cjs');
|
|
6
|
+
var chunkZDEYV373_cjs = require('./chunk-ZDEYV373.cjs');
|
|
6
7
|
var chunkOR5DRJCW_cjs = require('./chunk-OR5DRJCW.cjs');
|
|
7
8
|
var React = require('react');
|
|
9
|
+
var reactDom = require('react-dom');
|
|
8
10
|
var jsxRuntime = require('react/jsx-runtime');
|
|
9
11
|
|
|
10
12
|
function _interopNamespace(e) {
|
|
@@ -27,14 +29,7 @@ function _interopNamespace(e) {
|
|
|
27
29
|
|
|
28
30
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
29
31
|
|
|
30
|
-
var
|
|
31
|
-
"bottom-start": "top-full left-0 mt-2",
|
|
32
|
-
"bottom-end": "top-full right-0 mt-2",
|
|
33
|
-
bottom: "top-full left-1/2 -translate-x-1/2 mt-2",
|
|
34
|
-
"top-start": "bottom-full left-0 mb-2",
|
|
35
|
-
"top-end": "bottom-full right-0 mb-2",
|
|
36
|
-
top: "bottom-full left-1/2 -translate-x-1/2 mb-2"
|
|
37
|
-
};
|
|
32
|
+
var placementOffset = 8;
|
|
38
33
|
var DropdownContext = React__namespace.createContext(null);
|
|
39
34
|
function getNodeText(node) {
|
|
40
35
|
if (typeof node === "string" || typeof node === "number") {
|
|
@@ -259,8 +254,18 @@ function Dropdown({
|
|
|
259
254
|
}),
|
|
260
255
|
[multiSelect, selectedValues, toggleSelectedValue]
|
|
261
256
|
);
|
|
262
|
-
chunkIKMR2ADM_cjs.useClickOutside(containerRef, handleClose, isOpen);
|
|
263
257
|
chunkFHY3K6PL_cjs.useEscapeKey(handleClose, isOpen);
|
|
258
|
+
const { anchorRef, floatingRef, style } = chunkZDEYV373_cjs.useAnchoredPosition({
|
|
259
|
+
open: isOpen,
|
|
260
|
+
placement,
|
|
261
|
+
offset: placementOffset,
|
|
262
|
+
matchMinWidth: width === "trigger"
|
|
263
|
+
});
|
|
264
|
+
const outsideRefs = React__namespace.useMemo(
|
|
265
|
+
() => [containerRef, floatingRef],
|
|
266
|
+
[floatingRef]
|
|
267
|
+
);
|
|
268
|
+
chunkFSGEDDF2_cjs.useClickOutside(outsideRefs, handleClose, isOpen);
|
|
264
269
|
React__namespace.useEffect(() => {
|
|
265
270
|
if (!isOpen) {
|
|
266
271
|
setSearchQuery("");
|
|
@@ -277,7 +282,7 @@ function Dropdown({
|
|
|
277
282
|
"aria-controls": isOpen ? menuId : void 0,
|
|
278
283
|
disabled: disabled || trigger.props.disabled
|
|
279
284
|
});
|
|
280
|
-
const widthStyle = typeof width === "number" ? { width: `${width}px` } :
|
|
285
|
+
const widthStyle = typeof width === "number" ? { width: `${width}px` } : {};
|
|
281
286
|
const filteredChildren = React__namespace.useMemo(
|
|
282
287
|
() => filterDropdownChildren(children, searchQuery),
|
|
283
288
|
[children, searchQuery]
|
|
@@ -309,74 +314,87 @@ function Dropdown({
|
|
|
309
314
|
setSelectedValues,
|
|
310
315
|
visibleSelectableValues
|
|
311
316
|
]);
|
|
312
|
-
return /* @__PURE__ */ jsxRuntime.jsx(DropdownContext.Provider, { value: dropdownContext, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
placementStyles[placement],
|
|
325
|
-
className
|
|
326
|
-
),
|
|
327
|
-
children: [
|
|
328
|
-
searchable && /* @__PURE__ */ jsxRuntime.jsx(
|
|
317
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DropdownContext.Provider, { value: dropdownContext, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
318
|
+
"div",
|
|
319
|
+
{
|
|
320
|
+
ref: (node) => {
|
|
321
|
+
containerRef.current = node;
|
|
322
|
+
anchorRef.current = node;
|
|
323
|
+
},
|
|
324
|
+
className: "relative inline-flex",
|
|
325
|
+
children: [
|
|
326
|
+
triggerElement,
|
|
327
|
+
isOpen && reactDom.createPortal(
|
|
328
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
329
329
|
"div",
|
|
330
330
|
{
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
"
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
331
|
+
ref: floatingRef,
|
|
332
|
+
style: { ...style, ...widthStyle },
|
|
333
|
+
"data-slot": "dropdown-menu",
|
|
334
|
+
className: chunkOR5DRJCW_cjs.cn(
|
|
335
|
+
"flex min-w-[12rem] flex-col overflow-hidden",
|
|
336
|
+
"rounded-xl border border-neutral-200 bg-white shadow-lg",
|
|
337
|
+
"dark:border-neutral-700 dark:bg-neutral-800",
|
|
338
|
+
"animate-in fade-in zoom-in-95 duration-100",
|
|
339
|
+
className
|
|
340
|
+
),
|
|
341
|
+
children: [
|
|
342
|
+
searchable && /* @__PURE__ */ jsxRuntime.jsx(
|
|
343
|
+
"div",
|
|
344
|
+
{
|
|
345
|
+
className: "shrink-0 border-b border-neutral-200 p-2 dark:border-neutral-700",
|
|
346
|
+
"data-slot": "dropdown-search",
|
|
347
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
348
|
+
"input",
|
|
349
|
+
{
|
|
350
|
+
ref: searchInputRef,
|
|
351
|
+
type: "search",
|
|
352
|
+
value: searchQuery,
|
|
353
|
+
onChange: (event) => setSearchQuery(event.target.value),
|
|
354
|
+
placeholder: searchPlaceholder,
|
|
355
|
+
"aria-label": searchAriaLabel,
|
|
356
|
+
"aria-controls": menuId,
|
|
357
|
+
"aria-autocomplete": "list",
|
|
358
|
+
"data-slot": "dropdown-search-input",
|
|
359
|
+
className: chunkOR5DRJCW_cjs.cn(
|
|
360
|
+
chunkMSRU3XBH_cjs.inputVariants({ size: "sm" }),
|
|
361
|
+
"text-sm",
|
|
362
|
+
"dark:border-neutral-600 dark:bg-neutral-700 dark:text-neutral-100"
|
|
363
|
+
)
|
|
364
|
+
}
|
|
365
|
+
)
|
|
366
|
+
}
|
|
367
|
+
),
|
|
368
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { id: menuId, role: "menu", className: "min-h-0 overflow-y-auto", children: [
|
|
369
|
+
multiSelect && showSelectAll && visibleSelectableValues.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
370
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-2", "data-slot": "dropdown-select-all", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
371
|
+
DropdownItem,
|
|
372
|
+
{
|
|
373
|
+
checked: allVisibleSelected,
|
|
374
|
+
indeterminate: !allVisibleSelected && someVisibleSelected,
|
|
375
|
+
onClick: handleSelectAll,
|
|
376
|
+
children: selectAllLabel
|
|
377
|
+
}
|
|
378
|
+
) }),
|
|
379
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownSeparator, {})
|
|
380
|
+
] }),
|
|
381
|
+
searchable ? hasSearchResults ? filteredChildren : /* @__PURE__ */ jsxRuntime.jsx(
|
|
382
|
+
"div",
|
|
383
|
+
{
|
|
384
|
+
className: "text-muted-foreground px-3 py-4 text-center text-sm",
|
|
385
|
+
"data-slot": "dropdown-empty",
|
|
386
|
+
children: searchEmptyState
|
|
387
|
+
}
|
|
388
|
+
) : children
|
|
389
|
+
] })
|
|
390
|
+
]
|
|
352
391
|
}
|
|
353
392
|
),
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
checked: allVisibleSelected,
|
|
360
|
-
indeterminate: !allVisibleSelected && someVisibleSelected,
|
|
361
|
-
onClick: handleSelectAll,
|
|
362
|
-
children: selectAllLabel
|
|
363
|
-
}
|
|
364
|
-
) }),
|
|
365
|
-
/* @__PURE__ */ jsxRuntime.jsx(DropdownSeparator, {})
|
|
366
|
-
] }),
|
|
367
|
-
searchable ? hasSearchResults ? filteredChildren : /* @__PURE__ */ jsxRuntime.jsx(
|
|
368
|
-
"div",
|
|
369
|
-
{
|
|
370
|
-
className: "text-muted-foreground px-3 py-4 text-center text-sm",
|
|
371
|
-
"data-slot": "dropdown-empty",
|
|
372
|
-
children: searchEmptyState
|
|
373
|
-
}
|
|
374
|
-
) : children
|
|
375
|
-
] })
|
|
376
|
-
]
|
|
377
|
-
}
|
|
378
|
-
)
|
|
379
|
-
] }) });
|
|
393
|
+
document.body
|
|
394
|
+
)
|
|
395
|
+
]
|
|
396
|
+
}
|
|
397
|
+
) });
|
|
380
398
|
}
|
|
381
399
|
Dropdown.displayName = "Dropdown";
|
|
382
400
|
var DropdownHeader = React__namespace.forwardRef(
|
|
@@ -616,5 +634,5 @@ exports.DropdownHeader = DropdownHeader;
|
|
|
616
634
|
exports.DropdownItem = DropdownItem;
|
|
617
635
|
exports.DropdownLabel = DropdownLabel;
|
|
618
636
|
exports.DropdownSeparator = DropdownSeparator;
|
|
619
|
-
//# sourceMappingURL=chunk-
|
|
620
|
-
//# sourceMappingURL=chunk-
|
|
637
|
+
//# sourceMappingURL=chunk-MZPF2QGM.cjs.map
|
|
638
|
+
//# sourceMappingURL=chunk-MZPF2QGM.cjs.map
|