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