@common-origin/design-system 2.19.0 → 2.20.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/client.js +169 -169
- package/dist/client.js.map +1 -1
- package/dist/components/atoms/Avatar/Avatar.d.mts +8 -0
- package/dist/components/atoms/Avatar/Avatar.mjs +103 -0
- package/dist/components/atoms/Avatar/Avatar.mjs.map +1 -0
- package/dist/components/atoms/Avatar/index.d.mts +1 -0
- package/dist/components/atoms/Badge/Badge.d.mts +25 -0
- package/dist/components/atoms/Badge/Badge.mjs +98 -0
- package/dist/components/atoms/Badge/Badge.mjs.map +1 -0
- package/dist/components/atoms/Badge/index.d.mts +2 -0
- package/dist/components/atoms/Box/Box.d.mts +62 -0
- package/dist/components/atoms/Box/Box.mjs +246 -0
- package/dist/components/atoms/Box/Box.mjs.map +1 -0
- package/dist/components/atoms/Box/index.d.mts +1 -0
- package/dist/components/atoms/Button/Button.d.mts +40 -0
- package/dist/components/atoms/Button/Button.mjs +208 -0
- package/dist/components/atoms/Button/Button.mjs.map +1 -0
- package/dist/components/atoms/Button/index.d.mts +1 -0
- package/dist/components/atoms/CategoryBadge/CategoryBadge.d.mts +29 -0
- package/dist/components/atoms/CategoryBadge/CategoryBadge.mjs +29 -0
- package/dist/components/atoms/CategoryBadge/CategoryBadge.mjs.map +1 -0
- package/dist/components/atoms/CategoryBadge/index.d.mts +2 -0
- package/dist/components/atoms/CategoryLabel/CategoryLabel.d.mts +69 -0
- package/dist/components/atoms/CategoryLabel/CategoryLabel.mjs +151 -0
- package/dist/components/atoms/CategoryLabel/CategoryLabel.mjs.map +1 -0
- package/dist/components/atoms/CategoryLabel/index.d.mts +2 -0
- package/dist/components/atoms/Chip/BooleanChip.d.mts +28 -0
- package/dist/components/atoms/Chip/BooleanChip.mjs +76 -0
- package/dist/components/atoms/Chip/BooleanChip.mjs.map +1 -0
- package/dist/components/atoms/Chip/Chip.d.mts +37 -0
- package/dist/components/atoms/Chip/Chip.mjs +76 -0
- package/dist/components/atoms/Chip/Chip.mjs.map +1 -0
- package/dist/components/atoms/Chip/FilterChip.d.mts +13 -0
- package/dist/components/atoms/Chip/FilterChip.mjs +14 -0
- package/dist/components/atoms/Chip/FilterChip.mjs.map +1 -0
- package/dist/components/atoms/Chip/InputChip.d.mts +27 -0
- package/dist/components/atoms/Chip/InputChip.mjs +97 -0
- package/dist/components/atoms/Chip/InputChip.mjs.map +1 -0
- package/dist/components/atoms/Chip/index.d.mts +4 -0
- package/dist/components/atoms/Chip/shared/ChipBase.d.mts +12 -0
- package/dist/components/atoms/Chip/shared/ChipBase.mjs +45 -0
- package/dist/components/atoms/Chip/shared/ChipBase.mjs.map +1 -0
- package/dist/components/atoms/Chip/shared/types.d.mts +34 -0
- package/dist/components/atoms/Chip/shared/utils.d.mts +10 -0
- package/dist/components/atoms/Chip/shared/utils.mjs +46 -0
- package/dist/components/atoms/Chip/shared/utils.mjs.map +1 -0
- package/dist/components/atoms/Container/Container.d.mts +6 -0
- package/dist/components/atoms/Container/Container.mjs +24 -0
- package/dist/components/atoms/Container/Container.mjs.map +1 -0
- package/dist/components/atoms/Container/index.d.mts +1 -0
- package/dist/components/atoms/DateFormatter/DateFormatter.d.mts +23 -0
- package/dist/components/atoms/DateFormatter/DateFormatter.mjs +64 -0
- package/dist/components/atoms/DateFormatter/DateFormatter.mjs.map +1 -0
- package/dist/components/atoms/DateFormatter/index.d.mts +1 -0
- package/dist/components/atoms/Divider/Divider.d.mts +30 -0
- package/dist/components/atoms/Divider/Divider.mjs +134 -0
- package/dist/components/atoms/Divider/Divider.mjs.map +1 -0
- package/dist/components/atoms/Divider/index.d.mts +1 -0
- package/dist/components/atoms/Icon/Icon.d.mts +22 -0
- package/dist/components/atoms/Icon/Icon.mjs +95 -0
- package/dist/components/atoms/Icon/Icon.mjs.map +1 -0
- package/dist/components/atoms/Icon/index.d.mts +1 -0
- package/dist/components/atoms/IconButton/IconButton.d.mts +14 -0
- package/dist/components/atoms/IconButton/IconButton.mjs +150 -0
- package/dist/components/atoms/IconButton/IconButton.mjs.map +1 -0
- package/dist/components/atoms/IconButton/index.d.mts +1 -0
- package/dist/components/atoms/MoneyDisplay/MoneyDisplay.d.mts +26 -0
- package/dist/components/atoms/MoneyDisplay/MoneyDisplay.mjs +126 -0
- package/dist/components/atoms/MoneyDisplay/MoneyDisplay.mjs.map +1 -0
- package/dist/components/atoms/MoneyDisplay/index.d.mts +2 -0
- package/dist/components/atoms/Picture/Picture.d.mts +12 -0
- package/dist/components/atoms/Picture/Picture.mjs +65 -0
- package/dist/components/atoms/Picture/Picture.mjs.map +1 -0
- package/dist/components/atoms/Picture/index.d.mts +1 -0
- package/dist/components/atoms/ProgressBar/ProgressBar.d.mts +21 -0
- package/dist/components/atoms/ProgressBar/ProgressBar.mjs +91 -0
- package/dist/components/atoms/ProgressBar/ProgressBar.mjs.map +1 -0
- package/dist/components/atoms/ProgressBar/index.d.mts +2 -0
- package/dist/components/atoms/Stack/Stack.d.mts +16 -0
- package/dist/components/atoms/Stack/Stack.mjs +71 -0
- package/dist/components/atoms/Stack/Stack.mjs.map +1 -0
- package/dist/components/atoms/Stack/index.d.mts +1 -0
- package/dist/components/atoms/StatusBadge/StatusBadge.d.mts +23 -0
- package/dist/components/atoms/StatusBadge/StatusBadge.mjs +18 -0
- package/dist/components/atoms/StatusBadge/StatusBadge.mjs.map +1 -0
- package/dist/components/atoms/StatusBadge/index.d.mts +2 -0
- package/dist/components/atoms/StatusLabel/StatusLabel.d.mts +17 -0
- package/dist/components/atoms/StatusLabel/StatusLabel.mjs +28 -0
- package/dist/components/atoms/StatusLabel/StatusLabel.mjs.map +1 -0
- package/dist/components/atoms/StatusLabel/StatusLabelBase.d.mts +49 -0
- package/dist/components/atoms/StatusLabel/StatusLabelBase.mjs +161 -0
- package/dist/components/atoms/StatusLabel/StatusLabelBase.mjs.map +1 -0
- package/dist/components/atoms/StatusLabel/index.d.mts +2 -0
- package/dist/components/atoms/Tag/Tag.d.mts +36 -0
- package/dist/components/atoms/Tag/Tag.mjs +115 -0
- package/dist/components/atoms/Tag/Tag.mjs.map +1 -0
- package/dist/components/atoms/Tag/index.d.mts +2 -0
- package/dist/components/atoms/Typography/Typography.d.mts +34 -0
- package/dist/components/atoms/Typography/Typography.mjs +139 -0
- package/dist/components/atoms/Typography/Typography.mjs.map +1 -0
- package/dist/components/atoms/Typography/index.d.mts +1 -0
- package/dist/components/atoms/index.d.mts +20 -0
- package/dist/components/index.d.mts +4 -0
- package/dist/components/layout/GridSystem/GridSystem.d.mts +58 -0
- package/dist/components/layout/GridSystem/GridSystem.mjs +221 -0
- package/dist/components/layout/GridSystem/GridSystem.mjs.map +1 -0
- package/dist/components/layout/GridSystem/index.d.mts +1 -0
- package/dist/components/layout/index.d.mts +1 -0
- package/dist/components/molecules/AccountCard/AccountCard.d.mts +44 -0
- package/dist/components/molecules/AccountCard/AccountCard.mjs +191 -0
- package/dist/components/molecules/AccountCard/AccountCard.mjs.map +1 -0
- package/dist/components/molecules/AccountCard/index.d.mts +2 -0
- package/dist/components/molecules/ActionSheet/ActionSheet.d.mts +111 -0
- package/dist/components/molecules/ActionSheet/ActionSheet.mjs +283 -0
- package/dist/components/molecules/ActionSheet/ActionSheet.mjs.map +1 -0
- package/dist/components/molecules/ActionSheet/index.d.mts +2 -0
- package/dist/components/molecules/AgentInput/AgentInput.d.mts +30 -0
- package/dist/components/molecules/AgentInput/AgentInput.mjs +735 -0
- package/dist/components/molecules/AgentInput/AgentInput.mjs.map +1 -0
- package/dist/components/molecules/AgentInput/agentInputSpeech.d.mts +43 -0
- package/dist/components/molecules/AgentInput/agentInputSpeech.mjs +49 -0
- package/dist/components/molecules/AgentInput/agentInputSpeech.mjs.map +1 -0
- package/dist/components/molecules/AgentInput/agentInputStateMachine.d.mts +29 -0
- package/dist/components/molecules/AgentInput/agentInputStateMachine.mjs +55 -0
- package/dist/components/molecules/AgentInput/agentInputStateMachine.mjs.map +1 -0
- package/dist/components/molecules/AgentInput/index.d.mts +3 -0
- package/dist/components/molecules/Alert/Alert.d.mts +68 -0
- package/dist/components/molecules/Alert/Alert.mjs +284 -0
- package/dist/components/molecules/Alert/Alert.mjs.map +1 -0
- package/dist/components/molecules/Alert/index.d.mts +1 -0
- package/dist/components/molecules/Breadcrumbs/Breadcrumbs.d.mts +16 -0
- package/dist/components/molecules/Breadcrumbs/Breadcrumbs.mjs +74 -0
- package/dist/components/molecules/Breadcrumbs/Breadcrumbs.mjs.map +1 -0
- package/dist/components/molecules/Breadcrumbs/index.d.mts +1 -0
- package/dist/components/molecules/CardLarge/CardLarge.d.mts +12 -0
- package/dist/components/molecules/CardLarge/CardLarge.mjs +75 -0
- package/dist/components/molecules/CardLarge/CardLarge.mjs.map +1 -0
- package/dist/components/molecules/CardLarge/index.d.mts +1 -0
- package/dist/components/molecules/CardSmall/CardSmall.d.mts +16 -0
- package/dist/components/molecules/CardSmall/CardSmall.mjs +73 -0
- package/dist/components/molecules/CardSmall/CardSmall.mjs.map +1 -0
- package/dist/components/molecules/CardSmall/index.d.mts +1 -0
- package/dist/components/molecules/Checkbox/Checkbox.d.mts +64 -0
- package/dist/components/molecules/Checkbox/Checkbox.mjs +139 -0
- package/dist/components/molecules/Checkbox/Checkbox.mjs.map +1 -0
- package/dist/components/molecules/Checkbox/SelectableInputBase.d.mts +40 -0
- package/dist/components/molecules/Checkbox/SelectableInputBase.mjs +99 -0
- package/dist/components/molecules/Checkbox/SelectableInputBase.mjs.map +1 -0
- package/dist/components/molecules/Checkbox/index.d.mts +3 -0
- package/dist/components/molecules/ChipGroup/ChipGroup.d.mts +7 -0
- package/dist/components/molecules/ChipGroup/ChipGroup.mjs +54 -0
- package/dist/components/molecules/ChipGroup/ChipGroup.mjs.map +1 -0
- package/dist/components/molecules/ChipGroup/index.d.mts +1 -0
- package/dist/components/molecules/CodeBlock/CodeBlock.d.mts +46 -0
- package/dist/components/molecules/CodeBlock/CodeBlock.mjs +231 -0
- package/dist/components/molecules/CodeBlock/CodeBlock.mjs.map +1 -0
- package/dist/components/molecules/CodeBlock/index.d.mts +1 -0
- package/dist/components/molecules/DateGroup/DateGroup.d.mts +37 -0
- package/dist/components/molecules/DateGroup/DateGroup.mjs +104 -0
- package/dist/components/molecules/DateGroup/DateGroup.mjs.map +1 -0
- package/dist/components/molecules/DateGroup/index.d.mts +2 -0
- package/dist/components/molecules/Dropdown/Dropdown.d.mts +27 -0
- package/dist/components/molecules/Dropdown/Dropdown.mjs +282 -0
- package/dist/components/molecules/Dropdown/Dropdown.mjs.map +1 -0
- package/dist/components/molecules/Dropdown/index.d.mts +1 -0
- package/dist/components/molecules/EmptyState/EmptyState.d.mts +32 -0
- package/dist/components/molecules/EmptyState/EmptyState.mjs +133 -0
- package/dist/components/molecules/EmptyState/EmptyState.mjs.map +1 -0
- package/dist/components/molecules/EmptyState/index.d.mts +2 -0
- package/dist/components/molecules/FeatureBlock/FeatureBlock.d.mts +14 -0
- package/dist/components/molecules/FeatureBlock/FeatureBlock.mjs +99 -0
- package/dist/components/molecules/FeatureBlock/FeatureBlock.mjs.map +1 -0
- package/dist/components/molecules/FeatureBlock/index.d.mts +1 -0
- package/dist/components/molecules/InlineAlert/InlineAlert.d.mts +54 -0
- package/dist/components/molecules/InlineAlert/InlineAlert.mjs +140 -0
- package/dist/components/molecules/InlineAlert/InlineAlert.mjs.map +1 -0
- package/dist/components/molecules/InlineAlert/index.d.mts +2 -0
- package/dist/components/molecules/List/List.d.mts +30 -0
- package/dist/components/molecules/List/List.mjs +45 -0
- package/dist/components/molecules/List/List.mjs.map +1 -0
- package/dist/components/molecules/List/ListContext.d.mts +6 -0
- package/dist/components/molecules/List/ListContext.mjs +11 -0
- package/dist/components/molecules/List/ListContext.mjs.map +1 -0
- package/dist/components/molecules/List/ListItem.d.mts +101 -0
- package/dist/components/molecules/List/ListItem.mjs +224 -0
- package/dist/components/molecules/List/ListItem.mjs.map +1 -0
- package/dist/components/molecules/List/index.d.mts +4 -0
- package/dist/components/molecules/Modal/Modal.d.mts +69 -0
- package/dist/components/molecules/Modal/Modal.mjs +259 -0
- package/dist/components/molecules/Modal/Modal.mjs.map +1 -0
- package/dist/components/molecules/Modal/index.d.mts +2 -0
- package/dist/components/molecules/NumberInput/NumberInput.d.mts +86 -0
- package/dist/components/molecules/NumberInput/NumberInput.mjs +268 -0
- package/dist/components/molecules/NumberInput/NumberInput.mjs.map +1 -0
- package/dist/components/molecules/NumberInput/index.d.mts +2 -0
- package/dist/components/molecules/PageTitle/PageTitle.d.mts +21 -0
- package/dist/components/molecules/PageTitle/PageTitle.mjs +77 -0
- package/dist/components/molecules/PageTitle/PageTitle.mjs.map +1 -0
- package/dist/components/molecules/PageTitle/index.d.mts +1 -0
- package/dist/components/molecules/PasswordField/PasswordField.d.mts +55 -0
- package/dist/components/molecules/PasswordField/PasswordField.mjs +146 -0
- package/dist/components/molecules/PasswordField/PasswordField.mjs.map +1 -0
- package/dist/components/molecules/PasswordField/index.d.mts +2 -0
- package/dist/components/molecules/SearchField/SearchField.d.mts +108 -0
- package/dist/components/molecules/SearchField/SearchField.mjs +340 -0
- package/dist/components/molecules/SearchField/SearchField.mjs.map +1 -0
- package/dist/components/molecules/SearchField/index.d.mts +2 -0
- package/dist/components/molecules/Sheet/Sheet.d.mts +96 -0
- package/dist/components/molecules/Sheet/Sheet.mjs +243 -0
- package/dist/components/molecules/Sheet/Sheet.mjs.map +1 -0
- package/dist/components/molecules/Sheet/index.d.mts +2 -0
- package/dist/components/molecules/Slider/Slider.d.mts +102 -0
- package/dist/components/molecules/Slider/Slider.mjs +462 -0
- package/dist/components/molecules/Slider/Slider.mjs.map +1 -0
- package/dist/components/molecules/Slider/index.d.mts +2 -0
- package/dist/components/molecules/TabBar/TabBar.d.mts +82 -0
- package/dist/components/molecules/TabBar/TabBar.mjs +213 -0
- package/dist/components/molecules/TabBar/TabBar.mjs.map +1 -0
- package/dist/components/molecules/TabBar/index.d.mts +2 -0
- package/dist/components/molecules/TextField/InputBase.d.mts +22 -0
- package/dist/components/molecules/TextField/InputBase.mjs +56 -0
- package/dist/components/molecules/TextField/InputBase.mjs.map +1 -0
- package/dist/components/molecules/TextField/TextField.d.mts +56 -0
- package/dist/components/molecules/TextField/TextField.mjs +115 -0
- package/dist/components/molecules/TextField/TextField.mjs.map +1 -0
- package/dist/components/molecules/TextField/index.d.mts +4 -0
- package/dist/components/molecules/TransactionListItem/TransactionListItem.d.mts +39 -0
- package/dist/components/molecules/TransactionListItem/TransactionListItem.mjs +224 -0
- package/dist/components/molecules/TransactionListItem/TransactionListItem.mjs.map +1 -0
- package/dist/components/molecules/TransactionListItem/index.d.mts +2 -0
- package/dist/components/molecules/index.d.mts +26 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +55 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/cssTokens.d.mts +14 -0
- package/dist/lib/cssTokens.mjs +19 -0
- package/dist/lib/cssTokens.mjs.map +1 -0
- package/dist/lib/cssVariables.d.mts +15 -0
- package/dist/lib/cssVariables.mjs +37 -0
- package/dist/lib/cssVariables.mjs.map +1 -0
- package/dist/lib/styleUtils.d.mts +42 -0
- package/dist/lib/styleUtils.mjs +160 -0
- package/dist/lib/styleUtils.mjs.map +1 -0
- package/dist/lib/tokenAliases.d.mts +13 -0
- package/dist/lib/tokenAliases.mjs +121 -0
- package/dist/lib/tokenAliases.mjs.map +1 -0
- package/dist/lib/usePresence.d.mts +16 -0
- package/dist/lib/usePresence.mjs +50 -0
- package/dist/lib/usePresence.mjs.map +1 -0
- package/dist/{data.esm.js → styles/icons.json.mjs} +2 -1466
- package/dist/styles/icons.json.mjs.map +1 -0
- package/dist/styles/tokens.d.mts +3174 -0
- package/dist/styles/tokens.json.mjs +1454 -0
- package/dist/{tokens/index.esm.js.map → styles/tokens.json.mjs.map} +1 -1
- package/dist/tokens/{index.esm.js → index.mjs} +1 -1
- package/dist/tokens/index.mjs.map +1 -0
- package/dist/tokens/styles/tokens.d.mts +3174 -0
- package/dist/tokens/tokens.d.mts +4 -0
- package/dist/tokens/types/tokens.d.mts +6 -0
- package/dist/tokens.css.d.mts +4 -0
- package/dist/types/icons.d.mts +25 -0
- package/dist/types/icons.mjs +10 -0
- package/dist/types/icons.mjs.map +1 -0
- package/dist/types/index.d.mts +1 -0
- package/dist/types/tokens.d.mts +6 -0
- package/dist/types/tokens.mjs +10 -0
- package/dist/types/tokens.mjs.map +1 -0
- package/dist/vendor/tslib/tslib.es6.mjs +99 -0
- package/dist/vendor/tslib/tslib.es6.mjs.map +1 -0
- package/package.json +26 -12
- package/dist/client.esm.js +0 -8289
- package/dist/client.esm.js.map +0 -1
- package/dist/data.esm.js.map +0 -1
- package/dist/index.esm.js +0 -8
- package/dist/index.esm.js.map +0 -1
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { __makeTemplateObject } from '../../../vendor/tslib/tslib.es6.mjs';
|
|
3
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { useRef, useEffect } from 'react';
|
|
5
|
+
import { createPortal } from 'react-dom';
|
|
6
|
+
import styled$module, { keyframes, css } from 'styled-components';
|
|
7
|
+
const styled = styled$module.default || styled$module;
|
|
8
|
+
import { IconButton } from '../../atoms/IconButton/IconButton.mjs';
|
|
9
|
+
import { Button } from '../../atoms/Button/Button.mjs';
|
|
10
|
+
import { Typography } from '../../atoms/Typography/Typography.mjs';
|
|
11
|
+
import { Divider } from '../../atoms/Divider/Divider.mjs';
|
|
12
|
+
import tokens from '../../../lib/cssTokens.mjs';
|
|
13
|
+
import { exitAnimation, reducedMotion } from '../../../lib/styleUtils.mjs';
|
|
14
|
+
import { usePresence, useInert } from '../../../lib/usePresence.mjs';
|
|
15
|
+
|
|
16
|
+
var semantic = tokens.semantic;
|
|
17
|
+
var space = semantic.space,
|
|
18
|
+
color = semantic.color,
|
|
19
|
+
elevation = semantic.elevation,
|
|
20
|
+
motion = semantic.motion;
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
// Size map
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
var sizeToWidth = {
|
|
25
|
+
small: tokens.semantic.size.overlay.sm,
|
|
26
|
+
medium: tokens.semantic.size.overlay.md,
|
|
27
|
+
large: tokens.semantic.size.overlay.lg
|
|
28
|
+
};
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
// Animations
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
var fadeIn = keyframes(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n from { opacity: 0; }\n to { opacity: 1; }\n"], ["\n from { opacity: 0; }\n to { opacity: 1; }\n"])));
|
|
33
|
+
var scaleIn = keyframes(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n from {\n opacity: 0;\n transform: translate(-50%, -50%) scale(0.95);\n }\n to {\n opacity: 1;\n transform: translate(-50%, -50%) scale(1);\n }\n"], ["\n from {\n opacity: 0;\n transform: translate(-50%, -50%) scale(0.95);\n }\n to {\n opacity: 1;\n transform: translate(-50%, -50%) scale(1);\n }\n"
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
// Styled components
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
])));
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
// Styled components
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
var StyledOverlay = /*#__PURE__*/styled.div.withConfig({
|
|
42
|
+
displayName: "Modal__StyledOverlay",
|
|
43
|
+
componentId: "sc-1d3g5gh-0"
|
|
44
|
+
})(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: fixed;\n inset: 0;\n background-color: ", ";\n z-index: ", ";\n ", "\n"], ["\n position: fixed;\n inset: 0;\n background-color: ", ";\n z-index: ", ";\n ", "\n"])), semantic.surface.scrim, semantic.layer.modal, css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["animation: ", " ", " ", "", ";"], ["animation: ", " ", " ", "", ";"])), fadeIn, motion.duration.moderate, motion.easing.decelerate, function (_a) {
|
|
45
|
+
var $isExiting = _a.$isExiting;
|
|
46
|
+
return $isExiting && exitAnimation;
|
|
47
|
+
}));
|
|
48
|
+
var StyledDialog = /*#__PURE__*/styled.div.withConfig({
|
|
49
|
+
shouldForwardProp: function shouldForwardProp(prop) {
|
|
50
|
+
return !prop.startsWith('$');
|
|
51
|
+
},
|
|
52
|
+
displayName: "Modal__StyledDialog",
|
|
53
|
+
componentId: "sc-1d3g5gh-1"
|
|
54
|
+
})(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%) scale(1);\n z-index: ", ";\n\n width: ", ";\n max-width: calc(100vw - ", " * 2);\n max-height: calc(100vh - ", " * 2);\n\n display: flex;\n flex-direction: column;\n\n background-color: ", ";\n border-radius: ", ";\n box-shadow: ", ";\n overflow: hidden;\n\n ", "\n\n ", " {\n animation: ", " ", " ", "", ";\n }\n\n /* Auto-fullscreen below md breakpoint (768px) */\n @media (max-width: ", ") {\n width: 100vw;\n height: 100vh;\n max-width: 100vw;\n max-height: 100vh;\n border-radius: 0;\n top: 0;\n left: 0;\n transform: none;\n animation: ", " ", " ", "", ";\n }\n\n &:focus {\n outline: none;\n }\n\n"], ["\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%) scale(1);\n z-index: ", ";\n\n width: ", ";\n max-width: calc(100vw - ", " * 2);\n max-height: calc(100vh - ", " * 2);\n\n display: flex;\n flex-direction: column;\n\n background-color: ", ";\n border-radius: ", ";\n box-shadow: ", ";\n overflow: hidden;\n\n ", "\n\n ", " {\n animation: ", " ", " ", "", ";\n }\n\n /* Auto-fullscreen below md breakpoint (768px) */\n @media (max-width: ", ") {\n width: 100vw;\n height: 100vh;\n max-width: 100vw;\n max-height: 100vh;\n border-radius: 0;\n top: 0;\n left: 0;\n transform: none;\n animation: ", " ", " ", "", ";\n }\n\n &:focus {\n outline: none;\n }\n\n"])), semantic.layer.modal, function (_a) {
|
|
55
|
+
var $width = _a.$width;
|
|
56
|
+
return $width;
|
|
57
|
+
}, space[400], space[400], semantic.surface.raised, semantic.radius.xl, elevation.overlay, css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["animation: ", " ", " ", "", ";"], ["animation: ", " ", " ", "", ";"])), scaleIn, motion.duration.moderate, motion.easing.decelerate, function (_a) {
|
|
58
|
+
var $isExiting = _a.$isExiting;
|
|
59
|
+
return $isExiting && exitAnimation;
|
|
60
|
+
}), reducedMotion, fadeIn, motion.duration.moderate, motion.easing.decelerate, function (_a) {
|
|
61
|
+
var $isExiting = _a.$isExiting;
|
|
62
|
+
return $isExiting && exitAnimation;
|
|
63
|
+
}, semantic.breakpoint.md, fadeIn, motion.duration.moderate, motion.easing.decelerate, function (_a) {
|
|
64
|
+
var $isExiting = _a.$isExiting;
|
|
65
|
+
return $isExiting && exitAnimation;
|
|
66
|
+
});
|
|
67
|
+
var StyledHeader = /*#__PURE__*/styled.div.withConfig({
|
|
68
|
+
displayName: "Modal__StyledHeader",
|
|
69
|
+
componentId: "sc-1d3g5gh-2"
|
|
70
|
+
})(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: ", " ", " 0;\n flex-shrink: 0;\n"], ["\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: ", " ", " 0;\n flex-shrink: 0;\n"])), space[400], space[400]);
|
|
71
|
+
var StyledBody = /*#__PURE__*/styled.div.withConfig({
|
|
72
|
+
displayName: "Modal__StyledBody",
|
|
73
|
+
componentId: "sc-1d3g5gh-3"
|
|
74
|
+
})(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n flex: 1 1 auto;\n overflow-y: auto;\n padding: ", " ", ";\n\n /* Scrollbar styling */\n &::-webkit-scrollbar {\n width: ", ";\n }\n &::-webkit-scrollbar-track {\n background: ", ";\n }\n &::-webkit-scrollbar-thumb {\n background: ", ";\n border-radius: ", ";\n }\n &::-webkit-scrollbar-thumb:hover {\n background: ", ";\n }\n"], ["\n flex: 1 1 auto;\n overflow-y: auto;\n padding: ", " ", ";\n\n /* Scrollbar styling */\n &::-webkit-scrollbar {\n width: ", ";\n }\n &::-webkit-scrollbar-track {\n background: ", ";\n }\n &::-webkit-scrollbar-thumb {\n background: ", ";\n border-radius: ", ";\n }\n &::-webkit-scrollbar-thumb:hover {\n background: ", ";\n }\n"])), space[300], space[400], semantic.space[200], color.fill.muted, color.border["default"], semantic.radius.full, color.fill.inverse);
|
|
75
|
+
var StyledFooter = /*#__PURE__*/styled.div.withConfig({
|
|
76
|
+
displayName: "Modal__StyledFooter",
|
|
77
|
+
componentId: "sc-1d3g5gh-4"
|
|
78
|
+
})(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n display: flex;\n justify-content: flex-end;\n gap: ", ";\n padding: 0 ", " ", ";\n flex-shrink: 0;\n"], ["\n display: flex;\n justify-content: flex-end;\n gap: ", ";\n padding: 0 ", " ", ";\n flex-shrink: 0;\n"
|
|
79
|
+
// ---------------------------------------------------------------------------
|
|
80
|
+
// Component
|
|
81
|
+
// ---------------------------------------------------------------------------
|
|
82
|
+
/**
|
|
83
|
+
* Modal component
|
|
84
|
+
*
|
|
85
|
+
* A centred dialog overlay with a title, close button (IconButton), scrollable
|
|
86
|
+
* body content, and an optional footer with structured action buttons.
|
|
87
|
+
*
|
|
88
|
+
* - Renders via `createPortal` to avoid z-index / overflow issues.
|
|
89
|
+
* - Auto-fullscreen on viewports narrower than 768 px.
|
|
90
|
+
* - Focus trap, Escape-to-close, overlay-click-to-close.
|
|
91
|
+
* - Locks body scroll while open.
|
|
92
|
+
*
|
|
93
|
+
* Composes: IconButton, Button, Typography, Stack, Divider
|
|
94
|
+
*/])), space[200], space[400], space[400]);
|
|
95
|
+
// ---------------------------------------------------------------------------
|
|
96
|
+
// Component
|
|
97
|
+
// ---------------------------------------------------------------------------
|
|
98
|
+
/**
|
|
99
|
+
* Modal component
|
|
100
|
+
*
|
|
101
|
+
* A centred dialog overlay with a title, close button (IconButton), scrollable
|
|
102
|
+
* body content, and an optional footer with structured action buttons.
|
|
103
|
+
*
|
|
104
|
+
* - Renders via `createPortal` to avoid z-index / overflow issues.
|
|
105
|
+
* - Auto-fullscreen on viewports narrower than 768 px.
|
|
106
|
+
* - Focus trap, Escape-to-close, overlay-click-to-close.
|
|
107
|
+
* - Locks body scroll while open.
|
|
108
|
+
*
|
|
109
|
+
* Composes: IconButton, Button, Typography, Stack, Divider
|
|
110
|
+
*/
|
|
111
|
+
var Modal = function Modal(_a) {
|
|
112
|
+
var isOpen = _a.isOpen,
|
|
113
|
+
onClose = _a.onClose,
|
|
114
|
+
title = _a.title,
|
|
115
|
+
children = _a.children,
|
|
116
|
+
_b = _a.size,
|
|
117
|
+
size = _b === void 0 ? 'medium' : _b,
|
|
118
|
+
actions = _a.actions,
|
|
119
|
+
_c = _a.closeOnOverlayClick,
|
|
120
|
+
closeOnOverlayClick = _c === void 0 ? true : _c,
|
|
121
|
+
_d = _a.closeOnEscape,
|
|
122
|
+
closeOnEscape = _d === void 0 ? true : _d,
|
|
123
|
+
dataTestId = _a["data-testid"],
|
|
124
|
+
ariaLabel = _a["aria-label"],
|
|
125
|
+
ariaDescribedBy = _a["aria-describedby"];
|
|
126
|
+
var dialogRef = useRef(null);
|
|
127
|
+
var previousFocusRef = useRef(null);
|
|
128
|
+
var _e = usePresence(isOpen),
|
|
129
|
+
isPresent = _e.isPresent,
|
|
130
|
+
isExiting = _e.isExiting;
|
|
131
|
+
useInert(dialogRef, isExiting);
|
|
132
|
+
// -----------------------------------------------------------------------
|
|
133
|
+
// Focus & scroll-lock management
|
|
134
|
+
// -----------------------------------------------------------------------
|
|
135
|
+
useEffect(function () {
|
|
136
|
+
var _a;
|
|
137
|
+
if (isOpen) {
|
|
138
|
+
previousFocusRef.current = document.activeElement;
|
|
139
|
+
// Short delay so the animation can start before we shift focus
|
|
140
|
+
var timer_1 = setTimeout(function () {
|
|
141
|
+
var _a;
|
|
142
|
+
return (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
143
|
+
}, 100);
|
|
144
|
+
document.body.style.overflow = 'hidden';
|
|
145
|
+
return function () {
|
|
146
|
+
clearTimeout(timer_1);
|
|
147
|
+
};
|
|
148
|
+
} else {
|
|
149
|
+
(_a = previousFocusRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
150
|
+
document.body.style.overflow = '';
|
|
151
|
+
}
|
|
152
|
+
return function () {
|
|
153
|
+
document.body.style.overflow = '';
|
|
154
|
+
};
|
|
155
|
+
}, [isOpen]);
|
|
156
|
+
// -----------------------------------------------------------------------
|
|
157
|
+
// Keyboard handling (Escape + focus trap)
|
|
158
|
+
// -----------------------------------------------------------------------
|
|
159
|
+
var handleKeyDown = function handleKeyDown(event) {
|
|
160
|
+
var _a;
|
|
161
|
+
if (closeOnEscape && event.key === 'Escape') {
|
|
162
|
+
event.preventDefault();
|
|
163
|
+
onClose();
|
|
164
|
+
}
|
|
165
|
+
if (event.key === 'Tab') {
|
|
166
|
+
var focusableElements = (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
|
|
167
|
+
if (!focusableElements || focusableElements.length === 0) return;
|
|
168
|
+
var first = focusableElements[0];
|
|
169
|
+
var last = focusableElements[focusableElements.length - 1];
|
|
170
|
+
if (event.shiftKey && document.activeElement === first) {
|
|
171
|
+
event.preventDefault();
|
|
172
|
+
last.focus();
|
|
173
|
+
} else if (!event.shiftKey && document.activeElement === last) {
|
|
174
|
+
event.preventDefault();
|
|
175
|
+
first.focus();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
// -----------------------------------------------------------------------
|
|
180
|
+
// Overlay click
|
|
181
|
+
// -----------------------------------------------------------------------
|
|
182
|
+
var handleOverlayClick = function handleOverlayClick(event) {
|
|
183
|
+
// While exiting, the backdrop still catches clicks but doesn't close again
|
|
184
|
+
if (!isExiting && closeOnOverlayClick && event.target === event.currentTarget) {
|
|
185
|
+
onClose();
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
// -----------------------------------------------------------------------
|
|
189
|
+
// Render
|
|
190
|
+
// -----------------------------------------------------------------------
|
|
191
|
+
// Stays mounted while the exit fade runs, hidden from assistive technology
|
|
192
|
+
if (!isPresent) return null;
|
|
193
|
+
var titleId = dataTestId ? "".concat(dataTestId, "-title") : 'modal-title';
|
|
194
|
+
var width = sizeToWidth[size];
|
|
195
|
+
var modal = jsxs(Fragment, {
|
|
196
|
+
children: [jsx(StyledOverlay, {
|
|
197
|
+
onClick: handleOverlayClick,
|
|
198
|
+
"$isExiting": isExiting,
|
|
199
|
+
"data-testid": dataTestId ? "".concat(dataTestId, "-overlay") : 'modal-overlay'
|
|
200
|
+
}), jsxs(StyledDialog, {
|
|
201
|
+
ref: dialogRef,
|
|
202
|
+
role: "dialog",
|
|
203
|
+
"aria-modal": "true",
|
|
204
|
+
"aria-label": ariaLabel || title,
|
|
205
|
+
"aria-labelledby": titleId,
|
|
206
|
+
"aria-describedby": ariaDescribedBy,
|
|
207
|
+
"aria-hidden": isExiting || undefined,
|
|
208
|
+
tabIndex: -1,
|
|
209
|
+
"$width": width,
|
|
210
|
+
"$isExiting": isExiting,
|
|
211
|
+
onKeyDown: handleKeyDown,
|
|
212
|
+
"data-testid": dataTestId,
|
|
213
|
+
children: [jsxs(StyledHeader, {
|
|
214
|
+
children: [jsx("span", {
|
|
215
|
+
id: titleId,
|
|
216
|
+
children: jsx(Typography, {
|
|
217
|
+
variant: "h3",
|
|
218
|
+
children: title
|
|
219
|
+
})
|
|
220
|
+
}), jsx(IconButton, {
|
|
221
|
+
variant: "naked",
|
|
222
|
+
iconName: "close",
|
|
223
|
+
"aria-label": "Close modal",
|
|
224
|
+
onClick: onClose,
|
|
225
|
+
size: "medium",
|
|
226
|
+
"data-testid": dataTestId ? "".concat(dataTestId, "-close") : 'modal-close'
|
|
227
|
+
})]
|
|
228
|
+
}), jsx(Divider, {
|
|
229
|
+
size: "small"
|
|
230
|
+
}), jsx(StyledBody, {
|
|
231
|
+
"data-testid": dataTestId ? "".concat(dataTestId, "-body") : 'modal-body',
|
|
232
|
+
children: children
|
|
233
|
+
}), actions && actions.length > 0 && jsxs(Fragment, {
|
|
234
|
+
children: [jsx(Divider, {
|
|
235
|
+
size: "small"
|
|
236
|
+
}), jsx(StyledFooter, {
|
|
237
|
+
"data-testid": dataTestId ? "".concat(dataTestId, "-footer") : 'modal-footer',
|
|
238
|
+
children: actions.map(function (action, index) {
|
|
239
|
+
return jsx(Button, {
|
|
240
|
+
onClick: action.onClick,
|
|
241
|
+
variant: action.variant || 'secondary',
|
|
242
|
+
iconName: action.icon,
|
|
243
|
+
disabled: action.disabled,
|
|
244
|
+
size: "medium",
|
|
245
|
+
"data-testid": dataTestId ? "".concat(dataTestId, "-action-").concat(index) : "modal-action-".concat(index),
|
|
246
|
+
children: action.label
|
|
247
|
+
}, "".concat(action.label, "-").concat(index));
|
|
248
|
+
})
|
|
249
|
+
})]
|
|
250
|
+
})]
|
|
251
|
+
})]
|
|
252
|
+
});
|
|
253
|
+
return /*#__PURE__*/createPortal(modal, document.body);
|
|
254
|
+
};
|
|
255
|
+
Modal.displayName = 'Modal';
|
|
256
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9;
|
|
257
|
+
|
|
258
|
+
export { Modal };
|
|
259
|
+
//# sourceMappingURL=Modal.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { InputHTMLAttributes, ChangeEvent } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Props for the NumberInput component
|
|
4
|
+
*/
|
|
5
|
+
export interface NumberInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'onChange' | 'value' | 'defaultValue'> {
|
|
6
|
+
/**
|
|
7
|
+
* Label text for the input
|
|
8
|
+
*/
|
|
9
|
+
label?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Helper text displayed below the input
|
|
12
|
+
*/
|
|
13
|
+
helperText?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Error message to display
|
|
16
|
+
*/
|
|
17
|
+
error?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the field is required
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
required?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the input is disabled
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Minimum allowed value
|
|
30
|
+
*/
|
|
31
|
+
min?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Maximum allowed value
|
|
34
|
+
*/
|
|
35
|
+
max?: number;
|
|
36
|
+
/**
|
|
37
|
+
* Step increment/decrement value
|
|
38
|
+
* @default 1
|
|
39
|
+
*/
|
|
40
|
+
step?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Current value (controlled)
|
|
43
|
+
*/
|
|
44
|
+
value?: number | '';
|
|
45
|
+
/**
|
|
46
|
+
* Default value (uncontrolled)
|
|
47
|
+
*/
|
|
48
|
+
defaultValue?: number | '';
|
|
49
|
+
/**
|
|
50
|
+
* Callback fired when value changes
|
|
51
|
+
*/
|
|
52
|
+
onChange?: (value: number | '', event: ChangeEvent<HTMLInputElement>) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Unique identifier for the input
|
|
55
|
+
* Generated automatically if not provided
|
|
56
|
+
*/
|
|
57
|
+
id?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Test identifier for automated testing
|
|
60
|
+
*/
|
|
61
|
+
'data-testid'?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* NumberInput component for numeric input with stepper buttons and WCAG 2.2 AA compliance
|
|
65
|
+
*
|
|
66
|
+
* Features:
|
|
67
|
+
* - Stepper buttons for increment/decrement
|
|
68
|
+
* - Keyboard arrow up/down support
|
|
69
|
+
* - Min/max value constraints
|
|
70
|
+
* - Custom step values
|
|
71
|
+
* - Decimal and integer support
|
|
72
|
+
* - Full accessibility with ARIA attributes
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```tsx
|
|
76
|
+
* <NumberInput
|
|
77
|
+
* label="Quantity"
|
|
78
|
+
* min={0}
|
|
79
|
+
* max={100}
|
|
80
|
+
* step={1}
|
|
81
|
+
* value={value}
|
|
82
|
+
* onChange={(newValue) => setValue(newValue)}
|
|
83
|
+
* />
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare const NumberInput: import("react").ForwardRefExoticComponent<NumberInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { __makeTemplateObject, __rest, __assign } from '../../../vendor/tslib/tslib.es6.mjs';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { forwardRef, useId, useCallback } from 'react';
|
|
5
|
+
import styled$module from 'styled-components';
|
|
6
|
+
const styled = styled$module.default || styled$module;
|
|
7
|
+
import { StyledInputBase } from '../TextField/InputBase.mjs';
|
|
8
|
+
import { IconButton } from '../../atoms/IconButton/IconButton.mjs';
|
|
9
|
+
import tokens from '../../../lib/cssTokens.mjs';
|
|
10
|
+
|
|
11
|
+
var field = tokens.component.field;
|
|
12
|
+
// Gaps come from the semantic spacing scale: no component spacing tokens (decision 0022)
|
|
13
|
+
var space = tokens.semantic.space;
|
|
14
|
+
var StyledFieldContainer = /*#__PURE__*/styled.div.withConfig({
|
|
15
|
+
displayName: "NumberInput__StyledFieldContainer",
|
|
16
|
+
componentId: "sc-qotc3w-0"
|
|
17
|
+
})(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n gap: ", ";\n width: 100%;\n"], ["\n display: flex;\n flex-direction: column;\n gap: ", ";\n width: 100%;\n"])), space[200]);
|
|
18
|
+
var StyledLabel = /*#__PURE__*/styled.label.withConfig({
|
|
19
|
+
displayName: "NumberInput__StyledLabel",
|
|
20
|
+
componentId: "sc-qotc3w-1"
|
|
21
|
+
})(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n gap: ", ";\n font: ", ";\n color: ", ";\n\n &[data-disabled='true'] {\n color: ", ";\n }\n"], ["\n display: flex;\n align-items: center;\n gap: ", ";\n font: ", ";\n color: ", ";\n\n &[data-disabled='true'] {\n color: ", ";\n }\n"])), space[100], field.label.typography, field.label.color, field.label.colorDisabled);
|
|
22
|
+
var StyledRequiredIndicator = /*#__PURE__*/styled.span.withConfig({
|
|
23
|
+
displayName: "NumberInput__StyledRequiredIndicator",
|
|
24
|
+
componentId: "sc-qotc3w-2"
|
|
25
|
+
})(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n color: ", ";\n font-weight: ", ";\n"], ["\n color: ", ";\n font-weight: ", ";\n"])), field.requiredIndicator.color, field.requiredIndicator.fontWeight);
|
|
26
|
+
var StyledInputWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
27
|
+
displayName: "NumberInput__StyledInputWrapper",
|
|
28
|
+
componentId: "sc-qotc3w-3"
|
|
29
|
+
})(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: relative;\n display: flex;\n align-items: center;\n"], ["\n position: relative;\n display: flex;\n align-items: center;\n"])));
|
|
30
|
+
var StyledNumberInput = /*#__PURE__*/styled(StyledInputBase).withConfig({
|
|
31
|
+
displayName: "NumberInput__StyledNumberInput",
|
|
32
|
+
componentId: "sc-qotc3w-4"
|
|
33
|
+
})(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n /* Add padding on the right to make room for stepper buttons */\n padding-right: ", ";\n"], ["\n /* Add padding on the right to make room for stepper buttons */\n padding-right: ", ";\n"])), tokens.semantic.space[1000]);
|
|
34
|
+
var StyledStepperContainer = /*#__PURE__*/styled.div.withConfig({
|
|
35
|
+
displayName: "NumberInput__StyledStepperContainer",
|
|
36
|
+
componentId: "sc-qotc3w-5"
|
|
37
|
+
})(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n position: absolute;\n right: ", ";\n display: flex;\n flex-direction: row;\n gap: ", ";\n"], ["\n position: absolute;\n right: ", ";\n display: flex;\n flex-direction: row;\n gap: ", ";\n"])), tokens.semantic.space[200], tokens.semantic.space[200]);
|
|
38
|
+
var StyledHelperText = /*#__PURE__*/styled.div.withConfig({
|
|
39
|
+
displayName: "NumberInput__StyledHelperText",
|
|
40
|
+
componentId: "sc-qotc3w-6"
|
|
41
|
+
})(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n font: ", ";\n color: ", ";\n"], ["\n font: ", ";\n color: ", ";\n"
|
|
42
|
+
/**
|
|
43
|
+
* NumberInput component for numeric input with stepper buttons and WCAG 2.2 AA compliance
|
|
44
|
+
*
|
|
45
|
+
* Features:
|
|
46
|
+
* - Stepper buttons for increment/decrement
|
|
47
|
+
* - Keyboard arrow up/down support
|
|
48
|
+
* - Min/max value constraints
|
|
49
|
+
* - Custom step values
|
|
50
|
+
* - Decimal and integer support
|
|
51
|
+
* - Full accessibility with ARIA attributes
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```tsx
|
|
55
|
+
* <NumberInput
|
|
56
|
+
* label="Quantity"
|
|
57
|
+
* min={0}
|
|
58
|
+
* max={100}
|
|
59
|
+
* step={1}
|
|
60
|
+
* value={value}
|
|
61
|
+
* onChange={(newValue) => setValue(newValue)}
|
|
62
|
+
* />
|
|
63
|
+
* ```
|
|
64
|
+
*/])), field.helperText.typography, function (_a) {
|
|
65
|
+
var $isError = _a.$isError;
|
|
66
|
+
return $isError ? field.helperText.colorError : field.helperText.color;
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* NumberInput component for numeric input with stepper buttons and WCAG 2.2 AA compliance
|
|
70
|
+
*
|
|
71
|
+
* Features:
|
|
72
|
+
* - Stepper buttons for increment/decrement
|
|
73
|
+
* - Keyboard arrow up/down support
|
|
74
|
+
* - Min/max value constraints
|
|
75
|
+
* - Custom step values
|
|
76
|
+
* - Decimal and integer support
|
|
77
|
+
* - Full accessibility with ARIA attributes
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```tsx
|
|
81
|
+
* <NumberInput
|
|
82
|
+
* label="Quantity"
|
|
83
|
+
* min={0}
|
|
84
|
+
* max={100}
|
|
85
|
+
* step={1}
|
|
86
|
+
* value={value}
|
|
87
|
+
* onChange={(newValue) => setValue(newValue)}
|
|
88
|
+
* />
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
var NumberInput = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
92
|
+
var label = _a.label,
|
|
93
|
+
helperText = _a.helperText,
|
|
94
|
+
error = _a.error,
|
|
95
|
+
_b = _a.required,
|
|
96
|
+
required = _b === void 0 ? false : _b,
|
|
97
|
+
_c = _a.disabled,
|
|
98
|
+
disabled = _c === void 0 ? false : _c,
|
|
99
|
+
min = _a.min,
|
|
100
|
+
max = _a.max,
|
|
101
|
+
_d = _a.step,
|
|
102
|
+
step = _d === void 0 ? 1 : _d,
|
|
103
|
+
value = _a.value,
|
|
104
|
+
defaultValue = _a.defaultValue,
|
|
105
|
+
onChange = _a.onChange,
|
|
106
|
+
providedId = _a.id,
|
|
107
|
+
testId = _a["data-testid"],
|
|
108
|
+
placeholder = _a.placeholder,
|
|
109
|
+
ariaLabel = _a["aria-label"],
|
|
110
|
+
ariaDescribedBy = _a["aria-describedby"],
|
|
111
|
+
rest = __rest(_a, ["label", "helperText", "error", "required", "disabled", "min", "max", "step", "value", "defaultValue", "onChange", "id", 'data-testid', "placeholder", 'aria-label', 'aria-describedby']);
|
|
112
|
+
var generatedId = useId();
|
|
113
|
+
var id = providedId || generatedId;
|
|
114
|
+
var helperId = "".concat(id, "-helper");
|
|
115
|
+
var errorId = "".concat(id, "-error");
|
|
116
|
+
// Parse string value to number or empty string
|
|
117
|
+
var parseValue = useCallback(function (val) {
|
|
118
|
+
if (val === '' || val === '-') return '';
|
|
119
|
+
var parsed = parseFloat(val);
|
|
120
|
+
return isNaN(parsed) ? '' : parsed;
|
|
121
|
+
}, []);
|
|
122
|
+
// Format number to string for display
|
|
123
|
+
var formatValue = useCallback(function (val) {
|
|
124
|
+
return val === '' ? '' : String(val);
|
|
125
|
+
}, []);
|
|
126
|
+
// Handle increment
|
|
127
|
+
var handleIncrement = useCallback(function () {
|
|
128
|
+
if (disabled) return;
|
|
129
|
+
var inputElement = ref === null || ref === void 0 ? void 0 : ref.current;
|
|
130
|
+
var currentValue = value !== undefined ? value : parseValue((inputElement === null || inputElement === void 0 ? void 0 : inputElement.value) || '');
|
|
131
|
+
var numValue = currentValue === '' ? min !== undefined ? min : 0 : currentValue;
|
|
132
|
+
var newValue = numValue + step;
|
|
133
|
+
// Check max constraint
|
|
134
|
+
if (max !== undefined && newValue > max) return;
|
|
135
|
+
// Update input value directly for both controlled and uncontrolled
|
|
136
|
+
if (inputElement) {
|
|
137
|
+
inputElement.value = String(newValue);
|
|
138
|
+
}
|
|
139
|
+
// Create synthetic event
|
|
140
|
+
var syntheticEvent = {
|
|
141
|
+
target: inputElement || {
|
|
142
|
+
value: String(newValue)
|
|
143
|
+
},
|
|
144
|
+
currentTarget: inputElement || {
|
|
145
|
+
value: String(newValue)
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue, syntheticEvent);
|
|
149
|
+
}, [disabled, value, min, max, step, onChange, parseValue, ref]);
|
|
150
|
+
// Handle decrement
|
|
151
|
+
var handleDecrement = useCallback(function () {
|
|
152
|
+
if (disabled) return;
|
|
153
|
+
var inputElement = ref === null || ref === void 0 ? void 0 : ref.current;
|
|
154
|
+
var currentValue = value !== undefined ? value : parseValue((inputElement === null || inputElement === void 0 ? void 0 : inputElement.value) || '');
|
|
155
|
+
var numValue = currentValue === '' ? max !== undefined ? max : 0 : currentValue;
|
|
156
|
+
var newValue = numValue - step;
|
|
157
|
+
// Check min constraint
|
|
158
|
+
if (min !== undefined && newValue < min) return;
|
|
159
|
+
// Update input value directly for both controlled and uncontrolled
|
|
160
|
+
if (inputElement) {
|
|
161
|
+
inputElement.value = String(newValue);
|
|
162
|
+
}
|
|
163
|
+
// Create synthetic event
|
|
164
|
+
var syntheticEvent = {
|
|
165
|
+
target: inputElement || {
|
|
166
|
+
value: String(newValue)
|
|
167
|
+
},
|
|
168
|
+
currentTarget: inputElement || {
|
|
169
|
+
value: String(newValue)
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue, syntheticEvent);
|
|
173
|
+
}, [disabled, value, min, max, step, onChange, parseValue, ref]);
|
|
174
|
+
// Handle input change
|
|
175
|
+
var handleChange = useCallback(function (e) {
|
|
176
|
+
var inputValue = e.target.value;
|
|
177
|
+
// Allow empty, negative sign, or valid number (including decimals)
|
|
178
|
+
if (inputValue === '' || inputValue === '-' || /^-?\d*\.?\d*$/.test(inputValue)) {
|
|
179
|
+
var parsedValue = parseValue(inputValue);
|
|
180
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(parsedValue, e);
|
|
181
|
+
} else {
|
|
182
|
+
// Prevent invalid input by not updating
|
|
183
|
+
e.preventDefault();
|
|
184
|
+
e.target.value = formatValue(value !== undefined ? value : '');
|
|
185
|
+
}
|
|
186
|
+
}, [onChange, parseValue, value, formatValue]);
|
|
187
|
+
// Handle keyboard navigation
|
|
188
|
+
var handleKeyDown = useCallback(function (e) {
|
|
189
|
+
if (e.key === 'ArrowUp') {
|
|
190
|
+
e.preventDefault();
|
|
191
|
+
handleIncrement();
|
|
192
|
+
} else if (e.key === 'ArrowDown') {
|
|
193
|
+
e.preventDefault();
|
|
194
|
+
handleDecrement();
|
|
195
|
+
}
|
|
196
|
+
}, [handleIncrement, handleDecrement]);
|
|
197
|
+
// Check if buttons should be disabled
|
|
198
|
+
var isIncrementDisabled = disabled || max !== undefined && value !== '' && typeof value === 'number' && value >= max;
|
|
199
|
+
var isDecrementDisabled = disabled || min !== undefined && value !== '' && typeof value === 'number' && value <= min;
|
|
200
|
+
// Build aria-describedby
|
|
201
|
+
var ariaDescribedByIds = [ariaDescribedBy, helperText ? helperId : null, error ? errorId : null].filter(Boolean).join(' ') || undefined;
|
|
202
|
+
return jsxs(StyledFieldContainer, {
|
|
203
|
+
children: [label && jsxs(StyledLabel, {
|
|
204
|
+
htmlFor: id,
|
|
205
|
+
"data-disabled": disabled,
|
|
206
|
+
children: [label, required && jsx(StyledRequiredIndicator, {
|
|
207
|
+
"aria-label": "required",
|
|
208
|
+
children: "*"
|
|
209
|
+
})]
|
|
210
|
+
}), jsxs(StyledInputWrapper, {
|
|
211
|
+
children: [jsx(StyledNumberInput, __assign({
|
|
212
|
+
ref: ref,
|
|
213
|
+
id: id,
|
|
214
|
+
type: "text",
|
|
215
|
+
inputMode: "decimal",
|
|
216
|
+
value: value !== undefined ? formatValue(value) : undefined,
|
|
217
|
+
defaultValue: defaultValue !== undefined ? formatValue(defaultValue) : undefined,
|
|
218
|
+
onChange: handleChange,
|
|
219
|
+
onKeyDown: handleKeyDown,
|
|
220
|
+
disabled: disabled,
|
|
221
|
+
required: required,
|
|
222
|
+
placeholder: placeholder,
|
|
223
|
+
"$hasError": !!error,
|
|
224
|
+
"$disabled": disabled,
|
|
225
|
+
"aria-label": ariaLabel || label,
|
|
226
|
+
"aria-invalid": !!error,
|
|
227
|
+
"aria-describedby": ariaDescribedByIds,
|
|
228
|
+
"aria-required": required,
|
|
229
|
+
"data-testid": testId,
|
|
230
|
+
role: "spinbutton",
|
|
231
|
+
"aria-valuemin": min,
|
|
232
|
+
"aria-valuemax": max,
|
|
233
|
+
"aria-valuenow": typeof value === 'number' ? value : undefined
|
|
234
|
+
}, rest)), jsxs(StyledStepperContainer, {
|
|
235
|
+
children: [jsx(IconButton, {
|
|
236
|
+
iconName: "caretUp",
|
|
237
|
+
variant: "secondary",
|
|
238
|
+
size: "small",
|
|
239
|
+
onClick: handleIncrement,
|
|
240
|
+
disabled: isIncrementDisabled,
|
|
241
|
+
"aria-label": "Increment value",
|
|
242
|
+
tabIndex: -1,
|
|
243
|
+
type: "button"
|
|
244
|
+
}), jsx(IconButton, {
|
|
245
|
+
iconName: "caretDown",
|
|
246
|
+
variant: "secondary",
|
|
247
|
+
size: "small",
|
|
248
|
+
onClick: handleDecrement,
|
|
249
|
+
disabled: isDecrementDisabled,
|
|
250
|
+
"aria-label": "Decrement value",
|
|
251
|
+
tabIndex: -1,
|
|
252
|
+
type: "button"
|
|
253
|
+
})]
|
|
254
|
+
})]
|
|
255
|
+
}), (helperText || error) && jsx(StyledHelperText, {
|
|
256
|
+
id: error ? errorId : helperId,
|
|
257
|
+
"$isError": !!error,
|
|
258
|
+
role: error ? 'alert' : undefined,
|
|
259
|
+
"aria-live": error ? 'polite' : undefined,
|
|
260
|
+
children: error || helperText
|
|
261
|
+
})]
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
NumberInput.displayName = 'NumberInput';
|
|
265
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
266
|
+
|
|
267
|
+
export { NumberInput };
|
|
268
|
+
//# sourceMappingURL=NumberInput.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberInput.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
interface PageTitleProps {
|
|
3
|
+
title: string;
|
|
4
|
+
hasBackButton?: boolean;
|
|
5
|
+
subtitle?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated PageTitle is a leftover from the personal site (its back button always links to `/music`)
|
|
9
|
+
* and will be removed in the next major version. Compose a page title from `Typography` in a `Stack`:
|
|
10
|
+
*
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <Stack direction="column" gap="md">
|
|
13
|
+
* <Typography variant="h1">{title}</Typography>
|
|
14
|
+
* <Typography variant="caption" color="subdued">{subtitle}</Typography>
|
|
15
|
+
* </Stack>
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* For a back link, add an `IconButton` with your own `url` and `aria-label`.
|
|
19
|
+
*/
|
|
20
|
+
export declare const PageTitle: FC<PageTitleProps>;
|
|
21
|
+
export {};
|