@sebgroup/green-react 3.18.0 → 3.19.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/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.18.0",
5
+ "version": "3.19.0",
6
6
  "peerDependencies": {
7
7
  "react": "^17 || ^18",
8
8
  "react-dom": "^17 || ^18"
9
9
  },
10
10
  "dependencies": {
11
- "@sebgroup/green-core": "^1.41.2",
11
+ "@sebgroup/green-core": "^1.41.3",
12
12
  "@sebgroup/chlorophyll": "^3.6.2",
13
13
  "@sebgroup/extract": "^3.0.1",
14
14
  "@lit/react": "^1.0.2",
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import { GdsDatepicker } from '@sebgroup/green-core/components/datepicker/index.js';
2
3
  import { GdsValidator } from '@sebgroup/green-core/components/form/form-control';
3
4
  export declare const CoreDatepicker: import("@lit/react").ReactWebComponent<GdsDatepicker, {
@@ -11,35 +12,35 @@ export type DatepickerOptions = {
11
12
  /**
12
13
  * Whether to disable weekends in the calendar.
13
14
  */
14
- disabledWeekends: boolean;
15
+ disabledWeekends?: boolean;
15
16
  /**
16
17
  * Whether to hide the label above the input field.
17
18
  */
18
- hideLabel: boolean;
19
+ hideLabel?: boolean;
19
20
  /**
20
21
  * Validation state of the form control. Setting this to true triggers the invalid state of the control.
21
22
  */
22
- invalid: boolean;
23
+ invalid?: boolean;
23
24
  /**
24
25
  * Validate the form control element. Should return the validity state and an optional validation message.
25
26
  */
26
- validator: GdsValidator;
27
+ validator?: GdsValidator;
27
28
  /**
28
29
  * The label text displayed above the datepicker. This should always be set to a descriptive label.
29
30
  */
30
- label: string;
31
+ label?: string;
31
32
  /**
32
33
  * The maximum date that can be selected.
33
34
  */
34
- maxDate: Date;
35
+ maxDate?: Date;
35
36
  /**
36
37
  * The minimum date that can be selected.
37
38
  */
38
- minDate: Date;
39
+ minDate?: Date;
39
40
  /**
40
41
  * Controls whether the datepicker popover is open.
41
42
  */
42
- open: boolean;
43
+ open?: boolean;
43
44
  /**
44
45
  * Callback function that is called when the value of the Datepicker changes.
45
46
  */
@@ -47,15 +48,15 @@ export type DatepickerOptions = {
47
48
  /**
48
49
  * Sets the datepicker as a required field for forms.
49
50
  */
50
- required: boolean;
51
+ required?: boolean;
51
52
  /**
52
53
  * Whether to show a column of week numbers in the calendar.
53
54
  */
54
- showWeeks: boolean;
55
+ showWeeks?: boolean;
55
56
  /**
56
57
  * Whether to use the small variant of the datepicker field.
57
58
  */
58
- size: 'small' | 'medium';
59
+ size?: 'small' | 'medium';
59
60
  /**
60
61
  * The test ID used for testing.
61
62
  */
@@ -65,6 +66,14 @@ export type DatepickerOptions = {
65
66
  * This can be a string if set via the value attribute in markup, or via the setAttribute DOM API.
66
67
  */
67
68
  value?: Date;
69
+ /**
70
+ * The ref to the datepicker element.
71
+ */
72
+ ref?: React.Ref<GdsDatepicker>;
73
+ /**
74
+ * The children of the datepicker.
75
+ */
76
+ children?: React.ReactNode;
68
77
  /**
69
78
  * @deprecated Use `value` instead.
70
79
  */
@@ -74,5 +83,5 @@ export type DatepickerOptions = {
74
83
  */
75
84
  currentDate?: Date;
76
85
  };
77
- export declare const Datepicker: ({ label, onChange, minDate, maxDate, value, showWeeks, testId, validator, selectedDate, currentDate, ...props }: DatepickerOptions) => import("react/jsx-runtime").JSX.Element;
86
+ export declare const Datepicker: React.ForwardRefExoticComponent<Omit<DatepickerOptions, "ref"> & React.RefAttributes<unknown>>;
78
87
  export default Datepicker;
@@ -1,6 +1,6 @@
1
1
  import { _ as __rest } from '../../../_tslib.js';
2
2
  import { jsx } from 'react/jsx-runtime';
3
- import React, { useEffect } from 'react';
3
+ import React, { forwardRef, useRef, useImperativeHandle, useEffect } from 'react';
4
4
  import { createComponent } from '@lit/react';
5
5
  import { GdsDatepicker } from '@sebgroup/green-core/components/datepicker/index.js';
6
6
  import { getScopedTagName } from '@sebgroup/green-core/scoping';
@@ -15,7 +15,7 @@ var CoreDatepicker = createComponent({
15
15
  },
16
16
  react: React
17
17
  });
18
- var Datepicker = function Datepicker(_a) {
18
+ var Datepicker = /*#__PURE__*/forwardRef(function (_a, ref) {
19
19
  var _a$label = _a.label,
20
20
  label = _a$label === void 0 ? 'Date' : _a$label,
21
21
  onChange = _a.onChange,
@@ -37,10 +37,13 @@ var Datepicker = function Datepicker(_a) {
37
37
  onChange(e.detail.value);
38
38
  }
39
39
  };
40
- var ref = React.useRef(null);
40
+ var _ref = useRef(null);
41
+ useImperativeHandle(ref, function () {
42
+ return _ref.current;
43
+ }, [_ref]);
41
44
  useEffect(function () {
42
- if (ref.current) {
43
- ref.current.validator = validator;
45
+ if (_ref === null || _ref === void 0 ? void 0 : _ref.current) {
46
+ _ref.current.validator = validator;
44
47
  }
45
48
  }, [validator]);
46
49
  return jsx("div", {
@@ -53,9 +56,9 @@ var Datepicker = function Datepicker(_a) {
53
56
  showWeekNumbers: showWeeks,
54
57
  onchange: onChangeHandler,
55
58
  value: value,
56
- ref: ref
59
+ ref: _ref
57
60
  }, props))
58
61
  });
59
- };
62
+ });
60
63
 
61
64
  export { CoreDatepicker, Datepicker, Datepicker as default };
@@ -10,5 +10,5 @@ export interface ButtonProps extends DetailedHTMLProps<ButtonHTMLAttributes<HTML
10
10
  /** Renders as a `data-testid` attribute on the `<button>` element, useful in testing scenarios. */
11
11
  testId?: string;
12
12
  }
13
- export declare function Button({ className, variant, active, type, size, testId, ...otherProps }: ButtonProps): import("react/jsx-runtime").JSX.Element;
13
+ export declare const Button: import("react").ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
14
14
  export default Button;
@@ -1,8 +1,9 @@
1
1
  import { _ as __rest } from '../../../../_tslib.js';
2
2
  import { jsx } from 'react/jsx-runtime';
3
+ import { forwardRef } from 'react';
3
4
  import classNames from 'classnames';
4
5
 
5
- function Button(_a) {
6
+ var Button = /*#__PURE__*/forwardRef(function (_a, ref) {
6
7
  var _b;
7
8
  var className = _a.className,
8
9
  variant = _a.variant,
@@ -12,21 +13,23 @@ function Button(_a) {
12
13
  type = _a$type === void 0 ? 'button' : _a$type,
13
14
  size = _a.size,
14
15
  testId = _a.testId,
15
- otherProps = __rest(_a, ["className", "variant", "active", "type", "size", "testId"]);
16
+ props = __rest(_a, ["className", "variant", "active", "type", "size", "testId"]);
16
17
  var buttonClassName = classNames(className, variant, size, {
17
18
  active: active
18
19
  }) || undefined;
19
20
  return variant == 'close' ? jsx("button", Object.assign({
20
21
  className: buttonClassName,
21
- "aria-label": (_b = otherProps['aria-label']) !== null && _b !== void 0 ? _b : 'Close',
22
- "data-testid": testId
23
- }, otherProps, {
22
+ "aria-label": (_b = props['aria-label']) !== null && _b !== void 0 ? _b : 'Close',
23
+ "data-testid": testId,
24
+ ref: ref
25
+ }, props, {
24
26
  children: jsx("i", {})
25
27
  })) : jsx("button", Object.assign({
26
28
  className: buttonClassName,
27
29
  type: type,
28
- "data-testid": testId
29
- }, otherProps));
30
- }
30
+ "data-testid": testId,
31
+ ref: ref
32
+ }, props));
33
+ });
31
34
 
