@samuel-charpentier/sform 0.0.3 → 0.0.5
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/README.md
CHANGED
|
@@ -193,6 +193,7 @@ Supported text types: `text`, `email`, `tel`, `url`, `search`, `date`, `datetime
|
|
|
193
193
|
| `showToggleIcon` | `Snippet<[passwordShown: boolean]>` | `undefined` | Custom toggle icon snippet |
|
|
194
194
|
| `prefix` | `string \| Snippet` | `undefined` | Content before input |
|
|
195
195
|
| `suffix` | `string \| Snippet` | `undefined` | Content after input |
|
|
196
|
+
| `autocomplete` | `string` | `undefined` | HTML autocomplete attribute |
|
|
196
197
|
|
|
197
198
|
#### Number Input
|
|
198
199
|
|
|
@@ -221,11 +222,10 @@ Supported text types: `text`, `email`, `tel`, `url`, `search`, `date`, `datetime
|
|
|
221
222
|
<Sfield field={fields.notes} type="textarea" label="Notes" prefix="📝" suffix="(max 500 chars)" />
|
|
222
223
|
```
|
|
223
224
|
|
|
224
|
-
| Prop
|
|
225
|
-
|
|
|
226
|
-
| `prefix`
|
|
227
|
-
| `suffix`
|
|
228
|
-
| `autocomplete` | `string` | `undefined` | HTML autocomplete attribute |
|
|
225
|
+
| Prop | Type | Default | Description |
|
|
226
|
+
| -------- | ------------------- | ----------- | -------------------- |
|
|
227
|
+
| `prefix` | `string \| Snippet` | `undefined` | Content before input |
|
|
228
|
+
| `suffix` | `string \| Snippet` | `undefined` | Content after input |
|
|
229
229
|
|
|
230
230
|
#### Select
|
|
231
231
|
|
|
@@ -242,9 +242,10 @@ Supported text types: `text`, `email`, `tel`, `url`, `search`, `date`, `datetime
|
|
|
242
242
|
/>
|
|
243
243
|
```
|
|
244
244
|
|
|
245
|
-
| Prop
|
|
246
|
-
|
|
|
247
|
-
| `options`
|
|
245
|
+
| Prop | Type | Default | Description |
|
|
246
|
+
| -------------- | ---------------------------- | ----------- | --------------------------- |
|
|
247
|
+
| `options` | `SelectOption[] \| string[]` | required | Select options |
|
|
248
|
+
| `autocomplete` | `string` | `undefined` | HTML autocomplete attribute |
|
|
248
249
|
|
|
249
250
|
#### Checkbox
|
|
250
251
|
|
|
@@ -286,13 +287,14 @@ Supported text types: `text`, `email`, `tel`, `url`, `search`, `date`, `datetime
|
|
|
286
287
|
/>
|
|
287
288
|
```
|
|
288
289
|
|
|
289
|
-
| Prop
|
|
290
|
-
|
|
|
291
|
-
| `min`
|
|
292
|
-
| `max`
|
|
293
|
-
| `step`
|
|
294
|
-
| `showValue`
|
|
295
|
-
| `formatValue`
|
|
290
|
+
| Prop | Type | Default | Description |
|
|
291
|
+
| -------------- | --------------------------- | ----------- | --------------------------- |
|
|
292
|
+
| `min` | `number \| string` | `0` | Minimum value |
|
|
293
|
+
| `max` | `number \| string` | `100` | Maximum value |
|
|
294
|
+
| `step` | `number \| string` | `1` | Step increment |
|
|
295
|
+
| `showValue` | `boolean` | `false` | Show current value |
|
|
296
|
+
| `formatValue` | `(value: number) => string` | `undefined` | Format displayed value |
|
|
297
|
+
| `autocomplete` | `string` | `undefined` | HTML autocomplete attribute |
|
|
296
298
|
|
|
297
299
|
#### Toggle
|
|
298
300
|
|
|
@@ -365,6 +367,7 @@ Supported text types: `text`, `email`, `tel`, `url`, `search`, `date`, `datetime
|
|
|
365
367
|
| `unmaskValue` | `boolean` | `true` | Store unmasked value |
|
|
366
368
|
| `prefix` | `string \| Snippet` | `undefined` | Content before input |
|
|
367
369
|
| `suffix` | `string \| Snippet` | `undefined` | Content after input |
|
|
370
|
+
| `autocomplete` | `string` | `undefined` | HTML autocomplete attribute |
|
|
368
371
|
|
|
369
372
|
**Mask Tokens:**
|
|
370
373
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { CheckboxGroupInputProps, SelectOption } from '../types.js';
|
|
3
|
+
import Fieldset from '../utils/Fieldset.svelte';
|
|
3
4
|
|
|
4
5
|
let {
|
|
5
6
|
field,
|
|
@@ -29,10 +30,7 @@
|
|
|
29
30
|
}
|
|
30
31
|
</script>
|
|
31
32
|
|
|
32
|
-
<
|
|
33
|
-
{#if label}
|
|
34
|
-
<legend class={labelClass}>{label}</legend>
|
|
35
|
-
{/if}
|
|
33
|
+
<Fieldset {label} {labelClass} {className} {disabled}>
|
|
36
34
|
{#each normalizedOptions as option}
|
|
37
35
|
{@const fieldAttrs = getFieldAttrs(option.value)}
|
|
38
36
|
{@const uniqueId = `${name}-${option.value}`}
|
|
@@ -48,20 +46,9 @@
|
|
|
48
46
|
<span class="sform-checkbox-label">{option.label}</span>
|
|
49
47
|
</label>
|
|
50
48
|
{/each}
|
|
51
|
-
</
|
|
49
|
+
</Fieldset>
|
|
52
50
|
|
|
53
51
|
<style>
|
|
54
|
-
.sform-checkbox-group {
|
|
55
|
-
border: none;
|
|
56
|
-
padding: 0;
|
|
57
|
-
margin: 0;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.sform-checkbox-group legend {
|
|
61
|
-
padding: 0;
|
|
62
|
-
margin-bottom: 0.5rem;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
52
|
.sform-checkbox-option {
|
|
66
53
|
display: flex;
|
|
67
54
|
align-items: center;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { RadioInputProps, SelectOption } from '../types.js';
|
|
3
|
+
import Fieldset from '../utils/Fieldset.svelte';
|
|
3
4
|
|
|
4
5
|
let {
|
|
5
6
|
field,
|
|
@@ -29,10 +30,7 @@
|
|
|
29
30
|
}
|
|
30
31
|
</script>
|
|
31
32
|
|
|
32
|
-
<
|
|
33
|
-
{#if label}
|
|
34
|
-
<legend class={labelClass}>{label}</legend>
|
|
35
|
-
{/if}
|
|
33
|
+
<Fieldset {label} {labelClass} {className} {disabled}>
|
|
36
34
|
{#each normalizedOptions as option}
|
|
37
35
|
{@const fieldAttrs = getFieldAttrs(option.value)}
|
|
38
36
|
{@const uniqueId = `${name}-${option.value}`}
|
|
@@ -48,7 +46,7 @@
|
|
|
48
46
|
<span class="sform-radio-label">{option.label}</span>
|
|
49
47
|
</label>
|
|
50
48
|
{/each}
|
|
51
|
-
</
|
|
49
|
+
</Fieldset>
|
|
52
50
|
|
|
53
51
|
<style>
|
|
54
52
|
.sform-radio-group {
|
package/dist/Sform/types.d.ts
CHANGED
|
@@ -458,8 +458,6 @@ export interface BaseInputComponentProps {
|
|
|
458
458
|
disabled?: boolean;
|
|
459
459
|
/** Whether input is readonly */
|
|
460
460
|
readonly?: boolean;
|
|
461
|
-
/** Autocomplete attribute */
|
|
462
|
-
autocomplete?: HTMLInputAttributes['autocomplete'];
|
|
463
461
|
/** Whether to show validation state (controls aria-invalid) */
|
|
464
462
|
showIssues?: boolean;
|
|
465
463
|
/** Blur handler */
|
|
@@ -512,6 +510,8 @@ export interface NumberInputComponentProps extends BaseInputComponentProps, Inpu
|
|
|
512
510
|
align?: 'start' | 'end';
|
|
513
511
|
/** Maximum decimal places allowed (0 = integers only, undefined = no limit) */
|
|
514
512
|
maxDecimals?: number;
|
|
513
|
+
/** Autocomplete attribute */
|
|
514
|
+
autocomplete?: HTMLInputAttributes['autocomplete'];
|
|
515
515
|
}
|
|
516
516
|
/**
|
|
517
517
|
* Props for text input component (text, email, tel, url, search, date, etc.)
|
|
@@ -519,11 +519,15 @@ export interface NumberInputComponentProps extends BaseInputComponentProps, Inpu
|
|
|
519
519
|
export interface TextInputComponentProps extends BaseInputComponentProps, InputAffixProps {
|
|
520
520
|
/** Input type - text-like types only */
|
|
521
521
|
type: TextInputType;
|
|
522
|
+
/** Autocomplete attribute */
|
|
523
|
+
autocomplete?: HTMLInputAttributes['autocomplete'];
|
|
522
524
|
}
|
|
523
525
|
/**
|
|
524
526
|
* Props for textarea input component
|
|
525
527
|
*/
|
|
526
528
|
export interface TextareaInputProps extends BaseInputComponentProps, InputAffixProps {
|
|
529
|
+
/** Autocomplete attribute */
|
|
530
|
+
autocomplete?: HTMLInputAttributes['autocomplete'];
|
|
527
531
|
}
|
|
528
532
|
/**
|
|
529
533
|
* Props for select input component
|
|
@@ -531,6 +535,8 @@ export interface TextareaInputProps extends BaseInputComponentProps, InputAffixP
|
|
|
531
535
|
export interface SelectInputProps extends BaseInputComponentProps {
|
|
532
536
|
/** Options for select */
|
|
533
537
|
options: SelectOption[] | string[];
|
|
538
|
+
/** Autocomplete attribute */
|
|
539
|
+
autocomplete?: HTMLInputAttributes['autocomplete'];
|
|
534
540
|
}
|
|
535
541
|
/**
|
|
536
542
|
* Props for checkbox input component (single yes/no)
|
|
@@ -628,6 +634,8 @@ export interface RangeInputProps extends NumericInputComponentProps {
|
|
|
628
634
|
showValue?: boolean;
|
|
629
635
|
/** Format function for value display */
|
|
630
636
|
formatValue?: (value: number) => string;
|
|
637
|
+
/** Autocomplete attribute */
|
|
638
|
+
autocomplete?: HTMLInputAttributes['autocomplete'];
|
|
631
639
|
}
|
|
632
640
|
/**
|
|
633
641
|
* Props for password input component
|
|
@@ -636,6 +644,8 @@ export interface PasswordInputProps extends BaseInputComponentProps {
|
|
|
636
644
|
/** Whether to show the password visibility toggle */
|
|
637
645
|
showToggle?: boolean;
|
|
638
646
|
showToggleIcon?: Snippet<[boolean]>;
|
|
647
|
+
/** Autocomplete attribute */
|
|
648
|
+
autocomplete?: HTMLInputAttributes['autocomplete'];
|
|
639
649
|
}
|
|
640
650
|
/**
|
|
641
651
|
* Props for toggle input component
|
|
@@ -681,4 +691,16 @@ export interface MaskedInputProps extends BaseInputComponentProps, InputAffixPro
|
|
|
681
691
|
showMaskPlaceholder?: boolean;
|
|
682
692
|
/** Whether to store the unmasked (raw) value. If true, stores '1234567890'. If false, stores '(123) 456-7890'. Default: true */
|
|
683
693
|
unmaskValue?: boolean;
|
|
694
|
+
/** Autocomplete attribute */
|
|
695
|
+
autocomplete?: HTMLInputAttributes['autocomplete'];
|
|
684
696
|
}
|
|
697
|
+
/**
|
|
698
|
+
* Props for Fieldset utils component
|
|
699
|
+
*/
|
|
700
|
+
export type FieldsetProps = {
|
|
701
|
+
label?: string;
|
|
702
|
+
labelClass?: string;
|
|
703
|
+
className?: string;
|
|
704
|
+
disabled?: boolean;
|
|
705
|
+
children: Snippet;
|
|
706
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { FieldsetProps } from '../types';
|
|
4
|
+
|
|
5
|
+
let { label, labelClass, className, disabled, children }: FieldsetProps = $props();
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<fieldset class="sform-checkbox-group {className ?? ''}" {disabled}>
|
|
9
|
+
{#if label}
|
|
10
|
+
<legend class={labelClass}>{label}</legend>
|
|
11
|
+
{/if}
|
|
12
|
+
{@render children()}
|
|
13
|
+
</fieldset>
|
|
14
|
+
|
|
15
|
+
<style>
|
|
16
|
+
.sform-checkbox-group legend {
|
|
17
|
+
padding: 0.25rem 0.5rem;
|
|
18
|
+
margin: 0;
|
|
19
|
+
border: var(--sform-border-width) solid var(--sform-border);
|
|
20
|
+
background: var(--sform-bg);
|
|
21
|
+
border-radius: 0.25rem;
|
|
22
|
+
line-height: 1;
|
|
23
|
+
}
|
|
24
|
+
</style>
|