not-bulma 2.0.5 → 2.0.6

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": "not-bulma",
3
- "version": "2.0.5",
3
+ "version": "2.0.6",
4
4
  "description": "not-* family UI components on Bulma CSS Framework",
5
5
  "main": "src/index.js",
6
6
  "svelte": "src/index.js",
@@ -1,8 +1,8 @@
1
1
  <script>
2
- import { createEventDispatcher } from "svelte";
3
- const dispatch = createEventDispatcher();
4
- import UIButton from "./ui.button.svelte";
2
+ import { onMount } from "svelte";
3
+ import UICommon from "../common";
5
4
 
5
+ import UIButton from "./ui.button.svelte";
6
6
 
7
7
  /**
8
8
  * @typedef {Object} Props
@@ -21,10 +21,15 @@
21
21
  right = false,
22
22
  classes = "",
23
23
  buttonComponent = UIButton,
24
+ onclick = () => {},
24
25
  action = (e) => {
25
- dispatch("click", e);
26
- }
26
+ onclick(e);
27
+ },
27
28
  } = $props();
29
+
30
+ if (!values.every((itm) => Object.hasOwn(itm, "id"))) {
31
+ values = UICommon.addIds(values);
32
+ }
28
33
  </script>
29
34
 
30
35
  <div
@@ -32,13 +37,15 @@
32
37
  ? 'is-right'
33
38
  : ''} {classes}"
34
39
  >
35
- {#each values as item (item.id)}
36
- {@const SvelteComponent = buttonComponent}
37
- <SvelteComponent
38
- {...item}
39
- bind:value={item.value}
40
- action={item.action ? item.action : action}
41
- on:click
42
- />
43
- {/each}
40
+ {#if Array.isArray(values)}
41
+ {#each values as item (item.id)}
42
+ {@const SvelteComponent = buttonComponent}
43
+ <SvelteComponent
44
+ {...item}
45
+ bind:value={item.value}
46
+ action={item.action ? item.action : action}
47
+ {onclick}
48
+ />
49
+ {/each}
50
+ {/if}
44
51
  </div>
@@ -169,4 +169,11 @@ export default class UICommon {
169
169
  return `${hours} ${unit} назад`;
170
170
  }
171
171
  }
172
+
173
+ static addIds(arr, fieldName = 'id'){
174
+ return arr.map((itm, index)=>{
175
+ itm[fieldName] = index;
176
+ return itm;
177
+ });
178
+ }
172
179
  }
@@ -33,8 +33,9 @@
33
33
  .filter((form) => {
34
34
  return mode !== form.mode;
35
35
  })
36
- .map((form) => {
36
+ .map((form, index) => {
37
37
  return {
38
+ id: index,
38
39
  title: form.title,
39
40
  outlined: true,
40
41
  type: "link",
@@ -53,6 +54,6 @@
53
54
  <div class="block-container" id="{name}-form-set">
54
55
  <div class="form-paper" id="{name}-form-set-container"></div>
55
56
  {#if showModes}
56
- <UIButtons centered={true} bind:values={FORMS_BUTTONS} classes="mt-4" />
57
+ <UIButtons centered={true} values={FORMS_BUTTONS} classes="mt-4" />
57
58
  {/if}
58
59
  </div>
@@ -87,8 +87,10 @@ export default class UIAdapterSvelte {
87
87
  }
88
88
 
89
89
  destroy(){
90
- unmount(this.#instance);
91
- this.#instance = undefined;
90
+ if (this.#instance){
91
+ unmount(this.#instance);
92
+ this.#instance = undefined;
93
+ }
92
94
  this.#props = undefined;
93
95
  this.#uiConstructor = undefined;
94
96
  return this;