@charcoal-ui/react 4.0.0-beta.0 → 4.0.0-beta.11
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/README.md +1 -1
- package/dist/_lib/compat.d.ts +0 -12
- package/dist/_lib/compat.d.ts.map +1 -1
- package/dist/_lib/createDivComponent.d.ts +4 -0
- package/dist/_lib/createDivComponent.d.ts.map +1 -0
- package/dist/_lib/useClassNames.d.ts +2 -2
- package/dist/_lib/useClassNames.d.ts.map +1 -1
- package/dist/components/Button/index.d.ts +5 -1
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Checkbox/CheckboxInput/index.d.ts +11 -0
- package/dist/components/Checkbox/CheckboxInput/index.d.ts.map +1 -0
- package/dist/components/Checkbox/CheckboxWithLabel.d.ts +9 -0
- package/dist/components/Checkbox/CheckboxWithLabel.d.ts.map +1 -0
- package/dist/components/Checkbox/index.d.ts +12 -21
- package/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/Clickable/index.d.ts +9 -15
- package/dist/components/Clickable/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/Divider/index.d.ts +3 -0
- package/dist/components/DropdownSelector/Divider/index.d.ts.map +1 -0
- package/dist/components/DropdownSelector/DropdownMenuItem/index.d.ts +8 -0
- package/dist/components/DropdownSelector/DropdownMenuItem/index.d.ts.map +1 -0
- package/dist/components/DropdownSelector/DropdownPopover.d.ts.map +1 -1
- package/dist/components/DropdownSelector/ListItem/index.d.ts +5 -13
- package/dist/components/DropdownSelector/ListItem/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/index.d.ts +10 -3
- package/dist/components/DropdownSelector/MenuItem/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.d.ts +1 -1
- package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.d.ts.map +1 -1
- package/dist/components/DropdownSelector/MenuItemGroup/index.d.ts +1 -3
- package/dist/components/DropdownSelector/MenuItemGroup/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/MenuList/index.d.ts +1 -4
- package/dist/components/DropdownSelector/MenuList/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/Popover/index.d.ts +2 -2
- package/dist/components/DropdownSelector/Popover/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/index.d.ts +3 -1
- package/dist/components/DropdownSelector/index.d.ts.map +1 -1
- package/dist/components/FieldLabel/index.d.ts +1 -0
- package/dist/components/FieldLabel/index.d.ts.map +1 -1
- package/dist/components/IconButton/index.d.ts +7 -5
- package/dist/components/IconButton/index.d.ts.map +1 -1
- package/dist/components/LoadingSpinner/index.d.ts +1 -0
- package/dist/components/LoadingSpinner/index.d.ts.map +1 -1
- package/dist/components/Modal/Dialog/index.d.ts +6 -24
- package/dist/components/Modal/Dialog/index.d.ts.map +1 -1
- package/dist/components/Modal/ModalPlumbing.d.ts +10 -3
- package/dist/components/Modal/ModalPlumbing.d.ts.map +1 -1
- package/dist/components/Modal/index.d.ts +6 -2
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/useCustomModalOverlay.d.ts +1 -0
- package/dist/components/Modal/useCustomModalOverlay.d.ts.map +1 -1
- package/dist/components/Radio/RadioGroup/index.d.ts +20 -0
- package/dist/components/Radio/RadioGroup/index.d.ts.map +1 -0
- package/dist/components/Radio/RadioGroupContext.d.ts +11 -0
- package/dist/components/Radio/RadioGroupContext.d.ts.map +1 -0
- package/dist/components/Radio/RadioInput/index.d.ts +10 -0
- package/dist/components/Radio/RadioInput/index.d.ts.map +1 -0
- package/dist/components/Radio/index.d.ts +1 -14
- package/dist/components/Radio/index.d.ts.map +1 -1
- package/dist/components/SegmentedControl/index.d.ts +1 -0
- package/dist/components/SegmentedControl/index.d.ts.map +1 -1
- package/dist/components/Switch/SwitchInput/index.d.ts +9 -0
- package/dist/components/Switch/SwitchInput/index.d.ts.map +1 -0
- package/dist/components/Switch/SwitchWithLabel.d.ts +9 -0
- package/dist/components/Switch/SwitchWithLabel.d.ts.map +1 -0
- package/dist/components/Switch/index.d.ts +4 -15
- package/dist/components/Switch/index.d.ts.map +1 -1
- package/dist/components/TagItem/index.d.ts +10 -15
- package/dist/components/TagItem/index.d.ts.map +1 -1
- package/dist/components/TextArea/index.d.ts +29 -18
- package/dist/components/TextArea/index.d.ts.map +1 -1
- package/dist/components/TextField/AssistiveText/index.d.ts +5 -0
- package/dist/components/TextField/AssistiveText/index.d.ts.map +1 -0
- package/dist/components/TextField/index.d.ts +33 -22
- package/dist/components/TextField/index.d.ts.map +1 -1
- package/dist/core/CharcoalProvider.d.ts +4 -11
- package/dist/core/CharcoalProvider.d.ts.map +1 -1
- package/dist/core/SSRProvider.d.ts +3 -1
- package/dist/core/SSRProvider.d.ts.map +1 -1
- package/dist/index.cjs.js +576 -1255
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +1097 -3
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +555 -1231
- package/dist/index.esm.js.map +1 -1
- package/package.json +25 -23
- package/src/README.mdx +68 -0
- package/src/SSR.mdx +67 -0
- package/src/_lib/compat.ts +0 -11
- package/src/_lib/createDivComponent.tsx +11 -0
- package/src/_lib/useClassNames.ts +3 -9
- package/src/components/Button/__snapshots__/index.story.storyshot +18 -56
- package/src/components/Button/index.css +2 -3
- package/src/components/Button/index.story.tsx +14 -67
- package/src/components/Button/index.tsx +7 -3
- package/src/components/Checkbox/CheckboxInput/__snapshots__/index.story.storyshot +77 -0
- package/src/components/Checkbox/CheckboxInput/index.css +110 -0
- package/src/components/Checkbox/CheckboxInput/index.story.tsx +51 -0
- package/src/components/Checkbox/CheckboxInput/index.tsx +47 -0
- package/src/components/Checkbox/CheckboxWithLabel.tsx +24 -0
- package/src/components/Checkbox/__snapshots__/index.story.storyshot +103 -538
- package/src/components/Checkbox/index.css +21 -0
- package/src/components/Checkbox/index.story.tsx +49 -79
- package/src/components/Checkbox/index.tsx +32 -162
- package/src/components/Clickable/__snapshots__/index.story.storyshot +4 -80
- package/src/components/Clickable/index.css +41 -0
- package/src/components/Clickable/index.story.tsx +2 -2
- package/src/components/Clickable/index.tsx +19 -84
- package/src/components/DropdownSelector/Divider/index.css +11 -0
- package/src/components/DropdownSelector/Divider/index.tsx +5 -0
- package/src/components/DropdownSelector/DropdownMenuItem/index.css +20 -0
- package/src/components/DropdownSelector/DropdownMenuItem/index.tsx +34 -0
- package/src/components/DropdownSelector/DropdownPopover.tsx +16 -9
- package/src/components/DropdownSelector/ListItem/__snapshots__/index.story.storyshot +41 -224
- package/src/components/DropdownSelector/ListItem/index.css +24 -0
- package/src/components/DropdownSelector/ListItem/index.story.tsx +12 -6
- package/src/components/DropdownSelector/ListItem/index.tsx +14 -53
- package/src/components/DropdownSelector/MenuItem/index.tsx +17 -12
- package/src/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.tsx +2 -2
- package/src/components/DropdownSelector/MenuItemGroup/index.css +19 -0
- package/src/components/DropdownSelector/MenuItemGroup/index.tsx +6 -28
- package/src/components/DropdownSelector/MenuList/__snapshots__/index.story.storyshot +162 -416
- package/src/components/DropdownSelector/MenuList/index.css +4 -0
- package/src/components/DropdownSelector/MenuList/index.story.tsx +1 -1
- package/src/components/DropdownSelector/MenuList/index.tsx +4 -12
- package/src/components/DropdownSelector/Popover/__snapshots__/index.story.storyshot +5 -5
- package/src/components/DropdownSelector/Popover/index.css +11 -0
- package/src/components/DropdownSelector/Popover/index.story.tsx +1 -1
- package/src/components/DropdownSelector/Popover/index.tsx +7 -17
- package/src/components/DropdownSelector/__snapshots__/index.story.storyshot +468 -2494
- package/src/components/DropdownSelector/index.css +84 -0
- package/src/components/DropdownSelector/index.story.tsx +2 -6
- package/src/components/DropdownSelector/index.tsx +61 -137
- package/src/components/FieldLabel/index.css +35 -0
- package/src/components/FieldLabel/index.tsx +15 -105
- package/src/components/Icon/__snapshots__/index.story.storyshot +1 -1
- package/src/components/Icon/index.story.tsx +1 -1
- package/src/components/IconButton/__snapshots__/index.story.storyshot +19 -297
- package/src/components/IconButton/index.css +118 -0
- package/src/components/IconButton/index.story.tsx +17 -40
- package/src/components/IconButton/index.tsx +41 -118
- package/src/components/LoadingSpinner/__snapshots__/LoadingSpinnerIcon.story.storyshot +2 -17
- package/src/components/LoadingSpinner/__snapshots__/index.story.storyshot +80 -30
- package/src/components/LoadingSpinner/index.css +42 -0
- package/src/components/LoadingSpinner/index.story.tsx +19 -8
- package/src/components/LoadingSpinner/index.tsx +26 -52
- package/src/components/Modal/Dialog/index.css +44 -0
- package/src/components/Modal/Dialog/index.tsx +14 -57
- package/src/components/Modal/ModalPlumbing.css +40 -0
- package/src/components/Modal/ModalPlumbing.tsx +13 -61
- package/src/components/Modal/__snapshots__/index.story.storyshot +281 -2221
- package/src/components/Modal/index.css +36 -0
- package/src/components/Modal/index.story.tsx +26 -13
- package/src/components/Modal/index.tsx +42 -78
- package/src/components/Modal/useCustomModalOverlay.tsx +19 -4
- package/src/components/Radio/RadioGroup/index.css +5 -0
- package/src/components/Radio/RadioGroup/index.tsx +80 -0
- package/src/components/Radio/RadioGroupContext.ts +23 -0
- package/src/components/Radio/RadioInput/index.css +82 -0
- package/src/components/Radio/RadioInput/index.tsx +41 -0
- package/src/components/Radio/__snapshots__/index.story.storyshot +111 -855
- package/src/components/Radio/index.css +18 -0
- package/src/components/Radio/index.story.tsx +47 -40
- package/src/components/Radio/index.test.tsx +18 -26
- package/src/components/Radio/index.tsx +16 -208
- package/src/components/SegmentedControl/__snapshots__/index.story.storyshot +32 -262
- package/src/components/SegmentedControl/index.css +50 -0
- package/src/components/SegmentedControl/index.story.tsx +1 -1
- package/src/components/SegmentedControl/index.tsx +20 -89
- package/src/components/Switch/SwitchInput/index.css +82 -0
- package/src/components/Switch/SwitchInput/index.tsx +40 -0
- package/src/components/Switch/SwitchWithLabel.tsx +24 -0
- package/src/components/Switch/__snapshots__/index.story.storyshot +35 -539
- package/src/components/Switch/index.css +23 -0
- package/src/components/Switch/index.story.tsx +16 -19
- package/src/components/Switch/index.tsx +43 -140
- package/src/components/TagItem/__snapshots__/index.story.storyshot +212 -1063
- package/src/components/TagItem/index.css +140 -0
- package/src/components/TagItem/index.story.tsx +45 -162
- package/src/components/TagItem/index.tsx +72 -220
- package/src/components/TextArea/TextArea.story.tsx +63 -25
- package/src/components/TextArea/__snapshots__/TextArea.story.storyshot +615 -1055
- package/src/components/TextArea/index.css +78 -0
- package/src/components/TextArea/index.tsx +83 -174
- package/src/components/TextField/AssistiveText/index.css +10 -0
- package/src/components/TextField/AssistiveText/index.tsx +6 -0
- package/src/components/TextField/TextField.story.tsx +85 -76
- package/src/components/TextField/__snapshots__/TextField.story.storyshot +632 -1710
- package/src/components/TextField/index.css +87 -0
- package/src/components/TextField/index.tsx +92 -211
- package/src/core/CharcoalProvider.tsx +5 -29
- package/src/core/SSRProvider.tsx +12 -1
- package/src/index.ts +7 -19
- package/src/type.d.ts +3 -8
- package/dist/components/Button/index.story.d.ts +0 -24
- package/dist/components/Button/index.story.d.ts.map +0 -1
- package/dist/components/Checkbox/index.story.d.ts +0 -8
- package/dist/components/Checkbox/index.story.d.ts.map +0 -1
- package/dist/components/Clickable/index.story.d.ts +0 -6
- package/dist/components/Clickable/index.story.d.ts.map +0 -1
- package/dist/components/DropdownSelector/Divider.d.ts +0 -7
- package/dist/components/DropdownSelector/Divider.d.ts.map +0 -1
- package/dist/components/DropdownSelector/DropdownMenuItem.d.ts +0 -7
- package/dist/components/DropdownSelector/DropdownMenuItem.d.ts.map +0 -1
- package/dist/components/DropdownSelector/ListItem/index.story.d.ts +0 -9
- package/dist/components/DropdownSelector/ListItem/index.story.d.ts.map +0 -1
- package/dist/components/DropdownSelector/MenuList/index.story.d.ts +0 -8
- package/dist/components/DropdownSelector/MenuList/index.story.d.ts.map +0 -1
- package/dist/components/DropdownSelector/Popover/index.story.d.ts +0 -5
- package/dist/components/DropdownSelector/Popover/index.story.d.ts.map +0 -1
- package/dist/components/DropdownSelector/index.story.d.ts +0 -19
- package/dist/components/DropdownSelector/index.story.d.ts.map +0 -1
- package/dist/components/Icon/index.story.d.ts +0 -6
- package/dist/components/Icon/index.story.d.ts.map +0 -1
- package/dist/components/IconButton/index.story.d.ts +0 -9
- package/dist/components/IconButton/index.story.d.ts.map +0 -1
- package/dist/components/LoadingSpinner/LoadingSpinnerIcon.story.d.ts +0 -8
- package/dist/components/LoadingSpinner/LoadingSpinnerIcon.story.d.ts.map +0 -1
- package/dist/components/LoadingSpinner/index.story.d.ts +0 -6
- package/dist/components/LoadingSpinner/index.story.d.ts.map +0 -1
- package/dist/components/Modal/__stories__/InternalScrollStory.d.ts +0 -4
- package/dist/components/Modal/__stories__/InternalScrollStory.d.ts.map +0 -1
- package/dist/components/Modal/index.story.d.ts +0 -21
- package/dist/components/Modal/index.story.d.ts.map +0 -1
- package/dist/components/MultiSelect/context.d.ts +0 -14
- package/dist/components/MultiSelect/context.d.ts.map +0 -1
- package/dist/components/MultiSelect/index.d.ts +0 -36
- package/dist/components/MultiSelect/index.d.ts.map +0 -1
- package/dist/components/MultiSelect/index.story.d.ts +0 -82
- package/dist/components/MultiSelect/index.story.d.ts.map +0 -1
- package/dist/components/MultiSelect/index.test.d.ts +0 -2
- package/dist/components/MultiSelect/index.test.d.ts.map +0 -1
- package/dist/components/Radio/index.story.d.ts +0 -26
- package/dist/components/Radio/index.story.d.ts.map +0 -1
- package/dist/components/Radio/index.test.d.ts +0 -2
- package/dist/components/Radio/index.test.d.ts.map +0 -1
- package/dist/components/SegmentedControl/index.story.d.ts +0 -7
- package/dist/components/SegmentedControl/index.story.d.ts.map +0 -1
- package/dist/components/Switch/index.story.d.ts +0 -9
- package/dist/components/Switch/index.story.d.ts.map +0 -1
- package/dist/components/TagItem/index.story.d.ts +0 -16
- package/dist/components/TagItem/index.story.d.ts.map +0 -1
- package/dist/components/TextArea/TextArea.story.d.ts +0 -9
- package/dist/components/TextArea/TextArea.story.d.ts.map +0 -1
- package/dist/components/TextField/TextField.story.d.ts +0 -22
- package/dist/components/TextField/TextField.story.d.ts.map +0 -1
- package/dist/components/a11y.test.d.ts +0 -2
- package/dist/components/a11y.test.d.ts.map +0 -1
- package/dist/core/ComponentAbstraction.d.ts +0 -24
- package/dist/core/ComponentAbstraction.d.ts.map +0 -1
- package/dist/styled.d.ts +0 -95
- package/dist/styled.d.ts.map +0 -1
- package/src/components/DropdownSelector/Divider.tsx +0 -16
- package/src/components/DropdownSelector/DropdownMenuItem.tsx +0 -43
- package/src/components/LoadingSpinner/LoadingSpinnerIcon.story.tsx +0 -13
- package/src/components/Modal/__stories__/InternalScrollStory.tsx +0 -75
- package/src/components/MultiSelect/__snapshots__/index.story.storyshot +0 -1066
- package/src/components/MultiSelect/context.ts +0 -23
- package/src/components/MultiSelect/index.story.tsx +0 -216
- package/src/components/MultiSelect/index.test.tsx +0 -263
- package/src/components/MultiSelect/index.tsx +0 -281
- package/src/components/a11y.test.tsx +0 -99
- package/src/core/ComponentAbstraction.tsx +0 -48
- package/src/styled.ts +0 -3
package/dist/index.cjs.js
CHANGED
|
@@ -30,7 +30,6 @@ __export(src_exports, {
|
|
|
30
30
|
CharcoalProvider: () => CharcoalProvider,
|
|
31
31
|
Checkbox: () => Checkbox_default,
|
|
32
32
|
Clickable: () => Clickable_default,
|
|
33
|
-
ComponentAbstraction: () => ComponentAbstraction,
|
|
34
33
|
DropdownMenuItem: () => DropdownMenuItem,
|
|
35
34
|
DropdownSelector: () => DropdownSelector,
|
|
36
35
|
Icon: () => Icon_default,
|
|
@@ -42,72 +41,38 @@ __export(src_exports, {
|
|
|
42
41
|
ModalAlign: () => ModalAlign,
|
|
43
42
|
ModalBody: () => ModalBody,
|
|
44
43
|
ModalButtons: () => ModalButtons,
|
|
44
|
+
ModalCloseButton: () => ModalCloseButton,
|
|
45
45
|
ModalHeader: () => ModalHeader,
|
|
46
|
-
MultiSelect: () => MultiSelect_default,
|
|
47
|
-
MultiSelectGroup: () => MultiSelectGroup,
|
|
48
46
|
OverlayProvider: () => import_overlays.OverlayProvider,
|
|
49
47
|
Radio: () => Radio_default,
|
|
50
48
|
RadioGroup: () => RadioGroup,
|
|
51
|
-
SSRProvider: () =>
|
|
49
|
+
SSRProvider: () => SSRProvider,
|
|
52
50
|
SegmentedControl: () => SegmentedControl_default,
|
|
53
51
|
Switch: () => Switch_default,
|
|
54
52
|
TagItem: () => TagItem_default,
|
|
55
53
|
TextArea: () => TextArea_default,
|
|
56
|
-
TextField: () => TextField_default
|
|
57
|
-
useComponentAbstraction: () => useComponentAbstraction
|
|
54
|
+
TextField: () => TextField_default
|
|
58
55
|
});
|
|
59
56
|
module.exports = __toCommonJS(src_exports);
|
|
60
57
|
|
|
61
|
-
// src/core/ComponentAbstraction.tsx
|
|
62
|
-
var import_react = require("react");
|
|
63
|
-
var React = __toESM(require("react"));
|
|
64
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
65
|
-
var DefaultLink = React.forwardRef(function DefaultLink2({
|
|
66
|
-
to,
|
|
67
|
-
children,
|
|
68
|
-
...rest
|
|
69
|
-
}, ref) {
|
|
70
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: to, ref, ...rest, children });
|
|
71
|
-
});
|
|
72
|
-
var DefaultValue = {
|
|
73
|
-
Link: DefaultLink
|
|
74
|
-
};
|
|
75
|
-
var ComponentAbstractionContext = React.createContext(DefaultValue);
|
|
76
|
-
function ComponentAbstraction({
|
|
77
|
-
children,
|
|
78
|
-
components
|
|
79
|
-
}) {
|
|
80
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ComponentAbstractionContext.Provider, { value: {
|
|
81
|
-
...DefaultValue,
|
|
82
|
-
...components
|
|
83
|
-
}, children });
|
|
84
|
-
}
|
|
85
|
-
function useComponentAbstraction() {
|
|
86
|
-
return (0, import_react.useContext)(ComponentAbstractionContext);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
58
|
// src/core/SSRProvider.tsx
|
|
90
59
|
var import_ssr = require("@react-aria/ssr");
|
|
60
|
+
var import_react = require("react");
|
|
61
|
+
function isReactVersionOver(minVersion) {
|
|
62
|
+
const reactMajorVersion = parseInt(import_react.version.split(".")[0], 10);
|
|
63
|
+
return Number.isFinite(reactMajorVersion) ? reactMajorVersion >= minVersion : false;
|
|
64
|
+
}
|
|
65
|
+
var SSRProvider = isReactVersionOver(18) ? import_react.Fragment : import_ssr.SSRProvider;
|
|
91
66
|
|
|
92
67
|
// src/core/OverlayProvider.tsx
|
|
93
68
|
var import_overlays = require("@react-aria/overlays");
|
|
94
69
|
|
|
95
70
|
// src/core/CharcoalProvider.tsx
|
|
96
|
-
var
|
|
97
|
-
var import_styled = require("@charcoal-ui/styled");
|
|
98
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
71
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
99
72
|
function CharcoalProvider({
|
|
100
|
-
|
|
101
|
-
defaultTheme = themeMap[":root"],
|
|
102
|
-
components = {},
|
|
103
|
-
injectTokens = true,
|
|
104
|
-
children,
|
|
105
|
-
background
|
|
73
|
+
children
|
|
106
74
|
}) {
|
|
107
|
-
return /* @__PURE__ */ (0,
|
|
108
|
-
injectTokens && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_styled.TokenInjector, { theme: themeMap, background }),
|
|
109
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ComponentAbstraction, { components, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_overlays.OverlayProvider, { children }) })
|
|
110
|
-
] }) });
|
|
75
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SSRProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_overlays.OverlayProvider, { children }) });
|
|
111
76
|
}
|
|
112
77
|
|
|
113
78
|
// src/components/Button/index.tsx
|
|
@@ -115,123 +80,58 @@ var import_react3 = require("react");
|
|
|
115
80
|
|
|
116
81
|
// src/_lib/useClassNames.ts
|
|
117
82
|
var import_react2 = require("react");
|
|
118
|
-
function useClassNames(
|
|
119
|
-
return (0, import_react2.useMemo)(() =>
|
|
83
|
+
function useClassNames(...classNames) {
|
|
84
|
+
return (0, import_react2.useMemo)(() => classNames.filter((v) => v).join(" "), [classNames]);
|
|
120
85
|
}
|
|
121
86
|
|
|
122
87
|
// src/components/Button/index.tsx
|
|
123
|
-
var
|
|
88
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
124
89
|
var Button = (0, import_react3.forwardRef)(function Button2({
|
|
125
90
|
variant,
|
|
126
91
|
fullWidth,
|
|
127
92
|
size,
|
|
128
93
|
className,
|
|
129
|
-
|
|
94
|
+
component,
|
|
130
95
|
isActive,
|
|
131
96
|
...props
|
|
132
97
|
}, ref) {
|
|
133
|
-
const Component = (0, import_react3.useMemo)(() =>
|
|
98
|
+
const Component = (0, import_react3.useMemo)(() => component ?? "button", [component]);
|
|
134
99
|
const classNames = useClassNames("charcoal-button", className);
|
|
135
|
-
return /* @__PURE__ */ (0,
|
|
100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Component, { ...props, className: classNames, "data-variant": variant, "data-size": size, "data-full-width": fullWidth, "data-active": isActive, ref });
|
|
136
101
|
});
|
|
137
102
|
var Button_default = Button;
|
|
138
103
|
|
|
139
104
|
// src/components/Clickable/index.tsx
|
|
140
|
-
var
|
|
141
|
-
var
|
|
142
|
-
var
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const as = isLink ? Link : "button";
|
|
150
|
-
const ariaDisabled = isLink && props.disabled === true ? true : void 0;
|
|
151
|
-
let rest = props;
|
|
152
|
-
if (isLink) {
|
|
153
|
-
const {
|
|
154
|
-
disabled,
|
|
155
|
-
..._rest
|
|
156
|
-
} = props;
|
|
157
|
-
rest = _rest;
|
|
158
|
-
}
|
|
159
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(StyledClickableDiv, { ...rest, ref, as, "aria-disabled": ariaDisabled });
|
|
105
|
+
var import_react4 = require("react");
|
|
106
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
107
|
+
var Clickable = (0, import_react4.forwardRef)(function Clickable2({
|
|
108
|
+
component,
|
|
109
|
+
...props
|
|
110
|
+
}, ref) {
|
|
111
|
+
const className = useClassNames("charcoal-clickable", props.className);
|
|
112
|
+
const Component = (0, import_react4.useMemo)(() => component ?? "button", [component]);
|
|
113
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Component, { ...props, ref, className });
|
|
160
114
|
});
|
|
161
115
|
var Clickable_default = Clickable;
|
|
162
|
-
var StyledClickableDiv = import_styled_components2.default.div.withConfig({
|
|
163
|
-
componentId: "ccl__sc-1lxyknw-0"
|
|
164
|
-
})(["cursor:pointer;", "{cursor:default;}appearance:none;background:transparent;padding:0;border-style:none;outline:none;color:inherit;text-rendering:inherit;letter-spacing:inherit;word-spacing:inherit;text-decoration:none;&:focus{outline:none;}font:inherit;margin:0;overflow:visible;text-transform:none;&::-moz-focus-inner{border-style:none;padding:0;}"], import_utils.disabledSelector);
|
|
165
116
|
|
|
166
117
|
// src/components/IconButton/index.tsx
|
|
167
|
-
var
|
|
168
|
-
var
|
|
169
|
-
var
|
|
170
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
171
|
-
var IconButton = (0, import_react4.forwardRef)(function IconButtonInner({
|
|
118
|
+
var import_react5 = require("react");
|
|
119
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
120
|
+
var IconButton = (0, import_react5.forwardRef)(function IconButtonInner({
|
|
172
121
|
variant = "Default",
|
|
173
122
|
size = "M",
|
|
174
123
|
icon,
|
|
175
124
|
isActive = false,
|
|
125
|
+
componentAs,
|
|
126
|
+
as,
|
|
176
127
|
...rest
|
|
177
128
|
}, ref) {
|
|
178
129
|
validateIconSize(size, icon);
|
|
179
|
-
|
|
130
|
+
const Component = (0, import_react5.useMemo)(() => as ?? "button", [as]);
|
|
131
|
+
const classNames = useClassNames("charcoal-icon-button", rest.className);
|
|
132
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Component, { ...rest, as: componentAs, ref, className: classNames, "data-size": size, "data-active": isActive, "data-variant": variant, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("pixiv-icon", { name: icon }) });
|
|
180
133
|
});
|
|
181
134
|
var IconButton_default = IconButton;
|
|
182
|
-
var StyledIconButton = (0, import_styled_components3.default)(Clickable_default).attrs(styledProps).withConfig({
|
|
183
|
-
componentId: "ccl__sc-zssehl-0"
|
|
184
|
-
})(["user-select:none;width:", "px;height:", "px;display:flex;align-items:center;justify-content:center;color:var(", ");background-color:var(", ");border-radius:999999px;transition:0.2s background-color,0.2s box-shadow;&:not(:disabled):not([aria-disabled]),&[aria-disabled='false']{", " ", "}&:disabled,&[aria-disabled]:not([aria-disabled='false']){opacity:0.32;}"], (p) => p.$width, (p) => p.$height, ({
|
|
185
|
-
$font
|
|
186
|
-
}) => `--charcoal-${$font}`, ({
|
|
187
|
-
$background
|
|
188
|
-
}) => `--charcoal-${$background}`, ({
|
|
189
|
-
$isActive,
|
|
190
|
-
$background,
|
|
191
|
-
$font
|
|
192
|
-
}) => $isActive ? (0, import_styled_components3.css)(["color:var(--charcoal-", "-press);background-color:var(--charcoal-", "-press);"], $font, $background) : (0, import_styled_components3.css)(["&:hover{color:var(--charcoal-", "-hover);background-color:var(--charcoal-", "-hover);}&:active{color:var(--charcoal-", "-press);background-color:var(--charcoal-", "-press);}"], $font, $background, $font, $background), import_styled2.focusVisibleFocusRingCss);
|
|
193
|
-
function styledProps({
|
|
194
|
-
$size,
|
|
195
|
-
$variant
|
|
196
|
-
}) {
|
|
197
|
-
return {
|
|
198
|
-
...variantToProps($variant),
|
|
199
|
-
...sizeToProps($size)
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
function variantToProps(variant) {
|
|
203
|
-
switch (variant) {
|
|
204
|
-
case "Default":
|
|
205
|
-
return {
|
|
206
|
-
$font: "text3",
|
|
207
|
-
$background: "transparent"
|
|
208
|
-
};
|
|
209
|
-
case "Overlay":
|
|
210
|
-
return {
|
|
211
|
-
$font: "text5",
|
|
212
|
-
$background: "surface4"
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
function sizeToProps(size) {
|
|
217
|
-
switch (size) {
|
|
218
|
-
case "XS":
|
|
219
|
-
return {
|
|
220
|
-
$width: 20,
|
|
221
|
-
$height: 20
|
|
222
|
-
};
|
|
223
|
-
case "S":
|
|
224
|
-
return {
|
|
225
|
-
$width: 32,
|
|
226
|
-
$height: 32
|
|
227
|
-
};
|
|
228
|
-
case "M":
|
|
229
|
-
return {
|
|
230
|
-
$width: 40,
|
|
231
|
-
$height: 40
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
135
|
function validateIconSize(size, icon) {
|
|
236
136
|
let requiredIconSize;
|
|
237
137
|
switch (size) {
|
|
@@ -254,17 +154,47 @@ function validateIconSize(size, icon) {
|
|
|
254
154
|
}
|
|
255
155
|
|
|
256
156
|
// src/components/Radio/index.tsx
|
|
257
|
-
var
|
|
258
|
-
var React4 = __toESM(require("react"));
|
|
259
|
-
var import_styled_components4 = __toESM(require("styled-components"));
|
|
157
|
+
var import_react7 = require("react");
|
|
260
158
|
var import_warning = __toESM(require("warning"));
|
|
261
|
-
|
|
159
|
+
|
|
160
|
+
// src/components/Radio/RadioGroupContext.ts
|
|
161
|
+
var React4 = __toESM(require("react"));
|
|
162
|
+
var RadioGroupContext = React4.createContext({
|
|
163
|
+
name: void 0,
|
|
164
|
+
selected: void 0,
|
|
165
|
+
disabled: false,
|
|
166
|
+
readonly: false,
|
|
167
|
+
invalid: false,
|
|
168
|
+
onChange() {
|
|
169
|
+
throw new Error("Cannot find onChange() handler. Perhaps you forgot to wrap with <RadioGroup> ?");
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// src/components/Radio/RadioInput/index.tsx
|
|
174
|
+
var import_react6 = require("react");
|
|
175
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
176
|
+
var RadioInput = (0, import_react6.forwardRef)(function RadioInput2({
|
|
177
|
+
onChange,
|
|
178
|
+
invalid,
|
|
179
|
+
className,
|
|
180
|
+
...props
|
|
181
|
+
}, ref) {
|
|
182
|
+
const handleChange = (0, import_react6.useCallback)((e) => {
|
|
183
|
+
const el = e.currentTarget;
|
|
184
|
+
onChange?.(el.value);
|
|
185
|
+
}, [onChange]);
|
|
186
|
+
const classNames = useClassNames("charcoal-radio-input", className);
|
|
187
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { className: classNames, ref, type: "radio", onChange: handleChange, "aria-invalid": invalid, ...props });
|
|
188
|
+
});
|
|
189
|
+
var RadioInput_default = (0, import_react6.memo)(RadioInput);
|
|
190
|
+
|
|
191
|
+
// src/components/Radio/index.tsx
|
|
262
192
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
263
|
-
var Radio = (0,
|
|
193
|
+
var Radio = (0, import_react7.forwardRef)(function RadioInner({
|
|
264
194
|
value,
|
|
265
195
|
disabled = false,
|
|
266
196
|
children,
|
|
267
|
-
|
|
197
|
+
...props
|
|
268
198
|
}, ref) {
|
|
269
199
|
const {
|
|
270
200
|
name,
|
|
@@ -273,7 +203,8 @@ var Radio = (0, import_react5.forwardRef)(function RadioInner({
|
|
|
273
203
|
readonly,
|
|
274
204
|
invalid,
|
|
275
205
|
onChange
|
|
276
|
-
} = (0,
|
|
206
|
+
} = (0, import_react7.useContext)(RadioGroupContext);
|
|
207
|
+
const classNames = useClassNames("charcoal-radio__label", props.className);
|
|
277
208
|
(0, import_warning.default)(
|
|
278
209
|
name !== void 0,
|
|
279
210
|
`"name" is not Provided for <Radio>. Perhaps you forgot to wrap with <RadioGroup> ?`
|
|
@@ -281,41 +212,17 @@ var Radio = (0, import_react5.forwardRef)(function RadioInner({
|
|
|
281
212
|
const isSelected = value === selected;
|
|
282
213
|
const isDisabled = disabled || isParentDisabled;
|
|
283
214
|
const isReadonly = readonly && !isSelected;
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(RadioRoot, { "aria-disabled": isDisabled || isReadonly, className, children: [
|
|
288
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(RadioInput, { name, value, checked: isSelected, "aria-invalid": invalid, onChange: handleChange, disabled: isDisabled || isReadonly, ref }),
|
|
289
|
-
children != null && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(RadioLabel, { children })
|
|
215
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { "aria-disabled": isDisabled || isReadonly, className: classNames, children: [
|
|
216
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(RadioInput_default, { name, value, checked: isSelected, "aria-invalid": invalid, onChange, disabled: isDisabled || isReadonly, ref }),
|
|
217
|
+
children != null && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "charcoal-radio__label_div", children })
|
|
290
218
|
] });
|
|
291
219
|
});
|
|
292
|
-
var Radio_default = (0,
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
var
|
|
297
|
-
|
|
298
|
-
}).withConfig({
|
|
299
|
-
componentId: "ccl__sc-1hitkzn-1"
|
|
300
|
-
})(["&[type='radio']{appearance:none;display:block;box-sizing:border-box;margin:0;padding:6px;width:20px;height:20px;cursor:pointer;border-radius:999999px;background-color:var(--charcoal-surface1);transition:0.2s background-color,0.2s box-shadow;:disabled{cursor:default;}&:not(:disabled):not([aria-disabled]),&[aria-disabled='false']{&:hover{background-color:var(--charcoal-surface1-hover);}&:active{background-color:var(--charcoal-surface1-press);}", " &[aria-invalid='true']{box-shadow:0 0 0 4px rgba(255,43,0,0.32);&:focus{box-shadow:0 0 0 4px rgba(255,43,0,0.32);}}}&:not(:checked){border-width:2px;border-style:solid;border-color:var(--charcoal-text3);}&:checked{background-color:var(--charcoal-brand);&::after{content:'';display:block;width:8px;height:8px;pointer-events:none;background-color:var(--charcoal-text5);border-radius:999999px;transition:0.2s background-color,0.2s box-shadow;}&:not(:disabled):not([aria-disabled]),&[aria-disabled='false']{&:hover{background-color:var(--charcoal-brand-hover);&::after{background-color:var(--charcoal-text5-hover);}}&:active{background-color:var(--charcoal-brand-press);&::after{background-color:var(--charcoal-text5-press);}}}}}"], import_styled3.focusVisibleFocusRingCss);
|
|
301
|
-
var RadioLabel = import_styled_components4.default.div.withConfig({
|
|
302
|
-
componentId: "ccl__sc-1hitkzn-2"
|
|
303
|
-
})(["font-size:14px;line-height:22px;display:flow-root;color:var(--charcoal-text2);&::before{display:block;width:0;height:0;content:'';margin-top:-4px;}&::after{display:block;width:0;height:0;content:'';margin-bottom:-4px;}"]);
|
|
304
|
-
var StyledRadioGroup = import_styled_components4.default.div.withConfig({
|
|
305
|
-
componentId: "ccl__sc-1hitkzn-3"
|
|
306
|
-
})(["display:grid;grid-template-columns:1fr;grid-gap:8px;"]);
|
|
307
|
-
var RadioGroupContext = React4.createContext({
|
|
308
|
-
name: void 0,
|
|
309
|
-
selected: void 0,
|
|
310
|
-
disabled: false,
|
|
311
|
-
readonly: false,
|
|
312
|
-
invalid: false,
|
|
313
|
-
onChange() {
|
|
314
|
-
throw new Error("Cannot find onChange() handler. Perhaps you forgot to wrap with <RadioGroup> ?");
|
|
315
|
-
}
|
|
316
|
-
});
|
|
317
|
-
function RadioGroup({
|
|
318
|
-
className,
|
|
220
|
+
var Radio_default = (0, import_react7.memo)(Radio);
|
|
221
|
+
|
|
222
|
+
// src/components/Radio/RadioGroup/index.tsx
|
|
223
|
+
var import_react8 = require("react");
|
|
224
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
225
|
+
var RadioGroup = (0, import_react8.forwardRef)(function RadioGroupInner({
|
|
319
226
|
value,
|
|
320
227
|
label,
|
|
321
228
|
name,
|
|
@@ -323,207 +230,93 @@ function RadioGroup({
|
|
|
323
230
|
disabled,
|
|
324
231
|
readonly,
|
|
325
232
|
invalid,
|
|
326
|
-
children
|
|
327
|
-
|
|
328
|
-
|
|
233
|
+
children,
|
|
234
|
+
"aria-orientation": ariaOrientation = "vertical",
|
|
235
|
+
...props
|
|
236
|
+
}, ref) {
|
|
237
|
+
const classNames = useClassNames("charcoal-radio-group", props.className);
|
|
238
|
+
const handleChange = (0, import_react8.useCallback)((next) => {
|
|
329
239
|
onChange(next);
|
|
330
240
|
}, [onChange]);
|
|
331
|
-
|
|
241
|
+
const contextValue = (0, import_react8.useMemo)(() => ({
|
|
332
242
|
name,
|
|
333
243
|
selected: value,
|
|
334
244
|
disabled: disabled ?? false,
|
|
335
245
|
readonly: readonly ?? false,
|
|
336
246
|
invalid: invalid ?? false,
|
|
337
247
|
onChange: handleChange
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
// src/components/MultiSelect/index.tsx
|
|
342
|
-
var import_react7 = require("react");
|
|
343
|
-
var import_styled_components5 = __toESM(require("styled-components"));
|
|
344
|
-
var import_warning2 = __toESM(require("warning"));
|
|
345
|
-
var import_utils2 = require("@charcoal-ui/utils");
|
|
346
|
-
|
|
347
|
-
// src/components/MultiSelect/context.ts
|
|
348
|
-
var import_react6 = require("react");
|
|
349
|
-
var MultiSelectGroupContext = (0, import_react6.createContext)({
|
|
350
|
-
name: void 0,
|
|
351
|
-
selected: [],
|
|
352
|
-
disabled: false,
|
|
353
|
-
readonly: false,
|
|
354
|
-
invalid: false,
|
|
355
|
-
onChange() {
|
|
356
|
-
throw new Error("Cannot find `onChange()` handler. Perhaps you forgot to wrap it with `<MultiSelectGroup />` ?");
|
|
357
|
-
}
|
|
248
|
+
}), [disabled, handleChange, invalid, name, readonly, value]);
|
|
249
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(RadioGroupContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { role: "radiogroup", "aria-disabled": disabled, "aria-invalid": invalid, "aria-label": label, "aria-labelledby": props["aria-labelledby"], "aria-orientation": ariaOrientation, className: classNames, ref, children }) });
|
|
358
250
|
});
|
|
359
251
|
|
|
360
|
-
// src/components/
|
|
361
|
-
var
|
|
362
|
-
var
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
252
|
+
// src/components/Switch/index.tsx
|
|
253
|
+
var import_react10 = require("react");
|
|
254
|
+
var import_utils = require("@react-aria/utils");
|
|
255
|
+
|
|
256
|
+
// src/components/Switch/SwitchInput/index.tsx
|
|
257
|
+
var import_react9 = require("react");
|
|
258
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
259
|
+
var SwitchInput = (0, import_react9.forwardRef)(function SwitchInput2({
|
|
366
260
|
onChange,
|
|
367
|
-
variant = "default",
|
|
368
261
|
className,
|
|
369
|
-
|
|
262
|
+
...props
|
|
370
263
|
}, ref) {
|
|
371
|
-
const {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
} = (0, import_react7.useContext)(MultiSelectGroupContext);
|
|
379
|
-
(0, import_warning2.default)(
|
|
380
|
-
name !== void 0,
|
|
381
|
-
`"name" is not Provided for <MultiSelect>. Perhaps you forgot to wrap with <MultiSelectGroup> ?`
|
|
382
|
-
);
|
|
383
|
-
const isSelected = selected.includes(value);
|
|
384
|
-
const isDisabled = disabled || parentDisabled || readonly;
|
|
385
|
-
const handleChange = (0, import_react7.useCallback)((event) => {
|
|
386
|
-
if (!(event.currentTarget instanceof HTMLInputElement)) {
|
|
387
|
-
return;
|
|
388
|
-
}
|
|
389
|
-
if (onChange)
|
|
390
|
-
onChange({
|
|
391
|
-
value,
|
|
392
|
-
selected: event.currentTarget.checked
|
|
393
|
-
});
|
|
394
|
-
parentOnChange({
|
|
395
|
-
value,
|
|
396
|
-
selected: event.currentTarget.checked
|
|
397
|
-
});
|
|
398
|
-
}, [onChange, parentOnChange, value]);
|
|
399
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(MultiSelectRoot, { "aria-disabled": isDisabled, className, children: [
|
|
400
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MultiSelectInput, { ...{
|
|
401
|
-
name,
|
|
402
|
-
value,
|
|
403
|
-
invalid
|
|
404
|
-
}, checked: isSelected, disabled: isDisabled, onChange: handleChange, overlay: variant === "overlay", "aria-invalid": invalid, ref }),
|
|
405
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MultiSelectInputOverlay, { overlay: variant === "overlay", invalid, "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("pixiv-icon", { name: "24/Check", "unsafe-non-guideline-scale": 16 / 24 }) }),
|
|
406
|
-
Boolean(children) && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MultiSelectLabel, { children })
|
|
407
|
-
] });
|
|
264
|
+
const handleChange = (0, import_react9.useCallback)((e) => {
|
|
265
|
+
const el = e.currentTarget;
|
|
266
|
+
onChange?.(el.checked);
|
|
267
|
+
}, [onChange]);
|
|
268
|
+
props.children;
|
|
269
|
+
const classNames = useClassNames("charcoal-switch-input", className);
|
|
270
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("input", { ref, className: classNames, type: "checkbox", onChange: handleChange, ...props });
|
|
408
271
|
});
|
|
409
|
-
var
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
componentId: "ccl__sc-wpr5y9-1"
|
|
417
|
-
})(["display:flex;align-items:center;font-size:14px;line-height:22px;display:flow-root;color:var(--charcoal-text2);&::before{display:block;width:0;height:0;content:'';margin-top:-4px;}&::after{display:block;width:0;height:0;content:'';margin-bottom:-4px;}"]);
|
|
418
|
-
var MultiSelectInput = import_styled_components5.default.input.attrs({
|
|
419
|
-
type: "checkbox"
|
|
420
|
-
}).withConfig({
|
|
421
|
-
componentId: "ccl__sc-wpr5y9-2"
|
|
422
|
-
})(["&[type='checkbox']{appearance:none;display:block;width:20px;height:20px;margin:0;background-color:var(--charcoal-text3);border-radius:999999px;transition:0.2s background-color,0.2s box-shadow;&:checked{background-color:var(--charcoal-brand);&:hover{&:not(:disabled):not([aria-disabled]),&[aria-disabled='false']{background-color:var(--charcoal-brand-hover);}}&:active{&:not(:disabled):not([aria-disabled]),&[aria-disabled='false']{background-color:var(--charcoal-brand-press);}}}&:hover{&:not(:disabled):not([aria-disabled]),&[aria-disabled='false']{background-color:var(--charcoal-text3-hover);}}&:active{&:not(:disabled):not([aria-disabled]),&[aria-disabled='false']{background-color:var(--charcoal-text3-press);}}", " ", " ", "}"], import_styled4.focusVisibleFocusRingCss, ({
|
|
423
|
-
invalid,
|
|
424
|
-
overlay
|
|
425
|
-
}) => invalid && !overlay && (0, import_styled_components5.css)(["&:not(:disabled):not([aria-disabled]),&[aria-disabled='false']{box-shadow:0 0 0 4px rgba(255,43,0,0.32);}"]), ({
|
|
426
|
-
overlay
|
|
427
|
-
}) => overlay && (0, import_styled_components5.css)(["background-color:var(--charcoal-surface4);"]));
|
|
428
|
-
var MultiSelectInputOverlay = import_styled_components5.default.div.withConfig({
|
|
429
|
-
componentId: "ccl__sc-wpr5y9-3"
|
|
430
|
-
})(["position:absolute;top:-2px;left:-2px;box-sizing:border-box;display:flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:999999px;color:var(--charcoal-text5);transition:0.2s box-shadow;", " ", ""], ({
|
|
431
|
-
invalid,
|
|
432
|
-
overlay
|
|
433
|
-
}) => invalid && overlay && (0, import_styled_components5.css)(["&:not(:disabled):not([aria-disabled]),&[aria-disabled='false']{box-shadow:0 0 0 4px rgba(255,43,0,0.32);}"]), ({
|
|
434
|
-
overlay
|
|
435
|
-
}) => overlay && (0, import_styled_components5.css)(["border-color:var(--charcoal-text5);border-width:2px;border-style:solid;"]));
|
|
436
|
-
function MultiSelectGroup({
|
|
272
|
+
var SwitchInput_default = SwitchInput;
|
|
273
|
+
|
|
274
|
+
// src/components/Switch/SwitchWithLabel.tsx
|
|
275
|
+
var React5 = __toESM(require("react"));
|
|
276
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
277
|
+
var SwitchWithLabel = React5.memo(function SwitchWithLabel2({
|
|
278
|
+
children,
|
|
437
279
|
className,
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
onChange,
|
|
442
|
-
disabled = false,
|
|
443
|
-
readonly = false,
|
|
444
|
-
invalid = false,
|
|
445
|
-
children
|
|
280
|
+
disabled,
|
|
281
|
+
id,
|
|
282
|
+
input
|
|
446
283
|
}) {
|
|
447
|
-
const
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
} else {
|
|
454
|
-
if (index >= 0) {
|
|
455
|
-
onChange([...selected.slice(0, index), ...selected.slice(index + 1)]);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
}, [onChange, selected]);
|
|
459
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MultiSelectGroupContext.Provider, { value: {
|
|
460
|
-
name,
|
|
461
|
-
selected: Array.from(new Set(selected)),
|
|
462
|
-
disabled,
|
|
463
|
-
readonly,
|
|
464
|
-
invalid,
|
|
465
|
-
onChange: handleChange
|
|
466
|
-
}, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className, "aria-label": label, "data-testid": "SelectGroup", children }) });
|
|
467
|
-
}
|
|
284
|
+
const classNames = useClassNames("charcoal-switch__label", className);
|
|
285
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { htmlFor: id, className: classNames, "aria-disabled": disabled, children: [
|
|
286
|
+
input,
|
|
287
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "charcoal-switch__label_div", children })
|
|
288
|
+
] });
|
|
289
|
+
});
|
|
468
290
|
|
|
469
291
|
// src/components/Switch/index.tsx
|
|
470
|
-
var
|
|
471
|
-
var
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
isSelected: props.checked
|
|
487
|
-
}), [props]);
|
|
488
|
-
const state = (0, import_react_stately.useToggleState)(ariaSwitchProps);
|
|
489
|
-
const ref = (0, import_utils3.useObjectRef)(external);
|
|
490
|
-
const {
|
|
491
|
-
inputProps: {
|
|
492
|
-
className: _className,
|
|
493
|
-
type: _type,
|
|
494
|
-
...rest
|
|
495
|
-
}
|
|
496
|
-
} = (0, import_switch.useSwitch)(ariaSwitchProps, state, ref);
|
|
497
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Label, { className, "aria-disabled": disabled, children: [
|
|
498
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SwitchInput, { ...rest, ref }),
|
|
499
|
-
"children" in props ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(LabelInner, { children: props.children }) : void 0
|
|
500
|
-
] });
|
|
292
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
293
|
+
var Switch = (0, import_react10.forwardRef)(function Switch2({
|
|
294
|
+
children,
|
|
295
|
+
onChange,
|
|
296
|
+
disabled,
|
|
297
|
+
className,
|
|
298
|
+
id,
|
|
299
|
+
...props
|
|
300
|
+
}, ref) {
|
|
301
|
+
const htmlId = (0, import_utils.useId)(id);
|
|
302
|
+
const noChildren = children === void 0;
|
|
303
|
+
const input = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SwitchInput_default, { ...props, disabled, className: noChildren ? className : void 0, id: htmlId, onChange, ref, role: "switch", type: "checkbox" });
|
|
304
|
+
if (noChildren) {
|
|
305
|
+
return input;
|
|
306
|
+
}
|
|
307
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SwitchWithLabel, { className, disabled, id: htmlId, input, children });
|
|
501
308
|
});
|
|
502
|
-
var Switch_default = (0,
|
|
503
|
-
var Label = import_styled_components6.default.label.withConfig({
|
|
504
|
-
componentId: "ccl__sc-1wy6z5h-0"
|
|
505
|
-
})(["display:inline-grid;grid-template-columns:auto 1fr;align-items:center;cursor:pointer;outline:0;&:disabled,&[aria-disabled]:not([aria-disabled='false']){opacity:0.32;cursor:default;}"]);
|
|
506
|
-
var LabelInner = import_styled_components6.default.div.withConfig({
|
|
507
|
-
componentId: "ccl__sc-1wy6z5h-1"
|
|
508
|
-
})(["font-size:14px;line-height:22px;color:var(--charcoal-text2);margin-left:4px;"]);
|
|
509
|
-
var SwitchInput = import_styled_components6.default.input.attrs({
|
|
510
|
-
type: "checkbox"
|
|
511
|
-
}).withConfig({
|
|
512
|
-
componentId: "ccl__sc-1wy6z5h-2"
|
|
513
|
-
})(["appearance:none;display:inline-flex;position:relative;box-sizing:border-box;width:28px;border:2px solid transparent;transition-property:background-color,box-shadow;transition-duration:0.2s;cursor:inherit;outline:none;border-radius:16px;height:16px;margin:0;background-color:var(--charcoal-text4);:hover{background-color:var(--charcoal-text4-hover);}:active{background-color:var(--charcoal-text4-press);}", " &::after{content:'';position:absolute;display:block;top:0;left:0;width:12px;height:12px;transform:translateX(0);transition:transform 0.2s;border-radius:1024px;background-color:var(--charcoal-text5);:hover{background-color:var(--charcoal-text5-hover);}:active{background-color:var(--charcoal-text5-press);}}&:checked{background-color:var(--charcoal-brand);:hover{background-color:var(--charcoal-brand-hover);}:active{background-color:var(--charcoal-brand-press);}&::after{transform:translateX(12px);transition:transform 0.2s;}}"], import_styled5.focusVisibleFocusRingCss);
|
|
309
|
+
var Switch_default = (0, import_react10.memo)(Switch);
|
|
514
310
|
|
|
515
311
|
// src/components/TextField/index.tsx
|
|
516
|
-
var import_textfield = require("@react-aria/textfield");
|
|
517
312
|
var import_visually_hidden = require("@react-aria/visually-hidden");
|
|
518
|
-
var
|
|
519
|
-
var
|
|
520
|
-
var import_styled_components8 = __toESM(require("styled-components"));
|
|
313
|
+
var import_react13 = require("react");
|
|
314
|
+
var React7 = __toESM(require("react"));
|
|
521
315
|
|
|
522
316
|
// src/components/FieldLabel/index.tsx
|
|
523
|
-
var
|
|
524
|
-
var
|
|
525
|
-
var
|
|
526
|
-
var FieldLabel = React5.forwardRef(function FieldLabel2({
|
|
317
|
+
var React6 = __toESM(require("react"));
|
|
318
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
319
|
+
var FieldLabel = React6.forwardRef(function FieldLabel2({
|
|
527
320
|
style,
|
|
528
321
|
className,
|
|
529
322
|
label,
|
|
@@ -532,30 +325,16 @@ var FieldLabel = React5.forwardRef(function FieldLabel2({
|
|
|
532
325
|
subLabel,
|
|
533
326
|
...labelProps
|
|
534
327
|
}, ref) {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
/* @__PURE__ */ (0,
|
|
328
|
+
const classNames = useClassNames("charcoal-field-label-root", className);
|
|
329
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { style, className: classNames, children: [
|
|
330
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("label", { ref, className: "charcoal-field-label", ...labelProps, children: label }),
|
|
331
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "charcoal-field-label-required-text", children: requiredText }),
|
|
332
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "charcoal-field-label-sub-label", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: subLabel }) })
|
|
539
333
|
] });
|
|
540
334
|
});
|
|
541
335
|
var FieldLabel_default = FieldLabel;
|
|
542
|
-
var Label2 = import_styled_components7.default.label.withConfig({
|
|
543
|
-
componentId: "ccl__sc-1iotshb-0"
|
|
544
|
-
})(["font-size:14px;line-height:22px;font-weight:bold;display:flow-root;color:var(--charcoal-text1);&::before{display:block;width:0;height:0;content:'';margin-top:-4px;}&::after{display:block;width:0;height:0;content:'';margin-bottom:-4px;}"]);
|
|
545
|
-
var RequiredText = import_styled_components7.default.span.withConfig({
|
|
546
|
-
componentId: "ccl__sc-1iotshb-1"
|
|
547
|
-
})(["font-size:14px;line-height:22px;display:flow-root;color:var(--charcoal-text2);&::before{display:block;width:0;height:0;content:'';margin-top:-4px;}&::after{display:block;width:0;height:0;content:'';margin-bottom:-4px;}"]);
|
|
548
|
-
var SubLabelClickable = import_styled_components7.default.div.withConfig({
|
|
549
|
-
componentId: "ccl__sc-1iotshb-2"
|
|
550
|
-
})(["font-size:14px;line-height:22px;display:flow-root;color:var(--charcoal-text3);transition:0.2s color,0.2s box-shadow;&::before{display:block;width:0;height:0;content:'';margin-top:-4px;}&::after{display:block;width:0;height:0;content:'';margin-bottom:-4px;}&:not(:disabled):not([aria-disabled]),&[aria-disabled='false']{&:hover{color:var(--charcoal-text3-hover);}&:active{color:var(--charcoal-text3-press);}&:active,&:focus,&:focus-visible{outline:none;box-shadow:0 0 0 4px rgba(0,150,250,0.32);}}"]);
|
|
551
|
-
var FieldLabelWrapper = import_styled_components7.default.div.withConfig({
|
|
552
|
-
componentId: "ccl__sc-1iotshb-3"
|
|
553
|
-
})(["display:inline-flex;align-items:center;> ", "{margin-left:4px;}> ", "{margin-left:auto;}"], RequiredText, SubLabelClickable);
|
|
554
336
|
|
|
555
337
|
// src/_lib/index.ts
|
|
556
|
-
function unreachable(value) {
|
|
557
|
-
throw new Error(arguments.length === 0 ? "unreachable" : `unreachable (${JSON.stringify(value)})`);
|
|
558
|
-
}
|
|
559
338
|
function mergeRefs(...refs) {
|
|
560
339
|
return (value) => {
|
|
561
340
|
for (const ref of refs) {
|
|
@@ -573,9 +352,9 @@ function countCodePointsInString(string) {
|
|
|
573
352
|
}
|
|
574
353
|
|
|
575
354
|
// src/components/TextField/useFocusWithClick.tsx
|
|
576
|
-
var
|
|
355
|
+
var import_react11 = require("react");
|
|
577
356
|
function useFocusWithClick(containerRef, inputRef) {
|
|
578
|
-
(0,
|
|
357
|
+
(0, import_react11.useEffect)(() => {
|
|
579
358
|
const el = containerRef.current;
|
|
580
359
|
if (el) {
|
|
581
360
|
const handleDown = (e) => {
|
|
@@ -592,148 +371,124 @@ function useFocusWithClick(containerRef, inputRef) {
|
|
|
592
371
|
}
|
|
593
372
|
|
|
594
373
|
// src/components/TextField/index.tsx
|
|
595
|
-
var
|
|
596
|
-
|
|
597
|
-
|
|
374
|
+
var import_utils2 = require("@react-aria/utils");
|
|
375
|
+
|
|
376
|
+
// src/_lib/createDivComponent.tsx
|
|
377
|
+
var import_react12 = require("react");
|
|
378
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
379
|
+
function createDivComponent(mainClassName) {
|
|
380
|
+
return (0, import_react12.forwardRef)(function DivComponent({
|
|
381
|
+
className,
|
|
382
|
+
...props
|
|
383
|
+
}, ref) {
|
|
384
|
+
const classNames = useClassNames(mainClassName, className);
|
|
385
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: classNames, ref, ...props });
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// src/components/TextField/AssistiveText/index.tsx
|
|
390
|
+
var AssistiveText = createDivComponent("charcoal-text-field-assistive-text");
|
|
391
|
+
|
|
392
|
+
// src/components/TextField/index.tsx
|
|
393
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
394
|
+
var TextField = React7.forwardRef(function SingleLineTextFieldInner({
|
|
395
|
+
assistiveText,
|
|
396
|
+
className,
|
|
397
|
+
disabled = false,
|
|
398
|
+
label = "",
|
|
399
|
+
maxLength,
|
|
598
400
|
onChange,
|
|
401
|
+
prefix = null,
|
|
402
|
+
required,
|
|
403
|
+
requiredText,
|
|
404
|
+
showCount = false,
|
|
405
|
+
showLabel = false,
|
|
406
|
+
subLabel,
|
|
407
|
+
suffix = null,
|
|
408
|
+
type = "text",
|
|
409
|
+
invalid,
|
|
410
|
+
value,
|
|
411
|
+
getCount = countCodePointsInString,
|
|
599
412
|
...props
|
|
600
|
-
},
|
|
601
|
-
const
|
|
602
|
-
className,
|
|
603
|
-
showLabel = false,
|
|
604
|
-
showCount = false,
|
|
605
|
-
label,
|
|
606
|
-
requiredText,
|
|
607
|
-
subLabel,
|
|
608
|
-
disabled = false,
|
|
609
|
-
required,
|
|
610
|
-
invalid = false,
|
|
611
|
-
assistiveText,
|
|
612
|
-
maxLength,
|
|
613
|
-
prefix = null,
|
|
614
|
-
suffix = null,
|
|
615
|
-
...restProps
|
|
616
|
-
} = props;
|
|
413
|
+
}, forwardRef23) {
|
|
414
|
+
const inputRef = (0, import_react13.useRef)(null);
|
|
617
415
|
const {
|
|
618
416
|
visuallyHiddenProps
|
|
619
417
|
} = (0, import_visually_hidden.useVisuallyHidden)();
|
|
620
|
-
const
|
|
621
|
-
const
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
const count2 = countCodePointsInString(value);
|
|
418
|
+
const [count, setCount] = (0, import_react13.useState)(getCount(value ?? ""));
|
|
419
|
+
const handleChange = (0, import_react13.useCallback)((e) => {
|
|
420
|
+
const value2 = e.target.value;
|
|
421
|
+
const count2 = getCount(value2);
|
|
625
422
|
if (maxLength !== void 0 && count2 > maxLength) {
|
|
626
423
|
return;
|
|
627
424
|
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
const
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
errorMessage: invalid && assistiveText,
|
|
648
|
-
onChange: handleChange,
|
|
649
|
-
...props
|
|
650
|
-
}, ariaRef);
|
|
651
|
-
const containerRef = (0, import_react10.useRef)(null);
|
|
652
|
-
useFocusWithClick(containerRef, ariaRef);
|
|
653
|
-
const inputProps = (0, import_utils4.mergeProps)(restProps, ariaInputProps);
|
|
654
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(TextFieldRoot, { className, isDisabled: disabled, children: [
|
|
655
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TextFieldLabel, { label, requiredText, required, subLabel, ...labelProps, ...!showLabel ? visuallyHiddenProps : {} }),
|
|
656
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(StyledInputContainer, { ref: containerRef, invalid, "aria-disabled": disabled === true ? true : void 0, hasPrefix: prefix != null, hasSuffix: suffix != null || showCount, children: [
|
|
657
|
-
prefix && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PrefixContainer, { children: prefix }),
|
|
658
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(StyledInput, { ref: mergeRefs(forwardRef18, ariaRef), invalid, ...inputProps }),
|
|
659
|
-
(suffix || showCount) && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(SuffixContainer, { children: [
|
|
425
|
+
setCount(count2);
|
|
426
|
+
onChange?.(value2);
|
|
427
|
+
}, [getCount, maxLength, onChange]);
|
|
428
|
+
(0, import_react13.useEffect)(() => {
|
|
429
|
+
setCount(getCount(value ?? ""));
|
|
430
|
+
}, [getCount, value]);
|
|
431
|
+
const containerRef = (0, import_react13.useRef)(null);
|
|
432
|
+
useFocusWithClick(containerRef, inputRef);
|
|
433
|
+
const inputId = (0, import_utils2.useId)(props.id);
|
|
434
|
+
const describedbyId = (0, import_utils2.useId)();
|
|
435
|
+
const labelledbyId = (0, import_utils2.useId)();
|
|
436
|
+
const showAssistiveText = assistiveText != null && assistiveText.length !== 0;
|
|
437
|
+
const classNames = useClassNames("charcoal-text-field-root");
|
|
438
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: classNames, "aria-disabled": disabled, children: [
|
|
439
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(FieldLabel_default, { htmlFor: inputId, id: labelledbyId, label, required, requiredText, subLabel, ...!showLabel ? visuallyHiddenProps : {} }),
|
|
440
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "charcoal-text-field-container", "aria-disabled": disabled === true ? true : void 0, "data-invalid": invalid === true, ref: containerRef, children: [
|
|
441
|
+
prefix && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "charcoal-text-field-prefix", children: prefix }),
|
|
442
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { className: "charcoal-text-field-input", "aria-describedby": showAssistiveText ? describedbyId : void 0, "aria-invalid": invalid, "aria-labelledby": labelledbyId, id: inputId, "data-invalid": invalid === true, maxLength, onChange: handleChange, disabled, ref: (0, import_utils2.mergeRefs)(forwardRef23, inputRef), type, value, ...props }),
|
|
443
|
+
(suffix || showCount) && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "charcoal-text-field-suffix", children: [
|
|
660
444
|
suffix,
|
|
661
|
-
showCount && /* @__PURE__ */ (0,
|
|
445
|
+
showCount && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "charcoal-text-field-line-counter", children: maxLength !== void 0 ? `${count}/${maxLength}` : count })
|
|
662
446
|
] })
|
|
663
447
|
] }),
|
|
664
|
-
|
|
448
|
+
showAssistiveText && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(AssistiveText, { "data-invalid": invalid === true, id: describedbyId, children: assistiveText })
|
|
665
449
|
] });
|
|
666
450
|
});
|
|
667
451
|
var TextField_default = TextField;
|
|
668
|
-
var TextFieldRoot = import_styled_components8.default.div.withConfig({
|
|
669
|
-
componentId: "ccl__sc-3dd0tt-0"
|
|
670
|
-
})(["display:flex;flex-direction:column;", ""], (p) => p.isDisabled && {
|
|
671
|
-
opacity: p.theme.elementEffect.disabled.opacity
|
|
672
|
-
});
|
|
673
|
-
var TextFieldLabel = (0, import_styled_components8.default)(FieldLabel_default).withConfig({
|
|
674
|
-
componentId: "ccl__sc-3dd0tt-1"
|
|
675
|
-
})(["margin-bottom:8px;"]);
|
|
676
|
-
var StyledInputContainer = import_styled_components8.default.div.withConfig({
|
|
677
|
-
componentId: "ccl__sc-3dd0tt-2"
|
|
678
|
-
})(["display:grid;grid-template-columns:", ";height:40px;transition:0.2s background-color,0.2s box-shadow;color:var(--charcoal-text2);background-color:var(--charcoal-surface3);border-radius:4px;gap:4px;padding:0 8px;line-height:22px;font-size:14px;:not(:disabled):not([aria-disabled]):hover,[aria-disabled='false']:hover{background-color:var(--charcoal-surface3-hover);}:focus-within{outline:none;box-shadow:0 0 0 4px ", ";}", ""], (p) => [p.hasPrefix && "auto", "1fr", p.hasSuffix && "auto"].filter(Boolean).join(" "), (p) => p.invalid ? `rgba(255,43,0,0.32)` : `rgba(0, 150, 250, 0.32);`, (p) => p.invalid && (0, import_styled_components8.css)(["box-shadow:0 0 0 4px rgba(255,43,0,0.32);"]));
|
|
679
|
-
var PrefixContainer = import_styled_components8.default.div.withConfig({
|
|
680
|
-
componentId: "ccl__sc-3dd0tt-3"
|
|
681
|
-
})(["display:flex;align-items:center;"]);
|
|
682
|
-
var SuffixContainer = import_styled_components8.default.span.withConfig({
|
|
683
|
-
componentId: "ccl__sc-3dd0tt-4"
|
|
684
|
-
})(["display:flex;align-items:center;gap:8px;"]);
|
|
685
|
-
var StyledInput = import_styled_components8.default.input.withConfig({
|
|
686
|
-
componentId: "ccl__sc-3dd0tt-5"
|
|
687
|
-
})(["border:none;box-sizing:border-box;outline:none;font-family:inherit;transform-origin:top left;transform:scale(0.875);width:calc(100% / 0.875);height:calc(100% / 0.875);font-size:calc(14px / 0.875);line-height:calc(22px / 0.875);padding-left:0;padding-right:0;border-radius:calc(4px / 0.875);appearance:none;background:transparent;color:var(--charcoal-text2);&::placeholder{color:var(--charcoal-text3);}"]);
|
|
688
|
-
var SingleLineCounter = import_styled_components8.default.span.withConfig({
|
|
689
|
-
componentId: "ccl__sc-3dd0tt-6"
|
|
690
|
-
})(["line-height:22px;font-size:14px;color:var(--charcoal-text3);"]);
|
|
691
|
-
var AssistiveText = import_styled_components8.default.p.withConfig({
|
|
692
|
-
componentId: "ccl__sc-3dd0tt-7"
|
|
693
|
-
})(["font-size:14px;line-height:22px;margin-top:4px;margin-bottom:-4px;color:", ";"], (p) => `var(--charcoal-${p.invalid ? `assertive` : `text2`})`);
|
|
694
452
|
|
|
695
453
|
// src/components/TextArea/index.tsx
|
|
696
|
-
var import_textfield2 = require("@react-aria/textfield");
|
|
697
454
|
var import_visually_hidden2 = require("@react-aria/visually-hidden");
|
|
698
|
-
var
|
|
699
|
-
var
|
|
700
|
-
var
|
|
701
|
-
var
|
|
702
|
-
var TextArea = (0, import_react11.forwardRef)(function TextAreaInner({
|
|
455
|
+
var import_react14 = require("react");
|
|
456
|
+
var import_utils3 = require("@react-aria/utils");
|
|
457
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
458
|
+
var TextArea = (0, import_react14.forwardRef)(function TextAreaInner({
|
|
703
459
|
onChange,
|
|
460
|
+
className,
|
|
461
|
+
value,
|
|
462
|
+
showCount = false,
|
|
463
|
+
showLabel = false,
|
|
464
|
+
label = "",
|
|
465
|
+
requiredText,
|
|
466
|
+
subLabel,
|
|
467
|
+
disabled = false,
|
|
468
|
+
required,
|
|
469
|
+
assistiveText,
|
|
470
|
+
maxLength,
|
|
471
|
+
autoHeight = false,
|
|
472
|
+
rows: initialRows = 4,
|
|
473
|
+
invalid,
|
|
474
|
+
getCount = countCodePointsInString,
|
|
704
475
|
...props
|
|
705
|
-
},
|
|
706
|
-
const {
|
|
707
|
-
className,
|
|
708
|
-
showCount = false,
|
|
709
|
-
showLabel = false,
|
|
710
|
-
label,
|
|
711
|
-
requiredText,
|
|
712
|
-
subLabel,
|
|
713
|
-
disabled = false,
|
|
714
|
-
required,
|
|
715
|
-
invalid = false,
|
|
716
|
-
assistiveText,
|
|
717
|
-
maxLength,
|
|
718
|
-
autoHeight = false,
|
|
719
|
-
rows: initialRows = 4,
|
|
720
|
-
...restProps
|
|
721
|
-
} = props;
|
|
476
|
+
}, forwardRef23) {
|
|
722
477
|
const {
|
|
723
478
|
visuallyHiddenProps
|
|
724
479
|
} = (0, import_visually_hidden2.useVisuallyHidden)();
|
|
725
|
-
const textareaRef = (0,
|
|
726
|
-
const
|
|
727
|
-
const [
|
|
728
|
-
const
|
|
729
|
-
const syncHeight = (0, import_react11.useCallback)((textarea) => {
|
|
480
|
+
const textareaRef = (0, import_react14.useRef)(null);
|
|
481
|
+
const [count, setCount] = (0, import_react14.useState)(getCount(value ?? ""));
|
|
482
|
+
const [rows, setRows] = (0, import_react14.useState)(initialRows);
|
|
483
|
+
const syncHeight = (0, import_react14.useCallback)((textarea) => {
|
|
730
484
|
const rows2 = (`${textarea.value}
|
|
731
485
|
`.match(/\n/gu)?.length ?? 0) || 1;
|
|
732
486
|
setRows(initialRows <= rows2 ? rows2 : initialRows);
|
|
733
487
|
}, [initialRows]);
|
|
734
|
-
const nonControlled =
|
|
735
|
-
const handleChange = (0,
|
|
736
|
-
const
|
|
488
|
+
const nonControlled = value === void 0;
|
|
489
|
+
const handleChange = (0, import_react14.useCallback)((e) => {
|
|
490
|
+
const value2 = e.target.value;
|
|
491
|
+
const count2 = getCount(value2);
|
|
737
492
|
if (maxLength !== void 0 && count2 > maxLength) {
|
|
738
493
|
return;
|
|
739
494
|
}
|
|
@@ -743,110 +498,67 @@ var TextArea = (0, import_react11.forwardRef)(function TextAreaInner({
|
|
|
743
498
|
if (autoHeight && textareaRef.current !== null) {
|
|
744
499
|
syncHeight(textareaRef.current);
|
|
745
500
|
}
|
|
746
|
-
onChange?.(
|
|
747
|
-
}, [autoHeight, maxLength, nonControlled, onChange, syncHeight]);
|
|
748
|
-
(0,
|
|
749
|
-
setCount(
|
|
750
|
-
}, [
|
|
751
|
-
|
|
752
|
-
inputProps: ariaInputProps,
|
|
753
|
-
labelProps,
|
|
754
|
-
descriptionProps,
|
|
755
|
-
errorMessageProps
|
|
756
|
-
} = (0, import_textfield2.useTextField)({
|
|
757
|
-
inputElementType: "textarea",
|
|
758
|
-
isDisabled: disabled,
|
|
759
|
-
isRequired: required,
|
|
760
|
-
validationState: invalid ? "invalid" : "valid",
|
|
761
|
-
description: !invalid && assistiveText,
|
|
762
|
-
errorMessage: invalid && assistiveText,
|
|
763
|
-
onChange: handleChange,
|
|
764
|
-
...props
|
|
765
|
-
}, ariaRef);
|
|
766
|
-
(0, import_react11.useEffect)(() => {
|
|
501
|
+
onChange?.(value2);
|
|
502
|
+
}, [autoHeight, getCount, maxLength, nonControlled, onChange, syncHeight]);
|
|
503
|
+
(0, import_react14.useEffect)(() => {
|
|
504
|
+
setCount(getCount(value ?? ""));
|
|
505
|
+
}, [getCount, value]);
|
|
506
|
+
(0, import_react14.useEffect)(() => {
|
|
767
507
|
if (autoHeight && textareaRef.current !== null) {
|
|
768
508
|
syncHeight(textareaRef.current);
|
|
769
509
|
}
|
|
770
510
|
}, [autoHeight, syncHeight]);
|
|
771
|
-
const containerRef = (0,
|
|
772
|
-
useFocusWithClick(containerRef,
|
|
773
|
-
const
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
511
|
+
const containerRef = (0, import_react14.useRef)(null);
|
|
512
|
+
useFocusWithClick(containerRef, textareaRef);
|
|
513
|
+
const textAreaId = (0, import_utils3.useId)(props.id);
|
|
514
|
+
const describedbyId = (0, import_utils3.useId)();
|
|
515
|
+
const labelledbyId = (0, import_utils3.useId)();
|
|
516
|
+
const classNames = useClassNames("charcoal-text-area-root", className);
|
|
517
|
+
const showAssistiveText = assistiveText != null && assistiveText.length !== 0;
|
|
518
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: classNames, "aria-disabled": disabled, children: [
|
|
519
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(FieldLabel_default, { htmlFor: textAreaId, id: labelledbyId, label, required, requiredText, subLabel, ...!showLabel ? visuallyHiddenProps : {} }),
|
|
520
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "charcoal-text-area-container", "aria-disabled": disabled === true ? "true" : void 0, "aria-invalid": invalid === true, ref: containerRef, style: {
|
|
521
|
+
"--charcoal-text-area-rows": `${showCount ? rows + 1 : rows}`
|
|
522
|
+
}, children: [
|
|
523
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("textarea", { className: "charcoal-text-area-textarea", "aria-describedby": showAssistiveText ? describedbyId : void 0, "aria-invalid": invalid, "aria-labelledby": labelledbyId, id: textAreaId, maxLength, "data-no-bottom-padding": showCount, onChange: handleChange, ref: mergeRefs(forwardRef23, textareaRef), rows, value, disabled, ...props }),
|
|
524
|
+
showCount && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "charcoal-text-area-counter", children: maxLength !== void 0 ? `${count}/${maxLength}` : count })
|
|
779
525
|
] }),
|
|
780
|
-
|
|
526
|
+
showAssistiveText && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(AssistiveText, { "data-invalid": invalid === true, id: describedbyId, children: assistiveText })
|
|
781
527
|
] });
|
|
782
528
|
});
|
|
783
529
|
var TextArea_default = TextArea;
|
|
784
|
-
var TextFieldRoot2 = import_styled_components9.default.div.withConfig({
|
|
785
|
-
componentId: "ccl__sc-58waht-0"
|
|
786
|
-
})(["display:flex;flex-direction:column;", ""], (p) => p.isDisabled && {
|
|
787
|
-
opacity: p.theme.elementEffect.disabled.opacity
|
|
788
|
-
});
|
|
789
|
-
var StyledTextareaContainer = import_styled_components9.default.div.withConfig({
|
|
790
|
-
componentId: "ccl__sc-58waht-1"
|
|
791
|
-
})(["position:relative;overflow:hidden;color:var(--charcoal-text2);background-color:var(--charcoal-surface3);border-radius:4px;transition:0.2s background-color,0.2s box-shadow;", ";:not([aria-disabled]):hover,[aria-disabled='false']:hover{background-color:var(--charcoal-surface3-hover);}:focus-within{outline:none;box-shadow:0 0 0 4px ", ";}", ""], ({
|
|
792
|
-
rows
|
|
793
|
-
}) => (0, import_styled_components9.css)(["height:calc(22px * ", " + 18px);"], rows), (p) => p.invalid ? `rgba(255,43,0,0.32)` : `rgba(0, 150, 250, 0.32);`, (p) => p.invalid && (0, import_styled_components9.css)(["box-shadow:0 0 0 4px rgba(255,43,0,0.32);"]));
|
|
794
|
-
var StyledTextarea = import_styled_components9.default.textarea.withConfig({
|
|
795
|
-
componentId: "ccl__sc-58waht-2"
|
|
796
|
-
})(["border:none;outline:none;resize:none;font-family:inherit;color:inherit;box-sizing:border-box;transform-origin:top left;transform:scale(0.875);width:calc(100% / 0.875);font-size:calc(14px / 0.875);line-height:calc(22px / 0.875);padding:calc(9px / 0.875) calc(8px / 0.875) ", ";", ";appearance:none;background:none;&::placeholder{color:var(--charcoal-text3);}"], (p) => p.noBottomPadding ? 0 : "", ({
|
|
797
|
-
rows = 1,
|
|
798
|
-
noBottomPadding
|
|
799
|
-
}) => (0, import_styled_components9.css)(["height:calc(22px / 0.875 * ", " + ", "px);"], rows, noBottomPadding ? 9 : 20));
|
|
800
|
-
var MultiLineCounter = import_styled_components9.default.span.withConfig({
|
|
801
|
-
componentId: "ccl__sc-58waht-3"
|
|
802
|
-
})(["position:absolute;bottom:9px;right:8px;line-height:22px;font-size:14px;color:var(--charcoal-text3);"]);
|
|
803
530
|
|
|
804
531
|
// src/components/Icon/index.tsx
|
|
805
|
-
var
|
|
532
|
+
var React8 = __toESM(require("react"));
|
|
806
533
|
var import_icons = require("@charcoal-ui/icons");
|
|
807
|
-
var
|
|
808
|
-
var Icon =
|
|
534
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
535
|
+
var Icon = React8.forwardRef(function IconInner({
|
|
809
536
|
name,
|
|
810
537
|
scale,
|
|
811
538
|
unsafeNonGuidelineScale,
|
|
812
539
|
className,
|
|
813
540
|
...rest
|
|
814
541
|
}, ref) {
|
|
815
|
-
return /* @__PURE__ */ (0,
|
|
542
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("pixiv-icon", { ref, name, scale, "unsafe-non-guideline-scale": unsafeNonGuidelineScale, class: className, ...rest });
|
|
816
543
|
});
|
|
817
544
|
var Icon_default = Icon;
|
|
818
545
|
|
|
819
546
|
// src/components/Modal/index.tsx
|
|
820
|
-
var
|
|
821
|
-
var
|
|
547
|
+
var import_react17 = require("react");
|
|
548
|
+
var React12 = __toESM(require("react"));
|
|
822
549
|
var import_overlays3 = require("@react-aria/overlays");
|
|
823
|
-
var
|
|
824
|
-
var
|
|
825
|
-
var import_styled6 = require("@charcoal-ui/styled");
|
|
826
|
-
var import_react_spring2 = require("react-spring");
|
|
827
|
-
var import_utils8 = require("@react-aria/utils");
|
|
550
|
+
var import_react_spring = require("react-spring");
|
|
551
|
+
var import_utils4 = require("@react-aria/utils");
|
|
828
552
|
|
|
829
553
|
// src/components/Modal/Dialog/index.tsx
|
|
830
|
-
var
|
|
831
|
-
var import_styled_components10 = __toESM(require("styled-components"));
|
|
554
|
+
var import_react15 = require("react");
|
|
832
555
|
var import_dialog = require("@react-aria/dialog");
|
|
833
556
|
|
|
834
|
-
// ../foundation/src/grid.ts
|
|
835
|
-
var COLUMN_UNIT = 80;
|
|
836
|
-
var GUTTER_UNIT = 24;
|
|
837
|
-
function columnSystem(span, column, gutter) {
|
|
838
|
-
return span * column + (span - 1) * gutter;
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
// src/components/Modal/Dialog/index.tsx
|
|
842
|
-
var import_utils6 = require("@charcoal-ui/utils");
|
|
843
|
-
var import_react_spring = require("react-spring");
|
|
844
|
-
|
|
845
557
|
// src/_lib/useForwardedRef.tsx
|
|
846
|
-
var
|
|
558
|
+
var React9 = __toESM(require("react"));
|
|
847
559
|
function useForwardedRef(ref) {
|
|
848
|
-
const innerRef =
|
|
849
|
-
|
|
560
|
+
const innerRef = React9.useRef(null);
|
|
561
|
+
React9.useEffect(() => {
|
|
850
562
|
if (!ref)
|
|
851
563
|
return;
|
|
852
564
|
if (typeof ref === "function") {
|
|
@@ -859,44 +571,49 @@ function useForwardedRef(ref) {
|
|
|
859
571
|
}
|
|
860
572
|
|
|
861
573
|
// src/components/Modal/Dialog/index.tsx
|
|
862
|
-
var
|
|
863
|
-
var Dialog = (0,
|
|
864
|
-
|
|
574
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
575
|
+
var Dialog = (0, import_react15.forwardRef)(function Dialog2({
|
|
576
|
+
size,
|
|
577
|
+
bottomSheet,
|
|
578
|
+
className,
|
|
579
|
+
...props
|
|
580
|
+
}, forwardRef23) {
|
|
581
|
+
const ref = useForwardedRef(forwardRef23);
|
|
865
582
|
const {
|
|
866
583
|
dialogProps
|
|
867
584
|
} = (0, import_dialog.useDialog)({
|
|
868
585
|
role: "dialog"
|
|
869
586
|
}, ref);
|
|
870
|
-
|
|
587
|
+
const classNames = useClassNames("charcoal-modal-dialog", className);
|
|
588
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: classNames, role: dialogProps.role, "data-bottom-sheet": bottomSheet, tabIndex: dialogProps.tabIndex, "aria-labelledby": dialogProps["aria-labelledby"], onBlur: dialogProps.onBlur, "data-size": size, ref, ...props });
|
|
871
589
|
});
|
|
872
|
-
var AnimatedStyledDialogDiv = (0, import_react_spring.animated)(import_styled_components10.default.div.withConfig({
|
|
873
|
-
componentId: "ccl__sc-1ep4f6v-0"
|
|
874
|
-
})(["margin:auto;position:relative;height:fit-content;width:", "px;background-color:var(--charcoal-surface1);border-radius:24px;@media ", "{max-width:440px;width:calc(100% - 48px);", "}:focus{outline:none;}"], (p) => {
|
|
875
|
-
switch (p.size) {
|
|
876
|
-
case "S": {
|
|
877
|
-
return columnSystem(3, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT * 2;
|
|
878
|
-
}
|
|
879
|
-
case "M": {
|
|
880
|
-
return columnSystem(4, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT * 2;
|
|
881
|
-
}
|
|
882
|
-
case "L": {
|
|
883
|
-
return columnSystem(6, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT * 2;
|
|
884
|
-
}
|
|
885
|
-
default: {
|
|
886
|
-
return unreachable(p.size);
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
}, ({
|
|
890
|
-
theme
|
|
891
|
-
}) => (0, import_utils6.maxWidth)(theme.breakpoint.screen1), (p) => p.bottomSheet !== false && (0, import_styled_components10.css)(["max-width:unset;width:100%;border-radius:0;margin:auto 0 0 0;", ""], p.bottomSheet === "full" && (0, import_styled_components10.css)(["min-height:100%;"]))));
|
|
892
590
|
|
|
893
591
|
// src/components/Modal/ModalBackgroundContext.tsx
|
|
894
|
-
var
|
|
895
|
-
var ModalBackgroundContext =
|
|
592
|
+
var React10 = __toESM(require("react"));
|
|
593
|
+
var ModalBackgroundContext = React10.createContext(null);
|
|
896
594
|
|
|
897
595
|
// src/components/Modal/useCustomModalOverlay.tsx
|
|
898
|
-
var
|
|
596
|
+
var React11 = __toESM(require("react"));
|
|
899
597
|
var import_overlays2 = require("@react-aria/overlays");
|
|
598
|
+
|
|
599
|
+
// src/components/DropdownSelector/Popover/usePreventScroll.tsx
|
|
600
|
+
var import_react16 = require("react");
|
|
601
|
+
function usePreventScroll(element, isOpen) {
|
|
602
|
+
(0, import_react16.useEffect)(() => {
|
|
603
|
+
if (isOpen && element) {
|
|
604
|
+
const defaultPaddingRight = element.style.paddingRight;
|
|
605
|
+
const defaultOverflow = element.style.overflow;
|
|
606
|
+
element.style.paddingRight = `${window.innerWidth - element.clientWidth}px`;
|
|
607
|
+
element.style.overflow = "hidden";
|
|
608
|
+
return () => {
|
|
609
|
+
element.style.paddingRight = defaultPaddingRight;
|
|
610
|
+
element.style.overflow = defaultOverflow;
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
}, [element, isOpen]);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
// src/components/Modal/useCustomModalOverlay.tsx
|
|
900
617
|
function useCharcoalModalOverlay(props, state, ref) {
|
|
901
618
|
const {
|
|
902
619
|
overlayProps,
|
|
@@ -907,11 +624,9 @@ function useCharcoalModalOverlay(props, state, ref) {
|
|
|
907
624
|
onClose: state.onClose,
|
|
908
625
|
shouldCloseOnInteractOutside: () => false
|
|
909
626
|
}, ref);
|
|
910
|
-
(
|
|
911
|
-
isDisabled: !state.isOpen
|
|
912
|
-
});
|
|
627
|
+
usePreventScroll(typeof document !== "undefined" ? document.body : null, state.isOpen);
|
|
913
628
|
(0, import_overlays2.useOverlayFocusContain)();
|
|
914
|
-
|
|
629
|
+
React11.useEffect(() => {
|
|
915
630
|
if (state.isOpen && ref.current) {
|
|
916
631
|
return (0, import_overlays2.ariaHideOutside)([ref.current]);
|
|
917
632
|
}
|
|
@@ -921,11 +636,24 @@ function useCharcoalModalOverlay(props, state, ref) {
|
|
|
921
636
|
underlayProps
|
|
922
637
|
};
|
|
923
638
|
}
|
|
639
|
+
function useWindowWidth() {
|
|
640
|
+
const [width, setWidth] = React11.useState(window.innerWidth);
|
|
641
|
+
React11.useEffect(() => {
|
|
642
|
+
const handleResize = () => {
|
|
643
|
+
setWidth(window.innerWidth);
|
|
644
|
+
};
|
|
645
|
+
window.addEventListener("resize", handleResize);
|
|
646
|
+
return () => {
|
|
647
|
+
window.removeEventListener("resize", handleResize);
|
|
648
|
+
};
|
|
649
|
+
});
|
|
650
|
+
return width;
|
|
651
|
+
}
|
|
924
652
|
|
|
925
653
|
// src/components/Modal/index.tsx
|
|
926
|
-
var
|
|
654
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
927
655
|
var DEFAULT_Z_INDEX = 10;
|
|
928
|
-
var Modal = (0,
|
|
656
|
+
var Modal = (0, import_react17.forwardRef)(function ModalInner({
|
|
929
657
|
children,
|
|
930
658
|
zIndex = DEFAULT_Z_INDEX,
|
|
931
659
|
portalContainer,
|
|
@@ -938,9 +666,10 @@ var Modal = (0, import_react13.forwardRef)(function ModalInner({
|
|
|
938
666
|
isDismissable,
|
|
939
667
|
onClose,
|
|
940
668
|
className,
|
|
941
|
-
isOpen = false
|
|
669
|
+
isOpen = false,
|
|
670
|
+
closeButtonAriaLabel = "Close"
|
|
942
671
|
} = props;
|
|
943
|
-
const ref = (0,
|
|
672
|
+
const ref = (0, import_utils4.useObjectRef)(external);
|
|
944
673
|
const {
|
|
945
674
|
modalProps,
|
|
946
675
|
underlayProps
|
|
@@ -951,11 +680,10 @@ var Modal = (0, import_react13.forwardRef)(function ModalInner({
|
|
|
951
680
|
onClose,
|
|
952
681
|
isOpen
|
|
953
682
|
}, ref);
|
|
954
|
-
const
|
|
955
|
-
const isMobile = (0, import_styled6.useMedia)((0, import_utils7.maxWidth)(theme.breakpoint.screen1)) ?? false;
|
|
683
|
+
const isMobile = useWindowWidth() < 744;
|
|
956
684
|
const transitionEnabled = isMobile && bottomSheet !== false;
|
|
957
685
|
const showDismiss = !isMobile || bottomSheet !== true;
|
|
958
|
-
const transition = (0,
|
|
686
|
+
const transition = (0, import_react_spring.useTransition)(isOpen, {
|
|
959
687
|
from: {
|
|
960
688
|
transform: "translateY(100%)",
|
|
961
689
|
backgroundColor: "rgba(0, 0, 0, 0)",
|
|
@@ -975,13 +703,13 @@ var Modal = (0, import_react13.forwardRef)(function ModalInner({
|
|
|
975
703
|
},
|
|
976
704
|
config: transitionEnabled ? {
|
|
977
705
|
duration: 400,
|
|
978
|
-
easing:
|
|
706
|
+
easing: import_react_spring.easings.easeOutQuart
|
|
979
707
|
} : {
|
|
980
708
|
duration: 0
|
|
981
709
|
}
|
|
982
710
|
});
|
|
983
|
-
const bgRef =
|
|
984
|
-
const handleClick =
|
|
711
|
+
const bgRef = React12.useRef(null);
|
|
712
|
+
const handleClick = React12.useCallback((e) => {
|
|
985
713
|
if (e.currentTarget === e.target) {
|
|
986
714
|
onClose();
|
|
987
715
|
}
|
|
@@ -990,12 +718,15 @@ var Modal = (0, import_react13.forwardRef)(function ModalInner({
|
|
|
990
718
|
backgroundColor,
|
|
991
719
|
overflow,
|
|
992
720
|
transform
|
|
993
|
-
}, item) => item && /* @__PURE__ */ (0,
|
|
721
|
+
}, item) => item && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_overlays3.Overlay, { portalContainer, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_spring.animated.div, { className: "charcoal-modal-background", ref: bgRef, ...underlayProps, style: transitionEnabled ? {
|
|
994
722
|
backgroundColor,
|
|
995
|
-
overflow
|
|
996
|
-
|
|
723
|
+
overflow,
|
|
724
|
+
zIndex
|
|
725
|
+
} : {
|
|
726
|
+
zIndex
|
|
727
|
+
}, "data-bottom-sheet": bottomSheet, onClick: handleClick, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ModalBackgroundContext.Provider, { value: bgRef.current, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(AnimatedDialog, { ref, ...modalProps, style: transitionEnabled ? {
|
|
997
728
|
transform
|
|
998
|
-
} : {}, size, bottomSheet, className, children: /* @__PURE__ */ (0,
|
|
729
|
+
} : {}, size, bottomSheet, className, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(ModalContext.Provider, { value: {
|
|
999
730
|
titleProps: {},
|
|
1000
731
|
title,
|
|
1001
732
|
close: onClose,
|
|
@@ -1003,96 +734,54 @@ var Modal = (0, import_react13.forwardRef)(function ModalInner({
|
|
|
1003
734
|
bottomSheet
|
|
1004
735
|
}, children: [
|
|
1005
736
|
children,
|
|
1006
|
-
isDismissable === true && /* @__PURE__ */ (0,
|
|
737
|
+
isDismissable === true && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ModalCloseButton, { "aria-label": closeButtonAriaLabel, onClick: onClose })
|
|
1007
738
|
] }) }) }) }) }));
|
|
1008
739
|
});
|
|
1009
|
-
var
|
|
1010
|
-
var
|
|
740
|
+
var AnimatedDialog = (0, import_react_spring.animated)(Dialog);
|
|
741
|
+
var Modal_default = (0, import_react17.memo)(Modal);
|
|
742
|
+
var ModalContext = React12.createContext({
|
|
1011
743
|
titleProps: {},
|
|
1012
744
|
title: "",
|
|
1013
745
|
close: void 0,
|
|
1014
746
|
showDismiss: true,
|
|
1015
747
|
bottomSheet: false
|
|
1016
748
|
});
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
})(["z-index:", ";overflow:auto;display:flex;position:fixed;top:0;left:0;width:-webkit-fill-available;width:-moz-available;height:100%;justify-content:center;padding:40px 0;box-sizing:border-box;background-color:var(--charcoal-surface4);@media ", "{", "}"], ({
|
|
1020
|
-
zIndex
|
|
1021
|
-
}) => zIndex, ({
|
|
1022
|
-
theme
|
|
1023
|
-
}) => (0, import_utils7.maxWidth)(theme.breakpoint.screen1), (p) => p.$bottomSheet !== false && (0, import_styled_components11.css)(["padding:0;"])));
|
|
1024
|
-
var ModalCrossButton = (0, import_styled_components11.default)(IconButton_default).withConfig({
|
|
1025
|
-
componentId: "ccl__sc-h2bc55-1"
|
|
1026
|
-
})(["position:absolute;top:8px;right:8px;color:var(--charcoal-text3);transition:0.2s color;&:not(:disabled):not([aria-disabled]),&[aria-disabled='false']{&:hover{color:var(--charcoal-text3-hover);}&:active{color:var(--charcoal-text3-press);}}"]);
|
|
1027
|
-
function ModalTitle(props) {
|
|
1028
|
-
const {
|
|
1029
|
-
titleProps,
|
|
1030
|
-
title
|
|
1031
|
-
} = (0, import_react13.useContext)(ModalContext);
|
|
1032
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ModalHeading, { ...titleProps, ...props, children: title });
|
|
749
|
+
function ModalCloseButton(props) {
|
|
750
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(IconButton_default, { className: "charcoal-modal-close-button", size: "S", icon: "24/Close", type: "button", ...props });
|
|
1033
751
|
}
|
|
1034
|
-
var ModalHeading = import_styled_components11.default.h3.withConfig({
|
|
1035
|
-
componentId: "ccl__sc-h2bc55-2"
|
|
1036
|
-
})(["margin:0;font-weight:inherit;font-size:inherit;"]);
|
|
1037
752
|
|
|
1038
753
|
// src/components/Modal/ModalPlumbing.tsx
|
|
1039
|
-
var
|
|
1040
|
-
var
|
|
1041
|
-
var import_utils9 = require("@charcoal-ui/utils");
|
|
1042
|
-
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
754
|
+
var import_react18 = require("react");
|
|
755
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1043
756
|
function ModalHeader() {
|
|
1044
|
-
const modalCtx = (0,
|
|
1045
|
-
return /* @__PURE__ */ (0,
|
|
757
|
+
const modalCtx = (0, import_react18.useContext)(ModalContext);
|
|
758
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "charcoal-modal-header-root", "data-bottom-sheet": modalCtx.bottomSheet, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "charcoal-modal-header-title", children: modalCtx.title }) });
|
|
1046
759
|
}
|
|
1047
|
-
var
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
theme
|
|
1051
|
-
}) => (0, import_utils9.maxWidth)(theme.breakpoint.screen1), (p) => p.$bottomSheet !== false && (0, import_styled_components12.css)(["height:48px;"]));
|
|
1052
|
-
var StyledModalTitle = (0, import_styled_components12.default)(ModalTitle).withConfig({
|
|
1053
|
-
componentId: "ccl__sc-1k33wze-1"
|
|
1054
|
-
})(["color:var(--charcoal-text1);font-size:16px;line-height:24px;font-weight:bold;display:flow-root;&::before{display:block;width:0;height:0;content:'';margin-top:-4px;}&::after{display:block;width:0;height:0;content:'';margin-bottom:-4px;}"]);
|
|
1055
|
-
var ModalAlign = import_styled_components12.default.div.withConfig({
|
|
1056
|
-
componentId: "ccl__sc-1k33wze-2"
|
|
1057
|
-
})(["padding-left:16px;padding-right:16px;"]);
|
|
1058
|
-
var ModalBody = import_styled_components12.default.div.withConfig({
|
|
1059
|
-
componentId: "ccl__sc-1k33wze-3"
|
|
1060
|
-
})(["padding-bottom:40px;"]);
|
|
1061
|
-
var ModalButtons = import_styled_components12.default.div.withConfig({
|
|
1062
|
-
componentId: "ccl__sc-1k33wze-4"
|
|
1063
|
-
})(["display:grid;grid-auto-flow:row;grid-row-gap:8px;padding-top:16px;padding-left:16px;padding-right:16px;"]);
|
|
760
|
+
var ModalAlign = createDivComponent("charcoal-modal-align");
|
|
761
|
+
var ModalBody = createDivComponent("charcoal-modal-body");
|
|
762
|
+
var ModalButtons = createDivComponent("charcoal-modal-buttons");
|
|
1064
763
|
|
|
1065
764
|
// src/components/LoadingSpinner/index.tsx
|
|
1066
|
-
var
|
|
1067
|
-
var
|
|
1068
|
-
var
|
|
1069
|
-
var LoadingSpinner = (0, import_react15.forwardRef)(function LoadingSpinnerInner({
|
|
765
|
+
var import_react19 = require("react");
|
|
766
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
767
|
+
var LoadingSpinner = (0, import_react19.forwardRef)(function LoadingSpinnerInner({
|
|
1070
768
|
size = 48,
|
|
1071
769
|
padding = 16,
|
|
1072
770
|
transparent = false,
|
|
1073
|
-
|
|
771
|
+
...props
|
|
1074
772
|
}, ref) {
|
|
1075
|
-
|
|
773
|
+
const classNames = useClassNames("charcoal-loading-spinner", props.className);
|
|
774
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { role: "progressbar", style: {
|
|
775
|
+
"--charcoal-loading-spinner-size": `${size}px`,
|
|
776
|
+
"--charcoal-loading-spinner-padding": `${padding}px`
|
|
777
|
+
}, "data-transparent": transparent, className: classNames, ref, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(LoadingSpinnerIcon, {}) });
|
|
1076
778
|
});
|
|
1077
|
-
var LoadingSpinner_default = (0,
|
|
1078
|
-
var
|
|
1079
|
-
role: "progressbar"
|
|
1080
|
-
}).withConfig({
|
|
1081
|
-
componentId: "ccl__sc-1id6yz4-0"
|
|
1082
|
-
})(["box-sizing:content-box;margin:auto;padding:", "px;border-radius:8px;font-size:", "px;width:", "px;height:", "px;opacity:0.84;color:var(--charcoal-text4);background-color:", ";"], (props) => props.padding, (props) => props.size, (props) => props.size, (props) => props.size, ({
|
|
1083
|
-
transparent
|
|
1084
|
-
}) => `var(--charcoal-${transparent ? "transparent" : "background1"})`);
|
|
1085
|
-
var scaleOut = (0, import_styled_components13.keyframes)(["from{transform:scale(0);opacity:1;}to{transform:scale(1);opacity:0;}"]);
|
|
1086
|
-
var Icon2 = import_styled_components13.default.div.attrs({
|
|
1087
|
-
role: "presentation"
|
|
1088
|
-
}).withConfig({
|
|
1089
|
-
componentId: "ccl__sc-1id6yz4-1"
|
|
1090
|
-
})(["width:1em;height:1em;border-radius:1em;background-color:currentColor;animation:", " 1s both ease-out;animation-iteration-count:", ";&[data-reset-animation]{animation:none;}"], scaleOut, (p) => p.once ? 1 : "infinite");
|
|
1091
|
-
var LoadingSpinnerIcon = (0, import_react15.forwardRef)(function LoadingSpinnerIcon2({
|
|
779
|
+
var LoadingSpinner_default = (0, import_react19.memo)(LoadingSpinner);
|
|
780
|
+
var LoadingSpinnerIcon = (0, import_react19.forwardRef)(function LoadingSpinnerIcon2({
|
|
1092
781
|
once = false
|
|
1093
782
|
}, ref) {
|
|
1094
|
-
const iconRef = (0,
|
|
1095
|
-
(0,
|
|
783
|
+
const iconRef = (0, import_react19.useRef)(null);
|
|
784
|
+
(0, import_react19.useImperativeHandle)(ref, () => ({
|
|
1096
785
|
restart: () => {
|
|
1097
786
|
if (!iconRef.current) {
|
|
1098
787
|
return;
|
|
@@ -1102,44 +791,22 @@ var LoadingSpinnerIcon = (0, import_react15.forwardRef)(function LoadingSpinnerI
|
|
|
1102
791
|
delete iconRef.current.dataset.resetAnimation;
|
|
1103
792
|
}
|
|
1104
793
|
}));
|
|
1105
|
-
return /* @__PURE__ */ (0,
|
|
794
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { role: "presentation", ref: iconRef, "data-once": once, className: "charcoal-loading-spinner-icon" });
|
|
1106
795
|
});
|
|
1107
796
|
|
|
1108
797
|
// src/components/DropdownSelector/index.tsx
|
|
1109
|
-
var
|
|
1110
|
-
var import_styled_components16 = __toESM(require("styled-components"));
|
|
1111
|
-
var import_utils10 = require("@charcoal-ui/utils");
|
|
798
|
+
var import_react24 = require("react");
|
|
1112
799
|
|
|
1113
800
|
// src/components/DropdownSelector/DropdownPopover.tsx
|
|
1114
|
-
var
|
|
801
|
+
var import_react21 = require("react");
|
|
1115
802
|
|
|
1116
803
|
// src/components/DropdownSelector/Popover/index.tsx
|
|
1117
|
-
var
|
|
804
|
+
var import_react20 = require("react");
|
|
1118
805
|
var import_overlays4 = require("@react-aria/overlays");
|
|
1119
|
-
var
|
|
1120
|
-
|
|
1121
|
-
// src/components/DropdownSelector/Popover/usePreventScroll.tsx
|
|
1122
|
-
var import_react16 = require("react");
|
|
1123
|
-
function usePreventScroll2(element, isOpen) {
|
|
1124
|
-
(0, import_react16.useEffect)(() => {
|
|
1125
|
-
if (isOpen && element) {
|
|
1126
|
-
const defaultPaddingRight = element.style.paddingRight;
|
|
1127
|
-
const defaultOverflow = element.style.overflow;
|
|
1128
|
-
element.style.paddingRight = `${window.innerWidth - element.clientWidth}px`;
|
|
1129
|
-
element.style.overflow = "hidden";
|
|
1130
|
-
return () => {
|
|
1131
|
-
element.style.paddingRight = defaultPaddingRight;
|
|
1132
|
-
element.style.overflow = defaultOverflow;
|
|
1133
|
-
};
|
|
1134
|
-
}
|
|
1135
|
-
}, [element, isOpen]);
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
// src/components/DropdownSelector/Popover/index.tsx
|
|
1139
|
-
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
806
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1140
807
|
var _empty = () => null;
|
|
1141
808
|
function Popover(props) {
|
|
1142
|
-
const defaultPopoverRef = (0,
|
|
809
|
+
const defaultPopoverRef = (0, import_react20.useRef)(null);
|
|
1143
810
|
const finalPopoverRef = props.popoverRef === void 0 ? defaultPopoverRef : props.popoverRef;
|
|
1144
811
|
const {
|
|
1145
812
|
popoverProps,
|
|
@@ -1155,58 +822,64 @@ function Popover(props) {
|
|
|
1155
822
|
setOpen: _empty,
|
|
1156
823
|
toggle: _empty
|
|
1157
824
|
});
|
|
1158
|
-
const modalBackground = (0,
|
|
1159
|
-
|
|
825
|
+
const modalBackground = (0, import_react20.useContext)(ModalBackgroundContext);
|
|
826
|
+
usePreventScroll(modalBackground, props.isOpen);
|
|
1160
827
|
if (!props.isOpen)
|
|
1161
828
|
return null;
|
|
1162
|
-
return /* @__PURE__ */ (0,
|
|
1163
|
-
/* @__PURE__ */ (0,
|
|
829
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_overlays4.Overlay, { portalContainer: document.body, children: [
|
|
830
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { ...underlayProps, style: {
|
|
1164
831
|
position: "fixed",
|
|
1165
832
|
zIndex: typeof popoverProps.style?.zIndex === "number" ? popoverProps.style.zIndex - 1 : 99999,
|
|
1166
833
|
inset: 0
|
|
1167
834
|
} }),
|
|
1168
|
-
/* @__PURE__ */ (0,
|
|
1169
|
-
/* @__PURE__ */ (0,
|
|
835
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { ...popoverProps, ref: finalPopoverRef, className: "charcoal-popover", children: [
|
|
836
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_overlays4.DismissButton, { onDismiss: () => props.onClose() }),
|
|
837
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { tabIndex: 0, onFocus: props.onClose }),
|
|
1170
838
|
props.children,
|
|
1171
|
-
/* @__PURE__ */ (0,
|
|
839
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { tabIndex: 0, onFocus: props.onClose }),
|
|
840
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_overlays4.DismissButton, { onDismiss: () => props.onClose() })
|
|
1172
841
|
] })
|
|
1173
842
|
] });
|
|
1174
843
|
}
|
|
1175
|
-
var DropdownPopoverDiv = import_styled_components14.default.div.withConfig({
|
|
1176
|
-
componentId: "ccl__sc-jwnoy6-0"
|
|
1177
|
-
})(["margin:4px 0;list-style:none;overflow:auto;max-height:inherit;background-color:var(--charcoal-background1);border:solid 1px var(--charcoal-border-default);border-radius:8px;padding-top:8px;padding-bottom:8px;"]);
|
|
1178
844
|
|
|
1179
845
|
// src/components/DropdownSelector/DropdownPopover.tsx
|
|
1180
|
-
var
|
|
846
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1181
847
|
function DropdownPopover({
|
|
1182
848
|
children,
|
|
1183
849
|
...props
|
|
1184
850
|
}) {
|
|
1185
|
-
const ref = (0,
|
|
1186
|
-
(0,
|
|
851
|
+
const ref = (0, import_react21.useRef)(null);
|
|
852
|
+
(0, import_react21.useEffect)(() => {
|
|
1187
853
|
if (props.isOpen && ref.current && props.triggerRef.current) {
|
|
1188
854
|
ref.current.style.width = `${props.triggerRef.current.clientWidth}px`;
|
|
1189
855
|
}
|
|
1190
856
|
}, [props.triggerRef, props.isOpen]);
|
|
1191
|
-
(0,
|
|
1192
|
-
if (props.isOpen
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
857
|
+
(0, import_react21.useEffect)(() => {
|
|
858
|
+
if (props.isOpen) {
|
|
859
|
+
if (props.value !== void 0 && props.value !== "") {
|
|
860
|
+
const windowScrollY = window.scrollY;
|
|
861
|
+
const windowScrollX = window.scrollX;
|
|
862
|
+
const selectedElement = document.querySelector(`[data-key="${props.value.toString()}"]`);
|
|
863
|
+
selectedElement?.focus();
|
|
864
|
+
window.scrollTo(windowScrollX, windowScrollY);
|
|
865
|
+
} else {
|
|
866
|
+
const el = ref.current?.querySelector("[role='option']");
|
|
867
|
+
if (el instanceof HTMLElement) {
|
|
868
|
+
el.focus();
|
|
869
|
+
}
|
|
870
|
+
}
|
|
1198
871
|
}
|
|
1199
872
|
}, [props.value, props.isOpen]);
|
|
1200
|
-
return /* @__PURE__ */ (0,
|
|
873
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Popover, { isOpen: props.isOpen, onClose: props.onClose, popoverRef: ref, triggerRef: props.triggerRef, children });
|
|
1201
874
|
}
|
|
1202
875
|
|
|
1203
876
|
// src/components/DropdownSelector/utils/findPreviewRecursive.tsx
|
|
1204
|
-
var
|
|
877
|
+
var React13 = __toESM(require("react"));
|
|
1205
878
|
function findPreviewRecursive(children, value) {
|
|
1206
|
-
const childArray =
|
|
879
|
+
const childArray = React13.Children.toArray(children);
|
|
1207
880
|
for (let i = 0; i < childArray.length; i++) {
|
|
1208
881
|
const child = childArray[i];
|
|
1209
|
-
if (
|
|
882
|
+
if (React13.isValidElement(child)) {
|
|
1210
883
|
if ("value" in child.props) {
|
|
1211
884
|
const childValue = child.props.value;
|
|
1212
885
|
if (childValue === value && "children" in child.props) {
|
|
@@ -1225,12 +898,11 @@ function findPreviewRecursive(children, value) {
|
|
|
1225
898
|
}
|
|
1226
899
|
|
|
1227
900
|
// src/components/DropdownSelector/MenuList/index.tsx
|
|
1228
|
-
var
|
|
1229
|
-
var import_styled_components15 = __toESM(require("styled-components"));
|
|
901
|
+
var import_react23 = require("react");
|
|
1230
902
|
|
|
1231
903
|
// src/components/DropdownSelector/MenuList/MenuListContext.ts
|
|
1232
|
-
var
|
|
1233
|
-
var MenuListContext = (0,
|
|
904
|
+
var import_react22 = require("react");
|
|
905
|
+
var MenuListContext = (0, import_react22.createContext)({
|
|
1234
906
|
root: void 0,
|
|
1235
907
|
value: "",
|
|
1236
908
|
propsArray: [],
|
|
@@ -1239,13 +911,13 @@ var MenuListContext = (0, import_react19.createContext)({
|
|
|
1239
911
|
});
|
|
1240
912
|
|
|
1241
913
|
// src/components/DropdownSelector/MenuList/internals/getValuesRecursive.tsx
|
|
1242
|
-
var
|
|
914
|
+
var React14 = __toESM(require("react"));
|
|
1243
915
|
function getValuesRecursive(children) {
|
|
1244
|
-
const childArray =
|
|
916
|
+
const childArray = React14.Children.toArray(children);
|
|
1245
917
|
const propsArray = [];
|
|
1246
918
|
for (let i = 0; i < childArray.length; i++) {
|
|
1247
919
|
const child = childArray[i];
|
|
1248
|
-
if (
|
|
920
|
+
if (React14.isValidElement(child)) {
|
|
1249
921
|
const props = child.props;
|
|
1250
922
|
if ("value" in props && typeof props.value === "string") {
|
|
1251
923
|
propsArray.push({
|
|
@@ -1262,11 +934,11 @@ function getValuesRecursive(children) {
|
|
|
1262
934
|
}
|
|
1263
935
|
|
|
1264
936
|
// src/components/DropdownSelector/MenuList/index.tsx
|
|
1265
|
-
var
|
|
937
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1266
938
|
function MenuList(props) {
|
|
1267
|
-
const root = (0,
|
|
1268
|
-
const propsArray = (0,
|
|
1269
|
-
return /* @__PURE__ */ (0,
|
|
939
|
+
const root = (0, import_react23.useRef)(null);
|
|
940
|
+
const propsArray = (0, import_react23.useMemo)(() => getValuesRecursive(props.children), [props.children]);
|
|
941
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("ul", { className: "charcoal-menu-list", ref: root, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(MenuListContext.Provider, { value: {
|
|
1270
942
|
value: props.value ?? "",
|
|
1271
943
|
root,
|
|
1272
944
|
propsArray,
|
|
@@ -1275,91 +947,70 @@ function MenuList(props) {
|
|
|
1275
947
|
}
|
|
1276
948
|
}, children: props.children }) });
|
|
1277
949
|
}
|
|
1278
|
-
var StyledUl = import_styled_components15.default.ul.withConfig({
|
|
1279
|
-
componentId: "ccl__sc-1y72v02-0"
|
|
1280
|
-
})(["padding:0;margin:0;"]);
|
|
1281
950
|
|
|
1282
951
|
// src/components/DropdownSelector/index.tsx
|
|
1283
|
-
var import_styled7 = require("@charcoal-ui/styled");
|
|
1284
952
|
var import_visually_hidden3 = require("@react-aria/visually-hidden");
|
|
1285
|
-
var
|
|
1286
|
-
var
|
|
1287
|
-
function DropdownSelector(
|
|
1288
|
-
|
|
1289
|
-
|
|
953
|
+
var import_utils5 = require("@react-aria/utils");
|
|
954
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
955
|
+
function DropdownSelector({
|
|
956
|
+
onChange,
|
|
957
|
+
showLabel = false,
|
|
958
|
+
...props
|
|
959
|
+
}) {
|
|
960
|
+
const triggerRef = (0, import_react24.useRef)(null);
|
|
961
|
+
const [isOpen, setIsOpen] = (0, import_react24.useState)(false);
|
|
1290
962
|
const preview = findPreviewRecursive(props.children, props.value);
|
|
1291
|
-
const isPlaceholder = (0,
|
|
963
|
+
const isPlaceholder = (0, import_react24.useMemo)(() => props.placeholder !== void 0 && preview === void 0, [preview, props.placeholder]);
|
|
1292
964
|
const propsArray = getValuesRecursive(props.children);
|
|
1293
965
|
const {
|
|
1294
966
|
visuallyHiddenProps
|
|
1295
967
|
} = (0, import_visually_hidden3.useVisuallyHidden)();
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
968
|
+
const handleChange = (0, import_react24.useCallback)((e) => {
|
|
969
|
+
onChange(e.target.value);
|
|
970
|
+
}, [onChange]);
|
|
971
|
+
const labelId = (0, import_utils5.useId)();
|
|
972
|
+
const describedbyId = (0, import_utils5.useId)();
|
|
973
|
+
const classNames = useClassNames("charcoal-dropdown-selector-root", props.className);
|
|
974
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: classNames, "aria-disabled": props.disabled, children: [
|
|
975
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(FieldLabel_default, { id: labelId, label: props.label, required: props.required, requiredText: props.requiredText, subLabel: props.subLabel, ...!showLabel ? visuallyHiddenProps : {} }),
|
|
976
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { ...visuallyHiddenProps, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("select", { name: props.name, value: props.value, onChange: handleChange, tabIndex: -1, children: propsArray.map((itemProps) => {
|
|
977
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: itemProps.value, disabled: itemProps.disabled, children: itemProps.value }, itemProps.value);
|
|
1300
978
|
}) }) }),
|
|
1301
|
-
/* @__PURE__ */ (0,
|
|
979
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("button", { className: "charcoal-dropdown-selector-button", "aria-labelledby": labelId, "aria-invalid": props.invalid, "aria-describedby": props.assistiveText !== void 0 ? describedbyId : void 0, disabled: props.disabled, onClick: () => {
|
|
1302
980
|
if (props.disabled === true)
|
|
1303
981
|
return;
|
|
1304
982
|
setIsOpen(true);
|
|
1305
|
-
}, ref: triggerRef, type: "button",
|
|
1306
|
-
/* @__PURE__ */ (0,
|
|
1307
|
-
/* @__PURE__ */ (0,
|
|
983
|
+
}, ref: triggerRef, type: "button", "data-active": isOpen, children: [
|
|
984
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "charcoal-ui-dropdown-selector-text", "data-placeholder": isPlaceholder, children: isPlaceholder ? props.placeholder : preview }),
|
|
985
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Icon_default, { className: "charcoal-ui-dropdown-selector-icon", name: "16/Menu" })
|
|
1308
986
|
] }),
|
|
1309
|
-
isOpen && /* @__PURE__ */ (0,
|
|
1310
|
-
|
|
987
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropdownPopover, { isOpen, onClose: () => setIsOpen(false), triggerRef, value: props.value, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(MenuList, { value: props.value, onChange: (v) => {
|
|
988
|
+
onChange(v);
|
|
1311
989
|
setIsOpen(false);
|
|
1312
990
|
}, children: props.children }) }),
|
|
1313
|
-
props.assistiveText !== void 0 && /* @__PURE__ */ (0,
|
|
991
|
+
props.assistiveText !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(AssistiveText, { "data-invalid": props.invalid === true, id: describedbyId, children: props.assistiveText })
|
|
1314
992
|
] });
|
|
1315
993
|
}
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
var DropdownFieldLabel = (0, import_styled_components16.default)(FieldLabel_default).withConfig({
|
|
1320
|
-
componentId: "ccl__sc-1vnxmc8-1"
|
|
1321
|
-
})(["width:100%;margin-bottom:8px;"]);
|
|
1322
|
-
var DropdownButton = import_styled_components16.default.button.withConfig({
|
|
1323
|
-
componentId: "ccl__sc-1vnxmc8-2"
|
|
1324
|
-
})(["display:flex;justify-content:space-between;align-items:center;height:40px;width:100%;box-sizing:border-box;border:none;cursor:pointer;gap:4px;", "{cursor:default;}padding-right:8px;padding-left:8px;background-color:var(--charcoal-surface3);border-radius:4px;transition:0.2s box-shadow,0.2s background-color;&:not(:disabled):not([aria-disabled]),&[aria-disabled='false']{", " ", "}", ""], import_utils10.disabledSelector, import_styled7.focusVisibleFocusRingCss, ({
|
|
1325
|
-
$active
|
|
1326
|
-
}) => $active === true ? (0, import_styled_components16.css)(["background-color:var(--charcoal-surface3-press);"]) : (0, import_styled_components16.css)(["&:hover{background-color:var(--charcoal-surface3-hover);}&:active{background-color:var(--charcoal-surface3-press);}"]), ({
|
|
1327
|
-
invalid
|
|
1328
|
-
}) => invalid === true && (0, import_styled_components16.css)(["&:not(:disabled):not([aria-disabled]),&[aria-disabled='false']{box-shadow:0 0 0 4px rgba(255,43,0,0.32);}"]));
|
|
1329
|
-
var DropdownButtonText = import_styled_components16.default.span.withConfig({
|
|
1330
|
-
componentId: "ccl__sc-1vnxmc8-3"
|
|
1331
|
-
})(["text-align:left;font-size:14px;line-height:22px;display:flow-root;color:var(--charcoal-", ");overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"], (p) => p.$isText3 ? "text3" : "text2");
|
|
1332
|
-
var DropdownButtonIcon = (0, import_styled_components16.default)(Icon_default).withConfig({
|
|
1333
|
-
componentId: "ccl__sc-1vnxmc8-4"
|
|
1334
|
-
})(["color:var(--charcoal-text2);"]);
|
|
1335
|
-
var AssertiveText = import_styled_components16.default.div.withConfig({
|
|
1336
|
-
componentId: "ccl__sc-1vnxmc8-5"
|
|
1337
|
-
})(["margin-top:8px;font-size:14px;color:var(--charcoal-text2);line-height:22px;display:flow-root;&::before{display:block;width:0;height:0;content:'';margin-top:-4px;}&::after{display:block;width:0;height:0;content:'';margin-bottom:-4px;}", ""], ({
|
|
1338
|
-
invalid
|
|
1339
|
-
}) => invalid === true && (0, import_styled_components16.css)(["color:var(--charcoal-assertive);"]));
|
|
1340
|
-
|
|
1341
|
-
// src/components/DropdownSelector/DropdownMenuItem.tsx
|
|
1342
|
-
var import_styled_components18 = __toESM(require("styled-components"));
|
|
994
|
+
|
|
995
|
+
// src/components/DropdownSelector/MenuItem/index.tsx
|
|
996
|
+
var import_react27 = require("react");
|
|
1343
997
|
|
|
1344
998
|
// src/components/DropdownSelector/ListItem/index.tsx
|
|
1345
|
-
var
|
|
1346
|
-
var
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
var ItemDiv = import_styled_components17.default.div.withConfig({
|
|
1358
|
-
componentId: "ccl__sc-p1vs75-1"
|
|
1359
|
-
})(["display:flex;align-items:center;min-height:40px;cursor:pointer;outline:none;padding-right:16px;padding-left:16px;transition:background-color 0.2s;&:disabled,&[aria-disabled]:not([aria-disabled='false']){opacity:0.32;cursor:default;}:hover,:focus,:focus-within{&:not(disabled):not([aria-disabled='true']){background-color:var(--charcoal-surface3);}}"]);
|
|
999
|
+
var import_react25 = require("react");
|
|
1000
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
1001
|
+
var ListItem = (0, import_react25.forwardRef)(function ListItem2({
|
|
1002
|
+
as,
|
|
1003
|
+
className,
|
|
1004
|
+
...props
|
|
1005
|
+
}, ref) {
|
|
1006
|
+
const Component = (0, import_react25.useMemo)(() => as ?? "li", [as]);
|
|
1007
|
+
const classNames = useClassNames("charcoal-list-item", className);
|
|
1008
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Component, { className: classNames, ref, ...props });
|
|
1009
|
+
});
|
|
1010
|
+
var ListItem_default = ListItem;
|
|
1360
1011
|
|
|
1361
1012
|
// src/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.tsx
|
|
1362
|
-
var
|
|
1013
|
+
var import_react26 = require("react");
|
|
1363
1014
|
|
|
1364
1015
|
// src/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.tsx
|
|
1365
1016
|
function handleFocusByKeyBoard(element, parent) {
|
|
@@ -1396,12 +1047,12 @@ function useMenuItemHandleKeyDown(value) {
|
|
|
1396
1047
|
setValue,
|
|
1397
1048
|
root,
|
|
1398
1049
|
propsArray
|
|
1399
|
-
} = (0,
|
|
1400
|
-
const setContextValue = (0,
|
|
1050
|
+
} = (0, import_react26.useContext)(MenuListContext);
|
|
1051
|
+
const setContextValue = (0, import_react26.useCallback)(() => {
|
|
1401
1052
|
if (value !== void 0)
|
|
1402
1053
|
setValue(value);
|
|
1403
1054
|
}, [value, setValue]);
|
|
1404
|
-
const handleKeyDown = (0,
|
|
1055
|
+
const handleKeyDown = (0, import_react26.useCallback)((e) => {
|
|
1405
1056
|
if (e.key === "Enter") {
|
|
1406
1057
|
setContextValue();
|
|
1407
1058
|
} else if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
@@ -1436,337 +1087,95 @@ function useMenuItemHandleKeyDown(value) {
|
|
|
1436
1087
|
}
|
|
1437
1088
|
|
|
1438
1089
|
// src/components/DropdownSelector/MenuItem/index.tsx
|
|
1439
|
-
var
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
const [handleKeyDown, setContextValue] = useMenuItemHandleKeyDown(
|
|
1447
|
-
return /* @__PURE__ */ (0,
|
|
1448
|
-
}
|
|
1090
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
1091
|
+
var MenuItem = (0, import_react27.forwardRef)(function MenuItem2({
|
|
1092
|
+
className,
|
|
1093
|
+
value,
|
|
1094
|
+
disabled,
|
|
1095
|
+
...props
|
|
1096
|
+
}, ref) {
|
|
1097
|
+
const [handleKeyDown, setContextValue] = useMenuItemHandleKeyDown(value);
|
|
1098
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ListItem_default, { ...props, ref, "data-key": value, onKeyDown: handleKeyDown, onClick: disabled === true ? void 0 : setContextValue, tabIndex: -1, "aria-disabled": disabled, role: "option", children: props.children });
|
|
1099
|
+
});
|
|
1100
|
+
var MenuItem_default = MenuItem;
|
|
1449
1101
|
|
|
1450
|
-
// src/components/DropdownSelector/DropdownMenuItem.tsx
|
|
1451
|
-
var
|
|
1452
|
-
var
|
|
1102
|
+
// src/components/DropdownSelector/DropdownMenuItem/index.tsx
|
|
1103
|
+
var import_react28 = require("react");
|
|
1104
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
1453
1105
|
function DropdownMenuItem(props) {
|
|
1454
1106
|
const {
|
|
1455
1107
|
value: ctxValue
|
|
1456
|
-
} = (0,
|
|
1108
|
+
} = (0, import_react28.useContext)(MenuListContext);
|
|
1457
1109
|
const isSelected = props.value === ctxValue;
|
|
1458
1110
|
const {
|
|
1459
1111
|
children,
|
|
1460
1112
|
...rest
|
|
1461
1113
|
} = props;
|
|
1462
|
-
return /* @__PURE__ */ (0,
|
|
1463
|
-
isSelected && /* @__PURE__ */ (0,
|
|
1464
|
-
/* @__PURE__ */ (0,
|
|
1114
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(MenuItem_default, { ...rest, "aria-selected": isSelected, children: [
|
|
1115
|
+
isSelected && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Icon_default, { className: "charcoal-dropdown-selector-menu-item-icon", name: "16/Check" }),
|
|
1116
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "charcoal-dropdown-selector-menu-item", "data-selected": isSelected, children: props.children })
|
|
1465
1117
|
] });
|
|
1466
1118
|
}
|
|
1467
|
-
var StyledSpan = import_styled_components18.default.span.withConfig({
|
|
1468
|
-
componentId: "ccl__sc-108wg2j-0"
|
|
1469
|
-
})(["font-size:14px;line-height:22px;color:var(--charcoal-text2);padding:9px 0;display:flex;align-items:center;width:100%;margin-left:", "px;"], ({
|
|
1470
|
-
isSelected
|
|
1471
|
-
}) => isSelected === true ? 0 : 20);
|
|
1472
|
-
var Text2ColorIcon = (0, import_styled_components18.default)(Icon_default).withConfig({
|
|
1473
|
-
componentId: "ccl__sc-108wg2j-1"
|
|
1474
|
-
})(["color:var(--charcoal-text2);padding-right:4px;"]);
|
|
1475
1119
|
|
|
1476
1120
|
// src/components/DropdownSelector/MenuItemGroup/index.tsx
|
|
1477
|
-
var
|
|
1478
|
-
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
1121
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
1479
1122
|
function MenuItemGroup(props) {
|
|
1480
|
-
return /* @__PURE__ */ (0,
|
|
1481
|
-
/* @__PURE__ */ (0,
|
|
1482
|
-
/* @__PURE__ */ (0,
|
|
1123
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("li", { className: "charcoal-menu-item-group", role: "presentation", children: [
|
|
1124
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { children: props.text }),
|
|
1125
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("ul", { role: "group", children: props.children })
|
|
1483
1126
|
] });
|
|
1484
1127
|
}
|
|
1485
|
-
var TextSpan = import_styled_components19.default.span.withConfig({
|
|
1486
|
-
componentId: "ccl__sc-1ubjfz7-0"
|
|
1487
|
-
})(["display:block;color:var(--charcoal-text3);font-size:12px;font-weight:bold;padding:12px 0 8px 16px;"]);
|
|
1488
|
-
var StyledUl2 = import_styled_components19.default.ul.withConfig({
|
|
1489
|
-
componentId: "ccl__sc-1ubjfz7-1"
|
|
1490
|
-
})(["padding-left:0;margin:0;box-sizing:border-box;list-style:none;overflow:hidden;"]);
|
|
1491
|
-
var StyledLi2 = import_styled_components19.default.li.withConfig({
|
|
1492
|
-
componentId: "ccl__sc-1ubjfz7-2"
|
|
1493
|
-
})(["display:block;"]);
|
|
1494
|
-
|
|
1495
|
-
// src/components/SegmentedControl/index.tsx
|
|
1496
|
-
var import_react28 = require("react");
|
|
1497
|
-
|
|
1498
|
-
// ../../node_modules/@react-stately/form/dist/import.mjs
|
|
1499
|
-
var import_react24 = require("react");
|
|
1500
|
-
var $e5be200c675c3b3a$export$aca958c65c314e6c = {
|
|
1501
|
-
badInput: false,
|
|
1502
|
-
customError: false,
|
|
1503
|
-
patternMismatch: false,
|
|
1504
|
-
rangeOverflow: false,
|
|
1505
|
-
rangeUnderflow: false,
|
|
1506
|
-
stepMismatch: false,
|
|
1507
|
-
tooLong: false,
|
|
1508
|
-
tooShort: false,
|
|
1509
|
-
typeMismatch: false,
|
|
1510
|
-
valueMissing: false,
|
|
1511
|
-
valid: true
|
|
1512
|
-
};
|
|
1513
|
-
var $e5be200c675c3b3a$var$CUSTOM_VALIDITY_STATE = {
|
|
1514
|
-
...$e5be200c675c3b3a$export$aca958c65c314e6c,
|
|
1515
|
-
customError: true,
|
|
1516
|
-
valid: false
|
|
1517
|
-
};
|
|
1518
|
-
var $e5be200c675c3b3a$export$dad6ae84456c676a = {
|
|
1519
|
-
isInvalid: false,
|
|
1520
|
-
validationDetails: $e5be200c675c3b3a$export$aca958c65c314e6c,
|
|
1521
|
-
validationErrors: []
|
|
1522
|
-
};
|
|
1523
|
-
var $e5be200c675c3b3a$export$571b5131b7e65c11 = (0, import_react24.createContext)({});
|
|
1524
|
-
var $e5be200c675c3b3a$export$a763b9476acd3eb = "__formValidationState" + Date.now();
|
|
1525
|
-
function $e5be200c675c3b3a$export$fc1a364ae1f3ff10(props) {
|
|
1526
|
-
if (props[$e5be200c675c3b3a$export$a763b9476acd3eb]) {
|
|
1527
|
-
let {
|
|
1528
|
-
realtimeValidation,
|
|
1529
|
-
displayValidation,
|
|
1530
|
-
updateValidation,
|
|
1531
|
-
resetValidation,
|
|
1532
|
-
commitValidation
|
|
1533
|
-
} = props[$e5be200c675c3b3a$export$a763b9476acd3eb];
|
|
1534
|
-
return {
|
|
1535
|
-
realtimeValidation,
|
|
1536
|
-
displayValidation,
|
|
1537
|
-
updateValidation,
|
|
1538
|
-
resetValidation,
|
|
1539
|
-
commitValidation
|
|
1540
|
-
};
|
|
1541
|
-
}
|
|
1542
|
-
return $e5be200c675c3b3a$var$useFormValidationStateImpl(props);
|
|
1543
|
-
}
|
|
1544
|
-
function $e5be200c675c3b3a$var$useFormValidationStateImpl(props) {
|
|
1545
|
-
let {
|
|
1546
|
-
isInvalid,
|
|
1547
|
-
validationState,
|
|
1548
|
-
name,
|
|
1549
|
-
value,
|
|
1550
|
-
builtinValidation,
|
|
1551
|
-
validate,
|
|
1552
|
-
validationBehavior = "aria"
|
|
1553
|
-
} = props;
|
|
1554
|
-
if (validationState)
|
|
1555
|
-
isInvalid || (isInvalid = validationState === "invalid");
|
|
1556
|
-
let controlledError = isInvalid ? {
|
|
1557
|
-
isInvalid: true,
|
|
1558
|
-
validationErrors: [],
|
|
1559
|
-
validationDetails: $e5be200c675c3b3a$var$CUSTOM_VALIDITY_STATE
|
|
1560
|
-
} : null;
|
|
1561
|
-
let clientError = (0, import_react24.useMemo)(() => $e5be200c675c3b3a$var$getValidationResult($e5be200c675c3b3a$var$runValidate(validate, value)), [validate, value]);
|
|
1562
|
-
if (builtinValidation === null || builtinValidation === void 0 ? void 0 : builtinValidation.validationDetails.valid)
|
|
1563
|
-
builtinValidation = null;
|
|
1564
|
-
let serverErrors = (0, import_react24.useContext)($e5be200c675c3b3a$export$571b5131b7e65c11);
|
|
1565
|
-
let serverErrorMessages = (0, import_react24.useMemo)(() => {
|
|
1566
|
-
if (name)
|
|
1567
|
-
return Array.isArray(name) ? name.flatMap((name2) => $e5be200c675c3b3a$var$asArray(serverErrors[name2])) : $e5be200c675c3b3a$var$asArray(serverErrors[name]);
|
|
1568
|
-
return [];
|
|
1569
|
-
}, [serverErrors, name]);
|
|
1570
|
-
let [lastServerErrors, setLastServerErrors] = (0, import_react24.useState)(serverErrors);
|
|
1571
|
-
let [isServerErrorCleared, setServerErrorCleared] = (0, import_react24.useState)(false);
|
|
1572
|
-
if (serverErrors !== lastServerErrors) {
|
|
1573
|
-
setLastServerErrors(serverErrors);
|
|
1574
|
-
setServerErrorCleared(false);
|
|
1575
|
-
}
|
|
1576
|
-
let serverError = (0, import_react24.useMemo)(() => $e5be200c675c3b3a$var$getValidationResult(isServerErrorCleared ? [] : serverErrorMessages), [isServerErrorCleared, serverErrorMessages]);
|
|
1577
|
-
let nextValidation = (0, import_react24.useRef)($e5be200c675c3b3a$export$dad6ae84456c676a);
|
|
1578
|
-
let [currentValidity, setCurrentValidity] = (0, import_react24.useState)($e5be200c675c3b3a$export$dad6ae84456c676a);
|
|
1579
|
-
let lastError = (0, import_react24.useRef)($e5be200c675c3b3a$export$dad6ae84456c676a);
|
|
1580
|
-
let commitValidation = () => {
|
|
1581
|
-
if (!commitQueued)
|
|
1582
|
-
return;
|
|
1583
|
-
setCommitQueued(false);
|
|
1584
|
-
let error = clientError || builtinValidation || nextValidation.current;
|
|
1585
|
-
if (!$e5be200c675c3b3a$var$isEqualValidation(error, lastError.current)) {
|
|
1586
|
-
lastError.current = error;
|
|
1587
|
-
setCurrentValidity(error);
|
|
1588
|
-
}
|
|
1589
|
-
};
|
|
1590
|
-
let [commitQueued, setCommitQueued] = (0, import_react24.useState)(false);
|
|
1591
|
-
(0, import_react24.useEffect)(commitValidation);
|
|
1592
|
-
let realtimeValidation = controlledError || serverError || clientError || builtinValidation || $e5be200c675c3b3a$export$dad6ae84456c676a;
|
|
1593
|
-
let displayValidation = validationBehavior === "native" ? controlledError || serverError || currentValidity : controlledError || serverError || clientError || builtinValidation || currentValidity;
|
|
1594
|
-
return {
|
|
1595
|
-
realtimeValidation,
|
|
1596
|
-
displayValidation,
|
|
1597
|
-
updateValidation(value2) {
|
|
1598
|
-
if (validationBehavior === "aria" && !$e5be200c675c3b3a$var$isEqualValidation(currentValidity, value2))
|
|
1599
|
-
setCurrentValidity(value2);
|
|
1600
|
-
else
|
|
1601
|
-
nextValidation.current = value2;
|
|
1602
|
-
},
|
|
1603
|
-
resetValidation() {
|
|
1604
|
-
let error = $e5be200c675c3b3a$export$dad6ae84456c676a;
|
|
1605
|
-
if (!$e5be200c675c3b3a$var$isEqualValidation(error, lastError.current)) {
|
|
1606
|
-
lastError.current = error;
|
|
1607
|
-
setCurrentValidity(error);
|
|
1608
|
-
}
|
|
1609
|
-
if (validationBehavior === "native")
|
|
1610
|
-
setCommitQueued(false);
|
|
1611
|
-
setServerErrorCleared(true);
|
|
1612
|
-
},
|
|
1613
|
-
commitValidation() {
|
|
1614
|
-
if (validationBehavior === "native")
|
|
1615
|
-
setCommitQueued(true);
|
|
1616
|
-
setServerErrorCleared(true);
|
|
1617
|
-
}
|
|
1618
|
-
};
|
|
1619
|
-
}
|
|
1620
|
-
function $e5be200c675c3b3a$var$asArray(v) {
|
|
1621
|
-
if (!v)
|
|
1622
|
-
return [];
|
|
1623
|
-
return Array.isArray(v) ? v : [v];
|
|
1624
|
-
}
|
|
1625
|
-
function $e5be200c675c3b3a$var$runValidate(validate, value) {
|
|
1626
|
-
if (typeof validate === "function") {
|
|
1627
|
-
let e = validate(value);
|
|
1628
|
-
if (e && typeof e !== "boolean")
|
|
1629
|
-
return $e5be200c675c3b3a$var$asArray(e);
|
|
1630
|
-
}
|
|
1631
|
-
return [];
|
|
1632
|
-
}
|
|
1633
|
-
function $e5be200c675c3b3a$var$getValidationResult(errors) {
|
|
1634
|
-
return errors.length ? {
|
|
1635
|
-
isInvalid: true,
|
|
1636
|
-
validationErrors: errors,
|
|
1637
|
-
validationDetails: $e5be200c675c3b3a$var$CUSTOM_VALIDITY_STATE
|
|
1638
|
-
} : null;
|
|
1639
|
-
}
|
|
1640
|
-
function $e5be200c675c3b3a$var$isEqualValidation(a, b) {
|
|
1641
|
-
if (a === b)
|
|
1642
|
-
return true;
|
|
1643
|
-
return a && b && a.isInvalid === b.isInvalid && a.validationErrors.length === b.validationErrors.length && a.validationErrors.every((a2, i) => a2 === b.validationErrors[i]) && Object.entries(a.validationDetails).every(([k, v]) => b.validationDetails[k] === v);
|
|
1644
|
-
}
|
|
1645
|
-
|
|
1646
|
-
// ../../node_modules/@react-stately/utils/dist/import.mjs
|
|
1647
|
-
var import_react25 = require("react");
|
|
1648
|
-
function $458b0a5536c1a7cf$export$40bfa8c7b0832715(value, defaultValue, onChange) {
|
|
1649
|
-
let [stateValue, setStateValue] = (0, import_react25.useState)(value || defaultValue);
|
|
1650
|
-
let isControlledRef = (0, import_react25.useRef)(value !== void 0);
|
|
1651
|
-
let isControlled = value !== void 0;
|
|
1652
|
-
(0, import_react25.useEffect)(() => {
|
|
1653
|
-
let wasControlled = isControlledRef.current;
|
|
1654
|
-
if (wasControlled !== isControlled)
|
|
1655
|
-
console.warn(`WARN: A component changed from ${wasControlled ? "controlled" : "uncontrolled"} to ${isControlled ? "controlled" : "uncontrolled"}.`);
|
|
1656
|
-
isControlledRef.current = isControlled;
|
|
1657
|
-
}, [isControlled]);
|
|
1658
|
-
let currentValue = isControlled ? value : stateValue;
|
|
1659
|
-
let setValue = (0, import_react25.useCallback)((value2, ...args) => {
|
|
1660
|
-
let onChangeCaller = (value3, ...onChangeArgs) => {
|
|
1661
|
-
if (onChange) {
|
|
1662
|
-
if (!Object.is(currentValue, value3))
|
|
1663
|
-
onChange(value3, ...onChangeArgs);
|
|
1664
|
-
}
|
|
1665
|
-
if (!isControlled)
|
|
1666
|
-
currentValue = value3;
|
|
1667
|
-
};
|
|
1668
|
-
if (typeof value2 === "function") {
|
|
1669
|
-
console.warn("We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320");
|
|
1670
|
-
let updateFunction = (oldValue, ...functionArgs) => {
|
|
1671
|
-
let interceptedValue = value2(isControlled ? currentValue : oldValue, ...functionArgs);
|
|
1672
|
-
onChangeCaller(interceptedValue, ...args);
|
|
1673
|
-
if (!isControlled)
|
|
1674
|
-
return interceptedValue;
|
|
1675
|
-
return oldValue;
|
|
1676
|
-
};
|
|
1677
|
-
setStateValue(updateFunction);
|
|
1678
|
-
} else {
|
|
1679
|
-
if (!isControlled)
|
|
1680
|
-
setStateValue(value2);
|
|
1681
|
-
onChangeCaller(value2, ...args);
|
|
1682
|
-
}
|
|
1683
|
-
}, [isControlled, currentValue, onChange]);
|
|
1684
|
-
return [currentValue, setValue];
|
|
1685
|
-
}
|
|
1686
|
-
|
|
1687
|
-
// ../../node_modules/@react-stately/radio/dist/import.mjs
|
|
1688
|
-
var import_react26 = require("react");
|
|
1689
|
-
var $a54cdc5c1942b639$var$instance = Math.round(Math.random() * 1e10);
|
|
1690
|
-
var $a54cdc5c1942b639$var$i = 0;
|
|
1691
|
-
function $a54cdc5c1942b639$export$bca9d026f8e704eb(props) {
|
|
1692
|
-
let name = (0, import_react26.useMemo)(() => props.name || `radio-group-${$a54cdc5c1942b639$var$instance}-${++$a54cdc5c1942b639$var$i}`, [props.name]);
|
|
1693
|
-
var _props_defaultValue;
|
|
1694
|
-
let [selectedValue, setSelected] = (0, $458b0a5536c1a7cf$export$40bfa8c7b0832715)(props.value, (_props_defaultValue = props.defaultValue) !== null && _props_defaultValue !== void 0 ? _props_defaultValue : null, props.onChange);
|
|
1695
|
-
let [lastFocusedValue, setLastFocusedValue] = (0, import_react26.useState)(null);
|
|
1696
|
-
let validation = (0, $e5be200c675c3b3a$export$fc1a364ae1f3ff10)({
|
|
1697
|
-
...props,
|
|
1698
|
-
value: selectedValue
|
|
1699
|
-
});
|
|
1700
|
-
let setSelectedValue = (value) => {
|
|
1701
|
-
if (!props.isReadOnly && !props.isDisabled) {
|
|
1702
|
-
setSelected(value);
|
|
1703
|
-
validation.commitValidation();
|
|
1704
|
-
}
|
|
1705
|
-
};
|
|
1706
|
-
let isInvalid = validation.displayValidation.isInvalid;
|
|
1707
|
-
return {
|
|
1708
|
-
...validation,
|
|
1709
|
-
name,
|
|
1710
|
-
selectedValue,
|
|
1711
|
-
setSelectedValue,
|
|
1712
|
-
lastFocusedValue,
|
|
1713
|
-
setLastFocusedValue,
|
|
1714
|
-
isDisabled: props.isDisabled || false,
|
|
1715
|
-
isReadOnly: props.isReadOnly || false,
|
|
1716
|
-
isRequired: props.isRequired || false,
|
|
1717
|
-
validationState: props.validationState || (isInvalid ? "invalid" : null),
|
|
1718
|
-
isInvalid
|
|
1719
|
-
};
|
|
1720
|
-
}
|
|
1721
1128
|
|
|
1722
1129
|
// src/components/SegmentedControl/index.tsx
|
|
1130
|
+
var import_react30 = require("react");
|
|
1131
|
+
var import_radio = require("@react-stately/radio");
|
|
1723
1132
|
var import_radio2 = require("@react-aria/radio");
|
|
1724
|
-
var import_styled_components20 = __toESM(require("styled-components"));
|
|
1725
1133
|
|
|
1726
1134
|
// src/components/SegmentedControl/RadioGroupContext.tsx
|
|
1727
|
-
var
|
|
1728
|
-
var
|
|
1729
|
-
var RadioContext = (0,
|
|
1135
|
+
var import_react29 = require("react");
|
|
1136
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
1137
|
+
var RadioContext = (0, import_react29.createContext)(null);
|
|
1730
1138
|
var RadioProvider = ({
|
|
1731
1139
|
value,
|
|
1732
1140
|
children
|
|
1733
1141
|
}) => {
|
|
1734
|
-
return /* @__PURE__ */ (0,
|
|
1142
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(RadioContext.Provider, { value, children });
|
|
1735
1143
|
};
|
|
1736
1144
|
var useRadioContext = () => {
|
|
1737
|
-
const state = (0,
|
|
1145
|
+
const state = (0, import_react29.useContext)(RadioContext);
|
|
1738
1146
|
if (state === null)
|
|
1739
1147
|
throw new Error("`<RadioProvider>` is not likely mounted.");
|
|
1740
1148
|
return state;
|
|
1741
1149
|
};
|
|
1742
1150
|
|
|
1743
1151
|
// src/components/SegmentedControl/index.tsx
|
|
1744
|
-
var
|
|
1745
|
-
var SegmentedControl = (0,
|
|
1746
|
-
const
|
|
1152
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
1153
|
+
var SegmentedControl = (0, import_react30.forwardRef)(function SegmentedControlInner(props, ref) {
|
|
1154
|
+
const className = useClassNames("charcoal-segmented-control", props.className);
|
|
1155
|
+
const ariaRadioGroupProps = (0, import_react30.useMemo)(() => ({
|
|
1747
1156
|
...props,
|
|
1748
1157
|
isDisabled: props.disabled,
|
|
1749
1158
|
isReadOnly: props.readonly,
|
|
1750
1159
|
isRequired: props.required,
|
|
1751
1160
|
"aria-label": props.name
|
|
1752
1161
|
}), [props]);
|
|
1753
|
-
const state =
|
|
1162
|
+
const state = (0, import_radio.useRadioGroupState)(ariaRadioGroupProps);
|
|
1754
1163
|
const {
|
|
1755
1164
|
radioGroupProps
|
|
1756
1165
|
} = (0, import_radio2.useRadioGroup)(ariaRadioGroupProps, state);
|
|
1757
|
-
const segmentedControlItems = (0,
|
|
1166
|
+
const segmentedControlItems = (0, import_react30.useMemo)(() => {
|
|
1758
1167
|
return props.data.map((d) => typeof d === "string" ? {
|
|
1759
1168
|
value: d,
|
|
1760
1169
|
label: d
|
|
1761
1170
|
} : d);
|
|
1762
1171
|
}, [props.data]);
|
|
1763
|
-
return /* @__PURE__ */ (0,
|
|
1172
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { ref, ...radioGroupProps, className, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(RadioProvider, { value: state, children: segmentedControlItems.map((item) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Segmented, { value: item.value, disabled: item.disabled, children: item.label }, item.value)) }) });
|
|
1764
1173
|
});
|
|
1765
|
-
var SegmentedControl_default = (0,
|
|
1174
|
+
var SegmentedControl_default = (0, import_react30.memo)(SegmentedControl);
|
|
1766
1175
|
var Segmented = (props) => {
|
|
1767
1176
|
const state = useRadioContext();
|
|
1768
|
-
const ref = (0,
|
|
1769
|
-
const ariaRadioProps = (0,
|
|
1177
|
+
const ref = (0, import_react30.useRef)(null);
|
|
1178
|
+
const ariaRadioProps = (0, import_react30.useMemo)(() => ({
|
|
1770
1179
|
value: props.value,
|
|
1771
1180
|
isDisabled: props.disabled,
|
|
1772
1181
|
children: props.children
|
|
@@ -1776,195 +1185,109 @@ var Segmented = (props) => {
|
|
|
1776
1185
|
isDisabled,
|
|
1777
1186
|
isSelected
|
|
1778
1187
|
} = (0, import_radio2.useRadio)(ariaRadioProps, state, ref);
|
|
1779
|
-
return /* @__PURE__ */ (0,
|
|
1780
|
-
/* @__PURE__ */ (0,
|
|
1781
|
-
|
|
1188
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("label", { className: "charcoal-segmented-control-radio__label", "aria-disabled": isDisabled || state.isReadOnly, "data-checked": isSelected, children: [
|
|
1189
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("input", { className: "charcoal-segmented-control-radio__input", ...inputProps, ref }),
|
|
1190
|
+
props.children
|
|
1782
1191
|
] });
|
|
1783
1192
|
};
|
|
1784
|
-
var SegmentedControlRoot = import_styled_components20.default.div.withConfig({
|
|
1785
|
-
componentId: "ccl__sc-1xmkkqt-0"
|
|
1786
|
-
})(["display:inline-flex;align-items:center;background-color:var(--charcoal-surface3);border-radius:16px;"]);
|
|
1787
|
-
var SegmentedRoot = import_styled_components20.default.label.withConfig({
|
|
1788
|
-
componentId: "ccl__sc-1xmkkqt-1"
|
|
1789
|
-
})(["position:relative;display:flex;align-items:center;cursor:pointer;height:32px;padding-right:16px;padding-left:16px;border-radius:16px;&:disabled,&[aria-disabled]:not([aria-disabled='false']){cursor:default;opacity:0.32;}color:var(--charcoal-text2);", ""], ({
|
|
1790
|
-
checked = false
|
|
1791
|
-
}) => checked && (0, import_styled_components20.css)(["background-color:var(--charcoal-brand);color:var(--charcoal-text5);"]));
|
|
1792
|
-
var SegmentedInput = import_styled_components20.default.input.withConfig({
|
|
1793
|
-
componentId: "ccl__sc-1xmkkqt-2"
|
|
1794
|
-
})(["position:absolute;height:0px;width:0px;padding:0;margin:0;appearance:none;box-sizing:border-box;overflow:hidden;white-space:nowrap;opacity:0;"]);
|
|
1795
|
-
var RadioLabel2 = import_styled_components20.default.div.withConfig({
|
|
1796
|
-
componentId: "ccl__sc-1xmkkqt-3"
|
|
1797
|
-
})(["background:transparent;display:flex;align-items:center;height:22px;"]);
|
|
1798
|
-
var SegmentedLabelInner = import_styled_components20.default.div.withConfig({
|
|
1799
|
-
componentId: "ccl__sc-1xmkkqt-4"
|
|
1800
|
-
})(["font-size:14px;line-height:22px;display:flow-root;&::before{display:block;width:0;height:0;content:'';margin-top:-4px;}&::after{display:block;width:0;height:0;content:'';margin-bottom:-4px;}"]);
|
|
1801
1193
|
|
|
1802
1194
|
// src/components/Checkbox/index.tsx
|
|
1803
|
-
var
|
|
1804
|
-
var
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
var
|
|
1808
|
-
var
|
|
1809
|
-
var
|
|
1810
|
-
|
|
1811
|
-
|
|
1195
|
+
var import_react33 = require("react");
|
|
1196
|
+
var import_utils6 = require("@react-aria/utils");
|
|
1197
|
+
|
|
1198
|
+
// src/components/Checkbox/CheckboxInput/index.tsx
|
|
1199
|
+
var import_react31 = require("react");
|
|
1200
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
1201
|
+
var CheckboxInput = (0, import_react31.forwardRef)(function CheckboxInput2({
|
|
1202
|
+
onChange,
|
|
1203
|
+
checked,
|
|
1204
|
+
invalid,
|
|
1205
|
+
className,
|
|
1206
|
+
rounded,
|
|
1812
1207
|
...props
|
|
1813
1208
|
}, ref) {
|
|
1814
|
-
const
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1209
|
+
const handleChange = (0, import_react31.useCallback)((e) => {
|
|
1210
|
+
const el = e.currentTarget;
|
|
1211
|
+
onChange?.(el.checked);
|
|
1212
|
+
}, [onChange]);
|
|
1213
|
+
const classNames = useClassNames("charcoal-checkbox-input", className);
|
|
1214
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("input", { className: classNames, ref, type: "checkbox", onChange: handleChange, "aria-invalid": invalid, checked, "data-rounded": rounded, ...props });
|
|
1215
|
+
});
|
|
1216
|
+
var CheckboxInput_default = (0, import_react31.memo)(CheckboxInput);
|
|
1217
|
+
|
|
1218
|
+
// src/components/Checkbox/CheckboxWithLabel.tsx
|
|
1219
|
+
var import_react32 = __toESM(require("react"));
|
|
1220
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
1221
|
+
var CheckboxWithLabel = import_react32.default.memo(function CheckboxWithLabel2({
|
|
1222
|
+
className,
|
|
1223
|
+
children,
|
|
1224
|
+
input,
|
|
1225
|
+
id,
|
|
1226
|
+
disabled
|
|
1227
|
+
}) {
|
|
1228
|
+
const classNames = useClassNames("charcoal-checkbox__label", className);
|
|
1229
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("label", { htmlFor: id, "aria-disabled": disabled, className: classNames, children: [
|
|
1230
|
+
input,
|
|
1231
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "charcoal-checkbox__label_div", children })
|
|
1835
1232
|
] });
|
|
1836
1233
|
});
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
var
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
}
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1234
|
+
|
|
1235
|
+
// src/components/Checkbox/index.tsx
|
|
1236
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
1237
|
+
var Checkbox = (0, import_react33.forwardRef)(function Checkbox2({
|
|
1238
|
+
disabled,
|
|
1239
|
+
className,
|
|
1240
|
+
id,
|
|
1241
|
+
children,
|
|
1242
|
+
...props
|
|
1243
|
+
}, ref) {
|
|
1244
|
+
const htmlId = (0, import_utils6.useId)(id);
|
|
1245
|
+
const noChildren = children === void 0;
|
|
1246
|
+
const input = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(CheckboxInput_default, { ...props, className: noChildren ? className : void 0, disabled, id: htmlId, ref });
|
|
1247
|
+
if (noChildren) {
|
|
1248
|
+
return input;
|
|
1249
|
+
}
|
|
1250
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(CheckboxWithLabel, { className, disabled, id: htmlId, input, children });
|
|
1251
|
+
});
|
|
1252
|
+
var Checkbox_default = (0, import_react33.memo)(Checkbox);
|
|
1856
1253
|
|
|
1857
1254
|
// src/components/TagItem/index.tsx
|
|
1858
|
-
var
|
|
1859
|
-
var
|
|
1860
|
-
var
|
|
1861
|
-
var
|
|
1862
|
-
|
|
1863
|
-
var import_styled9 = require("@charcoal-ui/styled");
|
|
1864
|
-
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
1865
|
-
var sizeMap = {
|
|
1866
|
-
S: 32,
|
|
1867
|
-
M: 40
|
|
1868
|
-
};
|
|
1869
|
-
var TagItem = (0, import_react30.forwardRef)(function TagItemInner({
|
|
1255
|
+
var import_react34 = require("react");
|
|
1256
|
+
var import_utils7 = require("@react-aria/utils");
|
|
1257
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
1258
|
+
var TagItem = (0, import_react34.forwardRef)(function TagItemInner({
|
|
1259
|
+
component,
|
|
1870
1260
|
label,
|
|
1871
1261
|
translatedLabel,
|
|
1872
1262
|
bgColor = "#7ACCB1",
|
|
1873
1263
|
bgImage,
|
|
1874
1264
|
size = "M",
|
|
1875
|
-
disabled,
|
|
1876
1265
|
status = "default",
|
|
1877
|
-
className,
|
|
1878
1266
|
...props
|
|
1879
1267
|
}, _ref) {
|
|
1880
|
-
const ref = (0,
|
|
1881
|
-
const ariaButtonProps = (0, import_react30.useMemo)(() => ({
|
|
1882
|
-
elementType: "a",
|
|
1883
|
-
isDisabled: disabled,
|
|
1884
|
-
...props
|
|
1885
|
-
}), [disabled, props]);
|
|
1886
|
-
const {
|
|
1887
|
-
buttonProps
|
|
1888
|
-
} = (0, import_button.useButton)(ariaButtonProps, ref);
|
|
1268
|
+
const ref = (0, import_utils7.useObjectRef)(_ref);
|
|
1889
1269
|
const hasTranslatedLabel = translatedLabel !== void 0 && translatedLabel.length > 0;
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1270
|
+
const className = useClassNames("charcoal-tag-item", "charcoal-tag-item__bg", props.className);
|
|
1271
|
+
const bgVariant = bgImage !== void 0 && bgImage.length > 0 ? "image" : "color";
|
|
1272
|
+
const bg = bgVariant === "color" ? bgColor : `url(${bgImage ?? ""})`;
|
|
1273
|
+
const Component = (0, import_react34.useMemo)(() => component ?? "button", [component]);
|
|
1274
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(Component, { ...props, ref, className, "data-state": status, "data-bg-variant": bgVariant, "data-size": hasTranslatedLabel ? "M" : size, style: {
|
|
1275
|
+
"--charcoal-tag-item-bg": bg
|
|
1276
|
+
}, children: [
|
|
1277
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "charcoal-tag-item__label", "data-has-translate": hasTranslatedLabel, children: [
|
|
1278
|
+
hasTranslatedLabel && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: "charcoal-tag-item__label__translated", children: translatedLabel }),
|
|
1279
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: "charcoal-tag-item__label__text", "data-has-translate": hasTranslatedLabel, children: label })
|
|
1280
|
+
] }),
|
|
1281
|
+
status === "active" && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Icon_default, { name: "16/Remove" })
|
|
1899
1282
|
] });
|
|
1900
1283
|
});
|
|
1901
|
-
var TagItem_default = (0,
|
|
1902
|
-
var horizontalPadding = ({
|
|
1903
|
-
left,
|
|
1904
|
-
right
|
|
1905
|
-
}) => (0, import_styled_components22.css)(["padding-right:", ";padding-left:", ";"], (0, import_utils14.px)(right), (0, import_utils14.px)(left));
|
|
1906
|
-
var tagItemRootSize = (size) => {
|
|
1907
|
-
switch (size) {
|
|
1908
|
-
case "M":
|
|
1909
|
-
return horizontalPadding({
|
|
1910
|
-
left: 24,
|
|
1911
|
-
right: 24
|
|
1912
|
-
});
|
|
1913
|
-
case "S":
|
|
1914
|
-
return horizontalPadding({
|
|
1915
|
-
left: 16,
|
|
1916
|
-
right: 16
|
|
1917
|
-
});
|
|
1918
|
-
}
|
|
1919
|
-
};
|
|
1920
|
-
var activeTagItemRoot = horizontalPadding({
|
|
1921
|
-
left: 16,
|
|
1922
|
-
right: 8
|
|
1923
|
-
});
|
|
1924
|
-
var TagItemRoot = import_styled_components22.default.a.withConfig({
|
|
1925
|
-
componentId: "ccl__sc-11j9pu2-0"
|
|
1926
|
-
})(["isolation:isolate;position:relative;height:", "px;display:inline-flex;align-items:center;justify-content:center;text-decoration:none;cursor:pointer;overflow:hidden;border-radius:4px;", " ", " color:", ";transition:0.2s box-shadow;&:not(:disabled):not([aria-disabled]),&[aria-disabled='false']{", "}&:disabled,&[aria-disabled]:not([aria-disabled='false']){opacity:0.32;cursor:default;}"], ({
|
|
1927
|
-
size
|
|
1928
|
-
}) => sizeMap[size], ({
|
|
1929
|
-
size,
|
|
1930
|
-
status
|
|
1931
|
-
}) => status !== "active" && tagItemRootSize(size), ({
|
|
1932
|
-
status
|
|
1933
|
-
}) => status === "active" && activeTagItemRoot, ({
|
|
1934
|
-
status
|
|
1935
|
-
}) => status === "inactive" ? "var(--charcoal-text2)" : "var(--charcoal-text5)", import_styled9.focusVisibleFocusRingCss);
|
|
1936
|
-
var Background = import_styled_components22.default.div.withConfig({
|
|
1937
|
-
componentId: "ccl__sc-11j9pu2-1"
|
|
1938
|
-
})(["position:absolute;z-index:1;top:0;left:0;width:100%;height:100%;background-color:", ";", " ", ""], ({
|
|
1939
|
-
bgColor
|
|
1940
|
-
}) => bgColor, ({
|
|
1941
|
-
status
|
|
1942
|
-
}) => status === "inactive" && (0, import_styled_components22.css)(["background-color:var(--charcoal-surface3);"]), ({
|
|
1943
|
-
bgImage
|
|
1944
|
-
}) => bgImage !== void 0 && (0, import_styled_components22.css)(["background-color:var(--charcoal-surface4);&::before{content:'';position:absolute;top:0;left:0;width:100%;height:100%;background-position:center;background-size:cover;background-image:url(", ");mix-blend-mode:overlay;}"], bgImage));
|
|
1945
|
-
var Inner = import_styled_components22.default.div.withConfig({
|
|
1946
|
-
componentId: "ccl__sc-11j9pu2-2"
|
|
1947
|
-
})(["display:inline-flex;gap:8px;align-items:center;z-index:2;"]);
|
|
1948
|
-
var labelCSS = (0, import_styled_components22.css)(["font-size:14px;line-height:22px;font-weight:bold;display:flow-root;&::before{display:block;width:0;height:0;content:'';margin-top:-4px;}&::after{display:block;width:0;height:0;content:'';margin-bottom:-4px;}"]);
|
|
1949
|
-
var translateLabelCSS = (0, import_styled_components22.css)(["display:flex;align-items:center;flex-direction:column;font-size:10px;"]);
|
|
1950
|
-
var LabelWrapper = import_styled_components22.default.div.withConfig({
|
|
1951
|
-
componentId: "ccl__sc-11j9pu2-3"
|
|
1952
|
-
})(["", ""], ({
|
|
1953
|
-
isTranslate
|
|
1954
|
-
}) => isTranslate ?? false ? translateLabelCSS : labelCSS);
|
|
1955
|
-
var Label3 = import_styled_components22.default.span.withConfig({
|
|
1956
|
-
componentId: "ccl__sc-11j9pu2-4"
|
|
1957
|
-
})(["max-width:152px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:inherit;color:inherit;line-height:inherit;"]);
|
|
1958
|
-
var TranslatedLabel = import_styled_components22.default.div.withConfig({
|
|
1959
|
-
componentId: "ccl__sc-11j9pu2-5"
|
|
1960
|
-
})(["font-size:12px;line-height:20px;font-weight:bold;display:flow-root;&::before{display:block;width:0;height:0;content:'';margin-top:-4px;}&::after{display:block;width:0;height:0;content:'';margin-bottom:-4px;}"]);
|
|
1284
|
+
var TagItem_default = (0, import_react34.memo)(TagItem);
|
|
1961
1285
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1962
1286
|
0 && (module.exports = {
|
|
1963
1287
|
Button,
|
|
1964
1288
|
CharcoalProvider,
|
|
1965
1289
|
Checkbox,
|
|
1966
1290
|
Clickable,
|
|
1967
|
-
ComponentAbstraction,
|
|
1968
1291
|
DropdownMenuItem,
|
|
1969
1292
|
DropdownSelector,
|
|
1970
1293
|
Icon,
|
|
@@ -1976,9 +1299,8 @@ var TranslatedLabel = import_styled_components22.default.div.withConfig({
|
|
|
1976
1299
|
ModalAlign,
|
|
1977
1300
|
ModalBody,
|
|
1978
1301
|
ModalButtons,
|
|
1302
|
+
ModalCloseButton,
|
|
1979
1303
|
ModalHeader,
|
|
1980
|
-
MultiSelect,
|
|
1981
|
-
MultiSelectGroup,
|
|
1982
1304
|
OverlayProvider,
|
|
1983
1305
|
Radio,
|
|
1984
1306
|
RadioGroup,
|
|
@@ -1987,7 +1309,6 @@ var TranslatedLabel = import_styled_components22.default.div.withConfig({
|
|
|
1987
1309
|
Switch,
|
|
1988
1310
|
TagItem,
|
|
1989
1311
|
TextArea,
|
|
1990
|
-
TextField
|
|
1991
|
-
useComponentAbstraction
|
|
1312
|
+
TextField
|
|
1992
1313
|
});
|
|
1993
1314
|
//# sourceMappingURL=index.cjs.js.map
|