@nebularstreams/libmui 3.1.1 → 4.0.1

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.
Files changed (78) hide show
  1. package/dist/libmui.esm.js +3 -0
  2. package/dist/libmui.esm.min.js +3 -0
  3. package/package.json +6 -2
  4. package/dist/libui.esm.js +0 -3
  5. package/rollup.config.js +0 -20
  6. package/src/app/MainState.js +0 -22
  7. package/src/app/app.js +0 -9
  8. package/src/css/a-measures.css +0 -6
  9. package/src/css/b-colors.css +0 -12
  10. package/src/css/b-root-bootstrap-ext.css +0 -81
  11. package/src/css/b-root-bootstrap.css +0 -178
  12. package/src/css/b-root-semantic-flex.css +0 -87
  13. package/src/css/b-root-semantic-size-new.css +0 -37
  14. package/src/css/b-root-semantic-size.css +0 -75
  15. package/src/css/b-root-semantic-skin.css +0 -48
  16. package/src/css/b-root-semantic.css +0 -111
  17. package/src/css/b-root.css +0 -3
  18. package/src/css/cardie.css +0 -6
  19. package/src/css/flex.css +0 -46
  20. package/src/css/fontawesome/brands.min.css +0 -16
  21. package/src/css/fontawesome/fontawesome-ext.css +0 -7
  22. package/src/css/fontawesome/fontawesome-solid.css +0 -17
  23. package/src/css/fontawesome/fontawesome.css +0 -4359
  24. package/src/css/ui.notifications.css +0 -23
  25. package/src/css/ui.popup.css +0 -127
  26. package/src/css/ui.witharia.css +0 -25
  27. package/src/index.js +0 -112
  28. package/src/meta/InputTemplates.js +0 -3
  29. package/src/style.js +0 -37
  30. package/src/util/colorjoe.js +0 -1370
  31. package/src/util/filepath.js +0 -10
  32. package/src/util/fuckingconfirm.js +0 -28
  33. package/src/util/mithril-range.js +0 -445
  34. package/src/util/tainter.js +0 -39
  35. package/src/util/util.clone.js +0 -8
  36. package/src/util/util.tokenizer.js +0 -266
  37. package/src/util/widgets.core.js +0 -314
  38. package/src/util/widgets.js +0 -79
  39. package/src/util/widgets.utils.js +0 -10
  40. package/src/widgets/Basic.js +0 -352
  41. package/src/widgets/ButtonChoiceWidget.js +0 -72
  42. package/src/widgets/CardieWidget.js +0 -168
  43. package/src/widgets/ColorJoePack.js +0 -108
  44. package/src/widgets/ColorJoeWidget.js +0 -140
  45. package/src/widgets/ComboPrompt.js +0 -112
  46. package/src/widgets/ComboWidget.js +0 -156
  47. package/src/widgets/CoolContentTicker.js +0 -244
  48. package/src/widgets/CoolerEmpty.js +0 -37
  49. package/src/widgets/EmptyButton.js +0 -36
  50. package/src/widgets/FontSelectorButton.js +0 -37
  51. package/src/widgets/InputWidget.js +0 -254
  52. package/src/widgets/NoticeWidget.js +0 -31
  53. package/src/widgets/OverflowUtils.js +0 -449
  54. package/src/widgets/PlusMinusWidget.js +0 -55
  55. package/src/widgets/RangeWidget.js +0 -200
  56. package/src/widgets/SelectFileMiniButton.js +0 -170
  57. package/src/widgets/Separator.js +0 -21
  58. package/src/widgets/SmileysButton.js +0 -19
  59. package/src/widgets/SwitchWidget.js +0 -42
  60. package/src/widgets/TemplatedInputWidget.js +0 -1395
  61. package/src/widgets/TitleBarWidget.js +0 -71
  62. package/src/widgets/css/buttonchoice.css +0 -62
  63. package/src/widgets/css/buttonchoice.toggle.css +0 -37
  64. package/src/widgets/css/choicer.css +0 -24
  65. package/src/widgets/css/colorjoe.css +0 -230
  66. package/src/widgets/css/colorjoewidget.css +0 -105
  67. package/src/widgets/css/combo-ellipsis.css +0 -29
  68. package/src/widgets/css/fileminibutton.css +0 -12
  69. package/src/widgets/css/input.css +0 -35
  70. package/src/widgets/css/mithril-range.css +0 -69
  71. package/src/widgets/css/progressstrip.css +0 -31
  72. package/src/widgets/css/range-anims.css +0 -23
  73. package/src/widgets/css/separator.css +0 -21
  74. package/src/widgets/css/smileys.css +0 -85
  75. package/src/widgets/css/templatedinput.css +0 -67
  76. package/src/widgets/css/ui.titlebar.css +0 -44
  77. package/src/widgets/css/uploadfile.css +0 -5
  78. /package/dist/{libui.css → libmui.css} +0 -0
