etudes 5.1.0 → 5.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.
Files changed (160) hide show
  1. package/components/Accordion.d.ts +219 -0
  2. package/components/Accordion.js +319 -0
  3. package/components/Accordion.js.map +1 -0
  4. package/components/BurgerButton.d.ts +34 -0
  5. package/components/BurgerButton.js +181 -0
  6. package/components/BurgerButton.js.map +1 -0
  7. package/components/Carousel.d.ts +53 -0
  8. package/components/Carousel.js +230 -0
  9. package/components/Carousel.js.map +1 -0
  10. package/components/Collection.d.ts +171 -0
  11. package/components/Collection.js +182 -0
  12. package/components/Collection.js.map +1 -0
  13. package/components/Counter.d.ts +11 -0
  14. package/components/Counter.js +102 -0
  15. package/components/Counter.js.map +1 -0
  16. package/components/CoverImage.d.ts +28 -0
  17. package/components/CoverImage.js +97 -0
  18. package/components/CoverImage.js.map +1 -0
  19. package/components/CoverVideo.d.ts +28 -0
  20. package/components/CoverVideo.js +98 -0
  21. package/components/CoverVideo.js.map +1 -0
  22. package/components/DebugConsole.d.ts +15 -0
  23. package/components/DebugConsole.js +128 -0
  24. package/components/DebugConsole.js.map +1 -0
  25. package/components/Dial.d.ts +79 -0
  26. package/components/Dial.js +139 -0
  27. package/components/Dial.js.map +1 -0
  28. package/components/Dropdown.d.ts +109 -0
  29. package/components/Dropdown.js +200 -0
  30. package/components/Dropdown.js.map +1 -0
  31. package/components/FlatSVG.d.ts +72 -0
  32. package/components/FlatSVG.js +93 -0
  33. package/components/FlatSVG.js.map +1 -0
  34. package/components/Image.d.ts +144 -0
  35. package/components/Image.js +76 -0
  36. package/components/Image.js.map +1 -0
  37. package/components/MasonryGrid.d.ts +29 -0
  38. package/components/MasonryGrid.js +393 -0
  39. package/components/MasonryGrid.js.map +1 -0
  40. package/components/Panorama.d.ts +77 -0
  41. package/components/Panorama.js +140 -0
  42. package/components/Panorama.js.map +1 -0
  43. package/components/PanoramaSlider.d.ts +71 -0
  44. package/components/PanoramaSlider.js +200 -0
  45. package/components/PanoramaSlider.js.map +1 -0
  46. package/components/RangeSlider.d.ts +34 -0
  47. package/components/RangeSlider.js +297 -0
  48. package/components/RangeSlider.js.map +1 -0
  49. package/components/RotatingGallery.d.ts +91 -0
  50. package/components/RotatingGallery.js +89 -0
  51. package/components/RotatingGallery.js.map +1 -0
  52. package/components/SelectableButton.d.ts +19 -0
  53. package/components/SelectableButton.js +68 -0
  54. package/components/SelectableButton.js.map +1 -0
  55. package/components/Slider.d.ts +160 -0
  56. package/components/Slider.js +274 -0
  57. package/components/Slider.js.map +1 -0
  58. package/components/StepwiseSlider.d.ts +215 -0
  59. package/components/StepwiseSlider.js +355 -0
  60. package/components/StepwiseSlider.js.map +1 -0
  61. package/components/SwipeContainer.d.ts +21 -0
  62. package/components/SwipeContainer.js +110 -0
  63. package/components/SwipeContainer.js.map +1 -0
  64. package/components/TextField.d.ts +21 -0
  65. package/components/TextField.js +57 -0
  66. package/components/TextField.js.map +1 -0
  67. package/components/Video.d.ts +38 -0
  68. package/components/Video.js +95 -0
  69. package/components/Video.js.map +1 -0
  70. package/components/WithTooltip.d.ts +32 -0
  71. package/components/WithTooltip.js +244 -0
  72. package/components/WithTooltip.js.map +1 -0
  73. package/hooks/useClickOutsideEffect.d.ts +2 -0
  74. package/hooks/useClickOutsideEffect.js +57 -0
  75. package/hooks/useClickOutsideEffect.js.map +1 -0
  76. package/hooks/useDragEffect.d.ts +48 -0
  77. package/hooks/useDragEffect.js +98 -0
  78. package/hooks/useDragEffect.js.map +1 -0
  79. package/hooks/useDragValueEffect.d.ts +56 -0
  80. package/hooks/useDragValueEffect.js +135 -0
  81. package/hooks/useDragValueEffect.js.map +1 -0
  82. package/hooks/useImageSize.d.ts +21 -0
  83. package/hooks/useImageSize.js +66 -0
  84. package/hooks/useImageSize.js.map +1 -0
  85. package/hooks/useInterval.d.ts +18 -0
  86. package/hooks/useInterval.js +55 -0
  87. package/hooks/useInterval.js.map +1 -0
  88. package/hooks/useLoadImageEffect.d.ts +43 -0
  89. package/hooks/useLoadImageEffect.js +69 -0
  90. package/hooks/useLoadImageEffect.js.map +1 -0
  91. package/hooks/useLoadVideoMetadataEffect.d.ts +35 -0
  92. package/hooks/useLoadVideoMetadataEffect.js +65 -0
  93. package/hooks/useLoadVideoMetadataEffect.js.map +1 -0
  94. package/hooks/useMounted.d.ts +1 -0
  95. package/hooks/useMounted.js +31 -0
  96. package/hooks/useMounted.js.map +1 -0
  97. package/hooks/usePrevious.d.ts +19 -0
  98. package/hooks/usePrevious.js +19 -0
  99. package/hooks/usePrevious.js.map +1 -0
  100. package/hooks/useRect.d.ts +11 -0
  101. package/hooks/useRect.js +44 -0
  102. package/hooks/useRect.js.map +1 -0
  103. package/hooks/useResizeEffect.d.ts +17 -0
  104. package/hooks/useResizeEffect.js +62 -0
  105. package/hooks/useResizeEffect.js.map +1 -0
  106. package/hooks/useScrollPositionEffect.d.ts +13 -0
  107. package/hooks/useScrollPositionEffect.js +69 -0
  108. package/hooks/useScrollPositionEffect.js.map +1 -0
  109. package/hooks/useSearchParamState.d.ts +34 -0
  110. package/hooks/useSearchParamState.js +76 -0
  111. package/hooks/useSearchParamState.js.map +1 -0
  112. package/hooks/useSize.d.ts +10 -0
  113. package/hooks/useSize.js +43 -0
  114. package/hooks/useSize.js.map +1 -0
  115. package/hooks/useTimeout.d.ts +10 -0
  116. package/hooks/useTimeout.js +51 -0
  117. package/hooks/useTimeout.js.map +1 -0
  118. package/hooks/useVideoSize.d.ts +21 -0
  119. package/hooks/useVideoSize.js +66 -0
  120. package/hooks/useVideoSize.js.map +1 -0
  121. package/hooks/useViewportSize.d.ts +7 -0
  122. package/hooks/useViewportSize.js +40 -0
  123. package/hooks/useViewportSize.js.map +1 -0
  124. package/operators/Conditional.d.ts +5 -0
  125. package/operators/Conditional.js +18 -0
  126. package/operators/Conditional.js.map +1 -0
  127. package/operators/Each.d.ts +7 -0
  128. package/operators/Each.js +18 -0
  129. package/operators/Each.js.map +1 -0
  130. package/operators/ExtractChild.d.ts +8 -0
  131. package/operators/ExtractChild.js +52 -0
  132. package/operators/ExtractChild.js.map +1 -0
  133. package/operators/ExtractChildren.d.ts +6 -0
  134. package/operators/ExtractChildren.js +44 -0
  135. package/operators/ExtractChildren.js.map +1 -0
  136. package/operators/Repeat.d.ts +11 -0
  137. package/operators/Repeat.js +43 -0
  138. package/operators/Repeat.js.map +1 -0
  139. package/package.json +6 -7
  140. package/providers/ScrollPositionProvider.d.ts +15 -0
  141. package/providers/ScrollPositionProvider.js +90 -0
  142. package/providers/ScrollPositionProvider.js.map +1 -0
  143. package/utils/asClassNameDict.d.ts +3 -0
  144. package/utils/asClassNameDict.js +7 -0
  145. package/utils/asClassNameDict.js.map +1 -0
  146. package/utils/asComponentDict.d.ts +5 -0
  147. package/utils/asComponentDict.js +23 -0
  148. package/utils/asComponentDict.js.map +1 -0
  149. package/utils/asStyleDict.d.ts +4 -0
  150. package/utils/asStyleDict.js +7 -0
  151. package/utils/asStyleDict.js.map +1 -0
  152. package/utils/cloneStyledElement.d.ts +18 -0
  153. package/utils/cloneStyledElement.js +62 -0
  154. package/utils/cloneStyledElement.js.map +1 -0
  155. package/utils/index.d.ts +5 -0
  156. package/utils/index.js +22 -0
  157. package/utils/index.js.map +1 -0
  158. package/utils/styles.d.ts +2 -0
  159. package/utils/styles.js +22 -0
  160. package/utils/styles.js.map +1 -0
