@rokkit/forms 1.0.0-next.122

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 (84) hide show
  1. package/dist/src/forms-old/input/types.d.ts +7 -0
  2. package/dist/src/forms-old/lib/form.d.ts +95 -0
  3. package/dist/src/forms-old/lib/index.d.ts +1 -0
  4. package/dist/src/index.d.ts +5 -0
  5. package/dist/src/input/index.d.ts +18 -0
  6. package/dist/src/lib/builder.svelte.d.ts +140 -0
  7. package/dist/src/lib/deprecated/nested.d.ts +48 -0
  8. package/dist/src/lib/deprecated/nested.spec.d.ts +1 -0
  9. package/dist/src/lib/deprecated/validator.d.ts +30 -0
  10. package/dist/src/lib/deprecated/validator.spec.d.ts +1 -0
  11. package/dist/src/lib/fields.d.ts +16 -0
  12. package/dist/src/lib/fields.spec.d.ts +1 -0
  13. package/dist/src/lib/index.d.ts +7 -0
  14. package/dist/src/lib/layout.d.ts +7 -0
  15. package/dist/src/lib/schema.d.ts +7 -0
  16. package/dist/src/lib/validation.d.ts +41 -0
  17. package/dist/src/types.d.ts +5 -0
  18. package/package.json +38 -0
  19. package/src/DataEditor.svelte +30 -0
  20. package/src/FieldLayout.svelte +48 -0
  21. package/src/FormRenderer.svelte +118 -0
  22. package/src/Input.svelte +75 -0
  23. package/src/InputField.svelte +55 -0
  24. package/src/ListEditor.svelte +44 -0
  25. package/src/NestedEditor.svelte +85 -0
  26. package/src/forms-old/CheckBox.svelte +56 -0
  27. package/src/forms-old/DataEditor.svelte +30 -0
  28. package/src/forms-old/FieldLayout.svelte +48 -0
  29. package/src/forms-old/Form.svelte +17 -0
  30. package/src/forms-old/Icon.svelte +76 -0
  31. package/src/forms-old/Item.svelte +25 -0
  32. package/src/forms-old/ListEditor.svelte +44 -0
  33. package/src/forms-old/Tabs.svelte +57 -0
  34. package/src/forms-old/Wrapper.svelte +12 -0
  35. package/src/forms-old/input/Input.svelte +17 -0
  36. package/src/forms-old/input/InputField.svelte +70 -0
  37. package/src/forms-old/input/InputSelect.svelte +23 -0
  38. package/src/forms-old/input/InputSwitch.svelte +19 -0
  39. package/src/forms-old/input/types.js +29 -0
  40. package/src/forms-old/lib/form.js +72 -0
  41. package/src/forms-old/lib/index.js +12 -0
  42. package/src/forms-old/mocks/CustomField.svelte +7 -0
  43. package/src/forms-old/mocks/CustomWrapper.svelte +8 -0
  44. package/src/forms-old/mocks/Register.svelte +25 -0
  45. package/src/index.js +7 -0
  46. package/src/inp/Input.svelte +17 -0
  47. package/src/inp/InputField.svelte +69 -0
  48. package/src/inp/InputSelect.svelte +23 -0
  49. package/src/inp/InputSwitch.svelte +19 -0
  50. package/src/input/InputCheckbox.svelte +74 -0
  51. package/src/input/InputColor.svelte +42 -0
  52. package/src/input/InputDate.svelte +54 -0
  53. package/src/input/InputDateTime.svelte +54 -0
  54. package/src/input/InputEmail.svelte +63 -0
  55. package/src/input/InputFile.svelte +45 -0
  56. package/src/input/InputMonth.svelte +54 -0
  57. package/src/input/InputNumber.svelte +57 -0
  58. package/src/input/InputPassword.svelte +60 -0
  59. package/src/input/InputRadio.svelte +60 -0
  60. package/src/input/InputRange.svelte +51 -0
  61. package/src/input/InputSelect.svelte +71 -0
  62. package/src/input/InputSwitch.svelte +29 -0
  63. package/src/input/InputTel.svelte +60 -0
  64. package/src/input/InputText.svelte +60 -0
  65. package/src/input/InputTextArea.svelte +59 -0
  66. package/src/input/InputTime.svelte +54 -0
  67. package/src/input/InputUrl.svelte +60 -0
  68. package/src/input/InputWeek.svelte +54 -0
  69. package/src/input/index.js +23 -0
  70. package/src/lib/Input.svelte +291 -0
  71. package/src/lib/builder.svelte.js +359 -0
  72. package/src/lib/deprecated/Form.svelte +17 -0
  73. package/src/lib/deprecated/FormRenderer.svelte +121 -0
  74. package/src/lib/deprecated/nested.js +192 -0
  75. package/src/lib/deprecated/nested.spec.js +512 -0
  76. package/src/lib/deprecated/validator.js +137 -0
  77. package/src/lib/deprecated/validator.spec.js +348 -0
  78. package/src/lib/fields.js +119 -0
  79. package/src/lib/fields.spec.js +250 -0
  80. package/src/lib/index.js +7 -0
  81. package/src/lib/layout.js +63 -0
  82. package/src/lib/schema.js +32 -0
  83. package/src/lib/validation.js +273 -0
  84. package/src/types.js +29 -0
