@persona/design-system 0.10.8 → 0.10.10
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/CHANGELOG.md +27 -0
- package/dist/{Badge-8YzapjWf.mjs → Badge-BCdsVKuj.mjs} +2 -2
- package/dist/{Badge-8YzapjWf.mjs.map → Badge-BCdsVKuj.mjs.map} +1 -1
- package/dist/{Breadcrumbs-Dft2TR4v.mjs → Breadcrumbs-CMf3Uvow.mjs} +4 -4
- package/dist/{Breadcrumbs-Dft2TR4v.mjs.map → Breadcrumbs-CMf3Uvow.mjs.map} +1 -1
- package/dist/Card2.d.mts +2 -2
- package/dist/{CardV2-BRJbRSts.mjs → CardV2-CrV6eEQb.mjs} +15 -5
- package/dist/CardV2-CrV6eEQb.mjs.map +1 -0
- package/dist/{CheckboxGroupField-DnVqlpwi.d.mts → CheckboxGroupField-Bpu2j6G2.d.mts} +2 -2
- package/dist/CheckboxGroupField.d.mts +1 -1
- package/dist/{Combobox-fYZjpn5-.d.mts → Combobox-CIKqTYZt.d.mts} +3 -3
- package/dist/{Combobox-DQxaOCLA.mjs → Combobox-Gb_j1dg6.mjs} +5 -5
- package/dist/{Combobox-DQxaOCLA.mjs.map → Combobox-Gb_j1dg6.mjs.map} +1 -1
- package/dist/Combobox.d.mts +2 -2
- package/dist/{ComboboxBase-Mb8HyeAI.d.mts → ComboboxBase-BPXqJHaQ.d.mts} +2 -2
- package/dist/ComboboxBase.d.mts +1 -1
- package/dist/{ComboboxMultiSelect-C87lkXr7.d.mts → ComboboxMultiSelect-BwkkSymj.d.mts} +2 -2
- package/dist/ComboboxMultiSelect.d.mts +1 -1
- package/dist/{ComboboxSingleSelect-CIYakRW5.d.mts → ComboboxSingleSelect-CdNNJNkp.d.mts} +3 -3
- package/dist/ComboboxSingleSelect.d.mts +1 -1
- package/dist/{CompactBar-D67CdcIo.d.mts → CompactBar-BLZZWtIE.d.mts} +2 -2
- package/dist/CompactBar.d.mts +1 -1
- package/dist/{ControlBar-34th2yt4.d.mts → ControlBar-B3Jn8G0k.d.mts} +5 -4
- package/dist/ControlBar.d.mts +1 -1
- package/dist/{DataTable-BZtzdtVs.d.mts → DataTable-BE9inUi-.d.mts} +5 -5
- package/dist/{DataTable-BvA2H9D9.mjs → DataTable-CIZJ1vO8.mjs} +10 -10
- package/dist/{DataTable-BvA2H9D9.mjs.map → DataTable-CIZJ1vO8.mjs.map} +1 -1
- package/dist/DataTable.d.mts +1 -1
- package/dist/{DatePicker-D-_ibUd1.mjs → DatePicker-C9redLBr.mjs} +4 -4
- package/dist/{DatePicker-D-_ibUd1.mjs.map → DatePicker-C9redLBr.mjs.map} +1 -1
- package/dist/{DropdownButton-BiFRlSVD.mjs → DropdownButton-DpLG-cIj.mjs} +3 -3
- package/dist/{DropdownButton-BiFRlSVD.mjs.map → DropdownButton-DpLG-cIj.mjs.map} +1 -1
- package/dist/DropdownButton.d.mts +1 -1
- package/dist/{DropdownMenu-DVxXQDRC.d.mts → DropdownMenu-B6D4stkF.d.mts} +2 -2
- package/dist/{DropdownMenu-Q8S-9rXm.mjs → DropdownMenu-c8XK2Lr4.mjs} +2 -2
- package/dist/{DropdownMenu-Q8S-9rXm.mjs.map → DropdownMenu-c8XK2Lr4.mjs.map} +1 -1
- package/dist/DropdownMenu.d.mts +1 -1
- package/dist/{FloatingToolbar-Df90f7Dm.mjs → FloatingToolbar-DLRaE0o7.mjs} +3 -3
- package/dist/{FloatingToolbar-Df90f7Dm.mjs.map → FloatingToolbar-DLRaE0o7.mjs.map} +1 -1
- package/dist/{FormField-BStxmlZT.mjs → FormField-Cf1VMvoa.mjs} +7 -7
- package/dist/{FormField-BStxmlZT.mjs.map → FormField-Cf1VMvoa.mjs.map} +1 -1
- package/dist/{HoverCopyableField-CW7Jxmni.mjs → HoverCopyableField-XHC_n9tp.mjs} +2 -2
- package/dist/{HoverCopyableField-CW7Jxmni.mjs.map → HoverCopyableField-XHC_n9tp.mjs.map} +1 -1
- package/dist/{IconButton-DftINsp7.mjs → IconButton-DxHB2g80.mjs} +2 -2
- package/dist/{IconButton-DftINsp7.mjs.map → IconButton-DxHB2g80.mjs.map} +1 -1
- package/dist/IndexTableLayout.d.mts +4 -4
- package/dist/InlineCombobox.d.mts +1 -1
- package/dist/InlineInput.d.mts +1 -1
- package/dist/{Input-DtO3qMnE.mjs → Input-RHXujO9u.mjs} +2 -2
- package/dist/{Input-DtO3qMnE.mjs.map → Input-RHXujO9u.mjs.map} +1 -1
- package/dist/{Link-DKYmdL9t.mjs → Link-D_kCyLYX.mjs} +2 -2
- package/dist/{Link-DKYmdL9t.mjs.map → Link-D_kCyLYX.mjs.map} +1 -1
- package/dist/{ListBox-CDG0EAPg.mjs → ListBox-BZp6exb8.mjs} +6 -6
- package/dist/{ListBox-CDG0EAPg.mjs.map → ListBox-BZp6exb8.mjs.map} +1 -1
- package/dist/{ListBox-DxOACf6N.d.mts → ListBox-DpFcM-dM.d.mts} +2 -2
- package/dist/ListBox.d.mts +1 -1
- package/dist/{ListBoxField-CgnDuhUw.d.mts → ListBoxField-DL6Zk8TU.d.mts} +4 -4
- package/dist/ListBoxField.d.mts +1 -1
- package/dist/{LogicRow-Dv_1G1TC.d.mts → LogicRow-BakOUtzx.d.mts} +2 -2
- package/dist/LogicRow.d.mts +1 -1
- package/dist/{Menu-EIT_MwK6.mjs → Menu-BVn1jh46.mjs} +2 -2
- package/dist/{Menu-EIT_MwK6.mjs.map → Menu-BVn1jh46.mjs.map} +1 -1
- package/dist/{Menu-BfjvH8mr.d.mts → Menu-D6OrKCTC.d.mts} +2 -2
- package/dist/Menu.d.mts +1 -1
- package/dist/{Modal-BGlRX63w.mjs → Modal-De5_bPJ_.mjs} +4 -4
- package/dist/{Modal-BGlRX63w.mjs.map → Modal-De5_bPJ_.mjs.map} +1 -1
- package/dist/PageHeader-7_Hf6rHl.mjs +81 -0
- package/dist/PageHeader-7_Hf6rHl.mjs.map +1 -0
- package/dist/{PageHeader-DRatgscC.d.mts → PageHeader-UPiqJpIF.d.mts} +11 -3
- package/dist/PageHeader.d.mts +1 -1
- package/dist/{Pagination-C8hPOu0l.mjs → Pagination-DMH2IaV0.mjs} +5 -5
- package/dist/{Pagination-C8hPOu0l.mjs.map → Pagination-DMH2IaV0.mjs.map} +1 -1
- package/dist/{Pii-Bvh_kfGN.mjs → Pii-24D_nSRQ.mjs} +2 -2
- package/dist/{Pii-Bvh_kfGN.mjs.map → Pii-24D_nSRQ.mjs.map} +1 -1
- package/dist/{Select-CaG6OQi1.d.mts → Select-CR9TjFfo.d.mts} +2 -2
- package/dist/{Select-DkUMz4LG.mjs → Select-DOlw_LPR.mjs} +4 -4
- package/dist/{Select-DkUMz4LG.mjs.map → Select-DOlw_LPR.mjs.map} +1 -1
- package/dist/Select.d.mts +1 -1
- package/dist/SmartTextInputField.d.mts +2 -2
- package/dist/{StatusIndicator-Zf75KK3O.mjs → StatusIndicator-CzRaEFSz.mjs} +2 -2
- package/dist/{StatusIndicator-Zf75KK3O.mjs.map → StatusIndicator-CzRaEFSz.mjs.map} +1 -1
- package/dist/{Sticker-Bi_fezCO.mjs → Sticker-C1_6I08u.mjs} +3 -3
- package/dist/{Sticker-Bi_fezCO.mjs.map → Sticker-C1_6I08u.mjs.map} +1 -1
- package/dist/{TabBar-DpXYsWgS.mjs → TabBar-BCFO38E0.mjs} +3 -3
- package/dist/{TabBar-DpXYsWgS.mjs.map → TabBar-BCFO38E0.mjs.map} +1 -1
- package/dist/{TableBox-BfSF36Gy.mjs → TableBox-DNQsgQ8x.mjs} +4 -4
- package/dist/{TableBox-BfSF36Gy.mjs.map → TableBox-DNQsgQ8x.mjs.map} +1 -1
- package/dist/TableBox.d.mts +1 -1
- package/dist/{TableBoxCell-B9KMWebc.d.mts → TableBoxCell-CsRt_5gP.d.mts} +4 -4
- package/dist/TableBoxCell.d.mts +1 -1
- package/dist/{TableBoxField-0uIGzBhF.d.mts → TableBoxField-Db0Vjo6Z.d.mts} +5 -5
- package/dist/TableBoxField.d.mts +1 -1
- package/dist/{TableBoxRow-PjBBDcEk.d.mts → TableBoxRow-exMlZyc4.d.mts} +2 -2
- package/dist/TableBoxRow.d.mts +1 -1
- package/dist/{TableBoxRowActions-B7stm6Q3.d.mts → TableBoxRowActions-UO9YN34k.d.mts} +2 -2
- package/dist/TableBoxRowActions.d.mts +1 -1
- package/dist/{TableControls-BZ8RrYOc.mjs → TableControls-BrP_BqnF.mjs} +14 -14
- package/dist/TableControls-BrP_BqnF.mjs.map +1 -0
- package/dist/{TableControls-DT2YpFK8.d.mts → TableControls-Clo_0Mty.d.mts} +4 -4
- package/dist/TableControls.d.mts +1 -1
- package/dist/{TableControlsContext-CHuLxfa7.d.mts → TableControlsContext-BNd6z9mD.d.mts} +2 -2
- package/dist/TableControlsContext.d.mts +1 -1
- package/dist/{TableViewConfigurationDropdown-BWBBUXCs.d.mts → TableViewConfigurationDropdown-Cp7ausV_.d.mts} +2 -2
- package/dist/TableViewConfigurationDropdown.d.mts +1 -1
- package/dist/{TechnicalSticker-B_JlBkXZ.mjs → TechnicalSticker-Cq5jzYKQ.mjs} +2 -2
- package/dist/{TechnicalSticker-B_JlBkXZ.mjs.map → TechnicalSticker-Cq5jzYKQ.mjs.map} +1 -1
- package/dist/{clientFilterUtils-scLlIuP_.d.mts → clientFilterUtils-CGHYF5NE.d.mts} +2 -2
- package/dist/clientFilterUtils.d.mts +1 -1
- package/dist/components/Accordion/index.mjs +1 -1
- package/dist/components/Attribute/index.mjs +2 -2
- package/dist/components/Badge/index.mjs +1 -1
- package/dist/components/Banner/index.mjs +1 -1
- package/dist/components/BottomPanel/index.mjs +4 -4
- package/dist/components/Breadcrumbs/index.mjs +1 -1
- package/dist/components/Button/index.mjs +1 -1
- package/dist/components/ButtonGroup/index.mjs +1 -1
- package/dist/components/CardV2/index.mjs +1 -1
- package/dist/components/CodeHighlight/index.mjs +1 -1
- package/dist/components/Combobox/index.d.mts +2 -2
- package/dist/components/Combobox/index.mjs +1 -1
- package/dist/components/DataTable/TableControls/index.d.mts +7 -7
- package/dist/components/DataTable/TableControls/index.mjs +1 -1
- package/dist/components/DataTable/index.d.mts +5 -5
- package/dist/components/DataTable/index.mjs +1 -1
- package/dist/components/DataTable/types.d.mts +1 -1
- package/dist/components/DatePicker/index.mjs +1 -1
- package/dist/components/DropdownButton/index.mjs +1 -1
- package/dist/components/DropdownMenu/index.d.mts +1 -1
- package/dist/components/DropdownMenu/index.mjs +1 -1
- package/dist/components/FloatingPanel/index.mjs +2 -2
- package/dist/components/FloatingToolbar/index.mjs +1 -1
- package/dist/components/FormField/index.d.mts +4 -4
- package/dist/components/FormField/index.mjs +1 -1
- package/dist/components/HoverCopyableField/index.mjs +1 -1
- package/dist/components/ImageTile/index.mjs +2 -2
- package/dist/components/Input/index.mjs +1 -1
- package/dist/components/Link/index.mjs +1 -1
- package/dist/components/ListBox/index.d.mts +3 -3
- package/dist/components/ListBox/index.mjs +1 -1
- package/dist/components/MaskedInput/index.mjs +1 -1
- package/dist/components/Menu/index.d.mts +1 -1
- package/dist/components/Menu/index.mjs +1 -1
- package/dist/components/Modal/index.mjs +1 -1
- package/dist/components/PageHeader/index.d.mts +1 -1
- package/dist/components/PageHeader/index.mjs +1 -1
- package/dist/components/Pagination/index.mjs +1 -1
- package/dist/components/Pii/index.mjs +1 -1
- package/dist/components/RichTextEditor/index.mjs +4 -4
- package/dist/components/RightPanel/index.mjs +1 -1
- package/dist/components/Select/index.d.mts +1 -1
- package/dist/components/Select/index.mjs +1 -1
- package/dist/components/SmartTextInput/index.mjs +2 -2
- package/dist/components/StatusIndicator/index.mjs +1 -1
- package/dist/components/Sticker/index.mjs +1 -1
- package/dist/components/TabBar/index.mjs +1 -1
- package/dist/components/TableBox/index.d.mts +1 -1
- package/dist/components/TableBox/index.mjs +1 -1
- package/dist/components/TechnicalSticker/index.mjs +1 -1
- package/dist/components/Tile/index.mjs +1 -1
- package/dist/components/Toast/index.mjs +1 -1
- package/dist/components/VersionHistory/index.mjs +4 -4
- package/dist/fieldPickerOptions.d.mts +1 -1
- package/dist/{filters-yfzOlqKx.d.mts → filters-DTBc0mE7.d.mts} +2 -2
- package/dist/filters.d.mts +1 -1
- package/dist/{helpers-BeCjgAeE.d.mts → helpers-CBJ2AqGZ.d.mts} +2 -2
- package/dist/helpers.d.mts +1 -1
- package/dist/{index-BEHNqAZa.d.mts → index-OkdnW-u5.d.mts} +3 -3
- package/dist/{inputFields-BnCdmuBt.d.mts → inputFields-DpHeZiFX.d.mts} +4 -4
- package/dist/inputFields.d.mts +1 -1
- package/dist/lib/GlobalStyles.d.mts +19 -2
- package/dist/lib/GlobalStyles.mjs +50 -1
- package/dist/lib/GlobalStyles.mjs.map +1 -1
- package/dist/lib/schemaOptions.mjs +9 -4
- package/dist/lib/schemaOptions.mjs.map +1 -1
- package/dist/patterns/CardGrouping/index.mjs +4 -4
- package/dist/patterns/IndexTableLayout/index.mjs +2 -2
- package/dist/patterns/LayoutLoadingShimmer/index.mjs +2 -2
- package/dist/patterns/WizardModal/index.mjs +2 -2
- package/dist/theme.mjs +1 -1
- package/dist/{types-BXJ6qAGy.d.mts → types-BEdERA4v.d.mts} +2 -2
- package/dist/{types-BeFBvQ1c.d.mts → types-BiqzeNsa.d.mts} +2 -2
- package/dist/types5.d.mts +1 -1
- package/dist/useColumnConfiguration.d.mts +2 -2
- package/dist/useComboboxFooterAction.d.mts +1 -1
- package/dist/{useTableColumns-DJFy0Gp8.d.mts → useTableColumns-Xd14vx_h.d.mts} +2 -2
- package/dist/useTableColumns.d.mts +1 -1
- package/dist/useTruncation.d.mts +1 -1
- package/dist/variables/charting.mjs +1 -1
- package/dist/variables/charting.mjs.map +1 -1
- package/llms.txt +3 -3
- package/package.json +3 -3
- package/skills/ui-authoring/COMPONENTS.md +1 -1
- package/skills/ui-authoring/PATTERNS.md +7 -0
- package/dist/CardV2-BRJbRSts.mjs.map +0 -1
- package/dist/PageHeader-DEKTopzU.mjs +0 -75
- package/dist/PageHeader-DEKTopzU.mjs.map +0 -1
- package/dist/TableControls-BZ8RrYOc.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal-BGlRX63w.mjs","names":["AriaModal","Button","Heading","AriaHeading","Card","Modal"],"sources":["../src/components/Modal/Modal.tsx"],"sourcesContent":["import {\n forwardRef,\n type ComponentProps,\n type ComponentPropsWithoutRef,\n type MouseEvent,\n type ReactNode,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport {\n Dialog,\n DialogTrigger,\n Heading as AriaHeading,\n Modal as AriaModal,\n ModalOverlay,\n type ModalOverlayProps,\n OverlayTriggerStateContext,\n Pressable,\n} from 'react-aria-components';\nimport { useOverlayTriggerState } from 'react-stately';\nimport styled from 'styled-components';\n\nimport Button, { type ButtonProps } from '@persona/design-system/components/Button';\nimport Card from '@persona/design-system/components/Card';\nimport Stack, { HStack } from '@persona/design-system/components/Stack';\nimport TabBar, { Tab } from '@persona/design-system/components/TabBar';\nimport { Heading } from '@persona/design-system/components/Text';\nimport { Color, Spacing } from '@persona/design-tokens';\nimport { XIcon } from '@persona/icons';\n\nimport { usePDSStrings } from '#src/lib/i18n';\nimport { semanticColor, semanticOnly } from '#src/lib/semanticColor';\nimport useEmbeddedSurface, {\n useEmbeddedSurfaceGate,\n useEmbeddedSurfaceId,\n} from '#src/lib/useEmbeddedSurface';\nimport useModalInsetRight, {\n SIDEBAR_CLOSE_TRANSITION_MS,\n SIDEBAR_OPEN_TRANSITION_MS,\n} from '#src/lib/useModalInsetRight';\nimport { semanticScrollbar } from '#src/mixins/scrollbar';\n\nconst StyledModalOverlay = styled(ModalOverlay)<{\n $hostPending: boolean;\n $animationDelayMs: number;\n $insetRight: string;\n $transitionMs: number;\n}>`\n @keyframes overlayShow {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n }\n background-color: rgba(0, 0, 0, 0.5);\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: ${({ $insetRight }) => $insetRight};\n transition: right ${({ $transitionMs }) => $transitionMs}ms ease-out;\n animation: overlayShow 150ms cubic-bezier(0.16, 1, 0.3, 1);\n animation-delay: ${({ $animationDelayMs }) => $animationDelayMs}ms;\n animation-fill-mode: both;\n ${({ $hostPending }) =>\n $hostPending &&\n `\n animation-play-state: paused;\n `}\n @media (prefers-reduced-motion: reduce) {\n animation-duration: 0ms;\n animation-delay: 0ms;\n animation-play-state: running;\n }\n z-index: 10000;\n display: flex;\n align-items: center;\n justify-content: center;\n`;\n\nconst StyledModal = styled(AriaModal)`\n z-index: 10001;\n outline: none;\n width: fit-content;\n max-width: 100%;\n ${semanticOnly((tokens) => `color: ${tokens.FgPrimary};`)}\n`;\n\n/**\n * React Aria keeps the overlay mounted through the exit animation, so announcing the surface from\n * here — rather than from the persistent gate below — releases the host's backdrop exactly when the\n * modal stops being painted.\n */\nconst EmbeddedSurfaceModal = forwardRef<HTMLDivElement, { children: ReactNode; surfaceId: string }>(\n function EmbeddedSurfaceModal({ children, surfaceId }, ref) {\n useEmbeddedSurface(surfaceId);\n return <StyledModal ref={ref}>{children}</StyledModal>;\n },\n);\n\ntype EmbeddedSurfaceOverlayProps = ModalOverlayProps & {\n $insetRight: string;\n $transitionMs: number;\n surfaceId: string;\n};\n\nconst EmbeddedSurfaceOverlay = ({ surfaceId, ...props }: EmbeddedSurfaceOverlayProps) => {\n const state = useContext(OverlayTriggerStateContext);\n const isOpen = state?.isOpen ?? false;\n const { ready, animationDelayMs } = useEmbeddedSurfaceGate(surfaceId, isOpen);\n\n const { $insetRight, $transitionMs, ...overlayProps } = props;\n return (\n <StyledModalOverlay\n {...overlayProps}\n $insetRight={$insetRight}\n $transitionMs={$transitionMs}\n $animationDelayMs={animationDelayMs}\n $hostPending={isOpen && !ready}\n />\n );\n};\n\nconst ModalCloseButton = styled(Button)`\n display: inline-flex;\n padding: ${Spacing[2]};\n border-radius: ${Spacing[1]};\n width: fit-content;\n min-width: unset;\n`;\n\nconst ModalFooter = styled(HStack).attrs({\n justify: 'flex-end',\n align: 'center',\n spacing: Spacing[2],\n})`\n padding: ${Spacing[3]} ${Spacing[4]};\n border-top: 1px solid ${({ theme }) => semanticColor(theme, 'BorderSubtle', Color.BorderDivider)};\n`;\n\nconst ModalHeaderTitle = styled.div`\n flex: 1;\n`;\n\nexport const ModalTrigger = DialogTrigger;\nexport const ModalContent = StyledModal;\n\nexport const ModalClose = ({ onClick, ...props }: ButtonProps) => {\n const state = useContext(OverlayTriggerStateContext);\n return (\n <ModalCloseButton\n variant='text'\n width='icon'\n size='md'\n {...props}\n onClick={(event: MouseEvent<HTMLButtonElement>) => {\n // Return the consumer's result so Button can await a returned Promise (pending state,\n // swallowed rejection). The modal still closes immediately, as it did before.\n const result = onClick?.(event);\n if (!event.defaultPrevented) {\n state?.close();\n }\n return result;\n }}\n >\n <XIcon />\n </ModalCloseButton>\n );\n};\n\nexport interface ModalTitleProps {\n children: ReactNode;\n className?: string;\n}\n\n/** Props passed to modal content render functions. */\nexport interface ModalRenderProps {\n /** Element that floating content should use as its portal container. */\n portalContainer: HTMLDivElement | null;\n}\n\ntype ModalRenderable = ReactNode | ((props: ModalRenderProps) => ReactNode);\n\nconst ModalTitle = ({ children, ...props }: ModalTitleProps) => {\n return (\n <Heading size='sm' color='primary' as={AriaHeading} slot='title' {...props}>\n {children}\n </Heading>\n );\n};\n\nconst ModalHeader = styled(HStack)<{ $hasTabs: boolean }>`\n border-bottom: ${({ $hasTabs, theme }) =>\n $hasTabs ? 'none' : `1px solid ${semanticColor(theme, 'BorderSubtle', Color.BorderDivider)}`};\n padding: ${({ $hasTabs }) =>\n $hasTabs\n ? `${Spacing[3]} ${Spacing[2]} ${Spacing[1]} ${Spacing[4]}`\n : `${Spacing[3]} ${Spacing[2]} ${Spacing[3]} ${Spacing[4]}`};\n`;\n\nconst ModalTabBar = styled(TabBar)`\n padding-left: ${Spacing[4]};\n`;\n\nconst StyledDialog = styled(Dialog)`\n outline: none;\n`;\n\nconst StyledCard = styled(Card)<{ $size?: 'auto' | 'md' | 'lg' | 'xl' | 'full' }>`\n position: relative;\n width: ${({ $size }) => {\n switch ($size) {\n case 'auto':\n return 'auto';\n case 'full':\n return 'calc(100vw - 160px)';\n default:\n return '90vw';\n }\n }};\n max-width: ${({ theme, $size }) => {\n switch ($size) {\n case 'auto':\n return 'auto';\n case 'full':\n return 'calc(100vw - 160px)';\n default:\n return theme.modal.width[$size];\n }\n }};\n /* TODO: Use breakpoints to make this responsive */\n max-height: ${({ $size }) => ($size === 'full' ? 'calc(100vh - 160px)' : '85vh')};\n display: flex;\n flex-direction: column;\n overflow: hidden;\n ${({ $size }) =>\n $size === 'full' &&\n `\n height: calc(100vh - 160px);\n `}\n margin-bottom: 0;\n`;\n\ninterface ModalCardProps extends ComponentPropsWithoutRef<typeof Dialog> {\n /**\n * Display X button to close popover\n */\n showCloseButton?: boolean;\n\n /**\n * Accessible label for the built-in close button. Defaults to the PDS closeModal string (\"Close\").\n */\n closeButtonLabel?: string;\n\n /**\n * Max width of the modal\n */\n size?: 'auto' | 'md' | 'lg' | 'xl' | 'full';\n\n /**\n * Footer content\n */\n footer?: ReactNode;\n\n /**\n * Renders tabs within the modal.\n * Adds a tab bar and will render the contents of the selected tab in a tabpanel.\n * Overrides `children`.\n * Tab contents can be render functions that receive the modal portal container.\n */\n tabs?: TabView[];\n\n /**\n * Title of the modal\n */\n title?: ReactNode;\n\n /**\n * Children content\n */\n children?: ReactNode;\n\n /**\n * When true, removes horizontal and vertical padding from the body. Defaults to false.\n */\n noBodyPadding?: boolean;\n\n /**\n * Additional props for the Dialog element\n */\n className?: string;\n}\n\ninterface ModalCardInternalProps extends ModalCardProps {\n portalContainer: HTMLDivElement | null;\n}\n\nconst StyledModalCardBody = styled(Card.Body)<{\n $noPadding?: boolean;\n $hidden?: boolean;\n}>`\n overflow-y: auto;\n ${semanticScrollbar}\n flex: 1;\n min-height: 0;\n ${({ $noPadding }) =>\n $noPadding\n ? 'padding: 0;'\n : `\n padding-left: ${Spacing[4]};\n padding-right: ${Spacing[4]};\n `}\n ${({ $hidden }) => $hidden && 'display: none;'}\n`;\n\n/**\n * Card to be used in Modal contexts. Inherits props from react-aria-components Dialog.\n */\nconst ModalCard = forwardRef<HTMLDivElement, ModalCardInternalProps>(function ModalCard(\n {\n title,\n children,\n showCloseButton = true,\n closeButtonLabel,\n size,\n footer,\n tabs,\n noBodyPadding = false,\n portalContainer,\n ...props\n },\n ref,\n) {\n const strings = usePDSStrings();\n const [selectedTabIdx, setSelectedTabIdx] = useState(0);\n const tabCount = tabs?.length ?? 0;\n\n useEffect(() => {\n setSelectedTabIdx(0);\n }, [tabCount]);\n\n const titleAndClose = (\n <ModalHeader justify='flex-start' align='center' spacing={Spacing[2]} $hasTabs={Boolean(tabs)}>\n <ModalHeaderTitle>{title ? <ModalTitle>{title}</ModalTitle> : null}</ModalHeaderTitle>\n {showCloseButton && <ModalClose aria-label={closeButtonLabel ?? strings.closeModal} />}\n </ModalHeader>\n );\n\n const modalHeader = tabs ? (\n <Stack>\n {titleAndClose}\n <ModalTabBar>\n {tabs.map((tab, idx) => (\n <Tab\n key={tab.name}\n selected={selectedTabIdx === idx}\n id={`pds-modal_tab-${idx}`}\n onClick={() => setSelectedTabIdx(idx)}\n aria-controls={`pds-modal_tab-panel-${idx}`}\n >\n {tab.name}\n </Tab>\n ))}\n </ModalTabBar>\n </Stack>\n ) : (\n titleAndClose\n );\n\n return (\n <StyledDialog {...props} ref={ref}>\n <StyledCard elevated $size={size}>\n {(showCloseButton || title) && modalHeader}\n {tabs ? (\n tabs.map((tab, idx) => (\n <StyledModalCardBody\n key={tab.name}\n $noPadding={noBodyPadding}\n $hidden={selectedTabIdx !== idx}\n role={tabs ? 'tabpanel' : undefined}\n id={`pds-modal_tab-panel-${tab.name}`}\n aria-labelledby={`pds-modal_tab-${tab.name}`}\n >\n {typeof tab.contents === 'function'\n ? tab.contents({ portalContainer })\n : tab.contents}\n </StyledModalCardBody>\n ))\n ) : (\n <StyledModalCardBody\n $noPadding={noBodyPadding}\n role={tabs ? 'tabpanel' : undefined}\n id={`pds-modal_tab-panel-${selectedTabIdx}`}\n aria-labelledby={`pds-modal_tab-${selectedTabIdx}`}\n >\n {children}\n </StyledModalCardBody>\n )}\n\n {footer && <ModalFooter>{footer}</ModalFooter>}\n </StyledCard>\n </StyledDialog>\n );\n});\n\ninterface TabView {\n name: string;\n contents: ModalRenderable;\n badge?: React.ReactElement;\n disabled?: boolean;\n 'data-tour-target'?: string;\n}\n\nexport interface ModalProps {\n /**\n * Title of the Card\n */\n title?: string;\n\n /**\n * Component to use as trigger. React Aria trigger props will be merged with this element.\n */\n trigger?: ComponentProps<typeof Pressable>['children'];\n\n /**\n * Props to apply to Modal.Card within\n */\n contentProps?: ModalCardProps;\n\n /**\n * Max width of the modal\n */\n size?: 'auto' | 'md' | 'lg' | 'xl' | 'full';\n\n /**\n * Footer section intended for actions.\n * You can pass in Buttons directly and they will render in a HStack.\n */\n footer?: ReactNode;\n\n /**\n * Renders tabs within the modal.\n * Adds a tab bar and will render the contents of the selected tab in a tabpanel.\n * Overrides `children`.\n */\n tabs?: TabView[];\n\n /**\n * Children content\n */\n children?: ModalRenderable;\n\n /**\n * When true, removes horizontal and vertical padding from the body. Defaults to false.\n * Can also be set via contentProps.noBodyPadding.\n */\n noBodyPadding?: boolean;\n\n /**\n * Controls whether the modal is open (controlled)\n */\n open?: boolean;\n\n /**\n * Default open state (uncontrolled)\n */\n defaultOpen?: boolean;\n\n /**\n * Handler called when open state changes\n */\n onOpenChange?: (isOpen: boolean) => void;\n\n /**\n * Whether the modal can be dismissed by clicking outside or pressing escape\n */\n isDismissable?: boolean;\n\n /**\n * Whether pressing the escape key closes the modal\n */\n isKeyboardDismissDisabled?: boolean;\n}\n\nconst Modal = ({\n children,\n trigger,\n contentProps,\n noBodyPadding = false,\n size = 'md',\n title,\n footer,\n tabs,\n defaultOpen,\n onOpenChange,\n isDismissable = false,\n isKeyboardDismissDisabled = false,\n open,\n}: ModalProps) => {\n const [portalContainer, setPortalContainer] = useState<HTMLDivElement | null>(null);\n const overlayState = useOverlayTriggerState({\n isOpen: open,\n defaultOpen,\n onOpenChange,\n });\n const surfaceId = useEmbeddedSurfaceId();\n const { insetRight: modalInsetRight, panelState } = useModalInsetRight();\n const transitionMs =\n panelState === 'opening'\n ? SIDEBAR_OPEN_TRANSITION_MS\n : panelState === 'closing'\n ? SIDEBAR_CLOSE_TRANSITION_MS\n : 0;\n\n const content = (\n <ModalCard\n size={size}\n title={title}\n footer={footer}\n tabs={tabs}\n noBodyPadding={noBodyPadding}\n {...contentProps}\n portalContainer={portalContainer}\n >\n {typeof children === 'function' ? children({ portalContainer }) : children}\n </ModalCard>\n );\n\n // Wrap trigger element to ensure it works with react-aria-components\n const overlay = (\n <EmbeddedSurfaceOverlay\n surfaceId={surfaceId}\n $insetRight={modalInsetRight}\n $transitionMs={transitionMs}\n isDismissable={isDismissable}\n isKeyboardDismissDisabled={isKeyboardDismissDisabled}\n shouldCloseOnInteractOutside={(element) => !element.closest('[data-react-aria-top-layer]')}\n >\n <EmbeddedSurfaceModal ref={setPortalContainer} surfaceId={surfaceId}>\n {content}\n </EmbeddedSurfaceModal>\n </EmbeddedSurfaceOverlay>\n );\n\n // Without a trigger (controlled modals) DialogTrigger would render a PressResponder with no\n // pressable child, which react-aria warns about, so provide the overlay state directly.\n if (!trigger) {\n return (\n <OverlayTriggerStateContext.Provider value={overlayState}>\n {overlay}\n </OverlayTriggerStateContext.Provider>\n );\n }\n\n return (\n <DialogTrigger isOpen={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange}>\n <Pressable>{trigger}</Pressable>\n {overlay}\n </DialogTrigger>\n );\n};\n\nexport default Object.assign(Modal, {\n Title: ModalTitle,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AA2CA,MAAM,qBAAqB,OAAO,aAAa;;;;;;;;;;;;;;YAmBnC,EAAE,kBAAkB,YAAY;uBACrB,EAAE,oBAAoB,cAAc;;sBAErC,EAAE,wBAAwB,kBAAkB;;KAE7D,EAAE,mBACH,g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S,EACb,UACA,SACA,cACA,gBAAgB,OAChB,OAAO,MACP,OACA,QACA,MACA,aACA,cACA,gBAAgB,OAChB,4BAA4B,OAC5B,WACgB;CAChB,MAAM,CAAC,iBAAiB,sBAAsB,SAAgC,KAAK;CACnF,MAAM,eAAe,uBAAuB;EAC1C,QAAQ;EACR;EACA;EACD,CAAC;CACF,MAAM,YAAY,sBAAsB;CACxC,MAAM,EAAE,YAAY,iBAAiB,eAAe,oBAAoB;CAuBxE,MAAM,UACJ,oBAAC,wBAAD;EACa;EACX,aAAa;EACb,eAzBF,eAAe,YAAA,MAEX,eAAe,YAAA,MAEb;EAsBW;EACY;EAC3B,+BAA+B,YAAY,CAAC,QAAQ,QAAQ,8BAA8B;YAE1F,oBAAC,sBAAD;GAAsB,KAAK;GAA+B;aACvD,oBAxBJ,WAAD;IACQ;IACC;IACC;IACF;IACS;IACf,GAAI;IACa;cAEhB,OAAO,aAAa,aAAa,SAAS,EAAE,iBAAiB,CAAC,GAAG;IACxD,CAcA;GACa,CAAA;EACA,CAAA;AAK3B,KAAI,CAAC,QACH,QACE,oBAAC,2BAA2B,UAA5B;EAAqC,OAAO;YACzC;EACmC,CAAA;AAI1C,QACE,qBAAC,eAAD;EAAe,QAAQ;EAAmB;EAA2B;YAArE,CACE,oBAAC,WAAD,EAAA,UAAY,SAAoB,CAAA,EAC/B,QACa;;;AAIpB,IAAA,gBAAe,OAAO,OAAOA,SAAO,EAClC,OAAO,YACR,CAAC"}
|
|
1
|
+
{"version":3,"file":"Modal-De5_bPJ_.mjs","names":["AriaModal","Button","Heading","AriaHeading","Card","Modal"],"sources":["../src/components/Modal/Modal.tsx"],"sourcesContent":["import {\n forwardRef,\n type ComponentProps,\n type ComponentPropsWithoutRef,\n type MouseEvent,\n type ReactNode,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport {\n Dialog,\n DialogTrigger,\n Heading as AriaHeading,\n Modal as AriaModal,\n ModalOverlay,\n type ModalOverlayProps,\n OverlayTriggerStateContext,\n Pressable,\n} from 'react-aria-components';\nimport { useOverlayTriggerState } from 'react-stately';\nimport styled from 'styled-components';\n\nimport Button, { type ButtonProps } from '@persona/design-system/components/Button';\nimport Card from '@persona/design-system/components/Card';\nimport Stack, { HStack } from '@persona/design-system/components/Stack';\nimport TabBar, { Tab } from '@persona/design-system/components/TabBar';\nimport { Heading } from '@persona/design-system/components/Text';\nimport { Color, Spacing } from '@persona/design-tokens';\nimport { XIcon } from '@persona/icons';\n\nimport { usePDSStrings } from '#src/lib/i18n';\nimport { semanticColor, semanticOnly } from '#src/lib/semanticColor';\nimport useEmbeddedSurface, {\n useEmbeddedSurfaceGate,\n useEmbeddedSurfaceId,\n} from '#src/lib/useEmbeddedSurface';\nimport useModalInsetRight, {\n SIDEBAR_CLOSE_TRANSITION_MS,\n SIDEBAR_OPEN_TRANSITION_MS,\n} from '#src/lib/useModalInsetRight';\nimport { semanticScrollbar } from '#src/mixins/scrollbar';\n\nconst StyledModalOverlay = styled(ModalOverlay)<{\n $hostPending: boolean;\n $animationDelayMs: number;\n $insetRight: string;\n $transitionMs: number;\n}>`\n @keyframes overlayShow {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n }\n background-color: rgba(0, 0, 0, 0.5);\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: ${({ $insetRight }) => $insetRight};\n transition: right ${({ $transitionMs }) => $transitionMs}ms ease-out;\n animation: overlayShow 150ms cubic-bezier(0.16, 1, 0.3, 1);\n animation-delay: ${({ $animationDelayMs }) => $animationDelayMs}ms;\n animation-fill-mode: both;\n ${({ $hostPending }) =>\n $hostPending &&\n `\n animation-play-state: paused;\n `}\n @media (prefers-reduced-motion: reduce) {\n animation-duration: 0ms;\n animation-delay: 0ms;\n animation-play-state: running;\n }\n z-index: 10000;\n display: flex;\n align-items: center;\n justify-content: center;\n`;\n\nconst StyledModal = styled(AriaModal)`\n z-index: 10001;\n outline: none;\n width: fit-content;\n max-width: 100%;\n ${semanticOnly((tokens) => `color: ${tokens.FgPrimary};`)}\n`;\n\n/**\n * React Aria keeps the overlay mounted through the exit animation, so announcing the surface from\n * here — rather than from the persistent gate below — releases the host's backdrop exactly when the\n * modal stops being painted.\n */\nconst EmbeddedSurfaceModal = forwardRef<HTMLDivElement, { children: ReactNode; surfaceId: string }>(\n function EmbeddedSurfaceModal({ children, surfaceId }, ref) {\n useEmbeddedSurface(surfaceId);\n return <StyledModal ref={ref}>{children}</StyledModal>;\n },\n);\n\ntype EmbeddedSurfaceOverlayProps = ModalOverlayProps & {\n $insetRight: string;\n $transitionMs: number;\n surfaceId: string;\n};\n\nconst EmbeddedSurfaceOverlay = ({ surfaceId, ...props }: EmbeddedSurfaceOverlayProps) => {\n const state = useContext(OverlayTriggerStateContext);\n const isOpen = state?.isOpen ?? false;\n const { ready, animationDelayMs } = useEmbeddedSurfaceGate(surfaceId, isOpen);\n\n const { $insetRight, $transitionMs, ...overlayProps } = props;\n return (\n <StyledModalOverlay\n {...overlayProps}\n $insetRight={$insetRight}\n $transitionMs={$transitionMs}\n $animationDelayMs={animationDelayMs}\n $hostPending={isOpen && !ready}\n />\n );\n};\n\nconst ModalCloseButton = styled(Button)`\n display: inline-flex;\n padding: ${Spacing[2]};\n border-radius: ${Spacing[1]};\n width: fit-content;\n min-width: unset;\n`;\n\nconst ModalFooter = styled(HStack).attrs({\n justify: 'flex-end',\n align: 'center',\n spacing: Spacing[2],\n})`\n padding: ${Spacing[3]} ${Spacing[4]};\n border-top: 1px solid ${({ theme }) => semanticColor(theme, 'BorderSubtle', Color.BorderDivider)};\n`;\n\nconst ModalHeaderTitle = styled.div`\n flex: 1;\n`;\n\nexport const ModalTrigger = DialogTrigger;\nexport const ModalContent = StyledModal;\n\nexport const ModalClose = ({ onClick, ...props }: ButtonProps) => {\n const state = useContext(OverlayTriggerStateContext);\n return (\n <ModalCloseButton\n variant='text'\n width='icon'\n size='md'\n {...props}\n onClick={(event: MouseEvent<HTMLButtonElement>) => {\n // Return the consumer's result so Button can await a returned Promise (pending state,\n // swallowed rejection). The modal still closes immediately, as it did before.\n const result = onClick?.(event);\n if (!event.defaultPrevented) {\n state?.close();\n }\n return result;\n }}\n >\n <XIcon />\n </ModalCloseButton>\n );\n};\n\nexport interface ModalTitleProps {\n children: ReactNode;\n className?: string;\n}\n\n/** Props passed to modal content render functions. */\nexport interface ModalRenderProps {\n /** Element that floating content should use as its portal container. */\n portalContainer: HTMLDivElement | null;\n}\n\ntype ModalRenderable = ReactNode | ((props: ModalRenderProps) => ReactNode);\n\nconst ModalTitle = ({ children, ...props }: ModalTitleProps) => {\n return (\n <Heading size='sm' color='primary' as={AriaHeading} slot='title' {...props}>\n {children}\n </Heading>\n );\n};\n\nconst ModalHeader = styled(HStack)<{ $hasTabs: boolean }>`\n border-bottom: ${({ $hasTabs, theme }) =>\n $hasTabs ? 'none' : `1px solid ${semanticColor(theme, 'BorderSubtle', Color.BorderDivider)}`};\n padding: ${({ $hasTabs }) =>\n $hasTabs\n ? `${Spacing[3]} ${Spacing[2]} ${Spacing[1]} ${Spacing[4]}`\n : `${Spacing[3]} ${Spacing[2]} ${Spacing[3]} ${Spacing[4]}`};\n`;\n\nconst ModalTabBar = styled(TabBar)`\n padding-left: ${Spacing[4]};\n`;\n\nconst StyledDialog = styled(Dialog)`\n outline: none;\n`;\n\nconst StyledCard = styled(Card)<{ $size?: 'auto' | 'md' | 'lg' | 'xl' | 'full' }>`\n position: relative;\n width: ${({ $size }) => {\n switch ($size) {\n case 'auto':\n return 'auto';\n case 'full':\n return 'calc(100vw - 160px)';\n default:\n return '90vw';\n }\n }};\n max-width: ${({ theme, $size }) => {\n switch ($size) {\n case 'auto':\n return 'auto';\n case 'full':\n return 'calc(100vw - 160px)';\n default:\n return theme.modal.width[$size];\n }\n }};\n /* TODO: Use breakpoints to make this responsive */\n max-height: ${({ $size }) => ($size === 'full' ? 'calc(100vh - 160px)' : '85vh')};\n display: flex;\n flex-direction: column;\n overflow: hidden;\n ${({ $size }) =>\n $size === 'full' &&\n `\n height: calc(100vh - 160px);\n `}\n margin-bottom: 0;\n`;\n\ninterface ModalCardProps extends ComponentPropsWithoutRef<typeof Dialog> {\n /**\n * Display X button to close popover\n */\n showCloseButton?: boolean;\n\n /**\n * Accessible label for the built-in close button. Defaults to the PDS closeModal string (\"Close\").\n */\n closeButtonLabel?: string;\n\n /**\n * Max width of the modal\n */\n size?: 'auto' | 'md' | 'lg' | 'xl' | 'full';\n\n /**\n * Footer content\n */\n footer?: ReactNode;\n\n /**\n * Renders tabs within the modal.\n * Adds a tab bar and will render the contents of the selected tab in a tabpanel.\n * Overrides `children`.\n * Tab contents can be render functions that receive the modal portal container.\n */\n tabs?: TabView[];\n\n /**\n * Title of the modal\n */\n title?: ReactNode;\n\n /**\n * Children content\n */\n children?: ReactNode;\n\n /**\n * When true, removes horizontal and vertical padding from the body. Defaults to false.\n */\n noBodyPadding?: boolean;\n\n /**\n * Additional props for the Dialog element\n */\n className?: string;\n}\n\ninterface ModalCardInternalProps extends ModalCardProps {\n portalContainer: HTMLDivElement | null;\n}\n\nconst StyledModalCardBody = styled(Card.Body)<{\n $noPadding?: boolean;\n $hidden?: boolean;\n}>`\n overflow-y: auto;\n ${semanticScrollbar}\n flex: 1;\n min-height: 0;\n ${({ $noPadding }) =>\n $noPadding\n ? 'padding: 0;'\n : `\n padding-left: ${Spacing[4]};\n padding-right: ${Spacing[4]};\n `}\n ${({ $hidden }) => $hidden && 'display: none;'}\n`;\n\n/**\n * Card to be used in Modal contexts. Inherits props from react-aria-components Dialog.\n */\nconst ModalCard = forwardRef<HTMLDivElement, ModalCardInternalProps>(function ModalCard(\n {\n title,\n children,\n showCloseButton = true,\n closeButtonLabel,\n size,\n footer,\n tabs,\n noBodyPadding = false,\n portalContainer,\n ...props\n },\n ref,\n) {\n const strings = usePDSStrings();\n const [selectedTabIdx, setSelectedTabIdx] = useState(0);\n const tabCount = tabs?.length ?? 0;\n\n useEffect(() => {\n setSelectedTabIdx(0);\n }, [tabCount]);\n\n const titleAndClose = (\n <ModalHeader justify='flex-start' align='center' spacing={Spacing[2]} $hasTabs={Boolean(tabs)}>\n <ModalHeaderTitle>{title ? <ModalTitle>{title}</ModalTitle> : null}</ModalHeaderTitle>\n {showCloseButton && <ModalClose aria-label={closeButtonLabel ?? strings.closeModal} />}\n </ModalHeader>\n );\n\n const modalHeader = tabs ? (\n <Stack>\n {titleAndClose}\n <ModalTabBar>\n {tabs.map((tab, idx) => (\n <Tab\n key={tab.name}\n selected={selectedTabIdx === idx}\n id={`pds-modal_tab-${idx}`}\n onClick={() => setSelectedTabIdx(idx)}\n aria-controls={`pds-modal_tab-panel-${idx}`}\n >\n {tab.name}\n </Tab>\n ))}\n </ModalTabBar>\n </Stack>\n ) : (\n titleAndClose\n );\n\n return (\n <StyledDialog {...props} ref={ref}>\n <StyledCard elevated $size={size}>\n {(showCloseButton || title) && modalHeader}\n {tabs ? (\n tabs.map((tab, idx) => (\n <StyledModalCardBody\n key={tab.name}\n $noPadding={noBodyPadding}\n $hidden={selectedTabIdx !== idx}\n role={tabs ? 'tabpanel' : undefined}\n id={`pds-modal_tab-panel-${tab.name}`}\n aria-labelledby={`pds-modal_tab-${tab.name}`}\n >\n {typeof tab.contents === 'function'\n ? tab.contents({ portalContainer })\n : tab.contents}\n </StyledModalCardBody>\n ))\n ) : (\n <StyledModalCardBody\n $noPadding={noBodyPadding}\n role={tabs ? 'tabpanel' : undefined}\n id={`pds-modal_tab-panel-${selectedTabIdx}`}\n aria-labelledby={`pds-modal_tab-${selectedTabIdx}`}\n >\n {children}\n </StyledModalCardBody>\n )}\n\n {footer && <ModalFooter>{footer}</ModalFooter>}\n </StyledCard>\n </StyledDialog>\n );\n});\n\ninterface TabView {\n name: string;\n contents: ModalRenderable;\n badge?: React.ReactElement;\n disabled?: boolean;\n 'data-tour-target'?: string;\n}\n\nexport interface ModalProps {\n /**\n * Title of the Card\n */\n title?: string;\n\n /**\n * Component to use as trigger. React Aria trigger props will be merged with this element.\n */\n trigger?: ComponentProps<typeof Pressable>['children'];\n\n /**\n * Props to apply to Modal.Card within\n */\n contentProps?: ModalCardProps;\n\n /**\n * Max width of the modal\n */\n size?: 'auto' | 'md' | 'lg' | 'xl' | 'full';\n\n /**\n * Footer section intended for actions.\n * You can pass in Buttons directly and they will render in a HStack.\n */\n footer?: ReactNode;\n\n /**\n * Renders tabs within the modal.\n * Adds a tab bar and will render the contents of the selected tab in a tabpanel.\n * Overrides `children`.\n */\n tabs?: TabView[];\n\n /**\n * Children content\n */\n children?: ModalRenderable;\n\n /**\n * When true, removes horizontal and vertical padding from the body. Defaults to false.\n * Can also be set via contentProps.noBodyPadding.\n */\n noBodyPadding?: boolean;\n\n /**\n * Controls whether the modal is open (controlled)\n */\n open?: boolean;\n\n /**\n * Default open state (uncontrolled)\n */\n defaultOpen?: boolean;\n\n /**\n * Handler called when open state changes\n */\n onOpenChange?: (isOpen: boolean) => void;\n\n /**\n * Whether the modal can be dismissed by clicking outside or pressing escape\n */\n isDismissable?: boolean;\n\n /**\n * Whether pressing the escape key closes the modal\n */\n isKeyboardDismissDisabled?: boolean;\n}\n\nconst Modal = ({\n children,\n trigger,\n contentProps,\n noBodyPadding = false,\n size = 'md',\n title,\n footer,\n tabs,\n defaultOpen,\n onOpenChange,\n isDismissable = false,\n isKeyboardDismissDisabled = false,\n open,\n}: ModalProps) => {\n const [portalContainer, setPortalContainer] = useState<HTMLDivElement | null>(null);\n const overlayState = useOverlayTriggerState({\n isOpen: open,\n defaultOpen,\n onOpenChange,\n });\n const surfaceId = useEmbeddedSurfaceId();\n const { insetRight: modalInsetRight, panelState } = useModalInsetRight();\n const transitionMs =\n panelState === 'opening'\n ? SIDEBAR_OPEN_TRANSITION_MS\n : panelState === 'closing'\n ? SIDEBAR_CLOSE_TRANSITION_MS\n : 0;\n\n const content = (\n <ModalCard\n size={size}\n title={title}\n footer={footer}\n tabs={tabs}\n noBodyPadding={noBodyPadding}\n {...contentProps}\n portalContainer={portalContainer}\n >\n {typeof children === 'function' ? children({ portalContainer }) : children}\n </ModalCard>\n );\n\n // Wrap trigger element to ensure it works with react-aria-components\n const overlay = (\n <EmbeddedSurfaceOverlay\n surfaceId={surfaceId}\n $insetRight={modalInsetRight}\n $transitionMs={transitionMs}\n isDismissable={isDismissable}\n isKeyboardDismissDisabled={isKeyboardDismissDisabled}\n shouldCloseOnInteractOutside={(element) => !element.closest('[data-react-aria-top-layer]')}\n >\n <EmbeddedSurfaceModal ref={setPortalContainer} surfaceId={surfaceId}>\n {content}\n </EmbeddedSurfaceModal>\n </EmbeddedSurfaceOverlay>\n );\n\n // Without a trigger (controlled modals) DialogTrigger would render a PressResponder with no\n // pressable child, which react-aria warns about, so provide the overlay state directly.\n if (!trigger) {\n return (\n <OverlayTriggerStateContext.Provider value={overlayState}>\n {overlay}\n </OverlayTriggerStateContext.Provider>\n );\n }\n\n return (\n <DialogTrigger isOpen={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange}>\n <Pressable>{trigger}</Pressable>\n {overlay}\n </DialogTrigger>\n );\n};\n\nexport default Object.assign(Modal, {\n Title: ModalTitle,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AA2CA,MAAM,qBAAqB,OAAO,aAAa;;;;;;;;;;;;;;YAmBnC,EAAE,kBAAkB,YAAY;uBACrB,EAAE,oBAAoB,cAAc;;sBAErC,EAAE,wBAAwB,kBAAkB;;KAE7D,EAAE,mBACH,gBACA;;IAEA;;;;;;;;;;;AAYJ,MAAM,cAAc,OAAOA,MAAU;;;;;IAKjC,cAAc,WAAW,UAAU,OAAO,UAAU,GAAG,CAAC;;;;;;;AAQ5D,MAAM,uBAAuB,WAC3B,SAAS,qBAAqB,EAAE,UAAU,aAAa,KAAK;AAC1D,oBAAmB,UAAU;AAC7B,QAAO,oBAAC,aAAD;EAAkB;EAAM;EAAuB,CAAA;EAEzD;AAQD,MAAM,0BAA0B,EAAE,WAAW,GAAG,YAAyC;CAEvF,MAAM,SADQ,WAAW,2BACL,EAAE,UAAU;CAChC,MAAM,EAAE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,YAAA,MAEb;EAsBW;EACY;EAC3B,+BAA+B,YAAY,CAAC,QAAQ,QAAQ,8BAA8B;YAE1F,oBAAC,sBAAD;GAAsB,KAAK;GAA+B;aACvD,oBAxBJ,WAAD;IACQ;IACC;IACC;IACF;IACS;IACf,GAAI;IACa;cAEhB,OAAO,aAAa,aAAa,SAAS,EAAE,iBAAiB,CAAC,GAAG;IACxD,CAcA;GACa,CAAA;EACA,CAAA;AAK3B,KAAI,CAAC,QACH,QACE,oBAAC,2BAA2B,UAA5B;EAAqC,OAAO;YACzC;EACmC,CAAA;AAI1C,QACE,qBAAC,eAAD;EAAe,QAAQ;EAAmB;EAA2B;YAArE,CACE,oBAAC,WAAD,EAAA,UAAY,SAAoB,CAAA,EAC/B,QACa;;;AAIpB,IAAA,gBAAe,OAAO,OAAOA,SAAO,EAClC,OAAO,YACR,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { a as styled, r as css } from "./styledComponentsInterop-Cs5CCPRy.mjs";
|
|
2
|
+
import { semanticColor, semanticOnly } from "./lib/semanticColor.mjs";
|
|
3
|
+
import { i as Paragraph } from "./Text-D0vEReED.mjs";
|
|
4
|
+
import { t as Breadcrumbs } from "./Breadcrumbs-CMf3Uvow.mjs";
|
|
5
|
+
import { Spacing } from "@persona/design-tokens";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/PageHeader/PageHeader.tsx
|
|
8
|
+
const PageHeaderContainer = styled.header`
|
|
9
|
+
display: flex;
|
|
10
|
+
width: 100%;
|
|
11
|
+
justify-content: space-between;
|
|
12
|
+
align-items: center;
|
|
13
|
+
padding: ${Spacing[3]} ${Spacing[5]};
|
|
14
|
+
background-color: ${({ theme }) => semanticColor(theme, "SurfacePrimary", theme.color.background.primary)};
|
|
15
|
+
border-bottom: 1px solid ${({ theme }) => semanticColor(theme, "BorderDivider", theme.color.border.primary)};
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
min-height: 56px;
|
|
18
|
+
`;
|
|
19
|
+
const TitleContainer = styled.div`
|
|
20
|
+
display: flex;
|
|
21
|
+
flex: 0 1 auto;
|
|
22
|
+
min-width: 0;
|
|
23
|
+
align-items: center;
|
|
24
|
+
h1 {
|
|
25
|
+
${semanticOnly((tokens) => `color: ${tokens.FgPrimary};`)}
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
const LeftContainer = styled.div`
|
|
29
|
+
display: flex;
|
|
30
|
+
flex: 1 1 auto;
|
|
31
|
+
align-items: center;
|
|
32
|
+
gap: ${Spacing[2]};
|
|
33
|
+
min-width: 0;
|
|
34
|
+
& > :not(${TitleContainer}):not(p) {
|
|
35
|
+
flex-shrink: 0;
|
|
36
|
+
}
|
|
37
|
+
> p {
|
|
38
|
+
${semanticOnly((tokens) => `color: ${tokens.FgSecondary};`)}
|
|
39
|
+
}
|
|
40
|
+
/* Title and subtitle differ in size, so align their baselines rather than their boxes. */
|
|
41
|
+
${({ $hasSubtitle }) => $hasSubtitle && css`
|
|
42
|
+
> ${TitleContainer}, > p {
|
|
43
|
+
align-self: baseline;
|
|
44
|
+
}
|
|
45
|
+
`}
|
|
46
|
+
`;
|
|
47
|
+
const RightContainer = styled.div`
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
gap: ${Spacing[2]};
|
|
51
|
+
margin-left: ${Spacing[3]};
|
|
52
|
+
flex-shrink: 0;
|
|
53
|
+
`;
|
|
54
|
+
const PageHeader = ({ title, breadcrumbs, subtitle, level: _level, prepend, append, children, ...props }) => /* @__PURE__ */ jsxs(PageHeaderContainer, {
|
|
55
|
+
...props,
|
|
56
|
+
children: [/* @__PURE__ */ jsxs(LeftContainer, {
|
|
57
|
+
$hasSubtitle: Boolean(subtitle),
|
|
58
|
+
children: [
|
|
59
|
+
prepend,
|
|
60
|
+
/* @__PURE__ */ jsx(TitleContainer, { children: breadcrumbs ? /* @__PURE__ */ jsx(Breadcrumbs, {
|
|
61
|
+
size: "lg",
|
|
62
|
+
...breadcrumbs
|
|
63
|
+
}) : /* @__PURE__ */ jsx(Paragraph, {
|
|
64
|
+
as: "h1",
|
|
65
|
+
size: "lg",
|
|
66
|
+
weight: "bold",
|
|
67
|
+
color: "primary",
|
|
68
|
+
children: title
|
|
69
|
+
}) }),
|
|
70
|
+
append,
|
|
71
|
+
subtitle && /* @__PURE__ */ jsx(Paragraph, {
|
|
72
|
+
size: "md",
|
|
73
|
+
children: subtitle
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
}), children && /* @__PURE__ */ jsx(RightContainer, { children })]
|
|
77
|
+
});
|
|
78
|
+
//#endregion
|
|
79
|
+
export { PageHeaderContainer as n, PageHeader as t };
|
|
80
|
+
|
|
81
|
+
//# sourceMappingURL=PageHeader-7_Hf6rHl.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageHeader-7_Hf6rHl.mjs","names":[],"sources":["../src/components/PageHeader/PageHeader.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { Spacing } from '@persona/design-tokens';\n\nimport Breadcrumbs, { type BreadcrumbsProps } from '#src/components/Breadcrumbs';\nimport { Paragraph } from '#src/components/Text';\nimport { semanticColor, semanticOnly } from '#src/lib/semanticColor';\n\nexport const PageHeaderContainer = styled.header`\n display: flex;\n width: 100%;\n justify-content: space-between;\n align-items: center;\n padding: ${Spacing[3]} ${Spacing[5]};\n background-color: ${({ theme }) => semanticColor(theme, 'SurfacePrimary', theme.color.background.primary)};\n border-bottom: 1px solid ${({ theme }) => semanticColor(theme, 'BorderDivider', theme.color.border.primary)};\n box-sizing: border-box;\n min-height: 56px;\n`;\n\nconst TitleContainer = styled.div`\n display: flex;\n flex: 0 1 auto;\n min-width: 0;\n align-items: center;\n h1 {\n ${semanticOnly((tokens) => `color: ${tokens.FgPrimary};`)}\n }\n`;\n\nconst LeftContainer = styled.div<{ $hasSubtitle: boolean }>`\n display: flex;\n flex: 1 1 auto;\n align-items: center;\n gap: ${Spacing[2]};\n min-width: 0;\n & > :not(${TitleContainer}):not(p) {\n flex-shrink: 0;\n }\n > p {\n ${semanticOnly((tokens) => `color: ${tokens.FgSecondary};`)}\n }\n /* Title and subtitle differ in size, so align their baselines rather than their boxes. */\n ${({ $hasSubtitle }) =>\n $hasSubtitle &&\n css`\n > ${TitleContainer}, > p {\n align-self: baseline;\n }\n `}\n`;\n\nconst RightContainer = styled.div`\n display: flex;\n align-items: center;\n gap: ${Spacing[2]};\n margin-left: ${Spacing[3]};\n flex-shrink: 0;\n`;\n\ninterface PageHeaderCommonProps {\n /**\n * @deprecated Has no effect. Use `title` on index pages and `breadcrumbs` on detail pages.\n */\n level?: 'product' | 'detail';\n prepend?: ReactNode;\n append?: ReactNode;\n children?: ReactNode;\n}\n\n/** Exactly one heading source is required: either `title` or `breadcrumbs`. */\nexport type PageHeaderProps = PageHeaderCommonProps &\n (\n | { title: ReactNode; subtitle?: ReactNode; breadcrumbs?: never }\n | {\n title?: never;\n /**\n * The subtitle is sunset in the breadcrumbs variant (PX-1299); fold the value it\n * carried (e.g. an object ID) into the current crumb, with a copy action if useful.\n */\n subtitle?: never;\n /**\n * Renders in place of `title`; the current crumb becomes the page `h1`, at `lg` size.\n * For detail pages: pass the ancestor crumb(s) plus the current page. Pages without\n * ancestors should pass `title` instead of a single crumb.\n */\n breadcrumbs: BreadcrumbsProps;\n }\n );\n\nconst PageHeader = ({\n title,\n breadcrumbs,\n subtitle,\n level: _level,\n prepend,\n append,\n children,\n ...props\n}: PageHeaderProps) => (\n <PageHeaderContainer {...props}>\n <LeftContainer $hasSubtitle={Boolean(subtitle)}>\n {prepend}\n <TitleContainer>\n {breadcrumbs ? (\n <Breadcrumbs size='lg' {...breadcrumbs} />\n ) : (\n <Paragraph as='h1' size='lg' weight='bold' color='primary'>\n {title}\n </Paragraph>\n )}\n </TitleContainer>\n {append}\n {subtitle && <Paragraph size='md'>{subtitle}</Paragraph>}\n </LeftContainer>\n {children && <RightContainer>{children}</RightContainer>}\n </PageHeaderContainer>\n);\n\nexport default PageHeader;\n"],"mappings":";;;;;;;AASA,MAAa,sBAAsB,OAAO,MAAM;;;;;aAKnC,QAAQ,GAAG,GAAG,QAAQ,GAAG;uBACf,EAAE,YAAY,cAAc,OAAO,kBAAkB,MAAM,MAAM,WAAW,QAAQ,CAAC;8BAC9E,EAAE,YAAY,cAAc,OAAO,iBAAiB,MAAM,MAAM,OAAO,QAAQ,CAAC;;;;AAK9G,MAAM,iBAAiB,OAAO,GAAG;;;;;;MAM3B,cAAc,WAAW,UAAU,OAAO,UAAU,GAAG,CAAC;;;AAI9D,MAAM,gBAAgB,OAAO,GAA8B;;;;SAIlD,QAAQ,GAAG;;aAEP,eAAe;;;;MAItB,cAAc,WAAW,UAAU,OAAO,YAAY,GAAG,CAAC;;;KAG3D,EAAE,mBACH,gBACA,GAAG;UACG,eAAe;;;MAGnB;;AAGN,MAAM,iBAAiB,OAAO,GAAG;;;SAGxB,QAAQ,GAAG;iBACH,QAAQ,GAAG;;;AAkC5B,MAAM,cAAc,EAClB,OACA,aACA,UACA,OAAO,QACP,SACA,QACA,UACA,GAAG,YAEH,qBAAC,qBAAD;CAAqB,GAAI;WAAzB,CACE,qBAAC,eAAD;EAAe,cAAc,QAAQ,SAAS;YAA9C;GACG;GACD,oBAAC,gBAAD,EAAA,UACG,cACC,oBAAC,aAAD;IAAa,MAAK;IAAK,GAAI;IAAe,CAAA,GAE1C,oBAAC,WAAD;IAAW,IAAG;IAAK,MAAK;IAAK,QAAO;IAAO,OAAM;cAC9C;IACS,CAAA,EAEC,CAAA;GAChB;GACA,YAAY,oBAAC,WAAD;IAAW,MAAK;cAAM;IAAqB,CAAA;GAC1C;KACf,YAAY,oBAAC,gBAAD,EAAiB,UAA0B,CAAA,CACpC"}
|
|
@@ -6,6 +6,9 @@ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
|
6
6
|
//#region src/components/PageHeader/PageHeader.d.ts
|
|
7
7
|
declare const PageHeaderContainer: _$styled_components0.StyledComponent<"header", any, {}, never>;
|
|
8
8
|
interface PageHeaderCommonProps {
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Has no effect. Use `title` on index pages and `breadcrumbs` on detail pages.
|
|
11
|
+
*/
|
|
9
12
|
level?: 'product' | 'detail';
|
|
10
13
|
prepend?: ReactNode;
|
|
11
14
|
append?: ReactNode;
|
|
@@ -22,14 +25,19 @@ type PageHeaderProps = PageHeaderCommonProps & ({
|
|
|
22
25
|
* The subtitle is sunset in the breadcrumbs variant (PX-1299); fold the value it
|
|
23
26
|
* carried (e.g. an object ID) into the current crumb, with a copy action if useful.
|
|
24
27
|
*/
|
|
25
|
-
subtitle?: never;
|
|
28
|
+
subtitle?: never;
|
|
29
|
+
/**
|
|
30
|
+
* Renders in place of `title`; the current crumb becomes the page `h1`, at `lg` size.
|
|
31
|
+
* For detail pages: pass the ancestor crumb(s) plus the current page. Pages without
|
|
32
|
+
* ancestors should pass `title` instead of a single crumb.
|
|
33
|
+
*/
|
|
26
34
|
breadcrumbs: BreadcrumbsProps;
|
|
27
35
|
});
|
|
28
36
|
declare const PageHeader: ({
|
|
29
37
|
title,
|
|
30
38
|
breadcrumbs,
|
|
31
39
|
subtitle,
|
|
32
|
-
level,
|
|
40
|
+
level: _level,
|
|
33
41
|
prepend,
|
|
34
42
|
append,
|
|
35
43
|
children,
|
|
@@ -37,4 +45,4 @@ declare const PageHeader: ({
|
|
|
37
45
|
}: PageHeaderProps) => _$react_jsx_runtime0.JSX.Element;
|
|
38
46
|
//#endregion
|
|
39
47
|
export { PageHeaderContainer as n, PageHeaderProps as r, PageHeader as t };
|
|
40
|
-
//# sourceMappingURL=PageHeader-
|
|
48
|
+
//# sourceMappingURL=PageHeader-UPiqJpIF.d.mts.map
|
package/dist/PageHeader.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as PageHeaderContainer, r as PageHeaderProps, t as PageHeader } from "./PageHeader-
|
|
1
|
+
import { n as PageHeaderContainer, r as PageHeaderProps, t as PageHeader } from "./PageHeader-UPiqJpIF.mjs";
|
|
2
2
|
export { PageHeaderContainer, PageHeaderProps, PageHeader as default };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { a as styled } from "./styledComponentsInterop-Cs5CCPRy.mjs";
|
|
2
|
-
import { l as usePDSStrings } from "./i18n-DaOKaFc2.mjs";
|
|
3
2
|
import { semanticColor } from "./lib/semanticColor.mjs";
|
|
3
|
+
import { l as usePDSStrings } from "./i18n-DaOKaFc2.mjs";
|
|
4
4
|
import { t as HStack } from "./Stack-Bzom2BTR.mjs";
|
|
5
|
-
import { n as Button } from "./IconButton-
|
|
6
|
-
import { n as Input } from "./Input-
|
|
7
|
-
import { n as Select, t as Option } from "./Select-
|
|
5
|
+
import { n as Button } from "./IconButton-DxHB2g80.mjs";
|
|
6
|
+
import { n as Input } from "./Input-RHXujO9u.mjs";
|
|
7
|
+
import { n as Select, t as Option } from "./Select-DOlw_LPR.mjs";
|
|
8
8
|
import { useEffect, useMemo, useState } from "react";
|
|
9
9
|
import { Color, Spacing, Typography } from "@persona/design-tokens";
|
|
10
10
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -198,4 +198,4 @@ var Pagination_default = Pagination;
|
|
|
198
198
|
//#endregion
|
|
199
199
|
export { MIN_PAGE_SIZE as a, DEFAULT_PAGE_SIZE_OPTIONS as i, PAGE_LIMIT_BEFORE_SCROLL_MODE as n, PageSelector as r, Pagination_default as t };
|
|
200
200
|
|
|
201
|
-
//# sourceMappingURL=Pagination-
|
|
201
|
+
//# sourceMappingURL=Pagination-DMH2IaV0.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pagination-C8hPOu0l.mjs","names":[],"sources":["../src/components/Pagination/constants.ts","../src/components/Pagination/PageSelector.tsx","../src/components/Pagination/PageSizeSelector.tsx","../src/components/Pagination/Pagination.tsx","../src/components/Pagination/index.ts"],"sourcesContent":["export const DEFAULT_PAGE_SIZE_OPTIONS = [10, 25, 50, 100, 300];\nexport const MIN_PAGE_SIZE = 10;\n","import { debounce } from 'lodash-es';\nimport { useEffect, useMemo, useState } from 'react';\nimport styled from 'styled-components';\n\nimport Button from '@persona/design-system/components/Button';\nimport { Input } from '@persona/design-system/components/Input';\nimport { HStack } from '@persona/design-system/components/Stack';\nimport { Spacing } from '@persona/design-tokens';\n\nimport { usePDSStrings } from '#src/lib/i18n';\n\nimport type { PaginationParams } from './types';\n\n// After a certain limit, it no longer makes sense for someone\n// to jump to the last page. Deep paging has performance limitations. A collection\n// with exactly this many pages still gets the page input: servers that cap paging\n// at this limit (Kaminari's max_pages) report every page up to it as reachable.\nexport const PAGE_LIMIT_BEFORE_SCROLL_MODE = 100;\n\nconst PageSelectorStack = styled(HStack).attrs({ justify: 'flex-end' })`\n padding: ${Spacing[2]};\n`;\n\nexport const PageInput = styled(HStack).attrs({ align: 'center' })`\n white-space: nowrap;\n`;\n\ninterface PageSelectorProps {\n paginationParams: PaginationParams;\n handlePageLinkClick: (pageNumber: number) => void;\n isLoading?: boolean;\n /**\n * Called with the new page number after the page changes (next, prev, or\n * typed input). Lets the consumer react to page changes -- e.g. scroll the\n * page back to the top.\n */\n onPageChange?: (pageNumber: number) => void;\n /**\n * `total-pages` is only a lower bound: render it as `13+` and keep Next enabled past it. See\n * `Pagination`'s prop of the same name.\n */\n totalIsLowerBound?: boolean;\n}\n\nexport default function PageSelector({\n paginationParams,\n handlePageLinkClick,\n isLoading,\n onPageChange,\n totalIsLowerBound = false,\n}: PageSelectorProps) {\n const strings = usePDSStrings();\n const {\n 'current-page': currentPage,\n 'total-pages': totalPages,\n 'lower-bound': lowerBound,\n } = paginationParams ?? {};\n const [selectedPage, setSelectedPage] = useState<number | undefined>(currentPage);\n // Next stays enabled at the last page the totals know of when more may follow.\n const morePagesMayFollow = lowerBound || totalIsLowerBound;\n // Paged past a minimum page count, how many pages there are is no longer known.\n const totalUnknown = lowerBound || (totalIsLowerBound && currentPage > totalPages);\n\n // We don't use useDebounced to avoid function object reference issues.\n const handlePageLinkClickDebounced = useMemo(\n () => debounce(handlePageLinkClick, 500),\n [handlePageLinkClick],\n );\n\n // Keep input state synced to pagination state when other user action changes\n // pagination state.\n useEffect(() => {\n if (currentPage != null) {\n setSelectedPage(currentPage);\n }\n }, [currentPage]);\n\n if (!paginationParams) {\n return <div />;\n }\n\n return (\n <PageSelectorStack data-test='pagination__page-selector' id='pagination__page-selector'>\n <PageInput>\n {totalPages <= PAGE_LIMIT_BEFORE_SCROLL_MODE && !totalUnknown ? (\n <Input\n aria-label={strings.goToPageNumber}\n size='sm'\n inputSize={2}\n onChange={(e) => {\n const value = e.target.valueAsNumber;\n if (Number.isNaN(value)) {\n setSelectedPage(undefined);\n } else {\n // Setting unbounded value feels smoother as the value is not corrected until after the fetch via useEffect.\n setSelectedPage(value);\n const boundedValue = Math.min(Math.max(e.target.valueAsNumber, 1), totalPages);\n handlePageLinkClickDebounced(boundedValue);\n onPageChange?.(boundedValue);\n }\n }}\n onBlur={(e) => {\n // Fill blank value on blur.\n if (Number.isNaN(e.target.valueAsNumber)) {\n setSelectedPage(currentPage);\n }\n }}\n min={1}\n max={totalPages}\n type='number'\n disabled={isLoading}\n value={selectedPage ?? ''}\n />\n ) : (\n currentPage + ' '\n )}\n {strings.pageCount(\n currentPage,\n totalUnknown\n ? strings.many\n : totalIsLowerBound\n ? strings.atLeast(totalPages)\n : totalPages,\n )}\n </PageInput>\n <Button\n id='pagination__page-selector--left'\n disabled={currentPage === 1 || isLoading}\n onClick={() => {\n if (currentPage !== 1) {\n const prevPageNum = currentPage - 1;\n setSelectedPage(prevPageNum);\n handlePageLinkClick(prevPageNum);\n onPageChange?.(prevPageNum);\n }\n }}\n data-test='pagination__page-selector-paddle-left'\n variant='inverse'\n size='sm'\n width='auto'\n aria-label={strings.previousPage}\n >\n {strings.previousShort}\n </Button>\n <Button\n id='pagination__page-selector--right'\n disabled={(currentPage === totalPages && !morePagesMayFollow) || isLoading}\n onClick={() => {\n if (currentPage !== totalPages || morePagesMayFollow) {\n const nextPageNum = currentPage + 1;\n setSelectedPage(nextPageNum);\n handlePageLinkClick(nextPageNum);\n onPageChange?.(nextPageNum);\n }\n }}\n data-test='pagination__page-selector-paddle-right'\n variant='inverse'\n size='sm'\n width='auto'\n aria-label={strings.nextPage}\n >\n {strings.next}\n </Button>\n </PageSelectorStack>\n );\n}\n","import styled from 'styled-components';\n\nimport Select, { Option } from '@persona/design-system/components/Select';\nimport { Color, Spacing, Typography } from '@persona/design-tokens';\n\nimport { usePDSStrings } from '#src/lib/i18n';\nimport { semanticColor } from '#src/lib/semanticColor';\n\nconst Selector = styled('div')`\n padding: ${Spacing[2]};\n display: flex;\n justify-content: flex-end;\n`;\n\nconst Label = styled.label`\n display: flex;\n align-items: center;\n white-space: nowrap;\n gap: ${Spacing[2]};\n padding: ${Spacing[2]};\n`;\n\ninterface PageSizeOptionProps {\n currentPageSize: number;\n pageSizeOption: number;\n}\n\nexport const PageSizeOption = styled('div')<PageSizeOptionProps>`\n padding: 0 ${Spacing[1]};\n color: ${({ theme }) => semanticColor(theme, 'FgAccentStatic', Color.PrimaryPurple)};\n cursor: pointer;\n\n ${({ currentPageSize, pageSizeOption }) => {\n if (currentPageSize === pageSizeOption) {\n return `\n ${Typography.TextMediumBold};\n text-decoration: underline;\n `;\n }\n }};\n\n &:hover {\n text-decoration: underline;\n }\n`;\n\ninterface PageSizeSelectorProps {\n pageSize: number;\n pageSizeOptions: number[];\n handlePageSizeClick: (pageSize: number) => void;\n /**\n * Element the options menu renders into. Pass a container inside the surrounding dialog when the\n * pager sits in a clipping container, where the menu would otherwise be cut off.\n */\n menuPortalContainer?: HTMLElement | null;\n}\n\nconst PageSizeSelector = ({\n pageSize,\n pageSizeOptions,\n handlePageSizeClick,\n menuPortalContainer,\n}: PageSizeSelectorProps) => {\n const strings = usePDSStrings();\n // Add pageSize to selector just in case it isn't part of the options so UI doesn't look weird\n const pageSizes = [\n ...pageSizeOptions,\n ...(pageSizeOptions.includes(pageSize) ? [] : [pageSize]),\n ].sort((a, b) => a - b);\n\n return (\n <Selector data-test='pagination__page-size-selector'>\n <Label>\n {strings.itemsPerPage}\n <Select\n value={pageSize.toString()}\n onValueChange={(val) => handlePageSizeClick(Number(val))}\n size='sm'\n portal={menuPortalContainer != null}\n portalContainer={menuPortalContainer}\n >\n {pageSizes.map((size) => (\n <Option key={size} value={size.toString()}>\n {size}\n </Option>\n ))}\n </Select>\n </Label>\n </Selector>\n );\n};\n\nexport default PageSizeSelector;\n","import styled from 'styled-components';\n\nimport { Color, Typography } from '@persona/design-tokens';\n\nimport { usePDSStrings } from '#src/lib/i18n';\nimport { semanticColor } from '#src/lib/semanticColor';\n\nimport { DEFAULT_PAGE_SIZE_OPTIONS } from './constants';\nimport PageSelector from './PageSelector';\nimport PageSizeSelector from './PageSizeSelector';\nimport type { PaginationParams } from './types';\n\n// NB: this is configured in config/initializers/kaminari.rb\nconst MAX_PAGES = 100;\n\nconst Container = styled('nav')`\n ${Typography.TextMedium};\n display: flex;\n align-items: center;\n justify-content: space-between;\n`;\n\nexport const PaginationInfo = styled('div')`\n display: flex;\n align-items: center;\n\n color: ${({ theme }) => semanticColor(theme, 'FgPrimary', Color.TextPrimary)};\n`;\n\ninterface PaginationProps {\n pageSize?: number;\n pageSizeOptions?: number[];\n paginationParams?: PaginationParams;\n handlePageSizeClick: (pageSize: number) => void;\n handlePageLinkClick: (pageNumber: number) => void;\n isLoading?: boolean;\n showPageSizeSelector?: boolean;\n /**\n * Called with the new page number after the page changes. Lets the consumer\n * react to page changes -- e.g. scroll the page back to the top.\n */\n onPageChange?: (pageNumber: number) => void;\n /**\n * Element the page-size menu renders into. Pass a container inside the surrounding dialog when\n * the pager sits in a clipping container, where the menu would otherwise be cut off.\n */\n menuPortalContainer?: HTMLElement | null;\n /**\n * The totals in `paginationParams` are only a lower bound: there are at least that many items\n * and pages, e.g. when the server counts a bounded number of pages ahead. They render as `650+`\n * and `13+`, any page up to `total-pages` can still be typed in, and Next stays enabled past it.\n * `lower-bound` in `paginationParams`, a total that is not known at all, takes precedence.\n */\n totalIsLowerBound?: boolean;\n}\n\nconst Pagination = ({\n pageSize,\n pageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS,\n paginationParams,\n handlePageSizeClick,\n handlePageLinkClick,\n isLoading,\n showPageSizeSelector = true,\n onPageChange,\n menuPortalContainer,\n totalIsLowerBound = false,\n}: PaginationProps) => {\n const strings = usePDSStrings();\n\n if (!paginationParams || !pageSize) {\n return <div />;\n }\n\n const {\n 'current-page': currentPage,\n 'total-count': totalCount,\n 'total-pages': totalPages,\n 'lower-bound': lowerBound,\n } = paginationParams;\n\n // If the total number of pages is the same as MAX_PAGES, we guess that the total number of\n // items might be limited by max pages, and that the total could change based on page size.\n // To limit user confusion here, we use 'many' instead of a specific number.\n // Paged past the minimum the totals give, how many there are is no longer known: render it like\n // `lower-bound` rather than an item range that ends before it starts.\n const pastKnownTotal = totalIsLowerBound && !lowerBound && currentPage > totalPages;\n const totalUnknown = lowerBound || pastKnownTotal;\n const totalAtLeast = totalIsLowerBound && !totalUnknown;\n const totalCountDisplay =\n totalUnknown || totalPages >= MAX_PAGES\n ? strings.many\n : totalAtLeast\n ? strings.atLeast(totalCount)\n : totalCount;\n\n const lastItemIndex = totalUnknown\n ? currentPage * pageSize\n : Math.min(currentPage * pageSize, totalCount);\n const firstItemIndex = pageSize * (currentPage - 1) + 1;\n\n return (\n <Container role='navigation' aria-label={strings.pagination}>\n {showPageSizeSelector && (\n <PageSizeSelector\n pageSize={pageSize}\n pageSizeOptions={pageSizeOptions}\n handlePageSizeClick={handlePageSizeClick}\n menuPortalContainer={menuPortalContainer}\n />\n )}\n {totalCount > 0 && (\n <>\n <div>{strings.showingItems(firstItemIndex, lastItemIndex, totalCountDisplay)}</div>\n <PaginationInfo>\n <PageSelector\n paginationParams={paginationParams}\n handlePageLinkClick={handlePageLinkClick}\n isLoading={isLoading}\n onPageChange={onPageChange}\n totalIsLowerBound={totalIsLowerBound && !lowerBound}\n />\n </PaginationInfo>\n </>\n )}\n </Container>\n );\n};\n\nexport default Pagination;\n","import Pagination from './Pagination';\n\nexport { default as PageSelector, PAGE_LIMIT_BEFORE_SCROLL_MODE } from './PageSelector';\nexport * from './constants';\nexport default Pagination;\n"],"mappings":";;;;;;;;;;;;AAAA,MAAa,4BAA4B;CAAC;CAAI;CAAI;CAAI;CAAK;CAAI;AAC/D,MAAa,gBAAgB;;;ACgB7B,MAAa,gCAAgC;AAE7C,MAAM,oBAAoB,OAAO,OAAO,CAAC,MAAM,EAAE,SAAS,YAAY,CAAC;aAC1D,QAAQ,GAAG;;AAGxB,MAAa,YAAY,OAAO,OAAO,CAAC,MAAM,EAAE,OAAO,UAAU,CAAC;;;AAqBlE,SAAwB,aAAa,EACnC,kBACA,qBACA,WACA,cACA,oBAAoB,SACA;CACpB,MAAM,UAAU,eAAe;CAC/B,MAAM,EACJ,gBAAgB,aAChB,eAAe,YACf,eAAe,eACb,oBAAoB,EAAE;CAC1B,MAAM,CAAC,cAAc,mBAAmB,SAA6B,YAAY;CAEjF,MAAM,qBAAqB,cAAc;CAEzC,MAAM,eAAe,cAAe,qBAAqB,cAAc;CAGvE,MAAM,+BAA+B,cAC7B,SAAS,qBAAqB,IAAI,EACxC,CAAC,oBAAoB,CACtB;AAID,iBAAgB;AACd,MAAI,eAAe,KACjB,iBAAgB,YAAY;IAE7B,CAAC,YAAY,CAAC;AAEjB,KAAI,CAAC,iBACH,QAAO,oBAAC,OAAD,EAAO,CAAA;AAGhB,QACE,qBAAC,mBAAD;EAAmB,aAAU;EAA4B,IAAG;YAA5D;GACE,qBAAC,WAAD,EAAA,UAAA,CACG,cAAA,OAA+C,CAAC,eAC/C,oBAAC,OAAD;IACE,cAAY,QAAQ;IACpB,MAAK;IACL,WAAW;IACX,WAAW,MAAM;KACf,MAAM,QAAQ,EAAE,OAAO;AACvB,SAAI,OAAO,MAA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qB,CAAC,eAKnC,QAAQ,QAAQ,WAAW,GAC3B;CAER,MAAM,gBAAgB,eAClB,cAAc,WACd,KAAK,IAAI,cAAc,UAAU,WAAW;CAChD,MAAM,iBAAiB,YAAY,cAAc,KAAK;AAEtD,QACE,qBAAC,WAAD;EAAW,MAAK;EAAa,cAAY,QAAQ;YAAjD,CACG,wBACC,oBAAC,kBAAD;GACY;GACO;GACI;GACA;GACrB,CAAA,EAEH,aAAa,KACZ,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,OAAD,EAAA,UAAM,QAAQ,aAAa,gBAAgB,eAAe,kBAAkB,EAAO,CAAA,EACnF,oBAAC,gBAAD,EAAA,UACE,oBAAC,cAAD;GACoB;GACG;GACV;GACG;GACd,mBAAmB,qBAAqB,CAAC;GACzC,CAAA,EACa,CAAA,CAChB,EAAA,CAAA,CAEK;;;;;ACzHhB,IAAA,qBAAe"}
|
|
1
|
+
{"version":3,"file":"Pagination-DMH2IaV0.mjs","names":[],"sources":["../src/components/Pagination/constants.ts","../src/components/Pagination/PageSelector.tsx","../src/components/Pagination/PageSizeSelector.tsx","../src/components/Pagination/Pagination.tsx","../src/components/Pagination/index.ts"],"sourcesContent":["export const DEFAULT_PAGE_SIZE_OPTIONS = [10, 25, 50, 100, 300];\nexport const MIN_PAGE_SIZE = 10;\n","import { debounce } from 'lodash-es';\nimport { useEffect, useMemo, useState } from 'react';\nimport styled from 'styled-components';\n\nimport Button from '@persona/design-system/components/Button';\nimport { Input } from '@persona/design-system/components/Input';\nimport { HStack } from '@persona/design-system/components/Stack';\nimport { Spacing } from '@persona/design-tokens';\n\nimport { usePDSStrings } from '#src/lib/i18n';\n\nimport type { PaginationParams } from './types';\n\n// After a certain limit, it no longer makes sense for someone\n// to jump to the last page. Deep paging has performance limitations. A collection\n// with exactly this many pages still gets the page input: servers that cap paging\n// at this limit (Kaminari's max_pages) report every page up to it as reachable.\nexport const PAGE_LIMIT_BEFORE_SCROLL_MODE = 100;\n\nconst PageSelectorStack = styled(HStack).attrs({ justify: 'flex-end' })`\n padding: ${Spacing[2]};\n`;\n\nexport const PageInput = styled(HStack).attrs({ align: 'center' })`\n white-space: nowrap;\n`;\n\ninterface PageSelectorProps {\n paginationParams: PaginationParams;\n handlePageLinkClick: (pageNumber: number) => void;\n isLoading?: boolean;\n /**\n * Called with the new page number after the page changes (next, prev, or\n * typed input). Lets the consumer react to page changes -- e.g. scroll the\n * page back to the top.\n */\n onPageChange?: (pageNumber: number) => void;\n /**\n * `total-pages` is only a lower bound: render it as `13+` and keep Next enabled past it. See\n * `Pagination`'s prop of the same name.\n */\n totalIsLowerBound?: boolean;\n}\n\nexport default function PageSelector({\n paginationParams,\n handlePageLinkClick,\n isLoading,\n onPageChange,\n totalIsLowerBound = false,\n}: PageSelectorProps) {\n const strings = usePDSStrings();\n const {\n 'current-page': currentPage,\n 'total-pages': totalPages,\n 'lower-bound': lowerBound,\n } = paginationParams ?? {};\n const [selectedPage, setSelectedPage] = useState<number | undefined>(currentPage);\n // Next stays enabled at the last page the totals know of when more may follow.\n const morePagesMayFollow = lowerBound || totalIsLowerBound;\n // Paged past a minimum page count, how many pages there are is no longer known.\n const totalUnknown = lowerBound || (totalIsLowerBound && currentPage > totalPages);\n\n // We don't use useDebounced to avoid function object reference issues.\n const handlePageLinkClickDebounced = useMemo(\n () => debounce(handlePageLinkClick, 500),\n [handlePageLinkClick],\n );\n\n // Keep input state synced to pagination state when other user action changes\n // pagination state.\n useEffect(() => {\n if (currentPage != null) {\n setSelectedPage(currentPage);\n }\n }, [currentPage]);\n\n if (!paginationParams) {\n return <div />;\n }\n\n return (\n <PageSelectorStack data-test='pagination__page-selector' id='pagination__page-selector'>\n <PageInput>\n {totalPages <= PAGE_LIMIT_BEFORE_SCROLL_MODE && !totalUnknown ? (\n <Input\n aria-label={strings.goToPageNumber}\n size='sm'\n inputSize={2}\n onChange={(e) => {\n const value = e.target.valueAsNumber;\n if (Number.isNaN(value)) {\n setSelectedPage(undefined);\n } else {\n // Setting unbounded value feels smoother as the value is not corrected until after the fetch via useEffect.\n setSelectedPage(value);\n const boundedValue = Math.min(Math.max(e.target.valueAsNumber, 1), totalPages);\n handlePageLinkClickDebounced(boundedValue);\n onPageChange?.(boundedValue);\n }\n }}\n onBlur={(e) => {\n // Fill blank value on blur.\n if (Number.isNaN(e.target.valueAsNumber)) {\n setSelectedPage(currentPage);\n }\n }}\n min={1}\n max={totalPages}\n type='number'\n disabled={isLoading}\n value={selectedPage ?? ''}\n />\n ) : (\n currentPage + ' '\n )}\n {strings.pageCount(\n currentPage,\n totalUnknown\n ? strings.many\n : totalIsLowerBound\n ? strings.atLeast(totalPages)\n : totalPages,\n )}\n </PageInput>\n <Button\n id='pagination__page-selector--left'\n disabled={currentPage === 1 || isLoading}\n onClick={() => {\n if (currentPage !== 1) {\n const prevPageNum = currentPage - 1;\n setSelectedPage(prevPageNum);\n handlePageLinkClick(prevPageNum);\n onPageChange?.(prevPageNum);\n }\n }}\n data-test='pagination__page-selector-paddle-left'\n variant='inverse'\n size='sm'\n width='auto'\n aria-label={strings.previousPage}\n >\n {strings.previousShort}\n </Button>\n <Button\n id='pagination__page-selector--right'\n disabled={(currentPage === totalPages && !morePagesMayFollow) || isLoading}\n onClick={() => {\n if (currentPage !== totalPages || morePagesMayFollow) {\n const nextPageNum = currentPage + 1;\n setSelectedPage(nextPageNum);\n handlePageLinkClick(nextPageNum);\n onPageChange?.(nextPageNum);\n }\n }}\n data-test='pagination__page-selector-paddle-right'\n variant='inverse'\n size='sm'\n width='auto'\n aria-label={strings.nextPage}\n >\n {strings.next}\n </Button>\n </PageSelectorStack>\n );\n}\n","import styled from 'styled-components';\n\nimport Select, { Option } from '@persona/design-system/components/Select';\nimport { Color, Spacing, Typography } from '@persona/design-tokens';\n\nimport { usePDSStrings } from '#src/lib/i18n';\nimport { semanticColor } from '#src/lib/semanticColor';\n\nconst Selector = styled('div')`\n padding: ${Spacing[2]};\n display: flex;\n justify-content: flex-end;\n`;\n\nconst Label = styled.label`\n display: flex;\n align-items: center;\n white-space: nowrap;\n gap: ${Spacing[2]};\n padding: ${Spacing[2]};\n`;\n\ninterface PageSizeOptionProps {\n currentPageSize: number;\n pageSizeOption: number;\n}\n\nexport const PageSizeOption = styled('div')<PageSizeOptionProps>`\n padding: 0 ${Spacing[1]};\n color: ${({ theme }) => semanticColor(theme, 'FgAccentStatic', Color.PrimaryPurple)};\n cursor: pointer;\n\n ${({ currentPageSize, pageSizeOption }) => {\n if (currentPageSize === pageSizeOption) {\n return `\n ${Typography.TextMediumBold};\n text-decoration: underline;\n `;\n }\n }};\n\n &:hover {\n text-decoration: underline;\n }\n`;\n\ninterface PageSizeSelectorProps {\n pageSize: number;\n pageSizeOptions: number[];\n handlePageSizeClick: (pageSize: number) => void;\n /**\n * Element the options menu renders into. Pass a container inside the surrounding dialog when the\n * pager sits in a clipping container, where the menu would otherwise be cut off.\n */\n menuPortalContainer?: HTMLElement | null;\n}\n\nconst PageSizeSelector = ({\n pageSize,\n pageSizeOptions,\n handlePageSizeClick,\n menuPortalContainer,\n}: PageSizeSelectorProps) => {\n const strings = usePDSStrings();\n // Add pageSize to selector just in case it isn't part of the options so UI doesn't look weird\n const pageSizes = [\n ...pageSizeOptions,\n ...(pageSizeOptions.includes(pageSize) ? [] : [pageSize]),\n ].sort((a, b) => a - b);\n\n return (\n <Selector data-test='pagination__page-size-selector'>\n <Label>\n {strings.itemsPerPage}\n <Select\n value={pageSize.toString()}\n onValueChange={(val) => handlePageSizeClick(Number(val))}\n size='sm'\n portal={menuPortalContainer != null}\n portalContainer={menuPortalContainer}\n >\n {pageSizes.map((size) => (\n <Option key={size} value={size.toString()}>\n {size}\n </Option>\n ))}\n </Select>\n </Label>\n </Selector>\n );\n};\n\nexport default PageSizeSelector;\n","import styled from 'styled-components';\n\nimport { Color, Typography } from '@persona/design-tokens';\n\nimport { usePDSStrings } from '#src/lib/i18n';\nimport { semanticColor } from '#src/lib/semanticColor';\n\nimport { DEFAULT_PAGE_SIZE_OPTIONS } from './constants';\nimport PageSelector from './PageSelector';\nimport PageSizeSelector from './PageSizeSelector';\nimport type { PaginationParams } from './types';\n\n// NB: this is configured in config/initializers/kaminari.rb\nconst MAX_PAGES = 100;\n\nconst Container = styled('nav')`\n ${Typography.TextMedium};\n display: flex;\n align-items: center;\n justify-content: space-between;\n`;\n\nexport const PaginationInfo = styled('div')`\n display: flex;\n align-items: center;\n\n color: ${({ theme }) => semanticColor(theme, 'FgPrimary', Color.TextPrimary)};\n`;\n\ninterface PaginationProps {\n pageSize?: number;\n pageSizeOptions?: number[];\n paginationParams?: PaginationParams;\n handlePageSizeClick: (pageSize: number) => void;\n handlePageLinkClick: (pageNumber: number) => void;\n isLoading?: boolean;\n showPageSizeSelector?: boolean;\n /**\n * Called with the new page number after the page changes. Lets the consumer\n * react to page changes -- e.g. scroll the page back to the top.\n */\n onPageChange?: (pageNumber: number) => void;\n /**\n * Element the page-size menu renders into. Pass a container inside the surrounding dialog when\n * the pager sits in a clipping container, where the menu would otherwise be cut off.\n */\n menuPortalContainer?: HTMLElement | null;\n /**\n * The totals in `paginationParams` are only a lower bound: there are at least that many items\n * and pages, e.g. when the server counts a bounded number of pages ahead. They render as `650+`\n * and `13+`, any page up to `total-pages` can still be typed in, and Next stays enabled past it.\n * `lower-bound` in `paginationParams`, a total that is not known at all, takes precedence.\n */\n totalIsLowerBound?: boolean;\n}\n\nconst Pagination = ({\n pageSize,\n pageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS,\n paginationParams,\n handlePageSizeClick,\n handlePageLinkClick,\n isLoading,\n showPageSizeSelector = true,\n onPageChange,\n menuPortalContainer,\n totalIsLowerBound = false,\n}: PaginationProps) => {\n const strings = usePDSStrings();\n\n if (!paginationParams || !pageSize) {\n return <div />;\n }\n\n const {\n 'current-page': currentPage,\n 'total-count': totalCount,\n 'total-pages': totalPages,\n 'lower-bound': lowerBound,\n } = paginationParams;\n\n // If the total number of pages is the same as MAX_PAGES, we guess that the total number of\n // items might be limited by max pages, and that the total could change based on page size.\n // To limit user confusion here, we use 'many' instead of a specific number.\n // Paged past the minimum the totals give, how many there are is no longer known: render it like\n // `lower-bound` rather than an item range that ends before it starts.\n const pastKnownTotal = totalIsLowerBound && !lowerBound && currentPage > totalPages;\n const totalUnknown = lowerBound || pastKnownTotal;\n const totalAtLeast = totalIsLowerBound && !totalUnknown;\n const totalCountDisplay =\n totalUnknown || totalPages >= MAX_PAGES\n ? strings.many\n : totalAtLeast\n ? strings.atLeast(totalCount)\n : totalCount;\n\n const lastItemIndex = totalUnknown\n ? currentPage * pageSize\n : Math.min(currentPage * pageSize, totalCount);\n const firstItemIndex = pageSize * (currentPage - 1) + 1;\n\n return (\n <Container role='navigation' aria-label={strings.pagination}>\n {showPageSizeSelector && (\n <PageSizeSelector\n pageSize={pageSize}\n pageSizeOptions={pageSizeOptions}\n handlePageSizeClick={handlePageSizeClick}\n menuPortalContainer={menuPortalContainer}\n />\n )}\n {totalCount > 0 && (\n <>\n <div>{strings.showingItems(firstItemIndex, lastItemIndex, totalCountDisplay)}</div>\n <PaginationInfo>\n <PageSelector\n paginationParams={paginationParams}\n handlePageLinkClick={handlePageLinkClick}\n isLoading={isLoading}\n onPageChange={onPageChange}\n totalIsLowerBound={totalIsLowerBound && !lowerBound}\n />\n </PaginationInfo>\n </>\n )}\n </Container>\n );\n};\n\nexport default Pagination;\n","import Pagination from './Pagination';\n\nexport { default as PageSelector, PAGE_LIMIT_BEFORE_SCROLL_MODE } from './PageSelector';\nexport * from './constants';\nexport default Pagination;\n"],"mappings":";;;;;;;;;;;;AAAA,MAAa,4BAA4B;CAAC;CAAI;CAAI;CAAI;CAAK;CAAI;AAC/D,MAAa,gBAAgB;;;ACgB7B,MAAa,gCAAgC;AAE7C,MAAM,oBAAoB,OAAO,OAAO,CAAC,MAAM,EAAE,SAAS,YAAY,CAAC;aAC1D,QAAQ,GAAG;;AAGxB,MAAa,YAAY,OAAO,OAAO,CAAC,MAAM,EAAE,OAAO,UAAU,CAAC;;;AA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,EAAA,CAAA,CAEK;;;;;ACzHhB,IAAA,qBAAe"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as Sticker } from "./Sticker-
|
|
1
|
+
import { n as Sticker } from "./Sticker-C1_6I08u.mjs";
|
|
2
2
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
3
3
|
//#region src/components/Pii/Pii.tsx
|
|
4
4
|
const Pii = ({ children, isRedacted, hideOnRedacted }) => {
|
|
@@ -16,4 +16,4 @@ var Pii_default = Pii;
|
|
|
16
16
|
//#endregion
|
|
17
17
|
export { Pii_default as t };
|
|
18
18
|
|
|
19
|
-
//# sourceMappingURL=Pii-
|
|
19
|
+
//# sourceMappingURL=Pii-24D_nSRQ.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pii-
|
|
1
|
+
{"version":3,"file":"Pii-24D_nSRQ.mjs","names":[],"sources":["../src/components/Pii/Pii.tsx","../src/components/Pii/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport Sticker from '@persona/design-system/components/Sticker';\n\ninterface PiiProps {\n children?: ReactNode;\n isRedacted: boolean;\n hideOnRedacted?: boolean;\n}\n\nconst Pii = ({ children, isRedacted, hideOnRedacted }: PiiProps) => {\n if (isRedacted) {\n return hideOnRedacted ? null : <Sticker data-test='pii__redacted'>Redacted</Sticker>;\n }\n\n if (children == null || children === '') {\n return null;\n }\n\n // There used to be code inserting a classname here in certain cases. There's\n // no other reason for this to be conditionally wrapped in a span, but\n // removing it breaks a lot of tests. Someday, the tests will be fixed...\n // hopefully.\n if (['string', 'number'].includes(typeof children)) {\n return <span>{children}</span>;\n }\n\n return <>{children}</>;\n};\n\nexport default Pii;\n","import Pii from './Pii';\n\nexport default Pii;\n"],"mappings":";;;AAUA,MAAM,OAAO,EAAE,UAAU,YAAY,qBAA+B;AAClE,KAAI,WACF,QAAO,iBAAiB,OAAO,oBAAC,SAAD;EAAS,aAAU;YAAgB;EAAkB,CAAA;AAGtF,KAAI,YAAY,QAAQ,aAAa,GACnC,QAAO;AAOT,KAAI,CAAC,UAAU,SAAS,CAAC,SAAS,OAAO,SAAS,CAChD,QAAO,oBAAC,QAAD,EAAO,UAAgB,CAAA;AAGhC,QAAO,oBAAA,UAAA,EAAG,UAAY,CAAA;;;;ACzBxB,IAAA,cAAe"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as MenuItemProps } from "./Menu-
|
|
1
|
+
import { l as MenuItemProps } from "./Menu-D6OrKCTC.mjs";
|
|
2
2
|
import { n as InputSizes, t as InputMixinProps } from "./input-JDU1Goyr.mjs";
|
|
3
3
|
import * as _$react from "react";
|
|
4
4
|
import { ReactNode } from "react";
|
|
@@ -80,4 +80,4 @@ declare const Select: _$react.ForwardRefExoticComponent<SelectProps & _$react.Re
|
|
|
80
80
|
declare const Option: _$react.ForwardRefExoticComponent<SelectPrimitive.SelectItemProps & MenuItemProps<"div"> & _$react.RefAttributes<HTMLDivElement>>;
|
|
81
81
|
//#endregion
|
|
82
82
|
export { SelectProps as i, Select as n, SelectHeader as r, Option as t };
|
|
83
|
-
//# sourceMappingURL=Select-
|
|
83
|
+
//# sourceMappingURL=Select-CR9TjFfo.d.mts.map
|
|
@@ -7,10 +7,10 @@ import { Z_INDICES } from "./lib/zindex.mjs";
|
|
|
7
7
|
import inputMixin from "./mixins/input.mjs";
|
|
8
8
|
import { semanticScrollbar } from "./mixins/scrollbar.mjs";
|
|
9
9
|
import { t as HStack } from "./Stack-Bzom2BTR.mjs";
|
|
10
|
-
import { t as IconButton } from "./IconButton-
|
|
10
|
+
import { t as IconButton } from "./IconButton-DxHB2g80.mjs";
|
|
11
11
|
import { n as useFormField } from "./useFormField-pOVkb5BK.mjs";
|
|
12
|
-
import { c as MenuList, i as Menu, o as MenuHeading, s as MenuItem } from "./Menu-
|
|
13
|
-
import { n as DropdownMenu_default } from "./DropdownMenu-
|
|
12
|
+
import { c as MenuList, i as Menu, o as MenuHeading, s as MenuItem } from "./Menu-BVn1jh46.mjs";
|
|
13
|
+
import { n as DropdownMenu_default } from "./DropdownMenu-c8XK2Lr4.mjs";
|
|
14
14
|
import { forwardRef } from "react";
|
|
15
15
|
import { Color, Spacing } from "@persona/design-tokens";
|
|
16
16
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -244,4 +244,4 @@ const Option = forwardRef(function Option({ children, subtitle, ...props }, forw
|
|
|
244
244
|
//#endregion
|
|
245
245
|
export { Select as n, SelectHeader as r, Option as t };
|
|
246
246
|
|
|
247
|
-
//# sourceMappingURL=Select-
|
|
247
|
+
//# sourceMappingURL=Select-DOlw_LPR.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select-DkUMz4LG.mjs","names":["DropdownMenu"],"sources":["../src/components/Select/Select.tsx"],"sourcesContent":["import * as SelectPrimitive from '@radix-ui/react-select';\nimport type { Property } from 'csstype';\nimport { forwardRef, type ReactNode } from 'react';\nimport { useId } from 'react-aria';\nimport styled, { css } from 'styled-components';\n\nimport { Color, Spacing } from '@persona/design-tokens';\nimport { CaretDownIcon, MoreIcon } from '@persona/icons';\n\nimport { IconButton } from '#src/components/Button';\nimport DropdownMenu from '#src/components/DropdownMenu';\nimport useFormField from '#src/components/FormControl/useFormField';\nimport Menu, {\n MenuHeading,\n MenuItem,\n type MenuItemProps,\n MenuList,\n type MenuProps,\n} from '#src/components/Menu';\nimport { HStack } from '#src/components/Stack';\nimport { Paragraph } from '#src/components/Text';\nimport { isNotDisabled } from '#src/lib/pseudoClass';\nimport { semanticColor } from '#src/lib/semanticColor';\nimport { Z_INDICES } from '#src/lib/zindex';\nimport inputMixin, { type InputMixinProps, type InputSizes } from '#src/mixins/input';\nimport { semanticScrollbar } from '#src/mixins/scrollbar';\nimport { paragraphMixins } from '#src/mixins/text';\n\nexport interface SelectProps extends InputMixinProps, Omit<SelectPrimitive.SelectProps, 'value'> {\n 'aria-label'?: string;\n placeholder?: string;\n\n /**\n * id will be applied to trigger\n */\n id?: string;\n\n /**\n * Class name will be applied to trigger\n */\n className?: string;\n\n /**\n * Max height of options menu\n */\n maxHeight?: number;\n\n /**\n * Min width of the select\n */\n minWidth?: number;\n\n /**\n * Width of the selected value container\n */\n valueContainerWidth?: 'auto' | '100%';\n\n /**\n * Render dropdown menu in a portal.\n */\n portal?: boolean;\n\n /**\n * Element the portalled menu renders into. Defaults to `document.body`. Pass a container inside\n * the current dialog so the menu escapes clipping ancestors without leaving the dialog's\n * dismiss scope, which would close it on click. Requires `portal`.\n */\n portalContainer?: HTMLElement | null;\n\n /**\n * Props to apply to Radix Select.Trigger within\n */\n triggerProps?: SelectPrimitive.SelectTriggerProps;\n\n /**\n * Props to apply to Radix Select.Content within\n */\n contentProps?: SelectPrimitive.SelectContentProps;\n\n /**\n * Callback meant for use with `react-hook-form`'s `useForm` (or Persona's `useFormSecurely`)\n */\n onChange?: (event: { target: { value: string } }) => void;\n\n size?: InputSizes;\n\n value?: string | null;\n\n width?: string;\n\n header?: ReactNode;\n\n footer?: ReactNode;\n\n /**\n * z-index of content. Please use sparingly.\n */\n zIndex?: Property.ZIndex;\n}\n\ninterface SelectButtonProps extends InputMixinProps {\n isSelectingPlaceholder: boolean;\n $width?: string;\n $minWidth?: number;\n}\n\nconst SelectButton = styled('button')<SelectButtonProps>`\n ${inputMixin};\n display: inline-flex;\n position: relative;\n align-items: center;\n outline: none;\n appearance: none;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n padding-right: ${Spacing[6]};\n width: ${({ $width }) => $width ?? '100%'};\n min-width: ${({ $minWidth }) => ($minWidth != null ? `${$minWidth}px` : 'auto')};\n\n &${isNotDisabled} {\n cursor: pointer;\n }\n\n ${({ theme, isSelectingPlaceholder, disabled }) =>\n isSelectingPlaceholder &&\n !disabled &&\n css`\n color: ${semanticColor(theme, 'FgSecondary', theme.color.text.secondary)};\n `}\n`;\n\ninterface SelectValueContainerProps {\n width?: string;\n}\n\nconst SelectValueContainer = styled.span<SelectValueContainerProps>`\n text-overflow: ellipsis;\n min-width: 0px;\n overflow: hidden;\n text-align: start;\n\n ${({ width }) =>\n width &&\n css`\n width: ${width};\n `}\n`;\n\nconst OptionSubtitle = styled.div`\n color: ${({ theme }) => semanticColor(theme, 'FgSecondary', theme.color.text.secondary)};\n font-size: ${({ theme }) => theme.text.paragraph.sm.fontSize};\n margin-top: ${Spacing[1]};\n`;\n\ninterface OptionsMenuProps {\n maxHeight?: number;\n size?: InputSizes;\n}\n\nconst OptionsMenu = styled(Menu)<OptionsMenuProps>`\n width: var(--radix-select-trigger-width);\n max-height: ${({ maxHeight }) => maxHeight ?? '225px !important'};\n overflow-y: auto;\n ${semanticScrollbar}\n margin-bottom: 0;\n\n ${({ size }) => {\n switch (size) {\n case 'md': {\n return css`\n ${MenuList} {\n padding: ${Spacing[2]};\n }\n\n ${OptionItem} {\n ${paragraphMixins.md};\n padding: ${Spacing[2]};\n }\n\n ${MenuHeading} {\n padding: ${Spacing[2]};\n }\n `;\n }\n case 'sm': {\n return css`\n ${MenuList} {\n padding: ${Spacing[1]};\n }\n\n ${OptionItem} {\n ${paragraphMixins.sm};\n padding: ${Spacing[1]};\n }\n\n ${MenuHeading} {\n padding: ${Spacing[1]};\n }\n `;\n }\n }\n }}\n`;\n\nconst SelectContent = styled(SelectPrimitive.Content)<{ $zIndex?: number | string }>`\n z-index: ${({ $zIndex }) => $zIndex || Z_INDICES.dropdown};\n`;\n\nconst SelectHeaderContainer = styled(HStack)`\n display: flex;\n justify-content: space-between;\n padding: ${Spacing[1]} ${Spacing[1]} 0 ${Spacing[1]};\n margin-bottom: ${Spacing[1]};\n`;\n\nconst SelectFooter = styled.div`\n padding: ${Spacing[1]} 0;\n margin-top: ${Spacing[1]};\n border-top: 1px solid ${({ theme }) => semanticColor(theme, 'BorderSubtle', Color.BorderDivider)};\n`;\n\nconst SelectMenu = forwardRef<HTMLUListElement, MenuProps & OptionsMenuProps>(function SelectMenu(\n props: MenuProps,\n forwardedRef,\n) {\n return <OptionsMenu listRef={forwardedRef} {...props} />;\n});\n\nconst OptionItem = styled(MenuItem)`\n ${paragraphMixins.md};\n padding: ${Spacing[4]};\n`;\n\nconst SelectItem = forwardRef<HTMLDivElement, MenuItemProps>(function SelectItem(\n props: MenuItemProps,\n forwardedRef,\n) {\n return <OptionItem ref={forwardedRef} {...props} />;\n});\n\nconst StyledIconContainer = styled(SelectPrimitive.Icon)<{ disabled?: boolean }>`\n position: absolute;\n right: ${Spacing[2]};\n display: flex;\n justify-content: center;\n\n ${({ theme, disabled }) => css`\n color: ${\n disabled\n ? semanticColor(theme, 'FgDisabled', Color.BorderIconDisabled)\n : semanticColor(theme, 'FgPrimary', Color.BorderIconPrimary)\n };\n `}\n`;\n\ninterface SelectHeaderProps {\n title?: ReactNode;\n menuItems?: ReactNode;\n menuTriggerLabel?: string;\n}\n\nexport const SelectHeader = ({ title, menuItems, menuTriggerLabel }: SelectHeaderProps) => {\n const uniqueId = useId();\n\n return (\n <SelectHeaderContainer align='center'>\n {title && (\n <Paragraph color='primary' weight='bold' size='md'>\n {title}\n </Paragraph>\n )}\n {menuItems && (\n <DropdownMenu\n portal={true}\n trigger={\n <IconButton>\n <MoreIcon />\n </IconButton>\n }\n triggerProps={{\n 'aria-label': menuTriggerLabel,\n id: `select-header-menu-trigger-${uniqueId}`,\n }}\n side='right'\n align='start'\n zIndex={Z_INDICES.layeredDropdown}\n contentProps={{\n // Fix for Radix UI 2.1.15 upgrade breaking changes:\n // 1. Portal rendering causes pointer-events issues preventing dropdown interaction\n // 2. Portal timing causes onFocusOutside to fire immediately, closing dropdown\n style: {\n pointerEvents: 'auto', // Ensure dropdown items receive mouse events\n },\n onFocusOutside: (event) => event.preventDefault(), // Prevent immediate portal closing\n }}\n >\n {menuItems}\n </DropdownMenu>\n )}\n </SelectHeaderContainer>\n );\n};\n\nexport const Select = forwardRef<HTMLButtonElement, SelectProps>(function Select(\n { portal = false, portalContainer, size = 'md', ...props }: SelectProps,\n forwardedRef,\n) {\n const {\n 'aria-label': ariaLabel,\n hasError,\n hasWarning,\n focused,\n active,\n hovered,\n disabled,\n placeholder,\n maxHeight,\n children,\n triggerProps,\n contentProps,\n id,\n className,\n onChange,\n onValueChange,\n value,\n width,\n header,\n footer,\n minWidth,\n valueContainerWidth,\n zIndex,\n } = props;\n\n const field = useFormField({ inputId: props.id, disabled, hasWarning, hasError });\n\n const content = (\n <SelectContent\n position='popper'\n side='bottom'\n sideOffset={8}\n $zIndex={zIndex}\n {...contentProps}\n >\n <SelectMenu maxHeight={maxHeight} size={size}>\n {header}\n <SelectPrimitive.Viewport>{children}</SelectPrimitive.Viewport>\n {footer && (\n <>\n <SelectFooter>{footer}</SelectFooter>\n </>\n )}\n </SelectMenu>\n </SelectContent>\n );\n\n return (\n <SelectPrimitive.Root\n {...props}\n onValueChange={(value) => {\n onChange?.({ target: { value } });\n onValueChange?.(value);\n }}\n // Custom behavior to consider null as empty value\n value={value === null ? '' : value}\n >\n <SelectPrimitive.Trigger\n ref={forwardedRef}\n asChild\n id={id}\n className={className}\n disabled={field.disabled}\n aria-describedby={field.helperTextId}\n aria-errormessage={field.hasError ? field.helperTextId : undefined}\n aria-invalid={field.hasError}\n aria-label={ariaLabel}\n {...triggerProps}\n >\n <SelectButton\n hasWarning={field.hasWarning}\n hasError={field.hasError}\n hovered={hovered}\n focused={focused}\n active={active}\n disabled={field.disabled}\n placeholder={placeholder}\n isSelectingPlaceholder={props.value === '' || props.value == null}\n $minWidth={minWidth}\n $size={size}\n $width={width}\n >\n <SelectValueContainer width={valueContainerWidth}>\n <SelectPrimitive.Value placeholder={placeholder} />\n </SelectValueContainer>\n <StyledIconContainer disabled={field.disabled}>\n <CaretDownIcon />\n </StyledIconContainer>\n </SelectButton>\n </SelectPrimitive.Trigger>\n {portal ? (\n <SelectPrimitive.Portal container={portalContainer}>{content}</SelectPrimitive.Portal>\n ) : (\n content\n )}\n </SelectPrimitive.Root>\n );\n});\n\nexport default Select;\n\nexport const Option = forwardRef<HTMLDivElement, SelectPrimitive.SelectItemProps & MenuItemProps>(\n function Option({ children, subtitle, ...props }, forwardedRef) {\n return (\n <SelectPrimitive.Item {...props} ref={forwardedRef} asChild>\n <SelectItem {...props}>\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n {subtitle && <OptionSubtitle>{subtitle}</OptionSubtitle>}\n </SelectItem>\n </SelectPrimitive.Item>\n );\n },\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA0GA,MAAM,eAAe,OAAO,SAAS;IACjC,WAAW;;;;;;;;;mBASI,QAAQ,GAAG;YAClB,EAAE,aAAa,UAAU,OAAO;gBAC5B,EAAE,gBAAiB,aAAa,OAAO,GAAG,UAAU,MAAM,OAAQ;;KAE7E,cAAc;;;;KAId,EAAE,OAAO,wBAAwB,eAClC,0BACA,CAAC,YACD,GAAG;eACQ,cAAc,OAAO,eAAe,MAAM,MAAM,KAAK,UAAU,CAAC;MACzE;;AAON,MAAM,uBAAuB,OAAO,IAA+B;;;;;;KAM9D,EAAE,YACH,SACA,GAAG;eACQ,MAAM;MACf;;AAGN,MAAM,iBAAiB,OAAO,GAAG;YACrB,EAAE,YAAY,cAAc,OAAO,eAAe,MAAM,MAAM,KAAK,UAAU,CAAC;gBAC1E,EAAE,YAAY,MAAM,KAAK,UAAU,GAAG,SAAS;gBAC/C,QAAQ,GAAG;;AAQ3B,MAAM,cAAc,OAAO,KAAK;;iBAEf,EAAE,gBAAgB,aAAa,mBAAmB;;IAE/D,kBAAkB;;;KAGjB,EAAE,WAAW;AACd,SAAQ,MAAR;EACE,KAAK,KACH,QAAO,GAAG;YACN,SAAS;uBACE,QAAQ,GAAG;;;YAGtB,WAAW;cACT,gBAAgB,GAAG;uBACV,QAAQ,GAAG;;;YAGtB,YAAY;uBACD,QAAQ,GAAG;;;EAI5B,KAAK,KACH,QAAO,GAAG;YACN,SAAS;uBACE,QAAQ,GAAG;;;YAGtB,WAAW;cACT,gBAAgB,GAAG;uBACV,QAAQ,GAAG;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X,OAAO;IACP,QAAQ;cAXV,CAaE,oBAAC,sBAAD;KAAsB,OAAO;eAC3B,oBAAC,gBAAgB,OAAjB,EAAoC,aAAe,CAAA;KAC9B,CAAA,EACvB,oBAAC,qBAAD;KAAqB,UAAU,MAAM;eACnC,oBAAC,eAAD,EAAiB,CAAA;KACG,CAAA,CACT;;GACS,CAAA,EACzB,SACC,oBAAC,gBAAgB,QAAjB;GAAwB,WAAW;aAAkB;GAAiC,CAAA,GAEtF,QAEmB;;EAEzB;AAIF,MAAa,SAAS,WACpB,SAAS,OAAO,EAAE,UAAU,UAAU,GAAG,SAAS,cAAc;AAC9D,QACE,oBAAC,gBAAgB,MAAjB;EAAsB,GAAI;EAAO,KAAK;EAAc,SAAA;YAClD,qBAAC,YAAD;GAAY,GAAI;aAAhB,CACE,oBAAC,gBAAgB,UAAjB,EAA2B,UAAoC,CAAA,EAC9D,YAAY,oBAAC,gBAAD,EAAA,UAAiB,UAA0B,CAAA,CAC7C;;EACQ,CAAA;EAG5B"}
|
|
1
|
+
{"version":3,"file":"Select-DOlw_LPR.mjs","names":["DropdownMenu"],"sources":["../src/components/Select/Select.tsx"],"sourcesContent":["import * as SelectPrimitive from '@radix-ui/react-select';\nimport type { Property } from 'csstype';\nimport { forwardRef, type ReactNode } from 'react';\nimport { useId } from 'react-aria';\nimport styled, { css } from 'styled-components';\n\nimport { Color, Spacing } from '@persona/design-tokens';\nimport { CaretDownIcon, MoreIcon } from '@persona/icons';\n\nimport { IconButton } from '#src/components/Button';\nimport DropdownMenu from '#src/components/DropdownMenu';\nimport useFormField from '#src/components/FormControl/useFormField';\nimport Menu, {\n MenuHeading,\n MenuItem,\n type MenuItemProps,\n MenuList,\n type MenuProps,\n} from '#src/components/Menu';\nimport { HStack } from '#src/components/Stack';\nimport { Paragraph } from '#src/components/Text';\nimport { isNotDisabled } from '#src/lib/pseudoClass';\nimport { semanticColor } from '#src/lib/semanticColor';\nimport { Z_INDICES } from '#src/lib/zindex';\nimport inputMixin, { type InputMixinProps, type InputSizes } from '#src/mixins/input';\nimport { semanticScrollbar } from '#src/mixins/scrollbar';\nimport { paragraphMixins } from '#src/mixins/text';\n\nexport interface SelectProps extends InputMixinProps, Omit<SelectPrimitive.SelectProps, 'value'> {\n 'aria-label'?: string;\n placeholder?: string;\n\n /**\n * id will be applied to trigger\n */\n id?: string;\n\n /**\n * Class name will be applied to trigger\n */\n className?: string;\n\n /**\n * Max height of options menu\n */\n maxHeight?: number;\n\n /**\n * Min width of the select\n */\n minWidth?: number;\n\n /**\n * Width of the selected value container\n */\n valueContainerWidth?: 'auto' | '100%';\n\n /**\n * Render dropdown menu in a portal.\n */\n portal?: boolean;\n\n /**\n * Element the portalled menu renders into. Defaults to `document.body`. Pass a container inside\n * the current dialog so the menu escapes clipping ancestors without leaving the dialog's\n * dismiss scope, which would close it on click. Requires `portal`.\n */\n portalContainer?: HTMLElement | null;\n\n /**\n * Props to apply to Radix Select.Trigger within\n */\n triggerProps?: SelectPrimitive.SelectTriggerProps;\n\n /**\n * Props to apply to Radix Select.Content within\n */\n contentProps?: SelectPrimitive.SelectContentProps;\n\n /**\n * Callback meant for use with `react-hook-form`'s `useForm` (or Persona's `useFormSecurely`)\n */\n onChange?: (event: { target: { value: string } }) => void;\n\n size?: InputSizes;\n\n value?: string | null;\n\n width?: string;\n\n header?: ReactNode;\n\n footer?: ReactNode;\n\n /**\n * z-index of content. Please use sparingly.\n */\n zIndex?: Property.ZIndex;\n}\n\ninterface SelectButtonProps extends InputMixinProps {\n isSelectingPlaceholder: boolean;\n $width?: string;\n $minWidth?: number;\n}\n\nconst SelectButton = styled('button')<SelectButtonProps>`\n ${inputMixin};\n display: inline-flex;\n position: relative;\n align-items: center;\n outline: none;\n appearance: none;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n padding-right: ${Spacing[6]};\n width: ${({ $width }) => $width ?? '100%'};\n min-width: ${({ $minWidth }) => ($minWidth != null ? `${$minWidth}px` : 'auto')};\n\n &${isNotDisabled} {\n cursor: pointer;\n }\n\n ${({ theme, isSelectingPlaceholder, disabled }) =>\n isSelectingPlaceholder &&\n !disabled &&\n css`\n color: ${semanticColor(theme, 'FgSecondary', theme.color.text.secondary)};\n `}\n`;\n\ninterface SelectValueContainerProps {\n width?: string;\n}\n\nconst SelectValueContainer = styled.span<SelectValueContainerProps>`\n text-overflow: ellipsis;\n min-width: 0px;\n overflow: hidden;\n text-align: start;\n\n ${({ width }) =>\n width &&\n css`\n width: ${width};\n `}\n`;\n\nconst OptionSubtitle = styled.div`\n color: ${({ theme }) => semanticColor(theme, 'FgSecondary', theme.color.text.secondary)};\n font-size: ${({ theme }) => theme.text.paragraph.sm.fontSize};\n margin-top: ${Spacing[1]};\n`;\n\ninterface OptionsMenuProps {\n maxHeight?: number;\n size?: InputSizes;\n}\n\nconst OptionsMenu = styled(Menu)<OptionsMenuProps>`\n width: var(--radix-select-trigger-width);\n max-height: ${({ maxHeight }) => maxHeight ?? '225px !important'};\n overflow-y: auto;\n ${semanticScrollbar}\n margin-bottom: 0;\n\n ${({ size }) => {\n switch (size) {\n case 'md': {\n return css`\n ${MenuList} {\n padding: ${Spacing[2]};\n }\n\n ${OptionItem} {\n ${paragraphMixins.md};\n padding: ${Spacing[2]};\n }\n\n ${MenuHeading} {\n padding: ${Spacing[2]};\n }\n `;\n }\n case 'sm': {\n return css`\n ${MenuList} {\n padding: ${Spacing[1]};\n }\n\n ${OptionItem} {\n ${paragraphMixins.sm};\n padding: ${Spacing[1]};\n }\n\n ${MenuHeading} {\n padding: ${Spacing[1]};\n }\n `;\n }\n }\n }}\n`;\n\nconst SelectContent = styled(SelectPrimitive.Content)<{ $zIndex?: number | string }>`\n z-index: ${({ $zIndex }) => $zIndex || Z_INDICES.dropdown};\n`;\n\nconst SelectHeaderContainer = styled(HStack)`\n display: flex;\n justify-content: space-between;\n padding: ${Spacing[1]} ${Spacing[1]} 0 ${Spacing[1]};\n margin-bottom: ${Spacing[1]};\n`;\n\nconst SelectFooter = styled.div`\n padding: ${Spacing[1]} 0;\n margin-top: ${Spacing[1]};\n border-top: 1px solid ${({ theme }) => semanticColor(theme, 'BorderSubtle', Color.BorderDivider)};\n`;\n\nconst SelectMenu = forwardRef<HTMLUListElement, MenuProps & OptionsMenuProps>(function SelectMenu(\n props: MenuProps,\n forwardedRef,\n) {\n return <OptionsMenu listRef={forwardedRef} {...props} />;\n});\n\nconst OptionItem = styled(MenuItem)`\n ${paragraphMixins.md};\n padding: ${Spacing[4]};\n`;\n\nconst SelectItem = forwardRef<HTMLDivElement, MenuItemProps>(function SelectItem(\n props: MenuItemProps,\n forwardedRef,\n) {\n return <OptionItem ref={forwardedRef} {...props} />;\n});\n\nconst StyledIconContainer = styled(SelectPrimitive.Icon)<{ disabled?: boolean }>`\n position: absolute;\n right: ${Spacing[2]};\n display: flex;\n justify-content: center;\n\n ${({ theme, disabled }) => css`\n color: ${\n disabled\n ? semanticColor(theme, 'FgDisabled', Color.BorderIconDisabled)\n : semanticColor(theme, 'FgPrimary', Color.BorderIconPrimary)\n };\n `}\n`;\n\ninterface SelectHeaderProps {\n title?: ReactNode;\n menuItems?: ReactNode;\n menuTriggerLabel?: string;\n}\n\nexport const SelectHeader = ({ title, menuItems, menuTriggerLabel }: SelectHeaderProps) => {\n const uniqueId = useId();\n\n return (\n <SelectHeaderContainer align='center'>\n {title && (\n <Paragraph color='primary' weight='bold' size='md'>\n {title}\n </Paragraph>\n )}\n {menuItems && (\n <DropdownMenu\n portal={true}\n trigger={\n <IconButton>\n <MoreIcon />\n </IconButton>\n }\n triggerProps={{\n 'aria-label': menuTriggerLabel,\n id: `select-header-menu-trigger-${uniqueId}`,\n }}\n side='right'\n align='start'\n zIndex={Z_INDICES.layeredDropdown}\n contentProps={{\n // Fix for Radix UI 2.1.15 upgrade breaking changes:\n // 1. Portal rendering causes pointer-events issues preventing dropdown interaction\n // 2. Portal timing causes onFocusOutside to fire immediately, closing dropdown\n style: {\n pointerEvents: 'auto', // Ensure dropdown items receive mouse events\n },\n onFocusOutside: (event) => event.preventDefault(), // Prevent immediate portal closing\n }}\n >\n {menuItems}\n </DropdownMenu>\n )}\n </SelectHeaderContainer>\n );\n};\n\nexport const Select = forwardRef<HTMLButtonElement, SelectProps>(function Select(\n { portal = false, portalContainer, size = 'md', ...props }: SelectProps,\n forwardedRef,\n) {\n const {\n 'aria-label': ariaLabel,\n hasError,\n hasWarning,\n focused,\n active,\n hovered,\n disabled,\n placeholder,\n maxHeight,\n children,\n triggerProps,\n contentProps,\n id,\n className,\n onChange,\n onValueChange,\n value,\n width,\n header,\n footer,\n minWidth,\n valueContainerWidth,\n zIndex,\n } = props;\n\n const field = useFormField({ inputId: props.id, disabled, hasWarning, hasError });\n\n const content = (\n <SelectContent\n position='popper'\n side='bottom'\n sideOffset={8}\n $zIndex={zIndex}\n {...contentProps}\n >\n <SelectMenu maxHeight={maxHeight} size={size}>\n {header}\n <SelectPrimitive.Viewport>{children}</SelectPrimitive.Viewport>\n {footer && (\n <>\n <SelectFooter>{footer}</SelectFooter>\n </>\n )}\n </SelectMenu>\n </SelectContent>\n );\n\n return (\n <SelectPrimitive.Root\n {...props}\n onValueChange={(value) => {\n onChange?.({ target: { value } });\n onValueChange?.(value);\n }}\n // Custom behavior to consider null as empty value\n value={value === null ? '' : value}\n >\n <SelectPrimitive.Trigger\n ref={forwardedRef}\n asChild\n id={id}\n className={className}\n disabled={field.disabled}\n aria-describedby={field.helperTextId}\n aria-errormessage={field.hasError ? field.helperTextId : undefined}\n aria-invalid={field.hasError}\n aria-label={ariaLabel}\n {...triggerProps}\n >\n <SelectButton\n hasWarning={field.hasWarning}\n hasError={field.hasError}\n hovered={hovered}\n focused={focused}\n active={active}\n disabled={field.disabled}\n placeholder={placeholder}\n isSelectingPlaceholder={props.value === '' || props.value == null}\n $minWidth={minWidth}\n $size={size}\n $width={width}\n >\n <SelectValueContainer width={valueContainerWidth}>\n <SelectPrimitive.Value placeholder={placeholder} />\n </SelectValueContainer>\n <StyledIconContainer disabled={field.disabled}>\n <CaretDownIcon />\n </StyledIconContainer>\n </SelectButton>\n </SelectPrimitive.Trigger>\n {portal ? (\n <SelectPrimitive.Portal container={portalContainer}>{content}</SelectPrimitive.Portal>\n ) : (\n content\n )}\n </SelectPrimitive.Root>\n );\n});\n\nexport default Select;\n\nexport const Option = forwardRef<HTMLDivElement, SelectPrimitive.SelectItemProps & MenuItemProps>(\n function Option({ children, subtitle, ...props }, forwardedRef) {\n return (\n <SelectPrimitive.Item {...props} ref={forwardedRef} asChild>\n <SelectItem {...props}>\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n {subtitle && <OptionSubtitle>{subtitle}</OptionSubtitle>}\n </SelectItem>\n </SelectPrimitive.Item>\n );\n },\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA0GA,MAAM,eAAe,OAAO,SAAS;IACjC,WAAW;;;;;;;;;mBASI,QAAQ,GAAG;YAClB,EAAE,aAAa,UAAU,OAAO;gBAC5B,EAAE,gBAAiB,aAAa,OAAO,GAAG,UAAU,MAAM,OAAQ;;KAE7E,cAAc;;;;KAId,EAAE,OAAO,wBAAwB,eAClC,0BACA,CAAC,YACD,GAAG;eACQ,cAAc,OAAO,eAAe,MAAM,MAAM,KAAK,UAAU,CAAC;MACzE;;AAON,MAAM,uBAAuB,OAAO,IAA+B;;;;;;KAM9D,EAAE,YACH,SACA,GAAG;eACQ,MAAM;MACf;;AAGN,MAAM,iBAAiB,OAAO,GAAG;YACrB,EAAE,YAAY,cAAc,OAAO,eAAe,MAAM,MAAM,KAAK,UAAU,CAAC;gBAC1E,EAAE,YAAY,MAAM,KAAK,UAAU,GAAG,SAAS;gBAC/C,QAAQ,GAAG;;AAQ3B,MAAM,cAAc,OAAO,KAAK;;iBAEf,EAAE,gBAAgB,aAAa,mBAAmB;;IAE/D,kBAAkB;;;KAGjB,EAAE,WAAW;AACd,SAAQ,MAAR;EACE,KAAK,KACH,QAAO,GAAG;YACN,SAAS;uBACE,QAAQ,GAAG;;;YAG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KAAA;GACzD,gBAAc,MAAM;GACpB,cAAY;GACZ,GAAI;aAEJ,qBAAC,cAAD;IACE,YAAY,MAAM;IAClB,UAAU,MAAM;IACP;IACA;IACD;IACR,UAAU,MAAM;IACH;IACb,wBAAwB,MAAM,UAAU,MAAM,MAAM,SAAS;IAC7D,WAAW;IACX,OAAO;IACP,QAAQ;cAXV,CAaE,oBAAC,sBAAD;KAAsB,OAAO;eAC3B,oBAAC,gBAAgB,OAAjB,EAAoC,aAAe,CAAA;KAC9B,CAAA,EACvB,oBAAC,qBAAD;KAAqB,UAAU,MAAM;eACnC,oBAAC,eAAD,EAAiB,CAAA;KACG,CAAA,CACT;;GACS,CAAA,EACzB,SACC,oBAAC,gBAAgB,QAAjB;GAAwB,WAAW;aAAkB;GAAiC,CAAA,GAEtF,QAEmB;;EAEzB;AAIF,MAAa,SAAS,WACpB,SAAS,OAAO,EAAE,UAAU,UAAU,GAAG,SAAS,cAAc;AAC9D,QACE,oBAAC,gBAAgB,MAAjB;EAAsB,GAAI;EAAO,KAAK;EAAc,SAAA;YAClD,qBAAC,YAAD;GAAY,GAAI;aAAhB,CACE,oBAAC,gBAAgB,UAAjB,EAA2B,UAAoC,CAAA,EAC9D,YAAY,oBAAC,gBAAD,EAAA,UAAiB,UAA0B,CAAA,CAC7C;;EACQ,CAAA;EAG5B"}
|
package/dist/Select.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as SelectProps, n as Select, r as SelectHeader, t as Option } from "./Select-
|
|
1
|
+
import { i as SelectProps, n as Select, r as SelectHeader, t as Option } from "./Select-CR9TjFfo.mjs";
|
|
2
2
|
export { Option, Select, Select as default, SelectHeader, SelectProps };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as ImplementsFormField } from "./inputFields-
|
|
2
|
-
import { n as TableBoxField } from "./TableBoxField-
|
|
1
|
+
import { o as ImplementsFormField } from "./inputFields-DpHeZiFX.mjs";
|
|
2
|
+
import { n as TableBoxField } from "./TableBoxField-Db0Vjo6Z.mjs";
|
|
3
3
|
import SmartTextInput from "./SmartTextInput.mjs";
|
|
4
4
|
import { CSSProperties, ComponentProps } from "react";
|
|
5
5
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as styled, r as css } from "./styledComponentsInterop-Cs5CCPRy.mjs";
|
|
2
|
-
import { TruncatedText } from "./lib/TruncatedText.mjs";
|
|
3
2
|
import { semanticTokens } from "./lib/semanticColor.mjs";
|
|
3
|
+
import { TruncatedText } from "./lib/TruncatedText.mjs";
|
|
4
4
|
import { paragraphMixins } from "./mixins/text.mjs";
|
|
5
5
|
import { withAlpha } from "./lib/color.mjs";
|
|
6
6
|
import { BorderRadius, Color, Spacing } from "@persona/design-tokens";
|
|
@@ -312,4 +312,4 @@ const StatusIndicator = ({ status, type, background = "filled", showIcon = true,
|
|
|
312
312
|
//#endregion
|
|
313
313
|
export { StatusIndicator as n, STATUSES as t };
|
|
314
314
|
|
|
315
|
-
//# sourceMappingURL=StatusIndicator-
|
|
315
|
+
//# sourceMappingURL=StatusIndicator-CzRaEFSz.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatusIndicator-Zf75KK3O.mjs","names":[],"sources":["../src/components/StatusIndicator/StatusIndicator.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { BorderRadius, Color, Spacing } from '@persona/design-tokens';\nimport {\n CircleCheckFillIcon,\n CircleFillIcon,\n CircleHalfIcon,\n CircleMinusFillIcon,\n CircleNullIcon,\n CircleSlashIcon,\n WarningFillIcon,\n} from '@persona/icons/12px';\n\nimport { withAlpha } from '#src/lib/color';\nimport { type MaybeSemanticTheme, semanticTokens } from '#src/lib/semanticColor';\nimport { TruncatedText } from '#src/lib/TruncatedText';\nimport { paragraphMixins } from '#src/mixins/text';\nimport type { SemanticTokens } from '#src/variables/semantic';\n\nexport type StatusType =\n | 'neutral'\n | 'attention'\n | 'warning'\n | 'critical'\n | 'success'\n | 'feature'\n | 'informational'\n | 'miscellaneous';\nexport type BackgroundType = 'filled' | 'none';\n\n/**\n * Narrow set of status presets — one value per type+icon combination.\n * Override color with `type` or icon with `leadingIcon` when needed.\n */\nexport type Status =\n | 'open'\n | 'pending'\n | 'completed'\n | 'active'\n | 'failed'\n | 'needs_review'\n | 'canceled'\n | 'archived';\n\nconst STATUS_CONFIG: Record<Status, { type: StatusType; icon: ReactNode }> = {\n open: { type: 'neutral', icon: <CircleNullIcon /> },\n pending: { type: 'neutral', icon: <CircleHalfIcon /> },\n completed: { type: 'success', icon: <CircleCheckFillIcon /> },\n active: { type: 'success', icon: <CircleFillIcon /> },\n failed: { type: 'critical', icon: <CircleSlashIcon /> },\n needs_review: { type: 'warning', icon: <WarningFillIcon /> },\n canceled: { type: 'attention', icon: <CircleSlashIcon /> },\n archived: { type: 'neutral', icon: <CircleMinusFillIcon /> },\n};\n\n/** All supported `status` preset keys, derived from the config map. */\nexport const STATUSES = Object.keys(STATUS_CONFIG) as Status[];\n\nexport interface StatusIndicatorProps extends ComponentPropsWithoutRef<'div'> {\n /**\n * Preset that sets a default semantic type and icon.\n * Explicit `type` and `leadingIcon` override the preset.\n */\n status?: Status;\n\n /**\n * The semantic status type to display. Overrides `status` when both are set.\n */\n type?: StatusType;\n\n /**\n * Whether to show filled background or transparent\n */\n background?: BackgroundType;\n\n /**\n * Whether to show the icon. When false, displays label-only variant\n * @default true\n */\n showIcon?: boolean;\n\n /**\n * Optional custom icon to replace the default icon indicator (12px recommended)\n * - undefined (default): Uses `status` icon when set, otherwise CircleNullIcon\n * - null: Hides the icon completely\n * - ReactNode: Shows the provided custom icon\n * Note: showIcon must be true for this to take effect\n */\n leadingIcon?: ReactNode | null;\n\n /**\n * Truncate the label with an ellipsis instead of letting it overflow its container. Adds a\n * title tooltip with the full text when it doesn't fit.\n * @default false\n */\n truncate?: boolean;\n\n /**\n * Render the label exactly as given instead of capitalizing each word. Use for labels that are\n * authored outside the product, where the casing is not ours to change.\n * @default false\n */\n preserveCase?: boolean;\n\n /**\n * The text label to display\n */\n children?: ReactNode;\n}\n\ninterface StatusColors {\n background: string;\n text: string;\n icon: string;\n}\n\nconst FILLED_STATUS_COLORS: Record<StatusType, StatusColors> = {\n neutral: {\n background: Color.BackgroundStatusIndicatorDefault,\n text: Color.TextStatusIndicatorDefault,\n icon: Color.BorderIconLabelGrey,\n },\n attention: {\n background: Color.BackgroundStatusIndicatorAttention,\n text: Color.TextStatusIndicatorAttention,\n icon: Color.BorderIconLabelYellow,\n },\n warning: {\n background: Color.BackgroundStatusIndicatorWarning,\n text: Color.TextStatusIndicatorWarning,\n icon: Color.BorderIconLabelOrange,\n },\n critical: {\n background: Color.BackgroundStatusIndicatorCritical,\n text: Color.TextStatusIndicatorCritical,\n icon: Color.BorderIconLabelRed,\n },\n success: {\n background: Color.BackgroundStatusIndicatorSuccess,\n text: Color.TextStatusIndicatorSuccess,\n icon: Color.BorderIconLabelGreen,\n },\n feature: {\n background: Color.BackgroundStatusIndicatorFeature,\n text: Color.TextStatusIndicatorFeature,\n icon: Color.BorderIconLabelPurple,\n },\n informational: {\n background: Color.BackgroundStatusIndicatorInformational,\n text: Color.TextStatusIndicatorInformational,\n icon: Color.BorderIconLabelBlue,\n },\n miscellaneous: {\n background: Color.BackgroundStatusIndicatorMiscellaneous,\n text: Color.TextStatusIndicatorMiscellaneous,\n icon: Color.BorderIconLabelTeal,\n },\n};\n\nconst TRANSPARENT_STATUS_COLORS: Record<StatusType, StatusColors> = {\n neutral: {\n background: 'transparent',\n text: Color.TextPrimary,\n icon: Color.BorderIconSecondary,\n },\n attention: {\n background: 'transparent',\n text: Color.TextPrimary,\n icon: Color.BorderIconWarning,\n },\n warning: {\n background: 'transparent',\n text: Color.TextPrimary,\n icon: Color.BorderIconWarning,\n },\n critical: {\n background: 'transparent',\n text: Color.TextPrimary,\n icon: Color.BorderIconDanger,\n },\n success: {\n background: 'transparent',\n text: Color.TextPrimary,\n icon: Color.BorderIconSuccess,\n },\n feature: {\n background: 'transparent',\n text: Color.TextPrimary,\n icon: Color.BorderIconActive,\n },\n informational: {\n background: 'transparent',\n text: Color.TextPrimary,\n icon: Color.BorderIconLabelBlue,\n },\n miscellaneous: {\n background: 'transparent',\n text: Color.TextPrimary,\n icon: Color.BorderIconLabelTeal,\n },\n};\n\nconst semanticFilledStatusColors = (t: SemanticTokens): Record<StatusType, StatusColors> => ({\n neutral: { background: t.StatusNeutral, text: t.FgPrimary, icon: t.FgPrimary },\n attention: {\n background: withAlpha(t.StatusHighlight, t.Opacity15),\n text: t.FgHighlight,\n icon: t.FgHighlight,\n },\n warning: {\n background: withAlpha(t.StatusWarning, t.Opacity15),\n text: t.FgWarning2,\n icon: t.FgWarning2,\n },\n critical: {\n background: withAlpha(t.StatusDanger3, t.Opacity15),\n text: t.FgDanger2,\n icon: t.FgDanger2,\n },\n success: {\n background: withAlpha(t.StatusSuccess2, t.Opacity15),\n text: t.FgSuccess,\n icon: t.FgSuccess,\n },\n feature: {\n background: withAlpha(t.StatusFeature, t.Opacity25),\n text: t.FgFeature,\n icon: t.FgFeature,\n },\n informational: {\n background: withAlpha(t.StatusInfo2, t.Opacity25),\n text: t.FgInfo,\n icon: t.FgInfo,\n },\n miscellaneous: {\n background: withAlpha(t.StatusMisc, t.Opacity15),\n text: t.FgMisc,\n icon: t.FgMisc,\n },\n});\n\nconst semanticTransparentStatusColors = (t: SemanticTokens): Record<StatusType, StatusColors> => ({\n neutral: { background: 'transparent', text: t.FgPrimary, icon: t.FgSecondary },\n attention: { background: 'transparent', text: t.FgPrimary, icon: t.FeedbackHighlight1 },\n warning: { background: 'transparent', text: t.FgPrimary, icon: t.FgWarning1 },\n critical: { background: 'transparent', text: t.FgPrimary, icon: t.FgDanger1 },\n success: { background: 'transparent', text: t.FgPrimary, icon: t.FgSuccess },\n feature: { background: 'transparent', text: t.FgPrimary, icon: t.FgAccent },\n informational: { background: 'transparent', text: t.FgPrimary, icon: t.FgInfo },\n miscellaneous: { background: 'transparent', text: t.FgPrimary, icon: t.FgMisc },\n});\n\nconst semanticStatusColorCache = new WeakMap<\n SemanticTokens,\n Record<BackgroundType, Record<StatusType, StatusColors>>\n>();\n\nconst semanticStatusColors = (tokens: SemanticTokens) => {\n let colors = semanticStatusColorCache.get(tokens);\n if (!colors) {\n colors = {\n filled: semanticFilledStatusColors(tokens),\n none: semanticTransparentStatusColors(tokens),\n };\n semanticStatusColorCache.set(tokens, colors);\n }\n return colors;\n};\n\nconst statusColors = (theme: MaybeSemanticTheme, background: BackgroundType) => {\n const tokens = semanticTokens(theme);\n if (tokens) {\n return semanticStatusColors(tokens)[background];\n }\n return background === 'filled' ? FILLED_STATUS_COLORS : TRANSPARENT_STATUS_COLORS;\n};\n\nconst Label = styled.div<{\n $type: StatusType;\n $background: BackgroundType;\n $truncate: boolean;\n $preserveCase: boolean;\n}>`\n ${paragraphMixins.sm}\n display: flex;\n flex-direction: column;\n justify-content: center;\n flex-shrink: ${({ $truncate }) => ($truncate ? 1 : 0)};\n min-width: ${({ $truncate }) => ($truncate ? '0' : 'auto')};\n /* Line box hugs the font so pill height is driven by padding alone, and clipping an overflowing\n label can't cut into descenders. Matches Sticker. */\n line-height: 1;\n white-space: nowrap;\n text-transform: ${({ $preserveCase }) => ($preserveCase ? 'none' : 'capitalize')};\n /* Slight optical centering adjustment */\n transform: translateY(0.5px);\n color: ${({ theme, $type, $background }) => statusColors(theme, $background)[$type].text};\n`;\n\nconst IconContainer = styled.span<{ $type: StatusType; $background: BackgroundType }>`\n line-height: 0;\n color: ${({ theme, $type, $background }) => statusColors(theme, $background)[$type].icon};\n`;\n\nconst LabelContainer = styled.div<{ $hasIcon: boolean; $truncate: boolean }>`\n display: flex;\n align-items: center;\n gap: ${Spacing[1]};\n padding: ${({ $hasIcon }) =>\n `${Spacing[1]} ${Spacing[2]} ${Spacing[1]} ${$hasIcon ? Spacing[1] : Spacing[2]}`};\n position: relative;\n flex-shrink: ${({ $truncate }) => ($truncate ? 1 : 0)};\n min-width: ${({ $truncate }) => ($truncate ? '0' : 'auto')};\n`;\n\nconst StyledStatusIndicator = styled.div<{\n $type: StatusType;\n $background: BackgroundType;\n $truncate: boolean;\n}>`\n display: inline-flex;\n align-items: center;\n border-radius: ${BorderRadius.Xl};\n width: fit-content;\n max-width: ${({ $truncate }) => ($truncate ? '100%' : 'none')};\n\n ${({ theme, $type, $background }) => css`\n background-color: ${statusColors(theme, $background)[$type].background};\n `}\n`;\n\n/**\n * StatusIndicator displays semantic status information with a colored icon and label.\n * Supports both filled backgrounds and transparent styles.\n *\n * @example\n * ```tsx\n * <StatusIndicator status=\"active\">Active</StatusIndicator>\n * <StatusIndicator type=\"success\" background=\"filled\">Approved</StatusIndicator>\n * <StatusIndicator type=\"critical\" background=\"none\">Failed</StatusIndicator>\n * ```\n */\nexport const StatusIndicator = ({\n status,\n type,\n background = 'filled',\n showIcon = true,\n leadingIcon,\n truncate = false,\n preserveCase = false,\n children,\n ...props\n}: StatusIndicatorProps) => {\n const resolvedType = type ?? (status != null ? STATUS_CONFIG[status].type : 'neutral');\n\n // Determine which icon to show:\n // - showIcon=false with background='filled': label-only variant (no icon)\n // - leadingIcon set (including null): explicit override\n // - status set: use preset icon\n // - otherwise: default CircleNullIcon\n // - background='none' always shows icon (showIcon is ignored for none background)\n let iconToRender;\n if (!showIcon && background === 'filled') {\n iconToRender = null;\n } else if (typeof leadingIcon !== 'undefined') {\n iconToRender = leadingIcon;\n } else if (status != null) {\n iconToRender = STATUS_CONFIG[status].icon;\n } else {\n iconToRender = <CircleNullIcon />;\n }\n const hasIcon = iconToRender != null;\n\n return (\n <StyledStatusIndicator\n $type={resolvedType}\n $background={background}\n $truncate={truncate}\n {...props}\n >\n <LabelContainer $hasIcon={hasIcon} $truncate={truncate}>\n {hasIcon && (\n <IconContainer $type={resolvedType} $background={background}>\n {iconToRender}\n </IconContainer>\n )}\n <Label\n $type={resolvedType}\n $background={background}\n $truncate={truncate}\n $preserveCase={preserveCase}\n >\n {truncate ? <TruncatedText>{children}</TruncatedText> : children}\n </Label>\n </LabelContainer>\n </StyledStatusIndicator>\n );\n};\n\nexport default StatusIndicator;\n"],"mappings":";;;;;;;;;AA6CA,MAAM,gBAAuE;CAC3E,MAAM;EAAE,MAAM;EAAW,MAAM,oBAAC,gBAAD,EAAkB,CAAA;EAAE;CACnD,SAAS;EAAE,MAAM;EAAW,MAAM,oBAAC,gBAAD,EAAkB,CAAA;EAAE;CACtD,WAAW;EAAE,MAAM;EAAW,MAAM,oBAAC,qBAAD,EAAuB,CAAA;EAAE;CAC7D,QAAQ;EAAE,MAAM;EAAW,MAAM,oBAAC,gBAAD,EAAkB,CAAA;EAAE;CACrD,QAAQ;EAAE,MAAM;EAAY,MAAM,oBAAC,iBAAD,EAAmB,CAAA;EAAE;CACvD,cAAc;EAAE,MAAM;EAAW,MAAM,oBAAC,iBAAD,EAAmB,CAAA;EAAE;CAC5D,UAAU;EAAE,MAAM;EAAa,MAAM,oBAAC,iBAAD,EAAmB,CAAA;EAAE;CAC1D,UAAU;EAAE,MAAM;EAAW,MAAM,oBAAC,qBAAD,EAAuB,CAAA;EAAE;CAC7D;;AAGD,MAAa,WAAW,OAAO,KAAK,cAAc;AA4DlD,MAAM,uBAAyD;CAC7D,SAAS;EACP,YAAY,MAAM;EAClB,MAAM,MAAM;EACZ,MAAM,MAAM;EACb;CACD,WAAW;EACT,YAAY,MAAM;EAClB,MAAM,MAAM;EACZ,MAAM,MAAM;EACb;CACD,SAAS;EACP,YAAY,MAAM;EAClB,MAAM,MAAM;EACZ,MAAM,MAAM;EACb;CACD,UAAU;EACR,YAAY,MAAM;EAClB,MAAM,MAAM;EACZ,MAAM,MAAM;EACb;CACD,SAAS;EACP,YAAY,MAAM;EAClB,MAAM,MAAM;EACZ,MAAM,MAAM;EACb;CACD,SAAS;EACP,YAAY,MAAM;EAClB,MAAM,MAAM;EACZ,MAAM,MAAM;EACb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C,oBAAC,eAAD;IAAe,OAAO;IAAc,aAAa;cAC9C;IACa,CAAA,EAElB,oBAAC,OAAD;IACE,OAAO;IACP,aAAa;IACb,WAAW;IACX,eAAe;cAEd,WAAW,oBAAC,eAAD,EAAgB,UAAyB,CAAA,GAAG;IAClD,CAAA,CACO;;EACK,CAAA"}
|
|
1
|
+
{"version":3,"file":"StatusIndicator-CzRaEFSz.mjs","names":[],"sources":["../src/components/StatusIndicator/StatusIndicator.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { BorderRadius, Color, Spacing } from '@persona/design-tokens';\nimport {\n CircleCheckFillIcon,\n CircleFillIcon,\n CircleHalfIcon,\n CircleMinusFillIcon,\n CircleNullIcon,\n CircleSlashIcon,\n WarningFillIcon,\n} from '@persona/icons/12px';\n\nimport { withAlpha } from '#src/lib/color';\nimport { type MaybeSemanticTheme, semanticTokens } from '#src/lib/semanticColor';\nimport { TruncatedText } from '#src/lib/TruncatedText';\nimport { paragraphMixins } from '#src/mixins/text';\nimport type { SemanticTokens } from '#src/variables/semantic';\n\nexport type StatusType =\n | 'neutral'\n | 'attention'\n | 'warning'\n | 'critical'\n | 'success'\n | 'feature'\n | 'informational'\n | 'miscellaneous';\nexport type BackgroundType = 'filled' | 'none';\n\n/**\n * Narrow set of status presets — one value per type+icon combination.\n * Override color with `type` or icon with `leadingIcon` when needed.\n */\nexport type Status =\n | 'open'\n | 'pending'\n | 'completed'\n | 'active'\n | 'failed'\n | 'needs_review'\n | 'canceled'\n | 'archived';\n\nconst STATUS_CONFIG: Record<Status, { type: StatusType; icon: ReactNode }> = {\n open: { type: 'neutral', icon: <CircleNullIcon /> },\n pending: { type: 'neutral', icon: <CircleHalfIcon /> },\n completed: { type: 'success', icon: <CircleCheckFillIcon /> },\n active: { type: 'success', icon: <CircleFillIcon /> },\n failed: { type: 'critical', icon: <CircleSlashIcon /> },\n needs_review: { type: 'warning', icon: <WarningFillIcon /> },\n canceled: { type: 'attention', icon: <CircleSlashIcon /> },\n archived: { type: 'neutral', icon: <CircleMinusFillIcon /> },\n};\n\n/** All supported `status` preset keys, derived from the config map. */\nexport const STATUSES = Object.keys(STATUS_CONFIG) as Status[];\n\nexport interface StatusIndicatorProps extends ComponentPropsWithoutRef<'div'> {\n /**\n * Preset that sets a default semantic type and icon.\n * Explicit `type` and `leadingIcon` override the preset.\n */\n status?: Status;\n\n /**\n * The semantic status type to display. Overrides `status` when both are set.\n */\n type?: StatusType;\n\n /**\n * Whether to show filled background or transparent\n */\n background?: BackgroundType;\n\n /**\n * Whether to show the icon. When false, displays label-only variant\n * @default true\n */\n showIcon?: boolean;\n\n /**\n * Optional custom icon to replace the default icon indicator (12px recommended)\n * - undefined (default): Uses `status` icon when set, otherwise CircleNullIcon\n * - null: Hides the icon completely\n * - ReactNode: Shows the provided custom icon\n * Note: showIcon must be true for this to take effect\n */\n leadingIcon?: ReactNode | null;\n\n /**\n * Truncate the label with an ellipsis instead of letting it overflow its container. Adds a\n * title tooltip with the full text when it doesn't fit.\n * @default false\n */\n truncate?: boolean;\n\n /**\n * Render the label exactly as given instead of capitalizing each word. Use for labels that are\n * authored outside the product, where the casing is not ours to change.\n * @default false\n */\n preserveCase?: boolean;\n\n /**\n * The text label to display\n */\n children?: ReactNode;\n}\n\ninterface StatusColors {\n background: string;\n text: string;\n icon: string;\n}\n\nconst FILLED_STATUS_COLORS: Record<StatusType, StatusColors> = {\n neutral: {\n background: Color.BackgroundStatusIndicatorDefault,\n text: Color.TextStatusIndicatorDefault,\n icon: Color.BorderIconLabelGrey,\n },\n attention: {\n background: Color.BackgroundStatusIndicatorAttention,\n text: Color.TextStatusIndicatorAttention,\n icon: Color.BorderIconLabelYellow,\n },\n warning: {\n background: Color.BackgroundStatusIndicatorWarning,\n text: Color.TextStatusIndicatorWarning,\n icon: Color.BorderIconLabelOrange,\n },\n critical: {\n background: Color.BackgroundStatusIndicatorCritical,\n text: Color.TextStatusIndicatorCritical,\n icon: Color.BorderIconLabelRed,\n },\n success: {\n background: Color.BackgroundStatusIndicatorSuccess,\n text: Color.TextStatusIndicatorSuccess,\n icon: Color.BorderIconLabelGreen,\n },\n feature: {\n background: Color.BackgroundStatusIndicatorFeature,\n text: Color.TextStatusIndicatorFeature,\n icon: Color.BorderIconLabelPurple,\n },\n informational: {\n background: Color.BackgroundStatusIndicatorInformational,\n text: Color.TextStatusIndicatorInformational,\n icon: Color.BorderIconLabelBlue,\n },\n miscellaneous: {\n background: Color.BackgroundStatusIndicatorMiscellaneous,\n text: Color.TextStatusIndicatorMiscellaneous,\n icon: Color.BorderIconLabelTeal,\n },\n};\n\nconst TRANSPARENT_STATUS_COLORS: Record<StatusType, StatusColors> = {\n neutral: {\n background: 'transparent',\n text: Color.TextPrimary,\n icon: Color.BorderIconSecondary,\n },\n attention: {\n background: 'transparent',\n text: Color.TextPrimary,\n icon: Color.BorderIconWarning,\n },\n warning: {\n background: 'transparent',\n text: Color.TextPrimary,\n icon: Color.BorderIconWarning,\n },\n critical: {\n background: 'transparent',\n text: Color.TextPrimary,\n icon: Color.BorderIconDanger,\n },\n success: {\n background: 'transparent',\n text: Color.TextPrimary,\n icon: Color.BorderIconSuccess,\n },\n feature: {\n background: 'transparent',\n text: Color.TextPrimary,\n icon: Color.BorderIconActive,\n },\n informational: {\n background: 'transparent',\n text: Color.TextPrimary,\n icon: Color.BorderIconLabelBlue,\n },\n miscellaneous: {\n background: 'transparent',\n text: Color.TextPrimary,\n icon: Color.BorderIconLabelTeal,\n },\n};\n\nconst semanticFilledStatusColors = (t: SemanticTokens): Record<StatusType, StatusColors> => ({\n neutral: { background: t.StatusNeutral, text: t.FgPrimary, icon: t.FgPrimary },\n attention: {\n background: withAlpha(t.StatusHighlight, t.Opacity15),\n text: t.FgHighlight,\n icon: t.FgHighlight,\n },\n warning: {\n background: withAlpha(t.StatusWarning, t.Opacity15),\n text: t.FgWarning2,\n icon: t.FgWarning2,\n },\n critical: {\n background: withAlpha(t.StatusDanger3, t.Opacity15),\n text: t.FgDanger2,\n icon: t.FgDanger2,\n },\n success: {\n background: withAlpha(t.StatusSuccess2, t.Opacity15),\n text: t.FgSuccess,\n icon: t.FgSuccess,\n },\n feature: {\n background: withAlpha(t.StatusFeature, t.Opacity25),\n text: t.FgFeature,\n icon: t.FgFeature,\n },\n informational: {\n background: withAlpha(t.StatusInfo2, t.Opacity25),\n text: t.FgInfo,\n icon: t.FgInfo,\n },\n miscellaneous: {\n background: withAlpha(t.StatusMisc, t.Opacity15),\n text: t.FgMisc,\n icon: t.FgMisc,\n },\n});\n\nconst semanticTransparentStatusColors = (t: SemanticTokens): Record<StatusType, StatusColors> => ({\n neutral: { background: 'transparent', text: t.FgPrimary, icon: t.FgSecondary },\n attention: { background: 'transparent', text: t.FgPrimary, icon: t.FeedbackHighlight1 },\n warning: { background: 'transparent', text: t.FgPrimary, icon: t.FgWarning1 },\n critical: { background: 'transparent', text: t.FgPrimary, icon: t.FgDanger1 },\n success: { background: 'transparent', text: t.FgPrimary, icon: t.FgSuccess },\n feature: { background: 'transparent', text: t.FgPrimary, icon: t.FgAccent },\n informational: { background: 'transparent', text: t.FgPrimary, icon: t.FgInfo },\n miscellaneous: { background: 'transparent', text: t.FgPrimary, icon: t.FgMisc },\n});\n\nconst semanticStatusColorCache = new WeakMap<\n SemanticTokens,\n Record<BackgroundType, Record<StatusType, StatusColors>>\n>();\n\nconst semanticStatusColors = (tokens: SemanticTokens) => {\n let colors = semanticStatusColorCache.get(tokens);\n if (!colors) {\n colors = {\n filled: semanticFilledStatusColors(tokens),\n none: semanticTransparentStatusColors(tokens),\n };\n semanticStatusColorCache.set(tokens, colors);\n }\n return colors;\n};\n\nconst statusColors = (theme: MaybeSemanticTheme, background: BackgroundType) => {\n const tokens = semanticTokens(theme);\n if (tokens) {\n return semanticStatusColors(tokens)[background];\n }\n return background === 'filled' ? FILLED_STATUS_COLORS : TRANSPARENT_STATUS_COLORS;\n};\n\nconst Label = styled.div<{\n $type: StatusType;\n $background: BackgroundType;\n $truncate: boolean;\n $preserveCase: boolean;\n}>`\n ${paragraphMixins.sm}\n display: flex;\n flex-direction: column;\n justify-content: center;\n flex-shrink: ${({ $truncate }) => ($truncate ? 1 : 0)};\n min-width: ${({ $truncate }) => ($truncate ? '0' : 'auto')};\n /* Line box hugs the font so pill height is driven by padding alone, and clipping an overflowing\n label can't cut into descenders. Matches Sticker. */\n line-height: 1;\n white-space: nowrap;\n text-transform: ${({ $preserveCase }) => ($preserveCase ? 'none' : 'capitalize')};\n /* Slight optical centering adjustment */\n transform: translateY(0.5px);\n color: ${({ theme, $type, $background }) => statusColors(theme, $background)[$type].text};\n`;\n\nconst IconContainer = styled.span<{ $type: StatusType; $background: BackgroundType }>`\n line-height: 0;\n color: ${({ theme, $type, $background }) => statusColors(theme, $background)[$type].icon};\n`;\n\nconst LabelContainer = styled.div<{ $hasIcon: boolean; $truncate: boolean }>`\n display: flex;\n align-items: center;\n gap: ${Spacing[1]};\n padding: ${({ $hasIcon }) =>\n `${Spacing[1]} ${Spacing[2]} ${Spacing[1]} ${$hasIcon ? Spacing[1] : Spacing[2]}`};\n position: relative;\n flex-shrink: ${({ $truncate }) => ($truncate ? 1 : 0)};\n min-width: ${({ $truncate }) => ($truncate ? '0' : 'auto')};\n`;\n\nconst StyledStatusIndicator = styled.div<{\n $type: StatusType;\n $background: BackgroundType;\n $truncate: boolean;\n}>`\n display: inline-flex;\n align-items: center;\n border-radius: ${BorderRadius.Xl};\n width: fit-content;\n max-width: ${({ $truncate }) => ($truncate ? '100%' : 'none')};\n\n ${({ theme, $type, $background }) => css`\n background-color: ${statusColors(theme, $background)[$type].background};\n `}\n`;\n\n/**\n * StatusIndicator displays semantic status information with a colored icon and label.\n * Supports both filled backgrounds and transparent styles.\n *\n * @example\n * ```tsx\n * <StatusIndicator status=\"active\">Active</StatusIndicator>\n * <StatusIndicator type=\"success\" background=\"filled\">Approved</StatusIndicator>\n * <StatusIndicator type=\"critical\" background=\"none\">Failed</StatusIndicator>\n * ```\n */\nexport const StatusIndicator = ({\n status,\n type,\n background = 'filled',\n showIcon = true,\n leadingIcon,\n truncate = false,\n preserveCase = false,\n children,\n ...props\n}: StatusIndicatorProps) => {\n const resolvedType = type ?? (status != null ? STATUS_CONFIG[status].type : 'neutral');\n\n // Determine which icon to show:\n // - showIcon=false with background='filled': label-only variant (no icon)\n // - leadingIcon set (including null): explicit override\n // - status set: use preset icon\n // - otherwise: default CircleNullIcon\n // - background='none' always shows icon (showIcon is ignored for none background)\n let iconToRender;\n if (!showIcon && background === 'filled') {\n iconToRender = null;\n } else if (typeof leadingIcon !== 'undefined') {\n iconToRender = leadingIcon;\n } else if (status != null) {\n iconToRender = STATUS_CONFIG[status].icon;\n } else {\n iconToRender = <CircleNullIcon />;\n }\n const hasIcon = iconToRender != null;\n\n return (\n <StyledStatusIndicator\n $type={resolvedType}\n $background={background}\n $truncate={truncate}\n {...props}\n >\n <LabelContainer $hasIcon={hasIcon} $truncate={truncate}>\n {hasIcon && (\n <IconContainer $type={resolvedType} $background={background}>\n {iconToRender}\n </IconContainer>\n )}\n <Label\n $type={resolvedType}\n $background={background}\n $truncate={truncate}\n $preserveCase={preserveCase}\n >\n {truncate ? <TruncatedText>{children}</TruncatedText> : children}\n </Label>\n </LabelContainer>\n </StyledStatusIndicator>\n );\n};\n\nexport default StatusIndicator;\n"],"mappings":";;;;;;;;;AA6CA,MAAM,gBAAuE;CAC3E,MAAM;EAAE,MAAM;EAAW,MAAM,oBAAC,gBAAD,EAAkB,CAAA;EAAE;CACnD,SAAS;EAAE,MAAM;EAAW,MAAM,oBAAC,gBAAD,EAAkB,CAAA;EAAE;CACtD,WAAW;EAAE,MAAM;EAAW,MAAM,oBAAC,qBAAD,EAAuB,CAAA;EAAE;CAC7D,QAAQ;EAAE,MAAM;EAAW,MAAM,oBAAC,gBAAD,EAAkB,CAAA;EAAE;CACrD,QAAQ;EAAE,MAAM;EAAY,MAAM,oBAAC,iBAAD,EAAmB,CAAA;EAA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