@zanichelli/albe-web-components 10.0.8 → 11.0.1

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 (72) hide show
  1. package/CHANGELOG.md +2789 -0
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/web-components-library.cjs.js +1 -1
  4. package/dist/cjs/z-app-header_11.cjs.entry.js +3 -3
  5. package/dist/cjs/z-navigation-tab-link.cjs.entry.js +5 -2
  6. package/dist/cjs/z-navigation-tab.cjs.entry.js +1 -1
  7. package/dist/cjs/z-navigation-tabs.cjs.entry.js +108 -96
  8. package/dist/cjs/z-popover.cjs.entry.js +2 -2
  9. package/dist/cjs/z-range-picker.cjs.entry.js +22 -4
  10. package/dist/collection/collection-manifest.json +3 -3
  11. package/dist/collection/components/date-picker/z-range-picker/index.js +98 -4
  12. package/dist/collection/components/inputs/z-searchbar/styles.css +1 -1
  13. package/dist/collection/components/navigation/z-app-header/index.js +3 -2
  14. package/dist/collection/components/navigation/z-app-header/styles.css +9 -1
  15. package/dist/collection/components/navigation/z-navigation-tabs/index.js +335 -0
  16. package/dist/collection/components/navigation/z-navigation-tabs/index.stories.js +12 -0
  17. package/dist/collection/components/navigation/z-navigation-tabs/styles.css +212 -0
  18. package/dist/collection/components/z-popover/index.js +2 -2
  19. package/dist/collection/{components/navigation/tabs → deprecated}/navigation-tab.css +5 -4
  20. package/dist/collection/deprecated/z-link/index.js +1 -0
  21. package/dist/collection/{components/navigation/tabs → deprecated}/z-navigation-tab/index.js +8 -5
  22. package/dist/collection/{components/navigation/tabs → deprecated}/z-navigation-tab-link/index.js +7 -3
  23. package/dist/esm/loader.js +1 -1
  24. package/dist/esm/web-components-library.js +1 -1
  25. package/dist/esm/z-app-header_11.entry.js +3 -3
  26. package/dist/esm/z-navigation-tab-link.entry.js +5 -2
  27. package/dist/esm/z-navigation-tab.entry.js +1 -1
  28. package/dist/esm/z-navigation-tabs.entry.js +110 -98
  29. package/dist/esm/z-popover.entry.js +2 -2
  30. package/dist/esm/z-range-picker.entry.js +22 -4
  31. package/dist/types/components/date-picker/z-range-picker/index.d.ts +10 -0
  32. package/dist/types/components/navigation/z-app-header/index.d.ts +2 -1
  33. package/dist/types/components/navigation/{tabs/z-navigation-tabs → z-navigation-tabs}/index.d.ts +43 -31
  34. package/dist/types/components.d.ts +52 -2
  35. package/dist/types/deprecated/z-link/index.d.ts +1 -0
  36. package/dist/types/{components/navigation/tabs → deprecated}/z-navigation-tab/index.d.ts +2 -1
  37. package/dist/types/{components/navigation/tabs → deprecated}/z-navigation-tab-link/index.d.ts +2 -1
  38. package/dist/web-components-library/p-0b1c8f55.entry.js +1 -0
  39. package/dist/web-components-library/p-31a19318.entry.js +1 -0
  40. package/dist/web-components-library/p-498ed5c1.entry.js +1 -0
  41. package/dist/web-components-library/p-6c452dbc.entry.js +1 -0
  42. package/dist/web-components-library/p-9f2bfd3b.entry.js +1 -0
  43. package/dist/web-components-library/{p-5c8c249e.entry.js → p-a69d9a1c.entry.js} +1 -1
  44. package/dist/web-components-library/web-components-library.css +3 -2
  45. package/dist/web-components-library/web-components-library.esm.js +1 -1
  46. package/package.json +1 -1
  47. package/src-react/index.ts +1 -0
  48. package/www/build/p-08a3464e.js +129 -0
  49. package/www/build/p-0b1c8f55.entry.js +1 -0
  50. package/www/build/p-31a19318.entry.js +1 -0
  51. package/www/build/p-498ed5c1.entry.js +1 -0
  52. package/www/build/p-6c452dbc.entry.js +1 -0
  53. package/www/build/p-9f2bfd3b.entry.js +1 -0
  54. package/www/build/{p-5c8c249e.entry.js → p-a69d9a1c.entry.js} +1 -1
  55. package/www/build/{p-f7695a31.css → p-f47dfea6.css} +208 -34
  56. package/www/build/web-components-library.css +3 -2
  57. package/www/build/web-components-library.esm.js +1 -1
  58. package/www/index.html +1 -1
  59. package/dist/collection/components/navigation/tabs/z-navigation-tabs/index.js +0 -291
  60. package/dist/collection/components/navigation/tabs/z-navigation-tabs/index.stories.js +0 -11
  61. package/dist/collection/components/navigation/tabs/z-navigation-tabs/styles.css +0 -102
  62. package/dist/web-components-library/p-0d2c1891.entry.js +0 -1
  63. package/dist/web-components-library/p-200823b4.entry.js +0 -1
  64. package/dist/web-components-library/p-c5634f85.entry.js +0 -1
  65. package/dist/web-components-library/p-d5026b5b.entry.js +0 -1
  66. package/dist/web-components-library/p-fa7b1ee3.entry.js +0 -1
  67. package/www/build/p-0d2c1891.entry.js +0 -1
  68. package/www/build/p-200823b4.entry.js +0 -1
  69. package/www/build/p-51b30a96.js +0 -129
  70. package/www/build/p-c5634f85.entry.js +0 -1
  71. package/www/build/p-d5026b5b.entry.js +0 -1
  72. package/www/build/p-fa7b1ee3.entry.js +0 -1
