@kubex/zinc 1.0.115 → 1.0.116
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/custom-elements.json +52 -1
- package/dist/vscode.html-custom-data.json +6 -1
- package/dist/web-types.json +13 -3
- package/dist/zn.d.ts +4 -0
- package/dist/zn.min.css +1 -1
- package/dist/zn.min.js +49 -49
- package/package.json +1 -1
- package/scss/shared/_table.scss +1 -1
- package/src/components/page/page.component.ts +32 -2
- package/src/components/page/page.test.ts +17 -0
- package/src/components/tab/tab.component.ts +2 -0
package/package.json
CHANGED
package/scss/shared/_table.scss
CHANGED
|
@@ -20,6 +20,7 @@ interface TabDefinition {
|
|
|
20
20
|
sourceIndex: number;
|
|
21
21
|
uri: string | null;
|
|
22
22
|
slotName: string | null;
|
|
23
|
+
selected: boolean;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
/**
|
|
@@ -156,6 +157,7 @@ export default class ZnPage extends ZnTabs {
|
|
|
156
157
|
const priority = this.parsePriority(tab.getAttribute('priority'));
|
|
157
158
|
const uri = tab.getAttribute('uri');
|
|
158
159
|
const slotName = uri ? null : `page-tab-${index}`;
|
|
160
|
+
const selected = tab.hasAttribute('selected');
|
|
159
161
|
|
|
160
162
|
tab.id = id;
|
|
161
163
|
|
|
@@ -163,7 +165,7 @@ export default class ZnPage extends ZnTabs {
|
|
|
163
165
|
tab.slot = slotName!;
|
|
164
166
|
}
|
|
165
167
|
|
|
166
|
-
tabs.push({id, caption, priority, sourceIndex: index, uri, slotName});
|
|
168
|
+
tabs.push({id, caption, priority, sourceIndex: index, uri, slotName, selected});
|
|
167
169
|
});
|
|
168
170
|
|
|
169
171
|
this.tabDefinitions = tabs.sort((a, b) => this.compareTabs(a, b));
|
|
@@ -272,6 +274,12 @@ export default class ZnPage extends ZnTabs {
|
|
|
272
274
|
}
|
|
273
275
|
|
|
274
276
|
private activateInitialPageTab() {
|
|
277
|
+
const preselected = this.tabDefinitions.find(tab => tab.selected);
|
|
278
|
+
if (preselected) {
|
|
279
|
+
this.activateTabDefinition(preselected);
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
|
|
275
283
|
const selectedPanel = this.shadowRoot?.querySelector('#content > div[selected]');
|
|
276
284
|
const firstTab = this.tabDefinitions[0];
|
|
277
285
|
|
|
@@ -280,6 +288,28 @@ export default class ZnPage extends ZnTabs {
|
|
|
280
288
|
}
|
|
281
289
|
}
|
|
282
290
|
|
|
291
|
+
private activateTabDefinition(tab: TabDefinition) {
|
|
292
|
+
if (tab.uri) {
|
|
293
|
+
const navItem = this.findNavItemForUri(tab.uri);
|
|
294
|
+
if (navItem) {
|
|
295
|
+
this.clickTab(navItem, false);
|
|
296
|
+
this.syncNavigationActive(navItem);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
this.activateTab(tab.id, false);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
private findNavItemForUri(uri: string): HTMLElement | null {
|
|
304
|
+
const items = this.shadowRoot?.querySelectorAll<HTMLElement>('zn-navbar li[tab-uri]') ?? [];
|
|
305
|
+
for (const item of Array.from(items)) {
|
|
306
|
+
if (item.getAttribute('tab-uri') === uri) {
|
|
307
|
+
return item;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
|
|
283
313
|
private registerPagePanels() {
|
|
284
314
|
this.shadowRoot?.querySelectorAll<HTMLElement>('#content > div[id]').forEach(panel => {
|
|
285
315
|
this._addPanel(panel);
|
|
@@ -394,7 +424,7 @@ export default class ZnPage extends ZnTabs {
|
|
|
394
424
|
${this.tabDefinitions
|
|
395
425
|
.filter(tab => tab.slotName !== null)
|
|
396
426
|
.map(tab => html`
|
|
397
|
-
<div id="${tab.id}">
|
|
427
|
+
<div id="${tab.id}" ?selected=${tab.selected}>
|
|
398
428
|
<slot name="${tab.slotName!}"></slot>
|
|
399
429
|
</div>
|
|
400
430
|
`)}
|
|
@@ -380,6 +380,23 @@ describe('<zn-page>', () => {
|
|
|
380
380
|
expect(getComputedStyle(activeNavItem).transitionDuration).to.equal('0.1s');
|
|
381
381
|
});
|
|
382
382
|
|
|
383
|
+
it('opens the tab flagged with the selected attribute instead of the first', async () => {
|
|
384
|
+
const el = await fixture<ZnPage>(html`
|
|
385
|
+
<zn-page caption="Page Title">
|
|
386
|
+
<zn-tab caption="Overview">Overview Content</zn-tab>
|
|
387
|
+
<zn-tab caption="Dynamic Tab" uri="/tab-three" selected></zn-tab>
|
|
388
|
+
</zn-page>
|
|
389
|
+
`);
|
|
390
|
+
await aTimeout(60);
|
|
391
|
+
|
|
392
|
+
const navbar = el.shadowRoot!.querySelector('zn-navbar')!;
|
|
393
|
+
const uriItem = navbar.querySelector<HTMLElement>('li[tab-uri="/tab-three"]')!;
|
|
394
|
+
const overviewItem = navbar.querySelector<HTMLElement>('li[tab=""]')!;
|
|
395
|
+
|
|
396
|
+
expect(uriItem.classList.contains('active')).to.equal(true);
|
|
397
|
+
expect(overviewItem.classList.contains('active')).to.equal(false);
|
|
398
|
+
});
|
|
399
|
+
|
|
383
400
|
it('disables breadcrumbs in modal mode', async () => {
|
|
384
401
|
const el = await fixture<ZnPage>(html`
|
|
385
402
|
<zn-page caption="Page Title" modal>
|
|
@@ -18,6 +18,8 @@ export default class ZnTab extends ZincElement {
|
|
|
18
18
|
@property() caption: string;
|
|
19
19
|
@property({type: Number}) priority: number;
|
|
20
20
|
@property() uri: string;
|
|
21
|
+
/** When present, zn-page opens this tab on load instead of the first tab. */
|
|
22
|
+
@property({type: Boolean, reflect: true}) selected = false;
|
|
21
23
|
|
|
22
24
|
render() {
|
|
23
25
|
return html`<slot></slot>`;
|