not-bulma 1.0.42 → 1.0.44
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,82 +1,100 @@
|
|
|
1
1
|
<script>
|
|
2
|
+
import UICommon from "../common.js";
|
|
3
|
+
import ErrorsList from "../various/ui.errors.list.svelte";
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
import { createEventDispatcher } from "svelte";
|
|
6
|
+
let dispatch = createEventDispatcher();
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
let dispatch = createEventDispatcher();
|
|
8
|
+
export let inputStarted = false;
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
export let value = new Date();
|
|
11
|
+
export let placeholder = "Date and time of event";
|
|
12
|
+
export let fieldname = "datetime";
|
|
13
|
+
export let icon = false;
|
|
14
|
+
export let required = true;
|
|
15
|
+
export let readonly = false;
|
|
16
|
+
export let valid = true;
|
|
17
|
+
export let validated = false;
|
|
18
|
+
export let errors = false;
|
|
19
|
+
export let formErrors = false;
|
|
20
|
+
export let formLevelError = false;
|
|
10
21
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
$: iconClasses = (icon ? " has-icons-left " : "") + " has-icons-right ";
|
|
23
|
+
$: allErrors = [].concat(
|
|
24
|
+
errors ? errors : [],
|
|
25
|
+
formErrors ? formErrors : []
|
|
26
|
+
);
|
|
27
|
+
$: invalid = valid === false || formLevelError;
|
|
28
|
+
$: showErrors = !(validated && valid) && inputStarted;
|
|
29
|
+
$: validationClasses =
|
|
30
|
+
valid === true || !inputStarted
|
|
31
|
+
? UICommon.CLASS_OK
|
|
32
|
+
: UICommon.CLASS_ERR;
|
|
22
33
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
value: ev.currentTarget.value
|
|
33
|
-
};
|
|
34
|
-
inputStarted = true;
|
|
35
|
-
dispatch('change', data);
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function onInput(ev){
|
|
40
|
-
let data = {
|
|
41
|
-
field: fieldname,
|
|
42
|
-
value: ev.currentTarget.value
|
|
43
|
-
};
|
|
44
|
-
inputStarted = true;
|
|
45
|
-
dispatch('change', data);
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
34
|
+
function onBlur(ev) {
|
|
35
|
+
let data = {
|
|
36
|
+
field: fieldname,
|
|
37
|
+
value: ev.currentTarget.value,
|
|
38
|
+
};
|
|
39
|
+
inputStarted = true;
|
|
40
|
+
dispatch("change", data);
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
48
43
|
|
|
44
|
+
function onInput(ev) {
|
|
45
|
+
let data = {
|
|
46
|
+
field: fieldname,
|
|
47
|
+
value: ev.currentTarget.value,
|
|
48
|
+
};
|
|
49
|
+
inputStarted = true;
|
|
50
|
+
dispatch("change", data);
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
49
53
|
</script>
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
{#if readonly
|
|
53
|
-
|
|
55
|
+
<div class="control {iconClasses}">
|
|
56
|
+
{#if readonly}
|
|
57
|
+
<p>
|
|
58
|
+
<time datetime={value}
|
|
59
|
+
>{UICommon.tryFormatLocaleDateTime(value)}</time
|
|
60
|
+
>
|
|
61
|
+
</p>
|
|
54
62
|
{:else}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
63
|
+
<input
|
|
64
|
+
class="input {validationClasses}"
|
|
65
|
+
id="form-field-date-{fieldname}"
|
|
66
|
+
type="date"
|
|
67
|
+
name={fieldname}
|
|
68
|
+
{invalid}
|
|
69
|
+
{required}
|
|
70
|
+
{placeholder}
|
|
71
|
+
bind:value
|
|
72
|
+
{readonly}
|
|
73
|
+
autocomplete={fieldname}
|
|
74
|
+
aria-controls="input-field-helper-{fieldname}"
|
|
75
|
+
on:change={onBlur}
|
|
76
|
+
on:input={onInput}
|
|
77
|
+
aria-describedby="input-field-helper-{fieldname}"
|
|
78
|
+
/>
|
|
79
|
+
{#if icon}
|
|
80
|
+
<span class="icon is-small is-left"
|
|
81
|
+
><i class="fas fa-{icon}" /></span
|
|
82
|
+
>
|
|
83
|
+
{/if}
|
|
84
|
+
{#if validated === true}
|
|
85
|
+
<span class="icon is-small is-right">
|
|
86
|
+
{#if valid === true}
|
|
87
|
+
<i class="fas fa-check" />
|
|
88
|
+
{:else if valid === false}
|
|
89
|
+
<i class="fas fa-exclamation-triangle" />
|
|
90
|
+
{/if}
|
|
91
|
+
</span>
|
|
92
|
+
{/if}
|
|
75
93
|
{/if}
|
|
76
|
-
|
|
77
|
-
|
|
94
|
+
</div>
|
|
95
|
+
<ErrorsList
|
|
78
96
|
bind:errors={allErrors}
|
|
79
97
|
bind:show={showErrors}
|
|
80
98
|
bind:classes={validationClasses}
|
|
81
99
|
id="input-field-helper-{fieldname}"
|
|
82
|
-
|
|
100
|
+
/>
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
export let value = 0;
|
|
9
9
|
export let placeholder = "0.0";
|
|
10
10
|
export let min = 0;
|
|
11
|
-
export let max =
|
|
12
|
-
export let step =
|
|
11
|
+
export let max = 100;
|
|
12
|
+
export let step = 1;
|
|
13
13
|
export let fieldname = "number";
|
|
14
14
|
export let icon = false;
|
|
15
15
|
export let required = true;
|
|
@@ -1,185 +1,189 @@
|
|
|
1
|
-
import Menu from
|
|
2
|
-
import UISideMenu from
|
|
1
|
+
import Menu from "../menu.js";
|
|
2
|
+
import UISideMenu from "./ui.side.menu.svelte";
|
|
3
3
|
|
|
4
|
-
const TYPE =
|
|
4
|
+
const TYPE = "side";
|
|
5
5
|
|
|
6
6
|
class notSideMenu extends Menu {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
7
|
+
static nav;
|
|
8
|
+
static main;
|
|
9
|
+
static aside;
|
|
10
|
+
|
|
11
|
+
static DEFAULT = {
|
|
12
|
+
section: "any",
|
|
13
|
+
sectionTitle: "Меню",
|
|
14
|
+
priority: 0,
|
|
15
|
+
open: false,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
static options = {
|
|
19
|
+
type: TYPE,
|
|
20
|
+
items: [],
|
|
21
|
+
sections: [],
|
|
22
|
+
targetSelector: `#${TYPE}-menu`,
|
|
23
|
+
toggleSelector: `.${TYPE}-menu-toggle`,
|
|
24
|
+
root: "/",
|
|
25
|
+
open: false,
|
|
26
|
+
navigate: (urls) => {
|
|
27
|
+
this.hide();
|
|
28
|
+
if (!this.isDirectNavigation() && this.app) {
|
|
29
|
+
let func = this.app.getWorking("router");
|
|
30
|
+
if (func) {
|
|
31
|
+
return func.navigate(urls.short);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
document.location.assign(urls.full);
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
static render(app) {
|
|
39
|
+
if (app) {
|
|
40
|
+
this.setApp(app);
|
|
41
|
+
}
|
|
42
|
+
this.prepareData();
|
|
43
|
+
if (!this.menu) {
|
|
44
|
+
this.createUI();
|
|
32
45
|
}
|
|
33
|
-
}
|
|
34
|
-
document.location.assign(urls.full);
|
|
35
46
|
}
|
|
36
|
-
};
|
|
37
47
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
48
|
+
static update() {
|
|
49
|
+
if (this.menu) {
|
|
50
|
+
this.menu.$destroy();
|
|
51
|
+
this.createUI();
|
|
52
|
+
}
|
|
41
53
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
54
|
+
|
|
55
|
+
static createUI() {
|
|
56
|
+
let target = document.querySelector(this.getOptions().targetSelector);
|
|
57
|
+
if (!target) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
this.menu = new UISideMenu({
|
|
61
|
+
target,
|
|
62
|
+
props: {
|
|
63
|
+
items: this.items,
|
|
64
|
+
sections: this.sections,
|
|
65
|
+
root: this.getOptions().root,
|
|
66
|
+
navigate: this.getOptions().navigate,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
this.initSizeResponse();
|
|
70
|
+
this.interval = setInterval(this.updateMenuActiveItem.bind(this), 200);
|
|
71
|
+
this.bindToggle();
|
|
45
72
|
}
|
|
46
|
-
}
|
|
47
73
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
this.menu.$destroy();
|
|
51
|
-
this.createUI();
|
|
74
|
+
static itemIsActive(itemURL) {
|
|
75
|
+
return (this.location + "/").indexOf(itemURL + "/") > -1;
|
|
52
76
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
navigate: this.getOptions().navigate
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
this.initSizeResponse();
|
|
68
|
-
this.interval = setInterval(this.updateMenuActiveItem.bind(this), 200);
|
|
69
|
-
this.bindToggle();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
static itemIsActive(itemURL) {
|
|
73
|
-
return ((this.location + '/').indexOf(itemURL + '/') > -1);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
static updateMenu() {
|
|
77
|
-
Array.from(document.querySelectorAll(this.getOptions().targetSelector + ' a')).forEach((item) => {
|
|
78
|
-
if (this.itemIsActive(item.getAttribute('href'))) {
|
|
79
|
-
item.classList.add('is-active');
|
|
80
|
-
} else {
|
|
81
|
-
item.classList.remove('is-active');
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
static updateMenuActiveItem() {
|
|
87
|
-
let url = window.location.toString(),
|
|
88
|
-
lastLocation = this.location;
|
|
89
|
-
if (lastLocation) {
|
|
90
|
-
if (url !== lastLocation) {
|
|
91
|
-
this.location = url;
|
|
92
|
-
this.updateMenu();
|
|
93
|
-
}
|
|
94
|
-
} else {
|
|
95
|
-
this.location = url;
|
|
96
|
-
this.updateMenu();
|
|
77
|
+
|
|
78
|
+
static updateMenu() {
|
|
79
|
+
Array.from(
|
|
80
|
+
document.querySelectorAll(this.getOptions().targetSelector + " a")
|
|
81
|
+
).forEach((item) => {
|
|
82
|
+
if (this.itemIsActive(item.getAttribute("href"))) {
|
|
83
|
+
item.classList.add("is-active");
|
|
84
|
+
} else {
|
|
85
|
+
item.classList.remove("is-active");
|
|
86
|
+
}
|
|
87
|
+
});
|
|
97
88
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
89
|
+
|
|
90
|
+
static updateMenuActiveItem() {
|
|
91
|
+
let url = window.location.toString(),
|
|
92
|
+
lastLocation = this.location;
|
|
93
|
+
if (lastLocation) {
|
|
94
|
+
if (url !== lastLocation) {
|
|
95
|
+
this.location = url;
|
|
96
|
+
this.updateMenu();
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
this.location = url;
|
|
100
|
+
this.updateMenu();
|
|
101
|
+
}
|
|
111
102
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
this.
|
|
118
|
-
|
|
119
|
-
this.
|
|
120
|
-
this.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
103
|
+
|
|
104
|
+
static initSizeResponse() {
|
|
105
|
+
this.nav = document.querySelector("nav.navbar");
|
|
106
|
+
this.aside = document.querySelector("aside");
|
|
107
|
+
this.main = document.querySelector("main");
|
|
108
|
+
this.resizeAsideAndMain(this.aside, this.main, this.nav);
|
|
109
|
+
this.resizeMain(this.main, this.aside);
|
|
110
|
+
window.addEventListener("resize", this.resizeMain.bind(this));
|
|
111
|
+
if (this.getOptions().open) {
|
|
112
|
+
this.show();
|
|
113
|
+
} else {
|
|
114
|
+
this.hide();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
static resizeMain() {
|
|
119
|
+
if (this.isTouch()) {
|
|
120
|
+
if (this.aside.classList.contains("is-active")) {
|
|
121
|
+
this.main.style.display = "none";
|
|
122
|
+
} else {
|
|
123
|
+
this.main.style.display = "block";
|
|
124
|
+
this.main.style.marginLeft = "0px";
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
let rect = this.aside.getBoundingClientRect();
|
|
128
|
+
this.main.style.display = "block";
|
|
129
|
+
if (this.main.style.height === "0px") {
|
|
130
|
+
this.main.style.height = "auto";
|
|
131
|
+
}
|
|
132
|
+
this.main.style.marginLeft = rect.width + rect.left + "px";
|
|
133
|
+
}
|
|
129
134
|
}
|
|
130
|
-
}
|
|
131
135
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
static resizeAside() {
|
|
137
|
+
if (this.aside.style.display !== "none") {
|
|
138
|
+
let rect = this.nav.getBoundingClientRect();
|
|
139
|
+
this.aside.style.height = window.innerHeight - rect.height + "px";
|
|
140
|
+
this.aside.style.marginTop = rect.height + "px";
|
|
141
|
+
}
|
|
137
142
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
143
|
+
|
|
144
|
+
static resizeAsideAndMain() {
|
|
145
|
+
let rect = this.nav.getBoundingClientRect();
|
|
146
|
+
this.aside.style.height = window.innerHeight - rect.height + "px";
|
|
147
|
+
//this.aside.style.paddingTop = (rect.height) + 'px';
|
|
148
|
+
//this.main.style.marginTop = (rect.height) + 'px';
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
static bindToggle() {
|
|
152
|
+
let els = document.querySelectorAll(this.getOptions().toggleSelector);
|
|
153
|
+
Array.from(els).forEach((el) => {
|
|
154
|
+
el.removeEventListener("click", this.toggle.bind(this));
|
|
155
|
+
el.addEventListener("click", this.toggle.bind(this));
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
static toggle(e) {
|
|
160
|
+
e && e.preventDefault();
|
|
161
|
+
this.aside.classList.toggle("is-active");
|
|
162
|
+
this.resizeMain();
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
static hide(e) {
|
|
167
|
+
e && e.preventDefault();
|
|
168
|
+
this.aside.classList.remove("is-active");
|
|
169
|
+
this.resizeMain();
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
static show(e) {
|
|
174
|
+
e && e.preventDefault();
|
|
175
|
+
this.classList.add("is-active");
|
|
176
|
+
this.resizeMain();
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
static isOpen() {
|
|
181
|
+
if (this.aside) {
|
|
182
|
+
return this.aside.classList.contains("is-active");
|
|
183
|
+
} else {
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
181
186
|
}
|
|
182
|
-
}
|
|
183
187
|
}
|
|
184
188
|
|
|
185
189
|
export default notSideMenu;
|
package/src/frame/index.js
CHANGED
|
@@ -3,67 +3,71 @@
|
|
|
3
3
|
/*
|
|
4
4
|
Common functions
|
|
5
5
|
*/
|
|
6
|
-
import notCommon from
|
|
6
|
+
import notCommon from "./common.js";
|
|
7
7
|
|
|
8
8
|
/*
|
|
9
9
|
framework wide parser for data access
|
|
10
10
|
*/
|
|
11
|
-
import notPath from
|
|
11
|
+
import notPath from "not-path";
|
|
12
12
|
|
|
13
|
+
import notRouter from "./router.js";
|
|
13
14
|
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
import * as notAPI from './api';
|
|
15
|
+
import * as notAPI from "./api";
|
|
16
|
+
import * as notStores from "./stores";
|
|
17
17
|
/*
|
|
18
18
|
basic event handlers and core data modifiers
|
|
19
19
|
*/
|
|
20
|
-
import notBase from
|
|
20
|
+
import notBase from "./base.js";
|
|
21
21
|
|
|
22
|
-
import {COMPONENTS, FIELDS, VARIANTS} from
|
|
22
|
+
import { COMPONENTS, FIELDS, VARIANTS } from "./LIB.js";
|
|
23
23
|
/*
|
|
24
24
|
application main infrastructure setter
|
|
25
25
|
*/
|
|
26
|
-
import notApp from
|
|
26
|
+
import notApp from "./app.js";
|
|
27
27
|
/*
|
|
28
28
|
user controllers
|
|
29
29
|
*/
|
|
30
|
-
import notController from
|
|
31
|
-
import notRecord from
|
|
32
|
-
import notInterface from
|
|
30
|
+
import notController from "./controller.js";
|
|
31
|
+
import notRecord from "./record.js"; // wrapper for data with server live interactions
|
|
32
|
+
import notInterface from "./interface.js"; // wrapper for data with server live interactions
|
|
33
33
|
|
|
34
34
|
import {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
} from
|
|
35
|
+
notTable,
|
|
36
|
+
UIForm,
|
|
37
|
+
notForm,
|
|
38
|
+
notFormSet,
|
|
39
|
+
notFormUtils,
|
|
40
|
+
notBreadcrumbs,
|
|
41
|
+
notTopMenu,
|
|
42
|
+
notSideMenu,
|
|
43
|
+
} from "./components";
|
|
44
44
|
|
|
45
|
-
import notCRUD from
|
|
45
|
+
import notCRUD from "./crud/controller.crud.js";
|
|
46
46
|
|
|
47
47
|
const ncCRUD = notCRUD; //legacy alias
|
|
48
48
|
|
|
49
49
|
export {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
50
|
+
notCommon,
|
|
51
|
+
notPath,
|
|
52
|
+
notController,
|
|
53
|
+
notBase,
|
|
54
|
+
notRouter,
|
|
55
|
+
notRecord,
|
|
56
|
+
notInterface,
|
|
57
|
+
notApp,
|
|
58
|
+
notAPI,
|
|
59
|
+
notStores,
|
|
60
|
+
notCRUD,
|
|
61
|
+
ncCRUD,
|
|
62
|
+
COMPONENTS,
|
|
63
|
+
FIELDS,
|
|
64
|
+
VARIANTS,
|
|
65
|
+
notTable,
|
|
66
|
+
UIForm,
|
|
67
|
+
notForm,
|
|
68
|
+
notFormSet,
|
|
69
|
+
notFormUtils,
|
|
70
|
+
notBreadcrumbs,
|
|
71
|
+
notTopMenu,
|
|
72
|
+
notSideMenu,
|
|
69
73
|
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { writable } from "svelte/store";
|
|
2
|
+
|
|
3
|
+
const ALL = {};
|
|
4
|
+
|
|
5
|
+
function exist(key) {
|
|
6
|
+
return Object.hasOwn(ALL, key);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function get(key) {
|
|
10
|
+
if (exist(key)) {
|
|
11
|
+
return ALL[key];
|
|
12
|
+
} else {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function create(
|
|
18
|
+
key,
|
|
19
|
+
props = {
|
|
20
|
+
raw: [],
|
|
21
|
+
filtered: [],
|
|
22
|
+
selected: {},
|
|
23
|
+
}
|
|
24
|
+
) {
|
|
25
|
+
if (!exist(key)) {
|
|
26
|
+
if (Object.keys(props).length > 0) {
|
|
27
|
+
ALL[key] = {};
|
|
28
|
+
Object.keys(props).forEach((name) => {
|
|
29
|
+
ALL[key][name] = writable(props[name]);
|
|
30
|
+
});
|
|
31
|
+
} else {
|
|
32
|
+
throw new Error("store's props wasn't specified");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return ALL[key];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Creates object that is fake Store
|
|
40
|
+
* Some time this is useful when you need to initialize local var,
|
|
41
|
+
* before you could get actual Stores from central storage by its ID
|
|
42
|
+
* @params {mixed} val data of type that is actual storage will contain
|
|
43
|
+
* @returns {Object}
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
function fake(val) {
|
|
47
|
+
return {
|
|
48
|
+
subscribe(f) {
|
|
49
|
+
f(val);
|
|
50
|
+
return () => {};
|
|
51
|
+
},
|
|
52
|
+
set() {},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { create, get, fake };
|