@lumx/react 2.2.12-alpha.1 → 2.2.13

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.
Files changed (35) hide show
  1. package/esm/_internal/CommentBlock.js +12 -5
  2. package/esm/_internal/CommentBlock.js.map +1 -1
  3. package/esm/_internal/Dropdown2.js +5 -2
  4. package/esm/_internal/Dropdown2.js.map +1 -1
  5. package/esm/_internal/Icon2.js +20 -40
  6. package/esm/_internal/Icon2.js.map +1 -1
  7. package/esm/_internal/List2.js +11 -2
  8. package/esm/_internal/List2.js.map +1 -1
  9. package/esm/_internal/Popover2.js +69 -4
  10. package/esm/_internal/Popover2.js.map +1 -1
  11. package/esm/_internal/Slides.js +1 -24
  12. package/esm/_internal/Slides.js.map +1 -1
  13. package/esm/_internal/Tooltip2.js +1 -3
  14. package/esm/_internal/Tooltip2.js.map +1 -1
  15. package/esm/_internal/comment-block.js +8 -0
  16. package/esm/_internal/comment-block.js.map +1 -1
  17. package/package.json +4 -4
  18. package/src/components/autocomplete/__snapshots__/Autocomplete.test.tsx.snap +4 -0
  19. package/src/components/autocomplete/__snapshots__/AutocompleteMultiple.test.tsx.snap +1 -0
  20. package/src/components/comment-block/CommentBlock.stories.tsx +7 -4
  21. package/src/components/comment-block/CommentBlock.tsx +13 -3
  22. package/src/components/comment-block/__snapshots__/CommentBlock.test.tsx.snap +10 -5
  23. package/src/components/dialog/__snapshots__/Dialog.test.tsx.snap +1 -0
  24. package/src/components/dropdown/Dropdown.tsx +5 -0
  25. package/src/components/dropdown/__snapshots__/Dropdown.test.tsx.snap +1 -0
  26. package/src/components/icon/Icon.stories.tsx +12 -0
  27. package/src/components/icon/Icon.tsx +16 -37
  28. package/src/components/icon/__snapshots__/Icon.test.tsx.snap +1 -1
  29. package/src/components/list/List.tsx +12 -2
  30. package/src/components/list/__snapshots__/List.test.tsx.snap +5 -5
  31. package/src/components/popover/Popover.tsx +42 -2
  32. package/src/components/select/__snapshots__/Select.test.tsx.snap +1 -0
  33. package/src/components/select/__snapshots__/SelectMultiple.test.tsx.snap +2 -0
  34. package/src/components/tooltip/useTooltipOpen.tsx +0 -1
  35. package/types.d.ts +9 -1
@@ -4,6 +4,7 @@ import React, { forwardRef, Children } from 'react';
4
4
  import { g as getRootClassName, c as classnames, h as handleBasicClasses } from './getRootClassName.js';
5
5
  import { A as Avatar } from './Avatar2.js';
6
6
  import isFunction from 'lodash/isFunction';
7
+ import { T as Tooltip } from './Tooltip2.js';
7
8
 
