@nanoporetech-digital/components 5.8.1 → 5.8.3

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 (100) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/cjs/nano-details.cjs.entry.js +13 -4
  3. package/dist/cjs/nano-details.cjs.entry.js.map +1 -1
  4. package/dist/cjs/nano-global-nav-user-profile_3.cjs.entry.js +9 -3
  5. package/dist/cjs/nano-global-nav-user-profile_3.cjs.entry.js.map +1 -1
  6. package/dist/cjs/nano-global-nav.cjs.entry.js +5 -2
  7. package/dist/cjs/nano-global-nav.cjs.entry.js.map +1 -1
  8. package/dist/cjs/nano-grid_2.cjs.entry.js +15 -16
  9. package/dist/cjs/nano-grid_2.cjs.entry.js.map +1 -1
  10. package/dist/cjs/nano-tab-group.cjs.entry.js +9 -3
  11. package/dist/cjs/nano-tab-group.cjs.entry.js.map +1 -1
  12. package/dist/cjs/{nano-table-0f4ea38f.js → nano-table-9bd1168f.js} +2 -2
  13. package/dist/cjs/{nano-table-0f4ea38f.js.map → nano-table-9bd1168f.js.map} +1 -1
  14. package/dist/cjs/nano-table.cjs.entry.js +1 -1
  15. package/dist/cjs/{table.worker-ba6685a0.js → table.worker-894a0418.js} +2 -2
  16. package/dist/cjs/table.worker-894a0418.js.map +1 -0
  17. package/dist/cjs/transitions-6ca20f9b.js +50 -0
  18. package/dist/cjs/transitions-6ca20f9b.js.map +1 -0
  19. package/dist/collection/components/details/details.css +19 -10
  20. package/dist/collection/components/details/details.js +11 -2
  21. package/dist/collection/components/details/details.js.map +1 -1
  22. package/dist/collection/components/global-nav/global-nav.js +4 -1
  23. package/dist/collection/components/global-nav/global-nav.js.map +1 -1
  24. package/dist/collection/components/grid/grid.js +15 -16
  25. package/dist/collection/components/grid/grid.js.map +1 -1
  26. package/dist/collection/components/nav-item/nav-item.js +8 -2
  27. package/dist/collection/components/nav-item/nav-item.js.map +1 -1
  28. package/dist/collection/components/tabs/tab-group.js +8 -2
  29. package/dist/collection/components/tabs/tab-group.js.map +1 -1
  30. package/dist/collection/utils/transitions.js +22 -20
  31. package/dist/collection/utils/transitions.js.map +1 -1
  32. package/dist/components/grid.js +15 -16
  33. package/dist/components/grid.js.map +1 -1
  34. package/dist/components/nano-details.js +12 -3
  35. package/dist/components/nano-details.js.map +1 -1
  36. package/dist/components/nano-global-nav.js +4 -1
  37. package/dist/components/nano-global-nav.js.map +1 -1
  38. package/dist/components/nano-tab-group.js +8 -2
  39. package/dist/components/nano-tab-group.js.map +1 -1
  40. package/dist/components/nav-item.js +8 -2
  41. package/dist/components/nav-item.js.map +1 -1
  42. package/dist/components/transitions.js +22 -20
  43. package/dist/components/transitions.js.map +1 -1
  44. package/dist/esm/nano-details.entry.js +13 -4
  45. package/dist/esm/nano-details.entry.js.map +1 -1
  46. package/dist/esm/nano-global-nav-user-profile_3.entry.js +9 -3
  47. package/dist/esm/nano-global-nav-user-profile_3.entry.js.map +1 -1
  48. package/dist/esm/nano-global-nav.entry.js +5 -2
  49. package/dist/esm/nano-global-nav.entry.js.map +1 -1
  50. package/dist/esm/nano-grid_2.entry.js +15 -16
  51. package/dist/esm/nano-grid_2.entry.js.map +1 -1
  52. package/dist/esm/nano-tab-group.entry.js +9 -3
  53. package/dist/esm/nano-tab-group.entry.js.map +1 -1
  54. package/dist/esm/{nano-table-cc0fc046.js → nano-table-baba1696.js} +2 -2
  55. package/dist/esm/{nano-table-cc0fc046.js.map → nano-table-baba1696.js.map} +1 -1
  56. package/dist/esm/nano-table.entry.js +1 -1
  57. package/dist/esm/{table.worker-ca7b069b.js → table.worker-ae46bca0.js} +2 -2
  58. package/dist/esm/table.worker-ae46bca0.js.map +1 -0
  59. package/dist/esm/transitions-989cae97.js +48 -0
  60. package/dist/esm/transitions-989cae97.js.map +1 -0
  61. package/dist/nano-components/nano-components.esm.js +1 -1
  62. package/dist/nano-components/p-0ec40950.js +5 -0
  63. package/dist/nano-components/p-0ec40950.js.map +1 -0
  64. package/dist/nano-components/p-358b2ffd.entry.js +5 -0
  65. package/dist/nano-components/p-358b2ffd.entry.js.map +1 -0
  66. package/dist/nano-components/{p-43573870.js → p-587d3e3d.js} +2 -2
  67. package/dist/nano-components/p-84ba4c38.entry.js +5 -0
  68. package/dist/nano-components/p-84ba4c38.entry.js.map +1 -0
  69. package/dist/nano-components/{p-4b7e85b2.entry.js → p-a1ead0a7.entry.js} +2 -2
  70. package/dist/nano-components/p-ae85ca01.entry.js +5 -0
  71. package/dist/nano-components/p-ae85ca01.entry.js.map +1 -0
  72. package/dist/nano-components/{p-997319eb.entry.js → p-e2cc4045.entry.js} +2 -2
  73. package/dist/nano-components/p-e2cc4045.entry.js.map +1 -0
  74. package/dist/nano-components/{p-92195a83.entry.js → p-ecf6276f.entry.js} +2 -2
  75. package/dist/nano-components/p-ecf6276f.entry.js.map +1 -0
  76. package/dist/nano-components/{p-d2705006.js → p-f0226ce2.js} +2 -2
  77. package/dist/types/components/grid/grid.d.ts +0 -1
  78. package/dist/types/utils/transitions.d.ts +7 -3
  79. package/docs-json.json +6 -6
  80. package/hydrate/index.js +69 -44
  81. package/package.json +2 -2
  82. package/dist/cjs/table.worker-ba6685a0.js.map +0 -1
  83. package/dist/cjs/transitions-1205f12b.js +0 -48
  84. package/dist/cjs/transitions-1205f12b.js.map +0 -1
  85. package/dist/esm/table.worker-ca7b069b.js.map +0 -1
  86. package/dist/esm/transitions-686c5fec.js +0 -46
  87. package/dist/esm/transitions-686c5fec.js.map +0 -1
  88. package/dist/nano-components/p-20086faa.entry.js +0 -5
  89. package/dist/nano-components/p-20086faa.entry.js.map +0 -1
  90. package/dist/nano-components/p-5ca9275c.entry.js +0 -5
  91. package/dist/nano-components/p-5ca9275c.entry.js.map +0 -1
  92. package/dist/nano-components/p-92195a83.entry.js.map +0 -1
  93. package/dist/nano-components/p-997319eb.entry.js.map +0 -1
  94. package/dist/nano-components/p-afd3cd17.entry.js +0 -5
  95. package/dist/nano-components/p-afd3cd17.entry.js.map +0 -1
  96. package/dist/nano-components/p-f6de2d5d.js +0 -5
  97. package/dist/nano-components/p-f6de2d5d.js.map +0 -1
  98. /package/dist/nano-components/{p-43573870.js.map → p-587d3e3d.js.map} +0 -0
  99. /package/dist/nano-components/{p-4b7e85b2.entry.js.map → p-a1ead0a7.entry.js.map} +0 -0
  100. /package/dist/nano-components/{p-d2705006.js.map → p-f0226ce2.js.map} +0 -0
