@ui5/webcomponents-base 1.11.0-rc.1 → 1.11.0-rc.2

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/asset-registries/Icons.d.ts +1 -1
  3. package/dist/asset-registries/Icons.js +21 -21
  4. package/dist/asset-registries/Icons.js.map +1 -1
  5. package/dist/assets/bundle.esm.2d0cb31f.js +56 -0
  6. package/dist/assets/test/pages/{i18n.html.4b1c0bdb.js → i18n.html.cd6e3cfc.js} +1 -1
  7. package/dist/assets/test/pages/{i18n_texts.html.e98a417d.js → i18n_texts.html.7beb72ee.js} +1 -1
  8. package/dist/assets-meta/IconCollectionsAlias.d.ts +24 -10
  9. package/dist/assets-meta/IconCollectionsAlias.js +29 -9
  10. package/dist/assets-meta/IconCollectionsAlias.js.map +1 -1
  11. package/dist/config/Icons.d.ts +42 -18
  12. package/dist/config/Icons.js +74 -25
  13. package/dist/config/Icons.js.map +1 -1
  14. package/dist/config/RTL.js +3 -0
  15. package/dist/config/RTL.js.map +1 -1
  16. package/dist/generated/VersionInfo.js +3 -3
  17. package/dist/test/pages/AllTestElements.html +1 -1
  18. package/dist/test/pages/Configuration.html +1 -1
  19. package/dist/test/pages/ConfigurationScript.html +1 -1
  20. package/dist/test/pages/WithComplexTemplate.html +1 -1
  21. package/dist/test/pages/i18n.html +2 -2
  22. package/dist/test/pages/i18n_texts.html +2 -2
  23. package/dist/util/AriaLabelHelper.d.ts +10 -1
  24. package/dist/util/AriaLabelHelper.js +135 -8
  25. package/dist/util/AriaLabelHelper.js.map +1 -1
  26. package/package-scripts.js +1 -1
  27. package/package.json +3 -3
  28. package/src/asset-registries/Icons.ts +26 -27
  29. package/src/assets-meta/IconCollectionsAlias.ts +32 -9
  30. package/src/config/Icons.ts +85 -25
  31. package/src/config/RTL.ts +4 -0
  32. package/src/util/AriaLabelHelper.ts +167 -12
  33. package/dist/assets/bundle.esm.25073731.js +0 -56
@@ -1,48 +1,97 @@
1
1
  import { getTheme, isThemeFamily } from "./Theme.js";
2
+ import { getIconCollectionByAlias } from "../assets-meta/IconCollectionsAlias.js";
2
3
  const IconCollectionConfiguration = new Map();
3
- var IconCollection;
4
- (function (IconCollection) {
5
- IconCollection["v4"] = "SAP-icons";
6
- IconCollection["v5"] = "SAP-icons-v5";
7
- })(IconCollection || (IconCollection = {}));
4
+ // All registered icon collections - all icon collections resolves to these options at the end
5
+ var RegisteredIconCollection;
6
+ (function (RegisteredIconCollection) {
7
+ RegisteredIconCollection["SAPIconsV4"] = "SAP-icons-v4";
8
+ RegisteredIconCollection["SAPIconsV5"] = "SAP-icons-v5";
9
+ RegisteredIconCollection["SAPIconsTNTV2"] = "tnt-v2";
10
+ RegisteredIconCollection["SAPIconsTNTV3"] = "tnt-v3";
11
+ RegisteredIconCollection["SAPBSIcons"] = "business-suite";
12
+ })(RegisteredIconCollection || (RegisteredIconCollection = {}));
8
13
  /**
9
- * Sets the default icon collection (SAP-icons font v4 or SAP-icons font v5) per theme,
10
- * which will be applied in case icon collection is not specified.
14
+ * Sets the default icon collection for a given theme.
15
+ *
16
+ * SAP Icons is the default icon collection (that resolves to SAP-icons version 5.x in Horizon theme family and SAP-icons version 4.x in all other themes)
17
+ * and to display icons from other collections, you have to specify the icon collection in addition to the icon name, for example: "tnt/actor", "business-suite/1x2-grid-layout", etc.
18
+ * This method allows setting another (built-in or custom) icon collection as default per theme.
19
+ *
20
+ * <b>Usage</b>
21
+ * <b>For example</b>, to make "SAP-icons version 5.x" the default icon collection in "sap_fiori_3":
22
+ *
23
+ * <pre>
24
+ * setDefaultIconCollection("sap_fiori_3", "SAP-icons-v5");
25
+ *
26
+ * <ui5-icon name="home"></ui5-icon>
27
+ * </pre>
28
+ *
29
+ * <b>For example</b>, to make a custom icon collection (with name "my-custom-collection") the default icon collection in "sap_fiori_3":
30
+ *
31
+ * <pre>
32
+ * setDefaultIconCollection("sap_fiori_3", "my-custom-collection");
33
+ *
34
+ * <ui5-icon name="custom-icon-name"></ui5-icon>
35
+ * </pre>
11
36
  *
12
- * Note: by default SAP-icons-v5 is used in all SAP Horizon variants and SAP-icons-v4 for all the rest.
13
37
  * @public
14
- * @param {string} theme
15
- * @param {IconCollection} collectionName
38
+ * @param { string } theme
39
+ * @param { string } collectionName
16
40
  */
