etudes 5.2.0 → 5.3.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 (164) hide show
  1. package/components/Accordion.js +171 -205
  2. package/components/BurgerButton.js +40 -94
  3. package/components/Carousel.js +87 -123
  4. package/components/Collection.js +84 -120
  5. package/components/Counter.js +32 -63
  6. package/components/CoverImage.js +24 -68
  7. package/components/CoverVideo.js +25 -69
  8. package/components/DebugConsole.js +27 -79
  9. package/components/Dial.js +28 -65
  10. package/components/Dropdown.js +86 -98
  11. package/components/FlatSVG.js +22 -71
  12. package/components/Image.js +21 -50
  13. package/components/MasonryGrid.js +122 -257
  14. package/components/Panorama.js +48 -92
  15. package/components/PanoramaSlider.js +57 -113
  16. package/components/RangeSlider.js +125 -182
  17. package/components/RotatingGallery.js +28 -59
  18. package/components/SelectableButton.js +10 -54
  19. package/components/Slider.js +108 -159
  20. package/components/StepwiseSlider.js +124 -176
  21. package/components/SwipeContainer.js +30 -73
  22. package/components/TextField.js +12 -49
  23. package/components/Video.js +31 -61
  24. package/components/WithTooltip.js +117 -111
  25. package/components/index.js +24 -0
  26. package/hooks/index.js +17 -0
  27. package/hooks/useClickOutsideEffect.js +8 -38
  28. package/hooks/useDragEffect.js +20 -53
  29. package/hooks/useDragValueEffect.js +31 -81
  30. package/hooks/useImageSize.js +16 -38
  31. package/hooks/useInterval.js +9 -41
  32. package/hooks/useLoadImageEffect.js +15 -48
  33. package/hooks/useLoadVideoMetadataEffect.js +15 -48
  34. package/hooks/useMounted.js +5 -25
  35. package/hooks/usePrevious.js +4 -9
  36. package/hooks/useRect.js +9 -29
  37. package/hooks/useResizeEffect.js +10 -44
  38. package/hooks/useScrollPositionEffect.js +19 -50
  39. package/hooks/useSearchParamState.js +12 -34
  40. package/hooks/useSize.js +9 -29
  41. package/hooks/useTimeout.js +8 -38
  42. package/hooks/useVideoSize.js +16 -38
  43. package/hooks/useViewportSize.js +7 -27
  44. package/operators/Conditional.js +6 -11
  45. package/operators/Each.js +6 -14
  46. package/operators/ExtractChild.js +9 -36
  47. package/operators/ExtractChildren.js +7 -34
  48. package/operators/Repeat.js +4 -37
  49. package/operators/index.js +5 -0
  50. package/package.json +27 -41
  51. package/providers/ScrollPositionProvider.js +37 -60
  52. package/providers/index.js +1 -0
  53. package/utils/asClassNameDict.js +1 -5
  54. package/utils/asComponentDict.js +11 -16
  55. package/utils/asStyleDict.js +1 -5
  56. package/utils/cloneStyledElement.js +14 -61
  57. package/utils/index.js +5 -22
  58. package/utils/styles.js +5 -21
  59. package/components/Accordion.d.ts +0 -219
  60. package/components/Accordion.js.map +0 -1
  61. package/components/BurgerButton.d.ts +0 -34
  62. package/components/BurgerButton.js.map +0 -1
  63. package/components/Carousel.d.ts +0 -53
  64. package/components/Carousel.js.map +0 -1
  65. package/components/Collection.d.ts +0 -171
  66. package/components/Collection.js.map +0 -1
  67. package/components/Counter.d.ts +0 -11
  68. package/components/Counter.js.map +0 -1
  69. package/components/CoverImage.d.ts +0 -28
  70. package/components/CoverImage.js.map +0 -1
  71. package/components/CoverVideo.d.ts +0 -28
  72. package/components/CoverVideo.js.map +0 -1
  73. package/components/DebugConsole.d.ts +0 -15
  74. package/components/DebugConsole.js.map +0 -1
  75. package/components/Dial.d.ts +0 -79
  76. package/components/Dial.js.map +0 -1
  77. package/components/Dropdown.d.ts +0 -109
  78. package/components/Dropdown.js.map +0 -1
  79. package/components/FlatSVG.d.ts +0 -72
  80. package/components/FlatSVG.js.map +0 -1
  81. package/components/Image.d.ts +0 -144
  82. package/components/Image.js.map +0 -1
  83. package/components/MasonryGrid.d.ts +0 -29
  84. package/components/MasonryGrid.js.map +0 -1
  85. package/components/Panorama.d.ts +0 -77
  86. package/components/Panorama.js.map +0 -1
  87. package/components/PanoramaSlider.d.ts +0 -71
  88. package/components/PanoramaSlider.js.map +0 -1
  89. package/components/RangeSlider.d.ts +0 -34
  90. package/components/RangeSlider.js.map +0 -1
  91. package/components/RotatingGallery.d.ts +0 -91
  92. package/components/RotatingGallery.js.map +0 -1
  93. package/components/SelectableButton.d.ts +0 -19
  94. package/components/SelectableButton.js.map +0 -1
  95. package/components/Slider.d.ts +0 -160
  96. package/components/Slider.js.map +0 -1
  97. package/components/StepwiseSlider.d.ts +0 -215
  98. package/components/StepwiseSlider.js.map +0 -1
  99. package/components/SwipeContainer.d.ts +0 -21
  100. package/components/SwipeContainer.js.map +0 -1
  101. package/components/TextField.d.ts +0 -21
  102. package/components/TextField.js.map +0 -1
  103. package/components/Video.d.ts +0 -38
  104. package/components/Video.js.map +0 -1
  105. package/components/WithTooltip.d.ts +0 -32
  106. package/components/WithTooltip.js.map +0 -1
  107. package/hooks/useClickOutsideEffect.d.ts +0 -2
  108. package/hooks/useClickOutsideEffect.js.map +0 -1
  109. package/hooks/useDragEffect.d.ts +0 -48
  110. package/hooks/useDragEffect.js.map +0 -1
  111. package/hooks/useDragValueEffect.d.ts +0 -56
  112. package/hooks/useDragValueEffect.js.map +0 -1
  113. package/hooks/useImageSize.d.ts +0 -21
  114. package/hooks/useImageSize.js.map +0 -1
  115. package/hooks/useInterval.d.ts +0 -18
  116. package/hooks/useInterval.js.map +0 -1
  117. package/hooks/useLoadImageEffect.d.ts +0 -43
  118. package/hooks/useLoadImageEffect.js.map +0 -1
  119. package/hooks/useLoadVideoMetadataEffect.d.ts +0 -35
  120. package/hooks/useLoadVideoMetadataEffect.js.map +0 -1
  121. package/hooks/useMounted.d.ts +0 -1
  122. package/hooks/useMounted.js.map +0 -1
  123. package/hooks/usePrevious.d.ts +0 -19
  124. package/hooks/usePrevious.js.map +0 -1
  125. package/hooks/useRect.d.ts +0 -11
  126. package/hooks/useRect.js.map +0 -1
  127. package/hooks/useResizeEffect.d.ts +0 -17
  128. package/hooks/useResizeEffect.js.map +0 -1
  129. package/hooks/useScrollPositionEffect.d.ts +0 -13
  130. package/hooks/useScrollPositionEffect.js.map +0 -1
  131. package/hooks/useSearchParamState.d.ts +0 -34
  132. package/hooks/useSearchParamState.js.map +0 -1
  133. package/hooks/useSize.d.ts +0 -10
  134. package/hooks/useSize.js.map +0 -1
  135. package/hooks/useTimeout.d.ts +0 -10
  136. package/hooks/useTimeout.js.map +0 -1
  137. package/hooks/useVideoSize.d.ts +0 -21
  138. package/hooks/useVideoSize.js.map +0 -1
  139. package/hooks/useViewportSize.d.ts +0 -7
  140. package/hooks/useViewportSize.js.map +0 -1
  141. package/operators/Conditional.d.ts +0 -5
  142. package/operators/Conditional.js.map +0 -1
  143. package/operators/Each.d.ts +0 -7
  144. package/operators/Each.js.map +0 -1
  145. package/operators/ExtractChild.d.ts +0 -8
  146. package/operators/ExtractChild.js.map +0 -1
  147. package/operators/ExtractChildren.d.ts +0 -6
  148. package/operators/ExtractChildren.js.map +0 -1
  149. package/operators/Repeat.d.ts +0 -11
  150. package/operators/Repeat.js.map +0 -1
  151. package/providers/ScrollPositionProvider.d.ts +0 -15
  152. package/providers/ScrollPositionProvider.js.map +0 -1
  153. package/utils/asClassNameDict.d.ts +0 -3
  154. package/utils/asClassNameDict.js.map +0 -1
  155. package/utils/asComponentDict.d.ts +0 -5
  156. package/utils/asComponentDict.js.map +0 -1
  157. package/utils/asStyleDict.d.ts +0 -4
  158. package/utils/asStyleDict.js.map +0 -1
  159. package/utils/cloneStyledElement.d.ts +0 -18
  160. package/utils/cloneStyledElement.js.map +0 -1
  161. package/utils/index.d.ts +0 -5
  162. package/utils/index.js.map +0 -1
  163. package/utils/styles.d.ts +0 -2
  164. package/utils/styles.js.map +0 -1
