@watermarkinsights/ripple 3.0.1 → 3.0.2-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/cjs/{global-ccb9500c.js → global-1e540de6.js} +1 -1
  2. package/dist/cjs/loader.cjs.js +2 -2
  3. package/dist/cjs/priv-datepicker.cjs.entry.js +1 -1
  4. package/dist/cjs/ripple.cjs.js +2 -2
  5. package/dist/cjs/wm-datepicker.cjs.entry.js +25 -30
  6. package/dist/collection/components/wm-datepicker/priv-datepicker/priv-datepicker.css +9 -0
  7. package/dist/collection/components/wm-datepicker/wm-datepicker.js +26 -32
  8. package/dist/esm/{global-4f914bb2.js → global-d6b49e98.js} +1 -1
  9. package/dist/esm/loader.js +2 -2
  10. package/dist/esm/priv-datepicker.entry.js +1 -1
  11. package/dist/esm/ripple.js +2 -2
  12. package/dist/esm/wm-datepicker.entry.js +25 -30
  13. package/dist/ripple/p-129d94fa.entry.js +1 -0
  14. package/dist/ripple/{p-454ad552.entry.js → p-c0fe5201.entry.js} +1 -1
  15. package/dist/ripple/{p-69a73e86.js → p-e3843249.js} +1 -1
  16. package/dist/ripple/ripple.esm.js +1 -1
  17. package/dist/types/components/wm-datepicker/wm-datepicker.d.ts +3 -3
  18. package/package.json +1 -1
  19. package/dist/cjs/app-globals-a07327ae.js +0 -47
  20. package/dist/cjs/css-shim-a7379e2b.js +0 -6
  21. package/dist/cjs/dom-3e7d9c3b.js +0 -75
  22. package/dist/cjs/functions-65513c61.js +0 -8360
  23. package/dist/cjs/global-06317e3f.js +0 -36
  24. package/dist/cjs/global-f6930bb0.js +0 -38
  25. package/dist/cjs/index-8dea8c13.js +0 -2976
  26. package/dist/cjs/shadow-css-09555044.js +0 -391
  27. package/dist/esm/app-globals-f62991a4.js +0 -45
  28. package/dist/esm/css-shim-bbdf0cc6.js +0 -4
  29. package/dist/esm/dom-1f98a75f.js +0 -73
  30. package/dist/esm/functions-316c1b23.js +0 -8340
  31. package/dist/esm/global-03372f70.js +0 -34
  32. package/dist/esm/global-fedbc323.js +0 -36
  33. package/dist/esm/index-e34aa595.js +0 -2938
  34. package/dist/esm/shadow-css-67b66845.js +0 -389
  35. package/dist/ripple/app-globals-b5693c90.js +0 -45
  36. package/dist/ripple/app-globals-d72c2d3c.js +0 -45
  37. package/dist/ripple/app-globals-f62991a4.js +0 -45
  38. package/dist/ripple/css-shim-bbdf0cc6.js +0 -4
  39. package/dist/ripple/dom-1f98a75f.js +0 -73
  40. package/dist/ripple/functions-316c1b23.js +0 -8340
  41. package/dist/ripple/http-service-5d037e16.js +0 -52
  42. package/dist/ripple/index-20b65f86.js +0 -2938
  43. package/dist/ripple/index-e34aa595.js +0 -2938
  44. package/dist/ripple/interfaces-50753346.js +0 -51
  45. package/dist/ripple/p-0c2498f4.js +0 -1
  46. package/dist/ripple/p-42ca2e15.entry.js +0 -1
  47. package/dist/ripple/p-e91befe3.js +0 -1
  48. package/dist/ripple/priv-chart-popover.entry.js +0 -85
  49. package/dist/ripple/priv-datepicker.entry.js +0 -668
  50. package/dist/ripple/priv-navigator-button.entry.js +0 -25
  51. package/dist/ripple/priv-navigator-item.entry.js +0 -30
  52. package/dist/ripple/ripple.css +0 -84
  53. package/dist/ripple/shadow-css-67b66845.js +0 -389
  54. package/dist/ripple/wm-action-menu.entry.js +0 -202
  55. package/dist/ripple/wm-button.entry.js +0 -148
  56. package/dist/ripple/wm-chart-slice.entry.js +0 -18
  57. package/dist/ripple/wm-chart.entry.js +0 -504
  58. package/dist/ripple/wm-datepicker.entry.js +0 -258
  59. package/dist/ripple/wm-input.entry.js +0 -106
  60. package/dist/ripple/wm-menuitem.entry.js +0 -114
  61. package/dist/ripple/wm-modal-footer.entry.js +0 -39
  62. package/dist/ripple/wm-modal-header.entry.js +0 -41
  63. package/dist/ripple/wm-modal.entry.js +0 -145
  64. package/dist/ripple/wm-navigator.entry.js +0 -275
  65. package/dist/ripple/wm-network-uploader.entry.js +0 -427
  66. package/dist/ripple/wm-option.entry.js +0 -119
  67. package/dist/ripple/wm-pagination.entry.js +0 -172
  68. package/dist/ripple/wm-search.entry.js +0 -227
  69. package/dist/ripple/wm-select.entry.js +0 -362
  70. package/dist/ripple/wm-snackbar.entry.js +0 -156
  71. package/dist/ripple/wm-tab-item.entry.js +0 -78
  72. package/dist/ripple/wm-tab-list.entry.js +0 -201
  73. package/dist/ripple/wm-tab-panel.entry.js +0 -38
  74. package/dist/ripple/wm-tag-input.entry.js +0 -534
  75. package/dist/ripple/wm-timepicker.entry.js +0 -382
  76. package/dist/ripple/wm-toggletip.entry.js +0 -124
  77. package/dist/ripple/wm-uploader.entry.js +0 -338
  78. package/dist/ripple/wm-wrapper.entry.js +0 -17
  79. package/dist/types/components/wm-tag-input/wm-tag-input.d.ts~ds312_tagInputMaxTags +0 -87
  80. package/dist/types/components.d.ts~ds312_tagInputMaxTags +0 -879
  81. package/dist/types/stencil-public-runtime.d.ts~ds312_tagInputMaxTags +0 -1555
