@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
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import m from 'mithril';
|
|
2
|
-
import {defineWidget, ButtonNew} from "./Basic.js"
|
|
3
|
-
import {promptName} from "./OverflowUtils"
|
|
4
|
-
import {confirmPromise} from "../util/fuckingconfirm.js"
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
ThematicWrapper = defineWidget(
|
|
8
|
-
({attrs, children}) => m(
|
|
9
|
-
".buttonchoice.withicon.flexrow.scaff.scaff-b1.fadein.ohidden.fa-" + (attrs.icon || "gear"),
|
|
10
|
-
{class: (attrs.containerClass || "col-11 grows marg-1"), title: attrs.title},
|
|
11
|
-
m(
|
|
12
|
-
(attrs.themeClass ? attrs.themeClass:".flexrow.wrap") + ".grows.col-11.ohidden.scaff-left.bg-inputs",
|
|
13
|
-
{class: attrs.class},
|
|
14
|
-
children
|
|
15
|
-
)
|
|
16
|
-
)
|
|
17
|
-
),
|
|
18
|
-
optionsPrompt = (items, index, onAdd, onDelete, onEdit, allowUpdate) => {
|
|
19
|
-
|
|
20
|
-
const item = items[index];
|
|
21
|
-
|
|
22
|
-
confirmPromise(
|
|
23
|
-
"Choose an action for this preset",
|
|
24
|
-
onAdd && allowUpdate
|
|
25
|
-
? ["DELETE", "RENAME", "UPDATE", "CANCEL"]
|
|
26
|
-
: ["DELETE", "RENAME", "CANCEL"]
|
|
27
|
-
)
|
|
28
|
-
.then((idx) => {
|
|
29
|
-
|
|
30
|
-
if (idx === 0) {
|
|
31
|
-
items.splice(index, 1);
|
|
32
|
-
if (onDelete) onDelete(index);
|
|
33
|
-
m.redraw();
|
|
34
|
-
} else if (idx === 1) {
|
|
35
|
-
setTimeout(() => promptName(
|
|
36
|
-
"Rename Preset",
|
|
37
|
-
item.title || "",
|
|
38
|
-
"type a name for this preset",
|
|
39
|
-
(newName) => {
|
|
40
|
-
if (newName) {
|
|
41
|
-
newName = newName.trim();
|
|
42
|
-
if (newName) {
|
|
43
|
-
item.title = newName.substring(0, 24);
|
|
44
|
-
m.redraw();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
), 10);
|
|
49
|
-
} else if (onAdd && idx === 2) {
|
|
50
|
-
onAdd(false, index);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
},
|
|
54
|
-
GenericButtonTicker = defineWidget(
|
|
55
|
-
({attrs, children}) => {
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
{
|
|
59
|
-
title, noUpdate, items = [], current, altIndex, onEdit, emptyText,
|
|
60
|
-
onAdd, onSelect, onDelete, addText = "Add New",
|
|
61
|
-
unconfirm, buttonClass, themeIcon, themeTitle
|
|
62
|
-
} = attrs,
|
|
63
|
-
|
|
64
|
-
allItems = [
|
|
65
|
-
|
|
66
|
-
...items.map(
|
|
67
|
-
(item, index) => m(
|
|
68
|
-
"button.grows.marg-1.ellipsis.ohidden.hasShift",
|
|
69
|
-
{
|
|
70
|
-
|
|
71
|
-
class: (buttonClass ? buttonClass : "unitheightsmall scaff-b1")
|
|
72
|
-
+ (index === current ? " accent" : "")
|
|
73
|
-
+ (index === altIndex ? " alt-accent" : ""),
|
|
74
|
-
|
|
75
|
-
title,
|
|
76
|
-
onclick: (e) => {
|
|
77
|
-
if (e.metaKey && onEdit) {
|
|
78
|
-
onEdit(item);
|
|
79
|
-
} else if (onAdd && e.shiftKey) {
|
|
80
|
-
if (unconfirm) {
|
|
81
|
-
items.splice(index, 1);
|
|
82
|
-
if (onDelete) onDelete(index);
|
|
83
|
-
m.redraw();
|
|
84
|
-
} else {
|
|
85
|
-
optionsPrompt(items, index, onAdd, onDelete, undefined, !noUpdate);
|
|
86
|
-
}
|
|
87
|
-
} else {
|
|
88
|
-
onSelect && onSelect(item, index, e.metaKey, e.shiftKey);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
(item.title || item.name || item.text || String(1 + index)).substring(0, 32)
|
|
93
|
-
)
|
|
94
|
-
),
|
|
95
|
-
|
|
96
|
-
...!items.length && emptyText
|
|
97
|
-
? [
|
|
98
|
-
m(".grows.marg-1.ellipsis.ohidden.al-center", emptyText)
|
|
99
|
-
] : [],
|
|
100
|
-
|
|
101
|
-
...onAdd
|
|
102
|
-
? [
|
|
103
|
-
m(ButtonNew, {
|
|
104
|
-
tabIndex: -1,
|
|
105
|
-
icon: attrs.icon || "plus",
|
|
106
|
-
title: attrs.addTitle || "Add a new item",
|
|
107
|
-
class: "pad-2 pad-h al-center unitheightsmall transp addbut scaff-left bg-window-lo grows" + (items.length ? " some" : " empty"),
|
|
108
|
-
onClick: (e) => onAdd(e.ctrlKey || e.metaKey),
|
|
109
|
-
text: items?.length ? "" : addText
|
|
110
|
-
})
|
|
111
|
-
]
|
|
112
|
-
: [],
|
|
113
|
-
|
|
114
|
-
...!themeIcon && attrs.currentWidget && current >= 0 && items[current]
|
|
115
|
-
? attrs.currentWidget(items[current], current) || []
|
|
116
|
-
: [],
|
|
117
|
-
|
|
118
|
-
...!themeIcon && attrs.altCurrentWidget && altIndex >= 0 && items[altIndex]
|
|
119
|
-
? attrs.altCurrentWidget(items[altIndex], current) || []
|
|
120
|
-
: [],
|
|
121
|
-
|
|
122
|
-
...children
|
|
123
|
-
];
|
|
124
|
-
|
|
125
|
-
return themeIcon
|
|
126
|
-
? [
|
|
127
|
-
m(ThematicWrapper, {
|
|
128
|
-
title: themeTitle,
|
|
129
|
-
containerClass: attrs.containerClass,
|
|
130
|
-
themeClass: attrs.themeClass,
|
|
131
|
-
icon: themeIcon
|
|
132
|
-
}, allItems),
|
|
133
|
-
...attrs.currentWidget && current >= 0 && items[current] ? attrs.currentWidget(items[current], current) || [] : [],
|
|
134
|
-
...attrs.altCurrentWidget && altIndex >= 0 && items[altIndex] ? attrs.altCurrentWidget(items[altIndex], altIndex) || [] : [],
|
|
135
|
-
|
|
136
|
-
] : allItems;
|
|
137
|
-
}
|
|
138
|
-
),
|
|
139
|
-
CoolGenericTicker = defineWidget(
|
|
140
|
-
({attrs, children}) => {
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
{
|
|
144
|
-
nocontainer,
|
|
145
|
-
emptyText,
|
|
146
|
-
title,
|
|
147
|
-
addTitle,
|
|
148
|
-
items,
|
|
149
|
-
currentIndex,
|
|
150
|
-
altIndex,
|
|
151
|
-
onEdit,
|
|
152
|
-
onDelta,
|
|
153
|
-
onSelect,
|
|
154
|
-
onAdd,
|
|
155
|
-
addText,
|
|
156
|
-
icon,
|
|
157
|
-
buttonClass
|
|
158
|
-
} = attrs,
|
|
159
|
-
itemz = ((items && items.length <= (attrs.max || 15)) || !onDelta)
|
|
160
|
-
? m(GenericButtonTicker, {
|
|
161
|
-
addTitle,
|
|
162
|
-
emptyText,
|
|
163
|
-
title,
|
|
164
|
-
items,
|
|
165
|
-
current: currentIndex,
|
|
166
|
-
altIndex,
|
|
167
|
-
onSelect,
|
|
168
|
-
onAdd,
|
|
169
|
-
onEdit,
|
|
170
|
-
addText,
|
|
171
|
-
icon,
|
|
172
|
-
buttonClass
|
|
173
|
-
}, children)
|
|
174
|
-
: [
|
|
175
|
-
m(ButtonNew, {
|
|
176
|
-
tabIndex: -1,
|
|
177
|
-
icon: "caret-right",
|
|
178
|
-
class: "unitheightsmall grows marg-1 no-marg-left",
|
|
179
|
-
onClick: () => onDelta(-1)
|
|
180
|
-
}),
|
|
181
|
-
...items
|
|
182
|
-
? [
|
|
183
|
-
m(
|
|
184
|
-
".scaff.unitheightsmall.value.al-center.bg-window-lo.grows.marg-1.no-marg-left ",
|
|
185
|
-
(1 + currentIndex) + " / " + items.length
|
|
186
|
-
)
|
|
187
|
-
]
|
|
188
|
-
: [],
|
|
189
|
-
m(ButtonNew, {
|
|
190
|
-
tabIndex: -1,
|
|
191
|
-
icon: "caret-left",
|
|
192
|
-
class: "unitheightsmall grows marg-1 marg-v",
|
|
193
|
-
onClick: () => onDelta(1)
|
|
194
|
-
}),
|
|
195
|
-
...onAdd
|
|
196
|
-
? [
|
|
197
|
-
m(ButtonNew, {
|
|
198
|
-
tabIndex: -1,
|
|
199
|
-
icon: attrs.icon || "plus",
|
|
200
|
-
class: "unitheightsmall marg-1 marg-v",
|
|
201
|
-
onClick: () => onAdd()
|
|
202
|
-
})
|
|
203
|
-
] : []
|
|
204
|
-
];
|
|
205
|
-
|
|
206
|
-
return nocontainer
|
|
207
|
-
? itemz
|
|
208
|
-
: items.length || !onAdd ? m(
|
|
209
|
-
".flexrow.wrap.max.minusbar",
|
|
210
|
-
{class: (attrs.dynclass ? attrs.dynclass() + " " : "") + attrs.class},
|
|
211
|
-
itemz
|
|
212
|
-
) : [];
|
|
213
|
-
}
|
|
214
|
-
),
|
|
215
|
-
|
|
216
|
-
CoolContentTicker = defineWidget(
|
|
217
|
-
({attrs}) => {
|
|
218
|
-
|
|
219
|
-
if (!attrs.layer.items) return [];
|
|
220
|
-
|
|
221
|
-
const
|
|
222
|
-
{global, layer, remoteFirst: isRemote, isCue} = attrs,
|
|
223
|
-
{storyWrapper} = global,
|
|
224
|
-
{id, items} = layer,
|
|
225
|
-
|
|
226
|
-
currentIndex = storyWrapper.getTickerIndex(id, isRemote),
|
|
227
|
-
altIndex = isRemote ? storyWrapper.getTickerIndex(id, false) : undefined;
|
|
228
|
-
|
|
229
|
-
// noinspection JSUnusedGlobalSymbols
|
|
230
|
-
return m(CoolGenericTicker, {
|
|
231
|
-
title: attrs.title,
|
|
232
|
-
onAdd: attrs.onAdd,
|
|
233
|
-
class: "marg-1 marg-h grows",
|
|
234
|
-
items,
|
|
235
|
-
currentIndex,
|
|
236
|
-
altIndex,
|
|
237
|
-
current: items[currentIndex] || undefined,
|
|
238
|
-
onDelta: (direction) => storyWrapper.tickLayer(layer, direction, isRemote, isCue),
|
|
239
|
-
onSelect: (item, index, force) => storyWrapper.setTickerIndex(layer, index, force, isRemote, isCue)
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
);
|
|
243
|
-
|
|
244
|
-
export {CoolContentTicker, CoolGenericTicker, GenericButtonTicker, ThematicWrapper, optionsPrompt};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import m from "mithril"
|
|
2
|
-
import {defineWidget, ButtonNew, Empty} from "./Basic.js"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function TRANSLATE(message, arr, def) {
|
|
6
|
-
return arr ? arr[message] || (def || message) : (def || message);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
CoolerEmpty = {
|
|
11
|
-
oninit: ({attrs}) => {
|
|
12
|
-
attrs.oninit && attrs.oninit()
|
|
13
|
-
},
|
|
14
|
-
view: ({attrs}) => m(Empty, {
|
|
15
|
-
class: attrs.class,
|
|
16
|
-
icon: attrs.icon,
|
|
17
|
-
size: attrs.size || 4
|
|
18
|
-
}, [
|
|
19
|
-
...attrs.header ? [m("h3.pad-2.marg-0", TRANSLATE(attrs.header, attrs.headers))] : [],
|
|
20
|
-
m(".pad-2", TRANSLATE(attrs.message, attrs.messages)),
|
|
21
|
-
...attrs.action ? [
|
|
22
|
-
m(ButtonNew, {
|
|
23
|
-
text: attrs.action.caption,
|
|
24
|
-
class: "accentbutton marg-4 marg-v pad-2 font-150",
|
|
25
|
-
onClick: attrs.action.onclick
|
|
26
|
-
})
|
|
27
|
-
] : [],
|
|
28
|
-
...attrs.actions
|
|
29
|
-
? attrs.actions.map((action) => m(ButtonNew, {
|
|
30
|
-
text: action.caption,
|
|
31
|
-
class: "accentbutton marg-4 marg-v pad-2 font-150",
|
|
32
|
-
onClick: action.onclick
|
|
33
|
-
}))
|
|
34
|
-
: []
|
|
35
|
-
])
|
|
36
|
-
};
|
|
37
|
-
export default CoolerEmpty;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import m from "mithril"
|
|
2
|
-
import {defineWidget, ButtonNew, Empty} from "./Basic.js"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const EmptyButton = defineWidget(
|
|
6
|
-
({attrs}) => m(
|
|
7
|
-
Empty,
|
|
8
|
-
{
|
|
9
|
-
size: 2,
|
|
10
|
-
icon: attrs.icon,
|
|
11
|
-
class: "pad-2"
|
|
12
|
-
},
|
|
13
|
-
[
|
|
14
|
-
...attrs.texts
|
|
15
|
-
.map((text) => m(".text", text)),
|
|
16
|
-
...attrs.buttonText ? [
|
|
17
|
-
m(ButtonNew, {
|
|
18
|
-
class: "font-125 accentbutton unitheightsmall",
|
|
19
|
-
icon: attrs.icon || "plus",
|
|
20
|
-
text: attrs.buttonText,
|
|
21
|
-
onClick: attrs.onClick
|
|
22
|
-
})
|
|
23
|
-
] : [],
|
|
24
|
-
...attrs.buttonAlt ? [
|
|
25
|
-
m(ButtonNew, {
|
|
26
|
-
class: "font-125 accentbutton unitheightsmall",
|
|
27
|
-
icon: attrs.iconAlt || "plus",
|
|
28
|
-
text: attrs.buttonTextAlt,
|
|
29
|
-
onClick: attrs.onClick
|
|
30
|
-
})
|
|
31
|
-
] : []
|
|
32
|
-
]
|
|
33
|
-
)
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
export default EmptyButton;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import m from "mithril";
|
|
2
|
-
import {defineWidget, ButtonNew} from "./Basic";
|
|
3
|
-
import MainState from "../app/MainState.js"
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
// TODO
|
|
7
|
-
FontSelectorButton = defineWidget(
|
|
8
|
-
({attrs}) => {
|
|
9
|
-
const {fontFamily, state, onchange} = attrs;
|
|
10
|
-
return m(".flexrow.grows.fontgroup", {class: attrs.class}, [
|
|
11
|
-
...fontFamily && !attrs.nodelete
|
|
12
|
-
? [
|
|
13
|
-
m(ButtonNew, {
|
|
14
|
-
class: "scaff-right unitsize",
|
|
15
|
-
icon: "trash",
|
|
16
|
-
onClick: () => {
|
|
17
|
-
onchange(undefined);
|
|
18
|
-
MainState.setTransState();
|
|
19
|
-
}
|
|
20
|
-
})
|
|
21
|
-
]
|
|
22
|
-
: [],
|
|
23
|
-
m(ButtonNew, {
|
|
24
|
-
class: "grows transp font-125 ohidden",
|
|
25
|
-
text: fontFamily || "default",
|
|
26
|
-
icon: "font",
|
|
27
|
-
onClick: () => MainState.setTransState("fontsel", (selected) => {
|
|
28
|
-
onchange(selected);
|
|
29
|
-
MainState.setTransState();
|
|
30
|
-
})
|
|
31
|
-
}),
|
|
32
|
-
|
|
33
|
-
]);
|
|
34
|
-
}
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
export default FontSelectorButton;
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import m from "mithril";
|
|
2
|
-
import {ButtonNew} from "./Basic";
|
|
3
|
-
|
|
4
|
-
/* eslint-disable no-prototype-builtins,no-nested-ternary */
|
|
5
|
-
/* global m, Hammer */
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
getInput = (attrs, value, parse = false) => {
|
|
10
|
-
if (parse || attrs.type === "number") {
|
|
11
|
-
const val = attrs.float ? Number.parseFloat(value) : Number.parseInt(value, 10);
|
|
12
|
-
return Number.isNaN(val) ? undefined : val;
|
|
13
|
-
}
|
|
14
|
-
return value;
|
|
15
|
-
},
|
|
16
|
-
getValue = (attrs, state, parse) => {
|
|
17
|
-
const lastVal = state.hasOwnProperty("value") ? state.value : attrs.value;
|
|
18
|
-
return getInput(attrs, lastVal, parse);
|
|
19
|
-
},
|
|
20
|
-
/*
|
|
21
|
-
hammer = new Hammer.Manager(dom, { touchAction: "pan-y" }),
|
|
22
|
-
panner = new Hammer.Pan({ direction: Hammer.DIRECTION_VERTICAL }),
|
|
23
|
-
singleTap = listenTap && new Hammer.Tap();
|
|
24
|
-
|
|
25
|
-
hammer.add(listenTap ? [panner, singleTap] : [panner]);
|
|
26
|
-
hammer.on("panstart", (e) => {
|
|
27
|
-
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
StaticFieldWidget = {
|
|
31
|
-
view: (vnode) => {
|
|
32
|
-
const {attrs, state} = vnode;
|
|
33
|
-
// este vnode NO es el mismo que el del hammer, pero su estado SI !
|
|
34
|
-
state.attrs = attrs; // guardamos una copia de los ultimos attrs en el estado
|
|
35
|
-
|
|
36
|
-
return m(
|
|
37
|
-
".input-static.w-100.ellipsis",
|
|
38
|
-
{
|
|
39
|
-
class: (attrs.onDrag ? "withdrag " : "") + (attrs.staticClass || "grows"),
|
|
40
|
-
...attrs.staticTitle && {title: attrs.staticTitle},
|
|
41
|
-
...attrs.onDrag || {onclick: attrs.onClick},
|
|
42
|
-
oncreate: ({dom, state}) => {
|
|
43
|
-
|
|
44
|
-
if (attrs.onDrag && !attrs.readonly) {
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
hammer = state.hammer = new Hammer.Manager(dom, {touchAction: "pan-y"}),
|
|
48
|
-
panner = new Hammer.Pan({direction: Hammer.DIRECTION_VERTICAL}),
|
|
49
|
-
singleTap = new Hammer.Tap();
|
|
50
|
-
|
|
51
|
-
hammer.add([panner, singleTap]);
|
|
52
|
-
hammer.on("tap", () => vnode.state.attrs.onClick());
|
|
53
|
-
hammer.on("panup", (e) => vnode.state.attrs.onDrag(-1, e.srcEvent));
|
|
54
|
-
hammer.on("pandown", (e) => vnode.state.attrs.onDrag(1, e.srcEvent));
|
|
55
|
-
hammer.on("panend pancancel", (e) => vnode.state.attrs.onDrag(0, e.srcEvent));
|
|
56
|
-
}
|
|
57
|
-
if (attrs.focus) {
|
|
58
|
-
dom.focus();
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
onremove: ({state}) => {
|
|
62
|
-
state.hammer && state.hammer.destroy();
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
attrs.value
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
InputWidget = {
|
|
70
|
-
view: ({attrs, state}) => {
|
|
71
|
-
const reset = (redraw) => {
|
|
72
|
-
// if (state.value !== undefined && state.showInput) delete state.showInput;
|
|
73
|
-
if (state.value && state.showInput) delete state.showInput;
|
|
74
|
-
delete state.value;
|
|
75
|
-
if (redraw) m.redraw();
|
|
76
|
-
},
|
|
77
|
-
inputActions = [
|
|
78
|
-
...(attrs.multi && !attrs.alwaysmulti && (!attrs.type || attrs.type === "text"))
|
|
79
|
-
? [
|
|
80
|
-
m(ButtonNew, {
|
|
81
|
-
icon: state.multi ? "angle-double-up" : "angle-double-down",
|
|
82
|
-
class: "pad-2 transp inputaction",
|
|
83
|
-
onClick: () => {
|
|
84
|
-
state.multi = !state.multi;
|
|
85
|
-
m.redraw();
|
|
86
|
-
}
|
|
87
|
-
})
|
|
88
|
-
]
|
|
89
|
-
: [],
|
|
90
|
-
|
|
91
|
-
...attrs.actions ? attrs.actions.map((action) => m(ButtonNew, {
|
|
92
|
-
...action,
|
|
93
|
-
class: "inputaction transp pad-2"
|
|
94
|
-
})) : [],
|
|
95
|
-
|
|
96
|
-
...attrs.action
|
|
97
|
-
? [
|
|
98
|
-
m(ButtonNew, {...attrs.action, class: "inputaction transp pad-2"})
|
|
99
|
-
] : []
|
|
100
|
-
];
|
|
101
|
-
|
|
102
|
-
return m(
|
|
103
|
-
".textfield.flexcol.relative",
|
|
104
|
-
{
|
|
105
|
-
class: (attrs.label ? "witharia" : "") + (attrs.containerClass ? " " + attrs.containerClass : ""),
|
|
106
|
-
...attrs.label && {"aria-label": attrs.label}
|
|
107
|
-
},
|
|
108
|
-
m(".textfieldinner.flexrow", [
|
|
109
|
-
(attrs.staticField && (attrs.readonly || !state.showInput))
|
|
110
|
-
? m(StaticFieldWidget, {
|
|
111
|
-
readonly: attrs.readonly,
|
|
112
|
-
staticClass: (state.dragging ? "accent " : "") + (attrs.staticClass || ""),
|
|
113
|
-
staticTitle: attrs.staticTitle || attrs.draginc && "Click then drag up and down to modify value, or just click to enter a custom value",
|
|
114
|
-
value: attrs.displayTitle || getValue(attrs, state),
|
|
115
|
-
focus: attrs.focus,
|
|
116
|
-
...attrs.draginc && !attrs.readonly && {
|
|
117
|
-
onDrag: (direction, event) => {
|
|
118
|
-
if (direction) {
|
|
119
|
-
state.dragging = true;
|
|
120
|
-
let value = getValue(attrs, state, true);
|
|
121
|
-
if (Number.isNaN(value) || value === undefined) return;
|
|
122
|
-
value += direction * attrs.draginc;
|
|
123
|
-
if (attrs.max !== undefined && value > attrs.max) value = attrs.max;
|
|
124
|
-
if (attrs.min !== undefined && value < attrs.min) value = attrs.min;
|
|
125
|
-
state.value = attrs.type === "number" ? value : String(value);
|
|
126
|
-
attrs.onchange(state.value, event);
|
|
127
|
-
} else {
|
|
128
|
-
delete state.dragging;
|
|
129
|
-
delete state.value;
|
|
130
|
-
m.redraw();
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
...attrs.readonly || {
|
|
135
|
-
onClick: () => {
|
|
136
|
-
state.showInput = true;
|
|
137
|
-
state.value = attrs.value;
|
|
138
|
-
m.redraw();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
: ((state.multi || attrs.alwaysmulti) && (!attrs.type || attrs.type === "text"))
|
|
144
|
-
? m("textarea.w-100", {
|
|
145
|
-
class: attrs.class,
|
|
146
|
-
value: getValue(attrs, state),
|
|
147
|
-
...attrs.title && {title: attrs.title},
|
|
148
|
-
placeholder: attrs.hint || "",
|
|
149
|
-
oninput: (event) => {
|
|
150
|
-
state.value = getInput(attrs, event.target.value);
|
|
151
|
-
if (attrs.validator) state.isValid = attrs.validator(state.value);
|
|
152
|
-
if (attrs.onchange) {
|
|
153
|
-
(attrs.oninput || attrs.onchange)(state.value, event, true);
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
onchange: (event) => {
|
|
157
|
-
if (attrs.onchange) {
|
|
158
|
-
if (attrs.validator) state.isValid = attrs.validator(state.value);
|
|
159
|
-
const value = getInput(attrs, event.target.value);
|
|
160
|
-
reset(false);
|
|
161
|
-
attrs.onchange(value, event, true);
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
onblur: () => {
|
|
165
|
-
if (state.showInput) {
|
|
166
|
-
reset(true);
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
onkeyup: (event) => {
|
|
170
|
-
if (event.key === "Escape" && state.showInput) {
|
|
171
|
-
reset(false);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
})
|
|
175
|
-
: m("input.w-100", {
|
|
176
|
-
...attrs.id && {id: attrs.id},
|
|
177
|
-
type: attrs.type || "text",
|
|
178
|
-
...attrs.max !== undefined && {max: attrs.max},
|
|
179
|
-
...attrs.min !== undefined && {min: attrs.min},
|
|
180
|
-
...attrs.step > 0 && {step: attrs.step},
|
|
181
|
-
...attrs.maxlength && {maxlength: attrs.maxlength},
|
|
182
|
-
class: (attrs.class || "") + (attrs.validator ? state.isValid ? " bg-ok" : " bg-error" : ""),
|
|
183
|
-
...attrs.title && {title: attrs.title},
|
|
184
|
-
value: getValue(attrs, state),
|
|
185
|
-
placeholder: attrs.hint || "",
|
|
186
|
-
...attrs.readonly
|
|
187
|
-
? {
|
|
188
|
-
readonly: "readonly"
|
|
189
|
-
}
|
|
190
|
-
: {
|
|
191
|
-
oninput: (event) => {
|
|
192
|
-
state.value = getInput(attrs, event.target.value);
|
|
193
|
-
event.fromoninput = true;
|
|
194
|
-
if (attrs.validator) state.isValid = attrs.validator(state.value);
|
|
195
|
-
if (attrs.onchange) {
|
|
196
|
-
(attrs.oninput || attrs.onchange)(state.value, event);
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
onchange: (event) => {
|
|
200
|
-
if (attrs.onchange) {
|
|
201
|
-
if (attrs.validator) state.isValid = attrs.validator(state.value);
|
|
202
|
-
event.enterPressed = state.enterPressed;
|
|
203
|
-
delete state.enterPressed;
|
|
204
|
-
attrs.onchange(getInput(attrs, event.target.value), event);
|
|
205
|
-
if (attrs.staticField) {
|
|
206
|
-
reset(true);
|
|
207
|
-
} else {
|
|
208
|
-
delete state.value;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
|
-
onblur: () => {
|
|
213
|
-
if (state.showInput) {
|
|
214
|
-
reset(true);
|
|
215
|
-
}
|
|
216
|
-
},
|
|
217
|
-
onkeyup: (event) => {
|
|
218
|
-
if (state.showInput) {
|
|
219
|
-
if (event.key === "Escape") {
|
|
220
|
-
reset(true);
|
|
221
|
-
} else if (event.key === "Enter") {
|
|
222
|
-
if (state.value === attrs.value || !state.value) {
|
|
223
|
-
attrs.onchange(attrs.value, event);
|
|
224
|
-
reset(true);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
},
|
|
229
|
-
onbeforeinput: (e) => {
|
|
230
|
-
if (attrs.subtype === "number" && e.data && !/^[0-9.\-]$/.test(e.data)) {
|
|
231
|
-
e.preventDefault(); // nothing but 0-9 or “.” gets through
|
|
232
|
-
}
|
|
233
|
-
},
|
|
234
|
-
inputmode: attrs.subtype === "number" ? "decimal" : undefined, // nicer mobile keyboard
|
|
235
|
-
onkeypress: (event) => {
|
|
236
|
-
if (!state.showInput && event.key === "Enter") {
|
|
237
|
-
attrs.onenter && attrs.onenter(event.target.value, event);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
},
|
|
241
|
-
}),
|
|
242
|
-
|
|
243
|
-
...inputActions.length ? [m(".span.actions", inputActions)] : [],
|
|
244
|
-
]));
|
|
245
|
-
},
|
|
246
|
-
oninit: ({attrs, state}) => {
|
|
247
|
-
if (attrs.staticField && attrs.draginc) {
|
|
248
|
-
const value = getValue(attrs, state, true);
|
|
249
|
-
state.showInput = (Number.isNaN(value) || value === undefined || value === null);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
export default InputWidget;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import m from "mithril";
|
|
2
|
-
import {Icon, defineWidget} from "./Basic";
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
NoticeWidget = defineWidget(
|
|
6
|
-
({attrs, children}) => (
|
|
7
|
-
children.length
|
|
8
|
-
? m(
|
|
9
|
-
".notice.cardie.flexcol.pad-3",
|
|
10
|
-
{class: attrs.class || "marg-2 font-75"},
|
|
11
|
-
m(
|
|
12
|
-
".flexrow",
|
|
13
|
-
[
|
|
14
|
-
...attrs.icon ? [m(Icon, attrs)] : [],
|
|
15
|
-
m(".pad-2.pad-h", attrs.text)
|
|
16
|
-
]
|
|
17
|
-
),
|
|
18
|
-
...children
|
|
19
|
-
)
|
|
20
|
-
: m(
|
|
21
|
-
".notice.cardie.flexrow.pad-3",
|
|
22
|
-
{class: attrs.class || "marg-2 font-75", onclick: attrs.onClick},
|
|
23
|
-
[
|
|
24
|
-
...attrs.icon ? [m(Icon, attrs)] : [],
|
|
25
|
-
(attrs.texts || [attrs.text]).map((t) => m(".pad-2.pad-h", t))
|
|
26
|
-
]
|
|
27
|
-
)
|
|
28
|
-
)
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
export default NoticeWidget;
|