@@ -1,11 +1,12 @@
1
- import { r as registerInstance, h, H as Host, g as getElement } from './index-a2ca4b97.js';
2
- import { N as NavigationTabsOrientation, a as NavigationTabsSize, g as KeyboardCode, b as NavigationTabsKeyboardEvents } from './index-03c8b0f0.js';
1
+ import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-a2ca4b97.js';
2
+ import { N as NavigationTabsOrientation, a as NavigationTabsSize, b as NavigationTabsKeyboardEvents, g as KeyboardCode } from './index-03c8b0f0.js';
3
3
 
4
- const stylesCss = ":host{--z-navigation-tabs-nav-buttons-bg:var(--color-white);--z-navigation-tabs-nav-buttons-fg:var(--color-primary01);position:relative;z-index:0;display:flex;overflow:hidden;flex-direction:row;font-family:var(--font-family-sans);font-weight:var(--font-rg)}:host,:host *,::slotted(*){box-sizing:border-box}::-webkit-scrollbar{display:none}.navigation-button{position:absolute;z-index:1;display:flex;align-items:center;justify-content:center;padding:0;border:none;margin:0;background:var(--z-navigation-tabs-nav-buttons-bg);border-radius:var(--border-no-radius);box-shadow:0 0 4px 1px var(--shadow-color-base);cursor:pointer;fill:var(--z-navigation-tabs-nav-buttons-fg);outline:none}.navigation-button:disabled{display:none}nav{display:flex;overflow:auto;align-items:center;justify-content:flex-start;scroll-behavior:smooth;scrollbar-width:none}:host([orientation=\"horizontal\"]) nav{width:100%}:host([orientation=\"horizontal\"]) .navigation-button{top:0;width:calc(var(--space-unit) * 4);height:100%}:host([orientation=\"horizontal\"]) .navigation-button:first-child{left:0}:host([orientation=\"horizontal\"]) .navigation-button:last-child{right:0}:host([orientation=\"vertical\"]){width:fit-content;flex-direction:column}:host([orientation=\"vertical\"]) nav{height:100%;flex-direction:column;align-items:stretch}:host([orientation=\"vertical\"]) .navigation-button{left:0;width:100%;height:calc(var(--space-unit) * 4)}:host([orientation=\"vertical\"]) .navigation-button:first-child{top:0}:host([orientation=\"vertical\"]) .navigation-button:last-child{bottom:0}:host([size=\"small\"][orientation=\"vertical\"]) .navigation-button{height:calc(var(--space-unit) * 4)}";
4
+ const stylesCss = "z-navigation-tabs{position:relative;z-index:0;display:flex;overflow:hidden;flex-direction:row;font-family:var(--font-family-sans);font-weight:var(--font-rg)}z-navigation-tabs,z-navigation-tabs *{box-sizing:border-box}z-navigation-tabs>nav::-webkit-scrollbar{display:none}.navigation-button{position:absolute;z-index:1;display:flex;align-items:center;justify-content:center;padding:0;border:none;margin:0;background-color:var(--z-navigation-tabs-nav-buttons-bg, var(--color-surface01));border-radius:var(--border-no-radius);box-shadow:0 0 4px 1px var(--shadow-color-base);cursor:pointer;fill:var(--z-navigation-tabs-nav-buttons-fg, var(--color-primary01));outline:none}z-navigation-tabs .navigation-button:disabled{display:none}z-navigation-tabs>nav{z-index:0;display:flex;overflow:auto;align-items:center;justify-content:flex-start;scroll-behavior:smooth;scrollbar-width:none}z-navigation-tabs[orientation=\"horizontal\"]>nav{width:100%}z-navigation-tabs[orientation=\"horizontal\"] .navigation-button{top:0;width:calc(var(--space-unit) * 4);height:100%}z-navigation-tabs[orientation=\"horizontal\"] .navigation-button:first-child{left:0}z-navigation-tabs[orientation=\"horizontal\"] .navigation-button:last-child{right:0}z-navigation-tabs[orientation=\"vertical\"]{width:fit-content;flex-direction:column}z-navigation-tabs[orientation=\"vertical\"]>nav{height:100%;flex-direction:column;align-items:stretch}z-navigation-tabs[orientation=\"vertical\"] .navigation-button{left:0;width:100%;height:calc(var(--space-unit) * 4)}z-navigation-tabs[orientation=\"vertical\"] .navigation-button:first-child{top:0}z-navigation-tabs[orientation=\"vertical\"] .navigation-button:last-child{bottom:0}z-navigation-tabs[size=\"small\"][orientation=\"vertical\"] .navigation-button{height:calc(var(--space-unit) * 4)}z-navigation-tabs>nav>*{position:relative;z-index:0;display:inline-flex;width:auto;align-items:center;justify-content:center;padding:calc(var(--space-unit) * 2) calc(var(--space-unit) * 5);border:none;margin:0;background-color:unset;border-radius:var(--border-no-radius);color:var(--color-primary01);cursor:pointer;fill:currentcolor;font-family:var(--font-family-sans);font-size:inherit;gap:var(--space-unit);letter-spacing:inherit;line-height:inherit;outline:none;text-align:center;white-space:nowrap}z-navigation-tabs>nav>a{text-decoration:none}z-navigation-tabs>nav>*:focus:focus-visible{z-index:1;box-shadow:inset 0 0 4px 3px var(--color-highlight)}z-navigation-tabs>nav>:not([disabled]):hover{background-color:var(--color-surface02)}z-navigation-tabs>nav>button[disabled]{color:var(--color-disabled03);cursor:not-allowed;fill:currentcolor;pointer-events:all}z-navigation-tabs>nav>:not([disabled]):hover,nav>[aria-selected=\"true\"]{color:var(--color-hover-secondary);fill:currentcolor}z-navigation-tabs>nav>:not([disabled]):hover::after,nav>[aria-selected=\"true\"]::after{position:absolute;background-color:var(--color-hover-secondary);content:\"\"}z-navigation-tabs[orientation=\"horizontal\"]>nav>:not([disabled]):hover::after,z-navigation-tabs[orientation=\"horizontal\"]>nav>[aria-selected=\"true\"]::after{bottom:0;left:0;width:100%;height:var(--border-size-large)}z-navigation-tabs>nav>* z-icon{--z-icon-width:calc(var(--space-unit) * 2);--z-icon-height:calc(var(--space-unit) * 2);display:flex;margin:0}z-navigation-tabs[size=\"small\"][orientation=\"horizontal\"]>nav>*{padding:var(--space-unit) calc(var(--space-unit) * 2)}z-navigation-tabs[size=\"small\"][orientation=\"horizontal\"]>nav>:not([disabled]):hover::after,z-navigation-tabs[size=\"small\"][orientation=\"horizontal\"]>nav>[aria-selected=\"true\"]::after{height:var(--border-size-medium)}z-navigation-tabs[size=\"small\"]:not([orientation=\"vertical\"])>nav>* z-icon{--z-icon-width:14px;--z-icon-height:14px}z-navigation-tabs[orientation=\"vertical\"]>nav>*{padding:calc(var(--space-unit) * 3) calc(var(--space-unit) * 2)}z-navigation-tabs[orientation=\"vertical\"]>nav>*>:not(z-icon){display:none}z-navigation-tabs[orientation=\"vertical\"]>nav>:not([disabled]):hover::after,z-navigation-tabs[orientation=\"vertical\"]>nav>[aria-selected=\"true\"]::after{top:0;right:0;width:var(--border-size-large);height:100%}";
5
5
 
