@chayns-components/core 5.0.0-beta.402 → 5.0.0-beta.403
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 +4 -0
- package/lib/components/accordion/Accordion.js +2 -0
- package/lib/components/accordion/Accordion.js.map +1 -1
- package/lib/components/accordion/accordion-head/AccordionHead.d.ts +1 -0
- package/lib/components/accordion/accordion-head/AccordionHead.js +2 -1
- package/lib/components/accordion/accordion-head/AccordionHead.js.map +1 -1
- package/lib/components/input/Input.d.ts +4 -0
- package/lib/components/input/Input.js +4 -1
- package/lib/components/input/Input.js.map +1 -1
- package/lib/components/input/Input.styles.d.ts +5 -0
- package/lib/components/input/Input.styles.js +44 -22
- package/lib/components/input/Input.styles.js.map +1 -1
- package/package.json +2 -2
|
@@ -80,6 +80,10 @@ export type AccordionProps = {
|
|
|
80
80
|
* This will hide the background color of the accordion
|
|
81
81
|
*/
|
|
82
82
|
shouldHideBackground?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Whether the icon should be rotating.
|
|
85
|
+
*/
|
|
86
|
+
shouldRotateIcon?: boolean;
|
|
83
87
|
/**
|
|
84
88
|
* Title of the Accordion displayed in the head
|
|
85
89
|
*/
|
|
@@ -37,6 +37,7 @@ const Accordion = _ref => {
|
|
|
37
37
|
searchPlaceholder,
|
|
38
38
|
shouldForceBackground = false,
|
|
39
39
|
shouldHideBackground = false,
|
|
40
|
+
shouldRotateIcon = true,
|
|
40
41
|
title,
|
|
41
42
|
titleElement,
|
|
42
43
|
shouldRenderClosed = false
|
|
@@ -134,6 +135,7 @@ const Accordion = _ref => {
|
|
|
134
135
|
rightElement: rightElement,
|
|
135
136
|
searchIcon: searchIcon,
|
|
136
137
|
searchPlaceholder: searchPlaceholder,
|
|
138
|
+
shouldRotateIcon: shouldRotateIcon,
|
|
137
139
|
title: title,
|
|
138
140
|
titleElement: titleElement
|
|
139
141
|
}), /*#__PURE__*/_react.default.createElement(_framerMotion.AnimatePresence, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.js","names":["_framerMotion","require","_react","_interopRequireWildcard","_uuid","_AccordionBody","_interopRequireDefault","_AccordionGroup","_AccordionHead","_Accordion","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","AccordionContext","exports","React","createContext","isWrapped","Accordion","_ref","bodyMaxHeight","children","icon","isDefaultOpen","isDisabled","isFixed","isOpened","isTitleGreyed","onBodyScroll","onClose","onOpen","onSearchChange","rightElement","searchIcon","searchPlaceholder","shouldForceBackground","shouldHideBackground","title","titleElement","shouldRenderClosed","openAccordionUuid","updateOpenAccordionUuid","useContext","AccordionGroupContext","isParentWrapped","isAccordionOpen","setIsAccordionOpen","useState","uuid","useUuid","isInitialRenderRef","useRef","isInGroup","isOpen","onCloseRef","onOpenRef","useEffect","current","handleHeadClick","useCallback","currentIsAccordionOpen","shouldOnlyOpen","accordionContextProviderValue","useMemo","createElement","StyledAccordion","className","Provider","value","MotionConfig","transition","type","onClick","AnimatePresence","initial","maxHeight","onScroll","shouldHideBody","displayName","_default"],"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 * 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 * 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 shouldForceBackground = false,\n shouldHideBackground = false,\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 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,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAYA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,cAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,eAAA,GAAAN,OAAA;AACA,IAAAO,cAAA,GAAAF,sBAAA,CAAAL,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AAAqD,SAAAK,uBAAAI,GAAA,WAAAA,GAAA,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f5B,OAAO,EAAEA,OAAQ;IACjBE,aAAa,EAAEA,aAAa,IAAIH,UAAW;IAC3CP,SAAS,EAAEA,SAAU;IACrBuD,OAAO,EAAEd,eAAgB;IACzB3B,cAAc,EAAEA,cAAe;IAC/BC,YAAY,EAAEA,YAAa;IAC3BC,UAAU,EAAEA,UAAW;IACvBC,iBAAiB,EAAEA,iBAAkB;IACrCG,KAAK,EAAEA,KAAM;IACbC,YAAY,EAAEA;EAAa,CAC9B,CAAC,eACFvD,MAAA,CAAAU,OAAA,CAAAuE,aAAA,CAACnF,aAAA,CAAA4F,eAAe;IAACC,OAAO,EAAE;EAAM,GAC3B,CAACrB,MAAM,IAAId,kBAAkB,kBAC1BxD,MAAA,CAAAU,OAAA,CAAAuE,aAAA,CAAC9E,cAAA,CAAAO,OAAa;IACVkF,SAAS,EAAEvD,aAAc;IACzBwD,QAAQ,EAAEhD,YAAa;IACvBiD,cAAc,EAAEtC,kBAAkB,IAAI,CAACc;EAAO,GAE7ChC,QACU,CAEN,CACP,CACS,CACd,CAAC;AAE1B,CAAC;AAEDH,SAAS,CAAC4D,WAAW,GAAG,WAAW;AAAC,IAAAC,QAAA,GAAAjE,OAAA,CAAArB,OAAA,GAErByB,SAAS"}
|
|
1
|
+
{"version":3,"file":"Accordion.js","names":["_framerMotion","require","_react","_interopRequireWildcard","_uuid","_AccordionBody","_interopRequireDefault","_AccordionGroup","_AccordionHead","_Accordion","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","AccordionContext","exports","React","createContext","isWrapped","Accordion","_ref","bodyMaxHeight","children","icon","isDefaultOpen","isDisabled","isFixed","isOpened","isTitleGreyed","onBodyScroll","onClose","onOpen","onSearchChange","rightElement","searchIcon","searchPlaceholder","shouldForceBackground","shouldHideBackground","shouldRotateIcon","title","titleElement","shouldRenderClosed","openAccordionUuid","updateOpenAccordionUuid","useContext","AccordionGroupContext","isParentWrapped","isAccordionOpen","setIsAccordionOpen","useState","uuid","useUuid","isInitialRenderRef","useRef","isInGroup","isOpen","onCloseRef","onOpenRef","useEffect","current","handleHeadClick","useCallback","currentIsAccordionOpen","shouldOnlyOpen","accordionContextProviderValue","useMemo","createElement","StyledAccordion","className","Provider","value","MotionConfig","transition","type","onClick","AnimatePresence","initial","maxHeight","onScroll","shouldHideBody","displayName","_default"],"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 * 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 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 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,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAYA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,cAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,eAAA,GAAAN,OAAA;AACA,IAAAO,cAAA,GAAAF,sBAAA,CAAAL,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AAAqD,SAAAK,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAX,wBAAAW,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAH,UAAA,SAAAG,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAF,OAAA,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F,aAAA,CAAA6F,eAAe;IAACC,OAAO,EAAE;EAAM,GAC3B,CAACrB,MAAM,IAAId,kBAAkB,kBAC1BzD,MAAA,CAAAU,OAAA,CAAAwE,aAAA,CAAC/E,cAAA,CAAAO,OAAa;IACVmF,SAAS,EAAExD,aAAc;IACzByD,QAAQ,EAAEjD,YAAa;IACvBkD,cAAc,EAAEtC,kBAAkB,IAAI,CAACc;EAAO,GAE7CjC,QACU,CAEN,CACP,CACS,CACd,CAAC;AAE1B,CAAC;AAEDH,SAAS,CAAC6D,WAAW,GAAG,WAAW;AAAC,IAAAC,QAAA,GAAAlE,OAAA,CAAArB,OAAA,GAErByB,SAAS"}
|
|
@@ -24,6 +24,7 @@ const AccordionHead = _ref => {
|
|
|
24
24
|
rightElement,
|
|
25
25
|
searchIcon,
|
|
26
26
|
searchPlaceholder,
|
|
27
|
+
shouldRotateIcon,
|
|
27
28
|
title,
|
|
28
29
|
titleElement
|
|
29
30
|
} = _ref;
|
|
@@ -48,7 +49,7 @@ const AccordionHead = _ref => {
|
|
|
48
49
|
initial: false
|
|
49
50
|
}, /*#__PURE__*/_react.default.createElement(_AccordionHead.StyledMotionIconWrapper, {
|
|
50
51
|
animate: {
|
|
51
|
-
rotate: isOpen || isFixed ? 90 : 0
|
|
52
|
+
rotate: (isOpen || isFixed) && shouldRotateIcon ? 90 : 0
|
|
52
53
|
},
|
|
53
54
|
initial: false,
|
|
54
55
|
onClick: !isFixed ? onClick : undefined
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccordionHead.js","names":["_framerMotion","require","_react","_interopRequireWildcard","_Icon","_interopRequireDefault","_utils","_AccordionHead","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","AccordionHead","_ref","icon","isOpen","isFixed","isTitleGreyed","isWrapped","onClick","onSearchChange","rightElement","searchIcon","searchPlaceholder","title","titleElement","headHeight","setHeadHeight","useState","closed","open","titleWrapperRef","useRef","hasSearchIcon","Array","isArray","useEffect","getAccordionHeadHeight","width","current","clientWidth","createElement","StyledMotionAccordionHead","animate","height","className","initial","StyledMotionIconWrapper","rotate","undefined","icons","StyledMotionContentWrapper","opacity","ref","LayoutGroup","StyledMotionTitleWrapper","AnimatePresence","StyledMotionTitle","scale","key","StyledMotionTitleElementWrapper","layout","StyledRightWrapper","Fragment","StyledMotionRightInput","autoComplete","exit","hasIcon","onChange","placeholder","type","StyledMotionRightInputIconWrapper","StyledMotionRightElementWrapper","displayName","_default","exports"],"sources":["../../../../src/components/accordion/accordion-head/AccordionHead.tsx"],"sourcesContent":["import { AnimatePresence, LayoutGroup } from 'framer-motion';\nimport React, {\n ChangeEventHandler,\n FC,\n MouseEventHandler,\n ReactNode,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport Icon from '../../icon/Icon';\nimport { getAccordionHeadHeight } from '../utils';\nimport {\n StyledMotionAccordionHead,\n StyledMotionContentWrapper,\n StyledMotionIconWrapper,\n StyledMotionRightElementWrapper,\n StyledMotionRightInput,\n StyledMotionRightInputIconWrapper,\n StyledMotionTitle,\n StyledMotionTitleElementWrapper,\n StyledMotionTitleWrapper,\n StyledRightWrapper,\n} from './AccordionHead.styles';\n\ntype AccordionHeadProps = {\n icon?: string;\n isOpen: boolean;\n isFixed: boolean;\n isTitleGreyed: boolean;\n isWrapped: boolean;\n onClick: MouseEventHandler<HTMLDivElement>;\n onSearchChange?: ChangeEventHandler<HTMLInputElement>;\n rightElement?: ReactNode;\n searchIcon?: string[];\n searchPlaceholder?: string;\n title: string;\n titleElement?: ReactNode;\n};\n\ninterface HeadHeight {\n closed: number;\n open: number;\n}\n\nconst AccordionHead: FC<AccordionHeadProps> = ({\n icon,\n isOpen,\n isFixed,\n isTitleGreyed,\n isWrapped,\n onClick,\n onSearchChange,\n rightElement,\n searchIcon,\n searchPlaceholder,\n title,\n titleElement,\n}) => {\n const [headHeight, setHeadHeight] = useState<HeadHeight>({\n closed: isWrapped ? 40 : 33,\n open: isWrapped ? 40 : 33,\n });\n\n const titleWrapperRef = useRef<HTMLDivElement>(null);\n\n const hasSearchIcon = Array.isArray(searchIcon);\n\n useEffect(() => {\n setHeadHeight(\n getAccordionHeadHeight({\n isWrapped,\n title,\n width: (titleWrapperRef.current?.clientWidth ?? 0) - 10,\n })\n );\n }, [isWrapped, title]);\n\n return (\n <StyledMotionAccordionHead\n animate={{ height: isOpen ? headHeight.open : headHeight.closed }}\n className=\"beta-chayns-accordion-head\"\n initial={false}\n >\n <StyledMotionIconWrapper\n animate={{ rotate: isOpen || isFixed ? 90 : 0 }}\n initial={false}\n onClick={!isFixed ? onClick : undefined}\n >\n <Icon icons={[isFixed ? 'fa fa-horizontal-rule' : icon ?? 'fa fa-chevron-right']} />\n </StyledMotionIconWrapper>\n <StyledMotionContentWrapper\n animate={{ opacity: isTitleGreyed ? 0.5 : 1 }}\n initial={false}\n onClick={!isFixed ? onClick : undefined}\n ref={titleWrapperRef}\n >\n <LayoutGroup>\n <StyledMotionTitleWrapper>\n <AnimatePresence initial={false}>\n <StyledMotionTitle\n animate={{ scale: 1 }}\n initial={{ scale: isOpen && !isWrapped ? 1 / 1.3 : 1.3 }}\n isOpen={isOpen}\n isWrapped={isWrapped}\n key={\n isOpen && !isWrapped\n ? 'accordionHeadTitleBig'\n : 'accordionHeadTitle'\n }\n >\n {title}\n </StyledMotionTitle>\n </AnimatePresence>\n </StyledMotionTitleWrapper>\n {titleElement && (\n <StyledMotionTitleElementWrapper layout>\n {titleElement}\n </StyledMotionTitleElementWrapper>\n )}\n </LayoutGroup>\n </StyledMotionContentWrapper>\n {(typeof onSearchChange === 'function' || rightElement) && (\n <StyledRightWrapper>\n <AnimatePresence initial={false}>\n {typeof onSearchChange === 'function' && isOpen ? (\n <>\n <StyledMotionRightInput\n animate={{ opacity: 1, width: '165px' }}\n autoComplete=\"off\"\n exit={{ opacity: 0, width: 0 }}\n hasIcon={hasSearchIcon}\n initial={{ opacity: 0, width: 0 }}\n key=\"rightInput\"\n onChange={onSearchChange}\n placeholder={searchPlaceholder}\n type=\"text\"\n />\n {hasSearchIcon && (\n <StyledMotionRightInputIconWrapper\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n initial={{ opacity: 0 }}\n key=\"rightInputIcon\"\n >\n <Icon icons={searchIcon} />\n </StyledMotionRightInputIconWrapper>\n )}\n </>\n ) : (\n <StyledMotionRightElementWrapper\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n initial={{ opacity: 0 }}\n key=\"rightElementWrapper\"\n >\n {rightElement}\n </StyledMotionRightElementWrapper>\n )}\n </AnimatePresence>\n </StyledRightWrapper>\n )}\n </StyledMotionAccordionHead>\n );\n};\n\nAccordionHead.displayName = 'AccordionHead';\n\nexport default AccordionHead;\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AASA,IAAAG,KAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,cAAA,GAAAN,OAAA;AAWgC,SAAAI,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAH,UAAA,SAAAG,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAF,OAAA,EAAAE,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,C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C,KAAK;IAClBC,IAAI,EAAE;MAAEd,OAAO,EAAE,CAAC;MAAEd,KAAK,EAAE;IAAE,CAAE;IAC/B6B,OAAO,EAAElC,aAAc;IACvBa,OAAO,EAAE;MAAEM,OAAO,EAAE,CAAC;MAAEd,KAAK,EAAE;IAAE,CAAE;IAClCqB,GAAG,EAAC,YAAY;IAChBS,QAAQ,EAAEhD,cAAe;IACzBiD,WAAW,EAAE9C,iBAAkB;IAC/B+C,IAAI,EAAC;EAAM,CACd,CAAC,EACDrC,aAAa,iBACVjD,MAAA,CAAAQ,OAAA,CAAAiD,aAAA,CAACpD,cAAA,CAAAkF,iCAAiC;IAC9B5B,OAAO,EAAE;MAAES,OAAO,EAAE;IAAE,CAAE;IACxBc,IAAI,EAAE;MAAEd,OAAO,EAAE;IAAE,CAAE;IACrBN,OAAO,EAAE;MAAEM,OAAO,EAAE;IAAE,CAAE;IACxBO,GAAG,EAAC;EAAgB,gBAEpB3E,MAAA,CAAAQ,OAAA,CAAAiD,aAAA,CAACvD,KAAA,CAAAM,OAAI;IAAC0D,KAAK,EAAE5B;EAAW,CAAE,CACK,CAEzC,CAAC,gBAEHtC,MAAA,CAAAQ,OAAA,CAAAiD,aAAA,CAACpD,cAAA,CAAAmF,+BAA+B;IAC5B7B,OAAO,EAAE;MAAES,OAAO,EAAE;IAAE,CAAE;IACxBc,IAAI,EAAE;MAAEd,OAAO,EAAE;IAAE,CAAE;IACrBN,OAAO,EAAE;MAAEM,OAAO,EAAE;IAAE,CAAE;IACxBO,GAAG,EAAC;EAAqB,GAExBtC,YAC4B,CAExB,CACD,CAED,CAAC;AAEpC,CAAC;AAEDT,aAAa,CAAC6D,WAAW,GAAG,eAAe;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAnF,OAAA,GAE7BoB,aAAa"}
|
|
1
|
+
{"version":3,"file":"AccordionHead.js","names":["_framerMotion","require","_react","_interopRequireWildcard","_Icon","_interopRequireDefault","_utils","_AccordionHead","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","AccordionHead","_ref","icon","isOpen","isFixed","isTitleGreyed","isWrapped","onClick","onSearchChange","rightElement","searchIcon","searchPlaceholder","shouldRotateIcon","title","titleElement","headHeight","setHeadHeight","useState","closed","open","titleWrapperRef","useRef","hasSearchIcon","Array","isArray","useEffect","getAccordionHeadHeight","width","current","clientWidth","createElement","StyledMotionAccordionHead","animate","height","className","initial","StyledMotionIconWrapper","rotate","undefined","icons","StyledMotionContentWrapper","opacity","ref","LayoutGroup","StyledMotionTitleWrapper","AnimatePresence","StyledMotionTitle","scale","key","StyledMotionTitleElementWrapper","layout","StyledRightWrapper","Fragment","StyledMotionRightInput","autoComplete","exit","hasIcon","onChange","placeholder","type","StyledMotionRightInputIconWrapper","StyledMotionRightElementWrapper","displayName","_default","exports"],"sources":["../../../../src/components/accordion/accordion-head/AccordionHead.tsx"],"sourcesContent":["import { AnimatePresence, LayoutGroup } from 'framer-motion';\nimport React, {\n ChangeEventHandler,\n FC,\n MouseEventHandler,\n ReactNode,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport Icon from '../../icon/Icon';\nimport { getAccordionHeadHeight } from '../utils';\nimport {\n StyledMotionAccordionHead,\n StyledMotionContentWrapper,\n StyledMotionIconWrapper,\n StyledMotionRightElementWrapper,\n StyledMotionRightInput,\n StyledMotionRightInputIconWrapper,\n StyledMotionTitle,\n StyledMotionTitleElementWrapper,\n StyledMotionTitleWrapper,\n StyledRightWrapper,\n} from './AccordionHead.styles';\n\ntype AccordionHeadProps = {\n icon?: string;\n isOpen: boolean;\n isFixed: boolean;\n isTitleGreyed: boolean;\n isWrapped: boolean;\n onClick: MouseEventHandler<HTMLDivElement>;\n onSearchChange?: ChangeEventHandler<HTMLInputElement>;\n rightElement?: ReactNode;\n searchIcon?: string[];\n searchPlaceholder?: string;\n shouldRotateIcon?: boolean;\n title: string;\n titleElement?: ReactNode;\n};\n\ninterface HeadHeight {\n closed: number;\n open: number;\n}\n\nconst AccordionHead: FC<AccordionHeadProps> = ({\n icon,\n isOpen,\n isFixed,\n isTitleGreyed,\n isWrapped,\n onClick,\n onSearchChange,\n rightElement,\n searchIcon,\n searchPlaceholder,\n shouldRotateIcon,\n title,\n titleElement,\n}) => {\n const [headHeight, setHeadHeight] = useState<HeadHeight>({\n closed: isWrapped ? 40 : 33,\n open: isWrapped ? 40 : 33,\n });\n\n const titleWrapperRef = useRef<HTMLDivElement>(null);\n\n const hasSearchIcon = Array.isArray(searchIcon);\n\n useEffect(() => {\n setHeadHeight(\n getAccordionHeadHeight({\n isWrapped,\n title,\n width: (titleWrapperRef.current?.clientWidth ?? 0) - 10,\n })\n );\n }, [isWrapped, title]);\n\n return (\n <StyledMotionAccordionHead\n animate={{ height: isOpen ? headHeight.open : headHeight.closed }}\n className=\"beta-chayns-accordion-head\"\n initial={false}\n >\n <StyledMotionIconWrapper\n animate={{ rotate: (isOpen || isFixed) && shouldRotateIcon ? 90 : 0 }}\n initial={false}\n onClick={!isFixed ? onClick : undefined}\n >\n <Icon icons={[isFixed ? 'fa fa-horizontal-rule' : icon ?? 'fa fa-chevron-right']} />\n </StyledMotionIconWrapper>\n <StyledMotionContentWrapper\n animate={{ opacity: isTitleGreyed ? 0.5 : 1 }}\n initial={false}\n onClick={!isFixed ? onClick : undefined}\n ref={titleWrapperRef}\n >\n <LayoutGroup>\n <StyledMotionTitleWrapper>\n <AnimatePresence initial={false}>\n <StyledMotionTitle\n animate={{ scale: 1 }}\n initial={{ scale: isOpen && !isWrapped ? 1 / 1.3 : 1.3 }}\n isOpen={isOpen}\n isWrapped={isWrapped}\n key={\n isOpen && !isWrapped\n ? 'accordionHeadTitleBig'\n : 'accordionHeadTitle'\n }\n >\n {title}\n </StyledMotionTitle>\n </AnimatePresence>\n </StyledMotionTitleWrapper>\n {titleElement && (\n <StyledMotionTitleElementWrapper layout>\n {titleElement}\n </StyledMotionTitleElementWrapper>\n )}\n </LayoutGroup>\n </StyledMotionContentWrapper>\n {(typeof onSearchChange === 'function' || rightElement) && (\n <StyledRightWrapper>\n <AnimatePresence initial={false}>\n {typeof onSearchChange === 'function' && isOpen ? (\n <>\n <StyledMotionRightInput\n animate={{ opacity: 1, width: '165px' }}\n autoComplete=\"off\"\n exit={{ opacity: 0, width: 0 }}\n hasIcon={hasSearchIcon}\n initial={{ opacity: 0, width: 0 }}\n key=\"rightInput\"\n onChange={onSearchChange}\n placeholder={searchPlaceholder}\n type=\"text\"\n />\n {hasSearchIcon && (\n <StyledMotionRightInputIconWrapper\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n initial={{ opacity: 0 }}\n key=\"rightInputIcon\"\n >\n <Icon icons={searchIcon} />\n </StyledMotionRightInputIconWrapper>\n )}\n </>\n ) : (\n <StyledMotionRightElementWrapper\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n initial={{ opacity: 0 }}\n key=\"rightElementWrapper\"\n >\n {rightElement}\n </StyledMotionRightElementWrapper>\n )}\n </AnimatePresence>\n </StyledRightWrapper>\n )}\n </StyledMotionAccordionHead>\n );\n};\n\nAccordionHead.displayName = 'AccordionHead';\n\nexport default AccordionHead;\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AASA,IAAAG,KAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,cAAA,GAAAN,OAAA;AAWgC,SAAAI,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAA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AC;EAAqB,GAExBvC,YAC4B,CAExB,CACD,CAED,CAAC;AAEpC,CAAC;AAEDT,aAAa,CAAC8D,WAAW,GAAG,eAAe;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAApF,OAAA,GAE7BoB,aAAa"}
|
|
@@ -40,6 +40,10 @@ export type InputProps = {
|
|
|
40
40
|
* Element to be displayed next to or instead of the "placeholder"
|
|
41
41
|
*/
|
|
42
42
|
placeholderElement?: ReactNode;
|
|
43
|
+
/**
|
|
44
|
+
* An element that should be displayed on the right side of the Input.
|
|
45
|
+
*/
|
|
46
|
+
rightElement?: ReactNode;
|
|
43
47
|
/**
|
|
44
48
|
* If true, a clear icon is displayed at the end of the input field
|
|
45
49
|
*/
|
|
@@ -22,6 +22,7 @@ const Input = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
22
22
|
onKeyDown,
|
|
23
23
|
placeholder,
|
|
24
24
|
placeholderElement,
|
|
25
|
+
rightElement,
|
|
25
26
|
shouldShowClearIcon = false,
|
|
26
27
|
type = 'text',
|
|
27
28
|
value,
|
|
@@ -72,6 +73,8 @@ const Input = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
72
73
|
className: "beta-chayns-input",
|
|
73
74
|
isDisabled: isDisabled,
|
|
74
75
|
isInvalid: isInvalid
|
|
76
|
+
}, /*#__PURE__*/_react.default.createElement(_Input.StyledInputContentWrapper, {
|
|
77
|
+
shouldRoundRightCorners: !rightElement
|
|
75
78
|
}, iconElement && /*#__PURE__*/_react.default.createElement(_Input.StyledInputIconWrapper, null, iconElement), /*#__PURE__*/_react.default.createElement(_Input.StyledInputContent, null, /*#__PURE__*/_react.default.createElement(_Input.StyledInputField, {
|
|
76
79
|
disabled: isDisabled,
|
|
77
80
|
onBlur: onBlur,
|
|
@@ -111,7 +114,7 @@ const Input = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
111
114
|
}, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
112
115
|
icons: ['fa fa-times'],
|
|
113
116
|
color: isInvalid ? theme.wrong : undefined
|
|
114
|
-
})));
|
|
117
|
+
}))), rightElement && /*#__PURE__*/_react.default.createElement(_Input.StyledInputRightElement, null, rightElement));
|
|
115
118
|
});
|
|
116
119
|
Input.displayName = 'Input';
|
|
117
120
|
var _default = exports.default = Input;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","names":["_react","_interopRequireWildcard","require","_styledComponents","_Icon","_interopRequireDefault","_Input","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","Input","forwardRef","_ref","ref","iconElement","inputMode","isDisabled","onBlur","onChange","onFocus","onKeyDown","placeholder","placeholderElement","shouldShowClearIcon","type","value","shouldUseAutoFocus","isInvalid","hasValue","setHasValue","useState","theme","useTheme","inputRef","useRef","handleClearIconClick","useCallback","current","target","handleInputFieldChange","event","useImperativeHandle","focus","useEffect","labelPosition","useMemo","bottom","right","left","top","createElement","StyledInput","className","StyledInputIconWrapper","StyledInputContent","StyledInputField","disabled","autoFocus","StyledMotionInputLabel","animate","fontSize","initial","layout","style","transition","duration","StyledMotionInputClearIcon","opacity","onClick","icons","color","wrong","undefined","displayName","_default","exports"],"sources":["../../../src/components/input/Input.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n ChangeEventHandler,\n FocusEventHandler,\n forwardRef,\n HTMLInputTypeAttribute,\n KeyboardEventHandler,\n ReactNode,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useTheme } from 'styled-components';\nimport type { Theme } from '../color-scheme-provider/ColorSchemeProvider';\nimport Icon from '../icon/Icon';\nimport {\n StyledInput,\n StyledInputContent,\n StyledInputField,\n StyledInputIconWrapper,\n StyledMotionInputClearIcon,\n StyledMotionInputLabel,\n} from './Input.styles';\n\nexport type InputRef = {\n focus: VoidFunction;\n};\n\ntype InputMode =\n | 'email'\n | 'search'\n | 'tel'\n | 'text'\n | 'url'\n | 'none'\n | 'numeric'\n | 'decimal'\n | undefined;\n\nexport type InputProps = {\n /**\n * Icon element to be displayed on the left side of the input field\n */\n iconElement?: ReactNode;\n /**\n * Defines the input mode of the input\n */\n inputMode?: InputMode;\n /**\n * Disables the input so that it cannot be changed anymore\n */\n isDisabled?: boolean;\n /**\n * Function that is executed when the input field loses focus\n */\n onBlur?: FocusEventHandler<HTMLInputElement>;\n /**\n * Function that is executed when the text of the input changes\n */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Function that is executed when the input field is focused\n */\n onFocus?: FocusEventHandler<HTMLInputElement>;\n /**\n * Function that is executed when a letter is pressed\n */\n onKeyDown?: KeyboardEventHandler<HTMLInputElement>;\n /**\n * Placeholder for the input field\n */\n placeholder?: string;\n /**\n * Element to be displayed next to or instead of the \"placeholder\"\n */\n placeholderElement?: ReactNode;\n /**\n * If true, a clear icon is displayed at the end of the input field\n */\n shouldShowClearIcon?: boolean;\n /**\n * Input type set for input element (e.g. 'text', 'number' or 'password')\n */\n type?: HTMLInputTypeAttribute;\n /**\n * Value if the input field should be controlled\n */\n value?: string;\n /**\n * If true, the input field is focused when the component is mounted\n */\n shouldUseAutoFocus?: boolean;\n /**\n * If true, the input field is marked as invalid\n */\n isInvalid?: boolean;\n};\n\nconst Input = forwardRef<InputRef, InputProps>(\n (\n {\n iconElement,\n inputMode,\n isDisabled,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n placeholder,\n placeholderElement,\n shouldShowClearIcon = false,\n type = 'text',\n value,\n shouldUseAutoFocus = false,\n isInvalid = false,\n },\n ref,\n ) => {\n const [hasValue, setHasValue] = useState(typeof value === 'string' && value !== '');\n const theme = useTheme() as Theme;\n const inputRef = useRef<HTMLInputElement>(null);\n\n const handleClearIconClick = useCallback(() => {\n if (inputRef.current) {\n inputRef.current.value = '';\n\n setHasValue(false);\n\n if (typeof onChange === 'function') {\n onChange({ target: inputRef.current } as ChangeEvent<HTMLInputElement>);\n }\n }\n }, [onChange]);\n\n const handleInputFieldChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n setHasValue(event.target.value !== '');\n\n if (typeof onChange === 'function') {\n onChange(event);\n }\n },\n [onChange],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n focus: () => inputRef.current?.focus(),\n }),\n [],\n );\n\n useEffect(() => {\n if (typeof value === 'string') {\n setHasValue(value !== '');\n }\n }, [value]);\n\n const labelPosition = useMemo(() => {\n if (hasValue) {\n return { bottom: -8, right: -6 };\n }\n\n return { left: 0, top: 0 };\n }, [hasValue]);\n\n return (\n <StyledInput\n className=\"beta-chayns-input\"\n isDisabled={isDisabled}\n isInvalid={isInvalid}\n >\n {iconElement && <StyledInputIconWrapper>{iconElement}</StyledInputIconWrapper>}\n <StyledInputContent>\n <StyledInputField\n disabled={isDisabled}\n onBlur={onBlur}\n onChange={handleInputFieldChange}\n onFocus={onFocus}\n onKeyDown={onKeyDown}\n ref={inputRef}\n type={type}\n value={value}\n autoFocus={shouldUseAutoFocus}\n inputMode={inputMode}\n isInvalid={isInvalid}\n />\n <StyledMotionInputLabel\n animate={{\n fontSize: hasValue ? '10px' : '16px',\n }}\n initial={false}\n layout\n style={{ ...labelPosition }}\n transition={{ type: 'tween', duration: 0.3 }}\n isInvalid={isInvalid}\n >\n {placeholderElement}\n {placeholder}\n </StyledMotionInputLabel>\n </StyledInputContent>\n {shouldShowClearIcon && (\n <StyledMotionInputClearIcon\n animate={{ opacity: hasValue ? 1 : 0 }}\n initial={false}\n onClick={handleClearIconClick}\n transition={{ type: 'tween' }}\n isInvalid={isInvalid}\n >\n <Icon icons={['fa fa-times']} color={isInvalid ? theme.wrong : undefined} />\n </StyledMotionInputClearIcon>\n )}\n </StyledInput>\n );\n },\n);\n\nInput.displayName = 'Input';\n\nexport default Input;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAA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","require","_styledComponents","_Icon","_interopRequireDefault","_Input","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","Input","forwardRef","_ref","ref","iconElement","inputMode","isDisabled","onBlur","onChange","onFocus","onKeyDown","placeholder","placeholderElement","rightElement","shouldShowClearIcon","type","value","shouldUseAutoFocus","isInvalid","hasValue","setHasValue","useState","theme","useTheme","inputRef","useRef","handleClearIconClick","useCallback","current","target","handleInputFieldChange","event","useImperativeHandle","focus","useEffect","labelPosition","useMemo","bottom","right","left","top","createElement","StyledInput","className","StyledInputContentWrapper","shouldRoundRightCorners","StyledInputIconWrapper","StyledInputContent","StyledInputField","disabled","autoFocus","StyledMotionInputLabel","animate","fontSize","initial","layout","style","transition","duration","StyledMotionInputClearIcon","opacity","onClick","icons","color","wrong","undefined","StyledInputRightElement","displayName","_default","exports"],"sources":["../../../src/components/input/Input.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n ChangeEventHandler,\n FocusEventHandler,\n forwardRef,\n HTMLInputTypeAttribute,\n KeyboardEventHandler,\n ReactNode,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useTheme } from 'styled-components';\nimport type { Theme } from '../color-scheme-provider/ColorSchemeProvider';\nimport Icon from '../icon/Icon';\nimport {\n StyledInput,\n StyledInputContent,\n StyledInputContentWrapper,\n StyledInputField,\n StyledInputIconWrapper,\n StyledInputRightElement,\n StyledMotionInputClearIcon,\n StyledMotionInputLabel,\n} from './Input.styles';\n\nexport type InputRef = {\n focus: VoidFunction;\n};\n\ntype InputMode =\n | 'email'\n | 'search'\n | 'tel'\n | 'text'\n | 'url'\n | 'none'\n | 'numeric'\n | 'decimal'\n | undefined;\n\nexport type InputProps = {\n /**\n * Icon element to be displayed on the left side of the input field\n */\n iconElement?: ReactNode;\n /**\n * Defines the input mode of the input\n */\n inputMode?: InputMode;\n /**\n * Disables the input so that it cannot be changed anymore\n */\n isDisabled?: boolean;\n /**\n * Function that is executed when the input field loses focus\n */\n onBlur?: FocusEventHandler<HTMLInputElement>;\n /**\n * Function that is executed when the text of the input changes\n */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Function that is executed when the input field is focused\n */\n onFocus?: FocusEventHandler<HTMLInputElement>;\n /**\n * Function that is executed when a letter is pressed\n */\n onKeyDown?: KeyboardEventHandler<HTMLInputElement>;\n /**\n * Placeholder for the input field\n */\n placeholder?: string;\n /**\n * Element to be displayed next to or instead of the \"placeholder\"\n */\n placeholderElement?: ReactNode;\n /**\n * An element that should be displayed on the right side of the Input.\n */\n rightElement?: ReactNode;\n /**\n * If true, a clear icon is displayed at the end of the input field\n */\n shouldShowClearIcon?: boolean;\n /**\n * Input type set for input element (e.g. 'text', 'number' or 'password')\n */\n type?: HTMLInputTypeAttribute;\n /**\n * Value if the input field should be controlled\n */\n value?: string;\n /**\n * If true, the input field is focused when the component is mounted\n */\n shouldUseAutoFocus?: boolean;\n /**\n * If true, the input field is marked as invalid\n */\n isInvalid?: boolean;\n};\n\nconst Input = forwardRef<InputRef, InputProps>(\n (\n {\n iconElement,\n inputMode,\n isDisabled,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n placeholder,\n placeholderElement,\n rightElement,\n shouldShowClearIcon = false,\n type = 'text',\n value,\n shouldUseAutoFocus = false,\n isInvalid = false,\n },\n ref\n ) => {\n const [hasValue, setHasValue] = useState(typeof value === 'string' && value !== '');\n const theme = useTheme() as Theme;\n const inputRef = useRef<HTMLInputElement>(null);\n\n const handleClearIconClick = useCallback(() => {\n if (inputRef.current) {\n inputRef.current.value = '';\n\n setHasValue(false);\n\n if (typeof onChange === 'function') {\n onChange({ target: inputRef.current } as ChangeEvent<HTMLInputElement>);\n }\n }\n }, [onChange]);\n\n const handleInputFieldChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n setHasValue(event.target.value !== '');\n\n if (typeof onChange === 'function') {\n onChange(event);\n }\n },\n [onChange]\n );\n\n useImperativeHandle(\n ref,\n () => ({\n focus: () => inputRef.current?.focus(),\n }),\n []\n );\n\n useEffect(() => {\n if (typeof value === 'string') {\n setHasValue(value !== '');\n }\n }, [value]);\n\n const labelPosition = useMemo(() => {\n if (hasValue) {\n return { bottom: -8, right: -6 };\n }\n\n return { left: 0, top: 0 };\n }, [hasValue]);\n\n return (\n <StyledInput\n className=\"beta-chayns-input\"\n isDisabled={isDisabled}\n isInvalid={isInvalid}\n >\n <StyledInputContentWrapper shouldRoundRightCorners={!rightElement}>\n {iconElement && <StyledInputIconWrapper>{iconElement}</StyledInputIconWrapper>}\n <StyledInputContent>\n <StyledInputField\n disabled={isDisabled}\n onBlur={onBlur}\n onChange={handleInputFieldChange}\n onFocus={onFocus}\n onKeyDown={onKeyDown}\n ref={inputRef}\n type={type}\n value={value}\n autoFocus={shouldUseAutoFocus}\n inputMode={inputMode}\n isInvalid={isInvalid}\n />\n <StyledMotionInputLabel\n animate={{\n fontSize: hasValue ? '10px' : '16px',\n }}\n initial={false}\n layout\n style={{ ...labelPosition }}\n transition={{ type: 'tween', duration: 0.3 }}\n isInvalid={isInvalid}\n >\n {placeholderElement}\n {placeholder}\n </StyledMotionInputLabel>\n </StyledInputContent>\n {shouldShowClearIcon && (\n <StyledMotionInputClearIcon\n animate={{ opacity: hasValue ? 1 : 0 }}\n initial={false}\n onClick={handleClearIconClick}\n transition={{ type: 'tween' }}\n isInvalid={isInvalid}\n >\n <Icon\n icons={['fa fa-times']}\n color={isInvalid ? theme.wrong : undefined}\n />\n </StyledMotionInputClearIcon>\n )}\n </StyledInputContentWrapper>\n {rightElement && <StyledInputRightElement>{rightElement}</StyledInputRightElement>}\n </StyledInput>\n );\n }\n);\n\nInput.displayName = 'Input';\n\nexport default Input;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAeA,IAAAC,iBAAA,GAAAD,OAAA;AAEA,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C,CACxE,CAAC;AAEtB,CACJ,CAAC;AAEDb,KAAK,CAACmE,WAAW,GAAG,OAAO;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAzF,OAAA,GAEboB,KAAK"}
|
|
@@ -4,6 +4,10 @@ import type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';
|
|
|
4
4
|
import type { InputProps } from './Input';
|
|
5
5
|
type StyledInputProps = WithTheme<Pick<InputProps, 'isDisabled' | 'isInvalid'>>;
|
|
6
6
|
export declare const StyledInput: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledInputProps>>;
|
|
7
|
+
type StyledInputContentWrapperProps = WithTheme<{
|
|
8
|
+
shouldRoundRightCorners: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const StyledInputContentWrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledInputContentWrapperProps>>;
|
|
7
11
|
export declare const StyledInputContent: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
|
|
8
12
|
type StyledInputFieldProps = WithTheme<Pick<InputProps, 'isInvalid'>>;
|
|
9
13
|
export declare const StyledInputField: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, StyledInputFieldProps>>;
|
|
@@ -538,4 +542,5 @@ export declare const StyledMotionInputClearIcon: import("styled-components").ISt
|
|
|
538
542
|
onTransitionEndCapture?: import("react").TransitionEventHandler<HTMLDivElement> | undefined;
|
|
539
543
|
} & import("framer-motion").MotionProps & import("react").RefAttributes<HTMLDivElement>, StyledMotionInputClearIconProps>> & Omit<import("framer-motion").ForwardRefComponent<HTMLDivElement, import("framer-motion").HTMLMotionProps<"div">>, keyof import("react").Component<any, {}, any>>;
|
|
540
544
|
export declare const StyledInputIconWrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
|
|
545
|
+
export declare const StyledInputRightElement: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
|
|
541
546
|
export {};
|
|
@@ -3,43 +3,59 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.StyledMotionInputLabel = exports.StyledMotionInputClearIcon = exports.StyledInputIconWrapper = exports.StyledInputField = exports.StyledInputContent = exports.StyledInput = void 0;
|
|
6
|
+
exports.StyledMotionInputLabel = exports.StyledMotionInputClearIcon = exports.StyledInputRightElement = exports.StyledInputIconWrapper = exports.StyledInputField = exports.StyledInputContentWrapper = exports.StyledInputContent = exports.StyledInput = void 0;
|
|
7
7
|
var _framerMotion = require("framer-motion");
|
|
8
|
-
var _styledComponents =
|
|
9
|
-
function
|
|
8
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
11
|
const StyledInput = exports.StyledInput = _styledComponents.default.div`
|
|
12
|
+
opacity: ${_ref => {
|
|
13
|
+
let {
|
|
14
|
+
isDisabled
|
|
15
|
+
} = _ref;
|
|
16
|
+
return isDisabled ? 0.5 : 1;
|
|
17
|
+
}};
|
|
18
|
+
display: flex;
|
|
19
|
+
`;
|
|
20
|
+
const StyledInputContentWrapper = exports.StyledInputContentWrapper = _styledComponents.default.div`
|
|
11
21
|
align-items: center;
|
|
12
|
-
background-color: ${
|
|
22
|
+
background-color: ${_ref2 => {
|
|
13
23
|
let {
|
|
14
24
|
theme
|
|
15
|
-
} =
|
|
25
|
+
} = _ref2;
|
|
16
26
|
return theme['100'];
|
|
17
27
|
}};
|
|
18
|
-
border: 1px solid
|
|
28
|
+
border: 1px solid
|
|
29
|
+
${_ref3 => {
|
|
19
30
|
let {
|
|
20
31
|
theme,
|
|
21
32
|
isInvalid
|
|
22
|
-
} =
|
|
33
|
+
} = _ref3;
|
|
23
34
|
return isInvalid ? theme.wrong : 'rgba(160, 160, 160, 0.3)';
|
|
24
35
|
}};
|
|
25
|
-
|
|
26
|
-
color: ${_ref3 => {
|
|
36
|
+
color: ${_ref4 => {
|
|
27
37
|
let {
|
|
28
38
|
theme
|
|
29
|
-
} =
|
|
39
|
+
} = _ref4;
|
|
30
40
|
return theme['006'];
|
|
31
41
|
}};
|
|
32
42
|
display: flex;
|
|
33
43
|
justify-content: space-between;
|
|
34
44
|
min-height: 42px;
|
|
35
|
-
opacity: ${_ref4 => {
|
|
36
|
-
let {
|
|
37
|
-
isDisabled
|
|
38
|
-
} = _ref4;
|
|
39
|
-
return isDisabled ? 0.5 : 1;
|
|
40
|
-
}};
|
|
41
|
-
transition: opacity 0.3s ease;
|
|
42
45
|
width: 100%;
|
|
46
|
+
transition: opacity 0.3s ease;
|
|
47
|
+
border-bottom-left-radius: 3px;
|
|
48
|
+
border-top-left-radius: 3px;
|
|
49
|
+
|
|
50
|
+
${_ref5 => {
|
|
51
|
+
let {
|
|
52
|
+
shouldRoundRightCorners
|
|
53
|
+
} = _ref5;
|
|
54
|
+
return shouldRoundRightCorners && (0, _styledComponents.css)`
|
|
55
|
+
border-bottom-right-radius: 3px;
|
|
56
|
+
border-top-right-radius: 3px;
|
|
57
|
+
`;
|
|
58
|
+
}}}
|
|
43
59
|
`;
|
|
44
60
|
const StyledInputContent = exports.StyledInputContent = _styledComponents.default.div`
|
|
45
61
|
display: flex;
|
|
@@ -51,11 +67,11 @@ const StyledInputContent = exports.StyledInputContent = _styledComponents.defaul
|
|
|
51
67
|
const StyledInputField = exports.StyledInputField = _styledComponents.default.input`
|
|
52
68
|
background: none;
|
|
53
69
|
border: none;
|
|
54
|
-
color: ${
|
|
70
|
+
color: ${_ref6 => {
|
|
55
71
|
let {
|
|
56
72
|
theme,
|
|
57
73
|
isInvalid
|
|
58
|
-
} =
|
|
74
|
+
} = _ref6;
|
|
59
75
|
return isInvalid ? theme.wrong : theme.text;
|
|
60
76
|
}};
|
|
61
77
|
padding: 0;
|
|
@@ -70,13 +86,13 @@ const StyledMotionInputLabel = exports.StyledMotionInputLabel = (0, _styledCompo
|
|
|
70
86
|
pointer-events: none;
|
|
71
87
|
position: absolute;
|
|
72
88
|
user-select: none;
|
|
73
|
-
color: ${
|
|
89
|
+
color: ${_ref7 => {
|
|
74
90
|
let {
|
|
75
91
|
theme,
|
|
76
92
|
isInvalid
|
|
77
|
-
} =
|
|
93
|
+
} = _ref7;
|
|
78
94
|
return isInvalid ? theme.wrong : undefined;
|
|
79
|
-
}}
|
|
95
|
+
}};
|
|
80
96
|
`;
|
|
81
97
|
const StyledMotionInputClearIcon = exports.StyledMotionInputClearIcon = (0, _styledComponents.default)(_framerMotion.motion.div)`
|
|
82
98
|
align-items: center;
|
|
@@ -95,4 +111,10 @@ const StyledInputIconWrapper = exports.StyledInputIconWrapper = _styledComponent
|
|
|
95
111
|
justify-content: center;
|
|
96
112
|
margin-left: 10px;
|
|
97
113
|
`;
|
|
114
|
+
const StyledInputRightElement = exports.StyledInputRightElement = _styledComponents.default.div`
|
|
115
|
+
border-bottom-right-radius: 3px;
|
|
116
|
+
border-top-right-radius: 3px;
|
|
117
|
+
overflow: hidden;
|
|
118
|
+
flex: 0 0 auto;
|
|
119
|
+
`;
|
|
98
120
|
//# sourceMappingURL=Input.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.styles.js","names":["_framerMotion","require","_styledComponents","
|
|
1
|
+
{"version":3,"file":"Input.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","StyledInput","exports","styled","div","_ref","isDisabled","StyledInputContentWrapper","_ref2","theme","_ref3","isInvalid","wrong","_ref4","_ref5","shouldRoundRightCorners","css","StyledInputContent","StyledInputField","input","_ref6","text","StyledMotionInputLabel","motion","label","_ref7","undefined","StyledMotionInputClearIcon","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';\nimport type { InputProps } from './Input';\n\ntype StyledInputProps = WithTheme<Pick<InputProps, 'isDisabled' | 'isInvalid'>>;\n\nexport const StyledInput = styled.div<StyledInputProps>`\n opacity: ${({ isDisabled }) => (isDisabled ? 0.5 : 1)};\n display: flex;\n`;\n\ntype StyledInputContentWrapperProps = WithTheme<{ shouldRoundRightCorners: boolean }>;\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 border-bottom-left-radius: 3px;\n border-top-left-radius: 3px;\n \n ${({ shouldRoundRightCorners }) =>\n shouldRoundRightCorners &&\n css`\n border-bottom-right-radius: 3px;\n border-top-right-radius: 3px;\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<Pick<InputProps, 'isInvalid'>>;\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 StyledMotionInputLabelProps = WithTheme<Pick<InputProps, 'isInvalid'>>;\n\nexport const StyledMotionInputLabel = styled(motion.label)<StyledMotionInputLabelProps>`\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 color: ${({ theme, isInvalid }: StyledMotionInputLabelProps) =>\n isInvalid ? theme.wrong : undefined};\n`;\n\ntype StyledMotionInputClearIconProps = WithTheme<Pick<InputProps, 'isInvalid'>>;\n\nexport const StyledMotionInputClearIcon = styled(motion.div)<StyledMotionInputClearIconProps>`\n align-items: center;\n border-left: 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,IAAAA,aAAA,G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AAAoB,sBAAA,GAAG,IAAAnB,yBAAM,EAACoB,oBAAM,CAACC,KAAK,CAA+B;AACxF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAaC,KAAA;EAAA,IAAC;IAAEhB,KAAK;IAAEE;EAAuC,CAAC,GAAAc,KAAA;EAAA,OACvDd,SAAS,GAAGF,KAAK,CAACG,KAAK,GAAGc,SAAS;AAAA,CAAC;AAC5C,CAAC;AAIM,MAAMC,0BAA0B,GAAAzB,OAAA,CAAAyB,0BAAA,GAAG,IAAAxB,yBAAM,EAACoB,oBAAM,CAACnB,GAAG,CAAmC;AAC9F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMwB,sBAAsB,GAAA1B,OAAA,CAAA0B,sBAAA,GAAGzB,yBAAM,CAACC,GAAI;AACjD;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMyB,uBAAuB,GAAA3B,OAAA,CAAA2B,uBAAA,GAAG1B,yBAAM,CAACC,GAAI;AAClD;AACA;AACA;AACA;AACA,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.403",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chayns",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "ca4f49b15e2f0248bd1f8c5f26c90006c8bd6d7a"
|
|
74
74
|
}
|