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