@faststore/ui 2.0.122-alpha.0 → 2.0.132-alpha.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 (57) hide show
  1. package/dist/index.d.ts +0 -6
  2. package/dist/index.js +0 -4
  3. package/dist/index.js.map +1 -1
  4. package/package.json +2 -2
  5. package/src/components/atoms/Button/styles.scss +103 -63
  6. package/src/components/molecules/Accordion/styles.scss +3 -1
  7. package/src/components/molecules/Alert/styles.scss +2 -15
  8. package/src/components/molecules/Banner/styles.scss +1 -1
  9. package/src/components/molecules/BuyButton/styles.scss +9 -5
  10. package/src/components/molecules/Carousel/styles.scss +82 -56
  11. package/src/components/molecules/InputField/styles.scss +3 -9
  12. package/src/components/molecules/LinkButton/styles.scss +1 -2
  13. package/src/components/molecules/NavbarLinks/styles.scss +12 -9
  14. package/src/components/molecules/QuantitySelector/styles.scss +20 -75
  15. package/src/components/molecules/RegionBar/styles.scss +12 -9
  16. package/src/components/molecules/SearchInputField/styles.scss +16 -30
  17. package/src/components/organisms/Filter/styles.scss +11 -10
  18. package/src/components/organisms/Hero/styles.scss +4 -2
  19. package/src/components/organisms/ImageGallery/styles.scss +33 -20
  20. package/src/components/organisms/ProductShelf/styles.scss +2 -3
  21. package/src/index.ts +0 -16
  22. package/dist/components/molecules/Bullets/Bullets.d.ts +0 -35
  23. package/dist/components/molecules/Bullets/Bullets.js +0 -12
  24. package/dist/components/molecules/Bullets/Bullets.js.map +0 -1
  25. package/dist/components/molecules/Bullets/index.d.ts +0 -2
  26. package/dist/components/molecules/Bullets/index.js +0 -2
  27. package/dist/components/molecules/Bullets/index.js.map +0 -1
  28. package/dist/components/molecules/Carousel/Arrows.d.ts +0 -12
  29. package/dist/components/molecules/Carousel/Arrows.js +0 -6
  30. package/dist/components/molecules/Carousel/Arrows.js.map +0 -1
  31. package/dist/components/molecules/Carousel/Carousel.d.ts +0 -54
  32. package/dist/components/molecules/Carousel/Carousel.js +0 -183
  33. package/dist/components/molecules/Carousel/Carousel.js.map +0 -1
  34. package/dist/components/molecules/Carousel/CarouselItem.d.ts +0 -11
  35. package/dist/components/molecules/Carousel/CarouselItem.js +0 -18
  36. package/dist/components/molecules/Carousel/CarouselItem.js.map +0 -1
  37. package/dist/components/molecules/Carousel/hooks/useSlideVisibility.d.ts +0 -9
  38. package/dist/components/molecules/Carousel/hooks/useSlideVisibility.js +0 -29
  39. package/dist/components/molecules/Carousel/hooks/useSlideVisibility.js.map +0 -1
  40. package/dist/components/molecules/Carousel/index.d.ts +0 -2
  41. package/dist/components/molecules/Carousel/index.js +0 -3
  42. package/dist/components/molecules/Carousel/index.js.map +0 -1
  43. package/dist/hooks/useSlider/index.d.ts +0 -2
  44. package/dist/hooks/useSlider/index.js +0 -3
  45. package/dist/hooks/useSlider/index.js.map +0 -1
  46. package/dist/hooks/useSlider/useSlider.d.ts +0 -64
  47. package/dist/hooks/useSlider/useSlider.js +0 -103
  48. package/dist/hooks/useSlider/useSlider.js.map +0 -1
  49. package/src/components/molecules/Bullets/Bullets.tsx +0 -88
  50. package/src/components/molecules/Bullets/index.ts +0 -2
  51. package/src/components/molecules/Carousel/Arrows.tsx +0 -58
  52. package/src/components/molecules/Carousel/Carousel.tsx +0 -387
  53. package/src/components/molecules/Carousel/CarouselItem.tsx +0 -54
  54. package/src/components/molecules/Carousel/hooks/useSlideVisibility.ts +0 -59
  55. package/src/components/molecules/Carousel/index.ts +0 -2
  56. package/src/hooks/useSlider/index.ts +0 -2
  57. package/src/hooks/useSlider/useSlider.ts +0 -209