@@ -0,0 +1,219 @@
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;
@@ -0,0 +1,319 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ var __read = (this && this.__read) || function (o, n) {
25
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
26
+ if (!m) return o;
27
+ var i = m.call(o), r, ar = [], e;
28
+ try {
29
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
30
+ }
31
+ catch (error) { e = { error: error }; }
32
+ finally {
33
+ try {
34
+ if (r && !r.done && (m = i["return"])) m.call(i);
35
+ }
36
+ finally { if (e) throw e.error; }
37
+ }
38
+ return ar;
39
+ };
40
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
41
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
42
+ if (ar || !(i in from)) {
43
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
44
+ ar[i] = from[i];
45
+ }
46
+ }
47
+ return to.concat(ar || Array.prototype.slice.call(from));
48
+ };
49
+ var __importDefault = (this && this.__importDefault) || function (mod) {
50
+ return (mod && mod.__esModule) ? mod : { "default": mod };
51
+ };
52
+ Object.defineProperty(exports, "__esModule", { value: true });
53
+ exports.Accordion = void 0;
54
+ var jsx_runtime_1 = require("react/jsx-runtime");
55
+ var clsx_1 = __importDefault(require("clsx"));
56
+ var react_1 = __importDefault(require("fast-deep-equal/react"));
57
+ var react_2 = require("react");
58
+ var Each_1 = require("../operators/Each");
59
+ var utils_1 = require("../utils");
60
+ var Collection_1 = require("./Collection");
61
+ var FlatSVG_1 = require("./FlatSVG");
62
+ /**
63
+ * A collection of selectable items laid out in sections in an accordion. Items
64
+ * are generated based on the provided `ItemComponent` while each section header
65
+ * is optionally provided by `HeaderComponent` or generated automatically.
66
+ */
67
+ exports.Accordion = (0, react_2.forwardRef)(function (_a, ref) {
68
+ var children = _a.children, style = _a.style, _b = _a.autoCollapseSections, autoCollapseSections = _b === void 0 ? false : _b, collapseIconSvg = _a.collapseIconSvg, externalExpandedSectionIndices = _a.expandedSectionIndices, expandIconSvg = _a.expandIconSvg, _c = _a.orientation, orientation = _c === void 0 ? 'vertical' : _c, _d = _a.sectionPadding, sectionPadding = _d === void 0 ? 0 : _d, sections = _a.sections, externalSelection = _a.selection, _e = _a.selectionMode, selectionMode = _e === void 0 ? 'single' : _e, _f = _a.usesDefaultStyles, usesDefaultStyles = _f === void 0 ? false : _f, onActivateAt = _a.onActivateAt, onCollapseSectionAt = _a.onCollapseSectionAt, onDeselectAt = _a.onDeselectAt, onExpandedSectionsChange = _a.onExpandedSectionsChange, onExpandSectionAt = _a.onExpandSectionAt, onHeaderCustomEvent = _a.onHeaderCustomEvent, onItemCustomEvent = _a.onItemCustomEvent, onSelectAt = _a.onSelectAt, onSelectionChange = _a.onSelectionChange, HeaderComponent = _a.HeaderComponent, ItemComponent = _a.ItemComponent, props = __rest(_a, ["children", "style", "autoCollapseSections", "collapseIconSvg", "expandedSectionIndices", "expandIconSvg", "orientation", "sectionPadding", "sections", "selection", "selectionMode", "usesDefaultStyles", "onActivateAt", "onCollapseSectionAt", "onDeselectAt", "onExpandedSectionsChange", "onExpandSectionAt", "onHeaderCustomEvent", "onItemCustomEvent", "onSelectAt", "onSelectionChange", "HeaderComponent", "ItemComponent"]);
69
+ var isSectionIndexOutOfRange = function (sectionIndex) {
70
+ if (sectionIndex >= sections.length)
71
+ return true;
72
+ if (sectionIndex < 0)
73
+ return true;
74
+ return false;
75
+ };
76
+ var isItemIndexOutOfRange = function (itemIndex, sectionIndex) {
77
+ if (isSectionIndexOutOfRange(sectionIndex))
78
+ return true;
79
+ var items = sections[sectionIndex].items;
80
+ if (itemIndex >= items.length)
81
+ return true;
82
+ if (itemIndex < 0)
83
+ return true;
84
+ return false;
85
+ };
86
+ var isSelectedAt = function (itemIndex, sectionIndex) { var _a, _b; return ((_b = (_a = selection[sectionIndex]) === null || _a === void 0 ? void 0 : _a.indexOf(itemIndex)) !== null && _b !== void 0 ? _b : -1) >= 0; };
87
+ var sanitizeExpandedSectionIndices = function (sectionIndices) { return sortIndices(sectionIndices).filter(function (t) { return !isSectionIndexOutOfRange(t); }); };
88
+ var sanitizeSelection = function (selection) {
89
+ var _a;
90
+ var newValue = {};
91
+ var _loop_1 = function (sectionIndex) {
92
+ if (!Object.hasOwn(sections, sectionIndex))
93
+ return "continue";
94
+ var indices = sortIndices(__spreadArray([], __read((_a = selection[sectionIndex]) !== null && _a !== void 0 ? _a : []), false));
95
+ newValue[Number(sectionIndex)] = sortIndices(indices).filter(function (t) { return !isItemIndexOutOfRange(t, Number(sectionIndex)); });
96
+ };
97
+ for (var sectionIndex in sections) {
98
+ _loop_1(sectionIndex);
99
+ }
100
+ return newValue;
101
+ };
102
+ var isSectionExpandedAt = function (sectionIndex) { return expandedSectionIndices.indexOf(sectionIndex) >= 0; };
103
+ var toggleSectionAt = function (sectionIndex) {
104
+ var transform;
105
+ if (isSectionExpandedAt(sectionIndex)) {
106
+ transform = function (val) { return val.filter(function (t) { return t !== sectionIndex; }); };
107
+ }
108
+ else if (autoCollapseSections) {
109
+ transform = function (val) { return [sectionIndex]; };
110
+ }
111
+ else {
112
+ transform = function (val) { return __spreadArray(__spreadArray([], __read(val.filter(function (t) { return t !== sectionIndex; })), false), [sectionIndex], false); };
113
+ }
114
+ handleExpandedSectionsChange(expandedSectionIndices, transform(expandedSectionIndices));
115
+ };
116
+ var handleSelectAt = function (itemIndex, sectionIndex) {
117
+ if (isSelectedAt(itemIndex, sectionIndex))
118
+ return;
119
+ var transform;
120
+ switch (selectionMode) {
121
+ case 'multiple':
122
+ transform = function (val) {
123
+ var _a;
124
+ var _b;
125
+ return (__assign(__assign({}, val), (_a = {}, _a[sectionIndex] = sortIndices(__spreadArray(__spreadArray([], __read(((_b = val[sectionIndex]) !== null && _b !== void 0 ? _b : []).filter(function (t) { return t !== itemIndex; })), false), [itemIndex], false)), _a)));
126
+ };
127
+ break;
128
+ case 'single':
129
+ transform = function (val) {
130
+ var _a;
131
+ return (_a = {},
132
+ _a[sectionIndex] = [itemIndex],
133
+ _a);
134
+ };
135
+ break;
136
+ default:
137
+ return;
138
+ }
139
+ var newValue = transform(selection);
140
+ prevSelectionRef.current = newValue;
141
+ handleSelectionChange(selection, newValue);
142
+ };
143
+ var handleDeselectAt = function (itemIndex, sectionIndex) {
144
+ if (!isSelectedAt(itemIndex, sectionIndex))
145
+ return;
146
+ var transform = function (val) {
147
+ var _a;
148
+ var _b;
149
+ return (__assign(__assign({}, val), (_a = {}, _a[sectionIndex] = ((_b = val[sectionIndex]) !== null && _b !== void 0 ? _b : []).filter(function (t) { return t !== itemIndex; }), _a)));
150
+ };
151
+ var newValue = transform(selection);
152
+ prevSelectionRef.current = newValue;
153
+ handleSelectionChange(selection, newValue);
154
+ };
155
+ var handleExpandedSectionsChange = function (oldValue, newValue) {
156
+ var _a;
157
+ if ((0, react_1.default)(oldValue, newValue))
158
+ return;
159
+ var collapsed = (_a = oldValue === null || oldValue === void 0 ? void 0 : oldValue.filter(function (t) { return newValue.indexOf(t) === -1; })) !== null && _a !== void 0 ? _a : [];
160
+ var expanded = newValue.filter(function (t) { return (oldValue === null || oldValue === void 0 ? void 0 : oldValue.indexOf(t)) === -1; });
161
+ collapsed.forEach(function (t) { return onCollapseSectionAt === null || onCollapseSectionAt === void 0 ? void 0 : onCollapseSectionAt(t); });
162
+ expanded.forEach(function (t) { return onExpandSectionAt === null || onExpandSectionAt === void 0 ? void 0 : onExpandSectionAt(t); });
163
+ onExpandedSectionsChange === null || onExpandedSectionsChange === void 0 ? void 0 : onExpandedSectionsChange(newValue);
164
+ };
165
+ var handleSelectionChange = function (oldValue, newValue) {
166
+ var _a, _b;
167
+ if ((0, react_1.default)(oldValue, newValue))
168
+ return;
169
+ var numSections = sections.length;
170
+ var allDeselected = [];
171
+ var allSelected = [];
172
+ var _loop_2 = function (i) {
173
+ var oldSection = (_a = oldValue === null || oldValue === void 0 ? void 0 : oldValue[i]) !== null && _a !== void 0 ? _a : [];
174
+ var newSection = (_b = newValue[i]) !== null && _b !== void 0 ? _b : [];
175
+ var deselected = oldSection.filter(function (t) { return newSection.indexOf(t) === -1; });
176
+ var selected = newSection.filter(function (t) { return (oldSection === null || oldSection === void 0 ? void 0 : oldSection.indexOf(t)) === -1; });
177
+ allDeselected = __spreadArray(__spreadArray([], __read(allDeselected), false), __read(deselected.map(function (t) { return [t, i]; })), false);
178
+ allSelected = __spreadArray(__spreadArray([], __read(allSelected), false), __read(selected.map(function (t) { return [t, i]; })), false);
179
+ };
180
+ for (var i = 0; i < numSections; i++) {
181
+ _loop_2(i);
182
+ }
183
+ allDeselected.forEach(function (t) { return onDeselectAt === null || onDeselectAt === void 0 ? void 0 : onDeselectAt(t[0], t[1]); });
184
+ allSelected.forEach(function (t) { return onSelectAt === null || onSelectAt === void 0 ? void 0 : onSelectAt(t[0], t[1]); });
185
+ onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(newValue);
186
+ };
187
+ var selection = sanitizeSelection(externalSelection !== null && externalSelection !== void 0 ? externalSelection : {});
188
+ var expandedSectionIndices = sanitizeExpandedSectionIndices(externalExpandedSectionIndices !== null && externalExpandedSectionIndices !== void 0 ? externalExpandedSectionIndices : []);
189
+ var fixedStyles = getFixedStyles({ orientation: orientation });
190
+ var defaultStyles = usesDefaultStyles ? getDefaultStyles({ orientation: orientation }) : undefined;
191
+ var prevSelectionRef = (0, react_2.useRef)();
192
+ var prevSelection = prevSelectionRef.current;
193
+ (0, react_2.useEffect)(function () {
194
+ prevSelectionRef.current = selection;
195
+ if (prevSelection === undefined)
196
+ return;
197
+ handleSelectionChange(prevSelection, selection);
198
+ }, [JSON.stringify(selection)]);
199
+ return ((0, jsx_runtime_1.jsx)("div", __assign({}, props, { ref: ref, "data-component": 'accordion', style: (0, utils_1.styles)(style, fixedStyles.root), children: (0, jsx_runtime_1.jsx)(Each_1.Each, { in: sections, children: function (section, sectionIndex) {
200
+ var _a;
201
+ var _b = section.collectionPadding, collectionPadding = _b === void 0 ? 0 : _b, items = section.items, _c = section.itemLength, itemLength = _c === void 0 ? 50 : _c, _d = section.itemPadding, itemPadding = _d === void 0 ? 0 : _d, isSelectionTogglable = section.isSelectionTogglable, _e = section.layout, layout = _e === void 0 ? 'list' : _e, _f = section.maxVisible, maxVisible = _f === void 0 ? -1 : _f, _g = section.numSegments, numSegments = _g === void 0 ? 1 : _g;
202
+ var allVisible = layout === 'list' ? items.length : Math.ceil(items.length / numSegments);
203
+ var numVisible = maxVisible < 0 ? allVisible : Math.min(allVisible, maxVisible);
204
+ var maxLength = itemLength * numVisible + itemPadding * (numVisible - 1);
205
+ var isCollapsed = !isSectionExpandedAt(sectionIndex);
206
+ var expandIconComponent = expandIconSvg ? (0, jsx_runtime_1.jsx)(FlatSVG_1.FlatSVG, { style: defaultStyles === null || defaultStyles === void 0 ? void 0 : defaultStyles.expandIcon, svg: expandIconSvg }) : (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
207
+ var collapseIconComponent = collapseIconSvg ? (0, jsx_runtime_1.jsx)(FlatSVG_1.FlatSVG, { style: defaultStyles === null || defaultStyles === void 0 ? void 0 : defaultStyles.collapseIcon, svg: collapseIconSvg }) : expandIconComponent;
208
+ return ((0, jsx_runtime_1.jsxs)("div", { style: (0, utils_1.styles)(fixedStyles.section, orientation === 'vertical' ? {
209
+ marginTop: sectionIndex === 0 ? '0px' : "".concat(sectionPadding, "px"),
210
+ } : {
211
+ marginLeft: sectionIndex === 0 ? '0px' : "".concat(sectionPadding, "px"),
212
+ }), children: [HeaderComponent ? ((0, jsx_runtime_1.jsx)(HeaderComponent, { className: (0, clsx_1.default)({ collapsed: isCollapsed, expanded: !isCollapsed }), "data-child": 'header', index: sectionIndex, isCollapsed: isCollapsed, section: section, style: (0, utils_1.styles)(fixedStyles.header), onClick: function () { return toggleSectionAt(sectionIndex); }, onCustomEvent: function (name, info) { return onHeaderCustomEvent === null || onHeaderCustomEvent === void 0 ? void 0 : onHeaderCustomEvent(sectionIndex, name, info); } })) : ((0, jsx_runtime_1.jsxs)("button", { className: (0, clsx_1.default)({ collapsed: isCollapsed, expanded: !isCollapsed }), "data-child": 'header', style: (0, utils_1.styles)(fixedStyles.header, defaultStyles === null || defaultStyles === void 0 ? void 0 : defaultStyles.header), onClick: function () { return toggleSectionAt(sectionIndex); }, children: [(0, jsx_runtime_1.jsx)("span", { dangerouslySetInnerHTML: { __html: section.label }, style: (0, utils_1.styles)(defaultStyles === null || defaultStyles === void 0 ? void 0 : defaultStyles.headerLabel) }), (0, utils_1.cloneStyledElement)(isCollapsed ? expandIconComponent : collapseIconComponent, {
213
+ style: (0, utils_1.styles)(isCollapsed ? fixedStyles.expandIcon : fixedStyles.collapseIcon),
214
+ })] })), (0, jsx_runtime_1.jsx)(Collection_1.Collection, { className: (0, clsx_1.default)({ collapsed: isCollapsed, expanded: !isCollapsed }), "data-child": 'collection', isSelectionTogglable: isSelectionTogglable, ItemComponent: ItemComponent, itemLength: itemLength, itemPadding: itemPadding, items: items, layout: layout, numSegments: numSegments, orientation: orientation, selection: (_a = selection[sectionIndex]) !== null && _a !== void 0 ? _a : [], selectionMode: selectionMode, style: (0, utils_1.styles)(fixedStyles.list, defaultStyles === null || defaultStyles === void 0 ? void 0 : defaultStyles.collection, orientation === 'vertical' ? {
215
+ width: '100%',
216
+ height: isCollapsed ? '0px' : "".concat(maxLength, "px"),
217
+ marginTop: isCollapsed ? '0px' : "".concat(collectionPadding, "px"),
218
+ overflowY: maxVisible < 0 || maxVisible >= allVisible ? 'hidden' : 'scroll',
219
+ } : {
220
+ marginLeft: isCollapsed ? '0px' : "".concat(collectionPadding, "px"),
221
+ overflowX: maxVisible < 0 || maxVisible >= allVisible ? 'hidden' : 'scroll',
222
+ width: isCollapsed ? '0px' : "".concat(maxLength, "px"),
223
+ height: '100%',
224
+ }), onActivateAt: function (itemIndex) {
225
+ onActivateAt === null || onActivateAt === void 0 ? void 0 : onActivateAt(itemIndex, sectionIndex);
226
+ }, onDeselectAt: function (itemIndex) {
227
+ handleDeselectAt === null || handleDeselectAt === void 0 ? void 0 : handleDeselectAt(itemIndex, sectionIndex);
228
+ }, onItemCustomEvent: function (itemIndex, name, info) {
229
+ onItemCustomEvent === null || onItemCustomEvent === void 0 ? void 0 : onItemCustomEvent(itemIndex, sectionIndex, name, info);
230
+ }, onSelectAt: function (itemIndex) {
231
+ handleSelectAt === null || handleSelectAt === void 0 ? void 0 : handleSelectAt(itemIndex, sectionIndex);
232
+ } })] }));
233
+ } }) })));
234
+ });
235
+ Object.defineProperty(exports.Accordion, 'displayName', { value: 'Accordion', writable: false });
236
+ function sortIndices(indices) {
237
+ return indices.sort(function (a, b) { return a - b; });
238
+ }
239
+ function getFixedStyles(_a) {
240
+ var _b = _a.orientation, orientation = _b === void 0 ? 'vertical' : _b;
241
+ return (0, utils_1.asStyleDict)({
242
+ root: __assign({ alignItems: 'center', boxSizing: 'border-box', display: 'flex', flex: '0 0 auto', justifyContent: 'flex-start', padding: '0' }, orientation === 'vertical' ? {
243
+ flexDirection: 'column',
244
+ height: 'auto',
245
+ } : {
246
+ flexDirection: 'row',
247
+ width: 'auto',
248
+ }),
249
+ section: __assign({ alignItems: 'flex-start', display: 'flex', flex: '0 0 auto', justifyContent: 'flex-start', margin: '0', padding: '0' }, orientation === 'vertical' ? {
250
+ flexDirection: 'column',
251
+ width: '100%',
252
+ } : {
253
+ flexDirection: 'row',
254
+ height: '100%',
255
+ }),
256
+ list: {},
257
+ header: __assign({ cursor: 'pointer', margin: '0' }, orientation === 'vertical' ? {
258
+ width: '100%',
259
+ } : {
260
+ height: '100%',
261
+ }),
262
+ expandIcon: {
263
+ margin: '0',
264
+ padding: '0',
265
+ },
266
+ collapseIcon: {
267
+ margin: '0',
268
+ padding: '0',
269
+ },
270
+ });
271
+ }
272
+ function getDefaultStyles(_a) {
273
+ var _b = _a.orientation, orientation = _b === void 0 ? 'vertical' : _b;
274
+ return (0, utils_1.asStyleDict)({
275
+ collection: __assign({ transitionDuration: '100ms', transitionTimingFunction: 'ease-out' }, orientation === 'vertical' ? {
276
+ transitionProperty: 'height, margin',
277
+ } : {
278
+ transitionProperty: 'width, margin',
279
+ }),
280
+ header: __assign({ border: 'none', outline: 'none', alignItems: 'center', background: '#fff', boxSizing: 'border-box', display: 'flex', flexDirection: 'row', justifyContent: 'space-between', padding: '0 10px', transitionDuration: '100ms', transitionProperty: 'transform, opacity, background, color', transitionTimingFunction: 'ease-out' }, orientation === 'vertical' ? {
281
+ height: '50px',
282
+ } : {
283
+ width: '50px',
284
+ }),
285
+ headerLabel: {
286
+ color: 'inherit',
287
+ fontFamily: 'inherit',
288
+ fontSize: 'inherit',
289
+ fontWeight: 'inherit',
290
+ letterSpacing: 'inherit',
291
+ lineHeight: 'inherit',
292
+ pointerEvents: 'none',
293
+ transition: 'inherit',
294
+ },
295
+ expandIcon: {
296
+ boxSizing: 'border-box',
297
+ display: 'block',
298
+ fill: '#000',
299
+ height: '15px',
300
+ transformOrigin: 'center',
301
+ transitionDuration: '100ms',
302
+ transitionProperty: 'transform',
303
+ transitionTimingFunction: 'ease-out',
304
+ width: '15px',
305
+ },
306
+ collapseIcon: {
307
+ boxSizing: 'border-box',
308
+ display: 'block',
309
+ fill: '#000',
310
+ height: '15px',
311
+ transformOrigin: 'center',
312
+ transitionDuration: '100ms',
313
+ transitionProperty: 'transform',
314
+ transitionTimingFunction: 'ease-out',
315
+ width: '15px',
316
+ },
317
+ });
318
+ }
319
+ //# sourceMappingURL=Accordion.js.map
@@ -0,0 +1 @@
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,iB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EAAE,UAAU;YACpC,KAAK,EAAE,MAAM;SACd;QACD,YAAY,EAAE;YACZ,SAAS,EAAE,YAAY;YACvB,OAAO,EAAE,OAAO;YAChB,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,MAAM;YACd,eAAe,EAAE,QAAQ;YACzB,kBAAkB,EAAE,OAAO;YAC3B,kBAAkB,EAAE,WAAW;YAC/B,wBAAwB,EAAE,UAAU;YACpC,KAAK,EAAE,MAAM;SACd;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import clsx from 'clsx'\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"]}
@@ -0,0 +1,34 @@
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;