@sebgroup/green-react 2.0.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 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';
@@ -1751,7 +1751,7 @@ const Check = ({
1751
1751
  focusable: _focusable,
1752
1752
  "aria-labelledby": id
1753
1753
  }, {
1754
- children: ["title && ", jsx("title", Object.assign({
1754
+ children: [title && jsx("title", Object.assign({
1755
1755
  id: id
1756
1756
  }, {
1757
1757
  children: title
@@ -1776,7 +1776,7 @@ const ChevronDown = ({
1776
1776
  focusable: _focusable,
1777
1777
  "aria-labelledby": id
1778
1778
  }, {
1779
- children: ["title && ", jsx("title", Object.assign({
1779
+ children: [title && jsx("title", Object.assign({
1780
1780
  id: id
1781
1781
  }, {
1782
1782
  children: title
@@ -1885,6 +1885,37 @@ const InfoCircle = _a => {
1885
1885
  }));
1886
1886
  };
1887
1887
 
1888
+ const Edit = _a => {
1889
+ var {
1890
+ focusable = false,
1891
+ title,
1892
+ fill = 'white',
1893
+ width = 24,
1894
+ height = 24
1895
+ } = _a,
1896
+ props = __rest(_a, ["focusable", "title", "fill", "width", "height"]);
1897
+ let id;
1898
+ if (title) id = randomId();
1899
+ return jsxs("svg", Object.assign({
1900
+ width: width,
1901
+ height: height,
1902
+ viewBox: "0 0 576 512",
1903
+ xmlns: "http://www.w3.org/2000/svg",
1904
+ focusable: focusable,
1905
+ "aria-labelledby": id,
1906
+ "aria-hidden": props['aria-hidden']
1907
+ }, {
1908
+ children: [title && jsx("title", Object.assign({
1909
+ id: id
1910
+ }, {
1911
+ children: title
1912
+ })), jsx("path", {
1913
+ fill: fill,
1914
+ d: "M402.3 344.9l32-32c5-5 13.7-1.5 13.7 5.7V464c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V112c0-26.5 21.5-48 48-48h273.5c7.1 0 10.7 8.6 5.7 13.7l-32 32c-1.5 1.5-3.5 2.3-5.7 2.3H48v352h352V350.5c0-2.1.8-4.1 2.3-5.6zm156.6-201.8L296.3 405.7l-90.4 10c-26.2 2.9-48.5-19.2-45.6-45.6l10-90.4L432.9 17.1c22.9-22.9 59.9-22.9 82.7 0l43.2 43.2c22.9 22.9 22.9 60 .1 82.8zM460.1 174L402 115.9 216.2 301.8l-7.3 65.3 65.3-7.3L460.1 174zm64.8-79.7l-43.2-43.2c-4.1-4.1-10.8-4.1-14.8 0L436 82l58.1 58.1 30.9-30.9c4-4.2 4-10.8-.1-14.9z"
1915
+ })]
1916
+ }));
1917
+ };
1918
+
1888
1919
  function AlertRibbon({
1889
1920
  type,
1890
1921
  header,
@@ -2221,7 +2252,6 @@ const Dropdown = ({
2221
2252
  id,
2222
2253
  informationLabel,
2223
2254
  label,
2224
- loop,
2225
2255
  multiSelect,
2226
2256
  onChange,
2227
2257
  options,
@@ -2232,12 +2262,10 @@ const Dropdown = ({
2232
2262
  validator,
2233
2263
  value
2234
2264
  }) => {
2235
- const [selectedOption, setSelectedOption] = React.useState(options.find(o => o.value === value));
2236
2265
  const handleOnChange = e => {
2237
- var _a, _b;
2266
+ var _a;
2238
2267
  if ((_a = e.detail) === null || _a === void 0 ? void 0 : _a.value) {
2239
- setSelectedOption(options.find(o => o[_useValue] === e.detail.value));
2240
- 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);
2241
2269
  }
2242
2270
  };
2243
2271
  // These adapter functions are used to maintain backwards compatibility with the old interface
@@ -2256,10 +2284,10 @@ const Dropdown = ({
2256
2284
  label: label,
2257
2285
  searchable: searchable,
2258
2286
  multiple: multiSelect,
2259
- value: selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value,
2260
2287
  onchange: handleOnChange,
2261
2288
  invalid: (validator === null || validator === void 0 ? void 0 : validator.indicator) === 'error',
2262
2289
  compareWith: compareWithAdapter,
2290
+ value: value,
2263
2291
  searchFilter: searchFilterAdapter
2264
2292
  }, {
2265
2293
  children: [informationLabel && jsx("span", Object.assign({
@@ -2276,8 +2304,7 @@ const Dropdown = ({
2276
2304
  }, {
2277
2305
  children: (texts === null || texts === void 0 ? void 0 : texts.placeholder) || 'Select'
2278
2306
  })), options.map(option => jsx(CoreOption, Object.assign({
2279
- value: option[_useValue],
2280
- selected: option.selected
2307
+ value: option[_useValue]
2281
2308
  }, {
2282
2309
  children: option[_display]
2283
2310
  }), option[_useValue]))]
@@ -4216,6 +4243,61 @@ const RadioGroup = ({
4216
4243
  }));
4217
4244
  };
4218
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
+
4219
4301
  const Flexbox = _a => {
4220
4302
  var {
4221
4303
  alignContent,
@@ -4254,6 +4336,61 @@ const Flexbox = _a => {
4254
4336
  }));
4255
4337
  };
4256
4338
 
4339
+ const InPageWizardStepCard = props => {
4340
+ return jsxs("section", Object.assign({
4341
+ className: `gds-in-page-wizard-step-card card ${props.stepStatus === 'IsActive' ? 'active' : ''} ${props.stepStatus === 'IsComplete' ? 'completed' : ''}`,
4342
+ "data-testid": props.dataTestid
4343
+ }, {
4344
+ children: [jsxs("header", Object.assign({
4345
+ className: "gds-in-page-wizard-step-card__header"
4346
+ }, {
4347
+ children: [jsx("div", Object.assign({
4348
+ className: "gds-in-page-wizard-step-card__header__icon"
4349
+ }, {
4350
+ children: jsx(Check, {})
4351
+ })), jsx("div", Object.assign({
4352
+ className: "gds-in-page-wizard-step-card__header__progress"
4353
+ }, {
4354
+ children: props.stepText
4355
+ })), jsx("div", Object.assign({
4356
+ className: "gds-in-page-wizard-step-card__header__title"
4357
+ }, {
4358
+ children: jsx("h2", Object.assign({
4359
+ className: "h4"
4360
+ }, {
4361
+ children: props.title
4362
+ }))
4363
+ })), props.stepStatus === 'IsComplete' && jsx("div", Object.assign({
4364
+ className: "gds-in-page-wizard-step-card__header__edit"
4365
+ }, {
4366
+ children: jsxs("button", Object.assign({
4367
+ className: "secondary small",
4368
+ onClick: props.onEditClick
4369
+ }, {
4370
+ children: [jsx(Edit, {
4371
+ fill: 'var(--color)',
4372
+ height: 16,
4373
+ width: 16
4374
+ }), props.editBtnText]
4375
+ }))
4376
+ }))]
4377
+ })), (props.stepStatus === 'IsActive' || props.stepStatus === 'IsComplete') && jsx("div", Object.assign({
4378
+ className: "gds-in-page-wizard-step-card__content"
4379
+ }, {
4380
+ children: props.children
4381
+ })), props.stepStatus === 'IsActive' && !props.hideFooter && jsx("footer", Object.assign({
4382
+ className: "gds-in-page-wizard-step-card__footer"
4383
+ }, {
4384
+ children: jsxs("button", Object.assign({
4385
+ className: "primary",
4386
+ onClick: props.onNextClick
4387
+ }, {
4388
+ children: [props.nextBtnText, props.nextBtnIcon]
4389
+ }))
4390
+ }))]
4391
+ }));
4392
+ };
4393
+
4257
4394
  const Link = _a => {
4258
4395
  var {
4259
4396
  button,
@@ -4954,6 +5091,7 @@ const Tabs = ({
4954
5091
 
4955
5092
  const ModalHeader = ({
4956
5093
  header: _header = '',
5094
+ id,
4957
5095
  onClose
4958
5096
  }) => {
4959
5097
  const handleClose = event => {
@@ -4962,9 +5100,11 @@ const ModalHeader = ({
4962
5100
  return jsxs("div", Object.assign({
4963
5101
  className: "header"
4964
5102
  }, {
4965
- children: [jsx("h3", {
5103
+ children: [jsx("h3", Object.assign({
5104
+ id: id
5105
+ }, {
4966
5106
  children: _header
4967
- }), jsxs("button", Object.assign({
5107
+ })), jsxs("button", Object.assign({
4968
5108
  className: "close",
4969
5109
  onClick: handleClose
4970
5110
  }, {
@@ -4977,10 +5117,12 @@ const ModalHeader = ({
4977
5117
  }));
4978
5118
  };
4979
5119
  const ModalBody = ({
4980
- children
5120
+ children,
5121
+ id
4981
5122
  }) => {
4982
5123
  return jsx("div", Object.assign({
4983
- className: "body"
5124
+ className: "body",
5125
+ id: id
4984
5126
  }, {
4985
5127
  children: children
4986
5128
  }));
@@ -5019,38 +5161,59 @@ const ModalFooter = ({
5019
5161
  const Modal = _a => {
5020
5162
  var {
5021
5163
  type = 'default',
5022
- isOpen
5164
+ id = randomId(),
5165
+ isOpen,
5166
+ size = 'sm'
5023
5167
  } = _a,
5024
- props = __rest(_a, ["type", "isOpen"]);
5025
- const modalContent = () => {
5026
- switch (type) {
5027
- case 'slideout':
5028
- {
5029
- return jsxs("aside", Object.assign({
5030
- role: "dialog"
5031
- }, {
5032
- children: [jsx(ModalHeader, Object.assign({}, props)), jsx(ModalBody, Object.assign({}, props)), jsx(ModalFooter, Object.assign({}, props))]
5033
- }));
5034
- }
5035
- case 'takeover':
5036
- {
5037
- return jsxs("main", Object.assign({
5038
- role: "dialog"
5039
- }, {
5040
- children: [jsx(ModalHeader, Object.assign({}, props)), jsx(ModalBody, Object.assign({}, props)), jsx(ModalFooter, Object.assign({}, props))]
5041
- }));
5042
- }
5043
- default:
5044
- {
5045
- return jsxs("section", Object.assign({
5046
- role: "dialog"
5047
- }, {
5048
- children: [jsx(ModalHeader, Object.assign({}, props)), jsx(ModalBody, Object.assign({}, props)), jsx(ModalFooter, Object.assign({}, props))]
5049
- }));
5050
- }
5051
- }
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
5052
5179
  };
5053
- return isOpen ? modalContent() : null;
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
+ }
5054
5217
  };
5055
5218
 
5056
- export { Accordion, AlertRibbon as Alert, AlertRibbon, Badge, Button, ButtonGroup, Card, Checkbox, CoreDropdown, CoreOption, Datepicker, Dropdown, EmailInput, Flexbox, Form, FormItem, FormItems, Group, 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.0.0",
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.0",
10
- "@sebgroup/chlorophyll": "^2.0.1",
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
  },
package/src/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from './lib/dropdown/dropdown';
7
7
  export * from './lib/form';
8
8
  export * from './lib/formItem';
9
9
  export * from './lib/layout';
10
+ export * from './lib/in-page-wizard';
10
11
  export * from './lib/link/link';
11
12
  export * from './lib/list';
12
13
  export * from './lib/navbar/navbar';
@@ -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>;
@@ -0,0 +1,2 @@
1
+ import { IconProps } from '../../types/props';
2
+ export declare const Edit: ({ focusable, title, fill, width, height, ...props }: IconProps) => import("react/jsx-runtime").JSX.Element;
@@ -5,3 +5,4 @@ export * from './square-exclamation';
5
5
  export * from './square-info';
6
6
  export * from './times';
7
7
  export * from './infoCircle';
8
+ export * from './edit';
@@ -0,0 +1,16 @@
1
+ import { ReactNode } from 'react';
2
+ export interface InPageWizardStepCardProps {
3
+ stepText: string;
4
+ title: string;
5
+ editBtnText: string;
6
+ nextBtnText: string;
7
+ nextBtnIcon?: ReactNode;
8
+ stepStatus: WizardStepStatus;
9
+ hideFooter?: boolean;
10
+ children: React.ReactNode;
11
+ onNextClick: () => void;
12
+ onEditClick: () => void;
13
+ dataTestid?: string;
14
+ }
15
+ export declare type WizardStepStatus = 'NotStarted' | 'IsActive' | 'IsComplete';
16
+ export declare const InPageWizardStepCard: (props: InPageWizardStepCardProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from './inPageWizardStepCard';
@@ -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;
@@ -2,6 +2,8 @@ export interface IconProps {
2
2
  focusable?: boolean;
3
3
  title?: string;
4
4
  fill?: string;
5
+ width?: number;
6
+ height?: number;
5
7
  'aria-hidden'?: boolean;
6
8
  }
7
9
  export interface SelectorAttributesProps {