@sebgroup/green-react 2.1.0 → 2.2.1

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 CHANGED
@@ -42,7 +42,7 @@ yarn
42
42
  3. Start the Storybook
43
43
 
44
44
  ```bash
45
- yarn storybook react
45
+ npx nx run react:storybook
46
46
  ```
47
47
 
48
48
  4. Start the test runner (or make sure your IDE runs the tests continuously)
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, _b;
2266
+ var _a;
2269
2267
  if ((_a = e.detail) === null || _a === void 0 ? void 0 : _a.value) {
2270
- setSelectedOption(options.find(o => o[_useValue] === e.detail.value));
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,
@@ -4336,6 +4387,19 @@ const InPageWizardStepCard = props => {
4336
4387
  }, {
4337
4388
  children: [props.nextBtnText, props.nextBtnIcon]
4338
4389
  }))
4390
+ })), props.stepStatus === 'IsComplete' && !props.hideFooter && jsx("footer", Object.assign({
4391
+ className: "gds-in-page-wizard-step-card__footer__edit"
4392
+ }, {
4393
+ children: jsxs("button", Object.assign({
4394
+ className: "secondary",
4395
+ onClick: props.onEditClick
4396
+ }, {
4397
+ children: [jsx(Edit, {
4398
+ fill: 'var(--color)',
4399
+ height: 16,
4400
+ width: 16
4401
+ }), props.editBtnText]
4402
+ }))
4339
4403
  }))]
4340
4404
  }));
4341
4405
  };
@@ -5040,6 +5104,7 @@ const Tabs = ({
5040
5104
 
5041
5105
  const ModalHeader = ({
5042
5106
  header: _header = '',
5107
+ id,
5043
5108
  onClose
5044
5109
  }) => {
5045
5110
  const handleClose = event => {
@@ -5048,9 +5113,11 @@ const ModalHeader = ({
5048
5113
  return jsxs("div", Object.assign({
5049
5114
  className: "header"
5050
5115
  }, {
5051
- children: [jsx("h3", {
5116
+ children: [jsx("h3", Object.assign({
5117
+ id: id
5118
+ }, {
5052
5119
  children: _header
5053
- }), jsxs("button", Object.assign({
5120
+ })), jsxs("button", Object.assign({
5054
5121
  className: "close",
5055
5122
  onClick: handleClose
5056
5123
  }, {
@@ -5063,10 +5130,12 @@ const ModalHeader = ({
5063
5130
  }));
5064
5131
  };
5065
5132
  const ModalBody = ({
5066
- children
5133
+ children,
5134
+ id
5067
5135
  }) => {
5068
5136
  return jsx("div", Object.assign({
5069
- className: "body"
5137
+ className: "body",
5138
+ id: id
5070
5139
  }, {
5071
5140
  children: children
5072
5141
  }));
@@ -5105,38 +5174,59 @@ const ModalFooter = ({
5105
5174
  const Modal = _a => {
5106
5175
  var {
5107
5176
  type = 'default',
5108
- isOpen
5177
+ id = randomId(),
5178
+ isOpen,
5179
+ size = 'sm'
5109
5180
  } = _a,
5110
- props = __rest(_a, ["type", "isOpen"]);
5111
- const modalContent = () => {
5112
- switch (type) {
5113
- case 'slideout':
5114
- {
5115
- return jsxs("aside", Object.assign({
5116
- role: "dialog"
5117
- }, {
5118
- children: [jsx(ModalHeader, Object.assign({}, props)), jsx(ModalBody, Object.assign({}, props)), jsx(ModalFooter, Object.assign({}, props))]
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
- }
5181
+ props = __rest(_a, ["type", "id", "isOpen", "size"]);
5182
+ const [uuid, _] = useState(id);
5183
+ if (!isOpen) return null;
5184
+ const bodyId = `${uuid}_body`;
5185
+ const headerId = `${uuid}_header`;
5186
+ const dialogProps = {
5187
+ id: uuid,
5188
+ role: 'dialog',
5189
+ "aria-modal": true,
5190
+ "aria-labelledby": headerId,
5191
+ "aria-describedby": bodyId
5138
5192
  };
5139
- return isOpen ? modalContent() : null;
5193
+ switch (type) {
5194
+ case 'slideout':
5195
+ {
5196
+ let className = undefined;
5197
+ if (size === "lg") className = 'gds-slide-out--960';
5198
+ if (size === "md") className = 'gds-slide-out--768';
5199
+ return jsxs("aside", Object.assign({
5200
+ className: className
5201
+ }, dialogProps, {
5202
+ children: [jsx(ModalHeader, Object.assign({
5203
+ id: headerId
5204
+ }, props)), jsx(ModalBody, Object.assign({
5205
+ id: bodyId
5206
+ }, props)), jsx(ModalFooter, Object.assign({}, props))]
5207
+ }));
5208
+ }
5209
+ case 'takeover':
5210
+ {
5211
+ return jsxs("main", Object.assign({}, dialogProps, {
5212
+ children: [jsx(ModalHeader, Object.assign({
5213
+ id: headerId
5214
+ }, props)), jsx(ModalBody, Object.assign({
5215
+ id: bodyId
5216
+ }, props)), jsx(ModalFooter, Object.assign({}, props))]
5217
+ }));
5218
+ }
5219
+ default:
5220
+ {
5221
+ return jsxs("section", Object.assign({}, dialogProps, {
5222
+ children: [jsx(ModalHeader, Object.assign({
5223
+ id: headerId
5224
+ }, props)), jsx(ModalBody, Object.assign({
5225
+ id: bodyId
5226
+ }, props)), jsx(ModalFooter, Object.assign({}, props))]
5227
+ }));
5228
+ }
5229
+ }
5140
5230
  };
5141
5231
 
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 };
5232
+ 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.1.0",
3
+ "version": "2.2.1",
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.2",
10
- "@sebgroup/chlorophyll": "^2.1.0",
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, loop, multiSelect, onChange, options, searchFilter, searchable, texts, useValue, validator, value, }: DropdownProps) => import("react/jsx-runtime").JSX.Element;
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;
@@ -7,3 +7,4 @@ export * from './group/group';
7
7
  export * from './input/input';
8
8
  export * from './text/text';
9
9
  export * from './radioButton/radioGroup';
10
+ export * from './textarea/textarea';
@@ -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>;
@@ -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;