@cimpress-ui/react 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/components/checkbox/checkbox.d.ts +1 -1
- package/dist/commonjs/components/checkbox/checkbox.d.ts.map +1 -1
- package/dist/commonjs/components/checkbox/checkbox.js.map +1 -1
- package/dist/commonjs/components/date-picker/date-picker.d.ts +1 -1
- package/dist/commonjs/components/date-picker/date-picker.d.ts.map +1 -1
- package/dist/commonjs/components/date-picker/date-picker.js.map +1 -1
- package/dist/commonjs/components/file-picker/file-picker.d.ts.map +1 -1
- package/dist/commonjs/components/file-picker/file-picker.js +3 -3
- package/dist/commonjs/components/file-picker/file-picker.js.map +1 -1
- package/dist/commonjs/components/tabs/tabs.d.ts +1 -1
- package/dist/commonjs/components/tabs/tabs.d.ts.map +1 -1
- package/dist/commonjs/components/tabs/tabs.js +2 -4
- package/dist/commonjs/components/tabs/tabs.js.map +1 -1
- package/dist/commonjs/components/tag/tag-group.d.ts +1 -1
- package/dist/commonjs/components/tag/tag-group.d.ts.map +1 -1
- package/dist/commonjs/components/tag/tag-group.js.map +1 -1
- package/dist/commonjs/components/tag/tag.d.ts +1 -1
- package/dist/commonjs/components/tag/tag.d.ts.map +1 -1
- package/dist/commonjs/components/tag/tag.js.map +1 -1
- package/dist/commonjs/components/tag-field/tag-field.d.ts.map +1 -1
- package/dist/commonjs/components/tag-field/tag-field.js +6 -3
- package/dist/commonjs/components/tag-field/tag-field.js.map +1 -1
- package/dist/commonjs/components/text-inputs/text-field.d.ts.map +1 -1
- package/dist/commonjs/components/text-inputs/text-field.js +1 -1
- package/dist/commonjs/components/text-inputs/text-field.js.map +1 -1
- package/dist/commonjs/components/toggle/toggle.d.ts +1 -1
- package/dist/commonjs/components/toggle/toggle.d.ts.map +1 -1
- package/dist/commonjs/components/toggle/toggle.js.map +1 -1
- package/dist/commonjs/components/toggle-button/context.d.ts +2 -0
- package/dist/commonjs/components/toggle-button/context.d.ts.map +1 -0
- package/dist/commonjs/components/toggle-button/context.js +7 -0
- package/dist/commonjs/components/toggle-button/context.js.map +1 -0
- package/dist/commonjs/components/toggle-button/internal-toggle-button.d.ts +2 -0
- package/dist/commonjs/components/toggle-button/internal-toggle-button.d.ts.map +1 -0
- package/dist/commonjs/components/toggle-button/internal-toggle-button.js +57 -0
- package/dist/commonjs/components/toggle-button/internal-toggle-button.js.map +1 -0
- package/dist/commonjs/components/toggle-button/toggle-button-group.d.ts +10 -6
- package/dist/commonjs/components/toggle-button/toggle-button-group.d.ts.map +1 -1
- package/dist/commonjs/components/toggle-button/toggle-button-group.js +61 -9
- package/dist/commonjs/components/toggle-button/toggle-button-group.js.map +1 -1
- package/dist/commonjs/components/toggle-button/toggle-button.d.ts +8 -8
- package/dist/commonjs/components/toggle-button/toggle-button.d.ts.map +1 -1
- package/dist/commonjs/components/toggle-button/toggle-button.js +6 -6
- package/dist/commonjs/components/toggle-button/toggle-button.js.map +1 -1
- package/dist/commonjs/components/toggle-button/toggle-icon-button.d.ts +7 -6
- package/dist/commonjs/components/toggle-button/toggle-icon-button.d.ts.map +1 -1
- package/dist/commonjs/components/toggle-button/toggle-icon-button.js +7 -10
- package/dist/commonjs/components/toggle-button/toggle-icon-button.js.map +1 -1
- package/dist/commonjs/components/types.d.ts +7 -1
- package/dist/commonjs/components/types.d.ts.map +1 -1
- package/dist/commonjs/components/types.js.map +1 -1
- package/dist/commonjs/index.d.ts +5 -5
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +5 -5
- package/dist/commonjs/index.js.map +1 -1
- package/dist/esm/components/checkbox/checkbox.d.ts +1 -1
- package/dist/esm/components/checkbox/checkbox.d.ts.map +1 -1
- package/dist/esm/components/checkbox/checkbox.js.map +1 -1
- package/dist/esm/components/date-picker/date-picker.d.ts +1 -1
- package/dist/esm/components/date-picker/date-picker.d.ts.map +1 -1
- package/dist/esm/components/date-picker/date-picker.js.map +1 -1
- package/dist/esm/components/file-picker/file-picker.d.ts.map +1 -1
- package/dist/esm/components/file-picker/file-picker.js +3 -3
- package/dist/esm/components/file-picker/file-picker.js.map +1 -1
- package/dist/esm/components/tabs/tabs.d.ts +1 -1
- package/dist/esm/components/tabs/tabs.d.ts.map +1 -1
- package/dist/esm/components/tabs/tabs.js +2 -4
- package/dist/esm/components/tabs/tabs.js.map +1 -1
- package/dist/esm/components/tag/tag-group.d.ts +1 -1
- package/dist/esm/components/tag/tag-group.d.ts.map +1 -1
- package/dist/esm/components/tag/tag-group.js.map +1 -1
- package/dist/esm/components/tag/tag.d.ts +1 -1
- package/dist/esm/components/tag/tag.d.ts.map +1 -1
- package/dist/esm/components/tag/tag.js.map +1 -1
- package/dist/esm/components/tag-field/tag-field.d.ts.map +1 -1
- package/dist/esm/components/tag-field/tag-field.js +6 -3
- package/dist/esm/components/tag-field/tag-field.js.map +1 -1
- package/dist/esm/components/text-inputs/text-field.d.ts.map +1 -1
- package/dist/esm/components/text-inputs/text-field.js +1 -1
- package/dist/esm/components/text-inputs/text-field.js.map +1 -1
- package/dist/esm/components/toggle/toggle.d.ts +1 -1
- package/dist/esm/components/toggle/toggle.d.ts.map +1 -1
- package/dist/esm/components/toggle/toggle.js.map +1 -1
- package/dist/esm/components/toggle-button/context.d.ts +2 -0
- package/dist/esm/components/toggle-button/context.d.ts.map +1 -0
- package/dist/esm/components/toggle-button/context.js +4 -0
- package/dist/esm/components/toggle-button/context.js.map +1 -0
- package/dist/esm/components/toggle-button/internal-toggle-button.d.ts +2 -0
- package/dist/esm/components/toggle-button/internal-toggle-button.d.ts.map +1 -0
- package/dist/esm/components/toggle-button/internal-toggle-button.js +51 -0
- package/dist/esm/components/toggle-button/internal-toggle-button.js.map +1 -0
- package/dist/esm/components/toggle-button/toggle-button-group.d.ts +10 -6
- package/dist/esm/components/toggle-button/toggle-button-group.d.ts.map +1 -1
- package/dist/esm/components/toggle-button/toggle-button-group.js +62 -10
- package/dist/esm/components/toggle-button/toggle-button-group.js.map +1 -1
- package/dist/esm/components/toggle-button/toggle-button.d.ts +8 -8
- package/dist/esm/components/toggle-button/toggle-button.d.ts.map +1 -1
- package/dist/esm/components/toggle-button/toggle-button.js +5 -5
- package/dist/esm/components/toggle-button/toggle-button.js.map +1 -1
- package/dist/esm/components/toggle-button/toggle-icon-button.d.ts +7 -6
- package/dist/esm/components/toggle-button/toggle-icon-button.d.ts.map +1 -1
- package/dist/esm/components/toggle-button/toggle-icon-button.js +6 -6
- package/dist/esm/components/toggle-button/toggle-icon-button.js.map +1 -1
- package/dist/esm/components/types.d.ts +7 -1
- package/dist/esm/components/types.d.ts.map +1 -1
- package/dist/esm/components/types.js.map +1 -1
- package/dist/esm/index.d.ts +5 -5
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +5 -5
- package/dist/esm/index.js.map +1 -1
- package/dist-styles/core.css +1 -1
- package/dist-styles/styles.css +1 -1
- package/package.json +19 -15
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type SwitchProps as RACSwitchProps } from 'react-aria-components';
|
|
2
2
|
import type { AriaLabelingProps, CommonProps, StringLikeChildren } from '../types.js';
|
|
3
|
-
export interface UNSTABLE_ToggleProps extends CommonProps, AriaLabelingProps, Pick<RACSwitchProps, 'onChange' | 'isSelected' | 'isDisabled' | 'isReadOnly' | 'defaultSelected' | 'autoFocus' | 'name' | 'value'> {
|
|
3
|
+
export interface UNSTABLE_ToggleProps extends CommonProps, AriaLabelingProps, Pick<RACSwitchProps, 'onChange' | 'isSelected' | 'isDisabled' | 'isReadOnly' | 'defaultSelected' | 'autoFocus' | 'form' | 'name' | 'value'> {
|
|
4
4
|
/** The label rendered next to the toggle. */
|
|
5
5
|
children?: StringLikeChildren;
|
|
6
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle.d.ts","sourceRoot":"","sources":["../../../../src/components/toggle/toggle.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAuB,KAAK,WAAW,IAAI,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAKhG,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGtF,MAAM,WAAW,oBACf,SAAQ,WAAW,EACjB,iBAAiB,EACjB,IAAI,CACF,cAAc,
|
|
1
|
+
{"version":3,"file":"toggle.d.ts","sourceRoot":"","sources":["../../../../src/components/toggle/toggle.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAuB,KAAK,WAAW,IAAI,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAKhG,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGtF,MAAM,WAAW,oBACf,SAAQ,WAAW,EACjB,iBAAiB,EACjB,IAAI,CACF,cAAc,EACZ,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,iBAAiB,GACjB,WAAW,GACX,MAAM,GACN,MAAM,GACN,OAAO,CACV;IACH,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,kBAAkB,CAAC;CAC/B;AAgCD;;;;GAIG;AACH,QAAA,MAAM,gBAAgB,wKAAwD,CAAC;AAE/E,OAAO,EAAE,gBAAgB,IAAI,eAAe,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle.js","sourceRoot":"","sources":["../../../../src/components/toggle/toggle.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,gDAAwB;AAExB,iEAAgG;AAChG,yDAAkD;AAClD,mDAAoE;AACpE,qFAA6E;AAC7E,mEAA2D;AAE3D,mDAA6C;
|
|
1
|
+
{"version":3,"file":"toggle.js","sourceRoot":"","sources":["../../../../src/components/toggle/toggle.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,gDAAwB;AAExB,iEAAgG;AAChG,yDAAkD;AAClD,mDAAoE;AACpE,qFAA6E;AAC7E,mEAA2D;AAE3D,mDAA6C;AAqB7C,SAAS,eAAe,CACtB,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,GAAG,KAAK,EAAwB,EAC5E,GAAmC;IAEnC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IAE7E,IAAA,gDAAoB,EAAC,GAAG,EAAE;QACxB,IAAI,CAAC,QAAQ,IAAI,CAAC,SAAS,IAAI,CAAC,cAAc,EAAE,CAAC;YAC/C,OAAO,CAAC,IAAI,CAAC,kFAAkF,CAAC,CAAC;QACnG,CAAC;IACH,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC;IAE1C,OAAO,CACL,wBAAC,8BAAS,OAAK,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,IAAA,cAAI,EAAC,YAAY,EAAE,gBAAgB,CAAC,EAAE,KAAK,EAAE,YAAY,aAClG,gCAAK,SAAS,EAAC,0BAA0B,iCACvC,iCAAK,SAAS,EAAC,kBAAkB,aAC/B,uBAAC,wBAAa,KAAG,EACjB,uBAAC,wBAAa,KAAG,EACjB,gCAAK,SAAS,EAAC,uBAAuB,GAAG,IACrC,GACF,EACL,QAAQ,IAAI,CACX,uBAAC,cAAI,IAAC,EAAE,EAAC,MAAM,EAAC,OAAO,EAAC,QAAQ,YAC7B,QAAQ,GACJ,CACR,IACS,CACb,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,IAAA,oCAAc,EAAC,IAAA,2BAAU,EAAC,eAAe,CAAC,EAAE,QAAQ,CAAC,CAAC;AAElD,2CAAe","sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport type { ForwardedRef } from 'react';\nimport { Switch as RACSwitch, type SwitchProps as RACSwitchProps } from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { IconCheckBold, IconCloseBold } from '../../icons/index.js';\nimport { useProductionWarning } from '../../utils/use-production-warning.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport type { AriaLabelingProps, CommonProps, StringLikeChildren } from '../types.js';\nimport { Text } from '../typography/text.js';\n\nexport interface UNSTABLE_ToggleProps\n extends CommonProps,\n AriaLabelingProps,\n Pick<\n RACSwitchProps,\n | 'onChange'\n | 'isSelected'\n | 'isDisabled'\n | 'isReadOnly'\n | 'defaultSelected'\n | 'autoFocus'\n | 'form'\n | 'name'\n | 'value'\n > {\n /** The label rendered next to the toggle. */\n children?: StringLikeChildren;\n}\n\nfunction UNSTABLE_Toggle(\n { children, UNSAFE_className, UNSAFE_style, ...props }: UNSTABLE_ToggleProps,\n ref: ForwardedRef<HTMLLabelElement>,\n) {\n const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;\n\n useProductionWarning(() => {\n if (!children && !ariaLabel && !ariaLabelledBy) {\n console.warn('Toggle requires one of children / aria-label / aria-labelledby for accessibility');\n }\n }, [children, ariaLabel, ariaLabelledBy]);\n\n return (\n <RACSwitch {...props} ref={ref} className={clsx('cim-toggle', UNSAFE_className)} style={UNSAFE_style}>\n <div className=\"cim-toggle-track-wrapper\" aria-hidden>\n <div className=\"cim-toggle-track\">\n <IconCheckBold />\n <IconCloseBold />\n <div className=\"cim-toggle-track-head\" />\n </div>\n </div>\n {children && (\n <Text as=\"span\" variant=\"medium\">\n {children}\n </Text>\n )}\n </RACSwitch>\n );\n}\n\n/**\n * Allows users to turn a setting on or off.\n *\n * See [toggle usage guidelines](https://ui.cimpress.io/components/toggle/).\n */\nconst _UNSTABLE_Toggle = withStyleProps(forwardRef(UNSTABLE_Toggle), 'Toggle');\n\nexport { _UNSTABLE_Toggle as UNSTABLE_Toggle };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/components/toggle-button/context.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToggleButtonGroupContext = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/** @internal */
|
|
6
|
+
exports.ToggleButtonGroupContext = (0, react_1.createContext)(null);
|
|
7
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../src/components/toggle-button/context.tsx"],"names":[],"mappings":";;;AACA,iCAAsC;AAWtC,gBAAgB;AACH,QAAA,wBAAwB,GAAG,IAAA,qBAAa,EAAuC,IAAI,CAAC,CAAC","sourcesContent":["import type { FormValidationState } from '@react-stately/form';\nimport { createContext } from 'react';\n\n/** @internal */\nexport interface ToggleButtonGroupContextValue {\n form?: string;\n name?: string;\n isInvalid?: boolean;\n isRequired?: boolean;\n validationState: FormValidationState;\n}\n\n/** @internal */\nexport const ToggleButtonGroupContext = createContext<ToggleButtonGroupContextValue | null>(null);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-toggle-button.d.ts","sourceRoot":"","sources":["../../../../src/components/toggle-button/internal-toggle-button.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.InternalToggleButton = InternalToggleButton;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const form_1 = require("@react-aria/form");
|
|
9
|
+
const utils_1 = require("@react-aria/utils");
|
|
10
|
+
const form_2 = require("@react-stately/form");
|
|
11
|
+
const utils_2 = require("@react-stately/utils");
|
|
12
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
13
|
+
const react_1 = require("react");
|
|
14
|
+
const react_aria_components_1 = require("react-aria-components");
|
|
15
|
+
const context_js_1 = require("./context.js");
|
|
16
|
+
/** @internal */
|
|
17
|
+
function InternalToggleButton({ buttonRef: ref, children, size = 'medium', isDisabled, fullWidth, UNSAFE_className, UNSAFE_style, form, name, value, isSelected: consumerIsSelected, defaultSelected: consumerDefaultSelected, onChange, ...props }) {
|
|
18
|
+
// State
|
|
19
|
+
const toggleButtonGroupContext = (0, react_1.useContext)(context_js_1.ToggleButtonGroupContext);
|
|
20
|
+
const toggleGroupState = (0, react_1.useContext)(react_aria_components_1.ToggleGroupStateContext);
|
|
21
|
+
const descriptionProps = (0, react_aria_components_1.useSlottedContext)(react_aria_components_1.TextContext, 'description');
|
|
22
|
+
const errorMessageProps = (0, react_aria_components_1.useSlottedContext)(react_aria_components_1.TextContext, 'errorMessage');
|
|
23
|
+
const [isSelected, setIsSelected] = (0, utils_2.useControlledState)(toggleGroupState && value ? toggleGroupState.selectedKeys.has(value) : consumerIsSelected, consumerDefaultSelected ?? false, (newIsSelected) => {
|
|
24
|
+
onChange?.(newIsSelected);
|
|
25
|
+
if (toggleGroupState && value) {
|
|
26
|
+
toggleGroupState.setSelected(value, newIsSelected);
|
|
27
|
+
}
|
|
28
|
+
validationState.commitValidation();
|
|
29
|
+
});
|
|
30
|
+
// Validation
|
|
31
|
+
const buttonRef = (0, utils_1.useObjectRef)(ref);
|
|
32
|
+
const formInputRef = (0, react_1.useRef)(null);
|
|
33
|
+
const formInputName = toggleButtonGroupContext?.name ?? name;
|
|
34
|
+
const validationState = (0, form_2.useFormValidationState)({
|
|
35
|
+
// If part of a group, validation is handled at group level
|
|
36
|
+
name: toggleButtonGroupContext ? undefined : name,
|
|
37
|
+
value,
|
|
38
|
+
validationBehavior: 'native',
|
|
39
|
+
[form_2.privateValidationStateProp]: toggleButtonGroupContext?.validationState ?? undefined,
|
|
40
|
+
});
|
|
41
|
+
const [initialSelected] = (0, react_1.useState)(isSelected);
|
|
42
|
+
(0, utils_1.useFormReset)(formInputRef, consumerDefaultSelected ?? initialSelected, setIsSelected);
|
|
43
|
+
(0, form_1.useFormValidation)({
|
|
44
|
+
focus: () => buttonRef.current?.focus(),
|
|
45
|
+
validationBehavior: 'native',
|
|
46
|
+
}, validationState, formInputRef);
|
|
47
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_aria_components_1.ToggleButton, { ...props, ref: buttonRef, className: (0, clsx_1.default)('cim-toggle-button', UNSAFE_className), style: UNSAFE_style, id: toggleButtonGroupContext ? value : undefined, isDisabled: isDisabled, isSelected: isSelected, onChange: setIsSelected, "aria-describedby": [
|
|
48
|
+
props['aria-describedby'],
|
|
49
|
+
toggleButtonGroupContext?.isInvalid ? errorMessageProps?.id : null,
|
|
50
|
+
descriptionProps?.id,
|
|
51
|
+
]
|
|
52
|
+
.filter(Boolean)
|
|
53
|
+
.join(' ') || undefined, "data-variant": "secondary", "data-tone": "base", "data-size": size, "data-full-width": fullWidth || undefined, children: children }), formInputName && ((0, jsx_runtime_1.jsx)("input", { ref: formInputRef, style: { display: 'none' }, type: "checkbox", form: toggleButtonGroupContext?.form ?? form, name: formInputName, checked: isSelected, value: value, required: toggleButtonGroupContext?.isRequired, "aria-invalid": toggleButtonGroupContext?.validationState.displayValidation.isInvalid ??
|
|
54
|
+
validationState.displayValidation.isInvalid ??
|
|
55
|
+
undefined, onChange: () => { } }))] }));
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=internal-toggle-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-toggle-button.js","sourceRoot":"","sources":["../../../../src/components/toggle-button/internal-toggle-button.tsx"],"names":[],"mappings":";;;;;AA2DA,oDA+GC;;AA1KD,2CAAqD;AACrD,6CAA+D;AAC/D,8CAAyF;AACzF,gDAA0D;AAC1D,gDAAwB;AACxB,iCAA+E;AAC/E,iEAM+B;AAG/B,6CAAwD;AA2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CAChB,kCACE,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAC1B,IAAI,EAAC,UAAU,EACf,IAAI,EAAE,wBAAwB,EAAE,IAAI,IAAI,IAAI,EAC5C,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,wBAAwB,EAAE,UAAU,kBAE5C,wBAAwB,EAAE,eAAe,CAAC,iBAAiB,CAAC,SAAS;oBACrE,eAAe,CAAC,iBAAiB,CAAC,SAAS;oBAC3C,SAAS,EAEX,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC,GAClB,CACH,IACA,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import { useFormValidation } from '@react-aria/form';\nimport { useFormReset, useObjectRef } from '@react-aria/utils';\nimport { privateValidationStateProp, useFormValidationState } from '@react-stately/form';\nimport { useControlledState } from '@react-stately/utils';\nimport clsx from 'clsx';\nimport { type ReactNode, useContext, useRef, useState, type Ref } from 'react';\nimport {\n TextContext as RACTextContext,\n ToggleButton as RACToggleButton,\n type ToggleButtonProps as RACToggleButtonProps,\n ToggleGroupStateContext as RACToggleGroupStateContext,\n useSlottedContext,\n} from 'react-aria-components';\nimport type { BaseButtonProps } from '../button/types.js';\nimport type { AriaLabelingProps, CommonProps } from '../types.js';\nimport { ToggleButtonGroupContext } from './context.js';\n\n/** @internal */\nexport interface BaseToggleButtonProps\n extends Omit<CommonProps, 'id'>,\n AriaLabelingProps,\n Pick<BaseButtonProps, 'size' | 'fullWidth'>,\n Pick<\n RACToggleButtonProps,\n | 'defaultSelected'\n | 'isSelected'\n | 'onPress'\n | 'onHoverStart'\n | 'onHoverEnd'\n | 'onChange'\n | 'isDisabled'\n | 'autoFocus'\n > {\n /**\n * The `<form>` element to associate the input with.\n * The value of this attribute must be the id of a `<form>` in the same document.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).\n */\n form?: string;\n /**\n * The name of the input element, used when submitting an HTML form.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#name).\n */\n name?: string;\n /**\n * The value of the input element, used when submitting an HTML form.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#value).\n *\n * When used in a `ToggleButtonGroup`, `value` serves as an identifier for this button, and has to be unique across all buttons in the group.\n */\n value?: string;\n}\n\ninterface InternalToggleButtonProps extends BaseToggleButtonProps {\n children?: ReactNode;\n buttonRef?: Ref<HTMLButtonElement>;\n}\n\n/** @internal */\nexport function InternalToggleButton({\n buttonRef: ref,\n children,\n size = 'medium',\n isDisabled,\n fullWidth,\n UNSAFE_className,\n UNSAFE_style,\n form,\n name,\n value,\n isSelected: consumerIsSelected,\n defaultSelected: consumerDefaultSelected,\n onChange,\n ...props\n}: InternalToggleButtonProps) {\n // State\n\n const toggleButtonGroupContext = useContext(ToggleButtonGroupContext);\n const toggleGroupState = useContext(RACToggleGroupStateContext);\n const descriptionProps = useSlottedContext(RACTextContext, 'description');\n const errorMessageProps = useSlottedContext(RACTextContext, 'errorMessage');\n\n const [isSelected, setIsSelected] = useControlledState(\n toggleGroupState && value ? toggleGroupState.selectedKeys.has(value) : consumerIsSelected,\n consumerDefaultSelected ?? false,\n (newIsSelected) => {\n onChange?.(newIsSelected);\n\n if (toggleGroupState && value) {\n toggleGroupState.setSelected(value, newIsSelected);\n }\n\n validationState.commitValidation();\n },\n );\n\n // Validation\n\n const buttonRef = useObjectRef(ref);\n const formInputRef = useRef<HTMLInputElement>(null);\n const formInputName = toggleButtonGroupContext?.name ?? name;\n\n const validationState = useFormValidationState({\n // If part of a group, validation is handled at group level\n name: toggleButtonGroupContext ? undefined : name,\n value,\n validationBehavior: 'native',\n [privateValidationStateProp]: toggleButtonGroupContext?.validationState ?? undefined,\n });\n\n const [initialSelected] = useState(isSelected);\n useFormReset(formInputRef, consumerDefaultSelected ?? initialSelected, setIsSelected);\n\n useFormValidation(\n {\n focus: () => buttonRef.current?.focus(),\n validationBehavior: 'native',\n },\n validationState,\n formInputRef,\n );\n\n return (\n <>\n <RACToggleButton\n {...props}\n ref={buttonRef}\n className={clsx('cim-toggle-button', UNSAFE_className)}\n style={UNSAFE_style}\n id={toggleButtonGroupContext ? value : undefined}\n isDisabled={isDisabled}\n isSelected={isSelected}\n onChange={setIsSelected}\n aria-describedby={\n [\n props['aria-describedby'],\n toggleButtonGroupContext?.isInvalid ? errorMessageProps?.id : null,\n descriptionProps?.id,\n ]\n .filter(Boolean)\n .join(' ') || undefined\n }\n data-variant=\"secondary\"\n data-tone=\"base\"\n data-size={size}\n data-full-width={fullWidth || undefined}\n >\n {children}\n </RACToggleButton>\n\n {formInputName && (\n <input\n ref={formInputRef}\n style={{ display: 'none' }}\n type=\"checkbox\"\n form={toggleButtonGroupContext?.form ?? form}\n name={formInputName}\n checked={isSelected}\n value={value}\n required={toggleButtonGroupContext?.isRequired}\n aria-invalid={\n toggleButtonGroupContext?.validationState.displayValidation.isInvalid ??\n validationState.displayValidation.isInvalid ??\n undefined\n }\n onChange={() => {}}\n />\n )}\n </>\n );\n}\n"]}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
2
|
import { type ToggleButtonGroupProps as RACToggleButtonGroupProps } from 'react-aria-components';
|
|
3
|
-
import type { CommonProps,
|
|
4
|
-
export interface
|
|
5
|
-
/** Toggle buttons belonging to the group. Each button must have
|
|
3
|
+
import type { CommonProps, FieldProps, Key, WithRequired } from '../types.js';
|
|
4
|
+
export interface ToggleButtonGroupProps extends Omit<CommonProps, 'id'>, WithRequired<FieldProps<Set<Key>>, 'label'>, Pick<RACToggleButtonGroupProps, 'selectedKeys' | 'defaultSelectedKeys' | 'onSelectionChange' | 'selectionMode' | 'isDisabled'> {
|
|
5
|
+
/** Toggle buttons belonging to the group. Each button must have a `value` prop defined. */
|
|
6
6
|
children: ReactNode;
|
|
7
|
+
/** Whether the current selection is invalid. */
|
|
8
|
+
isInvalid?: boolean;
|
|
9
|
+
/** Whether a selection is required before form submission. */
|
|
10
|
+
isRequired?: boolean;
|
|
7
11
|
}
|
|
8
12
|
/**
|
|
9
13
|
* Allows users to toggle multiple options, with single or multiple selection.
|
|
10
14
|
*
|
|
11
15
|
* See [toggle button usage guidelines](https://ui.cimpress.io/components/toggle-button/).
|
|
12
16
|
*/
|
|
13
|
-
declare const
|
|
14
|
-
export {
|
|
17
|
+
declare const _ToggleButtonGroup: (props: ToggleButtonGroupProps & import("react").RefAttributes<HTMLDivElement> & import("../../with-style-props.js").StyleProps) => import("react").JSX.Element | null;
|
|
18
|
+
export { _ToggleButtonGroup as ToggleButtonGroup };
|
|
15
19
|
//# sourceMappingURL=toggle-button-group.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-button-group.d.ts","sourceRoot":"","sources":["../../../../src/components/toggle-button/toggle-button-group.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"toggle-button-group.d.ts","sourceRoot":"","sources":["../../../../src/components/toggle-button/toggle-button-group.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGhD,OAAO,EAML,KAAK,sBAAsB,IAAI,yBAAyB,EACzD,MAAM,uBAAuB,CAAC;AAO/B,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI9E,MAAM,WAAW,sBACf,SAAQ,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,EAC7B,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,EAC3C,IAAI,CACF,yBAAyB,EACzB,cAAc,GAAG,qBAAqB,GAAG,mBAAmB,GAAG,eAAe,GAAG,YAAY,CAC9F;IACH,2FAA2F;IAC3F,QAAQ,EAAE,SAAS,CAAC;IACpB,gDAAgD;IAChD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAuHD;;;;GAIG;AACH,QAAA,MAAM,kBAAkB,wKAAqE,CAAC;AAE9F,OAAO,EAAE,kBAAkB,IAAI,iBAAiB,EAAE,CAAC"}
|
|
@@ -4,27 +4,79 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.ToggleButtonGroup = void 0;
|
|
8
8
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const form_1 = require("@react-stately/form");
|
|
10
|
+
const utils_1 = require("@react-stately/utils");
|
|
9
11
|
const clsx_1 = __importDefault(require("clsx"));
|
|
12
|
+
const react_1 = require("react");
|
|
13
|
+
const react_aria_1 = require("react-aria");
|
|
10
14
|
const react_aria_components_1 = require("react-aria-components");
|
|
11
15
|
const forward_ref_js_1 = require("../../forward-ref.js");
|
|
16
|
+
const index_js_1 = require("../../i18n/index.js");
|
|
12
17
|
const use_production_warning_js_1 = require("../../utils/use-production-warning.js");
|
|
13
18
|
const with_style_props_js_1 = require("../../with-style-props.js");
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
const form_field_js_1 = require("../internal/form-field/form-field.js");
|
|
20
|
+
const stack_js_1 = require("../spacing/stack/stack.js");
|
|
21
|
+
const visually_hidden_js_1 = require("../visually-hidden/visually-hidden.js");
|
|
22
|
+
const context_js_1 = require("./context.js");
|
|
23
|
+
function ToggleButtonGroup({ children, label, description, error: errorMessage, validate, form, name, isInvalid, isRequired, selectedKeys: consumerSelectedKeys, defaultSelectedKeys: consumerDefaultSelectedKeys, onSelectionChange, UNSAFE_className, UNSAFE_style, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy, 'aria-details': ariaDetails, ...props }, ref) {
|
|
16
24
|
(0, use_production_warning_js_1.useProductionWarning)(() => {
|
|
17
|
-
if (!ariaLabel && !ariaLabelledBy) {
|
|
18
|
-
console.warn('ToggleButtonGroup requires one of aria-label / aria-labelledby for accessibility');
|
|
25
|
+
if (!label && !ariaLabel && !ariaLabelledBy) {
|
|
26
|
+
console.warn('ToggleButtonGroup requires one of label / aria-label / aria-labelledby for accessibility');
|
|
19
27
|
}
|
|
20
|
-
}, [ariaLabel, ariaLabelledBy]);
|
|
21
|
-
|
|
28
|
+
}, [label, ariaLabel, ariaLabelledBy]);
|
|
29
|
+
const labelMessages = (0, index_js_1.useLocalizedMessages)('label');
|
|
30
|
+
// State
|
|
31
|
+
const [selectedKeys, setSelectedKeys] = (0, utils_1.useControlledState)(consumerSelectedKeys, consumerDefaultSelectedKeys ?? [], (newSelectedKeys) => {
|
|
32
|
+
onSelectionChange?.(new Set(newSelectedKeys));
|
|
33
|
+
validationState.commitValidation();
|
|
34
|
+
});
|
|
35
|
+
const selectedSet = (0, react_1.useMemo)(() => new Set(selectedKeys), [selectedKeys]);
|
|
36
|
+
// Validation
|
|
37
|
+
const validationState = (0, form_1.useFormValidationState)({
|
|
38
|
+
value: selectedSet,
|
|
39
|
+
isInvalid,
|
|
40
|
+
isRequired,
|
|
41
|
+
name,
|
|
42
|
+
validate,
|
|
43
|
+
validationBehavior: 'native',
|
|
44
|
+
});
|
|
45
|
+
const { labelProps, fieldProps, descriptionProps, errorMessageProps } = (0, react_aria_1.useField)({
|
|
46
|
+
'aria-label': ariaLabel,
|
|
47
|
+
'aria-labelledby': ariaLabelledBy,
|
|
48
|
+
'aria-describedby': ariaDescribedBy,
|
|
49
|
+
'aria-details': ariaDetails,
|
|
50
|
+
description,
|
|
51
|
+
errorMessage: errorMessage || validationState.displayValidation.validationErrors,
|
|
52
|
+
isInvalid: isInvalid || validationState.displayValidation.isInvalid,
|
|
53
|
+
label,
|
|
54
|
+
labelElementType: 'span',
|
|
55
|
+
validate,
|
|
56
|
+
validationBehavior: 'native',
|
|
57
|
+
});
|
|
58
|
+
// Remove props that we don't want from fieldProps
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
60
|
+
const { id, ...filteredFieldProps } = fieldProps;
|
|
61
|
+
const toggleButtonGroupContext = {
|
|
62
|
+
form,
|
|
63
|
+
name,
|
|
64
|
+
isInvalid: isInvalid || validationState.displayValidation.isInvalid,
|
|
65
|
+
isRequired: isRequired && selectedSet.size === 0,
|
|
66
|
+
validationState,
|
|
67
|
+
};
|
|
68
|
+
return ((0, jsx_runtime_1.jsx)(react_aria_components_1.ToggleButtonGroup, { ...(0, react_aria_1.mergeProps)(props, filteredFieldProps), ref: ref, className: (0, clsx_1.default)('cim-toggle-button-group', UNSAFE_className), style: UNSAFE_style, selectedKeys: selectedKeys, onSelectionChange: setSelectedKeys, children: (0, jsx_runtime_1.jsxs)(react_aria_components_1.Provider, { values: [
|
|
69
|
+
[react_aria_components_1.LabelContext, { ...labelProps, elementType: 'span' }],
|
|
70
|
+
[react_aria_components_1.TextContext, { slots: { description: descriptionProps, errorMessage: errorMessageProps } }],
|
|
71
|
+
[react_aria_components_1.FieldErrorContext, validationState.displayValidation],
|
|
72
|
+
[context_js_1.ToggleButtonGroupContext, toggleButtonGroupContext],
|
|
73
|
+
], children: [(0, jsx_runtime_1.jsxs)(form_field_js_1.FormFieldLabel, { isRequired: isRequired, children: [label, isRequired && (0, jsx_runtime_1.jsx)(visually_hidden_js_1.UNSTABLE_VisuallyHidden, { children: labelMessages.format('required') })] }), (0, jsx_runtime_1.jsx)(stack_js_1.Stack, { gap: 8, direction: "horizontal", wrap: true, children: children }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldError, { children: errorMessage }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldDescription, { children: description })] }) }));
|
|
22
74
|
}
|
|
23
75
|
/**
|
|
24
76
|
* Allows users to toggle multiple options, with single or multiple selection.
|
|
25
77
|
*
|
|
26
78
|
* See [toggle button usage guidelines](https://ui.cimpress.io/components/toggle-button/).
|
|
27
79
|
*/
|
|
28
|
-
const
|
|
29
|
-
exports.
|
|
80
|
+
const _ToggleButtonGroup = (0, with_style_props_js_1.withStyleProps)((0, forward_ref_js_1.forwardRef)(ToggleButtonGroup), 'ToggleButtonGroup');
|
|
81
|
+
exports.ToggleButtonGroup = _ToggleButtonGroup;
|
|
30
82
|
//# sourceMappingURL=toggle-button-group.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-button-group.js","sourceRoot":"","sources":["../../../../src/components/toggle-button/toggle-button-group.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,gDAAwB;
|
|
1
|
+
{"version":3,"file":"toggle-button-group.js","sourceRoot":"","sources":["../../../../src/components/toggle-button/toggle-button-group.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,8CAA6D;AAC7D,gDAA0D;AAC1D,gDAAwB;AACxB,iCAAgD;AAEhD,2CAAkD;AAClD,iEAO+B;AAC/B,yDAAkD;AAClD,kDAA2D;AAC3D,qFAA6E;AAC7E,mEAA2D;AAC3D,wEAA4G;AAC5G,wDAAkD;AAElD,8EAAkG;AAClG,6CAA4F;AAiB5F,SAAS,iBAAiB,CACxB,EACE,QAAQ,EACR,KAAK,EACL,WAAW,EACX,KAAK,EAAE,YAAY,EACnB,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,UAAU,EACV,YAAY,EAAE,oBAAoB,EAClC,mBAAmB,EAAE,2BAA2B,EAChD,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,EACjC,kBAAkB,EAAE,eAAe,EACnC,cAAc,EAAE,WAAW,EAC3B,GAAG,KAAK,EACe,EACzB,GAAiC;IAEjC,IAAA,gDAAoB,EAAC,GAAG,EAAE;Q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,oCAAoB,cAAE,WAAW,GAAwB,IAC9C,GACO,CACxB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,IAAA,oCAAc,EAAC,IAAA,2BAAU,EAAC,iBAAiB,CAAC,EAAE,mBAAmB,CAAC,CAAC;AAE/D,+CAAiB","sourcesContent":["'use client';\n\nimport { useFormValidationState } from '@react-stately/form';\nimport { useControlledState } from '@react-stately/utils';\nimport clsx from 'clsx';\nimport { useMemo, type ReactNode } from 'react';\nimport type { ForwardedRef } from 'react';\nimport { mergeProps, useField } from 'react-aria';\nimport {\n LabelContext as RACLabelContext,\n FieldErrorContext as RACFieldErrorContext,\n Provider as RACProvider,\n TextContext as RACTextContext,\n ToggleButtonGroup as RACToggleButtonGroup,\n type ToggleButtonGroupProps as RACToggleButtonGroupProps,\n} from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useLocalizedMessages } from '../../i18n/index.js';\nimport { useProductionWarning } from '../../utils/use-production-warning.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport { FormFieldDescription, FormFieldError, FormFieldLabel } from '../internal/form-field/form-field.js';\nimport { Stack } from '../spacing/stack/stack.js';\nimport type { CommonProps, FieldProps, Key, WithRequired } from '../types.js';\nimport { UNSTABLE_VisuallyHidden as VisuallyHidden } from '../visually-hidden/visually-hidden.js';\nimport { ToggleButtonGroupContext, type ToggleButtonGroupContextValue } from './context.js';\n\nexport interface ToggleButtonGroupProps\n extends Omit<CommonProps, 'id'>,\n WithRequired<FieldProps<Set<Key>>, 'label'>,\n Pick<\n RACToggleButtonGroupProps,\n 'selectedKeys' | 'defaultSelectedKeys' | 'onSelectionChange' | 'selectionMode' | 'isDisabled'\n > {\n /** Toggle buttons belonging to the group. Each button must have a `value` prop defined. */\n children: ReactNode;\n /** Whether the current selection is invalid. */\n isInvalid?: boolean;\n /** Whether a selection is required before form submission. */\n isRequired?: boolean;\n}\n\nfunction ToggleButtonGroup(\n {\n children,\n label,\n description,\n error: errorMessage,\n validate,\n form,\n name,\n isInvalid,\n isRequired,\n selectedKeys: consumerSelectedKeys,\n defaultSelectedKeys: consumerDefaultSelectedKeys,\n onSelectionChange,\n UNSAFE_className,\n UNSAFE_style,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-details': ariaDetails,\n ...props\n }: ToggleButtonGroupProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n useProductionWarning(() => {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn('ToggleButtonGroup requires one of label / aria-label / aria-labelledby for accessibility');\n }\n }, [label, ariaLabel, ariaLabelledBy]);\n\n const labelMessages = useLocalizedMessages('label');\n\n // State\n\n const [selectedKeys, setSelectedKeys] = useControlledState(\n consumerSelectedKeys,\n consumerDefaultSelectedKeys ?? [],\n (newSelectedKeys) => {\n onSelectionChange?.(new Set(newSelectedKeys));\n validationState.commitValidation();\n },\n );\n\n const selectedSet = useMemo(() => new Set<Key>(selectedKeys), [selectedKeys]);\n\n // Validation\n\n const validationState = useFormValidationState({\n value: selectedSet,\n isInvalid,\n isRequired,\n name,\n validate,\n validationBehavior: 'native',\n });\n\n const { labelProps, fieldProps, descriptionProps, errorMessageProps } = useField({\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-details': ariaDetails,\n description,\n errorMessage: errorMessage || validationState.displayValidation.validationErrors,\n isInvalid: isInvalid || validationState.displayValidation.isInvalid,\n label,\n labelElementType: 'span',\n validate,\n validationBehavior: 'native',\n });\n\n // Remove props that we don't want from fieldProps\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { id, ...filteredFieldProps } = fieldProps;\n\n const toggleButtonGroupContext: ToggleButtonGroupContextValue = {\n form,\n name,\n isInvalid: isInvalid || validationState.displayValidation.isInvalid,\n isRequired: isRequired && selectedSet.size === 0,\n validationState,\n };\n\n return (\n <RACToggleButtonGroup\n {...mergeProps(props, filteredFieldProps)}\n ref={ref}\n className={clsx('cim-toggle-button-group', UNSAFE_className)}\n style={UNSAFE_style}\n selectedKeys={selectedKeys}\n onSelectionChange={setSelectedKeys}\n >\n <RACProvider\n values={[\n [RACLabelContext, { ...labelProps, elementType: 'span' }],\n [RACTextContext, { slots: { description: descriptionProps, errorMessage: errorMessageProps } }],\n [RACFieldErrorContext, validationState.displayValidation],\n [ToggleButtonGroupContext, toggleButtonGroupContext],\n ]}\n >\n <FormFieldLabel isRequired={isRequired}>\n {label}\n {/*\n * Button elements don't support `aria-required`, so we need to add visually hidden text to indicate that the field is required.\n * See: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-required#examples:~:text=Note%3A%20If%20the%20field%27s%20label%20already%20contains%20the%20word%20%22required%22%2C%20it%20is%20recommended%20to%20leave%20out%20the%20aria%2Drequired%20attribute.%20This%20avoids%20that%20screen%20readers%20read%20out%20the%20term%20%22required%22%20twice.\n */}\n {isRequired && <VisuallyHidden>{labelMessages.format('required')}</VisuallyHidden>}\n </FormFieldLabel>\n <Stack gap={8} direction=\"horizontal\" wrap>\n {children}\n </Stack>\n <FormFieldError>{errorMessage}</FormFieldError>\n <FormFieldDescription>{description}</FormFieldDescription>\n </RACProvider>\n </RACToggleButtonGroup>\n );\n}\n\n/**\n * Allows users to toggle multiple options, with single or multiple selection.\n *\n * See [toggle button usage guidelines](https://ui.cimpress.io/components/toggle-button/).\n */\nconst _ToggleButtonGroup = withStyleProps(forwardRef(ToggleButtonGroup), 'ToggleButtonGroup');\n\nexport { _ToggleButtonGroup as ToggleButtonGroup };\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
import
|
|
4
|
-
export interface
|
|
5
|
-
/**
|
|
6
|
-
|
|
1
|
+
import type { TextButtonProps } from '../button/types.js';
|
|
2
|
+
import type { StringLikeChildren } from '../types.js';
|
|
3
|
+
import { type BaseToggleButtonProps } from './internal-toggle-button.js';
|
|
4
|
+
export interface ToggleButtonProps extends BaseToggleButtonProps, Omit<TextButtonProps, 'children'> {
|
|
5
|
+
/** The text displayed on the button. Must remain the same regardless of selection state. */
|
|
6
|
+
children: StringLikeChildren;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Displays a labelled button that allows users to toggle between two states.
|
|
@@ -11,6 +11,6 @@ export interface UNSTABLE_ToggleButtonProps extends Omit<CommonProps, 'id'>, Tex
|
|
|
11
11
|
*
|
|
12
12
|
* See [toggle button usage guidelines](https://ui.cimpress.io/components/toggle-button/).
|
|
13
13
|
*/
|
|
14
|
-
declare const
|
|
15
|
-
export {
|
|
14
|
+
declare const _ToggleButton: (props: ToggleButtonProps & import("react").RefAttributes<HTMLButtonElement> & import("../../with-style-props.js").StyleProps) => import("react").JSX.Element | null;
|
|
15
|
+
export { _ToggleButton as ToggleButton };
|
|
16
16
|
//# sourceMappingURL=toggle-button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-button.d.ts","sourceRoot":"","sources":["../../../../src/components/toggle-button/toggle-button.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"toggle-button.d.ts","sourceRoot":"","sources":["../../../../src/components/toggle-button/toggle-button.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAwB,KAAK,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAE/F,MAAM,WAAW,iBAAkB,SAAQ,qBAAqB,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC;IACjG,4FAA4F;IAC5F,QAAQ,EAAE,kBAAkB,CAAC;CAC9B;AAeD;;;;;GAKG;AACH,QAAA,MAAM,aAAa,sKAA2D,CAAC;AAE/E,OAAO,EAAE,aAAa,IAAI,YAAY,EAAE,CAAC"}
|
|
@@ -4,14 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.ToggleButton = void 0;
|
|
8
8
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
9
|
const clsx_1 = __importDefault(require("clsx"));
|
|
10
|
-
const react_aria_components_1 = require("react-aria-components");
|
|
11
10
|
const forward_ref_js_1 = require("../../forward-ref.js");
|
|
12
11
|
const with_style_props_js_1 = require("../../with-style-props.js");
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const internal_toggle_button_js_1 = require("./internal-toggle-button.js");
|
|
13
|
+
function ToggleButton({ children, iconStart, iconEnd, UNSAFE_className, ...props }, ref) {
|
|
14
|
+
return ((0, jsx_runtime_1.jsxs)(internal_toggle_button_js_1.InternalToggleButton, { ...props, buttonRef: ref, UNSAFE_className: (0, clsx_1.default)('cim-button', UNSAFE_className), children: [iconStart, (0, jsx_runtime_1.jsx)("span", { className: "cim-button-text", children: children }), iconEnd] }));
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Displays a labelled button that allows users to toggle between two states.
|
|
@@ -19,6 +19,6 @@ function UNSTABLE_ToggleButton({ children, size = 'medium', iconStart, iconEnd,
|
|
|
19
19
|
*
|
|
20
20
|
* See [toggle button usage guidelines](https://ui.cimpress.io/components/toggle-button/).
|
|
21
21
|
*/
|
|
22
|
-
const
|
|
23
|
-
exports.
|
|
22
|
+
const _ToggleButton = (0, with_style_props_js_1.withStyleProps)((0, forward_ref_js_1.forwardRef)(ToggleButton), 'ToggleButton');
|
|
23
|
+
exports.ToggleButton = _ToggleButton;
|
|
24
24
|
//# sourceMappingURL=toggle-button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-button.js","sourceRoot":"","sources":["../../../../src/components/toggle-button/toggle-button.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,gDAAwB;AAExB,
|
|
1
|
+
{"version":3,"file":"toggle-button.js","sourceRoot":"","sources":["../../../../src/components/toggle-button/toggle-button.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,gDAAwB;AAExB,yDAAkD;AAClD,mEAA2D;AAG3D,2EAA+F;AAO/F,SAAS,YAAY,CACnB,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE,GAAG,KAAK,EAAqB,EAC/E,GAAoC;IAEpC,OAAO,CACL,wBAAC,gDAAoB,OAAK,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,gBAAgB,EAAE,IAAA,cAAI,EAAC,YAAY,EAAE,gBAAgB,CAAC,aACpG,SAAS,EACV,iCAAM,SAAS,EAAC,iBAAiB,YAAE,QAAQ,GAAQ,EAClD,OAAO,IACa,CACxB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,aAAa,GAAG,IAAA,oCAAc,EAAC,IAAA,2BAAU,EAAC,YAAY,CAAC,EAAE,cAAc,CAAC,CAAC;AAErD,qCAAY","sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport type { ForwardedRef } from 'react';\nimport { forwardRef } from '../../forward-ref.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport type { TextButtonProps } from '../button/types.js';\nimport type { StringLikeChildren } from '../types.js';\nimport { InternalToggleButton, type BaseToggleButtonProps } from './internal-toggle-button.js';\n\nexport interface ToggleButtonProps extends BaseToggleButtonProps, Omit<TextButtonProps, 'children'> {\n /** The text displayed on the button. Must remain the same regardless of selection state. */\n children: StringLikeChildren;\n}\n\nfunction ToggleButton(\n { children, iconStart, iconEnd, UNSAFE_className, ...props }: ToggleButtonProps,\n ref: ForwardedRef<HTMLButtonElement>,\n) {\n return (\n <InternalToggleButton {...props} buttonRef={ref} UNSAFE_className={clsx('cim-button', UNSAFE_className)}>\n {iconStart}\n <span className=\"cim-button-text\">{children}</span>\n {iconEnd}\n </InternalToggleButton>\n );\n}\n\n/**\n * Displays a labelled button that allows users to toggle between two states.\n * Can be used standalone, or as part of `ToggleButtonGroup`.\n *\n * See [toggle button usage guidelines](https://ui.cimpress.io/components/toggle-button/).\n */\nconst _ToggleButton = withStyleProps(forwardRef(ToggleButton), 'ToggleButton');\n\nexport { _ToggleButton as ToggleButton };\n"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { SingleIconButtonProps } from '../button/types.js';
|
|
2
|
+
import { type BaseToggleButtonProps } from './internal-toggle-button.js';
|
|
3
|
+
export interface ToggleIconButtonProps extends Omit<BaseToggleButtonProps, 'aria-label'>, Omit<SingleIconButtonProps, 'aria-label'> {
|
|
4
|
+
/** The label describing the function of this button for assistive technologies. Must remain the same regardless of selection state. */
|
|
5
|
+
'aria-label': string;
|
|
5
6
|
}
|
|
6
7
|
/**
|
|
7
8
|
* Displays an icon-only button that allows users to toggle between two states.
|
|
@@ -9,6 +10,6 @@ export interface UNSTABLE_ToggleIconButtonProps extends CommonProps, SingleIconB
|
|
|
9
10
|
*
|
|
10
11
|
* See [toggle button usage guidelines](https://ui.cimpress.io/components/toggle-button/).
|
|
11
12
|
*/
|
|
12
|
-
declare const
|
|
13
|
-
export {
|
|
13
|
+
declare const _ToggleIconButton: (props: ToggleIconButtonProps & import("react").RefAttributes<HTMLButtonElement> & import("../../with-style-props.js").StyleProps) => import("react").JSX.Element | null;
|
|
14
|
+
export { _ToggleIconButton as ToggleIconButton };
|
|
14
15
|
//# sourceMappingURL=toggle-icon-button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-icon-button.d.ts","sourceRoot":"","sources":["../../../../src/components/toggle-button/toggle-icon-button.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"toggle-icon-button.d.ts","sourceRoot":"","sources":["../../../../src/components/toggle-button/toggle-icon-button.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAwB,KAAK,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAE/F,MAAM,WAAW,qBACf,SAAQ,IAAI,CAAC,qBAAqB,EAAE,YAAY,CAAC,EAC/C,IAAI,CAAC,qBAAqB,EAAE,YAAY,CAAC;IAC3C,uIAAuI;IACvI,YAAY,EAAE,MAAM,CAAC;CACtB;AAaD;;;;;GAKG;AACH,QAAA,MAAM,iBAAiB,0KAAmE,CAAC;AAE3F,OAAO,EAAE,iBAAiB,IAAI,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
4
|
+
exports.ToggleIconButton = void 0;
|
|
8
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
-
const clsx_1 =
|
|
10
|
-
const react_aria_components_1 = require("react-aria-components");
|
|
6
|
+
const clsx_1 = require("clsx");
|
|
11
7
|
const forward_ref_js_1 = require("../../forward-ref.js");
|
|
12
8
|
const with_style_props_js_1 = require("../../with-style-props.js");
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
const internal_toggle_button_js_1 = require("./internal-toggle-button.js");
|
|
10
|
+
function ToggleIconButton({ icon, UNSAFE_className, ...props }, ref) {
|
|
11
|
+
return ((0, jsx_runtime_1.jsx)(internal_toggle_button_js_1.InternalToggleButton, { ...props, buttonRef: ref, UNSAFE_className: (0, clsx_1.clsx)('cim-icon-button', UNSAFE_className), children: icon }));
|
|
15
12
|
}
|
|
16
13
|
/**
|
|
17
14
|
* Displays an icon-only button that allows users to toggle between two states.
|
|
@@ -19,6 +16,6 @@ function UNSTABLE_ToggleIconButton({ icon, size = 'medium', isDisabled, fullWidt
|
|
|
19
16
|
*
|
|
20
17
|
* See [toggle button usage guidelines](https://ui.cimpress.io/components/toggle-button/).
|
|
21
18
|
*/
|
|
22
|
-
const
|
|
23
|
-
exports.
|
|
19
|
+
const _ToggleIconButton = (0, with_style_props_js_1.withStyleProps)((0, forward_ref_js_1.forwardRef)(ToggleIconButton), 'ToggleIconButton');
|
|
20
|
+
exports.ToggleIconButton = _ToggleIconButton;
|
|
24
21
|
//# sourceMappingURL=toggle-icon-button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-icon-button.js","sourceRoot":"","sources":["../../../../src/components/toggle-button/toggle-icon-button.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"toggle-icon-button.js","sourceRoot":"","sources":["../../../../src/components/toggle-button/toggle-icon-button.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;AAEb,+BAA4B;AAE5B,yDAAkD;AAClD,mEAA2D;AAE3D,2EAA+F;AAS/F,SAAS,gBAAgB,CACvB,EAAE,IAAI,EAAE,gBAAgB,EAAE,GAAG,KAAK,EAAyB,EAC3D,GAAoC;IAEpC,OAAO,CACL,uBAAC,gDAAoB,OAAK,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,gBAAgB,EAAE,IAAA,WAAI,EAAC,iBAAiB,EAAE,gBAAgB,CAAC,YACzG,IAAI,GACgB,CACxB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,IAAA,oCAAc,EAAC,IAAA,2BAAU,EAAC,gBAAgB,CAAC,EAAE,kBAAkB,CAAC,CAAC;AAE7D,6CAAgB","sourcesContent":["'use client';\n\nimport { clsx } from 'clsx';\nimport type { ForwardedRef } from 'react';\nimport { forwardRef } from '../../forward-ref.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport type { SingleIconButtonProps } from '../button/types.js';\nimport { InternalToggleButton, type BaseToggleButtonProps } from './internal-toggle-button.js';\n\nexport interface ToggleIconButtonProps\n extends Omit<BaseToggleButtonProps, 'aria-label'>,\n Omit<SingleIconButtonProps, 'aria-label'> {\n /** The label describing the function of this button for assistive technologies. Must remain the same regardless of selection state. */\n 'aria-label': string;\n}\n\nfunction ToggleIconButton(\n { icon, UNSAFE_className, ...props }: ToggleIconButtonProps,\n ref: ForwardedRef<HTMLButtonElement>,\n) {\n return (\n <InternalToggleButton {...props} buttonRef={ref} UNSAFE_className={clsx('cim-icon-button', UNSAFE_className)}>\n {icon}\n </InternalToggleButton>\n );\n}\n\n/**\n * Displays an icon-only button that allows users to toggle between two states.\n * Can be used standalone, or as part of `ToggleButtonGroup`.\n *\n * See [toggle button usage guidelines](https://ui.cimpress.io/components/toggle-button/).\n */\nconst _ToggleIconButton = withStyleProps(forwardRef(ToggleIconButton), 'ToggleIconButton');\n\nexport { _ToggleIconButton as ToggleIconButton };\n"]}
|
|
@@ -82,7 +82,13 @@ export type FieldError = string | string[] | undefined | ((validation: Validatio
|
|
|
82
82
|
/** Props available on form field components. */
|
|
83
83
|
export interface FieldProps<T> extends LabellableProps {
|
|
84
84
|
/**
|
|
85
|
-
* The
|
|
85
|
+
* The `<form>` element to associate the input with.
|
|
86
|
+
* The value of this attribute must be the id of a `<form>` in the same document.
|
|
87
|
+
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).
|
|
88
|
+
*/
|
|
89
|
+
form?: string;
|
|
90
|
+
/**
|
|
91
|
+
* The name of the input element, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#name).
|
|
86
92
|
*/
|
|
87
93
|
name?: string;
|
|
88
94
|
/** A description for the field. Provides a hint such as specific requirements for what to choose. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.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AChC,MAAM,WAAW,SAAU,SAAQ,WAAW,EAAE,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,iBAAiB,CAAC;IACvG;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,sCAAsC;IACtC,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IACpB,4BAA4B;IAC5B,IAAI,CAAC,EAAE,cAAc,CAAC;CACvB;AAED,+CAA+C;AAC/C,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,WAAW,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;IAClF,CAAC,QAAQ,EAAE,QAAQ,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;CACrE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { focusSafely } from '@react-aria/focus';\nimport type { CSSProperties, HTMLAttributes, ReactNode } from 'react';\nimport type {\n ButtonProps as RACButtonProps,\n LinkProps as RACLinkProps,\n PressEvent as RACPressEvent,\n ValidationResult as RACValidationResult,\n} from 'react-aria-components';\nimport type { ForegroundTone } from '../utils/style/types.js';\n\n/** Represents an identifier for a collection item. */\nexport type Key = string | number;\n\n/** Represents a selection of items in a collection. */\nexport type Selection = 'all' | Set<Key>;\n\n/** Represents a direction (vertical or horizontal). */\nexport type Direction = 'vertical' | 'horizontal';\n\n/**\n * Use this type when you want to restrict `children` to a string,\n * but also want to allow expressions that resolve to strings.\n */\nexport type StringLikeChildren = string | number | (string | number)[];\n\n// `FocusableElement` is not exported from any React Aria package\n/** Any focusable element, including both HTML and SVG elements. */\nexport type FocusableElement = Parameters<typeof focusSafely>[0];\n\n/**\n * A set of common props that are allowed on every component\n */\nexport interface CommonProps {\n /**\n * The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).\n */\n id?: string;\n /**\n * Use this attribute to \"claim\" the component tree for exclusive Cimpress UI usage.\n */\n 'data-cim-style-root'?: boolean;\n /**\n * Sets the CSS className for the element. Only use as a **last resort**. Use style props instead.\n *\n * See [styling guide](https://ui.cimpress.io/dev-guides/styling/).\n */\n UNSAFE_className?: string;\n /**\n * Sets the CSS style for the element. Only use as a **last resort**. Use style props instead.\n *\n * See [styling guide](https://ui.cimpress.io/dev-guides/styling/).\n */\n UNSAFE_style?: CSSProperties;\n}\n\n/**\n * An event fired when a component is pressed.\n *\n * By default, press events stop propagation to parent elements.\n * In cases where a handler decides not to handle a specific event,\n * it can call `continuePropagation()` to allow a parent to handle it.\n */\nexport type PressEvent = RACPressEvent;\n\n// HoverEvent is not exported from react-aria-components\n/** An event fired when a component is hovered. */\nexport type HoverEvent = Parameters<NonNullable<RACButtonProps['onHoverStart']>>[0];\n\n/**\n * Props for components that require a label, which can be hidden if necessary.\n */\nexport interface LabellableProps extends AriaLabelingProps {\n /** The content to display as the label. */\n label?: string;\n}\n\n// Copied from AriaLabelingProps from @react-types/shared\nexport interface AriaLabelingProps {\n /**\n * Defines a string value that labels the current element.\n */\n 'aria-label'?: string;\n\n /**\n * Identifies the element (or elements) that labels the current element.\n */\n 'aria-labelledby'?: string;\n\n /**\n * Identifies the element (or elements) that describes the object.\n */\n 'aria-describedby'?: string;\n\n /**\n * Identifies the element (or elements) that provide a detailed, extended description for the object.\n */\n 'aria-details'?: string;\n}\n\n/** Provides details about the validation state of a form field. */\nexport type ValidationResult = RACValidationResult;\n\n/** Represents the error message(s) for a form field. */\nexport type FieldError =\n | string\n | string[]\n | undefined\n | ((validation: ValidationResult) => string | string[] | undefined);\n\n/** Props available on form field components. */\nexport interface FieldProps<T> extends LabellableProps {\n /**\n * The name of the input element, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { focusSafely } from '@react-aria/focus';\nimport type { CSSProperties, HTMLAttributes, ReactNode } from 'react';\nimport type {\n ButtonProps as RACButtonProps,\n LinkProps as RACLinkProps,\n PressEvent as RACPressEvent,\n ValidationResult as RACValidationResult,\n} from 'react-aria-components';\nimport type { ForegroundTone } from '../utils/style/types.js';\n\n/** Represents an identifier for a collection item. */\nexport type Key = string | number;\n\n/** Represents a selection of items in a collection. */\nexport type Selection = 'all' | Set<Key>;\n\n/** Represents a direction (vertical or horizontal). */\nexport type Direction = 'vertical' | 'horizontal';\n\n/**\n * Use this type when you want to restrict `children` to a string,\n * but also want to allow expressions that resolve to strings.\n */\nexport type StringLikeChildren = string | number | (string | number)[];\n\n// `FocusableElement` is not exported from any React Aria package\n/** Any focusable element, including both HTML and SVG elements. */\nexport type FocusableElement = Parameters<typeof focusSafely>[0];\n\n/**\n * A set of common props that are allowed on every component\n */\nexport interface CommonProps {\n /**\n * The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).\n */\n id?: string;\n /**\n * Use this attribute to \"claim\" the component tree for exclusive Cimpress UI usage.\n */\n 'data-cim-style-root'?: boolean;\n /**\n * Sets the CSS className for the element. Only use as a **last resort**. Use style props instead.\n *\n * See [styling guide](https://ui.cimpress.io/dev-guides/styling/).\n */\n UNSAFE_className?: string;\n /**\n * Sets the CSS style for the element. Only use as a **last resort**. Use style props instead.\n *\n * See [styling guide](https://ui.cimpress.io/dev-guides/styling/).\n */\n UNSAFE_style?: CSSProperties;\n}\n\n/**\n * An event fired when a component is pressed.\n *\n * By default, press events stop propagation to parent elements.\n * In cases where a handler decides not to handle a specific event,\n * it can call `continuePropagation()` to allow a parent to handle it.\n */\nexport type PressEvent = RACPressEvent;\n\n// HoverEvent is not exported from react-aria-components\n/** An event fired when a component is hovered. */\nexport type HoverEvent = Parameters<NonNullable<RACButtonProps['onHoverStart']>>[0];\n\n/**\n * Props for components that require a label, which can be hidden if necessary.\n */\nexport interface LabellableProps extends AriaLabelingProps {\n /** The content to display as the label. */\n label?: string;\n}\n\n// Copied from AriaLabelingProps from @react-types/shared\nexport interface AriaLabelingProps {\n /**\n * Defines a string value that labels the current element.\n */\n 'aria-label'?: string;\n\n /**\n * Identifies the element (or elements) that labels the current element.\n */\n 'aria-labelledby'?: string;\n\n /**\n * Identifies the element (or elements) that describes the object.\n */\n 'aria-describedby'?: string;\n\n /**\n * Identifies the element (or elements) that provide a detailed, extended description for the object.\n */\n 'aria-details'?: string;\n}\n\n/** Provides details about the validation state of a form field. */\nexport type ValidationResult = RACValidationResult;\n\n/** Represents the error message(s) for a form field. */\nexport type FieldError =\n | string\n | string[]\n | undefined\n | ((validation: ValidationResult) => string | string[] | undefined);\n\n/** Props available on form field components. */\nexport interface FieldProps<T> extends LabellableProps {\n /**\n * The `<form>` element to associate the input with.\n * The value of this attribute must be the id of a `<form>` in the same document.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).\n */\n form?: string;\n /**\n * The name of the input element, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#name).\n */\n name?: string;\n /** A description for the field. Provides a hint such as specific requirements for what to choose. */\n description?: string;\n /** An error message for the field. */\n error?: FieldError;\n /**\n * A function that returns an error message (or `true`) if a given value is invalid.\n * Validation errors are displayed to the user when the form is submitted.\n * For real-time validation, use the `error` prop instead.\n */\n validate?: (value: T) => string | string[] | true | undefined;\n}\n\n/** Props available on form field components with text inputs. */\nexport interface FieldWithPlaceholderProps<T> extends FieldProps<T> {\n /** The placeholder text displayed in the input field. */\n placeholder?: string;\n}\n\n/** Changes specified optional properties within the provided type to be required. */\nexport type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };\n\n/**\n * This interface allows configuring navigation props with router options and type-safe URLs via TypeScript module augmentation.\n * By default, this is an empty interface. Extend with `href` and `routerOptions` properties to configure your router.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface RouterConfig {}\n\n/**\n * Represents a URL for navigation components.\n * This type can be configured by augmenting `RouterConfig` with an `href` property.\n */\nexport type Href = RouterConfig extends { href: infer H } ? H : string;\n\n/**\n * Represents router options for navigation components.\n * This type can be configured by augmenting `RouterConfig` with a `routerOptions` property.\n */\nexport type RouterOptions = RouterConfig extends { routerOptions: infer O } ? O : never;\n\n/**\n * Props available on components that perform navigation.\n */\nexport interface NavigationProps\n extends Pick<RACLinkProps, 'hrefLang' | 'target' | 'rel' | 'download' | 'ping' | 'referrerPolicy'> {\n /** A URL to link to. */\n href?: Href;\n /** Options for the configured client side router. */\n routerOptions?: RouterOptions;\n}\n\n/** Represents a minimal data shape of a dynamic item in collection components. */\nexport interface CollectionItem {\n /** Unique identifier for the item or group. */\n id: Key;\n}\n\n/** Props available on components that render collections. */\nexport interface CollectionProps<T extends CollectionItem> {\n /** The contents of the collection. */\n children?: ReactNode | ((item: T) => ReactNode);\n /** The items to display in the collection. */\n items?: Iterable<T>;\n}\n\n/** Props available on icons. */\nexport interface IconProps extends CommonProps, Pick<AriaLabelingProps, 'aria-label' | 'aria-labelledby'> {\n /**\n * Whether the icon is hidden from assistive technologies.\n * @default true\n */\n 'aria-hidden'?: boolean;\n /** The size of the icon in pixels. */\n size?: 16 | 24 | 32;\n /** The tone of the icon. */\n tone?: ForegroundTone;\n}\n\n/** Props available on native HTML elements. */\nexport interface NativeElementProps<T extends HTMLElement> extends HTMLAttributes<T> {\n [dataProp: `data-${string}`]: string | number | boolean | undefined;\n}\n"]}
|