@ui5/webcomponents-base 2.0.0-rc.6 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +1 -4
- package/dist/.tsbuildinfo +1 -1
- package/dist/UI5Element.d.ts +9 -8
- package/dist/UI5Element.js +111 -108
- package/dist/UI5Element.js.map +1 -1
- package/dist/UI5ElementMetadata.d.ts +6 -15
- package/dist/UI5ElementMetadata.js +3 -71
- package/dist/UI5ElementMetadata.js.map +1 -1
- package/dist/asset-registries/Icons.d.ts +1 -1
- package/dist/asset-registries/Icons.js.map +1 -1
- package/dist/converters/DOMReference.d.ts +5 -0
- package/dist/converters/DOMReference.js +13 -0
- package/dist/converters/DOMReference.js.map +1 -0
- package/dist/custom-elements-internal.json +15 -275
- package/dist/custom-elements.json +15 -269
- package/dist/decorators/property.js +1 -1
- package/dist/decorators/property.js.map +1 -1
- package/dist/delegate/ItemNavigation.d.ts +1 -1
- package/dist/delegate/ItemNavigation.js.map +1 -1
- package/dist/features/InputElementsFormSupport.d.ts +1 -1
- package/dist/features/InputElementsFormSupport.js.map +1 -1
- package/dist/features/OpenUI5Support.js +3 -0
- package/dist/features/OpenUI5Support.js.map +1 -1
- package/dist/generated/VersionInfo.js +3 -3
- package/dist/generated/VersionInfo.js.map +1 -1
- package/dist/prod/UI5Element.js +1 -1
- package/dist/prod/UI5Element.js.map +3 -3
- package/dist/prod/UI5ElementMetadata.js +1 -1
- package/dist/prod/UI5ElementMetadata.js.map +3 -3
- package/dist/prod/asset-registries/Icons.js +1 -1
- package/dist/prod/asset-registries/Icons.js.map +2 -2
- package/dist/prod/converters/DOMReference.js +2 -0
- package/dist/prod/converters/DOMReference.js.map +7 -0
- package/dist/prod/decorators/property.js +1 -1
- package/dist/prod/decorators/property.js.map +2 -2
- package/dist/prod/delegate/ItemNavigation.js.map +1 -1
- package/dist/prod/features/InputElementsFormSupport.js.map +1 -1
- package/dist/prod/features/OpenUI5Support.js +1 -1
- package/dist/prod/features/OpenUI5Support.js.map +2 -2
- package/dist/prod/generated/VersionInfo.js +1 -1
- package/dist/prod/generated/VersionInfo.js.map +2 -2
- package/dist/prod/util/AriaLabelHelper.js.map +1 -1
- package/dist/util/AriaLabelHelper.js.map +1 -1
- package/dist/util/getClassCopy.d.ts +5 -2
- package/package.json +3 -3
- package/dist/prod/types/CSSColor.js +0 -2
- package/dist/prod/types/CSSColor.js.map +0 -7
- package/dist/prod/types/CSSSize.js +0 -2
- package/dist/prod/types/CSSSize.js.map +0 -7
- package/dist/prod/types/DOMReference.js +0 -2
- package/dist/prod/types/DOMReference.js.map +0 -7
- package/dist/prod/types/DataType.js +0 -2
- package/dist/prod/types/DataType.js.map +0 -7
- package/dist/prod/types/Float.js +0 -2
- package/dist/prod/types/Float.js.map +0 -7
- package/dist/prod/types/Integer.js +0 -2
- package/dist/prod/types/Integer.js.map +0 -7
- package/dist/types/CSSColor.d.ts +0 -11
- package/dist/types/CSSColor.js +0 -14
- package/dist/types/CSSColor.js.map +0 -1
- package/dist/types/CSSSize.d.ts +0 -11
- package/dist/types/CSSSize.js +0 -14
- package/dist/types/CSSSize.js.map +0 -1
- package/dist/types/DOMReference.d.ts +0 -13
- package/dist/types/DOMReference.js +0 -21
- package/dist/types/DOMReference.js.map +0 -1
- package/dist/types/DataType.d.ts +0 -20
- package/dist/types/DataType.js +0 -39
- package/dist/types/DataType.js.map +0 -1
- package/dist/types/Float.d.ts +0 -14
- package/dist/types/Float.js +0 -18
- package/dist/types/Float.js.map +0 -1
- package/dist/types/Integer.d.ts +0 -14
- package/dist/types/Integer.js +0 -18
- package/dist/types/Integer.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/delegate/ItemNavigation.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\tisDown,\n\tisUp,\n\tisLeft,\n\tisRight,\n\tisHome,\n\tisEnd,\n\tisPageDown,\n\tisPageUp,\n} from \"../Keys.js\";\nimport getActiveElement from \"../util/getActiveElement.js\";\n\nimport NavigationMode from \"../types/NavigationMode.js\";\nimport ItemNavigationBehavior from \"../types/ItemNavigationBehavior.js\";\n\nimport type UI5Element from \"../UI5Element.js\";\nimport { instanceOfUI5Element } from \"../UI5Element.js\";\n\ninterface ITabbable {\n\tid: string,\n\tforcedTabIndex: string,\n}\n\ntype ItemNavigationOptions = {\n\tcurrentIndex?: number,\n\tnavigationMode?: NavigationMode,\n\trowSize?: number\n\tskipItemsSize?: number,\n\tbehavior?: ItemNavigationBehavior,\n\tgetItemsCallback: () => Array<ITabbable>,\n\taffectedPropertiesNames?: Array<string>,\n};\n\n/**\n * The ItemNavigation class manages the calculations to determine the correct \"tabindex\" for a group of related items inside a root component.\n * Important: ItemNavigation only does the calculations and does not change \"tabindex\" directly, this is a responsibility of the developer.\n *\n * The keys that trigger ItemNavigation are:\n * - Up/down\n * - Left/right\n * - Home/End\n *\n * Usage:\n * 1) Use the \"getItemsCallback\" constructor property to pass a callback to ItemNavigation, which, whenever called, will return the list of items to navigate among.\n *\n * Each item passed to ItemNavigation via \"getItemsCallback\" must be:\n * - A) either a UI5Element with a \"forcedTabIndex\" property\n * - B) or an Object with \"id\" and \"forcedTabIndex\" properties which represents a part of the root component's shadow DOM.\n * The \"id\" must be a valid ID within the shadow root of the component ItemNavigation operates on.\n * This object must not be a DOM object because, as said, ItemNavigation will not set \"tabindex\" on it. It must be a representation of a DOM object only\n * and the developer has the responsibility to update the \"tabindex\" in the component's DOM.\n * - C) a combination of the above\n *\n * Whenever the user navigates with the keyboard, ItemNavigation will modify the \"forcedTabIndex\" properties of the items.\n * It is the items' responsibilities to re-render themselves and apply the correct value of \"tabindex\" (i.e. to map the \"forcedTabIndex\" ItemNavigation set to them to the \"tabindex\" property).\n * If the items of the ItemNavigation are UI5Elements themselves, this can happen naturally since they will be invalidated by their \"forcedTabIndex\" property.\n * If the items are Objects with \"id\" and \"forcedTabIndex\" however, it is the developer's responsibility to apply these and the easiest way is to have the root component invalidated by ItemNavigation.\n * To do so, set the \"affectedPropertiesNames\" constructor property to point to one or more of the root component's properties that need refreshing when \"forcedTabIndex\" is changed deeply.\n *\n * 2) Call the \"setCurrentItem\" method of ItemNavigation whenever you want to change the current item.\n * This is most commonly required if the user for example clicks on an item and thus selects it directly.\n * Pass as the only argument to \"setCurrentItem\" the item that becomes current (must be one of the items, returned by \"getItemsCallback\").\n *\n * @class\n * @public\n */\nclass ItemNavigation {\n\trootWebComponent: UI5Element;\n\n\t_getItems: () => Array<ITabbable>;\n\n\t_currentIndex: number;\n\n\t_rowSize: number;\n\n\t_behavior: ItemNavigationBehavior;\n\n\t_navigationMode: NavigationMode;\n\n\t_affectedPropertiesNames: Array<string>;\n\n\t_skipItemsSize: number | null;\n\n\t_initBound: () => void;\n\n\t/**\n\t *\n\t * @param rootWebComponent the component to operate on (component that slots or contains within its shadow root the items the user navigates among)\n\t * @param {ItemNavigationOptions} options Object with configuration options:\n\t * - currentIndex: the index of the item that will be initially selected (from which navigation will begin)\n\t * - navigationMode (Auto|Horizontal|Vertical): whether the items are displayed horizontally (Horizontal), vertically (Vertical) or as a matrix (Auto) meaning the user can navigate in both directions (up/down and left/right)\n\t * - rowSize: tells how many items per row there are when the items are not rendered as a flat list but rather as a matrix. Relevant for navigationMode=Auto\n\t * \t- skipItemsSize: tells how many items upon PAGE_UP and PAGE_DOWN should be skipped to applying the focus on the next item\n\t * - behavior (Static|Cycling): tells what to do when trying to navigate beyond the first and last items\n\t * Static means that nothing happens if the user tries to navigate beyond the first/last item.\n\t * Cycling means that when the user navigates beyond the last item they go to the first and vice versa.\n\t * - getItemsCallback: function that, when called, returns an array with all items the user can navigate among\n\t * - affectedPropertiesNames: a list of metadata properties on the root component which, upon user navigation, will be reassigned by address thus causing the root component to invalidate\n\t */\n\tconstructor(rootWebComponent: UI5Element, options: ItemNavigationOptions) {\n\t\tif (!rootWebComponent.isUI5Element) {\n\t\t\tthrow new Error(\"The root web component must be a UI5 Element instance\");\n\t\t}\n\n\t\tthis.rootWebComponent = rootWebComponent;\n\t\tthis.rootWebComponent.addEventListener(\"keydown\", this._onkeydown.bind(this));\n\t\tthis._initBound = this._init.bind(this);\n\t\tthis.rootWebComponent.attachComponentStateFinalized(this._initBound);\n\n\t\tif (typeof options.getItemsCallback !== \"function\") {\n\t\t\tthrow new Error(\"getItemsCallback is required\");\n\t\t}\n\n\t\tthis._getItems = options.getItemsCallback;\n\t\tthis._currentIndex = options.currentIndex || 0;\n\t\tthis._rowSize = options.rowSize || 1;\n\t\tthis._behavior = options.behavior || ItemNavigationBehavior.Static;\n\t\tthis._navigationMode = options.navigationMode || NavigationMode.Auto;\n\t\tthis._affectedPropertiesNames = options.affectedPropertiesNames || [];\n\t\tthis._skipItemsSize = options.skipItemsSize || null;\n\t}\n\n\t/**\n\t * Call this method to set a new \"current\" (selected) item in the item navigation\n\t * Note: the item passed to this function must be one of the items, returned by the getItemsCallback function\n\t *\n\t * @public\n\t * @param current the new selected item\n\t */\n\tsetCurrentItem(current: ITabbable): void {\n\t\tconst currentItemIndex = this._getItems().indexOf(current);\n\n\t\tif (currentItemIndex === -1) {\n\t\t\tconsole.warn(`The provided item is not managed by ItemNavigation`, current); // eslint-disable-line\n\t\t\treturn;\n\t\t}\n\n\t\tthis._currentIndex = currentItemIndex;\n\t\tthis._applyTabIndex();\n\t}\n\n\t/**\n\t * Call this method to dynamically change the row size\n\t *\n\t * @public\n\t * @param newRowSize\n\t */\n\tsetRowSize(newRowSize: number): void {\n\t\tthis._rowSize = newRowSize;\n\t}\n\n\t_init() {\n\t\tthis._getItems().forEach((item, idx) => {\n\t\t\titem.forcedTabIndex = (idx === this._currentIndex) ? \"0\" : \"-1\";\n\t\t});\n\t}\n\n\t_onkeydown(event: KeyboardEvent) {\n\t\tif (!this._canNavigate()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst horizontalNavigationOn = this._navigationMode === NavigationMode.Horizontal || this._navigationMode === NavigationMode.Auto;\n\t\tconst verticalNavigationOn = this._navigationMode === NavigationMode.Vertical || this._navigationMode === NavigationMode.Auto;\n\t\tconst isRTL = this.rootWebComponent.effectiveDir === \"rtl\";\n\n\t\tif (isRTL && isLeft(event) && horizontalNavigationOn) {\n\t\t\tthis._handleRight();\n\t\t} else if (isRTL && isRight(event) && horizontalNavigationOn) {\n\t\t\tthis._handleLeft();\n\t\t} else if (isLeft(event) && horizontalNavigationOn) {\n\t\t\tthis._handleLeft();\n\t\t} else if (isRight(event) && horizontalNavigationOn) {\n\t\t\tthis._handleRight();\n\t\t} else if (isUp(event) && verticalNavigationOn) {\n\t\t\tthis._handleUp();\n\t\t} else if (isDown(event) && verticalNavigationOn) {\n\t\t\tthis._handleDown();\n\t\t} else if (isHome(event)) {\n\t\t\tthis._handleHome();\n\t\t} else if (isEnd(event)) {\n\t\t\tthis._handleEnd();\n\t\t} else if (isPageUp(event)) {\n\t\t\tthis._handlePageUp();\n\t\t} else if (isPageDown(event)) {\n\t\t\tthis._handlePageDown();\n\t\t} else {\n\t\t\treturn; // if none of the supported keys is pressed, we don't want to prevent the event or update the item navigation\n\t\t}\n\n\t\tevent.preventDefault();\n\t\tthis._applyTabIndex();\n\t\tthis._focusCurrentItem();\n\t}\n\n\t_handleUp() {\n\t\tconst itemsLength = this._getItems().length;\n\t\tif (this._currentIndex - this._rowSize >= 0) { // no border reached, just decrease the index by a row\n\t\t\tthis._currentIndex -= this._rowSize;\n\t\t\treturn;\n\t\t}\n\n\t\tif (this._behavior === ItemNavigationBehavior.Cyclic) { // if cyclic, go to the **last** item in the **previous** column\n\t\t\tconst firstItemInThisColumnIndex = this._currentIndex % this._rowSize;\n\t\t\tconst firstItemInPreviousColumnIndex = firstItemInThisColumnIndex === 0 ? this._rowSize - 1 : firstItemInThisColumnIndex - 1; // find the first item in the previous column (if the current column is the first column -> move to the last column)\n\t\t\tconst rows = Math.ceil(itemsLength / this._rowSize); // how many rows there are (even if incomplete, f.e. for 14 items and _rowSize=4 -> 4 rows total, although only 2 items on the last row)\n\t\t\tlet lastItemInPreviousColumnIndex = firstItemInPreviousColumnIndex + (rows - 1) * this._rowSize; // multiply rows by columns, and add the column's first item's index\n\t\t\tif (lastItemInPreviousColumnIndex > itemsLength - 1) { // for incomplete rows, use the previous row's last item, as for them the last item is missing\n\t\t\t\tlastItemInPreviousColumnIndex -= this._rowSize;\n\t\t\t}\n\t\t\tthis._currentIndex = lastItemInPreviousColumnIndex;\n\t\t} else { // not cyclic, so just go to the first item\n\t\t\tthis._currentIndex = 0;\n\t\t}\n\t}\n\n\t_handleDown() {\n\t\tconst itemsLength = this._getItems().length;\n\t\tif (this._currentIndex + this._rowSize < itemsLength) { // no border reached, just increase the index by a row\n\t\t\tthis._currentIndex += this._rowSize;\n\t\t\treturn;\n\t\t}\n\n\t\tif (this._behavior === ItemNavigationBehavior.Cyclic) { // if cyclic, go to the **first** item in the **next** column\n\t\t\tconst firstItemInThisColumnIndex = this._currentIndex % this._rowSize; // find the first item in the current column first\n\t\t\tconst firstItemInNextColumnIndex = (firstItemInThisColumnIndex + 1) % this._rowSize; // to get the first item in the next column, just increase the index by 1. The modulo by rows is for the case when we are at the last column\n\t\t\tthis._currentIndex = firstItemInNextColumnIndex;\n\t\t} else { // not cyclic, so just go to the last item\n\t\t\tthis._currentIndex = itemsLength - 1;\n\t\t}\n\t}\n\n\t_handleLeft() {\n\t\tconst itemsLength = this._getItems().length;\n\t\tif (this._currentIndex > 0) {\n\t\t\tthis._currentIndex -= 1;\n\t\t\treturn;\n\t\t}\n\n\t\tif (this._behavior === ItemNavigationBehavior.Cyclic) { // go to the first item in the next column\n\t\t\tthis._currentIndex = itemsLength - 1;\n\t\t}\n\t}\n\n\t_handleRight() {\n\t\tconst itemsLength = this._getItems().length;\n\t\tif (this._currentIndex < itemsLength - 1) {\n\t\t\tthis._currentIndex += 1;\n\t\t\treturn;\n\t\t}\n\n\t\tif (this._behavior === ItemNavigationBehavior.Cyclic) { // go to the first item in the next column\n\t\t\tthis._currentIndex = 0;\n\t\t}\n\t}\n\n\t_handleHome() {\n\t\tconst homeEndRange = this._rowSize > 1 ? this._rowSize : this._getItems().length;\n\t\tthis._currentIndex -= this._currentIndex % homeEndRange;\n\t}\n\n\t_handleEnd() {\n\t\tconst homeEndRange = this._rowSize > 1 ? this._rowSize : this._getItems().length;\n\t\tthis._currentIndex += (homeEndRange - 1 - this._currentIndex % homeEndRange); // eslint-disable-line\n\t}\n\n\t_handlePageUp() {\n\t\tif (this._rowSize > 1) {\n\t\t\t// eslint-disable-next-line\n\t\t\t// TODO: handle page up on matrix (grid) layout - ColorPalette, ProductSwitch.\n\t\t\treturn;\n\t\t}\n\t\tthis._handlePageUpFlat();\n\t}\n\n\t_handlePageDown() {\n\t\tif (this._rowSize > 1) {\n\t\t\t// eslint-disable-next-line\n\t\t\t// TODO: handle page up on matrix (grid) layout - ColorPalette, ProductSwitch.\n\t\t\treturn;\n\t\t}\n\t\tthis._handlePageDownFlat();\n\t}\n\n\t/**\n\t * Handles PAGE_UP in a flat list-like structure, both vertically and horizontally.\n\t */\n\t_handlePageUpFlat() {\n\t\tif (this._skipItemsSize === null) {\n\t\t\t// Move the focus to the very top (as Home).\n\t\t\tthis._currentIndex -= this._currentIndex;\n\t\t\treturn;\n\t\t}\n\n\t\tif (this._currentIndex + 1 > this._skipItemsSize) {\n\t\t\t// When there are more than \"skipItemsSize\" number of items to the top,\n\t\t\t// move the focus up/left with the predefined number.\n\t\t\tthis._currentIndex -= this._skipItemsSize;\n\t\t} else {\n\t\t\t// Otherwise, move the focus to the very top (as Home).\n\t\t\tthis._currentIndex -= this._currentIndex;\n\t\t}\n\t}\n\n\t/**\n\t * Handles PAGE_DOWN in a flat list-like structure, both vertically and horizontally.\n\t */\n\t_handlePageDownFlat() {\n\t\tif (this._skipItemsSize === null) {\n\t\t\t// Move the focus to the very bottom (as End).\n\t\t\tthis._currentIndex = this._getItems().length - 1;\n\t\t\treturn;\n\t\t}\n\n\t\tconst currentToEndRange = this._getItems().length - this._currentIndex - 1;\n\n\t\tif (currentToEndRange > this._skipItemsSize) {\n\t\t\t// When there are more than \"skipItemsSize\" number of items until the bottom,\n\t\t\t// move the focus down/right with the predefined number.\n\t\t\tthis._currentIndex += this._skipItemsSize;\n\t\t} else {\n\t\t\t// Otherwise, move the focus to the very bottom (as End).\n\t\t\tthis._currentIndex = this._getItems().length - 1;\n\t\t}\n\t}\n\n\t_applyTabIndex() {\n\t\tconst items = this._getItems();\n\t\tfor (let i = 0; i < items.length; i++) {\n\t\t\titems[i].forcedTabIndex = i === this._currentIndex ? \"0\" : \"-1\";\n\t\t}\n\n\t\tthis._affectedPropertiesNames.forEach(propName => {\n\t\t\tconst prop = (this.rootWebComponent as Record<string, any>)[propName];\n\t\t\t(this.rootWebComponent as Record<string, any>)[propName] = Array.isArray(prop) ? [...prop] : { ...prop };\n\t\t});\n\t}\n\n\t_focusCurrentItem() {\n\t\tconst currentItem = this._getCurrentItem();\n\t\tif (currentItem) {\n\t\t\tcurrentItem.focus();\n\t\t}\n\t}\n\n\t_canNavigate() {\n\t\tconst currentItem = this._getCurrentItem();\n\t\tconst activeElement = getActiveElement();\n\n\t\treturn currentItem && currentItem === activeElement;\n\t}\n\n\t_getCurrentItem() {\n\t\tconst items = this._getItems();\n\n\t\tif (!items.length) {\n\t\t\treturn;\n\t\t}\n\n\t\t// normalize the index\n\t\twhile (this._currentIndex >= items.length) {\n\t\t\tthis._currentIndex -= this._rowSize;\n\t\t}\n\n\t\tif (this._currentIndex < 0) {\n\t\t\tthis._currentIndex = 0;\n\t\t}\n\n\t\tconst currentItem = items[this._currentIndex];\n\n\t\tif (!currentItem) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (instanceOfUI5Element(currentItem)) {\n\t\t\treturn currentItem.getFocusDomRef();\n\t\t}\n\n\t\tconst currentItemDOMRef = this.rootWebComponent.getDomRef();\n\t\tif (!currentItemDOMRef) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (currentItem.id) {\n\t\t\treturn currentItemDOMRef.querySelector(`[id=\"${currentItem.id}\"]`) as HTMLElement;\n\t\t}\n\t}\n}\n\nexport default ItemNavigation;\n\nexport {\n\tITabbable,\n};\n"],
|
|
4
|
+
"sourcesContent": ["import {\n\tisDown,\n\tisUp,\n\tisLeft,\n\tisRight,\n\tisHome,\n\tisEnd,\n\tisPageDown,\n\tisPageUp,\n} from \"../Keys.js\";\nimport getActiveElement from \"../util/getActiveElement.js\";\n\nimport NavigationMode from \"../types/NavigationMode.js\";\nimport ItemNavigationBehavior from \"../types/ItemNavigationBehavior.js\";\n\nimport type UI5Element from \"../UI5Element.js\";\nimport { instanceOfUI5Element } from \"../UI5Element.js\";\n\ninterface ITabbable {\n\tid: string,\n\tforcedTabIndex?: string,\n}\n\ntype ItemNavigationOptions = {\n\tcurrentIndex?: number,\n\tnavigationMode?: NavigationMode,\n\trowSize?: number\n\tskipItemsSize?: number,\n\tbehavior?: ItemNavigationBehavior,\n\tgetItemsCallback: () => Array<ITabbable>,\n\taffectedPropertiesNames?: Array<string>,\n};\n\n/**\n * The ItemNavigation class manages the calculations to determine the correct \"tabindex\" for a group of related items inside a root component.\n * Important: ItemNavigation only does the calculations and does not change \"tabindex\" directly, this is a responsibility of the developer.\n *\n * The keys that trigger ItemNavigation are:\n * - Up/down\n * - Left/right\n * - Home/End\n *\n * Usage:\n * 1) Use the \"getItemsCallback\" constructor property to pass a callback to ItemNavigation, which, whenever called, will return the list of items to navigate among.\n *\n * Each item passed to ItemNavigation via \"getItemsCallback\" must be:\n * - A) either a UI5Element with a \"forcedTabIndex\" property\n * - B) or an Object with \"id\" and \"forcedTabIndex\" properties which represents a part of the root component's shadow DOM.\n * The \"id\" must be a valid ID within the shadow root of the component ItemNavigation operates on.\n * This object must not be a DOM object because, as said, ItemNavigation will not set \"tabindex\" on it. It must be a representation of a DOM object only\n * and the developer has the responsibility to update the \"tabindex\" in the component's DOM.\n * - C) a combination of the above\n *\n * Whenever the user navigates with the keyboard, ItemNavigation will modify the \"forcedTabIndex\" properties of the items.\n * It is the items' responsibilities to re-render themselves and apply the correct value of \"tabindex\" (i.e. to map the \"forcedTabIndex\" ItemNavigation set to them to the \"tabindex\" property).\n * If the items of the ItemNavigation are UI5Elements themselves, this can happen naturally since they will be invalidated by their \"forcedTabIndex\" property.\n * If the items are Objects with \"id\" and \"forcedTabIndex\" however, it is the developer's responsibility to apply these and the easiest way is to have the root component invalidated by ItemNavigation.\n * To do so, set the \"affectedPropertiesNames\" constructor property to point to one or more of the root component's properties that need refreshing when \"forcedTabIndex\" is changed deeply.\n *\n * 2) Call the \"setCurrentItem\" method of ItemNavigation whenever you want to change the current item.\n * This is most commonly required if the user for example clicks on an item and thus selects it directly.\n * Pass as the only argument to \"setCurrentItem\" the item that becomes current (must be one of the items, returned by \"getItemsCallback\").\n *\n * @class\n * @public\n */\nclass ItemNavigation {\n\trootWebComponent: UI5Element;\n\n\t_getItems: () => Array<ITabbable>;\n\n\t_currentIndex: number;\n\n\t_rowSize: number;\n\n\t_behavior: ItemNavigationBehavior;\n\n\t_navigationMode: NavigationMode;\n\n\t_affectedPropertiesNames: Array<string>;\n\n\t_skipItemsSize: number | null;\n\n\t_initBound: () => void;\n\n\t/**\n\t *\n\t * @param rootWebComponent the component to operate on (component that slots or contains within its shadow root the items the user navigates among)\n\t * @param {ItemNavigationOptions} options Object with configuration options:\n\t * - currentIndex: the index of the item that will be initially selected (from which navigation will begin)\n\t * - navigationMode (Auto|Horizontal|Vertical): whether the items are displayed horizontally (Horizontal), vertically (Vertical) or as a matrix (Auto) meaning the user can navigate in both directions (up/down and left/right)\n\t * - rowSize: tells how many items per row there are when the items are not rendered as a flat list but rather as a matrix. Relevant for navigationMode=Auto\n\t * \t- skipItemsSize: tells how many items upon PAGE_UP and PAGE_DOWN should be skipped to applying the focus on the next item\n\t * - behavior (Static|Cycling): tells what to do when trying to navigate beyond the first and last items\n\t * Static means that nothing happens if the user tries to navigate beyond the first/last item.\n\t * Cycling means that when the user navigates beyond the last item they go to the first and vice versa.\n\t * - getItemsCallback: function that, when called, returns an array with all items the user can navigate among\n\t * - affectedPropertiesNames: a list of metadata properties on the root component which, upon user navigation, will be reassigned by address thus causing the root component to invalidate\n\t */\n\tconstructor(rootWebComponent: UI5Element, options: ItemNavigationOptions) {\n\t\tif (!rootWebComponent.isUI5Element) {\n\t\t\tthrow new Error(\"The root web component must be a UI5 Element instance\");\n\t\t}\n\n\t\tthis.rootWebComponent = rootWebComponent;\n\t\tthis.rootWebComponent.addEventListener(\"keydown\", this._onkeydown.bind(this));\n\t\tthis._initBound = this._init.bind(this);\n\t\tthis.rootWebComponent.attachComponentStateFinalized(this._initBound);\n\n\t\tif (typeof options.getItemsCallback !== \"function\") {\n\t\t\tthrow new Error(\"getItemsCallback is required\");\n\t\t}\n\n\t\tthis._getItems = options.getItemsCallback;\n\t\tthis._currentIndex = options.currentIndex || 0;\n\t\tthis._rowSize = options.rowSize || 1;\n\t\tthis._behavior = options.behavior || ItemNavigationBehavior.Static;\n\t\tthis._navigationMode = options.navigationMode || NavigationMode.Auto;\n\t\tthis._affectedPropertiesNames = options.affectedPropertiesNames || [];\n\t\tthis._skipItemsSize = options.skipItemsSize || null;\n\t}\n\n\t/**\n\t * Call this method to set a new \"current\" (selected) item in the item navigation\n\t * Note: the item passed to this function must be one of the items, returned by the getItemsCallback function\n\t *\n\t * @public\n\t * @param current the new selected item\n\t */\n\tsetCurrentItem(current: ITabbable): void {\n\t\tconst currentItemIndex = this._getItems().indexOf(current);\n\n\t\tif (currentItemIndex === -1) {\n\t\t\tconsole.warn(`The provided item is not managed by ItemNavigation`, current); // eslint-disable-line\n\t\t\treturn;\n\t\t}\n\n\t\tthis._currentIndex = currentItemIndex;\n\t\tthis._applyTabIndex();\n\t}\n\n\t/**\n\t * Call this method to dynamically change the row size\n\t *\n\t * @public\n\t * @param newRowSize\n\t */\n\tsetRowSize(newRowSize: number): void {\n\t\tthis._rowSize = newRowSize;\n\t}\n\n\t_init() {\n\t\tthis._getItems().forEach((item, idx) => {\n\t\t\titem.forcedTabIndex = (idx === this._currentIndex) ? \"0\" : \"-1\";\n\t\t});\n\t}\n\n\t_onkeydown(event: KeyboardEvent) {\n\t\tif (!this._canNavigate()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst horizontalNavigationOn = this._navigationMode === NavigationMode.Horizontal || this._navigationMode === NavigationMode.Auto;\n\t\tconst verticalNavigationOn = this._navigationMode === NavigationMode.Vertical || this._navigationMode === NavigationMode.Auto;\n\t\tconst isRTL = this.rootWebComponent.effectiveDir === \"rtl\";\n\n\t\tif (isRTL && isLeft(event) && horizontalNavigationOn) {\n\t\t\tthis._handleRight();\n\t\t} else if (isRTL && isRight(event) && horizontalNavigationOn) {\n\t\t\tthis._handleLeft();\n\t\t} else if (isLeft(event) && horizontalNavigationOn) {\n\t\t\tthis._handleLeft();\n\t\t} else if (isRight(event) && horizontalNavigationOn) {\n\t\t\tthis._handleRight();\n\t\t} else if (isUp(event) && verticalNavigationOn) {\n\t\t\tthis._handleUp();\n\t\t} else if (isDown(event) && verticalNavigationOn) {\n\t\t\tthis._handleDown();\n\t\t} else if (isHome(event)) {\n\t\t\tthis._handleHome();\n\t\t} else if (isEnd(event)) {\n\t\t\tthis._handleEnd();\n\t\t} else if (isPageUp(event)) {\n\t\t\tthis._handlePageUp();\n\t\t} else if (isPageDown(event)) {\n\t\t\tthis._handlePageDown();\n\t\t} else {\n\t\t\treturn; // if none of the supported keys is pressed, we don't want to prevent the event or update the item navigation\n\t\t}\n\n\t\tevent.preventDefault();\n\t\tthis._applyTabIndex();\n\t\tthis._focusCurrentItem();\n\t}\n\n\t_handleUp() {\n\t\tconst itemsLength = this._getItems().length;\n\t\tif (this._currentIndex - this._rowSize >= 0) { // no border reached, just decrease the index by a row\n\t\t\tthis._currentIndex -= this._rowSize;\n\t\t\treturn;\n\t\t}\n\n\t\tif (this._behavior === ItemNavigationBehavior.Cyclic) { // if cyclic, go to the **last** item in the **previous** column\n\t\t\tconst firstItemInThisColumnIndex = this._currentIndex % this._rowSize;\n\t\t\tconst firstItemInPreviousColumnIndex = firstItemInThisColumnIndex === 0 ? this._rowSize - 1 : firstItemInThisColumnIndex - 1; // find the first item in the previous column (if the current column is the first column -> move to the last column)\n\t\t\tconst rows = Math.ceil(itemsLength / this._rowSize); // how many rows there are (even if incomplete, f.e. for 14 items and _rowSize=4 -> 4 rows total, although only 2 items on the last row)\n\t\t\tlet lastItemInPreviousColumnIndex = firstItemInPreviousColumnIndex + (rows - 1) * this._rowSize; // multiply rows by columns, and add the column's first item's index\n\t\t\tif (lastItemInPreviousColumnIndex > itemsLength - 1) { // for incomplete rows, use the previous row's last item, as for them the last item is missing\n\t\t\t\tlastItemInPreviousColumnIndex -= this._rowSize;\n\t\t\t}\n\t\t\tthis._currentIndex = lastItemInPreviousColumnIndex;\n\t\t} else { // not cyclic, so just go to the first item\n\t\t\tthis._currentIndex = 0;\n\t\t}\n\t}\n\n\t_handleDown() {\n\t\tconst itemsLength = this._getItems().length;\n\t\tif (this._currentIndex + this._rowSize < itemsLength) { // no border reached, just increase the index by a row\n\t\t\tthis._currentIndex += this._rowSize;\n\t\t\treturn;\n\t\t}\n\n\t\tif (this._behavior === ItemNavigationBehavior.Cyclic) { // if cyclic, go to the **first** item in the **next** column\n\t\t\tconst firstItemInThisColumnIndex = this._currentIndex % this._rowSize; // find the first item in the current column first\n\t\t\tconst firstItemInNextColumnIndex = (firstItemInThisColumnIndex + 1) % this._rowSize; // to get the first item in the next column, just increase the index by 1. The modulo by rows is for the case when we are at the last column\n\t\t\tthis._currentIndex = firstItemInNextColumnIndex;\n\t\t} else { // not cyclic, so just go to the last item\n\t\t\tthis._currentIndex = itemsLength - 1;\n\t\t}\n\t}\n\n\t_handleLeft() {\n\t\tconst itemsLength = this._getItems().length;\n\t\tif (this._currentIndex > 0) {\n\t\t\tthis._currentIndex -= 1;\n\t\t\treturn;\n\t\t}\n\n\t\tif (this._behavior === ItemNavigationBehavior.Cyclic) { // go to the first item in the next column\n\t\t\tthis._currentIndex = itemsLength - 1;\n\t\t}\n\t}\n\n\t_handleRight() {\n\t\tconst itemsLength = this._getItems().length;\n\t\tif (this._currentIndex < itemsLength - 1) {\n\t\t\tthis._currentIndex += 1;\n\t\t\treturn;\n\t\t}\n\n\t\tif (this._behavior === ItemNavigationBehavior.Cyclic) { // go to the first item in the next column\n\t\t\tthis._currentIndex = 0;\n\t\t}\n\t}\n\n\t_handleHome() {\n\t\tconst homeEndRange = this._rowSize > 1 ? this._rowSize : this._getItems().length;\n\t\tthis._currentIndex -= this._currentIndex % homeEndRange;\n\t}\n\n\t_handleEnd() {\n\t\tconst homeEndRange = this._rowSize > 1 ? this._rowSize : this._getItems().length;\n\t\tthis._currentIndex += (homeEndRange - 1 - this._currentIndex % homeEndRange); // eslint-disable-line\n\t}\n\n\t_handlePageUp() {\n\t\tif (this._rowSize > 1) {\n\t\t\t// eslint-disable-next-line\n\t\t\t// TODO: handle page up on matrix (grid) layout - ColorPalette, ProductSwitch.\n\t\t\treturn;\n\t\t}\n\t\tthis._handlePageUpFlat();\n\t}\n\n\t_handlePageDown() {\n\t\tif (this._rowSize > 1) {\n\t\t\t// eslint-disable-next-line\n\t\t\t// TODO: handle page up on matrix (grid) layout - ColorPalette, ProductSwitch.\n\t\t\treturn;\n\t\t}\n\t\tthis._handlePageDownFlat();\n\t}\n\n\t/**\n\t * Handles PAGE_UP in a flat list-like structure, both vertically and horizontally.\n\t */\n\t_handlePageUpFlat() {\n\t\tif (this._skipItemsSize === null) {\n\t\t\t// Move the focus to the very top (as Home).\n\t\t\tthis._currentIndex -= this._currentIndex;\n\t\t\treturn;\n\t\t}\n\n\t\tif (this._currentIndex + 1 > this._skipItemsSize) {\n\t\t\t// When there are more than \"skipItemsSize\" number of items to the top,\n\t\t\t// move the focus up/left with the predefined number.\n\t\t\tthis._currentIndex -= this._skipItemsSize;\n\t\t} else {\n\t\t\t// Otherwise, move the focus to the very top (as Home).\n\t\t\tthis._currentIndex -= this._currentIndex;\n\t\t}\n\t}\n\n\t/**\n\t * Handles PAGE_DOWN in a flat list-like structure, both vertically and horizontally.\n\t */\n\t_handlePageDownFlat() {\n\t\tif (this._skipItemsSize === null) {\n\t\t\t// Move the focus to the very bottom (as End).\n\t\t\tthis._currentIndex = this._getItems().length - 1;\n\t\t\treturn;\n\t\t}\n\n\t\tconst currentToEndRange = this._getItems().length - this._currentIndex - 1;\n\n\t\tif (currentToEndRange > this._skipItemsSize) {\n\t\t\t// When there are more than \"skipItemsSize\" number of items until the bottom,\n\t\t\t// move the focus down/right with the predefined number.\n\t\t\tthis._currentIndex += this._skipItemsSize;\n\t\t} else {\n\t\t\t// Otherwise, move the focus to the very bottom (as End).\n\t\t\tthis._currentIndex = this._getItems().length - 1;\n\t\t}\n\t}\n\n\t_applyTabIndex() {\n\t\tconst items = this._getItems();\n\t\tfor (let i = 0; i < items.length; i++) {\n\t\t\titems[i].forcedTabIndex = i === this._currentIndex ? \"0\" : \"-1\";\n\t\t}\n\n\t\tthis._affectedPropertiesNames.forEach(propName => {\n\t\t\tconst prop = (this.rootWebComponent as Record<string, any>)[propName];\n\t\t\t(this.rootWebComponent as Record<string, any>)[propName] = Array.isArray(prop) ? [...prop] : { ...prop };\n\t\t});\n\t}\n\n\t_focusCurrentItem() {\n\t\tconst currentItem = this._getCurrentItem();\n\t\tif (currentItem) {\n\t\t\tcurrentItem.focus();\n\t\t}\n\t}\n\n\t_canNavigate() {\n\t\tconst currentItem = this._getCurrentItem();\n\t\tconst activeElement = getActiveElement();\n\n\t\treturn currentItem && currentItem === activeElement;\n\t}\n\n\t_getCurrentItem() {\n\t\tconst items = this._getItems();\n\n\t\tif (!items.length) {\n\t\t\treturn;\n\t\t}\n\n\t\t// normalize the index\n\t\twhile (this._currentIndex >= items.length) {\n\t\t\tthis._currentIndex -= this._rowSize;\n\t\t}\n\n\t\tif (this._currentIndex < 0) {\n\t\t\tthis._currentIndex = 0;\n\t\t}\n\n\t\tconst currentItem = items[this._currentIndex];\n\n\t\tif (!currentItem) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (instanceOfUI5Element(currentItem)) {\n\t\t\treturn currentItem.getFocusDomRef();\n\t\t}\n\n\t\tconst currentItemDOMRef = this.rootWebComponent.getDomRef();\n\t\tif (!currentItemDOMRef) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (currentItem.id) {\n\t\t\treturn currentItemDOMRef.querySelector(`[id=\"${currentItem.id}\"]`) as HTMLElement;\n\t\t}\n\t}\n}\n\nexport default ItemNavigation;\n\nexport {\n\tITabbable,\n};\n"],
|
|
5
5
|
"mappings": "aAAA,OACC,UAAAA,EACA,QAAAC,EACA,UAAAC,EACA,WAAAC,EACA,UAAAC,EACA,SAAAC,EACA,cAAAC,EACA,YAAAC,MACM,aACP,OAAOC,MAAsB,8BAE7B,OAAOC,MAAoB,6BAC3B,OAAOC,MAA4B,qCAGnC,OAAS,wBAAAC,MAA4B,mBAkDrC,MAAMC,CAAe,CAiCpB,YAAYC,EAA8BC,EAAgC,CACzE,GAAI,CAACD,EAAiB,aACrB,MAAM,IAAI,MAAM,uDAAuD,EAQxE,GALA,KAAK,iBAAmBA,EACxB,KAAK,iBAAiB,iBAAiB,UAAW,KAAK,WAAW,KAAK,IAAI,CAAC,EAC5E,KAAK,WAAa,KAAK,MAAM,KAAK,IAAI,EACtC,KAAK,iBAAiB,8BAA8B,KAAK,UAAU,EAE/D,OAAOC,EAAQ,kBAAqB,WACvC,MAAM,IAAI,MAAM,8BAA8B,EAG/C,KAAK,UAAYA,EAAQ,iBACzB,KAAK,cAAgBA,EAAQ,cAAgB,EAC7C,KAAK,SAAWA,EAAQ,SAAW,EACnC,KAAK,UAAYA,EAAQ,UAAYJ,EAAuB,OAC5D,KAAK,gBAAkBI,EAAQ,gBAAkBL,EAAe,KAChE,KAAK,yBAA2BK,EAAQ,yBAA2B,CAAC,EACpE,KAAK,eAAiBA,EAAQ,eAAiB,IAChD,CASA,eAAeC,EAA0B,CACxC,MAAMC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,EAAM,KAAK,aAAa,EAE5C,GAAI,CAACI,EACJ,OAGD,GAAIxB,EAAqBwB,CAAW,EACnC,OAAOA,EAAY,eAAe,EAGnC,MAAME,EAAoB,KAAK,iBAAiB,UAAU,EAC1D,GAAKA,GAIDF,EAAY,GACf,OAAOE,EAAkB,cAAc,QAAQF,EAAY,EAAE,IAAI,CAEnE,CACD,CAEA,eAAevB,EAEf",
|
|
6
6
|
"names": ["isDown", "isUp", "isLeft", "isRight", "isHome", "isEnd", "isPageDown", "isPageUp", "getActiveElement", "NavigationMode", "ItemNavigationBehavior", "instanceOfUI5Element", "ItemNavigation", "rootWebComponent", "options", "current", "currentItemIndex", "newRowSize", "item", "idx", "event", "horizontalNavigationOn", "verticalNavigationOn", "isRTL", "itemsLength", "firstItemInThisColumnIndex", "firstItemInPreviousColumnIndex", "rows", "lastItemInPreviousColumnIndex", "firstItemInNextColumnIndex", "homeEndRange", "items", "i", "propName", "prop", "currentItem", "activeElement", "currentItemDOMRef"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/features/InputElementsFormSupport.ts"],
|
|
4
|
-
"sourcesContent": ["import type UI5Element from \"../UI5Element.js\";\n\ninterface IFormElement extends UI5Element {\n\t_internals?: ElementInternals;\n}\n\ninterface IFormInputElement extends IFormElement {\n\tname
|
|
4
|
+
"sourcesContent": ["import type UI5Element from \"../UI5Element.js\";\n\ninterface IFormElement extends UI5Element {\n\t_internals?: ElementInternals;\n}\n\ninterface IFormInputElement extends IFormElement {\n\tname?: string;\n\tformFormattedValue: FormData | string | null;\n\tformValidityMessage?: string;\n\tformValidity?: ValidityStateFlags;\n\tformElementAnchor?: () => HTMLElement | undefined | Promise<HTMLElement | undefined>;\n}\n\nconst attachFormElementInternals = (element: IFormInputElement | IFormElement) => {\n\telement._internals = element.attachInternals();\n\n\tif (isInputElement(element)) {\n\t\tsetFormValue(element);\n\t}\n};\n\nconst setFormValue = (element: IFormInputElement) => {\n\tif (!element._internals?.form) {\n\t\treturn;\n\t}\n\n\tsetFormValidity(element);\n\n\tif (!element.name) {\n\t\telement._internals?.setFormValue(null);\n\t\treturn;\n\t}\n\n\telement._internals.setFormValue(element.formFormattedValue);\n};\n\nconst setFormValidity = async (element: IFormInputElement) => {\n\tif (!element._internals?.form) {\n\t\treturn;\n\t}\n\tif (element.formValidity && Object.keys(element.formValidity).some(key => key)) {\n\t\tconst focusRef = await element.formElementAnchor?.();\n\t\telement._internals.setValidity(element.formValidity, element.formValidityMessage, focusRef);\n\t} else {\n\t\telement._internals.setValidity({});\n\t}\n};\n\nconst submitForm = (element: IFormElement) => {\n\telement._internals?.form?.requestSubmit();\n};\n\nconst resetForm = (element: IFormElement) => {\n\telement._internals?.form?.reset();\n};\n\nconst isInputElement = (element: IFormInputElement | IFormElement): element is IFormInputElement => {\n\treturn \"formFormattedValue\" in element && \"name\" in element;\n};\n\nexport {\n\tattachFormElementInternals,\n\tsetFormValue,\n\tsetFormValidity,\n\tsubmitForm,\n\tresetForm,\n};\n\nexport type {\n\tIFormInputElement,\n\tIFormElement,\n};\n"],
|
|
5
5
|
"mappings": "aAcA,MAAMA,EAA8BC,GAA8C,CACjFA,EAAQ,WAAaA,EAAQ,gBAAgB,EAEzCC,EAAeD,CAAO,GACzBE,EAAaF,CAAO,CAEtB,EAEME,EAAgBF,GAA+B,CACpD,GAAKA,EAAQ,YAAY,KAMzB,IAFAG,EAAgBH,CAAO,EAEnB,CAACA,EAAQ,KAAM,CAClBA,EAAQ,YAAY,aAAa,IAAI,EACrC,MACD,CAEAA,EAAQ,WAAW,aAAaA,EAAQ,kBAAkB,EAC3D,EAEMG,EAAkB,MAAOH,GAA+B,CAC7D,GAAKA,EAAQ,YAAY,KAGzB,GAAIA,EAAQ,cAAgB,OAAO,KAAKA,EAAQ,YAAY,EAAE,KAAKI,GAAOA,CAAG,EAAG,CAC/E,MAAMC,EAAW,MAAML,EAAQ,oBAAoB,EACnDA,EAAQ,WAAW,YAAYA,EAAQ,aAAcA,EAAQ,oBAAqBK,CAAQ,CAC3F,MACCL,EAAQ,WAAW,YAAY,CAAC,CAAC,CAEnC,EAEMM,EAAcN,GAA0B,CAC7CA,EAAQ,YAAY,MAAM,cAAc,CACzC,EAEMO,EAAaP,GAA0B,CAC5CA,EAAQ,YAAY,MAAM,MAAM,CACjC,EAEMC,EAAkBD,GAChB,uBAAwBA,GAAW,SAAUA,EAGrD,OACCD,KAAA,2BACAG,KAAA,aACAC,KAAA,gBACAG,KAAA,WACAC,KAAA",
|
|
6
6
|
"names": ["attachFormElementInternals", "element", "isInputElement", "setFormValue", "setFormValidity", "key", "focusRef", "submitForm", "resetForm"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";import u from"./patchPatcher.js";import l from"./patchPopup.js";import{registerFeature as m}from"../FeaturesRegistry.js";import{setTheme as g}from"../config/Theme.js";class a{static isAtLeastVersion116(){const e=window.sap.ui.version.split(".");return!e||e.length<2?!1:parseInt(e[0])>1||parseInt(e[1])>=116}static isOpenUI5Detected(){return typeof window.sap?.ui?.require=="function"}static init(){return a.isOpenUI5Detected()?new Promise(t=>{window.sap.ui.require(["sap/ui/core/Core"],async e=>{const i=()=>{let n=["sap/ui/core/Popup","sap/ui/core/Patcher","sap/ui/core/LocaleData"];a.isAtLeastVersion116()&&(n=[...n,"sap/base/i18n/Formatting","sap/base/i18n/Localization","sap/ui/core/ControlBehavior","sap/ui/core/Theming","sap/ui/core/date/CalendarUtils"]),window.sap.ui.require(n,(o,r)=>{u(r),l(o),t()})};a.isAtLeastVersion116()?(await e.ready(),i()):e.attachInit(i)})}):Promise.resolve()}static getConfigurationSettingsObject(){if(!a.isOpenUI5Detected())return{};if(a.isAtLeastVersion116()){const n=window.sap.ui.require("sap/ui/core/ControlBehavior"),o=window.sap.ui.require("sap/base/i18n/Localization"),r=window.sap.ui.require("sap/ui/core/Theming"),s=window.sap.ui.require("sap/base/i18n/Formatting"),c=window.sap.ui.require("sap/ui/core/date/CalendarUtils");return{animationMode:n.getAnimationMode(),language:o.getLanguage(),theme:r.getTheme(),themeRoot:r.getThemeRoot(),rtl:o.getRTL(),timezone:o.getTimezone(),calendarType:s.getCalendarType(),formatSettings:{firstDayOfWeek:c.getWeekConfigurationValues().firstDayOfWeek,legacyDateCalendarCustomizing:s.getCustomIslamicCalendarData?.()??s.getLegacyDateCalendarCustomizing?.()}}}const e=window.sap.ui.require("sap/ui/core/Core").getConfiguration(),i=window.sap.ui.require("sap/ui/core/LocaleData");return{animationMode:e.getAnimationMode(),language:e.getLanguage(),theme:e.getTheme(),themeRoot:e.getThemeRoot(),rtl:e.getRTL(),timezone:e.getTimezone(),calendarType:e.getCalendarType(),formatSettings:{firstDayOfWeek:i?i.getInstance(e.getLocale()).getFirstDayOfWeek():void 0,legacyDateCalendarCustomizing:e.getFormatSettings().getLegacyDateCalendarCustomizing()}}}static getLocaleDataObject(){if(!a.isOpenUI5Detected())return;const t=window.sap.ui.require("sap/ui/core/LocaleData");if(a.isAtLeastVersion116()){const n=window.sap.ui.require("sap/base/i18n/Localization");return t.getInstance(n.getLanguageTag())._get()}const i=window.sap.ui.require("sap/ui/core/Core").getConfiguration();return t.getInstance(i.getLocale())._get()}static _listenForThemeChange(){if(a.isAtLeastVersion116()){const t=window.sap.ui.require("sap/ui/core/Theming");t.attachApplied(()=>{g(t.getTheme())})}else{const t=window.sap.ui.require("sap/ui/core/Core"),e=t.getConfiguration();t.attachThemeChanged(()=>{g(e.getTheme())})}}static attachListeners(){a.isOpenUI5Detected()&&a._listenForThemeChange()}static cssVariablesLoaded(){if(!a.isOpenUI5Detected())return;const t=[...document.head.children].find(e=>e.id==="sap-ui-theme-sap.ui.core");return t?!!t.href.match(/\/css(-|_)variables\.css/):!1}}m("OpenUI5Support",a);export default a;
|
|
1
|
+
"use strict";import u from"./patchPatcher.js";import l from"./patchPopup.js";import{registerFeature as m}from"../FeaturesRegistry.js";import{setTheme as g}from"../config/Theme.js";class a{static isAtLeastVersion116(){if(!window.sap.ui.version)return!0;const e=window.sap.ui.version.split(".");return!e||e.length<2?!1:parseInt(e[0])>1||parseInt(e[1])>=116}static isOpenUI5Detected(){return typeof window.sap?.ui?.require=="function"}static init(){return a.isOpenUI5Detected()?new Promise(t=>{window.sap.ui.require(["sap/ui/core/Core"],async e=>{const i=()=>{let n=["sap/ui/core/Popup","sap/ui/core/Patcher","sap/ui/core/LocaleData"];a.isAtLeastVersion116()&&(n=[...n,"sap/base/i18n/Formatting","sap/base/i18n/Localization","sap/ui/core/ControlBehavior","sap/ui/core/Theming","sap/ui/core/date/CalendarUtils"]),window.sap.ui.require(n,(o,r)=>{u(r),l(o),t()})};a.isAtLeastVersion116()?(await e.ready(),i()):e.attachInit(i)})}):Promise.resolve()}static getConfigurationSettingsObject(){if(!a.isOpenUI5Detected())return{};if(a.isAtLeastVersion116()){const n=window.sap.ui.require("sap/ui/core/ControlBehavior"),o=window.sap.ui.require("sap/base/i18n/Localization"),r=window.sap.ui.require("sap/ui/core/Theming"),s=window.sap.ui.require("sap/base/i18n/Formatting"),c=window.sap.ui.require("sap/ui/core/date/CalendarUtils");return{animationMode:n.getAnimationMode(),language:o.getLanguage(),theme:r.getTheme(),themeRoot:r.getThemeRoot(),rtl:o.getRTL(),timezone:o.getTimezone(),calendarType:s.getCalendarType(),formatSettings:{firstDayOfWeek:c.getWeekConfigurationValues().firstDayOfWeek,legacyDateCalendarCustomizing:s.getCustomIslamicCalendarData?.()??s.getLegacyDateCalendarCustomizing?.()}}}const e=window.sap.ui.require("sap/ui/core/Core").getConfiguration(),i=window.sap.ui.require("sap/ui/core/LocaleData");return{animationMode:e.getAnimationMode(),language:e.getLanguage(),theme:e.getTheme(),themeRoot:e.getThemeRoot(),rtl:e.getRTL(),timezone:e.getTimezone(),calendarType:e.getCalendarType(),formatSettings:{firstDayOfWeek:i?i.getInstance(e.getLocale()).getFirstDayOfWeek():void 0,legacyDateCalendarCustomizing:e.getFormatSettings().getLegacyDateCalendarCustomizing()}}}static getLocaleDataObject(){if(!a.isOpenUI5Detected())return;const t=window.sap.ui.require("sap/ui/core/LocaleData");if(a.isAtLeastVersion116()){const n=window.sap.ui.require("sap/base/i18n/Localization");return t.getInstance(n.getLanguageTag())._get()}const i=window.sap.ui.require("sap/ui/core/Core").getConfiguration();return t.getInstance(i.getLocale())._get()}static _listenForThemeChange(){if(a.isAtLeastVersion116()){const t=window.sap.ui.require("sap/ui/core/Theming");t.attachApplied(()=>{g(t.getTheme())})}else{const t=window.sap.ui.require("sap/ui/core/Core"),e=t.getConfiguration();t.attachThemeChanged(()=>{g(e.getTheme())})}}static attachListeners(){a.isOpenUI5Detected()&&a._listenForThemeChange()}static cssVariablesLoaded(){if(!a.isOpenUI5Detected())return;const t=[...document.head.children].find(e=>e.id==="sap-ui-theme-sap.ui.core");return t?!!t.href.match(/\/css(-|_)variables\.css/):!1}}m("OpenUI5Support",a);export default a;
|
|
2
2
|
//# sourceMappingURL=OpenUI5Support.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/features/OpenUI5Support.ts"],
|
|
4
|
-
"sourcesContent": ["import patchPatcher from \"./patchPatcher.js\";\nimport type { OpenUI5Patcher } from \"./patchPatcher.js\";\nimport patchPopup from \"./patchPopup.js\";\nimport type { OpenUI5Popup } from \"./patchPopup.js\";\nimport { registerFeature } from \"../FeaturesRegistry.js\";\nimport { setTheme } from \"../config/Theme.js\";\nimport type { CLDRData } from \"../asset-registries/LocaleData.js\";\nimport type { LegacyDateCalendarCustomizing } from \"../features/LegacyDateFormats.js\";\n\ntype OpenUI5Core = {\n\tattachInit: (callback: () => void) => void,\n\tready: () => Promise<void>,\n\tattachThemeChanged: (callback: () => void) => void,\n\tgetConfiguration: () => OpenUI5CoreConfiguration,\n};\n\ntype OpenUI5CoreConfiguration = {\n\tgetAnimationMode: () => string,\n\tgetLanguage: () => string,\n\tgetTheme: () => string,\n\tgetThemeRoot: () => string,\n\tgetRTL: () => string,\n\tgetTimezone: () => string,\n\tgetCalendarType: () => string,\n\tgetLocale: () => string,\n\tgetFormatSettings: () => {\n\t\tgetLegacyDateCalendarCustomizing: () => LegacyDateCalendarCustomizing;\n\t}\n};\n\ntype ControlBehavior = {\n\tgetAnimationMode: () => string,\n}\n\ntype Localization = {\n\tgetLanguage: () => string,\n\tgetLanguageTag: () => string,\n\tgetRTL: () => string,\n\tgetTimezone: () => string,\n}\n\ntype LocaleData = {\n\tgetInstance: (locale: string) => Locale,\n}\n\ntype Theming = {\n\tgetThemeRoot: () => string,\n\tgetTheme: () => string,\n\tattachApplied: (callback: () => void) => void,\n}\n\ntype Formatting = {\n\tgetCalendarType: () => string,\n\tgetLegacyDateCalendarCustomizing: () => LegacyDateCalendarCustomizing,\n\tgetCustomIslamicCalendarData?: () => LegacyDateCalendarCustomizing,\n}\n\ntype CalendarUtils = {\n\tgetWeekConfigurationValues: () => {\n\t\tfirstDayOfWeek: number | undefined,\n\t},\n}\n\ntype Locale = {\n\tgetFirstDayOfWeek: () => number,\n\t_get: () => CLDRData,\n};\n\nclass OpenUI5Support {\n\tstatic isAtLeastVersion116() {\n\t\tconst version = window.sap.ui!.version as string;\n\t\tconst parts = version.split(\".\");\n\t\tif (!parts || parts.length < 2) {\n\t\t\treturn false;\n\t\t}\n\t\treturn parseInt(parts[0]) > 1 || parseInt(parts[1]) >= 116;\n\t}\n\n\tstatic isOpenUI5Detected() {\n\t\treturn typeof window.sap?.ui?.require === \"function\";\n\t}\n\n\tstatic init() {\n\t\tif (!OpenUI5Support.isOpenUI5Detected()) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\n\t\treturn new Promise<void>(resolve => {\n\t\t\twindow.sap.ui.require([\"sap/ui/core/Core\"], async (Core: OpenUI5Core) => {\n\t\t\t\tconst callback = () => {\n\t\t\t\t\tlet deps: Array<string> = [\"sap/ui/core/Popup\", \"sap/ui/core/Patcher\", \"sap/ui/core/LocaleData\"];\n\t\t\t\t\tif (OpenUI5Support.isAtLeastVersion116()) { // for versions since 1.116.0 and onward, use the modular core\n\t\t\t\t\t\tdeps = [\n\t\t\t\t\t\t\t...deps,\n\t\t\t\t\t\t\t\"sap/base/i18n/Formatting\",\n\t\t\t\t\t\t\t\"sap/base/i18n/Localization\",\n\t\t\t\t\t\t\t\"sap/ui/core/ControlBehavior\",\n\t\t\t\t\t\t\t\"sap/ui/core/Theming\",\n\t\t\t\t\t\t\t\"sap/ui/core/date/CalendarUtils\",\n\t\t\t\t\t\t];\n\t\t\t\t\t}\n\t\t\t\t\twindow.sap.ui.require(deps, (Popup: OpenUI5Popup, Patcher: OpenUI5Patcher) => {\n\t\t\t\t\t\tpatchPatcher(Patcher);\n\t\t\t\t\t\tpatchPopup(Popup);\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t});\n\t\t\t\t};\n\t\t\t\tif (OpenUI5Support.isAtLeastVersion116()) {\n\t\t\t\t\tawait Core.ready();\n\t\t\t\t\tcallback();\n\t\t\t\t} else {\n\t\t\t\t\tCore.attachInit(callback);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\tstatic getConfigurationSettingsObject() {\n\t\tif (!OpenUI5Support.isOpenUI5Detected()) {\n\t\t\treturn {};\n\t\t}\n\n\t\tif (OpenUI5Support.isAtLeastVersion116()) {\n\t\t\tconst ControlBehavior = window.sap.ui.require(\"sap/ui/core/ControlBehavior\") as ControlBehavior;\n\t\t\tconst Localization = window.sap.ui.require(\"sap/base/i18n/Localization\") as Localization;\n\t\t\tconst Theming = window.sap.ui.require(\"sap/ui/core/Theming\") as Theming;\n\t\t\tconst Formatting = window.sap.ui.require(\"sap/base/i18n/Formatting\") as Formatting;\n\t\t\tconst CalendarUtils = window.sap.ui.require(\"sap/ui/core/date/CalendarUtils\") as CalendarUtils;\n\n\t\t\treturn {\n\t\t\t\tanimationMode: ControlBehavior.getAnimationMode(),\n\t\t\t\tlanguage: Localization.getLanguage(),\n\t\t\t\ttheme: Theming.getTheme(),\n\t\t\t\tthemeRoot: Theming.getThemeRoot(),\n\t\t\t\trtl: Localization.getRTL(),\n\t\t\t\ttimezone: Localization.getTimezone(),\n\t\t\t\tcalendarType: Formatting.getCalendarType(),\n\t\t\t\tformatSettings: {\n\t\t\t\t\tfirstDayOfWeek: CalendarUtils.getWeekConfigurationValues().firstDayOfWeek,\n\t\t\t\t\tlegacyDateCalendarCustomizing: Formatting.getCustomIslamicCalendarData?.()\n\t\t\t\t\t\t\t\t\t\t\t\t?? Formatting.getLegacyDateCalendarCustomizing?.(),\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tconst Core = window.sap.ui.require(\"sap/ui/core/Core\") as OpenUI5Core;\n\t\tconst config = Core.getConfiguration();\n\t\tconst LocaleData = window.sap.ui.require(\"sap/ui/core/LocaleData\") as LocaleData;\n\n\t\treturn {\n\t\t\tanimationMode: config.getAnimationMode(),\n\t\t\tlanguage: config.getLanguage(),\n\t\t\ttheme: config.getTheme(),\n\t\t\tthemeRoot: config.getThemeRoot(),\n\t\t\trtl: config.getRTL(),\n\t\t\ttimezone: config.getTimezone(),\n\t\t\tcalendarType: config.getCalendarType(),\n\t\t\tformatSettings: {\n\t\t\t\tfirstDayOfWeek: LocaleData ? LocaleData.getInstance(config.getLocale()).getFirstDayOfWeek() : undefined,\n\t\t\t\tlegacyDateCalendarCustomizing: config.getFormatSettings().getLegacyDateCalendarCustomizing(),\n\t\t\t},\n\t\t};\n\t}\n\n\tstatic getLocaleDataObject() {\n\t\tif (!OpenUI5Support.isOpenUI5Detected()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst LocaleData = window.sap.ui.require(\"sap/ui/core/LocaleData\") as LocaleData;\n\n\t\tif (OpenUI5Support.isAtLeastVersion116()) {\n\t\t\tconst Localization = window.sap.ui.require(\"sap/base/i18n/Localization\") as Localization;\n\t\t\treturn LocaleData.getInstance(Localization.getLanguageTag())._get();\n\t\t}\n\n\t\tconst Core = window.sap.ui.require(\"sap/ui/core/Core\") as OpenUI5Core;\n\t\tconst config = Core.getConfiguration();\n\t\treturn LocaleData.getInstance(config.getLocale())._get();\n\t}\n\n\tstatic _listenForThemeChange() {\n\t\tif (OpenUI5Support.isAtLeastVersion116()) {\n\t\t\tconst Theming: Theming = window.sap.ui.require(\"sap/ui/core/Theming\");\n\t\t\tTheming.attachApplied(() => {\n\t\t\t\tsetTheme(Theming.getTheme());\n\t\t\t});\n\t\t} else {\n\t\t\tconst Core = window.sap.ui.require(\"sap/ui/core/Core\") as OpenUI5Core;\n\t\t\tconst config = Core.getConfiguration();\n\t\t\tCore.attachThemeChanged(() => {\n\t\t\t\tsetTheme(config.getTheme());\n\t\t\t});\n\t\t}\n\t}\n\n\tstatic attachListeners() {\n\t\tif (!OpenUI5Support.isOpenUI5Detected()) {\n\t\t\treturn;\n\t\t}\n\n\t\tOpenUI5Support._listenForThemeChange();\n\t}\n\n\tstatic cssVariablesLoaded() {\n\t\tif (!OpenUI5Support.isOpenUI5Detected()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst link = [...document.head.children].find(el => el.id === \"sap-ui-theme-sap.ui.core\") as HTMLLinkElement; // more reliable than querySelector early\n\t\tif (!link) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn !!link.href.match(/\\/css(-|_)variables\\.css/);\n\t}\n}\n\nregisterFeature(\"OpenUI5Support\", OpenUI5Support);\n\nexport default OpenUI5Support;\n"],
|
|
5
|
-
"mappings": "aAAA,OAAOA,MAAkB,oBAEzB,OAAOC,MAAgB,kBAEvB,OAAS,mBAAAC,MAAuB,yBAChC,OAAS,YAAAC,MAAgB,qBA+DzB,MAAMC,CAAe,CACpB,OAAO,qBAAsB,
|
|
4
|
+
"sourcesContent": ["import patchPatcher from \"./patchPatcher.js\";\nimport type { OpenUI5Patcher } from \"./patchPatcher.js\";\nimport patchPopup from \"./patchPopup.js\";\nimport type { OpenUI5Popup } from \"./patchPopup.js\";\nimport { registerFeature } from \"../FeaturesRegistry.js\";\nimport { setTheme } from \"../config/Theme.js\";\nimport type { CLDRData } from \"../asset-registries/LocaleData.js\";\nimport type { LegacyDateCalendarCustomizing } from \"../features/LegacyDateFormats.js\";\n\ntype OpenUI5Core = {\n\tattachInit: (callback: () => void) => void,\n\tready: () => Promise<void>,\n\tattachThemeChanged: (callback: () => void) => void,\n\tgetConfiguration: () => OpenUI5CoreConfiguration,\n};\n\ntype OpenUI5CoreConfiguration = {\n\tgetAnimationMode: () => string,\n\tgetLanguage: () => string,\n\tgetTheme: () => string,\n\tgetThemeRoot: () => string,\n\tgetRTL: () => string,\n\tgetTimezone: () => string,\n\tgetCalendarType: () => string,\n\tgetLocale: () => string,\n\tgetFormatSettings: () => {\n\t\tgetLegacyDateCalendarCustomizing: () => LegacyDateCalendarCustomizing;\n\t}\n};\n\ntype ControlBehavior = {\n\tgetAnimationMode: () => string,\n}\n\ntype Localization = {\n\tgetLanguage: () => string,\n\tgetLanguageTag: () => string,\n\tgetRTL: () => string,\n\tgetTimezone: () => string,\n}\n\ntype LocaleData = {\n\tgetInstance: (locale: string) => Locale,\n}\n\ntype Theming = {\n\tgetThemeRoot: () => string,\n\tgetTheme: () => string,\n\tattachApplied: (callback: () => void) => void,\n}\n\ntype Formatting = {\n\tgetCalendarType: () => string,\n\tgetLegacyDateCalendarCustomizing: () => LegacyDateCalendarCustomizing,\n\tgetCustomIslamicCalendarData?: () => LegacyDateCalendarCustomizing,\n}\n\ntype CalendarUtils = {\n\tgetWeekConfigurationValues: () => {\n\t\tfirstDayOfWeek: number | undefined,\n\t},\n}\n\ntype Locale = {\n\tgetFirstDayOfWeek: () => number,\n\t_get: () => CLDRData,\n};\n\nclass OpenUI5Support {\n\tstatic isAtLeastVersion116() {\n\t\tif (!window.sap.ui!.version) {\n\t\t\treturn true; // sap.ui.version will be removed in newer OpenUI5 versions\n\t\t}\n\t\tconst version = window.sap.ui!.version as string;\n\t\tconst parts = version.split(\".\");\n\t\tif (!parts || parts.length < 2) {\n\t\t\treturn false;\n\t\t}\n\t\treturn parseInt(parts[0]) > 1 || parseInt(parts[1]) >= 116;\n\t}\n\n\tstatic isOpenUI5Detected() {\n\t\treturn typeof window.sap?.ui?.require === \"function\";\n\t}\n\n\tstatic init() {\n\t\tif (!OpenUI5Support.isOpenUI5Detected()) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\n\t\treturn new Promise<void>(resolve => {\n\t\t\twindow.sap.ui.require([\"sap/ui/core/Core\"], async (Core: OpenUI5Core) => {\n\t\t\t\tconst callback = () => {\n\t\t\t\t\tlet deps: Array<string> = [\"sap/ui/core/Popup\", \"sap/ui/core/Patcher\", \"sap/ui/core/LocaleData\"];\n\t\t\t\t\tif (OpenUI5Support.isAtLeastVersion116()) { // for versions since 1.116.0 and onward, use the modular core\n\t\t\t\t\t\tdeps = [\n\t\t\t\t\t\t\t...deps,\n\t\t\t\t\t\t\t\"sap/base/i18n/Formatting\",\n\t\t\t\t\t\t\t\"sap/base/i18n/Localization\",\n\t\t\t\t\t\t\t\"sap/ui/core/ControlBehavior\",\n\t\t\t\t\t\t\t\"sap/ui/core/Theming\",\n\t\t\t\t\t\t\t\"sap/ui/core/date/CalendarUtils\",\n\t\t\t\t\t\t];\n\t\t\t\t\t}\n\t\t\t\t\twindow.sap.ui.require(deps, (Popup: OpenUI5Popup, Patcher: OpenUI5Patcher) => {\n\t\t\t\t\t\tpatchPatcher(Patcher);\n\t\t\t\t\t\tpatchPopup(Popup);\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t});\n\t\t\t\t};\n\t\t\t\tif (OpenUI5Support.isAtLeastVersion116()) {\n\t\t\t\t\tawait Core.ready();\n\t\t\t\t\tcallback();\n\t\t\t\t} else {\n\t\t\t\t\tCore.attachInit(callback);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\tstatic getConfigurationSettingsObject() {\n\t\tif (!OpenUI5Support.isOpenUI5Detected()) {\n\t\t\treturn {};\n\t\t}\n\n\t\tif (OpenUI5Support.isAtLeastVersion116()) {\n\t\t\tconst ControlBehavior = window.sap.ui.require(\"sap/ui/core/ControlBehavior\") as ControlBehavior;\n\t\t\tconst Localization = window.sap.ui.require(\"sap/base/i18n/Localization\") as Localization;\n\t\t\tconst Theming = window.sap.ui.require(\"sap/ui/core/Theming\") as Theming;\n\t\t\tconst Formatting = window.sap.ui.require(\"sap/base/i18n/Formatting\") as Formatting;\n\t\t\tconst CalendarUtils = window.sap.ui.require(\"sap/ui/core/date/CalendarUtils\") as CalendarUtils;\n\n\t\t\treturn {\n\t\t\t\tanimationMode: ControlBehavior.getAnimationMode(),\n\t\t\t\tlanguage: Localization.getLanguage(),\n\t\t\t\ttheme: Theming.getTheme(),\n\t\t\t\tthemeRoot: Theming.getThemeRoot(),\n\t\t\t\trtl: Localization.getRTL(),\n\t\t\t\ttimezone: Localization.getTimezone(),\n\t\t\t\tcalendarType: Formatting.getCalendarType(),\n\t\t\t\tformatSettings: {\n\t\t\t\t\tfirstDayOfWeek: CalendarUtils.getWeekConfigurationValues().firstDayOfWeek,\n\t\t\t\t\tlegacyDateCalendarCustomizing: Formatting.getCustomIslamicCalendarData?.()\n\t\t\t\t\t\t\t\t\t\t\t\t?? Formatting.getLegacyDateCalendarCustomizing?.(),\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tconst Core = window.sap.ui.require(\"sap/ui/core/Core\") as OpenUI5Core;\n\t\tconst config = Core.getConfiguration();\n\t\tconst LocaleData = window.sap.ui.require(\"sap/ui/core/LocaleData\") as LocaleData;\n\n\t\treturn {\n\t\t\tanimationMode: config.getAnimationMode(),\n\t\t\tlanguage: config.getLanguage(),\n\t\t\ttheme: config.getTheme(),\n\t\t\tthemeRoot: config.getThemeRoot(),\n\t\t\trtl: config.getRTL(),\n\t\t\ttimezone: config.getTimezone(),\n\t\t\tcalendarType: config.getCalendarType(),\n\t\t\tformatSettings: {\n\t\t\t\tfirstDayOfWeek: LocaleData ? LocaleData.getInstance(config.getLocale()).getFirstDayOfWeek() : undefined,\n\t\t\t\tlegacyDateCalendarCustomizing: config.getFormatSettings().getLegacyDateCalendarCustomizing(),\n\t\t\t},\n\t\t};\n\t}\n\n\tstatic getLocaleDataObject() {\n\t\tif (!OpenUI5Support.isOpenUI5Detected()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst LocaleData = window.sap.ui.require(\"sap/ui/core/LocaleData\") as LocaleData;\n\n\t\tif (OpenUI5Support.isAtLeastVersion116()) {\n\t\t\tconst Localization = window.sap.ui.require(\"sap/base/i18n/Localization\") as Localization;\n\t\t\treturn LocaleData.getInstance(Localization.getLanguageTag())._get();\n\t\t}\n\n\t\tconst Core = window.sap.ui.require(\"sap/ui/core/Core\") as OpenUI5Core;\n\t\tconst config = Core.getConfiguration();\n\t\treturn LocaleData.getInstance(config.getLocale())._get();\n\t}\n\n\tstatic _listenForThemeChange() {\n\t\tif (OpenUI5Support.isAtLeastVersion116()) {\n\t\t\tconst Theming: Theming = window.sap.ui.require(\"sap/ui/core/Theming\");\n\t\t\tTheming.attachApplied(() => {\n\t\t\t\tsetTheme(Theming.getTheme());\n\t\t\t});\n\t\t} else {\n\t\t\tconst Core = window.sap.ui.require(\"sap/ui/core/Core\") as OpenUI5Core;\n\t\t\tconst config = Core.getConfiguration();\n\t\t\tCore.attachThemeChanged(() => {\n\t\t\t\tsetTheme(config.getTheme());\n\t\t\t});\n\t\t}\n\t}\n\n\tstatic attachListeners() {\n\t\tif (!OpenUI5Support.isOpenUI5Detected()) {\n\t\t\treturn;\n\t\t}\n\n\t\tOpenUI5Support._listenForThemeChange();\n\t}\n\n\tstatic cssVariablesLoaded() {\n\t\tif (!OpenUI5Support.isOpenUI5Detected()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst link = [...document.head.children].find(el => el.id === \"sap-ui-theme-sap.ui.core\") as HTMLLinkElement; // more reliable than querySelector early\n\t\tif (!link) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn !!link.href.match(/\\/css(-|_)variables\\.css/);\n\t}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AE,KAAK,CACnE,CAGA,MAAMI,EADO,OAAO,IAAI,GAAG,QAAQ,kBAAkB,EACjC,iBAAiB,EACrC,OAAOC,EAAW,YAAYD,EAAO,UAAU,CAAC,EAAE,KAAK,CACxD,CAEA,OAAO,uBAAwB,CAC9B,GAAIb,EAAe,oBAAoB,EAAG,CACzC,MAAMU,EAAmB,OAAO,IAAI,GAAG,QAAQ,qBAAqB,EACpEA,EAAQ,cAAc,IAAM,CAC3BX,EAASW,EAAQ,SAAS,CAAC,CAC5B,CAAC,CACF,KAAO,CACN,MAAMP,EAAO,OAAO,IAAI,GAAG,QAAQ,kBAAkB,EAC/CU,EAASV,EAAK,iBAAiB,EACrCA,EAAK,mBAAmB,IAAM,CAC7BJ,EAASc,EAAO,SAAS,CAAC,CAC3B,CAAC,CACF,CACD,CAEA,OAAO,iBAAkB,CACnBb,EAAe,kBAAkB,GAItCA,EAAe,sBAAsB,CACtC,CAEA,OAAO,oBAAqB,CAC3B,GAAI,CAACA,EAAe,kBAAkB,EACrC,OAGD,MAAMe,EAAO,CAAC,GAAG,SAAS,KAAK,QAAQ,EAAE,KAAKC,GAAMA,EAAG,KAAO,0BAA0B,EACxF,OAAKD,EAIE,CAAC,CAACA,EAAK,KAAK,MAAM,0BAA0B,EAH3C,EAIT,CACD,CAEAjB,EAAgB,iBAAkBE,CAAc,EAEhD,eAAeA",
|
|
6
6
|
"names": ["patchPatcher", "patchPopup", "registerFeature", "setTheme", "OpenUI5Support", "parts", "resolve", "Core", "callback", "deps", "Popup", "Patcher", "ControlBehavior", "Localization", "Theming", "Formatting", "CalendarUtils", "config", "LocaleData", "link", "el"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const e={version:"2.0.0
|
|
1
|
+
"use strict";const e={version:"2.0.0",major:2,minor:0,patch:0,suffix:"",isNext:!1,buildTime:1720013643};export default e;
|
|
2
2
|
//# sourceMappingURL=VersionInfo.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/generated/VersionInfo.ts"],
|
|
4
|
-
"sourcesContent": ["const VersionInfo = {\n\tversion: \"2.0.0
|
|
5
|
-
"mappings": "aAAA,MAAMA,EAAc,CACnB,QAAS,
|
|
4
|
+
"sourcesContent": ["const VersionInfo = {\n\tversion: \"2.0.0\",\n\tmajor: 2,\n\tminor: 0,\n\tpatch: 0,\n\tsuffix: \"\",\n\tisNext: false,\n\tbuildTime: 1720013643,\n};\nexport default VersionInfo;"],
|
|
5
|
+
"mappings": "aAAA,MAAMA,EAAc,CACnB,QAAS,QACT,MAAO,EACP,MAAO,EACP,MAAO,EACP,OAAQ,GACR,OAAQ,GACR,UAAW,UACZ,EACA,eAAeA",
|
|
6
6
|
"names": ["VersionInfo"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/util/AriaLabelHelper.ts"],
|
|
4
|
-
"sourcesContent": ["import type UI5Element from \"../UI5Element.js\";\nimport type { ChangeInfo } from \"../UI5Element.js\";\n\ntype InvalidateCallback = (changeInfo: ChangeInfo) => void;\ntype MutationCallback = () => void;\ntype AssociatedElement = {\n\tobserver: MutationObserver | null;\n\tcallbacks: Array<MutationCallback>;\n};\ntype RegisteredElement = {\n\thost: UI5Element;\n\tobservedElements: Array<HTMLElement>;\n\tcallback: MutationCallback;\n\tinvalidationCallback: InvalidateCallback;\n};\n\nconst associatedElements = new WeakMap<HTMLElement, AssociatedElement>();\nconst registeredElements = new WeakMap<UI5Element, RegisteredElement>();\n\ntype AccessibleElement = HTMLElement & {\n\taccessibleNameRef
|
|
4
|
+
"sourcesContent": ["import type UI5Element from \"../UI5Element.js\";\nimport type { ChangeInfo } from \"../UI5Element.js\";\n\ntype InvalidateCallback = (changeInfo: ChangeInfo) => void;\ntype MutationCallback = () => void;\ntype AssociatedElement = {\n\tobserver: MutationObserver | null;\n\tcallbacks: Array<MutationCallback>;\n};\ntype RegisteredElement = {\n\thost: UI5Element;\n\tobservedElements: Array<HTMLElement>;\n\tcallback: MutationCallback;\n\tinvalidationCallback: InvalidateCallback;\n};\n\nconst associatedElements = new WeakMap<HTMLElement, AssociatedElement>();\nconst registeredElements = new WeakMap<UI5Element, RegisteredElement>();\n\ntype AccessibleElement = HTMLElement & {\n\taccessibleNameRef?: string;\n\taccessibleName?: string;\n};\n\nconst observerOptions = {\n\tattributes: true,\n\tchildList: true,\n\tcharacterData: true,\n\tsubtree: true,\n};\n\nconst getEffectiveAriaLabelText = (el: HTMLElement) => {\n\tconst accessibleEl = el as AccessibleElement;\n\n\tif (!accessibleEl.accessibleNameRef) {\n\t\tif (accessibleEl.accessibleName) {\n\t\t\treturn accessibleEl.accessibleName;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\treturn getAllAccessibleNameRefTexts(el);\n};\n\n/**\n *\n * @param {HTMLElement} el Defines the HTMLElement, for which you need to get all related texts\n */\nconst getAllAccessibleNameRefTexts = (el: HTMLElement) => {\n\tconst ids = (el as AccessibleElement).accessibleNameRef?.split(\" \") ?? [];\n\tconst owner = el.getRootNode() as HTMLElement;\n\tlet result = \"\";\n\n\tids.forEach((elementId: string, index: number) => {\n\t\tconst element = owner.querySelector(`[id='${elementId}']`);\n\t\tconst text = `${element && element.textContent ? element.textContent : \"\"}`;\n\t\tif (text) {\n\t\t\tresult += text;\n\t\t\tif (index < ids.length - 1) {\n\t\t\t\tresult += \" \";\n\t\t\t}\n\t\t}\n\t});\n\n\treturn result;\n};\n\nconst _getAllAssociatedElementsFromDOM = (el: UI5Element): Array<HTMLElement> => {\n\tconst set = new Set<HTMLElement>();\n\t// adding labels with attribute for matching the el.id\n\tconst labelsForAssociated = _getAssociatedLabels(el);\n\tlabelsForAssociated.forEach(itm => {\n\t\tset.add(itm);\n\t});\n\t// adding other elements that id is the same as accessibleNameRef value\n\tconst value = el[\"accessibleNameRef\" as keyof typeof el] as string;\n\tconst ids = value?.split(\" \") ?? [];\n\tids.forEach(id => {\n\t\tconst refEl = _getReferencedElementById(el, id);\n\t\tif (refEl) {\n\t\t\tset.add(refEl);\n\t\t}\n\t});\n\treturn Array.from(set);\n};\n\nconst _getAssociatedLabels = (el: HTMLElement): Array<HTMLElement> => {\n\tconst labels = (el.getRootNode() as HTMLElement).querySelectorAll<HTMLElement>(`[for=\"${el.id}\"]`);\n\treturn Array.from(labels);\n};\n\nconst _getReferencedElementById = (el: HTMLElement, elementId: string): HTMLElement | null => {\n\treturn (el.getRootNode() as HTMLElement).querySelector<HTMLElement>(`[id='${elementId}']`);\n};\n\n/**\n * @param {HTMLElement} el Defines the HTMLElement, for which you need to get all related \"label for\" texts\n */\nconst getAssociatedLabelForTexts = (el: HTMLElement) => {\n\tconst results: Array<string> = [];\n\tconst labels = _getAssociatedLabels(el);\n\n\tlabels.forEach((label: HTMLElement) => {\n\t\tconst labelText = label.textContent;\n\t\tlabelText && results.push(labelText);\n\t});\n\n\tif (results.length) {\n\t\treturn results.join(\" \");\n\t}\n\n\treturn undefined;\n};\n\nconst _createInvalidationCallback = (el: UI5Element) => {\n\tconst invalidationCallback = (changeInfo: ChangeInfo) => {\n\t\tif (!(changeInfo && changeInfo.type === \"property\" && changeInfo.name === \"accessibleNameRef\")) {\n\t\t\treturn;\n\t\t}\n\t\tconst registeredElement = registeredElements.get(el);\n\t\tif (!registeredElement) {\n\t\t\treturn;\n\t\t}\n\t\tconst oldAssociatedElements = registeredElement.observedElements;\n\t\tconst newAssociatedElements = _getAllAssociatedElementsFromDOM(el);\n\t\toldAssociatedElements.forEach(oldElement => {\n\t\t\tif (!newAssociatedElements.includes(oldElement)) {\n\t\t\t\t_removeObservedElementFromRegisteredElement(registeredElement, oldElement);\n\t\t\t}\n\t\t});\n\t\tnewAssociatedElements.forEach(newElement => {\n\t\t\tif (!oldAssociatedElements.includes(newElement)) {\n\t\t\t\t_addObservedElementToRegisteredElement(registeredElement, newElement);\n\t\t\t\tregisteredElement.observedElements.push(newElement);\n\t\t\t}\n\t\t});\n\t\tregisteredElement?.callback();\n\t};\n\treturn invalidationCallback;\n};\n\nconst registerUI5Element = (el: UI5Element, callback: MutationCallback) => {\n\tif (registeredElements.has(el)) {\n\t\treturn;\n\t}\n\tconst allAssociatedElements = _getAllAssociatedElementsFromDOM(el);\n\tconst invalidationCallback = _createInvalidationCallback(el);\n\tconst registeredElement = {\n\t\thost: el,\n\t\tobservedElements: allAssociatedElements,\n\t\tcallback,\n\t\tinvalidationCallback,\n\t};\n\tregisteredElements.set(el, registeredElement);\n\tel.attachInvalidate(invalidationCallback);\n\n\tallAssociatedElements.forEach((element: HTMLElement) => {\n\t\t_addObservedElementToRegisteredElement(registeredElement, element);\n\t});\n\tcallback();\n};\n\nconst _addObservedElementToRegisteredElement = (registeredElement: RegisteredElement, element: HTMLElement) => {\n\tlet associatedElement = associatedElements.get(element);\n\tif (!associatedElement) {\n\t\tassociatedElement = { observer: null, callbacks: [] };\n\t\tconst observer = new MutationObserver(() => {\n\t\t\tconst callbacks = (associatedElement as AssociatedElement).callbacks;\n\t\t\tcallbacks.forEach(callback => {\n\t\t\t\tcallback();\n\t\t\t});\n\t\t\tconst domEl = document.getElementById(element.id);\n\t\t\t// if no longer should be observed from this registeredElement, remove it\n\t\t\tif (!(registeredElement.host.id === element.getAttribute(\"for\") || domEl)) {\n\t\t\t\t_removeObservedElementFromRegisteredElement(registeredElement, element);\n\t\t\t}\n\t\t});\n\t\tassociatedElement.observer = observer;\n\t\tobserver.observe(element, observerOptions);\n\t\tassociatedElements.set(element, associatedElement);\n\t}\n\tif (!associatedElement.callbacks.includes(registeredElement.callback)) {\n\t\tassociatedElement.callbacks.push(registeredElement.callback);\n\t}\n};\n\nconst _removeObservedElementFromRegisteredElement = (registeredElement: RegisteredElement, element: HTMLElement) => {\n\tconst associatedElement = associatedElements.get(element);\n\tif (associatedElement) {\n\t\tassociatedElement.callbacks = associatedElement.callbacks.filter(itm => itm !== registeredElement.callback);\n\t\tif (!associatedElement.callbacks.length) {\n\t\t\tassociatedElement.observer?.disconnect();\n\t\t\tassociatedElements.delete(element);\n\t\t}\n\t}\n\tregisteredElement.observedElements = registeredElement.observedElements.filter(itm => itm !== element);\n};\n\nconst deregisterUI5Element = (el: UI5Element) => {\n\tconst registeredElement = registeredElements.get(el);\n\tif (!registeredElement) {\n\t\treturn;\n\t}\n\tconst oldObservedElements = [...registeredElement.observedElements];\n\toldObservedElements.forEach(observedElement => {\n\t\t_removeObservedElementFromRegisteredElement(registeredElement, observedElement);\n\t});\n\tel.detachInvalidate(registeredElement.invalidationCallback);\n\tregisteredElements.delete(el);\n};\n\nexport {\n\tgetEffectiveAriaLabelText,\n\tgetAssociatedLabelForTexts,\n\tregisterUI5Element,\n\tderegisterUI5Element,\n\tgetAllAccessibleNameRefTexts,\n};\n"],
|
|
5
5
|
"mappings": "aAgBA,MAAMA,EAAqB,IAAI,QACzBC,EAAqB,IAAI,QAOzBC,EAAkB,CACvB,WAAY,GACZ,UAAW,GACX,cAAe,GACf,QAAS,EACV,EAEMC,EAA6BC,GAAoB,CACtD,MAAMC,EAAeD,EAErB,OAAKC,EAAa,kBAQXC,EAA6BF,CAAE,EAPjCC,EAAa,eACTA,EAAa,eAGrB,MAIF,EAMMC,EAAgCF,GAAoB,CACzD,MAAMG,EAAOH,EAAyB,mBAAmB,MAAM,GAAG,GAAK,CAAC,EAClEI,EAAQJ,EAAG,YAAY,EAC7B,IAAIK,EAAS,GAEb,OAAAF,EAAI,QAAQ,CAACG,EAAmBC,IAAkB,CACjD,MAAMC,EAAUJ,EAAM,cAAc,QAAQE,CAAS,IAAI,EACnDG,EAAO,GAAGD,GAAWA,EAAQ,YAAcA,EAAQ,YAAc,EAAE,GACrEC,IACHJ,GAAUI,EACNF,EAAQJ,EAAI,OAAS,IACxBE,GAAU,KAGb,CAAC,EAEMA,CACR,EAEMK,EAAoCV,GAAuC,CAChF,MAAMW,EAAM,IAAI,IAGhB,OAD4BC,EAA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AAOX,GAAOA,IAAQL,CAAO,CACtG,EAEM8B,EAAwBtC,GAAmB,CAChD,MAAMwB,EAAoB3B,EAAmB,IAAIG,CAAE,EACnD,GAAI,CAACwB,EACJ,OAE2B,CAAC,GAAGA,EAAkB,gBAAgB,EAC9C,QAAQe,GAAmB,CAC9CX,EAA4CJ,EAAmBe,CAAe,CAC/E,CAAC,EACDvC,EAAG,iBAAiBwB,EAAkB,oBAAoB,EAC1D3B,EAAmB,OAAOG,CAAE,CAC7B,EAEA,OACCD,KAAA,0BACAmB,KAAA,2BACAa,KAAA,mBACAO,KAAA,qBACApC,KAAA",
|
|
6
6
|
"names": ["associatedElements", "registeredElements", "observerOptions", "getEffectiveAriaLabelText", "el", "accessibleEl", "getAllAccessibleNameRefTexts", "ids", "owner", "result", "elementId", "index", "element", "text", "_getAllAssociatedElementsFromDOM", "set", "_getAssociatedLabels", "itm", "id", "refEl", "_getReferencedElementById", "labels", "getAssociatedLabelForTexts", "results", "label", "labelText", "_createInvalidationCallback", "changeInfo", "registeredElement", "oldAssociatedElements", "newAssociatedElements", "oldElement", "_removeObservedElementFromRegisteredElement", "newElement", "_addObservedElementToRegisteredElement", "registerUI5Element", "callback", "allAssociatedElements", "invalidationCallback", "associatedElement", "observer", "domEl", "deregisterUI5Element", "observedElement"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AriaLabelHelper.js","sourceRoot":"","sources":["../../src/util/AriaLabelHelper.ts"],"names":[],"mappings":"AAgBA,MAAM,kBAAkB,GAAG,IAAI,OAAO,EAAkC,CAAC;AACzE,MAAM,kBAAkB,GAAG,IAAI,OAAO,EAAiC,CAAC;AAOxE,MAAM,eAAe,GAAG;IACvB,UAAU,EAAE,IAAI;IAChB,SAAS,EAAE,IAAI;IACf,aAAa,EAAE,IAAI;IACnB,OAAO,EAAE,IAAI;CACb,CAAC;AAEF,MAAM,yBAAyB,GAAG,CAAC,EAAe,EAAE,EAAE;IACrD,MAAM,YA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AAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACrD,IAAI,CAAC,iBAAiB,EAAE;QACvB,OAAO;KACP;IACD,MAAM,mBAAmB,GAAG,CAAC,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IACpE,mBAAmB,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE;QAC7C,2CAA2C,CAAC,iBAAiB,EAAE,eAAe,CAAC,CAAC;IACjF,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;IAC5D,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAC/B,CAAC,CAAC;AAEF,OAAO,EACN,yBAAyB,EACzB,0BAA0B,EAC1B,kBAAkB,EAClB,oBAAoB,EACpB,4BAA4B,GAC5B,CAAC","sourcesContent":["import type UI5Element from \"../UI5Element.js\";\nimport type { ChangeInfo } from \"../UI5Element.js\";\n\ntype InvalidateCallback = (changeInfo: ChangeInfo) => void;\ntype MutationCallback = () => void;\ntype AssociatedElement = {\n\tobserver: MutationObserver | null;\n\tcallbacks: Array<MutationCallback>;\n};\ntype RegisteredElement = {\n\thost: UI5Element;\n\tobservedElements: Array<HTMLElement>;\n\tcallback: MutationCallback;\n\tinvalidationCallback: InvalidateCallback;\n};\n\nconst associatedElements = new WeakMap<HTMLElement, AssociatedElement>();\nconst registeredElements = new WeakMap<UI5Element, RegisteredElement>();\n\ntype AccessibleElement = HTMLElement & {\n\taccessibleNameRef: string;\n\taccessibleName: string;\n};\n\nconst observerOptions = {\n\tattributes: true,\n\tchildList: true,\n\tcharacterData: true,\n\tsubtree: true,\n};\n\nconst getEffectiveAriaLabelText = (el: HTMLElement) => {\n\tconst accessibleEl = el as AccessibleElement;\n\n\tif (!accessibleEl.accessibleNameRef) {\n\t\tif (accessibleEl.accessibleName) {\n\t\t\treturn accessibleEl.accessibleName;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\treturn getAllAccessibleNameRefTexts(el);\n};\n\n/**\n *\n * @param {HTMLElement} el Defines the HTMLElement, for which you need to get all related texts\n */\nconst getAllAccessibleNameRefTexts = (el: HTMLElement) => {\n\tconst ids = (el as AccessibleElement).accessibleNameRef?.split(\" \") ?? [];\n\tconst owner = el.getRootNode() as HTMLElement;\n\tlet result = \"\";\n\n\tids.forEach((elementId: string, index: number) => {\n\t\tconst element = owner.querySelector(`[id='${elementId}']`);\n\t\tconst text = `${element && element.textContent ? element.textContent : \"\"}`;\n\t\tif (text) {\n\t\t\tresult += text;\n\t\t\tif (index < ids.length - 1) {\n\t\t\t\tresult += \" \";\n\t\t\t}\n\t\t}\n\t});\n\n\treturn result;\n};\n\nconst _getAllAssociatedElementsFromDOM = (el: UI5Element): Array<HTMLElement> => {\n\tconst set = new Set<HTMLElement>();\n\t// adding labels with attribute for matching the el.id\n\tconst labelsForAssociated = _getAssociatedLabels(el);\n\tlabelsForAssociated.forEach(itm => {\n\t\tset.add(itm);\n\t});\n\t// adding other elements that id is the same as accessibleNameRef value\n\tconst value = el[\"accessibleNameRef\" as keyof typeof el] as string;\n\tconst ids = value?.split(\" \") ?? [];\n\tids.forEach(id => {\n\t\tconst refEl = _getReferencedElementById(el, id);\n\t\tif (refEl) {\n\t\t\tset.add(refEl);\n\t\t}\n\t});\n\treturn Array.from(set);\n};\n\nconst _getAssociatedLabels = (el: HTMLElement): Array<HTMLElement> => {\n\tconst labels = (el.getRootNode() as HTMLElement).querySelectorAll<HTMLElement>(`[for=\"${el.id}\"]`);\n\treturn Array.from(labels);\n};\n\nconst _getReferencedElementById = (el: HTMLElement, elementId: string): HTMLElement | null => {\n\treturn (el.getRootNode() as HTMLElement).querySelector<HTMLElement>(`[id='${elementId}']`);\n};\n\n/**\n * @param {HTMLElement} el Defines the HTMLElement, for which you need to get all related \"label for\" texts\n */\nconst getAssociatedLabelForTexts = (el: HTMLElement) => {\n\tconst results: Array<string> = [];\n\tconst labels = _getAssociatedLabels(el);\n\n\tlabels.forEach((label: HTMLElement) => {\n\t\tconst labelText = label.textContent;\n\t\tlabelText && results.push(labelText);\n\t});\n\n\tif (results.length) {\n\t\treturn results.join(\" \");\n\t}\n\n\treturn undefined;\n};\n\nconst _createInvalidationCallback = (el: UI5Element) => {\n\tconst invalidationCallback = (changeInfo: ChangeInfo) => {\n\t\tif (!(changeInfo && changeInfo.type === \"property\" && changeInfo.name === \"accessibleNameRef\")) {\n\t\t\treturn;\n\t\t}\n\t\tconst registeredElement = registeredElements.get(el);\n\t\tif (!registeredElement) {\n\t\t\treturn;\n\t\t}\n\t\tconst oldAssociatedElements = registeredElement.observedElements;\n\t\tconst newAssociatedElements = _getAllAssociatedElementsFromDOM(el);\n\t\toldAssociatedElements.forEach(oldElement => {\n\t\t\tif (!newAssociatedElements.includes(oldElement)) {\n\t\t\t\t_removeObservedElementFromRegisteredElement(registeredElement, oldElement);\n\t\t\t}\n\t\t});\n\t\tnewAssociatedElements.forEach(newElement => {\n\t\t\tif (!oldAssociatedElements.includes(newElement)) {\n\t\t\t\t_addObservedElementToRegisteredElement(registeredElement, newElement);\n\t\t\t\tregisteredElement.observedElements.push(newElement);\n\t\t\t}\n\t\t});\n\t\tregisteredElement?.callback();\n\t};\n\treturn invalidationCallback;\n};\n\nconst registerUI5Element = (el: UI5Element, callback: MutationCallback) => {\n\tif (registeredElements.has(el)) {\n\t\treturn;\n\t}\n\tconst allAssociatedElements = _getAllAssociatedElementsFromDOM(el);\n\tconst invalidationCallback = _createInvalidationCallback(el);\n\tconst registeredElement = {\n\t\thost: el,\n\t\tobservedElements: allAssociatedElements,\n\t\tcallback,\n\t\tinvalidationCallback,\n\t};\n\tregisteredElements.set(el, registeredElement);\n\tel.attachInvalidate(invalidationCallback);\n\n\tallAssociatedElements.forEach((element: HTMLElement) => {\n\t\t_addObservedElementToRegisteredElement(registeredElement, element);\n\t});\n\tcallback();\n};\n\nconst _addObservedElementToRegisteredElement = (registeredElement: RegisteredElement, element: HTMLElement) => {\n\tlet associatedElement = associatedElements.get(element);\n\tif (!associatedElement) {\n\t\tassociatedElement = { observer: null, callbacks: [] };\n\t\tconst observer = new MutationObserver(() => {\n\t\t\tconst callbacks = (associatedElement as AssociatedElement).callbacks;\n\t\t\tcallbacks.forEach(callback => {\n\t\t\t\tcallback();\n\t\t\t});\n\t\t\tconst domEl = document.getElementById(element.id);\n\t\t\t// if no longer should be observed from this registeredElement, remove it\n\t\t\tif (!(registeredElement.host.id === element.getAttribute(\"for\") || domEl)) {\n\t\t\t\t_removeObservedElementFromRegisteredElement(registeredElement, element);\n\t\t\t}\n\t\t});\n\t\tassociatedElement.observer = observer;\n\t\tobserver.observe(element, observerOptions);\n\t\tassociatedElements.set(element, associatedElement);\n\t}\n\tif (!associatedElement.callbacks.includes(registeredElement.callback)) {\n\t\tassociatedElement.callbacks.push(registeredElement.callback);\n\t}\n};\n\nconst _removeObservedElementFromRegisteredElement = (registeredElement: RegisteredElement, element: HTMLElement) => {\n\tconst associatedElement = associatedElements.get(element);\n\tif (associatedElement) {\n\t\tassociatedElement.callbacks = associatedElement.callbacks.filter(itm => itm !== registeredElement.callback);\n\t\tif (!associatedElement.callbacks.length) {\n\t\t\tassociatedElement.observer?.disconnect();\n\t\t\tassociatedElements.delete(element);\n\t\t}\n\t}\n\tregisteredElement.observedElements = registeredElement.observedElements.filter(itm => itm !== element);\n};\n\nconst deregisterUI5Element = (el: UI5Element) => {\n\tconst registeredElement = registeredElements.get(el);\n\tif (!registeredElement) {\n\t\treturn;\n\t}\n\tconst oldObservedElements = [...registeredElement.observedElements];\n\toldObservedElements.forEach(observedElement => {\n\t\t_removeObservedElementFromRegisteredElement(registeredElement, observedElement);\n\t});\n\tel.detachInvalidate(registeredElement.invalidationCallback);\n\tregisteredElements.delete(el);\n};\n\nexport {\n\tgetEffectiveAriaLabelText,\n\tgetAssociatedLabelForTexts,\n\tregisterUI5Element,\n\tderegisterUI5Element,\n\tgetAllAccessibleNameRefTexts,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"AriaLab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C,MAAM,EAAE;YACxC,iBAAiB,CAAC,QAAQ,EAAE,UAAU,EAAE,CAAC;YACzC,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;SACnC;KACD;IACD,iBAAiB,CAAC,gBAAgB,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,OAAO,CAAC,CAAC;AACxG,CAAC,CAAC;AAEF,MAAM,oBAAoB,GAAG,CAAC,EAAc,EAAE,EAAE;IAC/C,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACrD,IAAI,CAAC,iBAAiB,EAAE;QACvB,OAAO;KACP;IACD,MAAM,mBAAmB,GAAG,CAAC,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IACpE,mBAAmB,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE;QAC7C,2CAA2C,CAAC,iBAAiB,EAAE,eAAe,CAAC,CAAC;IACjF,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;IAC5D,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAC/B,CAAC,CAAC;AAEF,OAAO,EACN,yBAAyB,EACzB,0BAA0B,EAC1B,kBAAkB,EAClB,oBAAoB,EACpB,4BAA4B,GAC5B,CAAC","sourcesContent":["import type UI5Element from \"../UI5Element.js\";\nimport type { ChangeInfo } from \"../UI5Element.js\";\n\ntype InvalidateCallback = (changeInfo: ChangeInfo) => void;\ntype MutationCallback = () => void;\ntype AssociatedElement = {\n\tobserver: MutationObserver | null;\n\tcallbacks: Array<MutationCallback>;\n};\ntype RegisteredElement = {\n\thost: UI5Element;\n\tobservedElements: Array<HTMLElement>;\n\tcallback: MutationCallback;\n\tinvalidationCallback: InvalidateCallback;\n};\n\nconst associatedElements = new WeakMap<HTMLElement, AssociatedElement>();\nconst registeredElements = new WeakMap<UI5Element, RegisteredElement>();\n\ntype AccessibleElement = HTMLElement & {\n\taccessibleNameRef?: string;\n\taccessibleName?: string;\n};\n\nconst observerOptions = {\n\tattributes: true,\n\tchildList: true,\n\tcharacterData: true,\n\tsubtree: true,\n};\n\nconst getEffectiveAriaLabelText = (el: HTMLElement) => {\n\tconst accessibleEl = el as AccessibleElement;\n\n\tif (!accessibleEl.accessibleNameRef) {\n\t\tif (accessibleEl.accessibleName) {\n\t\t\treturn accessibleEl.accessibleName;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\treturn getAllAccessibleNameRefTexts(el);\n};\n\n/**\n *\n * @param {HTMLElement} el Defines the HTMLElement, for which you need to get all related texts\n */\nconst getAllAccessibleNameRefTexts = (el: HTMLElement) => {\n\tconst ids = (el as AccessibleElement).accessibleNameRef?.split(\" \") ?? [];\n\tconst owner = el.getRootNode() as HTMLElement;\n\tlet result = \"\";\n\n\tids.forEach((elementId: string, index: number) => {\n\t\tconst element = owner.querySelector(`[id='${elementId}']`);\n\t\tconst text = `${element && element.textContent ? element.textContent : \"\"}`;\n\t\tif (text) {\n\t\t\tresult += text;\n\t\t\tif (index < ids.length - 1) {\n\t\t\t\tresult += \" \";\n\t\t\t}\n\t\t}\n\t});\n\n\treturn result;\n};\n\nconst _getAllAssociatedElementsFromDOM = (el: UI5Element): Array<HTMLElement> => {\n\tconst set = new Set<HTMLElement>();\n\t// adding labels with attribute for matching the el.id\n\tconst labelsForAssociated = _getAssociatedLabels(el);\n\tlabelsForAssociated.forEach(itm => {\n\t\tset.add(itm);\n\t});\n\t// adding other elements that id is the same as accessibleNameRef value\n\tconst value = el[\"accessibleNameRef\" as keyof typeof el] as string;\n\tconst ids = value?.split(\" \") ?? [];\n\tids.forEach(id => {\n\t\tconst refEl = _getReferencedElementById(el, id);\n\t\tif (refEl) {\n\t\t\tset.add(refEl);\n\t\t}\n\t});\n\treturn Array.from(set);\n};\n\nconst _getAssociatedLabels = (el: HTMLElement): Array<HTMLElement> => {\n\tconst labels = (el.getRootNode() as HTMLElement).querySelectorAll<HTMLElement>(`[for=\"${el.id}\"]`);\n\treturn Array.from(labels);\n};\n\nconst _getReferencedElementById = (el: HTMLElement, elementId: string): HTMLElement | null => {\n\treturn (el.getRootNode() as HTMLElement).querySelector<HTMLElement>(`[id='${elementId}']`);\n};\n\n/**\n * @param {HTMLElement} el Defines the HTMLElement, for which you need to get all related \"label for\" texts\n */\nconst getAssociatedLabelForTexts = (el: HTMLElement) => {\n\tconst results: Array<string> = [];\n\tconst labels = _getAssociatedLabels(el);\n\n\tlabels.forEach((label: HTMLElement) => {\n\t\tconst labelText = label.textContent;\n\t\tlabelText && results.push(labelText);\n\t});\n\n\tif (results.length) {\n\t\treturn results.join(\" \");\n\t}\n\n\treturn undefined;\n};\n\nconst _createInvalidationCallback = (el: UI5Element) => {\n\tconst invalidationCallback = (changeInfo: ChangeInfo) => {\n\t\tif (!(changeInfo && changeInfo.type === \"property\" && changeInfo.name === \"accessibleNameRef\")) {\n\t\t\treturn;\n\t\t}\n\t\tconst registeredElement = registeredElements.get(el);\n\t\tif (!registeredElement) {\n\t\t\treturn;\n\t\t}\n\t\tconst oldAssociatedElements = registeredElement.observedElements;\n\t\tconst newAssociatedElements = _getAllAssociatedElementsFromDOM(el);\n\t\toldAssociatedElements.forEach(oldElement => {\n\t\t\tif (!newAssociatedElements.includes(oldElement)) {\n\t\t\t\t_removeObservedElementFromRegisteredElement(registeredElement, oldElement);\n\t\t\t}\n\t\t});\n\t\tnewAssociatedElements.forEach(newElement => {\n\t\t\tif (!oldAssociatedElements.includes(newElement)) {\n\t\t\t\t_addObservedElementToRegisteredElement(registeredElement, newElement);\n\t\t\t\tregisteredElement.observedElements.push(newElement);\n\t\t\t}\n\t\t});\n\t\tregisteredElement?.callback();\n\t};\n\treturn invalidationCallback;\n};\n\nconst registerUI5Element = (el: UI5Element, callback: MutationCallback) => {\n\tif (registeredElements.has(el)) {\n\t\treturn;\n\t}\n\tconst allAssociatedElements = _getAllAssociatedElementsFromDOM(el);\n\tconst invalidationCallback = _createInvalidationCallback(el);\n\tconst registeredElement = {\n\t\thost: el,\n\t\tobservedElements: allAssociatedElements,\n\t\tcallback,\n\t\tinvalidationCallback,\n\t};\n\tregisteredElements.set(el, registeredElement);\n\tel.attachInvalidate(invalidationCallback);\n\n\tallAssociatedElements.forEach((element: HTMLElement) => {\n\t\t_addObservedElementToRegisteredElement(registeredElement, element);\n\t});\n\tcallback();\n};\n\nconst _addObservedElementToRegisteredElement = (registeredElement: RegisteredElement, element: HTMLElement) => {\n\tlet associatedElement = associatedElements.get(element);\n\tif (!associatedElement) {\n\t\tassociatedElement = { observer: null, callbacks: [] };\n\t\tconst observer = new MutationObserver(() => {\n\t\t\tconst callbacks = (associatedElement as AssociatedElement).callbacks;\n\t\t\tcallbacks.forEach(callback => {\n\t\t\t\tcallback();\n\t\t\t});\n\t\t\tconst domEl = document.getElementById(element.id);\n\t\t\t// if no longer should be observed from this registeredElement, remove it\n\t\t\tif (!(registeredElement.host.id === element.getAttribute(\"for\") || domEl)) {\n\t\t\t\t_removeObservedElementFromRegisteredElement(registeredElement, element);\n\t\t\t}\n\t\t});\n\t\tassociatedElement.observer = observer;\n\t\tobserver.observe(element, observerOptions);\n\t\tassociatedElements.set(element, associatedElement);\n\t}\n\tif (!associatedElement.callbacks.includes(registeredElement.callback)) {\n\t\tassociatedElement.callbacks.push(registeredElement.callback);\n\t}\n};\n\nconst _removeObservedElementFromRegisteredElement = (registeredElement: RegisteredElement, element: HTMLElement) => {\n\tconst associatedElement = associatedElements.get(element);\n\tif (associatedElement) {\n\t\tassociatedElement.callbacks = associatedElement.callbacks.filter(itm => itm !== registeredElement.callback);\n\t\tif (!associatedElement.callbacks.length) {\n\t\t\tassociatedElement.observer?.disconnect();\n\t\t\tassociatedElements.delete(element);\n\t\t}\n\t}\n\tregisteredElement.observedElements = registeredElement.observedElements.filter(itm => itm !== element);\n};\n\nconst deregisterUI5Element = (el: UI5Element) => {\n\tconst registeredElement = registeredElements.get(el);\n\tif (!registeredElement) {\n\t\treturn;\n\t}\n\tconst oldObservedElements = [...registeredElement.observedElements];\n\toldObservedElements.forEach(observedElement => {\n\t\t_removeObservedElementFromRegisteredElement(registeredElement, observedElement);\n\t});\n\tel.detachInvalidate(registeredElement.invalidationCallback);\n\tregisteredElements.delete(el);\n};\n\nexport {\n\tgetEffectiveAriaLabelText,\n\tgetAssociatedLabelForTexts,\n\tregisterUI5Element,\n\tderegisterUI5Element,\n\tgetAllAccessibleNameRefTexts,\n};\n"]}
|
|
@@ -22,6 +22,10 @@ declare const getClassCopy: (klass: typeof UI5Element, constructorCallback: () =
|
|
|
22
22
|
_state: import("../UI5ElementMetadata.js").State;
|
|
23
23
|
_internals?: ElementInternals | undefined;
|
|
24
24
|
_getRealDomRef?: (() => HTMLElement) | undefined;
|
|
25
|
+
initializedProperties: Map<string, unknown>;
|
|
26
|
+
_rendered: boolean;
|
|
27
|
+
_initShadowRoot(): void;
|
|
28
|
+
_onShadowRootSlotChange(e: Event): void;
|
|
25
29
|
readonly _id: string;
|
|
26
30
|
render(): object;
|
|
27
31
|
connectedCallback(): Promise<void>;
|
|
@@ -45,8 +49,6 @@ declare const getClassCopy: (klass: typeof UI5Element, constructorCallback: () =
|
|
|
45
49
|
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
46
50
|
formAssociatedCallback(): void;
|
|
47
51
|
_updateAttribute(name: string, newValue: import("../UI5ElementMetadata.js").PropertyValue): void;
|
|
48
|
-
_upgradeProperty(this: Record<string, any>, propertyName: string): void;
|
|
49
|
-
_upgradeAllProperties(): void;
|
|
50
52
|
_getChildChangeListener(slotName: string): (param: import("../UI5Element.js").ChangeInfo & {
|
|
51
53
|
target: UI5Element;
|
|
52
54
|
}) => void;
|
|
@@ -55,6 +57,7 @@ declare const getClassCopy: (klass: typeof UI5Element, constructorCallback: () =
|
|
|
55
57
|
_detachSlotChange(child: HTMLSlotElement, slotName: string): void;
|
|
56
58
|
_onSlotChange(slotName: string): void;
|
|
57
59
|
onInvalidation(changeInfo: import("../UI5Element.js").ChangeInfo): void;
|
|
60
|
+
updateAttributes(): void;
|
|
58
61
|
_render(): void;
|
|
59
62
|
_assignIndividualSlotsToChildren(): void;
|
|
60
63
|
_waitForDomRef(): Promise<void> & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ui5/webcomponents-base",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "UI5 Web Components: webcomponents.base",
|
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@openui5/sap.ui.core": "1.120.5",
|
|
54
|
-
"@ui5/webcomponents-tools": "2.0.0
|
|
54
|
+
"@ui5/webcomponents-tools": "2.0.0",
|
|
55
55
|
"chromedriver": "^125.0.0",
|
|
56
56
|
"clean-css": "^5.2.2",
|
|
57
57
|
"copy-and-watch": "^0.1.5",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"resolve": "^1.20.0",
|
|
63
63
|
"touch": "^3.1.0"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "2960694d66c4b62d4240e3d45e1401dd94f61aec"
|
|
66
66
|
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";import r from"./DataType.js";class a extends r{static isValid(e){return/^(#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})|rgb\(\s*((1?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))|([0-9]?[0-9](\.[0-9]+)?|100(\.0+)?)%)\s*(,\s*((1?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))|([0-9]?[0-9](\.[0-9]+)?|100(\.0+)?)%)\s*){2}\)|rgba\((\s*((1?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))|([0-9]?[0-9](\.[0-9]+)?|100(\.0+)?)%)\s*,){3}\s*(0(\.[0-9]+)?|1(\.0+)?)\s*\)|hsl\(\s*([0-2]?[0-9]?[0-9]|3([0-5][0-9]|60))\s*(,\s*(([0-9]?[0-9](\.[0-9]+)?|100(\.0+)?)%)\s*){2}\)|hsla\(\s*([0-2]?[0-9]?[0-9]|3([0-5][0-9]|60))\s*,(\s*(([0-9]?[0-9](\.[0-9]+)?|100(\.0+)?)%)\s*,){2}\s*(0(\.[0-9]+)?|1(\.0+)?)\s*\)|aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgrey|darkgreen|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|grey|green|greenyellow|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgrey|lightgreen|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silverskyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen|transparent|inherit|)$/.test(e)}}export default a;
|
|
2
|
-
//# sourceMappingURL=CSSColor.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/CSSColor.ts"],
|
|
4
|
-
"sourcesContent": ["import DataType from \"./DataType.js\";\n\n/**\n * @class\n * CSSColor data type.\n *\n * @public\n */\nclass CSSColor extends DataType {\n\tstatic override isValid(value: string) {\n\t\treturn /^(#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})|rgb\\(\\s*((1?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))|([0-9]?[0-9](\\.[0-9]+)?|100(\\.0+)?)%)\\s*(,\\s*((1?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))|([0-9]?[0-9](\\.[0-9]+)?|100(\\.0+)?)%)\\s*){2}\\)|rgba\\((\\s*((1?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))|([0-9]?[0-9](\\.[0-9]+)?|100(\\.0+)?)%)\\s*,){3}\\s*(0(\\.[0-9]+)?|1(\\.0+)?)\\s*\\)|hsl\\(\\s*([0-2]?[0-9]?[0-9]|3([0-5][0-9]|60))\\s*(,\\s*(([0-9]?[0-9](\\.[0-9]+)?|100(\\.0+)?)%)\\s*){2}\\)|hsla\\(\\s*([0-2]?[0-9]?[0-9]|3([0-5][0-9]|60))\\s*,(\\s*(([0-9]?[0-9](\\.[0-9]+)?|100(\\.0+)?)%)\\s*,){2}\\s*(0(\\.[0-9]+)?|1(\\.0+)?)\\s*\\)|aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgrey|darkgreen|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|grey|green|greenyellow|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgrey|lightgreen|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silverskyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen|transparent|inherit|)$/.test(value ); // eslint-disable-line\n\t}\n}\n\nexport default CSSColor;\n"],
|
|
5
|
-
"mappings": "aAAA,OAAOA,MAAc,gBAQrB,MAAMC,UAAiBD,CAAS,CAC/B,OAAgB,QAAQE,EAAe,CACtC,MAAO,+/DAA+/D,KAAKA,CAAM,CAClhE,CACD,CAEA,eAAeD",
|
|
6
|
-
"names": ["DataType", "CSSColor", "value"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";import m from"./DataType.js";class s extends m{static isValid(e){return/^(auto|inherit|[-+]?(0*|([0-9]+|[0-9]*\.[0-9]+)([rR][eE][mM]|[eE][mM]|[eE][xX]|[pP][xX]|[cC][mM]|[mM][mM]|[iI][nN]|[pP][tT]|[pP][cC]|%))|calc\(\s*(\(\s*)*[-+]?(([0-9]+|[0-9]*\.[0-9]+)([rR][eE][mM]|[eE][mM]|[eE][xX]|[pP][xX]|[cC][mM]|[mM][mM]|[iI][nN]|[pP][tT]|[pP][cC]|%)?)(\s*(\)\s*)*(\s[-+]\s|[*\/])\s*(\(\s*)*([-+]?(([0-9]+|[0-9]*\.[0-9]+)([rR][eE][mM]|[eE][mM]|[eE][xX]|[pP][xX]|[cC][mM]|[mM][mM]|[iI][nN]|[pP][tT]|[pP][cC]|%)?)))*\s*(\)\s*)*\))$/.test(e)}}export default s;
|
|
2
|
-
//# sourceMappingURL=CSSSize.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/CSSSize.ts"],
|
|
4
|
-
"sourcesContent": ["import DataType from \"./DataType.js\";\n\n/**\n * @class\n * CSSSize data type.\n *\n * @public\n */\nclass CSSSize extends DataType {\n\tstatic isValid(value: string) {\n\t\treturn /^(auto|inherit|[-+]?(0*|([0-9]+|[0-9]*\\.[0-9]+)([rR][eE][mM]|[eE][mM]|[eE][xX]|[pP][xX]|[cC][mM]|[mM][mM]|[iI][nN]|[pP][tT]|[pP][cC]|%))|calc\\(\\s*(\\(\\s*)*[-+]?(([0-9]+|[0-9]*\\.[0-9]+)([rR][eE][mM]|[eE][mM]|[eE][xX]|[pP][xX]|[cC][mM]|[mM][mM]|[iI][nN]|[pP][tT]|[pP][cC]|%)?)(\\s*(\\)\\s*)*(\\s[-+]\\s|[*\\/])\\s*(\\(\\s*)*([-+]?(([0-9]+|[0-9]*\\.[0-9]+)([rR][eE][mM]|[eE][mM]|[eE][xX]|[pP][xX]|[cC][mM]|[mM][mM]|[iI][nN]|[pP][tT]|[pP][cC]|%)?)))*\\s*(\\)\\s*)*\\))$/.test(value); // eslint-disable-line\n\t}\n}\n\nexport default CSSSize;\n"],
|
|
5
|
-
"mappings": "aAAA,OAAOA,MAAc,gBAQrB,MAAMC,UAAgBD,CAAS,CAC9B,OAAO,QAAQE,EAAe,CAC7B,MAAO,qcAAqc,KAAKA,CAAK,CACvd,CACD,CAEA,eAAeD",
|
|
6
|
-
"names": ["DataType", "CSSSize", "value"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/DOMReference.ts"],
|
|
4
|
-
"sourcesContent": ["import DataType from \"./DataType.js\";\n\n/**\n * @class\n * DOM Element reference or ID.\n * **Note:** If an ID is passed, it is expected to be part of the same `document` element as the consuming component.\n *\n * @public\n */\nclass DOMReference extends DataType {\n\tstatic override isValid(value: string | HTMLElement) {\n\t\treturn (typeof value === \"string\" || value instanceof HTMLElement);\n\t}\n\n\tstatic override propertyToAttribute(propertyValue: string | HTMLElement) {\n\t\tif (propertyValue instanceof HTMLElement) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn propertyValue;\n\t}\n}\n\nexport default DOMReference;\n"],
|
|
5
|
-
"mappings": "aAAA,OAAOA,MAAc,gBASrB,MAAMC,UAAqBD,CAAS,CACnC,OAAgB,QAAQE,EAA6B,CACpD,OAAQ,OAAOA,GAAU,UAAYA,aAAiB,WACvD,CAEA,OAAgB,oBAAoBC,EAAqC,CACxE,OAAIA,aAAyB,YACrB,KAGDA,CACR,CACD,CAEA,eAAeF",
|
|
6
|
-
"names": ["DataType", "DOMReference", "value", "propertyValue"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";class r{static isValid(t){return!1}static attributeToProperty(t){return t}static propertyToAttribute(t){return t===null?null:String(t)}static valuesAreEqual(t,e){return t===e}static generateTypeAccessors(t){Object.keys(t).forEach(e=>{Object.defineProperty(this,e,{get(){return t[e]}})})}static get isDataTypeClass(){return!0}}export default r;
|
|
2
|
-
//# sourceMappingURL=DataType.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/DataType.ts"],
|
|
4
|
-
"sourcesContent": ["import type { PropertyValue } from \"../UI5ElementMetadata.js\";\n\n/**\n * @class\n * Base class for all data types.\n *\n * @public\n */\nclass DataType {\n\t/**\n\t * Checks if the value is valid for its data type.\n \t * @public\n\t */\n\t// eslint-disable-next-line\n\tstatic isValid(value: any): boolean {\n\t\treturn false;\n\t}\n\n\tstatic attributeToProperty(attributeValue: string | null): PropertyValue {\n\t\treturn attributeValue;\n\t}\n\n\tstatic propertyToAttribute(propertyValue: PropertyValue): string | null {\n\t\treturn propertyValue === null ? null : String(propertyValue);\n\t}\n\n\tstatic valuesAreEqual(value1: any, value2: any) {\n\t\treturn value1 === value2;\n\t}\n\n\tstatic generateTypeAccessors(types: Record<string, string>) {\n\t\tObject.keys(types).forEach(type => {\n\t\t\tObject.defineProperty(this, type, {\n\t\t\t\tget() {\n\t\t\t\t\treturn types[type];\n\t\t\t\t},\n\t\t\t});\n\t\t});\n\t}\n\n\tstatic get isDataTypeClass() {\n\t\treturn true;\n\t}\n}\n\nexport default DataType;\n"],
|
|
5
|
-
"mappings": "aAQA,MAAMA,CAAS,CAMd,OAAO,QAAQC,EAAqB,CACnC,MAAO,EACR,CAEA,OAAO,oBAAoBC,EAA8C,CACxE,OAAOA,CACR,CAEA,OAAO,oBAAoBC,EAA6C,CACvE,OAAOA,IAAkB,KAAO,KAAO,OAAOA,CAAa,CAC5D,CAEA,OAAO,eAAeC,EAAaC,EAAa,CAC/C,OAAOD,IAAWC,CACnB,CAEA,OAAO,sBAAsBC,EAA+B,CAC3D,OAAO,KAAKA,CAAK,EAAE,QAAQC,GAAQ,CAClC,OAAO,eAAe,KAAMA,EAAM,CACjC,KAAM,CACL,OAAOD,EAAMC,CAAI,CAClB,CACD,CAAC,CACF,CAAC,CACF,CAEA,WAAW,iBAAkB,CAC5B,MAAO,EACR,CACD,CAEA,eAAeP",
|
|
6
|
-
"names": ["DataType", "value", "attributeValue", "propertyValue", "value1", "value2", "types", "type"]
|
|
7
|
-
}
|
package/dist/prod/types/Float.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/Float.ts"],
|
|
4
|
-
"sourcesContent": ["import type { PropertyValue } from \"../UI5ElementMetadata.js\";\nimport DataType from \"./DataType.js\";\n\n/**\n * @class\n * Float data type.\n *\n * @constructor\n * @public\n */\nclass Float extends DataType {\n\tstatic override isValid(value: any) {\n\t\treturn Number(value) === value;\n\t}\n\n\tstatic override attributeToProperty(attributeValue: string): PropertyValue {\n\t\treturn parseFloat(attributeValue);\n\t}\n}\n\nexport default Float;\n"],
|
|
5
|
-
"mappings": "aACA,OAAOA,MAAc,gBASrB,MAAMC,UAAcD,CAAS,CAC5B,OAAgB,QAAQE,EAAY,CACnC,OAAO,OAAOA,CAAK,IAAMA,CAC1B,CAEA,OAAgB,oBAAoBC,EAAuC,CAC1E,OAAO,WAAWA,CAAc,CACjC,CACD,CAEA,eAAeF",
|
|
6
|
-
"names": ["DataType", "Float", "value", "attributeValue"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/Integer.ts"],
|
|
4
|
-
"sourcesContent": ["import type { PropertyValue } from \"../UI5ElementMetadata.js\";\nimport DataType from \"./DataType.js\";\n\n/**\n * @class\n * Integer data type.\n *\n * @constructor\n * @public\n */\nclass Integer extends DataType {\n\tstatic override isValid(value: any) {\n\t\treturn Number.isInteger(value);\n\t}\n\n\tstatic override attributeToProperty(attributeValue: string): PropertyValue {\n\t\treturn parseInt(attributeValue);\n\t}\n}\n\nexport default Integer;\n"],
|
|
5
|
-
"mappings": "aACA,OAAOA,MAAc,gBASrB,MAAMC,UAAgBD,CAAS,CAC9B,OAAgB,QAAQE,EAAY,CACnC,OAAO,OAAO,UAAUA,CAAK,CAC9B,CAEA,OAAgB,oBAAoBC,EAAuC,CAC1E,OAAO,SAASA,CAAc,CAC/B,CACD,CAEA,eAAeF",
|
|
6
|
-
"names": ["DataType", "Integer", "value", "attributeValue"]
|
|
7
|
-
}
|
package/dist/types/CSSColor.d.ts
DELETED
package/dist/types/CSSColor.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import DataType from "./DataType.js";
|
|
2
|
-
/**
|
|
3
|
-
* @class
|
|
4
|
-
* CSSColor data type.
|
|
5
|
-
*
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
class CSSColor extends DataType {
|
|
9
|
-
static isValid(value) {
|
|
10
|
-
return /^(#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})|rgb\(\s*((1?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))|([0-9]?[0-9](\.[0-9]+)?|100(\.0+)?)%)\s*(,\s*((1?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))|([0-9]?[0-9](\.[0-9]+)?|100(\.0+)?)%)\s*){2}\)|rgba\((\s*((1?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))|([0-9]?[0-9](\.[0-9]+)?|100(\.0+)?)%)\s*,){3}\s*(0(\.[0-9]+)?|1(\.0+)?)\s*\)|hsl\(\s*([0-2]?[0-9]?[0-9]|3([0-5][0-9]|60))\s*(,\s*(([0-9]?[0-9](\.[0-9]+)?|100(\.0+)?)%)\s*){2}\)|hsla\(\s*([0-2]?[0-9]?[0-9]|3([0-5][0-9]|60))\s*,(\s*(([0-9]?[0-9](\.[0-9]+)?|100(\.0+)?)%)\s*,){2}\s*(0(\.[0-9]+)?|1(\.0+)?)\s*\)|aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgrey|darkgreen|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|grey|green|greenyellow|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgrey|lightgreen|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silverskyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen|transparent|inherit|)$/.test(value); // eslint-disable-line
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export default CSSColor;
|
|
14
|
-
//# sourceMappingURL=CSSColor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CSSColor.js","sourceRoot":"","sources":["../../src/types/CSSColor.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,eAAe,CAAC;AAErC;;;;;GAKG;AACH,MAAM,QAAS,SAAQ,QAAQ;IAC9B,MAAM,CAAU,OAAO,CAAC,KAAa;QACpC,OAAO,8/DAA8/D,CAAC,IAAI,CAAC,KAAK,CAAE,CAAC,CAAC,sBAAsB;IAC3iE,CAAC;CACD;AAED,eAAe,QAAQ,CAAC","sourcesContent":["import DataType from \"./DataType.js\";\n\n/**\n * @class\n * CSSColor data type.\n *\n * @public\n */\nclass CSSColor extends DataType {\n\tstatic override isValid(value: string) {\n\t\treturn /^(#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})|rgb\\(\\s*((1?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))|([0-9]?[0-9](\\.[0-9]+)?|100(\\.0+)?)%)\\s*(,\\s*((1?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))|([0-9]?[0-9](\\.[0-9]+)?|100(\\.0+)?)%)\\s*){2}\\)|rgba\\((\\s*((1?[0-9]?[0-9]|2([0-4][0-9]|5[0-5]))|([0-9]?[0-9](\\.[0-9]+)?|100(\\.0+)?)%)\\s*,){3}\\s*(0(\\.[0-9]+)?|1(\\.0+)?)\\s*\\)|hsl\\(\\s*([0-2]?[0-9]?[0-9]|3([0-5][0-9]|60))\\s*(,\\s*(([0-9]?[0-9](\\.[0-9]+)?|100(\\.0+)?)%)\\s*){2}\\)|hsla\\(\\s*([0-2]?[0-9]?[0-9]|3([0-5][0-9]|60))\\s*,(\\s*(([0-9]?[0-9](\\.[0-9]+)?|100(\\.0+)?)%)\\s*,){2}\\s*(0(\\.[0-9]+)?|1(\\.0+)?)\\s*\\)|aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgrey|darkgreen|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|grey|green|greenyellow|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgrey|lightgreen|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silverskyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen|transparent|inherit|)$/.test(value ); // eslint-disable-line\n\t}\n}\n\nexport default CSSColor;\n"]}
|
package/dist/types/CSSSize.d.ts
DELETED
package/dist/types/CSSSize.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import DataType from "./DataType.js";
|
|
2
|
-
/**
|
|
3
|
-
* @class
|
|
4
|
-
* CSSSize data type.
|
|
5
|
-
*
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
class CSSSize extends DataType {
|
|
9
|
-
static isValid(value) {
|
|
10
|
-
return /^(auto|inherit|[-+]?(0*|([0-9]+|[0-9]*\.[0-9]+)([rR][eE][mM]|[eE][mM]|[eE][xX]|[pP][xX]|[cC][mM]|[mM][mM]|[iI][nN]|[pP][tT]|[pP][cC]|%))|calc\(\s*(\(\s*)*[-+]?(([0-9]+|[0-9]*\.[0-9]+)([rR][eE][mM]|[eE][mM]|[eE][xX]|[pP][xX]|[cC][mM]|[mM][mM]|[iI][nN]|[pP][tT]|[pP][cC]|%)?)(\s*(\)\s*)*(\s[-+]\s|[*\/])\s*(\(\s*)*([-+]?(([0-9]+|[0-9]*\.[0-9]+)([rR][eE][mM]|[eE][mM]|[eE][xX]|[pP][xX]|[cC][mM]|[mM][mM]|[iI][nN]|[pP][tT]|[pP][cC]|%)?)))*\s*(\)\s*)*\))$/.test(value); // eslint-disable-line
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export default CSSSize;
|
|
14
|
-
//# sourceMappingURL=CSSSize.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CSSSize.js","sourceRoot":"","sources":["../../src/types/CSSSize.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,eAAe,CAAC;AAErC;;;;;GAKG;AACH,MAAM,OAAQ,SAAQ,QAAQ;IAC7B,MAAM,CAAC,OAAO,CAAC,KAAa;QAC3B,OAAO,ocAAoc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,sBAAsB;IAChf,CAAC;CACD;AAED,eAAe,OAAO,CAAC","sourcesContent":["import DataType from \"./DataType.js\";\n\n/**\n * @class\n * CSSSize data type.\n *\n * @public\n */\nclass CSSSize extends DataType {\n\tstatic isValid(value: string) {\n\t\treturn /^(auto|inherit|[-+]?(0*|([0-9]+|[0-9]*\\.[0-9]+)([rR][eE][mM]|[eE][mM]|[eE][xX]|[pP][xX]|[cC][mM]|[mM][mM]|[iI][nN]|[pP][tT]|[pP][cC]|%))|calc\\(\\s*(\\(\\s*)*[-+]?(([0-9]+|[0-9]*\\.[0-9]+)([rR][eE][mM]|[eE][mM]|[eE][xX]|[pP][xX]|[cC][mM]|[mM][mM]|[iI][nN]|[pP][tT]|[pP][cC]|%)?)(\\s*(\\)\\s*)*(\\s[-+]\\s|[*\\/])\\s*(\\(\\s*)*([-+]?(([0-9]+|[0-9]*\\.[0-9]+)([rR][eE][mM]|[eE][mM]|[eE][xX]|[pP][xX]|[cC][mM]|[mM][mM]|[iI][nN]|[pP][tT]|[pP][cC]|%)?)))*\\s*(\\)\\s*)*\\))$/.test(value); // eslint-disable-line\n\t}\n}\n\nexport default CSSSize;\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import DataType from "./DataType.js";
|
|
2
|
-
/**
|
|
3
|
-
* @class
|
|
4
|
-
* DOM Element reference or ID.
|
|
5
|
-
* **Note:** If an ID is passed, it is expected to be part of the same `document` element as the consuming component.
|
|
6
|
-
*
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
declare class DOMReference extends DataType {
|
|
10
|
-
static isValid(value: string | HTMLElement): boolean;
|
|
11
|
-
static propertyToAttribute(propertyValue: string | HTMLElement): string | null;
|
|
12
|
-
}
|
|
13
|
-
export default DOMReference;
|