32
35
  export { Button, Button as default };
@@ -1,4 +1,5 @@
1
1
  export { Button } from './button.js';
2
2
  import '../../../../_tslib.js';
3
3
  import 'react/jsx-runtime';
4
+ import 'react';
4
5
  import 'classnames';
@@ -1,8 +1,8 @@
1
1
  import { _ as _slicedToArray } from '../../../../_rollupPluginBabelHelpers.js';
2
+ import { _ as __rest } from '../../../../_tslib.js';
2
3
  import { jsx } from 'react/jsx-runtime';
3
4
  import { useState, useEffect } from 'react';
4
5
  import { Button } from '../button/button.js';
5
- import '../../../../_tslib.js';
6
6
  import '@sebgroup/extract';
7
7
  import classNames from 'classnames';
8
8
  import { Group } from '../group/group.js';
@@ -43,8 +43,10 @@ var ButtonGroup = function ButtonGroup(_ref) {
43
43
  return jsx(Group, {
44
44
  "data-label": "button-group",
45
45
  id: id,
46
- children: buttons.map(function (props) {
47
- return jsx(Button, Object.assign({}, props), props.key);
46
+ children: buttons.map(function (_a) {
47
+ var key = _a.key,
48
+ props = __rest(_a, ["key"]);
49
+ return jsx(Button, Object.assign({}, props), key);
48
50
  })
49
51
  });
50
52
  };
@@ -1,9 +1,9 @@
1
1
  export { ButtonGroup } from './buttonGroup.js';
2
2
  import '../../../../_rollupPluginBabelHelpers.js';
3
+ import '../../../../_tslib.js';
3
4
  import 'react/jsx-runtime';
4
5
  import 'react';
5
6
  import '../button/button.js';
6
- import '../../../../_tslib.js';
7
7
  import 'classnames';
8
8
  import '@sebgroup/extract';
9
9
  import '../group/group.js';
@@ -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: ({ "aria-describedby": ariaDescribedBy, id, label, validator, testId, required, className, ...props }: CheckboxProps) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const Checkbox: import("react").ForwardRefExoticComponent<Omit<CheckboxProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
@@ -3,9 +3,9 @@ import { _ as __rest } from '../../../../_tslib.js';
3
3
  import { jsxs, jsx } from 'react/jsx-runtime';
4
4
  import { randomId, validateClassName } from '@sebgroup/extract';
5
5
  import classNames from 'classnames';
6
- import { useState } from 'react';
6
+ import { forwardRef, useState } from 'react';
7
7
 
8
- var Checkbox = function Checkbox(_a) {
8
+ var Checkbox = /*#__PURE__*/forwardRef(function (_a, ref) {
9
9
  var ariaDescribedBy = _a['aria-describedby'],
10
10
  _a$id = _a.id,
11
11
  id = _a$id === void 0 ? randomId() : _a$id,
@@ -35,7 +35,8 @@ var Checkbox = function Checkbox(_a) {
35
35
  type: "checkbox",
36
36
  "data-testid": testId,
37
37
  id: uuid,
38
- required: required
38
+ required: required,
39
+ ref: ref
39
40
  }, props)), jsx("i", {})]
40
41
  }), validator && jsx("span", {
41
42
  className: "form-info",
@@ -43,6 +44,6 @@ var Checkbox = function Checkbox(_a) {
43
44
  children: validator.message
44
45
  })]
