@carbon/ibm-products-web-components 0.11.0-rc.0 → 0.11.0-rc.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 (73) hide show
  1. package/es/components/about-modal/about-modal.d.ts +87 -61
  2. package/es/components/side-panel/side-panel.d.ts +87 -61
  3. package/es/components/tearsheet/tearsheet.d.ts +87 -61
  4. package/es/components/user-avatar/user-avatar.d.ts +87 -61
  5. package/es/package.json.js +1 -1
  6. package/es-custom/components/about-modal/about-modal.d.ts +418 -0
  7. package/es-custom/components/about-modal/about-modal.js +143 -0
  8. package/es-custom/components/about-modal/about-modal.js.map +1 -0
  9. package/es-custom/components/about-modal/about-modal.scss.js +13 -0
  10. package/es-custom/components/about-modal/about-modal.scss.js.map +1 -0
  11. package/es-custom/components/about-modal/about-modal.test.d.ts +7 -0
  12. package/es-custom/components/about-modal/about-modal.test.js +87 -0
  13. package/es-custom/components/about-modal/about-modal.test.js.map +1 -0
  14. package/es-custom/components/about-modal/defs.d.ts +8 -0
  15. package/es-custom/components/about-modal/defs.js +8 -0
  16. package/es-custom/components/about-modal/defs.js.map +1 -0
  17. package/es-custom/components/about-modal/index.d.ts +9 -0
  18. package/es-custom/components/about-modal/index.js +9 -0
  19. package/es-custom/components/about-modal/index.js.map +1 -0
  20. package/es-custom/components/side-panel/defs.d.ts +39 -0
  21. package/es-custom/components/side-panel/defs.js +51 -0
  22. package/es-custom/components/side-panel/defs.js.map +1 -0
  23. package/es-custom/components/side-panel/index.d.ts +9 -0
  24. package/es-custom/components/side-panel/index.js +9 -0
  25. package/es-custom/components/side-panel/index.js.map +1 -0
  26. package/es-custom/components/side-panel/side-panel.d.ts +546 -0
  27. package/es-custom/components/side-panel/side-panel.js +828 -0
  28. package/es-custom/components/side-panel/side-panel.js.map +1 -0
  29. package/es-custom/components/side-panel/side-panel.scss.js +13 -0
  30. package/es-custom/components/side-panel/side-panel.scss.js.map +1 -0
  31. package/es-custom/components/side-panel/side-panel.test.d.ts +7 -0
  32. package/es-custom/components/side-panel/side-panel.test.js +56 -0
  33. package/es-custom/components/side-panel/side-panel.test.js.map +1 -0
  34. package/es-custom/components/tearsheet/defs.d.ts +26 -0
  35. package/es-custom/components/tearsheet/defs.js +39 -0
  36. package/es-custom/components/tearsheet/defs.js.map +1 -0
  37. package/es-custom/components/tearsheet/index.d.ts +9 -0
  38. package/es-custom/components/tearsheet/index.js +9 -0
  39. package/es-custom/components/tearsheet/index.js.map +1 -0
  40. package/es-custom/components/tearsheet/tearsheet.d.ts +516 -0
  41. package/es-custom/components/tearsheet/tearsheet.js +676 -0
  42. package/es-custom/components/tearsheet/tearsheet.js.map +1 -0
  43. package/es-custom/components/tearsheet/tearsheet.scss.js +13 -0
  44. package/es-custom/components/tearsheet/tearsheet.scss.js.map +1 -0
  45. package/es-custom/components/tearsheet/tearsheet.test.d.ts +7 -0
  46. package/es-custom/components/tearsheet/tearsheet.test.js +121 -0
  47. package/es-custom/components/tearsheet/tearsheet.test.js.map +1 -0
  48. package/es-custom/components/user-avatar/index.d.ts +9 -0
  49. package/es-custom/components/user-avatar/index.js +9 -0
  50. package/es-custom/components/user-avatar/index.js.map +1 -0
  51. package/es-custom/components/user-avatar/user-avatar.d.ts +405 -0
  52. package/es-custom/components/user-avatar/user-avatar.js +151 -0
  53. package/es-custom/components/user-avatar/user-avatar.js.map +1 -0
  54. package/es-custom/components/user-avatar/user-avatar.scss.js +13 -0
  55. package/es-custom/components/user-avatar/user-avatar.scss.js.map +1 -0
  56. package/es-custom/globals/internal/handle.d.ts +18 -0
  57. package/es-custom/globals/internal/handle.js +8 -0
  58. package/es-custom/globals/internal/handle.js.map +1 -0
  59. package/es-custom/globals/internal/storybook-cdn.js +78 -0
  60. package/es-custom/globals/internal/storybook-cdn.js.map +1 -0
  61. package/es-custom/globals/settings.d.ts +15 -0
  62. package/es-custom/globals/settings.js +28 -0
  63. package/es-custom/globals/settings.js.map +1 -0
  64. package/es-custom/index.d.ts +12 -0
  65. package/es-custom/index.js +12 -0
  66. package/es-custom/index.js.map +1 -0
  67. package/es-custom/package.json.js +13 -0
  68. package/es-custom/package.json.js.map +1 -0
  69. package/lib/components/about-modal/about-modal.d.ts +87 -61
  70. package/lib/components/side-panel/side-panel.d.ts +87 -61
  71. package/lib/components/tearsheet/tearsheet.d.ts +87 -61
  72. package/lib/components/user-avatar/user-avatar.d.ts +87 -61
  73. package/package.json +5 -3