17
41
  const setDefaultIconCollection = (theme, collectionName) => {
18
- if (collectionName === "horizon") {
19
- collectionName = IconCollection.v5;
20
- }
21
42
  IconCollectionConfiguration.set(theme, collectionName);
22
43
  };
23
44
  /**
24
- * Returns the default icon collection (v4 or v5) for given theme,
25
- * that is configured.
45
+ * Returns the configured default icon collection for a given theme.
26
46
  *
27
- * @param {string} theme
47
+ * @param { string } theme
28
48
  * @public
29
- * @returns {string | undefined}
49
+ * @returns { string | undefined }
30
50
  */
31
51
  const getDefaultIconCollection = (theme) => {
32
52
  return IconCollectionConfiguration.get(theme);
33
53
  };
34
54
  /**
35
- * Returns the effective icon collection that will be applied for icon web components
36
- * whenever namespace is not specified.
37
- * @returns {string}
55
+ * Returns the effective icon collection,
56
+ * based on the default icon collection configuration and the current theme:
57
+ * @param { IconCollection } collectionName
58
+ * @returns { IconCollection } the effective collection name
38
59
  */
39
- const getEffectiveDefaultIconCollection = () => {
60
+ const getEffectiveIconCollection = (collectionName) => {
40
61
  const currentTheme = getTheme();
41
62
  const currentThemeConfiguration = IconCollectionConfiguration.get(currentTheme);
42
- if (currentThemeConfiguration) {
43
- return currentThemeConfiguration;
63
+ // when no collection is set and default collection is configured - return the configured icon collection
64
+ if (!collectionName && currentThemeConfiguration) {
65
+ return getIconCollectionByAlias(currentThemeConfiguration);
66
+ }
67
+ // when collection is set - return the theme dependant icon collection
68
+ // when collection is not set and there is no default icon collection configured - return theme dependant icon collection
69
+ return getIconCollectionByTheme(collectionName);
70
+ };
71
+ /**
72
+ * Returns the icon theme dependant collection, based on the collection name and current theme as follows:
73
+ *
74
+ * - "no collection" resolves to "SAP-icons-v4" in "Quartz" and "Belize", and to "SAP-icons-v5" in "Horizon" (or as confugred via setDefaultIconCollection)
75
+ * - "SAP-icons-v4" (and its alias "SAP-icons") forces "SAP-icons v4" in any theme and resolves to itself "SAP-icons-v4"
76
+ * - "SAP-icons-v5" (and its alias "horizon") forces "SAP-icons v5" in any theme and resolves to itself "SAP-icons-v5"
77
+ * - "tnt" (and its alias "SAP-icons-TNT") resolves to "tnt-v2" in "Quartz", "Belize", and resolves to "tnt-v3" in "Horizon"
78
+ * - "tnt-v2" forces "TNT icons v2" in any theme and resolves to itself "tnt-v2"
79
+ * - "tnt-v3" forces "TNT icons v3" in any theme and resolves to itself "tnt-v3"
80
+ * - "business-suite" (and its alias "BusinessSuiteInAppSymbols") has no versioning and resolves to "business-suite"
81
+ *
82
+ * <b>Note:</b> "SAP-icons-v4", "SAP-icons-v5", "tnt-v2", "tnt-v3" and "business-suite" are just returned
83
+ * @param { IconCollection } collectionName
84
+ * @returns { RegisteredIconCollection } the registered collection name
85
+ */
86
+ const getIconCollectionByTheme = (collectionName) => {
87
+ const horizonThemeFamily = isThemeFamily("sap_horizon");
88
+ if (!collectionName) {
89
+ return horizonThemeFamily ? RegisteredIconCollection.SAPIconsV5 : RegisteredIconCollection.SAPIconsV4;
90
+ }
91
+ if (collectionName === "tnt") {
92
+ return horizonThemeFamily ? RegisteredIconCollection.SAPIconsTNTV3 : RegisteredIconCollection.SAPIconsTNTV2;
44
93
  }
45
- return isThemeFamily("sap_horizon") ? IconCollection.v5 : IconCollection.v4;
94
+ return collectionName;
46
95
  };
47
- export { setDefaultIconCollection, getDefaultIconCollection, getEffectiveDefaultIconCollection, };
96
+ export { setDefaultIconCollection, getDefaultIconCollection, getEffectiveIconCollection, RegisteredIconCollection, };
48
97
  //# sourceMappingURL=Icons.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Icons.js","sourceRoot":"","sources":["../../src/config/Icons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE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IAAI,cAAc,KAAK,KAAK,EAAE;QAC7B,OAAO,kBAAkB,CAAC,CAAC,CAAC,wBAAwB,CAAC,aAAa,CAAC,CAAC,CAAC,wBAAwB,CAAC,aAAa,CAAC;KAC5G;IAED,OAAO,cAA0C,CAAC;AACnD,CAAC,CAAC;AAEF,OAAO,EACN,wBAAwB,EACxB,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,GACxB,CAAC"}
@@ -24,6 +24,9 @@ const impliesRTL = (language) => {
24
24
  * @returns {boolean} whether RTL should be used
25
25
  */
26
26
  const getRTL = () => {
27
+ if (typeof document === "undefined") {
28
+ return false;
29
+ }
27
30
  const configurationRTL = getConfiguredRTL();
28
31
  if (configurationRTL !== undefined) {
29
32
  return !!configurationRTL;
@@ -1 +1 @@
1
- {"version":3,"file":"RTL.js","sourceRoot":"","sources":["../../src/config/RTL.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,4BAA4B,MAAM,yCAAyC,CAAC;AACnF,OAAO,uBAAuB,MAAM,oCAAoC,CAAC;AAEzE,MAAM,mBAAmB,GAAG;IAC3B,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;CACV,CAAC;AAEF,MAAM,aAAa,GAAG,4BAA4B,CAAC,6BAA6B,CAAC,IAAI,EAAE,CAAC;AAExF;;;;GAIG;AACH,MAAM,UAAU,GAAG,CAAC,QAAgB,EAAE,EAAE;IACvC,QAAQ,GAAG,CAAC,QAAQ,IAAI,mBAAmB,CAAC,QAA4C,CAAC,CAAC,IAAI,QAAQ,CAAC;IAEvG,OAAO,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,GAA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,gBAAgB,CAAC;KAC1B;IAED,OAAO,UAAU,CAAC,WAAW,EAAE,IAAI,uBAAuB,EAAE,CAAC,CAAC;AAC/D,CAAC,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,sBAAsB"}
@@ -1,10 +1,10 @@
1
1
  const VersionInfo = {
2
- version: "1.11.0-rc.1",
2
+ version: "1.11.0-rc.2",
3
3
  major: 1,
4
4
  minor: 11,
5
5
  patch: 0,
6
- suffix: "-rc.1",
6
+ suffix: "-rc.2",
7
7
  isNext: false,
8
- buildTime: 1675930310,
8
+ buildTime: 1676535002,
9
9
  };
10
10
  export default VersionInfo;
@@ -6,7 +6,7 @@
6
6
  <title>Base package default test page</title>
7
7
 
8
8
 
9
- <script type="module" crossorigin src="/assets/bundle.esm.25073731.js"></script>
9
+ <script type="module" crossorigin src="/assets/bundle.esm.2d0cb31f.js"></script>
10
10
  </head>
11
11
 
12
12
  <body>
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
 
10
- <script type="module" crossorigin src="/assets/bundle.esm.25073731.js"></script>
10
+ <script type="module" crossorigin src="/assets/bundle.esm.2d0cb31f.js"></script>
11
11
  </head>
12
12
 
13
13
  <body>
@@ -23,7 +23,7 @@
23
23
 
24
24
 
25
25
 
26
- <script type="module" crossorigin src="/assets/bundle.esm.25073731.js"></script>
26
+ <script type="module" crossorigin src="/assets/bundle.esm.2d0cb31f.js"></script>
27
27
  </head>
28
28
 
29
29
  <body>
@@ -4,7 +4,7 @@
4
4
  <meta charset="utf-8">
5
5
  <title>Compex Template Test Page</title>
6
6
 
7
- <script type="module" crossorigin src="/assets/bundle.esm.25073731.js"></script>
7
+ <script type="module" crossorigin src="/assets/bundle.esm.2d0cb31f.js"></script>
8
8
  </head>
9
9
 
10
10
  <body>
@@ -7,8 +7,8 @@
7
7
 
8
8
 
9
9
 
10
- <script type="module" crossorigin src="/assets/test/pages/i18n.html.4b1c0bdb.js"></script>
11
- <link rel="modulepreload" href="/assets/bundle.esm.25073731.js">
10
+ <script type="module" crossorigin src="/assets/test/pages/i18n.html.cd6e3cfc.js"></script>
11
+ <link rel="modulepreload" href="/assets/bundle.esm.2d0cb31f.js">
12
12
  </head>
13
13
 
14
14
  <body>
@@ -8,8 +8,8 @@
8
8
 
9
9
 
10
10
 
11
- <script type="module" crossorigin src="/assets/test/pages/i18n_texts.html.e98a417d.js"></script>
12
- <link rel="modulepreload" href="/assets/bundle.esm.25073731.js">
11
+ <script type="module" crossorigin src="/assets/test/pages/i18n_texts.html.7beb72ee.js"></script>
12
+ <link rel="modulepreload" href="/assets/bundle.esm.2d0cb31f.js">
13
13
  </head>
14
14
 
15
15
  <body>
@@ -1,6 +1,15 @@
1
+ import UI5Element from "../UI5Element.js";
2
+ type MutationCallback = () => void;
1
3
  declare const getEffectiveAriaLabelText: (el: HTMLElement) => string | undefined;
4
+ /**
5
+ *
6
+ * @param {HTMLElement} el Defines the HTMLElement, for which you need to get all related texts
7
+ */
8
+ declare const getAllAccessibleNameRefTexts: (el: HTMLElement) => string;
2
9
  /**
3
10
  * @param {HTMLElement} el Defines the HTMLElement, for which you need to get all related "label for" texts
4
11
  */
5
12
  declare const getAssociatedLabelForTexts: (el: HTMLElement) => string | undefined;
6
- export { getEffectiveAriaLabelText, getAssociatedLabelForTexts, };
13
+ declare const registerUI5Element: (el: UI5Element, callback: MutationCallback) => void;
14
+ declare const deregisterUI5Element: (el: UI5Element) => void;
15
+ export { getEffectiveAriaLabelText, getAssociatedLabelForTexts, registerUI5Element, deregisterUI5Element, getAllAccessibleNameRefTexts, };
@@ -1,3 +1,11 @@
1
+ const associatedElements = new WeakMap();
2
+ const registeredElements = new WeakMap();
3
+ const observerOptions = {
4
+ attributes: true,
5
+ childList: true,
6
+ characterData: true,
7
+ subtree: true,
8
+ };
1
9
  const getEffectiveAriaLabelText = (el) => {
2
10
  const accessibleEl = el;
3
11
  if (!accessibleEl.accessibleNameRef) {
@@ -6,31 +14,59 @@ const getEffectiveAriaLabelText = (el) => {
6
14
  }
7
15
  return undefined;
8
16
  }
9
- return _getAriaLabelledByTexts(el);
17
+ return getAllAccessibleNameRefTexts(el);
10
18
  };
11
19
  /**
12
20
  *
13
21
  * @param {HTMLElement} el Defines the HTMLElement, for which you need to get all related texts
14
22
  */
15
- const _getAriaLabelledByTexts = (el) => {
16
- const ids = el.accessibleNameRef.split(" ");
23
+ const getAllAccessibleNameRefTexts = (el) => {
24
+ const ids = el.accessibleNameRef?.split(" ") ?? [];
17
25
  const owner = el.getRootNode();
18
26
  let result = "";
19
27
  ids.forEach((elementId, index) => {
20
28
  const element = owner.querySelector(`[id='${elementId}']`);
21
- result += `${element && element.textContent ? element.textContent : ""}`;
22
- if (index < ids.length - 1) {
23
- result += " ";
29
+ const text = `${element && element.textContent ? element.textContent : ""}`;
30
+ if (text) {
31
+ result += text;
32
+ if (index < ids.length - 1) {
33
+ result += " ";
34
+ }
24
35
  }
25
36
  });
26
37
  return result;
27
38
  };
39
+ const _getAllAssociatedElementsFromDOM = (el) => {
40
+ const set = new Set();
41
+ // adding labels with attribute for matching the el.id
42
+ const labelsForAssociated = _getAssociatedLabels(el);
43
+ labelsForAssociated.forEach(itm => {
44
+ set.add(itm);
45
+ });
46
+ // adding other elements that id is the same as accessibleNameRef value
47
+ const value = el["accessibleNameRef"];
48
+ const ids = value?.split(" ") ?? [];
49
+ ids.forEach(id => {
50
+ const refEl = _getReferencedElementById(el, id);
51
+ if (refEl) {
52
+ set.add(refEl);
53
+ }
54
+ });
55
+ return Array.from(set);
56
+ };
57
+ const _getAssociatedLabels = (el) => {
58
+ const labels = el.getRootNode().querySelectorAll(`[for="${el.id}"]`);
59
+ return Array.from(labels);
60
+ };
61
+ const _getReferencedElementById = (el, elementId) => {
62
+ return el.getRootNode().querySelector(`[id='${elementId}']`);
63
+ };
28
64
  /**
29
65
  * @param {HTMLElement} el Defines the HTMLElement, for which you need to get all related "label for" texts
30
66
  */
31
67
  const getAssociatedLabelForTexts = (el) => {
32
68
  const results = [];
33
- const labels = el.getRootNode().querySelectorAll(`[ui5-label][for="${el.id}"],label[for="${el.id}"]`);
69
+ const labels = _getAssociatedLabels(el);
34
70
  labels.forEach((label) => {
35
71
  const labelText = label.textContent;
36
72
  labelText && results.push(labelText);
@@ -40,5 +76,96 @@ const getAssociatedLabelForTexts = (el) => {
40
76
  }
41
77
  return undefined;
42
78
  };
43
- export { getEffectiveAriaLabelText, getAssociatedLabelForTexts, };
79
+ const _createInvalidationCallback = (el) => {
80
+ const invalidationCallback = (changeInfo) => {
81
+ if (!(changeInfo && changeInfo.type === "property" && changeInfo.name === "accessibleNameRef")) {
82
+ return;
83
+ }
84
+ const registeredElement = registeredElements.get(el);
85
+ if (!registeredElement) {
86
+ return;
87
+ }
88
+ const oldAssociatedElements = registeredElement.observedElements;
89
+ const newAssociatedElements = _getAllAssociatedElementsFromDOM(el);
90
+ oldAssociatedElements.forEach(oldElement => {
91
+ if (!newAssociatedElements.includes(oldElement)) {
92
+ _removeObservedElementFromRegisteredElement(registeredElement, oldElement);
93
+ }
94
+ });
95
+ newAssociatedElements.forEach(newElement => {
96
+ if (!oldAssociatedElements.includes(newElement)) {
97
+ _addObservedElementToRegisteredElement(registeredElement, newElement);
98
+ registeredElement.observedElements.push(newElement);
99
+ }
100
+ });
101
+ registeredElement?.callback();
102
+ };
103
+ return invalidationCallback;
104
+ };
105
+ const registerUI5Element = (el, callback) => {
106
+ if (registeredElements.has(el)) {
107
+ return;
108
+ }
109
+ const allAssociatedElements = _getAllAssociatedElementsFromDOM(el);
110
+ const invalidationCallback = _createInvalidationCallback(el);
111
+ const registeredElement = {
112
+ host: el,
113
+ observedElements: allAssociatedElements,
114
+ callback,
115
+ invalidationCallback,
116
+ };
117
+ registeredElements.set(el, registeredElement);
118
+ el.attachInvalidate(invalidationCallback);
119
+ allAssociatedElements.forEach((element) => {
120
+ _addObservedElementToRegisteredElement(registeredElement, element);
121
+ });
122
+ callback();
123
+ };
124
+ const _addObservedElementToRegisteredElement = (registeredElement, element) => {
125
+ let associatedElement = associatedElements.get(element);
126
+ if (!associatedElement) {
127
+ associatedElement = { observer: null, callbacks: [] };
128
+ const observer = new MutationObserver(() => {
129
+ const callbacks = associatedElement.callbacks;
130
+ callbacks.forEach(callback => {
131
+ callback();
132
+ });
133
+ const domEl = document.getElementById(element.id);
134
+ // if no longer should be observed from this registeredElement, remove it
135
+ if (!(registeredElement.host.id === element.getAttribute("for") || domEl)) {
136
+ _removeObservedElementFromRegisteredElement(registeredElement, element);
137
+ }
138
+ });
139
+ associatedElement.observer = observer;
140
+ observer.observe(element, observerOptions);
141
+ associatedElements.set(element, associatedElement);
142
+ }
143
+ if (!associatedElement.callbacks.includes(registeredElement.callback)) {
144
+ associatedElement.callbacks.push(registeredElement.callback);
145
+ }
146
+ };
147
+ const _removeObservedElementFromRegisteredElement = (registeredElement, element) => {
148
+ const associatedElement = associatedElements.get(element);
149
+ if (associatedElement) {
150
+ associatedElement.callbacks = associatedElement.callbacks.filter(itm => itm !== registeredElement.callback);
151
+ if (!associatedElement.callbacks.length) {
152
+ associatedElement.observer?.disconnect();
153
+ associatedElements.delete(element);
154
+ }
155
+ }
156
+ registeredElement.observedElements = registeredElement.observedElements.filter(itm => itm !== element);
157
+ };
158
+ const deregisterUI5Element = (el) => {
159
+ const registeredElement = registeredElements.get(el);
160
+ if (!registeredElement) {
161
+ return;
162
+ }
163
+ const oldObservedElements = [...registeredElement.observedElements];
164
+ oldObservedElements.forEach(observedElement => {
165
+ _removeObservedElementFromRegisteredElement(registeredElement, observedElement);
166
+ });
167
+ el.detachInvalidate(registeredElement.invalidationCallback);
168
+ registeredElements.delete(el);
169
+ };
170
+ export { getEffectiveAriaLabelText, getAssociatedLabelForTexts, registerUI5Element, deregisterUI5Element, getAllAccessibleNameRefTexts, };
44
171
  //# sourceMappingURL=AriaLabelHelper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AriaLabelHelper.js","sourceRoot":"","sources":["../../src/util/AriaLabelHelper.ts"],"names":[],"mappings":"A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,oBAAoB,EACpB,4BAA4B,GAC5B,CAAC"}
@@ -16,7 +16,7 @@ const eslintConfig = `--config ${require.resolve("@ui5/webcomponents-tools/compo
16
16
  const scripts = {
17
17
  clean: "rimraf jsdoc-dist && rimraf src/generated && rimraf dist && rimraf .port",
18
18
  lint: `eslint . ${eslintConfig}`,
19
- prepare: "nps clean integrate copy generateAssetParameters generateVersionInfo generateStyles generateTemplates typescript generateAPI",
19
+ prepare: "cross-env UI5_TS=true nps clean integrate copy generateAssetParameters generateVersionInfo generateStyles generateTemplates typescript generateAPI",
20
20
  typescript: "tsc",
21
21
  integrate: {
22
22
  default: "nps integrate.copy-used-modules integrate.replace-amd integrate.amd-to-es6 integrate.esm-abs-to-rel integrate.third-party",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/webcomponents-base",
3
- "version": "1.11.0-rc.1",
3
+ "version": "1.11.0-rc.2",
4
4
  "description": "UI5 Web Components: webcomponents.base",
5
5
  "author": "SAP SE (https://www.sap.com)",
6
6
  "license": "Apache-2.0",
@@ -36,7 +36,7 @@
36
36
  "devDependencies": {
37
37
  "@buxlabs/amd-to-es6": "0.16.1",
38
38
  "@openui5/sap.ui.core": "1.109.0",
39
- "@ui5/webcomponents-tools": "1.11.0-rc.1",
39
+ "@ui5/webcomponents-tools": "1.11.0-rc.2",
40
40
  "chromedriver": "109.0.0",
41
41
  "clean-css": "^5.2.2",
42
42
  "copy-and-watch": "^0.1.5",
@@ -46,5 +46,5 @@
46
46
  "replace-in-file": "^6.3.5",
47
47
  "resolve": "^1.20.0"
48
48
  },
49
- "gitHead": "a76323e09b0190bbb72cbff141bb8093b8d0f4ff"
49
+ "gitHead": "a6334749f4f61a49b1ef754b75fe319991c54c17"
50
50
  }
@@ -1,6 +1,6 @@
1
1
  import getSharedResource from "../getSharedResource.js";
2
- import IconCollectionsAlias from "../assets-meta/IconCollectionsAlias.js";
3
- import { getEffectiveDefaultIconCollection } from "../config/Icons.js";
2
+ import { getIconCollectionByAlias } from "../assets-meta/IconCollectionsAlias.js";
3
+ import { getEffectiveIconCollection } from "../config/Icons.js";
4
4
  import { I18nText } from "../i18nBundle.js";
5
5
  import { TemplateFunction } from "../renderer/executeTemplate.js";
6
6
 
@@ -19,7 +19,7 @@ type CollectionData = {
19
19
  };
20
20
 
21
21
  type IconData = {
22
- collection?: string,
22
+ collection: string,
23
23
  packageName: string,
24
24
  pathData: string | Array<string>,
25
25
  ltr: boolean,
@@ -67,11 +67,8 @@ const _fillRegistry = (bundleData: CollectionData) => {
67
67
 
68
68
  // set
69
69
  const registerIcon = (name: string, iconData: IconData) => { // eslint-disable-line
70
- if (!iconData.collection) {
71
- iconData.collection = getEffectiveDefaultIconCollection();
72
- }
73
-
74
70
  const key = `${iconData.collection}/${name}`;
71
+
75
72
  registry.set(key, {
76
73
  pathData: iconData.pathData,
77
74
  ltr: iconData.ltr,
@@ -79,38 +76,48 @@ const registerIcon = (name: string, iconData: IconData) => { // eslint-disable-l
79
76
  packageName: iconData.packageName,
80
77
  customTemplate: iconData.customTemplate,
81
78
  viewBox: iconData.viewBox,
79
+ collection: iconData.collection,
82
80
  });
83
81
  };
84
82
 
85
- const _parseName = (name: string) => {
83
+ /**
84
+ * Processes the full icon name and splits it into - "name", "collection"
85
+ * to form the proper registry key ("collection/name") under which the icon is registered:
86
+ *
87
+ * - removes legacy protocol ("sap-icon://")
88
+ * - resolves aliases (f.e "SAP-icons-TNT/actor" => "tnt/actor")
89
+ * - determines theme dependant icon collection (f.e "home" => "SAP-icons-v4/home" in Quartz | "SAP-icons-v5/home" in Horizon)
90
+ *
91
+ * @param { string } name
92
+ * @return { object }
93
+ */
94
+ const processName = (name: string) => {
86
95
  // silently support ui5-compatible URIs
87
96
  if (name.startsWith("sap-icon://")) {
88
97
  name = name.replace("sap-icon://", "");
89
98
  }
90
99
 
91
- let collection;
100
+ let collection: string;
92
101
  [name, collection] = name.split("/").reverse();
93
- collection = collection || getEffectiveDefaultIconCollection();
94
-
95
- // Normalize collection name.
96
- // - resolve `SAP-icons-TNT` to `tnt`.
97
- // - resolve `BusinessSuiteInAppSymbols` to `business-suite`.
98
- // - resolve `horizon` to `SAP-icons-v5`,
99
- // Note: aliases can be made as a feature, if more collections need it or more aliases are needed.
100
- collection = _normalizeCollection(collection);
102
+
101
103
  name = name.replace("icon-", "");
102
104
 
105
+ if (collection) {
106
+ collection = getIconCollectionByAlias(collection);
107
+ }
108
+ collection = getEffectiveIconCollection(collection);
109
+
103
110
  const registryKey = `${collection}/${name}`;
104
111
  return { name, collection, registryKey };
105
112
  };
106
113
 
107
114
  const getIconDataSync = (name: string) => {
108
- const { registryKey } = _parseName(name);
115
+ const { registryKey } = processName(name);
109
116
  return registry.get(registryKey);
110
117
  };
111
118
 
112
119
  const getIconData = async (name: string) => {
113
- const { collection, registryKey } = _parseName(name);
120
+ const { collection, registryKey } = processName(name);
114
121
 
115
122
  let iconData: string | CollectionData = ICON_NOT_FOUND;
116
123
  try {
@@ -140,14 +147,6 @@ const _getRegisteredNames = async () => {
140
147
  return Array.from(registry.keys());
141
148
  };
142
149
 
143
- const _normalizeCollection = (collectionName: string) => {
144
- if (IconCollectionsAlias[collectionName as keyof typeof IconCollectionsAlias]) {
145
- return IconCollectionsAlias[collectionName as keyof typeof IconCollectionsAlias];
146
- }
147
-
148
- return collectionName;
149
- };
150
-
151
150
  export {
152
151
  registerIconLoader,
153
152
  getIconData,
@@ -1,18 +1,41 @@
1
1
  /**
2
- * Supported icon collection names and aliases.
2
+ * Supported icon collection aliases.
3
3
  *
4
4
  * Users might specify a collection, using both the key and the value in the following key-value pairs,
5
5
  * e.g the following pairs are completely exchangeable:
6
- * "SAP-icons-TNT/actor" and "tnt/actor", "BusinessSuiteInAppSymbols/3d" and "business-suite/3d",
7
- * "SAP-icons-v5/accept" and "horizon/accept".
8
6
  *
9
- * Note: technically, in the code we maintain the collections under the "value" name - "tnt", "business-suite",
10
- * SAP-icons-v5" and "SAP-icons"(which does not have an alias).
7
+ * - "SAP-icons/accept" and "SAP-icons-v4/accept"
8
+ * - "horizon/accept" and "SAP-icons-v5/accept"
9
+ * - "SAP-icons-TNT/actor" and "tnt/actor"
10
+ * - "BusinessSuiteInAppSymbols/3d" and "business-suite/3d"
11
11
  */
12
- const IconCollectionsAlias = {
13
- "SAP-icons-TNT": "tnt",
14
- "BusinessSuiteInAppSymbols": "business-suite",
15
- "horizon": "SAP-icons-v5",
12
+ enum IconCollectionsAlias {
13
+ "SAP-icons" = "SAP-icons-v4",
14
+ "horizon" = "SAP-icons-v5",
15
+ "SAP-icons-TNT" = "tnt",
16
+ "BusinessSuiteInAppSymbols" = "business-suite",
17
+ }
18
+
19
+ /**
20
+ * Returns the mapped collection name for a given alias.
21
+ *
22
+ * <b>For example</b>:
23
+ * - "SAP-icons-TNT"resolves to "tnt"
24
+ * - "BusinessSuiteInAppSymbols" resolves to "business-suite"
25
+ * - "horizon" resolves to "SAP-icons-v5"
26
+ *
27
+ * @param { string } collectionName
28
+ * @return { string } the normalized collection name
29
+ */
30
+ const getIconCollectionByAlias = (collectionName: string) => {
31
+ if (IconCollectionsAlias[collectionName as keyof typeof IconCollectionsAlias]) {
32
+ return IconCollectionsAlias[collectionName as keyof typeof IconCollectionsAlias];
33
+ }
34
+
35
+ return collectionName;
16
36
  };
17
37
 
18
38
  export default IconCollectionsAlias;
39
+ export {
40
+ getIconCollectionByAlias,
41
+ };