@@ -1,362 +0,0 @@
1
- import { r as registerInstance, e as createEvent, i as forceUpdate, h, g as getElement } from './index-e34aa595.js';
2
- import { i as intl, g as generateId, a as shouldOpenUp, b as getTextDir } from './functions-316c1b23.js';
3
-
4
- const wmSelectCss = "@charset \"UTF-8\";:host{position:relative;display:block;box-sizing:border-box;font-family:inherit}:host .sr-only{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;border:0 !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;clip-path:inset(50%) !important;white-space:nowrap !important;margin:-1px !important}.wrapper{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;flex-direction:column;font-size:0.875rem}.wrapper .label{display:block;line-height:normal;font-weight:600;white-space:nowrap;margin-bottom:0.25rem}.wrapper .label .required{color:#c0392b}.wrapper.label-left{flex-direction:row}.wrapper.label-left .label-wrapper{line-height:2.5rem}.wrapper.label-left .label-wrapper .label{display:flex;align-items:center;min-height:2.5rem;white-space:normal;margin-bottom:0;margin-right:0.75rem}.wrapper.label-none label{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;border:0 !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;clip-path:inset(50%) !important;white-space:nowrap !important;margin:-1px !important}.wrapper.invalid .label{color:#c0392b}.wrapper.invalid .label:after{display:inline-block;font:normal normal normal 24px/1 \"Material Design Icons\";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:\"\";margin-left:0.3125rem}[dir=RTL] .wrapper.invalid .label:after{margin-left:0;margin-right:0.3125rem}.wrapper.rtl.label-left .label{margin-right:0;margin-left:0.75rem}.wrapper .dropdown{position:relative;font-size:1.125rem;color:#575195;min-width:8.75rem}.wrapper .dropdown .displayedoption{-webkit-border-radius:3px;-moz-border-radius:3px;-ms-border-radius:3px;border-radius:3px;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;display:flex;align-items:center;flex-wrap:nowrap;background:transparent;width:100%;border:solid 1px rgba(35, 35, 35, 0.6);padding:0 1.875rem 0 0.9375rem;cursor:pointer;height:2.5rem;line-height:normal;font-family:inherit;color:#575195;font-weight:400;font-size:0.875rem;text-transform:none;text-align:left}@media only screen and (max-width: 768px){.wrapper .dropdown .displayedoption{height:2.75rem}}.wrapper .dropdown .displayedoption:before{display:inline-block;font:normal normal normal 24px/1 \"Material Design Icons\";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:\"\";position:absolute;right:0.5625rem;pointer-events:none}.wrapper .dropdown .displayedoption:hover:not(:disabled):not(.-disabled):not(.-raised){background:transparent;text-decoration:none}.wrapper .dropdown .displayedoption:active{-ms-transform:scale(1, 1) !important;transform:scale(1, 1) !important}.wrapper .dropdown .displayedoption:focus{outline:none}.wrapper .dropdown .displayedoption::-moz-focus-inner{border:0}.wrapper .dropdown .displayedoption.user-is-tabbing:focus{-webkit-box-shadow:0 2px 2px 0 rgba(244, 243, 246, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.1), 0 0 4px 3px #61279e;-moz-box-shadow:0 2px 2px 0 rgba(244, 243, 246, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.1), 0 0 4px 3px #61279e;box-shadow:0 2px 2px 0 rgba(244, 243, 246, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.1), 0 0 4px 3px #61279e}.wrapper .dropdown .displayedoption.user-is-tabbing:focus::-moz-focus-inner{border:0}.wrapper .dropdown .displayedoption .overflowcontrol{display:block;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;flex:1}.wrapper .dropdown .displayedoption .overflowcontrol.hassubinfo{display:flex}.wrapper .dropdown .displayedoption .overflowcontrol.hassubinfo .button-text{flex:1;text-overflow:ellipsis;overflow:hidden;min-width:0}.wrapper .dropdown .displayedoption .overflowcontrol.hassubinfo .subinfo{flex:none;font-style:italic}.wrapper .dropdown .displayedoption .overflow-counter{font-weight:bold;margin-left:0.5rem}.wrapper .dropdown>.displayedoption[disabled]{color:#6b6b6b;border-color:#8a8a8a;background:#f0f0f0;cursor:default}.wrapper .dropdown>.options{-webkit-overflow-scrolling:touch;overflow:auto;max-height:12.5rem;-webkit-box-shadow:0 4px 15px 0 rgba(0, 0, 0, 0.2);-moz-box-shadow:0 4px 15px 0 rgba(0, 0, 0, 0.2);box-shadow:0 4px 15px 0 rgba(0, 0, 0, 0.2);-ms-transition:transform 0.25s ease;-webkit-transition:transform 0.25s ease;-moz-transition:transform 0.25s ease;transition:transform 0.25s ease;-ms-transform:scale(1, 0);-webkit-transform:scale(1, 0);-moz-transform:scale(1, 0);transform:scale(1, 0);-ms-transform-origin:center top;-webkit-transform-origin:center top;-moz-transform-origin:center top;transform-origin:center top;-webkit-border-radius:3px;-moz-border-radius:3px;-ms-border-radius:3px;border-radius:3px;position:absolute;top:0;right:0;background:#fff;z-index:100;width:100%;font-size:0.875rem}.wrapper .dropdown>.options.upwards{top:unset;bottom:calc(100% - 2.5rem);-ms-transform-origin:center bottom;-webkit-transform-origin:center bottom;-moz-transform-origin:center bottom;transform-origin:center bottom}.wrapper .dropdown>.options.hidden{visibility:hidden}.wrapper .dropdown>.options.open{-ms-transform:scale(1, 1);-webkit-transform:scale(1, 1);-moz-transform:scale(1, 1);transform:scale(1, 1)}.wrapper.invalid .dropdown .displayedoption{-webkit-box-shadow:0 0 0 1px #c0392b;-moz-box-shadow:0 0 0 1px #c0392b;box-shadow:0 0 0 1px #c0392b;border-color:#c0392b}.wrapper .error-message{color:#c0392b;font-size:0.875rem;margin-top:0.25rem;margin-bottom:0.25rem;display:block;top:100%;left:0;font-style:italic}.rtl>.options{-ms-transform-origin:left top;-webkit-transform-origin:left top;-moz-transform-origin:left top;transform-origin:left top;left:0;right:auto}.rtl>.options .option{padding-left:3rem;padding-right:1.25rem}.rtl>.displayedoption{padding:0 0.9375rem 0 1.875rem;text-align:right}.rtl>.displayedoption:before{right:auto;left:0.5625rem}";
5
-
6
- const Select = class {
7
- constructor(hostRef) {
8
- registerInstance(this, hostRef);
9
- this.wmSelectDidLoad = createEvent(this, "wmSelectDidLoad", 7);
10
- this.wmComponentBlurred = createEvent(this, "wmComponentBlurred", 7);
11
- this.disabled = false;
12
- this.invalid = false;
13
- this.labelPosition = "top";
14
- this.requiredField = false;
15
- this.errorMessage = "";
16
- this.multiple = false;
17
- this.placeholder = intl.formatMessage({
18
- id: "select.multiPlaceholder",
19
- defaultMessage: "Make a selection",
20
- });
21
- this.allSelectedMessage = intl.formatMessage({
22
- id: "select.allSelected",
23
- defaultMessage: "All selected",
24
- });
25
- this.requiredMessage = intl.formatMessage({
26
- id: "global.requiredField",
27
- defaultMessage: "required field",
28
- });
29
- this.isTabbing = false;
30
- this.isExpanded = false;
31
- this.keysSoFar = "";
32
- this.searchIndex = 0;
33
- this.keyClear = null;
34
- this.openUp = false;
35
- // for multiselect button text
36
- this.overflowCount = 0;
37
- this.displayedItems = [];
38
- this.allSelected = false;
39
- }
40
- get childItems() {
41
- return Array.from(this.el.querySelectorAll("wm-option"));
42
- }
43
- get selectedItems() {
44
- return Array.from(this.el.querySelectorAll("wm-option")).filter((x) => x.selected);
45
- }
46
- toggleTabbingOn() {
47
- this.isTabbing = true;
48
- }
49
- toggleTabbingOff() {
50
- this.isTabbing = false;
51
- }
52
- handleOptionSelection(ev) {
53
- if (!this.multiple) {
54
- // ensure only one option is selected at a time
55
- this.childItems
56
- // remove selected on any other option
57
- .filter((option) => option != ev.target && !!option.selected)
58
- .map((option) => (option.selected = false));
59
- }
60
- this.focusItem(ev.target);
61
- this.selectItem(ev.target);
62
- if (!this.multiple) {
63
- this.close();
64
- }
65
- }
66
- handeChildEnter() {
67
- // only occurs for multiselects. handle the click, then close
68
- this.close();
69
- }
70
- handleChildUp(ev) {
71
- this.moveUp(ev.target);
72
- }
73
- handleChildDown(ev) {
74
- this.moveDown(ev.target);
75
- }
76
- moveToFirstItem() {
77
- this.focusItem(this.childItems[0]);
78
- }
79
- moveToLastItem() {
80
- this.focusItem(this.childItems[this.childItems.length - 1]);
81
- }
82
- handleTabKey() {
83
- this.close(false);
84
- }
85
- closePopupOnEscape() {
86
- this.close();
87
- }
88
- blurHandler(ev) {
89
- const isElOrChild = ev.target === this.el || this.el.contains(ev.target);
90
- if (!isElOrChild && this.isExpanded) {
91
- this.close();
92
- }
93
- }
94
- handleKey(ev) {
95
- switch (ev.keyCode) {
96
- // Arrow down
97
- case 40:
98
- if (this.isExpanded === false) {
99
- ev.preventDefault();
100
- this.open("next");
101
- }
102
- break;
103
- // Arrow up
104
- case 38:
105
- if (this.isExpanded === false) {
106
- ev.preventDefault();
107
- this.open("previous");
108
- }
109
- break;
110
- }
111
- }
112
- componentWillLoad() {
113
- if (!this.label) {
114
- console.error("For accessibility purposes, this component requires a label (even if `label-position` is set to `none`).");
115
- }
116
- this.el.focus = function () {
117
- if (!this.disabled) {
118
- this.shadowRoot.querySelector("button").focus();
119
- }
120
- };
121
- this.uid = this.el.id ? this.el.id : generateId();
122
- if (document.body.classList.contains("wmcl-user-is-tabbing")) {
123
- this.toggleTabbingOn();
124
- }
125
- }
126
- componentDidLoad() {
127
- this.wmSelectDidLoad.emit();
128
- if (!this.childItems.length) {
129
- throw new Error("wm-select should have wm-option elements as children.");
130
- }
131
- if (this.multiple && this.childItems.filter((x) => x.subinfo).length > 0) {
132
- throw new Error("wm-select with the multiple prop cannot have subinfo options");
133
- }
134
- if (this.multiple && !this.placeholder) {
135
- throw new Error("wm-select with the multiple prop needs to also use the placeholder prop.");
136
- }
137
- // set initial selections / button text
138
- if (this.selectedItems.length > 0) {
139
- this.selectedItems.forEach((x) => this.displayedItems.push(x));
140
- this.setButtonText();
141
- // single Select only, pre-select if no default option from dev
142
- }
143
- else if (!this.multiple) {
144
- this.selectItem(this.childItems[0]);
145
- }
146
- this.optionsEl.classList.add("hidden");
147
- forceUpdate(this.el);
148
- // Dev can overwrite the max-height rule set in the Sass file
149
- if (this.maxHeight) {
150
- this.optionsEl.style.maxHeight = this.maxHeight;
151
- }
152
- }
153
- moveUp(el) {
154
- const prevEl = el.previousElementSibling;
155
- if (prevEl) {
156
- // scroll option to top of dropdown if partially obscured / out of view
157
- if (prevEl.getBoundingClientRect().top < this.optionsEl.getBoundingClientRect().top) {
158
- this.optionsEl.scrollTop =
159
- prevEl.getBoundingClientRect().top - this.optionsEl.getBoundingClientRect().top + this.optionsEl.scrollTop;
160
- }
161
- this.focusItem(prevEl);
162
- }
163
- else {
164
- this.focusItem(this.childItems[this.childItems.length - 1]);
165
- }
166
- }
167
- moveDown(el) {
168
- const nextEl = el.nextElementSibling;
169
- if (nextEl && nextEl.tagName !== "INPUT") {
170
- // scroll option to bottom of dropdown if partially obscured / out of view
171
- if (nextEl.getBoundingClientRect().bottom > this.optionsEl.getBoundingClientRect().bottom) {
172
- this.optionsEl.scrollTop =
173
- nextEl.getBoundingClientRect().bottom -
174
- this.optionsEl.getBoundingClientRect().top +
175
- this.optionsEl.scrollTop -
176
- this.optionsEl.offsetHeight;
177
- }
178
- this.focusItem(nextEl);
179
- }
180
- else {
181
- this.focusItem(this.childItems[0]);
182
- }
183
- }
184
- open(itemToSelect) {
185
- if (!this.disabled) {
186
- const elHeight = this.el.clientHeight;
187
- const buttonHeight = this.buttonEl.clientHeight;
188
- this.openUp = shouldOpenUp(this.el, this.optionsEl,
189
- // when opening up, dropdown covers both label and button
190
- elHeight,
191
- // when opening down, dropdown covers only the button
192
- buttonHeight);
193
- this.isExpanded = true;
194
- this.optionsEl.classList.remove("hidden");
195
- window.requestAnimationFrame(() => {
196
- if (this.selectedItems.length > 0) {
197
- if (itemToSelect === "next") {
198
- this.moveDown(this.selectedItems[this.selectedItems.length - 1]);
199
- }
200
- else if (itemToSelect === "previous") {
201
- this.moveUp(this.selectedItems[0]);
202
- }
203
- else {
204
- this.focusItem(this.selectedItems[0]);
205
- }
206
- }
207
- else {
208
- this.focusItem(this.childItems[0]);
209
- }
210
- });
211
- }
212
- }
213
- close(returnFocus = true) {
214
- this.isExpanded = false;
215
- this.childItems.map((i) => (i.focused = false));
216
- window.setTimeout(() => {
217
- this.optionsEl.classList.add("hidden");
218
- // Returns focus to button after popup closes (no need if user is tabbing)
219
- // Delay is necessary for screenreader to get new expanded state before focus
220
- // window.requestAnimationFrame is probably enough, but since we are already using setTimeout it may as well be here
221
- // also UX wise, it makes sense for the button to only be focused after the animation is complete
222
- if (returnFocus) {
223
- this.el.focus();
224
- }
225
- }, 150);
226
- }
227
- focusItem(item) {
228
- this.childItems.forEach((i) => (i.focused = i === item));
229
- }
230
- selectItem(item) {
231
- if (this.multiple) {
232
- item.selected = !item.selected;
233
- }
234
- else {
235
- this.childItems.forEach((i) => (i.selected = i === item));
236
- }
237
- this.setButtonText();
238
- }
239
- findAndFocusItem(ev) {
240
- const character = ev.detail.toUpperCase();
241
- if (!this.keysSoFar) {
242
- for (var i = 0; i < this.childItems.length; i++) {
243
- if (this.childItems[i].focused) {
244
- this.searchIndex = i;
245
- }
246
- }
247
- }
248
- this.keysSoFar += character;
249
- this.clearKeysSoFarAfterDelay();
250
- var nextMatch = this.findMatchInRange(this.childItems, this.searchIndex + 1, this.childItems.length);
251
- if (!nextMatch) {
252
- nextMatch = this.findMatchInRange(this.childItems, 0, this.searchIndex);
253
- }
254
- if (nextMatch) {
255
- this.focusItem(nextMatch);
256
- }
257
- }
258
- clearKeysSoFarAfterDelay() {
259
- if (this.keyClear) {
260
- window.clearTimeout(this.keyClear);
261
- this.keyClear = null;
262
- }
263
- this.keyClear = window.setTimeout(function () {
264
- this.keysSoFar = "";
265
- this.keyClear = null;
266
- }.bind(this), 500);
267
- }
268
- findMatchInRange(list, startIndex, endIndex) {
269
- // Find the first item starting with the keysSoFar substring, searching in
270
- // the specified range of items
271
- for (var n = startIndex; n < endIndex; n++) {
272
- var label = list[n].textContent;
273
- if (label && label.toUpperCase().indexOf(this.keysSoFar) === 0) {
274
- return list[n];
275
- }
276
- }
277
- return null;
278
- }
279
- exposeErrors() {
280
- // When the error changes, a new id is set for the error container and the button's aria-describedby attribute is updated accordingly. This is to make sure the screen reader announces teh updated errors in Firefox. See this longstanding bug: https://bugzilla.mozilla.org/show_bug.cgi?id=493683
281
- const newId = generateId();
282
- this.errorContainer.id = `wm-errors-${newId}`;
283
- this.buttonEl.setAttribute("aria-describedby", `wm-errors-${newId}`);
284
- }
285
- renderErrorContainer() {
286
- return (h("div", { id: "wm-errors", class: this.errorMessage ? "error-message" : "", ref: (el) => (this.errorContainer = el), "aria-live": "assertive", "aria-atomic": "true" }, this.errorMessage));
287
- }
288
- handleComponentBlur() {
289
- if (!this.isExpanded) {
290
- this.wmComponentBlurred.emit();
291
- }
292
- }
293
- setButtonText() {
294
- this.displayedItems = this.childItems.filter((x) => x.selected);
295
- this.allSelected = this.displayedItems.length === this.childItems.length;
296
- // handle overflow + counter for multiselect
297
- if (this.multiple) {
298
- // this is a fixed measurement accounting for the max width of a 3 character overflow counter
299
- const overflowCounterWidth = 38;
300
- const computedStyle = window.getComputedStyle(this.buttonEl);
301
- // there seems to be no quick way to get an elements width without padding, except for subtracting padding manually
302
- const paddingLeft = parseInt(computedStyle.getPropertyValue("padding-left").slice(0, -2));
303
- const paddingRight = parseInt(computedStyle.getPropertyValue("padding-right").slice(0, -2));
304
- const availableSpace = this.buttonEl.clientWidth - paddingLeft - paddingRight - overflowCounterWidth;
305
- let optionsWidths = this.displayedItems.map((x) => x.shadowRoot.querySelector(".option-wrapper").clientWidth);
306
- let optionsTotalWidth = optionsWidths.reduce((acc, x) => acc + x, 0);
307
- this.overflowCount = 0;
308
- while (optionsTotalWidth > availableSpace && this.displayedItems.length > 1) {
309
- this.overflowCount++;
310
- optionsTotalWidth -= optionsWidths[optionsWidths.length - 1];
311
- optionsWidths.pop();
312
- this.displayedItems.pop();
313
- }
314
- }
315
- }
316
- renderButtonText() {
317
- if (this.multiple && this.displayedItems.length < 1) {
318
- return h("span", null, this.placeholder);
319
- }
320
- else if (this.multiple && this.allSelected && this.overflowCount > 0) {
321
- return this.allSelectedMessage;
322
- }
323
- else {
324
- return this.displayedItems.map((x, idx) => (h("span", null, idx > 0 ? ", " : "", x.textContent)));
325
- }
326
- }
327
- renderSubinfo() {
328
- // multiselects cannot have subinfo for options
329
- if (!this.multiple && this.selectedItems.length > 0 && this.selectedItems[0].subinfo) {
330
- return h("span", { class: "subinfo" }, this.selectedItems[0].subinfo);
331
- }
332
- }
333
- renderOverflowCount() {
334
- if (this.overflowCount > 0 && !this.allSelected) {
335
- return (h("span", null, h("span", { class: "overflow-counter" }, "+", this.overflowCount)));
336
- }
337
- }
338
- render() {
339
- const buttonProps = {
340
- id: `selectbtn-${this.uid}`,
341
- ["disabled"]: this.disabled,
342
- ["aria-controls"]: `list-${this.uid}`,
343
- ["aria-labelledby"]: `label-${this.uid} selectbtn-${this.uid}`,
344
- ["aria-describedby"]: "wm-errors",
345
- ["aria-expanded"]: this.isExpanded ? "true" : "false",
346
- onClick: () => (this.isExpanded ? this.close() : this.open()),
347
- onBlur: () => this.handleComponentBlur(),
348
- };
349
- return (h("div", { class: `wrapper ${getTextDir()} label-${this.labelPosition} ${this.invalid || this.errorMessage ? "invalid" : ""}` }, h("div", { class: "label-wrapper" }, h("label", { class: "label", id: `label-${this.uid}`, htmlFor: `selectbtn-${this.uid}` }, this.label,
350
- // we can't use aria-required or required attributes because it's invalid on the elements we're using (button controlling a listbox)
351
- this.requiredField ? (h("span", { class: "required" }, h("span", { class: "sr-only" }, this.requiredMessage), h("span", { "aria-hidden": "true" }, "*"))) : (""))), h("div", { class: "dropdown" }, h("button", Object.assign({}, buttonProps, { class: `displayedoption ${this.isTabbing ? "user-is-tabbing" : ""}`, ref: (el) => (this.buttonEl = el) }), h("span", { class: this.selectedItems.length > 0 && this.selectedItems.filter((x) => x.subinfo).length > 0
352
- ? "overflowcontrol hassubinfo"
353
- : "overflowcontrol" }, h("span", { class: "button-text" }, this.renderButtonText()), this.renderSubinfo()), this.renderOverflowCount()), h("div", { class: `options ${this.isExpanded ? "open" : ""} ${this.openUp ? "upwards" : ""}`, id: `list-${this.uid}`, tabindex: -1, role: "listbox", "aria-multiselectable": this.multiple ? "true" : null, "aria-labelledby": `label-${this.uid}`, ref: (el) => (this.optionsEl = el) }, h("slot", null)), this.renderErrorContainer())));
354
- }
355
- get el() { return getElement(this); }
356
- static get watchers() { return {
357
- "errorMessage": ["exposeErrors"]
358
- }; }
359
- };
360
- Select.style = wmSelectCss;
361
-
362
- export { Select as wm_select };
@@ -1,156 +0,0 @@
1
- import { r as registerInstance, e as createEvent, h, g as getElement } from './index-e34aa595.js';
2
- import { g as generateId } from './functions-316c1b23.js';
3
-
4
- const wmSnackbarCss = "@charset \"UTF-8\";.user-is-tabbing .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack:focus:not(:active){-webkit-box-shadow:0 2px 2px 0 rgba(244, 243, 246, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.1), 0 0 4px 3px #c6b4e3;-moz-box-shadow:0 2px 2px 0 rgba(244, 243, 246, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.1), 0 0 4px 3px #c6b4e3;box-shadow:0 2px 2px 0 rgba(244, 243, 246, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.1), 0 0 4px 3px #c6b4e3;outline:none}:host *,wm-snackbar *{box-sizing:border-box;margin:unset}:host .wm-snackbars,wm-snackbar .wm-snackbars{position:fixed;bottom:0;left:1.25rem;right:1.25rem;padding:0.25rem 0.625rem 1.875rem;z-index:2001;max-width:35.5rem;max-height:17.5rem;-webkit-overflow-scrolling:touch;overflow:auto}:host .wm-snackbars.empty,wm-snackbar .wm-snackbars.empty{-ms-transition:all 0.25s 0ms cubic-bezier(0.4, 0, 1, 1);-webkit-transition:all 0.25s 0ms cubic-bezier(0.4, 0, 1, 1);-moz-transition:all 0.25s 0ms cubic-bezier(0.4, 0, 1, 1);transition:all 0.25s 0ms cubic-bezier(0.4, 0, 1, 1);padding-top:0;padding-bottom:0}:host .wm-snackbars .wm-snack-wrapper,wm-snackbar .wm-snackbars .wm-snack-wrapper{width:100%;height:100%}:host .wm-snackbars .wm-snack-wrapper:not(:last-child),wm-snackbar .wm-snackbars .wm-snack-wrapper:not(:last-child){margin-bottom:1.25rem}:host .wm-snackbars .wm-snack-wrapper .wm-snackbar,wm-snackbar .wm-snackbars .wm-snack-wrapper .wm-snackbar{-webkit-box-shadow:0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 3px rgba(0, 0, 0, 0.12), 0 4px 15px 0 rgba(0, 0, 0, 0.2);-moz-box-shadow:0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 3px rgba(0, 0, 0, 0.12), 0 4px 15px 0 rgba(0, 0, 0, 0.2);box-shadow:0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 3px rgba(0, 0, 0, 0.12), 0 4px 15px 0 rgba(0, 0, 0, 0.2);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;-ms-transition:all 0.25s 0ms cubic-bezier(0.4, 0, 1, 1);-webkit-transition:all 0.25s 0ms cubic-bezier(0.4, 0, 1, 1);-moz-transition:all 0.25s 0ms cubic-bezier(0.4, 0, 1, 1);transition:all 0.25s 0ms cubic-bezier(0.4, 0, 1, 1);font-size:0.875rem;color:#fff;padding:0.9375rem 1.875rem;background:#4a4a4a;opacity:0;left:0;position:relative;font-family:inherit}:host .wm-snackbars .wm-snack-wrapper .wm-snackbar .link,wm-snackbar .wm-snackbars .wm-snack-wrapper .wm-snackbar .link{letter-spacing:0;text-transform:none;font-size:0.875rem;border:none;background:transparent;padding-left:0;padding-right:0;height:auto;border-radius:0;line-height:1;color:#85dadf;margin:0 3.125rem 0 0.625rem;text-decoration:none;font-weight:600}:host .wm-snackbars .wm-snack-wrapper .wm-snackbar .link:hover,wm-snackbar .wm-snackbars .wm-snack-wrapper .wm-snackbar .link:hover{text-decoration:underline}:host .wm-snackbars .wm-snack-wrapper .wm-snackbar .link:focus,wm-snackbar .wm-snackbars .wm-snack-wrapper .wm-snackbar .link:focus{outline:none;border:none}:host .wm-snackbars .wm-snack-wrapper .wm-snackbar .link::-moz-focus-inner,wm-snackbar .wm-snackbars .wm-snack-wrapper .wm-snackbar .link::-moz-focus-inner{border:0;outline:none}:host .wm-snackbars .wm-snack-wrapper .wm-snackbar:not(:last-child),wm-snackbar .wm-snackbars .wm-snack-wrapper .wm-snackbar:not(:last-child){margin-bottom:1.25rem}:host .wm-snackbars .wm-snack-wrapper .wm-snackbar.active:not(button),wm-snackbar .wm-snackbars .wm-snack-wrapper .wm-snackbar.active:not(button){opacity:1}:host .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg,wm-snackbar .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-ms-flex-pack:justify;-webkit-justify-content:space-between;justify-content:space-between;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;width:100%;position:relative;padding:0}:host .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .msgtext,wm-snackbar .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .msgtext{width:100%}:host .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack,wm-snackbar .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack{-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;-webkit-border-radius:50%;-moz-border-radius:50%;-ms-border-radius:50%;border-radius:50%;background-color:#3b3b3b;color:#ffffff;cursor:pointer;border:none;font-size:1rem;padding:0;height:auto;line-height:1;min-width:2.75rem;min-height:2.75rem;text-align:center;letter-spacing:normal}@media screen and (min-width: 48rem){:host .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack,wm-snackbar .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack{min-width:1.875rem;min-height:1.875rem}}:host .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack:before,wm-snackbar .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack:before{display:inline-block;font:normal normal normal 24px/1 \"Material Design Icons\";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:\"\"}:host .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack:hover,wm-snackbar .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack:hover{background-color:#fff;color:#4a4a4a}:host .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack:focus,wm-snackbar .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack:focus{outline:none}:host .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack::-moz-focus-inner,wm-snackbar .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack::-moz-focus-inner{border:0;outline:none}:host .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack:active,wm-snackbar .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack:active{-ms-transform:scale(0.9, 0.9);-webkit-transform:scale(0.9, 0.9);-moz-transform:scale(0.9, 0.9);transform:scale(0.9, 0.9)}:host .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack>.tooltip,wm-snackbar .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack>.tooltip{position:absolute;opacity:0;width:1px;height:1px;overflow:hidden;clip:rect(0, 0, 0, 0);font-size:0.875rem;text-transform:none;font-weight:normal;background:black;color:#fff;padding:0;line-height:normal;z-index:30}:host .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack:hover>.tooltip,:host .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack.user-is-tabbing:focus>.tooltip,wm-snackbar .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack:hover>.tooltip,wm-snackbar .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack.user-is-tabbing:focus>.tooltip{clip:auto;width:auto;height:auto;opacity:1;transition:opacity 500ms 500ms;padding:0.375rem;top:2.75rem;left:2.75rem;white-space:nowrap;transform:translateX(-50%)}@media screen and (min-width: 48rem){:host .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack:hover>.tooltip,:host .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack.user-is-tabbing:focus>.tooltip,wm-snackbar .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack:hover>.tooltip,wm-snackbar .wm-snackbars .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack.user-is-tabbing:focus>.tooltip{top:2.0625rem;left:auto}}:host .wm-snackbars .wm-snack-wrapper .wm-snackbar .sr-only,wm-snackbar .wm-snackbars .wm-snack-wrapper .wm-snackbar .sr-only{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;border:0 !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;clip-path:inset(50%) !important;white-space:nowrap !important;margin:-1px !important;top:0;left:0}:host .sr-only,wm-snackbar .sr-only{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;border:0 !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;clip-path:inset(50%) !important;white-space:nowrap !important;margin:-1px !important;top:0;left:0}.user-is-tabbing .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack:focus:not(:active)>.tooltip{clip:auto;width:auto;height:auto;opacity:1;transition:opacity 500ms 500ms;padding:0.375rem;top:2.75rem;left:2.75rem;white-space:nowrap;transform:translateX(-50%)}@media screen and (min-width: 48rem){.user-is-tabbing .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .closesnack:focus:not(:active)>.tooltip{top:2.0625rem;left:auto}}.user-is-tabbing .wm-snack-wrapper .wm-snackbar .wm-snackbarmsg .link:focus:not(:active){outline:none;background:linear-gradient(90deg, #85dadf 66%, transparent 0) repeat-x;background-size:0.375rem 0.1875rem;background-position:0 1em;border-radius:0;line-height:normal}";
5
-
6
- const Snackbar = class {
7
- constructor(hostRef) {
8
- registerInstance(this, hostRef);
9
- this.userFinishedSnack = createEvent(this, "userFinishedSnack", 7);
10
- this.userTriggeredAction = createEvent(this, "userTriggeredAction", 7);
11
- //Prop receives notifications as JSON string, which is later parsed into an array of objects.
12
- this.notifications = "[]";
13
- this.parsedNotifications = []; //Holds the parsed array
14
- this.isTabbing = false; //For screenreader purposes, to ensure link receives focus even after screenreader interprets "enter" as a "click"
15
- this.timers = [];
16
- this.newNotification = false;
17
- }
18
- updateSnacks(newValue) {
19
- const parsedData = JSON.parse(newValue);
20
- const length = parsedData.length;
21
- const prevNotificationsLength = this.parsedNotifications.length;
22
- this.parsedNotifications = [];
23
- //Parse notifications received as props and store a reference to them
24
- for (let i = 0; i < length; i++) {
25
- let newNotification = {
26
- id: parsedData[i].id.toString(),
27
- message: parsedData[i].message.toString(),
28
- link: parsedData[i].link.toString(),
29
- };
30
- this.parsedNotifications = [...this.parsedNotifications, newNotification];
31
- }
32
- //If a new notification was added, set a timer and store a reference to the current active element so that if focus must move to the notification, it can return the user where they were once they dismiss the notification.
33
- if (prevNotificationsLength < this.parsedNotifications.length) {
34
- const newTimer = window.setTimeout(() => this.snackExpired(), 20000);
35
- this.timers = [newTimer, ...this.timers];
36
- this.storeElToFocusOnDismiss();
37
- this.newNotification = true;
38
- }
39
- else {
40
- this.newNotification = false;
41
- }
42
- }
43
- componentWillLoad() {
44
- this.uid = this.el.id ? this.el.id : generateId();
45
- }
46
- //A change in the notificaiton prop will trigger the update function. The update's only role is to determine how focus should be managed when a notification is added.
47
- componentDidUpdate() {
48
- //If the user is tabbing and there's a new notification, focus the link and disable timer.
49
- this.isTabbing && this.newNotification && this.focusLinkAndDisableTimer();
50
- this.newNotification = false;
51
- }
52
- checkForTabbing(ev) {
53
- if (ev.keyCode === 9) {
54
- this.toggleTabbingOn();
55
- }
56
- }
57
- //Workaround for screenreader's triggering click event on "enter".
58
- handleMouse() {
59
- this.toggleTabbingOff();
60
- }
61
- focusLinkAndDisableTimer() {
62
- //If the new notification has a link, focus the link and clear the timeout. This is for accessibility purposes, for keyboard/screenreader users.
63
- const latestNotification = this.parsedNotifications[0];
64
- if (latestNotification.link) {
65
- let link = this.el.shadowRoot.querySelector(`#action-${latestNotification.id}`);
66
- link.focus();
67
- this.stopTimer(latestNotification);
68
- }
69
- }
70
- toggleTabbingOn() {
71
- this.isTabbing = true;
72
- this.snackbarEl && this.snackbarEl.classList.add("user-is-tabbing");
73
- }
74
- toggleTabbingOff() {
75
- this.isTabbing = false;
76
- this.snackbarEl && this.snackbarEl.classList.remove("user-is-tabbing");
77
- }
78
- storeElToFocusOnDismiss() {
79
- let triggeringButton = document.activeElement;
80
- while (triggeringButton && triggeringButton.shadowRoot) {
81
- triggeringButton = triggeringButton.shadowRoot.activeElement;
82
- }
83
- this.focusOnDismiss = triggeringButton;
84
- }
85
- snackDismissed(notification) {
86
- this.endSnack(notification);
87
- //Focus should only be returned if it was moved in the first place, i.e., there was a link and the user was tabbing. Otherwise, for a mouse user, the user's focus would jump back to the triggering element.
88
- notification.link && this.isTabbing && this.focusOnDismiss.focus();
89
- }
90
- //Remove snack from notification list once timer runs out
91
- snackExpired() {
92
- const notification = this.parsedNotifications[this.parsedNotifications.length - 1];
93
- this.endSnack(notification);
94
- }
95
- endSnack(notification) {
96
- //App listens for userFinishedSnack event and deletes the emitted notification.
97
- this.stopTimer(notification);
98
- this.userFinishedSnack.emit({
99
- id: notification.id,
100
- message: notification.message,
101
- link: notification.link,
102
- });
103
- }
104
- snackLinkClicked(notification) {
105
- //App listens for userTriggeredAction event, deletes emitted notification, and takes over focus.
106
- this.stopTimer(notification);
107
- this.userTriggeredAction.emit({
108
- id: notification.id,
109
- message: notification.message,
110
- link: notification.link,
111
- });
112
- }
113
- //Delete the timer corresponding to the dismissed notification
114
- stopTimer(notification) {
115
- this.parsedNotifications.forEach((notif, index) => {
116
- if (notif.id === notification.id) {
117
- clearTimeout(this.timers[index]);
118
- this.timers = this.timers.filter((timer, ind) => {
119
- if (ind !== index) {
120
- return timer;
121
- }
122
- });
123
- }
124
- });
125
- }
126
- renderSnackbars() {
127
- return this.parsedNotifications.map((notification) => (h("div", { class: "wm-snack-wrapper" }, h("div", { id: `snack-${this.uid}`, class: "wm-snackbar active neutral" }, h("div", { class: "sr-only", tabindex: notification.link ? 0 : -1, onFocus: () => notification.link && this.snackDismissed(notification) }), h("div", { class: "wm-snackbarmsg" }, h("div", { class: "msgtext" }, h("span", null, notification.message), notification.link && (h("a", { id: `action-${notification.id}`, class: "link", "aria-label": `Click to ${notification.link}...`, tabindex: 0, onClick: () => {
128
- this.snackLinkClicked(notification);
129
- }, onKeyDown: (ev) => ev.keyCode === 13 && this.snackLinkClicked(notification) }, h("span", { "aria-hidden": "true" }, notification.link)))), h("button", { id: `close-button-${notification.id}`, "aria-label": "Close this notification", class: "closesnack", tabindex: notification.link ? 0 : -1, onClick: () => this.snackDismissed(notification) }, h("span", { class: "tooltip", "aria-hidden": "true" }, "Close"))), h("div", { class: "sr-only", tabindex: notification.link ? 0 : -1, onFocus: () => notification.link && this.snackDismissed(notification) })))));
130
- }
131
- renderLiveRegion() {
132
- const latestNotification = this.parsedNotifications[0];
133
- const link = this.isTabbing ? "" : latestNotification.link;
134
- const srAnnouncement = `${latestNotification.message} ${link}`;
135
- const region = this.el.shadowRoot.querySelector(`#wm-live-region-${this.uid}`);
136
- if (region) {
137
- region.innerHTML = "";
138
- const wrapper = document.createElement("span");
139
- wrapper.innerHTML = srAnnouncement;
140
- region.appendChild(wrapper);
141
- }
142
- }
143
- render() {
144
- this.newNotification && this.renderLiveRegion();
145
- const snackbars = this.renderSnackbars();
146
- const wrappingClass = this.parsedNotifications.length === 0 ? "empty" : "";
147
- return (h("div", { ref: (el) => (this.snackbarEl = el), class: `wm-snackbars ${wrappingClass}` }, h("div", { class: "sr-only", "aria-live": "polite", "aria-atomic": "false", id: `wm-live-region-${this.uid}` }), snackbars));
148
- }
149
- get el() { return getElement(this); }
150
- static get watchers() { return {
151
- "notifications": ["updateSnacks"]
152
- }; }
153
- };
154
- Snackbar.style = wmSnackbarCss;
155
-
156
- export { Snackbar as wm_snackbar };
@@ -1,78 +0,0 @@
1
- import { r as registerInstance, e as createEvent, h, f as Host, g as getElement } from './index-e34aa595.js';
2
-
3
- const wmTabItemCss = ":host{font-family:inherit;display:inline-block}:host *{box-sizing:border-box}:host .tab-item{list-style-type:none;height:100%;display:inline-block}:host .tab-item .tab{-webkit-border-radius:0;-moz-border-radius:0;-ms-border-radius:0;border-radius:0;color:#575195;text-decoration:none;letter-spacing:0.7px;font-size:0.875rem;font-weight:500;opacity:1;position:relative;text-transform:uppercase;display:inline-block;height:3.3333333333em;line-height:3.3333333333em;padding-right:1.5rem;padding-left:1.5rem}:host .tab-item .tab[aria-selected=true]{font-weight:700;opacity:1;background:linear-gradient(currentColor, currentColor) bottom/0 0 no-repeat;background-size:calc(100% - 50px) 3px}:host .tab-item .tab[aria-selected=true].dark{color:#fff}:host .tab-item .tab,:host .tab-item .tab:hover,:host .tab-item .tab:active{outline:none}:host .tab-item .tab:focus{outline:none}:host .tab-item .tab.dark:not([aria-selected=true]){opacity:0.8;color:#fff}:host .tab-item .tab.user-is-tabbing:focus:not(:active){outline:none;-webkit-box-shadow:0 2px 2px 0 rgba(244, 243, 246, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.1), 0 0 4px 3px #61279e;-moz-box-shadow:0 2px 2px 0 rgba(244, 243, 246, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.1), 0 0 4px 3px #61279e;box-shadow:0 2px 2px 0 rgba(244, 243, 246, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.1), 0 0 4px 3px #61279e}:host .tab-item .tab.user-is-tabbing:focus:not(:active)::-moz-focus-inner{border:0}:host.hide{display:none}";
4
-
5
- const TabItem = class {
6
- constructor(hostRef) {
7
- registerInstance(this, hostRef);
8
- this.tabSelected = createEvent(this, "tabSelected", 7);
9
- this.keydownOnTabItem = createEvent(this, "keydownOnTabItem", 7);
10
- this.tabItemLoaded = createEvent(this, "tabItemLoaded", 7);
11
- /**
12
- * Indicates whether the tab is currently active
13
- */
14
- this.selected = false;
15
- this.show = true;
16
- /**
17
- * The id of the tab, linked to a tab panel.
18
- */
19
- this.tabId = "";
20
- this.tabClicked = (ev) => {
21
- ev.preventDefault();
22
- this.tabSelected.emit({ tabId: this.tabId });
23
- };
24
- this.tabPressed = (ev) => {
25
- const key = ev.key;
26
- if (key === "Enter" || key === " ") {
27
- ev.preventDefault();
28
- this.tabSelected.emit({ tabId: this.tabId });
29
- }
30
- else if (key === "Tab") {
31
- this.keydownOnTabItem.emit({ tabItem: this.el, key: ev.key });
32
- }
33
- else {
34
- ev.preventDefault();
35
- this.keydownOnTabItem.emit({ tabItem: this.el, key: ev.key });
36
- }
37
- };
38
- }
39
- get parentTabList() {
40
- return this.el.parentElement;
41
- }
42
- toggleTabbingOn() {
43
- this.linkEl && this.linkEl.classList.add("user-is-tabbing");
44
- }
45
- toggleTabbingOff() {
46
- this.linkEl && this.linkEl.classList.remove("user-is-tabbing");
47
- }
48
- componentWillLoad() {
49
- // @ts-ignore
50
- this.el.focus = function () {
51
- const linkEl = this.shadowRoot.querySelector("a");
52
- linkEl && linkEl.focus();
53
- };
54
- }
55
- componentDidLoad() {
56
- this.tabItemLoaded.emit();
57
- }
58
- render() {
59
- let classes = this.show ? "" : "hide ";
60
- classes += this.parentTabList && this.parentTabList.customBackground == "dark" ? "dark" : "";
61
- let styles = {};
62
- const padding = this.parentTabList && this.parentTabList.customPadding;
63
- if (padding) {
64
- const bkgSize = parseInt(padding, 10) * 2 || 0;
65
- const units = padding.split(/([0-9]+)/).pop();
66
- styles = {
67
- "padding-left": this.parentTabList.customPadding,
68
- "padding-right": this.parentTabList.customPadding,
69
- "background-size": `calc(100% - ${bkgSize}${units}) 3px`,
70
- };
71
- }
72
- return (h(Host, { role: "presentation" }, h("li", { class: "tab-item", role: "presentation" }, h("a", { class: `tab ${classes}`, style: styles, role: "tab", ref: (el) => (this.linkEl = el), onClick: this.tabClicked, id: `tab-link-${this.tabId}`, onKeyDown: (ev) => this.tabPressed(ev), "aria-selected": this.selected ? "true" : "false", tabindex: this.selected ? 0 : -1 }, h("slot", null)))));
73
- }
74
- get el() { return getElement(this); }
75
- };
76
- TabItem.style = wmTabItemCss;
77
-
78
- export { TabItem as wm_tab_item };