@festo-ui/react 9.0.0-dev.661 → 9.0.0-dev.663

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/index.d.ts CHANGED
@@ -33,7 +33,7 @@ export { default as Progress } from "./lib/components/progress/Progress";
33
33
  export { default as SearchInput } from "./lib/components/search-input/SearchInput";
34
34
  export { default as SearchSuggestion } from "./lib/components/search-input/SearchSuggestion";
35
35
  export { default as Snackbar } from "./lib/components/snackbar/Snackbar";
36
- export { default as SnackbarProvider } from "./lib/components/snackbar/SnackbarProvider";
36
+ export { default as SnackbarProvider, addSnackbar, } from "./lib/components/snackbar/SnackbarProvider";
37
37
  export { default as useSnackbar } from "./lib/components/snackbar/useSnackbar";
38
38
  export { default as StepHorizontal } from "./lib/components/stepper-horizontal/step-horizontal/StepHorizontal";
39
39
  export { default as StepperHorizontal } from "./lib/components/stepper-horizontal/StepperHorizontal";
package/index.js CHANGED
@@ -33,7 +33,7 @@ export { default as Progress } from "./lib/components/progress/Progress.js";
33
33
  export { default as SearchInput } from "./lib/components/search-input/SearchInput.js";
34
34
  export { default as SearchSuggestion } from "./lib/components/search-input/SearchSuggestion.js";
35
35
  export { default as Snackbar } from "./lib/components/snackbar/Snackbar.js";
36
- export { default as SnackbarProvider } from "./lib/components/snackbar/SnackbarProvider.js";
36
+ export { default as SnackbarProvider, addSnackbar } from "./lib/components/snackbar/SnackbarProvider.js";
37
37
  export { default as useSnackbar } from "./lib/components/snackbar/useSnackbar.js";
38
38
  export { default as StepHorizontal } from "./lib/components/stepper-horizontal/step-horizontal/StepHorizontal.js";
39
39
  export { default as StepperHorizontal } from "./lib/components/stepper-horizontal/StepperHorizontal.js";
@@ -1,7 +1,8 @@
1
1
  import { ClassNamePropsWithChildren } from "../../helper/types";
2
- import { SnackbarConfig } from "./Snackbar";
2
+ import { SnackbarConfig, SnackbarData } from "./Snackbar";
3
3
  interface SnackbarProviderProps extends ClassNamePropsWithChildren {
4
4
  config?: SnackbarConfig;
5
5
  }
6
6
  declare function SnackbarProvider(props: SnackbarProviderProps): import("react/jsx-runtime").JSX.Element;
7
7
  export default SnackbarProvider;
8
+ export declare const addSnackbar: (snackData: SnackbarData, onAction?: () => void, onClose?: () => void) => string | number;
@@ -3,6 +3,7 @@ import classNames from "classnames";
3
3
  import Snackbar from "./Snackbar.js";
4
4
  import SnackbarContext from "./SnackbarContext.js";
5
5
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
+ let addSnackbarFunction;
6
7
  function SnackbarProvider(props) {
7
8
  const {
8
9
  config = {
@@ -26,6 +27,7 @@ function SnackbarProvider(props) {
26
27
  }, ...prevSnacks]);
27
28
  return key;
28
29
  }, [config]);
30
+ addSnackbarFunction = addSnackbar;
29
31
  function closeSnackbar(key) {
30
32
  if (key !== undefined) {
31
33
  setSnacks(prevSnacks => prevSnacks.filter(snack => snack.key !== key));
@@ -54,4 +56,10 @@ function SnackbarProvider(props) {
54
56
  })]
55
57
  });
56
58
  }
57
- export default SnackbarProvider;
59
+ export default SnackbarProvider;
60
+ export const addSnackbar = (snackData, onAction, onClose) => {
61
+ if (!addSnackbarFunction) {
62
+ throw new Error("SnackbarProvider is not mounted.");
63
+ }
64
+ return addSnackbarFunction(snackData, onAction, onClose);
65
+ };
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
- import { ClassNameProps } from "../../helper/types";
2
+ import type { ClassNameProps } from "../../helper/types";
3
3
  import "./TextArea.scss";