8
9
  /**
9
10
  * Comment block variants.
@@ -44,6 +45,7 @@ var CommentBlock = forwardRef(function (props, ref) {
44
45
  children = props.children,
45
46
  className = props.className,
46
47
  date = props.date,
48
+ fullDate = props.fullDate,
47
49
  hasActions = props.hasActions,
48
50
  headerActions = props.headerActions,
49
51
  isOpen = props.isOpen,
@@ -55,7 +57,7 @@ var CommentBlock = forwardRef(function (props, ref) {
55
57
  text = props.text,
56
58
  theme = props.theme,
57
59
  variant = props.variant,
58
- forwardedProps = _objectWithoutProperties(props, ["actions", "avatarProps", "children", "className", "date", "hasActions", "headerActions", "isOpen", "isRelevant", "name", "onClick", "onMouseEnter", "onMouseLeave", "text", "theme", "variant"]);
60
+ forwardedProps = _objectWithoutProperties(props, ["actions", "avatarProps", "children", "className", "date", "fullDate", "hasActions", "headerActions", "isOpen", "isRelevant", "name", "onClick", "onMouseEnter", "onMouseLeave", "text", "theme", "variant"]);
59
61
 
60
62
  var enterKeyPress = function enterKeyPress(evt) {
61
63
  if (evt.key === 'Enter' && isFunction(onClick)) {
@@ -97,13 +99,18 @@ var CommentBlock = forwardRef(function (props, ref) {
97
99
  onMouseLeave: onMouseLeave,
98
100
  role: "button",
99
101
  tabIndex: onClick ? 0 : -1
100
- }, name), date && React.createElement("span", {
101
- className: "".concat(CLASSNAME, "__date")
102
- }, date), headerActions && React.createElement("span", {
102
+ }, name), headerActions && React.createElement("span", {
103
103
  className: "".concat(CLASSNAME, "__header-actions")
104
104
  }, headerActions)), React.createElement("div", {
105
105
  className: "".concat(CLASSNAME, "__text")
106
- }, text)), hasActions && React.createElement("div", {
106
+ }, text), date && (fullDate ? React.createElement(Tooltip, {
107
+ label: fullDate,
108
+ placement: "top"
109
+ }, React.createElement("span", {
110
+ className: "".concat(CLASSNAME, "__date")
111
+ }, date)) : React.createElement("span", {
112
+ className: "".concat(CLASSNAME, "__date")
113
+ }, date))), hasActions && React.createElement("div", {
107
114
  className: "".concat(CLASSNAME, "__actions")
108
115
  }, actions))), hasChildren && isOpen && React.createElement("div", {
109
116
  className: "".concat(CLASSNAME, "__children")
@@ -1 +1 @@
1
- {"version":3,"file":"CommentBlock.js","sources":["../../../src/components/comment-block/CommentBlock.tsx"],"sourcesContent":["import React, { Children, forwardRef, KeyboardEvent, KeyboardEventHandler, ReactNode } from 'react';\n\nimport classNames from 'classnames';\n\nimport { Avatar, Size, Theme } from '@lumx/react';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses, ValueOf } from '@lumx/react/utils';\n\nimport isFunction from 'lodash/isFunction';\nimport { AvatarProps } from '../avatar/Avatar';\n\n/**\n * Comment block variants.\n */\nexport const CommentBlockVariant = {\n indented: 'indented',\n linear: 'linear',\n} as const;\nexport type CommentBlockVariant = ValueOf<typeof CommentBlockVariant>;\n\n/**\n * Defines the props of the component.\n */\nexport interface CommentBlockProps extends GenericProps {\n /** Action toolbar content. */\n actions?: ReactNode;\n /** Props to pass to the avatar. */\n avatarProps: AvatarProps;\n /** Comment block replies. */\n children?: ReactNode;\n /** Comment date. */\n date: string;\n /** Whether the component has actions to display or not. */\n hasActions?: boolean;\n /** Action toolbar header content. */\n headerActions?: ReactNode;\n /** Whether the component is open or not. */\n isOpen?: boolean;\n /** Whether the comment is relevant or not. */\n isRelevant?: boolean;\n /** Comment author name. */\n name: string;\n /** On click callback. */\n onClick?(): void;\n /** On mouse enter callback. */\n onMouseEnter?(): void;\n /** On mouse leave callback. */\n onMouseLeave?(): void;\n /** Comment content. */\n text: ReactNode | string;\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** Comment variant. */\n variant?: CommentBlockVariant;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'CommentBlock';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<CommentBlockProps> = {\n theme: Theme.light,\n variant: CommentBlockVariant.indented,\n};\n\n/**\n * CommentBlock component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const CommentBlock: Comp<CommentBlockProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n actions,\n avatarProps,\n children,\n className,\n date,\n hasActions,\n headerActions,\n isOpen,\n isRelevant,\n name,\n onClick,\n onMouseEnter,\n onMouseLeave,\n text,\n theme,\n variant,\n ...forwardedProps\n } = props;\n const enterKeyPress: KeyboardEventHandler<HTMLElement> = (evt: KeyboardEvent<HTMLElement>) => {\n if (evt.key === 'Enter' && isFunction(onClick)) {\n onClick();\n }\n };\n const hasChildren = Children.count(children) > 0;\n\n return (\n <div\n ref={ref}\n className={classNames(\n className,\n handleBasicClasses({\n hasChildren: hasChildren && isOpen,\n hasIndentedChildren: hasChildren && variant === CommentBlockVariant.indented,\n hasLinearChildren: hasChildren && variant === CommentBlockVariant.linear,\n isRelevant,\n prefix: CLASSNAME,\n theme,\n }),\n )}\n {...forwardedProps}\n >\n <div className={`${CLASSNAME}__wrapper`}>\n <div className={`${CLASSNAME}__avatar`}>\n <Avatar\n {...avatarProps}\n size={Size.m}\n tabIndex={onClick ? 0 : -1}\n onClick={onClick}\n onKeyPress={enterKeyPress}\n />\n </div>\n\n <div className={`${CLASSNAME}__container`}>\n <div className={`${CLASSNAME}__content`}>\n <div className={`${CLASSNAME}__meta`}>\n <span\n className={`${CLASSNAME}__name`}\n onClick={onClick}\n onKeyPress={enterKeyPress}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n role=\"button\"\n tabIndex={onClick ? 0 : -1}\n >\n {name}\n </span>\n {date && <span className={`${CLASSNAME}__date`}>{date}</span>}\n {headerActions && <span className={`${CLASSNAME}__header-actions`}>{headerActions}</span>}\n </div>\n\n <div className={`${CLASSNAME}__text`}>{text}</div>\n </div>\n {hasActions && <div className={`${CLASSNAME}__actions`}>{actions}</div>}\n </div>\n </div>\n\n {hasChildren && isOpen && <div className={`${CLASSNAME}__children`}>{children}</div>}\n </div>\n );\n});\nCommentBlock.displayName = COMPONENT_NAME;\nCommentBlock.className = CLASSNAME;\nCommentBlock.defaultProps = DEFAULT_PROPS;\n"],"names":["CommentBlockVariant","indented","linear","COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","theme","Theme","light","variant","CommentBlock","forwardRef","props","ref","actions","avatarProps","children","className","date","hasActions","headerActions","isOpen","isRelevant","name","onClick","onMouseEnter","onMouseLeave","text","forwardedProps","enterKeyPress","evt","key","isFunction","hasChildren","Children","count","classNames","handleBasicClasses","hasIndentedChildren","hasLinearChildren","prefix","Size","m","displayName","defaultProps"],"mappings":";;;;;;;AAUA;;;IAGaA,mBAAmB,GAAG;AAC/BC,EAAAA,QAAQ,EAAE,UADqB;AAE/BC,EAAAA,MAAM,EAAE;AAFuB;;AA0CnC;;;AAGA,IAAMC,cAAc,GAAG,cAAvB;AAEA;;;;AAGA,IAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAD,CAAlC;AAEA;;;;AAGA,IAAMG,aAAyC,GAAG;AAC9CC,EAAAA,KAAK,EAAEC,KAAK,CAACC,KADiC;AAE9CC,EAAAA,OAAO,EAAEV,mBAAmB,CAACC;AAFiB,CAAlD;AAKA;;;;;;;;IAOaU,YAAqD,GAAGC,UAAU,CAAC,UAACC,KAAD,EAAQC,GAAR,EAAgB;AAAA,MAExFC,OAFwF,GAmBxFF,KAnBwF,CAExFE,OAFwF;AAAA,MAGxFC,WAHwF,GAmBxFH,KAnBwF,CAGxFG,WAHwF;AAAA,MAIxFC,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,CADJ,EAoBKR,UAAU,IAAI;AAAK,IAAA,SAAS,YAAKhB,SAAL;AAAd,KAA0CW,OAA1C,CApBnB,CAXJ,CAfJ,EAkDKmB,WAAW,IAAIZ,MAAf,IAAyB;AAAK,IAAA,SAAS,YAAKlB,SAAL;AAAd,KAA2Ca,QAA3C,CAlD9B,CADJ;AAsDH,CAjF8E;AAkF/EN,YAAY,CAACiC,WAAb,GAA2BzC,cAA3B;AACAQ,YAAY,CAACO,SAAb,GAAyBd,SAAzB;AACAO,YAAY,CAACkC,YAAb,GAA4BvC,aAA5B;;;;"}
1
+ {"version":3,"file":"CommentBlock.js","sources":["../../../src/components/comment-block/CommentBlock.tsx"],"sourcesContent":["import React, { Children, forwardRef, KeyboardEvent, KeyboardEventHandler, ReactNode } from 'react';\n\nimport classNames from 'classnames';\n\nimport { Avatar, Size, Theme, Tooltip } from '@lumx/react';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses, ValueOf } from '@lumx/react/utils';\n\nimport isFunction from 'lodash/isFunction';\nimport { AvatarProps } from '../avatar/Avatar';\n\n/**\n * Comment block variants.\n */\nexport const CommentBlockVariant = {\n indented: 'indented',\n linear: 'linear',\n} as const;\nexport type CommentBlockVariant = ValueOf<typeof CommentBlockVariant>;\n\n/**\n * Defines the props of the component.\n */\nexport interface CommentBlockProps extends GenericProps {\n /** Action toolbar content. */\n actions?: ReactNode;\n /** Props to pass to the avatar. */\n avatarProps: AvatarProps;\n /** Comment block replies. */\n children?: ReactNode;\n /** Comment date with the minimal timestamp informations (xx minutes, x hours, yesterday, 6 days, Month Day, Month Day Year)*/\n date: string;\n /** Comment date with the full timestamp informations (day, month, year, time) */\n fullDate?: string;\n /** Whether the component has actions to display or not. */\n hasActions?: boolean;\n /** Action toolbar header content. */\n headerActions?: ReactNode;\n /** Whether the component is open or not. */\n isOpen?: boolean;\n /** Whether the comment is relevant or not. */\n isRelevant?: boolean;\n /** Comment author name. */\n name: string;\n /** On click callback. */\n onClick?(): void;\n /** On mouse enter callback. */\n onMouseEnter?(): void;\n /** On mouse leave callback. */\n onMouseLeave?(): void;\n /** Comment content. */\n text: ReactNode | string;\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** Comment variant. */\n variant?: CommentBlockVariant;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'CommentBlock';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<CommentBlockProps> = {\n theme: Theme.light,\n variant: CommentBlockVariant.indented,\n};\n\n/**\n * CommentBlock component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const CommentBlock: Comp<CommentBlockProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n actions,\n avatarProps,\n children,\n className,\n date,\n fullDate,\n hasActions,\n headerActions,\n isOpen,\n isRelevant,\n name,\n onClick,\n onMouseEnter,\n onMouseLeave,\n text,\n theme,\n variant,\n ...forwardedProps\n } = props;\n const enterKeyPress: KeyboardEventHandler<HTMLElement> = (evt: KeyboardEvent<HTMLElement>) => {\n if (evt.key === 'Enter' && isFunction(onClick)) {\n onClick();\n }\n };\n const hasChildren = Children.count(children) > 0;\n\n return (\n <div\n ref={ref}\n className={classNames(\n className,\n handleBasicClasses({\n hasChildren: hasChildren && isOpen,\n hasIndentedChildren: hasChildren && variant === CommentBlockVariant.indented,\n hasLinearChildren: hasChildren && variant === CommentBlockVariant.linear,\n isRelevant,\n prefix: CLASSNAME,\n theme,\n }),\n )}\n {...forwardedProps}\n >\n <div className={`${CLASSNAME}__wrapper`}>\n <div className={`${CLASSNAME}__avatar`}>\n <Avatar\n {...avatarProps}\n size={Size.m}\n tabIndex={onClick ? 0 : -1}\n onClick={onClick}\n onKeyPress={enterKeyPress}\n />\n </div>\n\n <div className={`${CLASSNAME}__container`}>\n <div className={`${CLASSNAME}__content`}>\n <div className={`${CLASSNAME}__meta`}>\n <span\n className={`${CLASSNAME}__name`}\n onClick={onClick}\n onKeyPress={enterKeyPress}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n role=\"button\"\n tabIndex={onClick ? 0 : -1}\n >\n {name}\n </span>\n {headerActions && <span className={`${CLASSNAME}__header-actions`}>{headerActions}</span>}\n </div>\n\n <div className={`${CLASSNAME}__text`}>{text}</div>\n {date &&\n (fullDate ? (\n <Tooltip label={fullDate} placement=\"top\">\n <span className={`${CLASSNAME}__date`}>{date}</span>\n </Tooltip>\n ) : (\n <span className={`${CLASSNAME}__date`}>{date}</span>\n ))}\n </div>\n {hasActions && <div className={`${CLASSNAME}__actions`}>{actions}</div>}\n </div>\n </div>\n\n {hasChildren && isOpen && <div className={`${CLASSNAME}__children`}>{children}</div>}\n </div>\n );\n});\nCommentBlock.displayName = COMPONENT_NAME;\nCommentBlock.className = CLASSNAME;\nCommentBlock.defaultProps = DEFAULT_PROPS;\n"],"names":["CommentBlockVariant","indented","linear","COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","theme","Theme","light","variant","CommentBlock","forwardRef","props","ref","actions","avatarProps","children","className","date","fullDate","hasActions","headerActions","isOpen","isRelevant","name","onClick","onMouseEnter","onMouseLeave","text","forwardedProps","enterKeyPress","evt","key","isFunction","hasChildren","Children","count","classNames","handleBasicClasses","hasIndentedChildren","hasLinearChildren","prefix","Size","m","displayName","defaultProps"],"mappings":";;;;;;;;AAUA;;;IAGaA,mBAAmB,GAAG;AAC/BC,EAAAA,QAAQ,EAAE,UADqB;AAE/BC,EAAAA,MAAM,EAAE;AAFuB;;AA4CnC;;;AAGA,IAAMC,cAAc,GAAG,cAAvB;AAEA;;;;AAGA,IAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAD,CAAlC;AAEA;;;;AAGA,IAAMG,aAAyC,GAAG;AAC9CC,EAAAA,KAAK,EAAEC,KAAK,CAACC,KADiC;AAE9CC,EAAAA,OAAO,EAAEV,mBAAmB,CAACC;AAFiB,CAAl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,IATL,CADJ,EAYKH,aAAa,IAAI;AAAM,IAAA,SAAS,YAAKlB,SAAL;AAAf,KAAkDkB,aAAlD,CAZtB,CADJ,EAgBI;AAAK,IAAA,SAAS,YAAKlB,SAAL;AAAd,KAAuCyB,IAAvC,CAhBJ,EAiBKV,IAAI,KACAC,QAAQ,GACL,oBAAC,OAAD;AAAS,IAAA,KAAK,EAAEA,QAAhB;AAA0B,IAAA,SAAS,EAAC;AAApC,KACI;AAAM,IAAA,SAAS,YAAKhB,SAAL;AAAf,KAAwCe,IAAxC,CADJ,CADK,GAKL;AAAM,IAAA,SAAS,YAAKf,SAAL;AAAf,KAAwCe,IAAxC,CANH,CAjBT,CADJ,EA2BKE,UAAU,IAAI;AAAK,IAAA,SAAS,YAAKjB,SAAL;AAAd,KAA0CW,OAA1C,CA3BnB,CAXJ,CAfJ,EAyDKoB,WAAW,IAAIZ,MAAf,IAAyB;AAAK,IAAA,SAAS,YAAKnB,SAAL;AAAd,KAA2Ca,QAA3C,CAzD9B,CADJ;AA6DH,CAzF8E;AA0F/EN,YAAY,CAACkC,WAAb,GAA2B1C,cAA3B;AACAQ,YAAY,CAACO,SAAb,GAAyBd,SAAzB;AACAO,YAAY,CAACmC,YAAb,GAA4BxC,aAA5B;;;;"}
@@ -77,7 +77,8 @@ var DEFAULT_PROPS = {
77
77
  fitToAnchorWidth: true,
78
78
  fitWithinViewportHeight: true,
79
79
  placement: Placement.BOTTOM_START,
80
- shouldFocusOnOpen: true
80
+ shouldFocusOnOpen: true,
81
+ focusAnchorOnClose: true
81
82
  };
82
83
  /**
83
84
  * Dropdown component.
@@ -98,12 +99,13 @@ var Dropdown = forwardRef(function (props, ref) {
98
99
  fitWithinViewportHeight = props.fitWithinViewportHeight,
99
100
  isOpen = props.isOpen,
100
101
  offset = props.offset,
102
+ focusAnchorOnClose = props.focusAnchorOnClose,
101
103
  onClose = props.onClose,
102
104
  onInfiniteScroll = props.onInfiniteScroll,
103
105
  placement = props.placement,
104
106
  shouldFocusOnOpen = props.shouldFocusOnOpen,
105
107
  zIndex = props.zIndex,
106
- forwardedProps = _objectWithoutProperties(props, ["anchorRef", "children", "className", "closeOnClick", "closeOnClickAway", "closeOnEscape", "fitToAnchorWidth", "fitWithinViewportHeight", "isOpen", "offset", "onClose", "onInfiniteScroll", "placement", "shouldFocusOnOpen", "zIndex"]);
108
+ forwardedProps = _objectWithoutProperties(props, ["anchorRef", "children", "className", "closeOnClick", "closeOnClickAway", "closeOnEscape", "fitToAnchorWidth", "fitWithinViewportHeight", "isOpen", "offset", "focusAnchorOnClose", "onClose", "onInfiniteScroll", "placement", "shouldFocusOnOpen", "zIndex"]);
107
109
 
108
110
  var innerRef = useRef(null);
109
111
  var listElement = useRef(null);
@@ -126,6 +128,7 @@ var Dropdown = forwardRef(function (props, ref) {
126
128
  return isOpen ? React.createElement(Popover, _extends({
127
129
  ref: ref
128
130
  }, forwardedProps, {
131
+ focusAnchorOnClose: focusAnchorOnClose,
129
132
  anchorRef: anchorRef,
130
133
  className: classnames(className, handleBasicClasses({
131
134
  prefix: CLASSNAME
@@ -1 +1 @@
1
- {"version":3,"file":"Dropdown2.js","sources":["../../../src/hooks/useInfiniteScroll.tsx","../../../src/components/dropdown/Dropdown.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\n\ntype useInfiniteScrollType = (\n ref: React.RefObject<HTMLElement>,\n callback?: EventCallback,\n callbackOnMount?: boolean,\n) => void;\ntype EventCallback = (evt?: Event) => void;\n\n// The error margin in px we want to have for triggering infinite scroll\nconst SCROLL_TRIGGER_MARGIN = 5;\n\n/**\n * Listen to clicks away from a given element and callback the passed in function.\n *\n * @param ref A reference to the element on which you want to listen scroll event.\n * @param [callback] A callback function to call when the bottom of the reference element is reached.\n * @param [callbackOnMount] A callback function to call when the component is mounted.\n */\nexport const useInfiniteScroll: useInfiniteScrollType = (\n ref,\n callback,\n callbackOnMount = false,\n scrollTriggerMargin = SCROLL_TRIGGER_MARGIN,\n) => {\n useEffect(() => {\n const { current } = ref;\n if (!callback || !current) {\n return undefined;\n }\n\n const isAtBottom = () =>\n Boolean(\n current && current.scrollHeight - (current.scrollTop + current.clientHeight) <= scrollTriggerMargin,\n );\n\n const onScroll = (e?: Event): void => {\n if (isAtBottom()) {\n callback(e);\n }\n };\n\n if (isAtBottom()) {\n onScroll();\n }\n\n current.addEventListener('scroll', onScroll);\n current.addEventListener('resize', onScroll);\n return () => {\n current.removeEventListener('scroll', onScroll);\n current.removeEventListener('resize', onScroll);\n };\n }, [ref, callback, scrollTriggerMargin]);\n\n useEffect(() => {\n if (callback && callbackOnMount) {\n callback();\n }\n }, [callback, callbackOnMount]);\n};\n","import React, { cloneElement, forwardRef, useMemo, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport { List, ListProps } from '@lumx/react/components/list/List';\nimport { Offset, Placement, Popover } from '@lumx/react/components/popover/Popover';\nimport { useInfiniteScroll } from '@lumx/react/hooks/useInfiniteScroll';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses, isComponent } from '@lumx/react/utils';\n\n/**\n * Defines the props of the component.\n */\nexport interface DropdownProps extends GenericProps {\n /** Reference to the element around which the dropdown is placed.\n * @see {@link PopoverProps#anchorRef}\n */\n anchorRef: React.RefObject<HTMLElement>;\n /** Dropdown content. */\n children: React.ReactNode;\n /**\n * Whether a click anywhere out of the Dropdown would close it or not.\n * @see {@link PopoverProps#closeOnClickAway}\n */\n closeOnClickAway?: boolean;\n /**\n * Whether to close the Dropdown when clicking in it or not.\n */\n closeOnClick?: boolean;\n /**\n * Whether an escape key press would close the Dropdown or not.\n * @see {@link PopoverProps#closeOnEscape}\n */\n closeOnEscape?: boolean;\n /**\n * Whether the dropdown should fit to the anchor width (if dropdown is smaller) or not.\n * @see {@link PopoverProps#fitToAnchorWidth}\n */\n fitToAnchorWidth?: boolean;\n /**\n * Whether the dropdown should shrink to fit within the viewport height or not.\n * @see {@link PopoverProps#fitWithinViewportHeight}\n */\n fitWithinViewportHeight?: boolean;\n /**\n * Whether the dropdown should be displayed or not. Useful to control the Dropdown from outside the component.\n * @see {@link PopoverProps#isOpen}\n */\n isOpen: boolean;\n /**\n * Offset applied to the Dropdown position.\n * @see {@link PopoverProps#offset}\n */\n offset?: Offset;\n /**\n * Preferred Dropdown placement against the anchor element.\n * @see {@link PopoverProps#placement}\n */\n placement?: Placement;\n /** Whether the focus should be set on the list when the dropdown is open or not. */\n shouldFocusOnOpen?: boolean;\n /**\n * Z-axis position.\n * @see {@link PopoverProps#zIndex}\n */\n zIndex?: number;\n /**\n * On close callback.\n * @see {@link PopoverProps#onClose}\n */\n onClose?(): void;\n /** On scroll end callback. */\n onInfiniteScroll?(): void;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Dropdown';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<DropdownProps> = {\n closeOnClick: true,\n closeOnClickAway: true,\n closeOnEscape: true,\n fitToAnchorWidth: true,\n fitWithinViewportHeight: true,\n placement: Placement.BOTTOM_START,\n shouldFocusOnOpen: true,\n};\n\n/**\n * Dropdown component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Dropdown: Comp<DropdownProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n anchorRef,\n children,\n className,\n closeOnClick,\n closeOnClickAway,\n closeOnEscape,\n fitToAnchorWidth,\n fitWithinViewportHeight,\n isOpen,\n offset,\n onClose,\n onInfiniteScroll,\n placement,\n shouldFocusOnOpen,\n zIndex,\n ...forwardedProps\n } = props;\n const innerRef = useRef<HTMLDivElement>(null);\n const listElement = useRef(null);\n\n useInfiniteScroll(innerRef, onInfiniteScroll);\n\n const popperElement = useMemo(() => {\n return !Array.isArray(children) && isComponent(List)(children)\n ? cloneElement<ListProps>(children, {\n ...children.props,\n ref: listElement,\n onClick(evt: MouseEvent) {\n children.props.onClick?.(evt);\n\n if (closeOnClick) {\n onClose?.();\n }\n },\n isClickable: true,\n })\n : children;\n }, [children, closeOnClick, onClose]);\n\n return isOpen ? (\n <Popover\n ref={ref}\n {...forwardedProps}\n anchorRef={anchorRef}\n className={classNames(className, handleBasicClasses({ prefix: CLASSNAME }))}\n elevation={0 as any}\n closeOnClickAway={closeOnClickAway}\n closeOnEscape={closeOnEscape}\n fitToAnchorWidth={fitToAnchorWidth}\n fitWithinViewportHeight={fitWithinViewportHeight}\n focusElement={shouldFocusOnOpen ? listElement : undefined}\n isOpen={isOpen}\n offset={offset}\n onClose={onClose}\n placement={placement}\n zIndex={zIndex}\n >\n <div className={`${CLASSNAME}__menu`} ref={innerRef}>\n {popperElement}\n </div>\n </Popover>\n ) : null;\n});\nDropdown.displayName = COMPONENT_NAME;\nDropdown.className = CLASSNAME;\nDropdown.defaultProps = DEFAULT_PROPS;\n"],"names":["SCROLL_TRIGGER_MARGIN","useInfiniteScroll","ref","callback","callbackOnMount","scrollTriggerMargin","useEffect","current","undefined","isAtBottom","Boolean","scrollHeight","scrollTop","clientHeight","onScroll","e","addEventListener","removeEventListener","COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","closeOnClick","closeOnClickAway","closeOnEscape","fitToAnchorWidth","fitWithinViewportHeight","placement","Placement","BOTTOM_START","shouldFocusOnOpen","Dropdown","forwardRef","props","anchorRef","children","className","isOpen","offset","onClose","onInfiniteScroll","zIndex","forwardedProps","innerRef","useRef","listElement","popperElement","useMemo","Array","isArray","isComponent","List","cloneElement","onClick","evt","isClickable","classNames","handleBasicClasses","prefix","displayName","defaultProps"],"mappings":";;;;;;;AASA;AACA,IAAMA,qBAAqB,GAAG,CAA9B;AAEA;;;;;;;;AAOO,IAAMC,iBAAwC,GAAG,SAA3CA,iBAA2C,CACpDC,GADoD,EAEpDC,QAFoD,EAKnD;AAAA,MAFDC,eAEC,uEAFiB,KAEjB;AAAA,MADDC,mBACC,uEADqBL,qBACrB;AACDM,EAAAA,SAAS,CAAC,YAAM;AAAA,QAC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M,EAAEC,MAZZ;AAaI,IAAA,OAAO,EAAEC,OAbb;AAcI,IAAA,SAAS,EAAEZ,SAdf;AAeI,IAAA,MAAM,EAAEc;AAfZ,MAiBI;AAAK,IAAA,SAAS,YAAKtB,SAAL,WAAd;AAAsC,IAAA,GAAG,EAAEwB;AAA3C,KACKG,aADL,CAjBJ,CADS,GAsBT,IAtBJ;AAuBH,CAhEsE;AAiEvEf,QAAQ,CAAC4B,WAAT,GAAuBzC,cAAvB;AACAa,QAAQ,CAACK,SAAT,GAAqBjB,SAArB;AACAY,QAAQ,CAAC6B,YAAT,GAAwBvC,aAAxB;;;;"}
1
+ {"version":3,"file":"Dropdown2.js","sources":["../../../src/hooks/useInfiniteScroll.tsx","../../../src/components/dropdown/Dropdown.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\n\ntype useInfiniteScrollType = (\n ref: React.RefObject<HTMLElement>,\n callback?: EventCallback,\n callbackOnMount?: boolean,\n) => void;\ntype EventCallback = (evt?: Event) => void;\n\n// The error margin in px we want to have for triggering infinite scroll\nconst SCROLL_TRIGGER_MARGIN = 5;\n\n/**\n * Listen to clicks away from a given element and callback the passed in function.\n *\n * @param ref A reference to the element on which you want to listen scroll event.\n * @param [callback] A callback function to call when the bottom of the reference element is reached.\n * @param [callbackOnMount] A callback function to call when the component is mounted.\n */\nexport const useInfiniteScroll: useInfiniteScrollType = (\n ref,\n callback,\n callbackOnMount = false,\n scrollTriggerMargin = SCROLL_TRIGGER_MARGIN,\n) => {\n useEffect(() => {\n const { current } = ref;\n if (!callback || !current) {\n return undefined;\n }\n\n const isAtBottom = () =>\n Boolean(\n current && current.scrollHeight - (current.scrollTop + current.clientHeight) <= scrollTriggerMargin,\n );\n\n const onScroll = (e?: Event): void => {\n if (isAtBottom()) {\n callback(e);\n }\n };\n\n if (isAtBottom()) {\n onScroll();\n }\n\n current.addEventListener('scroll', onScroll);\n current.addEventListener('resize', onScroll);\n return () => {\n current.removeEventListener('scroll', onScroll);\n current.removeEventListener('resize', onScroll);\n };\n }, [ref, callback, scrollTriggerMargin]);\n\n useEffect(() => {\n if (callback && callbackOnMount) {\n callback();\n }\n }, [callback, callbackOnMount]);\n};\n","import React, { cloneElement, forwardRef, useMemo, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport { List, ListProps } from '@lumx/react/components/list/List';\nimport { Offset, Placement, Popover } from '@lumx/react/components/popover/Popover';\nimport { useInfiniteScroll } from '@lumx/react/hooks/useInfiniteScroll';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses, isComponent } from '@lumx/react/utils';\n\n/**\n * Defines the props of the component.\n */\nexport interface DropdownProps extends GenericProps {\n /** Reference to the element around which the dropdown is placed.\n * @see {@link PopoverProps#anchorRef}\n */\n anchorRef: React.RefObject<HTMLElement>;\n /** Dropdown content. */\n children: React.ReactNode;\n /**\n * Whether a click anywhere out of the Dropdown would close it or not.\n * @see {@link PopoverProps#closeOnClickAway}\n */\n closeOnClickAway?: boolean;\n /**\n * Whether to close the Dropdown when clicking in it or not.\n */\n closeOnClick?: boolean;\n /**\n * Whether an escape key press would close the Dropdown or not.\n * @see {@link PopoverProps#closeOnEscape}\n */\n closeOnEscape?: boolean;\n /**\n * Whether the dropdown should fit to the anchor width (if dropdown is smaller) or not.\n * @see {@link PopoverProps#fitToAnchorWidth}\n */\n fitToAnchorWidth?: boolean;\n /**\n * Whether the dropdown should shrink to fit within the viewport height or not.\n * @see {@link PopoverProps#fitWithinViewportHeight}\n */\n fitWithinViewportHeight?: boolean;\n /**\n * Whether the dropdown should be displayed or not. Useful to control the Dropdown from outside the component.\n * @see {@link PopoverProps#isOpen}\n */\n isOpen: boolean;\n /**\n * Offset applied to the Dropdown position.\n * @see {@link PopoverProps#offset}\n */\n offset?: Offset;\n /**\n * Preferred Dropdown placement against the anchor element.\n * @see {@link PopoverProps#placement}\n */\n placement?: Placement;\n /** Whether the focus should be set on the list when the dropdown is open or not. */\n shouldFocusOnOpen?: boolean;\n /** Whether the focus should go back on the anchor when dropdown closes and focus is within. */\n focusAnchorOnClose?: boolean;\n /**\n * Z-axis position.\n * @see {@link PopoverProps#zIndex}\n */\n zIndex?: number;\n /**\n * On close callback.\n * @see {@link PopoverProps#onClose}\n */\n onClose?(): void;\n /** On scroll end callback. */\n onInfiniteScroll?(): void;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Dropdown';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<DropdownProps> = {\n closeOnClick: true,\n closeOnClickAway: true,\n closeOnEscape: true,\n fitToAnchorWidth: true,\n fitWithinViewportHeight: true,\n placement: Placement.BOTTOM_START,\n shouldFocusOnOpen: true,\n focusAnchorOnClose: true,\n};\n\n/**\n * Dropdown component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Dropdown: Comp<DropdownProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n anchorRef,\n children,\n className,\n closeOnClick,\n closeOnClickAway,\n closeOnEscape,\n fitToAnchorWidth,\n fitWithinViewportHeight,\n isOpen,\n offset,\n focusAnchorOnClose,\n onClose,\n onInfiniteScroll,\n placement,\n shouldFocusOnOpen,\n zIndex,\n ...forwardedProps\n } = props;\n const innerRef = useRef<HTMLDivElement>(null);\n const listElement = useRef(null);\n\n useInfiniteScroll(innerRef, onInfiniteScroll);\n\n const popperElement = useMemo(() => {\n return !Array.isArray(children) && isComponent(List)(children)\n ? cloneElement<ListProps>(children, {\n ...children.props,\n ref: listElement,\n onClick(evt: MouseEvent) {\n children.props.onClick?.(evt);\n\n if (closeOnClick) {\n onClose?.();\n }\n },\n isClickable: true,\n })\n : children;\n }, [children, closeOnClick, onClose]);\n\n return isOpen ? (\n <Popover\n ref={ref}\n {...forwardedProps}\n focusAnchorOnClose={focusAnchorOnClose}\n anchorRef={anchorRef}\n className={classNames(className, handleBasicClasses({ prefix: CLASSNAME }))}\n elevation={0 as any}\n closeOnClickAway={closeOnClickAway}\n closeOnEscape={closeOnEscape}\n fitToAnchorWidth={fitToAnchorWidth}\n fitWithinViewportHeight={fitWithinViewportHeight}\n focusElement={shouldFocusOnOpen ? listElement : undefined}\n isOpen={isOpen}\n offset={offset}\n onClose={onClose}\n placement={placement}\n zIndex={zIndex}\n >\n <div className={`${CLASSNAME}__menu`} ref={innerRef}>\n {popperElement}\n </div>\n </Popover>\n ) : null;\n});\nDropdown.displayName = COMPONENT_NAME;\nDropdown.className = CLASSNAME;\nDropdown.defaultProps = DEFAULT_PROPS;\n"],"names":["SCROLL_TRIGGER_MARGIN","useInfiniteScroll","ref","callback","callbackOnMount","scrollTriggerMargin","useEffect","current","undefined","isAtBottom","Boolean","scrollHeight","scrollTop","clientHeight","onScroll","e","addEventListener","removeEventListener","COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","closeOnClick","closeOnClickAway","closeOnEscape","fitToAnchorWidth","fitWithinViewportHeight","placement","Placement","BOTTOM_START","shouldFocusOnOpen","focusAnchorOnClose","Dropdown","forwardRef","props","anchorRef","children","className","isOpen","offset","onClose","onInfiniteScroll","zIndex","forwardedProps","innerRef","useRef","listElement","popperElement","useMemo","Array","isArray","isComponent","List","cloneElement","onClick","evt","isClickable","classNames","handleBasicClasses","prefix","displayName","defaultProps"],"mappings":";;;;;;;AASA;AACA,IAAMA,qBAAqB,GAAG,CAA9B;AAEA;;;;;;;;AAOO,IAAMC,iBAAwC,GAAG,SAA3CA,iBAA2C,CACpDC,GADoD,EAEpDC,QAFoD,EAKnD;AAAA,MAFDC,eAEC,uEAFiB,KAEjB;AAAA,MADDC,mBACC,uEADqBL,qBACrB;AACDM,EAAAA,SAAS,CAAC,YAAM;AAAA,QACJC,OADI,GACQL,GADR,CACJK,OADI;;AAEZ,QAAI,CAACJ,QAAD,IAAa,CAACI,OAAlB,EAA2B;AACvB,aAAOC,SAAP;AACH;;AAED,QAAMC,UAAU,GAAG,SAAbA,UAAa;AAAA,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;AAcI,IAAA,OAAO,EAAEC,OAdb;AAeI,IAAA,SAAS,EAAEb,SAff;AAgBI,IAAA,MAAM,EAAEe;AAhBZ,MAkBI;AAAK,IAAA,SAAS,YAAKvB,SAAL,WAAd;AAAsC,IAAA,GAAG,EAAEyB;AAA3C,KACKG,aADL,CAlBJ,CADS,GAuBT,IAvBJ;AAwBH,CAlEsE;AAmEvEf,QAAQ,CAAC4B,WAAT,GAAuB1C,cAAvB;AACAc,QAAQ,CAACK,SAAT,GAAqBlB,SAArB;AACAa,QAAQ,CAAC6B,YAAT,GAAwBxC,aAAxB;;;;"}
@@ -56,50 +56,30 @@ var Icon = forwardRef(function (props, ref) {
56
56
  size = props.size,
57
57
  theme = props.theme,
58
58
  alt = props.alt,
59
- forwardedProps = _objectWithoutProperties(props, ["className", "color", "colorVariant", "hasShape", "icon", "size", "theme", "alt"]);
59
+ forwardedProps = _objectWithoutProperties(props, ["className", "color", "colorVariant", "hasShape", "icon", "size", "theme", "alt"]); // Color
60
60
 
61
- var iconColor;
62
- var iconColorVariant;
63
- var iconTheme;
64
61
 
65
- if (color) {
66
- iconColor = color;
67
- iconTheme = theme;
68
- }
62
+ var iconColor = color;
69
63
 
70
- if (hasShape) {
71
- if (theme === Theme.dark && !iconColor) {
72
- iconColor = ColorPalette.light;
73
- iconTheme = theme;
74
- } else {
75
- iconColor = iconColor || ColorPalette.dark;
76
- }
77
- } else if (!iconColor && theme) {
78
- iconTheme = theme;
79
- iconColor = iconColor || theme === Theme.light ? ColorPalette.dark : ColorPalette.light;
80
- }
64
+ if (!iconColor && (hasShape || theme)) {
65
+ iconColor = theme === Theme.dark ? ColorPalette.light : ColorPalette.dark;
66
+ } // Color variant
81
67
 
82
- if (!iconColorVariant) {
83
- if (hasShape && iconColor === ColorPalette.dark) {
84
- iconColorVariant = colorVariant || 'L2';
85
- } else {
86
- iconColorVariant = colorVariant || (theme === Theme.dark ? 'N' : 'L1');
87
- }
88
- }
89
68
 
90
- var iconSize;
91
-
92
- if (size) {
93
- if (hasShape) {
94
- if (size === Size.xxs || size === Size.xs) {
95
- iconSize = Size.s;
96
- } else if (size === Size.xxl) {
97
- iconSize = Size.xl;
98
- } else {
99
- iconSize = size;
100
- }
101
- } else {
102
- iconSize = size;
69
+ var iconColorVariant = colorVariant;
70
+
71
+ if (!iconColorVariant && hasShape && iconColor === ColorPalette.dark) {
72
+ iconColorVariant = 'L2';
73
+ } // Size
74
+
75
+
76
+ var iconSize = size;
77
+
78
+ if (size && hasShape) {
79
+ if (size === Size.xxs || size === Size.xs) {
80
+ iconSize = Size.s;
81
+ } else if (size === Size.xxl) {
82
+ iconSize = Size.xl;
103
83
  }
104
84
  } else if (hasShape) {
105
85
  iconSize = Size.m;
@@ -113,7 +93,7 @@ var Icon = forwardRef(function (props, ref) {
113
93
  colorVariant: iconColorVariant,
114
94
  hasShape: hasShape,
115
95
  prefix: CLASSNAME,
116
- theme: iconTheme,
96
+ theme: theme,
117
97
  size: iconSize
118
98
  }), !hasShape && "".concat(CLASSNAME, "--no-shape"), !hasShape && iconColor === ColorPalette.yellow && icon === mdiAlertCircle && "".concat(CLASSNAME, "--has-dark-layer"), "".concat(CLASSNAME, "--path"))
119
99
  }), React.createElement("svg", {