@classic-homes/theme-svelte 1.34.0 → 1.34.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.
@@ -1,4 +1,5 @@
1
1
  <script lang="ts">
2
+ import { tick } from 'svelte';
2
3
  import { Combobox as ComboboxPrimitive } from 'bits-ui';
3
4
  import { cn } from '../utils.js';
4
5
  import { computeDescribedBy } from '../utils/form.js';
@@ -80,6 +81,7 @@
80
81
  const describedBy = $derived(computeDescribedBy(hintId, errorId, !!hint, !!error));
81
82
 
82
83
  let searchQuery = $state('');
84
+ let inputEl = $state<HTMLInputElement | null>(null);
83
85
  let debounceTimer: ReturnType<typeof setTimeout> | null = null;
84
86
  let open = $state(false);
85
87
 
@@ -131,6 +133,20 @@
131
133
  if (toggled !== null) anchor = toggled;
132
134
  value = next;
133
135
  onValueChange?.(next);
136
+ clearInput();
137
+ }
138
+
139
+ /**
140
+ * The combobox writes the picked option's label into the input; clear it
141
+ * (through an input event, so the combobox's own state and the filter both
142
+ * reset) so the next search starts empty and the full list shows again.
143
+ */
144
+ function clearInput() {
145
+ void tick().then(() => {
146
+ if (!inputEl || inputEl.value === '') return;
147
+ inputEl.value = '';
148
+ inputEl.dispatchEvent(new Event('input', { bubbles: true }));
149
+ });
134
150
  }
135
151
 
136
152
  function removeValue(valueToRemove: string) {
@@ -143,6 +159,7 @@
143
159
  open = isOpen;
144
160
  if (!isOpen) {
145
161
  searchQuery = '';
162
+ clearInput();
146
163
  }
147
164
  }
148
165
 
@@ -235,6 +252,7 @@
235
252
  >
236
253
  <div class="relative">
237
254
  <ComboboxPrimitive.Input
255
+ bind:ref={inputEl}
238
256
  id={componentId}
239
257
  placeholder={value.length > 0 ? `${value.length} selected` : placeholder}
240
258
  oninput={handleSearchInput}
@@ -15,8 +15,9 @@
15
15
  *
16
16
  * Picking an item from elsewhere (an outline, an issue list) scrolls it into
17
17
  * view; picking it on the canvas does not, so it never moves under the
18
- * pointer. `insertPlacement="gutter"` puts the "+" in the left margin, for
19
- * items edited in place, where a centred "+" would sit on the text.
18
+ * pointer. For items edited in place, `insertPlacement="gutter"` puts the
19
+ * "+" in the left margin and `toolbarPlacement="above"` lifts the toolbar
20
+ * clear of the item, so neither sits on the text.
20
21
  */
21
22
  interface Props {
22
23
  children: Snippet;
@@ -39,6 +40,12 @@
39
40
  revealOnSelect?: boolean;
40
41
  /** Where the "+" sits: centred on the item's bottom edge, or in the left gutter beside it */
41
42
  insertPlacement?: 'center' | 'gutter';
43
+ /**
44
+ * Where the toolbar sits: straddling the item's top edge (default), or
45
+ * wholly above it, for items edited in place, where the default would
46
+ * cover the first line of text.
47
+ */
48
+ toolbarPlacement?: 'edge' | 'above';
42
49
  class?: string;
43
50
  }
44
51
 
@@ -53,6 +60,7 @@
53
60
  invalid = false,
54
61
  revealOnSelect = true,
55
62
  insertPlacement = 'center',
63
+ toolbarPlacement = 'edge',
56
64
  class: className,
57
65
  }: Props = $props();
58
66
 
@@ -129,7 +137,10 @@
129
137
  {#if selected && toolbar}
130
138
  <div
131
139
  data-studio-quick-action
132
- class="absolute -top-4 right-3 z-10 flex items-center gap-0.5 rounded-md border border-border bg-background p-0.5 shadow-md"
140
+ class={cn(
141
+ 'absolute right-3 z-10 flex items-center gap-0.5 rounded-md border border-border bg-background p-0.5 shadow-md',
142
+ toolbarPlacement === 'above' ? 'bottom-full mb-1' : '-top-4'
143
+ )}
133
144
  >
134
145
  {@render toolbar()}
135
146
  </div>
@@ -10,8 +10,9 @@ import { type Snippet } from 'svelte';
10
10
  *
11
11
  * Picking an item from elsewhere (an outline, an issue list) scrolls it into
12
12
  * view; picking it on the canvas does not, so it never moves under the
13
- * pointer. `insertPlacement="gutter"` puts the "+" in the left margin, for
14
- * items edited in place, where a centred "+" would sit on the text.
13
+ * pointer. For items edited in place, `insertPlacement="gutter"` puts the
14
+ * "+" in the left margin and `toolbarPlacement="above"` lifts the toolbar
15
+ * clear of the item, so neither sits on the text.
15
16
  */
16
17
  interface Props {
17
18
  children: Snippet;
@@ -34,6 +35,12 @@ interface Props {
34
35
  revealOnSelect?: boolean;
35
36
  /** Where the "+" sits: centred on the item's bottom edge, or in the left gutter beside it */
36
37
  insertPlacement?: 'center' | 'gutter';
38
+ /**
39
+ * Where the toolbar sits: straddling the item's top edge (default), or
40
+ * wholly above it, for items edited in place, where the default would
41
+ * cover the first line of text.
42
+ */
43
+ toolbarPlacement?: 'edge' | 'above';
37
44
  class?: string;
38
45
  }
39
46
  declare const StudioCanvasItem: import("svelte").Component<Props, {}, "">;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classic-homes/theme-svelte",
3
- "version": "1.34.0",
3
+ "version": "1.34.1",
4
4
  "description": "Svelte components for the Classic theme system",
5
5
  "type": "module",
6
6
  "svelte": "./dist/lib/index.js",