@csedl/hotwire-svelte-helpers 4.7.0 → 4.8.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@csedl/hotwire-svelte-helpers",
3
- "version": "4.7.0",
3
+ "version": "4.8.0",
4
4
  "description": "Hotwire + Svelte helpers for Rails: Stimulus floating dropdowns/toolips + Svelte global panels/modals + RTurbo-friendly utilities. Build together with the rubygem svelte-on-rails and its npm-package.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -7,7 +7,7 @@
7
7
  let {
8
8
  panel,
9
9
  label,
10
- svgIcon
10
+ icon
11
11
  } = $props();
12
12
 
13
13
  let buttonElement, panelInstance;
@@ -30,20 +30,30 @@
30
30
  props: {
31
31
  ...panel,
32
32
  closeFunction: closeDropdown,
33
+ buttonElement: buttonElement
33
34
  }
34
35
  }
35
36
  );
36
37
  }
38
+
39
+ const isIconUrl = $derived(
40
+ typeof icon === 'string' &&
41
+ !icon.trim().startsWith('<')
42
+ );
37
43
  </script>
38
44
 
39
45
  <span class="dropdown-button" onclick={ openPanel } bind:this={ buttonElement } role="button" tabindex="0" onkeyup={()=>{}}>
40
- {#if svgIcon}
41
- {@html svgIcon}
46
+ {#if icon}
47
+ {#if isIconUrl}
48
+ <img src={ icon } alt="" class="dropdown-button-icon" />
49
+ {:else}
50
+ {@html icon}
51
+ {/if}
42
52
  {/if}
43
53
  {#if label}
44
54
  {label}
45
55
  {/if}
46
- {#if !svgIcon && !label}
56
+ {#if !icon && !label}
47
57
  ??
48
58
  {/if}
49
59
  </span>
@@ -6,7 +6,6 @@
6
6
  title,
7
7
  panelClass,
8
8
  closeFunction,
9
- closeButtonSvg,
10
9
  buttonElement,
11
10
  content,
12
11
  placement,
@@ -6,7 +6,7 @@
6
6
 
7
7
  let {
8
8
  label,
9
- svgIcon,
9
+ icon,
10
10
  modal,
11
11
  beforeOpen
12
12
  } = $props()
@@ -32,13 +32,13 @@
32
32
  </script>
33
33
 
34
34
  <span role="button" tabindex="0" onkeyup={()=>{}} onclick={openModal} class="modal-button">
35
- {#if svgIcon}
36
- {@html svgIcon}
35
+ {#if icon}
36
+ {@html icon}
37
37
  {/if}
38
38
  {#if label}
39
39
  {label}
40
40
  {/if}
41
- {#if !svgIcon && !label}
41
+ {#if !icon && !label}
42
42
  ??
43
43
  {/if}
44
44
  </span>