@leanix/components 0.4.746 → 0.4.747
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.
|
@@ -137,6 +137,84 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImpo
|
|
|
137
137
|
args: ['item-click', ['$event']]
|
|
138
138
|
}] } });
|
|
139
139
|
|
|
140
|
+
const TRAVERSED_ELEMENTS_SELECTOR = 'ui5-icon';
|
|
141
|
+
const WEB_COMPONENT_STYLE_PROPERTIES_WHITELIST = new Set([
|
|
142
|
+
// positioning
|
|
143
|
+
'width',
|
|
144
|
+
'height',
|
|
145
|
+
'display',
|
|
146
|
+
'margin',
|
|
147
|
+
'margin-left',
|
|
148
|
+
'margin-right',
|
|
149
|
+
'margin-top',
|
|
150
|
+
'margin-bottom',
|
|
151
|
+
'padding',
|
|
152
|
+
'padding-left',
|
|
153
|
+
'padding-right',
|
|
154
|
+
'padding-top',
|
|
155
|
+
'padding-bottom',
|
|
156
|
+
// coloring
|
|
157
|
+
'color',
|
|
158
|
+
'fill',
|
|
159
|
+
'outline-color',
|
|
160
|
+
'background-color'
|
|
161
|
+
]);
|
|
162
|
+
/**
|
|
163
|
+
*
|
|
164
|
+
* A replacement for `HTMLElement.outerHTML`, but works with web components shadow DOM.
|
|
165
|
+
* Returns a string of outer HTML of a DOM node, inlining shadow DOM for web components.
|
|
166
|
+
* (@see TRAVERSED_ELEMENTS_SELECTOR for the list of supported web components.)
|
|
167
|
+
*
|
|
168
|
+
*
|
|
169
|
+
* @description
|
|
170
|
+
* Solves the problem of getting the full HTML structure of web components,
|
|
171
|
+
* as `element.outerHTML` does not include shadow DOM.
|
|
172
|
+
* This function inlines shadow DOM into a <template> tag inside the component root.
|
|
173
|
+
* It helps to keep the shadow DOM structure and preserve style encapsulation.
|
|
174
|
+
* Also includes whitelisted styles from computed styles into the component root as inline styles (@see WEB_COMPONENT_STYLE_PROPERTIES_WHITELIST).
|
|
175
|
+
*/
|
|
176
|
+
function getOuterHtmlWithShadowDom(rootNode) {
|
|
177
|
+
const lastId = addIdsToWebComponents(rootNode);
|
|
178
|
+
return getHTMLWithWebComponents(rootNode, lastId);
|
|
179
|
+
}
|
|
180
|
+
function addIdsToWebComponents(rootNode) {
|
|
181
|
+
const components = Array.from(rootNode.querySelectorAll(TRAVERSED_ELEMENTS_SELECTOR));
|
|
182
|
+
let lastId = 0;
|
|
183
|
+
for (const component of components) {
|
|
184
|
+
component.dataset['componentForExportId'] = lastId.toString();
|
|
185
|
+
lastId++;
|
|
186
|
+
}
|
|
187
|
+
return lastId;
|
|
188
|
+
}
|
|
189
|
+
function getNonDefaultStyles(cssStyleDeclaration) {
|
|
190
|
+
const cssText = Array.from(cssStyleDeclaration)
|
|
191
|
+
.filter((property) => {
|
|
192
|
+
const value = cssStyleDeclaration.getPropertyValue(property);
|
|
193
|
+
return value && WEB_COMPONENT_STYLE_PROPERTIES_WHITELIST.has(property);
|
|
194
|
+
})
|
|
195
|
+
.map((property) => `${property}: ${cssStyleDeclaration.getPropertyValue(property)}`)
|
|
196
|
+
.join('; ');
|
|
197
|
+
return cssText;
|
|
198
|
+
}
|
|
199
|
+
function getHTMLWithWebComponents(rootNode, lastId) {
|
|
200
|
+
let htmlString = rootNode.outerHTML.replace(/<!--[\S\s]*?-->/g, ''); // clear comments
|
|
201
|
+
if (!lastId) {
|
|
202
|
+
return htmlString;
|
|
203
|
+
}
|
|
204
|
+
for (let id = 0; id < lastId; id++) {
|
|
205
|
+
const component = rootNode.querySelector(`[data-component-for-export-id="${id}"]`);
|
|
206
|
+
const componentClone = component.cloneNode(false);
|
|
207
|
+
// Preferring defaultView to make getComputedStyle testable in custom jsdom environment
|
|
208
|
+
componentClone.style.cssText = getNonDefaultStyles(component.ownerDocument.defaultView.getComputedStyle(component));
|
|
209
|
+
// Adding shadow root to preserve style encapsulation
|
|
210
|
+
componentClone.innerHTML = `<template shadowrootmode="open">${component.shadowRoot?.innerHTML}</template>`;
|
|
211
|
+
// Regex to find the component by its data attribute
|
|
212
|
+
const componentRegex = new RegExp(`<[^>]+? data-component-for-export-id="${id}"[^>]*?>\\s*<\/[^>]+?>`, 'm');
|
|
213
|
+
htmlString = htmlString.replace(componentRegex, componentClone.outerHTML);
|
|
214
|
+
}
|
|
215
|
+
return htmlString;
|
|
216
|
+
}
|
|
217
|
+
|
|
140
218
|
/**
|
|
141
219
|
* All UI5-related components / directives supported by the SAP LeanIX Design System.
|
|
142
220
|
*/
|
|
@@ -145,5 +223,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImpo
|
|
|
145
223
|
* Generated bundle index. Do not edit.
|
|
146
224
|
*/
|
|
147
225
|
|
|
148
|
-
export { BreadcrumbsComponent, BreadcrumbsItemComponent, provideUi5 };
|
|
226
|
+
export { BreadcrumbsComponent, BreadcrumbsItemComponent, getOuterHtmlWithShadowDom, provideUi5 };
|
|
149
227
|
//# sourceMappingURL=leanix-components-ui5.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"leanix-components-ui5.mjs","sources":["../../../../libs/components/ui5/icons/register-icons.ts","../../../../libs/components/ui5/ui5.provider.ts","../../../../libs/components/ui5/components/breadcrumbs-item.component.ts","../../../../libs/components/ui5/components/breadcrumbs.component.ts","../../../../libs/components/ui5/index.ts","../../../../libs/components/ui5/leanix-components-ui5.ts"],"sourcesContent":["import { registerIconLoader } from '@ui5/webcomponents-base/dist/asset-registries/Icons.js';\n\n/**\n * Registers icon libraries with UI5.\n */\nexport async function registerIconsWithUi5() {\n await Promise.all([\n import('@ui5/webcomponents-icons-business-suite/dist/AllIcons.js'),\n import('@ui5/webcomponents-icons-tnt/dist/AllIcons.js'),\n import('@ui5/webcomponents-icons/dist/AllIcons.js')\n ]);\n\n registerIconLoader('lx-icons', () => import('./lx-icons.json'));\n}\n","import { provideAppInitializer } from '@angular/core';\nimport { setDefaultFontLoading } from '@ui5/webcomponents-base/dist/config/Fonts.js';\nimport { registerIconsWithUi5 } from './icons/register-icons';\n\n/**\n * Sets up providers necessary to use UI5 components in the application.\n *\n * @usageNotes\n *\n * Basic example of how you can add UI5 to your application:\n * ```ts\n * import { provideUi5 } from '@leanix/components/ui5';\n *\n * bootstrapApplication(AppComponent, {\n * providers: [provideUi5()]\n * });\n * ```\n */\nexport const provideUi5 = () =>\n provideAppInitializer(async () => {\n setDefaultFontLoading(false);\n await registerIconsWithUi5();\n });\n","import { LocationStrategy } from '@angular/common';\nimport { ChangeDetectionStrategy, Component, effect, inject, input, untracked } from '@angular/core';\nimport { Router, RouterLink } from '@angular/router';\nimport { BreadcrumbsItemComponent as Ui5BreadcrumbsItemComponent } from '@ui5/webcomponents-ngx/main/breadcrumbs-item';\n\n/**\n * This component extends the `ui5-breadcrumbs-item` component from `@ui5/webcomponents-ngx`.\n * This extension is needed for Angular versions before 20 to sync Angular's `RouterLink` directive\n * with the `href` attribute of the `ui5-breadcrumbs-item`.\n *\n * **Why?** Support for custom elements in the `RouterLink` directive was added in Angular 20.\n * For older versions, this component allows using the `RouterLink` on a `ui5-breadcrumb-item`.\n *\n * @see https://github.com/angular/angular/commit/ff98ccb19391ed4e04528b82771c04ad67067d68\n *\n */\n@Component({\n // eslint-disable-next-line @angular-eslint/component-selector\n selector: 'ui5-breadcrumbs-item',\n template: '<ng-content />',\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class BreadcrumbsItemComponent extends Ui5BreadcrumbsItemComponent {\n private readonly router = inject(Router);\n private readonly routerLinkInstance = inject(RouterLink, { optional: true });\n private readonly locationStrategy = inject(LocationStrategy, { optional: true });\n\n readonly routerLink = input<RouterLink['routerLink']>();\n\n readonly updateBreadcrumbHref = effect(() => {\n const routerLink = this.routerLink();\n\n untracked(() => {\n if (!routerLink || !this.routerLinkInstance) {\n this.href = undefined;\n return;\n }\n const urlTree = this.routerLinkInstance.urlTree;\n\n // See https://github.com/angular/angular/blob/main/packages/router/src/directives/router_link.ts#L430\n if (urlTree !== null && this.locationStrategy) {\n this.href = this.locationStrategy?.prepareExternalUrl(this.router.serializeUrl(urlTree)) ?? '';\n } else {\n this.href = undefined;\n }\n });\n });\n}\n","import { ChangeDetectionStrategy, Component, HostListener } from '@angular/core';\nimport { BreadcrumbsComponent as Ui5BreadcrumbsComponent } from '@ui5/webcomponents-ngx/main/breadcrumbs';\nimport { BreadcrumbsItemClickEventDetail } from '@ui5/webcomponents/dist/Breadcrumbs';\n\n/**\n * Enables users to navigate between items by providing a list of links to previous steps in the user's navigation path.\n *\n * It helps the user to be aware of their location within the application and allows faster navigation.\n *\n * This component extends the `ui5-breadcrumbs` component from `@ui5/webcomponents-ngx`.\n * See the [UI5 Breadcrumb documentation](https://ui5.github.io/webcomponents/components/Breadcrumbs) for more info.\n *\n * This extension allows using the `RouterLink` directive on `ui5-breadcrumbs-item` components.\n *\n * @example ```html\n * <ui5-breadcrumbs>\n * <ui5-breadcrumbs-item routerLink=\"/inventory\">Inventory</ui5-breadcrumbs-item>\n * <ui5-breadcrumbs-item routerLink=\"/inventory/agile-tracking\">Agile Tracking</ui5-breadcrumbs-item>\n * <ui5-breadcrumbs-item routerLink=\"/inventory/agile-tracking/settings\">Settings</ui5-breadcrumbs-item>\n * </ui5-breadcrumbs>\n * ```\n */\n@Component({\n // eslint-disable-next-line @angular-eslint/component-selector\n selector: 'ui5-breadcrumbs',\n template: '<ng-content />',\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class BreadcrumbsComponent extends Ui5BreadcrumbsComponent {\n /**\n * @internal\n */\n @HostListener('item-click', ['$event']) onClick(event: CustomEvent<BreadcrumbsItemClickEventDetail>) {\n // When a breadcrumb receives a click event from the nested `ui5-link`, the parent `ui5-breadcrumbs` component\n // emits the custom event `item-click`. However, since the `RouterLink` directive is applied on the individual breadcrumbs,\n // and it only listens to `click` events, the directive would not act on this event.\n // So we're triggering the `click` event on the selected breadcrumb item, to ensure `RouterLink#onClick` is called.\n event.detail.item.click();\n\n // Since the `ui5-breadcrumbs-item` already contains a nested `<a>` element, the `item-click`\n // event needs to be cancelled to prevent a full page reload.\n event.preventDefault();\n }\n}\n","/**\n * All UI5-related components / directives supported by the SAP LeanIX Design System.\n */\nexport * from './ui5.provider';\n\n// UI5 Components\nexport { BusyIndicatorComponent } from '@ui5/webcomponents-ngx/main/busy-indicator';\nexport { IconComponent } from '@ui5/webcomponents-ngx/main/icon';\nexport type { BreadcrumbsItemClickEventDetail } from '@ui5/webcomponents/dist/Breadcrumbs';\n\n// LX Extensions\nexport { BreadcrumbsItemComponent } from './components/breadcrumbs-item.component';\nexport { BreadcrumbsComponent } from './components/breadcrumbs.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["Ui5BreadcrumbsItemComponent","Ui5BreadcrumbsComponent"],"mappings":";;;;;;;;;;;AAEA;;AAEG;AACI,eAAe,oBAAoB,GAAA;IACxC,MAAM,OAAO,CAAC,GAAG,CAAC;QAChB,OAAO,0DAA0D,CAAC;QAClE,OAAO,+CAA+C,CAAC;QACvD,OAAO,2CAA2C;AACnD,KAAA,CAAC;IAEF,kBAAkB,CAAC,UAAU,EAAE,MAAM,OAAO,+CAAiB,CAAC,CAAC;AACjE;;ACTA;;;;;;;;;;;;;AAaG;AACU,MAAA,UAAU,GAAG,MACxB,qBAAqB,CAAC,YAAW;IAC/B,qBAAqB,CAAC,KAAK,CAAC;IAC5B,MAAM,oBAAoB,EAAE;AAC9B,CAAC;;ACjBH;;;;;;;;;;AAUG;AAOG,MAAO,wBAAyB,SAAQA,0BAA2B,CAAA;AANzE,IAAA,WAAA,GAAA;;AAOmB,QAAA,IAAA,CAAA,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QACvB,IAAkB,CAAA,kBAAA,GAAG,MAAM,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QAC3D,IAAgB,CAAA,gBAAA,GAAG,MAAM,CAAC,gBAAgB,EAAE,EAAE,QAAQ,EAAE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1C,iBAAA;;;ACjBD;;;;;;;;;;;;;;;;;AAiBG;AAOG,MAAO,oBAAqB,SAAQC,sBAAuB,CAAA;AAC/D;;AAEG;AACqC,IAAA,OAAO,CAAC,KAAmD,EAAA;;;;;AAKjG,QAAA,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE;;;QAIzB,KAAK,CAAC,cAAc,EAAE;;+GAbb,oBAAoB,EAAA,IAAA,EAAA,IAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;AAApB,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,oBAAoB,4JAHrB,gBAAgB,EAAA,QAAA,EAAA,IAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA,CAAA;;4FAGf,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBANhC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;;AAET,oBAAA,QAAQ,EAAE,iBAAiB;AAC3B,oBAAA,QAAQ,EAAE,gBAAgB;oBAC1B,eAAe,EAAE,uBAAuB,CAAC;AAC1C,iBAAA;8BAKyC,OAAO,EAAA,CAAA;sBAA9C,YAAY;uBAAC,YAAY,EAAE,CAAC,QAAQ,CAAC;;;AChCxC;;AAEG;;ACFH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"leanix-components-ui5.mjs","sources":["../../../../libs/components/ui5/icons/register-icons.ts","../../../../libs/components/ui5/ui5.provider.ts","../../../../libs/components/ui5/components/breadcrumbs-item.component.ts","../../../../libs/components/ui5/components/breadcrumbs.component.ts","../../../../libs/components/ui5/utils/get-outer-html-with-shadow-dom.ts","../../../../libs/components/ui5/index.ts","../../../../libs/components/ui5/leanix-components-ui5.ts"],"sourcesContent":["import { registerIconLoader } from '@ui5/webcomponents-base/dist/asset-registries/Icons.js';\n\n/**\n * Registers icon libraries with UI5.\n */\nexport async function registerIconsWithUi5() {\n await Promise.all([\n import('@ui5/webcomponents-icons-business-suite/dist/AllIcons.js'),\n import('@ui5/webcomponents-icons-tnt/dist/AllIcons.js'),\n import('@ui5/webcomponents-icons/dist/AllIcons.js')\n ]);\n\n registerIconLoader('lx-icons', () => import('./lx-icons.json'));\n}\n","import { provideAppInitializer } from '@angular/core';\nimport { setDefaultFontLoading } from '@ui5/webcomponents-base/dist/config/Fonts.js';\nimport { registerIconsWithUi5 } from './icons/register-icons';\n\n/**\n * Sets up providers necessary to use UI5 components in the application.\n *\n * @usageNotes\n *\n * Basic example of how you can add UI5 to your application:\n * ```ts\n * import { provideUi5 } from '@leanix/components/ui5';\n *\n * bootstrapApplication(AppComponent, {\n * providers: [provideUi5()]\n * });\n * ```\n */\nexport const provideUi5 = () =>\n provideAppInitializer(async () => {\n setDefaultFontLoading(false);\n await registerIconsWithUi5();\n });\n","import { LocationStrategy } from '@angular/common';\nimport { ChangeDetectionStrategy, Component, effect, inject, input, untracked } from '@angular/core';\nimport { Router, RouterLink } from '@angular/router';\nimport { BreadcrumbsItemComponent as Ui5BreadcrumbsItemComponent } from '@ui5/webcomponents-ngx/main/breadcrumbs-item';\n\n/**\n * This component extends the `ui5-breadcrumbs-item` component from `@ui5/webcomponents-ngx`.\n * This extension is needed for Angular versions before 20 to sync Angular's `RouterLink` directive\n * with the `href` attribute of the `ui5-breadcrumbs-item`.\n *\n * **Why?** Support for custom elements in the `RouterLink` directive was added in Angular 20.\n * For older versions, this component allows using the `RouterLink` on a `ui5-breadcrumb-item`.\n *\n * @see https://github.com/angular/angular/commit/ff98ccb19391ed4e04528b82771c04ad67067d68\n *\n */\n@Component({\n // eslint-disable-next-line @angular-eslint/component-selector\n selector: 'ui5-breadcrumbs-item',\n template: '<ng-content />',\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class BreadcrumbsItemComponent extends Ui5BreadcrumbsItemComponent {\n private readonly router = inject(Router);\n private readonly routerLinkInstance = inject(RouterLink, { optional: true });\n private readonly locationStrategy = inject(LocationStrategy, { optional: true });\n\n readonly routerLink = input<RouterLink['routerLink']>();\n\n readonly updateBreadcrumbHref = effect(() => {\n const routerLink = this.routerLink();\n\n untracked(() => {\n if (!routerLink || !this.routerLinkInstance) {\n this.href = undefined;\n return;\n }\n const urlTree = this.routerLinkInstance.urlTree;\n\n // See https://github.com/angular/angular/blob/main/packages/router/src/directives/router_link.ts#L430\n if (urlTree !== null && this.locationStrategy) {\n this.href = this.locationStrategy?.prepareExternalUrl(this.router.serializeUrl(urlTree)) ?? '';\n } else {\n this.href = undefined;\n }\n });\n });\n}\n","import { ChangeDetectionStrategy, Component, HostListener } from '@angular/core';\nimport { BreadcrumbsComponent as Ui5BreadcrumbsComponent } from '@ui5/webcomponents-ngx/main/breadcrumbs';\nimport { BreadcrumbsItemClickEventDetail } from '@ui5/webcomponents/dist/Breadcrumbs';\n\n/**\n * Enables users to navigate between items by providing a list of links to previous steps in the user's navigation path.\n *\n * It helps the user to be aware of their location within the application and allows faster navigation.\n *\n * This component extends the `ui5-breadcrumbs` component from `@ui5/webcomponents-ngx`.\n * See the [UI5 Breadcrumb documentation](https://ui5.github.io/webcomponents/components/Breadcrumbs) for more info.\n *\n * This extension allows using the `RouterLink` directive on `ui5-breadcrumbs-item` components.\n *\n * @example ```html\n * <ui5-breadcrumbs>\n * <ui5-breadcrumbs-item routerLink=\"/inventory\">Inventory</ui5-breadcrumbs-item>\n * <ui5-breadcrumbs-item routerLink=\"/inventory/agile-tracking\">Agile Tracking</ui5-breadcrumbs-item>\n * <ui5-breadcrumbs-item routerLink=\"/inventory/agile-tracking/settings\">Settings</ui5-breadcrumbs-item>\n * </ui5-breadcrumbs>\n * ```\n */\n@Component({\n // eslint-disable-next-line @angular-eslint/component-selector\n selector: 'ui5-breadcrumbs',\n template: '<ng-content />',\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class BreadcrumbsComponent extends Ui5BreadcrumbsComponent {\n /**\n * @internal\n */\n @HostListener('item-click', ['$event']) onClick(event: CustomEvent<BreadcrumbsItemClickEventDetail>) {\n // When a breadcrumb receives a click event from the nested `ui5-link`, the parent `ui5-breadcrumbs` component\n // emits the custom event `item-click`. However, since the `RouterLink` directive is applied on the individual breadcrumbs,\n // and it only listens to `click` events, the directive would not act on this event.\n // So we're triggering the `click` event on the selected breadcrumb item, to ensure `RouterLink#onClick` is called.\n event.detail.item.click();\n\n // Since the `ui5-breadcrumbs-item` already contains a nested `<a>` element, the `item-click`\n // event needs to be cancelled to prevent a full page reload.\n event.preventDefault();\n }\n}\n","const TRAVERSED_ELEMENTS_SELECTOR = 'ui5-icon';\nconst WEB_COMPONENT_STYLE_PROPERTIES_WHITELIST = new Set([\n // positioning\n 'width',\n 'height',\n 'display',\n 'margin',\n 'margin-left',\n 'margin-right',\n 'margin-top',\n 'margin-bottom',\n 'padding',\n 'padding-left',\n 'padding-right',\n 'padding-top',\n 'padding-bottom',\n\n // coloring\n 'color',\n 'fill',\n 'outline-color',\n 'background-color'\n]);\n\n/**\n *\n * A replacement for `HTMLElement.outerHTML`, but works with web components shadow DOM.\n * Returns a string of outer HTML of a DOM node, inlining shadow DOM for web components.\n * (@see TRAVERSED_ELEMENTS_SELECTOR for the list of supported web components.)\n *\n *\n * @description\n * Solves the problem of getting the full HTML structure of web components,\n * as `element.outerHTML` does not include shadow DOM.\n * This function inlines shadow DOM into a <template> tag inside the component root.\n * It helps to keep the shadow DOM structure and preserve style encapsulation.\n * Also includes whitelisted styles from computed styles into the component root as inline styles (@see WEB_COMPONENT_STYLE_PROPERTIES_WHITELIST).\n */\nexport function getOuterHtmlWithShadowDom(rootNode: HTMLElement) {\n const lastId = addIdsToWebComponents(rootNode);\n\n return getHTMLWithWebComponents(rootNode, lastId);\n}\n\nfunction addIdsToWebComponents(rootNode: HTMLElement) {\n const components = Array.from(rootNode.querySelectorAll<HTMLElement>(TRAVERSED_ELEMENTS_SELECTOR));\n\n let lastId = 0;\n\n for (const component of components) {\n component.dataset['componentForExportId'] = lastId.toString();\n lastId++;\n }\n\n return lastId;\n}\n\nfunction getNonDefaultStyles(cssStyleDeclaration: CSSStyleDeclaration) {\n const cssText = Array.from(cssStyleDeclaration)\n .filter((property) => {\n const value = cssStyleDeclaration.getPropertyValue(property);\n return value && WEB_COMPONENT_STYLE_PROPERTIES_WHITELIST.has(property);\n })\n .map((property) => `${property}: ${cssStyleDeclaration.getPropertyValue(property)}`)\n .join('; ');\n\n return cssText;\n}\n\nfunction getHTMLWithWebComponents(rootNode: HTMLElement, lastId: number) {\n let htmlString = rootNode.outerHTML.replace(/<!--[\\S\\s]*?-->/g, ''); // clear comments\n\n if (!lastId) {\n return htmlString;\n }\n\n for (let id = 0; id < lastId; id++) {\n const component = rootNode.querySelector(`[data-component-for-export-id=\"${id}\"]`)!;\n const componentClone = component.cloneNode(false) as HTMLElement;\n\n // Preferring defaultView to make getComputedStyle testable in custom jsdom environment\n componentClone.style.cssText = getNonDefaultStyles(component.ownerDocument.defaultView!.getComputedStyle(component));\n\n // Adding shadow root to preserve style encapsulation\n componentClone.innerHTML = `<template shadowrootmode=\"open\">${component.shadowRoot?.innerHTML}</template>`;\n\n // Regex to find the component by its data attribute\n const componentRegex = new RegExp(`<[^>]+? data-component-for-export-id=\"${id}\"[^>]*?>\\\\s*<\\/[^>]+?>`, 'm');\n htmlString = htmlString.replace(componentRegex, componentClone.outerHTML);\n }\n\n return htmlString;\n}\n","/**\n * All UI5-related components / directives supported by the SAP LeanIX Design System.\n */\nexport * from './ui5.provider';\n\n// UI5 Components\nexport { BusyIndicatorComponent } from '@ui5/webcomponents-ngx/main/busy-indicator';\nexport { IconComponent } from '@ui5/webcomponents-ngx/main/icon';\nexport type { BreadcrumbsItemClickEventDetail } from '@ui5/webcomponents/dist/Breadcrumbs';\n\n// LX Extensions\nexport { BreadcrumbsItemComponent } from './components/breadcrumbs-item.component';\nexport { BreadcrumbsComponent } from './components/breadcrumbs.component';\n\n// Utils\nexport { getOuterHtmlWithShadowDom } from './utils/get-outer-html-with-shadow-dom';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["Ui5BreadcrumbsItemComponent","Ui5BreadcrumbsComponent"],"mappings":";;;;;;;;;;;AAEA;;AAEG;AACI,eAAe,oBAAoB,GAAA;IACxC,MAAM,OAAO,CAAC,GAAG,CAAC;QAChB,OAAO,0DAA0D,CAAC;QAClE,OAAO,+CAA+C,CAAC;QACvD,OAAO,2CAA2C;AACnD,KAAA,CAAC;IAEF,kBAAkB,CAAC,UAAU,EAAE,MAAM,OAAO,+CAAiB,CAAC,CAAC;AACjE;;ACTA;;;;;;;;;;;;;AAaG;AACU,MAAA,UAAU,GAAG,MACxB,qBAAqB,CAAC,YAAW;IAC/B,qBAAqB,CAAC,KAAK,CAAC;IAC5B,MAAM,oBAAoB,EAAE;AAC9B,CAAC;;ACjBH;;;;;;;;;;AAUG;AAOG,MAAO,wBAAyB,SAAQA,0BAA2B,CAAA;AANzE,IAAA,WAAA,GAAA;;AAOmB,QAAA,IAAA,CAAA,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QACvB,IAAkB,CAAA,kBAAA,GAAG,MAAM,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QAC3D,IAAgB,CAAA,gBAAA,GAAG,MAAM,CAAC,gBAAgB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QAEvE,IAAU,CAAA,UAAA,GAAG,KAAK,EAA4B;AAE9C,QAAA,IAAA,CAAA,oBAAoB,GAAG,MAAM,CAAC,MAAK;AAC1C,YAAA,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE;YAEpC,SAAS,CAAC,MAAK;gBACb,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE;AAC3C,oBAAA,IAAI,CAAC,IAAI,GAAG,SAAS;oBACrB;;AAEF,gBAAA,MAAM,O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C,SAAS,GAAG,CAAmC,gCAAA,EAAA,SAAS,CAAC,UAAU,EAAE,SAAS,CAAA,WAAA,CAAa;;QAG1G,MAAM,cAAc,GAAG,IAAI,MAAM,CAAC,CAAyC,sCAAA,EAAA,EAAE,CAAwB,sBAAA,CAAA,EAAE,GAAG,CAAC;QAC3G,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,SAAS,CAAC;;AAG3E,IAAA,OAAO,UAAU;AACnB;;AC5FA;;AAEG;;ACFH;;AAEG;;;;"}
|
package/package.json
CHANGED
package/ui5/index.d.ts
CHANGED
|
@@ -7,3 +7,4 @@ export { IconComponent } from '@ui5/webcomponents-ngx/main/icon';
|
|
|
7
7
|
export type { BreadcrumbsItemClickEventDetail } from '@ui5/webcomponents/dist/Breadcrumbs';
|
|
8
8
|
export { BreadcrumbsItemComponent } from './components/breadcrumbs-item.component';
|
|
9
9
|
export { BreadcrumbsComponent } from './components/breadcrumbs.component';
|
|
10
|
+
export { getOuterHtmlWithShadowDom } from './utils/get-outer-html-with-shadow-dom';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* A replacement for `HTMLElement.outerHTML`, but works with web components shadow DOM.
|
|
4
|
+
* Returns a string of outer HTML of a DOM node, inlining shadow DOM for web components.
|
|
5
|
+
* (@see TRAVERSED_ELEMENTS_SELECTOR for the list of supported web components.)
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* @description
|
|
9
|
+
* Solves the problem of getting the full HTML structure of web components,
|
|
10
|
+
* as `element.outerHTML` does not include shadow DOM.
|
|
11
|
+
* This function inlines shadow DOM into a <template> tag inside the component root.
|
|
12
|
+
* It helps to keep the shadow DOM structure and preserve style encapsulation.
|
|
13
|
+
* Also includes whitelisted styles from computed styles into the component root as inline styles (@see WEB_COMPONENT_STYLE_PROPERTIES_WHITELIST).
|
|
14
|
+
*/
|
|
15
|
+
export declare function getOuterHtmlWithShadowDom(rootNode: HTMLElement): string;
|