45
46
  });
46
- };
47
+ });
47
48
 
48
49
  export { Checkbox };
@@ -9,5 +9,5 @@ interface IconButtonInterface {
9
9
  size?: 'small' | 'normal';
10
10
  title?: string;
11
11
  }
12
- export declare const IconButton: ({ children, onClick, ...props }: IconButtonInterface) => import("react/jsx-runtime").JSX.Element;
12
+ export declare const IconButton: import("react").ForwardRefExoticComponent<IconButtonInterface & import("react").RefAttributes<HTMLButtonElement>>;
13
13
  export {};
@@ -1,7 +1,8 @@
1
1
  import { _ as __rest } from '../../../../_tslib.js';
2
2
  import { jsx } from 'react/jsx-runtime';
3
+ import { forwardRef } from 'react';
3
4
 
4
- var IconButton = function IconButton(_a) {
5
+ var IconButton = /*#__PURE__*/forwardRef(function (_a, ref) {
5
6
  var _b;
6
7
  var children = _a.children,
7
8
  onClick = _a.onClick,
@@ -12,9 +13,9 @@ var IconButton = function IconButton(_a) {
12
13
  "aria-controls": props['aria-controls'],
13
14
  "aria-expanded": props['aria-expanded'],
14
15
  type: (_b = props.type) !== null && _b !== void 0 ? _b : 'button',
15
- title: props.title,
16
+ ref: ref,
16
17
  children: children
17
18
  });
18
- };
19
+ });
19
20
 
