@sebgroup/green-react 3.26.0 → 3.27.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/package.json CHANGED
@@ -2,13 +2,13 @@
2
2
  "name": "@sebgroup/green-react",
3
3
  "main": "./src/index.js",
4
4
  "module": "./src/index.js",
5
- "version": "3.26.0",
5
+ "version": "3.27.1",
6
6
  "peerDependencies": {
7
7
  "react": "^17 || ^18 || ^19",
8
8
  "react-dom": "^17 || ^18 || ^19"
9
9
  },
10
10
  "dependencies": {
11
- "@sebgroup/green-core": "^1.70.0",
11
+ "@sebgroup/green-core": "^1.72.0",
12
12
  "@sebgroup/chlorophyll": "^3.6.16",
13
13
  "@sebgroup/extract": "^3.0.1",
14
14
  "@lit/react": "^1.0.2",
@@ -1,4 +1,4 @@
1
- import React, { AriaAttributes, ReactNode } from 'react';
1
+ import React, { ReactNode } from 'react';
2
2
  import { AlertRibbonType } from '@sebgroup/extract';
3
3
  export interface AlertRibbonProps {
4
4
  children: ReactNode;
@@ -9,7 +9,7 @@ export interface AlertRibbonProps {
9
9
  closeText?: string;
10
10
  onClose?: (event: React.MouseEvent<HTMLButtonElement>) => void;
11
11
  role?: 'alert';
12
- ['aria-live']?: AriaAttributes['aria-live'];
12
+ 'aria-live'?: React.AriaAttributes['aria-live'];
13
13
  closeAriaLabel?: string;
14
14
  }
15
15
  export declare function AlertRibbon({ type, header, footer, children, closeText, isCloseable, onClose, role, 'aria-live': ariaLive, closeAriaLabel, }: AlertRibbonProps): import("react/jsx-runtime").JSX.Element;
@@ -1,26 +1,46 @@
1
1
  import { DetailedHTMLProps, InputHTMLAttributes, ReactNode } from 'react';
2
2
  import { IExpandableInformation, IValidator } from '@sebgroup/extract';
3
3
  export interface InputProps extends IExpandableInformation, DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> {
4
- /** Data test id used for finding elements in test */
4
+ /**
5
+ * Data test id used for finding elements in test
6
+ */
5
7
  testId?: string;
6
- /** Format value on change */
8
+ /**
9
+ * Function to format the value on change
10
+ */
7
11
  formatter?: (value: string) => string;
8
- /** Extra describing text, below the label */
12
+ /**
13
+ * Additional descriptive text displayed below the label
14
+ */
9
15
  info?: ReactNode;
10
- /** Label describing the input */
16
+ /**
17
+ * Label text describing the input field
18
+ */
11
19
  label?: string;
12
- /** Text on the right side of the input, used for unit such as 'kr' or '%' */
20
+ /**
21
+ * Text displayed on the right side of the input, typically used for units like 'kr' or '%'
22
+ */
13
23
  unit?: string;
14
- /** Validation object */
24
+ /**
25
+ * Validation object for input validation
26
+ */
15
27
  validator?: IValidator;
16
28
  /**
17
- * Value of input
29
+ * Current value of the input field
18
30
  */
19
31
  value?: string | number;
20
- /** Function called when input value changes */
32
+ /**
33
+ * Callback function triggered when the input value changes
34
+ */
21
35
  onChangeInput?: (value: string) => string;
22
- /** Pass an string that is an id to another element describing the input-field*/
36
+ /**
37
+ * ID of another element that describes the input field
38
+ */
23
39
  'aria-describedby'?: string;
40
+ /**
41
+ * ARIA live region attribute for the form control footer, affecting how error messages are read by screen readers
42
+ */
43
+ 'aria-live'?: React.AriaAttributes['aria-live'];
24
44
  }
25
45
  export declare const Input: import("react").ForwardRefExoticComponent<Omit<InputProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
26
46
  export declare const TextInput: import("react").ForwardRefExoticComponent<Omit<InputProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
@@ -19,6 +19,8 @@ import '../useInput.js';
19
19
 
20
20
  var Input = /*#__PURE__*/forwardRef(function (_a, ref) {
21
21
  var ariaDescribedBy = _a['aria-describedby'],
22
+ _a$ariaLive = _a['aria-live'],
23
+ ariaLive = _a$ariaLive === void 0 ? 'assertive' : _a$ariaLive,
22
24
  _a$autoComplete = _a.autoComplete,
23
25
  autoComplete = _a$autoComplete === void 0 ? 'off' : _a$autoComplete,
24
26
  children = _a.children,
@@ -39,7 +41,7 @@ var Input = /*#__PURE__*/forwardRef(function (_a, ref) {
39
41
  _a$value = _a.value,
40
42
  value = _a$value === void 0 ? '' : _a$value,
41
43
  required = _a.required,
42
- props = __rest(_a, ['aria-describedby', "autoComplete", "children", "className", "testId", "expandableInfo", "expandableInfoButtonLabel", "formatter", "id", "label", "info", "onChange", "unit", "role", "validator", "onChangeInput", "value", "required"]);
44
+ props = __rest(_a, ['aria-describedby', 'aria-live', "autoComplete", "children", "className", "testId", "expandableInfo", "expandableInfoButtonLabel", "formatter", "id", "label", "info", "onChange", "unit", "role", "validator", "onChangeInput", "value", "required"]);
43
45
  var _useState = useState(id),
44
46
  _useState2 = _slicedToArray(_useState, 1),
45
47
  uuid = _useState2[0];
@@ -68,7 +70,7 @@ var Input = /*#__PURE__*/forwardRef(function (_a, ref) {
68
70
  if (onChangeInput) onChangeInput(formattedValue);
69
71
  }, [formatter, setLocalValue, onChange, onChangeInput]);
70
72
  var showSimpleInput = !label && !info && !expandableInfo;
71
- var describedBy = classNames(ariaDescribedBy, _defineProperty(_defineProperty(_defineProperty({}, "".concat(uuid, "_group-message"), !showSimpleInput && (validator === null || validator === void 0 ? void 0 : validator.message) !== undefined && validator.message.length > 0), "".concat(uuid, "_info"), !showSimpleInput && info), "gds-expandable-info-".concat(uuid), !showSimpleInput && expandableInfo));
73
+ var describedBy = classNames(ariaDescribedBy, _defineProperty(_defineProperty(_defineProperty({}, "".concat(uuid, "_message"), !showSimpleInput), "".concat(uuid, "_info"), !showSimpleInput && info), "gds-expandable-info-".concat(uuid), !showSimpleInput && expandableInfo));
72
74
  var inputClassName = classNames(className, _defineProperty({}, validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator), validator));
73
75
  var input = jsx("input", Object.assign({
74
76
  "aria-describedby": describedBy || undefined,
@@ -96,6 +98,7 @@ var Input = /*#__PURE__*/forwardRef(function (_a, ref) {
96
98
  labelInformation: info,
97
99
  role: role,
98
100
  validator: validator,
101
+ "aria-live": ariaLive,
99
102
  children: jsx("div", {
100
103
  className: "gds-input-wrapper",
101
104
  children: jsxs(Group, {
@@ -1,6 +1,11 @@
1
1
  import React from 'react';
2
2
  import { IExpandableInformation, ILabelAndLabelInformation, IValidator } from '@sebgroup/extract';
3
3
  export interface RadioGroupProps extends IExpandableInformation, ILabelAndLabelInformation {
4
+ /**
5
+ * Set the live region attribute of the form control footer, this will change how error messages are read by screen readers
6
+ * @default 'assertive'
7
+ */
8
+ 'aria-live'?: React.AriaAttributes['aria-live'];
4
9
  label?: string;
5
10
  title?: string;
6
11
  valueSelected?: string;
@@ -12,5 +17,5 @@ export interface RadioGroupProps extends IExpandableInformation, ILabelAndLabelI
12
17
  name?: string;
13
18
  horizontal?: boolean;
14
19
  }
15
- export declare const RadioGroup: ({ defaultSelected, valueSelected, label, title, labelInformation, description, expandableInfo, expandableInfoButtonLabel, validator, onChangeRadio, onChange, name: propName, horizontal, children, }: React.PropsWithChildren<RadioGroupProps>) => import("react/jsx-runtime").JSX.Element;
20
+ export declare const RadioGroup: ({ "aria-live": ariaLive, defaultSelected, valueSelected, label, title, labelInformation, description, expandableInfo, expandableInfoButtonLabel, validator, onChangeRadio, onChange, name: propName, horizontal, children, }: React.PropsWithChildren<RadioGroupProps>) => import("react/jsx-runtime").JSX.Element;
16
21
  export default RadioGroup;
@@ -14,7 +14,8 @@ import '../../icons/times.js';
14
14
  import '../../icons/infoCircle.js';
15
15
 
16
16
  var RadioGroup = function RadioGroup(_ref) {
17
- var defaultSelected = _ref.defaultSelected,
17
+ var ariaLive = _ref['aria-live'],
18
+ defaultSelected = _ref.defaultSelected,
18
19
  valueSelected = _ref.valueSelected,
19
20
  label = _ref.label,
20
21
  title = _ref.title,
@@ -42,7 +43,7 @@ var RadioGroup = function RadioGroup(_ref) {
42
43
  name = _useState6[0];
43
44
  var _useState7 = useState(randomId()),
44
45
  _useState8 = _slicedToArray(_useState7, 1),
45
- uniqueId = _useState8[0];
46
+ uuid = _useState8[0];
46
47
  if (valueSelected !== prevValueSelected) {
47
48
  setSelected(valueSelected);
48
49
  setPrevValueSelected(valueSelected);
@@ -80,14 +81,15 @@ var RadioGroup = function RadioGroup(_ref) {
80
81
  label: labelFromTitle,
81
82
  expandableInfo: expandableInfo,
82
83
  expandableInfoButtonLabel: expandableInfoButtonLabel,
83
- role: 'radiogroup'
84
+ role: 'radiogroup',
85
+ 'aria-live': ariaLive
84
86
  };
85
87
  var radioGroupWrapperClassNames = classNames('gds-radio-group-wrapper', {
86
88
  'gds-radio-group-wrapper--horizontal': horizontal
87
89
  });
88
- var describedBy = classNames(_defineProperty(_defineProperty(_defineProperty({}, "".concat(uniqueId, "_message"), (validator === null || validator === void 0 ? void 0 : validator.message) !== undefined && validator.message.length > 0), "".concat(uniqueId, "_info"), labelInformation), "gds-expandable-info-".concat(uniqueId), expandableInfo));
90
+ var describedBy = classNames(_defineProperty(_defineProperty(_defineProperty({}, "".concat(uuid, "_message"), (validator === null || validator === void 0 ? void 0 : validator.message) !== undefined && validator.message.length > 0), "".concat(uuid, "_info"), labelInformation), "gds-expandable-info-".concat(uuid), expandableInfo));
89
91
  return jsx(FormItem, Object.assign({}, formItemProps, {
90
- inputId: uniqueId,
92
+ inputId: uuid,
91
93
  children: jsx("div", {
92
94
  className: radioGroupWrapperClassNames,
93
95
  children: React.Children.map(children, function (radioButton) {
@@ -1,6 +1,11 @@
1
1
  import { DetailedHTMLProps, ReactNode } from 'react';
2
2
  import { IExpandableInformation, IValidator } from '@sebgroup/extract';
3
3
  export interface ITextAreaProps extends IExpandableInformation, DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement> {
4
+ /**
5
+ * Set the live region attribute of the form control footer, this will change how error messages are read by screen readers
6
+ * @default 'assertive'
7
+ */
8
+ 'aria-live'?: React.AriaAttributes['aria-live'];
4
9
  /** Data test id used for finding elements in test */
5
10
  testId?: string;
6
11
  /** Label describing the textarea */
@@ -14,7 +14,9 @@ import '../../icons/times.js';
14
14
  import '../../icons/infoCircle.js';
15
15
 
16
16
  var TextArea = /*#__PURE__*/forwardRef(function (_a, ref) {
17
- var ariaDescribedBy = _a['aria-describedby'],
17
+ var _a$ariaLive = _a['aria-live'],
18
+ ariaLive = _a$ariaLive === void 0 ? 'assertive' : _a$ariaLive,
19
+ ariaDescribedBy = _a['aria-describedby'],
18
20
  _a$autoComplete = _a.autoComplete,
19
21
  autoComplete = _a$autoComplete === void 0 ? 'off' : _a$autoComplete,
20
22
  className = _a.className,
@@ -33,7 +35,7 @@ var TextArea = /*#__PURE__*/forwardRef(function (_a, ref) {
33
35
  dataTestId = _a.testId,
34
36
  maxLength = _a.maxLength,
35
37
  required = _a.required,
36
- props = __rest(_a, ['aria-describedby', "autoComplete", "className", "expandableInfo", "expandableInfoButtonLabel", "id", "label", "info", "onChange", "role", "rows", "validator", "value", "testId", "maxLength", "required"]);
38
+ props = __rest(_a, ['aria-live', 'aria-describedby', "autoComplete", "className", "expandableInfo", "expandableInfoButtonLabel", "id", "label", "info", "onChange", "role", "rows", "validator", "value", "testId", "maxLength", "required"]);
37
39
  var _useState = useState(id),
38
40
  _useState2 = _slicedToArray(_useState, 1),
39
41
  uuid = _useState2[0];
@@ -52,6 +54,7 @@ var TextArea = /*#__PURE__*/forwardRef(function (_a, ref) {
52
54
  var inputClassName = classNames(className, _defineProperty({}, validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator), validator)) || undefined;
53
55
  var rightAlignedFooterInfo = maxLength ? "".concat((localValue === null || localValue === void 0 ? void 0 : localValue.length) || 0, "/").concat(maxLength) : undefined;
54
56
  return jsx(FormItem, {
57
+ "aria-live": ariaLive,
55
58
  expandableInfo: expandableInfo,
56
59
  expandableInfoButtonLabel: expandableInfoButtonLabel,
57
60
  inputId: uuid,
@@ -135,7 +135,7 @@ var FormItem = function FormItem(_ref) {
135
135
  inert: isHidden ? true : undefined,
136
136
  children: jsxs("div", {
137
137
  ref: expandableInnerRef,
138
- children: [" ", expandableInfo, " "]
138
+ children: [" ", !isHidden && expandableInfo, " "]
139
139
  })
140
140
  }), children, jsxs("div", {
141
141
  className: "gds-form-item__footer",
@@ -1,6 +1,11 @@
1
1
  import React from 'react';
2
2
  import { IExpandableInformation, ILabelAndLabelInformation, IValidator } from '@sebgroup/extract';
3
3
  export interface SelectProps extends IExpandableInformation, ILabelAndLabelInformation, React.DetailedHTMLProps<React.SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement> {
4
+ /**
5
+ * Set the live region attribute of the form control footer, this will change how error messages are read by screen readers
6
+ * @default 'assertive'
7
+ */
8
+ 'aria-live'?: React.AriaAttributes['aria-live'];
4
9
  label: string;
5
10
  info?: string;
6
11
  validator?: IValidator | undefined;
@@ -15,7 +15,9 @@ import '../icons/times.js';
15
15
  import '../icons/infoCircle.js';
16
16
 
17
17
  var Select = /*#__PURE__*/React.forwardRef(function (_a, ref) {
18
- var ariaDescribedBy = _a['aria-describedby'],
18
+ var _a$ariaLive = _a['aria-live'],
19
+ ariaLive = _a$ariaLive === void 0 ? 'assertive' : _a$ariaLive,
20
+ ariaDescribedBy = _a['aria-describedby'],
19
21
  _a$id = _a.id,
20
22
  id = _a$id === void 0 ? randomId() : _a$id,
21
23
  validator = _a.validator,
@@ -25,13 +27,14 @@ var Select = /*#__PURE__*/React.forwardRef(function (_a, ref) {
25
27
  expandableInfo = _a.expandableInfo,
26
28
  expandableInfoButtonLabel = _a.expandableInfoButtonLabel,
27
29
  required = _a.required,
28
- props = __rest(_a, ['aria-describedby', "id", "validator", "label", "info", "testId", "expandableInfo", "expandableInfoButtonLabel", "required"]);
30
+ props = __rest(_a, ['aria-live', 'aria-describedby', "id", "validator", "label", "info", "testId", "expandableInfo", "expandableInfoButtonLabel", "required"]);
29
31
  var _useState = useState(id),
30
32
  _useState2 = _slicedToArray(_useState, 1),
31
33
  uuid = _useState2[0];
32
34
  var selectClassName = classNames('gds-select', _defineProperty({}, "".concat(validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)), validator));
33
35
  var describedBy = classNames(ariaDescribedBy, _defineProperty(_defineProperty(_defineProperty({}, "".concat(uuid, "_message"), (validator === null || validator === void 0 ? void 0 : validator.message) !== undefined && validator.message.length > 0), "".concat(uuid, "_info"), info || props.labelInformation), "gds-expandable-info-".concat(uuid), expandableInfo));
34
36
  return jsx(FormItem, {
37
+ "aria-live": ariaLive,
35
38
  label: label,
36
39
  labelInformation: info !== null && info !== void 0 ? info : props.labelInformation,
37
40
  expandableInfo: expandableInfo,