@hypericon/mico 0.4.2 → 0.5.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.
- package/dist/cjs/components/menu/Menu.d.ts +2 -0
- package/dist/cjs/components/menu/menu-manager.d.ts +2 -0
- package/dist/cjs/components/menu/menu-manager.js +18 -1
- package/dist/cjs/components/table/Table.d.ts +4 -0
- package/dist/cjs/components/table/Table.js +5 -1
- package/dist/cjs/components/tooltip/tooltip-function.d.ts +1 -1
- package/dist/cjs/components/tooltip/tooltip-function.js +1 -1
- package/dist/esm/components/accordion/index.d.ts +1 -0
- package/dist/esm/components/accordion/index.js +1 -0
- package/dist/esm/components/data-grid/index.d.ts +1 -0
- package/dist/esm/components/data-grid/index.js +1 -0
- package/dist/esm/components/data-table/index.d.ts +1 -0
- package/dist/esm/components/data-table/index.js +1 -0
- package/dist/esm/components/dialog/Dialog.js +2 -1
- package/dist/esm/components/dialog/dialog-manager.js +20 -13
- package/dist/esm/components/dialog/index.js +17 -1
- package/dist/esm/components/drag-handler/DragHandler.js +9 -3
- package/dist/esm/components/drag-handler/index.js +17 -1
- package/dist/esm/components/drawer/index.d.ts +1 -0
- package/dist/esm/components/drawer/index.js +1 -0
- package/dist/esm/components/drop-target/DropTarget.js +15 -9
- package/dist/esm/components/drop-target/drop-target.state.js +14 -10
- package/dist/esm/components/drop-target/index.js +17 -1
- package/dist/esm/components/form/Form.js +4 -1
- package/dist/esm/components/form/index.js +17 -1
- package/dist/esm/components/icon/Icon.js +9 -3
- package/dist/esm/components/icon/icons.js +2 -1
- package/dist/esm/components/icon/index.js +18 -2
- package/dist/esm/components/index.js +28 -12
- package/dist/esm/components/markdown/Markdown.js +15 -9
- package/dist/esm/components/markdown/index.js +17 -1
- package/dist/esm/components/markdown-editor/MarkdownEditor.js +70 -44
- package/dist/esm/components/markdown-editor/index.js +17 -1
- package/dist/esm/components/markdown-editor/markdown-editor.state.js +11 -7
- package/dist/esm/components/menu/Menu.d.ts +2 -0
- package/dist/esm/components/menu/Menu.js +16 -10
- package/dist/esm/components/menu/MenuButton.js +31 -25
- package/dist/esm/components/menu/MenuSeparator.js +11 -5
- package/dist/esm/components/menu/index.js +22 -6
- package/dist/esm/components/menu/menu-constants.js +4 -1
- package/dist/esm/components/menu/menu-manager.d.ts +2 -0
- package/dist/esm/components/menu/menu-manager.js +35 -11
- package/dist/esm/components/menu/menu-settings.js +4 -1
- package/dist/esm/components/modal/index.d.ts +1 -0
- package/dist/esm/components/modal/index.js +1 -0
- package/dist/esm/components/pagination/Pagination.js +35 -29
- package/dist/esm/components/pagination/index.js +18 -2
- package/dist/esm/components/pagination/pagination-settings.js +4 -1
- package/dist/esm/components/panel-tree/PanelTree.js +27 -21
- package/dist/esm/components/panel-tree/index.d.ts +1 -0
- package/dist/esm/components/panel-tree/index.js +1 -0
- package/dist/esm/components/panel-tree/panel-tree-constants.js +5 -2
- package/dist/esm/components/panel-tree/panel-tree-store.js +13 -9
- package/dist/esm/components/panel-tree/panel-tree-utils.js +7 -3
- package/dist/esm/components/popover/index.d.ts +1 -0
- package/dist/esm/components/popover/index.js +1 -0
- package/dist/esm/components/reorderable-list/RedorderableList.js +17 -11
- package/dist/esm/components/reorderable-list/index.d.ts +1 -0
- package/dist/esm/components/reorderable-list/index.js +1 -0
- package/dist/esm/components/select/Select.js +18 -12
- package/dist/esm/components/select/SelectOptionsPanel.js +19 -13
- package/dist/esm/components/select/constants.js +5 -2
- package/dist/esm/components/select/index.js +18 -2
- package/dist/esm/components/select/select-options-manager.js +7 -3
- package/dist/esm/components/tab-panel/TabPanel.js +19 -13
- package/dist/esm/components/tab-panel/index.js +19 -3
- package/dist/esm/components/tab-panel/tab-panel-default-settings.js +4 -1
- package/dist/esm/components/tab-panel/tab-panel-settings.js +2 -1
- package/dist/esm/components/table/Table.d.ts +4 -0
- package/dist/esm/components/table/Table.js +24 -13
- package/dist/esm/components/table/index.js +17 -1
- package/dist/esm/components/toast/index.js +17 -1
- package/dist/esm/components/toast/toast.js +39 -9
- package/dist/esm/components/tooltip/index.js +19 -3
- package/dist/esm/components/tooltip/tooltip-defaults.js +4 -1
- package/dist/esm/components/tooltip/tooltip-function.d.ts +1 -1
- package/dist/esm/components/tooltip/tooltip-function.js +26 -21
- package/dist/esm/components/tooltip/tooltip-interfaces.js +2 -1
- package/dist/esm/components/tree/Tree.js +29 -22
- package/dist/esm/components/tree/index.js +19 -3
- package/dist/esm/components/tree/tree-node.interface.js +2 -1
- package/dist/esm/components/tree/tree-utils.js +5 -1
- package/dist/esm/index.js +18 -2
- package/dist/esm/utils/date-time.js +7 -2
- package/dist/esm/utils/dom.js +7 -2
- package/dist/esm/utils/events.js +5 -1
- package/dist/esm/utils/index.js +19 -3
- package/package.json +1 -1
|
@@ -1,66 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Pagination = void 0;
|
|
7
|
+
const mithril_1 = __importDefault(require("mithril"));
|
|
8
|
+
const pagination_settings_1 = require("./pagination-settings");
|
|
9
|
+
const icon_1 = require("../icon");
|
|
10
|
+
exports.Pagination = {
|
|
5
11
|
view({ attrs }) {
|
|
6
12
|
var _a, _b;
|
|
7
|
-
const layout = (attrs.layout ||
|
|
8
|
-
return
|
|
13
|
+
const layout = (attrs.layout || pagination_settings_1.PAGINATION_DEFAULT_SETTINGS.layout);
|
|
14
|
+
return (0, mithril_1.default)(".mico-pagination", {
|
|
9
15
|
class: `${(_a = attrs.class) !== null && _a !== void 0 ? _a : ""}`,
|
|
10
16
|
style: `${(_b = attrs.style) !== null && _b !== void 0 ? _b : ""} display: flex; align-items: center;`,
|
|
11
17
|
}, [
|
|
12
|
-
(layout === "middle" || layout === "right") ?
|
|
18
|
+
(layout === "middle" || layout === "right") ? (0, mithril_1.default)("", { style: "flex: 1;" }) : [],
|
|
13
19
|
(attrs.size) ? [
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
(0, mithril_1.default)("span", `Page size:`),
|
|
21
|
+
(0, mithril_1.default)("select.mico-pagination-select", {
|
|
16
22
|
value: attrs.size.size,
|
|
17
23
|
oninput: (e) => attrs.size.onselect(Number(e.target.value)),
|
|
18
|
-
}, (attrs.size.sizes ||
|
|
24
|
+
}, (attrs.size.sizes || pagination_settings_1.PAGINATION_DEFAULT_SETTINGS.pageSizes).map(s => (0, mithril_1.default)("option", s))),
|
|
19
25
|
] : [],
|
|
20
26
|
(attrs.xToYOfZ !== undefined) ? [
|
|
21
27
|
(attrs.xToYOfZ === false) ? [] :
|
|
22
|
-
(typeof attrs.xToYOfZ === "string") ?
|
|
28
|
+
(typeof attrs.xToYOfZ === "string") ? (0, mithril_1.default)("span.mico-pagination-xtoyofz", attrs.xToYOfZ) :
|
|
23
29
|
attrs.xToYOfZ,
|
|
24
30
|
] : [
|
|
25
|
-
|
|
31
|
+
(0, mithril_1.default)("span.mico-pagination-xtoyofz", `${attrs.from}-${attrs.to} of ${attrs.of}`),
|
|
26
32
|
],
|
|
27
|
-
(attrs.first !== undefined) ?
|
|
33
|
+
(attrs.first !== undefined) ? (0, mithril_1.default)("button.mico-pagination-button", {
|
|
28
34
|
disabled: attrs.isAtStart,
|
|
29
35
|
title: "First page",
|
|
30
36
|
onclick: (ev) => { var _a; return (_a = attrs.first) === null || _a === void 0 ? void 0 : _a.call(attrs, ev); },
|
|
31
37
|
}, [
|
|
32
|
-
|
|
33
|
-
?
|
|
34
|
-
:
|
|
38
|
+
pagination_settings_1.PAGINATION_DEFAULT_SETTINGS.iconComponents.first
|
|
39
|
+
? (0, mithril_1.default)(pagination_settings_1.PAGINATION_DEFAULT_SETTINGS.iconComponents.first)
|
|
40
|
+
: (0, mithril_1.default)(icon_1.Icon, { fas: "angles-left" }),
|
|
35
41
|
]) : [],
|
|
36
|
-
(attrs.prev !== undefined) ?
|
|
42
|
+
(attrs.prev !== undefined) ? (0, mithril_1.default)("button.mico-pagination-button", {
|
|
37
43
|
disabled: attrs.isAtStart,
|
|
38
44
|
title: "Previous page",
|
|
39
45
|
onclick: (ev) => { var _a; return (_a = attrs.prev) === null || _a === void 0 ? void 0 : _a.call(attrs, ev); },
|
|
40
46
|
}, [
|
|
41
|
-
|
|
42
|
-
?
|
|
43
|
-
:
|
|
47
|
+
pagination_settings_1.PAGINATION_DEFAULT_SETTINGS.iconComponents.prev
|
|
48
|
+
? (0, mithril_1.default)(pagination_settings_1.PAGINATION_DEFAULT_SETTINGS.iconComponents.prev)
|
|
49
|
+
: (0, mithril_1.default)(icon_1.Icon, { fas: "angle-left" }),
|
|
44
50
|
]) : [],
|
|
45
|
-
(attrs.next !== undefined) ?
|
|
51
|
+
(attrs.next !== undefined) ? (0, mithril_1.default)("button.mico-pagination-button", {
|
|
46
52
|
disabled: attrs.isAtEnd,
|
|
47
53
|
title: "Next page",
|
|
48
54
|
onclick: (ev) => { var _a; return (_a = attrs.next) === null || _a === void 0 ? void 0 : _a.call(attrs, ev); },
|
|
49
55
|
}, [
|
|
50
|
-
|
|
51
|
-
?
|
|
52
|
-
:
|
|
56
|
+
pagination_settings_1.PAGINATION_DEFAULT_SETTINGS.iconComponents.next
|
|
57
|
+
? (0, mithril_1.default)(pagination_settings_1.PAGINATION_DEFAULT_SETTINGS.iconComponents.next)
|
|
58
|
+
: (0, mithril_1.default)(icon_1.Icon, { fas: "angle-right" }),
|
|
53
59
|
]) : [],
|
|
54
|
-
(attrs.last !== undefined) ?
|
|
60
|
+
(attrs.last !== undefined) ? (0, mithril_1.default)("button.mico-pagination-button", {
|
|
55
61
|
disabled: attrs.isAtEnd,
|
|
56
62
|
title: "Last page",
|
|
57
63
|
onclick: (ev) => { var _a; return (_a = attrs.last) === null || _a === void 0 ? void 0 : _a.call(attrs, ev); },
|
|
58
64
|
}, [
|
|
59
|
-
|
|
60
|
-
?
|
|
61
|
-
:
|
|
65
|
+
pagination_settings_1.PAGINATION_DEFAULT_SETTINGS.iconComponents.last
|
|
66
|
+
? (0, mithril_1.default)(pagination_settings_1.PAGINATION_DEFAULT_SETTINGS.iconComponents.last)
|
|
67
|
+
: (0, mithril_1.default)(icon_1.Icon, { fas: "angles-right" }),
|
|
62
68
|
]) : [],
|
|
63
|
-
(layout === "middle" || layout === "left") ?
|
|
69
|
+
(layout === "middle" || layout === "left") ? (0, mithril_1.default)("", { style: "flex: 1;" }) : [],
|
|
64
70
|
]);
|
|
65
71
|
},
|
|
66
72
|
};
|
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Pagination"), exports);
|
|
18
|
+
__exportStar(require("./pagination-settings"), exports);
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PAGINATION_DEFAULT_SETTINGS = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Default common settings for pagination components
|
|
3
6
|
*/
|
|
4
|
-
|
|
7
|
+
exports.PAGINATION_DEFAULT_SETTINGS = {
|
|
5
8
|
/** "left" | "middle" | "right" */
|
|
6
9
|
layout: "right",
|
|
7
10
|
pageSize: 25,
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PanelTreeHandle = exports.PanelTreePanel = void 0;
|
|
7
|
+
const mithril_1 = __importDefault(require("mithril"));
|
|
8
|
+
const panel_tree_constants_1 = require("./panel-tree-constants");
|
|
9
|
+
const panel_tree_store_1 = require("./panel-tree-store");
|
|
10
|
+
const panel_tree_utils_1 = require("./panel-tree-utils");
|
|
5
11
|
/** Data about the state of the ongoing drag operation */
|
|
6
|
-
const PTStore = new PanelTreeStore();
|
|
7
|
-
|
|
12
|
+
const PTStore = new panel_tree_store_1.PanelTreeStore();
|
|
13
|
+
exports.PanelTreePanel = {
|
|
8
14
|
oninit() {
|
|
9
15
|
// this.isDragOver = false;
|
|
10
16
|
},
|
|
@@ -45,7 +51,7 @@ export const PanelTreePanel = {
|
|
|
45
51
|
ev.stopImmediatePropagation();
|
|
46
52
|
ev.preventDefault();
|
|
47
53
|
// PANEL_TREE_DEBUG ?? console.debug("is dragging over panel with parent " + parentType);
|
|
48
|
-
const { dragEv, touchEv } =
|
|
54
|
+
const { dragEv, touchEv } = panel_tree_utils_1.PanelTreeUtils.dragOrTouch(ev);
|
|
49
55
|
PTStore.overEl = this.el;
|
|
50
56
|
const isRecursive = (_a = PTStore.draggedPanel) === null || _a === void 0 ? void 0 : _a.contains(this.el);
|
|
51
57
|
const isValidTarget = parentType !== undefined && PTStore.draggedData !== data && !isRecursive;
|
|
@@ -59,19 +65,19 @@ export const PanelTreePanel = {
|
|
|
59
65
|
const overDiv = ev.currentTarget;
|
|
60
66
|
const targetRect = overDiv.getBoundingClientRect();
|
|
61
67
|
if (parentType === "row") {
|
|
62
|
-
const leftToMouse =
|
|
68
|
+
const leftToMouse = panel_tree_utils_1.PanelTreeUtils.eventXPos(ev) - targetRect.left;
|
|
63
69
|
const isLeft = leftToMouse < (targetRect.width - leftToMouse);
|
|
64
70
|
this.isOverStart = isLeft;
|
|
65
71
|
}
|
|
66
72
|
else {
|
|
67
|
-
const topToMouse =
|
|
73
|
+
const topToMouse = panel_tree_utils_1.PanelTreeUtils.eventYPos(ev) - targetRect.top;
|
|
68
74
|
const isAbove = topToMouse < (targetRect.height - topToMouse);
|
|
69
75
|
this.isOverStart = isAbove;
|
|
70
76
|
}
|
|
71
|
-
PANEL_TREE_DEBUG !== null && PANEL_TREE_DEBUG !== void 0 ? PANEL_TREE_DEBUG : console.debug(`dragging over valid target, ${this.isOverStart ? "over start" : "over end"}`);
|
|
77
|
+
panel_tree_constants_1.PANEL_TREE_DEBUG !== null && panel_tree_constants_1.PANEL_TREE_DEBUG !== void 0 ? panel_tree_constants_1.PANEL_TREE_DEBUG : console.debug(`dragging over valid target, ${this.isOverStart ? "over start" : "over end"}`);
|
|
72
78
|
}
|
|
73
79
|
else {
|
|
74
|
-
PANEL_TREE_DEBUG !== null && PANEL_TREE_DEBUG !== void 0 ? PANEL_TREE_DEBUG : console.debug(`dragging over invalid target`);
|
|
80
|
+
panel_tree_constants_1.PANEL_TREE_DEBUG !== null && panel_tree_constants_1.PANEL_TREE_DEBUG !== void 0 ? panel_tree_constants_1.PANEL_TREE_DEBUG : console.debug(`dragging over invalid target`);
|
|
75
81
|
}
|
|
76
82
|
};
|
|
77
83
|
const onDrop = (ev) => {
|
|
@@ -84,12 +90,12 @@ export const PanelTreePanel = {
|
|
|
84
90
|
PTStore.dropTargetPanel = this.el;
|
|
85
91
|
const isRecursive = (_a = PTStore.draggedPanel) === null || _a === void 0 ? void 0 : _a.contains(this.el);
|
|
86
92
|
const movedData = PTStore.draggedData;
|
|
87
|
-
PANEL_TREE_DEBUG !== null && PANEL_TREE_DEBUG !== void 0 ? PANEL_TREE_DEBUG : console.debug(`drag dropped, dataTransfer data: ${JSON.stringify(movedData)}`);
|
|
93
|
+
panel_tree_constants_1.PANEL_TREE_DEBUG !== null && panel_tree_constants_1.PANEL_TREE_DEBUG !== void 0 ? panel_tree_constants_1.PANEL_TREE_DEBUG : console.debug(`drag dropped, dataTransfer data: ${JSON.stringify(movedData)}`);
|
|
88
94
|
if (movedData && movedData !== data && !isRecursive) {
|
|
89
95
|
setTimeout(() => {
|
|
90
|
-
PANEL_TREE_DEBUG !== null && PANEL_TREE_DEBUG !== void 0 ? PANEL_TREE_DEBUG : console.debug(`Instruct tree to insert subtree: ${JSON.stringify(movedData)}`);
|
|
96
|
+
panel_tree_constants_1.PANEL_TREE_DEBUG !== null && panel_tree_constants_1.PANEL_TREE_DEBUG !== void 0 ? panel_tree_constants_1.PANEL_TREE_DEBUG : console.debug(`Instruct tree to insert subtree: ${JSON.stringify(movedData)}`);
|
|
91
97
|
attrs.insert(movedData, this.isOverStart);
|
|
92
|
-
|
|
98
|
+
mithril_1.default.redraw();
|
|
93
99
|
}, 1);
|
|
94
100
|
}
|
|
95
101
|
PTStore.isDragging = false;
|
|
@@ -97,11 +103,11 @@ export const PanelTreePanel = {
|
|
|
97
103
|
const onEnd = (ev) => {
|
|
98
104
|
// ev.stopImmediatePropagation();
|
|
99
105
|
// this.isDragOver = false;
|
|
100
|
-
PANEL_TREE_DEBUG !== null && PANEL_TREE_DEBUG !== void 0 ? PANEL_TREE_DEBUG : console.debug("drag ended");
|
|
106
|
+
panel_tree_constants_1.PANEL_TREE_DEBUG !== null && panel_tree_constants_1.PANEL_TREE_DEBUG !== void 0 ? panel_tree_constants_1.PANEL_TREE_DEBUG : console.debug("drag ended");
|
|
101
107
|
// No op?
|
|
102
108
|
PTStore.isDragging = false;
|
|
103
109
|
};
|
|
104
|
-
return
|
|
110
|
+
return (0, mithril_1.default)(`.${panel_tree_constants_1.PANEL_TREE_PANEL_CLASS}.flex-1.rounded.shadow-md`, {
|
|
105
111
|
// TODO
|
|
106
112
|
// class: `${attrs.class ?? ""} ${mobileMode.isMob ? "p-1" : "p-2"} ${dragBorder}`,
|
|
107
113
|
class: `${(_b = attrs.class) !== null && _b !== void 0 ? _b : ""} p-1 ${dragBorder}`,
|
|
@@ -135,14 +141,14 @@ export const PanelTreePanel = {
|
|
|
135
141
|
}, children);
|
|
136
142
|
},
|
|
137
143
|
};
|
|
138
|
-
|
|
144
|
+
exports.PanelTreeHandle = {
|
|
139
145
|
oninit() { },
|
|
140
146
|
oncreate({ dom }) {
|
|
141
147
|
this.el = dom;
|
|
142
148
|
},
|
|
143
149
|
view({ attrs }) {
|
|
144
150
|
const { data } = attrs;
|
|
145
|
-
return
|
|
151
|
+
return (0, mithril_1.default)(".px-2.py-1.flex.items-center.cursor-move", {
|
|
146
152
|
// TODO
|
|
147
153
|
// ...tooltipSpread("Reposition this element", { delay: 1_000 }),
|
|
148
154
|
draggable: true,
|
|
@@ -155,12 +161,12 @@ export const PanelTreeHandle = {
|
|
|
155
161
|
// Disable scrolling if there is an ongoing drag
|
|
156
162
|
ev.stopImmediatePropagation();
|
|
157
163
|
ev.preventDefault();
|
|
158
|
-
|
|
164
|
+
panel_tree_utils_1.PanelTreeUtils.dispatchTouchEventToHoveredPanel(ev);
|
|
159
165
|
}
|
|
160
166
|
},
|
|
161
167
|
ontouchend: (ev) => {
|
|
162
168
|
// Re-dispatch the event first to set the drop target data
|
|
163
|
-
|
|
169
|
+
panel_tree_utils_1.PanelTreeUtils.dispatchTouchEventToLastHoveredPanel(ev);
|
|
164
170
|
// Next, handle the end of the drag and possibly call the function to remove the panel
|
|
165
171
|
PTStore.onEndDraggingHandle(ev, data, () => { var _a; return (_a = attrs.remove) === null || _a === void 0 ? void 0 : _a.call(attrs); });
|
|
166
172
|
},
|
|
@@ -168,7 +174,7 @@ export const PanelTreeHandle = {
|
|
|
168
174
|
PTStore.isDragging = false;
|
|
169
175
|
},
|
|
170
176
|
}, [
|
|
171
|
-
|
|
177
|
+
(0, mithril_1.default)("i.fas.fa-grip-vertical.text-icon"),
|
|
172
178
|
]);
|
|
173
179
|
},
|
|
174
180
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PANEL_TREE_DEBUG = exports.PANEL_TREE_PANEL_CLASS = void 0;
|
|
1
4
|
/** The CSS class applied all panel tree panels */
|
|
2
|
-
|
|
3
|
-
|
|
5
|
+
exports.PANEL_TREE_PANEL_CLASS = "panel-tree-panel";
|
|
6
|
+
exports.PANEL_TREE_DEBUG = false;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PanelTreeStore = void 0;
|
|
4
|
+
const panel_tree_constants_1 = require("./panel-tree-constants");
|
|
5
|
+
const panel_tree_utils_1 = require("./panel-tree-utils");
|
|
6
|
+
class PanelTreeStore {
|
|
4
7
|
/** Whether the current drop operation is recursive */
|
|
5
8
|
get isRecursive() {
|
|
6
9
|
return (this.draggedPanel !== undefined) &&
|
|
@@ -28,14 +31,14 @@ export class PanelTreeStore {
|
|
|
28
31
|
var _a;
|
|
29
32
|
ev.stopImmediatePropagation();
|
|
30
33
|
// ev.preventDefault();
|
|
31
|
-
const { dragEv, touchEv } =
|
|
32
|
-
const parentPanel =
|
|
34
|
+
const { dragEv, touchEv } = panel_tree_utils_1.PanelTreeUtils.dragOrTouch(ev);
|
|
35
|
+
const parentPanel = panel_tree_utils_1.PanelTreeUtils.findParentPanel(ev.currentTarget);
|
|
33
36
|
// logger.debug(``)
|
|
34
37
|
if (parentPanel) {
|
|
35
38
|
this.isDragging = true;
|
|
36
39
|
this.draggedData = data;
|
|
37
40
|
this.draggedPanel = parentPanel;
|
|
38
|
-
PANEL_TREE_DEBUG !== null && PANEL_TREE_DEBUG !== void 0 ? PANEL_TREE_DEBUG : console.debug(`Begin dragging, handle data: ${JSON.stringify(data)}`);
|
|
41
|
+
panel_tree_constants_1.PANEL_TREE_DEBUG !== null && panel_tree_constants_1.PANEL_TREE_DEBUG !== void 0 ? panel_tree_constants_1.PANEL_TREE_DEBUG : console.debug(`Begin dragging, handle data: ${JSON.stringify(data)}`);
|
|
39
42
|
const parentRect = parentPanel.getBoundingClientRect();
|
|
40
43
|
if (dragEv) {
|
|
41
44
|
(_a = dragEv.dataTransfer) === null || _a === void 0 ? void 0 : _a.setDragImage(parentPanel, dragEv.clientX - parentRect.left, dragEv.clientY - parentRect.top);
|
|
@@ -45,15 +48,16 @@ export class PanelTreeStore {
|
|
|
45
48
|
/** The user has stopped dragging a handle of a panel */
|
|
46
49
|
onEndDraggingHandle(ev, data, remove) {
|
|
47
50
|
ev.stopImmediatePropagation();
|
|
48
|
-
const { dragEv, touchEv } =
|
|
51
|
+
const { dragEv, touchEv } = panel_tree_utils_1.PanelTreeUtils.dragOrTouch(ev);
|
|
49
52
|
const isRecursive = this.isRecursive; // STORE.dropTargetPanel && STORE.draggedPanel?.contains(STORE.dropTargetPanel);
|
|
50
|
-
PANEL_TREE_DEBUG !== null && PANEL_TREE_DEBUG !== void 0 ? PANEL_TREE_DEBUG : console.debug(`End dragging, dropEffect: ${this.dropEffect}, handle data: ${JSON.stringify(data)}`);
|
|
53
|
+
panel_tree_constants_1.PANEL_TREE_DEBUG !== null && panel_tree_constants_1.PANEL_TREE_DEBUG !== void 0 ? panel_tree_constants_1.PANEL_TREE_DEBUG : console.debug(`End dragging, dropEffect: ${this.dropEffect}, handle data: ${JSON.stringify(data)}`);
|
|
51
54
|
if (this.dropEffect === "move") {
|
|
52
55
|
if (this.dropTargetData !== data && !isRecursive) {
|
|
53
|
-
PANEL_TREE_DEBUG !== null && PANEL_TREE_DEBUG !== void 0 ? PANEL_TREE_DEBUG : console.debug(`Instruct tree to remove subtree: ${JSON.stringify(data)}`);
|
|
56
|
+
panel_tree_constants_1.PANEL_TREE_DEBUG !== null && panel_tree_constants_1.PANEL_TREE_DEBUG !== void 0 ? panel_tree_constants_1.PANEL_TREE_DEBUG : console.debug(`Instruct tree to remove subtree: ${JSON.stringify(data)}`);
|
|
54
57
|
remove === null || remove === void 0 ? void 0 : remove();
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
this.isDragging = false;
|
|
58
61
|
}
|
|
59
62
|
}
|
|
63
|
+
exports.PanelTreeStore = PanelTreeStore;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PanelTreeUtils = void 0;
|
|
4
|
+
const panel_tree_constants_1 = require("./panel-tree-constants");
|
|
2
5
|
/**
|
|
3
6
|
* Stateless utility functions used by the PanelTree component
|
|
4
7
|
*/
|
|
5
|
-
|
|
8
|
+
class PanelTreeUtils {
|
|
6
9
|
/** Find the first parent element of the given element that contains the CSS class for panel tree panels */
|
|
7
10
|
static findParentPanel(handleEl) {
|
|
8
11
|
const parent = handleEl.parentElement;
|
|
9
12
|
if (!parent)
|
|
10
13
|
return;
|
|
11
|
-
if (parent.classList.contains(PANEL_TREE_PANEL_CLASS))
|
|
14
|
+
if (parent.classList.contains(panel_tree_constants_1.PANEL_TREE_PANEL_CLASS))
|
|
12
15
|
return parent;
|
|
13
16
|
return this.findParentPanel(parent);
|
|
14
17
|
}
|
|
@@ -53,3 +56,4 @@ export class PanelTreeUtils {
|
|
|
53
56
|
}
|
|
54
57
|
}
|
|
55
58
|
}
|
|
59
|
+
exports.PanelTreeUtils = PanelTreeUtils;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ReorderableList = void 0;
|
|
7
|
+
const mithril_1 = __importDefault(require("mithril"));
|
|
8
|
+
const utils_1 = require("../../utils");
|
|
3
9
|
/**
|
|
4
10
|
* A reorderable list of items. Expects a list of reorderable list items in children.
|
|
5
11
|
*
|
|
@@ -28,7 +34,7 @@ import { coordsWithinElement } from "../../utils";
|
|
|
28
34
|
* this.items.splice(toIndex, 0, dragged);
|
|
29
35
|
* ```
|
|
30
36
|
*/
|
|
31
|
-
|
|
37
|
+
exports.ReorderableList = {
|
|
32
38
|
oninit({ attrs }) {
|
|
33
39
|
this.draggingIndex = undefined;
|
|
34
40
|
this.draggedOverIndex = undefined;
|
|
@@ -92,7 +98,7 @@ export const ReorderableList = {
|
|
|
92
98
|
this.draggedOverIndex = undefined;
|
|
93
99
|
this.draggedOverTop = undefined;
|
|
94
100
|
};
|
|
95
|
-
return
|
|
101
|
+
return (0, mithril_1.default)("", {
|
|
96
102
|
id: attrs.id,
|
|
97
103
|
class: `${attrs.class || ""} no-select`,
|
|
98
104
|
style: `${attrs.style || ""}`,
|
|
@@ -113,7 +119,7 @@ export const ReorderableList = {
|
|
|
113
119
|
for (let i = 0; i < rowContainerEl.children.length; i++) {
|
|
114
120
|
const childEl = rowContainerEl.children[i];
|
|
115
121
|
const childElBounds = childEl.getBoundingClientRect();
|
|
116
|
-
if (coordsWithinElement(touchX, touchY, childEl)) {
|
|
122
|
+
if ((0, utils_1.coordsWithinElement)(touchX, touchY, childEl)) {
|
|
117
123
|
overIndex = i;
|
|
118
124
|
const boundsTopToTouch = touchY - childElBounds.top;
|
|
119
125
|
isAbove = boundsTopToTouch < (childElBounds.height - boundsTopToTouch);
|
|
@@ -131,9 +137,9 @@ export const ReorderableList = {
|
|
|
131
137
|
endDrag(ev);
|
|
132
138
|
},
|
|
133
139
|
}, [
|
|
134
|
-
(childArr.length === 0) ? attrs.emptyMessage ||
|
|
140
|
+
(childArr.length === 0) ? attrs.emptyMessage || (0, mithril_1.default)("p", "No items to display") : [],
|
|
135
141
|
childArr.map((item, childIndex) => {
|
|
136
|
-
return
|
|
142
|
+
return (0, mithril_1.default)(ReorderableListItem, {
|
|
137
143
|
itemIndex: childIndex,
|
|
138
144
|
draggedOverIndex: this.draggedOverIndex,
|
|
139
145
|
draggedOverTop: this.draggedOverTop,
|
|
@@ -175,25 +181,25 @@ const ReorderableListItem = {
|
|
|
175
181
|
: attrs.draggedOverTop
|
|
176
182
|
? "border-t-2 border-primary"
|
|
177
183
|
: "border-b-2 border-primary";
|
|
178
|
-
return
|
|
184
|
+
return (0, mithril_1.default)(".flex.flex-row.items-stretch.space-x-2", {
|
|
179
185
|
key: attrs.key,
|
|
180
186
|
class: `${(_a = attrs.class) !== null && _a !== void 0 ? _a : ""} ${dragBorderClass}`,
|
|
181
187
|
style: ``,
|
|
182
188
|
onmousemove: (ev) => attrs.mouseOverFn(ev),
|
|
183
189
|
}, [
|
|
184
190
|
// Draggable index row header
|
|
185
|
-
|
|
191
|
+
(0, mithril_1.default)(".flex.items-center.space-x-2", {
|
|
186
192
|
style: `width: ${hideNumbers ? "30px" : "50px"};`,
|
|
187
193
|
class: `${disableReordering ? "text-hint" : "cursor-move"}`,
|
|
188
194
|
onmousedown: (ev) => attrs.mouseDownFn(ev),
|
|
189
195
|
ontouchstart: (ev) => attrs.touchStartFn(ev),
|
|
190
196
|
}, [
|
|
191
|
-
|
|
197
|
+
(0, mithril_1.default)(`i.fas.fa-grip-vertical`, {
|
|
192
198
|
class: `${disableReordering ? "text-hint" : "text-grey-700 dark:text-grey-300"} ${hideNumbers ? "pl-2" : ""}`,
|
|
193
199
|
}),
|
|
194
200
|
hideNumbers
|
|
195
201
|
? []
|
|
196
|
-
:
|
|
202
|
+
: (0, mithril_1.default)("", attrs.itemIndex + 1),
|
|
197
203
|
]),
|
|
198
204
|
// The content in the reorderable item
|
|
199
205
|
children,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Select = void 0;
|
|
7
|
+
const mithril_1 = __importDefault(require("mithril"));
|
|
8
|
+
const select_options_manager_1 = require("./select-options-manager");
|
|
9
|
+
const optsPanelMgr = new select_options_manager_1.SelectOptionsManager();
|
|
4
10
|
/**
|
|
5
11
|
* A dropdown select box that takes Mithril Vnodes as options
|
|
6
12
|
*/
|
|
7
|
-
|
|
13
|
+
exports.Select = {
|
|
8
14
|
oninit({ attrs }) {
|
|
9
15
|
this.id = attrs.id || `select-${Math.random().toString().replace(".", "")}`;
|
|
10
16
|
this.lastViewportRect = new DOMRect();
|
|
@@ -55,7 +61,7 @@ export const Select = {
|
|
|
55
61
|
// attrs.onclose?.();
|
|
56
62
|
};
|
|
57
63
|
// The main "select box" div
|
|
58
|
-
return
|
|
64
|
+
return (0, mithril_1.default)(".input.no-select", {
|
|
59
65
|
id: this.id,
|
|
60
66
|
tabindex: 0,
|
|
61
67
|
style: `height: 2rem; ${attrs.style || ""} padding-top: 0; padding-bottom: 0; position: relative;`,
|
|
@@ -81,26 +87,26 @@ export const Select = {
|
|
|
81
87
|
}
|
|
82
88
|
}, [
|
|
83
89
|
// The selected option within the select box div
|
|
84
|
-
|
|
85
|
-
|
|
90
|
+
(0, mithril_1.default)(".flex-1.overflow-x-hidden", {}, [
|
|
91
|
+
(0, mithril_1.default)(".overflow-x-hidden", {
|
|
86
92
|
key: attrs.value,
|
|
87
93
|
}, [
|
|
88
94
|
(_a = attrs.options.find(o => o.attrs.value === attrs.value)) !== null && _a !== void 0 ? _a : ((attrs.placeholder && typeof attrs.placeholder === "string")
|
|
89
|
-
?
|
|
95
|
+
? (0, mithril_1.default)("span.hint", attrs.placeholder)
|
|
90
96
|
: attrs.placeholder),
|
|
91
97
|
]),
|
|
92
98
|
]),
|
|
93
99
|
// Open/close down/up arrow in the input box
|
|
94
|
-
|
|
100
|
+
(0, mithril_1.default)(".ml-1", {
|
|
95
101
|
class: this.disabled ? "text-gray-500" : "",
|
|
96
102
|
}, [
|
|
97
103
|
// optsPanelSvc.isOpen(this.id)
|
|
98
104
|
// ? m(".h-full.flex.items-center", { key: "up" }, m("i.fas.fa-caret-up"))
|
|
99
105
|
// : m(".h-full.flex.items-center", { key: "down" }, m("i.fas.fa-caret-down")),
|
|
100
|
-
|
|
106
|
+
(0, mithril_1.default)(".h-full.flex.items-center", [
|
|
101
107
|
optsPanelMgr.isOpen(this.id)
|
|
102
|
-
?
|
|
103
|
-
:
|
|
108
|
+
? (0, mithril_1.default)(`i.fas.fa-caret-up`)
|
|
109
|
+
: (0, mithril_1.default)(`i.fas.fa-caret-down`),
|
|
104
110
|
]),
|
|
105
111
|
]),
|
|
106
112
|
]);
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SelectOptionsPanel = void 0;
|
|
7
|
+
const mithril_1 = __importDefault(require("mithril"));
|
|
8
|
+
const rxjs_1 = require("rxjs");
|
|
9
|
+
const constants_1 = require("./constants");
|
|
10
|
+
const select_options_manager_1 = require("./select-options-manager");
|
|
5
11
|
// const logger = getLogger("SelectOptionsPanel");
|
|
6
12
|
const DEBUG = false;
|
|
7
|
-
const optsPanelMgr = new SelectOptionsManager();
|
|
13
|
+
const optsPanelMgr = new select_options_manager_1.SelectOptionsManager();
|
|
8
14
|
const MIN_OPTIONS_PANEL_WIDTH = 200;
|
|
9
15
|
const OPTIONS_PANEL_ID = "select-options-panel";
|
|
10
16
|
const TEXT_IDLE_TIMEOUT = 1000;
|
|
11
|
-
|
|
17
|
+
exports.SelectOptionsPanel = {
|
|
12
18
|
oninit() {
|
|
13
|
-
this.subs = new Subscription();
|
|
19
|
+
this.subs = new rxjs_1.Subscription();
|
|
14
20
|
this.isOpen = false;
|
|
15
21
|
this.isReversed = false;
|
|
16
22
|
this.isAnchoredRight = false;
|
|
@@ -43,7 +49,7 @@ export const SelectOptionsPanel = {
|
|
|
43
49
|
this.subs.add(optsPanelMgr.panel$.subscribe(panelDef => {
|
|
44
50
|
if (panelDef) {
|
|
45
51
|
// If the available space is less than the approximate size of the options panel, open upwards instead
|
|
46
|
-
this.isReversed = (window.innerHeight - panelDef.selectRect.bottom) < Math.min((panelDef.options.length * OPTION_APPROX_HEIGHT), MAX_OPTION_PANEL_HEIGHT);
|
|
52
|
+
this.isReversed = (window.innerHeight - panelDef.selectRect.bottom) < Math.min((panelDef.options.length * constants_1.OPTION_APPROX_HEIGHT), constants_1.MAX_OPTION_PANEL_HEIGHT);
|
|
47
53
|
// TODO: calculate is anchored right
|
|
48
54
|
if (!this.isOpen) {
|
|
49
55
|
DEBUG && console.log("opening select options panel");
|
|
@@ -58,7 +64,7 @@ export const SelectOptionsPanel = {
|
|
|
58
64
|
else {
|
|
59
65
|
this.isOpen = false;
|
|
60
66
|
}
|
|
61
|
-
|
|
67
|
+
mithril_1.default.redraw();
|
|
62
68
|
}));
|
|
63
69
|
this.textSearch = "";
|
|
64
70
|
this.handleTextSearch = (ev) => {
|
|
@@ -105,11 +111,11 @@ export const SelectOptionsPanel = {
|
|
|
105
111
|
const rect = panel.selectRect;
|
|
106
112
|
const width = Math.max(rect.width, MIN_OPTIONS_PANEL_WIDTH);
|
|
107
113
|
DEBUG && console.log("Drawing select options panel for select rect:", rect);
|
|
108
|
-
return
|
|
114
|
+
return (0, mithril_1.default)(".bg-white.text-dark.dark:bg-black.dark:text-white.shadow-lg.border.border-grey-500", {
|
|
109
115
|
id: OPTIONS_PANEL_ID,
|
|
110
116
|
tabindex: -1,
|
|
111
117
|
style: `position: fixed; left: ${rect.left}px; width: ${width}px; ${this.isReversed ? `bottom: ${document.documentElement.clientHeight - rect.top}px;` : `top: ${rect.bottom}px;`}
|
|
112
|
-
min-width: ${MIN_OPTIONS_PANEL_WIDTH}px; max-height: ${MAX_OPTION_PANEL_HEIGHT}px; overflow-y: auto; z-index: 100; outline: none;`,
|
|
118
|
+
min-width: ${MIN_OPTIONS_PANEL_WIDTH}px; max-height: ${constants_1.MAX_OPTION_PANEL_HEIGHT}px; overflow-y: auto; z-index: 100; outline: none;`,
|
|
113
119
|
onkeydown: (ev) => {
|
|
114
120
|
if (ev.code === "ArrowUp") {
|
|
115
121
|
this.highlightedIndex = Math.max(this.highlightedIndex - 1, 0);
|
|
@@ -139,7 +145,7 @@ export const SelectOptionsPanel = {
|
|
|
139
145
|
},
|
|
140
146
|
}, [
|
|
141
147
|
// The container of the option buttons, may be larger than the displayed panel
|
|
142
|
-
|
|
148
|
+
(0, mithril_1.default)("", {
|
|
143
149
|
style: ``,
|
|
144
150
|
class: `flex flex-col items-stretch`,
|
|
145
151
|
}, [
|
|
@@ -147,7 +153,7 @@ export const SelectOptionsPanel = {
|
|
|
147
153
|
const value = optionVnode.attrs.value;
|
|
148
154
|
const disabled = optionVnode.attrs.disabled === true;
|
|
149
155
|
// An option value button
|
|
150
|
-
return
|
|
156
|
+
return (0, mithril_1.default)(`button`, {
|
|
151
157
|
key: value,
|
|
152
158
|
disabled,
|
|
153
159
|
class: `px-2 py-1 flex items-start ${this.highlightedIndex === optionIndex ? "bg-gray-200 dark:bg-black-light" : ""}`,
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OPTION_APPROX_HEIGHT = exports.MAX_OPTION_PANEL_HEIGHT = void 0;
|
|
4
|
+
exports.MAX_OPTION_PANEL_HEIGHT = 320;
|
|
5
|
+
exports.OPTION_APPROX_HEIGHT = 30;
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Select"), exports);
|
|
18
|
+
__exportStar(require("./SelectOptionsPanel"), exports);
|
|
3
19
|
// export * from "./select-options-panel-manager";
|