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