@rokkit/forms 1.1.18 → 1.2.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.
- package/dist/FieldLayout.svelte.d.ts +23 -0
- package/dist/FormRenderer.svelte.d.ts +59 -0
- package/dist/InfoField.svelte.d.ts +10 -0
- package/dist/Input.svelte.d.ts +14 -0
- package/dist/InputField.svelte.d.ts +37 -0
- package/dist/StatusList.svelte.d.ts +19 -0
- package/dist/StepIndicator.svelte.d.ts +12 -0
- package/dist/display/DisplayCardGrid.svelte.d.ts +17 -0
- package/dist/display/DisplayList.svelte.d.ts +14 -0
- package/dist/display/DisplaySection.svelte.d.ts +13 -0
- package/dist/display/DisplayTable.svelte.d.ts +19 -0
- package/dist/display/DisplayValue.svelte.d.ts +11 -0
- package/dist/input/ArrayEditor.svelte.d.ts +15 -0
- package/dist/input/InputCheckbox.svelte.d.ts +15 -0
- package/dist/input/InputColor.svelte.d.ts +8 -0
- package/dist/input/InputDate.svelte.d.ts +8 -0
- package/dist/input/InputDateTime.svelte.d.ts +8 -0
- package/dist/input/InputEmail.svelte.d.ts +8 -0
- package/dist/input/InputFile.svelte.d.ts +8 -0
- package/dist/input/InputMonth.svelte.d.ts +8 -0
- package/dist/input/InputNumber.svelte.d.ts +8 -0
- package/dist/input/InputPassword.svelte.d.ts +8 -0
- package/dist/input/InputRadio.svelte.d.ts +16 -0
- package/dist/input/InputRange.svelte.d.ts +8 -0
- package/dist/input/InputSelect.svelte.d.ts +13 -0
- package/dist/input/InputSwatch.svelte.d.ts +13 -0
- package/dist/input/InputSwitch.svelte.d.ts +7 -0
- package/dist/input/InputTel.svelte.d.ts +8 -0
- package/dist/input/InputText.svelte.d.ts +8 -0
- package/dist/input/InputTextArea.svelte.d.ts +8 -0
- package/dist/input/InputTime.svelte.d.ts +8 -0
- package/dist/input/InputToggle.svelte.d.ts +5 -0
- package/dist/input/InputUrl.svelte.d.ts +8 -0
- package/dist/input/InputWeek.svelte.d.ts +8 -0
- package/dist/lib/Input.svelte.d.ts +37 -0
- package/dist/{src/lib → lib}/builder.svelte.d.ts +8 -8
- package/dist/types.d.ts +14 -0
- package/package.json +14 -3
- package/src/FieldLayout.svelte +35 -7
- package/src/FormRenderer.svelte +87 -19
- package/src/InfoField.svelte +10 -2
- package/src/Input.svelte +14 -2
- package/src/InputField.svelte +41 -14
- package/src/StatusList.svelte +23 -4
- package/src/StepIndicator.svelte +10 -8
- package/src/display/DisplayCardGrid.svelte +24 -7
- package/src/display/DisplayList.svelte +15 -2
- package/src/display/DisplaySection.svelte +14 -2
- package/src/display/DisplayTable.svelte +36 -13
- package/src/display/DisplayValue.svelte +18 -9
- package/src/input/ArrayEditor.svelte +41 -23
- package/src/input/InputCheckbox.svelte +17 -25
- package/src/input/InputColor.svelte +10 -17
- package/src/input/InputDate.svelte +10 -21
- package/src/input/InputDateTime.svelte +10 -21
- package/src/input/InputEmail.svelte +10 -24
- package/src/input/InputFile.svelte +10 -18
- package/src/input/InputMonth.svelte +10 -21
- package/src/input/InputNumber.svelte +10 -22
- package/src/input/InputPassword.svelte +10 -23
- package/src/input/InputRadio.svelte +16 -21
- package/src/input/InputRange.svelte +10 -20
- package/src/input/InputSelect.svelte +20 -20
- package/src/input/InputSwatch.svelte +12 -14
- package/src/input/InputSwitch.svelte +6 -12
- package/src/input/InputTel.svelte +10 -23
- package/src/input/InputText.svelte +10 -23
- package/src/input/InputTextArea.svelte +10 -23
- package/src/input/InputTime.svelte +10 -21
- package/src/input/InputToggle.svelte +4 -14
- package/src/input/InputUrl.svelte +10 -23
- package/src/input/InputWeek.svelte +10 -21
- package/src/lib/Input.svelte +47 -13
- package/src/lib/builder.svelte.js +6 -6
- package/dist/src/types.d.ts +0 -5
- /package/dist/{src/display → display}/index.d.ts +0 -0
- /package/dist/{src/index.d.ts → index.d.ts} +0 -0
- /package/dist/{src/input → input}/index.d.ts +0 -0
- /package/dist/{src/lib → lib}/conditions.d.ts +0 -0
- /package/dist/{src/lib → lib}/conditions.spec.d.ts +0 -0
- /package/dist/{src/lib → lib}/fields.d.ts +0 -0
- /package/dist/{src/lib → lib}/fields.spec.d.ts +0 -0
- /package/dist/{src/lib → lib}/index.d.ts +0 -0
- /package/dist/{src/lib → lib}/layout.d.ts +0 -0
- /package/dist/{src/lib → lib}/lookup.svelte.d.ts +0 -0
- /package/dist/{src/lib → lib}/renderers.d.ts +0 -0
- /package/dist/{src/lib → lib}/schema.d.ts +0 -0
- /package/dist/{src/lib → lib}/validation.d.ts +0 -0
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import { Select } from '@rokkit/ui'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
type Option = string | Record<string, unknown>
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
value?: unknown
|
|
8
|
+
fields?: Record<string, string>
|
|
9
|
+
options?: Option[]
|
|
10
|
+
placeholder?: string
|
|
11
|
+
disabled?: boolean
|
|
12
|
+
size?: 'sm' | 'md' | 'lg'
|
|
13
|
+
onchange?: (value: unknown, item: unknown) => void
|
|
14
|
+
}
|
|
15
|
+
|
|
16
16
|
let {
|
|
17
17
|
value = $bindable(),
|
|
18
18
|
fields,
|
|
@@ -22,18 +22,18 @@
|
|
|
22
22
|
size,
|
|
23
23
|
onchange,
|
|
24
24
|
..._rest
|
|
25
|
-
} = $props()
|
|
25
|
+
}: Props = $props()
|
|
26
|
+
|
|
27
|
+
function isEmptyOption(opt: Option): boolean {
|
|
28
|
+
return opt === '' || (typeof opt === 'object' && opt?.value === '')
|
|
29
|
+
}
|
|
26
30
|
|
|
27
31
|
// Check if options include an empty string (used as "none" option)
|
|
28
|
-
const hasEmptyOption = $derived(
|
|
29
|
-
options.some((opt) => opt === '' || (typeof opt === 'object' && opt?.value === ''))
|
|
30
|
-
)
|
|
32
|
+
const hasEmptyOption = $derived(options.some(isEmptyOption))
|
|
31
33
|
|
|
32
34
|
// Filter out empty strings — Select + ProxyItem handles string options natively
|
|
33
35
|
const filteredOptions = $derived(
|
|
34
|
-
hasEmptyOption
|
|
35
|
-
? options.filter((opt) => opt !== '' && !(typeof opt === 'object' && opt?.value === ''))
|
|
36
|
-
: options
|
|
36
|
+
hasEmptyOption ? options.filter((opt) => !isEmptyOption(opt)) : options
|
|
37
37
|
)
|
|
38
38
|
|
|
39
39
|
// Use placeholder for empty option, or provide a default clear label
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import { Swatch } from '@rokkit/ui'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*/
|
|
4
|
+
type Props = {
|
|
5
|
+
value?: unknown
|
|
6
|
+
options?: Array<string | number | Record<string, unknown>>
|
|
7
|
+
fields?: Record<string, string>
|
|
8
|
+
multiple?: boolean
|
|
9
|
+
shape?: 'square' | 'circle'
|
|
10
|
+
size?: 'sm' | 'md' | 'lg'
|
|
11
|
+
disabled?: boolean
|
|
12
|
+
onchange?: (value: unknown, item: unknown) => void
|
|
13
|
+
}
|
|
15
14
|
|
|
16
|
-
/** @type {InputSwatchProps & { [key: string]: any }} */
|
|
17
15
|
let {
|
|
18
16
|
value = $bindable(),
|
|
19
17
|
options = [],
|
|
@@ -24,7 +22,7 @@
|
|
|
24
22
|
disabled = false,
|
|
25
23
|
onchange,
|
|
26
24
|
..._rest
|
|
27
|
-
} = $props()
|
|
25
|
+
}: Props = $props()
|
|
28
26
|
</script>
|
|
29
27
|
|
|
30
28
|
<Swatch {options} {fields} bind:value {multiple} {shape} {size} {disabled} {onchange} />
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { Switch } from '@rokkit/ui'
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Switch, type SwitchProps } from '@rokkit/ui'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* @property {any} value
|
|
8
|
-
* @property {[any, any]} options
|
|
9
|
-
* @property {Object} fields
|
|
10
|
-
* @property {Function} onchange
|
|
11
|
-
*/
|
|
4
|
+
type Props = SwitchProps & {
|
|
5
|
+
name?: string
|
|
6
|
+
}
|
|
12
7
|
|
|
13
|
-
|
|
14
|
-
let { name, value = $bindable(), options, fields, onchange, ...restProps } = $props()
|
|
8
|
+
let { name, value = $bindable(), options, fields, onchange, ...restProps }: Props = $props()
|
|
15
9
|
</script>
|
|
16
10
|
|
|
17
11
|
<input {name} type="hidden" bind:value />
|
|
@@ -1,24 +1,11 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
*/
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLInputAttributes } from 'svelte/elements'
|
|
3
|
+
|
|
4
|
+
type Props = Omit<HTMLInputAttributes, 'value' | 'onchange'> & {
|
|
5
|
+
value?: string
|
|
6
|
+
onchange?: (value: string) => void
|
|
7
|
+
}
|
|
20
8
|
|
|
21
|
-
/** @type {InputTelProps & { [key: string]: any }} */
|
|
22
9
|
let {
|
|
23
10
|
value = $bindable(),
|
|
24
11
|
onchange,
|
|
@@ -36,10 +23,10 @@
|
|
|
36
23
|
pattern,
|
|
37
24
|
size,
|
|
38
25
|
...rest
|
|
39
|
-
} = $props()
|
|
26
|
+
}: Props = $props()
|
|
40
27
|
|
|
41
|
-
function handleChange(event) {
|
|
42
|
-
value = event.
|
|
28
|
+
function handleChange(event: Event & { currentTarget: HTMLInputElement }) {
|
|
29
|
+
value = event.currentTarget.value
|
|
43
30
|
onchange?.(value)
|
|
44
31
|
}
|
|
45
32
|
</script>
|
|
@@ -1,24 +1,11 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
*/
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLInputAttributes } from 'svelte/elements'
|
|
3
|
+
|
|
4
|
+
type Props = Omit<HTMLInputAttributes, 'value' | 'onchange'> & {
|
|
5
|
+
value?: string
|
|
6
|
+
onchange?: (value: string) => void
|
|
7
|
+
}
|
|
20
8
|
|
|
21
|
-
/** @type {InputTextProps & { [key: string]: any }} */
|
|
22
9
|
let {
|
|
23
10
|
value = $bindable(),
|
|
24
11
|
onchange,
|
|
@@ -36,10 +23,10 @@
|
|
|
36
23
|
pattern,
|
|
37
24
|
size,
|
|
38
25
|
...rest
|
|
39
|
-
} = $props()
|
|
26
|
+
}: Props = $props()
|
|
40
27
|
|
|
41
|
-
function handleChange(event) {
|
|
42
|
-
value = event.
|
|
28
|
+
function handleChange(event: Event & { currentTarget: HTMLInputElement }) {
|
|
29
|
+
value = event.currentTarget.value
|
|
43
30
|
onchange?.(value)
|
|
44
31
|
}
|
|
45
32
|
</script>
|
|
@@ -1,24 +1,11 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
*/
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLTextareaAttributes } from 'svelte/elements'
|
|
3
|
+
|
|
4
|
+
type Props = Omit<HTMLTextareaAttributes, 'value' | 'onchange'> & {
|
|
5
|
+
value?: string
|
|
6
|
+
onchange?: (value: string) => void
|
|
7
|
+
}
|
|
20
8
|
|
|
21
|
-
/** @type {InputTextAreaProps & { [key: string]: any }} */
|
|
22
9
|
let {
|
|
23
10
|
value = $bindable(),
|
|
24
11
|
onchange,
|
|
@@ -36,10 +23,10 @@
|
|
|
36
23
|
minlength,
|
|
37
24
|
wrap,
|
|
38
25
|
...rest
|
|
39
|
-
} = $props()
|
|
26
|
+
}: Props = $props()
|
|
40
27
|
|
|
41
|
-
function handleChange(event) {
|
|
42
|
-
value = event.
|
|
28
|
+
function handleChange(event: Event & { currentTarget: HTMLTextAreaElement }) {
|
|
29
|
+
value = event.currentTarget.value
|
|
43
30
|
onchange?.(value)
|
|
44
31
|
}
|
|
45
32
|
</script>
|
|
@@ -1,22 +1,11 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
*/
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLInputAttributes } from 'svelte/elements'
|
|
3
|
+
|
|
4
|
+
type Props = Omit<HTMLInputAttributes, 'value' | 'onchange'> & {
|
|
5
|
+
value?: string
|
|
6
|
+
onchange?: (value: string) => void
|
|
7
|
+
}
|
|
18
8
|
|
|
19
|
-
/** @type {InputTimeProps & { [key: string]: any }} */
|
|
20
9
|
let {
|
|
21
10
|
value = $bindable(),
|
|
22
11
|
onchange,
|
|
@@ -32,10 +21,10 @@
|
|
|
32
21
|
id,
|
|
33
22
|
autocomplete,
|
|
34
23
|
...rest
|
|
35
|
-
} = $props()
|
|
24
|
+
}: Props = $props()
|
|
36
25
|
|
|
37
|
-
function handleChange(event) {
|
|
38
|
-
value = event.
|
|
26
|
+
function handleChange(event: Event & { currentTarget: HTMLInputElement }) {
|
|
27
|
+
value = event.currentTarget.value
|
|
39
28
|
onchange?.(value)
|
|
40
29
|
}
|
|
41
30
|
</script>
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { Toggle } from '@rokkit/ui'
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Toggle, type ToggleProps } from '@rokkit/ui'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
* @typedef {Object} InputToggleProps
|
|
6
|
-
* @property {any} value - Selected value (bindable)
|
|
7
|
-
* @property {Array<Object|string>} [options] - Options array (strings or objects)
|
|
8
|
-
* @property {Object} [fields] - Field mapping for option data
|
|
9
|
-
* @property {boolean} [disabled] - Whether the toggle is disabled
|
|
10
|
-
* @property {string} [size] - Size variant ('sm' | 'md' | 'lg')
|
|
11
|
-
* @property {boolean} [showLabels] - Show text labels
|
|
12
|
-
* @property {Function} [onchange] - Change callback
|
|
13
|
-
*/
|
|
4
|
+
type Props = Pick<ToggleProps, 'value' | 'options' | 'fields' | 'disabled' | 'size' | 'showLabels' | 'onchange'>
|
|
14
5
|
|
|
15
|
-
/** @type {InputToggleProps & { [key: string]: any }} */
|
|
16
6
|
let {
|
|
17
7
|
value = $bindable(),
|
|
18
8
|
options = [],
|
|
@@ -22,7 +12,7 @@
|
|
|
22
12
|
showLabels,
|
|
23
13
|
onchange,
|
|
24
14
|
..._rest
|
|
25
|
-
} = $props()
|
|
15
|
+
}: Props = $props()
|
|
26
16
|
</script>
|
|
27
17
|
|
|
28
18
|
<Toggle {options} {fields} bind:value {onchange} {disabled} {size} {showLabels} />
|
|
@@ -1,24 +1,11 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
*/
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLInputAttributes } from 'svelte/elements'
|
|
3
|
+
|
|
4
|
+
type Props = Omit<HTMLInputAttributes, 'value' | 'onchange'> & {
|
|
5
|
+
value?: string
|
|
6
|
+
onchange?: (value: string) => void
|
|
7
|
+
}
|
|
20
8
|
|
|
21
|
-
/** @type {InputUrlProps & { [key: string]: any }} */
|
|
22
9
|
let {
|
|
23
10
|
value = $bindable(),
|
|
24
11
|
onchange,
|
|
@@ -36,10 +23,10 @@
|
|
|
36
23
|
pattern,
|
|
37
24
|
size,
|
|
38
25
|
...rest
|
|
39
|
-
} = $props()
|
|
26
|
+
}: Props = $props()
|
|
40
27
|
|
|
41
|
-
function handleChange(event) {
|
|
42
|
-
value = event.
|
|
28
|
+
function handleChange(event: Event & { currentTarget: HTMLInputElement }) {
|
|
29
|
+
value = event.currentTarget.value
|
|
43
30
|
onchange?.(value)
|
|
44
31
|
}
|
|
45
32
|
</script>
|
|
@@ -1,22 +1,11 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
*/
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLInputAttributes } from 'svelte/elements'
|
|
3
|
+
|
|
4
|
+
type Props = Omit<HTMLInputAttributes, 'value' | 'onchange'> & {
|
|
5
|
+
value?: string
|
|
6
|
+
onchange?: (value: string) => void
|
|
7
|
+
}
|
|
18
8
|
|
|
19
|
-
/** @type {InputWeekProps & { [key: string]: any }} */
|
|
20
9
|
let {
|
|
21
10
|
value = $bindable(),
|
|
22
11
|
onchange,
|
|
@@ -32,10 +21,10 @@
|
|
|
32
21
|
id,
|
|
33
22
|
autocomplete,
|
|
34
23
|
...rest
|
|
35
|
-
} = $props()
|
|
24
|
+
}: Props = $props()
|
|
36
25
|
|
|
37
|
-
function handleChange(event) {
|
|
38
|
-
value = event.
|
|
26
|
+
function handleChange(event: Event & { currentTarget: HTMLInputElement }) {
|
|
27
|
+
value = event.currentTarget.value
|
|
39
28
|
onchange?.(value)
|
|
40
29
|
}
|
|
41
30
|
</script>
|
package/src/lib/Input.svelte
CHANGED
|
@@ -1,9 +1,36 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
/**
|
|
3
3
|
* Universal Input wrapper component supporting all HTML input types
|
|
4
4
|
* Provides consistent interface with label, description, message handling
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
type Message = { state: 'error' | 'warning' | 'info' | 'success'; text: string }
|
|
8
|
+
|
|
9
|
+
type SelectOption = string | { value: unknown; label?: string }
|
|
10
|
+
|
|
11
|
+
type Props = {
|
|
12
|
+
type?: string
|
|
13
|
+
value?: unknown
|
|
14
|
+
label?: string
|
|
15
|
+
description?: string
|
|
16
|
+
message?: Message | null
|
|
17
|
+
placeholder?: string
|
|
18
|
+
required?: boolean
|
|
19
|
+
disabled?: boolean
|
|
20
|
+
readonly?: boolean
|
|
21
|
+
min?: number | string
|
|
22
|
+
max?: number | string
|
|
23
|
+
step?: number | string
|
|
24
|
+
pattern?: string
|
|
25
|
+
minLength?: number
|
|
26
|
+
maxLength?: number
|
|
27
|
+
options?: SelectOption[]
|
|
28
|
+
className?: string
|
|
29
|
+
onchange?: (value: unknown) => void
|
|
30
|
+
onfocus?: (event: FocusEvent) => void
|
|
31
|
+
onblur?: (event: FocusEvent) => void
|
|
32
|
+
} & Record<string, unknown>
|
|
33
|
+
|
|
7
34
|
let {
|
|
8
35
|
// Core input properties
|
|
9
36
|
type = 'text',
|
|
@@ -39,10 +66,10 @@
|
|
|
39
66
|
|
|
40
67
|
// Pass through any other props
|
|
41
68
|
...props
|
|
42
|
-
} = $props()
|
|
69
|
+
}: Props = $props()
|
|
43
70
|
|
|
44
71
|
// Determine layout class based on input type
|
|
45
|
-
function getLayoutClass(inputType) {
|
|
72
|
+
function getLayoutClass(inputType: string): string {
|
|
46
73
|
switch (inputType) {
|
|
47
74
|
case 'checkbox':
|
|
48
75
|
return 'input-layout-checkbox'
|
|
@@ -54,14 +81,21 @@
|
|
|
54
81
|
}
|
|
55
82
|
|
|
56
83
|
// Resolve new value from event based on input type
|
|
57
|
-
function resolveValue(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
84
|
+
function resolveValue(
|
|
85
|
+
event: Event & { currentTarget: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement }
|
|
86
|
+
): unknown {
|
|
87
|
+
const target = event.currentTarget
|
|
88
|
+
if ((type === 'checkbox' || type === 'radio') && target instanceof HTMLInputElement)
|
|
89
|
+
return target.checked
|
|
90
|
+
if ((type === 'number' || type === 'range') && target instanceof HTMLInputElement)
|
|
91
|
+
return target.valueAsNumber
|
|
92
|
+
return target.value
|
|
61
93
|
}
|
|
62
94
|
|
|
63
95
|
// Handle change events
|
|
64
|
-
function handleChange(
|
|
96
|
+
function handleChange(
|
|
97
|
+
event: Event & { currentTarget: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement }
|
|
98
|
+
) {
|
|
65
99
|
value = resolveValue(event)
|
|
66
100
|
if (onchange) onchange(value)
|
|
67
101
|
}
|
|
@@ -85,7 +119,7 @@
|
|
|
85
119
|
<input
|
|
86
120
|
id={fieldId}
|
|
87
121
|
{type}
|
|
88
|
-
checked={value}
|
|
122
|
+
checked={Boolean(value)}
|
|
89
123
|
{required}
|
|
90
124
|
{disabled}
|
|
91
125
|
{readonly}
|
|
@@ -134,8 +168,8 @@
|
|
|
134
168
|
{required}
|
|
135
169
|
{disabled}
|
|
136
170
|
{readonly}
|
|
137
|
-
{minLength}
|
|
138
|
-
{maxLength}
|
|
171
|
+
minlength={minLength}
|
|
172
|
+
maxlength={maxLength}
|
|
139
173
|
aria-describedby={ariaDescribedBy}
|
|
140
174
|
onchange={handleChange}
|
|
141
175
|
{onfocus}
|
|
@@ -155,8 +189,8 @@
|
|
|
155
189
|
{max}
|
|
156
190
|
{step}
|
|
157
191
|
{pattern}
|
|
158
|
-
{minLength}
|
|
159
|
-
{maxLength}
|
|
192
|
+
minlength={minLength}
|
|
193
|
+
maxlength={maxLength}
|
|
160
194
|
aria-describedby={ariaDescribedBy}
|
|
161
195
|
onchange={handleChange}
|
|
162
196
|
{onfocus}
|
|
@@ -106,10 +106,10 @@ function setNestedValue(data, keys, value) {
|
|
|
106
106
|
* FormBuilder class for dynamically generating forms from data structures
|
|
107
107
|
*/
|
|
108
108
|
export class FormBuilder {
|
|
109
|
-
/** @type {
|
|
109
|
+
/** @type {Record<string, unknown>} */
|
|
110
110
|
#data = $state({})
|
|
111
111
|
|
|
112
|
-
/** @type {
|
|
112
|
+
/** @type {Record<string, unknown>} - Snapshot of data at construction (or last snapshot()) */
|
|
113
113
|
#initialData = {}
|
|
114
114
|
|
|
115
115
|
/** @type {Object} */
|
|
@@ -144,7 +144,7 @@ export class FormBuilder {
|
|
|
144
144
|
}
|
|
145
145
|
/**
|
|
146
146
|
* Get the current data
|
|
147
|
-
* @returns {
|
|
147
|
+
* @returns {Record<string, unknown>} Current data object
|
|
148
148
|
*/
|
|
149
149
|
get data() {
|
|
150
150
|
return this.#data
|
|
@@ -152,7 +152,7 @@ export class FormBuilder {
|
|
|
152
152
|
|
|
153
153
|
/**
|
|
154
154
|
* Set the data
|
|
155
|
-
* @param {
|
|
155
|
+
* @param {Record<string, unknown>} value - New data object
|
|
156
156
|
*/
|
|
157
157
|
set data(value) {
|
|
158
158
|
this.#data = value
|
|
@@ -219,7 +219,7 @@ export class FormBuilder {
|
|
|
219
219
|
|
|
220
220
|
/**
|
|
221
221
|
* Create a new FormBuilder instance
|
|
222
|
-
* @param {
|
|
222
|
+
* @param {Record<string, unknown>} [data={}] - Initial data object
|
|
223
223
|
* @param {Object|null} [schema=null] - Optional schema override
|
|
224
224
|
* @param {Object|null} [layout=null] - Optional layout override
|
|
225
225
|
* @param {Object<string, import('./lookup.svelte.js').LookupConfig>} [lookups={}] - Lookup configurations
|
|
@@ -740,7 +740,7 @@ export class FormBuilder {
|
|
|
740
740
|
* Get form data with hidden field values stripped out
|
|
741
741
|
* Hidden fields are those absent from this.elements (the derived list)
|
|
742
742
|
* Does not mutate this.#data
|
|
743
|
-
* @returns {
|
|
743
|
+
* @returns {Record<string, unknown>} Filtered data containing only visible field keys
|
|
744
744
|
*/
|
|
745
745
|
getVisibleData() {
|
|
746
746
|
const visiblePaths = new SvelteSet(
|
package/dist/src/types.d.ts
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|