@@ -0,0 +1,59 @@
1
+ <script>
2
+ /**
3
+ * @typedef {Object} InputTextAreaProps
4
+ * @property {string} value
5
+ * @property {Function} onchange
6
+ * @property {Function} onfocus
7
+ * @property {Function} onblur
8
+ * @property {string} placeholder
9
+ * @property {boolean} required
10
+ * @property {boolean} disabled
11
+ * @property {boolean} readonly
12
+ * @property {string} name
13
+ * @property {string} id
14
+ * @property {number} rows
15
+ * @property {number} cols
16
+ * @property {number} maxlength
17
+ * @property {number} minlength
18
+ * @property {string} wrap
19
+ */
20
+
21
+ /** @type {InputTextAreaProps & { [key: string]: any }} */
22
+ let {
23
+ value = $bindable(),
24
+ onchange,
25
+ onfocus,
26
+ onblur,
27
+ placeholder,
28
+ required,
29
+ disabled,
30
+ readonly,
31
+ name,
32
+ id,
33
+ rows,
34
+ cols,
35
+ maxlength,
36
+ minlength,
37
+ wrap,
38
+ ...rest
39
+ } = $props()
40
+ </script>
41
+
42
+ <textarea
43
+ bind:value
44
+ {placeholder}
45
+ {required}
46
+ {disabled}
47
+ {readonly}
48
+ {name}
49
+ {id}
50
+ {rows}
51
+ {cols}
52
+ {maxlength}
53
+ {minlength}
54
+ {wrap}
55
+ {onchange}
56
+ {onfocus}
57
+ {onblur}
58
+ {...rest}
59
+ ></textarea>
@@ -0,0 +1,54 @@
1
+ <script>
2
+ /**
3
+ * @typedef {Object} InputTimeProps
4
+ * @property {string} value
5
+ * @property {Function} onchange
6
+ * @property {Function} onfocus
7
+ * @property {Function} onblur
8
+ * @property {string} min
9
+ * @property {string} max
10
+ * @property {number} step
11
+ * @property {boolean} required
12
+ * @property {boolean} disabled
13
+ * @property {boolean} readonly
14
+ * @property {string} name
15
+ * @property {string} id
16
+ * @property {string} autocomplete
17
+ */
18
+
19
+ /** @type {InputTimeProps & { [key: string]: any }} */
20
+ let {
21
+ value = $bindable(),
22
+ onchange,
23
+ onfocus,
24
+ onblur,
25
+ min,
26
+ max,
27
+ step,
28
+ required,
29
+ disabled,
30
+ readonly,
31
+ name,
32
+ id,
33
+ autocomplete,
34
+ ...rest
35
+ } = $props()
36
+ </script>
37
+
38
+ <input
39
+ bind:value
40
+ type="time"
41
+ {min}
42
+ {max}
43
+ {step}
44
+ {required}
45
+ {disabled}
46
+ {readonly}
47
+ {name}
48
+ {id}
49
+ {autocomplete}
50
+ {onchange}
51
+ {onfocus}
52
+ {onblur}
53
+ {...rest}
54
+ />
@@ -0,0 +1,60 @@
1
+ <script>
2
+ /**
3
+ * @typedef {Object} InputUrlProps
4
+ * @property {string} value
5
+ * @property {Function} onchange
6
+ * @property {Function} onfocus
7
+ * @property {Function} onblur
8
+ * @property {string} placeholder
9
+ * @property {boolean} required
10
+ * @property {boolean} disabled
11
+ * @property {boolean} readonly
12
+ * @property {string} name
13
+ * @property {string} id
14
+ * @property {string} autocomplete
15
+ * @property {number} maxlength
16
+ * @property {number} minlength
17
+ * @property {string} pattern
18
+ * @property {number} size
19
+ */
20
+
21
+ /** @type {InputUrlProps & { [key: string]: any }} */
22
+ let {
23
+ value = $bindable(),
24
+ onchange,
25
+ onfocus,
26
+ onblur,
27
+ placeholder,
28
+ required,
29
+ disabled,
30
+ readonly,
31
+ name,
32
+ id,
33
+ autocomplete,
34
+ maxlength,
35
+ minlength,
36
+ pattern,
37
+ size,
38
+ ...rest
39
+ } = $props()
40
+ </script>
41
+
42
+ <input
43
+ bind:value
44
+ type="url"
45
+ {placeholder}
46
+ {required}
47
+ {disabled}
48
+ {readonly}
49
+ {name}
50
+ {id}
51
+ {autocomplete}
52
+ {maxlength}
53
+ {minlength}
54
+ {pattern}
55
+ {size}
56
+ {onchange}
57
+ {onfocus}
58
+ {onblur}
59
+ {...rest}
60
+ />
@@ -0,0 +1,54 @@
1
+ <script>
2
+ /**
3
+ * @typedef {Object} InputWeekProps
4
+ * @property {string} value
5
+ * @property {Function} onchange
6
+ * @property {Function} onfocus
7
+ * @property {Function} onblur
8
+ * @property {string} min
9
+ * @property {string} max
10
+ * @property {number} step
11
+ * @property {boolean} required
12
+ * @property {boolean} disabled
13
+ * @property {boolean} readonly
14
+ * @property {string} name
15
+ * @property {string} id
16
+ * @property {string} autocomplete
17
+ */
18
+
19
+ /** @type {InputWeekProps & { [key: string]: any }} */
20
+ let {
21
+ value = $bindable(),
22
+ onchange,
23
+ onfocus,
24
+ onblur,
25
+ min,
26
+ max,
27
+ step,
28
+ required,
29
+ disabled,
30
+ readonly,
31
+ name,
32
+ id,
33
+ autocomplete,
34
+ ...rest
35
+ } = $props()
36
+ </script>
37
+
38
+ <input
39
+ bind:value
40
+ type="week"
41
+ {min}
42
+ {max}
43
+ {step}
44
+ {required}
45
+ {disabled}
46
+ {readonly}
47
+ {name}
48
+ {id}
49
+ {autocomplete}
50
+ {onchange}
51
+ {onfocus}
52
+ {onblur}
53
+ {...rest}
54
+ />
@@ -0,0 +1,23 @@
1
+ // Native Input Components
2
+ export { default as InputCheckbox } from './InputCheckbox.svelte'
3
+ export { default as InputColor } from './InputColor.svelte'
4
+ export { default as InputDate } from './InputDate.svelte'
5
+ export { default as InputDateTime } from './InputDateTime.svelte'
6
+ export { default as InputEmail } from './InputEmail.svelte'
7
+
8
+ export { default as InputFile } from './InputFile.svelte'
9
+ export { default as InputMonth } from './InputMonth.svelte'
10
+ export { default as InputNumber } from './InputNumber.svelte'
11
+ export { default as InputPassword } from './InputPassword.svelte'
12
+ export { default as InputRadio } from './InputRadio.svelte'
13
+
14
+ export { default as InputRange } from './InputRange.svelte'
15
+ export { default as InputSelect } from './InputSelect.svelte'
16
+ // export { default as InputSwitch } from './InputSwitch.svelte'
17
+ export { default as InputTel } from './InputTel.svelte'
18
+ export { default as InputText } from './InputText.svelte'
19
+ export { default as InputTextArea } from './InputTextArea.svelte'
20
+ export { default as InputTime } from './InputTime.svelte'
21
+
22
+ export { default as InputUrl } from './InputUrl.svelte'
23
+ export { default as InputWeek } from './InputWeek.svelte'
@@ -0,0 +1,291 @@
1
+ <script>
2
+ /**
3
+ * Universal Input wrapper component supporting all HTML input types
4
+ * Provides consistent interface with label, description, message handling
5
+ */
6
+
7
+ let {
8
+ // Core input properties
9
+ type = 'text',
10
+ value = $bindable(),
11
+
12
+ // Enhanced properties
13
+ label = '',
14
+ description = '',
15
+ message = null, // { state: 'error|warning|info|success', text: 'Message content' }
16
+
17
+ // Standard HTML input attributes
18
+ placeholder = '',
19
+ required = false,
20
+ disabled = false,
21
+ readonly = false,
22
+ min = undefined,
23
+ max = undefined,
24
+ step = undefined,
25
+ pattern = undefined,
26
+ minLength = undefined,
27
+ maxLength = undefined,
28
+
29
+ // Select-specific
30
+ options = [],
31
+
32
+ // Styling
33
+ className = '',
34
+
35
+ // Event handlers
36
+ onchange = undefined,
37
+ onfocus = undefined,
38
+ onblur = undefined,
39
+
40
+ // Pass through any other props
41
+ ...props
42
+ } = $props()
43
+
44
+ // Determine layout class based on input type
45
+ function getLayoutClass(inputType) {
46
+ switch (inputType) {
47
+ case 'checkbox':
48
+ return 'input-layout-checkbox'
49
+ case 'radio':
50
+ return 'input-layout-radio'
51
+ default:
52
+ return 'input-layout-standard'
53
+ }
54
+ }
55
+
56
+ // Handle change events
57
+ function handleChange(event) {
58
+ if (type === 'checkbox' || type === 'radio') {
59
+ value = event.target.checked
60
+ } else if (type === 'number' || type === 'range') {
61
+ value = event.target.valueAsNumber
62
+ } else {
63
+ value = event.target.value
64
+ }
65
+
66
+ if (onchange) {
67
+ onchange(value)
68
+ }
69
+ }
70
+
71
+ // Generate unique ID for accessibility
72
+ let fieldId = `field-${Math.random().toString(36).substr(2, 9)}`
73
+ let descriptionId = description ? `${fieldId}-description` : undefined
74
+ let messageId = message ? `${fieldId}-message` : undefined
75
+
76
+ // Build aria-describedby
77
+ let ariaDescribedBy = [descriptionId, messageId].filter(Boolean).join(' ') || undefined
78
+ </script>
79
+
80
+ <div
81
+ class="input-wrapper {getLayoutClass(type)} {className}"
82
+ class:has-error={message?.state === 'error'}
83
+ >
84
+ {#if type === 'checkbox' || type === 'radio'}
85
+ <!-- Checkbox/Radio: Input first, label on the right -->
86
+ <div class="input-control">
87
+ <input
88
+ id={fieldId}
89
+ {type}
90
+ checked={value}
91
+ {required}
92
+ {disabled}
93
+ {readonly}
94
+ aria-describedby={ariaDescribedBy}
95
+ onchange={handleChange}
96
+ {onfocus}
97
+ {onblur}
98
+ {...props}
99
+ />
100
+ {#if label}
101
+ <label for={fieldId} class="input-label">{label}</label>
102
+ {/if}
103
+ </div>
104
+ {:else}
105
+ <!-- Standard layout: Label above input -->
106
+ {#if label}
107
+ <label for={fieldId} class="input-label">{label}</label>
108
+ {/if}
109
+
110
+ <div class="input-control">
111
+ {#if type === 'select'}
112
+ <select
113
+ id={fieldId}
114
+ bind:value
115
+ {required}
116
+ {disabled}
117
+ aria-describedby={ariaDescribedBy}
118
+ onchange={handleChange}
119
+ {onfocus}
120
+ {onblur}
121
+ {...props}
122
+ >
123
+ {#each options as option, index (index)}
124
+ {#if typeof option === 'string'}
125
+ <option value={option}>{option}</option>
126
+ {:else}
127
+ <option value={option.value}>{option.label || option.value}</option>
128
+ {/if}
129
+ {/each}
130
+ </select>
131
+ {:else if type === 'textarea'}
132
+ <textarea
133
+ id={fieldId}
134
+ bind:value
135
+ {placeholder}
136
+ {required}
137
+ {disabled}
138
+ {readonly}
139
+ {minLength}
140
+ {maxLength}
141
+ aria-describedby={ariaDescribedBy}
142
+ onchange={handleChange}
143
+ {onfocus}
144
+ {onblur}
145
+ {...props}
146
+ ></textarea>
147
+ {:else}
148
+ <input
149
+ id={fieldId}
150
+ {type}
151
+ bind:value
152
+ {placeholder}
153
+ {required}
154
+ {disabled}
155
+ {readonly}
156
+ {min}
157
+ {max}
158
+ {step}
159
+ {pattern}
160
+ {minLength}
161
+ {maxLength}
162
+ aria-describedby={ariaDescribedBy}
163
+ onchange={handleChange}
164
+ {onfocus}
165
+ {onblur}
166
+ {...props}
167
+ />
168
+ {/if}
169
+ </div>
170
+ {/if}
171
+
172
+ <!-- Description text -->
173
+ {#if description}
174
+ <div id={descriptionId} class="input-description">{description}</div>
175
+ {/if}
176
+
177
+ <!-- Message display -->
178
+ {#if message}
179
+ <div
180
+ id={messageId}
181
+ class="input-message message-{message.state}"
182
+ role="alert"
183
+ aria-live="polite"
184
+ >
185
+ {message.text}
186
+ </div>
187
+ {/if}
188
+ </div>
189
+
190
+ <style>
191
+ .input-wrapper {
192
+ display: flex;
193
+ flex-direction: column;
194
+ gap: 0.25rem;
195
+ }
196
+
197
+ .input-layout-checkbox,
198
+ .input-layout-radio {
199
+ flex-direction: row;
200
+ align-items: flex-start;
201
+ gap: 0.5rem;
202
+ }
203
+
204
+ .input-layout-checkbox .input-control,
205
+ .input-layout-radio .input-control {
206
+ display: flex;
207
+ align-items: center;
208
+ gap: 0.5rem;
209
+ }
210
+
211
+ .input-control {
212
+ display: flex;
213
+ flex-direction: column;
214
+ }
215
+
216
+ .input-label {
217
+ font-weight: 500;
218
+ color: #374151;
219
+ margin-bottom: 0.25rem;
220
+ }
221
+
222
+ .input-layout-checkbox .input-label,
223
+ .input-layout-radio .input-label {
224
+ margin-bottom: 0;
225
+ font-weight: normal;
226
+ }
227
+
228
+ input,
229
+ select,
230
+ textarea {
231
+ padding: 0.5rem;
232
+ border: 1px solid #d1d5db;
233
+ border-radius: 0.375rem;
234
+ font-size: 0.875rem;
235
+ line-height: 1.25rem;
236
+ }
237
+
238
+ input:focus,
239
+ select:focus,
240
+ textarea:focus {
241
+ outline: none;
242
+ border-color: #3b82f6;
243
+ box-shadow: 0 0 0 1px #3b82f6;
244
+ }
245
+
246
+ input[type='checkbox'],
247
+ input[type='radio'] {
248
+ width: auto;
249
+ padding: 0;
250
+ }
251
+
252
+ .input-description {
253
+ font-size: 0.75rem;
254
+ color: #6b7280;
255
+ margin-top: 0.25rem;
256
+ }
257
+
258
+ .input-message {
259
+ font-size: 0.75rem;
260
+ margin-top: 0.25rem;
261
+ }
262
+
263
+ .message-error {
264
+ color: #dc2626;
265
+ }
266
+
267
+ .message-warning {
268
+ color: #d97706;
269
+ }
270
+
271
+ .message-info {
272
+ color: #2563eb;
273
+ }
274
+
275
+ .message-success {
276
+ color: #059669;
277
+ }
278
+
279
+ .has-error input,
280
+ .has-error select,
281
+ .has-error textarea {
282
+ border-color: #dc2626;
283
+ }
284
+
285
+ .has-error input:focus,
286
+ .has-error select:focus,
287
+ .has-error textarea:focus {
288
+ border-color: #dc2626;
289
+ box-shadow: 0 0 0 1px #dc2626;
290
+ }
291
+ </style>