@bitrise/bitkit-v2 0.3.518 → 0.3.520
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/BitkitControlButton/BitkitControlButton.js +2 -0
- package/dist/components/BitkitControlButton/BitkitControlButton.js.map +1 -1
- package/dist/components/BitkitRadio/BitkitRadio.js +1 -0
- package/dist/components/BitkitRadio/BitkitRadio.js.map +1 -1
- package/dist/components/BitkitSwitch/BitkitSwitch.js +3 -0
- package/dist/components/BitkitSwitch/BitkitSwitch.js.map +1 -1
- package/dist/components/BitkitToggleButton/BitkitToggleButton.js +1 -0
- package/dist/components/BitkitToggleButton/BitkitToggleButton.js.map +1 -1
- package/dist/theme/recipes/Button.recipe.js +15 -8
- package/dist/theme/recipes/Button.recipe.js.map +1 -1
- package/dist/theme/recipes/Skeleton.recipe.d.ts +3 -0
- package/dist/theme/recipes/Skeleton.recipe.js +4 -5
- package/dist/theme/recipes/Skeleton.recipe.js.map +1 -1
- package/package.json +1 -1
|
@@ -47,6 +47,7 @@ var BitkitControlButton = forwardRef((props, ref) => {
|
|
|
47
47
|
rel: effectiveRel,
|
|
48
48
|
target: effectiveTarget,
|
|
49
49
|
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
50
|
+
display: "flex",
|
|
50
51
|
loading: isSkeleton,
|
|
51
52
|
children: /* @__PURE__ */ jsx(Icon, { size: iconSize })
|
|
52
53
|
})
|
|
@@ -69,6 +70,7 @@ var BitkitControlButton = forwardRef((props, ref) => {
|
|
|
69
70
|
size
|
|
70
71
|
}),
|
|
71
72
|
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
73
|
+
display: "flex",
|
|
72
74
|
loading: isSkeleton,
|
|
73
75
|
children: /* @__PURE__ */ jsx(Icon, { size: iconSize })
|
|
74
76
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitkitControlButton.js","names":[],"sources":["../../../lib/components/BitkitControlButton/BitkitControlButton.tsx"],"sourcesContent":["import { Skeleton } from '@chakra-ui/react/skeleton';\nimport { chakra, type HTMLChakraProps, useRecipe } from '@chakra-ui/react/styled-system';\nimport { forwardRef, type KeyboardEvent, type MouseEvent, type Ref } from 'react';\n\nimport { type BitkitIconComponent } from '../../icons';\nimport opensPopup from '../../utilities/opensPopup';\nimport BitkitLabelTooltip, { type BitkitLabelTooltipProps } from '../BitkitLabelTooltip/BitkitLabelTooltip';\n\ntype ControlButtonSize = 'xxs' | 'xs' | 'sm' | 'md' | 'lg';\n\ninterface BitkitControlButtonCommonProps {\n icon: BitkitIconComponent;\n isDanger?: boolean;\n label: string;\n size?: ControlButtonSize;\n state?: 'disabled' | 'skeleton';\n /**\n * Overrides for the label tooltip. It is off by default when this control opens a popup — a menu,\n * select or popover trigger — where the panel is the affordance and a tooltip would hover over it.\n * Pass `{ disabled: false }` to bring it back. The accessible name comes from `label` either way.\n */\n tooltipProps?: Partial<Omit<BitkitLabelTooltipProps, 'children' | 'text'>>;\n}\n\n// Exported so dependent declarations can name it: `BitkitTabs.AddButton`'s props derive from\n// `Extract<BitkitControlButtonProps, { href?: undefined }>` (this type), and the .d.ts emit\n// fails with TS4023 (\"cannot be named\") if it isn't exported.\nexport interface BitkitControlButtonAsButtonProps\n extends BitkitControlButtonCommonProps, Omit<HTMLChakraProps<'button'>, 'children' | 'disabled' | 'size'> {\n href?: undefined;\n isExternal?: undefined;\n}\n\nexport interface BitkitControlButtonAsAnchorProps\n extends BitkitControlButtonCommonProps, Omit<HTMLChakraProps<'a'>, 'children' | 'size'> {\n href: string;\n isExternal?: boolean;\n}\n\nexport type BitkitControlButtonProps = BitkitControlButtonAsButtonProps | BitkitControlButtonAsAnchorProps;\n\nconst BitkitControlButton = forwardRef<HTMLButtonElement | HTMLAnchorElement, BitkitControlButtonProps>(\n (props, ref) => {\n const Icon = props.icon;\n const size = props.size ?? 'sm';\n const recipe = useRecipe({ key: 'controlButton' });\n const iconSize = size === 'xxs' || size === 'xs' ? '16' : '24';\n const isDisabled = props.state === 'disabled';\n const isSkeleton = props.state === 'skeleton';\n const isPopupTrigger = opensPopup(props);\n const inertOnClick = isDisabled || isSkeleton;\n\n // --- Anchor mode (href) ---\n if (props.href !== undefined) {\n const {\n href,\n icon: _icon,\n isDanger,\n isExternal,\n label,\n onClick,\n onKeyDown,\n rel,\n size: _size,\n state: _state,\n target,\n tooltipProps,\n ...anchorRest\n } = props;\n const effectiveTarget = isExternal ? '_blank' : target;\n const effectiveRel = isExternal ? (rel ? `${rel} noreferrer noopener` : 'noreferrer noopener') : rel;\n const handleClick = inertOnClick\n ? (e: MouseEvent<HTMLAnchorElement>) => {\n e.preventDefault();\n e.stopPropagation();\n }\n : onClick;\n const handleKeyDown = inertOnClick\n ? (e: KeyboardEvent<HTMLAnchorElement>) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n e.stopPropagation();\n }\n }\n : onKeyDown;\n return (\n <BitkitLabelTooltip text={label} disabled={isPopupTrigger} {...tooltipProps}>\n <chakra.a\n ref={ref as Ref<HTMLAnchorElement>}\n aria-disabled={inertOnClick || undefined}\n aria-label={label}\n {...anchorRest}\n css={recipe({ isDanger, size })}\n href={inertOnClick ? undefined : href}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n rel={effectiveRel}\n target={effectiveTarget}\n >\n <Skeleton loading={isSkeleton}>\n <Icon size={iconSize} />\n </Skeleton>\n </chakra.a>\n </BitkitLabelTooltip>\n );\n }\n\n // --- Button mode (default) ---\n const { icon: _icon, isDanger, label, size: _size, state, tooltipProps, ...buttonRest } = props;\n return (\n <BitkitLabelTooltip text={label} disabled={isPopupTrigger} {...tooltipProps}>\n <chakra.button\n ref={ref as Ref<HTMLButtonElement>}\n aria-label={label}\n disabled={state === 'disabled' || state === 'skeleton'}\n // A control button is an action, not a form submit — without this it would submit any\n // form it happens to sit inside. Before the spread, so a consumer can still opt into\n // `type=\"submit\"`.\n type=\"button\"\n {...buttonRest}\n css={recipe({ isDanger, size })}\n >\n <Skeleton loading={isSkeleton}>\n <Icon size={iconSize} />\n </Skeleton>\n </chakra.button>\n </BitkitLabelTooltip>\n );\n },\n);\n\nBitkitControlButton.displayName = 'BitkitControlButton';\n\nexport default BitkitControlButton;\n"],"mappings":";;;;;;;AAyCA,IAAM,sBAAsB,YACzB,OAAO,QAAQ;CACd,MAAM,OAAO,MAAM;CACnB,MAAM,OAAO,MAAM,QAAQ;CAC3B,MAAM,SAAS,UAAU,EAAE,KAAK,gBAAgB,CAAC;CACjD,MAAM,WAAW,SAAS,SAAS,SAAS,OAAO,OAAO;CAC1D,MAAM,aAAa,MAAM,UAAU;CACnC,MAAM,aAAa,MAAM,UAAU;CACnC,MAAM,iBAAiB,WAAW,KAAK;CACvC,MAAM,eAAe,cAAc;CAGnC,IAAI,MAAM,SAAS,KAAA,GAAW;EAC5B,MAAM,EACJ,MACA,MAAM,OACN,UACA,YACA,OACA,SACA,WACA,KACA,MAAM,OACN,OAAO,QACP,QACA,cACA,GAAG,eACD;EACJ,MAAM,kBAAkB,aAAa,WAAW;EAChD,MAAM,eAAe,aAAc,MAAM,GAAG,IAAI,wBAAwB,wBAAyB;EACjG,MAAM,cAAc,gBACf,MAAqC;GACpC,EAAE,eAAe;GACjB,EAAE,gBAAgB;EACpB,IACA;EACJ,MAAM,gBAAgB,gBACjB,MAAwC;GACvC,IAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK;IACtC,EAAE,eAAe;IACjB,EAAE,gBAAgB;GACpB;EACF,IACA;EACJ,OACE,oBAAC,oBAAD;GAAoB,MAAM;GAAO,UAAU;GAAgB,GAAI;GAC7D,UAAA,oBAAC,OAAO,GAAR;IACO;IACL,iBAAe,gBAAgB,KAAA;IAC/B,cAAY;IACZ,GAAI;IACJ,KAAK,OAAO;KAAE;KAAU;IAAK,CAAC;IAC9B,MAAM,eAAe,KAAA,IAAY;IACjC,SAAS;IACT,WAAW;IACX,KAAK;IACL,QAAQ;IAER,UAAA,oBAAC,UAAD;KAAU,SAAS;
|
|
1
|
+
{"version":3,"file":"BitkitControlButton.js","names":[],"sources":["../../../lib/components/BitkitControlButton/BitkitControlButton.tsx"],"sourcesContent":["import { Skeleton } from '@chakra-ui/react/skeleton';\nimport { chakra, type HTMLChakraProps, useRecipe } from '@chakra-ui/react/styled-system';\nimport { forwardRef, type KeyboardEvent, type MouseEvent, type Ref } from 'react';\n\nimport { type BitkitIconComponent } from '../../icons';\nimport opensPopup from '../../utilities/opensPopup';\nimport BitkitLabelTooltip, { type BitkitLabelTooltipProps } from '../BitkitLabelTooltip/BitkitLabelTooltip';\n\ntype ControlButtonSize = 'xxs' | 'xs' | 'sm' | 'md' | 'lg';\n\ninterface BitkitControlButtonCommonProps {\n icon: BitkitIconComponent;\n isDanger?: boolean;\n label: string;\n size?: ControlButtonSize;\n state?: 'disabled' | 'skeleton';\n /**\n * Overrides for the label tooltip. It is off by default when this control opens a popup — a menu,\n * select or popover trigger — where the panel is the affordance and a tooltip would hover over it.\n * Pass `{ disabled: false }` to bring it back. The accessible name comes from `label` either way.\n */\n tooltipProps?: Partial<Omit<BitkitLabelTooltipProps, 'children' | 'text'>>;\n}\n\n// Exported so dependent declarations can name it: `BitkitTabs.AddButton`'s props derive from\n// `Extract<BitkitControlButtonProps, { href?: undefined }>` (this type), and the .d.ts emit\n// fails with TS4023 (\"cannot be named\") if it isn't exported.\nexport interface BitkitControlButtonAsButtonProps\n extends BitkitControlButtonCommonProps, Omit<HTMLChakraProps<'button'>, 'children' | 'disabled' | 'size'> {\n href?: undefined;\n isExternal?: undefined;\n}\n\nexport interface BitkitControlButtonAsAnchorProps\n extends BitkitControlButtonCommonProps, Omit<HTMLChakraProps<'a'>, 'children' | 'size'> {\n href: string;\n isExternal?: boolean;\n}\n\nexport type BitkitControlButtonProps = BitkitControlButtonAsButtonProps | BitkitControlButtonAsAnchorProps;\n\nconst BitkitControlButton = forwardRef<HTMLButtonElement | HTMLAnchorElement, BitkitControlButtonProps>(\n (props, ref) => {\n const Icon = props.icon;\n const size = props.size ?? 'sm';\n const recipe = useRecipe({ key: 'controlButton' });\n const iconSize = size === 'xxs' || size === 'xs' ? '16' : '24';\n const isDisabled = props.state === 'disabled';\n const isSkeleton = props.state === 'skeleton';\n const isPopupTrigger = opensPopup(props);\n const inertOnClick = isDisabled || isSkeleton;\n\n // --- Anchor mode (href) ---\n if (props.href !== undefined) {\n const {\n href,\n icon: _icon,\n isDanger,\n isExternal,\n label,\n onClick,\n onKeyDown,\n rel,\n size: _size,\n state: _state,\n target,\n tooltipProps,\n ...anchorRest\n } = props;\n const effectiveTarget = isExternal ? '_blank' : target;\n const effectiveRel = isExternal ? (rel ? `${rel} noreferrer noopener` : 'noreferrer noopener') : rel;\n const handleClick = inertOnClick\n ? (e: MouseEvent<HTMLAnchorElement>) => {\n e.preventDefault();\n e.stopPropagation();\n }\n : onClick;\n const handleKeyDown = inertOnClick\n ? (e: KeyboardEvent<HTMLAnchorElement>) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n e.stopPropagation();\n }\n }\n : onKeyDown;\n return (\n <BitkitLabelTooltip text={label} disabled={isPopupTrigger} {...tooltipProps}>\n <chakra.a\n ref={ref as Ref<HTMLAnchorElement>}\n aria-disabled={inertOnClick || undefined}\n aria-label={label}\n {...anchorRest}\n css={recipe({ isDanger, size })}\n href={inertOnClick ? undefined : href}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n rel={effectiveRel}\n target={effectiveTarget}\n >\n <Skeleton display=\"flex\" loading={isSkeleton}>\n <Icon size={iconSize} />\n </Skeleton>\n </chakra.a>\n </BitkitLabelTooltip>\n );\n }\n\n // --- Button mode (default) ---\n const { icon: _icon, isDanger, label, size: _size, state, tooltipProps, ...buttonRest } = props;\n return (\n <BitkitLabelTooltip text={label} disabled={isPopupTrigger} {...tooltipProps}>\n <chakra.button\n ref={ref as Ref<HTMLButtonElement>}\n aria-label={label}\n disabled={state === 'disabled' || state === 'skeleton'}\n // A control button is an action, not a form submit — without this it would submit any\n // form it happens to sit inside. Before the spread, so a consumer can still opt into\n // `type=\"submit\"`.\n type=\"button\"\n {...buttonRest}\n css={recipe({ isDanger, size })}\n >\n <Skeleton display=\"flex\" loading={isSkeleton}>\n <Icon size={iconSize} />\n </Skeleton>\n </chakra.button>\n </BitkitLabelTooltip>\n );\n },\n);\n\nBitkitControlButton.displayName = 'BitkitControlButton';\n\nexport default BitkitControlButton;\n"],"mappings":";;;;;;;AAyCA,IAAM,sBAAsB,YACzB,OAAO,QAAQ;CACd,MAAM,OAAO,MAAM;CACnB,MAAM,OAAO,MAAM,QAAQ;CAC3B,MAAM,SAAS,UAAU,EAAE,KAAK,gBAAgB,CAAC;CACjD,MAAM,WAAW,SAAS,SAAS,SAAS,OAAO,OAAO;CAC1D,MAAM,aAAa,MAAM,UAAU;CACnC,MAAM,aAAa,MAAM,UAAU;CACnC,MAAM,iBAAiB,WAAW,KAAK;CACvC,MAAM,eAAe,cAAc;CAGnC,IAAI,MAAM,SAAS,KAAA,GAAW;EAC5B,MAAM,EACJ,MACA,MAAM,OACN,UACA,YACA,OACA,SACA,WACA,KACA,MAAM,OACN,OAAO,QACP,QACA,cACA,GAAG,eACD;EACJ,MAAM,kBAAkB,aAAa,WAAW;EAChD,MAAM,eAAe,aAAc,MAAM,GAAG,IAAI,wBAAwB,wBAAyB;EACjG,MAAM,cAAc,gBACf,MAAqC;GACpC,EAAE,eAAe;GACjB,EAAE,gBAAgB;EACpB,IACA;EACJ,MAAM,gBAAgB,gBACjB,MAAwC;GACvC,IAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK;IACtC,EAAE,eAAe;IACjB,EAAE,gBAAgB;GACpB;EACF,IACA;EACJ,OACE,oBAAC,oBAAD;GAAoB,MAAM;GAAO,UAAU;GAAgB,GAAI;GAC7D,UAAA,oBAAC,OAAO,GAAR;IACO;IACL,iBAAe,gBAAgB,KAAA;IAC/B,cAAY;IACZ,GAAI;IACJ,KAAK,OAAO;KAAE;KAAU;IAAK,CAAC;IAC9B,MAAM,eAAe,KAAA,IAAY;IACjC,SAAS;IACT,WAAW;IACX,KAAK;IACL,QAAQ;IAER,UAAA,oBAAC,UAAD;KAAU,SAAQ;KAAO,SAAS;KAChC,UAAA,oBAAC,MAAD,EAAM,MAAM,SAAW,CAAA;IACf,CAAA;GACF,CAAA;EACQ,CAAA;CAExB;CAGA,MAAM,EAAE,MAAM,OAAO,UAAU,OAAO,MAAM,OAAO,OAAO,cAAc,GAAG,eAAe;CAC1F,OACE,oBAAC,oBAAD;EAAoB,MAAM;EAAO,UAAU;EAAgB,GAAI;EAC7D,UAAA,oBAAC,OAAO,QAAR;GACO;GACL,cAAY;GACZ,UAAU,UAAU,cAAc,UAAU;GAI5C,MAAK;GACL,GAAI;GACJ,KAAK,OAAO;IAAE;IAAU;GAAK,CAAC;GAE9B,UAAA,oBAAC,UAAD;IAAU,SAAQ;IAAO,SAAS;IAChC,UAAA,oBAAC,MAAD,EAAM,MAAM,SAAW,CAAA;GACf,CAAA;EACG,CAAA;CACG,CAAA;AAExB,CACF;AAEA,oBAAoB,cAAc"}
|
|
@@ -27,6 +27,7 @@ var BitkitRadio = forwardRef((props, ref) => {
|
|
|
27
27
|
children: /* @__PURE__ */ jsx(RadioGroup.ItemIndicator, {})
|
|
28
28
|
}),
|
|
29
29
|
!!badge && /* @__PURE__ */ jsx(Skeleton, {
|
|
30
|
+
display: "flex",
|
|
30
31
|
loading: state === "skeleton",
|
|
31
32
|
children: /* @__PURE__ */ jsx(BitkitBadge, {
|
|
32
33
|
colorVariant: badge === "on" ? "green" : "neutral",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitkitRadio.js","names":[],"sources":["../../../lib/components/BitkitRadio/BitkitRadio.tsx"],"sourcesContent":["import { RadioGroup, useRadioGroupStyles } from '@chakra-ui/react/radio-group';\nimport { Skeleton } from '@chakra-ui/react/skeleton';\nimport { type DataAttr } from '@chakra-ui/react/styled-system';\nimport { Text } from '@chakra-ui/react/text';\nimport { forwardRef, type InputHTMLAttributes, type ReactElement, type ReactNode, type Ref } from 'react';\n\nimport { isEmptyNode } from '../../utilities/isEmptyNode';\nimport BitkitBadge from '../BitkitBadge/BitkitBadge';\n\n/**\n * Passthrough attributes for the radio `<input>`. The RadioGroup machine owns the behavioral / state\n * attributes (`checked`, `value`, `name`, `type`, `disabled`, `onChange`, …), so they're excluded —\n * setting them here would let the input drift out of sync with its `RadioGroup.Item`. Keep it to\n * things like `data-testid`.\n */\ntype RadioInputProps = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n 'checked' | 'defaultChecked' | 'defaultValue' | 'disabled' | 'name' | 'onChange' | 'type' | 'value'\n> &\n DataAttr;\n\ntype BitkitRadioBaseProps = {\n badge?: 'off' | 'on';\n inputProps?: RadioInputProps;\n state?: 'disabled' | 'skeleton';\n} & Omit<RadioGroup.ItemProps, 'disabled'>;\n\n/**\n * A radio has to end up with an accessible name, and it takes that name from its label. So either\n * pass a visible `labelText`, or — for a radio in a layout with no room for one, like a table row\n * selector — an `aria-label`, which is applied to the hidden input instead of being rendered.\n */\nexport type BitkitRadioProps<T extends NonNullable<ReactNode> = NonNullable<ReactNode>> = BitkitRadioBaseProps &\n (\n | {\n helperText?: ReactNode;\n /**\n * The visible label, which is where the radio gets its accessible name from. It has to be\n * non-empty — an empty string is a compile error. When the layout has no room for a visible\n * label, pass `aria-label` instead of an empty `labelText`.\n */\n labelText: T extends '' ? never : T;\n }\n | { 'aria-label': string; helperText?: never; labelText?: null }\n );\n\nconst BitkitRadio = forwardRef<HTMLInputElement, BitkitRadioProps>((props, ref) => {\n const { 'aria-label': ariaLabel, badge, helperText, inputProps, labelText, state, ...rest } = props;\n const styles = useRadioGroupStyles();\n const hasHelperText = !isEmptyNode(helperText);\n const hasLabel = !isEmptyNode(labelText) || hasHelperText;\n\n // Skeleton has to set disabled to be inert: the Skeleton wrapper's own pointer-events: none never\n // stopped a click, it only moved the target to the <label>, which activates the control. The cursor\n // style prop then keeps the arrow plain — style props land outside @layer recipes, where the\n // recipe's _disabled: { cursor: 'not-allowed' } sits.\n return (\n <RadioGroup.Item\n cursor={state === 'skeleton' ? 'default' : undefined}\n disabled={state === 'disabled' || state === 'skeleton'}\n {...rest}\n >\n <RadioGroup.ItemHiddenInput aria-label={ariaLabel} ref={ref} {...inputProps} />\n <Skeleton borderRadius=\"50%\" loading={state === 'skeleton'}>\n <RadioGroup.ItemIndicator />\n </Skeleton>\n {!!badge && (\n <Skeleton loading={state === 'skeleton'}>\n <BitkitBadge colorVariant={badge === 'on' ? 'green' : 'neutral'} css={styles.badge}>\n {badge}\n </BitkitBadge>\n </Skeleton>\n )}\n {hasLabel && (\n <Skeleton loading={state === 'skeleton'}>\n <RadioGroup.ItemText as=\"div\">\n {labelText}\n {hasHelperText && (\n <Text color={state === 'disabled' ? 'text/disabled' : 'text/helper'} textStyle=\"comp/input/helperText\">\n {helperText}\n </Text>\n )}\n </RadioGroup.ItemText>\n </Skeleton>\n )}\n </RadioGroup.Item>\n );\n});\n\nBitkitRadio.displayName = 'BitkitRadio';\n\n// The generic is what makes `labelText=\"\"` a compile error: `Exclude` cannot narrow `string` to\n// \"non-empty string\", but a conditional type on an inferred literal can. The cast carries the\n// generic through the call site, which `forwardRef`'s own signature would erase.\nexport default BitkitRadio as <T extends NonNullable<ReactNode>>(\n props: BitkitRadioProps<T> & { ref?: Ref<HTMLInputElement> },\n) => ReactElement;\n"],"mappings":";;;;;;;;AA8CA,IAAM,cAAc,YAAgD,OAAO,QAAQ;CACjF,MAAM,EAAE,cAAc,WAAW,OAAO,YAAY,YAAY,WAAW,OAAO,GAAG,SAAS;CAC9F,MAAM,SAAS,oBAAoB;CACnC,MAAM,gBAAgB,CAAC,YAAY,UAAU;CAC7C,MAAM,WAAW,CAAC,YAAY,SAAS,KAAK;CAM5C,OACE,qBAAC,WAAW,MAAZ;EACE,QAAQ,UAAU,aAAa,YAAY,KAAA;EAC3C,UAAU,UAAU,cAAc,UAAU;EAC5C,GAAI;EAHN,UAAA;GAKE,oBAAC,WAAW,iBAAZ;IAA4B,cAAY;IAAgB;IAAK,GAAI;GAAa,CAAA;GAC9E,oBAAC,UAAD;IAAU,cAAa;IAAM,SAAS,UAAU;IAC9C,UAAA,oBAAC,WAAW,eAAZ,CAA2B,CAAA;GACnB,CAAA;GACT,CAAC,CAAC,SACD,oBAAC,UAAD;IAAU,SAAS,UAAU;
|
|
1
|
+
{"version":3,"file":"BitkitRadio.js","names":[],"sources":["../../../lib/components/BitkitRadio/BitkitRadio.tsx"],"sourcesContent":["import { RadioGroup, useRadioGroupStyles } from '@chakra-ui/react/radio-group';\nimport { Skeleton } from '@chakra-ui/react/skeleton';\nimport { type DataAttr } from '@chakra-ui/react/styled-system';\nimport { Text } from '@chakra-ui/react/text';\nimport { forwardRef, type InputHTMLAttributes, type ReactElement, type ReactNode, type Ref } from 'react';\n\nimport { isEmptyNode } from '../../utilities/isEmptyNode';\nimport BitkitBadge from '../BitkitBadge/BitkitBadge';\n\n/**\n * Passthrough attributes for the radio `<input>`. The RadioGroup machine owns the behavioral / state\n * attributes (`checked`, `value`, `name`, `type`, `disabled`, `onChange`, …), so they're excluded —\n * setting them here would let the input drift out of sync with its `RadioGroup.Item`. Keep it to\n * things like `data-testid`.\n */\ntype RadioInputProps = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n 'checked' | 'defaultChecked' | 'defaultValue' | 'disabled' | 'name' | 'onChange' | 'type' | 'value'\n> &\n DataAttr;\n\ntype BitkitRadioBaseProps = {\n badge?: 'off' | 'on';\n inputProps?: RadioInputProps;\n state?: 'disabled' | 'skeleton';\n} & Omit<RadioGroup.ItemProps, 'disabled'>;\n\n/**\n * A radio has to end up with an accessible name, and it takes that name from its label. So either\n * pass a visible `labelText`, or — for a radio in a layout with no room for one, like a table row\n * selector — an `aria-label`, which is applied to the hidden input instead of being rendered.\n */\nexport type BitkitRadioProps<T extends NonNullable<ReactNode> = NonNullable<ReactNode>> = BitkitRadioBaseProps &\n (\n | {\n helperText?: ReactNode;\n /**\n * The visible label, which is where the radio gets its accessible name from. It has to be\n * non-empty — an empty string is a compile error. When the layout has no room for a visible\n * label, pass `aria-label` instead of an empty `labelText`.\n */\n labelText: T extends '' ? never : T;\n }\n | { 'aria-label': string; helperText?: never; labelText?: null }\n );\n\nconst BitkitRadio = forwardRef<HTMLInputElement, BitkitRadioProps>((props, ref) => {\n const { 'aria-label': ariaLabel, badge, helperText, inputProps, labelText, state, ...rest } = props;\n const styles = useRadioGroupStyles();\n const hasHelperText = !isEmptyNode(helperText);\n const hasLabel = !isEmptyNode(labelText) || hasHelperText;\n\n // Skeleton has to set disabled to be inert: the Skeleton wrapper's own pointer-events: none never\n // stopped a click, it only moved the target to the <label>, which activates the control. The cursor\n // style prop then keeps the arrow plain — style props land outside @layer recipes, where the\n // recipe's _disabled: { cursor: 'not-allowed' } sits.\n return (\n <RadioGroup.Item\n cursor={state === 'skeleton' ? 'default' : undefined}\n disabled={state === 'disabled' || state === 'skeleton'}\n {...rest}\n >\n <RadioGroup.ItemHiddenInput aria-label={ariaLabel} ref={ref} {...inputProps} />\n <Skeleton borderRadius=\"50%\" loading={state === 'skeleton'}>\n <RadioGroup.ItemIndicator />\n </Skeleton>\n {!!badge && (\n <Skeleton display=\"flex\" loading={state === 'skeleton'}>\n <BitkitBadge colorVariant={badge === 'on' ? 'green' : 'neutral'} css={styles.badge}>\n {badge}\n </BitkitBadge>\n </Skeleton>\n )}\n {hasLabel && (\n <Skeleton loading={state === 'skeleton'}>\n <RadioGroup.ItemText as=\"div\">\n {labelText}\n {hasHelperText && (\n <Text color={state === 'disabled' ? 'text/disabled' : 'text/helper'} textStyle=\"comp/input/helperText\">\n {helperText}\n </Text>\n )}\n </RadioGroup.ItemText>\n </Skeleton>\n )}\n </RadioGroup.Item>\n );\n});\n\nBitkitRadio.displayName = 'BitkitRadio';\n\n// The generic is what makes `labelText=\"\"` a compile error: `Exclude` cannot narrow `string` to\n// \"non-empty string\", but a conditional type on an inferred literal can. The cast carries the\n// generic through the call site, which `forwardRef`'s own signature would erase.\nexport default BitkitRadio as <T extends NonNullable<ReactNode>>(\n props: BitkitRadioProps<T> & { ref?: Ref<HTMLInputElement> },\n) => ReactElement;\n"],"mappings":";;;;;;;;AA8CA,IAAM,cAAc,YAAgD,OAAO,QAAQ;CACjF,MAAM,EAAE,cAAc,WAAW,OAAO,YAAY,YAAY,WAAW,OAAO,GAAG,SAAS;CAC9F,MAAM,SAAS,oBAAoB;CACnC,MAAM,gBAAgB,CAAC,YAAY,UAAU;CAC7C,MAAM,WAAW,CAAC,YAAY,SAAS,KAAK;CAM5C,OACE,qBAAC,WAAW,MAAZ;EACE,QAAQ,UAAU,aAAa,YAAY,KAAA;EAC3C,UAAU,UAAU,cAAc,UAAU;EAC5C,GAAI;EAHN,UAAA;GAKE,oBAAC,WAAW,iBAAZ;IAA4B,cAAY;IAAgB;IAAK,GAAI;GAAa,CAAA;GAC9E,oBAAC,UAAD;IAAU,cAAa;IAAM,SAAS,UAAU;IAC9C,UAAA,oBAAC,WAAW,eAAZ,CAA2B,CAAA;GACnB,CAAA;GACT,CAAC,CAAC,SACD,oBAAC,UAAD;IAAU,SAAQ;IAAO,SAAS,UAAU;IAC1C,UAAA,oBAAC,aAAD;KAAa,cAAc,UAAU,OAAO,UAAU;KAAW,KAAK,OAAO;KAC1E,UAAA;IACU,CAAA;GACL,CAAA;GAEX,YACC,oBAAC,UAAD;IAAU,SAAS,UAAU;IAC3B,UAAA,qBAAC,WAAW,UAAZ;KAAqB,IAAG;KAAxB,UAAA,CACG,WACA,iBACC,oBAAC,MAAD;MAAM,OAAO,UAAU,aAAa,kBAAkB;MAAe,WAAU;MAC5E,UAAA;KACG,CAAA,CAEW;;GACb,CAAA;EAEG;;AAErB,CAAC;AAED,YAAY,cAAc"}
|
|
@@ -26,6 +26,7 @@ var BitkitSwitchDefault = forwardRef((props, ref) => {
|
|
|
26
26
|
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
27
27
|
loading: state === "skeleton",
|
|
28
28
|
borderRadius: "12",
|
|
29
|
+
display: "flex",
|
|
29
30
|
height: size === "md" ? "16" : "24",
|
|
30
31
|
children: /* @__PURE__ */ jsxs(Switch.Control, { children: [/* @__PURE__ */ jsx(Switch.Thumb, {}), /* @__PURE__ */ jsx(Switch.Indicator, {
|
|
31
32
|
fallback: /* @__PURE__ */ jsx(IconCross, { size: size === "md" ? "16" : "24" }),
|
|
@@ -68,6 +69,7 @@ var BitkitSwitchDynamicText = forwardRef((props, ref) => {
|
|
|
68
69
|
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
69
70
|
loading: state === "skeleton",
|
|
70
71
|
borderRadius: "12",
|
|
72
|
+
display: "flex",
|
|
71
73
|
height: size === "md" ? "16" : "24",
|
|
72
74
|
children: /* @__PURE__ */ jsxs(Switch.Control, { children: [/* @__PURE__ */ jsx(Switch.Thumb, {}), /* @__PURE__ */ jsx(Switch.Indicator, {
|
|
73
75
|
fallback: /* @__PURE__ */ jsx(IconCross, { size: size === "md" ? "16" : "24" }),
|
|
@@ -133,6 +135,7 @@ var BitkitSwitchFixed = forwardRef((props, ref) => {
|
|
|
133
135
|
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
134
136
|
loading: state === "skeleton",
|
|
135
137
|
borderRadius: "12",
|
|
138
|
+
display: "flex",
|
|
136
139
|
height: size === "md" ? "16" : "24",
|
|
137
140
|
children: /* @__PURE__ */ jsx(Box, {
|
|
138
141
|
asChild: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitkitSwitch.js","names":[],"sources":["../../../lib/components/BitkitSwitch/BitkitSwitch.tsx"],"sourcesContent":["import { Box } from '@chakra-ui/react/box';\nimport { Skeleton } from '@chakra-ui/react/skeleton';\nimport { useSlotRecipe } from '@chakra-ui/react/styled-system';\nimport { Switch } from '@chakra-ui/react/switch';\nimport { type ForwardedRef, forwardRef, type ReactNode, useId } from 'react';\n\nimport { IconCheck, IconCross } from '../../icons';\nimport type {\n BitkitSwitchAnyVariantProps,\n BitkitSwitchDefaultProps,\n BitkitSwitchDynamicTextProps,\n BitkitSwitchFixedProps,\n BitkitSwitchProps,\n} from './BitkitSwitch.types';\nimport BitkitSwitchHelperText from './components/BitkitSwitchHelperText';\nimport BitkitSwitchLabel from './components/BitkitSwitchLabel';\nimport BitkitSwitchReadOnly from './components/BitkitSwitchReadOnly';\nimport BitkitSwitchValueText from './components/BitkitSwitchValueText';\n\nconst BitkitSwitchDefault = forwardRef<HTMLLabelElement, Omit<BitkitSwitchDefaultProps, 'variant'>>((props, ref) => {\n const { hideLabel, inputRef, label, size = 'lg', state = 'default', ...rest } = props;\n\n return (\n <Switch.Root\n ref={ref}\n size={size}\n readOnly={state === 'readOnly'}\n disabled={state === 'disabled' || state === 'skeleton'}\n {...rest}\n >\n <Switch.HiddenInput ref={inputRef} />\n <BitkitSwitchReadOnly state={state}>\n <Skeleton loading={state === 'skeleton'} borderRadius=\"12\" height={size === 'md' ? '16' : '24'}>\n <Switch.Control>\n <Switch.Thumb />\n <Switch.Indicator fallback={<IconCross size={size === 'md' ? '16' : '24'} />}>\n <IconCheck size={size === 'md' ? '16' : '24'} />\n </Switch.Indicator>\n </Switch.Control>\n </Skeleton>\n </BitkitSwitchReadOnly>\n {/* `srOnly` rather than a hidden label passed in by the consumer: it positions the element\n absolutely, so it leaves the flex flow and the root's gap no longer reserves space for it. */}\n {label && <Switch.Label srOnly={hideLabel}>{label}</Switch.Label>}\n </Switch.Root>\n );\n});\n\nBitkitSwitchDefault.displayName = 'BitkitSwitchDefault';\n\nconst BitkitSwitchDynamicText = forwardRef<HTMLLabelElement, Omit<BitkitSwitchDynamicTextProps, 'variant'>>(\n (props, ref) => {\n const {\n inputRef,\n label,\n optional,\n tooltip,\n helperText,\n valueText,\n size = 'lg',\n state = 'default',\n ...rest\n } = props;\n\n const recipe = useSlotRecipe({ key: 'switch' });\n const styles = recipe({ size });\n\n return (\n <Switch.Root\n ref={ref}\n gap=\"4\"\n size={size}\n flexDirection=\"column\"\n alignItems=\"flex-start\"\n readOnly={state === 'readOnly'}\n disabled={state === 'disabled' || state === 'disabledInput' || state === 'skeleton'}\n {...rest}\n >\n <Switch.HiddenInput ref={inputRef} />\n <BitkitSwitchLabel label={label} state={state} tooltip={tooltip} optional={optional} />\n <Box css={styles.root}>\n <BitkitSwitchReadOnly state={state}>\n <Skeleton loading={state === 'skeleton'} borderRadius=\"12\" height={size === 'md' ? '16' : '24'}>\n <Switch.Control>\n <Switch.Thumb />\n <Switch.Indicator fallback={<IconCross size={size === 'md' ? '16' : '24'} />}>\n <IconCheck size={size === 'md' ? '16' : '24'} />\n </Switch.Indicator>\n </Switch.Control>\n </Skeleton>\n </BitkitSwitchReadOnly>\n <BitkitSwitchValueText size={size} state={state} valueText={valueText} />\n </Box>\n <BitkitSwitchHelperText state={state} helperText={helperText} />\n </Switch.Root>\n );\n },\n);\n\nBitkitSwitchDynamicText.displayName = 'BitkitSwitchDynamicText';\n\nconst BitkitSwitchFixed = forwardRef<HTMLDivElement, Omit<BitkitSwitchFixedProps, 'variant'>>((props, ref) => {\n const { icon, ids, inputRef, label, optional, tooltip, helperText, size = 'lg', state = 'default', ...rest } = props;\n const id = useId();\n const switchIds = { hiddenInput: `${id}-input`, label: `${id}-label`, ...ids };\n\n return (\n <Switch.Root\n asChild\n ids={switchIds}\n size={size}\n readOnly={state === 'readOnly'}\n disabled={state === 'disabled' || state === 'disabledInput' || state === 'skeleton'}\n {...rest}\n >\n <Box ref={ref} gap=\"24\" width=\"100%\" display=\"flex\">\n <Switch.HiddenInput ref={inputRef} />\n <Box display=\"flex\" flex=\"1\" flexDirection=\"column\" gap=\"4\" minWidth=\"0\">\n <BitkitSwitchLabel\n icon={icon}\n id={switchIds.label}\n label={label}\n state={state}\n tooltip={tooltip}\n optional={optional}\n />\n <BitkitSwitchHelperText state={state} helperText={helperText} />\n </Box>\n <BitkitSwitchReadOnly state={state}>\n <Skeleton loading={state === 'skeleton'} borderRadius=\"12\" height={size === 'md' ? '16' : '24'}>\n <Box asChild display=\"flex\">\n <label htmlFor={switchIds.hiddenInput}>\n <Switch.Control>\n <Switch.Thumb />\n <Switch.Indicator fallback={<IconCross size={size === 'md' ? '16' : '24'} />}>\n <IconCheck size={size === 'md' ? '16' : '24'} />\n </Switch.Indicator>\n </Switch.Control>\n </label>\n </Box>\n </Skeleton>\n </BitkitSwitchReadOnly>\n </Box>\n </Switch.Root>\n );\n});\n\nBitkitSwitchFixed.displayName = 'BitkitSwitchFixed';\n\nconst BitkitSwitch = forwardRef<HTMLElement, BitkitSwitchProps>((props, ref) => {\n // At runtime (e.g. a shared Storybook meta) sibling-variant props may still flow in, so split them\n // off here and forward only what the chosen variant consumes — otherwise they leak to the DOM.\n const { variant, hideLabel, icon, inputRef, tooltip, optional, valueText, helperText, ...rest } =\n props as BitkitSwitchAnyVariantProps;\n\n if (variant === 'dynamic-text') {\n return (\n <BitkitSwitchDynamicText\n ref={ref as ForwardedRef<HTMLLabelElement>}\n inputRef={inputRef}\n tooltip={tooltip}\n optional={optional}\n valueText={valueText}\n helperText={helperText}\n {...rest}\n />\n );\n }\n\n if (variant === 'fixed') {\n return (\n <BitkitSwitchFixed\n ref={ref as ForwardedRef<HTMLDivElement>}\n icon={icon}\n inputRef={inputRef}\n tooltip={tooltip}\n optional={optional}\n helperText={helperText as ReactNode}\n {...rest}\n />\n );\n }\n\n return (\n <BitkitSwitchDefault\n ref={ref as ForwardedRef<HTMLLabelElement>}\n hideLabel={hideLabel}\n inputRef={inputRef}\n {...(rest as Omit<BitkitSwitchDefaultProps, 'variant'>)}\n />\n );\n});\n\nBitkitSwitch.displayName = 'BitkitSwitch';\n\nexport default BitkitSwitch;\n"],"mappings":";;;;;;;;;;;;;AAmBA,IAAM,sBAAsB,YAAyE,OAAO,QAAQ;CAClH,MAAM,EAAE,WAAW,UAAU,OAAO,OAAO,MAAM,QAAQ,WAAW,GAAG,SAAS;CAEhF,OACE,qBAAC,OAAO,MAAR;EACO;EACC;EACN,UAAU,UAAU;EACpB,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AC,UAAD;MAAU,SAAS,UAAU;MAAY,cAAa;MAAK,QAAQ,SAAS,OAAO,OAAO;MACxF,UAAA,oBAAC,KAAD;OAAK,SAAA;OAAQ,SAAQ;OACnB,UAAA,oBAAC,SAAD;QAAO,SAAS,UAAU;QACxB,UAAA,qBAAC,OAAO,SAAR,EAAA,UAAA,CACE,oBAAC,OAAO,OAAR,CAAe,CAAA,GACf,oBAAC,OAAO,WAAR;SAAkB,UAAU,oBAAC,WAAD,EAAW,MAAM,SAAS,OAAO,OAAO,KAAO,CAAA;SACzE,UAAA,oBAAC,WAAD,EAAW,MAAM,SAAS,OAAO,OAAO,KAAO,CAAA;QAC/B,CAAA,CACJ,EAAA,CAAA;OACX,CAAA;MACJ,CAAA;KACG,CAAA;IACU,CAAA;GACnB;;CACM,CAAA;AAEjB,CAAC;AAED,kBAAkB,cAAc;AAEhC,IAAM,eAAe,YAA4C,OAAO,QAAQ;CAG9E,MAAM,EAAE,SAAS,WAAW,MAAM,UAAU,SAAS,UAAU,WAAW,YAAY,GAAG,SACvF;CAEF,IAAI,YAAY,gBACd,OACE,oBAAC,yBAAD;EACO;EACK;EACD;EACC;EACC;EACC;EACZ,GAAI;CACL,CAAA;CAIL,IAAI,YAAY,SACd,OACE,oBAAC,mBAAD;EACO;EACC;EACI;EACD;EACC;EACE;EACZ,GAAI;CACL,CAAA;CAIL,OACE,oBAAC,qBAAD;EACO;EACM;EACD;EACV,GAAK;CACN,CAAA;AAEL,CAAC;AAED,aAAa,cAAc"}
|
|
1
|
+
{"version":3,"file":"BitkitSwitch.js","names":[],"sources":["../../../lib/components/BitkitSwitch/BitkitSwitch.tsx"],"sourcesContent":["import { Box } from '@chakra-ui/react/box';\nimport { Skeleton } from '@chakra-ui/react/skeleton';\nimport { useSlotRecipe } from '@chakra-ui/react/styled-system';\nimport { Switch } from '@chakra-ui/react/switch';\nimport { type ForwardedRef, forwardRef, type ReactNode, useId } from 'react';\n\nimport { IconCheck, IconCross } from '../../icons';\nimport type {\n BitkitSwitchAnyVariantProps,\n BitkitSwitchDefaultProps,\n BitkitSwitchDynamicTextProps,\n BitkitSwitchFixedProps,\n BitkitSwitchProps,\n} from './BitkitSwitch.types';\nimport BitkitSwitchHelperText from './components/BitkitSwitchHelperText';\nimport BitkitSwitchLabel from './components/BitkitSwitchLabel';\nimport BitkitSwitchReadOnly from './components/BitkitSwitchReadOnly';\nimport BitkitSwitchValueText from './components/BitkitSwitchValueText';\n\nconst BitkitSwitchDefault = forwardRef<HTMLLabelElement, Omit<BitkitSwitchDefaultProps, 'variant'>>((props, ref) => {\n const { hideLabel, inputRef, label, size = 'lg', state = 'default', ...rest } = props;\n\n return (\n <Switch.Root\n ref={ref}\n size={size}\n readOnly={state === 'readOnly'}\n disabled={state === 'disabled' || state === 'skeleton'}\n {...rest}\n >\n <Switch.HiddenInput ref={inputRef} />\n <BitkitSwitchReadOnly state={state}>\n <Skeleton loading={state === 'skeleton'} borderRadius=\"12\" display=\"flex\" height={size === 'md' ? '16' : '24'}>\n <Switch.Control>\n <Switch.Thumb />\n <Switch.Indicator fallback={<IconCross size={size === 'md' ? '16' : '24'} />}>\n <IconCheck size={size === 'md' ? '16' : '24'} />\n </Switch.Indicator>\n </Switch.Control>\n </Skeleton>\n </BitkitSwitchReadOnly>\n {/* `srOnly` rather than a hidden label passed in by the consumer: it positions the element\n absolutely, so it leaves the flex flow and the root's gap no longer reserves space for it. */}\n {label && <Switch.Label srOnly={hideLabel}>{label}</Switch.Label>}\n </Switch.Root>\n );\n});\n\nBitkitSwitchDefault.displayName = 'BitkitSwitchDefault';\n\nconst BitkitSwitchDynamicText = forwardRef<HTMLLabelElement, Omit<BitkitSwitchDynamicTextProps, 'variant'>>(\n (props, ref) => {\n const {\n inputRef,\n label,\n optional,\n tooltip,\n helperText,\n valueText,\n size = 'lg',\n state = 'default',\n ...rest\n } = props;\n\n const recipe = useSlotRecipe({ key: 'switch' });\n const styles = recipe({ size });\n\n return (\n <Switch.Root\n ref={ref}\n gap=\"4\"\n size={size}\n flexDirection=\"column\"\n alignItems=\"flex-start\"\n readOnly={state === 'readOnly'}\n disabled={state === 'disabled' || state === 'disabledInput' || state === 'skeleton'}\n {...rest}\n >\n <Switch.HiddenInput ref={inputRef} />\n <BitkitSwitchLabel label={label} state={state} tooltip={tooltip} optional={optional} />\n <Box css={styles.root}>\n <BitkitSwitchReadOnly state={state}>\n <Skeleton\n loading={state === 'skeleton'}\n borderRadius=\"12\"\n display=\"flex\"\n height={size === 'md' ? '16' : '24'}\n >\n <Switch.Control>\n <Switch.Thumb />\n <Switch.Indicator fallback={<IconCross size={size === 'md' ? '16' : '24'} />}>\n <IconCheck size={size === 'md' ? '16' : '24'} />\n </Switch.Indicator>\n </Switch.Control>\n </Skeleton>\n </BitkitSwitchReadOnly>\n <BitkitSwitchValueText size={size} state={state} valueText={valueText} />\n </Box>\n <BitkitSwitchHelperText state={state} helperText={helperText} />\n </Switch.Root>\n );\n },\n);\n\nBitkitSwitchDynamicText.displayName = 'BitkitSwitchDynamicText';\n\nconst BitkitSwitchFixed = forwardRef<HTMLDivElement, Omit<BitkitSwitchFixedProps, 'variant'>>((props, ref) => {\n const { icon, ids, inputRef, label, optional, tooltip, helperText, size = 'lg', state = 'default', ...rest } = props;\n const id = useId();\n const switchIds = { hiddenInput: `${id}-input`, label: `${id}-label`, ...ids };\n\n return (\n <Switch.Root\n asChild\n ids={switchIds}\n size={size}\n readOnly={state === 'readOnly'}\n disabled={state === 'disabled' || state === 'disabledInput' || state === 'skeleton'}\n {...rest}\n >\n <Box ref={ref} gap=\"24\" width=\"100%\" display=\"flex\">\n <Switch.HiddenInput ref={inputRef} />\n <Box display=\"flex\" flex=\"1\" flexDirection=\"column\" gap=\"4\" minWidth=\"0\">\n <BitkitSwitchLabel\n icon={icon}\n id={switchIds.label}\n label={label}\n state={state}\n tooltip={tooltip}\n optional={optional}\n />\n <BitkitSwitchHelperText state={state} helperText={helperText} />\n </Box>\n <BitkitSwitchReadOnly state={state}>\n <Skeleton\n loading={state === 'skeleton'}\n borderRadius=\"12\"\n display=\"flex\"\n height={size === 'md' ? '16' : '24'}\n >\n <Box asChild display=\"flex\">\n <label htmlFor={switchIds.hiddenInput}>\n <Switch.Control>\n <Switch.Thumb />\n <Switch.Indicator fallback={<IconCross size={size === 'md' ? '16' : '24'} />}>\n <IconCheck size={size === 'md' ? '16' : '24'} />\n </Switch.Indicator>\n </Switch.Control>\n </label>\n </Box>\n </Skeleton>\n </BitkitSwitchReadOnly>\n </Box>\n </Switch.Root>\n );\n});\n\nBitkitSwitchFixed.displayName = 'BitkitSwitchFixed';\n\nconst BitkitSwitch = forwardRef<HTMLElement, BitkitSwitchProps>((props, ref) => {\n // At runtime (e.g. a shared Storybook meta) sibling-variant props may still flow in, so split them\n // off here and forward only what the chosen variant consumes — otherwise they leak to the DOM.\n const { variant, hideLabel, icon, inputRef, tooltip, optional, valueText, helperText, ...rest } =\n props as BitkitSwitchAnyVariantProps;\n\n if (variant === 'dynamic-text') {\n return (\n <BitkitSwitchDynamicText\n ref={ref as ForwardedRef<HTMLLabelElement>}\n inputRef={inputRef}\n tooltip={tooltip}\n optional={optional}\n valueText={valueText}\n helperText={helperText}\n {...rest}\n />\n );\n }\n\n if (variant === 'fixed') {\n return (\n <BitkitSwitchFixed\n ref={ref as ForwardedRef<HTMLDivElement>}\n icon={icon}\n inputRef={inputRef}\n tooltip={tooltip}\n optional={optional}\n helperText={helperText as ReactNode}\n {...rest}\n />\n );\n }\n\n return (\n <BitkitSwitchDefault\n ref={ref as ForwardedRef<HTMLLabelElement>}\n hideLabel={hideLabel}\n inputRef={inputRef}\n {...(rest as Omit<BitkitSwitchDefaultProps, 'variant'>)}\n />\n );\n});\n\nBitkitSwitch.displayName = 'BitkitSwitch';\n\nexport default BitkitSwitch;\n"],"mappings":";;;;;;;;;;;;;AAmBA,IAAM,sBAAsB,YAAyE,OAAO,QAAQ;CAClH,MAAM,EAAE,WAAW,UAAU,OAAO,OAAO,MAAM,QAAQ,WAAW,GAA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ACD,oBAAC,wBAAD;MAA+B;MAAmB;KAAa,CAAA,CAC5D;;IACL,oBAAC,sBAAD;KAA6B;KAC3B,UAAA,oBAAC,UAAD;MACE,SAAS,UAAU;MACnB,cAAa;MACb,SAAQ;MACR,QAAQ,SAAS,OAAO,OAAO;MAE/B,UAAA,oBAAC,KAAD;OAAK,SAAA;OAAQ,SAAQ;OACnB,UAAA,oBAAC,SAAD;QAAO,SAAS,UAAU;QACxB,UAAA,qBAAC,OAAO,SAAR,EAAA,UAAA,CACE,oBAAC,OAAO,OAAR,CAAe,CAAA,GACf,oBAAC,OAAO,WAAR;SAAkB,UAAU,oBAAC,WAAD,EAAW,MAAM,SAAS,OAAO,OAAO,KAAO,CAAA;SACzE,UAAA,oBAAC,WAAD,EAAW,MAAM,SAAS,OAAO,OAAO,KAAO,CAAA;QAC/B,CAAA,CACJ,EAAA,CAAA;OACX,CAAA;MACJ,CAAA;KACG,CAAA;IACU,CAAA;GACnB;;CACM,CAAA;AAEjB,CAAC;AAED,kBAAkB,cAAc;AAEhC,IAAM,eAAe,YAA4C,OAAO,QAAQ;CAG9E,MAAM,EAAE,SAAS,WAAW,MAAM,UAAU,SAAS,UAAU,WAAW,YAAY,GAAG,SACvF;CAEF,IAAI,YAAY,gBACd,OACE,oBAAC,yBAAD;EACO;EACK;EACD;EACC;EACC;EACC;EACZ,GAAI;CACL,CAAA;CAIL,IAAI,YAAY,SACd,OACE,oBAAC,mBAAD;EACO;EACC;EACI;EACD;EACC;EACE;EACZ,GAAI;CACL,CAAA;CAIL,OACE,oBAAC,qBAAD;EACO;EACM;EACD;EACV,GAAK;CACN,CAAA;AAEL,CAAC;AAED,aAAa,cAAc"}
|
|
@@ -18,6 +18,7 @@ var BitkitToggleButton = forwardRef((props, ref) => {
|
|
|
18
18
|
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
19
19
|
loading: state === "skeleton",
|
|
20
20
|
borderRadius: "4",
|
|
21
|
+
display: "flex",
|
|
21
22
|
width: "fit-content",
|
|
22
23
|
children: /* @__PURE__ */ jsx(Toggle.Root, {
|
|
23
24
|
asChild: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitkitToggleButton.js","names":[],"sources":["../../../lib/components/BitkitToggleButton/BitkitToggleButton.tsx"],"sourcesContent":["import { Skeleton } from '@chakra-ui/react/skeleton';\nimport { chakra, type HTMLChakraProps, useRecipe } from '@chakra-ui/react/styled-system';\nimport { Toggle } from '@chakra-ui/react/toggle';\nimport { forwardRef } from 'react';\n\nimport { type BitkitIconComponent } from '../../icons';\nimport opensPopup from '../../utilities/opensPopup';\nimport BitkitLabelTooltip, { type BitkitLabelTooltipProps } from '../BitkitLabelTooltip/BitkitLabelTooltip';\n\nexport interface BitkitToggleButtonProps extends Omit<HTMLChakraProps<'button'>, 'children' | 'disabled' | 'size'> {\n icon: BitkitIconComponent;\n label: string;\n size?: 'sm' | 'md' | 'lg';\n state?: 'disabled' | 'skeleton';\n isSelected?: boolean;\n /**\n * Overrides for the label tooltip. It is off by default when this control opens a popup — a menu,\n * select or popover trigger — where the panel is the affordance and a tooltip would hover over it.\n * Pass `{ disabled: false }` to bring it back. The accessible name comes from `label` either way.\n */\n tooltipProps?: Partial<Omit<BitkitLabelTooltipProps, 'children' | 'text'>>;\n defaultSelected?: boolean;\n onSelectedChange?: (selected: boolean) => void;\n}\n\nconst BitkitToggleButton = forwardRef<HTMLButtonElement, BitkitToggleButtonProps>((props, ref) => {\n const {\n icon: Icon,\n label,\n size = 'md',\n state,\n isSelected,\n tooltipProps,\n defaultSelected,\n onSelectedChange,\n css,\n ...rest\n } = props;\n\n const recipe = useRecipe({ key: 'toggleButton' });\n const iconSize = size === 'lg' ? '24' : '16';\n const isPopupTrigger = opensPopup(props);\n\n return (\n <BitkitLabelTooltip text={label} disabled={isPopupTrigger} {...tooltipProps}>\n <Skeleton loading={state === 'skeleton'} borderRadius=\"4\" width=\"fit-content\">\n <Toggle.Root\n asChild\n disabled={state === 'disabled'}\n defaultPressed={defaultSelected}\n onPressedChange={onSelectedChange}\n pressed={isSelected}\n >\n <chakra.button ref={ref} aria-label={label} {...rest} css={[recipe({ size }), css]}>\n <Icon size={iconSize} />\n </chakra.button>\n </Toggle.Root>\n </Skeleton>\n </BitkitLabelTooltip>\n );\n});\n\nBitkitToggleButton.displayName = 'BitkitToggleButton';\n\nexport default BitkitToggleButton;\n"],"mappings":";;;;;;;;AAyBA,IAAM,qBAAqB,YAAwD,OAAO,QAAQ;CAChG,MAAM,EACJ,MAAM,MACN,OACA,OAAO,MACP,OACA,YACA,cACA,iBACA,kBACA,KACA,GAAG,SACD;CAEJ,MAAM,SAAS,UAAU,EAAE,KAAK,eAAe,CAAC;CAChD,MAAM,WAAW,SAAS,OAAO,OAAO;CACxC,MAAM,iBAAiB,WAAW,KAAK;CAEvC,OACE,oBAAC,oBAAD;EAAoB,MAAM;EAAO,UAAU;EAAgB,GAAI;EAC7D,UAAA,oBAAC,UAAD;GAAU,SAAS,UAAU;GAAY,cAAa;GAAI,OAAM;
|
|
1
|
+
{"version":3,"file":"BitkitToggleButton.js","names":[],"sources":["../../../lib/components/BitkitToggleButton/BitkitToggleButton.tsx"],"sourcesContent":["import { Skeleton } from '@chakra-ui/react/skeleton';\nimport { chakra, type HTMLChakraProps, useRecipe } from '@chakra-ui/react/styled-system';\nimport { Toggle } from '@chakra-ui/react/toggle';\nimport { forwardRef } from 'react';\n\nimport { type BitkitIconComponent } from '../../icons';\nimport opensPopup from '../../utilities/opensPopup';\nimport BitkitLabelTooltip, { type BitkitLabelTooltipProps } from '../BitkitLabelTooltip/BitkitLabelTooltip';\n\nexport interface BitkitToggleButtonProps extends Omit<HTMLChakraProps<'button'>, 'children' | 'disabled' | 'size'> {\n icon: BitkitIconComponent;\n label: string;\n size?: 'sm' | 'md' | 'lg';\n state?: 'disabled' | 'skeleton';\n isSelected?: boolean;\n /**\n * Overrides for the label tooltip. It is off by default when this control opens a popup — a menu,\n * select or popover trigger — where the panel is the affordance and a tooltip would hover over it.\n * Pass `{ disabled: false }` to bring it back. The accessible name comes from `label` either way.\n */\n tooltipProps?: Partial<Omit<BitkitLabelTooltipProps, 'children' | 'text'>>;\n defaultSelected?: boolean;\n onSelectedChange?: (selected: boolean) => void;\n}\n\nconst BitkitToggleButton = forwardRef<HTMLButtonElement, BitkitToggleButtonProps>((props, ref) => {\n const {\n icon: Icon,\n label,\n size = 'md',\n state,\n isSelected,\n tooltipProps,\n defaultSelected,\n onSelectedChange,\n css,\n ...rest\n } = props;\n\n const recipe = useRecipe({ key: 'toggleButton' });\n const iconSize = size === 'lg' ? '24' : '16';\n const isPopupTrigger = opensPopup(props);\n\n return (\n <BitkitLabelTooltip text={label} disabled={isPopupTrigger} {...tooltipProps}>\n <Skeleton loading={state === 'skeleton'} borderRadius=\"4\" display=\"flex\" width=\"fit-content\">\n <Toggle.Root\n asChild\n disabled={state === 'disabled'}\n defaultPressed={defaultSelected}\n onPressedChange={onSelectedChange}\n pressed={isSelected}\n >\n <chakra.button ref={ref} aria-label={label} {...rest} css={[recipe({ size }), css]}>\n <Icon size={iconSize} />\n </chakra.button>\n </Toggle.Root>\n </Skeleton>\n </BitkitLabelTooltip>\n );\n});\n\nBitkitToggleButton.displayName = 'BitkitToggleButton';\n\nexport default BitkitToggleButton;\n"],"mappings":";;;;;;;;AAyBA,IAAM,qBAAqB,YAAwD,OAAO,QAAQ;CAChG,MAAM,EACJ,MAAM,MACN,OACA,OAAO,MACP,OACA,YACA,cACA,iBACA,kBACA,KACA,GAAG,SACD;CAEJ,MAAM,SAAS,UAAU,EAAE,KAAK,eAAe,CAAC;CAChD,MAAM,WAAW,SAAS,OAAO,OAAO;CACxC,MAAM,iBAAiB,WAAW,KAAK;CAEvC,OACE,oBAAC,oBAAD;EAAoB,MAAM;EAAO,UAAU;EAAgB,GAAI;EAC7D,UAAA,oBAAC,UAAD;GAAU,SAAS,UAAU;GAAY,cAAa;GAAI,SAAQ;GAAO,OAAM;GAC7E,UAAA,oBAAC,OAAO,MAAR;IACE,SAAA;IACA,UAAU,UAAU;IACpB,gBAAgB;IAChB,iBAAiB;IACjB,SAAS;IAET,UAAA,oBAAC,OAAO,QAAR;KAAoB;KAAK,cAAY;KAAO,GAAI;KAAM,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,GAAG;KAC/E,UAAA,oBAAC,MAAD,EAAM,MAAM,SAAW,CAAA;IACV,CAAA;GACJ,CAAA;EACL,CAAA;CACQ,CAAA;AAExB,CAAC;AAED,mBAAmB,cAAc"}
|
|
@@ -25,22 +25,29 @@ var variantStyles = [
|
|
|
25
25
|
color: isSecondary ? "button/secondary/text-active" : `button/${variant}/fg-active`,
|
|
26
26
|
_icon: { color: isSecondary ? "button/secondary/icon-active" : void 0 }
|
|
27
27
|
};
|
|
28
|
+
const disabledStyles = {
|
|
29
|
+
backgroundColor: `button/${variant}/bg-disabled`,
|
|
30
|
+
borderColor: disabledBorderColor,
|
|
31
|
+
color: isSecondary ? "button/secondary/text-disabled" : `button/${variant}/fg-disabled`,
|
|
32
|
+
cursor: "not-allowed",
|
|
33
|
+
_icon: { color: isSecondary ? "button/secondary/icon-disabled" : void 0 }
|
|
34
|
+
};
|
|
35
|
+
const expandedStyles = {
|
|
36
|
+
...activeStyles,
|
|
37
|
+
_disabled: disabledStyles
|
|
38
|
+
};
|
|
28
39
|
obj[variant] = {
|
|
29
40
|
_hover: {
|
|
30
41
|
backgroundColor: `button/${variant}/bg-hover`,
|
|
31
42
|
borderColor: variant?.includes("secondary") ? `button/${variant}/border-hover` : `button/${variant}/bg-hover`,
|
|
32
43
|
color: isSecondary ? "button/secondary/text-hover" : `button/${variant}/fg-hover`,
|
|
33
44
|
_icon: { color: isSecondary ? "button/secondary/icon-hover" : void 0 },
|
|
34
|
-
_active: activeStyles
|
|
45
|
+
_active: activeStyles,
|
|
46
|
+
_expanded: expandedStyles
|
|
35
47
|
},
|
|
36
48
|
_active: activeStyles,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
borderColor: disabledBorderColor,
|
|
40
|
-
color: isSecondary ? "button/secondary/text-disabled" : `button/${variant}/fg-disabled`,
|
|
41
|
-
cursor: "not-allowed",
|
|
42
|
-
_icon: { color: isSecondary ? "button/secondary/icon-disabled" : void 0 }
|
|
43
|
-
},
|
|
49
|
+
_expanded: expandedStyles,
|
|
50
|
+
_disabled: disabledStyles,
|
|
44
51
|
_icon: { color: isSecondary ? "button/secondary/icon" : void 0 },
|
|
45
52
|
backgroundColor: `button/${variant}/bg`,
|
|
46
53
|
borderColor,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.recipe.js","names":[],"sources":["../../../lib/theme/recipes/Button.recipe.ts"],"sourcesContent":["import { defineRecipe, type SystemStyleObject } from '@chakra-ui/react/styled-system';\n\nimport { rem } from '../themeUtils';\n\n// `as const` is load-bearing: without it `(typeof buttonVariants)[number]` widens to `string`,\n// which collapses the recipe's `variant` prop type to `string` — losing TS autocomplete/checking\n// and leaving Storybook/docgen (and the bitkit-storybook MCP) unable to enumerate the variants.\nconst buttonVariants = [\n 'primary',\n 'secondary',\n 'tertiary',\n 'danger-primary',\n 'danger-secondary',\n 'danger-tertiary',\n 'ai-primary',\n 'ai-secondary',\n 'ai-tertiary',\n] as const;\n\nexport type Variant = (typeof buttonVariants)[number];\n\nconst variantStyles = buttonVariants.reduce(\n (obj, variant) => {\n let borderColor = variant?.includes('secondary') ? `button/${variant}/border` : `button/${variant}/bg`;\n let disabledBorderColor = variant?.includes('secondary')\n ? `button/${variant}/border-disabled`\n : `button/${variant}/bg-disabled`;\n if (variant?.includes('tertiary')) {\n borderColor = 'transparent';\n disabledBorderColor = 'transparent';\n }\n const isSecondary = variant === 'secondary';\n const activeStyles: SystemStyleObject = {\n backgroundColor: `button/${variant}/bg-active`,\n borderColor: variant?.includes('secondary') ? `button/${variant}/border-active` : `button/${variant}/bg-active`,\n color: isSecondary ? 'button/secondary/text-active' : `button/${variant}/fg-active`,\n _icon: {\n color: isSecondary ? 'button/secondary/icon-active' : undefined,\n },\n };\n obj[variant as NonNullable<Variant>] = {\n // `_hover`/`_active` (not raw `&:hover`/`&:active`) compile to `:not(:disabled, [data-disabled])`,\n // so they never match a disabled button — the `_disabled` styles win naturally, no `!important` needed.\n _hover: {\n backgroundColor: `button/${variant}/bg-hover`,\n borderColor: variant?.includes('secondary') ? `button/${variant}/border-hover` : `button/${variant}/bg-hover`,\n color: isSecondary ? 'button/secondary/text-hover' : `button/${variant}/fg-hover`,\n _icon: {\n color: isSecondary ? 'button/secondary/icon-hover' : undefined,\n },\n // Repeat active under hover so
|
|
1
|
+
{"version":3,"file":"Button.recipe.js","names":[],"sources":["../../../lib/theme/recipes/Button.recipe.ts"],"sourcesContent":["import { defineRecipe, type SystemStyleObject } from '@chakra-ui/react/styled-system';\n\nimport { rem } from '../themeUtils';\n\n// `as const` is load-bearing: without it `(typeof buttonVariants)[number]` widens to `string`,\n// which collapses the recipe's `variant` prop type to `string` — losing TS autocomplete/checking\n// and leaving Storybook/docgen (and the bitkit-storybook MCP) unable to enumerate the variants.\nconst buttonVariants = [\n 'primary',\n 'secondary',\n 'tertiary',\n 'danger-primary',\n 'danger-secondary',\n 'danger-tertiary',\n 'ai-primary',\n 'ai-secondary',\n 'ai-tertiary',\n] as const;\n\nexport type Variant = (typeof buttonVariants)[number];\n\nconst variantStyles = buttonVariants.reduce(\n (obj, variant) => {\n let borderColor = variant?.includes('secondary') ? `button/${variant}/border` : `button/${variant}/bg`;\n let disabledBorderColor = variant?.includes('secondary')\n ? `button/${variant}/border-disabled`\n : `button/${variant}/bg-disabled`;\n if (variant?.includes('tertiary')) {\n borderColor = 'transparent';\n disabledBorderColor = 'transparent';\n }\n const isSecondary = variant === 'secondary';\n const activeStyles: SystemStyleObject = {\n backgroundColor: `button/${variant}/bg-active`,\n borderColor: variant?.includes('secondary') ? `button/${variant}/border-active` : `button/${variant}/bg-active`,\n color: isSecondary ? 'button/secondary/text-active' : `button/${variant}/fg-active`,\n _icon: {\n color: isSecondary ? 'button/secondary/icon-active' : undefined,\n },\n };\n const disabledStyles: SystemStyleObject = {\n backgroundColor: `button/${variant}/bg-disabled`,\n borderColor: disabledBorderColor,\n color: isSecondary ? 'button/secondary/text-disabled' : `button/${variant}/fg-disabled`,\n cursor: 'not-allowed',\n _icon: {\n color: isSecondary ? 'button/secondary/icon-disabled' : undefined,\n },\n };\n // A menu or popover trigger stays active while its content is open. `_expanded` (aria-expanded), not\n // `_open`: a tooltip trigger gets `data-state=open` too. It has no disabled guard, and Zag keeps an\n // open menu open when its trigger turns disabled, so the disabled styles are repeated inside.\n const expandedStyles: SystemStyleObject = { ...activeStyles, _disabled: disabledStyles };\n obj[variant as NonNullable<Variant>] = {\n // `_hover`/`_active` (not raw `&:hover`/`&:active`) compile to `:not(:disabled, [data-disabled])`,\n // so they never match a disabled button — the `_disabled` styles win naturally, no `!important` needed.\n _hover: {\n backgroundColor: `button/${variant}/bg-hover`,\n borderColor: variant?.includes('secondary') ? `button/${variant}/border-hover` : `button/${variant}/bg-hover`,\n color: isSecondary ? 'button/secondary/text-hover' : `button/${variant}/fg-hover`,\n _icon: {\n color: isSecondary ? 'button/secondary/icon-hover' : undefined,\n },\n // Repeat active and expanded under hover so the pointer doesn't override them (see CLAUDE.md).\n _active: activeStyles,\n _expanded: expandedStyles,\n },\n _active: activeStyles,\n _expanded: expandedStyles,\n _disabled: disabledStyles,\n _icon: {\n color: isSecondary ? 'button/secondary/icon' : undefined,\n },\n backgroundColor: `button/${variant}/bg`,\n borderColor,\n borderStyle: 'solid',\n borderWidth: '1',\n color: isSecondary ? 'button/secondary/text' : `button/${variant}/fg`,\n };\n return obj;\n },\n {} as Record<NonNullable<Variant>, SystemStyleObject>,\n);\n\nconst buttonRecipe = defineRecipe({\n className: 'button',\n base: {\n borderRadius: '4',\n cursor: 'pointer',\n fontWeight: 600,\n border: '1px solid transparent',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n gap: '8',\n position: 'relative',\n '--spinner-color': 'currentColor',\n '--spinner-size': 'sizes.16',\n _disabled: {\n cursor: 'not-allowed',\n },\n },\n variants: {\n variant: variantStyles,\n size: {\n sm: {\n minWidth: '32',\n height: '32',\n paddingInline: rem(11),\n paddingBlock: rem(5),\n textStyle: 'comp/button/sm',\n },\n md: {\n minWidth: '40',\n height: '40',\n paddingInline: rem(15),\n paddingBlock: rem(7),\n textStyle: 'comp/button/md',\n },\n lg: {\n minWidth: '48',\n height: '48',\n padding: rem(15),\n textStyle: 'comp/button/lg',\n },\n },\n },\n defaultVariants: {\n variant: 'primary',\n size: 'lg',\n },\n});\n\nexport default buttonRecipe;\n"],"mappings":";;;AAqBA,IAAM,gBAAgB;CAbpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAKoB,CAAA,CAAe,QAClC,KAAK,YAAY;CAChB,IAAI,cAAc,SAAS,SAAS,WAAW,IAAI,UAAU,QAAQ,WAAW,UAAU,QAAQ;CAClG,IAAI,sBAAsB,SAAS,SAAS,WAAW,IACnD,UAAU,QAAQ,oBAClB,UAAU,QAAQ;CACtB,IAAI,SAAS,SAAS,UAAU,GAAG;EACjC,cAAc;EACd,sBAAsB;CACxB;CACA,MAAM,cAAc,YAAY;CAChC,MAAM,eAAkC;EACtC,iBAAiB,UAAU,QAAQ;EACnC,aAAa,SAAS,SAAS,WAAW,IAAI,UAAU,QAAQ,kBAAkB,UAAU,QAAQ;EACpG,OAAO,cAAc,iCAAiC,UAAU,QAAQ;EACxE,OAAO,EACL,OAAO,cAAc,iCAAiC,KAAA,EACxD;CACF;CACA,MAAM,iBAAoC;EACxC,iBAAiB,UAAU,QAAQ;EACnC,aAAa;EACb,OAAO,cAAc,mCAAmC,UAAU,QAAQ;EAC1E,QAAQ;EACR,OAAO,EACL,OAAO,cAAc,mCAAmC,KAAA,EAC1D;CACF;CAIA,MAAM,iBAAoC;EAAE,GAAG;EAAc,WAAW;CAAe;CACvF,IAAI,WAAmC;EAGrC,QAAQ;GACN,iBAAiB,UAAU,QAAQ;GACnC,aAAa,SAAS,SAAS,WAAW,IAAI,UAAU,QAAQ,iBAAiB,UAAU,QAAQ;GACnG,OAAO,cAAc,gCAAgC,UAAU,QAAQ;GACvE,OAAO,EACL,OAAO,cAAc,gCAAgC,KAAA,EACvD;GAEA,SAAS;GACT,WAAW;EACb;EACA,SAAS;EACT,WAAW;EACX,WAAW;EACX,OAAO,EACL,OAAO,cAAc,0BAA0B,KAAA,EACjD;EACA,iBAAiB,UAAU,QAAQ;EACnC;EACA,aAAa;EACb,aAAa;EACb,OAAO,cAAc,0BAA0B,UAAU,QAAQ;CACnE;CACA,OAAO;AACT,GACA,CAAC,CACH;AAEA,IAAM,eAAe,aAAa;CAChC,WAAW;CACX,MAAM;EACJ,cAAc;EACd,QAAQ;EACR,YAAY;EACZ,QAAQ;EACR,SAAS;EACT,YAAY;EACZ,gBAAgB;EAChB,KAAK;EACL,UAAU;EACV,mBAAmB;EACnB,kBAAkB;EAClB,WAAW,EACT,QAAQ,cACV;CACF;CACA,UAAU;EACR,SAAS;EACT,MAAM;GACJ,IAAI;IACF,UAAU;IACV,QAAQ;IACR,eAAe,IAAI,EAAE;IACrB,cAAc,IAAI,CAAC;IACnB,WAAW;GACb;GACA,IAAI;IACF,UAAU;IACV,QAAQ;IACR,eAAe,IAAI,EAAE;IACrB,cAAc,IAAI,CAAC;IACnB,WAAW;GACb;GACA,IAAI;IACF,UAAU;IACV,QAAQ;IACR,SAAS,IAAI,EAAE;IACf,WAAW;GACb;EACF;CACF;CACA,iBAAiB;EACf,SAAS;EACT,MAAM;CACR;AACF,CAAC"}
|
|
@@ -3,13 +3,12 @@ import { defineRecipe } from "@chakra-ui/react/styled-system";
|
|
|
3
3
|
//#region lib/theme/recipes/Skeleton.recipe.ts
|
|
4
4
|
var skeletonRecipe = defineRecipe({
|
|
5
5
|
className: "skeleton",
|
|
6
|
-
base: {
|
|
7
|
-
display: "flex",
|
|
8
|
-
alignItems: "center",
|
|
9
|
-
justifyContent: "center"
|
|
10
|
-
},
|
|
6
|
+
base: {},
|
|
11
7
|
variants: { loading: {
|
|
12
8
|
true: {
|
|
9
|
+
display: "flex",
|
|
10
|
+
alignItems: "center",
|
|
11
|
+
justifyContent: "center",
|
|
13
12
|
position: "relative",
|
|
14
13
|
overflow: "hidden",
|
|
15
14
|
backgroundColor: "utilities/skeleton",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Skeleton.recipe.js","names":[],"sources":["../../../lib/theme/recipes/Skeleton.recipe.ts"],"sourcesContent":["import { defineRecipe } from '@chakra-ui/react/styled-system';\n\nimport { skeletonShimmerAfter } from '../common/skeletonShimmer';\n\n// Matches the v1 Skeleton: a static neutral base with a soft-masked highlight band sweeping\n// left→right (a `::after` overlay), rather than animating a two-tone gradient's background-position.\n\nconst skeletonRecipe = defineRecipe({\n className: 'skeleton',\n base: {\n display: 'flex',\n
|
|
1
|
+
{"version":3,"file":"Skeleton.recipe.js","names":[],"sources":["../../../lib/theme/recipes/Skeleton.recipe.ts"],"sourcesContent":["import { defineRecipe } from '@chakra-ui/react/styled-system';\n\nimport { skeletonShimmerAfter } from '../common/skeletonShimmer';\n\n// Matches the v1 Skeleton: a static neutral base with a soft-masked highlight band sweeping\n// left→right (a `::after` overlay), rather than animating a two-tone gradient's background-position.\n\nconst skeletonRecipe = defineRecipe({\n className: 'skeleton',\n base: {},\n\n variants: {\n loading: {\n // Layout only while loading: once loaded, the wrapper must not re-lay out (e.g. centre) what it wraps.\n true: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n position: 'relative',\n overflow: 'hidden',\n backgroundColor: 'utilities/skeleton',\n borderColor: 'transparent',\n backgroundClip: 'padding-box',\n cursor: 'default',\n color: 'transparent',\n pointerEvents: 'none',\n userSelect: 'none',\n flexShrink: '0',\n // Hide the wrapped content (asChild) and `::before`, but not `::after` — that paints the shimmer.\n '&::before, *': {\n visibility: 'hidden',\n },\n '&::after': skeletonShimmerAfter,\n },\n false: {\n animation: 'fade-in var(--fade-duration, 0.1s) ease-out !important',\n },\n },\n },\n\n defaultVariants: {\n loading: true,\n },\n});\n\nexport default skeletonRecipe;\n"],"mappings":";;;AAOA,IAAM,iBAAiB,aAAa;CAClC,WAAW;CACX,MAAM,CAAC;CAEP,UAAU,EACR,SAAS;EAEP,MAAM;GACJ,SAAS;GACT,YAAY;GACZ,gBAAgB;GAChB,UAAU;GACV,UAAU;GACV,iBAAiB;GACjB,aAAa;GACb,gBAAgB;GAChB,QAAQ;GACR,OAAO;GACP,eAAe;GACf,YAAY;GACZ,YAAY;GAEZ,gBAAgB,EACd,YAAY,SACd;GACA,YAAY;EACd;EACA,OAAO,EACL,WAAW,yDACb;CACF,EACF;CAEA,iBAAiB,EACf,SAAS,KACX;AACF,CAAC"}
|