package/hydrate/index.js CHANGED
@@ -12165,37 +12165,39 @@ class Demo {
12165
12165
  * - OnHide remove show class, listen for transition end, then display: none on finish
12166
12166
  * - OnShow, display block on start then add a show class
12167
12167
  * @param el
12168
- * @param className
12169
- * @param show
12168
+ * @param options
12170
12169
  * @returns a promise of resolving as either 'show' or 'hidden'
12171
12170
  */
12172
- const displayTransition = (el, className, show = true, showDisplay = 'block') => {
12171
+ const displayTransition = (el, options) => {
12172
+ const opts = Object.assign({ className: '', show: true, showDisplay: 'block' }, options);
12173
12173
  return new Promise((resolve) => {
12174
- if (show) {
12175
- el.addEventListener('transitionend', (e) => {
12176
- if (e.target === el ||
12177
- e.composedPath().some((el) => el === e.target)) {
12178
- resolve('shown');
12179
- }
12180
- }, { once: true });
12181
- el.style.display = showDisplay;
12174
+ const showCb = (e) => {
12175
+ if (e.target === el || e.composedPath().some((el) => el === e.target)) {
12176
+ resolve('shown');
12177
+ el.removeEventListener('transitionend', showCb);
12178
+ }
12179
+ };
12180
+ const hideCb = (e) => {
12181
+ if (e.target === el || e.composedPath().some((el) => el === e.target)) {
12182
+ el.style.display = 'none';
12183
+ resolve('hidden');
12184
+ el.removeEventListener('transitionend', hideCb);
12185
+ }
12186
+ };
12187
+ if (opts.show) {
12188
+ el.addEventListener('transitionend', showCb);
12189
+ el.style.display = opts.showDisplay;
12182
12190
  el.dataset.displayTransition = 'true';
12183
- setTimeout(() => el.classList.add(className), 20);
12191
+ setTimeout(() => el.classList.add(opts.className), 20);
12184
12192
  }
12185
12193
  else {
12186
- el.addEventListener('transitionend', (e) => {
12187
- if (e.target === el ||
12188
- e.composedPath().some((el) => el === e.target)) {
12189
- el.style.display = 'none';
12190
- resolve('hidden');
12191
- }
12192
- }, { once: true });
12193
- el.classList.remove(className);
12194
+ el.addEventListener('transitionend', hideCb);
12195
+ el.classList.remove(opts.className);
12194
12196
  }
12195
12197
  });
12196
12198
  };
12197
12199
 
12198
- const detailsCss = "/*!@:host*/.sc-nano-details-h{box-sizing:border-box}/*!@*,\n*::before,\n*::after*/*.sc-nano-details,*.sc-nano-details::before,*.sc-nano-details::after{box-sizing:border-box}/*!@[hidden]*/[hidden].sc-nano-details{display:none !important}/*!@:host*/.sc-nano-details-h{font-family:inherit;font-size:inherit;font-stretch:inherit;font-style:inherit;font-weight:inherit;letter-spacing:inherit;text-decoration:inherit;text-overflow:inherit;text-transform:inherit;text-align:inherit;white-space:inherit;color:inherit;--padding:1em;--btn-padding:var(--padding);--btn-bg-color:var(--nano-color-contrast, #dad6d3);--btn-bg-color--open:var(--nano-color-base, #dad6d3);--btn-bg-color--hover:var(--nano-color-tint, #f9f9fb);--btn-text-color:var(--nano-color-base, #455556);--btn-text-color--open:var(--nano-color-contrast, var(--btn-text-color));--btn-text-color--hover:var(--nano-color-contrast, var(--btn-text-color));--content-transition:height 0.2s ease-out;--border-width:none;--border-color:none;--border-style:none;--border-radius:none;--box-shadow:none;--focus-style:var(--nano-control-focus-shadow, 0 0 0 0.1875rem var(--nano-control-focus-color, rgba(144, 198, 231, 0.8)));display:block;border-style:var(--border-style);border-width:var(--border-width-dims);border-color:var(--border-color);border-radius:var(--border-radius-dims);box-shadow:var(--box-shadow)}/*!@:host([disabled])*/[disabled].sc-nano-details-h{opacity:0.5}/*!@:host(:last-of-type)*/.sc-nano-details-h:last-of-type{--border-width-dims:0 var(--border-width) var(--border-width);--border-radius-dims:0 0 var(--border-radius) var(--border-radius)}/*!@:host(:last-of-type) .open .content*/.sc-nano-details-h:last-of-type .open.sc-nano-details .content.sc-nano-details{border-radius:0 0 var(--border-radius) var(--border-radius)}/*!@:host(:first-of-type)*/.sc-nano-details-h:first-of-type{--border-radius-dims:var(--border-radius) var(--border-radius) 0 0;--border-width-dims:var(--border-width)}/*!@:host(:first-of-type:last-of-type)*/.sc-nano-details-h:first-of-type:last-of-type{--border-radius-dims:var(--border-radius);--border-width-dims:var(--border-width)}/*!@:host(:not(:last-of-type):not(:first-of-type))*/.sc-nano-details-h:not(:last-of-type):not(:first-of-type){--border-width-dims:0 var(--border-width) var(--border-width)}/*!@.header*/.header.sc-nano-details{height:auto;padding:var(--btn-padding);text-align:inherit;position:relative;font-size:1em;line-height:1;margin:0;transition:0.3s ease background, 0.3s ease color, 0.15s ease box-shadow;display:flex;align-items:center;background:var(--btn-bg-color);color:var(--btn-text-color);border-radius:var(--border-radius-dims);cursor:pointer}/*!@.header::-webkit-details-marker*/.header.sc-nano-details::-webkit-details-marker{display:none}/*!@.header:focus*/.header.sc-nano-details:focus{outline:none}/*!@.header:focus-visible*/.header.sc-nano-details:focus-visible{box-shadow:var(--focus-style);outline:none;position:relative;z-index:1}/*!@.header:hover*/.header.sc-nano-details:hover{background:var(--btn-bg-color--hover);color:var(--btn-text-color--hover)}/*!@.open .header*/.open.sc-nano-details .header.sc-nano-details{background:var(--btn-bg-color--open);color:var(--btn-text-color--open);border-end-end-radius:0;border-end-start-radius:0}/*!@.disabled .header*/.disabled.sc-nano-details .header.sc-nano-details{cursor:not-allowed}/*!@.header .label*/.header.sc-nano-details .label.sc-nano-details{width:100%;max-width:100%;max-height:100%;flex:1;display:inline-block}/*!@.header .icon*/.header.sc-nano-details .icon.sc-nano-details{line-height:0;flex-direction:column;justify-content:center;display:inline-block;color:currentcolor;transition:0.3s ease transform;transform-origin:center}/*!@.header .icon--start*/.header.sc-nano-details .icon--start.sc-nano-details{margin-inline:0 var(--padding);margin-block:0}/*!@.header .icon--end*/.header.sc-nano-details .icon--end.sc-nano-details{margin-inline:var(--padding) 0;margin-block:0}/*!@.header .icon ::slotted(nano-icon)*/.header .icon .sc-nano-details-s>nano-icon{--color:currentcolor}/*!@.body*/.body.sc-nano-details{overflow:hidden;transition:var(--content-transition), 0.2s ease border-radius;outline:none}/*!@.body > **/.body.sc-nano-details>*.sc-nano-details{opacity:0;transition:opacity 0.2s ease-out}/*!@.open .body > **/.open.sc-nano-details .body.sc-nano-details>*.sc-nano-details{opacity:1}/*!@.content*/.content.sc-nano-details{padding:var(--padding)}";
12200
+ const detailsCss = "/*!@:host*/.sc-nano-details-h{box-sizing:border-box}/*!@*,\n*::before,\n*::after*/*.sc-nano-details,*.sc-nano-details::before,*.sc-nano-details::after{box-sizing:border-box}/*!@[hidden]*/[hidden].sc-nano-details{display:none !important}/*!@:host*/.sc-nano-details-h{font-family:inherit;font-size:inherit;font-stretch:inherit;font-style:inherit;font-weight:inherit;letter-spacing:inherit;text-decoration:inherit;text-overflow:inherit;text-transform:inherit;text-align:inherit;white-space:inherit;color:inherit;--padding:1em;--btn-padding:var(--padding);--content-padding:var(--padding);--btn-bg-color:var(--nano-color-contrast, #dad6d3);--btn-bg-color--open:var(--nano-color-base, #dad6d3);--btn-bg-color--hover:var(--nano-color-tint, #f9f9fb);--btn-text-color:var(--nano-color-base, #455556);--btn-text-color--open:var(--nano-color-contrast, var(--btn-text-color));--btn-text-color--hover:var(--nano-color-contrast, var(--btn-text-color));--transition-duration:0.2s;--border-width:none;--border-color:none;--border-style:none;--border-radius:none;--box-shadow:none;--focus-style:var(--nano-control-focus-shadow, 0 0 0 0.1875rem var(--nano-control-focus-color, rgba(144, 198, 231, 0.8)));display:block;border-style:var(--border-style);border-width:var(--border-width-dims);border-color:var(--border-color);border-radius:var(--border-radius-dims);box-shadow:var(--box-shadow)}/*!@:host([disabled])*/[disabled].sc-nano-details-h{opacity:0.5}/*!@:host(:last-of-type)*/.sc-nano-details-h:last-of-type{--border-width-dims:0 var(--border-width) var(--border-width);--border-radius-dims:0 0 var(--border-radius) var(--border-radius)}/*!@:host(:last-of-type) .open .content*/.sc-nano-details-h:last-of-type .open.sc-nano-details .content.sc-nano-details{border-radius:0 0 var(--border-radius) var(--border-radius)}/*!@:host(:first-of-type)*/.sc-nano-details-h:first-of-type{--border-radius-dims:var(--border-radius) var(--border-radius) 0 0;--border-width-dims:var(--border-width)}/*!@:host(:first-of-type:last-of-type)*/.sc-nano-details-h:first-of-type:last-of-type{--border-radius-dims:var(--border-radius);--border-width-dims:var(--border-width)}/*!@:host(:not(:last-of-type):not(:first-of-type))*/.sc-nano-details-h:not(:last-of-type):not(:first-of-type){--border-width-dims:0 var(--border-width) var(--border-width)}/*!@.header*/.header.sc-nano-details{height:auto;padding:var(--btn-padding);text-align:inherit;position:relative;font-size:1em;line-height:1;margin:0;transition:0.3s ease background, 0.3s ease color, 0.15s ease box-shadow;display:flex;align-items:center;background:var(--btn-bg-color);color:var(--btn-text-color);border-radius:var(--border-radius-dims);cursor:pointer}/*!@.header::-webkit-details-marker*/.header.sc-nano-details::-webkit-details-marker{display:none}/*!@.header:focus*/.header.sc-nano-details:focus{outline:none}/*!@.header:focus-visible*/.header.sc-nano-details:focus-visible{box-shadow:var(--focus-style);outline:none;position:relative;z-index:1}/*!@.header:hover*/.header.sc-nano-details:hover{background:var(--btn-bg-color--hover);color:var(--btn-text-color--hover)}/*!@.open .header*/.open.sc-nano-details .header.sc-nano-details{background:var(--btn-bg-color--open);color:var(--btn-text-color--open);border-end-end-radius:0;border-end-start-radius:0}/*!@.disabled .header*/.disabled.sc-nano-details .header.sc-nano-details{cursor:not-allowed}/*!@.header .label*/.header.sc-nano-details .label.sc-nano-details{width:100%;max-width:100%;max-height:100%;flex:1;display:inline-block}/*!@.header .icon*/.header.sc-nano-details .icon.sc-nano-details{line-height:0;flex-direction:column;justify-content:center;display:inline-block;color:currentcolor;transition:0.3s ease transform;transform-origin:center}/*!@.header .icon--start*/.header.sc-nano-details .icon--start.sc-nano-details{margin-inline:0 var(--btn-padding);margin-block:0}/*!@.header .icon--end*/.header.sc-nano-details .icon--end.sc-nano-details{margin-inline:var(--btn-padding) 0;margin-block:0}/*!@.header .icon ::slotted(nano-icon)*/.header .icon .sc-nano-details-s>nano-icon{--color:currentcolor}/*!@.body*/.body.sc-nano-details{overflow:hidden;transition:height var(--transition-duration, 0.3s) ease-out, 0.2s ease border-radius;outline:none}/*!@.is-hidden .body > **/.is-hidden.sc-nano-details .body.sc-nano-details>*.sc-nano-details{animation:fade 0.1s ease reverse}/*!@.open .body > **/.open.sc-nano-details .body.sc-nano-details>*.sc-nano-details{animation:fade var(--transition-duration, 0.3s) ease forwards}/*!@.content*/.content.sc-nano-details{padding:var(--content-padding)}@keyframes fade{from{opacity:0}to{opacity:1}}";
12199
12201
 
12200
12202
  /**
12201
12203
  * A simple element used to hide or reveal more content with slide effect. Can be used independently or nested within a [accordion](story/components-accordion--accordion) element to add 'one item open at a time' support.
@@ -12269,9 +12271,14 @@ class Details {
12269
12271
  }
12270
12272
  this.cacheHeight = this.contentEl.scrollHeight;
12271
12273
  this.bodyEl.style.height = this.cacheHeight + 'px';
12272
- displayTransition(this.bodyEl, 'is-shown', false).then(() => {
12274
+ displayTransition(this.bodyEl, {
12275
+ className: 'is-shown',
12276
+ show: false,
12277
+ transitionProp: 'height',
12278
+ }).then(() => {
12273
12279
  this.stateChanging = false;
12274
12280
  this.detailsEl.open = false;
12281
+ this.bodyEl.classList.add('is-hidden');
12275
12282
  });
12276
12283
  requestAnimationFrame(() => {
12277
12284
  this.bodyEl.style.height = '0px';
@@ -12285,7 +12292,11 @@ class Details {
12285
12292
  this.detailsEl.open = false;
12286
12293
  return;
12287
12294
  }
12288
- displayTransition(this.bodyEl, 'is-shown', true).then(() => {
12295
+ displayTransition(this.bodyEl, {
12296
+ className: 'is-shown',
12297
+ show: true,
12298
+ transitionProp: 'height',
12299
+ }).then(() => {
12289
12300
  this.stateChanging = false;
12290
12301
  this.bodyEl.style.height = 'auto';
12291
12302
  });
@@ -17111,7 +17122,10 @@ class GlobalNav {
17111
17122
  }
17112
17123
  }
17113
17124
  async handleUserMenu() {
17114
- await displayTransition(this.userLinkPanel, 'show', this.userMenuOpen);
17125
+ await displayTransition(this.userLinkPanel, {
17126
+ className: 'show',
17127
+ show: this.userMenuOpen,
17128
+ });
17115
17129
  if (this.userMenuOpen) {
17116
17130
  this.userLinkPanel.focus();
17117
17131
  this.userLinkPanel.addEventListener('focusout', this.onUserMenuBlur);
@@ -18336,7 +18350,6 @@ var __metadata = (undefined && undefined.__metadata) || function (k, v) {
18336
18350
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
18337
18351
  return Reflect.metadata(k, v);
18338
18352
  };
18339
- let gridId = 0;
18340
18353
  /**
18341
18354
  * A lightweight, context-aware CSS grid implementation.
18342
18355
  *
@@ -18355,15 +18368,14 @@ class Grid {
18355
18368
  constructor(hostRef) {
18356
18369
  registerInstance(this, hostRef);
18357
18370
  this.grids = [];
18358
- this.gridId = 'nano-grid-' + gridId++;
18359
18371
  this.styles = () => {
18360
18372
  const css = /* css */ `
18361
18373
  ${this.grids
18362
18374
  .map((bp) => /* css */ `
18363
- @container (min-width: ${typeof bp.breakpoint === 'number'
18364
- ? bp.breakpoint + 1 + 'px'
18375
+ @container (min-width: ${!!Number(bp.breakpoint + 1)
18376
+ ? Number(bp.breakpoint) + 1 + 'px'
18365
18377
  : bp.breakpoint}) {
18366
- #${this.gridId}.grid {
18378
+ [cache-key="${this.cacheKey}"].grid {
18367
18379
  --current-grid-size: "grid size: ${bp.name}";
18368
18380
  ${bp.template
18369
18381
  ? `grid-template: ${bp.template};`
@@ -18373,11 +18385,11 @@ class Grid {
18373
18385
  .map((_, i) => {
18374
18386
  const gItm = i + 1;
18375
18387
  return /* css */ `
18376
- #${this.gridId}.grid > [grid-states~="${bp.name}-col-start-${gItm}"],
18388
+ [cache-key="${this.cacheKey}"].grid > [grid-states~="${bp.name}-col-start-${gItm}"],
18377
18389
  ::slotted([grid-states~="${bp.name}-col-start-${gItm}"]) {
18378
18390
  grid-column-start: ${gItm} !important;
18379
18391
  }
18380
- #${this.gridId}.grid > [grid-states~="${bp.name}-col-span-${gItm}"],
18392
+ [cache-key="${this.cacheKey}"].grid > [grid-states~="${bp.name}-col-span-${gItm}"],
18381
18393
  ::slotted([grid-states~="${bp.name}-col-span-${gItm}"]) {
18382
18394
  grid-column-end: span ${gItm} !important;
18383
18395
  }
@@ -18388,23 +18400,24 @@ class Grid {
18388
18400
  .map((_, i) => {
18389
18401
  const gItm = i + 1;
18390
18402
  return /* css */ `
18391
- #${this.gridId}.grid > [grid-states~="${bp.name}-row-start-${gItm}"],
18403
+ [cache-key="${this.cacheKey}"].grid > [grid-states~="${bp.name}-row-start-${gItm}"],
18392
18404
  ::slotted([grid-states~="${bp.name}-row-start-${gItm}"]) {
18393
18405
  grid-row-start: ${gItm} !important;
18394
18406
  }
18395
- #${this.gridId}.grid > [grid-states~="${bp.name}-row-span-${gItm}"],
18407
+ [cache-key="${this.cacheKey}"].grid > [grid-states~="${bp.name}-row-span-${gItm}"],
18396
18408
  ::slotted([grid-states~="${bp.name}-row-span-${gItm}"]) {
18397
18409
  grid-row-end: span ${gItm} !important;
18398
18410
  }
18399
18411
  `;
18400
18412
  })
18401
18413
  .join('')}
18402
- ${this.showHelper &&
18403
- /* css */ `
18404
- #${this.gridId} .grid--helper :nth-child(-n+${bp.cols}) {
18405
- display: block !important;
18406
- }
18407
- `}
18414
+ ${this.showHelper
18415
+ ? /* css */ `
18416
+ [cache-key="${this.cacheKey}"] .grid--helper :nth-child(-n+${bp.cols}) {
18417
+ display: block !important;
18418
+ }
18419
+ `
18420
+ : ''}
18408
18421
  }
18409
18422
  `)
18410
18423
  .join('')}
@@ -18476,7 +18489,7 @@ class Grid {
18476
18489
  this.constructSizeArray();
18477
18490
  }
18478
18491
  render() {
18479
- return (hAsync(Host, null, hAsync("div", { part: "grid", class: "grid", id: this.gridId }, hAsync("slot", null)), this.showHelper && (hAsync("div", { class: "grid grid--helper", part: "helper" }, [...Array(24)].map(() => (hAsync("div", { class: "grid__helper-item" })))))));
18492
+ return (hAsync(Host, null, hAsync("div", { part: "grid", class: "grid", "cache-key": this.cacheKey }, hAsync("slot", null)), this.showHelper && (hAsync("div", { class: "grid grid--helper", part: "helper" }, [...Array(24)].map(() => (hAsync("div", { class: "grid__helper-item" })))))));
18480
18493
  }
18481
18494
  static get watchers() { return {
18482
18495
  "sTpl": ["constructSizeArray"],
@@ -20038,7 +20051,10 @@ class NavItem {
20038
20051
  if (!this.hasSecondarySlot || !this.didOpen)
20039
20052
  return;
20040
20053
  this.open = false;
20041
- await displayTransition(this.secondaryDiv, 'open', false);
20054
+ await displayTransition(this.secondaryDiv, {
20055
+ className: 'open',
20056
+ show: false,
20057
+ });
20042
20058
  this.nanoClosing.emit({ secondaryMenu: this.secondaryDiv });
20043
20059
  this.didOpen = false;
20044
20060
  };
@@ -20050,7 +20066,10 @@ class NavItem {
20050
20066
  if (!this.hasSecondarySlot || this.didOpen)
20051
20067
  return;
20052
20068
  this.open = true;
20053
- await displayTransition(this.secondaryDiv, 'open', true);
20069
+ await displayTransition(this.secondaryDiv, {
20070
+ className: 'open',
20071
+ show: true,
20072
+ });
20054
20073
  this.nanoOpening.emit({ secondaryMenu: this.secondaryDiv });
20055
20074
  this.didOpen = true;
20056
20075
  };
@@ -28662,12 +28681,18 @@ class TabGroup {
28662
28681
  hideRightBtn() {
28663
28682
  if (!this.rightBtn)
28664
28683
  return;
28665
- displayTransition(this.rightBtn, 'is-shown', !this.hideControlRight);
28684
+ displayTransition(this.rightBtn, {
28685
+ className: 'is-shown',
28686
+ show: !this.hideControlRight,
28687
+ });
28666
28688
  }
28667
28689
  hideLeftBtn() {
28668
28690
  if (!this.leftBtn)
28669
28691
  return;
28670
- displayTransition(this.leftBtn, 'is-shown', !this.hideControlLeft);
28692
+ displayTransition(this.leftBtn, {
28693
+ className: 'is-shown',
28694
+ show: !this.hideControlLeft,
28695
+ });
28671
28696
  }
28672
28697
  watchScrollControls() {
28673
28698
  if (this.hasScrollControls)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nanoporetech-digital/components",
3
- "version": "5.8.1",
3
+ "version": "5.8.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://git.oxfordnanolabs.local/Digital/nano-components"
@@ -131,7 +131,7 @@
131
131
  "nanopore",
132
132
  "digital"
133
133
  ],
134
- "gitHead": "fed5a165db8918f46d56956446b279a735c3e546",
134
+ "gitHead": "7b65fb267760ce988dad75e884a2b372737d085b",
135
135
  "volta": {
136
136
  "node": "14.18.1",
137
137
  "npm": "8.6.0"
@@ -1 +0,0 @@
1
- {"file":"table.worker-ba6685a0.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":[],"sourcesContent":[],"version":3}
@@ -1,48 +0,0 @@
1
- /*!
2
- * Web Components for Nanopore digital Web Apps
3
- */
4
- 'use strict';
5
-
6
- /**
7
- * Quality of life for transition handling.
8
- * Adds / removes transitionend events. Resolves on complete
9
- */
10
- /**
11
- * handles hiding and showing elements properly (with display),
12
- * along with transitions, so they are no longer viewable in the dom.
13
- * - OnHide remove show class, listen for transition end, then display: none on finish
14
- * - OnShow, display block on start then add a show class
15
- * @param el
16
- * @param className
17
- * @param show
18
- * @returns a promise of resolving as either 'show' or 'hidden'
19
- */
20
- const displayTransition = (el, className, show = true, showDisplay = 'block') => {
21
- return new Promise((resolve) => {
22
- if (show) {
23
- el.addEventListener('transitionend', (e) => {
24
- if (e.target === el ||
25
- e.composedPath().some((el) => el === e.target)) {
26
- resolve('shown');
27
- }
28
- }, { once: true });
29
- el.style.display = showDisplay;
30
- el.dataset.displayTransition = 'true';
31
- setTimeout(() => el.classList.add(className), 20);
32
- }
33
- else {
34
- el.addEventListener('transitionend', (e) => {
35
- if (e.target === el ||
36
- e.composedPath().some((el) => el === e.target)) {
37
- el.style.display = 'none';
38
- resolve('hidden');
39
- }
40
- }, { once: true });
41
- el.classList.remove(className);
42
- }
43
- });
44
- };
45
-
46
- exports.displayTransition = displayTransition;
47
-
48
- //# sourceMappingURL=transitions-1205f12b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/**\n * Quality of life for transition handling.\n * Adds / removes transitionend events. Resolves on complete\n */\nexport const transitionDone = (\n el: HTMLElement\n): Promise<'shown' | 'hidden'> => {\n return new Promise((resolve) => {\n const callback = () => {\n el.removeEventListener('transitionend', callback);\n resolve;\n };\n el.addEventListener('transitionend', callback);\n // ??\n });\n};\n\n/**\n * handles hiding and showing elements properly (with display),\n * along with transitions, so they are no longer viewable in the dom.\n * - OnHide remove show class, listen for transition end, then display: none on finish\n * - OnShow, display block on start then add a show class\n * @param el\n * @param className\n * @param show\n * @returns a promise of resolving as either 'show' or 'hidden'\n */\nexport const displayTransition = (\n el: HTMLElement,\n className: string,\n show: boolean = true,\n showDisplay: string = 'block'\n): Promise<'shown' | 'hidden'> => {\n return new Promise((resolve) => {\n if (show) {\n el.addEventListener(\n 'transitionend',\n (e: Event) => {\n if (\n e.target === el ||\n e.composedPath().some((el) => el === e.target)\n ) {\n resolve('shown');\n }\n },\n { once: true }\n );\n el.style.display = showDisplay;\n el.dataset.displayTransition = 'true';\n setTimeout(() => el.classList.add(className), 20);\n } else {\n el.addEventListener(\n 'transitionend',\n (e: Event) => {\n if (\n e.target === el ||\n e.composedPath().some((el) => el === e.target)\n ) {\n el.style.display = 'none';\n resolve('hidden');\n }\n },\n { once: true }\n );\n el.classList.remove(className);\n }\n });\n};\n"],"version":3}
@@ -1 +0,0 @@
1
- {"file":"table.worker-ca7b069b.js","mappings":";;;;;;;;;;;;;;;;;;;","names":[],"sources":[],"sourcesContent":[],"version":3}
@@ -1,46 +0,0 @@
1
- /*!
2
- * Web Components for Nanopore digital Web Apps
3
- */
4
- /**
5
- * Quality of life for transition handling.
6
- * Adds / removes transitionend events. Resolves on complete
7
- */
8
- /**
9
- * handles hiding and showing elements properly (with display),
10
- * along with transitions, so they are no longer viewable in the dom.
11
- * - OnHide remove show class, listen for transition end, then display: none on finish
12
- * - OnShow, display block on start then add a show class
13
- * @param el
14
- * @param className
15
- * @param show
16
- * @returns a promise of resolving as either 'show' or 'hidden'
17
- */
18
- const displayTransition = (el, className, show = true, showDisplay = 'block') => {
19
- return new Promise((resolve) => {
20
- if (show) {
21
- el.addEventListener('transitionend', (e) => {
22
- if (e.target === el ||
23
- e.composedPath().some((el) => el === e.target)) {
24
- resolve('shown');
25
- }
26
- }, { once: true });
27
- el.style.display = showDisplay;
28
- el.dataset.displayTransition = 'true';
29
- setTimeout(() => el.classList.add(className), 20);
30
- }
31
- else {
32
- el.addEventListener('transitionend', (e) => {
33
- if (e.target === el ||
34
- e.composedPath().some((el) => el === e.target)) {
35
- el.style.display = 'none';
36
- resolve('hidden');
37
- }
38
- }, { once: true });
39
- el.classList.remove(className);
40
- }
41
- });
42
- };
43
-
44
- export { displayTransition as d };
45
-
46
- //# sourceMappingURL=transitions-686c5fec.js.map
@@ -1 +0,0 @@
1
- {"file":"transitions-686c5fec.js","mappings":";;;AAAA;;;;AAiBA;;;;;;;;;;MAUa,iBAAiB,GAAG,CAC/B,EAAe,EACf,SAAiB,EACjB,OAAgB,IAAI,EACpB,cAAsB,OAAO;EAE7B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO;IACzB,IAAI,IAAI,EAAE;MACR,EAAE,CAAC,gBAAgB,CACjB,eAAe,EACf,CAAC,CAAQ;QACP,IACE,CAAC,CAAC,MAAM,KAAK,EAAE;UACf,CAAC,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,EAC9C;UACA,OAAO,CAAC,OAAO,CAAC,CAAC;SAClB;OACF,EACD,EAAE,IAAI,EAAE,IAAI,EAAE,CACf,CAAC;MACF,EAAE,CAAC,KAAK,CAAC,OAAO,GAAG,WAAW,CAAC;MAC/B,EAAE,CAAC,OAAO,CAAC,iBAAiB,GAAG,MAAM,CAAC;MACtC,UAAU,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC;KACnD;SAAM;MACL,EAAE,CAAC,gBAAgB,CACjB,eAAe,EACf,CAAC,CAAQ;QACP,IACE,CAAC,CAAC,MAAM,KAAK,EAAE;UACf,CAAC,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,EAC9C;UACA,EAAE,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;UAC1B,OAAO,CAAC,QAAQ,CAAC,CAAC;SACnB;OACF,EACD,EAAE,IAAI,EAAE,IAAI,EAAE,CACf,CAAC;MACF,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;KAChC;GACF,CAAC,CAAC;AACL;;;;","names":[],"sources":["./src/utils/transitions.ts"],"sourcesContent":["/**\n * Quality of life for transition handling.\n * Adds / removes transitionend events. Resolves on complete\n */\nexport const transitionDone = (\n el: HTMLElement\n): Promise<'shown' | 'hidden'> => {\n return new Promise((resolve) => {\n const callback = () => {\n el.removeEventListener('transitionend', callback);\n resolve;\n };\n el.addEventListener('transitionend', callback);\n // ??\n });\n};\n\n/**\n * handles hiding and showing elements properly (with display),\n * along with transitions, so they are no longer viewable in the dom.\n * - OnHide remove show class, listen for transition end, then display: none on finish\n * - OnShow, display block on start then add a show class\n * @param el\n * @param className\n * @param show\n * @returns a promise of resolving as either 'show' or 'hidden'\n */\nexport const displayTransition = (\n el: HTMLElement,\n className: string,\n show: boolean = true,\n showDisplay: string = 'block'\n): Promise<'shown' | 'hidden'> => {\n return new Promise((resolve) => {\n if (show) {\n el.addEventListener(\n 'transitionend',\n (e: Event) => {\n if (\n e.target === el ||\n e.composedPath().some((el) => el === e.target)\n ) {\n resolve('shown');\n }\n },\n { once: true }\n );\n el.style.display = showDisplay;\n el.dataset.displayTransition = 'true';\n setTimeout(() => el.classList.add(className), 20);\n } else {\n el.addEventListener(\n 'transitionend',\n (e: Event) => {\n if (\n e.target === el ||\n e.composedPath().some((el) => el === e.target)\n ) {\n el.style.display = 'none';\n resolve('hidden');\n }\n },\n { once: true }\n );\n el.classList.remove(className);\n }\n });\n};\n"],"version":3}
@@ -1,5 +0,0 @@
1
- /*!
2
- * Web Components for Nanopore digital Web Apps
3
- */
4
- import{h as i,g as t,a as e,r as n,c as s}from"./p-d6a04b3a.js";const r=(()=>{try{return!!new CSSStyleSheet}catch(i){return false}})();const o=new WeakMap;function h(n={}){return(s,h)=>{if(!n.cacheKeyProperty){n.cacheKeyProperty=h}const{componentWillLoad:d,render:u,componentWillRender:g}=s;if(!d)console.warn(`ConstructibleStyle requires you to have a \`componentWillLoad\` lifecycle method in \`${s.constructor.name}\`. Failure to add this function may cause ConstructibleStyle to fail due to StencilJS build optimizations.`);if(r){const i=i=>{if(!i[n.cacheKeyProperty]||o.get(i)&&o.get(i)===i[n.cacheKeyProperty])return;o.set(i,i[n.cacheKeyProperty]);const e=t(i);const r=typeof i[h]==="function"?i[h]():i[h];const a=e.shadowRoot||document;a.adoptedStyleSheets=[...a.adoptedStyleSheets||[],c(i,s,r,n)]};s.componentWillLoad=function(){const t=d&&d.call(this);i(this);return t};s.componentWillRender=function(){const t=g&&g.call(this);i(this);return t}}else{s.render=function(){const t=typeof this[h]==="function"?this[h]():this[h];let n=u.call(this);if(l(n)){a(n,s.constructor.name,t)}else{n=i(e,null,n);if(!("attachShadow"in HTMLElement.prototype)){a(n,s.constructor.name,t)}else{if(!s.__constructableStyle){const i=document.createElement("style");i.setAttribute("type","text/css");i.setAttribute("constructible-style",s.constructor.name);i.innerHTML=t;s.__constructableStyle=i;document.head.appendChild(i)}}}return n}}}}function a(t,e,n){(d(t)||[]).push(i("style",{type:"text/css","constructible-style":e},n))}function c(i,t,e,n){if(!t.__constructableStyle){t.__constructableStyle={}}const s=i[n.cacheKeyProperty];if(!t.__constructableStyle[s]){t.__constructableStyle[s]=new CSSStyleSheet;t.__constructableStyle[s].replace(e)}return t.__constructableStyle[s]}function l(i){for(const t in i){if(i.hasOwnProperty(t)){if(i[t]===e){return true}}}return false}function d(i){for(const t in i){if(i.hasOwnProperty(t)){if(Array.isArray(i[t])){return i[t]}}}}const u=':host{box-sizing:border-box}*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}:host{--grid-col-gap:var(--nano-spacing-medium, 16px);--grid-row-gap:var(--nano-spacing-medium, 16px);--current-grid-size:"grid size: s";container-type:inline-size;display:block}:host .grid{display:grid;gap:var(--grid-row-gap) var(--grid-col-gap);block-size:inherit;min-block-size:inherit}:host([show-helper]:not([show-helper=false])){position:relative}:host([show-helper]:not([show-helper=false])) .grid--helper{position:absolute;inset:0;pointer-events:none}:host([show-helper]:not([show-helper=false])) .grid--helper::before{content:var(--current-grid-size);font-size:30px;position:absolute;inline-size:100%;inset-inline-start:0;text-align:center;inset-block-start:50%;transform:translateY(-50%);color:rgba(0, 0, 0, 0.2);text-transform:uppercase;z-index:99;pointer-events:none}:host([show-helper]:not([show-helper=false])) .grid__helper-item{display:none;background:rgba(126, 195, 241, 0.25)}';var g=undefined&&undefined.__decorate||function(i,t,e,n){var s=arguments.length,r=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,o;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(i,t,e,n);else for(var h=i.length-1;h>=0;h--)if(o=i[h])r=(s<3?o(r):s>3?o(t,e,r):o(t,e))||r;return s>3&&r&&Object.defineProperty(t,e,r),r};var p=undefined&&undefined.__metadata||function(i,t){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(i,t)};let f=0;const m=class{constructor(i){n(this,i);this.grids=[];this.gridId="nano-grid-"+f++;this.styles=()=>{const i=`\n ${this.grids.map((i=>`\n @container (min-width: ${typeof i.breakpoint==="number"?i.breakpoint+1+"px":i.breakpoint}) {\n #${this.gridId}.grid {\n --current-grid-size: "grid size: ${i.name}";\n ${i.template?`grid-template: ${i.template};`:`grid-template-columns: repeat(${i.cols}, minmax(calc((100% / ${i.cols}) - var(--grid-col-gap)), 1fr));`}\n }\n ${[...Array(i.cols)].map(((t,e)=>{const n=e+1;return`\n #${this.gridId}.grid > [grid-states~="${i.name}-col-start-${n}"],\n ::slotted([grid-states~="${i.name}-col-start-${n}"]) {\n grid-column-start: ${n} !important;\n }\n #${this.gridId}.grid > [grid-states~="${i.name}-col-span-${n}"],\n ::slotted([grid-states~="${i.name}-col-span-${n}"]) {\n grid-column-end: span ${n} !important;\n }\n `})).join("")}\n ${[...Array(24)].map(((t,e)=>{const n=e+1;return`\n #${this.gridId}.grid > [grid-states~="${i.name}-row-start-${n}"],\n ::slotted([grid-states~="${i.name}-row-start-${n}"]) {\n grid-row-start: ${n} !important;\n }\n #${this.gridId}.grid > [grid-states~="${i.name}-row-span-${n}"],\n ::slotted([grid-states~="${i.name}-row-span-${n}"]) {\n grid-row-end: span ${n} !important;\n }\n `})).join("")}\n ${this.showHelper&&`\n #${this.gridId} .grid--helper :nth-child(-n+${i.cols}) {\n display: block !important;\n }\n `}\n }\n `)).join("")}\n `;return i};this.cacheKey=undefined;this.sSize=300;this.mSize=550;this.lSize=800;this.xlSize=1e3;this.sCols=undefined;this.mCols=undefined;this.lCols=undefined;this.xlCols=undefined;this.xxlCols=undefined;this.sTpl=undefined;this.mTpl=undefined;this.lTpl=undefined;this.xlTpl=undefined;this.xxlTpl=undefined;this.showHelper=false}constructSizeArray(){this.grids=[];if(this.sCols)this.grids.push({cols:this.sCols,breakpoint:0,name:"s",template:this.sTpl});if(this.mCols)this.grids.push({cols:this.mCols,breakpoint:this.sSize,name:"m",template:this.mTpl});if(this.lCols)this.grids.push({cols:this.lCols,breakpoint:this.mSize,name:"l",template:this.lTpl});if(this.xlCols)this.grids.push({cols:this.xlCols,breakpoint:this.lSize,name:"xl",template:this.xlTpl});if(this.xxlCols)this.grids.push({cols:this.xxlCols,breakpoint:this.xlSize,name:"xxl",template:this.xxlTpl});this.cacheKey=this.grids.map((i=>`${i.cols}-${i.breakpoint}-${i.template||""}`)).join("")+"-helper-"+this.showHelper}componentWillLoad(){this.constructSizeArray()}render(){return i(e,null,i("div",{part:"grid",class:"grid",id:this.gridId},i("slot",null)),this.showHelper&&i("div",{class:"grid grid--helper",part:"helper"},[...Array(24)].map((()=>i("div",{class:"grid__helper-item"})))))}static get watchers(){return{sTpl:["constructSizeArray"],mTpl:["constructSizeArray"],lTpl:["constructSizeArray"],xlTpl:["constructSizeArray"],xxlTpl:["constructSizeArray"],sSize:["constructSizeArray"],mSize:["constructSizeArray"],lSize:["constructSizeArray"],xlSize:["constructSizeArray"],sCols:["constructSizeArray"],mCols:["constructSizeArray"],lCols:["constructSizeArray"],xlCols:["constructSizeArray"],xxlCols:["constructSizeArray"],showHelper:["constructSizeArray"]}}};g([h({cacheKeyProperty:"cacheKey"}),p("design:type",Object)],m.prototype,"styles",void 0);m.style=u;const b=":host{box-sizing:border-box}*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}:host{--padding:0;display:inline-block;object-fit:cover;object-position:center;background-size:cover;background-position:center}:host *{border-radius:inherit}:host([background]:not([background=false])){display:block}.img{position:relative;object-fit:inherit;object-position:inherit;background-color:inherit;background-position:inherit;background-size:inherit;background-origin:inherit;background-attachment:inherit;background-repeat:inherit;flex:1 1 100%;display:flex;flex-direction:column;min-block-size:inherit;max-block-size:inherit;max-inline-size:inherit;min-height:inherit;min-width:inherit;block-size:inherit;inline-size:inherit;height:inherit;width:inherit;max-height:inherit;max-width:inherit;aspect-ratio:inherit}.img__loader,.img__observer{position:absolute;inset:0;block-size:100%;inline-size:100%;z-index:-1}.img__image,.img__bg{border-radius:inherit;display:block;opacity:0;transition:0.5s ease opacity, 0.3s ease filter 0.4s;filter:blur(5px);flex:1}.img__image.loaded,.img__bg.loaded{opacity:1;filter:blur(0)}@media not all and (min-resolution: 0.001dpcm){@supports (-webkit-appearance: none){.img__image.loaded,.img__bg.loaded{filter:blur(0)}}}.img__image{object-fit:inherit;object-position:inherit;max-inline-size:100%;min-block-size:inherit;max-block-size:inherit;min-height:inherit;min-width:inherit;block-size:auto;inline-size:inherit;height:inherit;width:inherit;max-height:inherit;max-width:inherit;aspect-ratio:inherit}.img__image.hide{visibility:hidden}.img__image.hide.no-height{block-size:1px;position:absolute;z-index:-1}.img__bg{background-color:inherit;background-position:inherit;background-size:inherit;background-origin:inherit;background-attachment:inherit;background-repeat:inherit;overflow:auto;padding:var(--padding)}.img__bg.no-height{position:absolute;inset:0}";const y=class{constructor(i){n(this,i);this.nanoImgWillLoad=s(this,"nanoImgWillLoad",7);this.nanoImgDidLoad=s(this,"nanoImgDidLoad",7);this.nanoImgError=s(this,"nanoImgError",7);this._srcSet={};this.onLoad=()=>{this.nanoImgDidLoad.emit();setTimeout((()=>this.hasLoaded=true),50)};this.onError=()=>{this.nanoImgError.emit()};this.onResize=i=>{Object.entries(i.detail).forEach((([i,t])=>{this._srcSet[i].active=t}));const t=[];Object.keys(this._srcSet).sort().forEach((i=>{if(this._srcSet[i].active)t.push(this._srcSet[i].src)}));if(t.length)this._src=t.slice(-1)[0];else this._src=this.src};this.loadSrc=undefined;this.loadError=undefined;this.hasLoaded=false;this.imgStates=null;this._src=undefined;this.alt=undefined;this.src=undefined;this.srcSet=undefined;this.lazy=true;this.background=undefined;this.autoHeight="content"}_srcChanged(){this.hasLoaded=false;this.addIO()}srcChanged(){this._src=this.src}srcSetChanged(){if(!this.srcSet)return;delete this._srcSet;this._srcSet={};this.imgStates=this.srcSet.split(",").map((i=>{const[t,e]=i.split(" ").filter((i=>i.length));this._srcSet[t]={src:e,active:false};return t})).join(", ")}lazyChanged(){if(!this.lazy)this.load()}addIO(){if(!this._src||this.hasLoaded)return;if(!this.lazy){this.load();return}if(typeof window!=="undefined"&&"IntersectionObserver"in window){this.removeIO();this.io=new IntersectionObserver((i=>{if(i[0].isIntersecting){this.load();this.removeIO()}}));this.io.observe(this.host)}else setTimeout((()=>this.load()),200)}load(){this.loadError=this.onError;this.loadSrc=this._src;this.nanoImgWillLoad.emit()}removeIO(){if(this.io){this.io.disconnect();this.io=undefined}}connectedCallback(){this.srcChanged();this.srcSetChanged();this.lazyChanged()}componentDidLoad(){this.addIO()}disconnectedCallback(){this.removeIO()}render(){const t=!!this.loadSrc?{"background-image":`url(${this.loadSrc})`}:{};return i("div",{class:"img"},i("nano-skeleton",{class:"img__loader"}),!!this.background&&i("div",{class:{loaded:this.hasLoaded,img__bg:true,"no-height":this.autoHeight==="image"},style:t},i("slot",null)),i("img",{class:{img__image:true,loaded:this.hasLoaded,hide:this.background,"no-height":this.autoHeight==="content"},decoding:"async",src:this.loadSrc,loading:undefined,alt:this.alt,onLoad:this.onLoad,onError:this.loadError}),i("nano-resize-observe",{class:"img__observer",onNanoResizeStateChange:this.onResize,states:this.imgStates}))}get host(){return t(this)}static get watchers(){return{_src:["_srcChanged"],src:["srcChanged"],srcSet:["srcSetChanged"],lazy:["lazyChanged"]}}};y.style=b;export{m as nano_grid,y as nano_img};
5
- //# sourceMappingURL=p-20086faa.entry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["supportsConstructibleStylesheets","CSSStyleSheet","e","cacheKeys","WeakMap","ConstructibleStyle","opts","target","propertyKey","cacheKeyProperty","componentWillLoad","render","componentWillRender","console","warn","constructor","name","addStylesheet","instance","get","set","host","getElement","cssText","root","shadowRoot","document","adoptedStyleSheets","getOrCreateStylesheet","willLoadResult","call","this","willRenderResult","renderedNode","isHost","appendStyleToHost","h","Host","HTMLElement","prototype","__constructableStyle","style","createElement","setAttribute","innerHTML","head","appendChild","node","targetName","getHostChildren","push","type","key","replace","prop","hasOwnProperty","Array","isArray","gridCss","gridId","Grid","grids","styles","css","map","bp","breakpoint","template","cols","_","i","gItm","join","showHelper","constructSizeArray","sCols","sTpl","mCols","sSize","mTpl","lCols","mSize","lTpl","xlCols","lSize","xlTpl","xxlCols","xlSize","xxlTpl","cacheKey","part","class","id","__decorate","imgCss","Img","_srcSet","onLoad","nanoImgDidLoad","emit","setTimeout","hasLoaded","onError","nanoImgError","onResize","Object","entries","detail","forEach","active","srcOpts","keys","sort","src","length","_src","slice","_srcChanged","addIO","srcChanged","srcSetChanged","srcSet","imgStates","split","bpSrc","filter","lazyChanged","lazy","load","window","removeIO","io","IntersectionObserver","data","isIntersecting","observe","loadError","loadSrc","nanoImgWillLoad","disconnect","undefined","connectedCallback","componentDidLoad","disconnectedCallback","bgStyle","background","loaded","img__bg","autoHeight","img__image","hide","decoding","loading","alt","onNanoResizeStateChange","states"],"sources":["./src/utils/constructible-style.tsx","./src/components/grid/grid.scss?tag=nano-grid&encapsulation=shadow","./src/components/grid/grid.tsx","./src/components/img/img.scss?tag=nano-img&encapsulation=shadow","./src/components/img/img.tsx"],"sourcesContent":["import { h, Host, getElement, VNode, ComponentInterface } from '@stencil/core';\n// import type { VNode, HTMLStencilElement } from \"@stencil/core\";\n\nconst supportsConstructibleStylesheets = (() => {\n try {\n return !!new CSSStyleSheet();\n } catch (e) {\n return false;\n }\n})();\n\nconst cacheKeys: WeakMap<ComponentInterface, string> = new WeakMap();\n\ndeclare type ConstructibleStyleDecorator = (\n target: ComponentInterface,\n propertyKey: string\n) => void;\n\n/**\n * Dynamically create a constructible stylesheet which is applied to the component.\n * The stylesheet is then cached for future instances of the component.\n * @usage\nAs a string:\n```\n@ConstructableStyle() style = `.bg { background: url('assets/${ this.mode }/bg.png'); }`;\n```\nAs a function:\n```\n@ConstructableStyle() style = () => `.bg { background: url('assets/${ this.mode }/bg.png'); }`;\n```\n * @param opts - optional `cacheKeyProperty` - in case an instance of a component could produce different styles based on variables.\n * @returns `@ConstructableStyle` decorator\n */\nexport function ConstructibleStyle(\n opts: ConstructibleStyleOptions = {}\n): ConstructibleStyleDecorator {\n return (target: ComponentInterface, propertyKey: string) => {\n if (!opts.cacheKeyProperty) {\n opts.cacheKeyProperty = propertyKey;\n }\n\n const { componentWillLoad, render, componentWillRender } = target;\n if (!componentWillLoad)\n console.warn(\n `ConstructibleStyle requires you to have a \\`componentWillLoad\\` lifecycle method in \\`${target.constructor.name}\\`. Failure to add this function may cause ConstructibleStyle to fail due to StencilJS build optimizations.`\n );\n\n if (supportsConstructibleStylesheets) {\n const addStylesheet = (instance: ComponentInterface) => {\n if (\n !instance[opts.cacheKeyProperty] ||\n (cacheKeys.get(instance) &&\n cacheKeys.get(instance) === instance[opts.cacheKeyProperty])\n )\n return;\n\n cacheKeys.set(instance, instance[opts.cacheKeyProperty]);\n const host = getElement(instance);\n const cssText =\n typeof instance[propertyKey] === 'function'\n ? instance[propertyKey]()\n : instance[propertyKey];\n const root = (host.shadowRoot || document) as any;\n root.adoptedStyleSheets = [\n ...(root.adoptedStyleSheets || []),\n getOrCreateStylesheet(instance, target, cssText, opts),\n ];\n };\n\n target.componentWillLoad = function () {\n const willLoadResult =\n componentWillLoad && componentWillLoad.call(this);\n addStylesheet(this);\n return willLoadResult;\n };\n\n target.componentWillRender = function () {\n const willRenderResult =\n componentWillRender && componentWillRender.call(this);\n addStylesheet(this);\n return willRenderResult;\n };\n } else {\n target.render = function () {\n const cssText =\n typeof this[propertyKey] === 'function'\n ? this[propertyKey]()\n : this[propertyKey];\n let renderedNode: VNode = render.call(this);\n\n if (isHost(renderedNode)) {\n appendStyleToHost(renderedNode, target.constructor.name, cssText);\n } else {\n renderedNode = <Host>{renderedNode}</Host>;\n\n if (!('attachShadow' in HTMLElement.prototype)) {\n appendStyleToHost(renderedNode, target.constructor.name, cssText);\n } else {\n if (!target.__constructableStyle) {\n const style = document.createElement('style');\n style.setAttribute('type', 'text/css');\n style.setAttribute(\n 'constructible-style',\n target.constructor.name\n );\n style.innerHTML = cssText;\n target.__constructableStyle = style;\n document.head.appendChild(style);\n }\n }\n }\n\n return renderedNode;\n };\n }\n };\n}\n\nfunction appendStyleToHost(node, targetName, cssText) {\n (getHostChildren(node) || []).push(\n <style type=\"text/css\" constructible-style={targetName}>\n {cssText}\n </style>\n );\n}\n\nfunction getOrCreateStylesheet(\n instance: ComponentInterface,\n target: ComponentInterface,\n cssText: string,\n opts: ConstructibleStyleOptions\n): CSSStyleSheet {\n if (!target.__constructableStyle) {\n target.__constructableStyle = {};\n }\n\n const key = instance[opts.cacheKeyProperty];\n\n if (!target.__constructableStyle[key]) {\n target.__constructableStyle[key] = new CSSStyleSheet();\n target.__constructableStyle[key].replace(cssText);\n }\n\n return target.__constructableStyle[key];\n}\n\nfunction isHost(node): boolean {\n for (const prop in node) {\n if (node.hasOwnProperty(prop)) {\n if (node[prop] === Host) {\n return true;\n }\n }\n }\n return false;\n}\n\nfunction getHostChildren(node): Array<VNode> {\n for (const prop in node) {\n if (node.hasOwnProperty(prop)) {\n if (Array.isArray(node[prop])) {\n return node[prop];\n }\n }\n }\n}\n\nexport interface ConstructibleStyleOptions {\n /**\n * Set this in case an instance of a component could produce different styles based on variables.\n * This will ensure that you get new styles for each mode.\n * @example\n```\n@Prop() mode: string;\n@ConstructableStyle({ cacheKeyProperty: \"mode\" }) style = `.bg { background: url('assets/${ this.mode }/bg.png'); }`;\n```\n */\n cacheKeyProperty?: string;\n}\n","@use 'sass:math';\n\n@import '../../global/style/nano-theme/base';\n\n:host {\n /**\n * @prop --grid-col-gap: gap between all columns. Defaults to theme's global padding\n * @prop --grid-row-gap: gap between all rows. Defaults to theme's global padding\n */\n\n --grid-col-gap: #{$spacing-medium};\n --grid-row-gap: #{$spacing-medium};\n --current-grid-size: \"grid size: s\";\n\n container-type: inline-size;\n display: block;\n\n .grid {\n display: grid;\n gap: var(--grid-row-gap) var(--grid-col-gap);\n block-size: inherit;\n min-block-size: inherit;\n }\n}\n\n:host([show-helper]:not([show-helper='false'])) {\n position: relative;\n\n .grid--helper {\n position: absolute;\n inset: 0;\n pointer-events: none;\n\n &::before {\n content: var(--current-grid-size);\n font-size: 30px;\n position: absolute;\n inline-size: 100%;\n inset-inline-start: 0;\n text-align: center;\n inset-block-start: 50%;\n transform: translateY(-50%);\n color: rgb(0 0 0 / 20%);\n text-transform: uppercase;\n z-index: 99;\n pointer-events: none;\n }\n }\n\n .grid__helper-item {\n display: none;\n background: hsl(204deg 80% 72% / 25%);\n }\n}\n","import { Component, h, Prop, Host, State, Watch } from '@stencil/core';\nimport { ConstructibleStyle } from '../../utils/constructible-style';\n\nlet gridId = 0;\n\n/**\n * A lightweight, context-aware CSS grid implementation.\n *\n * - Define multiple grids templates at different breakpoints\n * - Uses `@container` queries to select the correct grid depending on the current dimensions\n * - Use `grid-states=\"...\"` on direct descendants for `column` / `row` - `start` / `end`\n * - SSR optimised\n\n * @part grid - the main grid element.\n * Use this to set css such as `justify-items|content` / `align-items|content` / `place-content`\n * @part helper - a replica grid showed when `show-helper` is true\n *\n * @slot - default slot. Use this to place grid items. Use `grid-states=\"...\"` attribute to opt-out of auto / sequential placement.\n */\n@Component({\n tag: 'nano-grid',\n styleUrl: 'grid.scss',\n shadow: true,\n})\nexport class Grid {\n private grids: {\n cols: number;\n breakpoint: number | string;\n name: string;\n template?: string;\n }[] = [];\n private gridId = 'nano-grid-' + gridId++;\n @State() cacheKey: string;\n\n /** the component's small breakpoint. Note - all breakpoints are based on component width, not screen width.\n * Will default to `px` if no unit supplied e.g. `20rem` */\n @Prop({ reflect: true }) sSize: number | string = 300;\n\n /** the component's medium breakpoint. Note - all breakpoints are based on component width, not screen width.\n * Will default to `px` if no unit supplied e.g. `20rem` */\n @Prop({ reflect: true }) mSize: number | string = 550;\n\n /** the component's large breakpoint. Note - all breakpoints are based on component width, not screen width.\n * Will default to `px` if no unit supplied e.g. `20rem` */\n @Prop({ reflect: true }) lSize: number | string = 800;\n\n /** the component's xl breakpoint. Note - all breakpoints are based on component width, not screen width.\n * Will default to `px` if no unit supplied e.g. `20rem` */\n @Prop({ reflect: true }) xlSize: number | string = 1000;\n\n /** the number of columns the grid has at the small breakpoint. */\n @Prop({ reflect: true }) sCols: number;\n\n /** the number of columns the grid has at the medium breakpoint. */\n @Prop({ reflect: true }) mCols: number;\n\n /** the number of columns the grid has at the large breakpoint. */\n @Prop({ reflect: true }) lCols: number;\n\n /** the number of columns the grid has at the xl breakpoint. */\n @Prop({ reflect: true }) xlCols: number;\n\n /** the number of columns the grid has at the xxl breakpoint (anything greater than the xl breakpoint) */\n @Prop({ reflect: true }) xxlCols: number;\n\n /** Optional small `grid-template`. *Note* - you must set `sCols` for this to take affect */\n @Prop() sTpl?: string;\n\n /** Optional medium `grid-template`. *Note* - you must set `mCols` for this to take affect */\n @Prop() mTpl?: string;\n\n /** Optional large `grid-template`. *Note* - you must set `lCols` for this to take affect */\n @Prop() lTpl?: string;\n\n /** Optional xl `grid-template`. *Note* - you must set `xlCols` for this to take affect */\n @Prop() xlTpl?: string;\n\n /** Optional xxl `grid-template`. *Note* - you must set `xxlCols` for this to take affect */\n @Prop() xxlTpl?: string;\n\n /** shows a grid helper to visualise where columns are */\n @Prop({ reflect: true }) showHelper: boolean = false;\n\n @Watch('sTpl')\n @Watch('mTpl')\n @Watch('lTpl')\n @Watch('xlTpl')\n @Watch('xxlTpl')\n @Watch('sSize')\n @Watch('mSize')\n @Watch('lSize')\n @Watch('xlSize')\n @Watch('sCols')\n @Watch('mCols')\n @Watch('lCols')\n @Watch('xlCols')\n @Watch('xxlCols')\n @Watch('showHelper')\n constructSizeArray() {\n this.grids = [];\n\n if (this.sCols)\n this.grids.push({\n cols: this.sCols,\n breakpoint: 0,\n name: 's',\n template: this.sTpl,\n });\n if (this.mCols)\n this.grids.push({\n cols: this.mCols,\n breakpoint: this.sSize,\n name: 'm',\n template: this.mTpl,\n });\n if (this.lCols)\n this.grids.push({\n cols: this.lCols,\n breakpoint: this.mSize,\n name: 'l',\n template: this.lTpl,\n });\n if (this.xlCols)\n this.grids.push({\n cols: this.xlCols,\n breakpoint: this.lSize,\n name: 'xl',\n template: this.xlTpl,\n });\n if (this.xxlCols)\n this.grids.push({\n cols: this.xxlCols,\n breakpoint: this.xlSize,\n name: 'xxl',\n template: this.xxlTpl,\n });\n\n this.cacheKey =\n this.grids\n .map((bp) => `${bp.cols}-${bp.breakpoint}-${bp.template || ''}`)\n .join('') +\n '-helper-' +\n this.showHelper;\n }\n\n @ConstructibleStyle({ cacheKeyProperty: 'cacheKey' }) protected styles =\n () => {\n const css = /* css */ `\n ${this.grids\n .map(\n (bp) => /* css */ `\n @container (min-width: ${\n typeof bp.breakpoint === 'number'\n ? bp.breakpoint + 1 + 'px'\n : bp.breakpoint\n }) {\n #${this.gridId}.grid {\n --current-grid-size: \"grid size: ${bp.name}\";\n ${\n bp.template\n ? `grid-template: ${bp.template};`\n : `grid-template-columns: repeat(${bp.cols}, minmax(calc((100% / ${bp.cols}) - var(--grid-col-gap)), 1fr));`\n }\n }\n ${[...Array(bp.cols)]\n .map((_, i) => {\n const gItm = i + 1;\n return /* css */ `\n #${this.gridId}.grid > [grid-states~=\"${bp.name}-col-start-${gItm}\"],\n ::slotted([grid-states~=\"${bp.name}-col-start-${gItm}\"]) {\n grid-column-start: ${gItm} !important;\n }\n #${this.gridId}.grid > [grid-states~=\"${bp.name}-col-span-${gItm}\"],\n ::slotted([grid-states~=\"${bp.name}-col-span-${gItm}\"]) {\n grid-column-end: span ${gItm} !important;\n }\n `;\n })\n .join('')}\n ${[...Array(24)]\n .map((_, i) => {\n const gItm = i + 1;\n return /* css */ `\n #${this.gridId}.grid > [grid-states~=\"${bp.name}-row-start-${gItm}\"],\n ::slotted([grid-states~=\"${bp.name}-row-start-${gItm}\"]) {\n grid-row-start: ${gItm} !important;\n }\n #${this.gridId}.grid > [grid-states~=\"${bp.name}-row-span-${gItm}\"],\n ::slotted([grid-states~=\"${bp.name}-row-span-${gItm}\"]) {\n grid-row-end: span ${gItm} !important;\n }\n `;\n })\n .join('')}\n ${\n this.showHelper &&\n /* css */ `\n #${this.gridId} .grid--helper :nth-child(-n+${bp.cols}) {\n display: block !important;\n }\n `\n }\n }\n `\n )\n .join('')}\n `;\n return css;\n };\n\n componentWillLoad() {\n this.constructSizeArray();\n }\n\n render() {\n return (\n <Host>\n <div part=\"grid\" class=\"grid\" id={this.gridId}>\n <slot />\n </div>\n {this.showHelper && (\n <div class=\"grid grid--helper\" part=\"helper\">\n {[...Array(24)].map(() => (\n <div class=\"grid__helper-item\" />\n ))}\n </div>\n )}\n </Host>\n );\n }\n}\n",":host {\n /**\n * @prop --padding: padding around any content. Only relevent on `<nano-img background>`\n */\n --padding: 0;\n\n display: inline-block;\n object-fit: cover;\n object-position: center;\n background-size: cover;\n background-position: center;\n\n * {\n border-radius: inherit;\n }\n}\n\n:host([background]:not([background='false'])) {\n display: block;\n}\n\n.img {\n position: relative;\n object-fit: inherit;\n object-position: inherit;\n background-color: inherit;\n background-position: inherit;\n background-size: inherit;\n background-origin: inherit;\n background-attachment: inherit;\n background-repeat: inherit;\n flex: 1 1 100%;\n display: flex;\n flex-direction: column;\n min-block-size: inherit;\n max-block-size: inherit;\n max-inline-size: inherit;\n min-height: inherit;\n min-width: inherit;\n block-size: inherit;\n inline-size: inherit;\n height: inherit;\n width: inherit;\n max-height: inherit;\n max-width: inherit;\n aspect-ratio: inherit;\n}\n\n.img__loader,\n.img__observer {\n position: absolute;\n inset: 0;\n block-size: 100%;\n inline-size: 100%;\n z-index: -1;\n}\n\n.img__image,\n.img__bg {\n border-radius: inherit;\n display: block;\n opacity: 0;\n transition: 0.5s ease opacity, 0.3s ease filter 0.4s;\n filter: blur(5px);\n flex: 1;\n\n &.loaded {\n opacity: 1;\n filter: blur(0);\n\n @media not all and (min-resolution: 0.001dpcm) {\n @supports (-webkit-appearance: none) {\n filter: blur(0);\n }\n }\n }\n}\n\n.img__image {\n object-fit: inherit;\n object-position: inherit;\n max-inline-size: 100%;\n min-block-size: inherit;\n max-block-size: inherit;\n min-height: inherit;\n min-width: inherit;\n block-size: auto;\n inline-size: inherit;\n height: inherit;\n width: inherit;\n max-height: inherit;\n max-width: inherit;\n aspect-ratio: inherit;\n\n &.hide {\n visibility: hidden;\n\n &.no-height {\n block-size: 1px;\n position: absolute;\n z-index: -1;\n }\n }\n}\n\n.img__bg {\n background-color: inherit;\n background-position: inherit;\n background-size: inherit;\n background-origin: inherit;\n background-attachment: inherit;\n background-repeat: inherit;\n overflow: auto;\n padding: var(--padding);\n\n &.no-height {\n position: absolute;\n inset: 0;\n }\n}\n","import {\n Component,\n Element,\n Event,\n EventEmitter,\n State,\n Prop,\n Watch,\n h,\n ComponentInterface,\n Build,\n} from '@stencil/core';\nimport type { ResizeStateChangeEventDetail } from '../../interface';\n\n/**\n * Img with benefits. Lazy loading. Simple `srcSet` solution for both `<img>` and `background-image` varieties.\n * @slot - Main slot. Only relevant with `<nano-img background>`\n */\n@Component({\n tag: 'nano-img',\n styleUrl: 'img.scss',\n shadow: true,\n})\nexport class Img implements ComponentInterface {\n private io?: IntersectionObserver;\n private _srcSet: { [key: string]: { src: string; active: boolean } } = {};\n\n @Element() host!: HTMLNanoImgElement;\n\n @State() loadSrc?: string;\n @State() loadError?: () => void;\n @State() hasLoaded: boolean = false;\n @State() imgStates: string = null;\n @State() _src: string;\n @Watch('_src')\n _srcChanged() {\n this.hasLoaded = false;\n this.addIO();\n }\n\n /** This attribute defines the alternative text describing the image.\n * Users will see this text displayed if the image URL is wrong, or if the image is not yet downloaded. */\n @Prop() alt?: string;\n\n /** The image URL. This attribute is mandatory for the `<img>` element. */\n @Prop() src!: string;\n @Watch('src')\n srcChanged() {\n this._src = this.src;\n }\n\n /** Optional list string providing media sizes with corresponding image srcs.\n * i.e. show img-x at 300px wide. Format `srcSet=\"200w src/imgSmall.jpg, 500h src/imgMed.png\"` */\n @Prop() srcSet?: string;\n @Watch('srcSet')\n srcSetChanged() {\n if (!this.srcSet) return;\n\n delete this._srcSet;\n this._srcSet = {};\n\n this.imgStates = this.srcSet\n .split(',')\n .map((bpSrc) => {\n const [bp, src] = bpSrc.split(' ').filter((bp) => bp.length);\n this._srcSet[bp] = { src: src, active: false };\n return bp;\n })\n .join(', ');\n }\n\n /** Render image lazily, when it comes into the browser viewport **/\n @Prop() lazy: boolean = true;\n @Watch('lazy')\n lazyChanged() {\n if (!this.lazy) this.load();\n }\n\n /** Render the image as a background image **/\n @Prop() background?: boolean;\n\n /** When the image is rendered as a background, and there is no preset dimensions of the component,\n * you can set how the component height will be set. Via image size or via the content **/\n @Prop() autoHeight: 'content' | 'image' = 'content';\n\n /** Emitted when the img src has been set */\n @Event() nanoImgWillLoad!: EventEmitter<void>;\n\n /** Emitted when the image has finished loading */\n @Event() nanoImgDidLoad!: EventEmitter<void>;\n\n /** Emitted when the img fails to load */\n @Event() nanoImgError!: EventEmitter<void>;\n\n private addIO() {\n if (!this._src || this.hasLoaded) return;\n if (!this.lazy) {\n this.load();\n return;\n }\n if (\n typeof (window as any) !== 'undefined' &&\n 'IntersectionObserver' in window\n ) {\n this.removeIO();\n this.io = new IntersectionObserver((data) => {\n if (data[0].isIntersecting) {\n this.load();\n this.removeIO();\n }\n });\n\n this.io.observe(this.host);\n } else setTimeout(() => this.load(), 200);\n }\n\n private load() {\n this.loadError = this.onError;\n this.loadSrc = this._src;\n this.nanoImgWillLoad.emit();\n }\n\n private onLoad = () => {\n this.nanoImgDidLoad.emit();\n setTimeout(() => (this.hasLoaded = true), 50);\n };\n\n private onError = () => {\n this.nanoImgError.emit();\n };\n\n private onResize = (e: { detail: ResizeStateChangeEventDetail }) => {\n Object.entries(e.detail).forEach(([bp, active]) => {\n this._srcSet[bp].active = active;\n });\n\n // sort and find the highest sized matching image.\n const srcOpts = [];\n Object.keys(this._srcSet)\n .sort()\n .forEach((bp) => {\n if (this._srcSet[bp].active) srcOpts.push(this._srcSet[bp].src);\n });\n\n if (srcOpts.length) this._src = srcOpts.slice(-1)[0];\n // no matching image? Set back to default\n else this._src = this.src;\n };\n\n private removeIO() {\n if (this.io) {\n this.io.disconnect();\n this.io = undefined;\n }\n }\n\n connectedCallback() {\n this.srcChanged();\n this.srcSetChanged();\n this.lazyChanged();\n }\n\n componentDidLoad() {\n this.addIO();\n }\n\n disconnectedCallback() {\n this.removeIO();\n }\n\n render() {\n const bgStyle = !!this.loadSrc\n ? { 'background-image': `url(${this.loadSrc})` }\n : {};\n\n return (\n <div class=\"img\">\n <nano-skeleton class=\"img__loader\"></nano-skeleton>\n {!!this.background && (\n <div\n class={{\n loaded: this.hasLoaded,\n img__bg: true,\n 'no-height': this.autoHeight === 'image',\n }}\n style={bgStyle}\n >\n <slot />\n </div>\n )}\n <img\n class={{\n img__image: true,\n loaded: this.hasLoaded,\n hide: this.background,\n 'no-height': this.autoHeight === 'content',\n }}\n decoding=\"async\"\n src={Build.isServer ? this.src : this.loadSrc}\n loading={Build.isServer && this.lazy ? 'lazy' : undefined}\n alt={this.alt}\n onLoad={this.onLoad}\n onError={this.loadError}\n />\n <nano-resize-observe\n class=\"img__observer\"\n onNanoResizeStateChange={this.onResize}\n states={this.imgStates}\n />\n </div>\n );\n }\n}\n"],"mappings":";;;gEAGA,MAAMA,EAAmC,MACvC,IACE,QAAS,IAAIC,a,CACb,MAAOC,GACP,OAAO,K,CAEV,EANwC,GAQzC,MAAMC,EAAiD,IAAIC,Q,SAsB3CC,EACdC,EAAkC,IAElC,MAAO,CAACC,EAA4BC,KAClC,IAAKF,EAAKG,iBAAkB,CAC1BH,EAAKG,iBAAmBD,C,CAG1B,MAAME,kBAAEA,EAAiBC,OAAEA,EAAMC,oBAAEA,GAAwBL,EAC3D,IAAKG,EACHG,QAAQC,KACN,yFAAyFP,EAAOQ,YAAYC,mHAGhH,GAAIhB,EAAkC,CACpC,MAAMiB,EAAiBC,IACrB,IACGA,EAASZ,EAAKG,mBACdN,EAAUgB,IAAID,IACbf,EAAUgB,IAAID,KAAcA,EAASZ,EAAKG,kBAE5C,OAEFN,EAAUiB,IAAIF,EAAUA,EAASZ,EAAKG,mBACtC,MAAMY,EAAOC,EAAWJ,GACxB,MAAMK,SACGL,EAASV,KAAiB,WAC7BU,EAASV,KACTU,EAASV,GACf,MAAMgB,EAAQH,EAAKI,YAAcC,SACjCF,EAAKG,mBAAqB,IACpBH,EAAKG,oBAAsB,GAC/BC,EAAsBV,EAAUX,EAAQgB,EAASjB,GAClD,EAGHC,EAAOG,kBAAoB,WACzB,MAAMmB,EACJnB,GAAqBA,EAAkBoB,KAAKC,MAC9Cd,EAAcc,MACd,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,B as e,h as o,g as i}from"./p-d6a04b3a.js";import{d as s}from"./p-f6de2d5d.js";const a=":host{box-sizing:border-box}*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}:host{font-family:inherit;font-size:inherit;font-stretch:inherit;font-style:inherit;font-weight:inherit;letter-spacing:inherit;text-decoration:inherit;text-overflow:inherit;text-transform:inherit;text-align:inherit;white-space:inherit;color:inherit;--padding:1em;--btn-padding:var(--padding);--btn-bg-color:var(--nano-color-contrast, #dad6d3);--btn-bg-color--open:var(--nano-color-base, #dad6d3);--btn-bg-color--hover:var(--nano-color-tint, #f9f9fb);--btn-text-color:var(--nano-color-base, #455556);--btn-text-color--open:var(--nano-color-contrast, var(--btn-text-color));--btn-text-color--hover:var(--nano-color-contrast, var(--btn-text-color));--content-transition:height 0.2s ease-out;--border-width:none;--border-color:none;--border-style:none;--border-radius:none;--box-shadow:none;--focus-style:var(--nano-control-focus-shadow, 0 0 0 0.1875rem var(--nano-control-focus-color, rgba(144, 198, 231, 0.8)));display:block;border-style:var(--border-style);border-width:var(--border-width-dims);border-color:var(--border-color);border-radius:var(--border-radius-dims);box-shadow:var(--box-shadow)}:host([disabled]){opacity:0.5}:host(:last-of-type){--border-width-dims:0 var(--border-width) var(--border-width);--border-radius-dims:0 0 var(--border-radius) var(--border-radius)}:host(:last-of-type) .open .content{border-radius:0 0 var(--border-radius) var(--border-radius)}:host(:first-of-type){--border-radius-dims:var(--border-radius) var(--border-radius) 0 0;--border-width-dims:var(--border-width)}:host(:first-of-type:last-of-type){--border-radius-dims:var(--border-radius);--border-width-dims:var(--border-width)}:host(:not(:last-of-type):not(:first-of-type)){--border-width-dims:0 var(--border-width) var(--border-width)}.header{height:auto;padding:var(--btn-padding);text-align:inherit;position:relative;font-size:1em;line-height:1;margin:0;transition:0.3s ease background, 0.3s ease color, 0.15s ease box-shadow;display:flex;align-items:center;background:var(--btn-bg-color);color:var(--btn-text-color);border-radius:var(--border-radius-dims);cursor:pointer}.header::-webkit-details-marker{display:none}.header:focus{outline:none}.header:focus-visible{box-shadow:var(--focus-style);outline:none;position:relative;z-index:1}.header:hover{background:var(--btn-bg-color--hover);color:var(--btn-text-color--hover)}.open .header{background:var(--btn-bg-color--open);color:var(--btn-text-color--open);border-end-end-radius:0;border-end-start-radius:0}.disabled .header{cursor:not-allowed}.header .label{width:100%;max-width:100%;max-height:100%;flex:1;display:inline-block}.header .icon{line-height:0;flex-direction:column;justify-content:center;display:inline-block;color:currentcolor;transition:0.3s ease transform;transform-origin:center}.header .icon--start{margin-inline:0 var(--padding);margin-block:0}.header .icon--end{margin-inline:var(--padding) 0;margin-block:0}.header .icon ::slotted(nano-icon){--color:currentcolor}.body{overflow:hidden;transition:var(--content-transition), 0.2s ease border-radius;outline:none}.body>*{opacity:0;transition:opacity 0.2s ease-out}.open .body>*{opacity:1}.content{padding:var(--padding)}";const n=class{constructor(e){t(this,e);this.nanoOpened=r(this,"nanoOpened",7);this.nanoClosed=r(this,"nanoClosed",7);this.stateChanging=false;this.onKeyDown=t=>{if(this.stateChanging||this.disabled)return;switch(t.key){case"Enter":case" ":t.preventDefault();this.open=!this.open;break;case"ArrowUp":t.preventDefault();this.open=false;break;case"ArrowDown":t.preventDefault();this.open=true;break}};this.onMouseDown=t=>{t.preventDefault();this.headerEl.focus();if(this.stateChanging||this.disabled)return;this.open=!this.open};this.label="";this.open=false;this.disabled=false;this.noHandle=false;this.iconRotation=90;this.useCacheHeight=false}toggleClick(){this.stateChanging=true;if(this.open)this.show();else this.hide()}hide(){const t=this.nanoClosed.emit(this.open);if(t.defaultPrevented){this.open=true;this.detailsEl.open=true;return}this.cacheHeight=this.contentEl.scrollHeight;this.bodyEl.style.height=this.cacheHeight+"px";s(this.bodyEl,"is-shown",false).then((()=>{this.stateChanging=false;this.detailsEl.open=false}));requestAnimationFrame((()=>{this.bodyEl.style.height="0px"}))}show(){const t=this.nanoOpened.emit();this.detailsEl.open=true;if(t.defaultPrevented){this.open=false;this.detailsEl.open=false;return}s(this.bodyEl,"is-shown",true).then((()=>{this.stateChanging=false;this.bodyEl.style.height="auto"}));this.bodyEl.style.height=(this.useCacheHeight?this.cacheHeight:this.contentEl.scrollHeight)+"px"}attachMo(){if(this.mo||!this.detailsEl||!e.isBrowser)return;this.mo=new MutationObserver((t=>{if(this.stateChanging)return;for(const r of t){if(r.type==="attributes"&&r.attributeName==="open"){this.open=this.detailsEl.open}}}));this.mo.observe(this.detailsEl,{attributes:true})}componentWillLoad(){this.hasStartSlot=!!this.host.querySelector('[slot="icon-start"]');this.hasEndSlot=!!this.host.querySelector('[slot="icon-end"]')}componentDidLoad(){this.bodyEl.style.height=this.open?"auto":"0";if(this.open)this.detailsEl.setAttribute("open","true");this.attachMo()}connectedCallback(){this.attachMo()}disconnectedCallback(){if(this.mo){this.mo.disconnect();this.mo=undefined}}render(){return o("details",{part:"base",ref:t=>this.detailsEl=t,class:{details:true,open:this.open,disabled:this.disabled}},o("summary",{part:"header","aria-controls":"content","aria-expanded":this.open?"true":"false","aria-disabled":this.disabled?"true":"false",tabindex:this.disabled?"-1":"0",style:{display:this.noHandle?"none":""},id:"header",role:"button",class:"header",ref:t=>this.headerEl=t,onKeyDown:this.onKeyDown,onClick:this.onMouseDown},this.hasStartSlot?o("span",{part:"icon--start",class:"icon icon--start",style:{transform:this.open?`rotate(${this.iconRotation}deg)`:""}},o("slot",{name:"icon-start"})):"",o("div",{part:"label",class:"label"},this.label?this.label:o("slot",{name:"label"})),this.hasEndSlot?o("span",{part:"icon--end",class:"icon icon--end",style:{transform:this.open?`rotate(${this.iconRotation}deg)`:""}},o("slot",{name:"icon-end"})):""),o("div",{part:"body",class:"body",ref:t=>this.bodyEl=t,tabindex:"-1",role:"region","aria-labelledby":"header"},o("div",{part:"content",ref:t=>this.contentEl=t,class:"content",id:"content"},o("slot",null))))}get host(){return i(this)}static get watchers(){return{open:["toggleClick"]}}};n.style=a;export{n as nano_details};
5
- //# sourceMappingURL=p-5ca9275c.entry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["detailsCss","Details","this","stateChanging","onKeyDown","e","disabled","key","preventDefault","open","onMouseDown","headerEl","focus","toggleClick","show","hide","nanoClose","nanoClosed","emit","defaultPrevented","detailsEl","cacheHeight","contentEl","scrollHeight","bodyEl","style","height","displayTransition","then","requestAnimationFrame","nanoOpen","nanoOpened","useCacheHeight","attachMo","mo","Build","isBrowser","MutationObserver","changes","change","type","attributeName","observe","attributes","componentWillLoad","hasStartSlot","host","querySelector","hasEndSlot","componentDidLoad","setAttribute","connectedCallback","disconnectedCallback","disconnect","undefined","render","h","part","ref","d","class","details","tabindex","display","noHandle","id","role","s","onClick","transform","iconRotation","name","label","div"],"sources":["./src/components/details/details.scss?tag=nano-details&encapsulation=shadow","./src/components/details/details.tsx"],"sourcesContent":["@use 'sass:map';\n@use 'sass:list';\n\n@import '../../global/style/utilities/globals';\n@import '../../global/style/nano-theme/colours';\n@import '../../global/style/nano-theme/base';\n@import '../../global/style/nano-theme/form';\n\n:host {\n /**\n * @prop --padding: Default to 1em;\n\n * @prop --btn-padding: Defaults to var(--padding);\n * @prop --btn-bg-color: Defaults to var(--nano-color-contrast, #dad6d3);\n * @prop --btn-bg-color--open: Defaults to var(--nano-color-base, #dad6d3);\n * @prop --btn-bg-color--hover: Defaults to var(--nano-color-tint, #{map.get($colors, offwhite)});\n\n * @prop --btn-text-color: Defaults to var(--nano-color-base, #455556);\n * @prop --btn-text-color--open: Defaults to var(--nano-color-contrast, var(--btn-text-color));\n * @prop --btn-text-color--hover: Defaults to var(--nano-color-contrast, var(--btn-text-color));\n\n * @prop --content-transition: Defaults to height .2s ease-out;\n\n * @prop --border-width: Defaults to none;\n * @prop --border-color: Defaults to none;\n * @prop --border-style: Defaults to none;\n * @prop --border-radius: Defaults to none;\n * @prop --box-shadow: Defaults to none;\n * @prop --focus-style: Defaults to #{$control-focus-style}\n */\n\n @include text-inherit();\n\n --padding: 1em;\n --btn-padding: var(--padding);\n --btn-bg-color: var(--nano-color-contrast, #dad6d3);\n --btn-bg-color--open: var(--nano-color-base, #dad6d3);\n --btn-bg-color--hover: var(--nano-color-tint, #{map.get($colors, offwhite)});\n --btn-text-color: var(--nano-color-base, #455556);\n --btn-text-color--open: var(--nano-color-contrast, var(--btn-text-color));\n --btn-text-color--hover: var(--nano-color-contrast, var(--btn-text-color));\n --content-transition: height 0.2s ease-out;\n --border-width: none;\n --border-color: none;\n --border-style: none;\n --border-radius: none;\n --box-shadow: none;\n --focus-style: #{$control-focus-style};\n\n display: block;\n border-style: var(--border-style);\n border-width: var(--border-width-dims);\n border-color: var(--border-color);\n border-radius: var(--border-radius-dims);\n box-shadow: var(--box-shadow);\n}\n\n:host([disabled]) {\n opacity: 0.5;\n}\n\n:host(:last-of-type) {\n --border-width-dims: 0 var(--border-width) var(--border-width);\n --border-radius-dims: 0 0 var(--border-radius) var(--border-radius);\n\n .open .content {\n border-radius: 0 0 var(--border-radius) var(--border-radius);\n }\n}\n\n:host(:first-of-type) {\n --border-radius-dims: var(--border-radius) var(--border-radius) 0 0;\n --border-width-dims: var(--border-width);\n}\n\n:host(:first-of-type:last-of-type) {\n --border-radius-dims: var(--border-radius);\n --border-width-dims: var(--border-width);\n}\n\n:host(:not(:last-of-type):not(:first-of-type)) {\n --border-width-dims: 0 var(--border-width) var(--border-width);\n}\n\n.header {\n height: auto;\n padding: var(--btn-padding);\n text-align: inherit;\n position: relative;\n font-size: 1em;\n line-height: 1;\n margin: 0;\n transition: 0.3s ease background, 0.3s ease color, 0.15s ease box-shadow;\n display: flex;\n align-items: center;\n background: var(--btn-bg-color);\n color: var(--btn-text-color);\n border-radius: var(--border-radius-dims);\n cursor: pointer;\n\n &::-webkit-details-marker {\n display: none;\n }\n\n &:focus {\n outline: none;\n }\n\n &:focus-visible {\n box-shadow: var(--focus-style);\n outline: none;\n position: relative;\n z-index: 1;\n }\n\n &:hover {\n background: var(--btn-bg-color--hover);\n color: var(--btn-text-color--hover);\n }\n\n .open & {\n background: var(--btn-bg-color--open);\n color: var(--btn-text-color--open);\n border-end-end-radius: 0;\n border-end-start-radius: 0;\n }\n\n .disabled & {\n cursor: not-allowed;\n }\n\n .label {\n width: 100%;\n max-width: 100%;\n max-height: 100%;\n flex: 1;\n display: inline-block;\n }\n\n .icon {\n line-height: 0;\n flex-direction: column;\n justify-content: center;\n display: inline-block;\n color: currentcolor;\n transition: 0.3s ease transform;\n transform-origin: center;\n\n &--start {\n margin-inline: 0 var(--padding);\n margin-block: 0;\n }\n\n &--end {\n margin-inline: var(--padding) 0;\n margin-block: 0;\n }\n\n ::slotted(nano-icon) {\n --color: currentcolor;\n }\n }\n}\n\n.body {\n overflow: hidden;\n transition: var(--content-transition), 0.2s ease border-radius;\n outline: none;\n\n > * {\n opacity: 0;\n transition: opacity 0.2s ease-out;\n\n .open & {\n opacity: 1;\n }\n }\n}\n\n.content {\n padding: var(--padding);\n}\n","import {\n Component,\n Event,\n EventEmitter,\n Prop,\n h,\n Element,\n Watch,\n Build,\n} from '@stencil/core';\nimport { displayTransition } from '../../utils/transitions';\n\n/**\n * A simple element used to hide or reveal more content with slide effect. Can be used independently or nested within a [accordion](story/components-accordion--accordion) element to add 'one item open at a time' support.\n */\n/**\n * @slot - content that will be hidden / revealed\n * @slot icon-start - used for icons at the start of the handle\n * @slot label - can be used when you wish to insert complex label markup\n * @slot icon-end - used for icons at the end of the handle\n *\n * @part base - the root `details` element\n * @part header - the main `summary` ui control\n * @part label - the text wrapper of the ui control\n * @part icon--start - the icon wrapper at the start of the ui control\n * @part icon--end - the icon wrapper at the end of the ui control\n * @part body - the wrapper around content\n * @part content - the main content wrapper\n */\n@Component({\n tag: 'nano-details',\n styleUrl: 'details.scss',\n shadow: true,\n})\nexport class Details {\n private hasStartSlot: boolean;\n private hasEndSlot: boolean;\n private mo?: MutationObserver;\n private stateChanging: boolean = false;\n private bodyEl: HTMLElement;\n private detailsEl: HTMLDetailsElement;\n private headerEl: HTMLElement;\n private contentEl: HTMLDivElement;\n private cacheHeight: number;\n\n @Element() private host: HTMLNanoDetailsElement;\n\n /** Summary / handle text. Use the `label` slot for HTML markup */\n @Prop() label: string = '';\n\n /** Should item be open on load */\n @Prop({ mutable: true, reflect: true }) open: boolean = false;\n\n /** Disables the details so it can't be toggled. */\n @Prop({ mutable: true, reflect: true }) disabled: boolean = false;\n\n /** Hide the handle. (You will need to control the hiding / showing of content with script) */\n @Prop() noHandle: boolean = false;\n\n /** Icon slot rotation amount (degrees) on open */\n @Prop() iconRotation: number = 90;\n\n /**\n * Sometimes, nested content will resize within the details component which results in choppy show/hide animations.\n * Set `useCacheHeight` to `true` try to keep animations smooth. */\n @Prop() useCacheHeight = false;\n\n /**\n * Emitted when the component opens.\n * Note: when wrapped in an accordion this event will not propogate. Use nanoToggle events instead.\n */\n @Event() nanoOpened: EventEmitter;\n\n /**\n * Emitted when the component closes.\n * Note: when wrapped in an accordion this event will not propogate. Use nanoToggle events instead.\n */\n @Event() nanoClosed: EventEmitter;\n\n @Watch('open')\n toggleClick() {\n this.stateChanging = true;\n if (this.open) this.show();\n else this.hide();\n }\n\n private onKeyDown = (e: KeyboardEvent) => {\n if (this.stateChanging || this.disabled) return;\n\n switch (e.key) {\n case 'Enter':\n case ' ':\n e.preventDefault();\n this.open = !this.open;\n break;\n case 'ArrowUp':\n e.preventDefault();\n this.open = false;\n break;\n case 'ArrowDown':\n e.preventDefault();\n this.open = true;\n break;\n }\n };\n\n private onMouseDown = (e: MouseEvent) => {\n e.preventDefault();\n this.headerEl.focus();\n\n if (this.stateChanging || this.disabled) return;\n this.open = !this.open;\n };\n\n private hide() {\n const nanoClose = this.nanoClosed.emit(this.open);\n\n if (nanoClose.defaultPrevented) {\n this.open = true;\n this.detailsEl.open = true;\n return;\n }\n\n this.cacheHeight = this.contentEl.scrollHeight;\n this.bodyEl.style.height = this.cacheHeight + 'px';\n\n displayTransition(this.bodyEl, 'is-shown', false).then(() => {\n this.stateChanging = false;\n this.detailsEl.open = false;\n });\n\n requestAnimationFrame(() => {\n this.bodyEl.style.height = '0px';\n });\n }\n\n private show() {\n const nanoOpen = this.nanoOpened.emit();\n this.detailsEl.open = true;\n\n if (nanoOpen.defaultPrevented) {\n this.open = false;\n this.detailsEl.open = false;\n return;\n }\n\n displayTransition(this.bodyEl, 'is-shown', true).then(() => {\n this.stateChanging = false;\n this.bodyEl.style.height = 'auto';\n });\n\n this.bodyEl.style.height =\n (this.useCacheHeight ? this.cacheHeight : this.contentEl.scrollHeight) +\n 'px';\n }\n\n private attachMo() {\n if (this.mo || !this.detailsEl || !Build.isBrowser) return;\n\n this.mo = new MutationObserver((changes) => {\n if (this.stateChanging) return;\n\n for (const change of changes) {\n if (change.type === 'attributes' && change.attributeName === 'open') {\n this.open = this.detailsEl.open;\n }\n }\n });\n this.mo.observe(this.detailsEl, { attributes: true });\n }\n\n componentWillLoad() {\n this.hasStartSlot = !!this.host.querySelector('[slot=\"icon-start\"]');\n this.hasEndSlot = !!this.host.querySelector('[slot=\"icon-end\"]');\n }\n\n componentDidLoad() {\n this.bodyEl.style.height = this.open ? 'auto' : '0';\n if (this.open) this.detailsEl.setAttribute('open', 'true');\n this.attachMo();\n }\n\n connectedCallback() {\n this.attachMo();\n }\n\n disconnectedCallback() {\n if (this.mo) {\n this.mo.disconnect();\n this.mo = undefined;\n }\n }\n\n render() {\n return (\n <details\n part=\"base\"\n ref={(d: HTMLDetailsElement) => (this.detailsEl = d)}\n class={{\n details: true,\n open: this.open,\n disabled: this.disabled,\n }}\n >\n <summary\n part=\"header\"\n aria-controls=\"content\"\n aria-expanded={this.open ? 'true' : 'false'}\n aria-disabled={this.disabled ? 'true' : 'false'}\n tabindex={this.disabled ? '-1' : '0'}\n style={{ display: this.noHandle ? 'none' : '' }}\n id=\"header\"\n role=\"button\"\n class=\"header\"\n ref={(s) => (this.headerEl = s)}\n onKeyDown={this.onKeyDown}\n onClick={this.onMouseDown}\n >\n {this.hasStartSlot ? (\n <span\n part=\"icon--start\"\n class=\"icon icon--start\"\n style={{\n transform: this.open ? `rotate(${this.iconRotation}deg)` : '',\n }}\n >\n <slot name=\"icon-start\" />\n </span>\n ) : (\n ''\n )}\n <div part=\"label\" class=\"label\">\n {this.label ? this.label : <slot name=\"label\" />}\n </div>\n {this.hasEndSlot ? (\n <span\n part=\"icon--end\"\n class=\"icon icon--end\"\n style={{\n transform: this.open ? `rotate(${this.iconRotation}deg)` : '',\n }}\n >\n <slot name=\"icon-end\" />\n </span>\n ) : (\n ''\n )}\n </summary>\n <div\n part=\"body\"\n class=\"body\"\n ref={(div) => (this.bodyEl = div)}\n tabindex=\"-1\"\n role=\"region\"\n aria-labelledby=\"header\"\n >\n <div\n part=\"content\"\n ref={(div) => (this.contentEl = div)}\n class=\"content\"\n id=\"content\"\n >\n <slot />\n </div>\n </div>\n </details>\n );\n }\n}\n"],"mappings":";;;oGAAA,MAAMA,EAAa,2qG,MCkCNC,EAAO,M,uGAIVC,KAAAC,cAAyB,MAgDzBD,KAAAE,UAAaC,IACnB,GAAIH,KAAKC,eAAiBD,KAAKI,SAAU,OAEzC,OAAQD,EAAEE,KACR,IAAK,QACL,IAAK,IACHF,EAAEG,iBACFN,KAAKO,MAAQP,KAAKO,KAClB,MACF,IAAK,UACHJ,EAAEG,iBACFN,KAAKO,KAAO,MACZ,MACF,IAAK,YACHJ,EAAEG,iBACFN,KAAKO,KAAO,KACZ,M,EAIEP,KAAAQ,YAAeL,IACrBA,EAAEG,iBACFN,KAAKS,SAASC,QAEd,GAAIV,KAAKC,eAAiBD,KAAKI,SAAU,OACzCJ,KAAKO,MAAQP,KAAKO,IAAI,E,WA/DA,G,UAGgC,M,cAGI,M,cAGhC,M,kBAGG,G,oBAKN,K,CAezBI,cACEX,KAAKC,cAAgB,KACrB,GAAID,KAAKO,KAAMP,KAAKY,YACfZ,KAAKa,M,CA+BJA,OACN,MAAMC,EAAYd,KAAKe,WAAWC,KAAKhB,KAAKO,MAE5C,GAAIO,EAAUG,iBAAkB,CAC9BjB,KAAKO,KAAO,KACZP,KAAKkB,UAAUX,KAAO,KACtB,M,CA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