svseeds 0.3.0 → 0.3.2

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.
@@ -1,6 +1,5 @@
1
1
  <script module lang="ts">
2
2
  export type TagsInputProps = {
3
- bottom?: string, // bindable
4
3
  values?: string[], // bindable
5
4
  type?: "left" | "right" | "bottom", // <"left">
6
5
  confirm?: string[],
@@ -33,7 +32,7 @@
33
32
  </script>
34
33
 
35
34
  <script lang="ts">
36
- let { bottom = $bindable(), values = $bindable([]), type = "left", confirm = [], trim = false, unique = true, min, max, validations = [], status = $bindable(""), style, element = $bindable(), deps }: TagsInputProps = $props();
35
+ let { values = $bindable([]), type = "left", confirm = [], trim = false, unique = true, min, max, validations = [], status = $bindable(""), style, element = $bindable(), deps }: TagsInputProps = $props();
37
36
 
38
37
  // *** Initialize *** //
39
38
  if (!status) status = STATE.DEFAULT;
@@ -95,7 +94,7 @@
95
94
 
96
95
  <!---------------------------------------->
97
96
 
98
- <TextField bind:value bind:status bind:bottom bind:element type="text" {...deps?.svsTextField} {left} {right} />
97
+ <TextField bind:value bind:status bind:element type="text" {...deps?.svsTextField} {left} {right} />
99
98
  {#if type === "bottom"}
100
99
  <div class={cls(AREA.BOTTOM, status)}>
101
100
  {@render tags()}
@@ -1,5 +1,4 @@
1
1
  export type TagsInputProps = {
2
- bottom?: string;
3
2
  values?: string[];
4
3
  type?: "left" | "right" | "bottom";
5
4
  confirm?: string[];
@@ -26,6 +25,6 @@ export type TagCountValidation = {
26
25
  import { type ClassRuleSet } from "./core";
27
26
  import { type TextFieldProps, type TextFieldReqdProps, type TextFieldBindProps } from "./_TextField.svelte";
28
27
  import { type BadgeProps, type BadgeReqdProps, type BadgeBindProps } from "./_Badge.svelte";
29
- declare const TagsInput: import("svelte").Component<TagsInputProps, {}, "bottom" | "status" | "element" | "values">;
28
+ declare const TagsInput: import("svelte").Component<TagsInputProps, {}, "status" | "element" | "values">;
30
29
  type TagsInput = ReturnType<typeof TagsInput>;
31
30
  export default TagsInput;
@@ -4,7 +4,7 @@
4
4
  label?: string,
5
5
  extra?: string,
6
6
  aux?: Snippet<[string, string[], HTMLInputElement[] | undefined]>, // Snippet<[status,values,elements]>
7
- bottom?: string, // bindable
7
+ bottom?: string,
8
8
  values?: string[], // bindable
9
9
  multiple?: boolean, // <true>
10
10
  descFirst?: boolean, // <false>
@@ -16,7 +16,7 @@
16
16
  elements?: HTMLInputElement[], // bindable
17
17
  };
18
18
  export type CheckFieldReqdProps = "options";
19
- export type CheckFieldBindProps = "bottom" | "values" | "status" | "elements";
19
+ export type CheckFieldBindProps = "values" | "status" | "elements";
20
20
 
21
21
  type CheckFieldTarget = { currentTarget: EventTarget & HTMLInputElement };
22
22
  const svs = "svs-check-field";
@@ -30,7 +30,7 @@
30
30
  </script>
31
31
 
32
32
  <script lang="ts">
33
- let { options, label, extra, aux, bottom = $bindable(), values = $bindable([]), multiple = true, descFirst = false, validations = [], status = $bindable(""), style, attributes, action, elements = $bindable([])}: CheckFieldProps = $props();
33
+ let { options, label, extra, aux, bottom, values = $bindable([]), multiple = true, descFirst = false, validations = [], status = $bindable(""), style, attributes, action, elements = $bindable([])}: CheckFieldProps = $props();
34
34
 
35
35
  // *** Initialize *** //
36
36
  if (!status) status = STATE.DEFAULT;
@@ -42,7 +42,7 @@
42
42
  const idErr = idDesc ?? elemId.id;
43
43
  const attrs = omit(attributes, "class", "id", "type", "name", "value", "onchange", "oninvalid");
44
44
  const roleGroup = multiple ? "group" : "radiogroup";
45
- const description = bottom;
45
+ let message = $state(bottom);
46
46
 
47
47
  // *** Status *** //
48
48
  const phase = { change: false, submit: false };
@@ -55,7 +55,7 @@
55
55
  const toNonInvalid = () => shiftStatus(phase.change && values.length ? STATE.ACTIVE : neutral);
56
56
  function shiftStatus(stat: string, msg?: string) {
57
57
  status = stat;
58
- bottom = stat === STATE.INACTIVE ? msg ?? description : description;
58
+ message = stat === STATE.INACTIVE ? msg ?? bottom : bottom;
59
59
  elements[0]?.setCustomValidity(msg ?? "");
60
60
  }
61
61
  function validate() {
@@ -118,7 +118,7 @@
118
118
  {/if}
119
119
  {/snippet}
120
120
  {#snippet main()}
121
- <div class={cls(AREA.MIDDLE, status)} role={roleGroup} aria-describedby={idDesc} aria-invalid={!multiple ? invalid : undefined} aria-errormessage={!multiple && bottom?.trim() ? errMsg : undefined}>
121
+ <div class={cls(AREA.MIDDLE, status)} role={roleGroup} aria-describedby={idDesc} aria-invalid={!multiple ? invalid : undefined} aria-errormessage={!multiple && message?.trim() ? errMsg : undefined}>
122
122
  {#each opts as {value, text, checked}, i (value)}
123
123
  <label class={cls(AREA.MAIN, status)}>
124
124
  {#if action}
@@ -132,7 +132,7 @@
132
132
  </div>
133
133
  {/snippet}
134
134
  {#snippet desc(show: boolean)}
135
- {#if show && bottom?.trim()}
136
- <div class={cls(AREA.BOTTOM, status)} id={idDesc ?? idErr} role={live}>{bottom}</div>
135
+ {#if show && message?.trim()}
136
+ <div class={cls(AREA.BOTTOM, status)} id={idDesc ?? idErr} role={live}>{message}</div>
137
137
  {/if}
138
138
  {/snippet}
@@ -15,12 +15,12 @@ export type CheckFieldProps = {
15
15
  elements?: HTMLInputElement[];
16
16
  };
17
17
  export type CheckFieldReqdProps = "options";
18
- export type CheckFieldBindProps = "bottom" | "values" | "status" | "elements";
18
+ export type CheckFieldBindProps = "values" | "status" | "elements";
19
19
  import { type Snippet } from "svelte";
20
20
  import { type Action } from "svelte/action";
21
21
  import { type SvelteMap } from "svelte/reactivity";
22
22
  import { type HTMLInputAttributes } from "svelte/elements";
23
23
  import { type ClassRuleSet } from "./core";
24
- declare const CheckField: import("svelte").Component<CheckFieldProps, {}, "bottom" | "elements" | "status" | "values">;
24
+ declare const CheckField: import("svelte").Component<CheckFieldProps, {}, "elements" | "status" | "values">;
25
25
  type CheckField = ReturnType<typeof CheckField>;
26
26
  export default CheckField;
@@ -6,7 +6,7 @@
6
6
  aux?: Snippet<[string, string, HTMLSelectElement | undefined]>, // Snippet<[status,value,element]>
7
7
  left?: Snippet<[string, string, HTMLSelectElement | undefined]>, // Snippet<[status,value,element]>
8
8
  right?: Snippet<[string, string, HTMLSelectElement | undefined]>, // Snippet<[status,value,element]>
9
- bottom?: string, // bindable
9
+ bottom?: string,
10
10
  value?: string, // bindable
11
11
  descFirst?: boolean, // <false>
12
12
  validations?: ((value: string, validity?: ValidityState) => string)[],
@@ -17,7 +17,7 @@
17
17
  element?: HTMLSelectElement, // bindable
18
18
  };
19
19
  export type SelectFieldReqdProps = "options";
20
- export type SelectFieldBindProps = "bottom" | "value" | "status" | "element";
20
+ export type SelectFieldBindProps = "value" | "status" | "element";
21
21
 
22
22
  type SelectFieldTarget = { currentTarget: EventTarget & HTMLSelectElement };
23
23
  const svs = "svs-select-field";
@@ -31,7 +31,7 @@
31
31
  </script>
32
32
 
33
33
  <script lang="ts">
34
- let { options, label, extra, aux, left, right, bottom = $bindable(), value = $bindable(""), descFirst = false, validations = [], status = $bindable(""), style, attributes, action, element = $bindable() }: SelectFieldProps = $props();
34
+ let { options, label, extra, aux, left, right, bottom, value = $bindable(""), descFirst = false, validations = [], status = $bindable(""), style, attributes, action, element = $bindable() }: SelectFieldProps = $props();
35
35
 
36
36
  // *** Initialize *** //
37
37
  if (!status) status = STATE.DEFAULT;
@@ -41,7 +41,7 @@
41
41
  const idDesc = elemId.get(bottom?.trim());
42
42
  const idErr = idDesc ?? elemId.id;
43
43
  const attrs = omit(attributes, "class", "id", "value", "oninvalid");
44
- const description = bottom;
44
+ let message = $state(bottom);
45
45
 
46
46
  // *** Status *** //
47
47
  let neutral = isNeutral(status) ? status : STATE.DEFAULT;
@@ -53,7 +53,7 @@
53
53
  const toNonInvalid = (stat: string) => shiftStatus(stat);
54
54
  function shiftStatus(stat: string, msg?: string) {
55
55
  status = stat;
56
- bottom = msg ?? description;
56
+ message = msg ?? bottom;
57
57
  element?.setCustomValidity(msg ?? "");
58
58
  }
59
59
  function validate() {
@@ -120,7 +120,7 @@
120
120
  {/snippet}
121
121
  {#snippet main()}
122
122
  {@const c = cls(AREA.MAIN, status)}
123
- {@const msg = bottom?.trim() ? errMsg : undefined}
123
+ {@const msg = message?.trim() ? errMsg : undefined}
124
124
  {#if action}
125
125
  <select bind:value bind:this={element} class={c} {id} {oninvalid} {...attrs} aria-describedby={idDesc} aria-invalid={invalid} aria-errormessage={msg} use:action>
126
126
  {@render option()}
@@ -137,7 +137,7 @@
137
137
  {/each}
138
138
  {/snippet}
139
139
  {#snippet desc(show: boolean)}
140
- {#if show && bottom?.trim()}
141
- <div class={cls(AREA.BOTTOM, status)} id={idDesc ?? idErr} role={live}>{bottom}</div>
140
+ {#if show && message?.trim()}
141
+ <div class={cls(AREA.BOTTOM, status)} id={idDesc ?? idErr} role={live}>{message}</div>
142
142
  {/if}
143
143
  {/snippet}
@@ -16,12 +16,12 @@ export type SelectFieldProps = {
16
16
  element?: HTMLSelectElement;
17
17
  };
18
18
  export type SelectFieldReqdProps = "options";
19
- export type SelectFieldBindProps = "bottom" | "value" | "status" | "element";
19
+ export type SelectFieldBindProps = "value" | "status" | "element";
20
20
  import { type Snippet } from "svelte";
21
21
  import { type Action } from "svelte/action";
22
22
  import { type SvelteMap } from "svelte/reactivity";
23
23
  import { type HTMLSelectAttributes } from "svelte/elements";
24
24
  import { type ClassRuleSet } from "./core";
25
- declare const SelectField: import("svelte").Component<SelectFieldProps, {}, "bottom" | "value" | "status" | "element">;
25
+ declare const SelectField: import("svelte").Component<SelectFieldProps, {}, "value" | "status" | "element">;
26
26
  type SelectField = ReturnType<typeof SelectField>;
27
27
  export default SelectField;
@@ -5,7 +5,7 @@
5
5
  aux?: Snippet<[string, string, HTMLInputElement | HTMLTextAreaElement | undefined]>, // Snippet<[status,value,element]>
6
6
  left?: Snippet<[string, string, HTMLInputElement | HTMLTextAreaElement | undefined]>, // Snippet<[status,value,element]>
7
7
  right?: Snippet<[string, string, HTMLInputElement | HTMLTextAreaElement | undefined]>, // Snippet<[status,value,element]>
8
- bottom?: string, // bindable
8
+ bottom?: string,
9
9
  value?: string, // bindable
10
10
  type?: "text" | "area" | "email" | "password" | "search" | "tel" | "url" | "number", // bindable <"text">
11
11
  options?: SvelteSet<string> | Set<string>,
@@ -18,7 +18,7 @@
18
18
  element?: HTMLInputElement | HTMLTextAreaElement, // bindable
19
19
  };
20
20
  export type TextFieldReqdProps = never;
21
- export type TextFieldBindProps = "bottom" | "value" | "type" | "status" | "element";
21
+ export type TextFieldBindProps = "value" | "type" | "status" | "element";
22
22
 
23
23
  const svs = "svs-text-field";
24
24
  const preset: ClassRuleSet = {};
@@ -31,7 +31,7 @@
31
31
  </script>
32
32
 
33
33
  <script lang="ts">
34
- let { label, extra, aux, left, right, bottom = $bindable(), value = $bindable(""), type = $bindable("text"), options, descFirst = false, validations = [], status = $bindable(""), style, attributes, action, element = $bindable() }: TextFieldProps = $props();
34
+ let { label, extra, aux, left, right, bottom, value = $bindable(""), type = $bindable("text"), options, descFirst = false, validations = [], status = $bindable(""), style, attributes, action, element = $bindable() }: TextFieldProps = $props();
35
35
 
36
36
  // *** Initialize *** //
37
37
  if (!status) status = STATE.DEFAULT;
@@ -42,7 +42,7 @@
42
42
  const idList = elemId.get(options?.size);
43
43
  const idErr = idDesc ?? elemId.id;
44
44
  const attrs = omit(attributes as any, "class", "id", "type", "value", "list", "onchange", "oninvalid");
45
- const description = bottom;
45
+ let message = $state(bottom);
46
46
 
47
47
  // *** Status *** //
48
48
  let neutral = isNeutral(status) ? status : STATE.DEFAULT;
@@ -54,7 +54,7 @@
54
54
  const toNonInvalid = (stat: string) => shiftStatus(stat);
55
55
  function shiftStatus(stat: string, msg?: string) {
56
56
  status = stat;
57
- bottom = msg ?? description;
57
+ message = msg ?? bottom;
58
58
  element?.setCustomValidity(msg ?? "");
59
59
  }
60
60
  function validate(onchange?: boolean) {
@@ -126,7 +126,7 @@
126
126
  {/snippet}
127
127
  {#snippet main()}
128
128
  {@const c = cls(AREA.MAIN, status)}
129
- {@const msg = bottom?.trim() ? errMsg : undefined}
129
+ {@const msg = message?.trim() ? errMsg : undefined}
130
130
  {#if type === "area"}
131
131
  {#if action}
132
132
  <textarea bind:value bind:this={element} class={c} {id} {onchange} {oninvalid} {...attrs} aria-describedby={idDesc} aria-invalid={invalid} aria-errormessage={msg} use:action></textarea>
@@ -149,7 +149,7 @@
149
149
  {/if}
150
150
  {/snippet}
151
151
  {#snippet desc(show: boolean)}
152
- {#if show && bottom?.trim()}
153
- <div class={cls(AREA.BOTTOM, status)} id={idDesc ?? idErr} role={live}>{bottom}</div>
152
+ {#if show && message?.trim()}
153
+ <div class={cls(AREA.BOTTOM, status)} id={idDesc ?? idErr} role={live}>{message}</div>
154
154
  {/if}
155
155
  {/snippet}
@@ -17,12 +17,12 @@ export type TextFieldProps = {
17
17
  element?: HTMLInputElement | HTMLTextAreaElement;
18
18
  };
19
19
  export type TextFieldReqdProps = never;
20
- export type TextFieldBindProps = "bottom" | "value" | "type" | "status" | "element";
20
+ export type TextFieldBindProps = "value" | "type" | "status" | "element";
21
21
  import { type Snippet } from "svelte";
22
22
  import { type Action } from "svelte/action";
23
23
  import { type SvelteSet } from "svelte/reactivity";
24
24
  import { type HTMLInputAttributes, type HTMLTextareaAttributes } from "svelte/elements";
25
25
  import { type ClassRuleSet } from "./core";
26
- declare const TextField: import("svelte").Component<TextFieldProps, {}, "type" | "bottom" | "value" | "status" | "element">;
26
+ declare const TextField: import("svelte").Component<TextFieldProps, {}, "type" | "value" | "status" | "element">;
27
27
  type TextField = ReturnType<typeof TextField>;
28
28
  export default TextField;
@@ -4,7 +4,7 @@
4
4
  label?: string,
5
5
  extra?: string,
6
6
  aux?: Snippet<[string, string[], HTMLButtonElement[] | undefined]>, // Snippet<[status,values,elements]>
7
- bottom?: string, // bindable
7
+ bottom?: string,
8
8
  values?: string[], // bindable
9
9
  multiple?: boolean, // <true>
10
10
  descFirst?: boolean, // <false>
@@ -16,7 +16,7 @@
16
16
  elements?: HTMLButtonElement[], // bindable
17
17
  };
18
18
  export type TogglesFieldReqdProps = "options";
19
- export type TogglesFieldBindProps = "bottom" | "values" | "status" | "elements";
19
+ export type TogglesFieldBindProps = "values" | "status" | "elements";
20
20
 
21
21
  type TogglesFieldTarget = { currentTarget: EventTarget & HTMLButtonElement };
22
22
  const svs = "svs-toggles-field";
@@ -30,7 +30,7 @@
30
30
  </script>
31
31
 
32
32
  <script lang="ts">
33
- let { options, label, extra, aux, bottom = $bindable(), values = $bindable([]), multiple = true, descFirst = false, validations = [], status = $bindable(""), style, attributes, action, elements = $bindable([]) }: TogglesFieldProps = $props();
33
+ let { options, label, extra, aux, bottom, values = $bindable([]), multiple = true, descFirst = false, validations = [], status = $bindable(""), style, attributes, action, elements = $bindable([]) }: TogglesFieldProps = $props();
34
34
 
35
35
  // *** Initialize *** //
36
36
  if (!status) status = STATE.DEFAULT;
@@ -41,7 +41,7 @@
41
41
  const idErr = idDesc ?? elemId.id;
42
42
  const attrs = omit(attributes, "class", "id", "type", "role", "aria-checked", "onclick", "oninvalid");
43
43
  const roleGroup = multiple ? "group" : "radiogroup";
44
- const description = bottom;
44
+ let message = $state(bottom);
45
45
  let elem: HTMLInputElement | undefined = $state();
46
46
 
47
47
  // *** Status *** //
@@ -55,7 +55,7 @@
55
55
  const toNonInvalid = () => shiftStatus(phase.change && values.length ? STATE.ACTIVE : neutral);
56
56
  function shiftStatus(stat: string, msg?: string) {
57
57
  status = stat;
58
- bottom = stat === STATE.INACTIVE ? msg ?? description : description;
58
+ message = stat === STATE.INACTIVE ? msg ?? bottom : bottom;
59
59
  elem?.setCustomValidity(msg ?? "");
60
60
  }
61
61
  function validate() {
@@ -123,7 +123,7 @@
123
123
  {#snippet main()}
124
124
  {@const c = cls(AREA.MAIN, status)}
125
125
  <input bind:this={elem} style="display: none;" aria-hidden="true" {oninvalid} />
126
- <div class={cls(AREA.MIDDLE, status)} role={roleGroup} aria-describedby={idDesc} aria-invalid={!multiple ? invalid : undefined} aria-errormessage={!multiple && bottom?.trim() ? errMsg : undefined}>
126
+ <div class={cls(AREA.MIDDLE, status)} role={roleGroup} aria-describedby={idDesc} aria-invalid={!multiple ? invalid : undefined} aria-errormessage={!multiple && message?.trim() ? errMsg : undefined}>
127
127
  {#each opts as { value, text, checked }, i (value)}
128
128
  {#if action}
129
129
  <button bind:this={elements[i]} class={c} aria-checked={checked} aria-invalid={multiple ? invalid : undefined} onclick={updateValues(value)} type="button" {role} {...attrs} use:action>
@@ -138,7 +138,7 @@
138
138
  </div>
139
139
  {/snippet}
140
140
  {#snippet desc(show: boolean)}
141
- {#if show && bottom?.trim()}
142
- <div class={cls(AREA.BOTTOM, status)} id={idDesc ?? idErr} role={live}>{bottom}</div>
141
+ {#if show && message?.trim()}
142
+ <div class={cls(AREA.BOTTOM, status)} id={idDesc ?? idErr} role={live}>{message}</div>
143
143
  {/if}
144
144
  {/snippet}
@@ -15,12 +15,12 @@ export type TogglesFieldProps = {
15
15
  elements?: HTMLButtonElement[];
16
16
  };
17
17
  export type TogglesFieldReqdProps = "options";
18
- export type TogglesFieldBindProps = "bottom" | "values" | "status" | "elements";
18
+ export type TogglesFieldBindProps = "values" | "status" | "elements";
19
19
  import { type Snippet } from "svelte";
20
20
  import { type Action } from "svelte/action";
21
21
  import { type SvelteMap } from "svelte/reactivity";
22
22
  import { type HTMLButtonAttributes } from "svelte/elements";
23
23
  import { type ClassRuleSet } from "./core";
24
- declare const TogglesField: import("svelte").Component<TogglesFieldProps, {}, "bottom" | "elements" | "status" | "values">;
24
+ declare const TogglesField: import("svelte").Component<TogglesFieldProps, {}, "elements" | "status" | "values">;
25
25
  type TogglesField = ReturnType<typeof TogglesField>;
26
26
  export default TogglesField;
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { type ClassRuleSet, type ThemePreset, CONST, STATE, AREA, elemId, theme, fnClass, isNeutral, omit, debounce, throttle, UniqueId } from "./_svseeds/core";
1
+ export { type ClassRuleSet, type ThemePreset, CONST, STATE, AREA, elemId, fnClass, isNeutral, omit, debounce, throttle, UniqueId } from "./_svseeds/core";
2
2
  export { default as Accordion, type AccordionProps, type AccordionReqdProps, type AccordionBindProps, type AccordionDeps } from "./_svseeds/Accordion.svelte";
3
3
  export { default as Badge, type BadgeProps, type BadgeReqdProps, type BadgeBindProps } from "./_svseeds/_Badge.svelte";
4
4
  export { default as Button, type ButtonProps, type ButtonReqdProps, type ButtonBindProps } from "./_svseeds/_Button.svelte";
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { CONST, STATE, AREA, elemId, theme, fnClass, isNeutral, omit, debounce, throttle, UniqueId } from "./_svseeds/core";
1
+ export { CONST, STATE, AREA, elemId, fnClass, isNeutral, omit, debounce, throttle, UniqueId } from "./_svseeds/core";
2
2
  export { default as Accordion } from "./_svseeds/Accordion.svelte";
3
3
  export { default as Badge } from "./_svseeds/_Badge.svelte";
4
4
  export { default as Button } from "./_svseeds/_Button.svelte";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svseeds",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Simple headless components for Svelte.",
5
5
  "type": "module",
6
6
  "main": "./index.js",