@@ -1,108 +0,0 @@
1
- import m from "mithril";
2
- import {ButtonNew, defineWidget} from "./Basic";
3
- import ColorJoeWidget from "./ColorJoeWidget";
4
-
5
- const
6
- DEFAULT_COLOR = [255, 255, 255, 1],
7
- hslToRgb = (h, s, l) => {
8
-
9
- let r,
10
- g,
11
- b;
12
-
13
- if (s === 0) {
14
- r = g = b = l; // achromatic
15
- } else {
16
- const hue2rgb = (p, q, t) => {
17
- if (t < 0) t += 1;
18
- if (t > 1) t -= 1;
19
- if (t < 1 / 6) return p + (q - p) * 6 * t;
20
- if (t < 1 / 2) return q;
21
- if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
22
- return p;
23
- };
24
-
25
- const
26
- q = l < 0.5 ? l * (1 + s) : l + s - l * s,
27
- p = 2 * l - q;
28
-
29
- r = hue2rgb(p, q, h + 1 / 3);
30
- g = hue2rgb(p, q, h);
31
- b = hue2rgb(p, q, h - 1 / 3);
32
- }
33
-
34
- return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
35
- };
36
-
37
- export default defineWidget(
38
- ({attrs}) => {
39
-
40
- const
41
- {colors = [], max = 8} = attrs,
42
- length = colors.length,
43
- getRgb = (colorBase = [0, 0, 0, 0]) => ("rgba("
44
- + (colorBase.map((c, i) => (i < 3 ? Math.floor(c * 255) : c)).join(",")) + ")"),
45
-
46
- getHsl = (colorBase = [0, 0, 0, 0]) => ("rgba("
47
- + (hslToRgb(colorBase[0], colorBase[1], colorBase[2]).join(","))
48
- + "," + colorBase[3] + ")");
49
-
50
- return m(".flexrow.wrap.gradient.grows",
51
- {
52
- class: attrs.class
53
- },
54
- [
55
-
56
- ...colors.map((entry, index) => m(
57
- ColorJoeWidget,
58
- {
59
- class: "grows",
60
- color: attrs.hsl ? getHsl(colors[index]) : getRgb(colors[index]),
61
- title: "Click to edit, or Shift-click to remove this color from the collection",
62
- hsl: attrs.hsl,
63
- onchange: (parsedColor, colorObject) => {
64
- let finalColor;
65
- if (attrs.hsl) {
66
- const hsl = colorObject.hsl();
67
- finalColor = [hsl.hue(), hsl.saturation(), hsl.lightness(), colorObject.a()];
68
- } else {
69
- finalColor = [colorObject.r(), colorObject.g(), colorObject.b(), colorObject.a()];
70
- }
71
- colors[index] = finalColor;
72
- if (attrs.onchange) {
73
- attrs.onchange(colors);
74
- }
75
- m.redraw();
76
- },
77
- onshiftclick: () => {
78
- colors.splice(index, 1);
79
- if (attrs.onchange) {
80
- attrs.onchange(colors);
81
- }
82
- m.redraw();
83
- }
84
- }
85
- )),
86
-
87
- ...(length < max)
88
- ? [
89
- m(ButtonNew, {
90
- icon: "plus",
91
- class: "unitheightsmall accent bg-window-lo " + (length ? "mini" : "grows"),
92
- title: "Add a new color to the collection, or SHIFT-CLICK to delete all colors",
93
- onClick: (e) => {
94
- if (e.shiftKey) {
95
- colors.splice(0, colors.length);
96
- } else {
97
- colors.push(DEFAULT_COLOR);
98
- }
99
- if (attrs.onchange) {
100
- attrs.onchange(colors);
101
- }
102
- m.redraw();
103
- }
104
- })
105
- ] : []
106
- ]);
107
- }
108
- );
@@ -1,140 +0,0 @@
1
- import m from "mithril";
2
- import defineWidget from "../util/widgets.utils";
3
- import {popupMessage} from "../util/widgets"
4
- import colorjoe from "../util/colorjoe"
5
-
6
- const
7
- ColorJoe = defineWidget(
8
- () => m(".colorjoe-frame.absolute"),
9
- null,
10
- ({attrs, dom}) => {
11
-
12
- window.SCALE = 1;
13
-
14
- attrs.state.joe = (attrs.hsl ? colorjoe.hsl : colorjoe.rgb)(
15
- dom,
16
- attrs.color,
17
- attrs.noalpha
18
- ? []
19
- : [
20
- // "currentColor",
21
- "alpha"
22
- ]
23
- );
24
-
25
- attrs.state.joe.on("change", (c) => {
26
- attrs.onColor(attrs.noalpha ? c.css() : c.cssa(), c);
27
- })
28
- .update();
29
- }
30
- ),
31
- FAVORITES = [],
32
- ColorJoeWrapper = defineWidget(
33
- ({attrs, state, children}) => m(".colorjoe-popper.flexcol", {
34
- class: attrs.noalpha ? "no-alpha" : ""
35
- }, [
36
- m(ColorJoe, {...attrs, state}),
37
- ...children,
38
- m(".flexrow.extended.w-100.scaff-top.pad-2.wrap", [
39
-
40
- [0, 1, 2, 3, 4, 5, 6, 7, 8].map((i) => m("button.scaff.scaff-b1.marg-1.unitheightsmall.grows", {
41
- class: FAVORITES[i] ? "" : "chequered",
42
- style: {
43
- ...FAVORITES[i] && {backgroundColor: FAVORITES[i]}
44
- },
45
- onclick: (e) => {
46
- if (e.shiftKey) {
47
- FAVORITES[i] = state.joe.get()
48
- .css();
49
- } else {
50
- if (FAVORITES[i]) state.joe.set(FAVORITES[i]);
51
- }
52
- if (attrs.onRedraw) attrs.onRedraw(); else m.redraw();
53
- }
54
- })),
55
- m(".flexbreak"),
56
- /* TODO ELECTRON
57
- m(ColorProbeButton, {
58
- class: "grows marg-1 scaff scaff-b1 unitheightsmall",
59
- icon: "magic",
60
- title: "Pick a color from the scene",
61
- onColor: (color) => state.joe.set(color)
62
- }),
63
- */
64
- ...attrs.onRemove ? [m("button.scaff.scaff-b1.unitheightsmall.marg-1.pad-2.pad-h.grows.fabf.transp.bg-accent.fa-trash", {
65
- onclick: () => attrs.onRemove(state.joe.get())
66
- })] : []
67
- ])
68
- ])
69
- ),
70
- popupColor = (vnode) => popupMessage(
71
- () => m(ColorJoeWrapper, {
72
- noalpha: vnode.attrs.noalpha,
73
- color: vnode.state.color,
74
- hsl: vnode.attrs.hsl,
75
- onColor: (parsedColor, colorObject) => {
76
- vnode.state.color = parsedColor;
77
- if (vnode.attrs.onchange) vnode.attrs.onchange(parsedColor, colorObject);
78
- m.redraw();
79
- },
80
- onRemove: () => {
81
- if (vnode.attrs.onchange) vnode.attrs.onchange(null, null);
82
- popupMessage(null);
83
- },
84
- onRedraw: () => {
85
- popupMessage.redraw();
86
- m.redraw();
87
- }
88
- }, vnode.children),
89
-
90
- () => {
91
- },
92
-
93
- ".modal-content-popper"
94
- );
95
-
96
- const ColorJoeWidget = defineWidget(
97
- (vnode) => {
98
- const {attrs, state} = vnode;
99
- return [
100
- m(
101
- ".colorjoe-cell.chequered",
102
- {
103
- class: (attrs.class || "") + (state.shown ? " open" : ""),
104
- title: attrs.title,
105
- ...attrs.style && {style: attrs.style}
106
- },
107
- [
108
- m(".inset", {
109
- style: {
110
- backgroundColor: state.color
111
- },
112
- ...attrs.caption && {"data-caption": attrs.caption, class: "titled"},
113
- onclick: (e) => {
114
- if (attrs.onshiftclick && (e.shiftKey || e.ctrlKey)) {
115
- attrs.onshiftclick();
116
- } else {
117
- popupColor(vnode);
118
- }
119
- }
120
- })
121
- ])
122
- ];
123
- },
124
- ({attrs, state}) => {
125
- state.original = attrs.color;
126
- state.color = state.original || "rgba(0,0,0,0)";
127
- },
128
- null,
129
- null,
130
- ({attrs, state}) => {
131
- if (state.original !== attrs.color) {
132
- state.original = attrs.color;
133
- state.color = state.original || "rgba(0,0,0,0)";
134
- m.redraw();
135
- }
136
- }
137
- );
138
-
139
-
140
- export default ColorJoeWidget;
@@ -1,112 +0,0 @@
1
- import m from "mithril";
2
- import defineWidget from "../util/widgets.utils";
3
- import {confirm} from "../util/fuckingconfirm";
4
- import {ButtonNew} from "./Basic"
5
- import {promptOptions} from "./OverflowUtils";
6
-
7
- function storyOverflow(attrs) {
8
-
9
- const
10
- {
11
- title,
12
- items: maybeFunctionItems,
13
- itemsKey,
14
- itemsText,
15
- field,
16
- onchange,
17
- textNew,
18
- textHint,
19
- resolve,
20
- icon
21
- } = attrs,
22
- source = typeof maybeFunctionItems === "function" ? maybeFunctionItems() : maybeFunctionItems,
23
- items = itemsKey ? typeof itemsKey === "function" ? itemsKey() : source[itemsKey] || [] : source;
24
-
25
- return promptOptions(items, onchange, {title, field, icon, textNew, textHint, resolve});
26
- }
27
-
28
- const
29
- ComboPrompt = defineWidget(
30
- ({attrs}) => m(
31
- ".flexcol.combocontainer.grows", {
32
- class: (attrs.outerClass || "") + " " + (attrs.label ? "witharia" : ""),
33
- ...attrs.label && {"aria-label": attrs.label},
34
- title: attrs.hint
35
- }, [
36
-
37
- m(
38
- ".flexrow.combowidget.bg-inputs",
39
- {
40
- class: (attrs.value ? "yesvalue " : "novalue ") + (attrs.class || "")
41
- },
42
- [
43
- m(ButtonNew, {
44
- class: "transp combovalue grows flexrow " + (attrs.buttonClass || "") + (attrs.innerLabel ? " witharia" : ""),
45
- textClass: "grows " + attrs.textClass,
46
- iconClass: "noshrink",
47
- ...attrs.innerLabel && {"aria-label": attrs.innerLabel},
48
- onClick: (e) => {
49
- if (e.shiftKey) {
50
- attrs.onchange(undefined, e);
51
- } else if (!attrs.locked) {
52
- storyOverflow(attrs);
53
- }
54
- },
55
- ...attrs.value
56
- ? {
57
- icon: attrs.value?.icon || attrs.icon,
58
- text: attrs.field || attrs.fieldTitle
59
- ? attrs.value[attrs.fieldTitle || attrs.field]
60
- : attrs.itemsText
61
- ? attrs.itemsText[attrs.value] || attrs.value
62
- : attrs.value
63
- }
64
- : {
65
- icon: attrs.emptyIcon || (attrs.emptyText ? "" : "plus"),
66
- text: attrs.emptyText || ""
67
- }
68
- }),
69
- attrs.value && !attrs.nodelete
70
- ? [
71
- m(
72
- ButtonNew,
73
- {
74
- class: "clrcombo pad-2 pad-h transp " + (attrs.closeClass || "scaff-left"),
75
- onClick: (e) => {
76
-
77
- const {field} = attrs;
78
- if (attrs.confirm && !e.shiftKey && !e.metaKey && !e.ctrlKey && !e.altKey) {
79
- const msg = (typeof attrs.confirm === "function") ? attrs.confirm() : attrs.confirm;
80
- if (msg) {
81
- confirm(msg, () => {
82
- attrs.onchange(field ? undefined : "", e);
83
- });
84
- } else {
85
- attrs.onchange(field ? undefined : "", e);
86
- }
87
- } else {
88
- attrs.onchange(field ? undefined : "", e);
89
- }
90
- m.redraw();
91
- /*
92
- if (attrs.confirm && !e.shiftKey && !e.metaKey && !e.ctrlKey && !e.altKey) {
93
- confirm(attrs.confirm, () => {
94
- attrs.onchange(attrs.field ? undefined : "", e);
95
- });
96
- } else {
97
- attrs.onchange(attrs.field ? undefined : "", e);
98
- }
99
- m.redraw();
100
- */
101
- },
102
- icon: attrs.removeIcon || "times",
103
- title: attrs.removeHint || "remove this item"
104
- }
105
- )
106
- ]
107
- : []
108
- ]
109
- )])
110
- );
111
-
112
- export default ComboPrompt;
@@ -1,156 +0,0 @@
1
- import m from "mithril";
2
- import "./css/combo-ellipsis.css"
3
-
4
- const
5
- PropGroup = {
6
- view: ({attrs}) => attrs.items.map(({name}, index) => m(
7
- "option",
8
- {
9
- ...(attrs.state.index === index + (attrs.offset || 0)) && {selected: true}
10
- },
11
- name
12
- ))
13
- };
14
-
15
- let
16
- __timer;
17
-
18
- function parseGroups(attrs, state) {
19
-
20
- if (attrs.groups) {
21
-
22
- state.groups = {};
23
- state.allItems = [];
24
-
25
- attrs.parsed = true;
26
-
27
- const
28
- groupKeys = Object.keys(attrs.groups);
29
-
30
- groupKeys.forEach((groupKey) => {
31
- state.groups[groupKey] = {
32
- label: groupKey,
33
- len: attrs.groups[groupKey].length,
34
- items: attrs.groups[groupKey]
35
- };
36
- });
37
-
38
- const
39
- groupValues = Object.values(state.groups);
40
-
41
- groupValues
42
- .forEach((group, index) => {
43
-
44
- if (attrs.value) {
45
- state.index = 0;
46
- }
47
-
48
- group.offset = index ? groupValues[index - 1].offset + groupValues[index - 1].len : 0;
49
- state.allItems = state.allItems.concat(group.items);
50
- if (attrs.value) {
51
-
52
- group.items.forEach((item, itemIndex) => {
53
- const
54
- itemValue = item.value,
55
- parsedValue = attrs.parser ? attrs.parser(itemValue) : itemValue;
56
- if (parsedValue === attrs.value) {
57
- state.index = itemIndex + group.offset;
58
- }
59
- });
60
- }
61
- });
62
- } else if (attrs.items) {
63
- state.index = 0;
64
- for (let i = 0, l = attrs.items.length; i < l; i++) {
65
- const
66
- itemValue = attrs.items[i].value,
67
- parsedValue = attrs.parser ? attrs.parser(itemValue) : itemValue;
68
- if (parsedValue === attrs.value) {
69
- state.index = i;
70
- break;
71
- }
72
- }
73
- state.allItems = attrs.items;
74
- } else {
75
- state.allItems = [];
76
- }
77
-
78
- }
79
-
80
- const ComboWidget = {
81
-
82
- /**
83
- * Creates the Widget View
84
- * @param vnode
85
- * @param {SelectAttrs} vnode.attrs
86
- * @param {Object} vnode.state
87
- * @return {*}
88
- * @private
89
- */
90
-
91
-
92
- view: ({attrs, state}) => {
93
- const {groups} = state;
94
- return m(
95
- "select",
96
- {
97
- "aria-label": attrs.caption,
98
- class: attrs.class,
99
- oninput: (ev) => {
100
-
101
- // el desincronismo es si se camian los items y el state no se entera
102
- // esto asegura que estan synchro
103
- parseGroups(attrs, state);
104
-
105
- const
106
- index = state.index = ev.target.selectedIndex,
107
- item = index >= 0 ? state.allItems[index] : null;
108
-
109
- if (attrs.onchange && item) {
110
- attrs.onchange(item.value, item, index);
111
- }
112
-
113
- m.redraw();
114
- }
115
- },
116
- groups
117
- ? Object.values(groups)
118
- .map((group) => m("optgroup", {label: group.label}, m(PropGroup, {
119
- items: group.items,
120
- offset: group.offset,
121
- state
122
- })))
123
- : m(PropGroup, {items: (attrs.items != null ? attrs.items : []), state}));
124
- },
125
-
126
- oninit: ({attrs, state}) => {
127
- Object.assign(state, {
128
- index: attrs.index || 0,
129
- initial: attrs.value
130
- });
131
- parseGroups(attrs, state);
132
- },
133
-
134
- oncreate: () => {
135
- },
136
-
137
- onupdate: ({attrs, state}) => {
138
-
139
- const refresh = (attrs.value !== undefined && state.initial !== attrs.value);
140
-
141
- if (!state.groups && !state.allItems || refresh) {
142
-
143
- // sets index from attrs.value
144
- parseGroups(attrs, state);
145
-
146
- if (refresh) {
147
- state.initial = attrs.value;
148
- clearTimeout(__timer);
149
- __timer = setTimeout(() => m.redraw(), 50);
150
- }
151
- }
152
-
153
- }
154
- };
155
-
156
- export default ComboWidget;