20
21
  export { IconButton };
@@ -1,3 +1,4 @@
1
1
  export { IconButton } from './iconButton.js';
2
2
  import '../../../../_tslib.js';
3
3
  import 'react/jsx-runtime';
4
+ import 'react';
@@ -12,9 +12,9 @@ export { RadioGroup } from './radioButton/radioGroup.js';
12
12
  export { TextArea } from './textarea/textarea.js';
13
13
  import '../../../_tslib.js';
14
14
  import 'react/jsx-runtime';
15
+ import 'react';
15
16
  import 'classnames';
16
17
  import '../../../_rollupPluginBabelHelpers.js';
17
- import 'react';
18
18
  import '@sebgroup/extract';
19
19
  import './formContext.js';
20
20
  import './validateInput.js';
@@ -13,14 +13,18 @@ export interface InputProps extends IExpandableInformation, DetailedHTMLProps<In
13
13
  unit?: string;
14
14
  /** Validation object */
15
15
  validator?: IValidator;
16
- /** Value of input */
16
+ /**
17
+ * Value of input
18
+ */
17
19
  value?: string | number;
18
20
  /** Function called when input value changes */
19
21
  onChangeInput?: (value: string) => string;
22
+ /** Pass an string that is an id to another element describing the input-field*/
23
+ 'aria-describedby'?: string;
20
24
  }
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
- export declare const TextInput: (props: Omit<InputProps, 'type'>) => import("react/jsx-runtime").JSX.Element;
23
- export declare const EmailInput: (props: Omit<InputProps, 'type'>) => import("react/jsx-runtime").JSX.Element;
24
- export declare const NumberInput: (props: Omit<InputProps, 'type'>) => import("react/jsx-runtime").JSX.Element;
25
+ export declare const Input: import("react").ForwardRefExoticComponent<Omit<InputProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
26
+ export declare const TextInput: import("react").ForwardRefExoticComponent<Omit<Omit<InputProps, "type">, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
27
+ export declare const EmailInput: import("react").ForwardRefExoticComponent<Omit<Omit<InputProps, "type">, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
28
+ export declare const NumberInput: import("react").ForwardRefExoticComponent<Omit<Omit<InputProps, "type">, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
25
29
  export { RadioButton } from '../radioButton/radioButton';
26
30
  export { Checkbox } from '../checkbox/checkbox';
@@ -1,7 +1,7 @@
1
1
  import { _ as _slicedToArray, a as _defineProperty } from '../../../../_rollupPluginBabelHelpers.js';
2
2
  import { _ as __rest } from '../../../../_tslib.js';
3
3
  import { jsx, jsxs } from 'react/jsx-runtime';
4
- import { useState, useEffect, useCallback } from 'react';
4
+ import { forwardRef, useState, useEffect, useCallback } from 'react';
5
5
  import { randomId, validateClassName } from '@sebgroup/extract';
6
6
  import { FormItem } from '../../formItem/formItem.js';
7
7
  import { Group } from '../group/group.js';
@@ -13,7 +13,7 @@ import '../../icons/times.js';
13
13
  import '../../icons/infoCircle.js';
14
14
  import '../useInput.js';
15
15
 
16
- var Input = function Input(_a) {
16
+ var Input = /*#__PURE__*/forwardRef(function (_a, ref) {
17
17
  var ariaDescribedBy = _a['aria-describedby'],
18
18
  _a$autoComplete = _a.autoComplete,
19
19
  autoComplete = _a$autoComplete === void 0 ? 'off' : _a$autoComplete,
@@ -77,7 +77,8 @@ var Input = function Input(_a) {
77
77
  onChange: handleChange,
78
78
  role: role,
79
79
  value: localValue,
80
- required: required
80
+ required: required,
81
+ ref: ref
81
82
  }, props));
82
83
  if (showSimpleInput) return input;
83
84
  var spanClassName = classNames('form-text', {
@@ -104,21 +105,27 @@ var Input = function Input(_a) {
104
105
  })
105
106
  })
