not-bulma 2.0.13 → 2.0.15
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/dist/notBulma.css +1 -1
- package/dist/notBulma.js +15063 -17597
- package/dist/notBulma.min.js +2 -2
- package/package.json +1 -1
- package/src/elements/button/ui.button.switch.svelte +19 -24
- package/src/elements/button/ui.buttons.row.svelte +5 -4
- package/src/elements/button/ui.buttons.svelte +4 -0
- package/src/elements/button/ui.buttons.switchers.svelte +23 -23
- package/src/frame/components/form/form.set.svelte.js +12 -14
- package/src/frame/components/form/form.svelte.js +40 -36
- package/src/frame/components/form/index.js +1 -1
- package/src/frame/components/navigation/menu.svelte.js +47 -30
- package/src/frame/components/navigation/top.menu.svelte.js +14 -16
- package/src/frame/components/table/notTable.svelte.js +67 -71
- package/src/frame/crud/controller.crud.svelte.js +21 -19
package/package.json
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { run } from
|
|
2
|
+
import { run } from "svelte/legacy";
|
|
3
3
|
|
|
4
4
|
import UIButton from "./ui.button.svelte";
|
|
5
|
-
import { createEventDispatcher } from "svelte";
|
|
6
|
-
|
|
7
|
-
const dispatch = createEventDispatcher();
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
5
|
|
|
13
6
|
/**
|
|
14
7
|
* @typedef {Object} Props
|
|
@@ -44,7 +37,7 @@
|
|
|
44
37
|
inverted = false,
|
|
45
38
|
rounded = false,
|
|
46
39
|
disabled = false,
|
|
47
|
-
state = "",
|
|
40
|
+
state: notState = "",
|
|
48
41
|
type = "",
|
|
49
42
|
color = "",
|
|
50
43
|
size = "",
|
|
@@ -52,30 +45,32 @@
|
|
|
52
45
|
icon = false,
|
|
53
46
|
iconSide = "right",
|
|
54
47
|
uiOff = () => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
return {
|
|
49
|
+
color: "",
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
onchange = () => {},
|
|
53
|
+
onclick = () => {},
|
|
59
54
|
uiOn = () => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
return {
|
|
56
|
+
color: "success",
|
|
57
|
+
};
|
|
58
|
+
},
|
|
64
59
|
action = () => {
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
return !selected;
|
|
61
|
+
},
|
|
67
62
|
value,
|
|
68
|
-
selected = $bindable(false)
|
|
63
|
+
selected = $bindable(false),
|
|
69
64
|
} = $props();
|
|
70
65
|
|
|
71
66
|
function onClick(event) {
|
|
72
67
|
selected = action(event, value, selected);
|
|
73
|
-
|
|
68
|
+
onclick({ value, selected });
|
|
74
69
|
onChange();
|
|
75
70
|
}
|
|
76
71
|
|
|
77
72
|
function onChange() {
|
|
78
|
-
|
|
73
|
+
onchange({
|
|
79
74
|
value,
|
|
80
75
|
selected,
|
|
81
76
|
});
|
|
@@ -100,7 +95,7 @@
|
|
|
100
95
|
{inverted}
|
|
101
96
|
{rounded}
|
|
102
97
|
{disabled}
|
|
103
|
-
{
|
|
98
|
+
state={notState}
|
|
104
99
|
{type}
|
|
105
100
|
{color}
|
|
106
101
|
{size}
|
|
@@ -108,5 +103,5 @@
|
|
|
108
103
|
{icon}
|
|
109
104
|
{iconSide}
|
|
110
105
|
{value}
|
|
111
|
-
|
|
106
|
+
onclick={onClick}
|
|
112
107
|
></UIButton>
|
|
@@ -14,18 +14,19 @@
|
|
|
14
14
|
classes = "",
|
|
15
15
|
left = [],
|
|
16
16
|
center = [],
|
|
17
|
-
right = []
|
|
17
|
+
right = [],
|
|
18
|
+
disabled = false,
|
|
18
19
|
} = $props();
|
|
19
20
|
</script>
|
|
20
21
|
|
|
21
22
|
<div class="columns {classes}">
|
|
22
23
|
<div class="column">
|
|
23
|
-
<UIButtons values={left}></UIButtons>
|
|
24
|
+
<UIButtons values={left} {disabled}></UIButtons>
|
|
24
25
|
</div>
|
|
25
26
|
<div class="column">
|
|
26
|
-
<UIButtons values={center} centered={true}></UIButtons>
|
|
27
|
+
<UIButtons values={center} centered={true} {disabled}></UIButtons>
|
|
27
28
|
</div>
|
|
28
29
|
<div class="column">
|
|
29
|
-
<UIButtons values={right} right={true}></UIButtons>
|
|
30
|
+
<UIButtons values={right} right={true} {disabled}></UIButtons>
|
|
30
31
|
</div>
|
|
31
32
|
</div>
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
let {
|
|
18
18
|
values = [],
|
|
19
19
|
centered = false,
|
|
20
|
+
disabled = false,
|
|
20
21
|
right = false,
|
|
21
22
|
classes = "",
|
|
22
23
|
buttonComponent = UIButton,
|
|
@@ -41,6 +42,9 @@
|
|
|
41
42
|
{@const SvelteComponent = buttonComponent}
|
|
42
43
|
<SvelteComponent
|
|
43
44
|
{...item}
|
|
45
|
+
disabled={Object.hasOwn(item, "disabled")
|
|
46
|
+
? item.disabled
|
|
47
|
+
: disabled}
|
|
44
48
|
bind:value={item.value}
|
|
45
49
|
action={item.action ? item.action : action}
|
|
46
50
|
{onclick}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
const dispatch = createEventDispatcher();
|
|
4
4
|
import UIButtonSwitch from "./ui.button.switch.svelte";
|
|
5
5
|
|
|
6
|
-
|
|
7
6
|
const selectHistory = [];
|
|
8
7
|
|
|
9
8
|
export function selectAll() {
|
|
@@ -84,7 +83,6 @@
|
|
|
84
83
|
}
|
|
85
84
|
}
|
|
86
85
|
|
|
87
|
-
|
|
88
86
|
/**
|
|
89
87
|
* @typedef {Object} Props
|
|
90
88
|
* @property {any} [values]
|
|
@@ -105,29 +103,31 @@
|
|
|
105
103
|
classes = "",
|
|
106
104
|
buttonComponent = UIButtonSwitch,
|
|
107
105
|
action = (ev, value, selected) => {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
let newSelected = !selected;
|
|
107
|
+
const indexOfCurrent = values.indexOf((itm) => itm.value === value);
|
|
108
|
+
const cnt = countSelected() + (newSelected ? 1 : -1);
|
|
111
109
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
110
|
+
if (min) {
|
|
111
|
+
if (cnt < min) {
|
|
112
|
+
selectUpToMin(cnt, indexOfCurrent);
|
|
113
|
+
values = values;
|
|
114
|
+
}
|
|
116
115
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
116
|
+
if (max) {
|
|
117
|
+
if (max < cnt) {
|
|
118
|
+
deselectDownToMin(cnt, indexOfCurrent);
|
|
119
|
+
values = values;
|
|
120
|
+
}
|
|
122
121
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
},
|
|
122
|
+
if (newSelected) {
|
|
123
|
+
addToHistory(indexOfCurrent);
|
|
124
|
+
}
|
|
125
|
+
return newSelected;
|
|
126
|
+
},
|
|
129
127
|
min = 0,
|
|
130
|
-
max = 100
|
|
128
|
+
max = 100,
|
|
129
|
+
onclick = () => {},
|
|
130
|
+
onchange = () => {},
|
|
131
131
|
} = $props();
|
|
132
132
|
</script>
|
|
133
133
|
|
|
@@ -143,8 +143,8 @@
|
|
|
143
143
|
bind:value={item.value}
|
|
144
144
|
bind:selected={item.selected}
|
|
145
145
|
action={item.action ? item.action : action}
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
{onclick}
|
|
147
|
+
{onchange}
|
|
148
148
|
/>
|
|
149
149
|
{/each}
|
|
150
150
|
</div>
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import Lib from "
|
|
2
|
-
import notCommon from "
|
|
3
|
-
import notBase from "
|
|
1
|
+
import Lib from "../../lib.js";
|
|
2
|
+
import notCommon from "../../common.js";
|
|
3
|
+
import notBase from "../../base.js";
|
|
4
4
|
|
|
5
5
|
import UIAdapterSvelte from "../../ui.adapter.svelte";
|
|
6
6
|
|
|
7
|
-
import UIFormSetComponent from "
|
|
7
|
+
import UIFormSetComponent from "./form.set.svelte";
|
|
8
8
|
import UIFormComponent from "./form.svelte";
|
|
9
9
|
|
|
10
10
|
const DEFAULT_CONTAINER_SELECTOR = ".form-set";
|
|
11
11
|
const DEFAULT_FORM_SET_NAME = "form-set";
|
|
12
12
|
|
|
13
|
-
|
|
14
13
|
class notFormSet extends notBase {
|
|
15
14
|
#formSetComponent = null;
|
|
16
15
|
#formComponent = null;
|
|
@@ -18,7 +17,6 @@ class notFormSet extends notBase {
|
|
|
18
17
|
#form = null;
|
|
19
18
|
#frame = null;
|
|
20
19
|
|
|
21
|
-
|
|
22
20
|
/*
|
|
23
21
|
new notFormSet({
|
|
24
22
|
options:{
|
|
@@ -64,11 +62,11 @@ class notFormSet extends notBase {
|
|
|
64
62
|
**/
|
|
65
63
|
initUI() {
|
|
66
64
|
const target = this.getFrameTargetEl();
|
|
67
|
-
while (target.children.length) target.removeChild(target.firstChild);
|
|
65
|
+
while (target.children.length) target.removeChild(target.firstChild);
|
|
68
66
|
this.#frame = new UIAdapterSvelte(
|
|
69
|
-
this.#formSetComponent,
|
|
67
|
+
this.#formSetComponent,
|
|
70
68
|
target,
|
|
71
|
-
this.#getFrameProps()
|
|
69
|
+
this.#getFrameProps()
|
|
72
70
|
);
|
|
73
71
|
this.updateForm();
|
|
74
72
|
}
|
|
@@ -83,8 +81,8 @@ class notFormSet extends notBase {
|
|
|
83
81
|
}
|
|
84
82
|
|
|
85
83
|
updateFormModeInUI() {
|
|
86
|
-
if (this.#frame && this.getWorking("mode") !== null
|
|
87
|
-
this.#frame.set(
|
|
84
|
+
if (this.#frame && this.getWorking("mode") !== null) {
|
|
85
|
+
this.#frame.set("mode", this.getWorking("mode"));
|
|
88
86
|
}
|
|
89
87
|
}
|
|
90
88
|
|
|
@@ -194,11 +192,11 @@ class notFormSet extends notBase {
|
|
|
194
192
|
showModes: this.getOptions("showModes", true),
|
|
195
193
|
mode: this.getFormMode(),
|
|
196
194
|
forms: this.getOptions("forms", []),
|
|
197
|
-
name: this.getOptions("name", DEFAULT_FORM_SET_NAME),
|
|
198
|
-
onmode: (newMode)=>{
|
|
195
|
+
name: this.getOptions("name", DEFAULT_FORM_SET_NAME),
|
|
196
|
+
onmode: (newMode) => {
|
|
199
197
|
this.setFormMode(newMode);
|
|
200
198
|
this.updateForm();
|
|
201
|
-
}
|
|
199
|
+
},
|
|
202
200
|
};
|
|
203
201
|
}
|
|
204
202
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Runner } from "not-validation";
|
|
2
2
|
import UIAdapterSvelte from "../../ui.adapter.svelte";
|
|
3
3
|
|
|
4
|
-
import { VARIANTS } from "
|
|
5
|
-
import Lib from "
|
|
6
|
-
import notCommon from "
|
|
7
|
-
import notBase from "
|
|
4
|
+
import { VARIANTS } from "../../LIB.js";
|
|
5
|
+
import Lib from "../../lib.js";
|
|
6
|
+
import notCommon from "../../common.js";
|
|
7
|
+
import notBase from "../../base.js";
|
|
8
8
|
|
|
9
|
-
import UICommon from "
|
|
10
|
-
import FormHelpers from "
|
|
11
|
-
import UIFormComponent from "
|
|
12
|
-
import notFormRules from "
|
|
9
|
+
import UICommon from "../../../elements/common.js";
|
|
10
|
+
import FormHelpers from "./form.helpers.js";
|
|
11
|
+
import UIFormComponent from "./form.svelte";
|
|
12
|
+
import notFormRules from "./form.rules.js";
|
|
13
13
|
|
|
14
|
-
import { DEFAULT_STATUS_SUCCESS, DEFAULT_STATUS_ERROR } from "
|
|
14
|
+
import { DEFAULT_STATUS_SUCCESS, DEFAULT_STATUS_ERROR } from "../../const.js";
|
|
15
15
|
|
|
16
16
|
const DEFAULT_CONTAINER_SELECTOR = ".form";
|
|
17
17
|
const DEFAULT_ACTION_NAME = "default";
|
|
@@ -104,13 +104,13 @@ class notForm extends notBase {
|
|
|
104
104
|
formOptions: this.getFormOptions(),
|
|
105
105
|
data: this.getFormData(),
|
|
106
106
|
injectedProps: this.getFormInjectedProps(),
|
|
107
|
-
});
|
|
107
|
+
});
|
|
108
108
|
const target = this.getFormTargetEl();
|
|
109
|
-
while (target.children.length){
|
|
109
|
+
while (target.children.length) {
|
|
110
110
|
target.removeChild(target.firstChild);
|
|
111
111
|
}
|
|
112
112
|
this.#form = new UIAdapterSvelte(this.#uiComponent, target, props);
|
|
113
|
-
|
|
113
|
+
|
|
114
114
|
this.#bindUIEvents();
|
|
115
115
|
this.validateForm();
|
|
116
116
|
} catch (e) {
|
|
@@ -125,7 +125,7 @@ class notForm extends notBase {
|
|
|
125
125
|
formOptions: this.getFormOptions(),
|
|
126
126
|
data: this.getFormData(),
|
|
127
127
|
injectedProps: this.getFormInjectedProps(),
|
|
128
|
-
});
|
|
128
|
+
});
|
|
129
129
|
this.#form.replaceProps(props);
|
|
130
130
|
this.validateForm();
|
|
131
131
|
} catch (e) {
|
|
@@ -134,14 +134,14 @@ class notForm extends notBase {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
#bindUIEvents() {
|
|
137
|
-
this.#form.on(
|
|
137
|
+
this.#form.on("onchange", (event) => {
|
|
138
138
|
this.validateForm();
|
|
139
139
|
this.emit("onchange", event);
|
|
140
140
|
this.emit(`onchange.${event.field}`, event.value);
|
|
141
141
|
});
|
|
142
|
-
this.#form.on(
|
|
143
|
-
this.#form.on(
|
|
144
|
-
this.#form.on(
|
|
142
|
+
this.#form.on("onsubmit", (event) => this.submit(event));
|
|
143
|
+
this.#form.on("onreject", () => this.reject());
|
|
144
|
+
this.#form.on("onerror", (event) => this.emit("onerror", event));
|
|
145
145
|
this.#bindMasterSlaveEvents();
|
|
146
146
|
}
|
|
147
147
|
|
|
@@ -173,8 +173,6 @@ class notForm extends notBase {
|
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
|
|
178
176
|
async validateForm() {
|
|
179
177
|
if (this.getOptions("readonly", false)) {
|
|
180
178
|
return;
|
|
@@ -184,7 +182,9 @@ class notForm extends notBase {
|
|
|
184
182
|
this.collectData(),
|
|
185
183
|
this.getFormAction()
|
|
186
184
|
);
|
|
187
|
-
this.#form.exec(
|
|
185
|
+
this.#form.exec("updateFormValidationStatus", [
|
|
186
|
+
validationResult.getReport(),
|
|
187
|
+
]);
|
|
188
188
|
if (!validationResult.clean) {
|
|
189
189
|
this.emit("onerror", validationResult.getReport());
|
|
190
190
|
}
|
|
@@ -192,7 +192,8 @@ class notForm extends notBase {
|
|
|
192
192
|
const report = {
|
|
193
193
|
form: [UICommon.ERROR_DEFAULT, e.message],
|
|
194
194
|
};
|
|
195
|
-
this.#form &&
|
|
195
|
+
this.#form &&
|
|
196
|
+
this.#form.exec("updateFormValidationStatus", [report]);
|
|
196
197
|
this.emit("onerror", report);
|
|
197
198
|
notCommon.report(e);
|
|
198
199
|
}
|
|
@@ -209,18 +210,18 @@ class notForm extends notBase {
|
|
|
209
210
|
//binding event to actual UI
|
|
210
211
|
$on() {
|
|
211
212
|
if (this.#form) {
|
|
212
|
-
this.#form.on(...arguments);
|
|
213
|
+
this.#form.on(...arguments);
|
|
213
214
|
}
|
|
214
215
|
}
|
|
215
216
|
|
|
216
217
|
setLoading() {
|
|
217
218
|
this.emit("onloading");
|
|
218
|
-
this.#form.set(
|
|
219
|
+
this.#form.set("loading", true);
|
|
219
220
|
}
|
|
220
221
|
|
|
221
222
|
resetLoading() {
|
|
222
223
|
this.emit("onloaded");
|
|
223
|
-
this.#form.set(
|
|
224
|
+
this.#form.set("loading", false);
|
|
224
225
|
}
|
|
225
226
|
|
|
226
227
|
destroy() {
|
|
@@ -301,9 +302,9 @@ class notForm extends notBase {
|
|
|
301
302
|
setFormAction(val) {
|
|
302
303
|
if (val && val !== this.#action) {
|
|
303
304
|
this.#action = val;
|
|
304
|
-
try{
|
|
305
|
-
this.#form && this.#form.$destroy && this.#form.$destroy();
|
|
306
|
-
}catch{}
|
|
305
|
+
try {
|
|
306
|
+
this.#form && this.#form.$destroy && this.#form.$destroy();
|
|
307
|
+
} catch {}
|
|
307
308
|
this.initForm();
|
|
308
309
|
}
|
|
309
310
|
}
|
|
@@ -322,7 +323,7 @@ class notForm extends notBase {
|
|
|
322
323
|
* Form validation result
|
|
323
324
|
**/
|
|
324
325
|
setFormSuccess() {
|
|
325
|
-
this.#form.set(
|
|
326
|
+
this.#form.set("success", true);
|
|
326
327
|
this.emit("onsuccess");
|
|
327
328
|
}
|
|
328
329
|
|
|
@@ -340,7 +341,7 @@ class notForm extends notBase {
|
|
|
340
341
|
if (result.errors && Object.keys(result.errors).length > 0) {
|
|
341
342
|
status.fields = { ...result.errors };
|
|
342
343
|
}
|
|
343
|
-
this.#form.exec(
|
|
344
|
+
this.#form.exec("updateFormValidationStatus", [status]);
|
|
344
345
|
this.emit("onerror", status);
|
|
345
346
|
}
|
|
346
347
|
|
|
@@ -443,18 +444,21 @@ class notForm extends notBase {
|
|
|
443
444
|
if (this.getOptions("readonly", false)) {
|
|
444
445
|
return this.getData();
|
|
445
446
|
}
|
|
446
|
-
const data = FormHelpers.collectData(
|
|
447
|
+
const data = FormHelpers.collectData(
|
|
448
|
+
this.#form.props.fields,
|
|
449
|
+
this.#form.props.form
|
|
450
|
+
);
|
|
447
451
|
this.setData({ ...data }); //update in inner store
|
|
448
452
|
return data;
|
|
449
453
|
}
|
|
450
454
|
|
|
451
455
|
updateField(fieldName, props) {
|
|
452
|
-
if (this.#form.props && this.#form.props.form){
|
|
453
|
-
if(
|
|
454
|
-
this.#form.changeProp(`form.${fieldName}`, (val)=>{
|
|
455
|
-
return {...val, ...props}
|
|
456
|
-
});
|
|
457
|
-
}else{
|
|
456
|
+
if (this.#form.props && this.#form.props.form) {
|
|
457
|
+
if (this.#form.props.form[fieldName]) {
|
|
458
|
+
this.#form.changeProp(`form.${fieldName}`, (val) => {
|
|
459
|
+
return { ...val, ...props };
|
|
460
|
+
});
|
|
461
|
+
} else {
|
|
458
462
|
this.#form.set(`form.${fieldName}`, {
|
|
459
463
|
...props,
|
|
460
464
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import notFormUtils from "./utils";
|
|
2
2
|
import notFormHelpers from "./form.helpers";
|
|
3
|
-
import notForm from "
|
|
3
|
+
import notForm from "./form.svelte.js";
|
|
4
4
|
import notFormRules from "./form.rules";
|
|
5
5
|
import notFormSet from "./form.set.svelte.js";
|
|
6
6
|
import UIForm from "./form.svelte";
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { COMPONENTS } from "
|
|
2
|
-
import UICommon from "
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { COMPONENTS } from "../../LIB.js";
|
|
2
|
+
import UICommon from "../../../elements/common.js";
|
|
5
3
|
|
|
6
4
|
class Menu {
|
|
7
5
|
static MAX_TOUCH_WIDTH = 1023;
|
|
@@ -35,7 +33,7 @@ class Menu {
|
|
|
35
33
|
static items = [];
|
|
36
34
|
static sections = [];
|
|
37
35
|
static menuStructure = [];
|
|
38
|
-
|
|
36
|
+
|
|
39
37
|
static location;
|
|
40
38
|
static interval;
|
|
41
39
|
|
|
@@ -55,7 +53,7 @@ class Menu {
|
|
|
55
53
|
return `menu.${this.options.type}.${what}`;
|
|
56
54
|
}
|
|
57
55
|
|
|
58
|
-
static getCurrentUrl(){
|
|
56
|
+
static getCurrentUrl() {
|
|
59
57
|
return window.location.toString();
|
|
60
58
|
}
|
|
61
59
|
|
|
@@ -70,8 +68,11 @@ class Menu {
|
|
|
70
68
|
|
|
71
69
|
static getOptions() {
|
|
72
70
|
if (this.app) {
|
|
73
|
-
return {
|
|
74
|
-
class: this.app.getOptions(
|
|
71
|
+
return {
|
|
72
|
+
class: this.app.getOptions(
|
|
73
|
+
this.getOptionsPathTo("class"),
|
|
74
|
+
this.options.class
|
|
75
|
+
),
|
|
75
76
|
brand: this.app.getOptions("brand", this.options.brand),
|
|
76
77
|
items: this.app.getOptions(
|
|
77
78
|
this.getOptionsPathTo("items"),
|
|
@@ -100,7 +101,6 @@ class Menu {
|
|
|
100
101
|
root: this.app.getOptions("router.root", this.options.root),
|
|
101
102
|
navigate: this.options.navigate.bind(this),
|
|
102
103
|
getComponent: this.getComponent.bind(this),
|
|
103
|
-
|
|
104
104
|
};
|
|
105
105
|
} else {
|
|
106
106
|
return this.options;
|
|
@@ -166,7 +166,7 @@ class Menu {
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
static prepareData() {
|
|
169
|
-
const items = [...this.getOptions().items];
|
|
169
|
+
const items = [...this.getOptions().items];
|
|
170
170
|
const sections = [...this.getOptions().sections];
|
|
171
171
|
|
|
172
172
|
this.initField(sections, ["priority"]);
|
|
@@ -186,12 +186,14 @@ class Menu {
|
|
|
186
186
|
this.menuStructure = this.createStructure();
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
static createStructure(){
|
|
189
|
+
static createStructure() {
|
|
190
190
|
const menuStructure = [];
|
|
191
|
-
this.sections.forEach((section)=>{
|
|
191
|
+
this.sections.forEach((section) => {
|
|
192
192
|
const menuItem = structuredClone(section);
|
|
193
|
-
const subItems = this.items
|
|
194
|
-
|
|
193
|
+
const subItems = this.items
|
|
194
|
+
.filter((item) => item.section === section.id)
|
|
195
|
+
.map((subitem) => structuredClone(subitem));
|
|
196
|
+
if (subItems && subItems.length) {
|
|
195
197
|
menuItem.items = subItems;
|
|
196
198
|
}
|
|
197
199
|
menuStructure.push(menuItem);
|
|
@@ -244,7 +246,7 @@ class Menu {
|
|
|
244
246
|
}
|
|
245
247
|
|
|
246
248
|
static updateSection(sectionId, proc) {
|
|
247
|
-
if (this.menu.props.items && typeof sectionId !==
|
|
249
|
+
if (this.menu.props.items && typeof sectionId !== "undefined") {
|
|
248
250
|
for (let id in this.menu.props.items) {
|
|
249
251
|
if (this.menu.props.items[id].id !== sectionId) continue;
|
|
250
252
|
this.menu.props.items[id] = proc(this.menu.props.items[id]);
|
|
@@ -254,33 +256,48 @@ class Menu {
|
|
|
254
256
|
|
|
255
257
|
static updateSectionItems(sectionId, proc) {
|
|
256
258
|
if (!this.menu) return;
|
|
257
|
-
if (this.menu.props.items && typeof sectionId !==
|
|
258
|
-
const index = this.menu.props.items.findIndex(
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
259
|
+
if (this.menu.props.items && typeof sectionId !== "undefined") {
|
|
260
|
+
const index = this.menu.props.items.findIndex(
|
|
261
|
+
(sec) => sec.id === sectionId
|
|
262
|
+
);
|
|
263
|
+
if (index > -1) {
|
|
264
|
+
this.menu.props.items[index].items = proc(
|
|
265
|
+
this.menu.props.items[index].items
|
|
266
|
+
);
|
|
267
|
+
}
|
|
262
268
|
}
|
|
263
269
|
}
|
|
264
270
|
|
|
265
|
-
static getSectionIndexByItemId(itemId){
|
|
271
|
+
static getSectionIndexByItemId(itemId) {
|
|
266
272
|
if (!this.menu) return;
|
|
267
|
-
for(let sectionIndex in this.menu.props.items){
|
|
268
|
-
if (
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
273
|
+
for (let sectionIndex in this.menu.props.items) {
|
|
274
|
+
if (
|
|
275
|
+
this.menu.props.items[sectionIndex] &&
|
|
276
|
+
Array.isArray(this.menu.props.items[sectionIndex].items)
|
|
277
|
+
) {
|
|
278
|
+
const itemIndex = this.menu.props.items[
|
|
279
|
+
sectionIndex
|
|
280
|
+
].items.findIndex((item) => item.id === itemId);
|
|
281
|
+
if (itemIndex > -1) {
|
|
282
|
+
return { sectionIndex, itemIndex };
|
|
272
283
|
}
|
|
273
284
|
}
|
|
274
|
-
}
|
|
285
|
+
}
|
|
275
286
|
return undefined;
|
|
276
287
|
}
|
|
277
288
|
|
|
278
289
|
static updateItem(itemId, proc) {
|
|
279
290
|
if (!this.menu) return;
|
|
280
|
-
if (typeof itemId !==
|
|
291
|
+
if (typeof itemId !== "undefined" && this.items) {
|
|
281
292
|
const place = this.getSectionIndexByItemId(itemId);
|
|
282
|
-
if (place){
|
|
283
|
-
this.menu.props.items[place.sectionIndex].items[
|
|
293
|
+
if (place) {
|
|
294
|
+
this.menu.props.items[place.sectionIndex].items[
|
|
295
|
+
place.itemIndex
|
|
296
|
+
] = proc(
|
|
297
|
+
this.menu.props.items[place.sectionIndex].items[
|
|
298
|
+
place.itemIndex
|
|
299
|
+
]
|
|
300
|
+
);
|
|
284
301
|
}
|
|
285
302
|
}
|
|
286
303
|
}
|