wj-elements 0.4.1 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base-path.js.map +1 -1
- package/dist/packages/wje-accordion-item/accordion-item.element.d.ts +2 -2
- package/dist/packages/wje-avatar/service/service.d.ts +0 -1
- package/dist/packages/wje-breadcrumb/breadcrumb.element.d.ts +1 -2
- package/dist/packages/wje-carousel/carousel.element.d.ts +6 -6
- package/dist/packages/wje-copy-button/copy-button.element.d.ts +5 -3
- package/dist/packages/wje-dropdown/dropdown.element.d.ts +29 -1
- package/dist/packages/wje-element/element.d.ts +1 -1
- package/dist/packages/wje-input/input.element.d.ts +1 -0
- package/dist/packages/wje-option/option.element.d.ts +3 -0
- package/dist/packages/wje-select/select.element.d.ts +17 -0
- package/dist/{popup.element-DklicGea.js → popup.element-C8-g3WLs.js} +3 -3
- package/dist/{popup.element-DklicGea.js.map → popup.element-C8-g3WLs.js.map} +1 -1
- package/dist/wje-accordion-item.js.map +1 -1
- package/dist/wje-avatar.js.map +1 -1
- package/dist/wje-breadcrumb.js +0 -1
- package/dist/wje-breadcrumb.js.map +1 -1
- package/dist/wje-carousel.js +6 -6
- package/dist/wje-carousel.js.map +1 -1
- package/dist/wje-copy-button.js +21 -12
- package/dist/wje-copy-button.js.map +1 -1
- package/dist/wje-dropdown.js +67 -2
- package/dist/wje-dropdown.js.map +1 -1
- package/dist/wje-element.js +1 -1
- package/dist/wje-element.js.map +1 -1
- package/dist/wje-file-upload.js +0 -1
- package/dist/wje-file-upload.js.map +1 -1
- package/dist/wje-input.js +50 -6
- package/dist/wje-input.js.map +1 -1
- package/dist/wje-master.js +1 -1
- package/dist/wje-option.js +8 -2
- package/dist/wje-option.js.map +1 -1
- package/dist/wje-options.js +15 -2
- package/dist/wje-options.js.map +1 -1
- package/dist/wje-popup.js +1 -1
- package/dist/wje-select.js +187 -28
- package/dist/wje-select.js.map +1 -1
- package/dist/wje-tab.js.map +1 -1
- package/dist/wje-tooltip.js +1 -1
- package/package.json +5 -4
package/dist/wje-options.js
CHANGED
|
@@ -8,7 +8,8 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
|
|
|
8
8
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
9
9
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
10
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
11
|
-
var
|
|
11
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
12
|
+
var _loadedOptions, _drawPreloadedElements, _Options_instances, getLazyList_fn;
|
|
12
13
|
import WJElement from "./wje-element.js";
|
|
13
14
|
import InfiniteScroll from "./wje-infinite-scroll.js";
|
|
14
15
|
import List from "./wje-list.js";
|
|
@@ -18,6 +19,7 @@ const styles = "/*\n[ WJ OPTIONS ]\n*/\n\n:host {\n display: block;\n height:
|
|
|
18
19
|
class Options extends WJElement {
|
|
19
20
|
constructor() {
|
|
20
21
|
super();
|
|
22
|
+
__privateAdd(this, _Options_instances);
|
|
21
23
|
__privateAdd(this, _loadedOptions, []);
|
|
22
24
|
__privateAdd(this, _drawPreloadedElements, []);
|
|
23
25
|
__publicField(this, "dependencies", {
|
|
@@ -434,8 +436,13 @@ class Options extends WJElement {
|
|
|
434
436
|
return;
|
|
435
437
|
}
|
|
436
438
|
const item = this.htmlItem(optionData);
|
|
439
|
+
const lazyList = __privateMethod(this, _Options_instances, getLazyList_fn).call(this);
|
|
437
440
|
__privateGet(this, _drawPreloadedElements).push(item);
|
|
438
|
-
|
|
441
|
+
if (lazyList) {
|
|
442
|
+
lazyList.appendChild(item);
|
|
443
|
+
} else {
|
|
444
|
+
this.prepend(item);
|
|
445
|
+
}
|
|
439
446
|
this.loadedOptions.push(optionData);
|
|
440
447
|
}
|
|
441
448
|
/**
|
|
@@ -453,6 +460,12 @@ class Options extends WJElement {
|
|
|
453
460
|
}
|
|
454
461
|
_loadedOptions = new WeakMap();
|
|
455
462
|
_drawPreloadedElements = new WeakMap();
|
|
463
|
+
_Options_instances = new WeakSet();
|
|
464
|
+
getLazyList_fn = function() {
|
|
465
|
+
var _a;
|
|
466
|
+
if (!this.lazy) return null;
|
|
467
|
+
return ((_a = this.infiniteScroll) == null ? void 0 : _a.querySelector("wje-list")) ?? this.querySelector(":scope > wje-infinite-scroll > wje-list");
|
|
468
|
+
};
|
|
456
469
|
Options.define("wje-options", Options);
|
|
457
470
|
export {
|
|
458
471
|
Options as default
|
package/dist/wje-options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-options.js","sources":["../packages/wje-options/options.element.js","../packages/wje-options/options.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport InfiniteScroll from '../wje-infinite-scroll/infinite-scroll.js';\nimport List from '../wje-list/list.js';\nimport Option from '../wje-option/option.js';\n\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Options` is a custom web component that represents a set of options. It extends from `WJElement`.\n * @summary This element represents a set of options.\n * @documentation https://elements.webjet.sk/components/options\n * @status stable\n * @tag wje-options\n */\n\nexport default class Options extends WJElement {\n\n\t#loadedOptions = [];\n\n\t#drawPreloadedElements = [];\n\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tdependencies = {\n\t\t'wje-option': Option,\n\t\t'wje-infinite-scroll': InfiniteScroll,\n\t\t'wje-list': List,\n\t}\n\n\t/**\n\t * Sets the option array path attribute.\n\t * @param {string} value The value to set for the option array path.\n\t */\n\tset optionArrayPath(value) {\n\t\tthis.setAttribute('option-array-path', value);\n\t}\n\n\t/**\n\t * Gets the option array path attribute.\n\t * @returns {string} The value of the option array path attribute or \"data\" if not set.\n\t */\n\tget optionArrayPath() {\n\t\treturn this.getAttribute('option-array-path');\n\t}\n\n\t/**\n\t * Checks if the option array path attribute is present.\n\t * @returns {boolean} True if the option array path attribute is present, false otherwise.\n\t */\n\tget hasOptionArrayPath() {\n\t\treturn this.hasAttribute('option-array-path');\n\t}\n\n\t/**\n\t * Gets the dropdown height attribute.\n\t * @returns {string} The value of the dropdown height attribute or \"100%\" if not set.\n\t */\n\tget dropdownHeight() {\n\t\treturn this.getAttribute('dropdown-height') || '100%';\n\t}\n\n\t/**\n\t * Sets the dropdown height attribute.\n\t * @param {string} value The value to set for the dropdown height.\n\t */\n\tset dropdownHeight(value) {\n\t\tthis.setAttribute('dropdown-height', value);\n\t}\n\n\t/**\n\t * Sets the item value attribute.\n\t * @param {string} value The value to set for the item value.\n\t */\n\tset itemValue(value) {\n\t\tthis.setAttribute('item-value', value);\n\t}\n\n\t/**\n\t * Gets the item value attribute.\n\t * @returns {string} The value of the item value attribute or \"value\" if not set.\n\t */\n\tget itemValue() {\n\t\treturn this.getAttribute('item-value') || 'value';\n\t}\n\n\t/**\n\t * Sets the item text attribute.\n\t * @param {string} value The value to set for the item text.\n\t */\n\tset itemText(value) {\n\t\tthis.setAttribute('item-text', value);\n\t}\n\n\t/**\n\t * Gets the item text attribute.\n\t * @returns {string} The value of the item text attribute or \"text\" if not set.\n\t */\n\tget itemText() {\n\t\treturn this.getAttribute('item-text') || 'text';\n\t}\n\n\t/**\n\t * Gets the lazy load size attribute.\n\t * @returns {number} The value of the lazy load size attribute or 10 if not set.\n\t */\n\tget lazyLoadSize() {\n\t\treturn this.getAttribute('lazy-load-size') || 10;\n\t}\n\n\t/**\n\t * Sets the lazy load size attribute.\n\t * @param {number} value The value to set for the lazy load size.\n\t */\n\tset lazyLoadSize(value) {\n\t\tthis.setAttribute('lazy-load-size', value);\n\t}\n\n\t/**\n\t * Sets the search attribute.\n\t * @param {string} value The value to set for the search.\n\t */\n\tset search(value) {\n\t\tthis.setAttribute('search', value);\n\t}\n\n\t/**\n\t * Gets the search attribute.\n\t * @returns {string} The value of the search attribute.\n\t */\n\tget search() {\n\t\treturn this.getAttribute('search');\n\t}\n\n\t/**\n\t * Checks if the search attribute is present.\n\t * @returns {boolean} True if the search attribute is present, false otherwise.\n\t */\n\tget hasSearch() {\n\t\treturn this.hasAttribute('search');\n\t}\n\n\t/**\n\t * Retrieves the value of the 'search-to-query-params' attribute from the current instance.\n\t * @returns {string | null} The value of the 'search-to-query-params' attribute, or null if the attribute is not set.\n\t */\n\tget searchToQueryParams() {\n\t\treturn this.getAttribute('search-to-query-params');\n\t}\n\n\t/**\n\t * Sets the value to define search-to-query params behavior.\n\t * @param {string} value The value to be set for the search-to-query-params attribute.\n\t */\n\tset searchToQueryParams(value) {\n\t\tthis.setAttribute('search-to-query-params', value);\n\t}\n\n\t/**\n\t * Determines whether the 'search-to-query-params' attribute is present on the element.\n\t * @returns {boolean} True if the 'search-to-query-params' attribute exists, otherwise false.\n\t */\n\tget hasSearchToQueryParams() {\n\t\treturn this.hasAttribute('search-to-query-params');\n\t}\n\n\t/**\n\t * Sets the value of the search parameter name attribute.\n\t * @param {string} value The string value to set as the search parameter name.\n\t */\n\tset searchParamName(value) {\n\t\tthis.setAttribute('search-param-name', value);\n\t}\n\n\t/**\n\t * Gets the search parameter name used in queries.\n\t * Retrieves the value of the 'search-param-name' attribute.\n\t * If the attribute is not set, it defaults to 'search'.\n\t * @returns {string} The search parameter name used for queries.\n\t */\n\tget searchParamName() {\n\t\treturn this.getAttribute('search-param-name') || 'search';\n\t}\n\n\t/**\n\t * Sets the queryParams attribute on the element.\n\t * @param {string} value The query parameters to set, represented as a string.\n\t */\n\tset queryParams(value) {\n\t\tthis.setAttribute('query-params', value);\n\t}\n\n\t/**\n\t * Retrieves the value of the 'query-params' attribute.\n\t * @returns {string | null} The value of the 'query-params' attribute, or null if the attribute is not set.\n\t */\n\tget queryParams() {\n\t\treturn this.getAttribute('query-params');\n\t}\n\n\t/**\n\t * Sets the lazy attribute.\n\t * @param {boolean} value The value to set for the lazy attribute.\n\t */\n\tset lazy(value) {\n\t\tthis.setAttribute('lazy', value);\n\t}\n\n\t/**\n\t * Checks if the lazy attribute is present.\n\t * @returns {boolean} True if the lazy attribute is present, false otherwise.\n\t */\n\tget lazy() {\n\t\treturn this.hasAttribute('lazy');\n\t}\n\n\t/**\n\t * Gets the loaded options.\n\t * @returns {Array} The loaded options.\n\t */\n\tget options() {\n\t\treturn this.loadedOptions?.flat();\n\t}\n\n\t/**\n\t * Gets the loaded options.\n\t * @type {Array}\n\t */\n\tget loadedOptions() {\n\t\treturn this.#loadedOptions;\n\t}\n\n\t/**\n\t * Sets the loaded options.\n\t * @type {Array}\n\t */\n\tset loadedOptions(loadedOptions) {\n\t\tthis.#loadedOptions = loadedOptions;\n\t}\n\n\t/**\n\t * Array of preloaded elements.\n\t * @type {Array}\n\t * @private\n\t */\n\tget drawPreloadedElements() {\n\t\treturn this.#drawPreloadedElements;\n\t}\n\n\t/**\n\t * Sets the elements that are preloaded and ready to be drawn.\n\t * @param {Array|object} elements The elements to be set for preloading. This can be an array or a specific object containing drawable elements.\n\t */\n\tset drawPreloadedElements(elements) {\n\t\tthis.#drawPreloadedElements = elements;\n\t}\n\n\tclassName = 'Options';\n\n\t/**\n\t * Returns the CSS styles for the component.\n\t * @static\n\t * @returns {CSSStyleSheet} The CSS styles for the component.\n\t */\n\tstatic get cssStyleSheet() {\n\t\treturn styles;\n\t}\n\n\t/**\n\t * Retrieves an array of attributes that should be observed for changes.\n\t * The method returns a list of attribute names that the browser will monitor for changes.\n\t * @returns {Array<string>} An array of attribute names to observe.\n\t */\n\tstatic get observedAttributes() {\n\t\treturn ['search', 'attached'];\n\t}\n\n\t/**\n\t * Sets up the attributes for the component.\n\t */\n\tsetupAttributes() {\n\t\tthis.isShadowRoot = 'open';\n\t\tthis.syncAria();\n\t}\n\n\t/**\n\t * Draws the component.\n\t * @returns {DocumentFragment}\n\t */\n\tasync draw() {\n\t\tlet fragment = document.createDocumentFragment();\n\n\t\tconst slot = document.createElement('slot');\n\t\tfragment.appendChild(slot);\n\t\tthis.syncAria();\n\n\t\tif (this.lazy) {\n\t\t\tif (this.contains(this.infiniteScroll)) {\n\t\t\t\tthis.drawPreloadedElements.forEach((el) => { el.remove() });\n\t\t\t\tthis.loadedOptions = [];\n\t\t\t\tthis.infiniteScroll.placementObj.innerHTML = '';\n\t\t\t\tthis.infiniteScroll.totalPages = 0;\n\t\t\t\tthis.infiniteScroll.refresh();\n\t\t\t}\n\n\t\t\tlet loader = document.createElement('div');\n\t\t\tloader.setAttribute('slot', 'loader');\n\t\t\tloader.append('Loading...');\n\t\t\tloader.classList.add('loader');\n\n\t\t\tconst infiniteScroll = document.createElement('wje-infinite-scroll');\n\t\t\tinfiniteScroll.setAttribute('placement', 'wje-list');\n\t\t\tinfiniteScroll.setAttribute('height', this.dropdownHeight);\n\t\t\tinfiniteScroll.setAttribute('object-name', this.optionArrayPath);\n\t\t\tinfiniteScroll.dataToHtml = this.htmlItem;\n\t\t\tinfiniteScroll.setCustomData = async (page, signal) => {\n\t\t\t\tlet processedUrl = `${this.url}${this.search ? `/${this.search}` : ''}?page=${page}&size=${this.lazyLoadSize}${this.queryParams ? `&${this.queryParams}` : ''}`;\n\n\t\t\t\tif (this.hasSearchToQueryParams) {\n\t\t\t\t\tprocessedUrl = `${this.url}?page=${page}&size=${this.lazyLoadSize}${this.queryParams ? `&${this.queryParams}` : ''}${this.search ? `&${this.searchParamName}=${this.search}` : ''}`;\n\t\t\t\t}\n\n\t\t\t\tlet res = await this.service.get(processedUrl, null, false, signal);\n\t\t\t\tconst filteredOptions = this.filterOutDrawnOptions(res);\n\t\t\t\tthis.loadedOptions.push(...this.processData(filteredOptions));\n\n\t\t\t\treturn filteredOptions;\n\t\t\t};\n\n\t\t\tconst list = document.createElement('wje-list');\n\n\t\t\tinfiniteScroll.append(list);\n\t\t\tinfiniteScroll.append(loader);\n\n\t\t\tif (this.hasAttribute('attached') && !this.hasSearch) {\n\t\t\t\tthis.appendChild(infiniteScroll);\n\t\t\t\tthis.drawPreloadedElements.forEach((el) => {\n\t\t\t\t\tlist.appendChild(el);\n\t\t\t\t});\n\t\t\t\tthis.infiniteScroll = infiniteScroll;\n\t\t\t}\n\t\t} else {\n\t\t\tthis.response = await this.getPages();\n\n\t\t\tlet optionsData = this.filterOutDrawnOptions(this.response);\n\t\t\toptionsData = this.processData(optionsData);\n\n\t\t\tthis.loadedOptions.push(...optionsData);\n\n\t\t\tthis.append(...optionsData.map(this.htmlItem));\n\n\t\t\tevent.dispatchCustomEvent(this, 'wje-options:load', {});\n\t\t}\n\n\t\treturn fragment;\n\t}\n\n\t/**\n\t * Syncs ARIA attributes on the host element.\n\t */\n\tsyncAria() {\n\t\tconst isMultiple = this.closest('wje-select')?.hasAttribute('multiple');\n\t\tthis.setAriaState({\n\t\t\trole: 'listbox',\n\t\t\tmultiselectable: isMultiple ? 'true' : undefined,\n\t\t});\n\t}\n\n\tafterDraw() {\n\t\tevent.addListener(this.infiniteScroll, 'wje-infinite-scroll:load', null, this.dispatchOptionsLoadEvent);\n\t}\n\n\tdispatchOptionsLoadEvent = (e) => {\n\t\t// Wait for next paint cycle to ensure options are in DOM\n\t\trequestAnimationFrame(() => {\n\t\t\trequestAnimationFrame(() => {\n\t\t\t\tevent.dispatchCustomEvent(this, 'wje-options:load', {});\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Processes the provided data based on the optional array path set in the instance.\n\t * @param {object} data The input data to be processed.\n\t * @returns {Array} The resolved options array from the data or an empty array if no match is found.\n\t */\n\tprocessData(data) {\n\t\tconst splittedOptionArrayPath = this.optionArrayPath ? this.optionArrayPath?.split('.') : null;\n\t\tlet options = data;\n\n\t\tsplittedOptionArrayPath?.forEach((path) => {\n\t\t\toptions = options[path];\n\t\t});\n\n\t\treturn options ?? [];\n\t}\n\n\t/**\n\t * Filters out options from the response object that have already been drawn, based on the specified option array path.\n\t * @param {object} response The response object containing data to process.\n\t * @returns {object} The filtered response object with drawn options removed.\n\t */\n\tfilterOutDrawnOptions(response) {\n\t\tconst splittedOptionArrayPath = this.optionArrayPath ? this.optionArrayPath?.split('.') : [];\n\t\tlet filteredResponse = structuredClone(response);\n\n\t\tfilteredResponse = this.recursiveUpdate(filteredResponse, splittedOptionArrayPath);\n\t\treturn filteredResponse;\n\t}\n\n\t/**\n\t * Recursively updates the object based on the provided path to the property.\n\t * @param {object | Array | null} object\n\t * @param {Array<string> | null} pathToProperty\n\t * @returns {object | Array | null}\n\t */\n\trecursiveUpdate = (object, pathToProperty) => {\n\t\tif (pathToProperty.length === 0) {\n\t\t\tif (Array.isArray(object)) {\n\t\t\t\treturn object.filter(\n\t\t\t\t\t(option) =>\n\t\t\t\t\t\t!this.loadedOptions.some(\n\t\t\t\t\t\t\t(loadedOption) => loadedOption[this.itemValue] === option[this.itemValue]\n\t\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconsole.error('Expected an array but got:', object, pathToProperty);\n\t\t\t\treturn [];\n\t\t\t}\n\t\t}\n\n\t\tconst [currentPath, ...remainingPath] = pathToProperty;\n\t\tif (remainingPath.length > 0) {\n\t\t\tobject[currentPath] = this.recursiveUpdate(object[currentPath], remainingPath);\n\t\t} else {\n\t\t\tobject[currentPath] =\n\t\t\t\tobject[currentPath]?.filter(\n\t\t\t\t\t(option) =>\n\t\t\t\t\t\t!this.loadedOptions.some(\n\t\t\t\t\t\t\t(loadedOption) => loadedOption[this.itemValue] === option[this.itemValue]\n\t\t\t\t\t\t)\n\t\t\t\t) ?? [];\n\t\t}\n\t\treturn object;\n\t};\n\n\t/**\n\t * Generates an HTML option element based on the provided item.\n\t * @param {object} item The item to generate the option element for.\n\t * @returns {HTMLElement} The generated option element.\n\t */\n\thtmlItem = (item) => {\n\t\tlet option = document.createElement('wje-option');\n\n\t\tif (item[this.itemValue] === null || item[this.itemValue] === undefined) {\n\t\t\tconsole.warn(`The item ${JSON.stringify(item)} does not have the property ${this.itemValue}`);\n\t\t}\n\n\t\tif (item[this.itemText] === null || item[this.itemText] === undefined) {\n\t\t\tconsole.warn(`The item ${JSON.stringify(item)} does not have the property ${this.itemText}`);\n\t\t}\n\n\t\toption.setAttribute('value', item[this.itemValue] ?? '');\n\t\toption.innerText = item[this.itemText] ?? '';\n\n\t\treturn option;\n\t};\n\n\t/**\n\t * Fetches the pages from the provided URL.\n\t * @param {number} page The page number to fetch.\n\t * @returns {Promise<object>} The fetched data.\n\t * @throws Will throw an error if the response is not ok.\n\t */\n\tasync getPages(page) {\n\t\tconst response = await fetch(this.url);\n\t\tif (!response.ok) {\n\t\t\tthrow new Error(`An error occurred: ${response.status}`);\n\t\t}\n\t\treturn await response.json();\n\t}\n\n\t/**\n\t * Finds the selected option data based on the given selected option values.\n\t * @param {Array} selectedOptionValues The array of selected option values.\n\t * @returns {Array} - The array of option data that matches the selected option values.\n\t */\n\tfindSelectedOptionData(selectedOptionValues = []) {\n\t\treturn this.options.filter((option) => selectedOptionValues.includes(option[this.itemValue]));\n\t}\n\n\t/**\n\t * Adds an option to the element.\n\t * @param {object} optionData The data of the option to be added.\n\t */\n\taddOption(optionData) {\n\t\tif (this.loadedOptions.some((option) => option[this.itemValue] === optionData[this.itemValue])) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst item = this.htmlItem(optionData);\n\t\tthis.#drawPreloadedElements.push(item);\n\t\tthis.prepend(item);\n\t\tthis.loadedOptions.push(optionData);\n\t}\n\n\t/**\n\t * Adds options to the element.\n\t * @param {Array} optionsData The array of option data to be added.\n\t * @param {boolean} [silent] Whether to suppress events triggered by adding options.\n\t */\n\taddOptions(optionsData = [], silent = false) {\n\t\tif (Array.isArray(optionsData)) optionsData?.forEach((od) => this.addOption(od, silent));\n\t\telse this.addOption(optionsData, silent);\n\t}\n\n\tbeforeDisconnect() {\n\t\tevent.removeListener(this.infiniteScroll, 'wje-infinite-scroll:load', null, this.dispatchOptionsLoadEvent);\n\t}\n}\n","import Options from './options.element.js';\n\nexport default Options;\n\nOptions.define('wje-options', Options);\n"],"names":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;AAAA;AAAA;AAAA,EAkEA,MAAM,SAAS,MAAM;AACpB,UAAM,WAAW,MAAM,MAAM,KAAK,GAAG;AACrC,QAAI,CAAC,SAAS,IAAI;AACjB,YAAM,IAAI,MAAM,sBAAsB,SAAS,MAAM,EAAE;AAAA,IACxD;AACA,WAAO,MAAM,SAAS,KAAI;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,uBAAuB,uBAAuB,IAAI;AACjD,WAAO,KAAK,QAAQ,OAAO,CAAC,WAAW,qBAAqB,SAAS,OAAO,KAAK,SAAS,CAAC,CAAC;AAAA,EAC7F;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAU,YAAY;AACrB,QAAI,KAAK,cAAc,KAAK,CAAC,WAAW,OAAO,KAAK,SAAS,MAAM,WAAW,KAAK,SAAS,CAAC,GAAG;AAC/F;AAAA,IACD;AAEA,UAAM,OAAO,KAAK,SAAS,UAAU;AACrC,uBAAK,wBAAuB,KAAK,IAAI;AACrC,SAAK,QAAQ,IAAI;AACjB,SAAK,cAAc,KAAK,UAAU;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAAW,cAAc,IAAI,SAAS,OAAO;AAC5C,QAAI,MAAM,QAAQ,WAAW,EAAG,4CAAa,QAAQ,CAAC,OAAO,KAAK,UAAU,IAAI,MAAM;AAAA,QACjF,MAAK,UAAU,aAAa,MAAM;AAAA,EACxC;AAAA,EAEA,mBAAmB;AAClB,UAAM,eAAe,KAAK,gBAAgB,4BAA4B,MAAM,KAAK,wBAAwB;AAAA,EAC1G;AACD;AAvfC;AAEA;ACfD,QAAQ,OAAO,eAAe,OAAO;"}
|
|
1
|
+
{"version":3,"file":"wje-options.js","sources":["../packages/wje-options/options.element.js","../packages/wje-options/options.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport InfiniteScroll from '../wje-infinite-scroll/infinite-scroll.js';\nimport List from '../wje-list/list.js';\nimport Option from '../wje-option/option.js';\n\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Options` is a custom web component that represents a set of options. It extends from `WJElement`.\n * @summary This element represents a set of options.\n * @documentation https://elements.webjet.sk/components/options\n * @status stable\n * @tag wje-options\n */\n\nexport default class Options extends WJElement {\n\n\t#loadedOptions = [];\n\n\t#drawPreloadedElements = [];\n\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tdependencies = {\n\t\t'wje-option': Option,\n\t\t'wje-infinite-scroll': InfiniteScroll,\n\t\t'wje-list': List,\n\t}\n\n\t/**\n\t * Sets the option array path attribute.\n\t * @param {string} value The value to set for the option array path.\n\t */\n\tset optionArrayPath(value) {\n\t\tthis.setAttribute('option-array-path', value);\n\t}\n\n\t/**\n\t * Gets the option array path attribute.\n\t * @returns {string} The value of the option array path attribute or \"data\" if not set.\n\t */\n\tget optionArrayPath() {\n\t\treturn this.getAttribute('option-array-path');\n\t}\n\n\t/**\n\t * Checks if the option array path attribute is present.\n\t * @returns {boolean} True if the option array path attribute is present, false otherwise.\n\t */\n\tget hasOptionArrayPath() {\n\t\treturn this.hasAttribute('option-array-path');\n\t}\n\n\t/**\n\t * Gets the dropdown height attribute.\n\t * @returns {string} The value of the dropdown height attribute or \"100%\" if not set.\n\t */\n\tget dropdownHeight() {\n\t\treturn this.getAttribute('dropdown-height') || '100%';\n\t}\n\n\t/**\n\t * Sets the dropdown height attribute.\n\t * @param {string} value The value to set for the dropdown height.\n\t */\n\tset dropdownHeight(value) {\n\t\tthis.setAttribute('dropdown-height', value);\n\t}\n\n\t/**\n\t * Sets the item value attribute.\n\t * @param {string} value The value to set for the item value.\n\t */\n\tset itemValue(value) {\n\t\tthis.setAttribute('item-value', value);\n\t}\n\n\t/**\n\t * Gets the item value attribute.\n\t * @returns {string} The value of the item value attribute or \"value\" if not set.\n\t */\n\tget itemValue() {\n\t\treturn this.getAttribute('item-value') || 'value';\n\t}\n\n\t/**\n\t * Sets the item text attribute.\n\t * @param {string} value The value to set for the item text.\n\t */\n\tset itemText(value) {\n\t\tthis.setAttribute('item-text', value);\n\t}\n\n\t/**\n\t * Gets the item text attribute.\n\t * @returns {string} The value of the item text attribute or \"text\" if not set.\n\t */\n\tget itemText() {\n\t\treturn this.getAttribute('item-text') || 'text';\n\t}\n\n\t/**\n\t * Gets the lazy load size attribute.\n\t * @returns {number} The value of the lazy load size attribute or 10 if not set.\n\t */\n\tget lazyLoadSize() {\n\t\treturn this.getAttribute('lazy-load-size') || 10;\n\t}\n\n\t/**\n\t * Sets the lazy load size attribute.\n\t * @param {number} value The value to set for the lazy load size.\n\t */\n\tset lazyLoadSize(value) {\n\t\tthis.setAttribute('lazy-load-size', value);\n\t}\n\n\t/**\n\t * Sets the search attribute.\n\t * @param {string} value The value to set for the search.\n\t */\n\tset search(value) {\n\t\tthis.setAttribute('search', value);\n\t}\n\n\t/**\n\t * Gets the search attribute.\n\t * @returns {string} The value of the search attribute.\n\t */\n\tget search() {\n\t\treturn this.getAttribute('search');\n\t}\n\n\t/**\n\t * Checks if the search attribute is present.\n\t * @returns {boolean} True if the search attribute is present, false otherwise.\n\t */\n\tget hasSearch() {\n\t\treturn this.hasAttribute('search');\n\t}\n\n\t/**\n\t * Retrieves the value of the 'search-to-query-params' attribute from the current instance.\n\t * @returns {string | null} The value of the 'search-to-query-params' attribute, or null if the attribute is not set.\n\t */\n\tget searchToQueryParams() {\n\t\treturn this.getAttribute('search-to-query-params');\n\t}\n\n\t/**\n\t * Sets the value to define search-to-query params behavior.\n\t * @param {string} value The value to be set for the search-to-query-params attribute.\n\t */\n\tset searchToQueryParams(value) {\n\t\tthis.setAttribute('search-to-query-params', value);\n\t}\n\n\t/**\n\t * Determines whether the 'search-to-query-params' attribute is present on the element.\n\t * @returns {boolean} True if the 'search-to-query-params' attribute exists, otherwise false.\n\t */\n\tget hasSearchToQueryParams() {\n\t\treturn this.hasAttribute('search-to-query-params');\n\t}\n\n\t/**\n\t * Sets the value of the search parameter name attribute.\n\t * @param {string} value The string value to set as the search parameter name.\n\t */\n\tset searchParamName(value) {\n\t\tthis.setAttribute('search-param-name', value);\n\t}\n\n\t/**\n\t * Gets the search parameter name used in queries.\n\t * Retrieves the value of the 'search-param-name' attribute.\n\t * If the attribute is not set, it defaults to 'search'.\n\t * @returns {string} The search parameter name used for queries.\n\t */\n\tget searchParamName() {\n\t\treturn this.getAttribute('search-param-name') || 'search';\n\t}\n\n\t/**\n\t * Sets the queryParams attribute on the element.\n\t * @param {string} value The query parameters to set, represented as a string.\n\t */\n\tset queryParams(value) {\n\t\tthis.setAttribute('query-params', value);\n\t}\n\n\t/**\n\t * Retrieves the value of the 'query-params' attribute.\n\t * @returns {string | null} The value of the 'query-params' attribute, or null if the attribute is not set.\n\t */\n\tget queryParams() {\n\t\treturn this.getAttribute('query-params');\n\t}\n\n\t/**\n\t * Sets the lazy attribute.\n\t * @param {boolean} value The value to set for the lazy attribute.\n\t */\n\tset lazy(value) {\n\t\tthis.setAttribute('lazy', value);\n\t}\n\n\t/**\n\t * Checks if the lazy attribute is present.\n\t * @returns {boolean} True if the lazy attribute is present, false otherwise.\n\t */\n\tget lazy() {\n\t\treturn this.hasAttribute('lazy');\n\t}\n\n\t/**\n\t * Gets the loaded options.\n\t * @returns {Array} The loaded options.\n\t */\n\tget options() {\n\t\treturn this.loadedOptions?.flat();\n\t}\n\n\t/**\n\t * Gets the loaded options.\n\t * @type {Array}\n\t */\n\tget loadedOptions() {\n\t\treturn this.#loadedOptions;\n\t}\n\n\t/**\n\t * Sets the loaded options.\n\t * @type {Array}\n\t */\n\tset loadedOptions(loadedOptions) {\n\t\tthis.#loadedOptions = loadedOptions;\n\t}\n\n\t/**\n\t * Array of preloaded elements.\n\t * @type {Array}\n\t * @private\n\t */\n\tget drawPreloadedElements() {\n\t\treturn this.#drawPreloadedElements;\n\t}\n\n\t/**\n\t * Sets the elements that are preloaded and ready to be drawn.\n\t * @param {Array|object} elements The elements to be set for preloading. This can be an array or a specific object containing drawable elements.\n\t */\n\tset drawPreloadedElements(elements) {\n\t\tthis.#drawPreloadedElements = elements;\n\t}\n\n\tclassName = 'Options';\n\n\t/**\n\t * Returns the CSS styles for the component.\n\t * @static\n\t * @returns {CSSStyleSheet} The CSS styles for the component.\n\t */\n\tstatic get cssStyleSheet() {\n\t\treturn styles;\n\t}\n\n\t/**\n\t * Retrieves an array of attributes that should be observed for changes.\n\t * The method returns a list of attribute names that the browser will monitor for changes.\n\t * @returns {Array<string>} An array of attribute names to observe.\n\t */\n\tstatic get observedAttributes() {\n\t\treturn ['search', 'attached'];\n\t}\n\n\t/**\n\t * Sets up the attributes for the component.\n\t */\n\tsetupAttributes() {\n\t\tthis.isShadowRoot = 'open';\n\t\tthis.syncAria();\n\t}\n\n\t/**\n\t * Draws the component.\n\t * @returns {DocumentFragment}\n\t */\n\tasync draw() {\n\t\tlet fragment = document.createDocumentFragment();\n\n\t\tconst slot = document.createElement('slot');\n\t\tfragment.appendChild(slot);\n\t\tthis.syncAria();\n\n\t\tif (this.lazy) {\n\t\t\tif (this.contains(this.infiniteScroll)) {\n\t\t\t\tthis.drawPreloadedElements.forEach((el) => { el.remove() });\n\t\t\t\tthis.loadedOptions = [];\n\t\t\t\tthis.infiniteScroll.placementObj.innerHTML = '';\n\t\t\t\tthis.infiniteScroll.totalPages = 0;\n\t\t\t\tthis.infiniteScroll.refresh();\n\t\t\t}\n\n\t\t\tlet loader = document.createElement('div');\n\t\t\tloader.setAttribute('slot', 'loader');\n\t\t\tloader.append('Loading...');\n\t\t\tloader.classList.add('loader');\n\n\t\t\tconst infiniteScroll = document.createElement('wje-infinite-scroll');\n\t\t\tinfiniteScroll.setAttribute('placement', 'wje-list');\n\t\t\tinfiniteScroll.setAttribute('height', this.dropdownHeight);\n\t\t\tinfiniteScroll.setAttribute('object-name', this.optionArrayPath);\n\t\t\tinfiniteScroll.dataToHtml = this.htmlItem;\n\t\t\tinfiniteScroll.setCustomData = async (page, signal) => {\n\t\t\t\tlet processedUrl = `${this.url}${this.search ? `/${this.search}` : ''}?page=${page}&size=${this.lazyLoadSize}${this.queryParams ? `&${this.queryParams}` : ''}`;\n\n\t\t\t\tif (this.hasSearchToQueryParams) {\n\t\t\t\t\tprocessedUrl = `${this.url}?page=${page}&size=${this.lazyLoadSize}${this.queryParams ? `&${this.queryParams}` : ''}${this.search ? `&${this.searchParamName}=${this.search}` : ''}`;\n\t\t\t\t}\n\n\t\t\t\tlet res = await this.service.get(processedUrl, null, false, signal);\n\t\t\t\tconst filteredOptions = this.filterOutDrawnOptions(res);\n\t\t\t\tthis.loadedOptions.push(...this.processData(filteredOptions));\n\n\t\t\t\treturn filteredOptions;\n\t\t\t};\n\n\t\t\tconst list = document.createElement('wje-list');\n\n\t\t\tinfiniteScroll.append(list);\n\t\t\tinfiniteScroll.append(loader);\n\n\t\t\tif (this.hasAttribute('attached') && !this.hasSearch) {\n\t\t\t\tthis.appendChild(infiniteScroll);\n\t\t\t\tthis.drawPreloadedElements.forEach((el) => {\n\t\t\t\t\tlist.appendChild(el);\n\t\t\t\t});\n\t\t\t\tthis.infiniteScroll = infiniteScroll;\n\t\t\t}\n\t\t} else {\n\t\t\tthis.response = await this.getPages();\n\n\t\t\tlet optionsData = this.filterOutDrawnOptions(this.response);\n\t\t\toptionsData = this.processData(optionsData);\n\n\t\t\tthis.loadedOptions.push(...optionsData);\n\n\t\t\tthis.append(...optionsData.map(this.htmlItem));\n\n\t\t\tevent.dispatchCustomEvent(this, 'wje-options:load', {});\n\t\t}\n\n\t\treturn fragment;\n\t}\n\n\t/**\n\t * Syncs ARIA attributes on the host element.\n\t */\n\tsyncAria() {\n\t\tconst isMultiple = this.closest('wje-select')?.hasAttribute('multiple');\n\t\tthis.setAriaState({\n\t\t\trole: 'listbox',\n\t\t\tmultiselectable: isMultiple ? 'true' : undefined,\n\t\t});\n\t}\n\n\tafterDraw() {\n\t\tevent.addListener(this.infiniteScroll, 'wje-infinite-scroll:load', null, this.dispatchOptionsLoadEvent);\n\t}\n\n\tdispatchOptionsLoadEvent = (e) => {\n\t\t// Wait for next paint cycle to ensure options are in DOM\n\t\trequestAnimationFrame(() => {\n\t\t\trequestAnimationFrame(() => {\n\t\t\t\tevent.dispatchCustomEvent(this, 'wje-options:load', {});\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Processes the provided data based on the optional array path set in the instance.\n\t * @param {object} data The input data to be processed.\n\t * @returns {Array} The resolved options array from the data or an empty array if no match is found.\n\t */\n\tprocessData(data) {\n\t\tconst splittedOptionArrayPath = this.optionArrayPath ? this.optionArrayPath?.split('.') : null;\n\t\tlet options = data;\n\n\t\tsplittedOptionArrayPath?.forEach((path) => {\n\t\t\toptions = options[path];\n\t\t});\n\n\t\treturn options ?? [];\n\t}\n\n\t/**\n\t * Filters out options from the response object that have already been drawn, based on the specified option array path.\n\t * @param {object} response The response object containing data to process.\n\t * @returns {object} The filtered response object with drawn options removed.\n\t */\n\tfilterOutDrawnOptions(response) {\n\t\tconst splittedOptionArrayPath = this.optionArrayPath ? this.optionArrayPath?.split('.') : [];\n\t\tlet filteredResponse = structuredClone(response);\n\n\t\tfilteredResponse = this.recursiveUpdate(filteredResponse, splittedOptionArrayPath);\n\t\treturn filteredResponse;\n\t}\n\n\t/**\n\t * Recursively updates the object based on the provided path to the property.\n\t * @param {object | Array | null} object\n\t * @param {Array<string> | null} pathToProperty\n\t * @returns {object | Array | null}\n\t */\n\trecursiveUpdate = (object, pathToProperty) => {\n\t\tif (pathToProperty.length === 0) {\n\t\t\tif (Array.isArray(object)) {\n\t\t\t\treturn object.filter(\n\t\t\t\t\t(option) =>\n\t\t\t\t\t\t!this.loadedOptions.some(\n\t\t\t\t\t\t\t(loadedOption) => loadedOption[this.itemValue] === option[this.itemValue]\n\t\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconsole.error('Expected an array but got:', object, pathToProperty);\n\t\t\t\treturn [];\n\t\t\t}\n\t\t}\n\n\t\tconst [currentPath, ...remainingPath] = pathToProperty;\n\t\tif (remainingPath.length > 0) {\n\t\t\tobject[currentPath] = this.recursiveUpdate(object[currentPath], remainingPath);\n\t\t} else {\n\t\t\tobject[currentPath] =\n\t\t\t\tobject[currentPath]?.filter(\n\t\t\t\t\t(option) =>\n\t\t\t\t\t\t!this.loadedOptions.some(\n\t\t\t\t\t\t\t(loadedOption) => loadedOption[this.itemValue] === option[this.itemValue]\n\t\t\t\t\t\t)\n\t\t\t\t) ?? [];\n\t\t}\n\t\treturn object;\n\t};\n\n\t/**\n\t * Generates an HTML option element based on the provided item.\n\t * @param {object} item The item to generate the option element for.\n\t * @returns {HTMLElement} The generated option element.\n\t */\n\thtmlItem = (item) => {\n\t\tlet option = document.createElement('wje-option');\n\n\t\tif (item[this.itemValue] === null || item[this.itemValue] === undefined) {\n\t\t\tconsole.warn(`The item ${JSON.stringify(item)} does not have the property ${this.itemValue}`);\n\t\t}\n\n\t\tif (item[this.itemText] === null || item[this.itemText] === undefined) {\n\t\t\tconsole.warn(`The item ${JSON.stringify(item)} does not have the property ${this.itemText}`);\n\t\t}\n\n\t\toption.setAttribute('value', item[this.itemValue] ?? '');\n\t\toption.innerText = item[this.itemText] ?? '';\n\n\t\treturn option;\n\t};\n\n\t/**\n\t * Fetches the pages from the provided URL.\n\t * @param {number} page The page number to fetch.\n\t * @returns {Promise<object>} The fetched data.\n\t * @throws Will throw an error if the response is not ok.\n\t */\n\tasync getPages(page) {\n\t\tconst response = await fetch(this.url);\n\t\tif (!response.ok) {\n\t\t\tthrow new Error(`An error occurred: ${response.status}`);\n\t\t}\n\t\treturn await response.json();\n\t}\n\n\t/**\n\t * Finds the selected option data based on the given selected option values.\n\t * @param {Array} selectedOptionValues The array of selected option values.\n\t * @returns {Array} - The array of option data that matches the selected option values.\n\t */\n\tfindSelectedOptionData(selectedOptionValues = []) {\n\t\treturn this.options.filter((option) => selectedOptionValues.includes(option[this.itemValue]));\n\t}\n\n\t/**\n\t * Adds an option to the element.\n\t * @param {object} optionData The data of the option to be added.\n\t */\n\taddOption(optionData) {\n\t\tif (this.loadedOptions.some((option) => option[this.itemValue] === optionData[this.itemValue])) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst item = this.htmlItem(optionData);\n\t\tconst lazyList = this.#getLazyList();\n\t\tthis.#drawPreloadedElements.push(item);\n\n\t\tif (lazyList) {\n\t\t\tlazyList.appendChild(item);\n\t\t} else {\n\t\t\tthis.prepend(item);\n\t\t}\n\n\t\tthis.loadedOptions.push(optionData);\n\t}\n\n\t#getLazyList() {\n\t\tif (!this.lazy) return null;\n\n\t\treturn this.infiniteScroll?.querySelector('wje-list') ?? this.querySelector(':scope > wje-infinite-scroll > wje-list');\n\t}\n\n\t/**\n\t * Adds options to the element.\n\t * @param {Array} optionsData The array of option data to be added.\n\t * @param {boolean} [silent] Whether to suppress events triggered by adding options.\n\t */\n\taddOptions(optionsData = [], silent = false) {\n\t\tif (Array.isArray(optionsData)) optionsData?.forEach((od) => this.addOption(od, silent));\n\t\telse this.addOption(optionsData, silent);\n\t}\n\n\tbeforeDisconnect() {\n\t\tevent.removeListener(this.infiniteScroll, 'wje-infinite-scroll:load', null, this.dispatchOptionsLoadEvent);\n\t}\n}\n","import Options from './options.element.js';\n\nexport default Options;\n\nOptions.define('wje-options', Options);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAee,MAAM,gBAAgB,UAAU;AAAA,EAM9C,cAAc;AACb,UAAK;AAPQ;AAEd,uCAAiB,CAAA;AAEjB,+CAAyB,CAAA;AAMzB,wCAAe;AAAA,MACd,cAAc;AAAA,MACd,uBAAuB;AAAA,MACvB,YAAY;AAAA,IACd;AAqOC,qCAAY;AAmHZ,oDAA2B,CAAC,MAAM;AAEjC,4BAAsB,MAAM;AAC3B,8BAAsB,MAAM;AAC3B,gBAAM,oBAAoB,MAAM,oBAAoB,CAAA,CAAE;AAAA,QACvD,CAAC;AAAA,MACF,CAAC;AAAA,IACF;AAqCA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2CAAkB,CAAC,QAAQ,mBAAmB;;AAC7C,U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C,WAAW,OAAO,KAAK,SAAS,MAAM,WAAW,KAAK,SAAS,CAAC,GAAG;AAC/F;AAAA,IACD;AAEA,UAAM,OAAO,KAAK,SAAS,UAAU;AACrC,UAAM,WAAW,sBAAK,oCAAL;AACjB,uBAAK,wBAAuB,KAAK,IAAI;AAErC,QAAI,UAAU;AACb,eAAS,YAAY,IAAI;AAAA,IAC1B,OAAO;AACN,WAAK,QAAQ,IAAI;AAAA,IAClB;AAEA,SAAK,cAAc,KAAK,UAAU;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,WAAW,cAAc,IAAI,SAAS,OAAO;AAC5C,QAAI,MAAM,QAAQ,WAAW,EAAG,4CAAa,QAAQ,CAAC,OAAO,KAAK,UAAU,IAAI,MAAM;AAAA,QACjF,MAAK,UAAU,aAAa,MAAM;AAAA,EACxC;AAAA,EAEA,mBAAmB;AAClB,UAAM,eAAe,KAAK,gBAAgB,4BAA4B,MAAM,KAAK,wBAAwB;AAAA,EAC1G;AACD;AApgBC;AAEA;AAJc;AAmfd,iBAAY,WAAG;;AACd,MAAI,CAAC,KAAK,KAAM,QAAO;AAEvB,WAAO,UAAK,mBAAL,mBAAqB,cAAc,gBAAe,KAAK,cAAc,yCAAyC;AACtH;AClgBD,QAAQ,OAAO,eAAe,OAAO;"}
|
package/dist/wje-popup.js
CHANGED
package/dist/wje-select.js
CHANGED
|
@@ -9,7 +9,7 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
|
|
|
9
9
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
10
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
11
11
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
12
|
-
var _addedOptions, _htmlOptions, _Select_instances, htmlSelectedItem_fn, getSelectedOptions_fn, hasVisibleOptions_fn, updateEmptyState_fn, _applySearchFilter, _onMenuItemClickCapture, syncOptionCheckbox_fn;
|
|
12
|
+
var _addedOptions, _htmlOptions, _portaledOptionRecords, _Select_instances, htmlSelectedItem_fn, getSelectedOptions_fn, hasVisibleOptions_fn, updateEmptyState_fn, _applySearchFilter, _handleOptionsLoad, _onMenuItemClickCapture, _syncPortalStyles, copyPortalCustomProperties_fn, syncOptionOwners_fn, portalOptions_fn, _restorePortaledOptions, focusFindInput_fn, syncOptionCheckbox_fn;
|
|
13
13
|
import { F as FormAssociatedElement } from "./form-associated-element-DEQ4y-jn.js";
|
|
14
14
|
import { event } from "./event.js";
|
|
15
15
|
import { Localizer } from "./localize.js";
|
|
@@ -22,7 +22,7 @@ import Input from "./wje-input.js";
|
|
|
22
22
|
import Option from "./wje-option.js";
|
|
23
23
|
import Options from "./wje-options.js";
|
|
24
24
|
import Checkbox from "./wje-checkbox.js";
|
|
25
|
-
import { P as Popup } from "./popup.element-
|
|
25
|
+
import { P as Popup } from "./popup.element-C8-g3WLs.js";
|
|
26
26
|
const styles = "/*\n[ WJ Select ]\n*/\n\n:host {\n margin-bottom: var(--wje-select-margin-bottom);\n width: 100%;\n display: block;\n [slot='arrow'] {\n transform: rotate(0deg);\n transition: all 0.2s ease-in;\n }\n label {\n margin: var(--wje-select-label-margin);\n padding: var(--wje-select-label-padding);\n display: var(--wje-select-label-display);\n opacity: 1;\n cursor: text;\n transition: opacity 0.2s ease;\n line-height: var(--wje-select-label-line-height);\n font-size: var(--wje-select-label-font-size);\n }\n}\n\n.native-select {\n position: relative;\n &.default {\n .wrapper {\n display: block;\n background-color: var(--wje-select-background);\n border-width: var(--wje-select-border-width);\n border-style: var(--wje-select-border-style);\n border-color: var(--wje-select-border-color);\n border-radius: var(--wje-select-border-radius);\n padding-inline: 0.5rem;\n padding-top: 0.125rem;\n padding-bottom: 0.125rem;\n }\n .input-wrapper {\n padding: 0;\n min-height: 28px;\n margin-top: -4px;\n }\n &.focused {\n wje-label {\n opacity: 0.67;\n font-size: 12px;\n letter-spacing: normal;\n }\n }\n label {\n &.fade {\n opacity: 0.5;\n font-size: 12px;\n letter-spacing: normal;\n }\n }\n }\n &.standard {\n .wrapper {\n height: var(--wje-select-height);\n box-sizing: border-box;\n background-color: var(--wje-select-background);\n border-width: var(--wje-select-border-width);\n border-style: var(--wje-select-border-style);\n border-color: var(--wje-select-border-color);\n border-radius: var(--wje-select-border-radius);\n }\n .input-wrapper {\n background: transparent;\n width: 100%;\n }\n slot[name='error'] {\n position: static;\n\n background: transparent;\n padding: 0.25rem 0;\n left: auto;\n transform: none;\n color: var(--wje-input-color-invalid);\n font-size: 12px;\n line-height: normal;\n }\n }\n}\n\n.wrapper {\n display: flex;\n width: 100%;\n}\n\n.input-wrapper {\n display: grid;\n grid-template-columns: auto 1fr auto auto auto;\n align-items: center;\n background-color: var(--wje-select-background);\n /*min-height: 28px;*/\n color: var(--wje-select-color);\n line-height: var(--wje-select-line-height);\n appearance: none;\n padding: 2px 0.5rem;\n font-size: 14px !important;\n font-weight: normal;\n vertical-align: middle;\n input[readonly] {\n pointer-events: none;\n caret-color: transparent;\n }\n}\n\ninput {\n color: var(--wje-select-color);\n line-height: var(--wje-select-line-height);\n font-size: 14px !important;\n font-weight: 400;\n letter-spacing: 0.01em;\n border: medium;\n height: 25px;\n min-height: 25px;\n padding: 0;\n background: none;\n box-shadow: none;\n width: 100%;\n outline: 0;\n font-size: 14px !important;\n}\n\n::placeholder {\n opacity: 1;\n}\n\n:host [active] {\n .wrapper {\n border-radius: var(--wje-select-border-radius);\n }\n [slot='arrow'] {\n transform: rotate(180deg);\n transition: all 0.2s ease-in;\n }\n}\n\n.options-wrapper {\n border-width: var(--wje-select-options-border-width);\n border-style: var(--wje-select-options-border-style);\n border-color: var(--wje-select-options-border-color);\n border-radius: var(--wje-select-options-border-radius);\n margin-top: calc(0px - var(--wje-select-border-width));\n background-color: var(--wje-select-options-background-color);\n overflow: hidden;\n}\n\n.find {\n margin-block: var(--wje-select-find-margin-block);\n margin-inline: var(--wje-select-find-margin-inline);\n width: var(--wje-select-find-width);\n}\n\n.list {\n overflow: auto;\n height: 100%;\n position: relative;\n}\n\n.list:has(.empty:not([hidden])) {\n min-height: 44px;\n}\n\n.empty {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: var(--wje-spacing-small);\n color: var(--wje-select-color);\n text-align: center;\n background-color: var(--wje-select-options-background-color);\n pointer-events: none;\n}\n\n.empty[hidden] {\n display: none;\n}\n\n.options-wrapper:has(.find) .list {\n height: calc(100% - 32px - 2 * var(--wje-select-find-margin-block));\n}\n\n:host([multiple]) input {\n position: absolute;\n z-index: -1;\n top: 0;\n left: 0;\n width: 0;\n height: 0;\n opacity: 0;\n}\n\n:host([multiple]) .chips {\n display: flex;\n flex: 1;\n align-items: center;\n flex-wrap: wrap;\n gap: var(--wje-spacing-3x-small);\n}\n\n:host([disabled]) .input-wrapper {\n opacity: 0.5;\n pointer-events: none;\n cursor: not-allowed;\n}\n\n.counter {\n padding-inline: 0.5rem;\n}\n\nwje-chip {\n --wje-chip-margin: 0 0.25rem 0 0;\n}\n\nwje-button {\n --wje-padding-top: 0.25rem;\n --wje-padding-start: 0.25rem;\n --wje-padding-end: 0.25rem;\n --wje-padding-bottom: 0.25rem;\n --wje-button-margin-inline: 0 0.25rem;\n}\n\n.slot-start,\n.slot-end {\n &:not(:empty) {\n margin-right: 0.5rem;\n }\n}\n\nslot[name='error'] {\n display: none;\n}\n\n:host([invalid]) slot[name='error'] {\n display: block;\n}\n\nslot[name='error'] {\n display: none;\n position: absolute;\n max-width: 100%;\n min-width: auto;\n border-radius: 50px;\n background-color: var(--wje-select-error-background-color, var(--wje-tooltip-background));\n padding: 0.25rem 0.5rem;\n top: 0;\n left: 50%;\n transform: translate(-50%, -50%);\n color: var(--wje-select-error-color, var(--wje-tooltip-color));\n font-size: var(--wje-font-size-small);\n width: max-content;\n line-height: normal;\n}\n\n.input-hidden{\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n padding: 0;\n margin: 0;\n opacity: 0;\n z-index: -1;\n}\n\n:host([required]) .wrapper::after {\n color: var(--wje-input-color-invalid);\n content: var(--wje-input-required-symbol);\n font-size: 24px;\n position: absolute;\n right: 12px;\n top: 0;\n}\n\n:host([required]) .standard .input-wrapper::after {\n right: 13px;\n top: -20px;\n}\n";
|
|
27
27
|
const _Select = class _Select extends FormAssociatedElement {
|
|
28
28
|
constructor() {
|
|
@@ -30,6 +30,7 @@ const _Select = class _Select extends FormAssociatedElement {
|
|
|
30
30
|
__privateAdd(this, _Select_instances);
|
|
31
31
|
__privateAdd(this, _addedOptions, []);
|
|
32
32
|
__privateAdd(this, _htmlOptions, []);
|
|
33
|
+
__privateAdd(this, _portaledOptionRecords, []);
|
|
33
34
|
/**
|
|
34
35
|
* An object representing component dependencies with their respective classes.
|
|
35
36
|
* Each property in the object maps a custom component name (as a string key)
|
|
@@ -146,6 +147,30 @@ const _Select = class _Select extends FormAssociatedElement {
|
|
|
146
147
|
__privateMethod(this, _Select_instances, updateEmptyState_fn).call(this);
|
|
147
148
|
}
|
|
148
149
|
});
|
|
150
|
+
__privateAdd(this, _handleOptionsLoad, (e) => {
|
|
151
|
+
var _a;
|
|
152
|
+
this.selectedOptions.forEach((option) => {
|
|
153
|
+
this.getAllOptions().forEach((el) => {
|
|
154
|
+
if (el.value === option.value) {
|
|
155
|
+
el.selected = true;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
const attrValue = ((_a = this.getAttribute("value")) == null ? void 0 : _a.split(" ")) || [];
|
|
160
|
+
attrValue.forEach((val) => {
|
|
161
|
+
const existingOption = Array.from(this.getAllOptions()).find((el) => el.value === val);
|
|
162
|
+
if (existingOption) {
|
|
163
|
+
existingOption.selected = true;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
this.selectedOptions = __privateMethod(this, _Select_instances, getSelectedOptions_fn).call(this);
|
|
167
|
+
this.selections(true);
|
|
168
|
+
__privateMethod(this, _Select_instances, updateEmptyState_fn).call(this);
|
|
169
|
+
__privateMethod(this, _Select_instances, syncOptionOwners_fn).call(this);
|
|
170
|
+
__privateMethod(this, _Select_instances, portalOptions_fn).call(this);
|
|
171
|
+
this.list.scrollTo(0, 0);
|
|
172
|
+
event.dispatchCustomEvent(this.popup, "wje-popup:content-ready");
|
|
173
|
+
});
|
|
149
174
|
/**
|
|
150
175
|
* Prevent closing the parent <wje-select>'s popup when a nested <wje-dropdown>
|
|
151
176
|
* menu item is clicked. Closes only the dropdown that owns the clicked item.
|
|
@@ -163,6 +188,31 @@ const _Select = class _Select extends FormAssociatedElement {
|
|
|
163
188
|
}
|
|
164
189
|
e.stopPropagation();
|
|
165
190
|
});
|
|
191
|
+
__privateAdd(this, _syncPortalStyles, (e) => {
|
|
192
|
+
var _a;
|
|
193
|
+
const container = (_a = e.detail) == null ? void 0 : _a.container;
|
|
194
|
+
if (!(container instanceof HTMLElement)) return;
|
|
195
|
+
container.setAttribute("data-wje-select-portal", "");
|
|
196
|
+
__privateMethod(this, _Select_instances, copyPortalCustomProperties_fn).call(this, container);
|
|
197
|
+
__privateMethod(this, _Select_instances, portalOptions_fn).call(this, container);
|
|
198
|
+
if (container.querySelector("style[data-wje-select-portal-style]")) return;
|
|
199
|
+
const style = document.createElement("style");
|
|
200
|
+
style.setAttribute("data-wje-select-portal-style", "");
|
|
201
|
+
style.textContent = _Select.portalStyles;
|
|
202
|
+
container.prepend(style);
|
|
203
|
+
});
|
|
204
|
+
__privateAdd(this, _restorePortaledOptions, () => {
|
|
205
|
+
if (__privateGet(this, _portaledOptionRecords).length === 0) return;
|
|
206
|
+
__privateGet(this, _portaledOptionRecords).forEach(({ option, placeholder }) => {
|
|
207
|
+
option.removeEventListener("wje-option:change", this.optionChange);
|
|
208
|
+
option.removeAttribute("data-wje-select-portaled-option");
|
|
209
|
+
if (placeholder.parentNode) {
|
|
210
|
+
placeholder.parentNode.insertBefore(option, placeholder);
|
|
211
|
+
placeholder.remove();
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
__privateSet(this, _portaledOptionRecords, []);
|
|
215
|
+
});
|
|
166
216
|
this.localizer = new Localizer(this);
|
|
167
217
|
this.counterEl = null;
|
|
168
218
|
this._wasOppened = false;
|
|
@@ -258,6 +308,32 @@ const _Select = class _Select extends FormAssociatedElement {
|
|
|
258
308
|
get defaultValue() {
|
|
259
309
|
return this.getAttribute("value") ?? "";
|
|
260
310
|
}
|
|
311
|
+
/**
|
|
312
|
+
* Sets or removes the `portaled` attribute on the select.
|
|
313
|
+
* Mirrors the dropdown API so popup content can be rendered in a portal root.
|
|
314
|
+
* @param {boolean|string} value Determines whether and where the popup should be portaled.
|
|
315
|
+
*/
|
|
316
|
+
set portaled(value) {
|
|
317
|
+
if (value) {
|
|
318
|
+
this.setAttribute("portaled", value);
|
|
319
|
+
} else {
|
|
320
|
+
this.removeAttribute("portaled");
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Getter for the `portaled` attribute value.
|
|
325
|
+
* @returns {string} The configured portal target or an empty string for the default body portal.
|
|
326
|
+
*/
|
|
327
|
+
get portaled() {
|
|
328
|
+
return this.getAttribute("portaled") || "";
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Checks whether popup content should be portaled.
|
|
332
|
+
* @returns {boolean} True when the `portaled` attribute is present.
|
|
333
|
+
*/
|
|
334
|
+
get isPortaled() {
|
|
335
|
+
return this.hasAttribute("portaled");
|
|
336
|
+
}
|
|
261
337
|
/**
|
|
262
338
|
* Sets the trigger value.
|
|
263
339
|
* @param {string} value The trigger value to set.
|
|
@@ -452,7 +528,7 @@ const _Select = class _Select extends FormAssociatedElement {
|
|
|
452
528
|
* @returns {Array<string>}
|
|
453
529
|
*/
|
|
454
530
|
static get observedAttributes() {
|
|
455
|
-
return ["active", "disabled", "readonly"];
|
|
531
|
+
return ["active", "disabled", "readonly", "portaled"];
|
|
456
532
|
}
|
|
457
533
|
/**
|
|
458
534
|
* Sets up the attributes for the component.
|
|
@@ -558,6 +634,9 @@ const _Select = class _Select extends FormAssociatedElement {
|
|
|
558
634
|
popup.setAttribute("size", "");
|
|
559
635
|
popup.setAttribute("part", "popup");
|
|
560
636
|
popup.setAttribute("offset", this.offset);
|
|
637
|
+
if (this.isPortaled) {
|
|
638
|
+
popup.setAttribute("portal", this.portaled);
|
|
639
|
+
}
|
|
561
640
|
if ((this.lazy || this.querySelector("wje-options")) && !this._wasOppened) {
|
|
562
641
|
popup.setAttribute("loader", "");
|
|
563
642
|
} else {
|
|
@@ -589,7 +668,7 @@ const _Select = class _Select extends FormAssociatedElement {
|
|
|
589
668
|
find.setAttribute("part", "find");
|
|
590
669
|
find.clearable = true;
|
|
591
670
|
find.classList.add("find");
|
|
592
|
-
optionsWrapper.
|
|
671
|
+
optionsWrapper.append(find);
|
|
593
672
|
this.findEl = find;
|
|
594
673
|
}
|
|
595
674
|
let slotFooter = document.createElement("slot");
|
|
@@ -634,8 +713,11 @@ const _Select = class _Select extends FormAssociatedElement {
|
|
|
634
713
|
}
|
|
635
714
|
this.syncAria();
|
|
636
715
|
(_a = this.getAllOptions()) == null ? void 0 : _a.forEach((option) => {
|
|
716
|
+
option.ownerSelect = this;
|
|
637
717
|
this.optionCheckSlot(option);
|
|
638
718
|
});
|
|
719
|
+
event.addListener(this.popup, "wje-router:rebind", null, __privateGet(this, _syncPortalStyles));
|
|
720
|
+
event.addListener(this.popup, "wje-portal:restored", null, __privateGet(this, _restorePortaledOptions));
|
|
639
721
|
this.selectedOptions = __privateMethod(this, _Select_instances, getSelectedOptions_fn).call(this);
|
|
640
722
|
this.selectOptions(this.value, true);
|
|
641
723
|
if (this.lazy) {
|
|
@@ -663,6 +745,7 @@ const _Select = class _Select extends FormAssociatedElement {
|
|
|
663
745
|
let subtractHeight = rect.height + totalHeight;
|
|
664
746
|
this.list.style.height = `calc(100% - ${subtractHeight}px)`;
|
|
665
747
|
}
|
|
748
|
+
__privateMethod(this, _Select_instances, focusFindInput_fn).call(this);
|
|
666
749
|
});
|
|
667
750
|
__privateSet(this, _htmlOptions, Array.from(this.querySelectorAll(":scope > wje-option")).map((option) => {
|
|
668
751
|
return {
|
|
@@ -700,28 +783,8 @@ const _Select = class _Select extends FormAssociatedElement {
|
|
|
700
783
|
e.stopPropagation();
|
|
701
784
|
this.clearSelections();
|
|
702
785
|
});
|
|
703
|
-
this.list.addEventListener("wje-options:load", (
|
|
704
|
-
|
|
705
|
-
this.selectedOptions.forEach((option) => {
|
|
706
|
-
this.getAllOptions().forEach((el) => {
|
|
707
|
-
if (el.value === option.value) {
|
|
708
|
-
el.selected = true;
|
|
709
|
-
}
|
|
710
|
-
});
|
|
711
|
-
});
|
|
712
|
-
const attrValue = ((_a2 = this.getAttribute("value")) == null ? void 0 : _a2.split(" ")) || [];
|
|
713
|
-
attrValue.forEach((val) => {
|
|
714
|
-
const existingOption = Array.from(this.getAllOptions()).find((el) => el.value === val);
|
|
715
|
-
if (existingOption) {
|
|
716
|
-
existingOption.selected = true;
|
|
717
|
-
}
|
|
718
|
-
});
|
|
719
|
-
this.selectedOptions = __privateMethod(this, _Select_instances, getSelectedOptions_fn).call(this);
|
|
720
|
-
this.selections(true);
|
|
721
|
-
__privateMethod(this, _Select_instances, updateEmptyState_fn).call(this);
|
|
722
|
-
this.list.scrollTo(0, 0);
|
|
723
|
-
event.dispatchCustomEvent(this.popup, "wje-popup:content-ready");
|
|
724
|
-
});
|
|
786
|
+
this.list.addEventListener("wje-options:load", __privateGet(this, _handleOptionsLoad));
|
|
787
|
+
this.addEventListener("wje-options:load", __privateGet(this, _handleOptionsLoad));
|
|
725
788
|
if (this.hasAttribute("find") && this.findEl instanceof HTMLElement) {
|
|
726
789
|
event.addListener(this.findEl, "keyup", "", __privateGet(this, _applySearchFilter));
|
|
727
790
|
event.addListener(this.findEl, "wje-input:clear", "", __privateGet(this, _applySearchFilter));
|
|
@@ -733,7 +796,9 @@ const _Select = class _Select extends FormAssociatedElement {
|
|
|
733
796
|
* @returns {NodeList} The options as HTML.
|
|
734
797
|
*/
|
|
735
798
|
getAllOptions() {
|
|
736
|
-
|
|
799
|
+
const localOptions = Array.from(this.querySelectorAll("wje-option"));
|
|
800
|
+
const portaledOptions = __privateGet(this, _portaledOptionRecords).map(({ option }) => option);
|
|
801
|
+
return Array.from(/* @__PURE__ */ new Set([...localOptions, ...portaledOptions]));
|
|
737
802
|
}
|
|
738
803
|
/**
|
|
739
804
|
* Handles changes in the selection for a component, updating internal values, input fields,
|
|
@@ -993,6 +1058,7 @@ const _Select = class _Select extends FormAssociatedElement {
|
|
|
993
1058
|
}
|
|
994
1059
|
}
|
|
995
1060
|
disconnectedCallback() {
|
|
1061
|
+
__privateGet(this, _restorePortaledOptions).call(this);
|
|
996
1062
|
document.removeEventListener("mousedown", __privateGet(this, _onMenuItemClickCapture), true);
|
|
997
1063
|
}
|
|
998
1064
|
/**
|
|
@@ -1014,6 +1080,7 @@ const _Select = class _Select extends FormAssociatedElement {
|
|
|
1014
1080
|
};
|
|
1015
1081
|
_addedOptions = new WeakMap();
|
|
1016
1082
|
_htmlOptions = new WeakMap();
|
|
1083
|
+
_portaledOptionRecords = new WeakMap();
|
|
1017
1084
|
_Select_instances = new WeakSet();
|
|
1018
1085
|
/**
|
|
1019
1086
|
* Processes the given item and retrieves the corresponding value from the selected options.
|
|
@@ -1032,7 +1099,7 @@ htmlSelectedItem_fn = function(item) {
|
|
|
1032
1099
|
* @returns {Array<Element>} An array of elements representing the options that are currently selected.
|
|
1033
1100
|
*/
|
|
1034
1101
|
getSelectedOptions_fn = function() {
|
|
1035
|
-
return
|
|
1102
|
+
return this.getAllOptions().filter((option) => option.hasAttribute("selected"));
|
|
1036
1103
|
};
|
|
1037
1104
|
/**
|
|
1038
1105
|
* Determines whether the select currently contains at least one visible option.
|
|
@@ -1055,7 +1122,51 @@ updateEmptyState_fn = function() {
|
|
|
1055
1122
|
this.emptyState.hidden = __privateMethod(this, _Select_instances, hasVisibleOptions_fn).call(this);
|
|
1056
1123
|
};
|
|
1057
1124
|
_applySearchFilter = new WeakMap();
|
|
1125
|
+
_handleOptionsLoad = new WeakMap();
|
|
1058
1126
|
_onMenuItemClickCapture = new WeakMap();
|
|
1127
|
+
_syncPortalStyles = new WeakMap();
|
|
1128
|
+
copyPortalCustomProperties_fn = function(container) {
|
|
1129
|
+
const style = getComputedStyle(this);
|
|
1130
|
+
for (let i = 0; i < style.length; i++) {
|
|
1131
|
+
const prop = style[i];
|
|
1132
|
+
if (prop.startsWith("--")) {
|
|
1133
|
+
container.style.setProperty(prop, style.getPropertyValue(prop));
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
};
|
|
1137
|
+
syncOptionOwners_fn = function() {
|
|
1138
|
+
this.getAllOptions().forEach((option) => {
|
|
1139
|
+
option.ownerSelect = this;
|
|
1140
|
+
});
|
|
1141
|
+
};
|
|
1142
|
+
portalOptions_fn = function(container = ((_a) => (_a = this.popup) == null ? void 0 : _a._portalContainer)()) {
|
|
1143
|
+
if (!(container instanceof HTMLElement)) return;
|
|
1144
|
+
const list = container.querySelector(".list");
|
|
1145
|
+
if (!(list instanceof HTMLElement)) return;
|
|
1146
|
+
const options = this.getAllOptions();
|
|
1147
|
+
options.forEach((option) => {
|
|
1148
|
+
if (__privateGet(this, _portaledOptionRecords).some((record) => record.option === option)) return;
|
|
1149
|
+
if (!option.parentNode) return;
|
|
1150
|
+
const placeholder = document.createComment("wje-select-portaled-option");
|
|
1151
|
+
option.parentNode.insertBefore(placeholder, option);
|
|
1152
|
+
option.ownerSelect = this;
|
|
1153
|
+
option.setAttribute("data-wje-select-portaled-option", "");
|
|
1154
|
+
option.addEventListener("wje-option:change", this.optionChange);
|
|
1155
|
+
__privateGet(this, _portaledOptionRecords).push({ option, placeholder });
|
|
1156
|
+
list.insertBefore(option, this.emptyState);
|
|
1157
|
+
});
|
|
1158
|
+
};
|
|
1159
|
+
_restorePortaledOptions = new WeakMap();
|
|
1160
|
+
focusFindInput_fn = function() {
|
|
1161
|
+
if (!this.hasAttribute("find") || !(this.findEl instanceof HTMLElement)) return;
|
|
1162
|
+
requestAnimationFrame(() => {
|
|
1163
|
+
var _a;
|
|
1164
|
+
const input = this.findEl.input || ((_a = this.findEl.shadowRoot) == null ? void 0 : _a.querySelector("input"));
|
|
1165
|
+
if (input instanceof HTMLElement) {
|
|
1166
|
+
input.focus();
|
|
1167
|
+
}
|
|
1168
|
+
});
|
|
1169
|
+
};
|
|
1059
1170
|
syncOptionCheckbox_fn = function(option) {
|
|
1060
1171
|
const checkbox = option.querySelector('wje-checkbox[slot="check"]');
|
|
1061
1172
|
if (!checkbox) return;
|
|
@@ -1068,6 +1179,54 @@ syncOptionCheckbox_fn = function(option) {
|
|
|
1068
1179
|
}
|
|
1069
1180
|
};
|
|
1070
1181
|
__publicField(_Select, "_instanceId", 0);
|
|
1182
|
+
__publicField(_Select, "portalStyles", `
|
|
1183
|
+
[data-wje-select-portal] .options-wrapper {
|
|
1184
|
+
border-width: var(--wje-select-options-border-width, 1px);
|
|
1185
|
+
border-style: var(--wje-select-options-border-style, solid);
|
|
1186
|
+
border-color: var(--wje-select-options-border-color, var(--wje-border-color, #dcdfe3));
|
|
1187
|
+
border-radius: var(--wje-select-options-border-radius, var(--wje-border-radius, 4px));
|
|
1188
|
+
margin-top: calc(0px - var(--wje-select-border-width, 1px));
|
|
1189
|
+
background-color: var(--wje-select-options-background-color, var(--wje-color-contrast-0, #fff));
|
|
1190
|
+
overflow: hidden;
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
[data-wje-select-portal] .find {
|
|
1194
|
+
margin-block: var(--wje-select-find-margin-block, .5rem);
|
|
1195
|
+
margin-inline: var(--wje-select-find-margin-inline, .5rem);
|
|
1196
|
+
width: var(--wje-select-find-width, calc(100% - 1rem));
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
[data-wje-select-portal] .list {
|
|
1200
|
+
overflow: auto;
|
|
1201
|
+
height: 100%;
|
|
1202
|
+
position: relative;
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
[data-wje-select-portal] .list:has(.empty:not([hidden])) {
|
|
1206
|
+
min-height: 44px;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
[data-wje-select-portal] .empty {
|
|
1210
|
+
position: absolute;
|
|
1211
|
+
inset: 0;
|
|
1212
|
+
display: flex;
|
|
1213
|
+
align-items: center;
|
|
1214
|
+
justify-content: center;
|
|
1215
|
+
padding: var(--wje-spacing-small, 1rem);
|
|
1216
|
+
color: var(--wje-select-color, inherit);
|
|
1217
|
+
text-align: center;
|
|
1218
|
+
background-color: var(--wje-select-options-background-color, var(--wje-color-contrast-0, #fff));
|
|
1219
|
+
pointer-events: none;
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
[data-wje-select-portal] .empty[hidden] {
|
|
1223
|
+
display: none;
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
[data-wje-select-portal] .options-wrapper:has(.find) .list {
|
|
1227
|
+
height: calc(100% - 32px - 2 * var(--wje-select-find-margin-block, .5rem));
|
|
1228
|
+
}
|
|
1229
|
+
`);
|
|
1071
1230
|
let Select = _Select;
|
|
1072
1231
|
Select.define("wje-select", Select);
|
|
1073
1232
|
export {
|