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