@uibit/carousel 0.1.1 → 0.2.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.
@@ -710,6 +710,14 @@
710
710
  "module": "./carousel"
711
711
  }
712
712
  },
713
+ {
714
+ "kind": "js",
715
+ "name": "UIBitCarousel",
716
+ "declaration": {
717
+ "name": "UIBitCarousel",
718
+ "module": "./carousel"
719
+ }
720
+ },
713
721
  {
714
722
  "kind": "js",
715
723
  "name": "CarouselConfig",
@@ -1,86 +1,98 @@
1
- import { Component, ChangeDetectionStrategy, ElementRef, input, effect, output, booleanAttribute, numberAttribute } from '@angular/core';
1
+ import { Component, ChangeDetectionStrategy, ElementRef, model, input, effect, output, booleanAttribute, numberAttribute } from '@angular/core';
2
2
  import '@uibit/carousel';
3
3
  import type { UIBitCarousel as HTMLElementClass } from '@uibit/carousel';
4
-
5
4
  @Component({
6
- selector: 'uibit-carousel',
7
- template: '<ng-content></ng-content>',
8
- changeDetection: ChangeDetectionStrategy.OnPush,
9
- standalone: true,
10
- host: {
11
- '(slide-change)': 'slideChange.emit($event)'
12
- }
5
+ selector: 'uibit-carousel',
6
+ template: '<ng-content></ng-content>',
7
+ changeDetection: ChangeDetectionStrategy.OnPush,
8
+ standalone: true,
9
+ host: {
10
+ '(slide-change)': 'slideChange.emit($event); totalSlides.set($event.detail?.totalSlides !== undefined ? $event.detail.totalSlides : $event.target.totalSlides)'
11
+ }
13
12
  })
14
13
  export class NgxUIBitCarousel {
15
- constructor(private el: ElementRef<HTMLElementClass>) {
16
- effect(() => {
17
- if (this.el.nativeElement) {
18
- this.el.nativeElement.autoPlay = this.autoPlay();
19
- }
14
+ constructor(private el: ElementRef<HTMLElementClass>){
15
+ effect(()=>{
16
+ if (this.el.nativeElement) {
17
+ this.el.nativeElement.autoPlay = this.autoPlay();
18
+ }
19
+ });
20
+ effect(()=>{
21
+ if (this.el.nativeElement) {
22
+ this.el.nativeElement.autoPlayInterval = this.autoPlayInterval();
23
+ }
24
+ });
25
+ effect(()=>{
26
+ if (this.el.nativeElement) {
27
+ this.el.nativeElement.loop = this.loop();
28
+ }
29
+ });
30
+ effect(()=>{
31
+ if (this.el.nativeElement) {
32
+ this.el.nativeElement.content = this.content();
33
+ }
34
+ });
35
+ effect(()=>{
36
+ if (this.el.nativeElement) {
37
+ this.el.nativeElement.viewport = this.viewport();
38
+ }
39
+ });
40
+ effect(()=>{
41
+ if (this.el.nativeElement) {
42
+ this.el.nativeElement.slotElement = this.slotElement();
43
+ }
44
+ });
45
+ effect(()=>{
46
+ if (this.el.nativeElement) {
47
+ this.el.nativeElement.currentIndex = this.currentIndex();
48
+ }
49
+ });
50
+ effect(()=>{
51
+ if (this.el.nativeElement) {
52
+ this.el.nativeElement.totalSlides = this.totalSlides();
53
+ }
54
+ });
55
+ effect(()=>{
56
+ if (this.el.nativeElement) {
57
+ this.el.nativeElement.canPrev = this.canPrev();
58
+ }
59
+ });
60
+ effect(()=>{
61
+ if (this.el.nativeElement) {
62
+ this.el.nativeElement.canNext = this.canNext();
63
+ }
64
+ });
65
+ effect(()=>{
66
+ if (this.el.nativeElement) {
67
+ this.el.nativeElement.locale = this.locale();
68
+ }
69
+ });
70
+ }
71
+ readonly autoPlay = input<boolean, any>(false, {
72
+ transform: booleanAttribute
20
73
  });
21
- effect(() => {
22
- if (this.el.nativeElement) {
23
- this.el.nativeElement.autoPlayInterval = this.autoPlayInterval();
24
- }
74
+ readonly autoPlayInterval = input<number, any>(5000, {
75
+ transform: numberAttribute
25
76
  });
26
- effect(() => {
27
- if (this.el.nativeElement) {
28
- this.el.nativeElement.loop = this.loop();
29
- }
77
+ readonly loop = input<boolean, any>(true, {
78
+ transform: booleanAttribute
30
79
  });
31
- effect(() => {
32
- if (this.el.nativeElement) {
33
- this.el.nativeElement.content = this.content();
34
- }
80
+ readonly content = input<HTMLElement | undefined>(undefined);
81
+ readonly viewport = input<HTMLElement | undefined>(undefined);
82
+ readonly slotElement = input<HTMLSlotElement | undefined>(undefined);
83
+ readonly currentIndex = input<number, any>(0, {
84
+ transform: numberAttribute
35
85
  });
36
- effect(() => {
37
- if (this.el.nativeElement) {
38
- this.el.nativeElement.viewport = this.viewport();
39
- }
86
+ readonly totalSlides = model<number>(0);
87
+ readonly canPrev = input<boolean, any>(false, {
88
+ transform: booleanAttribute
40
89
  });
41
- effect(() => {
42
- if (this.el.nativeElement) {
43
- this.el.nativeElement.slotElement = this.slotElement();
44
- }
90
+ readonly canNext = input<boolean, any>(true, {
91
+ transform: booleanAttribute
45
92
  });
46
- effect(() => {
47
- if (this.el.nativeElement) {
48
- this.el.nativeElement.currentIndex = this.currentIndex();
49
- }
50
- });
51
- effect(() => {
52
- if (this.el.nativeElement) {
53
- this.el.nativeElement.totalSlides = this.totalSlides();
54
- }
55
- });
56
- effect(() => {
57
- if (this.el.nativeElement) {
58
- this.el.nativeElement.canPrev = this.canPrev();
59
- }
60
- });
61
- effect(() => {
62
- if (this.el.nativeElement) {
63
- this.el.nativeElement.canNext = this.canNext();
64
- }
65
- });
66
- effect(() => {
67
- if (this.el.nativeElement) {
68
- this.el.nativeElement.locale = this.locale();
69
- }
70
- });
71
- }
72
-
73
- readonly autoPlay = input<boolean, any>(false, { transform: booleanAttribute });
74
- readonly autoPlayInterval = input<number, any>(5000, { transform: numberAttribute });
75
- readonly loop = input<boolean, any>(true, { transform: booleanAttribute });
76
- readonly content = input<HTMLElement | undefined, any>(undefined);
77
- readonly viewport = input<HTMLElement | undefined, any>(undefined);
78
- readonly slotElement = input<HTMLSlotElement | undefined, any>(undefined);
79
- readonly currentIndex = input<number, any>(0, { transform: numberAttribute });
80
- readonly totalSlides = input<number, any>(0, { transform: numberAttribute });
81
- readonly canPrev = input<boolean, any>(false, { transform: booleanAttribute });
82
- readonly canNext = input<boolean, any>(true, { transform: booleanAttribute });
83
- readonly locale = input<string, any>('');
84
-
85
- readonly slideChange = output<CustomEvent<{ index: number, totalSlides: number }>>();
93
+ readonly locale = input<string>('');
94
+ readonly slideChange = output<CustomEvent<{
95
+ index: number;
96
+ totalSlides: number;
97
+ }>>();
86
98
  }
@@ -4,7 +4,20 @@ import '@uibit/carousel';
4
4
  declare global {
5
5
  namespace astroHTML.JSX {
6
6
  interface IntrinsicElements {
7
- 'uibit-carousel': Partial<HTMLElementClass> & astroHTML.JSX.HTMLAttributes;
7
+ 'uibit-carousel': Partial<HTMLElementClass> & astroHTML.JSX.HTMLAttributes & {
8
+ autoPlay?: boolean;
9
+ autoPlayInterval?: number;
10
+ loop?: boolean;
11
+ content?: HTMLElement | undefined;
12
+ viewport?: HTMLElement | undefined;
13
+ slotElement?: HTMLSlotElement | undefined;
14
+ currentIndex?: number;
15
+ totalSlides?: number;
16
+ canPrev?: boolean;
17
+ canNext?: boolean;
18
+ locale?: string;
19
+ "on:slide-change"?: (event: CustomEvent<{ index: number, totalSlides: number }>) => void;
20
+ };
8
21
  }
9
22
  }
10
23
  }
@@ -17,6 +17,8 @@ declare module 'preact' {
17
17
  canPrev?: boolean;
18
18
  canNext?: boolean;
19
19
  locale?: string;
20
+ onSlideChange?: (event: CustomEvent<{ index: number, totalSlides: number }>) => void;
21
+ "on:slide-change"?: (event: CustomEvent<{ index: number, totalSlides: number }>) => void;
20
22
  };
21
23
  }
22
24
  }
@@ -0,0 +1,182 @@
1
+ import React, { useRef, useEffect, useLayoutEffect, useImperativeHandle } from 'react';
2
+ import type { UIBitCarousel as HTMLElementClass } from '@uibit/carousel';
3
+ import '@uibit/carousel';
4
+ const useTypeOfLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
5
+ export interface UIBitCarouselProps extends Omit<React.HTMLAttributes<HTMLElementClass>, 'autoPlay' | 'autoPlayInterval' | 'loop' | 'content' | 'viewport' | 'slotElement' | 'currentIndex' | 'totalSlides' | 'canPrev' | 'canNext' | 'locale' | 'onSlideChange'> {
6
+ children?: React.ReactNode;
7
+ autoPlay?: boolean;
8
+ autoPlayInterval?: number;
9
+ loop?: boolean;
10
+ content?: HTMLElement | undefined;
11
+ viewport?: HTMLElement | undefined;
12
+ slotElement?: HTMLSlotElement | undefined;
13
+ currentIndex?: number;
14
+ totalSlides?: number;
15
+ canPrev?: boolean;
16
+ canNext?: boolean;
17
+ locale?: string;
18
+ onSlideChange?: (event: CustomEvent<{
19
+ index: number;
20
+ totalSlides: number;
21
+ }>) => void;
22
+ }
23
+ export const UIBitCarousel = ({ ref, children, ...props }: UIBitCarouselProps & {
24
+ ref?: React.Ref<HTMLElementClass>;
25
+ })=>{
26
+ const innerRef = useRef<HTMLElementClass>(null);
27
+ const propsRef = useRef(props);
28
+ propsRef.current = props;
29
+ useImperativeHandle(ref, ()=>innerRef.current!);
30
+ useTypeOfLayoutEffect(()=>{
31
+ const element = innerRef.current;
32
+ if (element && props.autoPlay !== undefined) {
33
+ (element as any).autoPlay = props.autoPlay;
34
+ }
35
+ }, [
36
+ props.autoPlay
37
+ ]);
38
+ useTypeOfLayoutEffect(()=>{
39
+ const element = innerRef.current;
40
+ if (element && props.autoPlayInterval !== undefined) {
41
+ (element as any).autoPlayInterval = props.autoPlayInterval;
42
+ }
43
+ }, [
44
+ props.autoPlayInterval
45
+ ]);
46
+ useTypeOfLayoutEffect(()=>{
47
+ const element = innerRef.current;
48
+ if (element && props.loop !== undefined) {
49
+ (element as any).loop = props.loop;
50
+ }
51
+ }, [
52
+ props.loop
53
+ ]);
54
+ useTypeOfLayoutEffect(()=>{
55
+ const element = innerRef.current;
56
+ if (element && props.content !== undefined) {
57
+ (element as any).content = props.content;
58
+ }
59
+ }, [
60
+ props.content
61
+ ]);
62
+ useTypeOfLayoutEffect(()=>{
63
+ const element = innerRef.current;
64
+ if (element && props.viewport !== undefined) {
65
+ (element as any).viewport = props.viewport;
66
+ }
67
+ }, [
68
+ props.viewport
69
+ ]);
70
+ useTypeOfLayoutEffect(()=>{
71
+ const element = innerRef.current;
72
+ if (element && props.slotElement !== undefined) {
73
+ (element as any).slotElement = props.slotElement;
74
+ }
75
+ }, [
76
+ props.slotElement
77
+ ]);
78
+ useTypeOfLayoutEffect(()=>{
79
+ const element = innerRef.current;
80
+ if (element && props.currentIndex !== undefined) {
81
+ (element as any).currentIndex = props.currentIndex;
82
+ }
83
+ }, [
84
+ props.currentIndex
85
+ ]);
86
+ useTypeOfLayoutEffect(()=>{
87
+ const element = innerRef.current;
88
+ if (element && props.totalSlides !== undefined) {
89
+ (element as any).totalSlides = props.totalSlides;
90
+ }
91
+ }, [
92
+ props.totalSlides
93
+ ]);
94
+ useTypeOfLayoutEffect(()=>{
95
+ const element = innerRef.current;
96
+ if (element && props.canPrev !== undefined) {
97
+ (element as any).canPrev = props.canPrev;
98
+ }
99
+ }, [
100
+ props.canPrev
101
+ ]);
102
+ useTypeOfLayoutEffect(()=>{
103
+ const element = innerRef.current;
104
+ if (element && props.canNext !== undefined) {
105
+ (element as any).canNext = props.canNext;
106
+ }
107
+ }, [
108
+ props.canNext
109
+ ]);
110
+ useTypeOfLayoutEffect(()=>{
111
+ const element = innerRef.current;
112
+ if (element && props.locale !== undefined) {
113
+ (element as any).locale = props.locale;
114
+ }
115
+ }, [
116
+ props.locale
117
+ ]);
118
+ useTypeOfLayoutEffect(()=>{
119
+ const element = innerRef.current;
120
+ if (!element) return;
121
+ const handleEvent = (event: Event)=>{
122
+ if (propsRef.current.onSlideChange) {
123
+ propsRef.current.onSlideChange(event as any);
124
+ }
125
+ };
126
+ element.addEventListener('slide-change', handleEvent);
127
+ return ()=>{
128
+ element.removeEventListener('slide-change', handleEvent);
129
+ };
130
+ }, []);
131
+ const domProps = {
132
+ ...props
133
+ };
134
+ const customPropNames = [
135
+ 'autoPlay',
136
+ 'autoPlayInterval',
137
+ 'loop',
138
+ 'content',
139
+ 'viewport',
140
+ 'slotElement',
141
+ 'currentIndex',
142
+ 'totalSlides',
143
+ 'canPrev',
144
+ 'canNext',
145
+ 'locale',
146
+ 'onSlideChange'
147
+ ];
148
+ for (const key of customPropNames){
149
+ delete (domProps as any)[key];
150
+ }
151
+ return React.createElement('uibit-carousel', {
152
+ ref: innerRef,
153
+ ...domProps
154
+ }, children);
155
+ };
156
+ declare global {
157
+ namespace React {
158
+ namespace JSX {
159
+ interface IntrinsicElements {
160
+ 'uibit-carousel': React.ClassAttributes<HTMLElementClass> & React.HTMLAttributes<HTMLElementClass> & {
161
+ children?: React.ReactNode;
162
+ class?: string;
163
+ autoPlay?: boolean;
164
+ autoPlayInterval?: number;
165
+ loop?: boolean;
166
+ content?: HTMLElement | undefined;
167
+ viewport?: HTMLElement | undefined;
168
+ slotElement?: HTMLSlotElement | undefined;
169
+ currentIndex?: number;
170
+ totalSlides?: number;
171
+ canPrev?: boolean;
172
+ canNext?: boolean;
173
+ locale?: string;
174
+ onSlideChange?: (event: CustomEvent<{
175
+ index: number;
176
+ totalSlides: number;
177
+ }>) => void;
178
+ };
179
+ }
180
+ }
181
+ }
182
+ }
@@ -17,7 +17,7 @@ declare module 'solid-js' {
17
17
  canPrev?: boolean;
18
18
  canNext?: boolean;
19
19
  locale?: string;
20
- "on:slide-change"?: (event: CustomEvent) => void;
20
+ "on:slide-change"?: (event: CustomEvent<{ index: number, totalSlides: number }>) => void;
21
21
  };
22
22
  }
23
23
  }
@@ -16,6 +16,8 @@ declare module '@stencil/core' {
16
16
  canPrev?: boolean;
17
17
  canNext?: boolean;
18
18
  locale?: string;
19
+ onSlideChange?: (event: CustomEvent<{ index: number, totalSlides: number }>) => void;
20
+ "on:slide-change"?: (event: CustomEvent<{ index: number, totalSlides: number }>) => void;
19
21
  };
20
22
  }
21
23
  }
@@ -1,23 +1,24 @@
1
1
  <script lang="ts">
2
2
  import '@uibit/carousel';
3
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
- locale = undefined,
17
- item = undefined,
18
- children
4
+
5
+ let {
6
+ autoPlay = $bindable(),
7
+ autoPlayInterval = $bindable(),
8
+ loop = $bindable(),
9
+ content = $bindable(),
10
+ viewport = $bindable(),
11
+ slotElement = $bindable(),
12
+ currentIndex = $bindable(),
13
+ totalSlides = $bindable(),
14
+ canPrev = $bindable(),
15
+ canNext = $bindable(),
16
+ locale = $bindable(),
17
+ item = undefined,
18
+ children,
19
+ ...restProps
19
20
  } = $props<{
20
- children?: any;
21
+ children?: import('svelte').Snippet;
21
22
  autoPlay?: boolean;
22
23
  autoPlayInterval?: number;
23
24
  loop?: boolean;
@@ -30,49 +31,101 @@
30
31
  canNext?: boolean;
31
32
  locale?: string;
32
33
  item?: import('svelte').Snippet;
34
+ [key: string]: any;
33
35
  }>();
34
-
35
- let elementRef: HTMLElementClass | null = $state(null);
36
-
37
- $effect(() => {
38
- if (elementRef && autoPlay !== undefined) {
36
+
37
+ let elementRef: HTMLElementClass | null = $state(null);
38
+
39
+ $effect(() => {
40
+ if (elementRef && autoPlay !== undefined && elementRef.autoPlay !== autoPlay) {
39
41
  elementRef.autoPlay = autoPlay;
40
42
  }
41
- if (elementRef && autoPlayInterval !== undefined) {
43
+ if (elementRef && autoPlayInterval !== undefined && elementRef.autoPlayInterval !== autoPlayInterval) {
42
44
  elementRef.autoPlayInterval = autoPlayInterval;
43
45
  }
44
- if (elementRef && loop !== undefined) {
46
+ if (elementRef && loop !== undefined && elementRef.loop !== loop) {
45
47
  elementRef.loop = loop;
46
48
  }
47
- if (elementRef && content !== undefined) {
49
+ if (elementRef && content !== undefined && elementRef.content !== content) {
48
50
  elementRef.content = content;
49
51
  }
50
- if (elementRef && viewport !== undefined) {
52
+ if (elementRef && viewport !== undefined && elementRef.viewport !== viewport) {
51
53
  elementRef.viewport = viewport;
52
54
  }
53
- if (elementRef && slotElement !== undefined) {
55
+ if (elementRef && slotElement !== undefined && elementRef.slotElement !== slotElement) {
54
56
  elementRef.slotElement = slotElement;
55
57
  }
56
- if (elementRef && currentIndex !== undefined) {
58
+ if (elementRef && currentIndex !== undefined && elementRef.currentIndex !== currentIndex) {
57
59
  elementRef.currentIndex = currentIndex;
58
60
  }
59
- if (elementRef && totalSlides !== undefined) {
61
+ if (elementRef && totalSlides !== undefined && elementRef.totalSlides !== totalSlides) {
60
62
  elementRef.totalSlides = totalSlides;
61
63
  }
62
- if (elementRef && canPrev !== undefined) {
64
+ if (elementRef && canPrev !== undefined && elementRef.canPrev !== canPrev) {
63
65
  elementRef.canPrev = canPrev;
64
66
  }
65
- if (elementRef && canNext !== undefined) {
67
+ if (elementRef && canNext !== undefined && elementRef.canNext !== canNext) {
66
68
  elementRef.canNext = canNext;
67
69
  }
68
- if (elementRef && locale !== undefined) {
70
+ if (elementRef && locale !== undefined && elementRef.locale !== locale) {
69
71
  elementRef.locale = locale;
70
72
  }
71
73
  });
72
-
74
+
75
+ $effect(() => {
76
+ const element = elementRef;
77
+ if (!element) return;
78
+
79
+ const handleEvent = () => {
80
+ if (autoPlay !== element.autoPlay) {
81
+ autoPlay = element.autoPlay as any;
82
+ }
83
+ if (autoPlayInterval !== element.autoPlayInterval) {
84
+ autoPlayInterval = element.autoPlayInterval as any;
85
+ }
86
+ if (loop !== element.loop) {
87
+ loop = element.loop as any;
88
+ }
89
+ if (content !== element.content) {
90
+ content = element.content as any;
91
+ }
92
+ if (viewport !== element.viewport) {
93
+ viewport = element.viewport as any;
94
+ }
95
+ if (slotElement !== element.slotElement) {
96
+ slotElement = element.slotElement as any;
97
+ }
98
+ if (currentIndex !== element.currentIndex) {
99
+ currentIndex = element.currentIndex as any;
100
+ }
101
+ if (totalSlides !== element.totalSlides) {
102
+ totalSlides = element.totalSlides as any;
103
+ }
104
+ if (canPrev !== element.canPrev) {
105
+ canPrev = element.canPrev as any;
106
+ }
107
+ if (canNext !== element.canNext) {
108
+ canNext = element.canNext as any;
109
+ }
110
+ if (locale !== element.locale) {
111
+ locale = element.locale as any;
112
+ }
113
+ };
114
+
115
+ const events = ['change', 'input', 'slide-change'];
116
+ for (const event of events) {
117
+ element.addEventListener(event, handleEvent);
118
+ }
119
+ return () => {
120
+ for (const event of events) {
121
+ element.removeEventListener(event, handleEvent);
122
+ }
123
+ };
124
+ });
125
+
73
126
  </script>
74
127
 
75
- <uibit-carousel bind:this={elementRef} {...$$restProps}>
128
+ <uibit-carousel bind:this={elementRef} {...restProps}>
76
129
  {#if item}
77
130
  <div slot="item">
78
131
  {@render item()}
@@ -1,34 +1,195 @@
1
- import { defineComponent, h } from 'vue';
1
+ import { defineComponent, h, ref, watch } from 'vue';
2
2
  import type { UIBitCarousel as HTMLElementClass } from '@uibit/carousel';
3
3
  import '@uibit/carousel';
4
-
5
4
  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
- locale: { type: [String, Number, Boolean, Array, Object] as any }
19
- },
20
- emits: ['slide-change'],
21
- setup(props, { slots, emit }) {
22
- return () => {
23
- const eventListeners: Record<string, any> = {};
24
- eventListeners['onSlide-change'] = (event: Event) => {
25
- emit('slide-change', event);
26
- };
27
-
28
- return h('uibit-carousel', {
29
- ...props,
30
- ...eventListeners
31
- }, slots.default?.());
32
- };
33
- }
5
+ name: 'UIBitCarousel',
6
+ props: {
7
+ autoPlay: {
8
+ type: [
9
+ String,
10
+ Number,
11
+ Boolean,
12
+ Array,
13
+ Object
14
+ ] as any
15
+ },
16
+ autoPlayInterval: {
17
+ type: [
18
+ String,
19
+ Number,
20
+ Boolean,
21
+ Array,
22
+ Object
23
+ ] as any
24
+ },
25
+ loop: {
26
+ type: [
27
+ String,
28
+ Number,
29
+ Boolean,
30
+ Array,
31
+ Object
32
+ ] as any
33
+ },
34
+ content: {
35
+ type: [
36
+ String,
37
+ Number,
38
+ Boolean,
39
+ Array,
40
+ Object
41
+ ] as any
42
+ },
43
+ viewport: {
44
+ type: [
45
+ String,
46
+ Number,
47
+ Boolean,
48
+ Array,
49
+ Object
50
+ ] as any
51
+ },
52
+ slotElement: {
53
+ type: [
54
+ String,
55
+ Number,
56
+ Boolean,
57
+ Array,
58
+ Object
59
+ ] as any
60
+ },
61
+ currentIndex: {
62
+ type: [
63
+ String,
64
+ Number,
65
+ Boolean,
66
+ Array,
67
+ Object
68
+ ] as any
69
+ },
70
+ totalSlides: {
71
+ type: [
72
+ String,
73
+ Number,
74
+ Boolean,
75
+ Array,
76
+ Object
77
+ ] as any
78
+ },
79
+ canPrev: {
80
+ type: [
81
+ String,
82
+ Number,
83
+ Boolean,
84
+ Array,
85
+ Object
86
+ ] as any
87
+ },
88
+ canNext: {
89
+ type: [
90
+ String,
91
+ Number,
92
+ Boolean,
93
+ Array,
94
+ Object
95
+ ] as any
96
+ },
97
+ locale: {
98
+ type: [
99
+ String,
100
+ Number,
101
+ Boolean,
102
+ Array,
103
+ Object
104
+ ] as any
105
+ }
106
+ },
107
+ emits: [
108
+ 'slide-change'
109
+ ],
110
+ setup (props, { slots, emit }) {
111
+ const elementRef = ref<HTMLElementClass | null>(null);
112
+ if (false) {
113
+ watch(()=>props.modelValue, (newVal)=>{
114
+ if (elementRef.value && newVal !== undefined && elementRef.value.value !== newVal) {
115
+ elementRef.value.value = newVal;
116
+ }
117
+ });
118
+ watch(()=>props.value, (newVal)=>{
119
+ if (elementRef.value && newVal !== undefined && elementRef.value.value !== newVal) {
120
+ elementRef.value.value = newVal;
121
+ }
122
+ });
123
+ }
124
+ watch(()=>props.autoPlay, (newVal)=>{
125
+ if (elementRef.value && newVal !== undefined) {
126
+ (elementRef.value as any).autoPlay = newVal;
127
+ }
128
+ });
129
+ watch(()=>props.autoPlayInterval, (newVal)=>{
130
+ if (elementRef.value && newVal !== undefined) {
131
+ (elementRef.value as any).autoPlayInterval = newVal;
132
+ }
133
+ });
134
+ watch(()=>props.loop, (newVal)=>{
135
+ if (elementRef.value && newVal !== undefined) {
136
+ (elementRef.value as any).loop = newVal;
137
+ }
138
+ });
139
+ watch(()=>props.content, (newVal)=>{
140
+ if (elementRef.value && newVal !== undefined) {
141
+ (elementRef.value as any).content = newVal;
142
+ }
143
+ });
144
+ watch(()=>props.viewport, (newVal)=>{
145
+ if (elementRef.value && newVal !== undefined) {
146
+ (elementRef.value as any).viewport = newVal;
147
+ }
148
+ });
149
+ watch(()=>props.slotElement, (newVal)=>{
150
+ if (elementRef.value && newVal !== undefined) {
151
+ (elementRef.value as any).slotElement = newVal;
152
+ }
153
+ });
154
+ watch(()=>props.currentIndex, (newVal)=>{
155
+ if (elementRef.value && newVal !== undefined) {
156
+ (elementRef.value as any).currentIndex = newVal;
157
+ }
158
+ });
159
+ watch(()=>props.totalSlides, (newVal)=>{
160
+ if (elementRef.value && newVal !== undefined) {
161
+ (elementRef.value as any).totalSlides = newVal;
162
+ }
163
+ });
164
+ watch(()=>props.canPrev, (newVal)=>{
165
+ if (elementRef.value && newVal !== undefined) {
166
+ (elementRef.value as any).canPrev = newVal;
167
+ }
168
+ });
169
+ watch(()=>props.canNext, (newVal)=>{
170
+ if (elementRef.value && newVal !== undefined) {
171
+ (elementRef.value as any).canNext = newVal;
172
+ }
173
+ });
174
+ watch(()=>props.locale, (newVal)=>{
175
+ if (elementRef.value && newVal !== undefined) {
176
+ (elementRef.value as any).locale = newVal;
177
+ }
178
+ });
179
+ return ()=>{
180
+ const eventListeners: Record<string, any> = {};
181
+ eventListeners['onSlide-change'] = (event: Event)=>{
182
+ emit('slide-change', event);
183
+ };
184
+ const mergedProps = {
185
+ ...props,
186
+ ...eventListeners,
187
+ ref: elementRef
188
+ };
189
+ if (false && props.modelValue !== undefined) {
190
+ (mergedProps as any).value = props.modelValue;
191
+ }
192
+ return h('uibit-carousel', mergedProps, slots.default?.());
193
+ };
194
+ }
34
195
  });
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { UIBitCarousel as default } from './carousel';
1
+ export { UIBitCarousel as default, UIBitCarousel } from './carousel';
2
2
  export type { CarouselConfig, SlideChangeEvent } from './types';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACrE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { UIBitCarousel as default } from './carousel';
1
+ export { UIBitCarousel as default, UIBitCarousel } from './carousel';
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uibit/carousel",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Native, accessible carousel using CSS scroll-snap and scroll-driven animations. Perfect for image galleries, testimonials, and product showcases.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -12,7 +12,10 @@
12
12
  },
13
13
  "./carousel.css": "./dist/carousel.css",
14
14
  "./custom-elements.json": "./custom-elements.json",
15
- "./react": "./dist/frameworks/react/index.d.ts",
15
+ "./react": {
16
+ "types": "./dist/frameworks/react/index.ts",
17
+ "import": "./dist/frameworks/react/index.ts"
18
+ },
16
19
  "./vue": "./dist/frameworks/vue/index.ts",
17
20
  "./svelte": "./dist/frameworks/svelte/index.svelte",
18
21
  "./angular": "./dist/frameworks/angular/index.ts",
@@ -53,7 +56,7 @@
53
56
  "@types/node": "^20.19.43",
54
57
  "lit": "^3.3.3",
55
58
  "typescript": "7.0.2",
56
- "@uibit/codegen": "0.1.0"
59
+ "@uibit/codegen": "0.2.0"
57
60
  },
58
61
  "peerDependencies": {
59
62
  "lit": "^3.0.0",
@@ -1,28 +0,0 @@
1
- import type { HTMLAttributes, ClassAttributes } from 'react';
2
- import type { UIBitCarousel as HTMLElementClass } from '@uibit/carousel';
3
- import '@uibit/carousel';
4
-
5
- declare global {
6
- namespace React {
7
- namespace JSX {
8
- interface IntrinsicElements {
9
- 'uibit-carousel': ClassAttributes<HTMLElementClass> & HTMLAttributes<HTMLElementClass> & {
10
- children?: React.ReactNode;
11
- class?: string;
12
- autoPlay?: boolean;
13
- autoPlayInterval?: number;
14
- loop?: boolean;
15
- content?: HTMLElement | undefined;
16
- viewport?: HTMLElement | undefined;
17
- slotElement?: HTMLSlotElement | undefined;
18
- currentIndex?: number;
19
- totalSlides?: number;
20
- canPrev?: boolean;
21
- canNext?: boolean;
22
- locale?: string;
23
- onSlideChange?: (event: any) => void;
24
- };
25
- }
26
- }
27
- }
28
- }