@@ -1,209 +0,0 @@
1
- import type { Dispatch } from 'react'
2
- import { useReducer } from 'react'
3
- import type { SwipeableProps } from 'react-swipeable'
4
- import { useSwipeable } from 'react-swipeable'
5
-
6
- export type SlideDirection = 'next' | 'previous'
7
-
8
- interface NextPageAction {
9
- type: 'NEXT_PAGE'
10
- }
11
-
12
- interface PreviousPageAction {
13
- type: 'PREVIOUS_PAGE'
14
- }
15
-
16
- interface GoToPageAction {
17
- type: 'GO_TO_PAGE'
18
- payload: {
19
- pageIndex: number
20
- shouldSlide: boolean
21
- }
22
- }
23
-
24
- interface StopSlideAction {
25
- type: 'STOP_SLIDE'
26
- }
27
-
28
- export type Action =
29
- | NextPageAction
30
- | PreviousPageAction
31
- | StopSlideAction
32
- | GoToPageAction
33
-
34
- export type SliderDispatch = Dispatch<Action>
35
-
36
- export interface SliderState {
37
- /**
38
- * The `currentItem` in a Slider with multiple items in a single page is
39
- * always **the one with the lowest index** in the current page.
40
- */
41
- currentItem: number
42
- /** Currently active page */
43
- currentPage: number
44
- /**
45
- * Whether or not the Slider is currently sliding. This is useful to
46
- * manipulate the `transition` property in a component.
47
- */
48
- sliding: boolean
49
- /** The direction in which the Slider is sliding. */
50
- slideDirection: SlideDirection
51
- /** The total number of unique items in the slider. */
52
- totalItems: number
53
- /** The number of items in a single page. */
54
- itemsPerPage: number
55
- /** The total number of pages in the slider. */
56
- totalPages: number
57
- /** Whether or not the slider is infinite. */
58
- infinite: boolean
59
- }
60
-
61
- export const nextPage = (current: number, total: number) =>
62
- (current + 1) % total
63
-
64
- export const previousPage = (current: number, total: number) =>
65
- (total - ((total - current + 1) % total)) % total
66
-
67
- function reducer(state: SliderState, action: Action): SliderState {
68
- switch (action.type) {
69
- case 'NEXT_PAGE': {
70
- // If `state.infinite` is true, we need to take into account an extra
71
- // page in the calculation. This extra page is a clone of the first page.
72
- const adjustedTotalPages = state.infinite
73
- ? state.totalPages + 1
74
- : state.totalPages
75
-
76
- const nextPageIndex = nextPage(state.currentPage, adjustedTotalPages)
77
-
78
- const nextItemIndex =
79
- (nextPageIndex % adjustedTotalPages) * state.itemsPerPage
80
-
81
- return {
82
- ...state,
83
- sliding: true,
84
- slideDirection: 'next',
85
- currentItem: nextItemIndex,
86
- currentPage: nextPageIndex,
87
- }
88
- }
89
-
90
- case 'PREVIOUS_PAGE': {
91
- // If `state.infinite` is true, we need to take into account an extra
92
- // page in the calculation. This extra page is a clone of the first page.
93
- const adjustedTotalPages = state.infinite
94
- ? state.totalPages + 1
95
- : state.totalPages
96
-
97
- // If `state.infinite` is true and we're currently on page 0, we need to
98
- // let the slider go to page -1. This -1 page is a clone of the last page.
99
- const shouldGoToClone = state.infinite && state.currentPage === 0
100
- const previousPageIndex = shouldGoToClone
101
- ? -1
102
- : previousPage(state.currentPage, state.totalPages)
103
-
104
- return {
105
- ...state,
106
- sliding: true,
107
- slideDirection: 'previous',
108
- currentItem:
109
- (previousPageIndex % adjustedTotalPages) * state.itemsPerPage,
110
- currentPage: previousPageIndex,
111
- }
112
- }
113
-
114
- case 'GO_TO_PAGE': {
115
- if (action.payload.pageIndex === state.currentPage) {
116
- return state
117
- }
118
-
119
- return {
120
- ...state,
121
- sliding: action.payload.shouldSlide,
122
- slideDirection:
123
- action.payload.pageIndex > state.currentPage ? 'next' : 'previous',
124
- currentItem:
125
- (action.payload.pageIndex % state.totalPages) * state.itemsPerPage,
126
- currentPage: action.payload.pageIndex,
127
- }
128
- }
129
-
130
- case 'STOP_SLIDE':
131
- return { ...state, sliding: false }
132
-
133
- default:
134
- return state
135
- }
136
- }
137
-
138
- const defaultSliderState = (
139
- totalItems: number,
140
- itemsPerPage: number,
141
- infinite: boolean
142
- ): SliderState => ({
143
- currentItem: 0,
144
- currentPage: 0,
145
- sliding: false,
146
- slideDirection: 'next',
147
- totalItems,
148
- itemsPerPage,
149
- totalPages: Math.ceil(totalItems / itemsPerPage),
150
- infinite,
151
- })
152
-
153
- const slide = (page: SlideDirection | number, dispatch: Dispatch<Action>) => {
154
- if (page === 'next') {
155
- dispatch({ type: 'NEXT_PAGE' })
156
- }
157
-
158
- if (page === 'previous') {
159
- dispatch({ type: 'PREVIOUS_PAGE' })
160
- }
161
-
162
- if (typeof page === 'number') {
163
- dispatch({
164
- type: 'GO_TO_PAGE',
165
- payload: {
166
- pageIndex: page,
167
- shouldSlide: true,
168
- },
169
- })
170
- }
171
- }
172
-
173
- export interface UseSliderArgs extends SwipeableProps {
174
- /** The total number of unique items in the slider. */
175
- totalItems: number
176
- /** The number of items in a single slider page. */
177
- itemsPerPage?: number
178
- /** Whether or not the slider is infinite. */
179
- infiniteMode?: boolean
180
- /** Whether or not slide after swiping left/right. */
181
- shouldSlideOnSwipe?: boolean
182
- }
183
-
184
- export default function useSlider({
185
- totalItems,
186
- itemsPerPage = 1,
187
- infiniteMode = false,
188
- shouldSlideOnSwipe = true,
189
- ...swipeableConfigOverrides
190
- }: UseSliderArgs) {
191
- const [sliderState, sliderDispatch] = useReducer(reducer, undefined, () =>
192
- defaultSliderState(totalItems, itemsPerPage, infiniteMode)
193
- )
194
-
195
- const handlers = useSwipeable({
196
- onSwipedRight: () =>
197
- shouldSlideOnSwipe && slide('previous', sliderDispatch),
198
- onSwipedLeft: () => shouldSlideOnSwipe && slide('next', sliderDispatch),
199
- trackMouse: true,
200
- ...swipeableConfigOverrides,
201
- })
202
-
203
- return {
204
- handlers,
205
- slide,
206
- sliderState,
207
- sliderDispatch,
208
- }
209
- }