6
6
  const ZNavigationTabs = class {
7
7
  constructor(hostRef) {
8
8
  registerInstance(this, hostRef);
9
+ this.selected = createEvent(this, "selected", 7);
9
10
  /**
10
11
  * Navigation tabs orientation.
11
12
  */
@@ -14,6 +15,14 @@ const ZNavigationTabs = class {
14
15
  * Navigation tabs size.
15
16
  */
16
17
  this.size = NavigationTabsSize.BIG;
18
+ /**
19
+ * Index of the selected tab.
20
+ */
21
+ this.selectedTab = undefined;
22
+ /**
23
+ * Index of the last tab that held focus.
24
+ */
25
+ this.focusedTab = 0;
17
26
  }
18
27
  /**
19
28
  * Getter for the direction to check based on current orientation.
@@ -28,158 +37,161 @@ const ZNavigationTabs = class {
28
37
  return this.orientation == NavigationTabsOrientation.HORIZONTAL ? "Width" : "Height";
29
38
  }
30
39
  get tabs() {
31
- return Array.from(this.host.children);
40
+ return Array.from(this.nav.children);
32
41
  }
33
42
  /**
34
- * Set the `size` prop to all `z-navigation-tab` children.
43
+ * Scroll into view to center the tab.
35
44
  */
36
- setChildrenSize() {
37
- this.tabs.forEach((tab) => {
38
- tab.size = this.size;
45
+ scrollToTab(tabElement) {
46
+ const scrollOptions = (this.orientation === NavigationTabsOrientation.HORIZONTAL
47
+ ? { block: "nearest", inline: "center" }
48
+ : { block: "center", inline: "nearest" });
49
+ tabElement.scrollIntoView(Object.assign({ behavior: "smooth" }, scrollOptions));
50
+ }
51
+ /**
52
+ * Scroll the navigation bar half of its size backward.
53
+ */
54
+ navigateBackwards() {
55
+ this.nav.scrollBy({
56
+ [this.direction.toLowerCase()]: 0 - this.nav[`client${this.dimension}`] / 2,
57
+ behavior: "smooth",
39
58
  });
40
59
  }
41
60
  /**
42
- * Set the `orientation` prop to all `z-navigation-tab` children.
61
+ * Scroll the navigation bar half of its size forward.
43
62
  */
44
- setChildrenOrientation() {
45
- this.tabs.forEach((tab) => {
46
- tab.orientation = this.orientation;
63
+ navigateForward() {
64
+ this.nav.scrollBy({
65
+ [this.direction.toLowerCase()]: this.nav[`scroll${this.direction}`] + this.nav[`client${this.dimension}`] / 2,
66
+ behavior: "smooth",
47
67
  });
48
68
  }
49
69
  /**
50
- * Check if the navigation buttons are needed on window resize.
70
+ * Check if a keyboard event was triggered by an arrow key.
51
71
  */
52
- checkScrollVisible() {
53
- if (!this.tabsNav) {
54
- return;
55
- }
56
- this.canNavigate = this.tabsNav[`scroll${this.dimension}`] > this.tabsNav[`client${this.dimension}`];
72
+ isArrowNavigation(e) {
73
+ return Object.values(NavigationTabsKeyboardEvents).includes(e.key);
57
74
  }
58
75
  /**
59
76
  * Check if navigation buttons can be enabled for each direction.
60
77
  */
61
78
  checkScrollEnabled() {
62
- if (!this.tabsNav) {
79
+ if (!this.nav) {
63
80
  return;
64
81
  }
65
82
  this.canNavigateNext =
66
- this.tabsNav[`scroll${this.direction}`] + this.tabsNav[`client${this.dimension}`] <
67
- this.tabsNav[`scroll${this.dimension}`];
68
- this.canNavigatePrev = this.tabsNav[`scroll${this.direction}`] > 0;
83
+ this.nav[`scroll${this.direction}`] + this.nav[`client${this.dimension}`] < this.nav[`scroll${this.dimension}`];
84
+ this.canNavigatePrev = this.nav[`scroll${this.direction}`] > 0;
69
85
  }
70
86
  /**
71
- * Listen for child tab selection.
72
- * Deselect all other previously selected tabs,
73
- * then scroll to the new selected tab and center it.
74
- * @param {CustomEvent} event `selected` event triggered by a child tab
87
+ * When the selected tab changes, update the `aria-selected` attribute on each tab and scroll to the selected tab.
75
88
  */
76
- onTabSelected(event) {
77
- const selectedTab = event.target;
89
+ onTabSelected() {
78
90
  this.tabs.forEach((tab, i) => {
79
- if (tab !== selectedTab) {
80
- tab.selected = undefined;
81
- }
82
- else {
83
- this.tabFocus = i;
91
+ const zicon = tab.querySelector("z-icon");
92
+ const strokeIcon = zicon === null || zicon === void 0 ? void 0 : zicon.getAttribute("name").replace("-filled", "");
93
+ if (i !== this.selectedTab) {
94
+ tab.setAttribute("aria-selected", "false");
95
+ tab.tabIndex = -1;
96
+ zicon === null || zicon === void 0 ? void 0 : zicon.setAttribute("name", strokeIcon);
97
+ return;
84
98
  }
99
+ zicon === null || zicon === void 0 ? void 0 : zicon.setAttribute("name", `${strokeIcon}-filled`);
100
+ tab.tabIndex = 0;
101
+ tab.setAttribute("aria-selected", "true");
85
102
  });
103
+ this.scrollToTab(this.tabs[this.selectedTab]);
104
+ this.selected.emit(this.selectedTab);
86
105
  }
87
106
  /**
88
- * Scroll the navigation bar half of its size backward.
107
+ * Check if the navigation buttons are needed on window resize.
89
108
  */
90
- navigateBackwards() {
91
- this.tabsNav.scrollBy({
92
- [this.direction.toLowerCase()]: 0 - this.tabsNav[`client${this.dimension}`] / 2,
93
- behavior: "smooth",
94
- });
109
+ checkScrollVisible() {
110
+ if (!this.nav) {
111
+ return;
112
+ }
113
+ this.canNavigate = this.nav[`scroll${this.dimension}`] > this.nav[`client${this.dimension}`];
95
114
  }
96
115
  /**
97
- * Scroll the navigation bar half of its size forward.
116
+ * Handle click on the tabs.
117
+ * @param event `click` event triggered by a child tab
98
118
  */
99
- navigateForward() {
100
- this.tabsNav.scrollBy({
101
- [this.direction.toLowerCase()]: this.tabsNav[`scroll${this.direction}`] + this.tabsNav[`client${this.dimension}`] / 2,
102
- behavior: "smooth",
103
- });
119
+ handleTabClick(event) {
120
+ const clickedTab = event.target.closest("[role='tab']");
121
+ if (!this.tabs.some((child) => child.contains(clickedTab))) {
122
+ return;
123
+ }
124
+ this.selectedTab = this.tabs.indexOf(clickedTab);
104
125
  }
105
126
  /**
106
- * Move focus through tabs using keyboard arrows.
107
- * When `TAB` is pressed, focus the currently selected tab, if any.
127
+ * Move focus through tabs when an arrow key is pressed.
128
+ * When `TAB` is pressed, focus the currently selected tab if any.
108
129
  */
109
- navigateThroughTabs(e) {
110
- const tabs = this.tabs;
111
- if (e.key === KeyboardCode.TAB) {
112
- tabs.forEach((tab, i) => {
113
- if (tab.selected && tabs.some((tab) => tab === e.target)) {
114
- this.tabFocus = i;
115
- }
116
- });
117
- tabs[this.tabFocus].children[0].tabIndex = 0;
118
- tabs[this.tabFocus].children[0].focus();
130
+ navigateThroughTabs(event) {
131
+ if (!this.tabs.some((tab) => tab.contains(event.target))) {
132
+ return true;
133
+ }
134
+ if (event.key === KeyboardCode.TAB) {
135
+ this.focusedTab = this.selectedTab || 0;
136
+ this.tabs[this.focusedTab].focus({ preventScroll: true });
119
137
  return;
120
138
  }
121
- if (!this.isArrowNavigation(e)) {
139
+ if (!this.isArrowNavigation(event)) {
122
140
  return true;
123
141
  }
124
- e.preventDefault();
125
- tabs[this.tabFocus].children[0].tabIndex = -1;
126
- // Move forward
127
- if ((e.key === NavigationTabsKeyboardEvents.RIGHT && this.orientation == NavigationTabsOrientation.HORIZONTAL) ||
128
- (e.key === NavigationTabsKeyboardEvents.DOWN && this.orientation == NavigationTabsOrientation.VERTICAL)) {
129
- this.tabFocus++;
130
- if (this.tabFocus >= tabs.length) {
131
- this.tabFocus = 0;
142
+ event.preventDefault();
143
+ this.tabs[this.focusedTab].tabIndex = -1;
144
+ if ((event.key === NavigationTabsKeyboardEvents.RIGHT && this.orientation == NavigationTabsOrientation.HORIZONTAL) ||
145
+ (event.key === NavigationTabsKeyboardEvents.DOWN && this.orientation == NavigationTabsOrientation.VERTICAL)) {
146
+ // Move forward
147
+ this.focusedTab++;
148
+ if (this.focusedTab >= this.tabs.length) {
149
+ this.focusedTab = 0;
132
150
  }
133
- // Move backward
134
151
  }
135
- else if ((e.key === NavigationTabsKeyboardEvents.LEFT && this.orientation == NavigationTabsOrientation.HORIZONTAL) ||
136
- (e.key === NavigationTabsKeyboardEvents.UP && this.orientation == NavigationTabsOrientation.VERTICAL)) {
137
- this.tabFocus--;
138
- if (this.tabFocus < 0) {
139
- this.tabFocus = tabs.length - 1;
152
+ else if ((event.key === NavigationTabsKeyboardEvents.LEFT && this.orientation == NavigationTabsOrientation.HORIZONTAL) ||
153
+ (event.key === NavigationTabsKeyboardEvents.UP && this.orientation == NavigationTabsOrientation.VERTICAL)) {
154
+ // Move backward
155
+ this.focusedTab--;
156
+ if (this.focusedTab < 0) {
157
+ this.focusedTab = this.tabs.length - 1;
140
158
  }
141
159
  }
142
- // ignore disabled tabs
143
- if (tabs[this.tabFocus].disabled) {
144
- this.navigateThroughTabs(e);
145
- }
146
- else {
147
- tabs[this.tabFocus].children[0].tabIndex = 0;
148
- tabs[this.tabFocus].children[0].focus();
160
+ // Ignore disabled tabs
161
+ if (this.tabs[this.focusedTab].hasAttribute("disabled") &&
162
+ this.tabs[this.focusedTab].getAttribute("disabled") !== "false") {
163
+ return this.navigateThroughTabs(event);
149
164
  }
150
- }
151
- /**
152
- * Check if a keyboard event was triggered by an arrow key.
153
- */
154
- isArrowNavigation(e) {
155
- return Object.values(NavigationTabsKeyboardEvents).includes(e.key);
165
+ this.tabs[this.focusedTab].tabIndex = 0;
166
+ this.tabs[this.focusedTab].focus();
167
+ this.scrollToTab(this.tabs[this.focusedTab]);
156
168
  }
157
169
  componentDidRender() {
158
- this.setChildrenSize();
159
- this.setChildrenOrientation();
160
170
  this.checkScrollVisible();
161
- const tabActive = this.tabs.findIndex((tab) => tab.ariaSelected === "true");
162
- if ((!this.tabFocus && tabActive < 0) || this.tabFocus === undefined) {
163
- this.tabFocus = tabActive >= 0 ? tabActive : 0;
164
- const tabChild = this.tabs[this.tabFocus].children[0];
165
- if (tabChild) {
166
- tabChild.tabIndex = 0;
167
- }
171
+ }
172
+ componentDidLoad() {
173
+ // Set role and tabindex to each slotted tab
174
+ this.tabs.forEach((tab) => {
175
+ tab.setAttribute("role", "tab");
176
+ tab.tabIndex = -1;
177
+ });
178
+ this.tabs[0].tabIndex = 0;
179
+ if (this.selectedTab !== undefined) {
180
+ this.onTabSelected();
168
181
  }
169
182
  }
170
183
  render() {
171
184
  return (h(Host, { class: {
172
185
  "interactive-2": this.size === NavigationTabsSize.SMALL,
173
186
  "interactive-1": this.size !== NavigationTabsSize.SMALL,
174
- }, scrollable: this.canNavigate }, this.canNavigate && (h("button", { class: "navigation-button", onClick: this.navigateBackwards.bind(this), tabindex: "-1", disabled: !this.canNavigatePrev, "aria-label": "Mostra elementi precedenti" }, h("z-icon", { name: this.orientation === NavigationTabsOrientation.HORIZONTAL ? "chevron-left" : "chevron-up", width: 16, height: 16 }))), h("nav", { role: "tablist", "aria-label": this.ariaLabel, ref: (el) => (this.tabsNav = el !== null && el !== void 0 ? el : this.tabsNav), onScroll: this.checkScrollEnabled.bind(this), "aria-orientation": this.orientation }, h("slot", null)), this.canNavigate && (h("button", { class: "navigation-button", onClick: this.navigateForward.bind(this), onKeyDown: (e) => {
187
+ }, scrollable: this.canNavigate }, this.canNavigate && (h("button", { class: "navigation-button", onClick: this.navigateBackwards.bind(this), tabIndex: -1, disabled: !this.canNavigatePrev, "aria-label": "Mostra elementi precedenti" }, h("z-icon", { name: this.orientation === NavigationTabsOrientation.HORIZONTAL ? "chevron-left" : "chevron-up", width: 16, height: 16 }))), h("nav", { role: "tablist", "aria-label": this.ariaLabel, ref: (el) => (this.nav = el !== null && el !== void 0 ? el : this.nav), onScroll: this.checkScrollEnabled.bind(this), "aria-orientation": this.orientation }, h("slot", null)), this.canNavigate && (h("button", { class: "navigation-button", onClick: this.navigateForward.bind(this), onKeyDown: (e) => {
175
188
  this.navigateThroughTabs(e);
176
189
  }, tabindex: "-1", disabled: !this.canNavigateNext, "aria-label": "Mostra elementi successivi" }, h("z-icon", { name: this.orientation === NavigationTabsOrientation.HORIZONTAL ? "chevron-right" : "chevron-down", width: 16, height: 16 })))));
177
190
  }
178
191
  get host() { return getElement(this); }
179
192
  static get watchers() { return {
180
- "size": ["setChildrenSize"],
181
- "orientation": ["setChildrenOrientation"],
182
- "canNavigate": ["checkScrollEnabled"]
193
+ "canNavigate": ["checkScrollEnabled"],
194
+ "selectedTab": ["onTabSelected"]
183
195
  }; }
184
196
  };
185
197
  ZNavigationTabs.style = stylesCss;
@@ -126,7 +126,7 @@ const ZPopover = class {
126
126
  }
127
127
  if (!e.composedPath().includes(this.host)) {
128
128
  const target = e.target;
129
- const triggerElemClicked = this.bindTo instanceof HTMLElement ? this.bindTo.contains(target) : target.closest(this.bindTo);
129
+ const triggerElemClicked = this.bindTo instanceof HTMLElement ? this.bindTo.contains(target) : target.closest(CSS.escape(this.bindTo));
130
130
  if (triggerElemClicked) {
131
131
  e.stopPropagation();
132
132
  }
@@ -170,7 +170,7 @@ const ZPopover = class {
170
170
  setPosition() {
171
171
  let element;
172
172
  if (typeof this.bindTo === "string") {
173
- element = this.host.ownerDocument.querySelector(this.bindTo);
173
+ element = this.host.ownerDocument.querySelector(CSS.escape(this.bindTo));
174
174
  }
175
175
  else if (this.bindTo) {
176
176
  element = this.bindTo;
@@ -11,6 +11,14 @@ const ZRangePicker = class {
11
11
  this.dateSelect = createEvent(this, "dateSelect", 7);
12
12
  /** [Optional] datepicker mode: date or datetime */
13
13
  this.mode = ZRangePickerMode.DATE;
14
+ /** readonly mode */
15
+ this.firstPickerReadOnly = false;
16
+ /** readonly mode */
17
+ this.lastPickerReadOnly = false;
18
+ /** readonly mode */
19
+ this.firstPickerPlaceholder = "";
20
+ /** readonly mode */
21
+ this.lastPickerPlaceholder = "";
14
22
  this.flatpickrPosition = ZDatePickerPosition.BOTTOM;
15
23
  this.activeInput = "start-input";
16
24
  this.firstInputError = false;
@@ -56,6 +64,14 @@ const ZRangePicker = class {
56
64
  componentDidLoad() {
57
65
  this.setupPickers();
58
66
  }
67
+ setupFirstPickersReadOnly() {
68
+ var _a;
69
+ (_a = this.firstPicker) === null || _a === void 0 ? void 0 : _a.set("clickOpens", !this.firstPickerReadOnly);
70
+ }
71
+ setupLastPickersReadOnly() {
72
+ var _a;
73
+ (_a = this.lastPicker) === null || _a === void 0 ? void 0 : _a.set("clickOpens", !this.lastPickerReadOnly);
74
+ }
59
75
  setupPickers() {
60
76
  const config = {
61
77
  enableTime: this.mode === ZRangePickerMode.DATE_TIME,
@@ -109,8 +125,8 @@ const ZRangePicker = class {
109
125
  setAriaOptions(this.element, this.mode);
110
126
  },
111
127
  };
112
- this.firstPicker = flatpickr(`.${this.rangePickerId}-1-container`, Object.assign(Object.assign({}, config), { mode: "single", appendTo: this.element.querySelector(`.${this.rangePickerId}-1-wrapper`) }));
113
- this.lastPicker = flatpickr(`.${this.rangePickerId}-2-container`, Object.assign(Object.assign({}, config), { mode: "single", appendTo: this.element.querySelector(`.${this.rangePickerId}-2-wrapper`) }));
128
+ this.firstPicker = flatpickr(`.${this.rangePickerId}-1-container`, Object.assign(Object.assign({}, Object.assign(Object.assign({}, config), { clickOpens: !this.firstPickerReadOnly })), { mode: "single", appendTo: this.element.querySelector(`.${this.rangePickerId}-1-wrapper`) }));
129
+ this.lastPicker = flatpickr(`.${this.rangePickerId}-2-container`, Object.assign(Object.assign({}, Object.assign(Object.assign({}, config), { clickOpens: !this.lastPickerReadOnly })), { mode: "single", appendTo: this.element.querySelector(`.${this.rangePickerId}-2-wrapper`) }));
114
130
  this.element.querySelectorAll(".flatpickr-weekday").forEach((element) => {
115
131
  element.innerHTML = element.innerHTML.trim().charAt(0);
116
132
  });
@@ -323,14 +339,16 @@ const ZRangePicker = class {
323
339
  [this.mode]: true,
324
340
  [this.activeInput]: true,
325
341
  [this.flatpickrPosition]: true,
326
- } }, h("div", { class: `${this.rangePickerId}-1-wrapper` }, h("div", { class: `${this.rangePickerId}-1-container` }, h("z-input", Object.assign({}, zInputProps, { "data-input": "data-input", class: `start-input ${this.rangePickerId}-1`, ariaLabel: this.firstAriaLabel, label: this.firstLabel, status: this.firstInputError && InputStatus.ERROR, onStartTyping: () => {
342
+ } }, h("div", { class: `${this.rangePickerId}-1-wrapper` }, h("div", { class: `${this.rangePickerId}-1-container` }, h("z-input", Object.assign({}, zInputProps, { placeholder: this.firstPickerPlaceholder, readonly: this.firstPickerReadOnly, "data-input": "data-input", class: `start-input ${this.rangePickerId}-1`, ariaLabel: this.firstAriaLabel, label: this.firstLabel, status: this.firstInputError && InputStatus.ERROR, onStartTyping: () => {
327
343
  this.firstInputError = false;
328
- } })))), h("div", { class: `${this.rangePickerId}-2-wrapper` }, h("div", { class: `${this.rangePickerId}-2-container` }, h("z-input", Object.assign({}, zInputProps, { "data-input": "data-input", class: `end-input ${this.rangePickerId}-2`, ariaLabel: this.secondAriaLabel, label: this.secondLabel, status: this.lastInputError && InputStatus.ERROR, onStartTyping: () => {
344
+ } })))), h("div", { class: `${this.rangePickerId}-2-wrapper` }, h("div", { class: `${this.rangePickerId}-2-container` }, h("z-input", Object.assign({}, zInputProps, { placeholder: this.lastPickerPlaceholder, readonly: this.lastPickerReadOnly, "data-input": "data-input", class: `end-input ${this.rangePickerId}-2`, ariaLabel: this.secondAriaLabel, label: this.secondLabel, status: this.lastInputError && InputStatus.ERROR, onStartTyping: () => {
329
345
  this.lastInputError = false;
330
346
  } }))))));
331
347
  }
332
348
  get element() { return getElement(this); }
333
349
  static get watchers() { return {
350
+ "firstPickerReadOnly": ["setupFirstPickersReadOnly"],
351
+ "lastPickerReadOnly": ["setupLastPickersReadOnly"],
334
352
  "mode": ["setupPickers"]
335
353
  }; }
336
354
  };
@@ -14,6 +14,14 @@ export declare class ZRangePicker {
14
14
  secondLabel?: string;
15
15
  /** [Optional] datepicker mode: date or datetime */
16
16
  mode: ZRangePickerMode;
17
+ /** readonly mode */
18
+ firstPickerReadOnly: boolean;
19
+ /** readonly mode */
20
+ lastPickerReadOnly: boolean;
21
+ /** readonly mode */
22
+ firstPickerPlaceholder: string;
23
+ /** readonly mode */
24
+ lastPickerPlaceholder: string;
17
25
  flatpickrPosition: ZDatePickerPosition;
18
26
  activeInput: string;
19
27
  firstInputError: boolean;
@@ -25,6 +33,8 @@ export declare class ZRangePicker {
25
33
  handleClick(): void;
26
34
  handleKeyDown(ev: KeyboardEvent): void;
27
35
  componentDidLoad(): void;
36
+ setupFirstPickersReadOnly(): void;
37
+ setupLastPickersReadOnly(): void;
28
38
  setupPickers(): void;
29
39
  private onDateSelect;
30
40
  private disableDates;
@@ -1,7 +1,8 @@
1
1
  import { EventEmitter } from "../../../stencil-public-runtime";
2
2
  /**
3
3
  * @slot title - Slot for the main title
4
- * @slot subtitle - Slot for the subtitle. It will not appear in stuck header.
4
+ * @slot subtitle - Slot for the bottom subtitle. It will not appear in stuck header.
5
+ * @slot top-subtitle - Slot for the top subtitle. It will not appear in stuck header.
5
6
  * @slot stucked-title - Title for the stuck header. By default it uses the text from the `title` slot.
6
7
  * @cssprop --app-header-typography-1-size - Part of the heading typography's scale. Use it if you have to override the default value. Value: `24px`.
7
8
  * @cssprop --app-header-typography-2-size - Part of the heading typography's scale. Use it if you have to override the default value. Value: `28px`.
@@ -1,13 +1,15 @@
1
- import { NavigationTabsSize, NavigationTabsOrientation } from "../../../../beans";
1
+ import { EventEmitter } from "../../../stencil-public-runtime";
2
+ import { NavigationTabsSize, NavigationTabsOrientation } from "../../../beans";
2
3
  /**
3
4
  * Navigation tabs component.
4
- * @slot - Main slot. Use `z-navigation-tab` or `z-navigation-tab-link` components as children.
5
+ * To select a specific tab programmatically, set the `aria-selected` attribute to `true` on the desired tab.
6
+ * @slot - Main slot. Use `<button>` or `<a>` tags as children.
5
7
  * @cssprop --z-navigation-tabs-nav-buttons-bg - Navigation buttons background color.
6
8
  * @cssprop --z-navigation-tabs-nav-buttons-fg - Navigation buttons foreground color.
7
9
  */
8
10
  export declare class ZNavigationTabs {
9
11
  /**
10
- * Set aria-label attribute in tablist role.
12
+ * Set `aria-label` attribute to the internal `<nav>` element with `tablist` role.
11
13
  */
12
14
  ariaLabel?: string;
13
15
  /**
@@ -18,24 +20,35 @@ export declare class ZNavigationTabs {
18
20
  * Navigation tabs size.
19
21
  */
20
22
  size?: NavigationTabsSize;
23
+ /**
24
+ * Index of the selected tab.
25
+ */
26
+ selectedTab: number;
27
+ /**
28
+ * Emitted when the selected tab changes.
29
+ */
30
+ selected: EventEmitter<number>;
21
31
  /**
22
32
  * Whether to show navigation buttons.
23
33
  */
24
34
  canNavigate: boolean;
25
35
  /**
26
- * Whether backwards navigation is enabled.
36
+ * Whether backwards navigation is allowed.
27
37
  */
28
38
  canNavigatePrev: boolean;
29
39
  /**
30
- * Whether forward navigation is enabled.
40
+ * Whether forward navigation is allowed.
31
41
  */
32
42
  canNavigateNext: boolean;
43
+ host: HTMLZNavigationTabsElement;
33
44
  /**
34
- * tab focus index.
45
+ * Index of the last tab that held focus.
35
46
  */
36
- tabFocus: number;
37
- host: HTMLZNavigationTabsElement;
38
- private tabsNav;
47
+ private focusedTab;
48
+ /**
49
+ * Reference to the `<nav>` element
50
+ */
51
+ private nav;
39
52
  /**
40
53
  * Getter for the direction to check based on current orientation.
41
54
  */
@@ -44,47 +57,46 @@ export declare class ZNavigationTabs {
44
57
  * Getter for the dimension to check based on current orientation.
45
58
  */
46
59
  get dimension(): string;
47
- get tabs(): (HTMLZNavigationTabElement | HTMLZNavigationTabLinkElement)[];
60
+ get tabs(): HTMLElement[];
48
61
  /**
49
- * Set the `size` prop to all `z-navigation-tab` children.
62
+ * Scroll into view to center the tab.
50
63
  */
51
- setChildrenSize(): void;
64
+ private scrollToTab;
52
65
  /**
53
- * Set the `orientation` prop to all `z-navigation-tab` children.
66
+ * Scroll the navigation bar half of its size backward.
54
67
  */
55
- setChildrenOrientation(): void;
68
+ private navigateBackwards;
56
69
  /**
57
- * Check if the navigation buttons are needed on window resize.
70
+ * Scroll the navigation bar half of its size forward.
58
71
  */
59
- checkScrollVisible(): void;
72
+ private navigateForward;
73
+ /**
74
+ * Check if a keyboard event was triggered by an arrow key.
75
+ */
76
+ private isArrowNavigation;
60
77
  /**
61
78
  * Check if navigation buttons can be enabled for each direction.
62
79
  */
63
80
  checkScrollEnabled(): void;
64
81
  /**
65
- * Listen for child tab selection.
66
- * Deselect all other previously selected tabs,
67
- * then scroll to the new selected tab and center it.
68
- * @param {CustomEvent} event `selected` event triggered by a child tab
82
+ * When the selected tab changes, update the `aria-selected` attribute on each tab and scroll to the selected tab.
69
83
  */
70
- onTabSelected(event: CustomEvent): void;
84
+ onTabSelected(): void;
71
85
  /**
72
- * Scroll the navigation bar half of its size backward.
86
+ * Check if the navigation buttons are needed on window resize.
73
87
  */
74
- private navigateBackwards;
88
+ checkScrollVisible(): void;
75
89
  /**
76
- * Scroll the navigation bar half of its size forward.
90
+ * Handle click on the tabs.
91
+ * @param event `click` event triggered by a child tab
77
92
  */
78
- private navigateForward;
93
+ handleTabClick(event: MouseEvent): void;
79
94
  /**
80
- * Move focus through tabs using keyboard arrows.
81
- * When `TAB` is pressed, focus the currently selected tab, if any.
95
+ * Move focus through tabs when an arrow key is pressed.
96
+ * When `TAB` is pressed, focus the currently selected tab if any.
82
97
  */
83
98
  private navigateThroughTabs;
84
- /**
85
- * Check if a keyboard event was triggered by an arrow key.
86
- */
87
- private isArrowNavigation;
88
99
  componentDidRender(): void;
100
+ componentDidLoad(): void;
89
101
  render(): HTMLZNavigationTabsElement;
90
102
  }