@kushagradhawan/kookie-ui 0.1.5 → 0.1.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/components.css +100 -9
- package/dist/cjs/components/_internal/base-button.d.ts +2 -1
- package/dist/cjs/components/_internal/base-button.d.ts.map +1 -1
- package/dist/cjs/components/_internal/base-button.js +1 -1
- package/dist/cjs/components/_internal/base-button.js.map +3 -3
- package/dist/cjs/components/checkbox-cards.js.map +1 -1
- package/dist/cjs/components/icon-button.d.ts +12 -1
- package/dist/cjs/components/icon-button.d.ts.map +1 -1
- package/dist/cjs/components/icon-button.js +1 -1
- package/dist/cjs/components/icon-button.js.map +2 -2
- package/dist/cjs/components/radio-cards.js.map +1 -1
- package/dist/cjs/components/toggle-icon-button.d.ts +21 -7
- package/dist/cjs/components/toggle-icon-button.d.ts.map +1 -1
- package/dist/cjs/components/toggle-icon-button.js +1 -1
- package/dist/cjs/components/toggle-icon-button.js.map +3 -3
- package/dist/esm/components/_internal/base-button.d.ts +2 -1
- package/dist/esm/components/_internal/base-button.d.ts.map +1 -1
- package/dist/esm/components/_internal/base-button.js +1 -1
- package/dist/esm/components/_internal/base-button.js.map +3 -3
- package/dist/esm/components/checkbox-cards.js.map +1 -1
- package/dist/esm/components/icon-button.d.ts +12 -1
- package/dist/esm/components/icon-button.d.ts.map +1 -1
- package/dist/esm/components/icon-button.js +1 -1
- package/dist/esm/components/icon-button.js.map +2 -2
- package/dist/esm/components/radio-cards.js.map +1 -1
- package/dist/esm/components/toggle-icon-button.d.ts +21 -7
- package/dist/esm/components/toggle-icon-button.d.ts.map +1 -1
- package/dist/esm/components/toggle-icon-button.js +1 -1
- package/dist/esm/components/toggle-icon-button.js.map +2 -2
- package/package.json +1 -1
- package/src/components/_internal/base-button.css +118 -9
- package/src/components/_internal/base-button.tsx +26 -4
- package/src/components/checkbox-cards.tsx +4 -4
- package/src/components/icon-button.tsx +33 -5
- package/src/components/radio-cards.tsx +3 -3
- package/src/components/toggle-icon-button.tsx +36 -20
- package/src/styles/tokens/base.css +1 -0
- package/src/styles/tokens/shadow.css +4 -4
- package/src/styles/tokens/transition.css +43 -0
- package/styles.css +133 -13
- package/tokens/base.css +33 -4
- package/tokens.css +33 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/checkbox-cards.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client';\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport { Context } from 'radix-ui/internal';\n\nimport * as CheckboxGroupPrimitive from './checkbox-group.primitive.js';\nimport { createCheckboxGroupScope } from './checkbox-group.primitive.js';\nimport { checkboxCardsRootPropDefs } from './checkbox-cards.props.js';\nimport { baseCheckboxPropDefs } from './_internal/base-checkbox.props.js';\nimport { Grid } from './grid.js';\nimport { ThickCheckIcon } from './icons.js';\nimport { extractProps } from '../helpers/extract-props.js';\nimport { marginPropDefs } from '../props/margin.props.js';\n\nimport type { ComponentPropsWithout, RemovedProps } from '../helpers/component-props.js';\nimport type { MarginProps } from '../props/margin.props.js';\nimport type { Responsive, GetPropDefTypes } from '../props/prop-def.js';\n\nconst CHECKBOX_CARD_GROUP_NAME = 'CheckboxCards';\n\ntype ScopedProps<P> = P & { __scopeCheckboxCards?: Context.Scope };\nconst [createCheckboxCardsContext] = Context.createContextScope(CHECKBOX_CARD_GROUP_NAME, [\n createCheckboxGroupScope,\n]);\nconst useCheckboxGroupScope = createCheckboxGroupScope();\n\ntype CheckboxCardsContextValue = {\n size?: Responsive<(typeof checkboxCardsRootPropDefs.size.values)[number]>;\n highContrast?: boolean;\n};\n\nconst [CheckboxCardsProvider, useCheckboxCardsContext] =\n createCheckboxCardsContext<CheckboxCardsContextValue>(CHECKBOX_CARD_GROUP_NAME);\n\ntype CheckboxCardsRootElement = React.ElementRef<typeof CheckboxGroupPrimitive.Root>;\ntype CheckboxCardsRootOwnProps = GetPropDefTypes<typeof checkboxCardsRootPropDefs>;\ninterface CheckboxCardsRootProps\n extends ComponentPropsWithout<\n typeof CheckboxGroupPrimitive.Root,\n 'asChild' | 'color' | 'defaultChecked'\n >,\n MarginProps,\n CheckboxCardsRootOwnProps {}\nconst CheckboxCardsRoot = React.forwardRef<CheckboxCardsRootElement, CheckboxCardsRootProps>(\n (props: ScopedProps<CheckboxCardsRootProps>, forwardedRef) => {\n const { __scopeCheckboxCards, className, color, ...rootProps } = extractProps(\n props,\n checkboxCardsRootPropDefs,\n marginPropDefs
|
|
4
|
+
"sourcesContent": ["'use client';\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport { Context } from 'radix-ui/internal';\n\nimport * as CheckboxGroupPrimitive from './checkbox-group.primitive.js';\nimport { createCheckboxGroupScope } from './checkbox-group.primitive.js';\nimport { checkboxCardsRootPropDefs } from './checkbox-cards.props.js';\nimport { baseCheckboxPropDefs } from './_internal/base-checkbox.props.js';\nimport { Grid } from './grid.js';\nimport { ThickCheckIcon } from './icons.js';\nimport { extractProps } from '../helpers/extract-props.js';\nimport { marginPropDefs } from '../props/margin.props.js';\n\nimport type { ComponentPropsWithout, RemovedProps } from '../helpers/component-props.js';\nimport type { MarginProps } from '../props/margin.props.js';\nimport type { Responsive, GetPropDefTypes } from '../props/prop-def.js';\n\nconst CHECKBOX_CARD_GROUP_NAME = 'CheckboxCards';\n\ntype ScopedProps<P> = P & { __scopeCheckboxCards?: Context.Scope };\nconst [createCheckboxCardsContext] = Context.createContextScope(CHECKBOX_CARD_GROUP_NAME, [\n createCheckboxGroupScope,\n]);\nconst useCheckboxGroupScope = createCheckboxGroupScope();\n\ntype CheckboxCardsContextValue = {\n size?: Responsive<(typeof checkboxCardsRootPropDefs.size.values)[number]>;\n highContrast?: boolean;\n};\n\nconst [CheckboxCardsProvider, useCheckboxCardsContext] =\n createCheckboxCardsContext<CheckboxCardsContextValue>(CHECKBOX_CARD_GROUP_NAME);\n\ntype CheckboxCardsRootElement = React.ElementRef<typeof CheckboxGroupPrimitive.Root>;\ntype CheckboxCardsRootOwnProps = GetPropDefTypes<typeof checkboxCardsRootPropDefs>;\ninterface CheckboxCardsRootProps\n extends ComponentPropsWithout<\n typeof CheckboxGroupPrimitive.Root,\n 'asChild' | 'color' | 'defaultChecked'\n >,\n MarginProps,\n CheckboxCardsRootOwnProps {}\nconst CheckboxCardsRoot = React.forwardRef<CheckboxCardsRootElement, CheckboxCardsRootProps>(\n (props: ScopedProps<CheckboxCardsRootProps>, forwardedRef) => {\n const { __scopeCheckboxCards, className, color, ...rootProps } = extractProps(\n props,\n checkboxCardsRootPropDefs,\n marginPropDefs,\n );\n const checkboxGroupScope = useCheckboxGroupScope(__scopeCheckboxCards);\n return (\n <CheckboxCardsProvider\n scope={__scopeCheckboxCards}\n size={props.size}\n highContrast={props.highContrast}\n >\n <Grid asChild>\n <CheckboxGroupPrimitive.Root\n {...checkboxGroupScope}\n data-accent-color={color}\n {...rootProps}\n ref={forwardedRef}\n className={classNames('rt-CheckboxCardsRoot', className)}\n />\n </Grid>\n </CheckboxCardsProvider>\n );\n },\n);\nCheckboxCardsRoot.displayName = 'CheckboxCards.Root';\n\ntype CheckboxCardsItemElement = React.ElementRef<typeof CheckboxGroupPrimitive.Item>;\ninterface CheckboxCardsItemProps\n extends ComponentPropsWithout<typeof CheckboxGroupPrimitive.Item, RemovedProps>,\n MarginProps {}\nconst CheckboxCardsItem = React.forwardRef<\n CheckboxCardsItemElement,\n ScopedProps<CheckboxCardsItemProps>\n>(({ __scopeCheckboxCards, children, className, style, ...props }, forwardedRef) => {\n const context = useCheckboxCardsContext('CheckboxCardsItem', __scopeCheckboxCards);\n const checkboxGroupScope = useCheckboxGroupScope(__scopeCheckboxCards);\n const { className: checkboxClassName } = extractProps(\n // Pass size / highContrast values from the context and static variant to generate styles\n { size: context?.size, variant: 'surface', highContrast: context?.highContrast },\n // Pass size & variant prop defs to allow it to be extracted\n baseCheckboxPropDefs,\n );\n return (\n <label className={classNames('rt-BaseCard', 'rt-CheckboxCardsItem', className)} style={style}>\n {children}\n <CheckboxGroupPrimitive.Item\n {...checkboxGroupScope}\n {...props}\n ref={forwardedRef}\n className={classNames(\n 'rt-reset',\n 'rt-BaseCheckboxRoot',\n 'rt-CheckboxCardCheckbox',\n checkboxClassName,\n )}\n >\n <CheckboxGroupPrimitive.Indicator\n {...checkboxGroupScope}\n asChild\n className=\"rt-BaseCheckboxIndicator\"\n >\n <ThickCheckIcon />\n </CheckboxGroupPrimitive.Indicator>\n </CheckboxGroupPrimitive.Item>\n </label>\n );\n});\nCheckboxCardsItem.displayName = 'CheckboxCards.Item';\n\nexport { CheckboxCardsRoot as Root, CheckboxCardsItem as Item };\nexport type { CheckboxCardsRootProps as RootProps, CheckboxCardsItemProps as ItemProps };\n"],
|
|
5
5
|
"mappings": "aAEA,UAAYA,MAAW,QACvB,OAAOC,MAAgB,aACvB,OAAS,WAAAC,MAAe,oBAExB,UAAYC,MAA4B,gCACxC,OAAS,4BAAAC,MAAgC,gCACzC,OAAS,6BAAAC,MAAiC,4BAC1C,OAAS,wBAAAC,MAA4B,qCACrC,OAAS,QAAAC,MAAY,YACrB,OAAS,kBAAAC,MAAsB,aAC/B,OAAS,gBAAAC,MAAoB,8BAC7B,OAAS,kBAAAC,MAAsB,2BAM/B,MAAMC,EAA2B,gBAG3B,CAACC,CAA0B,EAAIV,EAAQ,mBAAmBS,EAA0B,CACxFP,CACF,CAAC,EACKS,EAAwBT,EAAyB,EAOjD,CAACU,EAAuBC,CAAuB,EACnDH,EAAsDD,CAAwB,EAW1EK,EAAoBhB,EAAM,WAC9B,CAACiB,EAA4CC,IAAiB,CAC5D,KAAM,CAAE,qBAAAC,EAAsB,UAAAC,EAAW,MAAAC,EAAO,GAAGC,CAAU,EAAIb,EAC/DQ,EACAZ,EACAK,CACF,EACMa,EAAqBV,EAAsBM,CAAoB,EACrE,OACEnB,EAAA,cAACc,EAAA,CACC,MAAOK,EACP,KAAMF,EAAM,KACZ,aAAcA,EAAM,cAEpBjB,EAAA,cAACO,EAAA,CAAK,QAAO,IACXP,EAAA,cAACG,EAAuB,KAAvB,CACE,GAAGoB,EACJ,oBAAmBF,EAClB,GAAGC,EACJ,IAAKJ,EACL,UAAWjB,EAAW,uBAAwBmB,CAAS,EACzD,CACF,CACF,CAEJ,CACF,EACAJ,EAAkB,YAAc,qBAMhC,MAAMQ,EAAoBxB,EAAM,WAG9B,CAAC,CAAE,qBAAAmB,EAAsB,SAAAM,EAAU,UAAAL,EAAW,MAAAM,EAAO,GAAGT,CAAM,EAAGC,IAAiB,CAClF,MAAMS,EAAUZ,EAAwB,oBAAqBI,CAAoB,EAC3EI,EAAqBV,EAAsBM,CAAoB,EAC/D,CAAE,UAAWS,CAAkB,EAAInB,EAEvC,CAAE,KAAMkB,GAAS,KAAM,QAAS,UAAW,aAAcA,GAAS,YAAa,EAE/ErB,CACF,EACA,OACEN,EAAA,cAAC,SAAM,UAAWC,EAAW,cAAe,uBAAwBmB,CAAS,EAAG,MAAOM,GACpFD,EACDzB,EAAA,cAACG,EAAuB,KAAvB,CACE,GAAGoB,EACH,GAAGN,EACJ,IAAKC,EACL,UAAWjB,EACT,WACA,sBACA,0BACA2B,CACF,GAEA5B,EAAA,cAACG,EAAuB,UAAvB,CACE,GAAGoB,EACJ,QAAO,GACP,UAAU,4BAEVvB,EAAA,cAACQ,EAAA,IAAe,CAClB,CACF,CACF,CAEJ,CAAC,EACDgB,EAAkB,YAAc",
|
|
6
6
|
"names": ["React", "classNames", "Context", "CheckboxGroupPrimitive", "createCheckboxGroupScope", "checkboxCardsRootPropDefs", "baseCheckboxPropDefs", "Grid", "ThickCheckIcon", "extractProps", "marginPropDefs", "CHECKBOX_CARD_GROUP_NAME", "createCheckboxCardsContext", "useCheckboxGroupScope", "CheckboxCardsProvider", "useCheckboxCardsContext", "CheckboxCardsRoot", "props", "forwardedRef", "__scopeCheckboxCards", "className", "color", "rootProps", "checkboxGroupScope", "CheckboxCardsItem", "children", "style", "context", "checkboxClassName"]
|
|
7
7
|
}
|
|
@@ -2,7 +2,18 @@ import * as React from 'react';
|
|
|
2
2
|
import { BaseButton } from './_internal/base-button.js';
|
|
3
3
|
import type { BaseButtonProps } from './_internal/base-button.js';
|
|
4
4
|
type IconButtonElement = React.ElementRef<typeof BaseButton>;
|
|
5
|
-
type
|
|
5
|
+
type AccessibilityProps = {
|
|
6
|
+
'aria-label': string;
|
|
7
|
+
'aria-labelledby'?: never;
|
|
8
|
+
} | {
|
|
9
|
+
'aria-label'?: never;
|
|
10
|
+
'aria-labelledby': string;
|
|
11
|
+
} | {
|
|
12
|
+
'aria-label'?: never;
|
|
13
|
+
'aria-labelledby'?: never;
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
};
|
|
16
|
+
type IconButtonOwnProps = Omit<BaseButtonProps, 'as'> & AccessibilityProps;
|
|
6
17
|
type IconButtonProps<C extends React.ElementType = 'button'> = IconButtonOwnProps & {
|
|
7
18
|
as?: C;
|
|
8
19
|
} & Omit<React.ComponentPropsWithoutRef<C>, keyof IconButtonOwnProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-button.d.ts","sourceRoot":"","sources":["../../../src/components/icon-button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE,KAAK,iBAAiB,GAAG,KAAK,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAG7D,KAAK,kBAAkB,GAAG,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"icon-button.d.ts","sourceRoot":"","sources":["../../../src/components/icon-button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE,KAAK,iBAAiB,GAAG,KAAK,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAG7D,KAAK,kBAAkB,GACnB;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,KAAK,CAAA;CAAE,GACnD;IAAE,YAAY,CAAC,EAAE,KAAK,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,GACnD;IAAE,YAAY,CAAC,EAAE,KAAK,CAAC;IAAC,iBAAiB,CAAC,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAAC;AAGnF,KAAK,kBAAkB,GAAG,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,GAAG,kBAAkB,CAAC;AAE3E,KAAK,eAAe,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,QAAQ,IAAI,kBAAkB,GAAG;IAClF,EAAE,CAAC,EAAE,CAAC,CAAC;CACR,GAAG,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,MAAM,kBAAkB,CAAC,CAAC;AAEtE,KAAK,mBAAmB,GAAG,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,QAAQ,EAChE,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAA;CAAE,KACxE,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;AAE/B,QAAA,MAAM,UAAU,EA6BX,mBAAmB,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAIpD,OAAO,EAAE,UAAU,EAAE,CAAC;AACtB,YAAY,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as e from"react";import r from"classnames";import{BaseButton as l}from"./_internal/base-button.js";const t=e.forwardRef(({className:n,...o},a)=>e.createElement(l,{...o,ref:a,className:r("rt-IconButton",n)}));t.displayName="IconButton";export{t as IconButton};
|
|
2
2
|
//# sourceMappingURL=icon-button.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/icon-button.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nimport classNames from 'classnames';\n\nimport { BaseButton } from './_internal/base-button.js';\nimport type { BaseButtonProps } from './_internal/base-button.js';\n\ntype IconButtonElement = React.ElementRef<typeof BaseButton>;\n\n// Polymorphic IconButton props\ntype IconButtonOwnProps = Omit<BaseButtonProps, 'as'
|
|
5
|
-
"mappings": "AAAA,UAAYA,MAAW,QACvB,OAAOC,MAAgB,aAEvB,OAAS,cAAAC,MAAkB,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport classNames from 'classnames';\n\nimport { BaseButton } from './_internal/base-button.js';\nimport type { BaseButtonProps } from './_internal/base-button.js';\n\ntype IconButtonElement = React.ElementRef<typeof BaseButton>;\n\n// Required accessibility props for icon buttons\ntype AccessibilityProps =\n | { 'aria-label': string; 'aria-labelledby'?: never }\n | { 'aria-label'?: never; 'aria-labelledby': string }\n | { 'aria-label'?: never; 'aria-labelledby'?: never; children: React.ReactNode };\n\n// Polymorphic IconButton props with required accessibility\ntype IconButtonOwnProps = Omit<BaseButtonProps, 'as'> & AccessibilityProps;\n\ntype IconButtonProps<C extends React.ElementType = 'button'> = IconButtonOwnProps & {\n as?: C;\n} & Omit<React.ComponentPropsWithoutRef<C>, keyof IconButtonOwnProps>;\n\ntype IconButtonComponent = <C extends React.ElementType = 'button'>(\n props: IconButtonProps<C> & { ref?: React.ForwardedRef<IconButtonElement> },\n) => React.ReactElement | null;\n\nconst IconButton = React.forwardRef(\n (\n { className, ...props }: IconButtonProps,\n forwardedRef: React.ForwardedRef<IconButtonElement>,\n ) => {\n // Warn in development if no accessibility attributes are provided\n if (process.env.NODE_ENV === 'development') {\n const hasAriaLabel = 'aria-label' in props && props['aria-label'];\n const hasAriaLabelledBy = 'aria-labelledby' in props && props['aria-labelledby'];\n const hasChildren = 'children' in props && props.children;\n\n if (!hasAriaLabel && !hasAriaLabelledBy && !hasChildren) {\n console.warn(\n 'IconButton: Icon buttons must have an accessible name. Please provide either:' +\n '\\n- aria-label prop with descriptive text' +\n '\\n- aria-labelledby prop referencing a label element' +\n '\\n- or visible text children',\n );\n }\n }\n\n return (\n <BaseButton\n {...props}\n ref={forwardedRef}\n className={classNames('rt-IconButton', className)}\n />\n );\n },\n) as IconButtonComponent & { displayName?: string };\n\nIconButton.displayName = 'IconButton';\n\nexport { IconButton };\nexport type { IconButtonProps };\n"],
|
|
5
|
+
"mappings": "AAAA,UAAYA,MAAW,QACvB,OAAOC,MAAgB,aAEvB,OAAS,cAAAC,MAAkB,6BAsB3B,MAAMC,EAAaH,EAAM,WACvB,CACE,CAAE,UAAAI,EAAW,GAAGC,CAAM,EACtBC,IAmBEN,EAAA,cAACE,EAAA,CACE,GAAGG,EACJ,IAAKC,EACL,UAAWL,EAAW,gBAAiBG,CAAS,EAClD,CAGN,EAEAD,EAAW,YAAc",
|
|
6
6
|
"names": ["React", "classNames", "BaseButton", "IconButton", "className", "props", "forwardedRef"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/radio-cards.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nimport classNames from 'classnames';\nimport { RadioGroup as RadioGroupPrimitive } from 'radix-ui';\n\nimport { radioCardsRootPropDefs } from './radio-cards.props.js';\nimport { Grid } from './grid.js';\nimport { extractProps } from '../helpers/extract-props.js';\nimport { marginPropDefs } from '../props/margin.props.js';\n\nimport type { MarginProps } from '../props/margin.props.js';\nimport type { ComponentPropsWithout, RemovedProps } from '../helpers/component-props.js';\nimport type { GetPropDefTypes } from '../props/prop-def.js';\n\ntype RadioCardsRootElement = React.ElementRef<typeof RadioGroupPrimitive.Root>;\ntype RadioCardsRootOwnProps = GetPropDefTypes<typeof radioCardsRootPropDefs>;\ninterface RadioCardsRootProps\n extends ComponentPropsWithout<\n typeof RadioGroupPrimitive.Root,\n 'asChild' | 'color' | 'defaultChecked'\n >,\n MarginProps,\n RadioCardsRootOwnProps {}\nconst RadioCardsRoot = React.forwardRef<RadioCardsRootElement, RadioCardsRootProps>(\n (props, forwardedRef) => {\n const { className, color, ...rootProps } = extractProps(\n props,\n radioCardsRootPropDefs,\n marginPropDefs
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport classNames from 'classnames';\nimport { RadioGroup as RadioGroupPrimitive } from 'radix-ui';\n\nimport { radioCardsRootPropDefs } from './radio-cards.props.js';\nimport { Grid } from './grid.js';\nimport { extractProps } from '../helpers/extract-props.js';\nimport { marginPropDefs } from '../props/margin.props.js';\n\nimport type { MarginProps } from '../props/margin.props.js';\nimport type { ComponentPropsWithout, RemovedProps } from '../helpers/component-props.js';\nimport type { GetPropDefTypes } from '../props/prop-def.js';\n\ntype RadioCardsRootElement = React.ElementRef<typeof RadioGroupPrimitive.Root>;\ntype RadioCardsRootOwnProps = GetPropDefTypes<typeof radioCardsRootPropDefs>;\ninterface RadioCardsRootProps\n extends ComponentPropsWithout<\n typeof RadioGroupPrimitive.Root,\n 'asChild' | 'color' | 'defaultChecked'\n >,\n MarginProps,\n RadioCardsRootOwnProps {}\nconst RadioCardsRoot = React.forwardRef<RadioCardsRootElement, RadioCardsRootProps>(\n (props, forwardedRef) => {\n const { className, color, ...rootProps } = extractProps(\n props,\n radioCardsRootPropDefs,\n marginPropDefs,\n );\n return (\n <Grid asChild>\n <RadioGroupPrimitive.Root\n data-accent-color={color}\n {...rootProps}\n ref={forwardedRef}\n className={classNames('rt-RadioCardsRoot', className)}\n />\n </Grid>\n );\n },\n);\nRadioCardsRoot.displayName = 'RadioCards.Root';\n\ntype RadioCardsItemElement = React.ElementRef<typeof RadioGroupPrimitive.Item>;\ninterface RadioCardsItemProps\n extends ComponentPropsWithout<typeof RadioGroupPrimitive.Item, RemovedProps>,\n MarginProps {}\nconst RadioCardsItem = React.forwardRef<RadioCardsItemElement, RadioCardsItemProps>(\n ({ className, ...props }, forwardedRef) => (\n <RadioGroupPrimitive.Item\n {...props}\n asChild={false}\n ref={forwardedRef}\n className={classNames('rt-reset', 'rt-BaseCard', 'rt-RadioCardsItem', className)}\n />\n ),\n);\nRadioCardsItem.displayName = 'RadioCards.Item';\n\nexport { RadioCardsRoot as Root, RadioCardsItem as Item };\nexport type { RadioCardsRootProps as RootProps, RadioCardsItemProps as ItemProps };\n"],
|
|
5
5
|
"mappings": "AAAA,UAAYA,MAAW,QACvB,OAAOC,MAAgB,aACvB,OAAS,cAAcC,MAA2B,WAElD,OAAS,0BAAAC,MAA8B,yBACvC,OAAS,QAAAC,MAAY,YACrB,OAAS,gBAAAC,MAAoB,8BAC7B,OAAS,kBAAAC,MAAsB,2BAe/B,MAAMC,EAAiBP,EAAM,WAC3B,CAACQ,EAAOC,IAAiB,CACvB,KAAM,CAAE,UAAAC,EAAW,MAAAC,EAAO,GAAGC,CAAU,EAAIP,EACzCG,EACAL,EACAG,CACF,EACA,OACEN,EAAA,cAACI,EAAA,CAAK,QAAO,IACXJ,EAAA,cAACE,EAAoB,KAApB,CACC,oBAAmBS,EAClB,GAAGC,EACJ,IAAKH,EACL,UAAWR,EAAW,oBAAqBS,CAAS,EACtD,CACF,CAEJ,CACF,EACAH,EAAe,YAAc,kBAM7B,MAAMM,EAAiBb,EAAM,WAC3B,CAAC,CAAE,UAAAU,EAAW,GAAGF,CAAM,EAAGC,IACxBT,EAAA,cAACE,EAAoB,KAApB,CACE,GAAGM,EACJ,QAAS,GACT,IAAKC,EACL,UAAWR,EAAW,WAAY,cAAe,oBAAqBS,CAAS,EACjF,CAEJ,EACAG,EAAe,YAAc",
|
|
6
6
|
"names": ["React", "classNames", "RadioGroupPrimitive", "radioCardsRootPropDefs", "Grid", "extractProps", "marginPropDefs", "RadioCardsRoot", "props", "forwardedRef", "className", "color", "rootProps", "RadioCardsItem"]
|
|
7
7
|
}
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { Toggle } from 'radix-ui';
|
|
3
|
+
import type { BaseButtonProps } from './_internal/base-button.js';
|
|
4
|
+
type ToggleProps = React.ComponentPropsWithoutRef<typeof Toggle.Root>;
|
|
5
|
+
type AccessibilityProps = {
|
|
6
|
+
'aria-label': string;
|
|
7
|
+
'aria-labelledby'?: never;
|
|
8
|
+
} | {
|
|
9
|
+
'aria-label'?: never;
|
|
10
|
+
'aria-labelledby': string;
|
|
11
|
+
} | {
|
|
12
|
+
'aria-label'?: never;
|
|
13
|
+
'aria-labelledby'?: never;
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
};
|
|
16
|
+
interface ToggleIconButtonProps extends Omit<BaseButtonProps, 'as'> {
|
|
17
|
+
pressed?: ToggleProps['pressed'];
|
|
18
|
+
onPressedChange?: ToggleProps['onPressedChange'];
|
|
19
|
+
defaultPressed?: ToggleProps['defaultPressed'];
|
|
7
20
|
}
|
|
8
|
-
|
|
21
|
+
type ToggleIconButtonPropsWithAccessibility = ToggleIconButtonProps & AccessibilityProps;
|
|
22
|
+
declare const ToggleIconButton: React.ForwardRefExoticComponent<ToggleIconButtonPropsWithAccessibility & React.RefAttributes<HTMLButtonElement>>;
|
|
9
23
|
export { ToggleIconButton };
|
|
10
|
-
export type { ToggleIconButtonProps };
|
|
24
|
+
export type { ToggleIconButtonPropsWithAccessibility as ToggleIconButtonProps };
|
|
11
25
|
//# sourceMappingURL=toggle-icon-button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-icon-button.d.ts","sourceRoot":"","sources":["../../../src/components/toggle-icon-button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"toggle-icon-button.d.ts","sourceRoot":"","sources":["../../../src/components/toggle-icon-button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAKlE,KAAK,WAAW,GAAG,KAAK,CAAC,wBAAwB,CAAC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;AAGtE,KAAK,kBAAkB,GACnB;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,KAAK,CAAA;CAAE,GACnD;IAAE,YAAY,CAAC,EAAE,KAAK,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,GACnD;IAAE,YAAY,CAAC,EAAE,KAAK,CAAC;IAAC,iBAAiB,CAAC,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAAC;AAGnF,UAAU,qBAAsB,SAAQ,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC;IACjE,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACjC,eAAe,CAAC,EAAE,WAAW,CAAC,iBAAiB,CAAC,CAAC;IACjD,cAAc,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,CAAC;CAChD;AAGD,KAAK,sCAAsC,GAAG,qBAAqB,GAAG,kBAAkB,CAAC;AAEzF,QAAA,MAAM,gBAAgB,kHAcpB,CAAC;AAGH,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,YAAY,EAAE,sCAAsC,IAAI,qBAAqB,EAAE,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as e from"react";import{Toggle as a}from"radix-ui";import{IconButton as g}from"./icon-button.js";import"./_internal/base-button.js";const o=e.forwardRef(({pressed:t,onPressedChange:s,defaultPressed:r,...n},l)=>e.createElement(a.Root,{pressed:t,onPressedChange:s,defaultPressed:r,asChild:!0},e.createElement(g,{...n,ref:l})));o.displayName="ToggleIconButton";export{o as ToggleIconButton};
|
|
2
2
|
//# sourceMappingURL=toggle-icon-button.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/toggle-icon-button.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nimport { Toggle } from 'radix-ui';\nimport { IconButton } from './icon-button.js';\n\
|
|
5
|
-
"mappings": "AAAA,UAAYA,MAAW,QACvB,OAAS,UAAAC,MAAc,WACvB,OAAS,cAAAC,MAAkB,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport { Toggle } from 'radix-ui';\nimport { IconButton } from './icon-button.js';\nimport { BaseButton } from './_internal/base-button.js';\nimport type { BaseButtonProps } from './_internal/base-button.js';\n\ntype ToggleIconButtonElement = React.ElementRef<typeof BaseButton>;\n\n// Extract toggle-specific props from Radix Toggle\ntype ToggleProps = React.ComponentPropsWithoutRef<typeof Toggle.Root>;\n\n// Required accessibility props for icon buttons (same as IconButton)\ntype AccessibilityProps =\n | { 'aria-label': string; 'aria-labelledby'?: never }\n | { 'aria-label'?: never; 'aria-labelledby': string }\n | { 'aria-label'?: never; 'aria-labelledby'?: never; children: React.ReactNode };\n\n// Combine BaseButton props with Toggle-specific props and accessibility requirements\ninterface ToggleIconButtonProps extends Omit<BaseButtonProps, 'as'> {\n pressed?: ToggleProps['pressed'];\n onPressedChange?: ToggleProps['onPressedChange'];\n defaultPressed?: ToggleProps['defaultPressed'];\n}\n\n// Intersection with accessibility props\ntype ToggleIconButtonPropsWithAccessibility = ToggleIconButtonProps & AccessibilityProps;\n\nconst ToggleIconButton = React.forwardRef<\n ToggleIconButtonElement,\n ToggleIconButtonPropsWithAccessibility\n>(({ pressed, onPressedChange, defaultPressed, ...iconButtonProps }, forwardedRef) => {\n return (\n <Toggle.Root\n pressed={pressed}\n onPressedChange={onPressedChange}\n defaultPressed={defaultPressed}\n asChild\n >\n <IconButton {...iconButtonProps} ref={forwardedRef} />\n </Toggle.Root>\n );\n});\nToggleIconButton.displayName = 'ToggleIconButton';\n\nexport { ToggleIconButton };\nexport type { ToggleIconButtonPropsWithAccessibility as ToggleIconButtonProps };\n"],
|
|
5
|
+
"mappings": "AAAA,UAAYA,MAAW,QACvB,OAAS,UAAAC,MAAc,WACvB,OAAS,cAAAC,MAAkB,mBAC3B,MAA2B,6BAwB3B,MAAMC,EAAmBH,EAAM,WAG7B,CAAC,CAAE,QAAAI,EAAS,gBAAAC,EAAiB,eAAAC,EAAgB,GAAGC,CAAgB,EAAGC,IAEjER,EAAA,cAACC,EAAO,KAAP,CACC,QAASG,EACT,gBAAiBC,EACjB,eAAgBC,EAChB,QAAO,IAEPN,EAAA,cAACE,EAAA,CAAY,GAAGK,EAAiB,IAAKC,EAAc,CACtD,CAEH,EACDL,EAAiB,YAAc",
|
|
6
6
|
"names": ["React", "Toggle", "IconButton", "ToggleIconButton", "pressed", "onPressedChange", "defaultPressed", "iconButtonProps", "forwardedRef"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
.rt-BaseButton {
|
|
2
|
+
all: unset;
|
|
3
|
+
box-sizing: border-box;
|
|
2
4
|
display: inline-flex;
|
|
3
5
|
align-items: center;
|
|
4
6
|
justify-content: center;
|
|
5
7
|
flex-shrink: 0;
|
|
6
8
|
user-select: none;
|
|
7
|
-
|
|
9
|
+
position: relative;
|
|
10
|
+
cursor: default;
|
|
11
|
+
gap: var(--base-button-gap);
|
|
12
|
+
transition: var(--transition-button);
|
|
8
13
|
|
|
9
14
|
font-family: var(--default-font-family);
|
|
10
15
|
font-style: normal;
|
|
@@ -12,10 +17,28 @@
|
|
|
12
17
|
|
|
13
18
|
&:where([data-disabled]) {
|
|
14
19
|
--spinner-opacity: 1;
|
|
20
|
+
/* Disabled cursor and interaction prevention */
|
|
21
|
+
cursor: not-allowed;
|
|
22
|
+
pointer-events: none;
|
|
15
23
|
}
|
|
16
24
|
|
|
17
25
|
&:where(.rt-loading) {
|
|
18
26
|
position: relative;
|
|
27
|
+
cursor: wait;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* Scale animation on press for all button variants */
|
|
31
|
+
&:where(:active:not([data-disabled], [data-state='open'])) {
|
|
32
|
+
transform: scale(0.98);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* Reduced motion support for transforms */
|
|
36
|
+
@media (prefers-reduced-motion: reduce) {
|
|
37
|
+
transition: none;
|
|
38
|
+
|
|
39
|
+
&:where(:active:not([data-disabled], [data-state='open'])) {
|
|
40
|
+
transform: none;
|
|
41
|
+
}
|
|
19
42
|
}
|
|
20
43
|
|
|
21
44
|
height: var(--base-button-height);
|
|
@@ -71,6 +94,8 @@
|
|
|
71
94
|
--base-button-classic-hover-shadow: var(--shadow-3);
|
|
72
95
|
--base-button-classic-active-shadow: var(--shadow-2);
|
|
73
96
|
--base-button-classic-disabled-shadow: none;
|
|
97
|
+
--base-button-classic-hover-filter: brightness(1.08) saturate(1.02) contrast(1.02);
|
|
98
|
+
--base-button-classic-active-filter: brightness(0.88) saturate(1.05) contrast(1.1);
|
|
74
99
|
}
|
|
75
100
|
/* prettier-ignore */
|
|
76
101
|
:is(.dark, .dark-theme),
|
|
@@ -79,6 +104,8 @@
|
|
|
79
104
|
--base-button-classic-hover-shadow: var(--shadow-3);
|
|
80
105
|
--base-button-classic-active-shadow: var(--shadow-2);
|
|
81
106
|
--base-button-classic-disabled-shadow: none;
|
|
107
|
+
--base-button-classic-hover-filter: brightness(1.12) saturate(1.05) contrast(1.02);
|
|
108
|
+
--base-button-classic-active-filter: brightness(0.92) saturate(1.1) contrast(1.05);
|
|
82
109
|
}
|
|
83
110
|
|
|
84
111
|
.rt-BaseButton:where(.rt-variant-classic) {
|
|
@@ -108,8 +135,9 @@
|
|
|
108
135
|
}
|
|
109
136
|
@media (hover: hover) {
|
|
110
137
|
&:where(:hover) {
|
|
111
|
-
background: linear-gradient(to bottom, var(--accent-
|
|
138
|
+
background: linear-gradient(to bottom, var(--accent-9), var(--accent-10));
|
|
112
139
|
box-shadow: var(--base-button-classic-hover-shadow);
|
|
140
|
+
filter: var(--base-button-classic-hover-filter);
|
|
113
141
|
&:where(.rt-high-contrast) {
|
|
114
142
|
background: linear-gradient(to bottom, var(--accent-11), var(--accent-12));
|
|
115
143
|
filter: contrast(0.88) saturate(1.1) brightness(1.1);
|
|
@@ -122,8 +150,9 @@
|
|
|
122
150
|
}
|
|
123
151
|
}
|
|
124
152
|
&:where([data-state='open']) {
|
|
125
|
-
background: linear-gradient(to bottom, var(--accent-
|
|
153
|
+
background: linear-gradient(to bottom, var(--accent-9), var(--accent-10));
|
|
126
154
|
box-shadow: var(--base-button-classic-hover-shadow);
|
|
155
|
+
filter: var(--base-button-classic-hover-filter);
|
|
127
156
|
&:where(.rt-high-contrast) {
|
|
128
157
|
background: linear-gradient(to bottom, var(--accent-11), var(--accent-12));
|
|
129
158
|
filter: contrast(0.88) saturate(1.1) brightness(1.1);
|
|
@@ -135,11 +164,12 @@
|
|
|
135
164
|
}
|
|
136
165
|
}
|
|
137
166
|
&:where(:active:not([data-state='open'], [data-disabled])) {
|
|
138
|
-
background: linear-gradient(to bottom, var(--accent-
|
|
167
|
+
background: linear-gradient(to bottom, var(--accent-9), var(--accent-10));
|
|
139
168
|
box-shadow: var(--base-button-classic-active-shadow);
|
|
169
|
+
filter: var(--base-button-classic-active-filter);
|
|
140
170
|
|
|
141
171
|
&:where(.rt-high-contrast) {
|
|
142
|
-
background: linear-gradient(to bottom, var(--accent-
|
|
172
|
+
background: linear-gradient(to bottom, var(--accent-11), var(--accent-12));
|
|
143
173
|
filter: contrast(0.82) saturate(1.2) brightness(1.16);
|
|
144
174
|
|
|
145
175
|
/* Use solid color for non-gray accent colors */
|
|
@@ -154,6 +184,8 @@
|
|
|
154
184
|
box-shadow: var(--base-button-classic-disabled-shadow);
|
|
155
185
|
outline: none;
|
|
156
186
|
filter: none;
|
|
187
|
+
cursor: not-allowed;
|
|
188
|
+
pointer-events: none;
|
|
157
189
|
}
|
|
158
190
|
}
|
|
159
191
|
|
|
@@ -222,6 +254,8 @@
|
|
|
222
254
|
background-color: var(--gray-a3);
|
|
223
255
|
outline: none;
|
|
224
256
|
filter: none;
|
|
257
|
+
cursor: not-allowed;
|
|
258
|
+
pointer-events: none;
|
|
225
259
|
}
|
|
226
260
|
}
|
|
227
261
|
|
|
@@ -236,6 +270,8 @@
|
|
|
236
270
|
&:where([data-disabled]) {
|
|
237
271
|
color: var(--gray-a8);
|
|
238
272
|
background-color: var(--gray-a3);
|
|
273
|
+
cursor: not-allowed;
|
|
274
|
+
pointer-events: none;
|
|
239
275
|
}
|
|
240
276
|
}
|
|
241
277
|
|
|
@@ -260,6 +296,8 @@
|
|
|
260
296
|
&:where([data-disabled]) {
|
|
261
297
|
color: var(--gray-a8);
|
|
262
298
|
background-color: var(--gray-a3);
|
|
299
|
+
cursor: not-allowed;
|
|
300
|
+
pointer-events: none;
|
|
263
301
|
}
|
|
264
302
|
}
|
|
265
303
|
|
|
@@ -282,6 +320,8 @@
|
|
|
282
320
|
&:where([data-disabled]) {
|
|
283
321
|
color: var(--gray-a8);
|
|
284
322
|
background-color: transparent;
|
|
323
|
+
cursor: not-allowed;
|
|
324
|
+
pointer-events: none;
|
|
285
325
|
}
|
|
286
326
|
}
|
|
287
327
|
|
|
@@ -316,6 +356,8 @@
|
|
|
316
356
|
color: var(--gray-a8);
|
|
317
357
|
box-shadow: inset 0 0 0 1px var(--gray-a7);
|
|
318
358
|
background-color: transparent;
|
|
359
|
+
cursor: not-allowed;
|
|
360
|
+
pointer-events: none;
|
|
319
361
|
}
|
|
320
362
|
}
|
|
321
363
|
|
|
@@ -349,6 +391,8 @@
|
|
|
349
391
|
color: var(--gray-a8);
|
|
350
392
|
box-shadow: inset 0 0 0 1px var(--gray-a6);
|
|
351
393
|
background-color: var(--gray-a2);
|
|
394
|
+
cursor: not-allowed;
|
|
395
|
+
pointer-events: none;
|
|
352
396
|
}
|
|
353
397
|
}
|
|
354
398
|
|
|
@@ -360,14 +404,23 @@
|
|
|
360
404
|
|
|
361
405
|
/* Toggle button pressed states for all variants */
|
|
362
406
|
.rt-BaseButton:where([data-state='on']) {
|
|
407
|
+
/* Add scale transform for pressed state - same as active */
|
|
408
|
+
transform: scale(0.98);
|
|
409
|
+
|
|
410
|
+
/* Reduced motion support */
|
|
411
|
+
@media (prefers-reduced-motion: reduce) {
|
|
412
|
+
transform: none;
|
|
413
|
+
}
|
|
414
|
+
|
|
363
415
|
/* Classic variant pressed */
|
|
364
416
|
&:where(.rt-variant-classic) {
|
|
365
|
-
background: linear-gradient(to bottom, var(--accent-
|
|
366
|
-
box-shadow: var(--base-button-classic-
|
|
417
|
+
background: linear-gradient(to bottom, var(--accent-9), var(--accent-10));
|
|
418
|
+
box-shadow: var(--base-button-classic-active-shadow);
|
|
419
|
+
filter: var(--base-button-classic-active-filter);
|
|
367
420
|
|
|
368
421
|
&:where(.rt-high-contrast) {
|
|
369
422
|
background: linear-gradient(to bottom, var(--accent-11), var(--accent-12));
|
|
370
|
-
filter: contrast(0.
|
|
423
|
+
filter: contrast(0.82) saturate(1.2) brightness(1.16);
|
|
371
424
|
|
|
372
425
|
&:where(:not([data-accent-color='gray'])) {
|
|
373
426
|
background: var(--accent-12);
|
|
@@ -378,10 +431,11 @@
|
|
|
378
431
|
/* Solid variant pressed */
|
|
379
432
|
&:where(.rt-variant-solid) {
|
|
380
433
|
background-color: var(--accent-10);
|
|
434
|
+
filter: var(--base-button-solid-active-filter);
|
|
381
435
|
|
|
382
436
|
&:where(.rt-high-contrast) {
|
|
383
437
|
background-color: var(--accent-12);
|
|
384
|
-
filter: var(--base-button-solid-high-contrast-
|
|
438
|
+
filter: var(--base-button-solid-high-contrast-active-filter);
|
|
385
439
|
}
|
|
386
440
|
}
|
|
387
441
|
|
|
@@ -406,3 +460,58 @@
|
|
|
406
460
|
box-shadow: inset 0 0 0 1px var(--accent-a8);
|
|
407
461
|
}
|
|
408
462
|
}
|
|
463
|
+
|
|
464
|
+
/* Disabled state for ALL toggle buttons (pressed and unpressed) */
|
|
465
|
+
.rt-BaseButton:where([disabled][aria-pressed]) {
|
|
466
|
+
/* Remove scale transform when disabled */
|
|
467
|
+
transform: none;
|
|
468
|
+
|
|
469
|
+
/* Apply consistent disabled styling across all variants */
|
|
470
|
+
color: var(--gray-a8);
|
|
471
|
+
background-color: var(--gray-a3);
|
|
472
|
+
background: var(--gray-a3);
|
|
473
|
+
box-shadow: none;
|
|
474
|
+
filter: none;
|
|
475
|
+
opacity: 0.6;
|
|
476
|
+
cursor: not-allowed;
|
|
477
|
+
pointer-events: none;
|
|
478
|
+
|
|
479
|
+
/* Override any pressed state styling with higher specificity */
|
|
480
|
+
&:where([data-state='on']) {
|
|
481
|
+
transform: none;
|
|
482
|
+
background: var(--gray-a3);
|
|
483
|
+
background-color: var(--gray-a3);
|
|
484
|
+
box-shadow: none;
|
|
485
|
+
filter: none;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/* Override variant-specific pressed states */
|
|
489
|
+
&:where(.rt-variant-classic) {
|
|
490
|
+
background: var(--gray-a3);
|
|
491
|
+
box-shadow: none;
|
|
492
|
+
filter: none;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
&:where(.rt-variant-solid) {
|
|
496
|
+
background-color: var(--gray-a3);
|
|
497
|
+
filter: none;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
&:where(.rt-variant-soft) {
|
|
501
|
+
background-color: var(--gray-a3);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
&:where(.rt-variant-ghost) {
|
|
505
|
+
background-color: var(--gray-a3);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
&:where(.rt-variant-outline) {
|
|
509
|
+
background-color: var(--gray-a3);
|
|
510
|
+
box-shadow: none;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
&:where(.rt-variant-surface) {
|
|
514
|
+
background-color: var(--gray-a3);
|
|
515
|
+
box-shadow: none;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
@@ -17,12 +17,12 @@ import type { GetPropDefTypes } from '../../props/prop-def.js';
|
|
|
17
17
|
type BaseButtonElement = React.ElementRef<'button'>;
|
|
18
18
|
type BaseButtonOwnProps = GetPropDefTypes<typeof baseButtonPropDefs>;
|
|
19
19
|
|
|
20
|
-
// Polymorphic types
|
|
20
|
+
// Polymorphic types using the proper ComponentPropsWithout pattern
|
|
21
21
|
type PolymorphicBaseButtonProps<C extends React.ElementType = 'button'> = {
|
|
22
22
|
as?: C;
|
|
23
23
|
} & BaseButtonOwnProps &
|
|
24
24
|
MarginProps &
|
|
25
|
-
|
|
25
|
+
ComponentPropsWithout<C, RemovedProps | keyof BaseButtonOwnProps | keyof MarginProps | 'as'>;
|
|
26
26
|
|
|
27
27
|
interface BaseButtonProps extends PolymorphicBaseButtonProps {}
|
|
28
28
|
|
|
@@ -46,6 +46,19 @@ const BaseButton = React.forwardRef<BaseButtonElement, BaseButtonProps>((props,
|
|
|
46
46
|
const shouldPassDisabled =
|
|
47
47
|
asChild || !as || ['button', 'input', 'textarea', 'select'].includes(as);
|
|
48
48
|
|
|
49
|
+
// Generate unique ID for loading announcements
|
|
50
|
+
const loadingId = React.useId();
|
|
51
|
+
const describedById = props.loading ? `${loadingId}-loading` : undefined;
|
|
52
|
+
|
|
53
|
+
// Enhanced accessibility props for loading state
|
|
54
|
+
const accessibilityProps = props.loading
|
|
55
|
+
? {
|
|
56
|
+
'aria-busy': true,
|
|
57
|
+
'aria-disabled': true,
|
|
58
|
+
'aria-describedby': describedById,
|
|
59
|
+
}
|
|
60
|
+
: {};
|
|
61
|
+
|
|
49
62
|
return (
|
|
50
63
|
<Comp
|
|
51
64
|
// The `data-disabled` attribute enables correct styles when doing `<Button asChild disabled>`
|
|
@@ -53,6 +66,7 @@ const BaseButton = React.forwardRef<BaseButtonElement, BaseButtonProps>((props,
|
|
|
53
66
|
data-accent-color={color}
|
|
54
67
|
data-radius={radius}
|
|
55
68
|
{...baseButtonProps}
|
|
69
|
+
{...accessibilityProps}
|
|
56
70
|
ref={forwardedRef}
|
|
57
71
|
className={classNames('rt-reset', 'rt-BaseButton', className)}
|
|
58
72
|
{...(shouldPassDisabled && { disabled })}
|
|
@@ -69,11 +83,19 @@ const BaseButton = React.forwardRef<BaseButtonElement, BaseButtonProps>((props,
|
|
|
69
83
|
<span style={{ display: 'contents', visibility: 'hidden' }} aria-hidden>
|
|
70
84
|
{children}
|
|
71
85
|
</span>
|
|
72
|
-
|
|
86
|
+
|
|
87
|
+
{/* Enhanced accessibility for loading state */}
|
|
88
|
+
<VisuallyHidden>
|
|
89
|
+
<span id={describedById}>Loading, please wait...</span>
|
|
90
|
+
{children}
|
|
91
|
+
</VisuallyHidden>
|
|
73
92
|
|
|
74
93
|
<Flex asChild align="center" justify="center" position="absolute" inset="0">
|
|
75
94
|
<span>
|
|
76
|
-
<Spinner
|
|
95
|
+
<Spinner
|
|
96
|
+
size={mapResponsiveProp(size, mapButtonSizeToSpinnerSize)}
|
|
97
|
+
aria-hidden="true"
|
|
98
|
+
/>
|
|
77
99
|
</span>
|
|
78
100
|
</Flex>
|
|
79
101
|
</>
|
|
@@ -47,7 +47,7 @@ const CheckboxCardsRoot = React.forwardRef<CheckboxCardsRootElement, CheckboxCar
|
|
|
47
47
|
const { __scopeCheckboxCards, className, color, ...rootProps } = extractProps(
|
|
48
48
|
props,
|
|
49
49
|
checkboxCardsRootPropDefs,
|
|
50
|
-
marginPropDefs
|
|
50
|
+
marginPropDefs,
|
|
51
51
|
);
|
|
52
52
|
const checkboxGroupScope = useCheckboxGroupScope(__scopeCheckboxCards);
|
|
53
53
|
return (
|
|
@@ -67,7 +67,7 @@ const CheckboxCardsRoot = React.forwardRef<CheckboxCardsRootElement, CheckboxCar
|
|
|
67
67
|
</Grid>
|
|
68
68
|
</CheckboxCardsProvider>
|
|
69
69
|
);
|
|
70
|
-
}
|
|
70
|
+
},
|
|
71
71
|
);
|
|
72
72
|
CheckboxCardsRoot.displayName = 'CheckboxCards.Root';
|
|
73
73
|
|
|
@@ -85,7 +85,7 @@ const CheckboxCardsItem = React.forwardRef<
|
|
|
85
85
|
// Pass size / highContrast values from the context and static variant to generate styles
|
|
86
86
|
{ size: context?.size, variant: 'surface', highContrast: context?.highContrast },
|
|
87
87
|
// Pass size & variant prop defs to allow it to be extracted
|
|
88
|
-
baseCheckboxPropDefs
|
|
88
|
+
baseCheckboxPropDefs,
|
|
89
89
|
);
|
|
90
90
|
return (
|
|
91
91
|
<label className={classNames('rt-BaseCard', 'rt-CheckboxCardsItem', className)} style={style}>
|
|
@@ -98,7 +98,7 @@ const CheckboxCardsItem = React.forwardRef<
|
|
|
98
98
|
'rt-reset',
|
|
99
99
|
'rt-BaseCheckboxRoot',
|
|
100
100
|
'rt-CheckboxCardCheckbox',
|
|
101
|
-
checkboxClassName
|
|
101
|
+
checkboxClassName,
|
|
102
102
|
)}
|
|
103
103
|
>
|
|
104
104
|
<CheckboxGroupPrimitive.Indicator
|
|
@@ -6,8 +6,14 @@ import type { BaseButtonProps } from './_internal/base-button.js';
|
|
|
6
6
|
|
|
7
7
|
type IconButtonElement = React.ElementRef<typeof BaseButton>;
|
|
8
8
|
|
|
9
|
-
//
|
|
10
|
-
type
|
|
9
|
+
// Required accessibility props for icon buttons
|
|
10
|
+
type AccessibilityProps =
|
|
11
|
+
| { 'aria-label': string; 'aria-labelledby'?: never }
|
|
12
|
+
| { 'aria-label'?: never; 'aria-labelledby': string }
|
|
13
|
+
| { 'aria-label'?: never; 'aria-labelledby'?: never; children: React.ReactNode };
|
|
14
|
+
|
|
15
|
+
// Polymorphic IconButton props with required accessibility
|
|
16
|
+
type IconButtonOwnProps = Omit<BaseButtonProps, 'as'> & AccessibilityProps;
|
|
11
17
|
|
|
12
18
|
type IconButtonProps<C extends React.ElementType = 'button'> = IconButtonOwnProps & {
|
|
13
19
|
as?: C;
|
|
@@ -21,9 +27,31 @@ const IconButton = React.forwardRef(
|
|
|
21
27
|
(
|
|
22
28
|
{ className, ...props }: IconButtonProps,
|
|
23
29
|
forwardedRef: React.ForwardedRef<IconButtonElement>,
|
|
24
|
-
) =>
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
) => {
|
|
31
|
+
// Warn in development if no accessibility attributes are provided
|
|
32
|
+
if (process.env.NODE_ENV === 'development') {
|
|
33
|
+
const hasAriaLabel = 'aria-label' in props && props['aria-label'];
|
|
34
|
+
const hasAriaLabelledBy = 'aria-labelledby' in props && props['aria-labelledby'];
|
|
35
|
+
const hasChildren = 'children' in props && props.children;
|
|
36
|
+
|
|
37
|
+
if (!hasAriaLabel && !hasAriaLabelledBy && !hasChildren) {
|
|
38
|
+
console.warn(
|
|
39
|
+
'IconButton: Icon buttons must have an accessible name. Please provide either:' +
|
|
40
|
+
'\n- aria-label prop with descriptive text' +
|
|
41
|
+
'\n- aria-labelledby prop referencing a label element' +
|
|
42
|
+
'\n- or visible text children',
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<BaseButton
|
|
49
|
+
{...props}
|
|
50
|
+
ref={forwardedRef}
|
|
51
|
+
className={classNames('rt-IconButton', className)}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
},
|
|
27
55
|
) as IconButtonComponent & { displayName?: string };
|
|
28
56
|
|
|
29
57
|
IconButton.displayName = 'IconButton';
|
|
@@ -25,7 +25,7 @@ const RadioCardsRoot = React.forwardRef<RadioCardsRootElement, RadioCardsRootPro
|
|
|
25
25
|
const { className, color, ...rootProps } = extractProps(
|
|
26
26
|
props,
|
|
27
27
|
radioCardsRootPropDefs,
|
|
28
|
-
marginPropDefs
|
|
28
|
+
marginPropDefs,
|
|
29
29
|
);
|
|
30
30
|
return (
|
|
31
31
|
<Grid asChild>
|
|
@@ -37,7 +37,7 @@ const RadioCardsRoot = React.forwardRef<RadioCardsRootElement, RadioCardsRootPro
|
|
|
37
37
|
/>
|
|
38
38
|
</Grid>
|
|
39
39
|
);
|
|
40
|
-
}
|
|
40
|
+
},
|
|
41
41
|
);
|
|
42
42
|
RadioCardsRoot.displayName = 'RadioCards.Root';
|
|
43
43
|
|
|
@@ -53,7 +53,7 @@ const RadioCardsItem = React.forwardRef<RadioCardsItemElement, RadioCardsItemPro
|
|
|
53
53
|
ref={forwardedRef}
|
|
54
54
|
className={classNames('rt-reset', 'rt-BaseCard', 'rt-RadioCardsItem', className)}
|
|
55
55
|
/>
|
|
56
|
-
)
|
|
56
|
+
),
|
|
57
57
|
);
|
|
58
58
|
RadioCardsItem.displayName = 'RadioCards.Item';
|
|
59
59
|
|