@spear-ai/spectral 1.21.0 → 1.21.2
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/ButtonGroup/ButtonGroupButton.d.ts.map +1 -1
- package/dist/ButtonGroup/ButtonGroupButton.js +6 -5
- package/dist/ButtonGroup/ButtonGroupButton.js.map +1 -1
- package/dist/ButtonGroup.js +1 -1
- package/dist/ButtonGroup.js.map +1 -1
- package/dist/ButtonIcon.js +2 -2
- package/dist/ButtonIcon.js.map +1 -1
- package/dist/Checkbox.d.ts +1 -0
- package/dist/Checkbox.d.ts.map +1 -1
- package/dist/Checkbox.js +3 -3
- package/dist/Checkbox.js.map +1 -1
- package/dist/Combobox.d.ts.map +1 -1
- package/dist/Combobox.js +2 -2
- package/dist/Combobox.js.map +1 -1
- package/dist/DateTimePicker/Calendar.d.ts +13 -1
- package/dist/DateTimePicker/Calendar.d.ts.map +1 -1
- package/dist/DateTimePicker/Calendar.js +11 -4
- package/dist/DateTimePicker/Calendar.js.map +1 -1
- package/dist/DateTimePicker/DateTimeDisplayInput.d.ts +2 -2
- package/dist/DateTimePicker/DateTimeDisplayInput.d.ts.map +1 -1
- package/dist/DateTimePicker/DateTimeDisplayInput.js +3 -3
- package/dist/DateTimePicker/DateTimeDisplayInput.js.map +1 -1
- package/dist/DateTimePicker.d.ts +17 -4
- package/dist/DateTimePicker.d.ts.map +1 -1
- package/dist/DateTimePicker.js +48 -33
- package/dist/DateTimePicker.js.map +1 -1
- package/dist/Input.d.ts +1 -1
- package/dist/Input.d.ts.map +1 -1
- package/dist/Input.js +24 -17
- package/dist/Input.js.map +1 -1
- package/dist/InputOTP.d.ts +2 -0
- package/dist/InputOTP.d.ts.map +1 -1
- package/dist/InputOTP.js +52 -40
- package/dist/InputOTP.js.map +1 -1
- package/dist/InputSearch.d.ts +2 -2
- package/dist/InputSearch.d.ts.map +1 -1
- package/dist/InputSearch.js +6 -5
- package/dist/InputSearch.js.map +1 -1
- package/dist/Kbd.d.ts.map +1 -1
- package/dist/Kbd.js.map +1 -1
- package/dist/MultiSelect/MultiSelectBase.d.ts.map +1 -1
- package/dist/MultiSelect/MultiSelectBase.js +6 -5
- package/dist/MultiSelect/MultiSelectBase.js.map +1 -1
- package/dist/RadialMenu.d.ts.map +1 -1
- package/dist/RadialMenu.js +3 -4
- package/dist/RadialMenu.js.map +1 -1
- package/dist/RadioButton.js +1 -1
- package/dist/RadioButton.js.map +1 -1
- package/dist/RadioButtonGroup/RadioButtonGroupBase.d.ts +1 -1
- package/dist/RadioButtonGroup/RadioButtonGroupBase.d.ts.map +1 -1
- package/dist/RadioButtonGroup/RadioButtonGroupBase.js +3 -3
- package/dist/RadioButtonGroup/RadioButtonGroupBase.js.map +1 -1
- package/dist/RadioButtonGroup.d.ts +1 -1
- package/dist/RadioGroup.d.ts +6 -5
- package/dist/RadioGroup.d.ts.map +1 -1
- package/dist/RadioGroup.js +18 -14
- package/dist/RadioGroup.js.map +1 -1
- package/dist/Select.d.ts +1 -0
- package/dist/Select.d.ts.map +1 -1
- package/dist/Select.js +3 -3
- package/dist/Select.js.map +1 -1
- package/dist/Slider.js +1 -1
- package/dist/Slider.js.map +1 -1
- package/dist/Switch.d.ts +3 -3
- package/dist/Switch.d.ts.map +1 -1
- package/dist/Switch.js +5 -5
- package/dist/Switch.js.map +1 -1
- package/dist/Textarea.d.ts +3 -3
- package/dist/Textarea.d.ts.map +1 -1
- package/dist/Textarea.js +4 -3
- package/dist/Textarea.js.map +1 -1
- package/dist/primitives/input.d.ts.map +1 -1
- package/dist/primitives/input.js +2 -0
- package/dist/primitives/input.js.map +1 -1
- package/dist/primitives/textarea.d.ts.map +1 -1
- package/dist/primitives/textarea.js +2 -0
- package/dist/primitives/textarea.js.map +1 -1
- package/dist/styles/horizon/colors.css +5 -3
- package/dist/styles/spectral.css +1 -1
- package/dist/utils/formFieldUtils.d.ts +9 -1
- package/dist/utils/formFieldUtils.d.ts.map +1 -1
- package/dist/utils/formFieldUtils.js +19 -2
- package/dist/utils/formFieldUtils.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonGroupButton.d.ts","names":[],"sources":["../../src/components/ButtonGroup/ButtonGroupButton.tsx"],"mappings":";;;;;;;cAKa,cAAA,GAAc,KAAA;;;
|
|
1
|
+
{"version":3,"file":"ButtonGroupButton.d.ts","names":[],"sources":["../../src/components/ButtonGroup/ButtonGroupButton.tsx"],"mappings":";;;;;;;cAKa,cAAA,GAAc,KAAA;;;IAwB1B,iCAAA,CAAA,SAAA;AAAA;EAGC,OAAA;EACA,SAAA;EACA,IAAA;EACA,OAAA;EAAA,GACG;AAAA,GACF,cAAA,aACD,YAAA,QAAoB,cAAA;EAClB,OAAA;AAAA,IACD,oBAAA,CAAA,GAAA,CAAA,OAAA;AAAA"}
|
|
@@ -6,19 +6,20 @@ import { jsx } from "react/jsx-runtime";
|
|
|
6
6
|
import { cva } from "class-variance-authority";
|
|
7
7
|
|
|
8
8
|
//#region src/components/ButtonGroup/ButtonGroupButton.tsx
|
|
9
|
-
const buttonVariants = cva(`gap-2 text-sm font-medium [&_svg:not([class*='size-'])]:size-4 aria-invalid:
|
|
9
|
+
const buttonVariants = cva(`gap-2 text-sm font-medium [&_svg:not([class*='size-'])]:size-4 aria-invalid:border-danger-400 inline-flex shrink-0 cursor-pointer items-center justify-center rounded-[var(--radius,0.375rem)]
|
|
10
|
+
bg-level-two whitespace-nowrap text-text-primary transition-colors outline-none hover:bg-level-four focus-visible:border-accent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent active:bg-accent active:text-text-inverted disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0`, {
|
|
10
11
|
variants: {
|
|
11
12
|
variant: {
|
|
12
13
|
default: "",
|
|
13
|
-
outline: "border border-level-
|
|
14
|
-
divided: "border border-level-
|
|
14
|
+
outline: "border border-level-four",
|
|
15
|
+
divided: "border border-level-four"
|
|
15
16
|
},
|
|
16
17
|
size: {
|
|
17
|
-
md: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
18
18
|
sm: "h-8 gap-1.5 px-3 has-[>svg]:px-2.5",
|
|
19
|
+
md: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
19
20
|
lg: "h-10 px-6 has-[>svg]:px-4",
|
|
20
|
-
"icon-md": "size-9",
|
|
21
21
|
"icon-sm": "size-8",
|
|
22
|
+
"icon-md": "size-9",
|
|
22
23
|
"icon-lg": "size-10"
|
|
23
24
|
}
|
|
24
25
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonGroupButton.js","names":[],"sources":["../../src/components/ButtonGroup/ButtonGroupButton.tsx"],"sourcesContent":["import { Slot } from '@primitives/slot'\nimport { cn } from '@utils/twUtils'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { type ComponentProps } from 'react'\n\nexport const buttonVariants = cva(\n `gap-2 text-sm font-medium [&_svg:not([class*='size-'])]:size-4 aria-invalid:
|
|
1
|
+
{"version":3,"file":"ButtonGroupButton.js","names":[],"sources":["../../src/components/ButtonGroup/ButtonGroupButton.tsx"],"sourcesContent":["import { Slot } from '@primitives/slot'\nimport { cn } from '@utils/twUtils'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { type ComponentProps } from 'react'\n\nexport const buttonVariants = cva(\n `gap-2 text-sm font-medium [&_svg:not([class*='size-'])]:size-4 aria-invalid:border-danger-400 inline-flex shrink-0 cursor-pointer items-center justify-center rounded-[var(--radius,0.375rem)]\n bg-level-two whitespace-nowrap text-text-primary transition-colors outline-none hover:bg-level-four focus-visible:border-accent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent active:bg-accent active:text-text-inverted disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0`,\n {\n variants: {\n variant: {\n default: '',\n outline: 'border border-level-four',\n divided: 'border border-level-four',\n },\n size: {\n sm: 'h-8 gap-1.5 px-3 has-[>svg]:px-2.5',\n md: 'h-9 px-4 py-2 has-[>svg]:px-3',\n lg: 'h-10 px-6 has-[>svg]:px-4',\n 'icon-sm': 'size-8',\n 'icon-md': 'size-9',\n 'icon-lg': 'size-10',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'md',\n },\n },\n)\n\nexport const ButtonGroupButton = ({\n asChild = false,\n className,\n size,\n variant,\n ...props\n}: ComponentProps<'button'> &\n VariantProps<typeof buttonVariants> & {\n asChild?: boolean\n }) => {\n const Comp = asChild ? Slot : 'button'\n\n return <Comp className={cn(buttonVariants({ variant, size, className }))} data-size={size} data-slot='button-group-item' data-variant={variant} {...props} />\n}\nButtonGroupButton.displayName = 'ButtonGroupButton'\n"],"mappings":";;;;;;;;AAKA,MAAa,iBAAiB,IAC5B;iWAEA;CACE,UAAU;EACR,SAAS;GACP,SAAS;GACT,SAAS;GACT,SAAS;GACV;EACD,MAAM;GACJ,IAAI;GACJ,IAAI;GACJ,IAAI;GACJ,WAAW;GACX,WAAW;GACX,WAAW;GACZ;EACF;CACD,iBAAiB;EACf,SAAS;EACT,MAAM;EACP;CACF,CACF;AAED,MAAa,qBAAqB,EAChC,UAAU,OACV,WACA,MACA,SACA,GAAG,YAIG;AAGN,QAAO,oBAFM,UAAU,OAAO,UAEvB;EAAM,WAAW,GAAG,eAAe;GAAE;GAAS;GAAM;GAAW,CAAC,CAAC;EAAE,aAAW;EAAM,aAAU;EAAoB,gBAAc;EAAS,GAAI;EAAS;;AAE/J,kBAAkB,cAAc"}
|
package/dist/ButtonGroup.js
CHANGED
|
@@ -49,7 +49,7 @@ const ButtonGroupItem = ({ asChild, children, className, size, variant, ...props
|
|
|
49
49
|
ButtonGroupItem.displayName = "ButtonGroupItem";
|
|
50
50
|
const ButtonGroupText = ({ asChild = false, className, ...props }) => {
|
|
51
51
|
return /* @__PURE__ */ jsx(asChild ? Slot : "div", {
|
|
52
|
-
className: cn(`
|
|
52
|
+
className: cn(`gap-2 rounded-md px-4 text-sm font-medium shadow-xs [&_svg:not([class*='size-'])]:size-4 flex items-center border [&_svg]:pointer-events-none`, className),
|
|
53
53
|
"data-slot": "button-group-text",
|
|
54
54
|
...props
|
|
55
55
|
});
|
package/dist/ButtonGroup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonGroup.js","names":[],"sources":["../src/components/ButtonGroup/ButtonGroup.tsx"],"sourcesContent":["import { Separator } from '@components/Separator/Separator'\nimport { Slot } from '@primitives/slot'\nimport { cn } from '@utils/twUtils'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { Children, cloneElement, isValidElement, type ComponentProps, type ReactElement } from 'react'\nimport { ButtonGroupButton } from './ButtonGroupButton'\n\ninterface ButtonGroupChildProps {\n size?: 'md' | 'sm' | 'lg' | 'icon-md' | 'icon-sm' | 'icon-lg'\n variant?: 'default' | 'outline' | 'divided'\n}\n\nexport type ButtonGroupProps = ComponentProps<typeof ButtonGroup> & VariantProps<typeof buttonGroupVariants>\n\nexport const buttonGroupVariants = cva(\n `has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2 flex w-fit items-stretch [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 data-[variant='divided']:[&>[data-slot=button-group-item]]:border-y-0 data-[variant='divided']:[&>[data-slot=button-group-item]:first-of-type]:border-l-0 data-[variant='divided']:[&>[data-slot=button-group-item]:last-of-type]:border-r-0 data-[orientation='vertical']:data-[variant='divided']:[&>[data-slot=button-group-item]]:border-x-0 data-[orientation='vertical']:data-[variant='divided']:[&>[data-slot=button-group-item]:first-of-type]:border-t-0 data-[orientation='vertical']:data-[variant='divided']:[&>[data-slot=button-group-item]:last-of-type]:border-b-0`,\n {\n variants: {\n orientation: {\n horizontal: '[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none',\n vertical: 'flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none',\n },\n },\n defaultVariants: {\n orientation: 'horizontal',\n },\n },\n)\n\nexport const ButtonGroup = ({\n children,\n className,\n orientation = 'horizontal',\n size = 'md',\n variant = 'default',\n ...props\n}: ComponentProps<'div'> &\n VariantProps<typeof buttonGroupVariants> & {\n size?: 'md' | 'sm' | 'lg' | 'icon-md' | 'icon-sm' | 'icon-lg'\n variant?: 'default' | 'outline' | 'divided'\n }) => {\n return (\n <div aria-label={props['aria-label']} className={cn(buttonGroupVariants({ orientation }), className)} data-orientation={orientation} data-slot='button-group' data-testid='spectral-button-group' data-variant={variant} role='group' {...props}>\n {Children.map(children, (child) => {\n if (isValidElement<ButtonGroupChildProps>(child) && (child.type === ButtonGroupItem || child.type === ButtonGroupButton)) {\n return cloneElement(child as ReactElement<ButtonGroupChildProps>, {\n variant: child.props.variant ?? variant,\n size: child.props.size ?? size,\n })\n }\n return child\n })}\n </div>\n )\n}\nButtonGroup.displayName = 'ButtonGroup'\n\nexport const ButtonGroupItem = ({\n asChild,\n children,\n className,\n size,\n variant,\n ...props\n}: ComponentProps<'button'> & {\n asChild?: boolean\n size?: 'sm' | 'md' | 'lg' | 'icon-sm' | 'icon-md' | 'icon-lg'\n variant?: 'default' | 'outline' | 'divided'\n}) => {\n return (\n <ButtonGroupButton asChild={asChild} className={cn(className)} data-slot='button-group-item' data-testid='spectral-button-group-item' data-variant={variant} size={size} variant={variant} {...props}>\n {children}\n </ButtonGroupButton>\n )\n}\nButtonGroupItem.displayName = 'ButtonGroupItem'\n\nexport const ButtonGroupText = ({\n asChild = false,\n className,\n ...props\n}: ComponentProps<'div'> & {\n asChild?: boolean\n}) => {\n const Comp = asChild ? Slot : 'div'\n return <Comp className={cn(`
|
|
1
|
+
{"version":3,"file":"ButtonGroup.js","names":[],"sources":["../src/components/ButtonGroup/ButtonGroup.tsx"],"sourcesContent":["import { Separator } from '@components/Separator/Separator'\nimport { Slot } from '@primitives/slot'\nimport { cn } from '@utils/twUtils'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { Children, cloneElement, isValidElement, type ComponentProps, type ReactElement } from 'react'\nimport { ButtonGroupButton } from './ButtonGroupButton'\n\ninterface ButtonGroupChildProps {\n size?: 'md' | 'sm' | 'lg' | 'icon-md' | 'icon-sm' | 'icon-lg'\n variant?: 'default' | 'outline' | 'divided'\n}\n\nexport type ButtonGroupProps = ComponentProps<typeof ButtonGroup> & VariantProps<typeof buttonGroupVariants>\n\nexport const buttonGroupVariants = cva(\n `has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2 flex w-fit items-stretch [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 data-[variant='divided']:[&>[data-slot=button-group-item]]:border-y-0 data-[variant='divided']:[&>[data-slot=button-group-item]:first-of-type]:border-l-0 data-[variant='divided']:[&>[data-slot=button-group-item]:last-of-type]:border-r-0 data-[orientation='vertical']:data-[variant='divided']:[&>[data-slot=button-group-item]]:border-x-0 data-[orientation='vertical']:data-[variant='divided']:[&>[data-slot=button-group-item]:first-of-type]:border-t-0 data-[orientation='vertical']:data-[variant='divided']:[&>[data-slot=button-group-item]:last-of-type]:border-b-0`,\n {\n variants: {\n orientation: {\n horizontal: '[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none',\n vertical: 'flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none',\n },\n },\n defaultVariants: {\n orientation: 'horizontal',\n },\n },\n)\n\nexport const ButtonGroup = ({\n children,\n className,\n orientation = 'horizontal',\n size = 'md',\n variant = 'default',\n ...props\n}: ComponentProps<'div'> &\n VariantProps<typeof buttonGroupVariants> & {\n size?: 'md' | 'sm' | 'lg' | 'icon-md' | 'icon-sm' | 'icon-lg'\n variant?: 'default' | 'outline' | 'divided'\n }) => {\n return (\n <div aria-label={props['aria-label']} className={cn(buttonGroupVariants({ orientation }), className)} data-orientation={orientation} data-slot='button-group' data-testid='spectral-button-group' data-variant={variant} role='group' {...props}>\n {Children.map(children, (child) => {\n if (isValidElement<ButtonGroupChildProps>(child) && (child.type === ButtonGroupItem || child.type === ButtonGroupButton)) {\n return cloneElement(child as ReactElement<ButtonGroupChildProps>, {\n variant: child.props.variant ?? variant,\n size: child.props.size ?? size,\n })\n }\n return child\n })}\n </div>\n )\n}\nButtonGroup.displayName = 'ButtonGroup'\n\nexport const ButtonGroupItem = ({\n asChild,\n children,\n className,\n size,\n variant,\n ...props\n}: ComponentProps<'button'> & {\n asChild?: boolean\n size?: 'sm' | 'md' | 'lg' | 'icon-sm' | 'icon-md' | 'icon-lg'\n variant?: 'default' | 'outline' | 'divided'\n}) => {\n return (\n <ButtonGroupButton asChild={asChild} className={cn(className)} data-slot='button-group-item' data-testid='spectral-button-group-item' data-variant={variant} size={size} variant={variant} {...props}>\n {children}\n </ButtonGroupButton>\n )\n}\nButtonGroupItem.displayName = 'ButtonGroupItem'\n\nexport const ButtonGroupText = ({\n asChild = false,\n className,\n ...props\n}: ComponentProps<'div'> & {\n asChild?: boolean\n}) => {\n const Comp = asChild ? Slot : 'div'\n return <Comp className={cn(`gap-2 rounded-md px-4 text-sm font-medium shadow-xs [&_svg:not([class*='size-'])]:size-4 flex items-center border [&_svg]:pointer-events-none`, className)} data-slot='button-group-text' data-testid='spectral-button-group-text' {...props} />\n}\n\nexport const ButtonGroupSeparator = ({\n className,\n orientation = 'vertical',\n ...props\n}: ComponentProps<typeof Separator> & {\n orientation?: 'vertical' | 'horizontal'\n}) => {\n return <Separator className={cn('m-0! relative self-stretch bg-input-primitive-border data-[orientation=vertical]:h-auto', className)} data-slot='button-group-separator' data-testid='spectral-button-group-separator' orientation={orientation} {...props} />\n}\nButtonGroupSeparator.displayName = 'ButtonGroupSeparator'\n"],"mappings":";;;;;;;;;;AAcA,MAAa,sBAAsB,IACjC,w1BACA;CACE,UAAU,EACR,aAAa;EACX,YAAY;EACZ,UAAU;EACX,EACF;CACD,iBAAiB,EACf,aAAa,cACd;CACF,CACH;AAEA,MAAa,eAAe,EAC1B,UACA,WACA,cAAc,cACd,OAAO,MACP,UAAU,WACV,GAAG,YAKG;AACN,QACE,oBAAC,OAAD;EAAK,cAAY,MAAM;EAAe,WAAW,GAAG,oBAAoB,EAAE,aAAa,CAAC,EAAE,UAAU;EAAE,oBAAkB;EAAa,aAAU;EAAmD,gBAAc;EAAS,MAAK;EAAQ,GAAI;YACvO,SAAS,IAAI,WAAW,UAAU;AACjC,OAAI,eAAsC,MAAM,KAAK,MAAM,SAAS,mBAAmB,MAAM,SAAS,mBACpG,QAAO,aAAa,OAA8C;IAChE,SAAS,MAAM,MAAM,WAAW;IAChC,MAAM,MAAM,MAAM,QAAQ;IAC3B,CAAA;AAEH,UAAO;IACP;EACC;;AAGT,YAAY,cAAc;AAE1B,MAAa,mBAAmB,EAC9B,SACA,UACA,WACA,MACA,SACA,GAAG,YAKC;AACJ,QACE,oBAAC,mBAAD;EAA4B;EAAS,WAAW,GAAG,UAAU;EAAE,aAAU;EAA6D,gBAAc;EAAe;EAAe;EAAS,GAAI;EAC5L;EACgB;;AAGvB,gBAAgB,cAAc;AAE9B,MAAa,mBAAmB,EAC9B,UAAU,OACV,WACA,GAAG,YAGC;AAEJ,QAAO,oBADM,UAAU,OAAO,OACvB;EAAM,WAAW,GAAG,iJAAiJ,UAAU;EAAE,aAAU;EAA6D,GAAI;EAAQ;;AAG7Q,MAAa,wBAAwB,EACnC,WACA,cAAc,YACd,GAAG,YAGC;AACJ,QAAO,oBAAC,WAAD;EAAW,WAAW,GAAG,2FAA2F,UAAU;EAAE,aAAU;EAAoF;EAAa,GAAI;EAAQ;;AAEhQ,qBAAqB,cAAc"}
|
package/dist/ButtonIcon.js
CHANGED
|
@@ -5,8 +5,8 @@ import { cloneElement, isValidElement } from "react";
|
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
|
|
7
7
|
//#region src/components/ButtonIcon/ButtonIcon.tsx
|
|
8
|
-
const buttonStyles = `bg-level-
|
|
9
|
-
active:scale-[0.97] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-
|
|
8
|
+
const buttonStyles = `bg-level-two hover:bg-level-four aspect-square text-text-primary inline-flex shrink-0 items-center justify-center whitespace-nowrap transition-[background-color,color,transform]
|
|
9
|
+
active:scale-[0.97] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent focus:outline-none cursor-pointer [&_svg]:pointer-events-none [&_svg]:shrink-0 disabled:opacity-50
|
|
10
10
|
disabled:pointer-events-none disabled:text-text-secondary disabled:hover:bg-level-one`;
|
|
11
11
|
const sizeConfig = {
|
|
12
12
|
sm: {
|
package/dist/ButtonIcon.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonIcon.js","names":[],"sources":["../src/components/ButtonIcon/ButtonIcon.tsx"],"sourcesContent":["import { LoaderIcon } from '@components/Icons'\nimport { cn } from '@utils/twUtils'\nimport { cloneElement, isValidElement, type ButtonHTMLAttributes, type MouseEvent, type ReactElement, type Ref, type SVGProps } from 'react'\n\ntype IconOrSVG = ReactElement | (() => ReactElement)\n\nexport interface ButtonIconProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick'> {\n className?: string\n icon: IconOrSVG\n isLoading?: boolean\n label: string\n onClick?: (event: MouseEvent<HTMLButtonElement>) => void\n shape?: 'circle' | 'square'\n size?: 'sm' | 'md' | 'lg'\n}\n\nconst buttonStyles = `bg-level-
|
|
1
|
+
{"version":3,"file":"ButtonIcon.js","names":[],"sources":["../src/components/ButtonIcon/ButtonIcon.tsx"],"sourcesContent":["import { LoaderIcon } from '@components/Icons'\nimport { cn } from '@utils/twUtils'\nimport { cloneElement, isValidElement, type ButtonHTMLAttributes, type MouseEvent, type ReactElement, type Ref, type SVGProps } from 'react'\n\ntype IconOrSVG = ReactElement | (() => ReactElement)\n\nexport interface ButtonIconProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick'> {\n className?: string\n icon: IconOrSVG\n isLoading?: boolean\n label: string\n onClick?: (event: MouseEvent<HTMLButtonElement>) => void\n shape?: 'circle' | 'square'\n size?: 'sm' | 'md' | 'lg'\n}\n\nconst buttonStyles = `bg-level-two hover:bg-level-four aspect-square text-text-primary inline-flex shrink-0 items-center justify-center whitespace-nowrap transition-[background-color,color,transform]\n active:scale-[0.97] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent focus:outline-none cursor-pointer [&_svg]:pointer-events-none [&_svg]:shrink-0 disabled:opacity-50\n disabled:pointer-events-none disabled:text-text-secondary disabled:hover:bg-level-one`\n\nconst sizeConfig = {\n sm: { button: 'size-8 min-size-8', icon: 16 },\n md: { button: 'size-10 min-size-10', icon: 24 },\n lg: { button: 'size-12 min-size-12', icon: 32 },\n} as const\n\nexport const ButtonIcon = ({\n className,\n disabled,\n icon,\n isLoading = false,\n label,\n onClick,\n ref,\n shape = 'square',\n size = 'md',\n ...props\n}: ButtonIconProps & {\n ref?: Ref<HTMLButtonElement>\n}) => {\n const handleClick = (event: MouseEvent<HTMLButtonElement>) => onClick?.(event)\n\n const effectiveLabel = isLoading ? `${label} - Loading` : label\n\n const renderIcon = (): ReactElement => {\n if (isLoading) {\n return <LoaderIcon size={sizeConfig[size as keyof typeof sizeConfig].icon} aria-hidden='true' />\n }\n\n const iconElement = typeof icon === 'function' ? icon() : icon\n\n if (isValidElement(iconElement)) {\n const currentSize = sizeConfig[size as keyof typeof sizeConfig].icon\n\n if (iconElement.type === 'svg') {\n return cloneElement(iconElement as ReactElement<SVGProps<SVGSVGElement>>, {\n className: cn('shrink-0', (iconElement.props as { className?: string }).className),\n height: currentSize,\n width: currentSize,\n 'aria-hidden': 'true',\n })\n }\n\n // For icon components, pass size prop if the element accepts it\n const baseIconProps = {\n 'aria-hidden': 'true',\n className: cn('shrink-0', (iconElement.props as { className?: string }).className),\n }\n\n // Check if this is an icon component that accepts size prop\n // All our icon components accept refs and have displayName containing 'Icon'\n const componentType = iconElement.type as { displayName?: string }\n const isIconComponent = componentType.displayName?.endsWith('Icon') ?? false\n\n if (isIconComponent) {\n const iconPropsWithSize = {\n ...baseIconProps,\n size: currentSize,\n }\n return cloneElement(iconElement, iconPropsWithSize)\n }\n\n return cloneElement(iconElement, baseIconProps)\n }\n\n return iconElement\n }\n\n return (\n <button\n aria-label={effectiveLabel}\n className={cn(buttonStyles, shape === 'circle' ? 'rounded-full' : 'rounded-lg', sizeConfig[size as keyof typeof sizeConfig].button, isLoading && 'cursor-wait', disabled && 'cursor-not-allowed opacity-50', className)}\n data-testid='spectral-button-icon'\n disabled={disabled ?? isLoading}\n onClick={handleClick}\n ref={ref}\n type='button'\n {...props}\n >\n {renderIcon()}\n </button>\n )\n}\nButtonIcon.displayName = 'ButtonIcon'\n"],"mappings":";;;;;;;AAgBA,MAAM,eAAe;;;AAIrB,MAAM,aAAa;CACjB,IAAI;EAAE,QAAQ;EAAqB,MAAM;EAAI;CAC7C,IAAI;EAAE,QAAQ;EAAuB,MAAM;EAAI;CAC/C,IAAI;EAAE,QAAQ;EAAuB,MAAM;EAAI;CAChD;AAED,MAAa,cAAc,EACzB,WACA,UACA,MACA,YAAY,OACZ,OACA,SACA,KACA,QAAQ,UACR,OAAO,MACP,GAAG,YAGC;CACJ,MAAM,eAAe,UAAyC,UAAU,MAAK;CAE7E,MAAM,iBAAiB,YAAY,GAAG,MAAM,cAAc;CAE1D,MAAM,mBAAiC;AACrC,MAAI,UACF,QAAO,oBAAC,YAAD;GAAY,MAAM,WAAW,MAAiC;GAAM,eAAY;GAAQ;EAGjG,MAAM,cAAc,OAAO,SAAS,aAAa,MAAM,GAAG;AAE1D,MAAI,eAAe,YAAY,EAAE;GAC/B,MAAM,cAAc,WAAW,MAAiC;AAEhE,OAAI,YAAY,SAAS,MACvB,QAAO,aAAa,aAAsD;IACxE,WAAW,GAAG,YAAa,YAAY,MAAiC,UAAU;IAClF,QAAQ;IACR,OAAO;IACP,eAAe;IAChB,CAAA;GAIH,MAAM,gBAAgB;IACpB,eAAe;IACf,WAAW,GAAG,YAAa,YAAY,MAAiC,UAAU;IACpF;AAOA,OAHsB,YAAY,KACI,aAAa,SAAS,OAAO,IAAI,MAOrE,QAAO,aAAa,aAAa;IAH/B,GAAG;IACH,MAAM;IAE0C,CAAA;AAGpD,UAAO,aAAa,aAAa,cAAa;;AAGhD,SAAO;;AAGT,QACE,oBAAC,UAAD;EACE,cAAY;EACZ,WAAW,GAAG,cAAc,UAAU,WAAW,iBAAiB,cAAc,WAAW,MAAiC,QAAQ,aAAa,eAAe,YAAY,iCAAiC,UAAU;EAEvN,UAAU,YAAY;EACtB,SAAS;EACJ;EACL,MAAK;EACL,GAAI;YAEH,YAAY;EACP;;AAGZ,WAAW,cAAc"}
|
package/dist/Checkbox.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ interface CheckboxProps extends Omit<ComponentPropsWithoutRef<typeof CheckboxBas
|
|
|
13
13
|
errorMessage?: BaseFormFieldProps['errorMessage'];
|
|
14
14
|
id?: string;
|
|
15
15
|
label?: string;
|
|
16
|
+
/** @deprecated Use `label` instead. `labelText` will be removed in a future release. */
|
|
16
17
|
labelText?: string;
|
|
17
18
|
messageReserveLines?: number;
|
|
18
19
|
messageReserveSpace?: boolean;
|
package/dist/Checkbox.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.d.ts","names":[],"sources":["../src/components/Checkbox/Checkbox.tsx"],"mappings":";;;;;;;UAMiB,aAAA,SAAsB,IAAA,CAAK,wBAAA,QAAgC,YAAA;EAC1E,kBAAA;EACA,YAAA;EACA,OAAA;EACA,QAAA;EACA,YAAA,GAAe,kBAAA;EACf,EAAA;EACA,KAAA;
|
|
1
|
+
{"version":3,"file":"Checkbox.d.ts","names":[],"sources":["../src/components/Checkbox/Checkbox.tsx"],"mappings":";;;;;;;UAMiB,aAAA,SAAsB,IAAA,CAAK,wBAAA,QAAgC,YAAA;EAC1E,kBAAA;EACA,YAAA;EACA,OAAA;EACA,QAAA;EACA,YAAA,GAAe,kBAAA;EACf,EAAA;EACA,KAAA;EAFe;EAIf,SAAA;EACA,mBAAA;EACA,mBAAA;EACA,IAAA;EACA,eAAA,GAAkB,KAAA;EAClB,QAAA;EACA,KAAA,GAAQ,cAAA;EACR,KAAA;EACA,cAAA,GAAiB,kBAAA;AAAA;AAAA;EAIjB,OAAA;EACA,SAAA;EACA,YAAA;EACA,EAAA;EACA,KAAA;EACA,SAAA;EACA,mBAAA;EACA,mBAAA;EACA,eAAA;EACA,GAAA;EACA,QAAA;EACA,KAAA;EACA,cAAA;EAAA,oBACoB,eAAA;EAAA,cACN,SAAA;EAAA,GACX;AAAA,GACF,aAAA;EACD,GAAA,GAAM,GAAA,CAAI,YAAA,QAAoB,YAAA;AAAA,IAC/B,oBAAA,CAAA,GAAA,CAAA,OAAA;AAAA"}
|
package/dist/Checkbox.js
CHANGED
|
@@ -3,7 +3,7 @@ import { CheckmarkIcon } from "./Icons/CheckmarkIcon.js";
|
|
|
3
3
|
import { MinusIcon } from "./Icons/MinusIcon.js";
|
|
4
4
|
import { cn } from "./utils/twUtils.js";
|
|
5
5
|
import { ErrorMessage, WarningMessage } from "./FormFieldMessage.js";
|
|
6
|
-
import { useFormFieldId } from "./utils/formFieldUtils.js";
|
|
6
|
+
import { getErrorMessageId, getWarningMessageId, useFormFieldId } from "./utils/formFieldUtils.js";
|
|
7
7
|
import { CheckboxBase, CheckboxIndicator } from "./Checkbox/CheckboxBase.js";
|
|
8
8
|
import "react";
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -12,8 +12,8 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
12
12
|
const Checkbox = ({ checked, className, errorMessage, id, label, labelText, messageReserveLines = 1, messageReserveSpace = false, onCheckedChange, ref, required, state = "default", warningMessage, "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, ...props }) => {
|
|
13
13
|
const inputId = useFormFieldId(id, props.name);
|
|
14
14
|
const resolvedLabel = label ?? labelText;
|
|
15
|
-
const errorMessageId =
|
|
16
|
-
const warningMessageId =
|
|
15
|
+
const errorMessageId = getErrorMessageId(inputId);
|
|
16
|
+
const warningMessageId = getWarningMessageId(inputId);
|
|
17
17
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
18
18
|
/* @__PURE__ */ jsxs("div", {
|
|
19
19
|
className: "gap-2 flex items-start shrink-0",
|
package/dist/Checkbox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","names":[],"sources":["../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import { CheckmarkIcon, MinusIcon } from '@components/Icons'\nimport { ErrorMessage,
|
|
1
|
+
{"version":3,"file":"Checkbox.js","names":[],"sources":["../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import { CheckmarkIcon, MinusIcon } from '@components/Icons'\nimport { ErrorMessage, getErrorMessageId, getWarningMessageId, useFormFieldId, WarningMessage, type BaseFormFieldProps, type FormFieldState } from '@utils/formFieldUtils'\nimport { cn } from '@utils/twUtils'\nimport { type ComponentPropsWithoutRef, type ComponentRef, type Ref } from 'react'\nimport { CheckboxBase, CheckboxIndicator } from './CheckboxBase'\n\nexport interface CheckboxProps extends Omit<ComponentPropsWithoutRef<typeof CheckboxBase>, 'onCheckedChange'> {\n 'aria-describedby'?: string\n 'aria-label'?: string\n checked?: boolean | 'indeterminate'\n disabled?: boolean\n errorMessage?: BaseFormFieldProps['errorMessage']\n id?: string\n label?: string\n /** @deprecated Use `label` instead. `labelText` will be removed in a future release. */\n labelText?: string\n messageReserveLines?: number\n messageReserveSpace?: boolean\n name?: string\n onCheckedChange: (value: boolean | 'indeterminate') => void\n required?: boolean\n state?: FormFieldState\n value?: string\n warningMessage?: BaseFormFieldProps['errorMessage']\n}\n\nexport const Checkbox = ({\n checked,\n className,\n errorMessage,\n id,\n label,\n labelText,\n messageReserveLines = 1,\n messageReserveSpace = false,\n onCheckedChange,\n ref,\n required,\n state = 'default',\n warningMessage,\n 'aria-describedby': ariaDescribedBy,\n 'aria-label': ariaLabel,\n ...props\n}: CheckboxProps & {\n ref?: Ref<ComponentRef<typeof CheckboxBase>>\n}) => {\n const inputId = useFormFieldId(id, props.name)\n const resolvedLabel = label ?? labelText\n const errorMessageId = getErrorMessageId(inputId)\n const warningMessageId = getWarningMessageId(inputId)\n const messageId = state === 'error' && errorMessage && errorMessageId ? errorMessageId : state === 'warning' && warningMessage && warningMessageId ? warningMessageId : undefined\n\n return (\n <div>\n <div className='gap-2 flex items-start shrink-0'>\n <CheckboxBase\n aria-describedby={[messageId, ariaDescribedBy].filter(Boolean).join(' ') || undefined}\n aria-invalid={state === 'error' ? true : undefined}\n aria-label={ariaLabel ?? (!resolvedLabel ? 'Checkbox' : undefined)}\n aria-required={required ?? undefined}\n checked={checked}\n className={cn(\n 'checkbox peer size-5 mt-0.5 border-checkbox-border hover:opacity-80 focus-visible:outline-1 focus-visible:outline-checkbox-border--focus data-[state=checked]:border-checkbox-border--checked',\n className,\n )}\n data-field-state={state}\n data-testid='spectral-checkbox'\n id={inputId}\n onCheckedChange={onCheckedChange}\n ref={ref}\n {...props}\n >\n <CheckboxIndicator data-testid='spectral-checkbox-indicator' className={cn('checkbox-indicator flex items-center justify-center text-checkbox-indicator--checked')}>\n {checked === 'indeterminate' ? <MinusIcon className='checkbox-indeterminate' size={16} strokeWidth={4} /> : <CheckmarkIcon className='checkbox-check' size={16} strokeWidth={4} />}\n </CheckboxIndicator>\n </CheckboxBase>\n {resolvedLabel && (\n <label className='text-md peer-disabled:text-neutral-400 text-text-primary' data-testid='spectral-checkbox-label' htmlFor={inputId}>\n {resolvedLabel}\n </label>\n )}\n </div>\n <ErrorMessage\n dataTestId='spectral-checkbox-error-message'\n id={errorMessageId}\n message={state === 'error' ? errorMessage : null}\n messageReserveLines={messageReserveLines}\n messageReserveSpace={messageReserveSpace && state === 'error'}\n />\n <WarningMessage\n dataTestId='spectral-checkbox-warning-message'\n id={warningMessageId}\n message={state === 'warning' ? warningMessage : null}\n messageReserveLines={messageReserveLines}\n messageReserveSpace={messageReserveSpace && state === 'warning'}\n />\n </div>\n )\n}\n\nCheckbox.displayName = 'Checkbox'\n"],"mappings":";;;;;;;;;;;AA0BA,MAAa,YAAY,EACvB,SACA,WACA,cACA,IACA,OACA,WACA,sBAAsB,GACtB,sBAAsB,OACtB,iBACA,KACA,UACA,QAAQ,WACR,gBACA,oBAAoB,iBACpB,cAAc,WACd,GAAG,YAGC;CACJ,MAAM,UAAU,eAAe,IAAI,MAAM,KAAI;CAC7C,MAAM,gBAAgB,SAAS;CAC/B,MAAM,iBAAiB,kBAAkB,QAAO;CAChD,MAAM,mBAAmB,oBAAoB,QAAO;AAGpD,QACE,qBAAC,OAAD;EACE,qBAAC,OAAD;GAAK,WAAU;aAAf,CACE,oBAAC,cAAD;IACE,oBAAkB,CANR,UAAU,WAAW,gBAAgB,iBAAiB,iBAAiB,UAAU,aAAa,kBAAkB,mBAAmB,mBAAmB,QAMlI,gBAAgB,CAAC,OAAO,QAAQ,CAAC,KAAK,IAAI,IAAI;IAC5E,gBAAc,UAAU,UAAU,OAAO;IACzC,cAAY,cAAc,CAAC,gBAAgB,aAAa;IACxD,iBAAe,YAAY;IAClB;IACT,WAAW,GACT,iMACA,UACD;IACD,oBAAkB;IAElB,IAAI;IACa;IACZ;IACL,GAAI;cAEJ,oBAAC,mBAAD;KAA6D,WAAW,GAAG,uFAAuF;eAC/J,YAAY,kBAAkB,oBAAC,WAAD;MAAW,WAAU;MAAyB,MAAM;MAAI,aAAa;MAAK,IAAG,oBAAC,eAAD;MAAe,WAAU;MAAiB,MAAM;MAAI,aAAa;MAAK;KACjK;IACP,GACb,iBACC,oBAAC,SAAD;IAAO,WAAU;IAAiG,SAAS;cACxH;IACI,EAEN;;EACL,oBAAC,cAAD;GACE,YAAW;GACX,IAAI;GACJ,SAAS,UAAU,UAAU,eAAe;GACvB;GACrB,qBAAqB,uBAAuB,UAAU;GACvD;EACD,oBAAC,gBAAD;GACE,YAAW;GACX,IAAI;GACJ,SAAS,UAAU,YAAY,iBAAiB;GAC3B;GACrB,qBAAqB,uBAAuB,UAAU;GACvD;EACE;;AAIT,SAAS,cAAc"}
|
package/dist/Combobox.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Combobox.d.ts","names":[],"sources":["../src/components/Combobox/Combobox.tsx"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"Combobox.d.ts","names":[],"sources":["../src/components/Combobox/Combobox.tsx"],"mappings":";;;;;;KA2BY,cAAA,GAAiB,UAAA;AAAA,UAEZ,aAAA,SAAsB,IAAA,CAAK,kBAAA;EAC1C,SAAA;EACA,YAAA;EACA,aAAA,GAAgB,aAAA;EAChB,YAAA;EACA,cAAA;EACA,cAAA;EACA,QAAA,IAAY,KAAA;EAPiB;EAS7B,aAAA,IAAiB,KAAA;EACjB,OAAA,EAAS,cAAA;EACT,WAAA;EACA,KAAA,GAAQ,OAAA,CAAQ,cAAA;EAChB,KAAA;EACA,cAAA,GAAiB,kBAAA;AAAA;AAAA;EAIjB,SAAA;EACA,QAAA;EACA,YAAA;EACA,aAAA;EACA,YAAA;EACA,YAAA;EACA,EAAA;EACA,KAAA;EACA,cAAA;EACA,cAAA;EACA,mBAAA;EACA,mBAAA;EACA,IAAA;EACA,QAAA;EACA,aAAA;EACA,OAAA;EACA,WAAA;EACA,GAAA;EACA,QAAA;EACA,KAAA;EACA,KAAA,EAAO,SAAA;EACP,cAAA;EAAA,oBACoB,eAAA;EAAA,cACN;AAAA,GACb,aAAA;EAAkB,GAAA,GAAM,GAAA,CAAI,cAAA;AAAA,IAAiB,oBAAA,CAAA,GAAA,CAAA,OAAA;AAAA"}
|
package/dist/Combobox.js
CHANGED
|
@@ -4,7 +4,7 @@ import { ChevronDownIcon } from "./Icons/ChevronDownIcon.js";
|
|
|
4
4
|
import { LoaderIcon } from "./Icons/LoaderIcon.js";
|
|
5
5
|
import { cn } from "./utils/twUtils.js";
|
|
6
6
|
import { ErrorMessage, WarningMessage } from "./FormFieldMessage.js";
|
|
7
|
-
import { EmptyState, LoadingState, getAriaProps, getDropdownSurfaceClasses, getDropdownWidthStyles, getErrorMessageId, getFormFieldCSSProperties, getOptionClasses, getTriggerClasses, useFormFieldId } from "./utils/formFieldUtils.js";
|
|
7
|
+
import { EmptyState, LoadingState, getAriaProps, getDropdownSurfaceClasses, getDropdownWidthStyles, getErrorMessageId, getFormFieldCSSProperties, getOptionClasses, getTriggerClasses, getWarningMessageId, useFormFieldId } from "./utils/formFieldUtils.js";
|
|
8
8
|
import { useUncontrolledState } from "./hooks/useUncontrolledState.js";
|
|
9
9
|
import { Label } from "./Label.js";
|
|
10
10
|
import { InputGroup, InputGroupAddon } from "./primitives/input-group.js";
|
|
@@ -18,7 +18,7 @@ const Combobox = ({ className, disabled, defaultValue = "", dropdownWidth = "tri
|
|
|
18
18
|
const comboboxId = useFormFieldId(id, name);
|
|
19
19
|
const listboxId = `${comboboxId}-listbox`;
|
|
20
20
|
const errorMessageId = getErrorMessageId(comboboxId);
|
|
21
|
-
const warningMessageId =
|
|
21
|
+
const warningMessageId = getWarningMessageId(comboboxId);
|
|
22
22
|
const messageId = state === "error" ? errorMessageId : state === "warning" && warningMessage ? warningMessageId : void 0;
|
|
23
23
|
const isDisabled = Boolean(disabled);
|
|
24
24
|
const isLoading = state === "loading";
|
package/dist/Combobox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Combobox.js","names":[],"sources":["../src/components/Combobox/Combobox.tsx"],"sourcesContent":["import { Combobox as ComboboxPrimitive } from '@base-ui/react'\nimport { CheckmarkIcon, ChevronDownIcon, LoaderIcon } from '@components/Icons'\nimport { Label } from '@components/Label/Label'\nimport { useUncontrolledState } from '@hooks/useUncontrolledState'\nimport { InputGroup, InputGroupAddon } from '@primitives/input-group'\nimport {\n EmptyState,\n ErrorMessage,\n getAriaProps,\n getDropdownWidthStyles,\n getDropdownSurfaceClasses,\n getErrorMessageId,\n getFormFieldCSSProperties,\n getOptionClasses,\n getTriggerClasses,\n LoadingState,\n WarningMessage,\n useFormFieldId,\n type BaseFormFieldProps,\n type BaseOption,\n type DropdownWidth,\n type FormFieldState,\n} from '@utils/formFieldUtils'\nimport { cn } from '@utils/twUtils'\nimport { useMemo, useRef, useState, type CSSProperties, type MouseEvent, type Ref } from 'react'\n\nexport type ComboboxOption = BaseOption\n\nexport interface ComboboxProps extends Omit<BaseFormFieldProps, 'onChange' | 'state'> {\n className?: string\n defaultValue?: string\n dropdownWidth?: DropdownWidth\n emptyMessage?: string\n labelClassName?: string\n loadingMessage?: string\n onChange?: (value: string) => void\n /** @deprecated Use `onChange` instead. `onValueChange` will be removed in a future release. */\n onValueChange?: (value: string) => void\n options: ComboboxOption[]\n placeholder?: string\n state?: Exclude<FormFieldState, 'disabled'>\n value?: string\n warningMessage?: BaseFormFieldProps['errorMessage']\n}\n\nexport const Combobox = ({\n className,\n disabled,\n defaultValue = '',\n dropdownWidth = 'trigger',\n emptyMessage = 'No options found.',\n errorMessage,\n id,\n label,\n labelClassName,\n loadingMessage = 'Loading…',\n messageReserveLines = 1,\n messageReserveSpace = false,\n name,\n onChange,\n onValueChange,\n options,\n placeholder = 'Search…',\n ref,\n required,\n state = 'default',\n value: valueProp,\n warningMessage,\n 'aria-describedby': ariaDescribedBy,\n 'aria-label': ariaLabel,\n}: ComboboxProps & { ref?: Ref<HTMLDivElement> }) => {\n if (process.env.NODE_ENV !== 'production' && !label && !ariaLabel) {\n console.warn('Combobox: provide either `label` or `aria-label` for an accessible name.')\n }\n\n const comboboxId = useFormFieldId(id, name)\n const listboxId = `${comboboxId}-listbox`\n const errorMessageId = getErrorMessageId(comboboxId)\n const warningMessageId = `${comboboxId}-warning`\n const messageId = state === 'error' ? errorMessageId : state === 'warning' && warningMessage ? warningMessageId : undefined\n const isDisabled = Boolean(disabled)\n const isLoading = state === 'loading'\n const isInvalid = state === 'error'\n const ariaProps = getAriaProps(state, ariaDescribedBy, required, messageId)\n\n const [open, setOpen] = useState(false)\n const [inputValue, setInputValue] = useState('')\n const inputRef = useRef<HTMLInputElement>(null)\n const [value, setValue] = useUncontrolledState<string>({\n value: valueProp,\n defaultValue,\n onChange: (nextValue) => {\n if (onChange) {\n onChange(nextValue)\n } else {\n onValueChange?.(nextValue)\n }\n },\n })\n\n const selectedOption = useMemo(() => options.find((o) => o.value === value) ?? null, [options, value])\n const filteredOptions = useMemo(() => {\n const query = inputValue.trim().toLowerCase()\n if (!query) return options\n return options.filter((option) => option.label.toLowerCase().includes(query))\n }, [inputValue, options])\n const showsSelectedValueAsPlaceholder = Boolean(selectedOption && inputValue.length === 0)\n const { dropdownWidthMode, dropdownWidthStyle } = getDropdownWidthStyles({\n dropdownWidth,\n triggerWidth: 'var(--anchor-width)',\n })\n\n const handleValueChange = (nextOption: ComboboxOption | null, eventDetails: { reason?: string }) => {\n const nextValue = nextOption?.value ?? ''\n const shouldClearSelection = eventDetails.reason === 'item-press' && nextValue === value\n setValue(shouldClearSelection ? '' : nextValue)\n setInputValue('')\n setOpen(false)\n }\n\n const handleOpenChange = (nextOpen: boolean) => {\n if (isDisabled || isLoading) {\n setOpen(false)\n return\n }\n\n if (!nextOpen) {\n setInputValue('')\n }\n\n setOpen(nextOpen)\n }\n\n const handleTriggerContainerClick = (event: MouseEvent<HTMLDivElement>) => {\n if (isDisabled || isLoading) return\n\n const target = event.target as HTMLElement\n if (target === inputRef.current) return\n if (target.closest('[data-slot=combobox-trigger-button]')) return\n inputRef.current?.focus()\n setOpen(true)\n }\n\n return (\n <div className='w-full' ref={ref}>\n {label && (\n <Label className={cn('mb-2 block text-text-primary', labelClassName, isDisabled && 'text-text-secondary')} data-testid='spectral-combobox-label' htmlFor={comboboxId}>\n {label}\n </Label>\n )}\n\n <ComboboxPrimitive.Root\n autoHighlight\n disabled={isDisabled || isLoading}\n filter={null}\n inputValue={inputValue}\n itemToStringLabel={(option: ComboboxOption) => option.label}\n itemToStringValue={(option: ComboboxOption) => option.value}\n openOnInputClick\n onInputValueChange={(nextInputValue, eventDetails) => {\n if (eventDetails.reason !== 'input-change' && eventDetails.reason !== 'input-clear') return\n setInputValue(nextInputValue)\n }}\n name={name}\n onOpenChange={handleOpenChange}\n onValueChange={handleValueChange}\n open={open}\n required={required}\n value={selectedOption}\n >\n <ComboboxPrimitive.InputGroup\n render={\n <InputGroup\n data-slot='combobox-content'\n data-state={state}\n data-testid='spectral-combobox-trigger'\n className={cn(getTriggerClasses(open, state), 'ring-0! outline-none focus-within:outline-none has-[[data-slot=input-group-control]:focus-visible]:outline-0', isDisabled && 'pointer-events-none cursor-not-allowed', className)}\n onClick={handleTriggerContainerClick}\n style={getFormFieldCSSProperties() as CSSProperties}\n />\n }\n >\n <ComboboxPrimitive.Input\n aria-controls={listboxId}\n aria-expanded={open}\n aria-label={ariaLabel ?? label}\n autoComplete='off'\n className={cn(\n 'min-w-0 text-base flex-1 truncate overflow-hidden border-0 bg-transparent whitespace-nowrap text-input-text outline-hidden outline-0 placeholder:opacity-100 focus-visible:ring-0 focus-visible:outline-none',\n showsSelectedValueAsPlaceholder ? 'placeholder:text-input-text!' : 'placeholder:text-input-text-placeholder!',\n )}\n data-slot='input-group-control'\n id={comboboxId}\n ref={inputRef}\n placeholder={selectedOption?.label ?? placeholder}\n {...ariaProps}\n />\n <InputGroupAddon align='inline-end' className='cursor-pointer'>\n <ComboboxPrimitive.Trigger\n aria-label='Toggle options'\n className='cursor-pointer'\n data-slot='combobox-trigger-button'\n >\n {isLoading ? <LoaderIcon className='size-5 motion-safe:animate-spin' /> : <ChevronDownIcon className={cn('size-5 shrink-0 transition-transform duration-200', open && 'rotate-180')} />}\n </ComboboxPrimitive.Trigger>\n </InputGroupAddon>\n </ComboboxPrimitive.InputGroup>\n\n <ComboboxPrimitive.Portal>\n <ComboboxPrimitive.Positioner align='start' className='isolate z-50' sideOffset={4}>\n <ComboboxPrimitive.Popup\n className={cn(\n 'p-1 z-50 motion-safe:data-closed:animate-out motion-safe:data-open:animate-in',\n getDropdownSurfaceClasses(),\n 'motion-safe:data-closed:fade-out-0 motion-safe:data-closed:zoom-out-95 motion-safe:data-open:fade-in-0 motion-safe:data-open:zoom-in-95',\n 'max-h-[min(var(--available-height),18rem)] motion-safe:data-[side=bottom]:slide-in-from-top-2 motion-safe:data-[side=top]:slide-in-from-bottom-2',\n // Keep a single scroll container (the list) to avoid dual scrollbar styles.\n 'min-w-32 origin-(--transform-origin) overflow-hidden',\n )}\n data-dropdown-width-mode={dropdownWidthMode}\n data-dropdown-width-value={dropdownWidthMode === 'custom' ? dropdownWidth : undefined}\n data-testid='spectral-combobox-content'\n style={dropdownWidthStyle}\n >\n {isLoading ? (\n <LoadingState message={loadingMessage} />\n ) : filteredOptions.length === 0 ? (\n <EmptyState message={emptyMessage} />\n ) : (\n <ComboboxPrimitive.List className='max-h-[min(var(--available-height),18rem)] overflow-y-auto' id={listboxId}>\n {filteredOptions.map((option) => (\n <ComboboxPrimitive.Item\n className={cn(getOptionClasses(!!option.disabled, false, value === option.value), 'group/command-item relative flex w-full items-center data-highlighted:bg-input-bg--hover')}\n data-testid='spectral-combobox-item'\n disabled={option.disabled}\n key={option.value}\n value={option}\n >\n <span className='min-w-0 flex-1 truncate whitespace-nowrap'>{option.label}</span>\n <ComboboxPrimitive.ItemIndicator\n render={\n <span className='right-2 h-4 w-4 absolute flex items-center justify-center'>\n <CheckmarkIcon size={16} />\n </span>\n }\n />\n </ComboboxPrimitive.Item>\n ))}\n </ComboboxPrimitive.List>\n )}\n </ComboboxPrimitive.Popup>\n </ComboboxPrimitive.Positioner>\n </ComboboxPrimitive.Portal>\n </ComboboxPrimitive.Root>\n\n <ErrorMessage\n dataTestId='spectral-combobox-error-message'\n id={errorMessageId}\n message={isInvalid ? (errorMessage ?? null) : null}\n messageReserveLines={messageReserveLines}\n messageReserveSpace={messageReserveSpace && state === 'error'}\n />\n <WarningMessage\n dataTestId='spectral-combobox-warning-message'\n id={warningMessageId}\n message={state === 'warning' ? (warningMessage ?? null) : null}\n messageReserveLines={messageReserveLines}\n messageReserveSpace={messageReserveSpace && state === 'warning'}\n />\n </div>\n )\n}\nCombobox.displayName = 'Combobox'\n"],"mappings":";;;;;;;;;;;;;;;AA6CA,MAAa,YAAY,EACvB,WACA,UACA,eAAe,IACf,gBAAgB,WAChB,eAAe,qBACf,cACA,IACA,OACA,gBACA,iBAAiB,YACjB,sBAAsB,GACtB,sBAAsB,OACtB,MACA,UACA,eACA,SACA,cAAc,WACd,KACA,UACA,QAAQ,WACR,OAAO,WACP,gBACA,oBAAoB,iBACpB,cAAc,gBACqC;AACnD,KAA6C,CAAC,SAAS,CAAC,UACtD,SAAQ,KAAK,2EAA0E;CAGzF,MAAM,aAAa,eAAe,IAAI,KAAI;CAC1C,MAAM,YAAY,GAAG,WAAW;CAChC,MAAM,iBAAiB,kBAAkB,WAAU;CACnD,MAAM,mBAAmB,GAAG,WAAW;CACvC,MAAM,YAAY,UAAU,UAAU,iBAAiB,UAAU,aAAa,iBAAiB,mBAAmB;CAClH,MAAM,aAAa,QAAQ,SAAQ;CACnC,MAAM,YAAY,UAAU;CAC5B,MAAM,YAAY,UAAU;CAC5B,MAAM,YAAY,aAAa,OAAO,iBAAiB,UAAU,UAAS;CAE1E,MAAM,CAAC,MAAM,WAAW,SAAS,MAAK;CACtC,MAAM,CAAC,YAAY,iBAAiB,SAAS,GAAE;CAC/C,MAAM,WAAW,OAAyB,KAAI;CAC9C,MAAM,CAAC,OAAO,YAAY,qBAA6B;EACrD,OAAO;EACP;EACA,WAAW,cAAc;AACvB,OAAI,SACF,UAAS,UAAS;OAElB,iBAA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nB;QACE,WAAW,GAAG,iBAAiB,CAAC,CAAC,OAAO,UAAU,OAAO,UAAU,OAAO,MAAM,EAAE,2FAA2F;QAE7K,UAAU,OAAO;QAEjB,OAAO;kBALT,CAOE,oBAAC,QAAD;SAAM,WAAU;mBAA6C,OAAO;SAAY,GAChF,oBAAC,WAAkB,eAAnB,EACE,QACE,oBAAC,QAAD;SAAM,WAAU;mBACd,oBAAC,eAAD,EAAe,MAAM,IAAK;SACtB,GAET,EACqB;UAXjB,OAAO,MAWU,CACxB;OACoB;MAEH;KACG,GACN,EACJ;;GAExB,oBAAC,cAAD;IACE,YAAW;IACX,IAAI;IACJ,SAAS,YAAa,gBAAgB,OAAQ;IACzB;IACrB,qBAAqB,uBAAuB,UAAU;IACvD;GACD,oBAAC,gBAAD;IACE,YAAW;IACX,IAAI;IACJ,SAAS,UAAU,YAAa,kBAAkB,OAAQ;IACrC;IACrB,qBAAqB,uBAAuB,UAAU;IACvD;GACE;;;AAGT,SAAS,cAAc"}
|
|
1
|
+
{"version":3,"file":"Combobox.js","names":[],"sources":["../src/components/Combobox/Combobox.tsx"],"sourcesContent":["import { Combobox as ComboboxPrimitive } from '@base-ui/react'\nimport { CheckmarkIcon, ChevronDownIcon, LoaderIcon } from '@components/Icons'\nimport { Label } from '@components/Label/Label'\nimport { useUncontrolledState } from '@hooks/useUncontrolledState'\nimport { InputGroup, InputGroupAddon } from '@primitives/input-group'\nimport {\n EmptyState,\n ErrorMessage,\n getAriaProps,\n getDropdownWidthStyles,\n getDropdownSurfaceClasses,\n getErrorMessageId,\n getFormFieldCSSProperties,\n getOptionClasses,\n getTriggerClasses,\n getWarningMessageId,\n LoadingState,\n WarningMessage,\n useFormFieldId,\n type BaseFormFieldProps,\n type BaseOption,\n type DropdownWidth,\n type FormFieldState,\n} from '@utils/formFieldUtils'\nimport { cn } from '@utils/twUtils'\nimport { useMemo, useRef, useState, type CSSProperties, type MouseEvent, type Ref } from 'react'\n\nexport type ComboboxOption = BaseOption\n\nexport interface ComboboxProps extends Omit<BaseFormFieldProps, 'onChange' | 'state'> {\n className?: string\n defaultValue?: string\n dropdownWidth?: DropdownWidth\n emptyMessage?: string\n labelClassName?: string\n loadingMessage?: string\n onChange?: (value: string) => void\n /** @deprecated Use `onChange` instead. `onValueChange` will be removed in a future release. */\n onValueChange?: (value: string) => void\n options: ComboboxOption[]\n placeholder?: string\n state?: Exclude<FormFieldState, 'disabled'>\n value?: string\n warningMessage?: BaseFormFieldProps['errorMessage']\n}\n\nexport const Combobox = ({\n className,\n disabled,\n defaultValue = '',\n dropdownWidth = 'trigger',\n emptyMessage = 'No options found.',\n errorMessage,\n id,\n label,\n labelClassName,\n loadingMessage = 'Loading…',\n messageReserveLines = 1,\n messageReserveSpace = false,\n name,\n onChange,\n onValueChange,\n options,\n placeholder = 'Search…',\n ref,\n required,\n state = 'default',\n value: valueProp,\n warningMessage,\n 'aria-describedby': ariaDescribedBy,\n 'aria-label': ariaLabel,\n}: ComboboxProps & { ref?: Ref<HTMLDivElement> }) => {\n if (process.env.NODE_ENV !== 'production' && !label && !ariaLabel) {\n console.warn('Combobox: provide either `label` or `aria-label` for an accessible name.')\n }\n\n const comboboxId = useFormFieldId(id, name)\n const listboxId = `${comboboxId}-listbox`\n const errorMessageId = getErrorMessageId(comboboxId)\n const warningMessageId = getWarningMessageId(comboboxId)\n const messageId = state === 'error' ? errorMessageId : state === 'warning' && warningMessage ? warningMessageId : undefined\n const isDisabled = Boolean(disabled)\n const isLoading = state === 'loading'\n const isInvalid = state === 'error'\n const ariaProps = getAriaProps(state, ariaDescribedBy, required, messageId)\n\n const [open, setOpen] = useState(false)\n const [inputValue, setInputValue] = useState('')\n const inputRef = useRef<HTMLInputElement>(null)\n const [value, setValue] = useUncontrolledState<string>({\n value: valueProp,\n defaultValue,\n onChange: (nextValue) => {\n if (onChange) {\n onChange(nextValue)\n } else {\n onValueChange?.(nextValue)\n }\n },\n })\n\n const selectedOption = useMemo(() => options.find((o) => o.value === value) ?? null, [options, value])\n const filteredOptions = useMemo(() => {\n const query = inputValue.trim().toLowerCase()\n if (!query) return options\n return options.filter((option) => option.label.toLowerCase().includes(query))\n }, [inputValue, options])\n const showsSelectedValueAsPlaceholder = Boolean(selectedOption && inputValue.length === 0)\n const { dropdownWidthMode, dropdownWidthStyle } = getDropdownWidthStyles({\n dropdownWidth,\n triggerWidth: 'var(--anchor-width)',\n })\n\n const handleValueChange = (nextOption: ComboboxOption | null, eventDetails: { reason?: string }) => {\n const nextValue = nextOption?.value ?? ''\n const shouldClearSelection = eventDetails.reason === 'item-press' && nextValue === value\n setValue(shouldClearSelection ? '' : nextValue)\n setInputValue('')\n setOpen(false)\n }\n\n const handleOpenChange = (nextOpen: boolean) => {\n if (isDisabled || isLoading) {\n setOpen(false)\n return\n }\n\n if (!nextOpen) {\n setInputValue('')\n }\n\n setOpen(nextOpen)\n }\n\n const handleTriggerContainerClick = (event: MouseEvent<HTMLDivElement>) => {\n if (isDisabled || isLoading) return\n\n const target = event.target as HTMLElement\n if (target === inputRef.current) return\n if (target.closest('[data-slot=combobox-trigger-button]')) return\n inputRef.current?.focus()\n setOpen(true)\n }\n\n return (\n <div className='w-full' ref={ref}>\n {label && (\n <Label className={cn('mb-2 block text-text-primary', labelClassName, isDisabled && 'text-text-secondary')} data-testid='spectral-combobox-label' htmlFor={comboboxId}>\n {label}\n </Label>\n )}\n\n <ComboboxPrimitive.Root\n autoHighlight\n disabled={isDisabled || isLoading}\n filter={null}\n inputValue={inputValue}\n itemToStringLabel={(option: ComboboxOption) => option.label}\n itemToStringValue={(option: ComboboxOption) => option.value}\n openOnInputClick\n onInputValueChange={(nextInputValue, eventDetails) => {\n if (eventDetails.reason !== 'input-change' && eventDetails.reason !== 'input-clear') return\n setInputValue(nextInputValue)\n }}\n name={name}\n onOpenChange={handleOpenChange}\n onValueChange={handleValueChange}\n open={open}\n required={required}\n value={selectedOption}\n >\n <ComboboxPrimitive.InputGroup\n render={\n <InputGroup\n data-slot='combobox-content'\n data-state={state}\n data-testid='spectral-combobox-trigger'\n className={cn(getTriggerClasses(open, state), 'ring-0! outline-none focus-within:outline-none has-[[data-slot=input-group-control]:focus-visible]:outline-0', isDisabled && 'pointer-events-none cursor-not-allowed', className)}\n onClick={handleTriggerContainerClick}\n style={getFormFieldCSSProperties() as CSSProperties}\n />\n }\n >\n <ComboboxPrimitive.Input\n aria-controls={listboxId}\n aria-expanded={open}\n aria-label={ariaLabel ?? label}\n autoComplete='off'\n className={cn(\n 'min-w-0 text-base flex-1 truncate overflow-hidden border-0 bg-transparent whitespace-nowrap text-input-text outline-hidden outline-0 placeholder:opacity-100 focus-visible:ring-0 focus-visible:outline-none',\n showsSelectedValueAsPlaceholder ? 'placeholder:text-input-text!' : 'placeholder:text-input-text-placeholder!',\n )}\n data-slot='input-group-control'\n id={comboboxId}\n ref={inputRef}\n placeholder={selectedOption?.label ?? placeholder}\n {...ariaProps}\n />\n <InputGroupAddon align='inline-end' className='cursor-pointer'>\n <ComboboxPrimitive.Trigger\n aria-label='Toggle options'\n className='cursor-pointer'\n data-slot='combobox-trigger-button'\n >\n {isLoading ? <LoaderIcon className='size-5 motion-safe:animate-spin' /> : <ChevronDownIcon className={cn('size-5 shrink-0 transition-transform duration-200', open && 'rotate-180')} />}\n </ComboboxPrimitive.Trigger>\n </InputGroupAddon>\n </ComboboxPrimitive.InputGroup>\n\n <ComboboxPrimitive.Portal>\n <ComboboxPrimitive.Positioner align='start' className='isolate z-50' sideOffset={4}>\n <ComboboxPrimitive.Popup\n className={cn(\n 'p-1 z-50 motion-safe:data-closed:animate-out motion-safe:data-open:animate-in',\n getDropdownSurfaceClasses(),\n 'motion-safe:data-closed:fade-out-0 motion-safe:data-closed:zoom-out-95 motion-safe:data-open:fade-in-0 motion-safe:data-open:zoom-in-95',\n 'max-h-[min(var(--available-height),18rem)] motion-safe:data-[side=bottom]:slide-in-from-top-2 motion-safe:data-[side=top]:slide-in-from-bottom-2',\n // Keep a single scroll container (the list) to avoid dual scrollbar styles.\n 'min-w-32 origin-(--transform-origin) overflow-hidden',\n )}\n data-dropdown-width-mode={dropdownWidthMode}\n data-dropdown-width-value={dropdownWidthMode === 'custom' ? dropdownWidth : undefined}\n data-testid='spectral-combobox-content'\n style={dropdownWidthStyle}\n >\n {isLoading ? (\n <LoadingState message={loadingMessage} />\n ) : filteredOptions.length === 0 ? (\n <EmptyState message={emptyMessage} />\n ) : (\n <ComboboxPrimitive.List className='max-h-[min(var(--available-height),18rem)] overflow-y-auto' id={listboxId}>\n {filteredOptions.map((option) => (\n <ComboboxPrimitive.Item\n className={cn(getOptionClasses(!!option.disabled, false, value === option.value), 'group/command-item relative flex w-full items-center data-highlighted:bg-input-bg--hover')}\n data-testid='spectral-combobox-item'\n disabled={option.disabled}\n key={option.value}\n value={option}\n >\n <span className='min-w-0 flex-1 truncate whitespace-nowrap'>{option.label}</span>\n <ComboboxPrimitive.ItemIndicator\n render={\n <span className='right-2 h-4 w-4 absolute flex items-center justify-center'>\n <CheckmarkIcon size={16} />\n </span>\n }\n />\n </ComboboxPrimitive.Item>\n ))}\n </ComboboxPrimitive.List>\n )}\n </ComboboxPrimitive.Popup>\n </ComboboxPrimitive.Positioner>\n </ComboboxPrimitive.Portal>\n </ComboboxPrimitive.Root>\n\n <ErrorMessage\n dataTestId='spectral-combobox-error-message'\n id={errorMessageId}\n message={isInvalid ? (errorMessage ?? null) : null}\n messageReserveLines={messageReserveLines}\n messageReserveSpace={messageReserveSpace && state === 'error'}\n />\n <WarningMessage\n dataTestId='spectral-combobox-warning-message'\n id={warningMessageId}\n message={state === 'warning' ? (warningMessage ?? null) : null}\n messageReserveLines={messageReserveLines}\n messageReserveSpace={messageReserveSpace && state === 'warning'}\n />\n </div>\n )\n}\nCombobox.displayName = 'Combobox'\n"],"mappings":";;;;;;;;;;;;;;;AA8CA,MAAa,YAAY,EACvB,WACA,UACA,eAAe,IACf,gBAAgB,WAChB,eAAe,qBACf,cACA,IACA,OACA,gBACA,iBAAiB,YACjB,sBAAsB,GACtB,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ACE,YAAW;IACX,IAAI;IACJ,SAAS,UAAU,YAAa,kBAAkB,OAAQ;IACrC;IACrB,qBAAqB,uBAAuB,UAAU;IACvD;GACE;;;AAGT,SAAS,cAAc"}
|
|
@@ -7,15 +7,27 @@ type CalendarProps = DayPickerProps & {
|
|
|
7
7
|
disabled?: Matcher | Matcher[];
|
|
8
8
|
disablePastDates?: boolean;
|
|
9
9
|
fixedWeeks?: boolean; /** The locale object used to localize dates. Import from 'react-day-picker/locale'. */
|
|
10
|
-
locale?: Partial<Locale>;
|
|
10
|
+
locale?: Partial<Locale>; /** The earliest selectable date (inclusive). Dates before this are disabled. */
|
|
11
|
+
minDate?: Date; /** The latest selectable date (inclusive). Dates after this are disabled. */
|
|
12
|
+
maxDate?: Date;
|
|
13
|
+
/**
|
|
14
|
+
* The date treated as "today". Receives the `rdp-today` styling and is used as the reference
|
|
15
|
+
* for `disablePastDates`. When `defaultMonth` is not set, the calendar also opens to this date's
|
|
16
|
+
* month. Defaults to the current date. Useful when picking dates around historical data.
|
|
17
|
+
*/
|
|
18
|
+
today?: Date;
|
|
11
19
|
};
|
|
12
20
|
declare function Calendar({
|
|
13
21
|
classNames,
|
|
22
|
+
defaultMonth,
|
|
14
23
|
disabled,
|
|
15
24
|
disablePastDates,
|
|
16
25
|
fixedWeeks,
|
|
17
26
|
locale,
|
|
27
|
+
maxDate,
|
|
28
|
+
minDate,
|
|
18
29
|
showOutsideDays,
|
|
30
|
+
today,
|
|
19
31
|
...props
|
|
20
32
|
}: CalendarProps): _$react_jsx_runtime0.JSX.Element;
|
|
21
33
|
declare namespace Calendar {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.d.ts","names":[],"sources":["../../src/components/DateTimePicker/Calendar.tsx"],"mappings":";;;;;KAKY,aAAA,GAAgB,cAAA;EAC1B,QAAA,GAAW,OAAA,GAAU,OAAA;EACrB,gBAAA;EACA,UAAA,YAHuB;EAKvB,MAAA,GAAS,OAAA,CAAQ,MAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"file":"Calendar.d.ts","names":[],"sources":["../../src/components/DateTimePicker/Calendar.tsx"],"mappings":";;;;;KAKY,aAAA,GAAgB,cAAA;EAC1B,QAAA,GAAW,OAAA,GAAU,OAAA;EACrB,gBAAA;EACA,UAAA,YAHuB;EAKvB,MAAA,GAAS,OAAA,CAAQ,MAAA,GALS;EAO1B,OAAA,GAAU,IAAA,EANW;EAQrB,OAAA,GAAU,IAAA;EAJD;;;;;EAUT,KAAA,GAAQ,IAAA;AAAA;AAAA;EAGiB,UAAA;EAAY,YAAA;EAAc,QAAA;EAAU,gBAAA;EAAyB,UAAA;EAAY,MAAA;EAAQ,OAAA;EAAS,OAAA;EAAS,eAAA;EAAwB,KAAA;EAAA,GAAU;AAAA,GAAS,aAAA,GAAa,oBAAA,CAAA,GAAA,CAAA,OAAA;AAAA"}
|
|
@@ -6,9 +6,14 @@ import { jsx } from "react/jsx-runtime";
|
|
|
6
6
|
import { DayPicker } from "react-day-picker";
|
|
7
7
|
|
|
8
8
|
//#region src/components/DateTimePicker/Calendar.tsx
|
|
9
|
-
const Calendar = ({ classNames, disabled, disablePastDates = true, fixedWeeks, locale, showOutsideDays = true, ...props }) => {
|
|
10
|
-
const
|
|
11
|
-
const combinedDisabled = [
|
|
9
|
+
const Calendar = ({ classNames, defaultMonth, disabled, disablePastDates = true, fixedWeeks, locale, maxDate, minDate, showOutsideDays = true, today, ...props }) => {
|
|
10
|
+
const referenceDate = useMemo(() => today ?? /* @__PURE__ */ new Date(), [today]);
|
|
11
|
+
const combinedDisabled = [
|
|
12
|
+
...disablePastDates ? [{ before: referenceDate }] : [],
|
|
13
|
+
...minDate ? [{ before: minDate }] : [],
|
|
14
|
+
...maxDate ? [{ after: maxDate }] : [],
|
|
15
|
+
...Array.isArray(disabled) ? disabled : disabled ? [disabled] : []
|
|
16
|
+
];
|
|
12
17
|
return /* @__PURE__ */ jsx(DayPicker, {
|
|
13
18
|
...props,
|
|
14
19
|
classNames: {
|
|
@@ -40,10 +45,12 @@ const Calendar = ({ classNames, disabled, disablePastDates = true, fixedWeeks, l
|
|
|
40
45
|
className: cn("size-4", orientation === "left" && "rotate-90", orientation === "right" && "-rotate-90")
|
|
41
46
|
}) },
|
|
42
47
|
"data-slot": "calendar",
|
|
48
|
+
defaultMonth: defaultMonth ?? referenceDate,
|
|
43
49
|
disabled: combinedDisabled.length > 0 ? combinedDisabled : void 0,
|
|
44
50
|
fixedWeeks,
|
|
45
51
|
locale,
|
|
46
|
-
showOutsideDays
|
|
52
|
+
showOutsideDays,
|
|
53
|
+
today: referenceDate
|
|
47
54
|
});
|
|
48
55
|
};
|
|
49
56
|
Calendar.displayName = "Calendar";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.js","names":[],"sources":["../../src/components/DateTimePicker/Calendar.tsx"],"sourcesContent":["import { ChevronDownIcon } from '@components/Icons'\nimport { cn } from '@utils/twUtils'\nimport { useMemo } from 'react'\nimport { DayPicker, type DayPickerProps, type Matcher, type Locale } from 'react-day-picker'\n\nexport type CalendarProps = DayPickerProps & {\n disabled?: Matcher | Matcher[]\n disablePastDates?: boolean\n fixedWeeks?: boolean\n /** The locale object used to localize dates. Import from 'react-day-picker/locale'. */\n locale?: Partial<Locale>\n}\n\nexport const Calendar = ({ classNames, disabled, disablePastDates = true, fixedWeeks, locale, showOutsideDays = true, ...props }: CalendarProps) => {\n //
|
|
1
|
+
{"version":3,"file":"Calendar.js","names":[],"sources":["../../src/components/DateTimePicker/Calendar.tsx"],"sourcesContent":["import { ChevronDownIcon } from '@components/Icons'\nimport { cn } from '@utils/twUtils'\nimport { useMemo } from 'react'\nimport { DayPicker, type DayPickerProps, type Matcher, type Locale } from 'react-day-picker'\n\nexport type CalendarProps = DayPickerProps & {\n disabled?: Matcher | Matcher[]\n disablePastDates?: boolean\n fixedWeeks?: boolean\n /** The locale object used to localize dates. Import from 'react-day-picker/locale'. */\n locale?: Partial<Locale>\n /** The earliest selectable date (inclusive). Dates before this are disabled. */\n minDate?: Date\n /** The latest selectable date (inclusive). Dates after this are disabled. */\n maxDate?: Date\n /**\n * The date treated as \"today\". Receives the `rdp-today` styling and is used as the reference\n * for `disablePastDates`. When `defaultMonth` is not set, the calendar also opens to this date's\n * month. Defaults to the current date. Useful when picking dates around historical data.\n */\n today?: Date\n}\n\nexport const Calendar = ({ classNames, defaultMonth, disabled, disablePastDates = true, fixedWeeks, locale, maxDate, minDate, showOutsideDays = true, today, ...props }: CalendarProps) => {\n // Reference date for the `today` modifier and past-date disabling. Defaults to the current date.\n const referenceDate = useMemo(() => today ?? new Date(), [today])\n\n // Combine user-provided disabled dates with the past-date, min, and max constraints\n const combinedDisabled: Matcher[] = [\n ...(disablePastDates ? [{ before: referenceDate }] : []),\n ...(minDate ? [{ before: minDate }] : []),\n ...(maxDate ? [{ after: maxDate }] : []),\n ...(Array.isArray(disabled) ? disabled : disabled ? [disabled] : []),\n ]\n\n return (\n <DayPicker\n {...props}\n classNames={{\n months: cn('months relative flex'),\n month: cn('month'),\n caption: cn('calendar-header'),\n caption_label: cn('month-title'),\n nav: cn('rdp-nav flex w-full items-center'),\n nav_button: cn('nav-button h-7 w-7 p-0 bg-transparent opacity-50 hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent'),\n button_previous: cn('nav-prev left-1 top-0 absolute'),\n button_next: cn('nav-next right-1 top-0 absolute'),\n table: cn('table w-full border-collapse'),\n head_row: cn('day-head-row flex'),\n head_cell: cn('days-of-week'),\n row: cn('day-row mt-2 flex w-full'),\n cell: cn('day-cell'),\n day: cn('day'),\n day_range_start: cn('day-range-start'),\n day_range_middle: cn('day-range-middle'),\n day_range_end: cn('day-range-end'),\n day_selected: cn('day-selected'),\n day_outside: cn('day-outside'),\n day_disabled: cn('day-disabled'),\n hidden: cn('hidden'),\n ...classNames,\n }}\n components={{\n Chevron: ({ orientation }) => <ChevronDownIcon aria-hidden='true' className={cn('size-4', orientation === 'left' && 'rotate-90', orientation === 'right' && '-rotate-90')} />,\n }}\n data-slot='calendar'\n data-testid='spectral-calendar'\n defaultMonth={defaultMonth ?? referenceDate}\n disabled={combinedDisabled.length > 0 ? combinedDisabled : undefined}\n fixedWeeks={fixedWeeks}\n locale={locale}\n showOutsideDays={showOutsideDays}\n today={referenceDate}\n />\n )\n}\n\nCalendar.displayName = 'Calendar'\n"],"mappings":";;;;;;;;AAuBA,MAAa,YAAY,EAAE,YAAY,cAAc,UAAU,mBAAmB,MAAM,YAAY,QAAQ,SAAS,SAAS,kBAAkB,MAAM,OAAO,GAAG,YAA2B;CAEzL,MAAM,gBAAgB,cAAc,yBAAS,IAAI,MAAM,EAAE,CAAC,MAAM,CAAA;CAGhE,MAAM,mBAA8B;EAClC,GAAI,mBAAmB,CAAC,EAAE,QAAQ,eAAe,CAAC,GAAG,EAAE;EACvD,GAAI,UAAU,CAAC,EAAE,QAAQ,SAAS,CAAC,GAAG,EAAE;EACxC,GAAI,UAAU,CAAC,EAAE,OAAO,SAAS,CAAC,GAAG,EAAE;EACvC,GAAI,MAAM,QAAQ,SAAS,GAAG,WAAW,WAAW,CAAC,SAAS,GAAG,EAAE;EACrE;AAEA,QACE,oBAAC,WAAD;EACE,GAAI;EACJ,YAAY;GACV,QAAQ,GAAG,uBAAuB;GAClC,OAAO,GAAG,QAAQ;GAClB,SAAS,GAAG,kBAAkB;GAC9B,eAAe,GAAG,cAAc;GAChC,KAAK,GAAG,mCAAmC;GAC3C,YAAY,GAAG,mLAAmL;GAClM,iBAAiB,GAAG,iCAAiC;GACrD,aAAa,GAAG,kCAAkC;GAClD,OAAO,GAAG,+BAA+B;GACzC,UAAU,GAAG,oBAAoB;GACjC,WAAW,GAAG,eAAe;GAC7B,KAAK,GAAG,2BAA2B;GACnC,MAAM,GAAG,WAAW;GACpB,KAAK,GAAG,MAAM;GACd,iBAAiB,GAAG,kBAAkB;GACtC,kBAAkB,GAAG,mBAAmB;GACxC,eAAe,GAAG,gBAAgB;GAClC,cAAc,GAAG,eAAe;GAChC,aAAa,GAAG,cAAc;GAC9B,cAAc,GAAG,eAAe;GAChC,QAAQ,GAAG,SAAS;GACpB,GAAG;GACJ;EACD,YAAY,EACV,UAAU,EAAE,kBAAkB,oBAAC,iBAAD;GAAiB,eAAY;GAAO,WAAW,GAAG,UAAU,gBAAgB,UAAU,aAAa,gBAAgB,WAAW,aAAa;GAAI,GAC9K;EACD,aAAU;EAEV,cAAc,gBAAgB;EAC9B,UAAU,iBAAiB,SAAS,IAAI,mBAAmB;EAC/C;EACJ;EACS;EACjB,OAAO;EACR;;AAIL,SAAS,cAAc"}
|
|
@@ -8,12 +8,12 @@ interface DateTimeDisplayInputProps extends Omit<ComponentProps<'div'>, 'onChang
|
|
|
8
8
|
defaultValue?: Date;
|
|
9
9
|
disabled?: boolean;
|
|
10
10
|
endIcon?: ReactNode;
|
|
11
|
+
hideTime?: boolean;
|
|
11
12
|
hourFormat?: HourFormat;
|
|
12
13
|
label?: string;
|
|
13
14
|
locale?: string;
|
|
14
15
|
onChange?: (date: Date | undefined) => void;
|
|
15
|
-
|
|
16
|
-
state?: 'default' | 'disabled' | 'error';
|
|
16
|
+
state?: 'default' | 'disabled' | 'error' | 'warning';
|
|
17
17
|
value?: Date;
|
|
18
18
|
/** @deprecated Use `value` instead */
|
|
19
19
|
date?: Date;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTimeDisplayInput.d.ts","names":[],"sources":["../../src/components/DateTimePicker/DateTimeDisplayInput.tsx"],"mappings":";;;;;;UAOiB,yBAAA,SAAkC,IAAA,CAAK,cAAA;EACtD,YAAA,GAAe,IAAA;EACf,QAAA;EACA,OAAA,GAAU,SAAA;EACV,UAAA,GAAa,UAAA;EACb,KAAA;EACA,MAAA;EACA,QAAA,IAAY,IAAA,EAAM,IAAA;EAClB,
|
|
1
|
+
{"version":3,"file":"DateTimeDisplayInput.d.ts","names":[],"sources":["../../src/components/DateTimePicker/DateTimeDisplayInput.tsx"],"mappings":";;;;;;UAOiB,yBAAA,SAAkC,IAAA,CAAK,cAAA;EACtD,YAAA,GAAe,IAAA;EACf,QAAA;EACA,OAAA,GAAU,SAAA;EACV,QAAA;EACA,UAAA,GAAa,UAAA;EACb,KAAA;EACA,MAAA;EACA,QAAA,IAAY,IAAA,EAAM,IAAA;EAClB,KAAA;EACA,KAAA,GAAQ,IAAA;EAAA;EAGR,IAAA,GAAO,IAAA;EAEe;EAAtB,YAAA,IAAgB,IAAA,EAAM,IAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;cA4WX,oBAAA,EAAoB,OAAA,CAAA,yBAAA,CAAA,IAAA,CAAA,yBAAA,WAAA,OAAA,CAAA,aAAA,CAAA,cAAA"}
|
|
@@ -325,7 +325,7 @@ const SegmentInput = ({ ariaLabel, config, disabled, onLeftFocus, onRightFocus,
|
|
|
325
325
|
* <DateTimeDisplayInput date={date} onDateChange={setDate} />
|
|
326
326
|
* ```
|
|
327
327
|
*/
|
|
328
|
-
const DateTimeDisplayInput = forwardRef(({ className, defaultValue, disabled, endIcon, hourFormat = "12", id, label, locale, onChange,
|
|
328
|
+
const DateTimeDisplayInput = forwardRef(({ className, defaultValue, disabled, endIcon, hourFormat = "12", id, label, locale, onChange, hideTime = false, state = "default", value, "aria-labelledby": ariaLabelledBy, date: legacyDate, onDateChange: legacyOnDateChange, ...props }, ref) => {
|
|
329
329
|
const generatedId = useId();
|
|
330
330
|
const displayInputId = id ?? `datetime-display-input-${generatedId}`;
|
|
331
331
|
const displayLabelId = `${displayInputId}-label`;
|
|
@@ -421,7 +421,7 @@ const DateTimeDisplayInput = forwardRef(({ className, defaultValue, disabled, en
|
|
|
421
421
|
ariaLabel: "Year"
|
|
422
422
|
}
|
|
423
423
|
];
|
|
424
|
-
if (
|
|
424
|
+
if (hideTime) return dateSegments;
|
|
425
425
|
const timeSegments = hourFormat === "24" ? [{
|
|
426
426
|
key: "hour",
|
|
427
427
|
config: SEGMENT_CONFIGS.hour24,
|
|
@@ -449,7 +449,7 @@ const DateTimeDisplayInput = forwardRef(({ className, defaultValue, disabled, en
|
|
|
449
449
|
];
|
|
450
450
|
return [...dateSegments, ...timeSegments];
|
|
451
451
|
}, [
|
|
452
|
-
|
|
452
|
+
hideTime,
|
|
453
453
|
hourFormat,
|
|
454
454
|
periodLabels
|
|
455
455
|
]);
|