4
- interface TextAreaProps extends ClassNameProps {
4
+ export interface TextAreaProps extends ClassNameProps {
5
5
  disabled?: boolean;
6
6
  required?: boolean;
7
7
  readonly?: boolean;
@@ -14,9 +14,10 @@ interface TextAreaProps extends ClassNameProps {
14
14
  error?: string;
15
15
  value?: string;
16
16
  defaultValue?: string;
17
+ name?: string;
17
18
  rows?: number;
18
19
  maxLength?: number;
19
20
  id?: string;
20
21
  }
21
- declare function TextArea({ disabled, onBlur, onChange, onFocus, onInput, readonly, required, label, error, hint, value, rows, maxLength, className, id: idProps, defaultValue, }: TextAreaProps): import("react/jsx-runtime").JSX.Element;
22
+ declare function TextArea({ disabled, onBlur, onChange, onFocus, onInput, readonly, required, label, error, hint, value, defaultValue, name, rows, maxLength, className, id: idProps, }: Readonly<TextAreaProps>): import("react/jsx-runtime").JSX.Element;
22
23
  export default TextArea;
@@ -15,11 +15,12 @@ function TextArea(_ref) {
15
15
  error,
16
16
  hint,
17
17
  value,
18
+ defaultValue,
19
+ name,
18
20
  rows,
19
- maxLength = 0,
21
+ maxLength,
20
22
  className,
21
- id: idProps,
22
- defaultValue
23
+ id: idProps
23
24
  } = _ref;
24
25
  const controlled = value !== undefined;
25
26
  const [innerValue, setInnerValue] = useState(controlled ? value : defaultValue);
@@ -43,7 +44,7 @@ function TextArea(_ref) {
43
44
  const newHeight = Math.max(minRows * 24, shadow.scrollHeight);
44
45
  setHeight(newHeight + 4 + 4 + 1);
45
46
  }
46
- }, [innerValue]);
47
+ }, []);
47
48
  function handleChange(event) {
48
49
  if (!controlled) {
49
50
  setInnerValue(event.target.value);
@@ -63,6 +64,7 @@ function TextArea(_ref) {
63
64
  })
64
65
  },
65
66
  ref: ref,
67
+ name: name,
66
68
  className: classNames("fr-textarea", `fwe-row-${rows}`),
67
69
  disabled: disabled,
68
70
  readOnly: readonly,
