@rokkit/forms 1.0.0-next.147 → 1.0.0-next.148
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/src/input/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/Input.svelte +2 -2
- package/src/input/InputSwatch.svelte +30 -0
- package/src/input/index.js +1 -0
- package/src/lib/renderers.js +3 -1
|
@@ -11,6 +11,7 @@ export { default as InputPassword } from "./InputPassword.svelte";
|
|
|
11
11
|
export { default as InputRadio } from "./InputRadio.svelte";
|
|
12
12
|
export { default as InputRange } from "./InputRange.svelte";
|
|
13
13
|
export { default as InputSelect } from "./InputSelect.svelte";
|
|
14
|
+
export { default as InputSwatch } from "./InputSwatch.svelte";
|
|
14
15
|
export { default as InputSwitch } from "./InputSwitch.svelte";
|
|
15
16
|
export { default as InputTel } from "./InputTel.svelte";
|
|
16
17
|
export { default as InputText } from "./InputText.svelte";
|
package/package.json
CHANGED
package/src/Input.svelte
CHANGED
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
const extraProps = $derived(type === 'integer' ? { step: '1' } : {})
|
|
18
18
|
</script>
|
|
19
19
|
|
|
20
|
-
{#if type === 'checkbox'}
|
|
21
|
-
{@const Component = resolveRenderer({ type:
|
|
20
|
+
{#if type === 'checkbox' || type === 'swatch'}
|
|
21
|
+
{@const Component = resolveRenderer({ type, props: restProps }, allRenderers)}
|
|
22
22
|
<Component bind:value {onchange} {oninput} {onfocus} {onblur} {...restProps} />
|
|
23
23
|
{:else}
|
|
24
24
|
{@const Component = resolveRenderer({ type, props: restProps }, allRenderers)}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { Swatch } from '@rokkit/ui'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {Object} InputSwatchProps
|
|
6
|
+
* @property {any} value - Selected value (bindable); array when multiple=true
|
|
7
|
+
* @property {Array<Object|string>} [options] - Options array
|
|
8
|
+
* @property {Object} [fields] - Field mapping (label, value, disabled)
|
|
9
|
+
* @property {boolean} [multiple] - Multi-select mode
|
|
10
|
+
* @property {'square'|'circle'} [shape] - Default cell shape
|
|
11
|
+
* @property {'sm'|'md'|'lg'} [size] - Size variant
|
|
12
|
+
* @property {boolean} [disabled] - Disabled state
|
|
13
|
+
* @property {Function} [onchange] - Change callback
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** @type {InputSwatchProps & { [key: string]: any }} */
|
|
17
|
+
let {
|
|
18
|
+
value = $bindable(),
|
|
19
|
+
options = [],
|
|
20
|
+
fields,
|
|
21
|
+
multiple = false,
|
|
22
|
+
shape = 'square',
|
|
23
|
+
size = 'md',
|
|
24
|
+
disabled = false,
|
|
25
|
+
onchange,
|
|
26
|
+
..._rest
|
|
27
|
+
} = $props()
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<Swatch {options} {fields} bind:value {multiple} {shape} {size} {disabled} {onchange} />
|
package/src/input/index.js
CHANGED
|
@@ -14,6 +14,7 @@ export { default as InputRadio } from './InputRadio.svelte'
|
|
|
14
14
|
|
|
15
15
|
export { default as InputRange } from './InputRange.svelte'
|
|
16
16
|
export { default as InputSelect } from './InputSelect.svelte'
|
|
17
|
+
export { default as InputSwatch } from './InputSwatch.svelte'
|
|
17
18
|
export { default as InputSwitch } from './InputSwitch.svelte'
|
|
18
19
|
export { default as InputTel } from './InputTel.svelte'
|
|
19
20
|
export { default as InputText } from './InputText.svelte'
|
package/src/lib/renderers.js
CHANGED
|
@@ -20,6 +20,7 @@ import InputRange from '../input/InputRange.svelte'
|
|
|
20
20
|
import InputSelect from '../input/InputSelect.svelte'
|
|
21
21
|
import InputSwitch from '../input/InputSwitch.svelte'
|
|
22
22
|
import InputToggle from '../input/InputToggle.svelte'
|
|
23
|
+
import InputSwatch from '../input/InputSwatch.svelte'
|
|
23
24
|
import InputTel from '../input/InputTel.svelte'
|
|
24
25
|
import InputText from '../input/InputText.svelte'
|
|
25
26
|
import InputTextArea from '../input/InputTextArea.svelte'
|
|
@@ -54,7 +55,8 @@ export const defaultRenderers = {
|
|
|
54
55
|
radio: InputRadio,
|
|
55
56
|
select: InputSelect,
|
|
56
57
|
switch: InputSwitch,
|
|
57
|
-
toggle: InputToggle
|
|
58
|
+
toggle: InputToggle,
|
|
59
|
+
swatch: InputSwatch
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
/**
|