@14ch/svelte-ui 0.0.35 → 0.0.37

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.
@@ -61,34 +61,18 @@
61
61
  onchange = () => {} // No params for type inference
62
62
  }: CheckboxGroupProps = $props();
63
63
 
64
- let localValues: Record<string, boolean> = $state(
65
- Object.fromEntries(options.map((opt) => [String(opt.value), (value ?? []).includes(opt.value)]))
66
- );
67
-
68
- // =========================================================================
69
- // Effects
70
- // =========================================================================
71
- $effect(() => {
72
- options.forEach((option) => {
73
- const key = String(option.value);
74
- if (!(key in localValues)) {
75
- localValues[key] = (value ?? []).includes(option.value);
76
- }
77
- });
78
- });
79
-
80
64
  // =========================================================================
81
65
  // Methods
82
66
  // =========================================================================
83
- const handleChange = () => {
84
- value = options
85
- .filter((option) => localValues[String(option.value)])
86
- .map((option) => option.value);
67
+ const handleChange = (optionValue: OptionValue, checked: boolean) => {
68
+ value = checked
69
+ ? [...(value ?? []), optionValue]
70
+ : (value ?? []).filter((v) => v !== optionValue);
87
71
  onchange(value);
88
72
  };
89
73
 
90
74
  // =========================================================================
91
- // $defived
75
+ // $derived
92
76
  // =========================================================================
93
77
  const gapStyle = $derived(gap !== undefined ? getStyleFromNumber(gap) : undefined);
94
78
  const minOptionWidthStyle = $derived(getStyleFromNumber(minOptionWidth));
@@ -104,12 +88,12 @@
104
88
  {#each options as option (option.value)}
105
89
  <li class="checkbox-group__option">
106
90
  <Checkbox
107
- bind:value={localValues[String(option.value)]}
91
+ value={(value ?? []).includes(option.value)}
108
92
  {size}
109
- {disabled}
93
+ disabled={disabled || (option.disabled ?? false)}
110
94
  {required}
111
95
  {reducedMotion}
112
- onchange={handleChange}
96
+ onchange={(checked) => handleChange(option.value, checked)}
113
97
  >
114
98
  {option.label}
115
99
  </Checkbox>
@@ -163,7 +163,7 @@
163
163
  ...restProps
164
164
  }: ComboboxProps = $props();
165
165
 
166
- let inputValue = $state('');
166
+ let inputValue = $state(value != null ? String(value) : '');
167
167
  let inputRef = $state<any>();
168
168
  let listElement = $state<HTMLDivElement>();
169
169
  let comboboxElement = $state<HTMLDivElement>();
@@ -173,6 +173,15 @@
173
173
  let isFocused = $state(false);
174
174
  let isKeyboardNavigation = $state(false);
175
175
 
176
+ // =========================================================================
177
+ // Effects
178
+ // =========================================================================
179
+ $effect(() => {
180
+ if (!isFocused) {
181
+ inputValue = value != null ? String(value) : '';
182
+ }
183
+ });
184
+
176
185
  // =========================================================================
177
186
  // Methods
178
187
  // =========================================================================
@@ -447,7 +456,7 @@
447
456
  {readonly}
448
457
  {required}
449
458
  {clearable}
450
- rightIcon={inline ? undefined : 'arrow_drop_down'}
459
+ rightIcon="arrow_drop_down"
451
460
  {tabindex}
452
461
  {maxlength}
453
462
  {rounded}
@@ -1199,6 +1199,10 @@
1199
1199
  .input__link-text {
1200
1200
  padding-right: var(--svelte-ui-input-icon-space-inline);
1201
1201
  }
1202
+
1203
+ .input__icon-right {
1204
+ right: 0;
1205
+ }
1202
1206
  }
1203
1207
 
1204
1208
  &.input--clearable {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@14ch/svelte-ui",
3
3
  "description": "Modern Svelte UI components library with TypeScript support",
4
4
  "private": false,
5
- "version": "0.0.35",
5
+ "version": "0.0.37",
6
6
  "type": "module",
7
7
  "keywords": [
8
8
  "svelte",