@operato/popup 2.0.0-beta.26 → 2.0.0-beta.31
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/CHANGELOG.md +18 -0
- package/dist/src/ox-popup-list.js +2 -2
- package/dist/src/ox-popup-list.js.map +1 -1
- package/dist/src/ox-popup.d.ts +3 -2
- package/dist/src/ox-popup.js +12 -8
- package/dist/src/ox-popup.js.map +1 -1
- package/dist/src/ox-prompt.d.ts +9 -2
- package/dist/src/ox-prompt.js +16 -6
- package/dist/src/ox-prompt.js.map +1 -1
- package/dist/stories/ox-popup-list-sortable.stories.d.ts +2 -2
- package/dist/stories/ox-popup-list-sortable.stories.js +3 -3
- package/dist/stories/ox-popup-list-sortable.stories.js.map +1 -1
- package/dist/stories/ox-prompt-icon.stories.d.ts +2 -2
- package/dist/stories/ox-prompt-icon.stories.js +12 -8
- package/dist/stories/ox-prompt-icon.stories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/ox-popup-list.ts +2 -2
- package/src/ox-popup.ts +12 -6
- package/src/ox-prompt.ts +15 -5
- package/stories/ox-popup-list-sortable.stories.ts +4 -4
- package/stories/ox-prompt-icon.stories.ts +13 -10
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.0.0-beta.31](https://github.com/hatiolab/operato/compare/v2.0.0-beta.30...v2.0.0-beta.31) (2024-06-19)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### :bug: Bug Fix
|
|
10
|
+
|
|
11
|
+
* record-view button style ([83ec982](https://github.com/hatiolab/operato/commit/83ec9821f551173233d5c37d83de2e1cb699a370))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [2.0.0-beta.30](https://github.com/hatiolab/operato/compare/v2.0.0-beta.29...v2.0.0-beta.30) (2024-06-18)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### :bug: Bug Fix
|
|
19
|
+
|
|
20
|
+
* ox-prompt button ([3121f69](https://github.com/hatiolab/operato/commit/3121f698b46581ef7e78bd356ad884b387649a3b))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
6
24
|
## [2.0.0-beta.26](https://github.com/hatiolab/operato/compare/v2.0.0-beta.25...v2.0.0-beta.26) (2024-06-18)
|
|
7
25
|
|
|
8
26
|
|
|
@@ -68,7 +68,7 @@ let OxPopupList = class OxPopupList extends OxPopup {
|
|
|
68
68
|
if (!this.contains(to)) {
|
|
69
69
|
/* If the focus has clearly moved to an element outside of my range, the ox-popup-list should be closed. */
|
|
70
70
|
// @ts-ignore for debug
|
|
71
|
-
!this.debug && !window.POPUP_DEBUG && this.close();
|
|
71
|
+
!this.preventCloseOnBlur && !this.debug && !window.POPUP_DEBUG && this.close();
|
|
72
72
|
}
|
|
73
73
|
}.bind(this);
|
|
74
74
|
this._onclick = function (e) {
|
|
@@ -342,7 +342,7 @@ OxPopupList.styles = [
|
|
|
342
342
|
z-index: 100;
|
|
343
343
|
box-shadow: 2px 3px 10px 5px rgba(0, 0, 0, 0.15);
|
|
344
344
|
padding: var(--spacing-small) 0;
|
|
345
|
-
border-radius:var(--md-sys-shape-corner-small, 5px);
|
|
345
|
+
border-radius: var(--md-sys-shape-corner-small, 5px);
|
|
346
346
|
|
|
347
347
|
color: var(--ox-popup-list-color, var(--md-sys-color-primary-container));
|
|
348
348
|
font-size: var(--md-sys-typescale-label-large-size, 0.875rem);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ox-popup-list.js","sourceRoot":"","sources":["../../src/ox-popup-list.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AAEnC,OAAO,EAAE,GAAG,EAAa,IAAI,EAAkB,MAAM,KAAK,CAAA;AAC1D,OAAO,EAAE,MAA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AW;IADvB,aAAa,CAAC,eAAe,CAAC;GAClB,WAAW,CA4hBvB","sourcesContent":["import '@material/web/icon/icon.js'\n\nimport { css, CSSResult, html, PropertyValues } from 'lit'\nimport { render } from 'lit-html'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport Sortable from 'sortablejs'\n\nimport { OxPopup } from './ox-popup'\n\nfunction guaranteeFocus(element: HTMLElement) {\n // 1. Give focus opportunity to the first focusable element within the option element.\n const focusible = element.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])')\n\n if (focusible) {\n ;(focusible as HTMLElement).focus()\n return\n }\n\n // 2. Give focus opportunity to the closest parent, including itself.\n const closest = element.closest(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])'\n ) as HTMLElement\n\n closest?.focus()\n}\n\n/**\n * A custom element representing a list-like popup menu.\n */\n@customElement('ox-popup-list')\nexport class OxPopupList extends OxPopup {\n static styles = [\n ...OxPopup.styles,\n css`\n :host {\n display: none;\n align-items: stretch;\n background-color: var(--ox-popup-list-background-color, var(--md-sys-color-surface-container-lowest));\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(--md-sys-shape-corner-small, 5px);\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 font:\n normal 14px 'Roboto',\n sans-serif;\n }\n\n :host([active]) {\n display: flex;\n flex-direction: column;\n }\n\n :host(*:focus) {\n outline: none;\n }\n\n :host([nowrap]) ::slotted([option]) {\n white-space: nowrap;\n }\n\n ::slotted([option]) {\n border-left: 3px solid transparent;\n }\n\n ::slotted(*) {\n padding: var(--spacing-medium);\n border-bottom: 1px solid var(--md-sys-color-surface-variant);\n cursor: pointer;\n outline: none;\n color: var(--ox-popup-list-color, var(--md-sys-color-on-surface-variant));\n }\n\n ::slotted(*:focus) {\n outline: none;\n }\n\n ::slotted([option][active]),\n ::slotted([option]: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([option][selected]) {\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 ::slotted([hidden]) {\n display: none;\n }\n\n [search] {\n display: flex;\n position: relative;\n align-items: center;\n padding: var(--spacing-small) var(--spacing-medium);\n\n --md-icon-size: var(--icon-size-small);\n }\n\n [search] [type='text'] {\n flex: 1;\n background-color: transparent;\n border: 0;\n padding: 0 0 0 var(--spacing-huge);\n outline: none;\n width: 50px;\n }\n\n [search] md-icon {\n color: var(--md-sys-color-secondary);\n }\n\n [search] md-icon[search-icon] {\n position: absolute;\n }\n\n [search] md-icon[delete-icon] {\n opacity: 0.5;\n --md-icon-size: var(--icon-size-tiny);\n }\n\n [nothing] {\n opacity: 0.5;\n text-align: center;\n }\n\n div[body] {\n flex: 1;\n display: flex;\n flex-direction: column;\n margin: 0;\n padding: 0;\n overflow: auto;\n }\n `\n ]\n\n /**\n * A boolean property that, when set to true, allows multiple options to be selected in the popup list.\n * @type {boolean}\n */\n @property({ type: Boolean, attribute: true, reflect: true }) multiple: boolean = false\n\n /**\n * An optional attribute that specifies the name of the attribute used to mark selected options in the list.\n * @type {string|undefined}\n */\n @property({ type: String, attribute: 'attr-selected', reflect: true }) attrSelected?: string\n\n /**\n * A boolean property that, when set to true, enables the search functionality in the popup list.\n * Users can search/filter options by typing in a search bar.\n * @type {boolean|undefined}\n */\n @property({ type: Boolean, attribute: 'with-search', reflect: true }) withSearch?: boolean\n\n /**\n * A boolean property that, when set to true, enables the drag-and-drop sorting functionality within the popup list.\n * This allows users to reorder the options in the list by dragging them into new positions.\n * @type {boolean|undefined}\n */\n @property({ type: Boolean, attribute: 'sortable', reflect: true }) sortable?: boolean = false\n\n /**\n * The value(s) of the selected option(s) in the popup list.\n * This property can be a string or an array of strings, depending on whether multiple selections are allowed.\n * @type {string|string[]|undefined}\n */\n @property({ type: String }) value?: string | string[]\n\n @state() activeIndex?: number\n @state() searchKeyword?: string\n @state() nothingToSelect: boolean = false\n\n @query('[search] input') searchInput!: HTMLInputElement\n @query('div[body]') body!: HTMLDivElement\n\n private sortableObject?: Sortable\n private locked: boolean = false\n\n render() {\n return html`\n <slot name=\"header\"> </slot>\n\n ${this.withSearch\n ? html`\n <label search for=\"search\" @input=${(e: InputEvent) => this._oninputsearch(e)}>\n <md-icon search-icon>search</md-icon>\n <input\n id=\"search\"\n type=\"text\"\n autocomplete=\"off\"\n @keydown=${(e: KeyboardEvent) => this._onkeydownsearch(e)}\n @change=${(e: InputEvent) => this._onchangesearch(e)}\n />\n <md-icon\n @click=${() => {\n this.searchInput.value = ''\n this.searchKeyword = ''\n }}\n delete-icon\n >delete</md-icon\n >\n </label>\n `\n : html``}\n\n <div body>\n <slot\n @change=${(e: Event) => {\n e.stopPropagation()\n }}\n >\n </slot>\n </div>\n\n ${this.nothingToSelect ? html`<label nothing>nothing to select</label>` : html``}\n `\n }\n\n protected _oninputsearch(e: InputEvent) {\n e.stopPropagation()\n e.preventDefault()\n\n this.searchKeyword = (e.target as HTMLInputElement).value\n }\n\n protected _onchangesearch(e: InputEvent) {\n e.stopPropagation()\n this.searchKeyword = (e.target as HTMLInputElement).value\n }\n\n protected _onkeydownsearch(e: KeyboardEvent) {\n const keys = ['Esc', 'Escape', 'Up', 'ArrowUp', 'Down', 'ArrowDown']\n if (!keys.includes(e.key)) {\n e.stopPropagation()\n }\n }\n\n protected _onkeydown: (e: KeyboardEvent) => void = function (this: OxPopupList, 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 case 'Left': // for IE/Edge\n case 'ArrowLeft':\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 case ' ':\n case 'Spacebar': // for old firefox\n this.setActive(this.activeIndex!, true)\n this.select()\n break\n }\n }.bind(this)\n\n protected _onfocusout: (e: FocusEvent) => void = function (this: OxPopupList, e: FocusEvent) {\n const to = e.relatedTarget as HTMLElement\n\n if (!this.contains(to)) {\n /* If the focus has clearly moved to an element outside of my range, the ox-popup-list should be closed. */\n // @ts-ignore for debug\n !this.debug && !window.POPUP_DEBUG && this.close()\n }\n }.bind(this)\n\n protected _onclick: (e: MouseEvent) => void = function (this: OxPopupList, e: MouseEvent) {\n e.stopPropagation()\n\n // Check if the click event target is a checkbox\n if ((e.target as HTMLElement).closest('input[type=\"checkbox\"]')) {\n return // Do not proceed if it's a checkbox click\n }\n\n const option = (e.target as HTMLElement)?.closest('[option]')\n if (option) {\n this.setActive(option, true)\n this.select()\n }\n }.bind(this)\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('activeIndex')) {\n this.activeIndex !== undefined && this.setActive(this.activeIndex)\n }\n\n if (changes.has('sortable')) {\n this.sortableObject && this.sortableObject.destroy()\n\n if (this.sortable) {\n this.sortableObject = Sortable.create(this, {\n handle: '[option]',\n draggable: '[option]',\n direction: 'vertical',\n animation: 150,\n touchStartThreshold: 10,\n onEnd: e => {\n this.locked = false\n this.dispatchEvent(\n new CustomEvent('sorted', {\n detail: Array.from(this.querySelectorAll('[option]'))\n })\n )\n },\n onMove: e => {\n // Check if the drag event target is a checkbox\n if ((e.dragged as HTMLElement).querySelector('input[type=\"checkbox\"]')) {\n return false // Prevent sorting if it's a checkbox drag\n }\n this.locked = true\n }\n })\n }\n }\n\n if (changes.has('searchKeyword')) {\n const attrSelected = this.attrSelected || 'selected'\n this.querySelectorAll(`[option]`).forEach(item => {\n if (!this.searchKeyword || item.textContent?.match(new RegExp(this.searchKeyword, 'i'))) {\n item.removeAttribute('hidden')\n } else {\n item.removeAttribute('selected')\n item.setAttribute('hidden', '')\n }\n })\n this.nothingToSelect = this.querySelectorAll(`[option]:not([hidden])`).length === 0\n }\n\n if (changes.has('value')) {\n const options = Array.from(this.querySelectorAll(':scope > [option]'))\n\n var values = this.value\n if (!(values instanceof Array)) {\n values = [values as string]\n }\n\n options.forEach(option => {\n if (values?.includes((option as HTMLElement).getAttribute('value') || '')) {\n option.setAttribute(this.attrSelected || 'selected', '')\n } else {\n option.removeAttribute(this.attrSelected || 'selected')\n }\n })\n }\n }\n\n /**\n * Retrieves the labels of the selected options in the popup list.\n * If multiple selections are allowed, an array of labels is returned. Otherwise, a single label is returned.\n * @returns {string|string[]} The label(s) of the selected option(s).\n */\n public getSelectedLabels(): string | string[] {\n const options = Array.from(this.querySelectorAll(':scope > [option]'))\n\n const selected = options\n .filter(option => option.hasAttribute('value') && option.hasAttribute(this.attrSelected || 'selected'))\n .map(option => option.textContent || '')\n\n return this.multiple ? selected : selected[0]\n }\n\n /**\n * Handles the selection of options in the popup list and dispatches a 'select' event with the selected value(s).\n * If multiple selections are allowed, an array of selected values is dispatched; otherwise, a single value is dispatched.\n * Also, it checks whether the selected option should remain alive and whether the popup should be closed.\n */\n async select() {\n await this.updateComplete\n\n const options = Array.from(this.querySelectorAll(':scope > [option]'))\n\n const selected = options\n .filter(option => option.hasAttribute('value') && option.hasAttribute(this.attrSelected || 'selected'))\n .map(option => option.getAttribute('value'))\n\n this.dispatchEvent(\n new CustomEvent('select', {\n bubbles: true,\n composed: true,\n detail: this.multiple ? selected : selected[0]\n })\n )\n\n const option = options[this.activeIndex!]\n if (!option.hasAttribute('alive-on-select') && !this.hasAttribute('multiple')) {\n this.close()\n }\n }\n\n /**\n * Sets the active option within the popup list based on the given index or Element.\n * If 'withSelect' is true, it also manages the selection state of the option.\n *\n * @param {number | Element | null} active - The index or Element of the option to set as active.\n * @param {boolean | undefined} withSelect - Indicates whether to manage the selection state of the option.\n */\n setActive(active: number | Element | null, withSelect?: boolean) {\n var options = Array.from(this.querySelectorAll('[option]:not([hidden])'))\n if (this.withSearch) {\n options.push(this.renderRoot.querySelector('[search]')!)\n }\n\n if (active instanceof Element) {\n const index = options.findIndex(option => option === active)\n this.setActive(index === -1 ? 0 : index, withSelect)\n return\n }\n\n const attrSelected = this.attrSelected || 'selected'\n\n options.forEach(async (option, index) => {\n if (typeof active === 'number' && index === (active + options.length) % options.length) {\n option.setAttribute('active', '')\n\n if (withSelect && !this.attrSelected) {\n /* being set attribute attrs-selected means, that element should know how to do when event happened. */\n this.multiple ? option.toggleAttribute('selected') : option.setAttribute('selected', '')\n }\n\n guaranteeFocus(option as HTMLElement)\n\n this.activeIndex = index\n } else {\n option.removeAttribute('active')\n /* even thought attribute attrs-selected set, ox-popup-list have to unset others. */\n !this.multiple && withSelect && option.removeAttribute(attrSelected)\n }\n })\n }\n\n /**\n * Overrides the 'open' method of the base class 'OxPopup' to set the initial active index\n * when the popup list is opened. It ensures that an option is initially selected for user interaction.\n *\n * @param {object} params - The parameters for opening the popup, including position and size.\n */\n override open(params: {\n left?: number\n top?: number\n right?: number\n bottom?: number\n width?: string\n height?: string\n silent?: boolean\n }) {\n super.open(params)\n\n if (this.activeIndex === undefined) {\n const activeElement = this.querySelector(`[${this.attrSelected || 'selected'}]`)\n this.setActive(activeElement || 0)\n } else {\n this.setActive(this.activeIndex)\n }\n }\n\n /**\n * Overrides the 'close' method of the base class 'OxPopup' to dispatch a custom event\n * indicating that the popup list is being closed. This event can be used for further interactions\n * or logic in the application.\n */\n override close() {\n if (this.locked) {\n return\n }\n\n if (this.hasAttribute('active')) {\n this.dispatchEvent(\n new CustomEvent('close', {\n bubbles: true,\n composed: true\n })\n )\n }\n\n super.close()\n }\n\n /**\n * Open OxPopup\n *\n * @param {PopupOpenOptions}\n */\n static open({\n template,\n top,\n left,\n right,\n bottom,\n parent,\n multiple,\n sortable,\n attrSelected,\n styles,\n debug\n }: {\n template: unknown\n top?: number\n left?: number\n right?: number\n bottom?: number\n parent?: Element | null\n multiple?: boolean\n sortable?: boolean\n debug?: boolean\n attrSelected?: string\n styles: CSSResult\n }): OxPopupList {\n const owner = parent || document.body\n const target = document.createElement('ox-popup-list') as OxPopupList\n\n if (styles) {\n const style = document.createElement('style')\n style.textContent = styles.cssText\n\n const shadow = target.attachShadow({ mode: 'open' })\n shadow.appendChild(style)\n }\n\n if (!!debug) {\n target.setAttribute('debug', '')\n }\n\n if (!!multiple) {\n target.setAttribute('multiple', '')\n }\n\n if (!!sortable) {\n target.setAttribute('sortable', '')\n }\n\n if (attrSelected) {\n target.setAttribute('attr-selected', attrSelected)\n }\n\n render(template, target)\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-list.js","sourceRoot":"","sources":["../../src/ox-popup-list.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AAEnC,OAAO,EAAE,GAAG,EAAa,IAAI,EAAkB,MAAM,KAAK,CAAA;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,QAAQ,MAAM,YAAY,CAAA;AAEjC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC,SAAS,cAAc,CAAC,OAAoB;IAC1C,sFAAsF;IACtF,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,0EAA0E,CAAC,CAAA;IAEnH,IAAI,SAAS,EAAE,CAAC;QACd,CAAC;QAAC,SAAyB,CAAC,KAAK,EAAE,CAAA;QACnC,OAAM;IACR,CAAC;IAED,qEAAqE;IACrE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAC7B,0EAA0E,CAC5D,C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,CAmHZ;AAM4D;IAA5D,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CAA0B;AAMf;IAAtE,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iDAAsB;AAOtB;IAArE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;+CAAqB;AAOvB;IAAlE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CAA2B;AAOjE;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAA0B;AAE5C;IAAR,KAAK,EAAE;gDAAqB;AACpB;IAAR,KAAK,EAAE;kDAAuB;AACtB;IAAR,KAAK,EAAE;oDAAiC;AAEhB;IAAxB,KAAK,CAAC,gBAAgB,CAAC;gDAA+B;AACnC;IAAnB,KAAK,CAAC,WAAW,CAAC;yCAAsB;AA5J9B,WAAW;IADvB,aAAa,CAAC,eAAe,CAAC;GAClB,WAAW,CA4hBvB","sourcesContent":["import '@material/web/icon/icon.js'\n\nimport { css, CSSResult, html, PropertyValues } from 'lit'\nimport { render } from 'lit-html'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport Sortable from 'sortablejs'\n\nimport { OxPopup } from './ox-popup'\n\nfunction guaranteeFocus(element: HTMLElement) {\n // 1. Give focus opportunity to the first focusable element within the option element.\n const focusible = element.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])')\n\n if (focusible) {\n ;(focusible as HTMLElement).focus()\n return\n }\n\n // 2. Give focus opportunity to the closest parent, including itself.\n const closest = element.closest(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])'\n ) as HTMLElement\n\n closest?.focus()\n}\n\n/**\n * A custom element representing a list-like popup menu.\n */\n@customElement('ox-popup-list')\nexport class OxPopupList extends OxPopup {\n static styles = [\n ...OxPopup.styles,\n css`\n :host {\n display: none;\n align-items: stretch;\n background-color: var(--ox-popup-list-background-color, var(--md-sys-color-surface-container-lowest));\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(--md-sys-shape-corner-small, 5px);\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 font:\n normal 14px 'Roboto',\n sans-serif;\n }\n\n :host([active]) {\n display: flex;\n flex-direction: column;\n }\n\n :host(*:focus) {\n outline: none;\n }\n\n :host([nowrap]) ::slotted([option]) {\n white-space: nowrap;\n }\n\n ::slotted([option]) {\n border-left: 3px solid transparent;\n }\n\n ::slotted(*) {\n padding: var(--spacing-medium);\n border-bottom: 1px solid var(--md-sys-color-surface-variant);\n cursor: pointer;\n outline: none;\n color: var(--ox-popup-list-color, var(--md-sys-color-on-surface-variant));\n }\n\n ::slotted(*:focus) {\n outline: none;\n }\n\n ::slotted([option][active]),\n ::slotted([option]: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([option][selected]) {\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 ::slotted([hidden]) {\n display: none;\n }\n\n [search] {\n display: flex;\n position: relative;\n align-items: center;\n padding: var(--spacing-small) var(--spacing-medium);\n\n --md-icon-size: var(--icon-size-small);\n }\n\n [search] [type='text'] {\n flex: 1;\n background-color: transparent;\n border: 0;\n padding: 0 0 0 var(--spacing-huge);\n outline: none;\n width: 50px;\n }\n\n [search] md-icon {\n color: var(--md-sys-color-secondary);\n }\n\n [search] md-icon[search-icon] {\n position: absolute;\n }\n\n [search] md-icon[delete-icon] {\n opacity: 0.5;\n --md-icon-size: var(--icon-size-tiny);\n }\n\n [nothing] {\n opacity: 0.5;\n text-align: center;\n }\n\n div[body] {\n flex: 1;\n display: flex;\n flex-direction: column;\n margin: 0;\n padding: 0;\n overflow: auto;\n }\n `\n ]\n\n /**\n * A boolean property that, when set to true, allows multiple options to be selected in the popup list.\n * @type {boolean}\n */\n @property({ type: Boolean, attribute: true, reflect: true }) multiple: boolean = false\n\n /**\n * An optional attribute that specifies the name of the attribute used to mark selected options in the list.\n * @type {string|undefined}\n */\n @property({ type: String, attribute: 'attr-selected', reflect: true }) attrSelected?: string\n\n /**\n * A boolean property that, when set to true, enables the search functionality in the popup list.\n * Users can search/filter options by typing in a search bar.\n * @type {boolean|undefined}\n */\n @property({ type: Boolean, attribute: 'with-search', reflect: true }) withSearch?: boolean\n\n /**\n * A boolean property that, when set to true, enables the drag-and-drop sorting functionality within the popup list.\n * This allows users to reorder the options in the list by dragging them into new positions.\n * @type {boolean|undefined}\n */\n @property({ type: Boolean, attribute: 'sortable', reflect: true }) sortable?: boolean = false\n\n /**\n * The value(s) of the selected option(s) in the popup list.\n * This property can be a string or an array of strings, depending on whether multiple selections are allowed.\n * @type {string|string[]|undefined}\n */\n @property({ type: String }) value?: string | string[]\n\n @state() activeIndex?: number\n @state() searchKeyword?: string\n @state() nothingToSelect: boolean = false\n\n @query('[search] input') searchInput!: HTMLInputElement\n @query('div[body]') body!: HTMLDivElement\n\n private sortableObject?: Sortable\n private locked: boolean = false\n\n render() {\n return html`\n <slot name=\"header\"> </slot>\n\n ${this.withSearch\n ? html`\n <label search for=\"search\" @input=${(e: InputEvent) => this._oninputsearch(e)}>\n <md-icon search-icon>search</md-icon>\n <input\n id=\"search\"\n type=\"text\"\n autocomplete=\"off\"\n @keydown=${(e: KeyboardEvent) => this._onkeydownsearch(e)}\n @change=${(e: InputEvent) => this._onchangesearch(e)}\n />\n <md-icon\n @click=${() => {\n this.searchInput.value = ''\n this.searchKeyword = ''\n }}\n delete-icon\n >delete</md-icon\n >\n </label>\n `\n : html``}\n\n <div body>\n <slot\n @change=${(e: Event) => {\n e.stopPropagation()\n }}\n >\n </slot>\n </div>\n\n ${this.nothingToSelect ? html`<label nothing>nothing to select</label>` : html``}\n `\n }\n\n protected _oninputsearch(e: InputEvent) {\n e.stopPropagation()\n e.preventDefault()\n\n this.searchKeyword = (e.target as HTMLInputElement).value\n }\n\n protected _onchangesearch(e: InputEvent) {\n e.stopPropagation()\n this.searchKeyword = (e.target as HTMLInputElement).value\n }\n\n protected _onkeydownsearch(e: KeyboardEvent) {\n const keys = ['Esc', 'Escape', 'Up', 'ArrowUp', 'Down', 'ArrowDown']\n if (!keys.includes(e.key)) {\n e.stopPropagation()\n }\n }\n\n protected _onkeydown: (e: KeyboardEvent) => void = function (this: OxPopupList, 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 case 'Left': // for IE/Edge\n case 'ArrowLeft':\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 case ' ':\n case 'Spacebar': // for old firefox\n this.setActive(this.activeIndex!, true)\n this.select()\n break\n }\n }.bind(this)\n\n protected _onfocusout: (e: FocusEvent) => void = function (this: OxPopupList, e: FocusEvent) {\n const to = e.relatedTarget as HTMLElement\n\n if (!this.contains(to)) {\n /* If the focus has clearly moved to an element outside of my range, the ox-popup-list should be closed. */\n // @ts-ignore for debug\n !this.preventCloseOnBlur && !this.debug && !window.POPUP_DEBUG && this.close()\n }\n }.bind(this)\n\n protected _onclick: (e: MouseEvent) => void = function (this: OxPopupList, e: MouseEvent) {\n e.stopPropagation()\n\n // Check if the click event target is a checkbox\n if ((e.target as HTMLElement).closest('input[type=\"checkbox\"]')) {\n return // Do not proceed if it's a checkbox click\n }\n\n const option = (e.target as HTMLElement)?.closest('[option]')\n if (option) {\n this.setActive(option, true)\n this.select()\n }\n }.bind(this)\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('activeIndex')) {\n this.activeIndex !== undefined && this.setActive(this.activeIndex)\n }\n\n if (changes.has('sortable')) {\n this.sortableObject && this.sortableObject.destroy()\n\n if (this.sortable) {\n this.sortableObject = Sortable.create(this, {\n handle: '[option]',\n draggable: '[option]',\n direction: 'vertical',\n animation: 150,\n touchStartThreshold: 10,\n onEnd: e => {\n this.locked = false\n this.dispatchEvent(\n new CustomEvent('sorted', {\n detail: Array.from(this.querySelectorAll('[option]'))\n })\n )\n },\n onMove: e => {\n // Check if the drag event target is a checkbox\n if ((e.dragged as HTMLElement).querySelector('input[type=\"checkbox\"]')) {\n return false // Prevent sorting if it's a checkbox drag\n }\n this.locked = true\n }\n })\n }\n }\n\n if (changes.has('searchKeyword')) {\n const attrSelected = this.attrSelected || 'selected'\n this.querySelectorAll(`[option]`).forEach(item => {\n if (!this.searchKeyword || item.textContent?.match(new RegExp(this.searchKeyword, 'i'))) {\n item.removeAttribute('hidden')\n } else {\n item.removeAttribute('selected')\n item.setAttribute('hidden', '')\n }\n })\n this.nothingToSelect = this.querySelectorAll(`[option]:not([hidden])`).length === 0\n }\n\n if (changes.has('value')) {\n const options = Array.from(this.querySelectorAll(':scope > [option]'))\n\n var values = this.value\n if (!(values instanceof Array)) {\n values = [values as string]\n }\n\n options.forEach(option => {\n if (values?.includes((option as HTMLElement).getAttribute('value') || '')) {\n option.setAttribute(this.attrSelected || 'selected', '')\n } else {\n option.removeAttribute(this.attrSelected || 'selected')\n }\n })\n }\n }\n\n /**\n * Retrieves the labels of the selected options in the popup list.\n * If multiple selections are allowed, an array of labels is returned. Otherwise, a single label is returned.\n * @returns {string|string[]} The label(s) of the selected option(s).\n */\n public getSelectedLabels(): string | string[] {\n const options = Array.from(this.querySelectorAll(':scope > [option]'))\n\n const selected = options\n .filter(option => option.hasAttribute('value') && option.hasAttribute(this.attrSelected || 'selected'))\n .map(option => option.textContent || '')\n\n return this.multiple ? selected : selected[0]\n }\n\n /**\n * Handles the selection of options in the popup list and dispatches a 'select' event with the selected value(s).\n * If multiple selections are allowed, an array of selected values is dispatched; otherwise, a single value is dispatched.\n * Also, it checks whether the selected option should remain alive and whether the popup should be closed.\n */\n async select() {\n await this.updateComplete\n\n const options = Array.from(this.querySelectorAll(':scope > [option]'))\n\n const selected = options\n .filter(option => option.hasAttribute('value') && option.hasAttribute(this.attrSelected || 'selected'))\n .map(option => option.getAttribute('value'))\n\n this.dispatchEvent(\n new CustomEvent('select', {\n bubbles: true,\n composed: true,\n detail: this.multiple ? selected : selected[0]\n })\n )\n\n const option = options[this.activeIndex!]\n if (!option.hasAttribute('alive-on-select') && !this.hasAttribute('multiple')) {\n this.close()\n }\n }\n\n /**\n * Sets the active option within the popup list based on the given index or Element.\n * If 'withSelect' is true, it also manages the selection state of the option.\n *\n * @param {number | Element | null} active - The index or Element of the option to set as active.\n * @param {boolean | undefined} withSelect - Indicates whether to manage the selection state of the option.\n */\n setActive(active: number | Element | null, withSelect?: boolean) {\n var options = Array.from(this.querySelectorAll('[option]:not([hidden])'))\n if (this.withSearch) {\n options.push(this.renderRoot.querySelector('[search]')!)\n }\n\n if (active instanceof Element) {\n const index = options.findIndex(option => option === active)\n this.setActive(index === -1 ? 0 : index, withSelect)\n return\n }\n\n const attrSelected = this.attrSelected || 'selected'\n\n options.forEach(async (option, index) => {\n if (typeof active === 'number' && index === (active + options.length) % options.length) {\n option.setAttribute('active', '')\n\n if (withSelect && !this.attrSelected) {\n /* being set attribute attrs-selected means, that element should know how to do when event happened. */\n this.multiple ? option.toggleAttribute('selected') : option.setAttribute('selected', '')\n }\n\n guaranteeFocus(option as HTMLElement)\n\n this.activeIndex = index\n } else {\n option.removeAttribute('active')\n /* even thought attribute attrs-selected set, ox-popup-list have to unset others. */\n !this.multiple && withSelect && option.removeAttribute(attrSelected)\n }\n })\n }\n\n /**\n * Overrides the 'open' method of the base class 'OxPopup' to set the initial active index\n * when the popup list is opened. It ensures that an option is initially selected for user interaction.\n *\n * @param {object} params - The parameters for opening the popup, including position and size.\n */\n override open(params: {\n left?: number\n top?: number\n right?: number\n bottom?: number\n width?: string\n height?: string\n silent?: boolean\n }) {\n super.open(params)\n\n if (this.activeIndex === undefined) {\n const activeElement = this.querySelector(`[${this.attrSelected || 'selected'}]`)\n this.setActive(activeElement || 0)\n } else {\n this.setActive(this.activeIndex)\n }\n }\n\n /**\n * Overrides the 'close' method of the base class 'OxPopup' to dispatch a custom event\n * indicating that the popup list is being closed. This event can be used for further interactions\n * or logic in the application.\n */\n override close() {\n if (this.locked) {\n return\n }\n\n if (this.hasAttribute('active')) {\n this.dispatchEvent(\n new CustomEvent('close', {\n bubbles: true,\n composed: true\n })\n )\n }\n\n super.close()\n }\n\n /**\n * Open OxPopup\n *\n * @param {PopupOpenOptions}\n */\n static open({\n template,\n top,\n left,\n right,\n bottom,\n parent,\n multiple,\n sortable,\n attrSelected,\n styles,\n debug\n }: {\n template: unknown\n top?: number\n left?: number\n right?: number\n bottom?: number\n parent?: Element | null\n multiple?: boolean\n sortable?: boolean\n debug?: boolean\n attrSelected?: string\n styles: CSSResult\n }): OxPopupList {\n const owner = parent || document.body\n const target = document.createElement('ox-popup-list') as OxPopupList\n\n if (styles) {\n const style = document.createElement('style')\n style.textContent = styles.cssText\n\n const shadow = target.attachShadow({ mode: 'open' })\n shadow.appendChild(style)\n }\n\n if (!!debug) {\n target.setAttribute('debug', '')\n }\n\n if (!!multiple) {\n target.setAttribute('multiple', '')\n }\n\n if (!!sortable) {\n target.setAttribute('sortable', '')\n }\n\n if (attrSelected) {\n target.setAttribute('attr-selected', attrSelected)\n }\n\n render(template, target)\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"]}
|
package/dist/src/ox-popup.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { LitElement } from 'lit';
|
|
|
10
10
|
*/
|
|
11
11
|
export declare class OxPopup extends LitElement {
|
|
12
12
|
static styles: import("lit").CSSResult[];
|
|
13
|
-
|
|
13
|
+
preventCloseOnBlur: boolean;
|
|
14
14
|
_parent: Element | null;
|
|
15
15
|
private lastActive;
|
|
16
16
|
render(): import("lit-html").TemplateResult<1>;
|
|
@@ -34,7 +34,7 @@ export declare class OxPopup extends LitElement {
|
|
|
34
34
|
* @property {Number} left The position-left where the pop-up will be displayed
|
|
35
35
|
* @property {HTMLElement} parent Popup's parent element
|
|
36
36
|
*/
|
|
37
|
-
static open({ template, top, left, right, bottom, width, height, parent, style }: {
|
|
37
|
+
static open({ template, top, left, right, bottom, width, height, parent, style, preventCloseOnBlur }: {
|
|
38
38
|
template: unknown;
|
|
39
39
|
top?: number;
|
|
40
40
|
left?: number;
|
|
@@ -44,6 +44,7 @@ export declare class OxPopup extends LitElement {
|
|
|
44
44
|
height?: string;
|
|
45
45
|
parent?: Element | null;
|
|
46
46
|
style?: string;
|
|
47
|
+
preventCloseOnBlur?: boolean;
|
|
47
48
|
}): OxPopup;
|
|
48
49
|
/**
|
|
49
50
|
* Opens the 'ox-popup' with the specified position and dimensions.
|
package/dist/src/ox-popup.js
CHANGED
|
@@ -15,15 +15,15 @@ import { ScrollbarStyles } from '@operato/styles';
|
|
|
15
15
|
let OxPopup = class OxPopup extends LitElement {
|
|
16
16
|
constructor() {
|
|
17
17
|
super(...arguments);
|
|
18
|
-
this.
|
|
18
|
+
this.preventCloseOnBlur = false;
|
|
19
19
|
this._parent = null;
|
|
20
20
|
this.lastActive = document.activeElement;
|
|
21
21
|
this._onfocusout = function (e) {
|
|
22
22
|
const to = e.relatedTarget;
|
|
23
23
|
if (!this.contains(to)) {
|
|
24
24
|
/* 분명히 내 범위가 아닌 엘리먼트로 포커스가 옮겨졌다면, ox-popup은 닫혀야 한다. */
|
|
25
|
-
// @ts-ignore for
|
|
26
|
-
!this.
|
|
25
|
+
// @ts-ignore for preventCloseOnBlur
|
|
26
|
+
!this.preventCloseOnBlur && !window.POPUP_DEBUG && this.close();
|
|
27
27
|
}
|
|
28
28
|
}.bind(this);
|
|
29
29
|
this._onkeydown = function (e) {
|
|
@@ -59,8 +59,8 @@ let OxPopup = class OxPopup extends LitElement {
|
|
|
59
59
|
this.close();
|
|
60
60
|
}.bind(this);
|
|
61
61
|
this._onwindowblur = function (e) {
|
|
62
|
-
// @ts-ignore for
|
|
63
|
-
!this.
|
|
62
|
+
// @ts-ignore for preventCloseOnBlur
|
|
63
|
+
!this.preventCloseOnBlur && !window.POPUP_DEBUG && this.close();
|
|
64
64
|
}.bind(this);
|
|
65
65
|
}
|
|
66
66
|
render() {
|
|
@@ -89,9 +89,12 @@ let OxPopup = class OxPopup extends LitElement {
|
|
|
89
89
|
* @property {Number} left The position-left where the pop-up will be displayed
|
|
90
90
|
* @property {HTMLElement} parent Popup's parent element
|
|
91
91
|
*/
|
|
92
|
-
static open({ template, top, left, right, bottom, width, height, parent, style }) {
|
|
92
|
+
static open({ template, top, left, right, bottom, width, height, parent, style, preventCloseOnBlur }) {
|
|
93
93
|
const owner = parent || document.body;
|
|
94
94
|
const target = document.createElement('ox-popup');
|
|
95
|
+
if (preventCloseOnBlur) {
|
|
96
|
+
target.preventCloseOnBlur = preventCloseOnBlur;
|
|
97
|
+
}
|
|
95
98
|
if (style) {
|
|
96
99
|
target.style.cssText = style;
|
|
97
100
|
}
|
|
@@ -241,6 +244,7 @@ OxPopup.styles = [
|
|
|
241
244
|
|
|
242
245
|
:host([active]) {
|
|
243
246
|
display: flex;
|
|
247
|
+
flex-direction: column;
|
|
244
248
|
}
|
|
245
249
|
|
|
246
250
|
:host(*:focus) {
|
|
@@ -249,8 +253,8 @@ OxPopup.styles = [
|
|
|
249
253
|
`
|
|
250
254
|
];
|
|
251
255
|
__decorate([
|
|
252
|
-
property({ type: Boolean })
|
|
253
|
-
], OxPopup.prototype, "
|
|
256
|
+
property({ type: Boolean, attribute: 'prevent-close-on-blur' })
|
|
257
|
+
], OxPopup.prototype, "preventCloseOnBlur", void 0);
|
|
254
258
|
__decorate([
|
|
255
259
|
state()
|
|
256
260
|
], OxPopup.prototype, "_parent", void 0);
|
package/dist/src/ox-popup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD;;;;;;;;GAQG;AAEI,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,UAAU;IAAhC;;QA4BwB,UAAK,GAAY,KAAK,CAAA;QAE1C,YAAO,GAAmB,IAAI,CAAA;QAE/B,eAAU,GAAgB,QAAQ,CAAC,aAA4B,CAAA;QAM7D,gBAAW,GAA4B,UAAyB,CAAa;YACrF,MAAM,EAAE,GAAG,CAAC,CAAC,aAA4B,CAAA;YAEzC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;gBACvB,sDAAsD;gBACtD,uBAAuB;gBACvB,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,IAAI,CAAC,KAAK,EAAE,CAAA;YACpD,CAAC;QACH,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAEF,eAAU,GAA+B,UAAyB,CAAgB;YAC1F,CAAC,CAAC,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ChD,IAAI,CAAC,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;YACnD,IAAI,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;YACzD,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,CAAA;YACpD,IAAI,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;;AAhTM,cAAM,GAAG;IACd,eAAe;IACf,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;KAsBF;CACF,AAzBY,CAyBZ;AAE4B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sCAAuB;AAE1C;IAAR,KAAK,EAAE;wCAA+B;AA9B5B,OAAO;IADnB,aAAa,CAAC,UAAU,CAAC;GACb,OAAO,CAkTnB","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 }\n\n :host(*:focus) {\n outline: none;\n }\n `\n ]\n\n @property({ type: Boolean }) debug: 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 debug\n !this.debug && !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 debug\n !this.debug && !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 }: {\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 }): OxPopup {\n const owner = parent || document.body\n const target = document.createElement('ox-popup') as OxPopup\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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I,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"]}
|
package/dist/src/ox-prompt.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import '@material/web/button/
|
|
1
|
+
import '@material/web/button/filled-button.js';
|
|
2
|
+
import '@material/web/button/outlined-button.js';
|
|
2
3
|
import '@material/web/icon/icon.js';
|
|
3
4
|
import { LitElement } from 'lit';
|
|
4
5
|
/**
|
|
@@ -44,6 +45,10 @@ export declare class OxPrompt extends LitElement {
|
|
|
44
45
|
text: string;
|
|
45
46
|
color?: string;
|
|
46
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* Prevents the popup from closing when it loses focus (blur event).
|
|
50
|
+
*/
|
|
51
|
+
preventCloseOnBlur: boolean;
|
|
47
52
|
/**
|
|
48
53
|
* A callback function called when the popup is closed, providing the result of the user's interaction.
|
|
49
54
|
*/
|
|
@@ -94,10 +99,11 @@ export declare class OxPrompt extends LitElement {
|
|
|
94
99
|
* @param {string} [options.width] - The maximum width of the popup (CSS string).
|
|
95
100
|
* @param {string} [options.height] - The maximum height of the popup (CSS string).
|
|
96
101
|
* @param {Element | null} [options.parent] - The parent element to which the popup should be attached. If not provided, it will be attached to the document body.
|
|
102
|
+
* @param {boolean} [options.preventCloseOnBlur] - Prevents the popup from closing when it loses focus (blur event).
|
|
97
103
|
* @param {(result: { value: boolean }) => void} [options.callback] - A callback function that will be invoked when the user interacts with the popup, providing the result of the interaction.
|
|
98
104
|
* @returns {Promise<boolean>} A Promise that resolves based on user interaction with the popup.
|
|
99
105
|
*/
|
|
100
|
-
static open({ template, type, icon, title, text, footer, confirmButton, cancelButton, top, left, right, bottom, width, height, parent, callback }: {
|
|
106
|
+
static open({ template, type, icon, title, text, footer, confirmButton, cancelButton, top, left, right, bottom, width, height, parent, preventCloseOnBlur, callback }: {
|
|
101
107
|
template?: unknown;
|
|
102
108
|
type?: 'success' | 'error' | 'warning' | 'info' | 'question';
|
|
103
109
|
icon?: string;
|
|
@@ -119,6 +125,7 @@ export declare class OxPrompt extends LitElement {
|
|
|
119
125
|
width?: string;
|
|
120
126
|
height?: string;
|
|
121
127
|
parent?: Element | null;
|
|
128
|
+
preventCloseOnBlur?: boolean;
|
|
122
129
|
callback?: (result: {
|
|
123
130
|
value: boolean;
|
|
124
131
|
}) => void;
|
package/dist/src/ox-prompt.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import '@material/web/button/
|
|
2
|
+
import '@material/web/button/filled-button.js';
|
|
3
|
+
import '@material/web/button/outlined-button.js';
|
|
3
4
|
import '@material/web/icon/icon.js';
|
|
4
5
|
import { styles as MDTypeScaleStyles } from '@material/web/typography/md-typescale-styles';
|
|
5
6
|
import { css, html, nothing, LitElement } from 'lit';
|
|
@@ -23,13 +24,17 @@ let OxPrompt = class OxPrompt extends LitElement {
|
|
|
23
24
|
* Specifies the title of the popup.
|
|
24
25
|
*/
|
|
25
26
|
this.titler = '';
|
|
27
|
+
/**
|
|
28
|
+
* Prevents the popup from closing when it loses focus (blur event).
|
|
29
|
+
*/
|
|
30
|
+
this.preventCloseOnBlur = false;
|
|
26
31
|
this.resolveFn = null;
|
|
27
32
|
this._onfocusout = function (e) {
|
|
28
33
|
const to = e.relatedTarget;
|
|
29
34
|
if (!this.contains(to)) {
|
|
30
35
|
/* 분명히 내 범위가 아닌 엘리먼트로 포커스가 옮겨졌다면, ox-prompt은 닫혀야 한다. */
|
|
31
36
|
// @ts-ignore for debug
|
|
32
|
-
if (window.POPUP_DEBUG) {
|
|
37
|
+
if (this.preventCloseOnBlur || window.POPUP_DEBUG) {
|
|
33
38
|
return;
|
|
34
39
|
}
|
|
35
40
|
this.resolveFn && this.resolveFn(false);
|
|
@@ -72,7 +77,7 @@ let OxPrompt = class OxPrompt extends LitElement {
|
|
|
72
77
|
}.bind(this);
|
|
73
78
|
this._onwindowblur = function (e) {
|
|
74
79
|
// @ts-ignore for debug
|
|
75
|
-
if (window.POPUP_DEBUG) {
|
|
80
|
+
if (this.preventCloseOnBlur || window.POPUP_DEBUG) {
|
|
76
81
|
return;
|
|
77
82
|
}
|
|
78
83
|
this.resolveFn && this.resolveFn(false);
|
|
@@ -95,14 +100,14 @@ let OxPrompt = class OxPrompt extends LitElement {
|
|
|
95
100
|
${this.confirmButton
|
|
96
101
|
? html `
|
|
97
102
|
<md-filled-button id="confirm" @click=${(e) => this.onConfirm()}
|
|
98
|
-
>${(_a = this.confirmButton) === null || _a === void 0 ? void 0 : _a.text}</md-
|
|
103
|
+
>${(_a = this.confirmButton) === null || _a === void 0 ? void 0 : _a.text}</md-filled-button
|
|
99
104
|
>
|
|
100
105
|
`
|
|
101
106
|
: nothing}
|
|
102
107
|
${this.cancelButton
|
|
103
108
|
? html `
|
|
104
109
|
<md-outlined-button id="cancel" @click=${(e) => this.onCancel()}
|
|
105
|
-
>${(_b = this.cancelButton) === null || _b === void 0 ? void 0 : _b.text}</md-
|
|
110
|
+
>${(_b = this.cancelButton) === null || _b === void 0 ? void 0 : _b.text}</md-outlined-button
|
|
106
111
|
>
|
|
107
112
|
`
|
|
108
113
|
: nothing}
|
|
@@ -159,10 +164,11 @@ let OxPrompt = class OxPrompt extends LitElement {
|
|
|
159
164
|
* @param {string} [options.width] - The maximum width of the popup (CSS string).
|
|
160
165
|
* @param {string} [options.height] - The maximum height of the popup (CSS string).
|
|
161
166
|
* @param {Element | null} [options.parent] - The parent element to which the popup should be attached. If not provided, it will be attached to the document body.
|
|
167
|
+
* @param {boolean} [options.preventCloseOnBlur] - Prevents the popup from closing when it loses focus (blur event).
|
|
162
168
|
* @param {(result: { value: boolean }) => void} [options.callback] - A callback function that will be invoked when the user interacts with the popup, providing the result of the interaction.
|
|
163
169
|
* @returns {Promise<boolean>} A Promise that resolves based on user interaction with the popup.
|
|
164
170
|
*/
|
|
165
|
-
static async open({ template, type, icon, title, text, footer, confirmButton, cancelButton, top, left, right, bottom, width, height, parent, callback }) {
|
|
171
|
+
static async open({ template, type, icon, title, text, footer, confirmButton, cancelButton, top, left, right, bottom, width, height, parent, preventCloseOnBlur, callback }) {
|
|
166
172
|
const owner = parent || document.body;
|
|
167
173
|
const target = document.createElement('ox-prompt');
|
|
168
174
|
target.type = type;
|
|
@@ -172,6 +178,7 @@ let OxPrompt = class OxPrompt extends LitElement {
|
|
|
172
178
|
target.footer = footer;
|
|
173
179
|
target.confirmButton = confirmButton;
|
|
174
180
|
target.cancelButton = cancelButton;
|
|
181
|
+
target.preventCloseOnBlur = !!preventCloseOnBlur;
|
|
175
182
|
render(template, target);
|
|
176
183
|
target._parent = owner;
|
|
177
184
|
owner.appendChild(target);
|
|
@@ -423,6 +430,9 @@ __decorate([
|
|
|
423
430
|
__decorate([
|
|
424
431
|
property({ type: Object })
|
|
425
432
|
], OxPrompt.prototype, "cancelButton", void 0);
|
|
433
|
+
__decorate([
|
|
434
|
+
property({ type: Boolean, attribute: 'prevent-close-on-blur' })
|
|
435
|
+
], OxPrompt.prototype, "preventCloseOnBlur", void 0);
|
|
426
436
|
__decorate([
|
|
427
437
|
property({ type: Object })
|
|
428
438
|
], OxPrompt.prototype, "callback", void 0);
|