@transferwise/components 46.93.0 → 46.93.2
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/build/button/LegacyButton.js +0 -2
- package/build/button/LegacyButton.js.map +1 -1
- package/build/button/LegacyButton.mjs +0 -2
- package/build/button/LegacyButton.mjs.map +1 -1
- package/build/carousel/Carousel.js +1 -3
- package/build/carousel/Carousel.js.map +1 -1
- package/build/carousel/Carousel.mjs +1 -3
- package/build/carousel/Carousel.mjs.map +1 -1
- package/build/checkbox/Checkbox.js.map +1 -1
- package/build/checkbox/Checkbox.mjs.map +1 -1
- package/build/checkboxButton/CheckboxButton.js +1 -1
- package/build/checkboxButton/CheckboxButton.js.map +1 -1
- package/build/checkboxButton/CheckboxButton.mjs +1 -1
- package/build/checkboxButton/CheckboxButton.mjs.map +1 -1
- package/build/checkboxOption/CheckboxOption.js.map +1 -1
- package/build/checkboxOption/CheckboxOption.mjs.map +1 -1
- package/build/common/bottomSheet/BottomSheet.js.map +1 -1
- package/build/common/bottomSheet/BottomSheet.mjs.map +1 -1
- package/build/common/dateUtils/isDateValid/isDateValid.js +3 -3
- package/build/common/dateUtils/isDateValid/isDateValid.js.map +1 -1
- package/build/common/dateUtils/isDateValid/isDateValid.mjs +3 -3
- package/build/common/dateUtils/isDateValid/isDateValid.mjs.map +1 -1
- package/build/common/panel/Panel.js +3 -8
- package/build/common/panel/Panel.js.map +1 -1
- package/build/common/panel/Panel.mjs +3 -8
- package/build/common/panel/Panel.mjs.map +1 -1
- package/build/dimmer/dimmerManager/DimmerManager.js.map +1 -1
- package/build/dimmer/dimmerManager/DimmerManager.mjs.map +1 -1
- package/build/dropFade/DropFade.js.map +1 -1
- package/build/dropFade/DropFade.mjs.map +1 -1
- package/build/emphasis/EmphasisHtmlTransformer.js.map +1 -1
- package/build/emphasis/EmphasisHtmlTransformer.mjs.map +1 -1
- package/build/inputs/Input.js +1 -3
- package/build/inputs/Input.js.map +1 -1
- package/build/inputs/Input.mjs +1 -3
- package/build/inputs/Input.mjs.map +1 -1
- package/build/inputs/SelectInput.js +1 -3
- package/build/inputs/SelectInput.js.map +1 -1
- package/build/inputs/SelectInput.mjs +1 -3
- package/build/inputs/SelectInput.mjs.map +1 -1
- package/build/inputs/_ButtonInput.js +1 -3
- package/build/inputs/_ButtonInput.js.map +1 -1
- package/build/inputs/_ButtonInput.mjs +1 -3
- package/build/inputs/_ButtonInput.mjs.map +1 -1
- package/build/inputs/_Popover.js +1 -3
- package/build/inputs/_Popover.js.map +1 -1
- package/build/inputs/_Popover.mjs +1 -3
- package/build/inputs/_Popover.mjs.map +1 -1
- package/build/moneyInput/currencyFormatting.js +2 -2
- package/build/moneyInput/currencyFormatting.js.map +1 -1
- package/build/moneyInput/currencyFormatting.mjs +2 -2
- package/build/moneyInput/currencyFormatting.mjs.map +1 -1
- package/build/nudge/Nudge.js +0 -2
- package/build/nudge/Nudge.js.map +1 -1
- package/build/nudge/Nudge.mjs +0 -2
- package/build/nudge/Nudge.mjs.map +1 -1
- package/build/promoCard/PromoCardContext.js +0 -1
- package/build/promoCard/PromoCardContext.js.map +1 -1
- package/build/promoCard/PromoCardContext.mjs +0 -1
- package/build/promoCard/PromoCardContext.mjs.map +1 -1
- package/build/promoCard/PromoCardGroup.js +0 -1
- package/build/promoCard/PromoCardGroup.js.map +1 -1
- package/build/promoCard/PromoCardGroup.mjs +0 -1
- package/build/promoCard/PromoCardGroup.mjs.map +1 -1
- package/build/select/Select.js +19 -25
- package/build/select/Select.js.map +1 -1
- package/build/select/Select.mjs +19 -25
- package/build/select/Select.mjs.map +1 -1
- package/build/table/Table.js +1 -3
- package/build/table/Table.js.map +1 -1
- package/build/table/Table.mjs +1 -3
- package/build/table/Table.mjs.map +1 -1
- package/build/tooltip/Tooltip.js +2 -6
- package/build/tooltip/Tooltip.js.map +1 -1
- package/build/tooltip/Tooltip.mjs +2 -6
- package/build/tooltip/Tooltip.mjs.map +1 -1
- package/build/typeahead/typeaheadInput/TypeaheadInput.js +4 -1
- package/build/typeahead/typeaheadInput/TypeaheadInput.js.map +1 -1
- package/build/typeahead/typeaheadInput/TypeaheadInput.mjs +4 -1
- package/build/typeahead/typeaheadInput/TypeaheadInput.mjs.map +1 -1
- package/build/types/button/LegacyButton.d.ts.map +1 -1
- package/build/types/carousel/Carousel.d.ts.map +1 -1
- package/build/types/checkbox/Checkbox.d.ts.map +1 -1
- package/build/types/checkboxOption/CheckboxOption.d.ts +1 -2
- package/build/types/checkboxOption/CheckboxOption.d.ts.map +1 -1
- package/build/types/common/bottomSheet/BottomSheet.d.ts.map +1 -1
- package/build/types/common/dateUtils/isDateValid/isDateValid.d.ts.map +1 -1
- package/build/types/common/panel/Panel.d.ts.map +1 -1
- package/build/types/dimmer/dimmerManager/DimmerManager.d.ts +1 -1
- package/build/types/dimmer/dimmerManager/DimmerManager.d.ts.map +1 -1
- package/build/types/dropFade/DropFade.d.ts.map +1 -1
- package/build/types/emphasis/EmphasisHtmlTransformer.d.ts +2 -2
- package/build/types/emphasis/EmphasisHtmlTransformer.d.ts.map +1 -1
- package/build/types/inputs/Input.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/inputs/_ButtonInput.d.ts.map +1 -1
- package/build/types/inputs/_Popover.d.ts.map +1 -1
- package/build/types/nudge/Nudge.d.ts.map +1 -1
- package/build/types/promoCard/PromoCardContext.d.ts.map +1 -1
- package/build/types/promoCard/PromoCardGroup.d.ts.map +1 -1
- package/build/types/select/Select.d.ts.map +1 -1
- package/build/types/table/Table.d.ts.map +1 -1
- package/build/types/tooltip/Tooltip.d.ts.map +1 -1
- package/build/types/typeahead/typeaheadInput/TypeaheadInput.d.ts.map +1 -1
- package/build/types/withId/story/source.d.ts +1 -1
- package/build/types/withId/story/source.d.ts.map +1 -1
- package/build/upload/steps/completeStep/completeStep.js +1 -0
- package/build/upload/steps/completeStep/completeStep.js.map +1 -1
- package/build/upload/steps/completeStep/completeStep.mjs +1 -0
- package/build/upload/steps/completeStep/completeStep.mjs.map +1 -1
- package/build/upload/steps/processingStep/processingStep.js +1 -0
- package/build/upload/steps/processingStep/processingStep.js.map +1 -1
- package/build/upload/steps/processingStep/processingStep.mjs +1 -0
- package/build/upload/steps/processingStep/processingStep.mjs.map +1 -1
- package/package.json +6 -3
- package/src/accordion/Accordion.story.tsx +2 -2
- package/src/alert/Alert.story.tsx +4 -4
- package/src/alert/Alert.tests.story.tsx +3 -3
- package/src/button/LegacyButton.tsx +0 -2
- package/src/carousel/Carousel.spec.tsx +0 -4
- package/src/carousel/Carousel.tsx +0 -1
- package/src/checkbox/Checkbox.tsx +0 -1
- package/src/checkboxButton/CheckboxButton.story.tsx +0 -2
- package/src/checkboxButton/CheckboxButton.tsx +1 -1
- package/src/checkboxOption/CheckboxOption.tsx +1 -2
- package/src/common/bottomSheet/BottomSheet.spec.tsx +0 -1
- package/src/common/bottomSheet/BottomSheet.story.tsx +1 -1
- package/src/common/bottomSheet/BottomSheet.tsx +0 -1
- package/src/common/dateUtils/isDateValid/isDateValid.ts +5 -3
- package/src/common/hooks/useHasIntersected/useHasIntersected.spec.js +0 -2
- package/src/common/panel/Panel.tsx +2 -13
- package/src/dimmer/Dimmer.spec.tsx +3 -1
- package/src/dimmer/Dimmer.story.tsx +3 -2
- package/src/dimmer/dimmerManager/DimmerManager.ts +1 -1
- package/src/display/Display.story.tsx +0 -2
- package/src/drawer/Drawer.story.tsx +6 -4
- package/src/dropFade/DropFade.story.tsx +1 -2
- package/src/dropFade/DropFade.tsx +0 -1
- package/src/emphasis/EmphasisHtmlTransformer.spec.tsx +4 -4
- package/src/emphasis/EmphasisHtmlTransformer.ts +2 -2
- package/src/flowNavigation/FlowNavigation.story.tsx +6 -1
- package/src/inputs/Input.tsx +0 -1
- package/src/inputs/SelectInput.story.tsx +6 -2
- package/src/inputs/SelectInput.tsx +1 -7
- package/src/inputs/_ButtonInput.tsx +0 -1
- package/src/inputs/_Popover.tsx +0 -1
- package/src/link/Link.story.tsx +0 -1
- package/src/listItem/ListItem.story.tsx +0 -2
- package/src/markdown/Markdown.spec.tsx +0 -1
- package/src/modal/Modal.story.tsx +14 -4
- package/src/moneyInput/currencyFormatting.ts +3 -3
- package/src/nudge/Nudge.tsx +0 -2
- package/src/popover/Popover.story.tsx +10 -2
- package/src/promoCard/PromoCardContext.tsx +0 -1
- package/src/promoCard/PromoCardGroup.story.tsx +3 -15
- package/src/promoCard/PromoCardGroup.tsx +0 -1
- package/src/provider/theme/ThemeProvider.story.tsx +3 -5
- package/src/select/Select.spec.tsx +0 -1
- package/src/select/Select.tsx +0 -3
- package/src/select/option/Option.spec.js +2 -2
- package/src/selectOption/SelectOption.story.tsx +1 -2
- package/src/slidingPanel/SlidingPanel.story.tsx +1 -1
- package/src/table/Table.tsx +0 -1
- package/src/test-utils/jest.setup.ts +0 -1
- package/src/tooltip/Tooltip.tsx +0 -2
- package/src/typeahead/Typeahead.story.tsx +46 -0
- package/src/typeahead/typeaheadInput/TypeaheadInput.tsx +4 -1
- package/src/upload/Upload.events.spec.js +4 -4
- package/src/upload/steps/completeStep/completeStep.tsx +1 -1
- package/src/upload/steps/processingStep/processingStep.tsx +1 -1
- package/src/withId/story/source.tsx +1 -1
- package/src/withId/withId.story.tsx +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BottomSheet.js","sources":["../../../src/common/bottomSheet/BottomSheet.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport {\n CSSProperties,\n HTMLAttributes,\n PropsWithChildren,\n SyntheticEvent,\n useContext,\n useRef,\n useState,\n} from 'react';\n\nimport Dimmer from '../../dimmer';\nimport Drawer from '../../drawer';\nimport { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';\nimport SlidingPanel from '../../slidingPanel';\nimport { CloseButton } from '../closeButton';\nimport { CommonProps } from '../commonProps';\nimport { isServerSide } from '../domHelpers';\nimport { useConditionalListener } from '../hooks';\nimport { useMedia } from '../hooks/useMedia';\nimport { Breakpoint } from '../propsValues/breakpoint';\nimport { Position } from '../propsValues/position';\n\nconst INITIAL_Y_POSITION = 0;\n\nconst CONTENT_SCROLL_THRESHOLD = 1;\n\nconst MOVE_OFFSET_THRESHOLD = 50;\n\nexport type BottomSheetProps = PropsWithChildren<\n {\n onClose?: (event: Event | SyntheticEvent) => void;\n open: boolean;\n } & CommonProps &\n Pick<HTMLAttributes<HTMLDivElement>, 'role' | 'aria-labelledby' | 'aria-label'>\n>;\n\n/**\n * Neptune: https://transferwise.github.io/neptune/components/bottom-sheet/\n *\n * Neptune Web: https://transferwise.github.io/neptune-web/components/overlays/BottomSheet\n *\n */\nconst BottomSheet = ({ role = 'dialog', ...props }: BottomSheetProps) => {\n const bottomSheetReference = useRef<HTMLDivElement>(null);\n const topBarReference = useRef<HTMLDivElement>(null);\n const contentReference = useRef<HTMLDivElement>(null);\n\n const [pressed, setPressed] = useState<boolean>(false);\n\n /**\n * Used to track `requestAnimationFrame` requests\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#return_value\n */\n const animationId = useRef<number>(0);\n\n /**\n * Difference between initial coordinate ({@link initialYCoordinate})\n * and new position (when user moves component), it's get calculated on `onTouchMove` and `onMouseMove` events\n *\n * @see {@link calculateOffsetAfterMove}\n */\n const moveOffset = useRef<number>(0);\n const initialYCoordinate = useRef<number>(0);\n\n // apply shadow to the bottom of top-bar when scroll over content\n useConditionalListener({\n attachListener: props.open && !isServerSide(),\n callback: () => {\n if (topBarReference.current !== null) {\n const { classList } = topBarReference.current;\n if (!isContentScrollPositionAtTop()) {\n classList.add('np-bottom-sheet--top-bar--shadow');\n } else {\n classList.remove('np-bottom-sheet--top-bar--shadow');\n }\n }\n },\n eventType: 'scroll',\n parent: isServerSide() ? undefined : document,\n });\n\n function move(newHeight: number): void {\n if (bottomSheetReference.current !== null) {\n bottomSheetReference.current.style.transform = `translateY(${newHeight}px)`;\n }\n }\n\n function close(event: Event | SyntheticEvent): void {\n setPressed(false);\n moveOffset.current = INITIAL_Y_POSITION;\n if (bottomSheetReference.current !== null) {\n bottomSheetReference.current.style.removeProperty('transform');\n }\n if (props.onClose) {\n props.onClose(event);\n }\n }\n\n const onSwipeStart = (\n event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n ): void => {\n initialYCoordinate.current = ('touches' in event ? event.touches[0] : event).clientY;\n setPressed(true);\n };\n\n const onSwipeMove = (\n event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n ): void => {\n if (pressed) {\n const { clientY } = 'touches' in event ? event.touches[0] : event;\n\n const offset = calculateOffsetAfterMove(clientY);\n // check whether move is to the bottom only and content scroll position is at the top\n if (offset > INITIAL_Y_POSITION && isContentScrollPositionAtTop()) {\n moveOffset.current = offset;\n animationId.current = requestAnimationFrame(() => {\n if (animationId.current !== undefined && bottomSheetReference.current !== null) {\n move(offset);\n }\n });\n }\n }\n };\n\n function onSwipeEnd(\n event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n ): void {\n // stop moving component\n cancelAnimationFrame(animationId.current);\n setPressed(false);\n // check whether move down is strong enough\n // and content scroll position is at the top to close the component\n if (moveOffset.current > MOVE_OFFSET_THRESHOLD && isContentScrollPositionAtTop()) {\n close(event);\n }\n // otherwise move component back to default (initial) position\n else {\n move(INITIAL_Y_POSITION);\n }\n moveOffset.current = INITIAL_Y_POSITION;\n }\n\n function isContentScrollPositionAtTop(): boolean {\n return (\n contentReference?.current?.scrollTop !== undefined &&\n contentReference.current.scrollTop <= CONTENT_SCROLL_THRESHOLD\n );\n }\n\n /**\n * Calculates how hard user moves component,\n * result value used to determine whether to hide component or re-position to default state\n *\n * @param afterMoveYCoordinate\n */\n function calculateOffsetAfterMove(afterMoveYCoordinate: number): number {\n return afterMoveYCoordinate - initialYCoordinate.current;\n }\n\n /**\n * Set `max-height` for content part (in order to keep it scrollable for content overflow cases) of the component\n * and ensures space for safe zone (32px) at the top.\n */\n function setContentMaxHeight(): CSSProperties {\n const safeZoneHeight = '64px';\n const topbarHeight = '32px';\n const windowHight: number = isServerSide() ? 0 : window.innerHeight;\n /**\n * Calculate _real_ height of the screen (taking into account parts of browser interface).\n *\n * See https://css-tricks.com/the-trick-to-viewport-units-on-mobile for more details.\n */\n const screenHeight = `${windowHight * 0.01 * 100}px`;\n return {\n maxHeight: `calc(${screenHeight} - ${safeZoneHeight} - ${topbarHeight})`,\n };\n }\n\n const is400Zoom = useMedia(`(max-width: ${Breakpoint.ZOOM_400}px)`);\n\n const overlayId = useContext(OverlayIdContext);\n\n return is400Zoom ? (\n <Drawer\n aria-labelledby={props['aria-labelledby']}\n aria-label={props['aria-label']}\n role={role}\n open={props.open}\n className={props.className}\n onClose={close}\n >\n {props.children}\n </Drawer>\n ) : (\n <Dimmer open={props.open} fadeContentOnEnter fadeContentOnExit onClose={close}>\n <SlidingPanel\n ref={bottomSheetReference}\n open={props.open}\n position={Position.BOTTOM}\n className={clsx('np-bottom-sheet', props.className)}\n >\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */}\n <div\n id={overlayId}\n aria-labelledby={props['aria-labelledby'] || undefined}\n aria-label={props['aria-label'] || undefined}\n role={role}\n aria-modal\n onTouchStart={onSwipeStart}\n onTouchMove={onSwipeMove}\n onTouchEnd={onSwipeEnd}\n onMouseDown={onSwipeStart}\n onMouseMove={onSwipeMove}\n onMouseUp={onSwipeEnd}\n >\n <div ref={topBarReference} className=\"np-bottom-sheet--top-bar\">\n <div className=\"np-bottom-sheet--handler\" />\n <CloseButton size=\"sm\" className=\"sr-only np-bottom-sheet--close-btn\" onClick={close} />\n </div>\n <div\n ref={contentReference}\n style={setContentMaxHeight()}\n className=\"np-bottom-sheet--content\"\n >\n {props.children}\n </div>\n </div>\n </SlidingPanel>\n </Dimmer>\n );\n};\n\nexport default BottomSheet;\n"],"names":["INITIAL_Y_POSITION","CONTENT_SCROLL_THRESHOLD","MOVE_OFFSET_THRESHOLD","BottomSheet","role","props","bottomSheetReference","useRef","topBarReference","contentReference","pressed","setPressed","useState","animationId","moveOffset","initialYCoordinate","useConditionalListener","attachListener","open","isServerSide","callback","current","classList","isContentScrollPositionAtTop","add","remove","eventType","parent","undefined","document","move","newHeight","style","transform","close","event","removeProperty","onClose","onSwipeStart","touches","clientY","onSwipeMove","offset","calculateOffsetAfterMove","requestAnimationFrame","onSwipeEnd","cancelAnimationFrame","scrollTop","afterMoveYCoordinate","setContentMaxHeight","safeZoneHeight","topbarHeight","windowHight","window","innerHeight","screenHeight","maxHeight","is400Zoom","useMedia","Breakpoint","ZOOM_400","overlayId","useContext","OverlayIdContext","_jsx","Drawer","className","children","Dimmer","fadeContentOnEnter","fadeContentOnExit","SlidingPanel","ref","position","Position","BOTTOM","clsx","_jsxs","id","onTouchStart","onTouchMove","onTouchEnd","onMouseDown","onMouseMove","onMouseUp","CloseButton","size","onClick"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,MAAMA,kBAAkB,GAAG,CAAC,CAAA;AAE5B,MAAMC,wBAAwB,GAAG,CAAC,CAAA;AAElC,MAAMC,qBAAqB,GAAG,EAAE,CAAA;AAUhC;;;;;AAKG;AACGC,MAAAA,WAAW,GAAGA,CAAC;AAAEC,EAAAA,IAAI,GAAG,QAAQ;EAAE,GAAGC,KAAAA;AAAyB,CAAA,KAAI;AACtE,EAAA,MAAMC,oBAAoB,GAAGC,YAAM,CAAiB,IAAI,CAAC,CAAA;AACzD,EAAA,MAAMC,eAAe,GAAGD,YAAM,CAAiB,IAAI,CAAC,CAAA;AACpD,EAAA,MAAME,gBAAgB,GAAGF,YAAM,CAAiB,IAAI,CAAC,CAAA;EAErD,MAAM,CAACG,OAAO,EAAEC,UAAU,CAAC,GAAGC,cAAQ,CAAU,KAAK,CAAC,CAAA;AAEtD;;;;AAIG;AACH,EAAA,MAAMC,WAAW,GAAGN,YAAM,CAAS,CAAC,CAAC,CAAA;AAErC;;;;;AAKG;AACH,EAAA,MAAMO,UAAU,GAAGP,YAAM,CAAS,CAAC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A,gBAC7DH,cAAA,CAAA,KAAA,EAAA;AAAKE,YAAAA,SAAS,EAAC,0BAAA;AAA0B,WACzC,CAAA,eAAAF,cAAA,CAACqB,uBAAW,EAAA;AAACC,YAAAA,IAAI,EAAC,IAAI;AAACpB,YAAAA,SAAS,EAAC,oCAAoC;AAACqB,YAAAA,OAAO,EAAErD,KAAAA;AAAM,WACvF,CAAA,CAAA;SAAK,CACL,eAAA8B,cAAA,CAAA,KAAA,EAAA;AACEQ,UAAAA,GAAG,EAAE/D,gBAAiB;UACtBuB,KAAK,EAAEiB,mBAAmB,EAAG;AAC7BiB,UAAAA,SAAS,EAAC,0BAA0B;UAAAC,QAAA,EAEnC9D,KAAK,CAAC8D,QAAAA;AAAQ,SACZ,CACP,CAAA;OAAK,CAAA;KACO,CAAA;AAChB,GAAQ,CACT,CAAA;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"BottomSheet.js","sources":["../../../src/common/bottomSheet/BottomSheet.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport {\n CSSProperties,\n HTMLAttributes,\n PropsWithChildren,\n SyntheticEvent,\n useContext,\n useRef,\n useState,\n} from 'react';\n\nimport Dimmer from '../../dimmer';\nimport Drawer from '../../drawer';\nimport { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';\nimport SlidingPanel from '../../slidingPanel';\nimport { CloseButton } from '../closeButton';\nimport { CommonProps } from '../commonProps';\nimport { isServerSide } from '../domHelpers';\nimport { useConditionalListener } from '../hooks';\nimport { useMedia } from '../hooks/useMedia';\nimport { Breakpoint } from '../propsValues/breakpoint';\nimport { Position } from '../propsValues/position';\n\nconst INITIAL_Y_POSITION = 0;\n\nconst CONTENT_SCROLL_THRESHOLD = 1;\n\nconst MOVE_OFFSET_THRESHOLD = 50;\n\nexport type BottomSheetProps = PropsWithChildren<\n {\n onClose?: (event: Event | SyntheticEvent) => void;\n open: boolean;\n } & CommonProps &\n Pick<HTMLAttributes<HTMLDivElement>, 'role' | 'aria-labelledby' | 'aria-label'>\n>;\n\n/**\n * Neptune: https://transferwise.github.io/neptune/components/bottom-sheet/\n *\n * Neptune Web: https://transferwise.github.io/neptune-web/components/overlays/BottomSheet\n *\n */\nconst BottomSheet = ({ role = 'dialog', ...props }: BottomSheetProps) => {\n const bottomSheetReference = useRef<HTMLDivElement>(null);\n const topBarReference = useRef<HTMLDivElement>(null);\n const contentReference = useRef<HTMLDivElement>(null);\n\n const [pressed, setPressed] = useState<boolean>(false);\n\n /**\n * Used to track `requestAnimationFrame` requests\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#return_value\n */\n const animationId = useRef<number>(0);\n\n /**\n * Difference between initial coordinate ({@link initialYCoordinate})\n * and new position (when user moves component), it's get calculated on `onTouchMove` and `onMouseMove` events\n *\n * @see {@link calculateOffsetAfterMove}\n */\n const moveOffset = useRef<number>(0);\n const initialYCoordinate = useRef<number>(0);\n\n // apply shadow to the bottom of top-bar when scroll over content\n useConditionalListener({\n attachListener: props.open && !isServerSide(),\n callback: () => {\n if (topBarReference.current !== null) {\n const { classList } = topBarReference.current;\n if (!isContentScrollPositionAtTop()) {\n classList.add('np-bottom-sheet--top-bar--shadow');\n } else {\n classList.remove('np-bottom-sheet--top-bar--shadow');\n }\n }\n },\n eventType: 'scroll',\n parent: isServerSide() ? undefined : document,\n });\n\n function move(newHeight: number): void {\n if (bottomSheetReference.current !== null) {\n bottomSheetReference.current.style.transform = `translateY(${newHeight}px)`;\n }\n }\n\n function close(event: Event | SyntheticEvent): void {\n setPressed(false);\n moveOffset.current = INITIAL_Y_POSITION;\n if (bottomSheetReference.current !== null) {\n bottomSheetReference.current.style.removeProperty('transform');\n }\n if (props.onClose) {\n props.onClose(event);\n }\n }\n\n const onSwipeStart = (\n event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n ): void => {\n initialYCoordinate.current = ('touches' in event ? event.touches[0] : event).clientY;\n setPressed(true);\n };\n\n const onSwipeMove = (\n event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n ): void => {\n if (pressed) {\n const { clientY } = 'touches' in event ? event.touches[0] : event;\n\n const offset = calculateOffsetAfterMove(clientY);\n // check whether move is to the bottom only and content scroll position is at the top\n if (offset > INITIAL_Y_POSITION && isContentScrollPositionAtTop()) {\n moveOffset.current = offset;\n animationId.current = requestAnimationFrame(() => {\n if (animationId.current !== undefined && bottomSheetReference.current !== null) {\n move(offset);\n }\n });\n }\n }\n };\n\n function onSwipeEnd(\n event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n ): void {\n // stop moving component\n cancelAnimationFrame(animationId.current);\n setPressed(false);\n // check whether move down is strong enough\n // and content scroll position is at the top to close the component\n if (moveOffset.current > MOVE_OFFSET_THRESHOLD && isContentScrollPositionAtTop()) {\n close(event);\n }\n // otherwise move component back to default (initial) position\n else {\n move(INITIAL_Y_POSITION);\n }\n moveOffset.current = INITIAL_Y_POSITION;\n }\n\n function isContentScrollPositionAtTop(): boolean {\n return (\n contentReference?.current?.scrollTop !== undefined &&\n contentReference.current.scrollTop <= CONTENT_SCROLL_THRESHOLD\n );\n }\n\n /**\n * Calculates how hard user moves component,\n * result value used to determine whether to hide component or re-position to default state\n *\n * @param afterMoveYCoordinate\n */\n function calculateOffsetAfterMove(afterMoveYCoordinate: number): number {\n return afterMoveYCoordinate - initialYCoordinate.current;\n }\n\n /**\n * Set `max-height` for content part (in order to keep it scrollable for content overflow cases) of the component\n * and ensures space for safe zone (32px) at the top.\n */\n function setContentMaxHeight(): CSSProperties {\n const safeZoneHeight = '64px';\n const topbarHeight = '32px';\n const windowHight: number = isServerSide() ? 0 : window.innerHeight;\n /**\n * Calculate _real_ height of the screen (taking into account parts of browser interface).\n *\n * See https://css-tricks.com/the-trick-to-viewport-units-on-mobile for more details.\n */\n const screenHeight = `${windowHight * 0.01 * 100}px`;\n return {\n maxHeight: `calc(${screenHeight} - ${safeZoneHeight} - ${topbarHeight})`,\n };\n }\n\n const is400Zoom = useMedia(`(max-width: ${Breakpoint.ZOOM_400}px)`);\n\n const overlayId = useContext(OverlayIdContext);\n\n return is400Zoom ? (\n <Drawer\n aria-labelledby={props['aria-labelledby']}\n aria-label={props['aria-label']}\n role={role}\n open={props.open}\n className={props.className}\n onClose={close}\n >\n {props.children}\n </Drawer>\n ) : (\n <Dimmer open={props.open} fadeContentOnEnter fadeContentOnExit onClose={close}>\n <SlidingPanel\n ref={bottomSheetReference}\n open={props.open}\n position={Position.BOTTOM}\n className={clsx('np-bottom-sheet', props.className)}\n >\n <div\n id={overlayId}\n aria-labelledby={props['aria-labelledby'] || undefined}\n aria-label={props['aria-label'] || undefined}\n role={role}\n aria-modal\n onTouchStart={onSwipeStart}\n onTouchMove={onSwipeMove}\n onTouchEnd={onSwipeEnd}\n onMouseDown={onSwipeStart}\n onMouseMove={onSwipeMove}\n onMouseUp={onSwipeEnd}\n >\n <div ref={topBarReference} className=\"np-bottom-sheet--top-bar\">\n <div className=\"np-bottom-sheet--handler\" />\n <CloseButton size=\"sm\" className=\"sr-only np-bottom-sheet--close-btn\" onClick={close} />\n </div>\n <div\n ref={contentReference}\n style={setContentMaxHeight()}\n className=\"np-bottom-sheet--content\"\n >\n {props.children}\n </div>\n </div>\n </SlidingPanel>\n </Dimmer>\n );\n};\n\nexport default BottomSheet;\n"],"names":["INITIAL_Y_POSITION","CONTENT_SCROLL_THRESHOLD","MOVE_OFFSET_THRESHOLD","BottomSheet","role","props","bottomSheetReference","useRef","topBarReference","contentReference","pressed","setPressed","useState","animationId","moveOffset","initialYCoordinate","useConditionalListener","attachListener","open","isServerSide","callback","current","classList","isContentScrollPositionAtTop","add","remove","eventType","parent","undefined","document","move","newHeight","style","transform","close","event","removeProperty","onClose","onSwipeStart","touches","clientY","onSwipeMove","offset","calculateOffsetAfterMove","requestAnimationFrame","onSwipeEnd","cancelAnimationFrame","scrollTop","afterMoveYCoordinate","setContentMaxHeight","safeZoneHeight","topbarHeight","windowHight","window","innerHeight","screenHeight","maxHeight","is400Zoom","useMedia","Breakpoint","ZOOM_400","overlayId","useContext","OverlayIdContext","_jsx","Drawer","className","children","Dimmer","fadeContentOnEnter","fadeContentOnExit","SlidingPanel","ref","position","Position","BOTTOM","clsx","_jsxs","id","onTouchStart","onTouchMove","onTouchEnd","onMouseDown","onMouseMove","onMouseUp","CloseButton","size","onClick"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,MAAMA,kBAAkB,GAAG,CAAC,CAAA;AAE5B,MAAMC,wBAAwB,GAAG,CAAC,CAAA;AAElC,MAAMC,qBAAqB,GAAG,EAAE,CAAA;AAUhC;;;;;AAKG;AACGC,MAAAA,WAAW,GAAGA,CAAC;AAAEC,EAAAA,IAAI,GAAG,QAAQ;EAAE,GAAGC,KAAAA;AAAyB,CAAA,KAAI;AACtE,EAAA,MAAMC,oBAAoB,GAAGC,YAAM,CAAiB,IAAI,CAAC,CAAA;AACzD,EAAA,MAAMC,eAAe,GAAGD,YAAM,CAAiB,IAAI,CAAC,CAAA;AACpD,EAAA,MAAME,gBAAgB,GAAGF,YAAM,CAAiB,IAAI,CAAC,CAAA;EAErD,MAAM,CAACG,OAAO,EAAEC,UAAU,CAAC,GAAGC,cAAQ,CAAU,KAAK,CAAC,CAAA;AAEtD;;;;AAIG;AACH,EAAA,MAAMC,WAAW,GAAGN,YAAM,CAAS,CAAC,CAAC,CAAA;AAErC;;;;;AAKG;AACH,EAAA,MAAMO,UAAU,GAAGP,YAAM,CAAS,CAAC,CAAC,CAAA;AACpC,EAAA,MAAMQ,kBAAkB,GAAGR,YAAM,CAAS,CAAC,CAAC,CAAA;AAE5C;AACAS,EAAAA,6CAAsB,CAAC;IACrBC,cAAc,EAAEZ,KAAK,CAACa,IAAI,IAAI,CAACC,6BAAY,EAAE;IAC7CC,QAAQ,EAAEA,MAAK;AACb,MAAA,IAAIZ,eAAe,CAACa,OAAO,KAAK,IAAI,EAAE;QACpC,MAAM;AAAEC,UAAAA,SAAAA;SAAW,GAAGd,eAAe,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/D,gBAAiB;UACtBuB,KAAK,EAAEiB,mBAAmB,EAAG;AAC7BiB,UAAAA,SAAS,EAAC,0BAA0B;UAAAC,QAAA,EAEnC9D,KAAK,CAAC8D,QAAAA;AAAQ,SACZ,CACP,CAAA;OAAK,CAAA;KACO,CAAA;AAChB,GAAQ,CACT,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BottomSheet.mjs","sources":["../../../src/common/bottomSheet/BottomSheet.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport {\n CSSProperties,\n HTMLAttributes,\n PropsWithChildren,\n SyntheticEvent,\n useContext,\n useRef,\n useState,\n} from 'react';\n\nimport Dimmer from '../../dimmer';\nimport Drawer from '../../drawer';\nimport { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';\nimport SlidingPanel from '../../slidingPanel';\nimport { CloseButton } from '../closeButton';\nimport { CommonProps } from '../commonProps';\nimport { isServerSide } from '../domHelpers';\nimport { useConditionalListener } from '../hooks';\nimport { useMedia } from '../hooks/useMedia';\nimport { Breakpoint } from '../propsValues/breakpoint';\nimport { Position } from '../propsValues/position';\n\nconst INITIAL_Y_POSITION = 0;\n\nconst CONTENT_SCROLL_THRESHOLD = 1;\n\nconst MOVE_OFFSET_THRESHOLD = 50;\n\nexport type BottomSheetProps = PropsWithChildren<\n {\n onClose?: (event: Event | SyntheticEvent) => void;\n open: boolean;\n } & CommonProps &\n Pick<HTMLAttributes<HTMLDivElement>, 'role' | 'aria-labelledby' | 'aria-label'>\n>;\n\n/**\n * Neptune: https://transferwise.github.io/neptune/components/bottom-sheet/\n *\n * Neptune Web: https://transferwise.github.io/neptune-web/components/overlays/BottomSheet\n *\n */\nconst BottomSheet = ({ role = 'dialog', ...props }: BottomSheetProps) => {\n const bottomSheetReference = useRef<HTMLDivElement>(null);\n const topBarReference = useRef<HTMLDivElement>(null);\n const contentReference = useRef<HTMLDivElement>(null);\n\n const [pressed, setPressed] = useState<boolean>(false);\n\n /**\n * Used to track `requestAnimationFrame` requests\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#return_value\n */\n const animationId = useRef<number>(0);\n\n /**\n * Difference between initial coordinate ({@link initialYCoordinate})\n * and new position (when user moves component), it's get calculated on `onTouchMove` and `onMouseMove` events\n *\n * @see {@link calculateOffsetAfterMove}\n */\n const moveOffset = useRef<number>(0);\n const initialYCoordinate = useRef<number>(0);\n\n // apply shadow to the bottom of top-bar when scroll over content\n useConditionalListener({\n attachListener: props.open && !isServerSide(),\n callback: () => {\n if (topBarReference.current !== null) {\n const { classList } = topBarReference.current;\n if (!isContentScrollPositionAtTop()) {\n classList.add('np-bottom-sheet--top-bar--shadow');\n } else {\n classList.remove('np-bottom-sheet--top-bar--shadow');\n }\n }\n },\n eventType: 'scroll',\n parent: isServerSide() ? undefined : document,\n });\n\n function move(newHeight: number): void {\n if (bottomSheetReference.current !== null) {\n bottomSheetReference.current.style.transform = `translateY(${newHeight}px)`;\n }\n }\n\n function close(event: Event | SyntheticEvent): void {\n setPressed(false);\n moveOffset.current = INITIAL_Y_POSITION;\n if (bottomSheetReference.current !== null) {\n bottomSheetReference.current.style.removeProperty('transform');\n }\n if (props.onClose) {\n props.onClose(event);\n }\n }\n\n const onSwipeStart = (\n event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n ): void => {\n initialYCoordinate.current = ('touches' in event ? event.touches[0] : event).clientY;\n setPressed(true);\n };\n\n const onSwipeMove = (\n event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n ): void => {\n if (pressed) {\n const { clientY } = 'touches' in event ? event.touches[0] : event;\n\n const offset = calculateOffsetAfterMove(clientY);\n // check whether move is to the bottom only and content scroll position is at the top\n if (offset > INITIAL_Y_POSITION && isContentScrollPositionAtTop()) {\n moveOffset.current = offset;\n animationId.current = requestAnimationFrame(() => {\n if (animationId.current !== undefined && bottomSheetReference.current !== null) {\n move(offset);\n }\n });\n }\n }\n };\n\n function onSwipeEnd(\n event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n ): void {\n // stop moving component\n cancelAnimationFrame(animationId.current);\n setPressed(false);\n // check whether move down is strong enough\n // and content scroll position is at the top to close the component\n if (moveOffset.current > MOVE_OFFSET_THRESHOLD && isContentScrollPositionAtTop()) {\n close(event);\n }\n // otherwise move component back to default (initial) position\n else {\n move(INITIAL_Y_POSITION);\n }\n moveOffset.current = INITIAL_Y_POSITION;\n }\n\n function isContentScrollPositionAtTop(): boolean {\n return (\n contentReference?.current?.scrollTop !== undefined &&\n contentReference.current.scrollTop <= CONTENT_SCROLL_THRESHOLD\n );\n }\n\n /**\n * Calculates how hard user moves component,\n * result value used to determine whether to hide component or re-position to default state\n *\n * @param afterMoveYCoordinate\n */\n function calculateOffsetAfterMove(afterMoveYCoordinate: number): number {\n return afterMoveYCoordinate - initialYCoordinate.current;\n }\n\n /**\n * Set `max-height` for content part (in order to keep it scrollable for content overflow cases) of the component\n * and ensures space for safe zone (32px) at the top.\n */\n function setContentMaxHeight(): CSSProperties {\n const safeZoneHeight = '64px';\n const topbarHeight = '32px';\n const windowHight: number = isServerSide() ? 0 : window.innerHeight;\n /**\n * Calculate _real_ height of the screen (taking into account parts of browser interface).\n *\n * See https://css-tricks.com/the-trick-to-viewport-units-on-mobile for more details.\n */\n const screenHeight = `${windowHight * 0.01 * 100}px`;\n return {\n maxHeight: `calc(${screenHeight} - ${safeZoneHeight} - ${topbarHeight})`,\n };\n }\n\n const is400Zoom = useMedia(`(max-width: ${Breakpoint.ZOOM_400}px)`);\n\n const overlayId = useContext(OverlayIdContext);\n\n return is400Zoom ? (\n <Drawer\n aria-labelledby={props['aria-labelledby']}\n aria-label={props['aria-label']}\n role={role}\n open={props.open}\n className={props.className}\n onClose={close}\n >\n {props.children}\n </Drawer>\n ) : (\n <Dimmer open={props.open} fadeContentOnEnter fadeContentOnExit onClose={close}>\n <SlidingPanel\n ref={bottomSheetReference}\n open={props.open}\n position={Position.BOTTOM}\n className={clsx('np-bottom-sheet', props.className)}\n >\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */}\n <div\n id={overlayId}\n aria-labelledby={props['aria-labelledby'] || undefined}\n aria-label={props['aria-label'] || undefined}\n role={role}\n aria-modal\n onTouchStart={onSwipeStart}\n onTouchMove={onSwipeMove}\n onTouchEnd={onSwipeEnd}\n onMouseDown={onSwipeStart}\n onMouseMove={onSwipeMove}\n onMouseUp={onSwipeEnd}\n >\n <div ref={topBarReference} className=\"np-bottom-sheet--top-bar\">\n <div className=\"np-bottom-sheet--handler\" />\n <CloseButton size=\"sm\" className=\"sr-only np-bottom-sheet--close-btn\" onClick={close} />\n </div>\n <div\n ref={contentReference}\n style={setContentMaxHeight()}\n className=\"np-bottom-sheet--content\"\n >\n {props.children}\n </div>\n </div>\n </SlidingPanel>\n </Dimmer>\n );\n};\n\nexport default BottomSheet;\n"],"names":["INITIAL_Y_POSITION","CONTENT_SCROLL_THRESHOLD","MOVE_OFFSET_THRESHOLD","BottomSheet","role","props","bottomSheetReference","useRef","topBarReference","contentReference","pressed","setPressed","useState","animationId","moveOffset","initialYCoordinate","useConditionalListener","attachListener","open","isServerSide","callback","current","classList","isContentScrollPositionAtTop","add","remove","eventType","parent","undefined","document","move","newHeight","style","transform","close","event","removeProperty","onClose","onSwipeStart","touches","clientY","onSwipeMove","offset","calculateOffsetAfterMove","requestAnimationFrame","onSwipeEnd","cancelAnimationFrame","scrollTop","afterMoveYCoordinate","setContentMaxHeight","safeZoneHeight","topbarHeight","windowHight","window","innerHeight","screenHeight","maxHeight","is400Zoom","useMedia","Breakpoint","ZOOM_400","overlayId","useContext","OverlayIdContext","_jsx","Drawer","className","children","Dimmer","fadeContentOnEnter","fadeContentOnExit","SlidingPanel","ref","position","Position","BOTTOM","clsx","_jsxs","id","onTouchStart","onTouchMove","onTouchEnd","onMouseDown","onMouseMove","onMouseUp","CloseButton","size","onClick"],"mappings":";;;;;;;;;;;;;;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src/common/bottomSheet/BottomSheet.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport {\n CSSProperties,\n HTMLAttributes,\n PropsWithChildren,\n SyntheticEvent,\n useContext,\n useRef,\n useState,\n} from 'react';\n\nimport Dimmer from '../../dimmer';\nimport Drawer from '../../drawer';\nimport { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';\nimport SlidingPanel from '../../slidingPanel';\nimport { CloseButton } from '../closeButton';\nimport { CommonProps } from '../commonProps';\nimport { isServerSide } from '../domHelpers';\nimport { useConditionalListener } from '../hooks';\nimport { useMedia } from '../hooks/useMedia';\nimport { Breakpoint } from '../propsValues/breakpoint';\nimport { Position } from '../propsValues/position';\n\nconst INITIAL_Y_POSITION = 0;\n\nconst CONTENT_SCROLL_THRESHOLD = 1;\n\nconst MOVE_OFFSET_THRESHOLD = 50;\n\nexport type BottomSheetProps = PropsWithChildren<\n {\n onClose?: (event: Event | SyntheticEvent) => void;\n open: boolean;\n } & CommonProps &\n Pick<HTMLAttributes<HTMLDivElement>, 'role' | 'aria-labelledby' | 'aria-label'>\n>;\n\n/**\n * Neptune: https://transferwise.github.io/neptune/components/bottom-sheet/\n *\n * Neptune Web: https://transferwise.github.io/neptune-web/components/overlays/BottomSheet\n *\n */\nconst BottomSheet = ({ role = 'dialog', ...props }: BottomSheetProps) => {\n const bottomSheetReference = useRef<HTMLDivElement>(null);\n const topBarReference = useRef<HTMLDivElement>(null);\n const contentReference = useRef<HTMLDivElement>(null);\n\n const [pressed, setPressed] = useState<boolean>(false);\n\n /**\n * Used to track `requestAnimationFrame` requests\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#return_value\n */\n const animationId = useRef<number>(0);\n\n /**\n * Difference between initial coordinate ({@link initialYCoordinate})\n * and new position (when user moves component), it's get calculated on `onTouchMove` and `onMouseMove` events\n *\n * @see {@link calculateOffsetAfterMove}\n */\n const moveOffset = useRef<number>(0);\n const initialYCoordinate = useRef<number>(0);\n\n // apply shadow to the bottom of top-bar when scroll over content\n useConditionalListener({\n attachListener: props.open && !isServerSide(),\n callback: () => {\n if (topBarReference.current !== null) {\n const { classList } = topBarReference.current;\n if (!isContentScrollPositionAtTop()) {\n classList.add('np-bottom-sheet--top-bar--shadow');\n } else {\n classList.remove('np-bottom-sheet--top-bar--shadow');\n }\n }\n },\n eventType: 'scroll',\n parent: isServerSide() ? undefined : document,\n });\n\n function move(newHeight: number): void {\n if (bottomSheetReference.current !== null) {\n bottomSheetReference.current.style.transform = `translateY(${newHeight}px)`;\n }\n }\n\n function close(event: Event | SyntheticEvent): void {\n setPressed(false);\n moveOffset.current = INITIAL_Y_POSITION;\n if (bottomSheetReference.current !== null) {\n bottomSheetReference.current.style.removeProperty('transform');\n }\n if (props.onClose) {\n props.onClose(event);\n }\n }\n\n const onSwipeStart = (\n event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n ): void => {\n initialYCoordinate.current = ('touches' in event ? event.touches[0] : event).clientY;\n setPressed(true);\n };\n\n const onSwipeMove = (\n event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n ): void => {\n if (pressed) {\n const { clientY } = 'touches' in event ? event.touches[0] : event;\n\n const offset = calculateOffsetAfterMove(clientY);\n // check whether move is to the bottom only and content scroll position is at the top\n if (offset > INITIAL_Y_POSITION && isContentScrollPositionAtTop()) {\n moveOffset.current = offset;\n animationId.current = requestAnimationFrame(() => {\n if (animationId.current !== undefined && bottomSheetReference.current !== null) {\n move(offset);\n }\n });\n }\n }\n };\n\n function onSwipeEnd(\n event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n ): void {\n // stop moving component\n cancelAnimationFrame(animationId.current);\n setPressed(false);\n // check whether move down is strong enough\n // and content scroll position is at the top to close the component\n if (moveOffset.current > MOVE_OFFSET_THRESHOLD && isContentScrollPositionAtTop()) {\n close(event);\n }\n // otherwise move component back to default (initial) position\n else {\n move(INITIAL_Y_POSITION);\n }\n moveOffset.current = INITIAL_Y_POSITION;\n }\n\n function isContentScrollPositionAtTop(): boolean {\n return (\n contentReference?.current?.scrollTop !== undefined &&\n contentReference.current.scrollTop <= CONTENT_SCROLL_THRESHOLD\n );\n }\n\n /**\n * Calculates how hard user moves component,\n * result value used to determine whether to hide component or re-position to default state\n *\n * @param afterMoveYCoordinate\n */\n function calculateOffsetAfterMove(afterMoveYCoordinate: number): number {\n return afterMoveYCoordinate - initialYCoordinate.current;\n }\n\n /**\n * Set `max-height` for content part (in order to keep it scrollable for content overflow cases) of the component\n * and ensures space for safe zone (32px) at the top.\n */\n function setContentMaxHeight(): CSSProperties {\n const safeZoneHeight = '64px';\n const topbarHeight = '32px';\n const windowHight: number = isServerSide() ? 0 : window.innerHeight;\n /**\n * Calculate _real_ height of the screen (taking into account parts of browser interface).\n *\n * See https://css-tricks.com/the-trick-to-viewport-units-on-mobile for more details.\n */\n const screenHeight = `${windowHight * 0.01 * 100}px`;\n return {\n maxHeight: `calc(${screenHeight} - ${safeZoneHeight} - ${topbarHeight})`,\n };\n }\n\n const is400Zoom = useMedia(`(max-width: ${Breakpoint.ZOOM_400}px)`);\n\n const overlayId = useContext(OverlayIdContext);\n\n return is400Zoom ? (\n <Drawer\n aria-labelledby={props['aria-labelledby']}\n aria-label={props['aria-label']}\n role={role}\n open={props.open}\n className={props.className}\n onClose={close}\n >\n {props.children}\n </Drawer>\n ) : (\n <Dimmer open={props.open} fadeContentOnEnter fadeContentOnExit onClose={close}>\n <SlidingPanel\n ref={bottomSheetReference}\n open={props.open}\n position={Position.BOTTOM}\n className={clsx('np-bottom-sheet', props.className)}\n >\n <div\n id={overlayId}\n aria-labelledby={props['aria-labelledby'] || undefined}\n aria-label={props['aria-label'] || undefined}\n role={role}\n aria-modal\n onTouchStart={onSwipeStart}\n onTouchMove={onSwipeMove}\n onTouchEnd={onSwipeEnd}\n onMouseDown={onSwipeStart}\n onMouseMove={onSwipeMove}\n onMouseUp={onSwipeEnd}\n >\n <div ref={topBarReference} className=\"np-bottom-sheet--top-bar\">\n <div className=\"np-bottom-sheet--handler\" />\n <CloseButton size=\"sm\" className=\"sr-only np-bottom-sheet--close-btn\" onClick={close} />\n </div>\n <div\n ref={contentReference}\n style={setContentMaxHeight()}\n className=\"np-bottom-sheet--content\"\n >\n {props.children}\n </div>\n </div>\n </SlidingPanel>\n </Dimmer>\n );\n};\n\nexport default BottomSheet;\n"],"names":["INITIAL_Y_POSITION","CONTENT_SCROLL_THRESHOLD","MOVE_OFFSET_THRESHOLD","BottomSheet","role","props","bottomSheetReference","useRef","topBarReference","contentReference","pressed","setPressed","useState","animationId","moveOffset","initialYCoordinate","useConditionalListener","attachListener","open","isServerSide","callback","current","classList","isContentScrollPositionAtTop","add","remove","eventType","parent","undefined","document","move","newHeight","style","transform","close","event","removeProperty","onClose","onSwipeStart","touches","clientY","onSwipeMove","offset","calculateOffsetAfterMove","requestAnimationFrame","onSwipeEnd","cancelAnimationFrame","scrollTop","afterMoveYCoordinate","setContentMaxHeight","safeZoneHeight","topbarHeight","windowHight","window","innerHeight","screenHeight","maxHeight","is400Zoom","useMedia","Breakpoint","ZOOM_400","overlayId","useContext","OverlayIdContext","_jsx","Drawer","className","children","Dimmer","fadeContentOnEnter","fadeContentOnExit","SlidingPanel","ref","position","Position","BOTTOM","clsx","_jsxs","id","onTouchStart","onTouchMove","onTouchEnd","onMouseDown","onMouseMove","onMouseUp","CloseButton","size","onClick"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAMA,kBAAkB,GAAG,CAAC,CAAA;AAE5B,MAAMC,wBAAwB,GAAG,CAAC,CAAA;AAElC,MAAMC,qBAAqB,GAAG,EAAE,CAAA;AAUhC;;;;;AAKG;AACGC,MAAAA,WAAW,GAAGA,CAAC;AAAEC,EAAAA,IAAI,GAAG,QAAQ;EAAE,GAAGC,KAAAA;AAAyB,CAAA,KAAI;AACtE,EAAA,MAAMC,oBAAoB,GAAGC,MAAM,CAAiB,IAAI,CAAC,CAAA;AACzD,EAAA,MA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;AAC3B0C,QAAAA,WAAW,EAAEvC,WAAY;AACzBwC,QAAAA,UAAU,EAAEpC,UAAW;AACvBqC,QAAAA,WAAW,EAAE5C,YAAa;AAC1B6C,QAAAA,WAAW,EAAE1C,WAAY;AACzB2C,QAAAA,SAAS,EAAEvC,UAAW;AAAAsB,QAAAA,QAAA,gBAEtBU,IAAA,CAAA,KAAA,EAAA;AAAKL,UAAAA,GAAG,EAAEhE,eAAgB;AAAC0D,UAAAA,SAAS,EAAC,0BAA0B;AAAAC,UAAAA,QAAA,gBAC7DH,GAAA,CAAA,KAAA,EAAA;AAAKE,YAAAA,SAAS,EAAC,0BAAA;AAA0B,WACzC,CAAA,eAAAF,GAAA,CAACqB,WAAW,EAAA;AAACC,YAAAA,IAAI,EAAC,IAAI;AAACpB,YAAAA,SAAS,EAAC,oCAAoC;AAACqB,YAAAA,OAAO,EAAErD,KAAAA;AAAM,WACvF,CAAA,CAAA;SAAK,CACL,eAAA8B,GAAA,CAAA,KAAA,EAAA;AACEQ,UAAAA,GAAG,EAAE/D,gBAAiB;UACtBuB,KAAK,EAAEiB,mBAAmB,EAAG;AAC7BiB,UAAAA,SAAS,EAAC,0BAA0B;UAAAC,QAAA,EAEnC9D,KAAK,CAAC8D,QAAAA;AAAQ,SACZ,CACP,CAAA;OAAK,CAAA;KACO,CAAA;AAChB,GAAQ,CACT,CAAA;AACH;;;;"}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
const isDateValid = date => {
|
|
4
4
|
if (date === null) {
|
|
5
5
|
return false;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
|
+
if (date instanceof Date) {
|
|
7
8
|
return validDateObject(date);
|
|
8
|
-
} else {
|
|
9
|
-
return validDateString(date);
|
|
10
9
|
}
|
|
10
|
+
return validDateString(date);
|
|
11
11
|
};
|
|
12
12
|
const validDateString = dateString => validDateObject(new Date(dateString));
|
|
13
13
|
const validDateObject = dateObject => !isNaN(dateObject.getTime());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isDateValid.js","sources":["../../../../src/common/dateUtils/isDateValid/isDateValid.ts"],"sourcesContent":["export const isDateValid = (date: Date | string | null) => {\n if (date === null) {\n return false;\n }
|
|
1
|
+
{"version":3,"file":"isDateValid.js","sources":["../../../../src/common/dateUtils/isDateValid/isDateValid.ts"],"sourcesContent":["export const isDateValid = (date: Date | string | null) => {\n if (date === null) {\n return false;\n }\n\n if (date instanceof Date) {\n return validDateObject(date);\n }\n\n return validDateString(date);\n};\n\nexport const validDateString = (dateString: string) => validDateObject(new Date(dateString));\n\nconst validDateObject = (dateObject: Date) => !isNaN(dateObject.getTime());\n"],"names":["isDateValid","date","Date","validDateObject","validDateString","dateString","dateObject","isNaN","getTime"],"mappings":";;AAAaA,MAAAA,WAAW,GAAIC,IAA0B,IAAI;EACxD,IAAIA,IAAI,KAAK,IAAI,EAAE;AACjB,IAAA,OAAO,KAAK,CAAA;AACd,GAAA;EAEA,IAAIA,IAAI,YAAYC,IAAI,EAAE;IACxB,OAAOC,eAAe,CAACF,IAAI,CAAC,CAAA;AAC9B,GAAA;EAEA,OAAOG,eAAe,CAACH,IAAI,CAAC,CAAA;AAC9B,EAAC;AAEYG,MAAAA,eAAe,GAAIC,UAAkB,IAAKF,eAAe,CAAC,IAAID,IAAI,CAACG,UAAU,CAAC,EAAC;AAE5F,MAAMF,eAAe,GAAIG,UAAgB,IAAK,CAACC,KAAK,CAACD,UAAU,CAACE,OAAO,EAAE,CAAC;;;;;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const isDateValid = date => {
|
|
2
2
|
if (date === null) {
|
|
3
3
|
return false;
|
|
4
|
-
}
|
|
4
|
+
}
|
|
5
|
+
if (date instanceof Date) {
|
|
5
6
|
return validDateObject(date);
|
|
6
|
-
} else {
|
|
7
|
-
return validDateString(date);
|
|
8
7
|
}
|
|
8
|
+
return validDateString(date);
|
|
9
9
|
};
|
|
10
10
|
const validDateString = dateString => validDateObject(new Date(dateString));
|
|
11
11
|
const validDateObject = dateObject => !isNaN(dateObject.getTime());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isDateValid.mjs","sources":["../../../../src/common/dateUtils/isDateValid/isDateValid.ts"],"sourcesContent":["export const isDateValid = (date: Date | string | null) => {\n if (date === null) {\n return false;\n }
|
|
1
|
+
{"version":3,"file":"isDateValid.mjs","sources":["../../../../src/common/dateUtils/isDateValid/isDateValid.ts"],"sourcesContent":["export const isDateValid = (date: Date | string | null) => {\n if (date === null) {\n return false;\n }\n\n if (date instanceof Date) {\n return validDateObject(date);\n }\n\n return validDateString(date);\n};\n\nexport const validDateString = (dateString: string) => validDateObject(new Date(dateString));\n\nconst validDateObject = (dateObject: Date) => !isNaN(dateObject.getTime());\n"],"names":["isDateValid","date","Date","validDateObject","validDateString","dateString","dateObject","isNaN","getTime"],"mappings":"AAAaA,MAAAA,WAAW,GAAIC,IAA0B,IAAI;EACxD,IAAIA,IAAI,KAAK,IAAI,EAAE;AACjB,IAAA,OAAO,KAAK,CAAA;AACd,GAAA;EAEA,IAAIA,IAAI,YAAYC,IAAI,EAAE;IACxB,OAAOC,eAAe,CAACF,IAAI,CAAC,CAAA;AAC9B,GAAA;EAEA,OAAOG,eAAe,CAACH,IAAI,CAAC,CAAA;AAC9B,EAAC;AAEYG,MAAAA,eAAe,GAAIC,UAAkB,IAAKF,eAAe,CAAC,IAAID,IAAI,CAACG,UAAU,CAAC,EAAC;AAE5F,MAAMF,eAAe,GAAIG,UAAgB,IAAK,CAACC,KAAK,CAACD,UAAU,CAACE,OAAO,EAAE,CAAC;;;;"}
|
|
@@ -121,9 +121,7 @@ const Panel = /*#__PURE__*/React.forwardRef(function Panel({
|
|
|
121
121
|
id: overlayId,
|
|
122
122
|
...rest,
|
|
123
123
|
ref: setPopperElement,
|
|
124
|
-
role: "dialog"
|
|
125
|
-
// eslint-disable-next-line react/forbid-dom-props
|
|
126
|
-
,
|
|
124
|
+
role: "dialog",
|
|
127
125
|
style: {
|
|
128
126
|
...styles.popper
|
|
129
127
|
},
|
|
@@ -132,15 +130,12 @@ const Panel = /*#__PURE__*/React.forwardRef(function Panel({
|
|
|
132
130
|
'np-panel--open': open
|
|
133
131
|
}, rest.className),
|
|
134
132
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
135
|
-
ref: reference
|
|
136
|
-
/* eslint-disable-next-line react/forbid-dom-props */,
|
|
133
|
+
ref: reference,
|
|
137
134
|
style: contentStyle,
|
|
138
135
|
className: clsx.clsx('np-panel__content'),
|
|
139
136
|
children: [children, arrow && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
140
137
|
ref: setArrowElement,
|
|
141
|
-
className: clsx.clsx('np-panel__arrow')
|
|
142
|
-
// eslint-disable-next-line react/forbid-dom-props
|
|
143
|
-
,
|
|
138
|
+
className: clsx.clsx('np-panel__arrow'),
|
|
144
139
|
style: styles.arrow
|
|
145
140
|
})]
|
|
146
141
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Panel.js","sources":["../../../src/common/panel/Panel.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport {\n CSSProperties,\n HTMLAttributes,\n MutableRefObject,\n PropsWithChildren,\n SyntheticEvent,\n forwardRef,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { usePopper } from 'react-popper';\n\nimport { Position, PositionBottom, PositionLeft, PositionRight, PositionTop } from '..';\nimport Dimmer from '../../dimmer';\nimport { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';\n\nconst POPOVER_OFFSET = [0, 16];\n\n// By default the flip positioning explores only the opposite alternative. So if left is passed and there's no enough space\n// the right one gets chosen. If there's no space on both sides popover goes back to the initially chosen one left.\n// This mapping forces popover to try the four available positions before going back to the initial chosen one.\nconst fallbackPlacements = {\n [Position.TOP]: [Position.BOTTOM, Position.RIGHT, Position.LEFT],\n [Position.BOTTOM]: [Position.TOP, Position.RIGHT, Position.LEFT],\n [Position.LEFT]: [Position.RIGHT, Position.TOP, Position.BOTTOM],\n [Position.RIGHT]: [Position.LEFT, Position.TOP, Position.BOTTOM],\n};\n\nexport type PanelProps = PropsWithChildren<{\n arrow?: boolean;\n flip?: boolean;\n altAxis?: boolean;\n open?: boolean;\n onClose?: (event: Event | SyntheticEvent) => void;\n position?: PositionBottom | PositionLeft | PositionRight | PositionTop;\n anchorRef: MutableRefObject<Element | null>;\n anchorWidth?: boolean;\n}> &\n HTMLAttributes<HTMLDivElement>;\n\nconst Panel = forwardRef<HTMLDivElement, PanelProps>(function Panel(\n {\n arrow = false,\n flip = true,\n altAxis = false,\n children,\n open = false,\n onClose,\n position = Position.BOTTOM,\n anchorRef,\n anchorWidth = false,\n ...rest\n }: PanelProps,\n reference,\n) {\n const [arrowElement, setArrowElement] = useState<HTMLDivElement | null>(null);\n const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null);\n\n const modifiers = [];\n\n if (altAxis) {\n modifiers.push({\n // https://popper.js.org/docs/v2/modifiers/prevent-overflow\n name: 'preventOverflow',\n options: {\n altAxis: true,\n tether: false,\n },\n });\n }\n\n if (arrow) {\n modifiers.push({\n name: 'arrow',\n options: {\n element: arrowElement,\n options: {\n padding: 8, // 8px from the edges of the popper\n },\n },\n });\n // This lets you displace a popper element from its reference element.\n modifiers.push({ name: 'offset', options: { offset: POPOVER_OFFSET } });\n }\n if (flip && fallbackPlacements[position]) {\n modifiers.push({\n name: 'flip',\n options: {\n fallbackPlacements: fallbackPlacements[position],\n },\n });\n }\n\n const { styles, attributes, forceUpdate } = usePopper(anchorRef.current, popperElement, {\n placement: position,\n modifiers,\n });\n\n // If the trigger is not visible when the position is calculated, it will be incorrect. Because this can happen repeatedly (on resize for example),\n // it is most simple just to always position before opening\n useEffect(() => {\n if (open && forceUpdate) {\n forceUpdate();\n }\n }, [open]);\n\n const contentStyle: CSSProperties = {\n ...(anchorWidth ? { width: anchorRef.current?.clientWidth } : undefined),\n };\n\n const overlayId = useContext(OverlayIdContext);\n\n return (\n <Dimmer open={open} transparent fadeContentOnEnter fadeContentOnExit onClose={onClose}>\n <div\n id={overlayId}\n {...rest}\n ref={setPopperElement}\n role=\"dialog\"\n
|
|
1
|
+
{"version":3,"file":"Panel.js","sources":["../../../src/common/panel/Panel.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport {\n CSSProperties,\n HTMLAttributes,\n MutableRefObject,\n PropsWithChildren,\n SyntheticEvent,\n forwardRef,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { usePopper } from 'react-popper';\n\nimport { Position, PositionBottom, PositionLeft, PositionRight, PositionTop } from '..';\nimport Dimmer from '../../dimmer';\nimport { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';\n\nconst POPOVER_OFFSET = [0, 16];\n\n// By default the flip positioning explores only the opposite alternative. So if left is passed and there's no enough space\n// the right one gets chosen. If there's no space on both sides popover goes back to the initially chosen one left.\n// This mapping forces popover to try the four available positions before going back to the initial chosen one.\nconst fallbackPlacements = {\n [Position.TOP]: [Position.BOTTOM, Position.RIGHT, Position.LEFT],\n [Position.BOTTOM]: [Position.TOP, Position.RIGHT, Position.LEFT],\n [Position.LEFT]: [Position.RIGHT, Position.TOP, Position.BOTTOM],\n [Position.RIGHT]: [Position.LEFT, Position.TOP, Position.BOTTOM],\n};\n\nexport type PanelProps = PropsWithChildren<{\n arrow?: boolean;\n flip?: boolean;\n altAxis?: boolean;\n open?: boolean;\n onClose?: (event: Event | SyntheticEvent) => void;\n position?: PositionBottom | PositionLeft | PositionRight | PositionTop;\n anchorRef: MutableRefObject<Element | null>;\n anchorWidth?: boolean;\n}> &\n HTMLAttributes<HTMLDivElement>;\n\nconst Panel = forwardRef<HTMLDivElement, PanelProps>(function Panel(\n {\n arrow = false,\n flip = true,\n altAxis = false,\n children,\n open = false,\n onClose,\n position = Position.BOTTOM,\n anchorRef,\n anchorWidth = false,\n ...rest\n }: PanelProps,\n reference,\n) {\n const [arrowElement, setArrowElement] = useState<HTMLDivElement | null>(null);\n const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null);\n\n const modifiers = [];\n\n if (altAxis) {\n modifiers.push({\n // https://popper.js.org/docs/v2/modifiers/prevent-overflow\n name: 'preventOverflow',\n options: {\n altAxis: true,\n tether: false,\n },\n });\n }\n\n if (arrow) {\n modifiers.push({\n name: 'arrow',\n options: {\n element: arrowElement,\n options: {\n padding: 8, // 8px from the edges of the popper\n },\n },\n });\n // This lets you displace a popper element from its reference element.\n modifiers.push({ name: 'offset', options: { offset: POPOVER_OFFSET } });\n }\n if (flip && fallbackPlacements[position]) {\n modifiers.push({\n name: 'flip',\n options: {\n fallbackPlacements: fallbackPlacements[position],\n },\n });\n }\n\n const { styles, attributes, forceUpdate } = usePopper(anchorRef.current, popperElement, {\n placement: position,\n modifiers,\n });\n\n // If the trigger is not visible when the position is calculated, it will be incorrect. Because this can happen repeatedly (on resize for example),\n // it is most simple just to always position before opening\n useEffect(() => {\n if (open && forceUpdate) {\n forceUpdate();\n }\n }, [open]);\n\n const contentStyle: CSSProperties = {\n ...(anchorWidth ? { width: anchorRef.current?.clientWidth } : undefined),\n };\n\n const overlayId = useContext(OverlayIdContext);\n\n return (\n <Dimmer open={open} transparent fadeContentOnEnter fadeContentOnExit onClose={onClose}>\n <div\n id={overlayId}\n {...rest}\n ref={setPopperElement}\n role=\"dialog\"\n style={{ ...styles.popper }}\n {...attributes.popper}\n className={clsx('np-panel', { 'np-panel--open': open }, rest.className)}\n >\n <div ref={reference} style={contentStyle} className={clsx('np-panel__content')}>\n {children}\n {/* Arrow has to stay inside content to get the same animations as the \"dialog\" and to get hidden when panel is closed. */}\n {arrow && (\n <div ref={setArrowElement} className={clsx('np-panel__arrow')} style={styles.arrow} />\n )}\n </div>\n </div>\n </Dimmer>\n );\n});\n\nexport default Panel;\n"],"names":["POPOVER_OFFSET","fallbackPlacements","Position","TOP","BOTTOM","RIGHT","LEFT","Panel","forwardRef","arrow","flip","altAxis","children","open","onClose","position","anchorRef","anchorWidth","rest","reference","arrowElement","setArrowElement","useState","popperElement","setPopperElement","modifiers","push","name","options","tether","element","padding","offset","styles","attributes","forceUpdate","usePopper","current","placement","useEffect","contentStyle","width","clientWidth","undefined","overlayId","useContext","OverlayIdContext","_jsx","Dimmer","transparent","fadeContentOnEnter","fadeContentOnExit","id","ref","role","style","popper","className","clsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAMA,cAAc,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAE9B;AACA;AACA;AACA,MAAMC,kBAAkB,GAAG;AACzB,EAAA,CAACC,iBAAQ,CAACC,GAAG,GAAG,CAACD,iBAAQ,CAACE,MAAM,EAAEF,iBAAQ,CAACG,KAAK,EAAEH,iBAAQ,CAACI,IAAI,CAAC;AAChE,EAAA,CAACJ,iBAAQ,CAACE,MAAM,GAAG,CAACF,iBAAQ,CAACC,GAAG,EAAED,iBAAQ,CAACG,KAAK,EAAEH,iBAAQ,CAACI,IAAI,CAAC;AAChE,EAAA,CAACJ,iBAAQ,CAACI,IAAI,GAAG,CAACJ,iBAAQ,CAACG,KAAK,EAAEH,iBAAQ,CAACC,GAAG,EAAED,iBAAQ,CAACE,MAAM,CAAC;AAChE,EAAA,CAACF,iBAAQ,CAACG,KAAK,GAAG,CAACH,iBAAQ,CAACI,IAAI,EAAEJ,iBAAQ,CAACC,GAAG,EAAED,iBAAQ,CAACE,MAAM,CAAA;CAChE,CAAA;AAcD,MAAMG,KAAK,gBAAGC,gBAAU,CAA6B,SAASD,KAAKA,CACjE;AACEE,EAAAA,KAAK,GAAG,KAAK;AACbC,EAAAA,IAAI,GAAG,IAAI;AACXC,EAAAA,OAAO,GAAG,KAAK;EACfC,QAAQ;AACRC,EAAAA,IAAI,GAAG,KAAK;EACZC,OAAO;YACPC,UAAQ,GAAGb,iBAAQ,CAACE,MAAM;EAC1BY,SAAS;AACTC,EAAAA,WAAW,GAAG,KAAK;EACnB,GAAGC,IAAAA;AAAI,CACI,EACbC,SAAS,EAAA;EA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Aa;AAACiB,QAAAA,SAAS,EAAEC,SAAI,CAAC,mBAAmB,CAAE;AAAA9C,QAAAA,QAAA,EAC5EA,CAAAA,QAAQ,EAERH,KAAK,iBACJsC,cAAA,CAAA,KAAA,EAAA;AAAKM,UAAAA,GAAG,EAAEhC,eAAgB;AAACoC,UAAAA,SAAS,EAAEC,SAAI,CAAC,iBAAiB,CAAE;UAACH,KAAK,EAAEtB,MAAM,CAACxB,KAAAA;AAAM,SAAA,CACpF,CAAA;OACE,CAAA;KACF,CAAA;AACP,GAAQ,CAAC,CAAA;AAEb,CAAC;;;;"}
|
|
@@ -119,9 +119,7 @@ const Panel = /*#__PURE__*/forwardRef(function Panel({
|
|
|
119
119
|
id: overlayId,
|
|
120
120
|
...rest,
|
|
121
121
|
ref: setPopperElement,
|
|
122
|
-
role: "dialog"
|
|
123
|
-
// eslint-disable-next-line react/forbid-dom-props
|
|
124
|
-
,
|
|
122
|
+
role: "dialog",
|
|
125
123
|
style: {
|
|
126
124
|
...styles.popper
|
|
127
125
|
},
|
|
@@ -130,15 +128,12 @@ const Panel = /*#__PURE__*/forwardRef(function Panel({
|
|
|
130
128
|
'np-panel--open': open
|
|
131
129
|
}, rest.className),
|
|
132
130
|
children: /*#__PURE__*/jsxs("div", {
|
|
133
|
-
ref: reference
|
|
134
|
-
/* eslint-disable-next-line react/forbid-dom-props */,
|
|
131
|
+
ref: reference,
|
|
135
132
|
style: contentStyle,
|
|
136
133
|
className: clsx('np-panel__content'),
|
|
137
134
|
children: [children, arrow && /*#__PURE__*/jsx("div", {
|
|
138
135
|
ref: setArrowElement,
|
|
139
|
-
className: clsx('np-panel__arrow')
|
|
140
|
-
// eslint-disable-next-line react/forbid-dom-props
|
|
141
|
-
,
|
|
136
|
+
className: clsx('np-panel__arrow'),
|
|
142
137
|
style: styles.arrow
|
|
143
138
|
})]
|
|
144
139
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Panel.mjs","sources":["../../../src/common/panel/Panel.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport {\n CSSProperties,\n HTMLAttributes,\n MutableRefObject,\n PropsWithChildren,\n SyntheticEvent,\n forwardRef,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { usePopper } from 'react-popper';\n\nimport { Position, PositionBottom, PositionLeft, PositionRight, PositionTop } from '..';\nimport Dimmer from '../../dimmer';\nimport { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';\n\nconst POPOVER_OFFSET = [0, 16];\n\n// By default the flip positioning explores only the opposite alternative. So if left is passed and there's no enough space\n// the right one gets chosen. If there's no space on both sides popover goes back to the initially chosen one left.\n// This mapping forces popover to try the four available positions before going back to the initial chosen one.\nconst fallbackPlacements = {\n [Position.TOP]: [Position.BOTTOM, Position.RIGHT, Position.LEFT],\n [Position.BOTTOM]: [Position.TOP, Position.RIGHT, Position.LEFT],\n [Position.LEFT]: [Position.RIGHT, Position.TOP, Position.BOTTOM],\n [Position.RIGHT]: [Position.LEFT, Position.TOP, Position.BOTTOM],\n};\n\nexport type PanelProps = PropsWithChildren<{\n arrow?: boolean;\n flip?: boolean;\n altAxis?: boolean;\n open?: boolean;\n onClose?: (event: Event | SyntheticEvent) => void;\n position?: PositionBottom | PositionLeft | PositionRight | PositionTop;\n anchorRef: MutableRefObject<Element | null>;\n anchorWidth?: boolean;\n}> &\n HTMLAttributes<HTMLDivElement>;\n\nconst Panel = forwardRef<HTMLDivElement, PanelProps>(function Panel(\n {\n arrow = false,\n flip = true,\n altAxis = false,\n children,\n open = false,\n onClose,\n position = Position.BOTTOM,\n anchorRef,\n anchorWidth = false,\n ...rest\n }: PanelProps,\n reference,\n) {\n const [arrowElement, setArrowElement] = useState<HTMLDivElement | null>(null);\n const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null);\n\n const modifiers = [];\n\n if (altAxis) {\n modifiers.push({\n // https://popper.js.org/docs/v2/modifiers/prevent-overflow\n name: 'preventOverflow',\n options: {\n altAxis: true,\n tether: false,\n },\n });\n }\n\n if (arrow) {\n modifiers.push({\n name: 'arrow',\n options: {\n element: arrowElement,\n options: {\n padding: 8, // 8px from the edges of the popper\n },\n },\n });\n // This lets you displace a popper element from its reference element.\n modifiers.push({ name: 'offset', options: { offset: POPOVER_OFFSET } });\n }\n if (flip && fallbackPlacements[position]) {\n modifiers.push({\n name: 'flip',\n options: {\n fallbackPlacements: fallbackPlacements[position],\n },\n });\n }\n\n const { styles, attributes, forceUpdate } = usePopper(anchorRef.current, popperElement, {\n placement: position,\n modifiers,\n });\n\n // If the trigger is not visible when the position is calculated, it will be incorrect. Because this can happen repeatedly (on resize for example),\n // it is most simple just to always position before opening\n useEffect(() => {\n if (open && forceUpdate) {\n forceUpdate();\n }\n }, [open]);\n\n const contentStyle: CSSProperties = {\n ...(anchorWidth ? { width: anchorRef.current?.clientWidth } : undefined),\n };\n\n const overlayId = useContext(OverlayIdContext);\n\n return (\n <Dimmer open={open} transparent fadeContentOnEnter fadeContentOnExit onClose={onClose}>\n <div\n id={overlayId}\n {...rest}\n ref={setPopperElement}\n role=\"dialog\"\n
|
|
1
|
+
{"version":3,"file":"Panel.mjs","sources":["../../../src/common/panel/Panel.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport {\n CSSProperties,\n HTMLAttributes,\n MutableRefObject,\n PropsWithChildren,\n SyntheticEvent,\n forwardRef,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { usePopper } from 'react-popper';\n\nimport { Position, PositionBottom, PositionLeft, PositionRight, PositionTop } from '..';\nimport Dimmer from '../../dimmer';\nimport { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';\n\nconst POPOVER_OFFSET = [0, 16];\n\n// By default the flip positioning explores only the opposite alternative. So if left is passed and there's no enough space\n// the right one gets chosen. If there's no space on both sides popover goes back to the initially chosen one left.\n// This mapping forces popover to try the four available positions before going back to the initial chosen one.\nconst fallbackPlacements = {\n [Position.TOP]: [Position.BOTTOM, Position.RIGHT, Position.LEFT],\n [Position.BOTTOM]: [Position.TOP, Position.RIGHT, Position.LEFT],\n [Position.LEFT]: [Position.RIGHT, Position.TOP, Position.BOTTOM],\n [Position.RIGHT]: [Position.LEFT, Position.TOP, Position.BOTTOM],\n};\n\nexport type PanelProps = PropsWithChildren<{\n arrow?: boolean;\n flip?: boolean;\n altAxis?: boolean;\n open?: boolean;\n onClose?: (event: Event | SyntheticEvent) => void;\n position?: PositionBottom | PositionLeft | PositionRight | PositionTop;\n anchorRef: MutableRefObject<Element | null>;\n anchorWidth?: boolean;\n}> &\n HTMLAttributes<HTMLDivElement>;\n\nconst Panel = forwardRef<HTMLDivElement, PanelProps>(function Panel(\n {\n arrow = false,\n flip = true,\n altAxis = false,\n children,\n open = false,\n onClose,\n position = Position.BOTTOM,\n anchorRef,\n anchorWidth = false,\n ...rest\n }: PanelProps,\n reference,\n) {\n const [arrowElement, setArrowElement] = useState<HTMLDivElement | null>(null);\n const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null);\n\n const modifiers = [];\n\n if (altAxis) {\n modifiers.push({\n // https://popper.js.org/docs/v2/modifiers/prevent-overflow\n name: 'preventOverflow',\n options: {\n altAxis: true,\n tether: false,\n },\n });\n }\n\n if (arrow) {\n modifiers.push({\n name: 'arrow',\n options: {\n element: arrowElement,\n options: {\n padding: 8, // 8px from the edges of the popper\n },\n },\n });\n // This lets you displace a popper element from its reference element.\n modifiers.push({ name: 'offset', options: { offset: POPOVER_OFFSET } });\n }\n if (flip && fallbackPlacements[position]) {\n modifiers.push({\n name: 'flip',\n options: {\n fallbackPlacements: fallbackPlacements[position],\n },\n });\n }\n\n const { styles, attributes, forceUpdate } = usePopper(anchorRef.current, popperElement, {\n placement: position,\n modifiers,\n });\n\n // If the trigger is not visible when the position is calculated, it will be incorrect. Because this can happen repeatedly (on resize for example),\n // it is most simple just to always position before opening\n useEffect(() => {\n if (open && forceUpdate) {\n forceUpdate();\n }\n }, [open]);\n\n const contentStyle: CSSProperties = {\n ...(anchorWidth ? { width: anchorRef.current?.clientWidth } : undefined),\n };\n\n const overlayId = useContext(OverlayIdContext);\n\n return (\n <Dimmer open={open} transparent fadeContentOnEnter fadeContentOnExit onClose={onClose}>\n <div\n id={overlayId}\n {...rest}\n ref={setPopperElement}\n role=\"dialog\"\n style={{ ...styles.popper }}\n {...attributes.popper}\n className={clsx('np-panel', { 'np-panel--open': open }, rest.className)}\n >\n <div ref={reference} style={contentStyle} className={clsx('np-panel__content')}>\n {children}\n {/* Arrow has to stay inside content to get the same animations as the \"dialog\" and to get hidden when panel is closed. */}\n {arrow && (\n <div ref={setArrowElement} className={clsx('np-panel__arrow')} style={styles.arrow} />\n )}\n </div>\n </div>\n </Dimmer>\n );\n});\n\nexport default Panel;\n"],"names":["POPOVER_OFFSET","fallbackPlacements","Position","TOP","BOTTOM","RIGHT","LEFT","Panel","forwardRef","arrow","flip","altAxis","children","open","onClose","position","anchorRef","anchorWidth","rest","reference","arrowElement","setArrowElement","useState","popperElement","setPopperElement","modifiers","push","name","options","tether","element","padding","offset","styles","attributes","forceUpdate","usePopper","current","placement","useEffect","contentStyle","width","clientWidth","undefined","overlayId","useContext","OverlayIdContext","_jsx","Dimmer","transparent","fadeContentOnEnter","fadeContentOnExit","id","ref","role","style","popper","className","clsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAMA,cAAc,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAE9B;AACA;AACA;AACA,MAAMC,kBAAkB,GAAG;AACzB,EAAA,CAACC,QAAQ,CAACC,GAAG,GAAG,CAACD,QAAQ,CAACE,MAAM,EAAEF,QAAQ,CAACG,KAAK,EAAEH,QAAQ,CAACI,IAAI,CAAC;AAChE,EAAA,CAACJ,QAAQ,CAACE,MAAM,GAAG,CAACF,QAAQ,CAACC,GAAG,EAAED,QAAQ,CAACG,KAAK,EAAEH,QAAQ,CAACI,IAAI,CAAC;AAChE,EAAA,CAACJ,QAAQ,CAACI,IAAI,GAAG,CAACJ,QAAQ,CAACG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AEA,OAAQ;AAAAF,IAAAA,QAAA,eACpFmC,GAAA,CAAA,KAAA,EAAA;AACEK,MAAAA,EAAE,EAAER,SAAU;AAAA,MAAA,GACV1B,IAAI;AACRmC,MAAAA,GAAG,EAAE7B,gBAAiB;AACtB8B,MAAAA,IAAI,EAAC,QAAQ;AACbC,MAAAA,KAAK,EAAE;AAAE,QAAA,GAAGtB,MAAM,CAACuB,MAAAA;OAAS;MAAA,GACxBtB,UAAU,CAACsB,MAAM;AACrBC,MAAAA,SAAS,EAAEC,IAAI,CAAC,UAAU,EAAE;AAAE,QAAA,gBAAgB,EAAE7C,IAAAA;AAAI,OAAE,EAAEK,IAAI,CAACuC,SAAS,CAAE;AAAA7C,MAAAA,QAAA,eAExE+C,IAAA,CAAA,KAAA,EAAA;AAAKN,QAAAA,GAAG,EAAElC,SAAU;AAACoC,QAAAA,KAAK,EAAEf,YAAa;AAACiB,QAAAA,SAAS,EAAEC,IAAI,CAAC,mBAAmB,CAAE;AAAA9C,QAAAA,QAAA,EAC5EA,CAAAA,QAAQ,EAERH,KAAK,iBACJsC,GAAA,CAAA,KAAA,EAAA;AAAKM,UAAAA,GAAG,EAAEhC,eAAgB;AAACoC,UAAAA,SAAS,EAAEC,IAAI,CAAC,iBAAiB,CAAE;UAACH,KAAK,EAAEtB,MAAM,CAACxB,KAAAA;AAAM,SAAA,CACpF,CAAA;OACE,CAAA;KACF,CAAA;AACP,GAAQ,CAAC,CAAA;AAEb,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DimmerManager.js","sources":["../../../src/dimmer/dimmerManager/DimmerManager.ts"],"sourcesContent":["/**\n * Dimmer state management inspired by Material UI's ModalManager (https://github.com/mui-org/material-ui)\n */\nexport default class DimmerManager {\n /**\n * Dimmer refs\n */\n private dimmers: Element[];\n\n constructor() {\n this.dimmers = [];\n }\n\n add(dimmer: Element): number {\n let dimmerIndex = this.dimmers.indexOf(dimmer);\n if (dimmerIndex !== -1) {\n return dimmerIndex;\n }\n\n dimmerIndex = this.dimmers.length;\n this.dimmers.push(dimmer);\n return dimmerIndex;\n }\n\n remove(dimmer: Element): number {\n const dimmerIndex = this.dimmers.indexOf(dimmer);\n\n if (dimmerIndex !== -1) {\n this.dimmers.splice(dimmerIndex, 1);\n }\n return dimmerIndex;\n }\n\n isTop(dimmer: Element): boolean {\n return this.dimmers.length > 0 && this.dimmers[this.dimmers.length - 1] === dimmer;\n }\n}\n"],"names":["DimmerManager","dimmers","constructor","add","dimmer","dimmerIndex","indexOf","length","push","remove","splice","isTop"],"mappings":";;AAAA;;AAEG;AACW,MAAOA,aAAa,CAAA;AAChC;;AAEG;
|
|
1
|
+
{"version":3,"file":"DimmerManager.js","sources":["../../../src/dimmer/dimmerManager/DimmerManager.ts"],"sourcesContent":["/**\n * Dimmer state management inspired by Material UI's ModalManager (https://github.com/mui-org/material-ui)\n */\nexport default class DimmerManager {\n /**\n * Dimmer refs\n */\n private readonly dimmers: Element[];\n\n constructor() {\n this.dimmers = [];\n }\n\n add(dimmer: Element): number {\n let dimmerIndex = this.dimmers.indexOf(dimmer);\n if (dimmerIndex !== -1) {\n return dimmerIndex;\n }\n\n dimmerIndex = this.dimmers.length;\n this.dimmers.push(dimmer);\n return dimmerIndex;\n }\n\n remove(dimmer: Element): number {\n const dimmerIndex = this.dimmers.indexOf(dimmer);\n\n if (dimmerIndex !== -1) {\n this.dimmers.splice(dimmerIndex, 1);\n }\n return dimmerIndex;\n }\n\n isTop(dimmer: Element): boolean {\n return this.dimmers.length > 0 && this.dimmers[this.dimmers.length - 1] === dimmer;\n }\n}\n"],"names":["DimmerManager","dimmers","constructor","add","dimmer","dimmerIndex","indexOf","length","push","remove","splice","isTop"],"mappings":";;AAAA;;AAEG;AACW,MAAOA,aAAa,CAAA;AAChC;;AAEG;EACcC,OAAO,CAAA;AAExBC,EAAAA,WAAAA,GAAA;IACE,IAAI,CAACD,OAAO,GAAG,EAAE,CAAA;AACnB,GAAA;EAEAE,GAAGA,CAACC,MAAe,EAAA;IACjB,IAAIC,WAAW,GAAG,IAAI,CAACJ,OAAO,CAACK,OAAO,CAACF,MAAM,CAAC,CAAA;AAC9C,IAAA,IAAIC,WAAW,KAAK,CAAC,CAAC,EAAE;AACtB,MAAA,OAAOA,WAAW,CAAA;AACpB,KAAA;AAEAA,IAAAA,WAAW,GAAG,IAAI,CAACJ,OAAO,CAACM,MAAM,CAAA;AACjC,IAAA,IAAI,CAACN,OAAO,CAACO,IAAI,CAACJ,MAAM,CAAC,CAAA;AACzB,IAAA,OAAOC,WAAW,CAAA;AACpB,GAAA;EAEAI,MAAMA,CAACL,MAAe,EAAA;IACpB,MAAMC,WAAW,GAAG,IAAI,CAACJ,OAAO,CAACK,OAAO,CAACF,MAAM,CAAC,CAAA;AAEhD,IAAA,IAAIC,WAAW,KAAK,CAAC,CAAC,EAAE;MACtB,IAAI,CAACJ,OAAO,CAACS,MAAM,CAACL,WAAW,EAAE,CAAC,CAAC,CAAA;AACrC,KAAA;AACA,IAAA,OAAOA,WAAW,CAAA;AACpB,GAAA;EAEAM,KAAKA,CAACP,MAAe,EAAA;IACnB,OAAO,IAAI,CAACH,OAAO,CAACM,MAAM,GAAG,CAAC,IAAI,IAAI,CAACN,OAAO,CAAC,IAAI,CAACA,OAAO,CAACM,MAAM,GAAG,CAAC,CAAC,KAAKH,MAAM,CAAA;AACpF,GAAA;AACD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DimmerManager.mjs","sources":["../../../src/dimmer/dimmerManager/DimmerManager.ts"],"sourcesContent":["/**\n * Dimmer state management inspired by Material UI's ModalManager (https://github.com/mui-org/material-ui)\n */\nexport default class DimmerManager {\n /**\n * Dimmer refs\n */\n private dimmers: Element[];\n\n constructor() {\n this.dimmers = [];\n }\n\n add(dimmer: Element): number {\n let dimmerIndex = this.dimmers.indexOf(dimmer);\n if (dimmerIndex !== -1) {\n return dimmerIndex;\n }\n\n dimmerIndex = this.dimmers.length;\n this.dimmers.push(dimmer);\n return dimmerIndex;\n }\n\n remove(dimmer: Element): number {\n const dimmerIndex = this.dimmers.indexOf(dimmer);\n\n if (dimmerIndex !== -1) {\n this.dimmers.splice(dimmerIndex, 1);\n }\n return dimmerIndex;\n }\n\n isTop(dimmer: Element): boolean {\n return this.dimmers.length > 0 && this.dimmers[this.dimmers.length - 1] === dimmer;\n }\n}\n"],"names":["DimmerManager","dimmers","constructor","add","dimmer","dimmerIndex","indexOf","length","push","remove","splice","isTop"],"mappings":"AAAA;;AAEG;AACW,MAAOA,aAAa,CAAA;AAChC;;AAEG;
|
|
1
|
+
{"version":3,"file":"DimmerManager.mjs","sources":["../../../src/dimmer/dimmerManager/DimmerManager.ts"],"sourcesContent":["/**\n * Dimmer state management inspired by Material UI's ModalManager (https://github.com/mui-org/material-ui)\n */\nexport default class DimmerManager {\n /**\n * Dimmer refs\n */\n private readonly dimmers: Element[];\n\n constructor() {\n this.dimmers = [];\n }\n\n add(dimmer: Element): number {\n let dimmerIndex = this.dimmers.indexOf(dimmer);\n if (dimmerIndex !== -1) {\n return dimmerIndex;\n }\n\n dimmerIndex = this.dimmers.length;\n this.dimmers.push(dimmer);\n return dimmerIndex;\n }\n\n remove(dimmer: Element): number {\n const dimmerIndex = this.dimmers.indexOf(dimmer);\n\n if (dimmerIndex !== -1) {\n this.dimmers.splice(dimmerIndex, 1);\n }\n return dimmerIndex;\n }\n\n isTop(dimmer: Element): boolean {\n return this.dimmers.length > 0 && this.dimmers[this.dimmers.length - 1] === dimmer;\n }\n}\n"],"names":["DimmerManager","dimmers","constructor","add","dimmer","dimmerIndex","indexOf","length","push","remove","splice","isTop"],"mappings":"AAAA;;AAEG;AACW,MAAOA,aAAa,CAAA;AAChC;;AAEG;EACcC,OAAO,CAAA;AAExBC,EAAAA,WAAAA,GAAA;IACE,IAAI,CAACD,OAAO,GAAG,EAAE,CAAA;AACnB,GAAA;EAEAE,GAAGA,CAACC,MAAe,EAAA;IACjB,IAAIC,WAAW,GAAG,IAAI,CAACJ,OAAO,CAACK,OAAO,CAACF,MAAM,CAAC,CAAA;AAC9C,IAAA,IAAIC,WAAW,KAAK,CAAC,CAAC,EAAE;AACtB,MAAA,OAAOA,WAAW,CAAA;AACpB,KAAA;AAEAA,IAAAA,WAAW,GAAG,IAAI,CAACJ,OAAO,CAACM,MAAM,CAAA;AACjC,IAAA,IAAI,CAACN,OAAO,CAACO,IAAI,CAACJ,MAAM,CAAC,CAAA;AACzB,IAAA,OAAOC,WAAW,CAAA;AACpB,GAAA;EAEAI,MAAMA,CAACL,MAAe,EAAA;IACpB,MAAMC,WAAW,GAAG,IAAI,CAACJ,OAAO,CAACK,OAAO,CAACF,MAAM,CAAC,CAAA;AAEhD,IAAA,IAAIC,WAAW,KAAK,CAAC,CAAC,EAAE;MACtB,IAAI,CAACJ,OAAO,CAACS,MAAM,CAACL,WAAW,EAAE,CAAC,CAAC,CAAA;AACrC,KAAA;AACA,IAAA,OAAOA,WAAW,CAAA;AACpB,GAAA;EAEAM,KAAKA,CAACP,MAAe,EAAA;IACnB,OAAO,IAAI,CAACH,OAAO,CAACM,MAAM,GAAG,CAAC,IAAI,IAAI,CAACN,OAAO,CAAC,IAAI,CAACA,OAAO,CAACM,MAAM,GAAG,CAAC,CAAC,KAAKH,MAAM,CAAA;AACpF,GAAA;AACD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropFade.js","sources":["../../src/dropFade/DropFade.tsx"],"sourcesContent":["import React, { useRef, useState, ReactElement } from 'react';\nimport { CSSTransition } from 'react-transition-group';\n\nconst DropFade = ({ children, show }: { children: ReactElement; show: boolean }) => {\n const reference = useRef<HTMLDivElement>(null);\n const [height, setHeight] = useState<number | undefined>(0);\n\n const clonedChild = React.cloneElement(children);\n\n return (\n <CSSTransition\n nodeRef={reference}\n in={show}\n timeout={300}\n classNames=\"np-dropfade\"\n onEntering={() => {\n // Set height so we can animate to the correct height\n setHeight(reference.current?.scrollHeight || 0);\n }}\n // Un-set height, as we don't want to presume it should be that height forever\n onEntered={() => setHeight(undefined)}\n onExit={() => {\n setHeight(reference.current?.scrollHeight || 0);\n }}\n onExiting={() => {\n setHeight(0);\n }}\n >\n
|
|
1
|
+
{"version":3,"file":"DropFade.js","sources":["../../src/dropFade/DropFade.tsx"],"sourcesContent":["import React, { useRef, useState, ReactElement } from 'react';\nimport { CSSTransition } from 'react-transition-group';\n\nconst DropFade = ({ children, show }: { children: ReactElement; show: boolean }) => {\n const reference = useRef<HTMLDivElement>(null);\n const [height, setHeight] = useState<number | undefined>(0);\n\n const clonedChild = React.cloneElement(children);\n\n return (\n <CSSTransition\n nodeRef={reference}\n in={show}\n timeout={300}\n classNames=\"np-dropfade\"\n onEntering={() => {\n // Set height so we can animate to the correct height\n setHeight(reference.current?.scrollHeight || 0);\n }}\n // Un-set height, as we don't want to presume it should be that height forever\n onEntered={() => setHeight(undefined)}\n onExit={() => {\n setHeight(reference.current?.scrollHeight || 0);\n }}\n onExiting={() => {\n setHeight(0);\n }}\n >\n <div ref={reference} style={{ height }} className=\"np-dropfade\">\n {clonedChild}\n </div>\n </CSSTransition>\n );\n};\n\nexport default DropFade;\n"],"names":["DropFade","children","show","reference","useRef","height","setHeight","useState","clonedChild","React","cloneElement","_jsx","CSSTransition","nodeRef","in","timeout","classNames","onEntering","current","scrollHeight","onEntered","undefined","onExit","onExiting","ref","style","className"],"mappings":";;;;;;;;;;AAGMA,MAAAA,QAAQ,GAAGA,CAAC;EAAEC,QAAQ;AAAEC,EAAAA,IAAAA;AAAiD,CAAA,KAAI;AACjF,EAAA,MAAMC,SAAS,GAAGC,YAAM,CAAiB,IAAI,CAAC,CAAA;EAC9C,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAGC,cAAQ,CAAqB,CAAC,CAAC,CAAA;AAE3D,EAAA,MAAMC,WAAW,gBAAGC,sBAAK,CAACC,YAAY,CAACT,QAAQ,CAAC,CAAA;EAEhD,oBACEU,cAAA,CAACC,kCAAa,EAAA;AACZC,IAAAA,OAAO,EAAEV,SAAU;AACnBW,IAAAA,EAAE,EAAEZ,IAAK;AACTa,IAAAA,OAAO,EAAE,GAAI;AACbC,IAAAA,UAAU,EAAC,aAAa;IACxBC,UAAU,EAAEA,MAAK;AACf;MACAX,SAAS,CAACH,SAAS,CAACe,OAAO,EAAEC,YAAY,IAAI,CAAC,CAAC,CAAA;AACjD,KAAA;AACA;AAAA;AACAC,IAAAA,SAAS,EAAEA,MAAMd,SAAS,CAACe,SAAS,CAAE;IACtCC,MAAM,EAAEA,MAAK;MACXhB,SAAS,CAACH,SAAS,CAACe,OAAO,EAAEC,YAAY,IAAI,CAAC,CAAC,CAAA;KAC/C;IACFI,SAAS,EAAEA,MAAK;MACdjB,SAAS,CAAC,CAAC,CAAC,CAAA;KACZ;AAAAL,IAAAA,QAAA,eAEFU,cAAA,CAAA,KAAA,EAAA;AAAKa,MAAAA,GAAG,EAAErB,SAAU;AAACsB,MAAAA,KAAK,EAAE;AAAEpB,QAAAA,MAAAA;OAAS;AAACqB,MAAAA,SAAS,EAAC,aAAa;AAAAzB,MAAAA,QAAA,EAC5DO,WAAAA;KACE,CAAA;AACP,GAAe,CAAC,CAAA;AAEpB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropFade.mjs","sources":["../../src/dropFade/DropFade.tsx"],"sourcesContent":["import React, { useRef, useState, ReactElement } from 'react';\nimport { CSSTransition } from 'react-transition-group';\n\nconst DropFade = ({ children, show }: { children: ReactElement; show: boolean }) => {\n const reference = useRef<HTMLDivElement>(null);\n const [height, setHeight] = useState<number | undefined>(0);\n\n const clonedChild = React.cloneElement(children);\n\n return (\n <CSSTransition\n nodeRef={reference}\n in={show}\n timeout={300}\n classNames=\"np-dropfade\"\n onEntering={() => {\n // Set height so we can animate to the correct height\n setHeight(reference.current?.scrollHeight || 0);\n }}\n // Un-set height, as we don't want to presume it should be that height forever\n onEntered={() => setHeight(undefined)}\n onExit={() => {\n setHeight(reference.current?.scrollHeight || 0);\n }}\n onExiting={() => {\n setHeight(0);\n }}\n >\n
|
|
1
|
+
{"version":3,"file":"DropFade.mjs","sources":["../../src/dropFade/DropFade.tsx"],"sourcesContent":["import React, { useRef, useState, ReactElement } from 'react';\nimport { CSSTransition } from 'react-transition-group';\n\nconst DropFade = ({ children, show }: { children: ReactElement; show: boolean }) => {\n const reference = useRef<HTMLDivElement>(null);\n const [height, setHeight] = useState<number | undefined>(0);\n\n const clonedChild = React.cloneElement(children);\n\n return (\n <CSSTransition\n nodeRef={reference}\n in={show}\n timeout={300}\n classNames=\"np-dropfade\"\n onEntering={() => {\n // Set height so we can animate to the correct height\n setHeight(reference.current?.scrollHeight || 0);\n }}\n // Un-set height, as we don't want to presume it should be that height forever\n onEntered={() => setHeight(undefined)}\n onExit={() => {\n setHeight(reference.current?.scrollHeight || 0);\n }}\n onExiting={() => {\n setHeight(0);\n }}\n >\n <div ref={reference} style={{ height }} className=\"np-dropfade\">\n {clonedChild}\n </div>\n </CSSTransition>\n );\n};\n\nexport default DropFade;\n"],"names":["DropFade","children","show","reference","useRef","height","setHeight","useState","clonedChild","React","cloneElement","_jsx","CSSTransition","nodeRef","in","timeout","classNames","onEntering","current","scrollHeight","onEntered","undefined","onExit","onExiting","ref","style","className"],"mappings":";;;;AAGMA,MAAAA,QAAQ,GAAGA,CAAC;EAAEC,QAAQ;AAAEC,EAAAA,IAAAA;AAAiD,CAAA,KAAI;AACjF,EAAA,MAAMC,SAAS,GAAGC,MAAM,CAAiB,IAAI,CAAC,CAAA;EAC9C,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAGC,QAAQ,CAAqB,CAAC,CAAC,CAAA;AAE3D,EAAA,MAAMC,WAAW,gBAAGC,cAAK,CAACC,YAAY,CAACT,QAAQ,CAAC,CAAA;EAEhD,oBACEU,GAAA,CAACC,aAAa,EAAA;AACZC,IAAAA,OAAO,EAAEV,SAAU;AACnBW,IAAAA,EAAE,EAAEZ,IAAK;AACTa,IAAAA,OAAO,EAAE,GAAI;AACbC,IAAAA,UAAU,EAAC,aAAa;IACxBC,UAAU,EAAEA,MAAK;AACf;MACAX,SAAS,CAACH,SAAS,CAACe,OAAO,EAAEC,YAAY,IAAI,CAAC,CAAC,CAAA;AACjD,KAAA;AACA;AAAA;AACAC,IAAAA,SAAS,EAAEA,MAAMd,SAAS,CAACe,SAAS,CAAE;IACtCC,MAAM,EAAEA,MAAK;MACXhB,SAAS,CAACH,SAAS,CAACe,OAAO,EAAEC,YAAY,IAAI,CAAC,CAAC,CAAA;KAC/C;IACFI,SAAS,EAAEA,MAAK;MACdjB,SAAS,CAAC,CAAC,CAAC,CAAA;KACZ;AAAAL,IAAAA,QAAA,eAEFU,GAAA,CAAA,KAAA,EAAA;AAAKa,MAAAA,GAAG,EAAErB,SAAU;AAACsB,MAAAA,KAAK,EAAE;AAAEpB,QAAAA,MAAAA;OAAS;AAACqB,MAAAA,SAAS,EAAC,aAAa;AAAAzB,MAAAA,QAAA,EAC5DO,WAAAA;KACE,CAAA;AACP,GAAe,CAAC,CAAA;AAEpB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmphasisHtmlTransformer.js","sources":["../../src/emphasis/EmphasisHtmlTransformer.ts"],"sourcesContent":["const ESCAPED_OPENING_CHEVRON = '<';\nconst ESCAPED_CLOSING_CHEVRON = '>';\n\ntype Tags = {\n transformed: {\n opening: string;\n closing: string;\n };\n escapedRegex: {\n opening: RegExp;\n closing: RegExp;\n };\n};\n\nclass EmphasisHtmlTransformer {\n tags:
|
|
1
|
+
{"version":3,"file":"EmphasisHtmlTransformer.js","sources":["../../src/emphasis/EmphasisHtmlTransformer.ts"],"sourcesContent":["const ESCAPED_OPENING_CHEVRON = '<';\nconst ESCAPED_CLOSING_CHEVRON = '>';\n\ntype Tags = {\n transformed: {\n opening: string;\n closing: string;\n };\n escapedRegex: {\n opening: RegExp;\n closing: RegExp;\n };\n};\n\nclass EmphasisHtmlTransformer {\n tags: Tags[];\n\n constructor(whitelistedTags?: string[]) {\n this.tags = (whitelistedTags || []).map((tag) => {\n return {\n transformed: {\n opening: `<em class=\"emphasis emphasis--${tag}\">`,\n closing: '</em>',\n },\n escapedRegex: {\n opening: new RegExp(`${ESCAPED_OPENING_CHEVRON}${tag}${ESCAPED_CLOSING_CHEVRON}`, 'g'),\n closing: new RegExp(`${ESCAPED_OPENING_CHEVRON}/${tag}${ESCAPED_CLOSING_CHEVRON}`, 'g'),\n },\n };\n });\n }\n\n // Algorithm:\n // 1) Escape all dangerous characters (<,>,&)\n // 2) Replace all escaped, whitelisted tags with styled spans.\n // 3) Transform new line characters to `<br />`s\n //\n // Note: for simplicity this doesn't support tags with non-standard whitespaces, e.g. <positive></ positive>\n transform(unsafe: string): string | null {\n if (!unsafe) {\n return null;\n }\n\n const safe = unsafe.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');\n\n return this.tags\n .reduce((accumulator, tag) => {\n return accumulator\n .replace(tag.escapedRegex.opening, tag.transformed.opening)\n .replace(tag.escapedRegex.closing, tag.transformed.closing);\n }, safe)\n .replace(/\\\\n|\\n/g, '<br />');\n }\n}\n\nexport default EmphasisHtmlTransformer;\n"],"names":["ESCAPED_OPENING_CHEVRON","ESCAPED_CLOSING_CHEVRON","EmphasisHtmlTransformer","tags","constructor","whitelistedTags","map","tag","transformed","opening","closing","escapedRegex","RegExp","transform","unsafe","safe","replace","reduce","accumulator"],"mappings":";;AAAA,MAAMA,uBAAuB,GAAG,MAAM,CAAA;AACtC,MAAMC,uBAAuB,GAAG,MAAM,CAAA;AAatC,MAAMC,uBAAuB,CAAA;EAC3BC,IAAI,CAAA;EAEJC,WAAAA,CAAYC,eAA0B,EAAA;IACpC,IAAI,CAACF,IAAI,GAAG,CAACE,eAAe,IAAI,EAAE,EAAEC,GAAG,CAAEC,GAAG,IAAI;MAC9C,OAAO;AACLC,QAAAA,WAAW,EAAE;UACXC,OAAO,EAAE,CAAiCF,8BAAAA,EAAAA,GAAG,CAAI,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["const ESCAPED_OPENING_CHEVRON = '<';\nconst ESCAPED_CLOSING_CHEVRON = '>';\n\ntype Tags = {\n transformed: {\n opening: string;\n closing: string;\n };\n escapedRegex: {\n opening: RegExp;\n closing: RegExp;\n };\n};\n\nclass EmphasisHtmlTransformer {\n tags:
|
|
1
|
+
{"version":3,"file":"EmphasisHtmlTransformer.mjs","sources":["../../src/emphasis/EmphasisHtmlTransformer.ts"],"sourcesContent":["const ESCAPED_OPENING_CHEVRON = '<';\nconst ESCAPED_CLOSING_CHEVRON = '>';\n\ntype Tags = {\n transformed: {\n opening: string;\n closing: string;\n };\n escapedRegex: {\n opening: RegExp;\n closing: RegExp;\n };\n};\n\nclass EmphasisHtmlTransformer {\n tags: Tags[];\n\n constructor(whitelistedTags?: string[]) {\n this.tags = (whitelistedTags || []).map((tag) => {\n return {\n transformed: {\n opening: `<em class=\"emphasis emphasis--${tag}\">`,\n closing: '</em>',\n },\n escapedRegex: {\n opening: new RegExp(`${ESCAPED_OPENING_CHEVRON}${tag}${ESCAPED_CLOSING_CHEVRON}`, 'g'),\n closing: new RegExp(`${ESCAPED_OPENING_CHEVRON}/${tag}${ESCAPED_CLOSING_CHEVRON}`, 'g'),\n },\n };\n });\n }\n\n // Algorithm:\n // 1) Escape all dangerous characters (<,>,&)\n // 2) Replace all escaped, whitelisted tags with styled spans.\n // 3) Transform new line characters to `<br />`s\n //\n // Note: for simplicity this doesn't support tags with non-standard whitespaces, e.g. <positive></ positive>\n transform(unsafe: string): string | null {\n if (!unsafe) {\n return null;\n }\n\n const safe = unsafe.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');\n\n return this.tags\n .reduce((accumulator, tag) => {\n return accumulator\n .replace(tag.escapedRegex.opening, tag.transformed.opening)\n .replace(tag.escapedRegex.closing, tag.transformed.closing);\n }, safe)\n .replace(/\\\\n|\\n/g, '<br />');\n }\n}\n\nexport default EmphasisHtmlTransformer;\n"],"names":["ESCAPED_OPENING_CHEVRON","ESCAPED_CLOSING_CHEVRON","EmphasisHtmlTransformer","tags","constructor","whitelistedTags","map","tag","transformed","opening","closing","escapedRegex","RegExp","transform","unsafe","safe","replace","reduce","accumulator"],"mappings":"AAAA,MAAMA,uBAAuB,GAAG,MAAM,CAAA;AACtC,MAAMC,uBAAuB,GAAG,MAAM,CAAA;AAatC,MAAMC,uBAAuB,CAAA;EAC3BC,IAAI,CAAA;EAEJC,WAAAA,CAAYC,eAA0B,EAAA;IACpC,IAAI,CAACF,IAAI,GAAG,CAACE,eAAe,IAAI,EAAE,EAAEC,GAAG,CAAEC,GAAG,IAAI;MAC9C,OAAO;AACLC,QAAAA,WAAW,EAAE;UACXC,OAAO,EAAE,CAAiCF,8BAAAA,EAAAA,GAAG,CAAI,EAAA,CAAA;AACjDG,UAAAA,OAAO,EAAE,OAAA;SACV;AACDC,QAAAA,YAAY,EAAE;AACZF,UAAAA,OAAO,EAAE,IAAIG,MAAM,CAAC,CAAGZ,EAAAA,uBAAuB,CAAGO,EAAAA,GAAG,CAAGN,EAAAA,uBAAuB,CAAE,CAAA,EAAE,GAAG,CAAC;AACtFS,UAAAA,OAAO,EAAE,IAAIE,MAAM,CAAC,CAAGZ,EAAAA,uBAAuB,CAAIO,CAAAA,EAAAA,GAAG,CAAGN,EAAAA,uBAAuB,CAAE,CAAA,EAAE,GAAG,CAAA;AACvF,SAAA;OACF,CAAA;AACH,KAAC,CAAC,CAAA;AACJ,GAAA;AAEA;AACA;AACA;AACA;AACA;AACA;EACAY,SAASA,CAACC,MAAc,EAAA;IACtB,IAAI,CAACA,MAAM,EAAE;AACX,MAAA,OAAO,IAAI,CAAA;AACb,KAAA;IAEA,MAAMC,IAAI,GAAGD,MAAM,CAACE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAACA,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAACA,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAEtF,OAAO,IAAI,CAACb,IAAI,CACbc,MAAM,CAAC,CAACC,WAAW,EAAEX,GAAG,KAAI;AAC3B,MAAA,OAAOW,WAAW,CACfF,OAAO,CAACT,GAAG,CAACI,YAAY,CAACF,OAAO,EAAEF,GAAG,CAACC,WAAW,CAACC,OAAO,CAAC,CAC1DO,OAAO,CAACT,GAAG,CAACI,YAAY,CAACD,OAAO,EAAEH,GAAG,CAACC,WAAW,CAACE,OAAO,CAAC,CAAA;KAC9D,EAAEK,IAAI,CAAC,CACPC,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;AACjC,GAAA;AACD;;;;"}
|
package/build/inputs/Input.js
CHANGED
|
@@ -22,9 +22,7 @@ const Input = /*#__PURE__*/React.forwardRef(function Input({
|
|
|
22
22
|
}), 'np-input', {
|
|
23
23
|
'np-input--shape-rectangle': shape === 'rectangle',
|
|
24
24
|
'np-input--shape-pill': shape === 'pill'
|
|
25
|
-
})
|
|
26
|
-
// eslint-disable-next-line react/forbid-dom-props
|
|
27
|
-
,
|
|
25
|
+
}),
|
|
28
26
|
style: inputPaddings,
|
|
29
27
|
...inputAttributes,
|
|
30
28
|
...restProps
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sources":["../../src/inputs/Input.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { forwardRef } from 'react';\n\nimport { SizeLarge, SizeMedium, SizeSmall } from '../common';\nimport { Merge } from '../utils';\nimport { inputClassNameBase } from './_common';\nimport { useInputAttributes } from './contexts';\nimport { useInputPaddings } from './InputGroup';\n\nexport interface InputProps\n extends Merge<\n React.ComponentPropsWithRef<'input'>,\n {\n size?: 'auto' | SizeSmall | SizeMedium | SizeLarge;\n shape?: 'rectangle' | 'pill';\n 'aria-invalid'?: boolean;\n }\n > {}\n\nexport const Input = forwardRef(function Input(\n { size = 'auto', shape = 'rectangle', className, ...restProps }: InputProps,\n reference: React.ForwardedRef<HTMLInputElement | null>,\n) {\n const inputAttributes = useInputAttributes();\n const inputPaddings = useInputPaddings();\n\n return (\n <input\n ref={reference}\n className={clsx(className, inputClassNameBase({ size }), 'np-input', {\n 'np-input--shape-rectangle': shape === 'rectangle',\n 'np-input--shape-pill': shape === 'pill',\n })}\n
|
|
1
|
+
{"version":3,"file":"Input.js","sources":["../../src/inputs/Input.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { forwardRef } from 'react';\n\nimport { SizeLarge, SizeMedium, SizeSmall } from '../common';\nimport { Merge } from '../utils';\nimport { inputClassNameBase } from './_common';\nimport { useInputAttributes } from './contexts';\nimport { useInputPaddings } from './InputGroup';\n\nexport interface InputProps\n extends Merge<\n React.ComponentPropsWithRef<'input'>,\n {\n size?: 'auto' | SizeSmall | SizeMedium | SizeLarge;\n shape?: 'rectangle' | 'pill';\n 'aria-invalid'?: boolean;\n }\n > {}\n\nexport const Input = forwardRef(function Input(\n { size = 'auto', shape = 'rectangle', className, ...restProps }: InputProps,\n reference: React.ForwardedRef<HTMLInputElement | null>,\n) {\n const inputAttributes = useInputAttributes();\n const inputPaddings = useInputPaddings();\n\n return (\n <input\n ref={reference}\n className={clsx(className, inputClassNameBase({ size }), 'np-input', {\n 'np-input--shape-rectangle': shape === 'rectangle',\n 'np-input--shape-pill': shape === 'pill',\n })}\n style={inputPaddings}\n {...inputAttributes}\n {...restProps}\n />\n );\n});\n"],"names":["Input","forwardRef","size","shape","className","restProps","reference","inputAttributes","useInputAttributes","inputPaddings","useInputPaddings","_jsx","ref","clsx","inputClassNameBase","style"],"mappings":";;;;;;;;;MAmBaA,KAAK,gBAAGC,gBAAU,CAAC,SAASD,KAAKA,CAC5C;AAAEE,EAAAA,IAAI,GAAG,MAAM;AAAEC,EAAAA,KAAK,GAAG,WAAW;EAAEC,SAAS;EAAE,GAAGC,SAAAA;AAAuB,CAAA,EAC3EC,SAAsD,EAAA;AAEtD,EAAA,MAAMC,eAAe,GAAGC,2BAAkB,EAAE,CAAA;AAC5C,EAAA,MAAMC,aAAa,GAAGC,2BAAgB,EAAE,CAAA;AAExC,EAAA,oBACEC,cAAA,CAAA,OAAA,EAAA;AACEC,IAAAA,GAAG,EAAEN,SAAU;AACfF,IAAAA,SAAS,EAAES,SAAI,CAACT,SAAS,EAAEU,0BAAkB,CAAC;AAAEZ,MAAAA,IAAAA;KAAM,CAAC,EAAE,UAAU,EAAE;MACnE,2BAA2B,EAAEC,KAAK,KAAK,WAAW;MAClD,sBAAsB,EAAEA,KAAK,KAAK,MAAA;AACnC,KAAA,CAAE;AACHY,IAAAA,KAAK,EAAEN,aAAc;AAAA,IAAA,GACjBF,eAAe;IAAA,GACfF,SAAAA;AAAS,GAAC,CACd,CAAA;AAEN,CAAC;;;;"}
|
package/build/inputs/Input.mjs
CHANGED
|
@@ -20,9 +20,7 @@ const Input = /*#__PURE__*/forwardRef(function Input({
|
|
|
20
20
|
}), 'np-input', {
|
|
21
21
|
'np-input--shape-rectangle': shape === 'rectangle',
|
|
22
22
|
'np-input--shape-pill': shape === 'pill'
|
|
23
|
-
})
|
|
24
|
-
// eslint-disable-next-line react/forbid-dom-props
|
|
25
|
-
,
|
|
23
|
+
}),
|
|
26
24
|
style: inputPaddings,
|
|
27
25
|
...inputAttributes,
|
|
28
26
|
...restProps
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.mjs","sources":["../../src/inputs/Input.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { forwardRef } from 'react';\n\nimport { SizeLarge, SizeMedium, SizeSmall } from '../common';\nimport { Merge } from '../utils';\nimport { inputClassNameBase } from './_common';\nimport { useInputAttributes } from './contexts';\nimport { useInputPaddings } from './InputGroup';\n\nexport interface InputProps\n extends Merge<\n React.ComponentPropsWithRef<'input'>,\n {\n size?: 'auto' | SizeSmall | SizeMedium | SizeLarge;\n shape?: 'rectangle' | 'pill';\n 'aria-invalid'?: boolean;\n }\n > {}\n\nexport const Input = forwardRef(function Input(\n { size = 'auto', shape = 'rectangle', className, ...restProps }: InputProps,\n reference: React.ForwardedRef<HTMLInputElement | null>,\n) {\n const inputAttributes = useInputAttributes();\n const inputPaddings = useInputPaddings();\n\n return (\n <input\n ref={reference}\n className={clsx(className, inputClassNameBase({ size }), 'np-input', {\n 'np-input--shape-rectangle': shape === 'rectangle',\n 'np-input--shape-pill': shape === 'pill',\n })}\n
|
|
1
|
+
{"version":3,"file":"Input.mjs","sources":["../../src/inputs/Input.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { forwardRef } from 'react';\n\nimport { SizeLarge, SizeMedium, SizeSmall } from '../common';\nimport { Merge } from '../utils';\nimport { inputClassNameBase } from './_common';\nimport { useInputAttributes } from './contexts';\nimport { useInputPaddings } from './InputGroup';\n\nexport interface InputProps\n extends Merge<\n React.ComponentPropsWithRef<'input'>,\n {\n size?: 'auto' | SizeSmall | SizeMedium | SizeLarge;\n shape?: 'rectangle' | 'pill';\n 'aria-invalid'?: boolean;\n }\n > {}\n\nexport const Input = forwardRef(function Input(\n { size = 'auto', shape = 'rectangle', className, ...restProps }: InputProps,\n reference: React.ForwardedRef<HTMLInputElement | null>,\n) {\n const inputAttributes = useInputAttributes();\n const inputPaddings = useInputPaddings();\n\n return (\n <input\n ref={reference}\n className={clsx(className, inputClassNameBase({ size }), 'np-input', {\n 'np-input--shape-rectangle': shape === 'rectangle',\n 'np-input--shape-pill': shape === 'pill',\n })}\n style={inputPaddings}\n {...inputAttributes}\n {...restProps}\n />\n );\n});\n"],"names":["Input","forwardRef","size","shape","className","restProps","reference","inputAttributes","useInputAttributes","inputPaddings","useInputPaddings","_jsx","ref","clsx","inputClassNameBase","style"],"mappings":";;;;;;;MAmBaA,KAAK,gBAAGC,UAAU,CAAC,SAASD,KAAKA,CAC5C;AAAEE,EAAAA,IAAI,GAAG,MAAM;AAAEC,EAAAA,KAAK,GAAG,WAAW;EAAEC,SAAS;EAAE,GAAGC,SAAAA;AAAuB,CAAA,EAC3EC,SAAsD,EAAA;AAEtD,EAAA,MAAMC,eAAe,GAAGC,kBAAkB,EAAE,CAAA;AAC5C,EAAA,MAAMC,aAAa,GAAGC,gBAAgB,EAAE,CAAA;AAExC,EAAA,oBACEC,GAAA,CAAA,OAAA,EAAA;AACEC,IAAAA,GAAG,EAAEN,SAAU;AACfF,IAAAA,SAAS,EAAES,IAAI,CAACT,SAAS,EAAEU,kBAAkB,CAAC;AAAEZ,MAAAA,IAAAA;KAAM,CAAC,EAAE,UAAU,EAAE;MACnE,2BAA2B,EAAEC,KAAK,KAAK,WAAW;MAClD,sBAAsB,EAAEA,KAAK,KAAK,MAAA;AACnC,KAAA,CAAE;AACHY,IAAAA,KAAK,EAAEN,aAAc;AAAA,IAAA,GACjBF,eAAe;IAAA,GACfF,SAAAA;AAAS,GAAC,CACd,CAAA;AAEN,CAAC;;;;"}
|
|
@@ -446,9 +446,7 @@ function SelectInputOptions({
|
|
|
446
446
|
const listboxId = React.useId();
|
|
447
447
|
const getItemNode = index => {
|
|
448
448
|
const item = filteredItems[index];
|
|
449
|
-
return /*#__PURE__*/jsxRuntime.jsx(SelectInputItemView
|
|
450
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
451
|
-
, {
|
|
449
|
+
return /*#__PURE__*/jsxRuntime.jsx(SelectInputItemView, {
|
|
452
450
|
item: item,
|
|
453
451
|
renderValue: renderValue,
|
|
454
452
|
needle: needle
|