svseeds 0.1.0 → 0.1.1

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
@@ -1,4 +1,4 @@
1
- # SvSeeds - Simple Headless Components for Svelte
1
+ # SvSeeds - Simple Components for Svelte
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/svseeds)](https://www.npmjs.com/package/svseeds)
4
4
  [![JSR](https://jsr.io/badges/@svseeds/ui)](https://jsr.io/@svseeds/ui)
@@ -25,7 +25,7 @@
25
25
  .toSorted((x,y) => x.localeCompare(y));
26
26
  }
27
27
  function toNamedId(names: string[]): NamedId[] {
28
- return names.map((x) => ({ id: elemId.get(true)!, name: x }));
28
+ return names.map((x) => ({ id: elemId.id, name: x }));
29
29
  }
30
30
 
31
31
  import { type Snippet, untrack } from "svelte";
@@ -36,10 +36,10 @@
36
36
  if (!status) status = STATE.DEFAULT;
37
37
  const cls = fnClass(svs, preset, style);
38
38
  const type = multiple ? "checkbox" : "radio";
39
- const name = attributes?.["name"] ? attributes?.["name"] : elemId.get(true);
39
+ const name = attributes?.["name"] ? attributes?.["name"] : elemId.id;
40
40
  const idLabel = elemId.get(label?.trim());
41
41
  const idDesc = elemId.get(bottom?.trim());
42
- const idErr = idDesc ?? elemId.get(true);
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
45
  const description = bottom;
@@ -48,7 +48,7 @@
48
48
  const phase = { change: false, submit: false };
49
49
  let neutral = isNeutral(status) ? status : STATE.DEFAULT;
50
50
  $effect(() => { neutral = isNeutral(status) ? status : neutral });
51
- let alert = $derived(status === STATE.INACTIVE ? "alert" : undefined);
51
+ let live = $derived(status === STATE.INACTIVE ? "alert" : "status");
52
52
  let invalid = $derived(status === STATE.INACTIVE ? true : undefined);
53
53
  let errMsg = $derived(status === STATE.INACTIVE ? idErr : undefined);
54
54
  const toInvalid = (msg?: string) => shiftStatus(phase.submit ? STATE.INACTIVE : neutral, msg);
@@ -92,23 +92,19 @@
92
92
  <!---------------------------------------->
93
93
 
94
94
  {#if opts.length}
95
- {#if label?.trim() || aux || bottom?.trim()}
96
- <div class={cls(AREA.WHOLE, status)} role="group" aria-labelledby={idLabel}>
97
- {#if aux}
98
- <div class={cls(AREA.TOP, status)}>
99
- {@render lbl()}
100
- <span class={cls(AREA.AUX, status)}>{@render aux(status, values, elements)}</span>
101
- </div>
102
- {:else}
95
+ <div class={cls(AREA.WHOLE, status)} role="group" aria-labelledby={idLabel}>
96
+ {#if aux}
97
+ <div class={cls(AREA.TOP, status)}>
103
98
  {@render lbl()}
104
- {/if}
105
- {@render desc(descFirst)}
106
- {@render main()}
107
- {@render desc(!descFirst)}
108
- </div>
109
- {:else}
99
+ <span class={cls(AREA.AUX, status)}>{@render aux(status, values, elements)}</span>
100
+ </div>
101
+ {:else}
102
+ {@render lbl()}
103
+ {/if}
104
+ {@render desc(descFirst)}
110
105
  {@render main()}
111
- {/if}
106
+ {@render desc(!descFirst)}
107
+ </div>
112
108
  {/if}
113
109
 
114
110
  {#snippet lbl()}
@@ -137,6 +133,6 @@
137
133
  {/snippet}
138
134
  {#snippet desc(show: boolean)}
139
135
  {#if show && bottom?.trim()}
140
- <div class={cls(AREA.BOTTOM, status)} id={idDesc ?? idErr} role={alert}>{bottom}</div>
136
+ <div class={cls(AREA.BOTTOM, status)} id={idDesc ?? idErr} role={live}>{bottom}</div>
141
137
  {/if}
142
138
  {/snippet}
@@ -30,7 +30,7 @@
30
30
  // *** Initialize *** //
31
31
  if (!status) status = STATE.DEFAULT;
32
32
  const cls = fnClass(svs, preset, style);
33
- const idList = elemId.get(true);
33
+ const idList = elemId.id;
34
34
  const attrs = omit(attributes, "class", "type", "value", "list", "role", "aria-haspopup", "aria-autocomplete", "aria-controls", "aria-expanded");
35
35
  let selected = $state(NA);
36
36
  let overflow = $state({x: false, y: false});
@@ -39,14 +39,14 @@
39
39
  const id = attributes?.id ? attributes.id : elemId.get(label?.trim());
40
40
  const idLabel = elemId.get(label?.trim());
41
41
  const idDesc = elemId.get(bottom?.trim());
42
- const idErr = idDesc ?? elemId.get(true);
42
+ const idErr = idDesc ?? elemId.id;
43
43
  const attrs = omit(attributes, "class", "id", "value", "oninvalid");
44
44
  const description = bottom;
45
45
 
46
46
  // *** Status *** //
47
47
  let neutral = isNeutral(status) ? status : STATE.DEFAULT;
48
48
  $effect(() => { neutral = isNeutral(status) ? status : neutral });
49
- let alert = $derived(status === STATE.INACTIVE ? "alert" : undefined);
49
+ let live = $derived(status === STATE.INACTIVE ? "alert" : "status");
50
50
  let invalid = $derived(status === STATE.INACTIVE ? true : undefined);
51
51
  let errMsg = $derived(status === STATE.INACTIVE ? idErr : undefined);
52
52
  const toInvalid = (msg?: string) => shiftStatus(STATE.INACTIVE, msg);
@@ -84,27 +84,23 @@
84
84
  <!---------------------------------------->
85
85
 
86
86
  {#if opts.length}
87
- {#if label?.trim() || aux || left || right || bottom?.trim()}
88
- <div class={cls(AREA.WHOLE, status)} role="group" aria-labelledby={idLabel}>
89
- {#if aux}
90
- <div class={cls(AREA.TOP, status)}>
91
- {@render lbl()}
92
- <span class={cls(AREA.AUX, status)}>{@render aux(status, value, element)}</span>
93
- </div>
94
- {:else}
87
+ <div class={cls(AREA.WHOLE, status)} role="group" aria-labelledby={idLabel}>
88
+ {#if aux}
89
+ <div class={cls(AREA.TOP, status)}>
95
90
  {@render lbl()}
96
- {/if}
97
- {@render desc(descFirst)}
98
- <div class={cls(AREA.MIDDLE, status)}>
99
- {@render side(AREA.LEFT, left)}
100
- {@render main()}
101
- {@render side(AREA.RIGHT, right)}
91
+ <span class={cls(AREA.AUX, status)}>{@render aux(status, value, element)}</span>
102
92
  </div>
103
- {@render desc(!descFirst)}
93
+ {:else}
94
+ {@render lbl()}
95
+ {/if}
96
+ {@render desc(descFirst)}
97
+ <div class={cls(AREA.MIDDLE, status)}>
98
+ {@render side(AREA.LEFT, left)}
99
+ {@render main()}
100
+ {@render side(AREA.RIGHT, right)}
104
101
  </div>
105
- {:else}
106
- {@render main()}
107
- {/if}
102
+ {@render desc(!descFirst)}
103
+ </div>
108
104
  {/if}
109
105
 
110
106
  {#snippet lbl()}
@@ -142,6 +138,6 @@
142
138
  {/snippet}
143
139
  {#snippet desc(show: boolean)}
144
140
  {#if show && bottom?.trim()}
145
- <div class={cls(AREA.BOTTOM, status)} id={idDesc ?? idErr} role={alert}>{bottom}</div>
141
+ <div class={cls(AREA.BOTTOM, status)} id={idDesc ?? idErr} role={live}>{bottom}</div>
146
142
  {/if}
147
143
  {/snippet}
@@ -22,7 +22,7 @@
22
22
  .toSorted((x,y) => x.localeCompare(y));
23
23
  }
24
24
  function toNamedId(names: string[]): NamedId[] {
25
- return names.map((x) => ({ id: elemId.get(true)!, name: x }));
25
+ return names.map((x) => ({ id: elemId.id, name: x }));
26
26
  }
27
27
  function correctCurrent(active: number, labels: string[]): number {
28
28
  if (active <= 0) return 0;
@@ -40,14 +40,14 @@
40
40
  const idLabel = elemId.get(label?.trim());
41
41
  const idDesc = elemId.get(bottom?.trim());
42
42
  const idList = elemId.get(options?.size);
43
- const idErr = idDesc ?? elemId.get(true);
43
+ const idErr = idDesc ?? elemId.id;
44
44
  const attrs = omit(attributes as any, "class", "id", "type", "value", "list", "onchange", "oninvalid");
45
45
  const description = bottom;
46
46
 
47
47
  // *** Status *** //
48
48
  let neutral = isNeutral(status) ? status : STATE.DEFAULT;
49
49
  $effect(() => { neutral = isNeutral(status) ? status : neutral });
50
- let alert = $derived(status === STATE.INACTIVE ? "alert" : undefined);
50
+ let live = $derived(status === STATE.INACTIVE ? "alert" : "status");
51
51
  let invalid = $derived(status === STATE.INACTIVE ? true : undefined);
52
52
  let errMsg = $derived(status === STATE.INACTIVE ? idErr : undefined);
53
53
  const toInvalid = (msg?: string) => shiftStatus(STATE.INACTIVE, msg);
@@ -91,27 +91,23 @@
91
91
 
92
92
  <!---------------------------------------->
93
93
 
94
- {#if label?.trim() || aux || left || right || bottom?.trim()}
95
- <div class={cls(AREA.WHOLE, status)} role="group" aria-labelledby={idLabel}>
96
- {#if aux}
97
- <div class={cls(AREA.TOP, status)}>
98
- {@render lbl()}
99
- <span class={cls(AREA.AUX, status)}>{@render aux(status, value, element)}</span>
100
- </div>
101
- {:else}
94
+ <div class={cls(AREA.WHOLE, status)} role="group" aria-labelledby={idLabel}>
95
+ {#if aux}
96
+ <div class={cls(AREA.TOP, status)}>
102
97
  {@render lbl()}
103
- {/if}
104
- {@render desc(descFirst)}
105
- <div class={cls(AREA.MIDDLE, status)}>
106
- {@render side(AREA.LEFT, left)}
107
- {@render main()}
108
- {@render side(AREA.RIGHT, right)}
98
+ <span class={cls(AREA.AUX, status)}>{@render aux(status, value, element)}</span>
109
99
  </div>
110
- {@render desc(!descFirst)}
100
+ {:else}
101
+ {@render lbl()}
102
+ {/if}
103
+ {@render desc(descFirst)}
104
+ <div class={cls(AREA.MIDDLE, status)}>
105
+ {@render side(AREA.LEFT, left)}
106
+ {@render main()}
107
+ {@render side(AREA.RIGHT, right)}
111
108
  </div>
112
- {:else}
113
- {@render main()}
114
- {/if}
109
+ {@render desc(!descFirst)}
110
+ </div>
115
111
 
116
112
  {#snippet lbl()}
117
113
  {#if label?.trim()}
@@ -154,6 +150,6 @@
154
150
  {/snippet}
155
151
  {#snippet desc(show: boolean)}
156
152
  {#if show && bottom?.trim()}
157
- <div class={cls(AREA.BOTTOM, status)} id={idDesc ?? idErr} role={alert}>{bottom}</div>
153
+ <div class={cls(AREA.BOTTOM, status)} id={idDesc ?? idErr} role={live}>{bottom}</div>
158
154
  {/if}
159
155
  {/snippet}
@@ -38,7 +38,7 @@
38
38
  const role = multiple ? "checkbox" : "radio";
39
39
  const idLabel = elemId.get(label?.trim());
40
40
  const idDesc = elemId.get(bottom?.trim());
41
- const idErr = idDesc ?? elemId.get(true);
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
44
  const description = bottom;
@@ -48,7 +48,7 @@
48
48
  const phase = { change: false, submit: false };
49
49
  let neutral = isNeutral(status) ? status : STATE.DEFAULT;
50
50
  $effect(() => { neutral = isNeutral(status) ? status : neutral });
51
- let alert = $derived(status === STATE.INACTIVE ? "alert" : undefined);
51
+ let live = $derived(status === STATE.INACTIVE ? "alert" : "status");
52
52
  let invalid = $derived(status === STATE.INACTIVE ? true : undefined);
53
53
  let errMsg = $derived(status === STATE.INACTIVE ? idErr : undefined);
54
54
  const toInvalid = (msg?: string) => shiftStatus(phase.submit ? STATE.INACTIVE : neutral, msg);
@@ -95,23 +95,19 @@
95
95
  <!---------------------------------------->
96
96
 
97
97
  {#if opts.length}
98
- {#if label?.trim() || aux || bottom?.trim()}
99
- <div class={cls(AREA.WHOLE, status)} role="group" aria-labelledby={idLabel}>
100
- {#if aux}
101
- <div class={cls(AREA.TOP, status)}>
102
- {@render lbl()}
103
- <span class={cls(AREA.AUX, status)}>{@render aux(status, values, elements)}</span>
104
- </div>
105
- {:else}
98
+ <div class={cls(AREA.WHOLE, status)} role="group" aria-labelledby={idLabel}>
99
+ {#if aux}
100
+ <div class={cls(AREA.TOP, status)}>
106
101
  {@render lbl()}
107
- {/if}
108
- {@render desc(descFirst)}
109
- {@render main()}
110
- {@render desc(!descFirst)}
111
- </div>
112
- {:else}
102
+ <span class={cls(AREA.AUX, status)}>{@render aux(status, values, elements)}</span>
103
+ </div>
104
+ {:else}
105
+ {@render lbl()}
106
+ {/if}
107
+ {@render desc(descFirst)}
113
108
  {@render main()}
114
- {/if}
109
+ {@render desc(!descFirst)}
110
+ </div>
115
111
  {/if}
116
112
 
117
113
  {#snippet lbl()}
@@ -143,6 +139,6 @@
143
139
  {/snippet}
144
140
  {#snippet desc(show: boolean)}
145
141
  {#if show && bottom?.trim()}
146
- <div class={cls(AREA.BOTTOM, status)} id={idDesc ?? idErr} role={alert}>{bottom}</div>
142
+ <div class={cls(AREA.BOTTOM, status)} id={idDesc ?? idErr} role={live}>{bottom}</div>
147
143
  {/if}
148
144
  {/snippet}
@@ -118,7 +118,7 @@
118
118
  if (this.#ids.has(id)) this.#current = id;
119
119
  }
120
120
  register(name?: string): string {
121
- const id = name ? name : elemId.get(true)!;
121
+ const id = name ? name : elemId.id;
122
122
  if (this.#ids.has(id)) return "";
123
123
  if (!this.#default) this.#default = id;
124
124
  this.#ids.add(id);
@@ -1,9 +1,9 @@
1
- export { type ClassRuleSet, type ThemePreset, CONST, STATE, AREA, elemId, theme, fnClass, isNeutral, omit, debounce, throttle, };
1
+ export { type ClassRuleSet, type ThemePreset, CONST, STATE, AREA, elemId, theme, fnClass, isNeutral, omit, debounce, throttle, UniqueId, };
2
2
  type ClassRule = Partial<Record<string, string>>;
3
3
  type ClassRuleSet = Partial<Record<string, ClassRule>>;
4
4
  type CssVarSet = Record<string, string>;
5
5
  type ThemePreset = Record<string, CssVarSet>;
6
- declare const CONST = "constant";
6
+ declare const CONST = "const";
7
7
  declare const STATE: Readonly<{
8
8
  DEFAULT: "default";
9
9
  ACTIVE: "active";
@@ -21,8 +21,10 @@ declare const AREA: Readonly<{
21
21
  AUX: "aux";
22
22
  EXTRA: "extra";
23
23
  }>;
24
- declare class RandomId {
24
+ declare class UniqueId {
25
25
  #private;
26
+ get id(): string;
27
+ constructor(len?: number);
26
28
  get(v: unknown): string | undefined;
27
29
  }
28
30
  declare class ThemeSwitcher {
@@ -34,7 +36,7 @@ declare class ThemeSwitcher {
34
36
  toDark(): void;
35
37
  switch(theme: string): void;
36
38
  }
37
- declare const elemId: RandomId;
39
+ declare const elemId: UniqueId;
38
40
  declare const theme: ThemeSwitcher;
39
41
  type ClassFn = (area: string, status: string) => string | undefined;
40
42
  declare function fnClass(name: string, preset: ClassRuleSet, style?: ClassRuleSet | string): ClassFn;
package/_svseeds/core.js CHANGED
@@ -1 +1 @@
1
- var t=this&&this.__assign||function(){return t=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},t.apply(this,arguments)},e=this&&this.__classPrivateFieldGet||function(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)},n=this&&this.__classPrivateFieldSet||function(t,e,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(t,n):i?i.value=n:e.set(t,n),n},r=this&&this.__spreadArray||function(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))};export{i as CONST,o as STATE,a as AREA,f as elemId,l as theme,s as fnClass,h as isNeutral,d as omit,v as debounce,p as throttle};var i="constant",o=Object.freeze({DEFAULT:"default",ACTIVE:"active",INACTIVE:"inactive"}),a=Object.freeze({WHOLE:"whole",MIDDLE:"middle",MAIN:"main",TOP:"top",LEFT:"left",RIGHT:"right",BOTTOM:"bottom",LABEL:"label",AUX:"aux",EXTRA:"extra"}),c=function(){function t(){n.add(this),a.set(this,new Set)}var n,i,o,a,c,u,f;return t.prototype.get=function(t){if(t)return e(this,a,"f").size>1e4&&e(this,a,"f").clear(),e(this,n,"m",f).call(this)},i=t,a=new WeakMap,n=new WeakSet,c=function(){return e(i,i,"f",o)[Math.trunc(Math.random()*e(i,i,"f",o).length)]},u=function(){var t=this;return String.fromCharCode.apply(String,r(r([],Array(4).fill(null).map((function(){return e(t,n,"m",c).call(t)})),!1),[58],!1))},f=function(){for(var t=e(this,n,"m",u).call(this);e(this,a,"f").has(t);)t=e(this,n,"m",u).call(this);return e(this,a,"f").add(t),t},o={value:r(r([],Array.from(Array(25).keys(),(function(t){return t+65})),!0),Array.from(Array(25).keys(),(function(t){return t+97})),!0)},t}(),u=function(){function t(){r.add(this),c.set(this,new Map),u.set(this,void 0),n(this,u,e(i,i,"m",d).call(i),"f")}var r,i,o,a,c,u,f,l,s,h,d;return Object.defineProperty(t.prototype,"current",{get:function(){return e(this,u,"f")},enumerable:!1,configurable:!0}),t.prototype.setPreset=function(t){return e(this,r,"m",s).call(this,t),e(this,r,"m",l).call(this),this},t.prototype.toLight=function(){this.switch(e(i,i,"f",a))},t.prototype.toDark=function(){this.switch(e(i,i,"f",o))},t.prototype.switch=function(t){e(this,c,"f").has(t)&&(n(this,u,t,"f"),e(this,r,"m",f).call(this))},i=t,c=new WeakMap,u=new WeakMap,r=new WeakSet,f=function(){var t;if("undefined"!=typeof window){var n=window.document.body.style;Object.entries(null!==(t=e(this,c,"f").get(e(this,u,"f")))&&void 0!==t?t:{}).forEach((function(t){var e=t[0],r=t[1];return n.setProperty(e,r)}))}},l=function(){if("undefined"!=typeof window){var t=Object.keys(e(this,c,"f")).filter((function(t){return t===e(i,i,"f",a)||t===e(i,i,"f",o)}));window.document.documentElement.style.colorScheme=t.join(" ")}},s=function(t){var n=this;Object.entries(t).forEach((function(t){var r=t[0],o=t[1];return e(n,c,"f").set(r,e(i,i,"m",h).call(i,o))}))},h=function(t){return Object.fromEntries(Object.entries(t).map((function(t){var e=t[0],n=t[1];return["--".concat(e.replaceAll("_","-")),n]})))},d=function(){return"undefined"==typeof window||window.matchMedia("(prefers-color-scheme: light)").matches?e(i,i,"f",a):e(i,i,"f",o)},o={value:"dark"},a={value:"light"},t}(),f=new c,l=new u;function s(e,n,i){var a=function(e,n,i){if("string"==typeof i)return i.trim()?i:e;var o=function(e,n){var i=Object.keys(e);if(i.length<=0)return n;var o=Object.keys(n);if(o.length<=0)return e;var a={};return new Set(r(r([],i,!0),o,!0)).forEach((function(r){var i,o;a[r]=t(t({},null!==(i=e[r])&&void 0!==i?i:{}),null!==(o=n[r])&&void 0!==o?o:{})})),a}(n,i);return Object.keys(o).length<=0?e:o}(e,n,null!=i?i:{});return"string"==typeof a?function(t,e){return function(t,e,n){return"".concat(t," ").concat(e).concat(n===o.DEFAULT?"":" ".concat(n))}(a,t,e)}:function(t,e){return function(t,e,n){var r,i,o,a,c,u,f=null!==(i=null===(r=t[e])||void 0===r?void 0:r.constant)&&void 0!==i?i:"",l=null!==(u=null!==(a=null===(o=t[e])||void 0===o?void 0:o[n])&&void 0!==a?a:null===(c=t[e])||void 0===c?void 0:c.default)&&void 0!==u?u:"";return""===f&&""===l?void 0:"".concat(f).concat(f&&l?" ":"").concat(l)}(a,t,e)}}function h(t){return t!==o.ACTIVE&&t!==o.INACTIVE}function d(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];if(!e)return{};var i=t({},e);return n.forEach((function(t){return delete i[t]})),i}function v(t,e){var n;return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];n&&clearTimeout(n),n=setTimeout((function(){e.call.apply(e,r([null],i,!1))}),t)}}function p(t,e){var n,i=0,o=function(){return Date.now()-i},a=function(t){e.call.apply(e,r([null],t,!1)),i=Date.now()};return function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];if(!i)return a(e);clearTimeout(n),n=setTimeout((function(){o()>=t&&a(e)}),t-o())}}
1
+ var t=this&&this.__assign||function(){return t=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},t.apply(this,arguments)},e=this&&this.__classPrivateFieldSet||function(t,e,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(t,n):i?i.value=n:e.set(t,n),n},n=this&&this.__classPrivateFieldGet||function(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)},r=this&&this.__spreadArray||function(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))};export{i as CONST,o as STATE,a as AREA,f as elemId,l as theme,s as fnClass,h as isNeutral,d as omit,p as debounce,v as throttle,c as UniqueId};var i="const",o=Object.freeze({DEFAULT:"default",ACTIVE:"active",INACTIVE:"inactive"}),a=Object.freeze({WHOLE:"whole",MIDDLE:"middle",MAIN:"main",TOP:"top",LEFT:"left",RIGHT:"right",BOTTOM:"bottom",LABEL:"label",AUX:"aux",EXTRA:"extra"}),c=function(){function t(t){void 0===t&&(t=4),i.add(this),c.set(this,new Set),u.set(this,4),t>2&&e(this,u,t,"f")}var i,o,a,c,u,f,l,s;return Object.defineProperty(t.prototype,"id",{get:function(){return this.get(!0)},enumerable:!1,configurable:!0}),t.prototype.get=function(t){if(t)return n(this,c,"f").size>1e4&&n(this,c,"f").clear(),n(this,i,"m",s).call(this)},o=t,c=new WeakMap,u=new WeakMap,i=new WeakSet,f=function(){return n(o,o,"f",a)[Math.trunc(Math.random()*n(o,o,"f",a).length)]},l=function(){var t=this;return String.fromCharCode.apply(String,Array(n(this,u,"f")).fill(null).map((function(){return n(t,i,"m",f).call(t)})))},s=function(){for(var t=n(this,i,"m",l).call(this);n(this,c,"f").has(t);)t=n(this,i,"m",l).call(this);return n(this,c,"f").add(t),t},a={value:r(r([],Array.from(Array(25).keys(),(function(t){return t+65})),!0),Array.from(Array(25).keys(),(function(t){return t+97})),!0)},t}(),u=function(){function t(){r.add(this),c.set(this,new Map),u.set(this,void 0),e(this,u,n(i,i,"m",d).call(i),"f")}var r,i,o,a,c,u,f,l,s,h,d;return Object.defineProperty(t.prototype,"current",{get:function(){return n(this,u,"f")},enumerable:!1,configurable:!0}),t.prototype.setPreset=function(t){return n(this,r,"m",s).call(this,t),n(this,r,"m",l).call(this),this},t.prototype.toLight=function(){this.switch(n(i,i,"f",a))},t.prototype.toDark=function(){this.switch(n(i,i,"f",o))},t.prototype.switch=function(t){n(this,c,"f").has(t)&&(e(this,u,t,"f"),n(this,r,"m",f).call(this))},i=t,c=new WeakMap,u=new WeakMap,r=new WeakSet,f=function(){var t;if("undefined"!=typeof window){var e=window.document.body.style;Object.entries(null!==(t=n(this,c,"f").get(n(this,u,"f")))&&void 0!==t?t:{}).forEach((function(t){var n=t[0],r=t[1];return e.setProperty(n,r)}))}},l=function(){if("undefined"!=typeof window){var t=Object.keys(n(this,c,"f")).filter((function(t){return t===n(i,i,"f",a)||t===n(i,i,"f",o)}));window.document.documentElement.style.colorScheme=t.join(" ")}},s=function(t){var e=this;Object.entries(t).forEach((function(t){var r=t[0],o=t[1];return n(e,c,"f").set(r,n(i,i,"m",h).call(i,o))}))},h=function(t){return Object.fromEntries(Object.entries(t).map((function(t){var e=t[0],n=t[1];return["--".concat(e.replaceAll("_","-")),n]})))},d=function(){return"undefined"==typeof window||window.matchMedia("(prefers-color-scheme: light)").matches?n(i,i,"f",a):n(i,i,"f",o)},o={value:"dark"},a={value:"light"},t}(),f=new c,l=new u;function s(e,n,a){var c=function(e,n,i){if("string"==typeof i)return i.trim()?i:e;var o=function(e,n){var i=Object.keys(e);if(i.length<=0)return n;var o=Object.keys(n);if(o.length<=0)return e;var a={};return new Set(r(r([],i,!0),o,!0)).forEach((function(r){var i,o;a[r]=t(t({},null!==(i=e[r])&&void 0!==i?i:{}),null!==(o=n[r])&&void 0!==o?o:{})})),a}(n,i);return Object.keys(o).length<=0?e:o}(e,n,null!=a?a:{});return"string"==typeof c?function(t,e){return function(t,e,n){return"".concat(t," ").concat(e).concat(n===o.DEFAULT?"":" ".concat(n))}(c,t,e)}:function(t,e){return function(t,e,n){var r,a,c,u,f,l,s=null!==(a=null===(r=t[e])||void 0===r?void 0:r[i])&&void 0!==a?a:"",h=null!==(l=null!==(u=null===(c=t[e])||void 0===c?void 0:c[n])&&void 0!==u?u:null===(f=t[e])||void 0===f?void 0:f[o.DEFAULT])&&void 0!==l?l:"";return""===s&&""===h?void 0:"".concat(s).concat(s&&h?" ":"").concat(h)}(c,t,e)}}function h(t){return t!==o.ACTIVE&&t!==o.INACTIVE}function d(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];if(!e)return{};var i=t({},e);return n.forEach((function(t){return delete i[t]})),i}function p(t,e){var n;return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];n&&clearTimeout(n),n=setTimeout((function(){e.call.apply(e,r([null],i,!1))}),t)}}function v(t,e){var n,i=0,o=function(){return Date.now()-i},a=function(t){e.call.apply(e,r([null],t,!1)),i=Date.now()};return function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];if(!i)return a(e);clearTimeout(n),n=setTimeout((function(){o()>=t&&a(e)}),t-o())}}
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from "./_svseeds/core";
1
+ export { type ClassRuleSet, type ThemePreset, CONST, STATE, AREA, elemId, theme, 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 * from "./_svseeds/core";
1
+ export { CONST, STATE, AREA, elemId, theme, 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.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Simple headless components for Svelte.",
5
5
  "type": "module",
6
6
  "main": "./index.js",