@axium/client 0.4.2 → 0.4.3

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.
@@ -19,6 +19,7 @@
19
19
 
20
20
  let input = $state<HTMLInputElement | HTMLSelectElement>()!;
21
21
  let checked = $state(schema.def.type == 'boolean' && getByString<boolean>(preferences, path));
22
+ const initialValue = $derived<any>(getByString(preferences, path) ?? getByString(preferenceDefaults, path));
22
23
 
23
24
  function dateAttr(date: Date | null, format: 'date' | 'time' | 'datetime' | 'time+sec') {
24
25
  if (!date) return null;
@@ -62,14 +63,7 @@
62
63
  </script>
63
64
 
64
65
  {#snippet _in(rest: HTMLInputAttributes)}
65
- <input
66
- bind:this={input}
67
- {id}
68
- {...rest}
69
- value={getByString(preferences, path) ?? getByString(preferenceDefaults, path)}
70
- {onchange}
71
- required={!optional}
72
- />
66
+ <input bind:this={input} {id} {...rest} value={initialValue} {onchange} required={!optional} />
73
67
  {/snippet}
74
68
 
75
69
  {#if zIs(schema, 'string')}
@@ -94,7 +88,7 @@
94
88
  {:else if zIs(schema, 'literal')}
95
89
  <select bind:this={input} {id} {onchange} required={!optional}>
96
90
  {#each schema.values as value}
97
- <option {value} selected={getByString(preferences, path) === value}>{value}</option>
91
+ <option {value} selected={initialValue === value}>{value}</option>
98
92
  {/each}
99
93
  </select>
100
94
  {:else if zIs(schema, 'template_literal')}
@@ -104,7 +98,7 @@
104
98
  <Preference {userId} bind:preferences {path} schema={schema.def.innerType} optional={true} />
105
99
  {:else if zIs(schema, 'array')}
106
100
  <div class="pref-sub">
107
- {#each getByString<unknown[]>(preferences, path), i}
101
+ {#each initialValue, i}
108
102
  <div class="pref-record-entry">
109
103
  <Preference {userId} bind:preferences path="{path}.{i}" schema={schema.element} />
110
104
  </div>
@@ -112,7 +106,7 @@
112
106
  </div>
113
107
  {:else if zIs(schema, 'record')}
114
108
  <div class="pref-sub">
115
- {#each Object.keys(getByString<object>(preferences, path)) as key}
109
+ {#each Object.keys(initialValue) as key}
116
110
  <div class="pref-record-entry">
117
111
  <label for={id}>{key}</label>
118
112
  <Preference {userId} bind:preferences path="{path}.{key}" schema={schema.valueType} />
@@ -135,7 +129,7 @@
135
129
  {:else if zIs(schema, 'enum')}
136
130
  <select bind:this={input} {id} {onchange} required={!optional}>
137
131
  {#each Object.entries(schema.enum) as [key, value]}
138
- <option value selected={getByString(preferences, path) === value}>{key}</option>
132
+ <option {value} selected={initialValue === value}>{key}</option>
139
133
  {/each}
140
134
  </select>
141
135
  {:else}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/client",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "author": "James Prevett <jp@jamespre.dev>",
5
5
  "funding": {
6
6
  "type": "individual",