@chayns-components/core 5.0.0-beta.461 → 5.0.0-beta.468
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/accordion/Accordion.d.ts +0 -5
- package/lib/components/accordion/Accordion.js +3 -3
- package/lib/components/accordion/Accordion.js.map +1 -1
- package/lib/components/accordion/accordion-group/AccordionGroup.d.ts +7 -1
- package/lib/components/accordion/accordion-group/AccordionGroup.js +4 -1
- package/lib/components/accordion/accordion-group/AccordionGroup.js.map +1 -1
- package/lib/components/input/Input.styles.js +1 -0
- package/lib/components/input/Input.styles.js.map +1 -1
- package/lib/components/list/List.d.ts +6 -0
- package/lib/components/list/List.js +7 -4
- package/lib/components/list/List.js.map +1 -1
- package/lib/components/list/list-item/ListItem.js +3 -1
- package/lib/components/list/list-item/ListItem.js.map +1 -1
- package/lib/components/list/list-item/ListItem.styles.d.ts +1 -0
- package/lib/components/list/list-item/ListItem.styles.js +9 -2
- package/lib/components/list/list-item/ListItem.styles.js.map +1 -1
- package/lib/components/search-box/SearchBox.js +8 -0
- package/lib/components/search-box/SearchBox.js.map +1 -1
- package/lib/components/setup-wizard/SetupWizard.d.ts +4 -0
- package/lib/components/setup-wizard/SetupWizard.js +5 -2
- package/lib/components/setup-wizard/SetupWizard.js.map +1 -1
- package/lib/components/setup-wizard/setup-wizard-item/SetupWizardItem.d.ts +0 -4
- package/lib/components/setup-wizard/setup-wizard-item/SetupWizardItem.js +2 -4
- package/lib/components/setup-wizard/setup-wizard-item/SetupWizardItem.js.map +1 -1
- package/lib/components/truncation/Truncation.d.ts +5 -0
- package/lib/components/truncation/Truncation.js +7 -3
- package/lib/components/truncation/Truncation.js.map +1 -1
- package/lib/components/truncation/Truncation.styles.d.ts +7 -0
- package/lib/components/truncation/Truncation.styles.js +25 -2
- package/lib/components/truncation/Truncation.styles.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/types/file.d.ts +5 -1
- package/lib/types/file.js.map +1 -1
- package/lib/types/truncation.d.ts +5 -0
- package/lib/types/truncation.js +7 -0
- package/lib/types/truncation.js.map +1 -0
- package/lib/utils/uploadFile.d.ts +2 -2
- package/lib/utils/uploadFile.js.map +1 -1
- package/package.json +2 -2
|
@@ -37,11 +37,6 @@ export type AccordionProps = {
|
|
|
37
37
|
* This will gray out the title of the Accordion to indicate hidden content, for example.
|
|
38
38
|
*/
|
|
39
39
|
isTitleGreyed?: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* This value must be set for nested Accordions. This adjusts the style of
|
|
42
|
-
* the head and the padding of the content.
|
|
43
|
-
*/
|
|
44
|
-
isWrapped?: boolean;
|
|
45
40
|
/**
|
|
46
41
|
* Function that is executed when the accordion body will be scrolled
|
|
47
42
|
*/
|
|
@@ -18,7 +18,6 @@ const Accordion = _ref => {
|
|
|
18
18
|
isFixed = false,
|
|
19
19
|
isOpened,
|
|
20
20
|
isTitleGreyed = false,
|
|
21
|
-
isWrapped = false,
|
|
22
21
|
onBodyScroll,
|
|
23
22
|
onClose,
|
|
24
23
|
onOpen,
|
|
@@ -35,6 +34,7 @@ const Accordion = _ref => {
|
|
|
35
34
|
shouldRenderClosed = false
|
|
36
35
|
} = _ref;
|
|
37
36
|
const {
|
|
37
|
+
isWrapped,
|
|
38
38
|
openAccordionUuid,
|
|
39
39
|
updateOpenAccordionUuid
|
|
40
40
|
} = useContext(AccordionGroupContext);
|
|
@@ -101,7 +101,7 @@ const Accordion = _ref => {
|
|
|
101
101
|
}
|
|
102
102
|
}, [isOpened, updateOpenAccordionUuid, uuid]);
|
|
103
103
|
const accordionContextProviderValue = useMemo(() => ({
|
|
104
|
-
isWrapped
|
|
104
|
+
isWrapped: isWrapped === true
|
|
105
105
|
}), [isWrapped]);
|
|
106
106
|
return /*#__PURE__*/React.createElement(StyledAccordion, {
|
|
107
107
|
className: "beta-chayns-accordion",
|
|
@@ -121,7 +121,7 @@ const Accordion = _ref => {
|
|
|
121
121
|
isOpen: isOpen,
|
|
122
122
|
isFixed: isFixed,
|
|
123
123
|
isTitleGreyed: isTitleGreyed || isDisabled,
|
|
124
|
-
isWrapped: isWrapped,
|
|
124
|
+
isWrapped: isWrapped === true,
|
|
125
125
|
onClick: handleHeadClick,
|
|
126
126
|
onSearchChange: onSearchChange,
|
|
127
127
|
rightElement: rightElement,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.js","names":["AnimatePresence","MotionConfig","React","useCallback","useContext","useEffect","useMemo","useRef","useState","useUuid","AccordionBody","AccordionGroupContext","AccordionHead","StyledAccordion","AccordionContext","createContext","isWrapped","Accordion","_ref","bodyMaxHeight","children","icon","isDefaultOpen","isDisabled","isFixed","isOpened","isTitleGreyed","onBodyScroll","onClose","onOpen","onSearchChange","rightElement","searchIcon","searchPlaceholder","searchValue","shouldForceBackground","shouldHideBackground","shouldRotateIcon","title","titleElement","shouldRenderClosed","openAccordionUuid","updateOpenAccordionUuid","isParentWrapped","isAccordionOpen","setIsAccordionOpen","uuid","isInitialRenderRef","isInGroup","isOpen","onCloseRef","onOpenRef","current","handleHeadClick","currentIsAccordionOpen","shouldOnlyOpen","accordionContextProviderValue","createElement","className","$isOpen","$isParentWrapped","$isWrapped","$shouldForceBackground","$shouldHideBackground","Provider","value","transition","type","onClick","initial","maxHeight","onScroll","shouldHideBody","displayName"],"sources":["../../../src/components/accordion/Accordion.tsx"],"sourcesContent":["import { AnimatePresence, MotionConfig } from 'framer-motion';\nimport React, {\n ChangeEventHandler,\n FC,\n ReactNode,\n UIEvent,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useUuid } from '../../hooks/uuid';\nimport AccordionBody from './accordion-body/AccordionBody';\nimport { AccordionGroupContext } from './accordion-group/AccordionGroup';\nimport AccordionHead from './accordion-head/AccordionHead';\nimport { StyledAccordion } from './Accordion.styles';\n\nexport const AccordionContext = React.createContext({ isWrapped: false });\n\nexport type AccordionProps = {\n /**\n * Maximum height of the accordion body element. This automatically makes the content of the\n * body element scrollable.\n */\n bodyMaxHeight?: number;\n /**\n * The content of the accordion body\n */\n children: ReactNode;\n /**\n * The icon that is displayed in front of the title\n */\n icon?: string;\n /**\n * This can be used to automatically expand the Accordion during the first render.\n */\n isDefaultOpen?: boolean;\n /**\n * This will disable the Accordion so that it cannot be opened and will gray out the title. Does not work with isOpened.\n */\n isDisabled?: boolean;\n /**\n * This can be used so that the Accordion cannot be opened or closed.\n * In addition, in this case the icon is exchanged to mark the Accordions.\n */\n isFixed?: boolean;\n /**\n * This can be used to open the Accordion from the outside.\n */\n isOpened?: boolean;\n /**\n * This will gray out the title of the Accordion to indicate hidden content, for example.\n */\n isTitleGreyed?: boolean;\n /**\n * This value must be set for nested Accordions. This adjusts the style of\n * the head and the padding of the content.\n */\n isWrapped?: boolean;\n /**\n * Function that is executed when the accordion body will be scrolled\n */\n onBodyScroll?: (event: UIEvent<HTMLDivElement>) => void;\n /**\n * Function that is executed when the accordion will be closed.\n */\n onClose?: VoidFunction;\n /**\n * Function that is executed when the accordion will be opened.\n */\n onOpen?: VoidFunction;\n /**\n * Function that is executed when the text of the search in the accordion\n * head changes. When this function is given, the search field is displayed\n * in the Accordion Head.\n */\n onSearchChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Content to be displayed on the right side in the head of the Accordion\n */\n rightElement?: ReactNode;\n /**\n * Icon to be displayed on the right side in the search input\n */\n searchIcon?: string[];\n /**\n * The placeholder to be used for the search\n */\n searchPlaceholder?: string;\n /**\n * The value that is displayed inside the search\n */\n searchValue?: string;\n /**\n * This will force the background color of the accordion to be used even if it is closed and not hovered.\n */\n shouldForceBackground?: boolean;\n /**\n * This will hide the background color of the accordion\n */\n shouldHideBackground?: boolean;\n /**\n * Whether the icon should be rotating.\n */\n shouldRotateIcon?: boolean;\n /**\n * Title of the Accordion displayed in the head\n */\n title: string;\n /**\n * Additional elements to be displayed in the header next to the title.\n */\n titleElement?: ReactNode;\n /**\n * This will render the Accordion closed on the first render.\n */\n shouldRenderClosed?: boolean;\n};\n\nconst Accordion: FC<AccordionProps> = ({\n bodyMaxHeight,\n children,\n icon,\n isDefaultOpen = false,\n isDisabled = false,\n isFixed = false,\n isOpened,\n isTitleGreyed = false,\n isWrapped = false,\n onBodyScroll,\n onClose,\n onOpen,\n onSearchChange,\n rightElement,\n searchIcon,\n searchPlaceholder,\n searchValue,\n shouldForceBackground = false,\n shouldHideBackground = false,\n shouldRotateIcon = true,\n title,\n titleElement,\n shouldRenderClosed = false,\n}) => {\n const { openAccordionUuid, updateOpenAccordionUuid } = useContext(AccordionGroupContext);\n const { isWrapped: isParentWrapped } = useContext(AccordionContext);\n\n const [isAccordionOpen, setIsAccordionOpen] = useState<boolean>(isDefaultOpen ?? isOpened);\n\n const uuid = useUuid();\n\n const isInitialRenderRef = useRef(true);\n\n const isInGroup = typeof updateOpenAccordionUuid === 'function';\n\n const isOpen = isInGroup ? openAccordionUuid === uuid : isAccordionOpen;\n\n const onCloseRef = useRef(onClose);\n const onOpenRef = useRef(onOpen);\n\n useEffect(() => {\n onCloseRef.current = onClose;\n onOpenRef.current = onOpen;\n }, [onClose, onOpen]);\n\n const handleHeadClick = useCallback(() => {\n if (isDisabled) {\n return;\n }\n\n if (typeof updateOpenAccordionUuid === 'function') {\n updateOpenAccordionUuid(uuid);\n }\n\n setIsAccordionOpen((currentIsAccordionOpen) => !currentIsAccordionOpen);\n }, [isDisabled, updateOpenAccordionUuid, uuid]);\n\n useEffect(() => {\n if (isDisabled && isOpen) {\n if (typeof updateOpenAccordionUuid === 'function') {\n updateOpenAccordionUuid(uuid);\n }\n\n setIsAccordionOpen((currentIsAccordionOpen) => !currentIsAccordionOpen);\n }\n }, [isDisabled, isOpen, updateOpenAccordionUuid, uuid]);\n\n useEffect(() => {\n if (isInitialRenderRef.current) {\n isInitialRenderRef.current = false;\n } else if (isOpen) {\n if (typeof onOpenRef.current === 'function') {\n onOpenRef.current();\n }\n } else if (typeof onCloseRef.current === 'function') {\n onCloseRef.current();\n }\n }, [isOpen]);\n\n useEffect(() => {\n if (isDefaultOpen) {\n if (typeof updateOpenAccordionUuid === 'function') {\n updateOpenAccordionUuid(uuid, { shouldOnlyOpen: true });\n } else {\n setIsAccordionOpen(true);\n }\n }\n }, [isDefaultOpen, updateOpenAccordionUuid, uuid]);\n\n useEffect(() => {\n if (typeof isOpened === 'boolean') {\n if (typeof updateOpenAccordionUuid === 'function' && isOpened) {\n updateOpenAccordionUuid(uuid);\n } else {\n setIsAccordionOpen(isOpened);\n }\n }\n }, [isOpened, updateOpenAccordionUuid, uuid]);\n\n const accordionContextProviderValue = useMemo(() => ({ isWrapped }), [isWrapped]);\n\n return (\n <StyledAccordion\n className=\"beta-chayns-accordion\"\n $isOpen={isOpen}\n $isParentWrapped={isParentWrapped}\n $isWrapped={isWrapped}\n $shouldForceBackground={shouldForceBackground}\n $shouldHideBackground={shouldHideBackground}\n >\n <AccordionContext.Provider value={accordionContextProviderValue}>\n <MotionConfig transition={{ type: 'tween' }}>\n <AccordionHead\n icon={icon}\n isOpen={isOpen}\n isFixed={isFixed}\n isTitleGreyed={isTitleGreyed || isDisabled}\n isWrapped={isWrapped}\n onClick={handleHeadClick}\n onSearchChange={onSearchChange}\n rightElement={rightElement}\n searchIcon={searchIcon}\n searchPlaceholder={searchPlaceholder}\n searchValue={searchValue}\n shouldRotateIcon={shouldRotateIcon}\n title={title}\n titleElement={titleElement}\n />\n <AnimatePresence initial={false}>\n {(isOpen || shouldRenderClosed) && (\n <AccordionBody\n maxHeight={bodyMaxHeight}\n onScroll={onBodyScroll}\n shouldHideBody={shouldRenderClosed && !isOpen}\n >\n {children}\n </AccordionBody>\n )}\n </AnimatePresence>\n </MotionConfig>\n </AccordionContext.Provider>\n </StyledAccordion>\n );\n};\n\nAccordion.displayName = 'Accordion';\n\nexport default Accordion;\n"],"mappings":"AAAA,SAASA,eAAe,EAAEC,YAAY,QAAQ,eAAe;AAC7D,OAAOC,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AA,CAAAuD,aAAA,CAACxD,YAAY;IAACiE,UAAU,EAAE;MAAEC,IAAI,EAAE;IAAQ;EAAE,gBACxCjE,KAAA,CAAAuD,aAAA,CAAC7C,aAAa;IACVS,IAAI,EAAEA,IAAK;IACX4B,MAAM,EAAEA,MAAO;IACfzB,OAAO,EAAEA,OAAQ;IACjBE,aAAa,EAAEA,aAAa,IAAIH,UAAW;IAC3CP,SAAS,EAAEA,SAAU;IACrBoD,OAAO,EAAEf,eAAgB;IACzBvB,cAAc,EAAEA,cAAe;IAC/BC,YAAY,EAAEA,YAAa;IAC3BC,UAAU,EAAEA,UAAW;IACvBC,iBAAiB,EAAEA,iBAAkB;IACrCC,WAAW,EAAEA,WAAY;IACzBG,gBAAgB,EAAEA,gBAAiB;IACnCC,KAAK,EAAEA,KAAM;IACbC,YAAY,EAAEA;EAAa,CAC9B,CAAC,eACFrC,KAAA,CAAAuD,aAAA,CAACzD,eAAe;IAACqE,OAAO,EAAE;EAAM,GAC3B,CAACpB,MAAM,IAAIT,kBAAkB,kBAC1BtC,KAAA,CAAAuD,aAAA,CAAC/C,aAAa;IACV4D,SAAS,EAAEnD,aAAc;IACzBoD,QAAQ,EAAE5C,YAAa;IACvB6C,cAAc,EAAEhC,kBAAkB,IAAI,CAACS;EAAO,GAE7C7B,QACU,CAEN,CACP,CACS,CACd,CAAC;AAE1B,CAAC;AAEDH,SAAS,CAACwD,WAAW,GAAG,WAAW;AAEnC,eAAexD,SAAS"}
|
|
1
|
+
{"version":3,"file":"Accordion.js","names":["AnimatePresence","MotionConfig","React","useCallback","useContext","useEffect","useMemo","useRef","useState","useUuid","AccordionBody","AccordionGroupContext","AccordionHead","StyledAccordion","AccordionContext","createContext","isWrapped","Accordion","_ref","bodyMaxHeight","children","icon","isDefaultOpen","isDisabled","isFixed","isOpened","isTitleGreyed","onBodyScroll","onClose","onOpen","onSearchChange","rightElement","searchIcon","searchPlaceholder","searchValue","shouldForceBackground","shouldHideBackground","shouldRotateIcon","title","titleElement","shouldRenderClosed","openAccordionUuid","updateOpenAccordionUuid","isParentWrapped","isAccordionOpen","setIsAccordionOpen","uuid","isInitialRenderRef","isInGroup","isOpen","onCloseRef","onOpenRef","current","handleHeadClick","currentIsAccordionOpen","shouldOnlyOpen","accordionContextProviderValue","createElement","className","$isOpen","$isParentWrapped","$isWrapped","$shouldForceBackground","$shouldHideBackground","Provider","value","transition","type","onClick","initial","maxHeight","onScroll","shouldHideBody","displayName"],"sources":["../../../src/components/accordion/Accordion.tsx"],"sourcesContent":["import { AnimatePresence, MotionConfig } from 'framer-motion';\nimport React, {\n ChangeEventHandler,\n FC,\n ReactNode,\n UIEvent,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useUuid } from '../../hooks/uuid';\nimport AccordionBody from './accordion-body/AccordionBody';\nimport { AccordionGroupContext } from './accordion-group/AccordionGroup';\nimport AccordionHead from './accordion-head/AccordionHead';\nimport { StyledAccordion } from './Accordion.styles';\n\nexport const AccordionContext = React.createContext({ isWrapped: false });\n\nexport type AccordionProps = {\n /**\n * Maximum height of the accordion body element. This automatically makes the content of the\n * body element scrollable.\n */\n bodyMaxHeight?: number;\n /**\n * The content of the accordion body\n */\n children: ReactNode;\n /**\n * The icon that is displayed in front of the title\n */\n icon?: string;\n /**\n * This can be used to automatically expand the Accordion during the first render.\n */\n isDefaultOpen?: boolean;\n /**\n * This will disable the Accordion so that it cannot be opened and will gray out the title. Does not work with isOpened.\n */\n isDisabled?: boolean;\n /**\n * This can be used so that the Accordion cannot be opened or closed.\n * In addition, in this case the icon is exchanged to mark the Accordions.\n */\n isFixed?: boolean;\n /**\n * This can be used to open the Accordion from the outside.\n */\n isOpened?: boolean;\n /**\n * This will gray out the title of the Accordion to indicate hidden content, for example.\n */\n isTitleGreyed?: boolean;\n /**\n * Function that is executed when the accordion body will be scrolled\n */\n onBodyScroll?: (event: UIEvent<HTMLDivElement>) => void;\n /**\n * Function that is executed when the accordion will be closed.\n */\n onClose?: VoidFunction;\n /**\n * Function that is executed when the accordion will be opened.\n */\n onOpen?: VoidFunction;\n /**\n * Function that is executed when the text of the search in the accordion\n * head changes. When this function is given, the search field is displayed\n * in the Accordion Head.\n */\n onSearchChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Content to be displayed on the right side in the head of the Accordion\n */\n rightElement?: ReactNode;\n /**\n * Icon to be displayed on the right side in the search input\n */\n searchIcon?: string[];\n /**\n * The placeholder to be used for the search\n */\n searchPlaceholder?: string;\n /**\n * The value that is displayed inside the search\n */\n searchValue?: string;\n /**\n * This will force the background color of the accordion to be used even if it is closed and not hovered.\n */\n shouldForceBackground?: boolean;\n /**\n * This will hide the background color of the accordion\n */\n shouldHideBackground?: boolean;\n /**\n * Whether the icon should be rotating.\n */\n shouldRotateIcon?: boolean;\n /**\n * Title of the Accordion displayed in the head\n */\n title: string;\n /**\n * Additional elements to be displayed in the header next to the title.\n */\n titleElement?: ReactNode;\n /**\n * This will render the Accordion closed on the first render.\n */\n shouldRenderClosed?: boolean;\n};\n\nconst Accordion: FC<AccordionProps> = ({\n bodyMaxHeight,\n children,\n icon,\n isDefaultOpen = false,\n isDisabled = false,\n isFixed = false,\n isOpened,\n isTitleGreyed = false,\n onBodyScroll,\n onClose,\n onOpen,\n onSearchChange,\n rightElement,\n searchIcon,\n searchPlaceholder,\n searchValue,\n shouldForceBackground = false,\n shouldHideBackground = false,\n shouldRotateIcon = true,\n title,\n titleElement,\n shouldRenderClosed = false,\n}) => {\n const { isWrapped, openAccordionUuid, updateOpenAccordionUuid } =\n useContext(AccordionGroupContext);\n const { isWrapped: isParentWrapped } = useContext(AccordionContext);\n\n const [isAccordionOpen, setIsAccordionOpen] = useState<boolean>(isDefaultOpen ?? isOpened);\n\n const uuid = useUuid();\n\n const isInitialRenderRef = useRef(true);\n\n const isInGroup = typeof updateOpenAccordionUuid === 'function';\n\n const isOpen = isInGroup ? openAccordionUuid === uuid : isAccordionOpen;\n\n const onCloseRef = useRef(onClose);\n const onOpenRef = useRef(onOpen);\n\n useEffect(() => {\n onCloseRef.current = onClose;\n onOpenRef.current = onOpen;\n }, [onClose, onOpen]);\n\n const handleHeadClick = useCallback(() => {\n if (isDisabled) {\n return;\n }\n\n if (typeof updateOpenAccordionUuid === 'function') {\n updateOpenAccordionUuid(uuid);\n }\n\n setIsAccordionOpen((currentIsAccordionOpen) => !currentIsAccordionOpen);\n }, [isDisabled, updateOpenAccordionUuid, uuid]);\n\n useEffect(() => {\n if (isDisabled && isOpen) {\n if (typeof updateOpenAccordionUuid === 'function') {\n updateOpenAccordionUuid(uuid);\n }\n\n setIsAccordionOpen((currentIsAccordionOpen) => !currentIsAccordionOpen);\n }\n }, [isDisabled, isOpen, updateOpenAccordionUuid, uuid]);\n\n useEffect(() => {\n if (isInitialRenderRef.current) {\n isInitialRenderRef.current = false;\n } else if (isOpen) {\n if (typeof onOpenRef.current === 'function') {\n onOpenRef.current();\n }\n } else if (typeof onCloseRef.current === 'function') {\n onCloseRef.current();\n }\n }, [isOpen]);\n\n useEffect(() => {\n if (isDefaultOpen) {\n if (typeof updateOpenAccordionUuid === 'function') {\n updateOpenAccordionUuid(uuid, { shouldOnlyOpen: true });\n } else {\n setIsAccordionOpen(true);\n }\n }\n }, [isDefaultOpen, updateOpenAccordionUuid, uuid]);\n\n useEffect(() => {\n if (typeof isOpened === 'boolean') {\n if (typeof updateOpenAccordionUuid === 'function' && isOpened) {\n updateOpenAccordionUuid(uuid);\n } else {\n setIsAccordionOpen(isOpened);\n }\n }\n }, [isOpened, updateOpenAccordionUuid, uuid]);\n\n const accordionContextProviderValue = useMemo(\n () => ({ isWrapped: isWrapped === true }),\n [isWrapped],\n );\n\n return (\n <StyledAccordion\n className=\"beta-chayns-accordion\"\n $isOpen={isOpen}\n $isParentWrapped={isParentWrapped}\n $isWrapped={isWrapped}\n $shouldForceBackground={shouldForceBackground}\n $shouldHideBackground={shouldHideBackground}\n >\n <AccordionContext.Provider value={accordionContextProviderValue}>\n <MotionConfig transition={{ type: 'tween' }}>\n <AccordionHead\n icon={icon}\n isOpen={isOpen}\n isFixed={isFixed}\n isTitleGreyed={isTitleGreyed || isDisabled}\n isWrapped={isWrapped === true}\n onClick={handleHeadClick}\n onSearchChange={onSearchChange}\n rightElement={rightElement}\n searchIcon={searchIcon}\n searchPlaceholder={searchPlaceholder}\n searchValue={searchValue}\n shouldRotateIcon={shouldRotateIcon}\n title={title}\n titleElement={titleElement}\n />\n <AnimatePresence initial={false}>\n {(isOpen || shouldRenderClosed) && (\n <AccordionBody\n maxHeight={bodyMaxHeight}\n onScroll={onBodyScroll}\n shouldHideBody={shouldRenderClosed && !isOpen}\n >\n {children}\n </AccordionBody>\n )}\n </AnimatePresence>\n </MotionConfig>\n </AccordionContext.Provider>\n </StyledAccordion>\n );\n};\n\nAccordion.displayName = 'Accordion';\n\nexport default Accordion;\n"],"mappings":"AAAA,SAASA,eAAe,EAAEC,YAAY,QAAQ,eAAe;AAC7D,OAAOC,KAAK,IAKRC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,OAAOC,aAAa,MAAM,gCAAgC;AAC1D,SAASC,qBAAqB,QAAQ,kCAAkC;AACxE,OAAOC,aAAa,MAAM,gCAAgC;AAC1D,SAASC,eAAe,QAAQ,oBAAoB;AAEpD,OAAO,MAAMC,gBAAgB,gBAAGZ,KAAK,CAACa,aAAa,CAAC;EAAEC,SAAS,EAAE;AAAM,CAAC,CAAC;AAiGzE,MAAMC,SAA6B,GAAGC,IAAA,IAuBhC;EAAA,IAvBiC;IACnCC,aAAa;IACbC,QAAQ;IACRC,IAAI;IACJC,aAAa,GAAG,KAAK;IACrBC,UAAU,GAAG,KAAK;IAClBC,OAAO,GAAG,KAAK;IACfC,QAAQ;IACRC,aAAa,GAAG,KAAK;IACrBC,YAAY;IACZC,OAAO;IACPC,MAAM;IACNC,cAAc;IACdC,YAA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C3B,CAACpB,MAAM,IAAIT,kBAAkB,kBAC1BtC,KAAA,CAAAuD,aAAA,CAAC/C,aAAa;IACV4D,SAAS,EAAEnD,aAAc;IACzBoD,QAAQ,EAAE5C,YAAa;IACvB6C,cAAc,EAAEhC,kBAAkB,IAAI,CAACS;EAAO,GAE7C7B,QACU,CAEN,CACP,CACS,CACd,CAAC;AAE1B,CAAC;AAEDH,SAAS,CAACwD,WAAW,GAAG,WAAW;AAEnC,eAAexD,SAAS"}
|
|
@@ -3,7 +3,8 @@ type IUpdateOpenAccordionUuid = (uuid: string, options?: {
|
|
|
3
3
|
shouldOnlyOpen?: boolean;
|
|
4
4
|
}) => void;
|
|
5
5
|
interface IAccordionGroupContext {
|
|
6
|
-
|
|
6
|
+
isWrapped?: boolean;
|
|
7
|
+
openAccordionUuid?: string;
|
|
7
8
|
setOpenAccordionUuid?: Dispatch<SetStateAction<string | undefined>>;
|
|
8
9
|
updateOpenAccordionUuid?: IUpdateOpenAccordionUuid;
|
|
9
10
|
}
|
|
@@ -14,6 +15,11 @@ type AccordionGroupProps = {
|
|
|
14
15
|
* automatically closed when an `Accordion` of the group is opened.
|
|
15
16
|
*/
|
|
16
17
|
children: ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* This value must be set for nested AccordionGroup components. This adjusts the style of
|
|
20
|
+
* the head and the padding of the content accordions.
|
|
21
|
+
*/
|
|
22
|
+
isWrapped?: boolean;
|
|
17
23
|
/**
|
|
18
24
|
* Function that is executed when all accordions in group are closed.
|
|
19
25
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
export const AccordionGroupContext = /*#__PURE__*/React.createContext({
|
|
3
|
+
isWrapped: undefined,
|
|
3
4
|
openAccordionUuid: undefined,
|
|
4
5
|
setOpenAccordionUuid: undefined,
|
|
5
6
|
updateOpenAccordionUuid: undefined
|
|
@@ -8,6 +9,7 @@ AccordionGroupContext.displayName = 'AccordionGroupContext';
|
|
|
8
9
|
const AccordionGroup = _ref => {
|
|
9
10
|
let {
|
|
10
11
|
children,
|
|
12
|
+
isWrapped = false,
|
|
11
13
|
onClose,
|
|
12
14
|
onOpen
|
|
13
15
|
} = _ref;
|
|
@@ -36,10 +38,11 @@ const AccordionGroup = _ref => {
|
|
|
36
38
|
}
|
|
37
39
|
}, [onClose, onOpen, openAccordionUuid]);
|
|
38
40
|
const providerValue = useMemo(() => ({
|
|
41
|
+
isWrapped,
|
|
39
42
|
openAccordionUuid,
|
|
40
43
|
setOpenAccordionUuid,
|
|
41
44
|
updateOpenAccordionUuid
|
|
42
|
-
}), [openAccordionUuid, updateOpenAccordionUuid]);
|
|
45
|
+
}), [isWrapped, openAccordionUuid, updateOpenAccordionUuid]);
|
|
43
46
|
return /*#__PURE__*/React.createElement(AccordionGroupContext.Provider, {
|
|
44
47
|
value: providerValue
|
|
45
48
|
}, children);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccordionGroup.js","names":["React","useCallback","useEffect","useMemo","useRef","useState","AccordionGroupContext","createContext","
|
|
1
|
+
{"version":3,"file":"AccordionGroup.js","names":["React","useCallback","useEffect","useMemo","useRef","useState","AccordionGroupContext","createContext","isWrapped","undefined","openAccordionUuid","setOpenAccordionUuid","updateOpenAccordionUuid","displayName","AccordionGroup","_ref","children","onClose","onOpen","isInitialRenderRef","uuid","shouldOnlyOpen","arguments","length","currentOpenAccordionUuid","current","providerValue","createElement","Provider","value"],"sources":["../../../../src/components/accordion/accordion-group/AccordionGroup.tsx"],"sourcesContent":["import React, {\n Dispatch,\n FC,\n ReactNode,\n SetStateAction,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\ntype IUpdateOpenAccordionUuid = (uuid: string, options?: { shouldOnlyOpen?: boolean }) => void;\n\ninterface IAccordionGroupContext {\n isWrapped?: boolean;\n openAccordionUuid?: string;\n setOpenAccordionUuid?: Dispatch<SetStateAction<string | undefined>>;\n updateOpenAccordionUuid?: IUpdateOpenAccordionUuid;\n}\n\nexport const AccordionGroupContext = React.createContext<IAccordionGroupContext>({\n isWrapped: undefined,\n openAccordionUuid: undefined,\n setOpenAccordionUuid: undefined,\n updateOpenAccordionUuid: undefined,\n});\n\nAccordionGroupContext.displayName = 'AccordionGroupContext';\n\ntype AccordionGroupProps = {\n /**\n * The Accordions that should be grouped. Accordions with the same group are\n * automatically closed when an `Accordion` of the group is opened.\n */\n children: ReactNode;\n /**\n * This value must be set for nested AccordionGroup components. This adjusts the style of\n * the head and the padding of the content accordions.\n */\n isWrapped?: boolean;\n /**\n * Function that is executed when all accordions in group are closed.\n */\n onClose?: VoidFunction;\n /**\n * Function that is executed when any accordion in group will be opened.\n */\n onOpen?: VoidFunction;\n};\n\nconst AccordionGroup: FC<AccordionGroupProps> = ({\n children,\n isWrapped = false,\n onClose,\n onOpen,\n}) => {\n const [openAccordionUuid, setOpenAccordionUuid] =\n useState<IAccordionGroupContext['openAccordionUuid']>(undefined);\n\n const isInitialRenderRef = useRef(true);\n\n const updateOpenAccordionUuid = useCallback<IUpdateOpenAccordionUuid>(\n (uuid, { shouldOnlyOpen } = {}) => {\n setOpenAccordionUuid((currentOpenAccordionUuid) => {\n if (currentOpenAccordionUuid === uuid && shouldOnlyOpen !== true) {\n return undefined;\n }\n\n return uuid;\n });\n },\n [setOpenAccordionUuid],\n );\n\n useEffect(() => {\n if (isInitialRenderRef.current) {\n isInitialRenderRef.current = false;\n } else if (typeof openAccordionUuid === 'string') {\n if (typeof onOpen === 'function') {\n onOpen();\n }\n } else if (typeof onClose === 'function') {\n onClose();\n }\n }, [onClose, onOpen, openAccordionUuid]);\n\n const providerValue = useMemo<IAccordionGroupContext>(\n () => ({\n isWrapped,\n openAccordionUuid,\n setOpenAccordionUuid,\n updateOpenAccordionUuid,\n }),\n [isWrapped, openAccordionUuid, updateOpenAccordionUuid],\n );\n\n return (\n <AccordionGroupContext.Provider value={providerValue}>\n {children}\n </AccordionGroupContext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AAE;MAC9C,IAAI,OAAOQ,MAAM,KAAK,UAAU,EAAE;QAC9BA,MAAM,CAAC,CAAC;MACZ;IACJ,CAAC,MAAM,IAAI,OAAOD,OAAO,KAAK,UAAU,EAAE;MACtCA,OAAO,CAAC,CAAC;IACb;EACJ,CAAC,EAAE,CAACA,OAAO,EAAEC,MAAM,EAAER,iBAAiB,CAAC,CAAC;EAExC,MAAMgB,aAAa,GAAGvB,OAAO,CACzB,OAAO;IACHK,SAAS;IACTE,iBAAiB;IACjBC,oBAAoB;IACpBC;EACJ,CAAC,CAAC,EACF,CAACJ,SAAS,EAAEE,iBAAiB,EAAEE,uBAAuB,CAC1D,CAAC;EAED,oBACIZ,KAAA,CAAA2B,aAAA,CAACrB,qBAAqB,CAACsB,QAAQ;IAACC,KAAK,EAAEH;EAAc,GAChDV,QAC2B,CAAC;AAEzC,CAAC;AAEDF,cAAc,CAACD,WAAW,GAAG,gBAAgB;AAE7C,eAAeC,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.styles.js","names":["motion","styled","css","StyledInput","div","_ref","$isDisabled","StyledInputContentWrapper","_ref2","theme","_ref3","$isInvalid","wrong","_ref4","_ref5","$shouldRoundRightCorners","$shouldShowOnlyBottomBorder","StyledInputContent","StyledInputField","input","_ref6","text","StyledMotionInputLabelWrapper","label","_ref7","$width","StyledInputLabel","_ref8","undefined","StyledMotionInputClearIcon","_ref9","StyledInputIconWrapper","StyledInputRightElement"],"sources":["../../../src/components/input/Input.styles.ts"],"sourcesContent":["import { motion } from 'framer-motion';\nimport styled, { css } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledInputProps = WithTheme<{ $isDisabled?: boolean; $isInvalid?: boolean }>;\n\nexport const StyledInput = styled.div<StyledInputProps>`\n opacity: ${({ $isDisabled }) => ($isDisabled ? 0.5 : 1)};\n display: flex;\n width: 100%;\n`;\n\ntype StyledInputContentWrapperProps = WithTheme<{\n $shouldRoundRightCorners: boolean;\n $shouldShowOnlyBottomBorder?: boolean;\n}>;\n\nexport const StyledInputContentWrapper = styled.div<StyledInputContentWrapperProps>`\n align-items: center;\n background-color: ${({ theme }: StyledInputProps) => theme['100']};\n border: 1px solid\n ${({ theme, $isInvalid }: StyledInputProps) =>\n $isInvalid ? theme.wrong : 'rgba(160, 160, 160, 0.3)'};\n color: ${({ theme }: StyledInputProps) => theme['006']};\n display: flex;\n justify-content: space-between;\n min-height: 42px;\n width: 100%;\n transition: opacity 0.3s ease;\n\n ${({ $shouldRoundRightCorners, $shouldShowOnlyBottomBorder, theme }) => {\n if ($shouldShowOnlyBottomBorder) {\n return css`\n border-top: none;\n border-right: none;\n border-left: none;\n background-color: transparent;\n border-color: ${theme['408']};\n `;\n }\n\n if ($shouldRoundRightCorners) {\n return css`\n border-radius: 3px;\n `;\n }\n\n return css`\n border-bottom-left-radius: 3px;\n border-top-left-radius: 3px;\n `;\n }}\n`;\n\nexport const StyledInputContent = styled.div`\n display: flex;\n flex: 1 1 auto;\n min-width: 0;\n margin: 8px 10px;\n position: relative;\n`;\n\ntype StyledInputFieldProps = WithTheme<{ $isInvalid?: boolean }>;\n\nexport const StyledInputField = styled.input<StyledInputFieldProps>`\n background: none;\n border: none;\n color: ${({ theme, $isInvalid }: StyledInputFieldProps) =>\n $isInvalid ? theme.wrong : theme.text};\n padding: 0;\n width: 100%;\n`;\n\ntype StyledMotionInputLabelWrapperProps = WithTheme<{ $width: number }>;\n\nexport const StyledMotionInputLabelWrapper = styled(\n motion.label,\n)<StyledMotionInputLabelWrapperProps>`\n align-items: baseline;\n display: flex;\n flex: 0 0 auto;\n gap: 4px;\n line-height: 1.3;\n pointer-events: none;\n position: absolute;\n user-select: none;\n max-width: ${({ $width }) => $width}px;\n`;\n\ntype StyledInputLabelProps = WithTheme<{ $isInvalid?: boolean }>;\n\nexport const StyledInputLabel = styled.label<StyledInputLabelProps>`\n line-height: 1.3;\n pointer-events: none;\n width: 100%;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n color: ${({ theme, $isInvalid }: StyledInputLabelProps) =>\n $isInvalid ? theme.wrong : undefined};\n`;\n\ntype StyledMotionInputClearIconProps = WithTheme<{ $shouldShowOnlyBottomBorder?: boolean }>;\n\nexport const StyledMotionInputClearIcon = styled(motion.div)<StyledMotionInputClearIconProps>`\n align-items: center;\n border-left: ${({ $shouldShowOnlyBottomBorder }) =>\n $shouldShowOnlyBottomBorder ? 'none' : '1px solid rgba(160, 160, 160, 0.3)'};\n cursor: pointer;\n display: flex;\n flex: 0 0 auto;\n height: 40px;\n justify-content: center;\n width: 40px;\n`;\n\nexport const StyledInputIconWrapper = styled.div`\n align-items: baseline;\n display: flex;\n flex: 0 0 auto;\n justify-content: center;\n margin-left: 10px;\n`;\n\nexport const StyledInputRightElement = styled.div`\n border-bottom-right-radius: 3px;\n border-top-right-radius: 3px;\n overflow: hidden;\n flex: 0 0 auto;\n`;\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,eAAe;AACtC,OAAOC,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAK/C,OAAO,MAAMC,WAAW,GAAGF,MAAM,CAACG,GAAsB;AACxD,eAAeC,IAAA;EAAA,IAAC;IAAEC;EAAY,CAAC,GAAAD,IAAA;EAAA,OAAMC,WAAW,GAAG,GAAG,GAAG,CAAC;AAAA,CAAE;AAC5D;AACA;AACA,CAAC;AAOD,OAAO,MAAMC,yBAAyB,GAAGN,MAAM,CAACG,GAAoC;AACpF;AACA,wBAAwBI,KAAA;EAAA,IAAC;IAAEC;EAAwB,CAAC,GAAAD,KAAA;EAAA,OAAKC,KAAK,CAAC,KAAK,CAAC;AAAA,CAAC;AACtE;AACA,UAAUC,KAAA;EAAA,IAAC;IAAED,KAAK;IAAEE;EAA6B,CAAC,GAAAD,KAAA;EAAA,OACtCC,UAAU,GAAGF,KAAK,CAACG,KAAK,GAAG,0BAA0B;AAAA,CAAC;AAClE,aAAaC,KAAA;EAAA,IAA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AAK,CAACG,KAAK,GAAGgB,SAAS;AAAA,CAAC;AAC7C,CAAC;AAID,OAAO,MAAMC,0BAA0B,GAAG5B,MAAM,CAACD,MAAM,CAACI,GAAG,CAAmC;AAC9F;AACA,mBAAmB0B,KAAA;EAAA,IAAC;IAAEd;EAA4B,CAAC,GAAAc,KAAA;EAAA,OAC3Cd,2BAA2B,GAAG,MAAM,GAAG,oCAAoC;AAAA,CAAC;AACpF;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMe,sBAAsB,GAAG9B,MAAM,CAACG,GAAI;AACjD;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAM4B,uBAAuB,GAAG/B,MAAM,CAACG,GAAI;AAClD;AACA;AACA;AACA;AACA,CAAC"}
|
|
1
|
+
{"version":3,"file":"Input.styles.js","names":["motion","styled","css","StyledInput","div","_ref","$isDisabled","StyledInputContentWrapper","_ref2","theme","_ref3","$isInvalid","wrong","_ref4","_ref5","$shouldRoundRightCorners","$shouldShowOnlyBottomBorder","StyledInputContent","StyledInputField","input","_ref6","text","StyledMotionInputLabelWrapper","label","_ref7","$width","StyledInputLabel","_ref8","undefined","StyledMotionInputClearIcon","_ref9","StyledInputIconWrapper","StyledInputRightElement"],"sources":["../../../src/components/input/Input.styles.ts"],"sourcesContent":["import { motion } from 'framer-motion';\nimport styled, { css } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledInputProps = WithTheme<{ $isDisabled?: boolean; $isInvalid?: boolean }>;\n\nexport const StyledInput = styled.div<StyledInputProps>`\n opacity: ${({ $isDisabled }) => ($isDisabled ? 0.5 : 1)};\n display: flex;\n width: 100%;\n`;\n\ntype StyledInputContentWrapperProps = WithTheme<{\n $shouldRoundRightCorners: boolean;\n $shouldShowOnlyBottomBorder?: boolean;\n}>;\n\nexport const StyledInputContentWrapper = styled.div<StyledInputContentWrapperProps>`\n align-items: center;\n background-color: ${({ theme }: StyledInputProps) => theme['100']};\n border: 1px solid\n ${({ theme, $isInvalid }: StyledInputProps) =>\n $isInvalid ? theme.wrong : 'rgba(160, 160, 160, 0.3)'};\n color: ${({ theme }: StyledInputProps) => theme['006']};\n display: flex;\n justify-content: space-between;\n min-height: 42px;\n width: 100%;\n transition: opacity 0.3s ease;\n\n ${({ $shouldRoundRightCorners, $shouldShowOnlyBottomBorder, theme }) => {\n if ($shouldShowOnlyBottomBorder) {\n return css`\n border-top: none;\n border-right: none;\n border-left: none;\n background-color: transparent;\n border-color: ${theme['408']};\n `;\n }\n\n if ($shouldRoundRightCorners) {\n return css`\n border-radius: 3px;\n `;\n }\n\n return css`\n border-bottom-left-radius: 3px;\n border-top-left-radius: 3px;\n border-right: none;\n `;\n }}\n`;\n\nexport const StyledInputContent = styled.div`\n display: flex;\n flex: 1 1 auto;\n min-width: 0;\n margin: 8px 10px;\n position: relative;\n`;\n\ntype StyledInputFieldProps = WithTheme<{ $isInvalid?: boolean }>;\n\nexport const StyledInputField = styled.input<StyledInputFieldProps>`\n background: none;\n border: none;\n color: ${({ theme, $isInvalid }: StyledInputFieldProps) =>\n $isInvalid ? theme.wrong : theme.text};\n padding: 0;\n width: 100%;\n`;\n\ntype StyledMotionInputLabelWrapperProps = WithTheme<{ $width: number }>;\n\nexport const StyledMotionInputLabelWrapper = styled(\n motion.label,\n)<StyledMotionInputLabelWrapperProps>`\n align-items: baseline;\n display: flex;\n flex: 0 0 auto;\n gap: 4px;\n line-height: 1.3;\n pointer-events: none;\n position: absolute;\n user-select: none;\n max-width: ${({ $width }) => $width}px;\n`;\n\ntype StyledInputLabelProps = WithTheme<{ $isInvalid?: boolean }>;\n\nexport const StyledInputLabel = styled.label<StyledInputLabelProps>`\n line-height: 1.3;\n pointer-events: none;\n width: 100%;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n color: ${({ theme, $isInvalid }: StyledInputLabelProps) =>\n $isInvalid ? theme.wrong : undefined};\n`;\n\ntype StyledMotionInputClearIconProps = WithTheme<{ $shouldShowOnlyBottomBorder?: boolean }>;\n\nexport const StyledMotionInputClearIcon = styled(motion.div)<StyledMotionInputClearIconProps>`\n align-items: center;\n border-left: ${({ $shouldShowOnlyBottomBorder }) =>\n $shouldShowOnlyBottomBorder ? 'none' : '1px solid rgba(160, 160, 160, 0.3)'};\n cursor: pointer;\n display: flex;\n flex: 0 0 auto;\n height: 40px;\n justify-content: center;\n width: 40px;\n`;\n\nexport const StyledInputIconWrapper = styled.div`\n align-items: baseline;\n display: flex;\n flex: 0 0 auto;\n justify-content: center;\n margin-left: 10px;\n`;\n\nexport const StyledInputRightElement = styled.div`\n border-bottom-right-radius: 3px;\n border-top-right-radius: 3px;\n overflow: hidden;\n flex: 0 0 auto;\n`;\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,eAAe;AACtC,OAAOC,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAK/C,OAAO,MAAMC,WAAW,GAAGF,MAAM,CAACG,GAAsB;AACxD,eAAeC,IAAA;EAAA,IAAC;IAAEC;EAAY,CAAC,GAAAD,IAAA;EAAA,OAAMC,WAAW,GAAG,GAAG,GAAG,CAAC;AAAA,CAAE;AAC5D;AACA;AACA,CAAC;AAOD,OAAO,MAAMC,yBAAyB,GAAGN,MAAM,CAACG,GAAoC;AACpF;AACA,wBAAwBI,KAAA;EAAA,IAAC;IAAEC;EAAwB,CAAC,GAAAD,KAAA;EAAA,OAAKC,KAAK,CAAC,KAAK,CAAC;AAAA,CAAC;AACtE;AACA,UAAUC,KAAA;EAAA,IAAC;IAAED,KAAK;IAAEE;EAA6B,CAAC,GAAAD,KAAA;EAAA,OACtCC,UAAU,GAAGF,KAAK,CAACG,KAAK,GAAG,0BAA0B;AAAA,CAAC;AAClE,aAAaC,KAAA;EAAA,IAAC;IAAEJ;EAAwB,CAAC,GAAAI,KAAA;EAAA,OAAKJ,KAAK,CAAC,KAAK,CAAC;AAAA,CAAC;AAC3D;AACA;AACA;AACA;AACA;AACA;AACA,MAAM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AmC;AAC9F;AACA,mBAAmB0B,KAAA;EAAA,IAAC;IAAEd;EAA4B,CAAC,GAAAc,KAAA;EAAA,OAC3Cd,2BAA2B,GAAG,MAAM,GAAG,oCAAoC;AAAA,CAAC;AACpF;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMe,sBAAsB,GAAG9B,MAAM,CAACG,GAAI;AACjD;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAM4B,uBAAuB,GAAG/B,MAAM,CAACG,GAAI;AAClD;AACA;AACA;AACA;AACA,CAAC"}
|
|
@@ -2,6 +2,7 @@ import React, { FC, ReactNode } from 'react';
|
|
|
2
2
|
interface IListContext {
|
|
3
3
|
incrementExpandableItemCount: () => () => void;
|
|
4
4
|
isAnyItemExpandable: boolean;
|
|
5
|
+
isWrapped: boolean;
|
|
5
6
|
openItemUuid: string | undefined;
|
|
6
7
|
updateOpenItemUuid: (uuid: string, options?: {
|
|
7
8
|
shouldOnlyOpen?: boolean;
|
|
@@ -13,6 +14,11 @@ type ListProps = {
|
|
|
13
14
|
* The items of the list
|
|
14
15
|
*/
|
|
15
16
|
children: ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* This value must be set for nested AccordionGroup components. This adjusts the style of
|
|
19
|
+
* the head and the padding of the content accordions.
|
|
20
|
+
*/
|
|
21
|
+
isWrapped?: boolean;
|
|
16
22
|
};
|
|
17
23
|
declare const List: FC<ListProps>;
|
|
18
24
|
export default List;
|
|
@@ -2,13 +2,15 @@ import React, { useCallback, useMemo, useState } from 'react';
|
|
|
2
2
|
export const ListContext = /*#__PURE__*/React.createContext({
|
|
3
3
|
incrementExpandableItemCount: () => () => {},
|
|
4
4
|
isAnyItemExpandable: false,
|
|
5
|
+
isWrapped: false,
|
|
5
6
|
openItemUuid: undefined,
|
|
6
7
|
updateOpenItemUuid: () => {}
|
|
7
8
|
});
|
|
8
9
|
ListContext.displayName = 'ListContext';
|
|
9
10
|
const List = _ref => {
|
|
10
11
|
let {
|
|
11
|
-
children
|
|
12
|
+
children,
|
|
13
|
+
isWrapped = false
|
|
12
14
|
} = _ref;
|
|
13
15
|
const [openItemUuid, setOpenItemUuid] = useState(undefined);
|
|
14
16
|
const [expandableItemCount, setExpandableItemCount] = useState(0);
|
|
@@ -30,11 +32,12 @@ const List = _ref => {
|
|
|
30
32
|
};
|
|
31
33
|
}, [setExpandableItemCount]);
|
|
32
34
|
const providerValue = useMemo(() => ({
|
|
35
|
+
incrementExpandableItemCount,
|
|
33
36
|
isAnyItemExpandable: expandableItemCount > 0,
|
|
34
|
-
|
|
37
|
+
isWrapped,
|
|
35
38
|
openItemUuid,
|
|
36
|
-
|
|
37
|
-
}), [expandableItemCount, incrementExpandableItemCount, openItemUuid, updateOpenItemUuid]);
|
|
39
|
+
updateOpenItemUuid
|
|
40
|
+
}), [expandableItemCount, incrementExpandableItemCount, isWrapped, openItemUuid, updateOpenItemUuid]);
|
|
38
41
|
return /*#__PURE__*/React.createElement(ListContext.Provider, {
|
|
39
42
|
value: providerValue
|
|
40
43
|
}, children);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.js","names":["React","useCallback","useMemo","useState","ListContext","createContext","incrementExpandableItemCount","isAnyItemExpandable","openItemUuid","undefined","updateOpenItemUuid","displayName","List","_ref","children","setOpenItemUuid","expandableItemCount","setExpandableItemCount","uuid","shouldOnlyOpen","arguments","length","currentOpenItemUuid","count","providerValue","createElement","Provider","value"],"sources":["../../../src/components/list/List.tsx"],"sourcesContent":["import React, { FC, ReactNode, useCallback, useMemo, useState } from 'react';\n\ninterface IListContext {\n incrementExpandableItemCount: () => () => void;\n isAnyItemExpandable: boolean;\n openItemUuid: string | undefined;\n updateOpenItemUuid: (uuid: string, options?: { shouldOnlyOpen?: boolean }) => void;\n}\n\nexport const ListContext = React.createContext<IListContext>({\n incrementExpandableItemCount: () => () => {},\n isAnyItemExpandable: false,\n openItemUuid: undefined,\n updateOpenItemUuid: () => {},\n});\n\nListContext.displayName = 'ListContext';\n\ntype ListProps = {\n /**\n * The items of the list\n */\n children: ReactNode;\n};\n\nconst List: FC<ListProps> = ({ children }) => {\n const [openItemUuid, setOpenItemUuid] = useState<IListContext['openItemUuid']>(undefined);\n const [expandableItemCount, setExpandableItemCount] = useState<number>(0);\n\n const updateOpenItemUuid = useCallback<IListContext['updateOpenItemUuid']>(\n (uuid, { shouldOnlyOpen } = {}) => {\n setOpenItemUuid((currentOpenItemUuid) => {\n if (currentOpenItemUuid === uuid && shouldOnlyOpen !== true) {\n return undefined;\n }\n\n return uuid;\n });\n },\n [setOpenItemUuid]
|
|
1
|
+
{"version":3,"file":"List.js","names":["React","useCallback","useMemo","useState","ListContext","createContext","incrementExpandableItemCount","isAnyItemExpandable","isWrapped","openItemUuid","undefined","updateOpenItemUuid","displayName","List","_ref","children","setOpenItemUuid","expandableItemCount","setExpandableItemCount","uuid","shouldOnlyOpen","arguments","length","currentOpenItemUuid","count","providerValue","createElement","Provider","value"],"sources":["../../../src/components/list/List.tsx"],"sourcesContent":["import React, { FC, ReactNode, useCallback, useMemo, useState } from 'react';\n\ninterface IListContext {\n incrementExpandableItemCount: () => () => void;\n isAnyItemExpandable: boolean;\n isWrapped: boolean;\n openItemUuid: string | undefined;\n updateOpenItemUuid: (uuid: string, options?: { shouldOnlyOpen?: boolean }) => void;\n}\n\nexport const ListContext = React.createContext<IListContext>({\n incrementExpandableItemCount: () => () => {},\n isAnyItemExpandable: false,\n isWrapped: false,\n openItemUuid: undefined,\n updateOpenItemUuid: () => {},\n});\n\nListContext.displayName = 'ListContext';\n\ntype ListProps = {\n /**\n * The items of the list\n */\n children: ReactNode;\n /**\n * This value must be set for nested AccordionGroup components. This adjusts the style of\n * the head and the padding of the content accordions.\n */\n isWrapped?: boolean;\n};\n\nconst List: FC<ListProps> = ({ children, isWrapped = false }) => {\n const [openItemUuid, setOpenItemUuid] = useState<IListContext['openItemUuid']>(undefined);\n const [expandableItemCount, setExpandableItemCount] = useState<number>(0);\n\n const updateOpenItemUuid = useCallback<IListContext['updateOpenItemUuid']>(\n (uuid, { shouldOnlyOpen } = {}) => {\n setOpenItemUuid((currentOpenItemUuid) => {\n if (currentOpenItemUuid === uuid && shouldOnlyOpen !== true) {\n return undefined;\n }\n\n return uuid;\n });\n },\n [setOpenItemUuid],\n );\n\n const incrementExpandableItemCount = useCallback(() => {\n setExpandableItemCount((count) => count + 1);\n\n return () => {\n setExpandableItemCount((count) => count - 1);\n };\n }, [setExpandableItemCount]);\n\n const providerValue = useMemo<IListContext>(\n () => ({\n incrementExpandableItemCount,\n isAnyItemExpandable: expandableItemCount > 0,\n isWrapped,\n openItemUuid,\n updateOpenItemUuid,\n }),\n [\n expandableItemCount,\n incrementExpandableItemCount,\n isWrapped,\n openItemUuid,\n updateOpenItemUuid,\n ],\n );\n\n return <ListContext.Provider value={providerValue}>{children}</ListContext.Provider>;\n};\n\nList.displayName = 'List';\n\nexport default List;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAmBC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAU5E,OAAO,MAAMC,WAAW,gBAAGJ,KAAK,CAACK,aAAa,CAAe;EACzDC,4BAA4B,EAAEA,CAAA,KAAM,MAAM,CAAC,CAAC;EAC5CC,mBAAmB,EAAE,KAAK;EAC1BC,SAAS,EAAE,KAAK;EAChBC,YAAY,EAAEC,SAAS;EACvBC,kBAAkB,EAAEA,CAAA,KAAM,CAAC;AAC/B,CAAC,CAAC;AAEFP,WAAW,CAACQ,WAAW,GAAG,aAAa;AAcvC,MAAMC,IAAmB,GAAGC,IAAA,IAAqC;EAAA,IAApC;IAAEC,QAAQ;IAAEP,SAAS,GAAG;EAAM,CAAC,GAAAM,IAAA;EACxD,MAAM,CAACL,YAAY,EAAEO,eAAe,CAAC,GAAGb,QAAQ,CAA+BO,SAAS,CAAC;EACzF,MAAM,CAACO,mBAAmB,EAAEC,sBAAsB,CAAC,GAAGf,QAAQ,CAAS,CAAC,CAAC;EAEzE,MAAMQ,kBAAkB,GAAGV,WAAW,CAClC,UAACkB,IAAI,EAA8B;IAAA,IAA5B;MAAEC;IAAe,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAX,SAAA,GAAAW,SAAA,MAAG,CAAC,CAAC;IAC1BL,eAAe,CAAEO,mBAAmB,IAAK;MACrC,IAAIA,mBAAmB,KAAKJ,IAAI,IAAIC,cAAc,KAAK,IAAI,EAAE;QACzD,OAAOV,SAAS;MACpB;MAEA,OAAOS,IAAI;IACf,CAAC,CAAC;EACN,CAAC,EACD,CAACH,eAAe,CACpB,CAAC;EAED,MAAMV,4BAA4B,GAAGL,WAAW,CAAC,MAAM;IACnDiB,sBAAsB,CAAEM,KAAK,IAAKA,KAAK,GAAG,CAAC,CAAC;IAE5C,OAAO,MAAM;MACTN,sBAAsB,CAAEM,KAAK,IAAKA,KAAK,GAAG,CAAC,CAAC;IAChD,CAAC;EACL,CAAC,EAAE,CAACN,sBAAsB,CAAC,CAAC;EAE5B,MAAMO,aAAa,GAAGvB,OAAO,CACzB,OAAO;IACHI,4BAA4B;IAC5BC,mBAAmB,EAAEU,mBAAmB,GAAG,CAAC;IAC5CT,SAAS;IACTC,YAAY;IACZE;EACJ,CAAC,CAAC,EACF,CACIM,mBAAmB,EACnBX,4BAA4B,EAC5BE,SAAS,EACTC,YAAY,EACZE,kBAAkB,CAE1B,CAAC;EAED,oBAAOX,KAAA,CAAA0B,aAAA,CAACtB,WAAW,CAACuB,QAAQ;IAACC,KAAK,EAAEH;EAAc,GAAEV,QAA+B,CAAC;AACxF,CAAC;AAEDF,IAAI,CAACD,WAAW,GAAG,MAAM;AAEzB,eAAeC,IAAI"}
|
|
@@ -24,6 +24,7 @@ const ListItem = _ref => {
|
|
|
24
24
|
const {
|
|
25
25
|
incrementExpandableItemCount,
|
|
26
26
|
isAnyItemExpandable,
|
|
27
|
+
isWrapped,
|
|
27
28
|
openItemUuid,
|
|
28
29
|
updateOpenItemUuid
|
|
29
30
|
} = useContext(ListContext);
|
|
@@ -56,7 +57,8 @@ const ListItem = _ref => {
|
|
|
56
57
|
return /*#__PURE__*/React.createElement(StyledListItem, {
|
|
57
58
|
className: "beta-chayns-list-item",
|
|
58
59
|
$isClickable: typeof onClick === 'function' || isExpandable,
|
|
59
|
-
$isOpen: isItemOpen
|
|
60
|
+
$isOpen: isItemOpen,
|
|
61
|
+
$isWrapped: isWrapped
|
|
60
62
|
}, /*#__PURE__*/React.createElement(ListItemHead, {
|
|
61
63
|
hoverItem: hoverItem,
|
|
62
64
|
icons: icons,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.js","names":["AnimatePresence","React","useCallback","useContext","useEffect","useUuid","ListContext","ListItemBody","ListItemHead","StyledListItem","ListItem","_ref","children","hoverItem","icons","images","isDefaultOpen","isOpen","onClick","onLongPress","leftElements","rightElements","subtitle","shouldShowRoundImage","title","incrementExpandableItemCount","isAnyItemExpandable","openItemUuid","updateOpenItemUuid","uuid","isExpandable","undefined","isItemOpen","handleHeadClick","event","shouldOnlyOpen","createElement","className","$isClickable","$isOpen","initial","id","displayName"],"sources":["../../../../src/components/list/list-item/ListItem.tsx"],"sourcesContent":["import { AnimatePresence } from 'framer-motion';\nimport React, {\n FC,\n MouseEventHandler,\n ReactNode,\n TouchEventHandler,\n useCallback,\n useContext,\n useEffect,\n} from 'react';\nimport { useUuid } from '../../../hooks/uuid';\nimport { ListContext } from '../List';\nimport ListItemBody from './list-item-body/ListItemBody';\nimport ListItemHead from './list-item-head/ListItemHead';\nimport { StyledListItem } from './ListItem.styles';\n\ntype ListItemProps = {\n /**\n * The content of the `ListItem` body. When the `ListItem` has children,\n * it can be opened and also gets an icon as an indicator automatically.\n */\n children?: ReactNode;\n /**\n * Element that is displayed when hovering over the `ListItem` on the right\n * side. On mobile devices, this element is not displayed.\n */\n hoverItem?: ReactNode;\n /**\n * The FontAwesome or tobit icons to render like an image on the left side\n * of the header. Multiple icons are stacked. See the `Icon` component\n * documentation for more information.\n */\n icons?: string[];\n /**\n * A list of image URLs that are displayed on the left side of the header.\n * If multiple URLs are passed, the image is assembled from the first three\n * image URLs as a puzzle.\n */\n images?: string[];\n /**\n * This can be used to automatically expand the `ListItem` during the first render.\n */\n isDefaultOpen?: boolean;\n /**\n * This overrides the internal opening state of the item and makes it controlled.\n */\n isOpen?: boolean;\n /**\n * Function to be executed when the header of the `ListItem` was clicked\n */\n onClick?: MouseEventHandler<HTMLDivElement>;\n /**\n * Function to be executed when the header of the `ListItem` is pressed for\n * 400 milliseconds.\n */\n onLongPress?: TouchEventHandler<HTMLDivElement>;\n /**\n * Elements that are displayed on the left side of the header. If multiple\n * elements are specified, they are displayed one aside the other.\n */\n leftElements?: [ReactNode, ...ReactNode[]];\n /**\n * Elements that are displayed on the right side of the header. If multiple\n * elements are specified, they are displayed one below the other.\n */\n rightElements?: [ReactNode, ...ReactNode[]];\n /**\n * Images of users should always be displayed in a round shape. Therefore,\n * this property can be set to true.\n */\n shouldShowRoundImage?: boolean;\n /**\n * Subtitle of the `ListItem` displayed in the head below the title\n */\n subtitle?: ReactNode;\n /**\n * Title of the `ListItem` displayed in the head\n */\n title: ReactNode;\n};\n\nconst ListItem: FC<ListItemProps> = ({\n children,\n hoverItem,\n icons,\n images,\n isDefaultOpen,\n isOpen,\n onClick,\n onLongPress,\n leftElements,\n rightElements,\n subtitle,\n shouldShowRoundImage,\n title,\n}) => {\n const {
|
|
1
|
+
{"version":3,"file":"ListItem.js","names":["AnimatePresence","React","useCallback","useContext","useEffect","useUuid","ListContext","ListItemBody","ListItemHead","StyledListItem","ListItem","_ref","children","hoverItem","icons","images","isDefaultOpen","isOpen","onClick","onLongPress","leftElements","rightElements","subtitle","shouldShowRoundImage","title","incrementExpandableItemCount","isAnyItemExpandable","isWrapped","openItemUuid","updateOpenItemUuid","uuid","isExpandable","undefined","isItemOpen","handleHeadClick","event","shouldOnlyOpen","createElement","className","$isClickable","$isOpen","$isWrapped","initial","id","displayName"],"sources":["../../../../src/components/list/list-item/ListItem.tsx"],"sourcesContent":["import { AnimatePresence } from 'framer-motion';\nimport React, {\n FC,\n MouseEventHandler,\n ReactNode,\n TouchEventHandler,\n useCallback,\n useContext,\n useEffect,\n} from 'react';\nimport { useUuid } from '../../../hooks/uuid';\nimport { ListContext } from '../List';\nimport ListItemBody from './list-item-body/ListItemBody';\nimport ListItemHead from './list-item-head/ListItemHead';\nimport { StyledListItem } from './ListItem.styles';\n\ntype ListItemProps = {\n /**\n * The content of the `ListItem` body. When the `ListItem` has children,\n * it can be opened and also gets an icon as an indicator automatically.\n */\n children?: ReactNode;\n /**\n * Element that is displayed when hovering over the `ListItem` on the right\n * side. On mobile devices, this element is not displayed.\n */\n hoverItem?: ReactNode;\n /**\n * The FontAwesome or tobit icons to render like an image on the left side\n * of the header. Multiple icons are stacked. See the `Icon` component\n * documentation for more information.\n */\n icons?: string[];\n /**\n * A list of image URLs that are displayed on the left side of the header.\n * If multiple URLs are passed, the image is assembled from the first three\n * image URLs as a puzzle.\n */\n images?: string[];\n /**\n * This can be used to automatically expand the `ListItem` during the first render.\n */\n isDefaultOpen?: boolean;\n /**\n * This overrides the internal opening state of the item and makes it controlled.\n */\n isOpen?: boolean;\n /**\n * Function to be executed when the header of the `ListItem` was clicked\n */\n onClick?: MouseEventHandler<HTMLDivElement>;\n /**\n * Function to be executed when the header of the `ListItem` is pressed for\n * 400 milliseconds.\n */\n onLongPress?: TouchEventHandler<HTMLDivElement>;\n /**\n * Elements that are displayed on the left side of the header. If multiple\n * elements are specified, they are displayed one aside the other.\n */\n leftElements?: [ReactNode, ...ReactNode[]];\n /**\n * Elements that are displayed on the right side of the header. If multiple\n * elements are specified, they are displayed one below the other.\n */\n rightElements?: [ReactNode, ...ReactNode[]];\n /**\n * Images of users should always be displayed in a round shape. Therefore,\n * this property can be set to true.\n */\n shouldShowRoundImage?: boolean;\n /**\n * Subtitle of the `ListItem` displayed in the head below the title\n */\n subtitle?: ReactNode;\n /**\n * Title of the `ListItem` displayed in the head\n */\n title: ReactNode;\n};\n\nconst ListItem: FC<ListItemProps> = ({\n children,\n hoverItem,\n icons,\n images,\n isDefaultOpen,\n isOpen,\n onClick,\n onLongPress,\n leftElements,\n rightElements,\n subtitle,\n shouldShowRoundImage,\n title,\n}) => {\n const {\n incrementExpandableItemCount,\n isAnyItemExpandable,\n isWrapped,\n openItemUuid,\n updateOpenItemUuid,\n } = useContext(ListContext);\n\n const uuid = useUuid();\n\n const isExpandable = children !== undefined;\n const isItemOpen = isOpen ?? openItemUuid === uuid;\n\n const handleHeadClick = useCallback<MouseEventHandler<HTMLDivElement>>(\n (event) => {\n if (isExpandable) {\n updateOpenItemUuid(uuid);\n }\n\n if (typeof onClick === 'function') {\n onClick(event);\n }\n },\n [isExpandable, onClick, updateOpenItemUuid, uuid],\n );\n\n useEffect(() => {\n if (isExpandable) {\n // The incrementExpandableItemCount function returns an cleanup\n // function to decrement expandableItemCount if component unmounts\n return incrementExpandableItemCount();\n }\n\n return undefined;\n }, [incrementExpandableItemCount, isExpandable]);\n\n useEffect(() => {\n if (isDefaultOpen) {\n updateOpenItemUuid(uuid, { shouldOnlyOpen: true });\n }\n }, [isDefaultOpen, updateOpenItemUuid, uuid]);\n\n return (\n <StyledListItem\n className=\"beta-chayns-list-item\"\n $isClickable={typeof onClick === 'function' || isExpandable}\n $isOpen={isItemOpen}\n $isWrapped={isWrapped}\n >\n <ListItemHead\n hoverItem={hoverItem}\n icons={icons}\n images={images}\n isAnyItemExpandable={isAnyItemExpandable}\n isExpandable={isExpandable}\n isOpen={isItemOpen}\n onClick={handleHeadClick}\n onLongPress={onLongPress}\n leftElements={leftElements}\n rightElements={rightElements}\n subtitle={subtitle}\n shouldShowRoundImage={shouldShowRoundImage}\n title={title}\n />\n <AnimatePresence initial={false}>\n {isExpandable && isItemOpen && <ListItemBody id={uuid}>{children}</ListItemBody>}\n </AnimatePresence>\n </StyledListItem>\n );\n};\n\nListItem.displayName = 'ListItem';\n\nexport default ListItem;\n"],"m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
|
|
5
5
|
$isOpen: boolean;
|
|
6
|
+
$isWrapped: boolean;
|
|
6
7
|
}>;
|
|
7
8
|
export declare const StyledListItem: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledListItemProps>>;
|
|
8
9
|
export {};
|
|
@@ -6,7 +6,7 @@ export const StyledListItem = styled.div`
|
|
|
6
6
|
theme
|
|
7
7
|
} = _ref;
|
|
8
8
|
return $isOpen && css`
|
|
9
|
-
background-color: rgba(${theme['100-rgb']},
|
|
9
|
+
background-color: rgba(${theme['100-rgb']}, ${theme.cardBackgroundOpacity});
|
|
10
10
|
`;
|
|
11
11
|
}}
|
|
12
12
|
|
|
@@ -35,6 +35,13 @@ export const StyledListItem = styled.div`
|
|
|
35
35
|
`;
|
|
36
36
|
}}}
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
${_ref4 => {
|
|
39
|
+
let {
|
|
40
|
+
$isWrapped
|
|
41
|
+
} = _ref4;
|
|
42
|
+
return $isWrapped && css`
|
|
43
|
+
padding-left: 26px;
|
|
44
|
+
`;
|
|
45
|
+
}}
|
|
39
46
|
`;
|
|
40
47
|
//# sourceMappingURL=ListItem.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.styles.js","names":["styled","css","StyledListItem","div","_ref","$isOpen","theme","_ref2","$isClickable","_ref3","accordionLines","headline"],"sources":["../../../../src/components/list/list-item/ListItem.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport type { WithTheme } from '../../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledListItemProps = WithTheme<{\n $isClickable: boolean;\n $isOpen: boolean;\n}>;\n\nexport const StyledListItem = styled.div<StyledListItemProps>`\n ${({ $isOpen, theme }) =>\n $isOpen &&\n css`\n background-color: rgba(${theme['100-rgb']},
|
|
1
|
+
{"version":3,"file":"ListItem.styles.js","names":["styled","css","StyledListItem","div","_ref","$isOpen","theme","cardBackgroundOpacity","_ref2","$isClickable","_ref3","accordionLines","headline","_ref4","$isWrapped"],"sources":["../../../../src/components/list/list-item/ListItem.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport type { WithTheme } from '../../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledListItemProps = WithTheme<{\n $isClickable: boolean;\n $isOpen: boolean;\n $isWrapped: boolean;\n}>;\n\nexport const StyledListItem = styled.div<StyledListItemProps>`\n ${({ $isOpen, theme }) =>\n $isOpen &&\n css`\n background-color: rgba(${theme['100-rgb']}, ${theme.cardBackgroundOpacity});\n `}\n\n transition: background-color 0.3s ease;\n\n ${({ $isClickable, theme }) =>\n $isClickable &&\n css`\n :hover {\n background-color: rgba(${theme['100-rgb']}, 0.85);\n }\n `}\n \n ${({ theme }: StyledListItemProps) =>\n theme.accordionLines &&\n css`\n &:not(:last-child) {\n border-bottom: 1px solid ${theme.headline};\n }\n `}}\n\n ${({ $isWrapped }) =>\n $isWrapped &&\n css`\n padding-left: 26px;\n `}\n`;\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAS/C,OAAO,MAAMC,cAAc,GAAGF,MAAM,CAACG,GAAyB;AAC9D,MAAMC,IAAA;EAAA,IAAC;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAAF,IAAA;EAAA,OACjBC,OAAO,IACPJ,GAAI;AACZ,qCAAqCK,KAAK,CAAC,SAAS,CAAE,KAAIA,KAAK,CAACC,qBAAsB;AACtF,SAAS;AAAA,CAAC;AACV;AACA;AACA;AACA,MAAMC,KAAA;EAAA,IAAC;IAAEC,YAAY;IAAEH;EAAM,CAAC,GAAAE,KAAA;EAAA,OACtBC,YAAY,IACZR,GAAI;AACZ;AACA,yCAAyCK,KAAK,CAAC,SAAS,CAAE;AAC1D;AACA,SAAS;AAAA,CAAC;AACV;AACA,MAAMI,KAAA;EAAA,IAAC;IAAEJ;EAA2B,CAAC,GAAAI,KAAA;EAAA,OAC7BJ,KAAK,CAACK,cAAc,IACpBV,GAAI;AACZ;AACA,2CAA2CK,KAAK,CAACM,QAAS;AAC1D;AACA,SAAS;AAAA,CAAC;AACV;AACA,MAAMC,KAAA;EAAA,IAAC;IAAEC;EAAW,CAAC,GAAAD,KAAA;EAAA,OACbC,UAAU,IACVb,GAAI;AACZ;AACA,SAAS;AAAA,CAAC;AACV,CAAC"}
|
|
@@ -97,6 +97,14 @@ const SearchBox = _ref => {
|
|
|
97
97
|
setIsAnimating(true);
|
|
98
98
|
}
|
|
99
99
|
}, [list, shouldShowContentOnEmptyInput, value]);
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
if (list) {
|
|
102
|
+
setMatchingItems(searchList({
|
|
103
|
+
items: list,
|
|
104
|
+
searchString: value
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
}, [list, value]);
|
|
100
108
|
|
|
101
109
|
/**
|
|
102
110
|
* This function handles changes of the input
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchBox.js","names":["getDevice","AnimatePresence","React","useCallback","useEffect","useMemo","useRef","useState","calculateContentHeight","searchList","Input","SearchBoxItem","StyledMotionSearchBoxBody","StyledSearchBox","SearchBox","_ref","placeholder","list","onChange","onBlur","onSelect","selectedId","shouldShowRoundImage","shouldShowContentOnEmptyInput","matchingItems","setMatchingItems","value","setValue","isAnimating","setIsAnimating","height","setHeight","width","setWidth","focusedIndex","setFocusedIndex","boxRef","contentRef","inputRef","browser","handleOutsideClick","event","current","contains","target","document","addEventListener","removeEventListener","textArray","map","_ref2","text","input","getElementById","offsetWidth","selectedItem","find","_ref3","id","handleFocus","items","searchString","handleChange","searchedItems","length","handleBlur","handleSelect","item","content","sort","a","b","localeCompare","forEach","_ref4","imageUrl","push","createElement","key","handleKeyDown","e","preventDefault","children","newIndex","prevElement","tabIndex","newElement","focus","element","textContent","replace","handleKeyPress","keyCode","ref","onFocus","initial","$browser","name","$height","$width","opacity","animate","transition","duration","type","displayName"],"sources":["../../../src/components/search-box/SearchBox.tsx"],"sourcesContent":["import { getDevice } from 'chayns-api';\nimport { AnimatePresence } from 'framer-motion';\nimport React, {\n ChangeEvent,\n ChangeEventHandler,\n FC,\n FocusEvent,\n FocusEventHandler,\n ReactElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport type { ISearchBoxItem } from '../../types/searchBox';\nimport { calculateContentHeight } from '../../utils/calculate';\nimport { searchList } from '../../utils/searchBox';\nimport Input from '../input/Input';\nimport SearchBoxItem from './search-box-item/SearchBoxItem';\nimport { StyledMotionSearchBoxBody, StyledSearchBox } from './SearchBox.styles';\n\nexport type SearchBoxProps = {\n /**\n * A list of items that can be searched.\n */\n list: ISearchBoxItem[];\n /**\n * The placeholder that should be displayed.\n */\n placeholder?: string;\n /**\n * Function to be executed when the input lost focus.\n */\n onBlur?: FocusEventHandler<HTMLInputElement>;\n /**\n * Function to be executed when the input is changed.\n */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Function to be executed when an item is selected.\n */\n onSelect?: (item: ISearchBoxItem) => void;\n /**\n * Control the selected item. If you use this prop, make sure to update it when the user selects an item.\n */\n selectedId?: string;\n /**\n * Whether the full list of items should be displayed if the input is empty.\n */\n shouldShowContentOnEmptyInput?: boolean;\n /**\n * If true, the images of the items are displayed in a round shape.\n */\n shouldShowRoundImage?: boolean;\n};\n\nconst SearchBox: FC<SearchBoxProps> = ({\n placeholder,\n list,\n onChange,\n onBlur,\n onSelect,\n selectedId,\n shouldShowRoundImage,\n shouldShowContentOnEmptyInput = true,\n}) => {\n const [matchingItems, setMatchingItems] = useState<ISearchBoxItem[]>([]);\n const [value, setValue] = useState('');\n const [isAnimating, setIsAnimating] = useState(false);\n const [height, setHeight] = useState<number>(0);\n const [width, setWidth] = useState(0);\n const [focusedIndex, setFocusedIndex] = useState<number | null>(null);\n\n const boxRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const { browser } = getDevice();\n\n /**\n * This function closes the list of items\n */\n const handleOutsideClick = useCallback(\n (event: MouseEvent) => {\n if (boxRef.current && !boxRef.current.contains(event.target as Node)) {\n setIsAnimating(false);\n }\n },\n [boxRef],\n );\n\n /**\n * This hook listens for clicks\n */\n useEffect(() => {\n document.addEventListener('click', handleOutsideClick);\n\n return () => {\n document.removeEventListener('click', handleOutsideClick);\n };\n }, [handleOutsideClick, boxRef]);\n\n /**\n * This hook calculates the height\n */\n useEffect(() => {\n const textArray = list.map(({ text }) => text);\n\n setHeight(calculateContentHeight(textArray));\n }, [list, placeholder]);\n\n /**\n * This hook calculates the width\n */\n useEffect(() => {\n const input = document.getElementById('search_box_input');\n\n if (input) {\n setWidth(input.offsetWidth);\n }\n }, []);\n\n useEffect(() => {\n if (selectedId) {\n const selectedItem = list.find(({ id }) => id === selectedId);\n\n if (selectedItem) {\n setValue(selectedItem.text);\n }\n }\n }, [list, selectedId]);\n\n /**\n * This function sets the items on focus if shouldShowContentOnEmptyInput\n */\n const handleFocus = useCallback(() => {\n if (shouldShowContentOnEmptyInput) {\n setMatchingItems(searchList({ items: list, searchString: value }));\n setIsAnimating(true);\n }\n }, [list, shouldShowContentOnEmptyInput, value]);\n\n /**\n * This function handles changes of the input\n */\n const handleChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const searchedItems = searchList({ items: list, searchString: event.target.value });\n\n if (!shouldShowContentOnEmptyInput && !event.target.value) {\n setMatchingItems([]);\n } else {\n setMatchingItems(searchedItems);\n setIsAnimating(searchedItems.length !== 0);\n }\n\n setValue(event.target.value);\n\n if (typeof onChange === 'function') {\n onChange(event);\n }\n },\n [list, onChange, shouldShowContentOnEmptyInput],\n );\n\n /**\n * This function handles the blur event of the input\n */\n const handleBlur = useCallback(\n (event: FocusEvent<HTMLInputElement>) => {\n if (typeof onBlur === 'function') {\n onBlur(event);\n }\n },\n [onBlur],\n );\n\n /**\n * This function handles the item selection\n */\n const handleSelect = useCallback(\n (item: ISearchBoxItem) => {\n setValue(item.text);\n setIsAnimating(false);\n\n if (typeof onSelect === 'function') {\n onSelect(item);\n }\n },\n [onSelect],\n );\n\n const content = useMemo(() => {\n const items: ReactElement[] = [];\n\n matchingItems.sort((a, b) => a.text.localeCompare(b.text));\n\n matchingItems.forEach(({ id, text, imageUrl }) => {\n items.push(\n <SearchBoxItem\n key={id}\n text={text}\n imageUrl={imageUrl}\n id={id}\n shouldShowRoundImage={shouldShowRoundImage}\n onSelect={handleSelect}\n />,\n );\n });\n\n return items;\n }, [shouldShowRoundImage, handleSelect, matchingItems]);\n\n useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {\n e.preventDefault();\n const children = contentRef.current?.children;\n if (children && children.length > 0) {\n const newIndex =\n focusedIndex !== null\n ? (focusedIndex + (e.key === 'ArrowUp' ? -1 : 1) + children.length) %\n children.length\n : 0;\n\n if (focusedIndex !== null) {\n const prevElement = children[focusedIndex] as HTMLDivElement;\n prevElement.tabIndex = -1;\n }\n\n setFocusedIndex(newIndex);\n\n const newElement = children[newIndex] as HTMLDivElement;\n newElement.tabIndex = 0;\n newElement.focus();\n }\n } else if (e.key === 'Enter' && focusedIndex !== null) {\n const element = contentRef.current?.children[focusedIndex];\n\n if (!element) {\n return;\n }\n\n const { id, textContent } = element;\n\n handleSelect({ id: id.replace('search-box-item__', ''), text: textContent ?? '' });\n }\n };\n\n document.addEventListener('keydown', handleKeyDown);\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n };\n }, [focusedIndex, handleSelect]);\n\n const handleKeyPress = useCallback((event: KeyboardEvent) => {\n if (event.keyCode === 27) {\n setMatchingItems([]);\n }\n }, []);\n\n useEffect(() => {\n document.addEventListener('keydown', handleKeyPress);\n\n return () => {\n document.addEventListener('keydown', handleKeyPress);\n };\n }, [handleKeyPress]);\n\n return useMemo(\n () => (\n <StyledSearchBox ref={boxRef}>\n <div id=\"search_box_input\">\n <Input\n ref={inputRef}\n onChange={handleChange}\n onBlur={handleBlur}\n onFocus={handleFocus}\n placeholder={placeholder}\n value={value}\n />\n </div>\n <AnimatePresence initial={false}>\n <StyledMotionSearchBoxBody\n $browser={browser?.name}\n key=\"content\"\n $height={height}\n $width={width}\n initial={{ height: 0, opacity: 0 }}\n animate={\n isAnimating\n ? { height: 'fit-content', opacity: 1 }\n : { height: 0, opacity: 0 }\n }\n transition={{\n duration: 0.2,\n type: 'tween',\n }}\n >\n <div ref={contentRef}>{content}</div>\n </StyledMotionSearchBoxBody>\n </AnimatePresence>\n </StyledSearchBox>\n ),\n [\n browser?.name,\n content,\n handleBlur,\n handleChange,\n handleFocus,\n height,\n isAnimating,\n placeholder,\n value,\n width,\n ],\n );\n};\n\nSearchBox.displayName = 'SearchBox';\n\nexport default SearchBox;\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,YAAY;AACtC,SAASC,eAAe,QAAQ,eAAe;AAC/C,OAAOC,KAAK,IAORC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AAEd,SAASC,sBAAsB,QAAQ,uBAAuB;AAC9D,SAASC,UAAU,QAAQ,uBAAuB;AAClD,OAAOC,KAAK,MAAM,gBAAgB;AAClC,OAAOC,aAAa,MAAM,iCAAiC;AAC3D,SAASC,yBAAyB,EAAEC,eAAe,QAAQ,oBAAoB;AAqC/E,MAAMC,SAA6B,GAAGC,IAAA,IAShC;EAAA,IATiC;IACnCC,WAAW;IACXC,IAAI;IACJC,QAAQ;IACRC,MAAM;IACNC,QAAQ;IACRC,UAAU;IACVC,oBAAoB;IACpBC,6BAA6B,GAAG;EACpC,CAAC,GAAAR,IAAA;EACG,MAAM,CAACS,aAAa,EAAEC,gBAAgB,CAAC,GAAGlB,QAAQ,CAAmB,EAAE,CAAC;EACxE,MAAM,CAACmB,KAAK,EAAEC,QAAQ,CAAC,GAAGpB,QAAQ,CA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xD,KAAA,CAAA2E,aAAA,CAACnE,KAAK;IACFmF,GAAG,EAAEvD,QAAS;IACdpB,QAAQ,EAAE4C,YAAa;IACvB3C,MAAM,EAAE8C,UAAW;IACnB6B,OAAO,EAAEnC,WAAY;IACrB3C,WAAW,EAAEA,WAAY;IACzBU,KAAK,EAAEA;EAAM,CAChB,CACA,CAAC,eACNxB,KAAA,CAAA2E,aAAA,CAAC5E,eAAe;IAAC8F,OAAO,EAAE;EAAM,gBAC5B7F,KAAA,CAAA2E,aAAA,CAACjE,yBAAyB;IACtBoF,QAAQ,EAAEzD,OAAO,EAAE0D,IAAK;IACxBnB,GAAG,EAAC,SAAS;IACboB,OAAO,EAAEpE,MAAO;IAChBqE,MAAM,EAAEnE,KAAM;IACd+D,OAAO,EAAE;MAAEjE,MAAM,EAAE,CAAC;MAAEsE,OAAO,EAAE;IAAE,CAAE;IACnCC,OAAO,EACHzE,WAAW,GACL;MAAEE,MAAM,EAAE,aAAa;MAAEsE,OAAO,EAAE;IAAE,CAAC,GACrC;MAAEtE,MAAM,EAAE,CAAC;MAAEsE,OAAO,EAAE;IAAE,CACjC;IACDE,UAAU,EAAE;MACRC,QAAQ,EAAE,GAAG;MACbC,IAAI,EAAE;IACV;EAAE,gBAEFtG,KAAA,CAAA2E,aAAA;IAAKgB,GAAG,EAAExD;EAAW,GAAE+B,OAAa,CACb,CACd,CACJ,CACpB,EACD,CACI7B,OAAO,EAAE0D,IAAI,EACb7B,OAAO,EACPH,UAAU,EACVH,YAAY,EACZH,WAAW,EACX7B,MAAM,EACNF,WAAW,EACXZ,WAAW,EACXU,KAAK,EACLM,KAAK,CAEb,CAAC;AACL,CAAC;AAEDlB,SAAS,CAAC2F,WAAW,GAAG,WAAW;AAEnC,eAAe3F,SAAS"}
|
|
1
|
+
{"version":3,"file":"SearchBox.js","names":["getDevice","AnimatePresence","React","useCallback","useEffect","useMemo","useRef","useState","calculateContentHeight","searchList","Input","SearchBoxItem","StyledMotionSearchBoxBody","StyledSearchBox","SearchBox","_ref","placeholder","list","onChange","onBlur","onSelect","selectedId","shouldShowRoundImage","shouldShowContentOnEmptyInput","matchingItems","setMatchingItems","value","setValue","isAnimating","setIsAnimating","height","setHeight","width","setWidth","focusedIndex","setFocusedIndex","boxRef","contentRef","inputRef","browser","handleOutsideClick","event","current","contains","target","document","addEventListener","removeEventListener","textArray","map","_ref2","text","input","getElementById","offsetWidth","selectedItem","find","_ref3","id","handleFocus","items","searchString","handleChange","searchedItems","length","handleBlur","handleSelect","item","content","sort","a","b","localeCompare","forEach","_ref4","imageUrl","push","createElement","key","handleKeyDown","e","preventDefault","children","newIndex","prevElement","tabIndex","newElement","focus","element","textContent","replace","handleKeyPress","keyCode","ref","onFocus","initial","$browser","name","$height","$width","opacity","animate","transition","duration","type","displayName"],"sources":["../../../src/components/search-box/SearchBox.tsx"],"sourcesContent":["import { getDevice } from 'chayns-api';\nimport { AnimatePresence } from 'framer-motion';\nimport React, {\n ChangeEvent,\n ChangeEventHandler,\n FC,\n FocusEvent,\n FocusEventHandler,\n ReactElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport type { ISearchBoxItem } from '../../types/searchBox';\nimport { calculateContentHeight } from '../../utils/calculate';\nimport { searchList } from '../../utils/searchBox';\nimport Input from '../input/Input';\nimport SearchBoxItem from './search-box-item/SearchBoxItem';\nimport { StyledMotionSearchBoxBody, StyledSearchBox } from './SearchBox.styles';\n\nexport type SearchBoxProps = {\n /**\n * A list of items that can be searched.\n */\n list: ISearchBoxItem[];\n /**\n * The placeholder that should be displayed.\n */\n placeholder?: string;\n /**\n * Function to be executed when the input lost focus.\n */\n onBlur?: FocusEventHandler<HTMLInputElement>;\n /**\n * Function to be executed when the input is changed.\n */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Function to be executed when an item is selected.\n */\n onSelect?: (item: ISearchBoxItem) => void;\n /**\n * Control the selected item. If you use this prop, make sure to update it when the user selects an item.\n */\n selectedId?: string;\n /**\n * Whether the full list of items should be displayed if the input is empty.\n */\n shouldShowContentOnEmptyInput?: boolean;\n /**\n * If true, the images of the items are displayed in a round shape.\n */\n shouldShowRoundImage?: boolean;\n};\n\nconst SearchBox: FC<SearchBoxProps> = ({\n placeholder,\n list,\n onChange,\n onBlur,\n onSelect,\n selectedId,\n shouldShowRoundImage,\n shouldShowContentOnEmptyInput = true,\n}) => {\n const [matchingItems, setMatchingItems] = useState<ISearchBoxItem[]>([]);\n const [value, setValue] = useState('');\n const [isAnimating, setIsAnimating] = useState(false);\n const [height, setHeight] = useState<number>(0);\n const [width, setWidth] = useState(0);\n const [focusedIndex, setFocusedIndex] = useState<number | null>(null);\n\n const boxRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const { browser } = getDevice();\n\n /**\n * This function closes the list of items\n */\n const handleOutsideClick = useCallback(\n (event: MouseEvent) => {\n if (boxRef.current && !boxRef.current.contains(event.target as Node)) {\n setIsAnimating(false);\n }\n },\n [boxRef],\n );\n\n /**\n * This hook listens for clicks\n */\n useEffect(() => {\n document.addEventListener('click', handleOutsideClick);\n\n return () => {\n document.removeEventListener('click', handleOutsideClick);\n };\n }, [handleOutsideClick, boxRef]);\n\n /**\n * This hook calculates the height\n */\n useEffect(() => {\n const textArray = list.map(({ text }) => text);\n\n setHeight(calculateContentHeight(textArray));\n }, [list, placeholder]);\n\n /**\n * This hook calculates the width\n */\n useEffect(() => {\n const input = document.getElementById('search_box_input');\n\n if (input) {\n setWidth(input.offsetWidth);\n }\n }, []);\n\n useEffect(() => {\n if (selectedId) {\n const selectedItem = list.find(({ id }) => id === selectedId);\n\n if (selectedItem) {\n setValue(selectedItem.text);\n }\n }\n }, [list, selectedId]);\n\n /**\n * This function sets the items on focus if shouldShowContentOnEmptyInput\n */\n const handleFocus = useCallback(() => {\n if (shouldShowContentOnEmptyInput) {\n setMatchingItems(searchList({ items: list, searchString: value }));\n setIsAnimating(true);\n }\n }, [list, shouldShowContentOnEmptyInput, value]);\n\n useEffect(() => {\n if (list) {\n setMatchingItems(searchList({ items: list, searchString: value }));\n }\n }, [list, value]);\n\n /**\n * This function handles changes of the input\n */\n const handleChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const searchedItems = searchList({ items: list, searchString: event.target.value });\n\n if (!shouldShowContentOnEmptyInput && !event.target.value) {\n setMatchingItems([]);\n } else {\n setMatchingItems(searchedItems);\n setIsAnimating(searchedItems.length !== 0);\n }\n\n setValue(event.target.value);\n\n if (typeof onChange === 'function') {\n onChange(event);\n }\n },\n [list, onChange, shouldShowContentOnEmptyInput],\n );\n\n /**\n * This function handles the blur event of the input\n */\n const handleBlur = useCallback(\n (event: FocusEvent<HTMLInputElement>) => {\n if (typeof onBlur === 'function') {\n onBlur(event);\n }\n },\n [onBlur],\n );\n\n /**\n * This function handles the item selection\n */\n const handleSelect = useCallback(\n (item: ISearchBoxItem) => {\n setValue(item.text);\n setIsAnimating(false);\n\n if (typeof onSelect === 'function') {\n onSelect(item);\n }\n },\n [onSelect],\n );\n\n const content = useMemo(() => {\n const items: ReactElement[] = [];\n\n matchingItems.sort((a, b) => a.text.localeCompare(b.text));\n\n matchingItems.forEach(({ id, text, imageUrl }) => {\n items.push(\n <SearchBoxItem\n key={id}\n text={text}\n imageUrl={imageUrl}\n id={id}\n shouldShowRoundImage={shouldShowRoundImage}\n onSelect={handleSelect}\n />,\n );\n });\n\n return items;\n }, [shouldShowRoundImage, handleSelect, matchingItems]);\n\n useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {\n e.preventDefault();\n const children = contentRef.current?.children;\n if (children && children.length > 0) {\n const newIndex =\n focusedIndex !== null\n ? (focusedIndex + (e.key === 'ArrowUp' ? -1 : 1) + children.length) %\n children.length\n : 0;\n\n if (focusedIndex !== null) {\n const prevElement = children[focusedIndex] as HTMLDivElement;\n prevElement.tabIndex = -1;\n }\n\n setFocusedIndex(newIndex);\n\n const newElement = children[newIndex] as HTMLDivElement;\n newElement.tabIndex = 0;\n newElement.focus();\n }\n } else if (e.key === 'Enter' && focusedIndex !== null) {\n const element = contentRef.current?.children[focusedIndex];\n\n if (!element) {\n return;\n }\n\n const { id, textContent } = element;\n\n handleSelect({ id: id.replace('search-box-item__', ''), text: textContent ?? '' });\n }\n };\n\n document.addEventListener('keydown', handleKeyDown);\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n };\n }, [focusedIndex, handleSelect]);\n\n const handleKeyPress = useCallback((event: KeyboardEvent) => {\n if (event.keyCode === 27) {\n setMatchingItems([]);\n }\n }, []);\n\n useEffect(() => {\n document.addEventListener('keydown', handleKeyPress);\n\n return () => {\n document.addEventListener('keydown', handleKeyPress);\n };\n }, [handleKeyPress]);\n\n return useMemo(\n () => (\n <StyledSearchBox ref={boxRef}>\n <div id=\"search_box_input\">\n <Input\n ref={inputRef}\n onChange={handleChange}\n onBlur={handleBlur}\n onFocus={handleFocus}\n placeholder={placeholder}\n value={value}\n />\n </div>\n <AnimatePresence initial={false}>\n <StyledMotionSearchBoxBody\n $browser={browser?.name}\n key=\"content\"\n $height={height}\n $width={width}\n initial={{ height: 0, opacity: 0 }}\n animate={\n isAnimating\n ? { height: 'fit-content', opacity: 1 }\n : { height: 0, opacity: 0 }\n }\n transition={{\n duration: 0.2,\n type: 'tween',\n }}\n >\n <div ref={contentRef}>{content}</div>\n </StyledMotionSearchBoxBody>\n </AnimatePresence>\n </StyledSearchBox>\n ),\n [\n browser?.name,\n content,\n handleBlur,\n handleChange,\n handleFocus,\n height,\n isAnimating,\n placeholder,\n value,\n width,\n ],\n );\n};\n\nSearchBox.displayName = 'SearchBox';\n\nexport default SearchBox;\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,YAAY;AACtC,SAASC,eAAe,QAAQ,eAAe;AAC/C,OAAOC,KAAK,IAORC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACN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IACd+D,OAAO,EAAE;MAAEjE,MAAM,EAAE,CAAC;MAAEsE,OAAO,EAAE;IAAE,CAAE;IACnCC,OAAO,EACHzE,WAAW,GACL;MAAEE,MAAM,EAAE,aAAa;MAAEsE,OAAO,EAAE;IAAE,CAAC,GACrC;MAAEtE,MAAM,EAAE,CAAC;MAAEsE,OAAO,EAAE;IAAE,CACjC;IACDE,UAAU,EAAE;MACRC,QAAQ,EAAE,GAAG;MACbC,IAAI,EAAE;IACV;EAAE,gBAEFtG,KAAA,CAAA2E,aAAA;IAAKgB,GAAG,EAAExD;EAAW,GAAE+B,OAAa,CACb,CACd,CACJ,CACpB,EACD,CACI7B,OAAO,EAAE0D,IAAI,EACb7B,OAAO,EACPH,UAAU,EACVH,YAAY,EACZH,WAAW,EACX7B,MAAM,EACNF,WAAW,EACXZ,WAAW,EACXU,KAAK,EACLM,KAAK,CAEb,CAAC;AACL,CAAC;AAEDlB,SAAS,CAAC2F,WAAW,GAAG,WAAW;AAEnC,eAAe3F,SAAS"}
|
|
@@ -18,6 +18,10 @@ export type SetupWizardProps = {
|
|
|
18
18
|
* The steps of the setup. Use the SetupWizardItem component.
|
|
19
19
|
*/
|
|
20
20
|
children: ReactElement<SetupWizardItemProps> | ReactElement<SetupWizardItemProps>[];
|
|
21
|
+
/**
|
|
22
|
+
* This value must be set if the SetupWizard is inside an Accordion.
|
|
23
|
+
*/
|
|
24
|
+
isWrapped?: boolean;
|
|
21
25
|
};
|
|
22
26
|
declare const SetupWizard: React.ForwardRefExoticComponent<SetupWizardProps & React.RefAttributes<SetupWizardRef>>;
|
|
23
27
|
export default SetupWizard;
|
|
@@ -10,7 +10,8 @@ export const SetupWizardContext = /*#__PURE__*/React.createContext({
|
|
|
10
10
|
SetupWizardContext.displayName = 'SetupWizardContext';
|
|
11
11
|
const SetupWizard = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
12
12
|
let {
|
|
13
|
-
children
|
|
13
|
+
children,
|
|
14
|
+
isWrapped
|
|
14
15
|
} = _ref;
|
|
15
16
|
const [selectedId, setSelectedId] = useState(0);
|
|
16
17
|
const [activeId, setActiveId] = useState(0);
|
|
@@ -63,7 +64,9 @@ const SetupWizard = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
63
64
|
}), [activeId, selectedId, updateActiveId, updateSelectedId]);
|
|
64
65
|
return useMemo(() => /*#__PURE__*/React.createElement(SetupWizardContext.Provider, {
|
|
65
66
|
value: providerValue
|
|
66
|
-
}, /*#__PURE__*/React.createElement(StyledSetupWizard, null, /*#__PURE__*/React.createElement(AccordionGroup,
|
|
67
|
+
}, /*#__PURE__*/React.createElement(StyledSetupWizard, null, /*#__PURE__*/React.createElement(AccordionGroup, {
|
|
68
|
+
isWrapped: isWrapped
|
|
69
|
+
}, children))), [children, isWrapped, providerValue]);
|
|
67
70
|
});
|
|
68
71
|
SetupWizard.displayName = 'SetupWizard';
|
|
69
72
|
export default SetupWizard;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SetupWizard.js","names":["React","forwardRef","useCallback","useEffect","useImperativeHandle","useMemo","useState","AccordionGroup","StyledSetupWizard","SetupWizardContext","createContext","selectedId","undefined","updateSelectedId","activeId","updateActiveId","displayName","SetupWizard","_ref","ref","children","setSelectedId","setActiveId","allIds","setAllIds","Children","map","child","prevState","props","id","handleNext","stepId","index","findIndex","numberAtIndex","handleReset","next","reset","providerValue","createElement","Provider","value"],"sources":["../../../src/components/setup-wizard/SetupWizard.tsx"],"sourcesContent":["import React, {\n forwardRef,\n ReactElement,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n} from 'react';\nimport AccordionGroup from '../accordion/accordion-group/AccordionGroup';\nimport type { SetupWizardItemProps } from './setup-wizard-item/SetupWizardItem';\nimport { StyledSetupWizard } from './SetupWizard.styles';\n\ntype UpdateSelectedId = (id: number) => void;\ntype UpdateActiveId = (id: number) => void;\n\ninterface SetupWizardContextProps {\n selectedId: number | undefined;\n updateSelectedId?: UpdateSelectedId;\n activeId: number | undefined;\n updateActiveId?: UpdateActiveId;\n}\n\nexport const SetupWizardContext = React.createContext<SetupWizardContextProps>({\n selectedId: undefined,\n updateSelectedId: undefined,\n activeId: undefined,\n updateActiveId: undefined,\n});\n\nSetupWizardContext.displayName = 'SetupWizardContext';\n\nexport type SetupWizardRef = {\n next: (stepId?: number) => void;\n reset: () => void;\n};\n\nexport type SetupWizardProps = {\n /**\n * The steps of the setup. Use the SetupWizardItem component.\n */\n children: ReactElement<SetupWizardItemProps> | ReactElement<SetupWizardItemProps>[];\n};\n\nconst SetupWizard = forwardRef<SetupWizardRef, SetupWizardProps>(({ children }, ref) => {\n const [selectedId, setSelectedId] = useState<SetupWizardContextProps['selectedId']>(0);\n const [activeId, setActiveId] = useState<SetupWizardContextProps['activeId']>(0);\n const [allIds, setAllIds] = useState<number[]>([]);\n\n useEffect(() => {\n React.Children.map(children, (child: ReactElement<SetupWizardItemProps>) => {\n setAllIds((prevState) => [...prevState, child.props.id]);\n });\n }, [children]);\n\n const updateSelectedId = useCallback<UpdateSelectedId>(\n (id) => {\n setSelectedId(id);\n },\n [setSelectedId],\n );\n\n const updateActiveId = useCallback<UpdateSelectedId>(\n (id) => {\n setActiveId(id);\n },\n [setActiveId],\n );\n\n const handleNext = useCallback(\n (stepId: number | undefined) => {\n if (typeof stepId === 'number') {\n updateSelectedId(stepId);\n\n if (typeof activeId === 'number' && stepId > activeId) {\n updateActiveId(stepId);\n }\n } else {\n const index = allIds.findIndex((id) => id === selectedId);\n\n if (index < 0) {\n return;\n }\n\n const numberAtIndex = allIds[index + 1];\n\n if (!numberAtIndex) {\n return;\n }\n\n updateSelectedId(numberAtIndex);\n\n if (typeof activeId === 'number' && numberAtIndex > activeId) {\n updateActiveId(numberAtIndex);\n }\n }\n },\n [activeId, allIds, selectedId, updateActiveId, updateSelectedId],\n );\n\n const handleReset = useCallback(() => {\n updateSelectedId(0);\n updateActiveId(0);\n }, [updateActiveId, updateSelectedId]);\n\n useImperativeHandle(\n ref,\n () => ({\n next: handleNext,\n reset: handleReset,\n }),\n [handleNext, handleReset],\n );\n\n const providerValue = useMemo<SetupWizardContextProps>(\n () => ({\n selectedId,\n updateSelectedId,\n activeId,\n updateActiveId,\n }),\n [activeId, selectedId, updateActiveId, updateSelectedId],\n );\n\n return useMemo(\n () => (\n <SetupWizardContext.Provider value={providerValue}>\n <StyledSetupWizard>\n <AccordionGroup>{children}</AccordionGroup>\n </StyledSetupWizard>\n </SetupWizardContext.Provider>\n ),\n [children, providerValue],\n );\n});\n\nSetupWizard.displayName = 'SetupWizard';\n\nexport default SetupWizard;\n"],"mappings":"AAAA,OAAOA,KAAK,IACRC,UAAU,EAEVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,EACPC,QAAQ,QACL,OAAO;AACd,OAAOC,cAAc,MAAM,6CAA6C;AAExE,SAASC,iBAAiB,QAAQ,sBAAsB;AAYxD,OAAO,MAAMC,kBAAkB,gBAAGT,KAAK,CAACU,aAAa,CAA0B;EAC3EC,UAAU,EAAEC,SAAS;EACrBC,gBAAgB,EAAED,SAAS;EAC3BE,QAAQ,EAAEF,SAAS;EACnBG,cAAc,EAAEH;AACpB,CAAC,CAAC;AAEFH,kBAAkB,CAACO,WAAW,GAAG,oBAAoB;
|
|
1
|
+
{"version":3,"file":"SetupWizard.js","names":["React","forwardRef","useCallback","useEffect","useImperativeHandle","useMemo","useState","AccordionGroup","StyledSetupWizard","SetupWizardContext","createContext","selectedId","undefined","updateSelectedId","activeId","updateActiveId","displayName","SetupWizard","_ref","ref","children","isWrapped","setSelectedId","setActiveId","allIds","setAllIds","Children","map","child","prevState","props","id","handleNext","stepId","index","findIndex","numberAtIndex","handleReset","next","reset","providerValue","createElement","Provider","value"],"sources":["../../../src/components/setup-wizard/SetupWizard.tsx"],"sourcesContent":["import React, {\n forwardRef,\n ReactElement,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n} from 'react';\nimport AccordionGroup from '../accordion/accordion-group/AccordionGroup';\nimport type { SetupWizardItemProps } from './setup-wizard-item/SetupWizardItem';\nimport { StyledSetupWizard } from './SetupWizard.styles';\n\ntype UpdateSelectedId = (id: number) => void;\ntype UpdateActiveId = (id: number) => void;\n\ninterface SetupWizardContextProps {\n selectedId: number | undefined;\n updateSelectedId?: UpdateSelectedId;\n activeId: number | undefined;\n updateActiveId?: UpdateActiveId;\n}\n\nexport const SetupWizardContext = React.createContext<SetupWizardContextProps>({\n selectedId: undefined,\n updateSelectedId: undefined,\n activeId: undefined,\n updateActiveId: undefined,\n});\n\nSetupWizardContext.displayName = 'SetupWizardContext';\n\nexport type SetupWizardRef = {\n next: (stepId?: number) => void;\n reset: () => void;\n};\n\nexport type SetupWizardProps = {\n /**\n * The steps of the setup. Use the SetupWizardItem component.\n */\n children: ReactElement<SetupWizardItemProps> | ReactElement<SetupWizardItemProps>[];\n /**\n * This value must be set if the SetupWizard is inside an Accordion.\n */\n isWrapped?: boolean;\n};\n\nconst SetupWizard = forwardRef<SetupWizardRef, SetupWizardProps>(({ children, isWrapped }, ref) => {\n const [selectedId, setSelectedId] = useState<SetupWizardContextProps['selectedId']>(0);\n const [activeId, setActiveId] = useState<SetupWizardContextProps['activeId']>(0);\n const [allIds, setAllIds] = useState<number[]>([]);\n\n useEffect(() => {\n React.Children.map(children, (child: ReactElement<SetupWizardItemProps>) => {\n setAllIds((prevState) => [...prevState, child.props.id]);\n });\n }, [children]);\n\n const updateSelectedId = useCallback<UpdateSelectedId>(\n (id) => {\n setSelectedId(id);\n },\n [setSelectedId],\n );\n\n const updateActiveId = useCallback<UpdateSelectedId>(\n (id) => {\n setActiveId(id);\n },\n [setActiveId],\n );\n\n const handleNext = useCallback(\n (stepId: number | undefined) => {\n if (typeof stepId === 'number') {\n updateSelectedId(stepId);\n\n if (typeof activeId === 'number' && stepId > activeId) {\n updateActiveId(stepId);\n }\n } else {\n const index = allIds.findIndex((id) => id === selectedId);\n\n if (index < 0) {\n return;\n }\n\n const numberAtIndex = allIds[index + 1];\n\n if (!numberAtIndex) {\n return;\n }\n\n updateSelectedId(numberAtIndex);\n\n if (typeof activeId === 'number' && numberAtIndex > activeId) {\n updateActiveId(numberAtIndex);\n }\n }\n },\n [activeId, allIds, selectedId, updateActiveId, updateSelectedId],\n );\n\n const handleReset = useCallback(() => {\n updateSelectedId(0);\n updateActiveId(0);\n }, [updateActiveId, updateSelectedId]);\n\n useImperativeHandle(\n ref,\n () => ({\n next: handleNext,\n reset: handleReset,\n }),\n [handleNext, handleReset],\n );\n\n const providerValue = useMemo<SetupWizardContextProps>(\n () => ({\n selectedId,\n updateSelectedId,\n activeId,\n updateActiveId,\n }),\n [activeId, selectedId, updateActiveId, updateSelectedId],\n );\n\n return useMemo(\n () => (\n <SetupWizardContext.Provider value={providerValue}>\n <StyledSetupWizard>\n <AccordionGroup isWrapped={isWrapped}>{children}</AccordionGroup>\n </StyledSetupWizard>\n </SetupWizardContext.Provider>\n ),\n [children, isWrapped, providerValue],\n );\n});\n\nSetupWizard.displayName = 'SetupWizard';\n\nexport default SetupWizard;\n"],"mappings":"AAAA,OAAOA,KAAK,IACRC,UAAU,EAEVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,EACPC,QAAQ,QACL,OAAO;AACd,OAAOC,cAAc,MAAM,6CAA6C;AAExE,SAASC,iBAAiB,QAAQ,sBAAsB;AAYxD,OAAO,MAAMC,kBAAkB,gBAAGT,KAAK,CAACU,aAAa,CAA0B;EAC3EC,UAAU,EAAEC,SAAS;EACrBC,gBAAgB,EAAED,SAAS;EAC3BE,QAAQ,EAAEF,SAAS;EACnBG,cAAc,EAAEH;AACpB,CAAC,CAAC;AAEFH,kBAAkB,CAACO,WAAW,GAAG,oBAAoB;AAkBrD,MAAMC,WAAW,gBAAGhB,UAAU,CAAmC,CAAAiB,IAAA,EAA0BC,GAAG,KAAK;EAAA,IAAjC;IAAEC,QAAQ;IAAEC;EAAU,CAAC,GAAAH,IAAA;EACrF,MAAM,CAACP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|
step,
|
|
12
12
|
title,
|
|
13
|
-
id
|
|
14
|
-
isWrapped
|
|
13
|
+
id
|
|
15
14
|
} = _ref;
|
|
16
15
|
const {
|
|
17
16
|
selectedId,
|
|
@@ -38,13 +37,12 @@ const SetupWizardItem = _ref => {
|
|
|
38
37
|
}
|
|
39
38
|
}, [id, updateSelectedId]);
|
|
40
39
|
return useMemo(() => /*#__PURE__*/React.createElement(StyledSetupWizardItem, null, /*#__PURE__*/React.createElement(Accordion, {
|
|
41
|
-
isWrapped: isWrapped,
|
|
42
40
|
onOpen: handleAccordionOpen,
|
|
43
41
|
title: `${step}. ${title}`,
|
|
44
42
|
isDefaultOpen: id === selectedId,
|
|
45
43
|
isDisabled: shouldBeDisabled,
|
|
46
44
|
rightElement: rightElement
|
|
47
|
-
}, /*#__PURE__*/React.createElement(AccordionContent, null, children))), [children, handleAccordionOpen, id,
|
|
45
|
+
}, /*#__PURE__*/React.createElement(AccordionContent, null, children))), [children, handleAccordionOpen, id, rightElement, selectedId, shouldBeDisabled, step, title]);
|
|
48
46
|
};
|
|
49
47
|
SetupWizardItem.displayName = 'SetupWizardItem';
|
|
50
48
|
export default SetupWizardItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SetupWizardItem.js","names":["React","useCallback","useContext","useMemo","Accordion","AccordionContent","Badge","Icon","SetupWizardContext","StyledSetupWizardItem","StyledSetupWizardItemBadge","SetupWizardItem","_ref","children","step","title","id","
|
|
1
|
+
{"version":3,"file":"SetupWizardItem.js","names":["React","useCallback","useContext","useMemo","Accordion","AccordionContent","Badge","Icon","SetupWizardContext","StyledSetupWizardItem","StyledSetupWizardItemBadge","SetupWizardItem","_ref","children","step","title","id","selectedId","updateSelectedId","activeId","shouldBeDisabled","rightElement","createElement","icons","handleAccordionOpen","onOpen","isDefaultOpen","isDisabled","displayName"],"sources":["../../../../src/components/setup-wizard/setup-wizard-item/SetupWizardItem.tsx"],"sourcesContent":["import React, { FC, ReactNode, useCallback, useContext, useMemo } from 'react';\nimport Accordion from '../../accordion/Accordion';\nimport AccordionContent from '../../accordion/accordion-content/AccordionContent';\nimport Badge from '../../badge/Badge';\nimport Icon from '../../icon/Icon';\nimport { SetupWizardContext } from '../SetupWizard';\nimport { StyledSetupWizardItem, StyledSetupWizardItemBadge } from './SetupWizardItem.styles';\n\nexport type SetupWizardItemProps = {\n /**\n * The content that should be displayed inside the item.\n */\n children: ReactNode;\n /**\n * The id of the item.\n */\n id: number;\n /**\n * The step of the item.\n */\n step: number;\n /**\n * The title of the item.\n */\n title: string;\n};\n\nconst SetupWizardItem: FC<SetupWizardItemProps> = ({ children, step, title, id }) => {\n const { selectedId, updateSelectedId, activeId } = useContext(SetupWizardContext);\n\n const shouldBeDisabled = useMemo(() => {\n if (typeof activeId === 'number' && activeId === id) {\n return false;\n }\n\n return typeof activeId === 'number' && activeId < id;\n }, [activeId, id]);\n\n const rightElement = useMemo(() => {\n if (activeId && id < activeId) {\n return (\n <Badge>\n <StyledSetupWizardItemBadge>\n <Icon icons={['ts-check']} />\n </StyledSetupWizardItemBadge>\n </Badge>\n );\n }\n\n return null;\n }, [activeId, id]);\n\n const handleAccordionOpen = useCallback(() => {\n if (typeof updateSelectedId === 'function') {\n updateSelectedId(id);\n }\n }, [id, updateSelectedId]);\n\n return useMemo(\n () => (\n <StyledSetupWizardItem>\n <Accordion\n onOpen={handleAccordionOpen}\n title={`${step}. ${title}`}\n isDefaultOpen={id === selectedId}\n isDisabled={shouldBeDisabled}\n rightElement={rightElement}\n >\n <AccordionContent>{children}</AccordionContent>\n </Accordion>\n </StyledSetupWizardItem>\n ),\n [\n children,\n handleAccordionOpen,\n id,\n rightElement,\n selectedId,\n shouldBeDisabled,\n step,\n title,\n ],\n );\n};\n\nSetupWizardItem.displayName = 'SetupWizardItem';\n\nexport default SetupWizardItem;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAmBC,WAAW,EAAEC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAC9E,OAAOC,SA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AC,EAAE,CAACA,EAAE,EAAEE,gBAAgB,CAAC,CAAC;EAE1B,OAAOf,OAAO,CACV,mBACIH,KAAA,CAAAsB,aAAA,CAACb,qBAAqB,qBAClBT,KAAA,CAAAsB,aAAA,CAAClB,SAAS;IACNqB,MAAM,EAAED,mBAAoB;IAC5BT,KAAK,EAAG,GAAED,IAAK,KAAIC,KAAM,EAAE;IAC3BW,aAAa,EAAEV,EAAE,KAAKC,UAAW;IACjCU,UAAU,EAAEP,gBAAiB;IAC7BC,YAAY,EAAEA;EAAa,gBAE3BrB,KAAA,CAAAsB,aAAA,CAACjB,gBAAgB,QAAEQ,QAA2B,CACvC,CACQ,CAC1B,EACD,CACIA,QAAQ,EACRW,mBAAmB,EACnBR,EAAE,EACFK,YAAY,EACZJ,UAAU,EACVG,gBAAgB,EAChBN,IAAI,EACJC,KAAK,CAEb,CAAC;AACL,CAAC;AAEDJ,eAAe,CAACiB,WAAW,GAAG,iBAAiB;AAE/C,eAAejB,eAAe"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { FC, MouseEvent, ReactElement } from 'react';
|
|
2
|
+
import { ClampPosition } from '../../types/truncation';
|
|
2
3
|
export type TruncationProps = {
|
|
3
4
|
/**
|
|
4
5
|
* The elements that should be expanding or collapsing.
|
|
5
6
|
*/
|
|
6
7
|
children: ReactElement;
|
|
8
|
+
/**
|
|
9
|
+
* The position of the clamp.
|
|
10
|
+
*/
|
|
11
|
+
clampPosition?: ClampPosition;
|
|
7
12
|
/**
|
|
8
13
|
* The height of the children Element in it`s collapsed state.
|
|
9
14
|
*/
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { ClampPosition } from '../../types/truncation';
|
|
2
3
|
import { truncateElement } from '../../utils/truncation';
|
|
3
|
-
import { StyledMotionTruncationContent, StyledTruncation, StyledTruncationClamp, StyledTruncationPseudoContent } from './Truncation.styles';
|
|
4
|
+
import { StyledMotionTruncationContent, StyledTruncation, StyledTruncationClamp, StyledTruncationClampWrapper, StyledTruncationPseudoContent } from './Truncation.styles';
|
|
4
5
|
const Truncation = _ref => {
|
|
5
6
|
let {
|
|
6
7
|
collapsedHeight = 150,
|
|
8
|
+
clampPosition = ClampPosition.Right,
|
|
7
9
|
isOpen,
|
|
8
10
|
moreLabel = 'Mehr',
|
|
9
11
|
lessLabel = 'Weniger',
|
|
@@ -120,9 +122,11 @@ const Truncation = _ref => {
|
|
|
120
122
|
},
|
|
121
123
|
onAnimationComplete: handleAnimationEnd,
|
|
122
124
|
ref: childrenRef
|
|
123
|
-
}), showClamp && /*#__PURE__*/React.createElement(
|
|
125
|
+
}), showClamp && /*#__PURE__*/React.createElement(StyledTruncationClampWrapper, {
|
|
126
|
+
$position: clampPosition
|
|
127
|
+
}, /*#__PURE__*/React.createElement(StyledTruncationClamp, {
|
|
124
128
|
onClick: handleClampClick
|
|
125
|
-
}, internalIsOpen ? lessLabel : moreLabel)), [children, handleAnimationEnd, handleClampClick, hasSizeChanged, internalIsOpen, lessLabel, moreLabel, newCollapsedHeight, originalHeight, showClamp]);
|
|
129
|
+
}, internalIsOpen ? lessLabel : moreLabel))), [children, clampPosition, handleAnimationEnd, handleClampClick, hasSizeChanged, internalIsOpen, lessLabel, moreLabel, newCollapsedHeight, originalHeight, showClamp]);
|
|
126
130
|
};
|
|
127
131
|
export default Truncation;
|
|
128
132
|
//# sourceMappingURL=Truncation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Truncation.js","names":["React","useCallback","useEffect","useMemo","useRef","useState","truncateElement","StyledMotionTruncationContent","StyledTruncation","StyledTruncationClamp","StyledTruncationPseudoContent","Truncation","_ref","collapsedHeight","isOpen","moreLabel","lessLabel","onChange","children","internalIsOpen","setInternalIsOpen","showClamp","setShowClamp","newCollapsedHeight","setNewCollapsedHeight","originalHeight","setOriginalHeight","shouldShowCollapsedElement","setShouldShowCollapsedElement","hasSizeChanged","setHasSizeChanged","initialRender","setInitialRender","originalSmallHeight","setOriginalSmallHeight","originalBigHeight","setOriginalBigHeight","pseudoChildrenRef","childrenRef","originalChildrenRef","handleClampClick","event","current","handleAnimationEnd","offsetHeight","firstChild","removeChild","appendChild","style","visibility","resizeObserver","ResizeObserver","entries","observedHeight","contentRect","height","observe","disconnect","createElement","className","ref","animate","initial","transition","type","duration","onAnimationComplete","onClick"],"sources":["../../../src/components/truncation/Truncation.tsx"],"sourcesContent":["import React, {\n FC,\n MouseEvent,\n MouseEventHandler,\n ReactElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { truncateElement } from '../../utils/truncation';\nimport {\n StyledMotionTruncationContent,\n StyledTruncation,\n StyledTruncationClamp,\n StyledTruncationPseudoContent,\n} from './Truncation.styles';\n\nexport type TruncationProps = {\n /**\n * The elements that should be expanding or collapsing.\n */\n children: ReactElement;\n /**\n * The height of the children Element in it`s collapsed state.\n */\n collapsedHeight?: number;\n /**\n * If set to true, the content is exposed.\n */\n isOpen?: boolean;\n /**\n * A text that should be displayed if the content is expanded.\n */\n lessLabel?: string;\n /**\n * A text that should be displayed if the content is collapsed.\n */\n moreLabel?: string;\n /**\n * Function to be executed when the component is expanding or collapsing.\n */\n onChange?: (event: MouseEvent<HTMLAnchorElement>, isOpen: boolean) => void;\n};\n\nconst Truncation: FC<TruncationProps> = ({\n collapsedHeight = 150,\n isOpen,\n moreLabel = 'Mehr',\n lessLabel = 'Weniger',\n onChange,\n children,\n}) => {\n const [internalIsOpen, setInternalIsOpen] = useState(false);\n const [showClamp, setShowClamp] = useState(true);\n const [newCollapsedHeight, setNewCollapsedHeight] = useState(collapsedHeight);\n const [originalHeight, setOriginalHeight] = useState(0);\n const [shouldShowCollapsedElement, setShouldShowCollapsedElement] = useState(true);\n const [hasSizeChanged, setHasSizeChanged] = useState(false);\n const [initialRender, setInitialRender] = useState(true);\n\n const [originalSmallHeight, setOriginalSmallHeight] = useState(0);\n const [originalBigHeight, setOriginalBigHeight] = useState(0);\n\n useEffect(() => {\n setInitialRender(false);\n }, []);\n\n const pseudoChildrenRef = useRef<HTMLDivElement>(null);\n const childrenRef = useRef<HTMLDivElement>(null);\n const originalChildrenRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (typeof isOpen === 'boolean') {\n setInternalIsOpen(isOpen);\n setShowClamp(!isOpen);\n }\n }, [isOpen]);\n\n // Changes the state of the truncation\n const handleClampClick = useCallback<MouseEventHandler<HTMLAnchorElement>>(\n (event) => {\n setInternalIsOpen((current) => {\n if (typeof onChange === 'function') {\n onChange(event, !current);\n }\n\n return !current;\n });\n },\n [onChange],\n );\n\n const handleAnimationEnd = useCallback(() => {\n setHasSizeChanged(false);\n setShouldShowCollapsedElement(!internalIsOpen);\n }, [internalIsOpen]);\n\n useEffect(() => {\n if (!pseudoChildrenRef.current) {\n return;\n }\n\n setOriginalHeight(pseudoChildrenRef.current.offsetHeight);\n setOriginalBigHeight(pseudoChildrenRef.current.offsetHeight);\n\n truncateElement(pseudoChildrenRef.current, collapsedHeight);\n\n setNewCollapsedHeight(pseudoChildrenRef.current.offsetHeight);\n setOriginalSmallHeight(pseudoChildrenRef.current.offsetHeight);\n }, [collapsedHeight, pseudoChildrenRef]);\n\n // Checks if the clamp should be shown\n useEffect(() => {\n if (pseudoChildrenRef.current && !hasSizeChanged && !initialRender) {\n setShowClamp(originalHeight > newCollapsedHeight);\n }\n }, [collapsedHeight, hasSizeChanged, initialRender, newCollapsedHeight, originalHeight]);\n\n useEffect(() => {\n if (childrenRef.current && pseudoChildrenRef.current && originalChildrenRef.current) {\n while (childrenRef.current.firstChild) {\n childrenRef.current.removeChild(childrenRef.current.firstChild);\n }\n\n childrenRef.current.appendChild(\n shouldShowCollapsedElement && !internalIsOpen\n ? pseudoChildrenRef.current\n : originalChildrenRef.current,\n );\n\n (childrenRef.current.children[0] as HTMLDivElement).style.visibility = 'visible';\n }\n }, [children, internalIsOpen, shouldShowCollapsedElement]);\n\n useEffect(() => {\n if (originalChildrenRef.current) {\n const resizeObserver = new ResizeObserver((entries) => {\n if (entries && entries[0]) {\n const observedHeight = entries[0].contentRect.height;\n setOriginalHeight(\n observedHeight < originalBigHeight ? originalBigHeight : observedHeight,\n );\n setHasSizeChanged(true);\n }\n });\n\n resizeObserver.observe(originalChildrenRef.current);\n\n return () => {\n resizeObserver.disconnect();\n };\n }\n\n return () => {};\n }, [originalBigHeight]);\n\n useEffect(() => {\n if (pseudoChildrenRef.current) {\n const resizeObserver = new ResizeObserver((entries) => {\n if (entries && entries[0]) {\n const observedHeight = entries[0].contentRect.height;\n setNewCollapsedHeight(\n observedHeight < originalSmallHeight ? originalSmallHeight : observedHeight,\n );\n setHasSizeChanged(true);\n }\n });\n\n resizeObserver.observe(pseudoChildrenRef.current);\n\n return () => {\n resizeObserver.disconnect();\n };\n }\n\n return () => {};\n }, [originalSmallHeight]);\n\n return useMemo(\n () => (\n <StyledTruncation className=\"beta-chayns-truncation\">\n <StyledTruncationPseudoContent ref={pseudoChildrenRef}>\n {children}\n </StyledTruncationPseudoContent>\n <StyledTruncationPseudoContent ref={originalChildrenRef}>\n {children}\n </StyledTruncationPseudoContent>\n <StyledMotionTruncationContent\n animate={{ height: internalIsOpen ? originalHeight : newCollapsedHeight }}\n initial={false}\n transition={{ type: 'tween', duration: hasSizeChanged ? 0 : 0.2 }}\n onAnimationComplete={handleAnimationEnd}\n ref={childrenRef}\n />\n {showClamp && (\n <StyledTruncationClamp onClick={handleClampClick}>\n {internalIsOpen ? lessLabel : moreLabel}\n </StyledTruncationClamp>\n )}\n </StyledTruncation>\n ),\n [\n children,\n handleAnimationEnd,\n handleClampClick,\n hasSizeChanged,\n internalIsOpen,\n lessLabel,\n moreLabel,\n newCollapsedHeight,\n originalHeight,\n showClamp,\n ],\n );\n};\n\nexport default Truncation;\n"],"mappings":"AAAA,OAAOA,KAAK,IAKRC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAA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,IAAI,EAAE,OAAO;MAAEC,QAAQ,EAAEpC,cAAc,GAAG,CAAC,GAAG;IAAI,CAAE;IAClEqC,mBAAmB,EAAEvB,kBAAmB;IACxCiB,GAAG,EAAEtB;EAAY,CACpB,CAAC,EACDjB,SAAS,iBACNrB,KAAA,CAAA0D,aAAA,CAACjD,qBAAqB;IAAC0D,OAAO,EAAE3B;EAAiB,GAC5CrB,cAAc,GAAGH,SAAS,GAAGD,SACX,CAEb,CACrB,EACD,CACIG,QAAQ,EACRyB,kBAAkB,EAClBH,gBAAgB,EAChBX,cAAc,EACdV,cAAc,EACdH,SAAS,EACTD,SAAS,EACTQ,kBAAkB,EAClBE,cAAc,EACdJ,SAAS,CAEjB,CAAC;AACL,CAAC;AAED,eAAeV,UAAU"}
|
|
1
|
+
{"version":3,"file":"Truncation.js","names":["React","useCallback","useEffect","useMemo","useRef","useState","ClampPosition","truncateElement","StyledMotionTruncationContent","StyledTruncation","StyledTruncationClamp","StyledTruncationClampWrapper","StyledTruncationPseudoContent","Truncation","_ref","collapsedHeight","clampPosition","Right","isOpen","moreLabel","lessLabel","onChange","children","internalIsOpen","setInternalIsOpen","showClamp","setShowClamp","newCollapsedHeight","setNewCollapsedHeight","originalHeight","setOriginalHeight","shouldShowCollapsedElement","setShouldShowCollapsedElement","hasSizeChanged","setHasSizeChanged","initialRender","setInitialRender","originalSmallHeight","setOriginalSmallHeight","originalBigHeight","setOriginalBigHeight","pseudoChildrenRef","childrenRef","originalChildrenRef","handleClampClick","event","current","handleAnimationEnd","offsetHeight","firstChild","removeChild","appendChild","style","visibility","resizeObserver","ResizeObserver","entries","observedHeight","contentRect","height","observe","disconnect","createElement","className","ref","animate","initial","transition","type","duration","onAnimationComplete","$position","onClick"],"sources":["../../../src/components/truncation/Truncation.tsx"],"sourcesContent":["import React, {\n FC,\n MouseEvent,\n MouseEventHandler,\n ReactElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { ClampPosition } from '../../types/truncation';\nimport { truncateElement } from '../../utils/truncation';\nimport {\n StyledMotionTruncationContent,\n StyledTruncation,\n StyledTruncationClamp,\n StyledTruncationClampWrapper,\n StyledTruncationPseudoContent,\n} from './Truncation.styles';\n\nexport type TruncationProps = {\n /**\n * The elements that should be expanding or collapsing.\n */\n children: ReactElement;\n /**\n * The position of the clamp.\n */\n clampPosition?: ClampPosition;\n /**\n * The height of the children Element in it`s collapsed state.\n */\n collapsedHeight?: number;\n /**\n * If set to true, the content is exposed.\n */\n isOpen?: boolean;\n /**\n * A text that should be displayed if the content is expanded.\n */\n lessLabel?: string;\n /**\n * A text that should be displayed if the content is collapsed.\n */\n moreLabel?: string;\n /**\n * Function to be executed when the component is expanding or collapsing.\n */\n onChange?: (event: MouseEvent<HTMLAnchorElement>, isOpen: boolean) => void;\n};\n\nconst Truncation: FC<TruncationProps> = ({\n collapsedHeight = 150,\n clampPosition = ClampPosition.Right,\n isOpen,\n moreLabel = 'Mehr',\n lessLabel = 'Weniger',\n onChange,\n children,\n}) => {\n const [internalIsOpen, setInternalIsOpen] = useState(false);\n const [showClamp, setShowClamp] = useState(true);\n const [newCollapsedHeight, setNewCollapsedHeight] = useState(collapsedHeight);\n const [originalHeight, setOriginalHeight] = useState(0);\n const [shouldShowCollapsedElement, setShouldShowCollapsedElement] = useState(true);\n const [hasSizeChanged, setHasSizeChanged] = useState(false);\n const [initialRender, setInitialRender] = useState(true);\n\n const [originalSmallHeight, setOriginalSmallHeight] = useState(0);\n const [originalBigHeight, setOriginalBigHeight] = useState(0);\n\n useEffect(() => {\n setInitialRender(false);\n }, []);\n\n const pseudoChildrenRef = useRef<HTMLDivElement>(null);\n const childrenRef = useRef<HTMLDivElement>(null);\n const originalChildrenRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (typeof isOpen === 'boolean') {\n setInternalIsOpen(isOpen);\n setShowClamp(!isOpen);\n }\n }, [isOpen]);\n\n // Changes the state of the truncation\n const handleClampClick = useCallback<MouseEventHandler<HTMLAnchorElement>>(\n (event) => {\n setInternalIsOpen((current) => {\n if (typeof onChange === 'function') {\n onChange(event, !current);\n }\n\n return !current;\n });\n },\n [onChange],\n );\n\n const handleAnimationEnd = useCallback(() => {\n setHasSizeChanged(false);\n setShouldShowCollapsedElement(!internalIsOpen);\n }, [internalIsOpen]);\n\n useEffect(() => {\n if (!pseudoChildrenRef.current) {\n return;\n }\n\n setOriginalHeight(pseudoChildrenRef.current.offsetHeight);\n setOriginalBigHeight(pseudoChildrenRef.current.offsetHeight);\n\n truncateElement(pseudoChildrenRef.current, collapsedHeight);\n\n setNewCollapsedHeight(pseudoChildrenRef.current.offsetHeight);\n setOriginalSmallHeight(pseudoChildrenRef.current.offsetHeight);\n }, [collapsedHeight, pseudoChildrenRef]);\n\n // Checks if the clamp should be shown\n useEffect(() => {\n if (pseudoChildrenRef.current && !hasSizeChanged && !initialRender) {\n setShowClamp(originalHeight > newCollapsedHeight);\n }\n }, [collapsedHeight, hasSizeChanged, initialRender, newCollapsedHeight, originalHeight]);\n\n useEffect(() => {\n if (childrenRef.current && pseudoChildrenRef.current && originalChildrenRef.current) {\n while (childrenRef.current.firstChild) {\n childrenRef.current.removeChild(childrenRef.current.firstChild);\n }\n\n childrenRef.current.appendChild(\n shouldShowCollapsedElement && !internalIsOpen\n ? pseudoChildrenRef.current\n : originalChildrenRef.current,\n );\n\n (childrenRef.current.children[0] as HTMLDivElement).style.visibility = 'visible';\n }\n }, [children, internalIsOpen, shouldShowCollapsedElement]);\n\n useEffect(() => {\n if (originalChildrenRef.current) {\n const resizeObserver = new ResizeObserver((entries) => {\n if (entries && entries[0]) {\n const observedHeight = entries[0].contentRect.height;\n setOriginalHeight(\n observedHeight < originalBigHeight ? originalBigHeight : observedHeight,\n );\n setHasSizeChanged(true);\n }\n });\n\n resizeObserver.observe(originalChildrenRef.current);\n\n return () => {\n resizeObserver.disconnect();\n };\n }\n\n return () => {};\n }, [originalBigHeight]);\n\n useEffect(() => {\n if (pseudoChildrenRef.current) {\n const resizeObserver = new ResizeObserver((entries) => {\n if (entries && entries[0]) {\n const observedHeight = entries[0].contentRect.height;\n setNewCollapsedHeight(\n observedHeight < originalSmallHeight ? originalSmallHeight : observedHeight,\n );\n setHasSizeChanged(true);\n }\n });\n\n resizeObserver.observe(pseudoChildrenRef.current);\n\n return () => {\n resizeObserver.disconnect();\n };\n }\n\n return () => {};\n }, [originalSmallHeight]);\n\n return useMemo(\n () => (\n <StyledTruncation className=\"beta-chayns-truncation\">\n <StyledTruncationPseudoContent ref={pseudoChildrenRef}>\n {children}\n </StyledTruncationPseudoContent>\n <StyledTruncationPseudoContent ref={originalChildrenRef}>\n {children}\n </StyledTruncationPseudoContent>\n <StyledMotionTruncationContent\n animate={{ height: internalIsOpen ? originalHeight : newCollapsedHeight }}\n initial={false}\n transition={{ type: 'tween', duration: hasSizeChanged ? 0 : 0.2 }}\n onAnimationComplete={handleAnimationEnd}\n ref={childrenRef}\n />\n {showClamp && (\n <StyledTruncationClampWrapper $position={clampPosition}>\n <StyledTruncationClamp onClick={handleClampClick}>\n {internalIsOpen ? lessLabel : moreLabel}\n </StyledTruncationClamp>\n </StyledTruncationClampWrapper>\n )}\n </StyledTruncation>\n ),\n [\n children,\n clampPosition,\n handleAnimationEnd,\n handleClampClick,\n hasSizeChanged,\n internalIsOpen,\n lessLabel,\n moreLabel,\n newCollapsedHeight,\n originalHeight,\n showClamp,\n ],\n );\n};\n\nexport default Truncation;\n"],"mappings":"AAAA,OAAOA,KAAK,IAKRC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SAASC,aAAa,QAAQ,wBAAwB;AACtD,SAASC,eAAe,QAAQ,wBAAwB;AACxD,SACIC,6BAA6B,EAC7BC,gBAAgB,EAChBC,qBAAqB,EACrBC,4BAA4B,EAC5BC,6BAA6B,QAC1B,qBAAqB;AAiC5B,MAAMC,UAA+B,GAAGC,IAAA,IAQlC;EAAA,IARmC;IACrCC,eAAe,GA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AC,EACDjB,SAAS,iBACNzB,KAAA,CAAA8D,aAAA,CAACnD,4BAA4B;IAAC4D,SAAS,EAAEvD;EAAc,gBACnDhB,KAAA,CAAA8D,aAAA,CAACpD,qBAAqB;IAAC8D,OAAO,EAAE5B;EAAiB,GAC5CrB,cAAc,GAAGH,SAAS,GAAGD,SACX,CACG,CAEpB,CACrB,EACD,CACIG,QAAQ,EACRN,aAAa,EACb+B,kBAAkB,EAClBH,gBAAgB,EAChBX,cAAc,EACdV,cAAc,EACdH,SAAS,EACTD,SAAS,EACTQ,kBAAkB,EAClBE,cAAc,EACdJ,SAAS,CAEjB,CAAC;AACL,CAAC;AAED,eAAeZ,UAAU"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
/// <reference types="react" />
|
|
3
|
+
import { ClampPosition } from '../../types/truncation';
|
|
4
|
+
import type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';
|
|
3
5
|
export declare const StyledTruncation: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
|
|
4
6
|
export declare const StyledMotionTruncationContent: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<{
|
|
5
7
|
slot?: string | undefined;
|
|
@@ -267,4 +269,9 @@ export declare const StyledMotionTruncationContent: import("styled-components").
|
|
|
267
269
|
theme: import("../color-scheme-provider/ColorSchemeProvider").Theme;
|
|
268
270
|
}>> & Omit<import("framer-motion").ForwardRefComponent<HTMLDivElement, import("framer-motion").HTMLMotionProps<"div">>, keyof import("react").Component<any, {}, any>>;
|
|
269
271
|
export declare const StyledTruncationPseudoContent: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
|
|
272
|
+
type StyledTruncationClampWrapperProps = WithTheme<{
|
|
273
|
+
$position: ClampPosition;
|
|
274
|
+
}>;
|
|
275
|
+
export declare const StyledTruncationClampWrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledTruncationClampWrapperProps>>;
|
|
270
276
|
export declare const StyledTruncationClamp: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, never>>;
|
|
277
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { motion } from 'framer-motion';
|
|
2
|
-
import styled from 'styled-components';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
import { ClampPosition } from '../../types/truncation';
|
|
3
4
|
export const StyledTruncation = styled.div`
|
|
4
5
|
position: relative;
|
|
5
6
|
`;
|
|
@@ -13,8 +14,30 @@ export const StyledTruncationPseudoContent = styled.div`
|
|
|
13
14
|
position: absolute;
|
|
14
15
|
width: fit-content;
|
|
15
16
|
`;
|
|
17
|
+
export const StyledTruncationClampWrapper = styled.div`
|
|
18
|
+
display: flex;
|
|
19
|
+
|
|
20
|
+
${_ref => {
|
|
21
|
+
let {
|
|
22
|
+
$position
|
|
23
|
+
} = _ref;
|
|
24
|
+
switch ($position) {
|
|
25
|
+
case ClampPosition.Left:
|
|
26
|
+
return css`
|
|
27
|
+
justify-content: left;
|
|
28
|
+
`;
|
|
29
|
+
case ClampPosition.Middle:
|
|
30
|
+
return css`
|
|
31
|
+
justify-content: center;
|
|
32
|
+
`;
|
|
33
|
+
default:
|
|
34
|
+
return css`
|
|
35
|
+
justify-content: right;
|
|
36
|
+
`;
|
|
37
|
+
}
|
|
38
|
+
}}
|
|
39
|
+
`;
|
|
16
40
|
export const StyledTruncationClamp = styled.a`
|
|
17
41
|
cursor: pointer;
|
|
18
|
-
float: right;
|
|
19
42
|
`;
|
|
20
43
|
//# sourceMappingURL=Truncation.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Truncation.styles.js","names":["motion","styled","StyledTruncation","div","StyledMotionTruncationContent","StyledTruncationPseudoContent","StyledTruncationClamp","a"],"sources":["../../../src/components/truncation/Truncation.styles.ts"],"sourcesContent":["import { motion } from 'framer-motion';\nimport styled from 'styled-components';\nimport type { FramerMotionBugFix } from '../color-scheme-provider/ColorSchemeProvider';\n\nexport const StyledTruncation = styled.div`\n position: relative;\n`;\n\n// Fix framer-motion bug\nexport const StyledMotionTruncationContent = styled(motion.div)<FramerMotionBugFix>`\n overflow: hidden;\n`;\n\nexport const StyledTruncationPseudoContent = styled.div`\n visibility: hidden;\n position: absolute;\n width: fit-content;\n`;\n\nexport const
|
|
1
|
+
{"version":3,"file":"Truncation.styles.js","names":["motion","styled","css","ClampPosition","StyledTruncation","div","StyledMotionTruncationContent","StyledTruncationPseudoContent","StyledTruncationClampWrapper","_ref","$position","Left","Middle","StyledTruncationClamp","a"],"sources":["../../../src/components/truncation/Truncation.styles.ts"],"sourcesContent":["import { motion } from 'framer-motion';\nimport styled, { css } from 'styled-components';\nimport { ClampPosition } from '../../types/truncation';\nimport type { FramerMotionBugFix, WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\n\nexport const StyledTruncation = styled.div`\n position: relative;\n`;\n\n// Fix framer-motion bug\nexport const StyledMotionTruncationContent = styled(motion.div)<FramerMotionBugFix>`\n overflow: hidden;\n`;\n\nexport const StyledTruncationPseudoContent = styled.div`\n visibility: hidden;\n position: absolute;\n width: fit-content;\n`;\n\ntype StyledTruncationClampWrapperProps = WithTheme<{ $position: ClampPosition }>;\n\nexport const StyledTruncationClampWrapper = styled.div<StyledTruncationClampWrapperProps>`\n display: flex;\n\n ${({ $position }) => {\n switch ($position) {\n case ClampPosition.Left:\n return css`\n justify-content: left;\n `;\n case ClampPosition.Middle:\n return css`\n justify-content: center;\n `;\n default:\n return css`\n justify-content: right;\n `;\n }\n }}\n`;\n\nexport const StyledTruncationClamp = styled.a`\n cursor: pointer;\n`;\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,eAAe;AACtC,OAAOC,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAC/C,SAASC,aAAa,QAAQ,wBAAwB;AAGtD,OAAO,MAAMC,gBAAgB,GAAGH,MAAM,CAACI,GAAI;AAC3C;AACA,CAAC;;AAED;AACA,OAAO,MAAMC,6BAA6B,GAAGL,MAAM,CAACD,MAAM,CAACK,GAAG,CAAsB;AACpF;AACA,CAAC;AAED,OAAO,MAAME,6BAA6B,GAAGN,MAAM,CAACI,GAAI;AACxD;AACA;AACA;AACA,CAAC;AAID,OAAO,MAAMG,4BAA4B,GAAGP,MAAM,CAACI,GAAuC;AAC1F;AACA;AACA,MAAMI,IAAA,IAAmB;EAAA,IAAlB;IAAEC;EAAU,CAAC,GAAAD,IAAA;EACZ,QAAQC,SAAS;IACb,KAAKP,aAAa,CAACQ,IAAI;MACnB,OAAOT,GAAI;AAC3B;AACA,iBAAiB;IACL,KAAKC,aAAa,CAACS,MAAM;MACrB,OAAOV,GAAI;AAC3B;AACA,iBAAiB;IACL;MACI,OAAOA,GAAI;AAC3B;AACA,iBAAiB;EACT;AACJ,CAAE;AACN,CAAC;AAED,OAAO,MAAMW,qBAAqB,GAAGZ,MAAM,CAACa,CAAE;AAC9C;AACA,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -46,12 +46,13 @@ export { default as Tooltip } from './components/tooltip/Tooltip';
|
|
|
46
46
|
export { default as Truncation } from './components/truncation/Truncation';
|
|
47
47
|
export { MentionFinderPopupAlignment } from './constants/mentionFinder';
|
|
48
48
|
export { ComboBoxDirection } from './types/comboBox';
|
|
49
|
-
export type { FileItem, Image, Meta, Video } from './types/file';
|
|
49
|
+
export type { FileItem, Image, InternalFileItem, Meta, Video } from './types/file';
|
|
50
50
|
export type { FilterButtonItemShape, FilterButtonSize, IFilterButtonItem as FilterButtonItem, } from './types/filterButtons';
|
|
51
51
|
export type { PopupRef } from './types/popup';
|
|
52
52
|
export type { ISearchBoxItem as SearchBoxItem } from './types/searchBox';
|
|
53
53
|
export type { SelectButtonItem } from './types/selectButton';
|
|
54
54
|
export type { SliderButtonItem } from './types/slider-button';
|
|
55
|
+
export { ClampPosition } from './types/truncation';
|
|
55
56
|
export { getFileAsArrayBuffer, selectFiles } from './utils/fileDialog';
|
|
56
57
|
export { isTobitEmployee } from './utils/isTobitEmployee';
|
|
57
58
|
export { uploadFile } from './utils/uploadFile';
|
package/lib/index.js
CHANGED
|
@@ -42,6 +42,7 @@ export { default as Tooltip } from './components/tooltip/Tooltip';
|
|
|
42
42
|
export { default as Truncation } from './components/truncation/Truncation';
|
|
43
43
|
export { MentionFinderPopupAlignment } from './constants/mentionFinder';
|
|
44
44
|
export { ComboBoxDirection } from './types/comboBox';
|
|
45
|
+
export { ClampPosition } from './types/truncation';
|
|
45
46
|
export { getFileAsArrayBuffer, selectFiles } from './utils/fileDialog';
|
|
46
47
|
export { isTobitEmployee } from './utils/isTobitEmployee';
|
|
47
48
|
export { uploadFile } from './utils/uploadFile';
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["default","Accordion","AccordionContent","AccordionGroup","AccordionIntro","AccordionItem","AmountControl","Badge","Button","Checkbox","ColorSchemeProvider","ComboBox","ContentCard","ContextMenu","FileInput","FilterButtons","GridImage","Icon","Input","List","ListItemContent","ListItem","MentionFinder","NumberInput","Popup","ProgressBar","RadioButtonGroup","RadioButton","ScrollView","SearchBox","SearchInput","SelectButton","SetupWizardItem","SetupWizard","SharingBar","Signature","SliderButton","Slider","SmallWaitCursor","SmallWaitCursorSize","SmallWaitCursorSpeed","TextArea","Tooltip","Truncation","MentionFinderPopupAlignment","ComboBoxDirection","getFileAsArrayBuffer","selectFiles","isTobitEmployee","uploadFile"],"sources":["../src/index.ts"],"sourcesContent":["// noinspection JSUnusedGlobalSymbols\nexport { default as Accordion } from './components/accordion/Accordion';\nexport { default as AccordionContent } from './components/accordion/accordion-content/AccordionContent';\nexport { default as AccordionGroup } from './components/accordion/accordion-group/AccordionGroup';\nexport { default as AccordionIntro } from './components/accordion/accordion-intro/AccordionIntro';\nexport { default as AccordionItem } from './components/accordion/accordion-item/AccordionItem';\nexport { default as AmountControl } from './components/amount-control/AmountControl';\nexport { default as Badge } from './components/badge/Badge';\nexport { default as Button } from './components/button/Button';\nexport { default as Checkbox } from './components/checkbox/Checkbox';\nexport { default as ColorSchemeProvider } from './components/color-scheme-provider/ColorSchemeProvider';\nexport type {\n FramerMotionBugFix,\n WithTheme,\n} from './components/color-scheme-provider/ColorSchemeProvider';\nexport { default as ComboBox } from './components/combobox/ComboBox';\nexport type { IComboBoxItem as ComboBoxItem } from './components/combobox/ComboBox';\nexport { default as ContentCard } from './components/content-card/ContentCard';\nexport { default as ContextMenu } from './components/context-menu/ContextMenu';\nexport { default as FileInput } from './components/file-input/FileInput';\nexport { default as FilterButtons } from './components/filter-buttons/FilterButtons';\nexport { default as GridImage } from './components/grid-image/GridImage';\nexport { default as Icon } from './components/icon/Icon';\nexport { default as Input } from './components/input/Input';\nexport { default as List } from './components/list/List';\nexport { default as ListItemContent } from './components/list/list-item/list-item-content/ListItemContent';\nexport { default as ListItem } from './components/list/list-item/ListItem';\nexport { default as MentionFinder } from './components/mention-finder/MentionFinder';\nexport type { MentionMember } from './components/mention-finder/MentionFinder';\nexport { default as NumberInput } from './components/number-input/NumberInput';\nexport { default as Popup } from './components/popup/Popup';\nexport { default as ProgressBar } from './components/progress-bar/ProgressBar';\nexport { default as RadioButtonGroup } from './components/radio-button/radio-button-group/RadioButtonGroup';\nexport { default as RadioButton } from './components/radio-button/RadioButton';\nexport { default as ScrollView } from './components/scroll-view/ScrollView';\nexport { default as SearchBox } from './components/search-box/SearchBox';\nexport { default as SearchInput } from './components/search-input/SearchInput';\nexport { default as SelectButton } from './components/select-button/SelectButton';\nexport { default as SetupWizardItem } from './components/setup-wizard/setup-wizard-item/SetupWizardItem';\nexport { default as SetupWizard } from './components/setup-wizard/SetupWizard';\nexport type { SetupWizardRef } from './components/setup-wizard/SetupWizard';\nexport { default as SharingBar } from './components/sharing-bar/SharingBar';\nexport { default as Signature } from './components/signature/Signature';\nexport type { SignatureRef } from './components/signature/Signature';\nexport { default as SliderButton } from './components/slider-button/SliderButton';\nexport { default as Slider } from './components/slider/Slider';\nexport {\n default as SmallWaitCursor,\n SmallWaitCursorSize,\n SmallWaitCursorSpeed,\n} from './components/small-wait-cursor/SmallWaitCursor';\nexport { default as TextArea } from './components/text-area/TextArea';\nexport { default as Tooltip } from './components/tooltip/Tooltip';\nexport { default as Truncation } from './components/truncation/Truncation';\nexport { MentionFinderPopupAlignment } from './constants/mentionFinder';\nexport { ComboBoxDirection } from './types/comboBox';\nexport type { FileItem, Image, Meta, Video } from './types/file';\nexport type {\n FilterButtonItemShape,\n FilterButtonSize,\n IFilterButtonItem as FilterButtonItem,\n} from './types/filterButtons';\nexport type { PopupRef } from './types/popup';\nexport type { ISearchBoxItem as SearchBoxItem } from './types/searchBox';\nexport type { SelectButtonItem } from './types/selectButton';\nexport type { SliderButtonItem } from './types/slider-button';\nexport { getFileAsArrayBuffer, selectFiles } from './utils/fileDialog';\nexport { isTobitEmployee } from './utils/isTobitEmployee';\nexport { uploadFile } from './utils/uploadFile';\n"],"mappings":"AAAA;AACA,SAASA,OAAO,IAAIC,SAAS,QAAQ,kCAAkC;AACvE,SAASD,OAAO,IAAIE,gBAAgB,QAAQ,2DAA2D;AACvG,SAASF,OAAO,IAAIG,cAAc,QAAQ,uDAAuD;AACjG,SAASH,OAAO,IAAII,cAAc,QAAQ,uDAAuD;AACjG,SAASJ,OAAO,IAAIK,aAAa,QAAQ,qDAAqD;AAC9F,SAASL,OAAO,IAAIM,aAAa,QAAQ,2CAA2C;AACpF,SAASN,OAAO,IAAIO,KAAK,QAAQ,0BAA0B;AAC3D,SAASP,OAAO,IAAIQ,MAAM,QAAQ,4BAA4B;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W,QAAQ,uCAAuC;AAE9E,SAASjC,OAAO,IAAIkC,UAAU,QAAQ,qCAAqC;AAC3E,SAASlC,OAAO,IAAImC,SAAS,QAAQ,kCAAkC;AAEvE,SAASnC,OAAO,IAAIoC,YAAY,QAAQ,yCAAyC;AACjF,SAASpC,OAAO,IAAIqC,MAAM,QAAQ,4BAA4B;AAC9D,SACIrC,OAAO,IAAIsC,eAAe,EAC1BC,mBAAmB,EACnBC,oBAAoB,QACjB,gDAAgD;AACvD,SAASxC,OAAO,IAAIyC,QAAQ,QAAQ,iCAAiC;AACrE,SAASzC,OAAO,IAAI0C,OAAO,QAAQ,8BAA8B;AACjE,SAAS1C,OAAO,IAAI2C,UAAU,QAAQ,oCAAoC;AAC1E,SAASC,2BAA2B,QAAQ,2BAA2B;AACvE,SAASC,iBAAiB,QAAQ,kBAAkB;AAWpD,SAASC,oBAAoB,EAAEC,WAAW,QAAQ,oBAAoB;AACtE,SAASC,eAAe,QAAQ,yBAAyB;AACzD,SAASC,UAAU,QAAQ,oBAAoB"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","Accordion","AccordionContent","AccordionGroup","AccordionIntro","AccordionItem","AmountControl","Badge","Button","Checkbox","ColorSchemeProvider","ComboBox","ContentCard","ContextMenu","FileInput","FilterButtons","GridImage","Icon","Input","List","ListItemContent","ListItem","MentionFinder","NumberInput","Popup","ProgressBar","RadioButtonGroup","RadioButton","ScrollView","SearchBox","SearchInput","SelectButton","SetupWizardItem","SetupWizard","SharingBar","Signature","SliderButton","Slider","SmallWaitCursor","SmallWaitCursorSize","SmallWaitCursorSpeed","TextArea","Tooltip","Truncation","MentionFinderPopupAlignment","ComboBoxDirection","ClampPosition","getFileAsArrayBuffer","selectFiles","isTobitEmployee","uploadFile"],"sources":["../src/index.ts"],"sourcesContent":["// noinspection JSUnusedGlobalSymbols\nexport { default as Accordion } from './components/accordion/Accordion';\nexport { default as AccordionContent } from './components/accordion/accordion-content/AccordionContent';\nexport { default as AccordionGroup } from './components/accordion/accordion-group/AccordionGroup';\nexport { default as AccordionIntro } from './components/accordion/accordion-intro/AccordionIntro';\nexport { default as AccordionItem } from './components/accordion/accordion-item/AccordionItem';\nexport { default as AmountControl } from './components/amount-control/AmountControl';\nexport { default as Badge } from './components/badge/Badge';\nexport { default as Button } from './components/button/Button';\nexport { default as Checkbox } from './components/checkbox/Checkbox';\nexport { default as ColorSchemeProvider } from './components/color-scheme-provider/ColorSchemeProvider';\nexport type {\n FramerMotionBugFix,\n WithTheme,\n} from './components/color-scheme-provider/ColorSchemeProvider';\nexport { default as ComboBox } from './components/combobox/ComboBox';\nexport type { IComboBoxItem as ComboBoxItem } from './components/combobox/ComboBox';\nexport { default as ContentCard } from './components/content-card/ContentCard';\nexport { default as ContextMenu } from './components/context-menu/ContextMenu';\nexport { default as FileInput } from './components/file-input/FileInput';\nexport { default as FilterButtons } from './components/filter-buttons/FilterButtons';\nexport { default as GridImage } from './components/grid-image/GridImage';\nexport { default as Icon } from './components/icon/Icon';\nexport { default as Input } from './components/input/Input';\nexport { default as List } from './components/list/List';\nexport { default as ListItemContent } from './components/list/list-item/list-item-content/ListItemContent';\nexport { default as ListItem } from './components/list/list-item/ListItem';\nexport { default as MentionFinder } from './components/mention-finder/MentionFinder';\nexport type { MentionMember } from './components/mention-finder/MentionFinder';\nexport { default as NumberInput } from './components/number-input/NumberInput';\nexport { default as Popup } from './components/popup/Popup';\nexport { default as ProgressBar } from './components/progress-bar/ProgressBar';\nexport { default as RadioButtonGroup } from './components/radio-button/radio-button-group/RadioButtonGroup';\nexport { default as RadioButton } from './components/radio-button/RadioButton';\nexport { default as ScrollView } from './components/scroll-view/ScrollView';\nexport { default as SearchBox } from './components/search-box/SearchBox';\nexport { default as SearchInput } from './components/search-input/SearchInput';\nexport { default as SelectButton } from './components/select-button/SelectButton';\nexport { default as SetupWizardItem } from './components/setup-wizard/setup-wizard-item/SetupWizardItem';\nexport { default as SetupWizard } from './components/setup-wizard/SetupWizard';\nexport type { SetupWizardRef } from './components/setup-wizard/SetupWizard';\nexport { default as SharingBar } from './components/sharing-bar/SharingBar';\nexport { default as Signature } from './components/signature/Signature';\nexport type { SignatureRef } from './components/signature/Signature';\nexport { default as SliderButton } from './components/slider-button/SliderButton';\nexport { default as Slider } from './components/slider/Slider';\nexport {\n default as SmallWaitCursor,\n SmallWaitCursorSize,\n SmallWaitCursorSpeed,\n} from './components/small-wait-cursor/SmallWaitCursor';\nexport { default as TextArea } from './components/text-area/TextArea';\nexport { default as Tooltip } from './components/tooltip/Tooltip';\nexport { default as Truncation } from './components/truncation/Truncation';\nexport { MentionFinderPopupAlignment } from './constants/mentionFinder';\nexport { ComboBoxDirection } from './types/comboBox';\nexport type { FileItem, Image, InternalFileItem, Meta, Video } from './types/file';\nexport type {\n FilterButtonItemShape,\n FilterButtonSize,\n IFilterButtonItem as FilterButtonItem,\n} from './types/filterButtons';\nexport type { PopupRef } from './types/popup';\nexport type { ISearchBoxItem as SearchBoxItem } from './types/searchBox';\nexport type { SelectButtonItem } from './types/selectButton';\nexport type { SliderButtonItem } from './types/slider-button';\nexport { ClampPosition } from './types/truncation';\nexport { getFileAsArrayBuffer, selectFiles } from './utils/fileDialog';\nexport { isTobitEmployee } from './utils/isTobitEmployee';\nexport { uploadFile } from './utils/uploadFile';\n"],"mappings":"AAAA;AACA,SAASA,OAAO,IAAIC,SAAS,QAAQ,kCAAkC;AACvE,SAASD,OAAO,IAAIE,gBAAgB,QAAQ,2DAA2D;AACvG,SAASF,OAAO,IAAIG,cAAc,QAAQ,uDAAuD;AACjG,SAASH,OAAO,IAAII,cAAc,QAAQ,uDAAuD;AACjG,SAASJ,OAAO,IAAIK,aAAa,QAAQ,qDAAqD;AAC9F,SAASL,OAAO,IAAIM,aAAa,QAAQ,2CAA2C;AACpF,SAASN,OAAO,IAAIO,KAAK,QAAQ,0BAA0B;AAC3D,SAASP,OAAO,IAAIQ,MAAM,QAAQ,4BAA4B;AAC9D,SAASR,OAAO,IAAIS,QAAQ,QAAQ,g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IkC,UAAU,QAAQ,qCAAqC;AAC3E,SAASlC,OAAO,IAAImC,SAAS,QAAQ,kCAAkC;AAEvE,SAASnC,OAAO,IAAIoC,YAAY,QAAQ,yCAAyC;AACjF,SAASpC,OAAO,IAAIqC,MAAM,QAAQ,4BAA4B;AAC9D,SACIrC,OAAO,IAAIsC,eAAe,EAC1BC,mBAAmB,EACnBC,oBAAoB,QACjB,gDAAgD;AACvD,SAASxC,OAAO,IAAIyC,QAAQ,QAAQ,iCAAiC;AACrE,SAASzC,OAAO,IAAI0C,OAAO,QAAQ,8BAA8B;AACjE,SAAS1C,OAAO,IAAI2C,UAAU,QAAQ,oCAAoC;AAC1E,SAASC,2BAA2B,QAAQ,2BAA2B;AACvE,SAASC,iBAAiB,QAAQ,kBAAkB;AAWpD,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,oBAAoB,EAAEC,WAAW,QAAQ,oBAAoB;AACtE,SAASC,eAAe,QAAQ,yBAAyB;AACzD,SAASC,UAAU,QAAQ,oBAAoB"}
|
package/lib/types/file.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export interface Meta {
|
|
|
17
17
|
width: string;
|
|
18
18
|
height: string;
|
|
19
19
|
}
|
|
20
|
-
export interface
|
|
20
|
+
export interface InternalFileItem {
|
|
21
21
|
/**
|
|
22
22
|
* The state will be set in this component
|
|
23
23
|
*/
|
|
@@ -40,3 +40,7 @@ export interface FileItem {
|
|
|
40
40
|
*/
|
|
41
41
|
previewUrl?: string;
|
|
42
42
|
}
|
|
43
|
+
export interface FileItem {
|
|
44
|
+
file: Video | Image;
|
|
45
|
+
id?: string;
|
|
46
|
+
}
|
package/lib/types/file.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.js","names":[],"sources":["../../src/types/file.ts"],"sourcesContent":["export type LoadingState = 'uploading' | 'uploaded' | 'none';\n\nexport interface Video {\n id: string;\n originalVideoQuality?: string;\n thumbnailUrl: string;\n url: string;\n ratio?: number;\n}\n\nexport interface Image {\n id?: string;\n url: string;\n meta?: Meta;\n ratio?: number;\n}\n\nexport interface Meta {\n preview: string;\n width: string;\n height: string;\n}\n\nexport interface
|
|
1
|
+
{"version":3,"file":"file.js","names":[],"sources":["../../src/types/file.ts"],"sourcesContent":["export type LoadingState = 'uploading' | 'uploaded' | 'none';\n\nexport interface Video {\n id: string;\n originalVideoQuality?: string;\n thumbnailUrl: string;\n url: string;\n ratio?: number;\n}\n\nexport interface Image {\n id?: string;\n url: string;\n meta?: Meta;\n ratio?: number;\n}\n\nexport interface Meta {\n preview: string;\n width: string;\n height: string;\n}\n\nexport interface InternalFileItem {\n /**\n * The state will be set in this component\n */\n state?: LoadingState;\n /**\n * Raw file from select or drag and drop\n */\n file?: File;\n /**\n * File that is uploaded at any service\n */\n uploadedFile?: Video | Image;\n /**\n * The ID of the file. If an `uploadedFile` object is provided, the ID is set to the ID of the uploaded file.\n * If no `uploadedFile` object is provided, a new ID will be generated.\n */\n id: string;\n /**\n * Preview url of the file\n */\n previewUrl?: string;\n}\n\nexport interface FileItem {\n file: Video | Image;\n id?: string;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export let ClampPosition = /*#__PURE__*/function (ClampPosition) {
|
|
2
|
+
ClampPosition[ClampPosition["Right"] = 0] = "Right";
|
|
3
|
+
ClampPosition[ClampPosition["Middle"] = 1] = "Middle";
|
|
4
|
+
ClampPosition[ClampPosition["Left"] = 2] = "Left";
|
|
5
|
+
return ClampPosition;
|
|
6
|
+
}({});
|
|
7
|
+
//# sourceMappingURL=truncation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"truncation.js","names":["ClampPosition"],"sources":["../../src/types/truncation.ts"],"sourcesContent":["export enum ClampPosition {\n Right,\n Middle,\n Left,\n}\n"],"mappings":"AAAA,WAAYA,aAAa,0BAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Image, InternalFileItem, Video } from '../types/file';
|
|
2
2
|
interface UploadFilesOptions {
|
|
3
|
-
fileToUpload:
|
|
3
|
+
fileToUpload: InternalFileItem;
|
|
4
4
|
callback: (UploadedFile: Video | Image) => void;
|
|
5
5
|
}
|
|
6
6
|
export declare const uploadFile: ({ fileToUpload, callback }: UploadFilesOptions) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadFile.js","names":["postImage","postVideo","uploadFile","_ref","fileToUpload","callback","state","file","type","includes","uploadedVideo","id","toString","uploadedImage","url","base","key","meta"],"sources":["../../src/utils/uploadFile.ts"],"sourcesContent":["import { postImage } from '../api/image/post';\nimport { postVideo } from '../api/video/post';\nimport type {
|
|
1
|
+
{"version":3,"file":"uploadFile.js","names":["postImage","postVideo","uploadFile","_ref","fileToUpload","callback","state","file","type","includes","uploadedVideo","id","toString","uploadedImage","url","base","key","meta"],"sources":["../../src/utils/uploadFile.ts"],"sourcesContent":["import { postImage } from '../api/image/post';\nimport { postVideo } from '../api/video/post';\nimport type { Image, InternalFileItem, Video } from '../types/file';\n\ninterface UploadFilesOptions {\n fileToUpload: InternalFileItem;\n callback: (UploadedFile: Video | Image) => void;\n}\n\nexport const uploadFile = async ({ fileToUpload, callback }: UploadFilesOptions): Promise<void> => {\n if (!fileToUpload || fileToUpload.state !== 'none') {\n return;\n }\n\n if (fileToUpload.file?.type.includes('video/')) {\n const uploadedVideo = await postVideo({ file: fileToUpload.file });\n\n if (uploadedVideo) {\n callback({\n ...uploadedVideo,\n id: uploadedVideo.id.toString(),\n });\n }\n }\n\n if (fileToUpload.file?.type.includes('image/')) {\n const uploadedImage = await postImage({ file: fileToUpload.file });\n\n if (uploadedImage) {\n callback({\n url: `${uploadedImage.base}/${uploadedImage.key}`,\n id: uploadedImage.key,\n meta: uploadedImage.meta,\n });\n }\n }\n};\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,mBAAmB;AAC7C,SAASC,SAAS,QAAQ,mBAAmB;AAQ7C,OAAO,MAAMC,UAAU,GAAG,MAAAC,IAAA,IAAyE;EAAA,IAAlE;IAAEC,YAAY;IAAEC;EAA6B,CAAC,GAAAF,IAAA;EAC3E,IAAI,CAACC,YAAY,IAAIA,YAAY,CAACE,KAAK,KAAK,MAAM,EAAE;IAChD;EACJ;EAEA,IAAIF,YAAY,CAACG,IAAI,EAAEC,IAAI,CAACC,QAAQ,CAAC,QAAQ,CAAC,EAAE;IAC5C,MAAMC,aAAa,GAAG,MAAMT,SAAS,CAAC;MAAEM,IAAI,EAAEH,YAAY,CAACG;IAAK,CAAC,CAAC;IAElE,IAAIG,aAAa,EAAE;MACfL,QAAQ,CAAC;QACL,GAAGK,aAAa;QAChBC,EAAE,EAAED,aAAa,CAACC,EAAE,CAACC,QAAQ,CAAC;MAClC,CAAC,CAAC;IACN;EACJ;EAEA,IAAIR,YAAY,CAACG,IAAI,EAAEC,IAAI,CAACC,QAAQ,CAAC,QAAQ,CAAC,EAAE;IAC5C,MAAMI,aAAa,GAAG,MAAMb,SAAS,CAAC;MAAEO,IAAI,EAAEH,YAAY,CAACG;IAAK,CAAC,CAAC;IAElE,IAAIM,aAAa,EAAE;MACfR,QAAQ,CAAC;QACLS,GAAG,EAAG,GAAED,aAAa,CAACE,IAAK,IAAGF,aAAa,CAACG,GAAI,EAAC;QACjDL,EAAE,EAAEE,aAAa,CAACG,GAAG;QACrBC,IAAI,EAAEJ,aAAa,CAACI;MACxB,CAAC,CAAC;IACN;EACJ;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/core",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.468",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"browserslist": [
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"publishConfig": {
|
|
73
73
|
"access": "public"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "decd1b4f580c2401d79d1a580689f5e36aa96fcb"
|
|
76
76
|
}
|