@nebularstreams/libmui 2.5.118 → 2.5.120
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/libui.css +1 -1
- package/dist/libui.esm.js +2 -2
- package/dist/libui.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/app/MainState.js +11 -2
- package/src/widgets/InputWidget.js +3 -3
- package/src/widgets/TemplatedInputWidget.js +40 -18
- package/src/widgets/css/buttonchoice.toggle.css +1 -1
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};
|
|
@@ -100,12 +100,12 @@ const
|
|
|
100
100
|
];
|
|
101
101
|
|
|
102
102
|
return m(
|
|
103
|
-
".textfield.
|
|
103
|
+
".textfield.flexcol.relative",
|
|
104
104
|
{
|
|
105
105
|
class: (attrs.label ? "witharia" : "") + (attrs.containerClass ? " " + attrs.containerClass : ""),
|
|
106
106
|
...attrs.label && {"aria-label": attrs.label}
|
|
107
107
|
},
|
|
108
|
-
[
|
|
108
|
+
m(".textfieldinner.flexrow", [
|
|
109
109
|
(attrs.staticField && (attrs.readonly || !state.showInput))
|
|
110
110
|
? m(StaticFieldWidget, {
|
|
111
111
|
readonly: attrs.readonly,
|
|
@@ -241,7 +241,7 @@ const
|
|
|
241
241
|
}),
|
|
242
242
|
|
|
243
243
|
...inputActions.length ? [m(".span.actions", inputActions)] : [],
|
|
244
|
-
]);
|
|
244
|
+
]));
|
|
245
245
|
},
|
|
246
246
|
oninit: ({attrs, state}) => {
|
|
247
247
|
if (attrs.staticField && attrs.draginc) {
|
|
@@ -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
|
});
|
|
@@ -512,15 +525,24 @@ const
|
|
|
512
525
|
: isWidget
|
|
513
526
|
? [
|
|
514
527
|
m(
|
|
515
|
-
metaDef.widget,
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
onchange(critical || UPDATECODE, rootParameters ? parameters : targetParameters, metaKey, undefined, metaDef)
|
|
522
|
-
|
|
523
|
-
|
|
528
|
+
getWidget(metaDef.widget),
|
|
529
|
+
|
|
530
|
+
typeof metaDef.attrs === "function"
|
|
531
|
+
? metaDef.attrs(
|
|
532
|
+
rawValue,
|
|
533
|
+
state,
|
|
534
|
+
(critical, rootParameters) => onchange(critical || UPDATECODE, rootParameters ? parameters : targetParameters, metaKey, undefined, metaDef),
|
|
535
|
+
global,
|
|
536
|
+
attrs,
|
|
537
|
+
targetParameters
|
|
538
|
+
)
|
|
539
|
+
: metaDef.attrs,
|
|
540
|
+
|
|
541
|
+
metaDef.children
|
|
542
|
+
? metaDef.children(rawValue, state, (critical, rootParameters) => {
|
|
543
|
+
onchange(critical || UPDATECODE, rootParameters ? parameters : targetParameters, metaKey, undefined, metaDef);
|
|
544
|
+
}, global, attrs, targetParameters)
|
|
545
|
+
: [])
|
|
524
546
|
]
|
|
525
547
|
: isPlusMinus
|
|
526
548
|
? [
|