@lumx/react 3.0.1 → 3.0.2
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/esm/_internal/ClickAwayProvider.js +9 -5
- package/esm/_internal/ClickAwayProvider.js.map +1 -1
- package/esm/_internal/FlexBox.js.map +1 -1
- package/esm/_internal/HeadingLevelProvider.js +112 -0
- package/esm/_internal/HeadingLevelProvider.js.map +1 -0
- package/esm/_internal/ProgressTrackerStepPanel.js +2 -1
- package/esm/_internal/ProgressTrackerStepPanel.js.map +1 -1
- package/esm/_internal/Slides.js +270 -79
- package/esm/_internal/Slides.js.map +1 -1
- package/esm/_internal/TabPanel.js +2 -1
- package/esm/_internal/TabPanel.js.map +1 -1
- package/esm/_internal/Text2.js +63 -0
- package/esm/_internal/Text2.js.map +1 -0
- package/esm/_internal/_rollupPluginBabelHelpers.js +17 -1
- package/esm/_internal/_rollupPluginBabelHelpers.js.map +1 -1
- package/esm/_internal/components.js +1 -0
- package/esm/_internal/components.js.map +1 -1
- package/esm/_internal/heading.js +11 -0
- package/esm/_internal/heading.js.map +1 -0
- package/esm/_internal/progress-tracker.js +2 -1
- package/esm/_internal/progress-tracker.js.map +1 -1
- package/esm/_internal/slideshow.js +2 -0
- package/esm/_internal/slideshow.js.map +1 -1
- package/esm/_internal/state.js +145 -0
- package/esm/_internal/state.js.map +1 -0
- package/esm/_internal/tabs.js +1 -0
- package/esm/_internal/tabs.js.map +1 -1
- package/esm/_internal/text.js +10 -0
- package/esm/_internal/text.js.map +1 -0
- package/esm/_internal/useRovingTabIndex.js +9 -144
- package/esm/_internal/useRovingTabIndex.js.map +1 -1
- package/esm/index.js +5 -1
- package/esm/index.js.map +1 -1
- package/package.json +4 -5
- package/src/components/flex-box/FlexBox.stories.tsx +60 -4
- package/src/components/flex-box/FlexBox.tsx +7 -4
- package/src/components/flex-box/__snapshots__/FlexBox.test.tsx.snap +35 -0
- package/src/components/heading/Heading.stories.tsx +108 -0
- package/src/components/heading/Heading.test.tsx +77 -0
- package/src/components/heading/Heading.tsx +62 -0
- package/src/components/heading/HeadingLevelProvider.tsx +30 -0
- package/src/components/heading/constants.ts +16 -0
- package/src/components/heading/context.tsx +13 -0
- package/src/components/heading/index.ts +3 -0
- package/src/components/heading/useHeadingLevel.tsx +8 -0
- package/src/components/index.ts +1 -0
- package/src/components/slideshow/Slides.tsx +33 -3
- package/src/components/slideshow/Slideshow.stories.tsx +98 -2
- package/src/components/slideshow/Slideshow.tsx +15 -3
- package/src/components/slideshow/SlideshowControls.stories.tsx +1 -1
- package/src/components/slideshow/SlideshowControls.tsx +49 -11
- package/src/components/slideshow/SlideshowItem.tsx +0 -5
- package/src/components/slideshow/SlideshowItemGroup.tsx +63 -0
- package/src/components/slideshow/__snapshots__/Slideshow.test.tsx.snap +4 -1
- package/src/components/slideshow/useSlideFocusManagement.tsx +92 -0
- package/src/components/text/Text.stories.tsx +80 -0
- package/src/components/text/Text.test.tsx +62 -0
- package/src/components/text/Text.tsx +94 -0
- package/src/components/text/index.ts +1 -0
- package/src/hooks/useRovingTabIndex.tsx +9 -0
- package/src/index.ts +2 -0
- package/src/utils/focus/constants.ts +5 -0
- package/src/utils/focus/getFirstAndLastFocusable.ts +4 -10
- package/src/utils/focus/getFocusableElements.test.ts +151 -0
- package/src/utils/focus/getFocusableElements.ts +7 -0
- package/types.d.ts +94 -7
package/esm/_internal/Slides.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { d as _slicedToArray,
|
|
1
|
+
import { d as _slicedToArray, b as _objectWithoutProperties, c as _extends, _ as _objectSpread2, a as _defineProperty } from './_rollupPluginBabelHelpers.js';
|
|
2
2
|
import { Theme, Emphasis } from './components.js';
|
|
3
|
-
import React, { useRef, useEffect, useState, useCallback, useMemo, forwardRef } from 'react';
|
|
3
|
+
import React, { useRef, useEffect, useState, useCallback, useMemo, forwardRef, Children } from 'react';
|
|
4
4
|
import { g as getRootClassName, c as classnames, h as handleBasicClasses, e as detectHorizontalSwipe } from './getRootClassName.js';
|
|
5
5
|
import { g as mdiChevronLeft, p as mdiPauseCircleOutline, q as mdiPlayCircleOutline, f as mdiChevronRight } from './Icon2.js';
|
|
6
6
|
import { W as WINDOW } from './constants.js';
|
|
@@ -9,7 +9,10 @@ import { m as mergeRefs } from './mergeRefs.js';
|
|
|
9
9
|
import { I as IconButton } from './IconButton.js';
|
|
10
10
|
import isFunction from 'lodash/isFunction';
|
|
11
11
|
import range from 'lodash/range';
|
|
12
|
+
import { a as getFocusableElements } from './ClickAwayProvider.js';
|
|
13
|
+
import { u as useRovingTabIndex } from './useRovingTabIndex.js';
|
|
12
14
|
import uniqueId from 'lodash/uniqueId';
|
|
15
|
+
import chunk from 'lodash/chunk';
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
18
|
* Making setInterval Declarative with React Hooks.
|
|
@@ -242,6 +245,172 @@ var useSlideshowControls = function useSlideshowControls(_ref) {
|
|
|
242
245
|
};
|
|
243
246
|
};
|
|
244
247
|
|
|
248
|
+
/**
|
|
249
|
+
* Classname set on elements whose focus was blocked.
|
|
250
|
+
* This is to easily find elements that have been tempered with,
|
|
251
|
+
* and not elements whose focus was already initially blocked.
|
|
252
|
+
* */
|
|
253
|
+
var BLOCKED_FOCUS_CLASSNAME = "focus-blocked";
|
|
254
|
+
/**
|
|
255
|
+
* Manage how slides must behave when visible or not.
|
|
256
|
+
* When not visible, they should be hidden from screen readers and not focusable.
|
|
257
|
+
*/
|
|
258
|
+
|
|
259
|
+
var useSlideFocusManagement = function useSlideFocusManagement(_ref) {
|
|
260
|
+
var isSlideDisplayed = _ref.isSlideDisplayed,
|
|
261
|
+
slideRef = _ref.slideRef;
|
|
262
|
+
useEffect(function () {
|
|
263
|
+
var element = slideRef === null || slideRef === void 0 ? void 0 : slideRef.current;
|
|
264
|
+
|
|
265
|
+
if (!element) {
|
|
266
|
+
return undefined;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Display given slide to screen readers and, if focus was blocked, restore focus on elements.
|
|
270
|
+
*/
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
var enableSlide = function enableSlide() {
|
|
274
|
+
// Hide from screen readers
|
|
275
|
+
element.setAttribute('aria-hidden', 'false'); // Find elements we have blocked focus on
|
|
276
|
+
|
|
277
|
+
element.querySelectorAll(".".concat(BLOCKED_FOCUS_CLASSNAME)).forEach(function (focusableElement) {
|
|
278
|
+
focusableElement.removeAttribute('tabindex');
|
|
279
|
+
focusableElement.classList.remove(BLOCKED_FOCUS_CLASSNAME);
|
|
280
|
+
});
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* Hide given slide from screen readers and block focus on all focusable elements within.
|
|
284
|
+
*/
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
var blockSlide = function blockSlide() {
|
|
288
|
+
element.setAttribute('aria-hidden', 'true');
|
|
289
|
+
getFocusableElements(element).forEach(function (focusableElement) {
|
|
290
|
+
focusableElement.setAttribute('tabindex', '-1');
|
|
291
|
+
focusableElement.classList.add(BLOCKED_FOCUS_CLASSNAME);
|
|
292
|
+
});
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
var handleDisplay = function handleDisplay() {
|
|
296
|
+
if (!element) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (isSlideDisplayed) {
|
|
301
|
+
enableSlide();
|
|
302
|
+
} else {
|
|
303
|
+
blockSlide();
|
|
304
|
+
}
|
|
305
|
+
}; // Callback function to execute when mutations are observed
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
var callback = function callback(mutationsList) {
|
|
309
|
+
if (element) {
|
|
310
|
+
var _iteratorNormalCompletion = true;
|
|
311
|
+
var _didIteratorError = false;
|
|
312
|
+
var _iteratorError = undefined;
|
|
313
|
+
|
|
314
|
+
try {
|
|
315
|
+
for (var _iterator = mutationsList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
316
|
+
var mutation = _step.value;
|
|
317
|
+
|
|
318
|
+
if (mutation.type === 'childList') {
|
|
319
|
+
handleDisplay();
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
} catch (err) {
|
|
323
|
+
_didIteratorError = true;
|
|
324
|
+
_iteratorError = err;
|
|
325
|
+
} finally {
|
|
326
|
+
try {
|
|
327
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
328
|
+
_iterator.return();
|
|
329
|
+
}
|
|
330
|
+
} finally {
|
|
331
|
+
if (_didIteratorError) {
|
|
332
|
+
throw _iteratorError;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}; // Create an observer instance linked to the callback function
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
var observer = new MutationObserver(callback);
|
|
341
|
+
|
|
342
|
+
if (element) {
|
|
343
|
+
handleDisplay();
|
|
344
|
+
/** If slide is hidden, start observing for elements to block focus */
|
|
345
|
+
|
|
346
|
+
if (!isSlideDisplayed) {
|
|
347
|
+
observer.observe(element, {
|
|
348
|
+
attributes: true,
|
|
349
|
+
childList: true,
|
|
350
|
+
subtree: true
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
return function () {
|
|
356
|
+
if (!isSlideDisplayed) {
|
|
357
|
+
observer.disconnect();
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
}, [isSlideDisplayed, slideRef]);
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Defines the props of the component.
|
|
365
|
+
*/
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Component display name.
|
|
369
|
+
*/
|
|
370
|
+
var COMPONENT_NAME = 'SlideshowItemGroup';
|
|
371
|
+
/**
|
|
372
|
+
* Component default class name and class prefix.
|
|
373
|
+
*/
|
|
374
|
+
|
|
375
|
+
var CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
376
|
+
var buildSlideShowGroupId = function buildSlideShowGroupId(slidesId, index) {
|
|
377
|
+
return "".concat(slidesId, "-slide-").concat(index);
|
|
378
|
+
};
|
|
379
|
+
/**
|
|
380
|
+
* SlideshowItemGroup component.
|
|
381
|
+
*
|
|
382
|
+
* @param props Component props.
|
|
383
|
+
* @param ref Component ref.
|
|
384
|
+
* @return React element.
|
|
385
|
+
*/
|
|
386
|
+
|
|
387
|
+
var SlideshowItemGroup = forwardRef(function (props, ref) {
|
|
388
|
+
var className = props.className,
|
|
389
|
+
children = props.children,
|
|
390
|
+
_props$role = props.role,
|
|
391
|
+
role = _props$role === void 0 ? 'group' : _props$role,
|
|
392
|
+
label = props.label,
|
|
393
|
+
isDisplayed = props.isDisplayed,
|
|
394
|
+
forwardedProps = _objectWithoutProperties(props, ["className", "children", "role", "label", "isDisplayed"]);
|
|
395
|
+
|
|
396
|
+
var groupRef = React.useRef(null);
|
|
397
|
+
useSlideFocusManagement({
|
|
398
|
+
isSlideDisplayed: isDisplayed,
|
|
399
|
+
slideRef: groupRef
|
|
400
|
+
});
|
|
401
|
+
return React.createElement("div", _extends({
|
|
402
|
+
ref: mergeRefs(groupRef, ref),
|
|
403
|
+
role: role,
|
|
404
|
+
className: classnames(className, handleBasicClasses({
|
|
405
|
+
prefix: CLASSNAME
|
|
406
|
+
})),
|
|
407
|
+
"aria-roledescription": "slide",
|
|
408
|
+
"aria-label": label
|
|
409
|
+
}, forwardedProps), children);
|
|
410
|
+
});
|
|
411
|
+
SlideshowItemGroup.displayName = COMPONENT_NAME;
|
|
412
|
+
SlideshowItemGroup.className = CLASSNAME;
|
|
413
|
+
|
|
245
414
|
/**
|
|
246
415
|
* Defines the props of the component.
|
|
247
416
|
*/
|
|
@@ -274,7 +443,8 @@ var Slideshow = forwardRef(function (props, ref) {
|
|
|
274
443
|
theme = props.theme,
|
|
275
444
|
id = props.id,
|
|
276
445
|
slidesId = props.slidesId,
|
|
277
|
-
|
|
446
|
+
slideGroupLabel = props.slideGroupLabel,
|
|
447
|
+
forwardedProps = _objectWithoutProperties(props, ["activeIndex", "autoPlay", "children", "className", "fillHeight", "groupBy", "interval", "onChange", "slideshowControlsProps", "theme", "id", "slidesId", "slideGroupLabel"]); // Number of slideshow items.
|
|
278
448
|
|
|
279
449
|
|
|
280
450
|
var itemsCount = React.Children.count(children);
|
|
@@ -310,6 +480,7 @@ var Slideshow = forwardRef(function (props, ref) {
|
|
|
310
480
|
onFocusIn: stopAutoPlay,
|
|
311
481
|
onFocusOut: startAutoPlay
|
|
312
482
|
});
|
|
483
|
+
var showControls = slideshowControlsProps && slidesCount > 1;
|
|
313
484
|
return React.createElement(Slides, _extends({
|
|
314
485
|
activeIndex: currentIndex,
|
|
315
486
|
id: slideshowId,
|
|
@@ -321,8 +492,9 @@ var Slideshow = forwardRef(function (props, ref) {
|
|
|
321
492
|
autoPlay: autoPlay,
|
|
322
493
|
slidesId: slideshowSlidesId,
|
|
323
494
|
toggleAutoPlay: toggleAutoPlay,
|
|
324
|
-
interval: interval,
|
|
325
495
|
ref: mergeRefs(ref, setSlideshow),
|
|
496
|
+
hasControls: showControls,
|
|
497
|
+
slideGroupLabel: slideGroupLabel,
|
|
326
498
|
afterSlides: slideshowControlsProps && slidesCount > 1 ? React.createElement("div", {
|
|
327
499
|
className: "".concat(Slides.className, "__controls")
|
|
328
500
|
}, React.createElement(SlideshowControls, _extends({}, slideshowControlsProps, {
|
|
@@ -343,7 +515,14 @@ var Slideshow = forwardRef(function (props, ref) {
|
|
|
343
515
|
playButtonProps: autoPlay ? _objectSpread2({
|
|
344
516
|
'aria-controls': slideshowSlidesId,
|
|
345
517
|
onClick: toggleForcePause
|
|
346
|
-
}, slideshowControlsProps.playButtonProps) : undefined
|
|
518
|
+
}, slideshowControlsProps.playButtonProps) : undefined,
|
|
519
|
+
paginationItemProps: function paginationItemProps(index) {
|
|
520
|
+
var _slideshowControlsPro;
|
|
521
|
+
|
|
522
|
+
return _objectSpread2({
|
|
523
|
+
'aria-controls': buildSlideShowGroupId(slideshowSlidesId, index)
|
|
524
|
+
}, (_slideshowControlsPro = slideshowControlsProps.paginationItemProps) === null || _slideshowControlsPro === void 0 ? void 0 : _slideshowControlsPro.call(slideshowControlsProps, index));
|
|
525
|
+
}
|
|
347
526
|
}))) : undefined
|
|
348
527
|
}, forwardedProps), children);
|
|
349
528
|
});
|
|
@@ -357,12 +536,12 @@ Slideshow.defaultProps = DEFAULT_PROPS;
|
|
|
357
536
|
/**
|
|
358
537
|
* Component display name.
|
|
359
538
|
*/
|
|
360
|
-
var COMPONENT_NAME = 'SlideshowItem';
|
|
539
|
+
var COMPONENT_NAME$1 = 'SlideshowItem';
|
|
361
540
|
/**
|
|
362
541
|
* Component default class name and class prefix.
|
|
363
542
|
*/
|
|
364
543
|
|
|
365
|
-
var CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
544
|
+
var CLASSNAME$1 = getRootClassName(COMPONENT_NAME$1);
|
|
366
545
|
/**
|
|
367
546
|
* SlideshowItem component.
|
|
368
547
|
*
|
|
@@ -379,14 +558,12 @@ var SlideshowItem = forwardRef(function (props, ref) {
|
|
|
379
558
|
return React.createElement("div", _extends({
|
|
380
559
|
ref: ref,
|
|
381
560
|
className: classnames(className, handleBasicClasses({
|
|
382
|
-
prefix: CLASSNAME
|
|
383
|
-
}))
|
|
384
|
-
"aria-roledescription": "slide",
|
|
385
|
-
role: "group"
|
|
561
|
+
prefix: CLASSNAME$1
|
|
562
|
+
}))
|
|
386
563
|
}, forwardedProps), children);
|
|
387
564
|
});
|
|
388
|
-
SlideshowItem.displayName = COMPONENT_NAME;
|
|
389
|
-
SlideshowItem.className = CLASSNAME;
|
|
565
|
+
SlideshowItem.displayName = COMPONENT_NAME$1;
|
|
566
|
+
SlideshowItem.className = CLASSNAME$1;
|
|
390
567
|
|
|
391
568
|
var isTouchDevice = function isTouchDevice() {
|
|
392
569
|
return 'ontouchstart' in window;
|
|
@@ -406,36 +583,6 @@ function useSwipeNavigate(element, onNext, onPrevious) {
|
|
|
406
583
|
}, [onPrevious, onNext, element]);
|
|
407
584
|
}
|
|
408
585
|
|
|
409
|
-
/**
|
|
410
|
-
* Listen keyboard to navigate left and right.
|
|
411
|
-
*/
|
|
412
|
-
|
|
413
|
-
function useKeyNavigate(element, onNext, onPrevious) {
|
|
414
|
-
useEffect(function () {
|
|
415
|
-
if (!element) return undefined;
|
|
416
|
-
|
|
417
|
-
var onKeyNavigate = function onKeyNavigate(evt) {
|
|
418
|
-
var callback;
|
|
419
|
-
|
|
420
|
-
if ((evt === null || evt === void 0 ? void 0 : evt.key) === 'ArrowRight') {
|
|
421
|
-
callback = onNext;
|
|
422
|
-
} else if ((evt === null || evt === void 0 ? void 0 : evt.key) === 'ArrowLeft') {
|
|
423
|
-
callback = onPrevious;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
if (!callback) return;
|
|
427
|
-
callback();
|
|
428
|
-
evt.preventDefault();
|
|
429
|
-
evt.stopPropagation();
|
|
430
|
-
};
|
|
431
|
-
|
|
432
|
-
element.addEventListener('keydown', onKeyNavigate);
|
|
433
|
-
return function () {
|
|
434
|
-
element.removeEventListener('keydown', onKeyNavigate);
|
|
435
|
-
};
|
|
436
|
-
}, [onPrevious, onNext, element]);
|
|
437
|
-
}
|
|
438
|
-
|
|
439
586
|
/**
|
|
440
587
|
* Calculate the currently visible pagination "bullet" range.
|
|
441
588
|
*/
|
|
@@ -487,12 +634,12 @@ function usePaginationVisibleRange(activeIndex, slideCount) {
|
|
|
487
634
|
/**
|
|
488
635
|
* Component display name.
|
|
489
636
|
*/
|
|
490
|
-
var COMPONENT_NAME$
|
|
637
|
+
var COMPONENT_NAME$2 = 'SlideshowControls';
|
|
491
638
|
/**
|
|
492
639
|
* Component default class name and class prefix.
|
|
493
640
|
*/
|
|
494
641
|
|
|
495
|
-
var CLASSNAME$
|
|
642
|
+
var CLASSNAME$2 = getRootClassName(COMPONENT_NAME$2);
|
|
496
643
|
/**
|
|
497
644
|
* Component default props.
|
|
498
645
|
*/
|
|
@@ -518,23 +665,24 @@ var InternalSlideshowControls = forwardRef(function (props, ref) {
|
|
|
518
665
|
onPreviousClick = props.onPreviousClick,
|
|
519
666
|
parentRef = props.parentRef,
|
|
520
667
|
previousButtonProps = props.previousButtonProps,
|
|
668
|
+
paginationProps = props.paginationProps,
|
|
521
669
|
slidesCount = props.slidesCount,
|
|
522
670
|
theme = props.theme,
|
|
523
671
|
_props$isAutoPlaying = props.isAutoPlaying,
|
|
524
672
|
isAutoPlaying = _props$isAutoPlaying === void 0 ? false : _props$isAutoPlaying,
|
|
525
673
|
playButtonProps = props.playButtonProps,
|
|
526
674
|
paginationItemLabel = props.paginationItemLabel,
|
|
527
|
-
|
|
675
|
+
paginationItemProps = props.paginationItemProps,
|
|
676
|
+
forwardedProps = _objectWithoutProperties(props, ["activeIndex", "className", "nextButtonProps", "onNextClick", "onPaginationClick", "onPreviousClick", "parentRef", "previousButtonProps", "paginationProps", "slidesCount", "theme", "isAutoPlaying", "playButtonProps", "paginationItemLabel", "paginationItemProps"]);
|
|
528
677
|
|
|
529
678
|
var parent;
|
|
530
679
|
|
|
531
680
|
if (WINDOW) {
|
|
532
681
|
// Checking window object to avoid errors in SSR.
|
|
533
682
|
parent = parentRef instanceof HTMLElement ? parentRef : parentRef === null || parentRef === void 0 ? void 0 : parentRef.current;
|
|
534
|
-
}
|
|
535
|
-
|
|
683
|
+
}
|
|
536
684
|
|
|
537
|
-
|
|
685
|
+
var paginationRef = React.useRef(null); // Listen to touch swipe navigate left & right.
|
|
538
686
|
|
|
539
687
|
useSwipeNavigate(parent, // Go next without loopback.
|
|
540
688
|
useCallback(function () {
|
|
@@ -542,7 +690,19 @@ var InternalSlideshowControls = forwardRef(function (props, ref) {
|
|
|
542
690
|
}, [onNextClick]), // Go previous without loopback.
|
|
543
691
|
useCallback(function () {
|
|
544
692
|
return onPreviousClick === null || onPreviousClick === void 0 ? void 0 : onPreviousClick(false);
|
|
545
|
-
}, [onPreviousClick]));
|
|
693
|
+
}, [onPreviousClick]));
|
|
694
|
+
/**
|
|
695
|
+
* Add roving tab index pattern to pagination items and activate slide on focus.
|
|
696
|
+
*/
|
|
697
|
+
|
|
698
|
+
useRovingTabIndex({
|
|
699
|
+
parentRef: paginationRef,
|
|
700
|
+
elementSelector: 'button',
|
|
701
|
+
keepTabIndex: true,
|
|
702
|
+
onElementFocus: function onElementFocus(element) {
|
|
703
|
+
element.click();
|
|
704
|
+
}
|
|
705
|
+
}); // Pagination "bullet" range.
|
|
546
706
|
|
|
547
707
|
var visibleRange = usePaginationVisibleRange(activeIndex, slidesCount); // Inline style of wrapper element.
|
|
548
708
|
|
|
@@ -553,56 +713,69 @@ var InternalSlideshowControls = forwardRef(function (props, ref) {
|
|
|
553
713
|
ref: ref
|
|
554
714
|
}, forwardedProps, {
|
|
555
715
|
className: classnames(className, handleBasicClasses({
|
|
556
|
-
prefix: CLASSNAME$
|
|
716
|
+
prefix: CLASSNAME$2,
|
|
557
717
|
theme: theme
|
|
558
|
-
}), _defineProperty({}, "".concat(CLASSNAME$
|
|
718
|
+
}), _defineProperty({}, "".concat(CLASSNAME$2, "--has-infinite-pagination"), slidesCount > PAGINATION_ITEMS_MAX))
|
|
559
719
|
}), React.createElement(IconButton, _extends({}, previousButtonProps, {
|
|
560
720
|
icon: mdiChevronLeft,
|
|
561
|
-
className: "".concat(CLASSNAME$
|
|
721
|
+
className: "".concat(CLASSNAME$2, "__navigation"),
|
|
562
722
|
color: theme === Theme.dark ? 'light' : 'dark',
|
|
563
723
|
emphasis: Emphasis.low,
|
|
564
724
|
onClick: onPreviousClick
|
|
565
725
|
})), React.createElement("div", {
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
726
|
+
ref: paginationRef,
|
|
727
|
+
className: "".concat(CLASSNAME$2, "__pagination")
|
|
728
|
+
}, React.createElement("div", _extends({
|
|
729
|
+
className: "".concat(CLASSNAME$2, "__pagination-items"),
|
|
730
|
+
style: wrapperStyle,
|
|
731
|
+
role: "tablist"
|
|
732
|
+
}, paginationProps), useMemo(function () {
|
|
571
733
|
return range(slidesCount).map(function (index) {
|
|
572
734
|
var isOnEdge = index !== 0 && index !== slidesCount - 1 && (index === visibleRange.min || index === visibleRange.max);
|
|
573
735
|
var isActive = activeIndex === index;
|
|
574
736
|
var isOutRange = index < visibleRange.min || index > visibleRange.max;
|
|
737
|
+
|
|
738
|
+
var _ref = paginationItemProps ? paginationItemProps(index) : {},
|
|
739
|
+
_ref$className = _ref.className,
|
|
740
|
+
itemClassName = _ref$className === void 0 ? undefined : _ref$className,
|
|
741
|
+
_ref$label = _ref.label,
|
|
742
|
+
label = _ref$label === void 0 ? undefined : _ref$label,
|
|
743
|
+
itemProps = _objectWithoutProperties(_ref, ["className", "label"]);
|
|
744
|
+
|
|
745
|
+
var ariaLabel = label || (paginationItemLabel === null || paginationItemLabel === void 0 ? void 0 : paginationItemLabel(index)) || "".concat(index + 1, " / ").concat(slidesCount);
|
|
575
746
|
return React.createElement("button", _extends({
|
|
576
747
|
className: classnames(handleBasicClasses({
|
|
577
|
-
prefix: "".concat(CLASSNAME$
|
|
748
|
+
prefix: "".concat(CLASSNAME$2, "__pagination-item"),
|
|
578
749
|
isActive: isActive,
|
|
579
750
|
isOnEdge: isOnEdge,
|
|
580
751
|
isOutRange: isOutRange
|
|
581
|
-
})),
|
|
752
|
+
}), itemClassName),
|
|
582
753
|
key: index,
|
|
583
754
|
type: "button",
|
|
755
|
+
tabIndex: isActive ? undefined : -1,
|
|
756
|
+
role: "tab",
|
|
757
|
+
"aria-selected": isActive,
|
|
584
758
|
onClick: function onClick() {
|
|
585
759
|
return onPaginationClick === null || onPaginationClick === void 0 ? void 0 : onPaginationClick(index);
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
}));
|
|
760
|
+
},
|
|
761
|
+
"aria-label": ariaLabel
|
|
762
|
+
}, itemProps));
|
|
590
763
|
});
|
|
591
|
-
}, [slidesCount, visibleRange.min, visibleRange.max, activeIndex, paginationItemLabel, onPaginationClick]))), playButtonProps ? React.createElement(IconButton, _extends({}, playButtonProps, {
|
|
764
|
+
}, [slidesCount, visibleRange.min, visibleRange.max, activeIndex, paginationItemProps, paginationItemLabel, onPaginationClick]))), playButtonProps ? React.createElement(IconButton, _extends({}, playButtonProps, {
|
|
592
765
|
icon: isAutoPlaying ? mdiPauseCircleOutline : mdiPlayCircleOutline,
|
|
593
|
-
className: "".concat(CLASSNAME$
|
|
766
|
+
className: "".concat(CLASSNAME$2, "__play"),
|
|
594
767
|
color: theme === Theme.dark ? 'light' : 'dark',
|
|
595
768
|
emphasis: Emphasis.low
|
|
596
769
|
})) : null, React.createElement(IconButton, _extends({}, nextButtonProps, {
|
|
597
770
|
icon: mdiChevronRight,
|
|
598
|
-
className: "".concat(CLASSNAME$
|
|
771
|
+
className: "".concat(CLASSNAME$2, "__navigation"),
|
|
599
772
|
color: theme === Theme.dark ? 'light' : 'dark',
|
|
600
773
|
emphasis: Emphasis.low,
|
|
601
774
|
onClick: onNextClick
|
|
602
775
|
})));
|
|
603
776
|
});
|
|
604
|
-
InternalSlideshowControls.displayName = COMPONENT_NAME$
|
|
605
|
-
InternalSlideshowControls.className = CLASSNAME$
|
|
777
|
+
InternalSlideshowControls.displayName = COMPONENT_NAME$2;
|
|
778
|
+
InternalSlideshowControls.className = CLASSNAME$2;
|
|
606
779
|
InternalSlideshowControls.defaultProps = DEFAULT_PROPS$1;
|
|
607
780
|
var SlideshowControls = Object.assign(InternalSlideshowControls, {
|
|
608
781
|
useSlideshowControls: useSlideshowControls,
|
|
@@ -612,12 +785,12 @@ var SlideshowControls = Object.assign(InternalSlideshowControls, {
|
|
|
612
785
|
/**
|
|
613
786
|
* Component display name.
|
|
614
787
|
*/
|
|
615
|
-
var COMPONENT_NAME$
|
|
788
|
+
var COMPONENT_NAME$3 = 'Slideshow';
|
|
616
789
|
/**
|
|
617
790
|
* Component default class name and class prefix.
|
|
618
791
|
*/
|
|
619
792
|
|
|
620
|
-
var CLASSNAME$
|
|
793
|
+
var CLASSNAME$3 = getRootClassName(COMPONENT_NAME$3);
|
|
621
794
|
/**
|
|
622
795
|
* Slides component.
|
|
623
796
|
*
|
|
@@ -640,34 +813,52 @@ var Slides = forwardRef(function (props, ref) {
|
|
|
640
813
|
slidesId = props.slidesId,
|
|
641
814
|
children = props.children,
|
|
642
815
|
afterSlides = props.afterSlides,
|
|
643
|
-
|
|
816
|
+
hasControls = props.hasControls,
|
|
817
|
+
slideGroupLabel = props.slideGroupLabel,
|
|
818
|
+
forwardedProps = _objectWithoutProperties(props, ["activeIndex", "id", "className", "theme", "fillHeight", "groupBy", "isAutoPlaying", "toggleAutoPlay", "slidesId", "children", "afterSlides", "hasControls", "slideGroupLabel"]);
|
|
644
819
|
|
|
820
|
+
var wrapperRef = React.useRef(null);
|
|
821
|
+
var startIndexVisible = activeIndex;
|
|
822
|
+
var endIndexVisible = startIndexVisible + 1; // Inline style of wrapper element.
|
|
645
823
|
|
|
646
824
|
var wrapperStyle = {
|
|
647
825
|
transform: "translateX(-".concat(FULL_WIDTH_PERCENT * activeIndex, "%)")
|
|
648
826
|
};
|
|
827
|
+
var groups = React.useMemo(function () {
|
|
828
|
+
var childrenArray = Children.toArray(children);
|
|
829
|
+
return groupBy && groupBy > 1 ? chunk(childrenArray, groupBy) : childrenArray;
|
|
830
|
+
}, [children, groupBy]);
|
|
649
831
|
return React.createElement("section", _extends({
|
|
650
832
|
id: id,
|
|
651
833
|
ref: ref
|
|
652
834
|
}, forwardedProps, {
|
|
653
835
|
className: classnames(className, handleBasicClasses({
|
|
654
|
-
prefix: CLASSNAME$
|
|
836
|
+
prefix: CLASSNAME$3,
|
|
655
837
|
theme: theme
|
|
656
|
-
}), (_classNames = {}, _defineProperty(_classNames, "".concat(CLASSNAME$
|
|
838
|
+
}), (_classNames = {}, _defineProperty(_classNames, "".concat(CLASSNAME$3, "--fill-height"), fillHeight), _defineProperty(_classNames, "".concat(CLASSNAME$3, "--group-by-").concat(groupBy), Boolean(groupBy)), _classNames)),
|
|
657
839
|
"aria-roledescription": "carousel"
|
|
658
840
|
}), React.createElement("div", {
|
|
659
841
|
id: slidesId,
|
|
660
|
-
className: "".concat(CLASSNAME$
|
|
842
|
+
className: "".concat(CLASSNAME$3, "__slides"),
|
|
661
843
|
onMouseEnter: toggleAutoPlay,
|
|
662
844
|
onMouseLeave: toggleAutoPlay,
|
|
663
845
|
"aria-live": isAutoPlaying ? 'off' : 'polite'
|
|
664
846
|
}, React.createElement("div", {
|
|
665
|
-
|
|
847
|
+
ref: wrapperRef,
|
|
848
|
+
className: "".concat(CLASSNAME$3, "__wrapper"),
|
|
666
849
|
style: wrapperStyle
|
|
667
|
-
},
|
|
850
|
+
}, groups.map(function (group, index) {
|
|
851
|
+
return React.createElement(SlideshowItemGroup, {
|
|
852
|
+
key: index,
|
|
853
|
+
id: slidesId && buildSlideShowGroupId(slidesId, index),
|
|
854
|
+
role: hasControls ? 'tabpanel' : 'group',
|
|
855
|
+
label: slideGroupLabel ? slideGroupLabel(index + 1, groups.length) : undefined,
|
|
856
|
+
isDisplayed: index >= startIndexVisible && index < endIndexVisible
|
|
857
|
+
}, group);
|
|
858
|
+
}))), afterSlides);
|
|
668
859
|
});
|
|
669
|
-
Slides.displayName = COMPONENT_NAME$
|
|
670
|
-
Slides.className = CLASSNAME$
|
|
860
|
+
Slides.displayName = COMPONENT_NAME$3;
|
|
861
|
+
Slides.className = CLASSNAME$3;
|
|
671
862
|
|
|
672
863
|
export { Slideshow as S, SlideshowItem as a, SlideshowControls as b, Slides as c };
|
|
673
864
|
//# sourceMappingURL=Slides.js.map
|