@dxos/react-ui 0.8.4-main.ef1bc66f44 → 0.8.4-main.f466a3d56e
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/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/browser/chunk-A5QCIG5R.mjs +24 -0
- package/dist/lib/browser/chunk-A5QCIG5R.mjs.map +7 -0
- package/dist/lib/browser/{chunk-EJYV4HAH.mjs → chunk-LY5XDQR5.mjs} +189 -117
- package/dist/lib/browser/chunk-LY5XDQR5.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +3257 -2048
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +70 -41
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/browser/translations.mjs +9 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-YTLZCZ2M.mjs → chunk-NGKLIKP3.mjs} +189 -117
- package/dist/lib/node-esm/chunk-NGKLIKP3.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-XCFLA74M.mjs +26 -0
- package/dist/lib/node-esm/chunk-XCFLA74M.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +3257 -2048
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +70 -41
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/translations.mjs +10 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/types/src/components/Avatars/Avatar.d.ts +1 -1
- package/dist/types/src/components/Avatars/Avatar.d.ts.map +1 -1
- package/dist/types/src/components/Avatars/Avatar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Avatars/AvatarGroup.stories.d.ts.map +1 -1
- package/dist/types/src/components/Breadcrumb/Breadcrumb.d.ts.map +1 -1
- package/dist/types/src/components/Breadcrumb/Breadcrumb.stories.d.ts.map +1 -1
- package/dist/types/src/components/Button/Button.d.ts +2 -2
- package/dist/types/src/components/Button/Button.d.ts.map +1 -1
- package/dist/types/src/components/Button/Button.stories.d.ts +1 -1
- package/dist/types/src/components/Button/Button.stories.d.ts.map +1 -1
- package/dist/types/src/components/Button/IconButton.d.ts +1 -0
- package/dist/types/src/components/Button/IconButton.d.ts.map +1 -1
- package/dist/types/src/components/Button/IconButton.stories.d.ts +3 -0
- package/dist/types/src/components/Button/IconButton.stories.d.ts.map +1 -1
- package/dist/types/src/components/Button/Toggle.d.ts +2 -2
- package/dist/types/src/components/Button/Toggle.d.ts.map +1 -1
- package/dist/types/src/components/Button/Toggle.stories.d.ts.map +1 -1
- package/dist/types/src/components/Button/ToggleGroup.d.ts +6 -6
- package/dist/types/src/components/Button/ToggleGroup.d.ts.map +1 -1
- package/dist/types/src/components/Button/ToggleGroup.stories.d.ts +2 -2
- package/dist/types/src/components/Button/ToggleGroup.stories.d.ts.map +1 -1
- package/dist/types/src/components/Card/Card.d.ts +124 -0
- package/dist/types/src/components/Card/Card.d.ts.map +1 -0
- package/dist/types/src/components/Card/Card.stories.d.ts +21 -0
- package/dist/types/src/components/Card/Card.stories.d.ts.map +1 -0
- package/dist/types/src/components/Card/index.d.ts +2 -0
- package/dist/types/src/components/Card/index.d.ts.map +1 -0
- package/dist/types/src/components/Carousel/Carousel.d.ts +90 -0
- package/dist/types/src/components/Carousel/Carousel.d.ts.map +1 -0
- package/dist/types/src/components/Carousel/index.d.ts +2 -0
- package/dist/types/src/components/Carousel/index.d.ts.map +1 -0
- package/dist/types/src/components/Clipboard/ClipboardProvider.d.ts.map +1 -1
- package/dist/types/src/components/Clipboard/CopyButton.d.ts.map +1 -1
- package/dist/types/src/components/Clipboard/index.d.ts +10 -1
- package/dist/types/src/components/Clipboard/index.d.ts.map +1 -1
- package/dist/types/src/components/DensityProvider/DensityProvider.d.ts.map +1 -1
- package/dist/types/src/components/Dialog/AlertDialog.d.ts +43 -23
- package/dist/types/src/components/Dialog/AlertDialog.d.ts.map +1 -1
- package/dist/types/src/components/Dialog/AlertDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/Dialog/Dialog.d.ts +48 -30
- package/dist/types/src/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/types/src/components/Dialog/Dialog.stories.d.ts +6 -8
- package/dist/types/src/components/Dialog/Dialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/ElevationProvider/ElevationProvider.d.ts.map +1 -1
- package/dist/types/src/components/ErrorFallback/ErrorFallback.d.ts +11 -0
- package/dist/types/src/components/ErrorFallback/ErrorFallback.d.ts.map +1 -0
- package/dist/types/src/components/ErrorFallback/ErrorFallback.stories.d.ts +7 -0
- package/dist/types/src/components/ErrorFallback/ErrorFallback.stories.d.ts.map +1 -0
- package/dist/types/src/components/ErrorFallback/ErrorStack.d.ts +19 -0
- package/dist/types/src/components/ErrorFallback/ErrorStack.d.ts.map +1 -0
- package/dist/types/src/components/ErrorFallback/ThrowError.d.ts +9 -0
- package/dist/types/src/components/ErrorFallback/ThrowError.d.ts.map +1 -0
- package/dist/types/src/components/ErrorFallback/index.d.ts +5 -0
- package/dist/types/src/components/ErrorFallback/index.d.ts.map +1 -0
- package/dist/types/src/components/Focus/Focus.d.ts +36 -0
- package/dist/types/src/components/Focus/Focus.d.ts.map +1 -0
- package/dist/types/src/components/Focus/Focus.stories.d.ts +9 -0
- package/dist/types/src/components/Focus/Focus.stories.d.ts.map +1 -0
- package/dist/types/src/components/Focus/index.d.ts +2 -0
- package/dist/types/src/components/Focus/index.d.ts.map +1 -0
- package/dist/types/src/components/Icon/Icon.d.ts +4 -0
- package/dist/types/src/components/Icon/Icon.d.ts.map +1 -1
- package/dist/types/src/components/Icon/Icon.stories.d.ts +11 -3
- package/dist/types/src/components/Icon/Icon.stories.d.ts.map +1 -1
- package/dist/types/src/components/Image/Image.d.ts +15 -0
- package/dist/types/src/components/Image/Image.d.ts.map +1 -0
- package/dist/types/src/components/Image/Image.stories.d.ts +34 -0
- package/dist/types/src/components/Image/Image.stories.d.ts.map +1 -0
- package/dist/types/src/components/Image/index.d.ts +2 -0
- package/dist/types/src/components/Image/index.d.ts.map +1 -0
- package/dist/types/src/components/Input/Input.d.ts +16 -22
- package/dist/types/src/components/Input/Input.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.stories.d.ts +6 -6
- package/dist/types/src/components/Input/Input.stories.d.ts.map +1 -1
- package/dist/types/src/components/Link/Link.stories.d.ts.map +1 -1
- package/dist/types/src/components/List/List.d.ts +5 -3
- package/dist/types/src/components/List/List.d.ts.map +1 -1
- package/dist/types/src/components/List/List.stories.d.ts +3 -1
- package/dist/types/src/components/List/List.stories.d.ts.map +1 -1
- package/dist/types/src/components/List/ListDropIndicator.d.ts.map +1 -1
- package/dist/types/src/components/List/Tree.d.ts +2 -2
- package/dist/types/src/components/List/Tree.d.ts.map +1 -1
- package/dist/types/src/components/List/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/components/List/TreeDropIndicator.d.ts.map +1 -1
- package/dist/types/src/components/List/Treegrid.d.ts +5 -9
- package/dist/types/src/components/List/Treegrid.d.ts.map +1 -1
- package/dist/types/src/components/List/Treegrid.stories.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.d.ts +11 -7
- package/dist/types/src/components/Main/Main.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.stories.d.ts +0 -3
- package/dist/types/src/components/Main/Main.stories.d.ts.map +1 -1
- package/dist/types/src/components/Main/useSwipeToDismiss.d.ts.map +1 -1
- package/dist/types/src/components/MediaPlayer/MediaPlayer.d.ts +46 -0
- package/dist/types/src/components/MediaPlayer/MediaPlayer.d.ts.map +1 -0
- package/dist/types/src/components/MediaPlayer/MediaPlayer.stories.d.ts +16 -0
- package/dist/types/src/components/MediaPlayer/MediaPlayer.stories.d.ts.map +1 -0
- package/dist/types/src/components/MediaPlayer/index.d.ts +2 -0
- package/dist/types/src/components/MediaPlayer/index.d.ts.map +1 -0
- package/dist/types/src/components/Menu/ContextMenu.d.ts.map +1 -1
- package/dist/types/src/components/Menu/ContextMenu.stories.d.ts.map +1 -1
- package/dist/types/src/components/Menu/DropdownMenu.d.ts +58 -49
- package/dist/types/src/components/Menu/DropdownMenu.d.ts.map +1 -1
- package/dist/types/src/components/Menu/DropdownMenu.stories.d.ts +14 -1
- package/dist/types/src/components/Menu/DropdownMenu.stories.d.ts.map +1 -1
- package/dist/types/src/components/Message/Message.d.ts +1 -1
- package/dist/types/src/components/Message/Message.d.ts.map +1 -1
- package/dist/types/src/components/Message/Message.stories.d.ts +4 -5
- package/dist/types/src/components/Message/Message.stories.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.d.ts +39 -22
- package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts +12 -11
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts +21 -10
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScrollContainer/ScrollContainer.d.ts +42 -13
- package/dist/types/src/components/ScrollContainer/ScrollContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScrollContainer/ScrollContainer.stories.d.ts +9 -5
- package/dist/types/src/components/ScrollContainer/ScrollContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/Select/Select.d.ts.map +1 -1
- package/dist/types/src/components/Select/Select.stories.d.ts +2 -2
- package/dist/types/src/components/Select/Select.stories.d.ts.map +1 -1
- package/dist/types/src/components/Separator/Separator.d.ts +3 -3
- package/dist/types/src/components/Separator/Separator.d.ts.map +1 -1
- package/dist/types/src/components/Skeleton/Skeleton.stories.d.ts.map +1 -1
- package/dist/types/src/components/Splitter/Splitter.d.ts +23 -15
- package/dist/types/src/components/Splitter/Splitter.d.ts.map +1 -1
- package/dist/types/src/components/Splitter/Splitter.stories.d.ts.map +1 -1
- package/dist/types/src/components/Status/Status.d.ts +3 -4
- package/dist/types/src/components/Status/Status.d.ts.map +1 -1
- package/dist/types/src/components/Status/Status.stories.d.ts +4 -2
- package/dist/types/src/components/Status/Status.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tag/Tag.d.ts.map +1 -1
- package/dist/types/src/components/Tag/Tag.stories.d.ts +0 -5
- package/dist/types/src/components/Tag/Tag.stories.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts +1 -1
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/ThemeProvider.stories.d.ts +12 -0
- package/dist/types/src/components/ThemeProvider/ThemeProvider.stories.d.ts.map +1 -0
- package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts +54 -55
- package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/index.d.ts +1 -1
- package/dist/types/src/components/ThemeProvider/index.d.ts.map +1 -1
- package/dist/types/src/components/Toast/Toast.d.ts +16 -16
- package/dist/types/src/components/Toast/Toast.d.ts.map +1 -1
- package/dist/types/src/components/Toast/Toast.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +32 -15
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.d.ts +16 -16
- package/dist/types/src/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts +2 -2
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +9 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/exemplars/generics.stories.d.ts +8 -6
- package/dist/types/src/exemplars/generics.stories.d.ts.map +1 -1
- package/dist/types/src/exemplars/slot.stories.d.ts +1 -0
- package/dist/types/src/exemplars/slot.stories.d.ts.map +1 -1
- package/dist/types/src/exemplars/tabster.stories.d.ts.map +1 -1
- package/dist/types/src/exemplars/virtualizer.stories.d.ts +11 -0
- package/dist/types/src/exemplars/virtualizer.stories.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useDensityContext.d.ts +1 -1
- package/dist/types/src/hooks/useDensityContext.d.ts.map +1 -1
- package/dist/types/src/hooks/useElevationContext.d.ts.map +1 -1
- package/dist/types/src/hooks/useIconHref.d.ts.map +1 -1
- package/dist/types/src/hooks/useSafeArea.d.ts.map +1 -1
- package/dist/types/src/hooks/useSafeCollisionPadding.d.ts.map +1 -1
- package/dist/types/src/hooks/useVisualViewport.d.ts.map +1 -1
- package/dist/types/src/playground/Controls.stories.d.ts.map +1 -1
- package/dist/types/src/playground/Custom.stories.d.ts +1 -1
- package/dist/types/src/playground/Custom.stories.d.ts.map +1 -1
- package/dist/types/src/playground/Typography.stories.d.ts.map +1 -1
- package/dist/types/src/primitives/Column/Column.d.ts +33 -0
- package/dist/types/src/primitives/Column/Column.d.ts.map +1 -0
- package/dist/types/src/primitives/Column/Column.stories.d.ts +25 -0
- package/dist/types/src/primitives/Column/Column.stories.d.ts.map +1 -0
- package/dist/types/src/primitives/Column/index.d.ts +2 -0
- package/dist/types/src/primitives/Column/index.d.ts.map +1 -0
- package/dist/types/src/primitives/Container/Container.d.ts +6 -22
- package/dist/types/src/primitives/Container/Container.d.ts.map +1 -1
- package/dist/types/src/primitives/Container/Container.stories.d.ts +2 -7
- package/dist/types/src/primitives/Container/Container.stories.d.ts.map +1 -1
- package/dist/types/src/primitives/Container/index.d.ts +0 -1
- package/dist/types/src/primitives/Container/index.d.ts.map +1 -1
- package/dist/types/src/primitives/Flex/Flex.d.ts +8 -5
- package/dist/types/src/primitives/Flex/Flex.d.ts.map +1 -1
- package/dist/types/src/primitives/Flex/Flex.stories.d.ts +8 -0
- package/dist/types/src/primitives/Flex/Flex.stories.d.ts.map +1 -0
- package/dist/types/src/primitives/Grid/Grid.d.ts +10 -0
- package/dist/types/src/primitives/Grid/Grid.d.ts.map +1 -0
- package/dist/types/src/primitives/Grid/Grid.stories.d.ts +8 -0
- package/dist/types/src/primitives/Grid/Grid.stories.d.ts.map +1 -0
- package/dist/types/src/primitives/Grid/index.d.ts +2 -0
- package/dist/types/src/primitives/Grid/index.d.ts.map +1 -0
- package/dist/types/src/primitives/Panel/Panel.d.ts +35 -0
- package/dist/types/src/primitives/Panel/Panel.d.ts.map +1 -0
- package/dist/types/src/primitives/Panel/Panel.stories.d.ts +6 -0
- package/dist/types/src/primitives/Panel/Panel.stories.d.ts.map +1 -0
- package/dist/types/src/primitives/Panel/index.d.ts +2 -0
- package/dist/types/src/primitives/Panel/index.d.ts.map +1 -0
- package/dist/types/src/primitives/index.d.ts +3 -0
- package/dist/types/src/primitives/index.d.ts.map +1 -1
- package/dist/types/src/testing/Loading.d.ts +9 -0
- package/dist/types/src/testing/Loading.d.ts.map +1 -0
- package/dist/types/src/testing/decorators/withLayout.d.ts +1 -1
- package/dist/types/src/testing/decorators/withLayout.d.ts.map +1 -1
- package/dist/types/src/testing/decorators/withLayoutVariants.d.ts.map +1 -1
- package/dist/types/src/testing/decorators/withTheme.d.ts +1 -1
- package/dist/types/src/testing/decorators/withTheme.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +16 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/src/util/usePx.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +34 -27
- package/src/components/Avatars/Avatar.stories.tsx +5 -7
- package/src/components/Avatars/Avatar.tsx +6 -14
- package/src/components/Avatars/AvatarGroup.stories.tsx +0 -1
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +1 -2
- package/src/components/Breadcrumb/Breadcrumb.tsx +11 -37
- package/src/components/Button/Button.stories.tsx +1 -2
- package/src/components/Button/Button.tsx +11 -25
- package/src/components/Button/IconButton.stories.tsx +6 -4
- package/src/components/Button/IconButton.tsx +3 -4
- package/src/components/Button/Toggle.stories.tsx +0 -1
- package/src/components/Button/Toggle.tsx +4 -4
- package/src/components/Button/ToggleGroup.stories.tsx +0 -1
- package/src/components/Button/ToggleGroup.tsx +12 -16
- package/src/components/Card/Card.stories.tsx +151 -0
- package/src/components/Card/Card.tsx +514 -0
- package/src/components/Card/index.ts +5 -0
- package/src/components/Carousel/Carousel.tsx +337 -0
- package/src/components/Carousel/index.ts +5 -0
- package/src/components/Clipboard/CopyButton.tsx +6 -7
- package/src/components/Dialog/AlertDialog.stories.tsx +14 -15
- package/src/components/Dialog/AlertDialog.tsx +123 -82
- package/src/components/Dialog/Dialog.stories.tsx +90 -14
- package/src/components/Dialog/Dialog.tsx +98 -113
- package/src/components/ErrorFallback/ErrorFallback.stories.tsx +45 -0
- package/src/components/ErrorFallback/ErrorFallback.tsx +70 -0
- package/src/components/ErrorFallback/ErrorStack.tsx +114 -0
- package/src/components/ErrorFallback/ThrowError.tsx +37 -0
- package/src/components/ErrorFallback/index.ts +9 -0
- package/src/components/Focus/AUDIT.md +43 -0
- package/src/components/Focus/Focus.stories.tsx +230 -0
- package/src/components/Focus/Focus.tsx +201 -0
- package/src/components/Focus/index.ts +5 -0
- package/src/components/Icon/Icon.stories.tsx +43 -13
- package/src/components/Icon/Icon.tsx +14 -3
- package/src/components/Image/Image.stories.tsx +86 -0
- package/src/components/Image/Image.tsx +246 -0
- package/src/components/Image/index.ts +5 -0
- package/src/components/Input/Input.stories.tsx +17 -38
- package/src/components/Input/Input.tsx +27 -71
- package/src/components/Link/Link.stories.tsx +0 -1
- package/src/components/Link/Link.tsx +2 -2
- package/src/components/List/List.stories.tsx +14 -22
- package/src/components/List/List.tsx +16 -20
- package/src/components/List/ListDropIndicator.tsx +7 -8
- package/src/components/List/Tree.stories.tsx +4 -5
- package/src/components/List/Tree.tsx +0 -1
- package/src/components/List/TreeDropIndicator.tsx +6 -6
- package/src/components/List/Treegrid.stories.tsx +27 -28
- package/src/components/List/Treegrid.tsx +22 -27
- package/src/components/Main/Main.stories.tsx +3 -7
- package/src/components/Main/Main.tsx +57 -48
- package/src/components/MediaPlayer/MediaPlayer.stories.tsx +50 -0
- package/src/components/MediaPlayer/MediaPlayer.tsx +153 -0
- package/src/components/MediaPlayer/index.ts +5 -0
- package/src/components/Menu/ContextMenu.stories.tsx +0 -1
- package/src/components/Menu/ContextMenu.tsx +9 -33
- package/src/components/Menu/DropdownMenu.stories.tsx +0 -1
- package/src/components/Menu/DropdownMenu.tsx +58 -52
- package/src/components/Message/Message.stories.tsx +25 -11
- package/src/components/Message/Message.tsx +30 -29
- package/src/components/Popover/Popover.stories.tsx +5 -6
- package/src/components/Popover/Popover.tsx +62 -59
- package/src/components/ScrollArea/ScrollArea.stories.tsx +98 -39
- package/src/components/ScrollArea/ScrollArea.tsx +45 -33
- package/src/components/ScrollContainer/ScrollContainer.stories.tsx +46 -25
- package/src/components/ScrollContainer/ScrollContainer.tsx +199 -92
- package/src/components/Select/Select.stories.tsx +5 -6
- package/src/components/Select/Select.tsx +11 -27
- package/src/components/Separator/Separator.tsx +5 -8
- package/src/components/Skeleton/Skeleton.stories.tsx +12 -13
- package/src/components/Skeleton/Skeleton.tsx +1 -1
- package/src/components/Splitter/Splitter.stories.tsx +47 -37
- package/src/components/Splitter/Splitter.tsx +44 -40
- package/src/components/Status/Status.stories.tsx +19 -16
- package/src/components/Status/Status.tsx +10 -7
- package/src/components/Tag/Tag.stories.tsx +3 -9
- package/src/components/Tag/Tag.tsx +2 -7
- package/src/components/ThemeProvider/ThemeProvider.stories.tsx +31 -0
- package/src/components/ThemeProvider/ThemeProvider.tsx +8 -7
- package/src/components/ThemeProvider/index.ts +1 -1
- package/src/components/Toast/Toast.stories.tsx +0 -1
- package/src/components/Toast/Toast.tsx +22 -41
- package/src/components/Toolbar/Toolbar.stories.tsx +0 -1
- package/src/components/Toolbar/Toolbar.tsx +175 -30
- package/src/components/Tooltip/Tooltip.stories.tsx +18 -17
- package/src/components/Tooltip/Tooltip.tsx +32 -31
- package/src/components/index.ts +10 -5
- package/src/exemplars/generics.stories.tsx +12 -15
- package/src/exemplars/slot.stories.tsx +68 -61
- package/src/exemplars/tabster.stories.tsx +5 -5
- package/src/exemplars/virtualizer.stories.tsx +136 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useDensityContext.ts +2 -2
- package/src/playground/Controls.stories.tsx +0 -6
- package/src/playground/Custom.stories.tsx +13 -16
- package/src/playground/Typography.stories.tsx +1 -1
- package/src/primitives/Column/AUDIT.md +148 -0
- package/src/primitives/Column/Column.stories.tsx +181 -0
- package/src/primitives/Column/Column.tsx +165 -0
- package/src/primitives/Column/index.ts +5 -0
- package/src/primitives/Container/Container.stories.tsx +13 -51
- package/src/primitives/Container/Container.tsx +14 -77
- package/src/primitives/Container/index.ts +0 -1
- package/src/primitives/Flex/Flex.stories.tsx +57 -0
- package/src/primitives/Flex/Flex.tsx +20 -19
- package/src/primitives/Grid/Grid.stories.tsx +56 -0
- package/src/primitives/Grid/Grid.tsx +30 -0
- package/src/primitives/Grid/index.ts +5 -0
- package/src/primitives/Panel/Panel.stories.tsx +68 -0
- package/src/primitives/Panel/Panel.tsx +120 -0
- package/src/primitives/Panel/index.ts +5 -0
- package/src/primitives/index.ts +3 -0
- package/src/testing/Loading.tsx +47 -0
- package/src/testing/decorators/withLayout.tsx +15 -11
- package/src/testing/decorators/withLayoutVariants.tsx +18 -21
- package/src/testing/decorators/withTheme.tsx +10 -7
- package/src/testing/index.ts +2 -0
- package/src/translations.ts +24 -0
- package/src/util/usePx.ts +1 -0
- package/dist/lib/browser/chunk-EJYV4HAH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YTLZCZ2M.mjs.map +0 -7
- package/dist/types/src/components/AnchoredOverflow/AnchoredOverflow.d.ts +0 -22
- package/dist/types/src/components/AnchoredOverflow/AnchoredOverflow.d.ts.map +0 -1
- package/dist/types/src/components/AnchoredOverflow/index.d.ts +0 -2
- package/dist/types/src/components/AnchoredOverflow/index.d.ts.map +0 -1
- package/dist/types/src/primitives/Container/Layout.d.ts +0 -18
- package/dist/types/src/primitives/Container/Layout.d.ts.map +0 -1
- package/dist/types/src/primitives/Container/Layout.stories.d.ts +0 -10
- package/dist/types/src/primitives/Container/Layout.stories.d.ts.map +0 -1
- package/src/components/AnchoredOverflow/AnchoredOverflow.tsx +0 -67
- package/src/components/AnchoredOverflow/index.ts +0 -5
- package/src/primitives/Container/Layout.stories.tsx +0 -57
- package/src/primitives/Container/Layout.tsx +0 -61
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { type SyntheticEvent, useCallback, useRef, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type ThemedClassName } from '@dxos/react-ui';
|
|
8
|
+
import { mx } from '@dxos/ui-theme';
|
|
9
|
+
|
|
10
|
+
const cache = new Map<string, string>();
|
|
11
|
+
|
|
12
|
+
export type ImageProps = ThemedClassName<
|
|
13
|
+
{
|
|
14
|
+
src: string;
|
|
15
|
+
alt?: string;
|
|
16
|
+
fit?: 'contain' | 'cover';
|
|
17
|
+
crossOrigin?: 'anonymous' | 'use-credentials' | '';
|
|
18
|
+
} & ColorOptions
|
|
19
|
+
>;
|
|
20
|
+
|
|
21
|
+
export const Image = ({
|
|
22
|
+
classNames,
|
|
23
|
+
src,
|
|
24
|
+
alt = '',
|
|
25
|
+
fit = 'contain',
|
|
26
|
+
crossOrigin = 'anonymous',
|
|
27
|
+
sampleSize = 64,
|
|
28
|
+
contrast = 0.9,
|
|
29
|
+
}: ImageProps) => {
|
|
30
|
+
const [crossOriginState, setCrossOriginState] = useState<ImageProps['crossOrigin']>(crossOrigin);
|
|
31
|
+
const [dominantColor, setDominantColor] = useState<string | undefined>(undefined);
|
|
32
|
+
const [imageLoaded, setImageLoaded] = useState<boolean>(false);
|
|
33
|
+
const canvasRef = useRef<HTMLCanvasElement>(null);
|
|
34
|
+
|
|
35
|
+
// CORS not supported by server.
|
|
36
|
+
const handleImageError = (): void => {
|
|
37
|
+
setCrossOriginState(undefined);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const handleImageLoad = useCallback(
|
|
41
|
+
({ target }: SyntheticEvent<HTMLImageElement>): void => {
|
|
42
|
+
const rgb = cache.get(src);
|
|
43
|
+
if (rgb) {
|
|
44
|
+
setDominantColor(rgb);
|
|
45
|
+
setImageLoaded(true);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const img = target as HTMLImageElement;
|
|
50
|
+
if (!canvasRef.current) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
const color = extractDominantColor(canvasRef.current, img, { sampleSize, contrast });
|
|
56
|
+
if (color) {
|
|
57
|
+
const rgb = `rgb(${color[0]}, ${color[1]}, ${color[2]})`;
|
|
58
|
+
cache.set(src, rgb);
|
|
59
|
+
setDominantColor(rgb);
|
|
60
|
+
}
|
|
61
|
+
} catch {
|
|
62
|
+
setCrossOriginState(undefined);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
setImageLoaded(true);
|
|
66
|
+
},
|
|
67
|
+
[sampleSize, contrast, src],
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<div
|
|
72
|
+
// `isolate` (`isolation: isolate`) creates a new stacking context so
|
|
73
|
+
// the inner <img>'s `z-10` stays scoped to this wrapper. Without it
|
|
74
|
+
// the z-10 leaks into the parent's stacking context and elevates the
|
|
75
|
+
// image above any pseudo-element rings (e.g. Focus.Item's
|
|
76
|
+
// `dx-ring-pseudo` `::after`) painted on ancestors — most visibly,
|
|
77
|
+
// the focus ring on a Card containing a Card.Poster.
|
|
78
|
+
className={mx(
|
|
79
|
+
`relative flex w-full justify-center overflow-hidden transition-all duration-700 isolate`,
|
|
80
|
+
classNames,
|
|
81
|
+
)}
|
|
82
|
+
style={{
|
|
83
|
+
backgroundColor: dominantColor,
|
|
84
|
+
}}
|
|
85
|
+
>
|
|
86
|
+
{/* Hidden canvas for color extraction. */}
|
|
87
|
+
<canvas ref={canvasRef} style={{ display: 'none' }} aria-hidden='true' />
|
|
88
|
+
|
|
89
|
+
{/* Background gradient overlay for smooth transition. */}
|
|
90
|
+
<div
|
|
91
|
+
className='absolute inset-0 pointer-events-none'
|
|
92
|
+
style={{
|
|
93
|
+
background: dominantColor
|
|
94
|
+
? `radial-gradient(circle at center, transparent 30%, ${dominantColor} 100%)`
|
|
95
|
+
: undefined,
|
|
96
|
+
transition: 'opacity 0.7s ease-in-out',
|
|
97
|
+
opacity: 0.5,
|
|
98
|
+
}}
|
|
99
|
+
/>
|
|
100
|
+
|
|
101
|
+
<img
|
|
102
|
+
src={src}
|
|
103
|
+
alt={alt}
|
|
104
|
+
crossOrigin={crossOriginState}
|
|
105
|
+
onError={handleImageError}
|
|
106
|
+
onLoad={handleImageLoad}
|
|
107
|
+
className={mx(
|
|
108
|
+
'z-10 transition-opacity duration-500',
|
|
109
|
+
fit === 'cover' ? 'w-full h-full object-cover' : 'object-contain',
|
|
110
|
+
)}
|
|
111
|
+
style={{
|
|
112
|
+
opacity: imageLoaded ? 1 : 0,
|
|
113
|
+
}}
|
|
114
|
+
/>
|
|
115
|
+
</div>
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
type ColorOptions = {
|
|
120
|
+
sampleSize?: number;
|
|
121
|
+
contrast?: number;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Get dominant color from image (esp. from corners).
|
|
126
|
+
*/
|
|
127
|
+
const extractDominantColor = (
|
|
128
|
+
canvas: HTMLCanvasElement,
|
|
129
|
+
img: HTMLImageElement,
|
|
130
|
+
{ sampleSize = 64, contrast = 0.95 }: ColorOptions,
|
|
131
|
+
): [number, number, number] | null => {
|
|
132
|
+
const ctx = canvas.getContext('2d');
|
|
133
|
+
if (!ctx) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Draw the image scaled down.
|
|
138
|
+
canvas.width = sampleSize;
|
|
139
|
+
canvas.height = sampleSize;
|
|
140
|
+
ctx.drawImage(img, 0, 0, sampleSize, sampleSize);
|
|
141
|
+
|
|
142
|
+
// Get image data.
|
|
143
|
+
const imageData = ctx.getImageData(0, 0, sampleSize, sampleSize);
|
|
144
|
+
const pixels = imageData.data;
|
|
145
|
+
|
|
146
|
+
// Check for transparent background.
|
|
147
|
+
if (isTransparent(pixels, sampleSize)) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
let r = 0;
|
|
152
|
+
let g = 0;
|
|
153
|
+
let b = 0;
|
|
154
|
+
let totalWeight = 0;
|
|
155
|
+
|
|
156
|
+
// Define corner sampling areas (e.g., 25% of each dimension from each corner).
|
|
157
|
+
const cornerSize = Math.floor(sampleSize * 0.125);
|
|
158
|
+
|
|
159
|
+
// Sample only pixels in corner areas.
|
|
160
|
+
for (let y = 0; y < sampleSize; y++) {
|
|
161
|
+
for (let x = 0; x < sampleSize; x++) {
|
|
162
|
+
// Check if pixel is in any corner area.
|
|
163
|
+
const isInTopLeft = x < cornerSize && y < cornerSize;
|
|
164
|
+
const isInTopRight = x >= sampleSize - cornerSize && y < cornerSize;
|
|
165
|
+
const isInBottomLeft = x < cornerSize && y >= sampleSize - cornerSize;
|
|
166
|
+
const isInBottomRight = x >= sampleSize - cornerSize && y >= sampleSize - cornerSize;
|
|
167
|
+
if (!isInTopLeft && !isInTopRight && !isInBottomLeft && !isInBottomRight) {
|
|
168
|
+
continue; // Skip pixels not in corner areas.
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const i = (y * sampleSize + x) * 4;
|
|
172
|
+
const red = pixels[i];
|
|
173
|
+
const green = pixels[i + 1];
|
|
174
|
+
const blue = pixels[i + 2];
|
|
175
|
+
const alpha = pixels[i + 3];
|
|
176
|
+
|
|
177
|
+
// Skip transparent pixels.
|
|
178
|
+
if (alpha === 0) {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Calculate saturation to weight vibrant colors more.
|
|
183
|
+
const max = Math.max(red, green, blue);
|
|
184
|
+
const min = Math.min(red, green, blue);
|
|
185
|
+
const saturation = max === 0 ? 0 : (max - min) / max;
|
|
186
|
+
const weight = 1 + saturation * 2;
|
|
187
|
+
|
|
188
|
+
r += red * weight;
|
|
189
|
+
g += green * weight;
|
|
190
|
+
b += blue * weight;
|
|
191
|
+
totalWeight += weight;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (totalWeight > 0) {
|
|
196
|
+
// Slightly darken the color for better contrast.
|
|
197
|
+
r = Math.round(Math.round(r / totalWeight) * contrast);
|
|
198
|
+
g = Math.round(Math.round(g / totalWeight) * contrast);
|
|
199
|
+
b = Math.round(Math.round(b / totalWeight) * contrast);
|
|
200
|
+
return [r, g, b];
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return null;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Detects if an image has a transparent background by examining edge pixels.
|
|
208
|
+
* @param pixels - Image pixel data from canvas
|
|
209
|
+
* @param sampleSize - Size of the sampled image
|
|
210
|
+
* @param threshold - Percentage threshold for considering background transparent (default: 0.5)
|
|
211
|
+
* @returns True if the image has a transparent background
|
|
212
|
+
*/
|
|
213
|
+
const isTransparent = (pixels: Uint8ClampedArray, sampleSize: number, threshold: number = 0.5): boolean => {
|
|
214
|
+
let edgeTransparentPixels = 0;
|
|
215
|
+
const edgePixels = sampleSize * 4 - 4; // Perimeter minus corners counted twice.
|
|
216
|
+
|
|
217
|
+
for (let x = 0; x < sampleSize; x++) {
|
|
218
|
+
// Top edge.
|
|
219
|
+
const topIndex = x * 4;
|
|
220
|
+
if (pixels[topIndex + 3] === 0) {
|
|
221
|
+
edgeTransparentPixels++;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Bottom edge.
|
|
225
|
+
const bottomIndex = ((sampleSize - 1) * sampleSize + x) * 4;
|
|
226
|
+
if (pixels[bottomIndex + 3] === 0) {
|
|
227
|
+
edgeTransparentPixels++;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
for (let y = 1; y < sampleSize - 1; y++) {
|
|
232
|
+
// Left edge.
|
|
233
|
+
const leftIndex = y * sampleSize * 4;
|
|
234
|
+
if (pixels[leftIndex + 3] === 0) {
|
|
235
|
+
edgeTransparentPixels++;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Right edge.
|
|
239
|
+
const rightIndex = (y * sampleSize + sampleSize - 1) * 4;
|
|
240
|
+
if (pixels[rightIndex + 3] === 0) {
|
|
241
|
+
edgeTransparentPixels++;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return edgeTransparentPixels / edgePixels > threshold;
|
|
246
|
+
};
|
|
@@ -5,11 +5,9 @@
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import { mx, surfaceShadow } from '@dxos/ui-theme';
|
|
9
8
|
import { type MessageValence } from '@dxos/ui-types';
|
|
10
9
|
|
|
11
|
-
import { withTheme } from '../../testing';
|
|
12
|
-
|
|
10
|
+
import { withLayoutVariants, withTheme } from '../../testing';
|
|
13
11
|
import {
|
|
14
12
|
type CheckboxProps,
|
|
15
13
|
Input,
|
|
@@ -29,7 +27,7 @@ type VariantMap = {
|
|
|
29
27
|
|
|
30
28
|
type Variant = { [K in keyof VariantMap]: { type: K } & VariantMap[K] }[keyof VariantMap];
|
|
31
29
|
|
|
32
|
-
type
|
|
30
|
+
type DefaultStoryProps = Partial<{
|
|
33
31
|
kind: keyof VariantMap;
|
|
34
32
|
label: string;
|
|
35
33
|
labelVisuallyHidden: boolean;
|
|
@@ -39,7 +37,7 @@ type BaseProps = Partial<{
|
|
|
39
37
|
validationMessage: string;
|
|
40
38
|
}>;
|
|
41
39
|
|
|
42
|
-
const
|
|
40
|
+
const DefaultStory = ({
|
|
43
41
|
kind,
|
|
44
42
|
label,
|
|
45
43
|
description,
|
|
@@ -48,7 +46,7 @@ const InputWrapper = ({
|
|
|
48
46
|
validationValence,
|
|
49
47
|
validationMessage,
|
|
50
48
|
...props
|
|
51
|
-
}:
|
|
49
|
+
}: DefaultStoryProps) => {
|
|
52
50
|
return (
|
|
53
51
|
<Input.Root {...{ validationValence }}>
|
|
54
52
|
<Input.Label srOnly={labelVisuallyHidden}>{label}</Input.Label>
|
|
@@ -60,48 +58,28 @@ const InputWrapper = ({
|
|
|
60
58
|
{kind === 'switch' && <Input.Switch {...props} />}
|
|
61
59
|
|
|
62
60
|
<Input.DescriptionAndValidation srOnly={descriptionVisuallyHidden}>
|
|
63
|
-
{validationMessage &&
|
|
64
|
-
<>
|
|
65
|
-
<Input.Validation>{validationMessage}</Input.Validation>{' '}
|
|
66
|
-
</>
|
|
67
|
-
)}
|
|
61
|
+
{validationMessage && <Input.Validation classNames='block'>{validationMessage}</Input.Validation>}
|
|
68
62
|
<Input.Description>{description}</Input.Description>
|
|
69
63
|
</Input.DescriptionAndValidation>
|
|
70
64
|
</Input.Root>
|
|
71
65
|
);
|
|
72
66
|
};
|
|
73
67
|
|
|
74
|
-
const DefaultStory = (props: BaseProps) => {
|
|
75
|
-
return (
|
|
76
|
-
<div className='space-b-4'>
|
|
77
|
-
<div className={mx('bg-baseSurface', 'p-4 rounded-md')}>
|
|
78
|
-
<InputWrapper {...props} />
|
|
79
|
-
</div>
|
|
80
|
-
<div className={mx('bg-cardSurface', 'p-4 rounded-md', surfaceShadow({ elevation: 'positioned' }))}>
|
|
81
|
-
<InputWrapper {...props} />
|
|
82
|
-
</div>
|
|
83
|
-
<div className={mx('bg-modalSurface', 'p-4 rounded-md', surfaceShadow({ elevation: 'dialog' }))}>
|
|
84
|
-
<InputWrapper {...props} />
|
|
85
|
-
</div>
|
|
86
|
-
</div>
|
|
87
|
-
);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
68
|
const meta = {
|
|
91
69
|
title: 'ui/react-ui-core/components/Input',
|
|
92
70
|
component: Input.Root as any,
|
|
93
71
|
render: DefaultStory,
|
|
94
|
-
decorators: [withTheme()],
|
|
72
|
+
decorators: [withTheme(), withLayoutVariants()],
|
|
95
73
|
} satisfies Meta<typeof DefaultStory>;
|
|
96
74
|
|
|
97
75
|
export default meta;
|
|
98
76
|
|
|
99
|
-
type Story = StoryObj<
|
|
77
|
+
type Story = StoryObj<DefaultStoryProps & Variant>;
|
|
100
78
|
|
|
101
79
|
export const DensityCoarse: Story = {
|
|
102
80
|
args: {
|
|
103
81
|
kind: 'text',
|
|
104
|
-
label: '
|
|
82
|
+
label: 'Input value',
|
|
105
83
|
placeholder: 'This is an input',
|
|
106
84
|
disabled: false,
|
|
107
85
|
description: undefined,
|
|
@@ -116,7 +94,7 @@ export const DensityCoarse: Story = {
|
|
|
116
94
|
export const DensityFine: Story = {
|
|
117
95
|
args: {
|
|
118
96
|
kind: 'text',
|
|
119
|
-
label: '
|
|
97
|
+
label: 'Input value',
|
|
120
98
|
placeholder: 'This is a density:fine input',
|
|
121
99
|
disabled: false,
|
|
122
100
|
description: undefined,
|
|
@@ -131,7 +109,7 @@ export const DensityFine: Story = {
|
|
|
131
109
|
export const Subdued: Story = {
|
|
132
110
|
args: {
|
|
133
111
|
kind: 'text',
|
|
134
|
-
label: '
|
|
112
|
+
label: 'Input value',
|
|
135
113
|
placeholder: 'This is a subdued input',
|
|
136
114
|
disabled: false,
|
|
137
115
|
description: undefined,
|
|
@@ -161,7 +139,7 @@ export const LabelVisuallyHidden: Story = {
|
|
|
161
139
|
},
|
|
162
140
|
};
|
|
163
141
|
|
|
164
|
-
export const
|
|
142
|
+
export const WithDescription: Story = {
|
|
165
143
|
args: {
|
|
166
144
|
kind: 'text',
|
|
167
145
|
label: 'Described input',
|
|
@@ -170,7 +148,7 @@ export const InputWithDescription: Story = {
|
|
|
170
148
|
},
|
|
171
149
|
};
|
|
172
150
|
|
|
173
|
-
export const
|
|
151
|
+
export const WithErrorAndDescription: Story = {
|
|
174
152
|
args: {
|
|
175
153
|
kind: 'text',
|
|
176
154
|
label: 'Described invalid input',
|
|
@@ -181,7 +159,7 @@ export const InputWithErrorAndDescription: Story = {
|
|
|
181
159
|
},
|
|
182
160
|
};
|
|
183
161
|
|
|
184
|
-
export const
|
|
162
|
+
export const WithValidationAndDescription: Story = {
|
|
185
163
|
args: {
|
|
186
164
|
kind: 'text',
|
|
187
165
|
label: 'Described input with validation message',
|
|
@@ -207,7 +185,8 @@ export const PinInput: Story = {
|
|
|
207
185
|
label: 'This input is a PIN-style input',
|
|
208
186
|
length: 6,
|
|
209
187
|
description: 'Type in secret you received',
|
|
210
|
-
|
|
188
|
+
pattern: '\\d*',
|
|
189
|
+
density: 'coarse',
|
|
211
190
|
},
|
|
212
191
|
};
|
|
213
192
|
|
|
@@ -215,7 +194,7 @@ export const Checkbox: Story = {
|
|
|
215
194
|
args: {
|
|
216
195
|
kind: 'checkbox',
|
|
217
196
|
label: 'This is a checkbox',
|
|
218
|
-
description: '
|
|
197
|
+
description: 'Checked, indeterminate, or unchecked',
|
|
219
198
|
size: 5,
|
|
220
199
|
},
|
|
221
200
|
};
|
|
@@ -224,6 +203,6 @@ export const Switch: Story = {
|
|
|
224
203
|
args: {
|
|
225
204
|
kind: 'switch',
|
|
226
205
|
label: 'This is a switch',
|
|
227
|
-
description:
|
|
206
|
+
description: 'On or off',
|
|
228
207
|
},
|
|
229
208
|
};
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
6
6
|
import { useControllableState } from '@radix-ui/react-use-controllable-state';
|
|
7
|
-
import React, { type ComponentPropsWithRef, type ForwardRefExoticComponent, forwardRef
|
|
7
|
+
import React, { type ComponentPropsWithRef, type ForwardRefExoticComponent, forwardRef } from 'react';
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
10
|
DescriptionAndValidation as DescriptionAndValidationPrimitive,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
useInputContext,
|
|
29
29
|
} from '@dxos/react-input';
|
|
30
30
|
import { mx } from '@dxos/ui-theme';
|
|
31
|
-
import { type
|
|
31
|
+
import { type Density, type Elevation, type Size } from '@dxos/ui-types';
|
|
32
32
|
|
|
33
33
|
import { useDensityContext, useElevationContext, useThemeContext } from '../../hooks';
|
|
34
34
|
import { type ThemedClassName } from '../../util';
|
|
@@ -40,10 +40,10 @@ type InputSharedProps = Partial<{ density: Density; elevation: Elevation; varian
|
|
|
40
40
|
|
|
41
41
|
type LabelProps = ThemedClassName<LabelPrimitiveProps> & { srOnly?: boolean };
|
|
42
42
|
|
|
43
|
-
const Label = forwardRef<HTMLLabelElement, LabelProps>(({
|
|
43
|
+
const Label = forwardRef<HTMLLabelElement, LabelProps>(({ classNames, children, srOnly, ...props }, forwardedRef) => {
|
|
44
44
|
const { tx } = useThemeContext();
|
|
45
45
|
return (
|
|
46
|
-
<LabelPrimitive {...props} className={tx('input.label',
|
|
46
|
+
<LabelPrimitive {...props} className={tx('input.label', { srOnly }, classNames)} ref={forwardedRef}>
|
|
47
47
|
{children}
|
|
48
48
|
</LabelPrimitive>
|
|
49
49
|
);
|
|
@@ -52,14 +52,10 @@ const Label = forwardRef<HTMLLabelElement, LabelProps>(({ srOnly, classNames, ch
|
|
|
52
52
|
type DescriptionProps = ThemedClassName<DescriptionPrimitiveProps> & { srOnly?: boolean };
|
|
53
53
|
|
|
54
54
|
const Description = forwardRef<HTMLSpanElement, DescriptionProps>(
|
|
55
|
-
({
|
|
55
|
+
({ classNames, children, srOnly, ...props }, forwardedRef) => {
|
|
56
56
|
const { tx } = useThemeContext();
|
|
57
57
|
return (
|
|
58
|
-
<DescriptionPrimitive
|
|
59
|
-
{...props}
|
|
60
|
-
className={tx('input.description', 'input__description', { srOnly }, classNames)}
|
|
61
|
-
ref={forwardedRef}
|
|
62
|
-
>
|
|
58
|
+
<DescriptionPrimitive {...props} className={tx('input.description', { srOnly }, classNames)} ref={forwardedRef}>
|
|
63
59
|
{children}
|
|
64
60
|
</DescriptionPrimitive>
|
|
65
61
|
);
|
|
@@ -69,18 +65,13 @@ const Description = forwardRef<HTMLSpanElement, DescriptionProps>(
|
|
|
69
65
|
type ValidationProps = ThemedClassName<ValidationPrimitiveProps> & { srOnly?: boolean };
|
|
70
66
|
|
|
71
67
|
const Validation = forwardRef<HTMLSpanElement, InputScopedProps<ValidationProps>>(
|
|
72
|
-
({ __inputScope,
|
|
68
|
+
({ __inputScope, classNames, children, srOnly, ...props }, forwardedRef) => {
|
|
73
69
|
const { tx } = useThemeContext();
|
|
74
70
|
const { validationValence } = useInputContext(INPUT_NAME, __inputScope);
|
|
75
71
|
return (
|
|
76
72
|
<ValidationPrimitive
|
|
77
73
|
{...props}
|
|
78
|
-
className={tx(
|
|
79
|
-
'input.validation',
|
|
80
|
-
`input__validation-message input__validation-message--${validationValence}`,
|
|
81
|
-
{ srOnly, validationValence },
|
|
82
|
-
classNames,
|
|
83
|
-
)}
|
|
74
|
+
className={tx('input.validation', { srOnly, validationValence }, classNames)}
|
|
84
75
|
ref={forwardedRef}
|
|
85
76
|
>
|
|
86
77
|
{children}
|
|
@@ -92,12 +83,12 @@ const Validation = forwardRef<HTMLSpanElement, InputScopedProps<ValidationProps>
|
|
|
92
83
|
type DescriptionAndValidationProps = ThemedClassName<DescriptionAndValidationPrimitiveProps> & { srOnly?: boolean };
|
|
93
84
|
|
|
94
85
|
const DescriptionAndValidation = forwardRef<HTMLParagraphElement, DescriptionAndValidationProps>(
|
|
95
|
-
({
|
|
86
|
+
({ classNames, children, srOnly, ...props }, forwardedRef) => {
|
|
96
87
|
const { tx } = useThemeContext();
|
|
97
88
|
return (
|
|
98
89
|
<DescriptionAndValidationPrimitive
|
|
99
90
|
{...props}
|
|
100
|
-
className={tx('input.descriptionAndValidation',
|
|
91
|
+
className={tx('input.descriptionAndValidation', { srOnly }, classNames)}
|
|
101
92
|
ref={forwardedRef}
|
|
102
93
|
>
|
|
103
94
|
{children}
|
|
@@ -106,53 +97,23 @@ const DescriptionAndValidation = forwardRef<HTMLParagraphElement, DescriptionAnd
|
|
|
106
97
|
},
|
|
107
98
|
);
|
|
108
99
|
|
|
109
|
-
type PinInputProps = InputSharedProps &
|
|
110
|
-
Omit<PinInputPrimitiveProps, 'segmentClassName' | 'inputClassName'> & {
|
|
111
|
-
segmentClassName?: ClassNameValue;
|
|
112
|
-
inputClassName?: ClassNameValue;
|
|
113
|
-
};
|
|
100
|
+
type PinInputProps = ThemedClassName<InputSharedProps & Omit<PinInputPrimitiveProps, 'className' | 'segmentClassName'>>;
|
|
114
101
|
|
|
115
102
|
const PinInput = forwardRef<HTMLInputElement, PinInputProps>(
|
|
116
|
-
(
|
|
117
|
-
{
|
|
118
|
-
density: propsDensity,
|
|
119
|
-
elevation: propsElevation,
|
|
120
|
-
segmentClassName: propsSegmentClassName,
|
|
121
|
-
inputClassName,
|
|
122
|
-
...props
|
|
123
|
-
},
|
|
124
|
-
forwardedRef,
|
|
125
|
-
) => {
|
|
103
|
+
({ classNames, density: propsDensity, elevation: propsElevation, ...props }, forwardedRef) => {
|
|
126
104
|
const { hasIosKeyboard } = useThemeContext();
|
|
127
105
|
const { tx } = useThemeContext();
|
|
128
106
|
const density = useDensityContext(propsDensity);
|
|
129
107
|
const elevation = useElevationContext(propsElevation);
|
|
130
108
|
|
|
131
|
-
const segmentClassName = useCallback(
|
|
132
|
-
({ focused, validationValence }: Parameters<Exclude<PinInputPrimitiveProps['segmentClassName'], undefined>>[0]) =>
|
|
133
|
-
tx(
|
|
134
|
-
'input.input',
|
|
135
|
-
'input--pin-segment',
|
|
136
|
-
{
|
|
137
|
-
variant: 'static',
|
|
138
|
-
focused,
|
|
139
|
-
disabled: props.disabled,
|
|
140
|
-
density,
|
|
141
|
-
elevation,
|
|
142
|
-
validationValence,
|
|
143
|
-
},
|
|
144
|
-
propsSegmentClassName,
|
|
145
|
-
),
|
|
146
|
-
[tx, props.disabled, elevation, propsElevation, density],
|
|
147
|
-
);
|
|
148
109
|
return (
|
|
149
110
|
<PinInputPrimitive
|
|
150
111
|
{...{
|
|
151
112
|
...props,
|
|
152
|
-
segmentClassName,
|
|
153
113
|
...(props.autoFocus && !hasIosKeyboard && { autoFocus: true }),
|
|
154
114
|
}}
|
|
155
|
-
|
|
115
|
+
className={tx('input.inputWithSegments', { disabled: props.disabled }, classNames) || ''}
|
|
116
|
+
segmentClassName={tx('input.segment', { disabled: props.disabled, density, elevation }) || ''}
|
|
156
117
|
ref={forwardedRef}
|
|
157
118
|
/>
|
|
158
119
|
);
|
|
@@ -169,17 +130,15 @@ type TextInputProps = InputSharedProps & ThemedClassName<TextInputPrimitiveProps
|
|
|
169
130
|
|
|
170
131
|
const TextInput = forwardRef<HTMLInputElement, InputScopedProps<TextInputProps>>(
|
|
171
132
|
(
|
|
172
|
-
{ __inputScope, classNames, density:
|
|
133
|
+
{ __inputScope, classNames, density: densityProp, elevation: elevationProp, variant, noAutoFill, ...props },
|
|
173
134
|
forwardedRef,
|
|
174
135
|
) => {
|
|
175
136
|
const { hasIosKeyboard } = useThemeContext();
|
|
176
|
-
const
|
|
177
|
-
const density = useDensityContext(
|
|
178
|
-
const elevation = useElevationContext(
|
|
137
|
+
const { tx } = useThemeContext();
|
|
138
|
+
const density = useDensityContext(densityProp);
|
|
139
|
+
const elevation = useElevationContext(elevationProp);
|
|
179
140
|
const { validationValence } = useInputContext(INPUT_NAME, __inputScope);
|
|
180
141
|
|
|
181
|
-
const { tx } = themeContextValue;
|
|
182
|
-
|
|
183
142
|
return (
|
|
184
143
|
<TextInputPrimitive
|
|
185
144
|
{...props}
|
|
@@ -187,7 +146,6 @@ const TextInput = forwardRef<HTMLInputElement, InputScopedProps<TextInputProps>>
|
|
|
187
146
|
{...{ 'data-1p-ignore': noAutoFill }}
|
|
188
147
|
className={tx(
|
|
189
148
|
'input.input',
|
|
190
|
-
'input',
|
|
191
149
|
{
|
|
192
150
|
variant,
|
|
193
151
|
disabled: props.disabled,
|
|
@@ -218,8 +176,7 @@ const TextArea = forwardRef<HTMLTextAreaElement, InputScopedProps<TextAreaProps>
|
|
|
218
176
|
<TextAreaPrimitive
|
|
219
177
|
{...props}
|
|
220
178
|
className={tx(
|
|
221
|
-
'input.
|
|
222
|
-
'input--text-area',
|
|
179
|
+
'input.textArea',
|
|
223
180
|
{
|
|
224
181
|
variant,
|
|
225
182
|
disabled: props.disabled,
|
|
@@ -227,7 +184,6 @@ const TextArea = forwardRef<HTMLTextAreaElement, InputScopedProps<TextAreaProps>
|
|
|
227
184
|
elevation,
|
|
228
185
|
validationValence,
|
|
229
186
|
},
|
|
230
|
-
'-mbe-labelSpacingBlock',
|
|
231
187
|
classNames,
|
|
232
188
|
)}
|
|
233
189
|
{...(props.autoFocus && !hasIosKeyboard && { autoFocus: true })}
|
|
@@ -237,7 +193,7 @@ const TextArea = forwardRef<HTMLTextAreaElement, InputScopedProps<TextAreaProps>
|
|
|
237
193
|
},
|
|
238
194
|
);
|
|
239
195
|
|
|
240
|
-
type CheckboxProps = ThemedClassName<Omit<
|
|
196
|
+
type CheckboxProps = ThemedClassName<Omit<CheckboxPrimitive.CheckboxProps, 'children'>> & {
|
|
241
197
|
size?: Size;
|
|
242
198
|
};
|
|
243
199
|
|
|
@@ -248,11 +204,11 @@ const Checkbox: ForwardRefExoticComponent<CheckboxProps> = forwardRef<
|
|
|
248
204
|
(
|
|
249
205
|
{
|
|
250
206
|
__inputScope,
|
|
207
|
+
classNames,
|
|
251
208
|
checked: propsChecked,
|
|
252
209
|
defaultChecked: propsDefaultChecked,
|
|
253
210
|
onCheckedChange: propsOnCheckedChange,
|
|
254
211
|
size,
|
|
255
|
-
classNames,
|
|
256
212
|
...props
|
|
257
213
|
},
|
|
258
214
|
forwardedRef,
|
|
@@ -266,7 +222,7 @@ const Checkbox: ForwardRefExoticComponent<CheckboxProps> = forwardRef<
|
|
|
266
222
|
const { tx } = useThemeContext();
|
|
267
223
|
|
|
268
224
|
return (
|
|
269
|
-
<CheckboxPrimitive
|
|
225
|
+
<CheckboxPrimitive.Root
|
|
270
226
|
{...{
|
|
271
227
|
...props,
|
|
272
228
|
checked,
|
|
@@ -277,15 +233,15 @@ const Checkbox: ForwardRefExoticComponent<CheckboxProps> = forwardRef<
|
|
|
277
233
|
'aria-invalid': 'true' as const,
|
|
278
234
|
'aria-errormessage': errorMessageId,
|
|
279
235
|
}),
|
|
280
|
-
className: tx('input.checkbox',
|
|
236
|
+
className: tx('input.checkbox', { size }, 'shrink-0', classNames),
|
|
281
237
|
}}
|
|
282
238
|
ref={forwardedRef}
|
|
283
239
|
>
|
|
284
240
|
<Icon
|
|
285
241
|
icon={checked === 'indeterminate' ? 'ph--minus--regular' : 'ph--check--regular'}
|
|
286
|
-
classNames={tx('input.checkboxIndicator',
|
|
242
|
+
classNames={tx('input.checkboxIndicator', { size, checked })}
|
|
287
243
|
/>
|
|
288
|
-
</CheckboxPrimitive>
|
|
244
|
+
</CheckboxPrimitive.Root>
|
|
289
245
|
);
|
|
290
246
|
},
|
|
291
247
|
);
|
|
@@ -298,10 +254,10 @@ const Switch = forwardRef<HTMLInputElement, InputScopedProps<SwitchProps>>(
|
|
|
298
254
|
(
|
|
299
255
|
{
|
|
300
256
|
__inputScope,
|
|
257
|
+
classNames,
|
|
301
258
|
checked: propsChecked,
|
|
302
259
|
defaultChecked: propsDefaultChecked,
|
|
303
260
|
onCheckedChange: propsOnCheckedChange,
|
|
304
|
-
classNames,
|
|
305
261
|
...props
|
|
306
262
|
},
|
|
307
263
|
forwardedRef,
|
|
@@ -18,7 +18,7 @@ export type LinkProps = ThemedClassName<ComponentPropsWithRef<typeof Primitive.a
|
|
|
18
18
|
export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
|
|
19
19
|
({ asChild, variant, classNames, ...props }, forwardedRef) => {
|
|
20
20
|
const { tx } = useThemeContext();
|
|
21
|
-
const
|
|
22
|
-
return <
|
|
21
|
+
const Comp = asChild ? Slot : Primitive.a;
|
|
22
|
+
return <Comp {...props} className={tx('link.root', { variant }, classNames)} ref={forwardedRef} />;
|
|
23
23
|
},
|
|
24
24
|
);
|