@spark-ui/components 17.11.0 → 17.11.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/accordion/index.js +1 -1
- package/dist/accordion/index.js.map +1 -1
- package/dist/accordion/index.mjs +1 -1
- package/dist/accordion/index.mjs.map +1 -1
- package/dist/alert-dialog/index.js +1 -1
- package/dist/alert-dialog/index.js.map +1 -1
- package/dist/alert-dialog/index.mjs +1 -1
- package/dist/alert-dialog/index.mjs.map +1 -1
- package/dist/avatar/index.js +1 -1
- package/dist/avatar/index.js.map +1 -1
- package/dist/avatar/index.mjs +16 -16
- package/dist/avatar/index.mjs.map +1 -1
- package/dist/card/index.js +1 -1
- package/dist/card/index.js.map +1 -1
- package/dist/card/index.mjs +1 -1
- package/dist/card/index.mjs.map +1 -1
- package/dist/carousel/index.js +1 -1
- package/dist/carousel/index.js.map +1 -1
- package/dist/carousel/index.mjs +1 -1
- package/dist/carousel/index.mjs.map +1 -1
- package/dist/checkbox/index.js +1 -1
- package/dist/checkbox/index.mjs +1 -1
- package/dist/{checkbox-xsURzANi.mjs → checkbox-CbMh-21q.mjs} +2 -2
- package/dist/{checkbox-xsURzANi.mjs.map → checkbox-CbMh-21q.mjs.map} +1 -1
- package/dist/{checkbox-DjwbAH09.js → checkbox-hVGRiWC_.js} +2 -2
- package/dist/{checkbox-DjwbAH09.js.map → checkbox-hVGRiWC_.js.map} +1 -1
- package/dist/chip/index.js +1 -1
- package/dist/chip/index.js.map +1 -1
- package/dist/chip/index.mjs +1 -1
- package/dist/chip/index.mjs.map +1 -1
- package/dist/circular-meter/index.js +1 -1
- package/dist/circular-meter/index.js.map +1 -1
- package/dist/circular-meter/index.mjs +28 -28
- package/dist/circular-meter/index.mjs.map +1 -1
- package/dist/combobox/index.js +1 -1
- package/dist/combobox/index.js.map +1 -1
- package/dist/combobox/index.mjs +9 -12
- package/dist/combobox/index.mjs.map +1 -1
- package/dist/dialog/index.js +1 -1
- package/dist/dialog/index.js.map +1 -1
- package/dist/dialog/index.mjs +1 -1
- package/dist/dialog/index.mjs.map +1 -1
- package/dist/drawer/index.js +1 -1
- package/dist/drawer/index.js.map +1 -1
- package/dist/drawer/index.mjs +1 -1
- package/dist/drawer/index.mjs.map +1 -1
- package/dist/dropdown/index.js +1 -1
- package/dist/dropdown/index.js.map +1 -1
- package/dist/dropdown/index.mjs +9 -12
- package/dist/dropdown/index.mjs.map +1 -1
- package/dist/file-upload/index.js +1 -1
- package/dist/file-upload/index.js.map +1 -1
- package/dist/file-upload/index.mjs +3 -3
- package/dist/file-upload/index.mjs.map +1 -1
- package/dist/form-field/index.js +1 -1
- package/dist/form-field/index.mjs +1 -1
- package/dist/form-field-BCqHBvWN.js +2 -0
- package/dist/form-field-BCqHBvWN.js.map +1 -0
- package/dist/{form-field-CV5dzt-I.mjs → form-field-ByLHXtzx.mjs} +27 -27
- package/dist/form-field-ByLHXtzx.mjs.map +1 -0
- package/dist/input/index.js +1 -1
- package/dist/input/index.mjs +1 -1
- package/dist/input-BSCMbnO4.js +2 -0
- package/dist/input-BSCMbnO4.js.map +1 -0
- package/dist/{input-CkqYG4S_.mjs → input-cKdm2R3n.mjs} +3 -3
- package/dist/input-cKdm2R3n.mjs.map +1 -0
- package/dist/input-otp/index.js +1 -1
- package/dist/input-otp/index.js.map +1 -1
- package/dist/input-otp/index.mjs +1 -1
- package/dist/input-otp/index.mjs.map +1 -1
- package/dist/menu/index.js +1 -1
- package/dist/menu/index.js.map +1 -1
- package/dist/menu/index.mjs +1 -1
- package/dist/menu/index.mjs.map +1 -1
- package/dist/meter/index.js +1 -1
- package/dist/meter/index.js.map +1 -1
- package/dist/meter/index.mjs +17 -17
- package/dist/meter/index.mjs.map +1 -1
- package/dist/pagination/index.js +1 -1
- package/dist/pagination/index.js.map +1 -1
- package/dist/pagination/index.mjs +1 -1
- package/dist/pagination/index.mjs.map +1 -1
- package/dist/popover/index.js +1 -1
- package/dist/popover/index.mjs +1 -1
- package/dist/{popover-R1H8ZBP8.mjs → popover-83FABwMs.mjs} +2 -2
- package/dist/popover-83FABwMs.mjs.map +1 -0
- package/dist/popover-Daknmg_Z.js +2 -0
- package/dist/popover-Daknmg_Z.js.map +1 -0
- package/dist/progress/index.js +1 -1
- package/dist/progress/index.mjs +1 -1
- package/dist/{progress-C-Zs94G2.mjs → progress-BfpWgeE1.mjs} +2 -2
- package/dist/{progress-C-Zs94G2.mjs.map → progress-BfpWgeE1.mjs.map} +1 -1
- package/dist/{progress-DaQt4olK.js → progress-DBD2FiQ1.js} +2 -2
- package/dist/{progress-DaQt4olK.js.map → progress-DBD2FiQ1.js.map} +1 -1
- package/dist/progress-tracker/index.js +1 -1
- package/dist/progress-tracker/index.js.map +1 -1
- package/dist/progress-tracker/index.mjs +4 -4
- package/dist/progress-tracker/index.mjs.map +1 -1
- package/dist/radio-group/index.js +1 -1
- package/dist/radio-group/index.js.map +1 -1
- package/dist/radio-group/index.mjs +5 -8
- package/dist/radio-group/index.mjs.map +1 -1
- package/dist/rating/index.js +1 -1
- package/dist/rating/index.mjs +1 -1
- package/dist/rating-display/index.js +1 -1
- package/dist/rating-display/index.js.map +1 -1
- package/dist/rating-display/index.mjs +1 -1
- package/dist/rating-display/index.mjs.map +1 -1
- package/dist/scrolling-list/index.js +1 -1
- package/dist/scrolling-list/index.js.map +1 -1
- package/dist/scrolling-list/index.mjs +15 -15
- package/dist/scrolling-list/index.mjs.map +1 -1
- package/dist/segmented-control/index.js +1 -1
- package/dist/segmented-control/index.js.map +1 -1
- package/dist/segmented-control/index.mjs +1 -1
- package/dist/segmented-control/index.mjs.map +1 -1
- package/dist/segmented-gauge/index.js +1 -1
- package/dist/segmented-gauge/index.js.map +1 -1
- package/dist/segmented-gauge/index.mjs +1 -1
- package/dist/segmented-gauge/index.mjs.map +1 -1
- package/dist/select/index.js +1 -1
- package/dist/select/index.js.map +1 -1
- package/dist/select/index.mjs +2 -2
- package/dist/select/index.mjs.map +1 -1
- package/dist/slider/index.js +1 -1
- package/dist/slider/index.js.map +1 -1
- package/dist/slider/index.mjs +2 -2
- package/dist/slider/index.mjs.map +1 -1
- package/dist/stepper/index.js +1 -1
- package/dist/stepper/index.js.map +1 -1
- package/dist/stepper/index.mjs +2 -2
- package/dist/stepper/index.mjs.map +1 -1
- package/dist/table/index.js +1 -1
- package/dist/table/index.js.map +1 -1
- package/dist/table/index.mjs +35 -35
- package/dist/table/index.mjs.map +1 -1
- package/dist/tabs/index.js +1 -1
- package/dist/tabs/index.js.map +1 -1
- package/dist/tabs/index.mjs +14 -14
- package/dist/tabs/index.mjs.map +1 -1
- package/dist/textarea/index.js +1 -1
- package/dist/textarea/index.mjs +1 -1
- package/package.json +5 -5
- package/dist/form-field-CV5dzt-I.mjs.map +0 -1
- package/dist/form-field-CYGgse45.js +0 -2
- package/dist/form-field-CYGgse45.js.map +0 -1
- package/dist/input-CZGLUZjM.js +0 -2
- package/dist/input-CZGLUZjM.js.map +0 -1
- package/dist/input-CkqYG4S_.mjs.map +0 -1
- package/dist/popover-R1H8ZBP8.mjs.map +0 -1
- package/dist/popover-q0MDNefk.js +0 -2
- package/dist/popover-q0MDNefk.js.map +0 -1
package/dist/slider/index.mjs
CHANGED
|
@@ -16,7 +16,7 @@ var b = r([
|
|
|
16
16
|
let S = v(), C = S.disabled ?? o, w = S.readOnly ?? c, T = S.name ?? l, [E, D] = p(S.labelId), [O, k] = p(0), A = f(null), j = f(null), M = s((e) => {
|
|
17
17
|
D(e);
|
|
18
18
|
}, []), N = s(() => (k((e) => e + 1), () => k((e) => e - 1)), []);
|
|
19
|
-
return /* @__PURE__ */ h(x
|
|
19
|
+
return /* @__PURE__ */ h(x, {
|
|
20
20
|
value: {
|
|
21
21
|
intent: e,
|
|
22
22
|
min: m,
|
|
@@ -168,7 +168,7 @@ var M = r([
|
|
|
168
168
|
defaultVariants: { intent: "support" }
|
|
169
169
|
}), N = a(null), P = () => c(N), F = ({ className: e, ref: t, children: n, ...r }) => {
|
|
170
170
|
let { intent: i, fieldLabelId: a, fieldId: o, thumbRef: s } = S(), c = f(null), l = _(s, t ?? c);
|
|
171
|
-
return /* @__PURE__ */ h(N
|
|
171
|
+
return /* @__PURE__ */ h(N, {
|
|
172
172
|
value: { isInsideThumb: !0 },
|
|
173
173
|
children: /* @__PURE__ */ h(y.Thumb, {
|
|
174
174
|
"data-spark-component": "slider-thumb",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/slider/Slider.styles.ts","../../src/slider/SliderContext.tsx","../../src/slider/Slider.tsx","../../src/slider/SliderControl.tsx","../../src/slider/SliderTrack.styles.ts","../../src/slider/SliderIndicator.tsx","../../src/slider/SliderLabel.tsx","../../src/slider/SliderMaxValue.tsx","../../src/slider/SliderMinValue.tsx","../../src/slider/SliderThumb.styles.ts","../../src/slider/SliderThumbContext.tsx","../../src/slider/SliderThumb.tsx","../../src/slider/SliderTrack.tsx","../../src/slider/useSliderValueBoundaries.ts","../../src/slider/SliderValue.tsx","../../src/slider/index.ts"],"sourcesContent":["import { cva } from 'class-variance-authority'\n\nexport const rootStyles = cva([\n 'grid grid-cols-[1fr_auto] gap-y-sm gap-x-md relative',\n 'touch-none select-none',\n 'data-disabled:cursor-not-allowed data-disabled:opacity-dim-3',\n])\n","import type { RefObject } from 'react'\nimport { createContext, useContext } from 'react'\n\nimport type { SliderProps } from './Slider'\n\nexport type SliderContextInterface = Pick<SliderProps, 'intent' | 'min' | 'max'> & {\n fieldLabelId?: string\n fieldId?: string\n onLabelId?: (id: string | undefined) => void\n hasValueInThumb: boolean\n registerValueInThumb: () => () => void\n controlRef: RefObject<HTMLElement | null>\n thumbRef: RefObject<HTMLElement | null>\n}\n\nexport const SliderContext = createContext<SliderContextInterface>({} as SliderContextInterface)\n\nexport const useSliderContext = () => useContext(SliderContext)\n","import { Slider as BaseSlider } from '@base-ui/react/slider'\nimport { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { ComponentProps, type PropsWithChildren, Ref, useCallback, useRef, useState } from 'react'\n\nimport { rootStyles } from './Slider.styles'\nimport { SliderContext } from './SliderContext'\nimport type { SliderRangeVariantsProps } from './SliderTrack.styles'\n\nexport interface SliderProps\n extends\n Omit<\n ComponentProps<typeof BaseSlider.Root>,\n 'render' | 'orientation' | 'onValueChange' | 'onValueCommitted'\n >,\n PropsWithChildren<SliderRangeVariantsProps> {\n /**\n * The value of the slider when initially rendered. Use when you do not need to control the state of the slider.\n */\n defaultValue?: number\n /**\n * The controlled value of the slider. Must be used in conjunction with `onValueChange`.\n */\n value?: number\n /**\n * Event handler called when the value changes.\n */\n onValueChange?: (value: number) => void\n /**\n * Event handler called when the value changes at the end of an interaction. Useful when you only need to capture a final value e.g. to update a backend service.\n */\n onValueCommit?: (value: number) => void\n /**\n * The name of the slider. Submitted with its owning form as part of a name/value pair.\n * If wrapped with a FormField with a name, will be inherited from it.\n */\n name?: string\n /**\n * When `true`, prevents the user from interacting with the slider.\n * @default false\n */\n disabled?: boolean\n /**\n * Sets the slider as interactive or not.\n */\n readOnly?: boolean\n /**\n * The minimum value for the range.\n * @default 0\n */\n min?: number\n /**\n * The maximum value for the range.\n * @default 100\n */\n max?: number\n /**\n * The stepping interval.\n * @default 1\n */\n step?: number\n ref?: Ref<HTMLDivElement>\n}\n\nexport const Slider = ({\n intent = 'support',\n children,\n className,\n ref,\n value: valueProp,\n defaultValue: defaultValueProp,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n name: nameProp,\n onValueChange,\n onValueCommit,\n min = 0,\n max = 100,\n ...rest\n}: SliderProps) => {\n const field = useFormFieldControl()\n\n const disabled = field.disabled ?? disabledProp\n const readOnly = field.readOnly ?? readOnlyProp\n const name = field.name ?? nameProp\n\n const [labelId, setLabelId] = useState<string | undefined>(field.labelId)\n const [valueInThumbCount, setValueInThumbCount] = useState(0)\n const controlRef = useRef<HTMLElement | null>(null)\n const thumbRef = useRef<HTMLElement | null>(null)\n\n const handleLabelId = useCallback((id: string | undefined) => {\n setLabelId(id)\n }, [])\n\n const registerValueInThumb = useCallback(() => {\n setValueInThumbCount(c => c + 1)\n\n return () => setValueInThumbCount(c => c - 1)\n }, [])\n\n return (\n <SliderContext.Provider\n value={{\n intent,\n min,\n max,\n fieldLabelId: field.labelId || labelId,\n fieldId: field.id,\n onLabelId: handleLabelId,\n hasValueInThumb: valueInThumbCount > 0,\n registerValueInThumb,\n controlRef,\n thumbRef,\n }}\n >\n <BaseSlider.Root\n ref={ref}\n data-spark-component=\"slider\"\n className={rootStyles({ className })}\n orientation=\"horizontal\"\n disabled={disabled || readOnly}\n thumbAlignment=\"edge\"\n name={name}\n aria-describedby={field.description}\n aria-invalid={field.isInvalid}\n aria-disabled={disabled || readOnly ? true : undefined}\n value={valueProp !== undefined ? [valueProp] : undefined}\n defaultValue={defaultValueProp !== undefined ? [defaultValueProp] : undefined}\n onValueChange={\n onValueChange\n ? (value: number | readonly number[]) => {\n const v = Array.isArray(value) ? (value[0] ?? 0) : value\n onValueChange(v)\n }\n : undefined\n }\n onValueCommitted={\n onValueCommit\n ? (value: number | readonly number[]) => {\n const v = Array.isArray(value) ? (value[0] ?? 0) : value\n onValueCommit(v)\n }\n : undefined\n }\n min={min}\n max={max}\n {...rest}\n >\n {children}\n </BaseSlider.Root>\n </SliderContext.Provider>\n )\n}\n\nSlider.displayName = 'Slider'\n","import { Slider as BaseSlider } from '@base-ui/react/slider'\nimport { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps } from 'react'\n\nimport { useSliderContext } from './SliderContext'\n\nexport type SliderControlProps = Omit<ComponentProps<typeof BaseSlider.Control>, 'render'>\n\n/** The container for the slider track and thumb(s). Renders a <div> element. */\nexport const SliderControl = ({ className, ref, ...rest }: SliderControlProps) => {\n const { hasValueInThumb, controlRef } = useSliderContext()\n const mergedRef = useMergeRefs(controlRef, ref)\n\n return (\n <BaseSlider.Control\n data-spark-component=\"slider-control\"\n ref={mergedRef}\n className={cx(\n 'min-h-sz-24 relative col-span-2 flex w-full min-w-0 flex-1 items-center',\n hasValueInThumb && 'mt-xl',\n className\n )}\n {...rest}\n />\n )\n}\n\nSliderControl.displayName = 'Slider.Control'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const trackVariants = cva(['relative grow h-sz-4 bg-on-background/dim-4 rounded-sm'])\n\nexport const rangeVariants = cva(\n [\n 'absolute h-full rounded-sm',\n // Disable transitions during drag to eliminate latency\n 'transition-none',\n ],\n {\n variants: {\n intent: {\n main: ['bg-main'],\n support: ['bg-support'],\n accent: ['bg-accent'],\n info: ['bg-info'],\n neutral: ['bg-neutral'],\n success: ['bg-success'],\n alert: ['bg-alert'],\n error: ['bg-error'],\n },\n },\n defaultVariants: {\n intent: 'support',\n },\n }\n)\n\nexport type SliderRangeVariantsProps = VariantProps<typeof rangeVariants>\n","import { Slider as BaseSlider } from '@base-ui/react/slider'\nimport { ComponentProps } from 'react'\n\nimport { useSliderContext } from './SliderContext'\nimport { rangeVariants } from './SliderTrack.styles'\n\nexport type SliderIndicatorProps = Omit<ComponentProps<typeof BaseSlider.Indicator>, 'render'>\n\n/** The filled portion of the slider track. Renders a <span> element. */\nexport const SliderIndicator = ({ className, ref, ...rest }: SliderIndicatorProps) => {\n const { intent } = useSliderContext()\n\n return (\n <BaseSlider.Indicator\n data-spark-component=\"slider-indicator\"\n ref={ref}\n className={rangeVariants({ intent, className })}\n {...rest}\n />\n )\n}\n\nSliderIndicator.displayName = 'Slider.Indicator'\n","import { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\nimport { cx } from 'class-variance-authority'\nimport { ReactNode, Ref, useEffect, useId, useRef } from 'react'\n\nimport { FormFieldRequiredIndicator } from '../form-field/FormFieldRequiredIndicator'\nimport { Label, LabelProps } from '../label'\nimport { Slottable } from '../slot'\nimport { useSliderContext } from './SliderContext'\n\nconst ID_PREFIX = ':slider-label'\n\nexport interface SliderLabelProps extends LabelProps {\n /**\n * Element shown when the input is required inside the label.\n */\n requiredIndicator?: ReactNode\n ref?: Ref<HTMLLabelElement>\n}\n\n/** The label for the slider. Renders a <label> element. */\nexport const SliderLabel = ({\n htmlFor: htmlForProp,\n id: idProp,\n className,\n children,\n requiredIndicator = <FormFieldRequiredIndicator />,\n asChild,\n ref,\n ...others\n}: SliderLabelProps) => {\n const field = useFormFieldControl()\n const { fieldLabelId, fieldId, onLabelId } = useSliderContext()\n\n // Generate an id if not provided and no FormField labelId is available\n const internalId = useId()\n const generatedId = `${ID_PREFIX}-${internalId}`\n const labelId = idProp || fieldLabelId || field.labelId || generatedId\n\n // Use FormField id for htmlFor if present, otherwise use fieldId from context, or the prop\n const htmlFor = asChild ? undefined : htmlForProp || fieldId || field.id\n\n // Get disabled and required state from FormField if present\n const disabled = field.disabled\n const isRequired = field.isRequired\n\n // Notify SliderContext of the label id if no FormField is present\n const labelRef = useRef<HTMLLabelElement>(null)\n const mergedRef = useMergeRefs(ref, labelRef)\n\n useEffect(() => {\n if (onLabelId && !fieldLabelId && !field.labelId) {\n onLabelId(labelId)\n }\n }, [onLabelId, fieldLabelId, field.labelId, labelId])\n\n return (\n <Label\n ref={mergedRef}\n id={labelId}\n data-spark-component=\"slider-label\"\n htmlFor={htmlFor}\n className={cx(disabled ? 'text-on-surface/dim-3 pointer-events-none' : undefined, className)}\n asChild={asChild}\n {...others}\n >\n <>\n <Slottable>{children}</Slottable>\n {isRequired && requiredIndicator}\n </>\n </Label>\n )\n}\n\nSliderLabel.displayName = 'Slider.Label'\n","import { cx } from 'class-variance-authority'\nimport { forwardRef, type ReactNode } from 'react'\n\nimport { useSliderContext } from './SliderContext'\n\nexport interface SliderMaxValueProps {\n className?: string\n children?: (value: number) => ReactNode\n}\n\n/** Displays the maximum value of the slider. Renders a <div> element. */\nexport const SliderMaxValue = forwardRef<HTMLDivElement, SliderMaxValueProps>(\n ({ className, children }, ref) => {\n const { max = 100 } = useSliderContext()\n\n const content = children ? children(max) : max\n\n return (\n <div\n data-spark-component=\"slider-max-value\"\n ref={ref}\n className={cx('text-on-surface/dim-1 text-body-2 col-start-2 text-right', className)}\n >\n {content}\n </div>\n )\n }\n)\n\nSliderMaxValue.displayName = 'Slider.MaxValue'\n","import { cx } from 'class-variance-authority'\nimport { forwardRef, type ReactNode } from 'react'\n\nimport { useSliderContext } from './SliderContext'\n\nexport interface SliderMinValueProps {\n className?: string\n children?: (value: number) => ReactNode\n}\n\n/** Displays the minimum value of the slider. Renders a <div> element. */\nexport const SliderMinValue = forwardRef<HTMLDivElement, SliderMinValueProps>(\n ({ className, children }, ref) => {\n const { min = 0 } = useSliderContext()\n\n const content = children ? children(min) : min\n\n return (\n <div\n data-spark-component=\"slider-min-value\"\n ref={ref}\n className={cx('text-on-surface/dim-1 text-body-2 col-start-1 text-left', className)}\n >\n {content}\n </div>\n )\n }\n)\n\nSliderMinValue.displayName = 'Slider.MinValue'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const thumbVariants = cva(\n [\n 'relative block size-sz-24 rounded-full cursor-pointer',\n 'outline-hidden',\n 'has-focus-visible:ring-2 has-focus-visible:ring-offset-2 has-focus-visible:ring-focus',\n 'data-disabled:hover:ring-0 data-disabled:cursor-not-allowed data-disabled:before:hidden',\n // visual thumb\n 'after:absolute after:left-1/2 after:top-1/2 after:-translate-x-1/2 after:-translate-y-1/2',\n 'after:size-sz-24 after:rounded-full',\n // hover effect\n 'before:absolute before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2',\n 'before:size-sz-24 before:rounded-full before:border-solid before:border-sm before:transition-all before:duration-75',\n 'hover:before:size-sz-32 data-dragging:before:size-sz-32',\n ],\n {\n variants: {\n intent: {\n main: ['after:bg-main', 'before:bg-main-container before:border-main'],\n support: ['after:bg-support', 'before:bg-support-container before:border-support'],\n accent: ['after:bg-accent', 'before:bg-accent-container before:border-accent'],\n info: ['after:bg-info', 'before:bg-info-container before:border-info'],\n neutral: ['after:bg-neutral', 'before:bg-neutral-container before:border-neutral'],\n success: ['after:bg-success', 'before:bg-success-container before:border-success'],\n alert: ['after:bg-alert', 'before:bg-alert-container before:border-alert'],\n error: ['after:bg-error', 'before:bg-error-container before:border-error'],\n },\n },\n defaultVariants: {\n intent: 'support',\n },\n }\n)\n\nexport type SliderThumbVariantsProps = VariantProps<typeof thumbVariants>\n","import { createContext, useContext } from 'react'\n\nexport interface SliderThumbContextValue {\n isInsideThumb: true\n}\n\nexport const SliderThumbContext = createContext<SliderThumbContextValue | null>(null)\n\nexport const useSliderThumbContext = () => useContext(SliderThumbContext)\n","import { Slider as BaseSlider } from '@base-ui/react/slider'\nimport { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\nimport { ComponentProps, type PropsWithChildren, useRef } from 'react'\n\nimport { useSliderContext } from './SliderContext'\nimport { thumbVariants } from './SliderThumb.styles'\nimport { SliderThumbContext } from './SliderThumbContext'\n\nexport type SliderThumbProps = Omit<ComponentProps<typeof BaseSlider.Thumb>, 'render' | 'index'> &\n PropsWithChildren\n\n/** The draggable handle element of the slider. Renders a <span> element. */\nexport const SliderThumb = ({\n className,\n ref: forwardedRef,\n children,\n ...rest\n}: SliderThumbProps) => {\n const { intent, fieldLabelId, fieldId, thumbRef: contextThumbRef } = useSliderContext()\n\n const innerRef = useRef<HTMLDivElement>(null)\n const ref = useMergeRefs(contextThumbRef, forwardedRef ?? innerRef)\n\n return (\n <SliderThumbContext.Provider value={{ isInsideThumb: true }}>\n <BaseSlider.Thumb\n data-spark-component=\"slider-thumb\"\n ref={ref}\n id={fieldId}\n className={thumbVariants({ intent, className })}\n aria-labelledby={fieldLabelId}\n {...rest}\n >\n {children}\n </BaseSlider.Thumb>\n </SliderThumbContext.Provider>\n )\n}\n\nSliderThumb.displayName = 'Slider.Thumb'\n","import { Slider as BaseSlider } from '@base-ui/react/slider'\nimport { ComponentProps } from 'react'\n\nimport { trackVariants } from './SliderTrack.styles'\n\nexport type SliderTrackProps = Omit<ComponentProps<typeof BaseSlider.Track>, 'render'>\n\n/** The track element of the slider. Renders a <span> element. */\nexport const SliderTrack = ({ className, ref, ...rest }: SliderTrackProps) => {\n return (\n <BaseSlider.Track\n data-spark-component=\"slider-track\"\n ref={ref}\n className={trackVariants({ className })}\n {...rest}\n />\n )\n}\n\nSliderTrack.displayName = 'Slider.Track'\n","import type { RefObject } from 'react'\nimport { useLayoutEffect, useState } from 'react'\n\n/**\n * Computes the translateX (in pixels) to apply to the value element so it stays\n * within the horizontal bounds of the slider control when displayed inside the thumb.\n *\n * @param controlRef - Ref to the slider control (track container)\n * @param thumbRef - Ref to the thumb element\n * @param valueRef - Ref to the value label element\n * @param value - Current slider value (0–100 or min–max), used to re-run when thumb moves\n * @returns translateX in pixels (positive = right, negative = left), or 0 if refs are missing\n */\nexport function useSliderValueBoundaries(\n controlRef: RefObject<HTMLElement | null>,\n thumbRef: RefObject<HTMLElement | null>,\n valueRef: RefObject<HTMLElement | null>,\n value: number\n): number {\n const [translateX, setTranslateX] = useState(0)\n const [refsRetryScheduled, setRefsRetryScheduled] = useState(false)\n\n useLayoutEffect(() => {\n const control = controlRef.current\n const thumb = thumbRef.current\n const valueEl = valueRef.current\n\n if (!control || !thumb || !valueEl) {\n setTranslateX(0)\n // Re-run once on next frame when refs may be set (e.g. Slider.Value mounts after Control/Thumb)\n if (!refsRetryScheduled) {\n requestAnimationFrame(() => setRefsRetryScheduled(true))\n }\n\n return\n }\n\n let cancelled = false\n\n const compute = () => {\n if (cancelled) return\n\n const controlRect = control.getBoundingClientRect()\n const thumbRect = thumb.getBoundingClientRect()\n const valueWidth = valueEl.scrollWidth\n\n // Skip until value label has been laid out (content from render prop may not be ready on first paint)\n if (valueWidth === 0) {\n requestAnimationFrame(compute)\n\n return\n }\n\n const thumbCenterPx = thumbRect.left - controlRect.left + thumbRect.width / 2\n\n const valueCenterMin = valueWidth / 2\n const valueCenterMax = controlRect.width - valueWidth / 2\n\n const clampedCenter = Math.max(valueCenterMin, Math.min(valueCenterMax, thumbCenterPx))\n const nextTranslateX = clampedCenter - thumbCenterPx\n\n setTranslateX(prev => (prev !== nextTranslateX ? nextTranslateX : prev))\n }\n\n compute()\n\n const resizeObserver = new ResizeObserver(compute)\n resizeObserver.observe(control)\n resizeObserver.observe(valueEl)\n\n return () => {\n cancelled = true\n resizeObserver.disconnect()\n }\n }, [controlRef, thumbRef, valueRef, value, refsRetryScheduled])\n\n return translateX\n}\n","import { Slider as BaseSlider } from '@base-ui/react/slider'\nimport { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\nimport { cx } from 'class-variance-authority'\nimport type { ReactNode } from 'react'\nimport { ComponentProps, useCallback, useEffect, useRef, useState } from 'react'\n\nimport { useSliderContext } from './SliderContext'\nimport { useSliderThumbContext } from './SliderThumbContext'\nimport { useSliderValueBoundaries } from './useSliderValueBoundaries'\n\nexport type SliderValueProps = Omit<\n ComponentProps<typeof BaseSlider.Value>,\n 'render' | 'children'\n> & {\n children?: ReactNode | ((formatted: string, value: number) => ReactNode)\n}\n\n/** The current value of the slider. Renders an <output> element. */\nexport const SliderValue = ({ className, children, ref, ...rest }: SliderValueProps) => {\n const { registerValueInThumb, controlRef, thumbRef } = useSliderContext()\n const thumbContext = useSliderThumbContext()\n const isInsideThumb = thumbContext !== null\n\n const valueRef = useRef<HTMLOutputElement | null>(null)\n const mergedRef = useMergeRefs(valueRef, ref)\n\n const [currentValue, setCurrentValue] = useState(0)\n const translateX = useSliderValueBoundaries(controlRef, thumbRef, valueRef, currentValue)\n\n useEffect(() => {\n if (!isInsideThumb) return\n\n return registerValueInThumb()\n }, [isInsideThumb, registerValueInThumb])\n\n const resolvedClassName = cx(\n isInsideThumb\n ? 'absolute left-1/2 -translate-x-1/2 top-[calc(-100%-var(--spacing-sm))] text-body-1-highlight whitespace-nowrap'\n : 'default:text-body-1-highlight col-start-2 text-right',\n className\n )\n\n const normalizedChildren = useCallback(\n (formattedValues: readonly string[], values: readonly number[]) => {\n const formatted = formattedValues[0] ?? String(values[0] ?? '')\n const value = values[0] ?? 0\n setCurrentValue(value)\n if (typeof children === 'function') {\n return children(formatted, value)\n }\n\n return formatted\n },\n [children]\n )\n\n const style = isInsideThumb\n ? { transform: `translate(calc(0% + ${translateX}px), 0)` }\n : undefined\n\n return (\n <BaseSlider.Value\n data-spark-component=\"slider-value\"\n ref={mergedRef}\n className={resolvedClassName}\n style={style}\n {...rest}\n >\n {normalizedChildren}\n </BaseSlider.Value>\n )\n}\n\nSliderValue.displayName = 'Slider.Value'\n","import { Slider as Root, type SliderProps } from './Slider'\nimport { SliderControl as Control, type SliderControlProps } from './SliderControl'\nimport { SliderIndicator as Indicator, type SliderIndicatorProps } from './SliderIndicator'\nimport { SliderLabel as Label, type SliderLabelProps } from './SliderLabel'\nimport { SliderMaxValue as MaxValue, type SliderMaxValueProps } from './SliderMaxValue'\nimport { SliderMinValue as MinValue, type SliderMinValueProps } from './SliderMinValue'\nimport { SliderThumb as Thumb, type SliderThumbProps } from './SliderThumb'\nimport { SliderTrack as Track, type SliderTrackProps } from './SliderTrack'\nimport { SliderValue as Value, type SliderValueProps } from './SliderValue'\n\n/**\n * An input control that allows users to select a value from a continuous range by dragging a handle.\n */\nexport const Slider: typeof Root & {\n Control: typeof Control\n Indicator: typeof Indicator\n Label: typeof Label\n MaxValue: typeof MaxValue\n MinValue: typeof MinValue\n Thumb: typeof Thumb\n Track: typeof Track\n Value: typeof Value\n} = Object.assign(Root, {\n Control,\n Indicator,\n Label,\n MaxValue,\n MinValue,\n Thumb,\n Track,\n Value,\n})\n\nSlider.displayName = 'Slider'\nControl.displayName = 'Slider.Control'\nIndicator.displayName = 'Slider.Indicator'\nLabel.displayName = 'Slider.Label'\nMaxValue.displayName = 'Slider.MaxValue'\nMinValue.displayName = 'Slider.MinValue'\nThumb.displayName = 'Slider.Thumb'\nTrack.displayName = 'Slider.Track'\nValue.displayName = 'Slider.Value'\n\nexport type {\n SliderProps,\n SliderControlProps,\n SliderIndicatorProps,\n SliderLabelProps,\n SliderMaxValueProps,\n SliderMinValueProps,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,KAAa,aACf,EAAS,GAAW,EAAM,GAG5B;IAET,CAAC,EAAS,CACX,EAEK,IAAQ,IACV,EAAE,WAAW,uBAAuB,EAAW,UAAU,GACzD,KAAA;AAEJ,QACE,kBAAC,EAAW,OAAZ;EACE,wBAAqB;EACrB,KAAK;EACL,WAAW;EACJ;EACP,GAAI;YAEH;EACgB,CAAA;;AAIvB,EAAY,cAAc;;;AC5D1B,IAAa,IAST,OAAO,OAAO,GAAM;CACtB,SAAA;CACA,WAAA;CACA,OAAA;CACA,UAAA;CACA,UAAA;CACA,OAAA;CACA,OAAA;CACA,OAAA;CACD,CAAC;AAEF,EAAO,cAAc,UACrB,EAAQ,cAAc,kBACtB,EAAU,cAAc,oBACxB,EAAM,cAAc,gBACpB,EAAS,cAAc,mBACvB,EAAS,cAAc,mBACvB,EAAM,cAAc,gBACpB,EAAM,cAAc,gBACpB,EAAM,cAAc"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/slider/Slider.styles.ts","../../src/slider/SliderContext.tsx","../../src/slider/Slider.tsx","../../src/slider/SliderControl.tsx","../../src/slider/SliderTrack.styles.ts","../../src/slider/SliderIndicator.tsx","../../src/slider/SliderLabel.tsx","../../src/slider/SliderMaxValue.tsx","../../src/slider/SliderMinValue.tsx","../../src/slider/SliderThumb.styles.ts","../../src/slider/SliderThumbContext.tsx","../../src/slider/SliderThumb.tsx","../../src/slider/SliderTrack.tsx","../../src/slider/useSliderValueBoundaries.ts","../../src/slider/SliderValue.tsx","../../src/slider/index.ts"],"sourcesContent":["import { cva } from 'class-variance-authority'\n\nexport const rootStyles = cva([\n 'grid grid-cols-[1fr_auto] gap-y-sm gap-x-md relative',\n 'touch-none select-none',\n 'data-disabled:cursor-not-allowed data-disabled:opacity-dim-3',\n])\n","import type { RefObject } from 'react'\nimport { createContext, useContext } from 'react'\n\nimport type { SliderProps } from './Slider'\n\nexport type SliderContextInterface = Pick<SliderProps, 'intent' | 'min' | 'max'> & {\n fieldLabelId?: string\n fieldId?: string\n onLabelId?: (id: string | undefined) => void\n hasValueInThumb: boolean\n registerValueInThumb: () => () => void\n controlRef: RefObject<HTMLElement | null>\n thumbRef: RefObject<HTMLElement | null>\n}\n\nexport const SliderContext = createContext<SliderContextInterface>({} as SliderContextInterface)\n\nexport const useSliderContext = () => useContext(SliderContext)\n","import { Slider as BaseSlider } from '@base-ui/react/slider'\nimport { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { ComponentProps, type PropsWithChildren, Ref, useCallback, useRef, useState } from 'react'\n\nimport { rootStyles } from './Slider.styles'\nimport { SliderContext } from './SliderContext'\nimport type { SliderRangeVariantsProps } from './SliderTrack.styles'\n\nexport interface SliderProps\n extends\n Omit<\n ComponentProps<typeof BaseSlider.Root>,\n 'render' | 'orientation' | 'onValueChange' | 'onValueCommitted'\n >,\n PropsWithChildren<SliderRangeVariantsProps> {\n /**\n * The value of the slider when initially rendered. Use when you do not need to control the state of the slider.\n */\n defaultValue?: number\n /**\n * The controlled value of the slider. Must be used in conjunction with `onValueChange`.\n */\n value?: number\n /**\n * Event handler called when the value changes.\n */\n onValueChange?: (value: number) => void\n /**\n * Event handler called when the value changes at the end of an interaction. Useful when you only need to capture a final value e.g. to update a backend service.\n */\n onValueCommit?: (value: number) => void\n /**\n * The name of the slider. Submitted with its owning form as part of a name/value pair.\n * If wrapped with a FormField with a name, will be inherited from it.\n */\n name?: string\n /**\n * When `true`, prevents the user from interacting with the slider.\n * @default false\n */\n disabled?: boolean\n /**\n * Sets the slider as interactive or not.\n */\n readOnly?: boolean\n /**\n * The minimum value for the range.\n * @default 0\n */\n min?: number\n /**\n * The maximum value for the range.\n * @default 100\n */\n max?: number\n /**\n * The stepping interval.\n * @default 1\n */\n step?: number\n ref?: Ref<HTMLDivElement>\n}\n\nexport const Slider = ({\n intent = 'support',\n children,\n className,\n ref,\n value: valueProp,\n defaultValue: defaultValueProp,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n name: nameProp,\n onValueChange,\n onValueCommit,\n min = 0,\n max = 100,\n ...rest\n}: SliderProps) => {\n const field = useFormFieldControl()\n\n const disabled = field.disabled ?? disabledProp\n const readOnly = field.readOnly ?? readOnlyProp\n const name = field.name ?? nameProp\n\n const [labelId, setLabelId] = useState<string | undefined>(field.labelId)\n const [valueInThumbCount, setValueInThumbCount] = useState(0)\n const controlRef = useRef<HTMLElement | null>(null)\n const thumbRef = useRef<HTMLElement | null>(null)\n\n const handleLabelId = useCallback((id: string | undefined) => {\n setLabelId(id)\n }, [])\n\n const registerValueInThumb = useCallback(() => {\n setValueInThumbCount(c => c + 1)\n\n return () => setValueInThumbCount(c => c - 1)\n }, [])\n\n return (\n <SliderContext\n value={{\n intent,\n min,\n max,\n fieldLabelId: field.labelId || labelId,\n fieldId: field.id,\n onLabelId: handleLabelId,\n hasValueInThumb: valueInThumbCount > 0,\n registerValueInThumb,\n controlRef,\n thumbRef,\n }}\n >\n <BaseSlider.Root\n ref={ref}\n data-spark-component=\"slider\"\n className={rootStyles({ className })}\n orientation=\"horizontal\"\n disabled={disabled || readOnly}\n thumbAlignment=\"edge\"\n name={name}\n aria-describedby={field.description}\n aria-invalid={field.isInvalid}\n aria-disabled={disabled || readOnly ? true : undefined}\n value={valueProp !== undefined ? [valueProp] : undefined}\n defaultValue={defaultValueProp !== undefined ? [defaultValueProp] : undefined}\n onValueChange={\n onValueChange\n ? (value: number | readonly number[]) => {\n const v = Array.isArray(value) ? (value[0] ?? 0) : value\n onValueChange(v)\n }\n : undefined\n }\n onValueCommitted={\n onValueCommit\n ? (value: number | readonly number[]) => {\n const v = Array.isArray(value) ? (value[0] ?? 0) : value\n onValueCommit(v)\n }\n : undefined\n }\n min={min}\n max={max}\n {...rest}\n >\n {children}\n </BaseSlider.Root>\n </SliderContext>\n )\n}\n\nSlider.displayName = 'Slider'\n","import { Slider as BaseSlider } from '@base-ui/react/slider'\nimport { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps } from 'react'\n\nimport { useSliderContext } from './SliderContext'\n\nexport type SliderControlProps = Omit<ComponentProps<typeof BaseSlider.Control>, 'render'>\n\n/** The container for the slider track and thumb(s). Renders a <div> element. */\nexport const SliderControl = ({ className, ref, ...rest }: SliderControlProps) => {\n const { hasValueInThumb, controlRef } = useSliderContext()\n const mergedRef = useMergeRefs(controlRef, ref)\n\n return (\n <BaseSlider.Control\n data-spark-component=\"slider-control\"\n ref={mergedRef}\n className={cx(\n 'min-h-sz-24 relative col-span-2 flex w-full min-w-0 flex-1 items-center',\n hasValueInThumb && 'mt-xl',\n className\n )}\n {...rest}\n />\n )\n}\n\nSliderControl.displayName = 'Slider.Control'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const trackVariants = cva(['relative grow h-sz-4 bg-on-background/dim-4 rounded-sm'])\n\nexport const rangeVariants = cva(\n [\n 'absolute h-full rounded-sm',\n // Disable transitions during drag to eliminate latency\n 'transition-none',\n ],\n {\n variants: {\n intent: {\n main: ['bg-main'],\n support: ['bg-support'],\n accent: ['bg-accent'],\n info: ['bg-info'],\n neutral: ['bg-neutral'],\n success: ['bg-success'],\n alert: ['bg-alert'],\n error: ['bg-error'],\n },\n },\n defaultVariants: {\n intent: 'support',\n },\n }\n)\n\nexport type SliderRangeVariantsProps = VariantProps<typeof rangeVariants>\n","import { Slider as BaseSlider } from '@base-ui/react/slider'\nimport { ComponentProps } from 'react'\n\nimport { useSliderContext } from './SliderContext'\nimport { rangeVariants } from './SliderTrack.styles'\n\nexport type SliderIndicatorProps = Omit<ComponentProps<typeof BaseSlider.Indicator>, 'render'>\n\n/** The filled portion of the slider track. Renders a <span> element. */\nexport const SliderIndicator = ({ className, ref, ...rest }: SliderIndicatorProps) => {\n const { intent } = useSliderContext()\n\n return (\n <BaseSlider.Indicator\n data-spark-component=\"slider-indicator\"\n ref={ref}\n className={rangeVariants({ intent, className })}\n {...rest}\n />\n )\n}\n\nSliderIndicator.displayName = 'Slider.Indicator'\n","import { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\nimport { cx } from 'class-variance-authority'\nimport { ReactNode, Ref, useEffect, useId, useRef } from 'react'\n\nimport { FormFieldRequiredIndicator } from '../form-field/FormFieldRequiredIndicator'\nimport { Label, LabelProps } from '../label'\nimport { Slottable } from '../slot'\nimport { useSliderContext } from './SliderContext'\n\nconst ID_PREFIX = ':slider-label'\n\nexport interface SliderLabelProps extends LabelProps {\n /**\n * Element shown when the input is required inside the label.\n */\n requiredIndicator?: ReactNode\n ref?: Ref<HTMLLabelElement>\n}\n\n/** The label for the slider. Renders a <label> element. */\nexport const SliderLabel = ({\n htmlFor: htmlForProp,\n id: idProp,\n className,\n children,\n requiredIndicator = <FormFieldRequiredIndicator />,\n asChild,\n ref,\n ...others\n}: SliderLabelProps) => {\n const field = useFormFieldControl()\n const { fieldLabelId, fieldId, onLabelId } = useSliderContext()\n\n // Generate an id if not provided and no FormField labelId is available\n const internalId = useId()\n const generatedId = `${ID_PREFIX}-${internalId}`\n const labelId = idProp || fieldLabelId || field.labelId || generatedId\n\n // Use FormField id for htmlFor if present, otherwise use fieldId from context, or the prop\n const htmlFor = asChild ? undefined : htmlForProp || fieldId || field.id\n\n // Get disabled and required state from FormField if present\n const disabled = field.disabled\n const isRequired = field.isRequired\n\n // Notify SliderContext of the label id if no FormField is present\n const labelRef = useRef<HTMLLabelElement>(null)\n const mergedRef = useMergeRefs(ref, labelRef)\n\n useEffect(() => {\n if (onLabelId && !fieldLabelId && !field.labelId) {\n onLabelId(labelId)\n }\n }, [onLabelId, fieldLabelId, field.labelId, labelId])\n\n return (\n <Label\n ref={mergedRef}\n id={labelId}\n data-spark-component=\"slider-label\"\n htmlFor={htmlFor}\n className={cx(disabled ? 'text-on-surface/dim-3 pointer-events-none' : undefined, className)}\n asChild={asChild}\n {...others}\n >\n <>\n <Slottable>{children}</Slottable>\n {isRequired && requiredIndicator}\n </>\n </Label>\n )\n}\n\nSliderLabel.displayName = 'Slider.Label'\n","import { cx } from 'class-variance-authority'\nimport { forwardRef, type ReactNode } from 'react'\n\nimport { useSliderContext } from './SliderContext'\n\nexport interface SliderMaxValueProps {\n className?: string\n children?: (value: number) => ReactNode\n}\n\n/** Displays the maximum value of the slider. Renders a <div> element. */\nexport const SliderMaxValue = forwardRef<HTMLDivElement, SliderMaxValueProps>(\n ({ className, children }, ref) => {\n const { max = 100 } = useSliderContext()\n\n const content = children ? children(max) : max\n\n return (\n <div\n data-spark-component=\"slider-max-value\"\n ref={ref}\n className={cx('text-on-surface/dim-1 text-body-2 col-start-2 text-right', className)}\n >\n {content}\n </div>\n )\n }\n)\n\nSliderMaxValue.displayName = 'Slider.MaxValue'\n","import { cx } from 'class-variance-authority'\nimport { forwardRef, type ReactNode } from 'react'\n\nimport { useSliderContext } from './SliderContext'\n\nexport interface SliderMinValueProps {\n className?: string\n children?: (value: number) => ReactNode\n}\n\n/** Displays the minimum value of the slider. Renders a <div> element. */\nexport const SliderMinValue = forwardRef<HTMLDivElement, SliderMinValueProps>(\n ({ className, children }, ref) => {\n const { min = 0 } = useSliderContext()\n\n const content = children ? children(min) : min\n\n return (\n <div\n data-spark-component=\"slider-min-value\"\n ref={ref}\n className={cx('text-on-surface/dim-1 text-body-2 col-start-1 text-left', className)}\n >\n {content}\n </div>\n )\n }\n)\n\nSliderMinValue.displayName = 'Slider.MinValue'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const thumbVariants = cva(\n [\n 'relative block size-sz-24 rounded-full cursor-pointer',\n 'outline-hidden',\n 'has-focus-visible:ring-2 has-focus-visible:ring-offset-2 has-focus-visible:ring-focus',\n 'data-disabled:hover:ring-0 data-disabled:cursor-not-allowed data-disabled:before:hidden',\n // visual thumb\n 'after:absolute after:left-1/2 after:top-1/2 after:-translate-x-1/2 after:-translate-y-1/2',\n 'after:size-sz-24 after:rounded-full',\n // hover effect\n 'before:absolute before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2',\n 'before:size-sz-24 before:rounded-full before:border-solid before:border-sm before:transition-all before:duration-75',\n 'hover:before:size-sz-32 data-dragging:before:size-sz-32',\n ],\n {\n variants: {\n intent: {\n main: ['after:bg-main', 'before:bg-main-container before:border-main'],\n support: ['after:bg-support', 'before:bg-support-container before:border-support'],\n accent: ['after:bg-accent', 'before:bg-accent-container before:border-accent'],\n info: ['after:bg-info', 'before:bg-info-container before:border-info'],\n neutral: ['after:bg-neutral', 'before:bg-neutral-container before:border-neutral'],\n success: ['after:bg-success', 'before:bg-success-container before:border-success'],\n alert: ['after:bg-alert', 'before:bg-alert-container before:border-alert'],\n error: ['after:bg-error', 'before:bg-error-container before:border-error'],\n },\n },\n defaultVariants: {\n intent: 'support',\n },\n }\n)\n\nexport type SliderThumbVariantsProps = VariantProps<typeof thumbVariants>\n","import { createContext, useContext } from 'react'\n\nexport interface SliderThumbContextValue {\n isInsideThumb: true\n}\n\nexport const SliderThumbContext = createContext<SliderThumbContextValue | null>(null)\n\nexport const useSliderThumbContext = () => useContext(SliderThumbContext)\n","import { Slider as BaseSlider } from '@base-ui/react/slider'\nimport { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\nimport { ComponentProps, type PropsWithChildren, useRef } from 'react'\n\nimport { useSliderContext } from './SliderContext'\nimport { thumbVariants } from './SliderThumb.styles'\nimport { SliderThumbContext } from './SliderThumbContext'\n\nexport type SliderThumbProps = Omit<ComponentProps<typeof BaseSlider.Thumb>, 'render' | 'index'> &\n PropsWithChildren\n\n/** The draggable handle element of the slider. Renders a <span> element. */\nexport const SliderThumb = ({\n className,\n ref: forwardedRef,\n children,\n ...rest\n}: SliderThumbProps) => {\n const { intent, fieldLabelId, fieldId, thumbRef: contextThumbRef } = useSliderContext()\n\n const innerRef = useRef<HTMLDivElement>(null)\n const ref = useMergeRefs(contextThumbRef, forwardedRef ?? innerRef)\n\n return (\n <SliderThumbContext value={{ isInsideThumb: true }}>\n <BaseSlider.Thumb\n data-spark-component=\"slider-thumb\"\n ref={ref}\n id={fieldId}\n className={thumbVariants({ intent, className })}\n aria-labelledby={fieldLabelId}\n {...rest}\n >\n {children}\n </BaseSlider.Thumb>\n </SliderThumbContext>\n )\n}\n\nSliderThumb.displayName = 'Slider.Thumb'\n","import { Slider as BaseSlider } from '@base-ui/react/slider'\nimport { ComponentProps } from 'react'\n\nimport { trackVariants } from './SliderTrack.styles'\n\nexport type SliderTrackProps = Omit<ComponentProps<typeof BaseSlider.Track>, 'render'>\n\n/** The track element of the slider. Renders a <span> element. */\nexport const SliderTrack = ({ className, ref, ...rest }: SliderTrackProps) => {\n return (\n <BaseSlider.Track\n data-spark-component=\"slider-track\"\n ref={ref}\n className={trackVariants({ className })}\n {...rest}\n />\n )\n}\n\nSliderTrack.displayName = 'Slider.Track'\n","import type { RefObject } from 'react'\nimport { useLayoutEffect, useState } from 'react'\n\n/**\n * Computes the translateX (in pixels) to apply to the value element so it stays\n * within the horizontal bounds of the slider control when displayed inside the thumb.\n *\n * @param controlRef - Ref to the slider control (track container)\n * @param thumbRef - Ref to the thumb element\n * @param valueRef - Ref to the value label element\n * @param value - Current slider value (0–100 or min–max), used to re-run when thumb moves\n * @returns translateX in pixels (positive = right, negative = left), or 0 if refs are missing\n */\nexport function useSliderValueBoundaries(\n controlRef: RefObject<HTMLElement | null>,\n thumbRef: RefObject<HTMLElement | null>,\n valueRef: RefObject<HTMLElement | null>,\n value: number\n): number {\n const [translateX, setTranslateX] = useState(0)\n const [refsRetryScheduled, setRefsRetryScheduled] = useState(false)\n\n useLayoutEffect(() => {\n const control = controlRef.current\n const thumb = thumbRef.current\n const valueEl = valueRef.current\n\n if (!control || !thumb || !valueEl) {\n setTranslateX(0)\n // Re-run once on next frame when refs may be set (e.g. Slider.Value mounts after Control/Thumb)\n if (!refsRetryScheduled) {\n requestAnimationFrame(() => setRefsRetryScheduled(true))\n }\n\n return\n }\n\n let cancelled = false\n\n const compute = () => {\n if (cancelled) return\n\n const controlRect = control.getBoundingClientRect()\n const thumbRect = thumb.getBoundingClientRect()\n const valueWidth = valueEl.scrollWidth\n\n // Skip until value label has been laid out (content from render prop may not be ready on first paint)\n if (valueWidth === 0) {\n requestAnimationFrame(compute)\n\n return\n }\n\n const thumbCenterPx = thumbRect.left - controlRect.left + thumbRect.width / 2\n\n const valueCenterMin = valueWidth / 2\n const valueCenterMax = controlRect.width - valueWidth / 2\n\n const clampedCenter = Math.max(valueCenterMin, Math.min(valueCenterMax, thumbCenterPx))\n const nextTranslateX = clampedCenter - thumbCenterPx\n\n setTranslateX(prev => (prev !== nextTranslateX ? nextTranslateX : prev))\n }\n\n compute()\n\n const resizeObserver = new ResizeObserver(compute)\n resizeObserver.observe(control)\n resizeObserver.observe(valueEl)\n\n return () => {\n cancelled = true\n resizeObserver.disconnect()\n }\n }, [controlRef, thumbRef, valueRef, value, refsRetryScheduled])\n\n return translateX\n}\n","import { Slider as BaseSlider } from '@base-ui/react/slider'\nimport { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\nimport { cx } from 'class-variance-authority'\nimport type { ReactNode } from 'react'\nimport { ComponentProps, useCallback, useEffect, useRef, useState } from 'react'\n\nimport { useSliderContext } from './SliderContext'\nimport { useSliderThumbContext } from './SliderThumbContext'\nimport { useSliderValueBoundaries } from './useSliderValueBoundaries'\n\nexport type SliderValueProps = Omit<\n ComponentProps<typeof BaseSlider.Value>,\n 'render' | 'children'\n> & {\n children?: ReactNode | ((formatted: string, value: number) => ReactNode)\n}\n\n/** The current value of the slider. Renders an <output> element. */\nexport const SliderValue = ({ className, children, ref, ...rest }: SliderValueProps) => {\n const { registerValueInThumb, controlRef, thumbRef } = useSliderContext()\n const thumbContext = useSliderThumbContext()\n const isInsideThumb = thumbContext !== null\n\n const valueRef = useRef<HTMLOutputElement | null>(null)\n const mergedRef = useMergeRefs(valueRef, ref)\n\n const [currentValue, setCurrentValue] = useState(0)\n const translateX = useSliderValueBoundaries(controlRef, thumbRef, valueRef, currentValue)\n\n useEffect(() => {\n if (!isInsideThumb) return\n\n return registerValueInThumb()\n }, [isInsideThumb, registerValueInThumb])\n\n const resolvedClassName = cx(\n isInsideThumb\n ? 'absolute left-1/2 -translate-x-1/2 top-[calc(-100%-var(--spacing-sm))] text-body-1-highlight whitespace-nowrap'\n : 'default:text-body-1-highlight col-start-2 text-right',\n className\n )\n\n const normalizedChildren = useCallback(\n (formattedValues: readonly string[], values: readonly number[]) => {\n const formatted = formattedValues[0] ?? String(values[0] ?? '')\n const value = values[0] ?? 0\n setCurrentValue(value)\n if (typeof children === 'function') {\n return children(formatted, value)\n }\n\n return formatted\n },\n [children]\n )\n\n const style = isInsideThumb\n ? { transform: `translate(calc(0% + ${translateX}px), 0)` }\n : undefined\n\n return (\n <BaseSlider.Value\n data-spark-component=\"slider-value\"\n ref={mergedRef}\n className={resolvedClassName}\n style={style}\n {...rest}\n >\n {normalizedChildren}\n </BaseSlider.Value>\n )\n}\n\nSliderValue.displayName = 'Slider.Value'\n","import { Slider as Root, type SliderProps } from './Slider'\nimport { SliderControl as Control, type SliderControlProps } from './SliderControl'\nimport { SliderIndicator as Indicator, type SliderIndicatorProps } from './SliderIndicator'\nimport { SliderLabel as Label, type SliderLabelProps } from './SliderLabel'\nimport { SliderMaxValue as MaxValue, type SliderMaxValueProps } from './SliderMaxValue'\nimport { SliderMinValue as MinValue, type SliderMinValueProps } from './SliderMinValue'\nimport { SliderThumb as Thumb, type SliderThumbProps } from './SliderThumb'\nimport { SliderTrack as Track, type SliderTrackProps } from './SliderTrack'\nimport { SliderValue as Value, type SliderValueProps } from './SliderValue'\n\n/**\n * An input control that allows users to select a value from a continuous range by dragging a handle.\n */\nexport const Slider: typeof Root & {\n Control: typeof Control\n Indicator: typeof Indicator\n Label: typeof Label\n MaxValue: typeof MaxValue\n MinValue: typeof MinValue\n Thumb: typeof Thumb\n Track: typeof Track\n Value: typeof Value\n} = Object.assign(Root, {\n Control,\n Indicator,\n Label,\n MaxValue,\n MinValue,\n Thumb,\n Track,\n Value,\n})\n\nSlider.displayName = 'Slider'\nControl.displayName = 'Slider.Control'\nIndicator.displayName = 'Slider.Indicator'\nLabel.displayName = 'Slider.Label'\nMaxValue.displayName = 'Slider.MaxValue'\nMinValue.displayName = 'Slider.MinValue'\nThumb.displayName = 'Slider.Thumb'\nTrack.displayName = 'Slider.Track'\nValue.displayName = 'Slider.Value'\n\nexport type {\n SliderProps,\n SliderControlProps,\n SliderIndicatorProps,\n SliderLabelProps,\n SliderMaxValueProps,\n SliderMinValueProps,\n SliderThumbProps,\n SliderTrackProps,\n SliderValueProps,\n}\n"],"mappings":";;;;;;;;;;AAEA,IAAa,IAAa,EAAI;CAC5B;CACA;CACA;CACD,CAAC,ECSW,IAAgB,EAAsC,EAAE,CAA2B,EAEnF,UAAyB,EAAW,EAAc,EC8ClD,KAAU,EACrB,YAAS,WACT,aACA,cACA,QACA,OAAO,GACP,cAAc,GACd,UAAU,GACV,UAAU,GACV,MAAM,GACN,kBACA,kBACA,SAAM,GACN,SAAM,KACN,GAAG,QACc;CACjB,IAAM,IAAQ,GAAqB,EAE7B,IAAW,EAAM,YAAY,GAC7B,IAAW,EAAM,YAAY,GAC7B,IAAO,EAAM,QAAQ,GAErB,CAAC,GAAS,KAAc,EAA6B,EAAM,QAAQ,EACnE,CAAC,GAAmB,KAAwB,EAAS,EAAE,EACvD,IAAa,EAA2B,KAAK,EAC7C,IAAW,EAA2B,KAAK,EAE3C,IAAgB,GAAa,MAA2B;AAC5D,IAAW,EAAG;IACb,EAAE,CAAC,EAEA,IAAuB,SAC3B,GAAqB,MAAK,IAAI,EAAE,QAEnB,GAAqB,MAAK,IAAI,EAAE,GAC5C,EAAE,CAAC;AAEN,QACE,kBAAC,GAAD;EACE,OAAO;GACL;GACA;GACA;GACA,cAAc,EAAM,WAAW;GAC/B,SAAS,EAAM;GACf,WAAW;GACX,iBAAiB,IAAoB;GACrC;GACA;GACA;GACD;YAED,kBAAC,EAAW,MAAZ;GACO;GACL,wBAAqB;GACrB,WAAW,EAAW,EAAE,cAAW,CAAC;GAC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Aa;AAEzF,SAAgB;AACT,QAEL,QAAO,GAAsB;IAC5B,CAAC,GAAe,EAAqB,CAAC;CAEzC,IAAM,IAAoB,EACxB,IACI,mHACA,wDACJ,EACD,EAEK,IAAqB,GACxB,GAAoC,MAA8B;EACjE,IAAM,IAAY,EAAgB,MAAM,OAAO,EAAO,MAAM,GAAG,EACzD,IAAQ,EAAO,MAAM;AAM3B,SALA,EAAgB,EAAM,EAClB,OAAO,KAAa,aACf,EAAS,GAAW,EAAM,GAG5B;IAET,CAAC,EAAS,CACX,EAEK,IAAQ,IACV,EAAE,WAAW,uBAAuB,EAAW,UAAU,GACzD,KAAA;AAEJ,QACE,kBAAC,EAAW,OAAZ;EACE,wBAAqB;EACrB,KAAK;EACL,WAAW;EACJ;EACP,GAAI;YAEH;EACgB,CAAA;;AAIvB,EAAY,cAAc;;;AC5D1B,IAAa,IAST,OAAO,OAAO,GAAM;CACtB,SAAA;CACA,WAAA;CACA,OAAA;CACA,UAAA;CACA,UAAA;CACA,OAAA;CACA,OAAA;CACA,OAAA;CACD,CAAC;AAEF,EAAO,cAAc,UACrB,EAAQ,cAAc,kBACtB,EAAU,cAAc,oBACxB,EAAM,cAAc,gBACpB,EAAS,cAAc,mBACvB,EAAS,cAAc,mBACvB,EAAM,cAAc,gBACpB,EAAM,cAAc,gBACpB,EAAM,cAAc"}
|
package/dist/stepper/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-C91j1N6u.js`);const e=require(`../icon-CRPcdgYp.js`),t=require(`../icon-button-CTe0v0g7.js`),n=require(`../input-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-C91j1N6u.js`);const e=require(`../icon-CRPcdgYp.js`),t=require(`../icon-button-CTe0v0g7.js`),n=require(`../input-BSCMbnO4.js`);let r=require(`class-variance-authority`),i=require(`react`),a=require(`react/jsx-runtime`),o=require(`@spark-ui/hooks/use-merge-refs`),s=require(`@spark-ui/components/form-field`),c=require(`@spark-ui/icons/Minus`),l=require(`@base-ui/react/number-field`),u=require(`@spark-ui/icons/Plus`);var d=(0,i.createContext)(null),f=({children:e,formatOptions:t,minValue:o,maxValue:c,ref:u,onValueChange:f,locale:p=`fr`,name:m,...h})=>{let g=(0,i.useRef)(null),_=(0,s.useFormFieldControl)(),v=(0,i.useRef)(h.value??h.defaultValue??null),y=_.name??m,b=_.disabled??h.disabled,x=_.readOnly??h.readOnly,S=_.isRequired??h.required,C=e=>{f&&e!==v.current&&(v.current=e,f(e))},{"aria-label":w,...T}=h;return(0,a.jsx)(d,{value:{inputRef:g,fieldId:_.id,fieldLabelId:_.labelId,fieldIsInvalid:_.isInvalid,fieldIsRequired:S,state:h.state,ariaLabel:w},children:(0,a.jsx)(l.NumberField.Root,{...T,format:t,min:o,max:c,locale:p,disabled:b,readOnly:x,required:S,name:y,inputRef:g,onValueCommitted:C,"aria-describedby":_.description,children:(0,a.jsx)(`div`,{"data-spark-component":`stepper`,ref:u,className:(0,r.cx)(n.r({disabled:b,readOnly:x}),h.className),children:e})})})};f.displayName=`Stepper`;var p=()=>{let e=(0,i.useContext)(d);if(!e)throw Error(`useStepperContext must be used within a Stepper provider`);return e},m=({children:n,design:i=`ghost`,intent:o=`neutral`,className:s,ref:c,disabled:d,...f})=>{let{fieldId:m,state:h}=p();return(0,a.jsx)(l.NumberField.Increment,{render:l=>{let p=d||`disabled`in l&&l.disabled,g=`readOnly`in l&&l.readOnly;return(0,a.jsx)(`div`,{className:(0,r.cx)(`rounded-r-lg`,p||g?`bg-on-surface/dim-5`:null),"data-spark-component":`stepper-increment-button`,children:(0,a.jsx)(t.t,{ref:c,design:i,intent:o,className:(0,r.cx)(`overflow-hidden border-sm shrink-0 h-full focus-visible:relative focus-visible:z-raised mx-0`,`rounded-l-0! -ml-px rounded-r-lg`,h===`error`&&`border-error`,h===`alert`&&`border-alert`,h===`success`&&`border-success`,!h&&`border-outline`,s),...f,...l,"aria-label":f[`aria-label`]||l[`aria-label`],"aria-controls":m,disabled:p,children:n||(0,a.jsx)(e.t,{children:(0,a.jsx)(u.Plus,{})})})})}})},h=({children:n,design:i=`ghost`,intent:o=`neutral`,className:s,ref:u,disabled:d,...f})=>{let{fieldId:m,state:h}=p();return(0,a.jsx)(l.NumberField.Decrement,{render:l=>{let p=d||`disabled`in l&&l.disabled,g=`readOnly`in l&&l.readOnly;return(0,a.jsx)(`div`,{className:(0,r.cx)(`rounded-l-lg`,p||g?`bg-on-surface/dim-5`:null),"data-spark-component":`stepper-decrement-button`,children:(0,a.jsx)(t.t,{ref:u,design:i,intent:o,className:(0,r.cx)(`overflow-hidden border-sm shrink-0 h-full focus-visible:relative focus-visible:z-raised mx-0`,`rounded-r-0! -mr-px rounded-l-lg`,h===`error`&&`border-error`,h===`alert`&&`border-alert`,h===`success`&&`border-success`,!h&&`border-outline`,s),...f,...l,"aria-label":f[`aria-label`]||l[`aria-label`],"aria-controls":m,disabled:p,children:n||(0,a.jsx)(e.t,{children:(0,a.jsx)(c.Minus,{})})})})}})},g=m,_=h;m.displayName=`Stepper.IncrementButton`,h.displayName=`Stepper.DecrementButton`;var v=({ref:e,...t})=>{let{inputRef:r,fieldId:i,fieldLabelId:s,fieldIsInvalid:c,fieldIsRequired:u,ariaLabel:d}=p(),f=(0,o.useMergeRefs)(e,r),{className:m=``,...h}=t,g=!!s;return(0,a.jsx)(`div`,{className:`relative inline-flex w-full`,children:(0,a.jsx)(l.NumberField.Input,{render:e=>{let t;u===void 0?`required`in e&&(t=e.required):t=u;let r=c===void 0?e[`aria-invalid`]:c;return(0,a.jsx)(n.n,{ref:f,...e,...h,id:i||e.id,required:t,"aria-invalid":r,"aria-label":g?void 0:d,className:`min-w-sz-56 text-center rounded-none! ${m}`})}})})},y=v;v.displayName=`Stepper.Input`;var b=Object.assign(f,{IncrementButton:g,DecrementButton:_,Input:y});b.displayName=`Stepper`,g.displayName=`Stepper.IncrementButton`,_.displayName=`Stepper.DecrementButton`,y.displayName=`Stepper.Input`,exports.Stepper=b;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/stepper/Stepper.tsx","../../src/stepper/StepperButton.tsx","../../src/stepper/StepperInput.tsx","../../src/stepper/index.ts"],"sourcesContent":["import { NumberField } from '@base-ui/react/number-field'\nimport { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { cx } from 'class-variance-authority'\nimport { createContext, type PropsWithChildren, RefObject, useContext, useRef } from 'react'\n\nimport { inputGroupStyles } from '../input/InputGroup.styles'\nimport type { StepperProps } from './types'\n\ninterface StepperContextValue {\n inputRef: RefObject<HTMLInputElement | null>\n fieldId?: string\n fieldLabelId?: string\n fieldIsInvalid?: boolean\n fieldIsRequired?: boolean\n state?: 'error' | 'alert' | 'success'\n ariaLabel?: string\n}\n\nconst StepperContext = createContext<StepperContextValue | null>(null)\n\nexport const Stepper = ({\n children,\n formatOptions,\n minValue,\n maxValue,\n ref: forwardedRef,\n onValueChange,\n locale = 'fr',\n name: nameProp,\n ...stepperProps\n}: PropsWithChildren<StepperProps>) => {\n const inputRef = useRef<HTMLInputElement>(null)\n const formFieldControlProps = useFormFieldControl()\n const lastCommittedValueRef = useRef<number | null>(\n stepperProps.value ?? stepperProps.defaultValue ?? null\n )\n\n const name = formFieldControlProps.name ?? nameProp\n const disabled = formFieldControlProps.disabled ?? stepperProps.disabled\n const readOnly = formFieldControlProps.readOnly ?? stepperProps.readOnly\n const required = formFieldControlProps.isRequired ?? stepperProps.required\n\n // Base UI calls onValueChange on every keystroke, but react-aria only called it on blur.\n // We use onValueCommitted to preserve the old behavior where onValueChange is only called on blur for input changes,\n // but immediately for button clicks.\n const handleValueCommit = (value: number | null) => {\n // Allow null values to be propagated (when input is cleared)\n // This is necessary for controlled mode and React Hook Form validation\n if (onValueChange && value !== lastCommittedValueRef.current) {\n lastCommittedValueRef.current = value\n onValueChange(value)\n }\n }\n\n // Extract aria-label to pass to input, not to NumberField.Root\n const { 'aria-label': ariaLabel, ...restStepperProps } = stepperProps\n\n return (\n <StepperContext.Provider\n value={{\n inputRef,\n fieldId: formFieldControlProps.id,\n fieldLabelId: formFieldControlProps.labelId,\n fieldIsInvalid: formFieldControlProps.isInvalid,\n fieldIsRequired: required,\n state: stepperProps.state,\n ariaLabel,\n }}\n >\n <NumberField.Root\n {...restStepperProps}\n format={formatOptions}\n min={minValue}\n max={maxValue}\n locale={locale}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n name={name}\n inputRef={inputRef}\n onValueCommitted={handleValueCommit}\n aria-describedby={formFieldControlProps.description}\n >\n <div\n data-spark-component=\"stepper\"\n ref={forwardedRef}\n className={cx(inputGroupStyles({ disabled, readOnly }), stepperProps.className)}\n >\n {children}\n </div>\n </NumberField.Root>\n </StepperContext.Provider>\n )\n}\n\nStepper.displayName = 'Stepper'\n\nexport const useStepperContext = () => {\n const context = useContext(StepperContext)\n\n if (!context) {\n throw Error('useStepperContext must be used within a Stepper provider')\n }\n\n return context\n}\n","import { NumberField } from '@base-ui/react/number-field'\nimport { Minus } from '@spark-ui/icons/Minus'\nimport { Plus } from '@spark-ui/icons/Plus'\nimport { cx } from 'class-variance-authority'\nimport { type PropsWithChildren } from 'react'\n\nimport { Icon } from '../icon'\nimport { IconButton } from '../icon-button'\nimport { useStepperContext } from './Stepper'\nimport type { StepperButtonProps } from './types'\n\n/** A button to increment the stepper value. Renders a <button> element. */\nconst IncrementButton = ({\n children,\n design = 'ghost',\n intent = 'neutral',\n className,\n ref: forwardedRef,\n disabled,\n ...rest\n}: PropsWithChildren<StepperButtonProps>) => {\n const { fieldId, state } = useStepperContext()\n\n return (\n <NumberField.Increment\n render={buttonProps => {\n const isDisabled = disabled || ('disabled' in buttonProps && (buttonProps as any).disabled)\n const isReadOnly = 'readOnly' in buttonProps && (buttonProps as any).readOnly\n const isInactive = isDisabled || isReadOnly\n\n return (\n <div\n className={cx('rounded-r-lg', isInactive ? 'bg-on-surface/dim-5' : null)}\n data-spark-component=\"stepper-increment-button\"\n >\n <IconButton\n ref={forwardedRef}\n design={design}\n intent={intent}\n className={cx(\n 'overflow-hidden border-sm shrink-0 h-full focus-visible:relative focus-visible:z-raised mx-0',\n 'rounded-l-0! -ml-px rounded-r-lg',\n state === 'error' && 'border-error',\n state === 'alert' && 'border-alert',\n state === 'success' && 'border-success',\n !state && 'border-outline',\n className\n )}\n {...rest}\n {...buttonProps}\n aria-label={rest['aria-label'] || (buttonProps['aria-label'] as string)}\n aria-controls={fieldId}\n disabled={isDisabled}\n >\n {children || (\n <Icon>\n <Plus />\n </Icon>\n )}\n </IconButton>\n </div>\n )\n }}\n />\n )\n}\n\n/** A button to decrement the stepper value. Renders a <button> element. */\nconst DecrementButton = ({\n children,\n design = 'ghost',\n intent = 'neutral',\n className,\n ref: forwardedRef,\n disabled,\n ...rest\n}: PropsWithChildren<StepperButtonProps>) => {\n const { fieldId, state } = useStepperContext()\n\n return (\n <NumberField.Decrement\n render={buttonProps => {\n const isDisabled = disabled || ('disabled' in buttonProps && (buttonProps as any).disabled)\n const isReadOnly = 'readOnly' in buttonProps && (buttonProps as any).readOnly\n const isInactive = isDisabled || isReadOnly\n\n return (\n <div\n className={cx('rounded-l-lg', isInactive ? 'bg-on-surface/dim-5' : null)}\n data-spark-component=\"stepper-decrement-button\"\n >\n <IconButton\n ref={forwardedRef}\n design={design}\n intent={intent}\n className={cx(\n 'overflow-hidden border-sm shrink-0 h-full focus-visible:relative focus-visible:z-raised mx-0',\n 'rounded-r-0! -mr-px rounded-l-lg',\n state === 'error' && 'border-error',\n state === 'alert' && 'border-alert',\n state === 'success' && 'border-success',\n !state && 'border-outline',\n className\n )}\n {...rest}\n {...buttonProps}\n aria-label={rest['aria-label'] || (buttonProps['aria-label'] as string)}\n aria-controls={fieldId}\n disabled={isDisabled}\n >\n {children || (\n <Icon>\n <Minus />\n </Icon>\n )}\n </IconButton>\n </div>\n )\n }}\n />\n )\n}\n\nexport const StepperIncrementButton = IncrementButton\n\nexport const StepperDecrementButton = DecrementButton\n\nIncrementButton.displayName = 'Stepper.IncrementButton'\nDecrementButton.displayName = 'Stepper.DecrementButton'\n","import { NumberField } from '@base-ui/react/number-field'\nimport { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\n\nimport { Input as SparkInput } from '../input'\nimport { useStepperContext } from './Stepper'\nimport type { StepperInputProps } from './types'\n\n/** The numeric input field displaying the stepper value. Renders an <input> element. */\nconst Input = ({ ref: forwardedRef, ...props }: StepperInputProps) => {\n const { inputRef, fieldId, fieldLabelId, fieldIsInvalid, fieldIsRequired, ariaLabel } =\n useStepperContext()\n const ref = useMergeRefs(forwardedRef, inputRef)\n const { className = '', ...remainingProps } = props\n\n // Only use aria-label if not wrapped in a FormField with a label (fieldLabelId would be set by FormField.Label)\n const hasFormFieldLabel = !!fieldLabelId\n\n return (\n <div className=\"relative inline-flex w-full\">\n <NumberField.Input\n render={inputProps => {\n // Determine required attribute\n let required: boolean | undefined = undefined\n if (fieldIsRequired !== undefined) {\n required = fieldIsRequired\n } else if ('required' in inputProps) {\n required = (inputProps as any).required\n }\n\n // Determine aria-invalid attribute\n const ariaInvalid =\n fieldIsInvalid !== undefined ? fieldIsInvalid : inputProps['aria-invalid']\n\n return (\n <SparkInput\n ref={ref}\n {...inputProps}\n {...remainingProps}\n id={fieldId || inputProps.id}\n required={required}\n aria-invalid={ariaInvalid}\n aria-label={hasFormFieldLabel ? undefined : ariaLabel}\n className={`min-w-sz-56 text-center rounded-none! ${className}`}\n />\n )\n }}\n />\n </div>\n )\n}\n\nexport const StepperInput = Input\n\nInput.displayName = 'Stepper.Input'\n","import { Stepper as Root } from './Stepper'\nimport {\n StepperDecrementButton as DecrementButton,\n StepperIncrementButton as IncrementButton,\n} from './StepperButton'\nimport { StepperInput as Input } from './StepperInput'\n\n/**\n * A numeric input component with increment and decrement buttons for adjusting values.\n */\nexport const Stepper: typeof Root & {\n IncrementButton: typeof IncrementButton\n DecrementButton: typeof DecrementButton\n Input: typeof Input\n} = Object.assign(Root, { IncrementButton, DecrementButton, Input })\n\nStepper.displayName = 'Stepper'\nIncrementButton.displayName = 'Stepper.IncrementButton'\nDecrementButton.displayName = 'Stepper.DecrementButton'\nInput.displayName = 'Stepper.Input'\n\nexport type { StepperProps, StepperButtonProps, StepperInputProps } from './types'\n"],"mappings":"ufAkBA,IAAM,GAAA,EAAA,EAAA,eAA2D,KAAK,CAEzD,GAAW,CACtB,WACA,gBACA,WACA,WACA,IAAK,EACL,gBACA,SAAS,KACT,KAAM,EACN,GAAG,KACkC,CACrC,IAAM,GAAA,EAAA,EAAA,QAAoC,KAAK,CACzC,GAAA,EAAA,EAAA,sBAA6C,CAC7C,GAAA,EAAA,EAAA,QACJ,EAAa,OAAS,EAAa,cAAgB,KACpD,CAEK,EAAO,EAAsB,MAAQ,EACrC,EAAW,EAAsB,UAAY,EAAa,SAC1D,EAAW,EAAsB,UAAY,EAAa,SAC1D,EAAW,EAAsB,YAAc,EAAa,SAK5D,EAAqB,GAAyB,CAG9C,GAAiB,IAAU,EAAsB,UACnD,EAAsB,QAAU,EAChC,EAAc,EAAM,GAKlB,CAAE,aAAc,EAAW,GAAG,GAAqB,EAEzD,OACE,EAAA,EAAA,KAAC,EAAe,SAAhB,CACE,MAAO,CACL,WACA,QAAS,EAAsB,GAC/B,aAAc,EAAsB,QACpC,eAAgB,EAAsB,UACtC,gBAAiB,EACjB,MAAO,EAAa,MACpB,YACD,WAED,EAAA,EAAA,KAAC,EAAA,YAAY,KAAb,CACE,GAAI,EACJ,OAAQ,EACR,IAAK,EACL,IAAK,EACG,SACE,WACA,WACA,WACJ,OACI,WACV,iBAAkB,EAClB,mBAAkB,EAAsB,sBAExC,EAAA,EAAA,KAAC,MAAD,CACE,uBAAqB,UACrB,IAAK,EACL,WAAA,EAAA,EAAA,IAAc,EAAA,EAAiB,CAAE,WAAU,WAAU,CAAC,CAAE,EAAa,UAAU,CAE9E,WACG,C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c,gBC3CpB,IAAa,EAIT,OAAO,OAAO,EAAM,CAAE,gBAAA,EAAiB,gBAAA,EAAiB,MAAA,EAAO,CAAC,CAEpE,EAAQ,YAAc,UACtB,EAAgB,YAAc,0BAC9B,EAAgB,YAAc,0BAC9B,EAAM,YAAc"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/stepper/Stepper.tsx","../../src/stepper/StepperButton.tsx","../../src/stepper/StepperInput.tsx","../../src/stepper/index.ts"],"sourcesContent":["import { NumberField } from '@base-ui/react/number-field'\nimport { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { cx } from 'class-variance-authority'\nimport { createContext, type PropsWithChildren, RefObject, useContext, useRef } from 'react'\n\nimport { inputGroupStyles } from '../input/InputGroup.styles'\nimport type { StepperProps } from './types'\n\ninterface StepperContextValue {\n inputRef: RefObject<HTMLInputElement | null>\n fieldId?: string\n fieldLabelId?: string\n fieldIsInvalid?: boolean\n fieldIsRequired?: boolean\n state?: 'error' | 'alert' | 'success'\n ariaLabel?: string\n}\n\nconst StepperContext = createContext<StepperContextValue | null>(null)\n\nexport const Stepper = ({\n children,\n formatOptions,\n minValue,\n maxValue,\n ref: forwardedRef,\n onValueChange,\n locale = 'fr',\n name: nameProp,\n ...stepperProps\n}: PropsWithChildren<StepperProps>) => {\n const inputRef = useRef<HTMLInputElement>(null)\n const formFieldControlProps = useFormFieldControl()\n const lastCommittedValueRef = useRef<number | null>(\n stepperProps.value ?? stepperProps.defaultValue ?? null\n )\n\n const name = formFieldControlProps.name ?? nameProp\n const disabled = formFieldControlProps.disabled ?? stepperProps.disabled\n const readOnly = formFieldControlProps.readOnly ?? stepperProps.readOnly\n const required = formFieldControlProps.isRequired ?? stepperProps.required\n\n // Base UI calls onValueChange on every keystroke, but react-aria only called it on blur.\n // We use onValueCommitted to preserve the old behavior where onValueChange is only called on blur for input changes,\n // but immediately for button clicks.\n const handleValueCommit = (value: number | null) => {\n // Allow null values to be propagated (when input is cleared)\n // This is necessary for controlled mode and React Hook Form validation\n if (onValueChange && value !== lastCommittedValueRef.current) {\n lastCommittedValueRef.current = value\n onValueChange(value)\n }\n }\n\n // Extract aria-label to pass to input, not to NumberField.Root\n const { 'aria-label': ariaLabel, ...restStepperProps } = stepperProps\n\n return (\n <StepperContext\n value={{\n inputRef,\n fieldId: formFieldControlProps.id,\n fieldLabelId: formFieldControlProps.labelId,\n fieldIsInvalid: formFieldControlProps.isInvalid,\n fieldIsRequired: required,\n state: stepperProps.state,\n ariaLabel,\n }}\n >\n <NumberField.Root\n {...restStepperProps}\n format={formatOptions}\n min={minValue}\n max={maxValue}\n locale={locale}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n name={name}\n inputRef={inputRef}\n onValueCommitted={handleValueCommit}\n aria-describedby={formFieldControlProps.description}\n >\n <div\n data-spark-component=\"stepper\"\n ref={forwardedRef}\n className={cx(inputGroupStyles({ disabled, readOnly }), stepperProps.className)}\n >\n {children}\n </div>\n </NumberField.Root>\n </StepperContext>\n )\n}\n\nStepper.displayName = 'Stepper'\n\nexport const useStepperContext = () => {\n const context = useContext(StepperContext)\n\n if (!context) {\n throw Error('useStepperContext must be used within a Stepper provider')\n }\n\n return context\n}\n","import { NumberField } from '@base-ui/react/number-field'\nimport { Minus } from '@spark-ui/icons/Minus'\nimport { Plus } from '@spark-ui/icons/Plus'\nimport { cx } from 'class-variance-authority'\nimport { type PropsWithChildren } from 'react'\n\nimport { Icon } from '../icon'\nimport { IconButton } from '../icon-button'\nimport { useStepperContext } from './Stepper'\nimport type { StepperButtonProps } from './types'\n\n/** A button to increment the stepper value. Renders a <button> element. */\nconst IncrementButton = ({\n children,\n design = 'ghost',\n intent = 'neutral',\n className,\n ref: forwardedRef,\n disabled,\n ...rest\n}: PropsWithChildren<StepperButtonProps>) => {\n const { fieldId, state } = useStepperContext()\n\n return (\n <NumberField.Increment\n render={buttonProps => {\n const isDisabled = disabled || ('disabled' in buttonProps && (buttonProps as any).disabled)\n const isReadOnly = 'readOnly' in buttonProps && (buttonProps as any).readOnly\n const isInactive = isDisabled || isReadOnly\n\n return (\n <div\n className={cx('rounded-r-lg', isInactive ? 'bg-on-surface/dim-5' : null)}\n data-spark-component=\"stepper-increment-button\"\n >\n <IconButton\n ref={forwardedRef}\n design={design}\n intent={intent}\n className={cx(\n 'overflow-hidden border-sm shrink-0 h-full focus-visible:relative focus-visible:z-raised mx-0',\n 'rounded-l-0! -ml-px rounded-r-lg',\n state === 'error' && 'border-error',\n state === 'alert' && 'border-alert',\n state === 'success' && 'border-success',\n !state && 'border-outline',\n className\n )}\n {...rest}\n {...buttonProps}\n aria-label={rest['aria-label'] || (buttonProps['aria-label'] as string)}\n aria-controls={fieldId}\n disabled={isDisabled}\n >\n {children || (\n <Icon>\n <Plus />\n </Icon>\n )}\n </IconButton>\n </div>\n )\n }}\n />\n )\n}\n\n/** A button to decrement the stepper value. Renders a <button> element. */\nconst DecrementButton = ({\n children,\n design = 'ghost',\n intent = 'neutral',\n className,\n ref: forwardedRef,\n disabled,\n ...rest\n}: PropsWithChildren<StepperButtonProps>) => {\n const { fieldId, state } = useStepperContext()\n\n return (\n <NumberField.Decrement\n render={buttonProps => {\n const isDisabled = disabled || ('disabled' in buttonProps && (buttonProps as any).disabled)\n const isReadOnly = 'readOnly' in buttonProps && (buttonProps as any).readOnly\n const isInactive = isDisabled || isReadOnly\n\n return (\n <div\n className={cx('rounded-l-lg', isInactive ? 'bg-on-surface/dim-5' : null)}\n data-spark-component=\"stepper-decrement-button\"\n >\n <IconButton\n ref={forwardedRef}\n design={design}\n intent={intent}\n className={cx(\n 'overflow-hidden border-sm shrink-0 h-full focus-visible:relative focus-visible:z-raised mx-0',\n 'rounded-r-0! -mr-px rounded-l-lg',\n state === 'error' && 'border-error',\n state === 'alert' && 'border-alert',\n state === 'success' && 'border-success',\n !state && 'border-outline',\n className\n )}\n {...rest}\n {...buttonProps}\n aria-label={rest['aria-label'] || (buttonProps['aria-label'] as string)}\n aria-controls={fieldId}\n disabled={isDisabled}\n >\n {children || (\n <Icon>\n <Minus />\n </Icon>\n )}\n </IconButton>\n </div>\n )\n }}\n />\n )\n}\n\nexport const StepperIncrementButton = IncrementButton\n\nexport const StepperDecrementButton = DecrementButton\n\nIncrementButton.displayName = 'Stepper.IncrementButton'\nDecrementButton.displayName = 'Stepper.DecrementButton'\n","import { NumberField } from '@base-ui/react/number-field'\nimport { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\n\nimport { Input as SparkInput } from '../input'\nimport { useStepperContext } from './Stepper'\nimport type { StepperInputProps } from './types'\n\n/** The numeric input field displaying the stepper value. Renders an <input> element. */\nconst Input = ({ ref: forwardedRef, ...props }: StepperInputProps) => {\n const { inputRef, fieldId, fieldLabelId, fieldIsInvalid, fieldIsRequired, ariaLabel } =\n useStepperContext()\n const ref = useMergeRefs(forwardedRef, inputRef)\n const { className = '', ...remainingProps } = props\n\n // Only use aria-label if not wrapped in a FormField with a label (fieldLabelId would be set by FormField.Label)\n const hasFormFieldLabel = !!fieldLabelId\n\n return (\n <div className=\"relative inline-flex w-full\">\n <NumberField.Input\n render={inputProps => {\n // Determine required attribute\n let required: boolean | undefined = undefined\n if (fieldIsRequired !== undefined) {\n required = fieldIsRequired\n } else if ('required' in inputProps) {\n required = (inputProps as any).required\n }\n\n // Determine aria-invalid attribute\n const ariaInvalid =\n fieldIsInvalid !== undefined ? fieldIsInvalid : inputProps['aria-invalid']\n\n return (\n <SparkInput\n ref={ref}\n {...inputProps}\n {...remainingProps}\n id={fieldId || inputProps.id}\n required={required}\n aria-invalid={ariaInvalid}\n aria-label={hasFormFieldLabel ? undefined : ariaLabel}\n className={`min-w-sz-56 text-center rounded-none! ${className}`}\n />\n )\n }}\n />\n </div>\n )\n}\n\nexport const StepperInput = Input\n\nInput.displayName = 'Stepper.Input'\n","import { Stepper as Root } from './Stepper'\nimport {\n StepperDecrementButton as DecrementButton,\n StepperIncrementButton as IncrementButton,\n} from './StepperButton'\nimport { StepperInput as Input } from './StepperInput'\n\n/**\n * A numeric input component with increment and decrement buttons for adjusting values.\n */\nexport const Stepper: typeof Root & {\n IncrementButton: typeof IncrementButton\n DecrementButton: typeof DecrementButton\n Input: typeof Input\n} = Object.assign(Root, { IncrementButton, DecrementButton, Input })\n\nStepper.displayName = 'Stepper'\nIncrementButton.displayName = 'Stepper.IncrementButton'\nDecrementButton.displayName = 'Stepper.DecrementButton'\nInput.displayName = 'Stepper.Input'\n\nexport type { StepperProps, StepperButtonProps, StepperInputProps } from './types'\n"],"mappings":"ufAkBA,IAAM,GAAA,EAAA,EAAA,eAA2D,KAAK,CAEzD,GAAW,CACtB,WACA,gBACA,WACA,WACA,IAAK,EACL,gBACA,SAAS,KACT,KAAM,EACN,GAAG,KACkC,CACrC,IAAM,GAAA,EAAA,EAAA,QAAoC,KAAK,CACzC,GAAA,EAAA,EAAA,sBAA6C,CAC7C,GAAA,EAAA,EAAA,QACJ,EAAa,OAAS,EAAa,cAAgB,KACpD,CAEK,EAAO,EAAsB,MAAQ,EACrC,EAAW,EAAsB,UAAY,EAAa,SAC1D,EAAW,EAAsB,UAAY,EAAa,SAC1D,EAAW,EAAsB,YAAc,EAAa,SAK5D,EAAqB,GAAyB,CAG9C,GAAiB,IAAU,EAAsB,UACnD,EAAsB,QAAU,EAChC,EAAc,EAAM,GAKlB,CAAE,aAAc,EAAW,GAAG,GAAqB,EAEzD,OACE,EAAA,EAAA,KAAC,EAAD,CACE,MAAO,CACL,WACA,QAAS,EAAsB,GAC/B,aAAc,EAAsB,QACpC,eAAgB,EAAsB,UACtC,gBAAiB,EACjB,MAAO,EAAa,MACpB,YACD,WAED,EAAA,EAAA,KAAC,EAAA,YAAY,KAAb,CACE,GAAI,EACJ,OAAQ,EACR,IAAK,EACL,IAAK,EACG,SACE,WACA,WACA,WACJ,OACI,WACV,iBAAkB,EAClB,mBAAkB,EAAsB,sBAExC,EAAA,EAAA,KAAC,MAAD,CACE,uBAAqB,UACrB,IAAK,EACL,WAAA,EAAA,EAAA,IAAc,EAAA,EA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pD,CAAA,EAGN,CAAA,CACE,CAAA,EAIG,EAAe,EAE5B,EAAM,YAAc,gBC3CpB,IAAa,EAIT,OAAO,OAAO,EAAM,CAAE,gBAAA,EAAiB,gBAAA,EAAiB,MAAA,EAAO,CAAC,CAEpE,EAAQ,YAAc,UACtB,EAAgB,YAAc,0BAC9B,EAAgB,YAAc,0BAC9B,EAAM,YAAc"}
|
package/dist/stepper/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as e } from "../icon-D05Uqh8_.mjs";
|
|
2
2
|
import { t } from "../icon-button-DVbKK2_a.mjs";
|
|
3
|
-
import { n, r } from "../input-
|
|
3
|
+
import { n, r } from "../input-cKdm2R3n.mjs";
|
|
4
4
|
import { cx as i } from "class-variance-authority";
|
|
5
5
|
import { createContext as a, useContext as o, useRef as s } from "react";
|
|
6
6
|
import { jsx as c } from "react/jsx-runtime";
|
|
@@ -14,7 +14,7 @@ var m = a(null), h = ({ children: e, formatOptions: t, minValue: n, maxValue: a,
|
|
|
14
14
|
let g = s(null), _ = u(), v = s(h.value ?? h.defaultValue ?? null), y = _.name ?? p, b = _.disabled ?? h.disabled, x = _.readOnly ?? h.readOnly, S = _.isRequired ?? h.required, C = (e) => {
|
|
15
15
|
l && e !== v.current && (v.current = e, l(e));
|
|
16
16
|
}, { "aria-label": w, ...T } = h;
|
|
17
|
-
return /* @__PURE__ */ c(m
|
|
17
|
+
return /* @__PURE__ */ c(m, {
|
|
18
18
|
value: {
|
|
19
19
|
inputRef: g,
|
|
20
20
|
fieldId: _.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/stepper/Stepper.tsx","../../src/stepper/StepperButton.tsx","../../src/stepper/StepperInput.tsx","../../src/stepper/index.ts"],"sourcesContent":["import { NumberField } from '@base-ui/react/number-field'\nimport { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { cx } from 'class-variance-authority'\nimport { createContext, type PropsWithChildren, RefObject, useContext, useRef } from 'react'\n\nimport { inputGroupStyles } from '../input/InputGroup.styles'\nimport type { StepperProps } from './types'\n\ninterface StepperContextValue {\n inputRef: RefObject<HTMLInputElement | null>\n fieldId?: string\n fieldLabelId?: string\n fieldIsInvalid?: boolean\n fieldIsRequired?: boolean\n state?: 'error' | 'alert' | 'success'\n ariaLabel?: string\n}\n\nconst StepperContext = createContext<StepperContextValue | null>(null)\n\nexport const Stepper = ({\n children,\n formatOptions,\n minValue,\n maxValue,\n ref: forwardedRef,\n onValueChange,\n locale = 'fr',\n name: nameProp,\n ...stepperProps\n}: PropsWithChildren<StepperProps>) => {\n const inputRef = useRef<HTMLInputElement>(null)\n const formFieldControlProps = useFormFieldControl()\n const lastCommittedValueRef = useRef<number | null>(\n stepperProps.value ?? stepperProps.defaultValue ?? null\n )\n\n const name = formFieldControlProps.name ?? nameProp\n const disabled = formFieldControlProps.disabled ?? stepperProps.disabled\n const readOnly = formFieldControlProps.readOnly ?? stepperProps.readOnly\n const required = formFieldControlProps.isRequired ?? stepperProps.required\n\n // Base UI calls onValueChange on every keystroke, but react-aria only called it on blur.\n // We use onValueCommitted to preserve the old behavior where onValueChange is only called on blur for input changes,\n // but immediately for button clicks.\n const handleValueCommit = (value: number | null) => {\n // Allow null values to be propagated (when input is cleared)\n // This is necessary for controlled mode and React Hook Form validation\n if (onValueChange && value !== lastCommittedValueRef.current) {\n lastCommittedValueRef.current = value\n onValueChange(value)\n }\n }\n\n // Extract aria-label to pass to input, not to NumberField.Root\n const { 'aria-label': ariaLabel, ...restStepperProps } = stepperProps\n\n return (\n <StepperContext.Provider\n value={{\n inputRef,\n fieldId: formFieldControlProps.id,\n fieldLabelId: formFieldControlProps.labelId,\n fieldIsInvalid: formFieldControlProps.isInvalid,\n fieldIsRequired: required,\n state: stepperProps.state,\n ariaLabel,\n }}\n >\n <NumberField.Root\n {...restStepperProps}\n format={formatOptions}\n min={minValue}\n max={maxValue}\n locale={locale}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n name={name}\n inputRef={inputRef}\n onValueCommitted={handleValueCommit}\n aria-describedby={formFieldControlProps.description}\n >\n <div\n data-spark-component=\"stepper\"\n ref={forwardedRef}\n className={cx(inputGroupStyles({ disabled, readOnly }), stepperProps.className)}\n >\n {children}\n </div>\n </NumberField.Root>\n </StepperContext.Provider>\n )\n}\n\nStepper.displayName = 'Stepper'\n\nexport const useStepperContext = () => {\n const context = useContext(StepperContext)\n\n if (!context) {\n throw Error('useStepperContext must be used within a Stepper provider')\n }\n\n return context\n}\n","import { NumberField } from '@base-ui/react/number-field'\nimport { Minus } from '@spark-ui/icons/Minus'\nimport { Plus } from '@spark-ui/icons/Plus'\nimport { cx } from 'class-variance-authority'\nimport { type PropsWithChildren } from 'react'\n\nimport { Icon } from '../icon'\nimport { IconButton } from '../icon-button'\nimport { useStepperContext } from './Stepper'\nimport type { StepperButtonProps } from './types'\n\n/** A button to increment the stepper value. Renders a <button> element. */\nconst IncrementButton = ({\n children,\n design = 'ghost',\n intent = 'neutral',\n className,\n ref: forwardedRef,\n disabled,\n ...rest\n}: PropsWithChildren<StepperButtonProps>) => {\n const { fieldId, state } = useStepperContext()\n\n return (\n <NumberField.Increment\n render={buttonProps => {\n const isDisabled = disabled || ('disabled' in buttonProps && (buttonProps as any).disabled)\n const isReadOnly = 'readOnly' in buttonProps && (buttonProps as any).readOnly\n const isInactive = isDisabled || isReadOnly\n\n return (\n <div\n className={cx('rounded-r-lg', isInactive ? 'bg-on-surface/dim-5' : null)}\n data-spark-component=\"stepper-increment-button\"\n >\n <IconButton\n ref={forwardedRef}\n design={design}\n intent={intent}\n className={cx(\n 'overflow-hidden border-sm shrink-0 h-full focus-visible:relative focus-visible:z-raised mx-0',\n 'rounded-l-0! -ml-px rounded-r-lg',\n state === 'error' && 'border-error',\n state === 'alert' && 'border-alert',\n state === 'success' && 'border-success',\n !state && 'border-outline',\n className\n )}\n {...rest}\n {...buttonProps}\n aria-label={rest['aria-label'] || (buttonProps['aria-label'] as string)}\n aria-controls={fieldId}\n disabled={isDisabled}\n >\n {children || (\n <Icon>\n <Plus />\n </Icon>\n )}\n </IconButton>\n </div>\n )\n }}\n />\n )\n}\n\n/** A button to decrement the stepper value. Renders a <button> element. */\nconst DecrementButton = ({\n children,\n design = 'ghost',\n intent = 'neutral',\n className,\n ref: forwardedRef,\n disabled,\n ...rest\n}: PropsWithChildren<StepperButtonProps>) => {\n const { fieldId, state } = useStepperContext()\n\n return (\n <NumberField.Decrement\n render={buttonProps => {\n const isDisabled = disabled || ('disabled' in buttonProps && (buttonProps as any).disabled)\n const isReadOnly = 'readOnly' in buttonProps && (buttonProps as any).readOnly\n const isInactive = isDisabled || isReadOnly\n\n return (\n <div\n className={cx('rounded-l-lg', isInactive ? 'bg-on-surface/dim-5' : null)}\n data-spark-component=\"stepper-decrement-button\"\n >\n <IconButton\n ref={forwardedRef}\n design={design}\n intent={intent}\n className={cx(\n 'overflow-hidden border-sm shrink-0 h-full focus-visible:relative focus-visible:z-raised mx-0',\n 'rounded-r-0! -mr-px rounded-l-lg',\n state === 'error' && 'border-error',\n state === 'alert' && 'border-alert',\n state === 'success' && 'border-success',\n !state && 'border-outline',\n className\n )}\n {...rest}\n {...buttonProps}\n aria-label={rest['aria-label'] || (buttonProps['aria-label'] as string)}\n aria-controls={fieldId}\n disabled={isDisabled}\n >\n {children || (\n <Icon>\n <Minus />\n </Icon>\n )}\n </IconButton>\n </div>\n )\n }}\n />\n )\n}\n\nexport const StepperIncrementButton = IncrementButton\n\nexport const StepperDecrementButton = DecrementButton\n\nIncrementButton.displayName = 'Stepper.IncrementButton'\nDecrementButton.displayName = 'Stepper.DecrementButton'\n","import { NumberField } from '@base-ui/react/number-field'\nimport { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\n\nimport { Input as SparkInput } from '../input'\nimport { useStepperContext } from './Stepper'\nimport type { StepperInputProps } from './types'\n\n/** The numeric input field displaying the stepper value. Renders an <input> element. */\nconst Input = ({ ref: forwardedRef, ...props }: StepperInputProps) => {\n const { inputRef, fieldId, fieldLabelId, fieldIsInvalid, fieldIsRequired, ariaLabel } =\n useStepperContext()\n const ref = useMergeRefs(forwardedRef, inputRef)\n const { className = '', ...remainingProps } = props\n\n // Only use aria-label if not wrapped in a FormField with a label (fieldLabelId would be set by FormField.Label)\n const hasFormFieldLabel = !!fieldLabelId\n\n return (\n <div className=\"relative inline-flex w-full\">\n <NumberField.Input\n render={inputProps => {\n // Determine required attribute\n let required: boolean | undefined = undefined\n if (fieldIsRequired !== undefined) {\n required = fieldIsRequired\n } else if ('required' in inputProps) {\n required = (inputProps as any).required\n }\n\n // Determine aria-invalid attribute\n const ariaInvalid =\n fieldIsInvalid !== undefined ? fieldIsInvalid : inputProps['aria-invalid']\n\n return (\n <SparkInput\n ref={ref}\n {...inputProps}\n {...remainingProps}\n id={fieldId || inputProps.id}\n required={required}\n aria-invalid={ariaInvalid}\n aria-label={hasFormFieldLabel ? undefined : ariaLabel}\n className={`min-w-sz-56 text-center rounded-none! ${className}`}\n />\n )\n }}\n />\n </div>\n )\n}\n\nexport const StepperInput = Input\n\nInput.displayName = 'Stepper.Input'\n","import { Stepper as Root } from './Stepper'\nimport {\n StepperDecrementButton as DecrementButton,\n StepperIncrementButton as IncrementButton,\n} from './StepperButton'\nimport { StepperInput as Input } from './StepperInput'\n\n/**\n * A numeric input component with increment and decrement buttons for adjusting values.\n */\nexport const Stepper: typeof Root & {\n IncrementButton: typeof IncrementButton\n DecrementButton: typeof DecrementButton\n Input: typeof Input\n} = Object.assign(Root, { IncrementButton, DecrementButton, Input })\n\nStepper.displayName = 'Stepper'\nIncrementButton.displayName = 'Stepper.IncrementButton'\nDecrementButton.displayName = 'Stepper.DecrementButton'\nInput.displayName = 'Stepper.Input'\n\nexport type { StepperProps, StepperButtonProps, StepperInputProps } from './types'\n"],"mappings":";;;;;;;;;;;;AAkBA,IAAM,IAAiB,EAA0C,KAAK,EAEzD,KAAW,EACtB,aACA,kBACA,aACA,aACA,KAAK,GACL,kB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mBAAgB,oBAAiB,iBACxE,GAAmB,EACf,IAAM,EAAa,GAAc,EAAS,EAC1C,EAAE,eAAY,IAAI,GAAG,MAAmB,GAGxC,IAAoB,CAAC,CAAC;AAE5B,QACE,kBAAC,OAAD;EAAK,WAAU;YACb,kBAAC,EAAY,OAAb,EACE,SAAQ,MAAc;GAEpB,IAAI;AACJ,GAAI,MAAoB,KAAA,IAEb,cAAc,MACvB,IAAY,EAAmB,YAF/B,IAAW;GAMb,IAAM,IACJ,MAAmB,KAAA,IAA6B,EAAW,kBAA5B;AAEjC,UACE,kBAAC,GAAD;IACO;IACL,GAAI;IACJ,GAAI;IACJ,IAAI,KAAW,EAAW;IAChB;IACV,gBAAc;IACd,cAAY,IAAoB,KAAA,IAAY;IAC5C,WAAW,yCAAyC;IACpD,CAAA;KAGN,CAAA;EACE,CAAA;GAIG,IAAe;AAE5B,EAAM,cAAc;;;AC3CpB,IAAa,IAIT,OAAO,OAAO,GAAM;CAAE,iBAAA;CAAiB,iBAAA;CAAiB,OAAA;CAAO,CAAC;AAEpE,EAAQ,cAAc,WACtB,EAAgB,cAAc,2BAC9B,EAAgB,cAAc,2BAC9B,EAAM,cAAc"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/stepper/Stepper.tsx","../../src/stepper/StepperButton.tsx","../../src/stepper/StepperInput.tsx","../../src/stepper/index.ts"],"sourcesContent":["import { NumberField } from '@base-ui/react/number-field'\nimport { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { cx } from 'class-variance-authority'\nimport { createContext, type PropsWithChildren, RefObject, useContext, useRef } from 'react'\n\nimport { inputGroupStyles } from '../input/InputGroup.styles'\nimport type { StepperProps } from './types'\n\ninterface StepperContextValue {\n inputRef: RefObject<HTMLInputElement | null>\n fieldId?: string\n fieldLabelId?: string\n fieldIsInvalid?: boolean\n fieldIsRequired?: boolean\n state?: 'error' | 'alert' | 'success'\n ariaLabel?: string\n}\n\nconst StepperContext = createContext<StepperContextValue | null>(null)\n\nexport const Stepper = ({\n children,\n formatOptions,\n minValue,\n maxValue,\n ref: forwardedRef,\n onValueChange,\n locale = 'fr',\n name: nameProp,\n ...stepperProps\n}: PropsWithChildren<StepperProps>) => {\n const inputRef = useRef<HTMLInputElement>(null)\n const formFieldControlProps = useFormFieldControl()\n const lastCommittedValueRef = useRef<number | null>(\n stepperProps.value ?? stepperProps.defaultValue ?? null\n )\n\n const name = formFieldControlProps.name ?? nameProp\n const disabled = formFieldControlProps.disabled ?? stepperProps.disabled\n const readOnly = formFieldControlProps.readOnly ?? stepperProps.readOnly\n const required = formFieldControlProps.isRequired ?? stepperProps.required\n\n // Base UI calls onValueChange on every keystroke, but react-aria only called it on blur.\n // We use onValueCommitted to preserve the old behavior where onValueChange is only called on blur for input changes,\n // but immediately for button clicks.\n const handleValueCommit = (value: number | null) => {\n // Allow null values to be propagated (when input is cleared)\n // This is necessary for controlled mode and React Hook Form validation\n if (onValueChange && value !== lastCommittedValueRef.current) {\n lastCommittedValueRef.current = value\n onValueChange(value)\n }\n }\n\n // Extract aria-label to pass to input, not to NumberField.Root\n const { 'aria-label': ariaLabel, ...restStepperProps } = stepperProps\n\n return (\n <StepperContext\n value={{\n inputRef,\n fieldId: formFieldControlProps.id,\n fieldLabelId: formFieldControlProps.labelId,\n fieldIsInvalid: formFieldControlProps.isInvalid,\n fieldIsRequired: required,\n state: stepperProps.state,\n ariaLabel,\n }}\n >\n <NumberField.Root\n {...restStepperProps}\n format={formatOptions}\n min={minValue}\n max={maxValue}\n locale={locale}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n name={name}\n inputRef={inputRef}\n onValueCommitted={handleValueCommit}\n aria-describedby={formFieldControlProps.description}\n >\n <div\n data-spark-component=\"stepper\"\n ref={forwardedRef}\n className={cx(inputGroupStyles({ disabled, readOnly }), stepperProps.className)}\n >\n {children}\n </div>\n </NumberField.Root>\n </StepperContext>\n )\n}\n\nStepper.displayName = 'Stepper'\n\nexport const useStepperContext = () => {\n const context = useContext(StepperContext)\n\n if (!context) {\n throw Error('useStepperContext must be used within a Stepper provider')\n }\n\n return context\n}\n","import { NumberField } from '@base-ui/react/number-field'\nimport { Minus } from '@spark-ui/icons/Minus'\nimport { Plus } from '@spark-ui/icons/Plus'\nimport { cx } from 'class-variance-authority'\nimport { type PropsWithChildren } from 'react'\n\nimport { Icon } from '../icon'\nimport { IconButton } from '../icon-button'\nimport { useStepperContext } from './Stepper'\nimport type { StepperButtonProps } from './types'\n\n/** A button to increment the stepper value. Renders a <button> element. */\nconst IncrementButton = ({\n children,\n design = 'ghost',\n intent = 'neutral',\n className,\n ref: forwardedRef,\n disabled,\n ...rest\n}: PropsWithChildren<StepperButtonProps>) => {\n const { fieldId, state } = useStepperContext()\n\n return (\n <NumberField.Increment\n render={buttonProps => {\n const isDisabled = disabled || ('disabled' in buttonProps && (buttonProps as any).disabled)\n const isReadOnly = 'readOnly' in buttonProps && (buttonProps as any).readOnly\n const isInactive = isDisabled || isReadOnly\n\n return (\n <div\n className={cx('rounded-r-lg', isInactive ? 'bg-on-surface/dim-5' : null)}\n data-spark-component=\"stepper-increment-button\"\n >\n <IconButton\n ref={forwardedRef}\n design={design}\n intent={intent}\n className={cx(\n 'overflow-hidden border-sm shrink-0 h-full focus-visible:relative focus-visible:z-raised mx-0',\n 'rounded-l-0! -ml-px rounded-r-lg',\n state === 'error' && 'border-error',\n state === 'alert' && 'border-alert',\n state === 'success' && 'border-success',\n !state && 'border-outline',\n className\n )}\n {...rest}\n {...buttonProps}\n aria-label={rest['aria-label'] || (buttonProps['aria-label'] as string)}\n aria-controls={fieldId}\n disabled={isDisabled}\n >\n {children || (\n <Icon>\n <Plus />\n </Icon>\n )}\n </IconButton>\n </div>\n )\n }}\n />\n )\n}\n\n/** A button to decrement the stepper value. Renders a <button> element. */\nconst DecrementButton = ({\n children,\n design = 'ghost',\n intent = 'neutral',\n className,\n ref: forwardedRef,\n disabled,\n ...rest\n}: PropsWithChildren<StepperButtonProps>) => {\n const { fieldId, state } = useStepperContext()\n\n return (\n <NumberField.Decrement\n render={buttonProps => {\n const isDisabled = disabled || ('disabled' in buttonProps && (buttonProps as any).disabled)\n const isReadOnly = 'readOnly' in buttonProps && (buttonProps as any).readOnly\n const isInactive = isDisabled || isReadOnly\n\n return (\n <div\n className={cx('rounded-l-lg', isInactive ? 'bg-on-surface/dim-5' : null)}\n data-spark-component=\"stepper-decrement-button\"\n >\n <IconButton\n ref={forwardedRef}\n design={design}\n intent={intent}\n className={cx(\n 'overflow-hidden border-sm shrink-0 h-full focus-visible:relative focus-visible:z-raised mx-0',\n 'rounded-r-0! -mr-px rounded-l-lg',\n state === 'error' && 'border-error',\n state === 'alert' && 'border-alert',\n state === 'success' && 'border-success',\n !state && 'border-outline',\n className\n )}\n {...rest}\n {...buttonProps}\n aria-label={rest['aria-label'] || (buttonProps['aria-label'] as string)}\n aria-controls={fieldId}\n disabled={isDisabled}\n >\n {children || (\n <Icon>\n <Minus />\n </Icon>\n )}\n </IconButton>\n </div>\n )\n }}\n />\n )\n}\n\nexport const StepperIncrementButton = IncrementButton\n\nexport const StepperDecrementButton = DecrementButton\n\nIncrementButton.displayName = 'Stepper.IncrementButton'\nDecrementButton.displayName = 'Stepper.DecrementButton'\n","import { NumberField } from '@base-ui/react/number-field'\nimport { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\n\nimport { Input as SparkInput } from '../input'\nimport { useStepperContext } from './Stepper'\nimport type { StepperInputProps } from './types'\n\n/** The numeric input field displaying the stepper value. Renders an <input> element. */\nconst Input = ({ ref: forwardedRef, ...props }: StepperInputProps) => {\n const { inputRef, fieldId, fieldLabelId, fieldIsInvalid, fieldIsRequired, ariaLabel } =\n useStepperContext()\n const ref = useMergeRefs(forwardedRef, inputRef)\n const { className = '', ...remainingProps } = props\n\n // Only use aria-label if not wrapped in a FormField with a label (fieldLabelId would be set by FormField.Label)\n const hasFormFieldLabel = !!fieldLabelId\n\n return (\n <div className=\"relative inline-flex w-full\">\n <NumberField.Input\n render={inputProps => {\n // Determine required attribute\n let required: boolean | undefined = undefined\n if (fieldIsRequired !== undefined) {\n required = fieldIsRequired\n } else if ('required' in inputProps) {\n required = (inputProps as any).required\n }\n\n // Determine aria-invalid attribute\n const ariaInvalid =\n fieldIsInvalid !== undefined ? fieldIsInvalid : inputProps['aria-invalid']\n\n return (\n <SparkInput\n ref={ref}\n {...inputProps}\n {...remainingProps}\n id={fieldId || inputProps.id}\n required={required}\n aria-invalid={ariaInvalid}\n aria-label={hasFormFieldLabel ? undefined : ariaLabel}\n className={`min-w-sz-56 text-center rounded-none! ${className}`}\n />\n )\n }}\n />\n </div>\n )\n}\n\nexport const StepperInput = Input\n\nInput.displayName = 'Stepper.Input'\n","import { Stepper as Root } from './Stepper'\nimport {\n StepperDecrementButton as DecrementButton,\n StepperIncrementButton as IncrementButton,\n} from './StepperButton'\nimport { StepperInput as Input } from './StepperInput'\n\n/**\n * A numeric input component with increment and decrement buttons for adjusting values.\n */\nexport const Stepper: typeof Root & {\n IncrementButton: typeof IncrementButton\n DecrementButton: typeof DecrementButton\n Input: typeof Input\n} = Object.assign(Root, { IncrementButton, DecrementButton, Input })\n\nStepper.displayName = 'Stepper'\nIncrementButton.displayName = 'Stepper.IncrementButton'\nDecrementButton.displayName = 'Stepper.DecrementButton'\nInput.displayName = 'Stepper.Input'\n\nexport type { StepperProps, StepperButtonProps, StepperInputProps } from './types'\n"],"mappings":";;;;;;;;;;;;AAkBA,IAAM,IAAiB,EAA0C,KAAK,EAEzD,KAAW,EACtB,aACA,kBACA,aACA,aACA,KAAK,GACL,kBACA,YAAS,MACT,MAAM,GACN,GAAG,QACkC;CACrC,IAAM,IAAW,EAAyB,KAAK,EACzC,IAAwB,GAAqB,EAC7C,IAAwB,EAC5B,EAAa,SAAS,EAAa,gBAAgB,KACpD,EAEK,IAAO,EAAsB,QAAQ,GACrC,IAAW,EAAsB,YAAY,EAAa,UAC1D,IAAW,EAAsB,YAAY,EAAa,UAC1D,IAAW,EAAsB,cAAc,EAAa,U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,YAF/B,IAAW;GAMb,IAAM,IACJ,MAAmB,KAAA,IAA6B,EAAW,kBAA5B;AAEjC,UACE,kBAAC,GAAD;IACO;IACL,GAAI;IACJ,GAAI;IACJ,IAAI,KAAW,EAAW;IAChB;IACV,gBAAc;IACd,cAAY,IAAoB,KAAA,IAAY;IAC5C,WAAW,yCAAyC;IACpD,CAAA;KAGN,CAAA;EACE,CAAA;GAIG,IAAe;AAE5B,EAAM,cAAc;;;AC3CpB,IAAa,IAIT,OAAO,OAAO,GAAM;CAAE,iBAAA;CAAiB,iBAAA;CAAiB,OAAA;CAAO,CAAC;AAEpE,EAAQ,cAAc,WACtB,EAAgB,cAAc,2BAC9B,EAAgB,cAAc,2BAC9B,EAAM,cAAc"}
|
package/dist/table/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../chunk-C91j1N6u.js`),t=require(`../icon-CRPcdgYp.js`),n=require(`../button-Tv2N8_24.js`),r=require(`../checkbox-DjwbAH09.js`);let i=require(`class-variance-authority`),a=require(`react`);a=e.t(a);let o=require(`react/jsx-runtime`),s=require(`@react-aria/utils`),c=require(`@react-stately/table`),l=require(`react-aria`),u=require(`@react-aria/table`),d=require(`@spark-ui/icons/ArrowDown`),f=require(`@spark-ui/icons/ArrowUp`),p=require(`@spark-ui/icons/Sort`);var m=(0,a.createContext)({isResizable:!1,tableWidth:0});function h(){return(0,a.useContext)(m)}var g=(0,a.createContext)({selectedCount:0,onClearSelection:()=>{}});function _(){return(0,a.useContext)(g)}function v({children:e,className:t,selectedKeys:n,onSelectionChange:r,totalCount:a,hasMultiplePages:s,onClearSelection:c,onSelectAll:l,allowsResizing:u=!0,resizeColumnAriaLabel:d,maxHeight:f,stickyHeader:p,onResizeStart:m,onResize:h,onResizeEnd:_,onKeyDownCapture:v,sortDescriptor:y,onSortChange:b,...x}){let S=0;n===`all`?S=a??0:n instanceof Set?S=n.size:n&&(S=new Set(n).size);let C=c??(()=>r?.(new Set)),w={...x,selectedKeys:n,onSelectionChange:r,totalCount:a,hasMultiplePages:s,onSelectAll:l,selectedCount:S,onClearSelection:C,allowsResizing:u,resizeColumnAriaLabel:d,maxHeight:f,stickyHeader:p,onResizeStart:m,onResize:h,onResizeEnd:_,onKeyDownCapture:v,sortDescriptor:y,onSortChange:b,className:t};return(0,o.jsx)(g.Provider,{value:w,children:(0,o.jsx)(`div`,{className:(0,i.cx)(`gap-md flex flex-col`,t),children:e})})}v.displayName=`Table`;function y({className:e,children:t,...n}){let r=(0,a.useRef)(null),[c,l]=(0,a.useState)(0);return(0,a.useLayoutEffect)(()=>{let e=r.current;e&&l(e.clientWidth)},[]),(0,s.useResizeObserver)({ref:r,onResize:()=>{let e=r.current;e&&l(e.clientWidth)}}),(0,o.jsx)(m.Provider,{value:{isResizable:!0,tableWidth:c},children:(0,o.jsx)(`div`,{ref:r,"data-spark-component":`resizable-table-container`,className:(0,i.cx)(`relative w-full overflow-auto`,e),...n,children:t})})}y.displayName=`ResizableTableContainer`;var b=`[data-spark-component="table-cell"]`;function x(e){return!e||!(e instanceof Element)?!1:!!e.closest(`[role="combobox"],select,[data-spark-component="dropdown-trigger"],[data-spark-component="combobox-input"]`)}function S(e){if(!e||!(e instanceof Element))return!1;let t=e.closest(`[role="combobox"],[data-spark-component="dropdown-trigger"],[data-spark-component="combobox-input"]`);return t?t.getAttribute(`aria-expanded`)===`true`:!1}var C=`a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]`;function w(e){return!e||!(e instanceof Element)?null:e.closest(b)}function T(e){return e.getAttribute(`data-table-cell-kind`)===`selection`}function E(e){return Array.from(e.querySelectorAll(C)).filter(t=>!(t===e||t.hasAttribute(`disabled`)||t.getAttribute(`aria-disabled`)===`true`||t.getAttribute(`hidden`)!==null))}function D(e,t){for(let n of E(e)){let e=`data-prev-tabindex`;if(!t)n.hasAttribute(e)||n.setAttribute(e,n.getAttribute(`tabindex`)??``),n.setAttribute(`tabindex`,`-1`);else{let t=n.getAttribute(e);if(t===null)continue;n.removeAttribute(e),t===``?n.removeAttribute(`tabindex`):n.setAttribute(`tabindex`,t)}}}function O(e){let t=Array.from(e.querySelectorAll(b));for(let e of t)D(e,!1)}function ee({ref:e,gridProps:t,onKeyDownCapture:n,onFocusCapture:r}){let[i,o]=(0,a.useState)(`grid`),s=(0,a.useRef)(`grid`),c=(0,a.useRef)(null),u=(0,a.useRef)(!1),d=(0,a.useMemo)(()=>{let{onKeyDown:a,...d}=t,f=e=>{c.current=e,s.current=`interaction`,o(`interaction`),D(e,!0)};return(0,l.mergeProps)(d,{onKeyDown:e=>{if(s.current===`interaction`&&(e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`||e.key===`ArrowDown`)){let e=c.current,t=document.activeElement;if(e&&t instanceof Node&&e.contains(t))return}s.current===`interaction`&&(e.key===`ArrowUp`||e.key===`ArrowDown`)&&x(e.target)&&w(e.target)===c.current||a?.(e)},onKeyDownCapture:e=>{if(n?.(e),s.current===`interaction`&&e.key===`Tab`){let t=w(e.target);t&&t===c.current&&e.stopPropagation();return}if(x(e.target)&&s.current===`interaction`&&(e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`||e.key===`ArrowDown`)){let t=w(e.target);if(t&&t===c.current)return}if(s.current===`interaction`&&(e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`||e.key===`ArrowDown`)){let t=w(e.target);if(t&&t===c.current){e.stopPropagation();return}}if(s.current===`grid`&&e.key===`ArrowRight`){let t=w(e.target);if(t){let n=t.closest(`tr`);if(n){let r=Array.from(n.querySelectorAll(b));if(r.length>0&&r[r.length-1]===t){e.preventDefault(),e.stopPropagation(),n.focus();return}}}}if(s.current===`grid`&&e.key===`Enter`){let t=w(e.target);if(!t||T(t))return;let n=E(t);if(n.length===0)return;e.preventDefault(),e.stopPropagation(),f(t),n[0]?.focus();return}if(s.current===`grid`&&e.key===`F2`){let t=w(e.target);if(!t||T(t))return;let n=E(t);if(n.length===0)return;e.preventDefault(),e.stopPropagation(),f(t),n[0]?.focus();return}if(s.current===`interaction`&&e.key===`Escape`){if(S(e.target))return;let t=c.current;if(!t)return;e.preventDefault(),e.stopPropagation(),s.current=`grid`,o(`grid`),t.focus()}if(s.current===`interaction`&&e.key===`F2`){let t=c.current;if(!t)return;e.preventDefault(),e.stopPropagation(),s.current=`grid`,o(`grid`),t.focus()}},onBlurCapture:t=>{if(s.current!==`interaction`)return;let n=e.current;if(!n)return;let r=t.relatedTarget;r instanceof Node&&n.contains(r)||(c.current=null,s.current=`grid`,o(`grid`))},onFocusCapture:t=>{r?.(t);let n=u.current;u.current=!1;let i=e.current,a=w(t.target);if(s.current===`interaction`&&c.current&&i){let e=!!(a&&a!==c.current),n=!a&&t.target instanceof Element&&i.contains(t.target)&&!c.current.contains(t.target);(e||n)&&(s.current=`grid`,o(`grid`),n&&(c.current=null))}if(!a)return;c.current=a;let l=t.target instanceof Element?t.target:null,d=a.matches(b),p=s.current===`grid`,m=!!(l&&l!==a&&a.contains(l)),h=E(a).length>0;p&&d&&m&&h&&!n&&queueMicrotask(()=>a.focus()),n&&p&&m&&d&&h&&!T(a)&&f(a)},onPointerDownCapture:e=>{let t=w(e.target);t?.matches(b)&&e.target instanceof Element&&e.target!==t&&t.contains(e.target)&&(u.current=!0)},"data-table-keyboard-mode":i})},[t,i,e,r,n]);return(0,a.useEffect)(()=>{s.current=i;let t=e.current;if(t){if(i===`grid`){O(t),c.current?.focus?.();return}O(t),c.current&&D(c.current,!0)}},[i,e]),{gridProps:d,keyboardMode:i}}var k=(0,i.cva)([`h-sz-64 min-w-sz-64`,`relative group/column first:rounded-l-xl last:rounded-r-xl bg-neutral-container`,`pl-lg pr-lg py-sm text-left outline-none box-border`,`cursor-default`,`data-focus-visible:u-outline data-focus-visible:-outline-offset-2`],{variants:{checkbox:{true:[`w-sz-64 min-w-sz-64 max-w-sz-64`,`px-0 align-middle`]},resizable:{true:[`pr-xl`]}},defaultVariants:{checkbox:!1,resizable:!1}}),te=(0,i.cva)([`flex flex-1 justify-between items-center gap-md`,`font-inherit text-left text-inherit`,`whitespace-nowrap text-ellipsis`,`border-transparent`,`data-focus-visible:u-outline data-focus-visible:outline-offset-2`],{variants:{},defaultVariants:{}});(0,i.cva)([`empty:italic empty:text-center empty:text-body-2 empty:py-lg`],{variants:{},defaultVariants:{}});var ne=(0,i.cva)([`p-lg outline-none box-border default:overflow-hidden`,`border-b-sm border-outline [tr:last-child>&]:border-b-0`,`[-webkit-tap-highlight-color:transparent]`,`data-focus-visible:u-outline-inset data-focus-visible:outline-dashed`],{variants:{checkbox:{true:[`w-sz-64 py-sm px-0 align-middle`]}},defaultVariants:{checkbox:!1}}),re=(0,i.cva)([`pointer-events-none`,`[&_td]:h-sz-16 [&_td]:p-0 [&_td]:border-0 [&_td]:border-b-0 [&_td]:bg-surface [&_td]:align-middle`],{variants:{},defaultVariants:{}}),ie=`button, [role="button"], [role="switch"], [role="checkbox"], [role="option"], input:not([type="hidden"]), select, textarea, [href], [data-spark-component="dropdown-trigger"], [data-spark-component="icon-button"], [data-spark-component="switch"], [data-spark-component="switch-input"], [data-spark-component="combobox-input"]`,ae=`a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]`;function oe(e){if(!e||!(e instanceof Element))return!1;let t=e;return t.matches(ie)||t.closest(ie)!==null}function se(e){return e?e instanceof Element?e:e instanceof Text?e.parentElement:null:null}function ce(e){for(let t of e.querySelectorAll(ae))if(t!==e&&!t.hasAttribute(`disabled`)&&t.getAttribute(`aria-disabled`)!==`true`&&t.getAttribute(`hidden`)===null)return!0;return!1}function le(e){let t=se(e);if(!t)return!1;if(oe(t))return!0;let n=t.closest(`[data-spark-component="table-cell"]`);return!n||n.getAttribute(`data-table-cell-kind`)===`selection`?!1:ce(n)}var A=(0,a.createContext)(`grid`);function j({checkboxProps:e,className:t,suppressFocusWalker:n}){let{isSelected:i,isIndeterminate:a,isDisabled:s,onChange:c,...l}=e,u=a===!0?`indeterminate`:!!i;return(0,o.jsx)(`span`,{...n?{"data-react-aria-prevent-focus":!0}:void 0,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),className:t??`flex h-full min-h-full items-center justify-center`,children:(0,o.jsx)(r.n,{checked:u,disabled:s,onCheckedChange:c,...l})})}j.displayName=`Table.SelectionCheckbox`;function M({cell:e,state:t,resizeState:n}){let r=(0,a.useRef)(null),{gridCellProps:i}=(0,l.useTableCell)({node:e},t,r),{isFocusVisible:s,focusProps:c}=(0,l.useFocusRing)(),d=(0,a.useContext)(A),f=(0,a.useCallback)(e=>{d===`interaction`&&(e.key!==` `&&e.key!==`Enter`||e.stopPropagation())},[d]),{onKeyDownCapture:p,...m}=i,h=(0,a.useCallback)(e=>{[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].includes(e.key)||p?.(e)},[p]),g=(0,u.useTableSelectionCheckbox)({key:e.parentKey??e.key},t),_=t.collection.columns[e.index??0]?.key??null,v=_?n?.columnWidths?.get?.(_):void 0;return e.props?.isSelectionCell?(0,o.jsx)(`td`,{...(0,l.mergeProps)(m,{onKeyDownCapture:h},c,{onKeyDown:f}),ref:r,"data-spark-component":`table-cell`,"data-table-cell-kind":`selection`,className:ne({checkbox:!0}),"data-focus-visible":s||void 0,children:(0,o.jsx)(j,{suppressFocusWalker:d===`grid`,checkboxProps:g.checkboxProps})}):(0,o.jsx)(`td`,{...(0,l.mergeProps)(m,{onKeyDownCapture:h},c,{onKeyDown:f}),ref:r,"data-spark-component":`table-cell`,className:ne(),"data-focus-visible":s||void 0,style:v?{width:v}:void 0,children:e.rendered})}M.displayName=`Table.BodyCellRenderer`;function N(e){if(e)return t=>{le((0,s.getEventTarget)(t.nativeEvent))||e(t)}}function P({item:e,state:t,resizeState:n}){let r=(0,a.useRef)(null),{rowProps:s,isSelected:c}=(0,l.useTableRow)({node:e},t,r),{isFocusVisible:u,focusProps:d}=(0,l.useFocusRing)(),{onClick:f,onPointerDown:p,onMouseDown:m,onPointerUp:h,onPointerCancel:g,..._}=s,v=(0,i.cx)(`outline-none box-border data-focus-visible:u-outline-inset data-focus-visible:outline-dashed`,_.className,c&&`bg-support-container text-on-support-container`);return(0,o.jsx)(`tr`,{...(0,l.mergeProps)(_,d),onPointerDown:N(p),onMouseDown:N(m),onPointerUp:N(h),onPointerCancel:N(g),onClick:N(f),ref:r,"data-spark-component":`table-row`,"data-selected":c||void 0,"data-focus-visible":u||void 0,className:v,tabIndex:-1,children:[...e.childNodes].map(e=>(0,o.jsx)(M,{cell:e,state:t,resizeState:n},e.key))})}P.displayName=`Table.BodyRowRenderer`;function F({column:e,ariaLabel:t,resizeState:n,resizeCallbacks:r}){let s=(0,a.useRef)(null),{resizerProps:c,inputProps:l,isResizing:d}=(0,u.useTableColumnResize)({column:e,"aria-label":t??`Resize column`,onResizeStart:r.onResizeStart,onResize:r.onResize,onResizeEnd:r.onResizeEnd},n,s);return(0,o.jsx)(`div`,{role:`presentation`,className:(0,i.cx)(`cursor-col-resize absolute inset-y-lg right-0 flex w-lg items-center justify-center`,`after:block after:h-full after:w-[2px] after:bg-outline after:transition-all after:duration-75`,`has-[input:focus-visible]:after:u-outline has-[input:focus-visible]:after:outline-offset-2`,d&&`after:bg-outline-high after:scale-120`),"data-resizable-direction":`both`,...c,children:(0,o.jsx)(`input`,{ref:s,disabled:!d,...l})})}F.displayName=`Table.ColumnResizer`;function I({state:e}){let{checkboxProps:t}=(0,u.useTableSelectAllCheckbox)(e),{collection:n,selectionManager:r}=e,i=r.selectedKeys,a=n,s=a.body,c=s==null?new Set(n.getKeys()):new Set([...a.getChildren(s.key)].map(e=>e.key)),l=i===`all`?c:i,d=[...c].filter(e=>l.has(e)).length,f=c.size,p=f>0&&d===f,m=d>0&&d<f,{isSelected:h,isIndeterminate:g,onChange:_,...v}=t,y=e=>{(e.key===` `||e.key===`Enter`)&&e.stopPropagation(),e.key===`Enter`&&(e.preventDefault(),t.isDisabled||_?.(!p))};return(0,o.jsx)(j,{checkboxProps:{...v,isSelected:p,isIndeterminate:m,onChange:_,onKeyDown:y}})}I.displayName=`Table.HeaderSelectionCheckbox`;var L=(0,i.cx)(`sticky top-0 z-sticky`);function R({column:e,state:n,resizeState:r,stickyHeader:s,resizeCallbacks:c,isLastColumnInRow:u=!1}){let m=(0,a.useRef)(null),{resizeColumnAriaLabel:h}=_(),{columnHeaderProps:g}=(0,l.useTableColumnHeader)({node:e},n,m),{isFocusVisible:v,focusProps:y}=(0,l.useFocusRing)(),b=e.props?.allowsResizing!==!1&&!u,x=r?.columnWidths?.get?.(e.key),S=!!(r&&b);if(e.props?.isSelectionCell)return(0,o.jsx)(`th`,{...g,ref:m,role:`columnheader`,className:(0,i.cx)(k({checkbox:!0}),s&&L),"data-spark-component":`table-column`,"data-table-selection-columnheader":!0,"data-focus-visible":v||void 0,children:(0,o.jsx)(I,{state:n})});let C=!!e.props?.allowsSorting,w=n.sortDescriptor?.column===e.key,T=n.sortDescriptor?.direction??`ascending`,E=w?T===`descending`?(0,o.jsx)(d.ArrowDown,{}):(0,o.jsx)(f.ArrowUp,{}):(0,o.jsx)(p.Sort,{}),D=t=>{C&&(t.key!==`Enter`&&t.key!==` `||(t.preventDefault(),t.stopPropagation(),n.sort?.(e.key)))};return(0,o.jsxs)(`th`,{...(0,l.mergeProps)(g,y),ref:m,role:`columnheader`,className:(0,i.cx)(k({resizable:S}),s&&L),style:x?{width:x}:void 0,"data-spark-component":`table-column`,"data-focus-visible":v||void 0,onKeyDown:D,children:[(0,o.jsxs)(`div`,{className:te(),children:[(0,o.jsx)(`button`,{type:`button`,className:(0,i.cx)(`gap-md flex min-w-0 flex-1 items-center text-left`,`focus-visible:u-outline outline-none`,`bg-transparent p-0 border-0`),onKeyDown:D,children:(0,o.jsx)(`span`,{className:`min-w-0 overflow-hidden text-ellipsis whitespace-nowrap`,children:e.rendered})}),C?(0,o.jsx)(`span`,{"aria-hidden":`true`,className:(0,i.cx)(`shrink-0 opacity-dim-2 group-hover/column:opacity-100`,w&&`opacity-100`),children:(0,o.jsx)(t.t,{size:`sm`,children:E})}):null]}),r&&b?(0,o.jsx)(F,{column:e,ariaLabel:typeof h==`function`?h(e):h,resizeState:r,resizeCallbacks:c}):null]})}R.displayName=`Table.ColumnHeader`;function z({item:e,state:t,resizeState:n,stickyHeader:r,resizeCallbacks:i}){let s=(0,a.useRef)(null),{rowProps:c}=(0,l.useTableHeaderRow)({node:e},t,s),u=[...e.childNodes];return(0,o.jsx)(`tr`,{...c,ref:s,children:u.map((e,a)=>(0,o.jsx)(R,{column:e,state:t,resizeState:n,stickyHeader:r,resizeCallbacks:i,isLastColumnInRow:a===u.length-1},e.key))})}z.displayName=`Table.HeaderRowRenderer`;function B({className:e,children:t,stickyHeader:n,...r}){let u=!!n,d=(0,a.useRef)(null),f=h(),p=r.selectionMode===`multiple`,m=(0,c.useTableState)({...r,showSelectionCheckboxes:r.selectionMode===`multiple`,children:t}),g=(0,c.useTableColumnResizeState)({tableWidth:f.tableWidth},m),_=f.isResizable&&r.allowsResizing!==!1?g:null,{gridProps:v}=(0,l.useTable)({...r},m,d),y=m.collection.headerRows,b=[...m.collection.body.childNodes],x=m.collection.body.props?.renderEmptyState,S=m.collection.columns.length||1,C=b.length>0||!!x,{rowGroupProps:w}=(0,l.useTableRowGroup)(),{rowGroupProps:T}=(0,l.useTableRowGroup)(),{gridProps:E,keyboardMode:D}=ee({ref:d,gridProps:v,onKeyDownCapture:r.onKeyDownCapture,onFocusCapture:r.onFocusCapture});return(0,o.jsx)(A.Provider,{value:D,children:(0,o.jsxs)(`table`,{...(0,l.mergeProps)(E,(0,s.filterDOMProps)(r,{global:!0})),ref:d,"data-spark-component":`table`,className:(0,i.cx)(`default:w-full`,p?`table-fixed`:void 0,`border-separate border-spacing-y-0`,`bg-surface`,`outline-none`,`text-body-1`,`forced-color-adjust-none`,`data-focus-visible:u-outline-inset`,`has-[>[data-empty]]:h-full`,e),children:[(0,o.jsx)(`thead`,{...w,"data-spark-component":`table-header`,children:y.map(e=>(0,o.jsx)(z,{item:e,state:m,resizeState:_,stickyHeader:u,resizeCallbacks:{onResizeStart:r.onResizeStart,onResize:r.onResize,onResizeEnd:r.onResizeEnd}},e.key))}),(0,o.jsxs)(`tbody`,{...T,"data-spark-component":`table-body`,children:[C?(0,o.jsx)(`tr`,{"aria-hidden":`true`,className:re(),role:`presentation`,"data-spark-component":`table-body-spacer`,children:(0,o.jsx)(`td`,{colSpan:S,role:`presentation`})}):null,b.length===0&&x?(0,o.jsx)(`tr`,{"data-empty":!0,children:(0,o.jsx)(`td`,{colSpan:S,children:x({isEmpty:!0})})}):null,b.map(e=>(0,o.jsx)(P,{item:e,state:m,resizeState:_},e.key))]})]})})}B.displayName=`Table.Grid.Inner`;function ue(e){return typeof e==`number`?`${e}px`:e}function V({"aria-label":e,"aria-labelledby":t,className:n,children:r}){let{allowsResizing:i=!0,maxHeight:a,stickyHeader:s,onResizeStart:c,onResize:l,onResizeEnd:u,onKeyDownCapture:d,sortDescriptor:f,onSortChange:p,className:m,...h}=_(),g=a==null?void 0:{maxHeight:ue(a)},v=n??m,b={...h,...e!=null&&{"aria-label":e},...t!=null&&{"aria-labelledby":t},sortDescriptor:f,onSortChange:p,onKeyDownCapture:d,className:v,stickyHeader:s},x=B;return i?(0,o.jsx)(y,{className:v,style:g,onResizeStart:c,onResize:l,onResizeEnd:u,children:(0,o.jsx)(x,{...b,children:r})}):(0,o.jsx)(`div`,{className:`relative w-full overflow-auto`,style:g,children:(0,o.jsx)(x,{...b,children:r})})}V.displayName=`Table.Grid`;function H(e){return(0,o.jsx)(c.TableBody,{...e})}H.displayName=`Table.Body`,H.getCollectionNode=c.TableBody.getCollectionNode;var U=(0,a.createContext)(null);function W(){let e=(0,a.useContext)(U);if(!e)throw Error(`Table.BulkBar subcomponents must be used within Table.BulkBar`);return e}function G({children:e,className:t,rootProps:n,...r}){let{selectedCount:a,totalCount:s,onClearSelection:c,onSelectAll:l,hasMultiplePages:u}=_(),d={selectedCount:a,totalCount:s,onClearSelection:c,onSelectAll:l,hasMultiplePages:u};return(0,o.jsx)(U.Provider,{value:d,children:(0,o.jsx)(`div`,{role:`toolbar`,"aria-label":r[`aria-label`]??`Table bulk actions`,"data-spark-component":`table-bulk-bar`,className:(0,i.cx)(`gap-lg min-h-sz-64 flex w-full flex-wrap items-center justify-between`,`rounded-lg`,`bg-support-container text-on-support-container p-lg`,t),...n,children:e})})}function K({children:e}){return W(),(0,o.jsx)(`span`,{className:`text-body-1-highlight`,children:e})}function q({className:e,children:t,...r}){let{selectedCount:a,onClearSelection:s,hasMultiplePages:c}=W();return c?(0,o.jsx)(n.t,{size:`sm`,design:`ghost`,intent:`support`,underline:!0,ariaDisabled:a===0,onClick:s,className:(0,i.cx)(`text-body-2`,e),...r,children:t}):null}function de({className:e,children:t,...r}){let{selectedCount:a,totalCount:s,onSelectAll:c,hasMultiplePages:l}=W();return l?(0,o.jsx)(n.t,{size:`sm`,design:`ghost`,intent:`support`,underline:!0,ariaDisabled:s==null||c==null||a>=s,onClick:c,className:(0,i.cx)(`text-body-2`,e),...r,children:t}):null}G.displayName=`Table.BulkBar`;var J=G;J.displayName=`Table.BulkBar`,K.displayName=`Table.BulkBarSelectedCount`,q.displayName=`Table.BulkBarClearButton`,de.displayName=`Table.BulkBarSelectAllButton`;function Y(e){return(0,o.jsx)(c.Cell,{...e})}Y.displayName=`Table.Cell`,Y.getCollectionNode=c.Cell.getCollectionNode;function X({label:e,allowsResizing:t=!0,...n}){return null}X.displayName=`Table.Column`,X.getCollectionNode=function*(e,t){let n=e.title??e.label??e.children??null,r=e.textValue||(typeof n==`string`?n:``)||e[`aria-label`],i=yield{type:`column`,key:e.id??null,hasChildNodes:!!e.childColumns||!!e.title&&a.default.Children.count(e.children)>0,rendered:n,textValue:r,props:{...e,title:e.title??e.label,allowsResizing:e.allowsResizing},*childNodes(){if(e.childColumns)for(let t of e.childColumns)yield{type:`column`,value:t};else if(e.title){let t=[];a.default.Children.forEach(e.children,e=>{t.push({type:`column`,element:e})}),yield*t}},shouldInvalidate(e){return o(e),!1}},o=e=>{for(let t of i)t.hasChildNodes||e.columns.push(t)};o(t)};function Z(e){return(0,o.jsx)(c.TableHeader,{...e})}Z.displayName=`Table.Header`,Z.getCollectionNode=c.TableHeader.getCollectionNode;function Q(e){return null}Q.displayName=`Table.Row`,Q.getCollectionNode=function*(e,t){let{children:n,textValue:r,UNSTABLE_childItems:i}=e;yield{type:`item`,key:e.id??null,props:e,textValue:r,"aria-label":e[`aria-label`],hasChildNodes:!0,*childNodes(){if(t.showDragButtons&&(yield{type:`cell`,key:`header-drag`,props:{isDragButtonCell:!0}}),t.showSelectionCheckboxes&&t.selectionMode!==`none`&&(yield{type:`cell`,key:`header`,props:{isSelectionCell:!0}}),typeof n==`function`){for(let e of t.columns)yield{type:`cell`,element:n(e.key),key:e.key};if(i)for(let e of i)yield{type:`item`,value:e}}else{let e=[],r=[],i=0;if(a.default.Children.forEach(n,n=>{if(n)if(n.type===Q){if(e.length<t.columns.length)throw Error(`All of a Row's child Cells must be positioned before any child Rows.`);r.push({type:`item`,element:n})}else e.push({type:`cell`,element:n}),i+=n.props?.colSpan??1}),i!==t.columns.length)throw Error(`Cell count must match column count. Found ${i} cells and ${t.columns.length} columns.`);yield*e,yield*r}},shouldInvalidate(e){return e.columns.length!==t.columns.length||e.columns.some((e,n)=>e.key!==t.columns[n].key)||e.showSelectionCheckboxes!==t.showSelectionCheckboxes||e.showDragButtons!==t.showDragButtons||e.selectionMode!==t.selectionMode}}};function fe(e,t,n,r){let i=e[n],a=t[n];if(i===a)return 0;let o;return o=typeof i==`number`&&typeof a==`number`?i<a?-1:1:String(i).localeCompare(String(a)),r===`descending`?-o:o}function pe(e,t={}){let{initialSort:n,compare:r}=t,[i,o]=(0,a.useState)(()=>n?{column:n.column,direction:n.direction}:{column:`id`,direction:`ascending`});return{sortDescriptor:i,onSortChange:o,setSortDescriptor:o,sortedItems:(0,a.useMemo)(()=>{let t=i.column;if(!t)return[...e];let n=r??fe,a=i.direction??`ascending`;return[...e].sort((e,r)=>n(e,r,t,a))},[e,i.column,i.direction,r])}}function me(e,t){let{pageSize:n,initialPage:r=1,getId:i}=t,[o,s]=(0,a.useState)(r),[c,l]=(0,a.useState)(()=>new Set),u=e.length,d=Math.max(1,Math.ceil(u/n));(0,a.useEffect)(()=>{s(e=>e<1?1:e>d?d:e)},[d]);let f=o;f<1?f=1:f>d&&(f=d);let p=(0,a.useMemo)(()=>{let t=(f-1)*n,r=t+n;return e.slice(t,r)},[e,f,n]),m=(0,a.useMemo)(()=>{let t=i??(e=>{let t=e.id;if(t==null)throw Error("useTablePagination: item.id is undefined. Provide a `getId` option to extract a stable key.");return t});return new Set(e.map(e=>t(e)))},[i,e]),h=(0,a.useMemo)(()=>{let e=i??(e=>{let t=e.id;if(t==null)throw Error("useTablePagination: item.id is undefined. Provide a `getId` option to extract a stable key.");return t});return new Set(p.map(t=>e(t)))},[i,p]);return{page:f,setPage:s,pageItems:p,totalItems:u,totalPages:d,allKeys:m,selectedKeys:c,onSelectionChange:e=>{let t=e===`all`?new Set(h):new Set(e);l(e=>{let n=new Set(t);for(let t of e)h.has(t)||n.add(t);return n})},onPageChange:e=>{s(e.page)},clearSelection:()=>{l(()=>new Set)}}}var $=Object.assign(v,{Grid:V,Header:Z,Column:X,Body:H,Row:Q,Cell:Y,BulkBar:J,BulkBarSelectedCount:K,BulkBarClearButton:q,BulkBarSelectAllButton:de});$.displayName=`Table`,Z.displayName=`Table.Header`,X.displayName=`Table.Column`,H.displayName=`Table.Body`,Q.displayName=`Table.Row`,Y.displayName=`Table.Cell`,exports.Table=$,exports.TableCompound=$,exports.useTablePagination=me,exports.useTableSort=pe;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../chunk-C91j1N6u.js`),t=require(`../icon-CRPcdgYp.js`),n=require(`../button-Tv2N8_24.js`),r=require(`../checkbox-hVGRiWC_.js`);let i=require(`class-variance-authority`),a=require(`react`);a=e.t(a);let o=require(`react/jsx-runtime`),s=require(`@react-aria/utils`),c=require(`@react-stately/table`),l=require(`react-aria`),u=require(`@react-aria/table`),d=require(`@spark-ui/icons/ArrowDown`),f=require(`@spark-ui/icons/ArrowUp`),p=require(`@spark-ui/icons/Sort`);var m=(0,a.createContext)({isResizable:!1,tableWidth:0});function h(){return(0,a.useContext)(m)}var g=(0,a.createContext)({selectedCount:0,onClearSelection:()=>{}});function _(){return(0,a.useContext)(g)}function v({children:e,className:t,selectedKeys:n,onSelectionChange:r,totalCount:a,hasMultiplePages:s,onClearSelection:c,onSelectAll:l,allowsResizing:u=!0,resizeColumnAriaLabel:d,maxHeight:f,stickyHeader:p,onResizeStart:m,onResize:h,onResizeEnd:_,onKeyDownCapture:v,sortDescriptor:y,onSortChange:b,...x}){let S=0;n===`all`?S=a??0:n instanceof Set?S=n.size:n&&(S=new Set(n).size);let C=c??(()=>r?.(new Set));return(0,o.jsx)(g,{value:{...x,selectedKeys:n,onSelectionChange:r,totalCount:a,hasMultiplePages:s,onSelectAll:l,selectedCount:S,onClearSelection:C,allowsResizing:u,resizeColumnAriaLabel:d,maxHeight:f,stickyHeader:p,onResizeStart:m,onResize:h,onResizeEnd:_,onKeyDownCapture:v,sortDescriptor:y,onSortChange:b,className:t},children:(0,o.jsx)(`div`,{className:(0,i.cx)(`gap-md flex flex-col`,t),children:e})})}v.displayName=`Table`;function y({className:e,children:t,...n}){let r=(0,a.useRef)(null),[c,l]=(0,a.useState)(0);return(0,a.useLayoutEffect)(()=>{let e=r.current;e&&l(e.clientWidth)},[]),(0,s.useResizeObserver)({ref:r,onResize:()=>{let e=r.current;e&&l(e.clientWidth)}}),(0,o.jsx)(m,{value:{isResizable:!0,tableWidth:c},children:(0,o.jsx)(`div`,{ref:r,"data-spark-component":`resizable-table-container`,className:(0,i.cx)(`relative w-full overflow-auto`,e),...n,children:t})})}y.displayName=`ResizableTableContainer`;var b=`[data-spark-component="table-cell"]`;function x(e){return!e||!(e instanceof Element)?!1:!!e.closest(`[role="combobox"],select,[data-spark-component="dropdown-trigger"],[data-spark-component="combobox-input"]`)}function S(e){if(!e||!(e instanceof Element))return!1;let t=e.closest(`[role="combobox"],[data-spark-component="dropdown-trigger"],[data-spark-component="combobox-input"]`);return t?t.getAttribute(`aria-expanded`)===`true`:!1}var C=`a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]`;function w(e){return!e||!(e instanceof Element)?null:e.closest(b)}function T(e){return e.getAttribute(`data-table-cell-kind`)===`selection`}function E(e){return Array.from(e.querySelectorAll(C)).filter(t=>!(t===e||t.hasAttribute(`disabled`)||t.getAttribute(`aria-disabled`)===`true`||t.getAttribute(`hidden`)!==null))}function D(e,t){for(let n of E(e)){let e=`data-prev-tabindex`;if(!t)n.hasAttribute(e)||n.setAttribute(e,n.getAttribute(`tabindex`)??``),n.setAttribute(`tabindex`,`-1`);else{let t=n.getAttribute(e);if(t===null)continue;n.removeAttribute(e),t===``?n.removeAttribute(`tabindex`):n.setAttribute(`tabindex`,t)}}}function O(e){let t=Array.from(e.querySelectorAll(b));for(let e of t)D(e,!1)}function ee({ref:e,gridProps:t,onKeyDownCapture:n,onFocusCapture:r}){let[i,o]=(0,a.useState)(`grid`),s=(0,a.useRef)(`grid`),c=(0,a.useRef)(null),u=(0,a.useRef)(!1),d=(0,a.useMemo)(()=>{let{onKeyDown:a,...d}=t,f=e=>{c.current=e,s.current=`interaction`,o(`interaction`),D(e,!0)};return(0,l.mergeProps)(d,{onKeyDown:e=>{if(s.current===`interaction`&&(e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`||e.key===`ArrowDown`)){let e=c.current,t=document.activeElement;if(e&&t instanceof Node&&e.contains(t))return}s.current===`interaction`&&(e.key===`ArrowUp`||e.key===`ArrowDown`)&&x(e.target)&&w(e.target)===c.current||a?.(e)},onKeyDownCapture:e=>{if(n?.(e),s.current===`interaction`&&e.key===`Tab`){let t=w(e.target);t&&t===c.current&&e.stopPropagation();return}if(x(e.target)&&s.current===`interaction`&&(e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`||e.key===`ArrowDown`)){let t=w(e.target);if(t&&t===c.current)return}if(s.current===`interaction`&&(e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`||e.key===`ArrowDown`)){let t=w(e.target);if(t&&t===c.current){e.stopPropagation();return}}if(s.current===`grid`&&e.key===`ArrowRight`){let t=w(e.target);if(t){let n=t.closest(`tr`);if(n){let r=Array.from(n.querySelectorAll(b));if(r.length>0&&r[r.length-1]===t){e.preventDefault(),e.stopPropagation(),n.focus();return}}}}if(s.current===`grid`&&e.key===`Enter`){let t=w(e.target);if(!t||T(t))return;let n=E(t);if(n.length===0)return;e.preventDefault(),e.stopPropagation(),f(t),n[0]?.focus();return}if(s.current===`grid`&&e.key===`F2`){let t=w(e.target);if(!t||T(t))return;let n=E(t);if(n.length===0)return;e.preventDefault(),e.stopPropagation(),f(t),n[0]?.focus();return}if(s.current===`interaction`&&e.key===`Escape`){if(S(e.target))return;let t=c.current;if(!t)return;e.preventDefault(),e.stopPropagation(),s.current=`grid`,o(`grid`),t.focus()}if(s.current===`interaction`&&e.key===`F2`){let t=c.current;if(!t)return;e.preventDefault(),e.stopPropagation(),s.current=`grid`,o(`grid`),t.focus()}},onBlurCapture:t=>{if(s.current!==`interaction`)return;let n=e.current;if(!n)return;let r=t.relatedTarget;r instanceof Node&&n.contains(r)||(c.current=null,s.current=`grid`,o(`grid`))},onFocusCapture:t=>{r?.(t);let n=u.current;u.current=!1;let i=e.current,a=w(t.target);if(s.current===`interaction`&&c.current&&i){let e=!!(a&&a!==c.current),n=!a&&t.target instanceof Element&&i.contains(t.target)&&!c.current.contains(t.target);(e||n)&&(s.current=`grid`,o(`grid`),n&&(c.current=null))}if(!a)return;c.current=a;let l=t.target instanceof Element?t.target:null,d=a.matches(b),p=s.current===`grid`,m=!!(l&&l!==a&&a.contains(l)),h=E(a).length>0;p&&d&&m&&h&&!n&&queueMicrotask(()=>a.focus()),n&&p&&m&&d&&h&&!T(a)&&f(a)},onPointerDownCapture:e=>{let t=w(e.target);t?.matches(b)&&e.target instanceof Element&&e.target!==t&&t.contains(e.target)&&(u.current=!0)},"data-table-keyboard-mode":i})},[t,i,e,r,n]);return(0,a.useEffect)(()=>{s.current=i;let t=e.current;if(t){if(i===`grid`){O(t),c.current?.focus?.();return}O(t),c.current&&D(c.current,!0)}},[i,e]),{gridProps:d,keyboardMode:i}}var k=(0,i.cva)([`h-sz-64 min-w-sz-64`,`relative group/column first:rounded-l-xl last:rounded-r-xl bg-neutral-container`,`pl-lg pr-lg py-sm text-left outline-none box-border`,`cursor-default`,`data-focus-visible:u-outline data-focus-visible:-outline-offset-2`],{variants:{checkbox:{true:[`w-sz-64 min-w-sz-64 max-w-sz-64`,`px-0 align-middle`]},resizable:{true:[`pr-xl`]}},defaultVariants:{checkbox:!1,resizable:!1}}),te=(0,i.cva)([`flex flex-1 justify-between items-center gap-md`,`font-inherit text-left text-inherit`,`whitespace-nowrap text-ellipsis`,`border-transparent`,`data-focus-visible:u-outline data-focus-visible:outline-offset-2`],{variants:{},defaultVariants:{}});(0,i.cva)([`empty:italic empty:text-center empty:text-body-2 empty:py-lg`],{variants:{},defaultVariants:{}});var ne=(0,i.cva)([`p-lg outline-none box-border default:overflow-hidden`,`border-b-sm border-outline [tr:last-child>&]:border-b-0`,`[-webkit-tap-highlight-color:transparent]`,`data-focus-visible:u-outline-inset data-focus-visible:outline-dashed`],{variants:{checkbox:{true:[`w-sz-64 py-sm px-0 align-middle`]}},defaultVariants:{checkbox:!1}}),re=(0,i.cva)([`pointer-events-none`,`[&_td]:h-sz-16 [&_td]:p-0 [&_td]:border-0 [&_td]:border-b-0 [&_td]:bg-surface [&_td]:align-middle`],{variants:{},defaultVariants:{}}),ie=`button, [role="button"], [role="switch"], [role="checkbox"], [role="option"], input:not([type="hidden"]), select, textarea, [href], [data-spark-component="dropdown-trigger"], [data-spark-component="icon-button"], [data-spark-component="switch"], [data-spark-component="switch-input"], [data-spark-component="combobox-input"]`,ae=`a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]`;function oe(e){if(!e||!(e instanceof Element))return!1;let t=e;return t.matches(ie)||t.closest(ie)!==null}function se(e){return e?e instanceof Element?e:e instanceof Text?e.parentElement:null:null}function ce(e){for(let t of e.querySelectorAll(ae))if(t!==e&&!t.hasAttribute(`disabled`)&&t.getAttribute(`aria-disabled`)!==`true`&&t.getAttribute(`hidden`)===null)return!0;return!1}function le(e){let t=se(e);if(!t)return!1;if(oe(t))return!0;let n=t.closest(`[data-spark-component="table-cell"]`);return!n||n.getAttribute(`data-table-cell-kind`)===`selection`?!1:ce(n)}var A=(0,a.createContext)(`grid`);function j({checkboxProps:e,className:t,suppressFocusWalker:n}){let{isSelected:i,isIndeterminate:a,isDisabled:s,onChange:c,...l}=e,u=a===!0?`indeterminate`:!!i;return(0,o.jsx)(`span`,{...n?{"data-react-aria-prevent-focus":!0}:void 0,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),className:t??`flex h-full min-h-full items-center justify-center`,children:(0,o.jsx)(r.n,{checked:u,disabled:s,onCheckedChange:c,...l})})}j.displayName=`Table.SelectionCheckbox`;function M({cell:e,state:t,resizeState:n}){let r=(0,a.useRef)(null),{gridCellProps:i}=(0,l.useTableCell)({node:e},t,r),{isFocusVisible:s,focusProps:c}=(0,l.useFocusRing)(),d=(0,a.useContext)(A),f=(0,a.useCallback)(e=>{d===`interaction`&&(e.key!==` `&&e.key!==`Enter`||e.stopPropagation())},[d]),{onKeyDownCapture:p,...m}=i,h=(0,a.useCallback)(e=>{[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].includes(e.key)||p?.(e)},[p]),g=(0,u.useTableSelectionCheckbox)({key:e.parentKey??e.key},t),_=t.collection.columns[e.index??0]?.key??null,v=_?n?.columnWidths?.get?.(_):void 0;return e.props?.isSelectionCell?(0,o.jsx)(`td`,{...(0,l.mergeProps)(m,{onKeyDownCapture:h},c,{onKeyDown:f}),ref:r,"data-spark-component":`table-cell`,"data-table-cell-kind":`selection`,className:ne({checkbox:!0}),"data-focus-visible":s||void 0,children:(0,o.jsx)(j,{suppressFocusWalker:d===`grid`,checkboxProps:g.checkboxProps})}):(0,o.jsx)(`td`,{...(0,l.mergeProps)(m,{onKeyDownCapture:h},c,{onKeyDown:f}),ref:r,"data-spark-component":`table-cell`,className:ne(),"data-focus-visible":s||void 0,style:v?{width:v}:void 0,children:e.rendered})}M.displayName=`Table.BodyCellRenderer`;function N(e){if(e)return t=>{le((0,s.getEventTarget)(t.nativeEvent))||e(t)}}function P({item:e,state:t,resizeState:n}){let r=(0,a.useRef)(null),{rowProps:s,isSelected:c}=(0,l.useTableRow)({node:e},t,r),{isFocusVisible:u,focusProps:d}=(0,l.useFocusRing)(),{onClick:f,onPointerDown:p,onMouseDown:m,onPointerUp:h,onPointerCancel:g,..._}=s,v=(0,i.cx)(`outline-none box-border data-focus-visible:u-outline-inset data-focus-visible:outline-dashed`,_.className,c&&`bg-support-container text-on-support-container`);return(0,o.jsx)(`tr`,{...(0,l.mergeProps)(_,d),onPointerDown:N(p),onMouseDown:N(m),onPointerUp:N(h),onPointerCancel:N(g),onClick:N(f),ref:r,"data-spark-component":`table-row`,"data-selected":c||void 0,"data-focus-visible":u||void 0,className:v,tabIndex:-1,children:[...e.childNodes].map(e=>(0,o.jsx)(M,{cell:e,state:t,resizeState:n},e.key))})}P.displayName=`Table.BodyRowRenderer`;function F({column:e,ariaLabel:t,resizeState:n,resizeCallbacks:r}){let s=(0,a.useRef)(null),{resizerProps:c,inputProps:l,isResizing:d}=(0,u.useTableColumnResize)({column:e,"aria-label":t??`Resize column`,onResizeStart:r.onResizeStart,onResize:r.onResize,onResizeEnd:r.onResizeEnd},n,s);return(0,o.jsx)(`div`,{role:`presentation`,className:(0,i.cx)(`cursor-col-resize absolute inset-y-lg right-0 flex w-lg items-center justify-center`,`after:block after:h-full after:w-[2px] after:bg-outline after:transition-all after:duration-75`,`has-[input:focus-visible]:after:u-outline has-[input:focus-visible]:after:outline-offset-2`,d&&`after:bg-outline-high after:scale-120`),"data-resizable-direction":`both`,...c,children:(0,o.jsx)(`input`,{ref:s,disabled:!d,...l})})}F.displayName=`Table.ColumnResizer`;function I({state:e}){let{checkboxProps:t}=(0,u.useTableSelectAllCheckbox)(e),{collection:n,selectionManager:r}=e,i=r.selectedKeys,a=n,s=a.body,c=s==null?new Set(n.getKeys()):new Set([...a.getChildren(s.key)].map(e=>e.key)),l=i===`all`?c:i,d=[...c].filter(e=>l.has(e)).length,f=c.size,p=f>0&&d===f,m=d>0&&d<f,{isSelected:h,isIndeterminate:g,onChange:_,...v}=t,y=e=>{(e.key===` `||e.key===`Enter`)&&e.stopPropagation(),e.key===`Enter`&&(e.preventDefault(),t.isDisabled||_?.(!p))};return(0,o.jsx)(j,{checkboxProps:{...v,isSelected:p,isIndeterminate:m,onChange:_,onKeyDown:y}})}I.displayName=`Table.HeaderSelectionCheckbox`;var L=(0,i.cx)(`sticky top-0 z-sticky`);function R({column:e,state:n,resizeState:r,stickyHeader:s,resizeCallbacks:c,isLastColumnInRow:u=!1}){let m=(0,a.useRef)(null),{resizeColumnAriaLabel:h}=_(),{columnHeaderProps:g}=(0,l.useTableColumnHeader)({node:e},n,m),{isFocusVisible:v,focusProps:y}=(0,l.useFocusRing)(),b=e.props?.allowsResizing!==!1&&!u,x=r?.columnWidths?.get?.(e.key),S=!!(r&&b);if(e.props?.isSelectionCell)return(0,o.jsx)(`th`,{...g,ref:m,role:`columnheader`,className:(0,i.cx)(k({checkbox:!0}),s&&L),"data-spark-component":`table-column`,"data-table-selection-columnheader":!0,"data-focus-visible":v||void 0,children:(0,o.jsx)(I,{state:n})});let C=!!e.props?.allowsSorting,w=n.sortDescriptor?.column===e.key,T=n.sortDescriptor?.direction??`ascending`,E=w?T===`descending`?(0,o.jsx)(d.ArrowDown,{}):(0,o.jsx)(f.ArrowUp,{}):(0,o.jsx)(p.Sort,{}),D=t=>{C&&(t.key!==`Enter`&&t.key!==` `||(t.preventDefault(),t.stopPropagation(),n.sort?.(e.key)))};return(0,o.jsxs)(`th`,{...(0,l.mergeProps)(g,y),ref:m,role:`columnheader`,className:(0,i.cx)(k({resizable:S}),s&&L),style:x?{width:x}:void 0,"data-spark-component":`table-column`,"data-focus-visible":v||void 0,onKeyDown:D,children:[(0,o.jsxs)(`div`,{className:te(),children:[(0,o.jsx)(`button`,{type:`button`,className:(0,i.cx)(`gap-md flex min-w-0 flex-1 items-center text-left`,`focus-visible:u-outline outline-none`,`bg-transparent p-0 border-0`),onKeyDown:D,children:(0,o.jsx)(`span`,{className:`min-w-0 overflow-hidden text-ellipsis whitespace-nowrap`,children:e.rendered})}),C?(0,o.jsx)(`span`,{"aria-hidden":`true`,className:(0,i.cx)(`shrink-0 opacity-dim-2 group-hover/column:opacity-100`,w&&`opacity-100`),children:(0,o.jsx)(t.t,{size:`sm`,children:E})}):null]}),r&&b?(0,o.jsx)(F,{column:e,ariaLabel:typeof h==`function`?h(e):h,resizeState:r,resizeCallbacks:c}):null]})}R.displayName=`Table.ColumnHeader`;function z({item:e,state:t,resizeState:n,stickyHeader:r,resizeCallbacks:i}){let s=(0,a.useRef)(null),{rowProps:c}=(0,l.useTableHeaderRow)({node:e},t,s),u=[...e.childNodes];return(0,o.jsx)(`tr`,{...c,ref:s,children:u.map((e,a)=>(0,o.jsx)(R,{column:e,state:t,resizeState:n,stickyHeader:r,resizeCallbacks:i,isLastColumnInRow:a===u.length-1},e.key))})}z.displayName=`Table.HeaderRowRenderer`;function B({className:e,children:t,stickyHeader:n,...r}){let u=!!n,d=(0,a.useRef)(null),f=h(),p=r.selectionMode===`multiple`,m=(0,c.useTableState)({...r,showSelectionCheckboxes:r.selectionMode===`multiple`,children:t}),g=(0,c.useTableColumnResizeState)({tableWidth:f.tableWidth},m),_=f.isResizable&&r.allowsResizing!==!1?g:null,{gridProps:v}=(0,l.useTable)({...r},m,d),y=m.collection.headerRows,b=[...m.collection.body.childNodes],x=m.collection.body.props?.renderEmptyState,S=m.collection.columns.length||1,C=b.length>0||!!x,{rowGroupProps:w}=(0,l.useTableRowGroup)(),{rowGroupProps:T}=(0,l.useTableRowGroup)(),{gridProps:E,keyboardMode:D}=ee({ref:d,gridProps:v,onKeyDownCapture:r.onKeyDownCapture,onFocusCapture:r.onFocusCapture});return(0,o.jsx)(A,{value:D,children:(0,o.jsxs)(`table`,{...(0,l.mergeProps)(E,(0,s.filterDOMProps)(r,{global:!0})),ref:d,"data-spark-component":`table`,className:(0,i.cx)(`default:w-full`,p?`table-fixed`:void 0,`border-separate border-spacing-y-0`,`bg-surface`,`outline-none`,`text-body-1`,`forced-color-adjust-none`,`data-focus-visible:u-outline-inset`,`has-[>[data-empty]]:h-full`,e),children:[(0,o.jsx)(`thead`,{...w,"data-spark-component":`table-header`,children:y.map(e=>(0,o.jsx)(z,{item:e,state:m,resizeState:_,stickyHeader:u,resizeCallbacks:{onResizeStart:r.onResizeStart,onResize:r.onResize,onResizeEnd:r.onResizeEnd}},e.key))}),(0,o.jsxs)(`tbody`,{...T,"data-spark-component":`table-body`,children:[C?(0,o.jsx)(`tr`,{"aria-hidden":`true`,className:re(),role:`presentation`,"data-spark-component":`table-body-spacer`,children:(0,o.jsx)(`td`,{colSpan:S,role:`presentation`})}):null,b.length===0&&x?(0,o.jsx)(`tr`,{"data-empty":!0,children:(0,o.jsx)(`td`,{colSpan:S,children:x({isEmpty:!0})})}):null,b.map(e=>(0,o.jsx)(P,{item:e,state:m,resizeState:_},e.key))]})]})})}B.displayName=`Table.Grid.Inner`;function ue(e){return typeof e==`number`?`${e}px`:e}function V({"aria-label":e,"aria-labelledby":t,className:n,children:r}){let{allowsResizing:i=!0,maxHeight:a,stickyHeader:s,onResizeStart:c,onResize:l,onResizeEnd:u,onKeyDownCapture:d,sortDescriptor:f,onSortChange:p,className:m,...h}=_(),g=a==null?void 0:{maxHeight:ue(a)},v=n??m,b={...h,...e!=null&&{"aria-label":e},...t!=null&&{"aria-labelledby":t},sortDescriptor:f,onSortChange:p,onKeyDownCapture:d,className:v,stickyHeader:s},x=B;return i?(0,o.jsx)(y,{className:v,style:g,onResizeStart:c,onResize:l,onResizeEnd:u,children:(0,o.jsx)(x,{...b,children:r})}):(0,o.jsx)(`div`,{className:`relative w-full overflow-auto`,style:g,children:(0,o.jsx)(x,{...b,children:r})})}V.displayName=`Table.Grid`;function H(e){return(0,o.jsx)(c.TableBody,{...e})}H.displayName=`Table.Body`,H.getCollectionNode=c.TableBody.getCollectionNode;var U=(0,a.createContext)(null);function W(){let e=(0,a.useContext)(U);if(!e)throw Error(`Table.BulkBar subcomponents must be used within Table.BulkBar`);return e}function G({children:e,className:t,rootProps:n,...r}){let{selectedCount:a,totalCount:s,onClearSelection:c,onSelectAll:l,hasMultiplePages:u}=_();return(0,o.jsx)(U,{value:{selectedCount:a,totalCount:s,onClearSelection:c,onSelectAll:l,hasMultiplePages:u},children:(0,o.jsx)(`div`,{role:`toolbar`,"aria-label":r[`aria-label`]??`Table bulk actions`,"data-spark-component":`table-bulk-bar`,className:(0,i.cx)(`gap-lg min-h-sz-64 flex w-full flex-wrap items-center justify-between`,`rounded-lg`,`bg-support-container text-on-support-container p-lg`,t),...n,children:e})})}function K({children:e}){return W(),(0,o.jsx)(`span`,{className:`text-body-1-highlight`,children:e})}function q({className:e,children:t,...r}){let{selectedCount:a,onClearSelection:s,hasMultiplePages:c}=W();return c?(0,o.jsx)(n.t,{size:`sm`,design:`ghost`,intent:`support`,underline:!0,ariaDisabled:a===0,onClick:s,className:(0,i.cx)(`text-body-2`,e),...r,children:t}):null}function de({className:e,children:t,...r}){let{selectedCount:a,totalCount:s,onSelectAll:c,hasMultiplePages:l}=W();return l?(0,o.jsx)(n.t,{size:`sm`,design:`ghost`,intent:`support`,underline:!0,ariaDisabled:s==null||c==null||a>=s,onClick:c,className:(0,i.cx)(`text-body-2`,e),...r,children:t}):null}G.displayName=`Table.BulkBar`;var J=G;J.displayName=`Table.BulkBar`,K.displayName=`Table.BulkBarSelectedCount`,q.displayName=`Table.BulkBarClearButton`,de.displayName=`Table.BulkBarSelectAllButton`;function Y(e){return(0,o.jsx)(c.Cell,{...e})}Y.displayName=`Table.Cell`,Y.getCollectionNode=c.Cell.getCollectionNode;function X({label:e,allowsResizing:t=!0,...n}){return null}X.displayName=`Table.Column`,X.getCollectionNode=function*(e,t){let n=e.title??e.label??e.children??null,r=e.textValue||(typeof n==`string`?n:``)||e[`aria-label`],i=yield{type:`column`,key:e.id??null,hasChildNodes:!!e.childColumns||!!e.title&&a.default.Children.count(e.children)>0,rendered:n,textValue:r,props:{...e,title:e.title??e.label,allowsResizing:e.allowsResizing},*childNodes(){if(e.childColumns)for(let t of e.childColumns)yield{type:`column`,value:t};else if(e.title){let t=[];a.default.Children.forEach(e.children,e=>{t.push({type:`column`,element:e})}),yield*t}},shouldInvalidate(e){return o(e),!1}},o=e=>{for(let t of i)t.hasChildNodes||e.columns.push(t)};o(t)};function Z(e){return(0,o.jsx)(c.TableHeader,{...e})}Z.displayName=`Table.Header`,Z.getCollectionNode=c.TableHeader.getCollectionNode;function Q(e){return null}Q.displayName=`Table.Row`,Q.getCollectionNode=function*(e,t){let{children:n,textValue:r,UNSTABLE_childItems:i}=e;yield{type:`item`,key:e.id??null,props:e,textValue:r,"aria-label":e[`aria-label`],hasChildNodes:!0,*childNodes(){if(t.showDragButtons&&(yield{type:`cell`,key:`header-drag`,props:{isDragButtonCell:!0}}),t.showSelectionCheckboxes&&t.selectionMode!==`none`&&(yield{type:`cell`,key:`header`,props:{isSelectionCell:!0}}),typeof n==`function`){for(let e of t.columns)yield{type:`cell`,element:n(e.key),key:e.key};if(i)for(let e of i)yield{type:`item`,value:e}}else{let e=[],r=[],i=0;if(a.default.Children.forEach(n,n=>{if(n)if(n.type===Q){if(e.length<t.columns.length)throw Error(`All of a Row's child Cells must be positioned before any child Rows.`);r.push({type:`item`,element:n})}else e.push({type:`cell`,element:n}),i+=n.props?.colSpan??1}),i!==t.columns.length)throw Error(`Cell count must match column count. Found ${i} cells and ${t.columns.length} columns.`);yield*e,yield*r}},shouldInvalidate(e){return e.columns.length!==t.columns.length||e.columns.some((e,n)=>e.key!==t.columns[n].key)||e.showSelectionCheckboxes!==t.showSelectionCheckboxes||e.showDragButtons!==t.showDragButtons||e.selectionMode!==t.selectionMode}}};function fe(e,t,n,r){let i=e[n],a=t[n];if(i===a)return 0;let o;return o=typeof i==`number`&&typeof a==`number`?i<a?-1:1:String(i).localeCompare(String(a)),r===`descending`?-o:o}function pe(e,t={}){let{initialSort:n,compare:r}=t,[i,o]=(0,a.useState)(()=>n?{column:n.column,direction:n.direction}:{column:`id`,direction:`ascending`});return{sortDescriptor:i,onSortChange:o,setSortDescriptor:o,sortedItems:(0,a.useMemo)(()=>{let t=i.column;if(!t)return[...e];let n=r??fe,a=i.direction??`ascending`;return[...e].sort((e,r)=>n(e,r,t,a))},[e,i.column,i.direction,r])}}function me(e,t){let{pageSize:n,initialPage:r=1,getId:i}=t,[o,s]=(0,a.useState)(r),[c,l]=(0,a.useState)(()=>new Set),u=e.length,d=Math.max(1,Math.ceil(u/n));(0,a.useEffect)(()=>{s(e=>e<1?1:e>d?d:e)},[d]);let f=o;f<1?f=1:f>d&&(f=d);let p=(0,a.useMemo)(()=>{let t=(f-1)*n,r=t+n;return e.slice(t,r)},[e,f,n]),m=(0,a.useMemo)(()=>{let t=i??(e=>{let t=e.id;if(t==null)throw Error("useTablePagination: item.id is undefined. Provide a `getId` option to extract a stable key.");return t});return new Set(e.map(e=>t(e)))},[i,e]),h=(0,a.useMemo)(()=>{let e=i??(e=>{let t=e.id;if(t==null)throw Error("useTablePagination: item.id is undefined. Provide a `getId` option to extract a stable key.");return t});return new Set(p.map(t=>e(t)))},[i,p]);return{page:f,setPage:s,pageItems:p,totalItems:u,totalPages:d,allKeys:m,selectedKeys:c,onSelectionChange:e=>{let t=e===`all`?new Set(h):new Set(e);l(e=>{let n=new Set(t);for(let t of e)h.has(t)||n.add(t);return n})},onPageChange:e=>{s(e.page)},clearSelection:()=>{l(()=>new Set)}}}var $=Object.assign(v,{Grid:V,Header:Z,Column:X,Body:H,Row:Q,Cell:Y,BulkBar:J,BulkBarSelectedCount:K,BulkBarClearButton:q,BulkBarSelectAllButton:de});$.displayName=`Table`,Z.displayName=`Table.Header`,X.displayName=`Table.Column`,H.displayName=`Table.Body`,Q.displayName=`Table.Row`,Y.displayName=`Table.Cell`,exports.Table=$,exports.TableCompound=$,exports.useTablePagination=me,exports.useTableSort=pe;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|