@@ -0,0 +1,676 @@
1
+ /**
2
+ * Copyright IBM Corp. 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { __decorate } from 'tslib';
9
+ import { LitElement, html } from 'lit';
10
+ import { query, queryAssignedElements, state, property } from 'lit/decorators.js';
11
+ import { prefix, carbonPrefix, selectorTabbable } from '../../globals/settings.js';
12
+ import HostListener from '@carbon/web-components/es/globals/decorators/host-listener.js';
13
+ import HostListenerMixin from '@carbon/web-components/es/globals/mixins/host-listener.js';
14
+ import styles from './tearsheet.scss.js';
15
+ import { carbonElement } from '@carbon/web-components/es/globals/decorators/carbon-element.js';
16
+ import '@carbon/web-components/es-custom/components/button/index.js';
17
+ import '@carbon/web-components/es-custom/components/layer/index.js';
18
+ import '@carbon/web-components/es-custom/components/button/button-set-base.js';
19
+ import '@carbon/web-components/es-custom/components/modal/index.js';
20
+ import { TEARSHEET_INFLUENCER_PLACEMENT, TEARSHEET_INFLUENCER_WIDTH, TEARSHEET_WIDTH } from './defs.js';
21
+
22
+ /**
23
+ * @license
24
+ *
25
+ * Copyright IBM Corp. 2023, 2024
26
+ *
27
+ * This source code is licensed under the Apache-2.0 license found in the
28
+ * LICENSE file in the root directory of this source tree.
29
+ */
30
+ var CDSTearsheet_1;
31
+ const maxStackDepth = 3;
32
+ const PRECEDING =
33
+ // eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope
34
+ Node.DOCUMENT_POSITION_PRECEDING | Node.DOCUMENT_POSITION_CONTAINS;
35
+ const FOLLOWING =
36
+ // eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope
37
+ Node.DOCUMENT_POSITION_FOLLOWING | Node.DOCUMENT_POSITION_CONTAINED_BY;
38
+ const blockClass = `${prefix}--tearsheet`;
39
+ const blockClassModalHeader = `${carbonPrefix}--modal-header`;
40
+ const blockClassActionSet = `${prefix}--action-set`;
41
+ /**
42
+ * Tries to focus on the given elements and bails out if one of them is successful.
43
+ *
44
+ * @param elements The elements.
45
+ * @param reverse `true` to go through the list in reverse order.
46
+ * @returns `true` if one of the attempts is successful, `false` otherwise.
47
+ */
48
+ function tryFocusElements(elements, reverse) {
49
+ {
50
+ for (let i = elements.length - 1; i >= 0; --i) {
51
+ const elem = elements[i];
52
+ elem.focus();
53
+ if (elem.ownerDocument.activeElement === elem) {
54
+ return true;
55
+ }
56
+ }
57
+ }
58
+ return false;
59
+ }
60
+ /**
61
+ * Tearsheet.
62
+ *
63
+ * @element c4p-tearsheet
64
+ * @csspart dialog The dialog.
65
+ * @fires c4p-tearsheet-beingclosed
66
+ * The custom event fired before this tearsheet is being closed upon a user gesture.
67
+ * Cancellation of this event stops the user-initiated action of closing this tearsheet.
68
+ * @fires c4p-tearsheet-closed - The custom event fired after this tearsheet is closed upon a user gesture.
69
+ */
70
+ let CDSTearsheet = CDSTearsheet_1 = class CDSTearsheet extends HostListenerMixin(LitElement) {
71
+ constructor() {
72
+ super(...arguments);
73
+ /**
74
+ * The element that had focus before this tearsheet gets open.
75
+ */
76
+ this._launcher = null;
77
+ this._actionsCount = 0;
78
+ this._hasHeaderActions = false;
79
+ this._hasLabel = false;
80
+ this._hasSlug = false;
81
+ this._hasTitle = false;
82
+ this._hasDescription = false;
83
+ this._hasInfluencerLeft = false;
84
+ this._hasInfluencerRight = false;
85
+ this._isOpen = false;
86
+ this._hasHeaderNavigation = false;
87
+ /**
88
+ * Handles `click` event on this element.
89
+ *
90
+ * @param event The event.
91
+ */
92
+ this._handleClick = (event) => {
93
+ if (event.composedPath().indexOf(this.shadowRoot) < 0 &&
94
+ !this.preventCloseOnClickOutside) {
95
+ this._handleUserInitiatedClose(event.target);
96
+ }
97
+ };
98
+ /**
99
+ * Handles `blur` event on this element.
100
+ *
101
+ * @param event The event.
102
+ * @param event.target The event target.
103
+ * @param event.relatedTarget The event relatedTarget.
104
+ */
105
+ this._handleBlur = async ({ target, relatedTarget }) => {
106
+ var _a;
107
+ if (!this._topOfStack()) {
108
+ return;
109
+ }
110
+ const {
111
+ // condensedActions,
112
+ open, _startSentinelNode: startSentinelNode, _endSentinelNode: endSentinelNode, } = this;
113
+ const oldContains = target !== this && this.contains(target);
114
+ const currentContains = relatedTarget !== this &&
115
+ (this.contains(relatedTarget) ||
116
+ (((_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.contains(relatedTarget)) &&
117
+ relatedTarget !== startSentinelNode &&
118
+ relatedTarget !== endSentinelNode));
119
+ // Performs focus wrapping if _all_ of the following is met:
120
+ // * This tearsheet is open
121
+ // * The viewport still has focus
122
+ // * Tearsheet body used to have focus but no longer has focus
123
+ const { selectorTabbable: selectorTabbableForTearsheet } = this
124
+ .constructor;
125
+ if (open && relatedTarget && oldContains && !currentContains) {
126
+ const comparisonResult = target.compareDocumentPosition(relatedTarget);
127
+ if (relatedTarget === startSentinelNode || comparisonResult & PRECEDING) {
128
+ await this.constructor._delay();
129
+ if (!tryFocusElements(this.querySelectorAll(selectorTabbableForTearsheet)) &&
130
+ relatedTarget !== this) {
131
+ this.focus();
132
+ }
133
+ }
134
+ else if (relatedTarget === endSentinelNode ||
135
+ comparisonResult & FOLLOWING) {
136
+ await this.constructor._delay();
137
+ if (!tryFocusElements(this.querySelectorAll(selectorTabbableForTearsheet))) {
138
+ this.focus();
139
+ }
140
+ }
141
+ }
142
+ };
143
+ this._handleKeydown = ({ key, target }) => {
144
+ if ((key === 'Esc' || key === 'Escape') && this._topOfStack()) {
145
+ this._handleUserInitiatedClose(target);
146
+ }
147
+ };
148
+ /**
149
+ * Optional aria label for the tearsheet
150
+ */
151
+ this.ariaLabel = '';
152
+ /**
153
+ * Sets the close button icon description
154
+ */
155
+ this.closeIconDescription = 'Close';
156
+ /**
157
+ * Enable a close icon ('x') in the header area of the tearsheet. By default,
158
+ * (when this prop is omitted, or undefined or null) a tearsheet does not
159
+ * display a close icon if there are navigation actions ("transactional
160
+ * tearsheet") and displays one if there are no navigation actions ("passive
161
+ * tearsheet"), and that behavior can be overridden if required by setting
162
+ * this prop to either true or false.
163
+ */
164
+ this.hasCloseIcon = false;
165
+ /**
166
+ * The placement of the influencer section, 'left' or 'right'.
167
+ */
168
+ this.influencerPlacement = TEARSHEET_INFLUENCER_PLACEMENT.RIGHT;
169
+ /**
170
+ * The width of the influencer section, 'narrow' or 'wide'.
171
+ */
172
+ this.influencerWidth = TEARSHEET_INFLUENCER_WIDTH.NARROW;
173
+ /**
174
+ * `true` if the tearsheet should be open.
175
+ */
176
+ this.open = false;
177
+ /**
178
+ * Prevent closing on click outside of tearsheet
179
+ */
180
+ this.preventCloseOnClickOutside = false;
181
+ /**
182
+ * The width of the influencer section, 'narrow' or 'wide'.
183
+ */
184
+ this.width = TEARSHEET_WIDTH.NARROW;
185
+ this._checkUpdateActionSizes = () => {
186
+ if (this._actions) {
187
+ for (let i = 0; i < this._actions.length; i++) {
188
+ this._actions[i].setAttribute('size', this.width === 'wide' ? '2xl' : 'xl');
189
+ }
190
+ }
191
+ };
192
+ this._maxActions = 4;
193
+ // Data structure to communicate the state of tearsheet stacking
194
+ // (i.e. when more than one tearsheet is open). Each tearsheet supplies a
195
+ // handler to be called whenever the stacking of the tearsheets changes, which
196
+ // happens when a tearsheet opens or closes. The 'open' array contains one
197
+ // handler per OPEN tearsheet ordered from lowest to highest in visual z-order.
198
+ // The 'all' array contains all the handlers for open and closed tearsheets.
199
+ this._stackDepth = -1;
200
+ this._stackPosition = -1;
201
+ this._topOfStack = () => {
202
+ return this._stackDepth === this._stackPosition;
203
+ };
204
+ this._notifyStack = () => {
205
+ CDSTearsheet_1._stack.all.forEach((handler) => {
206
+ handler(Math.min(CDSTearsheet_1._stack.open.length, maxStackDepth), CDSTearsheet_1._stack.open.indexOf(handler) + 1);
207
+ });
208
+ };
209
+ this._handleStackChange = (newDepth, newPosition) => {
210
+ this._stackDepth = newDepth;
211
+ this._stackPosition = newPosition;
212
+ if (this._stackDepth > 1 && this._stackPosition > 0) {
213
+ this.setAttribute('stack-position', `${newPosition}`);
214
+ this.setAttribute('stack-depth', `${this._stackDepth}`);
215
+ }
216
+ else {
217
+ this.removeAttribute('stack-position');
218
+ this.removeAttribute('stack-depth');
219
+ }
220
+ };
221
+ this._updateStack = () => {
222
+ if (this.open) {
223
+ CDSTearsheet_1._stack.open.push(this._handleStackChange);
224
+ }
225
+ else {
226
+ const indexOpen = CDSTearsheet_1._stack.open.indexOf(this._handleStackChange);
227
+ if (indexOpen >= 0) {
228
+ CDSTearsheet_1._stack.open.splice(indexOpen, 1);
229
+ }
230
+ }
231
+ this._notifyStack();
232
+ };
233
+ this.actionsMultiple = ['', 'single', 'double', 'triple'][this._actionsCount];
234
+ this._checkSetOpen = () => {
235
+ const { _tearsheet: tearsheet } = this;
236
+ if (tearsheet && this._isOpen) {
237
+ // wait until the tearsheet has transitioned off the screen to remove
238
+ tearsheet.addEventListener('transitionend', () => {
239
+ this._isOpen = false;
240
+ });
241
+ }
242
+ else {
243
+ // allow the html to render before animating in the tearsheet
244
+ window.requestAnimationFrame(() => {
245
+ this._isOpen = this.open;
246
+ });
247
+ }
248
+ };
249
+ }
250
+ _checkSetHasSlot(e) {
251
+ var _a, _b;
252
+ const t = e.target;
253
+ const dataPostfix = t.getAttribute('data-postfix');
254
+ const postfix = dataPostfix ? `-${dataPostfix}` : '';
255
+ // snake `ab-cd-ef` to _has camel case _hasAbCdEf
256
+ const hasName = `_has-${t.name}${postfix}`.replace(/-./g, (c) => c[1].toUpperCase());
257
+ this[hasName] = ((_b = (_a = t === null || t === void 0 ? void 0 : t.assignedElements()) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0;
258
+ }
259
+ /**
260
+ * Handles `click` event on the modal container.
261
+ *
262
+ * @param event The event.
263
+ */
264
+ _handleClickContainer(event) {
265
+ if (event.target.matches(this.constructor.selectorCloseButton)) {
266
+ this._handleUserInitiatedClose(event.target);
267
+ }
268
+ }
269
+ /**
270
+ * Handles user-initiated close request of this tearsheet.
271
+ *
272
+ * @param triggeredBy The element that triggered this close request.
273
+ */
274
+ _handleUserInitiatedClose(triggeredBy) {
275
+ if (this.open) {
276
+ const init = {
277
+ bubbles: true,
278
+ cancelable: true,
279
+ composed: true,
280
+ detail: {
281
+ triggeredBy,
282
+ },
283
+ };
284
+ if (this.dispatchEvent(new CustomEvent(this.constructor.eventBeforeClose, init))) {
285
+ this.open = false;
286
+ this.dispatchEvent(new CustomEvent(this.constructor.eventClose, init));
287
+ }
288
+ }
289
+ }
290
+ _handleSlugChange(e) {
291
+ const childItems = e.target.assignedElements();
292
+ this._hasSlug = childItems.length > 0;
293
+ if (this._hasSlug) {
294
+ childItems[0].setAttribute('size', 'sm');
295
+ this.setAttribute('slug', '');
296
+ }
297
+ else {
298
+ this.removeAttribute('slug');
299
+ }
300
+ }
301
+ _handleActionsChange(e) {
302
+ var _a;
303
+ const target = e.target;
304
+ const actions = target === null || target === void 0 ? void 0 : target.assignedElements();
305
+ const actionsCount = (_a = actions === null || actions === void 0 ? void 0 : actions.length) !== null && _a !== void 0 ? _a : 0;
306
+ if (actionsCount > this._maxActions) {
307
+ this._actionsCount = this._maxActions;
308
+ console.error(`Too many tearsheet actions, max ${this._maxActions}.`);
309
+ }
310
+ else {
311
+ this._actionsCount = actionsCount;
312
+ }
313
+ for (let i = 0; i < (actions === null || actions === void 0 ? void 0 : actions.length); i++) {
314
+ if (i + 1 > this._maxActions) {
315
+ // hide excessive tearsheet actions
316
+ actions[i].setAttribute('hidden', 'true');
317
+ actions[i].setAttribute(`data-actions-limit-${this._maxActions}-exceeded`, `${actions.length}`);
318
+ }
319
+ else {
320
+ actions[i].classList.add(`${blockClassActionSet}__action-button`);
321
+ }
322
+ }
323
+ this._checkUpdateActionSizes();
324
+ }
325
+ connectedCallback() {
326
+ super.connectedCallback();
327
+ CDSTearsheet_1._stack.all.push(this._handleStackChange);
328
+ }
329
+ disconnectedCallback() {
330
+ super.disconnectedCallback();
331
+ const indexAll = CDSTearsheet_1._stack.all.indexOf(this._handleStackChange);
332
+ CDSTearsheet_1._stack.all.splice(indexAll, 1);
333
+ const indexOpen = CDSTearsheet_1._stack.all.indexOf(this._handleStackChange);
334
+ CDSTearsheet_1._stack.open.splice(indexOpen, 1);
335
+ }
336
+ render() {
337
+ const { closeIconDescription, influencerPlacement, influencerWidth, open, width, } = this;
338
+ const actionsMultiple = ['', 'single', 'double', 'triple'][this._actionsCount];
339
+ const headerFieldsTemplate = html `<div
340
+ class=${`${blockClass}__header-fields`}
341
+ >
342
+ <h2 class=${`${blockClassModalHeader}__label`} ?hidden=${!this._hasLabel}>
343
+ <slot name="label" @slotchange=${this._checkSetHasSlot}></slot>
344
+ </h2>
345
+ <h3
346
+ class=${`${blockClassModalHeader}__heading ${blockClass}__heading`}
347
+ ?hidden=${!this._hasTitle}
348
+ >
349
+ <slot name="title" @slotchange=${this._checkSetHasSlot}></slot>
350
+ </h3>
351
+ <div
352
+ class=${`${blockClass}__header-description`}
353
+ ?hidden=${!this._hasDescription}
354
+ >
355
+ <slot name="description" @slotchange=${this._checkSetHasSlot}></slot>
356
+ </div>
357
+ </div>`;
358
+ const headerActionsTemplate = html ` <div
359
+ class=${`${blockClass}__header-actions`}
360
+ ?hidden=${!this._hasHeaderActions || this.width === 'narrow'}
361
+ >
362
+ <slot name="header-actions" @slotchange=${this._checkSetHasSlot}></slot>
363
+ </div>`;
364
+ const headerTemplate = html ` <cds-custom-modal-header
365
+ class=${`${blockClass}__header`}
366
+ ?has-close-icon=${this.hasCloseIcon || (this === null || this === void 0 ? void 0 : this._actionsCount) === 0}
367
+ ?has-navigation=${this._hasHeaderNavigation && this.width === 'wide'}
368
+ ?has-header-actions=${this._hasHeaderActions && this.width === 'wide'}
369
+ ?has-actions=${(this === null || this === void 0 ? void 0 : this._actionsCount) > 0}
370
+ ?has-slug=${this === null || this === void 0 ? void 0 : this._hasSlug}
371
+ width=${width}
372
+ >
373
+ ${this.width === TEARSHEET_WIDTH.WIDE
374
+ ? html `<cds-custom-layer level="1" class=${`${blockClass}__header-content`}
375
+ >${headerFieldsTemplate}${headerActionsTemplate}</cds-custom-layer
376
+ >`
377
+ : html `<div>${headerFieldsTemplate}${headerActionsTemplate}</div>`}
378
+
379
+ <div
380
+ class=${`${blockClass}__header-navigation`}
381
+ ?hidden=${!this._hasHeaderNavigation || this.width === 'narrow'}
382
+ >
383
+ <slot
384
+ name="header-navigation"
385
+ @slotchange=${this._checkSetHasSlot}
386
+ ></slot>
387
+ </div>
388
+ <slot name="slug" @slotchange=${this._handleSlugChange}></slot>
389
+ ${this.hasCloseIcon || (this === null || this === void 0 ? void 0 : this._actionsCount) === 0
390
+ ? html `<cds-custom-modal-close-button
391
+ close-button-label=${closeIconDescription}
392
+ @click=${this._handleUserInitiatedClose}
393
+ ></cds-custom-modal-close-button>`
394
+ : ''}
395
+ </cds-custom-modal-header>`;
396
+ return html `
397
+ <a
398
+ id="start-sentinel"
399
+ class="${prefix}--visually-hidden"
400
+ href="javascript:void 0"
401
+ role="navigation"
402
+ ></a>
403
+ <div
404
+ aria-label=${this.ariaLabel}
405
+ class=${`${blockClass}__container ${carbonPrefix}--modal-container ${carbonPrefix}--modal-container--sm`}
406
+ part="dialog"
407
+ role="complementary"
408
+ ?open=${this._isOpen}
409
+ ?opening=${open && !this._isOpen}
410
+ ?closing=${!open && this._isOpen}
411
+ width=${width}
412
+ stack-position=${this._stackPosition}
413
+ stack-depth=${this._stackDepth}
414
+ @click=${this._handleClickContainer}
415
+ >
416
+ <!-- Header -->
417
+ ${headerTemplate}
418
+
419
+ <!-- Body -->
420
+ <cds-custom-modal-body class=${`${blockClass}__body`} width=${width}>
421
+ <!-- Influencer when on left -->
422
+ ${influencerPlacement !== TEARSHEET_INFLUENCER_PLACEMENT.RIGHT
423
+ ? html `<div
424
+ class=${`${blockClass}__influencer`}
425
+ ?wide=${influencerWidth === 'wide'}
426
+ ?hidden=${!this._hasInfluencerLeft ||
427
+ this.width === TEARSHEET_WIDTH.NARROW}
428
+ >
429
+ <slot
430
+ name="influencer"
431
+ data-postfix="left"
432
+ @slotchange=${this._checkSetHasSlot}
433
+ ></slot>
434
+ </div>`
435
+ : ''}
436
+
437
+ <div class=${`${blockClass}__right`}>
438
+ <div class=${`${blockClass}__main`}>
439
+ <div class=${`${blockClass}__content`}>
440
+ <cds-custom-layer level="0">
441
+ <slot></slot>
442
+ </cds-custom-layer>
443
+ </div>
444
+
445
+ <!-- Influencer when on right -->
446
+ ${influencerPlacement === TEARSHEET_INFLUENCER_PLACEMENT.RIGHT
447
+ ? html `<div
448
+ class=${`${blockClass}__influencer`}
449
+ ?wide=${influencerWidth}
450
+ ?hidden=${!this._hasInfluencerRight ||
451
+ this.width === TEARSHEET_WIDTH.NARROW}
452
+ >
453
+ <slot
454
+ name="influencer"
455
+ data-postfix="right"
456
+ @slotchange=${this._checkSetHasSlot}
457
+ ></slot>
458
+ </div>`
459
+ : ''}
460
+ </div>
461
+ <!-- Action buttons -->
462
+ <cds-custom-button-set-base
463
+ class=${`${blockClass}__buttons ${blockClass}__button-container`}
464
+ actions-multiple=${actionsMultiple}
465
+ ?tearsheet-wide=${width === 'wide'}
466
+ ?hidden=${this._actionsCount === 0}
467
+ >
468
+ <slot
469
+ name="actions"
470
+ @slotchange=${this._handleActionsChange}
471
+ ></slot>
472
+ </cds-custom-button-set-base>
473
+ </div>
474
+ </cds-custom-modal-body>
475
+ </div>
476
+ <a
477
+ id="end-sentinel"
478
+ class="${prefix}--visually-hidden"
479
+ href="javascript:void 0"
480
+ role="navigation"
481
+ ></a>
482
+ `;
483
+ }
484
+ async updated(changedProperties) {
485
+ if (changedProperties.has('width')) {
486
+ this._checkUpdateActionSizes();
487
+ }
488
+ if (process.env.NODE_ENV === 'development' &&
489
+ (changedProperties.has('width') ||
490
+ changedProperties.has('_hasHeaderNavigation') ||
491
+ changedProperties.has('_hasInfluencerLeft') ||
492
+ changedProperties.has('_hasInfluencerRight') ||
493
+ changedProperties.has('_hasHeaderActions'))) {
494
+ if (this.width === 'narrow') {
495
+ if (this._hasHeaderNavigation) {
496
+ console.error(`Header navigation is not permitted in narrow Tearsheet.`);
497
+ }
498
+ if (this._hasInfluencerLeft || this._hasInfluencerRight) {
499
+ console.error(`Influencer is not permitted in narrow Tearsheet.`);
500
+ }
501
+ if (this._hasHeaderActions) {
502
+ console.error(`Header actions are not permitted in narrow Tearsheet.`);
503
+ }
504
+ }
505
+ }
506
+ if (changedProperties.has('open')) {
507
+ this._updateStack();
508
+ this._checkSetOpen();
509
+ if (this.open) {
510
+ this._launcher = this.ownerDocument.activeElement;
511
+ const focusNode = this.selectorInitialFocus &&
512
+ this.querySelector(this.selectorInitialFocus);
513
+ await this.constructor._delay();
514
+ if (focusNode) {
515
+ // For cases where a `carbon-web-components` component (e.g. `<cds-custom-button>`) being `primaryFocusNode`,
516
+ // where its first update/render cycle that makes it focusable happens after `<c4p-tearsheet>`'s first update/render cycle
517
+ focusNode.focus();
518
+ }
519
+ else if (!tryFocusElements(this.querySelectorAll(this.constructor.selectorTabbable))) {
520
+ this.focus();
521
+ }
522
+ }
523
+ else if (this._launcher &&
524
+ typeof this._launcher.focus === 'function') {
525
+ this._launcher.focus();
526
+ this._launcher = null;
527
+ }
528
+ }
529
+ }
530
+ /**
531
+ * @param ms The number of milliseconds.
532
+ * @returns A promise that is resolves after the given milliseconds.
533
+ */
534
+ static _delay(ms = 0) {
535
+ return new Promise((resolve) => {
536
+ setTimeout(resolve, ms);
537
+ });
538
+ }
539
+ /**
540
+ * A selector selecting buttons that should close this modal.
541
+ */
542
+ static get selectorCloseButton() {
543
+ return `[data-modal-close],${carbonPrefix}-modal-close-button`;
544
+ }
545
+ /**
546
+ * A selector selecting tabbable nodes.
547
+ */
548
+ static get selectorTabbable() {
549
+ return selectorTabbable;
550
+ }
551
+ /**
552
+ * The name of the custom event fired before this tearsheet is being closed upon a user gesture.
553
+ * Cancellation of this event stops the user-initiated action of closing this tearsheet.
554
+ */
555
+ static get eventBeforeClose() {
556
+ return `${prefix}-tearsheet-beingclosed`;
557
+ }
558
+ /**
559
+ * The name of the custom event fired after this tearsheet is closed upon a user gesture.
560
+ */
561
+ static get eventClose() {
562
+ return `${prefix}-tearsheet-closed`;
563
+ }
564
+ /**
565
+ * The name of the custom event fired on clicking the navigate back button
566
+ */
567
+ static get eventNavigateBack() {
568
+ return `${prefix}-tearsheet-header-navigate-back`;
569
+ }
570
+ };
571
+ CDSTearsheet._stack = {
572
+ open: [],
573
+ all: [],
574
+ };
575
+ CDSTearsheet.styles = styles; // `styles` here is a `CSSResult` generated by custom WebPack loader
576
+ __decorate([
577
+ query('#start-sentinel')
578
+ ], CDSTearsheet.prototype, "_startSentinelNode", void 0);
579
+ __decorate([
580
+ query('#end-sentinel')
581
+ ], CDSTearsheet.prototype, "_endSentinelNode", void 0);
582
+ __decorate([
583
+ query(`.${blockClass}__container`)
584
+ ], CDSTearsheet.prototype, "_tearsheet", void 0);
585
+ __decorate([
586
+ queryAssignedElements({
587
+ slot: 'actions',
588
+ selector: `${carbonPrefix}-button`,
589
+ })
590
+ ], CDSTearsheet.prototype, "_actions", void 0);
591
+ __decorate([
592
+ state()
593
+ ], CDSTearsheet.prototype, "_actionsCount", void 0);
594
+ __decorate([
595
+ state()
596
+ ], CDSTearsheet.prototype, "_hasHeaderActions", void 0);
597
+ __decorate([
598
+ state()
599
+ ], CDSTearsheet.prototype, "_hasLabel", void 0);
600
+ __decorate([
601
+ state()
602
+ ], CDSTearsheet.prototype, "_hasSlug", void 0);
603
+ __decorate([
604
+ state()
605
+ ], CDSTearsheet.prototype, "_hasTitle", void 0);
606
+ __decorate([
607
+ state()
608
+ ], CDSTearsheet.prototype, "_hasDescription", void 0);
609
+ __decorate([
610
+ state()
611
+ ], CDSTearsheet.prototype, "_hasInfluencerLeft", void 0);
612
+ __decorate([
613
+ state()
614
+ ], CDSTearsheet.prototype, "_hasInfluencerRight", void 0);
615
+ __decorate([
616
+ state()
617
+ ], CDSTearsheet.prototype, "_isOpen", void 0);
618
+ __decorate([
619
+ state()
620
+ ], CDSTearsheet.prototype, "_hasHeaderNavigation", void 0);
621
+ __decorate([
622
+ HostListener('click')
623
+ // @ts-ignore: The decorator refers to this method but TS thinks this method is not referred to
624
+ ], CDSTearsheet.prototype, "_handleClick", void 0);
625
+ __decorate([
626
+ HostListener('shadowRoot:focusout')
627
+ // @ts-ignore: The decorator refers to this method but TS thinks this method is not referred to
628
+ ], CDSTearsheet.prototype, "_handleBlur", void 0);
629
+ __decorate([
630
+ HostListener('document:keydown')
631
+ // @ts-ignore: The decorator refers to this method but TS thinks this method is not referred to
632
+ ], CDSTearsheet.prototype, "_handleKeydown", void 0);
633
+ __decorate([
634
+ property({ reflect: true, attribute: 'aria-label' })
635
+ ], CDSTearsheet.prototype, "ariaLabel", void 0);
636
+ __decorate([
637
+ property({ reflect: true, attribute: 'close-icon-description' })
638
+ ], CDSTearsheet.prototype, "closeIconDescription", void 0);
639
+ __decorate([
640
+ property({ reflect: true, type: Boolean, attribute: 'has-close-icon' })
641
+ ], CDSTearsheet.prototype, "hasCloseIcon", void 0);
642
+ __decorate([
643
+ property({ reflect: true, attribute: 'influencer-placement' })
644
+ ], CDSTearsheet.prototype, "influencerPlacement", void 0);
645
+ __decorate([
646
+ property({ reflect: true, attribute: 'influencer-width' })
647
+ ], CDSTearsheet.prototype, "influencerWidth", void 0);
648
+ __decorate([
649
+ property({ type: Boolean, reflect: true })
650
+ ], CDSTearsheet.prototype, "open", void 0);
651
+ __decorate([
652
+ property({ type: Boolean, attribute: 'prevent-close-on-click-outside' })
653
+ ], CDSTearsheet.prototype, "preventCloseOnClickOutside", void 0);
654
+ __decorate([
655
+ property({
656
+ reflect: true,
657
+ attribute: 'selector-initial-focus',
658
+ type: String,
659
+ })
660
+ ], CDSTearsheet.prototype, "selectorInitialFocus", void 0);
661
+ __decorate([
662
+ property({ reflect: true, attribute: 'width' })
663
+ ], CDSTearsheet.prototype, "width", void 0);
664
+ __decorate([
665
+ state()
666
+ ], CDSTearsheet.prototype, "_stackDepth", void 0);
667
+ __decorate([
668
+ state()
669
+ ], CDSTearsheet.prototype, "_stackPosition", void 0);
670
+ CDSTearsheet = CDSTearsheet_1 = __decorate([
671
+ carbonElement(`${prefix}-tearsheet`)
672
+ ], CDSTearsheet);
673
+ var CDSTearsheet$1 = CDSTearsheet;
674
+
675
+ export { TEARSHEET_INFLUENCER_PLACEMENT, TEARSHEET_INFLUENCER_WIDTH, TEARSHEET_WIDTH, CDSTearsheet$1 as default };
676
+ //# sourceMappingURL=tearsheet.js.map