not-bulma 2.0.9 → 2.0.12

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.9",
3
+ "version": "2.0.12",
4
4
  "description": "not-* family UI components on Bulma CSS Framework",
5
5
  "main": "src/index.js",
6
6
  "svelte": "src/index.js",
@@ -1,59 +1,56 @@
1
1
  <script>
2
- import { createEventDispatcher } from "svelte";
3
- const dispatch = createEventDispatcher();
4
2
  import { LOCALE } from "../../locale";
5
3
 
4
+ /**
5
+ * @typedef {Object} Props
6
+ * @property {string} [title]
7
+ * @property {boolean} [light]
8
+ * @property {boolean} [loading]
9
+ * @property {boolean} [raised]
10
+ * @property {boolean} [outlined]
11
+ * @property {boolean} [inverted]
12
+ * @property {boolean} [rounded]
13
+ * @property {boolean} [disabled]
14
+ * @property {string} [state]
15
+ * @property {string} [type]
16
+ * @property {string} [color]
17
+ * @property {string} [size]
18
+ * @property {string} [classes]
19
+ * @property {boolean} [icon]
20
+ * @property {string} [iconSide]
21
+ * @property {any} [action]
22
+ * @property {any} value
23
+ * @property {import('svelte').Snippet} [children]
24
+ */
6
25
 
7
-
8
- /**
9
- * @typedef {Object} Props
10
- * @property {string} [title]
11
- * @property {boolean} [light]
12
- * @property {boolean} [loading]
13
- * @property {boolean} [raised]
14
- * @property {boolean} [outlined]
15
- * @property {boolean} [inverted]
16
- * @property {boolean} [rounded]
17
- * @property {boolean} [disabled]
18
- * @property {string} [state]
19
- * @property {string} [type]
20
- * @property {string} [color]
21
- * @property {string} [size]
22
- * @property {string} [classes]
23
- * @property {boolean} [icon]
24
- * @property {string} [iconSide]
25
- * @property {any} [action]
26
- * @property {any} value
27
- * @property {import('svelte').Snippet} [children]
28
- */
29
-
30
- /** @type {Props} */
31
- let {
32
- title = "",
33
- light = false,
34
- loading = false,
35
- raised = false,
36
- outlined = false,
37
- inverted = false,
38
- rounded = false,
39
- disabled = false,
40
- state = "",
41
- type = "",
42
- color = "",
43
- size = "",
44
- classes = "",
45
- icon = false,
46
- iconSide = "right",
47
- action = () => {
48
- return true;
49
- },
50
- value,
51
- children
52
- } = $props();
26
+ /** @type {Props} */
27
+ let {
28
+ title = "",
29
+ light = false,
30
+ loading = false,
31
+ raised = false,
32
+ outlined = false,
33
+ inverted = false,
34
+ rounded = false,
35
+ disabled = false,
36
+ state = "",
37
+ type = "",
38
+ color = "",
39
+ size = "",
40
+ classes = "",
41
+ icon = false,
42
+ iconSide = "right",
43
+ action = () => {
44
+ return true;
45
+ },
46
+ value,
47
+ children,
48
+ onclick = () => {},
49
+ } = $props();
53
50
 
54
51
  function onClick(event) {
55
52
  event.stopPropagation();
56
- dispatch("click", { event, value });
53
+ onclick({ event, value });
57
54
  return action(event, value);
58
55
  }
59
56
  </script>
@@ -76,27 +73,21 @@
76
73
  {size ? `is-${size}` : ''}
77
74
  "
78
75
  >
