@react-fabric/form 1.0.0-beta.4 → 1.0.0-beta.40

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 (152) hide show
  1. package/{src/input/ArrayInput.module.css → css/_arrayInput.css} +8 -8
  2. package/css/_colorPicker.css +65 -0
  3. package/{src/internal/Field.module.css → css/_field.css} +26 -15
  4. package/{src/input/File.module.css → css/_file.css} +20 -6
  5. package/css/styles.css +27 -0
  6. package/dist/cjs/builder/FileField.js +37 -25
  7. package/dist/cjs/builder/FormField.js +44 -34
  8. package/dist/cjs/builder/SchemaEditor.js +72 -0
  9. package/dist/cjs/builder/components/AddSchemaFields.js +62 -0
  10. package/dist/cjs/builder/components/SchemaArrayForm.js +143 -0
  11. package/dist/cjs/builder/components/SchemaField.js +413 -0
  12. package/dist/cjs/form/Controller.js +1 -1
  13. package/dist/cjs/form/Form.js +19 -10
  14. package/dist/cjs/hooks/useFormBuilder.js +27 -15
  15. package/dist/cjs/index.js +9 -2
  16. package/dist/cjs/input/ArrayInput.js +36 -25
  17. package/dist/cjs/input/AvatarInput.js +1 -1
  18. package/dist/cjs/input/Checkbox.js +5 -4
  19. package/dist/cjs/input/ColorInput.js +70 -28
  20. package/dist/cjs/input/ColorPicker.js +1 -35
  21. package/dist/cjs/input/DateInput.js +183 -0
  22. package/dist/cjs/input/Field.js +4 -4
  23. package/dist/cjs/input/File.js +2 -3
  24. package/dist/cjs/input/Hidden.js +3 -1
  25. package/dist/cjs/input/Input.js +1 -1
  26. package/dist/cjs/input/Number.js +1 -1
  27. package/dist/cjs/input/Password.js +1 -1
  28. package/dist/cjs/input/Radio.js +1 -1
  29. package/dist/cjs/input/RadioGroup.js +6 -3
  30. package/dist/cjs/input/{Range.js → RangeSlider.js} +3 -3
  31. package/dist/cjs/input/Search.js +1 -1
  32. package/dist/cjs/input/Slider.js +1 -1
  33. package/dist/cjs/input/Switch.js +27 -5
  34. package/dist/cjs/input/Textarea.js +7 -3
  35. package/dist/cjs/internal/ErrorIcon.js +1 -1
  36. package/dist/cjs/internal/FieldWrapper.js +4 -3
  37. package/dist/cjs/internal/InputWrapper.js +14 -16
  38. package/dist/cjs/select/AutoComplete.js +1 -1
  39. package/dist/cjs/select/List.js +41 -20
  40. package/dist/cjs/select/Options.js +2 -2
  41. package/dist/cjs/select/Select.js +11 -8
  42. package/dist/cjs/select/useSelect.js +12 -7
  43. package/{src/input/ColorPicker.module.css → dist/cjs/types/schema.js} +18 -27
  44. package/dist/cjs/utils/getColor.js +6 -0
  45. package/dist/esm/builder/FileField.js +39 -27
  46. package/dist/esm/builder/FormField.js +44 -34
  47. package/dist/esm/builder/SchemaEditor.js +72 -0
  48. package/dist/esm/builder/components/AddSchemaFields.js +62 -0
  49. package/dist/esm/builder/components/SchemaArrayForm.js +143 -0
  50. package/dist/esm/builder/components/SchemaField.js +413 -0
  51. package/dist/esm/form/Controller.js +1 -1
  52. package/dist/esm/form/Form.js +19 -10
  53. package/dist/esm/hooks/useFormBuilder.js +25 -13
  54. package/dist/esm/index.js +4 -1
  55. package/dist/esm/input/ArrayInput.js +38 -27
  56. package/dist/esm/input/AvatarInput.js +1 -1
  57. package/dist/esm/input/Checkbox.js +5 -4
  58. package/dist/esm/input/ColorInput.js +72 -30
  59. package/dist/esm/input/ColorPicker.js +1 -35
  60. package/dist/esm/input/DateInput.js +183 -0
  61. package/dist/esm/input/Field.js +5 -5
  62. package/dist/esm/input/File.js +2 -3
  63. package/dist/esm/input/Hidden.js +3 -1
  64. package/dist/esm/input/Input.js +1 -1
  65. package/dist/esm/input/Number.js +1 -1
  66. package/dist/esm/input/Password.js +1 -1
  67. package/dist/esm/input/Radio.js +1 -1
  68. package/dist/esm/input/RadioGroup.js +7 -4
  69. package/dist/esm/input/{Range.js → RangeSlider.js} +3 -3
  70. package/dist/esm/input/Search.js +1 -1
  71. package/dist/esm/input/Slider.js +1 -1
  72. package/dist/esm/input/Switch.js +29 -7
  73. package/dist/esm/input/Textarea.js +7 -3
  74. package/dist/esm/internal/ErrorIcon.js +1 -1
  75. package/dist/esm/internal/FieldWrapper.js +4 -3
  76. package/dist/esm/internal/InputWrapper.js +14 -16
  77. package/dist/esm/select/AutoComplete.js +1 -1
  78. package/dist/esm/select/List.js +42 -21
  79. package/dist/esm/select/Options.js +2 -2
  80. package/dist/esm/select/Select.js +11 -8
  81. package/dist/esm/select/useSelect.js +13 -8
  82. package/dist/esm/types/schema.js +41 -0
  83. package/dist/esm/utils/getColor.js +6 -1
  84. package/dist/types/builder/FileField.d.ts +4 -2
  85. package/dist/types/builder/FormField.d.ts +3 -1
  86. package/dist/types/builder/SchemaEditor.d.ts +2 -0
  87. package/dist/types/builder/components/AddSchemaFields.d.ts +2 -0
  88. package/dist/types/builder/components/SchemaArrayForm.d.ts +2 -0
  89. package/dist/types/builder/components/SchemaField.d.ts +10 -0
  90. package/dist/types/form/Controller.d.ts +1 -1
  91. package/dist/types/hooks/useFormBuilder.d.ts +3 -1
  92. package/dist/types/index.d.ts +4 -2
  93. package/dist/types/input/ArrayInput.d.ts +20 -3
  94. package/dist/types/input/Checkbox.d.ts +4 -3
  95. package/dist/types/input/ColorInput.d.ts +1 -1
  96. package/dist/types/input/DateInput.d.ts +19 -0
  97. package/dist/types/input/RadioGroup.d.ts +18 -2
  98. package/dist/types/input/{Range.d.ts → RangeSlider.d.ts} +1 -1
  99. package/dist/types/input/Switch.d.ts +7 -3
  100. package/dist/types/input/Textarea.d.ts +5 -1
  101. package/dist/types/internal/InputWrapper.d.ts +1 -1
  102. package/dist/types/select/List.d.ts +1 -1
  103. package/dist/types/types/index.d.ts +9 -5
  104. package/dist/types/types/schema.d.ts +79 -33
  105. package/package.json +10 -7
  106. package/src/builder/FileField.tsx +53 -27
  107. package/src/builder/FormField.tsx +45 -32
  108. package/src/builder/SchemaEditor.tsx +72 -0
  109. package/src/builder/components/AddSchemaFields.tsx +74 -0
  110. package/src/builder/components/SchemaArrayForm.tsx +158 -0
  111. package/src/builder/components/SchemaField.tsx +435 -0
  112. package/src/form/Controller.tsx +2 -2
  113. package/src/form/Form.tsx +15 -8
  114. package/src/hooks/useFormBuilder.tsx +29 -15
  115. package/src/index.ts +10 -2
  116. package/src/input/ArrayInput.tsx +80 -42
  117. package/src/input/AvatarInput.tsx +1 -1
  118. package/src/input/Checkbox.tsx +5 -4
  119. package/src/input/ColorInput.tsx +102 -34
  120. package/src/input/ColorPicker.tsx +1 -35
  121. package/src/input/DateInput.tsx +248 -0
  122. package/src/input/Field.tsx +9 -11
  123. package/src/input/File.tsx +3 -6
  124. package/src/input/Hidden.tsx +4 -1
  125. package/src/input/Input.tsx +2 -2
  126. package/src/input/Number.tsx +2 -2
  127. package/src/input/Password.tsx +2 -2
  128. package/src/input/Radio.tsx +1 -1
  129. package/src/input/RadioGroup.tsx +27 -4
  130. package/src/input/{Range.tsx → RangeSlider.tsx} +2 -2
  131. package/src/input/Search.tsx +2 -2
  132. package/src/input/Slider.tsx +1 -1
  133. package/src/input/Switch.tsx +42 -6
  134. package/src/input/Textarea.tsx +11 -3
  135. package/src/internal/ErrorIcon.tsx +1 -1
  136. package/src/internal/FieldWrapper.tsx +3 -3
  137. package/src/internal/InputWrapper.tsx +21 -20
  138. package/src/select/AutoComplete.tsx +1 -1
  139. package/src/select/List.tsx +34 -7
  140. package/src/select/Options.tsx +1 -1
  141. package/src/select/Select.tsx +5 -2
  142. package/src/select/useSelect.tsx +27 -18
  143. package/src/types/index.ts +14 -7
  144. package/src/types/schema.ts +96 -41
  145. package/dist/cjs/input/ArrayInput.module.css +0 -1
  146. package/dist/cjs/input/ColorPicker.module.css +0 -1
  147. package/dist/cjs/input/File.module.css +0 -1
  148. package/dist/cjs/internal/Field.module.css +0 -1
  149. package/dist/esm/input/ArrayInput.module.css +0 -1
  150. package/dist/esm/input/ColorPicker.module.css +0 -1
  151. package/dist/esm/input/File.module.css +0 -1
  152. package/dist/esm/internal/Field.module.css +0 -1
