@yamada-ui/autocomplete 1.5.1 → 1.5.2-dev-20240917033401

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/autocomplete-context.d.mts +210 -0
  2. package/dist/autocomplete-context.d.ts +210 -0
  3. package/dist/autocomplete-context.js +53 -0
  4. package/dist/autocomplete-context.js.map +1 -0
  5. package/dist/autocomplete-context.mjs +18 -0
  6. package/dist/autocomplete-context.mjs.map +1 -0
  7. package/dist/autocomplete-create.d.mts +4 -3
  8. package/dist/autocomplete-create.d.ts +4 -3
  9. package/dist/autocomplete-create.js +56 -61
  10. package/dist/autocomplete-create.js.map +1 -1
  11. package/dist/autocomplete-create.mjs +4 -1
  12. package/dist/autocomplete-empty.d.mts +4 -3
  13. package/dist/autocomplete-empty.d.ts +4 -3
  14. package/dist/autocomplete-empty.js +54 -59
  15. package/dist/autocomplete-empty.js.map +1 -1
  16. package/dist/autocomplete-empty.mjs +4 -1
  17. package/dist/autocomplete-icon.d.mts +6 -4
  18. package/dist/autocomplete-icon.d.ts +6 -4
  19. package/dist/autocomplete-icon.js +15 -22
  20. package/dist/autocomplete-icon.js.map +1 -1
  21. package/dist/autocomplete-icon.mjs +2 -1
  22. package/dist/autocomplete-list.d.mts +2 -2
  23. package/dist/autocomplete-list.d.ts +2 -2
  24. package/dist/autocomplete-list.js +20 -23
  25. package/dist/autocomplete-list.js.map +1 -1
  26. package/dist/autocomplete-list.mjs +3 -1
  27. package/dist/autocomplete-option-group.d.mts +5 -9
  28. package/dist/autocomplete-option-group.d.ts +5 -9
  29. package/dist/autocomplete-option-group.js +14 -16
  30. package/dist/autocomplete-option-group.js.map +1 -1
  31. package/dist/autocomplete-option-group.mjs +3 -1
  32. package/dist/autocomplete-option.d.mts +15 -8
  33. package/dist/autocomplete-option.d.ts +15 -8
  34. package/dist/autocomplete-option.js +97 -102
  35. package/dist/autocomplete-option.js.map +1 -1
  36. package/dist/autocomplete-option.mjs +4 -1
  37. package/dist/autocomplete.d.mts +13 -7
  38. package/dist/autocomplete.d.ts +13 -7
  39. package/dist/autocomplete.js +673 -661
  40. package/dist/autocomplete.js.map +1 -1
  41. package/dist/autocomplete.mjs +12 -1
  42. package/dist/chunk-7GCVSXCV.mjs +190 -0
  43. package/dist/chunk-7GCVSXCV.mjs.map +1 -0
  44. package/dist/chunk-BD7VZQOL.mjs +267 -0
  45. package/dist/chunk-BD7VZQOL.mjs.map +1 -0
  46. package/dist/chunk-FZM3BH3D.mjs +57 -0
  47. package/dist/chunk-FZM3BH3D.mjs.map +1 -0
  48. package/dist/chunk-GM7RV2YY.mjs +959 -0
  49. package/dist/chunk-GM7RV2YY.mjs.map +1 -0
  50. package/dist/chunk-GOMUH7TZ.mjs +60 -0
  51. package/dist/chunk-GOMUH7TZ.mjs.map +1 -0
  52. package/dist/chunk-HL2KEBRX.mjs +87 -0
  53. package/dist/chunk-HL2KEBRX.mjs.map +1 -0
  54. package/dist/chunk-JMX72TSD.mjs +78 -0
  55. package/dist/chunk-JMX72TSD.mjs.map +1 -0
  56. package/dist/chunk-JPUKYLBW.mjs +25 -0
  57. package/dist/chunk-JPUKYLBW.mjs.map +1 -0
  58. package/dist/chunk-JXFXCGZK.mjs +102 -0
  59. package/dist/chunk-JXFXCGZK.mjs.map +1 -0
  60. package/dist/chunk-KCALQJLK.mjs +59 -0
  61. package/dist/chunk-KCALQJLK.mjs.map +1 -0
  62. package/dist/chunk-PRDD3JJO.mjs +202 -0
  63. package/dist/chunk-PRDD3JJO.mjs.map +1 -0
  64. package/dist/chunk-QGOCVO2C.mjs +68 -0
  65. package/dist/chunk-QGOCVO2C.mjs.map +1 -0
  66. package/dist/chunk-QQFSHTTC.mjs +59 -0
  67. package/dist/chunk-QQFSHTTC.mjs.map +1 -0
  68. package/dist/index.d.mts +4 -1
  69. package/dist/index.d.ts +4 -1
  70. package/dist/index.js +1550 -1536
  71. package/dist/index.js.map +1 -1
  72. package/dist/index.mjs +23 -6
  73. package/dist/multi-autocomplete.d.mts +13 -7
  74. package/dist/multi-autocomplete.d.ts +13 -7
  75. package/dist/multi-autocomplete.js +1516 -1504
  76. package/dist/multi-autocomplete.js.map +1 -1
  77. package/dist/multi-autocomplete.mjs +12 -1
  78. package/dist/use-autocomplete-list.d.mts +8 -0
  79. package/dist/use-autocomplete-list.d.ts +8 -0
  80. package/dist/use-autocomplete-list.js +103 -0
  81. package/dist/use-autocomplete-list.js.map +1 -0
  82. package/dist/use-autocomplete-list.mjs +9 -0
  83. package/dist/use-autocomplete-list.mjs.map +1 -0
  84. package/dist/use-autocomplete-option-group.d.mts +16 -0
  85. package/dist/use-autocomplete-option-group.d.ts +16 -0
  86. package/dist/use-autocomplete-option-group.js +113 -0
  87. package/dist/use-autocomplete-option-group.js.map +1 -0
  88. package/dist/use-autocomplete-option-group.mjs +9 -0
  89. package/dist/use-autocomplete-option-group.mjs.map +1 -0
  90. package/dist/use-autocomplete-option.d.mts +49 -0
  91. package/dist/use-autocomplete-option.d.ts +49 -0
  92. package/dist/use-autocomplete-option.js +231 -0
  93. package/dist/use-autocomplete-option.js.map +1 -0
  94. package/dist/use-autocomplete-option.mjs +13 -0
  95. package/dist/use-autocomplete-option.mjs.map +1 -0
  96. package/dist/use-autocomplete.d.mts +188 -8
  97. package/dist/use-autocomplete.d.ts +188 -8
  98. package/dist/use-autocomplete.js +359 -481
  99. package/dist/use-autocomplete.js.map +1 -1
  100. package/dist/use-autocomplete.mjs +9 -25
  101. package/package.json +13 -13
  102. package/dist/chunk-ZD25NCFE.mjs +0 -2038
  103. package/dist/chunk-ZD25NCFE.mjs.map +0 -1
  104. package/dist/use-autocomplete-BJNWa6hL.d.mts +0 -389
  105. package/dist/use-autocomplete-BJNWa6hL.d.ts +0 -389
