@rokkit/forms 1.1.18 → 1.1.19
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,17 +1,20 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
/**
|
|
3
3
|
* Format-aware value display component.
|
|
4
4
|
* Renders a value with formatting based on the `format` hint.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
type Props = {
|
|
8
|
+
value?: unknown
|
|
9
|
+
format?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let { value, format = 'text' }: Props = $props()
|
|
8
13
|
|
|
9
14
|
/**
|
|
10
15
|
* Format a duration value (minutes) into human-readable string.
|
|
11
|
-
* @param {number} minutes
|
|
12
|
-
* @returns {string}
|
|
13
16
|
*/
|
|
14
|
-
function formatDuration(minutes) {
|
|
17
|
+
function formatDuration(minutes: unknown): string {
|
|
15
18
|
if (typeof minutes !== 'number') return String(minutes)
|
|
16
19
|
const h = Math.floor(minutes / 60)
|
|
17
20
|
const m = minutes % 60
|
|
@@ -20,12 +23,18 @@
|
|
|
20
23
|
return `${m}m`
|
|
21
24
|
}
|
|
22
25
|
|
|
23
|
-
|
|
26
|
+
function toDate(v: unknown): Date {
|
|
27
|
+
if (v instanceof Date) return v
|
|
28
|
+
if (typeof v === 'number') return new Date(v)
|
|
29
|
+
return new Date(String(v))
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const valueFormatters: Record<string, (v: unknown) => string> = {
|
|
24
33
|
currency: (v) =>
|
|
25
|
-
new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(v),
|
|
26
|
-
datetime: (v) =>
|
|
34
|
+
new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(Number(v)),
|
|
35
|
+
datetime: (v) => toDate(v).toLocaleString(),
|
|
27
36
|
duration: (v) => formatDuration(v),
|
|
28
|
-
number: (v) => new Intl.NumberFormat().format(v),
|
|
37
|
+
number: (v) => new Intl.NumberFormat().format(Number(v)),
|
|
29
38
|
boolean: (v) => (v ? '✓' : '✗')
|
|
30
39
|
}
|
|
31
40
|
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import { defaultRenderers, resolveRenderer } from '../lib/renderers.js'
|
|
3
3
|
import FormRenderer from '../FormRenderer.svelte'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
type ItemSchema = {
|
|
6
|
+
type?: string
|
|
7
|
+
default?: unknown
|
|
8
|
+
properties?: Record<string, ItemSchema>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type Props = {
|
|
12
|
+
value?: unknown[]
|
|
13
|
+
onchange?: (value: unknown[]) => void
|
|
14
|
+
items?: ItemSchema
|
|
15
|
+
disabled?: boolean
|
|
16
|
+
readonly?: boolean
|
|
17
|
+
}
|
|
13
18
|
|
|
14
|
-
/** @type {ArrayEditorProps & { [key: string]: any }} */
|
|
15
19
|
let {
|
|
16
20
|
value = $bindable([]),
|
|
17
21
|
onchange,
|
|
@@ -19,28 +23,42 @@
|
|
|
19
23
|
disabled = false,
|
|
20
24
|
readonly = false,
|
|
21
25
|
..._rest
|
|
22
|
-
} = $props()
|
|
26
|
+
}: Props = $props()
|
|
23
27
|
|
|
24
28
|
// Normalize: treat undefined/null as empty array
|
|
25
29
|
const safeValue = $derived(Array.isArray(value) ? value : [])
|
|
26
30
|
|
|
31
|
+
// Narrow a dynamic array item into a record for object-schema rendering
|
|
32
|
+
function toRecord(item: unknown): Record<string, unknown> {
|
|
33
|
+
return item !== null && typeof item === 'object' && !Array.isArray(item)
|
|
34
|
+
? (item as Record<string, unknown>)
|
|
35
|
+
: {}
|
|
36
|
+
}
|
|
37
|
+
|
|
27
38
|
// Item schema — default to string if not provided
|
|
28
|
-
const itemSchema = $derived(items ?? { type: 'string' })
|
|
39
|
+
const itemSchema = $derived<ItemSchema>(items ?? { type: 'string' })
|
|
29
40
|
|
|
30
41
|
// Resolve the primitive renderer once (reused for all items)
|
|
31
42
|
const PrimitiveComponent = $derived(
|
|
32
43
|
itemSchema.type !== 'object'
|
|
33
|
-
? resolveRenderer({ type: itemSchema.type }, defaultRenderers)
|
|
44
|
+
? resolveRenderer({ type: itemSchema.type ?? 'string' }, defaultRenderers)
|
|
34
45
|
: null
|
|
35
46
|
)
|
|
36
47
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
48
|
+
const TYPE_DEFAULTS: Record<string, unknown> = {
|
|
49
|
+
string: '',
|
|
50
|
+
number: 0,
|
|
51
|
+
integer: 0,
|
|
52
|
+
boolean: false,
|
|
53
|
+
array: [],
|
|
54
|
+
object: {}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function typeDefault(type: string | undefined): unknown {
|
|
58
|
+
return TYPE_DEFAULTS[type ?? ''] ?? null
|
|
41
59
|
}
|
|
42
60
|
|
|
43
|
-
function createDefaultItem(schema) {
|
|
61
|
+
function createDefaultItem(schema: ItemSchema): unknown {
|
|
44
62
|
if (schema.type === 'object') {
|
|
45
63
|
return Object.fromEntries(
|
|
46
64
|
Object.entries(schema.properties ?? {}).map(([k, s]) => [
|
|
@@ -59,13 +77,13 @@
|
|
|
59
77
|
onchange?.(newValue)
|
|
60
78
|
}
|
|
61
79
|
|
|
62
|
-
function removeItem(index) {
|
|
80
|
+
function removeItem(index: number) {
|
|
63
81
|
const newValue = safeValue.filter((_, i) => i !== index)
|
|
64
82
|
value = newValue
|
|
65
83
|
onchange?.(newValue)
|
|
66
84
|
}
|
|
67
85
|
|
|
68
|
-
function updateItem(index, newItemValue) {
|
|
86
|
+
function updateItem(index: number, newItemValue: unknown) {
|
|
69
87
|
const newValue = safeValue.map((item, i) => (i === index ? newItemValue : item))
|
|
70
88
|
value = newValue
|
|
71
89
|
onchange?.(newValue)
|
|
@@ -83,14 +101,14 @@
|
|
|
83
101
|
<div data-array-editor-item-content>
|
|
84
102
|
{#if itemSchema.type === 'object'}
|
|
85
103
|
<FormRenderer
|
|
86
|
-
data={item}
|
|
104
|
+
data={toRecord(item)}
|
|
87
105
|
schema={itemSchema}
|
|
88
106
|
onupdate={(newData) => updateItem(index, newData)}
|
|
89
107
|
/>
|
|
90
|
-
{:else}
|
|
108
|
+
{:else if PrimitiveComponent}
|
|
91
109
|
<PrimitiveComponent
|
|
92
110
|
value={item}
|
|
93
|
-
onchange={(newVal) => updateItem(index, newVal)}
|
|
111
|
+
onchange={(newVal: unknown) => updateItem(index, newVal)}
|
|
94
112
|
{disabled}
|
|
95
113
|
{readonly}
|
|
96
114
|
/>
|
|
@@ -1,29 +1,21 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLInputAttributes } from 'svelte/elements'
|
|
2
3
|
import { DEFAULT_STATE_ICONS } from '@rokkit/core'
|
|
3
4
|
import { isNil } from 'ramda'
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*/
|
|
6
|
+
type StateIcons = {
|
|
7
|
+
checked?: string
|
|
8
|
+
unchecked?: string
|
|
9
|
+
unknown?: string
|
|
10
|
+
}
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* @property {Function} onfocus
|
|
19
|
-
* @property {Function} onblur
|
|
20
|
-
* @property {boolean} required
|
|
21
|
-
* @property {boolean} disabled
|
|
22
|
-
* @property {string} name
|
|
23
|
-
* @property {string} id
|
|
24
|
-
*/
|
|
12
|
+
type Props = Omit<HTMLInputAttributes, 'value' | 'onchange'> & {
|
|
13
|
+
value?: boolean | null
|
|
14
|
+
variant?: 'default' | 'custom'
|
|
15
|
+
icons?: StateIcons
|
|
16
|
+
onchange?: (value: boolean) => void
|
|
17
|
+
}
|
|
25
18
|
|
|
26
|
-
/** @type {InputCheckboxProps & { [key: string]: any }} */
|
|
27
19
|
let {
|
|
28
20
|
value = $bindable(),
|
|
29
21
|
variant = 'custom',
|
|
@@ -36,15 +28,15 @@
|
|
|
36
28
|
name,
|
|
37
29
|
id,
|
|
38
30
|
...rest
|
|
39
|
-
} = $props()
|
|
31
|
+
}: Props = $props()
|
|
40
32
|
|
|
41
|
-
function handleChange(event) {
|
|
42
|
-
value = Boolean(event.
|
|
33
|
+
function handleChange(event: Event & { currentTarget: HTMLInputElement }) {
|
|
34
|
+
value = Boolean(event.currentTarget.checked)
|
|
43
35
|
onchange?.(value)
|
|
44
36
|
}
|
|
45
37
|
|
|
46
38
|
function toggle() {
|
|
47
|
-
value = !
|
|
39
|
+
value = !value
|
|
48
40
|
onchange?.(value)
|
|
49
41
|
}
|
|
50
42
|
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* @property {boolean} required
|
|
9
|
-
* @property {boolean} disabled
|
|
10
|
-
* @property {string} name
|
|
11
|
-
* @property {string} id
|
|
12
|
-
* @property {string} autocomplete
|
|
13
|
-
*/
|
|
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
|
+
}
|
|
14
8
|
|
|
15
|
-
/** @type {InputColorProps & { [key: string]: any }} */
|
|
16
9
|
let {
|
|
17
10
|
value = $bindable(),
|
|
18
11
|
onchange,
|
|
@@ -24,10 +17,10 @@
|
|
|
24
17
|
id,
|
|
25
18
|
autocomplete,
|
|
26
19
|
...rest
|
|
27
|
-
} = $props()
|
|
20
|
+
}: Props = $props()
|
|
28
21
|
|
|
29
|
-
function handleChange(event) {
|
|
30
|
-
value = event.
|
|
22
|
+
function handleChange(event: Event & { currentTarget: HTMLInputElement }) {
|
|
23
|
+
value = event.currentTarget.value
|
|
31
24
|
onchange?.(value)
|
|
32
25
|
}
|
|
33
26
|
</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 {InputDateProps & { [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,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 {InputDateTimeProps & { [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,25 +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
|
-
* @property {boolean} multiple
|
|
20
|
-
*/
|
|
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
|
+
}
|
|
21
8
|
|
|
22
|
-
/** @type {InputEmailProps & { [key: string]: any }} */
|
|
23
9
|
let {
|
|
24
10
|
value = $bindable(),
|
|
25
11
|
onchange,
|
|
@@ -38,10 +24,10 @@
|
|
|
38
24
|
size,
|
|
39
25
|
multiple,
|
|
40
26
|
...rest
|
|
41
|
-
} = $props()
|
|
27
|
+
}: Props = $props()
|
|
42
28
|
|
|
43
|
-
function handleChange(event) {
|
|
44
|
-
value = event.
|
|
29
|
+
function handleChange(event: Event & { currentTarget: HTMLInputElement }) {
|
|
30
|
+
value = event.currentTarget.value
|
|
45
31
|
onchange?.(value)
|
|
46
32
|
}
|
|
47
33
|
</script>
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* @property {string} accept
|
|
9
|
-
* @property {boolean} multiple
|
|
10
|
-
* @property {boolean} required
|
|
11
|
-
* @property {boolean} disabled
|
|
12
|
-
* @property {string} name
|
|
13
|
-
* @property {string} id
|
|
14
|
-
*/
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLInputAttributes } from 'svelte/elements'
|
|
3
|
+
|
|
4
|
+
type Props = Omit<HTMLInputAttributes, 'value' | 'onchange'> & {
|
|
5
|
+
value?: FileList | null
|
|
6
|
+
onchange?: (value: FileList | null) => void
|
|
7
|
+
}
|
|
15
8
|
|
|
16
|
-
/** @type {InputFileProps & { [key: string]: any }} */
|
|
17
9
|
let {
|
|
18
10
|
value = $bindable(),
|
|
19
11
|
onchange,
|
|
@@ -26,10 +18,10 @@
|
|
|
26
18
|
name,
|
|
27
19
|
id,
|
|
28
20
|
...rest
|
|
29
|
-
} = $props()
|
|
21
|
+
}: Props = $props()
|
|
30
22
|
|
|
31
|
-
function handleChange(event) {
|
|
32
|
-
value = event.
|
|
23
|
+
function handleChange(event: Event & { currentTarget: HTMLInputElement }) {
|
|
24
|
+
value = event.currentTarget.files
|
|
33
25
|
onchange?.(value)
|
|
34
26
|
}
|
|
35
27
|
</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 {InputMonthProps & { [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,23 +1,11 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* @property {number} min
|
|
9
|
-
* @property {number} max
|
|
10
|
-
* @property {number} step
|
|
11
|
-
* @property {string} placeholder
|
|
12
|
-
* @property {boolean} required
|
|
13
|
-
* @property {boolean} disabled
|
|
14
|
-
* @property {boolean} readonly
|
|
15
|
-
* @property {string} name
|
|
16
|
-
* @property {string} id
|
|
17
|
-
* @property {string} autocomplete
|
|
18
|
-
*/
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLInputAttributes } from 'svelte/elements'
|
|
3
|
+
|
|
4
|
+
type Props = Omit<HTMLInputAttributes, 'value' | 'onchange'> & {
|
|
5
|
+
value?: number
|
|
6
|
+
onchange?: (value: number) => void
|
|
7
|
+
}
|
|
19
8
|
|
|
20
|
-
/** @type {InputNumberProps & { [key: string]: any }} */
|
|
21
9
|
let {
|
|
22
10
|
value = $bindable(),
|
|
23
11
|
onchange,
|
|
@@ -34,10 +22,10 @@
|
|
|
34
22
|
id,
|
|
35
23
|
autocomplete,
|
|
36
24
|
...rest
|
|
37
|
-
} = $props()
|
|
25
|
+
}: Props = $props()
|
|
38
26
|
|
|
39
|
-
function handleChange(event) {
|
|
40
|
-
value = event.
|
|
27
|
+
function handleChange(event: Event & { currentTarget: HTMLInputElement }) {
|
|
28
|
+
value = event.currentTarget.valueAsNumber
|
|
41
29
|
onchange?.(value)
|
|
42
30
|
}
|
|
43
31
|
</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 {InputPasswordProps & { [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,21 +1,20 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { getItemAtIndex, getIndexForItem, noop } from '@rokkit/core'
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getItemAtIndex, getIndexForItem, noop, type FieldMapping } from '@rokkit/core'
|
|
3
3
|
import { ProxyItem } from '@rokkit/states'
|
|
4
|
-
// import { equals } from 'ramda'
|
|
5
|
-
/**
|
|
6
|
-
* @typedef {Object} InputRadioProps
|
|
7
|
-
* @property {string} [class]
|
|
8
|
-
* @property {any} value
|
|
9
|
-
* @property {Object} [fields]
|
|
10
|
-
* @property {any} [options]
|
|
11
|
-
* @property {boolean} [disabled]
|
|
12
|
-
* @property {boolean} [flip]
|
|
13
|
-
* @property {Function} onchange
|
|
14
|
-
* @property {Function} onfocus
|
|
15
|
-
* @property {Function} onblur
|
|
16
|
-
*/
|
|
17
4
|
|
|
18
|
-
|
|
5
|
+
type Props = {
|
|
6
|
+
class?: string
|
|
7
|
+
value?: unknown
|
|
8
|
+
fields?: FieldMapping
|
|
9
|
+
options?: unknown[]
|
|
10
|
+
disabled?: boolean
|
|
11
|
+
flip?: boolean
|
|
12
|
+
onchange?: (value: unknown) => void
|
|
13
|
+
onfocus?: (event: FocusEvent) => void
|
|
14
|
+
onblur?: (event: FocusEvent) => void
|
|
15
|
+
[key: string]: unknown
|
|
16
|
+
}
|
|
17
|
+
|
|
19
18
|
let {
|
|
20
19
|
class: className = '',
|
|
21
20
|
value = $bindable(),
|
|
@@ -26,7 +25,7 @@
|
|
|
26
25
|
onfocus,
|
|
27
26
|
onblur,
|
|
28
27
|
...rest
|
|
29
|
-
} = $props()
|
|
28
|
+
}: Props = $props()
|
|
30
29
|
|
|
31
30
|
let currentIndex = $derived(getIndexForItem(options, value))
|
|
32
31
|
|
|
@@ -34,10 +33,6 @@
|
|
|
34
33
|
value = getItemAtIndex(options, currentIndex)
|
|
35
34
|
onchange?.(value)
|
|
36
35
|
}
|
|
37
|
-
|
|
38
|
-
// $effect.pre(() => {
|
|
39
|
-
// currentIndex = getIndexForItem(options, value)
|
|
40
|
-
// })
|
|
41
36
|
</script>
|
|
42
37
|
|
|
43
38
|
<radio-group class={className} class:disabled>
|
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* @property {number} min
|
|
9
|
-
* @property {number} max
|
|
10
|
-
* @property {number} step
|
|
11
|
-
* @property {string} list
|
|
12
|
-
* @property {boolean} required
|
|
13
|
-
* @property {boolean} disabled
|
|
14
|
-
* @property {string} name
|
|
15
|
-
* @property {string} id
|
|
16
|
-
*/
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLInputAttributes } from 'svelte/elements'
|
|
3
|
+
|
|
4
|
+
type Props = Omit<HTMLInputAttributes, 'value' | 'onchange'> & {
|
|
5
|
+
value?: number
|
|
6
|
+
onchange?: (value: number) => void
|
|
7
|
+
}
|
|
17
8
|
|
|
18
|
-
/** @type {InputRangeProps & { [key: string]: any }} */
|
|
19
9
|
let {
|
|
20
10
|
value = $bindable(),
|
|
21
11
|
min = undefined,
|
|
@@ -30,10 +20,10 @@
|
|
|
30
20
|
onfocus,
|
|
31
21
|
onblur,
|
|
32
22
|
...rest
|
|
33
|
-
} = $props()
|
|
23
|
+
}: Props = $props()
|
|
34
24
|
|
|
35
|
-
function handleChange(event) {
|
|
36
|
-
value = event.
|
|
25
|
+
function handleChange(event: Event & { currentTarget: HTMLInputElement }) {
|
|
26
|
+
value = event.currentTarget.valueAsNumber
|
|
37
27
|
onchange?.(value)
|
|
38
28
|
}
|
|
39
29
|
</script>
|