kritzel-stencil 0.0.128 → 0.0.130
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/index-CUSIflVf.js +2 -2
- package/dist/cjs/{index-C7Read21.js → index-CfXjPLHb.js} +46 -28
- package/dist/cjs/index-CfXjPLHb.js.map +1 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/{kritzel-brush-style_22.cjs.entry.js → kritzel-brush-style_23.cjs.entry.js} +502 -438
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/stencil.cjs.js +1 -1
- package/dist/collection/classes/commands/add-object.command.js +2 -2
- package/dist/collection/classes/commands/add-object.command.js.map +1 -1
- package/dist/collection/classes/commands/add-selection-group.command.js +3 -3
- package/dist/collection/classes/commands/add-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/remove-object.command.js +4 -4
- package/dist/collection/classes/commands/remove-object.command.js.map +1 -1
- package/dist/collection/classes/commands/remove-selection-group.command.js +2 -2
- package/dist/collection/classes/commands/remove-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/rotate-selection-group.command.js +2 -2
- package/dist/collection/classes/commands/rotate-selection-group.command.js.map +1 -1
- package/dist/collection/classes/handlers/selection.handler.js +5 -5
- package/dist/collection/classes/handlers/selection.handler.js.map +1 -1
- package/dist/collection/classes/objects/base-object.class.js +1 -1
- package/dist/collection/classes/objects/base-object.class.js.map +1 -1
- package/dist/collection/classes/objects/path.class.js +1 -1
- package/dist/collection/classes/objects/path.class.js.map +1 -1
- package/dist/collection/classes/objects/selection-group.class.js +6 -6
- package/dist/collection/classes/objects/selection-group.class.js.map +1 -1
- package/dist/collection/classes/store.class.js +9 -22
- package/dist/collection/classes/store.class.js.map +1 -1
- package/dist/collection/classes/structures/object-map.structure.js +42 -0
- package/dist/collection/classes/structures/object-map.structure.js.map +1 -0
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.css +7 -0
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +12 -2
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +17 -17
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.css +15 -155
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js +167 -177
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js.map +1 -1
- package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.css +129 -0
- package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js +261 -0
- package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js.map +1 -0
- package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js +160 -43
- package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js.map +1 -1
- package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.css +83 -74
- package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js +142 -118
- package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js.map +1 -1
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js +1 -1
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js +4 -4
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js +2 -2
- package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js +2 -2
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.css +5 -8
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +3 -3
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js +1 -1
- package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js +110 -88
- package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js.map +1 -1
- package/dist/collection/configs/default-engine-state.js +1 -1
- package/dist/collection/configs/default-engine-state.js.map +1 -1
- package/dist/collection/helpers/keyboard.helper.js +18 -0
- package/dist/collection/helpers/keyboard.helper.js.map +1 -1
- package/dist/collection/index.js +1 -0
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/interfaces/engine-state.interface.js.map +1 -1
- package/dist/collection/interfaces/menu-item.interface.js.map +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +3 -2
- package/dist/components/index.js.map +1 -1
- package/dist/components/kritzel-control-brush-config.js +1 -1
- package/dist/components/kritzel-control-text-config.js +1 -1
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-editor.js +53 -39
- package/dist/components/kritzel-editor.js.map +1 -1
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/kritzel-menu-item.d.ts +11 -0
- package/dist/components/kritzel-menu-item.js +9 -0
- package/dist/components/kritzel-menu-item.js.map +1 -0
- package/dist/components/kritzel-menu.js +1 -1
- package/dist/components/kritzel-portal.js +1 -1
- package/dist/components/kritzel-split-button.js +1 -1
- package/dist/components/kritzel-stroke-size.js +1 -1
- package/dist/components/kritzel-tooltip.js +1 -1
- package/dist/components/kritzel-utility-panel.js +1 -1
- package/dist/components/kritzel-workspace-manager.js +1 -1
- package/dist/components/{p-jG1e48OE.js → p-26poIWa_.js} +6 -6
- package/dist/components/{p-jG1e48OE.js.map → p-26poIWa_.js.map} +1 -1
- package/dist/components/{p-rQeWFfPG.js → p-BGccckxP.js} +3 -3
- package/dist/components/{p-rQeWFfPG.js.map → p-BGccckxP.js.map} +1 -1
- package/dist/components/p-BcQWRzsB.js +183 -0
- package/dist/components/p-BcQWRzsB.js.map +1 -0
- package/dist/components/p-C-DqsDXz.js +238 -0
- package/dist/components/p-C-DqsDXz.js.map +1 -0
- package/dist/components/{p-B7VrEdgP.js → p-C9-70hiF.js} +25 -7
- package/dist/components/p-C9-70hiF.js.map +1 -0
- package/dist/components/p-CJKA5zIE.js +10 -0
- package/dist/components/p-CJKA5zIE.js.map +1 -0
- package/dist/components/p-CaPdvVd4.js +127 -0
- package/dist/components/p-CaPdvVd4.js.map +1 -0
- package/dist/components/{p-a7KmQzo4.js → p-Cb1IUD_g.js} +5 -5
- package/dist/components/{p-a7KmQzo4.js.map → p-Cb1IUD_g.js.map} +1 -1
- package/dist/components/{p-BaKb8ZLg.js → p-Crni2OI4.js} +4 -4
- package/dist/components/{p-BaKb8ZLg.js.map → p-Crni2OI4.js.map} +1 -1
- package/dist/components/{p-BB22cVkU.js → p-D_Uh-xv_.js} +13 -18
- package/dist/components/p-D_Uh-xv_.js.map +1 -0
- package/dist/components/{p-BzSz74Ci.js → p-fyfT6A5K.js} +3 -3
- package/dist/components/{p-BzSz74Ci.js.map → p-fyfT6A5K.js.map} +1 -1
- package/dist/components/{p-D-zg05gA.js → p-jGaWxggY.js} +93 -179
- package/dist/components/p-jGaWxggY.js.map +1 -0
- package/dist/components/p-jpGLgpoq.js +237 -0
- package/dist/components/p-jpGLgpoq.js.map +1 -0
- package/dist/esm/{index-J4NpPimy.js → index-DqqxAoZI.js} +47 -29
- package/dist/esm/index-DqqxAoZI.js.map +1 -0
- package/dist/esm/index-NiIEUDzj.js +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/{kritzel-brush-style_22.entry.js → kritzel-brush-style_23.entry.js} +502 -439
- package/dist/esm/loader.js +1 -1
- package/dist/esm/stencil.js +1 -1
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/p-DqqxAoZI.js +2 -0
- package/dist/stencil/p-DqqxAoZI.js.map +1 -0
- package/dist/stencil/p-eebdbf65.entry.js +2 -0
- package/dist/stencil/p-eebdbf65.entry.js.map +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/structures/object-map.structure.d.ts +11 -0
- package/dist/types/components/core/kritzel-editor/kritzel-editor.d.ts +3 -0
- package/dist/types/components/shared/kritzel-menu/kritzel-menu.d.ts +18 -18
- package/dist/types/components/shared/kritzel-menu-item/kritzel-menu-item.d.ts +26 -0
- package/dist/types/components/shared/kritzel-portal/kritzel-portal.d.ts +15 -10
- package/dist/types/components/shared/kritzel-split-button/kritzel-split-button.d.ts +25 -16
- package/dist/types/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.d.ts +18 -14
- package/dist/types/components.d.ts +90 -61
- package/dist/types/helpers/keyboard.helper.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/interfaces/engine-state.interface.d.ts +2 -2
- package/dist/types/interfaces/menu-item.interface.d.ts +21 -7
- package/package.json +1 -1
- package/dist/cjs/index-C7Read21.js.map +0 -1
- package/dist/collection/classes/structures/octree.structure.js +0 -115
- package/dist/collection/classes/structures/octree.structure.js.map +0 -1
- package/dist/components/p-B7VrEdgP.js.map +0 -1
- package/dist/components/p-BB22cVkU.js.map +0 -1
- package/dist/components/p-BmJbJwkH.js +0 -167
- package/dist/components/p-BmJbJwkH.js.map +0 -1
- package/dist/components/p-D-zg05gA.js.map +0 -1
- package/dist/components/p-DV4ERZv5.js +0 -112
- package/dist/components/p-DV4ERZv5.js.map +0 -1
- package/dist/components/p-hSuNJiIq.js +0 -152
- package/dist/components/p-hSuNJiIq.js.map +0 -1
- package/dist/components/p-sQmW5NRu.js +0 -156
- package/dist/components/p-sQmW5NRu.js.map +0 -1
- package/dist/esm/index-J4NpPimy.js.map +0 -1
- package/dist/stencil/p-4a0009e7.entry.js +0 -2
- package/dist/stencil/p-4a0009e7.entry.js.map +0 -1
- package/dist/stencil/p-J4NpPimy.js +0 -2
- package/dist/stencil/p-J4NpPimy.js.map +0 -1
- package/dist/types/classes/structures/octree.structure.d.ts +0 -18
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: space-between;
|
|
6
|
+
width: 100%;
|
|
7
|
+
padding: var(--kritzel-menu-item-padding, 8px);
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
gap: 16px;
|
|
10
|
+
height: var(--kritzel-menu-item-height, 40px);
|
|
11
|
+
min-height: var(--kritzel-menu-item-min-height, 40px);
|
|
12
|
+
font-family: sans-serif;
|
|
13
|
+
font-size: var(--kritzel-menu-item-font-size, 14px);
|
|
14
|
+
border-radius: var(--kritzel-menu-item-border-radius, 12px);
|
|
15
|
+
outline: none;
|
|
16
|
+
cursor: default;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
:host(:hover) .menu-item-overlay, :host(:focus-within) .menu-item-overlay {
|
|
20
|
+
background-color: var(--kritzel-menu-item-button-hover-background-color, hsl(0, 0%, 0%, 4.3%))
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
:host(.selected) {
|
|
24
|
+
background-color: var(--kritzel-menu-item-selected-bg, #007aff);
|
|
25
|
+
color: var(--kritzel-menu-item-selected-color, #ffffff);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
:host(.selected) .action-button {
|
|
29
|
+
color: var(--kritzel-menu-item-selected-color, #ffffff);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
:host(.selected.editing) {
|
|
33
|
+
background-color: var(--kritzel-menu-item-selected-bg, #007aff);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
:host(.selected) .edit-input {
|
|
37
|
+
color: var(--kritzel-menu-item-selected-color, #ffffff);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
:host(.selected) .edit-input::selection {
|
|
41
|
+
background-color: var(--kritzel-menu-item-input-selection-color, rgba(255, 255, 255, 0.16));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
:host(.editing) {
|
|
45
|
+
background-color: var(--kritzel-menu-item-button-hover-background-color, hsl(0, 0%, 0%, 4.3%));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
:host(.disabled) {
|
|
49
|
+
opacity: 0.5;
|
|
50
|
+
pointer-events: none;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
:host(.child-open) {
|
|
54
|
+
background-color: var(--kritzel-menu-item-button-hover-background-color, hsl(0, 0%, 0%, 4.3%));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
:host(.child-open.selected) {
|
|
58
|
+
background-color: var(--kritzel-menu-item-selected-bg, #007aff);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.menu-item-overlay {
|
|
62
|
+
position: absolute;
|
|
63
|
+
inset: 0;
|
|
64
|
+
background-color: transparent;
|
|
65
|
+
z-index: 0;
|
|
66
|
+
pointer-events: none;
|
|
67
|
+
border-radius: var(--kritzel-menu-item-border-radius, 12px);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.menu-item-content {
|
|
71
|
+
display: flex;
|
|
72
|
+
align-items: center;
|
|
73
|
+
gap: 8px;
|
|
74
|
+
position: relative;
|
|
75
|
+
z-index: 1;
|
|
76
|
+
height: 100%;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.left {
|
|
80
|
+
justify-content: flex-start;
|
|
81
|
+
flex: 1;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.right {
|
|
85
|
+
justify-content: flex-end;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.edit-input {
|
|
89
|
+
flex: 1;
|
|
90
|
+
height: var(--kritzel-menu-item-input-height, 24px);
|
|
91
|
+
padding: 0;
|
|
92
|
+
background-color: transparent;
|
|
93
|
+
border-radius: 0;
|
|
94
|
+
border: none;
|
|
95
|
+
border-bottom: 1px solid var(--kritzel-menu-item-input-border, #ccc);
|
|
96
|
+
font-size: var(--kritzel-context-menu-item-font-size, 14px);
|
|
97
|
+
width: 100%;
|
|
98
|
+
min-width: 0;
|
|
99
|
+
box-sizing: border-box;
|
|
100
|
+
outline: none;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.edit-input::selection {
|
|
104
|
+
background-color: var(--kritzel-menu-item-input-selection-color, #007bff);
|
|
105
|
+
color: var(--kritzel-menu-item-input-selection-text-color, #ffffff);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.action-button {
|
|
109
|
+
padding: 4px;
|
|
110
|
+
border-radius: 8px;
|
|
111
|
+
border: none;
|
|
112
|
+
cursor: pointer;
|
|
113
|
+
display: flex;
|
|
114
|
+
align-items: center;
|
|
115
|
+
justify-content: center;
|
|
116
|
+
background-color: transparent;
|
|
117
|
+
background: transparent;
|
|
118
|
+
outline: none;
|
|
119
|
+
-webkit-tap-highlight-color: transparent;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.action-button:hover, .action-button:focus {
|
|
123
|
+
background-color: var(--kritzel-menu-item-button-hover-background-color, hsl(0, 0%, 0%, 4.3%));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.action-button.disabled {
|
|
127
|
+
pointer-events: none;
|
|
128
|
+
opacity: 0.5;
|
|
129
|
+
}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { Host, h } from "@stencil/core";
|
|
2
|
+
export class KritzelMenuItem {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.parent = null;
|
|
5
|
+
this.isDirty = false;
|
|
6
|
+
this.handleItemSelect = (event) => {
|
|
7
|
+
event.stopPropagation();
|
|
8
|
+
this.itemSelect.emit({ item: this.item, parent: this.parent });
|
|
9
|
+
};
|
|
10
|
+
this.handleInputChange = (event) => {
|
|
11
|
+
event.stopPropagation();
|
|
12
|
+
const target = event.target;
|
|
13
|
+
this.item.label = target.value;
|
|
14
|
+
this.isDirty = true;
|
|
15
|
+
};
|
|
16
|
+
this.handleSave = (event) => {
|
|
17
|
+
event.stopPropagation();
|
|
18
|
+
this.host.focus();
|
|
19
|
+
this.itemSave.emit(this.item);
|
|
20
|
+
};
|
|
21
|
+
this.handleCancel = (event) => {
|
|
22
|
+
event.stopPropagation();
|
|
23
|
+
this.host.focus();
|
|
24
|
+
this.itemCancel.emit(this.item);
|
|
25
|
+
};
|
|
26
|
+
this.handleMenuToggle = (event) => {
|
|
27
|
+
event.stopPropagation();
|
|
28
|
+
this.itemToggleChildMenu.emit({ item: this.item, childMenuAnchor: event.target });
|
|
29
|
+
};
|
|
30
|
+
this.handleMenuClose = () => {
|
|
31
|
+
this.itemCloseChildMenu.emit(this.item);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
onItemChange(newValue, oldValue) {
|
|
35
|
+
if (newValue !== oldValue) {
|
|
36
|
+
this.isDirty = false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
componentDidLoad() {
|
|
40
|
+
if (this.item.isEditing && this.inputRef && !this.isDirty) {
|
|
41
|
+
this.inputRef.focus();
|
|
42
|
+
this.inputRef.select();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
componentDidUpdate() {
|
|
46
|
+
if (this.item.isEditing && this.inputRef && !this.isDirty) {
|
|
47
|
+
this.inputRef.focus();
|
|
48
|
+
this.inputRef.select();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
renderViewMode() {
|
|
52
|
+
return [
|
|
53
|
+
h("div", { class: "menu-item-content left" }, h("div", null, this.item.label)),
|
|
54
|
+
h("div", { class: "menu-item-content right" }, this.item.children &&
|
|
55
|
+
this.item.children.length > 0 && [
|
|
56
|
+
h("button", { id: "child-menu-toggle", class: "action-button", onClick: this.handleMenuToggle, disabled: this.item.isDisabled }, h("kritzel-icon", { name: "ellipsis-vertical", size: 16 })),
|
|
57
|
+
h("kritzel-portal", { anchor: this.item.childMenuAnchor, offsetY: 4, onClose: this.handleMenuClose }, h("kritzel-menu", { items: this.item.children, parent: this.item, onItemSelect: event => this.itemSelect.emit(event.detail), onItemSave: event => this.itemSave.emit(event.detail), onItemCancel: event => this.itemCancel.emit(event.detail), onClose: this.handleMenuClose })),
|
|
58
|
+
]),
|
|
59
|
+
];
|
|
60
|
+
}
|
|
61
|
+
renderEditMode() {
|
|
62
|
+
return [
|
|
63
|
+
h("div", { class: "menu-item-content left" }, h("input", { ref: el => (this.inputRef = el), type: "text", class: "edit-input", value: this.item.label, onInput: this.handleInputChange })),
|
|
64
|
+
h("div", { class: "menu-item-content right" }, h("div", { tabIndex: !this.isDirty && !this.item.isNewItem ? -1 : 0, class: { 'action-button': true, 'disabled': !this.isDirty && !this.item.isNewItem }, onClick: this.handleSave }, h("kritzel-icon", { name: "check", size: 16 })), h("div", { tabIndex: 0, class: "action-button", onClick: this.handleCancel }, h("kritzel-icon", { name: "x", size: 16 }))),
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
render() {
|
|
68
|
+
return (h(Host, { key: '5440ed43726d00ab65e7f423f065c1a3fa74e39e', tabIndex: 0, class: {
|
|
69
|
+
'selected': this.item.isSelected,
|
|
70
|
+
'editing': this.item.isEditing,
|
|
71
|
+
'disabled': this.item.isDisabled,
|
|
72
|
+
'child-open': this.item.isChildMenuOpen,
|
|
73
|
+
}, onClick: this.handleItemSelect }, h("div", { key: '69542710179216a1df47bde5d474a72e4a07aa5b', class: "menu-item-overlay" }), this.item.isEditing ? this.renderEditMode() : this.renderViewMode()));
|
|
74
|
+
}
|
|
75
|
+
static get is() { return "kritzel-menu-item"; }
|
|
76
|
+
static get encapsulation() { return "shadow"; }
|
|
77
|
+
static get originalStyleUrls() {
|
|
78
|
+
return {
|
|
79
|
+
"$": ["kritzel-menu-item.css"]
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
static get styleUrls() {
|
|
83
|
+
return {
|
|
84
|
+
"$": ["kritzel-menu-item.css"]
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
static get properties() {
|
|
88
|
+
return {
|
|
89
|
+
"item": {
|
|
90
|
+
"type": "unknown",
|
|
91
|
+
"attribute": "item",
|
|
92
|
+
"mutable": false,
|
|
93
|
+
"complexType": {
|
|
94
|
+
"original": "IKritzelMenuItem",
|
|
95
|
+
"resolved": "IKritzelMenuItem<any>",
|
|
96
|
+
"references": {
|
|
97
|
+
"IKritzelMenuItem": {
|
|
98
|
+
"location": "import",
|
|
99
|
+
"path": "../../../interfaces/menu-item.interface",
|
|
100
|
+
"id": "src/interfaces/menu-item.interface.ts::IKritzelMenuItem"
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"required": false,
|
|
105
|
+
"optional": false,
|
|
106
|
+
"docs": {
|
|
107
|
+
"tags": [],
|
|
108
|
+
"text": ""
|
|
109
|
+
},
|
|
110
|
+
"getter": false,
|
|
111
|
+
"setter": false
|
|
112
|
+
},
|
|
113
|
+
"parent": {
|
|
114
|
+
"type": "unknown",
|
|
115
|
+
"attribute": "parent",
|
|
116
|
+
"mutable": false,
|
|
117
|
+
"complexType": {
|
|
118
|
+
"original": "IKritzelMenuItem",
|
|
119
|
+
"resolved": "IKritzelMenuItem<any>",
|
|
120
|
+
"references": {
|
|
121
|
+
"IKritzelMenuItem": {
|
|
122
|
+
"location": "import",
|
|
123
|
+
"path": "../../../interfaces/menu-item.interface",
|
|
124
|
+
"id": "src/interfaces/menu-item.interface.ts::IKritzelMenuItem"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"required": false,
|
|
129
|
+
"optional": false,
|
|
130
|
+
"docs": {
|
|
131
|
+
"tags": [],
|
|
132
|
+
"text": ""
|
|
133
|
+
},
|
|
134
|
+
"getter": false,
|
|
135
|
+
"setter": false,
|
|
136
|
+
"defaultValue": "null"
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
static get states() {
|
|
141
|
+
return {
|
|
142
|
+
"isDirty": {}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
static get events() {
|
|
146
|
+
return [{
|
|
147
|
+
"method": "itemSelect",
|
|
148
|
+
"name": "itemSelect",
|
|
149
|
+
"bubbles": true,
|
|
150
|
+
"cancelable": true,
|
|
151
|
+
"composed": true,
|
|
152
|
+
"docs": {
|
|
153
|
+
"tags": [],
|
|
154
|
+
"text": ""
|
|
155
|
+
},
|
|
156
|
+
"complexType": {
|
|
157
|
+
"original": "IKritzelMenuItemSelectEvent",
|
|
158
|
+
"resolved": "IKritzelMenuItemSelectEvent",
|
|
159
|
+
"references": {
|
|
160
|
+
"IKritzelMenuItemSelectEvent": {
|
|
161
|
+
"location": "import",
|
|
162
|
+
"path": "../../../interfaces/menu-item.interface",
|
|
163
|
+
"id": "src/interfaces/menu-item.interface.ts::IKritzelMenuItemSelectEvent"
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}, {
|
|
168
|
+
"method": "itemSave",
|
|
169
|
+
"name": "itemSave",
|
|
170
|
+
"bubbles": true,
|
|
171
|
+
"cancelable": true,
|
|
172
|
+
"composed": true,
|
|
173
|
+
"docs": {
|
|
174
|
+
"tags": [],
|
|
175
|
+
"text": ""
|
|
176
|
+
},
|
|
177
|
+
"complexType": {
|
|
178
|
+
"original": "IKritzelMenuItem",
|
|
179
|
+
"resolved": "IKritzelMenuItem<any>",
|
|
180
|
+
"references": {
|
|
181
|
+
"IKritzelMenuItem": {
|
|
182
|
+
"location": "import",
|
|
183
|
+
"path": "../../../interfaces/menu-item.interface",
|
|
184
|
+
"id": "src/interfaces/menu-item.interface.ts::IKritzelMenuItem"
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}, {
|
|
189
|
+
"method": "itemCancel",
|
|
190
|
+
"name": "itemCancel",
|
|
191
|
+
"bubbles": true,
|
|
192
|
+
"cancelable": true,
|
|
193
|
+
"composed": true,
|
|
194
|
+
"docs": {
|
|
195
|
+
"tags": [],
|
|
196
|
+
"text": ""
|
|
197
|
+
},
|
|
198
|
+
"complexType": {
|
|
199
|
+
"original": "IKritzelMenuItem",
|
|
200
|
+
"resolved": "IKritzelMenuItem<any>",
|
|
201
|
+
"references": {
|
|
202
|
+
"IKritzelMenuItem": {
|
|
203
|
+
"location": "import",
|
|
204
|
+
"path": "../../../interfaces/menu-item.interface",
|
|
205
|
+
"id": "src/interfaces/menu-item.interface.ts::IKritzelMenuItem"
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}, {
|
|
210
|
+
"method": "itemToggleChildMenu",
|
|
211
|
+
"name": "itemToggleChildMenu",
|
|
212
|
+
"bubbles": true,
|
|
213
|
+
"cancelable": true,
|
|
214
|
+
"composed": true,
|
|
215
|
+
"docs": {
|
|
216
|
+
"tags": [],
|
|
217
|
+
"text": ""
|
|
218
|
+
},
|
|
219
|
+
"complexType": {
|
|
220
|
+
"original": "IKritzelMenuItemToggleChildMenuEvent",
|
|
221
|
+
"resolved": "IKritzelMenuItemToggleChildMenuEvent",
|
|
222
|
+
"references": {
|
|
223
|
+
"IKritzelMenuItemToggleChildMenuEvent": {
|
|
224
|
+
"location": "import",
|
|
225
|
+
"path": "../../../interfaces/menu-item.interface",
|
|
226
|
+
"id": "src/interfaces/menu-item.interface.ts::IKritzelMenuItemToggleChildMenuEvent"
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}, {
|
|
231
|
+
"method": "itemCloseChildMenu",
|
|
232
|
+
"name": "itemCloseChildMenu",
|
|
233
|
+
"bubbles": true,
|
|
234
|
+
"cancelable": true,
|
|
235
|
+
"composed": true,
|
|
236
|
+
"docs": {
|
|
237
|
+
"tags": [],
|
|
238
|
+
"text": ""
|
|
239
|
+
},
|
|
240
|
+
"complexType": {
|
|
241
|
+
"original": "IKritzelMenuItem",
|
|
242
|
+
"resolved": "IKritzelMenuItem<any>",
|
|
243
|
+
"references": {
|
|
244
|
+
"IKritzelMenuItem": {
|
|
245
|
+
"location": "import",
|
|
246
|
+
"path": "../../../interfaces/menu-item.interface",
|
|
247
|
+
"id": "src/interfaces/menu-item.interface.ts::IKritzelMenuItem"
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}];
|
|
252
|
+
}
|
|
253
|
+
static get elementRef() { return "host"; }
|
|
254
|
+
static get watchers() {
|
|
255
|
+
return [{
|
|
256
|
+
"propName": "item",
|
|
257
|
+
"methodName": "onItemChange"
|
|
258
|
+
}];
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
//# sourceMappingURL=kritzel-menu-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kritzel-menu-item.js","sourceRoot":"","sources":["../../../../src/components/shared/kritzel-menu-item/kritzel-menu-item.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AAQrG,MAAM,OAAO,eAAe;IAL5B;QAeU,WAAM,GAAqB,IAAI,CAAC;QASxC,YAAO,GAAY,KAAK,CAAC;QAkBjB,qBAAgB,GAAG,CAAC,KAAiB,EAAE,EAAE;YAC/C,KAAK,CAAC,eAAe,EAAE,CAAC;YACxB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QACjE,CAAC,CAAC;QAEM,sBAAiB,GAAG,CAAC,KAAY,EAAE,EAAE;YAC3C,KAAK,CAAC,eAAe,EAAE,CAAC;YACxB,MAAM,MAAM,GAAG,KAAK,CAAC,MAA0B,CAAC;YAChD,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;YAC/B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,CAAC,CAAC;QAEM,eAAU,GAAG,CAAC,KAAiB,EAAE,EAAE;YACzC,KAAK,CAAC,eAAe,EAAE,CAAC;YACxB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAClB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC,CAAC;QAEM,iBAAY,GAAG,CAAC,KAAiB,EAAE,EAAE;YAC3C,KAAK,CAAC,eAAe,EAAE,CAAC;YACxB,IAAI,CAAC,IAAI,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, Prop, h, Element, State, Watch, Event, EventEmitter } from '@stencil/core';\r\nimport { IKritzelMenuItem, IKritzelMenuItemSelectEvent, IKritzelMenuItemToggleChildMenuEvent } from '../../../interfaces/menu-item.interface';\r\n\r\n@Component({\r\n tag: 'kritzel-menu-item',\r\n styleUrl: 'kritzel-menu-item.css',\r\n shadow: true,\r\n})\r\nexport class KritzelMenuItem {\r\n @Element() host: HTMLElement;\r\n\r\n @Prop() item: IKritzelMenuItem;\r\n @Watch('item')\r\n onItemChange(newValue: IKritzelMenuItem, oldValue: IKritzelMenuItem) {\r\n if (newValue !== oldValue) {\r\n this.isDirty = false;\r\n }\r\n }\r\n @Prop() parent: IKritzelMenuItem = null;\r\n\r\n @Event() itemSelect: EventEmitter<IKritzelMenuItemSelectEvent>;\r\n @Event() itemSave: EventEmitter<IKritzelMenuItem>;\r\n @Event() itemCancel: EventEmitter<IKritzelMenuItem>;\r\n @Event() itemToggleChildMenu: EventEmitter<IKritzelMenuItemToggleChildMenuEvent>;\r\n @Event() itemCloseChildMenu: EventEmitter<IKritzelMenuItem>;\r\n\r\n @State()\r\n isDirty: boolean = false;\r\n\r\n private inputRef: HTMLInputElement;\r\n\r\n componentDidLoad() {\r\n if (this.item.isEditing && this.inputRef && !this.isDirty) {\r\n this.inputRef.focus();\r\n this.inputRef.select();\r\n }\r\n }\r\n\r\n componentDidUpdate() {\r\n if (this.item.isEditing && this.inputRef && !this.isDirty) {\r\n this.inputRef.focus();\r\n this.inputRef.select();\r\n }\r\n }\r\n\r\n private handleItemSelect = (event: MouseEvent) => {\r\n event.stopPropagation();\r\n this.itemSelect.emit({ item: this.item, parent: this.parent });\r\n };\r\n\r\n private handleInputChange = (event: Event) => {\r\n event.stopPropagation();\r\n const target = event.target as HTMLInputElement;\r\n this.item.label = target.value;\r\n this.isDirty = true;\r\n };\r\n\r\n private handleSave = (event: MouseEvent) => {\r\n event.stopPropagation();\r\n this.host.focus();\r\n this.itemSave.emit(this.item);\r\n };\r\n\r\n private handleCancel = (event: MouseEvent) => {\r\n event.stopPropagation();\r\n this.host.focus();\r\n this.itemCancel.emit(this.item);\r\n };\r\n\r\n private handleMenuToggle = (event: MouseEvent) => {\r\n event.stopPropagation();\r\n this.itemToggleChildMenu.emit({ item: this.item, childMenuAnchor: event.target as HTMLElement });\r\n };\r\n\r\n private handleMenuClose = () => {\r\n this.itemCloseChildMenu.emit(this.item);\r\n };\r\n\r\n private renderViewMode() {\r\n return [\r\n <div class=\"menu-item-content left\">\r\n <div>{this.item.label}</div>\r\n </div>,\r\n <div class=\"menu-item-content right\">\r\n {this.item.children &&\r\n this.item.children.length > 0 && [\r\n <button id=\"child-menu-toggle\" class=\"action-button\" onClick={this.handleMenuToggle} disabled={this.item.isDisabled}>\r\n <kritzel-icon name=\"ellipsis-vertical\" size={16}></kritzel-icon>\r\n </button>,\r\n <kritzel-portal anchor={this.item.childMenuAnchor} offsetY={4} onClose={this.handleMenuClose}>\r\n <kritzel-menu\r\n items={this.item.children}\r\n parent={this.item}\r\n onItemSelect={event => this.itemSelect.emit(event.detail)}\r\n onItemSave={event => this.itemSave.emit(event.detail)}\r\n onItemCancel={event => this.itemCancel.emit(event.detail)}\r\n onClose={this.handleMenuClose}\r\n ></kritzel-menu>\r\n </kritzel-portal>,\r\n ]}\r\n </div>,\r\n ];\r\n }\r\n\r\n private renderEditMode() {\r\n return [\r\n <div class=\"menu-item-content left\">\r\n <input ref={el => (this.inputRef = el)} type=\"text\" class=\"edit-input\" value={this.item.label} onInput={this.handleInputChange} />\r\n </div>,\r\n <div class=\"menu-item-content right\">\r\n <div tabIndex={!this.isDirty && !this.item.isNewItem ? -1 : 0} class={{ 'action-button': true, 'disabled': !this.isDirty && !this.item.isNewItem }} onClick={this.handleSave}>\r\n <kritzel-icon name=\"check\" size={16}></kritzel-icon>\r\n </div>\r\n <div tabIndex={0} class=\"action-button\" onClick={this.handleCancel}>\r\n <kritzel-icon name=\"x\" size={16}></kritzel-icon>\r\n </div>\r\n </div>,\r\n ];\r\n }\r\n\r\n render() {\r\n return (\r\n <Host\r\n tabIndex={0}\r\n class={{\r\n 'selected': this.item.isSelected,\r\n 'editing': this.item.isEditing,\r\n 'disabled': this.item.isDisabled,\r\n 'child-open': this.item.isChildMenuOpen,\r\n }}\r\n onClick={this.handleItemSelect}\r\n >\r\n <div class=\"menu-item-overlay\"></div>\r\n {this.item.isEditing ? this.renderEditMode() : this.renderViewMode()}\r\n </Host>\r\n );\r\n }\r\n}\r\n"]}
|
|
@@ -1,41 +1,158 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
|
-
import {
|
|
3
|
-
const DEFAULT_OFFSET = 0;
|
|
4
|
-
const MIN_LEFT_POSITION = 0;
|
|
5
|
-
const Z_INDEX = '9005';
|
|
6
|
-
const ID_PORTAL = 'portal';
|
|
2
|
+
import { ObjectHelper } from "../../../helpers/object.helper";
|
|
7
3
|
export class KritzelPortal {
|
|
8
4
|
constructor() {
|
|
9
5
|
this.autoFocus = true;
|
|
10
|
-
this.
|
|
11
|
-
this.
|
|
12
|
-
|
|
13
|
-
if (!isAnchorInViewport) {
|
|
14
|
-
this.close.emit();
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
this.calculatePosition();
|
|
18
|
-
};
|
|
6
|
+
this.id = `portal-${ObjectHelper.generateUUID()}`;
|
|
7
|
+
this.defaultOffset = 0;
|
|
8
|
+
this.minLeft = 0;
|
|
19
9
|
}
|
|
20
10
|
anchorChanged(newValue) {
|
|
21
11
|
if (newValue) {
|
|
12
|
+
this.openPortal();
|
|
22
13
|
this.calculatePosition();
|
|
14
|
+
if (this.autoFocus) {
|
|
15
|
+
this.focusFirstElement();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
this.closePortal();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
handleOutsideClick(event) {
|
|
23
|
+
event.stopPropagation();
|
|
24
|
+
const isLastPortal = this.lastAddedPortal === this.portal;
|
|
25
|
+
if (!isLastPortal)
|
|
26
|
+
return;
|
|
27
|
+
const target = event.target;
|
|
28
|
+
if (!this.host.contains(target)) {
|
|
29
|
+
this.close.emit();
|
|
30
|
+
this.closePortal();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
handleKeyDown(event) {
|
|
34
|
+
event.stopPropagation();
|
|
35
|
+
const isLastPortal = this.lastAddedPortal === this.portal;
|
|
36
|
+
if (!isLastPortal)
|
|
37
|
+
return;
|
|
38
|
+
if (event.key === 'Escape') {
|
|
39
|
+
this.anchor.focus();
|
|
40
|
+
this.close.emit();
|
|
41
|
+
this.closePortal();
|
|
42
|
+
}
|
|
43
|
+
if (event.key === 'Tab') {
|
|
44
|
+
this.trapFocus(event);
|
|
45
|
+
}
|
|
46
|
+
if (event.key === 'Enter') {
|
|
47
|
+
const activeElement = this.getDeepActiveElement();
|
|
48
|
+
if (activeElement === null || activeElement === void 0 ? void 0 : activeElement.click) {
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
activeElement.click();
|
|
51
|
+
}
|
|
23
52
|
}
|
|
24
53
|
}
|
|
25
54
|
handleResize() {
|
|
26
55
|
this.calculatePosition();
|
|
27
56
|
}
|
|
57
|
+
focusFirstElement() {
|
|
58
|
+
requestAnimationFrame(() => {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
(_b = (_a = this.firstFocusableElement) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
getDeepActiveElement() {
|
|
64
|
+
var _a;
|
|
65
|
+
let activeEl = document.activeElement;
|
|
66
|
+
while ((_a = activeEl === null || activeEl === void 0 ? void 0 : activeEl.shadowRoot) === null || _a === void 0 ? void 0 : _a.activeElement) {
|
|
67
|
+
activeEl = activeEl.shadowRoot.activeElement;
|
|
68
|
+
}
|
|
69
|
+
return activeEl;
|
|
70
|
+
}
|
|
71
|
+
trapFocus(event) {
|
|
72
|
+
const focusableElements = this.getFocusableElements(this.host);
|
|
73
|
+
if (focusableElements.length === 0)
|
|
74
|
+
return;
|
|
75
|
+
const firstFocusable = focusableElements[0];
|
|
76
|
+
const lastFocusable = focusableElements[focusableElements.length - 1];
|
|
77
|
+
const activeElement = this.getDeepActiveElement();
|
|
78
|
+
if (event.shiftKey) {
|
|
79
|
+
/* shift + tab */
|
|
80
|
+
if (activeElement === firstFocusable) {
|
|
81
|
+
lastFocusable.focus();
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
/* tab */
|
|
87
|
+
if (activeElement === lastFocusable) {
|
|
88
|
+
firstFocusable.focus();
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
getFocusableElements(root) {
|
|
94
|
+
if (!root)
|
|
95
|
+
return [];
|
|
96
|
+
const focusableElements = [];
|
|
97
|
+
const focusableSelector = 'a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), details, [tabindex]:not([tabindex="-1"])';
|
|
98
|
+
const isVisible = (el) => {
|
|
99
|
+
return el.offsetParent !== null;
|
|
100
|
+
};
|
|
101
|
+
// Check if the root element itself is focusable
|
|
102
|
+
if (root.matches(focusableSelector) && !root.hasAttribute('disabled') && isVisible(root)) {
|
|
103
|
+
focusableElements.push(root);
|
|
104
|
+
}
|
|
105
|
+
// Function to recursively find focusable elements
|
|
106
|
+
const findFocusable = (element) => {
|
|
107
|
+
// Search in shadow root
|
|
108
|
+
if (element.shadowRoot) {
|
|
109
|
+
Array.from(element.shadowRoot.querySelectorAll(focusableSelector)).forEach(el => {
|
|
110
|
+
if (isVisible(el)) {
|
|
111
|
+
focusableElements.push(el);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
Array.from(element.shadowRoot.children).forEach(findFocusable);
|
|
115
|
+
}
|
|
116
|
+
// Search in light DOM
|
|
117
|
+
Array.from(element.querySelectorAll(focusableSelector)).forEach(el => {
|
|
118
|
+
if (!focusableElements.includes(el) && isVisible(el)) {
|
|
119
|
+
focusableElements.push(el);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
// Handle slotted content
|
|
123
|
+
if (element.tagName === 'SLOT') {
|
|
124
|
+
element.assignedElements({ flatten: true }).forEach(el => findFocusable(el));
|
|
125
|
+
}
|
|
126
|
+
Array.from(element.children).forEach(findFocusable);
|
|
127
|
+
};
|
|
128
|
+
findFocusable(root);
|
|
129
|
+
// Return unique elements in document order
|
|
130
|
+
return [...new Set(focusableElements)];
|
|
131
|
+
}
|
|
132
|
+
get firstFocusableElement() {
|
|
133
|
+
var _a, _b;
|
|
134
|
+
const slotEl = (_a = this.host.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot');
|
|
135
|
+
const firstAssigned = slotEl === null || slotEl === void 0 ? void 0 : slotEl.assignedElements({ flatten: true })[0];
|
|
136
|
+
if (!firstAssigned)
|
|
137
|
+
return null;
|
|
138
|
+
const focusable = this.getFocusableElements(firstAssigned);
|
|
139
|
+
return (_b = focusable[0]) !== null && _b !== void 0 ? _b : firstAssigned;
|
|
140
|
+
}
|
|
141
|
+
get lastAddedPortal() {
|
|
142
|
+
const portals = Array.from(document.querySelectorAll('[id^="portal-"]'));
|
|
143
|
+
return portals.length ? portals[portals.length - 1] : null;
|
|
144
|
+
}
|
|
28
145
|
calculateLeft() {
|
|
29
146
|
var _a;
|
|
30
147
|
if (!this.anchor || !this.portal)
|
|
31
148
|
return 0;
|
|
32
149
|
const refRect = this.anchor.getBoundingClientRect();
|
|
33
150
|
const portalRect = this.portal.getBoundingClientRect();
|
|
34
|
-
const offset = (_a = this.offsetX) !== null && _a !== void 0 ? _a :
|
|
151
|
+
const offset = (_a = this.offsetX) !== null && _a !== void 0 ? _a : this.defaultOffset;
|
|
35
152
|
let left = refRect.left + offset;
|
|
36
|
-
const maxLeft = window.innerWidth - portalRect.width -
|
|
37
|
-
if (left <
|
|
38
|
-
left =
|
|
153
|
+
const maxLeft = window.innerWidth - portalRect.width - this.minLeft;
|
|
154
|
+
if (left < this.minLeft)
|
|
155
|
+
left = this.minLeft;
|
|
39
156
|
if (left > maxLeft)
|
|
40
157
|
left = maxLeft;
|
|
41
158
|
return Math.round(left + window.scrollX);
|
|
@@ -46,25 +163,29 @@ export class KritzelPortal {
|
|
|
46
163
|
return 0;
|
|
47
164
|
const refRect = this.anchor.getBoundingClientRect();
|
|
48
165
|
const portalRect = this.portal.getBoundingClientRect();
|
|
49
|
-
const offset = (_a = this.offsetY) !== null && _a !== void 0 ? _a :
|
|
166
|
+
const offset = (_a = this.offsetY) !== null && _a !== void 0 ? _a : this.defaultOffset;
|
|
50
167
|
let top = refRect.bottom + offset;
|
|
51
168
|
if (top + portalRect.height > window.innerHeight) {
|
|
52
169
|
top = refRect.top - portalRect.height - offset;
|
|
53
170
|
}
|
|
54
171
|
return Math.round(top + window.scrollY);
|
|
55
172
|
}
|
|
56
|
-
|
|
173
|
+
openPortal() {
|
|
57
174
|
this.portal = document.createElement('div');
|
|
58
|
-
this.portal.setAttribute('id',
|
|
59
|
-
this.portal.style.zIndex =
|
|
175
|
+
this.portal.setAttribute('id', this.id);
|
|
176
|
+
this.portal.style.zIndex = '1';
|
|
60
177
|
this.portal.style.position = 'absolute';
|
|
61
178
|
this.portal.style.top = '0px';
|
|
62
179
|
this.portal.style.left = '0px';
|
|
180
|
+
this.portal.appendChild(this.host);
|
|
63
181
|
document.body.append(this.portal);
|
|
64
182
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
183
|
+
closePortal() {
|
|
184
|
+
const portal = document.getElementById(this.id);
|
|
185
|
+
if (!portal)
|
|
186
|
+
return;
|
|
187
|
+
document.body.removeChild(portal);
|
|
188
|
+
this.host.remove();
|
|
68
189
|
}
|
|
69
190
|
calculatePosition() {
|
|
70
191
|
if (!this.anchor || !this.portal)
|
|
@@ -74,25 +195,8 @@ export class KritzelPortal {
|
|
|
74
195
|
this.portal.style.top = `${top}px`;
|
|
75
196
|
this.portal.style.left = `${left}px`;
|
|
76
197
|
}
|
|
77
|
-
componentWillLoad() {
|
|
78
|
-
this.createPortal();
|
|
79
|
-
}
|
|
80
|
-
componentDidLoad() {
|
|
81
|
-
var _a;
|
|
82
|
-
this.moveElementToPortal();
|
|
83
|
-
if (this.anchor) {
|
|
84
|
-
this.calculatePosition();
|
|
85
|
-
this.scrollableParent = KritzelHTMLHelper.getScrollableParent(this.anchor);
|
|
86
|
-
(_a = this.scrollableParent) === null || _a === void 0 ? void 0 : _a.addEventListener('scroll', this.handleScroll);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
disconnectedCallback() {
|
|
90
|
-
var _a;
|
|
91
|
-
this.moved ? this.portal.remove() : (this.moved = true);
|
|
92
|
-
(_a = this.scrollableParent) === null || _a === void 0 ? void 0 : _a.removeEventListener('scroll', this.handleScroll);
|
|
93
|
-
}
|
|
94
198
|
render() {
|
|
95
|
-
return (h(Host, { key: '
|
|
199
|
+
return (h(Host, { key: '968f0360b9396da16f5b970293ba20f8a1dcc09a', style: { display: this.anchor ? 'block' : 'none' } }, h("slot", { key: '0fe1569bde60a834e9226d7c838d113a64151164' })));
|
|
96
200
|
}
|
|
97
201
|
static get is() { return "kritzel-portal"; }
|
|
98
202
|
static get encapsulation() { return "shadow"; }
|
|
@@ -199,6 +303,7 @@ export class KritzelPortal {
|
|
|
199
303
|
}
|
|
200
304
|
}];
|
|
201
305
|
}
|
|
306
|
+
static get elementRef() { return "host"; }
|
|
202
307
|
static get watchers() {
|
|
203
308
|
return [{
|
|
204
309
|
"propName": "anchor",
|
|
@@ -207,6 +312,18 @@ export class KritzelPortal {
|
|
|
207
312
|
}
|
|
208
313
|
static get listeners() {
|
|
209
314
|
return [{
|
|
315
|
+
"name": "click",
|
|
316
|
+
"method": "handleOutsideClick",
|
|
317
|
+
"target": "window",
|
|
318
|
+
"capture": false,
|
|
319
|
+
"passive": false
|
|
320
|
+
}, {
|
|
321
|
+
"name": "keydown",
|
|
322
|
+
"method": "handleKeyDown",
|
|
323
|
+
"target": "window",
|
|
324
|
+
"capture": false,
|
|
325
|
+
"passive": false
|
|
326
|
+
}, {
|
|
210
327
|
"name": "resize",
|
|
211
328
|
"method": "handleResize",
|
|
212
329
|
"target": "window",
|