@nebularstreams/libmui 3.1.0 → 4.0.0
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/libmui.esm.js +3 -0
- package/package.json +6 -2
- package/readme.md +48 -0
- package/dist/libui.esm.js +0 -3
- package/rollup.config.js +0 -20
- package/src/app/MainState.js +0 -22
- package/src/app/app.js +0 -9
- package/src/css/a-measures.css +0 -6
- package/src/css/b-colors.css +0 -12
- package/src/css/b-root-bootstrap-ext.css +0 -81
- package/src/css/b-root-bootstrap.css +0 -178
- package/src/css/b-root-semantic-flex.css +0 -87
- package/src/css/b-root-semantic-size-new.css +0 -37
- package/src/css/b-root-semantic-size.css +0 -75
- package/src/css/b-root-semantic-skin.css +0 -48
- package/src/css/b-root-semantic.css +0 -111
- package/src/css/b-root.css +0 -3
- package/src/css/cardie.css +0 -6
- package/src/css/flex.css +0 -46
- package/src/css/fontawesome/brands.min.css +0 -16
- package/src/css/fontawesome/fontawesome-ext.css +0 -7
- package/src/css/fontawesome/fontawesome-solid.css +0 -17
- package/src/css/fontawesome/fontawesome.css +0 -4359
- package/src/css/ui.notifications.css +0 -23
- package/src/css/ui.popup.css +0 -127
- package/src/css/ui.witharia.css +0 -25
- package/src/index.js +0 -112
- package/src/meta/InputTemplates.js +0 -3
- package/src/style.js +0 -37
- package/src/util/colorjoe.js +0 -1370
- package/src/util/filepath.js +0 -10
- package/src/util/fuckingconfirm.js +0 -28
- package/src/util/mithril-range.js +0 -445
- package/src/util/tainter.js +0 -39
- package/src/util/util.clone.js +0 -8
- package/src/util/util.tokenizer.js +0 -266
- package/src/util/widgets.core.js +0 -314
- package/src/util/widgets.js +0 -79
- package/src/util/widgets.utils.js +0 -10
- package/src/widgets/Basic.js +0 -352
- package/src/widgets/ButtonChoiceWidget.js +0 -72
- package/src/widgets/CardieWidget.js +0 -168
- package/src/widgets/ColorJoePack.js +0 -108
- package/src/widgets/ColorJoeWidget.js +0 -140
- package/src/widgets/ComboPrompt.js +0 -112
- package/src/widgets/ComboWidget.js +0 -156
- package/src/widgets/CoolContentTicker.js +0 -244
- package/src/widgets/CoolerEmpty.js +0 -37
- package/src/widgets/EmptyButton.js +0 -36
- package/src/widgets/FontSelectorButton.js +0 -37
- package/src/widgets/InputWidget.js +0 -254
- package/src/widgets/NoticeWidget.js +0 -31
- package/src/widgets/OverflowUtils.js +0 -449
- package/src/widgets/PlusMinusWidget.js +0 -55
- package/src/widgets/RangeWidget.js +0 -200
- package/src/widgets/SelectFileMiniButton.js +0 -170
- package/src/widgets/Separator.js +0 -21
- package/src/widgets/SmileysButton.js +0 -19
- package/src/widgets/SwitchWidget.js +0 -42
- package/src/widgets/TemplatedInputWidget.js +0 -1395
- package/src/widgets/TitleBarWidget.js +0 -71
- package/src/widgets/css/buttonchoice.css +0 -62
- package/src/widgets/css/buttonchoice.toggle.css +0 -37
- package/src/widgets/css/choicer.css +0 -24
- package/src/widgets/css/colorjoe.css +0 -230
- package/src/widgets/css/colorjoewidget.css +0 -105
- package/src/widgets/css/combo-ellipsis.css +0 -29
- package/src/widgets/css/fileminibutton.css +0 -12
- package/src/widgets/css/input.css +0 -35
- package/src/widgets/css/mithril-range.css +0 -69
- package/src/widgets/css/progressstrip.css +0 -31
- package/src/widgets/css/range-anims.css +0 -23
- package/src/widgets/css/separator.css +0 -21
- package/src/widgets/css/smileys.css +0 -85
- package/src/widgets/css/templatedinput.css +0 -67
- package/src/widgets/css/ui.titlebar.css +0 -44
- package/src/widgets/css/uploadfile.css +0 -5
- /package/dist/{libui.css → libmui.css} +0 -0
package/src/widgets/Basic.js
DELETED
|
@@ -1,352 +0,0 @@
|
|
|
1
|
-
import m from "mithril";
|
|
2
|
-
|
|
3
|
-
export function defineWidget(view, oninit, oncreate, onremove, onupdate) {
|
|
4
|
-
return {
|
|
5
|
-
...view && {view},
|
|
6
|
-
...oninit && {oninit},
|
|
7
|
-
...oncreate && {oncreate},
|
|
8
|
-
...onupdate && {onupdate},
|
|
9
|
-
...onremove && {onremove}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// ------------------------------------------------------------------------
|
|
15
|
-
|
|
16
|
-
function getAttrs(attrs, parentAttrs, panelInitialParams) {
|
|
17
|
-
const data = ((typeof attrs === "function") ? attrs(parentAttrs) : attrs) || {};
|
|
18
|
-
if (panelInitialParams) data.initialParams = panelInitialParams;
|
|
19
|
-
return data;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
isCurrent = ({currentIndex}, index) => currentIndex === index,
|
|
25
|
-
|
|
26
|
-
Icon = {
|
|
27
|
-
view: ({attrs}) => m(
|
|
28
|
-
`i.icon.${attrs.pack || "fas"}.fa-${attrs.icon || "cog"}${attrs.size ? ".fa-" + attrs.size + "x" : ""}`,
|
|
29
|
-
{
|
|
30
|
-
title: attrs.icontitle || undefined,
|
|
31
|
-
role: "presentation",
|
|
32
|
-
onclick: attrs.onclick || null, ...attrs.iconClass && {class: attrs.iconClass}
|
|
33
|
-
}
|
|
34
|
-
)
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
Button = {
|
|
38
|
-
view: ({attrs, state, children}) => m((attrs.download || attrs.link) ? "a.button" : "button", {
|
|
39
|
-
...attrs.link && {href: attrs.link},
|
|
40
|
-
...attrs.download && {download: attrs.download},
|
|
41
|
-
...attrs.target && {target: attrs.target},
|
|
42
|
-
"aria-label": attrs["aria-label"] || attrs.title || attrs.text,
|
|
43
|
-
title: attrs.title || attrs["aria-label"],
|
|
44
|
-
class: (attrs.class || "") + (state.busy ? " busy" : ""),
|
|
45
|
-
...state.error && {"data-error": state.error.message},
|
|
46
|
-
...attrs.onclick && {
|
|
47
|
-
onclick: (event) => {
|
|
48
|
-
clearTimeout(state.debounce);
|
|
49
|
-
state.debounce = setTimeout(() => {
|
|
50
|
-
const result = attrs.onclick(event, attrs);
|
|
51
|
-
if (result && result.then && result.catch) {
|
|
52
|
-
state.busy = true;
|
|
53
|
-
m.redraw();
|
|
54
|
-
result
|
|
55
|
-
.then(() => {
|
|
56
|
-
state.busy = false;
|
|
57
|
-
m.redraw();
|
|
58
|
-
})
|
|
59
|
-
.catch((error) => {
|
|
60
|
-
state.busy = false;
|
|
61
|
-
state.error = error;
|
|
62
|
-
m.redraw();
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}, 25);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}, [
|
|
69
|
-
...(attrs.icon && !attrs.right) ? [m(Icon, attrs)] : [],
|
|
70
|
-
...attrs.text ? [m("span.pad-1.pad-h", {class: attrs.textClass || null}, attrs.text)] : [],
|
|
71
|
-
...(attrs.icon && attrs.right) ? [m(Icon, attrs)] : [],
|
|
72
|
-
...children
|
|
73
|
-
])
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
ButtonNew = {
|
|
77
|
-
view: ({attrs, state, children}) => m((attrs.download || attrs.link) ? "a.button" : "button", {
|
|
78
|
-
...attrs.link && {href: attrs.link},
|
|
79
|
-
...attrs.download && {rel: "nofollow", download: attrs.download},
|
|
80
|
-
...attrs.target && {target: attrs.target},
|
|
81
|
-
"aria-label": attrs["aria-label"] || attrs.title || attrs.text,
|
|
82
|
-
title: attrs.title || attrs["aria-label"],
|
|
83
|
-
class: (attrs.class || "") + (state.busy ? " busy" : ""),
|
|
84
|
-
...state.error && {"data-error": state.error.message},
|
|
85
|
-
...attrs.onClick && {
|
|
86
|
-
onclick: (event) => {
|
|
87
|
-
clearTimeout(state.debounce);
|
|
88
|
-
state.debounce = setTimeout(() => {
|
|
89
|
-
const result = attrs.onClick(event, attrs);
|
|
90
|
-
if (result && result.then && result.catch) {
|
|
91
|
-
state.busy = true;
|
|
92
|
-
m.redraw();
|
|
93
|
-
result
|
|
94
|
-
.then(() => {
|
|
95
|
-
state.busy = false;
|
|
96
|
-
m.redraw();
|
|
97
|
-
})
|
|
98
|
-
.catch((error) => {
|
|
99
|
-
state.busy = false;
|
|
100
|
-
state.error = error;
|
|
101
|
-
m.redraw();
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}, 25);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}, [
|
|
108
|
-
...(attrs.icon && !attrs.right) ? [m(Icon, attrs)] : [],
|
|
109
|
-
...attrs.text ? [m("span.pad-1.pad-h", {class: attrs.textClass || null}, attrs.text)] : [],
|
|
110
|
-
...(attrs.icon && attrs.right) ? [m(Icon, attrs)] : [],
|
|
111
|
-
...children
|
|
112
|
-
])
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
Empty = {
|
|
116
|
-
|
|
117
|
-
view: ({attrs, children}) => m(
|
|
118
|
-
".flexcol.flexcenter.al-center.grows.emptywidget",
|
|
119
|
-
{
|
|
120
|
-
...attrs.class && {class: attrs.class},
|
|
121
|
-
...attrs.key && {key: attrs.key},
|
|
122
|
-
role: "presentation"
|
|
123
|
-
},
|
|
124
|
-
[
|
|
125
|
-
m(Icon, attrs),
|
|
126
|
-
...attrs.message
|
|
127
|
-
? [
|
|
128
|
-
m(".marg-2.marg-v",
|
|
129
|
-
{
|
|
130
|
-
role: "status",
|
|
131
|
-
class: attrs.size > 4 ? "font-150" : "font-100",
|
|
132
|
-
"aria-label": attrs.message
|
|
133
|
-
},
|
|
134
|
-
attrs.message.split("\n")
|
|
135
|
-
.map((str, idx, all) => all.length === 1 ? str : m("p.msg" + idx, str))
|
|
136
|
-
)
|
|
137
|
-
]
|
|
138
|
-
: [],
|
|
139
|
-
...children
|
|
140
|
-
? [m(".flexcol.additional", children)]
|
|
141
|
-
: []
|
|
142
|
-
]
|
|
143
|
-
)
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
setItem = (attrs, state, index, params) => {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
lastIndex = state.currentIndex,
|
|
151
|
-
lastParams = state.currentParams;
|
|
152
|
-
|
|
153
|
-
if (index === -1) {
|
|
154
|
-
Object.assign(state, {
|
|
155
|
-
current: null,
|
|
156
|
-
currentIndex: -1,
|
|
157
|
-
currentParams: []
|
|
158
|
-
});
|
|
159
|
-
} else {
|
|
160
|
-
Object.assign(state, {
|
|
161
|
-
current: attrs.items[index] || null,
|
|
162
|
-
currentIndex: state.current ? index : -1,
|
|
163
|
-
currentParams: params || []
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (attrs.onSelected) attrs.onSelected(state.current, state.currentParams, state.currentIndex !== lastIndex, lastParams);
|
|
168
|
-
|
|
169
|
-
m.redraw();
|
|
170
|
-
},
|
|
171
|
-
|
|
172
|
-
Selector = {
|
|
173
|
-
|
|
174
|
-
oninit: ({attrs, state}) => {
|
|
175
|
-
|
|
176
|
-
state = attrs.state || state;
|
|
177
|
-
state.setItem = (index, ...params) => setItem(attrs, attrs.state || state, index, params);
|
|
178
|
-
|
|
179
|
-
const
|
|
180
|
-
hasState = !isNaN(state.currentIndex),
|
|
181
|
-
selected = hasState ? state.currentIndex : attrs.selected,
|
|
182
|
-
currentIndex = (attrs.items && attrs.items.length)
|
|
183
|
-
? (selected !== undefined && attrs.items[selected])
|
|
184
|
-
? selected
|
|
185
|
-
: attrs.noinitial ? -1 : 0
|
|
186
|
-
: -1,
|
|
187
|
-
current = currentIndex !== -1 ? attrs.items[currentIndex] : null;
|
|
188
|
-
|
|
189
|
-
Object.assign(state, {currentIndex, current});
|
|
190
|
-
|
|
191
|
-
},
|
|
192
|
-
|
|
193
|
-
onupdate: ({attrs, state}) => {
|
|
194
|
-
(attrs.state || state).setItem = (index, ...params) => setItem(attrs, attrs.state || state, index, params);
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
view: ({attrs, state}) => {
|
|
198
|
-
|
|
199
|
-
state = attrs.state || state;
|
|
200
|
-
const {current} = state;
|
|
201
|
-
|
|
202
|
-
return m(
|
|
203
|
-
(attrs.element || "widget") + ".selector" + (attrs.horizontal ? ".flexrow" : ".flexcol") + (attrs.className ? "." + attrs.className : ""),
|
|
204
|
-
{
|
|
205
|
-
...attrs.key && {key: attrs.key},
|
|
206
|
-
class: (state.current ? "hascurrent" : "empty") + (attrs.class ? " " + attrs.class : "") + (current?.bodyTitle ? " withbodytitle" : "")
|
|
207
|
-
},
|
|
208
|
-
[
|
|
209
|
-
...((!attrs.hideonly || (attrs.items.length > 1)) && (!attrs.hidesel))
|
|
210
|
-
? [
|
|
211
|
-
/** navigation bar */
|
|
212
|
-
m(
|
|
213
|
-
"nav.toolbar.fullwidth" + (attrs.horizontal ? ".flexcol" : ".flexrow"),
|
|
214
|
-
{
|
|
215
|
-
"aria-label": attrs["aria-label"] || attrs.title || "selector",
|
|
216
|
-
class: attrs.toolbarClass
|
|
217
|
-
},
|
|
218
|
-
attrs.items.map((item, index) => m(Button, {
|
|
219
|
-
class: (item.class ? item.class + " " : "") + (isCurrent(state, index) ? "accent" : "nel"),
|
|
220
|
-
icon: item.icon || null,
|
|
221
|
-
...item.title && {title: item.title},
|
|
222
|
-
...item["aria-label"] && {"aria-label": item["aria-label"]},
|
|
223
|
-
...item.text && {text: item.text},
|
|
224
|
-
onclick: () => {
|
|
225
|
-
const t = Date.now();
|
|
226
|
-
if (t - state.clickts < 200) return;
|
|
227
|
-
state.clickts = Date.now();
|
|
228
|
-
state.bodyHidden = false;
|
|
229
|
-
state.setItem(index);
|
|
230
|
-
}
|
|
231
|
-
}))
|
|
232
|
-
)]
|
|
233
|
-
: [],
|
|
234
|
-
...current
|
|
235
|
-
? [
|
|
236
|
-
...(attrs.toggle && !state.bodyHidden)
|
|
237
|
-
? [
|
|
238
|
-
m(ButtonNew, {
|
|
239
|
-
class: "selectornotch " + (state.bodyHidden ? "bodyhidden" : "bodyshown"),
|
|
240
|
-
icon: state.bodyHidden ? "caret-up" : "caret-down",
|
|
241
|
-
title: state.bodyHidden ? "expand panel" : "contract panel",
|
|
242
|
-
onClick: () => {
|
|
243
|
-
state.bodyHidden = !state.bodyHidden;
|
|
244
|
-
m.redraw();
|
|
245
|
-
}
|
|
246
|
-
})
|
|
247
|
-
] : [],
|
|
248
|
-
...(!attrs.toggle || !state.bodyHidden)
|
|
249
|
-
? [
|
|
250
|
-
...current?.bodyTitle ? [
|
|
251
|
-
m(".bodytitle", current.bodyTitle)
|
|
252
|
-
] : [],
|
|
253
|
-
/** body */
|
|
254
|
-
m(".grows.flexcol.ohidden.selectorbody", {
|
|
255
|
-
class: attrs.bodyClass,
|
|
256
|
-
role: "presentation"
|
|
257
|
-
}, [
|
|
258
|
-
m(
|
|
259
|
-
current.widget,
|
|
260
|
-
getAttrs(current.attrs, attrs, state.currentParams),
|
|
261
|
-
current.children
|
|
262
|
-
)
|
|
263
|
-
])
|
|
264
|
-
]
|
|
265
|
-
: [],
|
|
266
|
-
...attrs.closeButton
|
|
267
|
-
? [
|
|
268
|
-
m(Button, {
|
|
269
|
-
class: "closebutton absolute toright",
|
|
270
|
-
icon: "times",
|
|
271
|
-
onclick: () => {
|
|
272
|
-
state.setItem(-1);
|
|
273
|
-
},
|
|
274
|
-
"aria-label": "close item"
|
|
275
|
-
})] : []
|
|
276
|
-
]
|
|
277
|
-
: m(Empty, attrs)
|
|
278
|
-
]
|
|
279
|
-
);
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
const ICONS = {
|
|
284
|
-
info: "info",
|
|
285
|
-
error: "exclamation-triangle",
|
|
286
|
-
success: "check"
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
function Notifications(TOAST_SHORT = 5000, altContainer) {
|
|
290
|
-
|
|
291
|
-
let
|
|
292
|
-
mNotifications = [],
|
|
293
|
-
mTimer;
|
|
294
|
-
|
|
295
|
-
function render(container, n) {
|
|
296
|
-
m.render(
|
|
297
|
-
container, m(
|
|
298
|
-
Button, {
|
|
299
|
-
class: "notification " + n.type,
|
|
300
|
-
text: n.text,
|
|
301
|
-
icon: ICONS[n.type] || "info",
|
|
302
|
-
size: 1,
|
|
303
|
-
role: "status",
|
|
304
|
-
// eslint-disable-next-line no-use-before-define
|
|
305
|
-
onclick: next
|
|
306
|
-
}
|
|
307
|
-
)
|
|
308
|
-
);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
function next() {
|
|
312
|
-
|
|
313
|
-
const
|
|
314
|
-
container = altContainer || document.getElementById("notification-container");
|
|
315
|
-
|
|
316
|
-
if (mNotifications.length) {
|
|
317
|
-
const n = mNotifications.splice(0, 1)[0];
|
|
318
|
-
render(container, n);
|
|
319
|
-
clearTimeout(mTimer);
|
|
320
|
-
mTimer = setTimeout(next, n.timer || TOAST_SHORT);
|
|
321
|
-
} else {
|
|
322
|
-
m.render(container, "");
|
|
323
|
-
mTimer = null;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
return {
|
|
328
|
-
add: (text, type) => {
|
|
329
|
-
mNotifications.push({
|
|
330
|
-
text,
|
|
331
|
-
type
|
|
332
|
-
});
|
|
333
|
-
if (!mTimer) next();
|
|
334
|
-
},
|
|
335
|
-
clear: () => {
|
|
336
|
-
mNotifications = [];
|
|
337
|
-
next();
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
const Notification = new Notifications();
|
|
344
|
-
|
|
345
|
-
export {
|
|
346
|
-
Empty,
|
|
347
|
-
Icon,
|
|
348
|
-
Selector,
|
|
349
|
-
Button,
|
|
350
|
-
ButtonNew,
|
|
351
|
-
Notification
|
|
352
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import m from "mithril";
|
|
2
|
-
import {ButtonNew, defineWidget} from "./Basic";
|
|
3
|
-
import Separator from "./Separator"
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
/*
|
|
8
|
-
SizeChoices = {
|
|
9
|
-
"1080p": {width: 1920, height: 1080, value: "1080p"},
|
|
10
|
-
"720p": {width: 1280, height: 720, value: "720p"},
|
|
11
|
-
"Fluid": {width: null, height: null, value: "Fluid"},
|
|
12
|
-
"Custom": {value: ""}
|
|
13
|
-
}
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
ButtonChoiceWidget = defineWidget(
|
|
17
|
-
({attrs}) => {
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
{value, field, toggle, element, emptyMessage, chooseKey, chooseDict} = attrs,
|
|
21
|
-
choose = (!attrs.choose && chooseKey && chooseDict) ? chooseDict[chooseKey] : attrs.choose,
|
|
22
|
-
choices = choose
|
|
23
|
-
? choose.map((choice) => ({value: choice, caption: choice}))
|
|
24
|
-
: attrs.choices || {};
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
keys = Object.keys(choices),
|
|
28
|
-
has = keys.length,
|
|
29
|
-
clase = (attrs.class || "") + (attrs.subclass ? " " + attrs.subclass : " scaff scaff-b1");
|
|
30
|
-
|
|
31
|
-
return has || emptyMessage
|
|
32
|
-
? [
|
|
33
|
-
...attrs.label ? [m(Separator, {text: attrs.label, class: attrs.labelClass || ""})] : [],
|
|
34
|
-
m(
|
|
35
|
-
(element || "div") + ".buttonchoice.flexrow.ohidden",
|
|
36
|
-
{
|
|
37
|
-
class: clase + (attrs.icon ? " withicon fa-" + attrs.icon : ""),
|
|
38
|
-
title: attrs.title
|
|
39
|
-
},
|
|
40
|
-
m(
|
|
41
|
-
".flexrow.grows.ohidden.wrap" + (attrs.icon ? " scaff-left" : ""),
|
|
42
|
-
keys.length
|
|
43
|
-
? keys.map((choicekey) => {
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
choice = choices[choicekey],
|
|
47
|
-
choicevalue = attrs.raw && field ? choice : choice.value,
|
|
48
|
-
finalchoicevalue = field ? choicevalue[field] : choicevalue,
|
|
49
|
-
current = finalchoicevalue === value;
|
|
50
|
-
|
|
51
|
-
// noinspection EqualityComparisonWithCoercionJS
|
|
52
|
-
return m(ButtonNew, {
|
|
53
|
-
|
|
54
|
-
icon: choice.icon || undefined,
|
|
55
|
-
class: "grows scaff-b0 " + (attrs.buttonClass ? attrs.buttonClass + " " : "rectbutton unitheightsmall ") + (choice.class ? choice.class + " " : "") + (current ? "accent" : ""),
|
|
56
|
-
title: choice.current ? choice.titleOn || choice.title : choice.titleOff || choice.title,
|
|
57
|
-
onClick: (e) => {
|
|
58
|
-
attrs.onchange(toggle ? current ? undefined : choice : choice, choicekey, e);
|
|
59
|
-
m.redraw();
|
|
60
|
-
}
|
|
61
|
-
}, attrs.render ? attrs.render(choice) : choice.caption || choicekey);
|
|
62
|
-
})
|
|
63
|
-
: [m(".emptychoice.grows.al-center.align-self-center.unitheightsmall", attrs.emptyMessage)]
|
|
64
|
-
)
|
|
65
|
-
)
|
|
66
|
-
]
|
|
67
|
-
: [];
|
|
68
|
-
}
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
export default ButtonChoiceWidget;
|
|
72
|
-
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import m from "mithril";
|
|
2
|
-
import {ButtonNew, defineWidget} from "./Basic";
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
globalState = {},
|
|
6
|
-
CARDIE_CLOSED = 0;
|
|
7
|
-
|
|
8
|
-
function setCardStatus(cardid, expanded = CARDIE_CLOSED) {
|
|
9
|
-
if (cardid) {
|
|
10
|
-
const [uniq, subname] = cardid.split("-");
|
|
11
|
-
if (expanded && uniq && subname) {
|
|
12
|
-
Object.keys(globalState)
|
|
13
|
-
.forEach((key) => {
|
|
14
|
-
if (key.startsWith(uniq + "-")) {
|
|
15
|
-
globalState[key] = CARDIE_CLOSED;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
globalState[cardid] = expanded;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const CardieWidget = defineWidget(
|
|
24
|
-
({attrs, state, children}) => {
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
{
|
|
29
|
-
nofold,
|
|
30
|
-
cardid,
|
|
31
|
-
size,
|
|
32
|
-
title,
|
|
33
|
-
action,
|
|
34
|
-
collapsedAction,
|
|
35
|
-
collapsedClass,
|
|
36
|
-
expandedClass,
|
|
37
|
-
cols,
|
|
38
|
-
element,
|
|
39
|
-
busy,
|
|
40
|
-
expandedView,
|
|
41
|
-
collapsedView,
|
|
42
|
-
titleWidget: titWidget,
|
|
43
|
-
titleAttrs,
|
|
44
|
-
titleClass,
|
|
45
|
-
bodyClass,
|
|
46
|
-
titleExpanded,
|
|
47
|
-
titleCollapsed,
|
|
48
|
-
foldIcon = "fa-chevron-down"
|
|
49
|
-
} = attrs,
|
|
50
|
-
|
|
51
|
-
collapsed = nofold
|
|
52
|
-
? false
|
|
53
|
-
: cardid
|
|
54
|
-
? !globalState[cardid]
|
|
55
|
-
: !!state.collapsed,
|
|
56
|
-
|
|
57
|
-
items = (!collapsed)
|
|
58
|
-
? (
|
|
59
|
-
expandedView
|
|
60
|
-
? expandedView(attrs, state)
|
|
61
|
-
: (children || [])
|
|
62
|
-
)
|
|
63
|
-
: collapsedView ? collapsedView(attrs, state) : [],
|
|
64
|
-
|
|
65
|
-
titleWidget = titWidget
|
|
66
|
-
? m(titWidget, titleAttrs || {})
|
|
67
|
-
: title ? m("span.ellipsis.ohidden.unfold", title) : undefined,
|
|
68
|
-
|
|
69
|
-
buttonClass = busy
|
|
70
|
-
? "fa-sync"
|
|
71
|
-
: `${foldIcon} ${collapsed ? "iscollapsed" : "isexpanded"}`;
|
|
72
|
-
|
|
73
|
-
return items.length || !attrs.skipEmpty
|
|
74
|
-
? m(
|
|
75
|
-
(element || "ul"),
|
|
76
|
-
{
|
|
77
|
-
class: "cardie ohidden "
|
|
78
|
-
+ (cols ? "flexcol " : "flexrow wrap ")
|
|
79
|
-
+ (attrs.class ? " " + attrs.class : "")
|
|
80
|
-
+ (nofold
|
|
81
|
-
? " expanded"
|
|
82
|
-
: ` ${collapsed ? "collapsed " + (collapsedClass || "") : "expanded " + (expandedClass || "")}`)
|
|
83
|
-
+ (size ? " marg-" + size : "") // marg-2")
|
|
84
|
-
+ (titWidget ? " withwidget" : "")
|
|
85
|
-
+ (busy ? " busycard" : "")
|
|
86
|
-
},
|
|
87
|
-
[
|
|
88
|
-
|
|
89
|
-
...titleWidget
|
|
90
|
-
? [
|
|
91
|
-
m(
|
|
92
|
-
".title.grows.fabf.flexrow.pointer.unfold",
|
|
93
|
-
nofold
|
|
94
|
-
? {
|
|
95
|
-
class: titleClass || "pad-2"
|
|
96
|
-
}
|
|
97
|
-
: {
|
|
98
|
-
class: `${titleClass || "pad-2"} ${buttonClass || ""}`,
|
|
99
|
-
|
|
100
|
-
title: collapsed
|
|
101
|
-
? (titleCollapsed || "Click to expand the options")
|
|
102
|
-
: (titleExpanded || titleCollapsed || "Click to collapse the options"),
|
|
103
|
-
|
|
104
|
-
onclick: (e) => {
|
|
105
|
-
|
|
106
|
-
if (e.target.classList.contains("unfold")) {
|
|
107
|
-
if (e.shiftKey && attrs.onShiftOpen) {
|
|
108
|
-
attrs.onShiftOpen();
|
|
109
|
-
} else if (attrs.cardid) {
|
|
110
|
-
setCardStatus(cardid, collapsed); // !state
|
|
111
|
-
} else {
|
|
112
|
-
state.collapsed = !state.collapsed;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
m.redraw();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
action && (nofold || !collapsed)
|
|
120
|
-
? [
|
|
121
|
-
m(ButtonNew, action),
|
|
122
|
-
titleWidget
|
|
123
|
-
]
|
|
124
|
-
: collapsedAction && collapsed
|
|
125
|
-
? [
|
|
126
|
-
m(ButtonNew, collapsedAction),
|
|
127
|
-
titleWidget
|
|
128
|
-
]
|
|
129
|
-
: titleWidget
|
|
130
|
-
)
|
|
131
|
-
]
|
|
132
|
-
: [],
|
|
133
|
-
|
|
134
|
-
...items.length
|
|
135
|
-
? [
|
|
136
|
-
m(".flexbreak"),
|
|
137
|
-
m(
|
|
138
|
-
".cardiebody.fadein-filter.grows",
|
|
139
|
-
{
|
|
140
|
-
class: (cols ? "flexcol " : "flexrow wrap") + " " + (bodyClass || "")
|
|
141
|
-
},
|
|
142
|
-
...items
|
|
143
|
-
)
|
|
144
|
-
] : [],
|
|
145
|
-
|
|
146
|
-
...(attrs.alwaysView
|
|
147
|
-
? [attrs.alwaysView({attrs, state})]
|
|
148
|
-
: [])
|
|
149
|
-
|
|
150
|
-
]
|
|
151
|
-
) : [];
|
|
152
|
-
},
|
|
153
|
-
({attrs, state}) => {
|
|
154
|
-
if (!attrs.cardid) {
|
|
155
|
-
state.collapsed = attrs.nofold
|
|
156
|
-
? false
|
|
157
|
-
: attrs.cardid
|
|
158
|
-
? !globalState[attrs.cardid]
|
|
159
|
-
: !!attrs.collapsed;
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
undefined,
|
|
163
|
-
undefined,
|
|
164
|
-
undefined,
|
|
165
|
-
{setCardStatus}
|
|
166
|
-
);
|
|
167
|
-
|
|
168
|
-
export default CardieWidget;
|