etudes 1.2.0 → 2.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/README.md +1 -1
- package/lib/Accordion.d.ts +80 -71
- package/lib/Accordion.js +173 -183
- package/lib/Accordion.js.map +1 -1
- package/lib/BurgerButton.d.ts +20 -7
- package/lib/BurgerButton.js +113 -20
- package/lib/BurgerButton.js.map +1 -1
- package/lib/Conditional.d.ts +2 -3
- package/lib/Conditional.js +0 -1
- package/lib/Conditional.js.map +1 -1
- package/lib/DebugConsole.d.ts +14 -23
- package/lib/DebugConsole.js +86 -87
- package/lib/DebugConsole.js.map +1 -1
- package/lib/Dial.d.ts +53 -16
- package/lib/Dial.js +121 -35
- package/lib/Dial.js.map +1 -1
- package/lib/Dropdown.d.ts +68 -83
- package/lib/Dropdown.js +226 -161
- package/lib/Dropdown.js.map +1 -1
- package/lib/Each.d.ts +2 -2
- package/lib/Each.js.map +1 -1
- package/lib/ExtractChild.d.ts +5 -4
- package/lib/ExtractChild.js +13 -11
- package/lib/ExtractChild.js.map +1 -1
- package/lib/ExtractChildren.d.ts +2 -2
- package/lib/ExtractChildren.js +7 -5
- package/lib/ExtractChildren.js.map +1 -1
- package/lib/FlatSVG.d.ts +30 -25
- package/lib/FlatSVG.js +28 -37
- package/lib/FlatSVG.js.map +1 -1
- package/lib/List.d.ts +97 -54
- package/lib/List.js +124 -63
- package/lib/List.js.map +1 -1
- package/lib/MasonryGrid.d.ts +27 -15
- package/lib/MasonryGrid.js +163 -148
- package/lib/MasonryGrid.js.map +1 -1
- package/lib/Panorama.d.ts +100 -21
- package/lib/Panorama.js +45 -44
- package/lib/Panorama.js.map +1 -1
- package/lib/PanoramaSlider.d.ts +65 -23
- package/lib/PanoramaSlider.js +150 -45
- package/lib/PanoramaSlider.js.map +1 -1
- package/lib/RangeSlider.d.ts +29 -89
- package/lib/RangeSlider.js +272 -286
- package/lib/RangeSlider.js.map +1 -1
- package/lib/Repeat.d.ts +4 -3
- package/lib/Repeat.js +3 -2
- package/lib/Repeat.js.map +1 -1
- package/lib/RotatingGallery.d.ts +38 -36
- package/lib/RotatingGallery.js +47 -17
- package/lib/RotatingGallery.js.map +1 -1
- package/lib/SelectableButton.d.ts +13 -4
- package/lib/SelectableButton.js +3 -14
- package/lib/SelectableButton.js.map +1 -1
- package/lib/Slider.d.ts +103 -41
- package/lib/Slider.js +182 -82
- package/lib/Slider.js.map +1 -1
- package/lib/StepwiseSlider.d.ts +146 -59
- package/lib/StepwiseSlider.js +248 -142
- package/lib/StepwiseSlider.js.map +1 -1
- package/lib/SwipeContainer.d.ts +13 -5
- package/lib/SwipeContainer.js +5 -15
- package/lib/SwipeContainer.js.map +1 -1
- package/lib/TextField.d.ts +1 -1
- package/lib/TextField.js +5 -15
- package/lib/TextField.js.map +1 -1
- package/lib/Video.d.ts +30 -51
- package/lib/Video.js +77 -119
- package/lib/Video.js.map +1 -1
- package/lib/WithTooltip.d.ts +16 -18
- package/lib/WithTooltip.js +167 -101
- package/lib/WithTooltip.js.map +1 -1
- package/lib/hooks/useDocumentTitle.d.ts +2 -1
- package/lib/hooks/useDocumentTitle.js +2 -1
- package/lib/hooks/useDocumentTitle.js.map +1 -1
- package/lib/hooks/useDragEffect.d.ts +25 -16
- package/lib/hooks/useDragEffect.js +30 -20
- package/lib/hooks/useDragEffect.js.map +1 -1
- package/lib/hooks/useElementRect.d.ts +2 -1
- package/lib/hooks/useElementRect.js +5 -4
- package/lib/hooks/useElementRect.js.map +1 -1
- package/lib/hooks/useInterval.d.ts +2 -2
- package/lib/hooks/useInterval.js +1 -1
- package/lib/hooks/useInterval.js.map +1 -1
- package/lib/hooks/useLoadImageEffect.d.ts +6 -6
- package/lib/hooks/useLoadImageEffect.js.map +1 -1
- package/lib/hooks/usePrevious.d.ts +6 -0
- package/lib/hooks/usePrevious.js +17 -0
- package/lib/hooks/usePrevious.js.map +1 -0
- package/lib/hooks/useResizeEffect.d.ts +2 -2
- package/lib/hooks/useResizeEffect.js +5 -8
- package/lib/hooks/useResizeEffect.js.map +1 -1
- package/lib/hooks/useSearchParamState.d.ts +10 -7
- package/lib/hooks/useSearchParamState.js +14 -10
- package/lib/hooks/useSearchParamState.js.map +1 -1
- package/lib/utils/asClassNameDict.d.ts +3 -0
- package/lib/utils/asClassNameDict.js +7 -0
- package/lib/utils/asClassNameDict.js.map +1 -0
- package/lib/utils/asComponentDict.d.ts +5 -0
- package/lib/utils/asComponentDict.js +23 -0
- package/lib/utils/asComponentDict.js.map +1 -0
- package/lib/utils/asStyleDict.d.ts +4 -0
- package/lib/utils/asStyleDict.js +7 -0
- package/lib/utils/asStyleDict.js.map +1 -0
- package/lib/utils/cloneStyledElement.d.ts +18 -0
- package/lib/utils/cloneStyledElement.js +63 -0
- package/lib/utils/cloneStyledElement.js.map +1 -0
- package/lib/utils/styles.d.ts +2 -0
- package/lib/utils/styles.js +22 -0
- package/lib/utils/styles.js.map +1 -0
- package/lib/utils/useDebug.d.ts +2 -0
- package/lib/utils/useDebug.js +46 -0
- package/lib/utils/useDebug.js.map +1 -0
- package/package.json +25 -33
- package/lib/AbstractSelectableCollection.d.ts +0 -94
- package/lib/AbstractSelectableCollection.js +0 -151
- package/lib/AbstractSelectableCollection.js.map +0 -1
- package/lib/types/index.d.ts +0 -7
- package/lib/types/index.js +0 -3
- package/lib/types/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
# Études [](https://www.npmjs.com/package/etudes) [](https://github.com/andrewscwei/etudes/actions?query=workflow%3ACI) [](https://github.com/andrewscwei/etudes/actions?query=workflow%3ACD)
|
|
2
2
|
|
|
3
|
-
A study of
|
|
3
|
+
A study of headless React components.
|
package/lib/Accordion.d.ts
CHANGED
|
@@ -1,38 +1,16 @@
|
|
|
1
|
-
import React, { ComponentType,
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* component. The data type is generic.
|
|
7
|
-
*/
|
|
8
|
-
export declare type ItemComponentProps<T = Record<string, never>> = ListItemComponentProps<T>;
|
|
9
|
-
export declare type SectionHeaderCSSProps = Readonly<{
|
|
10
|
-
borderColor: string;
|
|
11
|
-
borderThickness: number;
|
|
12
|
-
isCollapsed: boolean;
|
|
13
|
-
orientation: Orientation;
|
|
14
|
-
}>;
|
|
15
|
-
export declare type SectionCSSProps = Readonly<{
|
|
16
|
-
isCollapsed: boolean;
|
|
17
|
-
orientation: Orientation;
|
|
18
|
-
}>;
|
|
19
|
-
export interface SectionProps<T = Record<string, never>> {
|
|
1
|
+
import React, { ComponentType, HTMLAttributes, PropsWithChildren, ReactElement, Ref } from 'react';
|
|
2
|
+
import { ListItemProps } from './List';
|
|
3
|
+
declare type Orientation = 'horizontal' | 'vertical';
|
|
4
|
+
export declare type AccordionItemProps<T> = ListItemProps<T>;
|
|
5
|
+
export declare type SectionData<T> = {
|
|
20
6
|
label: string;
|
|
21
7
|
items: T[];
|
|
22
|
-
}
|
|
23
|
-
export
|
|
24
|
-
/**
|
|
25
|
-
* Class attribute to the root element.
|
|
26
|
-
*/
|
|
27
|
-
className?: string;
|
|
28
|
-
/**
|
|
29
|
-
* Inline style attribute to the element.
|
|
30
|
-
*/
|
|
31
|
-
style?: CSSProperties;
|
|
8
|
+
};
|
|
9
|
+
export declare type AccordionProps<T> = HTMLAttributes<HTMLDivElement> & PropsWithChildren<{
|
|
32
10
|
/**
|
|
33
11
|
* Data provided to each section.
|
|
34
12
|
*/
|
|
35
|
-
data:
|
|
13
|
+
data: SectionData<T>[];
|
|
36
14
|
/**
|
|
37
15
|
* Indicates if sections can be toggled, as in, once a section is expanded,
|
|
38
16
|
* it collapses when being selected again.
|
|
@@ -42,7 +20,7 @@ export interface Props<T = Record<string, never>> {
|
|
|
42
20
|
* Index of the section that is selected by default. Any value less than 0
|
|
43
21
|
* indicates that no section is selected by default.
|
|
44
22
|
*/
|
|
45
|
-
|
|
23
|
+
defaultExpandedSectionIndex?: number;
|
|
46
24
|
/**
|
|
47
25
|
* Length (in pixels) of each item. This does not apply to the section hedaer
|
|
48
26
|
* itself. Length refers to the height in vertical orientation and width in
|
|
@@ -69,10 +47,6 @@ export interface Props<T = Record<string, never>> {
|
|
|
69
47
|
* Orientation of the component.
|
|
70
48
|
*/
|
|
71
49
|
orientation?: Orientation;
|
|
72
|
-
/**
|
|
73
|
-
* Color of the border of every item and the section header itself.
|
|
74
|
-
*/
|
|
75
|
-
borderColor?: string;
|
|
76
50
|
/**
|
|
77
51
|
* Thickness of the border (in pixels) of every item and the section header
|
|
78
52
|
* itself. 0 indicates no borders.
|
|
@@ -85,7 +59,7 @@ export interface Props<T = Record<string, never>> {
|
|
|
85
59
|
/**
|
|
86
60
|
* React component type to be used for generating items inside the component.
|
|
87
61
|
*/
|
|
88
|
-
itemComponentType: ComponentType<
|
|
62
|
+
itemComponentType: ComponentType<AccordionItemProps<T>>;
|
|
89
63
|
/**
|
|
90
64
|
* Handler invoked when the selected item index of any section changes.
|
|
91
65
|
*/
|
|
@@ -94,39 +68,74 @@ export interface Props<T = Record<string, never>> {
|
|
|
94
68
|
* Handler invoked when the selected section index changes.
|
|
95
69
|
*/
|
|
96
70
|
onSectionIndexChange?: (index: number) => void;
|
|
71
|
+
}>;
|
|
72
|
+
declare const _default: <T>(props: React.HTMLAttributes<HTMLDivElement> & {
|
|
73
|
+
/**
|
|
74
|
+
* Data provided to each section.
|
|
75
|
+
*/
|
|
76
|
+
data: SectionData<T>[];
|
|
77
|
+
/**
|
|
78
|
+
* Indicates if sections can be toggled, as in, once a section is expanded,
|
|
79
|
+
* it collapses when being selected again.
|
|
80
|
+
*/
|
|
81
|
+
isTogglable?: boolean | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* Index of the section that is selected by default. Any value less than 0
|
|
84
|
+
* indicates that no section is selected by default.
|
|
85
|
+
*/
|
|
86
|
+
defaultExpandedSectionIndex?: number | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Length (in pixels) of each item. This does not apply to the section hedaer
|
|
89
|
+
* itself. Length refers to the height in vertical orientation and width in
|
|
90
|
+
* horizontal orientation.
|
|
91
|
+
*/
|
|
92
|
+
itemLength?: number | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* Padding (in pixels) between each item.
|
|
95
|
+
*/
|
|
96
|
+
itemPadding?: number | undefined;
|
|
97
97
|
/**
|
|
98
|
-
*
|
|
99
|
-
*/
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
*
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
98
|
+
* Padding (in pixels) between each section.
|
|
99
|
+
*/
|
|
100
|
+
sectionPadding?: number | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* Maximum number of items that are viside when a section expands. When a
|
|
103
|
+
* value greater than or equal to 0 is specified, only that number of items
|
|
104
|
+
* will be visible at a time, and a scrollbar will appear to scroll to
|
|
105
|
+
* remaining items. Any value less than 0 indicates that all items will be
|
|
106
|
+
* visible when a section expands.
|
|
107
|
+
*/
|
|
108
|
+
maxVisibleItems?: number | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* Orientation of the component.
|
|
111
|
+
*/
|
|
112
|
+
orientation?: Orientation | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* Thickness of the border (in pixels) of every item and the section header
|
|
115
|
+
* itself. 0 indicates no borders.
|
|
116
|
+
*/
|
|
117
|
+
borderThickness?: number | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* SVG markup to be put in the section header as the expand icon.
|
|
120
|
+
*/
|
|
121
|
+
expandIconSvg?: string | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* React component type to be used for generating items inside the component.
|
|
124
|
+
*/
|
|
125
|
+
itemComponentType: React.ComponentType<AccordionItemProps<T>>;
|
|
126
|
+
/**
|
|
127
|
+
* Handler invoked when the selected item index of any section changes.
|
|
128
|
+
*/
|
|
129
|
+
onItemIndexChange?: ((index: number) => void) | undefined;
|
|
130
|
+
/**
|
|
131
|
+
* Handler invoked when the selected section index changes.
|
|
132
|
+
*/
|
|
133
|
+
onSectionIndexChange?: ((index: number) => void) | undefined;
|
|
134
|
+
} & {
|
|
135
|
+
children?: React.ReactNode;
|
|
136
|
+
} & {
|
|
137
|
+
ref?: React.Ref<HTMLDivElement> | undefined;
|
|
138
|
+
}) => ReactElement;
|
|
139
|
+
export default _default;
|
|
140
|
+
export declare const AccordionHeader: ({ ...props }: HTMLAttributes<HTMLButtonElement>) => JSX.Element;
|
|
141
|
+
export declare const AccordionExpandIcon: ({ ...props }: HTMLAttributes<HTMLDivElement>) => JSX.Element;
|
package/lib/Accordion.js
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
18
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
19
|
-
return cooked;
|
|
20
|
-
};
|
|
21
2
|
var __assign = (this && this.__assign) || function () {
|
|
22
3
|
__assign = Object.assign || function(t) {
|
|
23
4
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -52,191 +33,200 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
52
33
|
__setModuleDefault(result, mod);
|
|
53
34
|
return result;
|
|
54
35
|
};
|
|
55
|
-
var
|
|
56
|
-
var
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
36
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
37
|
+
var t = {};
|
|
38
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
39
|
+
t[p] = s[p];
|
|
40
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
41
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
42
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
43
|
+
t[p[i]] = s[p[i]];
|
|
62
44
|
}
|
|
63
|
-
|
|
64
|
-
|
|
45
|
+
return t;
|
|
46
|
+
};
|
|
47
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
48
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
49
|
+
if (!m) return o;
|
|
50
|
+
var i = m.call(o), r, ar = [], e;
|
|
51
|
+
try {
|
|
52
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
53
|
+
}
|
|
54
|
+
catch (error) { e = { error: error }; }
|
|
55
|
+
finally {
|
|
56
|
+
try {
|
|
57
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
58
|
+
}
|
|
59
|
+
finally { if (e) throw e.error; }
|
|
60
|
+
}
|
|
61
|
+
return ar;
|
|
62
|
+
};
|
|
63
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
64
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
65
|
+
if (ar || !(i in from)) {
|
|
66
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
67
|
+
ar[i] = from[i];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
65
71
|
};
|
|
66
72
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
67
73
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
68
74
|
};
|
|
69
75
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
76
|
+
exports.AccordionExpandIcon = exports.AccordionHeader = void 0;
|
|
77
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
70
78
|
var react_1 = __importStar(require("react"));
|
|
71
|
-
var
|
|
79
|
+
var Each_1 = __importDefault(require("./Each"));
|
|
80
|
+
var FlatSVG_1 = __importDefault(require("./FlatSVG"));
|
|
72
81
|
var List_1 = __importDefault(require("./List"));
|
|
73
|
-
var
|
|
74
|
-
var
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
selectedSectionIndex: (_a = props.defaultSelectedSectionIndex) !== null && _a !== void 0 ? _a : -1,
|
|
85
|
-
selectedItemIndex: -1,
|
|
86
|
-
};
|
|
87
|
-
return _this;
|
|
88
|
-
}
|
|
89
|
-
Accordion.prototype.componentDidMount = function () {
|
|
90
|
-
var _a, _b, _c, _d;
|
|
91
|
-
(_b = (_a = this.props).onSectionIndexChange) === null || _b === void 0 ? void 0 : _b.call(_a, this.state.selectedSectionIndex);
|
|
92
|
-
(_d = (_c = this.props).onItemIndexChange) === null || _d === void 0 ? void 0 : _d.call(_c, this.state.selectedItemIndex);
|
|
93
|
-
};
|
|
94
|
-
Accordion.prototype.componentDidUpdate = function (prevProps, prevState) {
|
|
95
|
-
var _a, _b, _c, _d;
|
|
96
|
-
if (prevState.selectedSectionIndex !== this.state.selectedSectionIndex) {
|
|
97
|
-
debug("Changing section index to ".concat(this.state.selectedSectionIndex, "... OK"));
|
|
98
|
-
(_b = (_a = this.props).onSectionIndexChange) === null || _b === void 0 ? void 0 : _b.call(_a, this.state.selectedSectionIndex);
|
|
82
|
+
var asClassNameDict_1 = __importDefault(require("./utils/asClassNameDict"));
|
|
83
|
+
var asComponentDict_1 = __importDefault(require("./utils/asComponentDict"));
|
|
84
|
+
var asStyleDict_1 = __importDefault(require("./utils/asStyleDict"));
|
|
85
|
+
var cloneStyledElement_1 = __importDefault(require("./utils/cloneStyledElement"));
|
|
86
|
+
var styles_1 = __importDefault(require("./utils/styles"));
|
|
87
|
+
exports.default = (0, react_1.forwardRef)(function (_a, ref) {
|
|
88
|
+
var children = _a.children, className = _a.className, style = _a.style, _b = _a.borderThickness, borderThickness = _b === void 0 ? 0 : _b, data = _a.data, _c = _a.defaultExpandedSectionIndex, defaultExpandedSectionIndex = _c === void 0 ? -1 : _c, expandIconSvg = _a.expandIconSvg, _d = _a.isTogglable, isTogglable = _d === void 0 ? true : _d, itemComponentType = _a.itemComponentType, _e = _a.itemLength, itemLength = _e === void 0 ? 50 : _e, _f = _a.itemPadding, itemPadding = _f === void 0 ? 0 : _f, _g = _a.maxVisibleItems, maxVisibleItems = _g === void 0 ? -1 : _g, _h = _a.orientation, orientation = _h === void 0 ? 'vertical' : _h, _j = _a.sectionPadding, sectionPadding = _j === void 0 ? 0 : _j, onItemIndexChange = _a.onItemIndexChange, onSectionIndexChange = _a.onSectionIndexChange, props = __rest(_a, ["children", "className", "style", "borderThickness", "data", "defaultExpandedSectionIndex", "expandIconSvg", "isTogglable", "itemComponentType", "itemLength", "itemPadding", "maxVisibleItems", "orientation", "sectionPadding", "onItemIndexChange", "onSectionIndexChange"]);
|
|
89
|
+
var isSectionSelectedAt = function (index) { return expandedSectionIndex === index; };
|
|
90
|
+
var toggleSectionAt = function (index) {
|
|
91
|
+
if (isTogglable && isSectionSelectedAt(index)) {
|
|
92
|
+
setExpandedSectionIndex(-1);
|
|
99
93
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
(_d = (_c = this.props).onItemIndexChange) === null || _d === void 0 ? void 0 : _d.call(_c, this.state.selectedItemIndex);
|
|
94
|
+
else {
|
|
95
|
+
setExpandedSectionIndex(index);
|
|
103
96
|
}
|
|
104
97
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
98
|
+
var _k = __read((0, react_1.useState)(defaultExpandedSectionIndex), 2), expandedSectionIndex = _k[0], setExpandedSectionIndex = _k[1];
|
|
99
|
+
var _l = __read((0, react_1.useState)(-1), 2), selectedSectionIndex = _l[0], setSelectedSectionIndex = _l[1];
|
|
100
|
+
var _m = __read((0, react_1.useState)(-1), 2), selectedItemIndex = _m[0], setSelectedItemIndex = _m[1];
|
|
101
|
+
(0, react_1.useEffect)(function () {
|
|
102
|
+
onSectionIndexChange === null || onSectionIndexChange === void 0 ? void 0 : onSectionIndexChange(expandedSectionIndex);
|
|
103
|
+
}, [expandedSectionIndex]);
|
|
104
|
+
(0, react_1.useEffect)(function () {
|
|
105
|
+
onItemIndexChange === null || onItemIndexChange === void 0 ? void 0 : onItemIndexChange(selectedItemIndex);
|
|
106
|
+
}, [selectedItemIndex]);
|
|
107
|
+
var components = (0, asComponentDict_1.default)(children, {
|
|
108
|
+
header: exports.AccordionHeader,
|
|
109
|
+
expandIcon: exports.AccordionExpandIcon,
|
|
110
|
+
});
|
|
111
|
+
var fixedClassNames = (0, asClassNameDict_1.default)({
|
|
112
|
+
root: (0, classnames_1.default)(orientation),
|
|
113
|
+
header: (0, classnames_1.default)(orientation),
|
|
114
|
+
expandIcon: (0, classnames_1.default)(orientation),
|
|
115
|
+
});
|
|
116
|
+
var fixedStyles = (0, asStyleDict_1.default)({
|
|
117
|
+
root: __assign({ alignItems: 'center', boxSizing: 'border-box', display: 'flex', flex: '0 0 auto', justifyContent: 'flex-start', padding: '0' }, orientation === 'vertical' ? {
|
|
118
|
+
flexDirection: 'column',
|
|
119
|
+
height: 'auto',
|
|
120
|
+
} : {
|
|
121
|
+
flexDirection: 'row',
|
|
122
|
+
width: 'auto',
|
|
123
|
+
}),
|
|
124
|
+
section: __assign({ alignItems: 'flex-start', display: 'flex', flex: '0 0 auto', justifyContent: 'flex-start', margin: '0', padding: '0' }, orientation === 'vertical' ? {
|
|
125
|
+
flexDirection: 'column',
|
|
126
|
+
width: '100%',
|
|
127
|
+
} : {
|
|
128
|
+
flexDirection: 'row',
|
|
129
|
+
height: '100%',
|
|
130
|
+
}),
|
|
131
|
+
header: __assign({ borderWidth: "".concat(borderThickness, "px"), margin: '0', outline: 'none' }, orientation === 'vertical' ? {
|
|
132
|
+
width: '100%',
|
|
133
|
+
} : {
|
|
134
|
+
height: '100%',
|
|
135
|
+
}),
|
|
136
|
+
headerLabel: {
|
|
137
|
+
color: 'inherit',
|
|
138
|
+
fontFamily: 'inherit',
|
|
139
|
+
fontSize: 'inherit',
|
|
140
|
+
fontWeight: 'inherit',
|
|
141
|
+
letterSpacing: 'inherit',
|
|
142
|
+
lineHeight: 'inherit',
|
|
143
|
+
transition: 'inherit',
|
|
144
|
+
},
|
|
145
|
+
expandIcon: {
|
|
146
|
+
margin: '0',
|
|
147
|
+
padding: '0',
|
|
148
|
+
},
|
|
149
|
+
list: __assign({ transitionDuration: '100ms', transitionTimingFunction: 'ease-out' }, orientation === 'vertical' ? {
|
|
150
|
+
width: '100%',
|
|
151
|
+
transitionProperty: 'height, margin',
|
|
152
|
+
top: '100%',
|
|
153
|
+
} : {
|
|
154
|
+
height: '100%',
|
|
155
|
+
transitionProperty: 'width, margin',
|
|
156
|
+
left: '100%',
|
|
157
|
+
}),
|
|
158
|
+
});
|
|
159
|
+
var defaultStyles = (0, asStyleDict_1.default)({
|
|
160
|
+
header: __assign({ alignItems: 'center', background: '#fff', borderStyle: 'solid', boxSizing: 'border-box', display: 'flex', flexDirection: 'row', justifyContent: 'space-between', padding: '0 10px', transitionDuration: '100ms', transitionProperty: 'transform, opacity, background, color', transitionTimingFunction: 'ease-out' }, orientation === 'vertical' ? {
|
|
161
|
+
height: '50px',
|
|
162
|
+
} : {
|
|
163
|
+
width: '50px',
|
|
164
|
+
}),
|
|
165
|
+
expandIcon: {
|
|
166
|
+
boxSizing: 'border-box',
|
|
167
|
+
display: 'block',
|
|
168
|
+
fill: '#000',
|
|
169
|
+
height: '15px',
|
|
170
|
+
transformOrigin: 'center',
|
|
171
|
+
transitionDuration: '100ms',
|
|
172
|
+
transitionProperty: 'transform',
|
|
173
|
+
transitionTimingFunction: 'ease-out',
|
|
174
|
+
width: '15px',
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
return (react_1.default.createElement("div", __assign({}, props, { className: (0, classnames_1.default)(className, fixedClassNames.root), style: (0, styles_1.default)(style, fixedStyles.root) }),
|
|
178
|
+
react_1.default.createElement(Each_1.default, { in: data }, function (section, sectionIdx) {
|
|
122
179
|
var _a, _b;
|
|
123
180
|
var numItems = section.items.length;
|
|
124
181
|
var numVisibleItems = maxVisibleItems < 0 ? numItems : Math.min(numItems, maxVisibleItems);
|
|
125
182
|
var menuLength = (itemLength - borderThickness) * numVisibleItems + itemPadding * (numVisibleItems - 1) + borderThickness;
|
|
126
|
-
var isCollapsed = !
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return (react_1.default.createElement(StyledSection, { key: "section-".concat(i), isCollapsed: isCollapsed, orientation: orientation, extendedCSS: (_a = _this.props.sectionCSS) !== null && _a !== void 0 ? _a : (function () { return (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))); }), style: orientation === 'vertical' ? {
|
|
130
|
-
marginTop: i === 0 ? '0px' : "".concat(sectionPadding - borderThickness, "px"),
|
|
183
|
+
var isCollapsed = !isSectionSelectedAt(sectionIdx);
|
|
184
|
+
return (react_1.default.createElement("div", { style: (0, styles_1.default)(fixedStyles.section, orientation === 'vertical' ? {
|
|
185
|
+
marginTop: sectionIdx === 0 ? '0px' : "".concat(sectionPadding - borderThickness, "px"),
|
|
131
186
|
} : {
|
|
132
|
-
marginLeft:
|
|
133
|
-
} },
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
},
|
|
187
|
+
marginLeft: sectionIdx === 0 ? '0px' : "".concat(sectionPadding - borderThickness, "px"),
|
|
188
|
+
}) },
|
|
189
|
+
cloneStyledElement_1.default.apply(void 0, __spreadArray([(_a = components.header) !== null && _a !== void 0 ? _a : react_1.default.createElement(exports.AccordionHeader, { style: defaultStyles.header }), {
|
|
190
|
+
className: (0, classnames_1.default)(fixedClassNames.header, {
|
|
191
|
+
collapsed: isCollapsed,
|
|
192
|
+
expanded: !isCollapsed,
|
|
193
|
+
}),
|
|
194
|
+
style: (0, styles_1.default)(fixedStyles.header),
|
|
195
|
+
onClick: function () { return toggleSectionAt(sectionIdx); },
|
|
196
|
+
}], [
|
|
197
|
+
react_1.default.createElement("label", { style: fixedStyles.headerLabel, dangerouslySetInnerHTML: { __html: section.label } }),
|
|
198
|
+
(0, cloneStyledElement_1.default)((_b = components.expandIcon) !== null && _b !== void 0 ? _b : (expandIconSvg ? react_1.default.createElement(FlatSVG_1.default, { svg: expandIconSvg, style: defaultStyles.expandIcon }) : react_1.default.createElement(react_1.default.Fragment, null)), {
|
|
199
|
+
className: (0, classnames_1.default)(fixedClassNames.expandIcon),
|
|
200
|
+
style: (0, styles_1.default)(fixedStyles.expandIcon),
|
|
201
|
+
}),
|
|
202
|
+
], false)),
|
|
203
|
+
react_1.default.createElement(List_1.default, { style: (0, styles_1.default)(fixedStyles.list, orientation === 'vertical' ? {
|
|
142
204
|
height: isCollapsed ? '0px' : "".concat(menuLength, "px"),
|
|
143
205
|
marginTop: isCollapsed ? '0px' : "".concat(itemPadding - borderThickness, "px"),
|
|
144
|
-
overflowY:
|
|
206
|
+
overflowY: maxVisibleItems === -1 ? 'hidden' : maxVisibleItems < numItems ? 'scroll' : 'hidden',
|
|
145
207
|
} : {
|
|
146
208
|
marginLeft: isCollapsed ? '0px' : "".concat(itemPadding - borderThickness, "px"),
|
|
147
|
-
overflowX:
|
|
209
|
+
overflowX: maxVisibleItems === -1 ? 'hidden' : maxVisibleItems < numItems ? 'scroll' : 'hidden',
|
|
148
210
|
width: isCollapsed ? '0px' : "".concat(menuLength, "px"),
|
|
211
|
+
}), borderThickness: borderThickness, data: section.items, isSelectable: true, isTogglable: isTogglable, itemComponentType: itemComponentType, itemLength: itemLength, itemPadding: itemPadding, orientation: orientation, selectedIndex: selectedSectionIndex === sectionIdx ? selectedItemIndex : -1, onDeselectAt: function () {
|
|
212
|
+
if (selectedSectionIndex !== sectionIdx)
|
|
213
|
+
return;
|
|
214
|
+
setSelectedSectionIndex(-1);
|
|
215
|
+
setSelectedItemIndex(-1);
|
|
216
|
+
}, onSelectAt: function (itemIdx) {
|
|
217
|
+
setSelectedSectionIndex(sectionIdx);
|
|
218
|
+
setSelectedItemIndex(itemIdx);
|
|
149
219
|
} })));
|
|
150
220
|
})));
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
Accordion.prototype.selectSectionAt = function (index) {
|
|
165
|
-
var e_1, _a;
|
|
166
|
-
var _b;
|
|
167
|
-
if (this.isSectionSelectedAt(index))
|
|
168
|
-
return;
|
|
169
|
-
try {
|
|
170
|
-
for (var _c = __values(this.nodeRefs.lists), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
171
|
-
var ref = _d.value;
|
|
172
|
-
(_b = ref.current) === null || _b === void 0 ? void 0 : _b.setState({ selectedIndex: -1 });
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
176
|
-
finally {
|
|
177
|
-
try {
|
|
178
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
179
|
-
}
|
|
180
|
-
finally { if (e_1) throw e_1.error; }
|
|
181
|
-
}
|
|
182
|
-
this.setState({
|
|
183
|
-
selectedSectionIndex: index,
|
|
184
|
-
});
|
|
185
|
-
};
|
|
186
|
-
Accordion.prototype.deselectSectionAt = function (index) {
|
|
187
|
-
var e_2, _a;
|
|
188
|
-
var _b;
|
|
189
|
-
if (!this.isSectionSelectedAt(index))
|
|
190
|
-
return;
|
|
191
|
-
try {
|
|
192
|
-
for (var _c = __values(this.nodeRefs.lists), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
193
|
-
var ref = _d.value;
|
|
194
|
-
(_b = ref.current) === null || _b === void 0 ? void 0 : _b.setState({ selectedIndex: -1 });
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
198
|
-
finally {
|
|
199
|
-
try {
|
|
200
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
201
|
-
}
|
|
202
|
-
finally { if (e_2) throw e_2.error; }
|
|
203
|
-
}
|
|
204
|
-
this.setState({
|
|
205
|
-
selectedSectionIndex: -1,
|
|
206
|
-
});
|
|
207
|
-
};
|
|
208
|
-
Accordion.prototype.isItemSelectedAt = function (index) {
|
|
209
|
-
return (this.state.selectedItemIndex === index);
|
|
210
|
-
};
|
|
211
|
-
Accordion.prototype.toggleItemAt = function (index) {
|
|
212
|
-
var _a;
|
|
213
|
-
if (((_a = this.props.isTogglable) !== null && _a !== void 0 ? _a : true) && this.isItemSelectedAt(index)) {
|
|
214
|
-
this.deselectItemAt(index);
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
this.selectItemAt(index);
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
Accordion.prototype.selectItemAt = function (index) {
|
|
221
|
-
if (this.isItemSelectedAt(index))
|
|
222
|
-
return;
|
|
223
|
-
this.setState({
|
|
224
|
-
selectedItemIndex: index,
|
|
225
|
-
});
|
|
226
|
-
};
|
|
227
|
-
Accordion.prototype.deselectItemAt = function (index) {
|
|
228
|
-
if (!this.isItemSelectedAt(index))
|
|
229
|
-
return;
|
|
230
|
-
this.setState({
|
|
231
|
-
selectedItemIndex: -1,
|
|
232
|
-
});
|
|
233
|
-
};
|
|
234
|
-
return Accordion;
|
|
235
|
-
}(react_1.PureComponent));
|
|
236
|
-
exports.default = Accordion;
|
|
237
|
-
var StyledItemList = (0, styled_components_1.default)(List_1.default)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n transition-duration: 100ms;\n transition-timing-function: ease-out;\n\n ", "\n"], ["\n transition-duration: 100ms;\n transition-timing-function: ease-out;\n\n ", "\n"])), function (props) { return props.orientation === 'vertical' ? (0, styled_components_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n width: 100%;\n transition-property: height, margin;\n will-change: height, margin;\n top: 100%;\n "], ["\n width: 100%;\n transition-property: height, margin;\n will-change: height, margin;\n top: 100%;\n "]))) : (0, styled_components_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n height: 100%;\n transition-property: width, margin;\n will-change: width, margin;\n left: 100%;\n "], ["\n height: 100%;\n transition-property: width, margin;\n will-change: width, margin;\n left: 100%;\n "]))); });
|
|
238
|
-
var StyledSectionHeader = styled_components_1.default.button(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n align-items: center;\n background: #fff;\n border-color: ", ";\n border-style: solid;\n border-width: ", ";\n box-sizing: border-box;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n margin: 0;\n padding: 0 10px;\n transition-duration: 100ms;\n transition-property: transform, opacity, background, color;\n transition-timing-function: ease-out;\n will-change: transform, opacity, background, color;\n\n label {\n color: #000;\n transition-duration: 100ms;\n transition-property: color;\n transition-timing-function: ease-out;\n will-change: color;\n }\n\n span {\n box-sizing: border-box;\n display: block;\n fill: #000;\n height: 15px;\n transform-origin: center;\n transition-duration: 100ms;\n transition-property: transform;\n transition-timing-function: ease-out;\n width: 15px;\n will-change: transform;\n\n svg {\n width: 100%;\n height: 100%;\n fill: inherit;\n\n * {\n fill: inherit;\n transition-duration: 100ms;\n transition-property: fill;\n transition-timing-function: ease-out;\n }\n }\n }\n\n ", "\n\n ", "\n"], ["\n align-items: center;\n background: #fff;\n border-color: ", ";\n border-style: solid;\n border-width: ", ";\n box-sizing: border-box;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n margin: 0;\n padding: 0 10px;\n transition-duration: 100ms;\n transition-property: transform, opacity, background, color;\n transition-timing-function: ease-out;\n will-change: transform, opacity, background, color;\n\n label {\n color: #000;\n transition-duration: 100ms;\n transition-property: color;\n transition-timing-function: ease-out;\n will-change: color;\n }\n\n span {\n box-sizing: border-box;\n display: block;\n fill: #000;\n height: 15px;\n transform-origin: center;\n transition-duration: 100ms;\n transition-property: transform;\n transition-timing-function: ease-out;\n width: 15px;\n will-change: transform;\n\n svg {\n width: 100%;\n height: 100%;\n fill: inherit;\n\n * {\n fill: inherit;\n transition-duration: 100ms;\n transition-property: fill;\n transition-timing-function: ease-out;\n }\n }\n }\n\n ", "\n\n ", "\n"])), function (props) { return props.borderColor; }, function (props) { return props.borderThickness; }, function (props) { return props.orientation === 'vertical' ? (0, styled_components_1.css)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n height: 50px;\n width: 100%;\n "], ["\n height: 50px;\n width: 100%;\n "]))) : (0, styled_components_1.css)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n height: 100%;\n width: 50px;\n "], ["\n height: 100%;\n width: 50px;\n "]))); }, function (props) { return props.extendedCSS(props); });
|
|
239
|
-
var StyledSection = styled_components_1.default.section(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n align-items: flex-start;\n box-sizing: border-box;\n display: flex;\n flex: 0 0 auto;\n justify-content: flex-start;\n margin: 0;\n padding: 0;\n position: relative;\n\n ", "\n\n ", "\n"], ["\n align-items: flex-start;\n box-sizing: border-box;\n display: flex;\n flex: 0 0 auto;\n justify-content: flex-start;\n margin: 0;\n padding: 0;\n position: relative;\n\n ", "\n\n ", "\n"])), function (props) { return props.orientation === 'vertical' ? (0, styled_components_1.css)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n width: 100%;\n flex-direction: column;\n "], ["\n width: 100%;\n flex-direction: column;\n "]))) : (0, styled_components_1.css)(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n height: 100%;\n flex-direction: row;\n "], ["\n height: 100%;\n flex-direction: row;\n "]))); }, function (props) { return props.extendedCSS(props); });
|
|
240
|
-
var StyledRoot = styled_components_1.default.div(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n align-items: center;\n box-sizing: border-box;\n display: flex;\n flex: 0 0 auto;\n justify-content: flex-start;\n padding: 0;\n position: relative;\n\n ", "\n"], ["\n align-items: center;\n box-sizing: border-box;\n display: flex;\n flex: 0 0 auto;\n justify-content: flex-start;\n padding: 0;\n position: relative;\n\n ", "\n"])), function (props) { return props.orientation === 'vertical' ? (0, styled_components_1.css)(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n flex-direction: column;\n "], ["\n flex-direction: column;\n "]))) : (0, styled_components_1.css)(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n flex-direction: row;\n "], ["\n flex-direction: row;\n "]))); });
|
|
241
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14;
|
|
221
|
+
});
|
|
222
|
+
var AccordionHeader = function (_a) {
|
|
223
|
+
var props = __rest(_a, []);
|
|
224
|
+
return react_1.default.createElement("button", __assign({}, props));
|
|
225
|
+
};
|
|
226
|
+
exports.AccordionHeader = AccordionHeader;
|
|
227
|
+
var AccordionExpandIcon = function (_a) {
|
|
228
|
+
var props = __rest(_a, []);
|
|
229
|
+
return react_1.default.createElement("div", __assign({}, props));
|
|
230
|
+
};
|
|
231
|
+
exports.AccordionExpandIcon = AccordionExpandIcon;
|
|
242
232
|
//# sourceMappingURL=Accordion.js.map
|