106
107
  });
107
- };
108
- var TextInput = function TextInput(props) {
108
+ });
109
+ var TextInput = /*#__PURE__*/forwardRef(function (props, ref) {
109
110
  return jsx(Input, Object.assign({
110
111
  type: "text"
111
- }, props));
112
- };
113
- var EmailInput = function EmailInput(props) {
112
+ }, props, {
113
+ ref: ref
114
+ }));
115
+ });
116
+ var EmailInput = /*#__PURE__*/forwardRef(function (props, ref) {
114
117
  return jsx(Input, Object.assign({
115
118
  type: "email"
116
- }, props));
117
- };
118
- var NumberInput = function NumberInput(props) {
119
+ }, props, {
120
+ ref: ref
121
+ }));
122
+ });
123
+ var NumberInput = /*#__PURE__*/forwardRef(function (props, ref) {
119
124
  return jsx(Input, Object.assign({
120
125
  type: "number"
121
- }, props));
122
- };
126
+ }, props, {
127
+ ref: ref
128
+ }));
129
+ });
123
130
 
124
131
  export { EmailInput, Input, NumberInput, TextInput };
@@ -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, required, ...props }: ITextAreaProps) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const TextArea: import("react").ForwardRefExoticComponent<Omit<ITextAreaProps, "ref"> & import("react").RefAttributes<HTMLTextAreaElement>>;
@@ -2,14 +2,14 @@ import { _ as _slicedToArray, a as _defineProperty } from '../../../../_rollupPl
2
2
  import { _ as __rest } from '../../../../_tslib.js';
3
3
  import { jsx } from 'react/jsx-runtime';
4
4
  import { randomId, validateClassName } from '@sebgroup/extract';
5
- import { useState, useEffect, useCallback } from 'react';
5
+ import { forwardRef, useState, useEffect, useCallback } from 'react';
6
6
  import { FormItem } from '../../formItem/formItem.js';
7
7
  import classNames from 'classnames';
8
8
  import '../iconButton/iconButton.js';
9
9
  import '../../icons/times.js';
10
10
  import '../../icons/infoCircle.js';
11
11
 
12
- var TextArea = function TextArea(_a) {
12
+ var TextArea = /*#__PURE__*/forwardRef(function (_a, ref) {
13
13
  var ariaDescribedBy = _a['aria-describedby'],
14
14
  _a$autoComplete = _a.autoComplete,
15
15
  autoComplete = _a$autoComplete === void 0 ? 'off' : _a$autoComplete,
@@ -71,10 +71,11 @@ var TextArea = function TextArea(_a) {
71
71
  value: localValue,
72
72
  "data-testid": dataTestId,
73
73
  maxLength: maxLength,
74
- required: required
74
+ required: required,
75
+ ref: ref
75
76
  }, props))
76
77
  })
77
78
  });
78
- };
79
+ });
79
80
 
80
81
  export { TextArea };
@@ -1,9 +1,9 @@
1
1
  import { _ as _slicedToArray, b as _asyncToGenerator, c as _regeneratorRuntime } from '../../../_rollupPluginBabelHelpers.js';
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import '../../../_tslib.js';
4
+ import { useRef, useState, useLayoutEffect, useEffect } from 'react';
4
5
  import classNames from 'classnames';
5
6
  import { IconButton } from '../form/iconButton/iconButton.js';
6
- import { useRef, useState, useLayoutEffect, useEffect } from 'react';
7
7
  import { debounce, randomId, validateClassName, delay } from '@sebgroup/extract';
8
8
  import { Times } from '../icons/times.js';
9
9
  import { InfoCircle } from '../icons/infoCircle.js';
@@ -2,9 +2,9 @@ export { FormItem } from './formItem.js';
2
2
  import '../../../_rollupPluginBabelHelpers.js';
3
3
  import 'react/jsx-runtime';
4
4
  import '../../../_tslib.js';
5
+ import 'react';
5
6
  import 'classnames';
6
7
  import '../form/iconButton/iconButton.js';
7
- import 'react';
8
8
  import '@sebgroup/extract';
9
9
  import '../icons/times.js';
10
10
  import '../icons/infoCircle.js';