@react-fabric/form 1.0.0-beta.6 → 1.0.0-beta.60
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/{src/input/ArrayInput.module.css → css/_arrayInput.css} +8 -8
- package/css/_colorPicker.css +65 -0
- package/{src/internal/Field.module.css → css/_field.css} +66 -30
- package/{src/input/File.module.css → css/_file.css} +21 -6
- package/css/styles.css +27 -0
- package/dist/cjs/builder/FileField.js +40 -28
- package/dist/cjs/builder/FormField.js +50 -34
- package/dist/cjs/builder/SchemaEditor.js +72 -0
- package/dist/cjs/builder/components/AddSchemaFields.js +62 -0
- package/dist/cjs/builder/components/SchemaArrayForm.js +145 -0
- package/dist/cjs/builder/components/SchemaField.js +414 -0
- package/dist/cjs/form/Controller.js +46 -1
- package/dist/cjs/form/Form.js +70 -9
- package/dist/cjs/hooks/useFileUploader.js +16 -0
- package/dist/cjs/hooks/useFormBuilder.js +57 -15
- package/dist/cjs/i18n/ar.json.js +5 -4
- package/dist/cjs/i18n/en.json.js +5 -5
- package/dist/cjs/index.js +12 -2
- package/dist/cjs/input/ArrayInput.js +126 -36
- package/dist/cjs/input/AvatarInput.js +43 -23
- package/dist/cjs/input/Checkbox.js +16 -6
- package/dist/cjs/input/ColorInput.js +113 -58
- package/dist/cjs/input/ColorPicker.js +60 -76
- package/dist/cjs/input/DateInput.js +197 -0
- package/dist/cjs/input/Field.js +10 -4
- package/dist/cjs/input/File.js +14 -7
- package/dist/cjs/input/Hidden.js +13 -2
- package/dist/cjs/input/Input.js +24 -10
- package/dist/cjs/input/Number.js +22 -10
- package/dist/cjs/input/Password.js +22 -12
- package/dist/cjs/input/Radio.js +12 -3
- package/dist/cjs/input/RadioGroup.js +10 -1
- package/dist/cjs/input/{Range.js → RangeSlider.js} +16 -8
- package/dist/cjs/input/Search.js +30 -19
- package/dist/cjs/input/Slider.js +12 -6
- package/dist/cjs/input/Switch.js +20 -9
- package/dist/cjs/input/Textarea.js +29 -8
- package/dist/cjs/internal/ErrorIcon.js +1 -1
- package/dist/cjs/internal/FieldWrapper.js +11 -4
- package/dist/cjs/internal/InputWrapper.js +27 -20
- package/dist/cjs/select/AutoComplete.js +21 -11
- package/dist/cjs/select/DualList.js +34 -12
- package/dist/cjs/select/List.js +68 -22
- package/dist/cjs/select/Options.js +49 -42
- package/dist/cjs/select/Select.js +40 -10
- package/dist/cjs/select/useSelect.js +22 -11
- package/dist/cjs/types/schema.js +43 -0
- package/dist/cjs/utils/eventHandlers.js +15 -5
- package/dist/esm/builder/FileField.js +42 -30
- package/dist/esm/builder/FormField.js +50 -34
- package/dist/esm/builder/SchemaEditor.js +72 -0
- package/dist/esm/builder/components/AddSchemaFields.js +62 -0
- package/dist/esm/builder/components/SchemaArrayForm.js +145 -0
- package/dist/esm/builder/components/SchemaField.js +414 -0
- package/dist/esm/form/Controller.js +46 -1
- package/dist/esm/form/Form.js +72 -12
- package/dist/esm/hooks/useFileUploader.js +16 -0
- package/dist/esm/hooks/useFormBuilder.js +55 -13
- package/dist/esm/i18n/ar.json.js +5 -4
- package/dist/esm/i18n/en.json.js +5 -5
- package/dist/esm/index.js +6 -2
- package/dist/esm/input/ArrayInput.js +126 -36
- package/dist/esm/input/AvatarInput.js +44 -24
- package/dist/esm/input/Checkbox.js +16 -6
- package/dist/esm/input/ColorInput.js +115 -60
- package/dist/esm/input/ColorPicker.js +60 -76
- package/dist/esm/input/DateInput.js +197 -0
- package/dist/esm/input/Field.js +11 -5
- package/dist/esm/input/File.js +16 -9
- package/dist/esm/input/Hidden.js +13 -2
- package/dist/esm/input/Input.js +26 -12
- package/dist/esm/input/Number.js +24 -12
- package/dist/esm/input/Password.js +24 -14
- package/dist/esm/input/Radio.js +12 -3
- package/dist/esm/input/RadioGroup.js +11 -2
- package/dist/esm/input/{Range.js → RangeSlider.js} +16 -8
- package/dist/esm/input/Search.js +32 -21
- package/dist/esm/input/Slider.js +12 -6
- package/dist/esm/input/Switch.js +20 -9
- package/dist/esm/input/Textarea.js +30 -9
- package/dist/esm/internal/ErrorIcon.js +1 -1
- package/dist/esm/internal/FieldWrapper.js +11 -4
- package/dist/esm/internal/InputWrapper.js +27 -20
- package/dist/esm/select/AutoComplete.js +21 -11
- package/dist/esm/select/DualList.js +34 -12
- package/dist/esm/select/List.js +69 -23
- package/dist/esm/select/Options.js +49 -42
- package/dist/esm/select/Select.js +40 -10
- package/dist/esm/select/useSelect.js +23 -12
- package/{src/input/ColorPicker.module.css → dist/esm/types/schema.js} +18 -27
- package/dist/esm/utils/eventHandlers.js +15 -5
- package/dist/types/builder/FileField.d.ts +4 -2
- package/dist/types/builder/FormField.d.ts +3 -1
- package/dist/types/builder/SchemaEditor.d.ts +9 -0
- package/dist/types/builder/components/AddSchemaFields.d.ts +2 -0
- package/dist/types/builder/components/SchemaArrayForm.d.ts +2 -0
- package/dist/types/builder/components/SchemaField.d.ts +10 -0
- package/dist/types/form/Controller.d.ts +47 -2
- package/dist/types/form/Form.d.ts +48 -2
- package/dist/types/hooks/useFileUploader.d.ts +16 -0
- package/dist/types/hooks/useFormBuilder.d.ts +32 -1
- package/dist/types/index.d.ts +6 -3
- package/dist/types/input/ArrayInput.d.ts +69 -12
- package/dist/types/input/AvatarInput.d.ts +23 -3
- package/dist/types/input/Checkbox.d.ts +13 -4
- package/dist/types/input/ColorInput.d.ts +15 -2
- package/dist/types/input/ColorPicker.d.ts +11 -1
- package/dist/types/input/DateInput.d.ts +28 -0
- package/dist/types/input/Field.d.ts +5 -1
- package/dist/types/input/File.d.ts +9 -0
- package/dist/types/input/Hidden.d.ts +13 -1
- package/dist/types/input/Input.d.ts +9 -1
- package/dist/types/input/Number.d.ts +9 -1
- package/dist/types/input/Password.d.ts +7 -1
- package/dist/types/input/Radio.d.ts +9 -1
- package/dist/types/input/RadioGroup.d.ts +8 -1
- package/dist/types/input/RangeSlider.d.ts +67 -0
- package/dist/types/input/Search.d.ts +14 -1
- package/dist/types/input/Slider.d.ts +8 -2
- package/dist/types/input/Switch.d.ts +10 -2
- package/dist/types/input/Textarea.d.ts +15 -1
- package/dist/types/internal/FieldWrapper.d.ts +1 -1
- package/dist/types/internal/InputWrapper.d.ts +1 -1
- package/dist/types/ranger/index.d.ts +2 -2
- package/dist/types/select/AutoComplete.d.ts +8 -1
- package/dist/types/select/DualList.d.ts +17 -2
- package/dist/types/select/List.d.ts +9 -1
- package/dist/types/select/Options.d.ts +4 -3
- package/dist/types/select/Select.d.ts +9 -1
- package/dist/types/select/useSelect.d.ts +10 -6
- package/dist/types/types/index.d.ts +34 -5
- package/dist/types/types/schema.d.ts +78 -33
- package/dist/types/utils/eventHandlers.d.ts +2 -2
- package/package.json +22 -20
- package/src/builder/FileField.tsx +62 -30
- package/src/builder/FormField.tsx +52 -32
- package/src/builder/SchemaEditor.tsx +79 -0
- package/src/builder/components/AddSchemaFields.tsx +74 -0
- package/src/builder/components/SchemaArrayForm.tsx +161 -0
- package/src/builder/components/SchemaField.tsx +436 -0
- package/src/form/Controller.tsx +48 -3
- package/src/form/Form.tsx +80 -8
- package/src/hooks/useFileUploader.ts +16 -0
- package/src/hooks/useFormBuilder.tsx +58 -15
- package/src/i18n/ar.json +5 -4
- package/src/i18n/en.json +5 -5
- package/src/index.ts +12 -3
- package/src/input/ArrayInput.tsx +199 -64
- package/src/input/AvatarInput.tsx +67 -19
- package/src/input/Checkbox.tsx +16 -6
- package/src/input/ColorInput.tsx +131 -71
- package/src/input/ColorPicker.tsx +54 -72
- package/src/input/DateInput.tsx +260 -0
- package/src/input/Field.tsx +15 -11
- package/src/input/File.tsx +16 -14
- package/src/input/Hidden.tsx +17 -2
- package/src/input/Input.tsx +27 -13
- package/src/input/Number.tsx +22 -13
- package/src/input/Password.tsx +24 -16
- package/src/input/Radio.tsx +12 -3
- package/src/input/RadioGroup.tsx +12 -3
- package/src/input/{Range.tsx → RangeSlider.tsx} +17 -9
- package/src/input/Search.tsx +33 -22
- package/src/input/Slider.tsx +20 -11
- package/src/input/Switch.tsx +17 -6
- package/src/input/Textarea.tsx +34 -9
- package/src/internal/ErrorIcon.tsx +1 -1
- package/src/internal/FieldWrapper.tsx +8 -4
- package/src/internal/InputWrapper.tsx +49 -27
- package/src/select/AutoComplete.tsx +14 -3
- package/src/select/DualList.tsx +31 -16
- package/src/select/List.tsx +52 -8
- package/src/select/Options.tsx +50 -46
- package/src/select/Select.tsx +25 -5
- package/src/select/useSelect.tsx +26 -9
- package/src/types/index.ts +37 -6
- package/src/types/schema.ts +96 -41
- package/src/utils/eventHandlers.ts +14 -4
- package/dist/cjs/input/ArrayInput.module.css +0 -1
- package/dist/cjs/input/ColorPicker.module.css +0 -1
- package/dist/cjs/input/File.module.css +0 -1
- package/dist/cjs/internal/Field.module.css +0 -1
- package/dist/esm/input/ArrayInput.module.css +0 -1
- package/dist/esm/input/ColorPicker.module.css +0 -1
- package/dist/esm/input/File.module.css +0 -1
- package/dist/esm/internal/Field.module.css +0 -1
- package/dist/types/input/Range.d.ts +0 -59
|
@@ -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
|
|
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
|
|
31
|
-
color:
|
|
32
|
-
outline: 1px dashed
|
|
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:
|
|
36
|
-
background-color:
|
|
37
|
-
outline: 1px dashed
|
|
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
|
|
25
|
-
.fieldWrapper {
|
|
26
|
-
|
|
24
|
+
@layer components {
|
|
25
|
+
.fabric-fieldWrapper {
|
|
26
|
+
padding: 1px;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
@layer
|
|
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:
|
|
45
|
+
background-color: var(--color-tint-50);
|
|
46
46
|
|
|
47
47
|
& input,
|
|
48
48
|
& textarea {
|
|
@@ -54,24 +54,25 @@
|
|
|
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
|
-
|
|
64
|
+
&.fixed {
|
|
65
65
|
box-shadow: 0 0 2rem 0.5rem var(--fabric-shadow);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
& input,
|
|
69
69
|
& textarea {
|
|
70
70
|
max-width: 100%;
|
|
71
|
+
line-height: 1.25;
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
& > input[type="number"] + .inputClear {
|
|
74
|
-
margin-inline: -3rem
|
|
75
|
+
margin-inline: -3rem 0;
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
& input::-ms-clear,
|
|
@@ -90,49 +91,84 @@
|
|
|
90
91
|
letter-spacing: 2px;
|
|
91
92
|
}
|
|
92
93
|
|
|
94
|
+
& input[type="date"]::-webkit-calendar-picker-indicator,
|
|
95
|
+
& input[type="datetime-local"]::-webkit-calendar-picker-indicator {
|
|
96
|
+
display: none;
|
|
97
|
+
appearance: none;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
& input[type="date"].empty::-webkit-datetime-edit,
|
|
101
|
+
& input[type="datetime-local"].empty::-webkit-datetime-edit {
|
|
102
|
+
color: var(--color-tint-400);
|
|
103
|
+
}
|
|
104
|
+
|
|
93
105
|
& input:-webkit-autofill {
|
|
94
106
|
box-shadow: 0 0 0 999em var(--fabric-input) inset;
|
|
95
107
|
|
|
96
|
-
-webkit-text-fill-color:
|
|
108
|
+
-webkit-text-fill-color: var(--color-accent-700);
|
|
97
109
|
}
|
|
98
110
|
|
|
99
111
|
& input:-webkit-autofill:focus {
|
|
100
112
|
box-shadow: 0 0 0 999em var(--fabric-input-focus) inset;
|
|
101
113
|
|
|
102
|
-
-webkit-text-fill-color:
|
|
114
|
+
-webkit-text-fill-color: var(--color-accent-700);
|
|
103
115
|
}
|
|
104
116
|
|
|
105
|
-
&.invalidWrapper {
|
|
106
|
-
outline-color:
|
|
117
|
+
&.fabric-invalidWrapper {
|
|
118
|
+
outline-color: var(--color-danger-500);
|
|
107
119
|
|
|
108
120
|
&::after {
|
|
109
|
-
background-color:
|
|
121
|
+
background-color: var(--color-danger-500);
|
|
110
122
|
}
|
|
111
123
|
}
|
|
112
124
|
}
|
|
113
125
|
|
|
114
|
-
.fieldGroup {
|
|
126
|
+
.fabric-fieldGroup {
|
|
115
127
|
> * {
|
|
116
128
|
line-height: 1;
|
|
117
129
|
}
|
|
118
130
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
131
|
+
&[data-vertical="false"] {
|
|
132
|
+
> :not(:first-child) {
|
|
133
|
+
&,
|
|
134
|
+
& > div,
|
|
135
|
+
& > [role="button"],
|
|
136
|
+
& > [data-ref="button"] > [role="button"] {
|
|
137
|
+
border-start-start-radius: 0;
|
|
138
|
+
border-end-start-radius: 0;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
> :not(:last-child) {
|
|
143
|
+
&,
|
|
144
|
+
& > div,
|
|
145
|
+
& > [role="button"],
|
|
146
|
+
& > [data-ref="button"] > [role="button"] {
|
|
147
|
+
border-start-end-radius: 0;
|
|
148
|
+
border-end-end-radius: 0;
|
|
149
|
+
}
|
|
126
150
|
}
|
|
127
151
|
}
|
|
128
152
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
153
|
+
&[data-vertical="true"] {
|
|
154
|
+
> :not(:first-child) {
|
|
155
|
+
&,
|
|
156
|
+
& > div,
|
|
157
|
+
& > [role="button"],
|
|
158
|
+
& > [data-ref="button"] > [role="button"] {
|
|
159
|
+
border-start-start-radius: 0;
|
|
160
|
+
border-start-end-radius: 0;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
> :not(:last-child) {
|
|
165
|
+
&,
|
|
166
|
+
& > div,
|
|
167
|
+
& > [role="button"],
|
|
168
|
+
& > [data-ref="button"] > [role="button"] {
|
|
169
|
+
border-end-start-radius: 0;
|
|
170
|
+
border-end-end-radius: 0;
|
|
171
|
+
}
|
|
136
172
|
}
|
|
137
173
|
}
|
|
138
174
|
}
|
|
@@ -21,22 +21,37 @@
|
|
|
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
|
|
25
|
-
.fileInput {
|
|
24
|
+
@layer components {
|
|
25
|
+
.fabric-fileInput {
|
|
26
26
|
&::-webkit-file-upload-button {
|
|
27
|
-
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
|
|
29
|
+
padding-block: 0;
|
|
30
|
+
padding-inline: 4px;
|
|
31
|
+
|
|
32
|
+
color: var(--color-white);
|
|
33
|
+
|
|
34
|
+
opacity: 0.8;
|
|
35
|
+
background-color: var(--color-primary-500);
|
|
36
|
+
border: 0;
|
|
37
|
+
border-radius: var(--rounded);
|
|
38
|
+
|
|
39
|
+
&:hover {
|
|
40
|
+
opacity: 0.9;
|
|
41
|
+
}
|
|
28
42
|
}
|
|
29
43
|
|
|
30
44
|
&[aria-invalid="true"]::-webkit-file-upload-button {
|
|
31
|
-
|
|
45
|
+
background-color: var(--color-danger-500);
|
|
32
46
|
}
|
|
33
47
|
|
|
34
48
|
&:disabled::-webkit-file-upload-button {
|
|
35
|
-
|
|
49
|
+
pointer-events: none;
|
|
50
|
+
background-color: var(--bg-color-muted);
|
|
36
51
|
}
|
|
37
52
|
|
|
38
53
|
&[readOnly] {
|
|
39
|
-
|
|
54
|
+
pointer-events: none;
|
|
40
55
|
}
|
|
41
56
|
}
|
|
42
57
|
}
|
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", "
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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.
|
|
58
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Field.Field, {
|
|
53
59
|
plain: true,
|
|
54
60
|
inline: inline,
|
|
55
61
|
label: label,
|
|
56
|
-
|
|
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))
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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) {
|
|
@@ -98,18 +110,18 @@ var FileField = function FileField(_ref) {
|
|
|
98
110
|
children: file.error
|
|
99
111
|
})
|
|
100
112
|
}), file.progress && /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
|
|
101
|
-
icon:
|
|
113
|
+
icon: core.CoreIcons.stop,
|
|
102
114
|
bg: "danger",
|
|
103
115
|
color: "white",
|
|
104
116
|
size: "sm",
|
|
105
|
-
className: "p-
|
|
117
|
+
className: "p-0.5",
|
|
106
118
|
"aria-label": "abort",
|
|
107
119
|
onClick: function onClick() {
|
|
108
120
|
var _file$abort;
|
|
109
121
|
return (_file$abort = file.abort) === null || _file$abort === void 0 ? void 0 : _file$abort.call(file);
|
|
110
122
|
}
|
|
111
123
|
}), !file.progress && /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
|
|
112
|
-
icon:
|
|
124
|
+
icon: core.CoreIcons.trash,
|
|
113
125
|
color: "danger",
|
|
114
126
|
size: "sm",
|
|
115
127
|
"aria-label": "remove",
|
|
@@ -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
|
|
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", "
|
|
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.
|
|
31
|
-
|
|
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,61 @@ 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 ===
|
|
41
|
-
if (rest.datatype ===
|
|
42
|
-
if (rest.datatype ===
|
|
43
|
-
if (rest.datatype ===
|
|
44
|
-
if (rest.datatype ===
|
|
45
|
-
if (rest.datatype ===
|
|
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.DATETIME) return DateInput.DateInput;
|
|
53
|
+
if (rest.datatype === schema.DATA_TYPES.COLOR) return ColorInput.ColorInput;
|
|
54
|
+
if (hasOptions) return Select.Select;
|
|
46
55
|
return Input.Input;
|
|
47
|
-
}, [rest.datatype]);
|
|
56
|
+
}, [rest.datatype, hasOptions]);
|
|
48
57
|
var props = react.useMemo(function () {
|
|
49
|
-
var _rest$step, _rest$
|
|
50
|
-
if (rest.datatype ===
|
|
58
|
+
var _rest$step, _rest$min, _rest$max, _rest$step2, _optionLists, _rest$optionList2;
|
|
59
|
+
if (rest.datatype === schema.DATA_TYPES.NUMBER) return {
|
|
51
60
|
min: rest.min,
|
|
52
61
|
max: rest.max,
|
|
53
62
|
step: (_rest$step = rest.step) !== null && _rest$step !== void 0 ? _rest$step : 1
|
|
54
63
|
};
|
|
55
|
-
if (rest.datatype ===
|
|
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 {
|
|
64
|
+
if (rest.datatype === schema.DATA_TYPES.RANGE) return {
|
|
61
65
|
min: (_rest$min = rest.min) !== null && _rest$min !== void 0 ? _rest$min : 1,
|
|
62
66
|
max: (_rest$max = rest.max) !== null && _rest$max !== void 0 ? _rest$max : 99,
|
|
63
|
-
step: (_rest$
|
|
67
|
+
step: (_rest$step2 = rest.step) !== null && _rest$step2 !== void 0 ? _rest$step2 : 1,
|
|
64
68
|
showValue: true,
|
|
65
69
|
showLabels: true
|
|
66
70
|
};
|
|
67
|
-
if (rest.datatype ===
|
|
71
|
+
if (rest.datatype === schema.DATA_TYPES.DATE) return {
|
|
72
|
+
min: rest.min,
|
|
73
|
+
max: rest.max,
|
|
74
|
+
type: "date"
|
|
75
|
+
};
|
|
76
|
+
if (rest.datatype === schema.DATA_TYPES.DATETIME) return {
|
|
77
|
+
min: rest.min,
|
|
78
|
+
max: rest.max,
|
|
79
|
+
type: "datetime"
|
|
80
|
+
};
|
|
81
|
+
if (rest.datatype === schema.DATA_TYPES.TEXT) return {
|
|
68
82
|
rows: 3
|
|
69
83
|
};
|
|
70
|
-
if (rest.datatype ===
|
|
84
|
+
if (rest.datatype === schema.DATA_TYPES.COLOR) return {
|
|
71
85
|
showPicker: true
|
|
72
86
|
};
|
|
73
|
-
if (rest.datatype ===
|
|
74
|
-
options: rest.options,
|
|
87
|
+
if (rest.datatype === schema.DATA_TYPES.STRING && hasOptions) return _objectSpread({
|
|
75
88
|
multiple: rest.multiple,
|
|
89
|
+
allowCreate: rest.allowCustom,
|
|
76
90
|
searchable: true
|
|
77
|
-
}
|
|
91
|
+
}, (_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 : {
|
|
92
|
+
options: rest.options
|
|
93
|
+
});
|
|
78
94
|
return {};
|
|
79
|
-
}, [rest]);
|
|
80
|
-
if (rest.datatype ===
|
|
95
|
+
}, [rest, hasOptions, optionLists]);
|
|
96
|
+
if (rest.datatype === schema.DATA_TYPES.AVATAR) return uploadHandler && /*#__PURE__*/jsxRuntime.jsx(Controller.Controller, {
|
|
81
97
|
name: fieldName,
|
|
82
98
|
children: /*#__PURE__*/jsxRuntime.jsx(AvatarInput.AvatarInput, {
|
|
83
99
|
uploadHandler: uploadHandler,
|
|
@@ -85,7 +101,7 @@ var FormField = function FormField(_ref) {
|
|
|
85
101
|
name: fieldName
|
|
86
102
|
})
|
|
87
103
|
});
|
|
88
|
-
if (rest.datatype ===
|
|
104
|
+
if (rest.datatype === schema.DATA_TYPES.FILE) return uploadHandler && /*#__PURE__*/jsxRuntime.jsx(Controller.Controller, {
|
|
89
105
|
name: fieldName,
|
|
90
106
|
children: /*#__PURE__*/jsxRuntime.jsx(FileField.FileField, _objectSpread({
|
|
91
107
|
uploadHandler: uploadHandler,
|
|
@@ -94,12 +110,12 @@ var FormField = function FormField(_ref) {
|
|
|
94
110
|
id: id
|
|
95
111
|
}, rest))
|
|
96
112
|
});
|
|
97
|
-
return rest.multiple && !
|
|
113
|
+
return rest.multiple && !hasOptions ? /*#__PURE__*/jsxRuntime.jsx(ArrayInput.ArrayInput, {
|
|
98
114
|
name: fieldName,
|
|
99
|
-
label: t(
|
|
115
|
+
label: t("fb.".concat(id), label || id),
|
|
100
116
|
required: required,
|
|
101
117
|
onAdd: function onAdd() {
|
|
102
|
-
return "";
|
|
118
|
+
return String("");
|
|
103
119
|
},
|
|
104
120
|
children: /*#__PURE__*/jsxRuntime.jsx(Controller.Controller, {
|
|
105
121
|
children: /*#__PURE__*/jsxRuntime.jsx(E, _objectSpread({}, props))
|
|
@@ -108,8 +124,8 @@ var FormField = function FormField(_ref) {
|
|
|
108
124
|
name: fieldName,
|
|
109
125
|
children: /*#__PURE__*/jsxRuntime.jsx(E, _objectSpread(_objectSpread({}, props), {}, {
|
|
110
126
|
autoFocus: autoFocus,
|
|
111
|
-
label: t(
|
|
112
|
-
placeholder: t(
|
|
127
|
+
label: t("fb.".concat(id), label || id),
|
|
128
|
+
placeholder: t("fb.".concat(id), label || id),
|
|
113
129
|
required: required,
|
|
114
130
|
inline: inline
|
|
115
131
|
}))
|