@fanvue/ui 1.17.3 → 1.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Accordion/Accordion.cjs +29 -0
- package/dist/cjs/components/Accordion/Accordion.cjs.map +1 -0
- package/dist/cjs/components/Accordion/AccordionContent.cjs +44 -0
- package/dist/cjs/components/Accordion/AccordionContent.cjs.map +1 -0
- package/dist/cjs/components/Accordion/AccordionItem.cjs +40 -0
- package/dist/cjs/components/Accordion/AccordionItem.cjs.map +1 -0
- package/dist/cjs/components/Accordion/AccordionTrigger.cjs +55 -0
- package/dist/cjs/components/Accordion/AccordionTrigger.cjs.map +1 -0
- package/dist/cjs/components/Autocomplete/Autocomplete.cjs +239 -0
- package/dist/cjs/components/Autocomplete/Autocomplete.cjs.map +1 -0
- package/dist/cjs/components/Autocomplete/AutocompleteDropdownContent.cjs +52 -0
- package/dist/cjs/components/Autocomplete/AutocompleteDropdownContent.cjs.map +1 -0
- package/dist/cjs/components/Autocomplete/AutocompleteOptionItem.cjs +53 -0
- package/dist/cjs/components/Autocomplete/AutocompleteOptionItem.cjs.map +1 -0
- package/dist/cjs/components/Autocomplete/AutocompleteTag.cjs +36 -0
- package/dist/cjs/components/Autocomplete/AutocompleteTag.cjs.map +1 -0
- package/dist/cjs/components/Autocomplete/constants.cjs +15 -0
- package/dist/cjs/components/Autocomplete/constants.cjs.map +1 -0
- package/dist/cjs/components/Autocomplete/useAutocomplete.cjs +284 -0
- package/dist/cjs/components/Autocomplete/useAutocomplete.cjs.map +1 -0
- package/dist/cjs/components/Avatar/Avatar.cjs +1 -1
- package/dist/cjs/components/Avatar/Avatar.cjs.map +1 -1
- package/dist/cjs/components/BottomNavigation/BottomNavigation.cjs +68 -0
- package/dist/cjs/components/BottomNavigation/BottomNavigation.cjs.map +1 -0
- package/dist/cjs/components/BottomNavigation/BottomNavigationAction.cjs +79 -0
- package/dist/cjs/components/BottomNavigation/BottomNavigationAction.cjs.map +1 -0
- package/dist/cjs/components/Chip/Chip.cjs +1 -8
- package/dist/cjs/components/Chip/Chip.cjs.map +1 -1
- package/dist/cjs/components/Dialog/Dialog.cjs +170 -0
- package/dist/cjs/components/Dialog/Dialog.cjs.map +1 -0
- package/dist/cjs/components/Drawer/Drawer.cjs +151 -0
- package/dist/cjs/components/Drawer/Drawer.cjs.map +1 -0
- package/dist/cjs/components/Icons/LockerOffIcon.cjs +1 -1
- package/dist/cjs/components/Icons/LockerOffIcon.cjs.map +1 -1
- package/dist/cjs/components/Icons/LockerOnIcon.cjs +1 -1
- package/dist/cjs/components/Icons/LockerOnIcon.cjs.map +1 -1
- package/dist/cjs/components/Icons/PinIcon.cjs +1 -1
- package/dist/cjs/components/Icons/PinIcon.cjs.map +1 -1
- package/dist/cjs/components/MobileStepper/MobileStepper.cjs +136 -0
- package/dist/cjs/components/MobileStepper/MobileStepper.cjs.map +1 -0
- package/dist/cjs/components/Pagination/Pagination.cjs +1 -1
- package/dist/cjs/components/Pagination/Pagination.cjs.map +1 -1
- package/dist/cjs/components/PasswordField/PasswordField.cjs +1 -1
- package/dist/cjs/components/PasswordField/PasswordField.cjs.map +1 -1
- package/dist/cjs/components/ProgressBar/ProgressBar.cjs +2 -0
- package/dist/cjs/components/ProgressBar/ProgressBar.cjs.map +1 -1
- package/dist/cjs/components/Tabs/TabsTrigger.cjs +10 -1
- package/dist/cjs/components/Tabs/TabsTrigger.cjs.map +1 -1
- package/dist/cjs/components/TextArea/TextArea.cjs +1 -1
- package/dist/cjs/components/TextArea/TextArea.cjs.map +1 -1
- package/dist/cjs/components/TextField/TextField.cjs +1 -1
- package/dist/cjs/components/TextField/TextField.cjs.map +1 -1
- package/dist/cjs/index.cjs +37 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/components/Accordion/Accordion.mjs +11 -0
- package/dist/components/Accordion/Accordion.mjs.map +1 -0
- package/dist/components/Accordion/AccordionContent.mjs +26 -0
- package/dist/components/Accordion/AccordionContent.mjs.map +1 -0
- package/dist/components/Accordion/AccordionItem.mjs +22 -0
- package/dist/components/Accordion/AccordionItem.mjs.map +1 -0
- package/dist/components/Accordion/AccordionTrigger.mjs +37 -0
- package/dist/components/Accordion/AccordionTrigger.mjs.map +1 -0
- package/dist/components/Autocomplete/Autocomplete.mjs +221 -0
- package/dist/components/Autocomplete/Autocomplete.mjs.map +1 -0
- package/dist/components/Autocomplete/AutocompleteDropdownContent.mjs +52 -0
- package/dist/components/Autocomplete/AutocompleteDropdownContent.mjs.map +1 -0
- package/dist/components/Autocomplete/AutocompleteOptionItem.mjs +53 -0
- package/dist/components/Autocomplete/AutocompleteOptionItem.mjs.map +1 -0
- package/dist/components/Autocomplete/AutocompleteTag.mjs +36 -0
- package/dist/components/Autocomplete/AutocompleteTag.mjs.map +1 -0
- package/dist/components/Autocomplete/constants.mjs +15 -0
- package/dist/components/Autocomplete/constants.mjs.map +1 -0
- package/dist/components/Autocomplete/useAutocomplete.mjs +267 -0
- package/dist/components/Autocomplete/useAutocomplete.mjs.map +1 -0
- package/dist/components/Avatar/Avatar.mjs +1 -1
- package/dist/components/Avatar/Avatar.mjs.map +1 -1
- package/dist/components/BottomNavigation/BottomNavigation.mjs +51 -0
- package/dist/components/BottomNavigation/BottomNavigation.mjs.map +1 -0
- package/dist/components/BottomNavigation/BottomNavigationAction.mjs +62 -0
- package/dist/components/BottomNavigation/BottomNavigationAction.mjs.map +1 -0
- package/dist/components/Chip/Chip.mjs +1 -8
- package/dist/components/Chip/Chip.mjs.map +1 -1
- package/dist/components/Dialog/Dialog.mjs +152 -0
- package/dist/components/Dialog/Dialog.mjs.map +1 -0
- package/dist/components/Drawer/Drawer.mjs +133 -0
- package/dist/components/Drawer/Drawer.mjs.map +1 -0
- package/dist/components/Icons/LockerOffIcon.mjs +1 -1
- package/dist/components/Icons/LockerOffIcon.mjs.map +1 -1
- package/dist/components/Icons/LockerOnIcon.mjs +1 -1
- package/dist/components/Icons/LockerOnIcon.mjs.map +1 -1
- package/dist/components/Icons/PinIcon.mjs +1 -1
- package/dist/components/Icons/PinIcon.mjs.map +1 -1
- package/dist/components/MobileStepper/MobileStepper.mjs +119 -0
- package/dist/components/MobileStepper/MobileStepper.mjs.map +1 -0
- package/dist/components/Pagination/Pagination.mjs +1 -1
- package/dist/components/Pagination/Pagination.mjs.map +1 -1
- package/dist/components/PasswordField/PasswordField.mjs +1 -1
- package/dist/components/PasswordField/PasswordField.mjs.map +1 -1
- package/dist/components/ProgressBar/ProgressBar.mjs +2 -0
- package/dist/components/ProgressBar/ProgressBar.mjs.map +1 -1
- package/dist/components/Tabs/TabsTrigger.mjs +10 -1
- package/dist/components/Tabs/TabsTrigger.mjs.map +1 -1
- package/dist/components/TextArea/TextArea.mjs +1 -1
- package/dist/components/TextArea/TextArea.mjs.map +1 -1
- package/dist/components/TextField/TextField.mjs +1 -1
- package/dist/components/TextField/TextField.mjs.map +1 -1
- package/dist/index.d.ts +510 -0
- package/dist/index.mjs +37 -0
- package/dist/index.mjs.map +1 -1
- package/dist/styles/theme.css +26 -0
- package/package.json +5 -2
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const AccordionPrimitive = require("@radix-ui/react-accordion");
|
|
6
|
+
const React = require("react");
|
|
7
|
+
const cn = require("../../utils/cn.cjs");
|
|
8
|
+
function _interopNamespaceDefault(e) {
|
|
9
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
10
|
+
if (e) {
|
|
11
|
+
for (const k in e) {
|
|
12
|
+
if (k !== "default") {
|
|
13
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: () => e[k]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
const AccordionPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(AccordionPrimitive);
|
|
25
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
26
|
+
const Accordion = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(AccordionPrimitive__namespace.Root, { ref, className: cn.cn("space-y-2", className), ...props }));
|
|
27
|
+
Accordion.displayName = "Accordion";
|
|
28
|
+
exports.Accordion = Accordion;
|
|
29
|
+
//# sourceMappingURL=Accordion.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Accordion.cjs","sources":["../../../../src/components/Accordion/Accordion.tsx"],"sourcesContent":["import * as AccordionPrimitive from \"@radix-ui/react-accordion\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\n\n/** Props for the {@link Accordion} root component. Extends Radix `Accordion.Root` props. */\nexport type AccordionProps = React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Root>;\n\n/**\n * Root container for an accordion interface. Manages the expand/collapse state\n * and coordinates {@link AccordionItem}, {@link AccordionTrigger}, and {@link AccordionContent}.\n *\n * Built on Radix UI `Accordion`.\n *\n * @example\n * ```tsx\n * <Accordion type=\"single\" collapsible>\n * <AccordionItem value=\"item-1\">\n * <AccordionTrigger>Section 1</AccordionTrigger>\n * <AccordionContent>Content 1</AccordionContent>\n * </AccordionItem>\n * <AccordionItem value=\"item-2\">\n * <AccordionTrigger>Section 2</AccordionTrigger>\n * <AccordionContent>Content 2</AccordionContent>\n * </AccordionItem>\n * </Accordion>\n * ```\n */\nexport const Accordion = React.forwardRef<\n React.ComponentRef<typeof AccordionPrimitive.Root>,\n AccordionProps\n>(({ className, ...props }, ref) => (\n <AccordionPrimitive.Root ref={ref} className={cn(\"space-y-2\", className)} {...props} />\n));\n\nAccordion.displayName = \"Accordion\";\n"],"names":["React","jsx","AccordionPrimitive","cn"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2BO,MAAM,YAAYA,iBAAM,WAG7B,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QAC1BC,2BAAAA,IAACC,8BAAmB,MAAnB,EAAwB,KAAU,WAAWC,GAAAA,GAAG,aAAa,SAAS,GAAI,GAAG,OAAO,CACtF;AAED,UAAU,cAAc;;"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const AccordionPrimitive = require("@radix-ui/react-accordion");
|
|
6
|
+
const React = require("react");
|
|
7
|
+
const cn = require("../../utils/cn.cjs");
|
|
8
|
+
function _interopNamespaceDefault(e) {
|
|
9
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
10
|
+
if (e) {
|
|
11
|
+
for (const k in e) {
|
|
12
|
+
if (k !== "default") {
|
|
13
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: () => e[k]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
const AccordionPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(AccordionPrimitive);
|
|
25
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
26
|
+
const AccordionContent = React__namespace.forwardRef(({ className, children, noPadding, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
27
|
+
AccordionPrimitive__namespace.Content,
|
|
28
|
+
{
|
|
29
|
+
ref,
|
|
30
|
+
className: cn.cn(
|
|
31
|
+
"overflow-hidden",
|
|
32
|
+
"typography-regular-body-md text-foreground-secondary",
|
|
33
|
+
"motion-safe:data-[state=closed]:animate-accordion-collapse",
|
|
34
|
+
"motion-safe:data-[state=open]:animate-accordion-expand",
|
|
35
|
+
!noPadding && "px-3 pb-3",
|
|
36
|
+
className
|
|
37
|
+
),
|
|
38
|
+
...props,
|
|
39
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-w-0 overflow-wrap-anywhere", children })
|
|
40
|
+
}
|
|
41
|
+
));
|
|
42
|
+
AccordionContent.displayName = "AccordionContent";
|
|
43
|
+
exports.AccordionContent = AccordionContent;
|
|
44
|
+
//# sourceMappingURL=AccordionContent.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccordionContent.cjs","sources":["../../../../src/components/Accordion/AccordionContent.tsx"],"sourcesContent":["import * as AccordionPrimitive from \"@radix-ui/react-accordion\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\n\n/** Props for the {@link AccordionContent} panel component. */\nexport type AccordionContentProps = React.ComponentPropsWithoutRef<\n typeof AccordionPrimitive.Content\n> & {\n /** Remove the default inner padding (`px-3 pb-3`). Useful when you need custom content layout. */\n noPadding?: boolean;\n};\n\n/** Renders the collapsible content panel for an {@link AccordionItem}. Animates open and closed. */\nexport const AccordionContent = React.forwardRef<\n React.ComponentRef<typeof AccordionPrimitive.Content>,\n AccordionContentProps\n>(({ className, children, noPadding, ...props }, ref) => (\n <AccordionPrimitive.Content\n ref={ref}\n className={cn(\n \"overflow-hidden\",\n \"typography-regular-body-md text-foreground-secondary\",\n \"motion-safe:data-[state=closed]:animate-accordion-collapse\",\n \"motion-safe:data-[state=open]:animate-accordion-expand\",\n !noPadding && \"px-3 pb-3\",\n className,\n )}\n {...props}\n >\n <div className=\"min-w-0 overflow-wrap-anywhere\">{children}</div>\n </AccordionPrimitive.Content>\n));\n\nAccordionContent.displayName = \"AccordionContent\";\n"],"names":["React","jsx","AccordionPrimitive","cn"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAaO,MAAM,mBAAmBA,iBAAM,WAGpC,CAAC,EAAE,WAAW,UAAU,WAAW,GAAG,SAAS,QAC/CC,2BAAAA;AAAAA,EAACC,8BAAmB;AAAA,EAAnB;AAAA,IACC;AAAA,IACA,WAAWC,GAAAA;AAAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,CAAC,aAAa;AAAA,MACd;AAAA,IAAA;AAAA,IAED,GAAG;AAAA,IAEJ,UAAAF,2BAAAA,IAAC,OAAA,EAAI,WAAU,kCAAkC,SAAA,CAAS;AAAA,EAAA;AAC5D,CACD;AAED,iBAAiB,cAAc;;"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const AccordionPrimitive = require("@radix-ui/react-accordion");
|
|
6
|
+
const React = require("react");
|
|
7
|
+
const cn = require("../../utils/cn.cjs");
|
|
8
|
+
function _interopNamespaceDefault(e) {
|
|
9
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
10
|
+
if (e) {
|
|
11
|
+
for (const k in e) {
|
|
12
|
+
if (k !== "default") {
|
|
13
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: () => e[k]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
const AccordionPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(AccordionPrimitive);
|
|
25
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
26
|
+
const AccordionItem = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
27
|
+
AccordionPrimitive__namespace.Item,
|
|
28
|
+
{
|
|
29
|
+
ref,
|
|
30
|
+
className: cn.cn(
|
|
31
|
+
"overflow-hidden rounded-xl bg-surface-container",
|
|
32
|
+
"border border-neutral-200",
|
|
33
|
+
className
|
|
34
|
+
),
|
|
35
|
+
...props
|
|
36
|
+
}
|
|
37
|
+
));
|
|
38
|
+
AccordionItem.displayName = "AccordionItem";
|
|
39
|
+
exports.AccordionItem = AccordionItem;
|
|
40
|
+
//# sourceMappingURL=AccordionItem.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccordionItem.cjs","sources":["../../../../src/components/Accordion/AccordionItem.tsx"],"sourcesContent":["import * as AccordionPrimitive from \"@radix-ui/react-accordion\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\n\n/** Props for the {@link AccordionItem} component. */\nexport type AccordionItemProps = React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>;\n\n/** A single collapsible section within an {@link Accordion}. Contains an {@link AccordionTrigger} and {@link AccordionContent}. */\nexport const AccordionItem = React.forwardRef<\n React.ComponentRef<typeof AccordionPrimitive.Item>,\n AccordionItemProps\n>(({ className, ...props }, ref) => (\n <AccordionPrimitive.Item\n ref={ref}\n className={cn(\n \"overflow-hidden rounded-xl bg-surface-container\",\n \"border border-neutral-200\",\n className,\n )}\n {...props}\n />\n));\n\nAccordionItem.displayName = \"AccordionItem\";\n"],"names":["React","jsx","AccordionPrimitive","cn"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAQO,MAAM,gBAAgBA,iBAAM,WAGjC,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QAC1BC,2BAAAA;AAAAA,EAACC,8BAAmB;AAAA,EAAnB;AAAA,IACC;AAAA,IACA,WAAWC,GAAAA;AAAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,IAED,GAAG;AAAA,EAAA;AACN,CACD;AAED,cAAc,cAAc;;"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const AccordionPrimitive = require("@radix-ui/react-accordion");
|
|
6
|
+
const React = require("react");
|
|
7
|
+
const cn = require("../../utils/cn.cjs");
|
|
8
|
+
const ChevronDownIcon = require("../Icons/ChevronDownIcon.cjs");
|
|
9
|
+
function _interopNamespaceDefault(e) {
|
|
10
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
11
|
+
if (e) {
|
|
12
|
+
for (const k in e) {
|
|
13
|
+
if (k !== "default") {
|
|
14
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: () => e[k]
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
n.default = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
const AccordionPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(AccordionPrimitive);
|
|
26
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
27
|
+
const AccordionTrigger = React__namespace.forwardRef(({ className, children, icon, ...props }, ref) => {
|
|
28
|
+
const showIcon = icon !== null;
|
|
29
|
+
const iconElement = icon === void 0 ? /* @__PURE__ */ jsxRuntime.jsx(ChevronDownIcon.ChevronDownIcon, { className: "size-4 shrink-0 text-foreground-secondary" }) : icon;
|
|
30
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AccordionPrimitive__namespace.Header, { className: "flex", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
31
|
+
AccordionPrimitive__namespace.Trigger,
|
|
32
|
+
{
|
|
33
|
+
ref,
|
|
34
|
+
className: cn.cn(
|
|
35
|
+
"flex flex-1 items-center justify-between gap-3",
|
|
36
|
+
"rounded-xl px-3 py-3",
|
|
37
|
+
"typography-semibold-body-md text-foreground-default",
|
|
38
|
+
"cursor-pointer",
|
|
39
|
+
"motion-safe:transition-colors motion-safe:duration-200 motion-safe:ease-in-out",
|
|
40
|
+
"hover:bg-neutral-100",
|
|
41
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-surface-page",
|
|
42
|
+
"data-disabled:pointer-events-none data-disabled:opacity-50",
|
|
43
|
+
className
|
|
44
|
+
),
|
|
45
|
+
...props,
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate text-left", children }),
|
|
48
|
+
showIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0 motion-safe:transition-transform motion-safe:duration-200 [[data-state=open]>&]:rotate-180", children: iconElement })
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
) });
|
|
52
|
+
});
|
|
53
|
+
AccordionTrigger.displayName = "AccordionTrigger";
|
|
54
|
+
exports.AccordionTrigger = AccordionTrigger;
|
|
55
|
+
//# sourceMappingURL=AccordionTrigger.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccordionTrigger.cjs","sources":["../../../../src/components/Accordion/AccordionTrigger.tsx"],"sourcesContent":["import * as AccordionPrimitive from \"@radix-ui/react-accordion\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { ChevronDownIcon } from \"../Icons/ChevronDownIcon\";\n\n/** Props for the {@link AccordionTrigger} button component. */\nexport type AccordionTriggerProps = React.ComponentPropsWithoutRef<\n typeof AccordionPrimitive.Trigger\n> & {\n /** Custom icon element. Defaults to `ChevronDownIcon`. Pass `null` to suppress the icon entirely. */\n icon?: React.ReactNode | null;\n};\n\n/** An interactive button that toggles the visibility of its associated {@link AccordionContent} panel. */\nexport const AccordionTrigger = React.forwardRef<\n React.ComponentRef<typeof AccordionPrimitive.Trigger>,\n AccordionTriggerProps\n>(({ className, children, icon, ...props }, ref) => {\n const showIcon = icon !== null;\n const iconElement =\n icon === undefined ? (\n <ChevronDownIcon className=\"size-4 shrink-0 text-foreground-secondary\" />\n ) : (\n icon\n );\n\n return (\n <AccordionPrimitive.Header className=\"flex\">\n <AccordionPrimitive.Trigger\n ref={ref}\n className={cn(\n \"flex flex-1 items-center justify-between gap-3\",\n \"rounded-xl px-3 py-3\",\n \"typography-semibold-body-md text-foreground-default\",\n \"cursor-pointer\",\n \"motion-safe:transition-colors motion-safe:duration-200 motion-safe:ease-in-out\",\n \"hover:bg-neutral-100\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-surface-page\",\n \"data-disabled:pointer-events-none data-disabled:opacity-50\",\n className,\n )}\n {...props}\n >\n <span className=\"min-w-0 flex-1 truncate text-left\">{children}</span>\n {showIcon && (\n <span className=\"shrink-0 motion-safe:transition-transform motion-safe:duration-200 [[data-state=open]>&]:rotate-180\">\n {iconElement}\n </span>\n )}\n </AccordionPrimitive.Trigger>\n </AccordionPrimitive.Header>\n );\n});\n\nAccordionTrigger.displayName = \"AccordionTrigger\";\n"],"names":["React","ChevronDownIcon","jsx","AccordionPrimitive","jsxs","cn"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAcO,MAAM,mBAAmBA,iBAAM,WAGpC,CAAC,EAAE,WAAW,UAAU,MAAM,GAAG,MAAA,GAAS,QAAQ;AAClD,QAAM,WAAW,SAAS;AAC1B,QAAM,cACJ,SAAS,wCACNC,gBAAAA,iBAAA,EAAgB,WAAU,6CAA4C,IAEvE;AAGJ,SACEC,2BAAAA,IAACC,8BAAmB,QAAnB,EAA0B,WAAU,QACnC,UAAAC,2BAAAA;AAAAA,IAACD,8BAAmB;AAAA,IAAnB;AAAA,MACC;AAAA,MACA,WAAWE,GAAAA;AAAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,MAED,GAAG;AAAA,MAEJ,UAAA;AAAA,QAAAH,2BAAAA,IAAC,QAAA,EAAK,WAAU,qCAAqC,SAAA,CAAS;AAAA,QAC7D,YACCA,2BAAAA,IAAC,QAAA,EAAK,WAAU,uGACb,UAAA,YAAA,CACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAGN;AAEJ,CAAC;AAED,iBAAiB,cAAc;;"}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const Popover = require("@radix-ui/react-popover");
|
|
6
|
+
const React = require("react");
|
|
7
|
+
const cn = require("../../utils/cn.cjs");
|
|
8
|
+
const ChevronDownIcon = require("../Icons/ChevronDownIcon.cjs");
|
|
9
|
+
const CloseIcon = require("../Icons/CloseIcon.cjs");
|
|
10
|
+
const SpinnerIcon = require("../Icons/SpinnerIcon.cjs");
|
|
11
|
+
const AutocompleteDropdownContent = require("./AutocompleteDropdownContent.cjs");
|
|
12
|
+
const AutocompleteTag = require("./AutocompleteTag.cjs");
|
|
13
|
+
const useAutocomplete = require("./useAutocomplete.cjs");
|
|
14
|
+
function _interopNamespaceDefault(e) {
|
|
15
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
16
|
+
if (e) {
|
|
17
|
+
for (const k in e) {
|
|
18
|
+
if (k !== "default") {
|
|
19
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
20
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: () => e[k]
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
n.default = e;
|
|
28
|
+
return Object.freeze(n);
|
|
29
|
+
}
|
|
30
|
+
const Popover__namespace = /* @__PURE__ */ _interopNamespaceDefault(Popover);
|
|
31
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
32
|
+
const CONTAINER_HEIGHT = {
|
|
33
|
+
"48": "min-h-12",
|
|
34
|
+
"40": "min-h-10",
|
|
35
|
+
"32": "min-h-8"
|
|
36
|
+
};
|
|
37
|
+
const INPUT_SIZE_CLASSES = {
|
|
38
|
+
"48": "typography-regular-body-lg",
|
|
39
|
+
"40": "typography-regular-body-lg",
|
|
40
|
+
"32": "typography-regular-body-md"
|
|
41
|
+
};
|
|
42
|
+
const PADDING_CLASSES = {
|
|
43
|
+
"48": "px-4 py-1.5 gap-3",
|
|
44
|
+
"40": "px-4 py-1 gap-3",
|
|
45
|
+
"32": "px-3 py-1 gap-2"
|
|
46
|
+
};
|
|
47
|
+
function warnMissingAccessibleName(label, ariaLabel, ariaLabelledBy) {
|
|
48
|
+
if (process.env.NODE_ENV !== "production") {
|
|
49
|
+
if (!label && !ariaLabel && !ariaLabelledBy) {
|
|
50
|
+
console.warn(
|
|
51
|
+
"Autocomplete: no accessible name provided. Pass a `label`, `aria-label`, or `aria-labelledby` prop."
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const Autocomplete = React__namespace.forwardRef((props, ref) => {
|
|
57
|
+
const {
|
|
58
|
+
label,
|
|
59
|
+
"aria-label": ariaLabel,
|
|
60
|
+
"aria-labelledby": ariaLabelledby,
|
|
61
|
+
helperText,
|
|
62
|
+
size = "48",
|
|
63
|
+
error = false,
|
|
64
|
+
errorMessage,
|
|
65
|
+
placeholder,
|
|
66
|
+
leftIcon,
|
|
67
|
+
fullWidth = false,
|
|
68
|
+
disabled = false,
|
|
69
|
+
clearable = false,
|
|
70
|
+
clearAriaLabel = "Clear",
|
|
71
|
+
className,
|
|
72
|
+
loading = false,
|
|
73
|
+
loadingText,
|
|
74
|
+
emptyText = "No results",
|
|
75
|
+
renderOption,
|
|
76
|
+
renderTag
|
|
77
|
+
} = props;
|
|
78
|
+
const ac = useAutocomplete.useAutocomplete(props);
|
|
79
|
+
React__namespace.useImperativeHandle(ref, () => ac.inputRef.current);
|
|
80
|
+
warnMissingAccessibleName(label, ariaLabel, ariaLabelledby);
|
|
81
|
+
const bottomText = error && errorMessage ? errorMessage : helperText;
|
|
82
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Popover__namespace.Root, { open: ac.isOpen && !disabled, onOpenChange: ac.handleOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
83
|
+
"div",
|
|
84
|
+
{
|
|
85
|
+
className: cn.cn("flex flex-col", fullWidth && "w-full", className),
|
|
86
|
+
"data-autocomplete-root": "",
|
|
87
|
+
"data-disabled": disabled ? "" : void 0,
|
|
88
|
+
"data-error": error ? "" : void 0,
|
|
89
|
+
children: [
|
|
90
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(
|
|
91
|
+
"label",
|
|
92
|
+
{
|
|
93
|
+
htmlFor: ac.inputId,
|
|
94
|
+
className: "typography-semibold-body-sm px-1 pt-1 pb-2 text-foreground-default",
|
|
95
|
+
children: label
|
|
96
|
+
}
|
|
97
|
+
),
|
|
98
|
+
/* @__PURE__ */ jsxRuntime.jsx(Popover__namespace.Anchor, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
99
|
+
"div",
|
|
100
|
+
{
|
|
101
|
+
className: cn.cn(
|
|
102
|
+
"flex flex-wrap items-center overflow-hidden rounded-xl border bg-neutral-100 has-focus-visible:outline-none motion-safe:transition-colors",
|
|
103
|
+
error ? "border-error-default" : "border-transparent",
|
|
104
|
+
!disabled && !error && "hover:border-neutral-400",
|
|
105
|
+
ac.isOpen && !error && !disabled && "border-neutral-400",
|
|
106
|
+
CONTAINER_HEIGHT[size],
|
|
107
|
+
PADDING_CLASSES[size],
|
|
108
|
+
disabled && "opacity-50"
|
|
109
|
+
),
|
|
110
|
+
onClick: ac.handleContainerClick,
|
|
111
|
+
children: [
|
|
112
|
+
leftIcon && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-5 shrink-0 items-center justify-center text-foreground-secondary", children: leftIcon }),
|
|
113
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-1 flex-wrap items-center gap-1.5", children: [
|
|
114
|
+
ac.isMulti && ac.selectedMultiOptions.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
115
|
+
AutocompleteTag.AutocompleteTag,
|
|
116
|
+
{
|
|
117
|
+
option: opt,
|
|
118
|
+
disabled,
|
|
119
|
+
onRemove: () => ac.toggleMulti(opt.value),
|
|
120
|
+
renderTag
|
|
121
|
+
},
|
|
122
|
+
opt.value
|
|
123
|
+
)),
|
|
124
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
125
|
+
"input",
|
|
126
|
+
{
|
|
127
|
+
ref: ac.inputRef,
|
|
128
|
+
id: ac.inputId,
|
|
129
|
+
role: "combobox",
|
|
130
|
+
type: "text",
|
|
131
|
+
disabled,
|
|
132
|
+
"aria-expanded": ac.isOpen,
|
|
133
|
+
"aria-controls": ac.isOpen ? ac.listboxId : void 0,
|
|
134
|
+
"aria-activedescendant": ac.activeDescendantId,
|
|
135
|
+
"aria-autocomplete": "list",
|
|
136
|
+
"aria-describedby": bottomText ? ac.helperTextId : void 0,
|
|
137
|
+
"aria-invalid": error || void 0,
|
|
138
|
+
"aria-label": ariaLabel,
|
|
139
|
+
"aria-labelledby": ariaLabelledby,
|
|
140
|
+
autoComplete: "off",
|
|
141
|
+
placeholder: ac.isMulti && ac.selectedMultiValues.length > 0 ? void 0 : placeholder,
|
|
142
|
+
value: ac.displayInputValue,
|
|
143
|
+
onChange: ac.handleInputChange,
|
|
144
|
+
onKeyDown: ac.handleKeyDown,
|
|
145
|
+
onFocus: ac.handleFocus,
|
|
146
|
+
onBlur: ac.handleBlur,
|
|
147
|
+
className: cn.cn(
|
|
148
|
+
"min-w-[40px] flex-1 truncate rounded-xl bg-transparent text-foreground-default no-underline placeholder:text-foreground-secondary placeholder:opacity-40 focus:outline-none disabled:cursor-not-allowed",
|
|
149
|
+
INPUT_SIZE_CLASSES[size]
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
] }),
|
|
154
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [
|
|
155
|
+
loading && /* @__PURE__ */ jsxRuntime.jsx(SpinnerIcon.SpinnerIcon, { className: "size-4 animate-spin text-foreground-secondary" }),
|
|
156
|
+
clearable && ac.hasClearableValue && !disabled && /* @__PURE__ */ jsxRuntime.jsx(
|
|
157
|
+
"button",
|
|
158
|
+
{
|
|
159
|
+
type: "button",
|
|
160
|
+
tabIndex: -1,
|
|
161
|
+
"aria-label": clearAriaLabel,
|
|
162
|
+
className: "flex size-5 shrink-0 cursor-pointer items-center justify-center text-foreground-secondary hover:text-foreground-default active:scale-95",
|
|
163
|
+
onClick: ac.handleClear,
|
|
164
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon.CloseIcon, { className: "size-4" })
|
|
165
|
+
}
|
|
166
|
+
),
|
|
167
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-5 shrink-0 items-center justify-center text-foreground-secondary", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
168
|
+
ChevronDownIcon.ChevronDownIcon,
|
|
169
|
+
{
|
|
170
|
+
className: cn.cn("size-5 transition-transform", ac.isOpen && "rotate-180")
|
|
171
|
+
}
|
|
172
|
+
) })
|
|
173
|
+
] })
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
) }),
|
|
177
|
+
/* @__PURE__ */ jsxRuntime.jsx(Popover__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
178
|
+
Popover__namespace.Content,
|
|
179
|
+
{
|
|
180
|
+
sideOffset: 4,
|
|
181
|
+
collisionPadding: 8,
|
|
182
|
+
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
183
|
+
onCloseAutoFocus: (e) => e.preventDefault(),
|
|
184
|
+
style: { zIndex: "var(--fanvue-ui-portal-z-index, 50)" },
|
|
185
|
+
className: cn.cn(
|
|
186
|
+
"w-(--radix-popover-trigger-width) min-w-(--radix-popper-anchor-width) overflow-hidden rounded-xl border border-neutral-200 bg-surface-page text-foreground-default shadow-[0_4px_16px_rgba(0,0,0,0.10)]",
|
|
187
|
+
"data-[state=closed]:animate-out data-[state=open]:animate-in",
|
|
188
|
+
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
189
|
+
"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
|
|
190
|
+
"data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2"
|
|
191
|
+
),
|
|
192
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
193
|
+
"div",
|
|
194
|
+
{
|
|
195
|
+
ref: ac.listRef,
|
|
196
|
+
id: ac.listboxId,
|
|
197
|
+
role: "listbox",
|
|
198
|
+
"aria-label": label ?? ariaLabel ?? "Options",
|
|
199
|
+
"aria-multiselectable": ac.isMulti || void 0,
|
|
200
|
+
className: "max-h-60 overflow-y-auto p-1",
|
|
201
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
202
|
+
AutocompleteDropdownContent.AutocompleteDropdownContent,
|
|
203
|
+
{
|
|
204
|
+
loading,
|
|
205
|
+
loadingText,
|
|
206
|
+
emptyText,
|
|
207
|
+
visibleOptions: ac.visibleOptions,
|
|
208
|
+
listboxId: ac.listboxId,
|
|
209
|
+
activeIndex: ac.activeIndex,
|
|
210
|
+
isMulti: ac.isMulti,
|
|
211
|
+
selectedMultiValues: ac.selectedMultiValues,
|
|
212
|
+
selectedValue: ac.selectedValue,
|
|
213
|
+
onSelect: ac.handleSelect,
|
|
214
|
+
onMouseEnter: ac.setActiveIndex,
|
|
215
|
+
renderOption
|
|
216
|
+
}
|
|
217
|
+
)
|
|
218
|
+
}
|
|
219
|
+
)
|
|
220
|
+
}
|
|
221
|
+
) }),
|
|
222
|
+
bottomText && /* @__PURE__ */ jsxRuntime.jsx(
|
|
223
|
+
"p",
|
|
224
|
+
{
|
|
225
|
+
id: ac.helperTextId,
|
|
226
|
+
className: cn.cn(
|
|
227
|
+
"typography-regular-body-sm px-2 pt-1 pb-0.5",
|
|
228
|
+
error ? "text-error-default" : "text-foreground-secondary"
|
|
229
|
+
),
|
|
230
|
+
children: bottomText
|
|
231
|
+
}
|
|
232
|
+
)
|
|
233
|
+
]
|
|
234
|
+
}
|
|
235
|
+
) });
|
|
236
|
+
});
|
|
237
|
+
Autocomplete.displayName = "Autocomplete";
|
|
238
|
+
exports.Autocomplete = Autocomplete;
|
|
239
|
+
//# sourceMappingURL=Autocomplete.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Autocomplete.cjs","sources":["../../../../src/components/Autocomplete/Autocomplete.tsx"],"sourcesContent":["import * as Popover from \"@radix-ui/react-popover\";\nimport * as React from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport { ChevronDownIcon } from \"../Icons/ChevronDownIcon\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\nimport { SpinnerIcon } from \"../Icons/SpinnerIcon\";\nimport { AutocompleteDropdownContent } from \"./AutocompleteDropdownContent\";\nimport { AutocompleteTag } from \"./AutocompleteTag\";\nimport { useAutocomplete } from \"./useAutocomplete\";\n\nexport type AutocompleteSize = \"48\" | \"40\" | \"32\";\n\nexport interface AutocompleteOption {\n value: string;\n label?: string;\n disabled?: boolean;\n}\n\ninterface AutocompleteBaseProps {\n label?: string;\n \"aria-label\"?: string;\n \"aria-labelledby\"?: string;\n helperText?: string;\n /** @default \"48\" */\n size?: AutocompleteSize;\n /** @default false */\n error?: boolean;\n errorMessage?: string;\n placeholder?: string;\n leftIcon?: React.ReactNode;\n /** @default false */\n fullWidth?: boolean;\n /** @default false */\n disabled?: boolean;\n /** @default false */\n clearable?: boolean;\n clearAriaLabel?: string;\n id?: string;\n className?: string;\n options: AutocompleteOption[];\n inputValue?: string;\n onInputChange?: (value: string) => void;\n filterFn?: (option: AutocompleteOption, query: string) => boolean;\n /** @default false */\n creatable?: boolean;\n creatableLabel?: (inputValue: string) => string;\n onCreate?: (inputValue: string) => void;\n /** @default false */\n loading?: boolean;\n loadingText?: string;\n emptyText?: string;\n renderOption?: (\n option: AutocompleteOption,\n state: { selected: boolean; active: boolean },\n ) => React.ReactNode;\n renderTag?: (option: AutocompleteOption, onRemove: () => void) => React.ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n}\n\ninterface AutocompleteSingleProps extends AutocompleteBaseProps {\n multiple?: false;\n value?: string | null;\n defaultValue?: string | null;\n onChange?: (value: string | null) => void;\n}\n\ninterface AutocompleteMultiProps extends AutocompleteBaseProps {\n multiple: true;\n value?: string[];\n defaultValue?: string[];\n onChange?: (values: string[]) => void;\n}\n\nexport type AutocompleteProps = AutocompleteSingleProps | AutocompleteMultiProps;\n\nconst CONTAINER_HEIGHT: Record<AutocompleteSize, string> = {\n \"48\": \"min-h-12\",\n \"40\": \"min-h-10\",\n \"32\": \"min-h-8\",\n};\n\nconst INPUT_SIZE_CLASSES: Record<AutocompleteSize, string> = {\n \"48\": \"typography-regular-body-lg\",\n \"40\": \"typography-regular-body-lg\",\n \"32\": \"typography-regular-body-md\",\n};\n\nconst PADDING_CLASSES: Record<AutocompleteSize, string> = {\n \"48\": \"px-4 py-1.5 gap-3\",\n \"40\": \"px-4 py-1 gap-3\",\n \"32\": \"px-3 py-1 gap-2\",\n};\n\nfunction warnMissingAccessibleName(label?: string, ariaLabel?: string, ariaLabelledBy?: string) {\n if (process.env.NODE_ENV !== \"production\") {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn(\n \"Autocomplete: no accessible name provided. Pass a `label`, `aria-label`, or `aria-labelledby` prop.\",\n );\n }\n }\n}\n\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Conditional JSX branches in the render template\nexport const Autocomplete = React.forwardRef<HTMLInputElement, AutocompleteProps>((props, ref) => {\n const {\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n helperText,\n size = \"48\",\n error = false,\n errorMessage,\n placeholder,\n leftIcon,\n fullWidth = false,\n disabled = false,\n clearable = false,\n clearAriaLabel = \"Clear\",\n className,\n loading = false,\n loadingText,\n emptyText = \"No results\",\n renderOption,\n renderTag,\n } = props;\n\n const ac = useAutocomplete(props);\n\n React.useImperativeHandle(ref, () => ac.inputRef.current as HTMLInputElement);\n\n warnMissingAccessibleName(label, ariaLabel, ariaLabelledby);\n\n const bottomText = error && errorMessage ? errorMessage : helperText;\n\n return (\n <Popover.Root open={ac.isOpen && !disabled} onOpenChange={ac.handleOpenChange}>\n <div\n className={cn(\"flex flex-col\", fullWidth && \"w-full\", className)}\n data-autocomplete-root=\"\"\n data-disabled={disabled ? \"\" : undefined}\n data-error={error ? \"\" : undefined}\n >\n {label && (\n <label\n htmlFor={ac.inputId}\n className=\"typography-semibold-body-sm px-1 pt-1 pb-2 text-foreground-default\"\n >\n {label}\n </label>\n )}\n\n <Popover.Anchor asChild>\n {/* biome-ignore lint/a11y/noStaticElementInteractions: Container delegates click to the inner input */}\n {/* biome-ignore lint/a11y/useKeyWithClickEvents: Keyboard interaction is handled by the inner combobox input */}\n <div\n className={cn(\n \"flex flex-wrap items-center overflow-hidden rounded-xl border bg-neutral-100 has-focus-visible:outline-none motion-safe:transition-colors\",\n error ? \"border-error-default\" : \"border-transparent\",\n !disabled && !error && \"hover:border-neutral-400\",\n ac.isOpen && !error && !disabled && \"border-neutral-400\",\n CONTAINER_HEIGHT[size],\n PADDING_CLASSES[size],\n disabled && \"opacity-50\",\n )}\n onClick={ac.handleContainerClick}\n >\n {leftIcon && (\n <div className=\"flex size-5 shrink-0 items-center justify-center text-foreground-secondary\">\n {leftIcon}\n </div>\n )}\n\n <div className=\"flex min-w-0 flex-1 flex-wrap items-center gap-1.5\">\n {ac.isMulti &&\n ac.selectedMultiOptions.map((opt) => (\n <AutocompleteTag\n key={opt.value}\n option={opt}\n disabled={disabled}\n onRemove={() => ac.toggleMulti(opt.value)}\n renderTag={renderTag}\n />\n ))}\n\n <input\n ref={ac.inputRef}\n id={ac.inputId}\n role=\"combobox\"\n type=\"text\"\n disabled={disabled}\n aria-expanded={ac.isOpen}\n aria-controls={ac.isOpen ? ac.listboxId : undefined}\n aria-activedescendant={ac.activeDescendantId}\n aria-autocomplete=\"list\"\n aria-describedby={bottomText ? ac.helperTextId : undefined}\n aria-invalid={error || undefined}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n autoComplete=\"off\"\n placeholder={\n ac.isMulti && ac.selectedMultiValues.length > 0 ? undefined : placeholder\n }\n value={ac.displayInputValue}\n onChange={ac.handleInputChange}\n onKeyDown={ac.handleKeyDown}\n onFocus={ac.handleFocus}\n onBlur={ac.handleBlur}\n className={cn(\n \"min-w-[40px] flex-1 truncate rounded-xl bg-transparent text-foreground-default no-underline placeholder:text-foreground-secondary placeholder:opacity-40 focus:outline-none disabled:cursor-not-allowed\",\n INPUT_SIZE_CLASSES[size],\n )}\n />\n </div>\n\n <div className=\"flex shrink-0 items-center gap-1\">\n {loading && <SpinnerIcon className=\"size-4 animate-spin text-foreground-secondary\" />}\n {clearable && ac.hasClearableValue && !disabled && (\n <button\n type=\"button\"\n tabIndex={-1}\n aria-label={clearAriaLabel}\n className=\"flex size-5 shrink-0 cursor-pointer items-center justify-center text-foreground-secondary hover:text-foreground-default active:scale-95\"\n onClick={ac.handleClear}\n >\n <CloseIcon className=\"size-4\" />\n </button>\n )}\n <div className=\"flex size-5 shrink-0 items-center justify-center text-foreground-secondary\">\n <ChevronDownIcon\n className={cn(\"size-5 transition-transform\", ac.isOpen && \"rotate-180\")}\n />\n </div>\n </div>\n </div>\n </Popover.Anchor>\n\n <Popover.Portal>\n <Popover.Content\n sideOffset={4}\n collisionPadding={8}\n onOpenAutoFocus={(e) => e.preventDefault()}\n onCloseAutoFocus={(e) => e.preventDefault()}\n style={{ zIndex: \"var(--fanvue-ui-portal-z-index, 50)\" }}\n className={cn(\n \"w-(--radix-popover-trigger-width) min-w-(--radix-popper-anchor-width) overflow-hidden rounded-xl border border-neutral-200 bg-surface-page text-foreground-default shadow-[0_4px_16px_rgba(0,0,0,0.10)]\",\n \"data-[state=closed]:animate-out data-[state=open]:animate-in\",\n \"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n \"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95\",\n \"data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2\",\n )}\n >\n <div\n ref={ac.listRef}\n id={ac.listboxId}\n role=\"listbox\"\n aria-label={label ?? ariaLabel ?? \"Options\"}\n aria-multiselectable={ac.isMulti || undefined}\n className=\"max-h-60 overflow-y-auto p-1\"\n >\n <AutocompleteDropdownContent\n loading={loading}\n loadingText={loadingText}\n emptyText={emptyText}\n visibleOptions={ac.visibleOptions}\n listboxId={ac.listboxId}\n activeIndex={ac.activeIndex}\n isMulti={ac.isMulti}\n selectedMultiValues={ac.selectedMultiValues}\n selectedValue={ac.selectedValue}\n onSelect={ac.handleSelect}\n onMouseEnter={ac.setActiveIndex}\n renderOption={renderOption}\n />\n </div>\n </Popover.Content>\n </Popover.Portal>\n\n {bottomText && (\n <p\n id={ac.helperTextId}\n className={cn(\n \"typography-regular-body-sm px-2 pt-1 pb-0.5\",\n error ? \"text-error-default\" : \"text-foreground-secondary\",\n )}\n >\n {bottomText}\n </p>\n )}\n </div>\n </Popover.Root>\n );\n});\n\nAutocomplete.displayName = \"Autocomplete\";\n"],"names":["React","useAutocomplete","jsx","Popover","jsxs","cn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use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const SpinnerIcon = require("../Icons/SpinnerIcon.cjs");
|
|
6
|
+
const AutocompleteOptionItem = require("./AutocompleteOptionItem.cjs");
|
|
7
|
+
function AutocompleteDropdownContent({
|
|
8
|
+
loading,
|
|
9
|
+
loadingText,
|
|
10
|
+
emptyText,
|
|
11
|
+
visibleOptions,
|
|
12
|
+
listboxId,
|
|
13
|
+
activeIndex,
|
|
14
|
+
isMulti,
|
|
15
|
+
selectedMultiValues,
|
|
16
|
+
selectedValue,
|
|
17
|
+
onSelect,
|
|
18
|
+
onMouseEnter,
|
|
19
|
+
renderOption
|
|
20
|
+
}) {
|
|
21
|
+
if (loading) {
|
|
22
|
+
return (
|
|
23
|
+
// biome-ignore lint/a11y/useSemanticElements: <output> is not appropriate here; using role="status" for live region announcements
|
|
24
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { role: "status", className: "flex items-center justify-center py-4", children: [
|
|
25
|
+
/* @__PURE__ */ jsxRuntime.jsx(SpinnerIcon.SpinnerIcon, { className: "size-5 animate-spin text-foreground-secondary" }),
|
|
26
|
+
loadingText && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "typography-regular-body-md ml-2 text-foreground-secondary", children: loadingText })
|
|
27
|
+
] })
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
if (visibleOptions.length === 0) {
|
|
31
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "typography-regular-body-md block px-3 py-4 text-center text-foreground-secondary", children: emptyText });
|
|
32
|
+
}
|
|
33
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: visibleOptions.map((option, index) => {
|
|
34
|
+
const isSelected = isMulti ? selectedMultiValues.includes(option.value) : option.value === selectedValue;
|
|
35
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
36
|
+
AutocompleteOptionItem.AutocompleteOptionItem,
|
|
37
|
+
{
|
|
38
|
+
option,
|
|
39
|
+
optionId: `${listboxId}-option-${index}`,
|
|
40
|
+
index,
|
|
41
|
+
isSelected,
|
|
42
|
+
isActive: index === activeIndex,
|
|
43
|
+
onSelect: () => onSelect(option),
|
|
44
|
+
onMouseEnter: () => onMouseEnter(index),
|
|
45
|
+
renderOption
|
|
46
|
+
},
|
|
47
|
+
option.value
|
|
48
|
+
);
|
|
49
|
+
}) });
|
|
50
|
+
}
|
|
51
|
+
exports.AutocompleteDropdownContent = AutocompleteDropdownContent;
|
|
52
|
+
//# sourceMappingURL=AutocompleteDropdownContent.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutocompleteDropdownContent.cjs","sources":["../../../../src/components/Autocomplete/AutocompleteDropdownContent.tsx"],"sourcesContent":["import type * as React from \"react\";\nimport { SpinnerIcon } from \"../Icons/SpinnerIcon\";\nimport type { AutocompleteOption } from \"./Autocomplete\";\nimport { AutocompleteOptionItem } from \"./AutocompleteOptionItem\";\n\nexport function AutocompleteDropdownContent({\n loading,\n loadingText,\n emptyText,\n visibleOptions,\n listboxId,\n activeIndex,\n isMulti,\n selectedMultiValues,\n selectedValue,\n onSelect,\n onMouseEnter,\n renderOption,\n}: {\n loading: boolean;\n loadingText?: string;\n emptyText?: string;\n visibleOptions: AutocompleteOption[];\n listboxId: string;\n activeIndex: number;\n isMulti: boolean;\n selectedMultiValues: string[];\n selectedValue: string | null;\n onSelect: (option: AutocompleteOption) => void;\n onMouseEnter: (index: number) => void;\n renderOption?: (\n option: AutocompleteOption,\n state: { selected: boolean; active: boolean },\n ) => React.ReactNode;\n}) {\n if (loading) {\n return (\n // biome-ignore lint/a11y/useSemanticElements: <output> is not appropriate here; using role=\"status\" for live region announcements\n <div role=\"status\" className=\"flex items-center justify-center py-4\">\n <SpinnerIcon className=\"size-5 animate-spin text-foreground-secondary\" />\n {loadingText && (\n <span className=\"typography-regular-body-md ml-2 text-foreground-secondary\">\n {loadingText}\n </span>\n )}\n </div>\n );\n }\n\n if (visibleOptions.length === 0) {\n return (\n <div className=\"typography-regular-body-md block px-3 py-4 text-center text-foreground-secondary\">\n {emptyText}\n </div>\n );\n }\n\n return (\n <>\n {visibleOptions.map((option, index) => {\n const isSelected = isMulti\n ? selectedMultiValues.includes(option.value)\n : option.value === selectedValue;\n\n return (\n <AutocompleteOptionItem\n key={option.value}\n option={option}\n optionId={`${listboxId}-option-${index}`}\n index={index}\n isSelected={isSelected}\n isActive={index === activeIndex}\n onSelect={() => onSelect(option)}\n onMouseEnter={() => onMouseEnter(index)}\n renderOption={renderOption}\n />\n );\n })}\n </>\n );\n}\n"],"names":["jsxs","jsx","SpinnerIcon","Fragment","AutocompleteOptionItem"],"mappings":";;;;;;AAKO,SAAS,4BAA4B;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAgBG;AACD,MAAI,SAAS;AACX;AAAA;AAAA,MAEEA,2BAAAA,KAAC,OAAA,EAAI,MAAK,UAAS,WAAU,yCAC3B,UAAA;AAAA,QAAAC,2BAAAA,IAACC,YAAAA,aAAA,EAAY,WAAU,gDAAA,CAAgD;AAAA,QACtE,eACCD,2BAAAA,IAAC,QAAA,EAAK,WAAU,6DACb,UAAA,YAAA,CACH;AAAA,MAAA,EAAA,CAEJ;AAAA;AAAA,EAEJ;AAEA,MAAI,eAAe,WAAW,GAAG;AAC/B,WACEA,2BAAAA,IAAC,OAAA,EAAI,WAAU,oFACZ,UAAA,WACH;AAAA,EAEJ;AAEA,SACEA,2BAAAA,IAAAE,WAAAA,UAAA,EACG,UAAA,eAAe,IAAI,CAAC,QAAQ,UAAU;AACrC,UAAM,aAAa,UACf,oBAAoB,SAAS,OAAO,KAAK,IACzC,OAAO,UAAU;AAErB,WACEF,2BAAAA;AAAAA,MAACG,uBAAAA;AAAAA,MAAA;AAAA,QAEC;AAAA,QACA,UAAU,GAAG,SAAS,WAAW,KAAK;AAAA,QACtC;AAAA,QACA;AAAA,QACA,UAAU,UAAU;AAAA,QACpB,UAAU,MAAM,SAAS,MAAM;AAAA,QAC/B,cAAc,MAAM,aAAa,KAAK;AAAA,QACtC;AAAA,MAAA;AAAA,MARK,OAAO;AAAA,IAAA;AAAA,EAWlB,CAAC,EAAA,CACH;AAEJ;;"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const cn = require("../../utils/cn.cjs");
|
|
6
|
+
const CheckIcon = require("../Icons/CheckIcon.cjs");
|
|
7
|
+
const constants = require("./constants.cjs");
|
|
8
|
+
function AutocompleteOptionItem({
|
|
9
|
+
option,
|
|
10
|
+
optionId,
|
|
11
|
+
index,
|
|
12
|
+
isSelected,
|
|
13
|
+
isActive,
|
|
14
|
+
onSelect,
|
|
15
|
+
onMouseEnter,
|
|
16
|
+
renderOption
|
|
17
|
+
}) {
|
|
18
|
+
const isCreate = option.value.startsWith(constants.CREATE_PREFIX);
|
|
19
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
20
|
+
"div",
|
|
21
|
+
{
|
|
22
|
+
id: optionId,
|
|
23
|
+
role: "option",
|
|
24
|
+
tabIndex: -1,
|
|
25
|
+
"aria-selected": isSelected,
|
|
26
|
+
"aria-disabled": option.disabled || void 0,
|
|
27
|
+
"data-option-index": index,
|
|
28
|
+
className: cn.cn(
|
|
29
|
+
"typography-regular-body-lg relative flex w-full cursor-pointer select-none items-center gap-2 rounded-lg py-2 pr-2 pl-3 text-foreground-default outline-none",
|
|
30
|
+
isActive && "bg-neutral-100",
|
|
31
|
+
option.disabled && "pointer-events-none opacity-50",
|
|
32
|
+
isCreate && "italic"
|
|
33
|
+
),
|
|
34
|
+
onMouseEnter,
|
|
35
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
36
|
+
onClick: () => {
|
|
37
|
+
if (!option.disabled) onSelect();
|
|
38
|
+
},
|
|
39
|
+
onKeyDown: (e) => {
|
|
40
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
if (!option.disabled) onSelect();
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
children: renderOption ? renderOption(option, { selected: isSelected, active: isActive }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
46
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children: constants.getLabel(option) }),
|
|
47
|
+
isSelected && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-auto flex size-4 shrink-0 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(CheckIcon.CheckIcon, { className: "size-4 text-foreground-default" }) })
|
|
48
|
+
] })
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
exports.AutocompleteOptionItem = AutocompleteOptionItem;
|
|
53
|
+
//# sourceMappingURL=AutocompleteOptionItem.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutocompleteOptionItem.cjs","sources":["../../../../src/components/Autocomplete/AutocompleteOptionItem.tsx"],"sourcesContent":["import type * as React from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport { CheckIcon } from \"../Icons/CheckIcon\";\nimport type { AutocompleteOption } from \"./Autocomplete\";\nimport { CREATE_PREFIX, getLabel } from \"./constants\";\n\nexport function AutocompleteOptionItem({\n option,\n optionId,\n index,\n isSelected,\n isActive,\n onSelect,\n onMouseEnter,\n renderOption,\n}: {\n option: AutocompleteOption;\n optionId: string;\n index: number;\n isSelected: boolean;\n isActive: boolean;\n onSelect: () => void;\n onMouseEnter: () => void;\n renderOption?: (\n option: AutocompleteOption,\n state: { selected: boolean; active: boolean },\n ) => React.ReactNode;\n}) {\n const isCreate = option.value.startsWith(CREATE_PREFIX);\n\n return (\n <div\n id={optionId}\n role=\"option\"\n tabIndex={-1}\n aria-selected={isSelected}\n aria-disabled={option.disabled || undefined}\n data-option-index={index}\n className={cn(\n \"typography-regular-body-lg relative flex w-full cursor-pointer select-none items-center gap-2 rounded-lg py-2 pr-2 pl-3 text-foreground-default outline-none\",\n isActive && \"bg-neutral-100\",\n option.disabled && \"pointer-events-none opacity-50\",\n isCreate && \"italic\",\n )}\n onMouseEnter={onMouseEnter}\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => {\n if (!option.disabled) onSelect();\n }}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n if (!option.disabled) onSelect();\n }\n }}\n >\n {renderOption ? (\n renderOption(option, { selected: isSelected, active: isActive })\n ) : (\n <>\n <span className=\"min-w-0 flex-1 truncate\">{getLabel(option)}</span>\n {isSelected && (\n <span className=\"ml-auto flex size-4 shrink-0 items-center justify-center\">\n <CheckIcon className=\"size-4 text-foreground-default\" />\n </span>\n )}\n </>\n )}\n </div>\n );\n}\n"],"names":["CREATE_PREFIX","jsx","cn","jsxs","Fragment","getLabel","CheckIcon"],"mappings":";;;;;;;AAMO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAYG;AACD,QAAM,WAAW,OAAO,MAAM,WAAWA,UAAAA,aAAa;AAEtD,SACEC,2BAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,IAAI;AAAA,MACJ,MAAK;AAAA,MACL,UAAU;AAAA,MACV,iBAAe;AAAA,MACf,iBAAe,OAAO,YAAY;AAAA,MAClC,qBAAmB;AAAA,MACnB,WAAWC,GAAAA;AAAAA,QACT;AAAA,QACA,YAAY;AAAA,QACZ,OAAO,YAAY;AAAA,QACnB,YAAY;AAAA,MAAA;AAAA,MAEd;AAAA,MACA,aAAa,CAAC,MAAM,EAAE,eAAA;AAAA,MACtB,SAAS,MAAM;AACb,YAAI,CAAC,OAAO,SAAU,UAAA;AAAA,MACxB;AAAA,MACA,WAAW,CAAC,MAAM;AAChB,YAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK;AACtC,YAAE,eAAA;AACF,cAAI,CAAC,OAAO,SAAU,UAAA;AAAA,QACxB;AAAA,MACF;AAAA,MAEC,UAAA,eACC,aAAa,QAAQ,EAAE,UAAU,YAAY,QAAQ,SAAA,CAAU,IAE/DC,2BAAAA,KAAAC,WAAAA,UAAA,EACE,UAAA;AAAA,QAAAH,+BAAC,QAAA,EAAK,WAAU,2BAA2B,UAAAI,UAAAA,SAAS,MAAM,GAAE;AAAA,QAC3D,6CACE,QAAA,EAAK,WAAU,4DACd,UAAAJ,2BAAAA,IAACK,UAAAA,WAAA,EAAU,WAAU,iCAAA,CAAiC,EAAA,CACxD;AAAA,MAAA,EAAA,CAEJ;AAAA,IAAA;AAAA,EAAA;AAIR;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const CloseIcon = require("../Icons/CloseIcon.cjs");
|
|
6
|
+
const constants = require("./constants.cjs");
|
|
7
|
+
function AutocompleteTag({
|
|
8
|
+
option,
|
|
9
|
+
disabled,
|
|
10
|
+
onRemove,
|
|
11
|
+
renderTag
|
|
12
|
+
}) {
|
|
13
|
+
if (renderTag) {
|
|
14
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { children: renderTag(option, onRemove) });
|
|
15
|
+
}
|
|
16
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "typography-regular-body-sm inline-flex max-w-full items-center gap-1 rounded-md bg-neutral-200 px-2 py-0.5 text-foreground-default", children: [
|
|
17
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: constants.getLabel(option) }),
|
|
18
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
19
|
+
"button",
|
|
20
|
+
{
|
|
21
|
+
type: "button",
|
|
22
|
+
tabIndex: -1,
|
|
23
|
+
"aria-label": `Remove ${constants.getLabel(option)}`,
|
|
24
|
+
className: "flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-sm text-foreground-secondary hover:text-foreground-default active:scale-95",
|
|
25
|
+
onClick: (e) => {
|
|
26
|
+
e.stopPropagation();
|
|
27
|
+
onRemove();
|
|
28
|
+
},
|
|
29
|
+
disabled,
|
|
30
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon.CloseIcon, { className: "size-3" })
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
] });
|
|
34
|
+
}
|
|
35
|
+
exports.AutocompleteTag = AutocompleteTag;
|
|
36
|
+
//# sourceMappingURL=AutocompleteTag.cjs.map
|