@craftzbay/ui 0.11.2 → 0.11.4
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-lib/_virtual/_rolldown/runtime.js +11 -0
- package/dist-lib/components/ui/Accordion.js +42 -67
- package/dist-lib/components/ui/Accordion.js.map +1 -1
- package/dist-lib/components/ui/Alert.js +71 -77
- package/dist-lib/components/ui/Alert.js.map +1 -1
- package/dist-lib/components/ui/Avatar.js +67 -92
- package/dist-lib/components/ui/Avatar.js.map +1 -1
- package/dist-lib/components/ui/Badge.js +119 -74
- package/dist-lib/components/ui/Badge.js.map +1 -1
- package/dist-lib/components/ui/Breadcrumbs.js +62 -50
- package/dist-lib/components/ui/Breadcrumbs.js.map +1 -1
- package/dist-lib/components/ui/Button.js +129 -127
- package/dist-lib/components/ui/Button.js.map +1 -1
- package/dist-lib/components/ui/Calendar.d.ts +1 -1
- package/dist-lib/components/ui/Calendar.js +99 -136
- package/dist-lib/components/ui/Calendar.js.map +1 -1
- package/dist-lib/components/ui/Card.js +88 -94
- package/dist-lib/components/ui/Card.js.map +1 -1
- package/dist-lib/components/ui/Carousel.js +125 -170
- package/dist-lib/components/ui/Carousel.js.map +1 -1
- package/dist-lib/components/ui/Chart.d.ts +3 -3
- package/dist-lib/components/ui/Chart.js +435 -464
- package/dist-lib/components/ui/Chart.js.map +1 -1
- package/dist-lib/components/ui/Checkbox.js +60 -69
- package/dist-lib/components/ui/Checkbox.js.map +1 -1
- package/dist-lib/components/ui/Combobox.js +179 -192
- package/dist-lib/components/ui/Combobox.js.map +1 -1
- package/dist-lib/components/ui/CommandPalette.d.ts +2 -2
- package/dist-lib/components/ui/CommandPalette.js +106 -167
- package/dist-lib/components/ui/CommandPalette.js.map +1 -1
- package/dist-lib/components/ui/ContextMenu.d.ts +1 -1
- package/dist-lib/components/ui/ContextMenu.js +89 -154
- package/dist-lib/components/ui/ContextMenu.js.map +1 -1
- package/dist-lib/components/ui/DataGrid.d.ts +1 -1
- package/dist-lib/components/ui/DataGrid.js +99 -96
- package/dist-lib/components/ui/DataGrid.js.map +1 -1
- package/dist-lib/components/ui/DatePicker.js +151 -188
- package/dist-lib/components/ui/DatePicker.js.map +1 -1
- package/dist-lib/components/ui/DesignSystemProvider.d.ts +1 -1
- package/dist-lib/components/ui/DesignSystemProvider.js +120 -130
- package/dist-lib/components/ui/DesignSystemProvider.js.map +1 -1
- package/dist-lib/components/ui/Dialog.d.ts +3 -3
- package/dist-lib/components/ui/Dialog.js +108 -156
- package/dist-lib/components/ui/Dialog.js.map +1 -1
- package/dist-lib/components/ui/Drawer.d.ts +3 -3
- package/dist-lib/components/ui/Drawer.js +90 -124
- package/dist-lib/components/ui/Drawer.js.map +1 -1
- package/dist-lib/components/ui/DropdownMenu.d.ts +1 -1
- package/dist-lib/components/ui/DropdownMenu.js +92 -158
- package/dist-lib/components/ui/DropdownMenu.js.map +1 -1
- package/dist-lib/components/ui/EmptyState.js +31 -44
- package/dist-lib/components/ui/EmptyState.js.map +1 -1
- package/dist-lib/components/ui/ErrorState.js +57 -67
- package/dist-lib/components/ui/ErrorState.js.map +1 -1
- package/dist-lib/components/ui/FileUpload.js +113 -107
- package/dist-lib/components/ui/FileUpload.js.map +1 -1
- package/dist-lib/components/ui/Form.d.ts +6 -4
- package/dist-lib/components/ui/Form.js +117 -122
- package/dist-lib/components/ui/Form.js.map +1 -1
- package/dist-lib/components/ui/Icon.d.ts +1 -1
- package/dist-lib/components/ui/Icon.js +30 -29
- package/dist-lib/components/ui/Icon.js.map +1 -1
- package/dist-lib/components/ui/IconButton.js +61 -61
- package/dist-lib/components/ui/IconButton.js.map +1 -1
- package/dist-lib/components/ui/Input.js +133 -156
- package/dist-lib/components/ui/Input.js.map +1 -1
- package/dist-lib/components/ui/Kbd.js +14 -21
- package/dist-lib/components/ui/Kbd.js.map +1 -1
- package/dist-lib/components/ui/MultiSelect.js +176 -208
- package/dist-lib/components/ui/MultiSelect.js.map +1 -1
- package/dist-lib/components/ui/Pagination.js +152 -149
- package/dist-lib/components/ui/Pagination.js.map +1 -1
- package/dist-lib/components/ui/Popover.js +18 -33
- package/dist-lib/components/ui/Popover.js.map +1 -1
- package/dist-lib/components/ui/Progress.js +77 -99
- package/dist-lib/components/ui/Progress.js.map +1 -1
- package/dist-lib/components/ui/RadioGroup.js +51 -80
- package/dist-lib/components/ui/RadioGroup.js.map +1 -1
- package/dist-lib/components/ui/RelativeTime.js +22 -29
- package/dist-lib/components/ui/RelativeTime.js.map +1 -1
- package/dist-lib/components/ui/ScrollArea.js +39 -58
- package/dist-lib/components/ui/ScrollArea.js.map +1 -1
- package/dist-lib/components/ui/Select.js +108 -131
- package/dist-lib/components/ui/Select.js.map +1 -1
- package/dist-lib/components/ui/Separator.js +18 -24
- package/dist-lib/components/ui/Separator.js.map +1 -1
- package/dist-lib/components/ui/Sheet.d.ts +2 -2
- package/dist-lib/components/ui/Sheet.js +77 -129
- package/dist-lib/components/ui/Sheet.js.map +1 -1
- package/dist-lib/components/ui/Sidebar.d.ts +1 -1
- package/dist-lib/components/ui/Sidebar.js +168 -207
- package/dist-lib/components/ui/Sidebar.js.map +1 -1
- package/dist-lib/components/ui/Skeleton.js +17 -27
- package/dist-lib/components/ui/Skeleton.js.map +1 -1
- package/dist-lib/components/ui/Slider.js +45 -62
- package/dist-lib/components/ui/Slider.js.map +1 -1
- package/dist-lib/components/ui/Snackbar.js +75 -55
- package/dist-lib/components/ui/Snackbar.js.map +1 -1
- package/dist-lib/components/ui/Spinner.js +45 -52
- package/dist-lib/components/ui/Spinner.js.map +1 -1
- package/dist-lib/components/ui/Stepper.js +56 -108
- package/dist-lib/components/ui/Stepper.js.map +1 -1
- package/dist-lib/components/ui/Switch.js +46 -79
- package/dist-lib/components/ui/Switch.js.map +1 -1
- package/dist-lib/components/ui/Table.js +108 -169
- package/dist-lib/components/ui/Table.js.map +1 -1
- package/dist-lib/components/ui/Tabs.js +57 -88
- package/dist-lib/components/ui/Tabs.js.map +1 -1
- package/dist-lib/components/ui/TagInput.js +76 -109
- package/dist-lib/components/ui/TagInput.js.map +1 -1
- package/dist-lib/components/ui/Textarea.js +74 -86
- package/dist-lib/components/ui/Textarea.js.map +1 -1
- package/dist-lib/components/ui/Timeline.d.ts +3 -3
- package/dist-lib/components/ui/Timeline.js +61 -49
- package/dist-lib/components/ui/Timeline.js.map +1 -1
- package/dist-lib/components/ui/Toast.d.ts +1 -1
- package/dist-lib/components/ui/Toast.js +136 -150
- package/dist-lib/components/ui/Toast.js.map +1 -1
- package/dist-lib/components/ui/Tooltip.d.ts +2 -2
- package/dist-lib/components/ui/Tooltip.js +35 -56
- package/dist-lib/components/ui/Tooltip.js.map +1 -1
- package/dist-lib/components/ui/TopNav.js +46 -66
- package/dist-lib/components/ui/TopNav.js.map +1 -1
- package/dist-lib/components/ui/Tree.js +134 -168
- package/dist-lib/components/ui/Tree.js.map +1 -1
- package/dist-lib/hooks/use-debounce.js +27 -33
- package/dist-lib/hooks/use-debounce.js.map +1 -1
- package/dist-lib/hooks/use-delayed-loading.js +19 -18
- package/dist-lib/hooks/use-delayed-loading.js.map +1 -1
- package/dist-lib/hooks/use-field-ids.js +14 -16
- package/dist-lib/hooks/use-field-ids.js.map +1 -1
- package/dist-lib/hooks/use-media-query.js +15 -19
- package/dist-lib/hooks/use-media-query.js.map +1 -1
- package/dist-lib/hooks/use-modifier-key.js +20 -15
- package/dist-lib/hooks/use-modifier-key.js.map +1 -1
- package/dist-lib/hooks/use-strings.js +10 -10
- package/dist-lib/hooks/use-strings.js.map +1 -1
- package/dist-lib/hooks/use-toast.js +73 -62
- package/dist-lib/hooks/use-toast.js.map +1 -1
- package/dist-lib/icon.js +2 -6
- package/dist-lib/icons/index.js +166 -163
- package/dist-lib/icons/index.js.map +1 -1
- package/dist-lib/illustrations/index.d.ts +7 -7
- package/dist-lib/illustrations/index.js +255 -106
- package/dist-lib/illustrations/index.js.map +1 -1
- package/dist-lib/index.js +69 -291
- package/dist-lib/lib/cva.js +2 -0
- package/dist-lib/lib/format.js +71 -87
- package/dist-lib/lib/format.js.map +1 -1
- package/dist-lib/lib/return-focus.js +11 -11
- package/dist-lib/lib/return-focus.js.map +1 -1
- package/dist-lib/lib/strings.js +167 -135
- package/dist-lib/lib/strings.js.map +1 -1
- package/dist-lib/lib/strings.mn.js +150 -113
- package/dist-lib/lib/strings.mn.js.map +1 -1
- package/dist-lib/lib/utils.js +9 -9
- package/dist-lib/lib/utils.js.map +1 -1
- package/dist-lib/styles.css +3 -1
- package/dist-lib/theme.css +18 -5
- package/package.json +50 -50
- package/dist-lib/__tests__/helpers/color.d.ts +0 -9
- package/dist-lib/__tests__/helpers/theme.d.ts +0 -18
- package/dist-lib/icon.js.map +0 -1
- package/dist-lib/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sources":["../../../src/components/ui/Input.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n useRef,\n useState,\n type ComponentProps,\n type InputHTMLAttributes,\n type ReactNode,\n} from 'react';\nimport { Eye, EyeOff, Search, X } from '@/icons';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { cva, type VariantProps } from '@/lib/cva';\nimport { useFieldIds } from '@/hooks/use-field-ids';\n\n/* -----------------------------------------------------------------------------\n * Field-shell variants. The inner <input> is unstyled background and gets all\n * its visual treatment from this wrapper so prefix / suffix / clear slots\n * share the same border + focus state with no double rings.\n * --------------------------------------------------------------------------- */\nconst field = cva(\n [\n 'group inline-flex items-center w-full',\n 'rounded-md border border-border-input bg-card text-sm',\n 'transition-colors duration-[var(--duration-fast)] ease-[var(--ease-out)]',\n 'has-disabled:opacity-50 has-disabled:pointer-events-none',\n 'focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-offset-background',\n // Invalid state comes from the input's aria-invalid so Form wiring needs no extra prop.\n 'has-aria-invalid:border-danger has-aria-invalid:focus-within:border-danger has-aria-invalid:focus-within:ring-danger',\n ],\n {\n variants: {\n size: {\n sm: 'h-8 px-2.5 gap-1.5',\n md: 'h-9 px-3 gap-2',\n lg: 'h-10 px-3.5 gap-2',\n },\n tone: {\n default: 'focus-within:border-accent focus-within:ring-ring',\n error: 'border-danger focus-within:border-danger focus-within:ring-danger',\n },\n },\n defaultVariants: {\n size: 'md',\n tone: 'default',\n },\n },\n);\n\nconst innerInput = cva([\n 'flex-1 min-w-0 bg-transparent outline-none',\n // Fill the field's height so the focusable target is the full control\n // (32/36/40px), not the ~20px text box. Below 24px axe's target-size\n // rule only passes while nothing sits close by, which is a trap for\n // consumers packing a toolbar.\n 'self-stretch',\n 'placeholder:text-foreground-subtle',\n 'text-foreground',\n // 16px below md so iOS Safari does not zoom the page on focus; --text-lg = 1rem.\n 'text-lg md:text-sm',\n 'disabled:cursor-not-allowed',\n // `type=\"search\"` draws a native clear button in WebKit/Chromium. We render\n // our own via `clearable`, so suppress the native one or both show at once.\n '[&::-webkit-search-cancel-button]:appearance-none',\n '[&::-webkit-search-decoration]:appearance-none',\n]);\n\ntype InputType = NonNullable<InputHTMLAttributes<HTMLInputElement>['type']>;\n\n// Inline clear / password buttons: 24px box (WCAG 2.5.8 minimum) with a halo\n// that extends the hit area without growing the field.\nconst innerButton = cn(\n 'text-foreground-subtle hover:text-foreground relative -m-1 flex size-6 shrink-0 items-center justify-center rounded-sm',\n 'before:absolute before:-inset-0.5 before:content-[\"\"]',\n 'focus-visible:ring-ring focus-visible:ring-offset-background outline-none focus-visible:ring-2 focus-visible:ring-offset-2',\n 'disabled:pointer-events-none',\n);\n\nexport interface InputProps\n extends\n Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'prefix' | 'value'>,\n VariantProps<typeof field> {\n /** Controlled value. `null` is treated as an empty controlled value (no React warning). */\n value?: InputHTMLAttributes<HTMLInputElement>['value'] | null;\n /** Field type. `password` enables a show/hide toggle; `search` adds a clear button. */\n type?: InputType;\n /** Visible label rendered above the input. */\n label?: ReactNode;\n /** Hint below the input. Hidden while `error` is set. */\n helperText?: ReactNode;\n /** Validation message. Renders in `danger` colour and sets `aria-invalid`. */\n error?: ReactNode;\n /** Content rendered inside the field, before the input — icon or short text. */\n prefix?: ReactNode;\n /** Content rendered inside the field, after the input. */\n suffix?: ReactNode;\n /** Show an inline clear (×) button when the input has a value. */\n clearable?: boolean;\n /**\n * Fires when the clear button is pressed. Controlled inputs own their state\n * and should reset `value` here; uncontrolled inputs are cleared for you.\n */\n onClear?: () => void;\n /** Visually conceal the label while keeping it for screen readers. */\n hideLabel?: boolean;\n}\n\n/**\n * Text-style input with optional label, helper / error, prefix / suffix,\n * clear, and password show-hide. Wraps a single native `<input>` so it works\n * with `react-hook-form` and any controlled / uncontrolled pattern.\n *\n * @example Email with helper\n * <Input type=\"email\" label=\"Work email\" helperText=\"We never share this.\" />\n *\n * @example Password with show/hide\n * <Input type=\"password\" label=\"Password\" autoComplete=\"current-password\" />\n *\n * @example Search with clear\n * <Input type=\"search\" placeholder=\"Search…\" value={q} onChange={…}\n * clearable onClear={() => setQ('')} />\n *\n * @do Always pair an input with a visible label. If space forces hiding it,\n * use `hideLabel` so the label stays in the accessibility tree.\n * @dont Use placeholder as the only label — placeholders disappear on input\n * and fail accessibility.\n */\nexport const Input = forwardRef<HTMLInputElement, InputProps>(function Input(\n {\n className,\n type = 'text',\n size,\n tone,\n label,\n helperText,\n error,\n prefix,\n suffix,\n clearable,\n onClear,\n hideLabel,\n id,\n disabled,\n value: valueProp,\n defaultValue,\n onInput,\n 'aria-describedby': ariaDescribedby,\n 'aria-invalid': ariaInvalid,\n ...props\n },\n ref,\n) {\n const strings = useStrings();\n const isError = Boolean(error) || ariaInvalid === true || ariaInvalid === 'true';\n const { fieldId, helperId, errorId, describedBy } = useFieldIds(id, {\n hasHelper: Boolean(helperText),\n hasError: Boolean(error),\n extra: ariaDescribedby,\n });\n // `null` (nullable form state) is a controlled empty value, not \"uncontrolled\".\n const value = valueProp === null ? '' : valueProp;\n const innerRef = useRef<HTMLInputElement | null>(null);\n const setRefs = (el: HTMLInputElement | null) => {\n innerRef.current = el;\n if (typeof ref === 'function') ref(el);\n else if (ref) ref.current = el;\n };\n\n const [showPassword, setShowPassword] = useState(false);\n const effectiveType = type === 'password' ? (showPassword ? 'text' : 'password') : type;\n\n const effectiveTone = isError ? 'error' : tone;\n\n // Pre-fill prefix slot for search type.\n const renderedPrefix =\n prefix ??\n (type === 'search' ? <Search className=\"text-foreground-subtle size-4\" aria-hidden /> : null);\n\n // Track the value of uncontrolled inputs so `clearable` can show/hide the\n // button without the consumer wiring state.\n const isControlled = value !== undefined;\n const [localValue, setLocalValue] = useState<string>(\n defaultValue === undefined || defaultValue === null ? '' : String(defaultValue),\n );\n const current = isControlled ? value : localValue;\n const hasValue = current !== undefined && current !== '' && current !== null;\n\n // React 19 types `onInput` as `InputEventHandler`; `ComponentProps` keeps this portable.\n const handleInput: NonNullable<ComponentProps<'input'>['onInput']> = (e) => {\n if (!isControlled) setLocalValue(e.currentTarget.value);\n onInput?.(e);\n };\n\n const handleClear = () => {\n if (!isControlled && innerRef.current) {\n // Use the native setter so React's onChange/onInput listeners fire.\n const setter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set;\n setter?.call(innerRef.current, '');\n innerRef.current.dispatchEvent(new Event('input', { bubbles: true }));\n setLocalValue('');\n }\n onClear?.();\n innerRef.current?.focus();\n };\n\n return (\n <div className={cn('flex flex-col gap-1.5', className)}>\n {label && (\n <label\n htmlFor={fieldId}\n className={cn('text-foreground text-sm font-medium', hideLabel && 'sr-only')}\n >\n {label}\n </label>\n )}\n\n <div className={cn(field({ size, tone: effectiveTone }))}>\n {renderedPrefix && (\n <span className=\"text-foreground-subtle flex items-center [&_svg]:size-4\">\n {renderedPrefix}\n </span>\n )}\n\n <input\n ref={setRefs}\n id={fieldId}\n type={effectiveType}\n disabled={disabled}\n value={value}\n defaultValue={defaultValue}\n onInput={handleInput}\n aria-invalid={isError ? true : ariaInvalid}\n aria-describedby={describedBy}\n className={cn(innerInput())}\n {...props}\n />\n\n {clearable && hasValue && (\n <button\n type=\"button\"\n onClick={handleClear}\n disabled={disabled}\n tabIndex={disabled ? -1 : undefined}\n aria-label={strings.input.clear}\n className={innerButton}\n >\n <X className=\"size-4\" aria-hidden />\n </button>\n )}\n\n {type === 'password' && (\n <button\n type=\"button\"\n onClick={() => setShowPassword((p) => !p)}\n disabled={disabled}\n tabIndex={disabled ? -1 : undefined}\n aria-label={showPassword ? strings.input.hidePassword : strings.input.showPassword}\n aria-pressed={showPassword}\n className={innerButton}\n >\n {showPassword ? (\n <EyeOff className=\"size-4\" aria-hidden />\n ) : (\n <Eye className=\"size-4\" aria-hidden />\n )}\n </button>\n )}\n\n {suffix && (\n <span className=\"text-foreground-subtle flex items-center [&_svg]:size-4\">{suffix}</span>\n )}\n </div>\n\n {error ? (\n <p id={errorId} className=\"text-danger-text text-xs\">\n {error}\n </p>\n ) : helperText ? (\n <p id={helperId} className=\"text-foreground-subtle text-xs\">\n {helperText}\n </p>\n ) : null}\n </div>\n );\n});\n\nInput.displayName = 'Input';\n"],"names":["field","cva","innerInput","innerButton","cn","Input","forwardRef","className","type","size","tone","label","helperText","error","prefix","suffix","clearable","onClear","hideLabel","id","disabled","valueProp","defaultValue","onInput","ariaDescribedby","ariaInvalid","props","ref","strings","useStrings","isError","fieldId","helperId","errorId","describedBy","useFieldIds","value","innerRef","useRef","setRefs","el","showPassword","setShowPassword","useState","effectiveType","effectiveTone","renderedPrefix","jsx","Search","isControlled","localValue","setLocalValue","current","hasValue","handleInput","e","handleClear","setter","_a","_b","jsxs","X","p","EyeOff","Eye"],"mappings":";;;;;;;;AAqBA,MAAMA,KAAQC;AAAA,EACZ;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,EAAA;AAAA,EAEF;AAAA,IACE,UAAU;AAAA,MACR,MAAM;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,MA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AAU,2DAA2D,UAAAhC,EAAA,CAAO;AAAA,IAAA,GAEtF;AAAA,IAECF,IACC,gBAAAkC,EAAC,KAAA,EAAE,IAAId,GAAS,WAAU,4BACvB,UAAApB,EAAA,CACH,IACED,sBACD,KAAA,EAAE,IAAIoB,GAAU,WAAU,kCACxB,aACH,IACE;AAAA,EAAA,GACN;AAEJ,CAAC;AAED3B,GAAM,cAAc;"}
|
|
1
|
+
{"version":3,"file":"Input.js","names":[],"sources":["../../../src/components/ui/Input.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n useRef,\n useState,\n type ComponentProps,\n type InputHTMLAttributes,\n type ReactNode,\n} from 'react';\nimport { Eye, EyeOff, Search, X } from '@/icons';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { cva, type VariantProps } from '@/lib/cva';\nimport { useFieldIds } from '@/hooks/use-field-ids';\n\n/* -----------------------------------------------------------------------------\n * Field-shell variants. The inner <input> is unstyled background and gets all\n * its visual treatment from this wrapper so prefix / suffix / clear slots\n * share the same border + focus state with no double rings.\n * --------------------------------------------------------------------------- */\nconst field = cva(\n [\n 'group inline-flex items-center w-full',\n 'rounded-md border border-border-input bg-card text-sm',\n 'transition-colors duration-[var(--duration-fast)] ease-[var(--ease-out)]',\n 'has-disabled:opacity-50 has-disabled:pointer-events-none',\n 'focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-offset-background',\n // Invalid state comes from the input's aria-invalid so Form wiring needs no extra prop.\n 'has-aria-invalid:border-danger has-aria-invalid:focus-within:border-danger has-aria-invalid:focus-within:ring-danger',\n ],\n {\n variants: {\n size: {\n sm: 'h-8 px-2.5 gap-1.5',\n md: 'h-9 px-3 gap-2',\n lg: 'h-10 px-3.5 gap-2',\n },\n tone: {\n default: 'focus-within:border-accent focus-within:ring-ring',\n error: 'border-danger focus-within:border-danger focus-within:ring-danger',\n },\n },\n defaultVariants: {\n size: 'md',\n tone: 'default',\n },\n },\n);\n\nconst innerInput = cva([\n 'flex-1 min-w-0 bg-transparent outline-none',\n // Fill the field's height so the focusable target is the full control\n // (32/36/40px), not the ~20px text box. Below 24px axe's target-size\n // rule only passes while nothing sits close by, which is a trap for\n // consumers packing a toolbar.\n 'self-stretch',\n 'placeholder:text-foreground-subtle',\n 'text-foreground',\n // 16px below md so iOS Safari does not zoom the page on focus; --text-lg = 1rem.\n 'text-lg md:text-sm',\n 'disabled:cursor-not-allowed',\n // `type=\"search\"` draws a native clear button in WebKit/Chromium. We render\n // our own via `clearable`, so suppress the native one or both show at once.\n '[&::-webkit-search-cancel-button]:appearance-none',\n '[&::-webkit-search-decoration]:appearance-none',\n]);\n\ntype InputType = NonNullable<InputHTMLAttributes<HTMLInputElement>['type']>;\n\n// Inline clear / password buttons: 24px box (WCAG 2.5.8 minimum) with a halo\n// that extends the hit area without growing the field.\nconst innerButton = cn(\n 'text-foreground-subtle hover:text-foreground relative -m-1 flex size-6 shrink-0 items-center justify-center rounded-sm',\n 'before:absolute before:-inset-0.5 before:content-[\"\"]',\n 'focus-visible:ring-ring focus-visible:ring-offset-background outline-none focus-visible:ring-2 focus-visible:ring-offset-2',\n 'disabled:pointer-events-none',\n);\n\nexport interface InputProps\n extends\n Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'prefix' | 'value'>,\n VariantProps<typeof field> {\n /** Controlled value. `null` is treated as an empty controlled value (no React warning). */\n value?: InputHTMLAttributes<HTMLInputElement>['value'] | null;\n /** Field type. `password` enables a show/hide toggle; `search` adds a clear button. */\n type?: InputType;\n /** Visible label rendered above the input. */\n label?: ReactNode;\n /** Hint below the input. Hidden while `error` is set. */\n helperText?: ReactNode;\n /** Validation message. Renders in `danger` colour and sets `aria-invalid`. */\n error?: ReactNode;\n /** Content rendered inside the field, before the input — icon or short text. */\n prefix?: ReactNode;\n /** Content rendered inside the field, after the input. */\n suffix?: ReactNode;\n /** Show an inline clear (×) button when the input has a value. */\n clearable?: boolean;\n /**\n * Fires when the clear button is pressed. Controlled inputs own their state\n * and should reset `value` here; uncontrolled inputs are cleared for you.\n */\n onClear?: () => void;\n /** Visually conceal the label while keeping it for screen readers. */\n hideLabel?: boolean;\n}\n\n/**\n * Text-style input with optional label, helper / error, prefix / suffix,\n * clear, and password show-hide. Wraps a single native `<input>` so it works\n * with `react-hook-form` and any controlled / uncontrolled pattern.\n *\n * @example Email with helper\n * <Input type=\"email\" label=\"Work email\" helperText=\"We never share this.\" />\n *\n * @example Password with show/hide\n * <Input type=\"password\" label=\"Password\" autoComplete=\"current-password\" />\n *\n * @example Search with clear\n * <Input type=\"search\" placeholder=\"Search…\" value={q} onChange={…}\n * clearable onClear={() => setQ('')} />\n *\n * @do Always pair an input with a visible label. If space forces hiding it,\n * use `hideLabel` so the label stays in the accessibility tree.\n * @dont Use placeholder as the only label — placeholders disappear on input\n * and fail accessibility.\n */\nexport const Input = forwardRef<HTMLInputElement, InputProps>(function Input(\n {\n className,\n type = 'text',\n size,\n tone,\n label,\n helperText,\n error,\n prefix,\n suffix,\n clearable,\n onClear,\n hideLabel,\n id,\n disabled,\n value: valueProp,\n defaultValue,\n onInput,\n 'aria-describedby': ariaDescribedby,\n 'aria-invalid': ariaInvalid,\n ...props\n },\n ref,\n) {\n const strings = useStrings();\n const isError = Boolean(error) || ariaInvalid === true || ariaInvalid === 'true';\n const { fieldId, helperId, errorId, describedBy } = useFieldIds(id, {\n hasHelper: Boolean(helperText),\n hasError: Boolean(error),\n extra: ariaDescribedby,\n });\n // `null` (nullable form state) is a controlled empty value, not \"uncontrolled\".\n const value = valueProp === null ? '' : valueProp;\n const innerRef = useRef<HTMLInputElement | null>(null);\n const setRefs = (el: HTMLInputElement | null) => {\n innerRef.current = el;\n if (typeof ref === 'function') ref(el);\n else if (ref) ref.current = el;\n };\n\n const [showPassword, setShowPassword] = useState(false);\n const effectiveType = type === 'password' ? (showPassword ? 'text' : 'password') : type;\n\n const effectiveTone = isError ? 'error' : tone;\n\n // Pre-fill prefix slot for search type.\n const renderedPrefix =\n prefix ??\n (type === 'search' ? <Search className=\"text-foreground-subtle size-4\" aria-hidden /> : null);\n\n // Track the value of uncontrolled inputs so `clearable` can show/hide the\n // button without the consumer wiring state.\n const isControlled = value !== undefined;\n const [localValue, setLocalValue] = useState<string>(\n defaultValue === undefined || defaultValue === null ? '' : String(defaultValue),\n );\n const current = isControlled ? value : localValue;\n const hasValue = current !== undefined && current !== '' && current !== null;\n\n // React 19 types `onInput` as `InputEventHandler`; `ComponentProps` keeps this portable.\n const handleInput: NonNullable<ComponentProps<'input'>['onInput']> = (e) => {\n if (!isControlled) setLocalValue(e.currentTarget.value);\n onInput?.(e);\n };\n\n const handleClear = () => {\n if (!isControlled && innerRef.current) {\n // Use the native setter so React's onChange/onInput listeners fire.\n const setter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set;\n setter?.call(innerRef.current, '');\n innerRef.current.dispatchEvent(new Event('input', { bubbles: true }));\n setLocalValue('');\n }\n onClear?.();\n innerRef.current?.focus();\n };\n\n return (\n <div className={cn('flex flex-col gap-1.5', className)}>\n {label && (\n <label\n htmlFor={fieldId}\n className={cn('text-foreground text-sm font-medium', hideLabel && 'sr-only')}\n >\n {label}\n </label>\n )}\n\n <div className={cn(field({ size, tone: effectiveTone }))}>\n {renderedPrefix && (\n <span className=\"text-foreground-subtle flex items-center [&_svg]:size-4\">\n {renderedPrefix}\n </span>\n )}\n\n <input\n ref={setRefs}\n id={fieldId}\n type={effectiveType}\n disabled={disabled}\n value={value}\n defaultValue={defaultValue}\n onInput={handleInput}\n aria-invalid={isError ? true : ariaInvalid}\n aria-describedby={describedBy}\n className={cn(innerInput())}\n {...props}\n />\n\n {clearable && hasValue && (\n <button\n type=\"button\"\n onClick={handleClear}\n disabled={disabled}\n tabIndex={disabled ? -1 : undefined}\n aria-label={strings.input.clear}\n className={innerButton}\n >\n <X className=\"size-4\" aria-hidden />\n </button>\n )}\n\n {type === 'password' && (\n <button\n type=\"button\"\n onClick={() => setShowPassword((p) => !p)}\n disabled={disabled}\n tabIndex={disabled ? -1 : undefined}\n aria-label={showPassword ? strings.input.hidePassword : strings.input.showPassword}\n aria-pressed={showPassword}\n className={innerButton}\n >\n {showPassword ? (\n <EyeOff className=\"size-4\" aria-hidden />\n ) : (\n <Eye className=\"size-4\" aria-hidden />\n )}\n </button>\n )}\n\n {suffix && (\n <span className=\"text-foreground-subtle flex items-center [&_svg]:size-4\">{suffix}</span>\n )}\n </div>\n\n {error ? (\n <p id={errorId} className=\"text-danger-text text-xs\">\n {error}\n </p>\n ) : helperText ? (\n <p id={helperId} className=\"text-foreground-subtle text-xs\">\n {helperText}\n </p>\n ) : null}\n </div>\n );\n});\n\nInput.displayName = 'Input';\n"],"mappings":";;;;;;;;;AAqBA,IAAM,IAAQ,EACZ;CACE;CACA;CACA;CACA;CACA;CAEA;AACF,GACA;CACE,UAAU;EACR,MAAM;GACJ,IAAI;GACJ,IAAI;GACJ,IAAI;EACN;EACA,MAAM;GACJ,SAAS;GACT,OAAO;EACT;CACF;CACA,iBAAiB;EACf,MAAM;EACN,MAAM;CACR;AACF,CACF,GAEM,IAAa,EAAI;CACrB;CAKA;CACA;CACA;CAEA;CACA;CAGA;CACA;AACF,CAAC,GAMK,IAAc,EAClB,0HACA,2DACA,8HACA,8BACF,GAmDa,IAAQ,EAAyC,SAC5D,EACE,cACA,UAAO,QACP,SACA,SACA,UACA,eACA,UACA,WACA,WACA,cACA,YACA,cACA,OACA,aACA,OAAO,GACP,iBACA,YACA,oBAAoB,GACpB,gBAAgB,GAChB,GAAG,KAEL,GACA;CACA,IAAM,IAAU,EAAW,GACrB,IAAU,EAAQ,KAAU,MAAgB,MAAQ,MAAgB,QACpE,EAAE,YAAS,aAAU,YAAS,mBAAgB,EAAY,GAAI;EAClE,WAAW,EAAQ;EACnB,UAAU,EAAQ;EAClB,OAAO;CACT,CAAC,GAEK,IAAQ,MAAc,OAAO,KAAK,GAClC,IAAW,EAAgC,IAAI,GAC/C,KAAW,MAAgC;EAE/C,AADA,EAAS,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AAG,EAAW,CAAC;MAC1B,GAAI;KACL,CAAA;KAEA,KAAa,KACZ,kBAAC,UAAD;MACE,MAAK;MACL,SAAS;MACC;MACV,UAAU,IAAW,KAAK,KAAA;MAC1B,cAAY,EAAQ,MAAM;MAC1B,WAAW;MAEX,UAAA,kBAAC,GAAD;OAAG,WAAU;OAAS,eAAA;MAAa,CAAA;KAC7B,CAAA;KAGT,MAAS,cACR,kBAAC,UAAD;MACE,MAAK;MACL,eAAe,GAAiB,MAAM,CAAC,CAAC;MAC9B;MACV,UAAU,IAAW,KAAK,KAAA;MAC1B,cAAY,IAAe,EAAQ,MAAM,eAAe,EAAQ,MAAM;MACtE,gBAAc;MACd,WAAW;MAEV,UACC,EADD,IACE,IAEA,GAFD;OAAQ,WAAU;OAAS,eAAA;MAAa,CAEH;KAEjC,CAAA;KAGT,KACC,kBAAC,QAAD;MAAM,WAAU;MAA2D,UAAA;KAAa,CAAA;IAEvF;;GAEJ,IACC,kBAAC,KAAD;IAAG,IAAI;IAAS,WAAU;IACvB,UAAA;GACA,CAAA,IACD,IACF,kBAAC,KAAD;IAAG,IAAI;IAAU,WAAU;IACxB,UAAA;GACA,CAAA,IACD;EACD;;AAET,CAAC;AAED,EAAM,cAAc"}
|
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/utils.js";
|
|
3
|
+
import { forwardRef as t } from "react";
|
|
2
4
|
import { jsx as n } from "react/jsx-runtime";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
className: s(
|
|
11
|
-
"border-border bg-background-subtle inline-flex items-center justify-center rounded-sm border font-mono",
|
|
12
|
-
"text-foreground-muted shadow-xs",
|
|
13
|
-
e === "sm" ? "h-5 min-w-5 px-1 text-xs" : "h-6 min-w-6 px-1.5 text-xs",
|
|
14
|
-
r
|
|
15
|
-
),
|
|
16
|
-
...o
|
|
17
|
-
}
|
|
18
|
-
);
|
|
5
|
+
//#region src/components/ui/Kbd.tsx
|
|
6
|
+
var r = t(function({ size: t = "sm", className: r, ...i }, a) {
|
|
7
|
+
return /* @__PURE__ */ n("kbd", {
|
|
8
|
+
ref: a,
|
|
9
|
+
className: e("border-border bg-background-subtle inline-flex items-center justify-center rounded-sm border font-mono", "text-foreground-muted shadow-xs", t === "sm" ? "h-5 min-w-5 px-1 text-xs" : "h-6 min-w-6 px-1.5 text-xs", r),
|
|
10
|
+
...i
|
|
11
|
+
});
|
|
19
12
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
//# sourceMappingURL=Kbd.js.map
|
|
13
|
+
r.displayName = "Kbd";
|
|
14
|
+
//#endregion
|
|
15
|
+
export { r as Kbd };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=Kbd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Kbd.js","sources":["../../../src/components/ui/Kbd.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, type HTMLAttributes } from 'react';\nimport { cn } from '@/lib/utils';\n\nexport interface KbdProps extends HTMLAttributes<HTMLElement> {\n /** Visual size — match the surrounding text. */\n size?: 'sm' | 'md';\n}\n\n/**\n * Stylised keyboard shortcut indicator. Compose multiple `<Kbd>` for chords.\n *\n * @example\n * Press <Kbd>⌘</Kbd>+<Kbd>K</Kbd> to open the command palette.\n *\n * @do Use OS-conventional symbols (⌘ ⇧ ⌥ ⌃ ⏎) — keep visuals consistent\n * across the app.\n * @dont Use Kbd for clickable buttons — it implies a real keyboard input.\n */\nexport const Kbd = forwardRef<HTMLElement, KbdProps>(function Kbd(\n { size = 'sm', className, ...props },\n ref,\n) {\n return (\n <kbd\n ref={ref}\n className={cn(\n 'border-border bg-background-subtle inline-flex items-center justify-center rounded-sm border font-mono',\n 'text-foreground-muted shadow-xs',\n size === 'sm' ? 'h-5 min-w-5 px-1 text-xs' : 'h-6 min-w-6 px-1.5 text-xs',\n className,\n )}\n {...props}\n />\n );\n});\nKbd.displayName = 'Kbd';\n"],"
|
|
1
|
+
{"version":3,"file":"Kbd.js","names":[],"sources":["../../../src/components/ui/Kbd.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, type HTMLAttributes } from 'react';\nimport { cn } from '@/lib/utils';\n\nexport interface KbdProps extends HTMLAttributes<HTMLElement> {\n /** Visual size — match the surrounding text. */\n size?: 'sm' | 'md';\n}\n\n/**\n * Stylised keyboard shortcut indicator. Compose multiple `<Kbd>` for chords.\n *\n * @example\n * Press <Kbd>⌘</Kbd>+<Kbd>K</Kbd> to open the command palette.\n *\n * @do Use OS-conventional symbols (⌘ ⇧ ⌥ ⌃ ⏎) — keep visuals consistent\n * across the app.\n * @dont Use Kbd for clickable buttons — it implies a real keyboard input.\n */\nexport const Kbd = forwardRef<HTMLElement, KbdProps>(function Kbd(\n { size = 'sm', className, ...props },\n ref,\n) {\n return (\n <kbd\n ref={ref}\n className={cn(\n 'border-border bg-background-subtle inline-flex items-center justify-center rounded-sm border font-mono',\n 'text-foreground-muted shadow-xs',\n size === 'sm' ? 'h-5 min-w-5 px-1 text-xs' : 'h-6 min-w-6 px-1.5 text-xs',\n className,\n )}\n {...props}\n />\n );\n});\nKbd.displayName = 'Kbd';\n"],"mappings":";;;;;AAoBA,IAAa,IAAM,EAAkC,SACnD,EAAE,UAAO,MAAM,cAAW,GAAG,KAC7B,GACA;CACA,OACE,kBAAC,OAAD;EACO;EACL,WAAW,EACT,0GACA,mCACA,MAAS,OAAO,6BAA6B,8BAC7C,CACF;EACA,GAAI;CACL,CAAA;AAEL,CAAC;AACD,EAAI,cAAc"}
|
|
@@ -1,210 +1,178 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
"text-foreground flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm",
|
|
174
|
-
"data-[selected=true]:bg-background-muted",
|
|
175
|
-
"data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50"
|
|
176
|
-
),
|
|
177
|
-
children: [
|
|
178
|
-
/* @__PURE__ */ t(
|
|
179
|
-
"span",
|
|
180
|
-
{
|
|
181
|
-
"aria-hidden": !0,
|
|
182
|
-
className: a(
|
|
183
|
-
"flex size-4 items-center justify-center rounded-sm border",
|
|
184
|
-
o ? "border-accent bg-accent text-on-accent" : "border-border-input"
|
|
185
|
-
),
|
|
186
|
-
children: o && /* @__PURE__ */ t(_, { className: "size-3", "aria-hidden": !0 })
|
|
187
|
-
}
|
|
188
|
-
),
|
|
189
|
-
/* @__PURE__ */ t("span", { className: "flex-1", children: e.label }),
|
|
190
|
-
e.description && /* @__PURE__ */ t("span", { className: "text-foreground-subtle text-xs", children: e.description })
|
|
191
|
-
]
|
|
192
|
-
},
|
|
193
|
-
e.value
|
|
194
|
-
);
|
|
195
|
-
}),
|
|
196
|
-
R.length === 0 && /* @__PURE__ */ t(b.Empty, { className: "text-foreground-subtle px-2 py-6 text-center text-sm", children: $ })
|
|
197
|
-
]
|
|
198
|
-
}
|
|
199
|
-
)
|
|
200
|
-
}
|
|
201
|
-
) })
|
|
202
|
-
] }) }),
|
|
203
|
-
x ? /* @__PURE__ */ t("p", { id: H, className: "text-danger-text text-xs", children: x }) : h ? /* @__PURE__ */ t("p", { id: q, className: "text-foreground-subtle text-xs", children: h }) : null
|
|
204
|
-
] });
|
|
2
|
+
import { cn as e } from "../../lib/utils.js";
|
|
3
|
+
import { formatString as t } from "../../lib/strings.js";
|
|
4
|
+
import { useFieldIds as n } from "../../hooks/use-field-ids.js";
|
|
5
|
+
import { useStrings as r } from "../../hooks/use-strings.js";
|
|
6
|
+
import { Check as i, ChevronsUpDown as a, X as o } from "../../icons/index.js";
|
|
7
|
+
import { forwardRef as s, useCallback as c, useMemo as l, useRef as u, useState as d } from "react";
|
|
8
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
9
|
+
import * as m from "@radix-ui/react-popover";
|
|
10
|
+
import { Command as h } from "cmdk";
|
|
11
|
+
//#region src/components/ui/MultiSelect.tsx
|
|
12
|
+
var g = s(function({ options: s, value: g, onChange: _, label: v, helperText: y, error: b, placeholder: x, emptyText: S, maxVisibleChips: C = 3, clearable: w = !0, disabled: T, id: E, className: D }, O) {
|
|
13
|
+
let k = r(), A = x ?? k.multiSelect.placeholder, j = S ?? k.multiSelect.empty, M = !!b, { fieldId: N, helperId: P, errorId: F, describedBy: I } = n(E, {
|
|
14
|
+
hasHelper: !!y,
|
|
15
|
+
hasError: M
|
|
16
|
+
}), [L, R] = d(!1), [z, B] = d(""), V = u(null), H = u(null), [U, W] = d(void 0), G = c((e) => W(e?.id), []), K = l(() => s.filter((e) => g.includes(e.value)), [s, g]), q = c((e) => {
|
|
17
|
+
g.includes(e) ? _(g.filter((t) => t !== e)) : _([...g, e]);
|
|
18
|
+
}, [g, _]), J = c(() => _([]), [_]), Y = (e) => {
|
|
19
|
+
e.key === "Backspace" && z === "" && g.length > 0 ? _(g.slice(0, -1)) : (e.key === "ArrowDown" || e.key === "ArrowUp") && !L && R(!0);
|
|
20
|
+
}, X = l(() => s.filter((e) => e.label.toLowerCase().includes(z.toLowerCase())), [s, z]), Z = K.slice(0, C), Q = K.length - Z.length;
|
|
21
|
+
return /* @__PURE__ */ p("div", {
|
|
22
|
+
ref: O,
|
|
23
|
+
className: e("flex flex-col gap-1.5", D),
|
|
24
|
+
children: [
|
|
25
|
+
v && /* @__PURE__ */ f("label", {
|
|
26
|
+
id: `${N}-label`,
|
|
27
|
+
htmlFor: N,
|
|
28
|
+
className: "text-foreground text-sm font-medium",
|
|
29
|
+
children: v
|
|
30
|
+
}),
|
|
31
|
+
/* @__PURE__ */ f(h, {
|
|
32
|
+
shouldFilter: !1,
|
|
33
|
+
className: "flex w-full flex-col",
|
|
34
|
+
children: /* @__PURE__ */ p(m.Root, {
|
|
35
|
+
open: L,
|
|
36
|
+
onOpenChange: R,
|
|
37
|
+
children: [/* @__PURE__ */ f(m.Anchor, {
|
|
38
|
+
asChild: !0,
|
|
39
|
+
children: /* @__PURE__ */ p("div", {
|
|
40
|
+
ref: H,
|
|
41
|
+
"aria-disabled": T || void 0,
|
|
42
|
+
className: e("bg-card flex h-9 w-full cursor-text items-center gap-1.5 overflow-hidden rounded-md border px-2 py-1 text-sm", "transition-colors duration-[var(--duration-fast)] ease-[var(--ease-out)]", "focus-within:ring-offset-background focus-within:ring-2 focus-within:ring-offset-2", M ? "border-danger focus-within:border-danger focus-within:ring-danger" : "border-border-input focus-within:border-accent focus-within:ring-ring", T && "pointer-events-none opacity-50"),
|
|
43
|
+
onClick: () => {
|
|
44
|
+
V.current?.focus(), T || R(!0);
|
|
45
|
+
},
|
|
46
|
+
children: [/* @__PURE__ */ p("div", {
|
|
47
|
+
className: "flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden",
|
|
48
|
+
children: [
|
|
49
|
+
Z.map((e) => /* @__PURE__ */ p("span", {
|
|
50
|
+
className: "bg-accent-soft text-on-accent-soft inline-flex max-w-[10rem] shrink-0 items-center gap-1 rounded-md px-1.5 py-0.5 text-xs font-medium",
|
|
51
|
+
children: [/* @__PURE__ */ f("span", {
|
|
52
|
+
className: "truncate",
|
|
53
|
+
title: e.label,
|
|
54
|
+
children: e.label
|
|
55
|
+
}), /* @__PURE__ */ f("button", {
|
|
56
|
+
type: "button",
|
|
57
|
+
"aria-label": t(k.multiSelect.remove, { label: e.label }),
|
|
58
|
+
className: "text-on-accent-soft hover:text-foreground focus-visible:ring-ring focus-visible:ring-offset-background relative inline-flex items-center rounded-sm outline-none before:absolute before:-inset-1.5 before:content-[''] focus-visible:ring-2 focus-visible:ring-offset-1",
|
|
59
|
+
onClick: (t) => {
|
|
60
|
+
t.stopPropagation(), q(e.value);
|
|
61
|
+
},
|
|
62
|
+
children: /* @__PURE__ */ f(o, {
|
|
63
|
+
className: "size-3",
|
|
64
|
+
"aria-hidden": !0
|
|
65
|
+
})
|
|
66
|
+
})]
|
|
67
|
+
}, e.value)),
|
|
68
|
+
Q > 0 && /* @__PURE__ */ p("span", {
|
|
69
|
+
className: "bg-background-muted text-foreground-muted shrink-0 rounded-md px-1.5 py-0.5 text-xs font-medium",
|
|
70
|
+
children: ["+", Q]
|
|
71
|
+
}),
|
|
72
|
+
/* @__PURE__ */ f("input", {
|
|
73
|
+
ref: V,
|
|
74
|
+
id: N,
|
|
75
|
+
type: "text",
|
|
76
|
+
autoComplete: "off",
|
|
77
|
+
value: z,
|
|
78
|
+
onChange: (e) => B(e.target.value),
|
|
79
|
+
onFocus: () => R(!0),
|
|
80
|
+
onKeyDown: Y,
|
|
81
|
+
placeholder: Z.length === 0 ? A : void 0,
|
|
82
|
+
role: "combobox",
|
|
83
|
+
"aria-expanded": L,
|
|
84
|
+
"aria-controls": L ? U : void 0,
|
|
85
|
+
"aria-haspopup": "listbox",
|
|
86
|
+
"aria-autocomplete": "list",
|
|
87
|
+
"aria-labelledby": v ? `${N}-label` : void 0,
|
|
88
|
+
"aria-label": v || E ? void 0 : A,
|
|
89
|
+
"aria-invalid": M || void 0,
|
|
90
|
+
"aria-describedby": I,
|
|
91
|
+
className: "placeholder:text-foreground-subtle min-w-[6ch] flex-1 bg-transparent text-lg outline-none md:text-sm",
|
|
92
|
+
disabled: T
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
}), /* @__PURE__ */ p("span", {
|
|
96
|
+
className: "flex shrink-0 items-center gap-1 pl-1",
|
|
97
|
+
children: [w && K.length > 0 && /* @__PURE__ */ f("button", {
|
|
98
|
+
type: "button",
|
|
99
|
+
"aria-label": k.multiSelect.clearAll,
|
|
100
|
+
onClick: (e) => {
|
|
101
|
+
e.stopPropagation(), J();
|
|
102
|
+
},
|
|
103
|
+
className: "text-foreground-subtle hover:text-foreground focus-visible:ring-ring focus-visible:ring-offset-background inline-flex size-6 shrink-0 items-center justify-center rounded-sm outline-none focus-visible:ring-2 focus-visible:ring-offset-2",
|
|
104
|
+
children: /* @__PURE__ */ f(o, {
|
|
105
|
+
className: "size-4",
|
|
106
|
+
"aria-hidden": !0
|
|
107
|
+
})
|
|
108
|
+
}), /* @__PURE__ */ f(a, {
|
|
109
|
+
className: "text-foreground-subtle size-4",
|
|
110
|
+
"aria-hidden": !0
|
|
111
|
+
})]
|
|
112
|
+
})]
|
|
113
|
+
})
|
|
114
|
+
}), /* @__PURE__ */ f(m.Portal, { children: /* @__PURE__ */ f(m.Content, {
|
|
115
|
+
align: "start",
|
|
116
|
+
sideOffset: 4,
|
|
117
|
+
"aria-label": k.command.suggestions,
|
|
118
|
+
className: e("border-border bg-popover text-popover-foreground z-[var(--z-popover)] w-[var(--radix-popover-trigger-width)] overflow-hidden rounded-lg border shadow-md", "data-[state=open]:animate-in data-[state=closed]:animate-out", "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", "data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95"),
|
|
119
|
+
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
120
|
+
onInteractOutside: (e) => {
|
|
121
|
+
let t = e.target;
|
|
122
|
+
t && H.current?.contains(t) && e.preventDefault();
|
|
123
|
+
},
|
|
124
|
+
children: /* @__PURE__ */ p(h.List, {
|
|
125
|
+
ref: G,
|
|
126
|
+
label: k.command.suggestions,
|
|
127
|
+
className: "max-h-64 overflow-y-auto p-1",
|
|
128
|
+
children: [X.map((t) => {
|
|
129
|
+
let n = g.includes(t.value);
|
|
130
|
+
return /* @__PURE__ */ p(h.Item, {
|
|
131
|
+
value: t.value,
|
|
132
|
+
disabled: t.disabled,
|
|
133
|
+
onSelect: () => q(t.value),
|
|
134
|
+
className: e("text-foreground flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm", "data-[selected=true]:bg-background-muted", "data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50"),
|
|
135
|
+
children: [
|
|
136
|
+
/* @__PURE__ */ f("span", {
|
|
137
|
+
"aria-hidden": !0,
|
|
138
|
+
className: e("flex size-4 items-center justify-center rounded-sm border", n ? "border-accent bg-accent text-on-accent" : "border-border-input"),
|
|
139
|
+
children: n && /* @__PURE__ */ f(i, {
|
|
140
|
+
className: "size-3",
|
|
141
|
+
"aria-hidden": !0
|
|
142
|
+
})
|
|
143
|
+
}),
|
|
144
|
+
/* @__PURE__ */ f("span", {
|
|
145
|
+
className: "flex-1",
|
|
146
|
+
children: t.label
|
|
147
|
+
}),
|
|
148
|
+
t.description && /* @__PURE__ */ f("span", {
|
|
149
|
+
className: "text-foreground-subtle text-xs",
|
|
150
|
+
children: t.description
|
|
151
|
+
})
|
|
152
|
+
]
|
|
153
|
+
}, t.value);
|
|
154
|
+
}), X.length === 0 && /* @__PURE__ */ f(h.Empty, {
|
|
155
|
+
className: "text-foreground-subtle px-2 py-6 text-center text-sm",
|
|
156
|
+
children: j
|
|
157
|
+
})]
|
|
158
|
+
})
|
|
159
|
+
}) })]
|
|
160
|
+
})
|
|
161
|
+
}),
|
|
162
|
+
b ? /* @__PURE__ */ f("p", {
|
|
163
|
+
id: F,
|
|
164
|
+
className: "text-danger-text text-xs",
|
|
165
|
+
children: b
|
|
166
|
+
}) : y ? /* @__PURE__ */ f("p", {
|
|
167
|
+
id: P,
|
|
168
|
+
className: "text-foreground-subtle text-xs",
|
|
169
|
+
children: y
|
|
170
|
+
}) : null
|
|
171
|
+
]
|
|
172
|
+
});
|
|
205
173
|
});
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
//# sourceMappingURL=MultiSelect.js.map
|
|
174
|
+
g.displayName = "MultiSelect";
|
|
175
|
+
//#endregion
|
|
176
|
+
export { g as MultiSelect };
|
|
177
|
+
|
|
178
|
+
//# sourceMappingURL=MultiSelect.js.map
|