@epilot/zenith-react 0.2.0-next.6 → 0.2.0
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/README.md +1 -1
- package/dist/_virtual/_zenith-runtime-family_accordion.js +1 -1
- package/dist/_virtual/_zenith-runtime-family_alert-dialog.js +1 -1
- package/dist/_virtual/_zenith-runtime-family_avatar.js +1 -1
- package/dist/_virtual/_zenith-runtime-family_button.js +1 -1
- package/dist/_virtual/_zenith-runtime-family_checkbox.js +1 -1
- package/dist/_virtual/_zenith-runtime-family_csp-provider.js +1 -1
- package/dist/_virtual/_zenith-runtime-family_dialog.js +1 -1
- package/dist/_virtual/_zenith-runtime-family_direction-provider.js +1 -1
- package/dist/_virtual/_zenith-runtime-family_menu.js +1 -1
- package/dist/_virtual/_zenith-runtime-family_merge-props.js +1 -1
- package/dist/_virtual/_zenith-runtime-family_popover.js +1 -1
- package/dist/_virtual/_zenith-runtime-family_radio-group.js +1 -1
- package/dist/_virtual/_zenith-runtime-family_radio.js +1 -1
- package/dist/_virtual/_zenith-runtime-family_scroll-area.js +1 -1
- package/dist/_virtual/_zenith-runtime-family_select.js +1 -1
- package/dist/_virtual/_zenith-runtime-family_separator.js +1 -1
- package/dist/_virtual/_zenith-runtime-family_switch.js +1 -1
- package/dist/_virtual/_zenith-runtime-family_tabs.js +1 -1
- package/dist/_virtual/_zenith-runtime-family_toast.js +1 -1
- package/dist/_virtual/_zenith-runtime-family_toggle-group.js +1 -1
- package/dist/_virtual/_zenith-runtime-family_toggle.js +1 -1
- package/dist/_virtual/_zenith-runtime-family_tooltip.js +1 -1
- package/dist/_virtual/_zenith-runtime-family_use-render.js +1 -1
- package/dist/components/accordion/accordion.js +1 -1
- package/dist/components/accordion/accordion.js.map +1 -1
- package/dist/components/alert-dialog/alert-dialog.js +1 -1
- package/dist/components/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/components/appearance-boundary/appearance-boundary.js +1 -1
- package/dist/components/appearance-boundary/appearance-boundary.js.map +1 -1
- package/dist/components/avatar/avatar-group.js +1 -1
- package/dist/components/avatar/avatar-group.js.map +1 -1
- package/dist/components/avatar/avatar.js +1 -1
- package/dist/components/avatar/avatar.js.map +1 -1
- package/dist/components/badge/badge.js +1 -1
- package/dist/components/badge/badge.js.map +1 -1
- package/dist/components/breadcrumb/breadcrumb.js +1 -1
- package/dist/components/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/components/button/button.js +1 -1
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/button-group/button-group.js +1 -1
- package/dist/components/button-group/button-group.js.map +1 -1
- package/dist/components/callout/callout.js +1 -1
- package/dist/components/callout/callout.js.map +1 -1
- package/dist/components/card/card.js +1 -1
- package/dist/components/card/card.js.map +1 -1
- package/dist/components/checkbox/checkbox.js +41 -39
- package/dist/components/checkbox/checkbox.js.map +1 -1
- package/dist/components/code-block/code-block.js +1 -1
- package/dist/components/code-block/code-block.js.map +1 -1
- package/dist/components/code-editor/code-editor.js +1 -1
- package/dist/components/code-editor/code-editor.js.map +1 -1
- package/dist/components/collapsible-sidebar/collapsible-sidebar.js +1 -1
- package/dist/components/collapsible-sidebar/collapsible-sidebar.js.map +1 -1
- package/dist/components/command/command.js +1 -1
- package/dist/components/command/command.js.map +1 -1
- package/dist/components/data-table/data-table-body.js +1 -1
- package/dist/components/data-table/data-table-body.js.map +1 -1
- package/dist/components/data-table/data-table-column-header.js +1 -1
- package/dist/components/data-table/data-table-column-header.js.map +1 -1
- package/dist/components/data-table/data-table-column-order.js +1 -1
- package/dist/components/data-table/data-table-column-order.js.map +1 -1
- package/dist/components/data-table/data-table-column-visibility.js +1 -1
- package/dist/components/data-table/data-table-column-visibility.js.map +1 -1
- package/dist/components/data-table/data-table-content.js +1 -1
- package/dist/components/data-table/data-table-content.js.map +1 -1
- package/dist/components/data-table/data-table-error.js +1 -1
- package/dist/components/data-table/data-table-error.js.map +1 -1
- package/dist/components/data-table/data-table-footer.js +1 -1
- package/dist/components/data-table/data-table-footer.js.map +1 -1
- package/dist/components/data-table/data-table-header-draggable.js +1 -1
- package/dist/components/data-table/data-table-header-draggable.js.map +1 -1
- package/dist/components/data-table/data-table-header.js +1 -1
- package/dist/components/data-table/data-table-header.js.map +1 -1
- package/dist/components/data-table/data-table-loading.js +1 -1
- package/dist/components/data-table/data-table-loading.js.map +1 -1
- package/dist/components/data-table/data-table-resize-handle.js +1 -1
- package/dist/components/data-table/data-table-resize-handle.js.map +1 -1
- package/dist/components/data-table/data-table-row.js +1 -1
- package/dist/components/data-table/data-table-row.js.map +1 -1
- package/dist/components/data-table/data-table-toolbar.js +1 -1
- package/dist/components/data-table/data-table-toolbar.js.map +1 -1
- package/dist/components/data-table/data-table.js +1 -1
- package/dist/components/data-table/data-table.js.map +1 -1
- package/dist/components/date-range-picker/date-range-picker.js +1 -1
- package/dist/components/date-range-picker/date-range-picker.js.map +1 -1
- package/dist/components/date-range-picker/range-calendar.js +1 -1
- package/dist/components/date-range-picker/range-calendar.js.map +1 -1
- package/dist/components/date-time-picker/calendar.js +1 -1
- package/dist/components/date-time-picker/calendar.js.map +1 -1
- package/dist/components/date-time-picker/date-time-picker-input.js +1 -1
- package/dist/components/date-time-picker/date-time-picker-input.js.map +1 -1
- package/dist/components/date-time-picker/date-time-picker-panel.js +1 -1
- package/dist/components/date-time-picker/date-time-picker-panel.js.map +1 -1
- package/dist/components/date-time-picker/date-time-picker.js +1 -1
- package/dist/components/date-time-picker/date-time-picker.js.map +1 -1
- package/dist/components/date-time-picker/time-picker.js +1 -1
- package/dist/components/date-time-picker/time-picker.js.map +1 -1
- package/dist/components/density-provider/density-provider.js +1 -1
- package/dist/components/dialog/dialog.js +1 -1
- package/dist/components/dialog/dialog.js.map +1 -1
- package/dist/components/drawer/drawer.js +1 -1
- package/dist/components/drawer/drawer.js.map +1 -1
- package/dist/components/dropdown-menu/dropdown-menu.js +1 -1
- package/dist/components/dropdown-menu/dropdown-menu.js.map +1 -1
- package/dist/components/field/field-combobox.js +1 -1
- package/dist/components/field/field-combobox.js.map +1 -1
- package/dist/components/field/field-select.js +1 -1
- package/dist/components/field/field-select.js.map +1 -1
- package/dist/components/field/field.js +1 -1
- package/dist/components/field/field.js.map +1 -1
- package/dist/components/label/label.js +1 -1
- package/dist/components/label/label.js.map +1 -1
- package/dist/components/list/list.js +1 -1
- package/dist/components/list/list.js.map +1 -1
- package/dist/components/option-card/option-card.js +1 -1
- package/dist/components/option-card/option-card.js.map +1 -1
- package/dist/components/pill/pill.js +1 -1
- package/dist/components/pill/pill.js.map +1 -1
- package/dist/components/popover/popover.js +1 -1
- package/dist/components/popover/popover.js.map +1 -1
- package/dist/components/radio/radio.js +15 -12
- package/dist/components/radio/radio.js.map +1 -1
- package/dist/components/scroll-area/scroll-area.js +1 -1
- package/dist/components/scroll-area/scroll-area.js.map +1 -1
- package/dist/components/scroll-area/scrollbar-styles.js +1 -1
- package/dist/components/scroll-area/scrollbar-styles.js.map +1 -1
- package/dist/components/scroll-overflow/scroll-overflow.js +1 -1
- package/dist/components/scroll-overflow/scroll-overflow.js.map +1 -1
- package/dist/components/segmented-control/segmented-control.js +1 -1
- package/dist/components/segmented-control/segmented-control.js.map +1 -1
- package/dist/components/select/select.js +178 -176
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/separator/separator.js +1 -1
- package/dist/components/separator/separator.js.map +1 -1
- package/dist/components/skeleton/skeleton.js +1 -1
- package/dist/components/skeleton/skeleton.js.map +1 -1
- package/dist/components/slot/compose-as-child.js +1 -1
- package/dist/components/slot/compose-as-child.js.map +1 -1
- package/dist/components/spinner/spinner.js +1 -1
- package/dist/components/spinner/spinner.js.map +1 -1
- package/dist/components/surface/surface.js +1 -1
- package/dist/components/surface/surface.js.map +1 -1
- package/dist/components/switch/switch.js +59 -57
- package/dist/components/switch/switch.js.map +1 -1
- package/dist/components/table/table-pagination.js +1 -1
- package/dist/components/table/table-pagination.js.map +1 -1
- package/dist/components/table/table.js +1 -1
- package/dist/components/table/table.js.map +1 -1
- package/dist/components/tabs/tabs.js +1 -1
- package/dist/components/tabs/tabs.js.map +1 -1
- package/dist/components/text/text.js +1 -1
- package/dist/components/text/text.js.map +1 -1
- package/dist/components/toast/toast.js +1 -1
- package/dist/components/toast/toast.js.map +1 -1
- package/dist/components/toggle/toggle-group.js +1 -1
- package/dist/components/toggle/toggle-group.js.map +1 -1
- package/dist/components/toggle/toggle.js +1 -1
- package/dist/components/toggle/toggle.js.map +1 -1
- package/dist/components/tooltip/tooltip.js +1 -1
- package/dist/components/tooltip/tooltip.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/clear-button.js +1 -1
- package/dist/lib/clear-button.js.map +1 -1
- package/dist/lib/hidden-input-box.js +26 -0
- package/dist/lib/hidden-input-box.js.map +1 -0
- package/dist/packages/tokens/dist/delivery/index.js +1 -1
- package/dist/packages/tokens/dist/delivery/index.js.map +1 -1
- package/dist/packages/tokens/dist/install.js +1 -1
- package/dist/packages/tokens/dist/install.js.map +1 -1
- package/dist/renderer/served.js +1 -1
- package/dist/renderer/served.js.map +1 -1
- package/dist/styles/host-reset.js.map +1 -1
- package/dist/styles/make-styles.js +1 -1
- package/dist/styles/make-styles.js.map +1 -1
- package/dist/styles/text-box.js.map +1 -1
- package/dist/tokens.json +1 -1
- package/package.json +3 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"option-card.js","sources":["../../../src/components/option-card/option-card.tsx"],"sourcesContent":["import * as React from \"react\"\nimport { Toggle as TogglePrimitive } from \"@base-ui/react/toggle\"\nimport { mergeClasses, shorthands } from \"@epilot/zenith-runtime/v1/core\"\n\nimport { SLOT_ATTR } from \"../../renderer/contract\"\nimport { makeZenithStyles } from \"../../styles/make-styles\"\nimport { boxModel, nativeControl } from \"../../styles/host-reset\"\nimport * as tokens from \"../../tokens\"\nimport {\n respectDefaultPrevented,\n type ToggleChangeDetails,\n} from \"../toggle/toggle\"\nimport {\n ToggleGroupItemRoot,\n ToggleGroupRoot,\n type ToggleGroupMultipleProps,\n type ToggleGroupSingleProps,\n} from \"../toggle/toggle-group\"\n\nconst DEFAULT_LAYOUT = \"grid\" as const\n\nconst MISSING_VALUE_WARNING =\n \"OptionCard: a card inside an OptionCardGroup is missing a `value`. \" +\n \"Give each card a unique `value` so it can be selected and controlled.\"\n\n/** The trailing control glyph an {@link OptionCard} shows for its selected state. */\nexport type OptionCardControlType = \"radio\" | \"checkbox\" | \"switch\" | \"none\"\n\nexport type OptionCardLayout = \"grid\" | \"row\" | \"column\"\n\n// ── Group context ──────────────────────────────────────────────────────────\ntype OptionCardGroupContextValue = {\n type?: \"single\" | \"multiple\"\n layout: OptionCardLayout\n}\nconst OptionCardGroupContext =\n React.createContext<OptionCardGroupContextValue | null>(null)\n\n// ── Card context ───────────────────────────────────────────────────────────\ntype OptionCardContextValue = {\n controlType: OptionCardControlType\n registerType: (type: OptionCardControlType) => void\n}\nconst OptionCardContext = React.createContext<OptionCardContextValue | null>(\n null\n)\n\n// ── Styles ─────────────────────────────────────────────────────────────────\n\nconst useStyles = makeZenithStyles({\n // Group layouts\n group: {\n ...boxModel,\n // The GROUP only lays out. v1's group base class is literally \"\" -- every border, padding and\n // interaction style below used to live here, copied from v1's CARD class onto the wrong element,\n // while `styles.card` and `styles[layout]` were read but never declared. See make-styles.ts for\n // why tsc accepted that for as long as it did.\n display: \"grid\",\n ...shorthands.gap(tokens.spacingGroup1),\n },\n\n // v1: grid-cols-[repeat(auto-fit,minmax(200px,1fr))]\n grid: {\n gridTemplateColumns: \"repeat(auto-fit, minmax(200px, 1fr))\",\n },\n // v1: grid-flow-col auto-cols-fr -- equal-width columns in one non-wrapping row, so options read\n // as equal-weight peers regardless of their content.\n row: {\n gridAutoFlow: \"column\",\n gridAutoColumns: \"minmax(0, 1fr)\",\n },\n // v1: plain `grid` with no template. One column, stacked.\n column: {},\n\n card: {\n ...nativeControl,\n position: \"relative\",\n display: \"flex\",\n alignItems: \"center\",\n // v1 gap-3 = 0.75rem. No token: the semantic scale has no 0.75rem step.\n ...shorthands.gap(tokens.spacingElement3),\n overflow: \"hidden\",\n ...shorthands.borderRadius(tokens.radiusLg),\n // Not currentColor: that picked up this rule's `color: grayA12` and painted a near-black\n // edge. The predecessor's bare `border` resolved to a subtle grey; grayA6 is its match.\n ...shorthands.border(\"1px\", \"solid\", tokens.grayA6),\n ...shorthands.paddingInline(tokens.spacingElement3),\n ...shorthands.paddingBlock(\"0.375rem\"),\n textAlign: \"left\",\n fontSize: tokens.textSm,\n lineHeight: tokens.leadingSm,\n fontWeight: tokens.fontWeightNormal,\n color: tokens.grayA12,\n backgroundColor: \"transparent\",\n transitionProperty: \"color, background-color, border-color, box-shadow\",\n transitionDuration: \"150ms\",\n transitionTimingFunction: \"cubic-bezier(0.4, 0, 0.2, 1)\",\n cursor: \"pointer\",\n userSelect: \"none\",\n height: \"auto\",\n minWidth: \"0\",\n \":focus-visible\": {\n outlineWidth: \"2px\",\n outlineStyle: \"solid\",\n outlineOffset: \"2px\",\n outlineColor: tokens.accentA8,\n },\n \":disabled, &[data-disabled]\": {\n pointerEvents: \"none\",\n opacity: 0.5,\n },\n \"&[data-pressed]\": {\n backgroundColor: tokens.accentSoft,\n ...shorthands.borderColor(tokens.accentA8),\n },\n [`&[data-pressed] [${SLOT_ATTR}=\"option-card-radio-outer\"]`]: {\n ...shorthands.borderColor(tokens.accentSolid),\n },\n [`&[data-pressed] [${SLOT_ATTR}=\"option-card-radio-dot\"]`]: {\n opacity: 1,\n },\n [`&[data-pressed] [${SLOT_ATTR}=\"option-card-checkbox-outer\"]`]: {\n ...shorthands.borderColor(\"transparent\"),\n backgroundColor: tokens.accentSolid,\n },\n [`&[data-pressed] [${SLOT_ATTR}=\"option-card-checkbox-check\"]`]: {\n opacity: 1,\n },\n [`&[data-pressed] [${SLOT_ATTR}=\"option-card-switch-track\"]`]: {\n backgroundColor: tokens.accentSolid,\n },\n [`&[data-pressed] [${SLOT_ATTR}=\"option-card-switch-thumb\"]`]: {\n transform: \"translateX(calc(100% - 1px))\",\n },\n },\n\n // Media\n mediaRoot: {\n flexShrink: 0,\n },\n mediaIcon: {\n ...boxModel,\n display: \"grid\",\n width: \"2.5rem\",\n height: \"2.5rem\",\n placeContent: \"center\",\n alignSelf: \"start\",\n ...shorthands.borderRadius(tokens.radiusLg),\n backgroundColor: tokens.accentSoft,\n color: tokens.accentLight,\n \"& svg\": {\n width: \"1.25rem\",\n height: \"1.25rem\",\n },\n },\n mediaIllustration: {\n position: \"relative\",\n aspectRatio: \"1 / 1\",\n alignSelf: \"stretch\",\n overflow: \"hidden\",\n \"& svg\": {\n position: \"absolute\",\n ...shorthands.inset(0),\n width: \"100%\",\n height: \"100%\",\n },\n \"& img\": {\n position: \"absolute\",\n ...shorthands.inset(0),\n width: \"100%\",\n height: \"100%\",\n objectFit: \"contain\",\n },\n },\n\n // Content\n content: {\n ...boxModel,\n display: \"grid\",\n minWidth: 0,\n flexGrow: 1,\n flexShrink: 1,\n flexBasis: \"0%\",\n gridAutoRows: \"min-content\",\n alignItems: \"center\",\n columnGap: tokens.spacingElement2,\n paddingTop: tokens.spacingElement1,\n paddingBottom: tokens.spacingElement1,\n [`&:has([${SLOT_ATTR}=\"option-card-control\"])`]: {\n gridTemplateColumns: \"1fr auto\",\n },\n },\n\n // Title\n title: {\n ...boxModel,\n gridColumnStart: 1,\n gridRowStart: 1,\n minWidth: 0,\n alignSelf: \"center\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n fontWeight: tokens.fontWeightSemibold,\n },\n\n // Description\n description: {\n ...boxModel,\n gridColumnStart: 1,\n gridRowStart: 2,\n minWidth: 0,\n overflowWrap: \"break-word\",\n fontSize: tokens.textXs,\n lineHeight: tokens.leadingXs,\n fontWeight: tokens.fontWeightNormal,\n color: tokens.grayA11,\n },\n\n // Control\n control: {\n gridColumnStart: 2,\n gridRowStart: 1,\n alignSelf: \"center\",\n justifySelf: \"end\",\n },\n\n // Radio glyph\n radioOuter: {\n ...boxModel,\n display: \"grid\",\n width: \"1rem\",\n height: \"1rem\",\n flexShrink: 0,\n placeContent: \"center\",\n borderRadius: \"9999px\",\n ...shorthands.border(\"1px\", \"solid\", tokens.accentA7),\n backgroundColor: tokens.accentSoft,\n transitionProperty: \"border-color\",\n transitionDuration: \"150ms\",\n },\n radioDot: {\n ...boxModel,\n width: \"0.5rem\",\n height: \"0.5rem\",\n borderRadius: \"9999px\",\n backgroundColor: tokens.accentSolid,\n opacity: 0,\n transitionProperty: \"opacity\",\n transitionDuration: \"150ms\",\n },\n\n // Checkbox glyph\n checkboxOuter: {\n ...boxModel,\n display: \"grid\",\n width: \"1rem\",\n height: \"1rem\",\n flexShrink: 0,\n placeContent: \"center\",\n ...shorthands.borderRadius(\"4px\"),\n ...shorthands.border(\"1px\", \"solid\", tokens.accentA7),\n backgroundColor: tokens.accentSoft,\n color: tokens.accentContrast,\n transitionProperty: \"background-color, border-color\",\n transitionDuration: \"150ms\",\n },\n checkboxCheck: {\n ...boxModel,\n width: \"0.75rem\",\n height: \"0.75rem\",\n opacity: 0,\n transitionProperty: \"opacity\",\n transitionDuration: \"150ms\",\n },\n\n // Switch glyph\n switchTrack: {\n ...boxModel,\n display: \"inline-flex\",\n height: \"1.25rem\",\n width: \"2.125rem\",\n flexShrink: 0,\n alignItems: \"center\",\n borderRadius: \"9999px\",\n ...shorthands.border(\"1px\", \"solid\", \"transparent\"),\n backgroundColor: tokens.grayA3,\n transitionProperty: \"background-color\",\n transitionDuration: \"150ms\",\n },\n switchThumb: {\n ...boxModel,\n display: \"block\",\n width: \"1rem\",\n height: \"1rem\",\n transform: \"translateX(1px)\",\n borderRadius: \"9999px\",\n backgroundColor: tokens.grayContrast,\n // v1 shadow-xs; no shadow tokens in this package.\n boxShadow: \"0 1px 2px 0 #0000000d\",\n transitionProperty: \"transform\",\n transitionDuration: \"150ms\",\n },\n})\n\n// ── Control Glyphs ─────────────────────────────────────────────────────────\n\nconst CheckIcon = (props: React.SVGProps<SVGSVGElement>) => (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 -960 960 960\"\n fill=\"currentColor\"\n aria-hidden=\"true\"\n {...props}\n >\n <path d=\"m382-354 339-339q12-12 28-12t28 12q12 12 12 28.5T777-636L410-268q-12 12-28 12t-28-12L182-440q-12-12-11.5-28.5T183-497q12-12 28.5-12t28.5 12l142 143Z\" />\n </svg>\n)\n\nconst RadioGlyph = () => {\n const styles = useStyles()\n return (\n <span\n className={styles.radioOuter}\n {...{ [SLOT_ATTR]: \"option-card-radio-outer\" }}\n >\n <span\n className={styles.radioDot}\n {...{ [SLOT_ATTR]: \"option-card-radio-dot\" }}\n />\n </span>\n )\n}\n\nconst CheckboxGlyph = () => {\n const styles = useStyles()\n return (\n <span\n className={styles.checkboxOuter}\n {...{ [SLOT_ATTR]: \"option-card-checkbox-outer\" }}\n >\n <CheckIcon\n className={styles.checkboxCheck}\n {...{ [SLOT_ATTR]: \"option-card-checkbox-check\" }}\n />\n </span>\n )\n}\n\nconst SwitchGlyph = () => {\n const styles = useStyles()\n return (\n <span\n className={styles.switchTrack}\n {...{ [SLOT_ATTR]: \"option-card-switch-track\" }}\n >\n <span\n className={styles.switchThumb}\n {...{ [SLOT_ATTR]: \"option-card-switch-thumb\" }}\n />\n </span>\n )\n}\n\n// ── OptionCardGroup ────────────────────────────────────────────────────────\n\ntype OptionCardGroupOwnProps = { layout?: OptionCardLayout }\n\nexport type OptionCardGroupProps =\n | (ToggleGroupSingleProps & OptionCardGroupOwnProps)\n | (ToggleGroupMultipleProps & OptionCardGroupOwnProps)\n\nexport const OptionCardGroup = React.forwardRef<\n HTMLDivElement,\n OptionCardGroupProps\n>(function OptionCardGroup(\n { className, layout = DEFAULT_LAYOUT, ...props },\n ref\n) {\n const styles = useStyles()\n\n return (\n <OptionCardGroupContext.Provider value={{ type: props.type, layout }}>\n <ToggleGroupRoot\n ref={ref}\n data-slot=\"option-card-group\"\n {...{ [SLOT_ATTR]: \"option-card-group\" }}\n data-layout={layout}\n {...(props.type === \"single\" ? { role: \"radiogroup\" } : {})}\n className={mergeClasses(styles.group, styles[layout], className)}\n {...props}\n />\n </OptionCardGroupContext.Provider>\n )\n})\n\n// ── OptionCardControl ──────────────────────────────────────────────────────\n\nexport type OptionCardControlProps = React.ComponentProps<\"span\"> & {\n type?: OptionCardControlType\n}\n\nexport const OptionCardControl = React.forwardRef<\n HTMLSpanElement,\n OptionCardControlProps\n>(function OptionCardControl({ className, type, ...props }, ref) {\n const styles = useStyles()\n const card = React.useContext(OptionCardContext)\n const register = card?.registerType\n\n React.useEffect(() => {\n if (type && register) register(type)\n }, [type, register])\n\n const resolved = type ?? card?.controlType ?? \"checkbox\"\n if (resolved === \"none\") return null\n\n return (\n <span\n ref={ref}\n aria-hidden=\"true\"\n data-slot=\"option-card-control\"\n {...{ [SLOT_ATTR]: \"option-card-control\" }}\n className={mergeClasses(styles.control, className)}\n {...props}\n >\n {resolved === \"radio\" ? (\n <RadioGlyph />\n ) : resolved === \"switch\" ? (\n <SwitchGlyph />\n ) : (\n <CheckboxGlyph />\n )}\n </span>\n )\n})\n\n// ── OptionCardMedia ────────────────────────────────────────────────────────\n\nexport type OptionCardMediaVariant = \"icon\" | \"illustration\"\n\nexport type OptionCardMediaProps = React.ComponentProps<\"span\"> & {\n variant?: OptionCardMediaVariant\n}\n\nexport const OptionCardMedia = React.forwardRef<\n HTMLSpanElement,\n OptionCardMediaProps\n>(function OptionCardMedia({ className, variant = \"icon\", ...props }, ref) {\n const styles = useStyles()\n\n return (\n <span\n ref={ref}\n aria-hidden=\"true\"\n data-slot=\"option-card-media\"\n {...{ [SLOT_ATTR]: \"option-card-media\" }}\n data-variant={variant}\n className={mergeClasses(\n styles.mediaRoot,\n variant === \"illustration\"\n ? styles.mediaIllustration\n : styles.mediaIcon,\n className\n )}\n {...props}\n />\n )\n})\n\n// ── OptionCardTitle ────────────────────────────────────────────────────────\n\nexport type OptionCardTitleProps = React.ComponentProps<\"span\">\n\nexport const OptionCardTitle = React.forwardRef<\n HTMLSpanElement,\n OptionCardTitleProps\n>(function OptionCardTitle({ className, ...props }, ref) {\n const styles = useStyles()\n\n return (\n <span\n ref={ref}\n data-slot=\"option-card-title\"\n {...{ [SLOT_ATTR]: \"option-card-title\" }}\n className={mergeClasses(styles.title, className)}\n {...props}\n />\n )\n})\n\n// ── OptionCardDescription ──────────────────────────────────────────────────\n\nexport type OptionCardDescriptionProps = React.ComponentProps<\"span\">\n\nexport const OptionCardDescription = React.forwardRef<\n HTMLSpanElement,\n OptionCardDescriptionProps\n>(function OptionCardDescription({ className, ...props }, ref) {\n const styles = useStyles()\n\n return (\n <span\n ref={ref}\n data-slot=\"option-card-description\"\n {...{ [SLOT_ATTR]: \"option-card-description\" }}\n className={mergeClasses(styles.description, className)}\n {...props}\n />\n )\n})\n\n// ── OptionCardContent ──────────────────────────────────────────────────────\n\nexport type OptionCardContentProps = React.ComponentProps<\"span\">\n\nconst hasControl = (children: React.ReactNode) =>\n React.Children.toArray(children).some(\n (c) => React.isValidElement(c) && c.type === OptionCardControl\n )\n\nexport const OptionCardContent = React.forwardRef<\n HTMLSpanElement,\n OptionCardContentProps\n>(function OptionCardContent({ className, children, ...props }, ref) {\n const styles = useStyles()\n\n return (\n <span\n ref={ref}\n data-slot=\"option-card-content\"\n {...{ [SLOT_ATTR]: \"option-card-content\" }}\n className={mergeClasses(styles.content, className)}\n {...props}\n >\n {children}\n {!hasControl(children) && <OptionCardControl />}\n </span>\n )\n})\n\n// ── OptionCard ─────────────────────────────────────────────────────────────\n\nexport type OptionCardProps = Omit<\n React.ComponentProps<\"button\">,\n \"onChange\" | \"title\"\n> & {\n /** Value of this option. Required inside an {@link OptionCardGroup}. */\n value?: string\n /** Controlled selected state for a standalone (group-less) card. */\n pressed?: boolean\n /** Uncontrolled default selected state for a standalone card. */\n defaultPressed?: boolean\n /**\n * Fired when a standalone card is toggled, with Base UI's change details second.\n * `eventDetails.cancel()` keeps the current state.\n */\n onPressedChange?: (\n pressed: boolean,\n eventDetails: ToggleChangeDetails\n ) => void\n}\n\nconst isPart = (node: React.ReactNode, ...parts: React.ElementType[]) =>\n React.isValidElement(node) && parts.includes(node.type as React.ElementType)\n\nexport const OptionCard = React.forwardRef<HTMLButtonElement, OptionCardProps>(\n function OptionCard(\n {\n className,\n children,\n value,\n pressed,\n defaultPressed,\n onPressedChange,\n onClick,\n ...props\n },\n ref\n ) {\n const styles = useStyles()\n const group = React.useContext(OptionCardGroupContext)\n const inGroup = group !== null\n\n const fallbackId = React.useId()\n if (\n process.env.NODE_ENV !== \"production\" &&\n inGroup &&\n value === undefined\n ) {\n console.warn(MISSING_VALUE_WARNING)\n }\n\n const [internalPressed, setInternalPressed] = React.useState(\n defaultPressed ?? false\n )\n const isControlled = pressed !== undefined\n const currentPressed = isControlled ? pressed : internalPressed\n const handlePressedChange = (\n next: boolean,\n eventDetails: ToggleChangeDetails\n ) => {\n onPressedChange?.(next, eventDetails)\n if (!isControlled && !eventDetails.isCanceled) setInternalPressed(next)\n }\n\n const groupControlType: OptionCardControlType = inGroup\n ? group.type === \"multiple\"\n ? \"checkbox\"\n : \"radio\"\n : \"checkbox\"\n const [controlType, setControlType] =\n React.useState<OptionCardControlType>(groupControlType)\n const ctx = React.useMemo<OptionCardContextValue>(\n () => ({ controlType, registerType: setControlType }),\n [controlType]\n )\n\n const childArray = React.Children.toArray(children)\n const hasContentChild = childArray.some((c) => isPart(c, OptionCardContent))\n const media = childArray.filter((c) => isPart(c, OptionCardMedia))\n const rest = childArray.filter((c) => !isPart(c, OptionCardMedia))\n const content = hasContentChild ? (\n rest\n ) : (\n <OptionCardContent>\n <OptionCardTitle>{rest}</OptionCardTitle>\n </OptionCardContent>\n )\n\n const body = (\n <>\n {media}\n {content}\n </>\n )\n\n if (inGroup) {\n return (\n <OptionCardContext.Provider value={ctx}>\n <ToggleGroupItemRoot\n ref={ref}\n data-slot=\"option-card\"\n {...{ [SLOT_ATTR]: \"option-card\" }}\n value={value ?? fallbackId}\n className={mergeClasses(styles.card, className)}\n onClick={onClick}\n {...props}\n >\n {body}\n </ToggleGroupItemRoot>\n </OptionCardContext.Provider>\n )\n }\n\n const standaloneRole = controlType === \"switch\" ? \"switch\" : \"checkbox\"\n\n return (\n <OptionCardContext.Provider value={ctx}>\n <TogglePrimitive\n ref={ref}\n data-slot=\"option-card\"\n {...{ [SLOT_ATTR]: \"option-card\" }}\n pressed={currentPressed}\n onPressedChange={handlePressedChange}\n role={standaloneRole}\n aria-checked={currentPressed}\n aria-pressed={undefined}\n className={mergeClasses(styles.card, className)}\n // Base UI types the handlers with its own event wrapper; the element is the same\n // <button>, so the caller's button-typed handlers receive the events they declare.\n {...(props as TogglePrimitive.Props)}\n onClick={respectDefaultPrevented(onClick)}\n >\n {body}\n </TogglePrimitive>\n </OptionCardContext.Provider>\n )\n }\n)\n"],"names":["DEFAULT_LAYOUT","MISSING_VALUE_WARNING","OptionCardGroupContext","React","OptionCardContext","useStyles","makeZenithStyles","boxModel","shorthands","tokens.spacingGroup1","nativeControl","tokens.spacingElement3","tokens.radiusLg","tokens.grayA6","tokens.textSm","tokens.leadingSm","tokens.fontWeightNormal","tokens.grayA12","tokens.accentA8","tokens.accentSoft","SLOT_ATTR","tokens.accentSolid","tokens.accentLight","tokens.spacingElement2","tokens.spacingElement1","tokens.fontWeightSemibold","tokens.textXs","tokens.leadingXs","tokens.grayA11","tokens.accentA7","tokens.accentContrast","tokens.grayA3","tokens.grayContrast","CheckIcon","props","jsx","RadioGlyph","styles","CheckboxGlyph","SwitchGlyph","OptionCardGroup","className","layout","ref","ToggleGroupRoot","mergeClasses","OptionCardControl","type","card","register","resolved","OptionCardMedia","variant","OptionCardTitle","OptionCardDescription","hasControl","children","c","OptionCardContent","jsxs","isPart","node","parts","OptionCard","value","pressed","defaultPressed","onPressedChange","onClick","group","inGroup","fallbackId","internalPressed","setInternalPressed","isControlled","currentPressed","handlePressedChange","next","eventDetails","groupControlType","controlType","setControlType","ctx","childArray","hasContentChild","media","rest","body","Fragment","ToggleGroup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B,EAAaR,EAAO,MAAMI,CAAS;AAAA,QAG7C,GAAIP;AAAA,QACL,SAAS0D,GAAwBxB,CAAO;AAAA,QAEvC,UAAAmB;AAAA,MAAA;AAAA,IAAA,GAEL;AAAA,EAEJ;AACF;"}
|
|
1
|
+
{"version":3,"file":"option-card.js","sources":["../../../src/components/option-card/option-card.tsx"],"sourcesContent":["import * as React from \"react\"\nimport { Toggle as TogglePrimitive } from \"@base-ui/react/toggle\"\nimport { mergeClasses, shorthands } from \"@epilot/zenith-runtime/v1\"\n\nimport { SLOT_ATTR } from \"../../renderer/contract\"\nimport { makeZenithStyles } from \"../../styles/make-styles\"\nimport { boxModel, nativeControl } from \"../../styles/host-reset\"\nimport * as tokens from \"../../tokens\"\nimport {\n respectDefaultPrevented,\n type ToggleChangeDetails,\n} from \"../toggle/toggle\"\nimport {\n ToggleGroupItemRoot,\n ToggleGroupRoot,\n type ToggleGroupMultipleProps,\n type ToggleGroupSingleProps,\n} from \"../toggle/toggle-group\"\n\nconst DEFAULT_LAYOUT = \"grid\" as const\n\nconst MISSING_VALUE_WARNING =\n \"OptionCard: a card inside an OptionCardGroup is missing a `value`. \" +\n \"Give each card a unique `value` so it can be selected and controlled.\"\n\n/** The trailing control glyph an {@link OptionCard} shows for its selected state. */\nexport type OptionCardControlType = \"radio\" | \"checkbox\" | \"switch\" | \"none\"\n\nexport type OptionCardLayout = \"grid\" | \"row\" | \"column\"\n\n// ── Group context ──────────────────────────────────────────────────────────\ntype OptionCardGroupContextValue = {\n type?: \"single\" | \"multiple\"\n layout: OptionCardLayout\n}\nconst OptionCardGroupContext =\n React.createContext<OptionCardGroupContextValue | null>(null)\n\n// ── Card context ───────────────────────────────────────────────────────────\ntype OptionCardContextValue = {\n controlType: OptionCardControlType\n registerType: (type: OptionCardControlType) => void\n}\nconst OptionCardContext = React.createContext<OptionCardContextValue | null>(\n null\n)\n\n// ── Styles ─────────────────────────────────────────────────────────────────\n\nconst useStyles = makeZenithStyles({\n // Group layouts\n group: {\n ...boxModel,\n // The GROUP only lays out. v1's group base class is literally \"\" -- every border, padding and\n // interaction style below used to live here, copied from v1's CARD class onto the wrong element,\n // while `styles.card` and `styles[layout]` were read but never declared. See make-styles.ts for\n // why tsc accepted that for as long as it did.\n display: \"grid\",\n ...shorthands.gap(tokens.spacingGroup1),\n },\n\n // v1: grid-cols-[repeat(auto-fit,minmax(200px,1fr))]\n grid: {\n gridTemplateColumns: \"repeat(auto-fit, minmax(200px, 1fr))\",\n },\n // v1: grid-flow-col auto-cols-fr -- equal-width columns in one non-wrapping row, so options read\n // as equal-weight peers regardless of their content.\n row: {\n gridAutoFlow: \"column\",\n gridAutoColumns: \"minmax(0, 1fr)\",\n },\n // v1: plain `grid` with no template. One column, stacked.\n column: {},\n\n card: {\n ...nativeControl,\n position: \"relative\",\n display: \"flex\",\n alignItems: \"center\",\n // v1 gap-3 = 0.75rem. No token: the semantic scale has no 0.75rem step.\n ...shorthands.gap(tokens.spacingElement3),\n overflow: \"hidden\",\n ...shorthands.borderRadius(tokens.radiusLg),\n // Not currentColor: that picked up this rule's `color: grayA12` and painted a near-black\n // edge. The predecessor's bare `border` resolved to a subtle grey; grayA6 is its match.\n ...shorthands.border(\"1px\", \"solid\", tokens.grayA6),\n ...shorthands.paddingInline(tokens.spacingElement3),\n ...shorthands.paddingBlock(\"0.375rem\"),\n textAlign: \"left\",\n fontSize: tokens.textSm,\n lineHeight: tokens.leadingSm,\n fontWeight: tokens.fontWeightNormal,\n color: tokens.grayA12,\n backgroundColor: \"transparent\",\n transitionProperty: \"color, background-color, border-color, box-shadow\",\n transitionDuration: \"150ms\",\n transitionTimingFunction: \"cubic-bezier(0.4, 0, 0.2, 1)\",\n cursor: \"pointer\",\n userSelect: \"none\",\n height: \"auto\",\n minWidth: \"0\",\n \":focus-visible\": {\n outlineWidth: \"2px\",\n outlineStyle: \"solid\",\n outlineOffset: \"2px\",\n outlineColor: tokens.accentA8,\n },\n \":disabled, &[data-disabled]\": {\n pointerEvents: \"none\",\n opacity: 0.5,\n },\n \"&[data-pressed]\": {\n backgroundColor: tokens.accentSoft,\n ...shorthands.borderColor(tokens.accentA8),\n },\n [`&[data-pressed] [${SLOT_ATTR}=\"option-card-radio-outer\"]`]: {\n ...shorthands.borderColor(tokens.accentSolid),\n },\n [`&[data-pressed] [${SLOT_ATTR}=\"option-card-radio-dot\"]`]: {\n opacity: 1,\n },\n [`&[data-pressed] [${SLOT_ATTR}=\"option-card-checkbox-outer\"]`]: {\n ...shorthands.borderColor(\"transparent\"),\n backgroundColor: tokens.accentSolid,\n },\n [`&[data-pressed] [${SLOT_ATTR}=\"option-card-checkbox-check\"]`]: {\n opacity: 1,\n },\n [`&[data-pressed] [${SLOT_ATTR}=\"option-card-switch-track\"]`]: {\n backgroundColor: tokens.accentSolid,\n },\n [`&[data-pressed] [${SLOT_ATTR}=\"option-card-switch-thumb\"]`]: {\n transform: \"translateX(calc(100% - 1px))\",\n },\n },\n\n // Media\n mediaRoot: {\n flexShrink: 0,\n },\n mediaIcon: {\n ...boxModel,\n display: \"grid\",\n width: \"2.5rem\",\n height: \"2.5rem\",\n placeContent: \"center\",\n alignSelf: \"start\",\n ...shorthands.borderRadius(tokens.radiusLg),\n backgroundColor: tokens.accentSoft,\n color: tokens.accentLight,\n \"& svg\": {\n width: \"1.25rem\",\n height: \"1.25rem\",\n },\n },\n mediaIllustration: {\n position: \"relative\",\n aspectRatio: \"1 / 1\",\n alignSelf: \"stretch\",\n overflow: \"hidden\",\n \"& svg\": {\n position: \"absolute\",\n ...shorthands.inset(0),\n width: \"100%\",\n height: \"100%\",\n },\n \"& img\": {\n position: \"absolute\",\n ...shorthands.inset(0),\n width: \"100%\",\n height: \"100%\",\n objectFit: \"contain\",\n },\n },\n\n // Content\n content: {\n ...boxModel,\n display: \"grid\",\n minWidth: 0,\n flexGrow: 1,\n flexShrink: 1,\n flexBasis: \"0%\",\n gridAutoRows: \"min-content\",\n alignItems: \"center\",\n columnGap: tokens.spacingElement2,\n paddingTop: tokens.spacingElement1,\n paddingBottom: tokens.spacingElement1,\n [`&:has([${SLOT_ATTR}=\"option-card-control\"])`]: {\n gridTemplateColumns: \"1fr auto\",\n },\n },\n\n // Title\n title: {\n ...boxModel,\n gridColumnStart: 1,\n gridRowStart: 1,\n minWidth: 0,\n alignSelf: \"center\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n fontWeight: tokens.fontWeightSemibold,\n },\n\n // Description\n description: {\n ...boxModel,\n gridColumnStart: 1,\n gridRowStart: 2,\n minWidth: 0,\n overflowWrap: \"break-word\",\n fontSize: tokens.textXs,\n lineHeight: tokens.leadingXs,\n fontWeight: tokens.fontWeightNormal,\n color: tokens.grayA11,\n },\n\n // Control\n control: {\n gridColumnStart: 2,\n gridRowStart: 1,\n alignSelf: \"center\",\n justifySelf: \"end\",\n },\n\n // Radio glyph\n radioOuter: {\n ...boxModel,\n display: \"grid\",\n width: \"1rem\",\n height: \"1rem\",\n flexShrink: 0,\n placeContent: \"center\",\n borderRadius: \"9999px\",\n ...shorthands.border(\"1px\", \"solid\", tokens.accentA7),\n backgroundColor: tokens.accentSoft,\n transitionProperty: \"border-color\",\n transitionDuration: \"150ms\",\n },\n radioDot: {\n ...boxModel,\n width: \"0.5rem\",\n height: \"0.5rem\",\n borderRadius: \"9999px\",\n backgroundColor: tokens.accentSolid,\n opacity: 0,\n transitionProperty: \"opacity\",\n transitionDuration: \"150ms\",\n },\n\n // Checkbox glyph\n checkboxOuter: {\n ...boxModel,\n display: \"grid\",\n width: \"1rem\",\n height: \"1rem\",\n flexShrink: 0,\n placeContent: \"center\",\n ...shorthands.borderRadius(\"4px\"),\n ...shorthands.border(\"1px\", \"solid\", tokens.accentA7),\n backgroundColor: tokens.accentSoft,\n color: tokens.accentContrast,\n transitionProperty: \"background-color, border-color\",\n transitionDuration: \"150ms\",\n },\n checkboxCheck: {\n ...boxModel,\n width: \"0.75rem\",\n height: \"0.75rem\",\n opacity: 0,\n transitionProperty: \"opacity\",\n transitionDuration: \"150ms\",\n },\n\n // Switch glyph\n switchTrack: {\n ...boxModel,\n display: \"inline-flex\",\n height: \"1.25rem\",\n width: \"2.125rem\",\n flexShrink: 0,\n alignItems: \"center\",\n borderRadius: \"9999px\",\n ...shorthands.border(\"1px\", \"solid\", \"transparent\"),\n backgroundColor: tokens.grayA3,\n transitionProperty: \"background-color\",\n transitionDuration: \"150ms\",\n },\n switchThumb: {\n ...boxModel,\n display: \"block\",\n width: \"1rem\",\n height: \"1rem\",\n transform: \"translateX(1px)\",\n borderRadius: \"9999px\",\n backgroundColor: tokens.grayContrast,\n // v1 shadow-xs; no shadow tokens in this package.\n boxShadow: \"0 1px 2px 0 #0000000d\",\n transitionProperty: \"transform\",\n transitionDuration: \"150ms\",\n },\n})\n\n// ── Control Glyphs ─────────────────────────────────────────────────────────\n\nconst CheckIcon = (props: React.SVGProps<SVGSVGElement>) => (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 -960 960 960\"\n fill=\"currentColor\"\n aria-hidden=\"true\"\n {...props}\n >\n <path d=\"m382-354 339-339q12-12 28-12t28 12q12 12 12 28.5T777-636L410-268q-12 12-28 12t-28-12L182-440q-12-12-11.5-28.5T183-497q12-12 28.5-12t28.5 12l142 143Z\" />\n </svg>\n)\n\nconst RadioGlyph = () => {\n const styles = useStyles()\n return (\n <span\n className={styles.radioOuter}\n {...{ [SLOT_ATTR]: \"option-card-radio-outer\" }}\n >\n <span\n className={styles.radioDot}\n {...{ [SLOT_ATTR]: \"option-card-radio-dot\" }}\n />\n </span>\n )\n}\n\nconst CheckboxGlyph = () => {\n const styles = useStyles()\n return (\n <span\n className={styles.checkboxOuter}\n {...{ [SLOT_ATTR]: \"option-card-checkbox-outer\" }}\n >\n <CheckIcon\n className={styles.checkboxCheck}\n {...{ [SLOT_ATTR]: \"option-card-checkbox-check\" }}\n />\n </span>\n )\n}\n\nconst SwitchGlyph = () => {\n const styles = useStyles()\n return (\n <span\n className={styles.switchTrack}\n {...{ [SLOT_ATTR]: \"option-card-switch-track\" }}\n >\n <span\n className={styles.switchThumb}\n {...{ [SLOT_ATTR]: \"option-card-switch-thumb\" }}\n />\n </span>\n )\n}\n\n// ── OptionCardGroup ────────────────────────────────────────────────────────\n\ntype OptionCardGroupOwnProps = { layout?: OptionCardLayout }\n\nexport type OptionCardGroupProps =\n | (ToggleGroupSingleProps & OptionCardGroupOwnProps)\n | (ToggleGroupMultipleProps & OptionCardGroupOwnProps)\n\nexport const OptionCardGroup = React.forwardRef<\n HTMLDivElement,\n OptionCardGroupProps\n>(function OptionCardGroup(\n { className, layout = DEFAULT_LAYOUT, ...props },\n ref\n) {\n const styles = useStyles()\n\n return (\n <OptionCardGroupContext.Provider value={{ type: props.type, layout }}>\n <ToggleGroupRoot\n ref={ref}\n data-slot=\"option-card-group\"\n {...{ [SLOT_ATTR]: \"option-card-group\" }}\n data-layout={layout}\n {...(props.type === \"single\" ? { role: \"radiogroup\" } : {})}\n className={mergeClasses(styles.group, styles[layout], className)}\n {...props}\n />\n </OptionCardGroupContext.Provider>\n )\n})\n\n// ── OptionCardControl ──────────────────────────────────────────────────────\n\nexport type OptionCardControlProps = React.ComponentProps<\"span\"> & {\n type?: OptionCardControlType\n}\n\nexport const OptionCardControl = React.forwardRef<\n HTMLSpanElement,\n OptionCardControlProps\n>(function OptionCardControl({ className, type, ...props }, ref) {\n const styles = useStyles()\n const card = React.useContext(OptionCardContext)\n const register = card?.registerType\n\n React.useEffect(() => {\n if (type && register) register(type)\n }, [type, register])\n\n const resolved = type ?? card?.controlType ?? \"checkbox\"\n if (resolved === \"none\") return null\n\n return (\n <span\n ref={ref}\n aria-hidden=\"true\"\n data-slot=\"option-card-control\"\n {...{ [SLOT_ATTR]: \"option-card-control\" }}\n className={mergeClasses(styles.control, className)}\n {...props}\n >\n {resolved === \"radio\" ? (\n <RadioGlyph />\n ) : resolved === \"switch\" ? (\n <SwitchGlyph />\n ) : (\n <CheckboxGlyph />\n )}\n </span>\n )\n})\n\n// ── OptionCardMedia ────────────────────────────────────────────────────────\n\nexport type OptionCardMediaVariant = \"icon\" | \"illustration\"\n\nexport type OptionCardMediaProps = React.ComponentProps<\"span\"> & {\n variant?: OptionCardMediaVariant\n}\n\nexport const OptionCardMedia = React.forwardRef<\n HTMLSpanElement,\n OptionCardMediaProps\n>(function OptionCardMedia({ className, variant = \"icon\", ...props }, ref) {\n const styles = useStyles()\n\n return (\n <span\n ref={ref}\n aria-hidden=\"true\"\n data-slot=\"option-card-media\"\n {...{ [SLOT_ATTR]: \"option-card-media\" }}\n data-variant={variant}\n className={mergeClasses(\n styles.mediaRoot,\n variant === \"illustration\"\n ? styles.mediaIllustration\n : styles.mediaIcon,\n className\n )}\n {...props}\n />\n )\n})\n\n// ── OptionCardTitle ────────────────────────────────────────────────────────\n\nexport type OptionCardTitleProps = React.ComponentProps<\"span\">\n\nexport const OptionCardTitle = React.forwardRef<\n HTMLSpanElement,\n OptionCardTitleProps\n>(function OptionCardTitle({ className, ...props }, ref) {\n const styles = useStyles()\n\n return (\n <span\n ref={ref}\n data-slot=\"option-card-title\"\n {...{ [SLOT_ATTR]: \"option-card-title\" }}\n className={mergeClasses(styles.title, className)}\n {...props}\n />\n )\n})\n\n// ── OptionCardDescription ──────────────────────────────────────────────────\n\nexport type OptionCardDescriptionProps = React.ComponentProps<\"span\">\n\nexport const OptionCardDescription = React.forwardRef<\n HTMLSpanElement,\n OptionCardDescriptionProps\n>(function OptionCardDescription({ className, ...props }, ref) {\n const styles = useStyles()\n\n return (\n <span\n ref={ref}\n data-slot=\"option-card-description\"\n {...{ [SLOT_ATTR]: \"option-card-description\" }}\n className={mergeClasses(styles.description, className)}\n {...props}\n />\n )\n})\n\n// ── OptionCardContent ──────────────────────────────────────────────────────\n\nexport type OptionCardContentProps = React.ComponentProps<\"span\">\n\nconst hasControl = (children: React.ReactNode) =>\n React.Children.toArray(children).some(\n (c) => React.isValidElement(c) && c.type === OptionCardControl\n )\n\nexport const OptionCardContent = React.forwardRef<\n HTMLSpanElement,\n OptionCardContentProps\n>(function OptionCardContent({ className, children, ...props }, ref) {\n const styles = useStyles()\n\n return (\n <span\n ref={ref}\n data-slot=\"option-card-content\"\n {...{ [SLOT_ATTR]: \"option-card-content\" }}\n className={mergeClasses(styles.content, className)}\n {...props}\n >\n {children}\n {!hasControl(children) && <OptionCardControl />}\n </span>\n )\n})\n\n// ── OptionCard ─────────────────────────────────────────────────────────────\n\nexport type OptionCardProps = Omit<\n React.ComponentProps<\"button\">,\n \"onChange\" | \"title\"\n> & {\n /** Value of this option. Required inside an {@link OptionCardGroup}. */\n value?: string\n /** Controlled selected state for a standalone (group-less) card. */\n pressed?: boolean\n /** Uncontrolled default selected state for a standalone card. */\n defaultPressed?: boolean\n /**\n * Fired when a standalone card is toggled, with Base UI's change details second.\n * `eventDetails.cancel()` keeps the current state.\n */\n onPressedChange?: (\n pressed: boolean,\n eventDetails: ToggleChangeDetails\n ) => void\n}\n\nconst isPart = (node: React.ReactNode, ...parts: React.ElementType[]) =>\n React.isValidElement(node) && parts.includes(node.type as React.ElementType)\n\nexport const OptionCard = React.forwardRef<HTMLButtonElement, OptionCardProps>(\n function OptionCard(\n {\n className,\n children,\n value,\n pressed,\n defaultPressed,\n onPressedChange,\n onClick,\n ...props\n },\n ref\n ) {\n const styles = useStyles()\n const group = React.useContext(OptionCardGroupContext)\n const inGroup = group !== null\n\n const fallbackId = React.useId()\n if (\n process.env.NODE_ENV !== \"production\" &&\n inGroup &&\n value === undefined\n ) {\n console.warn(MISSING_VALUE_WARNING)\n }\n\n const [internalPressed, setInternalPressed] = React.useState(\n defaultPressed ?? false\n )\n const isControlled = pressed !== undefined\n const currentPressed = isControlled ? pressed : internalPressed\n const handlePressedChange = (\n next: boolean,\n eventDetails: ToggleChangeDetails\n ) => {\n onPressedChange?.(next, eventDetails)\n if (!isControlled && !eventDetails.isCanceled) setInternalPressed(next)\n }\n\n const groupControlType: OptionCardControlType = inGroup\n ? group.type === \"multiple\"\n ? \"checkbox\"\n : \"radio\"\n : \"checkbox\"\n const [controlType, setControlType] =\n React.useState<OptionCardControlType>(groupControlType)\n const ctx = React.useMemo<OptionCardContextValue>(\n () => ({ controlType, registerType: setControlType }),\n [controlType]\n )\n\n const childArray = React.Children.toArray(children)\n const hasContentChild = childArray.some((c) => isPart(c, OptionCardContent))\n const media = childArray.filter((c) => isPart(c, OptionCardMedia))\n const rest = childArray.filter((c) => !isPart(c, OptionCardMedia))\n const content = hasContentChild ? (\n rest\n ) : (\n <OptionCardContent>\n <OptionCardTitle>{rest}</OptionCardTitle>\n </OptionCardContent>\n )\n\n const body = (\n <>\n {media}\n {content}\n </>\n )\n\n if (inGroup) {\n return (\n <OptionCardContext.Provider value={ctx}>\n <ToggleGroupItemRoot\n ref={ref}\n data-slot=\"option-card\"\n {...{ [SLOT_ATTR]: \"option-card\" }}\n value={value ?? fallbackId}\n className={mergeClasses(styles.card, className)}\n onClick={onClick}\n {...props}\n >\n {body}\n </ToggleGroupItemRoot>\n </OptionCardContext.Provider>\n )\n }\n\n const standaloneRole = controlType === \"switch\" ? \"switch\" : \"checkbox\"\n\n return (\n <OptionCardContext.Provider value={ctx}>\n <TogglePrimitive\n ref={ref}\n data-slot=\"option-card\"\n {...{ [SLOT_ATTR]: \"option-card\" }}\n pressed={currentPressed}\n onPressedChange={handlePressedChange}\n role={standaloneRole}\n aria-checked={currentPressed}\n aria-pressed={undefined}\n className={mergeClasses(styles.card, className)}\n // Base UI types the handlers with its own event wrapper; the element is the same\n // <button>, so the caller's button-typed handlers receive the events they declare.\n {...(props as TogglePrimitive.Props)}\n onClick={respectDefaultPrevented(onClick)}\n >\n {body}\n </TogglePrimitive>\n </OptionCardContext.Provider>\n )\n }\n)\n"],"names":["DEFAULT_LAYOUT","MISSING_VALUE_WARNING","OptionCardGroupContext","React","OptionCardContext","useStyles","makeZenithStyles","boxModel","shorthands","tokens.spacingGroup1","nativeControl","tokens.spacingElement3","tokens.radiusLg","tokens.grayA6","tokens.textSm","tokens.leadingSm","tokens.fontWeightNormal","tokens.grayA12","tokens.accentA8","tokens.accentSoft","SLOT_ATTR","tokens.accentSolid","tokens.accentLight","tokens.spacingElement2","tokens.spacingElement1","tokens.fontWeightSemibold","tokens.textXs","tokens.leadingXs","tokens.grayA11","tokens.accentA7","tokens.accentContrast","tokens.grayA3","tokens.grayContrast","CheckIcon","props","jsx","RadioGlyph","styles","CheckboxGlyph","SwitchGlyph","OptionCardGroup","className","layout","ref","ToggleGroupRoot","mergeClasses","OptionCardControl","type","card","register","resolved","OptionCardMedia","variant","OptionCardTitle","OptionCardDescription","hasControl","children","c","OptionCardContent","jsxs","isPart","node","parts","OptionCard","value","pressed","defaultPressed","onPressedChange","onClick","group","inGroup","fallbackId","internalPressed","setInternalPressed","isControlled","currentPressed","handlePressedChange","next","eventDetails","groupControlType","controlType","setControlType","ctx","childArray","hasContentChild","media","rest","body","Fragment","ToggleGroupItemRoot","standaloneRole","TogglePrimitive","respectDefaultPrevented"],"mappings":";;;;;;;;;AAmBA,MAAMA,KAAiB,QAEjBC,KACJ,4IAaIC,IACJC,EAAM,cAAkD,IAAI,GAOxDC,IAAoBD,EAAM;AAAA,EAC9B;AACF,GAIME,IAAYC,GAAiB;AAAA;AAAA,EAEjC,OAAO;AAAA,IACL,GAAGC;AAAA;AAAA;AAAA;AAAA;AAAA,IAKH,SAAS;AAAA,IACT,GAAGC,EAAW,IAAIC,EAAoB;AAAA,EAAA;AAAA;AAAA,EAIxC,MAAM;AAAA,IACJ,qBAAqB;AAAA,EAAA;AAAA;AAAA;AAAA,EAIvB,KAAK;AAAA,IACH,cAAc;AAAA,IACd,iBAAiB;AAAA,EAAA;AAAA;AAAA,EAGnB,QAAQ,CAAA;AAAA,EAER,MAAM;AAAA,IACJ,GAAGC;AAAA,IACH,UAAU;AAAA,IACV,SAAS;AAAA,IACT,YAAY;AAAA;AAAA,IAEZ,GAAGF,EAAW,IAAIG,CAAsB;AAAA,IACxC,UAAU;AAAA,IACV,GAAGH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QAAA;AAAA,UACC,KAAA9C;AAAA,UACA,aAAU;AAAA,UACJ,CAACvB,CAAS,GAAG;AAAA,UACnB,OAAO4C,KAASO;AAAA,UAChB,WAAW1B,EAAaR,EAAO,MAAMI,CAAS;AAAA,UAC9C,SAAA2B;AAAA,UACC,GAAGlC;AAAA,UAEH,UAAAqD;AAAA,QAAA;AAAA,MAAA,GAEL;AAIJ,UAAMG,IAAiBV,MAAgB,WAAW,WAAW;AAE7D,WACE,gBAAA7C,EAAC/B,EAAkB,UAAlB,EAA2B,OAAO8E,GACjC,UAAA,gBAAA/C;AAAA,MAACwD;AAAAA,MAAA;AAAA,QACC,KAAAhD;AAAA,QACA,aAAU;AAAA,QACJ,CAACvB,CAAS,GAAG;AAAA,QACnB,SAASuD;AAAA,QACT,iBAAiBC;AAAA,QACjB,MAAMc;AAAA,QACN,gBAAcf;AAAA,QACd,gBAAc;AAAA,QACd,WAAW9B,EAAaR,EAAO,MAAMI,CAAS;AAAA,QAG7C,GAAIP;AAAA,QACL,SAAS0D,GAAwBxB,CAAO;AAAA,QAEvC,UAAAmB;AAAA,MAAA;AAAA,IAAA,GAEL;AAAA,EAEJ;AACF;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as z, jsx as O } from "react/jsx-runtime";
|
|
2
2
|
import * as R from "react";
|
|
3
|
-
import { mergeClasses as T, SLOT_ATTR as k, shorthands as L } from "@epilot/zenith-runtime/v1
|
|
3
|
+
import { mergeClasses as T, SLOT_ATTR as k, shorthands as L } from "@epilot/zenith-runtime/v1";
|
|
4
4
|
import { makeZenithStyles as N } from "../../styles/make-styles.js";
|
|
5
5
|
import { boxModel as c } from "../../styles/host-reset.js";
|
|
6
6
|
import { spacingGroup2 as v, spacingElement1 as u, accentA8 as E, radiusMd as I, spacingElement2 as P, fontWeightBold as A, leadingXs as B, textXs as C } from "../../tokens/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pill.js","sources":["../../../src/components/pill/pill.tsx"],"sourcesContent":["import * as React from \"react\"\n\nimport { mergeClasses, shorthands } from \"@epilot/zenith-runtime/v1/core\"\n\nimport { SLOT_ATTR } from \"../../renderer/contract\"\nimport { makeZenithStyles } from \"../../styles/make-styles\"\nimport { boxModel } from \"../../styles/host-reset\"\nimport { NS, PALETTE_NS } from \"../../tokens\"\nimport { isCoreFamily } from \"../../tokens/install\"\nimport { useZenithPaletteTokensFor } from \"../../tokens/use-palette-tokens\"\nimport * as tokens from \"../../tokens\"\nimport { ClearButton } from \"../../lib/clear-button\"\n\n/** Pill — same colour-matrix collapse as Badge, plus a hover background. */\n\nconst COLORS = [\n \"blue\",\n \"sky\",\n \"mint\",\n \"lime\",\n \"green\",\n \"teal\",\n \"cyan\",\n \"indigo\",\n \"purple\",\n \"pink\",\n \"red\",\n \"orange\",\n \"yellow\",\n \"bronze\",\n \"gray\",\n \"accent\",\n \"warning\",\n \"success\",\n \"error\",\n] as const\n\nexport type PillColor = (typeof COLORS)[number]\nexport type PillVariant = \"soft\" | \"solid\" | \"surface\"\n\n/** The four slots a variant can paint. Set inline; read by the atoms below. */\nconst BG = \"--zenith-pill-bg\"\nconst FG = \"--zenith-pill-fg\"\nconst BD = \"--zenith-pill-bd\"\nconst HOV = \"--zenith-pill-hov\"\n\n/**\n * The namespace fix — same shape as Badge's. Pill has no `neutral` alias of its own (its\n * gray-when-disabled resolution already happens in the component body, before `VARIANT_SLOTS` is\n * called — `color` here is always the already-resolved family), so no extra resolve step is needed\n * before classifying it.\n */\nconst namespaceFor = (family: string): string =>\n isCoreFamily(family) ? NS : PALETTE_NS\n\nconst semantic = (color: PillColor, slot: string): string =>\n `var(--zenith-${namespaceFor(color)}-${color}-${slot})`\nconst primitive = (color: PillColor, step: string): string =>\n `var(--zenith-${namespaceFor(color)}-${color}-${step})`\n\n/**\n * Which token each variant pulls into each slot. This replaces the 57-entry compound matrix: it is\n * data about three variants, not about 57 combinations. Text uses the `light` semantic slot, which\n * is Pill's one departure from Badge (Badge uses `default`).\n */\nconst VARIANT_SLOTS: Record<\n PillVariant,\n (color: PillColor) => Record<string, string>\n> = {\n soft: (c) => ({\n [BG]: semantic(c, \"soft\"),\n [FG]: semantic(c, \"light\"),\n [BD]: \"transparent\",\n [HOV]: semantic(c, \"soft-hover\"),\n }),\n solid: (c) => ({\n [BG]: semantic(c, \"solid\"),\n [FG]: semantic(c, \"contrast\"),\n [BD]: \"transparent\",\n [HOV]: semantic(c, \"solid-hover\"),\n }),\n surface: (c) => ({\n [BG]: semantic(c, \"surface\"),\n [FG]: semantic(c, \"light\"),\n [BD]: primitive(c, \"a6\"),\n [HOV]: semantic(c, \"surface-hover\"),\n }),\n}\n\nconst useStyles = makeZenithStyles({\n root: {\n ...boxModel,\n display: \"inline-flex\",\n alignItems: \"center\",\n // v1 `h-6` — a fixed height, not a minimum.\n height: \"1.5rem\",\n gap: tokens.spacingElement1,\n whiteSpace: \"nowrap\",\n flexShrink: 0,\n overflow: \"hidden\",\n fontSize: tokens.textXs,\n lineHeight: tokens.leadingXs,\n fontWeight: tokens.fontWeightBold,\n paddingInline: tokens.spacingElement2,\n borderRadius: tokens.radiusMd,\n transitionProperty: \"color, box-shadow, background-color\",\n // NEVER write a CSS shorthand in a Griffel style object — see Badge. One atom reads one\n // custom property; `border` and a later `borderColor` would both survive.\n ...shorthands.border(\"1px\", \"solid\", `var(${BD})`),\n // The whole point: one rule each, colour supplied per instance.\n backgroundColor: `var(${BG})`,\n color: `var(${FG})`,\n \":focus-visible\": {\n outlineWidth: \"2px\",\n outlineStyle: \"solid\",\n outlineOffset: \"2px\",\n outlineColor: tokens.accentA8,\n },\n // v1 `[&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:pointer-events-none`.\n \"& > svg\": {\n // Literals, not tokens.spacingGroup2: that happens to be 1rem, but a spacing token has no\n // business describing a dimension. The scale has no size family — noted rather than faked.\n width: \"1rem\",\n height: \"1rem\",\n flexShrink: 0,\n pointerEvents: \"none\",\n },\n },\n interactive: {\n cursor: \"pointer\",\n // The one hover rule. It reads the fourth custom property, line-picked per colour and variant\n // by VARIANT_SLOTS — never per-colour hover rules.\n \":hover\": { backgroundColor: `var(${HOV})` },\n },\n hasRemove: {\n ...boxModel,\n // v1's `pr-1` when a clear button is present.\n paddingRight: tokens.spacingElement1,\n },\n disabled: {\n pointerEvents: \"none\",\n },\n removeSize: {\n ...boxModel,\n // v1's `size-4` on the composed ClearButton.\n width: tokens.spacingGroup2,\n height: tokens.spacingGroup2,\n },\n})\n\nexport type PillProps = Omit<React.ComponentProps<\"span\">, \"color\"> & {\n color?: PillColor\n /**\n * Named `variant`, not `style`. v1 called this `style`, which shadows the HTML `style` attribute.\n * Retrocompat is not a requirement here, so the collision is fixed rather than inherited.\n */\n variant?: PillVariant\n disabled?: boolean\n onRemove?: (e: React.MouseEvent<HTMLButtonElement>) => void\n}\n\nexport const Pill = React.forwardRef<HTMLSpanElement, PillProps>(function Pill(\n {\n className,\n color = \"accent\",\n variant = \"soft\",\n disabled,\n onRemove,\n onClick,\n children,\n ...props\n },\n ref\n) {\n const styles = useStyles()\n\n // v1 resolves to gray when disabled and only makes the pill interactive when it has an onClick.\n const resolvedColor: PillColor = disabled ? \"gray\" : color\n\n // A decorative family can still arrive from an expression the build cannot see, so this has to\n // be re-evaluated every commit (WP2B2 — the hook closes over this render's resolved value) — but\n // it is the RESOLVED family that decides, and the five core families Pill offers (accent, gray,\n // warning, success, error) need no palette sheet at all.\n useZenithPaletteTokensFor(resolvedColor)\n const interactive = !!onClick && !disabled\n\n // The hover slot is only meaningful while interactive — v1 attaches its hover background class\n // (`interactive && hoverStyleClasses[...]`) only then, so drop it from the inline properties\n // otherwise. Setting it unconditionally would be harmless but would claim a hover state that\n // cannot be reached.\n const slot = VARIANT_SLOTS[variant](resolvedColor)\n if (!interactive) delete slot[HOV]\n\n return (\n <span\n ref={ref}\n data-slot=\"pill\"\n {...{ [SLOT_ATTR]: \"pill\" }}\n data-disabled={disabled || undefined}\n role={interactive ? \"button\" : undefined}\n tabIndex={interactive ? 0 : undefined}\n onClick={onClick}\n onKeyDown={\n interactive\n ? (e) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault()\n onClick?.(e as unknown as React.MouseEvent<HTMLSpanElement>)\n }\n }\n : undefined\n }\n className={mergeClasses(\n styles.root,\n interactive && styles.interactive,\n onRemove && styles.hasRemove,\n disabled && styles.disabled,\n className\n )}\n style={{ ...slot } as React.CSSProperties}\n {...props}\n >\n {children}\n {onRemove && (\n // v1 composes the shared ClearButton here — hover, focus ring and the size-3 CloseIcon\n // fallback all live in the lib, not inline.\n <ClearButton\n className={styles.removeSize}\n onClick={onRemove}\n disabled={disabled}\n />\n )}\n </span>\n )\n})\n\nexport { COLORS as PILL_COLORS }\n"],"names":["COLORS","BG","FG","BD","HOV","namespaceFor","family","isCoreFamily","NS","PALETTE_NS","semantic","color","slot","primitive","step","VARIANT_SLOTS","c","useStyles","makeZenithStyles","boxModel","tokens.spacingElement1","tokens.textXs","tokens.leadingXs","tokens.fontWeightBold","tokens.spacingElement2","tokens.radiusMd","shorthands","tokens.accentA8","tokens.spacingGroup2","Pill","React","className","variant","disabled","onRemove","onClick","children","props","ref","styles","resolvedColor","useZenithPaletteTokensFor","interactive","jsxs","SLOT_ATTR","e","mergeClasses","jsx","ClearButton"],"mappings":";;;;;;;;;;;AAeA,MAAMA,KAAS;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAMMC,IAAK,oBACLC,IAAK,oBACLC,IAAK,oBACLC,IAAM,qBAQNC,IAAe,CAACC,MACpBC,EAAaD,CAAM,IAAIE,IAAKC,GAExBC,IAAW,CAACC,GAAkBC,MAClC,gBAAgBP,EAAaM,CAAK,CAAC,IAA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A,IAAc,IAAI;AAAA,MAC5B,SAAAP;AAAA,MACA,WACEO,IACI,CAACG,MAAM;AACL,SAAIA,EAAE,QAAQ,WAAWA,EAAE,QAAQ,SACjCA,EAAE,eAAA,GACFV,KAAA,QAAAA,EAAUU;AAAA,MAEd,IACA;AAAA,MAEN,WAAWC;AAAA,QACTP,EAAO;AAAA,QACPG,KAAeH,EAAO;AAAA,QACtBL,KAAYK,EAAO;AAAA,QACnBN,KAAYM,EAAO;AAAA,QACnBR;AAAA,MAAA;AAAA,MAEF,OAAO,EAAE,GAAGnB,EAAA;AAAA,MACX,GAAGyB;AAAA,MAEH,UAAA;AAAA,QAAAD;AAAA,QACAF;AAAA;AAAA,QAGC,gBAAAa;AAAA,UAACC;AAAA,UAAA;AAAA,YACC,WAAWT,EAAO;AAAA,YAClB,SAASL;AAAA,YACT,UAAAD;AAAA,UAAA;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAIR,CAAC;"}
|
|
1
|
+
{"version":3,"file":"pill.js","sources":["../../../src/components/pill/pill.tsx"],"sourcesContent":["import * as React from \"react\"\n\nimport { mergeClasses, shorthands } from \"@epilot/zenith-runtime/v1\"\n\nimport { SLOT_ATTR } from \"../../renderer/contract\"\nimport { makeZenithStyles } from \"../../styles/make-styles\"\nimport { boxModel } from \"../../styles/host-reset\"\nimport { NS, PALETTE_NS } from \"../../tokens\"\nimport { isCoreFamily } from \"../../tokens/install\"\nimport { useZenithPaletteTokensFor } from \"../../tokens/use-palette-tokens\"\nimport * as tokens from \"../../tokens\"\nimport { ClearButton } from \"../../lib/clear-button\"\n\n/** Pill — same colour-matrix collapse as Badge, plus a hover background. */\n\nconst COLORS = [\n \"blue\",\n \"sky\",\n \"mint\",\n \"lime\",\n \"green\",\n \"teal\",\n \"cyan\",\n \"indigo\",\n \"purple\",\n \"pink\",\n \"red\",\n \"orange\",\n \"yellow\",\n \"bronze\",\n \"gray\",\n \"accent\",\n \"warning\",\n \"success\",\n \"error\",\n] as const\n\nexport type PillColor = (typeof COLORS)[number]\nexport type PillVariant = \"soft\" | \"solid\" | \"surface\"\n\n/** The four slots a variant can paint. Set inline; read by the atoms below. */\nconst BG = \"--zenith-pill-bg\"\nconst FG = \"--zenith-pill-fg\"\nconst BD = \"--zenith-pill-bd\"\nconst HOV = \"--zenith-pill-hov\"\n\n/**\n * The namespace fix — same shape as Badge's. Pill has no `neutral` alias of its own (its\n * gray-when-disabled resolution already happens in the component body, before `VARIANT_SLOTS` is\n * called — `color` here is always the already-resolved family), so no extra resolve step is needed\n * before classifying it.\n */\nconst namespaceFor = (family: string): string =>\n isCoreFamily(family) ? NS : PALETTE_NS\n\nconst semantic = (color: PillColor, slot: string): string =>\n `var(--zenith-${namespaceFor(color)}-${color}-${slot})`\nconst primitive = (color: PillColor, step: string): string =>\n `var(--zenith-${namespaceFor(color)}-${color}-${step})`\n\n/**\n * Which token each variant pulls into each slot. This replaces the 57-entry compound matrix: it is\n * data about three variants, not about 57 combinations. Text uses the `light` semantic slot, which\n * is Pill's one departure from Badge (Badge uses `default`).\n */\nconst VARIANT_SLOTS: Record<\n PillVariant,\n (color: PillColor) => Record<string, string>\n> = {\n soft: (c) => ({\n [BG]: semantic(c, \"soft\"),\n [FG]: semantic(c, \"light\"),\n [BD]: \"transparent\",\n [HOV]: semantic(c, \"soft-hover\"),\n }),\n solid: (c) => ({\n [BG]: semantic(c, \"solid\"),\n [FG]: semantic(c, \"contrast\"),\n [BD]: \"transparent\",\n [HOV]: semantic(c, \"solid-hover\"),\n }),\n surface: (c) => ({\n [BG]: semantic(c, \"surface\"),\n [FG]: semantic(c, \"light\"),\n [BD]: primitive(c, \"a6\"),\n [HOV]: semantic(c, \"surface-hover\"),\n }),\n}\n\nconst useStyles = makeZenithStyles({\n root: {\n ...boxModel,\n display: \"inline-flex\",\n alignItems: \"center\",\n // v1 `h-6` — a fixed height, not a minimum.\n height: \"1.5rem\",\n gap: tokens.spacingElement1,\n whiteSpace: \"nowrap\",\n flexShrink: 0,\n overflow: \"hidden\",\n fontSize: tokens.textXs,\n lineHeight: tokens.leadingXs,\n fontWeight: tokens.fontWeightBold,\n paddingInline: tokens.spacingElement2,\n borderRadius: tokens.radiusMd,\n transitionProperty: \"color, box-shadow, background-color\",\n // NEVER write a CSS shorthand in a Griffel style object — see Badge. One atom reads one\n // custom property; `border` and a later `borderColor` would both survive.\n ...shorthands.border(\"1px\", \"solid\", `var(${BD})`),\n // The whole point: one rule each, colour supplied per instance.\n backgroundColor: `var(${BG})`,\n color: `var(${FG})`,\n \":focus-visible\": {\n outlineWidth: \"2px\",\n outlineStyle: \"solid\",\n outlineOffset: \"2px\",\n outlineColor: tokens.accentA8,\n },\n // v1 `[&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:pointer-events-none`.\n \"& > svg\": {\n // Literals, not tokens.spacingGroup2: that happens to be 1rem, but a spacing token has no\n // business describing a dimension. The scale has no size family — noted rather than faked.\n width: \"1rem\",\n height: \"1rem\",\n flexShrink: 0,\n pointerEvents: \"none\",\n },\n },\n interactive: {\n cursor: \"pointer\",\n // The one hover rule. It reads the fourth custom property, line-picked per colour and variant\n // by VARIANT_SLOTS — never per-colour hover rules.\n \":hover\": { backgroundColor: `var(${HOV})` },\n },\n hasRemove: {\n ...boxModel,\n // v1's `pr-1` when a clear button is present.\n paddingRight: tokens.spacingElement1,\n },\n disabled: {\n pointerEvents: \"none\",\n },\n removeSize: {\n ...boxModel,\n // v1's `size-4` on the composed ClearButton.\n width: tokens.spacingGroup2,\n height: tokens.spacingGroup2,\n },\n})\n\nexport type PillProps = Omit<React.ComponentProps<\"span\">, \"color\"> & {\n color?: PillColor\n /**\n * Named `variant`, not `style`. v1 called this `style`, which shadows the HTML `style` attribute.\n * Retrocompat is not a requirement here, so the collision is fixed rather than inherited.\n */\n variant?: PillVariant\n disabled?: boolean\n onRemove?: (e: React.MouseEvent<HTMLButtonElement>) => void\n}\n\nexport const Pill = React.forwardRef<HTMLSpanElement, PillProps>(function Pill(\n {\n className,\n color = \"accent\",\n variant = \"soft\",\n disabled,\n onRemove,\n onClick,\n children,\n ...props\n },\n ref\n) {\n const styles = useStyles()\n\n // v1 resolves to gray when disabled and only makes the pill interactive when it has an onClick.\n const resolvedColor: PillColor = disabled ? \"gray\" : color\n\n // A decorative family can still arrive from an expression the build cannot see, so this has to\n // be re-evaluated every commit (WP2B2 — the hook closes over this render's resolved value) — but\n // it is the RESOLVED family that decides, and the five core families Pill offers (accent, gray,\n // warning, success, error) need no palette sheet at all.\n useZenithPaletteTokensFor(resolvedColor)\n const interactive = !!onClick && !disabled\n\n // The hover slot is only meaningful while interactive — v1 attaches its hover background class\n // (`interactive && hoverStyleClasses[...]`) only then, so drop it from the inline properties\n // otherwise. Setting it unconditionally would be harmless but would claim a hover state that\n // cannot be reached.\n const slot = VARIANT_SLOTS[variant](resolvedColor)\n if (!interactive) delete slot[HOV]\n\n return (\n <span\n ref={ref}\n data-slot=\"pill\"\n {...{ [SLOT_ATTR]: \"pill\" }}\n data-disabled={disabled || undefined}\n role={interactive ? \"button\" : undefined}\n tabIndex={interactive ? 0 : undefined}\n onClick={onClick}\n onKeyDown={\n interactive\n ? (e) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault()\n onClick?.(e as unknown as React.MouseEvent<HTMLSpanElement>)\n }\n }\n : undefined\n }\n className={mergeClasses(\n styles.root,\n interactive && styles.interactive,\n onRemove && styles.hasRemove,\n disabled && styles.disabled,\n className\n )}\n style={{ ...slot } as React.CSSProperties}\n {...props}\n >\n {children}\n {onRemove && (\n // v1 composes the shared ClearButton here — hover, focus ring and the size-3 CloseIcon\n // fallback all live in the lib, not inline.\n <ClearButton\n className={styles.removeSize}\n onClick={onRemove}\n disabled={disabled}\n />\n )}\n </span>\n )\n})\n\nexport { COLORS as PILL_COLORS }\n"],"names":["COLORS","BG","FG","BD","HOV","namespaceFor","family","isCoreFamily","NS","PALETTE_NS","semantic","color","slot","primitive","step","VARIANT_SLOTS","c","useStyles","makeZenithStyles","boxModel","tokens.spacingElement1","tokens.textXs","tokens.leadingXs","tokens.fontWeightBold","tokens.spacingElement2","tokens.radiusMd","shorthands","tokens.accentA8","tokens.spacingGroup2","Pill","React","className","variant","disabled","onRemove","onClick","children","props","ref","styles","resolvedColor","useZenithPaletteTokensFor","interactive","jsxs","SLOT_ATTR","e","mergeClasses","jsx","ClearButton"],"mappings":";;;;;;;;;;;AAeA,MAAMA,KAAS;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAMMC,IAAK,oBACLC,IAAK,oBACLC,IAAK,oBACLC,IAAM,qBAQNC,IAAe,CAACC,MACpBC,EAAaD,CAAM,IAAIE,IAAKC,GAExBC,IAAW,CAACC,GAAkBC,MAClC,gBAAgBP,EAAaM,CAAK,CAAC,IAAIA,CAAK,IAAIC,CAAI,KAChDC,IAAY,CAACF,GAAkBG,MACnC,gBAAgBT,EAAaM,CAAK,CAAC,IAAIA,CAAK,IAAIG,CAAI,KAOhDC,IAGF;AAAA,EACF,MAAM,CAACC,OAAO;AAAA,IACZ,CAACf,CAAE,GAAGS,EAASM,GAAG,MAAM;AAAA,IACxB,CAACd,CAAE,GAAGQ,EAASM,GAAG,OAAO;AAAA,IACzB,CAACb,CAAE,GAAG;AAAA,IACN,CAACC,CAAG,GAAGM,EAASM,GAAG,YAAY;AAAA,EAAA;AAAA,EAEjC,OAAO,CAACA,OAAO;AAAA,IACb,CAACf,CAAE,GAAGS,EAASM,GAAG,OAAO;AAAA,IACzB,CAACd,CAAE,GAAGQ,EAASM,GAAG,UAAU;AAAA,IAC5B,CAACb,CAAE,GAAG;AAAA,IACN,CAACC,CAAG,GAAGM,EAASM,GAAG,aAAa;AAAA,EAAA;AAAA,EAElC,SAAS,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AA;AAIR,CAAC;"}
|
|
@@ -3,7 +3,7 @@ import * as o from "react";
|
|
|
3
3
|
import { createPortal as q } from "react-dom";
|
|
4
4
|
import { Popover as p } from "../../_virtual/_zenith-runtime-family_popover.js";
|
|
5
5
|
import { useRender as G } from "../../_virtual/_zenith-runtime-family_use-render.js";
|
|
6
|
-
import { SLOT_ATTR as m, mergeClasses as P, shorthands as g } from "@epilot/zenith-runtime/v1
|
|
6
|
+
import { SLOT_ATTR as m, mergeClasses as P, shorthands as g } from "@epilot/zenith-runtime/v1";
|
|
7
7
|
import { useAppearanceAttributes as B } from "../appearance-boundary/appearance-boundary.js";
|
|
8
8
|
import { useDensity as J } from "../density-provider/density-provider.js";
|
|
9
9
|
import { makeZenithStyles as K } from "../../styles/make-styles.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.js","sources":["../../../src/components/popover/popover.tsx"],"sourcesContent":["import * as React from \"react\"\nimport { createPortal } from \"react-dom\"\n\nimport { Popover as PopoverPrimitive } from \"@base-ui/react/popover\"\nimport { useRender } from \"@base-ui/react/use-render\"\nimport { mergeClasses, shorthands } from \"@epilot/zenith-runtime/v1/core\"\n\nimport { useAppearanceAttributes } from \"../appearance-boundary/appearance-boundary\"\nimport { useDensity } from \"../density-provider/density-provider\"\nimport { SLOT_ATTR } from \"../../renderer/contract\"\nimport { makeZenithStyles } from \"../../styles/make-styles\"\nimport { boxModel, nativeControl } from \"../../styles/host-reset\"\nimport { OVERLAY_Z_INDEX } from \"../../styles/overlay-layer\"\nimport * as tokens from \"../../tokens\"\n\nconst easeOut = \"cubic-bezier(0.4, 0, 0.2, 1)\"\nconst easeIn = \"cubic-bezier(0.4, 0, 1, 1)\"\n\nconst useStyles = makeZenithStyles({\n // For the bare native `<button>` a Trigger/Close renders. Not applied under `asChild`, where the\n // child owns its own element and two atom sets would race for the same properties.\n nativeTrigger: {\n ...nativeControl,\n },\n // The positioner is what stacks against other layers, as Radix's popper wrapper did; it also\n // keeps that wrapper's `max-content` floor so the content wraps the same way.\n positioner: {\n zIndex: OVERLAY_Z_INDEX,\n minWidth: \"max-content\",\n },\n hideWhenDetached: {\n \"&[data-anchor-hidden]\": {\n visibility: \"hidden\",\n pointerEvents: \"none\",\n },\n },\n popup: {\n ...boxModel,\n backgroundColor: tokens.body,\n color: tokens.grayA12,\n transformOrigin: \"var(--transform-origin)\",\n ...shorthands.borderRadius(tokens.radiusXl),\n ...shorthands.border(\"1px\", \"solid\", tokens.grayA1),\n // v1 shadow-md\n boxShadow: \"0 4px 6px -1px #0000001a, 0 2px 4px -2px #0000001a\",\n outlineStyle: \"none\",\n zIndex: OVERLAY_Z_INDEX,\n transitionProperty: \"opacity, transform\",\n transitionDuration: \"150ms\",\n transitionTimingFunction: easeOut,\n \"&[data-starting-style]\": {\n opacity: 0,\n transform: \"scale(0.95)\",\n },\n \"&[data-starting-style][data-side='bottom']\": {\n transform: `translateY(-${tokens.spacingElement2}) scale(0.95)`,\n },\n \"&[data-starting-style][data-side='left']\": {\n transform: `translateX(${tokens.spacingElement2}) scale(0.95)`,\n },\n \"&[data-starting-style][data-side='right']\": {\n transform: `translateX(-${tokens.spacingElement2}) scale(0.95)`,\n },\n \"&[data-starting-style][data-side='top']\": {\n transform: `translateY(${tokens.spacingElement2}) scale(0.95)`,\n },\n \"&[data-ending-style]\": {\n opacity: 0,\n transform: \"scale(0.95)\",\n transitionDuration: \"100ms\",\n transitionTimingFunction: easeIn,\n },\n \"@media (prefers-reduced-motion: reduce)\": {\n transitionDuration: \"0.01ms\",\n \"&[data-ending-style]\": {\n transitionDuration: \"0.01ms\",\n },\n },\n },\n popupPadding: {\n ...boxModel,\n ...shorthands.padding(tokens.spacingGroup2),\n },\n})\n\n// A single child can arrive wrapped in a one-element array depending on the JSX runtime (MDX call\n// sites do this). Radix's Slot normalised that, so the `asChild` shim has to as well.\nfunction onlySlotChild(children: React.ReactNode) {\n const elements = React.Children.toArray(children).filter(React.isValidElement)\n return elements.length === 1 ? elements[0] : undefined\n}\n\n/**\n * Radix's `asChild` over Base UI's `render`: the single child element becomes the part and keeps\n * its own children, since Base UI lets the rendered element's props win the merge. `extra` joins\n * the part's children, after the caller's.\n */\nfunction contentSlotProps(\n asChild: boolean,\n children: React.ReactNode,\n extra: React.ReactNode\n) {\n const child = asChild ? onlySlotChild(children) : undefined\n if (!child)\n return {\n children: (\n <>\n {children}\n {extra}\n </>\n ),\n }\n if (!extra) return { render: child }\n const childProps = child.props as { children?: React.ReactNode }\n return {\n render: React.cloneElement(child, undefined, childProps.children, extra),\n }\n}\n\n/**\n * A part's props as they were under Radix: its native element's own (DOM attributes, React's\n * handler types, a `CSSProperties` style, a string `className`, `ref`) plus `asChild`. Base UI's\n * prop types widen `style` and `className` to functions of the part's state, wrap every handler's\n * event in `BaseUIEvent` and add props of their own; none of that reaches the public surface.\n */\ntype NativePartProps<Tag extends \"button\" | \"div\"> =\n React.ComponentProps<Tag> & {\n /** Renders the single child element as this part, merging its props and behaviour onto it. */\n asChild?: boolean\n }\n\n/**\n * Radix-shaped focus interception over Base UI's `initialFocus`/`finalFocus`. `preventDefault()`\n * leaves focus where it is; otherwise the default move happens, because Base UI reads a callback\n * that returns `undefined` as \"move nothing\".\n */\nfunction radixFocusCallback(handler: ((event: Event) => void) | undefined) {\n if (!handler) return undefined\n\n return () => {\n const event = new Event(\"focus\", { cancelable: true })\n const before = document.activeElement\n handler(event)\n const moved = document.activeElement\n // Base UI calls `finalFocus` inside React's commit, and React then restores the focus it saw\n // before the commit. Radix ran this handler after the commit, so a handler that moves focus\n // itself has its move applied again once the commit is done.\n if (moved !== before && moved instanceof HTMLElement) {\n queueMicrotask(() => moved.focus())\n }\n return !event.defaultPrevented\n }\n}\n\n/**\n * What `onOpenChange` receives as its second argument: Base UI's change details, declared in\n * Zenith. Base UI's own type drags its popover store into the published declarations, and\n * TypeScript 4 cannot parse that store. `event` narrows with `reason`, as it does in Base UI.\n */\ntype PopoverOpenChangeDetails = (\n | {\n reason: \"trigger-press\"\n event: MouseEvent | PointerEvent | TouchEvent | KeyboardEvent\n }\n | { reason: \"trigger-hover\"; event: MouseEvent }\n | { reason: \"trigger-focus\"; event: FocusEvent }\n | { reason: \"outside-press\"; event: MouseEvent | PointerEvent | TouchEvent }\n | { reason: \"escape-key\"; event: KeyboardEvent }\n | { reason: \"close-press\"; event: MouseEvent | KeyboardEvent | PointerEvent }\n | { reason: \"focus-out\"; event: FocusEvent | KeyboardEvent }\n | { reason: \"imperative-action\"; event: Event }\n | { reason: \"none\"; event: Event }\n) & {\n /** Keeps the popover in its current state. */\n cancel: () => void\n /** Lets the event propagate where the popover would otherwise stop it. */\n allowPropagation: () => void\n isCanceled: boolean\n isPropagationAllowed: boolean\n /** The element that caused the change, if any. */\n trigger: Element | undefined\n /** Keeps the popover's elements mounted after it closes. */\n preventUnmountOnClose: () => void\n}\n\n// Whether the root is modal, for PopoverContent's close part.\nconst PopoverModalContext = React.createContext(false)\n\n/** Anything with a client rect, which is all positioning reads from an anchor. */\ntype Measurable = { getBoundingClientRect(): DOMRect }\n\n// Radix modelled a custom anchor as a part; Base UI takes the element as the Positioner's\n// `anchor`. PopoverAnchor registers its element here and PopoverContent reads it back.\nconst PopoverAnchorContext = React.createContext<{\n anchor: Element | Measurable | null\n setAnchor: (anchor: Element | Measurable | null) => void\n} | null>(null)\n\nexport type PopoverProps = {\n children?: React.ReactNode\n open?: boolean\n defaultOpen?: boolean\n /**\n * While open, keeps Tab inside the popover, hides the rest of the page from assistive tech,\n * locks page scroll and blocks pointer interaction outside it.\n */\n modal?: boolean\n /**\n * Called when the popover opens or closes. `eventDetails.reason` says why (`trigger-press`,\n * `escape-key`, `outside-press`, `focus-out`) and `eventDetails.cancel()` keeps the popover in\n * its current state.\n */\n onOpenChange?: (open: boolean, eventDetails: PopoverOpenChangeDetails) => void\n}\n\nexport const Popover = React.forwardRef<HTMLElement, PopoverProps>(\n function Popover({ onOpenChange, ...props }, _ref) {\n const [anchor, setAnchor] = React.useState<Element | Measurable | null>(\n null\n )\n const anchorContext = React.useMemo(() => ({ anchor, setAnchor }), [anchor])\n\n return (\n <PopoverAnchorContext.Provider value={anchorContext}>\n <PopoverModalContext.Provider value={props.modal === true}>\n <PopoverPrimitive.Root\n data-slot=\"popover\"\n onOpenChange={(open, eventDetails) => {\n // A layer inside (a Volt select or menu, which run on Radix, or a control\n // handling the key itself) prevents the Escape it consumes, but Base UI\n // dismisses regardless, so one Escape would close both. Honour the handled\n // event. Consumers still mix Zenith with Volt on one page, so this stays\n // after the Radix teardown (D12).\n if (\n eventDetails.reason === \"escape-key\" &&\n eventDetails.event.defaultPrevented\n ) {\n eventDetails.cancel()\n return\n }\n onOpenChange?.(open, eventDetails)\n }}\n {...props}\n />\n </PopoverModalContext.Provider>\n </PopoverAnchorContext.Provider>\n )\n }\n)\n\nexport type PopoverTriggerProps = NativePartProps<\"button\">\n\nexport const PopoverTrigger = React.forwardRef<\n HTMLButtonElement,\n PopoverTriggerProps\n>(function PopoverTrigger(\n { asChild = false, children, className, ...props },\n ref\n) {\n const styles = useStyles()\n const child = asChild ? onlySlotChild(children) : undefined\n // Base UI drives a native <button> unless told otherwise; a child that is another intrinsic\n // element gets the ARIA button behaviour instead. A component child counts as a button: Base UI\n // checks the rendered tag on first mount, before a component's element can be known.\n const nativeButton =\n !child || typeof child.type !== \"string\" || child.type === \"button\"\n\n return (\n <PopoverPrimitive.Trigger\n ref={ref}\n data-slot=\"popover-trigger\"\n {...{ [SLOT_ATTR]: \"popover-trigger\" }}\n nativeButton={nativeButton}\n // Radix stamped type=\"button\" on any child, so an input child stays a button input; Base UI\n // only stamps it on a native button. The child's own type still wins.\n {...(child?.type === \"input\" ? { type: \"button\" } : {})}\n className={mergeClasses(!asChild && styles.nativeTrigger, className)}\n {...props}\n {...(child ? { render: child } : { children })}\n />\n )\n})\n\n// Lets PopoverContent supply Base UI's required Portal itself when no PopoverPortal wraps it.\nconst PopoverPortalPresenceContext = React.createContext(false)\n\nexport type PopoverPortalProps = {\n children?: React.ReactNode\n /** The element the content portals into; `document.body` when omitted or null. */\n container?: Element | DocumentFragment | null\n /** Keeps the content mounted while the popover is closed. */\n forceMount?: true\n}\n\nexport const PopoverPortal = React.forwardRef<HTMLElement, PopoverPortalProps>(\n function PopoverPortal({ container, forceMount, ...props }, ref) {\n return (\n <PopoverPortalPresenceContext.Provider value={true}>\n <PopoverPrimitive.Portal\n // Base UI types the ref as its portal div, which any HTMLElement ref can hold.\n ref={ref as React.Ref<HTMLDivElement>}\n data-slot=\"popover-portal\"\n {...{ [SLOT_ATTR]: \"popover-portal\" }}\n // Radix took any Element or DocumentFragment, null meaning the body. Base UI hands a\n // node straight to createPortal, which takes either, but reads null as \"wait for one\".\n container={(container ?? undefined) as HTMLElement | undefined}\n keepMounted={forceMount}\n {...props}\n />\n </PopoverPortalPresenceContext.Provider>\n )\n }\n)\n\nexport type PopoverAnchorProps = NativePartProps<\"div\"> & {\n /** Anchors the popover to something other than an element, such as a text selection; renders nothing. */\n virtualRef?: React.RefObject<{ getBoundingClientRect(): DOMRect }>\n}\n\nexport const PopoverAnchor = React.forwardRef<\n HTMLDivElement,\n PopoverAnchorProps\n>(function PopoverAnchor(\n { asChild = false, children, virtualRef, ...props },\n ref\n) {\n const setAnchor = React.useContext(PopoverAnchorContext)?.setAnchor\n const child = asChild ? onlySlotChild(children) : undefined\n\n // Read after every commit, as Radix did: the ref's target can change without a render.\n React.useEffect(() => {\n if (virtualRef) setAnchor?.(virtualRef.current)\n })\n React.useEffect(() => {\n if (virtualRef) return () => setAnchor?.(null)\n }, [setAnchor, virtualRef])\n\n return useRender({\n render: child,\n ref: setAnchor ? [ref, setAnchor] : ref,\n enabled: !virtualRef,\n props: {\n \"data-slot\": \"popover-anchor\",\n [SLOT_ATTR]: \"popover-anchor\",\n ...props,\n ...(child ? {} : { children }),\n },\n })\n})\n\ntype Side = \"top\" | \"right\" | \"bottom\" | \"left\"\ntype Boundary = Element | null\n\n// Radix let only `avoidCollisions={false}` switch both flip and shift off.\nconst NO_COLLISION_AVOIDANCE = {\n side: \"none\",\n align: \"none\",\n fallbackAxisSide: \"none\",\n} as const\n// Radix flipped to the opposite side and swapped start/end, never to the perpendicular axis.\nconst RADIX_COLLISION_AVOIDANCE = {\n side: \"flip\",\n align: \"flip\",\n fallbackAxisSide: \"none\",\n} as const\n\nexport type PopoverContentProps = NativePartProps<\"div\"> & {\n /**\n * Keeps the content mounted while the popover is closed. Inside PopoverPortal, the portal's\n * `forceMount` decides.\n */\n forceMount?: true\n side?: \"top\" | \"right\" | \"bottom\" | \"left\"\n sideOffset?: number\n align?: \"start\" | \"center\" | \"end\"\n alignOffset?: number\n arrowPadding?: number\n /** Flips and shifts the content to keep it in view. */\n avoidCollisions?: boolean\n /** The elements the content stays within; the viewport when omitted. */\n collisionBoundary?: Boundary | Boundary[]\n collisionPadding?: number | Partial<Record<Side, number>>\n /**\n * `\"partial\"` keeps the content attached to the trigger while any of it is in view; `\"always\"`\n * keeps the content in view even when that detaches it.\n */\n sticky?: \"partial\" | \"always\"\n /** Hides the content while the trigger is fully out of view. */\n hideWhenDetached?: boolean\n /**\n * Kept for compatibility. The position follows the trigger's resizes, layout shifts and scrolls\n * either way; `\"always\"` no longer re-measures on every animation frame.\n */\n updatePositionStrategy?: \"optimized\" | \"always\"\n /** Called before focus moves into the popover; `preventDefault()` leaves focus where it is. */\n onOpenAutoFocus?: (event: Event) => void\n /** Called before focus returns on close; `preventDefault()` skips the return. */\n onCloseAutoFocus?: (event: Event) => void\n flush?: boolean\n}\n\nexport const PopoverContent = React.forwardRef<\n HTMLDivElement,\n PopoverContentProps\n>(function PopoverContent(\n {\n asChild = false,\n className,\n children,\n forceMount,\n side = \"bottom\",\n sideOffset = 4,\n align = \"center\",\n alignOffset = 0,\n arrowPadding = 0,\n avoidCollisions = true,\n collisionBoundary = [],\n collisionPadding = 0,\n sticky = \"partial\",\n hideWhenDetached = false,\n updatePositionStrategy: _updatePositionStrategy,\n onOpenAutoFocus,\n onCloseAutoFocus,\n flush = false,\n ...props\n },\n ref\n) {\n const styles = useStyles()\n const hasPortal = React.useContext(PopoverPortalPresenceContext)\n const anchor = React.useContext(PopoverAnchorContext)?.anchor\n const modal = React.useContext(PopoverModalContext)\n // Base UI counts a Close part through React context, not DOM containment, so the part renders\n // into a node that is never attached: it takes no place among the caller's children.\n const [closePartHost] = React.useState(() =>\n typeof document === \"undefined\" ? null : document.createElement(\"div\")\n )\n // DENSITY-SPEC.md §4.4 — portal content boundary; see dialog.tsx's identical comment.\n const override = useDensity()\n // SPEC.md §2 rule 3 — the same portal asymmetry, for the appearance pair: re-stamp the\n // nearest explicit AppearanceBoundary's mode+surface, or neither attribute when there is\n // none, leaving live shell inheritance in place.\n const appearance = useAppearanceAttributes()\n\n const positioner = (\n <PopoverPrimitive.Positioner\n className={mergeClasses(\n styles.positioner,\n hideWhenDetached && styles.hideWhenDetached\n )}\n anchor={anchor ?? undefined}\n side={side}\n sideOffset={sideOffset}\n align={align}\n alignOffset={alignOffset}\n arrowPadding={arrowPadding}\n // Radix's default boundary is the viewport alone, not every clipping ancestor.\n collisionBoundary={(Array.isArray(collisionBoundary)\n ? collisionBoundary\n : [collisionBoundary]\n ).filter((element): element is Element => element !== null)}\n collisionPadding={collisionPadding}\n collisionAvoidance={\n avoidCollisions ? RADIX_COLLISION_AVOIDANCE : NO_COLLISION_AVOIDANCE\n }\n sticky={sticky === \"always\"}\n >\n <PopoverPrimitive.Popup\n ref={ref}\n data-slot=\"popover-content\"\n {...{ [SLOT_ATTR]: \"popover-content\" }}\n {...(override !== undefined ? { \"data-density\": override } : {})}\n {...appearance}\n initialFocus={radixFocusCallback(onOpenAutoFocus)}\n finalFocus={radixFocusCallback(onCloseAutoFocus)}\n className={mergeClasses(\n styles.popup,\n !flush && styles.popupPadding,\n className\n )}\n {...props}\n {...contentSlotProps(\n asChild,\n children,\n // Base UI traps Tab in a modal popup and hides the rest of the page from assistive\n // tech only while a Close part is inside it; Radix did both for any modal popover. This\n // one is never seen, focused or announced.\n modal &&\n closePartHost &&\n createPortal(<PopoverPrimitive.Close hidden />, closePartHost)\n )}\n />\n </PopoverPrimitive.Positioner>\n )\n\n // Base UI's Positioner requires a Portal ancestor; Radix rendered inline without one.\n return hasPortal ? (\n positioner\n ) : (\n <PopoverPrimitive.Portal keepMounted={forceMount}>\n {positioner}\n </PopoverPrimitive.Portal>\n )\n})\n"],"names":["easeOut","easeIn","useStyles","makeZenithStyles","nativeControl","OVERLAY_Z_INDEX","boxModel","tokens.body","tokens.grayA12","shorthands","tokens.radiusXl","tokens.grayA1","tokens.spacingElement2","tokens.spacingGroup2","onlySlotChild","children","elements","React","contentSlotProps","asChild","extra","child","jsxs","Fragment","childProps","radixFocusCallback","handler","event","before","moved","PopoverModalContext","PopoverAnchorContext","Popover","onOpenChange","props","_ref","anchor","setAnchor","anchorContext","jsx","PopoverPrimitive","open","eventDetails","PopoverTrigger","className","ref","styles","nativeButton","SLOT_ATTR","mergeClasses","PopoverPortalPresenceContext","PopoverPortal","container","forceMount","PopoverAnchor","virtualRef","_a","useRender","NO_COLLISION_AVOIDANCE","RADIX_COLLISION_AVOIDANCE","PopoverContent","side","sideOffset","align","alignOffset","arrowPadding","avoidCollisions","collisionBoundary","collisionPadding","sticky","hideWhenDetached","_updatePositionStrategy","onOpenAutoFocus","onCloseAutoFocus","flush","hasPortal","modal","closePartHost","override","useDensity","appearance","useAppearanceAttributes","positioner","element","createPortal"],"mappings":";;;;;;;;;;;;AAeA,MAAMA,KAAU,gCACVC,KAAS,8BAETC,IAAYC,EAAiB;AAAA;AAAA;AAAA,EAGjC,eAAe;AAAA,IACb,GAAGC;AAAA,EAAA;AAAA;AAAA;AAAA,EAIL,YAAY;AAAA,IACV,QAAQC;AAAA,IACR,UAAU;AAAA,EAAA;AAAA,EAEZ,kBAAkB;AAAA,IAChB,yBAAyB;AAAA,MACvB,YAAY;AAAA,MACZ,eAAe;AAAA,IAAA;AAAA,EACjB;AAAA,EAEF,OAAO;AAAA,IACL,GAAGC;AAAA,I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EAAO;AAAA,YACjBF;AAAA,UAAA;AAAA,UAED,GAAGV;AAAA,UACH,GAAGhB;AAAA,YACFC;AAAA,YACAJ;AAAA;AAAA;AAAA;AAAA,YAIA6D,KACEC,KACAO,EAAa,gBAAA7C,EAACC,EAAiB,OAAjB,EAAuB,QAAM,GAAA,CAAC,GAAIqC,CAAa;AAAA,UAAA;AAAA,QACjE;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAKJ,SAAOF,IACLO,IAEA,gBAAA3C,EAACC,EAAiB,QAAjB,EAAwB,aAAaa,GACnC,UAAA6B,GACH;AAEJ,CAAC;"}
|
|
1
|
+
{"version":3,"file":"popover.js","sources":["../../../src/components/popover/popover.tsx"],"sourcesContent":["import * as React from \"react\"\nimport { createPortal } from \"react-dom\"\n\nimport { Popover as PopoverPrimitive } from \"@base-ui/react/popover\"\nimport { useRender } from \"@base-ui/react/use-render\"\nimport { mergeClasses, shorthands } from \"@epilot/zenith-runtime/v1\"\n\nimport { useAppearanceAttributes } from \"../appearance-boundary/appearance-boundary\"\nimport { useDensity } from \"../density-provider/density-provider\"\nimport { SLOT_ATTR } from \"../../renderer/contract\"\nimport { makeZenithStyles } from \"../../styles/make-styles\"\nimport { boxModel, nativeControl } from \"../../styles/host-reset\"\nimport { OVERLAY_Z_INDEX } from \"../../styles/overlay-layer\"\nimport * as tokens from \"../../tokens\"\n\nconst easeOut = \"cubic-bezier(0.4, 0, 0.2, 1)\"\nconst easeIn = \"cubic-bezier(0.4, 0, 1, 1)\"\n\nconst useStyles = makeZenithStyles({\n // For the bare native `<button>` a Trigger/Close renders. Not applied under `asChild`, where the\n // child owns its own element and two atom sets would race for the same properties.\n nativeTrigger: {\n ...nativeControl,\n },\n // The positioner is what stacks against other layers, as Radix's popper wrapper did; it also\n // keeps that wrapper's `max-content` floor so the content wraps the same way.\n positioner: {\n zIndex: OVERLAY_Z_INDEX,\n minWidth: \"max-content\",\n },\n hideWhenDetached: {\n \"&[data-anchor-hidden]\": {\n visibility: \"hidden\",\n pointerEvents: \"none\",\n },\n },\n popup: {\n ...boxModel,\n backgroundColor: tokens.body,\n color: tokens.grayA12,\n transformOrigin: \"var(--transform-origin)\",\n ...shorthands.borderRadius(tokens.radiusXl),\n ...shorthands.border(\"1px\", \"solid\", tokens.grayA1),\n // v1 shadow-md\n boxShadow: \"0 4px 6px -1px #0000001a, 0 2px 4px -2px #0000001a\",\n outlineStyle: \"none\",\n zIndex: OVERLAY_Z_INDEX,\n transitionProperty: \"opacity, transform\",\n transitionDuration: \"150ms\",\n transitionTimingFunction: easeOut,\n \"&[data-starting-style]\": {\n opacity: 0,\n transform: \"scale(0.95)\",\n },\n \"&[data-starting-style][data-side='bottom']\": {\n transform: `translateY(-${tokens.spacingElement2}) scale(0.95)`,\n },\n \"&[data-starting-style][data-side='left']\": {\n transform: `translateX(${tokens.spacingElement2}) scale(0.95)`,\n },\n \"&[data-starting-style][data-side='right']\": {\n transform: `translateX(-${tokens.spacingElement2}) scale(0.95)`,\n },\n \"&[data-starting-style][data-side='top']\": {\n transform: `translateY(${tokens.spacingElement2}) scale(0.95)`,\n },\n \"&[data-ending-style]\": {\n opacity: 0,\n transform: \"scale(0.95)\",\n transitionDuration: \"100ms\",\n transitionTimingFunction: easeIn,\n },\n \"@media (prefers-reduced-motion: reduce)\": {\n transitionDuration: \"0.01ms\",\n \"&[data-ending-style]\": {\n transitionDuration: \"0.01ms\",\n },\n },\n },\n popupPadding: {\n ...boxModel,\n ...shorthands.padding(tokens.spacingGroup2),\n },\n})\n\n// A single child can arrive wrapped in a one-element array depending on the JSX runtime (MDX call\n// sites do this). Radix's Slot normalised that, so the `asChild` shim has to as well.\nfunction onlySlotChild(children: React.ReactNode) {\n const elements = React.Children.toArray(children).filter(React.isValidElement)\n return elements.length === 1 ? elements[0] : undefined\n}\n\n/**\n * Radix's `asChild` over Base UI's `render`: the single child element becomes the part and keeps\n * its own children, since Base UI lets the rendered element's props win the merge. `extra` joins\n * the part's children, after the caller's.\n */\nfunction contentSlotProps(\n asChild: boolean,\n children: React.ReactNode,\n extra: React.ReactNode\n) {\n const child = asChild ? onlySlotChild(children) : undefined\n if (!child)\n return {\n children: (\n <>\n {children}\n {extra}\n </>\n ),\n }\n if (!extra) return { render: child }\n const childProps = child.props as { children?: React.ReactNode }\n return {\n render: React.cloneElement(child, undefined, childProps.children, extra),\n }\n}\n\n/**\n * A part's props as they were under Radix: its native element's own (DOM attributes, React's\n * handler types, a `CSSProperties` style, a string `className`, `ref`) plus `asChild`. Base UI's\n * prop types widen `style` and `className` to functions of the part's state, wrap every handler's\n * event in `BaseUIEvent` and add props of their own; none of that reaches the public surface.\n */\ntype NativePartProps<Tag extends \"button\" | \"div\"> =\n React.ComponentProps<Tag> & {\n /** Renders the single child element as this part, merging its props and behaviour onto it. */\n asChild?: boolean\n }\n\n/**\n * Radix-shaped focus interception over Base UI's `initialFocus`/`finalFocus`. `preventDefault()`\n * leaves focus where it is; otherwise the default move happens, because Base UI reads a callback\n * that returns `undefined` as \"move nothing\".\n */\nfunction radixFocusCallback(handler: ((event: Event) => void) | undefined) {\n if (!handler) return undefined\n\n return () => {\n const event = new Event(\"focus\", { cancelable: true })\n const before = document.activeElement\n handler(event)\n const moved = document.activeElement\n // Base UI calls `finalFocus` inside React's commit, and React then restores the focus it saw\n // before the commit. Radix ran this handler after the commit, so a handler that moves focus\n // itself has its move applied again once the commit is done.\n if (moved !== before && moved instanceof HTMLElement) {\n queueMicrotask(() => moved.focus())\n }\n return !event.defaultPrevented\n }\n}\n\n/**\n * What `onOpenChange` receives as its second argument: Base UI's change details, declared in\n * Zenith. Base UI's own type drags its popover store into the published declarations, and\n * TypeScript 4 cannot parse that store. `event` narrows with `reason`, as it does in Base UI.\n */\ntype PopoverOpenChangeDetails = (\n | {\n reason: \"trigger-press\"\n event: MouseEvent | PointerEvent | TouchEvent | KeyboardEvent\n }\n | { reason: \"trigger-hover\"; event: MouseEvent }\n | { reason: \"trigger-focus\"; event: FocusEvent }\n | { reason: \"outside-press\"; event: MouseEvent | PointerEvent | TouchEvent }\n | { reason: \"escape-key\"; event: KeyboardEvent }\n | { reason: \"close-press\"; event: MouseEvent | KeyboardEvent | PointerEvent }\n | { reason: \"focus-out\"; event: FocusEvent | KeyboardEvent }\n | { reason: \"imperative-action\"; event: Event }\n | { reason: \"none\"; event: Event }\n) & {\n /** Keeps the popover in its current state. */\n cancel: () => void\n /** Lets the event propagate where the popover would otherwise stop it. */\n allowPropagation: () => void\n isCanceled: boolean\n isPropagationAllowed: boolean\n /** The element that caused the change, if any. */\n trigger: Element | undefined\n /** Keeps the popover's elements mounted after it closes. */\n preventUnmountOnClose: () => void\n}\n\n// Whether the root is modal, for PopoverContent's close part.\nconst PopoverModalContext = React.createContext(false)\n\n/** Anything with a client rect, which is all positioning reads from an anchor. */\ntype Measurable = { getBoundingClientRect(): DOMRect }\n\n// Radix modelled a custom anchor as a part; Base UI takes the element as the Positioner's\n// `anchor`. PopoverAnchor registers its element here and PopoverContent reads it back.\nconst PopoverAnchorContext = React.createContext<{\n anchor: Element | Measurable | null\n setAnchor: (anchor: Element | Measurable | null) => void\n} | null>(null)\n\nexport type PopoverProps = {\n children?: React.ReactNode\n open?: boolean\n defaultOpen?: boolean\n /**\n * While open, keeps Tab inside the popover, hides the rest of the page from assistive tech,\n * locks page scroll and blocks pointer interaction outside it.\n */\n modal?: boolean\n /**\n * Called when the popover opens or closes. `eventDetails.reason` says why (`trigger-press`,\n * `escape-key`, `outside-press`, `focus-out`) and `eventDetails.cancel()` keeps the popover in\n * its current state.\n */\n onOpenChange?: (open: boolean, eventDetails: PopoverOpenChangeDetails) => void\n}\n\nexport const Popover = React.forwardRef<HTMLElement, PopoverProps>(\n function Popover({ onOpenChange, ...props }, _ref) {\n const [anchor, setAnchor] = React.useState<Element | Measurable | null>(\n null\n )\n const anchorContext = React.useMemo(() => ({ anchor, setAnchor }), [anchor])\n\n return (\n <PopoverAnchorContext.Provider value={anchorContext}>\n <PopoverModalContext.Provider value={props.modal === true}>\n <PopoverPrimitive.Root\n data-slot=\"popover\"\n onOpenChange={(open, eventDetails) => {\n // A layer inside (a Volt select or menu, which run on Radix, or a control\n // handling the key itself) prevents the Escape it consumes, but Base UI\n // dismisses regardless, so one Escape would close both. Honour the handled\n // event. Consumers still mix Zenith with Volt on one page, so this stays\n // after the Radix teardown (D12).\n if (\n eventDetails.reason === \"escape-key\" &&\n eventDetails.event.defaultPrevented\n ) {\n eventDetails.cancel()\n return\n }\n onOpenChange?.(open, eventDetails)\n }}\n {...props}\n />\n </PopoverModalContext.Provider>\n </PopoverAnchorContext.Provider>\n )\n }\n)\n\nexport type PopoverTriggerProps = NativePartProps<\"button\">\n\nexport const PopoverTrigger = React.forwardRef<\n HTMLButtonElement,\n PopoverTriggerProps\n>(function PopoverTrigger(\n { asChild = false, children, className, ...props },\n ref\n) {\n const styles = useStyles()\n const child = asChild ? onlySlotChild(children) : undefined\n // Base UI drives a native <button> unless told otherwise; a child that is another intrinsic\n // element gets the ARIA button behaviour instead. A component child counts as a button: Base UI\n // checks the rendered tag on first mount, before a component's element can be known.\n const nativeButton =\n !child || typeof child.type !== \"string\" || child.type === \"button\"\n\n return (\n <PopoverPrimitive.Trigger\n ref={ref}\n data-slot=\"popover-trigger\"\n {...{ [SLOT_ATTR]: \"popover-trigger\" }}\n nativeButton={nativeButton}\n // Radix stamped type=\"button\" on any child, so an input child stays a button input; Base UI\n // only stamps it on a native button. The child's own type still wins.\n {...(child?.type === \"input\" ? { type: \"button\" } : {})}\n className={mergeClasses(!asChild && styles.nativeTrigger, className)}\n {...props}\n {...(child ? { render: child } : { children })}\n />\n )\n})\n\n// Lets PopoverContent supply Base UI's required Portal itself when no PopoverPortal wraps it.\nconst PopoverPortalPresenceContext = React.createContext(false)\n\nexport type PopoverPortalProps = {\n children?: React.ReactNode\n /** The element the content portals into; `document.body` when omitted or null. */\n container?: Element | DocumentFragment | null\n /** Keeps the content mounted while the popover is closed. */\n forceMount?: true\n}\n\nexport const PopoverPortal = React.forwardRef<HTMLElement, PopoverPortalProps>(\n function PopoverPortal({ container, forceMount, ...props }, ref) {\n return (\n <PopoverPortalPresenceContext.Provider value={true}>\n <PopoverPrimitive.Portal\n // Base UI types the ref as its portal div, which any HTMLElement ref can hold.\n ref={ref as React.Ref<HTMLDivElement>}\n data-slot=\"popover-portal\"\n {...{ [SLOT_ATTR]: \"popover-portal\" }}\n // Radix took any Element or DocumentFragment, null meaning the body. Base UI hands a\n // node straight to createPortal, which takes either, but reads null as \"wait for one\".\n container={(container ?? undefined) as HTMLElement | undefined}\n keepMounted={forceMount}\n {...props}\n />\n </PopoverPortalPresenceContext.Provider>\n )\n }\n)\n\nexport type PopoverAnchorProps = NativePartProps<\"div\"> & {\n /** Anchors the popover to something other than an element, such as a text selection; renders nothing. */\n virtualRef?: React.RefObject<{ getBoundingClientRect(): DOMRect }>\n}\n\nexport const PopoverAnchor = React.forwardRef<\n HTMLDivElement,\n PopoverAnchorProps\n>(function PopoverAnchor(\n { asChild = false, children, virtualRef, ...props },\n ref\n) {\n const setAnchor = React.useContext(PopoverAnchorContext)?.setAnchor\n const child = asChild ? onlySlotChild(children) : undefined\n\n // Read after every commit, as Radix did: the ref's target can change without a render.\n React.useEffect(() => {\n if (virtualRef) setAnchor?.(virtualRef.current)\n })\n React.useEffect(() => {\n if (virtualRef) return () => setAnchor?.(null)\n }, [setAnchor, virtualRef])\n\n return useRender({\n render: child,\n ref: setAnchor ? [ref, setAnchor] : ref,\n enabled: !virtualRef,\n props: {\n \"data-slot\": \"popover-anchor\",\n [SLOT_ATTR]: \"popover-anchor\",\n ...props,\n ...(child ? {} : { children }),\n },\n })\n})\n\ntype Side = \"top\" | \"right\" | \"bottom\" | \"left\"\ntype Boundary = Element | null\n\n// Radix let only `avoidCollisions={false}` switch both flip and shift off.\nconst NO_COLLISION_AVOIDANCE = {\n side: \"none\",\n align: \"none\",\n fallbackAxisSide: \"none\",\n} as const\n// Radix flipped to the opposite side and swapped start/end, never to the perpendicular axis.\nconst RADIX_COLLISION_AVOIDANCE = {\n side: \"flip\",\n align: \"flip\",\n fallbackAxisSide: \"none\",\n} as const\n\nexport type PopoverContentProps = NativePartProps<\"div\"> & {\n /**\n * Keeps the content mounted while the popover is closed. Inside PopoverPortal, the portal's\n * `forceMount` decides.\n */\n forceMount?: true\n side?: \"top\" | \"right\" | \"bottom\" | \"left\"\n sideOffset?: number\n align?: \"start\" | \"center\" | \"end\"\n alignOffset?: number\n arrowPadding?: number\n /** Flips and shifts the content to keep it in view. */\n avoidCollisions?: boolean\n /** The elements the content stays within; the viewport when omitted. */\n collisionBoundary?: Boundary | Boundary[]\n collisionPadding?: number | Partial<Record<Side, number>>\n /**\n * `\"partial\"` keeps the content attached to the trigger while any of it is in view; `\"always\"`\n * keeps the content in view even when that detaches it.\n */\n sticky?: \"partial\" | \"always\"\n /** Hides the content while the trigger is fully out of view. */\n hideWhenDetached?: boolean\n /**\n * Kept for compatibility. The position follows the trigger's resizes, layout shifts and scrolls\n * either way; `\"always\"` no longer re-measures on every animation frame.\n */\n updatePositionStrategy?: \"optimized\" | \"always\"\n /** Called before focus moves into the popover; `preventDefault()` leaves focus where it is. */\n onOpenAutoFocus?: (event: Event) => void\n /** Called before focus returns on close; `preventDefault()` skips the return. */\n onCloseAutoFocus?: (event: Event) => void\n flush?: boolean\n}\n\nexport const PopoverContent = React.forwardRef<\n HTMLDivElement,\n PopoverContentProps\n>(function PopoverContent(\n {\n asChild = false,\n className,\n children,\n forceMount,\n side = \"bottom\",\n sideOffset = 4,\n align = \"center\",\n alignOffset = 0,\n arrowPadding = 0,\n avoidCollisions = true,\n collisionBoundary = [],\n collisionPadding = 0,\n sticky = \"partial\",\n hideWhenDetached = false,\n updatePositionStrategy: _updatePositionStrategy,\n onOpenAutoFocus,\n onCloseAutoFocus,\n flush = false,\n ...props\n },\n ref\n) {\n const styles = useStyles()\n const hasPortal = React.useContext(PopoverPortalPresenceContext)\n const anchor = React.useContext(PopoverAnchorContext)?.anchor\n const modal = React.useContext(PopoverModalContext)\n // Base UI counts a Close part through React context, not DOM containment, so the part renders\n // into a node that is never attached: it takes no place among the caller's children.\n const [closePartHost] = React.useState(() =>\n typeof document === \"undefined\" ? null : document.createElement(\"div\")\n )\n // DENSITY-SPEC.md §4.4 — portal content boundary; see dialog.tsx's identical comment.\n const override = useDensity()\n // SPEC.md §2 rule 3 — the same portal asymmetry, for the appearance pair: re-stamp the\n // nearest explicit AppearanceBoundary's mode+surface, or neither attribute when there is\n // none, leaving live shell inheritance in place.\n const appearance = useAppearanceAttributes()\n\n const positioner = (\n <PopoverPrimitive.Positioner\n className={mergeClasses(\n styles.positioner,\n hideWhenDetached && styles.hideWhenDetached\n )}\n anchor={anchor ?? undefined}\n side={side}\n sideOffset={sideOffset}\n align={align}\n alignOffset={alignOffset}\n arrowPadding={arrowPadding}\n // Radix's default boundary is the viewport alone, not every clipping ancestor.\n collisionBoundary={(Array.isArray(collisionBoundary)\n ? collisionBoundary\n : [collisionBoundary]\n ).filter((element): element is Element => element !== null)}\n collisionPadding={collisionPadding}\n collisionAvoidance={\n avoidCollisions ? RADIX_COLLISION_AVOIDANCE : NO_COLLISION_AVOIDANCE\n }\n sticky={sticky === \"always\"}\n >\n <PopoverPrimitive.Popup\n ref={ref}\n data-slot=\"popover-content\"\n {...{ [SLOT_ATTR]: \"popover-content\" }}\n {...(override !== undefined ? { \"data-density\": override } : {})}\n {...appearance}\n initialFocus={radixFocusCallback(onOpenAutoFocus)}\n finalFocus={radixFocusCallback(onCloseAutoFocus)}\n className={mergeClasses(\n styles.popup,\n !flush && styles.popupPadding,\n className\n )}\n {...props}\n {...contentSlotProps(\n asChild,\n children,\n // Base UI traps Tab in a modal popup and hides the rest of the page from assistive\n // tech only while a Close part is inside it; Radix did both for any modal popover. This\n // one is never seen, focused or announced.\n modal &&\n closePartHost &&\n createPortal(<PopoverPrimitive.Close hidden />, closePartHost)\n )}\n />\n </PopoverPrimitive.Positioner>\n )\n\n // Base UI's Positioner requires a Portal ancestor; Radix rendered inline without one.\n return hasPortal ? (\n positioner\n ) : (\n <PopoverPrimitive.Portal keepMounted={forceMount}>\n {positioner}\n </PopoverPrimitive.Portal>\n )\n})\n"],"names":["easeOut","easeIn","useStyles","makeZenithStyles","nativeControl","OVERLAY_Z_INDEX","boxModel","tokens.body","tokens.grayA12","shorthands","tokens.radiusXl","tokens.grayA1","tokens.spacingElement2","tokens.spacingGroup2","onlySlotChild","children","elements","React","contentSlotProps","asChild","extra","child","jsxs","Fragment","childProps","radixFocusCallback","handler","event","before","moved","PopoverModalContext","PopoverAnchorContext","Popover","onOpenChange","props","_ref","anchor","setAnchor","anchorContext","jsx","PopoverPrimitive","open","eventDetails","PopoverTrigger","className","ref","styles","nativeButton","SLOT_ATTR","mergeClasses","PopoverPortalPresenceContext","PopoverPortal","container","forceMount","PopoverAnchor","virtualRef","_a","useRender","NO_COLLISION_AVOIDANCE","RADIX_COLLISION_AVOIDANCE","PopoverContent","side","sideOffset","align","alignOffset","arrowPadding","avoidCollisions","collisionBoundary","collisionPadding","sticky","hideWhenDetached","_updatePositionStrategy","onOpenAutoFocus","onCloseAutoFocus","flush","hasPortal","modal","closePartHost","override","useDensity","appearance","useAppearanceAttributes","positioner","element","createPortal"],"mappings":";;;;;;;;;;;;AAeA,MAAMA,KAAU,gCACVC,KAAS,8BAETC,IAAYC,EAAiB;AAAA;AAAA;AAAA,EAGjC,eAAe;AAAA,IACb,GAAGC;AAAA,EAAA;AAAA;AAAA;AAAA,EAIL,YAAY;AAAA,IACV,QAAQC;AAAA,IACR,UAAU;AAAA,EAAA;AAAA,EAEZ,kBAAkB;AAAA,IAChB,yBAAyB;AAAA,MACvB,YAAY;AAAA,MACZ,eAAe;AAAA,IAAA;AAAA,EACjB;AAAA,EAEF,OAAO;AAAA,IACL,GAAGC;AAAA,IACH,iBAAiBC;AAAAA,IACjB,OAAOC;AAAAA,IACP,iBAAiB;AAAA,IACjB,GAAGC,EAAW,aAAaC,EAAe;AAAA,IAC1C,GAAGD,EAAW,OAAO,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,KACEC,KACAO,EAAa,gBAAA7C,EAACC,EAAiB,OAAjB,EAAuB,QAAM,GAAA,CAAC,GAAIqC,CAAa;AAAA,UAAA;AAAA,QACjE;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAKJ,SAAOF,IACLO,IAEA,gBAAA3C,EAACC,EAAiB,QAAjB,EAAwB,aAAaa,GACnC,UAAA6B,GACH;AAEJ,CAAC;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as t, jsxs as x } from "react/jsx-runtime";
|
|
2
2
|
import * as n from "react";
|
|
3
3
|
import { Radio as p } from "../../_virtual/_zenith-runtime-family_radio.js";
|
|
4
|
-
import { mergeClasses as b, SLOT_ATTR as l, shorthands as i } from "@epilot/zenith-runtime/v1
|
|
4
|
+
import { mergeClasses as b, SLOT_ATTR as l, shorthands as i } from "@epilot/zenith-runtime/v1";
|
|
5
5
|
import { makeZenithStyles as k } from "../../styles/make-styles.js";
|
|
6
|
-
import { boxModel as m, nativeControl as
|
|
7
|
-
import { accentContrast as f, errorA10 as
|
|
6
|
+
import { boxModel as m, nativeControl as v } from "../../styles/host-reset.js";
|
|
7
|
+
import { accentContrast as f, errorA10 as y, focusRing as h, errorSoft as R, grayA3 as g, accentSolid as w, accentOnSoft as S, accentSoft as I, errorA8 as E, accentA7 as A, spacingElement3 as T } from "../../tokens/index.js";
|
|
8
8
|
import { RadioGroupBase as j } from "./radio-group-base.js";
|
|
9
9
|
const G = n.forwardRef(
|
|
10
10
|
function(o, e) {
|
|
@@ -26,11 +26,14 @@ const G = n.forwardRef(
|
|
|
26
26
|
}
|
|
27
27
|
), C = k({
|
|
28
28
|
group: {
|
|
29
|
+
// A named group's radios each render a hidden input beside them, absolutely positioned with no
|
|
30
|
+
// offsets: the group is their containing block, so they cannot escape an app's scroll box (#132).
|
|
31
|
+
position: "relative",
|
|
29
32
|
display: "grid",
|
|
30
33
|
...i.gap(T)
|
|
31
34
|
},
|
|
32
35
|
item: {
|
|
33
|
-
...
|
|
36
|
+
...v,
|
|
34
37
|
boxSizing: "border-box",
|
|
35
38
|
display: "inline-flex",
|
|
36
39
|
alignItems: "center",
|
|
@@ -76,7 +79,7 @@ const G = n.forwardRef(
|
|
|
76
79
|
outlineColor: h
|
|
77
80
|
},
|
|
78
81
|
"&[data-checked][aria-invalid='true'], &[data-checked][data-invalid]": {
|
|
79
|
-
backgroundColor:
|
|
82
|
+
backgroundColor: y,
|
|
80
83
|
...i.borderColor("transparent")
|
|
81
84
|
}
|
|
82
85
|
},
|
|
@@ -106,32 +109,32 @@ function N(a) {
|
|
|
106
109
|
return o.length === 1 ? o[0] : void 0;
|
|
107
110
|
}
|
|
108
111
|
const F = n.forwardRef(
|
|
109
|
-
function({ className: o, asChild: e, children: d, ...u },
|
|
110
|
-
const
|
|
112
|
+
function({ className: o, asChild: e, children: d, ...u }, s) {
|
|
113
|
+
const c = C(), r = e ? N(d) : void 0;
|
|
111
114
|
return /* @__PURE__ */ t(
|
|
112
115
|
j,
|
|
113
116
|
{
|
|
114
|
-
ref:
|
|
117
|
+
ref: s,
|
|
115
118
|
"data-slot": "radio-group",
|
|
116
119
|
[l]: "radio-group",
|
|
117
|
-
className: b(
|
|
120
|
+
className: b(c.group, o),
|
|
118
121
|
...u,
|
|
119
122
|
...r ? { render: r } : { children: d }
|
|
120
123
|
}
|
|
121
124
|
);
|
|
122
125
|
}
|
|
123
|
-
), L = /* @__PURE__ */ t("button", { type: "button" }), P = n.forwardRef(function({ className: o, children: e, asChild: d, checked: u, ...
|
|
126
|
+
), L = /* @__PURE__ */ t("button", { type: "button" }), P = n.forwardRef(function({ className: o, children: e, asChild: d, checked: u, ...s }, c) {
|
|
124
127
|
const r = C();
|
|
125
128
|
return /* @__PURE__ */ x(
|
|
126
129
|
p.Root,
|
|
127
130
|
{
|
|
128
|
-
ref:
|
|
131
|
+
ref: c,
|
|
129
132
|
nativeButton: !0,
|
|
130
133
|
render: L,
|
|
131
134
|
"data-slot": "radio-group-item",
|
|
132
135
|
[l]: "radio-group-item",
|
|
133
136
|
className: b(r.item, o),
|
|
134
|
-
...
|
|
137
|
+
...s,
|
|
135
138
|
children: [
|
|
136
139
|
/* @__PURE__ */ t(
|
|
137
140
|
p.Indicator,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio.js","sources":["../../../src/components/radio/radio.tsx"],"sourcesContent":["import * as React from \"react\"\nimport { Radio } from \"@base-ui/react/radio\"\nimport { mergeClasses, shorthands } from \"@epilot/zenith-runtime/v1/core\"\n\nimport { SLOT_ATTR } from \"../../renderer/contract\"\nimport { makeZenithStyles } from \"../../styles/make-styles\"\nimport { boxModel, nativeControl } from \"../../styles/host-reset\"\nimport * as tokens from \"../../tokens\"\nimport {\n RadioGroupBase,\n type RadioGroupBaseProps,\n type RadioGroupOrientation,\n} from \"./radio-group-base\"\n\nconst CircleIcon = React.forwardRef<SVGSVGElement, React.ComponentProps<\"svg\">>(\n function CircleIcon(props, ref) {\n return (\n <svg\n ref={ref}\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n {...props}\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n </svg>\n )\n }\n)\n\nconst useStyles = makeZenithStyles({\n group: {\n display: \"grid\",\n ...shorthands.gap(tokens.spacingElement3),\n },\n item: {\n ...nativeControl,\n boxSizing: \"border-box\",\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n position: \"relative\",\n aspectRatio: \"1 / 1\",\n width: \"1rem\",\n height: \"1rem\",\n flexShrink: 0,\n borderRadius: \"9999px\",\n ...shorthands.border(\"1px\", \"solid\", tokens.accentA7),\n backgroundColor: tokens.accentSoft,\n color: tokens.accentOnSoft,\n // Tailwind `shadow-xs` — literal per CONVENTIONS B7\n boxShadow: \"0 1px 2px 0 #0000000d\",\n transitionProperty: \"color, box-shadow\",\n transitionDuration: \"150ms\",\n transitionTimingFunction: \"cubic-bezier(0.4, 0, 0.2, 1)\",\n \"@media (prefers-reduced-motion: reduce)\": {\n transitionDuration: \"0.01ms\",\n },\n \":focus-visible\": {\n outlineOffset: \"2px\",\n outlineWidth: \"2px\",\n outlineStyle: \"solid\",\n outlineColor: tokens.focusRing,\n },\n \"&[data-disabled]\": {\n cursor: \"not-allowed\",\n backgroundColor: tokens.grayA3,\n ...shorthands.borderColor(\"transparent\"),\n },\n \"&[data-checked]\": {\n backgroundColor: tokens.accentSolid,\n color: tokens.accentContrast,\n },\n \"&[data-checked][data-disabled]\": {\n backgroundColor: tokens.grayA3,\n },\n \"&[aria-invalid='true'], &[data-invalid]\": {\n backgroundColor: tokens.errorSoft,\n ...shorthands.borderColor(tokens.errorA8),\n outlineColor: tokens.focusRing,\n },\n \"&[data-checked][aria-invalid='true'], &[data-checked][data-invalid]\": {\n backgroundColor: tokens.errorA10,\n ...shorthands.borderColor(\"transparent\"),\n },\n },\n indicator: {\n ...boxModel,\n position: \"relative\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n width: \"100%\",\n height: \"100%\",\n },\n icon: {\n ...boxModel,\n color: tokens.accentContrast,\n position: \"absolute\",\n top: \"50%\",\n left: \"50%\",\n width: \"0.5rem\",\n height: \"0.5rem\",\n transform: \"translate(-50%, -50%)\",\n pointerEvents: \"none\",\n },\n})\n\n/**\n * What `onValueChange` receives as its second argument: Base UI's change details, declared in\n * Zenith so that none of Base UI's internals reach the published declarations, where TypeScript 4\n * cannot parse them.\n */\nexport type RadioGroupChangeDetails = {\n /** Why the value changed. Base UI reports every radio group change as `none`. */\n reason: \"none\"\n /** The native event behind the change. */\n event: Event\n /** Keeps the group's current value. */\n cancel: () => void\n /** Lets the event propagate where the group would otherwise stop it. */\n allowPropagation: () => void\n isCanceled: boolean\n isPropagationAllowed: boolean\n /** The element that caused the change, if any. */\n trigger: Element | undefined\n}\n\ntype RadioGroupRootProps = {\n /**\n * The controlled value of the radio item that should be currently selected.\n *\n * To render an uncontrolled radio group, use the `defaultValue` prop instead.\n */\n value?: string | null | undefined\n /** The value of the radio item that should be initially selected. */\n defaultValue?: string | undefined\n /** Event handler called when the value changes. */\n onValueChange?:\n ((value: string, eventDetails: RadioGroupChangeDetails) => void) | undefined\n /** Whether the component should ignore user interaction. */\n disabled?: boolean | undefined\n /** Whether the user must choose a value before submitting a form. */\n required?: boolean | undefined\n /** Identifies the field when a form is submitted. */\n name?: string | undefined\n /**\n * The axis the arrow keys move along. When set, only that axis' keys move between the options\n * (Up and Down for `vertical`) and it is restated as `aria-orientation`. Unset, all four work.\n */\n orientation?: RadioGroupOrientation | undefined\n /** The reading direction, which decides what Left and Right mean. */\n dir?: \"ltr\" | \"rtl\" | undefined\n /** Whether the arrow keys wrap from the last option to the first and back. Defaults to `true`. */\n loop?: boolean | undefined\n /** Renders the single child element as the group, merging the group's props and behaviour onto it. */\n asChild?: boolean | undefined\n}\n\nexport type RadioGroupProps = Omit<\n React.ComponentPropsWithRef<\"div\">,\n keyof RadioGroupRootProps\n> &\n RadioGroupRootProps\n\n// A single child can arrive wrapped in a one-element array depending on the JSX runtime, which\n// Radix's Slot normalised.\nfunction onlySlotChild(children: React.ReactNode) {\n const elements = React.Children.toArray(children).filter(React.isValidElement)\n return elements.length === 1 ? elements[0] : undefined\n}\n\nexport const RadioGroup = React.forwardRef<HTMLDivElement, RadioGroupProps>(\n function RadioGroup({ className, asChild, children, ...props }, ref) {\n const styles = useStyles()\n const child = asChild ? onlySlotChild(children) : undefined\n\n return (\n <RadioGroupBase\n ref={ref}\n data-slot=\"radio-group\"\n {...{ [SLOT_ATTR]: \"radio-group\" }}\n className={mergeClasses(styles.group, className)}\n // Base UI types the group's handlers for its <div>, which is the element rendered; the\n // caller's div-typed handlers receive exactly the events they declare.\n {...(props as RadioGroupBaseProps)}\n {...(child ? { render: child } : { children })}\n />\n )\n }\n)\n\ntype RadioGroupItemOwnProps = {\n /** The value this item submits and selects the group with. */\n value: string\n /** Whether the item should ignore user interaction. */\n disabled?: boolean | undefined\n /** Whether the user must choose this item before submitting a form. */\n required?: boolean | undefined\n /**\n * @deprecated Has no effect. The group decides which item is checked, as it did on Radix, which\n * ignored this prop.\n */\n checked?: boolean | undefined\n /**\n * @deprecated Has no effect. The indicator is the item's only child, so on Radix this rendered\n * the indicator as the item rather than an element of yours. Remove it.\n */\n asChild?: boolean | undefined\n}\n\n// `name` belongs to the group, which submits it, so it is not an item prop, as on Radix.\nexport type RadioGroupItemProps = Omit<\n React.ComponentPropsWithRef<\"button\">,\n keyof RadioGroupItemOwnProps | \"name\"\n> &\n RadioGroupItemOwnProps\n\n// Base UI renders a <span> by default and moves the caller's id onto its hidden input. A native\n// button keeps the id, the HTMLButtonElement ref, native disabled and <label for> as Radix had them.\nconst ITEM_ELEMENT = <button type=\"button\" />\n\nexport const RadioGroupItem = React.forwardRef<\n HTMLButtonElement,\n RadioGroupItemProps\n>(function RadioGroupItem(\n { className, children, asChild: _asChild, checked: _checked, ...props },\n ref\n) {\n const styles = useStyles()\n\n return (\n <Radio.Root\n ref={ref}\n nativeButton\n render={ITEM_ELEMENT}\n data-slot=\"radio-group-item\"\n {...{ [SLOT_ATTR]: \"radio-group-item\" }}\n className={mergeClasses(styles.item, className)}\n // Base UI types the item's handlers for its default <span>; the element is the button above.\n {...(props as Radio.Root.Props<string>)}\n >\n <Radio.Indicator\n data-slot=\"radio-group-indicator\"\n {...{ [SLOT_ATTR]: \"radio-group-indicator\" }}\n className={styles.indicator}\n >\n <CircleIcon className={styles.icon} />\n </Radio.Indicator>\n {children}\n </Radio.Root>\n )\n})\n"],"names":["CircleIcon","React","props","ref","jsx","useStyles","makeZenithStyles","shorthands","tokens.spacingElement3","nativeControl","tokens.accentA7","tokens.accentSoft","tokens.accentOnSoft","tokens.focusRing","tokens.grayA3","tokens.accentSolid","tokens.accentContrast","tokens.errorSoft","tokens.errorA8","tokens.errorA10","boxModel","onlySlotChild","children","elements","RadioGroup","className","asChild","styles","child","RadioGroupBase","SLOT_ATTR","mergeClasses","ITEM_ELEMENT","RadioGroupItem","_asChild","_checked","jsxs","Radio"],"mappings":";;;;;;;;AAcA,MAAMA,IAAaC,EAAM;AAAA,EACvB,SAAoBC,GAAOC,GAAK;AAC9B,WACE,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAAD;AAAA,QACA,OAAM;AAAA,QACN,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,QAAO;AAAA,QACP,aAAY;AAAA,QACZ,eAAc;AAAA,QACd,gBAAe;AAAA,QACd,GAAGD;AAAA,QAEJ,4BAAC,UAAA,EAAO,IAAG,MAAK,IAAG,MAAK,GAAE,KAAA,CAAK;AAAA,MAAA;AAAA,IAAA;AAAA,EAGrC;AACF,GAEMG,IAAYC,EAAiB;AAAA,EACjC,OAAO;AAAA,IACL,SAAS;AAAA,IACT,GAAGC,EAAW,IAAIC,CAAsB;AAAA,EAAA;AAAA,EAE1C,MAAM;AAAA,IACJ,GAAGC;AAAA,IACH,WAAW;AAAA,IACX,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,gBAAgB;AAAA,IAChB,UAAU;AAAA,IACV,aAAa;AAAA,IACb,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,GAAGF,EAAW,OAAO,OAAO,SAASG,CAAe;AAAA,IACpD,iBAAiBC;AAAAA,IACjB,OAAOC;AAAAA;AAAAA,IAEP,WAAW;AAAA,IACX,oBAAoB;AAAA,IACpB,oBAAoB;AAAA,IACpB,0BAA0B;AAAA,IAC1B,2CAA2C;AAAA,MACzC,oBAAoB;AAAA,IAAA;AAAA,IAEtB,kBAAkB;AAAA,MAChB,eAAe;AAAA,MACf,cAAc;AAAA,MACd,cAAc;AAAA,MACd,cAAcC;AAAAA,IAAO;AAAA,IAEvB,oBAAoB;AAAA,MAClB,QAAQ;AAAA,MACR,iBAAiBC;AAAAA,MACjB,GAAGP,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,EAAaJ,EAAO,OAAOF,CAAS;AAAA,QAG9C,GAAIvB;AAAA,QACJ,GAAI0B,IAAQ,EAAE,QAAQA,EAAA,IAAU,EAAE,UAAAN,EAAA;AAAA,MAAS;AAAA,IAAA;AAAA,EAGlD;AACF,GA8BMU,IAAe,gBAAA5B,EAAC,UAAA,EAAO,MAAK,SAAA,CAAS,GAE9B6B,IAAiBhC,EAAM,WAGlC,SACA,EAAE,WAAAwB,GAAW,UAAAH,GAAU,SAASY,GAAU,SAASC,GAAU,GAAGjC,EAAA,GAChEC,GACA;AACA,QAAMwB,IAAStB,EAAA;AAEf,SACE,gBAAA+B;AAAA,IAACC,EAAM;AAAA,IAAN;AAAA,MACC,KAAAlC;AAAA,MACA,cAAY;AAAA,MACZ,QAAQ6B;AAAA,MACR,aAAU;AAAA,MACJ,CAACF,CAAS,GAAG;AAAA,MACnB,WAAWC,EAAaJ,EAAO,MAAMF,CAAS;AAAA,MAE7C,GAAIvB;AAAA,MAEL,UAAA;AAAA,QAAA,gBAAAE;AAAA,UAACiC,EAAM;AAAA,UAAN;AAAA,YACC,aAAU;AAAA,YACJ,CAACP,CAAS,GAAG;AAAA,YACnB,WAAWH,EAAO;AAAA,YAElB,UAAA,gBAAAvB,EAACJ,GAAA,EAAW,WAAW2B,EAAO,KAAA,CAAM;AAAA,UAAA;AAAA,QAAA;AAAA,QAErCL;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGP,CAAC;"}
|
|
1
|
+
{"version":3,"file":"radio.js","sources":["../../../src/components/radio/radio.tsx"],"sourcesContent":["import * as React from \"react\"\nimport { Radio } from \"@base-ui/react/radio\"\nimport { mergeClasses, shorthands } from \"@epilot/zenith-runtime/v1\"\n\nimport { SLOT_ATTR } from \"../../renderer/contract\"\nimport { makeZenithStyles } from \"../../styles/make-styles\"\nimport { boxModel, nativeControl } from \"../../styles/host-reset\"\nimport * as tokens from \"../../tokens\"\nimport {\n RadioGroupBase,\n type RadioGroupBaseProps,\n type RadioGroupOrientation,\n} from \"./radio-group-base\"\n\nconst CircleIcon = React.forwardRef<SVGSVGElement, React.ComponentProps<\"svg\">>(\n function CircleIcon(props, ref) {\n return (\n <svg\n ref={ref}\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n {...props}\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n </svg>\n )\n }\n)\n\nconst useStyles = makeZenithStyles({\n group: {\n // A named group's radios each render a hidden input beside them, absolutely positioned with no\n // offsets: the group is their containing block, so they cannot escape an app's scroll box (#132).\n position: \"relative\",\n display: \"grid\",\n ...shorthands.gap(tokens.spacingElement3),\n },\n item: {\n ...nativeControl,\n boxSizing: \"border-box\",\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n position: \"relative\",\n aspectRatio: \"1 / 1\",\n width: \"1rem\",\n height: \"1rem\",\n flexShrink: 0,\n borderRadius: \"9999px\",\n ...shorthands.border(\"1px\", \"solid\", tokens.accentA7),\n backgroundColor: tokens.accentSoft,\n color: tokens.accentOnSoft,\n // Tailwind `shadow-xs` — literal per CONVENTIONS B7\n boxShadow: \"0 1px 2px 0 #0000000d\",\n transitionProperty: \"color, box-shadow\",\n transitionDuration: \"150ms\",\n transitionTimingFunction: \"cubic-bezier(0.4, 0, 0.2, 1)\",\n \"@media (prefers-reduced-motion: reduce)\": {\n transitionDuration: \"0.01ms\",\n },\n \":focus-visible\": {\n outlineOffset: \"2px\",\n outlineWidth: \"2px\",\n outlineStyle: \"solid\",\n outlineColor: tokens.focusRing,\n },\n \"&[data-disabled]\": {\n cursor: \"not-allowed\",\n backgroundColor: tokens.grayA3,\n ...shorthands.borderColor(\"transparent\"),\n },\n \"&[data-checked]\": {\n backgroundColor: tokens.accentSolid,\n color: tokens.accentContrast,\n },\n \"&[data-checked][data-disabled]\": {\n backgroundColor: tokens.grayA3,\n },\n \"&[aria-invalid='true'], &[data-invalid]\": {\n backgroundColor: tokens.errorSoft,\n ...shorthands.borderColor(tokens.errorA8),\n outlineColor: tokens.focusRing,\n },\n \"&[data-checked][aria-invalid='true'], &[data-checked][data-invalid]\": {\n backgroundColor: tokens.errorA10,\n ...shorthands.borderColor(\"transparent\"),\n },\n },\n indicator: {\n ...boxModel,\n position: \"relative\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n width: \"100%\",\n height: \"100%\",\n },\n icon: {\n ...boxModel,\n color: tokens.accentContrast,\n position: \"absolute\",\n top: \"50%\",\n left: \"50%\",\n width: \"0.5rem\",\n height: \"0.5rem\",\n transform: \"translate(-50%, -50%)\",\n pointerEvents: \"none\",\n },\n})\n\n/**\n * What `onValueChange` receives as its second argument: Base UI's change details, declared in\n * Zenith so that none of Base UI's internals reach the published declarations, where TypeScript 4\n * cannot parse them.\n */\nexport type RadioGroupChangeDetails = {\n /** Why the value changed. Base UI reports every radio group change as `none`. */\n reason: \"none\"\n /** The native event behind the change. */\n event: Event\n /** Keeps the group's current value. */\n cancel: () => void\n /** Lets the event propagate where the group would otherwise stop it. */\n allowPropagation: () => void\n isCanceled: boolean\n isPropagationAllowed: boolean\n /** The element that caused the change, if any. */\n trigger: Element | undefined\n}\n\ntype RadioGroupRootProps = {\n /**\n * The controlled value of the radio item that should be currently selected.\n *\n * To render an uncontrolled radio group, use the `defaultValue` prop instead.\n */\n value?: string | null | undefined\n /** The value of the radio item that should be initially selected. */\n defaultValue?: string | undefined\n /** Event handler called when the value changes. */\n onValueChange?:\n ((value: string, eventDetails: RadioGroupChangeDetails) => void) | undefined\n /** Whether the component should ignore user interaction. */\n disabled?: boolean | undefined\n /** Whether the user must choose a value before submitting a form. */\n required?: boolean | undefined\n /** Identifies the field when a form is submitted. */\n name?: string | undefined\n /**\n * The axis the arrow keys move along. When set, only that axis' keys move between the options\n * (Up and Down for `vertical`) and it is restated as `aria-orientation`. Unset, all four work.\n */\n orientation?: RadioGroupOrientation | undefined\n /** The reading direction, which decides what Left and Right mean. */\n dir?: \"ltr\" | \"rtl\" | undefined\n /** Whether the arrow keys wrap from the last option to the first and back. Defaults to `true`. */\n loop?: boolean | undefined\n /** Renders the single child element as the group, merging the group's props and behaviour onto it. */\n asChild?: boolean | undefined\n}\n\nexport type RadioGroupProps = Omit<\n React.ComponentPropsWithRef<\"div\">,\n keyof RadioGroupRootProps\n> &\n RadioGroupRootProps\n\n// A single child can arrive wrapped in a one-element array depending on the JSX runtime, which\n// Radix's Slot normalised.\nfunction onlySlotChild(children: React.ReactNode) {\n const elements = React.Children.toArray(children).filter(React.isValidElement)\n return elements.length === 1 ? elements[0] : undefined\n}\n\nexport const RadioGroup = React.forwardRef<HTMLDivElement, RadioGroupProps>(\n function RadioGroup({ className, asChild, children, ...props }, ref) {\n const styles = useStyles()\n const child = asChild ? onlySlotChild(children) : undefined\n\n return (\n <RadioGroupBase\n ref={ref}\n data-slot=\"radio-group\"\n {...{ [SLOT_ATTR]: \"radio-group\" }}\n className={mergeClasses(styles.group, className)}\n // Base UI types the group's handlers for its <div>, which is the element rendered; the\n // caller's div-typed handlers receive exactly the events they declare.\n {...(props as RadioGroupBaseProps)}\n {...(child ? { render: child } : { children })}\n />\n )\n }\n)\n\ntype RadioGroupItemOwnProps = {\n /** The value this item submits and selects the group with. */\n value: string\n /** Whether the item should ignore user interaction. */\n disabled?: boolean | undefined\n /** Whether the user must choose this item before submitting a form. */\n required?: boolean | undefined\n /**\n * @deprecated Has no effect. The group decides which item is checked, as it did on Radix, which\n * ignored this prop.\n */\n checked?: boolean | undefined\n /**\n * @deprecated Has no effect. The indicator is the item's only child, so on Radix this rendered\n * the indicator as the item rather than an element of yours. Remove it.\n */\n asChild?: boolean | undefined\n}\n\n// `name` belongs to the group, which submits it, so it is not an item prop, as on Radix.\nexport type RadioGroupItemProps = Omit<\n React.ComponentPropsWithRef<\"button\">,\n keyof RadioGroupItemOwnProps | \"name\"\n> &\n RadioGroupItemOwnProps\n\n// Base UI renders a <span> by default and moves the caller's id onto its hidden input. A native\n// button keeps the id, the HTMLButtonElement ref, native disabled and <label for> as Radix had them.\nconst ITEM_ELEMENT = <button type=\"button\" />\n\nexport const RadioGroupItem = React.forwardRef<\n HTMLButtonElement,\n RadioGroupItemProps\n>(function RadioGroupItem(\n { className, children, asChild: _asChild, checked: _checked, ...props },\n ref\n) {\n const styles = useStyles()\n\n return (\n <Radio.Root\n ref={ref}\n nativeButton\n render={ITEM_ELEMENT}\n data-slot=\"radio-group-item\"\n {...{ [SLOT_ATTR]: \"radio-group-item\" }}\n className={mergeClasses(styles.item, className)}\n // Base UI types the item's handlers for its default <span>; the element is the button above.\n {...(props as Radio.Root.Props<string>)}\n >\n <Radio.Indicator\n data-slot=\"radio-group-indicator\"\n {...{ [SLOT_ATTR]: \"radio-group-indicator\" }}\n className={styles.indicator}\n >\n <CircleIcon className={styles.icon} />\n </Radio.Indicator>\n {children}\n </Radio.Root>\n )\n})\n"],"names":["CircleIcon","React","props","ref","jsx","useStyles","makeZenithStyles","shorthands","tokens.spacingElement3","nativeControl","tokens.accentA7","tokens.accentSoft","tokens.accentOnSoft","tokens.focusRing","tokens.grayA3","tokens.accentSolid","tokens.accentContrast","tokens.errorSoft","tokens.errorA8","tokens.errorA10","boxModel","onlySlotChild","children","elements","RadioGroup","className","asChild","styles","child","RadioGroupBase","SLOT_ATTR","mergeClasses","ITEM_ELEMENT","RadioGroupItem","_asChild","_checked","jsxs","Radio"],"mappings":";;;;;;;;AAcA,MAAMA,IAAaC,EAAM;AAAA,EACvB,SAAoBC,GAAOC,GAAK;AAC9B,WACE,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAAD;AAAA,QACA,OAAM;AAAA,QACN,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,QAAO;AAAA,QACP,aAAY;AAAA,QACZ,eAAc;AAAA,QACd,gBAAe;AAAA,QACd,GAAGD;AAAA,QAEJ,4BAAC,UAAA,EAAO,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SACE,gBAAA+B;AAAA,IAACC,EAAM;AAAA,IAAN;AAAA,MACC,KAAAlC;AAAA,MACA,cAAY;AAAA,MACZ,QAAQ6B;AAAA,MACR,aAAU;AAAA,MACJ,CAACF,CAAS,GAAG;AAAA,MACnB,WAAWC,EAAaJ,EAAO,MAAMF,CAAS;AAAA,MAE7C,GAAIvB;AAAA,MAEL,UAAA;AAAA,QAAA,gBAAAE;AAAA,UAACiC,EAAM;AAAA,UAAN;AAAA,YACC,aAAU;AAAA,YACJ,CAACP,CAAS,GAAG;AAAA,YACnB,WAAWH,EAAO;AAAA,YAElB,UAAA,gBAAAvB,EAACJ,GAAA,EAAW,WAAW2B,EAAO,KAAA,CAAM;AAAA,UAAA;AAAA,QAAA;AAAA,QAErCL;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGP,CAAC;"}
|
|
@@ -3,7 +3,7 @@ import * as e from "react";
|
|
|
3
3
|
import { CSPProvider as D } from "../../_virtual/_zenith-runtime-family_csp-provider.js";
|
|
4
4
|
import { DirectionProvider as L } from "../../_virtual/_zenith-runtime-family_direction-provider.js";
|
|
5
5
|
import { ScrollArea as m } from "../../_virtual/_zenith-runtime-family_scroll-area.js";
|
|
6
|
-
import { mergeClasses as x, SLOT_ATTR as a, shorthands as g } from "@epilot/zenith-runtime/v1
|
|
6
|
+
import { mergeClasses as x, SLOT_ATTR as a, shorthands as g } from "@epilot/zenith-runtime/v1";
|
|
7
7
|
import { makeZenithStyles as M } from "../../styles/make-styles.js";
|
|
8
8
|
import { boxModel as _ } from "../../styles/host-reset.js";
|
|
9
9
|
import { grayA9 as q, grayA11 as I, grayA10 as X, focusRing as Y } from "../../tokens/index.js";
|