@csedl/hotwire-svelte-helpers 2.2.2 → 2.3.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/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # Hotwire Svelte Helpers
2
2
 
3
- is the successor of the `@csedl/stimulus-dropdown` package
4
-
5
3
  Dropdown with stimulus, based on floating-UI.
6
4
 
7
5
  **Links:**
@@ -20,9 +18,12 @@ HotwireSvelteHelpers.initializeOverlays()
20
18
  This package has a Server-Side Rendering (SSR) safe configuration, which means:
21
19
 
22
20
  You must add the file `<vite-sourcee-code-dir>/config/hotwire-svelte-helpers.js`.
23
- The package inside does a fixed `import customConfigs from '/config/hotwire-svelte-helpers.js'`.
21
+ The package inside does a fixed `import customConfigs from '@/config/hotwire-svelte-helpers.js'`.
24
22
  By this, it must find that file.
25
23
 
24
+ The alias `@` is by default a alias set by vite_rails, pointing to `sourceCodeDir`.
25
+ For this package it is required not to change override this.
26
+
26
27
  Minimal content of this file:
27
28
 
28
29
  ```javascript
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@csedl/hotwire-svelte-helpers",
3
- "version": "2.2.2",
3
+ "version": "2.3.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": {
package/src/lib/config.js CHANGED
@@ -1,4 +1,4 @@
1
- import customConfigs from '/config/hotwire-svelte-helpers.js'
1
+ import customConfigs from '@/config/hotwire-svelte-helpers.js'
2
2
 
3
3
  export function hotwireSvelteConfig(key) {
4
4
 
@@ -3,7 +3,7 @@
3
3
  import { unmount } from 'svelte'
4
4
  import { cleanMount } from "../cleanMount.js";
5
5
 
6
- let { panelContent, panelTitle, panelClass, label, svgIcon } = $props();
6
+ let { panelContent, panelTitle, panelClass, label, svgIcon, panelPlacement } = $props();
7
7
 
8
8
  let buttonElement, panelInstance;
9
9
 
@@ -15,7 +15,7 @@
15
15
  buttonElement.classList.remove('has-open-panel');
16
16
  };
17
17
 
18
- function openEditPanel() {
18
+ function openPanel() {
19
19
 
20
20
  if (buttonElement.classList.contains('has-open-panel')) return;
21
21
 
@@ -28,13 +28,14 @@
28
28
  buttonElement: buttonElement,
29
29
  panelClass: panelClass,
30
30
  content: panelContent,
31
+ placement: panelPlacement
31
32
  }
32
33
  }
33
34
  );
34
35
  }
35
36
  </script>
36
37
 
37
- <span class="dropdown-button" onclick={ openEditPanel } bind:this={ buttonElement } role="button" tabindex="0" onkeyup={()=>{}}>
38
+ <span class="dropdown-button" onclick={ openPanel } bind:this={ buttonElement } role="button" tabindex="0" onkeyup={()=>{}}>
38
39
  {#if svgIcon}
39
40
  {@html svgIcon}
40
41
  {/if}
@@ -1,6 +1,6 @@
1
1
  <script>
2
- import {openDropdownPanel, hotwireSvelteConfig} from "@csedl/hotwire-svelte-helpers";
3
- import {onMount} from "svelte";
2
+ import { openDropdownPanel, hotwireSvelteConfig } from "@csedl/hotwire-svelte-helpers";
3
+ import { onMount } from "svelte";
4
4
 
5
5
  let {
6
6
  title,
@@ -9,10 +9,14 @@
9
9
  closeButtonSvg,
10
10
  buttonElement,
11
11
  content,
12
+ placement,
12
13
  } = $props()
13
14
  let panelElement
14
15
 
15
16
  onMount(() => {
17
+ if (placement) {
18
+ panelElement.setAttribute('data-placement', placement)
19
+ }
16
20
  openDropdownPanel(buttonElement, panelElement);
17
21
  });
18
22