@entur/form 8.3.2-beta.9 → 8.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BaseFormControl.d.ts +3 -4
- package/dist/Checkbox.d.ts +1 -2
- package/dist/FeedbackText.d.ts +2 -3
- package/dist/Fieldset.d.ts +1 -2
- package/dist/InputGroupLabel.d.ts +1 -2
- package/dist/Radio.d.ts +1 -2
- package/dist/RadioGroup.d.ts +1 -1
- package/dist/RadioGroupContext.d.ts +1 -1
- package/dist/Switch.d.ts +1 -2
- package/dist/TextArea.d.ts +3 -4
- package/dist/TextField.d.ts +4 -5
- package/dist/VariantProvider.d.ts +2 -2
- package/dist/form.cjs.js +1054 -0
- package/dist/form.cjs.js.map +1 -0
- package/dist/form.esm.js +996 -942
- package/dist/form.esm.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/inputPanel/CheckboxPanel.d.ts +1 -1
- package/dist/inputPanel/InputPanelBase.d.ts +1 -2
- package/dist/inputPanel/RadioPanel.d.ts +1 -1
- package/dist/segmented-control/MultipleSegmentedControl.d.ts +1 -2
- package/dist/segmented-control/SegmentedChoice.d.ts +1 -2
- package/dist/segmented-control/SegmentedContext.d.ts +1 -1
- package/dist/segmented-control/SegmentedControl.d.ts +1 -2
- package/dist/styles.css +1406 -1473
- package/package.json +26 -16
- package/dist/form.cjs.development.js +0 -1026
- package/dist/form.cjs.development.js.map +0 -1
- package/dist/form.cjs.production.min.js +0 -2
- package/dist/form.cjs.production.min.js.map +0 -1
- package/dist/index.js +0 -8
package/dist/form.esm.js
CHANGED
|
@@ -1,984 +1,1038 @@
|
|
|
1
|
-
import { mergeRefs, useRandomId, useForceUpdate, useOnMount, warnAboutMissingStyles } from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
16
|
-
}
|
|
17
|
-
return n;
|
|
18
|
-
}, _extends.apply(null, arguments);
|
|
19
|
-
}
|
|
20
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
21
|
-
if (null == r) return {};
|
|
22
|
-
var t = {};
|
|
23
|
-
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
24
|
-
if (-1 !== e.indexOf(n)) continue;
|
|
25
|
-
t[n] = r[n];
|
|
26
|
-
}
|
|
27
|
-
return t;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
var _excluded$g = ["children", "hideIcon", "variant", "className"];
|
|
31
|
-
/** @deprecated use variant="information" instead */
|
|
32
|
-
var info = 'info';
|
|
33
|
-
/** @deprecated use variant="negative" instead */
|
|
34
|
-
var error$1 = 'error';
|
|
35
|
-
var AlertIcon = function AlertIcon(_ref) {
|
|
36
|
-
var variant = _ref.variant;
|
|
37
|
-
var iconClass = "eds-feedback-text__icon eds-feedback-text__icon--" + variant;
|
|
1
|
+
import { mergeRefs, useRandomId, useForceUpdate, useOnMount, warnAboutMissingStyles } from "@entur/utils";
|
|
2
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import React__default, { useRef } from "react";
|
|
5
|
+
import classNames from "classnames";
|
|
6
|
+
import { ValidationErrorFilledIcon, ValidationExclamationFilledIcon, ValidationSuccessFilledIcon, QuestionIcon, CheckIcon, CloseSmallIcon } from "@entur/icons";
|
|
7
|
+
import { Tooltip } from "@entur/tooltip";
|
|
8
|
+
import { IconButton } from "@entur/button";
|
|
9
|
+
import { SubLabel, Paragraph, Heading5, Label } from "@entur/typography";
|
|
10
|
+
import { colors } from "@entur/tokens";
|
|
11
|
+
const info = "info";
|
|
12
|
+
const error$1 = "error";
|
|
13
|
+
const AlertIcon = ({ variant }) => {
|
|
14
|
+
const iconClass = `eds-feedback-text__icon eds-feedback-text__icon--${variant}`;
|
|
38
15
|
switch (variant) {
|
|
39
|
-
case
|
|
40
|
-
return
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
16
|
+
case "success":
|
|
17
|
+
return /* @__PURE__ */ jsx(
|
|
18
|
+
ValidationSuccessFilledIcon,
|
|
19
|
+
{
|
|
20
|
+
"aria-label": "Suksessmelding",
|
|
21
|
+
className: iconClass
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
case "negative":
|
|
25
|
+
return /* @__PURE__ */ jsx(
|
|
26
|
+
ValidationErrorFilledIcon,
|
|
27
|
+
{
|
|
28
|
+
"aria-label": "Feilmelding",
|
|
29
|
+
className: iconClass
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
case "information":
|
|
50
33
|
return null;
|
|
51
|
-
case
|
|
52
|
-
return
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
34
|
+
case "warning":
|
|
35
|
+
return /* @__PURE__ */ jsx(
|
|
36
|
+
ValidationExclamationFilledIcon,
|
|
37
|
+
{
|
|
38
|
+
"aria-label": "Varselmelding",
|
|
39
|
+
className: iconClass
|
|
40
|
+
}
|
|
41
|
+
);
|
|
56
42
|
case error$1:
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
43
|
+
return /* @__PURE__ */ jsx(
|
|
44
|
+
ValidationErrorFilledIcon,
|
|
45
|
+
{
|
|
46
|
+
"aria-label": "Feilmelding",
|
|
47
|
+
className: iconClass
|
|
48
|
+
}
|
|
49
|
+
);
|
|
61
50
|
case info:
|
|
62
51
|
return null;
|
|
63
52
|
default:
|
|
64
53
|
return null;
|
|
65
54
|
}
|
|
66
55
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
56
|
+
const FeedbackText = ({
|
|
57
|
+
children,
|
|
58
|
+
hideIcon = false,
|
|
59
|
+
variant,
|
|
60
|
+
className,
|
|
61
|
+
...rest
|
|
62
|
+
}) => {
|
|
63
|
+
return /* @__PURE__ */ jsxs(
|
|
64
|
+
SubLabel,
|
|
65
|
+
{
|
|
66
|
+
className: classNames(
|
|
67
|
+
"eds-feedback-text",
|
|
68
|
+
{
|
|
69
|
+
"eds-feedback-text--information": variant === info || variant === "information"
|
|
70
|
+
},
|
|
71
|
+
className
|
|
72
|
+
),
|
|
73
|
+
...rest,
|
|
74
|
+
children: [
|
|
75
|
+
!hideIcon && /* @__PURE__ */ jsx(AlertIcon, { variant }),
|
|
76
|
+
/* @__PURE__ */ jsx("span", { className: "eds-feedback-text__text", children })
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
);
|
|
83
80
|
};
|
|
84
|
-
|
|
85
|
-
var InputGroupContext = /*#__PURE__*/React.createContext({
|
|
81
|
+
const InputGroupContext = React.createContext({
|
|
86
82
|
isFilled: false,
|
|
87
|
-
setFilled:
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
83
|
+
setFilled: () => null
|
|
90
84
|
});
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
isFilled: filled,
|
|
99
|
-
setFilled: setFilled
|
|
85
|
+
const InputGroupContextProvider = ({ children }) => {
|
|
86
|
+
const [filled, setFilled] = React.useState(false);
|
|
87
|
+
return /* @__PURE__ */ jsx(
|
|
88
|
+
InputGroupContext.Provider,
|
|
89
|
+
{
|
|
90
|
+
value: { isFilled: filled, setFilled },
|
|
91
|
+
children
|
|
100
92
|
}
|
|
101
|
-
|
|
93
|
+
);
|
|
102
94
|
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
95
|
+
const useInputGroupContext = () => React.useContext(InputGroupContext);
|
|
96
|
+
const InputGroupLabel = ({
|
|
97
|
+
label,
|
|
98
|
+
required,
|
|
99
|
+
labelId,
|
|
100
|
+
staticAnimation = false,
|
|
101
|
+
...rest
|
|
102
|
+
}) => {
|
|
103
|
+
const { isFilled: isFilled2 } = useInputGroupContext();
|
|
104
|
+
const filler = staticAnimation || isFilled2;
|
|
105
|
+
return /* @__PURE__ */ jsx(
|
|
106
|
+
"label",
|
|
107
|
+
{
|
|
108
|
+
className: classNames(rest.className, {
|
|
109
|
+
"eds-input-group-label-wrapper--filled": filler
|
|
110
|
+
}),
|
|
111
|
+
id: labelId,
|
|
112
|
+
...rest,
|
|
113
|
+
children: /* @__PURE__ */ jsxs(
|
|
114
|
+
"span",
|
|
115
|
+
{
|
|
116
|
+
className: classNames("eds-input-group__label", {
|
|
117
|
+
"eds-input-group__label--filled": filler
|
|
118
|
+
}),
|
|
119
|
+
children: [
|
|
120
|
+
label,
|
|
121
|
+
" ",
|
|
122
|
+
required && /* @__PURE__ */ jsx("span", { children: "*" })
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
128
|
};
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return React__default.createElement(VariantContext.Provider, {
|
|
136
|
-
value: variant
|
|
137
|
-
}, children);
|
|
129
|
+
const VariantContext = React__default.createContext(null);
|
|
130
|
+
const VariantProvider = ({
|
|
131
|
+
children,
|
|
132
|
+
variant = null
|
|
133
|
+
}) => {
|
|
134
|
+
return /* @__PURE__ */ jsx(VariantContext.Provider, { value: variant, children });
|
|
138
135
|
};
|
|
139
|
-
|
|
140
|
-
|
|
136
|
+
const useVariant = () => {
|
|
137
|
+
const context = React__default.useContext(VariantContext);
|
|
141
138
|
return context;
|
|
142
139
|
};
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
type: "checkbox",
|
|
261
|
-
ref: mergeRefs(ref, inputRef),
|
|
262
|
-
checked: isControlled ? checked === true : undefined,
|
|
263
|
-
disabled: disabled,
|
|
264
|
-
onKeyDown: function onKeyDown(e) {
|
|
265
|
-
if (readOnly && (e.key === ' ' || e.key === 'Enter')) {
|
|
266
|
-
e.preventDefault();
|
|
267
|
-
e.stopPropagation();
|
|
140
|
+
const error = "error";
|
|
141
|
+
const BaseFormControl = React__default.forwardRef(
|
|
142
|
+
({
|
|
143
|
+
after,
|
|
144
|
+
before,
|
|
145
|
+
children,
|
|
146
|
+
className,
|
|
147
|
+
disabled = false,
|
|
148
|
+
readOnly = false,
|
|
149
|
+
variant,
|
|
150
|
+
prepend,
|
|
151
|
+
append,
|
|
152
|
+
size = "medium",
|
|
153
|
+
isFilled: isFilled2,
|
|
154
|
+
label,
|
|
155
|
+
required,
|
|
156
|
+
labelTooltip,
|
|
157
|
+
labelTooltipButtonAriaLabel = `Klikk for tilleggsinfo om ${label}-feltet`,
|
|
158
|
+
labelTooltipPlacement = "top",
|
|
159
|
+
feedback,
|
|
160
|
+
labelId,
|
|
161
|
+
labelProps,
|
|
162
|
+
style,
|
|
163
|
+
disableLabelAnimation = false,
|
|
164
|
+
ariaAlertOnFeedback = false,
|
|
165
|
+
ariaLabelOnReadOnly = "Dette skjemafeltet kan bare leses",
|
|
166
|
+
...rest
|
|
167
|
+
}, ref) => {
|
|
168
|
+
const contextVariant = useVariant();
|
|
169
|
+
const currentVariant = variant || contextVariant;
|
|
170
|
+
return /* @__PURE__ */ jsx(InputGroupContextProvider, { children: /* @__PURE__ */ jsxs(
|
|
171
|
+
"div",
|
|
172
|
+
{
|
|
173
|
+
className: classNames(
|
|
174
|
+
"eds-form-control__field-and-feedback-text",
|
|
175
|
+
className,
|
|
176
|
+
{
|
|
177
|
+
"eds-form-control__field-and-feedback-text--has-tooltip": labelTooltip !== void 0
|
|
178
|
+
}
|
|
179
|
+
),
|
|
180
|
+
style,
|
|
181
|
+
children: [
|
|
182
|
+
before,
|
|
183
|
+
/* @__PURE__ */ jsxs(
|
|
184
|
+
"div",
|
|
185
|
+
{
|
|
186
|
+
className: classNames(
|
|
187
|
+
"eds-form-control-wrapper",
|
|
188
|
+
`eds-form-control-wrapper--size-${size}`,
|
|
189
|
+
{
|
|
190
|
+
"eds-form-control-wrapper--success": currentVariant === "success",
|
|
191
|
+
"eds-form-control-wrapper--negative": currentVariant === "negative" || currentVariant === error,
|
|
192
|
+
"eds-form-control-wrapper--disabled": disabled,
|
|
193
|
+
"eds-form-control-wrapper--readonly": readOnly,
|
|
194
|
+
"eds-form-control-wrapper--is-filled": isFilled2
|
|
195
|
+
}
|
|
196
|
+
),
|
|
197
|
+
ref,
|
|
198
|
+
tabIndex: readOnly ? -1 : void 0,
|
|
199
|
+
...rest,
|
|
200
|
+
children: [
|
|
201
|
+
prepend && /* @__PURE__ */ jsx("div", { className: "eds-form-control__prepend", children: prepend }),
|
|
202
|
+
/* @__PURE__ */ jsx(
|
|
203
|
+
InputGroupLabel,
|
|
204
|
+
{
|
|
205
|
+
label,
|
|
206
|
+
required,
|
|
207
|
+
labelId,
|
|
208
|
+
staticAnimation: disableLabelAnimation,
|
|
209
|
+
"aria-label": readOnly ? `${label}, ${ariaLabelOnReadOnly}` : void 0,
|
|
210
|
+
...labelProps
|
|
211
|
+
}
|
|
212
|
+
),
|
|
213
|
+
labelTooltip && /* @__PURE__ */ jsx(
|
|
214
|
+
Tooltip,
|
|
215
|
+
{
|
|
216
|
+
content: labelTooltip,
|
|
217
|
+
placement: labelTooltipPlacement,
|
|
218
|
+
showCloseButton: false,
|
|
219
|
+
disableFocusListener: true,
|
|
220
|
+
disableHoverListener: true,
|
|
221
|
+
disableClickListner: false,
|
|
222
|
+
disableKeyboardListener: false,
|
|
223
|
+
children: /* @__PURE__ */ jsx(
|
|
224
|
+
IconButton,
|
|
225
|
+
{
|
|
226
|
+
as: "span",
|
|
227
|
+
tabIndex: 0,
|
|
228
|
+
role: "button",
|
|
229
|
+
className: "eds-form-control__append eds-form-control__append--tooltip",
|
|
230
|
+
"aria-label": labelTooltipButtonAriaLabel,
|
|
231
|
+
children: /* @__PURE__ */ jsx(
|
|
232
|
+
QuestionIcon,
|
|
233
|
+
{
|
|
234
|
+
className: "eds-input-group__label-tooltip-icon",
|
|
235
|
+
"aria-hidden": "true"
|
|
236
|
+
}
|
|
237
|
+
)
|
|
238
|
+
}
|
|
239
|
+
)
|
|
240
|
+
}
|
|
241
|
+
),
|
|
242
|
+
children,
|
|
243
|
+
append && /* @__PURE__ */ jsx("div", { className: "eds-form-control__append", children: append })
|
|
244
|
+
]
|
|
245
|
+
}
|
|
246
|
+
),
|
|
247
|
+
feedback && currentVariant && /* @__PURE__ */ jsx(
|
|
248
|
+
FeedbackText,
|
|
249
|
+
{
|
|
250
|
+
variant: currentVariant,
|
|
251
|
+
role: ariaAlertOnFeedback ? "alert" : void 0,
|
|
252
|
+
children: feedback
|
|
253
|
+
}
|
|
254
|
+
),
|
|
255
|
+
after
|
|
256
|
+
]
|
|
268
257
|
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
258
|
+
) });
|
|
259
|
+
}
|
|
260
|
+
);
|
|
261
|
+
const Checkbox = React__default.forwardRef(
|
|
262
|
+
({
|
|
263
|
+
checked,
|
|
264
|
+
className,
|
|
265
|
+
children,
|
|
266
|
+
style,
|
|
267
|
+
disabled = false,
|
|
268
|
+
readOnly = false,
|
|
269
|
+
reduceClickArea,
|
|
270
|
+
disableAnimation = false,
|
|
271
|
+
...rest
|
|
272
|
+
}, ref) => {
|
|
273
|
+
const inputRef = React__default.useRef(null);
|
|
274
|
+
const isIndeterminate = checked === "indeterminate";
|
|
275
|
+
const isControlled = checked !== void 0;
|
|
276
|
+
React__default.useEffect(() => {
|
|
277
|
+
if (inputRef && inputRef.current) {
|
|
278
|
+
inputRef.current.indeterminate = isIndeterminate;
|
|
279
|
+
}
|
|
280
|
+
}, [isIndeterminate]);
|
|
281
|
+
return /* @__PURE__ */ jsxs(
|
|
282
|
+
"label",
|
|
283
|
+
{
|
|
284
|
+
className: classNames("eds-checkbox__container", className, {
|
|
285
|
+
"eds-checkbox--disabled": disabled,
|
|
286
|
+
"eds-checkbox--readonly": readOnly,
|
|
287
|
+
"eds-checkbox__container--reduced-click-area": reduceClickArea
|
|
288
|
+
}),
|
|
289
|
+
style,
|
|
290
|
+
children: [
|
|
291
|
+
/* @__PURE__ */ jsx(
|
|
292
|
+
"input",
|
|
293
|
+
{
|
|
294
|
+
type: "checkbox",
|
|
295
|
+
ref: mergeRefs(ref, inputRef),
|
|
296
|
+
checked: isControlled ? checked === true : void 0,
|
|
297
|
+
disabled,
|
|
298
|
+
onKeyDown: (e) => {
|
|
299
|
+
if (readOnly && (e.key === " " || e.key === "Enter")) {
|
|
300
|
+
e.preventDefault();
|
|
301
|
+
e.stopPropagation();
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
"aria-label": readOnly ? ` ${children?.toString()}. Kan ikke endres` : void 0,
|
|
305
|
+
...rest
|
|
306
|
+
}
|
|
307
|
+
),
|
|
308
|
+
/* @__PURE__ */ jsx(
|
|
309
|
+
"span",
|
|
310
|
+
{
|
|
311
|
+
className: classNames("eds-checkbox__icon", {
|
|
312
|
+
"eds-checkbox__icon--disabled": disabled,
|
|
313
|
+
"eds-checkbox__icon--readonly": readOnly,
|
|
314
|
+
"eds-checkbox__icon--reduced-click-area": reduceClickArea,
|
|
315
|
+
"eds-checkbox__icon--no-animation": disableAnimation || disabled || readOnly
|
|
316
|
+
}),
|
|
317
|
+
children: /* @__PURE__ */ jsx(CheckboxIcon, { indeterminate: isIndeterminate })
|
|
318
|
+
}
|
|
319
|
+
),
|
|
320
|
+
children && /* @__PURE__ */ jsx(Paragraph, { className: "eds-checkbox__label", margin: "none", as: "span", children })
|
|
321
|
+
]
|
|
322
|
+
}
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
);
|
|
326
|
+
const CheckboxIcon = ({
|
|
327
|
+
indeterminate = false
|
|
328
|
+
}) => {
|
|
329
|
+
return /* @__PURE__ */ jsx(
|
|
330
|
+
"svg",
|
|
331
|
+
{
|
|
332
|
+
className: "eds-checkbox-icon",
|
|
333
|
+
width: "11px",
|
|
334
|
+
height: "9px",
|
|
335
|
+
viewBox: "6 11 37 33",
|
|
336
|
+
"aria-hidden": true,
|
|
337
|
+
children: indeterminate ? /* @__PURE__ */ jsx("rect", { x: "10", y: "25", width: "28", height: "5", fill: "white" }) : /* @__PURE__ */ jsx("path", { d: "M14.1 27.2l7.1 7.2 14.6-14.8", fill: "none" })
|
|
338
|
+
}
|
|
339
|
+
);
|
|
318
340
|
};
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
341
|
+
const Fieldset = ({
|
|
342
|
+
children,
|
|
343
|
+
className,
|
|
344
|
+
label,
|
|
345
|
+
...rest
|
|
346
|
+
}) => /* @__PURE__ */ jsxs("fieldset", { className: classNames("eds-fieldset", className), ...rest, children: [
|
|
347
|
+
label && /* @__PURE__ */ jsx(Heading5, { as: "legend", children: label }),
|
|
348
|
+
children
|
|
349
|
+
] });
|
|
350
|
+
const RadioGroupContext = React__default.createContext(
|
|
351
|
+
null
|
|
352
|
+
);
|
|
353
|
+
const RadioGroupContextProvider = RadioGroupContext.Provider;
|
|
354
|
+
const useRadioGroupContext = () => {
|
|
355
|
+
const context = React__default.useContext(RadioGroupContext);
|
|
324
356
|
if (!context) {
|
|
325
|
-
throw new Error(
|
|
357
|
+
throw new Error(
|
|
358
|
+
"You need to wrap your RadioButtons in a RadioGroup component"
|
|
359
|
+
);
|
|
326
360
|
}
|
|
327
361
|
return context;
|
|
328
362
|
};
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
363
|
+
const Radio = React__default.forwardRef(
|
|
364
|
+
({ className, children, value, disabled, readOnlyLabelDescription, ...rest }, ref) => {
|
|
365
|
+
const {
|
|
366
|
+
name,
|
|
367
|
+
value: selectedValue,
|
|
368
|
+
onChange,
|
|
369
|
+
readOnly
|
|
370
|
+
} = useRadioGroupContext();
|
|
371
|
+
const classList = classNames(className, "eds-form-component--radio__radio", {
|
|
372
|
+
"eds-form-component--radio__radio--disabled": disabled,
|
|
373
|
+
"eds-form-component--radio__radio--readonly": readOnly
|
|
374
|
+
});
|
|
375
|
+
return /* @__PURE__ */ jsxs("label", { className: "eds-form-component--radio__container", children: [
|
|
376
|
+
/* @__PURE__ */ jsx(
|
|
377
|
+
"input",
|
|
378
|
+
{
|
|
379
|
+
type: "radio",
|
|
380
|
+
name: rest.name ?? name,
|
|
381
|
+
ref,
|
|
382
|
+
value,
|
|
383
|
+
checked: rest.checked ?? selectedValue === value,
|
|
384
|
+
onChange: (e) => {
|
|
385
|
+
if (readOnly) {
|
|
386
|
+
e.preventDefault();
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
(rest.onChange ?? onChange)?.(e);
|
|
390
|
+
},
|
|
391
|
+
onClick: (e) => {
|
|
392
|
+
if (readOnly) {
|
|
393
|
+
e.preventDefault();
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
disabled,
|
|
397
|
+
"aria-label": readOnly ? `${children?.toString()}. ${readOnlyLabelDescription ?? "Kan ikke endres"}` : void 0,
|
|
398
|
+
...rest
|
|
399
|
+
}
|
|
400
|
+
),
|
|
401
|
+
/* @__PURE__ */ jsx("span", { className: classList, children: /* @__PURE__ */ jsx("span", { className: "eds-form-component--radio__circle" }) }),
|
|
402
|
+
children && /* @__PURE__ */ jsx(
|
|
403
|
+
Paragraph,
|
|
404
|
+
{
|
|
405
|
+
margin: "none",
|
|
406
|
+
as: "span",
|
|
407
|
+
className: "eds-form-component--radio__label",
|
|
408
|
+
children
|
|
409
|
+
}
|
|
410
|
+
)
|
|
411
|
+
] });
|
|
412
|
+
}
|
|
413
|
+
);
|
|
414
|
+
const InputPanelBase = React__default.forwardRef(
|
|
415
|
+
({
|
|
416
|
+
className,
|
|
417
|
+
children,
|
|
418
|
+
value,
|
|
419
|
+
title,
|
|
420
|
+
secondaryLabel,
|
|
421
|
+
size = "medium",
|
|
422
|
+
hideSelectionIndicator = false,
|
|
423
|
+
style,
|
|
424
|
+
id,
|
|
425
|
+
disabled = false,
|
|
426
|
+
type = "radio",
|
|
427
|
+
onChange,
|
|
428
|
+
checked,
|
|
429
|
+
name,
|
|
430
|
+
...rest
|
|
431
|
+
}, ref) => {
|
|
432
|
+
const classList = classNames(
|
|
433
|
+
className,
|
|
434
|
+
"eds-input-panel__container",
|
|
435
|
+
`eds-input-panel--${size}`
|
|
436
|
+
);
|
|
437
|
+
const inputRef = useRef(null);
|
|
438
|
+
const defaultId = useRandomId("eds-inputpanel");
|
|
439
|
+
const inputPanelId = id || defaultId;
|
|
440
|
+
const forceUpdate = useForceUpdate();
|
|
441
|
+
const handleOnChange = (e) => {
|
|
442
|
+
if (onChange === void 0) forceUpdate();
|
|
443
|
+
onChange?.(e);
|
|
444
|
+
};
|
|
445
|
+
return /* @__PURE__ */ jsxs("label", { className: "eds-input-panel", htmlFor: inputPanelId, children: [
|
|
446
|
+
/* @__PURE__ */ jsx(
|
|
447
|
+
"input",
|
|
448
|
+
{
|
|
449
|
+
type,
|
|
450
|
+
name,
|
|
451
|
+
ref: mergeRefs(ref, inputRef),
|
|
452
|
+
value,
|
|
453
|
+
checked,
|
|
454
|
+
onChange: handleOnChange,
|
|
455
|
+
id: inputPanelId,
|
|
456
|
+
disabled,
|
|
457
|
+
...rest
|
|
458
|
+
}
|
|
459
|
+
),
|
|
460
|
+
/* @__PURE__ */ jsxs("div", { className: classList, style, children: [
|
|
461
|
+
/* @__PURE__ */ jsxs("div", { className: "eds-input-panel__title-wrapper", children: [
|
|
462
|
+
/* @__PURE__ */ jsx("div", { className: "eds-input-panel__title", children: title }),
|
|
463
|
+
/* @__PURE__ */ jsxs("div", { className: "eds-input-panel__secondary-label-and-icon-wrapper", children: [
|
|
464
|
+
secondaryLabel !== void 0 && /* @__PURE__ */ jsx(Fragment, { children: secondaryLabel }),
|
|
465
|
+
/* @__PURE__ */ jsx("span", { style: { pointerEvents: "none" }, children: !(disabled || hideSelectionIndicator) && (type === "radio" ? /* @__PURE__ */ jsx(
|
|
466
|
+
Radio,
|
|
467
|
+
{
|
|
468
|
+
name: "",
|
|
469
|
+
value: "",
|
|
470
|
+
checked: checked ?? inputRef.current?.checked ?? false,
|
|
471
|
+
onChange: () => {
|
|
472
|
+
return;
|
|
473
|
+
},
|
|
474
|
+
"aria-hidden": "true",
|
|
475
|
+
tabIndex: -1
|
|
476
|
+
}
|
|
477
|
+
) : /* @__PURE__ */ jsx(
|
|
478
|
+
Checkbox,
|
|
479
|
+
{
|
|
480
|
+
checked: checked ?? inputRef.current?.checked ?? false,
|
|
481
|
+
onChange: () => null,
|
|
482
|
+
"aria-hidden": "true",
|
|
483
|
+
tabIndex: -1
|
|
484
|
+
}
|
|
485
|
+
)) })
|
|
486
|
+
] })
|
|
487
|
+
] }),
|
|
488
|
+
children && /* @__PURE__ */ jsx("div", { className: "eds-input-panel__additional-content", children })
|
|
489
|
+
] })
|
|
490
|
+
] });
|
|
491
|
+
}
|
|
492
|
+
);
|
|
493
|
+
const RadioPanel = React__default.forwardRef(
|
|
494
|
+
({
|
|
495
|
+
className,
|
|
496
|
+
children,
|
|
497
|
+
value,
|
|
498
|
+
title,
|
|
499
|
+
secondaryLabel,
|
|
500
|
+
size = "medium",
|
|
501
|
+
hideRadioButton = false,
|
|
502
|
+
style,
|
|
503
|
+
id,
|
|
504
|
+
disabled = false,
|
|
505
|
+
...rest
|
|
506
|
+
}, ref) => {
|
|
507
|
+
const { name, value: selected, onChange } = useRadioGroupContext();
|
|
508
|
+
return /* @__PURE__ */ jsx(
|
|
509
|
+
InputPanelBase,
|
|
510
|
+
{
|
|
511
|
+
type: "radio",
|
|
512
|
+
name,
|
|
513
|
+
title,
|
|
514
|
+
value,
|
|
515
|
+
checked: selected === value,
|
|
516
|
+
onChange,
|
|
517
|
+
className,
|
|
518
|
+
secondaryLabel,
|
|
519
|
+
size,
|
|
520
|
+
hideSelectionIndicator: hideRadioButton,
|
|
521
|
+
style,
|
|
522
|
+
id,
|
|
523
|
+
disabled,
|
|
524
|
+
...rest,
|
|
525
|
+
ref,
|
|
526
|
+
children
|
|
361
527
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
528
|
+
);
|
|
529
|
+
}
|
|
530
|
+
);
|
|
531
|
+
const CheckboxPanel = React__default.forwardRef(
|
|
532
|
+
({
|
|
533
|
+
name,
|
|
534
|
+
checked,
|
|
535
|
+
onChange,
|
|
536
|
+
className,
|
|
537
|
+
children,
|
|
538
|
+
value,
|
|
539
|
+
title,
|
|
540
|
+
secondaryLabel,
|
|
541
|
+
size = "medium",
|
|
542
|
+
hideCheckbox = false,
|
|
543
|
+
style,
|
|
544
|
+
id,
|
|
545
|
+
disabled = false,
|
|
546
|
+
...rest
|
|
547
|
+
}, ref) => {
|
|
548
|
+
return /* @__PURE__ */ jsx(
|
|
549
|
+
InputPanelBase,
|
|
550
|
+
{
|
|
551
|
+
type: "checkbox",
|
|
552
|
+
name,
|
|
553
|
+
title,
|
|
554
|
+
value,
|
|
555
|
+
checked,
|
|
556
|
+
onChange,
|
|
557
|
+
className,
|
|
558
|
+
secondaryLabel,
|
|
559
|
+
size,
|
|
560
|
+
hideSelectionIndicator: hideCheckbox,
|
|
561
|
+
style,
|
|
562
|
+
id,
|
|
563
|
+
disabled,
|
|
564
|
+
...rest,
|
|
565
|
+
ref,
|
|
566
|
+
children
|
|
367
567
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
var className = _ref.className,
|
|
386
|
-
children = _ref.children,
|
|
387
|
-
value = _ref.value,
|
|
388
|
-
title = _ref.title,
|
|
389
|
-
secondaryLabel = _ref.secondaryLabel,
|
|
390
|
-
_ref$size = _ref.size,
|
|
391
|
-
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
392
|
-
_ref$hideSelectionInd = _ref.hideSelectionIndicator,
|
|
393
|
-
hideSelectionIndicator = _ref$hideSelectionInd === void 0 ? false : _ref$hideSelectionInd,
|
|
394
|
-
style = _ref.style,
|
|
395
|
-
id = _ref.id,
|
|
396
|
-
_ref$disabled = _ref.disabled,
|
|
397
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
398
|
-
_ref$type = _ref.type,
|
|
399
|
-
type = _ref$type === void 0 ? 'radio' : _ref$type,
|
|
400
|
-
onChange = _ref.onChange,
|
|
401
|
-
checked = _ref.checked,
|
|
402
|
-
name = _ref.name,
|
|
403
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$a);
|
|
404
|
-
var classList = classNames(className, 'eds-input-panel__container', "eds-input-panel--" + size);
|
|
405
|
-
var inputRef = useRef(null);
|
|
406
|
-
var defaultId = useRandomId('eds-inputpanel');
|
|
407
|
-
var inputPanelId = id || defaultId;
|
|
408
|
-
var forceUpdate = useForceUpdate();
|
|
409
|
-
var handleOnChange = function handleOnChange(e) {
|
|
410
|
-
if (onChange === undefined) forceUpdate();
|
|
411
|
-
onChange == null || onChange(e);
|
|
412
|
-
};
|
|
413
|
-
return React__default.createElement("label", {
|
|
414
|
-
className: "eds-input-panel",
|
|
415
|
-
htmlFor: inputPanelId
|
|
416
|
-
}, React__default.createElement("input", _extends({
|
|
417
|
-
type: type,
|
|
418
|
-
name: name,
|
|
419
|
-
ref: mergeRefs(ref, inputRef),
|
|
420
|
-
value: value,
|
|
421
|
-
checked: checked,
|
|
422
|
-
onChange: handleOnChange,
|
|
423
|
-
id: inputPanelId,
|
|
424
|
-
disabled: disabled
|
|
425
|
-
}, rest)), React__default.createElement("div", {
|
|
426
|
-
className: classList,
|
|
427
|
-
style: style
|
|
428
|
-
}, React__default.createElement("div", {
|
|
429
|
-
className: "eds-input-panel__title-wrapper"
|
|
430
|
-
}, React__default.createElement("div", {
|
|
431
|
-
className: "eds-input-panel__title"
|
|
432
|
-
}, title), React__default.createElement("div", {
|
|
433
|
-
className: "eds-input-panel__secondary-label-and-icon-wrapper"
|
|
434
|
-
}, secondaryLabel !== undefined && React__default.createElement(React__default.Fragment, null, secondaryLabel), React__default.createElement("span", {
|
|
435
|
-
style: {
|
|
436
|
-
pointerEvents: 'none'
|
|
437
|
-
}
|
|
438
|
-
}, !(disabled || hideSelectionIndicator) && (type === 'radio' ? React__default.createElement(Radio, {
|
|
439
|
-
name: "",
|
|
440
|
-
value: "",
|
|
441
|
-
checked: (_ref2 = checked != null ? checked : (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.checked) != null ? _ref2 : false,
|
|
442
|
-
onChange: function onChange() {
|
|
443
|
-
return;
|
|
444
|
-
},
|
|
445
|
-
"aria-hidden": "true",
|
|
446
|
-
tabIndex: -1
|
|
447
|
-
}) : React__default.createElement(Checkbox, {
|
|
448
|
-
checked: (_ref3 = checked != null ? checked : (_inputRef$current2 = inputRef.current) == null ? void 0 : _inputRef$current2.checked) != null ? _ref3 : false,
|
|
449
|
-
onChange: function onChange() {
|
|
450
|
-
return null;
|
|
451
|
-
},
|
|
452
|
-
"aria-hidden": "true",
|
|
453
|
-
tabIndex: -1
|
|
454
|
-
}))))), children && React__default.createElement("div", {
|
|
455
|
-
className: "eds-input-panel__additional-content"
|
|
456
|
-
}, children)));
|
|
457
|
-
});
|
|
458
|
-
|
|
459
|
-
var _excluded$9 = ["className", "children", "value", "title", "secondaryLabel", "size", "hideRadioButton", "style", "id", "disabled"];
|
|
460
|
-
var RadioPanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
461
|
-
var className = _ref.className,
|
|
462
|
-
children = _ref.children,
|
|
463
|
-
value = _ref.value,
|
|
464
|
-
title = _ref.title,
|
|
465
|
-
secondaryLabel = _ref.secondaryLabel,
|
|
466
|
-
_ref$size = _ref.size,
|
|
467
|
-
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
468
|
-
_ref$hideRadioButton = _ref.hideRadioButton,
|
|
469
|
-
hideRadioButton = _ref$hideRadioButton === void 0 ? false : _ref$hideRadioButton,
|
|
470
|
-
style = _ref.style,
|
|
471
|
-
id = _ref.id,
|
|
472
|
-
_ref$disabled = _ref.disabled,
|
|
473
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
474
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$9);
|
|
475
|
-
var _useRadioGroupContext = useRadioGroupContext(),
|
|
476
|
-
name = _useRadioGroupContext.name,
|
|
477
|
-
selected = _useRadioGroupContext.value,
|
|
478
|
-
onChange = _useRadioGroupContext.onChange;
|
|
479
|
-
return React__default.createElement(InputPanelBase, _extends({
|
|
480
|
-
type: "radio",
|
|
481
|
-
name: name,
|
|
482
|
-
title: title,
|
|
483
|
-
value: value,
|
|
484
|
-
checked: selected === value,
|
|
485
|
-
onChange: onChange,
|
|
486
|
-
className: className,
|
|
487
|
-
secondaryLabel: secondaryLabel,
|
|
488
|
-
size: size,
|
|
489
|
-
hideSelectionIndicator: hideRadioButton,
|
|
490
|
-
style: style,
|
|
491
|
-
id: id,
|
|
492
|
-
disabled: disabled
|
|
493
|
-
}, rest, {
|
|
494
|
-
ref: ref
|
|
495
|
-
}), children);
|
|
496
|
-
});
|
|
497
|
-
|
|
498
|
-
var _excluded$8 = ["name", "checked", "onChange", "className", "children", "value", "title", "secondaryLabel", "size", "hideCheckbox", "style", "id", "disabled"];
|
|
499
|
-
var CheckboxPanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
500
|
-
var name = _ref.name,
|
|
501
|
-
checked = _ref.checked,
|
|
502
|
-
onChange = _ref.onChange,
|
|
503
|
-
className = _ref.className,
|
|
504
|
-
children = _ref.children,
|
|
505
|
-
value = _ref.value,
|
|
506
|
-
title = _ref.title,
|
|
507
|
-
secondaryLabel = _ref.secondaryLabel,
|
|
508
|
-
_ref$size = _ref.size,
|
|
509
|
-
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
510
|
-
_ref$hideCheckbox = _ref.hideCheckbox,
|
|
511
|
-
hideCheckbox = _ref$hideCheckbox === void 0 ? false : _ref$hideCheckbox,
|
|
512
|
-
style = _ref.style,
|
|
513
|
-
id = _ref.id,
|
|
514
|
-
_ref$disabled = _ref.disabled,
|
|
515
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
516
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$8);
|
|
517
|
-
return React__default.createElement(InputPanelBase, _extends({
|
|
518
|
-
type: "checkbox",
|
|
519
|
-
name: name,
|
|
520
|
-
title: title,
|
|
521
|
-
value: value,
|
|
522
|
-
checked: checked,
|
|
523
|
-
onChange: onChange,
|
|
524
|
-
className: className,
|
|
525
|
-
secondaryLabel: secondaryLabel,
|
|
526
|
-
size: size,
|
|
527
|
-
hideSelectionIndicator: hideCheckbox,
|
|
528
|
-
style: style,
|
|
529
|
-
id: id,
|
|
530
|
-
disabled: disabled
|
|
531
|
-
}, rest, {
|
|
532
|
-
ref: ref
|
|
533
|
-
}), children);
|
|
534
|
-
});
|
|
535
|
-
|
|
536
|
-
var _excluded$7 = ["name", "value", "children", "onChange", "label", "readOnly"];
|
|
537
|
-
var RadioGroup = function RadioGroup(_ref) {
|
|
538
|
-
var name = _ref.name,
|
|
539
|
-
value = _ref.value,
|
|
540
|
-
children = _ref.children,
|
|
541
|
-
onChange = _ref.onChange,
|
|
542
|
-
label = _ref.label,
|
|
543
|
-
_ref$readOnly = _ref.readOnly,
|
|
544
|
-
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
545
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
546
|
-
var contextValue = React__default.useMemo(function () {
|
|
547
|
-
return {
|
|
548
|
-
name: name,
|
|
549
|
-
value: value,
|
|
550
|
-
onChange: onChange,
|
|
551
|
-
readOnly: readOnly
|
|
552
|
-
};
|
|
553
|
-
}, [name, value, onChange, readOnly]);
|
|
554
|
-
return React__default.createElement(RadioGroupContextProvider, {
|
|
555
|
-
value: contextValue
|
|
556
|
-
}, label ? React__default.createElement(Fieldset, _extends({
|
|
557
|
-
label: label
|
|
558
|
-
}, rest), children) : children);
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
);
|
|
571
|
+
const RadioGroup = ({
|
|
572
|
+
name,
|
|
573
|
+
value,
|
|
574
|
+
children,
|
|
575
|
+
onChange,
|
|
576
|
+
label,
|
|
577
|
+
readOnly = false,
|
|
578
|
+
...rest
|
|
579
|
+
}) => {
|
|
580
|
+
const contextValue = React__default.useMemo(
|
|
581
|
+
() => ({ name, value, onChange, readOnly }),
|
|
582
|
+
[name, value, onChange, readOnly]
|
|
583
|
+
);
|
|
584
|
+
return /* @__PURE__ */ jsx(RadioGroupContextProvider, { value: contextValue, children: label ? /* @__PURE__ */ jsx(Fieldset, { label, ...rest, children }) : children });
|
|
559
585
|
};
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
586
|
+
const Switch = React__default.forwardRef(
|
|
587
|
+
({
|
|
588
|
+
className,
|
|
589
|
+
children,
|
|
590
|
+
labelPlacement = "right",
|
|
591
|
+
icon,
|
|
592
|
+
hideIcon = false,
|
|
593
|
+
color = colors.validation.mint,
|
|
594
|
+
contrastColor = colors.validation.mintContrast,
|
|
595
|
+
size = "medium",
|
|
596
|
+
checked,
|
|
597
|
+
...rest
|
|
598
|
+
}, ref) => {
|
|
599
|
+
const displayedIcon = () => {
|
|
600
|
+
if (icon) return icon;
|
|
601
|
+
if (checked === void 0) return /* @__PURE__ */ jsx(Fragment, {});
|
|
602
|
+
const iconSize = size === "large" ? 23 : void 0;
|
|
603
|
+
return checked ? /* @__PURE__ */ jsx(CheckIcon, { size: iconSize }) : /* @__PURE__ */ jsx(CloseSmallIcon, { size: iconSize });
|
|
604
|
+
};
|
|
605
|
+
return /* @__PURE__ */ jsxs(
|
|
606
|
+
"label",
|
|
607
|
+
{
|
|
608
|
+
className: classNames(
|
|
609
|
+
"eds-switch",
|
|
610
|
+
`eds-switch--${labelPlacement}`,
|
|
611
|
+
className
|
|
612
|
+
),
|
|
613
|
+
style: { ...rest.style },
|
|
614
|
+
children: [
|
|
615
|
+
/* @__PURE__ */ jsx("input", { type: "checkbox", ref, checked, ...rest }),
|
|
616
|
+
/* @__PURE__ */ jsx(
|
|
617
|
+
"span",
|
|
618
|
+
{
|
|
619
|
+
className: classNames(
|
|
620
|
+
"eds-switch__switch",
|
|
621
|
+
`eds-switch__switch--${size}`
|
|
622
|
+
),
|
|
623
|
+
style: {
|
|
624
|
+
"--eds-switch-color": color,
|
|
625
|
+
"--eds-switch-contrast-color": contrastColor
|
|
626
|
+
},
|
|
627
|
+
"aria-hidden": "true",
|
|
628
|
+
children: /* @__PURE__ */ jsx("span", { className: "eds-switch__circle", children: !hideIcon && displayedIcon() })
|
|
629
|
+
}
|
|
630
|
+
),
|
|
631
|
+
children && /* @__PURE__ */ jsx(
|
|
632
|
+
"span",
|
|
633
|
+
{
|
|
634
|
+
className: classNames(
|
|
635
|
+
"eds-switch__label",
|
|
636
|
+
`eds-switch__label--${size}--${labelPlacement}`
|
|
637
|
+
),
|
|
638
|
+
children
|
|
639
|
+
}
|
|
640
|
+
)
|
|
641
|
+
]
|
|
642
|
+
}
|
|
643
|
+
);
|
|
644
|
+
}
|
|
645
|
+
);
|
|
610
646
|
function hasValue(value) {
|
|
611
647
|
return value != null && !(Array.isArray(value) && value.length === 0);
|
|
612
648
|
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
//
|
|
616
|
-
// @param obj
|
|
617
|
-
// @param SSR
|
|
618
|
-
// @returns {boolean} False when not present or empty string.
|
|
619
|
-
// True when any number or string with length.
|
|
620
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types -- disabled during Yarn upgrade
|
|
621
|
-
function isFilled(obj, SSR) {
|
|
622
|
-
if (SSR === void 0) {
|
|
623
|
-
SSR = false;
|
|
624
|
-
}
|
|
625
|
-
return obj && (hasValue(obj.value) && obj.value !== '' || SSR && hasValue(obj.defaultValue) && obj.defaultValue !== '');
|
|
649
|
+
function isFilled(obj, SSR = false) {
|
|
650
|
+
return obj && (hasValue(obj.value) && obj.value !== "" || SSR && hasValue(obj.defaultValue) && obj.defaultValue !== "");
|
|
626
651
|
}
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
setFiller && !isInputFilled
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
onClear();
|
|
850
|
-
}
|
|
851
|
-
}, props), React__default.createElement(CloseSmallIcon, null)));
|
|
652
|
+
const TextArea = React__default.forwardRef(
|
|
653
|
+
({
|
|
654
|
+
variant,
|
|
655
|
+
disabled = false,
|
|
656
|
+
readOnly = false,
|
|
657
|
+
className,
|
|
658
|
+
style,
|
|
659
|
+
label,
|
|
660
|
+
feedback,
|
|
661
|
+
labelTooltip,
|
|
662
|
+
labelTooltipButtonAriaLabel,
|
|
663
|
+
labelTooltipPlacement,
|
|
664
|
+
onChange,
|
|
665
|
+
disableLabelAnimation,
|
|
666
|
+
...rest
|
|
667
|
+
}, ref) => {
|
|
668
|
+
const textAreaId = useRandomId("eds-textarea");
|
|
669
|
+
const textareaRef = React__default.useRef(null);
|
|
670
|
+
return /* @__PURE__ */ jsx(
|
|
671
|
+
BaseFormControl,
|
|
672
|
+
{
|
|
673
|
+
className: classNames(className, "eds-textarea__wrapper"),
|
|
674
|
+
disabled,
|
|
675
|
+
readOnly,
|
|
676
|
+
variant,
|
|
677
|
+
style,
|
|
678
|
+
label,
|
|
679
|
+
labelId: textAreaId,
|
|
680
|
+
feedback,
|
|
681
|
+
labelTooltip,
|
|
682
|
+
labelTooltipButtonAriaLabel,
|
|
683
|
+
labelTooltipPlacement,
|
|
684
|
+
labelProps: { className: "eds-textarea__label" },
|
|
685
|
+
disableLabelAnimation,
|
|
686
|
+
onClick: (e) => {
|
|
687
|
+
if (e.target === e.currentTarget) textareaRef?.current?.focus();
|
|
688
|
+
},
|
|
689
|
+
children: /* @__PURE__ */ jsx(
|
|
690
|
+
TextAreaBase,
|
|
691
|
+
{
|
|
692
|
+
readOnly,
|
|
693
|
+
disabled,
|
|
694
|
+
ref: mergeRefs(ref, textareaRef),
|
|
695
|
+
"aria-labelledby": textAreaId,
|
|
696
|
+
onChange,
|
|
697
|
+
variant,
|
|
698
|
+
...rest
|
|
699
|
+
}
|
|
700
|
+
)
|
|
701
|
+
}
|
|
702
|
+
);
|
|
703
|
+
}
|
|
704
|
+
);
|
|
705
|
+
const TextAreaBase = React__default.forwardRef(
|
|
706
|
+
({ readOnly, disabled, onChange, value, variant, ...rest }, ref) => {
|
|
707
|
+
const contextVariant = useVariant();
|
|
708
|
+
const currentVariant = variant || contextVariant;
|
|
709
|
+
const { isFilled: isInputFilled, setFilled: setFiller } = useInputGroupContext();
|
|
710
|
+
useOnMount(() => {
|
|
711
|
+
if (value?.toString() || rest.defaultValue) {
|
|
712
|
+
setFiller && !isInputFilled && setFiller(true);
|
|
713
|
+
}
|
|
714
|
+
});
|
|
715
|
+
React__default.useEffect(() => {
|
|
716
|
+
if (value?.toString() && setFiller && !isInputFilled) {
|
|
717
|
+
setFiller(true);
|
|
718
|
+
}
|
|
719
|
+
}, [value, setFiller, isInputFilled]);
|
|
720
|
+
const handleChange = (event) => {
|
|
721
|
+
if (isFilled(event.target)) {
|
|
722
|
+
setFiller && !isInputFilled && setFiller(true);
|
|
723
|
+
} else {
|
|
724
|
+
setFiller && isInputFilled && setFiller(false);
|
|
725
|
+
}
|
|
726
|
+
if (onChange) {
|
|
727
|
+
onChange(event);
|
|
728
|
+
}
|
|
729
|
+
};
|
|
730
|
+
return /* @__PURE__ */ jsx(
|
|
731
|
+
"textarea",
|
|
732
|
+
{
|
|
733
|
+
className: "eds-form-control eds-textarea",
|
|
734
|
+
ref,
|
|
735
|
+
readOnly,
|
|
736
|
+
disabled,
|
|
737
|
+
onChange: handleChange,
|
|
738
|
+
value,
|
|
739
|
+
"aria-invalid": currentVariant === "error",
|
|
740
|
+
...rest
|
|
741
|
+
}
|
|
742
|
+
);
|
|
743
|
+
}
|
|
744
|
+
);
|
|
745
|
+
const TextField = React__default.forwardRef(
|
|
746
|
+
({
|
|
747
|
+
prepend,
|
|
748
|
+
append,
|
|
749
|
+
variant,
|
|
750
|
+
disabled = false,
|
|
751
|
+
readOnly = false,
|
|
752
|
+
className,
|
|
753
|
+
style,
|
|
754
|
+
size = "medium",
|
|
755
|
+
label,
|
|
756
|
+
required,
|
|
757
|
+
labelTooltip,
|
|
758
|
+
labelTooltipButtonAriaLabel,
|
|
759
|
+
labelTooltipPlacement,
|
|
760
|
+
feedback,
|
|
761
|
+
onChange,
|
|
762
|
+
disableLabelAnimation,
|
|
763
|
+
labelProps,
|
|
764
|
+
clearable = false,
|
|
765
|
+
onClear,
|
|
766
|
+
value,
|
|
767
|
+
ariaAlertOnFeedback = false,
|
|
768
|
+
...rest
|
|
769
|
+
}, ref) => {
|
|
770
|
+
const randomId = useRandomId("eds-textfield");
|
|
771
|
+
const textFieldId = labelProps && labelProps.id ? labelProps.id : randomId;
|
|
772
|
+
const textFieldRef = React__default.useRef(null);
|
|
773
|
+
return /* @__PURE__ */ jsx(
|
|
774
|
+
BaseFormControl,
|
|
775
|
+
{
|
|
776
|
+
disabled,
|
|
777
|
+
readOnly,
|
|
778
|
+
variant,
|
|
779
|
+
prepend,
|
|
780
|
+
append: clearable && onClear ? /* @__PURE__ */ jsx(ClearButton, { onClear }) : append,
|
|
781
|
+
className: classNames(className, "eds-textfield__wrapper"),
|
|
782
|
+
style,
|
|
783
|
+
size,
|
|
784
|
+
label,
|
|
785
|
+
required,
|
|
786
|
+
labelTooltip,
|
|
787
|
+
labelTooltipButtonAriaLabel,
|
|
788
|
+
labelTooltipPlacement,
|
|
789
|
+
labelId: textFieldId,
|
|
790
|
+
feedback,
|
|
791
|
+
disableLabelAnimation,
|
|
792
|
+
labelProps,
|
|
793
|
+
ariaAlertOnFeedback,
|
|
794
|
+
onClick: (e) => {
|
|
795
|
+
if (e.target === e.currentTarget) textFieldRef?.current?.focus();
|
|
796
|
+
},
|
|
797
|
+
children: /* @__PURE__ */ jsx(
|
|
798
|
+
TextFieldBase,
|
|
799
|
+
{
|
|
800
|
+
disabled,
|
|
801
|
+
readOnly,
|
|
802
|
+
ref: mergeRefs(ref, textFieldRef),
|
|
803
|
+
"aria-labelledby": textFieldId,
|
|
804
|
+
onChange,
|
|
805
|
+
value,
|
|
806
|
+
variant,
|
|
807
|
+
...rest
|
|
808
|
+
}
|
|
809
|
+
)
|
|
810
|
+
}
|
|
811
|
+
);
|
|
812
|
+
}
|
|
813
|
+
);
|
|
814
|
+
const TextFieldBase = React__default.forwardRef(
|
|
815
|
+
({ disabled, readOnly, placeholder, onChange, value, variant, ...rest }, forwardRef) => {
|
|
816
|
+
const contextVariant = useVariant();
|
|
817
|
+
const currentVariant = variant || contextVariant;
|
|
818
|
+
const { isFilled: isInputFilled, setFilled: setFiller } = useInputGroupContext();
|
|
819
|
+
useOnMount(() => {
|
|
820
|
+
if (value?.toString() || rest.defaultValue) {
|
|
821
|
+
setFiller && !isInputFilled && setFiller(true);
|
|
822
|
+
}
|
|
823
|
+
});
|
|
824
|
+
React__default.useEffect(() => {
|
|
825
|
+
if (value?.toString() && setFiller && !isInputFilled) {
|
|
826
|
+
setFiller(true);
|
|
827
|
+
}
|
|
828
|
+
}, [value, setFiller, isInputFilled]);
|
|
829
|
+
const handleChange = (event) => {
|
|
830
|
+
if (isFilled(event.target)) {
|
|
831
|
+
setFiller && !isInputFilled && setFiller(true);
|
|
832
|
+
} else {
|
|
833
|
+
setFiller && isInputFilled && setFiller(false);
|
|
834
|
+
}
|
|
835
|
+
if (onChange) {
|
|
836
|
+
onChange(event);
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
return /* @__PURE__ */ jsx(
|
|
840
|
+
"input",
|
|
841
|
+
{
|
|
842
|
+
"aria-invalid": currentVariant === "error",
|
|
843
|
+
className: "eds-form-control",
|
|
844
|
+
disabled,
|
|
845
|
+
readOnly,
|
|
846
|
+
ref: forwardRef,
|
|
847
|
+
placeholder,
|
|
848
|
+
onChange: handleChange,
|
|
849
|
+
value,
|
|
850
|
+
...rest
|
|
851
|
+
}
|
|
852
|
+
);
|
|
853
|
+
}
|
|
854
|
+
);
|
|
855
|
+
const ClearButton = ({ onClear, ...props }) => {
|
|
856
|
+
const { isFilled: hasValue2, setFilled } = useInputGroupContext();
|
|
857
|
+
return /* @__PURE__ */ jsxs("div", { className: "eds-textfield__clear-button-wrapper", children: [
|
|
858
|
+
hasValue2 && /* @__PURE__ */ jsx("div", { className: "eds-textfield__divider" }),
|
|
859
|
+
hasValue2 && /* @__PURE__ */ jsx(
|
|
860
|
+
"button",
|
|
861
|
+
{
|
|
862
|
+
className: "eds-textfield__clear-button",
|
|
863
|
+
type: "button",
|
|
864
|
+
tabIndex: -1,
|
|
865
|
+
onClick: () => {
|
|
866
|
+
setFilled(false);
|
|
867
|
+
onClear();
|
|
868
|
+
},
|
|
869
|
+
...props,
|
|
870
|
+
children: /* @__PURE__ */ jsx(CloseSmallIcon, {})
|
|
871
|
+
}
|
|
872
|
+
)
|
|
873
|
+
] });
|
|
852
874
|
};
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
var contextValue = React__default.useMemo(function () {
|
|
868
|
-
return {
|
|
875
|
+
const SegmentedContext = React__default.createContext(
|
|
876
|
+
null
|
|
877
|
+
);
|
|
878
|
+
const SegmentedProvider = ({
|
|
879
|
+
name,
|
|
880
|
+
onChange = () => void 0,
|
|
881
|
+
selectedValue,
|
|
882
|
+
multiple,
|
|
883
|
+
size,
|
|
884
|
+
...rest
|
|
885
|
+
}) => {
|
|
886
|
+
const generatedName = useRandomId("eds-segmented-control");
|
|
887
|
+
const contextValue = React__default.useMemo(
|
|
888
|
+
() => ({
|
|
869
889
|
name: name || generatedName,
|
|
870
|
-
onChange
|
|
871
|
-
multiple
|
|
872
|
-
selectedValue
|
|
873
|
-
size
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
}, rest));
|
|
890
|
+
onChange,
|
|
891
|
+
multiple,
|
|
892
|
+
selectedValue,
|
|
893
|
+
size
|
|
894
|
+
}),
|
|
895
|
+
[generatedName, multiple, name, onChange, selectedValue, size]
|
|
896
|
+
);
|
|
897
|
+
return /* @__PURE__ */ jsx(SegmentedContext.Provider, { value: contextValue, ...rest });
|
|
879
898
|
};
|
|
880
|
-
|
|
881
|
-
|
|
899
|
+
const useSegmentedContext = () => {
|
|
900
|
+
const context = React__default.useContext(SegmentedContext);
|
|
882
901
|
if (!context) {
|
|
883
|
-
throw new Error(
|
|
902
|
+
throw new Error(
|
|
903
|
+
"You need to wrap your SegmentedChoice in either SegmentedControl or MultipleSegmentedControl"
|
|
904
|
+
);
|
|
884
905
|
}
|
|
885
906
|
return context;
|
|
886
907
|
};
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
908
|
+
const SegmentedChoice = React__default.forwardRef(
|
|
909
|
+
({
|
|
910
|
+
children,
|
|
911
|
+
className,
|
|
912
|
+
style,
|
|
913
|
+
value,
|
|
914
|
+
name,
|
|
915
|
+
onChange = () => void 0,
|
|
916
|
+
...rest
|
|
917
|
+
}, ref) => {
|
|
918
|
+
const {
|
|
919
|
+
name: commonName,
|
|
920
|
+
selectedValue,
|
|
921
|
+
onChange: commonOnChange,
|
|
922
|
+
multiple,
|
|
923
|
+
size
|
|
924
|
+
} = useSegmentedContext();
|
|
925
|
+
const isChecked = multiple ? selectedValue[value] : selectedValue === value;
|
|
926
|
+
const handleChange = (e) => {
|
|
927
|
+
onChange(e);
|
|
928
|
+
if (multiple) {
|
|
929
|
+
commonOnChange({
|
|
930
|
+
...selectedValue,
|
|
931
|
+
[value]: e.target.checked
|
|
932
|
+
});
|
|
933
|
+
} else if (e.target.checked) {
|
|
934
|
+
commonOnChange(value);
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
return /* @__PURE__ */ jsxs(
|
|
938
|
+
"label",
|
|
939
|
+
{
|
|
940
|
+
className: classNames("eds-segmented-choice", className),
|
|
941
|
+
style,
|
|
942
|
+
children: [
|
|
943
|
+
/* @__PURE__ */ jsx(
|
|
944
|
+
"input",
|
|
945
|
+
{
|
|
946
|
+
type: multiple ? "checkbox" : "radio",
|
|
947
|
+
name: name || commonName,
|
|
948
|
+
checked: isChecked,
|
|
949
|
+
value,
|
|
950
|
+
onChange: handleChange,
|
|
951
|
+
ref,
|
|
952
|
+
...rest
|
|
953
|
+
}
|
|
954
|
+
),
|
|
955
|
+
/* @__PURE__ */ jsx(
|
|
956
|
+
"div",
|
|
957
|
+
{
|
|
958
|
+
className: classNames("eds-base-segmented", {
|
|
959
|
+
"eds-base-segmented--large": size === "large"
|
|
960
|
+
}),
|
|
961
|
+
children
|
|
962
|
+
}
|
|
963
|
+
)
|
|
964
|
+
]
|
|
965
|
+
}
|
|
966
|
+
);
|
|
967
|
+
}
|
|
968
|
+
);
|
|
969
|
+
const SegmentedControl = ({
|
|
970
|
+
children,
|
|
971
|
+
label,
|
|
972
|
+
name,
|
|
973
|
+
onChange,
|
|
974
|
+
selectedValue,
|
|
975
|
+
size = "medium",
|
|
976
|
+
className,
|
|
977
|
+
...rest
|
|
978
|
+
}) => {
|
|
979
|
+
return /* @__PURE__ */ jsx(
|
|
980
|
+
SegmentedProvider,
|
|
981
|
+
{
|
|
982
|
+
name,
|
|
983
|
+
selectedValue,
|
|
984
|
+
onChange,
|
|
985
|
+
multiple: false,
|
|
986
|
+
size,
|
|
987
|
+
children: /* @__PURE__ */ jsx(Fieldset, { label, children: /* @__PURE__ */ jsx(
|
|
988
|
+
"div",
|
|
989
|
+
{
|
|
990
|
+
className: classNames("eds-segmented-control", className),
|
|
991
|
+
...rest,
|
|
992
|
+
children
|
|
993
|
+
}
|
|
994
|
+
) })
|
|
995
|
+
}
|
|
996
|
+
);
|
|
997
|
+
};
|
|
998
|
+
const MultipleSegmentedControl = ({ children, label, name, onChange, selectedValue, ...rest }) => {
|
|
999
|
+
return /* @__PURE__ */ jsxs(
|
|
1000
|
+
SegmentedProvider,
|
|
1001
|
+
{
|
|
1002
|
+
name,
|
|
1003
|
+
selectedValue,
|
|
1004
|
+
onChange,
|
|
1005
|
+
multiple: true,
|
|
1006
|
+
size: "medium",
|
|
1007
|
+
children: [
|
|
1008
|
+
/* @__PURE__ */ jsx(Label, { as: "div", children: label }),
|
|
1009
|
+
/* @__PURE__ */ jsx("div", { className: "eds-segmented-control", ...rest, children })
|
|
1010
|
+
]
|
|
914
1011
|
}
|
|
915
|
-
|
|
916
|
-
return React__default.createElement("label", {
|
|
917
|
-
className: classNames('eds-segmented-choice', className),
|
|
918
|
-
style: style
|
|
919
|
-
}, React__default.createElement("input", _extends({
|
|
920
|
-
type: multiple ? 'checkbox' : 'radio',
|
|
921
|
-
name: name || commonName,
|
|
922
|
-
checked: isChecked,
|
|
923
|
-
value: value,
|
|
924
|
-
onChange: handleChange,
|
|
925
|
-
ref: ref
|
|
926
|
-
}, rest)), React__default.createElement("div", {
|
|
927
|
-
className: classNames('eds-base-segmented', {
|
|
928
|
-
'eds-base-segmented--large': size === 'large'
|
|
929
|
-
})
|
|
930
|
-
}, children));
|
|
931
|
-
});
|
|
932
|
-
|
|
933
|
-
var _excluded$1 = ["children", "label", "name", "onChange", "selectedValue", "size", "className"];
|
|
934
|
-
var SegmentedControl = function SegmentedControl(_ref) {
|
|
935
|
-
var children = _ref.children,
|
|
936
|
-
label = _ref.label,
|
|
937
|
-
name = _ref.name,
|
|
938
|
-
onChange = _ref.onChange,
|
|
939
|
-
selectedValue = _ref.selectedValue,
|
|
940
|
-
_ref$size = _ref.size,
|
|
941
|
-
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
942
|
-
className = _ref.className,
|
|
943
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
944
|
-
return React__default.createElement(SegmentedProvider, {
|
|
945
|
-
name: name,
|
|
946
|
-
selectedValue: selectedValue,
|
|
947
|
-
onChange: onChange,
|
|
948
|
-
multiple: false,
|
|
949
|
-
size: size
|
|
950
|
-
}, React__default.createElement(Fieldset, {
|
|
951
|
-
label: label
|
|
952
|
-
}, React__default.createElement("div", _extends({
|
|
953
|
-
className: classNames('eds-segmented-control', className)
|
|
954
|
-
}, rest), children)));
|
|
1012
|
+
);
|
|
955
1013
|
};
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
1014
|
+
warnAboutMissingStyles("form", "icons", "typography");
|
|
1015
|
+
export {
|
|
1016
|
+
BaseFormControl,
|
|
1017
|
+
Checkbox,
|
|
1018
|
+
CheckboxPanel,
|
|
1019
|
+
FeedbackText,
|
|
1020
|
+
Fieldset,
|
|
1021
|
+
InputGroupContextProvider,
|
|
1022
|
+
InputGroupLabel,
|
|
1023
|
+
MultipleSegmentedControl,
|
|
1024
|
+
Radio,
|
|
1025
|
+
RadioGroup,
|
|
1026
|
+
RadioPanel,
|
|
1027
|
+
SegmentedChoice,
|
|
1028
|
+
SegmentedControl,
|
|
1029
|
+
Switch,
|
|
1030
|
+
TextArea,
|
|
1031
|
+
TextField,
|
|
1032
|
+
VariantProvider,
|
|
1033
|
+
hasValue,
|
|
1034
|
+
isFilled,
|
|
1035
|
+
useInputGroupContext,
|
|
1036
|
+
useVariant
|
|
979
1037
|
};
|
|
980
|
-
|
|
981
|
-
warnAboutMissingStyles('form', 'icons', 'typography');
|
|
982
|
-
|
|
983
|
-
export { BaseFormControl, Checkbox, CheckboxPanel, FeedbackText, Fieldset, InputGroupContextProvider, InputGroupLabel, MultipleSegmentedControl, Radio, RadioGroup, RadioPanel, SegmentedChoice, SegmentedControl, Switch, TextArea, TextField, VariantProvider, hasValue, isFilled, useInputGroupContext, useVariant };
|
|
984
1038
|
//# sourceMappingURL=form.esm.js.map
|