etudes 0.24.0 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/AbstractSelectableCollection.d.ts +0 -69
- package/lib/AbstractSelectableCollection.js +2 -38
- package/lib/AbstractSelectableCollection.js.map +1 -1
- package/lib/Accordion.d.ts +2 -75
- package/lib/Accordion.js +57 -30
- package/lib/Accordion.js.map +1 -1
- package/lib/BurgerButton.js +27 -7
- package/lib/BurgerButton.js.map +1 -1
- package/lib/Compass.d.ts +0 -43
- package/lib/Compass.js +5 -5
- package/lib/Compass.js.map +1 -1
- package/lib/DebugConsole.d.ts +1 -1
- package/lib/DebugConsole.js +37 -17
- package/lib/DebugConsole.js.map +1 -1
- package/lib/Dropdown.d.ts +2 -110
- package/lib/Dropdown.js +12 -50
- package/lib/Dropdown.js.map +1 -1
- package/lib/FlatSVG.js +1 -4
- package/lib/FlatSVG.js.map +1 -1
- package/lib/List.d.ts +1 -63
- package/lib/List.js +9 -15
- package/lib/List.js.map +1 -1
- package/lib/MasonryGrid.d.ts +3 -67
- package/lib/MasonryGrid.js +47 -90
- package/lib/MasonryGrid.js.map +1 -1
- package/lib/Panorama.d.ts +1 -1
- package/lib/Panorama.js +10 -10
- package/lib/Panorama.js.map +1 -1
- package/lib/PanoramaSlider.d.ts +3 -48
- package/lib/PanoramaSlider.js +15 -13
- package/lib/PanoramaSlider.js.map +1 -1
- package/lib/RangeSlider.d.ts +2 -2
- package/lib/RangeSlider.js +44 -28
- package/lib/RangeSlider.js.map +1 -1
- package/lib/Slider.d.ts +26 -220
- package/lib/Slider.js +157 -339
- package/lib/Slider.js.map +1 -1
- package/lib/Video.js +4 -7
- package/lib/Video.js.map +1 -1
- package/lib/types/index.js.map +1 -1
- package/package.json +46 -41
|
@@ -1,94 +1,25 @@
|
|
|
1
1
|
import { CSSProperties, PureComponent } from 'react';
|
|
2
2
|
export interface Props {
|
|
3
|
-
/**
|
|
4
|
-
* Class attribute of the root element.
|
|
5
|
-
*/
|
|
6
3
|
className?: string;
|
|
7
|
-
/**
|
|
8
|
-
* Inline style attribute of the root element.
|
|
9
|
-
*/
|
|
10
4
|
style?: CSSProperties;
|
|
11
|
-
/**
|
|
12
|
-
* Indicates whether selections can be toggled. For example, in the case of
|
|
13
|
-
* a vertical list of selectable rows, being able to toggle a row means it
|
|
14
|
-
* gets deselected when selected again. Being unable to toggle the row means
|
|
15
|
-
* it does not get deselected when selected again.
|
|
16
|
-
*/
|
|
17
5
|
isTogglable?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Indicates whether selections are retained. For example, in the case of
|
|
20
|
-
* a vertical list of clickable rows, being able to retain a selection means
|
|
21
|
-
* when the row is clicked, it becomes and stays selected. Being unable to
|
|
22
|
-
* retain a selection means when the row is clicked, it does not become
|
|
23
|
-
* selected. It is simply clicked and the subsequent event is dispatched.
|
|
24
|
-
*/
|
|
25
6
|
shouldStaySelected?: boolean;
|
|
26
|
-
/**
|
|
27
|
-
* The default selected index. Any value below 0 indicates that nothing is
|
|
28
|
-
* selected.
|
|
29
|
-
*/
|
|
30
7
|
defaultSelectedIndex?: number;
|
|
31
|
-
/**
|
|
32
|
-
* Handler invoked when an index is deselected.
|
|
33
|
-
*/
|
|
34
8
|
onDeselectAt?: (index: number) => void;
|
|
35
|
-
/**
|
|
36
|
-
* Handler invoked when an index is selected.
|
|
37
|
-
*/
|
|
38
9
|
onSelectAt?: (index: number) => void;
|
|
39
10
|
}
|
|
40
11
|
export interface State {
|
|
41
|
-
/**
|
|
42
|
-
* The current selected index. Any value less than 0 indicates that no index
|
|
43
|
-
* is selected.
|
|
44
|
-
*/
|
|
45
12
|
selectedIndex?: number;
|
|
46
13
|
}
|
|
47
|
-
/**
|
|
48
|
-
* An abstract component that mimics and handles index selection in an abstract
|
|
49
|
-
* collection.
|
|
50
|
-
*/
|
|
51
14
|
export default class AbstractSelectableCollection<P extends Props = Props, S extends State = State> extends PureComponent<P, S> {
|
|
52
15
|
constructor(props: P);
|
|
53
16
|
componentDidMount(): void;
|
|
54
17
|
componentDidUpdate(prevProps: P, prevState: S): void;
|
|
55
18
|
render(): JSX.Element;
|
|
56
|
-
/**
|
|
57
|
-
* Checks if an index is out of range.
|
|
58
|
-
*
|
|
59
|
-
* @param index - The index to check.
|
|
60
|
-
*
|
|
61
|
-
* @returns `true` if the index is out of range, `false` otherwise.
|
|
62
|
-
*/
|
|
63
19
|
isIndexOutOfRange(index: number): boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Checks if an index is selected.
|
|
66
|
-
*
|
|
67
|
-
* @param index - The index to check.
|
|
68
|
-
*
|
|
69
|
-
* @returns `true` if the index is selected, `false` otherwise.
|
|
70
|
-
*/
|
|
71
20
|
isSelectedAt(index: number): boolean;
|
|
72
|
-
/**
|
|
73
|
-
* Toggles an index, i.e. reverses its selected state.
|
|
74
|
-
*
|
|
75
|
-
* @param index - The index to toggle.
|
|
76
|
-
*/
|
|
77
21
|
toggleAt(index: number): void;
|
|
78
|
-
/**
|
|
79
|
-
* Selects an index.
|
|
80
|
-
*
|
|
81
|
-
* @param index - The index to select.
|
|
82
|
-
*/
|
|
83
22
|
selectAt(index: number): void;
|
|
84
|
-
/**
|
|
85
|
-
* Deselects an index if it is currently selected.
|
|
86
|
-
*
|
|
87
|
-
* @param index - The index to deselect.
|
|
88
|
-
*/
|
|
89
23
|
deselectAt(index: number): void;
|
|
90
|
-
/**
|
|
91
|
-
* Deselects the currently selected index.
|
|
92
|
-
*/
|
|
93
24
|
deselectCurrent(): void;
|
|
94
25
|
}
|
|
@@ -36,11 +36,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
37
|
var react_1 = __importStar(require("react"));
|
|
38
38
|
var debug = process.env.NODE_ENV === 'development' ? require('debug')('etudes:asc') : function () { };
|
|
39
|
-
|
|
40
|
-
* An abstract component that mimics and handles index selection in an abstract
|
|
41
|
-
* collection.
|
|
42
|
-
*/
|
|
43
|
-
var AbstractSelectableCollection = /** @class */ (function (_super) {
|
|
39
|
+
var AbstractSelectableCollection = (function (_super) {
|
|
44
40
|
__extends(AbstractSelectableCollection, _super);
|
|
45
41
|
function AbstractSelectableCollection(props) {
|
|
46
42
|
var _a;
|
|
@@ -62,7 +58,7 @@ var AbstractSelectableCollection = /** @class */ (function (_super) {
|
|
|
62
58
|
var prevSelectedIndex = (_a = prevState.selectedIndex) !== null && _a !== void 0 ? _a : -1;
|
|
63
59
|
var selectedIndex = (_b = this.state.selectedIndex) !== null && _b !== void 0 ? _b : -1;
|
|
64
60
|
if (prevState.selectedIndex !== selectedIndex) {
|
|
65
|
-
debug("Selected index changed: "
|
|
61
|
+
debug("Selected index changed: ".concat(selectedIndex));
|
|
66
62
|
if (shouldStaySelected === true) {
|
|
67
63
|
if (!this.isIndexOutOfRange(prevSelectedIndex))
|
|
68
64
|
onDeselectAt === null || onDeselectAt === void 0 ? void 0 : onDeselectAt(prevSelectedIndex);
|
|
@@ -74,33 +70,14 @@ var AbstractSelectableCollection = /** @class */ (function (_super) {
|
|
|
74
70
|
AbstractSelectableCollection.prototype.render = function () {
|
|
75
71
|
return react_1.default.createElement(react_1.Fragment, null);
|
|
76
72
|
};
|
|
77
|
-
/**
|
|
78
|
-
* Checks if an index is out of range.
|
|
79
|
-
*
|
|
80
|
-
* @param index - The index to check.
|
|
81
|
-
*
|
|
82
|
-
* @returns `true` if the index is out of range, `false` otherwise.
|
|
83
|
-
*/
|
|
84
73
|
AbstractSelectableCollection.prototype.isIndexOutOfRange = function (index) {
|
|
85
74
|
if (index < 0)
|
|
86
75
|
return true;
|
|
87
76
|
return false;
|
|
88
77
|
};
|
|
89
|
-
/**
|
|
90
|
-
* Checks if an index is selected.
|
|
91
|
-
*
|
|
92
|
-
* @param index - The index to check.
|
|
93
|
-
*
|
|
94
|
-
* @returns `true` if the index is selected, `false` otherwise.
|
|
95
|
-
*/
|
|
96
78
|
AbstractSelectableCollection.prototype.isSelectedAt = function (index) {
|
|
97
79
|
return (this.state.selectedIndex === index);
|
|
98
80
|
};
|
|
99
|
-
/**
|
|
100
|
-
* Toggles an index, i.e. reverses its selected state.
|
|
101
|
-
*
|
|
102
|
-
* @param index - The index to toggle.
|
|
103
|
-
*/
|
|
104
81
|
AbstractSelectableCollection.prototype.toggleAt = function (index) {
|
|
105
82
|
if (this.props.isTogglable === true && this.isSelectedAt(index)) {
|
|
106
83
|
this.deselectAt(index);
|
|
@@ -109,11 +86,6 @@ var AbstractSelectableCollection = /** @class */ (function (_super) {
|
|
|
109
86
|
this.selectAt(index);
|
|
110
87
|
}
|
|
111
88
|
};
|
|
112
|
-
/**
|
|
113
|
-
* Selects an index.
|
|
114
|
-
*
|
|
115
|
-
* @param index - The index to select.
|
|
116
|
-
*/
|
|
117
89
|
AbstractSelectableCollection.prototype.selectAt = function (index) {
|
|
118
90
|
if (this.props.shouldStaySelected === true) {
|
|
119
91
|
if (this.isSelectedAt(index))
|
|
@@ -124,19 +96,11 @@ var AbstractSelectableCollection = /** @class */ (function (_super) {
|
|
|
124
96
|
this.props.onSelectAt(index);
|
|
125
97
|
}
|
|
126
98
|
};
|
|
127
|
-
/**
|
|
128
|
-
* Deselects an index if it is currently selected.
|
|
129
|
-
*
|
|
130
|
-
* @param index - The index to deselect.
|
|
131
|
-
*/
|
|
132
99
|
AbstractSelectableCollection.prototype.deselectAt = function (index) {
|
|
133
100
|
if (!this.isSelectedAt(index))
|
|
134
101
|
return;
|
|
135
102
|
this.setState({ selectedIndex: -1 });
|
|
136
103
|
};
|
|
137
|
-
/**
|
|
138
|
-
* Deselects the currently selected index.
|
|
139
|
-
*/
|
|
140
104
|
AbstractSelectableCollection.prototype.deselectCurrent = function () {
|
|
141
105
|
this.setState({ selectedIndex: -1 });
|
|
142
106
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractSelectableCollection.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"AbstractSelectableC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I,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;YAAE,OAAM;QACrC,IAAI,CAAC,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,EAAE,CAAC,CAAA;IACtC,CAAC;IAKD,sDAAe,GAAf;QACE,IAAI,CAAC,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,EAAE,CAAC,CAAA;IACtC,CAAC;IACH,mCAAC;AAAD,CAAC,AAtGD,CAA4G,qBAAa,GAsGxH","sourcesContent":["import React, { CSSProperties, Fragment, PureComponent } from 'react'\n\nconst debug = process.env.NODE_ENV === 'development' ? require('debug')('etudes:asc') : () => {}\n\nexport interface Props {\n /**\n * Class attribute of the root element.\n */\n className?: string\n\n /**\n * Inline style attribute of the root element.\n */\n style?: CSSProperties\n\n /**\n * Indicates whether selections can be toggled. For example, in the case of\n * a vertical list of selectable rows, being able to toggle a row means it\n * gets deselected when selected again. Being unable to toggle the row means\n * it does not get deselected when selected again.\n */\n isTogglable?: boolean\n\n /**\n * Indicates whether selections are retained. For example, in the case of\n * a vertical list of clickable rows, being able to retain a selection means\n * when the row is clicked, it becomes and stays selected. Being unable to\n * retain a selection means when the row is clicked, it does not become\n * selected. It is simply clicked and the subsequent event is dispatched.\n */\n shouldStaySelected?: boolean\n\n /**\n * The default selected index. Any value below 0 indicates that nothing is\n * selected.\n */\n defaultSelectedIndex?: number\n\n /**\n * Handler invoked when an index is deselected.\n */\n onDeselectAt?: (index: number) => void\n\n /**\n * Handler invoked when an index is selected.\n */\n onSelectAt?: (index: number) => void\n}\n\nexport interface State {\n /**\n * The current selected index. Any value less than 0 indicates that no index\n * is selected.\n */\n selectedIndex?: number\n}\n\n/**\n * An abstract component that mimics and handles index selection in an abstract\n * collection.\n */\nexport default class AbstractSelectableCollection<P extends Props = Props, S extends State = State> extends PureComponent<P, S> {\n constructor(props: P) {\n super(props)\n\n this.state = {\n selectedIndex: this.props.defaultSelectedIndex ?? -1,\n } as any\n }\n\n componentDidMount() {\n if (this.state.selectedIndex !== undefined && this.state.selectedIndex > -1) {\n this.props.onSelectAt?.(this.state.selectedIndex ?? -1)\n }\n }\n\n componentDidUpdate(prevProps: P, prevState: S) {\n const { shouldStaySelected, onSelectAt, onDeselectAt } = this.props\n const prevSelectedIndex = prevState.selectedIndex ?? -1\n const selectedIndex = this.state.selectedIndex ?? -1\n\n if (prevState.selectedIndex !== selectedIndex) {\n debug(`Selected index changed: ${selectedIndex}`)\n\n if (shouldStaySelected === true) {\n if (!this.isIndexOutOfRange(prevSelectedIndex)) onDeselectAt?.(prevSelectedIndex)\n if (!this.isIndexOutOfRange(selectedIndex)) onSelectAt?.(selectedIndex)\n }\n }\n }\n\n render() {\n return <Fragment/>\n }\n\n /**\n * Checks if an index is out of range.\n *\n * @param index - The index to check.\n *\n * @returns `true` if the index is out of range, `false` otherwise.\n */\n isIndexOutOfRange(index: number): boolean {\n if (index < 0) return true\n return false\n }\n\n /**\n * Checks if an index is selected.\n *\n * @param index - The index to check.\n *\n * @returns `true` if the index is selected, `false` otherwise.\n */\n isSelectedAt(index: number): boolean {\n return (this.state.selectedIndex === index)\n }\n\n /**\n * Toggles an index, i.e. reverses its selected state.\n *\n * @param index - The index to toggle.\n */\n toggleAt(index: number) {\n if (this.props.isTogglable === true && this.isSelectedAt(index)) {\n this.deselectAt(index)\n }\n else {\n this.selectAt(index)\n }\n }\n\n /**\n * Selects an index.\n *\n * @param index - The index to select.\n */\n selectAt(index: number) {\n if (this.props.shouldStaySelected === true) {\n if (this.isSelectedAt(index)) return\n this.setState({ selectedIndex: index })\n }\n else if (this.props.onSelectAt) {\n this.props.onSelectAt(index)\n }\n }\n\n /**\n * Deselects an index if it is currently selected.\n *\n * @param index - The index to deselect.\n */\n deselectAt(index: number) {\n if (!this.isSelectedAt(index)) return\n this.setState({ selectedIndex: -1 })\n }\n\n /**\n * Deselects the currently selected index.\n */\n deselectCurrent() {\n this.setState({ selectedIndex: -1 })\n }\n}\n"]}
|
package/lib/Accordion.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import React, { ComponentType, CSSProperties, PureComponent } from 'react';
|
|
2
2
|
import List, { ItemComponentProps as ListItemComponentProps } from './List';
|
|
3
3
|
import { ExtendedCSSFunction, Orientation } from './types';
|
|
4
|
-
/**
|
|
5
|
-
* Interface defining the props of the item component type to be provided to the
|
|
6
|
-
* component. The data type is generic.
|
|
7
|
-
*/
|
|
8
4
|
export declare type ItemComponentProps<T = Record<string, never>> = ListItemComponentProps<T>;
|
|
9
5
|
export declare type SectionHeaderCSSProps = Readonly<{
|
|
10
6
|
borderColor: string;
|
|
@@ -18,99 +14,30 @@ export declare type SectionCSSProps = Readonly<{
|
|
|
18
14
|
}>;
|
|
19
15
|
export interface SectionProps<T = Record<string, never>> {
|
|
20
16
|
label: string;
|
|
21
|
-
items:
|
|
17
|
+
items: T[];
|
|
22
18
|
}
|
|
23
19
|
export interface Props<T = Record<string, never>> {
|
|
24
|
-
/**
|
|
25
|
-
* Class attribute to the root element.
|
|
26
|
-
*/
|
|
27
20
|
className?: string;
|
|
28
|
-
/**
|
|
29
|
-
* Inline style attribute to the element.
|
|
30
|
-
*/
|
|
31
21
|
style?: CSSProperties;
|
|
32
|
-
|
|
33
|
-
* Data provided to each section.
|
|
34
|
-
*/
|
|
35
|
-
data: Array<SectionProps<T>>;
|
|
36
|
-
/**
|
|
37
|
-
* Indicates if sections can be toggled, as in, once a section is expanded,
|
|
38
|
-
* it collapses when being selected again.
|
|
39
|
-
*/
|
|
22
|
+
data: SectionProps<T>[];
|
|
40
23
|
isTogglable?: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Index of the section that is selected by default. Any value less than 0
|
|
43
|
-
* indicates that no section is selected by default.
|
|
44
|
-
*/
|
|
45
24
|
defaultSelectedSectionIndex?: number;
|
|
46
|
-
/**
|
|
47
|
-
* Length (in pixels) of each item. This does not apply to the section hedaer
|
|
48
|
-
* itself. Length refers to the height in vertical orientation and width in
|
|
49
|
-
* horizontal orientation.
|
|
50
|
-
*/
|
|
51
25
|
itemLength?: number;
|
|
52
|
-
/**
|
|
53
|
-
* Padding (in pixels) between each item.
|
|
54
|
-
*/
|
|
55
26
|
itemPadding?: number;
|
|
56
|
-
/**
|
|
57
|
-
* Padding (in pixels) between each section.
|
|
58
|
-
*/
|
|
59
27
|
sectionPadding?: number;
|
|
60
|
-
/**
|
|
61
|
-
* Maximum number of items that are viside when a section expands. When a
|
|
62
|
-
* value greater than or equal to 0 is specified, only that number of items
|
|
63
|
-
* will be visible at a time, and a scrollbar will appear to scroll to
|
|
64
|
-
* remaining items. Any value less than 0 indicates that all items will be
|
|
65
|
-
* visible when a section expands.
|
|
66
|
-
*/
|
|
67
28
|
maxVisibleItems?: number;
|
|
68
|
-
/**
|
|
69
|
-
* Orientation of the component.
|
|
70
|
-
*/
|
|
71
29
|
orientation?: Orientation;
|
|
72
|
-
/**
|
|
73
|
-
* Color of the border of every item and the section header itself.
|
|
74
|
-
*/
|
|
75
30
|
borderColor?: string;
|
|
76
|
-
/**
|
|
77
|
-
* Thickness of the border (in pixels) of every item and the section header
|
|
78
|
-
* itself. 0 indicates no borders.
|
|
79
|
-
*/
|
|
80
31
|
borderThickness?: number;
|
|
81
|
-
/**
|
|
82
|
-
* SVG markup to be put in the section header as the expand icon.
|
|
83
|
-
*/
|
|
84
32
|
expandIconSvg?: string;
|
|
85
|
-
/**
|
|
86
|
-
* React component type to be used for generating items inside the component.
|
|
87
|
-
*/
|
|
88
33
|
itemComponentType: ComponentType<ItemComponentProps<T>>;
|
|
89
|
-
/**
|
|
90
|
-
* Handler invoked when the selected item index of any section changes.
|
|
91
|
-
*/
|
|
92
34
|
onItemIndexChange?: (index: number) => void;
|
|
93
|
-
/**
|
|
94
|
-
* Handler invoked when the selected section index changes.
|
|
95
|
-
*/
|
|
96
35
|
onSectionIndexChange?: (index: number) => void;
|
|
97
|
-
/**
|
|
98
|
-
* Additional CSS to be provided to each section element.
|
|
99
|
-
*/
|
|
100
36
|
sectionCSS?: ExtendedCSSFunction<SectionCSSProps>;
|
|
101
|
-
/**
|
|
102
|
-
* Additional CSS to be provided to each section header element.
|
|
103
|
-
*/
|
|
104
37
|
sectionHeaderCSS?: ExtendedCSSFunction<SectionHeaderCSSProps>;
|
|
105
38
|
}
|
|
106
39
|
export interface State {
|
|
107
|
-
/**
|
|
108
|
-
* Current selected section index.
|
|
109
|
-
*/
|
|
110
40
|
selectedSectionIndex: number;
|
|
111
|
-
/**
|
|
112
|
-
* Current selected item index of the expanded section.
|
|
113
|
-
*/
|
|
114
41
|
selectedItemIndex: number;
|
|
115
42
|
}
|
|
116
43
|
export default class Accordion<T = Record<string, never>> extends PureComponent<Props<T>, State> {
|
package/lib/Accordion.js
CHANGED
|
@@ -48,6 +48,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
48
48
|
__setModuleDefault(result, mod);
|
|
49
49
|
return result;
|
|
50
50
|
};
|
|
51
|
+
var __values = (this && this.__values) || function(o) {
|
|
52
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
53
|
+
if (m) return m.call(o);
|
|
54
|
+
if (o && typeof o.length === "number") return {
|
|
55
|
+
next: function () {
|
|
56
|
+
if (o && i >= o.length) o = void 0;
|
|
57
|
+
return { value: o && o[i++], done: !o };
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
61
|
+
};
|
|
51
62
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
52
63
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
53
64
|
};
|
|
@@ -56,7 +67,7 @@ var react_1 = __importStar(require("react"));
|
|
|
56
67
|
var styled_components_1 = __importStar(require("styled-components"));
|
|
57
68
|
var List_1 = __importDefault(require("./List"));
|
|
58
69
|
var debug = process.env.NODE_ENV === 'development' ? require('debug')('etudes:accordion') : function () { };
|
|
59
|
-
var Accordion =
|
|
70
|
+
var Accordion = (function (_super) {
|
|
60
71
|
__extends(Accordion, _super);
|
|
61
72
|
function Accordion(props) {
|
|
62
73
|
var _a;
|
|
@@ -78,11 +89,11 @@ var Accordion = /** @class */ (function (_super) {
|
|
|
78
89
|
Accordion.prototype.componentDidUpdate = function (prevProps, prevState) {
|
|
79
90
|
var _a, _b, _c, _d;
|
|
80
91
|
if (prevState.selectedSectionIndex !== this.state.selectedSectionIndex) {
|
|
81
|
-
debug("Changing section index to "
|
|
92
|
+
debug("Changing section index to ".concat(this.state.selectedSectionIndex, "... OK"));
|
|
82
93
|
(_b = (_a = this.props).onSectionIndexChange) === null || _b === void 0 ? void 0 : _b.call(_a, this.state.selectedSectionIndex);
|
|
83
94
|
}
|
|
84
95
|
if (prevState.selectedItemIndex !== this.state.selectedItemIndex) {
|
|
85
|
-
debug("Changing item index to "
|
|
96
|
+
debug("Changing item index to ".concat(this.state.selectedItemIndex, "... OK"));
|
|
86
97
|
(_d = (_c = this.props).onItemIndexChange) === null || _d === void 0 ? void 0 : _d.call(_c, this.state.selectedItemIndex);
|
|
87
98
|
}
|
|
88
99
|
};
|
|
@@ -108,28 +119,28 @@ var Accordion = /** @class */ (function (_super) {
|
|
|
108
119
|
var numVisibleItems = maxVisibleItems < 0 ? numItems : Math.min(numItems, maxVisibleItems);
|
|
109
120
|
var menuLength = (itemLength - borderThickness) * numVisibleItems + itemPadding * (numVisibleItems - 1) + borderThickness;
|
|
110
121
|
var isCollapsed = !_this.isSectionSelectedAt(i);
|
|
111
|
-
var ref = react_1.createRef();
|
|
122
|
+
var ref = (0, react_1.createRef)();
|
|
112
123
|
_this.nodeRefs.lists.push(ref);
|
|
113
|
-
return (react_1.default.createElement(StyledSection, { key: "section-"
|
|
114
|
-
marginTop: i === 0 ? '0px' : sectionPadding - borderThickness
|
|
124
|
+
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' ? {
|
|
125
|
+
marginTop: i === 0 ? '0px' : "".concat(sectionPadding - borderThickness, "px"),
|
|
115
126
|
} : {
|
|
116
|
-
marginLeft: i === 0 ? '0px' : sectionPadding - borderThickness
|
|
127
|
+
marginLeft: i === 0 ? '0px' : "".concat(sectionPadding - borderThickness, "px"),
|
|
117
128
|
} },
|
|
118
|
-
react_1.default.createElement(StyledSectionHeader, { borderColor: borderColor, borderThickness: borderThickness, orientation: orientation, isCollapsed: isCollapsed, onClick: function () { return _this.toggleSectionAt(i); }, extendedCSS: (_b = _this.props.sectionHeaderCSS) !== null && _b !== void 0 ? _b : (function () { return styled_components_1.css(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""]))); }) },
|
|
129
|
+
react_1.default.createElement(StyledSectionHeader, { borderColor: borderColor, borderThickness: borderThickness, orientation: orientation, isCollapsed: isCollapsed, onClick: function () { return _this.toggleSectionAt(i); }, extendedCSS: (_b = _this.props.sectionHeaderCSS) !== null && _b !== void 0 ? _b : (function () { return (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""]))); }) },
|
|
119
130
|
react_1.default.createElement("label", null, section.label),
|
|
120
131
|
_this.props.expandIconSvg && react_1.default.createElement("span", { dangerouslySetInnerHTML: { __html: _this.props.expandIconSvg } })),
|
|
121
132
|
react_1.default.createElement(StyledItemList, { ref: ref, borderColor: borderColor, borderThickness: borderThickness, data: section.items, defaultSelectedIndex: -1, isTogglable: isTogglable, itemComponentType: _this.props.itemComponentType, itemPadding: itemPadding, onDeselectAt: function (idx) { return _this.deselectItemAt(idx); }, onSelectAt: function (idx) { return _this.selectItemAt(idx); }, orientation: orientation, shouldStaySelected: true, itemStyle: orientation === 'vertical' ? {
|
|
122
|
-
height: itemLength
|
|
133
|
+
height: "".concat(itemLength, "px"),
|
|
123
134
|
} : {
|
|
124
|
-
width: itemLength
|
|
135
|
+
width: "".concat(itemLength, "px"),
|
|
125
136
|
}, style: orientation === 'vertical' ? {
|
|
126
|
-
height: isCollapsed ? '0px' : menuLength
|
|
127
|
-
marginTop: isCollapsed ? '0px' : itemPadding - borderThickness
|
|
137
|
+
height: isCollapsed ? '0px' : "".concat(menuLength, "px"),
|
|
138
|
+
marginTop: isCollapsed ? '0px' : "".concat(itemPadding - borderThickness, "px"),
|
|
128
139
|
overflowY: (maxVisibleItems === -1) ? 'hidden' : (maxVisibleItems < numItems ? 'scroll' : 'hidden'),
|
|
129
140
|
} : {
|
|
130
|
-
marginLeft: isCollapsed ? '0px' : itemPadding - borderThickness
|
|
141
|
+
marginLeft: isCollapsed ? '0px' : "".concat(itemPadding - borderThickness, "px"),
|
|
131
142
|
overflowX: (maxVisibleItems === -1) ? 'hidden' : (maxVisibleItems < numItems ? 'scroll' : 'hidden'),
|
|
132
|
-
width: isCollapsed ? '0px' : menuLength
|
|
143
|
+
width: isCollapsed ? '0px' : "".concat(menuLength, "px"),
|
|
133
144
|
} })));
|
|
134
145
|
})));
|
|
135
146
|
};
|
|
@@ -146,24 +157,44 @@ var Accordion = /** @class */ (function (_super) {
|
|
|
146
157
|
}
|
|
147
158
|
};
|
|
148
159
|
Accordion.prototype.selectSectionAt = function (index) {
|
|
149
|
-
var _a;
|
|
160
|
+
var e_1, _a;
|
|
161
|
+
var _b;
|
|
150
162
|
if (this.isSectionSelectedAt(index))
|
|
151
163
|
return;
|
|
152
|
-
|
|
153
|
-
var
|
|
154
|
-
|
|
164
|
+
try {
|
|
165
|
+
for (var _c = __values(this.nodeRefs.lists), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
166
|
+
var ref = _d.value;
|
|
167
|
+
(_b = ref.current) === null || _b === void 0 ? void 0 : _b.setState({ selectedIndex: -1 });
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
171
|
+
finally {
|
|
172
|
+
try {
|
|
173
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
174
|
+
}
|
|
175
|
+
finally { if (e_1) throw e_1.error; }
|
|
155
176
|
}
|
|
156
177
|
this.setState({
|
|
157
178
|
selectedSectionIndex: index,
|
|
158
179
|
});
|
|
159
180
|
};
|
|
160
181
|
Accordion.prototype.deselectSectionAt = function (index) {
|
|
161
|
-
var _a;
|
|
182
|
+
var e_2, _a;
|
|
183
|
+
var _b;
|
|
162
184
|
if (!this.isSectionSelectedAt(index))
|
|
163
185
|
return;
|
|
164
|
-
|
|
165
|
-
var
|
|
166
|
-
|
|
186
|
+
try {
|
|
187
|
+
for (var _c = __values(this.nodeRefs.lists), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
188
|
+
var ref = _d.value;
|
|
189
|
+
(_b = ref.current) === null || _b === void 0 ? void 0 : _b.setState({ selectedIndex: -1 });
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
193
|
+
finally {
|
|
194
|
+
try {
|
|
195
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
196
|
+
}
|
|
197
|
+
finally { if (e_2) throw e_2.error; }
|
|
167
198
|
}
|
|
168
199
|
this.setState({
|
|
169
200
|
selectedSectionIndex: -1,
|
|
@@ -198,13 +229,9 @@ var Accordion = /** @class */ (function (_super) {
|
|
|
198
229
|
return Accordion;
|
|
199
230
|
}(react_1.PureComponent));
|
|
200
231
|
exports.default = Accordion;
|
|
201
|
-
var StyledItemList = 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 ",
|
|
202
|
-
|
|
203
|
-
var
|
|
204
|
-
|
|
205
|
-
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 ",
|
|
206
|
-
"\n\n ", "\n"])), function (props) { return props.orientation === 'vertical' ? 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 "]))) : 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); });
|
|
207
|
-
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 ",
|
|
208
|
-
"\n"])), function (props) { return props.orientation === 'vertical' ? styled_components_1.css(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n flex-direction: column;\n "], ["\n flex-direction: column;\n "]))) : styled_components_1.css(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n flex-direction: row;\n "], ["\n flex-direction: row;\n "]))); });
|
|
232
|
+
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 "]))); });
|
|
233
|
+
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); });
|
|
234
|
+
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); });
|
|
235
|
+
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 "]))); });
|
|
209
236
|
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;
|
|
210
237
|
//# sourceMappingURL=Accordion.js.map
|
package/lib/Accordion.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.js","sourceRoot":"","sources":["../src/Accordion.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAgG;AAChG,qEAA+C;AAC/C,gDAA2E;AAG3E,IAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,cAAO,CAAC,CAAA;AA0ItG;IAAkE,6BAA8B;IAK9F,mBAAY,KAAe;;QAA3B,YACE,kBAAM,KAAK,CAAC,SAMb;QAXD,cAAQ,GAAG;YACT,KAAK,EAAE,EAA+B;SACvC,CAAA;QAKC,KAAI,CAAC,KAAK,GAAG;YACX,oBAAoB,EAAE,MAAA,KAAK,CAAC,2BAA2B,mCAAI,CAAC,CAAC;YAC7D,iBAAiB,EAAE,CAAC,CAAC;SACtB,CAAA;;IACH,CAAC;IAED,qCAAiB,GAAjB;;QACE,MAAA,MAAA,IAAI,CAAC,KAAK,EAAC,oBAAoB,mDAAG,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAA;QAClE,MAAA,M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AAC,uBAAG,2GAAA,qCAE9C,KAAC,CAAC,KAAC,uBAAG,sGAAA,gCAER,IAAA,EAJU,CAIV,CACF,CAAA","sourcesContent":["import React, { ComponentType, createRef, CSSProperties, PureComponent, RefObject } from 'react'\nimport styled, { css } from 'styled-components'\nimport List, { ItemComponentProps as ListItemComponentProps } from './List'\nimport { ExtendedCSSFunction, ExtendedCSSProps, Orientation } from './types'\n\nconst debug = process.env.NODE_ENV === 'development' ? require('debug')('etudes:accordion') : () => {}\n\n/**\n * Interface defining the props of the item component type to be provided to the\n * component. The data type is generic.\n */\nexport type ItemComponentProps<T = Record<string, never>> = ListItemComponentProps<T>\n\nexport type SectionHeaderCSSProps = Readonly<{\n borderColor: string\n borderThickness: number\n isCollapsed: boolean\n orientation: Orientation\n}>\n\nexport type SectionCSSProps = Readonly<{\n isCollapsed: boolean\n orientation: Orientation\n}>\n\nexport interface SectionProps<T = Record<string, never>> {\n label: string\n items: T[]\n}\n\nexport interface Props<T = Record<string, never>> {\n /**\n * Class attribute to the root element.\n */\n className?: string\n\n /**\n * Inline style attribute to the element.\n */\n style?: CSSProperties\n\n /**\n * Data provided to each section.\n */\n data: SectionProps<T>[]\n\n /**\n * Indicates if sections can be toggled, as in, once a section is expanded,\n * it collapses when being selected again.\n */\n isTogglable?: boolean\n\n /**\n * Index of the section that is selected by default. Any value less than 0\n * indicates that no section is selected by default.\n */\n defaultSelectedSectionIndex?: number\n\n /**\n * Length (in pixels) of each item. This does not apply to the section hedaer\n * itself. Length refers to the height in vertical orientation and width in\n * horizontal orientation.\n */\n itemLength?: number\n\n /**\n * Padding (in pixels) between each item.\n */\n itemPadding?: number\n\n /**\n * Padding (in pixels) between each section.\n */\n sectionPadding?: number\n\n /**\n * Maximum number of items that are viside when a section expands. When a\n * value greater than or equal to 0 is specified, only that number of items\n * will be visible at a time, and a scrollbar will appear to scroll to\n * remaining items. Any value less than 0 indicates that all items will be\n * visible when a section expands.\n */\n maxVisibleItems?: number\n\n /**\n * Orientation of the component.\n */\n orientation?: Orientation\n\n /**\n * Color of the border of every item and the section header itself.\n */\n borderColor?: string\n\n /**\n * Thickness of the border (in pixels) of every item and the section header\n * itself. 0 indicates no borders.\n */\n borderThickness?: number\n\n /**\n * SVG markup to be put in the section header as the expand icon.\n */\n expandIconSvg?: string\n\n /**\n * React component type to be used for generating items inside the component.\n */\n itemComponentType: ComponentType<ItemComponentProps<T>>\n\n /**\n * Handler invoked when the selected item index of any section changes.\n */\n onItemIndexChange?: (index: number) => void\n\n /**\n * Handler invoked when the selected section index changes.\n */\n onSectionIndexChange?: (index: number) => void\n\n /**\n * Additional CSS to be provided to each section element.\n */\n sectionCSS?: ExtendedCSSFunction<SectionCSSProps>\n\n /**\n * Additional CSS to be provided to each section header element.\n */\n sectionHeaderCSS?: ExtendedCSSFunction<SectionHeaderCSSProps>\n}\n\nexport interface State {\n /**\n * Current selected section index.\n */\n selectedSectionIndex: number\n\n /**\n * Current selected item index of the expanded section.\n */\n selectedItemIndex: number\n}\n\nexport default class Accordion<T = Record<string, never>> extends PureComponent<Props<T>, State> {\n nodeRefs = {\n lists: [] as RefObject<List<T>>[],\n }\n\n constructor(props: Props<T>) {\n super(props)\n\n this.state = {\n selectedSectionIndex: props.defaultSelectedSectionIndex ?? -1,\n selectedItemIndex: -1,\n }\n }\n\n componentDidMount() {\n this.props.onSectionIndexChange?.(this.state.selectedSectionIndex)\n this.props.onItemIndexChange?.(this.state.selectedItemIndex)\n }\n\n componentDidUpdate(prevProps: Props<T>, prevState: State) {\n if (prevState.selectedSectionIndex !== this.state.selectedSectionIndex) {\n debug(`Changing section index to ${this.state.selectedSectionIndex}... OK`)\n this.props.onSectionIndexChange?.(this.state.selectedSectionIndex)\n }\n\n if (prevState.selectedItemIndex !== this.state.selectedItemIndex) {\n debug(`Changing item index to ${this.state.selectedItemIndex}... OK`)\n this.props.onItemIndexChange?.(this.state.selectedItemIndex)\n }\n }\n\n render() {\n const borderColor = this.props.borderColor ?? '#000'\n const borderThickness = this.props.borderThickness ?? 0\n const isTogglable = this.props.isTogglable ?? true\n const itemLength = this.props.itemLength ?? 50\n const itemPadding = this.props.itemPadding ?? 0\n const sectionPadding = this.props.sectionPadding ?? 0\n const maxVisibleItems = this.props.maxVisibleItems ?? -1\n const orientation = this.props.orientation ?? 'vertical'\n\n this.nodeRefs.lists = []\n\n return (\n <StyledRoot\n className={this.props.className}\n orientation={orientation}\n style={{\n ...this.props.style ?? {},\n ...(orientation === 'vertical' ? {\n height: 'auto',\n } : {\n width: 'auto',\n }),\n }}\n >\n {this.props.data.map((section, i) => {\n const numItems = section.items.length\n const numVisibleItems = maxVisibleItems < 0 ? numItems : Math.min(numItems, maxVisibleItems)\n const menuLength = (itemLength - borderThickness) * numVisibleItems + itemPadding * (numVisibleItems - 1) + borderThickness\n const isCollapsed = !this.isSectionSelectedAt(i)\n const ref = createRef<List<T>>()\n\n this.nodeRefs.lists.push(ref)\n\n return (\n <StyledSection\n key={`section-${i}`}\n isCollapsed={isCollapsed}\n orientation={orientation}\n extendedCSS={this.props.sectionCSS ?? (() => css``)}\n style={orientation === 'vertical' ? {\n marginTop: i === 0 ? '0px' : `${sectionPadding - borderThickness}px`,\n } : {\n marginLeft: i === 0 ? '0px' : `${sectionPadding - borderThickness}px`,\n }}\n >\n <StyledSectionHeader\n borderColor={borderColor}\n borderThickness={borderThickness}\n orientation={orientation}\n isCollapsed={isCollapsed}\n onClick={() => this.toggleSectionAt(i) }\n extendedCSS={this.props.sectionHeaderCSS ?? (() => css``)}\n >\n <label>{section.label}</label>\n {this.props.expandIconSvg && <span dangerouslySetInnerHTML={{ __html: this.props.expandIconSvg }}/>}\n </StyledSectionHeader>\n <StyledItemList\n ref={ref as any}\n borderColor={borderColor}\n borderThickness={borderThickness}\n data={section.items}\n defaultSelectedIndex={-1}\n isTogglable={isTogglable}\n itemComponentType={this.props.itemComponentType as any}\n itemPadding={itemPadding}\n onDeselectAt={idx => this.deselectItemAt(idx)}\n onSelectAt={idx => this.selectItemAt(idx)}\n orientation={orientation}\n shouldStaySelected={true}\n itemStyle={orientation === 'vertical' ? {\n height: `${itemLength}px`,\n } : {\n width: `${itemLength}px`,\n }}\n style={orientation === 'vertical' ? {\n height: isCollapsed ? '0px' : `${menuLength}px`,\n marginTop: isCollapsed ? '0px' : `${itemPadding - borderThickness}px`,\n overflowY: (maxVisibleItems === -1) ? 'hidden' : (maxVisibleItems < numItems ? 'scroll' : 'hidden'),\n } : {\n marginLeft: isCollapsed ? '0px' : `${itemPadding - borderThickness}px`,\n overflowX: (maxVisibleItems === -1) ? 'hidden' : (maxVisibleItems < numItems ? 'scroll' : 'hidden'),\n width: isCollapsed ? '0px' : `${menuLength}px`,\n }}\n />\n </StyledSection>\n )\n })}\n </StyledRoot>\n )\n }\n\n private isSectionSelectedAt(index: number): boolean {\n return this.state.selectedSectionIndex === index\n }\n\n private toggleSectionAt(index: number) {\n if ((this.props.isTogglable ?? true) && this.isSectionSelectedAt(index)) {\n this.deselectSectionAt(index)\n }\n else {\n this.selectSectionAt(index)\n }\n }\n\n private selectSectionAt(index: number) {\n if (this.isSectionSelectedAt(index)) return\n\n for (const ref of this.nodeRefs.lists) {\n ref.current?.setState({ selectedIndex: -1 })\n }\n\n this.setState({\n selectedSectionIndex: index,\n })\n }\n\n private deselectSectionAt(index: number) {\n if (!this.isSectionSelectedAt(index)) return\n\n for (const ref of this.nodeRefs.lists) {\n ref.current?.setState({ selectedIndex: -1 })\n }\n\n this.setState({\n selectedSectionIndex: -1,\n })\n }\n\n private isItemSelectedAt(index: number): boolean {\n return (this.state.selectedItemIndex === index)\n }\n\n private toggleItemAt(index: number) {\n if ((this.props.isTogglable ?? true) && this.isItemSelectedAt(index)) {\n this.deselectItemAt(index)\n }\n else {\n this.selectItemAt(index)\n }\n }\n\n private selectItemAt(index: number) {\n if (this.isItemSelectedAt(index)) return\n\n this.setState({\n selectedItemIndex: index,\n })\n }\n\n private deselectItemAt(index: number) {\n if (!this.isItemSelectedAt(index)) return\n\n this.setState({\n selectedItemIndex: -1,\n })\n }\n}\n\nconst StyledItemList = styled(List)<{\n itemPadding: number\n borderThickness: number\n orientation: Orientation\n}>`\n transition-duration: 100ms;\n transition-timing-function: ease-out;\n\n ${props => props.orientation === 'vertical' ? css`\n width: 100%;\n transition-property: height, margin;\n will-change: height, margin;\n top: 100%;\n ` : css`\n height: 100%;\n transition-property: width, margin;\n will-change: width, margin;\n left: 100%;\n `}\n`\n\nconst StyledSectionHeader = styled.button<SectionHeaderCSSProps & ExtendedCSSProps<SectionHeaderCSSProps>>`\n align-items: center;\n background: #fff;\n border-color: ${props => props.borderColor};\n border-style: solid;\n border-width: ${props => props.borderThickness};\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 ${props => props.orientation === 'vertical' ? css`\n height: 50px;\n width: 100%;\n ` : css`\n height: 100%;\n width: 50px;\n `}\n\n ${props => props.extendedCSS(props)}\n`\n\nconst StyledSection = styled.section<SectionCSSProps & ExtendedCSSProps<SectionCSSProps>>`\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 ${props => props.orientation === 'vertical' ? css`\n width: 100%;\n flex-direction: column;\n ` : css`\n height: 100%;\n flex-direction: row;\n `}\n\n ${props => props.extendedCSS(props)}\n`\n\nconst StyledRoot = styled.div<{\n orientation: Orientation\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 ${props => props.orientation === 'vertical' ? css`\n flex-direction: column;\n ` : css`\n flex-direction: row;\n `}\n`\n"]}
|