@epilot/zenith-react 0.2.0-next.5 → 0.2.0-next.7
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/components/checkbox/checkbox.js +41 -39
- package/dist/components/checkbox/checkbox.js.map +1 -1
- package/dist/components/radio/radio.js +14 -11
- package/dist/components/radio/radio.js.map +1 -1
- package/dist/components/segmented-control/segmented-control.js +133 -122
- 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/switch/switch.js +59 -57
- package/dist/components/switch/switch.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/tokens.json +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.js","sources":["../../../src/components/switch/switch.tsx"],"sourcesContent":["import * as React from \"react\"\nimport { Switch as SwitchPrimitive } from \"@base-ui/react/switch\"\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\"\n\nconst ThumbIconChecked = React.forwardRef<SVGSVGElement>(\n function ThumbIconChecked(_props, ref) {\n const styles = useThumbIconStyles()\n\n return (\n <svg\n ref={ref}\n data-slot=\"switch-thumb-icon-checked\"\n {...{ [SLOT_ATTR]: \"switch-thumb-icon-checked\" }}\n role=\"presentation\"\n className={styles.checked}\n viewBox=\"0 0 1 6\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <rect width=\"1\" height=\"6\" fill=\"currentColor\" />\n </svg>\n )\n }\n)\n\nconst ThumbIconUnchecked = React.forwardRef<SVGSVGElement>(\n function ThumbIconUnchecked(_props, ref) {\n const styles = useThumbIconStyles()\n\n return (\n <svg\n ref={ref}\n data-slot=\"switch-thumb-icon-unchecked\"\n {...{ [SLOT_ATTR]: \"switch-thumb-icon-unchecked\" }}\n role=\"presentation\"\n className={styles.unchecked}\n viewBox=\"0 0 4 6\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <rect\n x=\"0.5\"\n y=\"0.5\"\n width=\"3\"\n height=\"5\"\n rx=\"1.5\"\n stroke=\"currentColor\"\n />\n </svg>\n )\n }\n)\n\nconst ThumbIconDisabled = React.forwardRef<SVGSVGElement>(\n function ThumbIconDisabled(_props, ref) {\n const styles = useThumbIconStyles()\n\n return (\n <svg\n ref={ref}\n data-slot=\"switch-thumb-icon-disabled\"\n {...{ [SLOT_ATTR]: \"switch-thumb-icon-disabled\" }}\n className={styles.disabled}\n viewBox=\"0 0 4 5\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M0 5V1.875H0.666667V1.25C0.666667 0.90625 0.797223 0.611979 1.05833 0.367188C1.31944 0.122396 1.63333 0 2 0C2.36667 0 2.68056 0.122396 2.94167 0.367188C3.20278 0.611979 3.33333 0.90625 3.33333 1.25V1.875H4V5H0ZM1.33333 1.875H2.66667V1.25C2.66667 1.07292 2.60278 0.924479 2.475 0.804687C2.34722 0.684896 2.18889 0.625 2 0.625C1.81111 0.625 1.65278 0.684896 1.525 0.804687C1.39722 0.924479 1.33333 1.07292 1.33333 1.25V1.875Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n }\n)\n\nconst useThumbIconStyles = makeZenithStyles({\n checked: {\n display: \"none\",\n position: \"absolute\",\n pointerEvents: \"none\",\n ...shorthands.inset(0),\n color: \"currentColor\",\n ...shorthands.margin(\"auto\"),\n },\n unchecked: {\n display: \"none\",\n position: \"absolute\",\n pointerEvents: \"none\",\n ...shorthands.inset(0),\n color: \"currentColor\",\n ...shorthands.margin(\"auto\"),\n },\n disabled: {\n display: \"inline-block\",\n position: \"absolute\",\n pointerEvents: \"none\",\n ...shorthands.inset(0),\n color: \"currentColor\",\n ...shorthands.margin(\"auto\"),\n },\n})\n\nconst useRootStyles = makeZenithStyles({\n root: {\n ...nativeControl,\n boxSizing: \"border-box\",\n display: \"inline-flex\",\n alignItems: \"center\",\n flexShrink: 0,\n cursor: \"pointer\",\n borderRadius: \"9999px\",\n ...shorthands.border(\"1px\", \"solid\", \"transparent\"),\n boxShadow: \"0 1px 2px 0 #0000000d\",\n transitionProperty: \"all\",\n transitionTimingFunction: \"cubic-bezier(0.4, 0, 0.2, 1)\",\n transitionDuration: \"150ms\",\n \"@media (prefers-reduced-motion: reduce)\": {\n transitionDuration: \"0.01ms\",\n },\n \":focus-visible\": {\n outlineWidth: \"2px\",\n outlineStyle: \"solid\",\n outlineOffset: \"2px\",\n outlineColor: tokens.focusRing,\n },\n \":disabled, &[data-disabled]\": {\n pointerEvents: \"none\",\n opacity: 0.5,\n },\n },\n default: {\n color: tokens.grayA8,\n \"&[data-checked]\": { backgroundColor: tokens.accentSolid },\n \"&[data-unchecked]\": { backgroundColor: tokens.grayA3 },\n },\n destructive: {\n color: tokens.errorA8,\n \"&[data-checked]\": { backgroundColor: tokens.errorSolid },\n \"&[data-unchecked]\": { backgroundColor: tokens.errorA3 },\n },\n sm: {\n ...boxModel,\n width: \"1.625rem\",\n height: \"1rem\",\n \"& svg\": { width: \"0.25rem\", height: \"0.375rem\" },\n },\n base: {\n ...boxModel,\n width: \"2.125rem\",\n height: \"1.25rem\",\n \"& svg\": { width: \"0.4375rem\", height: \"0.5rem\" },\n },\n lg: {\n ...boxModel,\n width: \"2.625rem\",\n height: \"1.5rem\",\n \"& svg\": { width: \"0.5rem\", height: \"0.625rem\" },\n },\n})\n\nconst useThumbStyles = makeZenithStyles({\n thumb: {\n ...boxModel,\n position: \"relative\",\n display: \"block\",\n pointerEvents: \"none\",\n borderRadius: \"9999px\",\n boxShadow: \"0 1px 2px 0 #0000000d\",\n transitionProperty: \"transform\",\n transitionTimingFunction: \"cubic-bezier(0.4, 0, 0.2, 1)\",\n transitionDuration: \"150ms\",\n \"@media (prefers-reduced-motion: reduce)\": {\n transitionDuration: \"0.01ms\",\n },\n \"&[data-checked]\": {\n transform: \"translateX(calc(100% - 1px))\",\n },\n \"&[data-unchecked]\": {\n transform: \"translateX(1px)\",\n },\n \"&[data-checked] [data-zenith-slot='switch-thumb-icon-checked']\": {\n display: \"inline-block\",\n },\n \"&[data-unchecked] [data-zenith-slot='switch-thumb-icon-unchecked']\": {\n display: \"inline-block\",\n },\n },\n default: {\n backgroundColor: tokens.grayContrast,\n color: tokens.grayA8,\n \"&[data-checked]\": { color: tokens.accentA11 },\n \"&[data-unchecked]\": { color: tokens.grayA8 },\n },\n destructive: {\n backgroundColor: tokens.errorContrast,\n color: tokens.errorA8,\n \"&[data-checked]\": { color: tokens.errorA11 },\n \"&[data-unchecked]\": { color: tokens.errorA8 },\n },\n sm: {\n ...boxModel,\n width: \"0.75rem\",\n height: \"0.75rem\",\n \"& svg[data-zenith-slot='switch-thumb-icon-disabled']\": {\n width: \"0.25rem\",\n },\n },\n base: {\n ...boxModel,\n width: \"1rem\",\n height: \"1rem\",\n \"& svg[data-zenith-slot='switch-thumb-icon-disabled']\": {\n width: \"0.375rem\",\n },\n },\n lg: {\n ...boxModel,\n width: \"1.25rem\",\n height: \"1.25rem\",\n \"& svg[data-zenith-slot='switch-thumb-icon-disabled']\": {\n width: \"0.4375rem\",\n },\n },\n})\n\n/**\n * `primary` is a deprecated alias of `default`, carried because v1 has it and real consumers still\n * pass it — entity-sidepanel's SettingsControls does. v1's own comment marks it deprecated and its\n * styles are byte-identical to `default`, so it is mapped rather than duplicated.\n *\n * @remarks `primary` is deprecated; use `default`.\n */\nexport type SwitchVariant = \"default\" | \"destructive\" | \"primary\"\nexport type SwitchSize = \"sm\" | \"base\" | \"lg\"\n\n/**\n * What `onCheckedChange` 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 */\ntype SwitchCheckedChangeDetails = {\n /** Why the switch changed. Base UI reports every switch change as `none`. */\n reason: \"none\"\n /** The native event behind the change. */\n event: Event\n /** Keeps the switch in its current state. */\n cancel: () => void\n /** Lets the event propagate where the switch 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\n/**\n * The switch props Base UI adds to a `<button>`'s, declared in Zenith with Base UI's types. The\n * root renders a native `<button>`, so the DOM attributes, handlers, `ref`, `key`, `className`,\n * `style` and `value` stay the button's, as they were on Radix; `render` and `nativeButton` are\n * fixed by the wrapper.\n */\ntype SwitchRootProps = {\n /**\n * Whether the switch is currently active.\n *\n * To render an uncontrolled switch, use the `defaultChecked` prop instead.\n */\n checked?: boolean | undefined\n /** Whether the component should ignore user interaction. */\n disabled?: boolean | undefined\n /** A ref to access the hidden `<input>` element. */\n inputRef?: React.Ref<HTMLInputElement> | undefined\n /** Identifies the field when a form is submitted. */\n name?: string | undefined\n /**\n * Identifies the form that owns the hidden input.\n * Useful when the switch is rendered outside the form.\n */\n form?: string | undefined\n /** Event handler called when the switch is activated or deactivated. */\n onCheckedChange?:\n | ((checked: boolean, eventDetails: SwitchCheckedChangeDetails) => void)\n | undefined\n /** Whether the user should be unable to activate or deactivate the switch. */\n readOnly?: boolean | undefined\n /** Whether the user must activate the switch before submitting a form. */\n required?: boolean | undefined\n /**\n * The value submitted with the form when the switch is off.\n * By default, unchecked switches do not submit any value, matching native checkbox behavior.\n */\n uncheckedValue?: string | undefined\n}\n\nexport type SwitchProps = Omit<\n React.ComponentPropsWithRef<\"button\">,\n keyof SwitchRootProps\n> &\n SwitchRootProps & {\n /**\n * `default` or `destructive`. `primary` is a **deprecated alias of `default`** with byte-\n * identical styles, kept because v1 had it and consumers still pass it. Choosing it changes\n * nothing; use `default`.\n */\n variant?: SwitchVariant\n /** @default \"base\" */\n size?: SwitchSize\n showThumbIcon?: boolean\n /**\n * @deprecated Has no effect. The thumb is the switch's only child, so on Radix this rendered\n * the thumb as the switch rather than an element of yours. Remove it.\n */\n asChild?: boolean\n }\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 ROOT_ELEMENT = <button />\n\nexport const Switch = React.forwardRef<HTMLButtonElement, SwitchProps>(\n function Switch(\n {\n variant = \"default\",\n size = \"base\",\n className,\n showThumbIcon = false,\n asChild: _asChild,\n value,\n ...props\n },\n ref\n ) {\n const rootStyles = useRootStyles()\n const thumbStyles = useThumbStyles()\n // See SwitchVariant: `primary` is v1's deprecated alias for `default`, same styles.\n const variantKey = variant === \"primary\" ? \"default\" : variant\n\n return (\n <SwitchPrimitive.Root\n ref={ref}\n nativeButton\n render={ROOT_ELEMENT}\n // Radix took the button's value type; Base UI submits a string, so it is converted here\n // the way the button's value attribute stringified it.\n value={value === undefined ? undefined : String(value)}\n data-slot=\"switch\"\n {...{ [SLOT_ATTR]: \"switch\" }}\n className={mergeClasses(\n rootStyles.root,\n rootStyles[variantKey],\n rootStyles[size],\n className\n )}\n // Base UI types the root's handlers for its default <span>; the element is the button\n // above, so the caller's button-typed handlers receive exactly the events they declare.\n {...(props as SwitchPrimitive.Root.Props)}\n >\n <SwitchPrimitive.Thumb\n data-slot=\"switch-thumb\"\n {...{ [SLOT_ATTR]: \"switch-thumb\" }}\n className={mergeClasses(\n thumbStyles.thumb,\n thumbStyles[variantKey],\n thumbStyles[size]\n )}\n >\n {showThumbIcon && !props.disabled && <ThumbIconChecked />}\n {showThumbIcon && !props.disabled && <ThumbIconUnchecked />}\n {showThumbIcon && props.disabled && <ThumbIconDisabled />}\n </SwitchPrimitive.Thumb>\n </SwitchPrimitive.Root>\n )\n }\n)\n"],"names":["ThumbIconChecked","React","_props","ref","styles","useThumbIconStyles","jsx","SLOT_ATTR","ThumbIconUnchecked","ThumbIconDisabled","makeZenithStyles","shorthands","useRootStyles","nativeControl","tokens.focusRing","tokens.grayA8","tokens.accentSolid","tokens.grayA3","tokens.errorA8","tokens.errorSolid","tokens.errorA3","boxModel","useThumbStyles","tokens.grayContrast","tokens.accentA11","tokens.errorContrast","tokens.errorA11","ROOT_ELEMENT","Switch","variant","size","className","showThumbIcon","_asChild","value","props","rootStyles","thumbStyles","variantKey","SwitchPrimitive","mergeClasses","jsxs"],"mappings":";;;;;;;AASA,MAAMA,IAAmBC,EAAM;AAAA,EAC7B,SAA0BC,GAAQC,GAAK;AACrC,UAAMC,IAASC,EAAA;AAEf,WACE,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAAH;AAAA,QACA,aAAU;AAAA,QACJ,CAACI,CAAS,GAAG;AAAA,QACnB,MAAK;AAAA,QACL,WAAWH,EAAO;AAAA,QAClB,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,OAAM;AAAA,QAEN,4BAAC,QAAA,EAAK,OAAM,KAAI,QAAO,KAAI,MAAK,eAAA,CAAe;AAAA,MAAA;AAAA,IAAA;AAAA,EAGrD;AACF,GAEMI,IAAqBP,EAAM;AAAA,EAC/B,SAA4BC,GAAQC,GAAK;AACvC,UAAMC,IAASC,EAAA;AAEf,WACE,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAAH;AAAA,QACA,aAAU;AAAA,QACJ,CAACI,CAAS,GAAG;AAAA,QACnB,MAAK;AAAA,QACL,WAAWH,EAAO;AAAA,QAClB,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,OAAM;AAAA,QAEN,UAAA,gBAAAE;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,GAAE;AAAA,YACF,GAAE;AAAA,YACF,OAAM;AAAA,YACN,QAAO;AAAA,YACP,IAAG;AAAA,YACH,QAAO;AAAA,UAAA;AAAA,QAAA;AAAA,MACT;AAAA,IAAA;AAAA,EAGN;AACF,GAEMG,IAAoBR,EAAM;AAAA,EAC9B,SAA2BC,GAAQC,GAAK;AACtC,UAAMC,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QACA,cAAY;AAAA,QACZ,QAAQwB;AAAA,QAGR,OAAOO,MAAU,SAAY,SAAY,OAAOA,CAAK;AAAA,QACrD,aAAU;AAAA,QACJ,CAAC3B,CAAS,GAAG;AAAA,QACnB,WAAWiC;AAAA,UACTJ,EAAW;AAAA,UACXA,EAAWE,CAAU;AAAA,UACrBF,EAAWN,CAAI;AAAA,UACfC;AAAA,QAAA;AAAA,QAID,GAAII;AAAA,QAEL,UAAA,gBAAAM;AAAA,UAACF,EAAgB;AAAA,UAAhB;AAAA,YACC,aAAU;AAAA,YACJ,CAAChC,CAAS,GAAG;AAAA,YACnB,WAAWiC;AAAA,cACTH,EAAY;AAAA,cACZA,EAAYC,CAAU;AAAA,cACtBD,EAAYP,CAAI;AAAA,YAAA;AAAA,YAGjB,UAAA;AAAA,cAAAE,KAAiB,CAACG,EAAM,YAAY,gBAAA7B,EAACN,GAAA,CAAA,CAAiB;AAAA,cACtDgC,KAAiB,CAACG,EAAM,8BAAa3B,GAAA,CAAA,CAAmB;AAAA,cACxDwB,KAAiBG,EAAM,YAAY,gBAAA7B,EAACG,GAAA,CAAA,CAAkB;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACzD;AAAA,IAAA;AAAA,EAGN;AACF;"}
|
|
1
|
+
{"version":3,"file":"switch.js","sources":["../../../src/components/switch/switch.tsx"],"sourcesContent":["import * as React from \"react\"\nimport { Switch as SwitchPrimitive } from \"@base-ui/react/switch\"\nimport { mergeClasses, shorthands } from \"@epilot/zenith-runtime/v1\"\n\nimport { useOptionalFieldContext } from \"../field/field\"\nimport { HiddenInputBox } from \"../../lib/hidden-input-box\"\nimport { SLOT_ATTR } from \"../../renderer/contract\"\nimport { makeZenithStyles } from \"../../styles/make-styles\"\nimport { boxModel, nativeControl } from \"../../styles/host-reset\"\nimport * as tokens from \"../../tokens\"\n\nconst ThumbIconChecked = React.forwardRef<SVGSVGElement>(\n function ThumbIconChecked(_props, ref) {\n const styles = useThumbIconStyles()\n\n return (\n <svg\n ref={ref}\n data-slot=\"switch-thumb-icon-checked\"\n {...{ [SLOT_ATTR]: \"switch-thumb-icon-checked\" }}\n role=\"presentation\"\n className={styles.checked}\n viewBox=\"0 0 1 6\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <rect width=\"1\" height=\"6\" fill=\"currentColor\" />\n </svg>\n )\n }\n)\n\nconst ThumbIconUnchecked = React.forwardRef<SVGSVGElement>(\n function ThumbIconUnchecked(_props, ref) {\n const styles = useThumbIconStyles()\n\n return (\n <svg\n ref={ref}\n data-slot=\"switch-thumb-icon-unchecked\"\n {...{ [SLOT_ATTR]: \"switch-thumb-icon-unchecked\" }}\n role=\"presentation\"\n className={styles.unchecked}\n viewBox=\"0 0 4 6\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <rect\n x=\"0.5\"\n y=\"0.5\"\n width=\"3\"\n height=\"5\"\n rx=\"1.5\"\n stroke=\"currentColor\"\n />\n </svg>\n )\n }\n)\n\nconst ThumbIconDisabled = React.forwardRef<SVGSVGElement>(\n function ThumbIconDisabled(_props, ref) {\n const styles = useThumbIconStyles()\n\n return (\n <svg\n ref={ref}\n data-slot=\"switch-thumb-icon-disabled\"\n {...{ [SLOT_ATTR]: \"switch-thumb-icon-disabled\" }}\n className={styles.disabled}\n viewBox=\"0 0 4 5\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M0 5V1.875H0.666667V1.25C0.666667 0.90625 0.797223 0.611979 1.05833 0.367188C1.31944 0.122396 1.63333 0 2 0C2.36667 0 2.68056 0.122396 2.94167 0.367188C3.20278 0.611979 3.33333 0.90625 3.33333 1.25V1.875H4V5H0ZM1.33333 1.875H2.66667V1.25C2.66667 1.07292 2.60278 0.924479 2.475 0.804687C2.34722 0.684896 2.18889 0.625 2 0.625C1.81111 0.625 1.65278 0.684896 1.525 0.804687C1.39722 0.924479 1.33333 1.07292 1.33333 1.25V1.875Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n }\n)\n\nconst useThumbIconStyles = makeZenithStyles({\n checked: {\n display: \"none\",\n position: \"absolute\",\n pointerEvents: \"none\",\n ...shorthands.inset(0),\n color: \"currentColor\",\n ...shorthands.margin(\"auto\"),\n },\n unchecked: {\n display: \"none\",\n position: \"absolute\",\n pointerEvents: \"none\",\n ...shorthands.inset(0),\n color: \"currentColor\",\n ...shorthands.margin(\"auto\"),\n },\n disabled: {\n display: \"inline-block\",\n position: \"absolute\",\n pointerEvents: \"none\",\n ...shorthands.inset(0),\n color: \"currentColor\",\n ...shorthands.margin(\"auto\"),\n },\n})\n\nconst useRootStyles = makeZenithStyles({\n root: {\n ...nativeControl,\n boxSizing: \"border-box\",\n display: \"inline-flex\",\n alignItems: \"center\",\n flexShrink: 0,\n cursor: \"pointer\",\n borderRadius: \"9999px\",\n ...shorthands.border(\"1px\", \"solid\", \"transparent\"),\n boxShadow: \"0 1px 2px 0 #0000000d\",\n transitionProperty: \"all\",\n transitionTimingFunction: \"cubic-bezier(0.4, 0, 0.2, 1)\",\n transitionDuration: \"150ms\",\n \"@media (prefers-reduced-motion: reduce)\": {\n transitionDuration: \"0.01ms\",\n },\n \":focus-visible\": {\n outlineWidth: \"2px\",\n outlineStyle: \"solid\",\n outlineOffset: \"2px\",\n outlineColor: tokens.focusRing,\n },\n \":disabled, &[data-disabled]\": {\n pointerEvents: \"none\",\n opacity: 0.5,\n },\n },\n default: {\n color: tokens.grayA8,\n \"&[data-checked]\": { backgroundColor: tokens.accentSolid },\n \"&[data-unchecked]\": { backgroundColor: tokens.grayA3 },\n },\n destructive: {\n color: tokens.errorA8,\n \"&[data-checked]\": { backgroundColor: tokens.errorSolid },\n \"&[data-unchecked]\": { backgroundColor: tokens.errorA3 },\n },\n sm: {\n ...boxModel,\n width: \"1.625rem\",\n height: \"1rem\",\n \"& svg\": { width: \"0.25rem\", height: \"0.375rem\" },\n },\n base: {\n ...boxModel,\n width: \"2.125rem\",\n height: \"1.25rem\",\n \"& svg\": { width: \"0.4375rem\", height: \"0.5rem\" },\n },\n lg: {\n ...boxModel,\n width: \"2.625rem\",\n height: \"1.5rem\",\n \"& svg\": { width: \"0.5rem\", height: \"0.625rem\" },\n },\n})\n\nconst useThumbStyles = makeZenithStyles({\n thumb: {\n ...boxModel,\n position: \"relative\",\n display: \"block\",\n pointerEvents: \"none\",\n borderRadius: \"9999px\",\n boxShadow: \"0 1px 2px 0 #0000000d\",\n transitionProperty: \"transform\",\n transitionTimingFunction: \"cubic-bezier(0.4, 0, 0.2, 1)\",\n transitionDuration: \"150ms\",\n \"@media (prefers-reduced-motion: reduce)\": {\n transitionDuration: \"0.01ms\",\n },\n \"&[data-checked]\": {\n transform: \"translateX(calc(100% - 1px))\",\n },\n \"&[data-unchecked]\": {\n transform: \"translateX(1px)\",\n },\n \"&[data-checked] [data-zenith-slot='switch-thumb-icon-checked']\": {\n display: \"inline-block\",\n },\n \"&[data-unchecked] [data-zenith-slot='switch-thumb-icon-unchecked']\": {\n display: \"inline-block\",\n },\n },\n default: {\n backgroundColor: tokens.grayContrast,\n color: tokens.grayA8,\n \"&[data-checked]\": { color: tokens.accentA11 },\n \"&[data-unchecked]\": { color: tokens.grayA8 },\n },\n destructive: {\n backgroundColor: tokens.errorContrast,\n color: tokens.errorA8,\n \"&[data-checked]\": { color: tokens.errorA11 },\n \"&[data-unchecked]\": { color: tokens.errorA8 },\n },\n sm: {\n ...boxModel,\n width: \"0.75rem\",\n height: \"0.75rem\",\n \"& svg[data-zenith-slot='switch-thumb-icon-disabled']\": {\n width: \"0.25rem\",\n },\n },\n base: {\n ...boxModel,\n width: \"1rem\",\n height: \"1rem\",\n \"& svg[data-zenith-slot='switch-thumb-icon-disabled']\": {\n width: \"0.375rem\",\n },\n },\n lg: {\n ...boxModel,\n width: \"1.25rem\",\n height: \"1.25rem\",\n \"& svg[data-zenith-slot='switch-thumb-icon-disabled']\": {\n width: \"0.4375rem\",\n },\n },\n})\n\n/**\n * `primary` is a deprecated alias of `default`, carried because v1 has it and real consumers still\n * pass it — entity-sidepanel's SettingsControls does. v1's own comment marks it deprecated and its\n * styles are byte-identical to `default`, so it is mapped rather than duplicated.\n *\n * @remarks `primary` is deprecated; use `default`.\n */\nexport type SwitchVariant = \"default\" | \"destructive\" | \"primary\"\nexport type SwitchSize = \"sm\" | \"base\" | \"lg\"\n\n/**\n * What `onCheckedChange` 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 */\ntype SwitchCheckedChangeDetails = {\n /** Why the switch changed. Base UI reports every switch change as `none`. */\n reason: \"none\"\n /** The native event behind the change. */\n event: Event\n /** Keeps the switch in its current state. */\n cancel: () => void\n /** Lets the event propagate where the switch 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\n/**\n * The switch props Base UI adds to a `<button>`'s, declared in Zenith with Base UI's types. The\n * root renders a native `<button>`, so the DOM attributes, handlers, `ref`, `key`, `className`,\n * `style` and `value` stay the button's, as they were on Radix; `render` and `nativeButton` are\n * fixed by the wrapper.\n */\ntype SwitchRootProps = {\n /**\n * Whether the switch is currently active.\n *\n * To render an uncontrolled switch, use the `defaultChecked` prop instead.\n */\n checked?: boolean | undefined\n /** Whether the component should ignore user interaction. */\n disabled?: boolean | undefined\n /** A ref to access the hidden `<input>` element. */\n inputRef?: React.Ref<HTMLInputElement> | undefined\n /** Identifies the field when a form is submitted. */\n name?: string | undefined\n /**\n * Identifies the form that owns the hidden input.\n * Useful when the switch is rendered outside the form.\n */\n form?: string | undefined\n /** Event handler called when the switch is activated or deactivated. */\n onCheckedChange?:\n | ((checked: boolean, eventDetails: SwitchCheckedChangeDetails) => void)\n | undefined\n /** Whether the user should be unable to activate or deactivate the switch. */\n readOnly?: boolean | undefined\n /** Whether the user must activate the switch before submitting a form. */\n required?: boolean | undefined\n /**\n * The value submitted with the form when the switch is off.\n * By default, unchecked switches do not submit any value, matching native checkbox behavior.\n */\n uncheckedValue?: string | undefined\n}\n\nexport type SwitchProps = Omit<\n React.ComponentPropsWithRef<\"button\">,\n keyof SwitchRootProps\n> &\n SwitchRootProps & {\n /**\n * `default` or `destructive`. `primary` is a **deprecated alias of `default`** with byte-\n * identical styles, kept because v1 had it and consumers still pass it. Choosing it changes\n * nothing; use `default`.\n */\n variant?: SwitchVariant\n /** @default \"base\" */\n size?: SwitchSize\n showThumbIcon?: boolean\n /**\n * @deprecated Has no effect. The thumb is the switch's only child, so on Radix this rendered\n * the thumb as the switch rather than an element of yours. Remove it.\n */\n asChild?: boolean\n }\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 ROOT_ELEMENT = <button />\n\nexport const Switch = React.forwardRef<HTMLButtonElement, SwitchProps>(\n function Switch(\n {\n variant = \"default\",\n size = \"base\",\n className,\n showThumbIcon = false,\n asChild: _asChild,\n value,\n ...props\n },\n ref\n ) {\n const rootStyles = useRootStyles()\n const inField = useOptionalFieldContext() !== null\n const thumbStyles = useThumbStyles()\n // See SwitchVariant: `primary` is v1's deprecated alias for `default`, same styles.\n const variantKey = variant === \"primary\" ? \"default\" : variant\n\n const root = (\n <SwitchPrimitive.Root\n ref={ref}\n nativeButton\n render={ROOT_ELEMENT}\n // Radix took the button's value type; Base UI submits a string, so it is converted here\n // the way the button's value attribute stringified it.\n value={value === undefined ? undefined : String(value)}\n data-slot=\"switch\"\n {...{ [SLOT_ATTR]: \"switch\" }}\n className={mergeClasses(\n rootStyles.root,\n rootStyles[variantKey],\n rootStyles[size],\n className\n )}\n // Base UI types the root's handlers for its default <span>; the element is the button\n // above, so the caller's button-typed handlers receive exactly the events they declare.\n {...(props as SwitchPrimitive.Root.Props)}\n >\n <SwitchPrimitive.Thumb\n data-slot=\"switch-thumb\"\n {...{ [SLOT_ATTR]: \"switch-thumb\" }}\n className={mergeClasses(\n thumbStyles.thumb,\n thumbStyles[variantKey],\n thumbStyles[size]\n )}\n >\n {showThumbIcon && !props.disabled && <ThumbIconChecked />}\n {showThumbIcon && !props.disabled && <ThumbIconUnchecked />}\n {showThumbIcon && props.disabled && <ThumbIconDisabled />}\n </SwitchPrimitive.Thumb>\n </SwitchPrimitive.Root>\n )\n\n // A named switch's hidden input sits beside the button; the box keeps it in (#132). A Field is\n // positioned already, so inside one the switch stays the layout item itself.\n return props.name === undefined || inField ? (\n root\n ) : (\n <HiddenInputBox slot=\"switch-box\" layout=\"inline-flex\">\n {root}\n </HiddenInputBox>\n )\n }\n)\n"],"names":["ThumbIconChecked","React","_props","ref","styles","useThumbIconStyles","jsx","SLOT_ATTR","ThumbIconUnchecked","ThumbIconDisabled","makeZenithStyles","shorthands","useRootStyles","nativeControl","tokens.focusRing","tokens.grayA8","tokens.accentSolid","tokens.grayA3","tokens.errorA8","tokens.errorSolid","tokens.errorA3","boxModel","useThumbStyles","tokens.grayContrast","tokens.accentA11","tokens.errorContrast","tokens.errorA11","ROOT_ELEMENT","Switch","variant","size","className","showThumbIcon","_asChild","value","props","rootStyles","inField","useOptionalFieldContext","thumbStyles","variantKey","root","SwitchPrimitive","mergeClasses","jsxs","HiddenInputBox"],"mappings":";;;;;;;;;AAWA,MAAMA,IAAmBC,EAAM;AAAA,EAC7B,SAA0BC,GAAQC,GAAK;AACrC,UAAMC,IAASC,EAAA;AAEf,WACE,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAAH;AAAA,QACA,aAAU;AAAA,QACJ,CAACI,CAAS,GAAG;AAAA,QACnB,MAAK;AAAA,QACL,WAAWH,EAAO;AAAA,QAClB,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,OAAM;AAAA,QAEN,4BAAC,QAAA,EAAK,OAAM,KAAI,QAAO,KAAI,MAAK,eAAA,CAAe;AAAA,MAAA;AAAA,IAAA;AAAA,EAGrD;AACF,GAEMI,IAAqBP,EAAM;AAAA,EAC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BAAA7B,EAACG,GAAA,CAAA,CAAkB;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACzD;AAAA,IAAA;AAMJ,WAAO0B,EAAM,SAAS,UAAaE,IACjCI,IAEA,gBAAAnC,EAACuC,GAAA,EAAe,MAAK,cAAa,QAAO,eACtC,UAAAJ,EAAA,CACH;AAAA,EAEJ;AACF;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import * as s from "react";
|
|
3
|
+
import { mergeClasses as r, SLOT_ATTR as a } from "@epilot/zenith-runtime/v1";
|
|
4
|
+
import { makeZenithStyles as p } from "../styles/make-styles.js";
|
|
5
|
+
const f = p({
|
|
6
|
+
box: { position: "relative" },
|
|
7
|
+
"inline-flex": { display: "inline-flex", flexShrink: 0 },
|
|
8
|
+
"inline-block": { display: "inline-block", flexShrink: 0, lineHeight: 0 },
|
|
9
|
+
block: { display: "block", width: "100%" }
|
|
10
|
+
}), k = s.forwardRef(function({ slot: e, layout: n, children: o }, l) {
|
|
11
|
+
const i = f();
|
|
12
|
+
return /* @__PURE__ */ t(
|
|
13
|
+
"span",
|
|
14
|
+
{
|
|
15
|
+
ref: l,
|
|
16
|
+
"data-slot": e,
|
|
17
|
+
[a]: e,
|
|
18
|
+
className: r(i.box, i[n]),
|
|
19
|
+
children: o
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
export {
|
|
24
|
+
k as HiddenInputBox
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=hidden-input-box.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hidden-input-box.js","sources":["../../src/lib/hidden-input-box.tsx"],"sourcesContent":["import * as React from \"react\"\n\nimport { mergeClasses } from \"@epilot/zenith-runtime/v1\"\n\nimport { SLOT_ATTR } from \"../renderer/contract\"\nimport { makeZenithStyles } from \"../styles/make-styles\"\n\n/**\n * The positioned box a named control's hidden input needs (#132). With a `name`, Base UI renders\n * the control's form input beside the control, not inside it, with `position: absolute` and no\n * offsets, so the input's containing block is the nearest positioned ancestor. Under static\n * ancestors that is the page: in an app mounted in an `overflow: auto` box the inputs escape it and\n * stretch the document, and the viewport grows a scrollbar. Base UI offers no way to render the\n * input inside the control, so this box holds both.\n *\n * Its display follows the control's, so it sizes and aligns like it: an inline-flex or inline-block\n * control gets the same (the box's baseline and size are the control's), a full-width control a\n * full-width block. The inline-block box sets `line-height: 0` so its own line adds nothing in a\n * flex row or grid, where it becomes a block; a control that holds no text (Checkbox) is the only\n * one to use it. The caller's classes, ref and props stay on the control, but the box is the flex\n * or grid item, so placement the control asks for (an auto margin, `align-self`/`justify-self`,\n * grid or flex placement) no longer reaches the parent: it goes on an element around the control.\n * A control renders the box only when it has a name and is outside a Field: without a name Base UI\n * pins the input to the viewport (`position: fixed`), where it adds no overflow, and a Field is\n * positioned already.\n */\nconst useStyles = makeZenithStyles({\n box: { position: \"relative\" },\n \"inline-flex\": { display: \"inline-flex\", flexShrink: 0 },\n \"inline-block\": { display: \"inline-block\", flexShrink: 0, lineHeight: 0 },\n block: { display: \"block\", width: \"100%\" },\n})\n\nexport type HiddenInputBoxProps = {\n /** The box's slot name, `<control>-box`. */\n slot: string\n layout: \"inline-flex\" | \"inline-block\" | \"block\"\n children: React.ReactNode\n}\n\nexport const HiddenInputBox = React.forwardRef<\n HTMLSpanElement,\n HiddenInputBoxProps\n>(function HiddenInputBox({ slot, layout, children }, ref) {\n const styles = useStyles()\n\n return (\n <span\n ref={ref}\n data-slot={slot}\n {...{ [SLOT_ATTR]: slot }}\n className={mergeClasses(styles.box, styles[layout])}\n >\n {children}\n </span>\n )\n})\n"],"names":["useStyles","makeZenithStyles","HiddenInputBox","React","slot","layout","children","ref","styles","jsx","SLOT_ATTR","mergeClasses"],"mappings":";;;;AA0BA,MAAMA,IAAYC,EAAiB;AAAA,EACjC,KAAK,EAAE,UAAU,WAAA;AAAA,EACjB,eAAe,EAAE,SAAS,eAAe,YAAY,EAAA;AAAA,EACrD,gBAAgB,EAAE,SAAS,gBAAgB,YAAY,GAAG,YAAY,EAAA;AAAA,EACtE,OAAO,EAAE,SAAS,SAAS,OAAO,OAAA;AACpC,CAAC,GASYC,IAAiBC,EAAM,WAGlC,SAAwB,EAAE,MAAAC,GAAM,QAAAC,GAAQ,UAAAC,EAAA,GAAYC,GAAK;AACzD,QAAMC,IAASR,EAAA;AAEf,SACE,gBAAAS;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAAF;AAAA,MACA,aAAWH;AAAA,MACL,CAACM,CAAS,GAAGN;AAAA,MACnB,WAAWO,EAAaH,EAAO,KAAKA,EAAOH,CAAM,CAAC;AAAA,MAEjD,UAAAC;AAAA,IAAA;AAAA,EAAA;AAGP,CAAC;"}
|
package/dist/tokens.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$comment": "GENERATED. Design token values for consumers that do not render this package's React components. Compile these into your own CSS under your own names at your own build time; do not reference this package's runtime custom properties, whose names are content-hashed and change with their values. `themes.light`/`themes.dark` are mode-resolved; `densities.compact`/`densities.normal`/`densities.comfortable` resolve the component layer's geometry tokens (WP9A-ACCEPTANCE-WP9B1) and carry no mode of their own — do not read a value out of `themes` for a key that only exists under `densities`, or the reverse. This file is copied verbatim to this package's public `tokens.json` export (`package.json`'s `build` script, `cp src/generated/values.generated.json dist/tokens.json`).",
|
|
3
3
|
"package": "@epilot/zenith-react",
|
|
4
|
-
"version": "0.2.0-next.
|
|
4
|
+
"version": "0.2.0-next.7",
|
|
5
5
|
"themes": {
|
|
6
6
|
"light": {
|
|
7
7
|
"accent-1": "#fcfdfe",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epilot/zenith-react",
|
|
3
|
-
"version": "0.2.0-next.
|
|
3
|
+
"version": "0.2.0-next.7",
|
|
4
4
|
"description": "Zenith React components, styled with Griffel and designed for isolated micro-frontend delivery",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"verify:consumer": "bun ../../scripts/verify-packed-consumer.ts"
|
|
94
94
|
},
|
|
95
95
|
"dependencies": {
|
|
96
|
-
"@epilot/zenith-runtime": "0.2.0-next.
|
|
96
|
+
"@epilot/zenith-runtime": "0.2.0-next.5"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
99
99
|
"react": ">=18",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"@dnd-kit/core": "6.3.1",
|
|
105
105
|
"@dnd-kit/sortable": "10.0.0",
|
|
106
106
|
"@dnd-kit/utilities": "3.2.2",
|
|
107
|
-
"@epilot/zenith-tokens": "0.2.0-next.
|
|
107
|
+
"@epilot/zenith-tokens": "0.2.0-next.7",
|
|
108
108
|
"@tanstack/react-table": "8.21.3",
|
|
109
109
|
"@tanstack/react-virtual": "3.11.2",
|
|
110
110
|
"@testing-library/react": "^16.3.2",
|