@operato/popup 7.0.0-rc.8 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.storybook/preview.js +52 -0
- package/CHANGELOG.md +46 -0
- package/dist/src/open-popup.js +1 -1
- package/dist/src/open-popup.js.map +1 -1
- package/dist/src/ox-floating-overlay.js +210 -213
- package/dist/src/ox-floating-overlay.js.map +1 -1
- package/dist/src/ox-popup-list.js +120 -122
- package/dist/src/ox-popup-list.js.map +1 -1
- package/dist/src/ox-popup-menu.js +68 -69
- package/dist/src/ox-popup-menu.js.map +1 -1
- package/dist/src/ox-popup-menuitem.js +44 -45
- package/dist/src/ox-popup-menuitem.js.map +1 -1
- package/dist/src/ox-popup.js +27 -27
- package/dist/src/ox-popup.js.map +1 -1
- package/dist/src/ox-prompt.js +99 -100
- package/dist/src/ox-prompt.js.map +1 -1
- package/dist/stories/open-popup.stories.d.ts +0 -5
- package/dist/stories/open-popup.stories.js +2 -7
- package/dist/stories/open-popup.stories.js.map +1 -1
- package/dist/stories/ox-popup-list-sortable.stories.d.ts +0 -5
- package/dist/stories/ox-popup-list-sortable.stories.js +3 -8
- package/dist/stories/ox-popup-list-sortable.stories.js.map +1 -1
- package/dist/stories/ox-popup-list.stories.d.ts +2 -3
- package/dist/stories/ox-popup-list.stories.js +14 -11
- package/dist/stories/ox-popup-list.stories.js.map +1 -1
- package/dist/stories/ox-popup-menu.stories.d.ts +1 -7
- package/dist/stories/ox-popup-menu.stories.js +2 -8
- package/dist/stories/ox-popup-menu.stories.js.map +1 -1
- package/dist/stories/ox-popup.stories.d.ts +1 -7
- package/dist/stories/ox-popup.stories.js +2 -8
- package/dist/stories/ox-popup.stories.js.map +1 -1
- package/dist/stories/ox-prompt-icon.stories.d.ts +0 -5
- package/dist/stories/ox-prompt-icon.stories.js +5 -15
- package/dist/stories/ox-prompt-icon.stories.js.map +1 -1
- package/dist/stories/ox-prompt-normal.stories.d.ts +2 -3
- package/dist/stories/ox-prompt-normal.stories.js +9 -10
- package/dist/stories/ox-prompt-normal.stories.js.map +1 -1
- package/dist/stories/ox-prompt.stories.d.ts +2 -3
- package/dist/stories/ox-prompt.stories.js +6 -9
- package/dist/stories/ox-prompt.stories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -4
- package/src/ox-popup-menu.ts +1 -0
- package/src/ox-prompt.ts +1 -1
- package/stories/open-popup.stories.ts +2 -9
- package/stories/ox-popup-list-sortable.stories.ts +2 -8
- package/stories/ox-popup-list.stories.ts +14 -11
- package/stories/ox-popup-menu.stories.ts +3 -11
- package/stories/ox-popup.stories.ts +3 -11
- package/stories/ox-prompt-icon.stories.ts +4 -17
- package/stories/ox-prompt-normal.stories.ts +10 -11
- package/stories/ox-prompt.stories.ts +7 -11
- package/themes/app-theme.css +138 -0
- package/themes/calendar-theme.css +59 -0
- package/themes/dark.css +0 -100
- package/themes/grist-theme.css +45 -41
- package/themes/layout-theme.css +94 -0
- package/themes/light.css +3 -103
- package/themes/material-theme.css +23 -0
- package/themes/oops-theme.css +22 -0
- package/themes/report-theme.css +47 -0
- package/themes/spacing.css +7 -27
- package/themes/state-color.css +1 -1
- package/themes/tooltip-theme.css +11 -0
- package/tsconfig.json +2 -1
- package/themes/dark-hc.css +0 -151
- package/themes/dark-mc.css +0 -151
- package/themes/light-hc.css +0 -151
- package/themes/light-mc.css +0 -151
|
@@ -6,7 +6,7 @@ import { OxPopup } from './ox-popup';
|
|
|
6
6
|
function focusClosest(element) {
|
|
7
7
|
/* Find the closest focusable element. */
|
|
8
8
|
const closest = element.closest('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
|
|
9
|
-
closest
|
|
9
|
+
closest?.focus();
|
|
10
10
|
return closest;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
@@ -20,7 +20,6 @@ let OxPopupMenu = class OxPopupMenu extends OxPopup {
|
|
|
20
20
|
*/
|
|
21
21
|
this.activeIndex = 0;
|
|
22
22
|
this._onkeydown = function (e) {
|
|
23
|
-
var _a;
|
|
24
23
|
e.stopPropagation();
|
|
25
24
|
switch (e.key) {
|
|
26
25
|
case 'Esc': // for IE/Edge
|
|
@@ -41,7 +40,7 @@ let OxPopupMenu = class OxPopupMenu extends OxPopup {
|
|
|
41
40
|
break;
|
|
42
41
|
case 'Enter':
|
|
43
42
|
e.stopPropagation();
|
|
44
|
-
var menu =
|
|
43
|
+
var menu = e.target?.closest('[menu], ox-popup-menuitem');
|
|
45
44
|
if (menu) {
|
|
46
45
|
this.select(menu);
|
|
47
46
|
}
|
|
@@ -66,78 +65,17 @@ let OxPopupMenu = class OxPopupMenu extends OxPopup {
|
|
|
66
65
|
}
|
|
67
66
|
}.bind(this);
|
|
68
67
|
this._onclick = function (e) {
|
|
69
|
-
var _a;
|
|
70
68
|
e.stopPropagation();
|
|
71
|
-
const menu =
|
|
69
|
+
const menu = e.target?.closest('[menu], ox-popup-menuitem');
|
|
72
70
|
if (menu) {
|
|
73
71
|
this.setActive(menu);
|
|
74
72
|
this.select(menu);
|
|
75
73
|
}
|
|
76
74
|
}.bind(this);
|
|
77
75
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
updated(changes) {
|
|
82
|
-
if (changes.has('activeIndex')) {
|
|
83
|
-
this.setActive(this.activeIndex);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Selects a menu item by dispatching a 'select' event.
|
|
88
|
-
* Closes the menu if the item doesn't have 'alive-on-select' attribute.
|
|
89
|
-
*/
|
|
90
|
-
select(menu) {
|
|
91
|
-
menu.dispatchEvent(new CustomEvent('select'));
|
|
92
|
-
if (!menu.hasAttribute('alive-on-select')) {
|
|
93
|
-
this.dispatchEvent(new CustomEvent('ox-close', { bubbles: true, composed: true, detail: this }));
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Sets the active menu item based on the index or the menu element itself.
|
|
98
|
-
*/
|
|
99
|
-
setActive(active) {
|
|
100
|
-
const menus = Array.from(this.querySelectorAll(':scope > ox-popup-menuitem, :scope > [menu]'));
|
|
101
|
-
menus.map(async (menu, index) => {
|
|
102
|
-
if (typeof active === 'number' && index === (active + menus.length) % menus.length) {
|
|
103
|
-
menu.setAttribute('active', '');
|
|
104
|
-
focusClosest(menu);
|
|
105
|
-
this.activeIndex = index;
|
|
106
|
-
}
|
|
107
|
-
else if (active === menu) {
|
|
108
|
-
if (this.activeIndex === index) {
|
|
109
|
-
/* 메뉴의 update를 유도하기 위해서 강제로 토글시킴 */
|
|
110
|
-
menu.removeAttribute('active');
|
|
111
|
-
await this.updateComplete;
|
|
112
|
-
menu.setAttribute('active', '');
|
|
113
|
-
}
|
|
114
|
-
this.activeIndex = index;
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
menu.removeAttribute('active');
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Static method to open a popup menu with the provided template and position options.
|
|
123
|
-
* Creates and returns an instance of OxPopupMenu.
|
|
124
|
-
*
|
|
125
|
-
* @param {PopupOpenOptions}
|
|
126
|
-
*/
|
|
127
|
-
static open({ template, top, left, right, bottom, parent }) {
|
|
128
|
-
const owner = parent || document.body;
|
|
129
|
-
const target = document.createElement('ox-popup-menu');
|
|
130
|
-
render(template, target);
|
|
131
|
-
target.setAttribute('active', '');
|
|
132
|
-
target._parent = owner;
|
|
133
|
-
owner.appendChild(target);
|
|
134
|
-
target.open({ top, left, right, bottom });
|
|
135
|
-
return target;
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
OxPopupMenu.styles = [
|
|
139
|
-
...OxPopup.styles,
|
|
140
|
-
css `
|
|
76
|
+
static { this.styles = [
|
|
77
|
+
...OxPopup.styles,
|
|
78
|
+
css `
|
|
141
79
|
:host {
|
|
142
80
|
display: none;
|
|
143
81
|
flex-direction: column;
|
|
@@ -146,6 +84,7 @@ OxPopupMenu.styles = [
|
|
|
146
84
|
z-index: 100;
|
|
147
85
|
box-shadow: 2px 3px 10px 5px rgba(0, 0, 0, 0.15);
|
|
148
86
|
padding: var(--spacing-small) 0;
|
|
87
|
+
border-radius: var(--spacing-small);
|
|
149
88
|
|
|
150
89
|
color: var(--ox-popup-list-color, var(--md-sys-color-primary-container));
|
|
151
90
|
font-size: var(--md-sys-typescale-label-large-size, 0.875rem);
|
|
@@ -198,7 +137,67 @@ OxPopupMenu.styles = [
|
|
|
198
137
|
background-color: var(--ox-popup-menu-separator-color, var(--md-sys-color-surface-variant));
|
|
199
138
|
}
|
|
200
139
|
`
|
|
201
|
-
];
|
|
140
|
+
]; }
|
|
141
|
+
render() {
|
|
142
|
+
return html ` <slot> </slot> `;
|
|
143
|
+
}
|
|
144
|
+
updated(changes) {
|
|
145
|
+
if (changes.has('activeIndex')) {
|
|
146
|
+
this.setActive(this.activeIndex);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Selects a menu item by dispatching a 'select' event.
|
|
151
|
+
* Closes the menu if the item doesn't have 'alive-on-select' attribute.
|
|
152
|
+
*/
|
|
153
|
+
select(menu) {
|
|
154
|
+
menu.dispatchEvent(new CustomEvent('select'));
|
|
155
|
+
if (!menu.hasAttribute('alive-on-select')) {
|
|
156
|
+
this.dispatchEvent(new CustomEvent('ox-close', { bubbles: true, composed: true, detail: this }));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Sets the active menu item based on the index or the menu element itself.
|
|
161
|
+
*/
|
|
162
|
+
setActive(active) {
|
|
163
|
+
const menus = Array.from(this.querySelectorAll(':scope > ox-popup-menuitem, :scope > [menu]'));
|
|
164
|
+
menus.map(async (menu, index) => {
|
|
165
|
+
if (typeof active === 'number' && index === (active + menus.length) % menus.length) {
|
|
166
|
+
menu.setAttribute('active', '');
|
|
167
|
+
focusClosest(menu);
|
|
168
|
+
this.activeIndex = index;
|
|
169
|
+
}
|
|
170
|
+
else if (active === menu) {
|
|
171
|
+
if (this.activeIndex === index) {
|
|
172
|
+
/* 메뉴의 update를 유도하기 위해서 강제로 토글시킴 */
|
|
173
|
+
menu.removeAttribute('active');
|
|
174
|
+
await this.updateComplete;
|
|
175
|
+
menu.setAttribute('active', '');
|
|
176
|
+
}
|
|
177
|
+
this.activeIndex = index;
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
menu.removeAttribute('active');
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Static method to open a popup menu with the provided template and position options.
|
|
186
|
+
* Creates and returns an instance of OxPopupMenu.
|
|
187
|
+
*
|
|
188
|
+
* @param {PopupOpenOptions}
|
|
189
|
+
*/
|
|
190
|
+
static open({ template, top, left, right, bottom, parent }) {
|
|
191
|
+
const owner = parent || document.body;
|
|
192
|
+
const target = document.createElement('ox-popup-menu');
|
|
193
|
+
render(template, target);
|
|
194
|
+
target.setAttribute('active', '');
|
|
195
|
+
target._parent = owner;
|
|
196
|
+
owner.appendChild(target);
|
|
197
|
+
target.open({ top, left, right, bottom });
|
|
198
|
+
return target;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
202
201
|
__decorate([
|
|
203
202
|
property({ type: Number })
|
|
204
203
|
], OxPopupMenu.prototype, "activeIndex", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ox-popup-menu.js","sourceRoot":"","sources":["../../src/ox-popup-menu.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC,SAAS,YAAY,CAAC,OAAoB;IACxC,yCAAyC;IACzC,MAAM,OAAO,G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;;;OAKG;IACH,MAAM,CAAC,IAAI,CAAC,EACV,QAAQ,EACR,GAAG,EACH,IAAI,EACJ,KAAK,EACL,MAAM,EACN,MAAM,EAQP;QACC,MAAM,KAAK,GAAG,MAAM,IAAI,QAAQ,CAAC,IAAI,CAAA;QACrC,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,eAAe,CAAgB,CAAA;QACrE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;QAExB,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;QAEjC,MAAM,CAAC,OAAO,GAAG,KAAK,CAAA;QAEtB,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;QAEzB,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;QAEzC,OAAO,MAAM,CAAA;IACf,CAAC;;AAtNM,kBAAM,GAAG;IACd,GAAG,OAAO,CAAC,MAAM;IACjB,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4DF;CACF,AA/DY,CA+DZ;AAK2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAwB;AArExC,WAAW;IADvB,aAAa,CAAC,eAAe,CAAC;GAClB,WAAW,CAwNvB","sourcesContent":["import { css, html, PropertyValues } from 'lit'\nimport { render } from 'lit-html'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { OxPopup } from './ox-popup'\n\nfunction focusClosest(element: HTMLElement) {\n /* Find the closest focusable element. */\n const closest = element.closest(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])'\n ) as HTMLElement\n\n closest?.focus()\n\n return closest\n}\n\n/**\n * Custom element representing a popup menu. It extends OxPopup.\n */\n@customElement('ox-popup-menu')\nexport class OxPopupMenu extends OxPopup {\n static styles = [\n ...OxPopup.styles,\n css`\n :host {\n display: none;\n flex-direction: column;\n align-items: stretch;\n background-color: var(--ox-popup-menu-background-color, var(--md-sys-color-surface));\n z-index: 100;\n box-shadow: 2px 3px 10px 5px rgba(0, 0, 0, 0.15);\n padding: var(--spacing-small) 0;\n\n color: var(--ox-popup-list-color, var(--md-sys-color-primary-container));\n font-size: var(--md-sys-typescale-label-large-size, 0.875rem);\n }\n\n :host([active]) {\n display: flex;\n }\n\n :host(*:focus) {\n outline: none;\n }\n\n ::slotted(*) {\n padding: var(--spacing-medium);\n border-bottom: 1px solid var(--md-sys-color-surface-variant);\n cursor: pointer;\n color: var(--ox-popup-list-color, var(--md-sys-color-outline-variant));\n }\n\n ::slotted(*:focus) {\n cursor: pointer;\n outline: none;\n }\n\n ::slotted([menu]),\n ::slotted(ox-popup-menuitem) {\n border-left: 3px solid transparent;\n background-color: var(--ox-popup-menu-background-color, var(--md-sys-color-surface));\n color: var(--ox-popup-menu-color, var(--md-sys-color-on-surface));\n }\n\n ::slotted([menu][active]),\n ::slotted([menu]:hover),\n ::slotted(ox-popup-menuitem[active]),\n ::slotted(ox-popup-menuitem:hover) {\n background-color: var(--ox-popup-list-background-color-variant, var(--md-sys-color-primary-container));\n color: var(--ox-popup-list-color-variant, var(--md-sys-color-primary));\n }\n\n ::slotted(ox-popup-menuitem[active]) {\n border-left: 3px solid var(--md-sys-color-primary);\n font-weight: var(--md-sys-typescale-label-large-weight, var(--md-ref-typeface-weight-medium, 500));\n }\n\n ::slotted([separator]) {\n height: 1px;\n width: 100%;\n padding: 0;\n background-color: var(--ox-popup-menu-separator-color, var(--md-sys-color-surface-variant));\n }\n `\n ]\n\n /**\n * Property to track the index of the active menu item.\n */\n @property({ type: Number }) activeIndex: number = 0\n\n render() {\n return html` <slot> </slot> `\n }\n\n protected _onkeydown: (e: KeyboardEvent) => void = function (this: OxPopupMenu, e: KeyboardEvent) {\n e.stopPropagation()\n\n switch (e.key) {\n case 'Esc': // for IE/Edge\n case 'Escape':\n case 'Left': // for IE/Edge\n case 'ArrowLeft':\n this.close()\n break\n\n case 'Up': // for IE/Edge\n case 'ArrowUp':\n this.activeIndex--\n break\n\n case 'Right': // for IE/Edge\n case 'ArrowRight':\n case 'Down': // for IE/Edge\n case 'ArrowDown':\n this.activeIndex++\n break\n\n case 'Enter':\n e.stopPropagation()\n var menu = (e.target as HTMLElement)?.closest('[menu], ox-popup-menuitem')\n if (menu) {\n this.select(menu)\n }\n break\n }\n }.bind(this)\n\n protected _onfocusout: (e: FocusEvent) => void = function (this: OxPopupMenu, e: FocusEvent) {\n const target = e.target as HTMLElement\n const to = e.relatedTarget as HTMLElement\n const from = target.closest('ox-popup-menu')\n\n if (!to && from !== this) {\n e.stopPropagation()\n\n /* \"하위의 POPUP-MENU 엘리먼트가 포커스를 잃었지만, 그 포커스를 받은 엘리먼트가 없다.\"는 의미는 그 서브메뉴가 클로즈된 것을 의미한다. */\n this.setActive(this.activeIndex)\n } else {\n if (!this.contains(to)) {\n /* 분명히 내 범위가 아닌 엘리먼트로 포커스가 옮겨졌다면, popup-menu는 닫혀야 한다. */\n // @ts-ignore for debug\n !window.POPUP_DEBUG && this.close()\n }\n }\n }.bind(this)\n\n protected _onclick: (e: MouseEvent) => void = function (this: OxPopupMenu, e: MouseEvent) {\n e.stopPropagation()\n\n const menu = (e.target as HTMLElement)?.closest('[menu], ox-popup-menuitem')\n if (menu) {\n this.setActive(menu)\n this.select(menu)\n }\n }.bind(this)\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('activeIndex')) {\n this.setActive(this.activeIndex)\n }\n }\n\n /**\n * Selects a menu item by dispatching a 'select' event.\n * Closes the menu if the item doesn't have 'alive-on-select' attribute.\n */\n select(menu: Element) {\n menu.dispatchEvent(new CustomEvent('select'))\n if (!menu.hasAttribute('alive-on-select')) {\n this.dispatchEvent(new CustomEvent('ox-close', { bubbles: true, composed: true, detail: this }))\n }\n }\n\n /**\n * Sets the active menu item based on the index or the menu element itself.\n */\n setActive(active: number | Element | null) {\n const menus = Array.from(this.querySelectorAll(':scope > ox-popup-menuitem, :scope > [menu]'))\n\n menus.map(async (menu, index) => {\n if (typeof active === 'number' && index === (active + menus.length) % menus.length) {\n menu.setAttribute('active', '')\n focusClosest(menu as HTMLElement)\n\n this.activeIndex = index\n } else if (active === menu) {\n if (this.activeIndex === index) {\n /* 메뉴의 update를 유도하기 위해서 강제로 토글시킴 */\n menu.removeAttribute('active')\n await this.updateComplete\n menu.setAttribute('active', '')\n }\n\n this.activeIndex = index\n } else {\n menu.removeAttribute('active')\n }\n })\n }\n\n /**\n * Static method to open a popup menu with the provided template and position options.\n * Creates and returns an instance of OxPopupMenu.\n *\n * @param {PopupOpenOptions}\n */\n static open({\n template,\n top,\n left,\n right,\n bottom,\n parent\n }: {\n template: unknown\n top?: number\n left?: number\n right?: number\n bottom?: number\n parent?: Element | null\n }): OxPopupMenu {\n const owner = parent || document.body\n const target = document.createElement('ox-popup-menu') as OxPopupMenu\n render(template, target)\n\n target.setAttribute('active', '')\n\n target._parent = owner\n\n owner.appendChild(target)\n\n target.open({ top, left, right, bottom })\n\n return target\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ox-popup-menu.js","sourceRoot":"","sources":["../../src/ox-popup-menu.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC,SAAS,YAAY,CAAC,OAAoB;IACxC,yCAAyC;IACzC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAC7B,0EAA0E,CAC5D,CAAA;IAEhB,OAAO,EAAE,KAAK,EAAE,CAAA;IAEhB,OAAO,OAAO,CAAA;AAChB,CAAC;AAED;;GAEG;AAEI,IAAM,WAAW,GAAjB,M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V,QAAQ,EACR,GAAG,EACH,IAAI,EACJ,KAAK,EACL,MAAM,EACN,MAAM,EAQP;QACC,MAAM,KAAK,GAAG,MAAM,IAAI,QAAQ,CAAC,IAAI,CAAA;QACrC,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,eAAe,CAAgB,CAAA;QACrE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;QAExB,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;QAEjC,MAAM,CAAC,OAAO,GAAG,KAAK,CAAA;QAEtB,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;QAEzB,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;QAEzC,OAAO,MAAM,CAAA;IACf,CAAC;;AAlJ2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAwB;AAtExC,WAAW;IADvB,aAAa,CAAC,eAAe,CAAC;GAClB,WAAW,CAyNvB","sourcesContent":["import { css, html, PropertyValues } from 'lit'\nimport { render } from 'lit-html'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { OxPopup } from './ox-popup'\n\nfunction focusClosest(element: HTMLElement) {\n /* Find the closest focusable element. */\n const closest = element.closest(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])'\n ) as HTMLElement\n\n closest?.focus()\n\n return closest\n}\n\n/**\n * Custom element representing a popup menu. It extends OxPopup.\n */\n@customElement('ox-popup-menu')\nexport class OxPopupMenu extends OxPopup {\n static styles = [\n ...OxPopup.styles,\n css`\n :host {\n display: none;\n flex-direction: column;\n align-items: stretch;\n background-color: var(--ox-popup-menu-background-color, var(--md-sys-color-surface));\n z-index: 100;\n box-shadow: 2px 3px 10px 5px rgba(0, 0, 0, 0.15);\n padding: var(--spacing-small) 0;\n border-radius: var(--spacing-small);\n\n color: var(--ox-popup-list-color, var(--md-sys-color-primary-container));\n font-size: var(--md-sys-typescale-label-large-size, 0.875rem);\n }\n\n :host([active]) {\n display: flex;\n }\n\n :host(*:focus) {\n outline: none;\n }\n\n ::slotted(*) {\n padding: var(--spacing-medium);\n border-bottom: 1px solid var(--md-sys-color-surface-variant);\n cursor: pointer;\n color: var(--ox-popup-list-color, var(--md-sys-color-outline-variant));\n }\n\n ::slotted(*:focus) {\n cursor: pointer;\n outline: none;\n }\n\n ::slotted([menu]),\n ::slotted(ox-popup-menuitem) {\n border-left: 3px solid transparent;\n background-color: var(--ox-popup-menu-background-color, var(--md-sys-color-surface));\n color: var(--ox-popup-menu-color, var(--md-sys-color-on-surface));\n }\n\n ::slotted([menu][active]),\n ::slotted([menu]:hover),\n ::slotted(ox-popup-menuitem[active]),\n ::slotted(ox-popup-menuitem:hover) {\n background-color: var(--ox-popup-list-background-color-variant, var(--md-sys-color-primary-container));\n color: var(--ox-popup-list-color-variant, var(--md-sys-color-primary));\n }\n\n ::slotted(ox-popup-menuitem[active]) {\n border-left: 3px solid var(--md-sys-color-primary);\n font-weight: var(--md-sys-typescale-label-large-weight, var(--md-ref-typeface-weight-medium, 500));\n }\n\n ::slotted([separator]) {\n height: 1px;\n width: 100%;\n padding: 0;\n background-color: var(--ox-popup-menu-separator-color, var(--md-sys-color-surface-variant));\n }\n `\n ]\n\n /**\n * Property to track the index of the active menu item.\n */\n @property({ type: Number }) activeIndex: number = 0\n\n render() {\n return html` <slot> </slot> `\n }\n\n protected _onkeydown: (e: KeyboardEvent) => void = function (this: OxPopupMenu, e: KeyboardEvent) {\n e.stopPropagation()\n\n switch (e.key) {\n case 'Esc': // for IE/Edge\n case 'Escape':\n case 'Left': // for IE/Edge\n case 'ArrowLeft':\n this.close()\n break\n\n case 'Up': // for IE/Edge\n case 'ArrowUp':\n this.activeIndex--\n break\n\n case 'Right': // for IE/Edge\n case 'ArrowRight':\n case 'Down': // for IE/Edge\n case 'ArrowDown':\n this.activeIndex++\n break\n\n case 'Enter':\n e.stopPropagation()\n var menu = (e.target as HTMLElement)?.closest('[menu], ox-popup-menuitem')\n if (menu) {\n this.select(menu)\n }\n break\n }\n }.bind(this)\n\n protected _onfocusout: (e: FocusEvent) => void = function (this: OxPopupMenu, e: FocusEvent) {\n const target = e.target as HTMLElement\n const to = e.relatedTarget as HTMLElement\n const from = target.closest('ox-popup-menu')\n\n if (!to && from !== this) {\n e.stopPropagation()\n\n /* \"하위의 POPUP-MENU 엘리먼트가 포커스를 잃었지만, 그 포커스를 받은 엘리먼트가 없다.\"는 의미는 그 서브메뉴가 클로즈된 것을 의미한다. */\n this.setActive(this.activeIndex)\n } else {\n if (!this.contains(to)) {\n /* 분명히 내 범위가 아닌 엘리먼트로 포커스가 옮겨졌다면, popup-menu는 닫혀야 한다. */\n // @ts-ignore for debug\n !window.POPUP_DEBUG && this.close()\n }\n }\n }.bind(this)\n\n protected _onclick: (e: MouseEvent) => void = function (this: OxPopupMenu, e: MouseEvent) {\n e.stopPropagation()\n\n const menu = (e.target as HTMLElement)?.closest('[menu], ox-popup-menuitem')\n if (menu) {\n this.setActive(menu)\n this.select(menu)\n }\n }.bind(this)\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('activeIndex')) {\n this.setActive(this.activeIndex)\n }\n }\n\n /**\n * Selects a menu item by dispatching a 'select' event.\n * Closes the menu if the item doesn't have 'alive-on-select' attribute.\n */\n select(menu: Element) {\n menu.dispatchEvent(new CustomEvent('select'))\n if (!menu.hasAttribute('alive-on-select')) {\n this.dispatchEvent(new CustomEvent('ox-close', { bubbles: true, composed: true, detail: this }))\n }\n }\n\n /**\n * Sets the active menu item based on the index or the menu element itself.\n */\n setActive(active: number | Element | null) {\n const menus = Array.from(this.querySelectorAll(':scope > ox-popup-menuitem, :scope > [menu]'))\n\n menus.map(async (menu, index) => {\n if (typeof active === 'number' && index === (active + menus.length) % menus.length) {\n menu.setAttribute('active', '')\n focusClosest(menu as HTMLElement)\n\n this.activeIndex = index\n } else if (active === menu) {\n if (this.activeIndex === index) {\n /* 메뉴의 update를 유도하기 위해서 강제로 토글시킴 */\n menu.removeAttribute('active')\n await this.updateComplete\n menu.setAttribute('active', '')\n }\n\n this.activeIndex = index\n } else {\n menu.removeAttribute('active')\n }\n })\n }\n\n /**\n * Static method to open a popup menu with the provided template and position options.\n * Creates and returns an instance of OxPopupMenu.\n *\n * @param {PopupOpenOptions}\n */\n static open({\n template,\n top,\n left,\n right,\n bottom,\n parent\n }: {\n template: unknown\n top?: number\n left?: number\n right?: number\n bottom?: number\n parent?: Element | null\n }): OxPopupMenu {\n const owner = parent || document.body\n const target = document.createElement('ox-popup-menu') as OxPopupMenu\n render(template, target)\n\n target.setAttribute('active', '')\n\n target._parent = owner\n\n owner.appendChild(target)\n\n target.open({ top, left, right, bottom })\n\n return target\n }\n}\n"]}
|
|
@@ -51,6 +51,49 @@ let OxPopupMenuItem = class OxPopupMenuItem extends LitElement {
|
|
|
51
51
|
this._submenu = this.querySelector('ox-popup-menu');
|
|
52
52
|
}.bind(this);
|
|
53
53
|
}
|
|
54
|
+
static { this.styles = [
|
|
55
|
+
css `
|
|
56
|
+
:host {
|
|
57
|
+
display: flex;
|
|
58
|
+
flex-direction: row;
|
|
59
|
+
position: relative;
|
|
60
|
+
align-items: center;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
[icon] {
|
|
64
|
+
width: 20px;
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-direction: row;
|
|
67
|
+
padding: 0;
|
|
68
|
+
margin: 0 var(--spacing-small) 0 0;
|
|
69
|
+
align-items: center;
|
|
70
|
+
justify-content: center;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
[icon] > * {
|
|
74
|
+
flex: 1;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
[label] {
|
|
78
|
+
flex: 1;
|
|
79
|
+
text-transform: capitalize;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
::slotted(*[slot='icon']) {
|
|
83
|
+
color: var(--ox-popup-menu-color-variant, var(--md-sys-color-on-surface-variant));
|
|
84
|
+
font-size: var(--icon-size-small);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
md-icon {
|
|
88
|
+
display: block;
|
|
89
|
+
width: 24px;
|
|
90
|
+
text-align: right;
|
|
91
|
+
font-size: var(--icon-size-small);
|
|
92
|
+
color: var(--ox-popup-menu-color-variant, var(--md-sys-color-primary));
|
|
93
|
+
opacity: 0.7;
|
|
94
|
+
}
|
|
95
|
+
`
|
|
96
|
+
]; }
|
|
54
97
|
render() {
|
|
55
98
|
return html `
|
|
56
99
|
<div icon>
|
|
@@ -99,8 +142,7 @@ let OxPopupMenuItem = class OxPopupMenuItem extends LitElement {
|
|
|
99
142
|
* Collapses the submenu, if it exists.
|
|
100
143
|
*/
|
|
101
144
|
collapse() {
|
|
102
|
-
|
|
103
|
-
(_a = this._submenu) === null || _a === void 0 ? void 0 : _a.close();
|
|
145
|
+
this._submenu?.close();
|
|
104
146
|
}
|
|
105
147
|
/**
|
|
106
148
|
* Dispatches a custom 'ox-collapse' event indicating that the menu item should collapse itself.
|
|
@@ -117,49 +159,6 @@ let OxPopupMenuItem = class OxPopupMenuItem extends LitElement {
|
|
|
117
159
|
this.dispatchEvent(new CustomEvent('ox-close', { bubbles: true, composed: true, detail: this }));
|
|
118
160
|
}
|
|
119
161
|
};
|
|
120
|
-
OxPopupMenuItem.styles = [
|
|
121
|
-
css `
|
|
122
|
-
:host {
|
|
123
|
-
display: flex;
|
|
124
|
-
flex-direction: row;
|
|
125
|
-
position: relative;
|
|
126
|
-
align-items: center;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
[icon] {
|
|
130
|
-
width: 20px;
|
|
131
|
-
display: flex;
|
|
132
|
-
flex-direction: row;
|
|
133
|
-
padding: 0;
|
|
134
|
-
margin: 0 var(--spacing-small) 0 0;
|
|
135
|
-
align-items: center;
|
|
136
|
-
justify-content: center;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
[icon] > * {
|
|
140
|
-
flex: 1;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
[label] {
|
|
144
|
-
flex: 1;
|
|
145
|
-
text-transform: capitalize;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
::slotted(*[slot='icon']) {
|
|
149
|
-
color: var(--ox-popup-menu-color-variant, var(--md-sys-color-on-surface-variant));
|
|
150
|
-
font-size: var(--icon-size-small);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
md-icon {
|
|
154
|
-
display: block;
|
|
155
|
-
width: 24px;
|
|
156
|
-
text-align: right;
|
|
157
|
-
font-size: var(--icon-size-small);
|
|
158
|
-
color: var(--ox-popup-menu-color-variant, var(--md-sys-color-primary));
|
|
159
|
-
opacity: 0.7;
|
|
160
|
-
}
|
|
161
|
-
`
|
|
162
|
-
];
|
|
163
162
|
__decorate([
|
|
164
163
|
property({ type: Boolean })
|
|
165
164
|
], OxPopupMenuItem.prototype, "active", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ox-popup-menuitem.js","sourceRoot":"","sources":["../../src/ox-popup-menuitem.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAkB,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAIlE;;;GAGG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,UAAU;IAAxC;;QA6CL;;;WAGG;QAC0B,WAAM,GAAY,KAAK,CAAA;QA4B1C,aAAQ,GAA4B,UAAiC,CAAa;YAC1F,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACnB,OAAM;YACR,CAAC;YAED,CAAC,CAAC,eAAe,EAAE,CAAA;YAEnB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAgB,CAAA;YAC3D,IAAI,MAAM,EAAE,CAAC;gBACX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,GAAG,GAAG,CAAC,CAAA;QACb,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAA;QAC7B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAA;IAC3C,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAA;IACxB,CAAC;IAED;;;OAGG;IACH,YAAY;QACV,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,aAAa,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IACrG,CAAC;IAED;;;OAGG;IACH,KAAK;QACH,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAClG,CAAC;;AA7H4B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;+CAAwB;AAKxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAe;AAEjC;IAAR,KAAK,EAAE;iDAAuB;AAxDpB,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CA+K3B","sourcesContent":["import { css, html, LitElement, PropertyValues } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\n\nimport { OxPopupMenu } from './ox-popup-menu'\n\n/**\n * Custom element representing a menu item within an OxPopup menu.\n * It can contain a label and an optional submenu.\n */\n@customElement('ox-popup-menuitem')\nexport class OxPopupMenuItem extends LitElement {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: row;\n position: relative;\n align-items: center;\n }\n\n [icon] {\n width: 20px;\n display: flex;\n flex-direction: row;\n padding: 0;\n margin: 0 var(--spacing-small) 0 0;\n align-items: center;\n justify-content: center;\n }\n\n [icon] > * {\n flex: 1;\n }\n\n [label] {\n flex: 1;\n text-transform: capitalize;\n }\n\n ::slotted(*[slot='icon']) {\n color: var(--ox-popup-menu-color-variant, var(--md-sys-color-on-surface-variant));\n font-size: var(--icon-size-small);\n }\n\n md-icon {\n display: block;\n width: 24px;\n text-align: right;\n font-size: var(--icon-size-small);\n color: var(--ox-popup-menu-color-variant, var(--md-sys-color-primary));\n opacity: 0.7;\n }\n `\n ]\n\n /**\n * Property indicating whether the menu item is active or not.\n * When active, it may show a submenu.\n */\n @property({ type: Boolean }) active: boolean = false\n\n /**\n * The label to display for the menu item.\n */\n @property({ type: String }) label!: string\n\n @state() _submenu?: OxPopupMenu\n\n render() {\n return html`\n <div icon>\n <slot name=\"icon\"> </slot>\n </div>\n <div label>${this.label}</div>\n\n ${this._submenu ? html`<md-icon>chevron_right</md-icon>` : html``}\n\n <slot @slotchange=${this._onslotchange}> </slot>\n `\n }\n\n firstUpdated() {\n this.setAttribute('tabindex', '0')\n this.addEventListener('keydown', this._onkeydown)\n this.addEventListener('click', this._onclick)\n }\n\n protected _onclick: (e: MouseEvent) => void = function (this: OxPopupMenuItem, e: MouseEvent) {\n if (!this._submenu) {\n return\n }\n\n e.stopPropagation()\n\n const parent = this.closest('ox-popup-menu') as OxPopupMenu\n if (parent) {\n parent.setActive(this)\n }\n\n this.dispatchEvent(new CustomEvent('select'))\n\n requestAnimationFrame(() => {\n this.expand(false)\n })\n }.bind(this)\n\n protected _onkeydown: (e: KeyboardEvent) => void = function (this: OxPopupMenuItem, e: KeyboardEvent) {\n switch (e.key) {\n case 'Right':\n case 'ArrowRight':\n e.stopPropagation()\n this.expand(false)\n break\n\n case 'Left':\n case 'ArrowLeft':\n e.stopPropagation()\n this.collapseSelf()\n break\n\n case 'Enter':\n if (this._submenu) {\n e.stopPropagation()\n this.expand(false)\n }\n break\n }\n }.bind(this)\n\n protected _onslotchange: (e: Event) => void = function (this: OxPopupMenuItem, e: Event) {\n this._submenu = this.querySelector('ox-popup-menu') as OxPopupMenu\n }.bind(this)\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('active')) {\n this.updateActive()\n }\n }\n\n updateActive() {\n if (this.active) {\n this.expand(true)\n } else {\n this.collapse()\n }\n }\n\n /**\n * Expands the submenu, if it exists.\n * The submenu is displayed below and to the right of the menu item.\n *\n * @param {boolean} silent - If true, the submenu is opened silently without user interaction.\n */\n expand(silent: boolean) {\n if (!this._submenu) {\n return\n }\n\n const top = 0\n const left = this.clientWidth\n this._submenu.open({ top, left, silent })\n }\n\n /**\n * Collapses the submenu, if it exists.\n */\n collapse() {\n this._submenu?.close()\n }\n\n /**\n * Dispatches a custom 'ox-collapse' event indicating that the menu item should collapse itself.\n * This event can be used to trigger further interactions or logic in the application.\n */\n collapseSelf() {\n this.dispatchEvent(new CustomEvent('ox-collapse', { bubbles: true, composed: true, detail: this }))\n }\n\n /**\n * Dispatches a custom 'ox-close' event indicating that the menu item should close itself.\n * This event can be used to trigger further interactions or logic in the application.\n */\n close() {\n this.dispatchEvent(new CustomEvent('ox-close', { bubbles: true, composed: true, detail: this }))\n }\n}\n"]}
|
package/dist/src/ox-popup.js
CHANGED
|
@@ -63,6 +63,33 @@ let OxPopup = class OxPopup extends LitElement {
|
|
|
63
63
|
!this.preventCloseOnBlur && !window.POPUP_DEBUG && this.close();
|
|
64
64
|
}.bind(this);
|
|
65
65
|
}
|
|
66
|
+
static { this.styles = [
|
|
67
|
+
ScrollbarStyles,
|
|
68
|
+
css `
|
|
69
|
+
:host {
|
|
70
|
+
position: absolute;
|
|
71
|
+
display: none;
|
|
72
|
+
z-index: 100;
|
|
73
|
+
padding: 0;
|
|
74
|
+
box-shadow: 2px 3px 10px 5px rgba(0, 0, 0, 0.15);
|
|
75
|
+
box-sizing: border-box;
|
|
76
|
+
min-width: fit-content;
|
|
77
|
+
line-height: initial;
|
|
78
|
+
text-align: initial;
|
|
79
|
+
background-color: var(--ox-popup-list-background-color, var(--md-sys-color-surface));
|
|
80
|
+
color: var(--ox-popup-list-color, var(--md-sys-color-primary-container));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
:host([active]) {
|
|
84
|
+
display: flex;
|
|
85
|
+
flex-direction: column;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
:host(*:focus) {
|
|
89
|
+
outline: none;
|
|
90
|
+
}
|
|
91
|
+
`
|
|
92
|
+
]; }
|
|
66
93
|
render() {
|
|
67
94
|
return html `<slot />`;
|
|
68
95
|
}
|
|
@@ -225,33 +252,6 @@ let OxPopup = class OxPopup extends LitElement {
|
|
|
225
252
|
}
|
|
226
253
|
}
|
|
227
254
|
};
|
|
228
|
-
OxPopup.styles = [
|
|
229
|
-
ScrollbarStyles,
|
|
230
|
-
css `
|
|
231
|
-
:host {
|
|
232
|
-
position: absolute;
|
|
233
|
-
display: none;
|
|
234
|
-
z-index: 100;
|
|
235
|
-
padding: 0;
|
|
236
|
-
box-shadow: 2px 3px 10px 5px rgba(0, 0, 0, 0.15);
|
|
237
|
-
box-sizing: border-box;
|
|
238
|
-
min-width: fit-content;
|
|
239
|
-
line-height: initial;
|
|
240
|
-
text-align: initial;
|
|
241
|
-
background-color: var(--ox-popup-list-background-color, var(--md-sys-color-surface));
|
|
242
|
-
color: var(--ox-popup-list-color, var(--md-sys-color-primary-container));
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
:host([active]) {
|
|
246
|
-
display: flex;
|
|
247
|
-
flex-direction: column;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
:host(*:focus) {
|
|
251
|
-
outline: none;
|
|
252
|
-
}
|
|
253
|
-
`
|
|
254
|
-
];
|
|
255
255
|
__decorate([
|
|
256
256
|
property({ type: Boolean, attribute: 'prevent-close-on-blur' })
|
|
257
257
|
], OxPopup.prototype, "preventCloseOnBlur", void 0);
|
package/dist/src/ox-popup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"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AI,CAAC,mBAAmB,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;YACxD,IAAI,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;YAE5D,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;YAC9B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;YAEnB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBACpB,IAAI,CAAC,UAAU,CAAC,KAAK,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAA;YAClD,CAAC;QACH,CAAC;IACH,CAAC;;AAtTM,cAAM,GAAG;IACd,eAAe;IACf,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;KAuBF;CACF,AA1BY,CA0BZ;AAEgE;IAAhE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;mDAAoC;AAE3F;IAAR,KAAK,EAAE;wCAA+B;AA/B5B,OAAO;IADnB,aAAa,CAAC,UAAU,CAAC;GACb,OAAO,CAwTnB","sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { render } from 'lit-html'\nimport { customElement, property, state } from 'lit/decorators.js'\n\nimport { ScrollbarStyles } from '@operato/styles'\n\n/**\n * Custom element class representing the 'ox-popup' component.\n *\n * This component provides the functionality to display a popup with various configuration options.\n * It can be used to show additional information, notifications, or user interactions within a web application.\n *\n * @fires ox-close - Dispatched when the popup is closed.\n * @fires ox-collapse - Dispatched when the popup is collapsed.\n */\n@customElement('ox-popup')\nexport class OxPopup extends LitElement {\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n position: absolute;\n display: none;\n z-index: 100;\n padding: 0;\n box-shadow: 2px 3px 10px 5px rgba(0, 0, 0, 0.15);\n box-sizing: border-box;\n min-width: fit-content;\n line-height: initial;\n text-align: initial;\n background-color: var(--ox-popup-list-background-color, var(--md-sys-color-surface));\n color: var(--ox-popup-list-color, var(--md-sys-color-primary-container));\n }\n\n :host([active]) {\n display: flex;\n flex-direction: column;\n }\n\n :host(*:focus) {\n outline: none;\n }\n `\n ]\n\n @property({ type: Boolean, attribute: 'prevent-close-on-blur' }) preventCloseOnBlur: boolean = false\n\n @state() _parent: Element | null = null\n\n private lastActive: HTMLElement = document.activeElement as HTMLElement\n\n render() {\n return html`<slot />`\n }\n\n protected _onfocusout: (e: FocusEvent) => void = function (this: OxPopup, e: FocusEvent) {\n const to = e.relatedTarget as HTMLElement\n\n if (!this.contains(to)) {\n /* 분명히 내 범위가 아닌 엘리먼트로 포커스가 옮겨졌다면, ox-popup은 닫혀야 한다. */\n // @ts-ignore for preventCloseOnBlur\n !this.preventCloseOnBlur && !window.POPUP_DEBUG && this.close()\n }\n }.bind(this)\n\n protected _onkeydown: (e: KeyboardEvent) => void = function (this: OxPopup, e: KeyboardEvent) {\n e.stopPropagation()\n\n switch (e.key) {\n case 'Esc': // for IE/Edge\n case 'Escape':\n this.close()\n break\n }\n }.bind(this)\n\n protected _onkeyup: (e: KeyboardEvent) => void = function (this: OxPopup, e: KeyboardEvent) {\n e.stopPropagation()\n }.bind(this)\n\n protected _onmouseup: (e: MouseEvent) => void = function (this: OxPopup, e: MouseEvent) {\n e.stopPropagation()\n }.bind(this)\n\n protected _onmousedown: (e: MouseEvent) => void = function (this: OxPopup, e: MouseEvent) {\n e.stopPropagation()\n }.bind(this)\n\n protected _oncontextmenu: (e: Event) => void = function (this: OxPopup, e: Event) {\n e.stopPropagation()\n // this.close()\n }.bind(this)\n\n protected _onclick: (e: MouseEvent) => void = function (this: OxPopup, e: MouseEvent) {\n e.stopPropagation()\n }.bind(this)\n\n protected _onclose: (e: Event) => void = function (this: OxPopup, e: Event) {\n this.close()\n }.bind(this)\n\n protected _oncollapse: (e: Event) => void = function (this: OxPopup, e: Event) {\n e.stopPropagation()\n this.close()\n }.bind(this)\n\n protected _onwindowblur: (e: Event) => void = function (this: OxPopup, e: Event) {\n // @ts-ignore for preventCloseOnBlur\n !this.preventCloseOnBlur && !window.POPUP_DEBUG && this.close()\n }.bind(this)\n\n connectedCallback() {\n super.connectedCallback()\n\n this.addEventListener('focusout', this._onfocusout)\n this.addEventListener('keydown', this._onkeydown)\n this.addEventListener('keyup', this._onkeyup)\n this.addEventListener('click', this._onclick)\n this.addEventListener('mouseup', this._onmouseup)\n this.addEventListener('mousedown', this._onmousedown)\n this.addEventListener('contextmenu', this._oncontextmenu)\n this.addEventListener('ox-close', this._onclose)\n this.addEventListener('ox-collapse', this._oncollapse)\n\n this.setAttribute('tabindex', '0') // make this element focusable\n this.guaranteeFocus()\n }\n\n /**\n * Configuration for opening ox-popup\n *\n * @typedef {Object} PopupOpenOptions\n * @property {HTMLTemplate} template HTMLTemplate to be displayed inside the popup\n * @property {Number} top The position-top where the pop-up will be displayed\n * @property {Number} left The position-left where the pop-up will be displayed\n * @property {HTMLElement} parent Popup's parent element\n */\n static open({\n template,\n top,\n left,\n right,\n bottom,\n width,\n height,\n parent,\n style,\n preventCloseOnBlur\n }: {\n template: unknown\n top?: number\n left?: number\n right?: number\n bottom?: number\n width?: string\n height?: string\n parent?: Element | null\n style?: string\n preventCloseOnBlur?: boolean\n }): OxPopup {\n const owner = parent || document.body\n const target = document.createElement('ox-popup') as OxPopup\n if (preventCloseOnBlur) {\n target.preventCloseOnBlur = preventCloseOnBlur\n }\n if (style) {\n target.style.cssText = style\n }\n\n render(template, target)\n\n target._parent = owner\n owner.appendChild(target)\n\n target.open({ top, left, right, bottom, width, height })\n\n return target\n }\n\n /**\n * Opens the 'ox-popup' with the specified position and dimensions.\n *\n * @param {PopupOpenOptions} options - An object specifying the position and dimensions of the popup.\n * @param {number} options.left - The left position (in pixels) where the popup should be displayed. If not provided, it will be centered horizontally.\n * @param {number} options.top - The top position (in pixels) where the popup should be displayed. If not provided, it will be centered vertically.\n * @param {number} options.right - The right position (in pixels) where the popup should be displayed. If provided, it will override the 'left' value.\n * @param {number} options.bottom - The bottom position (in pixels) where the popup should be displayed. If provided, it will override the 'top' value.\n * @param {string} options.width - The maximum width of the popup (CSS string). For example, '300px'.\n * @param {string} options.height - The maximum height of the popup (CSS string). For example, '200px'.\n * @param {boolean} [options.silent=false] - A flag indicating whether the popup should auto-focus or not. If set to true, the popup won't attempt to focus on any element.\n */\n open({\n left,\n top,\n right,\n bottom,\n width,\n height,\n silent = false\n }: {\n left?: number\n top?: number\n right?: number\n bottom?: number\n width?: string\n height?: string\n silent?: boolean\n }) {\n if (width) {\n this.style.maxWidth = width\n this.style.overflowX = 'auto'\n }\n\n if (height) {\n this.style.maxHeight = height\n this.style.overflowY = 'auto'\n }\n\n if (left === undefined && top === undefined && right === undefined && bottom === undefined) {\n this.style.transform = 'translateX(-50%) translateY(-50%)'\n this.style.left = '50%'\n this.style.top = '50%'\n } else {\n if (left !== undefined) this.style.left = `${left}px`\n if (top !== undefined) this.style.top = `${top}px`\n if (right !== undefined) this.style.right = `${right}px`\n if (bottom !== undefined) this.style.bottom = `${bottom}px`\n }\n\n this.setAttribute('active', '')\n\n // adjust popup position\n requestAnimationFrame(() => {\n const vh = document.body.clientHeight\n const vw = document.body.clientWidth\n\n var bounding = this.getBoundingClientRect()\n\n var h = bounding.height\n var w = bounding.width\n var t = bounding.top\n var l = bounding.left\n\n // If the popup is too large, it will cause overflow scrolling.\n if (vh < h) {\n this.style.height = `${Math.min(Math.max(Math.floor((vh * 2) / 3), vh - (t + 20)), vh)}px`\n this.style.overflow = 'auto'\n h = vh\n }\n\n if (vw < w) {\n this.style.width = `${Math.min(Math.max(Math.floor((vw * 2) / 3), vw - (l + 20)), vw)}px`\n this.style.overflow = 'auto'\n w = vw\n }\n\n // To prevent pop-ups from crossing screen boundaries, use the\n const computedStyle = getComputedStyle(this)\n\n if (t < 0) {\n this.style.top = '10px'\n this.style.bottom = ''\n } else if (vh < t + h) {\n this.style.top = `calc(${computedStyle.top} - ${t + h - vh + 10}px)` // 현재의 top 값에 차감한다.\n this.style.bottom = ''\n // this.style.top = ''\n // this.style.bottom = '10px'\n }\n\n if (l < 0) {\n this.style.left = `calc(${computedStyle.left} - ${l - 10}px)` // 현재의 left 값에 l를 차감한다. (왼쪽으로 이탈했기 때문에 오른쪽으로 가야 화면에 보임)\n // this.style.left = '10px'\n this.style.right = ''\n } else if (vw < l + w) {\n this.style.left = `calc(${computedStyle.left} - ${l + w - vw + 10}px)` // 현재의 left 값에 차감한다.\n this.style.right = ''\n // this.style.left = ''\n // this.style.right = '10px'\n }\n })\n\n // auto focusing\n !silent && this.guaranteeFocus()\n\n /* When the window is out of focus, all pop-ups should disappear. */\n window.addEventListener('blur', this._onwindowblur)\n }\n\n guaranteeFocus(target?: HTMLElement) {\n const focusible = (target || this).querySelector(\n ':scope > button, :scope > [href], :scope > input, :scope > select, :scope > textarea, :scope > [tabindex]:not([tabindex=\"-1\"])'\n )\n\n if (focusible) {\n ;(focusible as HTMLElement).focus()\n } else {\n this.focus()\n }\n }\n\n /**\n * Closes the 'ox-popup'.\n */\n close() {\n this.removeAttribute('active')\n\n window.removeEventListener('blur', this._onwindowblur)\n\n if (this._parent) {\n /* this case is when the popup is opened by OxPopup.open(...) */\n this.removeEventListener('focusout', this._onfocusout)\n this.removeEventListener('keydown', this._onkeydown)\n this.removeEventListener('keyup', this._onkeyup)\n this.removeEventListener('click', this._onclick)\n this.removeEventListener('ox-close', this._onclose)\n this.removeEventListener('ox-collapse', this._oncollapse)\n this.removeEventListener('mouseup', this._onmouseup)\n this.removeEventListener('mousedown', this._onmousedown)\n this.removeEventListener('contextmenu', this._oncontextmenu)\n\n this._parent.removeChild(this)\n this._parent = null\n\n if (this.lastActive) {\n this.lastActive.focus && this.lastActive.focus()\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ox-popup.js","sourceRoot":"","sources":["../../src/ox-popup.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,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AC,YAAY,CAAC,CAAA;YACxD,IAAI,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;YAE5D,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;YAC9B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;YAEnB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBACpB,IAAI,CAAC,UAAU,CAAC,KAAK,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAA;YAClD,CAAC;QACH,CAAC;IACH,CAAC;;AA1RgE;IAAhE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;mDAAoC;AAE3F;IAAR,KAAK,EAAE;wCAA+B;AA/B5B,OAAO;IADnB,aAAa,CAAC,UAAU,CAAC;GACb,OAAO,CAwTnB","sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { render } from 'lit-html'\nimport { customElement, property, state } from 'lit/decorators.js'\n\nimport { ScrollbarStyles } from '@operato/styles'\n\n/**\n * Custom element class representing the 'ox-popup' component.\n *\n * This component provides the functionality to display a popup with various configuration options.\n * It can be used to show additional information, notifications, or user interactions within a web application.\n *\n * @fires ox-close - Dispatched when the popup is closed.\n * @fires ox-collapse - Dispatched when the popup is collapsed.\n */\n@customElement('ox-popup')\nexport class OxPopup extends LitElement {\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n position: absolute;\n display: none;\n z-index: 100;\n padding: 0;\n box-shadow: 2px 3px 10px 5px rgba(0, 0, 0, 0.15);\n box-sizing: border-box;\n min-width: fit-content;\n line-height: initial;\n text-align: initial;\n background-color: var(--ox-popup-list-background-color, var(--md-sys-color-surface));\n color: var(--ox-popup-list-color, var(--md-sys-color-primary-container));\n }\n\n :host([active]) {\n display: flex;\n flex-direction: column;\n }\n\n :host(*:focus) {\n outline: none;\n }\n `\n ]\n\n @property({ type: Boolean, attribute: 'prevent-close-on-blur' }) preventCloseOnBlur: boolean = false\n\n @state() _parent: Element | null = null\n\n private lastActive: HTMLElement = document.activeElement as HTMLElement\n\n render() {\n return html`<slot />`\n }\n\n protected _onfocusout: (e: FocusEvent) => void = function (this: OxPopup, e: FocusEvent) {\n const to = e.relatedTarget as HTMLElement\n\n if (!this.contains(to)) {\n /* 분명히 내 범위가 아닌 엘리먼트로 포커스가 옮겨졌다면, ox-popup은 닫혀야 한다. */\n // @ts-ignore for preventCloseOnBlur\n !this.preventCloseOnBlur && !window.POPUP_DEBUG && this.close()\n }\n }.bind(this)\n\n protected _onkeydown: (e: KeyboardEvent) => void = function (this: OxPopup, e: KeyboardEvent) {\n e.stopPropagation()\n\n switch (e.key) {\n case 'Esc': // for IE/Edge\n case 'Escape':\n this.close()\n break\n }\n }.bind(this)\n\n protected _onkeyup: (e: KeyboardEvent) => void = function (this: OxPopup, e: KeyboardEvent) {\n e.stopPropagation()\n }.bind(this)\n\n protected _onmouseup: (e: MouseEvent) => void = function (this: OxPopup, e: MouseEvent) {\n e.stopPropagation()\n }.bind(this)\n\n protected _onmousedown: (e: MouseEvent) => void = function (this: OxPopup, e: MouseEvent) {\n e.stopPropagation()\n }.bind(this)\n\n protected _oncontextmenu: (e: Event) => void = function (this: OxPopup, e: Event) {\n e.stopPropagation()\n // this.close()\n }.bind(this)\n\n protected _onclick: (e: MouseEvent) => void = function (this: OxPopup, e: MouseEvent) {\n e.stopPropagation()\n }.bind(this)\n\n protected _onclose: (e: Event) => void = function (this: OxPopup, e: Event) {\n this.close()\n }.bind(this)\n\n protected _oncollapse: (e: Event) => void = function (this: OxPopup, e: Event) {\n e.stopPropagation()\n this.close()\n }.bind(this)\n\n protected _onwindowblur: (e: Event) => void = function (this: OxPopup, e: Event) {\n // @ts-ignore for preventCloseOnBlur\n !this.preventCloseOnBlur && !window.POPUP_DEBUG && this.close()\n }.bind(this)\n\n connectedCallback() {\n super.connectedCallback()\n\n this.addEventListener('focusout', this._onfocusout)\n this.addEventListener('keydown', this._onkeydown)\n this.addEventListener('keyup', this._onkeyup)\n this.addEventListener('click', this._onclick)\n this.addEventListener('mouseup', this._onmouseup)\n this.addEventListener('mousedown', this._onmousedown)\n this.addEventListener('contextmenu', this._oncontextmenu)\n this.addEventListener('ox-close', this._onclose)\n this.addEventListener('ox-collapse', this._oncollapse)\n\n this.setAttribute('tabindex', '0') // make this element focusable\n this.guaranteeFocus()\n }\n\n /**\n * Configuration for opening ox-popup\n *\n * @typedef {Object} PopupOpenOptions\n * @property {HTMLTemplate} template HTMLTemplate to be displayed inside the popup\n * @property {Number} top The position-top where the pop-up will be displayed\n * @property {Number} left The position-left where the pop-up will be displayed\n * @property {HTMLElement} parent Popup's parent element\n */\n static open({\n template,\n top,\n left,\n right,\n bottom,\n width,\n height,\n parent,\n style,\n preventCloseOnBlur\n }: {\n template: unknown\n top?: number\n left?: number\n right?: number\n bottom?: number\n width?: string\n height?: string\n parent?: Element | null\n style?: string\n preventCloseOnBlur?: boolean\n }): OxPopup {\n const owner = parent || document.body\n const target = document.createElement('ox-popup') as OxPopup\n if (preventCloseOnBlur) {\n target.preventCloseOnBlur = preventCloseOnBlur\n }\n if (style) {\n target.style.cssText = style\n }\n\n render(template, target)\n\n target._parent = owner\n owner.appendChild(target)\n\n target.open({ top, left, right, bottom, width, height })\n\n return target\n }\n\n /**\n * Opens the 'ox-popup' with the specified position and dimensions.\n *\n * @param {PopupOpenOptions} options - An object specifying the position and dimensions of the popup.\n * @param {number} options.left - The left position (in pixels) where the popup should be displayed. If not provided, it will be centered horizontally.\n * @param {number} options.top - The top position (in pixels) where the popup should be displayed. If not provided, it will be centered vertically.\n * @param {number} options.right - The right position (in pixels) where the popup should be displayed. If provided, it will override the 'left' value.\n * @param {number} options.bottom - The bottom position (in pixels) where the popup should be displayed. If provided, it will override the 'top' value.\n * @param {string} options.width - The maximum width of the popup (CSS string). For example, '300px'.\n * @param {string} options.height - The maximum height of the popup (CSS string). For example, '200px'.\n * @param {boolean} [options.silent=false] - A flag indicating whether the popup should auto-focus or not. If set to true, the popup won't attempt to focus on any element.\n */\n open({\n left,\n top,\n right,\n bottom,\n width,\n height,\n silent = false\n }: {\n left?: number\n top?: number\n right?: number\n bottom?: number\n width?: string\n height?: string\n silent?: boolean\n }) {\n if (width) {\n this.style.maxWidth = width\n this.style.overflowX = 'auto'\n }\n\n if (height) {\n this.style.maxHeight = height\n this.style.overflowY = 'auto'\n }\n\n if (left === undefined && top === undefined && right === undefined && bottom === undefined) {\n this.style.transform = 'translateX(-50%) translateY(-50%)'\n this.style.left = '50%'\n this.style.top = '50%'\n } else {\n if (left !== undefined) this.style.left = `${left}px`\n if (top !== undefined) this.style.top = `${top}px`\n if (right !== undefined) this.style.right = `${right}px`\n if (bottom !== undefined) this.style.bottom = `${bottom}px`\n }\n\n this.setAttribute('active', '')\n\n // adjust popup position\n requestAnimationFrame(() => {\n const vh = document.body.clientHeight\n const vw = document.body.clientWidth\n\n var bounding = this.getBoundingClientRect()\n\n var h = bounding.height\n var w = bounding.width\n var t = bounding.top\n var l = bounding.left\n\n // If the popup is too large, it will cause overflow scrolling.\n if (vh < h) {\n this.style.height = `${Math.min(Math.max(Math.floor((vh * 2) / 3), vh - (t + 20)), vh)}px`\n this.style.overflow = 'auto'\n h = vh\n }\n\n if (vw < w) {\n this.style.width = `${Math.min(Math.max(Math.floor((vw * 2) / 3), vw - (l + 20)), vw)}px`\n this.style.overflow = 'auto'\n w = vw\n }\n\n // To prevent pop-ups from crossing screen boundaries, use the\n const computedStyle = getComputedStyle(this)\n\n if (t < 0) {\n this.style.top = '10px'\n this.style.bottom = ''\n } else if (vh < t + h) {\n this.style.top = `calc(${computedStyle.top} - ${t + h - vh + 10}px)` // 현재의 top 값에 차감한다.\n this.style.bottom = ''\n // this.style.top = ''\n // this.style.bottom = '10px'\n }\n\n if (l < 0) {\n this.style.left = `calc(${computedStyle.left} - ${l - 10}px)` // 현재의 left 값에 l를 차감한다. (왼쪽으로 이탈했기 때문에 오른쪽으로 가야 화면에 보임)\n // this.style.left = '10px'\n this.style.right = ''\n } else if (vw < l + w) {\n this.style.left = `calc(${computedStyle.left} - ${l + w - vw + 10}px)` // 현재의 left 값에 차감한다.\n this.style.right = ''\n // this.style.left = ''\n // this.style.right = '10px'\n }\n })\n\n // auto focusing\n !silent && this.guaranteeFocus()\n\n /* When the window is out of focus, all pop-ups should disappear. */\n window.addEventListener('blur', this._onwindowblur)\n }\n\n guaranteeFocus(target?: HTMLElement) {\n const focusible = (target || this).querySelector(\n ':scope > button, :scope > [href], :scope > input, :scope > select, :scope > textarea, :scope > [tabindex]:not([tabindex=\"-1\"])'\n )\n\n if (focusible) {\n ;(focusible as HTMLElement).focus()\n } else {\n this.focus()\n }\n }\n\n /**\n * Closes the 'ox-popup'.\n */\n close() {\n this.removeAttribute('active')\n\n window.removeEventListener('blur', this._onwindowblur)\n\n if (this._parent) {\n /* this case is when the popup is opened by OxPopup.open(...) */\n this.removeEventListener('focusout', this._onfocusout)\n this.removeEventListener('keydown', this._onkeydown)\n this.removeEventListener('keyup', this._onkeyup)\n this.removeEventListener('click', this._onclick)\n this.removeEventListener('ox-close', this._onclose)\n this.removeEventListener('ox-collapse', this._oncollapse)\n this.removeEventListener('mouseup', this._onmouseup)\n this.removeEventListener('mousedown', this._onmousedown)\n this.removeEventListener('contextmenu', this._oncontextmenu)\n\n this._parent.removeChild(this)\n this._parent = null\n\n if (this.lastActive) {\n this.lastActive.focus && this.lastActive.focus()\n }\n }\n }\n}\n"]}
|