@semcore/carousel 17.2.2 → 17.2.3-prerelease.1

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.
@@ -1,136 +1,181 @@
1
1
  import type { BoxProps } from '@semcore/base-components';
2
- import type { PropGetterFn, Intergalactic, IRootComponentProps } from '@semcore/core';
2
+ import type { PropGetterFn, Intergalactic } from '@semcore/core';
3
3
 
4
4
  import type { LocalizedMessages } from './translations/__intergalactic-dynamic-locales';
5
5
 
6
- export type CarouselProps = BoxProps & {
7
- /** Index active item */
8
- index?: number;
9
- /**
10
- * Index of the active item selected by default
11
- * @default 0
12
- */
13
- defaultIndex?: number;
14
- /** Called when the selection is changed */
15
- onIndexChange?: (index: number) => void;
16
- /** Animation duration
17
- * @default 300 */
18
- duration?: number;
19
- /** Disables infinite items change in the carousel
20
- * @default false */
21
- bounded?: boolean;
22
- /** Internal */
23
- step?: number;
24
- /** Specifies the locale for i18n support */
25
- locale?: string;
26
- /** Enable zoom feature for carousel items */
27
- zoom?: boolean;
28
- /** Width for items in zooming modal */
29
- zoomWidth?: number;
30
- /** Type of indicators */
31
- indicators?: 'default' | 'hide' | 'preview';
32
- };
33
-
34
- export type CarouselDefaultProps = {
35
- defaultIndex: 0;
36
- duration: 350;
37
- step: 100;
38
- bounded: false;
39
- i18n: LocalizedMessages;
40
- locale: 'en';
41
- indicators: 'default';
42
- };
43
-
44
- export type CarouselContext = {
45
- getContainerProps: PropGetterFn;
46
- getItemProps: PropGetterFn;
47
- getPrevProps: PropGetterFn;
48
- getNextProps: PropGetterFn;
49
- getIndicatorsProps: PropGetterFn;
50
- };
51
-
52
- export type CarouselItem = {
53
- node: HTMLElement;
54
- };
55
-
56
- export type CarouselItemProps = BoxProps & {
57
- /** Flag for css cursor
58
- * @private
59
- */
60
- zoomIn?: boolean;
61
- /** Flag for css cursor
62
- * @private
63
- */
64
- zoomOut?: boolean;
65
-
66
- /** Function to add item to list in Carousel
67
- * @private
68
- */
69
- toggleItem?: (item: CarouselItem, toRemove?: boolean) => void;
70
-
71
- /** Index of item in carousel */
72
- index?: number;
73
-
74
- uid?: string;
75
-
76
- /** Flag - is current item shown now */
77
- current?: boolean;
78
-
79
- /** Handler for show item in modal window
80
- * @private
81
- */
82
- onToggleZoomModal?: () => void;
83
-
84
- /** Value for transform item
85
- * @private
86
- */
87
- transform?: number;
88
-
89
- /**
90
- * Flag data zoomed
91
- * @private
92
- */
93
- isOpenZoom?: boolean;
94
- };
95
-
96
- export type CarouselState = {
97
- isOpenZoom: boolean;
98
- selectedIndex: number;
99
- items: CarouselItem[];
100
- };
101
-
102
- export type CarouselButtonProps = IRootComponentProps &
103
- BoxProps & {
104
- label?: string;
105
- inverted?: boolean;
106
- tabIndex?: number;
6
+ declare namespace NSCarousel {
7
+ type Props = BoxProps & {
8
+ /** Index active item */
9
+ index?: number;
10
+ /**
11
+ * Index of the active item selected by default
12
+ * @default 0
13
+ */
14
+ defaultIndex?: number;
15
+ /** Called when the selection is changed */
16
+ onIndexChange?: (index: number) => void;
17
+ /** Animation duration
18
+ * @default 300 */
19
+ duration?: number;
20
+ /** Disables infinite items change in the carousel
21
+ * @default false */
22
+ bounded?: boolean;
23
+ /** Internal */
24
+ step?: number;
25
+ /** Specifies the locale for i18n support */
26
+ locale?: string;
27
+ /** Enable zoom feature for carousel items */
28
+ zoom?: boolean;
29
+ /** Width for items in zooming modal */
30
+ zoomWidth?: number;
31
+ /** Type of indicators */
32
+ indicators?: 'default' | 'hide' | 'preview';
107
33
  };
108
-
109
- export type CarouselIndicatorsProps = IRootComponentProps &
110
- BoxProps & {
111
- items?: CarouselItem[];
112
- inverted?: boolean;
34
+ type DefaultProps = {
35
+ defaultIndex: 0;
36
+ duration: 350;
37
+ step: 100;
38
+ bounded: false;
39
+ i18n: LocalizedMessages;
40
+ locale: 'en';
41
+ indicators: 'default';
42
+ };
43
+ type State = {
44
+ isOpenZoom: boolean;
45
+ selectedIndex: number;
46
+ items: NSCarousel.Item[];
47
+ };
48
+ type Ctx = {
49
+ getContainerProps: PropGetterFn;
50
+ getItemProps: PropGetterFn;
51
+ getPrevProps: PropGetterFn;
52
+ getNextProps: PropGetterFn;
53
+ getIndicatorsProps: PropGetterFn;
54
+ };
55
+ type Handlers = {
56
+ index: [
57
+ null,
58
+ (index: NSCarousel.Props['index']) => void,
59
+ ];
60
+ };
61
+ type Item = {
62
+ node: HTMLElement;
113
63
  };
114
64
 
115
- export type CarouselIndicatorProps = IRootComponentProps &
116
- Omit<BoxProps, 'position'> & {
117
- active?: boolean;
118
- onClick?: () => void;
119
- inverted?: boolean;
120
- } & CarouselItem;
121
-
122
- declare const CarouselType: Intergalactic.Component<
123
- 'div',
124
- CarouselProps,
125
- CarouselContext & CarouselState
126
- > & {
127
- Container: Intergalactic.Component<'div', BoxProps>;
128
- ContentBox: Intergalactic.Component<'div', BoxProps>;
129
- Indicators: Intergalactic.Component<'div', CarouselIndicatorsProps, CarouselState>;
130
- Indicator: Intergalactic.Component<'div', CarouselIndicatorProps>;
131
- Item: Intergalactic.Component<'div', CarouselItemProps>;
132
- Prev: Intergalactic.Component<'div', CarouselButtonProps>;
133
- Next: Intergalactic.Component<'div', CarouselButtonProps>;
134
- };
135
-
136
- export default CarouselType;
65
+ namespace Container {
66
+ type Component = Intergalactic.Component<'div', BoxProps>;
67
+ }
68
+
69
+ namespace ContentBox {
70
+ type Component = Intergalactic.Component<'div', BoxProps>;
71
+ }
72
+
73
+ namespace Indicators {
74
+ type Props = BoxProps & {
75
+ items?: NSCarousel.Item[];
76
+ inverted?: boolean;
77
+ };
78
+ type Component = Intergalactic.Component<'div', Props, State>;
79
+ }
80
+
81
+ namespace Indicator {
82
+ type Props = Omit<BoxProps, 'position'> & {
83
+ active?: boolean;
84
+ onClick?: () => void;
85
+ inverted?: boolean;
86
+ };
87
+ type Component = Intergalactic.Component<'div', Props>;
88
+ }
89
+
90
+ namespace Item {
91
+ type Props = BoxProps & {
92
+ /** Flag for css cursor
93
+ * @private
94
+ */
95
+ zoomIn?: boolean;
96
+ /** Flag for css cursor
97
+ * @private
98
+ */
99
+ zoomOut?: boolean;
100
+
101
+ /** Function to add item to list in Carousel
102
+ * @private
103
+ */
104
+ toggleItem?: (item: NSCarousel.Item, toRemove?: boolean) => void;
105
+
106
+ /** Index of item in carousel */
107
+ index?: number;
108
+
109
+ uid?: string;
110
+
111
+ /** Flag - is current item shown now */
112
+ current?: boolean;
113
+
114
+ /** Handler for show item in modal window
115
+ * @private
116
+ */
117
+ onToggleZoomModal?: () => void;
118
+
119
+ /** Value for transform item
120
+ * @private
121
+ */
122
+ transform?: number;
123
+
124
+ /**
125
+ * Flag data zoomed
126
+ * @private
127
+ */
128
+ isOpenZoom?: boolean;
129
+ };
130
+ type Component = Intergalactic.Component<'div', Props>;
131
+ }
132
+
133
+ namespace Prev {
134
+ type Props = BoxProps & {
135
+ label?: string;
136
+ inverted?: boolean;
137
+ tabIndex?: number;
138
+ };
139
+ type Component = Intergalactic.Component<'div', Props>;
140
+ }
141
+
142
+ namespace Next {
143
+ type Props = BoxProps & {
144
+ label?: string;
145
+ inverted?: boolean;
146
+ tabIndex?: number;
147
+ };
148
+ type Component = Intergalactic.Component<'div', Props>;
149
+ }
150
+
151
+ type Component = Intergalactic.Component<'div', Props, Ctx & State> & {
152
+ Container: Container.Component;
153
+ ContentBox: ContentBox.Component;
154
+ Indicators: Indicators.Component;
155
+ Indicator: Indicator.Component;
156
+ Item: Item.Component;
157
+ Prev: Prev.Component;
158
+ Next: Next.Component;
159
+ };
160
+ }
161
+
162
+ /** @deprecated It will be removed in v18. */
163
+ export type CarouselProps = NSCarousel.Props;
164
+ /** @deprecated It will be removed in v18. */
165
+ export type CarouselDefaultProps = NSCarousel.DefaultProps;
166
+ /** @deprecated It will be removed in v18. */
167
+ export type CarouselContext = NSCarousel.Ctx;
168
+ /** @deprecated It will be removed in v18. */
169
+ export type CarouselItem = NSCarousel.Item;
170
+ /** @deprecated It will be removed in v18. */
171
+ export type CarouselItemProps = NSCarousel.Item.Props;
172
+ /** @deprecated It will be removed in v18. */
173
+ export type CarouselState = NSCarousel.State;
174
+ /** @deprecated It will be removed in v18. */
175
+ export type CarouselButtonProps = NSCarousel.Prev.Props;
176
+ /** @deprecated It will be removed in v18. */
177
+ export type CarouselIndicatorsProps = NSCarousel.Indicators.Props;
178
+ /** @deprecated It will be removed in v18. */
179
+ export type CarouselIndicatorProps = NSCarousel.Indicator.Props;
180
+
181
+ export type { NSCarousel };