@mitcsutt/kiln-ui 0.2.1 → 0.2.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/components/actions/Button/Button.d.ts +8 -0
- package/dist/components/actions/Button/Button.js.map +1 -1
- package/dist/components/actions/ChipGroup/ChipGroup.d.ts +9 -0
- package/dist/components/actions/ChipGroup/ChipGroup.js.map +1 -1
- package/dist/components/actions/IconButton/IconButton.d.ts +8 -0
- package/dist/components/actions/IconButton/IconButton.js.map +1 -1
- package/dist/components/actions/ModeToggle/ModeToggle.d.ts +8 -0
- package/dist/components/actions/ModeToggle/ModeToggle.js.map +1 -1
- package/dist/components/actions/SegmentedControl/SegmentedControl.d.ts +9 -0
- package/dist/components/actions/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/components/actions/ToggleChip/ToggleChip.d.ts +9 -0
- package/dist/components/actions/ToggleChip/ToggleChip.js.map +1 -1
- package/dist/components/display/Avatar/Avatar.d.ts +10 -0
- package/dist/components/display/Avatar/Avatar.js.map +1 -1
- package/dist/components/display/AvatarGroup/AvatarGroup.d.ts +7 -0
- package/dist/components/display/AvatarGroup/AvatarGroup.js.map +1 -1
- package/dist/components/display/Badge/Badge.d.ts +7 -0
- package/dist/components/display/Badge/Badge.js.map +1 -1
- package/dist/components/display/Card/Card.js.map +1 -1
- package/dist/components/display/CodeBlock/CodeBlock.d.ts +9 -0
- package/dist/components/display/CodeBlock/CodeBlock.js.map +1 -1
- package/dist/components/display/DataList/DataList.js.map +1 -1
- package/dist/components/display/Delta/Delta.d.ts +9 -0
- package/dist/components/display/Delta/Delta.js.map +1 -1
- package/dist/components/display/EmptyState/EmptyState.d.ts +8 -0
- package/dist/components/display/EmptyState/EmptyState.js.map +1 -1
- package/dist/components/display/List/List.js.map +1 -1
- package/dist/components/display/Marquee/Marquee.d.ts +8 -0
- package/dist/components/display/Marquee/Marquee.js.map +1 -1
- package/dist/components/display/Media/Media.d.ts +7 -0
- package/dist/components/display/Media/Media.js.map +1 -1
- package/dist/components/display/Meter/Meter.d.ts +9 -0
- package/dist/components/display/Meter/Meter.js.map +1 -1
- package/dist/components/display/Progress/Progress.d.ts +8 -0
- package/dist/components/display/Progress/Progress.js.map +1 -1
- package/dist/components/display/Skeleton/Skeleton.js.map +1 -1
- package/dist/components/display/Stamp/Stamp.d.ts +8 -0
- package/dist/components/display/Stamp/Stamp.js.map +1 -1
- package/dist/components/display/Stat/Stat.d.ts +8 -0
- package/dist/components/display/Stat/Stat.js.map +1 -1
- package/dist/components/display/Table/Table.js.map +1 -1
- package/dist/components/display/Tag/Tag.d.ts +7 -0
- package/dist/components/display/Tag/Tag.js.map +1 -1
- package/dist/components/feedback/Alert/Alert.d.ts +10 -0
- package/dist/components/feedback/Alert/Alert.js.map +1 -1
- package/dist/components/feedback/LiveIndicator/LiveIndicator.d.ts +7 -0
- package/dist/components/feedback/LiveIndicator/LiveIndicator.js.map +1 -1
- package/dist/components/feedback/RelativeTime/RelativeTime.d.ts +8 -0
- package/dist/components/feedback/RelativeTime/RelativeTime.js.map +1 -1
- package/dist/components/feedback/Spinner/Spinner.d.ts +10 -1
- package/dist/components/feedback/Spinner/Spinner.js.map +1 -1
- package/dist/components/feedback/StatusDot/StatusDot.d.ts +10 -1
- package/dist/components/feedback/StatusDot/StatusDot.js.map +1 -1
- package/dist/components/inputs/AmountField/AmountField.d.ts +7 -0
- package/dist/components/inputs/AmountField/AmountField.js.map +1 -1
- package/dist/components/inputs/AmountInput/AmountInput.d.ts +8 -0
- package/dist/components/inputs/AmountInput/AmountInput.js.map +1 -1
- package/dist/components/inputs/Checkbox/Checkbox.d.ts +8 -0
- package/dist/components/inputs/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/inputs/CheckboxField/CheckboxField.d.ts +7 -0
- package/dist/components/inputs/CheckboxField/CheckboxField.js.map +1 -1
- package/dist/components/inputs/CheckboxGroup/CheckboxGroup.d.ts +8 -0
- package/dist/components/inputs/CheckboxGroup/CheckboxGroup.js.map +1 -1
- package/dist/components/inputs/CheckboxGroupField/CheckboxGroupField.d.ts +7 -0
- package/dist/components/inputs/CheckboxGroupField/CheckboxGroupField.js.map +1 -1
- package/dist/components/inputs/ChipGroupField/ChipGroupField.d.ts +7 -0
- package/dist/components/inputs/ChipGroupField/ChipGroupField.js.map +1 -1
- package/dist/components/inputs/ChoiceCards/ChoiceCards.d.ts +9 -0
- package/dist/components/inputs/ChoiceCards/ChoiceCards.js.map +1 -1
- package/dist/components/inputs/ChoiceCardsField/ChoiceCardsField.d.ts +7 -0
- package/dist/components/inputs/ChoiceCardsField/ChoiceCardsField.js.map +1 -1
- package/dist/components/inputs/ColorField/ColorField.d.ts +6 -0
- package/dist/components/inputs/ColorField/ColorField.js.map +1 -1
- package/dist/components/inputs/ColorInput/ColorInput.d.ts +8 -0
- package/dist/components/inputs/ColorInput/ColorInput.js.map +1 -1
- package/dist/components/inputs/Combobox/Combobox.d.ts +9 -0
- package/dist/components/inputs/Combobox/Combobox.js.map +1 -1
- package/dist/components/inputs/ComboboxField/ComboboxField.d.ts +7 -0
- package/dist/components/inputs/ComboboxField/ComboboxField.js.map +1 -1
- package/dist/components/inputs/DateRangeField/DateRangeField.d.ts +7 -0
- package/dist/components/inputs/DateRangeField/DateRangeField.js.map +1 -1
- package/dist/components/inputs/Field/Field.d.ts +26 -0
- package/dist/components/inputs/Field/Field.js.map +1 -1
- package/dist/components/inputs/Fieldset/Fieldset.d.ts +8 -0
- package/dist/components/inputs/Fieldset/Fieldset.js.map +1 -1
- package/dist/components/inputs/FileDrop/FileDrop.d.ts +10 -0
- package/dist/components/inputs/FileDrop/FileDrop.js.map +1 -1
- package/dist/components/inputs/FileField/FileField.d.ts +7 -0
- package/dist/components/inputs/FileField/FileField.js.map +1 -1
- package/dist/components/inputs/Input/Input.d.ts +9 -0
- package/dist/components/inputs/Input/Input.js.map +1 -1
- package/dist/components/inputs/NumberField/NumberField.d.ts +7 -0
- package/dist/components/inputs/NumberField/NumberField.js.map +1 -1
- package/dist/components/inputs/NumberInput/NumberInput.d.ts +8 -0
- package/dist/components/inputs/NumberInput/NumberInput.js.map +1 -1
- package/dist/components/inputs/OneTimeCodeField/OneTimeCodeField.d.ts +7 -0
- package/dist/components/inputs/OneTimeCodeField/OneTimeCodeField.js.map +1 -1
- package/dist/components/inputs/OneTimeCodeInput/OneTimeCodeInput.d.ts +8 -0
- package/dist/components/inputs/OneTimeCodeInput/OneTimeCodeInput.js.map +1 -1
- package/dist/components/inputs/PasswordField/PasswordField.d.ts +7 -0
- package/dist/components/inputs/PasswordField/PasswordField.js.map +1 -1
- package/dist/components/inputs/PasswordInput/PasswordInput.d.ts +10 -0
- package/dist/components/inputs/PasswordInput/PasswordInput.js.map +1 -1
- package/dist/components/inputs/RadioGroup/RadioGroup.d.ts +9 -0
- package/dist/components/inputs/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/components/inputs/RadioGroupField/RadioGroupField.d.ts +8 -0
- package/dist/components/inputs/RadioGroupField/RadioGroupField.js.map +1 -1
- package/dist/components/inputs/RangeSlider/RangeSlider.d.ts +8 -0
- package/dist/components/inputs/RangeSlider/RangeSlider.js.map +1 -1
- package/dist/components/inputs/RangeSliderField/RangeSliderField.d.ts +7 -0
- package/dist/components/inputs/RangeSliderField/RangeSliderField.js.map +1 -1
- package/dist/components/inputs/Rating/Rating.d.ts +8 -0
- package/dist/components/inputs/Rating/Rating.js.map +1 -1
- package/dist/components/inputs/RatingField/RatingField.d.ts +7 -0
- package/dist/components/inputs/RatingField/RatingField.js.map +1 -1
- package/dist/components/inputs/SegmentedField/SegmentedField.d.ts +7 -0
- package/dist/components/inputs/SegmentedField/SegmentedField.js.map +1 -1
- package/dist/components/inputs/Select/Select.d.ts +9 -0
- package/dist/components/inputs/Select/Select.js.map +1 -1
- package/dist/components/inputs/SelectField/SelectField.d.ts +7 -0
- package/dist/components/inputs/SelectField/SelectField.js.map +1 -1
- package/dist/components/inputs/Slider/Slider.d.ts +8 -0
- package/dist/components/inputs/Slider/Slider.js.map +1 -1
- package/dist/components/inputs/SliderField/SliderField.d.ts +7 -0
- package/dist/components/inputs/SliderField/SliderField.js.map +1 -1
- package/dist/components/inputs/Switch/Switch.d.ts +8 -0
- package/dist/components/inputs/Switch/Switch.js.map +1 -1
- package/dist/components/inputs/SwitchField/SwitchField.d.ts +8 -0
- package/dist/components/inputs/SwitchField/SwitchField.js.map +1 -1
- package/dist/components/inputs/TagsField/TagsField.d.ts +6 -0
- package/dist/components/inputs/TagsField/TagsField.js.map +1 -1
- package/dist/components/inputs/TagsInput/TagsInput.d.ts +8 -0
- package/dist/components/inputs/TagsInput/TagsInput.js.map +1 -1
- package/dist/components/inputs/TextField/TextField.d.ts +8 -0
- package/dist/components/inputs/TextField/TextField.js.map +1 -1
- package/dist/components/inputs/Textarea/Textarea.d.ts +8 -0
- package/dist/components/inputs/Textarea/Textarea.js.map +1 -1
- package/dist/components/inputs/TextareaField/TextareaField.d.ts +7 -0
- package/dist/components/inputs/TextareaField/TextareaField.js.map +1 -1
- package/dist/components/layout/ActionBar/ActionBar.d.ts +7 -0
- package/dist/components/layout/ActionBar/ActionBar.js.map +1 -1
- package/dist/components/layout/AppShell/AppShell.js.map +1 -1
- package/dist/components/layout/AspectRatio/AspectRatio.d.ts +8 -0
- package/dist/components/layout/AspectRatio/AspectRatio.js.map +1 -1
- package/dist/components/layout/Box/Box.d.ts +8 -0
- package/dist/components/layout/Box/Box.js.map +1 -1
- package/dist/components/layout/Container/Container.d.ts +17 -0
- package/dist/components/layout/Container/Container.js.map +1 -1
- package/dist/components/layout/Divider/Divider.d.ts +7 -0
- package/dist/components/layout/Divider/Divider.js.map +1 -1
- package/dist/components/layout/Grid/Grid.d.ts +9 -0
- package/dist/components/layout/Grid/Grid.js.map +1 -1
- package/dist/components/layout/Inline/Inline.d.ts +8 -0
- package/dist/components/layout/Inline/Inline.js.map +1 -1
- package/dist/components/layout/Section/Section.d.ts +15 -0
- package/dist/components/layout/Section/Section.js.map +1 -1
- package/dist/components/layout/Split/Split.d.ts +9 -0
- package/dist/components/layout/Split/Split.js.map +1 -1
- package/dist/components/layout/Stack/Stack.d.ts +12 -0
- package/dist/components/layout/Stack/Stack.js.map +1 -1
- package/dist/components/layout/VisuallyHidden/VisuallyHidden.d.ts +7 -0
- package/dist/components/layout/VisuallyHidden/VisuallyHidden.js.map +1 -1
- package/dist/components/navigation/Accordion/Accordion.d.ts +7 -0
- package/dist/components/navigation/Accordion/Accordion.js.map +1 -1
- package/dist/components/navigation/BottomNav/BottomNav.d.ts +9 -0
- package/dist/components/navigation/BottomNav/BottomNav.js.map +1 -1
- package/dist/components/navigation/NavLinks/NavLinks.d.ts +9 -0
- package/dist/components/navigation/NavLinks/NavLinks.js.map +1 -1
- package/dist/components/navigation/Stepper/Stepper.d.ts +7 -0
- package/dist/components/navigation/Stepper/Stepper.js.map +1 -1
- package/dist/components/navigation/Tabs/Tabs.d.ts +8 -0
- package/dist/components/navigation/Tabs/Tabs.js.map +1 -1
- package/dist/components/overlays/Dialog/Dialog.d.ts +13 -0
- package/dist/components/overlays/Dialog/Dialog.js.map +1 -1
- package/dist/components/overlays/DropdownMenu/DropdownMenu.d.ts +8 -0
- package/dist/components/overlays/DropdownMenu/DropdownMenu.js.map +1 -1
- package/dist/components/overlays/Popover/Popover.d.ts +7 -0
- package/dist/components/overlays/Popover/Popover.js.map +1 -1
- package/dist/components/overlays/Sheet/Sheet.d.ts +8 -0
- package/dist/components/overlays/Sheet/Sheet.js.map +1 -1
- package/dist/components/overlays/Tooltip/Tooltip.d.ts +8 -0
- package/dist/components/overlays/Tooltip/Tooltip.js.map +1 -1
- package/dist/components/typography/Amount/Amount.d.ts +8 -0
- package/dist/components/typography/Amount/Amount.js.map +1 -1
- package/dist/components/typography/Code/Code.d.ts +8 -0
- package/dist/components/typography/Code/Code.js.map +1 -1
- package/dist/components/typography/Heading/Heading.d.ts +8 -0
- package/dist/components/typography/Heading/Heading.js.map +1 -1
- package/dist/components/typography/Kbd/Kbd.d.ts +6 -0
- package/dist/components/typography/Kbd/Kbd.js.map +1 -1
- package/dist/components/typography/Link/Link.d.ts +9 -0
- package/dist/components/typography/Link/Link.js.map +1 -1
- package/dist/components/typography/Numeral/Numeral.d.ts +8 -0
- package/dist/components/typography/Numeral/Numeral.js.map +1 -1
- package/dist/components/typography/Prose/Prose.d.ts +9 -0
- package/dist/components/typography/Prose/Prose.js.map +1 -1
- package/dist/components/typography/Quote/Quote.d.ts +7 -0
- package/dist/components/typography/Quote/Quote.js.map +1 -1
- package/dist/components/typography/SectionHeader/SectionHeader.d.ts +8 -0
- package/dist/components/typography/SectionHeader/SectionHeader.js.map +1 -1
- package/dist/components/typography/Text/Text.d.ts +8 -0
- package/dist/components/typography/Text/Text.js.map +1 -1
- package/package.json +1 -1
- package/skills/layout-composition/SKILL.md +27 -88
- package/skills/layout-composition/references/action-bar.md +3 -3
- package/skills/layout-composition/references/app-shell.md +10 -3
- package/skills/layout-composition/references/aspect-ratio.md +2 -0
- package/skills/layout-composition/references/box.md +6 -6
- package/skills/layout-composition/references/container.md +14 -12
- package/skills/layout-composition/references/divider.md +4 -4
- package/skills/layout-composition/references/section.md +69 -0
- package/skills/layout-composition/references/visually-hidden.md +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.js","names":["RadioGroup","RadixRadioGroup","styles","messageStyles","messages_module_default","RadioGroup_module_default","RadioGroupRoot","forwardRef","invalidProp","disabledProp","readOnlyProp","describedByProp","ariaInvalid","labelledByProp","rest","field","useResolvedField","RadioGroup","cx","className","orientation","size","onValueChange","RadioGroupItem","idProp","autoId","useId","id","descriptionId","radio","joinIds","description","label","RadioGroup$1","markFieldAware"],"sources":["../../../../src/components/inputs/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import { forwardRef, useId, type ComponentPropsWithoutRef, type ReactNode } from 'react'\nimport { RadioGroup as RadixRadioGroup } from 'radix-ui'\nimport { cx } from '#utils/cx'\nimport type { Size } from '#utils/tokens'\nimport { markFieldAware, useResolvedField } from '#components/inputs/internal/FieldContext'\nimport { joinIds } from '#components/inputs/internal/refs'\nimport messageStyles from '#components/inputs/internal/messages.module.css'\nimport styles from './RadioGroup.module.css'\n\nexport interface RadioGroupProps extends Omit<\n ComponentPropsWithoutRef<typeof RadixRadioGroup.Root>,\n 'asChild'\n> {\n size?: Size\n /** Critical border on every radio + `aria-invalid`. Inside a `<Field error>` this is set for you. */\n invalid?: boolean\n /** Focusable but not editable: sets `aria-readonly` and ignores selection changes. */\n readOnly?: boolean\n}\n\n/**\n * One choice from a short list (Radix RadioGroup: arrow keys move, one tab stop).\n * Label the group with a `<Fieldset legend>`, a `<Field label>` or `aria-label`.\n *\n * <RadioGroup defaultValue=\"20\" orientation=\"horizontal\">\n * <RadioGroup.Item value=\"10\" label=\"$10\" />\n * <RadioGroup.Item value=\"20\" label=\"$20\" />\n * </RadioGroup>\n */\nconst RadioGroupRoot = forwardRef<HTMLDivElement, RadioGroupProps>(function RadioGroup(\n {\n size = 'md',\n invalid: invalidProp,\n orientation = 'vertical',\n disabled: disabledProp,\n readOnly: readOnlyProp,\n onValueChange,\n className,\n 'aria-describedby': describedByProp,\n 'aria-invalid': ariaInvalid,\n 'aria-labelledby': labelledByProp,\n ...rest\n },\n ref,\n) {\n // A group is labelled by reference, so it takes the Field's label id rather than its id.\n const field = useResolvedField({\n describedBy: describedByProp,\n invalid: invalidProp,\n ariaInvalid,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n })\n return (\n <RadixRadioGroup.Root\n ref={ref}\n className={cx(styles.group, className)}\n orientation={orientation}\n data-orientation={orientation}\n data-size={size}\n data-invalid={field.invalid || undefined}\n data-readonly={field.readOnly || undefined}\n disabled={field.disabled}\n aria-labelledby={labelledByProp ?? field.groupLabelId}\n aria-readonly={field.readOnly || undefined}\n aria-describedby={field.describedBy}\n aria-invalid={field.invalid || undefined}\n aria-required={field.required || undefined}\n aria-busy={field.busy || undefined}\n onValueChange={field.readOnly ? undefined : onValueChange}\n {...rest}\n />\n )\n})\n\nexport interface RadioGroupItemProps extends Omit<\n ComponentPropsWithoutRef<typeof RadixRadioGroup.Item>,\n 'asChild'\n> {\n /** Visible label beside the radio. Omit only if you supply `aria-label`. */\n label?: ReactNode\n /** Secondary line under the label, linked with `aria-describedby`. */\n description?: ReactNode\n}\n\n/** One option. The ref and `className` go to the radio button itself. */\nconst RadioGroupItem = forwardRef<HTMLButtonElement, RadioGroupItemProps>(function RadioGroupItem(\n { label, description, id: idProp, className, 'aria-describedby': describedByProp, ...rest },\n ref,\n) {\n const autoId = useId()\n const id = idProp ?? `${autoId}radio`\n const descriptionId = `${id}-description`\n const radio = (\n <RadixRadioGroup.Item\n ref={ref}\n id={id}\n className={cx(styles.radio, className)}\n aria-describedby={joinIds(describedByProp, description != null && descriptionId)}\n {...rest}\n >\n <RadixRadioGroup.Indicator className={styles.dot} />\n </RadixRadioGroup.Item>\n )\n if (label == null) return radio\n return (\n <div className={styles.item} data-disabled={rest.disabled ? true : undefined}>\n <span className={styles.slot}>{radio}</span>\n <span className={styles.text}>\n <label htmlFor={id} className={styles.label}>\n {label}\n </label>\n {description != null ? (\n <span id={descriptionId} className={messageStyles.description}>\n {description}\n </span>\n ) : null}\n </span>\n </div>\n )\n})\n\nexport const RadioGroup = markFieldAware(Object.assign(RadioGroupRoot, { Item: RadioGroupItem }))\n"],"mappings":";;;;;;;;;AA6BA,IAAMM,IAAiBC,EAA4C,SACjE,EACE,UAAO,MACP,SAASC,GACT,iBAAc,YACd,UAAUC,GACV,UAAUC,GACV,kBACA,cACA,oBAAoBC,GACpB,gBAAgBC,GAChB,mBAAmBC,GACnB,GAAGC,KAEL,GACA;CAEA,IAAMC,IAAQC,EAAiB;EAC7B,aAAaL;EACb,SAASH;EACT;EACA,UAAUC;EACV,UAAUC;CACZ,CAAC;CACD,OACE,kBAACT,EAAgB,MAAjB;EACO;EACL,WAAWiB,EAAGhB,EAAO,OAAOiB,CAAS;EACxB;EACb,oBAAkBC;EAClB,aA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|
+
{"version":3,"file":"RadioGroup.js","names":["RadioGroup","RadixRadioGroup","styles","messageStyles","messages_module_default","RadioGroup_module_default","RadioGroupRoot","forwardRef","invalidProp","disabledProp","readOnlyProp","describedByProp","ariaInvalid","labelledByProp","rest","field","useResolvedField","RadioGroup","cx","className","orientation","size","onValueChange","RadioGroupItem","idProp","autoId","useId","id","descriptionId","radio","joinIds","description","label","RadioGroup$1","markFieldAware"],"sources":["../../../../src/components/inputs/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import { forwardRef, useId, type ComponentPropsWithoutRef, type ReactNode } from 'react'\nimport { RadioGroup as RadixRadioGroup } from 'radix-ui'\nimport { cx } from '#utils/cx'\nimport type { Size } from '#utils/tokens'\nimport { markFieldAware, useResolvedField } from '#components/inputs/internal/FieldContext'\nimport { joinIds } from '#components/inputs/internal/refs'\nimport messageStyles from '#components/inputs/internal/messages.module.css'\nimport styles from './RadioGroup.module.css'\n\nexport interface RadioGroupProps extends Omit<\n ComponentPropsWithoutRef<typeof RadixRadioGroup.Root>,\n 'asChild'\n> {\n size?: Size\n /** Critical border on every radio + `aria-invalid`. Inside a `<Field error>` this is set for you. */\n invalid?: boolean\n /** Focusable but not editable: sets `aria-readonly` and ignores selection changes. */\n readOnly?: boolean\n}\n\n/**\n * One choice from a short list (Radix RadioGroup: arrow keys move, one tab stop).\n * Label the group with a `<Fieldset legend>`, a `<Field label>` or `aria-label`.\n *\n * <RadioGroup defaultValue=\"20\" orientation=\"horizontal\">\n * <RadioGroup.Item value=\"10\" label=\"$10\" />\n * <RadioGroup.Item value=\"20\" label=\"$20\" />\n * </RadioGroup>\n */\nconst RadioGroupRoot = forwardRef<HTMLDivElement, RadioGroupProps>(function RadioGroup(\n {\n size = 'md',\n invalid: invalidProp,\n orientation = 'vertical',\n disabled: disabledProp,\n readOnly: readOnlyProp,\n onValueChange,\n className,\n 'aria-describedby': describedByProp,\n 'aria-invalid': ariaInvalid,\n 'aria-labelledby': labelledByProp,\n ...rest\n },\n ref,\n) {\n // A group is labelled by reference, so it takes the Field's label id rather than its id.\n const field = useResolvedField({\n describedBy: describedByProp,\n invalid: invalidProp,\n ariaInvalid,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n })\n return (\n <RadixRadioGroup.Root\n ref={ref}\n className={cx(styles.group, className)}\n orientation={orientation}\n data-orientation={orientation}\n data-size={size}\n data-invalid={field.invalid || undefined}\n data-readonly={field.readOnly || undefined}\n disabled={field.disabled}\n aria-labelledby={labelledByProp ?? field.groupLabelId}\n aria-readonly={field.readOnly || undefined}\n aria-describedby={field.describedBy}\n aria-invalid={field.invalid || undefined}\n aria-required={field.required || undefined}\n aria-busy={field.busy || undefined}\n onValueChange={field.readOnly ? undefined : onValueChange}\n {...rest}\n />\n )\n})\n\nexport interface RadioGroupItemProps extends Omit<\n ComponentPropsWithoutRef<typeof RadixRadioGroup.Item>,\n 'asChild'\n> {\n /** Visible label beside the radio. Omit only if you supply `aria-label`. */\n label?: ReactNode\n /** Secondary line under the label, linked with `aria-describedby`. */\n description?: ReactNode\n}\n\n/** One option. The ref and `className` go to the radio button itself. */\nconst RadioGroupItem = forwardRef<HTMLButtonElement, RadioGroupItemProps>(function RadioGroupItem(\n { label, description, id: idProp, className, 'aria-describedby': describedByProp, ...rest },\n ref,\n) {\n const autoId = useId()\n const id = idProp ?? `${autoId}radio`\n const descriptionId = `${id}-description`\n const radio = (\n <RadixRadioGroup.Item\n ref={ref}\n id={id}\n className={cx(styles.radio, className)}\n aria-describedby={joinIds(describedByProp, description != null && descriptionId)}\n {...rest}\n >\n <RadixRadioGroup.Indicator className={styles.dot} />\n </RadixRadioGroup.Item>\n )\n if (label == null) return radio\n return (\n <div className={styles.item} data-disabled={rest.disabled ? true : undefined}>\n <span className={styles.slot}>{radio}</span>\n <span className={styles.text}>\n <label htmlFor={id} className={styles.label}>\n {label}\n </label>\n {description != null ? (\n <span id={descriptionId} className={messageStyles.description}>\n {description}\n </span>\n ) : null}\n </span>\n </div>\n )\n})\n\n/**\n * One choice from a short list. One tab stop, with arrow keys to move and choose.\n *\n * @remarks\n * `RadioGroup` is Radix RadioGroup with Kiln's look. The group is one tab stop, and arrow keys\n * move between options and select them. Compose `RadioGroup.Item`s with your own labels, or use\n * {@link RadioGroupField | RadioGroupField}, which lays the options out with labels and\n * descriptions under a legend.\n */\nexport const RadioGroup = markFieldAware(Object.assign(RadioGroupRoot, { Item: RadioGroupItem }))\n"],"mappings":";;;;;;;;;AA6BA,IAAMM,IAAiBC,EAA4C,SACjE,EACE,UAAO,MACP,SAASC,GACT,iBAAc,YACd,UAAUC,GACV,UAAUC,GACV,kBACA,cACA,oBAAoBC,GACpB,gBAAgBC,GAChB,mBAAmBC,GACnB,GAAGC,KAEL,GACA;CAEA,IAAMC,IAAQC,EAAiB;EAC7B,aAAaL;EACb,SAASH;EACT;EACA,UAAUC;EACV,UAAUC;CACZ,CAAC;CACD,OACE,kBAACT,EAAgB,MAAjB;EACO;EACL,WAAWiB,EAAGhB,EAAO,OAAOiB,CAAS;EACxB;EACb,oBAAkBC;EAClB,aAAWC;EACX,gBAAcN,EAAM,WAAW,KAAA;EAC/B,iBAAeA,EAAM,YAAY,KAAA;EACjC,UAAUA,EAAM;EAChB,mBAAiBF,KAAkBE,EAAM;EACzC,iBAAeA,EAAM,YAAY,KAAA;EACjC,oBAAkBA,EAAM;EACxB,gBAAcA,EAAM,WAAW,KAAA;EAC/B,iBAAeA,EAAM,YAAY,KAAA;EACjC,aAAWA,EAAM,QAAQ,KAAA;EACzB,eAAeA,EAAM,WAAW,KAAA,IAAYO;EAC5C,GAAIR;CACL,CAAA;AAEL,CAAC,GAaKS,IAAiBhB,EAAmD,SACxE,EAAE,UAAO,gBAAa,IAAIiB,GAAQ,cAAW,oBAAoBb,GAAiB,GAAGG,KACrF,GACA;CACA,IAAMW,IAASC,EAAM,GACfC,IAAKH,KAAU,GAAGC,EAAO,QACzBG,IAAgB,GAAGD,EAAG,eACtBE,IACJ,kBAAC5B,EAAgB,MAAjB;EACO;EACD;EACJ,WAAWiB,EAAGhB,EAAO,OAAOiB,CAAS;EACrC,oBAAkBW,EAAQnB,GAAiBoB,KAAe,QAAQH,CAAa;EAC/E,GAAId;EAEJ,UAAA,kBAACb,EAAgB,WAAjB,EAA2B,WAAWC,EAAO,IAAM,CAAA;CAC/B,CAAA;CAGxB,OADI8B,KAAS,OAAaH,IAExB,kBAAC,OAAD;EAAK,WAAW3B,EAAO;EAAM,iBAAeY,EAAK,WAAW,KAAO,KAAA;EAAnE,UAAA,CACE,kBAAC,QAAD;GAAM,WAAWZ,EAAO;GAAO,UAAA2B;EAAY,CAAA,GAC3C,kBAAC,QAAD;GAAM,WAAW3B,EAAO;GAAxB,UAAA,CACE,kBAAC,SAAD;IAAO,SAASyB;IAAI,WAAWzB,EAAO;IACnC,UAAA8B;GACI,CAAA,GACND,KAAe,OAIZ,OAHF,kBAAC,QAAD;IAAM,IAAIH;IAAe,WAAWzB,EAAc;IAC/C,UAAA4B;GACG,CAAA,CAEJ;EACH,CAAA,CAAA;;AAET,CAAC,GAWY/B,IAAakC,EAAe,OAAO,OAAO5B,GAAgB,EAAE,MAAMiB,EAAe,CAAC,CAAC"}
|
|
@@ -7,6 +7,14 @@ export interface RadioGroupFieldProps extends FieldLabelProps, Omit<RadioGroupPr
|
|
|
7
7
|
orientation?: 'vertical' | 'horizontal';
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
+
* One choice from a short list, with labels, descriptions and a legend for the set.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* `RadioGroupField` lays out a {@link RadioGroup | RadioGroup} from `options` under a {@link
|
|
14
|
+
* Fieldset | Fieldset} legend, each option with a label and an optional description. Arrow keys
|
|
15
|
+
* move and select.
|
|
16
|
+
*
|
|
17
|
+
* @privateRemarks
|
|
10
18
|
* One choice from a short list, under a `<Fieldset>` legend. Arrow keys move and select;
|
|
11
19
|
* the group is one tab stop. `className`/`style` go to the fieldset; `ref`, `id`, `name`
|
|
12
20
|
* and the rest go to the radio group (`name` submits the checked value natively).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroupField.js","names":["RadioGroupField","forwardRef","fieldProps","rest","splitFieldLabelProps","props","groupProps","current","setCurrent","useControllableValue","value","defaultValue","onValueChange","handleBlur","useFocusLeave","onBlur","Fieldset","toFieldsetProps","RadioGroup","options","o"],"sources":["../../../../src/components/inputs/RadioGroupField/RadioGroupField.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport {\n useControllableValue,\n useFocusLeave,\n toFieldsetProps,\n type ChoiceOption,\n} from '#components/inputs/CheckboxGroup/choice'\nimport type { FieldLabelProps } from '#components/inputs/Field'\nimport { Fieldset } from '#components/inputs/Fieldset'\nimport { RadioGroup, type RadioGroupProps } from '#components/inputs/RadioGroup'\nimport { splitFieldLabelProps } from '#components/inputs/internal/fieldProps'\n\nexport interface RadioGroupFieldProps\n extends FieldLabelProps, Omit<RadioGroupProps, 'invalid' | 'children' | keyof FieldLabelProps> {\n options: readonly ChoiceOption[]\n /** `vertical` (default) stacks the options; `horizontal` runs them in a wrapping row. */\n orientation?: 'vertical' | 'horizontal'\n}\n\n/**\n * One choice from a short list, under a `<Fieldset>` legend. Arrow keys move and select;\n * the group is one tab stop. `className`/`style` go to the fieldset; `ref`, `id`, `name`\n * and the rest go to the radio group (`name` submits the checked value natively).\n *\n * <RadioGroupField label=\"Billing period\" name=\"period\" options={periods} defaultValue=\"monthly\" />\n */\nexport const RadioGroupField = forwardRef<HTMLDivElement, RadioGroupFieldProps>(\n function RadioGroupField(props, ref) {\n const [fieldProps, rest] = splitFieldLabelProps(props)\n const {\n options,\n value,\n defaultValue,\n onValueChange,\n onBlur,\n className,\n style,\n disabled,\n ...groupProps\n } = rest\n // Hold the value here so read-only also holds for an uncontrolled group.\n const [current, setCurrent] = useControllableValue(\n value === null ? '' : value,\n defaultValue ?? '',\n onValueChange,\n fieldProps.readOnly,\n )\n const handleBlur = useFocusLeave(onBlur)\n return (\n <Fieldset\n {...toFieldsetProps(fieldProps)}\n disabled={disabled}\n className={className}\n style={style}\n >\n <RadioGroup\n ref={ref}\n value={current}\n onValueChange={setCurrent}\n onBlur={handleBlur}\n {...groupProps}\n >\n {options.map((o) => (\n <RadioGroup.Item\n key={o.value}\n value={o.value}\n label={o.label}\n description={o.description}\n disabled={o.disabled}\n />\n ))}\n </RadioGroup>\n </Fieldset>\n )\n },\n)\n"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"RadioGroupField.js","names":["RadioGroupField","forwardRef","fieldProps","rest","splitFieldLabelProps","props","groupProps","current","setCurrent","useControllableValue","value","defaultValue","onValueChange","handleBlur","useFocusLeave","onBlur","Fieldset","toFieldsetProps","RadioGroup","options","o"],"sources":["../../../../src/components/inputs/RadioGroupField/RadioGroupField.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport {\n useControllableValue,\n useFocusLeave,\n toFieldsetProps,\n type ChoiceOption,\n} from '#components/inputs/CheckboxGroup/choice'\nimport type { FieldLabelProps } from '#components/inputs/Field'\nimport { Fieldset } from '#components/inputs/Fieldset'\nimport { RadioGroup, type RadioGroupProps } from '#components/inputs/RadioGroup'\nimport { splitFieldLabelProps } from '#components/inputs/internal/fieldProps'\n\nexport interface RadioGroupFieldProps\n extends FieldLabelProps, Omit<RadioGroupProps, 'invalid' | 'children' | keyof FieldLabelProps> {\n options: readonly ChoiceOption[]\n /** `vertical` (default) stacks the options; `horizontal` runs them in a wrapping row. */\n orientation?: 'vertical' | 'horizontal'\n}\n\n/**\n * One choice from a short list, with labels, descriptions and a legend for the set.\n *\n * @remarks\n * `RadioGroupField` lays out a {@link RadioGroup | RadioGroup} from `options` under a {@link\n * Fieldset | Fieldset} legend, each option with a label and an optional description. Arrow keys\n * move and select.\n *\n * @privateRemarks\n * One choice from a short list, under a `<Fieldset>` legend. Arrow keys move and select;\n * the group is one tab stop. `className`/`style` go to the fieldset; `ref`, `id`, `name`\n * and the rest go to the radio group (`name` submits the checked value natively).\n *\n * <RadioGroupField label=\"Billing period\" name=\"period\" options={periods} defaultValue=\"monthly\" />\n */\nexport const RadioGroupField = forwardRef<HTMLDivElement, RadioGroupFieldProps>(\n function RadioGroupField(props, ref) {\n const [fieldProps, rest] = splitFieldLabelProps(props)\n const {\n options,\n value,\n defaultValue,\n onValueChange,\n onBlur,\n className,\n style,\n disabled,\n ...groupProps\n } = rest\n // Hold the value here so read-only also holds for an uncontrolled group.\n const [current, setCurrent] = useControllableValue(\n value === null ? '' : value,\n defaultValue ?? '',\n onValueChange,\n fieldProps.readOnly,\n )\n const handleBlur = useFocusLeave(onBlur)\n return (\n <Fieldset\n {...toFieldsetProps(fieldProps)}\n disabled={disabled}\n className={className}\n style={style}\n >\n <RadioGroup\n ref={ref}\n value={current}\n onValueChange={setCurrent}\n onBlur={handleBlur}\n {...groupProps}\n >\n {options.map((o) => (\n <RadioGroup.Item\n key={o.value}\n value={o.value}\n label={o.label}\n description={o.description}\n disabled={o.disabled}\n />\n ))}\n </RadioGroup>\n </Fieldset>\n )\n },\n)\n"],"mappings":";;;;;;;AAkCA,IAAaA,IAAkBC,EAC7B,SAAyB,GAAO,GAAK;CACnC,IAAM,CAACC,GAAYC,KAAQC,EAAqBC,CAAK,GAC/C,EACJ,YACA,UACA,iBACA,kBACA,WACA,cACA,UACA,aACA,GAAGC,MACDH,GAEE,CAACI,GAASC,KAAcC,EAC5BC,MAAU,OAAO,KAAKA,GACtBC,KAAgB,IAChBC,GACAV,EAAW,QACb,GACMW,IAAaC,EAAcC,CAAM;CACvC,OACE,kBAACC,GAAD;EACE,GAAIC,EAAgBf,CAAU;EACpB;EACC;EACJ;EAEP,UAAA,kBAACgB,GAAD;GACO;GACL,OAAOX;GACP,eAAeC;GACf,QAAQK;GACR,GAAIP;GAEH,UAAAa,EAAQ,KAAK,MACZ,kBAACD,EAAW,MAAZ;IAEE,OAAOE,EAAE;IACT,OAAOA,EAAE;IACT,aAAaA,EAAE;IACf,UAAUA,EAAE;GACb,GALMA,EAAE,KAKR,CACF;EACS,CAAA;CACJ,CAAA;AAEd,CACF"}
|
|
@@ -12,6 +12,14 @@ export interface RangeSliderProps extends Omit<SliderProps, 'value' | 'defaultVa
|
|
|
12
12
|
thumbLabels?: readonly [string, string];
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
+
* A low and high value on one track, each thumb with its own name.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* `RangeSlider` picks a range: a departure window, a price band. The wrapper is a group, labelled
|
|
19
|
+
* by its Field or `aria-label`, and each thumb is a slider named by `thumbLabels`.
|
|
20
|
+
* `minStepsBetweenThumbs` keeps the thumbs apart.
|
|
21
|
+
*
|
|
22
|
+
* @privateRemarks
|
|
15
23
|
* A low–high range on one track ("Price range": £500–£5,000). The wrapper is a
|
|
16
24
|
* `role="group"` labelled by the surrounding `<Field>` (see `RangeSliderField`) or
|
|
17
25
|
* `aria-label`; each thumb is a `role="slider"` named by `thumbLabels`. The ref and `id`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RangeSlider.js","names":["DEFAULT_THUMB_LABELS","RangeSlider","markFieldAware","forwardRef","disabledProp","readOnlyProp","invalidProp","idProp","labelledByProp","describedByProp","ariaInvalid","rest","autoId","useId","field","useResolvedField","current","setCurrent","useControllableValue","value","defaultValue","min","max","onValueChange","next","handleBlur","useFocusLeave","onBlur","toTuple","thumbState","SliderBase","onValueCommit","thumbLabels"],"sources":["../../../../src/components/inputs/RangeSlider/RangeSlider.tsx"],"sourcesContent":["import { forwardRef, useId } from 'react'\nimport { useControllableValue, useFocusLeave } from '#components/inputs/CheckboxGroup/choice'\nimport { markFieldAware, useResolvedField } from '#components/inputs/internal/FieldContext'\nimport type { SliderProps } from '#components/inputs/Slider'\nimport { SliderBase } from '#components/inputs/Slider/SliderBase'\n\nexport interface RangeSliderProps extends Omit<\n SliderProps,\n 'value' | 'defaultValue' | 'onValueChange' | 'onValueCommit'\n> {\n /** Controlled `[low, high]`. */\n value?: readonly [number, number]\n /** Initial `[low, high]` when uncontrolled. Defaults to `[min, max]`. */\n defaultValue?: readonly [number, number]\n onValueChange?: (value: [number, number]) => void\n onValueCommit?: (value: [number, number]) => void\n /** How many steps the thumbs must stay apart. Default 0 (they may meet). */\n minStepsBetweenThumbs?: number\n /** Accessible names of the two thumbs. Default `['Minimum', 'Maximum']`. */\n thumbLabels?: readonly [string, string]\n}\n\nconst DEFAULT_THUMB_LABELS = ['Minimum', 'Maximum'] as const\n\n/**\n * A low–high range on one track (\"Price range\": £500–£5,000). The wrapper is a\n * `role=\"group\"` labelled by the surrounding `<Field>` (see `RangeSliderField`) or\n * `aria-label`; each thumb is a `role=\"slider\"` named by `thumbLabels`. The ref and `id`\n * go to the group. `onBlur` fires once, when focus leaves both thumbs.\n *\n * <RangeSlider aria-label=\"Price range\" min={500} max={5000} step={100} defaultValue={[1000, 2500]} showValue\n * formatOptions={{ style: 'currency', currency: 'GBP', maximumFractionDigits: 0 }} />\n */\nexport const RangeSlider = markFieldAware(\n forwardRef<HTMLSpanElement, RangeSliderProps>(function RangeSlider(\n {\n value,\n defaultValue,\n onValueChange,\n onValueCommit,\n min = 0,\n max = 100,\n step = 1,\n minStepsBetweenThumbs = 0,\n thumbLabels = DEFAULT_THUMB_LABELS,\n marks,\n showValue = false,\n formatOptions,\n locale,\n name,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n invalid: invalidProp,\n size = 'md',\n id: idProp,\n onBlur,\n 'aria-labelledby': labelledByProp,\n 'aria-describedby': describedByProp,\n 'aria-invalid': ariaInvalid,\n ...rest\n },\n ref,\n ) {\n const autoId = useId()\n const field = useResolvedField({\n id: idProp,\n describedBy: describedByProp,\n invalid: invalidProp,\n ariaInvalid,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n })\n const [current, setCurrent] = useControllableValue<readonly [number, number]>(\n value,\n defaultValue ?? [min, max],\n onValueChange &&\n ((next) => {\n onValueChange([next[0], next[1]])\n }),\n field.readOnly,\n )\n const handleBlur = useFocusLeave(onBlur)\n const toTuple = (next: number[]): [number, number] => [next[0] ?? min, next[1] ?? max]\n\n const thumbState = {\n 'aria-invalid': field.invalid || undefined,\n 'aria-readonly': field.readOnly || undefined,\n 'aria-busy': field.busy || undefined,\n } as const\n\n return (\n // aria-invalid on the group as well as each thumb, like CheckboxGroup: the error belongs to the range.\n // eslint-disable-next-line jsx-a11y/role-supports-aria-props\n <SliderBase\n ref={ref}\n id={field.id}\n role=\"group\"\n aria-labelledby={labelledByProp ?? (rest['aria-label'] ? undefined : field.labelId)}\n aria-describedby={field.describedBy}\n aria-invalid={field.invalid || undefined}\n {...rest}\n onBlur={handleBlur}\n values={current}\n onValuesChange={(next) => {\n setCurrent(toTuple(next))\n }}\n onValuesCommit={(next) => onValueCommit?.(toTuple(next))}\n min={min}\n max={max}\n step={step}\n minStepsBetweenThumbs={minStepsBetweenThumbs}\n marks={marks}\n showValue={showValue}\n formatOptions={formatOptions}\n locale={locale}\n name={name}\n disabled={field.disabled}\n readOnly={field.readOnly}\n invalid={field.invalid}\n size={size}\n thumbs={[\n { id: `${autoId}min`, 'aria-label': thumbLabels[0], ...thumbState },\n { id: `${autoId}max`, 'aria-label': thumbLabels[1], ...thumbState },\n ]}\n />\n )\n }),\n)\n"],"mappings":";;;;;;AAsBA,IAAMA,IAAuB,CAAC,WAAW,SAAS,
|
|
1
|
+
{"version":3,"file":"RangeSlider.js","names":["DEFAULT_THUMB_LABELS","RangeSlider","markFieldAware","forwardRef","disabledProp","readOnlyProp","invalidProp","idProp","labelledByProp","describedByProp","ariaInvalid","rest","autoId","useId","field","useResolvedField","current","setCurrent","useControllableValue","value","defaultValue","min","max","onValueChange","next","handleBlur","useFocusLeave","onBlur","toTuple","thumbState","SliderBase","onValueCommit","thumbLabels"],"sources":["../../../../src/components/inputs/RangeSlider/RangeSlider.tsx"],"sourcesContent":["import { forwardRef, useId } from 'react'\nimport { useControllableValue, useFocusLeave } from '#components/inputs/CheckboxGroup/choice'\nimport { markFieldAware, useResolvedField } from '#components/inputs/internal/FieldContext'\nimport type { SliderProps } from '#components/inputs/Slider'\nimport { SliderBase } from '#components/inputs/Slider/SliderBase'\n\nexport interface RangeSliderProps extends Omit<\n SliderProps,\n 'value' | 'defaultValue' | 'onValueChange' | 'onValueCommit'\n> {\n /** Controlled `[low, high]`. */\n value?: readonly [number, number]\n /** Initial `[low, high]` when uncontrolled. Defaults to `[min, max]`. */\n defaultValue?: readonly [number, number]\n onValueChange?: (value: [number, number]) => void\n onValueCommit?: (value: [number, number]) => void\n /** How many steps the thumbs must stay apart. Default 0 (they may meet). */\n minStepsBetweenThumbs?: number\n /** Accessible names of the two thumbs. Default `['Minimum', 'Maximum']`. */\n thumbLabels?: readonly [string, string]\n}\n\nconst DEFAULT_THUMB_LABELS = ['Minimum', 'Maximum'] as const\n\n/**\n * A low and high value on one track, each thumb with its own name.\n *\n * @remarks\n * `RangeSlider` picks a range: a departure window, a price band. The wrapper is a group, labelled\n * by its Field or `aria-label`, and each thumb is a slider named by `thumbLabels`.\n * `minStepsBetweenThumbs` keeps the thumbs apart.\n *\n * @privateRemarks\n * A low–high range on one track (\"Price range\": £500–£5,000). The wrapper is a\n * `role=\"group\"` labelled by the surrounding `<Field>` (see `RangeSliderField`) or\n * `aria-label`; each thumb is a `role=\"slider\"` named by `thumbLabels`. The ref and `id`\n * go to the group. `onBlur` fires once, when focus leaves both thumbs.\n *\n * <RangeSlider aria-label=\"Price range\" min={500} max={5000} step={100} defaultValue={[1000, 2500]} showValue\n * formatOptions={{ style: 'currency', currency: 'GBP', maximumFractionDigits: 0 }} />\n */\nexport const RangeSlider = markFieldAware(\n forwardRef<HTMLSpanElement, RangeSliderProps>(function RangeSlider(\n {\n value,\n defaultValue,\n onValueChange,\n onValueCommit,\n min = 0,\n max = 100,\n step = 1,\n minStepsBetweenThumbs = 0,\n thumbLabels = DEFAULT_THUMB_LABELS,\n marks,\n showValue = false,\n formatOptions,\n locale,\n name,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n invalid: invalidProp,\n size = 'md',\n id: idProp,\n onBlur,\n 'aria-labelledby': labelledByProp,\n 'aria-describedby': describedByProp,\n 'aria-invalid': ariaInvalid,\n ...rest\n },\n ref,\n ) {\n const autoId = useId()\n const field = useResolvedField({\n id: idProp,\n describedBy: describedByProp,\n invalid: invalidProp,\n ariaInvalid,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n })\n const [current, setCurrent] = useControllableValue<readonly [number, number]>(\n value,\n defaultValue ?? [min, max],\n onValueChange &&\n ((next) => {\n onValueChange([next[0], next[1]])\n }),\n field.readOnly,\n )\n const handleBlur = useFocusLeave(onBlur)\n const toTuple = (next: number[]): [number, number] => [next[0] ?? min, next[1] ?? max]\n\n const thumbState = {\n 'aria-invalid': field.invalid || undefined,\n 'aria-readonly': field.readOnly || undefined,\n 'aria-busy': field.busy || undefined,\n } as const\n\n return (\n // aria-invalid on the group as well as each thumb, like CheckboxGroup: the error belongs to the range.\n // eslint-disable-next-line jsx-a11y/role-supports-aria-props\n <SliderBase\n ref={ref}\n id={field.id}\n role=\"group\"\n aria-labelledby={labelledByProp ?? (rest['aria-label'] ? undefined : field.labelId)}\n aria-describedby={field.describedBy}\n aria-invalid={field.invalid || undefined}\n {...rest}\n onBlur={handleBlur}\n values={current}\n onValuesChange={(next) => {\n setCurrent(toTuple(next))\n }}\n onValuesCommit={(next) => onValueCommit?.(toTuple(next))}\n min={min}\n max={max}\n step={step}\n minStepsBetweenThumbs={minStepsBetweenThumbs}\n marks={marks}\n showValue={showValue}\n formatOptions={formatOptions}\n locale={locale}\n name={name}\n disabled={field.disabled}\n readOnly={field.readOnly}\n invalid={field.invalid}\n size={size}\n thumbs={[\n { id: `${autoId}min`, 'aria-label': thumbLabels[0], ...thumbState },\n { id: `${autoId}max`, 'aria-label': thumbLabels[1], ...thumbState },\n ]}\n />\n )\n }),\n)\n"],"mappings":";;;;;;AAsBA,IAAMA,IAAuB,CAAC,WAAW,SAAS,GAmBrCC,IAAcC,EACzBC,EA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AAcoB,EAAY;GAAI,GAAGH;EAAW,GAClE;GAAE,IAAI,GAAGjB,EAAO;GAAM,cAAcoB,EAAY;GAAI,GAAGH;EAAW,CACpE;CACD,CAAA;AAEL,CAAC,CACH"}
|
|
@@ -3,6 +3,13 @@ import { type RangeSliderProps } from '../RangeSlider/index.js';
|
|
|
3
3
|
export interface RangeSliderFieldProps extends FieldLabelProps, Omit<RangeSliderProps, 'invalid' | keyof FieldLabelProps> {
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
|
+
* A labelled range slider, the label naming the group and thumbLabels naming each thumb.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* `RangeSliderField` is a {@link Field | Field} around a {@link RangeSlider | RangeSlider}. The
|
|
10
|
+
* label names the group, and `thumbLabels` name the two thumbs.
|
|
11
|
+
*
|
|
12
|
+
* @privateRemarks
|
|
6
13
|
* A labelled `RangeSlider`: the Field's label names the group, `thumbLabels` name the two
|
|
7
14
|
* thumbs. `className`/`style` go to the Field; `ref`, `id`, `name` and the rest go to the
|
|
8
15
|
* range slider's group.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RangeSliderField.js","names":["RangeSliderField","forwardRef","fieldProps","sliderProps","splitFieldLabelProps","props","Field","id","RangeSlider"],"sources":["../../../../src/components/inputs/RangeSliderField/RangeSliderField.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { Field, type FieldLabelProps } from '#components/inputs/Field'\nimport { splitFieldLabelProps } from '#components/inputs/internal/fieldProps'\nimport { RangeSlider, type RangeSliderProps } from '#components/inputs/RangeSlider'\n\nexport interface RangeSliderFieldProps\n extends FieldLabelProps, Omit<RangeSliderProps, 'invalid' | keyof FieldLabelProps> {}\n\n/**\n * A labelled `RangeSlider`: the Field's label names the group, `thumbLabels` name the two\n * thumbs. `className`/`style` go to the Field; `ref`, `id`, `name` and the rest go to the\n * range slider's group.\n *\n * <RangeSliderField label=\"Price range\" name=\"price\" min={500} max={5000} step={100} showValue />\n */\nexport const RangeSliderField = forwardRef<HTMLSpanElement, RangeSliderFieldProps>(\n function RangeSliderField(props, ref) {\n const [fieldProps, { id, disabled, className, style, ...sliderProps }] =\n splitFieldLabelProps(props)\n return (\n <Field {...fieldProps} htmlFor={id} disabled={disabled} className={className} style={style}>\n <RangeSlider ref={ref} {...sliderProps} />\n </Field>\n )\n },\n)\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"RangeSliderField.js","names":["RangeSliderField","forwardRef","fieldProps","sliderProps","splitFieldLabelProps","props","Field","id","RangeSlider"],"sources":["../../../../src/components/inputs/RangeSliderField/RangeSliderField.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { Field, type FieldLabelProps } from '#components/inputs/Field'\nimport { splitFieldLabelProps } from '#components/inputs/internal/fieldProps'\nimport { RangeSlider, type RangeSliderProps } from '#components/inputs/RangeSlider'\n\nexport interface RangeSliderFieldProps\n extends FieldLabelProps, Omit<RangeSliderProps, 'invalid' | keyof FieldLabelProps> {}\n\n/**\n * A labelled range slider, the label naming the group and thumbLabels naming each thumb.\n *\n * @remarks\n * `RangeSliderField` is a {@link Field | Field} around a {@link RangeSlider | RangeSlider}. The\n * label names the group, and `thumbLabels` name the two thumbs.\n *\n * @privateRemarks\n * A labelled `RangeSlider`: the Field's label names the group, `thumbLabels` name the two\n * thumbs. `className`/`style` go to the Field; `ref`, `id`, `name` and the rest go to the\n * range slider's group.\n *\n * <RangeSliderField label=\"Price range\" name=\"price\" min={500} max={5000} step={100} showValue />\n */\nexport const RangeSliderField = forwardRef<HTMLSpanElement, RangeSliderFieldProps>(\n function RangeSliderField(props, ref) {\n const [fieldProps, { id, disabled, className, style, ...sliderProps }] =\n splitFieldLabelProps(props)\n return (\n <Field {...fieldProps} htmlFor={id} disabled={disabled} className={className} style={style}>\n <RangeSlider ref={ref} {...sliderProps} />\n </Field>\n )\n },\n)\n"],"mappings":";;;;;;AAsBA,IAAaA,IAAmBC,EAC9B,SAA0B,GAAO,GAAK;CACpC,IAAM,CAACC,GAAY,EAAE,OAAI,aAAU,cAAW,UAAO,GAAGC,OACtDC,EAAqBC,CAAK;CAC5B,OACE,kBAACC,GAAD;EAAO,GAAIJ;EAAY,SAASK;EAAc;EAAqB;EAAkB;EACnF,UAAA,kBAACC,GAAD;GAAkB;GAAK,GAAIL;EAAc,CAAA;CACpC,CAAA;AAEX,CACF"}
|
|
@@ -21,6 +21,14 @@ export interface RatingProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onCha
|
|
|
21
21
|
size?: Size;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
+
* A star rating that's one tab stop, with arrow keys to choose and a preview on hover.
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* `Rating` is a radio group whose radios are stars, so it's one tab stop and the arrow keys move
|
|
28
|
+
* and choose. Stars up to the rating fill with the accent, and hovering previews a rating before
|
|
29
|
+
* you choose. `clearable` lets pressing the chosen star again clear it.
|
|
30
|
+
*
|
|
31
|
+
* @privateRemarks
|
|
24
32
|
* A star rating — a Radix RadioGroup whose radios are stars, so it's one tab stop and the
|
|
25
33
|
* arrow keys move and choose. Stars up to the rating fill with the accent; hovering
|
|
26
34
|
* previews a rating before you choose it. Label it with a `<Field>` (see `RatingField`) or
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Rating.js","names":["RadixRadioGroup","styles","Rating_module_default","defaultItemLabel","n","max","Rating","markFieldAware","forwardRef","disabledProp","readOnlyProp","invalidProp","idProp","describedByProp","ariaInvalid","labelledByProp","rest","field","useResolvedField","current","setCurrent","useControllableValue","value","defaultValue","onValueChange","preview","setPreview","useState","handleBlur","useFocusLeave","onBlur","interactive","shown","stars","i","RadioGroup","cx","className","v","size","onPointerLeave","event","itemLabel","clearable","StarIcon","name"],"sources":["../../../../src/components/inputs/Rating/Rating.tsx"],"sourcesContent":["import { forwardRef, useState, type HTMLAttributes } from 'react'\nimport { RadioGroup as RadixRadioGroup } from 'radix-ui'\nimport { StarIcon } from '#icons'\nimport { cx } from '#utils/cx'\nimport type { Size } from '#utils/tokens'\nimport { useControllableValue, useFocusLeave } from '#components/inputs/CheckboxGroup/choice'\nimport { markFieldAware, useResolvedField } from '#components/inputs/internal/FieldContext'\nimport styles from './Rating.module.css'\n\nexport interface RatingProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'defaultValue' | 'dir'\n> {\n /** Controlled rating, `null` for none. */\n value?: number | null\n defaultValue?: number | null\n onValueChange?: (value: number | null) => void\n /** Number of stars. Default 5. */\n max?: number\n /** Choosing the current rating again clears it (`null`). */\n clearable?: boolean\n /** Each star's accessible name. Default `${n} of ${max}`. */\n itemLabel?: (n: number, max: number) => string\n /** Emits a hidden input with the rating (none when `null`), for native form submission. */\n name?: string\n disabled?: boolean\n /** Focusable but not editable: sets `aria-readonly` and ignores changes. */\n readOnly?: boolean\n /** Critical edge on the empty stars + `aria-invalid`. Inside a `<Field error>` this is set for you. */\n invalid?: boolean\n size?: Size\n}\n\nconst defaultItemLabel = (n: number, max: number) => `${String(n)} of ${String(max)}`\n\n/**\n * A star rating — a Radix RadioGroup whose radios are stars, so it's one tab stop and the\n * arrow keys move and choose. Stars up to the rating fill with the accent; hovering\n * previews a rating before you choose it. Label it with a `<Field>` (see `RatingField`) or\n * `aria-label`. `onBlur` fires once, when focus leaves the stars.\n *\n * <Rating aria-label=\"Rate this release\" defaultValue={4} clearable />\n */\nexport const Rating = markFieldAware(\n forwardRef<HTMLDivElement, RatingProps>(function Rating(\n {\n value,\n defaultValue = null,\n onValueChange,\n max = 5,\n clearable = false,\n itemLabel = defaultItemLabel,\n name,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n invalid: invalidProp,\n size = 'md',\n id: idProp,\n className,\n onBlur,\n onPointerLeave,\n 'aria-describedby': describedByProp,\n 'aria-invalid': ariaInvalid,\n 'aria-labelledby': labelledByProp,\n ...rest\n },\n ref,\n ) {\n const field = useResolvedField({\n id: idProp,\n describedBy: describedByProp,\n invalid: invalidProp,\n ariaInvalid,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n })\n const [current, setCurrent] = useControllableValue<number | null>(\n value,\n defaultValue,\n onValueChange,\n field.readOnly,\n )\n const [preview, setPreview] = useState<number | null>(null)\n const handleBlur = useFocusLeave(onBlur)\n const interactive = !field.disabled && !field.readOnly\n const shown = preview ?? current ?? 0\n const stars = Array.from({ length: Math.max(0, Math.floor(max)) }, (_, i) => i + 1)\n\n return (\n <RadixRadioGroup.Root\n ref={ref}\n id={field.id}\n className={cx(styles.rating, className)}\n value={current === null ? '' : String(current)}\n onValueChange={(v) => {\n setCurrent(v === '' ? null : Number(v))\n }}\n disabled={field.disabled}\n data-size={size}\n data-invalid={field.invalid || undefined}\n data-readonly={field.readOnly || undefined}\n data-previewing={preview !== null || undefined}\n aria-labelledby={labelledByProp ?? (rest['aria-label'] ? undefined : field.labelId)}\n aria-describedby={field.describedBy}\n aria-invalid={field.invalid || undefined}\n aria-required={field.required || undefined}\n aria-readonly={field.readOnly || undefined}\n aria-busy={field.busy || undefined}\n onBlur={handleBlur}\n onPointerLeave={(event) => {\n setPreview(null)\n onPointerLeave?.(event)\n }}\n {...rest}\n >\n {stars.map((n) => (\n <RadixRadioGroup.Item\n key={n}\n value={String(n)}\n className={styles.star}\n aria-label={itemLabel(n, max)}\n data-filled={n <= shown || undefined}\n onPointerEnter={\n interactive\n ? () => {\n setPreview(n)\n }\n : undefined\n }\n onClick={\n clearable\n ? () => {\n // Radix ignores a click on the checked radio; clearable turns it into \"none\".\n if (current === n) setCurrent(null)\n }\n : undefined\n }\n >\n <StarIcon className={styles.glyph} />\n </RadixRadioGroup.Item>\n ))}\n {name && current !== null ? (\n <input type=\"hidden\" name={name} value={current} disabled={field.disabled || undefined} />\n ) : null}\n </RadixRadioGroup.Root>\n )\n }),\n)\n"],"mappings":";;;;;;;;;AAiCA,IAAMG,KAAoB,GAAW,MAAgB,GAAG,OAAOC,CAAC,EAAE,MAAM,OAAOC,CAAG,
|
|
1
|
+
{"version":3,"file":"Rating.js","names":["RadixRadioGroup","styles","Rating_module_default","defaultItemLabel","n","max","Rating","markFieldAware","forwardRef","disabledProp","readOnlyProp","invalidProp","idProp","describedByProp","ariaInvalid","labelledByProp","rest","field","useResolvedField","current","setCurrent","useControllableValue","value","defaultValue","onValueChange","preview","setPreview","useState","handleBlur","useFocusLeave","onBlur","interactive","shown","stars","i","RadioGroup","cx","className","v","size","onPointerLeave","event","itemLabel","clearable","StarIcon","name"],"sources":["../../../../src/components/inputs/Rating/Rating.tsx"],"sourcesContent":["import { forwardRef, useState, type HTMLAttributes } from 'react'\nimport { RadioGroup as RadixRadioGroup } from 'radix-ui'\nimport { StarIcon } from '#icons'\nimport { cx } from '#utils/cx'\nimport type { Size } from '#utils/tokens'\nimport { useControllableValue, useFocusLeave } from '#components/inputs/CheckboxGroup/choice'\nimport { markFieldAware, useResolvedField } from '#components/inputs/internal/FieldContext'\nimport styles from './Rating.module.css'\n\nexport interface RatingProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'defaultValue' | 'dir'\n> {\n /** Controlled rating, `null` for none. */\n value?: number | null\n defaultValue?: number | null\n onValueChange?: (value: number | null) => void\n /** Number of stars. Default 5. */\n max?: number\n /** Choosing the current rating again clears it (`null`). */\n clearable?: boolean\n /** Each star's accessible name. Default `${n} of ${max}`. */\n itemLabel?: (n: number, max: number) => string\n /** Emits a hidden input with the rating (none when `null`), for native form submission. */\n name?: string\n disabled?: boolean\n /** Focusable but not editable: sets `aria-readonly` and ignores changes. */\n readOnly?: boolean\n /** Critical edge on the empty stars + `aria-invalid`. Inside a `<Field error>` this is set for you. */\n invalid?: boolean\n size?: Size\n}\n\nconst defaultItemLabel = (n: number, max: number) => `${String(n)} of ${String(max)}`\n\n/**\n * A star rating that's one tab stop, with arrow keys to choose and a preview on hover.\n *\n * @remarks\n * `Rating` is a radio group whose radios are stars, so it's one tab stop and the arrow keys move\n * and choose. Stars up to the rating fill with the accent, and hovering previews a rating before\n * you choose. `clearable` lets pressing the chosen star again clear it.\n *\n * @privateRemarks\n * A star rating — a Radix RadioGroup whose radios are stars, so it's one tab stop and the\n * arrow keys move and choose. Stars up to the rating fill with the accent; hovering\n * previews a rating before you choose it. Label it with a `<Field>` (see `RatingField`) or\n * `aria-label`. `onBlur` fires once, when focus leaves the stars.\n *\n * <Rating aria-label=\"Rate this release\" defaultValue={4} clearable />\n */\nexport const Rating = markFieldAware(\n forwardRef<HTMLDivElement, RatingProps>(function Rating(\n {\n value,\n defaultValue = null,\n onValueChange,\n max = 5,\n clearable = false,\n itemLabel = defaultItemLabel,\n name,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n invalid: invalidProp,\n size = 'md',\n id: idProp,\n className,\n onBlur,\n onPointerLeave,\n 'aria-describedby': describedByProp,\n 'aria-invalid': ariaInvalid,\n 'aria-labelledby': labelledByProp,\n ...rest\n },\n ref,\n ) {\n const field = useResolvedField({\n id: idProp,\n describedBy: describedByProp,\n invalid: invalidProp,\n ariaInvalid,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n })\n const [current, setCurrent] = useControllableValue<number | null>(\n value,\n defaultValue,\n onValueChange,\n field.readOnly,\n )\n const [preview, setPreview] = useState<number | null>(null)\n const handleBlur = useFocusLeave(onBlur)\n const interactive = !field.disabled && !field.readOnly\n const shown = preview ?? current ?? 0\n const stars = Array.from({ length: Math.max(0, Math.floor(max)) }, (_, i) => i + 1)\n\n return (\n <RadixRadioGroup.Root\n ref={ref}\n id={field.id}\n className={cx(styles.rating, className)}\n value={current === null ? '' : String(current)}\n onValueChange={(v) => {\n setCurrent(v === '' ? null : Number(v))\n }}\n disabled={field.disabled}\n data-size={size}\n data-invalid={field.invalid || undefined}\n data-readonly={field.readOnly || undefined}\n data-previewing={preview !== null || undefined}\n aria-labelledby={labelledByProp ?? (rest['aria-label'] ? undefined : field.labelId)}\n aria-describedby={field.describedBy}\n aria-invalid={field.invalid || undefined}\n aria-required={field.required || undefined}\n aria-readonly={field.readOnly || undefined}\n aria-busy={field.busy || undefined}\n onBlur={handleBlur}\n onPointerLeave={(event) => {\n setPreview(null)\n onPointerLeave?.(event)\n }}\n {...rest}\n >\n {stars.map((n) => (\n <RadixRadioGroup.Item\n key={n}\n value={String(n)}\n className={styles.star}\n aria-label={itemLabel(n, max)}\n data-filled={n <= shown || undefined}\n onPointerEnter={\n interactive\n ? () => {\n setPreview(n)\n }\n : undefined\n }\n onClick={\n clearable\n ? () => {\n // Radix ignores a click on the checked radio; clearable turns it into \"none\".\n if (current === n) setCurrent(null)\n }\n : undefined\n }\n >\n <StarIcon className={styles.glyph} />\n </RadixRadioGroup.Item>\n ))}\n {name && current !== null ? (\n <input type=\"hidden\" name={name} value={current} disabled={field.disabled || undefined} />\n ) : null}\n </RadixRadioGroup.Root>\n )\n }),\n)\n"],"mappings":";;;;;;;;;AAiCA,IAAMG,KAAoB,GAAW,MAAgB,GAAG,OAAOC,CAAC,EAAE,MAAM,OAAOC,CAAG,KAkBrEC,IAASC,EACpBC,EAAwC,SACtC,EACE,UACA,kBAAe,MACf,kBACA,SAAM,GACN,eAAY,IACZ,eAAYL,GACZ,SACA,UAAUM,GACV,UAAUC,GACV,SAASC,GACT,UAAO,MACP,IAAIC,GACJ,cACA,WACA,mBACA,oBAAoBC,GACpB,gBAAgBC,GAChB,mBAAmBC,GACnB,GAAGC,KAEL,GACA;CACA,IAAMC,IAAQC,EAAiB;EAC7B,IAAIN;EACJ,aAAaC;EACb,SAASF;EACT;EACA,UAAUF;EACV,UAAUC;CACZ,CAAC,GACK,CAACS,GAASC,KAAcC,EAC5BC,GACAC,GACAC,GACAP,EAAM,QACR,GACM,CAACQ,GAASC,KAAcC,EAAwB,IAAI,GACpDC,IAAaC,EAAcC,CAAM,GACjCC,IAAc,CAACd,EAAM,YAAY,CAACA,EAAM,UACxCe,IAAQP,KAAWN,KAAW,GAC9Bc,IAAQ,MAAM,KAAK,EAAE,QAAQ,KAAK,IAAI,GAAG,KAAK,MAA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AAA,IACvF,IACgB;;AAE1B,CAAC,CACH"}
|
|
@@ -3,6 +3,13 @@ import { type RatingProps } from '../Rating/index.js';
|
|
|
3
3
|
export interface RatingFieldProps extends FieldLabelProps, Omit<RatingProps, 'invalid' | keyof FieldLabelProps> {
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
|
+
* A labelled star rating.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* `RatingField` is a {@link Field | Field} around a {@link Rating | Rating}. The stars' radio
|
|
10
|
+
* group is labelled by the field's label and described by its help.
|
|
11
|
+
*
|
|
12
|
+
* @privateRemarks
|
|
6
13
|
* A labelled `Rating`. The stars' radiogroup is labelled by the Field's label and described
|
|
7
14
|
* by its help, warning and error. `className`/`style` go to the Field; `ref`, `id`, `name`
|
|
8
15
|
* and the rest go to the radiogroup.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RatingField.js","names":["RatingField","forwardRef","fieldProps","ratingProps","splitFieldLabelProps","props","Field","id","Rating"],"sources":["../../../../src/components/inputs/RatingField/RatingField.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { Field, type FieldLabelProps } from '#components/inputs/Field'\nimport { splitFieldLabelProps } from '#components/inputs/internal/fieldProps'\nimport { Rating, type RatingProps } from '#components/inputs/Rating'\n\nexport interface RatingFieldProps\n extends FieldLabelProps, Omit<RatingProps, 'invalid' | keyof FieldLabelProps> {}\n\n/**\n * A labelled `Rating`. The stars' radiogroup is labelled by the Field's label and described\n * by its help, warning and error. `className`/`style` go to the Field; `ref`, `id`, `name`\n * and the rest go to the radiogroup.\n *\n * <RatingField label=\"Rate this release\" name=\"rating\" clearable />\n */\nexport const RatingField = forwardRef<HTMLDivElement, RatingFieldProps>(\n function RatingField(props, ref) {\n const [fieldProps, { id, disabled, className, style, ...ratingProps }] =\n splitFieldLabelProps(props)\n return (\n <Field {...fieldProps} htmlFor={id} disabled={disabled} className={className} style={style}>\n <Rating ref={ref} {...ratingProps} />\n </Field>\n )\n },\n)\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"RatingField.js","names":["RatingField","forwardRef","fieldProps","ratingProps","splitFieldLabelProps","props","Field","id","Rating"],"sources":["../../../../src/components/inputs/RatingField/RatingField.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { Field, type FieldLabelProps } from '#components/inputs/Field'\nimport { splitFieldLabelProps } from '#components/inputs/internal/fieldProps'\nimport { Rating, type RatingProps } from '#components/inputs/Rating'\n\nexport interface RatingFieldProps\n extends FieldLabelProps, Omit<RatingProps, 'invalid' | keyof FieldLabelProps> {}\n\n/**\n * A labelled star rating.\n *\n * @remarks\n * `RatingField` is a {@link Field | Field} around a {@link Rating | Rating}. The stars' radio\n * group is labelled by the field's label and described by its help.\n *\n * @privateRemarks\n * A labelled `Rating`. The stars' radiogroup is labelled by the Field's label and described\n * by its help, warning and error. `className`/`style` go to the Field; `ref`, `id`, `name`\n * and the rest go to the radiogroup.\n *\n * <RatingField label=\"Rate this release\" name=\"rating\" clearable />\n */\nexport const RatingField = forwardRef<HTMLDivElement, RatingFieldProps>(\n function RatingField(props, ref) {\n const [fieldProps, { id, disabled, className, style, ...ratingProps }] =\n splitFieldLabelProps(props)\n return (\n <Field {...fieldProps} htmlFor={id} disabled={disabled} className={className} style={style}>\n <Rating ref={ref} {...ratingProps} />\n </Field>\n )\n },\n)\n"],"mappings":";;;;;;AAsBA,IAAaA,IAAcC,EACzB,SAAqB,GAAO,GAAK;CAC/B,IAAM,CAACC,GAAY,EAAE,OAAI,aAAU,cAAW,UAAO,GAAGC,OACtDC,EAAqBC,CAAK;CAC5B,OACE,kBAACC,GAAD;EAAO,GAAIJ;EAAY,SAASK;EAAc;EAAqB;EAAkB;EACnF,UAAA,kBAACC,GAAD;GAAa;GAAK,GAAIL;EAAc,CAAA;CAC/B,CAAA;AAEX,CACF"}
|
|
@@ -3,6 +3,13 @@ import { type FieldLabelProps } from '../Field/index.js';
|
|
|
3
3
|
export interface SegmentedFieldProps extends FieldLabelProps, Omit<SegmentedControlProps, 'children' | 'invalid' | keyof FieldLabelProps> {
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
|
+
* A labelled segmented control for one of two to five peers, always one selected.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* `SegmentedField` is a {@link SegmentedControl | SegmentedControl} with a label, description and
|
|
10
|
+
* error. It always has one segment selected, so it suits choices with a sensible default.
|
|
11
|
+
*
|
|
12
|
+
* @privateRemarks
|
|
6
13
|
* A labelled `SegmentedControl` — one of 2–5 peers, always one selected. The control is
|
|
7
14
|
* labelled by the Field's label and described by its help, warning and error.
|
|
8
15
|
* `className`/`style` go to the Field; `ref`, `id`, `name` and the rest go to the control.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedField.js","names":["SegmentedField","forwardRef","fieldProps","controlProps","splitFieldLabelProps","props","Field","id","SegmentedControl"],"sources":["../../../../src/components/inputs/SegmentedField/SegmentedField.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { SegmentedControl, type SegmentedControlProps } from '#components/actions/SegmentedControl'\nimport { Field, type FieldLabelProps } from '#components/inputs/Field'\nimport { splitFieldLabelProps } from '#components/inputs/internal/fieldProps'\n\nexport interface SegmentedFieldProps\n extends\n FieldLabelProps,\n Omit<SegmentedControlProps, 'children' | 'invalid' | keyof FieldLabelProps> {}\n\n/**\n * A labelled `SegmentedControl` — one of 2–5 peers, always one selected. The control is\n * labelled by the Field's label and described by its help, warning and error.\n * `className`/`style` go to the Field; `ref`, `id`, `name` and the rest go to the control.\n *\n * <SegmentedField label=\"Billing period\" name=\"period\" options={periods} layout=\"horizontal\" />\n */\nexport const SegmentedField = forwardRef<HTMLDivElement, SegmentedFieldProps>(\n function SegmentedField(props, ref) {\n const [fieldProps, { id, disabled, className, style, ...controlProps }] =\n splitFieldLabelProps(props)\n return (\n <Field {...fieldProps} htmlFor={id} disabled={disabled} className={className} style={style}>\n <SegmentedControl ref={ref} {...controlProps} />\n </Field>\n )\n },\n)\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"SegmentedField.js","names":["SegmentedField","forwardRef","fieldProps","controlProps","splitFieldLabelProps","props","Field","id","SegmentedControl"],"sources":["../../../../src/components/inputs/SegmentedField/SegmentedField.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { SegmentedControl, type SegmentedControlProps } from '#components/actions/SegmentedControl'\nimport { Field, type FieldLabelProps } from '#components/inputs/Field'\nimport { splitFieldLabelProps } from '#components/inputs/internal/fieldProps'\n\nexport interface SegmentedFieldProps\n extends\n FieldLabelProps,\n Omit<SegmentedControlProps, 'children' | 'invalid' | keyof FieldLabelProps> {}\n\n/**\n * A labelled segmented control for one of two to five peers, always one selected.\n *\n * @remarks\n * `SegmentedField` is a {@link SegmentedControl | SegmentedControl} with a label, description and\n * error. It always has one segment selected, so it suits choices with a sensible default.\n *\n * @privateRemarks\n * A labelled `SegmentedControl` — one of 2–5 peers, always one selected. The control is\n * labelled by the Field's label and described by its help, warning and error.\n * `className`/`style` go to the Field; `ref`, `id`, `name` and the rest go to the control.\n *\n * <SegmentedField label=\"Billing period\" name=\"period\" options={periods} layout=\"horizontal\" />\n */\nexport const SegmentedField = forwardRef<HTMLDivElement, SegmentedFieldProps>(\n function SegmentedField(props, ref) {\n const [fieldProps, { id, disabled, className, style, ...controlProps }] =\n splitFieldLabelProps(props)\n return (\n <Field {...fieldProps} htmlFor={id} disabled={disabled} className={className} style={style}>\n <SegmentedControl ref={ref} {...controlProps} />\n </Field>\n )\n },\n)\n"],"mappings":";;;;;;AAwBA,IAAaA,IAAiBC,EAC5B,SAAwB,GAAO,GAAK;CAClC,IAAM,CAACC,GAAY,EAAE,OAAI,aAAU,cAAW,UAAO,GAAGC,OACtDC,EAAqBC,CAAK;CAC5B,OACE,kBAACC,GAAD;EAAO,GAAIJ;EAAY,SAASK;EAAc;EAAqB;EAAkB;EACnF,UAAA,kBAACC,GAAD;GAAuB;GAAK,GAAIL;EAAe,CAAA;CAC1C,CAAA;AAEX,CACF"}
|
|
@@ -54,6 +54,15 @@ export interface SelectProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement
|
|
|
54
54
|
required?: boolean;
|
|
55
55
|
autoComplete?: string;
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Pick one option from a list. A styled listbox with keyboard support and native form submission.
|
|
59
|
+
*
|
|
60
|
+
* @remarks
|
|
61
|
+
* `Select` is Radix Select with Kiln's look: a button that opens a listbox, with typeahead, arrow
|
|
62
|
+
* keys and grouped options. Pass `options`, or `groups` for labelled sections. `name` adds a
|
|
63
|
+
* hidden input so it submits with a native form. For a labelled select, use {@link SelectField |
|
|
64
|
+
* SelectField}.
|
|
65
|
+
*/
|
|
57
66
|
export declare const Select: import("react").ForwardRefExoticComponent<SelectProps & import("react").RefAttributes<HTMLButtonElement>> & {
|
|
58
67
|
Root: typeof SelectRoot;
|
|
59
68
|
Trigger: import("react").ForwardRefExoticComponent<SelectTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","names":["RadixSelect","control","styles","Select","control_module_default","Select_module_default","TriggerNodeContext","createContext","SelectRoot","node","setNode","useState","scope","useMemo","Select","props","SelectTrigger","markFieldAware","forwardRef","invalidProp","readOnlyProp","idProp","disabledProp","describedByProp","ariaInvalid","rest","triggerNode","useContext","composedRef","useMergedRefs","ref","field","useResolvedField","cx","className","size","children","ChevronDownIcon","themeScopeOf","SelectContent","container","position","sideOffset","ChevronUpIcon","SelectItem","CheckIcon","SelectGroupPart","SelectLabel","SelectSeparator","SelectBase","onValueChange","options","option","groups","index","group","Select$1"],"sources":["../../../../src/components/inputs/Select/Select.tsx"],"sourcesContent":["import {\n createContext,\n forwardRef,\n useContext,\n useMemo,\n useState,\n type ButtonHTMLAttributes,\n type ComponentPropsWithoutRef,\n type ReactNode,\n} from 'react'\nimport { Select as RadixSelect } from 'radix-ui'\nimport { CheckIcon, ChevronDownIcon, ChevronUpIcon } from '#icons'\nimport { cx } from '#utils/cx'\nimport type { Size } from '#utils/tokens'\nimport { markFieldAware, useResolvedField } from '#components/inputs/internal/FieldContext'\nimport { useMergedRefs } from '#components/inputs/internal/refs'\nimport control from '#components/inputs/internal/control.module.css'\nimport styles from './Select.module.css'\n\nexport interface SelectOption {\n value: string\n label: string\n disabled?: boolean\n}\n\nexport interface SelectGroup {\n label: string\n options: SelectOption[]\n}\n\n/* ─── Compound parts (the escape hatch) ───────────────────────────────────── */\n\n// The trigger's element, so the popover can portal into the same theme scope.\nconst TriggerNodeContext = createContext<{\n node: HTMLElement | null\n setNode: (node: HTMLElement | null) => void\n} | null>(null)\n\nexport type SelectRootProps = ComponentPropsWithoutRef<typeof RadixSelect.Root>\n\n/** State owner. Radix naming: `value` / `defaultValue` / `onValueChange`, `open` / `onOpenChange`. */\nfunction SelectRoot(props: SelectRootProps) {\n const [node, setNode] = useState<HTMLElement | null>(null)\n const scope = useMemo(() => ({ node, setNode }), [node])\n return (\n <TriggerNodeContext.Provider value={scope}>\n <RadixSelect.Root {...props} />\n </TriggerNodeContext.Provider>\n )\n}\n\nexport interface SelectTriggerProps extends Omit<\n ComponentPropsWithoutRef<typeof RadixSelect.Trigger>,\n 'asChild'\n> {\n size?: Size\n invalid?: boolean\n /** Focusable but not editable: sets `aria-readonly`. Gate `onValueChange` at the `Root`. */\n readOnly?: boolean\n /** Shown while no value is chosen. */\n placeholder?: ReactNode\n}\n\n/** The field-styled button. Picks up id / describedby / invalid from a surrounding `<Field>`. */\nconst SelectTrigger = markFieldAware(\n forwardRef<HTMLButtonElement, SelectTriggerProps>(function SelectTrigger(\n {\n size = 'md',\n invalid: invalidProp,\n readOnly: readOnlyProp,\n placeholder,\n id: idProp,\n disabled: disabledProp,\n className,\n children,\n 'aria-describedby': describedByProp,\n 'aria-invalid': ariaInvalid,\n ...rest\n },\n ref,\n ) {\n const triggerNode = useContext(TriggerNodeContext)\n const composedRef = useMergedRefs(ref, triggerNode?.setNode)\n const field = useResolvedField({\n id: idProp,\n describedBy: describedByProp,\n invalid: invalidProp,\n ariaInvalid,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n })\n return (\n <RadixSelect.Trigger\n ref={composedRef}\n id={field.id}\n className={cx(control.box, styles.trigger, className)}\n data-size={size}\n data-invalid={field.invalid || undefined}\n data-disabled={field.disabled || undefined}\n data-readonly={field.readOnly || undefined}\n disabled={field.disabled || undefined}\n aria-readonly={field.readOnly || undefined}\n aria-describedby={field.describedBy}\n aria-invalid={field.invalid || undefined}\n aria-required={field.required || undefined}\n aria-busy={field.busy || undefined}\n {...rest}\n >\n <span className={styles.value}>\n {children ?? <RadixSelect.Value placeholder={placeholder} />}\n </span>\n <RadixSelect.Icon className={styles.chevron}>\n <ChevronDownIcon />\n </RadixSelect.Icon>\n </RadixSelect.Trigger>\n )\n }),\n)\n\nexport interface SelectContentProps extends Omit<\n ComponentPropsWithoutRef<typeof RadixSelect.Content>,\n 'asChild'\n> {\n /**\n * Where to portal the list. Defaults to the trigger's nearest `[data-theme]` scope, so a\n * select inside a `<ThemeScope>` opens in that theme; falls back to `document.body`.\n */\n container?: HTMLElement | null\n}\n\nfunction themeScopeOf(node: HTMLElement | null): HTMLElement | undefined {\n const scope = node?.closest<HTMLElement>('[data-theme]')\n return scope && scope !== node?.ownerDocument.documentElement ? scope : undefined\n}\n\n/** The floating list. Anchored under the trigger, at least as wide as it. */\nconst SelectContent = forwardRef<HTMLDivElement, SelectContentProps>(function SelectContent(\n {\n container,\n position = 'popper',\n sideOffset = 6,\n collisionPadding = 8,\n className,\n children,\n ...rest\n },\n ref,\n) {\n const triggerNode = useContext(TriggerNodeContext)\n return (\n <RadixSelect.Portal container={container ?? themeScopeOf(triggerNode?.node ?? null)}>\n <RadixSelect.Content\n ref={ref}\n position={position}\n sideOffset={position === 'popper' ? sideOffset : undefined}\n collisionPadding={collisionPadding}\n className={cx(styles.content, className)}\n {...rest}\n >\n <RadixSelect.ScrollUpButton className={styles.scroll}>\n <ChevronUpIcon />\n </RadixSelect.ScrollUpButton>\n <RadixSelect.Viewport className={styles.viewport}>{children}</RadixSelect.Viewport>\n <RadixSelect.ScrollDownButton className={styles.scroll}>\n <ChevronDownIcon />\n </RadixSelect.ScrollDownButton>\n </RadixSelect.Content>\n </RadixSelect.Portal>\n )\n})\n\nexport type SelectItemProps = Omit<ComponentPropsWithoutRef<typeof RadixSelect.Item>, 'asChild'>\n\n/** One option. The chosen one carries a check. */\nconst SelectItem = forwardRef<HTMLDivElement, SelectItemProps>(function SelectItem(\n { className, children, ...rest },\n ref,\n) {\n return (\n <RadixSelect.Item ref={ref} className={cx(styles.item, className)} {...rest}>\n <RadixSelect.ItemText>{children}</RadixSelect.ItemText>\n <RadixSelect.ItemIndicator className={styles.indicator}>\n <CheckIcon />\n </RadixSelect.ItemIndicator>\n </RadixSelect.Item>\n )\n})\n\nexport type SelectGroupProps = Omit<ComponentPropsWithoutRef<typeof RadixSelect.Group>, 'asChild'>\n\nconst SelectGroupPart = forwardRef<HTMLDivElement, SelectGroupProps>(function SelectGroup(\n { className, ...rest },\n ref,\n) {\n return <RadixSelect.Group ref={ref} className={cx(styles.group, className)} {...rest} />\n})\n\nexport type SelectLabelProps = Omit<ComponentPropsWithoutRef<typeof RadixSelect.Label>, 'asChild'>\n\n/** A group heading inside the list. */\nconst SelectLabel = forwardRef<HTMLDivElement, SelectLabelProps>(function SelectLabel(\n { className, ...rest },\n ref,\n) {\n return <RadixSelect.Label ref={ref} className={cx(styles.label, className)} {...rest} />\n})\n\nexport type SelectSeparatorProps = Omit<\n ComponentPropsWithoutRef<typeof RadixSelect.Separator>,\n 'asChild'\n>\n\nconst SelectSeparator = forwardRef<HTMLDivElement, SelectSeparatorProps>(function SelectSeparator(\n { className, ...rest },\n ref,\n) {\n return <RadixSelect.Separator ref={ref} className={cx(styles.separator, className)} {...rest} />\n})\n\n/* ─── Simple API ──────────────────────────────────────────────────────────── */\n\nexport interface SelectProps extends Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n 'value' | 'defaultValue' | 'onChange' | 'dir' | 'placeholder'\n> {\n /** Flat list of options. */\n options?: SelectOption[]\n /** Or headed groups (rendered after `options` if both are given). */\n groups?: SelectGroup[]\n value?: string\n defaultValue?: string\n onValueChange?: (value: string) => void\n open?: boolean\n defaultOpen?: boolean\n onOpenChange?: (open: boolean) => void\n placeholder?: ReactNode\n size?: Size\n /** Critical border + `aria-invalid`. Inside a `<Field error>` this is set for you. */\n invalid?: boolean\n /** Focusable but not editable: sets `aria-readonly` and ignores value changes. */\n readOnly?: boolean\n /** Submitted with a native `<form>` under this name. */\n name?: string\n required?: boolean\n autoComplete?: string\n}\n\n/**\n * A single-choice dropdown. Pass `options` (or `groups`) for the common case; compose\n * `Select.Root` / `Trigger` / `Content` / `Item` / `Group` / `Label` for anything custom.\n * The ref and native button props go to the trigger.\n *\n * <Select options={categories} placeholder=\"Choose a category\" onValueChange={setCategory} />\n */\nconst SelectBase = forwardRef<HTMLButtonElement, SelectProps>(function Select(\n {\n options,\n groups,\n value,\n defaultValue,\n onValueChange,\n open,\n defaultOpen,\n onOpenChange,\n placeholder,\n size,\n invalid,\n readOnly,\n name,\n required,\n disabled,\n autoComplete,\n form,\n ...rest\n },\n ref,\n) {\n const field = useResolvedField({ disabled, required, readOnly })\n return (\n <SelectRoot\n value={value}\n defaultValue={defaultValue}\n onValueChange={field.readOnly ? undefined : onValueChange}\n open={open}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n name={name}\n required={required}\n disabled={field.disabled}\n autoComplete={autoComplete}\n form={form}\n >\n <SelectTrigger\n ref={ref}\n size={size}\n invalid={invalid}\n readOnly={field.readOnly}\n placeholder={placeholder}\n {...rest}\n />\n <SelectContent>\n {options?.map((option) => (\n <SelectItem key={option.value} value={option.value} disabled={option.disabled}>\n {option.label}\n </SelectItem>\n ))}\n {groups?.map((group, index) => (\n <SelectGroupPart key={group.label}>\n {index > 0 || (options && options.length > 0) ? <SelectSeparator /> : null}\n <SelectLabel>{group.label}</SelectLabel>\n {group.options.map((option) => (\n <SelectItem key={option.value} value={option.value} disabled={option.disabled}>\n {option.label}\n </SelectItem>\n ))}\n </SelectGroupPart>\n ))}\n </SelectContent>\n </SelectRoot>\n )\n})\n\nexport const Select = markFieldAware(\n Object.assign(SelectBase, {\n Root: SelectRoot,\n Trigger: SelectTrigger,\n Content: SelectContent,\n Item: SelectItem,\n Group: SelectGroupPart,\n Label: SelectLabel,\n Separator: SelectSeparator,\n }),\n)\n"],"mappings":";;;;;;;;;;AAiCA,IAAMM,IAAqBC,EAGjB,IAAI;AAKd,SAASC,EAAW,GAAwB;CAC1C,IAAM,CAACC,GAAMC,KAAWC,EAA6B,IAAI,GACnDC,IAAQC,SAAe;EAAE;EAAM;CAAQ,IAAI,CAACJ,CAAI,CAAC;CACvD,OACE,kBAACH,EAAmB,UAApB;EAA6B,OAAOM;EAClC,UAAA,kBAACZ,EAAY,MAAb,EAAkB,GAAIe,EAAQ,CAAA;CACH,CAAA;AAEjC;AAeA,IAAMC,IAAgBC,EACpBC,EAAkD,SAChD,EACE,UAAO,MACP,SAASC,GACT,UAAUC,GACV,gBACA,IAAIC,GACJ,UAAUC,GACV,cACA,aACA,oBAAoBC,GACpB,gBAAgBC,GAChB,GAAGC,KAEL,GACA;CACA,IAAMC,IAAcC,EAAWrB,CAAkB,GAC3CsB,IAAcC,EAAcC,GAAKJ,GAAa,OAAO,GACrDK,IAAQC,EAAiB;EAC7B,IAAIX;EACJ,aAAaE;EACb,SAASJ;EACT;EACA,UAAUG;EACV,UAAUF;CACZ,CAAC;CACD,OACE,kBAACpB,EAAY,SAAb;EACE,KAAK4B;EACL,IAAIG,EAAM;EACV,WAAWE,EAAGhC,EAAQ,KAAKC,EAAO,SAASgC,CAAS;EACpD,aAAWC;EACX,gBAAcJ,EAAM,WAAW,KAAA;EAC/B,iBAAeA,EAAM,YAAY,KAAA;EACjC,iBAAeA,EAAM,YAAY,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EACR;EAXR,UAAA,CAaE,kBAACf,GAAD;GACO;GACC;GACG;GACT,UAAUe,EAAM;GACH;GACb,GAAIN;EACL,CAAA,GACD,kBAACc,GAAD,EAAA,UAAA,CACGY,GAAS,KAAK,MACb,kBAACP,GAAD;GAA+B,OAAOQ,EAAO;GAAO,UAAUA,EAAO;GAClE,UAAAA,EAAO;EACE,GAFKA,EAAO,KAEZ,CACb,GACAC,GAAQ,KAAK,GAAO,MACnB,kBAACP,GAAD,EAAA,UAAA;GACGQ,IAAQ,KAAMH,KAAWA,EAAQ,SAAS,IAAK,kBAACH,GAAD,CAAkB,CAAA,IAAI;GACtE,kBAACD,GAAD,EAAA,UAAcQ,EAAM,MAAmB,CAAA;GACtCA,EAAM,QAAQ,KAAK,MAClB,kBAACX,GAAD;IAA+B,OAAOQ,EAAO;IAAO,UAAUA,EAAO;IAClE,UAAAA,EAAO;GACE,GAFKA,EAAO,KAEZ,CACb;EACc,EAAA,GARKG,EAAM,KAQX,CAClB,CACY,EAAA,CAAA,CACL;;AAEhB,CAAC,GAEYpD,IAASc,EACpB,OAAO,OAAOgC,GAAY;CACxB,MAAMzC;CACN,SAASQ;CACT,SAASuB;CACT,MAAMK;CACN,OAAOE;CACP,OAAOC;CACP,WAAWC;AACb,CAAC,CACH"}
|
|
1
|
+
{"version":3,"file":"Select.js","names":["RadixSelect","control","styles","Select","control_module_default","Select_module_default","TriggerNodeContext","createContext","SelectRoot","node","setNode","useState","scope","useMemo","Select","props","SelectTrigger","markFieldAware","forwardRef","invalidProp","readOnlyProp","idProp","disabledProp","describedByProp","ariaInvalid","rest","triggerNode","useContext","composedRef","useMergedRefs","ref","field","useResolvedField","cx","className","size","children","ChevronDownIcon","themeScopeOf","SelectContent","container","position","sideOffset","ChevronUpIcon","SelectItem","CheckIcon","SelectGroupPart","SelectLabel","SelectSeparator","SelectBase","onValueChange","options","option","groups","index","group","Select$1"],"sources":["../../../../src/components/inputs/Select/Select.tsx"],"sourcesContent":["import {\n createContext,\n forwardRef,\n useContext,\n useMemo,\n useState,\n type ButtonHTMLAttributes,\n type ComponentPropsWithoutRef,\n type ReactNode,\n} from 'react'\nimport { Select as RadixSelect } from 'radix-ui'\nimport { CheckIcon, ChevronDownIcon, ChevronUpIcon } from '#icons'\nimport { cx } from '#utils/cx'\nimport type { Size } from '#utils/tokens'\nimport { markFieldAware, useResolvedField } from '#components/inputs/internal/FieldContext'\nimport { useMergedRefs } from '#components/inputs/internal/refs'\nimport control from '#components/inputs/internal/control.module.css'\nimport styles from './Select.module.css'\n\nexport interface SelectOption {\n value: string\n label: string\n disabled?: boolean\n}\n\nexport interface SelectGroup {\n label: string\n options: SelectOption[]\n}\n\n/* ─── Compound parts (the escape hatch) ───────────────────────────────────── */\n\n// The trigger's element, so the popover can portal into the same theme scope.\nconst TriggerNodeContext = createContext<{\n node: HTMLElement | null\n setNode: (node: HTMLElement | null) => void\n} | null>(null)\n\nexport type SelectRootProps = ComponentPropsWithoutRef<typeof RadixSelect.Root>\n\n/** State owner. Radix naming: `value` / `defaultValue` / `onValueChange`, `open` / `onOpenChange`. */\nfunction SelectRoot(props: SelectRootProps) {\n const [node, setNode] = useState<HTMLElement | null>(null)\n const scope = useMemo(() => ({ node, setNode }), [node])\n return (\n <TriggerNodeContext.Provider value={scope}>\n <RadixSelect.Root {...props} />\n </TriggerNodeContext.Provider>\n )\n}\n\nexport interface SelectTriggerProps extends Omit<\n ComponentPropsWithoutRef<typeof RadixSelect.Trigger>,\n 'asChild'\n> {\n size?: Size\n invalid?: boolean\n /** Focusable but not editable: sets `aria-readonly`. Gate `onValueChange` at the `Root`. */\n readOnly?: boolean\n /** Shown while no value is chosen. */\n placeholder?: ReactNode\n}\n\n/** The field-styled button. Picks up id / describedby / invalid from a surrounding `<Field>`. */\nconst SelectTrigger = markFieldAware(\n forwardRef<HTMLButtonElement, SelectTriggerProps>(function SelectTrigger(\n {\n size = 'md',\n invalid: invalidProp,\n readOnly: readOnlyProp,\n placeholder,\n id: idProp,\n disabled: disabledProp,\n className,\n children,\n 'aria-describedby': describedByProp,\n 'aria-invalid': ariaInvalid,\n ...rest\n },\n ref,\n ) {\n const triggerNode = useContext(TriggerNodeContext)\n const composedRef = useMergedRefs(ref, triggerNode?.setNode)\n const field = useResolvedField({\n id: idProp,\n describedBy: describedByProp,\n invalid: invalidProp,\n ariaInvalid,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n })\n return (\n <RadixSelect.Trigger\n ref={composedRef}\n id={field.id}\n className={cx(control.box, styles.trigger, className)}\n data-size={size}\n data-invalid={field.invalid || undefined}\n data-disabled={field.disabled || undefined}\n data-readonly={field.readOnly || undefined}\n disabled={field.disabled || undefined}\n aria-readonly={field.readOnly || undefined}\n aria-describedby={field.describedBy}\n aria-invalid={field.invalid || undefined}\n aria-required={field.required || undefined}\n aria-busy={field.busy || undefined}\n {...rest}\n >\n <span className={styles.value}>\n {children ?? <RadixSelect.Value placeholder={placeholder} />}\n </span>\n <RadixSelect.Icon className={styles.chevron}>\n <ChevronDownIcon />\n </RadixSelect.Icon>\n </RadixSelect.Trigger>\n )\n }),\n)\n\nexport interface SelectContentProps extends Omit<\n ComponentPropsWithoutRef<typeof RadixSelect.Content>,\n 'asChild'\n> {\n /**\n * Where to portal the list. Defaults to the trigger's nearest `[data-theme]` scope, so a\n * select inside a `<ThemeScope>` opens in that theme; falls back to `document.body`.\n */\n container?: HTMLElement | null\n}\n\nfunction themeScopeOf(node: HTMLElement | null): HTMLElement | undefined {\n const scope = node?.closest<HTMLElement>('[data-theme]')\n return scope && scope !== node?.ownerDocument.documentElement ? scope : undefined\n}\n\n/** The floating list. Anchored under the trigger, at least as wide as it. */\nconst SelectContent = forwardRef<HTMLDivElement, SelectContentProps>(function SelectContent(\n {\n container,\n position = 'popper',\n sideOffset = 6,\n collisionPadding = 8,\n className,\n children,\n ...rest\n },\n ref,\n) {\n const triggerNode = useContext(TriggerNodeContext)\n return (\n <RadixSelect.Portal container={container ?? themeScopeOf(triggerNode?.node ?? null)}>\n <RadixSelect.Content\n ref={ref}\n position={position}\n sideOffset={position === 'popper' ? sideOffset : undefined}\n collisionPadding={collisionPadding}\n className={cx(styles.content, className)}\n {...rest}\n >\n <RadixSelect.ScrollUpButton className={styles.scroll}>\n <ChevronUpIcon />\n </RadixSelect.ScrollUpButton>\n <RadixSelect.Viewport className={styles.viewport}>{children}</RadixSelect.Viewport>\n <RadixSelect.ScrollDownButton className={styles.scroll}>\n <ChevronDownIcon />\n </RadixSelect.ScrollDownButton>\n </RadixSelect.Content>\n </RadixSelect.Portal>\n )\n})\n\nexport type SelectItemProps = Omit<ComponentPropsWithoutRef<typeof RadixSelect.Item>, 'asChild'>\n\n/** One option. The chosen one carries a check. */\nconst SelectItem = forwardRef<HTMLDivElement, SelectItemProps>(function SelectItem(\n { className, children, ...rest },\n ref,\n) {\n return (\n <RadixSelect.Item ref={ref} className={cx(styles.item, className)} {...rest}>\n <RadixSelect.ItemText>{children}</RadixSelect.ItemText>\n <RadixSelect.ItemIndicator className={styles.indicator}>\n <CheckIcon />\n </RadixSelect.ItemIndicator>\n </RadixSelect.Item>\n )\n})\n\nexport type SelectGroupProps = Omit<ComponentPropsWithoutRef<typeof RadixSelect.Group>, 'asChild'>\n\nconst SelectGroupPart = forwardRef<HTMLDivElement, SelectGroupProps>(function SelectGroup(\n { className, ...rest },\n ref,\n) {\n return <RadixSelect.Group ref={ref} className={cx(styles.group, className)} {...rest} />\n})\n\nexport type SelectLabelProps = Omit<ComponentPropsWithoutRef<typeof RadixSelect.Label>, 'asChild'>\n\n/** A group heading inside the list. */\nconst SelectLabel = forwardRef<HTMLDivElement, SelectLabelProps>(function SelectLabel(\n { className, ...rest },\n ref,\n) {\n return <RadixSelect.Label ref={ref} className={cx(styles.label, className)} {...rest} />\n})\n\nexport type SelectSeparatorProps = Omit<\n ComponentPropsWithoutRef<typeof RadixSelect.Separator>,\n 'asChild'\n>\n\nconst SelectSeparator = forwardRef<HTMLDivElement, SelectSeparatorProps>(function SelectSeparator(\n { className, ...rest },\n ref,\n) {\n return <RadixSelect.Separator ref={ref} className={cx(styles.separator, className)} {...rest} />\n})\n\n/* ─── Simple API ──────────────────────────────────────────────────────────── */\n\nexport interface SelectProps extends Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n 'value' | 'defaultValue' | 'onChange' | 'dir' | 'placeholder'\n> {\n /** Flat list of options. */\n options?: SelectOption[]\n /** Or headed groups (rendered after `options` if both are given). */\n groups?: SelectGroup[]\n value?: string\n defaultValue?: string\n onValueChange?: (value: string) => void\n open?: boolean\n defaultOpen?: boolean\n onOpenChange?: (open: boolean) => void\n placeholder?: ReactNode\n size?: Size\n /** Critical border + `aria-invalid`. Inside a `<Field error>` this is set for you. */\n invalid?: boolean\n /** Focusable but not editable: sets `aria-readonly` and ignores value changes. */\n readOnly?: boolean\n /** Submitted with a native `<form>` under this name. */\n name?: string\n required?: boolean\n autoComplete?: string\n}\n\n/**\n * A single-choice dropdown. Pass `options` (or `groups`) for the common case; compose\n * `Select.Root` / `Trigger` / `Content` / `Item` / `Group` / `Label` for anything custom.\n * The ref and native button props go to the trigger.\n *\n * <Select options={categories} placeholder=\"Choose a category\" onValueChange={setCategory} />\n */\nconst SelectBase = forwardRef<HTMLButtonElement, SelectProps>(function Select(\n {\n options,\n groups,\n value,\n defaultValue,\n onValueChange,\n open,\n defaultOpen,\n onOpenChange,\n placeholder,\n size,\n invalid,\n readOnly,\n name,\n required,\n disabled,\n autoComplete,\n form,\n ...rest\n },\n ref,\n) {\n const field = useResolvedField({ disabled, required, readOnly })\n return (\n <SelectRoot\n value={value}\n defaultValue={defaultValue}\n onValueChange={field.readOnly ? undefined : onValueChange}\n open={open}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n name={name}\n required={required}\n disabled={field.disabled}\n autoComplete={autoComplete}\n form={form}\n >\n <SelectTrigger\n ref={ref}\n size={size}\n invalid={invalid}\n readOnly={field.readOnly}\n placeholder={placeholder}\n {...rest}\n />\n <SelectContent>\n {options?.map((option) => (\n <SelectItem key={option.value} value={option.value} disabled={option.disabled}>\n {option.label}\n </SelectItem>\n ))}\n {groups?.map((group, index) => (\n <SelectGroupPart key={group.label}>\n {index > 0 || (options && options.length > 0) ? <SelectSeparator /> : null}\n <SelectLabel>{group.label}</SelectLabel>\n {group.options.map((option) => (\n <SelectItem key={option.value} value={option.value} disabled={option.disabled}>\n {option.label}\n </SelectItem>\n ))}\n </SelectGroupPart>\n ))}\n </SelectContent>\n </SelectRoot>\n )\n})\n\n/**\n * Pick one option from a list. A styled listbox with keyboard support and native form submission.\n *\n * @remarks\n * `Select` is Radix Select with Kiln's look: a button that opens a listbox, with typeahead, arrow\n * keys and grouped options. Pass `options`, or `groups` for labelled sections. `name` adds a\n * hidden input so it submits with a native form. For a labelled select, use {@link SelectField |\n * SelectField}.\n */\nexport const Select = markFieldAware(\n Object.assign(SelectBase, {\n Root: SelectRoot,\n Trigger: SelectTrigger,\n Content: SelectContent,\n Item: SelectItem,\n Group: SelectGroupPart,\n Label: SelectLabel,\n Separator: SelectSeparator,\n }),\n)\n"],"mappings":";;;;;;;;;;AAiCA,IAAMM,IAAqBC,EAGjB,IAAI;AAKd,SAASC,EAAW,GAAwB;CAC1C,IAAM,CAACC,GAAMC,KAAWC,EAA6B,IAAI,GACnDC,IAAQC,SAAe;EAAE;EAAM;CAAQ,IAAI,CAACJ,CAAI,CAAC;CACvD,OACE,kBAACH,EAAmB,UAApB;EAA6B,OAAOM;EAClC,UAAA,kBAACZ,EAAY,MAAb,EAAkB,GAAIe,EAAQ,CAAA;CACH,CAAA;AAEjC;AAeA,IAAMC,IAAgBC,EACpBC,EAAkD,SAChD,EACE,UAAO,MACP,SAASC,GACT,UAAUC,GACV,gBACA,IAAIC,GACJ,UAAUC,GACV,cACA,aACA,oBAAoBC,GACpB,gBAAgBC,GAChB,GAAGC,KAEL,GACA;CACA,IAAMC,IAAcC,EAAWrB,CAAkB,GAC3CsB,IAAcC,EAAcC,GAAKJ,GAAa,OAAO,GACrDK,IAA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a/B,EAA2C,SAC5D,EACE,YACA,WACA,UACA,iBACA,kBACA,SACA,gBACA,iBACA,gBACA,SACA,YACA,aACA,SACA,aACA,aACA,iBACA,SACA,GAAGO,KAEL,GACA;CACA,IAAMM,IAAQC,EAAiB;EAAE;EAAU;EAAU;CAAS,CAAC;CAC/D,OACE,kBAACxB,GAAD;EACS;EACO;EACd,eAAeuB,EAAM,WAAW,KAAA,IAAYmB;EACtC;EACO;EACC;EACR;EACI;EACV,UAAUnB,EAAM;EACF;EACR;EAXR,UAAA,CAaE,kBAACf,GAAD;GACO;GACC;GACG;GACT,UAAUe,EAAM;GACH;GACb,GAAIN;EACL,CAAA,GACD,kBAACc,GAAD,EAAA,UAAA,CACGY,GAAS,KAAK,MACb,kBAACP,GAAD;GAA+B,OAAOQ,EAAO;GAAO,UAAUA,EAAO;GAClE,UAAAA,EAAO;EACE,GAFKA,EAAO,KAEZ,CACb,GACAC,GAAQ,KAAK,GAAO,MACnB,kBAACP,GAAD,EAAA,UAAA;GACGQ,IAAQ,KAAMH,KAAWA,EAAQ,SAAS,IAAK,kBAACH,GAAD,CAAkB,CAAA,IAAI;GACtE,kBAACD,GAAD,EAAA,UAAcQ,EAAM,MAAmB,CAAA;GACtCA,EAAM,QAAQ,KAAK,MAClB,kBAACX,GAAD;IAA+B,OAAOQ,EAAO;IAAO,UAAUA,EAAO;IAClE,UAAAA,EAAO;GACE,GAFKA,EAAO,KAEZ,CACb;EACc,EAAA,GARKG,EAAM,KAQX,CAClB,CACY,EAAA,CAAA,CACL;;AAEhB,CAAC,GAWYpD,IAASc,EACpB,OAAO,OAAOgC,GAAY;CACxB,MAAMzC;CACN,SAASQ;CACT,SAASuB;CACT,MAAMK;CACN,OAAOE;CACP,OAAOC;CACP,WAAWC;AACb,CAAC,CACH"}
|
|
@@ -4,6 +4,13 @@ export type { SelectOption, SelectGroup } from '../Select/index.js';
|
|
|
4
4
|
export interface SelectFieldProps extends FieldLabelProps, Omit<SelectProps, 'invalid'> {
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
|
+
* A labelled select with description, error and warning.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* `SelectField` is a {@link Field | Field} around a {@link Select | Select}. Select props
|
|
11
|
+
* (`options`, `groups`, `value`, `placeholder`) go to the select.
|
|
12
|
+
*
|
|
13
|
+
* @privateRemarks
|
|
7
14
|
* Label + Select + description + error. Select props (`options`, `value`,
|
|
8
15
|
* `onValueChange`, `placeholder`…) and the ref go to the trigger; `className`/`style` go
|
|
9
16
|
* to the field wrapper.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectField.js","names":["SelectField","forwardRef","fieldProps","rest","splitFieldLabelProps","props","selectRest","Field","id","Select"],"sources":["../../../../src/components/inputs/SelectField/SelectField.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { Field, type FieldLabelProps } from '#components/inputs/Field'\nimport { Select, type SelectProps } from '#components/inputs/Select'\nimport { splitFieldLabelProps } from '#components/inputs/internal/fieldProps'\n\nexport type { SelectOption, SelectGroup } from '#components/inputs/Select'\n\nexport interface SelectFieldProps extends FieldLabelProps, Omit<SelectProps, 'invalid'> {}\n\n/**\n * Label + Select + description + error. Select props (`options`, `value`,\n * `onValueChange`, `placeholder`…) and the ref go to the trigger; `className`/`style` go\n * to the field wrapper.\n *\n * <SelectField label=\"Category\" options={categories} placeholder=\"Choose one\" required />\n */\nexport const SelectField = forwardRef<HTMLButtonElement, SelectFieldProps>(\n function SelectField(props, ref) {\n const [fieldProps, rest] = splitFieldLabelProps(props)\n const { id, disabled, className, style, ...selectRest } = rest\n return (\n <Field {...fieldProps} htmlFor={id} disabled={disabled} className={className} style={style}>\n <Select ref={ref} id={id} disabled={disabled} {...selectRest} />\n </Field>\n )\n },\n)\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"SelectField.js","names":["SelectField","forwardRef","fieldProps","rest","splitFieldLabelProps","props","selectRest","Field","id","Select"],"sources":["../../../../src/components/inputs/SelectField/SelectField.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { Field, type FieldLabelProps } from '#components/inputs/Field'\nimport { Select, type SelectProps } from '#components/inputs/Select'\nimport { splitFieldLabelProps } from '#components/inputs/internal/fieldProps'\n\nexport type { SelectOption, SelectGroup } from '#components/inputs/Select'\n\nexport interface SelectFieldProps extends FieldLabelProps, Omit<SelectProps, 'invalid'> {}\n\n/**\n * A labelled select with description, error and warning.\n *\n * @remarks\n * `SelectField` is a {@link Field | Field} around a {@link Select | Select}. Select props\n * (`options`, `groups`, `value`, `placeholder`) go to the select.\n *\n * @privateRemarks\n * Label + Select + description + error. Select props (`options`, `value`,\n * `onValueChange`, `placeholder`…) and the ref go to the trigger; `className`/`style` go\n * to the field wrapper.\n *\n * <SelectField label=\"Category\" options={categories} placeholder=\"Choose one\" required />\n */\nexport const SelectField = forwardRef<HTMLButtonElement, SelectFieldProps>(\n function SelectField(props, ref) {\n const [fieldProps, rest] = splitFieldLabelProps(props)\n const { id, disabled, className, style, ...selectRest } = rest\n return (\n <Field {...fieldProps} htmlFor={id} disabled={disabled} className={className} style={style}>\n <Select ref={ref} id={id} disabled={disabled} {...selectRest} />\n </Field>\n )\n },\n)\n"],"mappings":";;;;;;AAuBA,IAAaA,IAAcC,EACzB,SAAqB,GAAO,GAAK;CAC/B,IAAM,CAACC,GAAYC,KAAQC,EAAqBC,CAAK,GAC/C,EAAE,OAAI,aAAU,cAAW,UAAO,GAAGC,MAAeH;CAC1D,OACE,kBAACI,GAAD;EAAO,GAAIL;EAAY,SAASM;EAAc;EAAqB;EAAkB;EACnF,UAAA,kBAACC,GAAD;GAAa;GAAS;GAAc;GAAU,GAAIH;EAAa,CAAA;CAC1D,CAAA;AAEX,CACF"}
|
|
@@ -30,6 +30,14 @@ export interface SliderProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'onCh
|
|
|
30
30
|
size?: SliderSize;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
+
* One number from a continuous range, by dragging or with the arrow keys.
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* `Slider` is Radix Slider with Kiln's look. Arrow keys step, Page Up and Page Down step by ten,
|
|
37
|
+
* and Home and End jump to the ends. Label it with a Field (see {@link SliderField | SliderField})
|
|
38
|
+
* or an `aria-label`.
|
|
39
|
+
*
|
|
40
|
+
* @privateRemarks
|
|
33
41
|
* One number from a continuous range (Radix Slider). Arrow keys step, Page Up/Down step
|
|
34
42
|
* by ten, Home/End jump to the ends. Label it with a `<Field>` (see `SliderField`) or
|
|
35
43
|
* `aria-label`. The ref and `id` go to the thumb — the focusable `role="slider"`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slider.js","names":["Slider","markFieldAware","forwardRef","disabledProp","readOnlyProp","invalidProp","idProp","ariaLabel","labelledByProp","describedByProp","ariaInvalid","rest","autoId","useId","field","useResolvedField","current","setCurrent","useControllableValue","value","defaultValue","min","onValueChange","handleBlur","useFocusLeave","onBlur","SliderBase","next","onValueCommit"],"sources":["../../../../src/components/inputs/Slider/Slider.tsx"],"sourcesContent":["import { forwardRef, useId, type HTMLAttributes } from 'react'\nimport { useControllableValue, useFocusLeave } from '#components/inputs/CheckboxGroup/choice'\nimport { markFieldAware, useResolvedField } from '#components/inputs/internal/FieldContext'\nimport { SliderBase, type SliderMark, type SliderSize } from './SliderBase'\n\nexport type { SliderMark, SliderSize } from './SliderBase'\n\nexport interface SliderProps extends Omit<\n HTMLAttributes<HTMLSpanElement>,\n 'onChange' | 'defaultValue' | 'dir'\n> {\n /** Controlled value. */\n value?: number\n /** Initial value when uncontrolled. Defaults to `min`. */\n defaultValue?: number\n /** Every change while dragging or stepping. */\n onValueChange?: (value: number) => void\n /** Once, when the user lets go (or after each key press). */\n onValueCommit?: (value: number) => void\n min?: number\n max?: number\n step?: number\n /** Labelled stops under the track. A thumb on a mark reads the mark's label. */\n marks?: readonly SliderMark[]\n /** Shows the formatted value beside the track, in tabular figures. */\n showValue?: boolean\n /** Formats the shown value and the thumb's `aria-valuetext` (\"£2,500\"). */\n formatOptions?: Intl.NumberFormatOptions\n locale?: string\n /** Emits a hidden input with the value, for native form submission. */\n name?: string\n disabled?: boolean\n /** Focusable but not editable: sets `aria-readonly` and ignores changes. */\n readOnly?: boolean\n /** Critical edge on the thumb + `aria-invalid`. Inside a `<Field error>` this is set for you. */\n invalid?: boolean\n size?: SliderSize\n}\n\n/**\n * One number from a continuous range (Radix Slider). Arrow keys step, Page Up/Down step\n * by ten, Home/End jump to the ends. Label it with a `<Field>` (see `SliderField`) or\n * `aria-label`. The ref and `id` go to the thumb — the focusable `role=\"slider\"`;\n * `className`/`style` and other props go to the wrapper. `onBlur` fires when focus leaves.\n *\n * <Slider aria-label=\"Discount rate\" defaultValue={20} step={5} showValue formatOptions={{ style: 'unit', unit: 'percent' }} />\n */\nexport const Slider = markFieldAware(\n forwardRef<HTMLSpanElement, SliderProps>(function Slider(\n {\n value,\n defaultValue,\n onValueChange,\n onValueCommit,\n min = 0,\n max = 100,\n step = 1,\n marks,\n showValue = false,\n formatOptions,\n locale,\n name,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n invalid: invalidProp,\n size = 'md',\n id: idProp,\n onBlur,\n 'aria-label': ariaLabel,\n 'aria-labelledby': labelledByProp,\n 'aria-describedby': describedByProp,\n 'aria-invalid': ariaInvalid,\n ...rest\n },\n ref,\n ) {\n const autoId = useId()\n const field = useResolvedField({\n id: idProp,\n describedBy: describedByProp,\n invalid: invalidProp,\n ariaInvalid,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n })\n const [current, setCurrent] = useControllableValue(\n value,\n defaultValue ?? min,\n onValueChange,\n field.readOnly,\n )\n const handleBlur = useFocusLeave(onBlur)\n\n return (\n <SliderBase\n {...rest}\n onBlur={handleBlur}\n values={[current]}\n onValuesChange={(next) => {\n setCurrent(next[0] ?? min)\n }}\n onValuesCommit={(next) => onValueCommit?.(next[0] ?? min)}\n min={min}\n max={max}\n step={step}\n marks={marks}\n showValue={showValue}\n formatOptions={formatOptions}\n locale={locale}\n name={name}\n disabled={field.disabled}\n readOnly={field.readOnly}\n invalid={field.invalid}\n size={size}\n thumbs={[\n {\n id: field.id ?? `${autoId}thumb`,\n ref,\n 'aria-label': ariaLabel,\n 'aria-labelledby': labelledByProp ?? (ariaLabel ? undefined : field.labelId),\n 'aria-describedby': field.describedBy,\n 'aria-invalid': field.invalid || undefined,\n 'aria-readonly': field.readOnly || undefined,\n 'aria-busy': field.busy || undefined,\n },\n ]}\n />\n )\n }),\n)\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"Slider.js","names":["Slider","markFieldAware","forwardRef","disabledProp","readOnlyProp","invalidProp","idProp","ariaLabel","labelledByProp","describedByProp","ariaInvalid","rest","autoId","useId","field","useResolvedField","current","setCurrent","useControllableValue","value","defaultValue","min","onValueChange","handleBlur","useFocusLeave","onBlur","SliderBase","next","onValueCommit"],"sources":["../../../../src/components/inputs/Slider/Slider.tsx"],"sourcesContent":["import { forwardRef, useId, type HTMLAttributes } from 'react'\nimport { useControllableValue, useFocusLeave } from '#components/inputs/CheckboxGroup/choice'\nimport { markFieldAware, useResolvedField } from '#components/inputs/internal/FieldContext'\nimport { SliderBase, type SliderMark, type SliderSize } from './SliderBase'\n\nexport type { SliderMark, SliderSize } from './SliderBase'\n\nexport interface SliderProps extends Omit<\n HTMLAttributes<HTMLSpanElement>,\n 'onChange' | 'defaultValue' | 'dir'\n> {\n /** Controlled value. */\n value?: number\n /** Initial value when uncontrolled. Defaults to `min`. */\n defaultValue?: number\n /** Every change while dragging or stepping. */\n onValueChange?: (value: number) => void\n /** Once, when the user lets go (or after each key press). */\n onValueCommit?: (value: number) => void\n min?: number\n max?: number\n step?: number\n /** Labelled stops under the track. A thumb on a mark reads the mark's label. */\n marks?: readonly SliderMark[]\n /** Shows the formatted value beside the track, in tabular figures. */\n showValue?: boolean\n /** Formats the shown value and the thumb's `aria-valuetext` (\"£2,500\"). */\n formatOptions?: Intl.NumberFormatOptions\n locale?: string\n /** Emits a hidden input with the value, for native form submission. */\n name?: string\n disabled?: boolean\n /** Focusable but not editable: sets `aria-readonly` and ignores changes. */\n readOnly?: boolean\n /** Critical edge on the thumb + `aria-invalid`. Inside a `<Field error>` this is set for you. */\n invalid?: boolean\n size?: SliderSize\n}\n\n/**\n * One number from a continuous range, by dragging or with the arrow keys.\n *\n * @remarks\n * `Slider` is Radix Slider with Kiln's look. Arrow keys step, Page Up and Page Down step by ten,\n * and Home and End jump to the ends. Label it with a Field (see {@link SliderField | SliderField})\n * or an `aria-label`.\n *\n * @privateRemarks\n * One number from a continuous range (Radix Slider). Arrow keys step, Page Up/Down step\n * by ten, Home/End jump to the ends. Label it with a `<Field>` (see `SliderField`) or\n * `aria-label`. The ref and `id` go to the thumb — the focusable `role=\"slider\"`;\n * `className`/`style` and other props go to the wrapper. `onBlur` fires when focus leaves.\n *\n * <Slider aria-label=\"Discount rate\" defaultValue={20} step={5} showValue formatOptions={{ style: 'unit', unit: 'percent' }} />\n */\nexport const Slider = markFieldAware(\n forwardRef<HTMLSpanElement, SliderProps>(function Slider(\n {\n value,\n defaultValue,\n onValueChange,\n onValueCommit,\n min = 0,\n max = 100,\n step = 1,\n marks,\n showValue = false,\n formatOptions,\n locale,\n name,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n invalid: invalidProp,\n size = 'md',\n id: idProp,\n onBlur,\n 'aria-label': ariaLabel,\n 'aria-labelledby': labelledByProp,\n 'aria-describedby': describedByProp,\n 'aria-invalid': ariaInvalid,\n ...rest\n },\n ref,\n ) {\n const autoId = useId()\n const field = useResolvedField({\n id: idProp,\n describedBy: describedByProp,\n invalid: invalidProp,\n ariaInvalid,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n })\n const [current, setCurrent] = useControllableValue(\n value,\n defaultValue ?? min,\n onValueChange,\n field.readOnly,\n )\n const handleBlur = useFocusLeave(onBlur)\n\n return (\n <SliderBase\n {...rest}\n onBlur={handleBlur}\n values={[current]}\n onValuesChange={(next) => {\n setCurrent(next[0] ?? min)\n }}\n onValuesCommit={(next) => onValueCommit?.(next[0] ?? min)}\n min={min}\n max={max}\n step={step}\n marks={marks}\n showValue={showValue}\n formatOptions={formatOptions}\n locale={locale}\n name={name}\n disabled={field.disabled}\n readOnly={field.readOnly}\n invalid={field.invalid}\n size={size}\n thumbs={[\n {\n id: field.id ?? `${autoId}thumb`,\n ref,\n 'aria-label': ariaLabel,\n 'aria-labelledby': labelledByProp ?? (ariaLabel ? undefined : field.labelId),\n 'aria-describedby': field.describedBy,\n 'aria-invalid': field.invalid || undefined,\n 'aria-readonly': field.readOnly || undefined,\n 'aria-busy': field.busy || undefined,\n },\n ]}\n />\n )\n }),\n)\n"],"mappings":";;;;;;AAuDA,IAAaA,IAASC,EACpBC,EAAyC,SACvC,EACE,UACA,iBACA,kBACA,kBACA,SAAM,GACN,SAAM,KACN,UAAO,GACP,UACA,eAAY,IACZ,kBACA,WACA,SACA,UAAUC,GACV,UAAUC,GACV,SAASC,GACT,UAAO,MACP,IAAIC,GACJ,WACA,cAAcC,GACd,mBAAmBC,GACnB,oBAAoBC,GACpB,gBAAgBC,GAChB,GAAGC,KAEL,GACA;CACA,IAAMC,IAASC,EAAM,GACfC,IAAQC,EAAiB;EAC7B,IAAIT;EACJ,aAAaG;EACb,SAASJ;EACT;EACA,UAAUF;EACV,UAAUC;CACZ,CAAC,GACK,CAACY,GAASC,KAAcC,EAC5BC,GACAC,KAAgBC,GAChBC,GACAR,EAAM,QACR,GACMS,IAAaC,EAAcC,CAAM;CAEvC,OACE,kBAACC,GAAD;EACE,GAAIf;EACJ,QAAQY;EACR,QAAQ,CAACP,CAAO;EAChB,iBAAiB,MAAS;GACxB,EAAWW,EAAK,MAAMN,CAAG;EAC3B;EACA,iBAAiB,MAASO,IAAgBD,EAAK,MAAMN,CAAG;EACnD;EACA;EACC;EACC;EACI;EACI;EACP;EACF;EACN,UAAUP,EAAM;EAChB,UAAUA,EAAM;EAChB,SAASA,EAAM;EACT;EACN,QAAQ,CACN;GACE,IAAIA,EAAM,MAAM,GAAGF,EAAO;GAC1B;GACA,cAAcL;GACd,mBAAmBC,MAAmBD,IAAY,KAAA,IAAYO,EAAM;GACpE,oBAAoBA,EAAM;GAC1B,gBAAgBA,EAAM,WAAW,KAAA;GACjC,iBAAiBA,EAAM,YAAY,KAAA;GACnC,aAAaA,EAAM,QAAQ,KAAA;EAC7B,CACF;CACD,CAAA;AAEL,CAAC,CACH"}
|
|
@@ -3,6 +3,13 @@ import { type SliderProps } from '../Slider/index.js';
|
|
|
3
3
|
export interface SliderFieldProps extends FieldLabelProps, Omit<SliderProps, 'invalid' | keyof FieldLabelProps> {
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
|
+
* A labelled slider, its thumb named by the label and described by the help text.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* `SliderField` is a {@link Field | Field} around a {@link Slider | Slider}. The thumb is labelled
|
|
10
|
+
* by the field's label and described by its description and error.
|
|
11
|
+
*
|
|
12
|
+
* @privateRemarks
|
|
6
13
|
* A labelled `Slider`. The thumb is labelled by the Field's label and described by its
|
|
7
14
|
* help, warning and error. `className`/`style` go to the Field; `ref`, `id`, `name` and the
|
|
8
15
|
* rest go to the slider (the ref to its thumb).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliderField.js","names":["SliderField","forwardRef","fieldProps","sliderProps","splitFieldLabelProps","props","Field","id","Slider"],"sources":["../../../../src/components/inputs/SliderField/SliderField.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { Field, type FieldLabelProps } from '#components/inputs/Field'\nimport { splitFieldLabelProps } from '#components/inputs/internal/fieldProps'\nimport { Slider, type SliderProps } from '#components/inputs/Slider'\n\nexport interface SliderFieldProps\n extends FieldLabelProps, Omit<SliderProps, 'invalid' | keyof FieldLabelProps> {}\n\n/**\n * A labelled `Slider`. The thumb is labelled by the Field's label and described by its\n * help, warning and error. `className`/`style` go to the Field; `ref`, `id`, `name` and the\n * rest go to the slider (the ref to its thumb).\n *\n * <SliderField label=\"Discount rate\" name=\"discountRate\" step={5} showValue formatOptions={{ style: 'unit', unit: 'percent' }} />\n */\nexport const SliderField = forwardRef<HTMLSpanElement, SliderFieldProps>(\n function SliderField(props, ref) {\n const [fieldProps, { id, disabled, className, style, ...sliderProps }] =\n splitFieldLabelProps(props)\n return (\n <Field {...fieldProps} htmlFor={id} disabled={disabled} className={className} style={style}>\n <Slider ref={ref} {...sliderProps} />\n </Field>\n )\n },\n)\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"SliderField.js","names":["SliderField","forwardRef","fieldProps","sliderProps","splitFieldLabelProps","props","Field","id","Slider"],"sources":["../../../../src/components/inputs/SliderField/SliderField.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { Field, type FieldLabelProps } from '#components/inputs/Field'\nimport { splitFieldLabelProps } from '#components/inputs/internal/fieldProps'\nimport { Slider, type SliderProps } from '#components/inputs/Slider'\n\nexport interface SliderFieldProps\n extends FieldLabelProps, Omit<SliderProps, 'invalid' | keyof FieldLabelProps> {}\n\n/**\n * A labelled slider, its thumb named by the label and described by the help text.\n *\n * @remarks\n * `SliderField` is a {@link Field | Field} around a {@link Slider | Slider}. The thumb is labelled\n * by the field's label and described by its description and error.\n *\n * @privateRemarks\n * A labelled `Slider`. The thumb is labelled by the Field's label and described by its\n * help, warning and error. `className`/`style` go to the Field; `ref`, `id`, `name` and the\n * rest go to the slider (the ref to its thumb).\n *\n * <SliderField label=\"Discount rate\" name=\"discountRate\" step={5} showValue formatOptions={{ style: 'unit', unit: 'percent' }} />\n */\nexport const SliderField = forwardRef<HTMLSpanElement, SliderFieldProps>(\n function SliderField(props, ref) {\n const [fieldProps, { id, disabled, className, style, ...sliderProps }] =\n splitFieldLabelProps(props)\n return (\n <Field {...fieldProps} htmlFor={id} disabled={disabled} className={className} style={style}>\n <Slider ref={ref} {...sliderProps} />\n </Field>\n )\n },\n)\n"],"mappings":";;;;;;AAsBA,IAAaA,IAAcC,EACzB,SAAqB,GAAO,GAAK;CAC/B,IAAM,CAACC,GAAY,EAAE,OAAI,aAAU,cAAW,UAAO,GAAGC,OACtDC,EAAqBC,CAAK;CAC5B,OACE,kBAACC,GAAD;EAAO,GAAIJ;EAAY,SAASK;EAAc;EAAqB;EAAkB;EACnF,UAAA,kBAACC,GAAD;GAAa;GAAK,GAAIL;EAAc,CAAA;CAC/B,CAAA;AAEX,CACF"}
|
|
@@ -10,6 +10,14 @@ export interface SwitchProps extends Omit<ComponentPropsWithoutRef<typeof RadixS
|
|
|
10
10
|
readOnly?: boolean;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
|
+
* An on-off setting that takes effect at once.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* `Switch` is for a setting that applies immediately, like turning alerts on. For a choice that's
|
|
17
|
+
* submitted with a form, a checkbox says more clearly that nothing happens until you submit.
|
|
18
|
+
* `label` puts a label beside it; inside a settings list, use {@link SwitchField | SwitchField}.
|
|
19
|
+
*
|
|
20
|
+
* @privateRemarks
|
|
13
21
|
* An on/off setting that applies immediately (Radix Switch). For a choice that's
|
|
14
22
|
* submitted with a form, prefer a checkbox. The ref and `className` go to the switch.
|
|
15
23
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.js","names":["Switch","RadixSwitch","styles","Switch_module_default","Switch$1","markFieldAware","forwardRef","invalidProp","idProp","disabledProp","readOnlyProp","describedByProp","ariaInvalid","rest","autoId","useId","field","useResolvedField","id","label","control","Switch","cx","className","size","onCheckedChange"],"sources":["../../../../src/components/inputs/Switch/Switch.tsx"],"sourcesContent":["import { forwardRef, useId, type ComponentPropsWithoutRef, type ReactNode } from 'react'\nimport { Switch as RadixSwitch } from 'radix-ui'\nimport { cx } from '#utils/cx'\nimport { markFieldAware, useResolvedField } from '#components/inputs/internal/FieldContext'\nimport styles from './Switch.module.css'\n\nexport interface SwitchProps extends Omit<\n ComponentPropsWithoutRef<typeof RadixSwitch.Root>,\n 'asChild'\n> {\n size?: 'sm' | 'md'\n /** Inline label after the switch. Omit inside a `<Field>` or when labelling another way. */\n label?: ReactNode\n /** Critical border + `aria-invalid`. Rare — a switch usually can't be wrong. */\n invalid?: boolean\n /** Focusable but not editable: sets `aria-readonly` and ignores toggling. */\n readOnly?: boolean\n}\n\n/**\n * An on/off setting that applies immediately (Radix Switch). For a choice that's\n * submitted with a form, prefer a checkbox. The ref and `className` go to the switch.\n *\n * <Switch label=\"Repeats monthly\" checked={recurring} onCheckedChange={setRecurring} />\n */\nexport const Switch = markFieldAware(\n forwardRef<HTMLButtonElement, SwitchProps>(function Switch(\n {\n size = 'md',\n label,\n invalid: invalidProp,\n id: idProp,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n onCheckedChange,\n className,\n 'aria-describedby': describedByProp,\n 'aria-invalid': ariaInvalid,\n ...rest\n },\n ref,\n ) {\n const autoId = useId()\n const field = useResolvedField({\n id: idProp,\n describedBy: describedByProp,\n invalid: invalidProp,\n ariaInvalid,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n })\n const id = field.id ?? (label != null ? autoId : undefined)\n\n const control = (\n <RadixSwitch.Root\n ref={ref}\n id={id}\n className={cx(styles.switch, className)}\n data-size={size}\n data-invalid={field.invalid || undefined}\n data-readonly={field.readOnly || undefined}\n disabled={field.disabled}\n aria-readonly={field.readOnly || undefined}\n aria-describedby={field.describedBy}\n aria-invalid={field.invalid || undefined}\n aria-required={field.required || undefined}\n aria-busy={field.busy || undefined}\n onCheckedChange={field.readOnly ? undefined : onCheckedChange}\n {...rest}\n >\n <RadixSwitch.Thumb className={styles.thumb} />\n </RadixSwitch.Root>\n )\n\n if (label == null) return control\n return (\n <span className={styles.wrapper} data-disabled={field.disabled || undefined}>\n {control}\n <label htmlFor={id} className={styles.label}>\n {label}\n </label>\n </span>\n )\n }),\n)\n"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"Switch.js","names":["Switch","RadixSwitch","styles","Switch_module_default","Switch$1","markFieldAware","forwardRef","invalidProp","idProp","disabledProp","readOnlyProp","describedByProp","ariaInvalid","rest","autoId","useId","field","useResolvedField","id","label","control","Switch","cx","className","size","onCheckedChange"],"sources":["../../../../src/components/inputs/Switch/Switch.tsx"],"sourcesContent":["import { forwardRef, useId, type ComponentPropsWithoutRef, type ReactNode } from 'react'\nimport { Switch as RadixSwitch } from 'radix-ui'\nimport { cx } from '#utils/cx'\nimport { markFieldAware, useResolvedField } from '#components/inputs/internal/FieldContext'\nimport styles from './Switch.module.css'\n\nexport interface SwitchProps extends Omit<\n ComponentPropsWithoutRef<typeof RadixSwitch.Root>,\n 'asChild'\n> {\n size?: 'sm' | 'md'\n /** Inline label after the switch. Omit inside a `<Field>` or when labelling another way. */\n label?: ReactNode\n /** Critical border + `aria-invalid`. Rare — a switch usually can't be wrong. */\n invalid?: boolean\n /** Focusable but not editable: sets `aria-readonly` and ignores toggling. */\n readOnly?: boolean\n}\n\n/**\n * An on-off setting that takes effect at once.\n *\n * @remarks\n * `Switch` is for a setting that applies immediately, like turning alerts on. For a choice that's\n * submitted with a form, a checkbox says more clearly that nothing happens until you submit.\n * `label` puts a label beside it; inside a settings list, use {@link SwitchField | SwitchField}.\n *\n * @privateRemarks\n * An on/off setting that applies immediately (Radix Switch). For a choice that's\n * submitted with a form, prefer a checkbox. The ref and `className` go to the switch.\n *\n * <Switch label=\"Repeats monthly\" checked={recurring} onCheckedChange={setRecurring} />\n */\nexport const Switch = markFieldAware(\n forwardRef<HTMLButtonElement, SwitchProps>(function Switch(\n {\n size = 'md',\n label,\n invalid: invalidProp,\n id: idProp,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n onCheckedChange,\n className,\n 'aria-describedby': describedByProp,\n 'aria-invalid': ariaInvalid,\n ...rest\n },\n ref,\n ) {\n const autoId = useId()\n const field = useResolvedField({\n id: idProp,\n describedBy: describedByProp,\n invalid: invalidProp,\n ariaInvalid,\n disabled: disabledProp,\n readOnly: readOnlyProp,\n })\n const id = field.id ?? (label != null ? autoId : undefined)\n\n const control = (\n <RadixSwitch.Root\n ref={ref}\n id={id}\n className={cx(styles.switch, className)}\n data-size={size}\n data-invalid={field.invalid || undefined}\n data-readonly={field.readOnly || undefined}\n disabled={field.disabled}\n aria-readonly={field.readOnly || undefined}\n aria-describedby={field.describedBy}\n aria-invalid={field.invalid || undefined}\n aria-required={field.required || undefined}\n aria-busy={field.busy || undefined}\n onCheckedChange={field.readOnly ? undefined : onCheckedChange}\n {...rest}\n >\n <RadixSwitch.Thumb className={styles.thumb} />\n </RadixSwitch.Root>\n )\n\n if (label == null) return control\n return (\n <span className={styles.wrapper} data-disabled={field.disabled || undefined}>\n {control}\n <label htmlFor={id} className={styles.label}>\n {label}\n </label>\n </span>\n )\n }),\n)\n"],"mappings":";;;;;;;AAiCA,IAAaA,IAASK,EACpBC,EAA2C,SACzC,EACE,UAAO,MACP,UACA,SAASC,GACT,IAAIC,GACJ,UAAUC,GACV,UAAUC,GACV,oBACA,cACA,oBAAoBC,GACpB,gBAAgBC,GAChB,GAAGC,KAEL,GACA;CACA,IAAMC,IAASC,EAAM,GACfC,IAAQC,EAAiB;EAC7B,IAAIT;EACJ,aAAaG;EACb,SAASJ;EACT;EACA,UAAUE;EACV,UAAUC;CACZ,CAAC,GACKQ,IAAKF,EAAM,OAAOG,KAAS,OAAgB,KAAA,IAATL,IAElCM,IACJ,kBAACnB,EAAY,MAAb;EACO;EACD;EACJ,WAAWqB,EAAGpB,EAAO,QAAQqB,CAAS;EACtC,aAAWC;EACX,gBAAcR,EAAM,WAAW,KAAA;EAC/B,iBAAeA,EAAM,YAAY,KAAA;EACjC,UAAUA,EAAM;EAChB,iBAAeA,EAAM,YAAY,KAAA;EACjC,oBAAkBA,EAAM;EACxB,gBAAcA,EAAM,WAAW,KAAA;EAC/B,iBAAeA,EAAM,YAAY,KAAA;EACjC,aAAWA,EAAM,QAAQ,KAAA;EACzB,iBAAiBA,EAAM,WAAW,KAAA,IAAYS;EAC9C,GAAIZ;EAEJ,UAAA,kBAACZ,EAAY,OAAb,EAAmB,WAAWC,EAAO,MAAQ,CAAA;CAC7B,CAAA;CAIpB,OADIiB,KAAS,OAAaC,IAExB,kBAAC,QAAD;EAAM,WAAWlB,EAAO;EAAS,iBAAec,EAAM,YAAY,KAAA;EAAlE,UAAA,CACGI,GACD,kBAAC,SAAD;GAAO,SAASF;GAAI,WAAWhB,EAAO;GACnC,UAAAiB;EACI,CAAA,CACH;;AAEV,CAAC,CACH"}
|
|
@@ -3,6 +3,14 @@ import type { FieldLabelProps } from '../Field/index.js';
|
|
|
3
3
|
export interface SwitchFieldProps extends FieldLabelProps, Omit<SwitchProps, 'label' | 'invalid' | keyof FieldLabelProps> {
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
|
+
* A settings row, with the label and its help on one side and the switch on the other.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* `SwitchField` is the row you'd find in a settings list: the label and its description on the
|
|
10
|
+
* left, the {@link Switch | Switch} on the right, an error underneath. The whole label is part of
|
|
11
|
+
* the target.
|
|
12
|
+
*
|
|
13
|
+
* @privateRemarks
|
|
6
14
|
* A settings row: the label and its help on the left, the switch on the right, an error
|
|
7
15
|
* line underneath. For a setting that applies as soon as it's flipped; for a choice that
|
|
8
16
|
* is submitted with a form, a CheckboxField reads better. The ref goes to the switch,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwitchField.js","names":["styles","messageStyles","messages_module_default","SwitchField_module_default","SwitchField","forwardRef","fieldProps","rest","splitFieldLabelProps","props","checkedProp","idProp","describedByProp","switchRest","autoId","useId","id","labelId","descriptionId","warningId","errorId","help","description","hint","showErrorMessage","hasErrorMessage","error","errorHidden","showWarning","warning","internal","setInternal","useState","defaultChecked","checked","cx","className","disabled","readOnly","labelHidden","LabelContent","validating","label","FieldDescription","Switch","hasError","required","joinIds","next","onCheckedChange","FieldWarning","FieldError","errorLive"],"sources":["../../../../src/components/inputs/SwitchField/SwitchField.tsx"],"sourcesContent":["import { forwardRef, useId, useState } from 'react'\nimport { cx } from '#utils/cx'\nimport { Switch, type SwitchProps } from '#components/inputs/Switch'\nimport type { FieldLabelProps } from '#components/inputs/Field'\nimport { splitFieldLabelProps } from '#components/inputs/internal/fieldProps'\nimport {\n FieldDescription,\n FieldError,\n FieldWarning,\n LabelContent,\n} from '#components/inputs/internal/messages'\nimport { hasError, hasErrorMessage } from '#components/inputs/internal/errors'\nimport messageStyles from '#components/inputs/internal/messages.module.css'\nimport { joinIds } from '#components/inputs/internal/refs'\nimport styles from './SwitchField.module.css'\n\nexport interface SwitchFieldProps\n extends FieldLabelProps, Omit<SwitchProps, 'label' | 'invalid' | keyof FieldLabelProps> {}\n\n/**\n * A settings row: the label and its help on the left, the switch on the right, an error\n * line underneath. For a setting that applies as soon as it's flipped; for a choice that\n * is submitted with a form, a CheckboxField reads better. The ref goes to the switch,\n * `className`/`style` to the row.\n *\n * <SwitchField label=\"Email me when a payment is due\" description=\"Three days before\" checked={on} onCheckedChange={setOn} />\n */\nexport const SwitchField = forwardRef<HTMLButtonElement, SwitchFieldProps>(\n function SwitchField(props, ref) {\n const [fieldProps, rest] = splitFieldLabelProps(props)\n const {\n label,\n description,\n hint,\n error,\n required = false,\n optional,\n labelHidden = false,\n warning,\n errorLive = true,\n errorHidden = false,\n validating = false,\n readOnly = false,\n } = fieldProps\n const {\n checked: checkedProp,\n defaultChecked = false,\n onCheckedChange,\n id: idProp,\n disabled = false,\n className,\n style,\n 'aria-describedby': describedByProp,\n ...switchRest\n } = rest\n\n const autoId = useId()\n const id = idProp ?? `${autoId}switch`\n const labelId = `${id}-label`\n const descriptionId = `${id}-description`\n const warningId = `${id}-warning`\n const errorId = `${id}-error`\n const help = description ?? hint\n const showErrorMessage = hasErrorMessage(error) && !errorHidden\n const showWarning = warning != null && !showErrorMessage\n\n // Always controlled underneath, so `readOnly` holds even when the caller is uncontrolled.\n const [internal, setInternal] = useState(defaultChecked)\n const checked = checkedProp ?? internal\n const handleCheckedChange = (next: boolean) => {\n if (readOnly) return\n if (checkedProp === undefined) setInternal(next)\n onCheckedChange?.(next)\n }\n\n return (\n <div\n className={cx(styles.root, className)}\n style={style}\n data-disabled={disabled || undefined}\n data-readonly={readOnly || undefined}\n >\n <div className={styles.text}>\n <label\n id={labelId}\n htmlFor={id}\n className={cx(styles.label, labelHidden && messageStyles.visuallyHidden)}\n >\n <LabelContent required={required} optional={optional} busy={validating}>\n {label}\n </LabelContent>\n </label>\n {help != null ? <FieldDescription id={descriptionId}>{help}</FieldDescription> : null}\n </div>\n <span className={styles.slot}>\n <Switch\n ref={ref}\n id={id}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n invalid={hasError(error)}\n aria-required={required || undefined}\n aria-busy={validating || undefined}\n aria-describedby={joinIds(\n describedByProp,\n help != null && descriptionId,\n showWarning && warningId,\n showErrorMessage && errorId,\n )}\n checked={checked}\n onCheckedChange={handleCheckedChange}\n {...switchRest}\n />\n </span>\n {showWarning ? (\n <FieldWarning id={warningId} className={styles.message}>\n {warning}\n </FieldWarning>\n ) : null}\n {showErrorMessage ? (\n <FieldError id={errorId} className={styles.message} live={errorLive}>\n {error}\n </FieldError>\n ) : null}\n </div>\n )\n },\n)\n"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"SwitchField.js","names":["styles","messageStyles","messages_module_default","SwitchField_module_default","SwitchField","forwardRef","fieldProps","rest","splitFieldLabelProps","props","checkedProp","idProp","describedByProp","switchRest","autoId","useId","id","labelId","descriptionId","warningId","errorId","help","description","hint","showErrorMessage","hasErrorMessage","error","errorHidden","showWarning","warning","internal","setInternal","useState","defaultChecked","checked","cx","className","disabled","readOnly","labelHidden","LabelContent","validating","label","FieldDescription","Switch","hasError","required","joinIds","next","onCheckedChange","FieldWarning","FieldError","errorLive"],"sources":["../../../../src/components/inputs/SwitchField/SwitchField.tsx"],"sourcesContent":["import { forwardRef, useId, useState } from 'react'\nimport { cx } from '#utils/cx'\nimport { Switch, type SwitchProps } from '#components/inputs/Switch'\nimport type { FieldLabelProps } from '#components/inputs/Field'\nimport { splitFieldLabelProps } from '#components/inputs/internal/fieldProps'\nimport {\n FieldDescription,\n FieldError,\n FieldWarning,\n LabelContent,\n} from '#components/inputs/internal/messages'\nimport { hasError, hasErrorMessage } from '#components/inputs/internal/errors'\nimport messageStyles from '#components/inputs/internal/messages.module.css'\nimport { joinIds } from '#components/inputs/internal/refs'\nimport styles from './SwitchField.module.css'\n\nexport interface SwitchFieldProps\n extends FieldLabelProps, Omit<SwitchProps, 'label' | 'invalid' | keyof FieldLabelProps> {}\n\n/**\n * A settings row, with the label and its help on one side and the switch on the other.\n *\n * @remarks\n * `SwitchField` is the row you'd find in a settings list: the label and its description on the\n * left, the {@link Switch | Switch} on the right, an error underneath. The whole label is part of\n * the target.\n *\n * @privateRemarks\n * A settings row: the label and its help on the left, the switch on the right, an error\n * line underneath. For a setting that applies as soon as it's flipped; for a choice that\n * is submitted with a form, a CheckboxField reads better. The ref goes to the switch,\n * `className`/`style` to the row.\n *\n * <SwitchField label=\"Email me when a payment is due\" description=\"Three days before\" checked={on} onCheckedChange={setOn} />\n */\nexport const SwitchField = forwardRef<HTMLButtonElement, SwitchFieldProps>(\n function SwitchField(props, ref) {\n const [fieldProps, rest] = splitFieldLabelProps(props)\n const {\n label,\n description,\n hint,\n error,\n required = false,\n optional,\n labelHidden = false,\n warning,\n errorLive = true,\n errorHidden = false,\n validating = false,\n readOnly = false,\n } = fieldProps\n const {\n checked: checkedProp,\n defaultChecked = false,\n onCheckedChange,\n id: idProp,\n disabled = false,\n className,\n style,\n 'aria-describedby': describedByProp,\n ...switchRest\n } = rest\n\n const autoId = useId()\n const id = idProp ?? `${autoId}switch`\n const labelId = `${id}-label`\n const descriptionId = `${id}-description`\n const warningId = `${id}-warning`\n const errorId = `${id}-error`\n const help = description ?? hint\n const showErrorMessage = hasErrorMessage(error) && !errorHidden\n const showWarning = warning != null && !showErrorMessage\n\n // Always controlled underneath, so `readOnly` holds even when the caller is uncontrolled.\n const [internal, setInternal] = useState(defaultChecked)\n const checked = checkedProp ?? internal\n const handleCheckedChange = (next: boolean) => {\n if (readOnly) return\n if (checkedProp === undefined) setInternal(next)\n onCheckedChange?.(next)\n }\n\n return (\n <div\n className={cx(styles.root, className)}\n style={style}\n data-disabled={disabled || undefined}\n data-readonly={readOnly || undefined}\n >\n <div className={styles.text}>\n <label\n id={labelId}\n htmlFor={id}\n className={cx(styles.label, labelHidden && messageStyles.visuallyHidden)}\n >\n <LabelContent required={required} optional={optional} busy={validating}>\n {label}\n </LabelContent>\n </label>\n {help != null ? <FieldDescription id={descriptionId}>{help}</FieldDescription> : null}\n </div>\n <span className={styles.slot}>\n <Switch\n ref={ref}\n id={id}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n invalid={hasError(error)}\n aria-required={required || undefined}\n aria-busy={validating || undefined}\n aria-describedby={joinIds(\n describedByProp,\n help != null && descriptionId,\n showWarning && warningId,\n showErrorMessage && errorId,\n )}\n checked={checked}\n onCheckedChange={handleCheckedChange}\n {...switchRest}\n />\n </span>\n {showWarning ? (\n <FieldWarning id={warningId} className={styles.message}>\n {warning}\n </FieldWarning>\n ) : null}\n {showErrorMessage ? (\n <FieldError id={errorId} className={styles.message} live={errorLive}>\n {error}\n </FieldError>\n ) : null}\n </div>\n )\n },\n)\n"],"mappings":";;;;;;;;;;;AAmCA,IAAaI,IAAcC,EACzB,SAAqB,GAAO,GAAK;CAC/B,IAAM,CAACC,GAAYC,KAAQC,EAAqBC,CAAK,GAC/C,EACJ,UACA,gBACA,SACA,UACA,cAAW,IACX,aACA,iBAAc,IACd,YACA,eAAY,IACZ,iBAAc,IACd,gBAAa,IACb,cAAW,OACTH,GACE,EACJ,SAASI,GACT,oBAAiB,IACjB,oBACA,IAAIC,GACJ,cAAW,IACX,cACA,UACA,oBAAoBC,GACpB,GAAGC,MACDN,GAEEO,IAASC,EAAM,GACfC,IAAKL,K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