@nolwenture/formik-jsonschema-form 0.4.2 → 0.6.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.
Files changed (88) hide show
  1. package/README.md +187 -0
  2. package/dist/Form.d.ts +2 -2
  3. package/dist/Form.js +15 -26
  4. package/dist/Form.stories.d.ts +12 -11
  5. package/dist/Form.stories.js +134 -101
  6. package/dist/Form.test.js +3 -3
  7. package/dist/FormEditor.d.ts +3 -3
  8. package/dist/FormEditor.js +14 -59
  9. package/dist/FormEditor.stories.d.ts +5 -4
  10. package/dist/FormEditor.stories.js +3 -16
  11. package/dist/fields/AnyField.d.ts +3 -3
  12. package/dist/fields/AnyField.js +12 -24
  13. package/dist/fields/ArrayField.d.ts +3 -3
  14. package/dist/fields/ArrayField.js +42 -64
  15. package/dist/fields/BooleanField.d.ts +3 -3
  16. package/dist/fields/BooleanField.js +7 -18
  17. package/dist/fields/DateField.d.ts +3 -3
  18. package/dist/fields/DateField.js +7 -18
  19. package/dist/fields/NullField.d.ts +3 -3
  20. package/dist/fields/NullField.js +5 -16
  21. package/dist/fields/NumberField.d.ts +3 -3
  22. package/dist/fields/NumberField.js +3 -14
  23. package/dist/fields/ObjectField.d.ts +3 -3
  24. package/dist/fields/ObjectField.js +43 -46
  25. package/dist/fields/RadioField.d.ts +3 -0
  26. package/dist/fields/RadioField.js +11 -0
  27. package/dist/fields/SchemaField.d.ts +3 -3
  28. package/dist/fields/SchemaField.js +13 -23
  29. package/dist/fields/SearchMultiTagSelectField.d.ts +3 -0
  30. package/dist/fields/SearchMultiTagSelectField.js +14 -0
  31. package/dist/fields/StringField.d.ts +3 -3
  32. package/dist/fields/StringField.js +13 -51
  33. package/dist/fields/ToggleField.d.ts +3 -0
  34. package/dist/fields/ToggleField.js +11 -0
  35. package/dist/fields/index.d.ts +3 -0
  36. package/dist/fields/index.js +3 -0
  37. package/dist/fields/types.js +1 -1
  38. package/dist/formEditorSchemas.d.ts +1 -1
  39. package/dist/formEditorSchemas.js +3 -3
  40. package/dist/hooks/index.d.ts +2 -0
  41. package/dist/hooks/index.js +2 -0
  42. package/dist/hooks/useExtractUiSchema.d.ts +8 -0
  43. package/dist/hooks/useExtractUiSchema.js +22 -0
  44. package/dist/hooks/useSetDefault.d.ts +2 -0
  45. package/dist/hooks/useSetDefault.js +16 -0
  46. package/dist/sampleData/completeSchema.d.ts +3 -0
  47. package/dist/{_sampleData.js → sampleData/completeSchema.js} +28 -97
  48. package/dist/sampleData/conditionsSchema.d.ts +3 -0
  49. package/dist/sampleData/conditionsSchema.js +80 -0
  50. package/dist/sampleData/generatedSchema.d.ts +2 -0
  51. package/dist/sampleData/generatedSchema.js +19 -0
  52. package/dist/sampleData/index.d.ts +5 -0
  53. package/dist/sampleData/index.js +5 -0
  54. package/dist/sampleData/requiredInputSchema.d.ts +3 -0
  55. package/dist/sampleData/requiredInputSchema.js +72 -0
  56. package/dist/sampleData/simpleData.d.ts +7 -0
  57. package/dist/sampleData/simpleData.js +16 -0
  58. package/dist/styledComponents.d.ts +193 -47
  59. package/dist/styledComponents.js +342 -138
  60. package/dist/templates/ArrayFieldTemplate.d.ts +3 -3
  61. package/dist/templates/ArrayFieldTemplate.js +11 -23
  62. package/dist/templates/FieldTemplate.d.ts +3 -3
  63. package/dist/templates/FieldTemplate.js +11 -23
  64. package/dist/templates/ObjectFieldTemplate.d.ts +3 -3
  65. package/dist/templates/ObjectFieldTemplate.js +13 -23
  66. package/dist/types.d.ts +34 -3
  67. package/dist/utils/__tests/getEnums.test.d.ts +1 -0
  68. package/dist/utils/__tests/getEnums.test.js +64 -0
  69. package/dist/utils/__tests/resolveSchema.test.d.ts +1 -0
  70. package/dist/utils/__tests/resolveSchema.test.js +106 -0
  71. package/dist/utils/deepEqual.d.ts +1 -0
  72. package/dist/utils/deepEqual.js +18 -0
  73. package/dist/utils/getEnums.d.ts +10 -0
  74. package/dist/utils/getEnums.js +30 -0
  75. package/dist/utils/getTitleAndDescription.d.ts +12 -0
  76. package/dist/utils/getTitleAndDescription.js +15 -0
  77. package/dist/utils/getTypes.d.ts +5 -0
  78. package/dist/utils/getTypes.js +53 -0
  79. package/dist/utils/index.d.ts +7 -0
  80. package/dist/utils/index.js +14 -0
  81. package/dist/utils/mergeSchemas.d.ts +1 -0
  82. package/dist/utils/mergeSchemas.js +26 -0
  83. package/dist/utils/resolveSchema.d.ts +2 -0
  84. package/dist/utils/resolveSchema.js +68 -0
  85. package/package.json +32 -37
  86. package/dist/_sampleData.d.ts +0 -11
  87. package/dist/utils.d.ts +0 -25
  88. package/dist/utils.js +0 -125