@@ -1,219 +0,0 @@
1
- import { type ComponentType, type HTMLAttributes, type PropsWithChildren, type ReactElement, type Ref } from 'react';
2
- import { type CollectionItemProps, type CollectionOrientation, type CollectionProps, type CollectionSelectionMode } from './Collection';
3
- /**
4
- * Type describing the current item selection of {@link Accordion}, composed of
5
- * a dictionary whose key corresponds the section index and value corresponds to
6
- * an array of selected item indices. If the selection mode of the
7
- * {@link Accordion} is `single`, only one key will be present and one index in
8
- * the array value.
9
- */
10
- export type AccordionSelection = Record<number, number[]>;
11
- /**
12
- * Type describing the data of each section in {@link Accordion}.
13
- */
14
- export type AccordionSection<T> = Pick<CollectionProps<T>, 'isSelectionTogglable' | 'itemLength' | 'itemPadding' | 'items' | 'layout' | 'numSegments'> & {
15
- /**
16
- * Padding (in pixels) between the sectionheader and the internal collection.
17
- */
18
- collectionPadding?: number;
19
- /**
20
- * Label for the section header.
21
- */
22
- label: string;
23
- /**
24
- * Maximum number of visible rows (if section orientation is `vertical`) or
25
- * columns (if section orientation is `horizontal`). If number of rows exceeds
26
- * the number of visible, a scrollbar will be put in place.
27
- */
28
- maxVisible?: number;
29
- };
30
- /**
31
- * Type describing the props of each `ItemComponent` provided to
32
- * {@link Accordion}.
33
- */
34
- export type AccordionItemProps<T> = CollectionItemProps<T>;
35
- /**
36
- * Type describing the props of each `HeaderComponent` provided to
37
- * {@link Accordion}.
38
- */
39
- export type AccordionHeaderProps<I, S extends AccordionSection<I> = AccordionSection<I>> = HTMLAttributes<HTMLElement> & PropsWithChildren<{
40
- /**
41
- * The index of the corresponding section.
42
- */
43
- index: number;
44
- /**
45
- * Indicates whether the corresponding section is collapsed.
46
- */
47
- isCollapsed: boolean;
48
- /**
49
- * Data provided to the corresponding section.
50
- */
51
- section: S;
52
- /**
53
- * Handler invoked to dispatch a custom event.
54
- *
55
- * @param name User-defined name of the custom event.
56
- * @param info Optional user-defined info of the custom event.
57
- */
58
- onCustomEvent?: (name: string, info?: any) => void;
59
- }>;
60
- /**
61
- * Type describing the props of {@link Accordion}.
62
- */
63
- export type AccordionProps<I, S extends AccordionSection<I> = AccordionSection<I>> = HTMLAttributes<HTMLDivElement> & PropsWithChildren<{
64
- /**
65
- * Specifies if expanded sections should automatically collapse upon expanding
66
- * another section.
67
- */
68
- autoCollapseSections?: boolean;
69
- /**
70
- * SVG markup to use as the collapse icon when a toggle button is
71
- * automatically generated (when `HeaderComponent` is absent).
72
- */
73
- collapseIconSvg?: string;
74
- /**
75
- * Indices of sections that are expanded. If specified, the component will not
76
- * manage expansion states.
77
- */
78
- expandedSectionIndices?: number[];
79
- /**
80
- * SVG markup to use as the expand icon when a toggle button is automatically
81
- * generated (when `HeaderComponent` is absent).
82
- */
83
- expandIconSvg?: string;
84
- /**
85
- * Orientation of this component.
86
- *
87
- * @see {@link CollectionOrientation}
88
- */
89
- orientation?: CollectionOrientation;
90
- /**
91
- * Padding (in pixels) between each section.
92
- */
93
- sectionPadding?: number;
94
- /**
95
- * Data provided to each section.
96
- */
97
- sections: S[];
98
- /**
99
- * Indices of selected items per section.
100
- *
101
- * @see {@link AccordionSelection}
102
- */
103
- selection?: AccordionSelection;
104
- /**
105
- * Selection mode of each section.
106
- *
107
- * @see {@link CollectionSelectionMode}
108
- */
109
- selectionMode?: CollectionSelectionMode;
110
- /**
111
- * Specifies if the component should use default styles.
112
- */
113
- usesDefaultStyles?: boolean;
114
- /**
115
- * Handler invoked when an item is activated in a section. The order of
116
- * handlers invoked when any selection changes take place is:
117
- * 1. `onActivateAt`
118
- * 2. `onDeselectAt`
119
- * 3. `onSelectAt`
120
- * 4. `onSelectionChange`
121
- *
122
- * @param itemIndex Item index.
123
- * @param sectionIndex Section index.
124
- */
125
- onActivateAt?: (itemIndex: number, sectionIndex: number) => void;
126
- /**
127
- * Handler invoked when a section is collapsed. The order of handlers invoked
128
- * when any section expansion changes take place is:
129
- * 1. `onCollapseSectionAt`
130
- * 2. `onExpandSectionAt`
131
- *
132
- * @param sectionIndex Section index.
133
- */
134
- onCollapseSectionAt?: (sectionIndex: number) => void;
135
- /**
136
- * Handler invoked when an item is deselected in a section. The order of
137
- * handlers invoked when any selection changes take place is:
138
- * 1. `onActivateAt`
139
- * 2. `onDeselectAt`
140
- * 3. `onSelectAt`
141
- * 4. `onSelectionChange`
142
- *
143
- * @param itemIndex Item index.
144
- * @param sectionIndex Section index.
145
- */
146
- onDeselectAt?: (itemIndex: number, sectionIndex: number) => void;
147
- /**
148
- * Handler invoked when the expansion state of any section changes.
149
- *
150
- * @param expandedSectionIndices Indices of sections that are expanded.
151
- */
152
- onExpandedSectionsChange?: (expandedSectionIndices: number[]) => void;
153
- /**
154
- * Handler invoked when a section is expanded. The order of handlers invoked
155
- * when any section expansion changes take place is:
156
- * 1. `onCollapseSectionAt`
157
- * 2. `onExpandSectionAt`
158
- *
159
- * @param sectionIndex Section index.
160
- */
161
- onExpandSectionAt?: (sectionIndex: number) => void;
162
- /**
163
- * Handler invoked when a custom event is dispatched from a section header.
164
- *
165
- * @param sectionIndex Index of the section which the header belongs.
166
- * @param eventName User-defined name of the dispatched event.
167
- * @param eventInfo Optional user-defined info of the dispatched event.
168
- */
169
- onHeaderCustomEvent?: (sectionIndex: number, eventName: string, eventInfo?: any) => void;
170
- /**
171
- * Handler invoked when a custom event is dispatched from an item.
172
- *
173
- * @param itemIndex Item index.
174
- * @param sectionIndex Section index.
175
- * @param eventName User-defined name of the dispatched event.
176
- * @param eventInfo Optional user-defined info of the dispatched event.
177
- */
178
- onItemCustomEvent?: (itemIndex: number, sectionIndex: number, eventName: string, eventInfo?: any) => void;
179
- /**
180
- * Handler invoked when an item is selected in a section. The order of
181
- * handlers invoked when any selection changes take place is:
182
- * 1. `onActivateAt`
183
- * 2. `onDeselectAt`
184
- * 3. `onSelectAt`
185
- * 4. `onSelectionChange`
186
- *
187
- * @param itemIndex Item index.
188
- * @param sectionIndex Section index.
189
- */
190
- onSelectAt?: (itemIndex: number, sectionIndex: number) => void;
191
- /**
192
- * Handler invoked when selected items have changed. The order of handlers
193
- * invoked when any selection changes take place is:
194
- * 1. `onActivateAt`
195
- * 2. `onDeselectAt`
196
- * 3. `onSelectAt`
197
- * 4. `onSelectionChange`
198
- *
199
- * @param selectedIndices Dictionary of indices of selected items per section.
200
- */
201
- onSelectionChange?: (selection: AccordionSelection) => void;
202
- /**
203
- * Component type for generating section headers inside the component. When
204
- * absent, one will be generated automatically.
205
- */
206
- HeaderComponent?: ComponentType<AccordionHeaderProps<I, S>>;
207
- /**
208
- * Component type for generating items for each section.
209
- */
210
- ItemComponent?: ComponentType<AccordionItemProps<I>>;
211
- }>;
212
- /**
213
- * A collection of selectable items laid out in sections in an accordion. Items
214
- * are generated based on the provided `ItemComponent` while each section header
215
- * is optionally provided by `HeaderComponent` or generated automatically.
216
- */
217
- export declare const Accordion: <I, S extends AccordionSection<I> = AccordionSection<I>>(props: AccordionProps<I, S> & {
218
- ref?: Ref<HTMLDivElement>;
219
- }) => ReactElement;
@@ -1 +0,0 @@
1
- {"version":3,"file":"Accordion.js","sourceRoot":"/","sources":["components/Accordion.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAuB;AACvB,gEAA+C;AAC/C,+BAAmJ;AACnJ,0CAAwC;AACxC,kCAAkE;AAClE,2CAAmJ;AACnJ,qCAAmC;AAiPnC;;;;GAIG;AACU,QAAA,SAAS,GAAG,IAAA,kBAAU,EAAC,UAAC,EAyBpC,EAAE,GAAG;IAxBJ,IAAA,QAAQ,cAAA,EACR,KAAK,WAAA,EACL,4BAA4B,EAA5B,oBAAoB,mBAAG,KAAK,KAAA,EAC5B,eAAe,qBAAA,EACS,8BAA8B,4BAAA,EACtD,aAAa,mBAAA,EACb,mBAAwB,EAAxB,WAAW,mBAAG,UAAU,KAAA,EACxB,sBAAkB,EAAlB,cAAc,mBAAG,CAAC,KAAA,EAClB,QAAQ,cAAA,EACG,iBAAiB,eAAA,EAC5B,qBAAwB,EAAxB,aAAa,mBAAG,QAAQ,KAAA,EACxB,yBAAyB,EAAzB,iBAAiB,mBAAG,KAAK,KAAA,EACzB,YAAY,kBAAA,EACZ,mBAAmB,yBAAA,EACnB,YAAY,kBAAA,EACZ,wBAAwB,8BAAA,EACxB,iBAAiB,uBAAA,EACjB,mBAAmB,yBAAA,EACnB,iBAAiB,uBAAA,EACjB,UAAU,gBAAA,EACV,iBAAiB,uBAAA,EACjB,eAAe,qBAAA,EACf,aAAa,mBAAA,EACV,KA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nimport isDeepEqual from 'fast-deep-equal/react'\nimport { forwardRef, useEffect, useRef, type ComponentType, type HTMLAttributes, type PropsWithChildren, type ReactElement, type Ref } from 'react'\nimport { Each } from '../operators/Each'\nimport { asStyleDict, cloneStyledElement, styles } from '../utils'\nimport { Collection, type CollectionItemProps, type CollectionOrientation, type CollectionProps, type CollectionSelectionMode } from './Collection'\nimport { FlatSVG } from './FlatSVG'\n\n/**\n * Type describing the current item selection of {@link Accordion}, composed of\n * a dictionary whose key corresponds the section index and value corresponds to\n * an array of selected item indices. If the selection mode of the\n * {@link Accordion} is `single`, only one key will be present and one index in\n * the array value.\n */\nexport type AccordionSelection = Record<number, number[]>\n\n/**\n * Type describing the data of each section in {@link Accordion}.\n */\nexport type AccordionSection<T> = Pick<CollectionProps<T>, 'isSelectionTogglable' | 'itemLength' | 'itemPadding' | 'items' | 'layout' | 'numSegments'> & {\n /**\n * Padding (in pixels) between the sectionheader and the internal collection.\n */\n collectionPadding?: number\n\n /**\n * Label for the section header.\n */\n label: string\n\n /**\n * Maximum number of visible rows (if section orientation is `vertical`) or\n * columns (if section orientation is `horizontal`). If number of rows exceeds\n * the number of visible, a scrollbar will be put in place.\n */\n maxVisible?: number\n}\n\n/**\n * Type describing the props of each `ItemComponent` provided to\n * {@link Accordion}.\n */\nexport type AccordionItemProps<T> = CollectionItemProps<T>\n\n/**\n * Type describing the props of each `HeaderComponent` provided to\n * {@link Accordion}.\n */\nexport type AccordionHeaderProps<I, S extends AccordionSection<I> = AccordionSection<I>> = HTMLAttributes<HTMLElement> & PropsWithChildren<{\n /**\n * The index of the corresponding section.\n */\n index: number\n\n /**\n * Indicates whether the corresponding section is collapsed.\n */\n isCollapsed: boolean\n\n /**\n * Data provided to the corresponding section.\n */\n section: S\n\n /**\n * Handler invoked to dispatch a custom event.\n *\n * @param name User-defined name of the custom event.\n * @param info Optional user-defined info of the custom event.\n */\n onCustomEvent?: (name: string, info?: any) => void\n}>\n\n/**\n * Type describing the props of {@link Accordion}.\n */\nexport type AccordionProps<I, S extends AccordionSection<I> = AccordionSection<I>> = HTMLAttributes<HTMLDivElement> & PropsWithChildren<{\n /**\n * Specifies if expanded sections should automatically collapse upon expanding\n * another section.\n */\n autoCollapseSections?: boolean\n\n /**\n * SVG markup to use as the collapse icon when a toggle button is\n * automatically generated (when `HeaderComponent` is absent).\n */\n collapseIconSvg?: string\n\n /**\n * Indices of sections that are expanded. If specified, the component will not\n * manage expansion states.\n */\n expandedSectionIndices?: number[]\n\n /**\n * SVG markup to use as the expand icon when a toggle button is automatically\n * generated (when `HeaderComponent` is absent).\n */\n expandIconSvg?: string\n\n /**\n * Orientation of this component.\n *\n * @see {@link CollectionOrientation}\n */\n orientation?: CollectionOrientation\n\n /**\n * Padding (in pixels) between each section.\n */\n sectionPadding?: number\n\n /**\n * Data provided to each section.\n */\n sections: S[]\n\n /**\n * Indices of selected items per section.\n *\n * @see {@link AccordionSelection}\n */\n selection?: AccordionSelection\n\n /**\n * Selection mode of each section.\n *\n * @see {@link CollectionSelectionMode}\n */\n selectionMode?: CollectionSelectionMode\n\n /**\n * Specifies if the component should use default styles.\n */\n usesDefaultStyles?: boolean\n\n /**\n * Handler invoked when an item is activated in a section. The order of\n * handlers invoked when any selection changes take place is:\n * 1. `onActivateAt`\n * 2. `onDeselectAt`\n * 3. `onSelectAt`\n * 4. `onSelectionChange`\n *\n * @param itemIndex Item index.\n * @param sectionIndex Section index.\n */\n onActivateAt?: (itemIndex: number, sectionIndex: number) => void\n\n /**\n * Handler invoked when a section is collapsed. The order of handlers invoked\n * when any section expansion changes take place is:\n * 1. `onCollapseSectionAt`\n * 2. `onExpandSectionAt`\n *\n * @param sectionIndex Section index.\n */\n onCollapseSectionAt?: (sectionIndex: number) => void\n\n /**\n * Handler invoked when an item is deselected in a section. The order of\n * handlers invoked when any selection changes take place is:\n * 1. `onActivateAt`\n * 2. `onDeselectAt`\n * 3. `onSelectAt`\n * 4. `onSelectionChange`\n *\n * @param itemIndex Item index.\n * @param sectionIndex Section index.\n */\n onDeselectAt?: (itemIndex: number, sectionIndex: number) => void\n\n /**\n * Handler invoked when the expansion state of any section changes.\n *\n * @param expandedSectionIndices Indices of sections that are expanded.\n */\n onExpandedSectionsChange?: (expandedSectionIndices: number[]) => void\n\n /**\n * Handler invoked when a section is expanded. The order of handlers invoked\n * when any section expansion changes take place is:\n * 1. `onCollapseSectionAt`\n * 2. `onExpandSectionAt`\n *\n * @param sectionIndex Section index.\n */\n onExpandSectionAt?: (sectionIndex: number) => void\n\n /**\n * Handler invoked when a custom event is dispatched from a section header.\n *\n * @param sectionIndex Index of the section which the header belongs.\n * @param eventName User-defined name of the dispatched event.\n * @param eventInfo Optional user-defined info of the dispatched event.\n */\n onHeaderCustomEvent?: (sectionIndex: number, eventName: string, eventInfo?: any) => void\n\n /**\n * Handler invoked when a custom event is dispatched from an item.\n *\n * @param itemIndex Item index.\n * @param sectionIndex Section index.\n * @param eventName User-defined name of the dispatched event.\n * @param eventInfo Optional user-defined info of the dispatched event.\n */\n onItemCustomEvent?: (itemIndex: number, sectionIndex: number, eventName: string, eventInfo?: any) => void\n\n /**\n * Handler invoked when an item is selected in a section. The order of\n * handlers invoked when any selection changes take place is:\n * 1. `onActivateAt`\n * 2. `onDeselectAt`\n * 3. `onSelectAt`\n * 4. `onSelectionChange`\n *\n * @param itemIndex Item index.\n * @param sectionIndex Section index.\n */\n onSelectAt?: (itemIndex: number, sectionIndex: number) => void\n\n /**\n * Handler invoked when selected items have changed. The order of handlers\n * invoked when any selection changes take place is:\n * 1. `onActivateAt`\n * 2. `onDeselectAt`\n * 3. `onSelectAt`\n * 4. `onSelectionChange`\n *\n * @param selectedIndices Dictionary of indices of selected items per section.\n */\n onSelectionChange?: (selection: AccordionSelection) => void\n\n /**\n * Component type for generating section headers inside the component. When\n * absent, one will be generated automatically.\n */\n HeaderComponent?: ComponentType<AccordionHeaderProps<I, S>>\n\n /**\n * Component type for generating items for each section.\n */\n ItemComponent?: ComponentType<AccordionItemProps<I>>\n}>\n\n/**\n * A collection of selectable items laid out in sections in an accordion. Items\n * are generated based on the provided `ItemComponent` while each section header\n * is optionally provided by `HeaderComponent` or generated automatically.\n */\nexport const Accordion = forwardRef(({\n children,\n style,\n autoCollapseSections = false,\n collapseIconSvg,\n expandedSectionIndices: externalExpandedSectionIndices,\n expandIconSvg,\n orientation = 'vertical',\n sectionPadding = 0,\n sections,\n selection: externalSelection,\n selectionMode = 'single',\n usesDefaultStyles = false,\n onActivateAt,\n onCollapseSectionAt,\n onDeselectAt,\n onExpandedSectionsChange,\n onExpandSectionAt,\n onHeaderCustomEvent,\n onItemCustomEvent,\n onSelectAt,\n onSelectionChange,\n HeaderComponent,\n ItemComponent,\n ...props\n}, ref) => {\n const isSectionIndexOutOfRange = (sectionIndex: number) => {\n if (sectionIndex >= sections.length) return true\n if (sectionIndex < 0) return true\n\n return false\n }\n\n const isItemIndexOutOfRange = (itemIndex: number, sectionIndex: number) => {\n if (isSectionIndexOutOfRange(sectionIndex)) return true\n\n const items = sections[sectionIndex].items\n\n if (itemIndex >= items.length) return true\n if (itemIndex < 0) return true\n\n return false\n }\n\n const isSelectedAt = (itemIndex: number, sectionIndex: number) => (selection[sectionIndex]?.indexOf(itemIndex) ?? -1) >= 0\n\n const sanitizeExpandedSectionIndices = (sectionIndices: number[]) => sortIndices(sectionIndices).filter(t => !isSectionIndexOutOfRange(t))\n\n const sanitizeSelection = (selection: AccordionSelection) => {\n const newValue: AccordionSelection = {}\n\n for (const sectionIndex in sections) {\n if (!Object.hasOwn(sections, sectionIndex)) continue\n\n const indices = sortIndices([...selection[sectionIndex] ?? []])\n\n newValue[Number(sectionIndex)] = sortIndices(indices).filter(t => !isItemIndexOutOfRange(t, Number(sectionIndex)))\n }\n\n return newValue\n }\n\n const isSectionExpandedAt = (sectionIndex: number) => expandedSectionIndices.indexOf(sectionIndex) >= 0\n\n const toggleSectionAt = (sectionIndex: number) => {\n let transform: (val: number[]) => number[]\n\n if (isSectionExpandedAt(sectionIndex)) {\n transform = val => val.filter(t => t !== sectionIndex)\n }\n else if (autoCollapseSections) {\n transform = val => [sectionIndex]\n }\n else {\n transform = val => [...val.filter(t => t !== sectionIndex), sectionIndex]\n }\n\n handleExpandedSectionsChange(expandedSectionIndices, transform(expandedSectionIndices))\n }\n\n const handleSelectAt = (itemIndex: number, sectionIndex: number) => {\n if (isSelectedAt(itemIndex, sectionIndex)) return\n\n let transform: (val: AccordionSelection) => AccordionSelection\n\n switch (selectionMode) {\n case 'multiple':\n transform = val => ({\n ...val,\n [sectionIndex]: sortIndices([...(val[sectionIndex] ?? []).filter(t => t !== itemIndex), itemIndex]),\n })\n break\n case 'single':\n transform = val => ({\n [sectionIndex]: [itemIndex],\n })\n break\n default:\n return\n }\n\n const newValue = transform(selection)\n\n prevSelectionRef.current = newValue\n handleSelectionChange(selection, newValue)\n }\n\n const handleDeselectAt = (itemIndex: number, sectionIndex: number) => {\n if (!isSelectedAt(itemIndex, sectionIndex)) return\n\n const transform = (val: AccordionSelection) => ({\n ...val,\n [sectionIndex]: (val[sectionIndex] ?? []).filter(t => t !== itemIndex),\n })\n\n const newValue = transform(selection)\n\n prevSelectionRef.current = newValue\n handleSelectionChange(selection, newValue)\n }\n\n const handleExpandedSectionsChange = (oldValue: number[] | undefined, newValue: number[]) => {\n if (isDeepEqual(oldValue, newValue)) return\n\n const collapsed = oldValue?.filter(t => newValue.indexOf(t) === -1) ?? []\n const expanded = newValue.filter(t => oldValue?.indexOf(t) === -1)\n\n collapsed.forEach(t => onCollapseSectionAt?.(t))\n expanded.forEach(t => onExpandSectionAt?.(t))\n\n onExpandedSectionsChange?.(newValue)\n }\n\n const handleSelectionChange = (oldValue: AccordionSelection | undefined, newValue: AccordionSelection) => {\n if (isDeepEqual(oldValue, newValue)) return\n\n const numSections = sections.length\n\n let allDeselected: number[][] = []\n let allSelected: number[][] = []\n\n for (let i = 0; i < numSections; i++) {\n const oldSection = oldValue?.[i] ?? []\n const newSection = newValue[i] ?? []\n const deselected = oldSection.filter(t => newSection.indexOf(t) === -1)\n const selected = newSection.filter(t => oldSection?.indexOf(t) === -1)\n\n allDeselected = [...allDeselected, ...deselected.map(t => [t, i])]\n allSelected = [...allSelected, ...selected.map(t => [t, i])]\n }\n\n allDeselected.forEach(t => onDeselectAt?.(t[0], t[1]))\n allSelected.forEach(t => onSelectAt?.(t[0], t[1]))\n\n onSelectionChange?.(newValue)\n }\n\n const selection = sanitizeSelection(externalSelection ?? {})\n const expandedSectionIndices = sanitizeExpandedSectionIndices(externalExpandedSectionIndices ?? [])\n const fixedStyles = getFixedStyles({ orientation })\n const defaultStyles = usesDefaultStyles ? getDefaultStyles({ orientation }) : undefined\n const prevSelectionRef = useRef<AccordionSelection>()\n const prevSelection = prevSelectionRef.current\n\n useEffect(() => {\n prevSelectionRef.current = selection\n\n if (prevSelection === undefined) return\n\n handleSelectionChange(prevSelection, selection)\n }, [JSON.stringify(selection)])\n\n return (\n <div {...props} ref={ref} data-component='accordion' style={styles(style, fixedStyles.root)}>\n <Each in={sections}>\n {(section, sectionIndex) => {\n const { collectionPadding = 0, items, itemLength = 50, itemPadding = 0, isSelectionTogglable, layout = 'list', maxVisible = -1, numSegments = 1 } = section\n const allVisible = layout === 'list' ? items.length : Math.ceil(items.length / numSegments)\n const numVisible = maxVisible < 0 ? allVisible : Math.min(allVisible, maxVisible)\n const maxLength = itemLength * numVisible + itemPadding * (numVisible - 1)\n const isCollapsed = !isSectionExpandedAt(sectionIndex)\n const expandIconComponent = expandIconSvg ? <FlatSVG style={defaultStyles?.expandIcon} svg={expandIconSvg}/> : <></>\n const collapseIconComponent = collapseIconSvg ? <FlatSVG style={defaultStyles?.collapseIcon} svg={collapseIconSvg}/> : expandIconComponent\n\n return (\n <div\n style={styles(fixedStyles.section, orientation === 'vertical' ? {\n marginTop: sectionIndex === 0 ? '0px' : `${sectionPadding}px`,\n } : {\n marginLeft: sectionIndex === 0 ? '0px' : `${sectionPadding}px`,\n })}\n >\n {HeaderComponent ? (\n <HeaderComponent\n className={clsx({ collapsed: isCollapsed, expanded: !isCollapsed })}\n data-child='header'\n index={sectionIndex}\n isCollapsed={isCollapsed}\n section={section}\n style={styles(fixedStyles.header)}\n onClick={() => toggleSectionAt(sectionIndex)}\n onCustomEvent={(name, info) => onHeaderCustomEvent?.(sectionIndex, name, info)}\n />\n ) : (\n <button\n className={clsx({ collapsed: isCollapsed, expanded: !isCollapsed })}\n data-child='header'\n style={styles(fixedStyles.header, defaultStyles?.header)}\n onClick={() => toggleSectionAt(sectionIndex)}\n >\n <span dangerouslySetInnerHTML={{ __html: section.label }} style={styles(defaultStyles?.headerLabel)}/>\n {cloneStyledElement(isCollapsed ? expandIconComponent : collapseIconComponent, {\n style: styles(isCollapsed ? fixedStyles.expandIcon : fixedStyles.collapseIcon),\n })}\n </button>\n )}\n <Collection\n className={clsx({ collapsed: isCollapsed, expanded: !isCollapsed })}\n data-child='collection'\n isSelectionTogglable={isSelectionTogglable}\n ItemComponent={ItemComponent}\n itemLength={itemLength}\n itemPadding={itemPadding}\n items={items}\n layout={layout}\n numSegments={numSegments}\n orientation={orientation}\n selection={selection[sectionIndex] ?? []}\n selectionMode={selectionMode}\n style={styles(fixedStyles.list, defaultStyles?.collection, orientation === 'vertical' ? {\n width: '100%',\n height: isCollapsed ? '0px' : `${maxLength}px`,\n marginTop: isCollapsed ? '0px' : `${collectionPadding}px`,\n overflowY: maxVisible < 0 || maxVisible >= allVisible ? 'hidden' : 'scroll',\n } : {\n marginLeft: isCollapsed ? '0px' : `${collectionPadding}px`,\n overflowX: maxVisible < 0 || maxVisible >= allVisible ? 'hidden' : 'scroll',\n width: isCollapsed ? '0px' : `${maxLength}px`,\n height: '100%',\n })}\n onActivateAt={itemIndex => {\n onActivateAt?.(itemIndex, sectionIndex)\n }}\n onDeselectAt={itemIndex => {\n handleDeselectAt?.(itemIndex, sectionIndex)\n }}\n onItemCustomEvent={(itemIndex, name, info) => {\n onItemCustomEvent?.(itemIndex, sectionIndex, name, info)\n }}\n onSelectAt={itemIndex => {\n handleSelectAt?.(itemIndex, sectionIndex)\n }}\n />\n </div>\n )\n }}\n </Each>\n </div>\n )\n}) as <I, S extends AccordionSection<I> = AccordionSection<I>>(props: AccordionProps<I, S> & { ref?: Ref<HTMLDivElement> }) => ReactElement\n\nObject.defineProperty(Accordion, 'displayName', { value: 'Accordion', writable: false })\n\nfunction sortIndices(indices: number[]): number[] {\n return indices.sort((a, b) => a - b)\n}\n\nfunction getFixedStyles({ orientation = 'vertical' }) {\n return asStyleDict({\n root: {\n alignItems: 'center',\n boxSizing: 'border-box',\n display: 'flex',\n flex: '0 0 auto',\n justifyContent: 'flex-start',\n padding: '0',\n ...orientation === 'vertical' ? {\n flexDirection: 'column',\n height: 'auto',\n } : {\n flexDirection: 'row',\n width: 'auto',\n },\n },\n section: {\n alignItems: 'flex-start',\n display: 'flex',\n flex: '0 0 auto',\n justifyContent: 'flex-start',\n margin: '0',\n padding: '0',\n ...orientation === 'vertical' ? {\n flexDirection: 'column',\n width: '100%',\n } : {\n flexDirection: 'row',\n height: '100%',\n },\n },\n list: {\n\n },\n header: {\n cursor: 'pointer',\n margin: '0',\n ...orientation === 'vertical' ? {\n width: '100%',\n } : {\n height: '100%',\n },\n },\n expandIcon: {\n margin: '0',\n padding: '0',\n },\n collapseIcon: {\n margin: '0',\n padding: '0',\n },\n })\n}\n\nfunction getDefaultStyles({ orientation = 'vertical' }) {\n return asStyleDict({\n collection: {\n transitionDuration: '100ms',\n transitionTimingFunction: 'ease-out',\n ...orientation === 'vertical' ? {\n transitionProperty: 'height, margin',\n } : {\n transitionProperty: 'width, margin',\n },\n },\n header: {\n border: 'none',\n outline: 'none',\n alignItems: 'center',\n background: '#fff',\n boxSizing: 'border-box',\n display: 'flex',\n flexDirection: 'row',\n justifyContent: 'space-between',\n padding: '0 10px',\n transitionDuration: '100ms',\n transitionProperty: 'transform, opacity, background, color',\n transitionTimingFunction: 'ease-out',\n ...orientation === 'vertical' ? {\n height: '50px',\n } : {\n width: '50px',\n },\n },\n headerLabel: {\n color: 'inherit',\n fontFamily: 'inherit',\n fontSize: 'inherit',\n fontWeight: 'inherit',\n letterSpacing: 'inherit',\n lineHeight: 'inherit',\n pointerEvents: 'none',\n transition: 'inherit',\n },\n expandIcon: {\n boxSizing: 'border-box',\n display: 'block',\n fill: '#000',\n height: '15px',\n transformOrigin: 'center',\n transitionDuration: '100ms',\n transitionProperty: 'transform',\n transitionTimingFunction: 'ease-out',\n width: '15px',\n },\n collapseIcon: {\n boxSizing: 'border-box',\n display: 'block',\n fill: '#000',\n height: '15px',\n transformOrigin: 'center',\n transitionDuration: '100ms',\n transitionProperty: 'transform',\n transitionTimingFunction: 'ease-out',\n width: '15px',\n },\n })\n}\n"]}
@@ -1,34 +0,0 @@
1
- import { type HTMLAttributes, type PropsWithChildren } from 'react';
2
- export type BurgerButtonProps = HTMLAttributes<HTMLButtonElement> & PropsWithChildren<{
3
- height?: number;
4
- isActive?: boolean;
5
- isDoubleJointed?: boolean;
6
- isLastBarHalfWidth?: boolean;
7
- thickness?: number;
8
- transitionDuration?: number;
9
- usesDefaultStyles?: boolean;
10
- width?: number;
11
- onActivate?: () => void;
12
- onDeactivate?: () => void;
13
- }>;
14
- /**
15
- * Three-striped burger button component that transforms into an "X" when
16
- * selected.
17
- *
18
- * @exports BurgerButtonBar Component for each line on the burger button.
19
- */
20
- export declare const BurgerButton: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLButtonElement> & {
21
- height?: number;
22
- isActive?: boolean;
23
- isDoubleJointed?: boolean;
24
- isLastBarHalfWidth?: boolean;
25
- thickness?: number;
26
- transitionDuration?: number;
27
- usesDefaultStyles?: boolean;
28
- width?: number;
29
- onActivate?: () => void;
30
- onDeactivate?: () => void;
31
- } & {
32
- children?: import("react").ReactNode | undefined;
33
- } & import("react").RefAttributes<HTMLButtonElement>>;
34
- export declare const BurgerButtonBar: ({ ...props }: HTMLAttributes<HTMLSpanElement>) => import("react/jsx-runtime").JSX.Element;
@@ -1 +0,0 @@
1
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clsx from 'clsx'\nimport { forwardRef, useEffect, useState, type HTMLAttributes, type PropsWithChildren } from 'react'\nimport { Repeat } from '../operators/Repeat'\nimport { asClassNameDict, asComponentDict, asStyleDict, cloneStyledElement, styles } from '../utils'\n\nexport type BurgerButtonProps = HTMLAttributes<HTMLButtonElement> & PropsWithChildren<{\n height?: number\n isActive?: boolean\n isDoubleJointed?: boolean\n isLastBarHalfWidth?: boolean\n thickness?: number\n transitionDuration?: number\n usesDefaultStyles?: boolean\n width?: number\n onActivate?: () => void\n onDeactivate?: () => void\n}>\n\n/**\n * Three-striped burger button component that transforms into an \"X\" when\n * selected.\n *\n * @exports BurgerButtonBar Component for each line on the burger button.\n */\nexport const BurgerButton = forwardRef<HTMLButtonElement, BurgerButtonProps>(({\n children,\n className,\n style,\n height = 20,\n isActive: externalIsActive = false,\n isDoubleJointed = false,\n isLastBarHalfWidth = false,\n thickness = 2,\n transitionDuration = 200,\n usesDefaultStyles = false,\n width = 20,\n onActivate,\n onDeactivate,\n ...props\n}, ref) => {\n const [isActive, setIsActive] = useState(externalIsActive)\n\n useEffect(() => {\n if (isActive === externalIsActive) return\n\n setIsActive(externalIsActive)\n }, [externalIsActive])\n\n useEffect(() => {\n if (isActive) {\n onActivate?.()\n }\n else {\n onDeactivate?.()\n }\n }, [isActive])\n\n const components = asComponentDict(children, {\n bar: BurgerButtonBar,\n })\n\n const fixedClassNames = asClassNameDict({\n root: clsx({\n active: isActive,\n }),\n bar: clsx({\n active: isActive,\n }),\n })\n\n const fixedStyles = getFixedStyles({ height, width, isDoubleJointed, thickness, isActive, isLastBarHalfWidth })\n const defaultStyles = usesDefaultStyles ? getDefaultStyles() : undefined\n\n return (\n <button\n {...props}\n ref={ref}\n className={clsx(className, fixedClassNames.root)}\n data-component='burger-button'\n style={styles(style, fixedStyles.root)}\n onClick={() => setIsActive(!isActive)}\n >\n <Repeat count={isDoubleJointed ? 2 : 1}>\n {j => (\n <div data-child='joint' style={styles(fixedStyles.joint, (fixedStyles as any)[`joint${j}`])}>\n <Repeat count={3}>\n {i => cloneStyledElement(components.bar ?? <BurgerButtonBar style={defaultStyles?.bar}/>, {\n 'className': clsx(fixedClassNames.bar),\n 'style': styles(fixedStyles.bar, (fixedStyles as any)[`bar${j}${i}`]),\n 'data-index': i,\n })}\n </Repeat>\n </div>\n )}\n </Repeat>\n </button>\n )\n})\n\nObject.defineProperty(BurgerButton, 'displayName', { value: 'BurgerButton', writable: false })\n\nexport const BurgerButtonBar = ({ ...props }: HTMLAttributes<HTMLSpanElement>) => <span {...props} data-child='bar'/>\n\nfunction getFixedStyles({ height = 0, width = 0, isDoubleJointed = false, thickness = 0, isActive = false, isLastBarHalfWidth = false }) {\n return asStyleDict({\n root: {\n background: 'transparent',\n border: 'none',\n display: 'block',\n height: `${height}px`,\n outline: 'none',\n width: `${width}px`,\n },\n joint: {\n height: '100%',\n position: 'absolute',\n width: isDoubleJointed ? '50%' : '100%',\n },\n joint0: {\n left: '0',\n top: '0',\n },\n joint1: {\n right: '0',\n top: '0',\n },\n bar: {\n height: `${thickness}px`,\n margin: '0',\n padding: '0',\n position: 'absolute',\n width: '100%',\n },\n bar00: {\n left: '0',\n top: '0',\n transform: isActive ? `translate3d(0, ${height * 0.5 - thickness * 0.5}px, 0) rotate(45deg)` : 'translate3d(0, 0, 0) rotate(0deg)',\n transformOrigin: isDoubleJointed ? 'right center' : 'center',\n },\n bar01: {\n left: '0',\n top: `${height * 0.5 - thickness * 0.5}px`,\n transform: isActive ? 'translate3d(0, 0, 0) scale(0)' : 'translate3d(0, 0, 0) scale(1)',\n transformOrigin: isDoubleJointed ? 'right center' : 'center',\n },\n bar02: {\n left: '0',\n top: `${height - thickness}px`,\n transform: isActive ? `translate3d(0, ${thickness * 0.5 - height * 0.5}px, 0) rotate(-45deg)` : 'translate3d(0, 0, 0) rotate(0deg)',\n transformOrigin: isDoubleJointed ? 'right center' : 'center',\n width: isActive || isDoubleJointed ? '100%' : `${isLastBarHalfWidth ? '50%' : '100%'}`,\n },\n bar10: {\n left: '0',\n top: '0',\n transform: isActive ? `translate3d(0, ${height * 0.5 - thickness * 0.5}px, 0) rotate(-45deg)` : 'translate3d(0, 0, 0) rotate(0deg)',\n transformOrigin: 'left center',\n },\n bar11: {\n left: '0',\n top: `${height * 0.5 - thickness * 0.5}px`,\n transform: isActive ? 'translate3d(0, 0, 0) scale(0)' : 'translate3d(0, 0, 0) scale(1)',\n transformOrigin: 'left center',\n },\n bar12: {\n left: '0',\n top: `${height - thickness}px`,\n transform: isActive ? `translate3d(0, ${thickness * 0.5 - height * 0.5}px, 0) rotate(45deg)` : 'translate3d(0, 0, 0) rotate(0deg)',\n transformOrigin: 'left center',\n width: isLastBarHalfWidth && !isActive ? '0' : '100%',\n },\n })\n}\n\nfunction getDefaultStyles() {\n return asStyleDict({\n bar: {\n background: '#fff',\n transitionDuration: '100ms',\n transitionProperty: 'width, height, transform, opacity, background',\n transitionTimingFunction: 'ease-out',\n },\n })\n}\n"]}
@@ -1,53 +0,0 @@
1
- import { type ComponentType, type ForwardedRef, type HTMLAttributes, type ReactElement } from 'react';
2
- export type CarouselOrientation = 'horizontal' | 'vertical';
3
- export type CarouselProps<I> = HTMLAttributes<HTMLElement> & {
4
- /**
5
- * Current item index.
6
- */
7
- index?: number;
8
- /**
9
- * The interval in milliseconds to wait before automatically advancing to the
10
- * next item (auto loops).
11
- */
12
- autoAdvanceInterval?: number;
13
- /**
14
- * Whether the carousel is draggable.
15
- */
16
- isDragEnabled?: boolean;
17
- /**
18
- * Props for each item component
19
- */
20
- items?: Omit<I, 'exposure'>[];
21
- /**
22
- * Orientation of the carousel.
23
- */
24
- orientation?: CarouselOrientation;
25
- /**
26
- * Whether to track item exposure (0-1, 0 meaning the item is fully scrolled
27
- * out of view, 1 meaning the item is fully scrolled into view).
28
- */
29
- tracksItemExposure?: boolean;
30
- /**
31
- * Handler invoked when auto advance pauses. This is invoked only when
32
- * {@link autoAdvanceInterval} is greater than 0.
33
- */
34
- onAutoAdvancePause?: () => void;
35
- /**
36
- * Handler invoked when auto advance resumes. This is invoked only when
37
- * {@link autoAdvanceInterval} is greater than 0.
38
- */
39
- onAutoAdvanceResume?: () => void;
40
- /**
41
- * Handler invoked when the item index changes.
42
- *
43
- * @param index The item index.
44
- */
45
- onIndexChange?: (index: number) => void;
46
- /**
47
- * The component to render for each item.
48
- */
49
- ItemComponent: ComponentType<I>;
50
- };
51
- export declare const Carousel: <I extends HTMLAttributes<HTMLElement>>(props: CarouselProps<I> & {
52
- ref?: ForwardedRef<HTMLDivElement>;
53
- }) => ReactElement;
@@ -1 +0,0 @@
1
- {"version":3,"file":"Carousel.js","sourceRoot":"/","sources":["components/Carousel.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAkL;AAClL,+BAAmC;AACnC,wDAAsD;AACtD,kDAAgD;AAChD,0CAAwC;AACxC,kCAA8C;AA8DjC,QAAA,QAAQ,GAAG,IAAA,kBAAU,EAAC,UAAC,EAanC,EAAE,GAAG;IAZJ,IAAA,KAAK,WAAA,EACL,2BAAuB,EAAvB,mBAAmB,mBAAG,CAAC,KAAA,EACvB,aAAS,EAAT,KAAK,mBAAG,CAAC,KAAA,EACT,qBAAoB,EAApB,aAAa,mBAAG,IAAI,KAAA,EACpB,aAAU,EAAV,KAAK,mBAAG,EAAE,KAAA,EACV,mBAA0B,EAA1B,WAAW,mBAAG,YAAY,KAAA,EAC1B,0BAA0B,EAA1B,kBAAkB,mBAAG,KAAK,KAAA,EAC1B,kBAAkB,wBAAA,EAClB,mBAAmB,yBAAA,EACnB,aAAa,mBAAA,EACb,aAAa,mBAAA,EACV,KAAK,cAZ0B,uLAanC,CADS;IAER,IAAM,gBAAgB,GAAG;QACvB,IAAM,eAAe,GAAG,WAAW,CAAC,OAAO,CAAA;QAC3C,IAAI,CAAC,eAAe;YAAE,OAAO,SAAS,CAAA;QAEtC,IAAM,SAAS,GAAG,EAAE,CAAA;QAEpB,KAAK,IAA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,MAAM,EAAE,MAAM;YACd,QAAQ,EAAE,QAAQ;YAClB,eAAe,EAAE,OAAO;YACxB,KAAK,EAAE,MAAM;YACb,cAAc,EAAE,QAAQ;SACzB;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,UAAU;YAChB,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,MAAM;SACd;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { forwardRef, useEffect, useRef, useState, type ComponentType, type ForwardedRef, type HTMLAttributes, type MouseEvent, type PointerEvent, type ReactElement } from 'react'\nimport { Point, Rect } from 'spase'\nimport { useDragEffect } from '../hooks/useDragEffect'\nimport { useTimeout } from '../hooks/useTimeout'\nimport { Each } from '../operators/Each'\nimport { asStyleDict, styles } from '../utils'\n\nexport type CarouselOrientation = 'horizontal' | 'vertical'\n\nexport type CarouselProps<I> = HTMLAttributes<HTMLElement> & {\n /**\n * Current item index.\n */\n index?: number\n\n /**\n * The interval in milliseconds to wait before automatically advancing to the\n * next item (auto loops).\n */\n autoAdvanceInterval?: number\n\n /**\n * Whether the carousel is draggable.\n */\n isDragEnabled?: boolean\n\n /**\n * Props for each item component\n */\n items?: Omit<I, 'exposure'>[]\n\n /**\n * Orientation of the carousel.\n */\n orientation?: CarouselOrientation\n\n /**\n * Whether to track item exposure (0-1, 0 meaning the item is fully scrolled\n * out of view, 1 meaning the item is fully scrolled into view).\n */\n tracksItemExposure?: boolean\n\n /**\n * Handler invoked when auto advance pauses. This is invoked only when\n * {@link autoAdvanceInterval} is greater than 0.\n */\n onAutoAdvancePause?: () => void\n\n /**\n * Handler invoked when auto advance resumes. This is invoked only when\n * {@link autoAdvanceInterval} is greater than 0.\n */\n onAutoAdvanceResume?: () => void\n\n /**\n * Handler invoked when the item index changes.\n *\n * @param index The item index.\n */\n onIndexChange?: (index: number) => void\n\n /**\n * The component to render for each item.\n */\n ItemComponent: ComponentType<I>\n}\n\nexport const Carousel = forwardRef(({\n style,\n autoAdvanceInterval = 0,\n index = 0,\n isDragEnabled = true,\n items = [],\n orientation = 'horizontal',\n tracksItemExposure = false,\n onAutoAdvancePause,\n onAutoAdvanceResume,\n onIndexChange,\n ItemComponent,\n ...props\n}, ref) => {\n const getItemExposures = () => {\n const viewportElement = viewportRef.current\n if (!viewportElement) return undefined\n\n const exposures = []\n\n for (let i = 0; i < viewportElement.children.length; i++) {\n exposures.push(getItemExposureAt(i))\n }\n\n return exposures\n }\n\n const getItemExposureAt = (idx: number) => {\n const viewportElement = viewportRef.current\n const child = viewportElement?.children[idx]\n if (!child) return 0\n\n const intersection = Rect.intersecting(child, viewportElement)\n if (!intersection) return 0\n\n switch (orientation) {\n case 'horizontal':\n return Math.max(0, Math.min(1, Math.round((intersection.width / viewportElement.clientWidth + Number.EPSILON) * 1000) / 1000))\n case 'vertical':\n return Math.max(0, Math.min(1, Math.round((intersection.height / viewportElement.clientHeight + Number.EPSILON) * 1000) / 1000))\n default:\n throw new Error(`Unsupported orientation '${orientation}'`)\n }\n }\n\n const handleIndexChange = (newValue: number) => {\n onIndexChange?.(newValue)\n }\n\n const handlePointerDown = (event: PointerEvent) => {\n pointerDownPositionRef.current = new Point([event.clientX, event.clientY])\n\n setIsPointerDown(true)\n }\n\n const handlePointerUp = (event: PointerEvent) => {\n pointerUpPositionRef.current = new Point([event.clientX, event.clientY])\n\n setIsPointerDown(false)\n }\n\n const handleClick = (event: MouseEvent) => {\n const downPosition = pointerDownPositionRef.current\n const upPosition = pointerUpPositionRef.current\n\n if (!downPosition || !upPosition) return\n\n const threshold = 5\n const delta = downPosition.subtract(upPosition)\n\n if (Math.abs(delta.x) > threshold || Math.abs(delta.y) > threshold) {\n event.stopPropagation()\n }\n\n pointerDownPositionRef.current = undefined\n pointerUpPositionRef.current = undefined\n }\n\n const autoScrollToCurrentIndex = () => {\n const viewportElement = viewportRef.current\n if (!viewportElement) return\n\n const top = orientation === 'horizontal' ? 0 : viewportElement.clientHeight * index\n const left = orientation === 'horizontal' ? viewportElement.clientWidth * index : 0\n\n viewportElement.scrollTo({ top, left, behavior: 'smooth' })\n\n clearTimeout(autoScrollTimeoutRef.current)\n autoScrollTimeoutRef.current = setTimeout(() => {\n clearTimeout(autoScrollTimeoutRef.current)\n autoScrollTimeoutRef.current = undefined\n }, autoScrollTimeoutMs)\n }\n\n const prevIndexRef = useRef<number>()\n const viewportRef = useRef<HTMLDivElement>(null)\n const pointerDownPositionRef = useRef<Point | undefined>()\n const pointerUpPositionRef = useRef<Point | undefined>()\n const [exposures, setExposures] = useState<number[] | undefined>(getItemExposures())\n const autoScrollTimeoutRef = useRef<NodeJS.Timeout>()\n const autoScrollTimeoutMs = 1000\n const [isPointerDown, setIsPointerDown] = useState(false)\n\n useEffect(() => {\n const viewportElement = viewportRef.current\n if (!viewportElement) return\n\n const scrollHandler = () => {\n if (tracksItemExposure) {\n setExposures(getItemExposures())\n }\n\n if (autoScrollTimeoutRef.current !== undefined) return\n\n const newIndex = orientation === 'horizontal'\n ? Math.round(viewportElement.scrollLeft / viewportElement.clientWidth)\n : Math.round(viewportElement.scrollTop / viewportElement.clientHeight)\n\n const clampedIndex = Math.max(0, Math.min(items.length - 1, newIndex))\n\n if (clampedIndex === index) return\n\n // Set previous index ref here to avoid the side-effect of handling index\n // changes from prop/state.\n prevIndexRef.current = clampedIndex\n\n handleIndexChange(clampedIndex)\n }\n\n viewportElement.addEventListener('scroll', scrollHandler)\n\n return () => {\n viewportElement.removeEventListener('scroll', scrollHandler)\n }\n }, [index, orientation])\n\n useEffect(() => {\n const isInitialRender = prevIndexRef.current === undefined\n const isIndexModifiedFromManualScrolling = prevIndexRef.current === index\n\n if (isIndexModifiedFromManualScrolling) return\n\n prevIndexRef.current = index\n\n if (isInitialRender) return\n\n handleIndexChange(index)\n autoScrollToCurrentIndex()\n }, [index, orientation])\n\n useEffect(() => {\n if (autoAdvanceInterval <= 0) return\n\n if (isPointerDown) {\n onAutoAdvancePause?.()\n }\n else {\n onAutoAdvanceResume?.()\n }\n }, [isPointerDown])\n\n useDragEffect(viewportRef, {\n isEnabled: isDragEnabled && items.length > 1,\n onDragMove: (displacement: Point) => {\n switch (orientation) {\n case 'horizontal':\n requestAnimationFrame(() => {\n if (!viewportRef.current) return\n viewportRef.current.scrollLeft += displacement.x * 1.5\n })\n\n break\n case 'vertical':\n requestAnimationFrame(() => {\n if (!viewportRef.current) return\n viewportRef.current.scrollTop += displacement.y * 1.5\n })\n\n break\n default:\n throw Error(`Unsupported orientation '${orientation}'`)\n }\n },\n })\n\n useTimeout(\n () => handleIndexChange((index + items.length + 1) % items.length),\n (isPointerDown || autoAdvanceInterval <= 0) ? -1 : autoAdvanceInterval,\n [isPointerDown, index, items.length],\n )\n\n const fixedStyles = getFixedStyles({ isPointerDown, orientation })\n\n return (\n <div\n {...props}\n ref={ref}\n data-component='carousel'\n style={styles(style, fixedStyles.root)}\n onClick={event => handleClick(event)}\n onPointerDown={event => handlePointerDown(event)}\n onPointerLeave={event => handlePointerUp(event)}\n onPointerUp={event => handlePointerUp(event)}\n >\n <div\n ref={viewportRef}\n data-child='viewport'\n style={styles(fixedStyles.viewport)}\n >\n <Each in={items}>\n {({ style: itemStyle, ...itemProps }, idx) => (\n <div style={styles(fixedStyles.itemContainer)}>\n <ItemComponent\n data-child='item'\n exposure={tracksItemExposure ? exposures?.[idx] : undefined}\n style={styles(itemStyle, fixedStyles.item)}\n {...itemProps as any}\n />\n </div>\n )}\n </Each>\n </div>\n </div>\n )\n}) as <I extends HTMLAttributes<HTMLElement>>(props: CarouselProps<I> & { ref?: ForwardedRef<HTMLDivElement> }) => ReactElement\n\nObject.defineProperty(Carousel, 'displayName', { value: 'Carousel', writable: false })\n\nfunction getFixedStyles({ isPointerDown = false, orientation = 'horizontal' }) {\n return asStyleDict({\n root: {\n },\n viewport: {\n alignItems: 'center',\n display: 'flex',\n height: '100%',\n userSelect: isPointerDown ? 'none' : 'auto',\n justifyContent: 'flex-start',\n scrollBehavior: isPointerDown ? 'auto' : 'smooth',\n scrollSnapStop: isPointerDown ? 'unset' : 'always',\n WebkitOverflowScrolling: 'touch',\n width: '100%',\n ...orientation === 'horizontal' ? {\n flexDirection: 'row',\n overflowX: 'scroll',\n overflowY: 'hidden',\n scrollSnapType: isPointerDown ? 'none' : 'x mandatory',\n } : {\n flexDirection: 'column',\n overflowX: 'hidden',\n overflowY: 'scroll',\n scrollSnapType: isPointerDown ? 'none' : 'y mandatory',\n },\n },\n itemContainer: {\n height: '100%',\n overflow: 'hidden',\n scrollSnapAlign: 'start',\n width: '100%',\n scrollBehavior: 'smooth',\n },\n item: {\n flex: '0 0 auto',\n height: '100%',\n width: '100%',\n },\n })\n}\n"]}
@@ -1,171 +0,0 @@
1
- import { type ComponentType, type HTMLAttributes, type ReactElement, type Ref } from 'react';
2
- /**
3
- * Type describing the layout orientation of items in {@link Collection}.
4
- */
5
- export type CollectionOrientation = 'horizontal' | 'vertical';
6
- /**
7
- * Type describing the layout appearance of {@link Collection}:
8
- * - `list`: Items will be laid out in a list.
9
- * - `grid`: Items will be laid out in a grid.
10
- */
11
- export type CollectionLayout = 'list' | 'grid';
12
- /**
13
- * Type describing the item selection behavior of {@link Collection}:
14
- * - `none`: No selection permitted at all.
15
- * - `single`: Only one item can be selected at a time (the previously
16
- * selected item will be automatically deselected).
17
- * - `multiple`: Multiple items can be selected simultaneously.
18
- */
19
- export type CollectionSelectionMode = 'none' | 'single' | 'multiple';
20
- /**
21
- * Type describing the current item selection of {@link Collection}, composed of
22
- * an array of indices of items that are selected. If the selection mode of the
23
- * {@link Collection} is `single`, only one index is expected in this array.
24
- */
25
- export type CollectionSelection = number[];
26
- /**
27
- * Type describing the props of `ItemComponent` provided to {@link Collection}.
28
- */
29
- export type CollectionItemProps<T> = HTMLAttributes<HTMLElement> & {
30
- /**
31
- * The index of the item.
32
- */
33
- index: number;
34
- /**
35
- * Indicates whether the item is selected.
36
- */
37
- isSelected: boolean;
38
- /**
39
- * Data provided to the item.
40
- */
41
- item: T;
42
- /**
43
- * Orientation of the parent collection.
44
- */
45
- orientation: CollectionOrientation;
46
- /**
47
- * Handler invoked to dispatch a custom event.
48
- *
49
- * @param name User-defined name of the custom event.
50
- * @param info Optional user-defined info of the custom event.
51
- */
52
- onCustomEvent?: (name: string, info?: any) => void;
53
- };
54
- /**
55
- * Type describing the props of {@link Collection}.
56
- */
57
- export type CollectionProps<T> = HTMLAttributes<HTMLDivElement> & {
58
- /**
59
- * Indicates if item selection can be toggled, i.e. they can be deselected if
60
- * selected again.
61
- */
62
- isSelectionTogglable?: boolean;
63
- /**
64
- * Optional length (in pixels) of each item. Length refers to the height in
65
- * vertical orientation and width in horizontal orientation.
66
- */
67
- itemLength?: number;
68
- /**
69
- * Padding between every item (in pixels).
70
- */
71
- itemPadding?: number;
72
- /**
73
- * Generically typed data of each item.
74
- */
75
- items: T[];
76
- /**
77
- * Specifies the layout appearance of this component.
78
- *
79
- * @see {@link CollectionLayout}
80
- */
81
- layout?: CollectionLayout;
82
- /**
83
- * Specifies the number of columns of this collection if the orientation is
84
- * `vertical` or number of rows if the orientation is `horizontal`. This
85
- * property is only used if the layout is set to `grid`.
86
- */
87
- numSegments?: number;
88
- /**
89
- * Orientation of the component.
90
- *
91
- * @see {@link CollectionOrientation}
92
- */
93
- orientation?: CollectionOrientation;
94
- /**
95
- * The selected indices. If `selectionMode` is `single`, only only the first
96
- * value will be used.
97
- *
98
- * @see {@link CollectionSelection}
99
- */
100
- selection?: CollectionSelection;
101
- /**
102
- * The item selection behavior.
103
- *
104
- * @see {@link CollectionSelectionMode}
105
- */
106
- selectionMode?: CollectionSelectionMode;
107
- /**
108
- * Handler invoked when an item is activated (i.e. clicked). The order of
109
- * handlers invoked when any selection changes take place is:
110
- * 1. `onActivateAt`
111
- * 2. `onDeselectAt`
112
- * 3. `onSelectAt`
113
- * 4. `onSelectionChange`
114
- *
115
- * @param index Item index.
116
- */
117
- onActivateAt?: (index: number) => void;
118
- /**
119
- * Handler invoked when an item is deselected. The order of handlers invoked
120
- * when any selection changes take place is:
121
- * 1. `onActivateAt`
122
- * 2. `onDeselectAt`
123
- * 3. `onSelectAt`
124
- * 4. `onSelectionChange`
125
- *
126
- * @param index Item index.
127
- */
128
- onDeselectAt?: (index: number) => void;
129
- /**
130
- * Handler invoked when a custom event is dispatched from the item.
131
- *
132
- * @param index Index of the item.
133
- * @param eventName User-defined name of the dispatched custom event.
134
- * @param eventInfo Optional user-defined info of the dispatched custom event.
135
- */
136
- onItemCustomEvent?: (index: number, eventName: string, eventInfo?: any) => void;
137
- /**
138
- * Handler invoked when an item is selected. The order of handlers invoked
139
- * when any selection changes take place is:
140
- * 1. `onActivateAt`
141
- * 2. `onDeselectAt`
142
- * 3. `onSelectAt`
143
- * 4. `onSelectionChange`
144
- *
145
- * @param index Item index.
146
- */
147
- onSelectAt?: (index: number) => void;
148
- /**
149
- * Handler invoked when the selected items changed. The order of handlers
150
- * invoked when any selection changes take place is:
151
- * 1. `onActivateAt`
152
- * 2. `onDeselectAt`
153
- * 3. `onSelectAt`
154
- * 4. `onSelectionChange`
155
- *
156
- * @param selection Indices of selected items.
157
- */
158
- onSelectionChange?: (selection: CollectionSelection) => void;
159
- /**
160
- * Component type for generating items in this collection.
161
- */
162
- ItemComponent?: ComponentType<CollectionItemProps<T>>;
163
- };
164
- /**
165
- * A collection of selectable items with generic data. Items are generated based
166
- * on the provided `ItemComponent`. This component supports different layouts in
167
- * both horizontal and vertical orientations.
168
- */
169
- export declare const Collection: <T>(props: CollectionProps<T> & {
170
- ref?: Ref<HTMLDivElement>;
171
- }) => ReactElement;