@cimpress-ui/react 1.9.2 → 1.11.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/copy/copy-button.d.ts +10 -5
- package/dist/commonjs/components/copy/copy-button.d.ts.map +1 -1
- package/dist/commonjs/components/copy/copy-button.js +18 -13
- package/dist/commonjs/components/copy/copy-button.js.map +1 -1
- package/dist/commonjs/components/copy/copy-inline.d.ts +17 -0
- package/dist/commonjs/components/copy/copy-inline.d.ts.map +1 -0
- package/dist/commonjs/components/copy/{inline-copy.js → copy-inline.js} +15 -10
- package/dist/commonjs/components/copy/copy-inline.js.map +1 -0
- package/dist/commonjs/components/internal/input/input.d.ts +8 -0
- package/dist/commonjs/components/internal/input/input.d.ts.map +1 -0
- package/dist/commonjs/components/internal/input/input.js +36 -0
- package/dist/commonjs/components/internal/input/input.js.map +1 -0
- package/dist/commonjs/components/number-field/number-field.d.ts.map +1 -1
- package/dist/commonjs/components/number-field/number-field.js +2 -2
- package/dist/commonjs/components/number-field/number-field.js.map +1 -1
- package/dist/commonjs/components/slider/slider.d.ts +34 -0
- package/dist/commonjs/components/slider/slider.d.ts.map +1 -0
- package/dist/commonjs/components/slider/slider.js +60 -0
- package/dist/commonjs/components/slider/slider.js.map +1 -0
- package/dist/commonjs/components/stepper/stepper-item.d.ts +6 -6
- package/dist/commonjs/components/stepper/stepper-item.d.ts.map +1 -1
- package/dist/commonjs/components/stepper/stepper-item.js +35 -27
- package/dist/commonjs/components/stepper/stepper-item.js.map +1 -1
- package/dist/commonjs/components/stepper/stepper.d.ts +1 -1
- package/dist/commonjs/components/stepper/stepper.d.ts.map +1 -1
- package/dist/commonjs/components/stepper/stepper.js +2 -2
- package/dist/commonjs/components/stepper/stepper.js.map +1 -1
- package/dist/commonjs/components/stepper/types.d.ts +1 -1
- package/dist/commonjs/components/stepper/types.d.ts.map +1 -1
- package/dist/commonjs/components/stepper/types.js.map +1 -1
- package/dist/commonjs/i18n/messages/en-US.d.ts.map +1 -1
- package/dist/commonjs/i18n/messages/en-US.js +1 -0
- package/dist/commonjs/i18n/messages/en-US.js.map +1 -1
- package/dist/commonjs/i18n/messages/types.d.ts +6 -0
- package/dist/commonjs/i18n/messages/types.d.ts.map +1 -1
- package/dist/commonjs/i18n/messages/types.js.map +1 -1
- package/dist/commonjs/index.d.ts +3 -2
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +3 -2
- package/dist/commonjs/index.js.map +1 -1
- package/dist/esm/components/copy/copy-button.d.ts +10 -5
- package/dist/esm/components/copy/copy-button.d.ts.map +1 -1
- package/dist/esm/components/copy/copy-button.js +15 -10
- package/dist/esm/components/copy/copy-button.js.map +1 -1
- package/dist/esm/components/copy/copy-inline.d.ts +17 -0
- package/dist/esm/components/copy/copy-inline.d.ts.map +1 -0
- package/dist/esm/components/copy/{inline-copy.js → copy-inline.js} +13 -8
- package/dist/esm/components/copy/copy-inline.js.map +1 -0
- package/dist/esm/components/internal/input/input.d.ts +8 -0
- package/dist/esm/components/internal/input/input.d.ts.map +1 -0
- package/dist/esm/components/internal/input/input.js +30 -0
- package/dist/esm/components/internal/input/input.js.map +1 -0
- package/dist/esm/components/number-field/number-field.d.ts.map +1 -1
- package/dist/esm/components/number-field/number-field.js +2 -2
- package/dist/esm/components/number-field/number-field.js.map +1 -1
- package/dist/esm/components/slider/slider.d.ts +34 -0
- package/dist/esm/components/slider/slider.d.ts.map +1 -0
- package/dist/esm/components/slider/slider.js +54 -0
- package/dist/esm/components/slider/slider.js.map +1 -0
- package/dist/esm/components/stepper/stepper-item.d.ts +6 -6
- package/dist/esm/components/stepper/stepper-item.d.ts.map +1 -1
- package/dist/esm/components/stepper/stepper-item.js +35 -27
- package/dist/esm/components/stepper/stepper-item.js.map +1 -1
- package/dist/esm/components/stepper/stepper.d.ts +1 -1
- package/dist/esm/components/stepper/stepper.d.ts.map +1 -1
- package/dist/esm/components/stepper/stepper.js +2 -2
- package/dist/esm/components/stepper/stepper.js.map +1 -1
- package/dist/esm/components/stepper/types.d.ts +1 -1
- package/dist/esm/components/stepper/types.d.ts.map +1 -1
- package/dist/esm/components/stepper/types.js.map +1 -1
- package/dist/esm/i18n/messages/en-US.d.ts.map +1 -1
- package/dist/esm/i18n/messages/en-US.js +1 -0
- package/dist/esm/i18n/messages/en-US.js.map +1 -1
- package/dist/esm/i18n/messages/types.d.ts +6 -0
- package/dist/esm/i18n/messages/types.d.ts.map +1 -1
- package/dist/esm/i18n/messages/types.js.map +1 -1
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -2
- 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 +1 -1
- package/dist/commonjs/components/copy/inline-copy.d.ts +0 -12
- package/dist/commonjs/components/copy/inline-copy.d.ts.map +0 -1
- package/dist/commonjs/components/copy/inline-copy.js.map +0 -1
- package/dist/esm/components/copy/inline-copy.d.ts +0 -12
- package/dist/esm/components/copy/inline-copy.d.ts.map +0 -1
- package/dist/esm/components/copy/inline-copy.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ActionButtonProps, BaseButtonProps } from '../button/types.js';
|
|
2
2
|
import type { AriaLabelingProps, CommonProps, StringLikeChildren } from '../types.js';
|
|
3
|
-
export interface
|
|
3
|
+
export interface CopyButtonProps extends CommonProps, AriaLabelingProps, Pick<BaseButtonProps, 'size'>, Pick<ActionButtonProps, 'isDisabled' | 'onHoverStart' | 'onHoverEnd'> {
|
|
4
4
|
/** The text displayed on the button. */
|
|
5
5
|
children?: StringLikeChildren;
|
|
6
6
|
/**
|
|
@@ -10,11 +10,16 @@ export interface UNSTABLE_CopyButtonProps extends CommonProps, AriaLabelingProps
|
|
|
10
10
|
variant?: 'secondary' | 'tertiary';
|
|
11
11
|
/** The content to be copied. */
|
|
12
12
|
value: string;
|
|
13
|
-
/** The
|
|
14
|
-
|
|
13
|
+
/** The description that appears in a tooltip when the user hovers or focuses the button. */
|
|
14
|
+
description?: string;
|
|
15
15
|
/** A handler that gets called when the user triggers the copying. */
|
|
16
16
|
onCopy?: () => void;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Displays a button that allows users to copy a specific value to clipboard.
|
|
20
|
+
*
|
|
21
|
+
* See [copy button usage guidelines](https://ui.cimpress.io/components/copy-button/).
|
|
22
|
+
*/
|
|
23
|
+
declare const _CopyButton: (props: CopyButtonProps & import("react").RefAttributes<HTMLButtonElement> & import("../../with-style-props.js").StyleProps) => import("react").JSX.Element | null;
|
|
24
|
+
export { _CopyButton as CopyButton };
|
|
20
25
|
//# sourceMappingURL=copy-button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-button.d.ts","sourceRoot":"","sources":["../../../../src/components/copy/copy-button.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"copy-button.d.ts","sourceRoot":"","sources":["../../../../src/components/copy/copy-button.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGtF,MAAM,WAAW,eACf,SAAQ,WAAW,EACjB,iBAAiB,EACjB,IAAI,CAAC,eAAe,EAAE,MAAM,CAAC,EAC7B,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,cAAc,GAAG,YAAY,CAAC;IACvE,wCAAwC;IACxC,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;IACnC,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,4FAA4F;IAC5F,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAuDD;;;;GAIG;AACH,QAAA,MAAM,WAAW,oKAAuD,CAAC;AAEzE,OAAO,EAAE,WAAW,IAAI,UAAU,EAAE,CAAC"}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
exports.CopyButton = void 0;
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
const react_aria_components_1 = require("react-aria-components");
|
|
8
8
|
const forward_ref_js_1 = require("../../forward-ref.js");
|
|
9
|
-
const index_js_1 = require("../../
|
|
9
|
+
const index_js_1 = require("../../i18n/index.js");
|
|
10
|
+
const index_js_2 = require("../../icons/index.js");
|
|
10
11
|
const use_production_warning_js_1 = require("../../utils/use-production-warning.js");
|
|
11
12
|
const with_style_props_js_1 = require("../../with-style-props.js");
|
|
12
13
|
const button_js_1 = require("../button/button.js");
|
|
13
14
|
const icon_button_js_1 = require("../button/icon-button.js");
|
|
14
15
|
const tooltip_js_1 = require("../tooltip/tooltip.js");
|
|
15
16
|
const use_copy_js_1 = require("./use-copy.js");
|
|
16
|
-
function
|
|
17
|
+
function CopyButton({ onCopy, description, ...props }, ref) {
|
|
17
18
|
const [copyStatus, showCopyFeedback, copyToClipboard] = (0, use_copy_js_1.useCopyToClipboard)();
|
|
18
19
|
const [showCopyFeedbackLabel, setShowCopyFeedbackLabel] = (0, react_1.useState)(showCopyFeedback);
|
|
19
20
|
(0, react_1.useEffect)(() => {
|
|
@@ -41,19 +42,23 @@ function UNSTABLE_CopyButton({ onCopy, helpText, ...props }, ref) {
|
|
|
41
42
|
copyToClipboard(props.value);
|
|
42
43
|
onCopy?.();
|
|
43
44
|
};
|
|
44
|
-
|
|
45
|
+
const messages = (0, index_js_1.useLocalizedMessages)('copyToClipboard');
|
|
46
|
+
return ((0, jsx_runtime_1.jsx)(tooltip_js_1.Tooltip, { isDisabled: props.isDisabled || (!showCopyFeedback && !description), label: showCopyFeedbackLabel
|
|
45
47
|
? copyStatus?.success
|
|
46
|
-
?
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
: (helpText ?? ''), placement: "top", children: (0, jsx_runtime_1.jsx)(CopyButtonInner, { ...props, buttonRef: ref, onCopy: onPress, showCopyFeedback: showCopyFeedback }) }));
|
|
48
|
+
? messages.format('success')
|
|
49
|
+
: messages.format('failure')
|
|
50
|
+
: (description ?? ''), placement: "top", children: (0, jsx_runtime_1.jsx)(CopyButtonInner, { ...props, buttonRef: ref, onCopy: onPress, showCopyFeedback: showCopyFeedback }) }));
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Displays a button that allows users to copy a specific value to clipboard.
|
|
54
|
+
*
|
|
55
|
+
* See [copy button usage guidelines](https://ui.cimpress.io/components/copy-button/).
|
|
56
|
+
*/
|
|
57
|
+
const _CopyButton = (0, with_style_props_js_1.withStyleProps)((0, forward_ref_js_1.forwardRef)(CopyButton), 'CopyButton');
|
|
58
|
+
exports.CopyButton = _CopyButton;
|
|
54
59
|
function CopyButtonInner({ UNSAFE_className, UNSAFE_style, children, value, onCopy, buttonRef, showCopyFeedback, ...props }) {
|
|
55
60
|
const tooltipTriggerState = (0, react_1.useContext)(react_aria_components_1.TooltipTriggerStateContext);
|
|
56
|
-
const icon = showCopyFeedback ? (0, jsx_runtime_1.jsx)(
|
|
61
|
+
const icon = showCopyFeedback ? (0, jsx_runtime_1.jsx)(index_js_2.IconCheckCircle, {}) : (0, jsx_runtime_1.jsx)(index_js_2.IconCopy, {});
|
|
57
62
|
(0, react_1.useEffect)(() => {
|
|
58
63
|
if (showCopyFeedback) {
|
|
59
64
|
tooltipTriggerState?.open(true);
|
|
@@ -63,6 +68,6 @@ function CopyButtonInner({ UNSAFE_className, UNSAFE_style, children, value, onCo
|
|
|
63
68
|
}
|
|
64
69
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
65
70
|
}, [showCopyFeedback]);
|
|
66
|
-
return children ? ((0, jsx_runtime_1.jsx)(button_js_1.Button, { ...props, ref: buttonRef, iconStart: icon, tone: "base", onPress: onCopy, children: children })) : ((0, jsx_runtime_1.jsx)(icon_button_js_1.IconButton, { ...props, ref: buttonRef, icon: icon, tone: "base", "aria-label": props['aria-label'] ?? '', onPress: onCopy }));
|
|
71
|
+
return children ? ((0, jsx_runtime_1.jsx)(button_js_1.Button, { ...props, ref: buttonRef, type: "button", iconStart: icon, tone: "base", onPress: onCopy, children: children })) : ((0, jsx_runtime_1.jsx)(icon_button_js_1.IconButton, { ...props, ref: buttonRef, type: "button", icon: icon, tone: "base", "aria-label": props['aria-label'] ?? '', onPress: onCopy }));
|
|
67
72
|
}
|
|
68
73
|
//# sourceMappingURL=copy-button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-button.js","sourceRoot":"","sources":["../../../../src/components/copy/copy-button.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;AAEb,iCAA2E;AAC3E,iEAAoG;AACpG,yDAAkD;AAClD,mDAAiE;AACjE,qFAA6E;AAC7E,mEAA2D;AAC3D,mDAA6C;AAC7C,6DAAsD;AAEtD,sDAAgD;AAEhD,+CAAmD;AAsBnD,SAAS,
|
|
1
|
+
{"version":3,"file":"copy-button.js","sourceRoot":"","sources":["../../../../src/components/copy/copy-button.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;AAEb,iCAA2E;AAC3E,iEAAoG;AACpG,yDAAkD;AAClD,kDAA2D;AAC3D,mDAAiE;AACjE,qFAA6E;AAC7E,mEAA2D;AAC3D,mDAA6C;AAC7C,6DAAsD;AAEtD,sDAAgD;AAEhD,+CAAmD;AAsBnD,SAAS,UAAU,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,EAAmB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,CAAC,CAChB,uBAAC,kBAAM,OAAK,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAC,MAAM,EAAC,OAAO,EAAE,MAAM,YAC1F,QAAQ,GACF,CACV,CAAC,CAAC,CAAC,CACF,uBAAC,2BAAU,OACL,KAAK,EACT,GAAG,EAAE,SAAS,EACd,IAAI,EAAC,QAAQ,EACb,IAAI,EAAE,IAAI,EACV,IAAI,EAAC,MAAM,gBACC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,EACrC,OAAO,EAAE,MAAM,GACf,CACH,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport { useContext, useEffect, useState, type ForwardedRef } from 'react';\nimport { TooltipTriggerStateContext as RACTooltipTriggerStateContext } from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useLocalizedMessages } from '../../i18n/index.js';\nimport { IconCheckCircle, IconCopy } from '../../icons/index.js';\nimport { useProductionWarning } from '../../utils/use-production-warning.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport { Button } from '../button/button.js';\nimport { IconButton } from '../button/icon-button.js';\nimport type { ActionButtonProps, BaseButtonProps } from '../button/types.js';\nimport { Tooltip } from '../tooltip/tooltip.js';\nimport type { AriaLabelingProps, CommonProps, StringLikeChildren } from '../types.js';\nimport { useCopyToClipboard } from './use-copy.js';\n\nexport interface CopyButtonProps\n extends CommonProps,\n AriaLabelingProps,\n Pick<BaseButtonProps, 'size'>,\n Pick<ActionButtonProps, 'isDisabled' | 'onHoverStart' | 'onHoverEnd'> {\n /** The text displayed on the button. */\n children?: StringLikeChildren;\n /**\n * Determines the visual appearance of the button.\n * @default 'secondary'\n */\n variant?: 'secondary' | 'tertiary';\n /** The content to be copied. */\n value: string;\n /** The description that appears in a tooltip when the user hovers or focuses the button. */\n description?: string;\n /** A handler that gets called when the user triggers the copying. */\n onCopy?: () => void;\n}\n\nfunction CopyButton({ onCopy, description, ...props }: CopyButtonProps, ref: ForwardedRef<HTMLButtonElement>) {\n const [copyStatus, showCopyFeedback, copyToClipboard] = useCopyToClipboard();\n const [showCopyFeedbackLabel, setShowCopyFeedbackLabel] = useState(showCopyFeedback);\n\n useEffect(() => {\n let labelChangeTimeout: ReturnType<typeof setTimeout> | undefined;\n\n if (showCopyFeedback) {\n setShowCopyFeedbackLabel(true);\n } else {\n // Wait until the tooltip has animated away before changing the label\n labelChangeTimeout = setTimeout(() => setShowCopyFeedbackLabel(false), 200);\n }\n\n return () => {\n if (labelChangeTimeout) {\n clearTimeout(labelChangeTimeout);\n }\n };\n }, [showCopyFeedback]);\n\n const { children, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;\n\n useProductionWarning(() => {\n if (!children && !ariaLabel && !ariaLabelledBy) {\n console.warn('CopyButton requires one of children / aria-label / aria-labelledby for accessibility');\n }\n }, [children, ariaLabel, ariaLabelledBy]);\n\n const onPress = () => {\n copyToClipboard(props.value);\n onCopy?.();\n };\n\n const messages = useLocalizedMessages('copyToClipboard');\n\n return (\n <Tooltip\n isDisabled={props.isDisabled || (!showCopyFeedback && !description)}\n label={\n showCopyFeedbackLabel\n ? copyStatus?.success\n ? messages.format('success')\n : messages.format('failure')\n : (description ?? '')\n }\n placement=\"top\"\n >\n <CopyButtonInner {...props} buttonRef={ref} onCopy={onPress} showCopyFeedback={showCopyFeedback} />\n </Tooltip>\n );\n}\n\n/**\n * Displays a button that allows users to copy a specific value to clipboard.\n *\n * See [copy button usage guidelines](https://ui.cimpress.io/components/copy-button/).\n */\nconst _CopyButton = withStyleProps(forwardRef(CopyButton), 'CopyButton');\n\nexport { _CopyButton as CopyButton };\n\nfunction CopyButtonInner({\n UNSAFE_className,\n UNSAFE_style,\n children,\n value,\n onCopy,\n buttonRef,\n showCopyFeedback,\n ...props\n}: Omit<CopyButtonProps, 'description'> & {\n buttonRef: ForwardedRef<HTMLButtonElement>;\n showCopyFeedback: boolean;\n}) {\n const tooltipTriggerState = useContext(RACTooltipTriggerStateContext);\n\n const icon = showCopyFeedback ? <IconCheckCircle /> : <IconCopy />;\n\n useEffect(() => {\n if (showCopyFeedback) {\n tooltipTriggerState?.open(true);\n } else {\n tooltipTriggerState?.close(true);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [showCopyFeedback]);\n\n return children ? (\n <Button {...props} ref={buttonRef} type=\"button\" iconStart={icon} tone=\"base\" onPress={onCopy}>\n {children}\n </Button>\n ) : (\n <IconButton\n {...props}\n ref={buttonRef}\n type=\"button\"\n icon={icon}\n tone=\"base\"\n aria-label={props['aria-label'] ?? ''}\n onPress={onCopy}\n />\n );\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ActionButtonProps } from '../button/types.js';
|
|
2
|
+
import type { AriaLabelingProps, CommonProps, StringLikeChildren } from '../types.js';
|
|
3
|
+
import type { TextStyleOptions } from '../typography/types.js';
|
|
4
|
+
export interface CopyInlineProps extends CommonProps, AriaLabelingProps, Pick<TextStyleOptions, 'variant'>, Pick<ActionButtonProps, 'isDisabled' | 'onHoverStart' | 'onHoverEnd'> {
|
|
5
|
+
/** The content to be copied. */
|
|
6
|
+
children: StringLikeChildren;
|
|
7
|
+
/** A handler that gets called when the user triggers the copying. */
|
|
8
|
+
onCopy?: () => void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Allows copying an inline value to clipboard.
|
|
12
|
+
*
|
|
13
|
+
* See [copy inline usage guidelines](https://ui.cimpress.io/components/copy-inline/).
|
|
14
|
+
*/
|
|
15
|
+
declare const _CopyInline: (props: CopyInlineProps & import("react").RefAttributes<HTMLButtonElement> & import("../../with-style-props.js").StyleProps) => import("react").JSX.Element | null;
|
|
16
|
+
export { _CopyInline as CopyInline };
|
|
17
|
+
//# sourceMappingURL=copy-inline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-inline.d.ts","sourceRoot":"","sources":["../../../../src/components/copy/copy-inline.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAO/D,MAAM,WAAW,eACf,SAAQ,WAAW,EACjB,iBAAiB,EACjB,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,EACjC,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,cAAc,GAAG,YAAY,CAAC;IACvE,gCAAgC;IAChC,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AA0CD;;;;GAIG;AACH,QAAA,MAAM,WAAW,oKAAuD,CAAC;AAEzE,OAAO,EAAE,WAAW,IAAI,UAAU,EAAE,CAAC"}
|
|
@@ -4,30 +4,35 @@ 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.CopyInline = void 0;
|
|
8
8
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
9
|
const clsx_1 = __importDefault(require("clsx"));
|
|
10
10
|
const react_1 = require("react");
|
|
11
11
|
const react_aria_components_1 = require("react-aria-components");
|
|
12
12
|
const forward_ref_js_1 = require("../../forward-ref.js");
|
|
13
|
-
const index_js_1 = require("../../
|
|
13
|
+
const index_js_1 = require("../../i18n/index.js");
|
|
14
|
+
const index_js_2 = require("../../icons/index.js");
|
|
14
15
|
const with_style_props_js_1 = require("../../with-style-props.js");
|
|
15
16
|
const tooltip_js_1 = require("../tooltip/tooltip.js");
|
|
16
17
|
const utils_js_1 = require("../typography/utils.js");
|
|
17
18
|
const use_copy_js_1 = require("./use-copy.js");
|
|
18
19
|
// Used to prevent word wrap between icons and text
|
|
19
20
|
const WORD_JOINER = '\u2060';
|
|
20
|
-
function
|
|
21
|
+
function CopyInline({ children, UNSAFE_className, UNSAFE_style, variant, onCopy, ...props }, ref) {
|
|
21
22
|
const tooltipTriggerRef = (0, react_1.useRef)(null);
|
|
22
23
|
const [copyStatus, showCopyFeedback, copyToClipboard] = (0, use_copy_js_1.useCopyToClipboard)();
|
|
23
24
|
const textValue = typeof children === 'string' ? children : typeof children === 'number' ? String(children) : children.join('');
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
label: copyStatus?.success ? 'Copied to clipboard.' : 'Failed to copy to clipboard.', placement: "top", triggerRef: tooltipTriggerRef, children: (0, jsx_runtime_1.jsxs)(react_aria_components_1.Button, { ...props, ref: ref, className: (0, clsx_1.default)('cim-inline-copy', (0, utils_js_1.textStyle)({ variant, tone, fontStyle }), UNSAFE_className), style: UNSAFE_style, onPress: () => {
|
|
25
|
+
const messages = (0, index_js_1.useLocalizedMessages)('copyToClipboard');
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(tooltip_js_1.Tooltip, { isOpen: showCopyFeedback, isDisabled: props.isDisabled, label: copyStatus?.success ? messages.format('success') : messages.format('failure'), placement: "top", triggerRef: tooltipTriggerRef, children: (0, jsx_runtime_1.jsxs)(react_aria_components_1.Button, { ...props, ref: ref, className: (0, clsx_1.default)('cim-copy-inline', (0, utils_js_1.textStyle)({ variant, tone: 'base' }), UNSAFE_className), style: UNSAFE_style, onPress: () => {
|
|
27
27
|
copyToClipboard(textValue);
|
|
28
28
|
onCopy?.();
|
|
29
|
-
}, children: [(0, jsx_runtime_1.jsx)("span", { className: "cim-inline-
|
|
29
|
+
}, children: [(0, jsx_runtime_1.jsx)("span", { className: "cim-copy-inline-text", children: children }), WORD_JOINER, (0, jsx_runtime_1.jsx)("span", { className: "cim-copy-inline-icon", ref: tooltipTriggerRef, children: showCopyFeedback ? (0, jsx_runtime_1.jsx)(index_js_2.IconCheckCircle, {}) : (0, jsx_runtime_1.jsx)(index_js_2.IconCopy, {}) })] }) }));
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Allows copying an inline value to clipboard.
|
|
33
|
+
*
|
|
34
|
+
* See [copy inline usage guidelines](https://ui.cimpress.io/components/copy-inline/).
|
|
35
|
+
*/
|
|
36
|
+
const _CopyInline = (0, with_style_props_js_1.withStyleProps)((0, forward_ref_js_1.forwardRef)(CopyInline), 'CopyInline');
|
|
37
|
+
exports.CopyInline = _CopyInline;
|
|
38
|
+
//# sourceMappingURL=copy-inline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-inline.js","sourceRoot":"","sources":["../../../../src/components/copy/copy-inline.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,gDAAwB;AACxB,iCAAkD;AAClD,iEAA4D;AAC5D,yDAAkD;AAClD,kDAA2D;AAC3D,mDAAiE;AACjE,mEAA2D;AAE3D,sDAAgD;AAGhD,qDAAmD;AACnD,+CAAmD;AAEnD,mDAAmD;AACnD,MAAM,WAAW,GAAG,QAAQ,CAAC;AAa7B,SAAS,UAAU,CACjB,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,KAAK,EAAmB,EACxF,GAAoC;IAEpC,MAAM,iBAAiB,GAAG,IAAA,cAAM,EAAkB,IAAI,CAAC,CAAC;IACxD,MAAM,CAAC,UAAU,EAAE,gBAAgB,EAAE,eAAe,CAAC,GAAG,IAAA,gCAAkB,GAAE,CAAC;IAE7E,MAAM,SAAS,GACb,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEhH,MAAM,QAAQ,GAAG,IAAA,+BAAoB,EAAC,iBAAiB,CAAC,CAAC;IAEzD,OAAO,CACL,uBAAC,oBAAO,IACN,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE,KAAK,CAAC,UAAU,EAC5B,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,EACpF,SAAS,EAAC,KAAK,EACf,UAAU,EAAE,iBAAiB,YAE7B,wBAAC,8BAAS,OACJ,KAAK,EACT,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,IAAA,cAAI,EAAC,iBAAiB,EAAE,IAAA,oBAAS,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,gBAAgB,CAAC,EAC1F,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,GAAG,EAAE;gBACZ,eAAe,CAAC,SAAS,CAAC,CAAC;gBAC3B,MAAM,EAAE,EAAE,CAAC;YACb,CAAC,aAED,iCAAM,SAAS,EAAC,sBAAsB,YAAE,QAAQ,GAAQ,EACvD,WAAW,EACZ,iCAAM,SAAS,EAAC,sBAAsB,EAAC,GAAG,EAAE,iBAAiB,YAC1D,gBAAgB,CAAC,CAAC,CAAC,uBAAC,0BAAe,KAAG,CAAC,CAAC,CAAC,uBAAC,mBAAQ,KAAG,GACjD,IACG,GACJ,CACX,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,WAAW,GAAG,IAAA,oCAAc,EAAC,IAAA,2BAAU,EAAC,UAAU,CAAC,EAAE,YAAY,CAAC,CAAC;AAEjD,iCAAU","sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { useRef, type ForwardedRef } from 'react';\nimport { Button as RACButton } from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useLocalizedMessages } from '../../i18n/index.js';\nimport { IconCheckCircle, IconCopy } from '../../icons/index.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport type { ActionButtonProps } from '../button/types.js';\nimport { Tooltip } from '../tooltip/tooltip.js';\nimport type { AriaLabelingProps, CommonProps, StringLikeChildren } from '../types.js';\nimport type { TextStyleOptions } from '../typography/types.js';\nimport { textStyle } from '../typography/utils.js';\nimport { useCopyToClipboard } from './use-copy.js';\n\n// Used to prevent word wrap between icons and text\nconst WORD_JOINER = '\\u2060';\n\nexport interface CopyInlineProps\n extends CommonProps,\n AriaLabelingProps,\n Pick<TextStyleOptions, 'variant'>,\n Pick<ActionButtonProps, 'isDisabled' | 'onHoverStart' | 'onHoverEnd'> {\n /** The content to be copied. */\n children: StringLikeChildren;\n /** A handler that gets called when the user triggers the copying. */\n onCopy?: () => void;\n}\n\nfunction CopyInline(\n { children, UNSAFE_className, UNSAFE_style, variant, onCopy, ...props }: CopyInlineProps,\n ref: ForwardedRef<HTMLButtonElement>,\n) {\n const tooltipTriggerRef = useRef<HTMLSpanElement>(null);\n const [copyStatus, showCopyFeedback, copyToClipboard] = useCopyToClipboard();\n\n const textValue =\n typeof children === 'string' ? children : typeof children === 'number' ? String(children) : children.join('');\n\n const messages = useLocalizedMessages('copyToClipboard');\n\n return (\n <Tooltip\n isOpen={showCopyFeedback}\n isDisabled={props.isDisabled}\n label={copyStatus?.success ? messages.format('success') : messages.format('failure')}\n placement=\"top\"\n triggerRef={tooltipTriggerRef}\n >\n <RACButton\n {...props}\n ref={ref}\n className={clsx('cim-copy-inline', textStyle({ variant, tone: 'base' }), UNSAFE_className)}\n style={UNSAFE_style}\n onPress={() => {\n copyToClipboard(textValue);\n onCopy?.();\n }}\n >\n <span className=\"cim-copy-inline-text\">{children}</span>\n {WORD_JOINER}\n <span className=\"cim-copy-inline-icon\" ref={tooltipTriggerRef}>\n {showCopyFeedback ? <IconCheckCircle /> : <IconCopy />}\n </span>\n </RACButton>\n </Tooltip>\n );\n}\n\n/**\n * Allows copying an inline value to clipboard.\n *\n * See [copy inline usage guidelines](https://ui.cimpress.io/components/copy-inline/).\n */\nconst _CopyInline = withStyleProps(forwardRef(CopyInline), 'CopyInline');\n\nexport { _CopyInline as CopyInline };\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type InputProps as RACInputProps } from 'react-aria-components';
|
|
2
|
+
import type { CommonProps } from '../../types.js';
|
|
3
|
+
interface InputProps extends CommonProps, Exclude<RACInputProps, 'className' | 'style'> {
|
|
4
|
+
width?: 'fit-content' | 'full-width';
|
|
5
|
+
}
|
|
6
|
+
export declare function Input(props: InputProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../../../src/components/internal/input/input.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAqB,KAAK,UAAU,IAAI,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC5F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD,UAAU,UAAW,SAAQ,WAAW,EAAE,OAAO,CAAC,aAAa,EAAE,WAAW,GAAG,OAAO,CAAC;IACrF,KAAK,CAAC,EAAE,aAAa,GAAG,YAAY,CAAC;CACtC;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,2CAqDtC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
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.Input = Input;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const utils_1 = require("@react-aria/utils");
|
|
9
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
10
|
+
const react_1 = require("react");
|
|
11
|
+
const react_aria_components_1 = require("react-aria-components");
|
|
12
|
+
const utils_js_1 = require("../../typography/utils.js");
|
|
13
|
+
function Input(props) {
|
|
14
|
+
const inputRef = (0, react_1.useRef)(null);
|
|
15
|
+
// TODO: find a better way to extract common props, if a new prop is added to `CommonProps` this will break
|
|
16
|
+
const { id, UNSAFE_className, UNSAFE_style, 'data-cim-style-root': dataCimStyleRoot, width, ...inputProps } = props;
|
|
17
|
+
// Field sizing based on input length for browsers that don't support `field-sizing: content`
|
|
18
|
+
(0, utils_1.useLayoutEffect)(() => {
|
|
19
|
+
const input = inputRef.current;
|
|
20
|
+
function setInputLengthStyle() {
|
|
21
|
+
// Ensure input value changes are flushed before updating input width, especially in Safari
|
|
22
|
+
requestAnimationFrame(() => input?.style.setProperty('--cim-input-length', input?.value.length.toString() ?? '0'));
|
|
23
|
+
}
|
|
24
|
+
if (input != null) {
|
|
25
|
+
setInputLengthStyle();
|
|
26
|
+
input.addEventListener('input', setInputLengthStyle);
|
|
27
|
+
input.addEventListener('change', setInputLengthStyle);
|
|
28
|
+
}
|
|
29
|
+
return () => {
|
|
30
|
+
input?.removeEventListener('input', setInputLengthStyle);
|
|
31
|
+
input?.removeEventListener('change', setInputLengthStyle);
|
|
32
|
+
};
|
|
33
|
+
}, []);
|
|
34
|
+
return ((0, jsx_runtime_1.jsx)("div", { id: id, className: (0, clsx_1.default)('cim-input', UNSAFE_className), style: UNSAFE_style, "data-cim-style-root": dataCimStyleRoot, children: (0, jsx_runtime_1.jsx)(react_aria_components_1.Input, { ...inputProps, ref: inputRef, className: (0, clsx_1.default)('cim-input-control', (0, utils_js_1.textStyle)({ variant: 'body' })), "data-width": width }) }));
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../../../../src/components/internal/input/input.tsx"],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gB,YAErC,uBAAC,6BAAQ,OACH,UAAU,EACd,GAAG,EAAE,QAAQ,EACb,SAAS,EAAE,IAAA,cAAI,EAAC,mBAAmB,EAAE,IAAA,oBAAS,EAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,gBACxD,KAAK,GACjB,GACE,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useLayoutEffect } from '@react-aria/utils';\nimport clsx from 'clsx';\nimport { useRef } from 'react';\nimport { Input as RACInput, type InputProps as RACInputProps } from 'react-aria-components';\nimport type { CommonProps } from '../../types.js';\nimport { textStyle } from '../../typography/utils.js';\n\ninterface InputProps extends CommonProps, Exclude<RACInputProps, 'className' | 'style'> {\n width?: 'fit-content' | 'full-width';\n}\n\nexport function Input(props: InputProps) {\n const inputRef = useRef<HTMLInputElement>(null);\n // TODO: find a better way to extract common props, if a new prop is added to `CommonProps` this will break\n const {\n id,\n UNSAFE_className,\n UNSAFE_style,\n 'data-cim-style-root': dataCimStyleRoot,\n\n width,\n\n ...inputProps\n } = props;\n\n // Field sizing based on input length for browsers that don't support `field-sizing: content`\n useLayoutEffect(() => {\n const input = inputRef.current;\n\n function setInputLengthStyle() {\n // Ensure input value changes are flushed before updating input width, especially in Safari\n requestAnimationFrame(() =>\n input?.style.setProperty('--cim-input-length', input?.value.length.toString() ?? '0'),\n );\n }\n\n if (input != null) {\n setInputLengthStyle();\n\n input.addEventListener('input', setInputLengthStyle);\n input.addEventListener('change', setInputLengthStyle);\n }\n\n return () => {\n input?.removeEventListener('input', setInputLengthStyle);\n input?.removeEventListener('change', setInputLengthStyle);\n };\n }, []);\n\n return (\n <div\n id={id}\n className={clsx('cim-input', UNSAFE_className)}\n style={UNSAFE_style}\n data-cim-style-root={dataCimStyleRoot}\n >\n <RACInput\n {...inputProps}\n ref={inputRef}\n className={clsx('cim-input-control', textStyle({ variant: 'body' }))}\n data-width={width}\n />\n </div>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-field.d.ts","sourceRoot":"","sources":["../../../../src/components/number-field/number-field.tsx"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,gBAAgB,IAAI,mBAAmB,EAE7C,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAGpF,MAAM,WAAW,gBACf,SAAQ,WAAW,EACjB,yBAAyB,CAAC,MAAM,CAAC,EACjC,QAAQ,CAAC,cAAc,CAAC,EACxB,IAAI,CACF,mBAAmB,EACjB,YAAY,GACZ,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,WAAW,GACX,UAAU,GACV,UAAU,GACV,MAAM,GACN,eAAe,GACf,SAAS,GACT,QAAQ,GACR,WAAW,CACd;IACH,2EAA2E;IAC3E,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,6EAA6E;IAC7E,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,0FAA0F;IAC1F,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"number-field.d.ts","sourceRoot":"","sources":["../../../../src/components/number-field/number-field.tsx"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,gBAAgB,IAAI,mBAAmB,EAE7C,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAGpF,MAAM,WAAW,gBACf,SAAQ,WAAW,EACjB,yBAAyB,CAAC,MAAM,CAAC,EACjC,QAAQ,CAAC,cAAc,CAAC,EACxB,IAAI,CACF,mBAAmB,EACjB,YAAY,GACZ,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,WAAW,GACX,UAAU,GACV,UAAU,GACV,MAAM,GACN,eAAe,GACf,SAAS,GACT,QAAQ,GACR,WAAW,CACd;IACH,2EAA2E;IAC3E,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,6EAA6E;IAC7E,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,0FAA0F;IAC1F,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CAG3C;AAED,iEAAiE;AACjE,MAAM,WAAW,cAAc;IAC7B,+BAA+B;IAC/B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,+CAA+C;IAC/C,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAwFD;;;;GAIG;AACH,QAAA,MAAM,YAAY,kKAAyD,CAAC;AAE5E,OAAO,EAAE,YAAY,IAAI,WAAW,EAAE,CAAC"}
|
|
@@ -17,7 +17,7 @@ const with_style_props_js_1 = require("../../with-style-props.js");
|
|
|
17
17
|
const icon_button_js_1 = require("../button/icon-button.js");
|
|
18
18
|
const form_field_js_1 = require("../internal/form-field/form-field.js");
|
|
19
19
|
const utils_js_1 = require("../typography/utils.js");
|
|
20
|
-
function NumberField({ label, description, error: errorMessage, placeholder, UNSAFE_className, UNSAFE_style, value, defaultValue, onChange, apiRef, ...props }, ref) {
|
|
20
|
+
function NumberField({ label, description, error: errorMessage, placeholder, UNSAFE_className, UNSAFE_style, value, defaultValue, onChange, apiRef, UNSTABLE_hideSpinner, ...props }, ref) {
|
|
21
21
|
const inputRef = (0, react_1.useRef)(null);
|
|
22
22
|
const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;
|
|
23
23
|
(0, use_production_warning_js_1.useProductionWarning)(() => {
|
|
@@ -34,7 +34,7 @@ function NumberField({ label, description, error: errorMessage, placeholder, UNS
|
|
|
34
34
|
// NumberField uses `NaN` to signify an empty value, which is unintuitive
|
|
35
35
|
// https://github.com/adobe/react-spectrum/issues/5524
|
|
36
36
|
// https://github.com/adobe/react-spectrum/issues/6971
|
|
37
|
-
value: value === null ? Number.NaN : value, defaultValue: defaultValue === null ? Number.NaN : defaultValue, onChange: onChange ? (value) => onChange(Number.isNaN(value) ? null : value) : undefined, children: [(0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldLabel, { isRequired: props.isRequired, isDisabled: props.isDisabled, children: label }), (0, jsx_runtime_1.jsxs)(react_aria_components_1.Group, { className: "cim-number-field-input-group", children: [(0, jsx_runtime_1.jsx)(react_aria_components_1.Input, { ref: inputRef, className: (0, clsx_1.default)('cim-number-field-input', (0, utils_js_1.textStyle)({ variant: 'body' })), placeholder: placeholder }), (0, jsx_runtime_1.jsxs)("div", { className: "cim-number-field-spinner", children: [(0, jsx_runtime_1.jsx)(icon_button_js_1.IconButton, { slot: "decrement", icon: (0, jsx_runtime_1.jsx)(index_js_2.IconSubtract, {}), "aria-label": messages.format('decrement'), variant: "tertiary", size: "small" }), (0, jsx_runtime_1.jsx)("div", { className: "cim-number-field-spinner-separator" }), (0, jsx_runtime_1.jsx)(icon_button_js_1.IconButton, { slot: "increment", icon: (0, jsx_runtime_1.jsx)(index_js_2.IconAdd, {}), "aria-label": messages.format('increment'), variant: "tertiary", size: "small" })] })] }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldError, { children: errorMessage }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldDescription, { children: description })] }));
|
|
37
|
+
value: value === null ? Number.NaN : value, defaultValue: defaultValue === null ? Number.NaN : defaultValue, onChange: onChange ? (value) => onChange(Number.isNaN(value) ? null : value) : undefined, children: [(0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldLabel, { isRequired: props.isRequired, isDisabled: props.isDisabled, children: label }), (0, jsx_runtime_1.jsxs)(react_aria_components_1.Group, { className: "cim-number-field-input-group", children: [(0, jsx_runtime_1.jsx)(react_aria_components_1.Input, { ref: inputRef, className: (0, clsx_1.default)('cim-number-field-input', (0, utils_js_1.textStyle)({ variant: 'body' })), placeholder: placeholder }), !UNSTABLE_hideSpinner && ((0, jsx_runtime_1.jsxs)("div", { className: "cim-number-field-spinner", children: [(0, jsx_runtime_1.jsx)(icon_button_js_1.IconButton, { slot: "decrement", icon: (0, jsx_runtime_1.jsx)(index_js_2.IconSubtract, {}), "aria-label": messages.format('decrement'), variant: "tertiary", size: "small" }), (0, jsx_runtime_1.jsx)("div", { className: "cim-number-field-spinner-separator" }), (0, jsx_runtime_1.jsx)(icon_button_js_1.IconButton, { slot: "increment", icon: (0, jsx_runtime_1.jsx)(index_js_2.IconAdd, {}), "aria-label": messages.format('increment'), variant: "tertiary", size: "small" })] }))] }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldError, { children: errorMessage }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldDescription, { children: description })] }));
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Allows users to edit a number with a keyboard or increment/decrement buttons.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-field.js","sourceRoot":"","sources":["../../../../src/components/number-field/number-field.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,gDAAwB;AACxB,iCAAuE;AACvE,iEAK+B;AAC/B,yDAAkD;AAClD,kDAA2D;AAC3D,mDAA6D;AAC7D,qFAA6E;AAC7E,mEAA2D;AAC3D,6DAAsD;AACtD,wEAA4G;AAE5G,qDAAmD;
|
|
1
|
+
{"version":3,"file":"number-field.js","sourceRoot":"","sources":["../../../../src/components/number-field/number-field.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,gDAAwB;AACxB,iCAAuE;AACvE,iEAK+B;AAC/B,yDAAkD;AAClD,kDAA2D;AAC3D,mDAA6D;AAC7D,qFAA6E;AAC7E,mEAA2D;AAC3D,6DAAsD;AACtD,wEAA4G;AAE5G,qDAAmD;AAuCnD,SAAS,WAAW,CAClB,EACE,KAAK,EACL,WAAW,EACX,KAAK,EAAE,YAAY,EACnB,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,KAAK,EACL,YAAY,EACZ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ardedRef, useImperativeHandle, useRef } from 'react';\nimport {\n Input as RACInput,\n NumberField as RACNumberField,\n type NumberFieldProps as RACNumberFieldProps,\n Group as RACGroup,\n} from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useLocalizedMessages } from '../../i18n/index.js';\nimport { IconAdd, IconSubtract } from '../../icons/index.js';\nimport { useProductionWarning } from '../../utils/use-production-warning.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport { IconButton } from '../button/icon-button.js';\nimport { FormFieldDescription, FormFieldError, FormFieldLabel } from '../internal/form-field/form-field.js';\nimport type { ApiProps, CommonProps, FieldWithPlaceholderProps } from '../types.js';\nimport { textStyle } from '../typography/utils.js';\n\nexport interface NumberFieldProps\n extends CommonProps,\n FieldWithPlaceholderProps<number>,\n ApiProps<NumberFieldApi>,\n Pick<\n RACNumberFieldProps,\n | 'isDisabled'\n | 'isRequired'\n | 'isInvalid'\n | 'isReadOnly'\n | 'autoFocus'\n | 'minValue'\n | 'maxValue'\n | 'step'\n | 'formatOptions'\n | 'onFocus'\n | 'onBlur'\n | 'onKeyDown'\n > {\n /** The current value (controlled). A `null` value means an empty field. */\n value?: number | null;\n /** The default value (uncontrolled). A `null` value means an empty field. */\n defaultValue?: number | null;\n /** Handler that is called when the value changes. A `null` value means an empty field. */\n onChange?: (value: number | null) => void;\n /** @internal */\n UNSTABLE_hideSpinner?: boolean;\n}\n\n/** The imperative API exposed by the `NumberField` component. */\nexport interface NumberFieldApi {\n /** Focuses the input field. */\n focus: () => void;\n /** Selects the contents of the input field. */\n select: () => void;\n}\n\nfunction NumberField(\n {\n label,\n description,\n error: errorMessage,\n placeholder,\n UNSAFE_className,\n UNSAFE_style,\n value,\n defaultValue,\n onChange,\n apiRef,\n UNSTABLE_hideSpinner,\n ...props\n }: NumberFieldProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const inputRef = useRef<HTMLInputElement>(null);\n\n const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;\n\n useProductionWarning(() => {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn('NumberField requires one of label / aria-label / aria-labelledby for accessibility');\n }\n }, [label, ariaLabel, ariaLabelledBy]);\n\n const messages = useLocalizedMessages('numberField');\n\n useImperativeHandle(\n apiRef,\n () => ({\n focus: () => inputRef.current?.focus(),\n select: () => inputRef.current?.select(),\n }),\n [],\n );\n\n return (\n <RACNumberField\n {...props}\n ref={ref}\n className={clsx('cim-number-field', UNSAFE_className)}\n style={UNSAFE_style}\n // NumberField uses `NaN` to signify an empty value, which is unintuitive\n // https://github.com/adobe/react-spectrum/issues/5524\n // https://github.com/adobe/react-spectrum/issues/6971\n value={value === null ? Number.NaN : value}\n defaultValue={defaultValue === null ? Number.NaN : defaultValue}\n onChange={onChange ? (value) => onChange(Number.isNaN(value) ? null : value) : undefined}\n >\n <FormFieldLabel isRequired={props.isRequired} isDisabled={props.isDisabled}>\n {label}\n </FormFieldLabel>\n <RACGroup className=\"cim-number-field-input-group\">\n <RACInput\n ref={inputRef}\n className={clsx('cim-number-field-input', textStyle({ variant: 'body' }))}\n placeholder={placeholder}\n />\n {!UNSTABLE_hideSpinner && (\n <div className=\"cim-number-field-spinner\">\n <IconButton\n slot=\"decrement\"\n icon={<IconSubtract />}\n aria-label={messages.format('decrement')}\n variant=\"tertiary\"\n size=\"small\"\n />\n <div className=\"cim-number-field-spinner-separator\" />\n <IconButton\n slot=\"increment\"\n icon={<IconAdd />}\n aria-label={messages.format('increment')}\n variant=\"tertiary\"\n size=\"small\"\n />\n </div>\n )}\n </RACGroup>\n <FormFieldError>{errorMessage}</FormFieldError>\n <FormFieldDescription>{description}</FormFieldDescription>\n </RACNumberField>\n );\n}\n\n/**\n * Allows users to edit a number with a keyboard or increment/decrement buttons.\n *\n * See [number field usage guidelines](https://ui.cimpress.io/components/number-field/).\n */\nconst _NumberField = withStyleProps(forwardRef(NumberField), 'NumberField');\n\nexport { _NumberField as NumberField };\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type SliderProps as RACSliderProps } from 'react-aria-components';
|
|
2
|
+
import type { CommonProps, LabellableProps } from '../types.js';
|
|
3
|
+
export interface UNSTABLE_SliderProps<T extends number | number[] = number> extends CommonProps, LabellableProps, Pick<RACSliderProps<T>, 'isDisabled' | 'minValue' | 'maxValue' | 'step'> {
|
|
4
|
+
/** A description for the field. Provides a hint such as specific requirements for what to choose. */
|
|
5
|
+
description?: string;
|
|
6
|
+
/** The current value (controlled). */
|
|
7
|
+
value?: T;
|
|
8
|
+
/** The default value (uncontrolled). */
|
|
9
|
+
defaultValue?: T;
|
|
10
|
+
/** Handler that is called when the value changes. */
|
|
11
|
+
onChange?: (value: T) => void;
|
|
12
|
+
/** Handler that is called when the slider stops moving. */
|
|
13
|
+
onChangeEnd?: (value: T) => void;
|
|
14
|
+
/**
|
|
15
|
+
* The `<form>` element to associate the input with.
|
|
16
|
+
* The value of this attribute must be the id of a `<form>` in the same document.
|
|
17
|
+
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).
|
|
18
|
+
*/
|
|
19
|
+
form?: string;
|
|
20
|
+
/**
|
|
21
|
+
* 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).
|
|
22
|
+
*/
|
|
23
|
+
name?: T extends number[] ? string[] : string;
|
|
24
|
+
/** Show input fields for slider values. */
|
|
25
|
+
withInput?: boolean;
|
|
26
|
+
/** Show static labels for minimum and maximum values. */
|
|
27
|
+
showLabels?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Allows users to select one or more values within a range.
|
|
31
|
+
*/
|
|
32
|
+
declare const _UNSTABLE_Slider: <T extends number | number[] = number>(props: UNSTABLE_SliderProps<T> & import("react").RefAttributes<HTMLDivElement> & import("../../with-style-props.js").StyleProps) => import("react").JSX.Element | null;
|
|
33
|
+
export { _UNSTABLE_Slider as UNSTABLE_Slider };
|
|
34
|
+
//# sourceMappingURL=slider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slider.d.ts","sourceRoot":"","sources":["../../../../src/components/slider/slider.tsx"],"names":[],"mappings":"AAKA,OAAO,EAYL,KAAK,WAAW,IAAI,cAAc,EACnC,MAAM,uBAAuB,CAAC;AAM/B,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAShE,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,CACxE,SAAQ,WAAW,EACjB,eAAe,EACf,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC;IAC1E,qGAAqG;IACrG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sCAAsC;IACtC,KAAK,CAAC,EAAE,CAAC,CAAC;IACV,wCAAwC;IACxC,YAAY,CAAC,EAAE,CAAC,CAAC;IACjB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC9B,2DAA2D;IAC3D,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IACjC;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,CAAC,EAAE,CAAC,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;IAC9C,2CAA2C;IAC3C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yDAAyD;IACzD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAiKD;;GAEG;AACH,QAAA,MAAM,gBAAgB,GAlKG,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,iLAkK0B,CAAC;AAE/E,OAAO,EAAE,gBAAgB,IAAI,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.UNSTABLE_Slider = void 0;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const utils_1 = require("@react-aria/utils");
|
|
10
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
11
|
+
const react_1 = require("react");
|
|
12
|
+
const react_aria_components_1 = require("react-aria-components");
|
|
13
|
+
const forward_ref_js_1 = require("../../forward-ref.js");
|
|
14
|
+
const use_production_warning_js_1 = require("../../utils/use-production-warning.js");
|
|
15
|
+
const with_style_props_js_1 = require("../../with-style-props.js");
|
|
16
|
+
const form_field_js_1 = require("../internal/form-field/form-field.js");
|
|
17
|
+
const input_js_1 = require("../internal/input/input.js");
|
|
18
|
+
const text_js_1 = require("../typography/text.js");
|
|
19
|
+
// TODO: move to translations when stabilized
|
|
20
|
+
const sliderStrings = {
|
|
21
|
+
srMinimum: 'minimum',
|
|
22
|
+
srMaximum: 'maximum',
|
|
23
|
+
};
|
|
24
|
+
function UNSTABLE_Slider({ label, description, UNSAFE_className, UNSAFE_style, form, name, withInput, showLabels, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, ...props }, ref) {
|
|
25
|
+
const descriptionId = (0, utils_1.useId)();
|
|
26
|
+
(0, use_production_warning_js_1.useProductionWarning)(() => {
|
|
27
|
+
if (!label && !ariaLabel && !ariaLabelledBy) {
|
|
28
|
+
console.warn('Slider requires one of label / aria-label / aria-labelledby for accessibility');
|
|
29
|
+
}
|
|
30
|
+
}, [label, ariaLabel, ariaLabelledBy]);
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)(react_aria_components_1.Provider, { values: [[react_aria_components_1.TextContext, { slots: { description: { id: descriptionId } } }]], children: (0, jsx_runtime_1.jsx)(react_aria_components_1.Slider, { ...props, ref: ref, className: (0, clsx_1.default)('cim-slider', UNSAFE_className), style: UNSAFE_style, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, orientation: "horizontal", "aria-describedby": [description && descriptionId, props['aria-describedby']].filter(Boolean).join(' '), children: ({ state, isDisabled }) => {
|
|
32
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldLabel, { isRequired: false, isDisabled: isDisabled, children: label }), !withInput && label != null && ((0, jsx_runtime_1.jsx)(react_aria_components_1.SliderOutput, { className: "cim-slider-output", children: (0, jsx_runtime_1.jsx)(text_js_1.Text, { as: "span", variant: "medium", children: state.values.map((_, i) => state.getThumbValueLabel(i)).join(' – ') }) })), (0, jsx_runtime_1.jsxs)("div", { className: "cim-slider-track-container", children: [showLabels && ((0, jsx_runtime_1.jsx)(text_js_1.Text, { as: "span", variant: "medium", UNSAFE_className: "cim-slider-label-min", children: state.getThumbMinValue(0) })), (0, jsx_runtime_1.jsx)(react_aria_components_1.SliderTrack, { className: "cim-slider-track", children: ({ state: trackState, isDisabled: trackIsDisabled }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "cim-slider-track-background", "data-disabled": trackIsDisabled || undefined }), (0, jsx_runtime_1.jsx)("div", { className: "cim-slider-fill", style: (state.values.length === 1
|
|
33
|
+
? {
|
|
34
|
+
'--cim-slider-fill-size': trackState.getThumbPercent(0) * 100 + '%',
|
|
35
|
+
}
|
|
36
|
+
: state.values.length === 2
|
|
37
|
+
? {
|
|
38
|
+
'--cim-slider-fill-start': trackState.getThumbPercent(0) * 100 + '%',
|
|
39
|
+
'--cim-slider-fill-size': (trackState.getThumbPercent(1) - trackState.getThumbPercent(0)) * 100 + '%',
|
|
40
|
+
}
|
|
41
|
+
: {}) }), trackState.values.map((_, i) => ((0, jsx_runtime_1.jsx)(SliderThumb, { index: i, name: typeof name === 'string' ? name : name?.[i], form: form }, i)))] })) }), showLabels && ((0, jsx_runtime_1.jsx)(text_js_1.Text, { as: "span", variant: "medium", UNSAFE_className: "cim-slider-label-max", children: state.getThumbMaxValue(state.values.length - 1) })), withInput && ((0, jsx_runtime_1.jsx)("div", { className: "cim-slider-inputs-container-wide", children: state.values.map((_, i) => ((0, jsx_runtime_1.jsx)(SliderNumberField, { index: i, style: { order: state.values.length === 2 ? (i === 0 ? -1 : 1) : undefined }, children: (0, jsx_runtime_1.jsx)(input_js_1.Input, { width: "fit-content" }) }, i))) }))] }), withInput && ((0, jsx_runtime_1.jsx)("div", { className: "cim-slider-inputs-container-narrow", children: state.values.map((_, i) => ((0, jsx_runtime_1.jsx)(SliderNumberField, { index: i, children: (0, jsx_runtime_1.jsx)(input_js_1.Input, {}) }, i))) })), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldDescription, { children: description })] }));
|
|
42
|
+
} }) }));
|
|
43
|
+
}
|
|
44
|
+
// eslint-disable-next-line react-refresh/only-export-components
|
|
45
|
+
function SliderNumberField({ index, ...props }) {
|
|
46
|
+
const state = (0, react_1.useContext)(react_aria_components_1.SliderStateContext);
|
|
47
|
+
const labelProps = (0, react_aria_components_1.useSlottedContext)(react_aria_components_1.LabelContext);
|
|
48
|
+
return ((0, jsx_runtime_1.jsx)(react_aria_components_1.NumberField, { ...props, className: "cim-slider-input", value: state.values[index], onChange: (value) => state.setThumbValue(index, value ?? 0), "aria-labelledby": labelProps.id, "aria-label": state.values.length === 2 ? (index === 0 ? sliderStrings.srMinimum : sliderStrings.srMaximum) : undefined }));
|
|
49
|
+
}
|
|
50
|
+
// eslint-disable-next-line react-refresh/only-export-components
|
|
51
|
+
function SliderThumb({ index, name, form }) {
|
|
52
|
+
const state = (0, react_1.useContext)(react_aria_components_1.SliderStateContext);
|
|
53
|
+
return ((0, jsx_runtime_1.jsx)(react_aria_components_1.SliderThumb, { index: index, className: "cim-slider-thumb", name: typeof name === 'string' ? name : name?.[index], form: form, "aria-label": state.values.length === 2 ? (index === 0 ? sliderStrings.srMinimum : sliderStrings.srMaximum) : undefined }));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Allows users to select one or more values within a range.
|
|
57
|
+
*/
|
|
58
|
+
const _UNSTABLE_Slider = (0, with_style_props_js_1.withStyleProps)((0, forward_ref_js_1.forwardRef)(UNSTABLE_Slider), 'Slider');
|
|
59
|
+
exports.UNSTABLE_Slider = _UNSTABLE_Slider;
|
|
60
|
+
//# sourceMappingURL=slider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slider.js","sourceRoot":"","sources":["../../../../src/components/slider/slider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,6CAA0C;AAC1C,gDAAwB;AACxB,iCAAsD;AACtD,iEAa+B;AAC/B,yDAAkD;AAClD,qFAA6E;AAC7E,mEAA2D;AAC3D,wEAA4F;AAC5F,yDAAmD;AAEnD,mDAA6C;AAE7C,6CAA6C;AAC7C,MAAM,aAAa,GAAG;IACpB,SAAS,EAAE,SAAS;IACpB,SAAS,EAAE,SAAS;CACrB,CAAC;AAgCF,SAAS,eAAe,CACtB,EACE,KAAK,EACL,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,UAAU,EACV,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,EACjC,GAAG,KAAK,EACgB,EAC1B,GAAiC;IAEjC,MAAM,aAAa,GAAG,IAAA,aAAK,GAAE,CAAC;IAE9B,IAAA,gDAAoB,EAAC,GAAG,EAAE;QACxB,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,IAAI,CAAC,cAAc,EAAE,CAAC;YAC5C,OAAO,CAAC,IAAI,CAAC,+EAA+E,CAAC,CAAC;QAChG,CAAC;IACH,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,cAAc,CAAC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C,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,IAAI,CAAC,CAAC,qBAC1C,UAAU,CAAC,EAAE,gBAE5B,KAAK,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,GAE3G,CACH,CAAC;AACJ,CAAC;AAED,gEAAgE;AAChE,SAAS,WAAW,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAA8D;IACpG,MAAM,KAAK,GAAG,IAAA,kBAAU,EAAC,0CAAqB,CAAE,CAAC;IAEjD,OAAO,CACL,uBAAC,mCAAc,IACb,KAAK,EAAE,KAAK,EACZ,SAAS,EAAC,kBAAkB,EAC5B,IAAI,EAAE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,EACrD,IAAI,EAAE,IAAI,gBAER,KAAK,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,GAE3G,CACH,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,gBAAgB,GAAG,IAAA,oCAAc,EAAC,IAAA,2BAAU,EAAC,eAAe,CAAC,EAAE,QAAQ,CAAC,CAAC;AAElD,2CAAe","sourcesContent":["'use client';\n\nimport { useId } from '@react-aria/utils';\nimport clsx from 'clsx';\nimport { useContext, type ForwardedRef } from 'react';\nimport {\n LabelContext as RACLabelContext,\n NumberField as RACNumberField,\n Provider as RACProvider,\n Slider as RACSlider,\n SliderOutput as RACSliderOutput,\n SliderStateContext as RACSliderStateContext,\n SliderThumb as RACSliderThumb,\n SliderTrack as RACSliderTrack,\n TextContext as RACTextContext,\n useSlottedContext,\n type NumberFieldProps as RACNumberFieldProps,\n type SliderProps as RACSliderProps,\n} from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useProductionWarning } from '../../utils/use-production-warning.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport { FormFieldDescription, FormFieldLabel } from '../internal/form-field/form-field.js';\nimport { Input } from '../internal/input/input.js';\nimport type { CommonProps, LabellableProps } from '../types.js';\nimport { Text } from '../typography/text.js';\n\n// TODO: move to translations when stabilized\nconst sliderStrings = {\n srMinimum: 'minimum',\n srMaximum: 'maximum',\n};\n\nexport interface UNSTABLE_SliderProps<T extends number | number[] = number>\n extends CommonProps,\n LabellableProps,\n Pick<RACSliderProps<T>, 'isDisabled' | 'minValue' | 'maxValue' | 'step'> {\n /** A description for the field. Provides a hint such as specific requirements for what to choose. */\n description?: string;\n /** The current value (controlled). */\n value?: T;\n /** The default value (uncontrolled). */\n defaultValue?: T;\n /** Handler that is called when the value changes. */\n onChange?: (value: T) => void;\n /** Handler that is called when the slider stops moving. */\n onChangeEnd?: (value: T) => void;\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?: T extends number[] ? string[] : string;\n /** Show input fields for slider values. */\n withInput?: boolean;\n /** Show static labels for minimum and maximum values. */\n showLabels?: boolean;\n}\n\nfunction UNSTABLE_Slider<T extends number | number[] = number>(\n {\n label,\n description,\n UNSAFE_className,\n UNSAFE_style,\n form,\n name,\n withInput,\n showLabels,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n ...props\n }: UNSTABLE_SliderProps<T>,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descriptionId = useId();\n\n useProductionWarning(() => {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn('Slider requires one of label / aria-label / aria-labelledby for accessibility');\n }\n }, [label, ariaLabel, ariaLabelledBy]);\n\n return (\n <RACProvider values={[[RACTextContext, { slots: { description: { id: descriptionId } } }]]}>\n <RACSlider\n {...props}\n ref={ref}\n className={clsx('cim-slider', UNSAFE_className)}\n style={UNSAFE_style}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n orientation=\"horizontal\"\n aria-describedby={[description && descriptionId, props['aria-describedby']].filter(Boolean).join(' ')}\n >\n {({ state, isDisabled }) => {\n return (\n <>\n <FormFieldLabel isRequired={false} isDisabled={isDisabled}>\n {label}\n </FormFieldLabel>\n {!withInput && label != null && (\n <RACSliderOutput className=\"cim-slider-output\">\n <Text as=\"span\" variant=\"medium\">\n {state.values.map((_, i) => state.getThumbValueLabel(i)).join(' – ')}\n </Text>\n </RACSliderOutput>\n )}\n <div className=\"cim-slider-track-container\">\n {showLabels && (\n <Text as=\"span\" variant=\"medium\" UNSAFE_className=\"cim-slider-label-min\">\n {state.getThumbMinValue(0)}\n </Text>\n )}\n\n <RACSliderTrack className=\"cim-slider-track\">\n {({ state: trackState, isDisabled: trackIsDisabled }) => (\n <>\n <div className=\"cim-slider-track-background\" data-disabled={trackIsDisabled || undefined} />\n <div\n className=\"cim-slider-fill\"\n style={\n (state.values.length === 1\n ? {\n '--cim-slider-fill-size': trackState.getThumbPercent(0) * 100 + '%',\n }\n : state.values.length === 2\n ? {\n '--cim-slider-fill-start': trackState.getThumbPercent(0) * 100 + '%',\n '--cim-slider-fill-size':\n (trackState.getThumbPercent(1) - trackState.getThumbPercent(0)) * 100 + '%',\n }\n : {}) as React.CSSProperties\n }\n />\n {trackState.values.map((_, i) => (\n <SliderThumb key={i} index={i} name={typeof name === 'string' ? name : name?.[i]} form={form} />\n ))}\n </>\n )}\n </RACSliderTrack>\n {showLabels && (\n <Text as=\"span\" variant=\"medium\" UNSAFE_className=\"cim-slider-label-max\">\n {state.getThumbMaxValue(state.values.length - 1)}\n </Text>\n )}\n {withInput && (\n <div className=\"cim-slider-inputs-container-wide\">\n {state.values.map((_, i) => (\n <SliderNumberField\n key={i}\n index={i}\n style={{ order: state.values.length === 2 ? (i === 0 ? -1 : 1) : undefined }}\n >\n <Input width=\"fit-content\" />\n </SliderNumberField>\n ))}\n </div>\n )}\n </div>\n {withInput && (\n <div className=\"cim-slider-inputs-container-narrow\">\n {state.values.map((_, i) => (\n <SliderNumberField key={i} index={i}>\n <Input />\n </SliderNumberField>\n ))}\n </div>\n )}\n <FormFieldDescription>{description}</FormFieldDescription>\n </>\n );\n }}\n </RACSlider>\n </RACProvider>\n );\n}\n\ninterface SliderNumberFieldProps extends RACNumberFieldProps {\n index: number;\n}\n\n// eslint-disable-next-line react-refresh/only-export-components\nfunction SliderNumberField({ index, ...props }: SliderNumberFieldProps) {\n const state = useContext(RACSliderStateContext)!;\n const labelProps = useSlottedContext(RACLabelContext)!;\n\n return (\n <RACNumberField\n {...props}\n className=\"cim-slider-input\"\n value={state.values[index]}\n onChange={(value) => state.setThumbValue(index, value ?? 0)}\n aria-labelledby={labelProps.id}\n aria-label={\n state.values.length === 2 ? (index === 0 ? sliderStrings.srMinimum : sliderStrings.srMaximum) : undefined\n }\n />\n );\n}\n\n// eslint-disable-next-line react-refresh/only-export-components\nfunction SliderThumb({ index, name, form }: { index: number; name?: string | string[]; form?: string }) {\n const state = useContext(RACSliderStateContext)!;\n\n return (\n <RACSliderThumb\n index={index}\n className=\"cim-slider-thumb\"\n name={typeof name === 'string' ? name : name?.[index]}\n form={form}\n aria-label={\n state.values.length === 2 ? (index === 0 ? sliderStrings.srMinimum : sliderStrings.srMaximum) : undefined\n }\n />\n );\n}\n\n/**\n * Allows users to select one or more values within a range.\n */\nconst _UNSTABLE_Slider = withStyleProps(forwardRef(UNSTABLE_Slider), 'Slider');\n\nexport { _UNSTABLE_Slider as UNSTABLE_Slider };\n"]}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { CommonProps, StringLikeChildren } from '../types.js';
|
|
2
3
|
import type { StepperStatus } from './types.js';
|
|
3
4
|
export interface UNSTABLE_StepperItemProps extends CommonProps {
|
|
4
5
|
/** The title of the step. */
|
|
5
|
-
|
|
6
|
-
/** The description of the step. */
|
|
7
|
-
description?:
|
|
6
|
+
children: StringLikeChildren;
|
|
7
|
+
/** The description of the step. Optionally, you can pass a React node to render rich text. */
|
|
8
|
+
description?: ReactNode;
|
|
8
9
|
/** The status of the step. */
|
|
9
10
|
status?: StepperStatus;
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
13
|
* Represents a single step in a stepper component.
|
|
13
14
|
*/
|
|
14
|
-
declare
|
|
15
|
-
export { _UNSTABLE_StepperItem as UNSTABLE_StepperItem };
|
|
15
|
+
export declare function UNSTABLE_StepperItem({ children, description, status: overrideStatus, UNSAFE_className, UNSAFE_style, ...props }: UNSTABLE_StepperItemProps): import("react/jsx-runtime").JSX.Element;
|
|
16
16
|
//# sourceMappingURL=stepper-item.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stepper-item.d.ts","sourceRoot":"","sources":["../../../../src/components/stepper/stepper-item.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stepper-item.d.ts","sourceRoot":"","sources":["../../../../src/components/stepper/stepper-item.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG5E,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAwChD,MAAM,WAAW,yBAA0B,SAAQ,WAAW;IAC5D,6BAA6B;IAC7B,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,8FAA8F;IAC9F,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,8BAA8B;IAC9B,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,QAAQ,EACR,WAAW,EACX,MAAM,EAAE,cAAc,EACtB,gBAAgB,EAChB,YAAY,EACZ,GAAG,KAAK,EACT,EAAE,yBAAyB,2CAiC3B"}
|