@nebularstreams/libmui 2.5.119 → 2.5.121
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
package/src/app/MainState.js
CHANGED
|
@@ -2,12 +2,21 @@ const
|
|
|
2
2
|
MAINSTATE = {
|
|
3
3
|
setTransState: () => {
|
|
4
4
|
console.warn("MainState: Not Implemented setTransState")
|
|
5
|
-
}
|
|
5
|
+
},
|
|
6
|
+
WIDGETS: {}
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
function implement(functs) {
|
|
9
10
|
Object.assign(MAINSTATE, functs);
|
|
10
11
|
}
|
|
11
12
|
|
|
13
|
+
function registerWidget(name, widget) {
|
|
14
|
+
Object.assign(MAINSTATE.WIDGETS, {[name]: widget});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function getWidget(name) {
|
|
18
|
+
return typeof (name) === "string" ? MAINSTATE.WIDGETS[name] : name;
|
|
19
|
+
}
|
|
20
|
+
|
|
12
21
|
export default MAINSTATE;
|
|
13
|
-
export {implement};
|
|
22
|
+
export {implement, registerWidget, getWidget};
|
|
@@ -22,7 +22,7 @@ import {confirm} from "../util/fuckingconfirm.js"
|
|
|
22
22
|
import {promptName} from "./OverflowUtils.js"
|
|
23
23
|
import {sanitizeFilename} from "../util/util.tokenizer"
|
|
24
24
|
import {taint} from "../util/tainter"
|
|
25
|
-
import MainState from "../app/MainState.js"
|
|
25
|
+
import MainState, {getWidget} from "../app/MainState.js"
|
|
26
26
|
|
|
27
27
|
const
|
|
28
28
|
|
|
@@ -61,7 +61,7 @@ const
|
|
|
61
61
|
MultiToggleWidget = defineWidget(
|
|
62
62
|
({attrs, children}) => m(".flexrow.wrap", {class: attrs.class}, attrs.source
|
|
63
63
|
? Object.keys(attrs.source)
|
|
64
|
-
.map((key) => m(attrs.widget || ToggleWidget, {
|
|
64
|
+
.map((key) => m(getWidget(attrs.widget) || ToggleWidget, {
|
|
65
65
|
text: key,
|
|
66
66
|
icon: attrs.icon,
|
|
67
67
|
checked: !!attrs.source[key],
|
|
@@ -110,7 +110,7 @@ const
|
|
|
110
110
|
buttonClass: attrs.buttonClass,
|
|
111
111
|
onchange: attrs.onchange,
|
|
112
112
|
hint: attrs.hint,
|
|
113
|
-
widget: attrs.nocustom !== state.current ? attrs.widget : undefined,
|
|
113
|
+
widget: attrs.nocustom !== state.current ? getWidget(attrs.widget) : undefined,
|
|
114
114
|
max: attrs.max,
|
|
115
115
|
mul: attrs.mul
|
|
116
116
|
}, children)
|
|
@@ -124,7 +124,8 @@ const
|
|
|
124
124
|
KeyIteratorWidget = defineWidget(
|
|
125
125
|
({attrs, children}) => {
|
|
126
126
|
const
|
|
127
|
-
|
|
127
|
+
isArray = attrs.source && Array.isArray(attrs.source),
|
|
128
|
+
keys = isArray ? attrs.source.map((_, i) => i) : attrs.keys || attrs.source && Object.keys(attrs.source),
|
|
128
129
|
expandedView = () => (keys && keys.length) || attrs.add
|
|
129
130
|
? [
|
|
130
131
|
...attrs.cardie || attrs.noseparator
|
|
@@ -137,7 +138,7 @@ const
|
|
|
137
138
|
m(".flexrow.wrap", {class: attrs.class},
|
|
138
139
|
(
|
|
139
140
|
attrs.source
|
|
140
|
-
? keys.map((key) => m(attrs.widget.name, {
|
|
141
|
+
? keys.map((key) => m(getWidget(attrs.widget.name), {
|
|
141
142
|
keyName: key,
|
|
142
143
|
class: attrs.widgetClass,
|
|
143
144
|
...((typeof attrs.widget.attrs === "function" ? attrs.widget.attrs(attrs, key) : attrs.widget.attrs) || {}),
|
|
@@ -145,7 +146,12 @@ const
|
|
|
145
146
|
parameters: attrs.targetParameters,
|
|
146
147
|
onchange: (newValue, event) => {
|
|
147
148
|
if (!newValue && attrs.add && event.shiftKey) {
|
|
148
|
-
|
|
149
|
+
|
|
150
|
+
if (isArray) {
|
|
151
|
+
attrs.source.splice(key, 1);
|
|
152
|
+
} else {
|
|
153
|
+
delete attrs.source[key];
|
|
154
|
+
}
|
|
149
155
|
} else {
|
|
150
156
|
attrs.source[key] = newValue;
|
|
151
157
|
}
|
|
@@ -165,14 +171,21 @@ const
|
|
|
165
171
|
"",
|
|
166
172
|
`type ${attrs.add} name`,
|
|
167
173
|
(newName) => {
|
|
174
|
+
|
|
175
|
+
const NEWITEM = ""; // TODO
|
|
176
|
+
|
|
168
177
|
if (newName) {
|
|
169
178
|
newName = sanitizeFilename(newName)
|
|
170
179
|
.toLowerCase();
|
|
171
180
|
}
|
|
172
181
|
if (newName) {
|
|
173
|
-
if (
|
|
174
|
-
attrs.source
|
|
175
|
-
|
|
182
|
+
if (isArray) {
|
|
183
|
+
attrs.source.push(NEWITEM);
|
|
184
|
+
} else {
|
|
185
|
+
if (!attrs.source[newName]) {
|
|
186
|
+
attrs.source[newName] = NEWITEM;
|
|
187
|
+
m.redraw();
|
|
188
|
+
}
|
|
176
189
|
}
|
|
177
190
|
}
|
|
178
191
|
});
|
|
@@ -397,14 +410,9 @@ const
|
|
|
397
410
|
},
|
|
398
411
|
isCardieArray
|
|
399
412
|
? Array.isArray(rawValue)
|
|
400
|
-
? rawValue.map(
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
cardid: metaDef.cardid + "-" + index,
|
|
404
|
-
nofold: false,
|
|
405
|
-
size: metaDef.margin || 0,
|
|
406
|
-
expandedView: () => [
|
|
407
|
-
m(ParameterTable, {
|
|
413
|
+
? rawValue.map(
|
|
414
|
+
(item, index) => metaDef.small
|
|
415
|
+
? m(ParameterTable, {
|
|
408
416
|
meta: metaDef.items,
|
|
409
417
|
crit: {},
|
|
410
418
|
when: {},
|
|
@@ -428,22 +436,55 @@ const
|
|
|
428
436
|
AssetButton: attrs.AssetButton,
|
|
429
437
|
CodeMirror: attrs.CodeMirror
|
|
430
438
|
})
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
439
|
+
: m(CardieWidget, {
|
|
440
|
+
class: "relative grows " + (metaDef.class || "pad-h emby w-max") + (metaDef.dynClass ? " " + metaDef.dynClass(parameters, auxParameters, index) : ""),
|
|
441
|
+
title: metaDef.dynTitle ? metaDef.dynTitle(parameters, auxParameters, index) : metaDef.title + " " + (index + 1),
|
|
442
|
+
cardid: metaDef.cardid + "-" + index,
|
|
443
|
+
nofold: false,
|
|
444
|
+
size: metaDef.margin || 0,
|
|
445
|
+
expandedView: () => [
|
|
446
|
+
m(ParameterTable, {
|
|
447
|
+
meta: metaDef.items,
|
|
448
|
+
crit: {},
|
|
449
|
+
when: {},
|
|
450
|
+
sizes: {},
|
|
451
|
+
|
|
452
|
+
parameters: item,
|
|
453
|
+
auxParameters,
|
|
454
|
+
|
|
455
|
+
global,
|
|
456
|
+
clone,
|
|
457
|
+
onchange,
|
|
458
|
+
itemClass,
|
|
459
|
+
wrapper,
|
|
460
|
+
empty: vacioperovacio,
|
|
461
|
+
itemsDict: attrs.itemsDict,
|
|
462
|
+
layer: attrs.layer,
|
|
463
|
+
onAction: attrs.onAction,
|
|
464
|
+
optionsDict: attrs.optionsDict,
|
|
465
|
+
play: attrs.play,
|
|
466
|
+
auxTargetIsDefault: false,
|
|
467
|
+
AssetButton: attrs.AssetButton,
|
|
468
|
+
CodeMirror: attrs.CodeMirror
|
|
469
|
+
})
|
|
470
|
+
],
|
|
471
|
+
titleExpended: metaDef.titleExpanded || metaDef.hint,
|
|
472
|
+
titleCollapsed: metaDef.titleCollapsed || metaDef.hint,
|
|
473
|
+
})
|
|
474
|
+
)
|
|
475
|
+
.concat(metaDef.addAction ? [
|
|
476
|
+
m(ButtonNew, {
|
|
477
|
+
...metaDef.addAction,
|
|
478
|
+
onClick: (e) => {
|
|
479
|
+
if (metaDef.addAction.onClick) {
|
|
480
|
+
metaDef.addAction.onClick(e, parameters, auxParameters);
|
|
481
|
+
} else if (metaDef.addAction.template) {
|
|
482
|
+
rawValue.push(cloneObject(metaDef.addAction.template));
|
|
483
|
+
}
|
|
484
|
+
m.redraw();
|
|
442
485
|
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
})
|
|
446
|
-
] : [])
|
|
486
|
+
})
|
|
487
|
+
] : [])
|
|
447
488
|
: []
|
|
448
489
|
|
|
449
490
|
: isCardie
|
|
@@ -512,10 +553,19 @@ const
|
|
|
512
553
|
: isWidget
|
|
513
554
|
? [
|
|
514
555
|
m(
|
|
515
|
-
metaDef.widget,
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
556
|
+
getWidget(metaDef.widget),
|
|
557
|
+
|
|
558
|
+
typeof metaDef.attrs === "function"
|
|
559
|
+
? metaDef.attrs(
|
|
560
|
+
rawValue,
|
|
561
|
+
state,
|
|
562
|
+
(critical, rootParameters) => onchange(critical || UPDATECODE, rootParameters ? parameters : targetParameters, metaKey, undefined, metaDef),
|
|
563
|
+
global,
|
|
564
|
+
attrs,
|
|
565
|
+
targetParameters
|
|
566
|
+
)
|
|
567
|
+
: metaDef.attrs,
|
|
568
|
+
|
|
519
569
|
metaDef.children
|
|
520
570
|
? metaDef.children(rawValue, state, (critical, rootParameters) => {
|
|
521
571
|
onchange(critical || UPDATECODE, rootParameters ? parameters : targetParameters, metaKey, undefined, metaDef);
|