@lumx/react 2.2.14 → 2.2.17

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.
@@ -1 +1 @@
1
- {"version":3,"file":"FlexBox.js","sources":["../../../src/components/flex-box/FlexBox.tsx"],"sourcesContent":["import { Alignment, HorizontalAlignment, Orientation, VerticalAlignment } from '@lumx/react';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\nimport classNames from 'classnames';\nimport castArray from 'lodash/castArray';\nimport React, { forwardRef, ReactNode } from 'react';\nimport { Size } from '..';\n\nexport type MarginAutoAlignment = Extract<Alignment, 'top' | 'bottom' | 'right' | 'left'>;\nexport type GapSize = Extract<Size, 'regular' | 'big' | 'huge'>;\n\n/**\n * Defines the props of the component.\n */\nexport interface FlexBoxProps extends GenericProps {\n /** Children elements. */\n children?: ReactNode;\n /** Whether the \"content filling space\" is enabled or not. */\n fillSpace?: boolean;\n /** Gap space between flexbox items. */\n gap?: GapSize;\n /** Flex horizontal alignment. */\n hAlign?: VerticalAlignment;\n /** Whether the \"auto margin\" is enabled all around or not. */\n marginAuto?: MarginAutoAlignment | MarginAutoAlignment[];\n /** Whether the \"content shrink\" is disabled or not. */\n noShrink?: boolean;\n /** Flex direction. */\n orientation?: Orientation;\n /** Flex vertical alignment. */\n vAlign?: HorizontalAlignment;\n /** Whether the \"flex wrap\" is enabled or not. */\n wrap?: boolean;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'FlexBox';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * FlexBox component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const FlexBox: Comp<FlexBoxProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n children,\n className,\n fillSpace,\n gap,\n hAlign,\n marginAuto,\n noShrink,\n orientation,\n vAlign,\n wrap,\n ...forwardedProps\n } = props;\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(\n className,\n handleBasicClasses({\n prefix: CLASSNAME,\n orientation: orientation ?? (wrap || hAlign || vAlign ? Orientation.horizontal : null),\n vAlign,\n hAlign,\n gap,\n }),\n wrap && `${CLASSNAME}--wrap`,\n fillSpace && `${CLASSNAME}--fill-space`,\n noShrink && `${CLASSNAME}--no-shrink`,\n marginAuto && castArray(marginAuto).map((align) => `${CLASSNAME}--margin-auto-${align}`),\n )}\n >\n {children}\n </div>\n );\n});\nFlexBox.displayName = COMPONENT_NAME;\nFlexBox.className = CLASSNAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","FlexBox","forwardRef","props","ref","children","className","fillSpace","gap","hAlign","marginAuto","noShrink","orientation","vAlign","wrap","forwardedProps","classNames","handleBasicClasses","prefix","Orientation","horizontal","castArray","map","align","displayName"],"mappings":";;;;;;AAkCA;;;AAGA,IAAMA,cAAc,GAAG,SAAvB;AAEA;;;;AAGA,IAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAD,CAAlC;AAEA;;;;;;;;IAOaG,OAA2C,GAAGC,UAAU,CAAC,UAACC,KAAD,EAAQC,GAAR,EAAgB;AAAA,MAE9EC,QAF8E,GAa9EF,KAb8E,CAE9EE,QAF8E;AAAA,MAG9EC,SAH8E,GAa9EH,KAb8E,CAG9EG,SAH8E;AAAA,MAI9EC,SAJ8E,GAa9EJ,KAb8E,CAI9EI,SAJ8E;AAAA,MAK9EC,GAL8E,GAa9EL,KAb8E,CAK9EK,GAL8E;AAAA,MAM9EC,MAN8E,GAa9EN,KAb8E,CAM9EM,MAN8E;AAAA,MAO9EC,UAP8E,GAa9EP,KAb8E,CAO9EO,UAP8E;AAAA,MAQ9EC,QAR8E,GAa9ER,KAb8E,CAQ9EQ,QAR8E;AAAA,MAS9EC,WAT8E,GAa9ET,KAb8E,CAS9ES,WAT8E;AAAA,MAU9EC,MAV8E,GAa9EV,KAb8E,CAU9EU,MAV8E;AAAA,MAW9EC,IAX8E,GAa9EX,KAb8E,CAW9EW,IAX8E;AAAA,MAY3EC,cAZ2E,4BAa9EZ,KAb8E;;AAelF,SACI;AACI,IAAA,GAAG,EAAEC;AADT,KAEQW,cAFR;AAGI,IAAA,SAAS,EAAEC,UAAU,CACjBV,SADiB,EAEjBW,kBAAkB,CAAC;AACfC,MAAAA,MAAM,EAAEnB,SADO;AAEfa,MAAAA,WAAW,EAAEA,WAAF,aAAEA,WAAF,cAAEA,WAAF,GAAkBE,IAAI,IAAIL,MAAR,IAAkBI,MAAlB,GAA2BM,WAAW,CAACC,UAAvC,GAAoD,IAFlE;AAGfP,MAAAA,MAAM,EAANA,MAHe;AAIfJ,MAAAA,MAAM,EAANA,MAJe;AAKfD,MAAAA,GAAG,EAAHA;AALe,KAAD,CAFD,EASjBM,IAAI,cAAOf,SAAP,WATa,EAUjBQ,SAAS,cAAOR,SAAP,iBAVQ,EAWjBY,QAAQ,cAAOZ,SAAP,gBAXS,EAYjBW,UAAU,IAAIW,SAAS,CAACX,UAAD,CAAT,CAAsBY,GAAtB,CAA0B,UAACC,KAAD;AAAA,uBAAcxB,SAAd,2BAAwCwB,KAAxC;AAAA,KAA1B,CAZG;AAHzB,MAkBKlB,QAlBL,CADJ;AAsBH,CArCoE;AAsCrEJ,OAAO,CAACuB,WAAR,GAAsB1B,cAAtB;AACAG,OAAO,CAACK,SAAR,GAAoBP,SAApB;;;;"}
1
+ {"version":3,"file":"FlexBox.js","sources":["../../../src/components/flex-box/FlexBox.tsx"],"sourcesContent":["import { Alignment, HorizontalAlignment, Orientation, VerticalAlignment } from '@lumx/react';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\nimport classNames from 'classnames';\nimport castArray from 'lodash/castArray';\nimport React, { forwardRef, ReactNode } from 'react';\nimport { Size } from '..';\n\nexport type MarginAutoAlignment = Extract<Alignment, 'top' | 'bottom' | 'right' | 'left'>;\nexport type GapSize = Extract<Size, 'regular' | 'medium' | 'big' | 'huge'>;\n\n/**\n * Defines the props of the component.\n */\nexport interface FlexBoxProps extends GenericProps {\n /** Children elements. */\n children?: ReactNode;\n /** Whether the \"content filling space\" is enabled or not. */\n fillSpace?: boolean;\n /** Gap space between flexbox items. */\n gap?: GapSize;\n /** Flex horizontal alignment. */\n hAlign?: VerticalAlignment;\n /** Whether the \"auto margin\" is enabled all around or not. */\n marginAuto?: MarginAutoAlignment | MarginAutoAlignment[];\n /** Whether the \"content shrink\" is disabled or not. */\n noShrink?: boolean;\n /** Flex direction. */\n orientation?: Orientation;\n /** Flex vertical alignment. */\n vAlign?: HorizontalAlignment;\n /** Whether the \"flex wrap\" is enabled or not. */\n wrap?: boolean;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'FlexBox';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * FlexBox component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const FlexBox: Comp<FlexBoxProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n children,\n className,\n fillSpace,\n gap,\n hAlign,\n marginAuto,\n noShrink,\n orientation,\n vAlign,\n wrap,\n ...forwardedProps\n } = props;\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(\n className,\n handleBasicClasses({\n prefix: CLASSNAME,\n orientation: orientation ?? (wrap || hAlign || vAlign ? Orientation.horizontal : null),\n vAlign,\n hAlign,\n gap,\n }),\n wrap && `${CLASSNAME}--wrap`,\n fillSpace && `${CLASSNAME}--fill-space`,\n noShrink && `${CLASSNAME}--no-shrink`,\n marginAuto && castArray(marginAuto).map((align) => `${CLASSNAME}--margin-auto-${align}`),\n )}\n >\n {children}\n </div>\n );\n});\nFlexBox.displayName = COMPONENT_NAME;\nFlexBox.className = CLASSNAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","FlexBox","forwardRef","props","ref","children","className","fillSpace","gap","hAlign","marginAuto","noShrink","orientation","vAlign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;AALe,KAAD,CAFD,EASjBM,IAAI,cAAOf,SAAP,WATa,EAUjBQ,SAAS,cAAOR,SAAP,iBAVQ,EAWjBY,QAAQ,cAAOZ,SAAP,gBAXS,EAYjBW,UAAU,IAAIW,SAAS,CAACX,UAAD,CAAT,CAAsBY,GAAtB,CAA0B,UAACC,KAAD;AAAA,uBAAcxB,SAAd,2BAAwCwB,KAAxC;AAAA,KAA1B,CAZG;AAHzB,MAkBKlB,QAlBL,CADJ;AAsBH,CArCoE;AAsCrEJ,OAAO,CAACuB,WAAR,GAAsB1B,cAAtB;AACAG,OAAO,CAACK,SAAR,GAAoBP,SAApB;;;;"}
@@ -339,7 +339,9 @@ var SelectMultipleField = function SelectMultipleField(_ref) {
339
339
  selectedValueRender = _ref.selectedValueRender,
340
340
  theme = _ref.theme,
341
341
  value = _ref.value,
342
- variant = _ref.variant;
342
+ variant = _ref.variant,
343
+ forwardedProps = _objectWithoutProperties(_ref, ["anchorRef", "handleKeyboardNav", "hasError", "id", "isDisabled", "isEmpty", "isRequired", "isValid", "label", "onClear", "onInputClick", "placeholder", "selectedChipRender", "selectedValueRender", "theme", "value", "variant"]);
344
+
343
345
  return React.createElement(React.Fragment, null, variant === SelectVariant.input && React.createElement(React.Fragment, null, label && React.createElement("div", {
344
346
  className: "".concat(CLASSNAME$2, "__header")
345
347
  }, React.createElement(InputLabel, {
@@ -347,7 +349,7 @@ var SelectMultipleField = function SelectMultipleField(_ref) {
347
349
  className: "".concat(CLASSNAME$2, "__label"),
348
350
  isRequired: isRequired,
349
351
  theme: theme
350
- }, label)), React.createElement("div", {
352
+ }, label)), React.createElement("div", _extends({
351
353
  ref: anchorRef,
352
354
  id: id,
353
355
  className: "".concat(CLASSNAME$2, "__wrapper"),
@@ -355,7 +357,7 @@ var SelectMultipleField = function SelectMultipleField(_ref) {
355
357
  onKeyDown: handleKeyboardNav,
356
358
  tabIndex: isDisabled ? undefined : 0,
357
359
  "aria-disabled": isDisabled || undefined
358
- }, React.createElement("div", {
360
+ }, forwardedProps), React.createElement("div", {
359
361
  className: "".concat(CLASSNAME$2, "__chips")
360
362
  }, !isEmpty && value.map(function (val, index) {
361
363
  return selectedChipRender === null || selectedChipRender === void 0 ? void 0 : selectedChipRender(val, index, onClear, isDisabled, theme);
@@ -371,7 +373,7 @@ var SelectMultipleField = function SelectMultipleField(_ref) {
371
373
  }, React.createElement(Icon, {
372
374
  icon: mdiMenuDown,
373
375
  size: Size.s
374
- })))), variant === SelectVariant.chip && React.createElement(Chip, {
376
+ })))), variant === SelectVariant.chip && React.createElement(Chip, _extends({
375
377
  id: id,
376
378
  isSelected: !isEmpty,
377
379
  isDisabled: isDisabled,
@@ -382,7 +384,7 @@ var SelectMultipleField = function SelectMultipleField(_ref) {
382
384
  onClick: onInputClick,
383
385
  ref: anchorRef,
384
386
  theme: theme
385
- }, isEmpty && React.createElement("span", null, label), !isEmpty && React.createElement("span", null, React.createElement("span", null, selectedValueRender === null || selectedValueRender === void 0 ? void 0 : selectedValueRender(value[0])), value.length > 1 && React.createElement("span", null, "\xA0+", value.length - 1))));
387
+ }, forwardedProps), isEmpty && React.createElement("span", null, label), !isEmpty && React.createElement("span", null, React.createElement("span", null, selectedValueRender === null || selectedValueRender === void 0 ? void 0 : selectedValueRender(value[0])), value.length > 1 && React.createElement("span", null, "\xA0+", value.length - 1))));
386
388
  };