@@ -73,8 +75,8 @@ function TextArea(_ref) {
73
75
  onInput: onInput,
74
76
  onBlur: onBlur,
75
77
  maxLength: maxLength,
76
- defaultValue: innerValue,
77
- value: innerValue,
78
+ defaultValue: defaultValue,
79
+ value: value,
78
80
  id: id
79
81
  }), /*#__PURE__*/_jsx("textarea", {
80
82
  style: {
@@ -98,7 +100,7 @@ function TextArea(_ref) {
98
100
  }), error !== undefined && /*#__PURE__*/_jsx("span", {
99
101
  className: "fwe-input-text-invalid",
100
102
  children: error
101
- }), maxLength > 0 && innerValue !== undefined && /*#__PURE__*/_jsxs("span", {
103
+ }), !!maxLength && innerValue !== undefined && /*#__PURE__*/_jsxs("span", {
102
104
  className: "fwe-input-text-count",
103
105
  children: [innerValue.length, " /", maxLength]
104
106
  })]
@@ -1,5 +1,5 @@
1
- import React from "react";
2
- interface TextInputProps {
1
+ import type React from "react";
2
+ export interface TextInputProps {
3
3
  disabled?: boolean;
4
4
  required?: boolean;
5
5
  readonly?: boolean;
@@ -9,6 +9,8 @@ interface TextInputProps {
9
9
  min?: number;
10
10
  max?: number;
11
11
  value?: string;
12
+ defaultValue?: string;
13
+ name?: string;
12
14
  onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
13
15
  onInput?: (event: React.FormEvent<HTMLInputElement>) => void;
14
16
  onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
@@ -1,4 +1,4 @@
1
- import React, { forwardRef, useEffect, useState, useRef } from "react";
1
+ import { forwardRef, useEffect, useRef } from "react";
2
2
  import classNames from "classnames";
3
3
  import useId from "../../helper/useId.js";
4
4
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -16,6 +16,8 @@ const TextInput = /*#__PURE__*/forwardRef((_ref, ref) => {
16
16
  step,
17
17
  type,
18
18
  value,
19
+ defaultValue,
20
+ name,
19
21
  error,
20
22
  hint,
21
23
  label,
@@ -26,11 +28,7 @@ const TextInput = /*#__PURE__*/forwardRef((_ref, ref) => {
26
28
  ...props
27
29
  } = _ref;
28
30
  const id = useId(idProps);
29
- const [innerValue, setInnerValue] = useState(value);
30
31
  const inputRef = useRef(null);
31
- useEffect(() => {
32
- setInnerValue(value);
33
- }, [value]);
34
32
 
35
33
  // Programmatically focus the input instead of using autoFocus attribute
36
34
  useEffect(() => {
@@ -44,13 +42,12 @@ const TextInput = /*#__PURE__*/forwardRef((_ref, ref) => {
44
42
  return undefined;
45
43
  }, [autoFocus]);
46
44
  const supported = ["text", "number", "password", "datetime-local"];
47
- const innerType = type && supported.indexOf(type) !== -1 ? type : "text";
45
+ const innerType = type && supported.includes(type) ? type : "text";
48
46
  const labelClasses = classNames("fwe-input-text", {
49
47
  "fwe-input-text-icon": icon
50
48
  }, labelClassName);
51
49
  const hintClasses = classNames("fwe-input-text-info");
52
50
  function handleChange(e) {
53
- setInnerValue(e.target.value);
54
51
  if (props.onChange) {
55
52
  props.onChange(e);
56
53
  }
@@ -60,6 +57,7 @@ const TextInput = /*#__PURE__*/forwardRef((_ref, ref) => {
60
57
  htmlFor: id,
61
58
  ref: ref,
62
59
  children: [/*#__PURE__*/_jsx("input", {
60
+ name: name,
63
61
  disabled: disabled,
64
62
  required: required,
65
63
  readOnly: readonly,
@@ -73,7 +71,8 @@ const TextInput = /*#__PURE__*/forwardRef((_ref, ref) => {
73
71
  onFocus: onFocus,
74
72
  onInput: onInput,
75
73
  type: innerType,
76
- value: innerValue,
74
+ value: value,
75
+ defaultValue: defaultValue,
77
76
  id: id,
78
77
  ref: inputRef,
79
78
  ...props
package/node/index.js CHANGED
@@ -381,6 +381,12 @@ Object.defineProperty(exports, "Tooltip", {
381
381
  return _Tooltip.default;
382
382
  }
383
383
  });
384
+ Object.defineProperty(exports, "addSnackbar", {
385
+ enumerable: true,
386
+ get: function () {
387
+ return _SnackbarProvider.addSnackbar;
388
+ }
389
+ });
384
390
  Object.defineProperty(exports, "useSnackbar", {
385
391
  enumerable: true,
386
392
  get: function () {
@@ -422,7 +428,7 @@ var _Progress = _interopRequireDefault(require("./lib/components/progress/Progre
422
428
  var _SearchInput = _interopRequireDefault(require("./lib/components/search-input/SearchInput.js"));
423
429
  var _SearchSuggestion = _interopRequireDefault(require("./lib/components/search-input/SearchSuggestion.js"));
424
430
  var _Snackbar = _interopRequireDefault(require("./lib/components/snackbar/Snackbar.js"));
425
- var _SnackbarProvider = _interopRequireDefault(require("./lib/components/snackbar/SnackbarProvider.js"));
431
+ var _SnackbarProvider = _interopRequireWildcard(require("./lib/components/snackbar/SnackbarProvider.js"));
426
432
  var _useSnackbar = _interopRequireDefault(require("./lib/components/snackbar/useSnackbar.js"));
427
433
  var _StepHorizontal = _interopRequireDefault(require("./lib/components/stepper-horizontal/step-horizontal/StepHorizontal.js"));
428
434
  var _StepperHorizontal = _interopRequireDefault(require("./lib/components/stepper-horizontal/StepperHorizontal.js"));
@@ -3,13 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = exports.addSnackbar = void 0;
7
7
  var _react = require("react");
8
8
  var _classnames = _interopRequireDefault(require("classnames"));
9
9
  var _Snackbar = _interopRequireDefault(require("./Snackbar.js"));
10
10
  var _SnackbarContext = _interopRequireDefault(require("./SnackbarContext.js"));
11
11
  var _jsxRuntime = require("react/jsx-runtime");
12
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ let addSnackbarFunction;
13
14
  function SnackbarProvider(props) {
14
15
  const {
15
16
  config = {
@@ -33,6 +34,7 @@ function SnackbarProvider(props) {
33
34
  }, ...prevSnacks]);
34
35
  return key;
35
36
  }, [config]);
37
+ addSnackbarFunction = addSnackbar;
36
38
  function closeSnackbar(key) {
37
39
  if (key !== undefined) {
38
40
  setSnacks(prevSnacks => prevSnacks.filter(snack => snack.key !== key));
@@ -61,4 +63,11 @@ function SnackbarProvider(props) {
61
63
  })]
62
64
  });
63
65
  }
64
- var _default = exports.default = SnackbarProvider;
66
+ var _default = exports.default = SnackbarProvider;
67
+ const addSnackbar = (snackData, onAction, onClose) => {
68
+ if (!addSnackbarFunction) {
69
+ throw new Error("SnackbarProvider is not mounted.");
70
+ }
71
+ return addSnackbarFunction(snackData, onAction, onClose);
72
+ };
73
+ exports.addSnackbar = addSnackbar;
@@ -24,11 +24,12 @@ function TextArea(_ref) {
24
24
  error,
25
25
  hint,
26
26
  value,
27
+ defaultValue,
28
+ name,
27
29
  rows,
28
- maxLength = 0,
30
+ maxLength,
29
31
  className,
30
- id: idProps,
31
- defaultValue
32
+ id: idProps
32
33
  } = _ref;
33
34
  const controlled = value !== undefined;
34
35
  const [innerValue, setInnerValue] = (0, _react.useState)(controlled ? value : defaultValue);
@@ -52,7 +53,7 @@ function TextArea(_ref) {
52
53
  const newHeight = Math.max(minRows * 24, shadow.scrollHeight);
53
54
  setHeight(newHeight + 4 + 4 + 1);
54
55
  }
55
- }, [innerValue]);
56
+ }, []);
56
57
  function handleChange(event) {
57
58
  if (!controlled) {
58
59
  setInnerValue(event.target.value);
@@ -72,6 +73,7 @@ function TextArea(_ref) {
72
73
  })
73
74
  },
74
75
  ref: ref,
76
+ name: name,
75
77
  className: (0, _classnames.default)("fr-textarea", `fwe-row-${rows}`),
76
78
  disabled: disabled,
77
79
  readOnly: readonly,
@@ -82,8 +84,8 @@ function TextArea(_ref) {
82
84
  onInput: onInput,
83
85
  onBlur: onBlur,
84
86
  maxLength: maxLength,
85
- defaultValue: innerValue,
86
- value: innerValue,
87
+ defaultValue: defaultValue,
88
+ value: value,
87
89
  id: id
88
90
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("textarea", {
89
91
  style: {
@@ -107,7 +109,7 @@ function TextArea(_ref) {
107
109
  }), error !== undefined && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
108
110
  className: "fwe-input-text-invalid",
109
111
  children: error
110
- }), maxLength > 0 && innerValue !== undefined && /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
112
+ }), !!maxLength && innerValue !== undefined && /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
111
113
  className: "fwe-input-text-count",
112
114
  children: [innerValue.length, " /", maxLength]
113
115
  })]
@@ -4,13 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _react = _interopRequireWildcard(require("react"));
7
+ var _react = require("react");
8
8
  var _classnames = _interopRequireDefault(require("classnames"));
9
9
  var _useId = _interopRequireDefault(require("../../helper/useId.js"));
10
10
  var _jsxRuntime = require("react/jsx-runtime");
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
12
  const TextInput = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
15
13
  let {
16
14
  disabled,
@@ -25,6 +23,8 @@ const TextInput = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
25
23
  step,
26
24
  type,
27
25
  value,
26
+ defaultValue,
27
+ name,
28
28
  error,
29
29
  hint,
30
30
  label,
@@ -35,11 +35,7 @@ const TextInput = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
35
35
  ...props
36
36
  } = _ref;
37
37
  const id = (0, _useId.default)(idProps);
38
- const [innerValue, setInnerValue] = (0, _react.useState)(value);
39
38
  const inputRef = (0, _react.useRef)(null);
40
- (0, _react.useEffect)(() => {
41
- setInnerValue(value);
42
- }, [value]);
43
39
 
44
40
  // Programmatically focus the input instead of using autoFocus attribute
45
41
  (0, _react.useEffect)(() => {
@@ -53,13 +49,12 @@ const TextInput = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
53
49
  return undefined;
54
50
  }, [autoFocus]);
55
51
  const supported = ["text", "number", "password", "datetime-local"];
56
- const innerType = type && supported.indexOf(type) !== -1 ? type : "text";
52
+ const innerType = type && supported.includes(type) ? type : "text";
57
53
  const labelClasses = (0, _classnames.default)("fwe-input-text", {
58
54
  "fwe-input-text-icon": icon
59
55
  }, labelClassName);
60
56
  const hintClasses = (0, _classnames.default)("fwe-input-text-info");
61
57
  function handleChange(e) {
62
- setInnerValue(e.target.value);
63
58
  if (props.onChange) {
64
59
  props.onChange(e);
65
60
  }
@@ -69,6 +64,7 @@ const TextInput = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
69
64
  htmlFor: id,
70
65
  ref: ref,
71
66
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
67
+ name: name,
72
68
  disabled: disabled,
73
69
  required: required,
74
70
  readOnly: readonly,
@@ -82,7 +78,8 @@ const TextInput = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
82
78
  onFocus: onFocus,
83
79
  onInput: onInput,
84
80
  type: innerType,
85
- value: innerValue,
81
+ value: value,
82
+ defaultValue: defaultValue,
86
83
  id: id,
87
84
  ref: inputRef,
88
85
  ...props
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@festo-ui/react",
3
- "version": "9.0.0-dev.661",
3
+ "version": "9.0.0-dev.663",
4
4
  "author": "Festo UI (styleguide@festo.com)",
5
5
  "copyright": "Copyright (c) 2025 Festo SE & Co. KG. All rights reserved.",
6
6
  "license": "apache-2.0",