not-bulma 1.0.73 → 1.0.75

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": "1.0.73",
3
+ "version": "1.0.75",
4
4
  "description": "not-* family UI components on Bulma CSS Framework",
5
5
  "main": "src/index.js",
6
6
  "svelte": "src/index.js",
@@ -65,18 +65,24 @@ export default class UICommon {
65
65
  return `${this.MONEY_SIGN}${major}.${minor}`;
66
66
  }
67
67
 
68
- static formatLocaleDatetime(dt) {
68
+ static formatLocaleDatetime(dt, opts = { date: true, time: true }) {
69
69
  const date = dt.toLocaleDateString(window.navigator.language);
70
70
  const time = dt.toLocaleTimeString(window.navigator.language);
71
- return `${date} ${time}`;
71
+ if (opts.date && opts.time) {
72
+ return `${date} ${time}`;
73
+ } else if (opts.date && !opts.time) {
74
+ return date;
75
+ } else {
76
+ return time;
77
+ }
72
78
  }
73
79
 
74
- static tryFormatLocaleDateTime(value) {
75
- if (typeof value == "string") {
80
+ static tryFormatLocaleDateTime(value, opts = { date: true, time: true }) {
81
+ if (typeof value == "string" || typeof value == "number") {
76
82
  const dt = new Date(value);
77
- return UICommon.formatLocaleDatetime(dt);
83
+ return UICommon.formatLocaleDatetime(dt, opts);
78
84
  } else if (typeof value == "object") {
79
- return UICommon.formatLocaleDatetime(value);
85
+ return UICommon.formatLocaleDatetime(value, opts);
80
86
  } else {
81
87
  return "";
82
88
  }
@@ -3,6 +3,7 @@
3
3
  import UITitle from "../various/ui.title.svelte";
4
4
  export let idFieldName = "id";
5
5
  export let items = [];
6
+ export let actions = [];
6
7
 
7
8
  export let itemClasses = "";
8
9
 
@@ -28,6 +29,7 @@
28
29
  {imageComponent}
29
30
  {imageComponentProps}
30
31
  {...item}
32
+ listActions={actions}
31
33
  classes={itemClasses}
32
34
  value={item}
33
35
  on:click
@@ -1,5 +1,5 @@
1
1
  <script>
2
- import { createEventDispatcher } from "svelte";
2
+ import { createEventDispatcher, onMount } from "svelte";
3
3
  const dispatch = createEventDispatcher();
4
4
 
5
5
  import UITitle from "../various/ui.title.svelte";
@@ -8,6 +8,7 @@
8
8
  export let title;
9
9
  export let description;
10
10
  export let actions = [];
11
+ export let listActions = [];
11
12
  export let classes = "";
12
13
  export let image = "";
13
14
  //value of item, will be passed to event handlers
@@ -23,6 +24,10 @@
23
24
  function onClick() {
24
25
  dispatch("click", value);
25
26
  }
27
+ let allActions = [];
28
+ $: allActions = [...actions, ...listActions].map((btn) => {
29
+ return { ...btn, action: () => btn.action(value) };
30
+ });
26
31
  </script>
27
32
 
28
33
  <div class="list-item {classes}" on:click|preventDefault={onClick}>
@@ -63,13 +68,21 @@
63
68
  }}
64
69
  >
65
70
  {#if titleComponent}
66
- <svelte:component
67
- this={titleComponent}
68
- {title}
69
- {...titleComponentProps}
70
- />
71
+ {#if typeof title === "string"}
72
+ <svelte:component
73
+ this={titleComponent}
74
+ {title}
75
+ {...titleComponentProps}
76
+ />
77
+ {:else}
78
+ <svelte:component
79
+ this={titleComponent}
80
+ {...title}
81
+ {...titleComponentProps}
82
+ />
83
+ {/if}
71
84
  {:else}
72
- {description}
85
+ {title}
73
86
  {/if}
74
87
  </div>
75
88
  {/if}
@@ -93,9 +106,9 @@
93
106
  </div>
94
107
  {/if}
95
108
  </div>
96
- {#if actions && actions.length}
109
+ {#if allActions && allActions.length}
97
110
  <div class="list-item-controls">
98
- <UIButtons values={actions} right={true} />
111
+ <UIButtons values={allActions} right={true} />
99
112
  </div>
100
113
  {/if}
101
114
  </div>
@@ -6,6 +6,7 @@
6
6
 
7
7
  export let classes = "";
8
8
  export let items = [];
9
+ export let actions = [];
9
10
 
10
11
  export let actionsVisible = false;
11
12
  export let itemsHoverable = false;
@@ -54,6 +55,7 @@
54
55
  {descriptionComponentProps}
55
56
  {imageComponent}
56
57
  {imageComponentProps}
58
+ {actions}
57
59
  on:click
58
60
  on:clickContent
59
61
  on:clickDescription
@@ -5,13 +5,11 @@
5
5
  export let id = "taggedValueId";
6
6
  export let title; //UITag props
7
7
  export let value; //UITag props
8
+ export let classes = "";
8
9
  </script>
9
10
 
10
- <div class="tags has-addons" {id}>
11
+ <div class="tags has-addons {classes}" {id}>
11
12
  {#if title}
12
- <UITag {...title} />
13
- {/if}
14
- {#if value}
15
- <UITag {...value} />
13
+ <UITag {...title} />{/if}{#if value}<UITag {...value} />
16
14
  {/if}
17
15
  </div>
@@ -655,6 +655,14 @@ class notCommon {
655
655
  notCommon.getApp() &&
656
656
  notCommon.getApp().getWorking("router").navigate(url);
657
657
  }
658
+
659
+ static select(variantsSet, value, def) {
660
+ if (Object.hasOwn(variantsSet, value)) {
661
+ return variantsSet[value];
662
+ } else {
663
+ return def;
664
+ }
665
+ }
658
666
  }
659
667
 
660
668
  function absorbServices(target, src) {