@sebgroup/green-react 3.2.0 → 3.3.0
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/index.esm.js +170 -145
- package/package.json +4 -4
- package/src/lib/datepicker/datepicker.d.ts +2 -0
- package/src/lib/dropdown/dropdown.d.ts +5 -1
- package/src/lib/form/checkbox/checkbox.d.ts +1 -1
- package/src/lib/form/input/input.d.ts +1 -1
- package/src/lib/form/textarea/textarea.d.ts +1 -1
- package/src/lib/select/select.d.ts +20 -37
package/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import React, { useState, useEffect,
|
|
2
|
+
import React, { useState, useEffect, useRef, useLayoutEffect, useMemo, forwardRef, useCallback, useId } from 'react';
|
|
3
3
|
import { randomId, validateClassName, debounce, delay, sliderColors, getSliderTrackBackground } from '@sebgroup/extract';
|
|
4
4
|
import { createComponent } from '@lit/react';
|
|
5
5
|
import { getScopedTagName, GdsDatepicker, GdsContextMenu, GdsMenuItem, GdsMenuHeading, GdsDropdown, GdsOption } from '@sebgroup/green-core';
|
|
@@ -2106,7 +2106,6 @@ const Datepicker = _a => {
|
|
|
2106
2106
|
const min = minDate ? minDate : new Date(new Date().getFullYear() - 10, 0, 1);
|
|
2107
2107
|
const max = maxDate ? maxDate : new Date(new Date().getFullYear() + 10, 0, 1);
|
|
2108
2108
|
const onChangeHandler = e => {
|
|
2109
|
-
console.log('OnChange event handler');
|
|
2110
2109
|
if (onChange) {
|
|
2111
2110
|
onChange(e.detail.value);
|
|
2112
2111
|
}
|
|
@@ -2121,7 +2120,9 @@ const Datepicker = _a => {
|
|
|
2121
2120
|
max: max,
|
|
2122
2121
|
showWeekNumbers: showWeeks,
|
|
2123
2122
|
onchange: onChangeHandler,
|
|
2124
|
-
|
|
2123
|
+
size: props.size,
|
|
2124
|
+
value: value,
|
|
2125
|
+
hideLabel: props.hideLabel
|
|
2125
2126
|
}, props))
|
|
2126
2127
|
}));
|
|
2127
2128
|
};
|
|
@@ -2294,23 +2295,25 @@ const CoreOption = createComponent({
|
|
|
2294
2295
|
elementClass: GdsOption,
|
|
2295
2296
|
react: React
|
|
2296
2297
|
});
|
|
2297
|
-
const Dropdown =
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2298
|
+
const Dropdown = _a => {
|
|
2299
|
+
var {
|
|
2300
|
+
compareWith,
|
|
2301
|
+
display = 'label',
|
|
2302
|
+
id,
|
|
2303
|
+
informationLabel,
|
|
2304
|
+
label,
|
|
2305
|
+
multiSelect,
|
|
2306
|
+
onChange,
|
|
2307
|
+
options,
|
|
2308
|
+
searchFilter,
|
|
2309
|
+
searchable,
|
|
2310
|
+
texts,
|
|
2311
|
+
useValue = 'value',
|
|
2312
|
+
validator,
|
|
2313
|
+
value,
|
|
2314
|
+
syncPopoverWidth
|
|
2315
|
+
} = _a,
|
|
2316
|
+
props = __rest(_a, ["compareWith", "display", "id", "informationLabel", "label", "multiSelect", "onChange", "options", "searchFilter", "searchable", "texts", "useValue", "validator", "value", "syncPopoverWidth"]);
|
|
2314
2317
|
const handleOnChange = e => {
|
|
2315
2318
|
var _a;
|
|
2316
2319
|
if ((_a = e.detail) === null || _a === void 0 ? void 0 : _a.value) {
|
|
@@ -2323,7 +2326,7 @@ const Dropdown = ({
|
|
|
2323
2326
|
return compareFn(o1, o2);
|
|
2324
2327
|
};
|
|
2325
2328
|
const searchFilterAdapter = (q, o) => {
|
|
2326
|
-
if (searchFilter) return searchFilter(q, o.value[
|
|
2329
|
+
if (searchFilter) return searchFilter(q, o.value[useValue]);else return ((q, o) => o.innerHTML.toLowerCase().includes(q.toLowerCase()))(q, o);
|
|
2327
2330
|
};
|
|
2328
2331
|
return jsx("div", Object.assign({
|
|
2329
2332
|
className: "form-group"
|
|
@@ -2338,7 +2341,9 @@ const Dropdown = ({
|
|
|
2338
2341
|
compareWith: compareWithAdapter,
|
|
2339
2342
|
value: value,
|
|
2340
2343
|
searchFilter: searchFilterAdapter,
|
|
2341
|
-
syncPopoverWidth: syncPopoverWidth
|
|
2344
|
+
syncPopoverWidth: syncPopoverWidth,
|
|
2345
|
+
size: props.size,
|
|
2346
|
+
hideLabel: props.hideLabel
|
|
2342
2347
|
}, {
|
|
2343
2348
|
children: [informationLabel && jsx("span", Object.assign({
|
|
2344
2349
|
slot: "sub-label"
|
|
@@ -2356,14 +2361,14 @@ const Dropdown = ({
|
|
|
2356
2361
|
})), options.map(option => {
|
|
2357
2362
|
if (option.heading) {
|
|
2358
2363
|
return jsx(CoreMenuHeading, {
|
|
2359
|
-
children: option[
|
|
2364
|
+
children: option[display]
|
|
2360
2365
|
}, option.label);
|
|
2361
2366
|
}
|
|
2362
2367
|
return jsx(CoreOption, Object.assign({
|
|
2363
|
-
value: option[
|
|
2368
|
+
value: option[useValue]
|
|
2364
2369
|
}, {
|
|
2365
|
-
children: option[
|
|
2366
|
-
}), option[
|
|
2370
|
+
children: option[display]
|
|
2371
|
+
}), option[useValue]);
|
|
2367
2372
|
})]
|
|
2368
2373
|
}))
|
|
2369
2374
|
}));
|
|
@@ -2404,7 +2409,7 @@ const IconButton = _a => {
|
|
|
2404
2409
|
} = _a,
|
|
2405
2410
|
props = __rest(_a, ["children", "onClick"]);
|
|
2406
2411
|
return jsx("button", Object.assign({
|
|
2407
|
-
className: `icon ${props.size
|
|
2412
|
+
className: `icon ${props.size === 'small' && 'small'}`,
|
|
2408
2413
|
onClick: onClick,
|
|
2409
2414
|
"aria-controls": props['aria-controls'],
|
|
2410
2415
|
"aria-expanded": props['aria-expanded'],
|
|
@@ -2448,46 +2453,48 @@ const ButtonGroup = ({
|
|
|
2448
2453
|
}));
|
|
2449
2454
|
};
|
|
2450
2455
|
|
|
2451
|
-
const useInput = (props, onChanges, onChangeInput) => {
|
|
2452
|
-
const id = useMemo(() => props.id || randomId(), [props.id]);
|
|
2453
|
-
const ref = useRef(null);
|
|
2454
|
-
const onChange = event => {
|
|
2455
|
-
onChanges && onChanges(event);
|
|
2456
|
-
onChangeInput && onChangeInput(event.target.value);
|
|
2457
|
-
};
|
|
2458
|
-
return Object.assign(Object.assign({}, props), {
|
|
2459
|
-
id,
|
|
2460
|
-
ref,
|
|
2461
|
-
onChange
|
|
2462
|
-
});
|
|
2463
|
-
};
|
|
2464
|
-
|
|
2465
2456
|
const Checkbox = _a => {
|
|
2466
2457
|
var {
|
|
2458
|
+
'aria-describedby': ariaDescribedBy,
|
|
2459
|
+
id = randomId(),
|
|
2467
2460
|
label,
|
|
2468
|
-
onChange,
|
|
2469
2461
|
validator,
|
|
2470
|
-
testId
|
|
2462
|
+
testId,
|
|
2463
|
+
required,
|
|
2464
|
+
className
|
|
2471
2465
|
} = _a,
|
|
2472
|
-
props = __rest(_a, ["
|
|
2473
|
-
const
|
|
2474
|
-
const
|
|
2475
|
-
const
|
|
2466
|
+
props = __rest(_a, ['aria-describedby', "id", "label", "validator", "testId", "required", "className"]);
|
|
2467
|
+
const [uuid] = useState(id);
|
|
2468
|
+
const validationClassName = validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
|
|
2469
|
+
const labelClassNames = classNames('form-control', {
|
|
2470
|
+
[validationClassName]: validator
|
|
2471
|
+
});
|
|
2472
|
+
const inputClassNames = classNames(className, {
|
|
2473
|
+
[validationClassName]: validator
|
|
2474
|
+
});
|
|
2475
|
+
const describedBy = classNames(ariaDescribedBy, {
|
|
2476
|
+
[`${uuid}_message`]: (validator === null || validator === void 0 ? void 0 : validator.message) !== undefined && validator.message.length > 0
|
|
2477
|
+
});
|
|
2476
2478
|
return jsxs("div", Object.assign({
|
|
2477
2479
|
className: "form-group"
|
|
2478
2480
|
}, {
|
|
2479
2481
|
children: [jsxs("label", Object.assign({
|
|
2480
|
-
htmlFor:
|
|
2482
|
+
htmlFor: uuid,
|
|
2481
2483
|
className: labelClassNames
|
|
2482
2484
|
}, {
|
|
2483
2485
|
children: [label, jsx("input", Object.assign({
|
|
2486
|
+
"aria-describedby": describedBy || undefined,
|
|
2487
|
+
"aria-invalid": (validator === null || validator === void 0 ? void 0 : validator.indicator) === 'error',
|
|
2488
|
+
"aria-required": required,
|
|
2489
|
+
className: inputClassNames || undefined,
|
|
2484
2490
|
type: "checkbox",
|
|
2485
|
-
"data-testid": testId
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
})), jsx("i", {})]
|
|
2491
|
+
"data-testid": testId,
|
|
2492
|
+
id: uuid,
|
|
2493
|
+
required: required
|
|
2494
|
+
}, props)), jsx("i", {})]
|
|
2489
2495
|
})), validator && jsx("span", Object.assign({
|
|
2490
|
-
className: "form-info"
|
|
2496
|
+
className: "form-info",
|
|
2497
|
+
id: `${uuid}_message`
|
|
2491
2498
|
}, {
|
|
2492
2499
|
children: validator.message
|
|
2493
2500
|
}))]
|
|
@@ -2707,7 +2714,8 @@ function Group({
|
|
|
2707
2714
|
}, {
|
|
2708
2715
|
children: children
|
|
2709
2716
|
})), error && jsx("span", Object.assign({
|
|
2710
|
-
className: "form-info"
|
|
2717
|
+
className: "form-info",
|
|
2718
|
+
id: id && `${id}-message`
|
|
2711
2719
|
}, {
|
|
2712
2720
|
children: errorMessage
|
|
2713
2721
|
}))]
|
|
@@ -3912,7 +3920,8 @@ const FormItem = ({
|
|
|
3912
3920
|
className: "gds-form-item__footer"
|
|
3913
3921
|
}, {
|
|
3914
3922
|
children: [validator && jsx("span", Object.assign({
|
|
3915
|
-
className: "form-info"
|
|
3923
|
+
className: "form-info",
|
|
3924
|
+
id: `${inputId}_message`
|
|
3916
3925
|
}, {
|
|
3917
3926
|
children: validator.message
|
|
3918
3927
|
})), rightAlignedFooterInfo && jsx("span", Object.assign({
|
|
@@ -3928,6 +3937,20 @@ const FormItem = ({
|
|
|
3928
3937
|
}));
|
|
3929
3938
|
};
|
|
3930
3939
|
|
|
3940
|
+
const useInput = (props, onChanges, onChangeInput) => {
|
|
3941
|
+
const id = useMemo(() => props.id || randomId(), [props.id]);
|
|
3942
|
+
const ref = useRef(null);
|
|
3943
|
+
const onChange = event => {
|
|
3944
|
+
onChanges && onChanges(event);
|
|
3945
|
+
onChangeInput && onChangeInput(event.target.value);
|
|
3946
|
+
};
|
|
3947
|
+
return Object.assign(Object.assign({}, props), {
|
|
3948
|
+
id,
|
|
3949
|
+
ref,
|
|
3950
|
+
onChange
|
|
3951
|
+
});
|
|
3952
|
+
};
|
|
3953
|
+
|
|
3931
3954
|
const RadioButton = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
3932
3955
|
var {
|
|
3933
3956
|
label,
|
|
@@ -3974,46 +3997,59 @@ const Input = _a => {
|
|
|
3974
3997
|
role,
|
|
3975
3998
|
validator,
|
|
3976
3999
|
onChangeInput,
|
|
3977
|
-
value = ''
|
|
4000
|
+
value = '',
|
|
4001
|
+
required
|
|
3978
4002
|
} = _a,
|
|
3979
|
-
props = __rest(_a, ['aria-describedby', "autoComplete", "children", "className", "testId", "expandableInfo", "expandableInfoButtonLabel", "formatter", "id", "label", "info", "onChange", "unit", "role", "validator", "onChangeInput", "value"]);
|
|
4003
|
+
props = __rest(_a, ['aria-describedby', "autoComplete", "children", "className", "testId", "expandableInfo", "expandableInfoButtonLabel", "formatter", "id", "label", "info", "onChange", "unit", "role", "validator", "onChangeInput", "value", "required"]);
|
|
3980
4004
|
const [uuid] = useState(id);
|
|
3981
4005
|
const [localValue, setLocalValue] = useState(value);
|
|
3982
4006
|
useEffect(() => {
|
|
3983
4007
|
setLocalValue(value);
|
|
3984
4008
|
}, [value]);
|
|
3985
|
-
const
|
|
3986
|
-
const
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
event.target
|
|
3990
|
-
|
|
3991
|
-
|
|
4009
|
+
const handleChange = useCallback(event => {
|
|
4010
|
+
const {
|
|
4011
|
+
selectionStart,
|
|
4012
|
+
value
|
|
4013
|
+
} = event.target;
|
|
4014
|
+
const formattedValue = formatter ? formatter(value) : value;
|
|
4015
|
+
const nrAddedChars = formattedValue.length - value.length;
|
|
4016
|
+
const updateCaretPosition = nrAddedChars !== 0;
|
|
4017
|
+
const newSelectionStart = updateCaretPosition && selectionStart ? selectionStart + nrAddedChars : selectionStart;
|
|
3992
4018
|
// Fixes bug: React loses caret position when you format the input value
|
|
3993
|
-
if (!formatter || newValue.length > oldValue.length) return;
|
|
3994
|
-
const pointer = event.target.selectionStart;
|
|
3995
|
-
const element = event.target;
|
|
3996
4019
|
window.requestAnimationFrame(() => {
|
|
3997
|
-
|
|
3998
|
-
|
|
4020
|
+
event.target.selectionStart = newSelectionStart;
|
|
4021
|
+
event.target.selectionEnd = newSelectionStart;
|
|
3999
4022
|
});
|
|
4023
|
+
setLocalValue(formattedValue);
|
|
4024
|
+
if (onChange) onChange(event);
|
|
4025
|
+
if (onChangeInput) onChangeInput(formattedValue);
|
|
4000
4026
|
}, [formatter, setLocalValue, onChange, onChangeInput]);
|
|
4001
|
-
const
|
|
4002
|
-
|
|
4003
|
-
[`${uuid}
|
|
4004
|
-
|
|
4005
|
-
|
|
4027
|
+
const showSimpleInput = !label && !info && !expandableInfo;
|
|
4028
|
+
const describedBy = classNames(ariaDescribedBy, {
|
|
4029
|
+
[`${uuid}_group-message`]: !showSimpleInput && (validator === null || validator === void 0 ? void 0 : validator.message) !== undefined && validator.message.length > 0,
|
|
4030
|
+
[`gds-expandable-info-${uuid}`]: !showSimpleInput && expandableInfo,
|
|
4031
|
+
[`${uuid}_info`]: !showSimpleInput && info
|
|
4032
|
+
});
|
|
4033
|
+
const inputClassName = classNames(className, {
|
|
4034
|
+
[validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)]: validator
|
|
4035
|
+
});
|
|
4006
4036
|
const input = jsx("input", Object.assign({
|
|
4007
|
-
"aria-describedby":
|
|
4037
|
+
"aria-describedby": describedBy || undefined,
|
|
4038
|
+
"aria-invalid": (validator === null || validator === void 0 ? void 0 : validator.indicator) === 'error',
|
|
4039
|
+
"aria-required": required,
|
|
4008
4040
|
autoComplete: autoComplete,
|
|
4009
|
-
className: inputClassName,
|
|
4041
|
+
className: inputClassName || undefined,
|
|
4010
4042
|
"data-testid": dataTestId,
|
|
4011
4043
|
id: uuid,
|
|
4012
|
-
onChange:
|
|
4044
|
+
onChange: handleChange,
|
|
4013
4045
|
role: role,
|
|
4014
|
-
value: localValue
|
|
4046
|
+
value: localValue,
|
|
4047
|
+
required: required
|
|
4015
4048
|
}, props));
|
|
4016
|
-
if (
|
|
4049
|
+
if (showSimpleInput) return input;
|
|
4050
|
+
const spanClassName = classNames('form-text', {
|
|
4051
|
+
'disabled': props.disabled
|
|
4052
|
+
});
|
|
4017
4053
|
return jsx(FormItem, Object.assign({
|
|
4018
4054
|
expandableInfo: expandableInfo,
|
|
4019
4055
|
expandableInfoButtonLabel: expandableInfoButtonLabel,
|
|
@@ -4028,10 +4064,11 @@ const Input = _a => {
|
|
|
4028
4064
|
children: jsxs(Group, Object.assign({
|
|
4029
4065
|
groupBorder: true,
|
|
4030
4066
|
groupFocus: true,
|
|
4031
|
-
error: validator
|
|
4067
|
+
error: validator === null || validator === void 0 ? void 0 : validator.message,
|
|
4068
|
+
id: `${uuid}_group`
|
|
4032
4069
|
}, {
|
|
4033
4070
|
children: [input, unit && jsx("span", Object.assign({
|
|
4034
|
-
className:
|
|
4071
|
+
className: spanClassName
|
|
4035
4072
|
}, {
|
|
4036
4073
|
children: unit
|
|
4037
4074
|
})), children]
|
|
@@ -4214,23 +4251,27 @@ const TextArea = _a => {
|
|
|
4214
4251
|
validator,
|
|
4215
4252
|
value,
|
|
4216
4253
|
testId: dataTestId,
|
|
4217
|
-
maxLength
|
|
4254
|
+
maxLength,
|
|
4255
|
+
required
|
|
4218
4256
|
} = _a,
|
|
4219
|
-
props = __rest(_a, ['aria-describedby', "autoComplete", "className", "expandableInfo", "expandableInfoButtonLabel", "id", "label", "info", "onChange", "role", "rows", "validator", "value", "testId", "maxLength"]);
|
|
4257
|
+
props = __rest(_a, ['aria-describedby', "autoComplete", "className", "expandableInfo", "expandableInfoButtonLabel", "id", "label", "info", "onChange", "role", "rows", "validator", "value", "testId", "maxLength", "required"]);
|
|
4220
4258
|
const [uuid] = useState(id);
|
|
4221
4259
|
const [localValue, setLocalValue] = useState(value);
|
|
4222
4260
|
useEffect(() => {
|
|
4223
4261
|
setLocalValue(value);
|
|
4224
4262
|
}, [value]);
|
|
4225
|
-
const
|
|
4263
|
+
const handleChange = useCallback(event => {
|
|
4226
4264
|
setLocalValue(event.target.value);
|
|
4227
4265
|
if (onChange) onChange(event);
|
|
4228
4266
|
}, [setLocalValue, onChange]);
|
|
4229
|
-
const
|
|
4267
|
+
const describedBy = classNames(ariaDescribedBy, {
|
|
4230
4268
|
[`gds-expandable-info-${uuid}`]: expandableInfo,
|
|
4231
|
-
[`${uuid}_info`]: info
|
|
4269
|
+
[`${uuid}_info`]: info,
|
|
4270
|
+
[`${uuid}_message`]: (validator === null || validator === void 0 ? void 0 : validator.message) !== undefined && validator.message.length > 0
|
|
4271
|
+
});
|
|
4272
|
+
const inputClassName = classNames(className, {
|
|
4273
|
+
[validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)]: validator
|
|
4232
4274
|
}) || undefined;
|
|
4233
|
-
const inputClassName = classNames(className, validator && validateClassName(validator.indicator)) || undefined;
|
|
4234
4275
|
const rightAlignedFooterInfo = maxLength ? `${(localValue === null || localValue === void 0 ? void 0 : localValue.length) || 0}/${maxLength}` : undefined;
|
|
4235
4276
|
return jsx(FormItem, Object.assign({
|
|
4236
4277
|
expandableInfo: expandableInfo,
|
|
@@ -4246,16 +4287,19 @@ const TextArea = _a => {
|
|
|
4246
4287
|
className: "gds-input-wrapper"
|
|
4247
4288
|
}, {
|
|
4248
4289
|
children: jsx("textarea", Object.assign({
|
|
4249
|
-
"aria-describedby":
|
|
4290
|
+
"aria-describedby": describedBy || undefined,
|
|
4291
|
+
"aria-invalid": (validator === null || validator === void 0 ? void 0 : validator.indicator) === 'error',
|
|
4292
|
+
"aria-required": required,
|
|
4250
4293
|
autoComplete: autoComplete,
|
|
4251
|
-
className: inputClassName,
|
|
4294
|
+
className: inputClassName || undefined,
|
|
4252
4295
|
id: uuid,
|
|
4253
|
-
onChange:
|
|
4296
|
+
onChange: handleChange,
|
|
4254
4297
|
role: role,
|
|
4255
4298
|
rows: rows,
|
|
4256
4299
|
value: localValue,
|
|
4257
4300
|
"data-testid": dataTestId,
|
|
4258
|
-
maxLength: maxLength
|
|
4301
|
+
maxLength: maxLength,
|
|
4302
|
+
required: required
|
|
4259
4303
|
}, props))
|
|
4260
4304
|
}))
|
|
4261
4305
|
}));
|
|
@@ -4563,75 +4607,56 @@ const Navbar = ({
|
|
|
4563
4607
|
}));
|
|
4564
4608
|
};
|
|
4565
4609
|
|
|
4566
|
-
const Select = /*#__PURE__*/React.forwardRef(({
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
const
|
|
4610
|
+
const Select = /*#__PURE__*/React.forwardRef((_a, ref) => {
|
|
4611
|
+
var {
|
|
4612
|
+
'aria-describedby': ariaDescribedBy,
|
|
4613
|
+
id = randomId(),
|
|
4614
|
+
validator,
|
|
4615
|
+
label,
|
|
4616
|
+
info,
|
|
4617
|
+
testId,
|
|
4618
|
+
expandableInfo,
|
|
4619
|
+
expandableInfoButtonLabel,
|
|
4620
|
+
required
|
|
4621
|
+
} = _a,
|
|
4622
|
+
props = __rest(_a, ['aria-describedby', "id", "validator", "label", "info", "testId", "expandableInfo", "expandableInfoButtonLabel", "required"]);
|
|
4623
|
+
const [uuid] = useState(id);
|
|
4624
|
+
const selectClassName = classNames('gds-select', {
|
|
4625
|
+
[`${validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)}`]: validator
|
|
4626
|
+
});
|
|
4627
|
+
const describedBy = classNames(ariaDescribedBy, {
|
|
4628
|
+
[`${uuid}_info`]: info,
|
|
4629
|
+
[`gds-expandable-info-${uuid}`]: expandableInfo,
|
|
4630
|
+
[`${uuid}_message`]: (validator === null || validator === void 0 ? void 0 : validator.message) !== undefined && validator.message.length > 0
|
|
4631
|
+
});
|
|
4584
4632
|
return jsx(FormItem, Object.assign({
|
|
4585
4633
|
label: label,
|
|
4586
|
-
labelInformation: labelInformation,
|
|
4634
|
+
labelInformation: info !== null && info !== void 0 ? info : props.labelInformation,
|
|
4587
4635
|
expandableInfo: expandableInfo,
|
|
4588
4636
|
expandableInfoButtonLabel: expandableInfoButtonLabel,
|
|
4589
|
-
inputId:
|
|
4637
|
+
inputId: uuid,
|
|
4590
4638
|
validator: validator
|
|
4591
4639
|
}, {
|
|
4592
4640
|
children: jsxs("div", Object.assign({
|
|
4593
|
-
className:
|
|
4641
|
+
className: selectClassName
|
|
4594
4642
|
}, {
|
|
4595
4643
|
children: [jsx("select", Object.assign({
|
|
4596
|
-
|
|
4644
|
+
"aria-describedby": describedBy || undefined,
|
|
4645
|
+
"aria-invalid": (validator === null || validator === void 0 ? void 0 : validator.indicator) === 'error',
|
|
4646
|
+
"aria-required": required,
|
|
4647
|
+
id: uuid,
|
|
4597
4648
|
"data-testid": testId,
|
|
4598
|
-
className: className,
|
|
4599
|
-
name: name,
|
|
4600
|
-
defaultValue: defaultValue,
|
|
4601
|
-
value: value,
|
|
4602
4649
|
ref: ref,
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
}
|
|
4606
|
-
}, {
|
|
4607
|
-
children: children
|
|
4608
|
-
})), jsx(ChevronDown, {})]
|
|
4650
|
+
required: required
|
|
4651
|
+
}, props)), jsx(ChevronDown, {})]
|
|
4609
4652
|
}))
|
|
4610
4653
|
}));
|
|
4611
4654
|
});
|
|
4612
|
-
const Option =
|
|
4613
|
-
|
|
4614
|
-
value,
|
|
4615
|
-
children
|
|
4616
|
-
} = _a,
|
|
4617
|
-
rest = __rest(_a, ["value", "children"]);
|
|
4618
|
-
return jsx("option", Object.assign({
|
|
4619
|
-
value: value
|
|
4620
|
-
}, rest, {
|
|
4621
|
-
children: children
|
|
4622
|
-
}));
|
|
4655
|
+
const Option = props => {
|
|
4656
|
+
return jsx("option", Object.assign({}, props));
|
|
4623
4657
|
};
|
|
4624
|
-
const OptionGroup =
|
|
4625
|
-
|
|
4626
|
-
disabled,
|
|
4627
|
-
children
|
|
4628
|
-
}) => {
|
|
4629
|
-
return jsx("optgroup", Object.assign({
|
|
4630
|
-
label: label,
|
|
4631
|
-
disabled: disabled
|
|
4632
|
-
}, {
|
|
4633
|
-
children: children
|
|
4634
|
-
}));
|
|
4658
|
+
const OptionGroup = props => {
|
|
4659
|
+
return jsx("optgroup", Object.assign({}, props));
|
|
4635
4660
|
};
|
|
4636
4661
|
|
|
4637
4662
|
var anObject$3 = anObject$e;
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sebgroup/green-react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"react": "^17 || ^18",
|
|
6
6
|
"react-dom": "^17 || ^18"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@sebgroup/green-core": "^1.
|
|
10
|
-
"@sebgroup/chlorophyll": "^3.0
|
|
11
|
-
"@sebgroup/extract": "^3.0.
|
|
9
|
+
"@sebgroup/green-core": "^1.7.0",
|
|
10
|
+
"@sebgroup/chlorophyll": "^3.1.0",
|
|
11
|
+
"@sebgroup/extract": "^3.0.1",
|
|
12
12
|
"@lit/react": "^1.0.2",
|
|
13
13
|
"classnames": "^2.3.2"
|
|
14
14
|
},
|
|
@@ -30,6 +30,10 @@ export interface DropdownArgs {
|
|
|
30
30
|
value?: any;
|
|
31
31
|
/** Force width of the popover to match trigger */
|
|
32
32
|
syncPopoverWidth?: boolean;
|
|
33
|
+
/** Size of the dropdown trigger */
|
|
34
|
+
size?: 'small' | 'medium';
|
|
35
|
+
/** Hide the label */
|
|
36
|
+
hideLabel?: boolean;
|
|
33
37
|
}
|
|
34
38
|
export interface DropdownTexts {
|
|
35
39
|
placeholder?: string;
|
|
@@ -48,5 +52,5 @@ export declare const CoreOption: import("@lit/react").ReactWebComponent<GdsOptio
|
|
|
48
52
|
export interface DropdownProps extends DropdownArgs {
|
|
49
53
|
onChange?: OnChange;
|
|
50
54
|
}
|
|
51
|
-
export declare const Dropdown: ({ compareWith, display, id, informationLabel, label, multiSelect, onChange, options, searchFilter, searchable, texts, useValue, validator, value, syncPopoverWidth, }: DropdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
55
|
+
export declare const Dropdown: ({ compareWith, display, id, informationLabel, label, multiSelect, onChange, options, searchFilter, searchable, texts, useValue, validator, value, syncPopoverWidth, ...props }: DropdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
52
56
|
export default Dropdown;
|
|
@@ -12,4 +12,4 @@ export interface CheckboxProps extends HTMLProps<HTMLInputElement> {
|
|
|
12
12
|
/** A handler function that takes the event and can act on it */
|
|
13
13
|
onChange?: FormEventHandler<HTMLInputElement>;
|
|
14
14
|
}
|
|
15
|
-
export declare const Checkbox: ({
|
|
15
|
+
export declare const Checkbox: ({ "aria-describedby": ariaDescribedBy, id, label, validator, testId, required, className, ...props }: CheckboxProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -18,7 +18,7 @@ export interface InputProps extends IExpandableInformation, DetailedHTMLProps<In
|
|
|
18
18
|
/** Function called when input value changes */
|
|
19
19
|
onChangeInput?: (value: string) => string;
|
|
20
20
|
}
|
|
21
|
-
export declare const Input: ({ "aria-describedby": ariaDescribedBy, autoComplete, children, className, testId: dataTestId, expandableInfo, expandableInfoButtonLabel, formatter, id, label, info, onChange, unit, role, validator, onChangeInput, value, ...props }: InputProps) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare const Input: ({ "aria-describedby": ariaDescribedBy, autoComplete, children, className, testId: dataTestId, expandableInfo, expandableInfoButtonLabel, formatter, id, label, info, onChange, unit, role, validator, onChangeInput, value, required, ...props }: InputProps) => import("react/jsx-runtime").JSX.Element;
|
|
22
22
|
export declare const TextInput: (props: Omit<InputProps, 'type'>) => import("react/jsx-runtime").JSX.Element;
|
|
23
23
|
export declare const EmailInput: (props: Omit<InputProps, 'type'>) => import("react/jsx-runtime").JSX.Element;
|
|
24
24
|
export declare const NumberInput: (props: Omit<InputProps, 'type'>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -12,4 +12,4 @@ export interface ITextAreaProps extends IExpandableInformation, DetailedHTMLProp
|
|
|
12
12
|
/** Value of textarea */
|
|
13
13
|
value?: string;
|
|
14
14
|
}
|
|
15
|
-
export declare const TextArea: ({ "aria-describedby": ariaDescribedBy, autoComplete, className, expandableInfo, expandableInfoButtonLabel, id, label, info, onChange, role, rows, validator, value, testId: dataTestId, maxLength, ...props }: ITextAreaProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare const TextArea: ({ "aria-describedby": ariaDescribedBy, autoComplete, className, expandableInfo, expandableInfoButtonLabel, id, label, info, onChange, role, rows, validator, value, testId: dataTestId, maxLength, required, ...props }: ITextAreaProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,42 +1,25 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { IValidator } from '@sebgroup/extract';
|
|
3
|
-
|
|
4
|
-
export interface SelectProps extends SelectorAttributesProps, LabelProps {
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
validator?: IValidator;
|
|
7
|
-
onChange?: (event: React.ChangeEvent<HTMLSelectElement>) => void;
|
|
8
|
-
onSelect?: (event: React.ChangeEvent<HTMLSelectElement>) => void;
|
|
9
|
-
defaultValue?: string | number;
|
|
10
|
-
value?: string | number;
|
|
11
|
-
testId?: string;
|
|
12
|
-
expandableInfo?: string;
|
|
13
|
-
expandableInfoButtonLabel?: string;
|
|
14
|
-
name?: string;
|
|
15
|
-
}
|
|
16
|
-
interface OptionProps {
|
|
17
|
-
children: string;
|
|
18
|
-
value: string | number;
|
|
19
|
-
disabled?: boolean;
|
|
20
|
-
invalid?: boolean;
|
|
21
|
-
autocomplete?: string;
|
|
22
|
-
autofocus?: boolean;
|
|
23
|
-
form?: string;
|
|
24
|
-
name?: string;
|
|
25
|
-
required?: boolean;
|
|
26
|
-
size?: number;
|
|
27
|
-
selected?: boolean;
|
|
28
|
-
}
|
|
29
|
-
interface OptionGroupProps {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IExpandableInformation, ILabelAndLabelInformation, IValidator } from '@sebgroup/extract';
|
|
3
|
+
export interface SelectProps extends IExpandableInformation, ILabelAndLabelInformation, React.DetailedHTMLProps<React.SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement> {
|
|
30
4
|
label: string;
|
|
31
|
-
|
|
32
|
-
|
|
5
|
+
info?: string;
|
|
6
|
+
validator?: IValidator | undefined;
|
|
7
|
+
value?: string;
|
|
8
|
+
testId?: string;
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated
|
|
11
|
+
* Use `info` instead
|
|
12
|
+
*/
|
|
13
|
+
labelInformation?: string;
|
|
33
14
|
}
|
|
34
|
-
export declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLSelectElement>>;
|
|
35
|
-
|
|
36
|
-
export declare const
|
|
15
|
+
export declare const Select: React.ForwardRefExoticComponent<Omit<SelectProps, "ref"> & React.RefAttributes<HTMLSelectElement>>;
|
|
16
|
+
declare type OptionProps = React.DetailedHTMLProps<React.OptionHTMLAttributes<HTMLOptionElement>, HTMLOptionElement>;
|
|
17
|
+
export declare const Option: (props: OptionProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
declare type OptGroupProps = React.DetailedHTMLProps<React.OptgroupHTMLAttributes<HTMLOptGroupElement>, HTMLOptGroupElement>;
|
|
19
|
+
export declare const OptionGroup: (props: OptGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
37
20
|
declare const _default: {
|
|
38
|
-
Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLSelectElement>>;
|
|
39
|
-
Option: (
|
|
40
|
-
OptionGroup: (
|
|
21
|
+
Select: React.ForwardRefExoticComponent<Omit<SelectProps, "ref"> & React.RefAttributes<HTMLSelectElement>>;
|
|
22
|
+
Option: (props: OptionProps) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
OptionGroup: (props: OptGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
41
24
|
};
|
|
42
25
|
export default _default;
|