@@ -1,18 +1,3 @@
1
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
2
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
- return cooked;
4
- };
5
- var __assign = (this && this.__assign) || function () {
6
- __assign = Object.assign || function(t) {
7
- for (var s, i = 1, n = arguments.length; i < n; i++) {
8
- s = arguments[i];
9
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
10
- t[p] = s[p];
11
- }
12
- return t;
13
- };
14
- return __assign.apply(this, arguments);
15
- };
16
1
  var __rest = (this && this.__rest) || function (s, e) {
17
2
  var t = {};
18
3
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -25,140 +10,187 @@ var __rest = (this && this.__rest) || function (s, e) {
25
10
  return t;
26
11
  };
27
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { useContext, useState } from "react";
28
14
  import styled from "styled-components";
29
15
  import * as formik from "formik";
30
- import { ArrayFieldButtonPurpose, ObjectFieldButtonPurpose, } from "./types";
31
- import { useContext } from "react";
32
16
  import { FormRegistry } from "./Form";
33
- export var Form = styled(formik.Form)(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])));
34
- export var FormButtonWrapper = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])));
35
- export var FormButton = styled.button(templateObject_3 || (templateObject_3 = __makeTemplateObject([""], [""])));
36
- export var ObjectFieldWrapper = styled.fieldset(templateObject_4 || (templateObject_4 = __makeTemplateObject([""], [""])));
37
- export var ObjectFieldTitle = styled.legend(templateObject_5 || (templateObject_5 = __makeTemplateObject([""], [""])));
38
- export var ObjectFieldList = styled.ul(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n list-style-type: none;\n padding: 0;\n"], ["\n list-style-type: none;\n padding: 0;\n"])));
39
- export var ObjectFieldItem = styled.li(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n display: flex;\n"], ["\n display: flex;\n"])));
40
- export var ObjectFieldItemButtons = styled.div(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n display: flex;\n margin: 0.5rem;\n"], ["\n display: flex;\n margin: 0.5rem;\n"])));
41
- export var ObjectFieldButton = styled.a(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n cursor: pointer;\n border: 1px solid black;\n line-height: 1em;\n height: 1em;\n padding: 0 0.3em;\n"], ["\n cursor: pointer;\n border: 1px solid black;\n line-height: 1em;\n height: 1em;\n padding: 0 0.3em;\n"])));
42
- export var ObjectFieldLineButton = styled(ObjectFieldButton)(templateObject_10 || (templateObject_10 = __makeTemplateObject([""], [""])));
43
- export var ObjectFieldUpButton = styled(ObjectFieldLineButton)(templateObject_11 || (templateObject_11 = __makeTemplateObject([""], [""])));
44
- export var ObjectFieldDownButton = styled(ObjectFieldLineButton)(templateObject_12 || (templateObject_12 = __makeTemplateObject([""], [""])));
45
- export var ObjectFieldRemoveButton = styled(ObjectFieldLineButton)(templateObject_13 || (templateObject_13 = __makeTemplateObject([""], [""])));
46
- export var ObjectFieldAddButton = styled(ObjectFieldButton)(templateObject_14 || (templateObject_14 = __makeTemplateObject([""], [""])));
47
- export function getObjectFieldButton(_a) {
48
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
49
- var purpose = _a.purpose, onClick = _a.onClick, uiSchema = _a.uiSchema;
17
+ import { ArrayFieldButtonPurpose, ObjectFieldButtonPurpose } from "./types";
18
+ export const Form = styled(formik.Form) ``;
19
+ export const FormButtonWrapper = styled.div ``;
20
+ export const FormButton = styled.button ``;
21
+ export const ObjectFieldWrapper = styled.fieldset ``;
22
+ export const ObjectFieldTitle = styled.legend ``;
23
+ export const ObjectFieldList = styled.ul `
24
+ list-style-type: none;
25
+ padding: 0;
26
+ `;
27
+ export const ObjectFieldItem = styled.li `
28
+ display: flex;
29
+ `;
30
+ export const ObjectFieldItemButtons = styled.div `
31
+ display: flex;
32
+ margin: 0.5rem;
33
+ `;
34
+ export const ObjectFieldButton = styled.a `
35
+ cursor: pointer;
36
+ border: 1px solid black;
37
+ line-height: 1em;
38
+ height: 1em;
39
+ padding: 0 0.3em;
40
+ `;
41
+ export const ObjectFieldLineButton = styled(ObjectFieldButton) ``;
42
+ export const ObjectFieldUpButton = styled(ObjectFieldLineButton) ``;
43
+ export const ObjectFieldDownButton = styled(ObjectFieldLineButton) ``;
44
+ export const ObjectFieldRemoveButton = styled(ObjectFieldLineButton) ``;
45
+ export const ObjectFieldAddButton = styled(ObjectFieldButton) ``;
46
+ export const getObjectFieldButton = ({ purpose, onClick, uiSchema, }) => {
47
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
50
48
  switch (purpose) {
51
49
  case ObjectFieldButtonPurpose.ADD:
52
- return (_jsx(ObjectFieldAddButton, __assign({}, ((_c = (_b = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:addButtonOptions"]) === null || _b === void 0 ? void 0 : _b.props) !== null && _c !== void 0 ? _c : {}), { onClick: onClick }, { children: (_e = (_d = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:addButtonOptions"]) === null || _d === void 0 ? void 0 : _d.content) !== null && _e !== void 0 ? _e : "+" })));
50
+ return (_jsx(ObjectFieldAddButton, Object.assign({}, ((_b = (_a = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:addButtonOptions"]) === null || _a === void 0 ? void 0 : _a.props) !== null && _b !== void 0 ? _b : {}), { onClick: onClick, children: (_d = (_c = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:addButtonOptions"]) === null || _c === void 0 ? void 0 : _c.content) !== null && _d !== void 0 ? _d : "+" })));
53
51
  case ObjectFieldButtonPurpose.REMOVE:
54
- return (_jsx(ObjectFieldRemoveButton, __assign({}, ((_g = (_f = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:removeButtonOptions"]) === null || _f === void 0 ? void 0 : _f.props) !== null && _g !== void 0 ? _g : {}), { onClick: onClick }, { children: (_j = (_h = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:removeButtonOptions"]) === null || _h === void 0 ? void 0 : _h.content) !== null && _j !== void 0 ? _j : "-" })));
52
+ return (_jsx(ObjectFieldRemoveButton, Object.assign({}, ((_f = (_e = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:removeButtonOptions"]) === null || _e === void 0 ? void 0 : _e.props) !== null && _f !== void 0 ? _f : {}), { onClick: onClick, children: (_h = (_g = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:removeButtonOptions"]) === null || _g === void 0 ? void 0 : _g.content) !== null && _h !== void 0 ? _h : "-" })));
55
53
  case ObjectFieldButtonPurpose.MOVE_UP:
56
- return (_jsx(ObjectFieldUpButton, __assign({}, ((_l = (_k = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:upButtonOptions"]) === null || _k === void 0 ? void 0 : _k.props) !== null && _l !== void 0 ? _l : {}), { onClick: onClick }, { children: (_o = (_m = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:upButtonOptions"]) === null || _m === void 0 ? void 0 : _m.content) !== null && _o !== void 0 ? _o : "↑" })));
54
+ return (_jsx(ObjectFieldUpButton, Object.assign({}, ((_k = (_j = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:upButtonOptions"]) === null || _j === void 0 ? void 0 : _j.props) !== null && _k !== void 0 ? _k : {}), { onClick: onClick, children: (_m = (_l = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:upButtonOptions"]) === null || _l === void 0 ? void 0 : _l.content) !== null && _m !== void 0 ? _m : "↑" })));
57
55
  case ObjectFieldButtonPurpose.MOVE_DOWN:
58
- return (_jsx(ObjectFieldDownButton, __assign({}, ((_q = (_p = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:downButtonOptions"]) === null || _p === void 0 ? void 0 : _p.props) !== null && _q !== void 0 ? _q : {}), { onClick: onClick }, { children: (_s = (_r = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:downButtonOptions"]) === null || _r === void 0 ? void 0 : _r.content) !== null && _s !== void 0 ? _s : "↓" })));
56
+ return (_jsx(ObjectFieldDownButton, Object.assign({}, ((_p = (_o = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:downButtonOptions"]) === null || _o === void 0 ? void 0 : _o.props) !== null && _p !== void 0 ? _p : {}), { onClick: onClick, children: (_r = (_q = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:downButtonOptions"]) === null || _q === void 0 ? void 0 : _q.content) !== null && _r !== void 0 ? _r : "↓" })));
59
57
  default:
60
- return (_jsx(ObjectFieldButton, __assign({}, ((_u = (_t = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:customButtonOptions"]) === null || _t === void 0 ? void 0 : _t.props) !== null && _u !== void 0 ? _u : {}), { onClick: onClick }, { children: (_w = (_v = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:customButtonOptions"]) === null || _v === void 0 ? void 0 : _v.content) !== null && _w !== void 0 ? _w : "" })));
58
+ return (_jsx(ObjectFieldButton, Object.assign({}, ((_t = (_s = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:customButtonOptions"]) === null || _s === void 0 ? void 0 : _s.props) !== null && _t !== void 0 ? _t : {}), { onClick: onClick, children: (_v = (_u = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:customButtonOptions"]) === null || _u === void 0 ? void 0 : _u.content) !== null && _v !== void 0 ? _v : "" })));
61
59
  }
62
- }
63
- export var ArrayFieldWrapper = ObjectFieldWrapper;
64
- export var ArrayFieldTitle = ObjectFieldTitle;
65
- export var ArrayFieldList = ObjectFieldList;
66
- export var ArrayFieldItem = ObjectFieldItem;
67
- export var ArrayFieldItemButtons = ObjectFieldItemButtons;
68
- export var ArrayFieldButton = styled(ObjectFieldButton)(templateObject_15 || (templateObject_15 = __makeTemplateObject([""], [""])));
69
- export var ArrayFieldLineButton = styled(ArrayFieldButton)(templateObject_16 || (templateObject_16 = __makeTemplateObject([""], [""])));
70
- export var ArrayFieldUpButton = styled(ArrayFieldLineButton)(templateObject_17 || (templateObject_17 = __makeTemplateObject([""], [""])));
71
- export var ArrayFieldDownButton = styled(ArrayFieldLineButton)(templateObject_18 || (templateObject_18 = __makeTemplateObject([""], [""])));
72
- export var ArrayFieldRemoveButton = styled(ArrayFieldLineButton)(templateObject_19 || (templateObject_19 = __makeTemplateObject([""], [""])));
73
- export var ArrayFieldAddButton = styled(ArrayFieldButton)(templateObject_20 || (templateObject_20 = __makeTemplateObject([""], [""])));
74
- export function GetArrayFieldButton(_a) {
75
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
76
- var purpose = _a.purpose, onClick = _a.onClick, uiSchema = _a.uiSchema;
77
- var _x = useContext(FormRegistry).components, ArrayFieldAddButton = _x.ArrayFieldAddButton, ArrayFieldRemoveButton = _x.ArrayFieldRemoveButton, ArrayFieldUpButton = _x.ArrayFieldUpButton, ArrayFieldDownButton = _x.ArrayFieldDownButton;
60
+ };
61
+ export const ArrayFieldWrapper = ObjectFieldWrapper;
62
+ export const ArrayFieldTitle = ObjectFieldTitle;
63
+ export const ArrayFieldList = ObjectFieldList;
64
+ export const ArrayFieldItem = ObjectFieldItem;
65
+ export const ArrayFieldItemButtons = ObjectFieldItemButtons;
66
+ export const ArrayFieldButton = styled(ObjectFieldButton) ``;
67
+ export const ArrayFieldLineButton = styled(ArrayFieldButton) ``;
68
+ export const ArrayFieldUpButton = styled(ArrayFieldLineButton) ``;
69
+ export const ArrayFieldDownButton = styled(ArrayFieldLineButton) ``;
70
+ export const ArrayFieldRemoveButton = styled(ArrayFieldLineButton) ``;
71
+ export const ArrayFieldAddButton = styled(ArrayFieldButton) ``;
72
+ export const GetArrayFieldButton = ({ purpose, onClick, uiSchema, }) => {
73
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
74
+ const { components: { ArrayFieldAddButton, ArrayFieldRemoveButton, ArrayFieldUpButton, ArrayFieldDownButton, }, } = useContext(FormRegistry);
78
75
  switch (purpose) {
79
76
  case ArrayFieldButtonPurpose.ADD:
80
- return (_jsx(ArrayFieldAddButton, __assign({}, ((_c = (_b = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:addButtonOptions"]) === null || _b === void 0 ? void 0 : _b.props) !== null && _c !== void 0 ? _c : {}), { onClick: onClick }, { children: (_e = (_d = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:addButtonOptions"]) === null || _d === void 0 ? void 0 : _d.content) !== null && _e !== void 0 ? _e : "+" })));
77
+ return (_jsx(ArrayFieldAddButton, Object.assign({}, ((_b = (_a = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:addButtonOptions"]) === null || _a === void 0 ? void 0 : _a.props) !== null && _b !== void 0 ? _b : {}), { onClick: onClick, children: (_d = (_c = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:addButtonOptions"]) === null || _c === void 0 ? void 0 : _c.content) !== null && _d !== void 0 ? _d : "+" })));
81
78
  case ArrayFieldButtonPurpose.REMOVE:
