@lumx/react 2.2.5 → 2.2.8
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/AutocompleteMultiple.js.map +1 -1
- package/esm/_internal/DatePickerField.js.map +1 -1
- package/esm/_internal/Icon2.js +5 -2
- package/esm/_internal/Icon2.js.map +1 -1
- package/esm/_internal/Lightbox2.js +6 -4
- package/esm/_internal/Lightbox2.js.map +1 -1
- package/esm/_internal/List2.js.map +1 -1
- package/esm/_internal/Notification2.js +2 -1
- package/esm/_internal/Notification2.js.map +1 -1
- package/esm/_internal/SelectMultiple.js.map +1 -1
- package/esm/_internal/SlideshowControls.js +234 -94
- package/esm/_internal/SlideshowControls.js.map +1 -1
- package/esm/_internal/Thumbnail2.js +1 -1
- package/esm/_internal/Thumbnail2.js.map +1 -1
- package/esm/_internal/Tooltip2.js +110 -113
- package/esm/_internal/Tooltip2.js.map +1 -1
- package/esm/_internal/autocomplete.js +0 -1
- package/esm/_internal/autocomplete.js.map +1 -1
- package/esm/_internal/button.js +0 -1
- package/esm/_internal/button.js.map +1 -1
- package/esm/_internal/constants.js.map +1 -1
- package/esm/_internal/date-picker.js +0 -1
- package/esm/_internal/date-picker.js.map +1 -1
- package/esm/_internal/expansion-panel.js +0 -1
- package/esm/_internal/expansion-panel.js.map +1 -1
- package/esm/_internal/getRootClassName.js +19 -1
- package/esm/_internal/getRootClassName.js.map +1 -1
- package/esm/_internal/lightbox.js +0 -1
- package/esm/_internal/lightbox.js.map +1 -1
- package/esm/_internal/mergeRefs.js.map +1 -1
- package/esm/_internal/select.js +0 -1
- package/esm/_internal/select.js.map +1 -1
- package/esm/_internal/side-navigation.js +0 -1
- package/esm/_internal/side-navigation.js.map +1 -1
- package/esm/_internal/slideshow.js +1 -1
- package/esm/_internal/text-field.js +0 -1
- package/esm/_internal/text-field.js.map +1 -1
- package/esm/_internal/tooltip.js +0 -1
- package/esm/_internal/tooltip.js.map +1 -1
- package/esm/_internal/useRovingTabIndex.js.map +1 -1
- package/esm/index.js +1 -1
- package/package.json +4 -4
- package/src/components/alert-dialog/AlertDialog.test.tsx +1 -0
- package/src/components/autocomplete/AutocompleteMultiple.tsx +3 -1
- package/src/components/button/__snapshots__/IconButton.test.tsx.snap +0 -5
- package/src/components/icon/Icon.tsx +6 -2
- package/src/components/image-block/ImageBlock.stories.tsx +1 -2
- package/src/components/lightbox/Lightbox.stories.tsx +1 -0
- package/src/components/lightbox/Lightbox.tsx +5 -3
- package/src/components/notification/Notification.tsx +1 -0
- package/src/components/select/SelectMultiple.tsx +0 -1
- package/src/components/slideshow/Slideshow.stories.tsx +1 -1
- package/src/components/slideshow/Slideshow.tsx +76 -112
- package/src/components/slideshow/SlideshowControls.stories.tsx +18 -12
- package/src/components/slideshow/SlideshowControls.tsx +11 -7
- package/src/components/slideshow/SlideshowItem.tsx +4 -1
- package/src/components/slideshow/__snapshots__/Slideshow.test.tsx.snap +52 -17
- package/src/components/tabs/state.ts +0 -1
- package/src/components/thumbnail/Thumbnail.stories.tsx +25 -1
- package/src/components/thumbnail/Thumbnail.test.tsx +9 -1
- package/src/components/thumbnail/Thumbnail.tsx +3 -0
- package/src/components/thumbnail/__snapshots__/Thumbnail.test.tsx.snap +26 -0
- package/src/components/tooltip/Tooltip.tsx +1 -2
- package/src/components/tooltip/useTooltipOpen.tsx +90 -91
- package/src/constants.ts +7 -1
- package/src/hooks/useFocusWithin.ts +33 -0
- package/src/hooks/useSlideshowControls.ts +213 -0
- package/src/utils/browserDoesNotSupportHover.test.js +24 -0
- package/src/utils/browserDoesNotSupportHover.ts +2 -0
- package/src/utils/index.tsx +0 -2
- package/src/utils/mergeRefs.ts +1 -1
- package/types.d.ts +62 -8
- package/src/utils/htmlDecode.ts +0 -13
|
@@ -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;\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","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;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,EAA2DM,YAA3D;AACH,GAHD;AAIH;;AAID;;;;;;AAMO,SAASE,cAAT,CACHC,OADG,EAEoB;AACvB,SAAO,UAAClB,GAAD,EAAS;AACZ,QAAIA,GAAG,CAACmB,GAAJ,KAAY,OAAhB,EAAyB;AACrB;AACH;;AACDD,IAAAA,OAAO,CAAClB,GAAD,CAAP;AACH,GALD;AAMH;AAED;;;;;;;AAMO,SAASoB,eAAT,CACHF,OADG,EAEoB;AACvB,SAAO,UAAClB,GAAD,EAAS;AACZ,QAAIA,GAAG,CAACmB,GAAJ,KAAY,QAAhB,EAA0B;AACtB;AACH;;AACDD,IAAAA,OAAO,CAAClB,GAAD,CAAP;AACH,GALD;AAMH;AAED;;;;;;;AAMO,SAASqB,eAAT,CACHH,OADG,EAEoB;AACvB,SAAO,UAAClB,GAAD,EAAS;AACZ,QAAIA,GAAG,CAACmB,GAAJ,KAAY,OAAZ,IAAuBnB,GAAG,CAACmB,GAAJ,KAAY,GAAvC,EAA4C;AACxC;AACH;;AACDD,IAAAA,OAAO,CAAClB,GAAD,CAAP;AACH,GALD;AAMH;;ACvSD;;;IAGasB,UAAU,GAAG;AAO1B;;;;;IAIaC,0BAA0B,GAAG;IAC7BC,gCAAgC,GAAG;;ACVhD,IAAMC,mBAAmB,GAAG,eAA5B;AAEA;;;;;;;;;;;AAUO,SAASC,gBAAT,CAA0BC,aAA1B,EAAiDC,YAAjD,EAAiF;AACpF,MAAMC,kBAAkB,aAAMP,UAAN,cAAoBrD,SAAS,CAAC0D,aAAD,CAA7B,CAAxB;;AAEA,MAAIC,YAAJ,EAAkB;AACd,WAAOC,kBAAkB,CAACC,OAAnB,CAA2BL,mBAA3B,EAAgD,QAAhD,CAAP;AACH;;AACD,SAAOI,kBAAP;AACH;;;;"}
|
|
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;\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":";;;;;;;;;;;;;;;;;;;;;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,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,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;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lightbox.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lightbox.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeRefs.js","sources":["../../../src/utils/mergeRefs.ts"],"sourcesContent":["import { Falsy } from '@lumx/react/utils/type';\nimport { MutableRefObject
|
|
1
|
+
{"version":3,"file":"mergeRefs.js","sources":["../../../src/utils/mergeRefs.ts"],"sourcesContent":["import { Falsy } from '@lumx/react/utils/type';\nimport { MutableRefObject } from 'react';\n\ntype FnRef<T> = (value: T) => void;\n\n/**\n * Merge refs into a single function ref.\n *\n * @param refs React references to merge.\n * @return the merged ref.\n */\nexport function mergeRefs<T>(...refs: Array<MutableRefObject<T | null> | FnRef<T> | Falsy>): FnRef<T> {\n return (value) =>\n refs.forEach((ref) => {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref) {\n // eslint-disable-next-line no-param-reassign\n (ref as MutableRefObject<T>).current = value;\n }\n });\n}\n"],"names":["mergeRefs","refs","value","forEach","ref","current"],"mappings":"AAKA;;;;;;AAMO,SAASA,SAAT,GAA+F;AAAA,oCAAtEC,IAAsE;AAAtEA,IAAAA,IAAsE;AAAA;;AAClG,SAAO,UAACC,KAAD;AAAA,WACHD,IAAI,CAACE,OAAL,CAAa,UAACC,GAAD,EAAS;AAClB,UAAI,OAAOA,GAAP,KAAe,UAAnB,EAA+B;AAC3BA,QAAAA,GAAG,CAACF,KAAD,CAAH;AACH,OAFD,MAEO,IAAIE,GAAJ,EAAS;AACZ;AACCA,QAAAA,GAAD,CAA6BC,OAA7B,GAAuCH,KAAvC;AACH;AACJ,KAPD,CADG;AAAA,GAAP;AASH;;;;"}
|
package/esm/_internal/select.js
CHANGED
|
@@ -27,5 +27,4 @@ import './InputHelper.js';
|
|
|
27
27
|
import './InputLabel.js';
|
|
28
28
|
export { a as Select, c as SelectMultiple, b as SelectMultipleField, S as SelectVariant } from './SelectMultiple.js';
|
|
29
29
|
import './Tooltip2.js';
|
|
30
|
-
import 'lodash/debounce';
|
|
31
30
|
//# sourceMappingURL=select.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"select.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"side-navigation.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"side-navigation.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -21,6 +21,6 @@ import 'react-dom';
|
|
|
21
21
|
import './ClickAwayProvider.js';
|
|
22
22
|
import 'lodash/pull';
|
|
23
23
|
export { S as Slideshow, b as SlideshowControls, a as SlideshowItem } from './SlideshowControls.js';
|
|
24
|
+
import 'lodash/uniqueId';
|
|
24
25
|
import './Tooltip2.js';
|
|
25
|
-
import 'lodash/debounce';
|
|
26
26
|
//# sourceMappingURL=slideshow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-field.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"text-field.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
|
package/esm/_internal/tooltip.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tooltip.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRovingTabIndex.js","sources":["../../../src/components/tabs/state.ts","../../../src/hooks/useRovingTabIndex.tsx"],"sourcesContent":["import { Dispatch, createContext, useCallback, useContext, useEffect, useMemo } from 'react';\nimport { clamp } from '@lumx/react/utils/clamp';\nimport { uid } from 'uid';\n\ntype TabType = 'tab' | 'tabPanel';\n\nexport interface State {\n isLazy: boolean;\n shouldActivateOnFocus: boolean;\n activeTabIndex: number;\n ids: Record<TabType, string[]>;\n}\n\nexport const INIT_STATE: State = {\n isLazy: true,\n shouldActivateOnFocus: false,\n activeTabIndex: 0,\n ids: { tab: [], tabPanel: [] },\n};\n\nexport type Action =\n | { type: 'update'; payload: Partial<State> }\n | { type: 'setActiveTabIndex'; payload: number }\n | { type: 'register'; payload: { type: TabType; id: string } }\n | { type: 'unregister'; payload: { type: TabType; id: string } };\n\nexport const reducer = (state: State, action: Action): State => {\n switch (action.type) {\n case 'update':\n return { ...state, ...action.payload };\n case 'setActiveTabIndex': {\n if (state.activeTabIndex === action.payload) {\n return state;\n }\n // Change active tab index.\n return { ...state, activeTabIndex: action.payload };\n }\n case 'register': {\n const { type, id } = action.payload;\n // Append tab/tabPanel id in state.\n return { ...state, ids: { ...state.ids, [type]: [...state.ids[type], id] } };\n }\n case 'unregister': {\n const { type, id } = action.payload;\n const index = state.ids[type].indexOf(id);\n if (index === -1) return state;\n // Remove tab & tab panel at index.\n const tabIds = [...state.ids.tab];\n tabIds.splice(index, 1);\n const tabPanelIds = [...state.ids.tabPanel];\n tabPanelIds.splice(index, 1);\n return {\n ...state,\n ids: { tab: tabIds, tabPanel: tabPanelIds },\n };\n }\n default:\n return state;\n }\n};\n\nexport const TabProviderContext = createContext<[State, Dispatch<Action>] | null>(null);\n\nexport type TabState = Pick<Required<State>, 'isLazy' | 'shouldActivateOnFocus'> & {\n isActive: boolean;\n tabId: string;\n tabPanelId: string;\n changeToTab(): void;\n};\n\n/* eslint-disable react-hooks/rules-of-hooks */\nexport const useTabProviderContext = (type: TabType, originalId?: string): undefined | TabState => {\n const context = useContext(TabProviderContext);\n if (!context) {\n return undefined;\n }\n const [state, dispatch] = context;\n\n // Current tab or tab panel id.\n const id = useMemo(\n () => originalId || `${type}-${uid()}`,\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n useEffect(\n () => {\n // On mount: register tab or tab panel id.\n dispatch({ type: 'register', payload: { type, id } });\n return () => {\n // On unmount: unregister tab or tab panel id.\n dispatch({ type: 'unregister', payload: { type, id } });\n };\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n\n // Find tab/tabPanel index using it's id.\n const index = useMemo(() => state.ids[type].indexOf(id), [state.ids, type, id]);\n const tabId = useMemo(() => state.ids.tab[index] || '', [state, index]);\n const tabPanelId = useMemo(() => state.ids.tabPanel[index] || '', [state, index]);\n const isActive = useMemo(() => state.activeTabIndex === index, [state, index]);\n const changeToTab = useCallback(() => dispatch({ type: 'setActiveTabIndex', payload: index }), [dispatch, index]);\n return {\n isLazy: state.isLazy,\n shouldActivateOnFocus: state.shouldActivateOnFocus,\n tabId,\n tabPanelId,\n isActive,\n changeToTab,\n };\n};\n\nexport const useTabProviderContextState = (): State | undefined => {\n const context = useContext(TabProviderContext);\n return context?.[0];\n};\n","import { RefObject, useEffect } from 'react';\n\ninterface UseRovingTabIndexOptions {\n parentRef: RefObject<HTMLElement>;\n elementSelector: string;\n keepTabIndex?: boolean;\n /** List of values to be used as extra dependencies of the useEffect */\n extraDependencies?: any[];\n}\n\nexport const useRovingTabIndex = ({\n parentRef,\n elementSelector,\n keepTabIndex,\n extraDependencies = [],\n}: UseRovingTabIndexOptions): void => {\n useEffect(\n () => {\n const parent = parentRef?.current;\n if (!parent) {\n return undefined;\n }\n\n const elements = parent.querySelectorAll(elementSelector) as NodeListOf<HTMLElement>;\n const initialFocusableElement = parent?.querySelector(`${elementSelector}[tabindex=\"0\"]`);\n\n const handleKeyDown = (index: number) => (evt: KeyboardEvent) => {\n let newTabFocus = index;\n if (!(evt.key === 'ArrowRight' || evt.key === 'ArrowLeft')) {\n return;\n }\n\n if (evt.key === 'ArrowRight') {\n // Move right\n newTabFocus += 1;\n // If we're at the end, go to the start\n if (newTabFocus >= elements.length) {\n newTabFocus = 0;\n }\n } else if (evt.key === 'ArrowLeft') {\n // Move left\n newTabFocus -= 1;\n if (newTabFocus < 0) {\n // If we're at the start, move to the end\n newTabFocus = elements.length - 1;\n }\n }\n const newElement = elements[newTabFocus];\n newElement?.focus();\n if (keepTabIndex) {\n (evt.currentTarget as HTMLElement).setAttribute('tabindex', '-1');\n newElement?.setAttribute('tabindex', '0');\n }\n };\n\n if (elements?.length > 0) {\n elements.forEach((el, key) => {\n // if no element has tabindex set to 0, set the first element as focusable\n if (!initialFocusableElement && key === 0) {\n el.setAttribute('tabindex', '0');\n // set all other to -1\n } else if (initialFocusableElement !== el) {\n el.setAttribute('tabindex', '-1');\n }\n // add event listener\n el.addEventListener('keydown', handleKeyDown(key) as EventListener);\n });\n }\n\n // Cleanup listeners\n return () => {\n if (elements?.length > 0) {\n elements.forEach((el, key) => {\n el.removeEventListener('keydown', handleKeyDown(key) as EventListener);\n });\n }\n };\n }, // eslint-disable-next-line react-hooks/exhaustive-deps\n [parentRef, ...extraDependencies],\n );\n};\n"],"names":["INIT_STATE","isLazy","shouldActivateOnFocus","activeTabIndex","ids","tab","tabPanel","reducer","state","action","type","payload","id","index","indexOf","tabIds","splice","tabPanelIds","TabProviderContext","createContext","useTabProviderContext","originalId","context","useContext","undefined","dispatch","useMemo","uid","useEffect","tabId","tabPanelId","isActive","changeToTab","useCallback","useTabProviderContextState","useRovingTabIndex","parentRef","elementSelector","keepTabIndex","extraDependencies","parent","current","elements","querySelectorAll","initialFocusableElement","querySelector","handleKeyDown","evt","newTabFocus","key","length","newElement","focus","currentTarget","setAttribute","forEach","el","addEventListener","removeEventListener"],"mappings":";;;;IAaaA,UAAiB,GAAG;AAC7BC,EAAAA,MAAM,EAAE,IADqB;AAE7BC,EAAAA,qBAAqB,EAAE,KAFM;AAG7BC,EAAAA,cAAc,EAAE,CAHa;AAI7BC,EAAAA,GAAG,EAAE;AAAEC,IAAAA,GAAG,EAAE,EAAP;AAAWC,IAAAA,QAAQ,EAAE;AAArB;AAJwB;IAapBC,OAAO,GAAG,SAAVA,OAAU,CAACC,KAAD,EAAeC,MAAf,EAAyC;AAC5D,UAAQA,MAAM,CAACC,IAAf;AACI,SAAK,QAAL;AACI,gCAAYF,KAAZ,MAAsBC,MAAM,CAACE,OAA7B;;AACJ,SAAK,mBAAL;AAA0B;AACtB,YAAIH,KAAK,CAACL,cAAN,KAAyBM,MAAM,CAACE,OAApC,EAA6C;AACzC,iBAAOH,KAAP;AACH,SAHqB;;;AAKtB,kCAAYA,KAAZ;AAAmBL,UAAAA,cAAc,EAAEM,MAAM,CAACE;AAA1C;AACH;;AACD,SAAK,UAAL;AAAiB;AAAA,8BACQF,MAAM,CAACE,OADf;AAAA,YACLD,IADK,mBACLA,IADK;AAAA,YACCE,EADD,mBACCA,EADD;;AAGb,kCAAYJ,KAAZ;AAAmBJ,UAAAA,GAAG,qBAAOI,KAAK,CAACJ,GAAb,sBAAmBM,IAAnB,+BAA8BF,KAAK,CAACJ,GAAN,CAAUM,IAAV,CAA9B,IAA+CE,EAA/C;AAAtB;AACH;;AACD,SAAK,YAAL;AAAmB;AAAA,+BACMH,MAAM,CAACE,OADb;AAAA,YACPD,KADO,oBACPA,IADO;AAAA,YACDE,GADC,oBACDA,EADC;;AAEf,YAAMC,KAAK,GA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QAAQ,SAAR,IAAAA,QAAQ,WAAR,YAAAA,QAAQ,CAAEQ,MAAV,IAAmB,CAAvB,EAA0B;AACtBR,QAAAA,QAAQ,CAACa,OAAT,CAAiB,UAACC,EAAD,EAAKP,GAAL,EAAa;AAC1BO,UAAAA,EAAE,CAACE,mBAAH,CAAuB,SAAvB,EAAkCZ,aAAa,CAACG,GAAD,CAA/C;AACH,SAFD;AAGH;AACJ,KAND;AAOH,GA7DI;AAAA,GA8DJb,SA9DI,4BA8DUG,iBA9DV,GAAT;AAgEH;;;;"}
|
|
1
|
+
{"version":3,"file":"useRovingTabIndex.js","sources":["../../../src/components/tabs/state.ts","../../../src/hooks/useRovingTabIndex.tsx"],"sourcesContent":["import { Dispatch, createContext, useCallback, useContext, useEffect, useMemo } from 'react';\nimport { uid } from 'uid';\n\ntype TabType = 'tab' | 'tabPanel';\n\nexport interface State {\n isLazy: boolean;\n shouldActivateOnFocus: boolean;\n activeTabIndex: number;\n ids: Record<TabType, string[]>;\n}\n\nexport const INIT_STATE: State = {\n isLazy: true,\n shouldActivateOnFocus: false,\n activeTabIndex: 0,\n ids: { tab: [], tabPanel: [] },\n};\n\nexport type Action =\n | { type: 'update'; payload: Partial<State> }\n | { type: 'setActiveTabIndex'; payload: number }\n | { type: 'register'; payload: { type: TabType; id: string } }\n | { type: 'unregister'; payload: { type: TabType; id: string } };\n\nexport const reducer = (state: State, action: Action): State => {\n switch (action.type) {\n case 'update':\n return { ...state, ...action.payload };\n case 'setActiveTabIndex': {\n if (state.activeTabIndex === action.payload) {\n return state;\n }\n // Change active tab index.\n return { ...state, activeTabIndex: action.payload };\n }\n case 'register': {\n const { type, id } = action.payload;\n // Append tab/tabPanel id in state.\n return { ...state, ids: { ...state.ids, [type]: [...state.ids[type], id] } };\n }\n case 'unregister': {\n const { type, id } = action.payload;\n const index = state.ids[type].indexOf(id);\n if (index === -1) return state;\n // Remove tab & tab panel at index.\n const tabIds = [...state.ids.tab];\n tabIds.splice(index, 1);\n const tabPanelIds = [...state.ids.tabPanel];\n tabPanelIds.splice(index, 1);\n return {\n ...state,\n ids: { tab: tabIds, tabPanel: tabPanelIds },\n };\n }\n default:\n return state;\n }\n};\n\nexport const TabProviderContext = createContext<[State, Dispatch<Action>] | null>(null);\n\nexport type TabState = Pick<Required<State>, 'isLazy' | 'shouldActivateOnFocus'> & {\n isActive: boolean;\n tabId: string;\n tabPanelId: string;\n changeToTab(): void;\n};\n\n/* eslint-disable react-hooks/rules-of-hooks */\nexport const useTabProviderContext = (type: TabType, originalId?: string): undefined | TabState => {\n const context = useContext(TabProviderContext);\n if (!context) {\n return undefined;\n }\n const [state, dispatch] = context;\n\n // Current tab or tab panel id.\n const id = useMemo(\n () => originalId || `${type}-${uid()}`,\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n useEffect(\n () => {\n // On mount: register tab or tab panel id.\n dispatch({ type: 'register', payload: { type, id } });\n return () => {\n // On unmount: unregister tab or tab panel id.\n dispatch({ type: 'unregister', payload: { type, id } });\n };\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n\n // Find tab/tabPanel index using it's id.\n const index = useMemo(() => state.ids[type].indexOf(id), [state.ids, type, id]);\n const tabId = useMemo(() => state.ids.tab[index] || '', [state, index]);\n const tabPanelId = useMemo(() => state.ids.tabPanel[index] || '', [state, index]);\n const isActive = useMemo(() => state.activeTabIndex === index, [state, index]);\n const changeToTab = useCallback(() => dispatch({ type: 'setActiveTabIndex', payload: index }), [dispatch, index]);\n return {\n isLazy: state.isLazy,\n shouldActivateOnFocus: state.shouldActivateOnFocus,\n tabId,\n tabPanelId,\n isActive,\n changeToTab,\n };\n};\n\nexport const useTabProviderContextState = (): State | undefined => {\n const context = useContext(TabProviderContext);\n return context?.[0];\n};\n","import { RefObject, useEffect } from 'react';\n\ninterface UseRovingTabIndexOptions {\n parentRef: RefObject<HTMLElement>;\n elementSelector: string;\n keepTabIndex?: boolean;\n /** List of values to be used as extra dependencies of the useEffect */\n extraDependencies?: any[];\n}\n\nexport const useRovingTabIndex = ({\n parentRef,\n elementSelector,\n keepTabIndex,\n extraDependencies = [],\n}: UseRovingTabIndexOptions): void => {\n useEffect(\n () => {\n const parent = parentRef?.current;\n if (!parent) {\n return undefined;\n }\n\n const elements = parent.querySelectorAll(elementSelector) as NodeListOf<HTMLElement>;\n const initialFocusableElement = parent?.querySelector(`${elementSelector}[tabindex=\"0\"]`);\n\n const handleKeyDown = (index: number) => (evt: KeyboardEvent) => {\n let newTabFocus = index;\n if (!(evt.key === 'ArrowRight' || evt.key === 'ArrowLeft')) {\n return;\n }\n\n if (evt.key === 'ArrowRight') {\n // Move right\n newTabFocus += 1;\n // If we're at the end, go to the start\n if (newTabFocus >= elements.length) {\n newTabFocus = 0;\n }\n } else if (evt.key === 'ArrowLeft') {\n // Move left\n newTabFocus -= 1;\n if (newTabFocus < 0) {\n // If we're at the start, move to the end\n newTabFocus = elements.length - 1;\n }\n }\n const newElement = elements[newTabFocus];\n newElement?.focus();\n if (keepTabIndex) {\n (evt.currentTarget as HTMLElement).setAttribute('tabindex', '-1');\n newElement?.setAttribute('tabindex', '0');\n }\n };\n\n if (elements?.length > 0) {\n elements.forEach((el, key) => {\n // if no element has tabindex set to 0, set the first element as focusable\n if (!initialFocusableElement && key === 0) {\n el.setAttribute('tabindex', '0');\n // set all other to -1\n } else if (initialFocusableElement !== el) {\n el.setAttribute('tabindex', '-1');\n }\n // add event listener\n el.addEventListener('keydown', handleKeyDown(key) as EventListener);\n });\n }\n\n // Cleanup listeners\n return () => {\n if (elements?.length > 0) {\n elements.forEach((el, key) => {\n el.removeEventListener('keydown', handleKeyDown(key) as EventListener);\n });\n }\n };\n }, // eslint-disable-next-line react-hooks/exhaustive-deps\n [parentRef, ...extraDependencies],\n );\n};\n"],"names":["INIT_STATE","isLazy","shouldActivateOnFocus","activeTabIndex","ids","tab","tabPanel","reducer","state","action","type","payload","id","index","indexOf","tabIds","splice","tabPanelIds","TabProviderContext","createContext","useTabProviderContext","originalId","context","useContext","undefined","dispatch","useMemo","uid","useEffect","tabId","tabPanelId","isActive","changeToTab","useCallback","useTabProviderContextState","useRovingTabIndex","parentRef","elementSelector","keepTabIndex","extraDependencies","parent","current","elements","querySelectorAll","initialFocusableElement","querySelector","handleKeyDown","evt","newTabFocus","key","length","newElement","focus","currentTarget","setAttribute","forEach","el","addEventListener","removeEventListener"],"mappings":";;;;IAYaA,UAAiB,GAAG;AAC7BC,EAAAA,MAAM,EAAE,IADqB;AAE7BC,EAAAA,qBAAqB,EAAE,KAFM;AAG7BC,EAAAA,cAAc,EAAE,CAHa;AAI7BC,EAAAA,GAAG,EAAE;AAAEC,IAAAA,GAAG,EAAE,EAAP;AAAWC,IAAAA,QAAQ,EAAE;AAArB;AAJwB;IAapBC,OAAO,GAAG,SAAVA,OAAU,CAACC,KAAD,EAAeC,MAAf,EAAyC;AAC5D,UAAQA,MAAM,CAACC,IAAf;AACI,SAAK,QAAL;AACI,gCAAYF,KAAZ,MAAsBC,MAAM,CAACE,OAA7B;;AACJ,SAAK,mBAAL;AAA0B;AACtB,YAAIH,KAAK,CAACL,cAAN,KAAyBM,MAAM,CAACE,OAApC,EAA6C;AACzC,iBAAOH,KAAP;AACH,SAHqB;;;AAKtB,kCAAYA,KAAZ;AAAmBL,UAAAA,cAAc,EAAEM,MAAM,CAACE;AAA1C;AACH;;AACD,SAAK,UAAL;AAAiB;AAAA,8BACQF,MAAM,CAACE,OADf;AAAA,YACLD,IADK,mBACLA,IADK;AAAA,YACCE,EADD,mBACCA,EADD;;AAGb,kCAAYJ,KAAZ;AAAmBJ,UAAAA,GAAG,qBAAOI,KAAK,CAACJ,GAAb,sBAAmBM,IAAnB,+BAA8BF,KAAK,CAACJ,GAAN,CAAUM,IAAV,CAA9B,IAA+CE,EAA/C;AAAtB;AACH;;AACD,SAAK,YAAL;AAAmB;AAAA,+BACMH,MAAM,CAACE,OADb;AAAA,YACPD,KADO,oBACPA,IADO;AAAA,YACDE,GADC,oBACDA,EADC;;A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M;AACT,UAAI,CAAAP,QAAQ,SAAR,IAAAA,QAAQ,WAAR,YAAAA,QAAQ,CAAEQ,MAAV,IAAmB,CAAvB,EAA0B;AACtBR,QAAAA,QAAQ,CAACa,OAAT,CAAiB,UAACC,EAAD,EAAKP,GAAL,EAAa;AAC1BO,UAAAA,EAAE,CAACE,mBAAH,CAAuB,SAAvB,EAAkCZ,aAAa,CAACG,GAAD,CAA/C;AACH,SAFD;AAGH;AACJ,KAND;AAOH,GA7DI;AAAA,GA8DJb,SA9DI,4BA8DUG,iBA9DV,GAAT;AAgEH;;;;"}
|
package/esm/index.js
CHANGED
|
@@ -75,6 +75,7 @@ export { S as SideNavigation, a as SideNavigationItem } from './_internal/SideNa
|
|
|
75
75
|
export { S as SkeletonCircle, b as SkeletonRectangle, a as SkeletonRectangleVariant, c as SkeletonTypography } from './_internal/SkeletonTypography.js';
|
|
76
76
|
export { S as Slider, c as clamp } from './_internal/Slider2.js';
|
|
77
77
|
export { S as Slideshow, b as SlideshowControls, a as SlideshowItem } from './_internal/SlideshowControls.js';
|
|
78
|
+
import 'lodash/uniqueId';
|
|
78
79
|
export { S as Switch } from './_internal/Switch2.js';
|
|
79
80
|
export { T as Table, a as TableBody, d as TableCell, c as TableCellVariant, e as TableHeader, f as TableRow, b as ThOrder } from './_internal/TableRow.js';
|
|
80
81
|
export { c as Tab, b as TabList, a as TabListLayout, d as TabPanel, T as TabProvider } from './_internal/TabPanel.js';
|
|
@@ -83,7 +84,6 @@ export { T as Thumbnail, u as useFocusPointStyle } from './_internal/Thumbnail2.
|
|
|
83
84
|
export { T as ThumbnailAspectRatio, a as ThumbnailVariant } from './_internal/types.js';
|
|
84
85
|
export { T as Toolbar } from './_internal/Toolbar2.js';
|
|
85
86
|
export { T as Tooltip } from './_internal/Tooltip2.js';
|
|
86
|
-
import 'lodash/debounce';
|
|
87
87
|
export { a as Uploader, U as UploaderVariant } from './_internal/Uploader2.js';
|
|
88
88
|
export { U as UserBlock } from './_internal/UserBlock.js';
|
|
89
89
|
//# sourceMappingURL=index.js.map
|
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.8",
|
|
11
|
+
"@lumx/icons": "^2.2.8",
|
|
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.8",
|
|
124
|
+
"gitHead": "9c235120d0b26f0d06544dcbf161558a858a205c"
|
|
125
125
|
}
|
|
@@ -18,6 +18,7 @@ const setup = ({ ...propsOverride }: Partial<AlertDialogProps> = {}, shallowRend
|
|
|
18
18
|
const props: AlertDialogProps = {
|
|
19
19
|
title: 'Alert',
|
|
20
20
|
description: 'Deserunt et sunt qui consequat sint sit.',
|
|
21
|
+
// eslint-disable-next-line no-alert
|
|
21
22
|
confirmProps: { onClick: () => alert('confirm'), label: 'OK' },
|
|
22
23
|
...propsOverride,
|
|
23
24
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mdiClose } from '@lumx/icons';
|
|
2
|
-
import { Autocomplete, AutocompleteProps, Chip,
|
|
2
|
+
import { Autocomplete, AutocompleteProps, Chip, HorizontalAlignment, Icon, Size } from '@lumx/react';
|
|
3
3
|
|
|
4
4
|
import { Comp, getRootClassName, handleBasicClasses } from '@lumx/react/utils';
|
|
5
5
|
|
|
@@ -68,6 +68,8 @@ export const AutocompleteMultiple: Comp<AutocompleteMultipleProps, HTMLDivElemen
|
|
|
68
68
|
const {
|
|
69
69
|
anchorToInput,
|
|
70
70
|
children,
|
|
71
|
+
// `chipsAlignment` needs to be here to remove it from `forwardedProps`.
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
71
73
|
chipsAlignment,
|
|
72
74
|
className,
|
|
73
75
|
closeOnClickAway,
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`<IconButton> Props should forward any CSS class 1`] = `
|
|
4
4
|
<Tooltip
|
|
5
|
-
delay={500}
|
|
6
5
|
placement="bottom"
|
|
7
6
|
>
|
|
8
7
|
<ButtonRoot
|
|
@@ -19,7 +18,6 @@ exports[`<IconButton> Props should forward any CSS class 1`] = `
|
|
|
19
18
|
|
|
20
19
|
exports[`<IconButton> Props should use default props 1`] = `
|
|
21
20
|
<Tooltip
|
|
22
|
-
delay={500}
|
|
23
21
|
placement="bottom"
|
|
24
22
|
>
|
|
25
23
|
<ButtonRoot
|
|
@@ -35,7 +33,6 @@ exports[`<IconButton> Props should use default props 1`] = `
|
|
|
35
33
|
|
|
36
34
|
exports[`<IconButton> Snapshots and structure should render icon button 1`] = `
|
|
37
35
|
<Tooltip
|
|
38
|
-
delay={500}
|
|
39
36
|
placement="bottom"
|
|
40
37
|
>
|
|
41
38
|
<ButtonRoot
|
|
@@ -51,7 +48,6 @@ exports[`<IconButton> Snapshots and structure should render icon button 1`] = `
|
|
|
51
48
|
|
|
52
49
|
exports[`<IconButton> Snapshots and structure should render icon button with an image 1`] = `
|
|
53
50
|
<Tooltip
|
|
54
|
-
delay={500}
|
|
55
51
|
placement="bottom"
|
|
56
52
|
>
|
|
57
53
|
<ButtonRoot
|
|
@@ -70,7 +66,6 @@ exports[`<IconButton> Snapshots and structure should render icon button with an
|
|
|
70
66
|
|
|
71
67
|
exports[`<IconButton> Snapshots and structure should render icon button with an image if both props are set 1`] = `
|
|
72
68
|
<Tooltip
|
|
73
|
-
delay={500}
|
|
74
69
|
placement="bottom"
|
|
75
70
|
>
|
|
76
71
|
<ButtonRoot
|
|
@@ -27,6 +27,8 @@ export interface IconProps extends GenericProps {
|
|
|
27
27
|
size?: IconSizes;
|
|
28
28
|
/** Theme adapting the component to light or dark background. */
|
|
29
29
|
theme?: Theme;
|
|
30
|
+
/** Sets an alternative text on the svg. Will set an `img` role to the svg. */
|
|
31
|
+
alt?: string;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
/**
|
|
@@ -52,7 +54,7 @@ const DEFAULT_PROPS: Partial<IconProps> = {};
|
|
|
52
54
|
* @return React element.
|
|
53
55
|
*/
|
|
54
56
|
export const Icon: Comp<IconProps, HTMLElement> = forwardRef((props, ref) => {
|
|
55
|
-
const { className, color, colorVariant, hasShape, icon, size, theme, ...forwardedProps } = props;
|
|
57
|
+
const { className, color, colorVariant, hasShape, icon, size, theme, alt, ...forwardedProps } = props;
|
|
56
58
|
|
|
57
59
|
let iconColor;
|
|
58
60
|
let iconColorVariant;
|
|
@@ -110,7 +112,9 @@ export const Icon: Comp<IconProps, HTMLElement> = forwardRef((props, ref) => {
|
|
|
110
112
|
)}
|
|
111
113
|
>
|
|
112
114
|
<svg
|
|
113
|
-
aria-hidden=
|
|
115
|
+
aria-hidden={alt ? undefined : 'true'}
|
|
116
|
+
role={alt ? 'img' : undefined}
|
|
117
|
+
aria-label={alt}
|
|
114
118
|
height="1em"
|
|
115
119
|
preserveAspectRatio="xMidYMid meet"
|
|
116
120
|
style={{ verticalAlign: '-0.125em' }}
|
|
@@ -2,7 +2,6 @@ import { LANDSCAPE_IMAGES, landscapeImageKnob } from '@lumx/react/stories/knobs/
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
4
|
import { Alignment, AspectRatio, Chip, ChipGroup, ImageBlock, Size } from '@lumx/react';
|
|
5
|
-
import { htmlDecode } from '@lumx/react/utils/htmlDecode';
|
|
6
5
|
import { boolean, select, text } from '@storybook/addon-knobs';
|
|
7
6
|
import { enumKnob } from '@lumx/react/stories/knobs/enumKnob';
|
|
8
7
|
import { focusKnob } from '@lumx/react/stories/knobs/focusKnob';
|
|
@@ -36,7 +35,7 @@ export const DefaultImageBlock = ({ theme }: any) => {
|
|
|
36
35
|
<ImageBlock
|
|
37
36
|
alt={alt}
|
|
38
37
|
description={description}
|
|
39
|
-
image={
|
|
38
|
+
image={imageUrl}
|
|
40
39
|
size={size}
|
|
41
40
|
tags={tags}
|
|
42
41
|
title={title}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef, RefObject, useRef } from 'react';
|
|
1
|
+
import React, { forwardRef, RefObject, useRef, useEffect } from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
@@ -89,9 +89,11 @@ export const Lightbox: Comp<LightboxProps, HTMLDivElement> = forwardRef((props,
|
|
|
89
89
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
90
90
|
useFocusTrap(wrapperRef.current, childrenRef.current?.firstChild);
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
93
|
+
const previousOpen = useRef(isOpen);
|
|
93
94
|
|
|
94
|
-
|
|
95
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
96
|
+
useEffect(() => {
|
|
95
97
|
if (isOpen !== previousOpen.current) {
|
|
96
98
|
previousOpen.current = isOpen;
|
|
97
99
|
|
|
@@ -6,7 +6,6 @@ import { mdiAlertCircle, mdiCheckCircle, mdiClose, mdiCloseCircle, mdiMenuDown }
|
|
|
6
6
|
|
|
7
7
|
import { Size } from '@lumx/react/components';
|
|
8
8
|
import { Chip } from '@lumx/react/components/chip/Chip';
|
|
9
|
-
import { ChipGroup } from '@lumx/react/components/chip/ChipGroup';
|
|
10
9
|
import { Icon } from '@lumx/react/components/icon/Icon';
|
|
11
10
|
import { InputLabel } from '@lumx/react/components/input-label/InputLabel';
|
|
12
11
|
|
|
@@ -29,7 +29,7 @@ export const Simple = ({ theme }: any) => {
|
|
|
29
29
|
{images.map(({ image, alt }, index) => (
|
|
30
30
|
<SlideshowItem key={`${image}-${index}`}>
|
|
31
31
|
<ImageBlock
|
|
32
|
-
thumbnailProps={{ aspectRatio: AspectRatio.horizontal }}
|
|
32
|
+
thumbnailProps={{ aspectRatio: AspectRatio.horizontal, loading: 'eager' }}
|
|
33
33
|
image={image}
|
|
34
34
|
alt={alt}
|
|
35
35
|
theme={theme}
|