@nuralyui/carousel 0.0.7 → 0.0.8

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 (2) hide show
  1. package/bundle.js +96 -1
  2. package/package.json +1 -1
package/bundle.js CHANGED
@@ -1 +1,96 @@
1
- import{css as t,LitElement as o,html as i,nothing as s}from"lit";import{property as e,queryAssignedElements as r,state as l,customElement as a}from"lit/decorators.js";import{repeat as n}from"lit/directives/repeat.js";const c=t`:host{position:relative}.carousel{width:100%;display:flex;justify-content:center;flex-direction:column;align-items:center}::slotted(.carousel-item-hidden){position:absolute;opacity:0}::slotted(:not(.carousel-item-hidden)){opacity:1;transition:opacity .5s ease}.controls{position:absolute;width:100%;top:50%;display:flex;justify-content:space-between}.button-control{--nuraly-button-ghost-text-color:grey;--nuraly-button-ghost-active-border-color:transparent;--nuraly-button-ghost-hover-background-color:transparent;--nuraly-button-ghost-hover-border-color:transparent}.dot{height:8px;width:8px;margin:0 5px;background-color:var(--carousel-dot-background-color);display:inline-block;cursor:pointer;opacity:.4}.dot.active{background-color:var(--carousel-dot-active-background-color);opacity:.9}:host{--carousel-dot-background-color:#bebebe;--carousel-dot-active-background-color:gray}@media (prefers-color-scheme:dark){:host{--carousel-dot-background-color:gray;--carousel-dot-active-background-color:lightgray}}`;var d=function(t,o,i,s){for(var e,r=arguments.length,l=r<3?o:null===s?s=Object.getOwnPropertyDescriptor(o,i):s,a=t.length-1;a>=0;a--)(e=t[a])&&(l=(r<3?e(l):r>3?e(o,i,l):e(o,i))||l);return r>3&&l&&Object.defineProperty(o,i,l),l};let h=class extends o{constructor(){super(...arguments),this.currentIndex=0,this.autoPlay=!1,this.autoplaySpeed=3e3,this.intervalId=null}firstUpdated(){this.displayedElements=this.slideElements.map(((t,o)=>(o!=this.currentIndex&&t.classList.add("carousel-item-hidden"),t))),this.autoPlay&&this.startAutoPlay()}startAutoPlay(){this.intervalId=window.setInterval((()=>{this.next()}),this.autoplaySpeed)}stopAutoPlay(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null)}next(){this.displayedElements[this.currentIndex].classList.add("carousel-item-hidden"),this.displayedElements.length-1==this.currentIndex?this.currentIndex=0:this.currentIndex++,this.displayedElements[this.currentIndex].classList.remove("carousel-item-hidden")}prev(){this.displayedElements[this.currentIndex].classList.add("carousel-item-hidden"),0==this.currentIndex?this.currentIndex=this.displayedElements.length-1:this.currentIndex--,this.displayedElements[this.currentIndex].classList.remove("carousel-item-hidden")}goTo(t){this.displayedElements[this.currentIndex].classList.add("carousel-item-hidden"),this.currentIndex=t,this.displayedElements[this.currentIndex].classList.remove("carousel-item-hidden")}disconnectedCallback(){super.disconnectedCallback(),this.stopAutoPlay()}render(){var t;return i`<div class="carousel"><slot></slot>${this.autoPlay?s:i`<div class="controls"><nr-button @click="${this.prev}" type="ghost" size="small" class="button-control" .icon="${["chevron-left"]}"></nr-button><nr-button @click="${this.next}" type="ghost" size="small" class="button-control" .icon="${["chevron-right"]}"></nr-button></div>`}<div class="dots">${n(Array.from({length:null===(t=this.displayedElements)||void 0===t?void 0:t.length}),((t,o)=>i`<span class="dot ${o===this.currentIndex?"active":""}" @click="${()=>this.goTo(o)}"></span>`))}</div></div>`}};h.styles=c,d([e({type:Number})],h.prototype,"currentIndex",void 0),d([e({type:Boolean})],h.prototype,"autoPlay",void 0),d([e({type:Number})],h.prototype,"autoplaySpeed",void 0),d([r()],h.prototype,"slideElements",void 0),d([l()],h.prototype,"displayedElements",void 0),h=d([a("hy-carousel")],h);export{h as CarouselComponent};
1
+ import{css as t,LitElement as o,html as s,nothing as e}from"lit";import{property as i,queryAssignedElements as r,state as l,customElement as n}from"lit/decorators.js";import{repeat as a}from"lit/directives/repeat.js";const c=t`
2
+ :host {
3
+ position: relative;
4
+ }
5
+
6
+ .carousel {
7
+ width: 100%;
8
+ display: flex;
9
+ justify-content: center;
10
+ flex-direction: column;
11
+ align-items: center;
12
+ }
13
+
14
+ ::slotted(.carousel-item-hidden) {
15
+ position: absolute;
16
+ opacity: 0;
17
+ }
18
+ ::slotted(:not(.carousel-item-hidden)) {
19
+ opacity: 1;
20
+ transition: opacity 0.5s ease;
21
+ }
22
+
23
+ .controls {
24
+ position: absolute;
25
+ width: 100%;
26
+ top: 50%;
27
+ display: flex;
28
+ justify-content: space-between;
29
+ }
30
+ .button-control {
31
+ --nuraly-button-ghost-text-color: grey;
32
+ --nuraly-button-ghost-active-border-color: transparent;
33
+ --nuraly-button-ghost-hover-background-color: transparent;
34
+ --nuraly-button-ghost-hover-border-color: transparent;
35
+ }
36
+
37
+ .dot {
38
+ height: 8px;
39
+ width: 8px;
40
+ margin: 0 5px;
41
+ background-color: var(--carousel-dot-background-color);
42
+ display: inline-block;
43
+ cursor: pointer;
44
+ opacity: 0.4;
45
+ }
46
+
47
+ .dot.active {
48
+ background-color: var(--carousel-dot-active-background-color);
49
+ opacity: 0.9;
50
+ }
51
+
52
+ :host {
53
+ --carousel-dot-background-color: #bebebe;
54
+ --carousel-dot-active-background-color: gray;
55
+ }
56
+ @media (prefers-color-scheme: dark) {
57
+ :host {
58
+ --carousel-dot-background-color: gray;
59
+ --carousel-dot-active-background-color: lightgray;
60
+ .button-control {
61
+ --nuraly-button-ghost-text-color: #ffffff;
62
+ }
63
+ }
64
+ }
65
+ `;var d=function(t,o,s,e){for(var i,r=arguments.length,l=r<3?o:null===e?e=Object.getOwnPropertyDescriptor(o,s):e,n=t.length-1;n>=0;n--)(i=t[n])&&(l=(r<3?i(l):r>3?i(o,s,l):i(o,s))||l);return r>3&&l&&Object.defineProperty(o,s,l),l};let h=class extends o{constructor(){super(...arguments),this.currentIndex=0,this.autoPlay=!1,this.autoplaySpeed=3e3,this.intervalId=null}firstUpdated(){this.displayedElements=this.slideElements.map(((t,o)=>(o!=this.currentIndex&&t.classList.add("carousel-item-hidden"),t))),this.autoPlay&&this.startAutoPlay()}startAutoPlay(){this.intervalId=window.setInterval((()=>{this.next()}),this.autoplaySpeed)}stopAutoPlay(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null)}next(){this.displayedElements[this.currentIndex].classList.add("carousel-item-hidden"),this.displayedElements.length-1==this.currentIndex?this.currentIndex=0:this.currentIndex++,this.displayedElements[this.currentIndex].classList.remove("carousel-item-hidden")}prev(){this.displayedElements[this.currentIndex].classList.add("carousel-item-hidden"),0==this.currentIndex?this.currentIndex=this.displayedElements.length-1:this.currentIndex--,this.displayedElements[this.currentIndex].classList.remove("carousel-item-hidden")}goTo(t){this.displayedElements[this.currentIndex].classList.add("carousel-item-hidden"),this.currentIndex=t,this.displayedElements[this.currentIndex].classList.remove("carousel-item-hidden")}disconnectedCallback(){super.disconnectedCallback(),this.stopAutoPlay()}render(){var t;return s`
66
+ <div class="carousel">
67
+ <slot></slot>
68
+ ${this.autoPlay?e:s`
69
+ <div class="controls">
70
+ <nr-button
71
+ @click="${this.prev}"
72
+ type="ghost"
73
+ size="small"
74
+ class="button-control"
75
+ .icon="${["chevron-left"]}"
76
+ ></nr-button>
77
+ <nr-button
78
+ @click="${this.next}"
79
+ type="ghost"
80
+ size="small"
81
+ class="button-control"
82
+ .icon="${["chevron-right"]}"
83
+ ></nr-button>
84
+ </div>
85
+ `}
86
+
87
+ <div class="dots">
88
+ ${a(Array.from({length:null===(t=this.displayedElements)||void 0===t?void 0:t.length}),((t,o)=>s`
89
+ <span
90
+ class="dot ${o===this.currentIndex?"active":""}"
91
+ @click="${()=>this.goTo(o)}"
92
+ ></span>
93
+ `))}
94
+ </div
95
+ </div>
96
+ `}};h.styles=c,d([i({type:Number})],h.prototype,"currentIndex",void 0),d([i({type:Boolean})],h.prototype,"autoPlay",void 0),d([i({type:Number})],h.prototype,"autoplaySpeed",void 0),d([r()],h.prototype,"slideElements",void 0),d([l()],h.prototype,"displayedElements",void 0),h=d([n("hy-carousel")],h);export{h as CarouselComponent};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuralyui/carousel",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",