srcdev-nuxt-components 9.4.8 → 9.4.10

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 (113) hide show
  1. package/.claude/commands/migrate-component.md +20 -6
  2. package/.claude/component-ledger/audit.json +1 -1
  3. package/.claude/component-ledger/build.mjs +26 -0
  4. package/.claude/component-ledger/output.html +8 -3
  5. package/.claude/component-ledger/template.html +7 -2
  6. package/.claude/skills/component-dynamic-slots.md +1 -1
  7. package/.claude/skills/components/alert-mask-core.md +84 -0
  8. package/.claude/skills/components/canvas-switcher.md +1 -1
  9. package/.claude/skills/components/carousel-flip.md +112 -168
  10. package/.claude/skills/components/container-glow.md +123 -0
  11. package/.claude/skills/components/dashboard-quad-grid.md +98 -0
  12. package/.claude/skills/components/dashboard-stats-grid.md +103 -0
  13. package/.claude/skills/components/display-theme-switch.md +60 -0
  14. package/.claude/skills/components/glowing-border.md +66 -0
  15. package/.claude/skills/components/input-range-core.md +142 -0
  16. package/.claude/skills/components/section-parallax.md +32 -10
  17. package/.claude/skills/components/ui-block-decorated.md +56 -0
  18. package/.claude/skills/components/wipe-away-vertical.md +98 -0
  19. package/.claude/skills/icon-sets.md +1 -1
  20. package/.claude/skills/index.md +10 -1
  21. package/.vscode/css-custom-data.json +38 -0
  22. package/.vscode/settings.json +3 -0
  23. package/.vscode/srcdev-component-alert-mask-core.code-snippets +31 -0
  24. package/.vscode/srcdev-component-carousel-flip.code-snippets +41 -0
  25. package/.vscode/srcdev-component-container-glow.code-snippets +33 -0
  26. package/.vscode/srcdev-component-dashboard-quad-grid.code-snippets +36 -0
  27. package/.vscode/srcdev-component-dashboard-stats-grid.code-snippets +35 -0
  28. package/.vscode/srcdev-component-display-theme-switch.code-snippets +27 -0
  29. package/.vscode/srcdev-component-glowing-border.code-snippets +23 -0
  30. package/.vscode/srcdev-component-input-range.code-snippets +85 -0
  31. package/.vscode/srcdev-component-section-parallax.code-snippets +27 -0
  32. package/.vscode/srcdev-component-ui-block-decorated.code-snippets +24 -0
  33. package/.vscode/srcdev-component-wipe-away-vertical.code-snippets +25 -0
  34. package/README.md +18 -37
  35. package/app/components/{alert-mask → 01.atoms/alert-mask}/AlertMaskCore.vue +16 -17
  36. package/app/components/01.atoms/alert-mask/CONSUMER-STYLING.md +46 -0
  37. package/app/components/01.atoms/alert-mask/stories/AlertMaskCore.stories.ts +79 -0
  38. package/app/components/{alert-mask → 01.atoms/alert-mask}/tests/AlertMaskCore.spec.ts +10 -10
  39. package/app/components/01.atoms/animations/container-glow/CONSUMER-STYLING.md +86 -0
  40. package/app/components/01.atoms/animations/container-glow/ContainerGlow.vue +299 -0
  41. package/app/components/01.atoms/animations/container-glow/stories/ContainerGlow.stories.ts +175 -0
  42. package/app/components/01.atoms/animations/container-glow/tests/ContainerGlow.spec.ts +131 -0
  43. package/app/components/01.atoms/animations/container-glow/tests/__snapshots__/ContainerGlow.spec.ts.snap +14 -0
  44. package/app/components/01.atoms/animations/glowing-border/CONSUMER-STYLING.md +61 -0
  45. package/app/components/01.atoms/animations/glowing-border/GlowingBorder.vue +132 -0
  46. package/app/components/01.atoms/animations/glowing-border/stories/GlowingBorder.stories.ts +165 -0
  47. package/app/components/01.atoms/animations/glowing-border/tests/GlowingBorder.spec.ts +94 -0
  48. package/app/components/01.atoms/animations/glowing-border/tests/__snapshots__/GlowingBorder.spec.ts.snap +3 -0
  49. package/app/components/01.atoms/animations/section-parallax/CONSUMER-STYLING.md +44 -0
  50. package/app/components/{parallax → 01.atoms/animations/section-parallax}/SectionParallax.vue +11 -10
  51. package/app/components/01.atoms/animations/section-parallax/stories/SectionParallax.stories.ts +98 -0
  52. package/app/components/01.atoms/animations/section-parallax/tests/SectionParallax.spec.ts +102 -0
  53. package/app/components/01.atoms/animations/section-parallax/tests/__snapshots__/SectionParallax.spec.ts.snap +9 -0
  54. package/app/components/01.atoms/animations/view-timeline/CONSUMER-STYLING.md +70 -0
  55. package/app/components/01.atoms/animations/view-timeline/WipeAwayVertical.vue +181 -0
  56. package/app/components/01.atoms/animations/view-timeline/stories/WipeAwayVertical.stories.ts +269 -0
  57. package/app/components/01.atoms/animations/view-timeline/tests/WipeAwayVertical.spec.ts +127 -0
  58. package/app/components/01.atoms/canvas-switcher/CONSUMER-STYLING.md +1 -1
  59. package/app/components/01.atoms/canvas-switcher/stories/CanvasSwitcher.stories.ts +1 -1
  60. package/app/components/01.atoms/content-wrappers/layout-grid/dashboard-quad-grid/CONSUMER-STYLING.md +42 -0
  61. package/app/components/{layout-grids/LayoutGridA.vue → 01.atoms/content-wrappers/layout-grid/dashboard-quad-grid/DashboardQuadGrid.vue} +23 -13
  62. package/app/components/{layout-grids/stories/LayoutGridA.stories.ts → 01.atoms/content-wrappers/layout-grid/dashboard-quad-grid/stories/DashboardQuadGrid.stories.ts} +151 -23
  63. package/app/components/{layout-grids/tests/LayoutGridA.spec.ts → 01.atoms/content-wrappers/layout-grid/dashboard-quad-grid/tests/DashboardQuadGrid.spec.ts} +25 -25
  64. package/app/components/01.atoms/content-wrappers/layout-grid/dashboard-stats-grid/CONSUMER-STYLING.md +41 -0
  65. package/app/components/01.atoms/content-wrappers/layout-grid/dashboard-stats-grid/DashboardStatsGrid.vue +133 -0
  66. package/app/components/{layout-grids/stories/LayoutGridB.stories.ts → 01.atoms/content-wrappers/layout-grid/dashboard-stats-grid/stories/DashboardStatsGrid.stories.ts} +24 -24
  67. package/app/components/{layout-grids/tests/LayoutGridB.spec.ts → 01.atoms/content-wrappers/layout-grid/dashboard-stats-grid/tests/DashboardStatsGrid.spec.ts} +23 -23
  68. package/app/components/01.atoms/navigation/skip-links/SkipLinks.vue +7 -1
  69. package/app/components/01.atoms/ui-block-decorated/CONSUMER-STYLING.md +39 -0
  70. package/app/components/01.atoms/ui-block-decorated/UiBlockDecorated.vue +141 -0
  71. package/app/components/01.atoms/ui-block-decorated/stories/UiBlockDecorated.stories.ts +148 -0
  72. package/app/components/01.atoms/ui-block-decorated/tests/UiBlockDecorated.spec.ts +80 -0
  73. package/app/components/01.atoms/ui-block-decorated/tests/__snapshots__/UiBlockDecorated.spec.ts.snap +3 -0
  74. package/app/components/02.molecules/alert-masked-content/tests/AlertMaskedContent.spec.ts +6 -6
  75. package/app/components/02.molecules/display-theme-switch/CONSUMER-STYLING.md +34 -0
  76. package/app/components/02.molecules/display-theme-switch/DisplayThemeSwitch.vue +102 -0
  77. package/app/components/02.molecules/display-theme-switch/stories/DisplayThemeSwitch.stories.ts +115 -0
  78. package/app/components/02.molecules/display-theme-switch/tests/DisplayThemeSwitch.spec.ts +86 -0
  79. package/app/components/03.organisms/image-galleries/carousel-flip/CONSUMER-STYLING.md +46 -0
  80. package/app/components/{carousels → 03.organisms/image-galleries/carousel-flip}/CarouselFlip.vue +63 -42
  81. package/app/components/{carousels → 03.organisms/image-galleries/carousel-flip}/stories/CarouselFlip.stories.ts +96 -11
  82. package/app/components/{carousels → 03.organisms/image-galleries/carousel-flip}/tests/CarouselFlip.spec.ts +80 -0
  83. package/app/components/05.forms/form-field/FormField.vue +1 -1
  84. package/app/components/05.forms/form-wrapper/FormWrapper.vue +1 -1
  85. package/app/components/05.forms/input-range/CONSUMER-STYLING.md +45 -0
  86. package/app/components/05.forms/input-range/InputRangeCore.vue +79 -143
  87. package/app/components/05.forms/input-range/stories/InputRangeCore.stories.ts +126 -0
  88. package/app/components/05.forms/input-range/tests/InputRangeCore.spec.ts +124 -0
  89. package/app/components/05.forms/input-range/variants/InputRangeDefault.vue +9 -32
  90. package/app/components/05.forms/input-range/variants/stories/InputRangeDefault.stories.ts +108 -0
  91. package/app/components/05.forms/input-range/variants/tests/InputRangeDefault.spec.ts +140 -0
  92. package/app/components/05.forms/patterns/stories/MigratedFieldsForm.stories.ts +135 -0
  93. package/app/components/05.forms/triple-toggle-switch/CONSUMER-STYLING.md +16 -2
  94. package/app/components/05.forms/triple-toggle-switch/TripleToggleSwitchCore.vue +6 -4
  95. package/app/types/components/container-glow.d.ts +8 -0
  96. package/app/types/components/index.ts +1 -1
  97. package/package.json +3 -2
  98. package/app/components/05.forms/input-range-fancy/InputRangeFancyCore.vue +0 -426
  99. package/app/components/05.forms/input-range-fancy/InputRangeFancyWithLabel.vue +0 -94
  100. package/app/components/carousels/CarouselBasic.vue +0 -317
  101. package/app/components/carousels/CarouselInfinite.vue +0 -358
  102. package/app/components/container-glow/ContainerGlowCore.vue +0 -296
  103. package/app/components/container-glow/stories/ContainerGlowCore.stories.ts +0 -337
  104. package/app/components/display-theme-switch/DisplayThemeSwitch.vue +0 -189
  105. package/app/components/display-theme-switch/stories/DisplayThemeSwitch.stories.ts +0 -154
  106. package/app/components/glowing-border/GlowingBorder.vue +0 -142
  107. package/app/components/glowing-border/stories/GlowingBorder.stories.ts +0 -141
  108. package/app/components/layout-grids/LayoutGridB.vue +0 -134
  109. package/app/components/test-storybook/TestStorybook.vue +0 -49
  110. package/app/components/test-storybook/stories/TestStorybook.stories.ts +0 -28
  111. package/app/components/ui-block-decorated/UiBlockDecorated.vue +0 -167
  112. package/app/components/view-timeline/WipeAwayVertical.vue +0 -180
  113. package/app/types/components/carousel-basic.d.ts +0 -19