82
- return (_jsx(ArrayFieldRemoveButton, __assign({}, ((_g = (_f = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:removeButtonOptions"]) === null || _f === void 0 ? void 0 : _f.props) !== null && _g !== void 0 ? _g : {}), { onClick: onClick }, { children: (_j = (_h = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:removeButtonOptions"]) === null || _h === void 0 ? void 0 : _h.content) !== null && _j !== void 0 ? _j : "-" })));
79
+ return (_jsx(ArrayFieldRemoveButton, Object.assign({}, ((_f = (_e = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:removeButtonOptions"]) === null || _e === void 0 ? void 0 : _e.props) !== null && _f !== void 0 ? _f : {}), { onClick: onClick, children: (_h = (_g = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:removeButtonOptions"]) === null || _g === void 0 ? void 0 : _g.content) !== null && _h !== void 0 ? _h : "-" })));
83
80
  case ArrayFieldButtonPurpose.MOVE_UP:
84
- return (_jsx(ArrayFieldUpButton, __assign({}, ((_l = (_k = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:upButtonOptions"]) === null || _k === void 0 ? void 0 : _k.props) !== null && _l !== void 0 ? _l : {}), { onClick: onClick }, { children: (_o = (_m = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:upButtonOptions"]) === null || _m === void 0 ? void 0 : _m.content) !== null && _o !== void 0 ? _o : "↑" })));
81
+ return (_jsx(ArrayFieldUpButton, Object.assign({}, ((_k = (_j = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:upButtonOptions"]) === null || _j === void 0 ? void 0 : _j.props) !== null && _k !== void 0 ? _k : {}), { onClick: onClick, children: (_m = (_l = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:upButtonOptions"]) === null || _l === void 0 ? void 0 : _l.content) !== null && _m !== void 0 ? _m : "↑" })));
85
82
  case ArrayFieldButtonPurpose.MOVE_DOWN:
86
- return (_jsx(ArrayFieldDownButton, __assign({}, ((_q = (_p = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:downButtonOptions"]) === null || _p === void 0 ? void 0 : _p.props) !== null && _q !== void 0 ? _q : {}), { onClick: onClick }, { children: (_s = (_r = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:downButtonOptions"]) === null || _r === void 0 ? void 0 : _r.content) !== null && _s !== void 0 ? _s : "↓" })));
83
+ return (_jsx(ArrayFieldDownButton, Object.assign({}, ((_p = (_o = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:downButtonOptions"]) === null || _o === void 0 ? void 0 : _o.props) !== null && _p !== void 0 ? _p : {}), { onClick: onClick, children: (_r = (_q = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:downButtonOptions"]) === null || _q === void 0 ? void 0 : _q.content) !== null && _r !== void 0 ? _r : "↓" })));
87
84
  default:
88
- return (_jsx(ArrayFieldButton, __assign({}, ((_u = (_t = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:customButtonOptions"]) === null || _t === void 0 ? void 0 : _t.props) !== null && _u !== void 0 ? _u : {}), { onClick: onClick }, { children: (_w = (_v = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:customButtonOptions"]) === null || _v === void 0 ? void 0 : _v.content) !== null && _w !== void 0 ? _w : "" })));
85
+ return (_jsx(ArrayFieldButton, Object.assign({}, ((_t = (_s = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:customButtonOptions"]) === null || _s === void 0 ? void 0 : _s.props) !== null && _t !== void 0 ? _t : {}), { onClick: onClick, children: (_v = (_u = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:customButtonOptions"]) === null || _u === void 0 ? void 0 : _u.content) !== null && _v !== void 0 ? _v : "" })));
89
86
  }
