@aurodesignsystem-dev/auro-carousel 0.0.0-pr97.0 → 0.0.0-pr97.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/demo/api.md CHANGED
@@ -32,12 +32,12 @@ The auro-carousel component displays a group of elements in a scrollable contain
32
32
 
33
33
  ## Slots
34
34
 
35
- | Name | Description |
36
- |-------------------------|--------------------------------------------------|
37
- | | the elements in the carousel |
38
- | [ariaLabel](#ariaLabel) | Text to give an accessible name to the carousel. |
39
- | `ariaLabel.scrollLeft` | Text to give an accessible name to the left scroll button. |
40
- | `ariaLabel.scrollRight` | Text to give an accessible name to the right scroll button. |
35
+ | Name | Description |
36
+ |--------------------------|--------------------------------------------------|
37
+ | | the elements in the carousel |
38
+ | [ariaLabel](#ariaLabel) | Text to give an accessible name to the carousel. |
39
+ | `ariaLabel.scroll.left` | Text to give an accessible name to the left scroll button. |
40
+ | `ariaLabel.scroll.right` | Text to give an accessible name to the right scroll button. |
41
41
 
42
42
  ## CSS Shadow Parts
43
43
 
@@ -464,15 +464,17 @@ Used for all elements inside the scrolling carousel.
464
464
 
465
465
  #### aria label slots
466
466
 
467
- Use the `ariaLabel`, `ariaLabel.scrollLeft`, and `ariaLabel.scrollRight` slots to customize the accessible names for the carousel container and the left and right scroll buttons.
467
+ Use the `ariaLabel`, `ariaLabel.scroll.left`, and `ariaLabel.scroll.right` slots to customize the accessible names for the carousel container and the left and right scroll buttons.
468
+
469
+ **Note:** Do not use the `aria-label` attribute on the `auro-carousel` element itself. This will be ignored in favor of the `ariaLabel` slot.
468
470
 
469
471
  <div class="exampleWrapper">
470
472
  <!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/ariaLabelSlots.html) -->
471
473
  <!-- The below content is automatically added from ./../apiExamples/ariaLabelSlots.html -->
472
474
  <auro-carousel centerSelected>
473
475
  <span slot="ariaLabel">My Carousel</span>
474
- <span slot="ariaLabel.scrollLeft">My custom scroll left text</span>
475
- <span slot="ariaLabel.scrollRight">My custom scroll right text</span>
476
+ <span slot="ariaLabel.scroll.left">My custom scroll left text</span>
477
+ <span slot="ariaLabel.scroll.right">My custom scroll right text</span>
476
478
  <auro-pane date="2020-10-10" price="$435"></auro-pane>
477
479
  <auro-pane date="2020-10-11" price="$435"></auro-pane>
478
480
  <auro-pane date="2020-10-12" price="$435"></auro-pane>
@@ -502,8 +504,8 @@ Use the `ariaLabel`, `ariaLabel.scrollLeft`, and `ariaLabel.scrollRight` slots t
502
504
  ```html
503
505
  <auro-carousel centerSelected>
504
506
  <span slot="ariaLabel">My Carousel</span>
505
- <span slot="ariaLabel.scrollLeft">My custom scroll left text</span>
506
- <span slot="ariaLabel.scrollRight">My custom scroll right text</span>
507
+ <span slot="ariaLabel.scroll.left">My custom scroll left text</span>
508
+ <span slot="ariaLabel.scroll.right">My custom scroll right text</span>
507
509
  <auro-pane date="2020-10-10" price="$435"></auro-pane>
508
510
  <auro-pane date="2020-10-11" price="$435"></auro-pane>
509
511
  <auro-pane date="2020-10-12" price="$435"></auro-pane>
@@ -282,8 +282,8 @@ var tokensCss = i$5`:host{--ds-auro-carousel-gradient-color-one: var(--ds-basic-
282
282
  *
283
283
  * @slot - the elements in the carousel
284
284
  * @slot ariaLabel - Text to give an accessible name to the carousel.
285
- * @slot ariaLabel.scrollLeft - Text to give an accessible name to the left scroll button.
286
- * @slot ariaLabel.scrollRight - Text to give an accessible name to the right scroll button.
285
+ * @slot ariaLabel.scroll.left - Text to give an accessible name to the left scroll button.
286
+ * @slot ariaLabel.scroll.right - Text to give an accessible name to the right scroll button.
287
287
  *
288
288
  * @csspart wrapper - The primary root HTML element of the component.
289
289
  *
@@ -615,8 +615,8 @@ class AuroCarousel extends i$2 {
615
615
  return u$2`
616
616
  <!-- Hidden slots for aria labels -->
617
617
  <slot name="ariaLabel" hidden @slotchange="${this.requestUpdate}"></slot>
618
- <slot name="ariaLabel.scrollLeft" hidden @slotchange="${this.requestUpdate}"></slot>
619
- <slot name="ariaLabel.scrollRight" hidden @slotchange="${this.requestUpdate}"></slot>
618
+ <slot name="ariaLabel.scroll.left" hidden @slotchange="${this.requestUpdate}"></slot>
619
+ <slot name="ariaLabel.scroll.right" hidden @slotchange="${this.requestUpdate}"></slot>
620
620
 
621
621
  <div class="breakpointDetector"></div>
622
622
  <div role="group"
@@ -628,7 +628,7 @@ class AuroCarousel extends i$2 {
628
628
 
629
629
  <!-- Left button -->
630
630
  <${this.buttonTag}
631
- aria-label="${o(this.runtimeUtils.getSlotText(this, 'ariaLabel.scrollLeft') || 'Scroll Left')}"
631
+ aria-label="${o(this.runtimeUtils.getSlotText(this, 'ariaLabel.scroll.left') || 'Scroll Left')}"
632
632
  shape="circle"
633
633
  variant="secondary"
634
634
  @click=${() => this.handleClick(false)}
@@ -644,7 +644,7 @@ class AuroCarousel extends i$2 {
644
644
 
645
645
  <!-- Right button -->
646
646
  <${this.buttonTag}
647
- aria-label="${o(this.runtimeUtils.getSlotText(this, 'ariaLabel.scrollRight') || 'Scroll Right')}"
647
+ aria-label="${o(this.runtimeUtils.getSlotText(this, 'ariaLabel.scroll.right') || 'Scroll Right')}"
648
648
  shape="circle"
649
649
  variant="secondary"
650
650
  @click=${() => this.handleClick(true)}
@@ -81,8 +81,8 @@ import{css as t,LitElement as e,html as o}from"lit";import{unsafeStatic as s,lit
81
81
  `;class V extends e{constructor(){super(),this.scrollDistance=300,this.runtimeUtils=new l;const t=new d;this.buttonTag=t.generateTag("auro-button","12.2.0",L),this.iconTag=t.generateTag("auro-icon","9.1.0",X),this.scrolledToStart=!1,this.scrolledToEnd=!1}static get properties(){return{displayArrows:{type:Boolean},scrollDistance:{type:Number,reflect:!0},label:{type:String},centerSelected:{type:String,reflect:!0}}}static get styles(){return[G,j,P]}static register(t="auro-carousel"){l.prototype.registerComponent(t,V)}firstUpdated(){this.runtimeUtils.handleComponentTagRename(this,"auro-carousel"),this.carousel=this.renderRoot.querySelector(".carousel"),this.label||console.warn("Label should be provided to auro-carousel for carousel to be accessible"),this.setScrollFlags(!1),this.setUpIntersectionObserver(),this.setUpResizeObserver(),this.hasAttribute("centerSelected")&&(this.actionOnChildrenReady(),document.addEventListener("DOMContentLoaded",()=>{this.actionOnChildrenReady()}))}actionOnChildrenReady(){const t=[];[...this.children].forEach(e=>{t.push(e.updateComplete)}),Promise.all(t).then(()=>{this.scrollToSelected()})}scrollToSelected(){const t=[...this.children].find(t=>t.hasAttribute("selected"));t&&this.centerElement(t)}isSmallScreen(){const t=this.renderRoot.querySelector(".breakpointDetector");return"sm"!==window.getComputedStyle(t,":before").getPropertyValue("content").replace(/"/gu,"")}scrollCarousel(t){this.carousel.scrollLeft+=t}centerElement(t){if(!this.contains(t))throw new Error("Element is not a descendant of this carousel");const e=t.getBoundingClientRect().x-this.getBoundingClientRect().left-this.offsetWidth/2+t.offsetWidth/2;this.scrollCarousel(e)}setScrollFlags(t){const{scrollLeft:e,scrollWidth:o,clientWidth:s}=this.carousel;this.scrolledToStart=e<=0,this.scrolledToEnd=e>=o-s,t&&(this.scrolledToStart||this.scrolledToEnd)&&(this.scrolledToStart?this.firstElementChild.focus():this.lastElementChild.focus()),this.requestUpdate()}setUpIntersectionObserver(){const t={root:this.carousel,threshold:.8};if("IntersectionObserver"in window&&!this.isSmallScreen()){const e=t=>{t.forEach(t=>{t.isIntersecting?(t.target.removeAttribute("tabindex"),t.target.removeAttribute("aria-hidden")):(t.target.setAttribute("tabindex","-1"),t.target.setAttribute("aria-hidden",!0))})};this.intersectionObserver=new IntersectionObserver(e,t),this.observeChildren()}}setUpResizeObserver(){"ResizeObserver"in window&&(this.resizeObserver=new ResizeObserver(()=>this.setScrollFlags()),Array.from(this.children).forEach(t=>{this.resizeObserver.observe(t)}))}observeChildren(){Array.from(this.children).forEach(t=>{this.intersectionObserver.observe(t)})}handleSlotChange(){this.setScrollFlags(!1),this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.observeChildren())}handleClick(t){let e=null;t?(this.scrollCarousel(this.scrollDistance),e=new CustomEvent("scrollRight",{bubbles:!0,composed:!0})):(this.scrollCarousel(-1*this.scrollDistance),e=new CustomEvent("scrollLeft",{bubbles:!0,composed:!0})),this.dispatchEvent(e)}render(){const t={wrapper:!0,carousel:!0,"carousel--scrolledToStart":this.scrolledToStart&&!this.displayArrows,"carousel--scrolledToEnd":this.scrolledToEnd&&!this.displayArrows};return r`
82
82
  <!-- Hidden slots for aria labels -->
83
83
  <slot name="ariaLabel" hidden @slotchange="${this.requestUpdate}"></slot>
84
- <slot name="ariaLabel.scrollLeft" hidden @slotchange="${this.requestUpdate}"></slot>
85
- <slot name="ariaLabel.scrollRight" hidden @slotchange="${this.requestUpdate}"></slot>
84
+ <slot name="ariaLabel.scroll.left" hidden @slotchange="${this.requestUpdate}"></slot>
85
+ <slot name="ariaLabel.scroll.right" hidden @slotchange="${this.requestUpdate}"></slot>
86
86
 
87
87
  <div class="breakpointDetector"></div>
88
88
  <div role="group"
@@ -94,7 +94,7 @@ import{css as t,LitElement as e,html as o}from"lit";import{unsafeStatic as s,lit
94
94
 
95
95
  <!-- Left button -->
96
96
  <${this.buttonTag}
97
- aria-label="${n(this.runtimeUtils.getSlotText(this,"ariaLabel.scrollLeft")||"Scroll Left")}"
97
+ aria-label="${n(this.runtimeUtils.getSlotText(this,"ariaLabel.scroll.left")||"Scroll Left")}"
98
98
  shape="circle"
99
99
  variant="secondary"
100
100
  @click=${()=>this.handleClick(!1)}
@@ -110,7 +110,7 @@ import{css as t,LitElement as e,html as o}from"lit";import{unsafeStatic as s,lit
110
110
 
111
111
  <!-- Right button -->
112
112
  <${this.buttonTag}
113
- aria-label="${n(this.runtimeUtils.getSlotText(this,"ariaLabel.scrollRight")||"Scroll Right")}"
113
+ aria-label="${n(this.runtimeUtils.getSlotText(this,"ariaLabel.scroll.right")||"Scroll Right")}"
114
114
  shape="circle"
115
115
  variant="secondary"
116
116
  @click=${()=>this.handleClick(!0)}
package/dist/index.d.ts CHANGED
@@ -86,8 +86,8 @@ class l{registerComponent(t,e){customElements.get(t)||customElements.define(t,cl
86
86
  `;class V extends LitElement{constructor(){super(),this.scrollDistance=300,this.runtimeUtils=new l;const t=new d;this.buttonTag=t.generateTag("auro-button","12.2.0",L),this.iconTag=t.generateTag("auro-icon","9.1.0",X),this.scrolledToStart=false,this.scrolledToEnd=false;}static get properties(){return {displayArrows:{type:Boolean},scrollDistance:{type:Number,reflect:true},label:{type:String},centerSelected:{type:String,reflect:true}}}static get styles(){return [G,j,P]}static register(t="auro-carousel"){l.prototype.registerComponent(t,V);}firstUpdated(){this.runtimeUtils.handleComponentTagRename(this,"auro-carousel"),this.carousel=this.renderRoot.querySelector(".carousel"),this.label||console.warn("Label should be provided to auro-carousel for carousel to be accessible"),this.setScrollFlags(false),this.setUpIntersectionObserver(),this.setUpResizeObserver(),this.hasAttribute("centerSelected")&&(this.actionOnChildrenReady(),document.addEventListener("DOMContentLoaded",()=>{this.actionOnChildrenReady();}));}actionOnChildrenReady(){const t=[];[...this.children].forEach(e=>{t.push(e.updateComplete);}),Promise.all(t).then(()=>{this.scrollToSelected();});}scrollToSelected(){const t=[...this.children].find(t=>t.hasAttribute("selected"));t&&this.centerElement(t);}isSmallScreen(){const t=this.renderRoot.querySelector(".breakpointDetector");return "sm"!==window.getComputedStyle(t,":before").getPropertyValue("content").replace(/"/gu,"")}scrollCarousel(t){this.carousel.scrollLeft+=t;}centerElement(t){if(!this.contains(t))throw new Error("Element is not a descendant of this carousel");const e=t.getBoundingClientRect().x-this.getBoundingClientRect().left-this.offsetWidth/2+t.offsetWidth/2;this.scrollCarousel(e);}setScrollFlags(t){const{scrollLeft:e,scrollWidth:o,clientWidth:s}=this.carousel;this.scrolledToStart=e<=0,this.scrolledToEnd=e>=o-s,t&&(this.scrolledToStart||this.scrolledToEnd)&&(this.scrolledToStart?this.firstElementChild.focus():this.lastElementChild.focus()),this.requestUpdate();}setUpIntersectionObserver(){const t={root:this.carousel,threshold:.8};if("IntersectionObserver"in window&&!this.isSmallScreen()){const e=t=>{t.forEach(t=>{t.isIntersecting?(t.target.removeAttribute("tabindex"),t.target.removeAttribute("aria-hidden")):(t.target.setAttribute("tabindex","-1"),t.target.setAttribute("aria-hidden",true));});};this.intersectionObserver=new IntersectionObserver(e,t),this.observeChildren();}}setUpResizeObserver(){"ResizeObserver"in window&&(this.resizeObserver=new ResizeObserver(()=>this.setScrollFlags()),Array.from(this.children).forEach(t=>{this.resizeObserver.observe(t);}));}observeChildren(){Array.from(this.children).forEach(t=>{this.intersectionObserver.observe(t);});}handleSlotChange(){this.setScrollFlags(false),this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.observeChildren());}handleClick(t){let e=null;t?(this.scrollCarousel(this.scrollDistance),e=new CustomEvent("scrollRight",{bubbles:true,composed:true})):(this.scrollCarousel(-1*this.scrollDistance),e=new CustomEvent("scrollLeft",{bubbles:true,composed:true})),this.dispatchEvent(e);}render(){const t={wrapper:true,carousel:true,"carousel--scrolledToStart":this.scrolledToStart&&!this.displayArrows,"carousel--scrolledToEnd":this.scrolledToEnd&&!this.displayArrows};return html`
87
87
  <!-- Hidden slots for aria labels -->
88
88
  <slot name="ariaLabel" hidden @slotchange="${this.requestUpdate}"></slot>
89
- <slot name="ariaLabel.scrollLeft" hidden @slotchange="${this.requestUpdate}"></slot>
90
- <slot name="ariaLabel.scrollRight" hidden @slotchange="${this.requestUpdate}"></slot>
89
+ <slot name="ariaLabel.scroll.left" hidden @slotchange="${this.requestUpdate}"></slot>
90
+ <slot name="ariaLabel.scroll.right" hidden @slotchange="${this.requestUpdate}"></slot>
91
91
 
92
92
  <div class="breakpointDetector"></div>
93
93
  <div role="group"
@@ -99,7 +99,7 @@ class l{registerComponent(t,e){customElements.get(t)||customElements.define(t,cl
99
99
 
100
100
  <!-- Left button -->
101
101
  <${this.buttonTag}
102
- aria-label="${ifDefined(this.runtimeUtils.getSlotText(this,"ariaLabel.scrollLeft")||"Scroll Left")}"
102
+ aria-label="${ifDefined(this.runtimeUtils.getSlotText(this,"ariaLabel.scroll.left")||"Scroll Left")}"
103
103
  shape="circle"
104
104
  variant="secondary"
105
105
  @click=${()=>this.handleClick(false)}
@@ -115,7 +115,7 @@ class l{registerComponent(t,e){customElements.get(t)||customElements.define(t,cl
115
115
 
116
116
  <!-- Right button -->
117
117
  <${this.buttonTag}
118
- aria-label="${ifDefined(this.runtimeUtils.getSlotText(this,"ariaLabel.scrollRight")||"Scroll Right")}"
118
+ aria-label="${ifDefined(this.runtimeUtils.getSlotText(this,"ariaLabel.scroll.right")||"Scroll Right")}"
119
119
  shape="circle"
120
120
  variant="secondary"
121
121
  @click=${()=>this.handleClick(true)}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export{A as AuroCarousel}from"./auro-carousel-BU_mtJJ-.js";import"lit";import"lit/static-html.js";import"lit/directives/class-map.js";import"lit/directives/if-defined.js";
1
+ export{A as AuroCarousel}from"./auro-carousel-DbNzxhOH.js";import"lit";import"lit/static-html.js";import"lit/directives/class-map.js";import"lit/directives/if-defined.js";
@@ -1 +1 @@
1
- import{A as i}from"./auro-carousel-BU_mtJJ-.js";import"lit";import"lit/static-html.js";import"lit/directives/class-map.js";import"lit/directives/if-defined.js";i.register();
1
+ import{A as i}from"./auro-carousel-DbNzxhOH.js";import"lit";import"lit/static-html.js";import"lit/directives/class-map.js";import"lit/directives/if-defined.js";i.register();
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "================================================================================"
8
8
  ],
9
9
  "name": "@aurodesignsystem-dev/auro-carousel",
10
- "version": "0.0.0-pr97.0",
10
+ "version": "0.0.0-pr97.2",
11
11
  "description": "auro-carousel HTML custom element",
12
12
  "repository": {
13
13
  "type": "git",