etudes 4.0.0-rc.8 → 5.0.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.
- package/{lib → components}/Accordion.d.ts +5 -164
- package/{lib → components}/Accordion.js +35 -50
- package/components/Accordion.js.map +1 -0
- package/{lib → components}/BurgerButton.d.ts +2 -0
- package/{lib → components}/BurgerButton.js +33 -26
- package/components/BurgerButton.js.map +1 -0
- package/components/Carousel.d.ts +53 -0
- package/components/Carousel.js +255 -0
- package/components/Carousel.js.map +1 -0
- package/{lib → components}/Collection.d.ts +4 -117
- package/{lib → components}/Collection.js +16 -30
- package/components/Collection.js.map +1 -0
- package/components/Counter.d.ts +11 -0
- package/components/Counter.js +127 -0
- package/components/Counter.js.map +1 -0
- package/components/CoverImage.d.ts +28 -0
- package/components/CoverImage.js +122 -0
- package/components/CoverImage.js.map +1 -0
- package/components/CoverVideo.d.ts +28 -0
- package/components/CoverVideo.js +123 -0
- package/components/CoverVideo.js.map +1 -0
- package/{lib → components}/DebugConsole.js +3 -3
- package/components/DebugConsole.js.map +1 -0
- package/{lib → components}/Dial.d.ts +12 -8
- package/{lib → components}/Dial.js +55 -48
- package/components/Dial.js.map +1 -0
- package/components/Dropdown.d.ts +109 -0
- package/{lib → components}/Dropdown.js +18 -78
- package/components/Dropdown.js.map +1 -0
- package/{lib → components}/FlatSVG.d.ts +10 -10
- package/{lib → components}/FlatSVG.js +5 -5
- package/components/FlatSVG.js.map +1 -0
- package/components/Image.d.ts +144 -0
- package/components/Image.js +98 -0
- package/components/Image.js.map +1 -0
- package/{lib → components}/MasonryGrid.d.ts +3 -10
- package/{lib → components}/MasonryGrid.js +154 -78
- package/components/MasonryGrid.js.map +1 -0
- package/components/Panorama.d.ts +77 -0
- package/{lib → components}/Panorama.js +32 -26
- package/components/Panorama.js.map +1 -0
- package/{lib → components}/PanoramaSlider.d.ts +14 -25
- package/{lib → components}/PanoramaSlider.js +79 -91
- package/components/PanoramaSlider.js.map +1 -0
- package/{lib → components}/RangeSlider.d.ts +7 -5
- package/{lib → components}/RangeSlider.js +100 -104
- package/components/RangeSlider.js.map +1 -0
- package/{lib → components}/RotatingGallery.d.ts +2 -5
- package/{lib → components}/RotatingGallery.js +12 -38
- package/components/RotatingGallery.js.map +1 -0
- package/{lib → components}/SelectableButton.js +1 -1
- package/components/SelectableButton.js.map +1 -0
- package/{lib → components}/Slider.d.ts +8 -0
- package/{lib → components}/Slider.js +73 -61
- package/components/Slider.js.map +1 -0
- package/{lib → components}/StepwiseSlider.d.ts +8 -0
- package/{lib → components}/StepwiseSlider.js +122 -112
- package/components/StepwiseSlider.js.map +1 -0
- package/{lib → components}/SwipeContainer.js +2 -2
- package/components/SwipeContainer.js.map +1 -0
- package/{lib → components}/TextField.d.ts +3 -1
- package/{lib → components}/TextField.js +5 -34
- package/components/TextField.js.map +1 -0
- package/components/Video.d.ts +38 -0
- package/{lib → components}/Video.js +32 -36
- package/components/Video.js.map +1 -0
- package/{lib → components}/WithTooltip.d.ts +0 -5
- package/{lib → components}/WithTooltip.js +29 -25
- package/components/WithTooltip.js.map +1 -0
- package/hooks/useClickOutsideEffect.d.ts +2 -0
- package/{lib/hooks → hooks}/useClickOutsideEffect.js +4 -3
- package/hooks/useClickOutsideEffect.js.map +1 -0
- package/hooks/useDragEffect.d.ts +48 -0
- package/hooks/useDragEffect.js +99 -0
- package/hooks/useDragEffect.js.map +1 -0
- package/{lib/hooks/useDragEffect.d.ts → hooks/useDragValueEffect.d.ts} +1 -1
- package/{lib/hooks/useDragEffect.js → hooks/useDragValueEffect.js} +7 -7
- package/hooks/useDragValueEffect.js.map +1 -0
- package/hooks/useImageSize.d.ts +21 -0
- package/hooks/useImageSize.js +67 -0
- package/hooks/useImageSize.js.map +1 -0
- package/{lib/hooks → hooks}/useInterval.d.ts +2 -2
- package/{lib/hooks → hooks}/useInterval.js +6 -5
- package/hooks/useInterval.js.map +1 -0
- package/hooks/useLoadImageEffect.d.ts +43 -0
- package/{lib/hooks → hooks}/useLoadImageEffect.js +18 -32
- package/hooks/useLoadImageEffect.js.map +1 -0
- package/hooks/useLoadVideoMetadataEffect.d.ts +35 -0
- package/hooks/useLoadVideoMetadataEffect.js +66 -0
- package/hooks/useLoadVideoMetadataEffect.js.map +1 -0
- package/{lib/hooks/useElementRect.d.ts → hooks/useRect.d.ts} +2 -2
- package/hooks/useRect.js +45 -0
- package/hooks/useRect.js.map +1 -0
- package/hooks/useResizeEffect.d.ts +17 -0
- package/{lib/hooks → hooks}/useResizeEffect.js +5 -12
- package/hooks/useResizeEffect.js.map +1 -0
- package/hooks/useScrollPositionEffect.d.ts +13 -0
- package/hooks/useScrollPositionEffect.js +70 -0
- package/hooks/useScrollPositionEffect.js.map +1 -0
- package/{lib/hooks → hooks}/useSearchParamState.js +0 -4
- package/hooks/useSearchParamState.js.map +1 -0
- package/hooks/useSize.d.ts +10 -0
- package/hooks/useSize.js +44 -0
- package/hooks/useSize.js.map +1 -0
- package/hooks/useTimeout.d.ts +10 -0
- package/hooks/useTimeout.js +52 -0
- package/hooks/useTimeout.js.map +1 -0
- package/hooks/useVideoSize.d.ts +21 -0
- package/hooks/useVideoSize.js +67 -0
- package/hooks/useVideoSize.js.map +1 -0
- package/operators/Conditional.js.map +1 -0
- package/{lib → operators}/Each.d.ts +1 -1
- package/{lib → operators}/Each.js +4 -1
- package/operators/Each.js.map +1 -0
- package/{lib → operators}/ExtractChild.js +1 -1
- package/operators/ExtractChild.js.map +1 -0
- package/{lib → operators}/ExtractChildren.d.ts +1 -1
- package/{lib → operators}/ExtractChildren.js +1 -1
- package/operators/ExtractChildren.js.map +1 -0
- package/{lib → operators}/Repeat.d.ts +1 -1
- package/{lib → operators}/Repeat.js +4 -1
- package/operators/Repeat.js.map +1 -0
- package/package.json +44 -40
- package/{lib/providers → providers}/ScrollPositionProvider.d.ts +1 -1
- package/providers/ScrollPositionProvider.js.map +1 -0
- package/utils/cloneStyledElement.js.map +1 -0
- package/{lib/utils → utils}/index.d.ts +0 -1
- package/{lib/utils → utils}/index.js +0 -1
- package/utils/index.js.map +1 -0
- package/lib/Accordion.js.map +0 -1
- package/lib/BurgerButton.js.map +0 -1
- package/lib/Carousel.d.ts +0 -22
- package/lib/Carousel.js +0 -171
- package/lib/Carousel.js.map +0 -1
- package/lib/Collection.js.map +0 -1
- package/lib/Conditional.js.map +0 -1
- package/lib/DebugConsole.js.map +0 -1
- package/lib/Dial.js.map +0 -1
- package/lib/Dropdown.d.ts +0 -196
- package/lib/Dropdown.js.map +0 -1
- package/lib/Each.js.map +0 -1
- package/lib/ExtractChild.js.map +0 -1
- package/lib/ExtractChildren.js.map +0 -1
- package/lib/FlatSVG.js.map +0 -1
- package/lib/Image.d.ts +0 -18
- package/lib/Image.js +0 -87
- package/lib/Image.js.map +0 -1
- package/lib/MasonryGrid.js.map +0 -1
- package/lib/Panorama.d.ts +0 -160
- package/lib/Panorama.js.map +0 -1
- package/lib/PanoramaSlider.js.map +0 -1
- package/lib/RangeSlider.js.map +0 -1
- package/lib/Repeat.js.map +0 -1
- package/lib/RotatingGallery.js.map +0 -1
- package/lib/SelectableButton.js.map +0 -1
- package/lib/Slider.js.map +0 -1
- package/lib/StepwiseSlider.js.map +0 -1
- package/lib/SwipeContainer.js.map +0 -1
- package/lib/TextField.js.map +0 -1
- package/lib/Video.d.ts +0 -31
- package/lib/Video.js.map +0 -1
- package/lib/WithTooltip.js.map +0 -1
- package/lib/hooks/useClickOutsideEffect.d.ts +0 -2
- package/lib/hooks/useClickOutsideEffect.js.map +0 -1
- package/lib/hooks/useDragEffect.js.map +0 -1
- package/lib/hooks/useElementRect.js +0 -65
- package/lib/hooks/useElementRect.js.map +0 -1
- package/lib/hooks/useInterval.js.map +0 -1
- package/lib/hooks/useLoadImageEffect.d.ts +0 -44
- package/lib/hooks/useLoadImageEffect.js.map +0 -1
- package/lib/hooks/useResizeEffect.d.ts +0 -22
- package/lib/hooks/useResizeEffect.js.map +0 -1
- package/lib/hooks/useSearchParamState.js.map +0 -1
- package/lib/providers/ScrollPositionProvider.js.map +0 -1
- package/lib/utils/cloneStyledElement.js.map +0 -1
- package/lib/utils/index.js.map +0 -1
- package/lib/utils/useDebug.d.ts +0 -2
- package/lib/utils/useDebug.js +0 -47
- package/lib/utils/useDebug.js.map +0 -1
- /package/{lib → components}/DebugConsole.d.ts +0 -0
- /package/{lib → components}/SelectableButton.d.ts +0 -0
- /package/{lib → components}/SwipeContainer.d.ts +0 -0
- /package/{lib/hooks → hooks}/useMounted.d.ts +0 -0
- /package/{lib/hooks → hooks}/useMounted.js +0 -0
- /package/{lib/hooks → hooks}/useMounted.js.map +0 -0
- /package/{lib/hooks → hooks}/usePrevious.d.ts +0 -0
- /package/{lib/hooks → hooks}/usePrevious.js +0 -0
- /package/{lib/hooks → hooks}/usePrevious.js.map +0 -0
- /package/{lib/hooks → hooks}/useSearchParamState.d.ts +0 -0
- /package/{lib/hooks → hooks}/useViewportSize.d.ts +0 -0
- /package/{lib/hooks → hooks}/useViewportSize.js +0 -0
- /package/{lib/hooks → hooks}/useViewportSize.js.map +0 -0
- /package/{lib → operators}/Conditional.d.ts +0 -0
- /package/{lib → operators}/Conditional.js +0 -0
- /package/{lib → operators}/ExtractChild.d.ts +0 -0
- /package/{lib/providers → providers}/ScrollPositionProvider.js +0 -0
- /package/{lib/utils → utils}/asClassNameDict.d.ts +0 -0
- /package/{lib/utils → utils}/asClassNameDict.js +0 -0
- /package/{lib/utils → utils}/asClassNameDict.js.map +0 -0
- /package/{lib/utils → utils}/asComponentDict.d.ts +0 -0
- /package/{lib/utils → utils}/asComponentDict.js +0 -0
- /package/{lib/utils → utils}/asComponentDict.js.map +0 -0
- /package/{lib/utils → utils}/asStyleDict.d.ts +0 -0
- /package/{lib/utils → utils}/asStyleDict.js +0 -0
- /package/{lib/utils → utils}/asStyleDict.js.map +0 -0
- /package/{lib/utils → utils}/cloneStyledElement.d.ts +0 -0
- /package/{lib/utils → utils}/cloneStyledElement.js +0 -0
- /package/{lib/utils → utils}/styles.d.ts +0 -0
- /package/{lib/utils → utils}/styles.js +0 -0
- /package/{lib/utils → utils}/styles.js.map +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type ComponentType, type HTMLAttributes, type PropsWithChildren, type ReactElement, type Ref } from 'react';
|
|
2
2
|
import { type CollectionItemProps, type CollectionOrientation, type CollectionProps, type CollectionSelectionMode } from './Collection';
|
|
3
3
|
/**
|
|
4
4
|
* Type describing the current item selection of {@link Accordion}, composed of
|
|
@@ -96,8 +96,7 @@ export type AccordionProps<I, S extends AccordionSection<I> = AccordionSection<I
|
|
|
96
96
|
*/
|
|
97
97
|
sections: S[];
|
|
98
98
|
/**
|
|
99
|
-
* Indices of selected items per section.
|
|
100
|
-
* manage selection state.
|
|
99
|
+
* Indices of selected items per section.
|
|
101
100
|
*
|
|
102
101
|
* @see {@link AccordionSelection}
|
|
103
102
|
*/
|
|
@@ -111,7 +110,7 @@ export type AccordionProps<I, S extends AccordionSection<I> = AccordionSection<I
|
|
|
111
110
|
/**
|
|
112
111
|
* Specifies if the component should use default styles.
|
|
113
112
|
*/
|
|
114
|
-
|
|
113
|
+
usesDefaultStyles?: boolean;
|
|
115
114
|
/**
|
|
116
115
|
* Handler invoked when an item is activated in a section. The order of
|
|
117
116
|
* handlers invoked when any selection changes take place is:
|
|
@@ -214,165 +213,7 @@ export type AccordionProps<I, S extends AccordionSection<I> = AccordionSection<I
|
|
|
214
213
|
* A collection of selectable items laid out in sections in an accordion. Items
|
|
215
214
|
* are generated based on the provided `ItemComponent` while each section header
|
|
216
215
|
* is optionally provided by `HeaderComponent` or generated automatically.
|
|
217
|
-
*
|
|
218
|
-
* This component automatically determines if it should track selection state
|
|
219
|
-
* and expansion states internally. If the `selection` prop is provided, the
|
|
220
|
-
* component will not initialize the selection state. It will be up to its
|
|
221
|
-
* parent to provide item selection in tandem with the component's
|
|
222
|
-
* `onSelectionChange` handler. Likewise for the omission of the expansion
|
|
223
|
-
* states if `expandedSectionIndices` prop is provided.
|
|
224
216
|
*/
|
|
225
|
-
export declare const Accordion: <I, S extends AccordionSection<I> = AccordionSection<I>>(props:
|
|
226
|
-
|
|
227
|
-
* Specifies if expanded sections should automatically collapse upon expanding
|
|
228
|
-
* another section.
|
|
229
|
-
*/
|
|
230
|
-
autoCollapseSections?: boolean | undefined;
|
|
231
|
-
/**
|
|
232
|
-
* SVG markup to use as the collapse icon when a toggle button is
|
|
233
|
-
* automatically generated (when `HeaderComponent` is absent).
|
|
234
|
-
*/
|
|
235
|
-
collapseIconSvg?: string | undefined;
|
|
236
|
-
/**
|
|
237
|
-
* Indices of sections that are expanded. If specified, the component will not
|
|
238
|
-
* manage expansion states.
|
|
239
|
-
*/
|
|
240
|
-
expandedSectionIndices?: number[] | undefined;
|
|
241
|
-
/**
|
|
242
|
-
* SVG markup to use as the expand icon when a toggle button is automatically
|
|
243
|
-
* generated (when `HeaderComponent` is absent).
|
|
244
|
-
*/
|
|
245
|
-
expandIconSvg?: string | undefined;
|
|
246
|
-
/**
|
|
247
|
-
* Orientation of this component.
|
|
248
|
-
*
|
|
249
|
-
* @see {@link CollectionOrientation}
|
|
250
|
-
*/
|
|
251
|
-
orientation?: CollectionOrientation | undefined;
|
|
252
|
-
/**
|
|
253
|
-
* Padding (in pixels) between each section.
|
|
254
|
-
*/
|
|
255
|
-
sectionPadding?: number | undefined;
|
|
256
|
-
/**
|
|
257
|
-
* Data provided to each section.
|
|
258
|
-
*/
|
|
259
|
-
sections: S[];
|
|
260
|
-
/**
|
|
261
|
-
* Indices of selected items per section. If specified, the component will not
|
|
262
|
-
* manage selection state.
|
|
263
|
-
*
|
|
264
|
-
* @see {@link AccordionSelection}
|
|
265
|
-
*/
|
|
266
|
-
selection?: AccordionSelection | undefined;
|
|
267
|
-
/**
|
|
268
|
-
* Selection mode of each section.
|
|
269
|
-
*
|
|
270
|
-
* @see {@link CollectionSelectionMode}
|
|
271
|
-
*/
|
|
272
|
-
selectionMode?: CollectionSelectionMode | undefined;
|
|
273
|
-
/**
|
|
274
|
-
* Specifies if the component should use default styles.
|
|
275
|
-
*/
|
|
276
|
-
useDefaultStyles?: boolean | undefined;
|
|
277
|
-
/**
|
|
278
|
-
* Handler invoked when an item is activated in a section. The order of
|
|
279
|
-
* handlers invoked when any selection changes take place is:
|
|
280
|
-
* 1. `onActivateAt`
|
|
281
|
-
* 2. `onDeselectAt`
|
|
282
|
-
* 3. `onSelectAt`
|
|
283
|
-
* 4. `onSelectionChange`
|
|
284
|
-
*
|
|
285
|
-
* @param itemIndex Item index.
|
|
286
|
-
* @param sectionIndex Section index.
|
|
287
|
-
*/
|
|
288
|
-
onActivateAt?: ((itemIndex: number, sectionIndex: number) => void) | undefined;
|
|
289
|
-
/**
|
|
290
|
-
* Handler invoked when a section is collapsed. The order of handlers invoked
|
|
291
|
-
* when any section expansion changes take place is:
|
|
292
|
-
* 1. `onCollapseSectionAt`
|
|
293
|
-
* 2. `onExpandSectionAt`
|
|
294
|
-
*
|
|
295
|
-
* @param sectionIndex Section index.
|
|
296
|
-
*/
|
|
297
|
-
onCollapseSectionAt?: ((sectionIndex: number) => void) | undefined;
|
|
298
|
-
/**
|
|
299
|
-
* Handler invoked when an item is deselected in a section. The order of
|
|
300
|
-
* handlers invoked when any selection changes take place is:
|
|
301
|
-
* 1. `onActivateAt`
|
|
302
|
-
* 2. `onDeselectAt`
|
|
303
|
-
* 3. `onSelectAt`
|
|
304
|
-
* 4. `onSelectionChange`
|
|
305
|
-
*
|
|
306
|
-
* @param itemIndex Item index.
|
|
307
|
-
* @param sectionIndex Section index.
|
|
308
|
-
*/
|
|
309
|
-
onDeselectAt?: ((itemIndex: number, sectionIndex: number) => void) | undefined;
|
|
310
|
-
/**
|
|
311
|
-
* Handler invoked when the expansion state of any section changes.
|
|
312
|
-
*
|
|
313
|
-
* @param expandedSectionIndices Indices of sections that are expanded.
|
|
314
|
-
*/
|
|
315
|
-
onExpandedSectionsChange?: ((expandedSectionIndices: number[]) => void) | undefined;
|
|
316
|
-
/**
|
|
317
|
-
* Handler invoked when a section is expanded. The order of handlers invoked
|
|
318
|
-
* when any section expansion changes take place is:
|
|
319
|
-
* 1. `onCollapseSectionAt`
|
|
320
|
-
* 2. `onExpandSectionAt`
|
|
321
|
-
*
|
|
322
|
-
* @param sectionIndex Section index.
|
|
323
|
-
*/
|
|
324
|
-
onExpandSectionAt?: ((sectionIndex: number) => void) | undefined;
|
|
325
|
-
/**
|
|
326
|
-
* Handler invoked when a custom event is dispatched from a section header.
|
|
327
|
-
*
|
|
328
|
-
* @param sectionIndex Index of the section which the header belongs.
|
|
329
|
-
* @param eventName User-defined name of the dispatched event.
|
|
330
|
-
* @param eventInfo Optional user-defined info of the dispatched event.
|
|
331
|
-
*/
|
|
332
|
-
onHeaderCustomEvent?: ((sectionIndex: number, eventName: string, eventInfo?: any) => void) | undefined;
|
|
333
|
-
/**
|
|
334
|
-
* Handler invoked when a custom event is dispatched from an item.
|
|
335
|
-
*
|
|
336
|
-
* @param itemIndex Item index.
|
|
337
|
-
* @param sectionIndex Section index.
|
|
338
|
-
* @param eventName User-defined name of the dispatched event.
|
|
339
|
-
* @param eventInfo Optional user-defined info of the dispatched event.
|
|
340
|
-
*/
|
|
341
|
-
onItemCustomEvent?: ((itemIndex: number, sectionIndex: number, eventName: string, eventInfo?: any) => void) | undefined;
|
|
342
|
-
/**
|
|
343
|
-
* Handler invoked when an item is selected in a section. The order of
|
|
344
|
-
* handlers invoked when any selection changes take place is:
|
|
345
|
-
* 1. `onActivateAt`
|
|
346
|
-
* 2. `onDeselectAt`
|
|
347
|
-
* 3. `onSelectAt`
|
|
348
|
-
* 4. `onSelectionChange`
|
|
349
|
-
*
|
|
350
|
-
* @param itemIndex Item index.
|
|
351
|
-
* @param sectionIndex Section index.
|
|
352
|
-
*/
|
|
353
|
-
onSelectAt?: ((itemIndex: number, sectionIndex: number) => void) | undefined;
|
|
354
|
-
/**
|
|
355
|
-
* Handler invoked when selected items have changed. The order of handlers
|
|
356
|
-
* invoked when any selection changes take place is:
|
|
357
|
-
* 1. `onActivateAt`
|
|
358
|
-
* 2. `onDeselectAt`
|
|
359
|
-
* 3. `onSelectAt`
|
|
360
|
-
* 4. `onSelectionChange`
|
|
361
|
-
*
|
|
362
|
-
* @param selectedIndices Dictionary of indices of selected items per section.
|
|
363
|
-
*/
|
|
364
|
-
onSelectionChange?: ((selection: AccordionSelection) => void) | undefined;
|
|
365
|
-
/**
|
|
366
|
-
* Component type for generating section headers inside the component. When
|
|
367
|
-
* absent, one will be generated automatically.
|
|
368
|
-
*/
|
|
369
|
-
HeaderComponent?: React.ComponentType<AccordionHeaderProps<I, S>> | undefined;
|
|
370
|
-
/**
|
|
371
|
-
* Component type for generating items for each section.
|
|
372
|
-
*/
|
|
373
|
-
ItemComponent?: React.ComponentType<AccordionItemProps<I>> | undefined;
|
|
374
|
-
} & {
|
|
375
|
-
children?: React.ReactNode;
|
|
376
|
-
} & {
|
|
377
|
-
ref?: React.Ref<HTMLDivElement> | undefined;
|
|
217
|
+
export declare const Accordion: <I, S extends AccordionSection<I> = AccordionSection<I>>(props: AccordionProps<I, S> & {
|
|
218
|
+
ref?: Ref<HTMLDivElement>;
|
|
378
219
|
}) => ReactElement;
|
|
@@ -74,27 +74,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
74
74
|
};
|
|
75
75
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
76
76
|
exports.Accordion = void 0;
|
|
77
|
-
var
|
|
77
|
+
var clsx_1 = __importDefault(require("clsx"));
|
|
78
78
|
var react_1 = __importDefault(require("fast-deep-equal/react"));
|
|
79
79
|
var react_2 = __importStar(require("react"));
|
|
80
|
+
var Each_1 = require("../operators/Each");
|
|
81
|
+
var utils_1 = require("../utils");
|
|
80
82
|
var Collection_1 = require("./Collection");
|
|
81
|
-
var Each_1 = require("./Each");
|
|
82
83
|
var FlatSVG_1 = require("./FlatSVG");
|
|
83
|
-
var utils_1 = require("./utils");
|
|
84
84
|
/**
|
|
85
85
|
* A collection of selectable items laid out in sections in an accordion. Items
|
|
86
86
|
* are generated based on the provided `ItemComponent` while each section header
|
|
87
87
|
* is optionally provided by `HeaderComponent` or generated automatically.
|
|
88
|
-
*
|
|
89
|
-
* This component automatically determines if it should track selection state
|
|
90
|
-
* and expansion states internally. If the `selection` prop is provided, the
|
|
91
|
-
* component will not initialize the selection state. It will be up to its
|
|
92
|
-
* parent to provide item selection in tandem with the component's
|
|
93
|
-
* `onSelectionChange` handler. Likewise for the omission of the expansion
|
|
94
|
-
* states if `expandedSectionIndices` prop is provided.
|
|
95
88
|
*/
|
|
96
89
|
exports.Accordion = (0, react_2.forwardRef)(function (_a, ref) {
|
|
97
|
-
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.
|
|
90
|
+
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"]);
|
|
98
91
|
var isSectionIndexOutOfRange = function (sectionIndex) {
|
|
99
92
|
if (sectionIndex >= sections.length)
|
|
100
93
|
return true;
|
|
@@ -113,15 +106,15 @@ exports.Accordion = (0, react_2.forwardRef)(function (_a, ref) {
|
|
|
113
106
|
return false;
|
|
114
107
|
};
|
|
115
108
|
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; };
|
|
116
|
-
var sanitizeExpandedSectionIndices = function (sectionIndices) { return sectionIndices
|
|
109
|
+
var sanitizeExpandedSectionIndices = function (sectionIndices) { return sortIndices(sectionIndices).filter(function (t) { return !isSectionIndexOutOfRange(t); }); };
|
|
117
110
|
var sanitizeSelection = function (selection) {
|
|
118
111
|
var _a;
|
|
119
112
|
var newValue = {};
|
|
120
113
|
var _loop_1 = function (sectionIndex) {
|
|
121
|
-
if (!Object.
|
|
114
|
+
if (!Object.hasOwn(sections, sectionIndex))
|
|
122
115
|
return "continue";
|
|
123
|
-
var indices = __spreadArray([], __read((_a = selection[sectionIndex]) !== null && _a !== void 0 ? _a : []), false)
|
|
124
|
-
newValue[Number(sectionIndex)] = indices
|
|
116
|
+
var indices = sortIndices(__spreadArray([], __read((_a = selection[sectionIndex]) !== null && _a !== void 0 ? _a : []), false));
|
|
117
|
+
newValue[Number(sectionIndex)] = sortIndices(indices).filter(function (t) { return !isItemIndexOutOfRange(t, Number(sectionIndex)); });
|
|
125
118
|
};
|
|
126
119
|
for (var sectionIndex in sections) {
|
|
127
120
|
_loop_1(sectionIndex);
|
|
@@ -140,12 +133,7 @@ exports.Accordion = (0, react_2.forwardRef)(function (_a, ref) {
|
|
|
140
133
|
else {
|
|
141
134
|
transform = function (val) { return __spreadArray(__spreadArray([], __read(val.filter(function (t) { return t !== sectionIndex; })), false), [sectionIndex], false); };
|
|
142
135
|
}
|
|
143
|
-
|
|
144
|
-
setExpandedSectionIndices(function (prev) { return transform(prev); });
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
handleExpandedSectionsChange(expandedSectionIndices, transform(expandedSectionIndices));
|
|
148
|
-
}
|
|
136
|
+
handleExpandedSectionsChange(expandedSectionIndices, transform(expandedSectionIndices));
|
|
149
137
|
};
|
|
150
138
|
var handleSelectAt = function (itemIndex, sectionIndex) {
|
|
151
139
|
if (isSelectedAt(itemIndex, sectionIndex))
|
|
@@ -156,7 +144,7 @@ exports.Accordion = (0, react_2.forwardRef)(function (_a, ref) {
|
|
|
156
144
|
transform = function (val) {
|
|
157
145
|
var _a;
|
|
158
146
|
var _b;
|
|
159
|
-
return (__assign(__assign({}, val), (_a = {}, _a[sectionIndex] = __spreadArray(__spreadArray([], __read(((_b = val[sectionIndex]) !== null && _b !== void 0 ? _b : []).filter(function (t) { return t !== itemIndex; })), false), [itemIndex], false)
|
|
147
|
+
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)));
|
|
160
148
|
};
|
|
161
149
|
break;
|
|
162
150
|
case 'single':
|
|
@@ -170,14 +158,9 @@ exports.Accordion = (0, react_2.forwardRef)(function (_a, ref) {
|
|
|
170
158
|
default:
|
|
171
159
|
return;
|
|
172
160
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
else {
|
|
177
|
-
var newValue = transform(selection);
|
|
178
|
-
prevSelectionRef.current = newValue;
|
|
179
|
-
handleSelectionChange(selection, newValue);
|
|
180
|
-
}
|
|
161
|
+
var newValue = transform(selection);
|
|
162
|
+
prevSelectionRef.current = newValue;
|
|
163
|
+
handleSelectionChange(selection, newValue);
|
|
181
164
|
};
|
|
182
165
|
var handleDeselectAt = function (itemIndex, sectionIndex) {
|
|
183
166
|
if (!isSelectedAt(itemIndex, sectionIndex))
|
|
@@ -187,14 +170,9 @@ exports.Accordion = (0, react_2.forwardRef)(function (_a, ref) {
|
|
|
187
170
|
var _b;
|
|
188
171
|
return (__assign(__assign({}, val), (_a = {}, _a[sectionIndex] = ((_b = val[sectionIndex]) !== null && _b !== void 0 ? _b : []).filter(function (t) { return t !== itemIndex; }), _a)));
|
|
189
172
|
};
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
else {
|
|
194
|
-
var newValue = transform(selection);
|
|
195
|
-
prevSelectionRef.current = newValue;
|
|
196
|
-
handleSelectionChange(selection, newValue);
|
|
197
|
-
}
|
|
173
|
+
var newValue = transform(selection);
|
|
174
|
+
prevSelectionRef.current = newValue;
|
|
175
|
+
handleSelectionChange(selection, newValue);
|
|
198
176
|
};
|
|
199
177
|
var handleExpandedSectionsChange = function (oldValue, newValue) {
|
|
200
178
|
var _a;
|
|
@@ -228,14 +206,10 @@ exports.Accordion = (0, react_2.forwardRef)(function (_a, ref) {
|
|
|
228
206
|
allSelected.forEach(function (t) { return onSelectAt === null || onSelectAt === void 0 ? void 0 : onSelectAt(t[0], t[1]); });
|
|
229
207
|
onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(newValue);
|
|
230
208
|
};
|
|
231
|
-
var
|
|
232
|
-
var
|
|
233
|
-
var sanitizedExternalSelection = sanitizeSelection(externalSelection !== null && externalSelection !== void 0 ? externalSelection : {});
|
|
234
|
-
var _g = __read(tracksSelectionChanges ? (0, react_2.useState)(sanitizedExternalSelection) : [sanitizedExternalSelection], 2), selection = _g[0], setSelection = _g[1];
|
|
235
|
-
var sanitizedExternalExpandedSectionIndices = sanitizeExpandedSectionIndices(externalExpandedSectionIndices !== null && externalExpandedSectionIndices !== void 0 ? externalExpandedSectionIndices : []);
|
|
236
|
-
var _h = __read(tracksExpansionChanges ? (0, react_2.useState)(sanitizedExternalExpandedSectionIndices) : [sanitizedExternalExpandedSectionIndices], 2), expandedSectionIndices = _h[0], setExpandedSectionIndices = _h[1];
|
|
209
|
+
var selection = sanitizeSelection(externalSelection !== null && externalSelection !== void 0 ? externalSelection : {});
|
|
210
|
+
var expandedSectionIndices = sanitizeExpandedSectionIndices(externalExpandedSectionIndices !== null && externalExpandedSectionIndices !== void 0 ? externalExpandedSectionIndices : []);
|
|
237
211
|
var fixedStyles = getFixedStyles({ orientation: orientation });
|
|
238
|
-
var defaultStyles =
|
|
212
|
+
var defaultStyles = usesDefaultStyles ? getDefaultStyles({ orientation: orientation }) : undefined;
|
|
239
213
|
var prevSelectionRef = (0, react_2.useRef)();
|
|
240
214
|
var prevSelection = prevSelectionRef.current;
|
|
241
215
|
(0, react_2.useEffect)(function () {
|
|
@@ -259,25 +233,36 @@ exports.Accordion = (0, react_2.forwardRef)(function (_a, ref) {
|
|
|
259
233
|
} : {
|
|
260
234
|
marginLeft: sectionIndex === 0 ? '0px' : "".concat(sectionPadding, "px"),
|
|
261
235
|
}) },
|
|
262
|
-
HeaderComponent ? (react_2.default.createElement(HeaderComponent, { "data-child": 'header', className: (0,
|
|
236
|
+
HeaderComponent ? (react_2.default.createElement(HeaderComponent, { "data-child": 'header', className: (0, clsx_1.default)({ collapsed: isCollapsed, expanded: !isCollapsed }), style: (0, utils_1.styles)(fixedStyles.header), index: sectionIndex, isCollapsed: isCollapsed, section: section, onClick: function () { return toggleSectionAt(sectionIndex); }, onCustomEvent: function (name, info) { return onHeaderCustomEvent === null || onHeaderCustomEvent === void 0 ? void 0 : onHeaderCustomEvent(sectionIndex, name, info); } })) : (react_2.default.createElement("button", { "data-child": 'header', className: (0, clsx_1.default)({ collapsed: isCollapsed, expanded: !isCollapsed }), style: (0, utils_1.styles)(fixedStyles.header, defaultStyles === null || defaultStyles === void 0 ? void 0 : defaultStyles.header), onClick: function () { return toggleSectionAt(sectionIndex); } },
|
|
263
237
|
react_2.default.createElement("span", { style: (0, utils_1.styles)(defaultStyles === null || defaultStyles === void 0 ? void 0 : defaultStyles.headerLabel), dangerouslySetInnerHTML: { __html: section.label } }),
|
|
264
238
|
(0, utils_1.cloneStyledElement)(isCollapsed ? expandIconComponent : collapseIconComponent, {
|
|
265
239
|
style: (0, utils_1.styles)(isCollapsed ? fixedStyles.expandIcon : fixedStyles.collapseIcon),
|
|
266
240
|
}))),
|
|
267
|
-
react_2.default.createElement(Collection_1.Collection, { "data-child": 'collection', className: (0,
|
|
241
|
+
react_2.default.createElement(Collection_1.Collection, { "data-child": 'collection', className: (0, clsx_1.default)({ collapsed: isCollapsed, expanded: !isCollapsed }), style: (0, utils_1.styles)(fixedStyles.list, defaultStyles === null || defaultStyles === void 0 ? void 0 : defaultStyles.collection, orientation === 'vertical' ? {
|
|
268
242
|
width: '100%',
|
|
269
243
|
height: isCollapsed ? '0px' : "".concat(maxLength, "px"),
|
|
270
244
|
marginTop: isCollapsed ? '0px' : "".concat(collectionPadding, "px"),
|
|
271
|
-
overflowY: maxVisible < 0
|
|
245
|
+
overflowY: maxVisible < 0 || maxVisible >= allVisible ? 'hidden' : 'scroll',
|
|
272
246
|
} : {
|
|
273
247
|
marginLeft: isCollapsed ? '0px' : "".concat(collectionPadding, "px"),
|
|
274
|
-
overflowX: maxVisible < 0
|
|
248
|
+
overflowX: maxVisible < 0 || maxVisible >= allVisible ? 'hidden' : 'scroll',
|
|
275
249
|
width: isCollapsed ? '0px' : "".concat(maxLength, "px"),
|
|
276
250
|
height: '100%',
|
|
277
|
-
}), selectionMode: selectionMode, isSelectionTogglable: isSelectionTogglable, itemLength: itemLength, itemPadding: itemPadding, items: items, orientation: orientation, layout: layout, numSegments: numSegments, selection: (_a = selection[sectionIndex]) !== null && _a !== void 0 ? _a : [], onActivateAt: function (itemIndex) {
|
|
251
|
+
}), selectionMode: selectionMode, isSelectionTogglable: isSelectionTogglable, itemLength: itemLength, itemPadding: itemPadding, items: items, orientation: orientation, layout: layout, numSegments: numSegments, selection: (_a = selection[sectionIndex]) !== null && _a !== void 0 ? _a : [], onActivateAt: function (itemIndex) {
|
|
252
|
+
onActivateAt === null || onActivateAt === void 0 ? void 0 : onActivateAt(itemIndex, sectionIndex);
|
|
253
|
+
}, onDeselectAt: function (itemIndex) {
|
|
254
|
+
handleDeselectAt === null || handleDeselectAt === void 0 ? void 0 : handleDeselectAt(itemIndex, sectionIndex);
|
|
255
|
+
}, onItemCustomEvent: function (itemIndex, name, info) {
|
|
256
|
+
onItemCustomEvent === null || onItemCustomEvent === void 0 ? void 0 : onItemCustomEvent(itemIndex, sectionIndex, name, info);
|
|
257
|
+
}, onSelectAt: function (itemIndex) {
|
|
258
|
+
handleSelectAt === null || handleSelectAt === void 0 ? void 0 : handleSelectAt(itemIndex, sectionIndex);
|
|
259
|
+
}, ItemComponent: ItemComponent })));
|
|
278
260
|
})));
|
|
279
261
|
});
|
|
280
262
|
Object.defineProperty(exports.Accordion, 'displayName', { value: 'Accordion', writable: false });
|
|
263
|
+
function sortIndices(indices) {
|
|
264
|
+
return indices.sort(function (a, b) { return a - b; });
|
|
265
|
+
}
|
|
281
266
|
function getFixedStyles(_a) {
|
|
282
267
|
var _b = _a.orientation, orientation = _b === void 0 ? 'vertical' : _b;
|
|
283
268
|
return (0, utils_1.asStyleDict)({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Accordion.js","sourceRoot":"/","sources":["components/Accordion.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CAAC,CAAC;YAC9B,MAAM,EAAE,MAAM;SACf,CAAC,CAAC,CAAC;YACF,KAAK,EAAE,MAAM;SACd,CACF;QACD,WAAW,EAAE;YACX,KAAK,EAAE,SAAS;YAChB,UAAU,EAAE,SAAS;YACrB,QAAQ,EAAE,SAAS;YACnB,UAAU,EAAE,SAAS;YACrB,aAAa,EAAE,SAAS;YACxB,UAAU,EAAE,SAAS;YACrB,aAAa,EAAE,MAAM;YACrB,UAAU,EAAE,SAAS;SACtB;QACD,UAAU,EAAE;YACV,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;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 React, { 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} data-component='accordion' style={styles(style, fixedStyles.root)} ref={ref}>\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 svg={expandIconSvg} style={defaultStyles?.expandIcon}/> : <></>\n const collapseIconComponent = collapseIconSvg ? <FlatSVG svg={collapseIconSvg} style={defaultStyles?.collapseIcon}/> : expandIconComponent\n\n return (\n <div style={styles(fixedStyles.section, orientation === 'vertical' ? {\n marginTop: sectionIndex === 0 ? '0px' : `${sectionPadding}px`,\n } : {\n marginLeft: sectionIndex === 0 ? '0px' : `${sectionPadding}px`,\n })}>\n {HeaderComponent ? (\n <HeaderComponent\n data-child='header'\n className={clsx({ collapsed: isCollapsed, expanded: !isCollapsed })}\n style={styles(fixedStyles.header)}\n index={sectionIndex}\n isCollapsed={isCollapsed}\n section={section}\n onClick={() => toggleSectionAt(sectionIndex)}\n onCustomEvent={(name, info) => onHeaderCustomEvent?.(sectionIndex, name, info)}\n />\n ) : (\n <button\n data-child='header'\n className={clsx({ collapsed: isCollapsed, expanded: !isCollapsed })}\n style={styles(fixedStyles.header, defaultStyles?.header)}\n onClick={() => toggleSectionAt(sectionIndex)}\n >\n <span style={styles(defaultStyles?.headerLabel)} dangerouslySetInnerHTML={{ __html: section.label }}/>\n {cloneStyledElement(isCollapsed ? expandIconComponent : collapseIconComponent, {\n style: styles(isCollapsed ? fixedStyles.expandIcon : fixedStyles.collapseIcon),\n })}\n </button>\n )}\n <Collection\n data-child='collection'\n className={clsx({ collapsed: isCollapsed, expanded: !isCollapsed })}\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 selectionMode={selectionMode}\n isSelectionTogglable={isSelectionTogglable}\n itemLength={itemLength}\n itemPadding={itemPadding}\n items={items}\n orientation={orientation}\n layout={layout}\n numSegments={numSegments}\n selection={selection[sectionIndex] ?? []}\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 ItemComponent={ItemComponent}\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"]}
|
|
@@ -6,6 +6,7 @@ export type BurgerButtonProps = HTMLAttributes<HTMLButtonElement> & PropsWithChi
|
|
|
6
6
|
isLastBarHalfWidth?: boolean;
|
|
7
7
|
thickness?: number;
|
|
8
8
|
transitionDuration?: number;
|
|
9
|
+
usesDefaultStyles?: boolean;
|
|
9
10
|
width?: number;
|
|
10
11
|
onActivate?: () => void;
|
|
11
12
|
onDeactivate?: () => void;
|
|
@@ -23,6 +24,7 @@ export declare const BurgerButton: React.ForwardRefExoticComponent<React.HTMLAtt
|
|
|
23
24
|
isLastBarHalfWidth?: boolean | undefined;
|
|
24
25
|
thickness?: number | undefined;
|
|
25
26
|
transitionDuration?: number | undefined;
|
|
27
|
+
usesDefaultStyles?: boolean | undefined;
|
|
26
28
|
width?: number | undefined;
|
|
27
29
|
onActivate?: (() => void) | undefined;
|
|
28
30
|
onDeactivate?: (() => void) | undefined;
|
|
@@ -65,10 +65,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
65
65
|
};
|
|
66
66
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67
67
|
exports.BurgerButtonBar = exports.BurgerButton = void 0;
|
|
68
|
-
var
|
|
68
|
+
var clsx_1 = __importDefault(require("clsx"));
|
|
69
69
|
var react_1 = __importStar(require("react"));
|
|
70
|
-
var Repeat_1 = require("
|
|
71
|
-
var utils_1 = require("
|
|
70
|
+
var Repeat_1 = require("../operators/Repeat");
|
|
71
|
+
var utils_1 = require("../utils");
|
|
72
72
|
/**
|
|
73
73
|
* Three-striped burger button component that transforms into an "X" when
|
|
74
74
|
* selected.
|
|
@@ -76,8 +76,8 @@ var utils_1 = require("./utils");
|
|
|
76
76
|
* @exports BurgerButtonBar Component for each line on the burger button.
|
|
77
77
|
*/
|
|
78
78
|
exports.BurgerButton = (0, react_1.forwardRef)(function (_a, ref) {
|
|
79
|
-
var children = _a.children, className = _a.className, style = _a.style, _b = _a.height, height = _b === void 0 ? 20 : _b, _c = _a.isActive, externalIsActive = _c === void 0 ? false : _c, _d = _a.isDoubleJointed, isDoubleJointed = _d === void 0 ? false : _d, _e = _a.isLastBarHalfWidth, isLastBarHalfWidth = _e === void 0 ? false : _e, _f = _a.thickness, thickness = _f === void 0 ? 2 : _f, _g = _a.transitionDuration, transitionDuration = _g === void 0 ? 200 : _g, _h = _a.width, width =
|
|
80
|
-
var
|
|
79
|
+
var children = _a.children, className = _a.className, style = _a.style, _b = _a.height, height = _b === void 0 ? 20 : _b, _c = _a.isActive, externalIsActive = _c === void 0 ? false : _c, _d = _a.isDoubleJointed, isDoubleJointed = _d === void 0 ? false : _d, _e = _a.isLastBarHalfWidth, isLastBarHalfWidth = _e === void 0 ? false : _e, _f = _a.thickness, thickness = _f === void 0 ? 2 : _f, _g = _a.transitionDuration, transitionDuration = _g === void 0 ? 200 : _g, _h = _a.usesDefaultStyles, usesDefaultStyles = _h === void 0 ? false : _h, _j = _a.width, width = _j === void 0 ? 20 : _j, onActivate = _a.onActivate, onDeactivate = _a.onDeactivate, props = __rest(_a, ["children", "className", "style", "height", "isActive", "isDoubleJointed", "isLastBarHalfWidth", "thickness", "transitionDuration", "usesDefaultStyles", "width", "onActivate", "onDeactivate"]);
|
|
80
|
+
var _k = __read((0, react_1.useState)(externalIsActive), 2), isActive = _k[0], setIsActive = _k[1];
|
|
81
81
|
(0, react_1.useEffect)(function () {
|
|
82
82
|
if (isActive === externalIsActive)
|
|
83
83
|
return;
|
|
@@ -95,14 +95,35 @@ exports.BurgerButton = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
95
95
|
bar: exports.BurgerButtonBar,
|
|
96
96
|
});
|
|
97
97
|
var fixedClassNames = (0, utils_1.asClassNameDict)({
|
|
98
|
-
root: (0,
|
|
98
|
+
root: (0, clsx_1.default)({
|
|
99
99
|
active: isActive,
|
|
100
100
|
}),
|
|
101
|
-
bar: (0,
|
|
101
|
+
bar: (0, clsx_1.default)({
|
|
102
102
|
active: isActive,
|
|
103
103
|
}),
|
|
104
104
|
});
|
|
105
|
-
var fixedStyles = (
|
|
105
|
+
var fixedStyles = getFixedStyles({ height: height, width: width, isDoubleJointed: isDoubleJointed, thickness: thickness, isActive: isActive, isLastBarHalfWidth: isLastBarHalfWidth });
|
|
106
|
+
var defaultStyles = usesDefaultStyles ? getDefaultStyles() : undefined;
|
|
107
|
+
return (react_1.default.createElement("button", __assign({}, props, { ref: ref, className: (0, clsx_1.default)(className, fixedClassNames.root), style: (0, utils_1.styles)(style, fixedStyles.root), "data-component": 'burger-button', onClick: function () { return setIsActive(!isActive); } }),
|
|
108
|
+
react_1.default.createElement(Repeat_1.Repeat, { count: isDoubleJointed ? 2 : 1 }, function (j) { return (react_1.default.createElement("div", { style: (0, utils_1.styles)(fixedStyles.joint, fixedStyles["joint".concat(j)]), "data-child": 'joint' },
|
|
109
|
+
react_1.default.createElement(Repeat_1.Repeat, { count: 3 }, function (i) {
|
|
110
|
+
var _a;
|
|
111
|
+
return (0, utils_1.cloneStyledElement)((_a = components.bar) !== null && _a !== void 0 ? _a : react_1.default.createElement(exports.BurgerButtonBar, { style: defaultStyles === null || defaultStyles === void 0 ? void 0 : defaultStyles.bar }), {
|
|
112
|
+
'className': (0, clsx_1.default)(fixedClassNames.bar),
|
|
113
|
+
'style': (0, utils_1.styles)(fixedStyles.bar, fixedStyles["bar".concat(j).concat(i)]),
|
|
114
|
+
'data-index': i,
|
|
115
|
+
});
|
|
116
|
+
}))); })));
|
|
117
|
+
});
|
|
118
|
+
Object.defineProperty(exports.BurgerButton, 'displayName', { value: 'BurgerButton', writable: false });
|
|
119
|
+
var BurgerButtonBar = function (_a) {
|
|
120
|
+
var props = __rest(_a, []);
|
|
121
|
+
return react_1.default.createElement("span", __assign({}, props, { "data-child": 'bar' }));
|
|
122
|
+
};
|
|
123
|
+
exports.BurgerButtonBar = BurgerButtonBar;
|
|
124
|
+
function getFixedStyles(_a) {
|
|
125
|
+
var _b = _a.height, height = _b === void 0 ? 0 : _b, _c = _a.width, width = _c === void 0 ? 0 : _c, _d = _a.isDoubleJointed, isDoubleJointed = _d === void 0 ? false : _d, _e = _a.thickness, thickness = _e === void 0 ? 0 : _e, _f = _a.isActive, isActive = _f === void 0 ? false : _f, _g = _a.isLastBarHalfWidth, isLastBarHalfWidth = _g === void 0 ? false : _g;
|
|
126
|
+
return (0, utils_1.asStyleDict)({
|
|
106
127
|
root: {
|
|
107
128
|
background: 'transparent',
|
|
108
129
|
border: 'none',
|
|
@@ -170,7 +191,9 @@ exports.BurgerButton = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
170
191
|
width: isLastBarHalfWidth && !isActive ? '0' : '100%',
|
|
171
192
|
},
|
|
172
193
|
});
|
|
173
|
-
|
|
194
|
+
}
|
|
195
|
+
function getDefaultStyles() {
|
|
196
|
+
return (0, utils_1.asStyleDict)({
|
|
174
197
|
bar: {
|
|
175
198
|
background: '#fff',
|
|
176
199
|
transitionDuration: '100ms',
|
|
@@ -178,21 +201,5 @@ exports.BurgerButton = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
178
201
|
transitionTimingFunction: 'ease-out',
|
|
179
202
|
},
|
|
180
203
|
});
|
|
181
|
-
|
|
182
|
-
react_1.default.createElement(Repeat_1.Repeat, { count: isDoubleJointed ? 2 : 1 }, function (j) { return (react_1.default.createElement("div", { style: (0, utils_1.styles)(fixedStyles.joint, fixedStyles["joint".concat(j)]) },
|
|
183
|
-
react_1.default.createElement(Repeat_1.Repeat, { count: 3 }, function (i) {
|
|
184
|
-
var _a;
|
|
185
|
-
return (0, utils_1.cloneStyledElement)((_a = components.bar) !== null && _a !== void 0 ? _a : react_1.default.createElement(exports.BurgerButtonBar, { style: defaultStyles.bar }), {
|
|
186
|
-
'className': (0, classnames_1.default)(fixedClassNames.bar),
|
|
187
|
-
'style': (0, utils_1.styles)(fixedStyles.bar, fixedStyles["bar".concat(j).concat(i)]),
|
|
188
|
-
'data-index': i,
|
|
189
|
-
});
|
|
190
|
-
}))); })));
|
|
191
|
-
});
|
|
192
|
-
Object.defineProperty(exports.BurgerButton, 'displayName', { value: 'BurgerButton', writable: false });
|
|
193
|
-
var BurgerButtonBar = function (_a) {
|
|
194
|
-
var props = __rest(_a, []);
|
|
195
|
-
return react_1.default.createElement("span", __assign({}, props));
|
|
196
|
-
};
|
|
197
|
-
exports.BurgerButtonBar = BurgerButtonBar;
|
|
204
|
+
}
|
|
198
205
|
//# sourceMappingURL=BurgerButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BurgerButton.js","sourceRoot":"/","sources":["components/BurgerButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAuB;AACvB,6CAA2G;AAC3G,8CAA4C;AAC5C,kCAAoG;AAepG;;;;;GAKG;AACU,QAAA,YAAY,GAAG,IAAA,kBAAU,EAAuC,UAAC,EAe7E,EAAE,GAAG;IAdJ,IAAA,QAAQ,cAAA,EACR,SAAS,eAAA,EACT,KAAK,WAAA,EACL,cAAW,EAAX,MAAM,mBAAG,EAAE,KAAA,EACX,gBAAkC,EAAxB,gBAAgB,mBAAG,KAAK,KAAA,EAClC,uBAAuB,EAAvB,eAAe,mBAAG,KAAK,KAAA,EACvB,0BAA0B,EAA1B,kBAAkB,mBAAG,KAAK,KAAA,EAC1B,iBAAa,EAAb,SAAS,mBAAG,CAAC,KAAA,EACb,0BAAwB,EAAxB,kBAAkB,mBAAG,GAAG,KAAA,EACxB,yBAAyB,EAAzB,iBAAiB,mBAAG,KAAK,KAAA,EACzB,aAAU,EAAV,KAAK,mBAAG,EAAE,KAAA,EACV,UAAU,gBAAA,EACV,YAAY,kBAAA,EACT,KAAK,cAdoE,gMAe7E,CADS;IAEF,IAAA,KAAA,OAA0B,IAAA,gBAAQ,EAAC,gBAAgB,CAAC,IAAA,EAAnD,QAAQ,QAAA,EA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YAClI,eAAe,EAAE,aAAa;YAC9B,KAAK,EAAE,kBAAkB,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM;SACtD;KACF,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,gBAAgB;IACvB,OAAO,IAAA,mBAAW,EAAC;QACjB,GAAG,EAAE;YACH,UAAU,EAAE,MAAM;YAClB,kBAAkB,EAAE,OAAO;YAC3B,kBAAkB,EAAE,+CAA+C;YACnE,wBAAwB,EAAE,UAAU;SACrC;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import clsx from 'clsx'\nimport React, { 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 style={styles(style, fixedStyles.root)}\n data-component='burger-button'\n onClick={() => setIsActive(!isActive)}\n >\n <Repeat count={isDoubleJointed ? 2 : 1}>\n {j => (\n <div style={styles(fixedStyles.joint, (fixedStyles as any)[`joint${j}`])} data-child='joint'>\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"]}
|