etudes 5.3.1 → 6.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/components/Accordion.d.ts +209 -0
- package/components/Accordion.js +17 -84
- package/components/BurgerButton.d.ts +26 -0
- package/components/BurgerButton.js +33 -53
- package/components/Button.d.ts +10 -0
- package/components/Button.js +15 -0
- package/components/Carousel.d.ts +53 -0
- package/components/Carousel.js +7 -8
- package/components/Collection.d.ts +171 -0
- package/components/Collection.js +1 -1
- package/components/Counter.d.ts +14 -0
- package/components/Counter.js +59 -33
- package/components/CoverImage.d.ts +20 -0
- package/components/CoverImage.js +20 -21
- package/components/CoverVideo.d.ts +20 -0
- package/components/CoverVideo.js +19 -20
- package/components/Dial.d.ts +79 -0
- package/components/Dial.js +10 -19
- package/components/Dropdown.d.ts +102 -0
- package/components/Dropdown.js +16 -51
- package/components/FlatSVG.d.ts +72 -0
- package/components/Image.d.ts +144 -0
- package/components/MasonryGrid.d.ts +28 -0
- package/components/MasonryGrid.js +8 -10
- package/components/OptionButton.d.ts +19 -0
- package/components/OptionButton.js +17 -0
- package/components/Panorama.d.ts +77 -0
- package/components/Panorama.js +2 -2
- package/components/PanoramaSlider.d.ts +63 -0
- package/components/PanoramaSlider.js +14 -41
- package/components/RangeSlider.d.ts +34 -0
- package/components/RangeSlider.js +27 -61
- package/components/SelectableButton.d.ts +21 -0
- package/components/SelectableButton.js +7 -10
- package/components/Slider.d.ts +151 -0
- package/components/Slider.js +15 -34
- package/components/StepwiseSlider.d.ts +198 -0
- package/components/StepwiseSlider.js +13 -33
- package/components/SwipeContainer.d.ts +21 -0
- package/components/SwipeContainer.js +2 -2
- package/components/TextField.d.ts +21 -0
- package/components/TextField.js +3 -2
- package/components/Video.d.ts +38 -0
- package/components/WithTooltip.d.ts +36 -0
- package/components/WithTooltip.js +143 -167
- package/hooks/useClickOutsideEffect.d.ts +2 -0
- package/hooks/useDragEffect.d.ts +48 -0
- package/hooks/useDragEffect.js +3 -3
- package/hooks/useDragValueEffect.d.ts +56 -0
- package/hooks/useImageSize.d.ts +21 -0
- package/hooks/useImageSize.js +1 -1
- package/hooks/useInterval.d.ts +18 -0
- package/hooks/useLoadImageEffect.d.ts +43 -0
- package/hooks/useLoadVideoMetadataEffect.d.ts +35 -0
- package/hooks/useMounted.d.ts +1 -0
- package/hooks/usePrevious.d.ts +19 -0
- package/hooks/useRect.d.ts +11 -0
- package/hooks/useRect.js +1 -1
- package/hooks/useResizeEffect.d.ts +17 -0
- package/hooks/useScrollPositionEffect.d.ts +13 -0
- package/hooks/useScrollPositionEffect.js +4 -4
- package/hooks/useSearchParamState.d.ts +34 -0
- package/hooks/useSize.d.ts +10 -0
- package/hooks/useSize.js +1 -1
- package/hooks/useTimeout.d.ts +10 -0
- package/hooks/useVideoSize.d.ts +21 -0
- package/hooks/useVideoSize.js +1 -1
- package/hooks/useViewportSize.d.ts +7 -0
- package/hooks/useViewportSize.js +1 -1
- package/operators/Conditional.d.ts +5 -0
- package/operators/Each.d.ts +7 -0
- package/operators/ExtractChild.d.ts +8 -0
- package/operators/ExtractChildren.d.ts +6 -0
- package/operators/Repeat.d.ts +11 -0
- package/package.json +20 -21
- package/providers/ScrollPositionProvider.d.ts +15 -0
- package/providers/ScrollPositionProvider.js +12 -12
- package/utils/asClassNameDict.d.ts +3 -0
- package/utils/asComponentDict.d.ts +5 -0
- package/utils/asStyleDict.d.ts +4 -0
- package/utils/cloneStyledElement.d.ts +17 -0
- package/utils/cloneStyledElement.js +2 -3
- package/utils/index.d.ts +5 -0
- package/utils/styles.d.ts +2 -0
- package/components/DebugConsole.js +0 -76
- package/components/RotatingGallery.js +0 -58
- package/components/index.js +0 -24
- package/hooks/index.js +0 -17
- package/operators/index.js +0 -5
- package/providers/index.js +0 -1
|
@@ -0,0 +1,209 @@
|
|
|
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.js';
|
|
3
|
+
import type { DropdownToggleProps } from './Dropdown.js';
|
|
4
|
+
/**
|
|
5
|
+
* Type describing the current item selection of {@link Accordion}, composed of
|
|
6
|
+
* a dictionary whose key corresponds the section index and value corresponds to
|
|
7
|
+
* an array of selected item indices. If the selection mode of the
|
|
8
|
+
* {@link Accordion} is `single`, only one key will be present and one index in
|
|
9
|
+
* the array value.
|
|
10
|
+
*/
|
|
11
|
+
export type AccordionSelection = Record<number, number[]>;
|
|
12
|
+
/**
|
|
13
|
+
* Type describing the data of each section in {@link Accordion}.
|
|
14
|
+
*/
|
|
15
|
+
export type AccordionSection<T> = Pick<CollectionProps<T>, 'isSelectionTogglable' | 'itemLength' | 'itemPadding' | 'items' | 'layout' | 'numSegments'> & {
|
|
16
|
+
/**
|
|
17
|
+
* Padding (in pixels) between the sectionheader and the internal collection.
|
|
18
|
+
*/
|
|
19
|
+
collectionPadding?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Label for the section header.
|
|
22
|
+
*/
|
|
23
|
+
label: string;
|
|
24
|
+
/**
|
|
25
|
+
* Maximum number of visible rows (if section orientation is `vertical`) or
|
|
26
|
+
* columns (if section orientation is `horizontal`). If number of rows exceeds
|
|
27
|
+
* the number of visible, a scrollbar will be put in place.
|
|
28
|
+
*/
|
|
29
|
+
maxVisible?: number;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Type describing the props of each `ItemComponent` provided to
|
|
33
|
+
* {@link Accordion}.
|
|
34
|
+
*/
|
|
35
|
+
export type AccordionItemProps<T> = CollectionItemProps<T>;
|
|
36
|
+
/**
|
|
37
|
+
* Type describing the props of each `HeaderComponent` provided to
|
|
38
|
+
* {@link Accordion}.
|
|
39
|
+
*/
|
|
40
|
+
export type AccordionHeaderProps<I, S extends AccordionSection<I> = AccordionSection<I>> = HTMLAttributes<HTMLElement> & PropsWithChildren<{
|
|
41
|
+
/**
|
|
42
|
+
* The index of the corresponding section.
|
|
43
|
+
*/
|
|
44
|
+
index: number;
|
|
45
|
+
/**
|
|
46
|
+
* Indicates whether the corresponding section is collapsed.
|
|
47
|
+
*/
|
|
48
|
+
isCollapsed: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Data provided to the corresponding section.
|
|
51
|
+
*/
|
|
52
|
+
section: S;
|
|
53
|
+
/**
|
|
54
|
+
* Handler invoked to dispatch a custom event.
|
|
55
|
+
*
|
|
56
|
+
* @param name User-defined name of the custom event.
|
|
57
|
+
* @param info Optional user-defined info of the custom event.
|
|
58
|
+
*/
|
|
59
|
+
onCustomEvent?: (name: string, info?: any) => void;
|
|
60
|
+
}>;
|
|
61
|
+
/**
|
|
62
|
+
* Type describing the props of {@link Accordion}.
|
|
63
|
+
*/
|
|
64
|
+
export type AccordionProps<I, S extends AccordionSection<I> = AccordionSection<I>> = HTMLAttributes<HTMLDivElement> & PropsWithChildren<{
|
|
65
|
+
/**
|
|
66
|
+
* Specifies if expanded sections should automatically collapse upon expanding
|
|
67
|
+
* another section.
|
|
68
|
+
*/
|
|
69
|
+
autoCollapseSections?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Indices of sections that are expanded. If specified, the component will not
|
|
72
|
+
* manage expansion states.
|
|
73
|
+
*/
|
|
74
|
+
expandedSectionIndices?: number[];
|
|
75
|
+
/**
|
|
76
|
+
* Orientation of this component.
|
|
77
|
+
*
|
|
78
|
+
* @see {@link CollectionOrientation}
|
|
79
|
+
*/
|
|
80
|
+
orientation?: CollectionOrientation;
|
|
81
|
+
/**
|
|
82
|
+
* Padding (in pixels) between each section.
|
|
83
|
+
*/
|
|
84
|
+
sectionPadding?: number;
|
|
85
|
+
/**
|
|
86
|
+
* Data provided to each section.
|
|
87
|
+
*/
|
|
88
|
+
sections: S[];
|
|
89
|
+
/**
|
|
90
|
+
* Indices of selected items per section.
|
|
91
|
+
*
|
|
92
|
+
* @see {@link AccordionSelection}
|
|
93
|
+
*/
|
|
94
|
+
selection?: AccordionSelection;
|
|
95
|
+
/**
|
|
96
|
+
* Selection mode of each section.
|
|
97
|
+
*
|
|
98
|
+
* @see {@link CollectionSelectionMode}
|
|
99
|
+
*/
|
|
100
|
+
selectionMode?: CollectionSelectionMode;
|
|
101
|
+
/**
|
|
102
|
+
* Handler invoked when an item is activated in a section. The order of
|
|
103
|
+
* handlers invoked when any selection changes take place is:
|
|
104
|
+
* 1. `onActivateAt`
|
|
105
|
+
* 2. `onDeselectAt`
|
|
106
|
+
* 3. `onSelectAt`
|
|
107
|
+
* 4. `onSelectionChange`
|
|
108
|
+
*
|
|
109
|
+
* @param itemIndex Item index.
|
|
110
|
+
* @param sectionIndex Section index.
|
|
111
|
+
*/
|
|
112
|
+
onActivateAt?: (itemIndex: number, sectionIndex: number) => void;
|
|
113
|
+
/**
|
|
114
|
+
* Handler invoked when a section is collapsed. The order of handlers invoked
|
|
115
|
+
* when any section expansion changes take place is:
|
|
116
|
+
* 1. `onCollapseSectionAt`
|
|
117
|
+
* 2. `onExpandSectionAt`
|
|
118
|
+
*
|
|
119
|
+
* @param sectionIndex Section index.
|
|
120
|
+
*/
|
|
121
|
+
onCollapseSectionAt?: (sectionIndex: number) => void;
|
|
122
|
+
/**
|
|
123
|
+
* Handler invoked when an item is deselected in a section. The order of
|
|
124
|
+
* handlers invoked when any selection changes take place is:
|
|
125
|
+
* 1. `onActivateAt`
|
|
126
|
+
* 2. `onDeselectAt`
|
|
127
|
+
* 3. `onSelectAt`
|
|
128
|
+
* 4. `onSelectionChange`
|
|
129
|
+
*
|
|
130
|
+
* @param itemIndex Item index.
|
|
131
|
+
* @param sectionIndex Section index.
|
|
132
|
+
*/
|
|
133
|
+
onDeselectAt?: (itemIndex: number, sectionIndex: number) => void;
|
|
134
|
+
/**
|
|
135
|
+
* Handler invoked when the expansion state of any section changes.
|
|
136
|
+
*
|
|
137
|
+
* @param expandedSectionIndices Indices of sections that are expanded.
|
|
138
|
+
*/
|
|
139
|
+
onExpandedSectionsChange?: (expandedSectionIndices: number[]) => void;
|
|
140
|
+
/**
|
|
141
|
+
* Handler invoked when a section is expanded. The order of handlers invoked
|
|
142
|
+
* when any section expansion changes take place is:
|
|
143
|
+
* 1. `onCollapseSectionAt`
|
|
144
|
+
* 2. `onExpandSectionAt`
|
|
145
|
+
*
|
|
146
|
+
* @param sectionIndex Section index.
|
|
147
|
+
*/
|
|
148
|
+
onExpandSectionAt?: (sectionIndex: number) => void;
|
|
149
|
+
/**
|
|
150
|
+
* Handler invoked when a custom event is dispatched from a section header.
|
|
151
|
+
*
|
|
152
|
+
* @param sectionIndex Index of the section which the header belongs.
|
|
153
|
+
* @param eventName User-defined name of the dispatched event.
|
|
154
|
+
* @param eventInfo Optional user-defined info of the dispatched event.
|
|
155
|
+
*/
|
|
156
|
+
onHeaderCustomEvent?: (sectionIndex: number, eventName: string, eventInfo?: any) => void;
|
|
157
|
+
/**
|
|
158
|
+
* Handler invoked when a custom event is dispatched from an item.
|
|
159
|
+
*
|
|
160
|
+
* @param itemIndex Item index.
|
|
161
|
+
* @param sectionIndex Section index.
|
|
162
|
+
* @param eventName User-defined name of the dispatched event.
|
|
163
|
+
* @param eventInfo Optional user-defined info of the dispatched event.
|
|
164
|
+
*/
|
|
165
|
+
onItemCustomEvent?: (itemIndex: number, sectionIndex: number, eventName: string, eventInfo?: any) => void;
|
|
166
|
+
/**
|
|
167
|
+
* Handler invoked when an item is selected in a section. The order of
|
|
168
|
+
* handlers invoked when any selection changes take place is:
|
|
169
|
+
* 1. `onActivateAt`
|
|
170
|
+
* 2. `onDeselectAt`
|
|
171
|
+
* 3. `onSelectAt`
|
|
172
|
+
* 4. `onSelectionChange`
|
|
173
|
+
*
|
|
174
|
+
* @param itemIndex Item index.
|
|
175
|
+
* @param sectionIndex Section index.
|
|
176
|
+
*/
|
|
177
|
+
onSelectAt?: (itemIndex: number, sectionIndex: number) => void;
|
|
178
|
+
/**
|
|
179
|
+
* Handler invoked when selected items have changed. The order of handlers
|
|
180
|
+
* invoked when any selection changes take place is:
|
|
181
|
+
* 1. `onActivateAt`
|
|
182
|
+
* 2. `onDeselectAt`
|
|
183
|
+
* 3. `onSelectAt`
|
|
184
|
+
* 4. `onSelectionChange`
|
|
185
|
+
*
|
|
186
|
+
* @param selectedIndices Dictionary of indices of selected items per section.
|
|
187
|
+
*/
|
|
188
|
+
onSelectionChange?: (selection: AccordionSelection) => void;
|
|
189
|
+
/**
|
|
190
|
+
* Component type for generating section headers inside the component. When
|
|
191
|
+
* absent, one will be generated automatically.
|
|
192
|
+
*/
|
|
193
|
+
HeaderComponent?: ComponentType<AccordionHeaderProps<I, S>>;
|
|
194
|
+
/**
|
|
195
|
+
* Component type for generating items for each section.
|
|
196
|
+
*/
|
|
197
|
+
ItemComponent?: ComponentType<AccordionItemProps<I>>;
|
|
198
|
+
}>;
|
|
199
|
+
/**
|
|
200
|
+
* A collection of selectable items laid out in sections in an accordion. Items
|
|
201
|
+
* are generated based on the provided `ItemComponent` while each section header
|
|
202
|
+
* is optionally provided by `HeaderComponent` or generated automatically.
|
|
203
|
+
*/
|
|
204
|
+
export declare const Accordion: <I, S extends AccordionSection<I> = AccordionSection<I>>(props: AccordionProps<I, S> & {
|
|
205
|
+
ref?: Ref<HTMLDivElement>;
|
|
206
|
+
}) => ReactElement;
|
|
207
|
+
export declare const AccordionHeader: ({ children, ...props }: HTMLAttributes<HTMLButtonElement> & PropsWithChildren<DropdownToggleProps>) => import("react/jsx-runtime").JSX.Element;
|
|
208
|
+
export declare const AccordionExpandIcon: ({ children, ...props }: HTMLAttributes<HTMLDivElement> & PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
|
|
209
|
+
export declare const AccordionCollapseIcon: ({ children, ...props }: HTMLAttributes<HTMLDivElement> & PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
|
package/components/Accordion.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import isDeepEqual from 'fast-deep-equal/react';
|
|
4
4
|
import { forwardRef, useEffect, useRef } from 'react';
|
|
5
5
|
import { Each } from '../operators/Each.js';
|
|
6
|
-
import { asStyleDict, cloneStyledElement, styles } from '../utils/index.js';
|
|
6
|
+
import { asComponentDict, asStyleDict, cloneStyledElement, styles } from '../utils/index.js';
|
|
7
7
|
import { Collection } from './Collection.js';
|
|
8
|
-
import { FlatSVG } from './FlatSVG.js';
|
|
9
8
|
/**
|
|
10
9
|
* A collection of selectable items laid out in sections in an accordion. Items
|
|
11
10
|
* are generated based on the provided `ItemComponent` while each section header
|
|
12
11
|
* is optionally provided by `HeaderComponent` or generated automatically.
|
|
13
12
|
*/
|
|
14
|
-
export const Accordion = forwardRef(({ children, style, autoCollapseSections = false,
|
|
13
|
+
export const Accordion = forwardRef(({ children, style, autoCollapseSections = false, expandedSectionIndices: externalExpandedSectionIndices, orientation = 'vertical', sectionPadding = 0, sections, selection: externalSelection, selectionMode = 'single', onActivateAt, onCollapseSectionAt, onDeselectAt, onExpandedSectionsChange, onExpandSectionAt, onHeaderCustomEvent, onItemCustomEvent, onSelectAt, onSelectionChange, HeaderComponent, ItemComponent, ...props }, ref) => {
|
|
15
14
|
const isSectionIndexOutOfRange = (sectionIndex) => {
|
|
16
15
|
if (sectionIndex >= sections.length)
|
|
17
16
|
return true;
|
|
@@ -119,9 +118,13 @@ export const Accordion = forwardRef(({ children, style, autoCollapseSections = f
|
|
|
119
118
|
const selection = sanitizeSelection(externalSelection ?? {});
|
|
120
119
|
const expandedSectionIndices = sanitizeExpandedSectionIndices(externalExpandedSectionIndices ?? []);
|
|
121
120
|
const fixedStyles = getFixedStyles({ orientation });
|
|
122
|
-
const defaultStyles = usesDefaultStyles ? getDefaultStyles({ orientation }) : undefined;
|
|
123
121
|
const prevSelectionRef = useRef();
|
|
124
122
|
const prevSelection = prevSelectionRef.current;
|
|
123
|
+
const components = asComponentDict(children, {
|
|
124
|
+
collapseIcon: AccordionCollapseIcon,
|
|
125
|
+
expandIcon: AccordionExpandIcon,
|
|
126
|
+
header: AccordionHeader,
|
|
127
|
+
});
|
|
125
128
|
useEffect(() => {
|
|
126
129
|
prevSelectionRef.current = selection;
|
|
127
130
|
if (prevSelection === undefined)
|
|
@@ -134,15 +137,15 @@ export const Accordion = forwardRef(({ children, style, autoCollapseSections = f
|
|
|
134
137
|
const numVisible = maxVisible < 0 ? allVisible : Math.min(allVisible, maxVisible);
|
|
135
138
|
const maxLength = itemLength * numVisible + itemPadding * (numVisible - 1);
|
|
136
139
|
const isCollapsed = !isSectionExpandedAt(sectionIndex);
|
|
137
|
-
const expandIconComponent = expandIconSvg ? _jsx(FlatSVG, { style: defaultStyles?.expandIcon, svg: expandIconSvg }) : _jsx(_Fragment, {});
|
|
138
|
-
const collapseIconComponent = collapseIconSvg ? _jsx(FlatSVG, { style: defaultStyles?.collapseIcon, svg: collapseIconSvg }) : expandIconComponent;
|
|
139
140
|
return (_jsxs("div", { style: styles(fixedStyles.section, orientation === 'vertical' ? {
|
|
140
141
|
marginTop: sectionIndex === 0 ? '0px' : `${sectionPadding}px`,
|
|
141
142
|
} : {
|
|
142
143
|
marginLeft: sectionIndex === 0 ? '0px' : `${sectionPadding}px`,
|
|
143
|
-
}), children: [HeaderComponent ? (_jsx(HeaderComponent, { className: clsx({ collapsed: isCollapsed, expanded: !isCollapsed }), "data-child": 'header', index: sectionIndex, isCollapsed: isCollapsed, section: section, style: styles(fixedStyles.header), onClick: () => toggleSectionAt(sectionIndex), onCustomEvent: (name, info) => onHeaderCustomEvent?.(sectionIndex, name, info) })) : (
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
}), children: [HeaderComponent ? (_jsx(HeaderComponent, { className: clsx({ collapsed: isCollapsed, expanded: !isCollapsed }), "data-child": 'header', index: sectionIndex, isCollapsed: isCollapsed, section: section, style: styles(fixedStyles.header), onClick: () => toggleSectionAt(sectionIndex), onCustomEvent: (name, info) => onHeaderCustomEvent?.(sectionIndex, name, info) })) : (cloneStyledElement(components.header ?? _jsx(AccordionHeader, {}), {
|
|
145
|
+
className: clsx({ collapsed: isCollapsed, expanded: !isCollapsed }),
|
|
146
|
+
style: styles(fixedStyles.header),
|
|
147
|
+
onClick: () => toggleSectionAt(sectionIndex),
|
|
148
|
+
}, _jsx("span", { dangerouslySetInnerHTML: { __html: section.label } }), isCollapsed ? components.collapseIcon ?? components.expandIcon : components.expandIcon)), _jsx(Collection, { className: clsx({ collapsed: isCollapsed, expanded: !isCollapsed }), "data-child": 'collection', isSelectionTogglable: isSelectionTogglable, ItemComponent: ItemComponent, itemLength: itemLength, itemPadding: itemPadding, items: items, layout: layout, numSegments: numSegments, orientation: orientation, selection: selection[sectionIndex] ?? [], selectionMode: selectionMode, style: styles(orientation === 'vertical' ? {
|
|
146
149
|
width: '100%',
|
|
147
150
|
height: isCollapsed ? '0px' : `${maxLength}px`,
|
|
148
151
|
marginTop: isCollapsed ? '0px' : `${collectionPadding}px`,
|
|
@@ -163,7 +166,9 @@ export const Accordion = forwardRef(({ children, style, autoCollapseSections = f
|
|
|
163
166
|
} })] }));
|
|
164
167
|
} }) }));
|
|
165
168
|
});
|
|
166
|
-
|
|
169
|
+
export const AccordionHeader = ({ children, ...props }) => (_jsx("button", { ...props, "data-child": 'header', children: children }));
|
|
170
|
+
export const AccordionExpandIcon = ({ children, ...props }) => (_jsx("figure", { ...props, "data-child": 'expand-icon', children: children }));
|
|
171
|
+
export const AccordionCollapseIcon = ({ children, ...props }) => (_jsx("figure", { ...props, "data-child": 'collapse-icon', children: children }));
|
|
167
172
|
function sortIndices(indices) {
|
|
168
173
|
return indices.sort((a, b) => a - b);
|
|
169
174
|
}
|
|
@@ -199,7 +204,6 @@ function getFixedStyles({ orientation = 'vertical' }) {
|
|
|
199
204
|
height: '100%',
|
|
200
205
|
},
|
|
201
206
|
},
|
|
202
|
-
list: {},
|
|
203
207
|
header: {
|
|
204
208
|
cursor: 'pointer',
|
|
205
209
|
margin: '0',
|
|
@@ -209,77 +213,6 @@ function getFixedStyles({ orientation = 'vertical' }) {
|
|
|
209
213
|
height: '100%',
|
|
210
214
|
},
|
|
211
215
|
},
|
|
212
|
-
expandIcon: {
|
|
213
|
-
margin: '0',
|
|
214
|
-
padding: '0',
|
|
215
|
-
},
|
|
216
|
-
collapseIcon: {
|
|
217
|
-
margin: '0',
|
|
218
|
-
padding: '0',
|
|
219
|
-
},
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
function getDefaultStyles({ orientation = 'vertical' }) {
|
|
223
|
-
return asStyleDict({
|
|
224
|
-
collection: {
|
|
225
|
-
transitionDuration: '100ms',
|
|
226
|
-
transitionTimingFunction: 'ease-out',
|
|
227
|
-
...orientation === 'vertical' ? {
|
|
228
|
-
transitionProperty: 'height, margin',
|
|
229
|
-
} : {
|
|
230
|
-
transitionProperty: 'width, margin',
|
|
231
|
-
},
|
|
232
|
-
},
|
|
233
|
-
header: {
|
|
234
|
-
border: 'none',
|
|
235
|
-
outline: 'none',
|
|
236
|
-
alignItems: 'center',
|
|
237
|
-
background: '#fff',
|
|
238
|
-
boxSizing: 'border-box',
|
|
239
|
-
display: 'flex',
|
|
240
|
-
flexDirection: 'row',
|
|
241
|
-
justifyContent: 'space-between',
|
|
242
|
-
padding: '0 10px',
|
|
243
|
-
transitionDuration: '100ms',
|
|
244
|
-
transitionProperty: 'transform, opacity, background, color',
|
|
245
|
-
transitionTimingFunction: 'ease-out',
|
|
246
|
-
...orientation === 'vertical' ? {
|
|
247
|
-
height: '50px',
|
|
248
|
-
} : {
|
|
249
|
-
width: '50px',
|
|
250
|
-
},
|
|
251
|
-
},
|
|
252
|
-
headerLabel: {
|
|
253
|
-
color: 'inherit',
|
|
254
|
-
fontFamily: 'inherit',
|
|
255
|
-
fontSize: 'inherit',
|
|
256
|
-
fontWeight: 'inherit',
|
|
257
|
-
letterSpacing: 'inherit',
|
|
258
|
-
lineHeight: 'inherit',
|
|
259
|
-
pointerEvents: 'none',
|
|
260
|
-
transition: 'inherit',
|
|
261
|
-
},
|
|
262
|
-
expandIcon: {
|
|
263
|
-
boxSizing: 'border-box',
|
|
264
|
-
display: 'block',
|
|
265
|
-
fill: '#000',
|
|
266
|
-
height: '15px',
|
|
267
|
-
transformOrigin: 'center',
|
|
268
|
-
transitionDuration: '100ms',
|
|
269
|
-
transitionProperty: 'transform',
|
|
270
|
-
transitionTimingFunction: 'ease-out',
|
|
271
|
-
width: '15px',
|
|
272
|
-
},
|
|
273
|
-
collapseIcon: {
|
|
274
|
-
boxSizing: 'border-box',
|
|
275
|
-
display: 'block',
|
|
276
|
-
fill: '#000',
|
|
277
|
-
height: '15px',
|
|
278
|
-
transformOrigin: 'center',
|
|
279
|
-
transitionDuration: '100ms',
|
|
280
|
-
transitionProperty: 'transform',
|
|
281
|
-
transitionTimingFunction: 'ease-out',
|
|
282
|
-
width: '15px',
|
|
283
|
-
},
|
|
284
216
|
});
|
|
285
217
|
}
|
|
218
|
+
Object.defineProperty(Accordion, 'displayName', { value: 'Accordion', writable: false });
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type HTMLAttributes, type PropsWithChildren } from 'react';
|
|
2
|
+
export type BurgerButtonProps = HTMLAttributes<HTMLButtonElement> & PropsWithChildren<{
|
|
3
|
+
isActive?: boolean;
|
|
4
|
+
isSplit?: boolean;
|
|
5
|
+
isTailHidden?: boolean;
|
|
6
|
+
onActivate?: () => void;
|
|
7
|
+
onDeactivate?: () => void;
|
|
8
|
+
onToggle?: (isActive: boolean) => void;
|
|
9
|
+
}>;
|
|
10
|
+
/**
|
|
11
|
+
* Three-striped burger button component that transforms into an "X" when
|
|
12
|
+
* selected.
|
|
13
|
+
*
|
|
14
|
+
* @exports BurgerButtonBar Component for each bar in the burger button.
|
|
15
|
+
*/
|
|
16
|
+
export declare const BurgerButton: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLButtonElement> & {
|
|
17
|
+
isActive?: boolean;
|
|
18
|
+
isSplit?: boolean;
|
|
19
|
+
isTailHidden?: boolean;
|
|
20
|
+
onActivate?: () => void;
|
|
21
|
+
onDeactivate?: () => void;
|
|
22
|
+
onToggle?: (isActive: boolean) => void;
|
|
23
|
+
} & {
|
|
24
|
+
children?: import("react").ReactNode | undefined;
|
|
25
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
26
|
+
export declare const BurgerButtonBar: ({ ...props }: HTMLAttributes<HTMLSpanElement>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import { forwardRef
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
4
|
import { Repeat } from '../operators/Repeat.js';
|
|
5
5
|
import { asClassNameDict, asComponentDict, asStyleDict, cloneStyledElement, styles } from '../utils/index.js';
|
|
6
6
|
/**
|
|
7
7
|
* Three-striped burger button component that transforms into an "X" when
|
|
8
8
|
* selected.
|
|
9
9
|
*
|
|
10
|
-
* @exports BurgerButtonBar Component for each
|
|
10
|
+
* @exports BurgerButtonBar Component for each bar in the burger button.
|
|
11
11
|
*/
|
|
12
|
-
export const BurgerButton = forwardRef(({ children, className, style,
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
if (isActive === externalIsActive)
|
|
16
|
-
return;
|
|
17
|
-
setIsActive(externalIsActive);
|
|
18
|
-
}, [externalIsActive]);
|
|
19
|
-
useEffect(() => {
|
|
12
|
+
export const BurgerButton = forwardRef(({ children, className, style, isActive = false, isTailHidden = false, isSplit = false, onActivate, onDeactivate, onToggle, ...props }, ref) => {
|
|
13
|
+
const onClick = () => {
|
|
14
|
+
onToggle?.(isActive);
|
|
20
15
|
if (isActive) {
|
|
21
|
-
|
|
16
|
+
onDeactivate?.();
|
|
22
17
|
}
|
|
23
18
|
else {
|
|
24
|
-
|
|
19
|
+
onActivate?.();
|
|
25
20
|
}
|
|
26
|
-
}
|
|
21
|
+
};
|
|
27
22
|
const components = asComponentDict(children, {
|
|
28
23
|
bar: BurgerButtonBar,
|
|
29
24
|
});
|
|
@@ -35,30 +30,25 @@ export const BurgerButton = forwardRef(({ children, className, style, height = 2
|
|
|
35
30
|
active: isActive,
|
|
36
31
|
}),
|
|
37
32
|
});
|
|
38
|
-
const fixedStyles = getFixedStyles({
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
'style': styles(fixedStyles.bar, fixedStyles[`bar${j}${i}`]),
|
|
43
|
-
'data-index': i,
|
|
33
|
+
const fixedStyles = getFixedStyles({ isSplit, isActive, isTailHidden });
|
|
34
|
+
return (_jsx("button", { ...props, ref: ref, className: clsx(className, fixedClassNames.root), "data-component": 'burger-button', style: styles(style, fixedStyles.root), onClick: onClick, children: _jsx(Repeat, { count: isSplit ? 2 : 1, children: j => (_jsx("div", { "data-child": 'joint', style: styles(fixedStyles.joint, fixedStyles[`joint${j}`]), children: _jsx(Repeat, { count: 3, children: i => cloneStyledElement(components.bar ?? _jsx(BurgerButtonBar, {}), {
|
|
35
|
+
className: clsx(fixedClassNames.bar),
|
|
36
|
+
style: styles(fixedStyles.bar, fixedStyles[`bar${j}${i}`]),
|
|
44
37
|
}) }) })) }) }));
|
|
45
38
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
function getFixedStyles({ height = 0, width = 0, isDoubleJointed = false, thickness = 0, isActive = false, isLastBarHalfWidth = false }) {
|
|
39
|
+
export const BurgerButtonBar = ({ ...props }) => (_jsx("span", { ...props, "data-child": 'bar' }));
|
|
40
|
+
function getFixedStyles({ isActive = false, isSplit = false, isTailHidden = false }) {
|
|
49
41
|
return asStyleDict({
|
|
50
42
|
root: {
|
|
51
43
|
background: 'transparent',
|
|
52
44
|
border: 'none',
|
|
53
45
|
display: 'block',
|
|
54
|
-
height: `${height}px`,
|
|
55
46
|
outline: 'none',
|
|
56
|
-
width: `${width}px`,
|
|
57
47
|
},
|
|
58
48
|
joint: {
|
|
59
49
|
height: '100%',
|
|
60
50
|
position: 'absolute',
|
|
61
|
-
width:
|
|
51
|
+
width: isSplit ? '50%' : '100%',
|
|
62
52
|
},
|
|
63
53
|
joint0: {
|
|
64
54
|
left: '0',
|
|
@@ -69,7 +59,6 @@ function getFixedStyles({ height = 0, width = 0, isDoubleJointed = false, thickn
|
|
|
69
59
|
top: '0',
|
|
70
60
|
},
|
|
71
61
|
bar: {
|
|
72
|
-
height: `${thickness}px`,
|
|
73
62
|
margin: '0',
|
|
74
63
|
padding: '0',
|
|
75
64
|
position: 'absolute',
|
|
@@ -77,51 +66,42 @@ function getFixedStyles({ height = 0, width = 0, isDoubleJointed = false, thickn
|
|
|
77
66
|
},
|
|
78
67
|
bar00: {
|
|
79
68
|
left: '0',
|
|
80
|
-
top: '0',
|
|
81
|
-
transform: isActive ?
|
|
82
|
-
transformOrigin:
|
|
69
|
+
top: isActive ? '50%' : '0',
|
|
70
|
+
transform: isActive ? 'translate(0, -50%) rotate(45deg)' : 'translate(0, 0) rotate(0deg)',
|
|
71
|
+
transformOrigin: isSplit ? 'right center' : 'center',
|
|
83
72
|
},
|
|
84
73
|
bar01: {
|
|
85
74
|
left: '0',
|
|
86
|
-
top:
|
|
87
|
-
transform: isActive ? '
|
|
88
|
-
transformOrigin:
|
|
75
|
+
top: '50%',
|
|
76
|
+
transform: isActive ? 'translate(0, -50%) scale(0)' : 'translate(0, -50%) scale(1)',
|
|
77
|
+
transformOrigin: isSplit ? 'right center' : 'center',
|
|
89
78
|
},
|
|
90
79
|
bar02: {
|
|
91
80
|
left: '0',
|
|
92
|
-
top:
|
|
93
|
-
transform: isActive ?
|
|
94
|
-
transformOrigin:
|
|
95
|
-
width: isActive ||
|
|
81
|
+
top: isActive ? '50%' : '100%',
|
|
82
|
+
transform: isActive ? 'translate(0, -50%) rotate(-45deg)' : 'translate(0, -100%) rotate(0deg)',
|
|
83
|
+
transformOrigin: isSplit ? 'right center' : 'center',
|
|
84
|
+
width: isActive || isSplit ? '100%' : `${isTailHidden ? '50%' : '100%'}`,
|
|
96
85
|
},
|
|
97
86
|
bar10: {
|
|
98
87
|
left: '0',
|
|
99
|
-
top: '0',
|
|
100
|
-
transform: isActive ?
|
|
88
|
+
top: isActive ? '50%' : '0',
|
|
89
|
+
transform: isActive ? 'translate(0, -50%) rotate(-45deg)' : 'translate(0, 0) rotate(0deg)',
|
|
101
90
|
transformOrigin: 'left center',
|
|
102
91
|
},
|
|
103
92
|
bar11: {
|
|
104
93
|
left: '0',
|
|
105
|
-
top:
|
|
106
|
-
transform: isActive ? '
|
|
94
|
+
top: '50%',
|
|
95
|
+
transform: isActive ? 'translate(0, -50%) scale(0)' : 'translate(0, -50%) scale(1)',
|
|
107
96
|
transformOrigin: 'left center',
|
|
108
97
|
},
|
|
109
98
|
bar12: {
|
|
110
99
|
left: '0',
|
|
111
|
-
top:
|
|
112
|
-
transform: isActive ?
|
|
100
|
+
top: isActive ? '50%' : '100%',
|
|
101
|
+
transform: isActive ? 'translate(0, -50%) rotate(45deg)' : 'translate(0, -100%) rotate(0deg)',
|
|
113
102
|
transformOrigin: 'left center',
|
|
114
|
-
width:
|
|
115
|
-
},
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
function getDefaultStyles() {
|
|
119
|
-
return asStyleDict({
|
|
120
|
-
bar: {
|
|
121
|
-
background: '#fff',
|
|
122
|
-
transitionDuration: '100ms',
|
|
123
|
-
transitionProperty: 'width, height, transform, opacity, background',
|
|
124
|
-
transitionTimingFunction: 'ease-out',
|
|
103
|
+
width: isTailHidden && !isActive ? '0' : '100%',
|
|
125
104
|
},
|
|
126
105
|
});
|
|
127
106
|
}
|
|
107
|
+
Object.defineProperty(BurgerButton, 'displayName', { value: 'BurgerButton', writable: false });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HTMLAttributes, PropsWithChildren } from 'react';
|
|
2
|
+
export type ButtonProps = HTMLAttributes<HTMLElement> & PropsWithChildren<{
|
|
3
|
+
href?: string;
|
|
4
|
+
isDisabled?: boolean;
|
|
5
|
+
label?: string;
|
|
6
|
+
opensInNewTab?: boolean;
|
|
7
|
+
to?: string;
|
|
8
|
+
type?: HTMLButtonElement['type'];
|
|
9
|
+
}>;
|
|
10
|
+
export declare function Button({ children, className, href, isDisabled, label, opensInNewTab, to, type, ...props }: ButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { Link } from 'react-router-dom';
|
|
4
|
+
export function Button({ children, className, href, isDisabled = false, label, opensInNewTab, to, type, ...props }) {
|
|
5
|
+
if (href) {
|
|
6
|
+
return (_jsx("a", { ...props, className: clsx(className, { disabled: isDisabled }), "data-component": 'button', href: href, rel: opensInNewTab ? 'noopener,noreferrer' : undefined, target: opensInNewTab ? '_blank' : undefined, children: children ?? label }));
|
|
7
|
+
}
|
|
8
|
+
else if (to) {
|
|
9
|
+
return (_jsx(Link, { ...props, className: clsx(className, { disabled: isDisabled }), "data-component": 'button', to: to, children: children ?? label }));
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
return (_jsx("button", { ...props, className: className, "data-component": 'button', disabled: isDisabled, type: type, children: children ?? label }));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(Button, 'displayName', { value: 'Button', writable: false });
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type ComponentType, type ForwardedRef, type HTMLAttributes, type ReactElement } from 'react';
|
|
2
|
+
export type CarouselOrientation = 'horizontal' | 'vertical';
|
|
3
|
+
export type CarouselProps<I> = HTMLAttributes<HTMLElement> & {
|
|
4
|
+
/**
|
|
5
|
+
* Current item index.
|
|
6
|
+
*/
|
|
7
|
+
index?: number;
|
|
8
|
+
/**
|
|
9
|
+
* The interval in milliseconds to wait before automatically advancing to the
|
|
10
|
+
* next item (auto loops).
|
|
11
|
+
*/
|
|
12
|
+
autoAdvanceInterval?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the carousel is draggable.
|
|
15
|
+
*/
|
|
16
|
+
isDragEnabled?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Props for each item component
|
|
19
|
+
*/
|
|
20
|
+
items?: Omit<I, 'exposure'>[];
|
|
21
|
+
/**
|
|
22
|
+
* Orientation of the carousel.
|
|
23
|
+
*/
|
|
24
|
+
orientation?: CarouselOrientation;
|
|
25
|
+
/**
|
|
26
|
+
* Whether to track item exposure (0-1, 0 meaning the item is fully scrolled
|
|
27
|
+
* out of view, 1 meaning the item is fully scrolled into view).
|
|
28
|
+
*/
|
|
29
|
+
tracksItemExposure?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Handler invoked when auto advance pauses. This is invoked only when
|
|
32
|
+
* {@link autoAdvanceInterval} is greater than 0.
|
|
33
|
+
*/
|
|
34
|
+
onAutoAdvancePause?: () => void;
|
|
35
|
+
/**
|
|
36
|
+
* Handler invoked when auto advance resumes. This is invoked only when
|
|
37
|
+
* {@link autoAdvanceInterval} is greater than 0.
|
|
38
|
+
*/
|
|
39
|
+
onAutoAdvanceResume?: () => void;
|
|
40
|
+
/**
|
|
41
|
+
* Handler invoked when the item index changes.
|
|
42
|
+
*
|
|
43
|
+
* @param index The item index.
|
|
44
|
+
*/
|
|
45
|
+
onIndexChange?: (index: number) => void;
|
|
46
|
+
/**
|
|
47
|
+
* The component to render for each item.
|
|
48
|
+
*/
|
|
49
|
+
ItemComponent: ComponentType<I>;
|
|
50
|
+
};
|
|
51
|
+
export declare const Carousel: <I extends HTMLAttributes<HTMLElement>>(props: CarouselProps<I> & {
|
|
52
|
+
ref?: ForwardedRef<HTMLDivElement>;
|
|
53
|
+
}) => ReactElement;
|