@@ -21,20 +21,20 @@
21
21
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  */
23
23
 
24
- @layer var {
25
- .arrayInput {
24
+ @layer variants {
25
+ .fabric-arrayInput {
26
26
  & [data-ref="fieldWrapper"] {
27
27
  flex: 1 1 0%;
28
28
  }
29
29
 
30
- & .addButton :global(.buttonInner) {
31
- color: theme(colors.tint.600);
32
- outline: 1px dashed theme(colors.tint.600);
30
+ & .fabric-addButton .fabric-button {
31
+ color: var(--color-tint-600);
32
+ outline: 1px dashed var(--color-tint-600);
33
33
 
34
34
  &[data-invalid="true"] {
35
- color: theme(colors.danger.600);
36
- background-color: theme(colors.danger.100);
37
- outline: 1px dashed theme(colors.danger.600);
35
+ color: var(--color-danger-600);
36
+ background-color: var(--color-danger-100);
37
+ outline: 1px dashed var(--color-danger-600);
38
38
  }
39
39
  }
40
40
  }
@@ -0,0 +1,65 @@
1
+ /*
2
+ * React Fabric
3
+ * @version: 1.0.0
4
+ *
5
+ *
6
+ * The MIT License (MIT)
7
+ * Copyright (c) 2024 Adarsh Pastakia
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
10
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
11
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
12
+ * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
13
+ * subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all copies or substantial
16
+ * portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19
+ * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+
24
+ @layer components {
25
+ .fabric-colorPicker {
26
+ --color-shadow: var(--border-color-base);
27
+
28
+ & input {
29
+ padding: 0 4px !important;
30
+
31
+ line-height: 2;
32
+ color: var(--text-color-base);
33
+
34
+ background-color: var(--bg-color-base);
35
+ border: 1px solid var(--border-color-base);
36
+ border-radius: var(--rounded-sm);
37
+ box-shadow: none;
38
+
39
+ &:focus {
40
+ border-color: var(--border-primary-500);
41
+ }
42
+ }
43
+
44
+ & label {
45
+ color: var(--text-color-base);
46
+ }
47
+
48
+ & .flexbox-fix {
49
+ justify-content: center;
50
+ border-color: var(--border-color-muted);
51
+
52
+ & > div > div {
53
+ text-align: center;
54
+ }
55
+
56
+ & span > div {
57
+ box-shadow: 0 0 1px 1px var(--border-color-base) inset !important;
58
+ }
59
+ }
60
+
61
+ & .saturation-black ~ div {
62
+ pointer-events: none;
63
+ }
64
+ }
65
+ }
@@ -21,28 +21,28 @@
21
21
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  */
23
23
 
24
- @layer comp {
25
- .fieldWrapper {
24
+ @layer components {
25
+ .fabric-fieldWrapper {
26
26
  /* later */
27
27
  }
28
28
  }
29
29
 
30
- @layer var {
31
- .inputWrapper {
30
+ @layer variants {
31
+ .fabric-inputWrapper {
32
32
  &::after {
33
33
  inset-inline: 50%;
34
34
  transition: all 300ms;
35
35
  transition-delay: 100ms;
36
36
  }
37
37
 
38
- & .decorate:has([data-ref="button"]) {
38
+ & .fabric-decorate:has([data-ref="button"]) {
39
39
  display: flex;
40
40
  align-self: stretch;
41
41
  }
42
42
 
43
43
  &:has(input[disabled], textarea[disabled]) {
44
44
  cursor: not-allowed;
45
- background-color: theme(colors.tint.50);
45
+ background-color: var(--color-tint-50);
46
46
 
47
47
  & input,
48
48
  & textarea {
@@ -54,14 +54,14 @@
54
54
  &:has([data-open="true"]) {
55
55
  z-index: 1;
56
56
  background-color: var(--fabric-input-focus);
57
- outline-color: var(--primary);
57
+ outline-color: var(--color-primary);
58
58
 
59
59
  &:not(:has([aria-readonly="true"]:not([hidden])))::after {
60
60
  inset-inline: 0;
61
61
  }
62
62
  }
63
63
 
64
- &:global(.fixed) {
64
+ &.fixed {
65
65
  box-shadow: 0 0 2rem 0.5rem var(--fabric-shadow);
66
66
  }
67
67
 
@@ -71,7 +71,7 @@
71
71
  }
72
72
 
73
73
  & > input[type="number"] + .inputClear {
74
- margin-inline: -3rem 2rem;
74
+ margin-inline: -3rem 0;
75
75
  }
76
76
 
77
77
  & input::-ms-clear,
@@ -90,28 +90,39 @@
90
90
  letter-spacing: 2px;
91
91
  }
92
92
 
93
+ & input[type="date"]::-webkit-calendar-picker-indicator,
94
+ & input[type="datetime-local"]::-webkit-calendar-picker-indicator {
95
+ display: none;
96
+ appearance: none;
97
+ }
98
+
99
+ & input[type="date"].empty::-webkit-datetime-edit,
100
+ & input[type="datetime-local"].empty::-webkit-datetime-edit {
101
+ color: var(--color-tint-400);
102
+ }
103
+
93
104
  & input:-webkit-autofill {
94
105
  box-shadow: 0 0 0 999em var(--fabric-input) inset;
95
106
 
96
- -webkit-text-fill-color: theme(colors.accent.700);
107
+ -webkit-text-fill-color: var(--color-accent-700);
97
108
  }
98
109
 
99
110
  & input:-webkit-autofill:focus {
100
111
  box-shadow: 0 0 0 999em var(--fabric-input-focus) inset;
101
112
 
102
- -webkit-text-fill-color: theme(colors.accent.700);
113
+ -webkit-text-fill-color: var(--color-accent-700);
103
114
  }
104
115
 
105
- &.invalidWrapper {
106
- outline-color: theme(colors.danger.500);
116
+ &.fabric-invalidWrapper {
117
+ outline-color: var(--color-danger-500);
107
118
 
108
119
  &::after {
109
- background-color: theme(colors.danger.500);
120
+ background-color: var(--color-danger-500);
110
121
  }
111
122
  }
112
123
  }
113
124
 
114
- .fieldGroup {
125
+ .fabric-fieldGroup {
115
126
  > * {
116
127
  line-height: 1;
117
128
  }
@@ -21,22 +21,36 @@
21
21
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  */
23
23
 
24
- @layer comp {
25
- .fileInput {
24
+ @layer components {
25
+ .fabric-fileInput {
26
26
  &::-webkit-file-upload-button {
27
- @apply bg-primary-500 opacity-80 hover:opacity-90 text-white rounded border-none py-0 cursor-pointer;
27
+ cursor: pointer;
28
+
29
+ padding-block: 0;
30
+
31
+ color: var(--text-white);
32
+
33
+ opacity: 0.8;
34
+ background-color: var(--bg-primary-500);
35
+ border: 0;
36
+ border-radius: var(--rounded);
37
+
38
+ &:hover {
39
+ opacity: 0.9;
40
+ }
28
41
  }
29
42
 
30
43
  &[aria-invalid="true"]::-webkit-file-upload-button {
31
- @apply bg-danger-500;
44
+ background-color: var(--bg-danger-500);
32
45
  }
33
46
 
34
47
  &:disabled::-webkit-file-upload-button {
35
- @apply bg-muted pointer-events-none;
48
+ pointer-events: none;
49
+ background-color: var(--bg-color-muted);
36
50
  }
37
51
 
38
52
  &[readOnly] {
39
- @apply pointer-events-none;
53
+ pointer-events: none;
40
54
  }
41
55
  }
42
56
  }
package/css/styles.css ADDED
@@ -0,0 +1,27 @@
1
+ /*
2
+ * React Fabric
3
+ * @version: 1.0.0
4
+ *
5
+ *
6
+ * The MIT License (MIT)
7
+ * Copyright (c) 2025 Adarsh Pastakia
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
10
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
11
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
12
+ * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
13
+ * subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all copies or substantial
16
+ * portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19
+ * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+
24
+ @import "./_arrayInput.css";
25
+ @import "./_colorPicker.css";
26
+ @import "./_field.css";
27
+ @import "./_file.css";
@@ -7,23 +7,29 @@ var _regeneratorRuntime = require('@babel/runtime/regenerator');
7
7
  var core = require('@react-fabric/core');
8
8
  var utilities = require('@react-fabric/utilities');
9
9
  var react = require('react');
10
+ var reactI18next = require('react-i18next');
10
11
  var useFileUploader = require('../hooks/useFileUploader.js');
11
12
  var Field = require('../input/Field.js');
12
13
  var Hidden = require('../input/Hidden.js');
13
14
  var jsxRuntime = require('react/jsx-runtime');
14
15
 
15
- var _excluded = ["uploadHandler", "inline", "label", "accept", "multiple", "value"];
16
+ var _excluded = ["uploadHandler", "inline", "label", "accept", "value", "fileUrl", "multiple", "invalid", "error"];
16
17
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
18
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
18
19
  var FileField = function FileField(_ref) {
20
+ var _error$values$label, _error$values, _error$values2;
19
21
  var uploadHandler = _ref.uploadHandler,
20
22
  inline = _ref.inline,
21
23
  label = _ref.label,
22
24
  accept = _ref.accept,
23
- _ref$multiple = _ref.multiple,
24
- multiple = _ref$multiple === void 0 ? false : _ref$multiple,
25
- value = _ref.value,
25
+ value = _ref.value;
26
+ _ref.fileUrl;
27
+ var multiple = _ref.multiple;
28
+ _ref.invalid;
29
+ var error = _ref.error,
26
30
  rest = _objectWithoutProperties(_ref, _excluded);
31
+ var _useTranslation = reactI18next.useTranslation(),
32
+ t = _useTranslation.t;
27
33
  var _useFileUploader = useFileUploader.useFileUploader( /*#__PURE__*/function () {
28
34
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(data, config) {
29
35
  return _regeneratorRuntime.wrap(function _callee$(_context) {
@@ -49,32 +55,38 @@ var FileField = function FileField(_ref) {
49
55
  upload = _useFileUploader.upload,
50
56
  remove = _useFileUploader.remove;
51
57
  return /*#__PURE__*/jsxRuntime.jsxs(react.Fragment, {
52
- children: [/*#__PURE__*/jsxRuntime.jsxs(Field.Field, {
58
+ children: [/*#__PURE__*/jsxRuntime.jsx(Field.Field, {
53
59
  plain: true,
54
60
  inline: inline,
55
61
  label: label,
56
- className: "inline-block",
57
- children: [/*#__PURE__*/jsxRuntime.jsx(Hidden.HiddenInput, _objectSpread({
62
+ children: /*#__PURE__*/jsxRuntime.jsx(Hidden.HiddenInput, _objectSpread({
58
63
  hiddenValue: multiple ? list : list === null || list === void 0 ? void 0 : list[0]
59
- }, rest)), /*#__PURE__*/jsxRuntime.jsx("span", {
60
- children: /*#__PURE__*/jsxRuntime.jsx(core.Button, {
61
- badge: pending > 0 ? "".concat(pending) : undefined,
62
- "data-ref": "filebtn",
63
- children: /*#__PURE__*/jsxRuntime.jsxs(react.Fragment, {
64
- children: [/*#__PURE__*/jsxRuntime.jsx("span", {
65
- children: "Add file"
66
- }), /*#__PURE__*/jsxRuntime.jsx("input", {
67
- type: "file",
68
- accept: accept,
69
- multiple: multiple,
70
- className: "absolute inset-0 opacity-0 z-5",
71
- onChange: function onChange(e) {
72
- return [upload(e.target.files), e.target.value = ""];
73
- }
74
- })]
75
- })
64
+ }, rest))
65
+ }), /*#__PURE__*/jsxRuntime.jsx(core.Tooltip, {
66
+ color: "danger-200",
67
+ content: utilities.isString(error) ? "".concat(error) : error && t(error === null || error === void 0 ? void 0 : error.key, error.values ? _objectSpread(_objectSpread({}, error === null || error === void 0 ? void 0 : error.values), {}, {
68
+ label: t((_error$values$label = (_error$values = error.values) === null || _error$values === void 0 ? void 0 : _error$values.label) !== null && _error$values$label !== void 0 ? _error$values$label : "form:badkey", (_error$values2 = error.values) === null || _error$values2 === void 0 ? void 0 : _error$values2.path)
69
+ }) : {}),
70
+ disabled: !error,
71
+ children: /*#__PURE__*/jsxRuntime.jsx(core.Button, {
72
+ badge: pending > 0 ? "".concat(pending) : undefined,
73
+ color: error ? "danger" : undefined,
74
+ variant: error ? "soft" : undefined,
75
+ "data-ref": "filebtn",
76
+ children: /*#__PURE__*/jsxRuntime.jsxs(react.Fragment, {
77
+ children: [/*#__PURE__*/jsxRuntime.jsx("span", {
78
+ children: "Add file"
79
+ }), /*#__PURE__*/jsxRuntime.jsx("input", {
80
+ type: "file",
81
+ accept: accept,
82
+ multiple: multiple,
83
+ className: "absolute inset-0 opacity-0 z-5",
84
+ onChange: function onChange(e) {
85
+ return [upload(e.target.files), e.target.value = ""];
86
+ }
87
+ })]
76
88
  })
77
- })]
89
+ })
78
90
  }), /*#__PURE__*/jsxRuntime.jsx("br", {}), /*#__PURE__*/jsxRuntime.jsx("div", {
79
91
  className: "bg-alternate",
80
92
  children: files.map(function (file, idx) {
@@ -2,22 +2,25 @@
2
2
 
3
3
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
4
  var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
5
+ var utilities = require('@react-fabric/utilities');
5
6
  var react = require('react');
6
7
  var reactI18next = require('react-i18next');
7
8
  var Controller = require('../form/Controller.js');
8
9
  var ArrayInput = require('../input/ArrayInput.js');
9
10
  var AvatarInput = require('../input/AvatarInput.js');
10
11
  var ColorInput = require('../input/ColorInput.js');
12
+ var DateInput = require('../input/DateInput.js');
11
13
  var Input = require('../input/Input.js');
12
14
  var Number = require('../input/Number.js');
13
- var Range = require('../input/Range.js');
15
+ var RangeSlider = require('../input/RangeSlider.js');
14
16
  var Switch = require('../input/Switch.js');
15
17
  var Textarea = require('../input/Textarea.js');
16
18
  var Select = require('../select/Select.js');
19
+ var schema = require('../types/schema.js');
17
20
  var FileField = require('./FileField.js');
18
21
  var jsxRuntime = require('react/jsx-runtime');
19
22
 
20
- var _excluded = ["id", "label", "required", "inline", "prefix", "autoFocus", "defaultValue", "fileUrl", "uploadHandler"];
23
+ var _excluded = ["id", "label", "required", "inline", "prefix", "autoFocus", "optionLists", "fileUrl", "uploadHandler"];
21
24
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
22
25
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
23
26
  var FormField = function FormField(_ref) {
@@ -26,9 +29,9 @@ var FormField = function FormField(_ref) {
26
29
  required = _ref.required,
27
30
  inline = _ref.inline,
28
31
  prefix = _ref.prefix,
29
- autoFocus = _ref.autoFocus;
30
- _ref.defaultValue;
31
- var fileUrl = _ref.fileUrl,
32
+ autoFocus = _ref.autoFocus,
33
+ optionLists = _ref.optionLists,
34
+ fileUrl = _ref.fileUrl,
32
35
  uploadHandler = _ref.uploadHandler,
33
36
  rest = _objectWithoutProperties(_ref, _excluded);
34
37
  var _useTranslation = reactI18next.useTranslation(),
@@ -36,48 +39,55 @@ var FormField = function FormField(_ref) {
36
39
  var fieldName = react.useMemo(function () {
37
40
  return [prefix, id].filter(Boolean).join(".");
38
41
  }, [id, prefix]);
42
+ var hasOptions = react.useMemo(function () {
43
+ var _rest$optionList;
44
+ return rest.datatype === schema.DATA_TYPES.STRING && (rest.optionList === "--CUSTOM--" && !utilities.isEmpty(rest.options) || !utilities.isEmpty(optionLists === null || optionLists === void 0 ? void 0 : optionLists[(_rest$optionList = rest.optionList) !== null && _rest$optionList !== void 0 ? _rest$optionList : ""]));
45
+ }, [rest]);
39
46
  var E = react.useMemo(function () {
40
- if (rest.datatype === "number" || rest.datatype === "decimal") return Number.Number;
41
- if (rest.datatype === "range") return Range.Range;
42
- if (rest.datatype === "boolean") return Switch.Switch;
43
- if (rest.datatype === "text") return Textarea.Textarea;
44
- if (rest.datatype === "color") return ColorInput.ColorInput;
45
- if (rest.datatype === "string" && rest.options) return Select.Select;
47
+ if (rest.datatype === schema.DATA_TYPES.NUMBER) return Number.Number;
48
+ if (rest.datatype === schema.DATA_TYPES.RANGE) return RangeSlider.RangeSlider;
49
+ if (rest.datatype === schema.DATA_TYPES.BOOL) return Switch.Switch;
50
+ if (rest.datatype === schema.DATA_TYPES.TEXT) return Textarea.Textarea;
51
+ if (rest.datatype === schema.DATA_TYPES.DATE) return DateInput.DateInput;
52
+ if (rest.datatype === schema.DATA_TYPES.COLOR) return ColorInput.ColorInput;
53
+ if (hasOptions) return Select.Select;
46
54
  return Input.Input;
47
- }, [rest.datatype]);
55
+ }, [rest.datatype, hasOptions]);
48
56
  var props = react.useMemo(function () {
49
- var _rest$step, _rest$step2, _rest$min, _rest$max, _rest$step3;
50
- if (rest.datatype === "number") return {
57
+ var _rest$step, _rest$min, _rest$max, _rest$step2, _optionLists, _rest$optionList2;
58
+ if (rest.datatype === schema.DATA_TYPES.NUMBER) return {
51
59
  min: rest.min,
52
60
  max: rest.max,
53
61
  step: (_rest$step = rest.step) !== null && _rest$step !== void 0 ? _rest$step : 1
54
62
  };
55
- if (rest.datatype === "decimal") return {
56
- min: rest.min,
57
- max: rest.max,
58
- step: (_rest$step2 = rest.step) !== null && _rest$step2 !== void 0 ? _rest$step2 : 0.1
59
- };
60
- if (rest.datatype === "range") return {
63
+ if (rest.datatype === schema.DATA_TYPES.RANGE) return {
61
64
  min: (_rest$min = rest.min) !== null && _rest$min !== void 0 ? _rest$min : 1,
62
65
  max: (_rest$max = rest.max) !== null && _rest$max !== void 0 ? _rest$max : 99,
63
- step: (_rest$step3 = rest.step) !== null && _rest$step3 !== void 0 ? _rest$step3 : 1,
66
+ step: (_rest$step2 = rest.step) !== null && _rest$step2 !== void 0 ? _rest$step2 : 1,
64
67
  showValue: true,
65
68
  showLabels: true
66
69
  };
67
- if (rest.datatype === "text") return {
70
+ if (rest.datatype === schema.DATA_TYPES.DATE) return {
71
+ min: rest.min,
72
+ max: rest.max,
73
+ type: rest.type
74
+ };
75
+ if (rest.datatype === schema.DATA_TYPES.TEXT) return {
68
76
  rows: 3
69
77
  };
70
- if (rest.datatype === "color") return {
78
+ if (rest.datatype === schema.DATA_TYPES.COLOR) return {
71
79
  showPicker: true
72
80
  };
73
- if (rest.datatype === "string" && rest.options) return {
74
- options: rest.options,
81
+ if (rest.datatype === schema.DATA_TYPES.STRING && hasOptions) return _objectSpread({
75
82
  multiple: rest.multiple,
83
+ allowCreate: rest.allowCustom,
76
84
  searchable: true
77
- };
85
+ }, (_optionLists = optionLists === null || optionLists === void 0 ? void 0 : optionLists[(_rest$optionList2 = rest.optionList) !== null && _rest$optionList2 !== void 0 ? _rest$optionList2 : ""]) !== null && _optionLists !== void 0 ? _optionLists : {
86
+ options: rest.options
87
+ });
78
88
  return {};
79
- }, [rest]);
80
- if (rest.datatype === "avatar") return uploadHandler && /*#__PURE__*/jsxRuntime.jsx(Controller.Controller, {
89
+ }, [rest, hasOptions, optionLists]);
90
+ if (rest.datatype === schema.DATA_TYPES.AVATAR) return uploadHandler && /*#__PURE__*/jsxRuntime.jsx(Controller.Controller, {
81
91
  name: fieldName,
82
92
  children: /*#__PURE__*/jsxRuntime.jsx(AvatarInput.AvatarInput, {
83
93
  uploadHandler: uploadHandler,
@@ -85,7 +95,7 @@ var FormField = function FormField(_ref) {
85
95
  name: fieldName
86
96
  })
87
97
  });
88
- if (rest.datatype === "file") return uploadHandler && /*#__PURE__*/jsxRuntime.jsx(Controller.Controller, {
98
+ if (rest.datatype === schema.DATA_TYPES.FILE) return uploadHandler && /*#__PURE__*/jsxRuntime.jsx(Controller.Controller, {
89
99
  name: fieldName,
90
100
  children: /*#__PURE__*/jsxRuntime.jsx(FileField.FileField, _objectSpread({
91
101
  uploadHandler: uploadHandler,
@@ -94,12 +104,12 @@ var FormField = function FormField(_ref) {
94
104
  id: id
95
105
  }, rest))
96
106
  });
97
- return rest.multiple && !("options" in rest) ? /*#__PURE__*/jsxRuntime.jsx(ArrayInput.ArrayInput, {
107
+ return rest.multiple && !hasOptions ? /*#__PURE__*/jsxRuntime.jsx(ArrayInput.ArrayInput, {
98
108
  name: fieldName,
99
- label: t(label, label),
109
+ label: t("fb.".concat(id), label || id),
100
110
  required: required,
101
111
  onAdd: function onAdd() {
102
- return "";
112
+ return String("");
103
113
  },
104
114
  children: /*#__PURE__*/jsxRuntime.jsx(Controller.Controller, {
105
115
  children: /*#__PURE__*/jsxRuntime.jsx(E, _objectSpread({}, props))
@@ -108,8 +118,8 @@ var FormField = function FormField(_ref) {
108
118
  name: fieldName,
109
119
  children: /*#__PURE__*/jsxRuntime.jsx(E, _objectSpread(_objectSpread({}, props), {}, {
110
120
  autoFocus: autoFocus,
111
- label: t(label, label),
112
- placeholder: t(label, label),
121
+ label: t("fb.".concat(id), label || id),
122
+ placeholder: t("fb.".concat(id), label || id),
113
123
  required: required,
114
124
  inline: inline
115
125
  }))
@@ -0,0 +1,72 @@
1
+ 'use strict';
2
+
3
+ var core = require('@react-fabric/core');
4
+ var utilities = require('@react-fabric/utilities');
5
+ var react = require('react');
6
+ var Form = require('../form/Form.js');
7
+ var schema = require('../types/schema.js');
8
+ var SchemaArrayForm = require('./components/SchemaArrayForm.js');
9
+ var jsxRuntime = require('react/jsx-runtime');
10
+
11
+ /*
12
+ * React Fabric
13
+ * @version: 1.0.0
14
+ *
15
+ *
16
+ * The MIT License (MIT)
17
+ * Copyright (c) 2025 Adarsh Pastakia
18
+ *
19
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
20
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
21
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
22
+ * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
23
+ * subject to the following conditions:
24
+ *
25
+ * The above copyright notice and this permission notice shall be included in all copies or substantial
26
+ * portions of the Software.
27
+ *
28
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
29
+ * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
30
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
31
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32
+ */
33
+
34
+ var SchemaEditor = function SchemaEditor(_ref) {
35
+ var schemaDef = _ref.schemaDef,
36
+ dynamic = _ref.dynamic,
37
+ acceptableTypes = _ref.acceptableTypes,
38
+ _ref$optionLists = _ref.optionLists,
39
+ optionLists = _ref$optionLists === void 0 ? utilities.EMPTY_ARRAY : _ref$optionLists,
40
+ children = _ref.children,
41
+ onSubmit = _ref.onSubmit,
42
+ onChange = _ref.onChange;
43
+ var formRef = react.useRef(null);
44
+ var handleChange = react.useCallback(function (model) {
45
+ onChange === null || onChange === void 0 || onChange(model.schema);
46
+ }, []);
47
+ var handleSubmit = react.useCallback(function (model) {
48
+ onSubmit === null || onSubmit === void 0 || onSubmit(model.schema);
49
+ }, []);
50
+ react.useEffect(function () {
51
+ var _formRef$current;
52
+ (_formRef$current = formRef.current) === null || _formRef$current === void 0 || _formRef$current.setValues({
53
+ schema: schemaDef
54
+ });
55
+ }, [schemaDef]);
56
+ return /*#__PURE__*/jsxRuntime.jsxs(Form.Form, {
57
+ formRef: formRef,
58
+ onChange: handleChange,
59
+ onSubmit: handleSubmit,
60
+ children: [/*#__PURE__*/jsxRuntime.jsx(SchemaArrayForm.SchemaArrayForm, {
61
+ dynamic: dynamic,
62
+ optionLists: optionLists,
63
+ acceptableTypes: acceptableTypes !== null && acceptableTypes !== void 0 ? acceptableTypes : Object.values(schema.DATA_TYPES)
64
+ }), children && /*#__PURE__*/jsxRuntime.jsx(core.Footer, {
65
+ flex: true,
66
+ className: "border-t bg-base px-6 py-2",
67
+ children: children
68
+ })]
69
+ });
70
+ };
71
+
72
+ exports.SchemaEditor = SchemaEditor;
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+
3
+ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
+ var core = require('@react-fabric/core');
5
+ var utilities = require('@react-fabric/utilities');
6
+ var react = require('react');
7
+ var Controller = require('../../form/Controller.js');
8
+ var Form = require('../../form/Form.js');
9
+ var ArrayInput = require('../../input/ArrayInput.js');
10
+ var Input = require('../../input/Input.js');
11
+ var jsxRuntime = require('react/jsx-runtime');
12
+
13
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
+ var fieldSchema = utilities.yup.object({
16
+ fields: utilities.yup.array(utilities.yup.string().trim().required()).required().min(1)
17
+ });
18
+ var AddSchemaFields = function AddSchemaFields(props) {
19
+ var handleSubmit = react.useCallback(function (model) {
20
+ props.onClose(model.fields.map(function (f) {
21
+ return f.split(",").map(function (ff) {
22
+ return ff.trim();
23
+ });
24
+ }).flat(2));
25
+ }, []);
26
+ return /*#__PURE__*/jsxRuntime.jsx(core.Modal, _objectSpread(_objectSpread({}, props), {}, {
27
+ children: /*#__PURE__*/jsxRuntime.jsxs(Form.Form, {
28
+ schema: fieldSchema,
29
+ defaultValues: {
30
+ fields: [" "]
31
+ },
32
+ onSubmit: handleSubmit,
33
+ children: [/*#__PURE__*/jsxRuntime.jsxs(core.Content, {
34
+ children: [/*#__PURE__*/jsxRuntime.jsx(ArrayInput.ArrayInput, {
35
+ minItems: 1,
36
+ name: "fields",
37
+ onAdd: function onAdd() {
38
+ return String("");
39
+ },
40
+ children: /*#__PURE__*/jsxRuntime.jsx(Controller.Controller, {
41
+ children: /*#__PURE__*/jsxRuntime.jsx(Input.Input, {
42
+ autoFocus: true
43
+ })
44
+ })
45
+ }), /*#__PURE__*/jsxRuntime.jsx("p", {
46
+ className: "text-sm text-muted",
47
+ children: "Provide list of fields or comma-separated value"
48
+ })]
49
+ }), /*#__PURE__*/jsxRuntime.jsx(core.Footer, {
50
+ flex: true,
51
+ justify: "end",
52
+ className: "px-2 py-1",
53
+ children: /*#__PURE__*/jsxRuntime.jsx(core.Button, {
54
+ type: "submit",
55
+ children: "Add"
56
+ })
57
+ })]
58
+ })
59
+ }));
60
+ };
61
+
62
+ exports.AddSchemaFields = AddSchemaFields;