@@ -1,317 +0,0 @@
1
- <template>
2
- <section
3
- ref="carouselWrapperRef"
4
- class="carousel-basic"
5
- :class="[elementClasses]"
6
- role="region"
7
- aria-label="Image carousel"
8
- >
9
- <!-- Screen reader announcement for current item -->
10
- <div aria-live="polite" aria-atomic="true" class="sr-only">Item {{ currentIndex + 1 }} of {{ itemCount }}</div>
11
-
12
- <PageRow tag="div" variant="full" :style-class-passthrough="['mbe-20']">
13
- <div
14
- ref="carouselContainerRef"
15
- tabindex="0"
16
- class="item-container"
17
- :class="{ 'allow-overflow': allowCarouselOverflow }"
18
- role="group"
19
- aria-label="Carousel items"
20
- >
21
- <div
22
- v-for="(item, index) in carouselDataIds"
23
- :key="index"
24
- ref="carouselItems"
25
- class="item"
26
- :aria-current="currentIndex === index ? 'true' : 'false'"
27
- >
28
- <slot :name="item"></slot>
29
- </div>
30
- </div>
31
- </PageRow>
32
-
33
- <PageRow tag="div" variant="full" :style-class-passthrough="['mbe-20']">
34
- <div class="timeline-container">
35
- <div v-for="index in itemCount" :key="index" class="timeline-item">
36
- <div class="count">Step {{ index }}</div>
37
- </div>
38
- </div>
39
- </PageRow>
40
-
41
- <PageRow tag="div" variant="full" :style-class-passthrough="['mbe-20']">
42
- <div ref="controlsContainerRef" tabindex="0" class="controls-container">
43
- <div class="markers-container">
44
- <ul class="markers-list">
45
- <li v-for="index in itemCount" :key="index" class="markers-item">
46
- <button
47
- class="btn-marker"
48
- :class="[{ active: currentIndex === index - 1 }]"
49
- :aria-label="`Jump to item ${Math.floor(index + 1)}`"
50
- @click.prevent="jumpToFrame(index - 1)"
51
- ></button>
52
- </li>
53
- </ul>
54
- </div>
55
- <div class="buttons-container">
56
- <button type="button" class="btn-action" aria-label="Go to previous item" @click.prevent="actionPrevious()">
57
- <Icon name="ic:outline-keyboard-arrow-left" class="arrows-icon" />
58
- </button>
59
- <button type="button" class="btn-action" aria-label="Go to next item" @click.prevent="actionNext()">
60
- <Icon name="ic:outline-keyboard-arrow-right" class="arrows-icon" />
61
- </button>
62
- </div>
63
- </div>
64
- </PageRow>
65
- </section>
66
- </template>
67
-
68
- <script setup lang="ts">
69
- import { useEventListener, useResizeObserver, useSwipe } from "@vueuse/core";
70
-
71
- const props = defineProps({
72
- carouselDataIds: {
73
- type: Array as PropType<string[]>,
74
- default: () => [],
75
- },
76
- styleClassPassthrough: {
77
- type: [String, Array] as PropType<string | string[]>,
78
- default: () => [],
79
- },
80
- transitionSpeed: {
81
- type: Number,
82
- default: 200,
83
- },
84
- allowCarouselOverflow: {
85
- type: Boolean,
86
- default: false,
87
- },
88
- returnToStart: {
89
- type: Boolean,
90
- default: false,
91
- },
92
- });
93
-
94
- const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough);
95
-
96
- const carouselWrapperRef = ref<HTMLDivElement | null>(null);
97
- const carouselContainerRef = ref<HTMLDivElement | null>(null);
98
- const carouselItemsRef = useTemplateRef<HTMLDivElement[]>("carouselItems");
99
- const controlsContainerRef = ref<HTMLDivElement | null>(null);
100
- const carouselInitComplete = ref(false);
101
-
102
- const currentIndex = ref(0);
103
- const itemCount = ref(props.carouselDataIds.length);
104
- const offset = ref(0);
105
- const transitionSpeedStr = props.transitionSpeed + "ms";
106
- const itemTransform = computed(() => {
107
- return `translateX(calc(${offset.value} * (${itemWidth.value} + var(--_carousel-item-track-gap))))`;
108
- });
109
-
110
- const itemWidth = ref("0px");
111
-
112
- const actionPrevious = () => {
113
- if (props.returnToStart && currentIndex.value === 0) {
114
- offset.value = -itemCount.value;
115
- doAction();
116
- }
117
-
118
- if (offset.value >= 0) {
119
- return;
120
- }
121
-
122
- offset.value = Math.min(offset.value + 1);
123
- doAction();
124
- };
125
-
126
- const actionNext = () => {
127
- if (props.returnToStart && offset.value <= -1 * (itemCount.value - 1)) {
128
- offset.value = 0;
129
- doAction();
130
- return;
131
- }
132
-
133
- if (offset.value <= -1 * (itemCount.value - 1)) {
134
- return;
135
- }
136
-
137
- offset.value = Math.min(offset.value - 1);
138
- doAction();
139
- };
140
-
141
- const doAction = () => {
142
- currentIndex.value = Math.abs(offset.value);
143
- };
144
-
145
- const jumpToFrame = (index: number) => {
146
- if (index >= 0 && index < itemCount.value) {
147
- offset.value = -index;
148
- doAction();
149
- }
150
- };
151
-
152
- const initialSetup = () => {
153
- if (carouselItemsRef?.value && carouselItemsRef.value.length > 0 && carouselItemsRef.value[0]) {
154
- itemWidth.value = carouselItemsRef.value[0].offsetWidth + "px";
155
- }
156
-
157
- carouselInitComplete.value = true;
158
- };
159
-
160
- const { direction } = useSwipe(carouselContainerRef, {
161
- passive: false,
162
- onSwipeEnd() {
163
- if (direction.value === "left") {
164
- actionNext();
165
- } else if (direction.value === "right") {
166
- actionPrevious();
167
- }
168
- },
169
- });
170
-
171
- useEventListener(carouselContainerRef, "keydown", (event: KeyboardEvent) => {
172
- if (event.key === "ArrowLeft") {
173
- actionPrevious();
174
- } else if (event.key === "ArrowRight") {
175
- actionNext();
176
- }
177
- });
178
-
179
- useEventListener(controlsContainerRef, "keydown", (event: KeyboardEvent) => {
180
- if (event.key === "ArrowLeft") {
181
- actionPrevious();
182
- } else if (event.key === "ArrowRight") {
183
- actionNext();
184
- }
185
- });
186
-
187
- useResizeObserver(carouselWrapperRef, async () => {
188
- initialSetup();
189
- });
190
-
191
- onMounted(() => {
192
- initialSetup();
193
- });
194
- </script>
195
-
196
- <style lang="css">
197
- @layer components {
198
- .carousel-basic {
199
- --_carousel-item-track-gap: 10px;
200
-
201
- display: grid;
202
- grid-template-columns: 1fr;
203
- gap: 10px;
204
-
205
- .sr-only {
206
- position: absolute;
207
- width: 1px;
208
- height: 1px;
209
- padding: 0;
210
- margin: -1px;
211
- overflow: hidden;
212
- clip: rect(0, 0, 0, 0);
213
- white-space: nowrap;
214
- border: 0;
215
- }
216
-
217
- .timeline-container {
218
- display: flex;
219
- gap: var(--_carousel-item-track-gap);
220
- overflow-x: hidden;
221
-
222
- .timeline-item {
223
- display: flex;
224
- flex: 0 0 100%;
225
- max-inline-size: 800px;
226
- align-items: center;
227
- transform: v-bind(itemTransform);
228
- position: relative;
229
-
230
- &::before {
231
- content: "";
232
- position: absolute;
233
- height: 2px;
234
- background-color: #fff;
235
- left: 70px;
236
- right: 0;
237
- }
238
-
239
- .count {
240
- width: fit-content;
241
- }
242
- }
243
- }
244
-
245
- .item-container {
246
- display: flex;
247
- gap: var(--_carousel-item-track-gap);
248
- overflow-x: hidden;
249
- position: relative;
250
-
251
- &.allow-overflow {
252
- overflow-x: initial;
253
- }
254
-
255
- .item {
256
- display: flex;
257
- flex: 0 0 100%;
258
- max-inline-size: 800px;
259
- transition: transform v-bind(transitionSpeedStr) ease;
260
- transform: v-bind(itemTransform);
261
- }
262
- }
263
-
264
- .controls-container {
265
- display: flex;
266
- align-items: center;
267
- justify-content: flex-end;
268
-
269
- .markers-container {
270
- .markers-list {
271
- display: flex;
272
- flex-direction: row;
273
- gap: 10px;
274
- list-style-type: none;
275
- margin: unset;
276
- padding: unset;
277
-
278
- .markers-item {
279
- .btn-marker {
280
- border: none;
281
- outline: none;
282
- box-shadow: none;
283
- cursor: pointer;
284
- transition: background-color v-bind(transitionSpeedStr) linear;
285
-
286
- &.active {
287
- background-color: red;
288
- }
289
- }
290
- }
291
- }
292
- }
293
-
294
- .buttons-container {
295
- display: flex;
296
- align-items: center;
297
- justify-content: end;
298
- gap: 20px;
299
-
300
- .btn-action {
301
- display: flex;
302
- align-items: center;
303
- justify-content: center;
304
-
305
- cursor: pointer;
306
- height: fit-content;
307
-
308
- .arrows-icon {
309
- width: 24px;
310
- height: 24px;
311
- }
312
- }
313
- }
314
- }
315
- }
316
- }
317
- </style>
@@ -1,358 +0,0 @@
1
- <template>
2
- <section
3
- class="carousel-infinite"
4
- :class="[elementClasses]"
5
- ref="carouselWrapperRef"
6
- role="region"
7
- aria-label="Image carousel"
8
- >
9
- <!-- Screen reader announcement for current item -->
10
- <div aria-live="polite" aria-atomic="true" class="sr-only">
11
- Item {{ currentVisibleIndex + 1 }} of {{ itemCount }}
12
- </div>
13
-
14
- <PageRow tag="div" variant="full" :style-class-passthrough="['mbe-20']">
15
- <div
16
- tabindex="0"
17
- class="item-container"
18
- :class="{ 'allow-overflow': allowCarouselOverflow }"
19
- ref="carouselContainerRef"
20
- role="group"
21
- aria-label="Carousel items"
22
- >
23
- <div
24
- v-for="(item, index) in carouselDataIds"
25
- :key="index"
26
- class="item"
27
- ref="carouselItems"
28
- :aria-current="currentVisibleIndex === index ? 'true' : 'false'"
29
- >
30
- <slot :name="item"></slot>
31
- </div>
32
- </div>
33
- </PageRow>
34
-
35
- <PageRow tag="div" variant="full" :style-class-passthrough="['mbe-20']">
36
- <div tabindex="0" class="controls-container" ref="controlsContainerRef">
37
- <div class="markers-container">
38
- <ul class="markers-list">
39
- <li v-for="index in itemCount" :key="index" class="markers-item">
40
- <button
41
- @click.prevent="jumpToFrame(index - 1)"
42
- class="btn-marker"
43
- :class="[{ active: currentVisibleIndex === index - 1 }]"
44
- :aria-label="`Jump to item ${Math.floor(index + 1)}`"
45
- ></button>
46
- </li>
47
- </ul>
48
- </div>
49
- <div class="buttons-container">
50
- <button type="button" @click.prevent="actionPrevious()" class="btn-action" aria-label="Go to previous item">
51
- <Icon name="ic:outline-keyboard-arrow-left" class="arrows-icon" />
52
- </button>
53
- <button type="button" @click.prevent="actionNext()" class="btn-action" aria-label="Go to next item">
54
- <Icon name="ic:outline-keyboard-arrow-right" class="arrows-icon" />
55
- </button>
56
- </div>
57
- </div>
58
- </PageRow>
59
- </section>
60
- </template>
61
-
62
- <script setup lang="ts">
63
- import { useEventListener, useResizeObserver, useSwipe } from "@vueuse/core";
64
-
65
- const props = defineProps({
66
- carouselDataIds: {
67
- type: Array as PropType<string[]>,
68
- default: () => [],
69
- },
70
- styleClassPassthrough: {
71
- type: [String, Array] as PropType<string | string[]>,
72
- default: () => [],
73
- },
74
- transitionSpeed: {
75
- type: Number,
76
- default: 200,
77
- },
78
- allowCarouselOverflow: {
79
- type: Boolean,
80
- default: false,
81
- },
82
- returnToStart: {
83
- type: Boolean,
84
- default: false,
85
- },
86
- });
87
-
88
- const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough);
89
-
90
- const carouselWrapperRef = ref<HTMLDivElement | null>(null);
91
- const carouselContainerRef = ref<HTMLDivElement | null>(null);
92
- const carouselItemsRef = useTemplateRef<HTMLDivElement[]>("carouselItems");
93
- const controlsContainerRef = ref<HTMLDivElement | null>(null);
94
- const carouselInitComplete = ref(false);
95
-
96
- const currentIndex = ref(0);
97
- const itemCount = ref(props.carouselDataIds.length);
98
- const transitionSpeedStr = props.transitionSpeed + "ms";
99
-
100
- const itemWidth = ref(0);
101
- const itemWidthOffsetStr = computed(() => {
102
- return `-${itemWidth.value}px`;
103
- });
104
-
105
- const currentVisibleIndex = ref(0);
106
-
107
- const carouselContainerRefLeftPosition = computed(() => {
108
- return carouselContainerRef.value ? carouselContainerRef.value.getBoundingClientRect().left : 0;
109
- });
110
- const fullScreenOffsset = computed(() => {
111
- return `-${Math.floor(carouselContainerRefLeftPosition.value)}px`;
112
- });
113
- console.log(
114
- "INIT: carouselContainerRefLeftPosition:",
115
- carouselContainerRefLeftPosition.value,
116
- "fullScreenOffsset:",
117
- fullScreenOffsset.value
118
- );
119
-
120
- const updateItemOrder = (index: number, order: number, zIndex: number = 2) => {
121
- if (carouselItemsRef?.value && carouselItemsRef.value[index]) {
122
- carouselItemsRef.value[index].style.order = order.toString();
123
- carouselItemsRef.value[index].style.zIndex = zIndex.toString();
124
- }
125
- };
126
-
127
- const reorderItems = (direction: "next" | "previous" | "jump" = "jump") => {
128
- console.log(`Reordering items in direction: ${direction}`);
129
- if (!carouselItemsRef?.value || !carouselInitComplete.value) return;
130
-
131
- // Capture positions before reordering
132
- const beforeRects = carouselItemsRef.value.map((item) => item.getBoundingClientRect());
133
-
134
- // Apply new order and z-index based on direction
135
- let order = 1;
136
-
137
- // For items from currentVisibleIndex to end
138
- for (let i = currentVisibleIndex.value; i < itemCount.value; i++) {
139
- let zIndex = 2; // default normal z-index
140
-
141
- if (i === currentVisibleIndex.value) {
142
- // The item becoming visible
143
- if (direction === "previous") {
144
- // When going previous, the item moving to first position should go behind
145
- zIndex = 1;
146
- } else {
147
- // Normal case - visible item gets highest z-index
148
- zIndex = 3;
149
- }
150
- }
151
-
152
- updateItemOrder(i, order++, zIndex);
153
- }
154
-
155
- // For items from 0 to currentVisibleIndex
156
- for (let i = 0; i < currentVisibleIndex.value; i++) {
157
- // Items that wrap around get lower z-index to slide behind
158
- const zIndex = 1;
159
- updateItemOrder(i, order++, zIndex);
160
- }
161
- };
162
-
163
- const actionPrevious = () => {
164
- if (!carouselInitComplete.value || !carouselItemsRef?.value) return;
165
-
166
- if (props.returnToStart && currentVisibleIndex.value === 0) {
167
- currentVisibleIndex.value = itemCount.value - 1;
168
- } else {
169
- currentVisibleIndex.value = currentVisibleIndex.value === 0 ? itemCount.value - 1 : currentVisibleIndex.value - 1;
170
- }
171
-
172
- reorderItems("previous");
173
- currentIndex.value = currentVisibleIndex.value;
174
- };
175
-
176
- const actionNext = () => {
177
- if (!carouselInitComplete.value || !carouselItemsRef?.value) return;
178
-
179
- if (props.returnToStart && currentVisibleIndex.value === itemCount.value - 1) {
180
- currentVisibleIndex.value = 0;
181
- } else {
182
- currentVisibleIndex.value = currentVisibleIndex.value === itemCount.value - 1 ? 0 : currentVisibleIndex.value + 1;
183
- }
184
-
185
- reorderItems("next");
186
- currentIndex.value = currentVisibleIndex.value;
187
- };
188
-
189
- const jumpToFrame = (index: number) => {
190
- if (index >= 0 && index < itemCount.value) {
191
- currentVisibleIndex.value = index;
192
- reorderItems("jump");
193
- currentIndex.value = currentVisibleIndex.value;
194
- }
195
- };
196
-
197
- const checkAndMoveLastItem = () => {
198
- if (props.allowCarouselOverflow) {
199
- const itemsFit = Math.floor(carouselContainerRefLeftPosition.value / itemWidth.value + 1);
200
- jumpToFrame(itemCount.value - 1);
201
- }
202
- };
203
-
204
- const initialSetup = () => {
205
- if (carouselItemsRef?.value && carouselItemsRef.value.length > 0 && carouselItemsRef.value[0]) {
206
- itemWidth.value = carouselItemsRef.value[0].offsetWidth;
207
-
208
- // Set initial order and z-index for all items
209
- carouselItemsRef.value.forEach((item, index) => {
210
- item.style.order = String(index + 1);
211
- // First item gets higher z-index, others get normal z-index
212
- item.style.zIndex = index === 0 ? "3" : "2";
213
- });
214
- }
215
-
216
- carouselInitComplete.value = true;
217
- checkAndMoveLastItem();
218
- };
219
-
220
- const { direction } = useSwipe(carouselContainerRef, {
221
- passive: false,
222
- onSwipeEnd() {
223
- if (direction.value === "left") {
224
- actionNext();
225
- } else if (direction.value === "right") {
226
- actionPrevious();
227
- }
228
- },
229
- });
230
-
231
- useEventListener(carouselContainerRef, "keydown", (event: KeyboardEvent) => {
232
- if (event.key === "ArrowLeft") {
233
- actionPrevious();
234
- } else if (event.key === "ArrowRight") {
235
- actionNext();
236
- }
237
- });
238
-
239
- useEventListener(controlsContainerRef, "keydown", (event: KeyboardEvent) => {
240
- if (event.key === "ArrowLeft") {
241
- actionPrevious();
242
- } else if (event.key === "ArrowRight") {
243
- actionNext();
244
- }
245
- });
246
-
247
- useResizeObserver(carouselWrapperRef, async () => {
248
- initialSetup();
249
- });
250
-
251
- onMounted(() => {
252
- initialSetup();
253
- console.log(
254
- "onMounted: carouselContainerRefLeftPosition:",
255
- carouselContainerRefLeftPosition.value,
256
- "fullScreenOffsset:",
257
- fullScreenOffsset.value
258
- );
259
- });
260
- </script>
261
-
262
- <style lang="css">
263
- @layer components {
264
- .carousel-infinite {
265
- --_carousel-item-track-gap: 10px;
266
-
267
- display: grid;
268
- grid-template-columns: 1fr;
269
- gap: 10px;
270
-
271
- .sr-only {
272
- position: absolute;
273
- width: 1px;
274
- height: 1px;
275
- padding: 0;
276
- margin: -1px;
277
- overflow: hidden;
278
- clip: rect(0, 0, 0, 0);
279
- white-space: nowrap;
280
- border: 0;
281
- }
282
-
283
- .item-container {
284
- display: flex;
285
- gap: var(--_carousel-item-track-gap);
286
- overflow-x: hidden;
287
- position: relative;
288
-
289
- &.allow-overflow {
290
- overflow-x: initial;
291
-
292
- .item {
293
- translate: calc(v-bind(itemWidthOffsetStr) - var(--_carousel-item-track-gap)) 0;
294
- }
295
- }
296
-
297
- .item {
298
- display: flex;
299
- flex: 0 0 100%;
300
- max-inline-size: 800px;
301
- position: relative;
302
- }
303
- }
304
-
305
- .controls-container {
306
- display: flex;
307
- align-items: center;
308
- justify-content: flex-end;
309
-
310
- .markers-container {
311
- .markers-list {
312
- display: flex;
313
- flex-direction: row;
314
- gap: 10px;
315
- list-style-type: none;
316
- margin: unset;
317
- padding: unset;
318
-
319
- .markers-item {
320
- .btn-marker {
321
- border: none;
322
- outline: none;
323
- box-shadow: none;
324
- cursor: pointer;
325
- transition: background-color v-bind(transitionSpeedStr) linear;
326
-
327
- &.active {
328
- background-color: red;
329
- }
330
- }
331
- }
332
- }
333
- }
334
-
335
- .buttons-container {
336
- display: flex;
337
- align-items: center;
338
- justify-content: end;
339
- gap: 20px;
340
-
341
- .btn-action {
342
- display: flex;
343
- align-items: center;
344
- justify-content: center;
345
-
346
- cursor: pointer;
347
- height: fit-content;
348
-
349
- .arrows-icon {
350
- width: 24px;
351
- height: 24px;
352
- }
353
- }
354
- }
355
- }
356
- }
357
- }
358
- </style>