@nolwenture/formik-jsonschema-form 1.2.0 → 1.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.
@@ -70,7 +70,7 @@ const DateInput = ({ name, label, placeholder, min, max, locale, helpText, disab
70
70
  setError(undefined);
71
71
  setValue(isoDate);
72
72
  }, [name, setFieldTouched, setValue, setError, withinBounds, outOfRangeMessage]);
73
- const openPicker = () => {
73
+ const openPicker = (0, react_1.useCallback)(() => {
74
74
  const el = nativeRef.current;
75
75
  if (!el || disabled || readOnly)
76
76
  return;
@@ -86,7 +86,7 @@ const DateInput = ({ name, label, placeholder, min, max, locale, helpText, disab
86
86
  el.focus();
87
87
  el.click();
88
88
  }
89
- };
89
+ }, [disabled, readOnly]);
90
90
  const handleParseOrError = (0, react_1.useCallback)((raw) => {
91
91
  if (readOnly || disabled)
92
92
  return;
@@ -99,13 +99,13 @@ const DateInput = ({ name, label, placeholder, min, max, locale, helpText, disab
99
99
  setError(invalidMessage);
100
100
  }
101
101
  }, [disabled, readOnly, preferOrder, name, onValueChange, setError, setFieldTouched, invalidMessage]);
102
- const handlePaste = (e) => {
102
+ const handlePaste = (0, react_1.useCallback)((e) => {
103
103
  if (readOnly || disabled)
104
104
  return;
105
105
  e.preventDefault();
106
106
  const text = e.clipboardData.getData("text")?.trim();
107
107
  handleParseOrError(text ?? "");
108
- };
108
+ }, [readOnly, disabled, handleParseOrError]);
109
109
  return ((0, jsx_runtime_1.jsxs)(styledComponents_1.Wrapper, { children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: `${name}-display`, children: label }), (0, jsx_runtime_1.jsxs)(styledComponents_1.Row, { children: [(0, jsx_runtime_1.jsx)(styledComponents_1.DisplayInput, { id: `${name}-display`, type: "text", placeholder: placeholder, autoComplete: "off", inputMode: "numeric", "aria-describedby": helpText ? `${name}-help` : undefined, "aria-invalid": hasExternalError, value: displayValue, onChange: (e) => setDisplayValue(e.target.value), onBlur: (e) => handleParseOrError(e.target.value), onPaste: handlePaste, disabled: disabled || readOnly, readOnly: readOnly }), !readOnly && ((0, jsx_runtime_1.jsx)(styledComponents_1.HiddenNative, { ref: nativeRef, id: `${name}-native`, type: "date", min: min, max: max, value: value ?? "", onChange: (e) => {
110
110
  onValueChange(e.target.value);
111
111
  }, tabIndex: -1, "aria-hidden": "true" })), (0, jsx_runtime_1.jsx)(styledComponents_1.PickerButton, { type: "button", onClick: openPicker, "aria-label": "Date picker", title: "Date picker", disabled: disabled || readOnly, children: (0, jsx_runtime_1.jsx)(fa_1.FaCalendar, {}) })] })] }));
@@ -67,7 +67,7 @@ export const DateInput = ({ name, label, placeholder, min, max, locale, helpText
67
67
  setError(undefined);
68
68
  setValue(isoDate);
69
69
  }, [name, setFieldTouched, setValue, setError, withinBounds, outOfRangeMessage]);
70
- const openPicker = () => {
70
+ const openPicker = useCallback(() => {
71
71
  const el = nativeRef.current;
72
72
  if (!el || disabled || readOnly)
73
73
  return;
@@ -83,7 +83,7 @@ export const DateInput = ({ name, label, placeholder, min, max, locale, helpText
83
83
  el.focus();
84
84
  el.click();
85
85
  }
86
- };
86
+ }, [disabled, readOnly]);
87
87
  const handleParseOrError = useCallback((raw) => {
88
88
  if (readOnly || disabled)
89
89
  return;
@@ -96,13 +96,13 @@ export const DateInput = ({ name, label, placeholder, min, max, locale, helpText
96
96
  setError(invalidMessage);
97
97
  }
98
98
  }, [disabled, readOnly, preferOrder, name, onValueChange, setError, setFieldTouched, invalidMessage]);
99
- const handlePaste = (e) => {
99
+ const handlePaste = useCallback((e) => {
100
100
  if (readOnly || disabled)
101
101
  return;
102
102
  e.preventDefault();
103
103
  const text = e.clipboardData.getData("text")?.trim();
104
104
  handleParseOrError(text ?? "");
105
- };
105
+ }, [readOnly, disabled, handleParseOrError]);
106
106
  return (_jsxs(Wrapper, { children: [_jsx("label", { htmlFor: `${name}-display`, children: label }), _jsxs(Row, { children: [_jsx(DisplayInput, { id: `${name}-display`, type: "text", placeholder: placeholder, autoComplete: "off", inputMode: "numeric", "aria-describedby": helpText ? `${name}-help` : undefined, "aria-invalid": hasExternalError, value: displayValue, onChange: (e) => setDisplayValue(e.target.value), onBlur: (e) => handleParseOrError(e.target.value), onPaste: handlePaste, disabled: disabled || readOnly, readOnly: readOnly }), !readOnly && (_jsx(HiddenNative, { ref: nativeRef, id: `${name}-native`, type: "date", min: min, max: max, value: value ?? "", onChange: (e) => {
107
107
  onValueChange(e.target.value);
108
108
  }, tabIndex: -1, "aria-hidden": "true" })), _jsx(PickerButton, { type: "button", onClick: openPicker, "aria-label": "Date picker", title: "Date picker", disabled: disabled || readOnly, children: _jsx(FaCalendar, {}) })] })] }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nolwenture/formik-jsonschema-form",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Formik form generation from json schema",
5
5
  "author": "anttivikman <antti.vikman@nolwenture.com>",
6
6
  "contributors": [