@@ -0,0 +1,190 @@
1
+ "use client"
2
+ import {
3
+ useAutocomplete,
4
+ useAutocompleteInput
5
+ } from "./chunk-GM7RV2YY.mjs";
6
+ import {
7
+ AutocompleteCreate
8
+ } from "./chunk-KCALQJLK.mjs";
9
+ import {
10
+ AutocompleteEmpty
11
+ } from "./chunk-GOMUH7TZ.mjs";
12
+ import {
13
+ AutocompleteList
14
+ } from "./chunk-HL2KEBRX.mjs";
15
+ import {
16
+ AutocompleteIcon
17
+ } from "./chunk-JXFXCGZK.mjs";
18
+ import {
19
+ AutocompleteDescendantsContextProvider,
20
+ AutocompleteProvider,
21
+ useAutocompleteContext
22
+ } from "./chunk-JPUKYLBW.mjs";
23
+
24
+ // src/autocomplete.tsx
25
+ import {
26
+ ui,
27
+ forwardRef,
28
+ useComponentMultiStyle,
29
+ omitThemeProps
30
+ } from "@yamada-ui/core";
31
+ import { Popover, PopoverTrigger } from "@yamada-ui/popover";
32
+ import { Portal } from "@yamada-ui/portal";
33
+ import { cx, runIfFunc } from "@yamada-ui/utils";
34
+ import { jsx, jsxs } from "react/jsx-runtime";
35
+ var Autocomplete = forwardRef(
36
+ (props, ref) => {
37
+ const [styles, mergedProps] = useComponentMultiStyle("Autocomplete", props);
38
+ let {
39
+ className,
40
+ defaultValue = "",
41
+ color,
42
+ h,
43
+ height,
44
+ minH,
45
+ minHeight,
46
+ containerProps,
47
+ contentProps,
48
+ listProps,
49
+ fieldProps,
50
+ inputProps,
51
+ iconProps,
52
+ portalProps = { isDisabled: true },
53
+ createProps,
54
+ emptyProps,
55
+ header,
56
+ footer,
57
+ children,
58
+ ...computedProps
59
+ } = omitThemeProps(mergedProps);
60
+ const {
61
+ value,
62
+ onClose,
63
+ descendants,
64
+ formControlProps,
65
+ getPopoverProps,
66
+ getContainerProps,
67
+ getFieldProps,
68
+ allowCreate,
69
+ isEmpty,
70
+ inputValue,
71
+ computedChildren,
72
+ ...rest
73
+ } = useAutocomplete({ ...computedProps, defaultValue, children });
74
+ h != null ? h : h = height;
75
+ minH != null ? minH : minH = minHeight;
76
+ const css = {
77
+ w: "100%",
78
+ h: "fit-content",
79
+ color,
80
+ ...styles.container
81
+ };
82
+ return /* @__PURE__ */ jsx(AutocompleteDescendantsContextProvider, { value: descendants, children: /* @__PURE__ */ jsx(
83
+ AutocompleteProvider,
84
+ {
85
+ value: {
86
+ ...rest,
87
+ value,
88
+ onClose,
89
+ formControlProps,
90
+ inputValue,
91
+ allowCreate,
92
+ isEmpty,
93
+ styles
94
+ },
95
+ children: /* @__PURE__ */ jsx(Popover, { ...getPopoverProps(), children: /* @__PURE__ */ jsxs(
96
+ ui.div,
97
+ {
98
+ className: cx("ui-autocomplete", className),
99
+ __css: css,
100
+ ...getContainerProps(containerProps),
101
+ children: [
102
+ /* @__PURE__ */ jsxs(
103
+ ui.div,
104
+ {
105
+ className: "ui-autocomplete__inner",
106
+ __css: { position: "relative", ...styles.inner },
107
+ children: [
108
+ /* @__PURE__ */ jsx(
109
+ AutocompleteField,
110
+ {
111
+ h,
112
+ minH,
113
+ inputProps,
114
+ ...getFieldProps(fieldProps, ref)
115
+ }
116
+ ),
117
+ /* @__PURE__ */ jsx(AutocompleteIcon, { ...iconProps, ...formControlProps })
118
+ ]
119
+ }
120
+ ),
121
+ !isEmpty ? /* @__PURE__ */ jsx(Portal, { ...portalProps, children: /* @__PURE__ */ jsxs(
122
+ AutocompleteList,
123
+ {
124
+ header: runIfFunc(header, { value, onClose }),
125
+ footer: runIfFunc(footer, { value, onClose }),
126
+ contentProps,
127
+ ...listProps,
128
+ children: [
129
+ allowCreate ? /* @__PURE__ */ jsx(AutocompleteCreate, { ...createProps }) : /* @__PURE__ */ jsx(AutocompleteEmpty, { ...emptyProps }),
130
+ children != null ? children : computedChildren
131
+ ]
132
+ }
133
+ ) }) : /* @__PURE__ */ jsx(Portal, { ...portalProps, children: /* @__PURE__ */ jsx(
134
+ AutocompleteList,
135
+ {
136
+ header: runIfFunc(header, { value, onClose }),
137
+ footer: runIfFunc(footer, { value, onClose }),
138
+ contentProps,
139
+ ...listProps,
140
+ children: allowCreate && inputValue ? /* @__PURE__ */ jsx(AutocompleteCreate, { ...createProps }) : /* @__PURE__ */ jsx(AutocompleteEmpty, { ...emptyProps })
141
+ }
142
+ ) })
143
+ ]
144
+ }
145
+ ) })
146
+ }
147
+ ) });
148
+ }
149
+ );
150
+ var AutocompleteField = forwardRef(
151
+ ({ className, h, minH, placeholder, inputProps, ...rest }, ref) => {
152
+ const { label, inputValue, styles } = useAutocompleteContext();
153
+ const { getInputProps } = useAutocompleteInput();
154
+ const css = {
155
+ pe: "2rem",
156
+ h,
157
+ minH,
158
+ display: "flex",
159
+ alignItems: "center",
160
+ ...styles.field,
161
+ cursor: "text"
162
+ };
163
+ return /* @__PURE__ */ jsx(PopoverTrigger, { children: /* @__PURE__ */ jsx(
164
+ ui.div,
165
+ {
166
+ className: cx("ui-autocomplete__field", className),
167
+ __css: css,
168
+ ...rest,
169
+ children: /* @__PURE__ */ jsx(
170
+ ui.input,
171
+ {
172
+ className: "ui-autocomplete__field__input",
173
+ display: "inline-block",
174
+ w: "100%",
175
+ placeholder,
176
+ ...getInputProps(
177
+ { ...inputProps, value: inputValue || label || "" },
178
+ ref
179
+ )
180
+ }
181
+ )
182
+ }
183
+ ) });
184
+ }
185
+ );
186
+
187
+ export {
188
+ Autocomplete
189
+ };
190
+ //# sourceMappingURL=chunk-7GCVSXCV.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/autocomplete.tsx"],"sourcesContent":["import type { CSSUIObject, HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport {\n ui,\n forwardRef,\n useComponentMultiStyle,\n omitThemeProps,\n} from \"@yamada-ui/core\"\nimport type { MotionProps } from \"@yamada-ui/motion\"\nimport { Popover, PopoverTrigger } from \"@yamada-ui/popover\"\nimport { Portal } from \"@yamada-ui/portal\"\nimport type { PortalProps } from \"@yamada-ui/portal\"\nimport { cx, runIfFunc } from \"@yamada-ui/utils\"\nimport type { FC, ReactNode } from \"react\"\nimport {\n AutocompleteDescendantsContextProvider,\n AutocompleteProvider,\n useAutocompleteContext,\n} from \"./autocomplete-context\"\nimport { AutocompleteCreate } from \"./autocomplete-create\"\nimport type { AutocompleteCreateProps } from \"./autocomplete-create\"\nimport { AutocompleteEmpty } from \"./autocomplete-empty\"\nimport type { AutocompleteEmptyProps } from \"./autocomplete-empty\"\nimport type { AutocompleteIconProps } from \"./autocomplete-icon\"\nimport { AutocompleteIcon } from \"./autocomplete-icon\"\nimport type { AutocompleteListProps } from \"./autocomplete-list\"\nimport { AutocompleteList } from \"./autocomplete-list\"\nimport type { UseAutocompleteProps } from \"./use-autocomplete\"\nimport { useAutocomplete, useAutocompleteInput } from \"./use-autocomplete\"\n\ninterface AutocompleteOptions {\n /**\n * The border color when the input is focused.\n */\n focusBorderColor?: string\n /**\n * The border color when the input is invalid.\n */\n errorBorderColor?: string\n /**\n * Props for autocomplete container element.\n */\n containerProps?: Omit<HTMLUIProps, \"children\">\n /**\n * Props for autocomplete content element.\n */\n contentProps?: Omit<MotionProps, \"children\">\n /**\n * Props for autocomplete list element.\n */\n listProps?: Omit<AutocompleteListProps, \"children\">\n /**\n * Props for autocomplete field element.\n */\n fieldProps?: Omit<AutocompleteFieldProps, \"inputProps\" | \"children\">\n /**\n * Props for autocomplete input element.\n */\n inputProps?: HTMLUIProps<\"input\">\n /**\n * Props for autocomplete icon element.\n */\n iconProps?: AutocompleteIconProps\n /**\n * Props to be forwarded to the portal component.\n *\n * @default '{ isDisabled: true }'\n */\n portalProps?: Omit<PortalProps, \"children\">\n /**\n * Props for autocomplete create element.\n */\n createProps?: Omit<AutocompleteCreateProps, \"children\">\n /**\n * Props for autocomplete empty element.\n */\n emptyProps?: Omit<AutocompleteEmptyProps, \"children\">\n /**\n * The header of the autocomplete content element.\n */\n header?: ReactNode | FC<{ value: string | undefined; onClose: () => void }>\n /**\n * The footer of the autocomplete content element.\n */\n footer?: ReactNode | FC<{ value: string | undefined; onClose: () => void }>\n}\n\nexport interface AutocompleteProps\n extends ThemeProps<\"Autocomplete\">,\n Omit<UseAutocompleteProps, \"maxSelectValues\" | \"omitSelectedValues\">,\n AutocompleteOptions {}\n\n/**\n * `Autocomplete` is a component used to display suggestions in response to user text input.\n *\n * @see Docs https://yamada-ui.com/components/forms/autocomplete\n */\nexport const Autocomplete = forwardRef<AutocompleteProps, \"input\">(\n (props, ref) => {\n const [styles, mergedProps] = useComponentMultiStyle(\"Autocomplete\", props)\n let {\n className,\n defaultValue = \"\",\n color,\n h,\n height,\n minH,\n minHeight,\n containerProps,\n contentProps,\n listProps,\n fieldProps,\n inputProps,\n iconProps,\n portalProps = { isDisabled: true },\n createProps,\n emptyProps,\n header,\n footer,\n children,\n ...computedProps\n } = omitThemeProps(mergedProps)\n\n const {\n value,\n onClose,\n descendants,\n formControlProps,\n getPopoverProps,\n getContainerProps,\n getFieldProps,\n allowCreate,\n isEmpty,\n inputValue,\n computedChildren,\n ...rest\n } = useAutocomplete({ ...computedProps, defaultValue, children })\n\n h ??= height\n minH ??= minHeight\n\n const css: CSSUIObject = {\n w: \"100%\",\n h: \"fit-content\",\n color,\n ...styles.container,\n }\n\n return (\n <AutocompleteDescendantsContextProvider value={descendants}>\n <AutocompleteProvider\n value={{\n ...rest,\n value,\n onClose,\n formControlProps,\n inputValue,\n allowCreate,\n isEmpty,\n styles,\n }}\n >\n <Popover {...getPopoverProps()}>\n <ui.div\n className={cx(\"ui-autocomplete\", className)}\n __css={css}\n {...getContainerProps(containerProps)}\n >\n <ui.div\n className=\"ui-autocomplete__inner\"\n __css={{ position: \"relative\", ...styles.inner }}\n >\n <AutocompleteField\n h={h}\n minH={minH}\n inputProps={inputProps}\n {...getFieldProps(fieldProps, ref)}\n />\n\n <AutocompleteIcon {...iconProps} {...formControlProps} />\n </ui.div>\n\n {!isEmpty ? (\n <Portal {...portalProps}>\n <AutocompleteList\n header={runIfFunc(header, { value, onClose })}\n footer={runIfFunc(footer, { value, onClose })}\n contentProps={contentProps}\n {...listProps}\n >\n {allowCreate ? (\n <AutocompleteCreate {...createProps} />\n ) : (\n <AutocompleteEmpty {...emptyProps} />\n )}\n\n {children ?? computedChildren}\n </AutocompleteList>\n </Portal>\n ) : (\n <Portal {...portalProps}>\n <AutocompleteList\n header={runIfFunc(header, { value, onClose })}\n footer={runIfFunc(footer, { value, onClose })}\n contentProps={contentProps}\n {...listProps}\n >\n {allowCreate && inputValue ? (\n <AutocompleteCreate {...createProps} />\n ) : (\n <AutocompleteEmpty {...emptyProps} />\n )}\n </AutocompleteList>\n </Portal>\n )}\n </ui.div>\n </Popover>\n </AutocompleteProvider>\n </AutocompleteDescendantsContextProvider>\n )\n },\n)\n\ninterface AutocompleteFieldProps\n extends HTMLUIProps,\n Pick<AutocompleteProps, \"inputProps\"> {}\n\nconst AutocompleteField = forwardRef<AutocompleteFieldProps, \"input\">(\n ({ className, h, minH, placeholder, inputProps, ...rest }, ref) => {\n const { label, inputValue, styles } = useAutocompleteContext()\n const { getInputProps } = useAutocompleteInput()\n\n const css: CSSUIObject = {\n pe: \"2rem\",\n h,\n minH,\n display: \"flex\",\n alignItems: \"center\",\n ...styles.field,\n cursor: \"text\",\n }\n\n return (\n <PopoverTrigger>\n <ui.div\n className={cx(\"ui-autocomplete__field\", className)}\n __css={css}\n {...rest}\n >\n <ui.input\n className=\"ui-autocomplete__field__input\"\n display=\"inline-block\"\n w=\"100%\"\n placeholder={placeholder}\n {...getInputProps(\n { ...inputProps, value: inputValue || label || \"\" },\n ref,\n )}\n />\n </ui.div>\n </PopoverTrigger>\n )\n },\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,SAAS,sBAAsB;AACxC,SAAS,cAAc;AAEvB,SAAS,IAAI,iBAAiB;AA4JhB,SAIE,KAJF;AAvEP,IAAM,eAAe;AAAA,EAC1B,CAAC,OAAO,QAAQ;AACd,UAAM,CAAC,QAAQ,WAAW,IAAI,uBAAuB,gBAAgB,KAAK;AAC1E,QAAI;AAAA,MACF;AAAA,MACA,eAAe;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,MAC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,UAAH;AAAA,YACC,WAAU;AAAA,YACV,SAAQ;AAAA,YACR,GAAE;AAAA,YACF;AAAA,YACC,GAAG;AAAA,cACF,EAAE,GAAG,YAAY,OAAO,cAAc,SAAS,GAAG;AAAA,cAClD;AAAA,YACF;AAAA;AAAA,QACF;AAAA;AAAA,IACF,GACF;AAAA,EAEJ;AACF;","names":[]}
@@ -0,0 +1,267 @@
1
+ "use client"
2
+ import {
3
+ useAutocomplete,
4
+ useAutocompleteInput
5
+ } from "./chunk-GM7RV2YY.mjs";
6
+ import {
7
+ AutocompleteCreate
8
+ } from "./chunk-KCALQJLK.mjs";
9
+ import {
10
+ AutocompleteEmpty
11
+ } from "./chunk-GOMUH7TZ.mjs";
12
+ import {
13
+ AutocompleteList
14
+ } from "./chunk-HL2KEBRX.mjs";
15
+ import {
16
+ AutocompleteClearIcon,
17
+ AutocompleteIcon
18
+ } from "./chunk-JXFXCGZK.mjs";
19
+ import {
20
+ AutocompleteDescendantsContextProvider,
21
+ AutocompleteProvider,
22
+ useAutocompleteContext
23
+ } from "./chunk-JPUKYLBW.mjs";
24
+
25
+ // src/multi-autocomplete.tsx
26
+ import {
27
+ ui,
28
+ forwardRef,
29
+ useComponentMultiStyle,
30
+ omitThemeProps
31
+ } from "@yamada-ui/core";
32
+ import { Popover, PopoverTrigger } from "@yamada-ui/popover";
33
+ import { Portal } from "@yamada-ui/portal";
34
+ import { cx, handlerAll, runIfFunc } from "@yamada-ui/utils";
35
+ import { cloneElement, useMemo } from "react";
36
+ import { jsx, jsxs } from "react/jsx-runtime";
37
+ var MultiAutocomplete = forwardRef(
38
+ (props, ref) => {
39
+ const [styles, mergedProps] = useComponentMultiStyle(
40
+ "MultiAutocomplete",
41
+ props
42
+ );
43
+ let {
44
+ className,
45
+ defaultValue = [],
46
+ component,
47
+ separator,
48
+ isClearable = true,
49
+ color,
50
+ h,
51
+ height,
52
+ minH,
53
+ minHeight,
54
+ closeOnSelect = false,
55
+ keepPlaceholder = false,
56
+ containerProps,
57
+ contentProps,
58
+ listProps,
59
+ fieldProps,
60
+ inputProps,
61
+ iconProps,
62
+ clearIconProps,
63
+ portalProps = { isDisabled: true },
64
+ createProps,
65
+ emptyProps,
66
+ header,
67
+ footer,
68
+ children,
69
+ ...computedProps
70
+ } = omitThemeProps(mergedProps);
71
+ const {
72
+ value,
73
+ onClose,
74
+ descendants,
75
+ formControlProps,
76
+ getPopoverProps,
77
+ getContainerProps,
78
+ getFieldProps,
79
+ allowCreate,
80
+ isEmpty,
81
+ inputValue,
82
+ computedChildren,
83
+ onClear,
84
+ ...rest
85
+ } = useAutocomplete({
86
+ ...computedProps,
87
+ defaultValue,
88
+ closeOnSelect,
89
+ children
90
+ });
91
+ h != null ? h : h = height;
92
+ minH != null ? minH : minH = minHeight;
93
+ const css = {
94
+ w: "100%",
95
+ h: "fit-content",
96
+ color,
97
+ ...styles.container
98
+ };
99
+ return /* @__PURE__ */ jsx(AutocompleteDescendantsContextProvider, { value: descendants, children: /* @__PURE__ */ jsx(
100
+ AutocompleteProvider,
101
+ {
102
+ value: {
103
+ ...rest,
104
+ value,
105
+ onClose,
106
+ formControlProps,
107
+ inputValue,
108
+ allowCreate,
109
+ isEmpty,
110
+ styles
111
+ },
112
+ children: /* @__PURE__ */ jsx(Popover, { ...getPopoverProps(), children: /* @__PURE__ */ jsxs(
113
+ ui.div,
114
+ {
115
+ className: cx("ui-multi-autocomplete", className),
116
+ __css: css,
117
+ ...getContainerProps(containerProps),
118
+ children: [
119
+ /* @__PURE__ */ jsxs(
120
+ ui.div,
121
+ {
122
+ className: "ui-multi-autocomplete__inner",
123
+ __css: { position: "relative", ...styles.inner },
124
+ children: [
125
+ /* @__PURE__ */ jsx(
126
+ MultiAutocompleteField,
127
+ {
128
+ component,
129
+ separator,
130
+ keepPlaceholder,
131
+ h,
132
+ minH,
133
+ inputProps,
134
+ ...getFieldProps(fieldProps, ref)
135
+ }
136
+ ),
137
+ isClearable && value.length ? /* @__PURE__ */ jsx(
138
+ AutocompleteClearIcon,
139
+ {
140
+ ...clearIconProps,
141
+ onClick: handlerAll(clearIconProps == null ? void 0 : clearIconProps.onClick, onClear),
142
+ ...formControlProps
143
+ }
144
+ ) : /* @__PURE__ */ jsx(AutocompleteIcon, { ...iconProps, ...formControlProps })
145
+ ]
146
+ }
147
+ ),
148
+ !isEmpty ? /* @__PURE__ */ jsx(Portal, { ...portalProps, children: /* @__PURE__ */ jsxs(
149
+ AutocompleteList,
150
+ {
151
+ header: runIfFunc(header, { value, onClose }),
152
+ footer: runIfFunc(footer, { value, onClose }),
153
+ contentProps,
154
+ ...listProps,
155
+ children: [
156
+ allowCreate ? /* @__PURE__ */ jsx(AutocompleteCreate, { ...createProps }) : /* @__PURE__ */ jsx(AutocompleteEmpty, { ...emptyProps }),
157
+ children != null ? children : computedChildren
158
+ ]
159
+ }
160
+ ) }) : /* @__PURE__ */ jsx(Portal, { ...portalProps, children: /* @__PURE__ */ jsx(
161
+ AutocompleteList,
162
+ {
163
+ header: runIfFunc(header, { value, onClose }),
164
+ footer: runIfFunc(footer, { value, onClose }),
165
+ contentProps,
166
+ ...listProps,
167
+ children: allowCreate && inputValue ? /* @__PURE__ */ jsx(AutocompleteCreate, { ...createProps }) : /* @__PURE__ */ jsx(AutocompleteEmpty, { ...emptyProps })
168
+ }
169
+ ) })
170
+ ]
171
+ }
172
+ ) })
173
+ }
174
+ ) });
175
+ }
176
+ );
177
+ var MultiAutocompleteField = forwardRef(
178
+ ({
179
+ className,
180
+ component,
181
+ separator = ",",
182
+ keepPlaceholder,
183
+ h,
184
+ minH,
185
+ placeholder,
186
+ inputProps,
187
+ ...rest
188
+ }, ref) => {
189
+ const { value, label, inputValue, onChange, isOpen, inputRef, styles } = useAutocompleteContext();
190
+ const { getInputProps } = useAutocompleteInput();
191
+ const cloneChildren = useMemo(() => {
192
+ if (!(label == null ? void 0 : label.length)) return null;
193
+ if (component) {
194
+ return label.map((label2, index) => {
195
+ const onRemove = (ev) => {
196
+ ev.stopPropagation();
197
+ onChange(value[index]);
198
+ if (inputRef.current) inputRef.current.focus();
199
+ };
200
+ const el = component({
201
+ value: value[index],
202
+ label: label2,
203
+ index,
204
+ onRemove
205
+ });
206
+ const style = {
207
+ marginBlockStart: "0.125rem",
208
+ marginBlockEnd: "0.125rem",
209
+ marginInlineEnd: "0.25rem"
210
+ };
211
+ return el ? cloneElement(el, { key: index, style }) : null;
212
+ });
213
+ } else {
214
+ return label.map((value2, index) => {
215
+ const isLast = label.length === index + 1;
216
+ return /* @__PURE__ */ jsxs(ui.span, { display: "inline-block", me: "0.25rem", children: [
217
+ value2,
218
+ !isLast || isOpen ? separator : null
219
+ ] }, index);
220
+ });
221
+ }
222
+ }, [label, component, value, onChange, isOpen, inputRef, separator]);
223
+ const css = {
224
+ pe: "2rem",
225
+ h,
226
+ minH,
227
+ display: "flex",
228
+ flexWrap: "wrap",
229
+ alignItems: "center",
230
+ ...styles.field,
231
+ cursor: "text"
232
+ };
233
+ return /* @__PURE__ */ jsx(PopoverTrigger, { children: /* @__PURE__ */ jsxs(
234
+ ui.div,
235
+ {
236
+ className: cx("ui-multi-autocomplete__field", className),
237
+ __css: css,
238
+ py: (label == null ? void 0 : label.length) && component ? "0.125rem" : void 0,
239
+ ...rest,
240
+ children: [
241
+ cloneChildren,
242
+ /* @__PURE__ */ jsx(
243
+ ui.input,
244
+ {
245
+ "aria-label": "Input value",
246
+ className: "ui-multi-autocomplete__field__input",
247
+ display: "inline-block",
248
+ flex: "1",
249
+ minW: "0px",
250
+ overflow: "hidden",
251
+ marginBlockStart: "0.125rem",
252
+ marginBlockEnd: "0.125rem",
253
+ "aria-multiselectable": "true",
254
+ placeholder: !label || !(label == null ? void 0 : label.length) || keepPlaceholder && isOpen ? placeholder : void 0,
255
+ ...getInputProps({ ...inputProps, value: inputValue != null ? inputValue : "" }, ref)
256
+ }
257
+ )
258
+ ]
259
+ }
260
+ ) });
261
+ }
262
+ );
263
+
264
+ export {
265
+ MultiAutocomplete
266
+ };
267
+ //# sourceMappingURL=chunk-BD7VZQOL.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/multi-autocomplete.tsx"],"sourcesContent":["import type { CSSUIObject, HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport {\n ui,\n forwardRef,\n useComponentMultiStyle,\n omitThemeProps,\n} from \"@yamada-ui/core\"\nimport type { MotionProps } from \"@yamada-ui/motion\"\nimport { Popover, PopoverTrigger } from \"@yamada-ui/popover\"\nimport type { PortalProps } from \"@yamada-ui/portal\"\nimport { Portal } from \"@yamada-ui/portal\"\nimport { cx, handlerAll, runIfFunc } from \"@yamada-ui/utils\"\nimport type {\n CSSProperties,\n FC,\n MouseEventHandler,\n ReactElement,\n ReactNode,\n} from \"react\"\nimport { cloneElement, useMemo } from \"react\"\nimport {\n AutocompleteDescendantsContextProvider,\n AutocompleteProvider,\n useAutocompleteContext,\n} from \"./autocomplete-context\"\nimport { AutocompleteCreate } from \"./autocomplete-create\"\nimport type { AutocompleteCreateProps } from \"./autocomplete-create\"\nimport { AutocompleteEmpty } from \"./autocomplete-empty\"\nimport type { AutocompleteEmptyProps } from \"./autocomplete-empty\"\nimport type { AutocompleteIconProps } from \"./autocomplete-icon\"\nimport { AutocompleteClearIcon, AutocompleteIcon } from \"./autocomplete-icon\"\nimport type { AutocompleteListProps } from \"./autocomplete-list\"\nimport { AutocompleteList } from \"./autocomplete-list\"\nimport type { UseAutocompleteProps } from \"./use-autocomplete\"\nimport { useAutocomplete, useAutocompleteInput } from \"./use-autocomplete\"\n\ninterface MultiAutocompleteOptions {\n /**\n * The visual separator between each value.\n *\n * @default ','\n */\n separator?: string\n /**\n * The custom display value to use.\n */\n component?: FC<{\n value: string | number\n label: string\n index: number\n onRemove: MouseEventHandler<HTMLElement>\n }>\n /**\n * If `true`, keep the placeholder.\n *\n * @default false\n */\n keepPlaceholder?: boolean\n /**\n * If `true`, display the select clear icon.\n *\n * @default true\n */\n isClearable?: boolean\n /**\n * The border color when the input is focused.\n */\n focusBorderColor?: string\n /**\n * The border color when the input is invalid.\n */\n errorBorderColor?: string\n /**\n * Props for multi autocomplete container element.\n */\n containerProps?: Omit<HTMLUIProps, \"children\">\n /**\n * Props for multi autocomplete content element.\n */\n contentProps?: Omit<MotionProps, \"children\">\n /**\n * Props for multi autocomplete list element.\n */\n listProps?: Omit<AutocompleteListProps, \"children\">\n /**\n * Props for multi autocomplete field element.\n */\n fieldProps?: Omit<\n MultiAutocompleteFieldProps,\n \"component\" | \"separator\" | \"keepPlaceholder\" | \"inputProps\" | \"children\"\n >\n /**\n * Props for multi autocomplete input element.\n */\n inputProps?: HTMLUIProps<\"input\">\n /**\n * Props for multi autocomplete icon element.\n */\n iconProps?: AutocompleteIconProps\n /**\n * Props for multi autocomplete clear icon element.\n */\n clearIconProps?: AutocompleteIconProps\n /**\n * Props to be forwarded to the portal component.\n *\n * @default '{ isDisabled: true }'\n *\n */\n portalProps?: Omit<PortalProps, \"children\">\n /**\n * If `true`, the list element will be closed when value is selected.\n *\n * @default false\n */\n closeOnSelect?: boolean\n /**\n * Props for autocomplete create element.\n */\n createProps?: Omit<AutocompleteCreateProps, \"children\">\n /**\n * Props for autocomplete empty element.\n */\n emptyProps?: Omit<AutocompleteEmptyProps, \"children\">\n /**\n * The header of the autocomplete content element.\n */\n header?: ReactNode | FC<{ value: string[] | undefined; onClose: () => void }>\n /**\n * The footer of the autocomplete content element.\n */\n footer?: ReactNode | FC<{ value: string[] | undefined; onClose: () => void }>\n}\n\nexport interface MultiAutocompleteProps\n extends ThemeProps<\"MultiAutocomplete\">,\n Omit<UseAutocompleteProps<string[]>, \"closeOnSelect\">,\n MultiAutocompleteOptions {}\n\n/**\n * `MultiAutocomplete` is a component used to display suggestions based on user text input and to obtain multiple values.\n *\n * @see Docs https://yamada-ui.com/components/forms/multi-autocomplete\n */\nexport const MultiAutocomplete = forwardRef<MultiAutocompleteProps, \"input\">(\n (props, ref) => {\n const [styles, mergedProps] = useComponentMultiStyle(\n \"MultiAutocomplete\",\n props,\n )\n let {\n className,\n defaultValue = [],\n component,\n separator,\n isClearable = true,\n color,\n h,\n height,\n minH,\n minHeight,\n closeOnSelect = false,\n keepPlaceholder = false,\n containerProps,\n contentProps,\n listProps,\n fieldProps,\n inputProps,\n iconProps,\n clearIconProps,\n portalProps = { isDisabled: true },\n createProps,\n emptyProps,\n header,\n footer,\n children,\n ...computedProps\n } = omitThemeProps(mergedProps)\n\n const {\n value,\n onClose,\n descendants,\n formControlProps,\n getPopoverProps,\n getContainerProps,\n getFieldProps,\n allowCreate,\n isEmpty,\n inputValue,\n computedChildren,\n onClear,\n ...rest\n } = useAutocomplete<string[]>({\n ...computedProps,\n defaultValue,\n closeOnSelect,\n children,\n })\n\n h ??= height\n minH ??= minHeight\n\n const css: CSSUIObject = {\n w: \"100%\",\n h: \"fit-content\",\n color,\n ...styles.container,\n }\n\n return (\n <AutocompleteDescendantsContextProvider value={descendants}>\n <AutocompleteProvider\n value={{\n ...rest,\n value,\n onClose,\n formControlProps,\n inputValue,\n allowCreate,\n isEmpty,\n styles,\n }}\n >\n <Popover {...getPopoverProps()}>\n <ui.div\n className={cx(\"ui-multi-autocomplete\", className)}\n __css={css}\n {...getContainerProps(containerProps)}\n >\n <ui.div\n className=\"ui-multi-autocomplete__inner\"\n __css={{ position: \"relative\", ...styles.inner }}\n >\n <MultiAutocompleteField\n component={component}\n separator={separator}\n keepPlaceholder={keepPlaceholder}\n h={h}\n minH={minH}\n inputProps={inputProps}\n {...getFieldProps(fieldProps, ref)}\n />\n\n {isClearable && value.length ? (\n <AutocompleteClearIcon\n {...clearIconProps}\n onClick={handlerAll(clearIconProps?.onClick, onClear)}\n {...formControlProps}\n />\n ) : (\n <AutocompleteIcon {...iconProps} {...formControlProps} />\n )}\n </ui.div>\n\n {!isEmpty ? (\n <Portal {...portalProps}>\n <AutocompleteList\n header={runIfFunc(header, { value, onClose })}\n footer={runIfFunc(footer, { value, onClose })}\n contentProps={contentProps}\n {...listProps}\n >\n {allowCreate ? (\n <AutocompleteCreate {...createProps} />\n ) : (\n <AutocompleteEmpty {...emptyProps} />\n )}\n\n {children ?? computedChildren}\n </AutocompleteList>\n </Portal>\n ) : (\n <Portal {...portalProps}>\n <AutocompleteList\n header={runIfFunc(header, { value, onClose })}\n footer={runIfFunc(footer, { value, onClose })}\n contentProps={contentProps}\n {...listProps}\n >\n {allowCreate && inputValue ? (\n <AutocompleteCreate {...createProps} />\n ) : (\n <AutocompleteEmpty {...emptyProps} />\n )}\n </AutocompleteList>\n </Portal>\n )}\n </ui.div>\n </Popover>\n </AutocompleteProvider>\n </AutocompleteDescendantsContextProvider>\n )\n },\n)\n\ninterface MultiAutocompleteFieldProps\n extends HTMLUIProps,\n Pick<\n MultiAutocompleteProps,\n \"component\" | \"separator\" | \"keepPlaceholder\" | \"inputProps\"\n > {}\n\nconst MultiAutocompleteField = forwardRef<MultiAutocompleteFieldProps, \"input\">(\n (\n {\n className,\n component,\n separator = \",\",\n keepPlaceholder,\n h,\n minH,\n placeholder,\n inputProps,\n ...rest\n },\n ref,\n ) => {\n const { value, label, inputValue, onChange, isOpen, inputRef, styles } =\n useAutocompleteContext()\n\n const { getInputProps } = useAutocompleteInput()\n\n const cloneChildren = useMemo(() => {\n if (!label?.length) return null\n\n if (component) {\n return (label as string[]).map((label, index) => {\n const onRemove: MouseEventHandler<HTMLElement> = (ev) => {\n ev.stopPropagation()\n\n onChange(value[index])\n\n if (inputRef.current) inputRef.current.focus()\n }\n\n const el = component({\n value: value[index],\n label,\n index,\n onRemove,\n })\n\n const style: CSSProperties = {\n marginBlockStart: \"0.125rem\",\n marginBlockEnd: \"0.125rem\",\n marginInlineEnd: \"0.25rem\",\n }\n\n return el\n ? cloneElement(el as ReactElement, { key: index, style })\n : null\n })\n } else {\n return (label as string[]).map((value, index) => {\n const isLast = label.length === index + 1\n\n return (\n <ui.span key={index} display=\"inline-block\" me=\"0.25rem\">\n {value}\n {!isLast || isOpen ? separator : null}\n </ui.span>\n )\n })\n }\n }, [label, component, value, onChange, isOpen, inputRef, separator])\n\n const css: CSSUIObject = {\n pe: \"2rem\",\n h,\n minH,\n display: \"flex\",\n flexWrap: \"wrap\",\n alignItems: \"center\",\n ...styles.field,\n cursor: \"text\",\n }\n\n return (\n <PopoverTrigger>\n <ui.div\n className={cx(\"ui-multi-autocomplete__field\", className)}\n __css={css}\n py={label?.length && component ? \"0.125rem\" : undefined}\n {...rest}\n >\n {cloneChildren}\n\n <ui.input\n aria-label=\"Input value\"\n className=\"ui-multi-autocomplete__field__input\"\n display=\"inline-block\"\n flex=\"1\"\n minW=\"0px\"\n overflow=\"hidden\"\n marginBlockStart=\"0.125rem\"\n marginBlockEnd=\"0.125rem\"\n aria-multiselectable=\"true\"\n placeholder={\n !label || !label?.length || (keepPlaceholder && isOpen)\n ? placeholder\n : undefined\n }\n {...getInputProps({ ...inputProps, value: inputValue ?? \"\" }, ref)}\n />\n </ui.div>\n </PopoverTrigger>\n )\n },\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,SAAS,sBAAsB;AAExC,SAAS,cAAc;AACvB,SAAS,IAAI,YAAY,iBAAiB;AAQ1C,SAAS,cAAc,eAAe;AAmNxB,SAIE,KAJF;AAtFP,IAAM,oBAAoB;AAAA,EAC/B,CAAC,OAAO,QAAQ;AACd,UAAM,CAAC,QAAQ,WAAW,IAAI;AAAA,MAC5B;AAAA,MACA;AAAA,IACF;AACA,QAAI;AAAA,MACF;AAAA,MACA,eAAe,CAAC;AAAA,MAChB;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAgB;AAAA,MAChB,kBAAkB;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc,EAAE,YAAY,KAAK;AAAA,MACj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;AAAA,cACR,MAAK;AAAA,cACL,MAAK;AAAA,cACL,UAAS;AAAA,cACT,kBAAiB;AAAA,cACjB,gBAAe;AAAA,cACf,wBAAqB;AAAA,cACrB,aACE,CAAC,SAAS,EAAC,+BAAO,WAAW,mBAAmB,SAC5C,cACA;AAAA,cAEL,GAAG,cAAc,EAAE,GAAG,YAAY,OAAO,kCAAc,GAAG,GAAG,GAAG;AAAA;AAAA,UACnE;AAAA;AAAA;AAAA,IACF,GACF;AAAA,EAEJ;AACF;","names":["label","value"]}
@@ -0,0 +1,57 @@
1
+ "use client"
2
+ import {
3
+ useAutocompleteOptionGroup
4
+ } from "./chunk-JMX72TSD.mjs";
5
+ import {
6
+ useAutocompleteContext
7
+ } from "./chunk-JPUKYLBW.mjs";
8
+
9
+ // src/autocomplete-option-group.tsx
10
+ import { ui, forwardRef } from "@yamada-ui/core";
11
+ import { cx } from "@yamada-ui/utils";
12
+ import { jsx, jsxs } from "react/jsx-runtime";
13
+ var AutocompleteOptionGroup = forwardRef(
14
+ ({ className, color, h, height, minH, minHeight, children, ...rest }, ref) => {
15
+ const { styles } = useAutocompleteContext();
16
+ const { label, getContainerProps, getGroupProps } = useAutocompleteOptionGroup(rest);
17
+ h != null ? h : h = height;
18
+ minH != null ? minH : minH = minHeight;
19
+ return /* @__PURE__ */ jsxs(
20
+ ui.li,
21
+ {
22
+ className: cx(
23
+ "ui-autocomplete__item",
24
+ "ui-autocomplete__item--group",
25
+ className
26
+ ),
27
+ __css: { w: "100%", h: "fit-content", color },
28
+ ...getContainerProps(),
29
+ children: [
30
+ /* @__PURE__ */ jsx(
31
+ ui.span,
32
+ {
33
+ className: "ui-autocomplete__item__group-label",
34
+ __css: styles.groupLabel,
35
+ lineClamp: 1,
36
+ children: label
37
+ }
38
+ ),
39
+ /* @__PURE__ */ jsx(
40
+ ui.ul,
41
+ {
42
+ ...getGroupProps({}, ref),
43
+ className: "ui-autocomplete__item__group",
44
+ __css: { h, minH, ...styles.group },
45
+ children
46
+ }
47
+ )
48
+ ]
49
+ }
50
+ );
51
+ }
52
+ );
53
+
54
+ export {
55
+ AutocompleteOptionGroup
56
+ };
57
+ //# sourceMappingURL=chunk-FZM3BH3D.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/autocomplete-option-group.tsx"],"sourcesContent":["import type { HTMLUIProps } from \"@yamada-ui/core\"\nimport { ui, forwardRef } from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport { useAutocompleteContext } from \"./autocomplete-context\"\nimport type { UseAutocompleteOptionGroupProps } from \"./use-autocomplete-option-group\"\nimport { useAutocompleteOptionGroup } from \"./use-autocomplete-option-group\"\n\ninterface AutocompleteOptionGroupOptions\n extends UseAutocompleteOptionGroupProps {}\n\nexport interface AutocompleteOptionGroupProps\n extends HTMLUIProps<\"ul\">,\n AutocompleteOptionGroupOptions {}\n\nexport const AutocompleteOptionGroup = forwardRef<\n AutocompleteOptionGroupProps,\n \"ul\"\n>(\n (\n { className, color, h, height, minH, minHeight, children, ...rest },\n ref,\n ) => {\n const { styles } = useAutocompleteContext()\n const { label, getContainerProps, getGroupProps } =\n useAutocompleteOptionGroup(rest)\n\n h ??= height\n minH ??= minHeight\n\n return (\n <ui.li\n className={cx(\n \"ui-autocomplete__item\",\n \"ui-autocomplete__item--group\",\n className,\n )}\n __css={{ w: \"100%\", h: \"fit-content\", color }}\n {...getContainerProps()}\n >\n <ui.span\n className=\"ui-autocomplete__item__group-label\"\n __css={styles.groupLabel}\n lineClamp={1}\n >\n {label}\n </ui.span>\n\n <ui.ul\n {...getGroupProps({}, ref)}\n className=\"ui-autocomplete__item__group\"\n __css={{ h, minH, ...styles.group }}\n >\n {children}\n </ui.ul>\n </ui.li>\n )\n },\n)\n"],"mappings":";;;;;;;;;AACA,SAAS,IAAI,kBAAkB;AAC/B,SAAS,UAAU;AA4Bb,SASE,KATF;AAhBC,IAAM,0BAA0B;AAAA,EAIrC,CACE,EAAE,WAAW,OAAO,GAAG,QAAQ,MAAM,WAAW,UAAU,GAAG,KAAK,GAClE,QACG;AACH,UAAM,EAAE,OAAO,IAAI,uBAAuB;AAC1C,UAAM,EAAE,OAAO,mBAAmB,cAAc,IAC9C,2BAA2B,IAAI;AAEjC,wBAAM;AACN,iCAAS;AAET,WACE;AAAA,MAAC,GAAG;AAAA,MAAH;AAAA,QACC,WAAW;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,QACA,OAAO,EAAE,GAAG,QAAQ,GAAG,eAAe,MAAM;AAAA,QAC3C,GAAG,kBAAkB;AAAA,QAEtB;AAAA;AAAA,YAAC,GAAG;AAAA,YAAH;AAAA,cACC,WAAU;AAAA,cACV,OAAO,OAAO;AAAA,cACd,WAAW;AAAA,cAEV;AAAA;AAAA,UACH;AAAA,UAEA;AAAA,YAAC,GAAG;AAAA,YAAH;AAAA,cACE,GAAG,cAAc,CAAC,GAAG,GAAG;AAAA,cACzB,WAAU;AAAA,cACV,OAAO,EAAE,GAAG,MAAM,GAAG,OAAO,MAAM;AAAA,cAEjC;AAAA;AAAA,UACH;AAAA;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;","names":[]}