@sebgroup/green-react 2.1.0 → 2.2.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/README.md +1 -1
- package/index.esm.js +121 -44
- package/package.json +3 -3
- package/src/lib/dropdown/dropdown.d.ts +1 -8
- package/src/lib/form/index.d.ts +1 -0
- package/src/lib/form/textarea/textarea.d.ts +10 -0
- package/src/lib/modal/modal.d.ts +2 -1
package/README.md
CHANGED
package/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import React, { useState, useEffect, useRef, useLayoutEffect, useMemo } from 'react';
|
|
2
|
+
import React, { useState, useEffect, useRef, useLayoutEffect, useMemo, memo, useCallback } from 'react';
|
|
3
3
|
import { randomId, createDatepicker, months, years, debounce, validateClassName, delay, sliderColors, getSliderTrackBackground, createStepper } from '@sebgroup/extract';
|
|
4
4
|
import { getScopedTagName, GdsDropdown, GdsOption } from '@sebgroup/green-core';
|
|
5
5
|
import { registerTransitionalStyles } from '@sebgroup/green-core/transitional-styles';
|
|
@@ -2252,7 +2252,6 @@ const Dropdown = ({
|
|
|
2252
2252
|
id,
|
|
2253
2253
|
informationLabel,
|
|
2254
2254
|
label,
|
|
2255
|
-
loop,
|
|
2256
2255
|
multiSelect,
|
|
2257
2256
|
onChange,
|
|
2258
2257
|
options,
|
|
@@ -2263,12 +2262,10 @@ const Dropdown = ({
|
|
|
2263
2262
|
validator,
|
|
2264
2263
|
value
|
|
2265
2264
|
}) => {
|
|
2266
|
-
const [selectedOption, setSelectedOption] = React.useState(options.find(o => o.value === value));
|
|
2267
2265
|
const handleOnChange = e => {
|
|
2268
|
-
var _a
|
|
2266
|
+
var _a;
|
|
2269
2267
|
if ((_a = e.detail) === null || _a === void 0 ? void 0 : _a.value) {
|
|
2270
|
-
|
|
2271
|
-
onChange === null || onChange === void 0 ? void 0 : onChange((_b = e.detail) === null || _b === void 0 ? void 0 : _b.value);
|
|
2268
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(e.detail.value);
|
|
2272
2269
|
}
|
|
2273
2270
|
};
|
|
2274
2271
|
// These adapter functions are used to maintain backwards compatibility with the old interface
|
|
@@ -2287,10 +2284,10 @@ const Dropdown = ({
|
|
|
2287
2284
|
label: label,
|
|
2288
2285
|
searchable: searchable,
|
|
2289
2286
|
multiple: multiSelect,
|
|
2290
|
-
value: selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value,
|
|
2291
2287
|
onchange: handleOnChange,
|
|
2292
2288
|
invalid: (validator === null || validator === void 0 ? void 0 : validator.indicator) === 'error',
|
|
2293
2289
|
compareWith: compareWithAdapter,
|
|
2290
|
+
value: value,
|
|
2294
2291
|
searchFilter: searchFilterAdapter
|
|
2295
2292
|
}, {
|
|
2296
2293
|
children: [informationLabel && jsx("span", Object.assign({
|
|
@@ -2307,8 +2304,7 @@ const Dropdown = ({
|
|
|
2307
2304
|
}, {
|
|
2308
2305
|
children: (texts === null || texts === void 0 ? void 0 : texts.placeholder) || 'Select'
|
|
2309
2306
|
})), options.map(option => jsx(CoreOption, Object.assign({
|
|
2310
|
-
value: option[_useValue]
|
|
2311
|
-
selected: option.selected
|
|
2307
|
+
value: option[_useValue]
|
|
2312
2308
|
}, {
|
|
2313
2309
|
children: option[_display]
|
|
2314
2310
|
}), option[_useValue]))]
|
|
@@ -4247,6 +4243,61 @@ const RadioGroup = ({
|
|
|
4247
4243
|
}));
|
|
4248
4244
|
};
|
|
4249
4245
|
|
|
4246
|
+
const TextArea = /*#__PURE__*/memo(_a => {
|
|
4247
|
+
var {
|
|
4248
|
+
autoComplete = 'off',
|
|
4249
|
+
expandableInfo,
|
|
4250
|
+
expandableInfoButtonLabel,
|
|
4251
|
+
id = randomId(),
|
|
4252
|
+
label,
|
|
4253
|
+
info,
|
|
4254
|
+
onChange,
|
|
4255
|
+
role,
|
|
4256
|
+
rows = 4,
|
|
4257
|
+
validator,
|
|
4258
|
+
value,
|
|
4259
|
+
'data-testid': dataTestId
|
|
4260
|
+
} = _a,
|
|
4261
|
+
props = __rest(_a, ["autoComplete", "expandableInfo", "expandableInfoButtonLabel", "id", "label", "info", "onChange", "role", "rows", "validator", "value", 'data-testid']);
|
|
4262
|
+
const [uuid] = useState(id);
|
|
4263
|
+
const [localValue, setLocalValue] = useState(value);
|
|
4264
|
+
useEffect(() => {
|
|
4265
|
+
setLocalValue(value);
|
|
4266
|
+
}, [value]);
|
|
4267
|
+
const localOnChange = useCallback(event => {
|
|
4268
|
+
setLocalValue(event.target.value);
|
|
4269
|
+
if (onChange) onChange(event);
|
|
4270
|
+
}, [setLocalValue, onChange]);
|
|
4271
|
+
const ariaDetails = [];
|
|
4272
|
+
if (info) ariaDetails.push(`${uuid}_info`);
|
|
4273
|
+
if (expandableInfo) ariaDetails.push(`gds-expandable-info-${uuid}`);
|
|
4274
|
+
return jsx(FormItem, Object.assign({
|
|
4275
|
+
expandableInfo: expandableInfo,
|
|
4276
|
+
expandableInfoButtonLabel: expandableInfoButtonLabel,
|
|
4277
|
+
inputId: uuid,
|
|
4278
|
+
label: label,
|
|
4279
|
+
labelInformation: info,
|
|
4280
|
+
role: role,
|
|
4281
|
+
validator: validator
|
|
4282
|
+
}, {
|
|
4283
|
+
children: jsx("div", Object.assign({
|
|
4284
|
+
className: "gds-input-wrapper"
|
|
4285
|
+
}, {
|
|
4286
|
+
children: jsx("textarea", Object.assign({
|
|
4287
|
+
"aria-describedby": ariaDetails.length > 0 ? ariaDetails.join(' ') : undefined,
|
|
4288
|
+
autoComplete: autoComplete,
|
|
4289
|
+
className: validator && validateClassName(validator.indicator),
|
|
4290
|
+
id: uuid,
|
|
4291
|
+
onChange: localOnChange,
|
|
4292
|
+
role: role,
|
|
4293
|
+
rows: rows,
|
|
4294
|
+
value: localValue,
|
|
4295
|
+
"data-testid": dataTestId
|
|
4296
|
+
}, props))
|
|
4297
|
+
}))
|
|
4298
|
+
}));
|
|
4299
|
+
});
|
|
4300
|
+
|
|
4250
4301
|
const Flexbox = _a => {
|
|
4251
4302
|
var {
|
|
4252
4303
|
alignContent,
|
|
@@ -5040,6 +5091,7 @@ const Tabs = ({
|
|
|
5040
5091
|
|
|
5041
5092
|
const ModalHeader = ({
|
|
5042
5093
|
header: _header = '',
|
|
5094
|
+
id,
|
|
5043
5095
|
onClose
|
|
5044
5096
|
}) => {
|
|
5045
5097
|
const handleClose = event => {
|
|
@@ -5048,9 +5100,11 @@ const ModalHeader = ({
|
|
|
5048
5100
|
return jsxs("div", Object.assign({
|
|
5049
5101
|
className: "header"
|
|
5050
5102
|
}, {
|
|
5051
|
-
children: [jsx("h3", {
|
|
5103
|
+
children: [jsx("h3", Object.assign({
|
|
5104
|
+
id: id
|
|
5105
|
+
}, {
|
|
5052
5106
|
children: _header
|
|
5053
|
-
}), jsxs("button", Object.assign({
|
|
5107
|
+
})), jsxs("button", Object.assign({
|
|
5054
5108
|
className: "close",
|
|
5055
5109
|
onClick: handleClose
|
|
5056
5110
|
}, {
|
|
@@ -5063,10 +5117,12 @@ const ModalHeader = ({
|
|
|
5063
5117
|
}));
|
|
5064
5118
|
};
|
|
5065
5119
|
const ModalBody = ({
|
|
5066
|
-
children
|
|
5120
|
+
children,
|
|
5121
|
+
id
|
|
5067
5122
|
}) => {
|
|
5068
5123
|
return jsx("div", Object.assign({
|
|
5069
|
-
className: "body"
|
|
5124
|
+
className: "body",
|
|
5125
|
+
id: id
|
|
5070
5126
|
}, {
|
|
5071
5127
|
children: children
|
|
5072
5128
|
}));
|
|
@@ -5105,38 +5161,59 @@ const ModalFooter = ({
|
|
|
5105
5161
|
const Modal = _a => {
|
|
5106
5162
|
var {
|
|
5107
5163
|
type = 'default',
|
|
5108
|
-
|
|
5164
|
+
id = randomId(),
|
|
5165
|
+
isOpen,
|
|
5166
|
+
size = 'sm'
|
|
5109
5167
|
} = _a,
|
|
5110
|
-
props = __rest(_a, ["type", "isOpen"]);
|
|
5111
|
-
const
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
case 'takeover':
|
|
5122
|
-
{
|
|
5123
|
-
return jsxs("main", Object.assign({
|
|
5124
|
-
role: "dialog"
|
|
5125
|
-
}, {
|
|
5126
|
-
children: [jsx(ModalHeader, Object.assign({}, props)), jsx(ModalBody, Object.assign({}, props)), jsx(ModalFooter, Object.assign({}, props))]
|
|
5127
|
-
}));
|
|
5128
|
-
}
|
|
5129
|
-
default:
|
|
5130
|
-
{
|
|
5131
|
-
return jsxs("section", Object.assign({
|
|
5132
|
-
role: "dialog"
|
|
5133
|
-
}, {
|
|
5134
|
-
children: [jsx(ModalHeader, Object.assign({}, props)), jsx(ModalBody, Object.assign({}, props)), jsx(ModalFooter, Object.assign({}, props))]
|
|
5135
|
-
}));
|
|
5136
|
-
}
|
|
5137
|
-
}
|
|
5168
|
+
props = __rest(_a, ["type", "id", "isOpen", "size"]);
|
|
5169
|
+
const [uuid, _] = useState(id);
|
|
5170
|
+
if (!isOpen) return null;
|
|
5171
|
+
const bodyId = `${uuid}_body`;
|
|
5172
|
+
const headerId = `${uuid}_header`;
|
|
5173
|
+
const dialogProps = {
|
|
5174
|
+
id: uuid,
|
|
5175
|
+
role: 'dialog',
|
|
5176
|
+
"aria-modal": true,
|
|
5177
|
+
"aria-labelledby": headerId,
|
|
5178
|
+
"aria-describedby": bodyId
|
|
5138
5179
|
};
|
|
5139
|
-
|
|
5180
|
+
switch (type) {
|
|
5181
|
+
case 'slideout':
|
|
5182
|
+
{
|
|
5183
|
+
let className = undefined;
|
|
5184
|
+
if (size === "lg") className = 'gds-slide-out--960';
|
|
5185
|
+
if (size === "md") className = 'gds-slide-out--768';
|
|
5186
|
+
return jsxs("aside", Object.assign({
|
|
5187
|
+
className: className
|
|
5188
|
+
}, dialogProps, {
|
|
5189
|
+
children: [jsx(ModalHeader, Object.assign({
|
|
5190
|
+
id: headerId
|
|
5191
|
+
}, props)), jsx(ModalBody, Object.assign({
|
|
5192
|
+
id: bodyId
|
|
5193
|
+
}, props)), jsx(ModalFooter, Object.assign({}, props))]
|
|
5194
|
+
}));
|
|
5195
|
+
}
|
|
5196
|
+
case 'takeover':
|
|
5197
|
+
{
|
|
5198
|
+
return jsxs("main", Object.assign({}, dialogProps, {
|
|
5199
|
+
children: [jsx(ModalHeader, Object.assign({
|
|
5200
|
+
id: headerId
|
|
5201
|
+
}, props)), jsx(ModalBody, Object.assign({
|
|
5202
|
+
id: bodyId
|
|
5203
|
+
}, props)), jsx(ModalFooter, Object.assign({}, props))]
|
|
5204
|
+
}));
|
|
5205
|
+
}
|
|
5206
|
+
default:
|
|
5207
|
+
{
|
|
5208
|
+
return jsxs("section", Object.assign({}, dialogProps, {
|
|
5209
|
+
children: [jsx(ModalHeader, Object.assign({
|
|
5210
|
+
id: headerId
|
|
5211
|
+
}, props)), jsx(ModalBody, Object.assign({
|
|
5212
|
+
id: bodyId
|
|
5213
|
+
}, props)), jsx(ModalFooter, Object.assign({}, props))]
|
|
5214
|
+
}));
|
|
5215
|
+
}
|
|
5216
|
+
}
|
|
5140
5217
|
};
|
|
5141
5218
|
|
|
5142
|
-
export { Accordion, AlertRibbon as Alert, AlertRibbon, Badge, Button, ButtonGroup, Card, Checkbox, CoreDropdown, CoreOption, Datepicker, Dropdown, EmailInput, Flexbox, Form, FormItem, FormItems, Group, InPageWizardStepCard, Link, List$1 as List, Modal, Navbar, NumberInput, Option, OptionGroup, RadioButton, RadioGroup, RenderInput, Select, Slider, Stepper, Tab, Tabs, Text, TextInput, valueList$1 as ValueList };
|
|
5219
|
+
export { Accordion, AlertRibbon as Alert, AlertRibbon, Badge, Button, ButtonGroup, Card, Checkbox, CoreDropdown, CoreOption, Datepicker, Dropdown, EmailInput, Flexbox, Form, FormItem, FormItems, Group, InPageWizardStepCard, Link, List$1 as List, Modal, Navbar, NumberInput, Option, OptionGroup, RadioButton, RadioGroup, RenderInput, Select, Slider, Stepper, Tab, Tabs, Text, TextArea, TextInput, valueList$1 as ValueList };
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sebgroup/green-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.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.0.
|
|
10
|
-
"@sebgroup/chlorophyll": "^2.
|
|
9
|
+
"@sebgroup/green-core": "^1.0.3",
|
|
10
|
+
"@sebgroup/chlorophyll": "^2.2.0",
|
|
11
11
|
"@sebgroup/extract": "^2.0.0",
|
|
12
12
|
"classnames": "^2.3.2"
|
|
13
13
|
},
|
|
@@ -20,9 +20,7 @@ export interface DropdownArgs {
|
|
|
20
20
|
id?: string;
|
|
21
21
|
informationLabel?: string;
|
|
22
22
|
label?: string;
|
|
23
|
-
loop?: boolean;
|
|
24
23
|
multiSelect?: boolean;
|
|
25
|
-
onTouched?: () => void;
|
|
26
24
|
options: DropdownOption[];
|
|
27
25
|
searchFilter?: SearchFilter;
|
|
28
26
|
searchable?: boolean;
|
|
@@ -32,12 +30,7 @@ export interface DropdownArgs {
|
|
|
32
30
|
value?: any;
|
|
33
31
|
}
|
|
34
32
|
export interface DropdownTexts {
|
|
35
|
-
select?: string;
|
|
36
|
-
selected?: string;
|
|
37
33
|
placeholder?: string;
|
|
38
|
-
searchPlaceholder?: string;
|
|
39
|
-
close?: string;
|
|
40
|
-
optionsDescription?: string;
|
|
41
34
|
}
|
|
42
35
|
export interface DropdownOption {
|
|
43
36
|
label?: string;
|
|
@@ -52,5 +45,5 @@ export declare const CoreOption: import("@lit-labs/react").ReactWebComponent<Gds
|
|
|
52
45
|
export interface DropdownProps extends DropdownArgs {
|
|
53
46
|
onChange?: OnChange;
|
|
54
47
|
}
|
|
55
|
-
export declare const Dropdown: ({ compareWith, display, id, informationLabel, label,
|
|
48
|
+
export declare const Dropdown: ({ compareWith, display, id, informationLabel, label, multiSelect, onChange, options, searchFilter, searchable, texts, useValue, validator, value, }: DropdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
56
49
|
export default Dropdown;
|
package/src/lib/form/index.d.ts
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IExpandableInformation, ILabelAndLabelInformation, IValidator } from '@sebgroup/extract';
|
|
3
|
+
export interface ITextAreaProps extends IExpandableInformation, ILabelAndLabelInformation, React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement> {
|
|
4
|
+
label: string;
|
|
5
|
+
info?: string;
|
|
6
|
+
validator?: IValidator | undefined;
|
|
7
|
+
value?: string;
|
|
8
|
+
'data-testid'?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const TextArea: import("react").MemoExoticComponent<({ autoComplete, expandableInfo, expandableInfoButtonLabel, id, label, info, onChange, role, rows, validator, value, "data-testid": dataTestId, ...props }: ITextAreaProps) => import("react/jsx-runtime").JSX.Element>;
|
package/src/lib/modal/modal.d.ts
CHANGED
|
@@ -8,10 +8,11 @@ export interface ModalProps {
|
|
|
8
8
|
confirm?: string;
|
|
9
9
|
dismiss?: string;
|
|
10
10
|
size?: Size;
|
|
11
|
+
id?: string;
|
|
11
12
|
isOpen?: boolean;
|
|
12
13
|
onClose?: ModalEventListener;
|
|
13
14
|
onConfirm?: ModalEventListener;
|
|
14
15
|
onDismiss?: ModalEventListener;
|
|
15
16
|
}
|
|
16
|
-
export declare const Modal: ({ type, isOpen, ...props }: ModalProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
17
|
+
export declare const Modal: ({ type, id, isOpen, size, ...props }: ModalProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
17
18
|
export default Modal;
|