@rio-cloud/rio-uikit 2.4.2 → 2.5.0
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/CountedInput.d.ts +2 -0
- package/CountedInput.js +5 -0
- package/CountedInput.js.map +1 -0
- package/TabbedPanel.d.ts +2 -0
- package/TabbedPanel.js +5 -0
- package/TabbedPanel.js.map +1 -0
- package/components/applicationHeader/NavItems.js +58 -46
- package/components/applicationHeader/NavItems.js.map +1 -1
- package/components/applicationLayout/ApplicationLayoutBody.d.ts +1 -1
- package/components/applicationLayout/ApplicationLayoutBody.js +29 -29
- package/components/applicationLayout/ApplicationLayoutBody.js.map +1 -1
- package/components/applicationLayout/ApplicationLayoutHeader.js +22 -7
- package/components/applicationLayout/ApplicationLayoutHeader.js.map +1 -1
- package/components/assetTree/useTreeHeight.js.map +1 -1
- package/components/button/Button.d.ts +11 -3
- package/components/button/Button.js.map +1 -1
- package/components/clearableInput/ClearableInput.d.ts +4 -0
- package/components/clearableInput/ClearableInput.js.map +1 -1
- package/components/countedInput/CountedInput.d.ts +91 -0
- package/components/countedInput/CountedInput.js +65 -0
- package/components/countedInput/CountedInput.js.map +1 -0
- package/components/datepicker/DayPicker.js +3 -2
- package/components/datepicker/DayPicker.js.map +1 -1
- package/components/datepicker/DayPickerInput.d.ts +1 -1
- package/components/datepicker/DayPickerInput.js.map +1 -1
- package/components/datepicker/dayPickerTypes.d.ts +3 -2
- package/components/datepicker/dayPickerTypes.js.map +1 -1
- package/components/datepicker/dayPickerUtils.d.ts +1 -1
- package/components/datepicker/dayPickerUtils.js +45 -22
- package/components/datepicker/dayPickerUtils.js.map +1 -1
- package/components/datepicker/useDayPickerInputState.d.ts +1 -1
- package/components/dialog/ConfirmationDialog.d.ts +17 -0
- package/components/dialog/ConfirmationDialog.js +43 -19
- package/components/dialog/ConfirmationDialog.js.map +1 -1
- package/components/dialog/DialogHeader.js +20 -19
- package/components/dialog/DialogHeader.js.map +1 -1
- package/components/dropdown/ButtonDropdown.d.ts +5 -0
- package/components/dropdown/ButtonDropdown.js +63 -61
- package/components/dropdown/ButtonDropdown.js.map +1 -1
- package/components/dropdown/DropdownToggleButton.d.ts +2 -0
- package/components/dropdown/DropdownToggleButton.js +39 -35
- package/components/dropdown/DropdownToggleButton.js.map +1 -1
- package/components/map/components/features/settings/builtinSettings/MapTypeSettings.js +103 -105
- package/components/map/components/features/settings/builtinSettings/MapTypeSettings.js.map +1 -1
- package/components/map/utils/eventHandling.js.map +1 -1
- package/components/map/utils/mapTypes.d.ts +7 -0
- package/components/map/utils/mapTypes.js.map +1 -1
- package/components/map/utils/rendering.js +5 -5
- package/components/numberControl/NumberControl.js.map +1 -1
- package/components/page/Page.d.ts +2 -0
- package/components/page/Page.js.map +1 -1
- package/components/rioglyph/Rioglyph.d.ts +8 -2
- package/components/rioglyph/Rioglyph.js.map +1 -1
- package/components/rioglyph/RioglyphIconType.d.ts +1 -1
- package/components/selects/BaseSelectDropdown.d.ts +8 -0
- package/components/selects/BaseSelectDropdown.js +76 -60
- package/components/selects/BaseSelectDropdown.js.map +1 -1
- package/components/selects/Multiselect.d.ts +5 -0
- package/components/selects/Multiselect.js +60 -58
- package/components/selects/Multiselect.js.map +1 -1
- package/components/selects/Select.d.ts +5 -0
- package/components/selects/Select.js +60 -58
- package/components/selects/Select.js.map +1 -1
- package/components/sidebars/Sidebar.js +40 -40
- package/components/sidebars/Sidebar.js.map +1 -1
- package/components/sidebars/SidebarCloseButton.d.ts +3 -1
- package/components/sidebars/SidebarCloseButton.js +19 -5
- package/components/sidebars/SidebarCloseButton.js.map +1 -1
- package/components/states/CustomState.d.ts +7 -1
- package/components/states/CustomState.js.map +1 -1
- package/components/states/StateButton.d.ts +11 -1
- package/components/states/StateButton.js +46 -10
- package/components/states/StateButton.js.map +1 -1
- package/components/statsWidget/StatsWidgetNumber.d.ts +16 -1
- package/components/statsWidget/StatsWidgetNumber.js +29 -12
- package/components/statsWidget/StatsWidgetNumber.js.map +1 -1
- package/components/tabbedPanel/TabbedPanel.d.ts +99 -0
- package/components/tabbedPanel/TabbedPanel.js +119 -0
- package/components/tabbedPanel/TabbedPanel.js.map +1 -0
- package/components/table/Table.types.d.ts +9 -1
- package/components/table/TableColumn.js +20 -19
- package/components/table/TableColumn.js.map +1 -1
- package/components/table/TableHeaderColumn.d.ts +4 -0
- package/components/table/TableHeaderColumn.js +50 -53
- package/components/table/TableHeaderColumn.js.map +1 -1
- package/components/table/TableToolbar.d.ts +4 -0
- package/components/table/TableToolbar.js.map +1 -1
- package/components/table/TableToolbarColumn.d.ts +3 -0
- package/components/table/TableToolbarColumn.js.map +1 -1
- package/components/table/render/header/resolveHeaderCellStyle.d.ts +87 -55
- package/components/timepicker/TimePicker.d.ts +6 -0
- package/components/timepicker/TimePicker.js +57 -56
- package/components/timepicker/TimePicker.js.map +1 -1
- package/hooks/useClickOutside.js +3 -3
- package/hooks/useClipboard.js.map +1 -1
- package/hooks/useScrollPosition.js.map +1 -1
- package/package.json +4 -4
- package/themes/Volkswagen/components/applicationHeader/VolkswagenApplicationHeader.js +23 -22
- package/themes/Volkswagen/components/applicationHeader/VolkswagenApplicationHeader.js.map +1 -1
- package/utils/analytics/getTrackingLabelFromNode.d.ts +2 -0
- package/utils/analytics/getTrackingLabelFromNode.js +24 -0
- package/utils/analytics/getTrackingLabelFromNode.js.map +1 -0
- package/utils/analytics/googleAnalyticsUtils.js +21 -28
- package/utils/analytics/googleAnalyticsUtils.js.map +1 -1
- package/utils/getNodeTextContent.d.ts +2 -0
- package/utils/getNodeTextContent.js +22 -0
- package/utils/getNodeTextContent.js.map +1 -0
- package/utils/init/initCSS.js +5 -5
- package/utils/init/initCSS.js.map +1 -1
- package/utils/init/initConfig.js +4 -7
- package/utils/init/initConfig.js.map +1 -1
- package/utils/init/initDocumentBootstrapping.js +14 -14
- package/utils/init/initDocumentBootstrapping.js.map +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/DayPickerPrototype.d.ts +0 -2
- package/DayPickerPrototype.js +0 -5
- package/DayPickerPrototype.js.map +0 -1
- package/TableNext.d.ts +0 -2
- package/TableNext.js +0 -25
- package/TableNext.js.map +0 -1
- package/components/datepicker/DayPickerPrototype.d.ts +0 -53
- package/components/datepicker/DayPickerPrototype.js +0 -285
- package/components/datepicker/DayPickerPrototype.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sidebar.js","sources":["../../../src/components/sidebars/Sidebar.tsx"],"sourcesContent":["import React, { type PropsWithChildren, useEffect, useRef, useState } from 'react';\nimport { motion } from 'motion/react';\nimport { noop } from 'es-toolkit/function';\nimport { toNumber } from 'es-toolkit/compat';\n\nimport classNames from '../../utils/classNames';\nimport SidebarFooter from './SidebarFooter';\nimport SidebarBackdrop from './SidebarBackdrop';\nimport SidebarFullscreenToggle from './SidebarFullscreenToggle';\nimport SidebarCloseButton from './SidebarCloseButton';\nimport Resizer from '../resizer/Resizer';\nimport useWindowResize from '../../hooks/useWindowResize';\nimport useEsc from '../../hooks/useEsc';\nimport getWidthInBoundaries from '../../utils/getWidthInBoundaries';\nimport type { ObjectValues } from '../../utils/ObjectValues';\nimport SmoothScrollbars from '../smoothScrollbars/SmoothScrollbars';\n\nconst DEFAULT_WIDTH = 350;\nconst DEFAULT_MIN_WIDTH = 100;\nconst DEFAULT_MAX_WIDTH = 800;\nconst DEFAULT_SWITCH_MODE_BREAKPOINT = 0;\n\n// Values define the min and max width for the module-content\n// where the fluid sidebar automatically changes to \"fly\" and back.\nconst MIN_MODULE_CONTENT_WIDTH = 400;\nconst MAX_MODULE_CONTENT_WIDTH = 800;\n\nconst ANIMATION_DURATION = 0.14;\nconst RESIZE_THROTTLE = 500;\n\nconst SidebarPosition = {\n LEFT: 'left',\n RIGHT: 'right',\n} as const;\n\nconst SidebarMode = {\n MODE_FLY: 'fly',\n MODE_FLUID: 'fluid',\n};\n\ntype AnimationVariantProps = {\n fromRight: boolean;\n closed?: boolean;\n};\n\nconst animationVariants = {\n sidebarEnter: ({ fromRight }: AnimationVariantProps) => ({\n x: fromRight ? '100%' : '-100%',\n opacity: 0,\n }),\n sidebarVisible: ({ fromRight, closed }: AnimationVariantProps) => ({\n x: !closed ? 0 : fromRight ? '100%' : '-100%',\n opacity: closed ? 0 : 1,\n display: closed ? 'none' : 'block',\n }),\n sidebarExit: ({ fromRight }: AnimationVariantProps) => ({\n x: fromRight ? '100%' : '-100%',\n opacity: 0,\n }),\n};\n\nexport type SidebarProps = {\n /**\n * Defines if the component will overlap the body content.\n *\n * @default false\n */\n fly?: boolean;\n\n /**\n * Defines whether the component is hidden or not.\n *\n * @default false\n */\n closed?: boolean;\n\n /**\n * Hides the close button. This may be used when the sidebar is always visible and may not be closed.\n *\n * @default false\n */\n disableClose?: boolean;\n\n /**\n * Callback function triggered when clicking the close icon.\n */\n onClose?: VoidFunction;\n\n /**\n * The Footer content. For example a save button.\n */\n footer?: string | React.ReactNode;\n\n /**\n * Additional classes added to the Sidebar footer.\n */\n footerClassName?: string;\n\n /**\n * Additional buttons to be rendered in the header.\n */\n headerButtons?: React.ReactNode;\n\n /**\n * Additional classes added to the Sidebar header.\n */\n headerClassName?: string;\n\n /**\n * Shows a sidebar header border\n */\n showHeaderBorder?: boolean;\n\n /**\n * Defines the width of the component. The value is set as pixel value as inline style.\n * Note: In the past, the type allowed to pass in a sting value like \"400px\" but that is not\n * possible anymore due to internal width calculations. To be backwards compatible for non\n * Typescript projects, the width is converted to a number.\n *\n * @default 350\n */\n width?: number;\n\n /**\n * Defines the minimum width in px of the component that will take effect when resizing.\n *\n * @default 100\n */\n minWidth?: number;\n\n /**\n * Defines the maximum width in px of the component that will take effect when resizing.\n *\n * @default 800\n */\n maxWidth?: number;\n\n /**\n * Opens Sidebar in fullscreen, means 100vw.\n *\n * @default false\n */\n openInFullscreen?: boolean;\n\n /**\n * Callback for when the fullscreen is toggled.\n */\n onFullScreenChange?: (newFullscreenState: boolean) => void;\n\n /**\n * Enables the fullscreen functionality and shows the fullscreen toggle.\n *\n * @default false\n */\n enableFullscreenToggle?: boolean;\n\n /**\n * Translated tooltip text for the fullscreen toggle button.\n */\n fullscreenToggleTooltip?: string;\n\n /**\n * Tells the sidebar where it is positioned. This will affect the resizing behavior\n * respectively. Note: the position need to be set properly whe using the resize\n * functionality to know on which side of the sidebar to attach the resizer handle.\n *\n * It is also relevant when the sidebar mode is set to `fly` to properly animate\n * the sidebar into the view.\n *\n * Possible values are:\n *\n * - `'left'`\n * - `'right'`\n * - `Sidebar.LEFT`\n * - `Sidebar.RIGHT`\n *\n * @default 'left'\n */\n position?: ObjectValues<typeof SidebarPosition>;\n\n /**\n * Defines whether or not the sidebar is resizable.\n * @default false\n */\n resizable?: boolean;\n\n /**\n * Callback for when the resize is done.\n */\n onResizeEnd?: VoidFunction;\n\n /**\n * Defines the breakpoint in pixel when the sidebar mode shall be changed. If the window width is lower\n * than the given breakpoint the mode is set to `fly`. If the window width is higher the mode is set\n * to `fluid`. This functionality is disabled by default and will be enabled when defining a breakpoint\n * higher than 0.\n */\n switchModeBreakpoint?: number;\n\n /**\n * By default the fullscreen mode can be left with \"esc\". If this is unwanted it can be disabled.\n *\n * @default false\n */\n disableEsc?: boolean;\n\n /**\n * Defined whether or not a backdrop will be rendered behind the Sidebar to avoid clicks outside.\n *\n * @default false\n */\n hasBackdrop?: boolean;\n\n /**\n * Defined whether or not the UIKIT SmoothScrollbar is active.\n *\n * @default false\n */\n hasSmoothScrollbar?: boolean;\n\n /**\n * Defined whether or not the backdrop is visible similar to the backdrop for modal dialogs.\n *\n * @default false\n */\n makeBackdropVisible?: boolean;\n\n /**\n * Callback for when the backdrop is clicked. This comes in handy when handling transient data from\n * the sidebar which need to be saved first and handle clicks outside.\n */\n onBackdropClick?: VoidFunction;\n\n /**\n * Additional ref added to the Sidebar body.\n */\n bodyRef?: React.MutableRefObject<HTMLDivElement | null>;\n\n /**\n * Content that will be displayed in the components header.\n */\n title?: string | React.ReactNode;\n\n /**\n * Additional classes added to the Sidebar title.\n */\n titleClassName?: string;\n\n /**\n * Additional classes added to the Sidebar backdrop.\n */\n backdropClassName?: string;\n\n /**\n * Additional classes added to the Sidebar body.\n */\n bodyClassName?: string;\n\n /**\n * Additional classes added on the wrapper element.\n */\n className?: string;\n};\n\nconst Sidebar = (props: PropsWithChildren<SidebarProps>) => {\n const {\n fly = false,\n closed = false,\n title = '',\n footer,\n resizable = false,\n position,\n width = DEFAULT_WIDTH,\n minWidth = DEFAULT_MIN_WIDTH,\n maxWidth = DEFAULT_MAX_WIDTH,\n hasBackdrop = false,\n hasSmoothScrollbar = false,\n makeBackdropVisible = false,\n enableFullscreenToggle = false,\n fullscreenToggleTooltip,\n openInFullscreen = false,\n showHeaderBorder = false,\n disableClose = false,\n bodyRef,\n headerButtons,\n switchModeBreakpoint = DEFAULT_SWITCH_MODE_BREAKPOINT,\n onClose = noop,\n onResizeEnd = noop,\n onFullScreenChange = noop,\n onBackdropClick = noop,\n disableEsc = false,\n titleClassName = '',\n bodyClassName = '',\n headerClassName = '',\n footerClassName = '',\n backdropClassName = '',\n className = '',\n children,\n ...remainingProps\n } = props;\n\n const [internalWidth, setInternalWidth] = useState(toNumber(width));\n const [sidebarMode, setSidebarMode] = useState(fly ? Sidebar.MODE_FLY : Sidebar.MODE_FLUID);\n const [isFullscreen, setIsFullscreen] = useState(openInFullscreen);\n const [isResize, setIsResize] = useState(false);\n const [isSplit, setIsSplit] = useState(false);\n const [isRight, setIsRight] = useState(position === SidebarPosition.RIGHT);\n\n const sidebarRef = useRef<HTMLDivElement>(null);\n\n // Used to keep the external reference to the module-content to avoid querying the DOM\n // periodically on window resize\n const moduleContentRef: React.MutableRefObject<HTMLDivElement | null> = useRef(null);\n\n // Position fallback in case the position property is not defined but the sidebar mode is fly\n // and we want to animate it, we nee to know the direction from where th sidebar is coming from.\n // That's why we check the ApplicationLayoutSidebar class if the sidebar inside is right aligned\n // or not and us this value instead.\n // Note: the position need to be set properly whe using the resize functionality to know on which\n // side of the sidebar to attach the resizer handle.\n useEffect(() => {\n if (sidebarRef.current && sidebarMode === Sidebar.MODE_FLY) {\n const sidebarLayout = sidebarRef.current.parentNode as HTMLDivElement;\n if (sidebarLayout?.className.includes('right')) {\n setIsRight(true);\n }\n }\n }, [sidebarRef.current, sidebarMode]);\n\n // Keep the previous closed state in order to prevent animation when switching sidebar mode\n const [previousClosed, setPreviousClosed] = useState(closed);\n if (previousClosed !== closed) {\n setPreviousClosed(closed);\n }\n\n // Update internal width from outside\n const [previousWidth, setPreviousWidth] = useState(width);\n if (previousWidth !== width) {\n console.log('update internal width');\n setInternalWidth(toNumber(width));\n setPreviousWidth(width);\n }\n\n // Switch between mode \"fly\" and \"fluid\"\n useWindowResize(() => adaptSidebarMode(), RESIZE_THROTTLE);\n\n // Initially check breakpoint after mounting the component\n useEffect(() => adaptSidebarMode(), []);\n\n // When Sidebar opens, check for available module-content width and\n // switch sidebar mode to fly in case\n useEffect(() => {\n if (!closed) {\n setTimeout(() => adaptSidebarMode());\n }\n }, [closed]);\n\n useEffect(() => {\n const moduleContent = document.querySelector('.module-content');\n if (moduleContent) {\n moduleContentRef.current = moduleContent as HTMLDivElement;\n }\n }, []);\n\n // Close the fullscreen with \"esc\"\n useEsc(() => {\n if (!disableEsc && enableFullscreenToggle && isFullscreen) {\n setIsFullscreen(false);\n onFullScreenChange(false);\n }\n });\n\n const adaptSidebarMode = () => {\n const moduleContentWidth = moduleContentRef.current?.clientWidth;\n\n if (fly || switchModeBreakpoint === DEFAULT_SWITCH_MODE_BREAKPOINT) {\n return;\n }\n\n const isModuleContentTooSmall = moduleContentWidth && moduleContentWidth <= MIN_MODULE_CONTENT_WIDTH;\n const isModuleContentBigEnough = moduleContentWidth && moduleContentWidth > MAX_MODULE_CONTENT_WIDTH;\n\n const isWindowSmallerThanBreakpoint = window.innerWidth <= switchModeBreakpoint;\n\n // switch to fly when module-content is less than x pixel and back if it is bigger\n if (isModuleContentTooSmall || isWindowSmallerThanBreakpoint) {\n setSidebarMode(Sidebar.MODE_FLY);\n return;\n }\n\n // if module-content is bigger and is initially fluid set back to initial fluid state\n if (isModuleContentBigEnough && !isWindowSmallerThanBreakpoint) {\n setSidebarMode(Sidebar.MODE_FLUID);\n return;\n }\n };\n\n const handleResize = (diff: number) => {\n const wasSplit = isSplit;\n const halfWindowWidth = window.innerWidth * 0.5;\n const usedMaxWidth = maxWidth || halfWindowWidth;\n\n // Check for sidebar width if it is half the window size. If it was before but the sidebar was resized so it is\n // no longer half window size, set the sidebar with to half window size to avoid jumping sidebar to old width\n setInternalWidth(oldWidth => {\n const updatedWidth = position === Sidebar.RIGHT ? oldWidth + diff : oldWidth - diff;\n const newWidth = getWidthInBoundaries(minWidth, usedMaxWidth, updatedWidth);\n\n const newIsSplit = newWidth === halfWindowWidth;\n setIsSplit(newIsSplit);\n\n return wasSplit && !isSplit ? halfWindowWidth : newWidth;\n });\n\n adaptSidebarMode();\n };\n\n const handleResizeStart = () => {\n const body = document.body;\n body?.classList.add('pointer-events-none');\n setIsResize(true);\n };\n\n const handleResizeEnd = () => {\n const body = document.body;\n body?.classList.remove('pointer-events-none');\n setIsResize(false);\n onResizeEnd();\n };\n\n const handleFullscreenChange = () => {\n const newFullscreenState = !isFullscreen;\n setIsFullscreen(newFullscreenState);\n onFullScreenChange(newFullscreenState);\n };\n\n const wrapperClasses = classNames(\n 'Sidebar',\n className,\n closed && 'closed',\n isFullscreen && 'width-100vw sidebar-fullscreen',\n isSplit && !isFullscreen && 'max-width-50vw width-50vw',\n sidebarMode === SidebarMode.MODE_FLY ? 'fly' : isFullscreen ? 'fly' : 'fluid'\n );\n\n const headerClassNames = classNames('SidebarHeader', headerClassName, showHeaderBorder && 'show-border');\n const titleClassNames = classNames('SidebarTitle', titleClassName);\n const bodyClassNames = classNames('SidebarBody', bodyClassName);\n\n const resizeLimitClasses = classNames('SidebarResizeLimit', isResize && 'display-block');\n\n const resizeIndicatorPosition = maxWidth || window.innerWidth * 0.5;\n const resizeLimitStyle = isRight ? { right: resizeIndicatorPosition } : { left: resizeIndicatorPosition };\n\n const sidebarContent = (\n <>\n <div className={resizeLimitClasses} style={resizeLimitStyle} />\n <div className='SidebarContent'>\n <div className={headerClassNames}>\n <div className={titleClassNames}>{title}</div>\n <div className='SidebarButtons non-printable close'>\n {headerButtons}\n {enableFullscreenToggle && (\n <SidebarFullscreenToggle\n isFullscreen={isFullscreen}\n onClick={handleFullscreenChange}\n tooltip={fullscreenToggleTooltip}\n />\n )}\n {!disableClose && (headerButtons || enableFullscreenToggle) && (\n <div className='SidebarButtons-spacer' />\n )}\n {!disableClose && <SidebarCloseButton onClick={onClose} />}\n </div>\n </div>\n {hasSmoothScrollbar ? (\n <SmoothScrollbars slideIn className={bodyClassNames} ref={bodyRef}>\n {children}\n </SmoothScrollbars>\n ) : (\n <div className={bodyClassNames} ref={bodyRef}>\n {children}\n </div>\n )}\n\n <SidebarFooter footer={footer} className={footerClassName} />\n </div>\n {resizable && (\n <Resizer\n onResizeStart={handleResizeStart}\n onResize={handleResize}\n onResizeEnd={handleResizeEnd}\n direction={Resizer.HORIZONTAL}\n position={isRight ? Resizer.LEFT : Resizer.RIGHT}\n />\n )}\n </>\n );\n\n return (\n <>\n <motion.div\n {...remainingProps}\n initial={previousClosed && 'sidebarEnter'}\n animate='sidebarVisible'\n // Cannot exit animation as sidebar is moved to offscreen by CSS class, means is still mounted\n exit='sidebarExit'\n variants={animationVariants}\n custom={{ fromRight: isRight, closed }}\n transition={{ duration: ANIMATION_DURATION }}\n className={wrapperClasses}\n style={{ width: internalWidth }}\n ref={sidebarRef}\n >\n {sidebarContent}\n </motion.div>\n {hasBackdrop && !closed && (\n <SidebarBackdrop\n className={backdropClassName}\n makeBackdropVisible={makeBackdropVisible}\n onClick={onBackdropClick}\n />\n )}\n </>\n );\n};\n\nSidebar.LEFT = SidebarPosition.LEFT;\nSidebar.RIGHT = SidebarPosition.RIGHT;\n\nSidebar.MODE_FLY = SidebarMode.MODE_FLY;\nSidebar.MODE_FLUID = SidebarMode.MODE_FLUID;\n\nexport default Sidebar;\n"],"names":["DEFAULT_WIDTH","DEFAULT_MIN_WIDTH","DEFAULT_MAX_WIDTH","DEFAULT_SWITCH_MODE_BREAKPOINT","MIN_MODULE_CONTENT_WIDTH","MAX_MODULE_CONTENT_WIDTH","ANIMATION_DURATION","RESIZE_THROTTLE","SidebarPosition","SidebarMode","animationVariants","fromRight","closed","Sidebar","props","fly","title","footer","resizable","position","width","minWidth","maxWidth","hasBackdrop","hasSmoothScrollbar","makeBackdropVisible","enableFullscreenToggle","fullscreenToggleTooltip","openInFullscreen","showHeaderBorder","disableClose","bodyRef","headerButtons","switchModeBreakpoint","onClose","noop","onResizeEnd","onFullScreenChange","onBackdropClick","disableEsc","titleClassName","bodyClassName","headerClassName","footerClassName","backdropClassName","className","children","remainingProps","internalWidth","setInternalWidth","useState","toNumber","sidebarMode","setSidebarMode","isFullscreen","setIsFullscreen","isResize","setIsResize","isSplit","setIsSplit","isRight","setIsRight","sidebarRef","useRef","moduleContentRef","useEffect","previousClosed","setPreviousClosed","previousWidth","setPreviousWidth","useWindowResize","adaptSidebarMode","moduleContent","useEsc","moduleContentWidth","isModuleContentTooSmall","isModuleContentBigEnough","isWindowSmallerThanBreakpoint","handleResize","diff","wasSplit","halfWindowWidth","usedMaxWidth","oldWidth","updatedWidth","newWidth","getWidthInBoundaries","handleResizeStart","handleResizeEnd","handleFullscreenChange","newFullscreenState","wrapperClasses","classNames","headerClassNames","titleClassNames","bodyClassNames","resizeLimitClasses","resizeIndicatorPosition","sidebarContent","jsxs","Fragment","jsx","SidebarFullscreenToggle","SidebarCloseButton","SmoothScrollbars","SidebarFooter","Resizer","motion","SidebarBackdrop"],"mappings":";;;;;;;;;;;;;;;AAiBA,MAAMA,KAAgB,KAChBC,KAAoB,KACpBC,KAAoB,KACpBC,IAAiC,GAIjCC,KAA2B,KAC3BC,KAA2B,KAE3BC,KAAqB,MACrBC,KAAkB,KAElBC,IAAkB;AAAA,EACpB,M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sidebars/Sidebar.tsx"],"sourcesContent":["import React, { type PropsWithChildren, useEffect, useRef, useState } from 'react';\nimport { motion } from 'motion/react';\nimport { noop } from 'es-toolkit/function';\nimport { toNumber } from 'es-toolkit/compat';\n\nimport classNames from '../../utils/classNames';\nimport SidebarFooter from './SidebarFooter';\nimport SidebarBackdrop from './SidebarBackdrop';\nimport SidebarFullscreenToggle from './SidebarFullscreenToggle';\nimport SidebarCloseButton from './SidebarCloseButton';\nimport Resizer from '../resizer/Resizer';\nimport useWindowResize from '../../hooks/useWindowResize';\nimport useEsc from '../../hooks/useEsc';\nimport getWidthInBoundaries from '../../utils/getWidthInBoundaries';\nimport type { ObjectValues } from '../../utils/ObjectValues';\nimport SmoothScrollbars from '../smoothScrollbars/SmoothScrollbars';\n\nconst DEFAULT_WIDTH = 350;\nconst DEFAULT_MIN_WIDTH = 100;\nconst DEFAULT_MAX_WIDTH = 800;\nconst DEFAULT_SWITCH_MODE_BREAKPOINT = 0;\n\n// Values define the min and max width for the module-content\n// where the fluid sidebar automatically changes to \"fly\" and back.\nconst MIN_MODULE_CONTENT_WIDTH = 400;\nconst MAX_MODULE_CONTENT_WIDTH = 800;\n\nconst ANIMATION_DURATION = 0.14;\nconst RESIZE_THROTTLE = 500;\n\nconst SidebarPosition = {\n LEFT: 'left',\n RIGHT: 'right',\n} as const;\n\nconst SidebarMode = {\n MODE_FLY: 'fly',\n MODE_FLUID: 'fluid',\n};\n\ntype AnimationVariantProps = {\n fromRight: boolean;\n closed?: boolean;\n};\n\nconst animationVariants = {\n sidebarEnter: ({ fromRight }: AnimationVariantProps) => ({\n x: fromRight ? '100%' : '-100%',\n opacity: 0,\n }),\n sidebarVisible: ({ fromRight, closed }: AnimationVariantProps) => ({\n x: !closed ? 0 : fromRight ? '100%' : '-100%',\n opacity: closed ? 0 : 1,\n display: closed ? 'none' : 'block',\n }),\n sidebarExit: ({ fromRight }: AnimationVariantProps) => ({\n x: fromRight ? '100%' : '-100%',\n opacity: 0,\n }),\n};\n\nexport type SidebarProps = {\n /**\n * Defines if the component will overlap the body content.\n *\n * @default false\n */\n fly?: boolean;\n\n /**\n * Defines whether the component is hidden or not.\n *\n * @default false\n */\n closed?: boolean;\n\n /**\n * Hides the close button. This may be used when the sidebar is always visible and may not be closed.\n *\n * @default false\n */\n disableClose?: boolean;\n\n /**\n * Callback function triggered when clicking the close icon.\n */\n onClose?: VoidFunction;\n\n /**\n * The Footer content. For example a save button.\n */\n footer?: string | React.ReactNode;\n\n /**\n * Additional classes added to the Sidebar footer.\n */\n footerClassName?: string;\n\n /**\n * Additional buttons to be rendered in the header.\n */\n headerButtons?: React.ReactNode;\n\n /**\n * Additional classes added to the Sidebar header.\n */\n headerClassName?: string;\n\n /**\n * Shows a sidebar header border\n */\n showHeaderBorder?: boolean;\n\n /**\n * Defines the width of the component. The value is set as pixel value as inline style.\n * Note: In the past, the type allowed to pass in a sting value like \"400px\" but that is not\n * possible anymore due to internal width calculations. To be backwards compatible for non\n * Typescript projects, the width is converted to a number.\n *\n * @default 350\n */\n width?: number;\n\n /**\n * Defines the minimum width in px of the component that will take effect when resizing.\n *\n * @default 100\n */\n minWidth?: number;\n\n /**\n * Defines the maximum width in px of the component that will take effect when resizing.\n *\n * @default 800\n */\n maxWidth?: number;\n\n /**\n * Opens Sidebar in fullscreen, means 100vw.\n *\n * @default false\n */\n openInFullscreen?: boolean;\n\n /**\n * Callback for when the fullscreen is toggled.\n */\n onFullScreenChange?: (newFullscreenState: boolean) => void;\n\n /**\n * Enables the fullscreen functionality and shows the fullscreen toggle.\n *\n * @default false\n */\n enableFullscreenToggle?: boolean;\n\n /**\n * Translated tooltip text for the fullscreen toggle button.\n */\n fullscreenToggleTooltip?: string;\n\n /**\n * Tells the sidebar where it is positioned. This will affect the resizing behavior\n * respectively. Note: the position need to be set properly whe using the resize\n * functionality to know on which side of the sidebar to attach the resizer handle.\n *\n * It is also relevant when the sidebar mode is set to `fly` to properly animate\n * the sidebar into the view.\n *\n * Possible values are:\n *\n * - `'left'`\n * - `'right'`\n * - `Sidebar.LEFT`\n * - `Sidebar.RIGHT`\n *\n * @default 'left'\n */\n position?: ObjectValues<typeof SidebarPosition>;\n\n /**\n * Defines whether or not the sidebar is resizable.\n * @default false\n */\n resizable?: boolean;\n\n /**\n * Callback for when the resize is done.\n */\n onResizeEnd?: VoidFunction;\n\n /**\n * Defines the breakpoint in pixel when the sidebar mode shall be changed. If the window width is lower\n * than the given breakpoint the mode is set to `fly`. If the window width is higher the mode is set\n * to `fluid`. This functionality is disabled by default and will be enabled when defining a breakpoint\n * higher than 0.\n */\n switchModeBreakpoint?: number;\n\n /**\n * By default the fullscreen mode can be left with \"esc\". If this is unwanted it can be disabled.\n *\n * @default false\n */\n disableEsc?: boolean;\n\n /**\n * Defined whether or not a backdrop will be rendered behind the Sidebar to avoid clicks outside.\n *\n * @default false\n */\n hasBackdrop?: boolean;\n\n /**\n * Defined whether or not the UIKIT SmoothScrollbar is active.\n *\n * @default false\n */\n hasSmoothScrollbar?: boolean;\n\n /**\n * Defined whether or not the backdrop is visible similar to the backdrop for modal dialogs.\n *\n * @default false\n */\n makeBackdropVisible?: boolean;\n\n /**\n * Callback for when the backdrop is clicked. This comes in handy when handling transient data from\n * the sidebar which need to be saved first and handle clicks outside.\n */\n onBackdropClick?: VoidFunction;\n\n /**\n * Additional ref added to the Sidebar body.\n */\n bodyRef?: React.MutableRefObject<HTMLDivElement | null>;\n\n /**\n * Content that will be displayed in the components header.\n */\n title?: string | React.ReactNode;\n\n /**\n * Additional classes added to the Sidebar title.\n */\n titleClassName?: string;\n\n /**\n * Additional classes added to the Sidebar backdrop.\n */\n backdropClassName?: string;\n\n /**\n * Additional classes added to the Sidebar body.\n */\n bodyClassName?: string;\n\n /**\n * Additional classes added on the wrapper element.\n */\n className?: string;\n};\n\nconst Sidebar = (props: PropsWithChildren<SidebarProps>) => {\n const {\n fly = false,\n closed = false,\n title = '',\n footer,\n resizable = false,\n position,\n width = DEFAULT_WIDTH,\n minWidth = DEFAULT_MIN_WIDTH,\n maxWidth = DEFAULT_MAX_WIDTH,\n hasBackdrop = false,\n hasSmoothScrollbar = false,\n makeBackdropVisible = false,\n enableFullscreenToggle = false,\n fullscreenToggleTooltip,\n openInFullscreen = false,\n showHeaderBorder = false,\n disableClose = false,\n bodyRef,\n headerButtons,\n switchModeBreakpoint = DEFAULT_SWITCH_MODE_BREAKPOINT,\n onClose = noop,\n onResizeEnd = noop,\n onFullScreenChange = noop,\n onBackdropClick = noop,\n disableEsc = false,\n titleClassName = '',\n bodyClassName = '',\n headerClassName = '',\n footerClassName = '',\n backdropClassName = '',\n className = '',\n children,\n ...remainingProps\n } = props;\n\n const [internalWidth, setInternalWidth] = useState(toNumber(width));\n const [sidebarMode, setSidebarMode] = useState(fly ? Sidebar.MODE_FLY : Sidebar.MODE_FLUID);\n const [isFullscreen, setIsFullscreen] = useState(openInFullscreen);\n const [isResize, setIsResize] = useState(false);\n const [isSplit, setIsSplit] = useState(false);\n const [isRight, setIsRight] = useState(position === SidebarPosition.RIGHT);\n\n const sidebarRef = useRef<HTMLDivElement>(null);\n\n // Used to keep the external reference to the module-content to avoid querying the DOM\n // periodically on window resize\n const moduleContentRef: React.MutableRefObject<HTMLDivElement | null> = useRef(null);\n\n // Position fallback in case the position property is not defined but the sidebar mode is fly\n // and we want to animate it, we nee to know the direction from where th sidebar is coming from.\n // That's why we check the ApplicationLayoutSidebar class if the sidebar inside is right aligned\n // or not and us this value instead.\n // Note: the position need to be set properly whe using the resize functionality to know on which\n // side of the sidebar to attach the resizer handle.\n useEffect(() => {\n if (sidebarRef.current && sidebarMode === Sidebar.MODE_FLY) {\n const sidebarLayout = sidebarRef.current.parentNode as HTMLDivElement;\n if (sidebarLayout?.className.includes('right')) {\n setIsRight(true);\n }\n }\n }, [sidebarRef.current, sidebarMode]);\n\n // Keep the previous closed state in order to prevent animation when switching sidebar mode\n const [previousClosed, setPreviousClosed] = useState(closed);\n if (previousClosed !== closed) {\n setPreviousClosed(closed);\n }\n\n // Update internal width from outside\n const [previousWidth, setPreviousWidth] = useState(width);\n if (previousWidth !== width) {\n console.log('update internal width');\n setInternalWidth(toNumber(width));\n setPreviousWidth(width);\n }\n\n // Switch between mode \"fly\" and \"fluid\"\n useWindowResize(() => adaptSidebarMode(), RESIZE_THROTTLE);\n\n // Initially check breakpoint after mounting the component\n useEffect(() => adaptSidebarMode(), []);\n\n // When Sidebar opens, check for available module-content width and\n // switch sidebar mode to fly in case\n useEffect(() => {\n if (!closed) {\n setTimeout(() => adaptSidebarMode());\n }\n }, [closed]);\n\n useEffect(() => {\n const moduleContent = document.querySelector('.module-content');\n if (moduleContent) {\n moduleContentRef.current = moduleContent as HTMLDivElement;\n }\n }, []);\n\n // Close the fullscreen with \"esc\"\n useEsc(() => {\n if (!disableEsc && enableFullscreenToggle && isFullscreen) {\n setIsFullscreen(false);\n onFullScreenChange(false);\n }\n });\n\n const adaptSidebarMode = () => {\n const moduleContentWidth = moduleContentRef.current?.clientWidth;\n\n if (fly || switchModeBreakpoint === DEFAULT_SWITCH_MODE_BREAKPOINT) {\n return;\n }\n\n const isModuleContentTooSmall = moduleContentWidth && moduleContentWidth <= MIN_MODULE_CONTENT_WIDTH;\n const isModuleContentBigEnough = moduleContentWidth && moduleContentWidth > MAX_MODULE_CONTENT_WIDTH;\n\n const isWindowSmallerThanBreakpoint = window.innerWidth <= switchModeBreakpoint;\n\n // switch to fly when module-content is less than x pixel and back if it is bigger\n if (isModuleContentTooSmall || isWindowSmallerThanBreakpoint) {\n setSidebarMode(Sidebar.MODE_FLY);\n return;\n }\n\n // if module-content is bigger and is initially fluid set back to initial fluid state\n if (isModuleContentBigEnough && !isWindowSmallerThanBreakpoint) {\n setSidebarMode(Sidebar.MODE_FLUID);\n return;\n }\n };\n\n const handleResize = (diff: number) => {\n const wasSplit = isSplit;\n const halfWindowWidth = window.innerWidth * 0.5;\n const usedMaxWidth = maxWidth || halfWindowWidth;\n\n // Check for sidebar width if it is half the window size. If it was before but the sidebar was resized so it is\n // no longer half window size, set the sidebar with to half window size to avoid jumping sidebar to old width\n setInternalWidth(oldWidth => {\n const updatedWidth = position === Sidebar.RIGHT ? oldWidth + diff : oldWidth - diff;\n const newWidth = getWidthInBoundaries(minWidth, usedMaxWidth, updatedWidth);\n\n const newIsSplit = newWidth === halfWindowWidth;\n setIsSplit(newIsSplit);\n\n return wasSplit && !isSplit ? halfWindowWidth : newWidth;\n });\n\n adaptSidebarMode();\n };\n\n const handleResizeStart = () => {\n const body = document.body;\n body?.classList.add('pointer-events-none');\n setIsResize(true);\n };\n\n const handleResizeEnd = () => {\n const body = document.body;\n body?.classList.remove('pointer-events-none');\n setIsResize(false);\n onResizeEnd();\n };\n\n const handleFullscreenChange = () => {\n const newFullscreenState = !isFullscreen;\n setIsFullscreen(newFullscreenState);\n onFullScreenChange(newFullscreenState);\n };\n\n const wrapperClasses = classNames(\n 'Sidebar',\n className,\n closed && 'closed',\n isFullscreen && 'width-100vw sidebar-fullscreen',\n isSplit && !isFullscreen && 'max-width-50vw width-50vw',\n sidebarMode === SidebarMode.MODE_FLY ? 'fly' : isFullscreen ? 'fly' : 'fluid'\n );\n\n const headerClassNames = classNames('SidebarHeader', headerClassName, showHeaderBorder && 'show-border');\n const titleClassNames = classNames('SidebarTitle', titleClassName);\n const bodyClassNames = classNames('SidebarBody', bodyClassName);\n\n const resizeLimitClasses = classNames('SidebarResizeLimit', isResize && 'display-block');\n\n const resizeIndicatorPosition = maxWidth || window.innerWidth * 0.5;\n const resizeLimitStyle = isRight ? { right: resizeIndicatorPosition } : { left: resizeIndicatorPosition };\n\n const sidebarContent = (\n <>\n <div className={resizeLimitClasses} style={resizeLimitStyle} />\n <div className='SidebarContent'>\n <div className={headerClassNames}>\n <div className={titleClassNames}>{title}</div>\n <div className='SidebarButtons non-printable close'>\n {headerButtons}\n {enableFullscreenToggle && (\n <SidebarFullscreenToggle\n isFullscreen={isFullscreen}\n onClick={handleFullscreenChange}\n tooltip={fullscreenToggleTooltip}\n />\n )}\n {!disableClose && (headerButtons || enableFullscreenToggle) && (\n <div className='SidebarButtons-spacer' />\n )}\n {!disableClose && <SidebarCloseButton title={title} onClick={onClose} />}\n </div>\n </div>\n {hasSmoothScrollbar ? (\n <SmoothScrollbars slideIn className={bodyClassNames} ref={bodyRef}>\n {children}\n </SmoothScrollbars>\n ) : (\n <div className={bodyClassNames} ref={bodyRef}>\n {children}\n </div>\n )}\n\n <SidebarFooter footer={footer} className={footerClassName} />\n </div>\n {resizable && (\n <Resizer\n onResizeStart={handleResizeStart}\n onResize={handleResize}\n onResizeEnd={handleResizeEnd}\n direction={Resizer.HORIZONTAL}\n position={isRight ? Resizer.LEFT : Resizer.RIGHT}\n />\n )}\n </>\n );\n\n return (\n <>\n <motion.div\n {...remainingProps}\n initial={previousClosed && 'sidebarEnter'}\n animate='sidebarVisible'\n // Cannot exit animation as sidebar is moved to offscreen by CSS class, means is still mounted\n exit='sidebarExit'\n variants={animationVariants}\n custom={{ fromRight: isRight, closed }}\n transition={{ duration: ANIMATION_DURATION }}\n className={wrapperClasses}\n style={{ width: internalWidth }}\n ref={sidebarRef}\n >\n {sidebarContent}\n </motion.div>\n {hasBackdrop && !closed && (\n <SidebarBackdrop\n className={backdropClassName}\n makeBackdropVisible={makeBackdropVisible}\n onClick={onBackdropClick}\n />\n )}\n </>\n );\n};\n\nSidebar.LEFT = SidebarPosition.LEFT;\nSidebar.RIGHT = SidebarPosition.RIGHT;\n\nSidebar.MODE_FLY = SidebarMode.MODE_FLY;\nSidebar.MODE_FLUID = SidebarMode.MODE_FLUID;\n\nexport default Sidebar;\n"],"names":["DEFAULT_WIDTH","DEFAULT_MIN_WIDTH","DEFAULT_MAX_WIDTH","DEFAULT_SWITCH_MODE_BREAKPOINT","MIN_MODULE_CONTENT_WIDTH","MAX_MODULE_CONTENT_WIDTH","ANIMATION_DURATION","RESIZE_THROTTLE","SidebarPosition","SidebarMode","animationVariants","fromRight","closed","Sidebar","props","fly","title","footer","resizable","position","width","minWidth","maxWidth","hasBackdrop","hasSmoothScrollbar","makeBackdropVisible","enableFullscreenToggle","fullscreenToggleTooltip","openInFullscreen","showHeaderBorder","disableClose","bodyRef","headerButtons","switchModeBreakpoint","onClose","noop","onResizeEnd","onFullScreenChange","onBackdropClick","disableEsc","titleClassName","bodyClassName","headerClassName","footerClassName","backdropClassName","className","children","remainingProps","internalWidth","setInternalWidth","useState","toNumber","sidebarMode","setSidebarMode","isFullscreen","setIsFullscreen","isResize","setIsResize","isSplit","setIsSplit","isRight","setIsRight","sidebarRef","useRef","moduleContentRef","useEffect","previousClosed","setPreviousClosed","previousWidth","setPreviousWidth","useWindowResize","adaptSidebarMode","moduleContent","useEsc","moduleContentWidth","isModuleContentTooSmall","isModuleContentBigEnough","isWindowSmallerThanBreakpoint","handleResize","diff","wasSplit","halfWindowWidth","usedMaxWidth","oldWidth","updatedWidth","newWidth","getWidthInBoundaries","handleResizeStart","handleResizeEnd","handleFullscreenChange","newFullscreenState","wrapperClasses","classNames","headerClassNames","titleClassNames","bodyClassNames","resizeLimitClasses","resizeIndicatorPosition","sidebarContent","jsxs","Fragment","jsx","SidebarFullscreenToggle","SidebarCloseButton","SmoothScrollbars","SidebarFooter","Resizer","motion","SidebarBackdrop"],"mappings":";;;;;;;;;;;;;;;AAiBA,MAAMA,KAAgB,KAChBC,KAAoB,KACpBC,KAAoB,KACpBC,IAAiC,GAIjCC,KAA2B,KAC3BC,KAA2B,KAE3BC,KAAqB,MACrBC,KAAkB,KAElBC,IAAkB;AAAA,EACpB,MAAM;AAAA,EACN,OAAO;AACX,GAEMC,IAAc;AAAA,EAChB,UAAU;AAAA,EACV,YAAY;AAChB,GAOMC,KAAoB;AAAA,EACtB,cAAc,CAAC,EAAE,WAAAC,SAAwC;AAAA,IACrD,GAAGA,IAAY,SAAS;AAAA,IACxB,SAAS;AAAA,EAAA;AAAA,EAEb,gBAAgB,CAAC,EAAE,WAAAA,GAAW,QAAAC,SAAqC;AAAA,IAC/D,GAAIA,IAAaD,IAAY,SA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F;AAAA,MAACK;AAAA,MAAA;AAAA,QACG,eAAenB;AAAA,QACf,UAAUT;AAAA,QACV,aAAaU;AAAA,QACb,WAAWkB,EAAQ;AAAA,QACnB,UAAU9C,IAAU8C,EAAQ,OAAOA,EAAQ;AAAA,MAAA;AAAA,IAAA;AAAA,EAC/C,GAER;AAGJ,SACI,gBAAAP,EAAAC,GAAA,EACI,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAACM,GAAO;AAAA,MAAP;AAAA,QACI,GAAG5D;AAAA,QACJ,SAASmB,KAAkB;AAAA,QAC3B,SAAQ;AAAA,QAER,MAAK;AAAA,QACL,UAAUxD;AAAA,QACV,QAAQ,EAAE,WAAWkD,GAAS,QAAAhD,EAAA;AAAA,QAC9B,YAAY,EAAE,UAAUN,GAAA;AAAA,QACxB,WAAWqF;AAAA,QACX,OAAO,EAAE,OAAO3C,GAAA;AAAA,QAChB,KAAKc;AAAA,QAEJ,UAAAoC;AAAA,MAAA;AAAA,IAAA;AAAA,IAEJ3E,KAAe,CAACX,KACb,gBAAAyF;AAAA,MAACO;AAAA,MAAA;AAAA,QACG,WAAWhE;AAAA,QACX,qBAAAnB;AAAA,QACA,SAASa;AAAA,MAAA;AAAA,IAAA;AAAA,EACb,GAER;AAER;AAEAzB,EAAQ,OAAOL,EAAgB;AAC/BK,EAAQ,QAAQL,EAAgB;AAEhCK,EAAQ,WAAWJ,EAAY;AAC/BI,EAAQ,aAAaJ,EAAY;"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
export type SidebarCloseButtonProps = {
|
|
3
|
+
title?: ReactNode;
|
|
2
4
|
onClick?: VoidFunction;
|
|
3
5
|
};
|
|
4
|
-
declare const SidebarCloseButton: ({ onClick }: SidebarCloseButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare const SidebarCloseButton: ({ title, onClick }: SidebarCloseButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
7
|
export default SidebarCloseButton;
|
|
@@ -1,8 +1,22 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { noop as
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { noop as i } from "es-toolkit/function";
|
|
3
|
+
import r from "../button/Button.js";
|
|
4
|
+
import { getTrackingLabelFromNode as n } from "../../utils/analytics/getTrackingLabelFromNode.js";
|
|
5
|
+
const d = ({ title: e, onClick: a = i }) => {
|
|
6
|
+
const o = n(e);
|
|
7
|
+
return /* @__PURE__ */ t(
|
|
8
|
+
r,
|
|
9
|
+
{
|
|
10
|
+
bsStyle: r.MUTED,
|
|
11
|
+
iconOnly: !0,
|
|
12
|
+
onClick: a,
|
|
13
|
+
autoTrackingKey: o && `sidebar::closed::${o}`,
|
|
14
|
+
"data-testid": "sidebarCloseButton",
|
|
15
|
+
children: /* @__PURE__ */ t("span", { className: "rioglyph rioglyph-remove" })
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
};
|
|
5
19
|
export {
|
|
6
|
-
|
|
20
|
+
d as default
|
|
7
21
|
};
|
|
8
22
|
//# sourceMappingURL=SidebarCloseButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SidebarCloseButton.js","sources":["../../../src/components/sidebars/SidebarCloseButton.tsx"],"sourcesContent":["import { noop } from 'es-toolkit/function';\n\nimport Button from '../button/Button';\n\nexport type SidebarCloseButtonProps = {\n onClick?: VoidFunction;\n};\n\nconst SidebarCloseButton = ({ onClick = noop }: SidebarCloseButtonProps) => (\n <Button
|
|
1
|
+
{"version":3,"file":"SidebarCloseButton.js","sources":["../../../src/components/sidebars/SidebarCloseButton.tsx"],"sourcesContent":["import { noop } from 'es-toolkit/function';\nimport type { ReactNode } from 'react';\n\nimport Button from '../button/Button';\nimport { getTrackingLabelFromNode } from '../../utils/analytics/getTrackingLabelFromNode';\n\nexport type SidebarCloseButtonProps = {\n title?: ReactNode;\n onClick?: VoidFunction;\n};\n\nconst SidebarCloseButton = ({ title, onClick = noop }: SidebarCloseButtonProps) => {\n const titleTrackingValue = getTrackingLabelFromNode(title);\n\n return (\n <Button\n bsStyle={Button.MUTED}\n iconOnly\n onClick={onClick}\n autoTrackingKey={titleTrackingValue && `sidebar::closed::${titleTrackingValue}`}\n data-testid='sidebarCloseButton'\n >\n <span className='rioglyph rioglyph-remove' />\n </Button>\n );\n};\n\nexport default SidebarCloseButton;\n"],"names":["SidebarCloseButton","title","onClick","noop","titleTrackingValue","getTrackingLabelFromNode","jsx","Button"],"mappings":";;;;AAWA,MAAMA,IAAqB,CAAC,EAAE,OAAAC,GAAO,SAAAC,IAAUC,QAAoC;AAC/E,QAAMC,IAAqBC,EAAyBJ,CAAK;AAEzD,SACI,gBAAAK;AAAA,IAACC;AAAA,IAAA;AAAA,MACG,SAASA,EAAO;AAAA,MAChB,UAAQ;AAAA,MACR,SAAAL;AAAA,MACA,iBAAiBE,KAAsB,oBAAoBA,CAAkB;AAAA,MAC7E,eAAY;AAAA,MAEZ,UAAA,gBAAAE,EAAC,QAAA,EAAK,WAAU,2BAAA,CAA2B;AAAA,IAAA;AAAA,EAAA;AAGvD;"}
|
|
@@ -21,10 +21,16 @@ export type BaseStateProps = {
|
|
|
21
21
|
image?: React.ReactNode;
|
|
22
22
|
/**
|
|
23
23
|
* The headline to be shown.
|
|
24
|
+
*
|
|
25
|
+
* Always provide a clear headline for state components.
|
|
24
26
|
*/
|
|
25
27
|
headline?: string | React.ReactNode;
|
|
26
28
|
/**
|
|
27
|
-
* The text to display.
|
|
29
|
+
* The descriptive text to display below the headline.
|
|
30
|
+
*
|
|
31
|
+
* Always provide a message for state components such as ErrorState, NotFoundState,
|
|
32
|
+
* EmptyState, ForbiddenState, MaintenanceState and CustomState so users understand
|
|
33
|
+
* what happened and what they can do next.
|
|
28
34
|
*/
|
|
29
35
|
message?: string | React.ReactNode;
|
|
30
36
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomState.js","sources":["../../../src/components/states/CustomState.tsx"],"sourcesContent":["import type { PropsWithChildren } from 'react';\nimport { isEmpty } from 'es-toolkit/compat';\n\nimport classNames from '../../utils/classNames';\nimport StateButton, { type StateButtonProps } from './StateButton';\nimport StateIcon from './StateIcon';\nimport type { TextAlignment } from '../../values/TextAlignment';\nimport type { StateIconProps } from './StateIcon';\nimport { hasPaddingClass } from '../../utils/hasUtilityClass';\n\nexport type BaseStateProps = {\n /**\n * The icon to be shown.\n *\n * Default icons are defined for all states.\n */\n icon?: string;\n\n /**\n * List of icons to show instead a single icon.\n *\n * @default []\n */\n icons?: StateIconProps[];\n\n /**\n * Custom Image if needed.\n */\n image?: React.ReactNode;\n\n /**\n * The headline to be shown.\n */\n headline?: string | React.ReactNode;\n\n /**\n * The text to display.\n */\n message?: string | React.ReactNode;\n\n /**\n * Definitions for the buttons to show.\n *\n * @default []\n */\n buttons?: StateButtonProps[];\n\n /**\n * Defines whether to use 100% width or default width.\n *\n * __Note:__ Only to be used for special cases on the CustomState component.\n *\n * @default false\n */\n fullWidth?: boolean;\n\n /**\n * Smaller icon and headline size.\n *\n * @default false\n */\n condensed?: boolean;\n\n /**\n * Defines where the panel is aligned.\n *\n * Possible values are:\n *\n * - `'left'`\n * - `'center'`\n * - `'right'`\n *\n * @default 'center'\n */\n alignment?: TextAlignment;\n\n /**\n * Optional class names for the wrapper.\n */\n outerClassName?: string;\n\n /**\n * Optional class names for the content.\n */\n innerClassName?: string;\n};\n\nconst justify: Record<TextAlignment, string> = {\n left: 'justify-content-start',\n center: 'justify-content-center',\n right: 'justify-content-end',\n};\n\nconst renderButtons = (buttons: StateButtonProps[]) => {\n if (isEmpty(buttons)) {\n return;\n }\n\n if (buttons.length === 1) {\n return (\n <div className='btn-toolbar margin-top-20'>\n <StateButton {...buttons[0]} />\n </div>\n );\n }\n\n if (buttons.length === 2) {\n return (\n <div className='btn-toolbar margin-top-20 justify-content-center-xs'>\n {buttons.map((buttonProps, index) => (\n <StateButton key={index} {...buttonProps} />\n ))}\n </div>\n );\n }\n\n return (\n <>\n <div className='btn-toolbar margin-top-20 justify-content-center-xs'>\n <StateButton key='1' {...buttons[0]} />\n <StateButton key='2' {...buttons[1]} />\n </div>\n <div className='btn-toolbar'>\n {buttons.map((buttonProps, index) => index > 1 && <StateButton key={index} {...buttonProps} />)}\n </div>\n </>\n );\n};\n\nexport type CustomStateProps = BaseStateProps;\n\nconst CustomState = (props: PropsWithChildren<CustomStateProps>) => {\n const {\n icon,\n icons = [],\n image,\n headline,\n message,\n buttons = [],\n alignment = 'center',\n fullWidth = false,\n condensed = false,\n outerClassName = '',\n innerClassName = '',\n children,\n ...remainingProps\n } = props;\n\n const wrapperClasses = classNames(\n 'margin-0',\n 'width-100pct',\n !fullWidth && 'max-width-600',\n 'panel-default',\n 'panel',\n !hasPaddingClass(outerClassName) ? (condensed ? 'padding-10' : 'padding-15') : '',\n outerClassName\n );\n\n const innerClassNames = classNames(\n 'display-flex',\n 'flex-column',\n 'align-items-center',\n 'text-center',\n !hasPaddingClass(innerClassName) ? (condensed ? 'padding-15' : 'padding-25') : '',\n innerClassName\n );\n\n const iconClasses = classNames(condensed ? 'text-size-16 margin-bottom-10' : 'text-size-h2 margin-bottom-20');\n\n const iconsClasses = classNames(\n condensed ? 'text-size-16 margin-bottom-10' : 'text-size-h2 margin-bottom-20',\n 'display-flex',\n 'align-items-center',\n 'max-width-100pct'\n );\n\n const headlineClassNames = classNames(\n condensed ? 'text-size-h4' : 'text-size-h3 text-size-h2-xl',\n 'line-height-125rel',\n 'text-color-dark',\n 'text-medium',\n 'width-500',\n 'max-width-100pct',\n 'text-wrap-balance'\n );\n\n const renderIcon = (\n <>\n {icon && (\n <div className={iconClasses}>\n <StateIcon name={icon} />\n </div>\n )}\n </>\n );\n\n const renderIcons = (\n <div className={iconsClasses}>\n {icons.map((iconProps, index) => (\n <StateIcon key={index} {...iconProps} />\n ))}\n </div>\n );\n\n const renderChildren = <div className='width-500 max-width-100pct margin-top-25'>{children}</div>;\n\n const renderHeadline = <div className={headlineClassNames}>{headline}</div>;\n\n const renderMessage = (\n <div className='text-color-dark margin-top-15 width-500 max-width-100pct text-wrap-balance'>{message}</div>\n );\n\n const singleOrMultiIcon = isEmpty(icons) ? renderIcon : renderIcons;\n\n const imageOrIcon = image ? image : singleOrMultiIcon;\n\n return (\n <div className={`display-flex ${justify[alignment]} max-width-100pct`} {...remainingProps}>\n <div className={wrapperClasses}>\n <div className={innerClassNames}>\n {imageOrIcon}\n {headline && renderHeadline}\n {message && renderMessage}\n {renderButtons(buttons)}\n {children && renderChildren}\n </div>\n </div>\n </div>\n );\n};\n\nexport default CustomState;\n"],"names":["justify","renderButtons","buttons","isEmpty","jsx","StateButton","buttonProps","index","jsxs","Fragment","CustomState","props","icon","icons","image","headline","message","alignment","fullWidth","condensed","outerClassName","innerClassName","children","remainingProps","wrapperClasses","classNames","hasPaddingClass","innerClassNames","iconClasses","iconsClasses","headlineClassNames","renderIcon","StateIcon","renderIcons","iconProps","renderChildren","renderHeadline","renderMessage","singleOrMultiIcon","imageOrIcon"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"CustomState.js","sources":["../../../src/components/states/CustomState.tsx"],"sourcesContent":["import type { PropsWithChildren } from 'react';\nimport { isEmpty } from 'es-toolkit/compat';\n\nimport classNames from '../../utils/classNames';\nimport StateButton, { type StateButtonProps } from './StateButton';\nimport StateIcon from './StateIcon';\nimport type { TextAlignment } from '../../values/TextAlignment';\nimport type { StateIconProps } from './StateIcon';\nimport { hasPaddingClass } from '../../utils/hasUtilityClass';\n\nexport type BaseStateProps = {\n /**\n * The icon to be shown.\n *\n * Default icons are defined for all states.\n */\n icon?: string;\n\n /**\n * List of icons to show instead a single icon.\n *\n * @default []\n */\n icons?: StateIconProps[];\n\n /**\n * Custom Image if needed.\n */\n image?: React.ReactNode;\n\n /**\n * The headline to be shown.\n *\n * Always provide a clear headline for state components.\n */\n headline?: string | React.ReactNode;\n\n /**\n * The descriptive text to display below the headline.\n *\n * Always provide a message for state components such as ErrorState, NotFoundState,\n * EmptyState, ForbiddenState, MaintenanceState and CustomState so users understand\n * what happened and what they can do next.\n */\n message?: string | React.ReactNode;\n\n /**\n * Definitions for the buttons to show.\n *\n * @default []\n */\n buttons?: StateButtonProps[];\n\n /**\n * Defines whether to use 100% width or default width.\n *\n * __Note:__ Only to be used for special cases on the CustomState component.\n *\n * @default false\n */\n fullWidth?: boolean;\n\n /**\n * Smaller icon and headline size.\n *\n * @default false\n */\n condensed?: boolean;\n\n /**\n * Defines where the panel is aligned.\n *\n * Possible values are:\n *\n * - `'left'`\n * - `'center'`\n * - `'right'`\n *\n * @default 'center'\n */\n alignment?: TextAlignment;\n\n /**\n * Optional class names for the wrapper.\n */\n outerClassName?: string;\n\n /**\n * Optional class names for the content.\n */\n innerClassName?: string;\n};\n\nconst justify: Record<TextAlignment, string> = {\n left: 'justify-content-start',\n center: 'justify-content-center',\n right: 'justify-content-end',\n};\n\nconst renderButtons = (buttons: StateButtonProps[]) => {\n if (isEmpty(buttons)) {\n return;\n }\n\n if (buttons.length === 1) {\n return (\n <div className='btn-toolbar margin-top-20'>\n <StateButton {...buttons[0]} />\n </div>\n );\n }\n\n if (buttons.length === 2) {\n return (\n <div className='btn-toolbar margin-top-20 justify-content-center-xs'>\n {buttons.map((buttonProps, index) => (\n <StateButton key={index} {...buttonProps} />\n ))}\n </div>\n );\n }\n\n return (\n <>\n <div className='btn-toolbar margin-top-20 justify-content-center-xs'>\n <StateButton key='1' {...buttons[0]} />\n <StateButton key='2' {...buttons[1]} />\n </div>\n <div className='btn-toolbar'>\n {buttons.map((buttonProps, index) => index > 1 && <StateButton key={index} {...buttonProps} />)}\n </div>\n </>\n );\n};\n\nexport type CustomStateProps = BaseStateProps;\n\nconst CustomState = (props: PropsWithChildren<CustomStateProps>) => {\n const {\n icon,\n icons = [],\n image,\n headline,\n message,\n buttons = [],\n alignment = 'center',\n fullWidth = false,\n condensed = false,\n outerClassName = '',\n innerClassName = '',\n children,\n ...remainingProps\n } = props;\n\n const wrapperClasses = classNames(\n 'margin-0',\n 'width-100pct',\n !fullWidth && 'max-width-600',\n 'panel-default',\n 'panel',\n !hasPaddingClass(outerClassName) ? (condensed ? 'padding-10' : 'padding-15') : '',\n outerClassName\n );\n\n const innerClassNames = classNames(\n 'display-flex',\n 'flex-column',\n 'align-items-center',\n 'text-center',\n !hasPaddingClass(innerClassName) ? (condensed ? 'padding-15' : 'padding-25') : '',\n innerClassName\n );\n\n const iconClasses = classNames(condensed ? 'text-size-16 margin-bottom-10' : 'text-size-h2 margin-bottom-20');\n\n const iconsClasses = classNames(\n condensed ? 'text-size-16 margin-bottom-10' : 'text-size-h2 margin-bottom-20',\n 'display-flex',\n 'align-items-center',\n 'max-width-100pct'\n );\n\n const headlineClassNames = classNames(\n condensed ? 'text-size-h4' : 'text-size-h3 text-size-h2-xl',\n 'line-height-125rel',\n 'text-color-dark',\n 'text-medium',\n 'width-500',\n 'max-width-100pct',\n 'text-wrap-balance'\n );\n\n const renderIcon = (\n <>\n {icon && (\n <div className={iconClasses}>\n <StateIcon name={icon} />\n </div>\n )}\n </>\n );\n\n const renderIcons = (\n <div className={iconsClasses}>\n {icons.map((iconProps, index) => (\n <StateIcon key={index} {...iconProps} />\n ))}\n </div>\n );\n\n const renderChildren = <div className='width-500 max-width-100pct margin-top-25'>{children}</div>;\n\n const renderHeadline = <div className={headlineClassNames}>{headline}</div>;\n\n const renderMessage = (\n <div className='text-color-dark margin-top-15 width-500 max-width-100pct text-wrap-balance'>{message}</div>\n );\n\n const singleOrMultiIcon = isEmpty(icons) ? renderIcon : renderIcons;\n\n const imageOrIcon = image ? image : singleOrMultiIcon;\n\n return (\n <div className={`display-flex ${justify[alignment]} max-width-100pct`} {...remainingProps}>\n <div className={wrapperClasses}>\n <div className={innerClassNames}>\n {imageOrIcon}\n {headline && renderHeadline}\n {message && renderMessage}\n {renderButtons(buttons)}\n {children && renderChildren}\n </div>\n </div>\n </div>\n );\n};\n\nexport default CustomState;\n"],"names":["justify","renderButtons","buttons","isEmpty","jsx","StateButton","buttonProps","index","jsxs","Fragment","CustomState","props","icon","icons","image","headline","message","alignment","fullWidth","condensed","outerClassName","innerClassName","children","remainingProps","wrapperClasses","classNames","hasPaddingClass","innerClassNames","iconClasses","iconsClasses","headlineClassNames","renderIcon","StateIcon","renderIcons","iconProps","renderChildren","renderHeadline","renderMessage","singleOrMultiIcon","imageOrIcon"],"mappings":";;;;;;AA6FA,MAAMA,IAAyC;AAAA,EAC3C,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AACX,GAEMC,IAAgB,CAACC,MAAgC;AACnD,MAAI,CAAAC,EAAQD,CAAO;AAInB,WAAIA,EAAQ,WAAW,IAEf,gBAAAE,EAAC,OAAA,EAAI,WAAU,6BACX,UAAA,gBAAAA,EAACC,KAAa,GAAGH,EAAQ,CAAC,EAAA,CAAG,EAAA,CACjC,IAIJA,EAAQ,WAAW,IAEf,gBAAAE,EAAC,OAAA,EAAI,WAAU,uDACV,YAAQ,IAAI,CAACE,GAAaC,wBACtBF,GAAA,EAAyB,GAAGC,KAAXC,CAAwB,CAC7C,GACL,IAKJ,gBAAAC,EAAAC,GAAA,EACI,UAAA;AAAA,MAAA,gBAAAD,EAAC,OAAA,EAAI,WAAU,uDACX,UAAA;AAAA,QAAA,gBAAAJ,EAACC,GAAA,EAAqB,GAAGH,EAAQ,CAAC,KAAjB,GAAoB;AAAA,0BACpCG,GAAA,EAAqB,GAAGH,EAAQ,CAAC,KAAjB,GAAoB;AAAA,MAAA,GACzC;AAAA,wBACC,OAAA,EAAI,WAAU,eACV,UAAAA,EAAQ,IAAI,CAACI,GAAaC,MAAUA,IAAQ,KAAK,gBAAAH,EAACC,GAAA,EAAyB,GAAGC,EAAA,GAAXC,CAAwB,CAAE,EAAA,CAClG;AAAA,IAAA,GACJ;AAER,GAIMG,IAAc,CAACC,MAA+C;AAChE,QAAM;AAAA,IACF,MAAAC;AAAA,I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S,GAErFc,IAAiB,gBAAAhC,EAAC,OAAA,EAAI,WAAW0B,GAAqB,UAAAf,GAAS,GAE/DsB,IACF,gBAAAjC,EAAC,OAAA,EAAI,WAAU,8EAA8E,UAAAY,GAAQ,GAGnGsB,IAAoBnC,EAAQU,CAAK,IAAIkB,IAAaE,GAElDM,IAAczB,KAAgBwB;AAEpC,2BACK,OAAA,EAAI,WAAW,gBAAgBtC,EAAQiB,CAAS,CAAC,qBAAsB,GAAGM,GACvE,4BAAC,OAAA,EAAI,WAAWC,GACZ,UAAA,gBAAAhB,EAAC,OAAA,EAAI,WAAWmB,GACX,UAAA;AAAA,IAAAY;AAAA,IACAxB,KAAYqB;AAAA,IACZpB,KAAWqB;AAAA,IACXpC,EAAcC,CAAO;AAAA,IACrBoB,KAAYa;AAAA,EAAA,EAAA,CACjB,GACJ,GACJ;AAER;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
+
import { AutoTrackingAttributes } from '../../utils/analytics/autoTracking';
|
|
2
3
|
import { BUTTON_STYLE } from '../../Button';
|
|
3
|
-
export type StateButtonProps = {
|
|
4
|
+
export type StateButtonProps = AutoTrackingAttributes & {
|
|
4
5
|
/**
|
|
5
6
|
* The button text.
|
|
6
7
|
*
|
|
@@ -29,6 +30,15 @@ export type StateButtonProps = {
|
|
|
29
30
|
* Additional classes assigned to the button.
|
|
30
31
|
*/
|
|
31
32
|
className?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Optional key used to generate automatic GA tracking attributes when no explicit
|
|
35
|
+
* tracking attributes are provided.
|
|
36
|
+
*/
|
|
37
|
+
autoTrackingKey?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Optional tracking attributes (e.g. from `getTrackingAttributes`) added to the button or link element.
|
|
40
|
+
*/
|
|
41
|
+
trackingAttributes?: AutoTrackingAttributes;
|
|
32
42
|
};
|
|
33
43
|
declare const StateButton: (props: StateButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
34
44
|
export default StateButton;
|
|
@@ -1,14 +1,50 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { getAutoTrackingAttributes as b } from "../../utils/analytics/autoTracking.js";
|
|
3
|
+
import c from "../../utils/classNames.js";
|
|
4
|
+
const N = (m) => {
|
|
5
|
+
const {
|
|
6
|
+
text: o,
|
|
7
|
+
bsStyle: u = "primary",
|
|
8
|
+
className: s,
|
|
9
|
+
onClick: a = () => {
|
|
10
|
+
},
|
|
11
|
+
href: t,
|
|
12
|
+
autoTrackingKey: l,
|
|
13
|
+
trackingAttributes: r,
|
|
14
|
+
...n
|
|
15
|
+
} = m, e = b({
|
|
16
|
+
autoTrackingKey: l,
|
|
17
|
+
props: { ...r, ...n },
|
|
18
|
+
source: t ? "link" : "button"
|
|
19
|
+
});
|
|
20
|
+
if (t)
|
|
21
|
+
return /* @__PURE__ */ i(
|
|
22
|
+
"a",
|
|
23
|
+
{
|
|
24
|
+
className: c("margin-top-15", s),
|
|
25
|
+
href: t,
|
|
26
|
+
onClick: a,
|
|
27
|
+
...e,
|
|
28
|
+
...r,
|
|
29
|
+
...n,
|
|
30
|
+
children: o
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
const p = c("btn", "margin-top-10", `btn-${u}`, s);
|
|
34
|
+
return /* @__PURE__ */ i(
|
|
35
|
+
"button",
|
|
36
|
+
{
|
|
37
|
+
className: p,
|
|
38
|
+
type: "button",
|
|
39
|
+
onClick: a,
|
|
40
|
+
...e,
|
|
41
|
+
...r,
|
|
42
|
+
...n,
|
|
43
|
+
children: o
|
|
44
|
+
}
|
|
45
|
+
);
|
|
10
46
|
};
|
|
11
47
|
export {
|
|
12
|
-
|
|
48
|
+
N as default
|
|
13
49
|
};
|
|
14
50
|
//# sourceMappingURL=StateButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateButton.js","sources":["../../../src/components/states/StateButton.tsx"],"sourcesContent":["import type React from 'react';\n\nimport classNames from '../../utils/classNames';\nimport type { BUTTON_STYLE } from '../../Button';\n\nexport type StateButtonProps = {\n /**\n * The button text.\n *\n * This can also be a node with an icon to be shown on the button.\n */\n text: string | React.ReactNode;\n\n /**\n * Callback fired after the component starts to collapse.\n *\n * @default () => {}\n */\n onClick?: VoidFunction;\n\n /**\n * Instead of a callback for the button you can specify a \"href\".\n *\n * This way it will render a link button instead.\n */\n href?: string;\n\n /**\n * The style of the button.\n *\n * @default 'primary'\n */\n bsStyle?: BUTTON_STYLE;\n\n /**\n * Additional classes assigned to the button.\n */\n className?: string;\n};\n\nconst StateButton = (props: StateButtonProps) => {\n const {
|
|
1
|
+
{"version":3,"file":"StateButton.js","sources":["../../../src/components/states/StateButton.tsx"],"sourcesContent":["import type React from 'react';\n\nimport { getAutoTrackingAttributes, type AutoTrackingAttributes } from '../../utils/analytics/autoTracking';\nimport classNames from '../../utils/classNames';\nimport type { BUTTON_STYLE } from '../../Button';\n\nexport type StateButtonProps = AutoTrackingAttributes & {\n /**\n * The button text.\n *\n * This can also be a node with an icon to be shown on the button.\n */\n text: string | React.ReactNode;\n\n /**\n * Callback fired after the component starts to collapse.\n *\n * @default () => {}\n */\n onClick?: VoidFunction;\n\n /**\n * Instead of a callback for the button you can specify a \"href\".\n *\n * This way it will render a link button instead.\n */\n href?: string;\n\n /**\n * The style of the button.\n *\n * @default 'primary'\n */\n bsStyle?: BUTTON_STYLE;\n\n /**\n * Additional classes assigned to the button.\n */\n className?: string;\n\n /**\n * Optional key used to generate automatic GA tracking attributes when no explicit\n * tracking attributes are provided.\n */\n autoTrackingKey?: string;\n\n /**\n * Optional tracking attributes (e.g. from `getTrackingAttributes`) added to the button or link element.\n */\n trackingAttributes?: AutoTrackingAttributes;\n};\n\nconst StateButton = (props: StateButtonProps) => {\n const {\n text,\n bsStyle = 'primary',\n className,\n onClick = () => {},\n href,\n autoTrackingKey,\n trackingAttributes,\n ...remainingProps\n } = props;\n\n const autoTrackingAttributes = getAutoTrackingAttributes({\n autoTrackingKey,\n props: { ...trackingAttributes, ...remainingProps },\n source: href ? 'link' : 'button',\n });\n\n // In case a href is given, render a link instead\n if (href) {\n return (\n <a\n className={classNames('margin-top-15', className)}\n href={href}\n onClick={onClick}\n {...autoTrackingAttributes}\n {...trackingAttributes}\n {...remainingProps}\n >\n {text}\n </a>\n );\n }\n\n const buttonClassNames = classNames('btn', 'margin-top-10', `btn-${bsStyle}`, className);\n\n return (\n <button\n className={buttonClassNames}\n type='button'\n onClick={onClick}\n {...autoTrackingAttributes}\n {...trackingAttributes}\n {...remainingProps}\n >\n {text}\n </button>\n );\n};\n\nexport default StateButton;\n"],"names":["StateButton","props","text","bsStyle","className","onClick","href","autoTrackingKey","trackingAttributes","remainingProps","autoTrackingAttributes","getAutoTrackingAttributes","jsx","classNames","buttonClassNames"],"mappings":";;;AAoDA,MAAMA,IAAc,CAACC,MAA4B;AAC7C,QAAM;AAAA,IACF,MAAAC;AAAA,IACA,SAAAC,IAAU;AAAA,IACV,WAAAC;AAAA,IACA,SAAAC,IAAU,MAAM;AAAA,IAAC;AAAA,IACjB,MAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,IACHR,GAEES,IAAyBC,EAA0B;AAAA,IACrD,iBAAAJ;AAAA,IACA,OAAO,EAAE,GAAGC,GAAoB,GAAGC,EAAA;AAAA,IACnC,QAAQH,IAAO,SAAS;AAAA,EAAA,CAC3B;AAGD,MAAIA;AACA,WACI,gBAAAM;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,WAAWC,EAAW,iBAAiBT,CAAS;AAAA,QAChD,MAAAE;AAAA,QACA,SAAAD;AAAA,QACC,GAAGK;AAAA,QACH,GAAGF;AAAA,QACH,GAAGC;AAAA,QAEH,UAAAP;AAAA,MAAA;AAAA,IAAA;AAKb,QAAMY,IAAmBD,EAAW,OAAO,iBAAiB,OAAOV,CAAO,IAAIC,CAAS;AAEvF,SACI,gBAAAQ;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAWE;AAAA,MACX,MAAK;AAAA,MACL,SAAAT;AAAA,MACC,GAAGK;AAAA,MACH,GAAGF;AAAA,MACH,GAAGC;AAAA,MAEH,UAAAP;AAAA,IAAA;AAAA,EAAA;AAGb;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ReactNode, MouseEventHandler } from 'react';
|
|
2
|
+
export type StatsWidgetNumberLabelPosition = 'top' | 'bottom';
|
|
2
3
|
export type StatsWidgetNumberProps = {
|
|
3
4
|
/**
|
|
4
5
|
* The value to be shown.
|
|
@@ -11,9 +12,23 @@ export type StatsWidgetNumberProps = {
|
|
|
11
12
|
*/
|
|
12
13
|
total?: string | number | ReactNode;
|
|
13
14
|
/**
|
|
14
|
-
* The label shown
|
|
15
|
+
* The label shown next to the number.
|
|
15
16
|
*/
|
|
16
17
|
label?: string | ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* Position of the label relative to the number.
|
|
20
|
+
*
|
|
21
|
+
* @default 'bottom'
|
|
22
|
+
*/
|
|
23
|
+
labelPosition?: StatsWidgetNumberLabelPosition;
|
|
24
|
+
/**
|
|
25
|
+
* Additional class names to be added to the label element.
|
|
26
|
+
*/
|
|
27
|
+
labelClassName?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Additional class names to be added to the value element.
|
|
30
|
+
*/
|
|
31
|
+
valueClassName?: string;
|
|
17
32
|
/**
|
|
18
33
|
* Defines whether the number is clickable i.e. in combination with a filter.
|
|
19
34
|
*
|
|
@@ -1,17 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
const
|
|
4
|
-
const {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { jsx as a, jsxs as i } from "react/jsx-runtime";
|
|
2
|
+
import s from "../../utils/classNames.js";
|
|
3
|
+
const W = (r) => {
|
|
4
|
+
const {
|
|
5
|
+
value: m = 0,
|
|
6
|
+
total: e,
|
|
7
|
+
label: l,
|
|
8
|
+
labelPosition: t = "bottom",
|
|
9
|
+
labelClassName: c,
|
|
10
|
+
valueClassName: n,
|
|
11
|
+
className: d,
|
|
12
|
+
clickable: b = !1,
|
|
13
|
+
onClick: N = () => {
|
|
14
|
+
},
|
|
15
|
+
...u
|
|
16
|
+
} = r, p = s(
|
|
17
|
+
"StatsWidgetNumber",
|
|
18
|
+
t === "top" && "label-position-top",
|
|
19
|
+
b && "cursor-pointer",
|
|
20
|
+
d
|
|
21
|
+
), o = l && /* @__PURE__ */ a("div", { className: s("StatsWidgetNumber-label", c), children: l }), v = /* @__PURE__ */ i("div", { className: "StatsWidgetNumber-counter", children: [
|
|
22
|
+
/* @__PURE__ */ a("div", { className: s("StatsWidgetNumber-value", n), children: m }),
|
|
23
|
+
(e || e === 0) && /* @__PURE__ */ a("div", { className: "StatsWidgetNumber-total", children: e })
|
|
24
|
+
] });
|
|
25
|
+
return /* @__PURE__ */ i("div", { ...u, onClick: N, className: p, children: [
|
|
26
|
+
t === "top" && o,
|
|
27
|
+
v,
|
|
28
|
+
t === "bottom" && o
|
|
12
29
|
] });
|
|
13
30
|
};
|
|
14
31
|
export {
|
|
15
|
-
|
|
32
|
+
W as default
|
|
16
33
|
};
|
|
17
34
|
//# sourceMappingURL=StatsWidgetNumber.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatsWidgetNumber.js","sources":["../../../src/components/statsWidget/StatsWidgetNumber.tsx"],"sourcesContent":["import type { ReactNode, MouseEventHandler } from 'react';\n\nimport classNames from '../../utils/classNames';\n\nexport type StatsWidgetNumberProps = {\n /**\n * The value to be shown.\n *\n * @default 0\n */\n value: string | number | ReactNode;\n\n /**\n * The total value to be shown i.e. in combination with an active filter.\n */\n total?: string | number | ReactNode;\n\n /**\n * The label shown
|
|
1
|
+
{"version":3,"file":"StatsWidgetNumber.js","sources":["../../../src/components/statsWidget/StatsWidgetNumber.tsx"],"sourcesContent":["import type { ReactNode, MouseEventHandler } from 'react';\n\nimport classNames from '../../utils/classNames';\n\nexport type StatsWidgetNumberLabelPosition = 'top' | 'bottom';\n\nexport type StatsWidgetNumberProps = {\n /**\n * The value to be shown.\n *\n * @default 0\n */\n value: string | number | ReactNode;\n\n /**\n * The total value to be shown i.e. in combination with an active filter.\n */\n total?: string | number | ReactNode;\n\n /**\n * The label shown next to the number.\n */\n label?: string | ReactNode;\n\n /**\n * Position of the label relative to the number.\n *\n * @default 'bottom'\n */\n labelPosition?: StatsWidgetNumberLabelPosition;\n\n /**\n * Additional class names to be added to the label element.\n */\n labelClassName?: string;\n\n /**\n * Additional class names to be added to the value element.\n */\n valueClassName?: string;\n\n /**\n * Defines whether the number is clickable i.e. in combination with a filter.\n *\n * @default false\n */\n clickable?: boolean;\n\n /**\n * Callback for when the user clicks the number widget.\n */\n onClick?: MouseEventHandler;\n\n /**\n * Additional class names to be added to the element.\n */\n className?: string;\n};\n\nconst StatsWidgetNumber = (props: StatsWidgetNumberProps) => {\n const {\n value = 0,\n total,\n label,\n labelPosition = 'bottom',\n labelClassName,\n valueClassName,\n className,\n clickable = false,\n onClick = () => {},\n ...remainingProps\n } = props;\n\n const wrapperClasses = classNames(\n 'StatsWidgetNumber',\n labelPosition === 'top' && 'label-position-top',\n clickable && 'cursor-pointer',\n className\n );\n\n const labelElement = label && <div className={classNames('StatsWidgetNumber-label', labelClassName)}>{label}</div>;\n\n const counterElement = (\n <div className='StatsWidgetNumber-counter'>\n <div className={classNames('StatsWidgetNumber-value', valueClassName)}>{value}</div>\n {(total || total === 0) && <div className='StatsWidgetNumber-total'>{total}</div>}\n </div>\n );\n\n return (\n <div {...remainingProps} onClick={onClick} className={wrapperClasses}>\n {labelPosition === 'top' && labelElement}\n {counterElement}\n {labelPosition === 'bottom' && labelElement}\n </div>\n );\n};\n\nexport default StatsWidgetNumber;\n"],"names":["StatsWidgetNumber","props","value","total","label","labelPosition","labelClassName","valueClassName","className","clickable","onClick","remainingProps","wrapperClasses","classNames","labelElement","jsx","counterElement","jsxs"],"mappings":";;AA2DA,MAAMA,IAAoB,CAACC,MAAkC;AACzD,QAAM;AAAA,IACF,OAAAC,IAAQ;AAAA,IACR,OAAAC;AAAA,IACA,OAAAC;AAAA,IACA,eAAAC,IAAgB;AAAA,IAChB,gBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,WAAAC;AAAA,IACA,WAAAC,IAAY;AAAA,IACZ,SAAAC,IAAU,MAAM;AAAA,IAAC;AAAA,IACjB,GAAGC;AAAA,EAAA,IACHV,GAEEW,IAAiBC;AAAA,IACnB;AAAA,IACAR,MAAkB,SAAS;AAAA,IAC3BI,KAAa;AAAA,IACbD;AAAA,EAAA,GAGEM,IAAeV,KAAS,gBAAAW,EAAC,OAAA,EAAI,WAAWF,EAAW,2BAA2BP,CAAc,GAAI,UAAAF,EAAA,CAAM,GAEtGY,IACF,gBAAAC,EAAC,OAAA,EAAI,WAAU,6BACX,UAAA;AAAA,IAAA,gBAAAF,EAAC,SAAI,WAAWF,EAAW,2BAA2BN,CAAc,GAAI,UAAAL,GAAM;AAAA,KAC5EC,KAASA,MAAU,wBAAO,OAAA,EAAI,WAAU,2BAA2B,UAAAA,EAAA,CAAM;AAAA,EAAA,GAC/E;AAGJ,2BACK,OAAA,EAAK,GAAGQ,GAAgB,SAAAD,GAAkB,WAAWE,GACjD,UAAA;AAAA,IAAAP,MAAkB,SAASS;AAAA,IAC3BE;AAAA,IACAX,MAAkB,YAAYS;AAAA,EAAA,GACnC;AAER;"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export type TabbedPanelTab = {
|
|
3
|
+
/**
|
|
4
|
+
* Unique key of the tab.
|
|
5
|
+
*/
|
|
6
|
+
key: string;
|
|
7
|
+
/**
|
|
8
|
+
* Title rendered inside the panel header navigation.
|
|
9
|
+
*/
|
|
10
|
+
title: React.ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the tab can be selected.
|
|
13
|
+
*
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Additional classes to be set on the tab list item.
|
|
19
|
+
*/
|
|
20
|
+
className?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Additional classes to be set on this tab's content wrapper.
|
|
23
|
+
*/
|
|
24
|
+
contentClassName?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Content rendered inside the panel body when the tab is active.
|
|
27
|
+
*/
|
|
28
|
+
content: React.ReactNode;
|
|
29
|
+
};
|
|
30
|
+
export type TabbedPanelProps = {
|
|
31
|
+
/**
|
|
32
|
+
* The selected tab key for controlled usage.
|
|
33
|
+
*/
|
|
34
|
+
activeKey?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The initially selected tab key for uncontrolled usage.
|
|
37
|
+
*/
|
|
38
|
+
defaultActiveKey?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Available tabs and their panel body content.
|
|
41
|
+
*/
|
|
42
|
+
tabs: TabbedPanelTab[];
|
|
43
|
+
/**
|
|
44
|
+
* Panel style variant. TabbedPanel supports the default bordered panel and the blank panel only.
|
|
45
|
+
*
|
|
46
|
+
* @default 'default'
|
|
47
|
+
*/
|
|
48
|
+
bsStyle?: 'blank' | 'default';
|
|
49
|
+
/**
|
|
50
|
+
* Body transition used when switching tabs.
|
|
51
|
+
*
|
|
52
|
+
* @default 'height-fade'
|
|
53
|
+
*/
|
|
54
|
+
bodyTransition?: 'none' | 'fade' | 'height-fade';
|
|
55
|
+
/**
|
|
56
|
+
* Animation duration in seconds.
|
|
57
|
+
*
|
|
58
|
+
* @default 0.16
|
|
59
|
+
*/
|
|
60
|
+
duration?: number;
|
|
61
|
+
/**
|
|
62
|
+
* Optional content rendered on the right side of the panel header.
|
|
63
|
+
*/
|
|
64
|
+
headerRight?: React.ReactNode | ((activeTab: TabbedPanelTab) => React.ReactNode);
|
|
65
|
+
/**
|
|
66
|
+
* Callback called when a tab is selected.
|
|
67
|
+
*/
|
|
68
|
+
onSelectTab?: (tabKey: string) => void;
|
|
69
|
+
/**
|
|
70
|
+
* Additional classes to be set on the wrapper element.
|
|
71
|
+
*/
|
|
72
|
+
className?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Additional classes to be set on the panel header.
|
|
75
|
+
*/
|
|
76
|
+
headerClassName?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Additional classes to be set on the tab navigation.
|
|
79
|
+
*/
|
|
80
|
+
navClassName?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Additional classes to be set on each tab link.
|
|
83
|
+
*/
|
|
84
|
+
tabLinkClassName?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Additional classes to be set on the panel body.
|
|
87
|
+
*/
|
|
88
|
+
bodyClassName?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Additional classes to be set on the active tab content wrapper.
|
|
91
|
+
*/
|
|
92
|
+
activeContentClassName?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Additional classes to be set on the header-right wrapper.
|
|
95
|
+
*/
|
|
96
|
+
headerRightClassName?: string;
|
|
97
|
+
};
|
|
98
|
+
declare const TabbedPanel: (props: TabbedPanelProps) => import("react/jsx-runtime").JSX.Element;
|
|
99
|
+
export default TabbedPanel;
|