@zendeskgarden/react-accordions 8.69.6 → 8.69.7
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/dist/index.cjs.js +147 -169
- package/dist/index.esm.js +150 -170
- package/dist/typings/elements/accordion/Accordion.d.ts +5 -5
- package/dist/typings/styled/accordion/StyledInnerPanel.d.ts +4 -9
- package/dist/typings/types/index.d.ts +7 -6
- package/dist/typings/utils/useAccordionContext.d.ts +6 -12
- package/dist/typings/utils/useStepContext.d.ts +3 -0
- package/dist/typings/utils/useStepperContext.d.ts +0 -1
- package/package.json +5 -8
package/dist/index.cjs.js
CHANGED
|
@@ -13,8 +13,6 @@ var styled = require('styled-components');
|
|
|
13
13
|
var reactTheming = require('@zendeskgarden/react-theming');
|
|
14
14
|
var polished = require('polished');
|
|
15
15
|
var containerUtilities = require('@zendeskgarden/container-utilities');
|
|
16
|
-
var debounce = require('lodash.debounce');
|
|
17
|
-
var mergeRefs = require('react-merge-refs');
|
|
18
16
|
var PropTypes = require('prop-types');
|
|
19
17
|
|
|
20
18
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -39,8 +37,6 @@ function _interopNamespace(e) {
|
|
|
39
37
|
|
|
40
38
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
41
39
|
var styled__default = /*#__PURE__*/_interopDefault(styled);
|
|
42
|
-
var debounce__default = /*#__PURE__*/_interopDefault(debounce);
|
|
43
|
-
var mergeRefs__default = /*#__PURE__*/_interopDefault(mergeRefs);
|
|
44
40
|
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
45
41
|
|
|
46
42
|
function _extends$3() {
|
|
@@ -59,7 +55,7 @@ function _extends$3() {
|
|
|
59
55
|
}
|
|
60
56
|
|
|
61
57
|
const COMPONENT_ID$k = 'accordions.step_content';
|
|
62
|
-
const sizeStyles$
|
|
58
|
+
const sizeStyles$2 = props => {
|
|
63
59
|
const {
|
|
64
60
|
rtl,
|
|
65
61
|
space
|
|
@@ -74,11 +70,11 @@ const sizeStyles$1 = props => {
|
|
|
74
70
|
};
|
|
75
71
|
const StyledContent = styled__default.default.div.attrs({
|
|
76
72
|
'data-garden-id': COMPONENT_ID$k,
|
|
77
|
-
'data-garden-version': '8.69.
|
|
73
|
+
'data-garden-version': '8.69.7'
|
|
78
74
|
}).withConfig({
|
|
79
75
|
displayName: "StyledContent",
|
|
80
76
|
componentId: "sc-mazvvo-0"
|
|
81
|
-
})(["display:grid;grid-template-rows:", "fr;transition:grid-template-rows 0.25s ease-in-out;word-break:break-word;", " ", ";"], props => props.isActive ? 1 : 0, sizeStyles$
|
|
77
|
+
})(["display:grid;grid-template-rows:", "fr;transition:grid-template-rows 0.25s ease-in-out;word-break:break-word;", " ", ";"], props => props.isActive ? 1 : 0, sizeStyles$2, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$k, props));
|
|
82
78
|
StyledContent.defaultProps = {
|
|
83
79
|
theme: reactTheming.DEFAULT_THEME
|
|
84
80
|
};
|
|
@@ -86,7 +82,7 @@ StyledContent.defaultProps = {
|
|
|
86
82
|
const COMPONENT_ID$j = 'accordions.step_line';
|
|
87
83
|
const StyledLine = styled__default.default.div.attrs({
|
|
88
84
|
'data-garden-id': COMPONENT_ID$j,
|
|
89
|
-
'data-garden-version': '8.69.
|
|
85
|
+
'data-garden-version': '8.69.7'
|
|
90
86
|
}).withConfig({
|
|
91
87
|
displayName: "StyledLine",
|
|
92
88
|
componentId: "sc-1gkpjbr-0"
|
|
@@ -98,7 +94,7 @@ StyledLine.defaultProps = {
|
|
|
98
94
|
const COMPONENT_ID$i = 'accordions.step';
|
|
99
95
|
const StyledStep = styled__default.default.li.attrs({
|
|
100
96
|
'data-garden-id': COMPONENT_ID$i,
|
|
101
|
-
'data-garden-version': '8.69.
|
|
97
|
+
'data-garden-version': '8.69.7'
|
|
102
98
|
}).withConfig({
|
|
103
99
|
displayName: "StyledStep",
|
|
104
100
|
componentId: "sc-12fiwtz-0"
|
|
@@ -110,7 +106,7 @@ StyledStep.defaultProps = {
|
|
|
110
106
|
const COMPONENT_ID$h = 'accordions.step_inner_content';
|
|
111
107
|
const StyledInnerContent = styled__default.default.div.attrs({
|
|
112
108
|
'data-garden-id': COMPONENT_ID$h,
|
|
113
|
-
'data-garden-version': '8.69.
|
|
109
|
+
'data-garden-version': '8.69.7'
|
|
114
110
|
}).withConfig({
|
|
115
111
|
displayName: "StyledInnerContent",
|
|
116
112
|
componentId: "sc-1xs9fh7-0"
|
|
@@ -122,7 +118,7 @@ StyledInnerContent.defaultProps = {
|
|
|
122
118
|
const COMPONENT_ID$g = 'accordions.stepper';
|
|
123
119
|
const StyledStepper = styled__default.default.ol.attrs({
|
|
124
120
|
'data-garden-id': COMPONENT_ID$g,
|
|
125
|
-
'data-garden-version': '8.69.
|
|
121
|
+
'data-garden-version': '8.69.7'
|
|
126
122
|
}).withConfig({
|
|
127
123
|
displayName: "StyledStepper",
|
|
128
124
|
componentId: "sc-dsxw0f-0"
|
|
@@ -136,21 +132,21 @@ const StyledIconFlexContainer = styled__default.default.div.withConfig({
|
|
|
136
132
|
displayName: "StyledIcon__StyledIconFlexContainer",
|
|
137
133
|
componentId: "sc-v20nz9-0"
|
|
138
134
|
})(["display:flex;flex-basis:100%;justify-content:center;width:100%;"]);
|
|
139
|
-
const sizeStyles = props => {
|
|
135
|
+
const sizeStyles$1 = props => {
|
|
140
136
|
const size = `${props.theme.space.base * 6}px`;
|
|
141
137
|
const fontSize = props.theme.fontSizes.sm;
|
|
142
138
|
return styled.css(["margin-bottom:", ";margin-", ":", ";width:", ";min-width:", ";height:", ";min-height:", ";line-height:", ";font-size:", ";"], props.isHorizontal && `${props.theme.space.base * 2}px`, props.theme.rtl ? 'left' : 'right', !props.isHorizontal && `${props.theme.space.base * 3}px`, size, size, size, size, reactTheming.getLineHeight(size, fontSize), fontSize);
|
|
143
139
|
};
|
|
144
|
-
const colorStyles$
|
|
140
|
+
const colorStyles$3 = props => {
|
|
145
141
|
return styled.css(["background:", ";color:", ";"], props.isActive ? reactTheming.getColor('neutralHue', 600, props.theme) : reactTheming.getColor('neutralHue', 200, props.theme), props.isActive ? props.theme.colors.background : props.theme.colors.foreground);
|
|
146
142
|
};
|
|
147
143
|
const StyledIcon = styled__default.default.div.attrs({
|
|
148
144
|
'data-garden-id': COMPONENT_ID$f,
|
|
149
|
-
'data-garden-version': '8.69.
|
|
145
|
+
'data-garden-version': '8.69.7'
|
|
150
146
|
}).withConfig({
|
|
151
147
|
displayName: "StyledIcon",
|
|
152
148
|
componentId: "sc-v20nz9-1"
|
|
153
|
-
})(["display:flex;align-items:center;justify-content:center;transition:background 0.25s ease-in-out,color 0.25s ease-in-out;border-radius:100%;", " ", " ", ";"], sizeStyles, colorStyles$
|
|
149
|
+
})(["display:flex;align-items:center;justify-content:center;transition:background 0.25s ease-in-out,color 0.25s ease-in-out;border-radius:100%;", " ", " ", ";"], sizeStyles$1, colorStyles$3, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$f, props));
|
|
154
150
|
StyledIconFlexContainer.defaultProps = {
|
|
155
151
|
theme: reactTheming.DEFAULT_THEME
|
|
156
152
|
};
|
|
@@ -161,7 +157,7 @@ StyledIcon.defaultProps = {
|
|
|
161
157
|
const COMPONENT_ID$e = 'accordions.step_label';
|
|
162
158
|
const StyledLabel = styled__default.default.div.attrs({
|
|
163
159
|
'data-garden-id': COMPONENT_ID$e,
|
|
164
|
-
'data-garden-version': '8.69.
|
|
160
|
+
'data-garden-version': '8.69.7'
|
|
165
161
|
}).withConfig({
|
|
166
162
|
displayName: "StyledLabel",
|
|
167
163
|
componentId: "sc-1o82llj-0"
|
|
@@ -173,7 +169,7 @@ StyledLabel.defaultProps = {
|
|
|
173
169
|
const COMPONENT_ID$d = 'accordions.step_label_text';
|
|
174
170
|
const StyledLabelText = styled__default.default.div.attrs({
|
|
175
171
|
'data-garden-id': COMPONENT_ID$d,
|
|
176
|
-
'data-garden-version': '8.69.
|
|
172
|
+
'data-garden-version': '8.69.7'
|
|
177
173
|
}).withConfig({
|
|
178
174
|
displayName: "StyledLabelText",
|
|
179
175
|
componentId: "sc-111m5zo-0"
|
|
@@ -185,7 +181,7 @@ StyledLabelText.defaultProps = {
|
|
|
185
181
|
const COMPONENT_ID$c = 'accordions.accordion';
|
|
186
182
|
const StyledAccordion = styled__default.default.div.attrs({
|
|
187
183
|
'data-garden-id': COMPONENT_ID$c,
|
|
188
|
-
'data-garden-version': '8.69.
|
|
184
|
+
'data-garden-version': '8.69.7'
|
|
189
185
|
}).withConfig({
|
|
190
186
|
displayName: "StyledAccordion",
|
|
191
187
|
componentId: "sc-niv9ic-0"
|
|
@@ -195,31 +191,43 @@ StyledAccordion.defaultProps = {
|
|
|
195
191
|
};
|
|
196
192
|
|
|
197
193
|
const COMPONENT_ID$b = 'accordions.panel';
|
|
198
|
-
const
|
|
194
|
+
const colorStyles$2 = props => {
|
|
195
|
+
const {
|
|
196
|
+
theme,
|
|
197
|
+
isBare
|
|
198
|
+
} = props;
|
|
199
|
+
return styled.css(["border-bottom-color:", ";"], isBare ? 'transparent' : reactTheming.getColor('neutralHue', 300, theme));
|
|
200
|
+
};
|
|
201
|
+
const sizeStyles = props => {
|
|
202
|
+
const {
|
|
203
|
+
theme,
|
|
204
|
+
isCompact,
|
|
205
|
+
isExpanded
|
|
206
|
+
} = props;
|
|
199
207
|
const {
|
|
200
208
|
base
|
|
201
|
-
} =
|
|
209
|
+
} = theme.space;
|
|
202
210
|
let paddingTop = base * 2;
|
|
203
211
|
let paddingHorizontal = base * 5;
|
|
204
212
|
let paddingBottom = base * 8;
|
|
205
|
-
if (
|
|
213
|
+
if (isCompact) {
|
|
206
214
|
paddingTop = base * 2;
|
|
207
215
|
paddingHorizontal = base * 3;
|
|
208
216
|
paddingBottom = base * 4;
|
|
209
217
|
}
|
|
210
|
-
if (
|
|
218
|
+
if (isExpanded === false) {
|
|
211
219
|
paddingTop = 0;
|
|
212
220
|
paddingBottom = 0;
|
|
213
221
|
}
|
|
214
|
-
return styled.css(["
|
|
222
|
+
return styled.css(["grid-template-rows:", "fr;border-bottom-width:", ";border-bottom-style:solid;padding:", "px ", "px ", "px;line-height:", ";font-size:", ";"], isExpanded ? 1 : 0, theme.borderWidths.sm, paddingTop, paddingHorizontal, paddingBottom, reactTheming.getLineHeight(base * 5, theme.fontSizes.md), theme.fontSizes.md);
|
|
215
223
|
};
|
|
216
224
|
const StyledPanel = styled__default.default.section.attrs({
|
|
217
225
|
'data-garden-id': COMPONENT_ID$b,
|
|
218
|
-
'data-garden-version': '8.69.
|
|
226
|
+
'data-garden-version': '8.69.7'
|
|
219
227
|
}).withConfig({
|
|
220
228
|
displayName: "StyledPanel",
|
|
221
229
|
componentId: "sc-1piryze-0"
|
|
222
|
-
})(["", ";
|
|
230
|
+
})(["display:grid;transition:", ";overflow:hidden;", " ", " ", ";"], props => props.isAnimated && 'padding 0.25s ease-in-out, grid-template-rows 0.25s ease-in-out', sizeStyles, colorStyles$2, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$b, props));
|
|
223
231
|
StyledPanel.defaultProps = {
|
|
224
232
|
isAnimated: true,
|
|
225
233
|
theme: reactTheming.DEFAULT_THEME
|
|
@@ -228,7 +236,7 @@ StyledPanel.defaultProps = {
|
|
|
228
236
|
const COMPONENT_ID$a = 'accordions.section';
|
|
229
237
|
const StyledSection = styled__default.default.div.attrs({
|
|
230
238
|
'data-garden-id': COMPONENT_ID$a,
|
|
231
|
-
'data-garden-version': '8.69.
|
|
239
|
+
'data-garden-version': '8.69.7'
|
|
232
240
|
}).withConfig({
|
|
233
241
|
displayName: "StyledSection",
|
|
234
242
|
componentId: "sc-v2t9bd-0"
|
|
@@ -240,7 +248,7 @@ StyledSection.defaultProps = {
|
|
|
240
248
|
const COMPONENT_ID$9 = 'accordions.header';
|
|
241
249
|
const StyledHeader = styled__default.default.div.attrs({
|
|
242
250
|
'data-garden-id': COMPONENT_ID$9,
|
|
243
|
-
'data-garden-version': '8.69.
|
|
251
|
+
'data-garden-version': '8.69.7'
|
|
244
252
|
}).withConfig({
|
|
245
253
|
displayName: "StyledHeader",
|
|
246
254
|
componentId: "sc-2c6rbr-0"
|
|
@@ -265,7 +273,7 @@ const colorStyles$1 = props => {
|
|
|
265
273
|
};
|
|
266
274
|
const StyledButton = styled__default.default.button.attrs({
|
|
267
275
|
'data-garden-id': COMPONENT_ID$8,
|
|
268
|
-
'data-garden-version': '8.69.
|
|
276
|
+
'data-garden-version': '8.69.7'
|
|
269
277
|
}).withConfig({
|
|
270
278
|
displayName: "StyledButton",
|
|
271
279
|
componentId: "sc-xj3hy7-0"
|
|
@@ -277,13 +285,12 @@ StyledButton.defaultProps = {
|
|
|
277
285
|
const COMPONENT_ID$7 = 'accordions.step_inner_panel';
|
|
278
286
|
const StyledInnerPanel = styled__default.default.div.attrs({
|
|
279
287
|
'data-garden-id': COMPONENT_ID$7,
|
|
280
|
-
'data-garden-version': '8.69.
|
|
288
|
+
'data-garden-version': '8.69.7'
|
|
281
289
|
}).withConfig({
|
|
282
290
|
displayName: "StyledInnerPanel",
|
|
283
291
|
componentId: "sc-8nbueg-0"
|
|
284
|
-
})(["
|
|
292
|
+
})(["overflow:hidden;line-height:inherit;font-size:inherit;", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$7, props));
|
|
285
293
|
StyledInnerPanel.defaultProps = {
|
|
286
|
-
isAnimated: true,
|
|
287
294
|
theme: reactTheming.DEFAULT_THEME
|
|
288
295
|
};
|
|
289
296
|
|
|
@@ -309,7 +316,7 @@ _ref => {
|
|
|
309
316
|
return React.cloneElement(React.Children.only(children), props);
|
|
310
317
|
}).attrs({
|
|
311
318
|
'data-garden-id': COMPONENT_ID$6,
|
|
312
|
-
'data-garden-version': '8.69.
|
|
319
|
+
'data-garden-version': '8.69.7'
|
|
313
320
|
}).withConfig({
|
|
314
321
|
displayName: "StyledRotateIcon",
|
|
315
322
|
componentId: "sc-hp435q-0"
|
|
@@ -321,7 +328,7 @@ StyledRotateIcon.defaultProps = {
|
|
|
321
328
|
const COMPONENT_ID$5 = 'timeline';
|
|
322
329
|
const StyledTimeline = styled__default.default.ol.attrs({
|
|
323
330
|
'data-garden-id': COMPONENT_ID$5,
|
|
324
|
-
'data-garden-version': '8.69.
|
|
331
|
+
'data-garden-version': '8.69.7'
|
|
325
332
|
}).withConfig({
|
|
326
333
|
displayName: "StyledTimeline",
|
|
327
334
|
componentId: "sc-pig5kv-0"
|
|
@@ -333,7 +340,7 @@ StyledTimeline.defaultProps = {
|
|
|
333
340
|
const COMPONENT_ID$4 = 'timeline.content.separator';
|
|
334
341
|
const StyledSeparator = styled__default.default.div.attrs({
|
|
335
342
|
'data-garden-id': COMPONENT_ID$4,
|
|
336
|
-
'data-garden-version': '8.69.
|
|
343
|
+
'data-garden-version': '8.69.7'
|
|
337
344
|
}).withConfig({
|
|
338
345
|
displayName: "StyledSeparator",
|
|
339
346
|
componentId: "sc-fki51e-0"
|
|
@@ -345,7 +352,7 @@ StyledSeparator.defaultProps = {
|
|
|
345
352
|
const COMPONENT_ID$3 = 'timeline.content';
|
|
346
353
|
const StyledTimelineContent = styled__default.default.div.attrs({
|
|
347
354
|
'data-garden-id': COMPONENT_ID$3,
|
|
348
|
-
'data-garden-version': '8.69.
|
|
355
|
+
'data-garden-version': '8.69.7'
|
|
349
356
|
}).withConfig({
|
|
350
357
|
displayName: "StyledContent__StyledTimelineContent",
|
|
351
358
|
componentId: "sc-19phgu1-0"
|
|
@@ -357,7 +364,7 @@ StyledTimelineContent.defaultProps = {
|
|
|
357
364
|
const COMPONENT_ID$2 = 'timeline.opposite.content';
|
|
358
365
|
const StyledOppositeContent = styled__default.default.div.attrs({
|
|
359
366
|
'data-garden-id': COMPONENT_ID$2,
|
|
360
|
-
'data-garden-version': '8.69.
|
|
367
|
+
'data-garden-version': '8.69.7'
|
|
361
368
|
}).withConfig({
|
|
362
369
|
displayName: "StyledOppositeContent",
|
|
363
370
|
componentId: "sc-jurh2k-0"
|
|
@@ -369,7 +376,7 @@ StyledOppositeContent.defaultProps = {
|
|
|
369
376
|
const COMPONENT_ID$1 = 'timeline.item';
|
|
370
377
|
const StyledTimelineItem = styled__default.default.li.attrs({
|
|
371
378
|
'data-garden-id': COMPONENT_ID$1,
|
|
372
|
-
'data-garden-version': '8.69.
|
|
379
|
+
'data-garden-version': '8.69.7'
|
|
373
380
|
}).withConfig({
|
|
374
381
|
displayName: "StyledItem__StyledTimelineItem",
|
|
375
382
|
componentId: "sc-5mcnzm-0"
|
|
@@ -388,7 +395,7 @@ const StyledItemIcon = styled__default.default(_ref => {
|
|
|
388
395
|
return React.cloneElement(React.Children.only(children), props);
|
|
389
396
|
}).attrs({
|
|
390
397
|
'data-garden-id': COMPONENT_ID,
|
|
391
|
-
'data-garden-version': '8.69.
|
|
398
|
+
'data-garden-version': '8.69.7'
|
|
392
399
|
}).withConfig({
|
|
393
400
|
displayName: "StyledItemIcon",
|
|
394
401
|
componentId: "sc-vz2l6e-0"
|
|
@@ -410,7 +417,7 @@ const StepContext = React.createContext(undefined);
|
|
|
410
417
|
const useStepContext = () => {
|
|
411
418
|
const context = React.useContext(StepContext);
|
|
412
419
|
if (context === undefined) {
|
|
413
|
-
throw new Error('This component must be rendered within a Stepper
|
|
420
|
+
throw new Error('This component must be rendered within a Stepper component');
|
|
414
421
|
}
|
|
415
422
|
return context;
|
|
416
423
|
};
|
|
@@ -428,7 +435,7 @@ const SectionContext = React.createContext(undefined);
|
|
|
428
435
|
const useSectionContext = () => {
|
|
429
436
|
const context = React.useContext(SectionContext);
|
|
430
437
|
if (context === undefined) {
|
|
431
|
-
throw new Error('This component must be rendered within
|
|
438
|
+
throw new Error('This component must be rendered within an Accordion component');
|
|
432
439
|
}
|
|
433
440
|
return context;
|
|
434
441
|
};
|
|
@@ -460,18 +467,9 @@ const useTimelineItemContext = () => {
|
|
|
460
467
|
return context;
|
|
461
468
|
};
|
|
462
469
|
|
|
463
|
-
const SectionComponent = React.forwardRef((props, ref) => {
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
} = useAccordionContext();
|
|
467
|
-
const sectionIndexRef = React.useRef(currentIndexRef.current++);
|
|
468
|
-
const sectionIndex = sectionIndexRef.current;
|
|
469
|
-
return React__namespace.default.createElement(SectionContext.Provider, {
|
|
470
|
-
value: sectionIndex
|
|
471
|
-
}, React__namespace.default.createElement(StyledSection, _extends$3({
|
|
472
|
-
ref: ref
|
|
473
|
-
}, props)));
|
|
474
|
-
});
|
|
470
|
+
const SectionComponent = React.forwardRef((props, ref) => React__namespace.default.createElement(StyledSection, _extends$3({
|
|
471
|
+
ref: ref
|
|
472
|
+
}, props)));
|
|
475
473
|
SectionComponent.displayName = 'Accordion.Section';
|
|
476
474
|
const Section = SectionComponent;
|
|
477
475
|
|
|
@@ -492,34 +490,35 @@ var SvgChevronDownStroke = function SvgChevronDownStroke(props) {
|
|
|
492
490
|
};
|
|
493
491
|
|
|
494
492
|
const HeaderComponent = React.forwardRef((props, ref) => {
|
|
495
|
-
const {
|
|
496
|
-
level: ariaLevel,
|
|
497
|
-
isCompact,
|
|
498
|
-
isCollapsible,
|
|
499
|
-
getHeaderProps,
|
|
500
|
-
getTriggerProps,
|
|
501
|
-
expandedSections
|
|
502
|
-
} = useAccordionContext();
|
|
503
493
|
const {
|
|
504
494
|
onClick,
|
|
505
495
|
onFocus,
|
|
506
496
|
onBlur,
|
|
507
497
|
onMouseOver,
|
|
508
498
|
onMouseOut,
|
|
499
|
+
role,
|
|
509
500
|
children,
|
|
510
501
|
...other
|
|
511
502
|
} = props;
|
|
512
|
-
const
|
|
503
|
+
const {
|
|
504
|
+
level: ariaLevel,
|
|
505
|
+
isCompact,
|
|
506
|
+
isCollapsible,
|
|
507
|
+
getHeaderProps,
|
|
508
|
+
getTriggerProps,
|
|
509
|
+
expandedSections
|
|
510
|
+
} = useAccordionContext();
|
|
511
|
+
const sectionValue = useSectionContext();
|
|
513
512
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
514
513
|
const [isHovered, setIsHovered] = React.useState(false);
|
|
515
|
-
const isExpanded = expandedSections.includes(
|
|
514
|
+
const isExpanded = expandedSections.includes(sectionValue);
|
|
516
515
|
const {
|
|
517
516
|
onClick: onTriggerClick,
|
|
518
517
|
onKeyDown,
|
|
519
518
|
...otherTriggerProps
|
|
520
519
|
} = getTriggerProps({
|
|
521
520
|
type: 'button',
|
|
522
|
-
|
|
521
|
+
value: sectionValue
|
|
523
522
|
});
|
|
524
523
|
const onHeaderFocus = e => {
|
|
525
524
|
e.persist();
|
|
@@ -537,20 +536,21 @@ const HeaderComponent = React.forwardRef((props, ref) => {
|
|
|
537
536
|
}), [isHovered, otherTriggerProps]);
|
|
538
537
|
return React__namespace.default.createElement(HeaderContext.Provider, {
|
|
539
538
|
value: value
|
|
540
|
-
}, React__namespace.default.createElement(StyledHeader,
|
|
539
|
+
}, React__namespace.default.createElement(StyledHeader, _extends$3({
|
|
540
|
+
isCollapsible: isCollapsible,
|
|
541
|
+
isExpanded: isExpanded,
|
|
542
|
+
isFocused: isFocused
|
|
543
|
+
}, getHeaderProps({
|
|
541
544
|
ref,
|
|
542
|
-
ariaLevel,
|
|
543
|
-
|
|
544
|
-
isFocused,
|
|
545
|
-
isExpanded,
|
|
546
|
-
isCollapsible,
|
|
545
|
+
'aria-level': ariaLevel,
|
|
546
|
+
role: role === undefined || role === null ? role : 'heading',
|
|
547
547
|
onClick: containerUtilities.composeEventHandlers(onClick, onTriggerClick),
|
|
548
548
|
onFocus: containerUtilities.composeEventHandlers(onFocus, onHeaderFocus),
|
|
549
549
|
onBlur: containerUtilities.composeEventHandlers(onBlur, () => setIsFocused(false)),
|
|
550
550
|
onMouseOver: containerUtilities.composeEventHandlers(onMouseOver, () => setIsHovered(true)),
|
|
551
551
|
onMouseOut: containerUtilities.composeEventHandlers(onMouseOut, () => setIsHovered(false)),
|
|
552
552
|
...other
|
|
553
|
-
}), children, React__namespace.default.createElement(StyledRotateIcon, {
|
|
553
|
+
})), children, React__namespace.default.createElement(StyledRotateIcon, {
|
|
554
554
|
isCompact: isCompact,
|
|
555
555
|
isHovered: isHovered,
|
|
556
556
|
isRotated: isExpanded,
|
|
@@ -563,13 +563,13 @@ HeaderComponent.displayName = 'Accordion.Header';
|
|
|
563
563
|
const Header = HeaderComponent;
|
|
564
564
|
|
|
565
565
|
const LabelComponent$1 = React.forwardRef((props, ref) => {
|
|
566
|
-
const
|
|
566
|
+
const sectionValue = useSectionContext();
|
|
567
567
|
const {
|
|
568
568
|
isCompact,
|
|
569
569
|
isCollapsible,
|
|
570
570
|
expandedSections
|
|
571
571
|
} = useAccordionContext();
|
|
572
|
-
const isExpanded = expandedSections.includes(
|
|
572
|
+
const isExpanded = expandedSections.includes(sectionValue);
|
|
573
573
|
const {
|
|
574
574
|
isHovered,
|
|
575
575
|
otherTriggerProps
|
|
@@ -585,87 +585,78 @@ const LabelComponent$1 = React.forwardRef((props, ref) => {
|
|
|
585
585
|
LabelComponent$1.displayName = 'Accordion.Label';
|
|
586
586
|
const Label$1 = LabelComponent$1;
|
|
587
587
|
|
|
588
|
-
const PanelComponent = React.forwardRef((
|
|
588
|
+
const PanelComponent = React.forwardRef((_ref, ref) => {
|
|
589
|
+
let {
|
|
590
|
+
role,
|
|
591
|
+
children,
|
|
592
|
+
...props
|
|
593
|
+
} = _ref;
|
|
589
594
|
const {
|
|
590
|
-
isCompact,
|
|
591
|
-
isBare,
|
|
592
595
|
isAnimated,
|
|
593
|
-
getPanelProps,
|
|
594
|
-
expandedSections
|
|
595
|
-
} = useAccordionContext();
|
|
596
|
-
const panelRef = React.useRef();
|
|
597
|
-
const index = useSectionContext();
|
|
598
|
-
const isExpanded = expandedSections.includes(index);
|
|
599
|
-
const theme = React.useContext(styled.ThemeContext);
|
|
600
|
-
const environment = reactTheming.useDocument(theme);
|
|
601
|
-
React.useEffect(() => {
|
|
602
|
-
if (!isAnimated) {
|
|
603
|
-
return undefined;
|
|
604
|
-
}
|
|
605
|
-
if (environment) {
|
|
606
|
-
const updateMaxHeight = debounce__default.default(() => {
|
|
607
|
-
if (panelRef.current) {
|
|
608
|
-
const child = panelRef.current.children[0];
|
|
609
|
-
child.style.maxHeight = `${child.scrollHeight}px`;
|
|
610
|
-
}
|
|
611
|
-
}, 100);
|
|
612
|
-
const win = environment.defaultView || window;
|
|
613
|
-
win.addEventListener('resize', updateMaxHeight);
|
|
614
|
-
updateMaxHeight();
|
|
615
|
-
return () => {
|
|
616
|
-
updateMaxHeight.cancel();
|
|
617
|
-
win.removeEventListener('resize', updateMaxHeight);
|
|
618
|
-
};
|
|
619
|
-
}
|
|
620
|
-
return undefined;
|
|
621
|
-
}, [isAnimated, panelRef, environment, props.children]);
|
|
622
|
-
return React__namespace.default.createElement(StyledPanel, getPanelProps({
|
|
623
|
-
role: null,
|
|
624
|
-
ref: mergeRefs__default.default([panelRef, ref]),
|
|
625
|
-
index,
|
|
626
596
|
isBare,
|
|
627
597
|
isCompact,
|
|
628
|
-
|
|
629
|
-
|
|
598
|
+
expandedSections,
|
|
599
|
+
getPanelProps
|
|
600
|
+
} = useAccordionContext();
|
|
601
|
+
const sectionValue = useSectionContext();
|
|
602
|
+
const isExpanded = expandedSections.includes(sectionValue);
|
|
603
|
+
return React__namespace.default.createElement(StyledPanel, _extends$3({
|
|
604
|
+
isAnimated: isAnimated,
|
|
605
|
+
isBare: isBare,
|
|
606
|
+
isCompact: isCompact,
|
|
607
|
+
isExpanded: isExpanded
|
|
608
|
+
}, getPanelProps({
|
|
609
|
+
role: role === undefined ? null : 'region',
|
|
610
|
+
ref,
|
|
611
|
+
value: sectionValue,
|
|
630
612
|
...props
|
|
631
|
-
}), React__namespace.default.createElement(StyledInnerPanel,
|
|
632
|
-
isExpanded: isExpanded,
|
|
633
|
-
isAnimated: isAnimated
|
|
634
|
-
}, props.children));
|
|
613
|
+
})), React__namespace.default.createElement(StyledInnerPanel, null, children));
|
|
635
614
|
});
|
|
636
615
|
PanelComponent.displayName = 'Accordion.Panel';
|
|
637
616
|
const Panel = PanelComponent;
|
|
638
617
|
|
|
639
618
|
const AccordionComponent = React.forwardRef((_ref, ref) => {
|
|
640
619
|
let {
|
|
641
|
-
|
|
620
|
+
children,
|
|
642
621
|
isBare,
|
|
643
|
-
onChange,
|
|
644
622
|
isCompact,
|
|
645
623
|
isAnimated,
|
|
646
624
|
isExpandable,
|
|
647
625
|
isCollapsible,
|
|
626
|
+
level,
|
|
627
|
+
onChange,
|
|
648
628
|
defaultExpandedSections,
|
|
649
629
|
expandedSections: controlledExpandedSections,
|
|
650
630
|
...props
|
|
651
631
|
} = _ref;
|
|
632
|
+
const {
|
|
633
|
+
sections,
|
|
634
|
+
sectionChildren
|
|
635
|
+
} = React.useMemo(() => React.Children.toArray(children).filter(React.isValidElement).map((child, index) => React__namespace.default.createElement(SectionContext.Provider, {
|
|
636
|
+
key: index,
|
|
637
|
+
value: index
|
|
638
|
+
}, child)).reduce((acc, child, index) => {
|
|
639
|
+
acc.sectionChildren.push(child);
|
|
640
|
+
acc.sections.push(index);
|
|
641
|
+
return acc;
|
|
642
|
+
}, {
|
|
643
|
+
sectionChildren: [],
|
|
644
|
+
sections: []
|
|
645
|
+
}), [children]);
|
|
652
646
|
const {
|
|
653
647
|
expandedSections,
|
|
654
648
|
getHeaderProps,
|
|
655
649
|
getTriggerProps,
|
|
656
650
|
getPanelProps
|
|
657
651
|
} = containerAccordion.useAccordion({
|
|
652
|
+
sections,
|
|
653
|
+
defaultExpandedSections,
|
|
654
|
+
expandedSections: controlledExpandedSections,
|
|
658
655
|
collapsible: isCollapsible,
|
|
659
656
|
expandable: isExpandable || false,
|
|
660
|
-
onChange
|
|
661
|
-
defaultExpandedSections,
|
|
662
|
-
expandedSections: controlledExpandedSections
|
|
663
|
-
});
|
|
664
|
-
const currentIndexRef = React.useRef(0);
|
|
665
|
-
React.useEffect(() => {
|
|
666
|
-
currentIndexRef.current = 0;
|
|
657
|
+
onChange
|
|
667
658
|
});
|
|
668
|
-
const
|
|
659
|
+
const accordionContextValue = React.useMemo(() => ({
|
|
669
660
|
level,
|
|
670
661
|
isBare,
|
|
671
662
|
isCompact,
|
|
@@ -674,14 +665,13 @@ const AccordionComponent = React.forwardRef((_ref, ref) => {
|
|
|
674
665
|
getPanelProps,
|
|
675
666
|
getHeaderProps,
|
|
676
667
|
getTriggerProps,
|
|
677
|
-
currentIndexRef,
|
|
678
668
|
expandedSections
|
|
679
|
-
}), [level, isBare, isCompact, isAnimated, isCollapsible, getPanelProps, getHeaderProps, getTriggerProps,
|
|
669
|
+
}), [level, isBare, isCompact, isAnimated, isCollapsible, getPanelProps, getHeaderProps, getTriggerProps, expandedSections]);
|
|
680
670
|
return React__namespace.default.createElement(AccordionContext.Provider, {
|
|
681
|
-
value:
|
|
671
|
+
value: accordionContextValue
|
|
682
672
|
}, React__namespace.default.createElement(StyledAccordion, _extends$3({
|
|
683
673
|
ref: ref
|
|
684
|
-
}, props)));
|
|
674
|
+
}, props), sectionChildren));
|
|
685
675
|
});
|
|
686
676
|
AccordionComponent.displayName = 'Accordion';
|
|
687
677
|
AccordionComponent.defaultProps = {
|
|
@@ -694,29 +684,18 @@ Accordion.Label = Label$1;
|
|
|
694
684
|
Accordion.Panel = Panel;
|
|
695
685
|
Accordion.Section = Section;
|
|
696
686
|
|
|
697
|
-
const StepComponent = React.forwardRef((
|
|
687
|
+
const StepComponent = React.forwardRef((_ref, ref) => {
|
|
688
|
+
let {
|
|
689
|
+
children,
|
|
690
|
+
...props
|
|
691
|
+
} = _ref;
|
|
698
692
|
const {
|
|
699
|
-
currentIndexRef,
|
|
700
693
|
isHorizontal
|
|
701
694
|
} = useStepperContext();
|
|
702
|
-
|
|
703
|
-
React.useLayoutEffect(() => {
|
|
704
|
-
setCurrentStepIndex(currentIndexRef.current);
|
|
705
|
-
currentIndexRef.current++;
|
|
706
|
-
const currentIndex = currentIndexRef;
|
|
707
|
-
return () => {
|
|
708
|
-
currentIndex.current--;
|
|
709
|
-
};
|
|
710
|
-
}, [currentIndexRef]);
|
|
711
|
-
const value = React.useMemo(() => ({
|
|
712
|
-
currentStepIndex
|
|
713
|
-
}), [currentStepIndex]);
|
|
714
|
-
return React__namespace.default.createElement(StepContext.Provider, {
|
|
715
|
-
value: value
|
|
716
|
-
}, React__namespace.default.createElement(StyledStep, _extends$3({
|
|
695
|
+
return React__namespace.default.createElement(StyledStep, _extends$3({
|
|
717
696
|
ref: ref,
|
|
718
697
|
isHorizontal: isHorizontal
|
|
719
|
-
}, props), isHorizontal && React__namespace.default.createElement(StyledLine, null),
|
|
698
|
+
}, props), isHorizontal && React__namespace.default.createElement(StyledLine, null), children);
|
|
720
699
|
});
|
|
721
700
|
StepComponent.displayName = 'Stepper.Step';
|
|
722
701
|
const Step = StepComponent;
|
|
@@ -750,16 +729,13 @@ const LabelComponent = React.forwardRef((_ref, ref) => {
|
|
|
750
729
|
...other
|
|
751
730
|
} = _ref;
|
|
752
731
|
const {
|
|
753
|
-
currentStepIndex
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
activeIndex,
|
|
732
|
+
currentStepIndex,
|
|
733
|
+
isActive,
|
|
734
|
+
isCompleted,
|
|
757
735
|
isHorizontal
|
|
758
|
-
} =
|
|
736
|
+
} = useStepContext();
|
|
759
737
|
const numericStep = currentStepIndex + 1;
|
|
760
738
|
const stepIcon = icon || numericStep;
|
|
761
|
-
const isActive = activeIndex === currentStepIndex;
|
|
762
|
-
const isCompleted = activeIndex > currentStepIndex;
|
|
763
739
|
const styledIcon = React__namespace.default.createElement(StyledIcon, {
|
|
764
740
|
isActive: isActive,
|
|
765
741
|
isHorizontal: isHorizontal
|
|
@@ -783,13 +759,9 @@ const Label = LabelComponent;
|
|
|
783
759
|
|
|
784
760
|
const ContentComponent$1 = React.forwardRef((props, ref) => {
|
|
785
761
|
const {
|
|
786
|
-
|
|
762
|
+
isActive,
|
|
787
763
|
isHorizontal
|
|
788
|
-
} = useStepperContext();
|
|
789
|
-
const {
|
|
790
|
-
currentStepIndex
|
|
791
764
|
} = useStepContext();
|
|
792
|
-
const isActive = currentStepIndex === activeIndex;
|
|
793
765
|
return isHorizontal === false ? React__namespace.default.createElement(StyledContent, _extends$3({
|
|
794
766
|
ref: ref,
|
|
795
767
|
isActive: isActive
|
|
@@ -800,31 +772,37 @@ const ContentComponent$1 = React.forwardRef((props, ref) => {
|
|
|
800
772
|
ContentComponent$1.displayName = 'Stepper.Content';
|
|
801
773
|
const Content$1 = ContentComponent$1;
|
|
802
774
|
|
|
775
|
+
const DEFAULT_ACTIVE_INDEX = 0;
|
|
803
776
|
const StepperComponent = React.forwardRef((_ref, ref) => {
|
|
804
777
|
let {
|
|
778
|
+
activeIndex = DEFAULT_ACTIVE_INDEX,
|
|
805
779
|
isHorizontal,
|
|
806
|
-
|
|
780
|
+
children,
|
|
807
781
|
...props
|
|
808
782
|
} = _ref;
|
|
809
|
-
const currentIndexRef = React.useRef(0);
|
|
810
783
|
const stepperContext = React.useMemo(() => ({
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
}), [isHorizontal, activeIndex, currentIndexRef]);
|
|
815
|
-
React.useEffect(() => {
|
|
816
|
-
currentIndexRef.current = 0;
|
|
817
|
-
});
|
|
784
|
+
activeIndex,
|
|
785
|
+
isHorizontal: isHorizontal || false
|
|
786
|
+
}), [activeIndex, isHorizontal]);
|
|
818
787
|
return React__namespace.default.createElement(StepperContext.Provider, {
|
|
819
788
|
value: stepperContext
|
|
820
789
|
}, React__namespace.default.createElement(StyledStepper, _extends$3({
|
|
821
790
|
ref: ref,
|
|
822
791
|
isHorizontal: isHorizontal
|
|
823
|
-
}, props)))
|
|
792
|
+
}, props), React.useMemo(() => React.Children.toArray(children).filter(React.isValidElement).map((child, index) => React__namespace.default.createElement(StepContext.Provider, {
|
|
793
|
+
key: index
|
|
794
|
+
,
|
|
795
|
+
value: {
|
|
796
|
+
currentStepIndex: index,
|
|
797
|
+
isActive: stepperContext.activeIndex === index,
|
|
798
|
+
isCompleted: stepperContext.activeIndex > index,
|
|
799
|
+
isHorizontal: stepperContext.isHorizontal
|
|
800
|
+
}
|
|
801
|
+
}, child)), [children, stepperContext])));
|
|
824
802
|
});
|
|
825
803
|
StepperComponent.displayName = 'Stepper';
|
|
826
804
|
StepperComponent.defaultProps = {
|
|
827
|
-
activeIndex:
|
|
805
|
+
activeIndex: DEFAULT_ACTIVE_INDEX
|
|
828
806
|
};
|
|
829
807
|
const Stepper = StepperComponent;
|
|
830
808
|
Stepper.Content = Content$1;
|