@aquera/nile-elements 1.4.3-beta-1.0 → 1.4.4-beta-1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +3 -0
  2. package/demo/index.html +65 -25
  3. package/dist/index.js +28 -50
  4. package/dist/nile-auto-complete/nile-auto-complete.cjs.js +1 -1
  5. package/dist/nile-auto-complete/nile-auto-complete.cjs.js.map +1 -1
  6. package/dist/nile-auto-complete/nile-auto-complete.esm.js +1 -1
  7. package/dist/nile-carousel/carousel-helpers.cjs.js +1 -1
  8. package/dist/nile-carousel/carousel-helpers.cjs.js.map +1 -1
  9. package/dist/nile-carousel/carousel-helpers.esm.js +1 -1
  10. package/dist/nile-carousel/index.cjs.js +1 -1
  11. package/dist/nile-carousel/index.esm.js +1 -1
  12. package/dist/nile-carousel/nile-carousel.cjs.js +1 -1
  13. package/dist/nile-carousel/nile-carousel.cjs.js.map +1 -1
  14. package/dist/nile-carousel/nile-carousel.css.cjs.js +1 -1
  15. package/dist/nile-carousel/nile-carousel.css.cjs.js.map +1 -1
  16. package/dist/nile-carousel/nile-carousel.css.esm.js +10 -40
  17. package/dist/nile-carousel/nile-carousel.esm.js +27 -19
  18. package/dist/src/nile-auto-complete/nile-auto-complete.js +1 -1
  19. package/dist/src/nile-auto-complete/nile-auto-complete.js.map +1 -1
  20. package/dist/src/nile-carousel/carousel-helpers.d.ts +3 -3
  21. package/dist/src/nile-carousel/carousel-helpers.js +21 -6
  22. package/dist/src/nile-carousel/carousel-helpers.js.map +1 -1
  23. package/dist/src/nile-carousel/nile-carousel.css.js +8 -38
  24. package/dist/src/nile-carousel/nile-carousel.css.js.map +1 -1
  25. package/dist/src/nile-carousel/nile-carousel.d.ts +3 -0
  26. package/dist/src/nile-carousel/nile-carousel.js +45 -11
  27. package/dist/src/nile-carousel/nile-carousel.js.map +1 -1
  28. package/dist/src/version.js +2 -2
  29. package/dist/src/version.js.map +1 -1
  30. package/dist/tsconfig.tsbuildinfo +1 -1
  31. package/package.json +1 -1
  32. package/src/nile-auto-complete/nile-auto-complete.ts +1 -1
  33. package/src/nile-carousel/carousel-helpers.ts +23 -6
  34. package/src/nile-carousel/nile-carousel.css.ts +8 -38
  35. package/src/nile-carousel/nile-carousel.ts +40 -11
  36. package/vscode-html-custom-data.json +18 -1
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Webcomponent nile-elements following open-wc recommendations",
4
4
  "license": "MIT",
5
5
  "author": "nile-elements",
6
- "version": "1.4.3-beta-1.0",
6
+ "version": "1.4.4-beta-1.0",
7
7
  "main": "dist/src/index.js",
8
8
  "type": "module",
9
9
  "module": "dist/src/index.js",
@@ -325,7 +325,7 @@ enableTabClose: this.enableTabClose,
325
325
  }
326
326
 