90
- }
91
- export var FieldWrapper = styled.div(templateObject_21 || (templateObject_21 = __makeTemplateObject(["\n margin: 0.5rem 0;\n"], ["\n margin: 0.5rem 0;\n"])));
92
- export var FieldTitle = styled.label(templateObject_22 || (templateObject_22 = __makeTemplateObject(["\n font-weight: 700;\n"], ["\n font-weight: 700;\n"])));
93
- export var FieldDescription = styled.p(templateObject_23 || (templateObject_23 = __makeTemplateObject(["\n margin: 0;\n font-size: 0.9em;\n"], ["\n margin: 0;\n font-size: 0.9em;\n"])));
94
- export var FieldHelp = styled.p(templateObject_24 || (templateObject_24 = __makeTemplateObject(["\n margin: 0;\n font-size: 0.9em;\n"], ["\n margin: 0;\n font-size: 0.9em;\n"])));
95
- export var InfoFieldBoxElement = styled.div(templateObject_25 || (templateObject_25 = __makeTemplateObject(["\n transition: opacity 0.5s;\n position: absolute;\n z-index: 1080;\n opacity: 0;\n visibility: hidden;\n margin: 0;\n font-size: 0.875rem;\n word-wrap: break-word;\n min-width: max-content;\n\n top: ", ";\n bottom: ", ";\n left: ", ";\n right: ", ";\n transform: translate(\n ", ",\n ", "\n );\n"], ["\n transition: opacity 0.5s;\n position: absolute;\n z-index: 1080;\n opacity: 0;\n visibility: hidden;\n margin: 0;\n font-size: 0.875rem;\n word-wrap: break-word;\n min-width: max-content;\n\n top: ", ";\n bottom: ", ";\n left: ", ";\n right: ", ";\n transform: translate(\n ", ",\n ", "\n );\n"])), function (_a) {
96
- var position = _a.position;
97
- return position === "bottom" ? "140%" : position === "top" ? "auto" : "50%";
98
- }, function (_a) {
99
- var position = _a.position;
100
- return position === "top"
101
- ? "140%"
102
- : position === "right" || position === "left"
103
- ? "50%"
104
- : "auto";
105
- }, function (_a) {
106
- var position = _a.position;
107
- return position === "right"
108
- ? "100%"
109
- : position === "bottom" || position === "top"
110
- ? "50%"
111
- : "auto";
112
- }, function (_a) {
113
- var position = _a.position;
114
- return position === "left"
115
- ? "100%"
116
- : position === "bottom" || position === "top"
117
- ? "50%"
118
- : "auto";
119
- }, function (_a) {
120
- var position = _a.position;
121
- return position === "bottom" || position === "top" ? "-50%" : "0";
122
- }, function (_a) {
123
- var position = _a.position;
124
- return position === "right" || position === "left" ? "-50%" : "0";
125
- });
126
- export var InfoFieldBoxArrowElement = styled.div(templateObject_26 || (templateObject_26 = __makeTemplateObject(["\n top: ", ";\n left: ", ";\n bottom: ", ";\n border: solid transparent;\n content: \"\";\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none;\n border-top-color: ", ";\n border-bottom-color: ", ";\n border-right-color: ", ";\n border-left-color: ", ";\n border-width: 5px;\n margin-left: -5px;\n"], ["\n top: ", ";\n left: ", ";\n bottom: ", ";\n border: solid transparent;\n content: \"\";\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none;\n border-top-color: ", ";\n border-bottom-color: ", ";\n border-right-color: ", ";\n border-left-color: ", ";\n border-width: 5px;\n margin-left: -5px;\n"])), function (_a) {
127
- var position = _a.position;
128
- return position === "top"
129
- ? "100%"
130
- : position === "right" || position === "left"
131
- ? "40%"
132
- : "unset";
133
- }, function (_a) {
134
- var position = _a.position;
135
- return position === "top" || position === "bottom"
87
+ };
88
+ export const FieldWrapper = styled.div `
89
+ margin: 0.5rem 0;
90
+ `;
91
+ export const FieldTitle = styled.label `
92
+ font-weight: 700;
93
+ `;
94
+ export const FieldDescription = styled.p `
95
+ margin: 0;
96
+ font-size: 0.9em;
97
+ `;
98
+ export const FieldHelp = styled.p `
99
+ margin: 0;
100
+ font-size: 0.9em;
101
+ `;
102
+ export const InfoFieldBoxElement = styled.div `
103
+ transition: opacity 0.5s;
104
+ position: absolute;
105
+ z-index: 1080;
106
+ opacity: 0;
107
+ visibility: hidden;
108
+ margin: 0;
109
+ font-size: 0.875rem;
110
+ word-wrap: break-word;
111
+ min-width: max-content;
112
+
113
+ top: ${({ position }) => position === "bottom" ? "140%" : position === "top" ? "auto" : "50%"};
114
+ bottom: ${({ position }) => position === "top"
115
+ ? "140%"
116
+ : position === "right" || position === "left"
117
+ ? "50%"
118
+ : "auto"};
119
+ left: ${({ position }) => position === "right"
120
+ ? "100%"
121
+ : position === "bottom" || position === "top"
122
+ ? "50%"
123
+ : "auto"};
124
+ right: ${({ position }) => position === "left"
125
+ ? "100%"
126
+ : position === "bottom" || position === "top"
136
127
  ? "50%"
137
- : position === "right"
138
- ? "-2%"
139
- : "102.5%";
140
- }, function (_a) {
141
- var position = _a.position;
142
- return (position === "bottom" ? "100%" : "unset");
143
- }, function (_a) {
144
- var position = _a.position;
145
- return position === "top" ? "grey" : "transparent";
146
- }, function (_a) {
147
- var position = _a.position;
148
- return position === "bottom" ? "grey" : "transparent";
149
- }, function (_a) {
150
- var position = _a.position;
151
- return position === "right" ? "grey" : "transparent";
152
- }, function (_a) {
153
- var position = _a.position;
154
- return position === "left" ? "grey" : "transparent";
155
- });
156
- export var InfoFieldBoxInnerElement = styled.div(templateObject_27 || (templateObject_27 = __makeTemplateObject(["\n padding: 0.25rem 0.5rem;\n color: white;\n text-align: center;\n background: grey;\n border: solid 1px grey;\n border-radius: 0.25rem;\n cursor: default;\n"], ["\n padding: 0.25rem 0.5rem;\n color: white;\n text-align: center;\n background: grey;\n border: solid 1px grey;\n border-radius: 0.25rem;\n cursor: default;\n"])));
157
- export var InfoFieldContainerElement = styled.a(templateObject_28 || (templateObject_28 = __makeTemplateObject(["\n position: relative;\n color: black;\n background: none;\n outline: none;\n cursor: pointer;\n border: 1px solid black;\n border-radius: 50%;\n line-height: 1em;\n font-size: 0.7em;\n padding: 0 0.44em;\n text-decoration: unset;\n\n &:active,\n &:focus {\n color: white;\n background: black;\n ", " {\n opacity: 1;\n visibility: visible;\n }\n }\n"], ["\n position: relative;\n color: black;\n background: none;\n outline: none;\n cursor: pointer;\n border: 1px solid black;\n border-radius: 50%;\n line-height: 1em;\n font-size: 0.7em;\n padding: 0 0.44em;\n text-decoration: unset;\n\n &:active,\n &:focus {\n color: white;\n background: black;\n ", " {\n opacity: 1;\n visibility: visible;\n }\n }\n"])), InfoFieldBoxElement);
158
- export var InfoFieldLabel = styled.span(templateObject_29 || (templateObject_29 = __makeTemplateObject([""], [""])));
159
- export var InfoFieldButton = function (_a) {
160
- var label = _a.label, content = _a.content, position = _a.position, props = _a.props, className = _a.className;
161
- return (_jsxs(InfoFieldContainerElement, __assign({ href: "#", onClick: function (e) { return e.preventDefault(); }, className: className }, { children: [_jsx(InfoFieldLabel, { children: label !== null && label !== void 0 ? label : "i" }), _jsxs(InfoFieldBoxElement, __assign({ position: position !== null && position !== void 0 ? position : "top", role: "tooltip" }, { children: [_jsx(InfoFieldBoxArrowElement, { position: position !== null && position !== void 0 ? position : "top" }), _jsx(InfoFieldBoxInnerElement, { children: content })] }))] })));
128
+ : "auto"};
129
+ transform: translate(
130
+ ${({ position }) => position === "bottom" || position === "top" ? "-50%" : "0"},
131
+ ${({ position }) => position === "right" || position === "left" ? "-50%" : "0"}
132
+ );
133
+ `;
134
+ export const InfoFieldBoxArrowElement = styled.div `
135
+ top: ${({ position }) => position === "top"
136
+ ? "100%"
137
+ : position === "right" || position === "left"
138
+ ? "40%"
139
+ : "unset"};
140
+ left: ${({ position }) => position === "top" || position === "bottom"
141
+ ? "50%"
142
+ : position === "right"
143
+ ? "-2%"
144
+ : "102.5%"};
145
+ bottom: ${({ position }) => (position === "bottom" ? "100%" : "unset")};
146
+ border: solid transparent;
147
+ content: "";
148
+ height: 0;
149
+ width: 0;
150
+ position: absolute;
151
+ pointer-events: none;
152
+ border-top-color: ${({ position }) => position === "top" ? "grey" : "transparent"};
153
+ border-bottom-color: ${({ position }) => position === "bottom" ? "grey" : "transparent"};
154
+ border-right-color: ${({ position }) => position === "right" ? "grey" : "transparent"};
155
+ border-left-color: ${({ position }) => position === "left" ? "grey" : "transparent"};
156
+ border-width: 5px;
157
+ margin-left: -5px;
158
+ `;
159
+ export const InfoFieldBoxInnerElement = styled.div `
160
+ padding: 0.25rem 0.5rem;
161
+ color: white;
162
+ text-align: center;
163
+ background: grey;
164
+ border: solid 1px grey;
165
+ border-radius: 0.25rem;
166
+ cursor: default;
167
+ `;
168
+ export const InfoFieldContainerElement = styled.a `
169
+ position: relative;
170
+ color: black;
171
+ background: none;
172
+ outline: none;
173
+ cursor: pointer;
174
+ border: 1px solid black;
175
+ border-radius: 50%;
176
+ line-height: 1em;
177
+ font-size: 0.7em;
178
+ padding: 0 0.44em;
179
+ text-decoration: unset;
180
+
181
+ &:active,
182
+ &:focus {
183
+ color: white;
184
+ background: black;
185
+ ${InfoFieldBoxElement} {
186
+ opacity: 1;
187
+ visibility: visible;
188
+ }
189
+ }
190
+ `;
191
+ export const InfoFieldLabel = styled.span ``;
192
+ export const InfoFieldButton = ({ label, content, position, props, className, }) => {
193
+ return (_jsxs(InfoFieldContainerElement, { href: "#", onClick: (e) => e.preventDefault(), className: className, children: [_jsx(InfoFieldLabel, { children: label !== null && label !== void 0 ? label : "i" }), _jsxs(InfoFieldBoxElement, { position: position !== null && position !== void 0 ? position : "top", role: "tooltip", children: [_jsx(InfoFieldBoxArrowElement, { position: position !== null && position !== void 0 ? position : "top" }), _jsx(InfoFieldBoxInnerElement, { children: content })] })] }));
162
194
  };
163
195
  InfoFieldButton.styles = {
164
196
  InfoFieldContainerElementStyle: InfoFieldContainerElement,
@@ -167,14 +199,186 @@ InfoFieldButton.styles = {
167
199
  InfoFieldBoxArrowElementStyle: InfoFieldBoxArrowElement,
168
200
  InfoFieldLabelStyle: InfoFieldLabel,
169
201
  };
170
- export var ErrorMessage = styled(formik.ErrorMessage)(templateObject_30 || (templateObject_30 = __makeTemplateObject([""], [""])));
202
+ // <--- InfoFieldButton
203
+ export const ErrorMessage = styled(formik.ErrorMessage) ``;
171
204
  /*
172
205
  * Works like Formik field, but "as" props needs to be given with "formikAs", since styled components uses as.
173
206
  *
174
207
  */
175
- export var FieldInput = styled(function (_a) {
176
- var formikAs = _a.formikAs, props = __rest(_a, ["formikAs"]);
177
- return _jsx(formik.Field, __assign({}, props, { as: formikAs }));
178
- })(templateObject_31 || (templateObject_31 = __makeTemplateObject([""], [""])));
179
- export var RequiredIndicator = styled.span(templateObject_32 || (templateObject_32 = __makeTemplateObject([""], [""])));
180
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16, templateObject_17, templateObject_18, templateObject_19, templateObject_20, templateObject_21, templateObject_22, templateObject_23, templateObject_24, templateObject_25, templateObject_26, templateObject_27, templateObject_28, templateObject_29, templateObject_30, templateObject_31, templateObject_32;
208
+ export const FieldInput = styled((_a) => {
209
+ var { formikAs } = _a, props = __rest(_a, ["formikAs"]);
210
+ return _jsx(formik.Field, Object.assign({}, props, { as: formikAs }));
211
+ }) ``;
212
+ export const RequiredIndicator = styled.span ``;
213
+ // ToggleSwitchField --->
214
+ export const Toggle = styled.span `
215
+ position: absolute;
216
+ cursor: pointer;
217
+ top: 0;
218
+ left: 0;
219
+ right: 0;
220
+ bottom: 0;
221
+ background: #ccc;
222
+ -webkit-transition: 0.4s;
223
+ transition: 0.4s;
224
+ border-radius: 34px;
225
+
226
+ &:before {
227
+ position: absolute;
228
+ content: "";
229
+ height: 0.9em;
230
+ width: 0.9em;
231
+ background: white;
232
+ -webkit-transition: 0.4s;
233
+ transition: 0.4s;
234
+ border-radius: 50%;
235
+ top: 0.13em;
236
+ left: 0.13em;
237
+ }
238
+ `;
239
+ export const ToggleLabel = styled.label `
240
+ position: relative;
241
+ display: inline-block;
242
+ width: 2em;
243
+ `;
244
+ export const ToggleFieldInput = styled(FieldInput) `
245
+ opacity: 0;
246
+ width: 0;
247
+ height: 0;
248
+
249
+ &:checked + ${Toggle} {
250
+ background: #2196f3;
251
+ }
252
+
253
+ &:focus + ${Toggle} {
254
+ box-shadow: 0 0 1px #2196f3;
255
+ }
256
+
257
+ &:checked + ${Toggle}:before {
258
+ transform: translateX(0.85em);
259
+ }
260
+ `;
261
+ export const ToggleSwitchField = ({ inputProps, name, className, }) => {
262
+ return (_jsxs(ToggleLabel, { className: className, children: [_jsx(ToggleFieldInput, Object.assign({}, inputProps, { name: name, type: "checkbox" })), _jsx(Toggle, {})] }));
263
+ };
264
+ ToggleSwitchField.styles = {
265
+ ToggleLabelStyle: ToggleLabel,
266
+ ToggleFieldInputStyle: ToggleFieldInput,
267
+ ToggleStyle: Toggle,
268
+ };
269
+ // <--- ToggleSwitchField
270
+ // RadioButtonField --->
271
+ export const RadioButtonFieldContainer = styled.div `
272
+ display: flex;
273
+ gap: 1em;
274
+ `;
275
+ export const RadioButtonFieldElement = styled.label `
276
+ display: inline-flex;
277
+ align-items: center;
278
+ `;
279
+ export const RadioButtonFieldInput = styled(FieldInput) `
280
+ margin: unset;
281
+ margin-top: 0.15em;
282
+ `;
283
+ export const ButtonLabel = styled.span `
284
+ margin-left: 0.2em;
285
+ `;
286
+ export const ButtonLabelTrue = styled(ButtonLabel) ``;
287
+ export const ButtonLabelFalse = styled(ButtonLabel) ``;
288
+ export const RadioButtonField = ({ label, inputProps, name, className, }) => {
289
+ var _a, _b;
290
+ return (_jsxs(RadioButtonFieldContainer, { className: className, children: [_jsxs(RadioButtonFieldElement, { children: [_jsx(RadioButtonFieldInput, Object.assign({}, inputProps, { name: name, type: "radio", value: "true" })), _jsx(ButtonLabelTrue, { children: (_a = label === null || label === void 0 ? void 0 : label.true) !== null && _a !== void 0 ? _a : "true" })] }), _jsxs(RadioButtonFieldElement, { children: [_jsx(RadioButtonFieldInput, Object.assign({}, inputProps, { name: name, type: "radio", value: "false" })), _jsx(ButtonLabelFalse, { children: (_b = label === null || label === void 0 ? void 0 : label.false) !== null && _b !== void 0 ? _b : "false" })] })] }));
291
+ };
292
+ RadioButtonField.styles = {
293
+ RadioButtonFieldContainerStyle: RadioButtonFieldContainer,
294
+ RadioButtonFieldElementStyle: RadioButtonFieldElement,
295
+ RadioButtonFieldInputStyle: RadioButtonFieldInput,
296
+ ButtonLabelStyle: ButtonLabel,
297
+ ButtonLabelTrueStyle: ButtonLabelTrue,
298
+ ButtonLabelFalseStyle: ButtonLabelFalse,
299
+ };
300
+ // ---> SearchableMultiTagSelectField
301
+ export const MultiSelectContainer = styled.div `
302
+ display: flex;
303
+ flex-direction: column;
304
+ `;
305
+ export const MultiSelectInput = styled(FieldInput) ``;
306
+ export const MultiSelectBadgeContainer = styled.div `
307
+ margin: 0.3em 0;
308
+ display: inline-flex;
309
+ gap: 1em;
310
+ `;
311
+ export const MultiSelectBadge = styled.span `
312
+ background: lightgray;
313
+ padding: 0 0.2em 0 0.5em;
314
+ border-radius: 0.1em;
315
+ display: flex;
316
+ `;
317
+ export const MultiSelectBadgeCloseElement = styled.span `
318
+ cursor: pointer;
319
+ margin-left: 0.5em;
320
+ font-size: 0.7em;
321
+ align-self: baseline;
322
+ font-family: sans-serif;
323
+ `;
324
+ export const MultiSelectOptionList = styled.ul `
325
+ padding: unset;
326
+ margin: unset;
327
+ border: 1px solid gray;
328
+ border-radius: 0.2em;
329
+ position: absolute;
330
+ background: white;
331
+ margin: 1.3em 0;
332
+ `;
333
+ export const MultiSelectOptionListItem = styled.li `
334
+ cursor: pointer;
335
+ list-style-type: none;
336
+ padding: 0.06em 0.2em;
337
+ height: 1.2em;
338
+ &:hover {
339
+ background: lightgray;
340
+ }
341
+ `;
342
+ export const MultiSelectOptionListWithoutItem = styled.li `
343
+ cursor: default;
344
+ color: gray;
345
+ list-style-type: none;
346
+ padding: 0.06em 0.2em;
347
+ height: 1.2em;
348
+ `;
349
+ export const SearchableMultiTagSelectField = ({ name, placeholder, enums, emptySearchMessage, closeElement, className, }) => {
350
+ const [search, setSearch] = useState("");
351
+ const searchIncludedInEnum = () => {
352
+ const hasValue = enums === null || enums === void 0 ? void 0 : enums.values.map((value) => value.title.toLowerCase().includes(search.toLowerCase()));
353
+ return hasValue === null || hasValue === void 0 ? void 0 : hasValue.includes(true);
354
+ };
355
+ return (_jsx(formik.Field, { className: className, name: name, multiple: true, children: ({ field, form: { setValues }, meta, }) => {
356
+ var _a;
357
+ return (_jsxs(MultiSelectContainer, { className: className, children: [_jsx(FieldInput, Object.assign({ type: "hidden" }, field)), _jsx(MultiSelectInput, { className: className, type: "text", onChange: (e) => {
358
+ setSearch(e.currentTarget.value);
359
+ }, placeholder: placeholder, value: search }), _jsx(MultiSelectBadgeContainer, { children: ((_a = field.value) !== null && _a !== void 0 ? _a : []).map((value) => {
360
+ var _a;
361
+ return (_jsxs(MultiSelectBadge, { children: [(_a = enums === null || enums === void 0 ? void 0 : enums.values.find((option) => option.const === value)) === null || _a === void 0 ? void 0 : _a.title, _jsx(MultiSelectBadgeCloseElement, { onClick: () => setValues({
362
+ [name]: field.value.filter((v) => v !== value),
363
+ }), children: closeElement !== null && closeElement !== void 0 ? closeElement : "x" })] }, value));
364
+ }) }), search.length > 0 && (_jsx(MultiSelectOptionList, { children: searchIncludedInEnum() ? (enums === null || enums === void 0 ? void 0 : enums.values.filter((item) => { var _a; return !((_a = field.value) !== null && _a !== void 0 ? _a : []).includes(item.const); }).filter((value) => value.title.toLowerCase().includes(search.toLowerCase())).map((option, index) => (_jsx(MultiSelectOptionListItem, { value: option.const, onClick: () => {
365
+ var _a;
366
+ setValues({
367
+ [name]: [
368
+ ...new Set([...((_a = field.value) !== null && _a !== void 0 ? _a : []), option.const]),
369
+ ],
370
+ });
371
+ setSearch("");
372
+ }, children: option.title }, index)))) : (_jsx(MultiSelectOptionListWithoutItem, { children: emptySearchMessage !== null && emptySearchMessage !== void 0 ? emptySearchMessage : "No match found" })) })), meta.touched && meta.error && (_jsx("div", { className: "error", children: meta.error }))] }));
373
+ } }));
374
+ };
375
+ SearchableMultiTagSelectField.styles = {
376
+ MultiSelectContainerStyle: MultiSelectContainer,
377
+ MultiSelectInputStyle: MultiSelectInput,
378
+ MultiSelectBadgeContainerStyle: MultiSelectBadgeContainer,
379
+ MultiSelectBadgeStyle: MultiSelectBadge,
380
+ MultiSelectBadgeCloseElementStyle: MultiSelectBadgeCloseElement,
381
+ MultiSelectOptionListStyle: MultiSelectOptionList,
382
+ MultiSelectOptionListItemStyle: MultiSelectOptionListItem,
383
+ MultiSelectOptionListWithoutItemStyle: MultiSelectOptionListWithoutItem,
384
+ };
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
2
- import { ArrayFieldTemplateProps } from "../types";
3
- export declare function ArrayFieldTemplate(props: ArrayFieldTemplateProps): JSX.Element;
1
+ import type { ArrayFieldTemplateProps } from "../types";
2
+ import React from "react";
3
+ export declare const ArrayFieldTemplate: React.FC<ArrayFieldTemplateProps>;
@@ -1,28 +1,16 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
2
  import { useContext } from "react";
14
3
  import { FormRegistry } from "../Form";
15
- import { useExtractUiSchema, getDescription, getTitle } from "../utils";
4
+ import { getDescription, getTitle } from "../utils";
5
+ import { useExtractUiSchema } from "../hooks";
16
6
  import { RequiredIndicator } from "../styledComponents";
17
- export function ArrayFieldTemplate(props) {
18
- var _a = useContext(FormRegistry).components, ArrayFieldWrapper = _a.ArrayFieldWrapper, ArrayFieldTitle = _a.ArrayFieldTitle, FieldDescription = _a.FieldDescription, ErrorMessage = _a.ErrorMessage, FieldHelp = _a.FieldHelp, InfoFieldButton = _a.InfoFieldButton;
19
- var name = props.name, uiSchema = props.uiSchema, children = props.children;
20
- var title = getTitle(props);
21
- var description = getDescription(props);
22
- var _b = useExtractUiSchema(uiSchema), help = _b.help, info = _b.info,
23
- //TODO: This is not right
24
- _c = _b.props,
7
+ export const ArrayFieldTemplate = (props) => {
8
+ const { components: { ArrayFieldWrapper, ArrayFieldTitle, FieldDescription, ErrorMessage, FieldHelp, InfoFieldButton, }, } = useContext(FormRegistry);
9
+ const { name, uiSchema, children } = props;
10
+ const title = getTitle(props);
11
+ const description = getDescription(props);
12
+ const { help, info,
25
13
  //TODO: This is not right
26
- _d = _c === void 0 ? {} : _c, wrappertProps = _d.wrapper, titleProps = _d.title, descriptionProps = _d.description, helpProps = _d.help, errorProps = _d.error;
27
- return (_jsxs(ArrayFieldWrapper, __assign({}, wrappertProps, { children: [title && (_jsxs(ArrayFieldTitle, __assign({}, titleProps, { htmlFor: name }, { children: [title, (props === null || props === void 0 ? void 0 : props.required) && _jsx(RequiredIndicator, { children: "*" })] }))), info && _jsx(InfoFieldButton, __assign({}, info)), description && (_jsx(FieldDescription, __assign({}, descriptionProps, { children: description }))), children, help && _jsx(FieldHelp, __assign({}, helpProps, { children: help })), _jsx(ErrorMessage, __assign({}, errorProps, { name: name }))] })));
28
- }
14
+ props: { wrapper: wrappertProps, title: titleProps, description: descriptionProps, help: helpProps, error: errorProps, } = {}, } = useExtractUiSchema(uiSchema);
15
+ return (_jsxs(ArrayFieldWrapper, Object.assign({}, wrappertProps, { children: [title && (_jsxs(ArrayFieldTitle, Object.assign({}, titleProps, { htmlFor: name, children: [title, (props === null || props === void 0 ? void 0 : props.required) && _jsx(RequiredIndicator, { children: "*" })] }))), info && _jsx(InfoFieldButton, Object.assign({}, info)), description && (_jsx(FieldDescription, Object.assign({}, descriptionProps, { children: description }))), children, help && _jsx(FieldHelp, Object.assign({}, helpProps, { children: help })), _jsx(ErrorMessage, Object.assign({}, errorProps, { name: name }))] })));
16
+ };
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
2
- import { FieldTemplateProps } from "../types";
3
- export declare function FieldTemplate(props: FieldTemplateProps): JSX.Element;
1
+ import type { FieldTemplateProps } from "../types";
2
+ import React from "react";
3
+ export declare const FieldTemplate: React.FC<FieldTemplateProps>;