79
- {#if children}{@render children()}{:else}
80
- {#if icon}
81
- {#if iconSide === "left"}
82
- <span class="icon"
83
- ><i
84
- class="fas fa-{icon} {size ? `is-${size}` : ''}"
85
- ></i></span
86
- >
87
- {/if}
88
- {#if title}
89
- <span>{$LOCALE[title]}</span>
90
- {/if}
91
- {#if iconSide === "right"}
92
- <span class="icon"
93
- ><i
94
- class="fas fa-{icon} {size ? `is-${size}` : ''}"
95
- ></i></span
96
- >
97
- {/if}
98
- {:else}
99
- {$LOCALE[title]}
76
+ {#if children}{@render children()}{:else if icon}
77
+ {#if iconSide === "left"}
78
+ <span class="icon"
79
+ ><i class="fas fa-{icon} {size ? `is-${size}` : ''}"></i></span
80
+ >
81
+ {/if}
82
+ {#if title}
83
+ <span>{$LOCALE[title]}</span>
84
+ {/if}
85
+ {#if iconSide === "right"}
86
+ <span class="icon"
87
+ ><i class="fas fa-{icon} {size ? `is-${size}` : ''}"></i></span
88
+ >
100
89
  {/if}
90
+ {:else}
91
+ {$LOCALE[title]}
101
92
  {/if}
102
93
  </button>
@@ -28,10 +28,10 @@
28
28
  /** @type {Props} */
29
29
  let {
30
30
  fieldname = "numbers_list",
31
- value = $bindable({}),
31
+ value = {},
32
32
  label = "named numbers list",
33
33
  inputStarted = false,
34
- placeholder = $bindable("new item"),
34
+ placeholder = "new item",
35
35
  readonly = false,
36
36
  valid = true,
37
37
  validated = false,
@@ -40,15 +40,19 @@
40
40
  onchange = () => {},
41
41
  } = $props();
42
42
 
43
- let list = $derived(
44
- Object.keys(value).map((name) => {
43
+ let list = $state([]);
44
+
45
+ function updateList() {
46
+ list = Object.keys(value).map((name) => {
45
47
  return {
46
48
  id: name,
47
49
  title: name,
48
50
  number: value[name],
49
51
  };
50
- })
51
- );
52
+ });
53
+ }
54
+
55
+ updateList();
52
56
 
53
57
  let allErrors;
54
58
  run(() => {
@@ -73,8 +77,9 @@
73
77
  if (notCommon.objHas(value, id)) {
74
78
  delete value[id];
75
79
  value = value;
76
- onchange({ value, field: fieldname });
80
+ onchange({ value: $state.snapshot(value), field: fieldname });
77
81
  }
82
+ updateList();
78
83
  }
79
84
 
80
85
  function add() {
@@ -83,7 +88,9 @@
83
88
  if (id && id !== "" && !isNaN(number) && !notCommon.objHas(value, id)) {
84
89
  value[id] = number;
85
90
  }
86
- onchange({ value, field: fieldname });
91
+ value = value;
92
+ onchange({ value: $state.snapshot(value), field: fieldname });
93
+ updateList();
87
94
  }
88
95
 
89
96
  const createNewVal = () => {
@@ -97,7 +104,7 @@
97
104
  </script>
98
105
 
99
106
  <UITitle title={label} size={5} />
100
- {#each list as item (item.id)}
107
+ {#each list as item, index (item.id)}
101
108
  <UIColumns>
102
109
  <UIColumn classes="is-6">
103
110
  {item.title}
@@ -115,7 +122,7 @@
115
122
  {#if !readonly}
116
123
  <UIColumns>
117
124
  <UIColumn classes="is-6">
118
- <UITextfield bind:value={newVal.id} bind:placeholder />
125
+ <UITextfield bind:value={newVal.id} {placeholder} />
119
126
  </UIColumn>
120
127
  <UIColumn classes="is-4">
121
128
  <UINumber bind:value={newVal.number} />
@@ -1,5 +1,6 @@
1
1
  <script>
2
2
  import { run } from "svelte/legacy";
3
+ import { onMount } from "svelte";
3
4
 
4
5
  import { LOCALE } from "../../locale";
5
6
  import UISelectOption from "./ui.select.option.svelte";
@@ -29,8 +30,8 @@
29
30
 
30
31
  /** @type {Props} */
31
32
  let {
32
- inputStarted = $bindable(false),
33
- value = $bindable(""),
33
+ inputStarted = false,
34
+ value = "",
34
35
  variants = [],
35
36
  placeholder = "",
36
37
  emptyValueTitle = "",
@@ -46,26 +47,58 @@
46
47
  formErrors = false,
47
48
  formLevelError = false,
48
49
  onchange = () => {},
50
+ onInputStarted = () => {},
51
+ class: classes = "",
52
+ idField = "id",
53
+ titleField = "title",
49
54
  } = $props();
50
55
 
51
56
  let selectedVariants = $state([]);
52
57
 
53
58
  function filterSelectedVariants(variant) {
54
59
  if (Array.isArray(value) && multiple) {
55
- return value.indexOf(variant.id) > -1;
60
+ return value.indexOf(variant[idField]) > -1;
56
61
  } else if (value) {
57
- return value == variant.id;
62
+ return value == variant[idField];
58
63
  } else {
59
64
  return false;
60
65
  }
61
66
  }
62
67
 
63
- let lastChange;
68
+ let lastChange, selectElement;
69
+
70
+ onMount(() => {
71
+ onInput({ currentTarget: selectElement });
72
+ });
73
+
74
+ function getSelectedValues() {
75
+ if (multiple) {
76
+ const _values = Array.from(selectElement.selectedOptions).map(
77
+ (el) => el.value
78
+ );
79
+ if (_values.indexOf(UICommon.CLEAR_MACRO) > -1) {
80
+ return [];
81
+ } else {
82
+ return _values;
83
+ }
84
+ } else {
85
+ if (selectElement.value === UICommon.CLEAR_MACRO) {
86
+ return "";
87
+ } else {
88
+ return selectElement.value;
89
+ }
90
+ }
91
+ }
92
+
93
+ function triggerInputStarted() {
94
+ onInputStarted();
95
+ inputStarted = true;
96
+ }
64
97
 
65
98
  function onBlur(ev) {
66
99
  let data = {
67
100
  field: fieldname,
68
- value: ev.currentTarget.value,
101
+ value: getSelectedValues(),
69
102
  };
70
103
  if (lastChange === data.value) {
71
104
  return true;
@@ -77,20 +110,7 @@
77
110
  return true;
78
111
  }
79
112
  }
80
- if (multiple) {
81
- value = Array.from(ev.target.selectedOptions).map((el) => el.value);
82
- if (value.indexOf(UICommon.CLEAR_MACRO) > -1) {
83
- value = [];
84
- }
85
- data.value = value;
86
- } else {
87
- if (data.value === UICommon.CLEAR_MACRO) {
88
- value = "";
89
- } else {
90
- value = data.value;
91
- }
92
- }
93
- inputStarted = true;
113
+ triggerInputStarted();
94
114
  onchange(data);
95
115
  return true;
96
116
  }
@@ -98,48 +118,40 @@
98
118
  function onInput(ev) {
99
119
  let data = {
100
120
  field: fieldname,
101
- value: ev.currentTarget.value,
121
+ value: getSelectedValues(),
102
122
  };
103
- if (multiple) {
104
- value = Array.from(ev.target.selectedOptions).map((el) => el.value);
105
- if (value.indexOf(UICommon.CLEAR_MACRO) > -1) {
106
- value = [];
107
- }
108
- data.value = value;
109
- } else {
110
- if (data.value === UICommon.CLEAR_MACRO) {
111
- value = "";
112
- } else {
113
- value = data.value;
114
- }
115
- }
116
- inputStarted = true;
123
+ triggerInputStarted();
117
124
  lastChange = data.value;
118
125
  onchange(data);
119
126
  return true;
120
127
  }
128
+
121
129
  let iconClasses = $derived(
122
130
  (icon ? " has-icons-left " : "") + " has-icons-right "
123
131
  );
124
- let allErrors;
132
+
133
+ let allErrors = $state([]);
125
134
  run(() => {
126
135
  allErrors = [].concat(
127
136
  errors ? errors : [],
128
137
  formErrors ? formErrors : []
129
138
  );
130
139
  });
131
- let showErrors;
140
+
141
+ let showErrors = $state(false);
132
142
  run(() => {
133
143
  showErrors = !(validated && valid) && inputStarted;
134
144
  });
135
145
  let invalid = $derived(valid === false || formLevelError);
136
- let validationClasses;
146
+
147
+ let validationClasses = $state("");
137
148
  run(() => {
138
149
  validationClasses =
139
150
  valid === true || !inputStarted
140
151
  ? UICommon.CLASS_OK
141
152
  : UICommon.CLASS_ERR;
142
153
  });
154
+
143
155
  let multipleClass = $derived(multiple ? " is-multiple " : "");
144
156
  run(() => {
145
157
  value;
@@ -153,7 +165,7 @@
153
165
  {#if readonly}
154
166
  {#if value}
155
167
  {#each selectedVariants as selectedVariant}
156
- <span class="mr-2">{$LOCALE[selectedVariant.title]}</span>
168
+ <span class="mr-2">{$LOCALE[selectedVariant[titleField]]}</span>
157
169
  {/each}
158
170
  {:else}
159
171
  <span class="mr-2">{$LOCALE[emptyValueTitle]}</span>
@@ -161,10 +173,12 @@
161
173
  {:else}
162
174
  <div class="select {validationClasses} {multipleClass}">
163
175
  <select
176
+ bind:this={selectElement}
164
177
  id="form-field-select-{fieldname}"
165
178
  name={fieldname}
166
179
  onblur={onBlur}
167
180
  oninput={onInput}
181
+ onchange={onInput}
168
182
  {readonly}
169
183
  {required}
170
184
  {multiple}
@@ -187,15 +201,16 @@
187
201
  {#each variants as variant}
188
202
  {#if multiple}
189
203
  <UISelectOption
190
- value={variant.id}
191
- selected={value && value.indexOf(variant.id) > -1}
192
- title={variant.title}
204
+ value={variant[idField]}
205
+ selected={value &&
206
+ value.indexOf(variant[idField]) > -1}
207
+ title={variant[titleField]}
193
208
  />
194
209
  {:else}
195
210
  <UISelectOption
196
- value={variant.id}
197
- selected={value == variant.id}
198
- title={variant.title}
211
+ value={variant[idField]}
212
+ selected={value == variant[idField]}
213
+ title={variant[titleField]}
199
214
  />
200
215
  {/if}
201
216
  {/each}
@@ -16,7 +16,7 @@
16
16
  srcFull,
17
17
  src,
18
18
  title,
19
- cors = "anonymous",
19
+ cors,
20
20
  size = 64,
21
21
  contained = true,
22
22
  covered = true,
@@ -28,6 +28,8 @@
28
28
  let sizeStyle = $derived(isNaN(size) ? `is-${size}` : `is-${size}x${size}`);
29
29
  let containedStyle = $derived(contained ? "is-contained" : "");
30
30
  let coveredStyle = $derived(covered ? "is-covered" : "");
31
+
32
+ let crossOrigin = $derived(cors);
31
33
  </script>
32
34
 
33
35
  {#if srcFull}
@@ -35,7 +37,7 @@
35
37
  <figure
36
38
  class="image {sizeStyle} {containedStyle} {coveredStyle} {classes}"
37
39
  >
38
- <img class="" alt={title} {src} crossOrigin={cors} />
40
+ <img class="" alt={title} {src} {crossOrigin} />
39
41
  </figure>
40
42
  </a>
41
43
  {:else}
@@ -46,6 +48,6 @@
46
48
  role="button"
47
49
  tabindex="0"
48
50
  >
49
- <img class="" alt={title} {src} crossOrigin={cors} />
51
+ <img class="" alt={title} {src} {crossOrigin} />
50
52
  </figure>
51
53
  {/if}
@@ -27,9 +27,6 @@
27
27
  onkeyup,
28
28
  ...other
29
29
  } = $props();
30
-
31
- const onKeyUp =
32
- onkeyup ?? (onclick ? UICommon.onlyOnEnter(onclick) : undefined);
33
30
  </script>
34
31
 
35
32
  <div
@@ -38,7 +35,7 @@
38
35
  " "
39
36
  )}
40
37
  {onclick}
41
- onkeyup={onKeyUp}
38
+ onkeyup={onkeyup ?? (onclick ? UICommon.onlyOnEnter(onclick) : undefined)}
42
39
  {role}
43
40
  {tabIndex}
44
41
  >
@@ -1,15 +1,14 @@
1
1
  <script>
2
- import {LOCALE} from '../../locale';
3
-
4
- let { message, title } = $props();
2
+ import { LOCALE } from "../../locale";
5
3
 
4
+ let { message, title, class: classes = "" } = $props();
6
5
  </script>
7
6
 
8
- <article class="message is-danger">
9
- <div class="message-header">
10
- <p>{$LOCALE[title]}</p>
11
- </div>
12
- <div class="message-body">
13
- {$LOCALE[message]}
14
- </div>
7
+ <article class="message is-danger {classes}">
8
+ <div class="message-header">
9
+ <p>{$LOCALE[title]}</p>
10
+ </div>
11
+ <div class="message-body">
12
+ {$LOCALE[message]}
13
+ </div>
15
14
  </article>
@@ -1,14 +1,13 @@
1
1
  <script>
2
- import {LOCALE} from '../../locale';
3
- let { message, title } = $props();
4
-
2
+ import { LOCALE } from "../../locale";
3
+ let { message, title, class: classes = "" } = $props();
5
4
  </script>
6
5
 
7
- <article class="message is-success">
8
- <div class="message-header">
9
- <p>{$LOCALE[title]}</p>
10
- </div>
11
- <div class="message-body">
12
- {$LOCALE[message]}
13
- </div>
6
+ <article class="message is-success {classes}">
7
+ <div class="message-header">
8
+ <p>{$LOCALE[title]}</p>
9
+ </div>
10
+ <div class="message-body">
11
+ {$LOCALE[message]}
12
+ </div>
14
13
  </article>
@@ -1,10 +1,9 @@
1
1
  <script>
2
2
  import "bulma-pageloader";
3
3
  import { LOCALE } from "../../locale";
4
-
4
+
5
5
  //hidden - no loader
6
6
  //container - parent container of form
7
-
8
7
 
9
8
  /**
10
9
  * @typedef {Object} Props
@@ -14,7 +13,11 @@
14
13
  */
15
14
 
16
15
  /** @type {Props} */
17
- let { loading = false, size = "container", title = "Waiting..." } = $props();
16
+ let {
17
+ loading = false,
18
+ size = "container",
19
+ title = "Waiting...",
20
+ } = $props();
18
21
  </script>
19
22
 
20
23
  {#if size !== "hidden"}
@@ -21,7 +21,7 @@
21
21
  size = 1,
22
22
  subsize,
23
23
  spaced = false,
24
- align = "left"
24
+ align = "left",
25
25
  } = $props();
26
26
 
27
27
  export const scrollToTop = (options = UICommon.SCROLL_OPTIONS) => {
@@ -30,16 +30,18 @@
30
30
  }, 100);
31
31
  };
32
32
 
33
- let size2 = $derived(subsize
34
- ? subsize
35
- : parseInt(size) < 6
36
- ? parseInt(size) + 1
37
- : size);
38
-
33
+ let size2 = $derived(
34
+ subsize ? subsize : parseInt(size) < 6 ? parseInt(size) + 1 : size
35
+ );
36
+
39
37
  let spacedStyle = $derived(spaced ? "is-spaced" : "");
40
38
 
41
- let resultTitle = $derived(`<h${size} id="${id}" style="text-align: ${align};" class="title ${spacedStyle} is-${size}">${$LOCALE[title]}</h${size}>`);
42
- let resultSubtitle = $derived(`<h${size2} id="${id}" style="text-align: ${align};" class="subtitle is-${size2}">${$LOCALE[subtitle]}</h${size2}>`);
39
+ let resultTitle = $derived(
40
+ `<h${size} id="${id}" style="text-align: ${align};" class="title ${spacedStyle} is-${size}">${$LOCALE[title]}</h${size}>`
41
+ );
42
+ let resultSubtitle = $derived(
43
+ `<h${size2} id="${id}" style="text-align: ${align};" class="subtitle is-${size2}">${$LOCALE[subtitle]}</h${size2}>`
44
+ );
43
45
  </script>
44
46
 
45
47
  {#if title}