@entur/form 8.3.2-beta.3 → 8.3.2-beta.4
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 +113 -0
- package/dist/Checkbox.d.ts +58 -0
- package/dist/FeedbackText.d.ts +20 -0
- package/dist/Fieldset.d.ts +12 -0
- package/dist/InputGroupContext.d.ts +10 -0
- package/dist/InputGroupLabel.d.ts +10 -0
- package/dist/Radio.d.ts +30 -0
- package/dist/RadioGroup.d.ts +17 -0
- package/dist/RadioGroupContext.d.ts +10 -0
- package/dist/Switch.d.ts +66 -0
- package/dist/TextArea.d.ts +57 -0
- package/dist/TextField.d.ts +91 -0
- package/dist/VariantProvider.d.ts +12 -0
- package/dist/form.cjs.development.js +1026 -0
- package/dist/form.cjs.development.js.map +1 -0
- package/dist/form.cjs.production.min.js +2 -0
- package/dist/form.cjs.production.min.js.map +1 -0
- package/dist/form.esm.js +942 -996
- package/dist/form.esm.js.map +1 -1
- package/dist/index.d.ts +19 -636
- package/dist/index.js +8 -0
- package/dist/inputPanel/CheckboxPanel.d.ts +30 -0
- package/dist/inputPanel/InputPanelBase.d.ts +33 -0
- package/dist/inputPanel/RadioPanel.d.ts +28 -0
- package/dist/inputPanel/index.d.ts +2 -0
- package/dist/segmented-control/MultipleSegmentedControl.d.ts +20 -0
- package/dist/segmented-control/SegmentedChoice.d.ts +13 -0
- package/dist/segmented-control/SegmentedContext.d.ts +33 -0
- package/dist/segmented-control/SegmentedControl.d.ts +21 -0
- package/dist/styles.css +1351 -1284
- package/dist/utils.d.ts +2 -0
- package/dist/variants.d.ts +7 -0
- package/package.json +16 -26
- package/dist/form.cjs.js +0 -1054
- package/dist/form.cjs.js.map +0 -1
package/dist/form.esm.js
CHANGED
|
@@ -1,1038 +1,984 @@
|
|
|
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
|
-
|
|
1
|
+
import { mergeRefs, useRandomId, useForceUpdate, useOnMount, warnAboutMissingStyles } from '@entur/utils';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import React__default, { useRef } from 'react';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import { ValidationErrorFilledIcon, ValidationExclamationFilledIcon, ValidationSuccessFilledIcon, QuestionIcon, CheckIcon, CloseSmallIcon } from '@entur/icons';
|
|
6
|
+
import { Tooltip } from '@entur/tooltip';
|
|
7
|
+
import { IconButton } from '@entur/button';
|
|
8
|
+
import { SubLabel, Paragraph, Heading5, Label } from '@entur/typography';
|
|
9
|
+
import { colors } from '@entur/tokens';
|
|
10
|
+
|
|
11
|
+
function _extends() {
|
|
12
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
13
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
14
|
+
var t = arguments[e];
|
|
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;
|
|
15
38
|
switch (variant) {
|
|
16
|
-
case
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
{
|
|
28
|
-
"aria-label": "Feilmelding",
|
|
29
|
-
className: iconClass
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
case "information":
|
|
39
|
+
case 'success':
|
|
40
|
+
return React__default.createElement(ValidationSuccessFilledIcon, {
|
|
41
|
+
"aria-label": "Suksessmelding",
|
|
42
|
+
className: iconClass
|
|
43
|
+
});
|
|
44
|
+
case 'negative':
|
|
45
|
+
return React__default.createElement(ValidationErrorFilledIcon, {
|
|
46
|
+
"aria-label": "Feilmelding",
|
|
47
|
+
className: iconClass
|
|
48
|
+
});
|
|
49
|
+
case 'information':
|
|
33
50
|
return null;
|
|
34
|
-
case
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
className: iconClass
|
|
40
|
-
}
|
|
41
|
-
);
|
|
51
|
+
case 'warning':
|
|
52
|
+
return React__default.createElement(ValidationExclamationFilledIcon, {
|
|
53
|
+
"aria-label": "Varselmelding",
|
|
54
|
+
className: iconClass
|
|
55
|
+
});
|
|
42
56
|
case error$1:
|
|
43
|
-
return
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
className: iconClass
|
|
48
|
-
}
|
|
49
|
-
);
|
|
57
|
+
return React__default.createElement(ValidationErrorFilledIcon, {
|
|
58
|
+
"aria-label": "Feilmelding",
|
|
59
|
+
className: iconClass
|
|
60
|
+
});
|
|
50
61
|
case info:
|
|
51
62
|
return null;
|
|
52
63
|
default:
|
|
53
64
|
return null;
|
|
54
65
|
}
|
|
55
66
|
};
|
|
56
|
-
|
|
57
|
-
children,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
),
|
|
73
|
-
...rest,
|
|
74
|
-
children: [
|
|
75
|
-
!hideIcon && /* @__PURE__ */ jsx(AlertIcon, { variant }),
|
|
76
|
-
/* @__PURE__ */ jsx("span", { className: "eds-feedback-text__text", children })
|
|
77
|
-
]
|
|
78
|
-
}
|
|
79
|
-
);
|
|
67
|
+
var FeedbackText = function FeedbackText(_ref2) {
|
|
68
|
+
var children = _ref2.children,
|
|
69
|
+
_ref2$hideIcon = _ref2.hideIcon,
|
|
70
|
+
hideIcon = _ref2$hideIcon === void 0 ? false : _ref2$hideIcon,
|
|
71
|
+
variant = _ref2.variant,
|
|
72
|
+
className = _ref2.className,
|
|
73
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded$g);
|
|
74
|
+
return React__default.createElement(SubLabel, _extends({
|
|
75
|
+
className: classNames('eds-feedback-text', {
|
|
76
|
+
'eds-feedback-text--information': variant === info || variant === 'information'
|
|
77
|
+
}, className)
|
|
78
|
+
}, rest), !hideIcon && React__default.createElement(AlertIcon, {
|
|
79
|
+
variant: variant
|
|
80
|
+
}), React__default.createElement("span", {
|
|
81
|
+
className: "eds-feedback-text__text"
|
|
82
|
+
}, children));
|
|
80
83
|
};
|
|
81
|
-
|
|
84
|
+
|
|
85
|
+
var InputGroupContext = /*#__PURE__*/React.createContext({
|
|
82
86
|
isFilled: false,
|
|
83
|
-
setFilled: ()
|
|
87
|
+
setFilled: function setFilled() {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
84
90
|
});
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
var InputGroupContextProvider = function InputGroupContextProvider(_ref) {
|
|
92
|
+
var children = _ref.children;
|
|
93
|
+
var _React$useState = React.useState(false),
|
|
94
|
+
filled = _React$useState[0],
|
|
95
|
+
setFilled = _React$useState[1];
|
|
96
|
+
return React.createElement(InputGroupContext.Provider, {
|
|
97
|
+
value: {
|
|
98
|
+
isFilled: filled,
|
|
99
|
+
setFilled: setFilled
|
|
92
100
|
}
|
|
93
|
-
);
|
|
101
|
+
}, children);
|
|
94
102
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
label,
|
|
121
|
-
" ",
|
|
122
|
-
required && /* @__PURE__ */ jsx("span", { children: "*" })
|
|
123
|
-
]
|
|
124
|
-
}
|
|
125
|
-
)
|
|
126
|
-
}
|
|
127
|
-
);
|
|
103
|
+
var useInputGroupContext = function useInputGroupContext() {
|
|
104
|
+
return React.useContext(InputGroupContext);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
var _excluded$f = ["label", "required", "labelId", "staticAnimation"];
|
|
108
|
+
var InputGroupLabel = function InputGroupLabel(_ref) {
|
|
109
|
+
var label = _ref.label,
|
|
110
|
+
required = _ref.required,
|
|
111
|
+
labelId = _ref.labelId,
|
|
112
|
+
_ref$staticAnimation = _ref.staticAnimation,
|
|
113
|
+
staticAnimation = _ref$staticAnimation === void 0 ? false : _ref$staticAnimation,
|
|
114
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$f);
|
|
115
|
+
var _useInputGroupContext = useInputGroupContext(),
|
|
116
|
+
isFilled = _useInputGroupContext.isFilled;
|
|
117
|
+
var filler = staticAnimation || isFilled;
|
|
118
|
+
return React__default.createElement("label", _extends({
|
|
119
|
+
className: classNames(rest.className, {
|
|
120
|
+
'eds-input-group-label-wrapper--filled': filler
|
|
121
|
+
}),
|
|
122
|
+
id: labelId
|
|
123
|
+
}, rest), React__default.createElement("span", {
|
|
124
|
+
className: classNames('eds-input-group__label', {
|
|
125
|
+
'eds-input-group__label--filled': filler
|
|
126
|
+
})
|
|
127
|
+
}, label, " ", required && React__default.createElement("span", null, "*")));
|
|
128
128
|
};
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
129
|
+
|
|
130
|
+
var VariantContext = /*#__PURE__*/React__default.createContext(null);
|
|
131
|
+
var VariantProvider = function VariantProvider(_ref) {
|
|
132
|
+
var children = _ref.children,
|
|
133
|
+
_ref$variant = _ref.variant,
|
|
134
|
+
variant = _ref$variant === void 0 ? null : _ref$variant;
|
|
135
|
+
return React__default.createElement(VariantContext.Provider, {
|
|
136
|
+
value: variant
|
|
137
|
+
}, children);
|
|
135
138
|
};
|
|
136
|
-
|
|
137
|
-
|
|
139
|
+
var useVariant = function useVariant() {
|
|
140
|
+
var context = React__default.useContext(VariantContext);
|
|
138
141
|
return context;
|
|
139
142
|
};
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
feedback && currentVariant && /* @__PURE__ */ jsx(
|
|
248
|
-
FeedbackText,
|
|
249
|
-
{
|
|
250
|
-
variant: currentVariant,
|
|
251
|
-
role: ariaAlertOnFeedback ? "alert" : void 0,
|
|
252
|
-
children: feedback
|
|
253
|
-
}
|
|
254
|
-
),
|
|
255
|
-
after
|
|
256
|
-
]
|
|
257
|
-
}
|
|
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" })
|
|
143
|
+
|
|
144
|
+
var _excluded$e = ["after", "before", "children", "className", "disabled", "readOnly", "variant", "prepend", "append", "size", "isFilled", "label", "required", "labelTooltip", "labelTooltipButtonAriaLabel", "labelTooltipPlacement", "feedback", "labelId", "labelProps", "style", "disableLabelAnimation", "ariaAlertOnFeedback", "ariaLabelOnReadOnly"];
|
|
145
|
+
/** @deprecated use variant="negative" instead */
|
|
146
|
+
var error = 'error';
|
|
147
|
+
var BaseFormControl = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
148
|
+
var after = _ref.after,
|
|
149
|
+
before = _ref.before,
|
|
150
|
+
children = _ref.children,
|
|
151
|
+
className = _ref.className,
|
|
152
|
+
_ref$disabled = _ref.disabled,
|
|
153
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
154
|
+
_ref$readOnly = _ref.readOnly,
|
|
155
|
+
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
156
|
+
variant = _ref.variant,
|
|
157
|
+
prepend = _ref.prepend,
|
|
158
|
+
append = _ref.append,
|
|
159
|
+
_ref$size = _ref.size,
|
|
160
|
+
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
161
|
+
isFilled = _ref.isFilled,
|
|
162
|
+
label = _ref.label,
|
|
163
|
+
required = _ref.required,
|
|
164
|
+
labelTooltip = _ref.labelTooltip,
|
|
165
|
+
_ref$labelTooltipButt = _ref.labelTooltipButtonAriaLabel,
|
|
166
|
+
labelTooltipButtonAriaLabel = _ref$labelTooltipButt === void 0 ? "Klikk for tilleggsinfo om " + label + "-feltet" : _ref$labelTooltipButt,
|
|
167
|
+
_ref$labelTooltipPlac = _ref.labelTooltipPlacement,
|
|
168
|
+
labelTooltipPlacement = _ref$labelTooltipPlac === void 0 ? 'top' : _ref$labelTooltipPlac,
|
|
169
|
+
feedback = _ref.feedback,
|
|
170
|
+
labelId = _ref.labelId,
|
|
171
|
+
labelProps = _ref.labelProps,
|
|
172
|
+
style = _ref.style,
|
|
173
|
+
_ref$disableLabelAnim = _ref.disableLabelAnimation,
|
|
174
|
+
disableLabelAnimation = _ref$disableLabelAnim === void 0 ? false : _ref$disableLabelAnim,
|
|
175
|
+
_ref$ariaAlertOnFeedb = _ref.ariaAlertOnFeedback,
|
|
176
|
+
ariaAlertOnFeedback = _ref$ariaAlertOnFeedb === void 0 ? false : _ref$ariaAlertOnFeedb,
|
|
177
|
+
_ref$ariaLabelOnReadO = _ref.ariaLabelOnReadOnly,
|
|
178
|
+
ariaLabelOnReadOnly = _ref$ariaLabelOnReadO === void 0 ? 'Dette skjemafeltet kan bare leses' : _ref$ariaLabelOnReadO,
|
|
179
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$e);
|
|
180
|
+
var contextVariant = useVariant();
|
|
181
|
+
var currentVariant = variant || contextVariant;
|
|
182
|
+
return React__default.createElement(InputGroupContextProvider, null, React__default.createElement("div", {
|
|
183
|
+
className: classNames('eds-form-control__field-and-feedback-text', className, {
|
|
184
|
+
'eds-form-control__field-and-feedback-text--has-tooltip': labelTooltip !== undefined
|
|
185
|
+
}),
|
|
186
|
+
style: style
|
|
187
|
+
}, before, React__default.createElement("div", _extends({
|
|
188
|
+
className: classNames('eds-form-control-wrapper', "eds-form-control-wrapper--size-" + size, {
|
|
189
|
+
'eds-form-control-wrapper--success': currentVariant === 'success',
|
|
190
|
+
'eds-form-control-wrapper--negative': currentVariant === 'negative' || currentVariant === error,
|
|
191
|
+
'eds-form-control-wrapper--disabled': disabled,
|
|
192
|
+
'eds-form-control-wrapper--readonly': readOnly,
|
|
193
|
+
'eds-form-control-wrapper--is-filled': isFilled
|
|
194
|
+
}),
|
|
195
|
+
ref: ref,
|
|
196
|
+
tabIndex: readOnly ? -1 : undefined
|
|
197
|
+
}, rest), prepend && React__default.createElement("div", {
|
|
198
|
+
className: "eds-form-control__prepend"
|
|
199
|
+
}, prepend), React__default.createElement(InputGroupLabel, _extends({
|
|
200
|
+
label: label,
|
|
201
|
+
required: required,
|
|
202
|
+
labelId: labelId,
|
|
203
|
+
staticAnimation: disableLabelAnimation,
|
|
204
|
+
"aria-label": readOnly ? label + ", " + ariaLabelOnReadOnly : undefined
|
|
205
|
+
}, labelProps)), labelTooltip && React__default.createElement(Tooltip, {
|
|
206
|
+
content: labelTooltip,
|
|
207
|
+
placement: labelTooltipPlacement,
|
|
208
|
+
showCloseButton: false,
|
|
209
|
+
disableFocusListener: true,
|
|
210
|
+
disableHoverListener: true,
|
|
211
|
+
disableClickListner: false,
|
|
212
|
+
disableKeyboardListener: false
|
|
213
|
+
}, React__default.createElement(IconButton, {
|
|
214
|
+
as: "span",
|
|
215
|
+
tabIndex: 0,
|
|
216
|
+
role: "button",
|
|
217
|
+
className: "eds-form-control__append eds-form-control__append--tooltip",
|
|
218
|
+
"aria-label": labelTooltipButtonAriaLabel
|
|
219
|
+
}, React__default.createElement(QuestionIcon, {
|
|
220
|
+
className: "eds-input-group__label-tooltip-icon",
|
|
221
|
+
"aria-hidden": "true"
|
|
222
|
+
}))), children, append && React__default.createElement("div", {
|
|
223
|
+
className: "eds-form-control__append"
|
|
224
|
+
}, append)), feedback && currentVariant && React__default.createElement(FeedbackText, {
|
|
225
|
+
variant: currentVariant,
|
|
226
|
+
role: ariaAlertOnFeedback ? 'alert' : undefined
|
|
227
|
+
}, feedback), after));
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
var _excluded$d = ["checked", "className", "children", "style", "disabled", "readOnly", "reduceClickArea", "disableAnimation"];
|
|
231
|
+
var Checkbox = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
232
|
+
var checked = _ref.checked,
|
|
233
|
+
className = _ref.className,
|
|
234
|
+
children = _ref.children,
|
|
235
|
+
style = _ref.style,
|
|
236
|
+
_ref$disabled = _ref.disabled,
|
|
237
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
238
|
+
_ref$readOnly = _ref.readOnly,
|
|
239
|
+
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
240
|
+
reduceClickArea = _ref.reduceClickArea,
|
|
241
|
+
_ref$disableAnimation = _ref.disableAnimation,
|
|
242
|
+
disableAnimation = _ref$disableAnimation === void 0 ? false : _ref$disableAnimation,
|
|
243
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$d);
|
|
244
|
+
var inputRef = React__default.useRef(null);
|
|
245
|
+
var isIndeterminate = checked === 'indeterminate';
|
|
246
|
+
var isControlled = checked !== undefined;
|
|
247
|
+
React__default.useEffect(function () {
|
|
248
|
+
if (inputRef && inputRef.current) {
|
|
249
|
+
inputRef.current.indeterminate = isIndeterminate;
|
|
338
250
|
}
|
|
339
|
-
);
|
|
251
|
+
}, [isIndeterminate]);
|
|
252
|
+
return React__default.createElement("label", {
|
|
253
|
+
className: classNames('eds-checkbox__container', className, {
|
|
254
|
+
'eds-checkbox--disabled': disabled,
|
|
255
|
+
'eds-checkbox--readonly': readOnly,
|
|
256
|
+
'eds-checkbox__container--reduced-click-area': reduceClickArea
|
|
257
|
+
}),
|
|
258
|
+
style: style
|
|
259
|
+
}, React__default.createElement("input", _extends({
|
|
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();
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
"aria-label": readOnly ? " " + (children == null ? void 0 : children.toString()) + ". Kan ikke endres" : undefined
|
|
271
|
+
}, rest)), React__default.createElement("span", {
|
|
272
|
+
className: classNames('eds-checkbox__icon', {
|
|
273
|
+
'eds-checkbox__icon--disabled': disabled,
|
|
274
|
+
'eds-checkbox__icon--readonly': readOnly,
|
|
275
|
+
'eds-checkbox__icon--reduced-click-area': reduceClickArea,
|
|
276
|
+
'eds-checkbox__icon--no-animation': disableAnimation || disabled || readOnly
|
|
277
|
+
})
|
|
278
|
+
}, React__default.createElement(CheckboxIcon, {
|
|
279
|
+
indeterminate: isIndeterminate
|
|
280
|
+
})), children && React__default.createElement(Paragraph, {
|
|
281
|
+
className: "eds-checkbox__label",
|
|
282
|
+
margin: "none",
|
|
283
|
+
as: "span"
|
|
284
|
+
}, children));
|
|
285
|
+
});
|
|
286
|
+
var CheckboxIcon = function CheckboxIcon(_ref2) {
|
|
287
|
+
var _ref2$indeterminate = _ref2.indeterminate,
|
|
288
|
+
indeterminate = _ref2$indeterminate === void 0 ? false : _ref2$indeterminate;
|
|
289
|
+
return React__default.createElement("svg", {
|
|
290
|
+
className: "eds-checkbox-icon",
|
|
291
|
+
width: "11px",
|
|
292
|
+
height: "9px",
|
|
293
|
+
viewBox: "6 11 37 33",
|
|
294
|
+
"aria-hidden": true
|
|
295
|
+
}, indeterminate ? React__default.createElement("rect", {
|
|
296
|
+
x: "10",
|
|
297
|
+
y: "25",
|
|
298
|
+
width: "28",
|
|
299
|
+
height: "5",
|
|
300
|
+
fill: "white"
|
|
301
|
+
}) : React__default.createElement("path", {
|
|
302
|
+
d: "M14.1 27.2l7.1 7.2 14.6-14.8",
|
|
303
|
+
fill: "none"
|
|
304
|
+
}));
|
|
340
305
|
};
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
);
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
306
|
+
|
|
307
|
+
var _excluded$c = ["children", "className", "label"];
|
|
308
|
+
var Fieldset = function Fieldset(_ref) {
|
|
309
|
+
var children = _ref.children,
|
|
310
|
+
className = _ref.className,
|
|
311
|
+
label = _ref.label,
|
|
312
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$c);
|
|
313
|
+
return React__default.createElement("fieldset", _extends({
|
|
314
|
+
className: classNames('eds-fieldset', className)
|
|
315
|
+
}, rest), label && React__default.createElement(Heading5, {
|
|
316
|
+
as: "legend"
|
|
317
|
+
}, label), children);
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
var RadioGroupContext = /*#__PURE__*/React__default.createContext(null);
|
|
321
|
+
var RadioGroupContextProvider = RadioGroupContext.Provider;
|
|
322
|
+
var useRadioGroupContext = function useRadioGroupContext() {
|
|
323
|
+
var context = React__default.useContext(RadioGroupContext);
|
|
356
324
|
if (!context) {
|
|
357
|
-
throw new Error(
|
|
358
|
-
"You need to wrap your RadioButtons in a RadioGroup component"
|
|
359
|
-
);
|
|
325
|
+
throw new Error('You need to wrap your RadioButtons in a RadioGroup component');
|
|
360
326
|
}
|
|
361
327
|
return context;
|
|
362
328
|
};
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
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
|
|
329
|
+
|
|
330
|
+
var _excluded$b = ["className", "children", "value", "disabled", "readOnlyLabelDescription"];
|
|
331
|
+
var Radio = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
332
|
+
var _rest$name, _rest$checked;
|
|
333
|
+
var className = _ref.className,
|
|
334
|
+
children = _ref.children,
|
|
335
|
+
value = _ref.value,
|
|
336
|
+
disabled = _ref.disabled,
|
|
337
|
+
readOnlyLabelDescription = _ref.readOnlyLabelDescription,
|
|
338
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$b);
|
|
339
|
+
var _useRadioGroupContext = useRadioGroupContext(),
|
|
340
|
+
name = _useRadioGroupContext.name,
|
|
341
|
+
selectedValue = _useRadioGroupContext.value,
|
|
342
|
+
_onChange = _useRadioGroupContext.onChange,
|
|
343
|
+
readOnly = _useRadioGroupContext.readOnly;
|
|
344
|
+
var classList = classNames(className, 'eds-form-component--radio__radio', {
|
|
345
|
+
'eds-form-component--radio__radio--disabled': disabled,
|
|
346
|
+
'eds-form-component--radio__radio--readonly': readOnly
|
|
347
|
+
});
|
|
348
|
+
return React__default.createElement("label", {
|
|
349
|
+
className: "eds-form-component--radio__container"
|
|
350
|
+
}, React__default.createElement("input", _extends({
|
|
351
|
+
type: "radio",
|
|
352
|
+
name: (_rest$name = rest.name) != null ? _rest$name : name,
|
|
353
|
+
ref: ref,
|
|
354
|
+
value: value,
|
|
355
|
+
checked: (_rest$checked = rest.checked) != null ? _rest$checked : selectedValue === value,
|
|
356
|
+
onChange: function onChange(e) {
|
|
357
|
+
var _ref2, _rest$onChange;
|
|
358
|
+
if (readOnly) {
|
|
359
|
+
e.preventDefault();
|
|
360
|
+
return;
|
|
527
361
|
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
)
|
|
531
|
-
|
|
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
|
|
362
|
+
(_ref2 = (_rest$onChange = rest.onChange) != null ? _rest$onChange : _onChange) == null || _ref2(e);
|
|
363
|
+
},
|
|
364
|
+
onClick: function onClick(e) {
|
|
365
|
+
if (readOnly) {
|
|
366
|
+
e.preventDefault();
|
|
567
367
|
}
|
|
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
|
-
|
|
368
|
+
},
|
|
369
|
+
disabled: disabled,
|
|
370
|
+
"aria-label": readOnly ? (children == null ? void 0 : children.toString()) + ". " + (readOnlyLabelDescription != null ? readOnlyLabelDescription : 'Kan ikke endres') : undefined
|
|
371
|
+
}, rest)), React__default.createElement("span", {
|
|
372
|
+
className: classList
|
|
373
|
+
}, React__default.createElement("span", {
|
|
374
|
+
className: "eds-form-component--radio__circle"
|
|
375
|
+
})), children && React__default.createElement(Paragraph, {
|
|
376
|
+
margin: "none",
|
|
377
|
+
as: "span",
|
|
378
|
+
className: "eds-form-component--radio__label"
|
|
379
|
+
}, children));
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
var _excluded$a = ["className", "children", "value", "title", "secondaryLabel", "size", "hideSelectionIndicator", "style", "id", "disabled", "type", "onChange", "checked", "name"];
|
|
383
|
+
var InputPanelBase = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
384
|
+
var _ref2, _inputRef$current, _ref3, _inputRef$current2;
|
|
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
|
|
604
552
|
};
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
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);
|
|
559
|
+
};
|
|
560
|
+
|
|
561
|
+
var _excluded$6 = ["className", "children", "labelPlacement", "icon", "hideIcon", "color", "contrastColor", "size", "checked"];
|
|
562
|
+
var Switch = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
563
|
+
var className = _ref.className,
|
|
564
|
+
children = _ref.children,
|
|
565
|
+
_ref$labelPlacement = _ref.labelPlacement,
|
|
566
|
+
labelPlacement = _ref$labelPlacement === void 0 ? 'right' : _ref$labelPlacement,
|
|
567
|
+
icon = _ref.icon,
|
|
568
|
+
_ref$hideIcon = _ref.hideIcon,
|
|
569
|
+
hideIcon = _ref$hideIcon === void 0 ? false : _ref$hideIcon,
|
|
570
|
+
_ref$color = _ref.color,
|
|
571
|
+
color = _ref$color === void 0 ? colors.validation.mint : _ref$color,
|
|
572
|
+
_ref$contrastColor = _ref.contrastColor,
|
|
573
|
+
contrastColor = _ref$contrastColor === void 0 ? colors.validation.mintContrast : _ref$contrastColor,
|
|
574
|
+
_ref$size = _ref.size,
|
|
575
|
+
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
576
|
+
checked = _ref.checked,
|
|
577
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
578
|
+
var displayedIcon = function displayedIcon() {
|
|
579
|
+
if (icon) return icon;
|
|
580
|
+
if (checked === undefined) return React__default.createElement(React__default.Fragment, null);
|
|
581
|
+
var iconSize = size === 'large' ? 23 : undefined;
|
|
582
|
+
return checked ? React__default.createElement(CheckIcon, {
|
|
583
|
+
size: iconSize
|
|
584
|
+
}) : React__default.createElement(CloseSmallIcon, {
|
|
585
|
+
size: iconSize
|
|
586
|
+
});
|
|
587
|
+
};
|
|
588
|
+
return React__default.createElement("label", {
|
|
589
|
+
className: classNames('eds-switch', "eds-switch--" + labelPlacement, className),
|
|
590
|
+
style: _extends({}, rest.style)
|
|
591
|
+
}, React__default.createElement("input", _extends({
|
|
592
|
+
type: "checkbox",
|
|
593
|
+
ref: ref,
|
|
594
|
+
checked: checked
|
|
595
|
+
}, rest)), React__default.createElement("span", {
|
|
596
|
+
className: classNames('eds-switch__switch', "eds-switch__switch--" + size),
|
|
597
|
+
style: {
|
|
598
|
+
'--eds-switch-color': color,
|
|
599
|
+
'--eds-switch-contrast-color': contrastColor
|
|
600
|
+
},
|
|
601
|
+
"aria-hidden": "true"
|
|
602
|
+
}, React__default.createElement("span", {
|
|
603
|
+
className: "eds-switch__circle"
|
|
604
|
+
}, !hideIcon && displayedIcon())), children && React__default.createElement("span", {
|
|
605
|
+
className: classNames('eds-switch__label', "eds-switch__label--" + size + "--" + labelPlacement)
|
|
606
|
+
}, children));
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types -- disabled during Yarn upgrade
|
|
646
610
|
function hasValue(value) {
|
|
647
611
|
return value != null && !(Array.isArray(value) && value.length === 0);
|
|
648
612
|
}
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
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
|
-
);
|
|
613
|
+
// Determine if field is empty or filled.
|
|
614
|
+
// Response determines if label is presented above field or as placeholder.
|
|
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;
|
|
703
624
|
}
|
|
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
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
)
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
625
|
+
return obj && (hasValue(obj.value) && obj.value !== '' || SSR && hasValue(obj.defaultValue) && obj.defaultValue !== '');
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
var _excluded$5 = ["variant", "disabled", "readOnly", "className", "style", "label", "feedback", "labelTooltip", "labelTooltipButtonAriaLabel", "labelTooltipPlacement", "onChange", "disableLabelAnimation"],
|
|
629
|
+
_excluded2$1 = ["readOnly", "disabled", "onChange", "value", "variant"];
|
|
630
|
+
var TextArea = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
631
|
+
var variant = _ref.variant,
|
|
632
|
+
_ref$disabled = _ref.disabled,
|
|
633
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
634
|
+
_ref$readOnly = _ref.readOnly,
|
|
635
|
+
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
636
|
+
className = _ref.className,
|
|
637
|
+
style = _ref.style,
|
|
638
|
+
label = _ref.label,
|
|
639
|
+
feedback = _ref.feedback,
|
|
640
|
+
labelTooltip = _ref.labelTooltip,
|
|
641
|
+
labelTooltipButtonAriaLabel = _ref.labelTooltipButtonAriaLabel,
|
|
642
|
+
labelTooltipPlacement = _ref.labelTooltipPlacement,
|
|
643
|
+
onChange = _ref.onChange,
|
|
644
|
+
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
645
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
646
|
+
var textAreaId = useRandomId('eds-textarea');
|
|
647
|
+
var textareaRef = React__default.useRef(null);
|
|
648
|
+
return React__default.createElement(BaseFormControl, {
|
|
649
|
+
className: classNames(className, 'eds-textarea__wrapper'),
|
|
650
|
+
disabled: disabled,
|
|
651
|
+
readOnly: readOnly,
|
|
652
|
+
variant: variant,
|
|
653
|
+
style: style,
|
|
654
|
+
label: label,
|
|
655
|
+
labelId: textAreaId,
|
|
656
|
+
feedback: feedback,
|
|
657
|
+
labelTooltip: labelTooltip,
|
|
658
|
+
labelTooltipButtonAriaLabel: labelTooltipButtonAriaLabel,
|
|
659
|
+
labelTooltipPlacement: labelTooltipPlacement,
|
|
660
|
+
labelProps: {
|
|
661
|
+
className: 'eds-textarea__label'
|
|
662
|
+
},
|
|
663
|
+
disableLabelAnimation: disableLabelAnimation,
|
|
664
|
+
onClick: function onClick(e) {
|
|
665
|
+
var _textareaRef$current;
|
|
666
|
+
if (e.target === e.currentTarget) textareaRef == null || (_textareaRef$current = textareaRef.current) == null || _textareaRef$current.focus();
|
|
667
|
+
}
|
|
668
|
+
}, React__default.createElement(TextAreaBase, _extends({
|
|
669
|
+
readOnly: readOnly,
|
|
670
|
+
disabled: disabled,
|
|
671
|
+
ref: mergeRefs(ref, textareaRef),
|
|
672
|
+
"aria-labelledby": textAreaId,
|
|
673
|
+
onChange: onChange,
|
|
674
|
+
variant: variant
|
|
675
|
+
}, rest)));
|
|
676
|
+
});
|
|
677
|
+
var TextAreaBase = /*#__PURE__*/React__default.forwardRef(function (_ref2, ref) {
|
|
678
|
+
var readOnly = _ref2.readOnly,
|
|
679
|
+
disabled = _ref2.disabled,
|
|
680
|
+
onChange = _ref2.onChange,
|
|
681
|
+
value = _ref2.value,
|
|
682
|
+
variant = _ref2.variant,
|
|
683
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded2$1);
|
|
684
|
+
var contextVariant = useVariant();
|
|
685
|
+
var currentVariant = variant || contextVariant;
|
|
686
|
+
var _useInputGroupContext = useInputGroupContext(),
|
|
687
|
+
isInputFilled = _useInputGroupContext.isFilled,
|
|
688
|
+
setFiller = _useInputGroupContext.setFilled;
|
|
689
|
+
useOnMount(function () {
|
|
690
|
+
if (value != null && value.toString() || rest.defaultValue) {
|
|
691
|
+
setFiller && !isInputFilled && setFiller(true);
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
React__default.useEffect(function () {
|
|
695
|
+
if (value != null && value.toString() && setFiller && !isInputFilled) {
|
|
696
|
+
setFiller(true);
|
|
697
|
+
}
|
|
698
|
+
}, [value, setFiller, isInputFilled]);
|
|
699
|
+
var handleChange = function handleChange(event) {
|
|
700
|
+
if (isFilled(event.target)) {
|
|
701
|
+
setFiller && !isInputFilled && setFiller(true);
|
|
702
|
+
} else {
|
|
703
|
+
setFiller && isInputFilled && setFiller(false);
|
|
704
|
+
}
|
|
705
|
+
if (onChange) {
|
|
706
|
+
onChange(event);
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
return React__default.createElement("textarea", _extends({
|
|
710
|
+
className: "eds-form-control eds-textarea",
|
|
711
|
+
ref: ref,
|
|
712
|
+
readOnly: readOnly,
|
|
713
|
+
disabled: disabled,
|
|
714
|
+
onChange: handleChange,
|
|
715
|
+
value: value,
|
|
716
|
+
"aria-invalid": currentVariant === 'error'
|
|
717
|
+
}, rest));
|
|
718
|
+
});
|
|
719
|
+
|
|
720
|
+
var _excluded$4 = ["prepend", "append", "variant", "disabled", "readOnly", "className", "style", "size", "label", "required", "labelTooltip", "labelTooltipButtonAriaLabel", "labelTooltipPlacement", "feedback", "onChange", "disableLabelAnimation", "labelProps", "clearable", "onClear", "value", "ariaAlertOnFeedback"],
|
|
721
|
+
_excluded2 = ["disabled", "readOnly", "placeholder", "onChange", "value", "variant"],
|
|
722
|
+
_excluded3 = ["onClear"];
|
|
723
|
+
var TextField = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
724
|
+
var prepend = _ref.prepend,
|
|
725
|
+
append = _ref.append,
|
|
726
|
+
variant = _ref.variant,
|
|
727
|
+
_ref$disabled = _ref.disabled,
|
|
728
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
729
|
+
_ref$readOnly = _ref.readOnly,
|
|
730
|
+
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
731
|
+
className = _ref.className,
|
|
732
|
+
style = _ref.style,
|
|
733
|
+
_ref$size = _ref.size,
|
|
734
|
+
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
735
|
+
label = _ref.label,
|
|
736
|
+
required = _ref.required,
|
|
737
|
+
labelTooltip = _ref.labelTooltip,
|
|
738
|
+
labelTooltipButtonAriaLabel = _ref.labelTooltipButtonAriaLabel,
|
|
739
|
+
labelTooltipPlacement = _ref.labelTooltipPlacement,
|
|
740
|
+
feedback = _ref.feedback,
|
|
741
|
+
onChange = _ref.onChange,
|
|
742
|
+
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
743
|
+
labelProps = _ref.labelProps,
|
|
744
|
+
_ref$clearable = _ref.clearable,
|
|
745
|
+
clearable = _ref$clearable === void 0 ? false : _ref$clearable,
|
|
746
|
+
onClear = _ref.onClear,
|
|
747
|
+
value = _ref.value,
|
|
748
|
+
_ref$ariaAlertOnFeedb = _ref.ariaAlertOnFeedback,
|
|
749
|
+
ariaAlertOnFeedback = _ref$ariaAlertOnFeedb === void 0 ? false : _ref$ariaAlertOnFeedb,
|
|
750
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
751
|
+
var randomId = useRandomId('eds-textfield');
|
|
752
|
+
var textFieldId = labelProps && labelProps.id ? labelProps.id : randomId;
|
|
753
|
+
var textFieldRef = React__default.useRef(null);
|
|
754
|
+
return React__default.createElement(BaseFormControl, {
|
|
755
|
+
disabled: disabled,
|
|
756
|
+
readOnly: readOnly,
|
|
757
|
+
variant: variant,
|
|
758
|
+
prepend: prepend,
|
|
759
|
+
append: clearable && onClear ? React__default.createElement(ClearButton, {
|
|
760
|
+
onClear: onClear
|
|
761
|
+
}) : append,
|
|
762
|
+
className: classNames(className, 'eds-textfield__wrapper'),
|
|
763
|
+
style: style,
|
|
764
|
+
size: size,
|
|
765
|
+
label: label,
|
|
766
|
+
required: required,
|
|
767
|
+
labelTooltip: labelTooltip,
|
|
768
|
+
labelTooltipButtonAriaLabel: labelTooltipButtonAriaLabel,
|
|
769
|
+
labelTooltipPlacement: labelTooltipPlacement,
|
|
770
|
+
labelId: textFieldId,
|
|
771
|
+
feedback: feedback,
|
|
772
|
+
disableLabelAnimation: disableLabelAnimation,
|
|
773
|
+
labelProps: labelProps,
|
|
774
|
+
ariaAlertOnFeedback: ariaAlertOnFeedback,
|
|
775
|
+
onClick: function onClick(e) {
|
|
776
|
+
var _textFieldRef$current;
|
|
777
|
+
if (e.target === e.currentTarget) textFieldRef == null || (_textFieldRef$current = textFieldRef.current) == null || _textFieldRef$current.focus();
|
|
778
|
+
}
|
|
779
|
+
}, React__default.createElement(TextFieldBase, _extends({
|
|
780
|
+
disabled: disabled,
|
|
781
|
+
readOnly: readOnly,
|
|
782
|
+
ref: mergeRefs(ref, textFieldRef),
|
|
783
|
+
"aria-labelledby": textFieldId,
|
|
784
|
+
onChange: onChange,
|
|
785
|
+
value: value,
|
|
786
|
+
variant: variant
|
|
787
|
+
}, rest)));
|
|
788
|
+
});
|
|
789
|
+
var TextFieldBase = /*#__PURE__*/React__default.forwardRef(function (_ref2, forwardRef) {
|
|
790
|
+
var disabled = _ref2.disabled,
|
|
791
|
+
readOnly = _ref2.readOnly,
|
|
792
|
+
placeholder = _ref2.placeholder,
|
|
793
|
+
onChange = _ref2.onChange,
|
|
794
|
+
value = _ref2.value,
|
|
795
|
+
variant = _ref2.variant,
|
|
796
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
797
|
+
var contextVariant = useVariant();
|
|
798
|
+
var currentVariant = variant || contextVariant;
|
|
799
|
+
var _useInputGroupContext = useInputGroupContext(),
|
|
800
|
+
isInputFilled = _useInputGroupContext.isFilled,
|
|
801
|
+
setFiller = _useInputGroupContext.setFilled;
|
|
802
|
+
useOnMount(function () {
|
|
803
|
+
if (value != null && value.toString() || rest.defaultValue) {
|
|
804
|
+
setFiller && !isInputFilled && setFiller(true);
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
React__default.useEffect(function () {
|
|
808
|
+
if (value != null && value.toString() && setFiller && !isInputFilled) {
|
|
809
|
+
setFiller(true);
|
|
810
|
+
}
|
|
811
|
+
}, [value, setFiller, isInputFilled]);
|
|
812
|
+
var handleChange = function handleChange(event) {
|
|
813
|
+
if (isFilled(event.target)) {
|
|
814
|
+
setFiller && !isInputFilled && setFiller(true);
|
|
815
|
+
} else {
|
|
816
|
+
setFiller && isInputFilled && setFiller(false);
|
|
817
|
+
}
|
|
818
|
+
if (onChange) {
|
|
819
|
+
onChange(event);
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
return React__default.createElement("input", _extends({
|
|
823
|
+
"aria-invalid": currentVariant === 'error',
|
|
824
|
+
className: "eds-form-control",
|
|
825
|
+
disabled: disabled,
|
|
826
|
+
readOnly: readOnly,
|
|
827
|
+
ref: forwardRef,
|
|
828
|
+
placeholder: placeholder,
|
|
829
|
+
onChange: handleChange,
|
|
830
|
+
value: value
|
|
831
|
+
}, rest));
|
|
832
|
+
});
|
|
833
|
+
var ClearButton = function ClearButton(_ref3) {
|
|
834
|
+
var onClear = _ref3.onClear,
|
|
835
|
+
props = _objectWithoutPropertiesLoose(_ref3, _excluded3);
|
|
836
|
+
var _useInputGroupContext2 = useInputGroupContext(),
|
|
837
|
+
hasValue = _useInputGroupContext2.isFilled,
|
|
838
|
+
setFilled = _useInputGroupContext2.setFilled;
|
|
839
|
+
return React__default.createElement("div", {
|
|
840
|
+
className: "eds-textfield__clear-button-wrapper"
|
|
841
|
+
}, hasValue && React__default.createElement("div", {
|
|
842
|
+
className: "eds-textfield__divider"
|
|
843
|
+
}), hasValue && React__default.createElement("button", _extends({
|
|
844
|
+
className: "eds-textfield__clear-button",
|
|
845
|
+
type: "button",
|
|
846
|
+
tabIndex: -1,
|
|
847
|
+
onClick: function onClick() {
|
|
848
|
+
setFilled(false);
|
|
849
|
+
onClear();
|
|
850
|
+
}
|
|
851
|
+
}, props), React__default.createElement(CloseSmallIcon, null)));
|
|
874
852
|
};
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
);
|
|
878
|
-
|
|
879
|
-
name,
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
853
|
+
|
|
854
|
+
var _excluded$3 = ["name", "onChange", "selectedValue", "multiple", "size"];
|
|
855
|
+
var SegmentedContext = /*#__PURE__*/React__default.createContext(null);
|
|
856
|
+
var SegmentedProvider = function SegmentedProvider(_ref) {
|
|
857
|
+
var name = _ref.name,
|
|
858
|
+
_ref$onChange = _ref.onChange,
|
|
859
|
+
onChange = _ref$onChange === void 0 ? function () {
|
|
860
|
+
return undefined;
|
|
861
|
+
} : _ref$onChange,
|
|
862
|
+
selectedValue = _ref.selectedValue,
|
|
863
|
+
multiple = _ref.multiple,
|
|
864
|
+
size = _ref.size,
|
|
865
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
866
|
+
var generatedName = useRandomId('eds-segmented-control');
|
|
867
|
+
var contextValue = React__default.useMemo(function () {
|
|
868
|
+
return {
|
|
889
869
|
name: name || generatedName,
|
|
890
|
-
onChange,
|
|
891
|
-
multiple,
|
|
892
|
-
selectedValue,
|
|
893
|
-
size
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
870
|
+
onChange: onChange,
|
|
871
|
+
multiple: multiple,
|
|
872
|
+
selectedValue: selectedValue,
|
|
873
|
+
size: size
|
|
874
|
+
};
|
|
875
|
+
}, [generatedName, multiple, name, onChange, selectedValue, size]);
|
|
876
|
+
return React__default.createElement(SegmentedContext.Provider, _extends({
|
|
877
|
+
value: contextValue
|
|
878
|
+
}, rest));
|
|
898
879
|
};
|
|
899
|
-
|
|
900
|
-
|
|
880
|
+
var useSegmentedContext = function useSegmentedContext() {
|
|
881
|
+
var context = React__default.useContext(SegmentedContext);
|
|
901
882
|
if (!context) {
|
|
902
|
-
throw new Error(
|
|
903
|
-
"You need to wrap your SegmentedChoice in either SegmentedControl or MultipleSegmentedControl"
|
|
904
|
-
);
|
|
883
|
+
throw new Error('You need to wrap your SegmentedChoice in either SegmentedControl or MultipleSegmentedControl');
|
|
905
884
|
}
|
|
906
885
|
return context;
|
|
907
886
|
};
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
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
|
-
]
|
|
887
|
+
|
|
888
|
+
var _excluded$2 = ["children", "className", "style", "value", "name", "onChange"];
|
|
889
|
+
var SegmentedChoice = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
890
|
+
var children = _ref.children,
|
|
891
|
+
className = _ref.className,
|
|
892
|
+
style = _ref.style,
|
|
893
|
+
value = _ref.value,
|
|
894
|
+
name = _ref.name,
|
|
895
|
+
_ref$onChange = _ref.onChange,
|
|
896
|
+
onChange = _ref$onChange === void 0 ? function () {
|
|
897
|
+
return undefined;
|
|
898
|
+
} : _ref$onChange,
|
|
899
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
900
|
+
var _useSegmentedContext = useSegmentedContext(),
|
|
901
|
+
commonName = _useSegmentedContext.name,
|
|
902
|
+
selectedValue = _useSegmentedContext.selectedValue,
|
|
903
|
+
commonOnChange = _useSegmentedContext.onChange,
|
|
904
|
+
multiple = _useSegmentedContext.multiple,
|
|
905
|
+
size = _useSegmentedContext.size;
|
|
906
|
+
var isChecked = multiple ? selectedValue[value] : selectedValue === value;
|
|
907
|
+
var handleChange = function handleChange(e) {
|
|
908
|
+
onChange(e);
|
|
909
|
+
if (multiple) {
|
|
910
|
+
var _extends2;
|
|
911
|
+
commonOnChange(_extends({}, selectedValue, (_extends2 = {}, _extends2[value] = e.target.checked, _extends2)));
|
|
912
|
+
} else if (e.target.checked) {
|
|
913
|
+
commonOnChange(value);
|
|
1011
914
|
}
|
|
1012
|
-
|
|
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)));
|
|
1013
955
|
};
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
956
|
+
|
|
957
|
+
var _excluded = ["children", "label", "name", "onChange", "selectedValue"];
|
|
958
|
+
/**This component is not used by anyone, and is therefore deprecated
|
|
959
|
+
* @deprecated
|
|
960
|
+
*/
|
|
961
|
+
var MultipleSegmentedControl = function MultipleSegmentedControl(_ref) {
|
|
962
|
+
var children = _ref.children,
|
|
963
|
+
label = _ref.label,
|
|
964
|
+
name = _ref.name,
|
|
965
|
+
onChange = _ref.onChange,
|
|
966
|
+
selectedValue = _ref.selectedValue,
|
|
967
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
968
|
+
return React__default.createElement(SegmentedProvider, {
|
|
969
|
+
name: name,
|
|
970
|
+
selectedValue: selectedValue,
|
|
971
|
+
onChange: onChange,
|
|
972
|
+
multiple: true,
|
|
973
|
+
size: "medium"
|
|
974
|
+
}, React__default.createElement(Label, {
|
|
975
|
+
as: "div"
|
|
976
|
+
}, label), React__default.createElement("div", _extends({
|
|
977
|
+
className: "eds-segmented-control"
|
|
978
|
+
}, rest), children));
|
|
1037
979
|
};
|
|
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 };
|
|
1038
984
|
//# sourceMappingURL=form.esm.js.map
|