@lumx/react 2.2.10 → 2.2.12-alpha.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/Icon2.js +21 -29
- package/esm/_internal/Icon2.js.map +1 -1
- package/esm/_internal/Slides.js +42 -68
- package/esm/_internal/Slides.js.map +1 -1
- package/esm/_internal/getRootClassName.js +1 -2
- package/esm/_internal/getRootClassName.js.map +1 -1
- package/esm/_internal/slideshow.js +0 -1
- package/esm/_internal/slideshow.js.map +1 -1
- package/package.json +4 -4
- package/src/components/icon/Icon.stories.tsx +55 -36
- package/src/components/icon/Icon.tsx +19 -28
- package/src/components/slideshow/Slides.tsx +5 -22
- package/src/components/slideshow/Slideshow.tsx +4 -9
- package/src/components/slideshow/SlideshowControls.stories.tsx +4 -10
- package/src/components/slideshow/SlideshowItem.tsx +2 -13
- package/src/components/slideshow/__snapshots__/Slideshow.test.tsx.snap +1 -3
- package/src/hooks/useSlideshowControls.ts +31 -18
- package/types.d.ts +6 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRootClassName.js","sources":["../../../../../node_modules/classnames/index.js","../../../../lumx-core/src/js/utils.ts","../../../../lumx-core/src/js/constants/index.ts","../../../src/utils/getRootClassName.ts"],"sourcesContent":["/*!\n Copyright (c) 2017 Jed Watson.\n Licensed under the MIT License (MIT), see\n http://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = [];\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (!arg) continue;\n\n\t\t\tvar argType = typeof arg;\n\n\t\t\tif (argType === 'string' || argType === 'number') {\n\t\t\t\tclasses.push(arg);\n\t\t\t} else if (Array.isArray(arg) && arg.length) {\n\t\t\t\tvar inner = classNames.apply(null, arg);\n\t\t\t\tif (inner) {\n\t\t\t\t\tclasses.push(inner);\n\t\t\t\t}\n\t\t\t} else if (argType === 'object') {\n\t\t\t\tfor (var key in arg) {\n\t\t\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\t\t\tclasses.push(key);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn classes.join(' ');\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","import classNames from 'classnames';\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport React from 'react';\n\nimport isBoolean from 'lodash/isBoolean';\nimport isEmpty from 'lodash/isEmpty';\nimport kebabCase from 'lodash/kebabCase';\nimport noop from 'lodash/noop';\n\n/**\n * Enhance isEmpty method to also works with numbers.\n *\n * @param value The value to check.\n * @return Whether the input value is empty or != 0.\n */\nconst _isEmpty = (value: any) => {\n if (typeof value === 'number') {\n return value === 0;\n }\n\n return isEmpty(value);\n};\n\n/**\n * Get the basic CSS class for the given type.\n *\n * @param prefix The class name prefix for the generated CSS class.\n * @param type The type of CSS class we want to generate (e.g.: 'color', 'variant', ...).\n * @param value The value of the type of the CSS class (e.g.: 'primary', 'button', ...).\n * @return The basic CSS class.\n */\nexport function getBasicClass({\n prefix,\n type,\n value,\n}: {\n prefix: string;\n type: string;\n value: string | number | boolean | undefined;\n}): string {\n if (isBoolean(value)) {\n if (!value) {\n // False value should not return a class.\n return '';\n }\n const booleanPrefixes = ['has', 'is'];\n\n if (booleanPrefixes.some((booleanPrefix) => type.toString().startsWith(booleanPrefix))) {\n return `${prefix}--${kebabCase(type)}`;\n }\n\n return `${prefix}--is-${kebabCase(type)}`;\n }\n\n return `${prefix}--${kebabCase(type)}-${value}`;\n}\n\n/**\n * Return all basic LumX CSS classes which are available for every components.\n *\n * @see {@link /src/components/index.d.ts} for the possible values of each parameter.\n *\n * @param prefix The class name prefix for the generated CSS class.\n * @param props All the other props you want to generate a class.\n * The rule of thumb: the key is the name of the prop in the class, the value a string that will\n * be used in the classname to represent the value of the given prop.\n * @return All LumX basic CSS classes.\n */\nexport function handleBasicClasses({ prefix, ...props }: { prefix: string; [prop: string]: any }): string {\n const otherClasses: any = {};\n if (!isEmpty(props)) {\n Object.keys(props).forEach((prop) => {\n otherClasses[getBasicClass({ prefix, type: prop, value: props[prop] })] = isBoolean(props[prop])\n ? props[prop]\n : !_isEmpty(props[prop]);\n });\n }\n\n return classNames(prefix, otherClasses);\n}\n\ndeclare type SwipeDirection = 'none' | 'up' | 'down' | 'left' | 'right';\n\n/**\n * Detects swipe direction.\n * Credits: http://javascriptkit.com/javatutors/touchevents2.shtml.\n *\n * @deprecated use `detectHorizontalSwipe` instead if possible (better performance and does not block scroll)\n * @param touchSurface Element that will hold touch events.\n * @param handleSwipe Callback function.\n * @return Function to remove listeners.\n */\nexport function detectSwipe(touchSurface: Element, handleSwipe: (direction: SwipeDirection) => void = noop) {\n let distX: number;\n let distY: number;\n let startX: number;\n let startY: number;\n let direction: SwipeDirection;\n // Required min distance traveled to be considered swipe.\n const threshold = 150;\n // Maximum distance allowed at the same time in perpendicular direction.\n const restraint = 100;\n // Maximum time allowed to travel that distance.\n const allowedTime = 300;\n let elapsedTime: number;\n let startTime: number;\n\n const onTouchStart = (evt: Event) => {\n const [touch] = Array.from((evt as TouchEvent).changedTouches);\n direction = 'none';\n // Const dist = 0;\n startX = touch.pageX;\n startY = touch.pageY;\n // Record time when finger first makes contact with surface.\n startTime = new Date().getTime();\n evt.preventDefault();\n };\n\n const onTouchMove = (evt: Event) => {\n // Prevent scrolling when inside DIV.\n evt.preventDefault();\n };\n\n const onTouchEnd = (evt: Event) => {\n const [touch] = Array.from((evt as TouchEvent).changedTouches);\n // Get horizontal dist traveled by finger while in contact with surface.\n distX = touch.pageX - startX;\n // Get vertical dist traveled by finger while in contact with surface.\n distY = touch.pageY - startY;\n // Get time elapsed.\n elapsedTime = new Date().getTime() - startTime;\n if (elapsedTime <= allowedTime) {\n // First condition for awipe met.\n if (Math.abs(distX) >= threshold && Math.abs(distY) <= restraint) {\n // 2nd condition for horizontal swipe met.\n // If dist traveled is negative, it indicates left swipe.\n direction = distX < 0 ? 'left' : 'right';\n } else if (Math.abs(distY) >= threshold && Math.abs(distX) <= restraint) {\n // 2nd condition for vertical swipe met.\n // If dist traveled is negative, it indicates up swipe.\n direction = distY < 0 ? 'up' : 'down';\n }\n }\n handleSwipe(direction);\n evt.preventDefault();\n };\n\n touchSurface.addEventListener('touchstart', onTouchStart, false);\n touchSurface.addEventListener('touchmove', onTouchMove, false);\n touchSurface.addEventListener('touchend', onTouchEnd, false);\n\n return () => {\n touchSurface.removeEventListener('touchstart', onTouchStart, false);\n touchSurface.removeEventListener('touchmove', onTouchMove, false);\n touchSurface.removeEventListener('touchend', onTouchEnd, false);\n };\n}\n\n/**\n * Checks whether or not the browser support passive events.\n * @see https://github.com/Modernizr/Modernizr/blob/6d56d814b9682843313b16060adb25a58d83a317/feature-detects/dom/passiveeventlisteners.js\n */\nfunction isPassiveEventAvailable() {\n let supportsPassiveOption = false;\n try {\n const opts = Object.defineProperty({}, 'passive', {\n get() {\n supportsPassiveOption = true;\n },\n });\n window.addEventListener('testPassiveEventSupport', noop, opts);\n window.removeEventListener('testPassiveEventSupport', noop, opts);\n } catch (e) {\n // ignored\n }\n return supportsPassiveOption;\n}\n\n/**\n * Detects horizontal swipe direction without blocking the browser scroll using passive event.\n * @see http://javascriptkit.com/javatutors/touchevents2.shtml\n * @see https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md\n */\nexport function detectHorizontalSwipe(touchSurface: Element, handleSwipe: (direction: 'right' | 'left') => void) {\n let startX: number;\n let startY: number;\n // Required min distance traveled to be considered swipe.\n const threshold = 150;\n // Maximum distance allowed at the same time in perpendicular direction.\n const restraint = 150;\n // Maximum time allowed to travel that distance.\n const allowedTime = 300;\n let elapsedTime: number;\n let startTime: number;\n let finished: boolean;\n\n const onTouchStart = (evt: Event) => {\n const [touch] = Array.from((evt as TouchEvent).changedTouches);\n startX = touch.pageX;\n startY = touch.pageY;\n // Record time when finger first makes contact with surface.\n startTime = new Date().getTime();\n finished = false;\n };\n\n const onTouchMove = (evt: Event) => {\n if (finished) {\n return;\n }\n\n elapsedTime = new Date().getTime() - startTime;\n if (elapsedTime > allowedTime) {\n // Touch swipe too long to be considered.\n return;\n }\n\n const [touch] = Array.from((evt as TouchEvent).changedTouches);\n // Get horizontal dist traveled by finger while in contact with surface.\n const distX = touch.pageX - startX;\n // Get vertical dist traveled by finger while in contact with surface.\n const distY = touch.pageY - startY;\n\n if (!(Math.abs(distX) >= threshold && Math.abs(distY) <= restraint)) {\n // Swipe is not horizontal.\n return;\n }\n // Swipe direction.\n const direction = distX < 0 ? 'left' : 'right';\n\n handleSwipe(direction);\n finished = true;\n };\n\n // Activate passive event if possible for better scrolling performance.\n const eventOptions: any = isPassiveEventAvailable() ? { passive: true } : false;\n touchSurface.addEventListener('touchstart', onTouchStart, eventOptions);\n touchSurface.addEventListener('touchmove', onTouchMove, eventOptions);\n\n return () => {\n touchSurface.removeEventListener('touchstart', onTouchStart, eventOptions);\n touchSurface.removeEventListener('touchmove', onTouchMove, eventOptions);\n };\n}\n\ntype KeyboardEventHandler<E extends KeyboardEvent | React.KeyboardEvent> = (event: E) => void;\n\n/**\n * Make sure the pressed key is the enter key before calling the callback.\n *\n * @param handler The handler to call on enter/return press.\n * @return The decorated function.\n */\nexport function onEnterPressed<E extends KeyboardEvent | React.KeyboardEvent>(\n handler: KeyboardEventHandler<E>,\n): KeyboardEventHandler<E> {\n return (evt) => {\n if (evt.key !== 'Enter') {\n return;\n }\n handler(evt);\n };\n}\n\n/**\n * Make sure the pressed key is the escape key before calling the callback.\n *\n * @param handler The handler to call on enter/return press.\n * @return The decorated function.\n */\nexport function onEscapePressed<E extends KeyboardEvent | React.KeyboardEvent>(\n handler: KeyboardEventHandler<E>,\n): KeyboardEventHandler<E> {\n return (evt) => {\n if (evt.key !== 'Escape') {\n return;\n }\n handler(evt);\n };\n}\n\n/**\n * Handle button key pressed (Enter + Space).\n *\n * @param handler The handler to call.\n * @return The decorated function.\n */\nexport function onButtonPressed<E extends KeyboardEvent | React.KeyboardEvent>(\n handler: KeyboardEventHandler<E>,\n): KeyboardEventHandler<E> {\n return (evt) => {\n if (evt.key !== 'Enter' && evt.key !== ' ') {\n return;\n }\n handler(evt);\n };\n}\n","/**\n * The prefix to use for the CSS classes.\n */\nexport const CSS_PREFIX = 'lumx';\n\n/**\n * Key codes.\n */\nexport * from './keycodes';\n\n/**\n * Animation duration constants. Take into consideration that if you change one of these variables,\n * you need to update their scss counterpart as well\n */\nexport const DIALOG_TRANSITION_DURATION = 400;\nexport const NOTIFICATION_TRANSITION_DURATION = 200;\nexport const SLIDESHOW_TRANSITION_DURATION = 5000;\n\n/**\n * Delay on hover after which we open or close the tooltip.\n * Only applies to devices supporting pointer hover.\n */\nexport const TOOLTIP_HOVER_DELAY = {\n open: 500,\n close: 0,\n};\n\n/**\n * Delay on long press after which we open or close the tooltip.\n * Only applies to devices not supporting pointer hover.\n */\nexport const TOOLTIP_LONG_PRESS_DELAY = {\n open: 250,\n close: 3000,\n};\n","import { CSS_PREFIX } from '@lumx/react/constants';\n\nimport kebabCase from 'lodash/kebabCase';\n\n// See https://regex101.com/r/YjS1uI/3\nconst LAST_PART_CLASSNAME = /^(.*)-(.+)$/gi;\n\n/**\n * Get the name of the root CSS class of a component based on its name.\n *\n * @param componentName The name of the component. This name should contains the component prefix and be\n * written in PascalCase.\n * @param subComponent Whether the current component is a sub component, if true, define the class according\n * to BEM standards.\n * @return The name of the root CSS class. This classname include the CSS classname prefix and is written in\n * lower-snake-case.\n */\nexport function getRootClassName(componentName: string, subComponent?: boolean): string {\n const formattedClassName = `${CSS_PREFIX}-${kebabCase(componentName)}`;\n\n if (subComponent) {\n return formattedClassName.replace(LAST_PART_CLASSNAME, '$1__$2');\n }\n return formattedClassName;\n}\n"],"names":["_isEmpty","value","isEmpty","getBasicClass","prefix","type","isBoolean","booleanPrefixes","some","booleanPrefix","toString","startsWith","kebabCase","handleBasicClasses","props","otherClasses","Object","keys","forEach","prop","classNames","isPassiveEventAvailable","supportsPassiveOption","opts","defineProperty","get","window","addEventListener","noop","removeEventListener","e","detectHorizontalSwipe","touchSurface","handleSwipe","startX","startY","threshold","restraint","allowedTime","elapsedTime","startTime","finished","onTouchStart","evt","Array","from","changedTouches","touch","pageX","pageY","Date","getTime","onTouchMove","distX","distY","Math","abs","direction","eventOptions","passive","onEnterPressed","handler","key","onEscapePressed","onButtonPressed","CSS_PREFIX","DIALOG_TRANSITION_DURATION","NOTIFICATION_TRANSITION_DURATION","SLIDESHOW_TRANSITION_DURATION","TOOLTIP_HOVER_DELAY","open","close","TOOLTIP_LONG_PRESS_DELAY","LAST_PART_CLASSNAME","getRootClassName","componentName","subComponent","formattedClassName","replace"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,YAAY;AAEb;AACA,CAAC,IAAI,MAAM,GAAG,EAAE,CAAC,cAAc,CAAC;AAChC;AACA,CAAC,SAAS,UAAU,IAAI;AACxB,EAAE,IAAI,OAAO,GAAG,EAAE,CAAC;AACnB;AACA,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC7C,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAC1B,GAAG,IAAI,CAAC,GAAG,EAAE,SAAS;AACtB;AACA,GAAG,IAAI,OAAO,GAAG,OAAO,GAAG,CAAC;AAC5B;AACA,GAAG,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,QAAQ,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RootClassName.js","sources":["../../../../../node_modules/classnames/index.js","../../../../lumx-core/src/js/utils.ts","../../../../lumx-core/src/js/constants/index.ts","../../../src/utils/getRootClassName.ts"],"sourcesContent":["/*!\n Copyright (c) 2017 Jed Watson.\n Licensed under the MIT License (MIT), see\n http://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = [];\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (!arg) continue;\n\n\t\t\tvar argType = typeof arg;\n\n\t\t\tif (argType === 'string' || argType === 'number') {\n\t\t\t\tclasses.push(arg);\n\t\t\t} else if (Array.isArray(arg) && arg.length) {\n\t\t\t\tvar inner = classNames.apply(null, arg);\n\t\t\t\tif (inner) {\n\t\t\t\t\tclasses.push(inner);\n\t\t\t\t}\n\t\t\t} else if (argType === 'object') {\n\t\t\t\tfor (var key in arg) {\n\t\t\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\t\t\tclasses.push(key);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn classes.join(' ');\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","import classNames from 'classnames';\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport React from 'react';\n\nimport isBoolean from 'lodash/isBoolean';\nimport isEmpty from 'lodash/isEmpty';\nimport kebabCase from 'lodash/kebabCase';\nimport noop from 'lodash/noop';\n\n/**\n * Enhance isEmpty method to also works with numbers.\n *\n * @param value The value to check.\n * @return Whether the input value is empty or != 0.\n */\nconst _isEmpty = (value: any) => {\n if (typeof value === 'number') {\n return value === 0;\n }\n\n return isEmpty(value);\n};\n\n/**\n * Get the basic CSS class for the given type.\n *\n * @param prefix The class name prefix for the generated CSS class.\n * @param type The type of CSS class we want to generate (e.g.: 'color', 'variant', ...).\n * @param value The value of the type of the CSS class (e.g.: 'primary', 'button', ...).\n * @return The basic CSS class.\n */\nexport function getBasicClass({\n prefix,\n type,\n value,\n}: {\n prefix: string;\n type: string;\n value: string | number | boolean | undefined;\n}): string {\n if (isBoolean(value)) {\n if (!value) {\n // False value should not return a class.\n return '';\n }\n const booleanPrefixes = ['has', 'is'];\n\n if (booleanPrefixes.some((booleanPrefix) => type.toString().startsWith(booleanPrefix))) {\n return `${prefix}--${kebabCase(type)}`;\n }\n\n return `${prefix}--is-${kebabCase(type)}`;\n }\n\n return `${prefix}--${kebabCase(type)}-${value}`;\n}\n\n/**\n * Return all basic LumX CSS classes which are available for every components.\n *\n * @see {@link /src/components/index.d.ts} for the possible values of each parameter.\n *\n * @param prefix The class name prefix for the generated CSS class.\n * @param props All the other props you want to generate a class.\n * The rule of thumb: the key is the name of the prop in the class, the value a string that will\n * be used in the classname to represent the value of the given prop.\n * @return All LumX basic CSS classes.\n */\nexport function handleBasicClasses({ prefix, ...props }: { prefix: string; [prop: string]: any }): string {\n const otherClasses: any = {};\n if (!isEmpty(props)) {\n Object.keys(props).forEach((prop) => {\n otherClasses[getBasicClass({ prefix, type: prop, value: props[prop] })] = isBoolean(props[prop])\n ? props[prop]\n : !_isEmpty(props[prop]);\n });\n }\n\n return classNames(prefix, otherClasses);\n}\n\ndeclare type SwipeDirection = 'none' | 'up' | 'down' | 'left' | 'right';\n\n/**\n * Detects swipe direction.\n * Credits: http://javascriptkit.com/javatutors/touchevents2.shtml.\n *\n * @deprecated use `detectHorizontalSwipe` instead if possible (better performance and does not block scroll)\n * @param touchSurface Element that will hold touch events.\n * @param handleSwipe Callback function.\n * @return Function to remove listeners.\n */\nexport function detectSwipe(touchSurface: Element, handleSwipe: (direction: SwipeDirection) => void = noop) {\n let distX: number;\n let distY: number;\n let startX: number;\n let startY: number;\n let direction: SwipeDirection;\n // Required min distance traveled to be considered swipe.\n const threshold = 150;\n // Maximum distance allowed at the same time in perpendicular direction.\n const restraint = 100;\n // Maximum time allowed to travel that distance.\n const allowedTime = 300;\n let elapsedTime: number;\n let startTime: number;\n\n const onTouchStart = (evt: Event) => {\n const [touch] = Array.from((evt as TouchEvent).changedTouches);\n direction = 'none';\n // Const dist = 0;\n startX = touch.pageX;\n startY = touch.pageY;\n // Record time when finger first makes contact with surface.\n startTime = new Date().getTime();\n evt.preventDefault();\n };\n\n const onTouchMove = (evt: Event) => {\n // Prevent scrolling when inside DIV.\n evt.preventDefault();\n };\n\n const onTouchEnd = (evt: Event) => {\n const [touch] = Array.from((evt as TouchEvent).changedTouches);\n // Get horizontal dist traveled by finger while in contact with surface.\n distX = touch.pageX - startX;\n // Get vertical dist traveled by finger while in contact with surface.\n distY = touch.pageY - startY;\n // Get time elapsed.\n elapsedTime = new Date().getTime() - startTime;\n if (elapsedTime <= allowedTime) {\n // First condition for awipe met.\n if (Math.abs(distX) >= threshold && Math.abs(distY) <= restraint) {\n // 2nd condition for horizontal swipe met.\n // If dist traveled is negative, it indicates left swipe.\n direction = distX < 0 ? 'left' : 'right';\n } else if (Math.abs(distY) >= threshold && Math.abs(distX) <= restraint) {\n // 2nd condition for vertical swipe met.\n // If dist traveled is negative, it indicates up swipe.\n direction = distY < 0 ? 'up' : 'down';\n }\n }\n handleSwipe(direction);\n evt.preventDefault();\n };\n\n touchSurface.addEventListener('touchstart', onTouchStart, false);\n touchSurface.addEventListener('touchmove', onTouchMove, false);\n touchSurface.addEventListener('touchend', onTouchEnd, false);\n\n return () => {\n touchSurface.removeEventListener('touchstart', onTouchStart, false);\n touchSurface.removeEventListener('touchmove', onTouchMove, false);\n touchSurface.removeEventListener('touchend', onTouchEnd, false);\n };\n}\n\n/**\n * Checks whether or not the browser support passive events.\n * @see https://github.com/Modernizr/Modernizr/blob/6d56d814b9682843313b16060adb25a58d83a317/feature-detects/dom/passiveeventlisteners.js\n */\nfunction isPassiveEventAvailable() {\n let supportsPassiveOption = false;\n try {\n const opts = Object.defineProperty({}, 'passive', {\n get() {\n supportsPassiveOption = true;\n },\n });\n window.addEventListener('testPassiveEventSupport', noop, opts);\n window.removeEventListener('testPassiveEventSupport', noop, opts);\n } catch (e) {\n // ignored\n }\n return supportsPassiveOption;\n}\n\n/**\n * Detects horizontal swipe direction without blocking the browser scroll using passive event.\n * @see http://javascriptkit.com/javatutors/touchevents2.shtml\n * @see https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md\n */\nexport function detectHorizontalSwipe(touchSurface: Element, handleSwipe: (direction: 'right' | 'left') => void) {\n let startX: number;\n let startY: number;\n // Required min distance traveled to be considered swipe.\n const threshold = 150;\n // Maximum distance allowed at the same time in perpendicular direction.\n const restraint = 150;\n // Maximum time allowed to travel that distance.\n const allowedTime = 300;\n let elapsedTime: number;\n let startTime: number;\n let finished: boolean;\n\n const onTouchStart = (evt: Event) => {\n const [touch] = Array.from((evt as TouchEvent).changedTouches);\n startX = touch.pageX;\n startY = touch.pageY;\n // Record time when finger first makes contact with surface.\n startTime = new Date().getTime();\n finished = false;\n };\n\n const onTouchMove = (evt: Event) => {\n if (finished) {\n return;\n }\n\n elapsedTime = new Date().getTime() - startTime;\n if (elapsedTime > allowedTime) {\n // Touch swipe too long to be considered.\n return;\n }\n\n const [touch] = Array.from((evt as TouchEvent).changedTouches);\n // Get horizontal dist traveled by finger while in contact with surface.\n const distX = touch.pageX - startX;\n // Get vertical dist traveled by finger while in contact with surface.\n const distY = touch.pageY - startY;\n\n if (!(Math.abs(distX) >= threshold && Math.abs(distY) <= restraint)) {\n // Swipe is not horizontal.\n return;\n }\n // Swipe direction.\n const direction = distX < 0 ? 'left' : 'right';\n\n handleSwipe(direction);\n finished = true;\n };\n\n // Activate passive event if possible for better scrolling performance.\n const eventOptions: any = isPassiveEventAvailable() ? { passive: true } : false;\n touchSurface.addEventListener('touchstart', onTouchStart, eventOptions);\n touchSurface.addEventListener('touchmove', onTouchMove, eventOptions);\n\n return () => {\n touchSurface.removeEventListener('touchstart', onTouchStart, eventOptions);\n touchSurface.removeEventListener('touchmove', onTouchMove, eventOptions);\n };\n}\n\ntype KeyboardEventHandler<E extends KeyboardEvent | React.KeyboardEvent> = (event: E) => void;\n\n/**\n * Make sure the pressed key is the enter key before calling the callback.\n *\n * @param handler The handler to call on enter/return press.\n * @return The decorated function.\n */\nexport function onEnterPressed<E extends KeyboardEvent | React.KeyboardEvent>(\n handler: KeyboardEventHandler<E>,\n): KeyboardEventHandler<E> {\n return (evt) => {\n if (evt.key !== 'Enter') {\n return;\n }\n handler(evt);\n };\n}\n\n/**\n * Make sure the pressed key is the escape key before calling the callback.\n *\n * @param handler The handler to call on enter/return press.\n * @return The decorated function.\n */\nexport function onEscapePressed<E extends KeyboardEvent | React.KeyboardEvent>(\n handler: KeyboardEventHandler<E>,\n): KeyboardEventHandler<E> {\n return (evt) => {\n if (evt.key !== 'Escape') {\n return;\n }\n handler(evt);\n };\n}\n\n/**\n * Handle button key pressed (Enter + Space).\n *\n * @param handler The handler to call.\n * @return The decorated function.\n */\nexport function onButtonPressed<E extends KeyboardEvent | React.KeyboardEvent>(\n handler: KeyboardEventHandler<E>,\n): KeyboardEventHandler<E> {\n return (evt) => {\n if (evt.key !== 'Enter' && evt.key !== ' ') {\n return;\n }\n handler(evt);\n };\n}\n","/**\n * The prefix to use for the CSS classes.\n */\nexport const CSS_PREFIX = 'lumx';\n\n/**\n * Key codes.\n */\nexport * from './keycodes';\n\n/**\n * Animation duration constants. Take into consideration that if you change one of these variables,\n * you need to update their scss counterpart as well\n */\nexport const DIALOG_TRANSITION_DURATION = 400;\nexport const NOTIFICATION_TRANSITION_DURATION = 200;\nexport const SLIDESHOW_TRANSITION_DURATION = 5000;\n\n/**\n * Delay on hover after which we open or close the tooltip.\n * Only applies to devices supporting pointer hover.\n */\nexport const TOOLTIP_HOVER_DELAY = {\n open: 500,\n close: 0,\n};\n\n/**\n * Delay on long press after which we open or close the tooltip.\n * Only applies to devices not supporting pointer hover.\n */\nexport const TOOLTIP_LONG_PRESS_DELAY = {\n open: 250,\n close: 3000,\n};\n","import { CSS_PREFIX } from '@lumx/react/constants';\n\nimport kebabCase from 'lodash/kebabCase';\n\n// See https://regex101.com/r/YjS1uI/3\nconst LAST_PART_CLASSNAME = /^(.*)-(.+)$/gi;\n\n/**\n * Get the name of the root CSS class of a component based on its name.\n *\n * @param componentName The name of the component. This name should contains the component prefix and be\n * written in PascalCase.\n * @param subComponent Whether the current component is a sub component, if true, define the class according\n * to BEM standards.\n * @return The name of the root CSS class. This classname include the CSS classname prefix and is written in\n * lower-snake-case.\n */\nexport function getRootClassName(componentName: string, subComponent?: boolean): string {\n const formattedClassName = `${CSS_PREFIX}-${kebabCase(componentName)}`;\n\n if (subComponent) {\n return formattedClassName.replace(LAST_PART_CLASSNAME, '$1__$2');\n }\n return formattedClassName;\n}\n"],"names":["_isEmpty","value","isEmpty","getBasicClass","prefix","type","isBoolean","booleanPrefixes","some","booleanPrefix","toString","startsWith","kebabCase","handleBasicClasses","props","otherClasses","Object","keys","forEach","prop","classNames","isPassiveEventAvailable","supportsPassiveOption","opts","defineProperty","get","window","addEventListener","noop","removeEventListener","e","detectHorizontalSwipe","touchSurface","handleSwipe","startX","startY","threshold","restraint","allowedTime","elapsedTime","startTime","finished","onTouchStart","evt","Array","from","changedTouches","touch","pageX","pageY","Date","getTime","onTouchMove","distX","distY","Math","abs","direction","eventOptions","passive","onEnterPressed","handler","key","onEscapePressed","onButtonPressed","CSS_PREFIX","DIALOG_TRANSITION_DURATION","NOTIFICATION_TRANSITION_DURATION","TOOLTIP_HOVER_DELAY","open","close","TOOLTIP_LONG_PRESS_DELAY","LAST_PART_CLASSNAME","getRootClassName","componentName","subComponent","formattedClassName","replace"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAA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B;AAE/BC,EAAAA,KAAK,EAAE;AAFwB;AAKnC;;;;;IAIaC,wBAAwB,GAAG;AACpCF,EAAAA,IAAI,EAAE,GAD8B;AAEpCC,EAAAA,KAAK,EAAE;AAF6B;;AC1BxC,IAAME,mBAAmB,GAAG,eAA5B;AAEA;;;;;;;;;;;AAUO,SAASC,gBAAT,CAA0BC,aAA1B,EAAiDC,YAAjD,EAAiF;AACpF,MAAMC,kBAAkB,aAAMX,UAAN,cAAoBrD,SAAS,CAAC8D,aAAD,CAA7B,CAAxB;;AAEA,MAAIC,YAAJ,EAAkB;AACd,WAAOC,kBAAkB,CAACC,OAAnB,CAA2BL,mBAA3B,EAAgD,QAAhD,CAAP;AACH;;AACD,SAAOI,kBAAP;AACH;;;;"}
|
|
@@ -20,7 +20,6 @@ import 'lodash/range';
|
|
|
20
20
|
import 'react-dom';
|
|
21
21
|
import './ClickAwayProvider.js';
|
|
22
22
|
import 'lodash/pull';
|
|
23
|
-
import './useDelayedVisibility.js';
|
|
24
23
|
export { c as Slides, S as Slideshow, b as SlideshowControls, a as SlideshowItem } from './Slides.js';
|
|
25
24
|
import 'lodash/uniqueId';
|
|
26
25
|
import './Tooltip2.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slideshow.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"slideshow.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@juggle/resize-observer": "^3.2.0",
|
|
10
|
-
"@lumx/core": "^2.2.
|
|
11
|
-
"@lumx/icons": "^2.2.
|
|
10
|
+
"@lumx/core": "^2.2.12-alpha.2",
|
|
11
|
+
"@lumx/icons": "^2.2.12-alpha.2",
|
|
12
12
|
"@popperjs/core": "^2.5.4",
|
|
13
13
|
"body-scroll-lock": "^3.1.5",
|
|
14
14
|
"classnames": "^2.2.6",
|
|
@@ -120,6 +120,6 @@
|
|
|
120
120
|
"build:storybook": "cd storybook && ./build"
|
|
121
121
|
},
|
|
122
122
|
"sideEffects": false,
|
|
123
|
-
"version": "2.2.
|
|
124
|
-
"gitHead": "
|
|
123
|
+
"version": "2.2.12-alpha.2",
|
|
124
|
+
"gitHead": "bca1497272a2a835b2563128fd558bf088f28444"
|
|
125
125
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
2
|
|
|
3
3
|
import { mdiEmail } from '@lumx/icons';
|
|
4
|
-
import { ColorPalette, FlexBox, Icon, IconSizes, Size } from '@lumx/react';
|
|
4
|
+
import { ColorPalette, ColorVariant, FlexBox, Icon, IconSizes, Size } from '@lumx/react';
|
|
5
5
|
import { Orientation } from '..';
|
|
6
6
|
|
|
7
|
-
export default { title: 'LumX components/icon/Icon' };
|
|
7
|
+
export default { title: 'LumX components/icon/Icon', parameters: { hasGreyBackground: true } };
|
|
8
8
|
|
|
9
9
|
const iconSizes: Array<IconSizes | undefined> = [
|
|
10
10
|
undefined,
|
|
@@ -16,42 +16,61 @@ const iconSizes: Array<IconSizes | undefined> = [
|
|
|
16
16
|
Size.xl,
|
|
17
17
|
Size.xxl,
|
|
18
18
|
];
|
|
19
|
-
const iconColors = [undefined, ...Object.values(ColorPalette)];
|
|
20
|
-
const iconShapes = [false, true];
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
const TemplateSizeVariants = ({ hasShape, theme }: any) => (
|
|
21
|
+
<FlexBox orientation={Orientation.horizontal}>
|
|
22
|
+
{iconSizes.map((size) => (
|
|
23
|
+
<FlexBox fillSpace key={`${size}`}>
|
|
24
|
+
<h2>Size: {size || 'undefined'}</h2>
|
|
25
|
+
<Icon icon={mdiEmail} size={size} hasShape={hasShape} theme={theme} />
|
|
26
|
+
</FlexBox>
|
|
27
|
+
))}
|
|
28
|
+
</FlexBox>
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export const AllSize = ({ theme }: any) => TemplateSizeVariants({ theme });
|
|
32
|
+
|
|
33
|
+
export const AllSizeWithShape = ({ theme }: any) => TemplateSizeVariants({ theme, hasShape: true });
|
|
34
|
+
|
|
35
|
+
const TemplateColorVariants = ({ hasShape, theme }: any) => {
|
|
36
|
+
const withUndefined = (a: any) => [undefined].concat(Object.values(a));
|
|
23
37
|
return (
|
|
24
|
-
|
|
25
|
-
{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
38
|
+
<FlexBox orientation={Orientation.horizontal}>
|
|
39
|
+
{withUndefined(ColorPalette).map((color) => (
|
|
40
|
+
<FlexBox fillSpace key={`${color}`}>
|
|
41
|
+
<small key={`${color}`}>Color: {color || 'undefined'}</small>
|
|
42
|
+
<br />
|
|
43
|
+
{withUndefined(Object.values(ColorVariant).reverse()).map((colorVariant) => (
|
|
44
|
+
<Fragment key={`${colorVariant}`}>
|
|
45
|
+
{!colorVariant && (
|
|
31
46
|
<>
|
|
32
|
-
<
|
|
33
|
-
<
|
|
34
|
-
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
icon={mdiEmail}
|
|
41
|
-
color={color}
|
|
42
|
-
size={size}
|
|
43
|
-
theme={theme}
|
|
44
|
-
/>
|
|
45
|
-
</FlexBox>
|
|
46
|
-
);
|
|
47
|
-
})}
|
|
48
|
-
</FlexBox>
|
|
47
|
+
<small>No theme</small>
|
|
48
|
+
<Icon
|
|
49
|
+
icon={mdiEmail}
|
|
50
|
+
color={color}
|
|
51
|
+
colorVariant={colorVariant}
|
|
52
|
+
size="m"
|
|
53
|
+
hasShape={hasShape}
|
|
54
|
+
/>
|
|
49
55
|
</>
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
)}
|
|
57
|
+
<small>Variant: {colorVariant || 'undefined'}</small>
|
|
58
|
+
<Icon
|
|
59
|
+
icon={mdiEmail}
|
|
60
|
+
color={color}
|
|
61
|
+
colorVariant={colorVariant}
|
|
62
|
+
size="m"
|
|
63
|
+
theme={theme}
|
|
64
|
+
hasShape={hasShape}
|
|
65
|
+
/>
|
|
66
|
+
</Fragment>
|
|
67
|
+
))}
|
|
68
|
+
</FlexBox>
|
|
69
|
+
))}
|
|
70
|
+
</FlexBox>
|
|
56
71
|
);
|
|
57
72
|
};
|
|
73
|
+
|
|
74
|
+
export const AllColors = ({ theme }: any) => TemplateColorVariants({ theme });
|
|
75
|
+
|
|
76
|
+
export const AllColorsWithShape = ({ theme }: any) => TemplateColorVariants({ theme, hasShape: true });
|
|
@@ -19,8 +19,8 @@ export interface IconProps extends GenericProps {
|
|
|
19
19
|
/** Whether the icon has a shape. */
|
|
20
20
|
hasShape?: boolean;
|
|
21
21
|
/**
|
|
22
|
-
* Icon (SVG path)
|
|
23
|
-
*
|
|
22
|
+
* Icon (SVG path) draw code (`d` property of the `<path>` SVG element).
|
|
23
|
+
* See https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths
|
|
24
24
|
*/
|
|
25
25
|
icon: string;
|
|
26
26
|
/** Size variant. */
|
|
@@ -56,35 +56,25 @@ const DEFAULT_PROPS: Partial<IconProps> = {};
|
|
|
56
56
|
export const Icon: Comp<IconProps, HTMLElement> = forwardRef((props, ref) => {
|
|
57
57
|
const { className, color, colorVariant, hasShape, icon, size, theme, alt, ...forwardedProps } = props;
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
let
|
|
61
|
-
if (
|
|
62
|
-
iconColor =
|
|
63
|
-
|
|
64
|
-
} else if (theme) {
|
|
65
|
-
iconColor = theme === Theme.light ? ColorPalette.dark : ColorPalette.light;
|
|
59
|
+
// Color
|
|
60
|
+
let iconColor = color;
|
|
61
|
+
if (!iconColor && (hasShape || theme)) {
|
|
62
|
+
iconColor = theme === Theme.dark ? ColorPalette.light : ColorPalette.dark;
|
|
63
|
+
}
|
|
66
64
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
} else if (hasShape) {
|
|
73
|
-
iconColor = ColorPalette.dark;
|
|
65
|
+
// Color variant
|
|
66
|
+
let iconColorVariant = colorVariant;
|
|
67
|
+
if (!iconColorVariant && hasShape && iconColor === ColorPalette.dark) {
|
|
68
|
+
iconColorVariant = 'L2';
|
|
74
69
|
}
|
|
75
70
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
} else {
|
|
84
|
-
iconSize = size;
|
|
85
|
-
}
|
|
86
|
-
} else {
|
|
87
|
-
iconSize = size;
|
|
71
|
+
// Size
|
|
72
|
+
let iconSize = size;
|
|
73
|
+
if (size && hasShape) {
|
|
74
|
+
if (size === Size.xxs || size === Size.xs) {
|
|
75
|
+
iconSize = Size.s;
|
|
76
|
+
} else if (size === Size.xxl) {
|
|
77
|
+
iconSize = Size.xl;
|
|
88
78
|
}
|
|
89
79
|
} else if (hasShape) {
|
|
90
80
|
iconSize = Size.m;
|
|
@@ -101,6 +91,7 @@ export const Icon: Comp<IconProps, HTMLElement> = forwardRef((props, ref) => {
|
|
|
101
91
|
colorVariant: iconColorVariant,
|
|
102
92
|
hasShape,
|
|
103
93
|
prefix: CLASSNAME,
|
|
94
|
+
theme,
|
|
104
95
|
size: iconSize,
|
|
105
96
|
}),
|
|
106
97
|
!hasShape && `${CLASSNAME}--no-shape`,
|
|
@@ -26,11 +26,7 @@ export interface SlidesProps extends GenericProps {
|
|
|
26
26
|
/** id to be passed in into the slides */
|
|
27
27
|
slidesId?: string;
|
|
28
28
|
/** callback to change whether the slideshow is playing or not */
|
|
29
|
-
|
|
30
|
-
/** starting visible index */
|
|
31
|
-
startIndexVisible: number;
|
|
32
|
-
/** ending visible index */
|
|
33
|
-
endIndexVisible: number;
|
|
29
|
+
toggleAutoPlay: () => void;
|
|
34
30
|
/** component to be rendered after the slides */
|
|
35
31
|
afterSlides?: React.ReactNode;
|
|
36
32
|
}
|
|
@@ -61,11 +57,8 @@ export const Slides: Comp<SlidesProps, HTMLDivElement> = forwardRef((props, ref)
|
|
|
61
57
|
fillHeight,
|
|
62
58
|
groupBy,
|
|
63
59
|
isAutoPlaying,
|
|
64
|
-
|
|
60
|
+
toggleAutoPlay,
|
|
65
61
|
slidesId,
|
|
66
|
-
setIsAutoPlaying,
|
|
67
|
-
startIndexVisible,
|
|
68
|
-
endIndexVisible,
|
|
69
62
|
children,
|
|
70
63
|
afterSlides,
|
|
71
64
|
...forwardedProps
|
|
@@ -87,22 +80,12 @@ export const Slides: Comp<SlidesProps, HTMLDivElement> = forwardRef((props, ref)
|
|
|
87
80
|
<div
|
|
88
81
|
id={slidesId}
|
|
89
82
|
className={`${CLASSNAME}__slides`}
|
|
90
|
-
onMouseEnter={
|
|
91
|
-
onMouseLeave={
|
|
83
|
+
onMouseEnter={toggleAutoPlay}
|
|
84
|
+
onMouseLeave={toggleAutoPlay}
|
|
92
85
|
aria-live={isAutoPlaying ? 'off' : 'polite'}
|
|
93
86
|
>
|
|
94
87
|
<div className={`${CLASSNAME}__wrapper`} style={wrapperStyle}>
|
|
95
|
-
{
|
|
96
|
-
if (React.isValidElement(child)) {
|
|
97
|
-
const isCurrentlyVisible = index >= startIndexVisible && index < endIndexVisible;
|
|
98
|
-
|
|
99
|
-
return React.cloneElement(child, {
|
|
100
|
-
isCurrentlyVisible,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return null;
|
|
105
|
-
})}
|
|
88
|
+
{children}
|
|
106
89
|
</div>
|
|
107
90
|
</div>
|
|
108
91
|
|
|
@@ -72,9 +72,6 @@ export const Slideshow: Comp<SlideshowProps, HTMLDivElement> = forwardRef((props
|
|
|
72
72
|
setSlideshow,
|
|
73
73
|
isAutoPlaying,
|
|
74
74
|
slideshowSlidesId,
|
|
75
|
-
setIsAutoPlaying,
|
|
76
|
-
startIndexVisible,
|
|
77
|
-
endIndexVisible,
|
|
78
75
|
slidesCount,
|
|
79
76
|
onNextClick,
|
|
80
77
|
onPaginationClick,
|
|
@@ -82,8 +79,8 @@ export const Slideshow: Comp<SlideshowProps, HTMLDivElement> = forwardRef((props
|
|
|
82
79
|
slideshow,
|
|
83
80
|
stopAutoPlay,
|
|
84
81
|
startAutoPlay,
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
toggleAutoPlay,
|
|
83
|
+
toggleForcePause,
|
|
87
84
|
} = SlideshowControls.useSlideshowControls({
|
|
88
85
|
activeIndex,
|
|
89
86
|
defaultActiveIndex: DEFAULT_PROPS.activeIndex as number,
|
|
@@ -113,9 +110,7 @@ export const Slideshow: Comp<SlideshowProps, HTMLDivElement> = forwardRef((props
|
|
|
113
110
|
isAutoPlaying={isAutoPlaying}
|
|
114
111
|
autoPlay={autoPlay}
|
|
115
112
|
slidesId={slideshowSlidesId}
|
|
116
|
-
|
|
117
|
-
startIndexVisible={startIndexVisible}
|
|
118
|
-
endIndexVisible={endIndexVisible}
|
|
113
|
+
toggleAutoPlay={toggleAutoPlay}
|
|
119
114
|
interval={interval}
|
|
120
115
|
ref={mergeRefs(ref, setSlideshow)}
|
|
121
116
|
afterSlides={
|
|
@@ -143,7 +138,7 @@ export const Slideshow: Comp<SlideshowProps, HTMLDivElement> = forwardRef((props
|
|
|
143
138
|
autoPlay
|
|
144
139
|
? {
|
|
145
140
|
'aria-controls': slideshowSlidesId,
|
|
146
|
-
onClick:
|
|
141
|
+
onClick: toggleForcePause,
|
|
147
142
|
...slideshowControlsProps.playButtonProps,
|
|
148
143
|
}
|
|
149
144
|
: undefined
|
|
@@ -39,18 +39,15 @@ export const ControllingSlideshow = ({ theme }: any) => {
|
|
|
39
39
|
setSlideshow,
|
|
40
40
|
isAutoPlaying,
|
|
41
41
|
slideshowSlidesId,
|
|
42
|
-
setIsAutoPlaying,
|
|
43
|
-
startIndexVisible,
|
|
44
|
-
endIndexVisible,
|
|
45
42
|
slidesCount,
|
|
46
43
|
onNextClick,
|
|
47
44
|
onPaginationClick,
|
|
48
45
|
onPreviousClick,
|
|
49
46
|
slideshow,
|
|
50
|
-
isForcePaused,
|
|
51
|
-
setIsForcePaused,
|
|
52
47
|
stopAutoPlay,
|
|
53
48
|
startAutoPlay,
|
|
49
|
+
toggleAutoPlay,
|
|
50
|
+
toggleForcePause,
|
|
54
51
|
} = SlideshowControls.useSlideshowControls({
|
|
55
52
|
activeIndex: 0,
|
|
56
53
|
defaultActiveIndex: 0,
|
|
@@ -73,11 +70,8 @@ export const ControllingSlideshow = ({ theme }: any) => {
|
|
|
73
70
|
ref={setSlideshow}
|
|
74
71
|
theme={theme}
|
|
75
72
|
isAutoPlaying={isAutoPlaying}
|
|
76
|
-
autoPlay
|
|
77
73
|
slidesId={slideshowSlidesId}
|
|
78
|
-
|
|
79
|
-
startIndexVisible={startIndexVisible}
|
|
80
|
-
endIndexVisible={endIndexVisible}
|
|
74
|
+
toggleAutoPlay={toggleAutoPlay}
|
|
81
75
|
groupBy={1}
|
|
82
76
|
style={{ width: '50%' }}
|
|
83
77
|
afterSlides={
|
|
@@ -96,7 +90,7 @@ export const ControllingSlideshow = ({ theme }: any) => {
|
|
|
96
90
|
playButtonProps={{
|
|
97
91
|
label: 'Play/Pause',
|
|
98
92
|
'aria-controls': slideshowSlidesId,
|
|
99
|
-
onClick:
|
|
93
|
+
onClick: toggleForcePause,
|
|
100
94
|
}}
|
|
101
95
|
paginationItemLabel={(index) => `Slide ${index}`}
|
|
102
96
|
/>
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import React, { forwardRef
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';
|
|
6
6
|
|
|
7
|
-
import { useDelayedVisibility } from '@lumx/react/hooks/useDelayedVisibility';
|
|
8
|
-
|
|
9
|
-
import { SLIDESHOW_TRANSITION_DURATION } from '@lumx/core/js/constants';
|
|
10
|
-
|
|
11
7
|
/**
|
|
12
8
|
* Defines the props of the component.
|
|
13
9
|
*/
|
|
@@ -36,12 +32,7 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
36
32
|
* @return React element.
|
|
37
33
|
*/
|
|
38
34
|
export const SlideshowItem: Comp<SlideshowItemProps, HTMLDivElement> = forwardRef((props, ref) => {
|
|
39
|
-
const { className, children,
|
|
40
|
-
const [isVisible, setIsVisible] = useState<boolean>(isCurrentlyVisible);
|
|
41
|
-
|
|
42
|
-
useDelayedVisibility(isCurrentlyVisible, SLIDESHOW_TRANSITION_DURATION, (isNowVisible) => {
|
|
43
|
-
setIsVisible(isNowVisible);
|
|
44
|
-
});
|
|
35
|
+
const { className, children, ...forwardedProps } = props;
|
|
45
36
|
|
|
46
37
|
return (
|
|
47
38
|
<div
|
|
@@ -55,8 +46,6 @@ export const SlideshowItem: Comp<SlideshowItemProps, HTMLDivElement> = forwardRe
|
|
|
55
46
|
aria-roledescription="slide"
|
|
56
47
|
role="group"
|
|
57
48
|
{...forwardedProps}
|
|
58
|
-
style={!isVisible ? { visibility: 'hidden', ...(forwardedProps.style || {}) } : forwardedProps.style || {}}
|
|
59
|
-
aria-hidden={!isVisible}
|
|
60
49
|
>
|
|
61
50
|
{children}
|
|
62
51
|
</div>
|
|
@@ -33,20 +33,18 @@ Array [
|
|
|
33
33
|
</div>
|
|
34
34
|
}
|
|
35
35
|
autoPlay={false}
|
|
36
|
-
endIndexVisible={1}
|
|
37
36
|
groupBy={1}
|
|
38
37
|
id="slideshow1"
|
|
39
38
|
interval={1000}
|
|
40
39
|
isAutoPlaying={false}
|
|
41
|
-
setIsAutoPlaying={[Function]}
|
|
42
40
|
slidesId="slideshow-slides2"
|
|
43
|
-
startIndexVisible={0}
|
|
44
41
|
style={
|
|
45
42
|
Object {
|
|
46
43
|
"width": "50%",
|
|
47
44
|
}
|
|
48
45
|
}
|
|
49
46
|
theme="light"
|
|
47
|
+
toggleAutoPlay={[Function]}
|
|
50
48
|
>
|
|
51
49
|
<SlideshowItem
|
|
52
50
|
key="/demo-assets/landscape1.jpg-0"
|
|
@@ -52,10 +52,10 @@ export interface UseSlideshowControls {
|
|
|
52
52
|
isAutoPlaying: boolean;
|
|
53
53
|
/** whether the slideshow was force paused or not */
|
|
54
54
|
isForcePaused: boolean;
|
|
55
|
-
/** callback to enable/disable the force pause feature */
|
|
56
|
-
setIsForcePaused: (isForcePaused: boolean) => void;
|
|
57
55
|
/** callback to change whether the slideshow is autoplaying or not */
|
|
58
|
-
|
|
56
|
+
toggleAutoPlay: () => void;
|
|
57
|
+
/** calback to change whether the slideshow should be force paused or not */
|
|
58
|
+
toggleForcePause: () => void;
|
|
59
59
|
/** current active slide index */
|
|
60
60
|
activeIndex: number;
|
|
61
61
|
/** set the current index as the active one */
|
|
@@ -141,10 +141,19 @@ export const useSlideshowControls = ({
|
|
|
141
141
|
}
|
|
142
142
|
}, [currentIndex, slidesCount, defaultActiveIndex]);
|
|
143
143
|
|
|
144
|
+
const startAutoPlay = () => {
|
|
145
|
+
setIsAutoPlaying(Boolean(autoPlay));
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const stopAutoPlay = () => {
|
|
149
|
+
setIsAutoPlaying(false);
|
|
150
|
+
};
|
|
151
|
+
|
|
144
152
|
// Handle click on a bullet to go to a specific slide.
|
|
145
153
|
const onPaginationClick = useCallback(
|
|
146
154
|
(index: number) => {
|
|
147
|
-
|
|
155
|
+
stopAutoPlay();
|
|
156
|
+
setIsForcePaused(true);
|
|
148
157
|
|
|
149
158
|
if (index >= 0 && index < slidesCount) {
|
|
150
159
|
setCurrentIndex(index);
|
|
@@ -156,7 +165,8 @@ export const useSlideshowControls = ({
|
|
|
156
165
|
// Handle click or keyboard event to go to next slide.
|
|
157
166
|
const onNextClick = useCallback(
|
|
158
167
|
(loopback = true) => {
|
|
159
|
-
|
|
168
|
+
stopAutoPlay();
|
|
169
|
+
setIsForcePaused(true);
|
|
160
170
|
goToNextSlide(loopback);
|
|
161
171
|
},
|
|
162
172
|
[goToNextSlide],
|
|
@@ -165,7 +175,8 @@ export const useSlideshowControls = ({
|
|
|
165
175
|
// Handle click or keyboard event to go to previous slide.
|
|
166
176
|
const onPreviousClick = useCallback(
|
|
167
177
|
(loopback = true) => {
|
|
168
|
-
|
|
178
|
+
stopAutoPlay();
|
|
179
|
+
setIsForcePaused(true);
|
|
169
180
|
goToPreviousSlide(loopback);
|
|
170
181
|
},
|
|
171
182
|
[goToPreviousSlide],
|
|
@@ -185,21 +196,23 @@ export const useSlideshowControls = ({
|
|
|
185
196
|
const slideshowId = useMemo(() => id || uniqueId('slideshow'), [id]);
|
|
186
197
|
const slideshowSlidesId = useMemo(() => slidesId || uniqueId('slideshow-slides'), [slidesId]);
|
|
187
198
|
|
|
188
|
-
const
|
|
189
|
-
|
|
199
|
+
const toggleAutoPlay = () => {
|
|
200
|
+
if (isSlideshowAutoPlaying) {
|
|
201
|
+
stopAutoPlay();
|
|
202
|
+
} else {
|
|
203
|
+
startAutoPlay();
|
|
204
|
+
}
|
|
190
205
|
};
|
|
191
206
|
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
};
|
|
207
|
+
const toggleForcePause = () => {
|
|
208
|
+
const shouldBePaused = !isForcePaused;
|
|
195
209
|
|
|
196
|
-
|
|
197
|
-
setIsForcePaused(isPaused);
|
|
210
|
+
setIsForcePaused(shouldBePaused);
|
|
198
211
|
|
|
199
|
-
if (
|
|
200
|
-
stopAutoPlay();
|
|
201
|
-
} else {
|
|
212
|
+
if (!shouldBePaused) {
|
|
202
213
|
startAutoPlay();
|
|
214
|
+
} else {
|
|
215
|
+
stopAutoPlay();
|
|
203
216
|
}
|
|
204
217
|
};
|
|
205
218
|
|
|
@@ -218,13 +231,13 @@ export const useSlideshowControls = ({
|
|
|
218
231
|
onNextClick,
|
|
219
232
|
onPaginationClick,
|
|
220
233
|
isAutoPlaying: isSlideshowAutoPlaying,
|
|
221
|
-
|
|
234
|
+
toggleAutoPlay,
|
|
222
235
|
activeIndex: currentIndex,
|
|
223
236
|
slidesCount,
|
|
224
237
|
setActiveIndex: setCurrentIndex,
|
|
225
238
|
startAutoPlay,
|
|
226
239
|
stopAutoPlay,
|
|
227
240
|
isForcePaused,
|
|
228
|
-
|
|
241
|
+
toggleForcePause,
|
|
229
242
|
};
|
|
230
243
|
};
|