@uibit/carousel 0.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.
@@ -0,0 +1,81 @@
1
+ <script lang="ts">
2
+ import '@uibit/carousel';
3
+ import type { UIBitCarousel as HTMLElementClass } from '@uibit/carousel';
4
+
5
+ let {
6
+ autoPlay = undefined,
7
+ autoPlayInterval = undefined,
8
+ loop = undefined,
9
+ content = undefined,
10
+ viewport = undefined,
11
+ slotElement = undefined,
12
+ currentIndex = undefined,
13
+ totalSlides = undefined,
14
+ canPrev = undefined,
15
+ canNext = undefined,
16
+ item = undefined,
17
+ children
18
+ } = $props<{
19
+ children?: any;
20
+ autoPlay?: boolean;
21
+ autoPlayInterval?: number;
22
+ loop?: boolean;
23
+ content?: HTMLElement | undefined;
24
+ viewport?: HTMLElement | undefined;
25
+ slotElement?: HTMLSlotElement | undefined;
26
+ currentIndex?: number;
27
+ totalSlides?: number;
28
+ canPrev?: boolean;
29
+ canNext?: boolean;
30
+ item?: import('svelte').Snippet;
31
+ }>();
32
+
33
+ let elementRef: HTMLElementClass | null = $state(null);
34
+
35
+ $effect(() => {
36
+ if (elementRef && autoPlay !== undefined) {
37
+ elementRef.autoPlay = autoPlay;
38
+ }
39
+ if (elementRef && autoPlayInterval !== undefined) {
40
+ elementRef.autoPlayInterval = autoPlayInterval;
41
+ }
42
+ if (elementRef && loop !== undefined) {
43
+ elementRef.loop = loop;
44
+ }
45
+ if (elementRef && content !== undefined) {
46
+ elementRef.content = content;
47
+ }
48
+ if (elementRef && viewport !== undefined) {
49
+ elementRef.viewport = viewport;
50
+ }
51
+ if (elementRef && slotElement !== undefined) {
52
+ elementRef.slotElement = slotElement;
53
+ }
54
+ if (elementRef && currentIndex !== undefined) {
55
+ elementRef.currentIndex = currentIndex;
56
+ }
57
+ if (elementRef && totalSlides !== undefined) {
58
+ elementRef.totalSlides = totalSlides;
59
+ }
60
+ if (elementRef && canPrev !== undefined) {
61
+ elementRef.canPrev = canPrev;
62
+ }
63
+ if (elementRef && canNext !== undefined) {
64
+ elementRef.canNext = canNext;
65
+ }
66
+ });
67
+
68
+ </script>
69
+
70
+ <uibit-carousel bind:this={elementRef} {...$$restProps}>
71
+ {#if item}
72
+ <div slot="item">
73
+ {@render item()}
74
+ </div>
75
+ {/if}
76
+ {#if children}
77
+ {@render children()}
78
+ {:else}
79
+ <slot />
80
+ {/if}
81
+ </uibit-carousel>
@@ -0,0 +1,33 @@
1
+ import { defineComponent, h } from 'vue';
2
+ import type { UIBitCarousel as HTMLElementClass } from '@uibit/carousel';
3
+ import '@uibit/carousel';
4
+
5
+ export const UIBitCarousel = defineComponent({
6
+ name: 'UIBitCarousel',
7
+ props: {
8
+ autoPlay: { type: [String, Number, Boolean, Array, Object] as any },
9
+ autoPlayInterval: { type: [String, Number, Boolean, Array, Object] as any },
10
+ loop: { type: [String, Number, Boolean, Array, Object] as any },
11
+ content: { type: [String, Number, Boolean, Array, Object] as any },
12
+ viewport: { type: [String, Number, Boolean, Array, Object] as any },
13
+ slotElement: { type: [String, Number, Boolean, Array, Object] as any },
14
+ currentIndex: { type: [String, Number, Boolean, Array, Object] as any },
15
+ totalSlides: { type: [String, Number, Boolean, Array, Object] as any },
16
+ canPrev: { type: [String, Number, Boolean, Array, Object] as any },
17
+ canNext: { type: [String, Number, Boolean, Array, Object] as any }
18
+ },
19
+ emits: ['slide-change'],
20
+ setup(props, { slots, emit }) {
21
+ return () => {
22
+ const eventListeners: Record<string, any> = {};
23
+ eventListeners['onSlide-change'] = (event: Event) => {
24
+ emit('slide-change', event);
25
+ };
26
+
27
+ return h('uibit-carousel', {
28
+ ...props,
29
+ ...eventListeners
30
+ }, slots.default?.());
31
+ };
32
+ }
33
+ });
@@ -0,0 +1,3 @@
1
+ export { UIBitCarousel as default } from './carousel';
2
+ export type { CarouselConfig, SlideChangeEvent } from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,MAAM,YAAY,CAAC;AACtD,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { UIBitCarousel as default } from './carousel';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const styles: import("lit").CSSResult;
2
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,yBAgKlB,CAAC"}
package/dist/styles.js ADDED
@@ -0,0 +1,163 @@
1
+ import { css } from 'lit';
2
+ export const styles = css `
3
+ :host {
4
+ --uibit-carousel-gap: var(--uibit-spacing-4, 1rem);
5
+ --uibit-carousel-padding: 0;
6
+ --uibit-carousel-duration: 300ms;
7
+ --uibit-carousel-items-per-view: 1;
8
+ --uibit-carousel-border-color: var(--uibit-border-color, var(--uibit-color-gray-200, #e5e7eb));
9
+ --uibit-carousel-button-bg: var(--uibit-bg-surface, var(--uibit-color-white, #ffffff));
10
+ --uibit-carousel-button-bg-hover: var(--uibit-focus-color, var(--uibit-color-black, #000000));
11
+ --uibit-carousel-button-color-hover: var(--uibit-color-white, #ffffff);
12
+ --uibit-carousel-indicator-bg: var(--uibit-border-color, var(--uibit-color-gray-200, #e5e7eb));
13
+ --uibit-carousel-indicator-active-bg: var(--uibit-focus-color, var(--uibit-color-black, #000000));
14
+ --uibit-carousel-focus-color: var(--uibit-focus-color, var(--uibit-color-black, #000000));
15
+ display: block;
16
+ width: 100%;
17
+ }
18
+
19
+ .carousel {
20
+ display: flex;
21
+ flex-direction: column;
22
+ gap: var(--uibit-spacing-4, 1rem);
23
+ width: 100%;
24
+ }
25
+
26
+ .carousel-viewport {
27
+ position: relative;
28
+ overflow: hidden;
29
+ border: 0.0625rem solid var(--uibit-carousel-border-color);
30
+ border-radius: var(--uibit-radius-2xl, 0.75rem);
31
+ background-color: var(--uibit-bg-surface, var(--uibit-color-white, #ffffff));
32
+ }
33
+
34
+ .carousel-content {
35
+ display: flex;
36
+ gap: var(--uibit-carousel-gap);
37
+ overflow-x: auto;
38
+ scroll-behavior: smooth;
39
+ scroll-snap-type: x mandatory;
40
+ padding: var(--uibit-carousel-padding, 0);
41
+ width: 100%;
42
+ scrollbar-width: none;
43
+ -ms-overflow-style: none;
44
+ }
45
+
46
+ .carousel-content::-webkit-scrollbar {
47
+ display: none;
48
+ }
49
+
50
+ slot[name='item'] {
51
+ display: contents;
52
+ }
53
+
54
+ ::slotted([slot='item']),
55
+ ::slotted(:not([slot])) {
56
+ scroll-snap-align: start;
57
+ scroll-snap-stop: always;
58
+ width: calc(
59
+ (100% - (var(--uibit-carousel-items-per-view, 1) - 1) * var(--uibit-carousel-gap, 1rem)) /
60
+ var(--uibit-carousel-items-per-view, 1)
61
+ );
62
+ flex-shrink: 0;
63
+ min-width: 0;
64
+ }
65
+
66
+ .carousel-controls {
67
+ display: flex;
68
+ align-items: center;
69
+ justify-content: space-between;
70
+ gap: var(--uibit-spacing-4, 1rem);
71
+ }
72
+
73
+ .carousel-buttons {
74
+ display: flex;
75
+ gap: 0.5rem;
76
+ }
77
+
78
+ .carousel-button {
79
+ width: 2.25rem;
80
+ height: 2.25rem;
81
+ background-color: var(--uibit-carousel-button-bg, #ffffff);
82
+ border: 0.0625rem solid var(--uibit-carousel-border-color, #e5e7eb);
83
+ border-radius: 9999rem;
84
+ cursor: pointer;
85
+ color: var(--uibit-text-primary, #111827);
86
+ transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease, opacity 100ms ease, transform 150ms ease;
87
+ display: inline-flex;
88
+ align-items: center;
89
+ justify-content: center;
90
+ box-shadow: none;
91
+ }
92
+
93
+ .carousel-button:hover:not(:disabled) {
94
+ background-color: var(--uibit-carousel-button-bg-hover, #f3f4f6);
95
+ color: var(--uibit-carousel-button-color-hover, #ffffff);
96
+ border-color: var(--uibit-carousel-button-bg-hover, #000000);
97
+ box-shadow: none;
98
+ transform: scale(1.06);
99
+ }
100
+
101
+ .carousel-button:active:not(:disabled) {
102
+ transform: scale(0.95);
103
+ }
104
+
105
+ .carousel-button:disabled {
106
+ opacity: 0.3;
107
+ cursor: not-allowed;
108
+ }
109
+
110
+ .carousel-button:focus-visible {
111
+ outline: 0.125rem solid var(--uibit-carousel-focus-color);
112
+ outline-offset: 0.125rem;
113
+ }
114
+
115
+ .carousel-indicators {
116
+ display: flex;
117
+ gap: 0.5rem;
118
+ align-items: center;
119
+ justify-content: center;
120
+ }
121
+
122
+ .carousel-indicator {
123
+ width: 0.5rem;
124
+ height: 0.5rem;
125
+ border-radius: 9999rem;
126
+ background-color: var(--uibit-carousel-indicator-bg);
127
+ cursor: pointer;
128
+ border: none;
129
+ padding: 0;
130
+ transition: background-color 150ms ease, width 150ms ease, border-radius 150ms ease, opacity 100ms ease;
131
+ }
132
+
133
+ .carousel-indicator:hover {
134
+ background-color: var(--uibit-carousel-indicator-active-bg);
135
+ }
136
+
137
+ .carousel-indicator:active {
138
+ opacity: 0.6;
139
+ }
140
+
141
+ .carousel-indicator.active {
142
+ width: 1.25rem;
143
+ border-radius: 0.25rem;
144
+ background-color: var(--uibit-carousel-indicator-active-bg);
145
+ }
146
+
147
+ .carousel-indicator:focus-visible {
148
+ outline: 0.125rem solid var(--uibit-carousel-focus-color);
149
+ outline-offset: 0.125rem;
150
+ }
151
+
152
+ @media (max-width: 40rem) {
153
+ .carousel-controls {
154
+ flex-wrap: wrap;
155
+ }
156
+
157
+ .carousel-content {
158
+ padding: var(--uibit-carousel-padding, 0);
159
+ }
160
+ }
161
+
162
+ `;
163
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgKxB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type UIBitCarousel from './carousel';
2
+ export interface CarouselConfig {
3
+ autoPlay?: boolean;
4
+ autoPlayInterval?: number;
5
+ loop?: boolean;
6
+ itemsPerView?: number;
7
+ gap?: number;
8
+ duration?: number;
9
+ }
10
+ export interface SlideChangeEvent extends CustomEvent {
11
+ detail: {
12
+ index: number;
13
+ totalSlides: number;
14
+ };
15
+ }
16
+ declare global {
17
+ interface HTMLElementTagNameMap {
18
+ 'uibit-carousel': UIBitCarousel;
19
+ }
20
+ }
21
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,YAAY,CAAC;AAE5C,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,OAAO,CAAC,MAAM,CAAC;IACf,UAAU,qBAAqB;QAC3B,gBAAgB,EAAE,aAAa,CAAC;KACnC;CACA"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,92 @@
1
+ {
2
+ "name": "@uibit/carousel",
3
+ "version": "0.1.0",
4
+ "description": "Native, accessible carousel using CSS scroll-snap and scroll-driven animations. Perfect for image galleries, testimonials, and product showcases.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./carousel.css": "./dist/carousel.css",
14
+ "./custom-elements.json": "./custom-elements.json",
15
+ "./react": "./dist/frameworks/react/index.d.ts",
16
+ "./vue": "./dist/frameworks/vue/index.ts",
17
+ "./svelte": "./dist/frameworks/svelte/index.svelte",
18
+ "./angular": "./dist/frameworks/angular/index.ts",
19
+ "./solid": "./dist/frameworks/solid/index.d.ts",
20
+ "./astro": "./dist/frameworks/astro/index.astro",
21
+ "./qwik": "./dist/frameworks/qwik/index.tsx",
22
+ "./nuxt": "./dist/frameworks/nuxt/index.ts",
23
+ "./preact": "./dist/frameworks/preact/index.d.ts",
24
+ "./stencil": "./dist/frameworks/stencil/index.d.ts"
25
+ },
26
+ "files": [
27
+ "dist",
28
+ "package.json",
29
+ "README.md",
30
+ "LICENSE",
31
+ "custom-elements.json"
32
+ ],
33
+ "keywords": [
34
+ "carousel",
35
+ "web-component",
36
+ "lit",
37
+ "scroll-snap",
38
+ "accessible",
39
+ "a11y"
40
+ ],
41
+ "author": "Jonathan Rawlings",
42
+ "license": "MIT",
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "https://github.com/Rawlings/uibit",
46
+ "directory": "packages/components/carousel"
47
+ },
48
+ "dependencies": {
49
+ "lucide": "^1.24.0",
50
+ "@uibit/core": "0.1.0"
51
+ },
52
+ "devDependencies": {
53
+ "@types/node": "^20.19.43",
54
+ "lit": "^3.3.3",
55
+ "typescript": "7.0.2",
56
+ "@uibit/codegen": "0.1.0"
57
+ },
58
+ "peerDependencies": {
59
+ "lit": "^3.0.0",
60
+ "react": ">=18",
61
+ "vue": ">=3",
62
+ "svelte": ">=4 || ^5",
63
+ "@angular/core": ">=14"
64
+ },
65
+ "customElements": "custom-elements.json",
66
+ "peerDependenciesMeta": {
67
+ "react": {
68
+ "optional": true
69
+ },
70
+ "vue": {
71
+ "optional": true
72
+ },
73
+ "svelte": {
74
+ "optional": true
75
+ },
76
+ "@angular/core": {
77
+ "optional": true
78
+ }
79
+ },
80
+ "uibit": {
81
+ "id": "carousel",
82
+ "title": "Carousel",
83
+ "category": "Media",
84
+ "tagName": "uibit-carousel"
85
+ },
86
+ "scripts": {
87
+ "build": "cem analyze --globs 'src/**/*.ts' --litelement && uibit-codegen --package . && tsc",
88
+ "dev": "concurrently \"cem analyze --globs 'src/**/*.ts' --litelement --watch\" \"tsc --watch\"",
89
+ "analyze": "cem analyze --globs 'src/**/*.ts' --litelement",
90
+ "typecheck": "tsc --noEmit"
91
+ }
92
+ }