327
327
  private handleSearch(event: CustomEvent) {
328
- this.value = event.detail.value.toLowerCase();
328
+ this.value = event.detail.value;
329
329
 
330
330
  // Filter menu items based on the search value
331
331
  this.menuItems = this.applyFilter(this.allMenuItems,this.filterFunction);
@@ -47,14 +47,20 @@ export function getPageCount(slidesCount: number, slidesPerPage: number, slidesP
47
47
  }
48
48
 
49
49
  export function getCurrentPage(activeSlide: number, slidesPerMove: number): number {
50
- return Math.ceil(activeSlide / slidesPerMove);
50
+ return Math.floor(activeSlide / slidesPerMove);
51
51
  }
52
52
 
53
- export function canScrollNext(currentPage: number, pageCount: number): boolean {
53
+ export function canScrollNext(currentPage: number, pageCount: number, loop: boolean = false): boolean {
54
+ if (loop) {
55
+ return true;
56
+ }
54
57
  return currentPage < pageCount - 1;
55
58
  }
56
59
 
57
- export function canScrollPrev(currentPage: number): boolean {
60
+ export function canScrollPrev(currentPage: number, loop: boolean = false): boolean {
61
+ if (loop) {
62
+ return true;
63
+ }
58
64
  return currentPage > 0;
59
65
  }
60
66
 
@@ -119,14 +125,25 @@ export function goToSlide(
119
125
  index: number,
120
126
  slides: HTMLElement[],
121
127
  slidesPerPage: number,
122
- behavior: ScrollBehavior = 'smooth'
128
+ behavior: ScrollBehavior = 'smooth',
129
+ loop: boolean = false
123
130
  ): { newActiveSlide: number; slideToScroll: HTMLElement } | null {
124
131
  if (!slides.length) {
125
132
  return null;
126
133
  }
127
134
 
128
- const newActiveSlide = clamp(index, 0, slides.length - slidesPerPage);
129
- const nextSlideIndex = clamp(index, 0, slides.length - 1);
135
+ let newActiveSlide: number;
136
+ let nextSlideIndex: number;
137
+
138
+ if (loop) {
139
+ const totalSlides = slides.length;
140
+ nextSlideIndex = ((index % totalSlides) + totalSlides) % totalSlides;
141
+ newActiveSlide = clamp(nextSlideIndex, 0, slides.length - slidesPerPage);
142
+ } else {
143
+ newActiveSlide = clamp(index, 0, slides.length - slidesPerPage);
144
+ nextSlideIndex = clamp(index, 0, slides.length - 1);
145
+ }
146
+
130
147
  const nextSlide = slides[nextSlideIndex];
131
148
 
132
149
  return {
@@ -28,6 +28,14 @@ export const styles = css`
28
28
  align-items: center;
29
29
  gap: var(--nile-spacing-sm, var(--ng-spacing-sm));
30
30
  width: 100%;
31
+ position: relative;
32
+ }
33
+
34
+ .carousel__navigation-wrapper--top-right {
35
+ display: flex;
36
+ justify-content: flex-end;
37
+ gap: var(--nile-spacing-md, var(--ng-spacing-md));
38
+ margin-bottom: var(--nile-spacing-sm, var(--ng-spacing-sm));
31
39
  }
32
40
 
33
41
  .carousel__slides {
@@ -63,50 +71,12 @@ export const styles = css`
63
71
  min-width: 0;
64
72
  }
65
73
 
66
- .carousel__navigation-button {
67
- display: inline-flex;
68
- align-items: center;
69
- justify-content: center;
70
- width: 2.5rem;
71
- height: 2.5rem;
72
- padding: 0;
73
- background: rgba(255, 255, 255, 0.9);
74
- border: 1px solid var(--nile-colors-dark-200, var(--ng-colors-border-secondary));
75
- border-radius: 50%;
76
- color: var(--nile-colors-dark-900, var(--ng-colors-text-primary-900));
77
- cursor: pointer;
78
- flex-shrink: 0;
79
- transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
80
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
81
- }
82
-
83
- .carousel__navigation-button:hover:not(.carousel__navigation-button--disabled) {
84
- background: rgba(255, 255, 255, 1);
85
- border-color: var(--nile-colors-neutral-400, var(--ng-colors-border-tertiary));
86
- transform: scale(1.1);
87
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
88
- }
89
-
90
- .carousel__navigation-button:active:not(.carousel__navigation-button--disabled) {
91
- background: rgba(255, 255, 255, 1);
92
- transform: scale(0.95);
93
- }
94
-
95
74
  .carousel__navigation-button--disabled {
96
75
  opacity: 0.4;
97
76
  cursor: not-allowed;
98
77
  pointer-events: none;
99
78
  }
100
79
 
101
- .carousel__navigation-button:focus {
102
- outline: none;
103
- }
104
-
105
- .carousel__navigation-button:focus-visible {
106
- outline: 2px solid var(--nile-colors-primary-600, var(--ng-colors-text-brand-secondary-700));
107
- outline-offset: 2px;
108
- }
109
-
110
80
  .carousel__pagination {
111
81
  display: flex;
112
82
  align-items: center;
@@ -6,6 +6,7 @@
6
6
  */
7
7
 
8
8
  import '../nile-icon';
9
+ import '../nile-button';
9
10
  import './nile-carousel-item/nile-carousel-item';
10
11
  import { html, CSSResultArray, TemplateResult } from 'lit';
11
12
  import { classMap } from 'lit/directives/class-map.js';
@@ -38,6 +39,10 @@ export class NileCarousel extends NileElement {
38
39
 
39
40
  @property({ type: Boolean, reflect: true }) pagination = false;
40
41
 
42
+ @property({ type: Boolean, reflect: true }) loop = false;
43
+
44
+ @property({ type: String, attribute: 'navigation-position' }) navigationPosition: 'sides' | 'top-right' = 'sides';
45
+
41
46
  @property({ type: Number, attribute: 'slides-per-page' }) slidesPerPage = 1;
42
47
 
43
48
  @property({ type: Number, attribute: 'slides-per-move' }) slidesPerMove = 1;
@@ -88,11 +93,11 @@ export class NileCarousel extends NileElement {
88
93
  }
89
94
 
90
95
  private canScrollNext(): boolean {
91
- return canScrollNext(this.getCurrentPage(), this.getPageCount());
96
+ return canScrollNext(this.getCurrentPage(), this.getPageCount(), this.loop);
92
97
  }
93
98
 
94
99
  private canScrollPrev(): boolean {
95
- return canScrollPrev(this.getCurrentPage());
100
+ return canScrollPrev(this.getCurrentPage(), this.loop);
96
101
  }
97
102
 
98
103
  private getSlides() {
@@ -230,18 +235,30 @@ export class NileCarousel extends NileElement {
230
235
  }
231
236
 
232
237
  previous(behavior: ScrollBehavior = 'smooth') {
233
- this.goToSlide(this.activeSlide - this.slidesPerMove, behavior);
238
+ const slides = this.getSlides();
239
+ if (this.loop && this.activeSlide === 0) {
240
+ this.goToSlide(slides.length - this.slidesPerMove, behavior);
241
+ } else {
242
+ this.goToSlide(this.activeSlide - this.slidesPerMove, behavior);
243
+ }
234
244
  }
235
245
 
236
246
  next(behavior: ScrollBehavior = 'smooth') {
237
- this.goToSlide(this.activeSlide + this.slidesPerMove, behavior);
247
+ const slides = this.getSlides();
248
+ const maxIndex = slides.length - this.slidesPerPage;
249
+
250
+ if (this.loop && this.activeSlide >= maxIndex) {
251
+ this.goToSlide(0, behavior);
252
+ } else {
253
+ this.goToSlide(this.activeSlide + this.slidesPerMove, behavior);
254
+ }
238
255
  }
239
256
 
240
257
  goToSlide(index: number, behavior: ScrollBehavior = 'smooth') {
241
258
  const { slidesPerPage } = this;
242
259
  const slides = this.getSlides();
243
260
 
244
- const result = goToSlideHelper(index, slides, slidesPerPage, behavior);
261
+ const result = goToSlideHelper(index, slides, slidesPerPage, behavior, this.loop);
245
262
  if (!result || !this.scrollContainer) {
246
263
  return;
247
264
  }
@@ -264,22 +281,27 @@ export class NileCarousel extends NileElement {
264
281
  onClick: () => void
265
282
  ): TemplateResult {
266
283
  const isPrevious = direction === 'previous';
267
- const iconName = isPrevious ? 'arrowleft' : 'arrowright';
284
+ const iconName = isPrevious
285
+ ? 'var(--nile-icon-arrow-left, var(--ng-icon-arrow-narrow-left))'
286
+ : 'var(--nile-icon-arrow-right, var(--ng-icon-arrow-narrow-right))';
268
287
  const slotName = isPrevious ? 'previous-icon' : 'next-icon';
269
288
  const partName = isPrevious ? 'navigation-button--previous' : 'navigation-button--next';
270
289
  const ariaLabel = isPrevious ? 'Previous slide' : 'Next slide';
290
+ const isTopRight = this.navigationPosition === 'top-right';
271
291
 
272
292
  return html`
273
- <button
293
+ <nile-button
274
294
  part="navigation-button ${partName}"
275
295
  class="${classMap({
276
296
  'carousel__navigation-button': true,
277
297
  [`carousel__navigation-button--${direction}`]: true,
278
298
  'carousel__navigation-button--disabled': !enabled
279
299
  })}"
300
+ ?circle=${!isTopRight}
301
+ variant="tertiary"
302
+ ?disabled=${!enabled}
280
303
  aria-label="${ariaLabel}"
281
304
  aria-controls="scroll-container"
282
- aria-disabled="${enabled ? 'false' : 'true'}"
283
305
  @click=${enabled ? onClick : null}
284
306
  >
285
307
  <slot name="${slotName}">
@@ -288,7 +310,7 @@ export class NileCarousel extends NileElement {
288
310
  name="${iconName}"
289
311
  ></nile-icon>
290
312
  </slot>
291
- </button>
313
+ </nile-button>
292
314
  `;
293
315
  }
294
316
 
@@ -353,13 +375,20 @@ export class NileCarousel extends NileElement {
353
375
  render() {
354
376
  const prevEnabled = this.canScrollPrev();
355
377
  const nextEnabled = this.canScrollNext();
378
+ const isTopRight = this.navigationPosition === 'top-right';
356
379
 
357
380
  return html`
358
381
  <div part="base" class="carousel">
382
+ ${isTopRight && this.navigation ? html`
383
+ <div class="carousel__navigation-wrapper--top-right">
384
+ ${this.renderNavigationButton('previous', prevEnabled, () => this.previous())}
385
+ ${this.renderNavigationButton('next', nextEnabled, () => this.next())}
386
+ </div>
387
+ ` : ''}
359
388
  <div class="carousel__content-wrapper">
360
- ${this.navigation ? this.renderNavigationButton('previous', prevEnabled, () => this.previous()) : ''}
389
+ ${!isTopRight && this.navigation ? this.renderNavigationButton('previous', prevEnabled, () => this.previous()) : ''}
361
390
  ${this.renderScrollContainer()}
362
- ${this.navigation ? this.renderNavigationButton('next', nextEnabled, () => this.next()) : ''}
391
+ ${!isTopRight && this.navigation ? this.renderNavigationButton('next', nextEnabled, () => this.next()) : ''}
363
392
  </div>
364
393
  ${this.renderPagination()}
365
394
  </div>
@@ -693,7 +693,7 @@
693
693
  },
694
694
  {
695
695
  "name": "nile-carousel",
696
- "description": "Attributes:\n\n * `navigation` {`boolean`} - \n\n * `pagination` {`boolean`} - \n\n * `slides-per-page` {`number`} - \n\n * `slides-per-move` {`number`} - \n\nProperties:\n\n * `styles` {`CSSResultArray`} - \n\n * `navigation` {`boolean`} - \n\n * `pagination` {`boolean`} - \n\n * `slidesPerPage` {`number`} - \n\n * `slidesPerMove` {`number`} - \n\n * `scrollContainer` {`HTMLElement`} - \n\n * `paginationContainer` {`HTMLElement`} - \n\n * `activeSlide` {`number`} - \n\n * `scrolling` {`boolean`} - \n\n * `mutationObserver` {`MutationObserver`} - \n\n * `pendingSlideChange` {`boolean`} - \n\n * `handleScroll` - \n\n * `handleScrollEnd` - \n\n * `handleSlotChange` - \n\n * `BUBBLES` {`boolean`} - \n\n * `COMPOSED` {`boolean`} - \n\n * `CANCELABLE` {`boolean`} - ",
696
+ "description": "Attributes:\n\n * `navigation` {`boolean`} - \n\n * `pagination` {`boolean`} - \n\n * `loop` {`boolean`} - \n\n * `navigation-position` {`\"sides\" | \"top-right\"`} - \n\n * `slides-per-page` {`number`} - \n\n * `slides-per-move` {`number`} - \n\nProperties:\n\n * `styles` {`CSSResultArray`} - \n\n * `navigation` {`boolean`} - \n\n * `pagination` {`boolean`} - \n\n * `loop` {`boolean`} - \n\n * `navigationPosition` {`\"sides\" | \"top-right\"`} - \n\n * `slidesPerPage` {`number`} - \n\n * `slidesPerMove` {`number`} - \n\n * `scrollContainer` {`HTMLElement`} - \n\n * `paginationContainer` {`HTMLElement`} - \n\n * `activeSlide` {`number`} - \n\n * `scrolling` {`boolean`} - \n\n * `mutationObserver` {`MutationObserver`} - \n\n * `pendingSlideChange` {`boolean`} - \n\n * `handleScroll` - \n\n * `handleScrollEnd` - \n\n * `handleSlotChange` - \n\n * `BUBBLES` {`boolean`} - \n\n * `COMPOSED` {`boolean`} - \n\n * `CANCELABLE` {`boolean`} - ",
697
697
  "attributes": [
698
698
  {
699
699
  "name": "navigation",
@@ -705,6 +705,23 @@
705
705
  "description": "`pagination` {`boolean`} - \n\nProperty: pagination\n\nDefault: false",
706
706
  "valueSet": "v"
707
707
  },
708
+ {
709
+ "name": "loop",
710
+ "description": "`loop` {`boolean`} - \n\nProperty: loop\n\nDefault: false",
711
+ "valueSet": "v"
712
+ },
713
+ {
714
+ "name": "navigation-position",
715
+ "description": "`navigation-position` {`\"sides\" | \"top-right\"`} - \n\nProperty: navigationPosition\n\nDefault: sides",
716
+ "values": [
717
+ {
718
+ "name": "sides"
719
+ },
720
+ {
721
+ "name": "top-right"
722
+ }
723
+ ]
724
+ },
708
725
  {
709
726
  "name": "slides-per-page",
710
727
  "description": "`slides-per-page` {`number`} - \n\nProperty: slidesPerPage\n\nDefault: 1"