387
389
  /**
388
390
  * SelectMultiple component.
@@ -1 +1 @@
1
- {"version":3,"file":"SelectMultiple.js","sources":["../../../src/hooks/useListenFocus.tsx","../../../src/components/select/constants.ts","../../../src/components/select/WithSelectContext.tsx","../../../src/components/select/Select.tsx","../../../src/components/select/SelectMultiple.tsx"],"sourcesContent":["import { RefObject, useEffect, useState } from 'react';\n\n/**\n * Listen on element focus to store the focus status.\n */\nexport function useListenFocus(ref: RefObject<HTMLElement>) {\n const [isFocus, setFocus] = useState(false);\n\n useEffect(() => {\n const { current: element } = ref;\n if (!element) {\n return undefined;\n }\n\n const onFocus = () => setFocus(true);\n const onBlur = () => setFocus(false);\n element.addEventListener('focus', onFocus);\n element.addEventListener('blur', onBlur);\n return () => {\n element.removeEventListener('focus', onFocus);\n element.removeEventListener('blur', onBlur);\n };\n }, [ref, setFocus]);\n\n return isFocus;\n}\n","import { IconButtonProps } from '@lumx/react';\nimport { Theme } from '@lumx/react/components';\nimport { GenericProps, ValueOf } from '@lumx/react/utils';\nimport { ReactNode, SyntheticEvent } from 'react';\n\n/**\n * Select variants.\n */\nexport const SelectVariant = { input: 'input', chip: 'chip' } as const;\nexport type SelectVariant = ValueOf<typeof SelectVariant>;\n\nexport interface CoreSelectProps extends GenericProps {\n /** Props to pass to the clear button (minus those already set by the Select props). If not specified, the button won't be displayed. */\n clearButtonProps?: Pick<IconButtonProps, 'label'> &\n Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis'>;\n /** Whether the select (input variant) is displayed with error style or not. */\n hasError?: boolean;\n /** Error message. */\n error?: string | ReactNode;\n /** Helper text. */\n helper?: string;\n /** Whether the select should close on click. */\n closeOnClick?: boolean;\n /** Whether the component is disabled or not. */\n isDisabled?: boolean;\n /** Whether the component is required or not. */\n isRequired?: boolean;\n /** Whether the component is open or not. */\n isOpen?: boolean;\n /** Whether the select (input variant) is displayed with valid style or not. */\n isValid?: boolean;\n /** Label text. */\n label?: string;\n /** Placeholder input text. */\n placeholder?: string;\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** Select variant. */\n variant?: SelectVariant;\n /** On clear callback. */\n onClear?(event: SyntheticEvent, value?: string): void;\n /** On blur callback. */\n onBlur?(): void;\n /** On filter text change callback (with 500ms debounce). */\n onFilter?(): void;\n /** On input click callback (can be used for dropdown toggle). */\n onInputClick?(): void;\n /** On dropdown close callback. */\n onDropdownClose?(): void;\n /** On scroll end callback. */\n onInfiniteScroll?(): void;\n /** Render value function. Default: Renders the value as a string. */\n selectedValueRender?(choice: string): ReactNode | string;\n}\n","import React, { Ref, useCallback, useMemo, useRef } from 'react';\n\nimport classNames from 'classnames';\nimport { uid } from 'uid';\n\nimport { Kind, Theme } from '@lumx/react/components';\nimport { Dropdown } from '@lumx/react/components/dropdown/Dropdown';\nimport { InputHelper } from '@lumx/react/components/input-helper/InputHelper';\nimport { Placement } from '@lumx/react/components/popover/Popover';\n\nimport { getRootClassName, handleBasicClasses } from '@lumx/react/utils';\nimport { mergeRefs } from '@lumx/react/utils/mergeRefs';\nimport { useListenFocus } from '@lumx/react/hooks/useListenFocus';\nimport { CoreSelectProps, SelectVariant } from './constants';\n\n/** The display name of the component. */\nconst COMPONENT_NAME = 'Select';\n\n/** The default class name and classes prefix for this component. */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/** The default value of props. */\nexport const DEFAULT_PROPS: Partial<CoreSelectProps> = {\n theme: Theme.light,\n variant: SelectVariant.input,\n};\n\nexport const WithSelectContext = (\n SelectElement: React.FC<any>,\n {\n children,\n className,\n isMultiple,\n closeOnClick = !isMultiple,\n disabled,\n error,\n hasError,\n helper,\n id,\n isDisabled = disabled,\n isEmpty,\n isOpen,\n isRequired,\n isValid,\n label,\n onClear,\n onDropdownClose,\n onInfiniteScroll,\n onInputClick,\n placeholder,\n theme = DEFAULT_PROPS.theme,\n value,\n variant = DEFAULT_PROPS.variant,\n ...forwardedProps\n }: CoreSelectProps,\n ref: Ref<HTMLDivElement>,\n): React.ReactElement => {\n const selectId = useMemo(() => id || `select-${uid()}`, [id]);\n const anchorRef = useRef<HTMLElement>(null);\n const selectRef = useRef<HTMLDivElement>(null);\n const isFocus = useListenFocus(anchorRef);\n\n const handleKeyboardNav = useCallback(\n (evt: React.KeyboardEvent<HTMLElement>) => {\n if ((evt.key === 'Enter' || evt.key === ' ' || evt.key === 'ArrowDown') && onInputClick) {\n evt.preventDefault();\n onInputClick();\n }\n },\n [onInputClick],\n );\n\n const onClose = () => {\n if (onDropdownClose) {\n onDropdownClose();\n }\n anchorRef?.current?.blur();\n };\n\n return (\n <div\n ref={mergeRefs(ref, selectRef)}\n className={classNames(\n className,\n handleBasicClasses({\n hasError,\n hasLabel: Boolean(label),\n hasPlaceholder: Boolean(placeholder),\n hasValue: !isEmpty,\n isDisabled,\n isEmpty,\n isFocus,\n isOpen,\n isValid,\n prefix: CLASSNAME,\n theme: theme === Theme.light ? Theme.light : Theme.dark,\n }),\n )}\n >\n <SelectElement\n {...forwardedProps}\n anchorRef={anchorRef}\n aria-disabled={isDisabled}\n handleKeyboardNav={handleKeyboardNav}\n hasError={hasError}\n isDisabled={isDisabled}\n isEmpty={isEmpty}\n isRequired={isRequired}\n isValid={isValid}\n label={label}\n placeholder={placeholder}\n id={selectId}\n theme={theme}\n value={value}\n variant={variant}\n onClear={onClear}\n onInputClick={onInputClick}\n />\n <Dropdown\n anchorRef={anchorRef}\n closeOnClick={closeOnClick}\n closeOnClickAway\n closeOnEscape\n isOpen={!!isOpen}\n placement={Placement.BOTTOM_START}\n onClose={onClose}\n onInfiniteScroll={onInfiniteScroll}\n >\n {children}\n </Dropdown>\n {hasError && error && (\n <InputHelper className={`${CLASSNAME}__helper`} kind={Kind.error} theme={theme}>\n {error}\n </InputHelper>\n )}\n {helper && (\n <InputHelper className={`${CLASSNAME}__helper`} theme={theme}>\n {helper}\n </InputHelper>\n )}\n </div>\n );\n};\n","import React, { forwardRef, RefObject } from 'react';\n\nimport classNames from 'classnames';\nimport lodashIsEmpty from 'lodash/isEmpty';\n\nimport { mdiAlertCircle, mdiCheckCircle, mdiCloseCircle, mdiMenuDown } from '@lumx/icons';\n\nimport { Emphasis, Size } from '@lumx/react/components';\nimport { IconButton } from '@lumx/react/components/button/IconButton';\nimport { Chip } from '@lumx/react/components/chip/Chip';\nimport { Icon } from '@lumx/react/components/icon/Icon';\nimport { InputLabel } from '@lumx/react/components/input-label/InputLabel';\n\nimport { Comp, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\nimport { WithSelectContext } from './WithSelectContext';\nimport { CoreSelectProps, SelectVariant } from './constants';\n\n/** Defines the props of the component. */\nexport interface SelectProps extends CoreSelectProps {\n /** Selected value. */\n value: string;\n}\n\nexport { SelectVariant };\n\n/** The display name of the component. */\nconst COMPONENT_NAME = 'Select';\n\n/** The default class name and classes prefix for this component. */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/** The default value of props. */\nconst DEFAULT_PROPS: Partial<SelectProps> = {\n selectedValueRender: (choice) => choice,\n};\n\nconst stopPropagation = (evt: Event) => evt.stopPropagation();\n\n/**\n * Select component.\n */\nconst SelectField: React.FC<SelectProps> = ({\n anchorRef,\n clearButtonProps,\n handleKeyboardNav,\n hasError,\n hasInputClear,\n id,\n isDisabled,\n isEmpty,\n isRequired,\n isValid,\n label,\n onClear,\n onInputClick,\n placeholder,\n selectedValueRender,\n theme,\n value,\n variant,\n ...forwardedProps\n}) => {\n return (\n <>\n {variant === SelectVariant.input && (\n <>\n {label && (\n <div className={`${CLASSNAME}__header`}>\n <InputLabel\n htmlFor={id}\n className={`${CLASSNAME}__label`}\n isRequired={isRequired}\n theme={theme}\n >\n {label}\n </InputLabel>\n </div>\n )}\n\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}\n <div\n ref={anchorRef as RefObject<HTMLDivElement>}\n id={id}\n className={`${CLASSNAME}__wrapper`}\n onClick={onInputClick}\n onKeyDown={handleKeyboardNav}\n tabIndex={isDisabled ? undefined : 0}\n aria-disabled={isDisabled || undefined}\n {...forwardedProps}\n >\n <div\n className={classNames([\n `${CLASSNAME}__input-native`,\n isEmpty && placeholder && `${CLASSNAME}__input-native--placeholder`,\n ])}\n >\n {!isEmpty && <span>{selectedValueRender?.(value)}</span>}\n\n {isEmpty && placeholder && <span>{placeholder}</span>}\n </div>\n\n {(isValid || hasError) && (\n <div className={`${CLASSNAME}__input-validity`}>\n <Icon icon={isValid ? mdiCheckCircle : mdiAlertCircle} size={Size.xxs} />\n </div>\n )}\n\n {hasInputClear && clearButtonProps && (\n <IconButton\n {...clearButtonProps}\n className={`${CLASSNAME}__input-clear`}\n icon={mdiCloseCircle}\n emphasis={Emphasis.low}\n size={Size.s}\n theme={theme}\n onClick={onClear}\n onKeyDown={stopPropagation}\n />\n )}\n\n <div className={`${CLASSNAME}__input-indicator`}>\n <Icon icon={mdiMenuDown} size={Size.s} />\n </div>\n </div>\n </>\n )}\n\n {variant === SelectVariant.chip && (\n <Chip\n id={id}\n isSelected={!isEmpty}\n isDisabled={isDisabled}\n after={<Icon icon={isEmpty ? mdiMenuDown : mdiCloseCircle} />}\n onAfterClick={isEmpty ? onInputClick : onClear}\n onClick={onInputClick}\n ref={anchorRef as RefObject<HTMLAnchorElement>}\n theme={theme}\n {...forwardedProps}\n >\n {isEmpty && <span>{label}</span>}\n\n {!isEmpty && <span>{selectedValueRender?.(value)}</span>}\n </Chip>\n )}\n </>\n );\n};\n\n/**\n * Select component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Select: Comp<SelectProps, HTMLDivElement> = forwardRef((props, ref) => {\n const isEmpty = lodashIsEmpty(props.value);\n const hasInputClear = props.onClear && props.clearButtonProps && !isEmpty;\n\n return WithSelectContext(\n SelectField,\n {\n ...props,\n className: classNames(\n props.className,\n handleBasicClasses({\n hasInputClear,\n hasUnique: !props.isEmpty,\n prefix: CLASSNAME,\n }),\n ),\n hasInputClear,\n isEmpty,\n },\n ref,\n );\n});\nSelect.displayName = COMPONENT_NAME;\nSelect.className = CLASSNAME;\nSelect.defaultProps = DEFAULT_PROPS;\nSelect.className = CLASSNAME;\n","import React, { forwardRef, ReactNode, RefObject, SyntheticEvent } from 'react';\n\nimport classNames from 'classnames';\n\nimport { mdiAlertCircle, mdiCheckCircle, mdiClose, mdiCloseCircle, mdiMenuDown } from '@lumx/icons';\n\nimport { Size } from '@lumx/react/components';\nimport { Chip } from '@lumx/react/components/chip/Chip';\nimport { Icon } from '@lumx/react/components/icon/Icon';\nimport { InputLabel } from '@lumx/react/components/input-label/InputLabel';\n\nimport { Comp, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\nimport { WithSelectContext } from './WithSelectContext';\nimport { CoreSelectProps, SelectVariant } from './constants';\n\n/** Defines the props of the component. */\nexport interface SelectMultipleProps extends CoreSelectProps {\n /** Selected values. */\n value: string[];\n /** Selected value render function. Default: Renders the value inside of a Chip. */\n selectedChipRender?(\n choice: string,\n index: number,\n onClear?: (event: SyntheticEvent, choice: string) => void,\n isDisabled?: boolean,\n theme?: any,\n ): ReactNode | string;\n}\n\n/** The display name of the component. */\nconst COMPONENT_NAME = 'Select';\n\n/** The default class name and classes prefix for this component. */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/** The default value of props. */\nconst DEFAULT_PROPS: Partial<SelectMultipleProps> = {\n selectedChipRender(choice, index, onClear, isDisabled?, theme?) {\n const onClick = (event: React.MouseEvent) => onClear && onClear(event, choice);\n return (\n <Chip\n key={index}\n after={onClear && <Icon icon={mdiClose} size={Size.xxs} />}\n isDisabled={isDisabled}\n size={Size.s}\n onAfterClick={onClick}\n onClick={onClick}\n theme={theme}\n >\n {choice}\n </Chip>\n );\n },\n selectedValueRender: (choice) => choice,\n};\n\nexport const SelectMultipleField: React.FC<SelectMultipleProps> = ({\n anchorRef,\n handleKeyboardNav,\n hasError,\n id,\n isDisabled,\n isEmpty,\n isRequired,\n isValid,\n label,\n onClear,\n onInputClick,\n placeholder,\n selectedChipRender,\n selectedValueRender,\n theme,\n value,\n variant,\n}) => (\n <>\n {variant === SelectVariant.input && (\n <>\n {label && (\n <div className={`${CLASSNAME}__header`}>\n <InputLabel\n htmlFor={id}\n className={`${CLASSNAME}__label`}\n isRequired={isRequired}\n theme={theme}\n >\n {label}\n </InputLabel>\n </div>\n )}\n\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}\n <div\n ref={anchorRef as RefObject<HTMLDivElement>}\n id={id}\n className={`${CLASSNAME}__wrapper`}\n onClick={onInputClick}\n onKeyDown={handleKeyboardNav}\n tabIndex={isDisabled ? undefined : 0}\n aria-disabled={isDisabled || undefined}\n >\n <div className={`${CLASSNAME}__chips`}>\n {!isEmpty &&\n value.map((val, index) => selectedChipRender?.(val, index, onClear, isDisabled, theme))}\n </div>\n\n {isEmpty && placeholder && (\n <div\n className={classNames([\n `${CLASSNAME}__input-native`,\n `${CLASSNAME}__input-native--placeholder`,\n ])}\n >\n <span>{placeholder}</span>\n </div>\n )}\n\n {(isValid || hasError) && (\n <div className={`${CLASSNAME}__input-validity`}>\n <Icon icon={isValid ? mdiCheckCircle : mdiAlertCircle} size={Size.xxs} />\n </div>\n )}\n\n <div className={`${CLASSNAME}__input-indicator`}>\n <Icon icon={mdiMenuDown} size={Size.s} />\n </div>\n </div>\n </>\n )}\n\n {variant === SelectVariant.chip && (\n <Chip\n id={id}\n isSelected={!isEmpty}\n isDisabled={isDisabled}\n after={<Icon icon={isEmpty ? mdiMenuDown : mdiCloseCircle} />}\n onAfterClick={isEmpty ? onInputClick : onClear}\n onClick={onInputClick}\n ref={anchorRef as RefObject<HTMLAnchorElement>}\n theme={theme}\n >\n {isEmpty && <span>{label}</span>}\n\n {!isEmpty && (\n <span>\n <span>{selectedValueRender?.(value[0])}</span>\n\n {value.length > 1 && <span>&nbsp;+{value.length - 1}</span>}\n </span>\n )}\n </Chip>\n )}\n </>\n);\n\n/**\n * SelectMultiple component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const SelectMultiple: Comp<SelectMultipleProps, HTMLDivElement> = forwardRef((props, ref) => {\n return WithSelectContext(\n SelectMultipleField,\n {\n ...props,\n className: classNames(\n props.className,\n handleBasicClasses({\n hasMultiple: !props.isEmpty,\n prefix: CLASSNAME,\n }),\n ),\n isEmpty: props.value.length === 0,\n isMultiple: true,\n },\n ref,\n );\n});\nSelectMultiple.displayName = COMPONENT_NAME;\nSelectMultiple.className = CLASSNAME;\nSelectMultiple.defaultProps = DEFAULT_PROPS;\n"],"names":["useListenFocus","ref","useState","isFocus","setFocus","useEffect","element","current","undefined","onFocus","onBlur","addEventListener","removeEventListener","SelectVariant","input","chip","COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","theme","Theme","light","variant","WithSelectContext","SelectElement","children","className","isMultiple","closeOnClick","disabled","error","hasError","helper","id","isDisabled","isEmpty","isOpen","isRequired","isValid","label","onClear","onDropdownClose","onInfiniteScroll","onInputClick","placeholder","value","forwardedProps","selectId","useMemo","uid","anchorRef","useRef","selectRef","handleKeyboardNav","useCallback","evt","key","preventDefault","onClose","blur","mergeRefs","classNames","handleBasicClasses","hasLabel","Boolean","hasPlaceholder","hasValue","prefix","dark","Placement","BOTTOM_START","Kind","selectedValueRender","choice","stopPropagation","SelectField","clearButtonProps","hasInputClear","mdiCheckCircle","mdiAlertCircle","Size","xxs","mdiCloseCircle","Emphasis","low","s","mdiMenuDown","Select","forwardRef","props","lodashIsEmpty","hasUnique","displayName","defaultProps","selectedChipRender","index","onClick","event","mdiClose","SelectMultipleField","map","val","length","SelectMultiple","hasMultiple"],"mappings":";;;;;;;;;;;;;;;AAEA;;;;AAGO,SAASA,cAAT,CAAwBC,GAAxB,EAAqD;AAAA,kBAC5BC,QAAQ,CAAC,KAAD,CADoB;AAAA;AAAA,MACjDC,OADiD;AAAA,MACxCC,QADwC;;AAGxDC,EAAAA,SAAS,CAAC,YAAM;AAAA,QACKC,OADL,GACiBL,GADjB,CACJM,OADI;;AAEZ,QAAI,CAACD,OAAL,EAAc;AACV,aAAOE,SAAP;AACH;;AAED,QAAMC,OAAO,GAAG,SAAVA,OAAU;AAAA,aAAML,QAAQ,CAAC,IAAD,CAAd;AAAA,KAAhB;;AACA,QAAMM,MAAM,GAAG,SAATA,MAAS;AAAA,aAAMN,QAAQ,CAAC,KAAD,CAAd;AAAA,KAAf;;AACAE,IAAAA,OAAO,CAACK,gBAAR,CAAyB,OAAzB,EAAkCF,OAAlC;AACAH,IAAAA,OAAO,CAACK,gBAAR,CAAyB,MAAzB,EAAiCD,MAAjC;AACA,WAAO,YAAM;AACTJ,MAAAA,OAAO,CAACM,mBAAR,CAA4B,OAA5B,EAAqCH,OAAr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YhB3E,IAAAA,UAAU,EAAE;AAZI,MAcpB3B,GAdoB,CAAxB;AAgBH,CAjBkF;AAkBnFuG,cAAc,CAACX,WAAf,GAA6B7E,gBAA7B;AACAwF,cAAc,CAAC7E,SAAf,GAA2BV,WAA3B;AACAuF,cAAc,CAACV,YAAf,GAA8B3E,eAA9B;;;;"}
1
+ {"version":3,"file":"SelectMultiple.js","sources":["../../../src/hooks/useListenFocus.tsx","../../../src/components/select/constants.ts","../../../src/components/select/WithSelectContext.tsx","../../../src/components/select/Select.tsx","../../../src/components/select/SelectMultiple.tsx"],"sourcesContent":["import { RefObject, useEffect, useState } from 'react';\n\n/**\n * Listen on element focus to store the focus status.\n */\nexport function useListenFocus(ref: RefObject<HTMLElement>) {\n const [isFocus, setFocus] = useState(false);\n\n useEffect(() => {\n const { current: element } = ref;\n if (!element) {\n return undefined;\n }\n\n const onFocus = () => setFocus(true);\n const onBlur = () => setFocus(false);\n element.addEventListener('focus', onFocus);\n element.addEventListener('blur', onBlur);\n return () => {\n element.removeEventListener('focus', onFocus);\n element.removeEventListener('blur', onBlur);\n };\n }, [ref, setFocus]);\n\n return isFocus;\n}\n","import { IconButtonProps } from '@lumx/react';\nimport { Theme } from '@lumx/react/components';\nimport { GenericProps, ValueOf } from '@lumx/react/utils';\nimport { ReactNode, SyntheticEvent } from 'react';\n\n/**\n * Select variants.\n */\nexport const SelectVariant = { input: 'input', chip: 'chip' } as const;\nexport type SelectVariant = ValueOf<typeof SelectVariant>;\n\nexport interface CoreSelectProps extends GenericProps {\n /** Props to pass to the clear button (minus those already set by the Select props). If not specified, the button won't be displayed. */\n clearButtonProps?: Pick<IconButtonProps, 'label'> &\n Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis'>;\n /** Whether the select (input variant) is displayed with error style or not. */\n hasError?: boolean;\n /** Error message. */\n error?: string | ReactNode;\n /** Helper text. */\n helper?: string;\n /** Whether the select should close on click. */\n closeOnClick?: boolean;\n /** Whether the component is disabled or not. */\n isDisabled?: boolean;\n /** Whether the component is required or not. */\n isRequired?: boolean;\n /** Whether the component is open or not. */\n isOpen?: boolean;\n /** Whether the select (input variant) is displayed with valid style or not. */\n isValid?: boolean;\n /** Label text. */\n label?: string;\n /** Placeholder input text. */\n placeholder?: string;\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** Select variant. */\n variant?: SelectVariant;\n /** On clear callback. */\n onClear?(event: SyntheticEvent, value?: string): void;\n /** On blur callback. */\n onBlur?(): void;\n /** On filter text change callback (with 500ms debounce). */\n onFilter?(): void;\n /** On input click callback (can be used for dropdown toggle). */\n onInputClick?(): void;\n /** On dropdown close callback. */\n onDropdownClose?(): void;\n /** On scroll end callback. */\n onInfiniteScroll?(): void;\n /** Render value function. Default: Renders the value as a string. */\n selectedValueRender?(choice: string): ReactNode | string;\n}\n","import React, { Ref, useCallback, useMemo, useRef } from 'react';\n\nimport classNames from 'classnames';\nimport { uid } from 'uid';\n\nimport { Kind, Theme } from '@lumx/react/components';\nimport { Dropdown } from '@lumx/react/components/dropdown/Dropdown';\nimport { InputHelper } from '@lumx/react/components/input-helper/InputHelper';\nimport { Placement } from '@lumx/react/components/popover/Popover';\n\nimport { getRootClassName, handleBasicClasses } from '@lumx/react/utils';\nimport { mergeRefs } from '@lumx/react/utils/mergeRefs';\nimport { useListenFocus } from '@lumx/react/hooks/useListenFocus';\nimport { CoreSelectProps, SelectVariant } from './constants';\n\n/** The display name of the component. */\nconst COMPONENT_NAME = 'Select';\n\n/** The default class name and classes prefix for this component. */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/** The default value of props. */\nexport const DEFAULT_PROPS: Partial<CoreSelectProps> = {\n theme: Theme.light,\n variant: SelectVariant.input,\n};\n\nexport const WithSelectContext = (\n SelectElement: React.FC<any>,\n {\n children,\n className,\n isMultiple,\n closeOnClick = !isMultiple,\n disabled,\n error,\n hasError,\n helper,\n id,\n isDisabled = disabled,\n isEmpty,\n isOpen,\n isRequired,\n isValid,\n label,\n onClear,\n onDropdownClose,\n onInfiniteScroll,\n onInputClick,\n placeholder,\n theme = DEFAULT_PROPS.theme,\n value,\n variant = DEFAULT_PROPS.variant,\n ...forwardedProps\n }: CoreSelectProps,\n ref: Ref<HTMLDivElement>,\n): React.ReactElement => {\n const selectId = useMemo(() => id || `select-${uid()}`, [id]);\n const anchorRef = useRef<HTMLElement>(null);\n const selectRef = useRef<HTMLDivElement>(null);\n const isFocus = useListenFocus(anchorRef);\n\n const handleKeyboardNav = useCallback(\n (evt: React.KeyboardEvent<HTMLElement>) => {\n if ((evt.key === 'Enter' || evt.key === ' ' || evt.key === 'ArrowDown') && onInputClick) {\n evt.preventDefault();\n onInputClick();\n }\n },\n [onInputClick],\n );\n\n const onClose = () => {\n if (onDropdownClose) {\n onDropdownClose();\n }\n anchorRef?.current?.blur();\n };\n\n return (\n <div\n ref={mergeRefs(ref, selectRef)}\n className={classNames(\n className,\n handleBasicClasses({\n hasError,\n hasLabel: Boolean(label),\n hasPlaceholder: Boolean(placeholder),\n hasValue: !isEmpty,\n isDisabled,\n isEmpty,\n isFocus,\n isOpen,\n isValid,\n prefix: CLASSNAME,\n theme: theme === Theme.light ? Theme.light : Theme.dark,\n }),\n )}\n >\n <SelectElement\n {...forwardedProps}\n anchorRef={anchorRef}\n aria-disabled={isDisabled}\n handleKeyboardNav={handleKeyboardNav}\n hasError={hasError}\n isDisabled={isDisabled}\n isEmpty={isEmpty}\n isRequired={isRequired}\n isValid={isValid}\n label={label}\n placeholder={placeholder}\n id={selectId}\n theme={theme}\n value={value}\n variant={variant}\n onClear={onClear}\n onInputClick={onInputClick}\n />\n <Dropdown\n anchorRef={anchorRef}\n closeOnClick={closeOnClick}\n closeOnClickAway\n closeOnEscape\n isOpen={!!isOpen}\n placement={Placement.BOTTOM_START}\n onClose={onClose}\n onInfiniteScroll={onInfiniteScroll}\n >\n {children}\n </Dropdown>\n {hasError && error && (\n <InputHelper className={`${CLASSNAME}__helper`} kind={Kind.error} theme={theme}>\n {error}\n </InputHelper>\n )}\n {helper && (\n <InputHelper className={`${CLASSNAME}__helper`} theme={theme}>\n {helper}\n </InputHelper>\n )}\n </div>\n );\n};\n","import React, { forwardRef, RefObject } from 'react';\n\nimport classNames from 'classnames';\nimport lodashIsEmpty from 'lodash/isEmpty';\n\nimport { mdiAlertCircle, mdiCheckCircle, mdiCloseCircle, mdiMenuDown } from '@lumx/icons';\n\nimport { Emphasis, Size } from '@lumx/react/components';\nimport { IconButton } from '@lumx/react/components/button/IconButton';\nimport { Chip } from '@lumx/react/components/chip/Chip';\nimport { Icon } from '@lumx/react/components/icon/Icon';\nimport { InputLabel } from '@lumx/react/components/input-label/InputLabel';\n\nimport { Comp, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\nimport { WithSelectContext } from './WithSelectContext';\nimport { CoreSelectProps, SelectVariant } from './constants';\n\n/** Defines the props of the component. */\nexport interface SelectProps extends CoreSelectProps {\n /** Selected value. */\n value: string;\n}\n\nexport { SelectVariant };\n\n/** The display name of the component. */\nconst COMPONENT_NAME = 'Select';\n\n/** The default class name and classes prefix for this component. */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/** The default value of props. */\nconst DEFAULT_PROPS: Partial<SelectProps> = {\n selectedValueRender: (choice) => choice,\n};\n\nconst stopPropagation = (evt: Event) => evt.stopPropagation();\n\n/**\n * Select component.\n */\nconst SelectField: React.FC<SelectProps> = ({\n anchorRef,\n clearButtonProps,\n handleKeyboardNav,\n hasError,\n hasInputClear,\n id,\n isDisabled,\n isEmpty,\n isRequired,\n isValid,\n label,\n onClear,\n onInputClick,\n placeholder,\n selectedValueRender,\n theme,\n value,\n variant,\n ...forwardedProps\n}) => {\n return (\n <>\n {variant === SelectVariant.input && (\n <>\n {label && (\n <div className={`${CLASSNAME}__header`}>\n <InputLabel\n htmlFor={id}\n className={`${CLASSNAME}__label`}\n isRequired={isRequired}\n theme={theme}\n >\n {label}\n </InputLabel>\n </div>\n )}\n\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}\n <div\n ref={anchorRef as RefObject<HTMLDivElement>}\n id={id}\n className={`${CLASSNAME}__wrapper`}\n onClick={onInputClick}\n onKeyDown={handleKeyboardNav}\n tabIndex={isDisabled ? undefined : 0}\n aria-disabled={isDisabled || undefined}\n {...forwardedProps}\n >\n <div\n className={classNames([\n `${CLASSNAME}__input-native`,\n isEmpty && placeholder && `${CLASSNAME}__input-native--placeholder`,\n ])}\n >\n {!isEmpty && <span>{selectedValueRender?.(value)}</span>}\n\n {isEmpty && placeholder && <span>{placeholder}</span>}\n </div>\n\n {(isValid || hasError) && (\n <div className={`${CLASSNAME}__input-validity`}>\n <Icon icon={isValid ? mdiCheckCircle : mdiAlertCircle} size={Size.xxs} />\n </div>\n )}\n\n {hasInputClear && clearButtonProps && (\n <IconButton\n {...clearButtonProps}\n className={`${CLASSNAME}__input-clear`}\n icon={mdiCloseCircle}\n emphasis={Emphasis.low}\n size={Size.s}\n theme={theme}\n onClick={onClear}\n onKeyDown={stopPropagation}\n />\n )}\n\n <div className={`${CLASSNAME}__input-indicator`}>\n <Icon icon={mdiMenuDown} size={Size.s} />\n </div>\n </div>\n </>\n )}\n\n {variant === SelectVariant.chip && (\n <Chip\n id={id}\n isSelected={!isEmpty}\n isDisabled={isDisabled}\n after={<Icon icon={isEmpty ? mdiMenuDown : mdiCloseCircle} />}\n onAfterClick={isEmpty ? onInputClick : onClear}\n onClick={onInputClick}\n ref={anchorRef as RefObject<HTMLAnchorElement>}\n theme={theme}\n {...forwardedProps}\n >\n {isEmpty && <span>{label}</span>}\n\n {!isEmpty && <span>{selectedValueRender?.(value)}</span>}\n </Chip>\n )}\n </>\n );\n};\n\n/**\n * Select component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Select: Comp<SelectProps, HTMLDivElement> = forwardRef((props, ref) => {\n const isEmpty = lodashIsEmpty(props.value);\n const hasInputClear = props.onClear && props.clearButtonProps && !isEmpty;\n\n return WithSelectContext(\n SelectField,\n {\n ...props,\n className: classNames(\n props.className,\n handleBasicClasses({\n hasInputClear,\n hasUnique: !props.isEmpty,\n prefix: CLASSNAME,\n }),\n ),\n hasInputClear,\n isEmpty,\n },\n ref,\n );\n});\nSelect.displayName = COMPONENT_NAME;\nSelect.className = CLASSNAME;\nSelect.defaultProps = DEFAULT_PROPS;\nSelect.className = CLASSNAME;\n","import React, { forwardRef, ReactNode, RefObject, SyntheticEvent } from 'react';\n\nimport classNames from 'classnames';\n\nimport { mdiAlertCircle, mdiCheckCircle, mdiClose, mdiCloseCircle, mdiMenuDown } from '@lumx/icons';\n\nimport { Size } from '@lumx/react/components';\nimport { Chip } from '@lumx/react/components/chip/Chip';\nimport { Icon } from '@lumx/react/components/icon/Icon';\nimport { InputLabel } from '@lumx/react/components/input-label/InputLabel';\n\nimport { Comp, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\nimport { WithSelectContext } from './WithSelectContext';\nimport { CoreSelectProps, SelectVariant } from './constants';\n\n/** Defines the props of the component. */\nexport interface SelectMultipleProps extends CoreSelectProps {\n /** Selected values. */\n value: string[];\n /** Selected value render function. Default: Renders the value inside of a Chip. */\n selectedChipRender?(\n choice: string,\n index: number,\n onClear?: (event: SyntheticEvent, choice: string) => void,\n isDisabled?: boolean,\n theme?: any,\n ): ReactNode | string;\n}\n\n/** The display name of the component. */\nconst COMPONENT_NAME = 'Select';\n\n/** The default class name and classes prefix for this component. */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/** The default value of props. */\nconst DEFAULT_PROPS: Partial<SelectMultipleProps> = {\n selectedChipRender(choice, index, onClear, isDisabled?, theme?) {\n const onClick = (event: React.MouseEvent) => onClear && onClear(event, choice);\n return (\n <Chip\n key={index}\n after={onClear && <Icon icon={mdiClose} size={Size.xxs} />}\n isDisabled={isDisabled}\n size={Size.s}\n onAfterClick={onClick}\n onClick={onClick}\n theme={theme}\n >\n {choice}\n </Chip>\n );\n },\n selectedValueRender: (choice) => choice,\n};\n\nexport const SelectMultipleField: React.FC<SelectMultipleProps> = ({\n anchorRef,\n handleKeyboardNav,\n hasError,\n id,\n isDisabled,\n isEmpty,\n isRequired,\n isValid,\n label,\n onClear,\n onInputClick,\n placeholder,\n selectedChipRender,\n selectedValueRender,\n theme,\n value,\n variant,\n ...forwardedProps\n}) => (\n <>\n {variant === SelectVariant.input && (\n <>\n {label && (\n <div className={`${CLASSNAME}__header`}>\n <InputLabel\n htmlFor={id}\n className={`${CLASSNAME}__label`}\n isRequired={isRequired}\n theme={theme}\n >\n {label}\n </InputLabel>\n </div>\n )}\n\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}\n <div\n ref={anchorRef as RefObject<HTMLDivElement>}\n id={id}\n className={`${CLASSNAME}__wrapper`}\n onClick={onInputClick}\n onKeyDown={handleKeyboardNav}\n tabIndex={isDisabled ? undefined : 0}\n aria-disabled={isDisabled || undefined}\n {...forwardedProps}\n >\n <div className={`${CLASSNAME}__chips`}>\n {!isEmpty &&\n value.map((val, index) => selectedChipRender?.(val, index, onClear, isDisabled, theme))}\n </div>\n\n {isEmpty && placeholder && (\n <div\n className={classNames([\n `${CLASSNAME}__input-native`,\n `${CLASSNAME}__input-native--placeholder`,\n ])}\n >\n <span>{placeholder}</span>\n </div>\n )}\n\n {(isValid || hasError) && (\n <div className={`${CLASSNAME}__input-validity`}>\n <Icon icon={isValid ? mdiCheckCircle : mdiAlertCircle} size={Size.xxs} />\n </div>\n )}\n\n <div className={`${CLASSNAME}__input-indicator`}>\n <Icon icon={mdiMenuDown} size={Size.s} />\n </div>\n </div>\n </>\n )}\n\n {variant === SelectVariant.chip && (\n <Chip\n id={id}\n isSelected={!isEmpty}\n isDisabled={isDisabled}\n after={<Icon icon={isEmpty ? mdiMenuDown : mdiCloseCircle} />}\n onAfterClick={isEmpty ? onInputClick : onClear}\n onClick={onInputClick}\n ref={anchorRef as RefObject<HTMLAnchorElement>}\n theme={theme}\n {...forwardedProps}\n >\n {isEmpty && <span>{label}</span>}\n\n {!isEmpty && (\n <span>\n <span>{selectedValueRender?.(value[0])}</span>\n\n {value.length > 1 && <span>&nbsp;+{value.length - 1}</span>}\n </span>\n )}\n </Chip>\n )}\n </>\n);\n\n/**\n * SelectMultiple component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const SelectMultiple: Comp<SelectMultipleProps, HTMLDivElement> = forwardRef((props, ref) => {\n return WithSelectContext(\n SelectMultipleField,\n {\n ...props,\n className: classNames(\n props.className,\n handleBasicClasses({\n hasMultiple: !props.isEmpty,\n prefix: CLASSNAME,\n }),\n ),\n isEmpty: props.value.length === 0,\n isMultiple: true,\n },\n ref,\n );\n});\nSelectMultiple.displayName = COMPONENT_NAME;\nSelectMultiple.className = CLASSNAME;\nSelectMultiple.defaultProps = DEFAULT_PROPS;\n"],"names":["useListenFocus","ref","useState","isFocus","setFocus","useEffect","element","current","undefined","onFocus","onBlur","addEventListener","removeEventListener","SelectVariant","input","chip","COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","theme","Theme","light","variant","WithSelectContext","SelectElement","children","className","isMultiple","closeOnClick","disabled","error","hasError","helper","id","isDisabled","isEmpty","isOpen","isRequired","isValid","label","onClear","onDropdownClose","onInfiniteScroll","onInputClick","placeholder","value","forwardedProps","selectId","useMemo","uid","anchorRef","useRef","selectRef","handleKeyboardNav","useCallback","evt","key","preventDefault","onClose","blur","mergeRefs","classNames","handleBasicClasses","hasLabel","Boolean","hasPlaceholder","hasValue","prefix","dark","Placement","BOTTOM_START","Kind","selectedValueRender","choice","stopPropagation","SelectField","clearButtonProps","hasInputClear","mdiCheckCircle","mdiAlertCircle","Size","xxs","mdiCloseCircle","Emphasis","low","s","mdiMenuDown","Select","forwardRef","props","lodashIsEmpty","hasUnique","displayName","defaultProps","selectedChipRender","index","onClick","event","mdiClose","SelectMultipleField","map","val","length","SelectMultiple","hasMultiple"],"mappings":";;;;;;;;;;;;;;;AAEA;;;;AAGO,SAASA,cAAT,CAAwBC,GAAx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hB,EAaK,CAACJ,OAAD,IACG,kCACI,kCAAOqC,mBAAP,aAAOA,mBAAP,uBAAOA,mBAAmB,CAAG3B,KAAK,CAAC,CAAD,CAAR,CAA1B,CADJ,EAGKA,KAAK,CAACyD,MAAN,GAAe,CAAf,IAAoB,2CAAczD,KAAK,CAACyD,MAAN,GAAe,CAA7B,CAHzB,CAdR,CAzDR,CApB8D;AAAA;AAsGlE;;;;;;;;IAOaC,cAAyD,GAAGf,UAAU,CAAC,UAACC,KAAD,EAAQzF,GAAR,EAAgB;AAChG,SAAOuB,iBAAiB,CACpB4E,mBADoB,qBAGbV,KAHa;AAIhB/D,IAAAA,SAAS,EAAEmC,UAAU,CACjB4B,KAAK,CAAC/D,SADW,EAEjBoC,kBAAkB,CAAC;AACf0C,MAAAA,WAAW,EAAE,CAACf,KAAK,CAACtD,OADL;AAEfgC,MAAAA,MAAM,EAAEnD;AAFO,KAAD,CAFD,CAJL;AAWhBmB,IAAAA,OAAO,EAAEsD,KAAK,CAAC5C,KAAN,CAAYyD,MAAZ,KAAuB,CAXhB;AAYhB3E,IAAAA,UAAU,EAAE;AAZI,MAcpB3B,GAdoB,CAAxB;AAgBH,CAjBkF;AAkBnFuG,cAAc,CAACX,WAAf,GAA6B7E,gBAA7B;AACAwF,cAAc,CAAC7E,SAAf,GAA2BV,WAA3B;AACAuF,cAAc,CAACV,YAAf,GAA8B3E,eAA9B;;;;"}
@@ -58,6 +58,7 @@ var Size = {
58
58
  xxl: 'xxl',
59
59
  tiny: 'tiny',
60
60
  regular: 'regular',
61
+ medium: 'medium',
61
62
  big: 'big',
62
63
  huge: 'huge'
63
64
  };
@@ -1 +1 @@
1
- {"version":3,"file":"components.js","sources":["../../../src/components/index.ts"],"sourcesContent":["import { ValueOf } from '@lumx/react/utils';\n\n/**\n * Alignments.\n */\nexport const Alignment = {\n bottom: 'bottom',\n center: 'center',\n end: 'end',\n left: 'left',\n right: 'right',\n spaceAround: 'space-around',\n spaceBetween: 'space-between',\n start: 'start',\n top: 'top',\n} as const;\nexport type Alignment = ValueOf<typeof Alignment>;\nexport type VerticalAlignment = Extract<Alignment, 'top' | 'center' | 'bottom'>;\nexport type HorizontalAlignment = Extract<Alignment, 'right' | 'center' | 'left'>;\n\n/**\n * See SCSS variable $lumx-color-palette\n */\nexport const ColorPalette = {\n primary: 'primary',\n secondary: 'secondary',\n blue: 'blue',\n dark: 'dark',\n green: 'green',\n yellow: 'yellow',\n red: 'red',\n light: 'light',\n grey: 'grey',\n} as const;\nexport type ColorPalette = ValueOf<typeof ColorPalette>;\nexport type Color = ColorPalette | string;\n\n/**\n * See SCSS variable $lumx-color-variants\n */\nexport const ColorVariant = {\n D1: 'D1',\n D2: 'D2',\n L1: 'L1',\n L2: 'L2',\n L3: 'L3',\n L4: 'L4',\n L5: 'L5',\n L6: 'L6',\n N: 'N',\n} as const;\nexport type ColorVariant = ValueOf<typeof ColorVariant>;\n\nexport const Theme = {\n light: 'light',\n dark: 'dark',\n} as const;\nexport type Theme = ValueOf<typeof Theme>;\n\nexport const Size = {\n xxs: 'xxs',\n xs: 'xs',\n s: 's',\n m: 'm',\n l: 'l',\n xl: 'xl',\n xxl: 'xxl',\n tiny: 'tiny',\n regular: 'regular',\n big: 'big',\n huge: 'huge',\n} as const;\nexport type Size = ValueOf<typeof Size>;\nexport type GlobalSize = Extract<Size, 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'>;\n\nexport const Orientation = {\n horizontal: 'horizontal',\n vertical: 'vertical',\n} as const;\nexport type Orientation = ValueOf<typeof Orientation>;\n\nexport const Emphasis = {\n low: 'low',\n medium: 'medium',\n high: 'high',\n} as const;\nexport type Emphasis = ValueOf<typeof Emphasis>;\n\n/**\n * List of typographies that can't be customized.\n */\nexport const TypographyInterface = {\n overline: 'overline',\n caption: 'caption',\n body1: 'body1',\n body2: 'body2',\n subtitle1: 'subtitle1',\n subtitle2: 'subtitle2',\n title: 'title',\n headline: 'headline',\n display1: 'display1',\n} as const;\nexport type TypographyInterface = ValueOf<typeof TypographyInterface>;\n\n/**\n * List of title typographies that can be customized (via CSS variables).\n */\nexport const TypographyTitleCustom = {\n title1: 'custom-title1',\n title2: 'custom-title2',\n title3: 'custom-title3',\n title4: 'custom-title4',\n title5: 'custom-title5',\n title6: 'custom-title6',\n} as const;\nexport type TypographyTitleCustom = ValueOf<typeof TypographyTitleCustom>;\n\n/**\n * List of typographies that can be customized (via CSS variables).\n */\nconst TypographyCustom = {\n ...TypographyTitleCustom,\n intro: 'intro',\n 'body-large': 'body-large',\n body: 'body',\n quote: 'quote',\n 'publish-info': 'publish-info',\n button: 'button',\n} as const;\nexport type TypographyCustom = ValueOf<typeof TypographyCustom>;\n\n/**\n * List of all typographies.\n */\nexport const Typography = {\n ...TypographyInterface,\n custom: TypographyCustom,\n} as const;\nexport type Typography = TypographyInterface | TypographyCustom;\n\n/**\n * All available aspect ratios.\n */\nexport const AspectRatio = {\n /** Intrinsic content ratio. */\n original: 'original',\n /** Ratio 16:9 */\n wide: 'wide',\n /** Ratio 3:2 */\n horizontal: 'horizontal',\n /** Ratio 3:2 */\n vertical: 'vertical',\n /** Ratio 1:1 */\n square: 'square',\n /** Ratio constrained by the parent. */\n free: 'free',\n} as const;\nexport type AspectRatio = ValueOf<typeof AspectRatio>;\n\n/**\n * Semantic info about the purpose of the component\n */\nexport const Kind = {\n info: 'info',\n success: 'success',\n warning: 'warning',\n error: 'error',\n} as const;\nexport type Kind = ValueOf<typeof Kind>;\n"],"names":["Alignment","bottom","center","end","left","right","spaceAround","spaceBetween","start","top","ColorPalette","primary","secondary","blue","dark","green","yellow","red","light","grey","ColorVariant","D1","D2","L1","L2","L3","L4","L5","L6","N","Theme","Size","xxs","xs","s","m","l","xl","xxl","tiny","regular","big","huge","Orientation","horizontal","vertical","Emphasis","low","medium","high","TypographyInterface","overline","caption","body1","body2","subtitle1","subtitle2","title","headline","display1","TypographyTitleCustom","title1","title2","title3","title4","title5","title6","TypographyCustom","intro","body","quote","button","Typography","custom","A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AAgB,cANE;AAOlBC,EAAAA,MAAM,EAAE;AAPU,EAAtB;;AAWA;;;IAGaC,UAAU,sBAChBtB,mBADgB;AAEnBuB,EAAAA,MAAM,EAAEN;AAFW;;AAMvB;;;IAGaO,WAAW,GAAG;AACvB;AACAC,EAAAA,QAAQ,EAAE,UAFa;;AAGvB;AACAC,EAAAA,IAAI,EAAE,MAJiB;;AAKvB;AACAhC,EAAAA,UAAU,EAAE,YANW;;AAOvB;AACAC,EAAAA,QAAQ,EAAE,UARa;;AASvB;AACAgC,EAAAA,MAAM,EAAE,QAVe;;AAWvB;AACAC,EAAAA,IAAI,EAAE;AAZiB;;AAgB3B;;;IAGaC,IAAI,GAAG;AAChBC,EAAAA,IAAI,EAAE,MADU;AAEhBC,EAAAA,OAAO,EAAE,SAFO;AAGhBC,EAAAA,OAAO,EAAE,SAHO;AAIhBC,EAAAA,KAAK,EAAE;AAJS;;;;"}
1
+ {"version":3,"file":"components.js","sources":["../../../src/components/index.ts"],"sourcesContent":["import { ValueOf } from '@lumx/react/utils';\n\n/**\n * Alignments.\n */\nexport const Alignment = {\n bottom: 'bottom',\n center: 'center',\n end: 'end',\n left: 'left',\n right: 'right',\n spaceAround: 'space-around',\n spaceBetween: 'space-between',\n start: 'start',\n top: 'top',\n} as const;\nexport type Alignment = ValueOf<typeof Alignment>;\nexport type VerticalAlignment = Extract<Alignment, 'top' | 'center' | 'bottom'>;\nexport type HorizontalAlignment = Extract<Alignment, 'right' | 'center' | 'left'>;\n\n/**\n * See SCSS variable $lumx-color-palette\n */\nexport const ColorPalette = {\n primary: 'primary',\n secondary: 'secondary',\n blue: 'blue',\n dark: 'dark',\n green: 'green',\n yellow: 'yellow',\n red: 'red',\n light: 'light',\n grey: 'grey',\n} as const;\nexport type ColorPalette = ValueOf<typeof ColorPalette>;\nexport type Color = ColorPalette | string;\n\n/**\n * See SCSS variable $lumx-color-variants\n */\nexport const ColorVariant = {\n D1: 'D1',\n D2: 'D2',\n L1: 'L1',\n L2: 'L2',\n L3: 'L3',\n L4: 'L4',\n L5: 'L5',\n L6: 'L6',\n N: 'N',\n} as const;\nexport type ColorVariant = ValueOf<typeof ColorVariant>;\n\nexport const Theme = {\n light: 'light',\n dark: 'dark',\n} as const;\nexport type Theme = ValueOf<typeof Theme>;\n\nexport const Size = {\n xxs: 'xxs',\n xs: 'xs',\n s: 's',\n m: 'm',\n l: 'l',\n xl: 'xl',\n xxl: 'xxl',\n tiny: 'tiny',\n regular: 'regular',\n medium: 'medium',\n big: 'big',\n huge: 'huge',\n} as const;\nexport type Size = ValueOf<typeof Size>;\nexport type GlobalSize = Extract<Size, 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'>;\n\nexport const Orientation = {\n horizontal: 'horizontal',\n vertical: 'vertical',\n} as const;\nexport type Orientation = ValueOf<typeof Orientation>;\n\nexport const Emphasis = {\n low: 'low',\n medium: 'medium',\n high: 'high',\n} as const;\nexport type Emphasis = ValueOf<typeof Emphasis>;\n\n/**\n * List of typographies that can't be customized.\n */\nexport const TypographyInterface = {\n overline: 'overline',\n caption: 'caption',\n body1: 'body1',\n body2: 'body2',\n subtitle1: 'subtitle1',\n subtitle2: 'subtitle2',\n title: 'title',\n headline: 'headline',\n display1: 'display1',\n} as const;\nexport type TypographyInterface = ValueOf<typeof TypographyInterface>;\n\n/**\n * List of title typographies that can be customized (via CSS variables).\n */\nexport const TypographyTitleCustom = {\n title1: 'custom-title1',\n title2: 'custom-title2',\n title3: 'custom-title3',\n title4: 'custom-title4',\n title5: 'custom-title5',\n title6: 'custom-title6',\n} as const;\nexport type TypographyTitleCustom = ValueOf<typeof TypographyTitleCustom>;\n\n/**\n * List of typographies that can be customized (via CSS variables).\n */\nconst TypographyCustom = {\n ...TypographyTitleCustom,\n intro: 'intro',\n 'body-large': 'body-large',\n body: 'body',\n quote: 'quote',\n 'publish-info': 'publish-info',\n button: 'button',\n} as const;\nexport type TypographyCustom = ValueOf<typeof TypographyCustom>;\n\n/**\n * List of all typographies.\n */\nexport const Typography = {\n ...TypographyInterface,\n custom: TypographyCustom,\n} as const;\nexport type Typography = TypographyInterface | TypographyCustom;\n\n/**\n * All available aspect ratios.\n */\nexport const AspectRatio = {\n /** Intrinsic content ratio. */\n original: 'original',\n /** Ratio 16:9 */\n wide: 'wide',\n /** Ratio 3:2 */\n horizontal: 'horizontal',\n /** Ratio 3:2 */\n vertical: 'vertical',\n /** Ratio 1:1 */\n square: 'square',\n /** Ratio constrained by the parent. */\n free: 'free',\n} as const;\nexport type AspectRatio = ValueOf<typeof AspectRatio>;\n\n/**\n * Semantic info about the purpose of the component\n */\nexport const Kind = {\n info: 'info',\n success: 'success',\n warning: 'warning',\n error: 'error',\n} as const;\nexport type Kind = ValueOf<typeof Kind>;\n"],"names":["Alignment","bottom","center","end","left","right","spaceAround","spaceBetween","start","top","ColorPalette","primary","secondary","blue","dark","green","yellow","red","light","grey","ColorVariant","D1","D2","L1","L2","L3","L4","L5","L6","N","Theme","Size","xxs","xs","s","m","l","xl","xxl","tiny","regular","medium","big","huge","Orientation","horizontal","vertical","Emphasis","low","high","TypographyInterface","overline","caption","body1","body2","subtitle1","subtitle2","title","headline","display1","TypographyTitleCustom","title1","title2","title3","title4","title5","title6","TypographyCustom","intro","body","quote","button","Typography","custom","AspectRatio","original","wide","square","free","Kind","info","success","warning","error"],"mappings":";;AAEA;;;IAGaA,SAAS,GAAG;AACrBC,EAAAA,MAAM,EAAE,QADa;AAErBC,EAAAA,MAAM,EAAE,QAFa;AAGrBC,EAAAA,GAAG,EAAE,KAHgB;AAIrBC,EAAAA,IAAI,EAAE,MAJe;AAKrBC,EAAAA,KAAK,EAAE,OALc;AAMrBC,EAAAA,WAAW,EAAE,cANQ;AAOrBC,EAAAA,YAAY,EAAE,eAPO;AAQrBC,EAAAA,KAAK,EAAE,OARc;AASrBC,EAAAA,GAAG,EAAE;AATgB;;AAezB;;;IAGaC,YAAY,GAAG;AACxBC,EAAAA,OAAO,EAAE,SADe;AAExBC,EAAAA,SA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IAGaC,IAAI,GAAG;AAChBC,EAAAA,IAAI,EAAE,MADU;AAEhBC,EAAAA,OAAO,EAAE,SAFO;AAGhBC,EAAAA,OAAO,EAAE,SAHO;AAIhBC,EAAAA,KAAK,EAAE;AAJS;;;;"}
@@ -1,6 +1,9 @@
1
1
  import { useEffect } from 'react';
2
2
  import { D as DOCUMENT } from './constants.js';
3
3
 
4
+ /** CSS selector listing all tabbable elements. */
5
+
6
+ var TABBABLE_ELEMENTS_SELECTOR = "a[href]:not([tabindex=\"-1\"], [disabled], [aria-disabled]),\nbutton:not([tabindex=\"-1\"], [disabled], [aria-disabled]),\ntextarea:not([tabindex=\"-1\"], [disabled], [aria-disabled]),\ninput[type=\"text\"]:not([tabindex=\"-1\"], [disabled], [aria-disabled]),\ninput[type=\"radio\"]:not([tabindex=\"-1\"], [disabled], [aria-disabled]),\ninput[type=\"checkbox\"]:not([tabindex=\"-1\"], [disabled], [aria-disabled]),\n[tabindex]:not([tabindex=\"-1\"], [disabled], [aria-disabled])";
4
7
  /**
5
8
  * Get first and last elements focusable in an element.
6
9
  *
@@ -9,7 +12,7 @@ import { D as DOCUMENT } from './constants.js';
9
12
  */
10
13
 
11
14
  function getFocusable(parentElement) {
12
- var focusableElements = parentElement.querySelectorAll('a[href]:not([tabindex="-1"]), button:not([tabindex="-1"]), textarea:not([tabindex="-1"]), input[type="text"]:not([tabindex="-1"]), input[type="radio"]:not([tabindex="-1"]), input[type="checkbox"]:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])');
15
+ var focusableElements = parentElement.querySelectorAll(TABBABLE_ELEMENTS_SELECTOR);
13
16
 
14
17
  if (focusableElements.length <= 0) {
15
18
  return {};
@@ -52,23 +55,26 @@ function useFocusTrap(focusZoneElement, focusElement) {
52
55
  return;
53
56
  }
54
57
 
55
- var _getFocusable = getFocusable(focusZoneElement),
56
- first = _getFocusable.first,
57
- last = _getFocusable.last; // Prevent focus switch if no focusable available.
58
+ var focusable = getFocusable(focusZoneElement); // Prevent focus switch if no focusable available.
58
59
 
60
+ if (!focusable.first) {
61
+ evt.preventDefault();
62
+ return;
63
+ }
59
64
 
60
- if (!first) {
65
+ if ( // No previous focus
66
+ !document.activeElement || // Previous focus is at the end of the focus zone.
67
+ !evt.shiftKey && document.activeElement === focusable.last || // Previous focus is outside the focus zone
68
+ !focusZoneElement.contains(document.activeElement)) {
69
+ focusable.first.focus();
61
70
  evt.preventDefault();
62
71
  return;
63
72
  }
64
73
 
65
- if (evt.shiftKey) {
66
- if (document.activeElement === first) {
67
- last === null || last === void 0 ? void 0 : last.focus();
68
- evt.preventDefault();
69
- }
70
- } else if (document.activeElement === last) {
71
- first === null || first === void 0 ? void 0 : first.focus();
74
+ if ( // Focus order reversed
75
+ evt.shiftKey && // Previous focus is at the start of the focus zone.
76
+ document.activeElement === focusable.first) {
77
+ focusable.last.focus();
72
78
  evt.preventDefault();
73
79
  }
74
80
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useFocusTrap.js","sources":["../../../src/hooks/useFocusTrap.ts"],"sourcesContent":["import { useEffect } from 'react';\n\nimport { DOCUMENT } from '@lumx/react/constants';\n\n/**\n * Get first and last elements focusable in an element.\n *\n * @param parentElement The element in which to search focusable elements.\n * @return first and last focusable elements\n */\nfunction getFocusable(parentElement: HTMLElement) {\n const focusableElements = parentElement.querySelectorAll<HTMLElement>(\n 'a[href]:not([tabindex=\"-1\"]), button:not([tabindex=\"-1\"]), textarea:not([tabindex=\"-1\"]), input[type=\"text\"]:not([tabindex=\"-1\"]), input[type=\"radio\"]:not([tabindex=\"-1\"]), input[type=\"checkbox\"]:not([tabindex=\"-1\"]), [tabindex]:not([tabindex=\"-1\"])',\n );\n\n if (focusableElements.length <= 0) {\n return {};\n }\n\n const first = focusableElements[0];\n const last = focusableElements[focusableElements.length - 1];\n return { first, last };\n}\n\n/**\n * Add a key down event handler to the given root element (document.body by default) to trap the move of focus\n * (TAB and SHIFT-TAB keys) inside the given focusZoneElement.\n * Will focus the given focus element when activating the focus trap.\n *\n * @param focusZoneElement The element in which to trap the focus.\n * @param focusElement The element to focus when the focus trap is activated.\n * @param rootElement The element on which the key down event will be placed.\n */\nexport function useFocusTrap(\n focusZoneElement: HTMLElement | null,\n focusElement?: HTMLElement | null,\n rootElement = DOCUMENT?.body,\n): void {\n useEffect(() => {\n if (rootElement && focusZoneElement) {\n (document.activeElement as HTMLElement)?.blur();\n if (focusElement) {\n focusElement.focus();\n }\n\n const onKeyDown = (evt: KeyboardEvent) => {\n const { key } = evt;\n if (key !== 'Tab') {\n return;\n }\n const { first, last } = getFocusable(focusZoneElement);\n\n // Prevent focus switch if no focusable available.\n if (!first) {\n evt.preventDefault();\n return;\n }\n\n if (evt.shiftKey) {\n if (document.activeElement === first) {\n last?.focus();\n evt.preventDefault();\n }\n } else if (document.activeElement === last) {\n first?.focus();\n evt.preventDefault();\n }\n };\n rootElement.addEventListener('keydown', onKeyDown);\n return () => rootElement.removeEventListener('keydown', onKeyDown);\n }\n return undefined;\n }, [focusElement, focusZoneElement, rootElement]);\n}\n"],"names":["getFocusable","parentElement","focusableElements","querySelectorAll","length","first","last","useFocusTrap","focusZoneElement","focusElement","rootElement","DOCUMENT","body","useEffect","document","activeElement","blur","focus","onKeyDown","evt","key","preventDefault","shiftKey","addEventListener","removeEventListener","undefined"],"mappings":";;;AAIA;;;;;;;AAMA,SAASA,YAAT,CAAsBC,aAAtB,EAAkD;AAC9C,MAAMC,iBAAiB,GAAGD,aAAa,CAACE,gBAAd,CACtB,2PADsB,CAA1B;;AAIA,MAAID,iBAAiB,CAACE,MAAlB,IAA4B,CAAhC,EAAmC;AAC/B,WAAO,EAAP;AACH;;AAED,MAAMC,KAAK,GAAGH,iBAAiB,CAAC,CAAD,CAA/B;AACA,MAAMI,IAAI,GAAGJ,iBAAiB,CAACA,iBAAiB,CAACE,MAAlB,GAA2B,CAA5B,CAA9B;AACA,SAAO;AAAEC,IAAAA,KAAK,EAALA,KAAF;AAASC,IAAAA,IAAI,EAAJA;AAAT,GAAP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,OAAP;AACH;;AACD,WAAOO,SAAP;AACH,GAlCQ,EAkCN,CAAChB,YAAD,EAAeD,gBAAf,EAAiCE,WAAjC,CAlCM,CAAT;AAmCH;;;;"}
1
+ {"version":3,"file":"useFocusTrap.js","sources":["../../../src/hooks/useFocusTrap.ts"],"sourcesContent":["import { useEffect } from 'react';\n\nimport { DOCUMENT } from '@lumx/react/constants';\n\n/** CSS selector listing all tabbable elements. */\nconst TABBABLE_ELEMENTS_SELECTOR = `a[href]:not([tabindex=\"-1\"], [disabled], [aria-disabled]),\nbutton:not([tabindex=\"-1\"], [disabled], [aria-disabled]),\ntextarea:not([tabindex=\"-1\"], [disabled], [aria-disabled]),\ninput[type=\"text\"]:not([tabindex=\"-1\"], [disabled], [aria-disabled]),\ninput[type=\"radio\"]:not([tabindex=\"-1\"], [disabled], [aria-disabled]),\ninput[type=\"checkbox\"]:not([tabindex=\"-1\"], [disabled], [aria-disabled]),\n[tabindex]:not([tabindex=\"-1\"], [disabled], [aria-disabled])`;\n\n/**\n * Get first and last elements focusable in an element.\n *\n * @param parentElement The element in which to search focusable elements.\n * @return first and last focusable elements\n */\nfunction getFocusable(parentElement: HTMLElement) {\n const focusableElements = parentElement.querySelectorAll<HTMLElement>(TABBABLE_ELEMENTS_SELECTOR);\n\n if (focusableElements.length <= 0) {\n return {};\n }\n\n const first = focusableElements[0];\n const last = focusableElements[focusableElements.length - 1];\n return { first, last };\n}\n\n/**\n * Add a key down event handler to the given root element (document.body by default) to trap the move of focus\n * (TAB and SHIFT-TAB keys) inside the given focusZoneElement.\n * Will focus the given focus element when activating the focus trap.\n *\n * @param focusZoneElement The element in which to trap the focus.\n * @param focusElement The element to focus when the focus trap is activated.\n * @param rootElement The element on which the key down event will be placed.\n */\nexport function useFocusTrap(\n focusZoneElement: HTMLElement | null,\n focusElement?: HTMLElement | null,\n rootElement = DOCUMENT?.body,\n): void {\n useEffect(() => {\n if (rootElement && focusZoneElement) {\n (document.activeElement as HTMLElement)?.blur();\n if (focusElement) {\n focusElement.focus();\n }\n\n const onKeyDown = (evt: KeyboardEvent) => {\n const { key } = evt;\n if (key !== 'Tab') {\n return;\n }\n const focusable = getFocusable(focusZoneElement);\n\n // Prevent focus switch if no focusable available.\n if (!focusable.first) {\n evt.preventDefault();\n return;\n }\n\n if (\n // No previous focus\n !document.activeElement ||\n // Previous focus is at the end of the focus zone.\n (!evt.shiftKey && document.activeElement === focusable.last) ||\n // Previous focus is outside the focus zone\n !focusZoneElement.contains(document.activeElement)\n ) {\n focusable.first.focus();\n evt.preventDefault();\n return;\n }\n\n if (\n // Focus order reversed\n evt.shiftKey &&\n // Previous focus is at the start of the focus zone.\n document.activeElement === focusable.first\n ) {\n focusable.last.focus();\n evt.preventDefault();\n }\n };\n rootElement.addEventListener('keydown', onKeyDown);\n return () => rootElement.removeEventListener('keydown', onKeyDown);\n }\n return undefined;\n }, [focusElement, focusZoneElement, rootElement]);\n}\n"],"names":["TABBABLE_ELEMENTS_SELECTOR","getFocusable","parentElement","focusableElements","querySelectorAll","length","first","last","useFocusTrap","focusZoneElement","focusElement","rootElement","DOCUMENT","body","useEffect","document","activeElement","blur","focus","onKeyDown","evt","key","focusable","preventDefault","shiftKey","contains","addEventListener","removeEventListener","undefined"],"mappings":";;;AAIA;;AACA,IAAMA,0BAA0B,meAAhC;AAQA;;;;;;;AAMA,SAASC,YAAT,CAAsBC,aAAtB,EAAkD;AAC9C,MAAMC,iBAAiB,GAAGD,aAAa,CAACE,gBAAd,CAA4CJ,0BAA5C,CAA1B;;AAEA,MAAIG,iBAAiB,CAACE,MAAlB,IAA4B,CAAhC,EAAmC;AAC/B,WAAO,EAAP;AACH;;AAED,MAAMC,KAAK,GAAGH,iBAAiB,CAAC,CAAD,CAA/B;AACA,MAAMI,IAAI,GAAGJ,iBAAiB,CAACA,iBAAiB,CAACE,MAAlB,GAA2B,CAA5B,CAA9B;AACA,SAAO;AAAEC,IAAAA,KAAK,EAALA,KAAF;AAASC,IAAAA,IAAI,EAAJA;AA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AMR,WAAW,CAACgB,mBAAZ,CAAgC,SAAhC,EAA2CR,SAA3C,CAAN;AAAA,OAAP;AACH;;AACD,WAAOS,SAAP;AACH,GA/CQ,EA+CN,CAAClB,YAAD,EAAeD,gBAAf,EAAiCE,WAAjC,CA/CM,CAAT;AAgDH;;;;"}
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.14",
11
- "@lumx/icons": "^2.2.14",
10
+ "@lumx/core": "^2.2.17",
11
+ "@lumx/icons": "^2.2.17",
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.14",
124
- "gitHead": "f91f87393935f907dffee38cff5f44721c2343d7"
123
+ "version": "2.2.17",
124
+ "gitHead": "61e7475ca5f8a66e8e672cefe8f694b823051afd"
125
125
  }
@@ -333,7 +333,7 @@ export const DialogWithFocusableElements = ({ theme }: any) => {
333
333
  label="Checkbox input"
334
334
  />
335
335
 
336
- <FlexBox orientation="horizontal">
336
+ <FlexBox orientation="horizontal" hAlign="bottom" gap="regular">
337
337
  <DatePickerField
338
338
  locale="fr"
339
339
  label="Start date"
@@ -366,6 +366,8 @@ export const DialogWithFocusableElements = ({ theme }: any) => {
366
366
  ))}
367
367
  </List>
368
368
  </Select>
369
+
370
+ <Button isDisabled>Disabled button (focus ignored)</Button>
369
371
  </FlexBox>
370
372
 
371
373
  {/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */}
@@ -152,6 +152,8 @@ exports[`<Dialog> Snapshots and structure should render story DialogWithFocusabl
152
152
  theme="light"
153
153
  />
154
154
  <FlexBox
155
+ gap="regular"
156
+ hAlign="bottom"
155
157
  orientation="horizontal"
156
158
  >
157
159
  <DatePickerField
@@ -210,6 +212,14 @@ exports[`<Dialog> Snapshots and structure should render story DialogWithFocusabl
210
212
  </ListItem>
211
213
  </List>
212
214
  </Select>
215
+ <Button
216
+ emphasis="high"
217
+ isDisabled={true}
218
+ size="m"
219
+ theme="light"
220
+ >
221
+ Disabled button (focus ignored)
222
+ </Button>
213
223
  </FlexBox>
214
224
  <div
215
225
  tabIndex={0}
@@ -1,5 +1,5 @@
1
1
  import { mdiPencil } from '@lumx/icons';
2
- import { Alignment, Button, Icon, Orientation } from '@lumx/react';
2
+ import { Alignment, Button, Icon, Orientation, Size } from '@lumx/react';
3
3
  import { boolean, number, select, text } from '@storybook/addon-knobs';
4
4
  import fromPairs from 'lodash/fromPairs';
5
5
  import React from 'react';
@@ -18,6 +18,7 @@ const flexViewKnobConfigs: Array<
18
18
  ['fillSpace', boolean],
19
19
  ['noShrink', boolean],
20
20
  ['wrap', boolean],
21
+ ['gap', select, [DEFAULT_PROPS.gap, Size.regular, Size.medium, Size.big, Size.huge]],
21
22
  ['hAlign', select, [DEFAULT_PROPS.hAlign, Alignment.center, Alignment.top, Alignment.bottom]],
22
23
  ['vAlign', select, [DEFAULT_PROPS.vAlign, Alignment.center, Alignment.right, Alignment.left]],
23
24
  ['orientation', select, [undefined, Orientation.horizontal, Orientation.vertical]],
@@ -52,7 +53,7 @@ const setupFlexBoxKnobs = (group: string, knobs: FlexBoxPropName[] = []) =>
52
53
  const flexChildKnobs: FlexBoxPropName[] = ['fillSpace', 'noShrink', 'marginAuto'];
53
54
 
54
55
  export const Flex = () => (
55
- <FlexBox {...setupFlexBoxKnobs('-flex container', ['orientation', 'hAlign', 'vAlign', 'wrap'])}>
56
+ <FlexBox {...setupFlexBoxKnobs('-flex container', ['orientation', 'hAlign', 'vAlign', 'wrap', 'gap'])}>
56
57
  <FlexBox {...setupFlexBoxKnobs('start', flexChildKnobs)}>
57
58
  <Icon icon={mdiPencil} />
58
59
  </FlexBox>
@@ -78,6 +79,16 @@ const vAlign = (prefix?: string) =>
78
79
  Alignment.center,
79
80
  );
80
81
 
82
+ const orientation = (prefix?: string) =>
83
+ select(
84
+ `${prefix ? `${prefix}: ` : ''}Set orientation`,
85
+ [Orientation.vertical, Orientation.horizontal],
86
+ Orientation.vertical,
87
+ );
88
+
89
+ const gapSize = (prefix?: string) =>
90
+ select(`${prefix ? `${prefix}: ` : ''}Gap size`, [Size.regular, Size.medium, Size.big, Size.huge], Size.regular);
91
+
81
92
  export const HorizontalFlex = () => (
82
93
  <FlexBox
83
94
  orientation={Orientation.horizontal}
@@ -122,6 +133,21 @@ export const VerticalFlex = () => (
122
133
  </FlexBox>
123
134
  );
124
135
 
136
+ export const GapSizeFlex = () => (
137
+ <FlexBox orientation={orientation()} gap={gapSize()}>
138
+ <Button>Item 1</Button>
139
+ <FlexBox vAlign={Alignment.left}>
140
+ <Button>Item 2</Button>
141
+ </FlexBox>
142
+ <FlexBox>
143
+ <Button>Item 3</Button>
144
+ </FlexBox>
145
+ <FlexBox vAlign={Alignment.right}>
146
+ <Button>Item 4</Button>
147
+ </FlexBox>
148
+ </FlexBox>
149
+ );
150
+
125
151
  export const WrapFlex = () => (
126
152
  <FlexBox
127
153
  orientation={Orientation.horizontal}
@@ -6,7 +6,7 @@ import React, { forwardRef, ReactNode } from 'react';
6
6
  import { Size } from '..';
7
7
 
8
8
  export type MarginAutoAlignment = Extract<Alignment, 'top' | 'bottom' | 'right' | 'left'>;
9
- export type GapSize = Extract<Size, 'regular' | 'big' | 'huge'>;
9
+ export type GapSize = Extract<Size, 'regular' | 'medium' | 'big' | 'huge'>;
10
10
 
11
11
  /**
12
12
  * Defines the props of the component.
@@ -89,6 +89,86 @@ Array [
89
89
  ]
90
90
  `;
91
91
 
92
+ exports[`<FlexBox> Snapshots and structure should render story 'GapSizeFlex' 1`] = `
93
+ Array [
94
+ <div
95
+ className="lumx-flex-box lumx-flex-box--orientation-vertical lumx-flex-box--gap-regular"
96
+ >
97
+ <Button
98
+ emphasis="high"
99
+ size="m"
100
+ theme="light"
101
+ >
102
+ Item 1
103
+ </Button>
104
+ <FlexBox
105
+ vAlign="left"
106
+ >
107
+ <Button
108
+ emphasis="high"
109
+ size="m"
110
+ theme="light"
111
+ >
112
+ Item 2
113
+ </Button>
114
+ </FlexBox>
115
+ <FlexBox>
116
+ <Button
117
+ emphasis="high"
118
+ size="m"
119
+ theme="light"
120
+ >
121
+ Item 3
122
+ </Button>
123
+ </FlexBox>
124
+ <FlexBox
125
+ vAlign="right"
126
+ >
127
+ <Button
128
+ emphasis="high"
129
+ size="m"
130
+ theme="light"
131
+ >
132
+ Item 4
133
+ </Button>
134
+ </FlexBox>
135
+ </div>,
136
+ <div
137
+ className="lumx-flex-box lumx-flex-box--orientation-horizontal lumx-flex-box--v-align-left"
138
+ >
139
+ <Button
140
+ emphasis="high"
141
+ size="m"
142
+ theme="light"
143
+ >
144
+ Item 2
145
+ </Button>
146
+ </div>,
147
+ <div
148
+ className="lumx-flex-box"
149
+ >
150
+ <Button
151
+ emphasis="high"
152
+ size="m"
153
+ theme="light"
154
+ >
155
+ Item 3
156
+ </Button>
157
+ </div>,
158
+ <div
159
+ className="lumx-flex-box lumx-flex-box--orientation-horizontal lumx-flex-box--v-align-right"
160
+ >
161
+ <Button
162
+ emphasis="high"
163
+ size="m"
164
+ theme="light"
165
+ >
166
+ Item 4
167
+ </Button>
168
+ </div>,
169
+ ]
170
+ `;
171
+
92
172
  exports[`<FlexBox> Snapshots and structure should render story 'HorizontalFlex' 1`] = `
93
173
  Array [
94
174
  <div
@@ -67,6 +67,7 @@ export const Size = {
67
67
  xxl: 'xxl',
68
68
  tiny: 'tiny',
69
69
  regular: 'regular',
70
+ medium: 'medium',
70
71
  big: 'big',
71
72
  huge: 'huge',
72
73
  } as const;
@@ -46,6 +46,8 @@ const setup = (props: SetupProps = {}, shallowRendering = true) => {
46
46
  (n: ShallowWrapper | ReactWrapper) => n.name() === 'InputHelper' && n.prop('kind') === Kind.info,
47
47
  ),
48
48
  input: wrapper.find('#select-uid:not(SelectMultipleField)').first(),
49
+ chip: wrapper.find('Chip'),
50
+ inputWrapper: wrapper.find('.lumx-select__wrapper'),
49
51
  props,
50
52
  wrapper,
51
53
  };
@@ -188,6 +190,29 @@ describe(`<SelectMultiple>`, () => {
188
190
  expect(error).toExist();
189
191
  expect(helper).toExist();
190
192
  });
193
+
194
+ it('should have a data-id as prop', () => {
195
+ const { inputWrapper } = setup(
196
+ {
197
+ 'data-id': 'select',
198
+ },
199
+ false,
200
+ );
201
+
202
+ expect(inputWrapper.prop('data-id')).toEqual('select');
203
+ });
204
+
205
+ it('should have a data-id as prop with Chip variant', () => {
206
+ const { chip } = setup(
207
+ {
208
+ 'data-id': 'select',
209
+ variant: SelectVariant.chip,
210
+ },
211
+ false,
212
+ );
213
+
214
+ expect(chip.prop('data-id')).toEqual('select');
215
+ });
191
216
  });
192
217
 
193
218
  // 3. Test events.
@@ -73,6 +73,7 @@ export const SelectMultipleField: React.FC<SelectMultipleProps> = ({
73
73
  theme,
74
74
  value,
75
75
  variant,
76
+ ...forwardedProps
76
77
  }) => (
77
78
  <>
78
79
  {variant === SelectVariant.input && (
@@ -99,6 +100,7 @@ export const SelectMultipleField: React.FC<SelectMultipleProps> = ({
99
100
  onKeyDown={handleKeyboardNav}
100
101
  tabIndex={isDisabled ? undefined : 0}
101
102
  aria-disabled={isDisabled || undefined}
103
+ {...forwardedProps}
102
104
  >
103
105
  <div className={`${CLASSNAME}__chips`}>
104
106
  {!isEmpty &&
@@ -139,6 +141,7 @@ export const SelectMultipleField: React.FC<SelectMultipleProps> = ({
139
141
  onClick={onInputClick}
140
142
  ref={anchorRef as RefObject<HTMLAnchorElement>}
141
143
  theme={theme}
144
+ {...forwardedProps}
142
145
  >
143
146
  {isEmpty && <span>{label}</span>}
144
147
 
@@ -2,6 +2,15 @@ import { useEffect } from 'react';
2
2
 
3
3
  import { DOCUMENT } from '@lumx/react/constants';
4
4
 
5
+ /** CSS selector listing all tabbable elements. */
6
+ const TABBABLE_ELEMENTS_SELECTOR = `a[href]:not([tabindex="-1"], [disabled], [aria-disabled]),
7
+ button:not([tabindex="-1"], [disabled], [aria-disabled]),
8
+ textarea:not([tabindex="-1"], [disabled], [aria-disabled]),
9
+ input[type="text"]:not([tabindex="-1"], [disabled], [aria-disabled]),
10
+ input[type="radio"]:not([tabindex="-1"], [disabled], [aria-disabled]),
11
+ input[type="checkbox"]:not([tabindex="-1"], [disabled], [aria-disabled]),
12
+ [tabindex]:not([tabindex="-1"], [disabled], [aria-disabled])`;
13
+
5
14
  /**
6
15
  * Get first and last elements focusable in an element.
7
16
  *
@@ -9,9 +18,7 @@ import { DOCUMENT } from '@lumx/react/constants';
9
18
  * @return first and last focusable elements
10
19
  */
11
20
  function getFocusable(parentElement: HTMLElement) {
12
- const focusableElements = parentElement.querySelectorAll<HTMLElement>(
13
- 'a[href]:not([tabindex="-1"]), button:not([tabindex="-1"]), textarea:not([tabindex="-1"]), input[type="text"]:not([tabindex="-1"]), input[type="radio"]:not([tabindex="-1"]), input[type="checkbox"]:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])',
14
- );
21
+ const focusableElements = parentElement.querySelectorAll<HTMLElement>(TABBABLE_ELEMENTS_SELECTOR);
15
22
 
16
23
  if (focusableElements.length <= 0) {
17
24
  return {};
@@ -48,21 +55,34 @@ export function useFocusTrap(
48
55
  if (key !== 'Tab') {
49
56
  return;
50
57
  }
51
- const { first, last } = getFocusable(focusZoneElement);
58
+ const focusable = getFocusable(focusZoneElement);
52
59
 
53
60
  // Prevent focus switch if no focusable available.
54
- if (!first) {
61
+ if (!focusable.first) {
62
+ evt.preventDefault();
63
+ return;
64
+ }
65
+
66
+ if (
67
+ // No previous focus
68
+ !document.activeElement ||
69
+ // Previous focus is at the end of the focus zone.
70
+ (!evt.shiftKey && document.activeElement === focusable.last) ||
71
+ // Previous focus is outside the focus zone
72
+ !focusZoneElement.contains(document.activeElement)
73
+ ) {
74
+ focusable.first.focus();
55
75
  evt.preventDefault();
56
76
  return;
57
77
  }
58
78
 
59
- if (evt.shiftKey) {
60
- if (document.activeElement === first) {
61
- last?.focus();
62
- evt.preventDefault();
63
- }
64
- } else if (document.activeElement === last) {
65
- first?.focus();
79
+ if (
80
+ // Focus order reversed
81
+ evt.shiftKey &&
82
+ // Previous focus is at the start of the focus zone.
83
+ document.activeElement === focusable.first
84
+ ) {
85
+ focusable.last.focus();
66
86
  evt.preventDefault();
67
87
  }
68
88
  };
package/types.d.ts CHANGED
@@ -95,6 +95,7 @@ export declare const Size: {
95
95
  readonly xxl: "xxl";
96
96
  readonly tiny: "tiny";
97
97
  readonly regular: "regular";
98
+ readonly medium: "medium";
98
99
  readonly big: "big";
99
100
  readonly huge: "huge";
100
101
  };
@@ -1091,7 +1092,7 @@ export interface FlagProps extends GenericProps {
1091
1092
  */
1092
1093
  export declare const Flag: Comp<FlagProps, HTMLDivElement>;
1093
1094
  export declare type MarginAutoAlignment = Extract<Alignment, "top" | "bottom" | "right" | "left">;
1094
- export declare type GapSize = Extract<Size, "regular" | "big" | "huge">;
1095
+ export declare type GapSize = Extract<Size, "regular" | "medium" | "big" | "huge">;
1095
1096
  /**
1096
1097
  * Defines the props of the component.
1097
1098
  */