@dxos/react-ui-pickers 0.8.4-main.ead640a → 0.8.4-main.ef1bc66f44
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-IEOELSPW.mjs +64 -0
- package/dist/lib/browser/chunk-IEOELSPW.mjs.map +7 -0
- package/dist/lib/browser/components/IconPicker/icons.mjs +9 -0
- package/dist/lib/browser/components/IconPicker/icons.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +195 -299
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/chunk-OLGXN23I.mjs +66 -0
- package/dist/lib/node-esm/chunk-OLGXN23I.mjs.map +7 -0
- package/dist/lib/node-esm/components/IconPicker/icons.mjs +10 -0
- package/dist/lib/node-esm/components/IconPicker/icons.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +194 -299
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/EmojiPicker/EmojiPicker.d.ts.map +1 -1
- package/dist/types/src/components/HuePicker/HuePicker.d.ts.map +1 -1
- package/dist/types/src/components/HuePicker/HuePicker.stories.d.ts +1 -1
- package/dist/types/src/components/IconPicker/IconPicker.d.ts +1 -1
- package/dist/types/src/components/IconPicker/IconPicker.d.ts.map +1 -1
- package/dist/types/src/components/IconPicker/IconPicker.stories.d.ts +1 -1
- package/dist/types/src/components/IconPicker/icons.d.ts +7 -0
- package/dist/types/src/components/IconPicker/icons.d.ts.map +1 -0
- package/dist/types/src/components/PickerButton/PickerButton.d.ts +2 -2
- package/dist/types/src/components/PickerButton/PickerButton.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +30 -17
- package/src/components/EmojiPicker/EmojiPicker.stories.tsx +1 -1
- package/src/components/EmojiPicker/EmojiPicker.tsx +22 -17
- package/src/components/HuePicker/HuePicker.stories.tsx +1 -1
- package/src/components/HuePicker/HuePicker.tsx +6 -10
- package/src/components/IconPicker/IconPicker.stories.tsx +1 -1
- package/src/components/IconPicker/IconPicker.tsx +7 -67
- package/src/components/IconPicker/icons.ts +66 -0
- package/src/components/PickerButton/PickerButton.tsx +8 -9
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-pickers",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.ef1bc66f44",
|
|
4
4
|
"description": "A collection of picker components.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
7
11
|
"license": "MIT",
|
|
8
12
|
"author": "DXOS.org",
|
|
9
13
|
"type": "module",
|
|
@@ -13,11 +17,21 @@
|
|
|
13
17
|
"types": "./dist/types/src/index.d.ts",
|
|
14
18
|
"browser": "./dist/lib/browser/index.mjs",
|
|
15
19
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
20
|
+
},
|
|
21
|
+
"./icons": {
|
|
22
|
+
"source": "./src/components/IconPicker/icons.ts",
|
|
23
|
+
"types": "./dist/types/src/components/IconPicker/icons.d.ts",
|
|
24
|
+
"browser": "./dist/lib/browser/components/IconPicker/icons.mjs",
|
|
25
|
+
"node": "./dist/lib/node-esm/components/IconPicker/icons.mjs"
|
|
16
26
|
}
|
|
17
27
|
},
|
|
18
28
|
"types": "dist/types/src/index.d.ts",
|
|
19
29
|
"typesVersions": {
|
|
20
|
-
"*": {
|
|
30
|
+
"*": {
|
|
31
|
+
"icons": [
|
|
32
|
+
"./dist/types/src/components/IconPicker/icons.d.ts"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
21
35
|
},
|
|
22
36
|
"files": [
|
|
23
37
|
"dist",
|
|
@@ -26,28 +40,27 @@
|
|
|
26
40
|
"dependencies": {
|
|
27
41
|
"@emoji-mart/data": "^1.1.2",
|
|
28
42
|
"@emoji-mart/react": "^1.1.1",
|
|
29
|
-
"@preact-signals/safe-react": "^0.9.0",
|
|
30
43
|
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
31
44
|
"react-resize-detector": "^11.0.1",
|
|
32
|
-
"@dxos/log": "0.8.4-main.
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/util": "0.8.4-main.
|
|
45
|
+
"@dxos/log": "0.8.4-main.ef1bc66f44",
|
|
46
|
+
"@dxos/ui-types": "0.8.4-main.ef1bc66f44",
|
|
47
|
+
"@dxos/util": "0.8.4-main.ef1bc66f44"
|
|
35
48
|
},
|
|
36
49
|
"devDependencies": {
|
|
37
|
-
"@types/react": "~19.2.
|
|
38
|
-
"@types/react-dom": "~19.2.
|
|
39
|
-
"react": "~19.2.
|
|
40
|
-
"react-dom": "~19.2.
|
|
50
|
+
"@types/react": "~19.2.7",
|
|
51
|
+
"@types/react-dom": "~19.2.3",
|
|
52
|
+
"react": "~19.2.3",
|
|
53
|
+
"react-dom": "~19.2.3",
|
|
41
54
|
"vite": "7.1.9",
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
55
|
+
"@dxos/ui-theme": "0.8.4-main.ef1bc66f44",
|
|
56
|
+
"@dxos/storybook-utils": "0.8.4-main.ef1bc66f44",
|
|
57
|
+
"@dxos/react-ui": "0.8.4-main.ef1bc66f44"
|
|
45
58
|
},
|
|
46
59
|
"peerDependencies": {
|
|
47
|
-
"react": "
|
|
48
|
-
"react-dom": "
|
|
49
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
50
|
-
"@dxos/
|
|
60
|
+
"react": "~19.2.3",
|
|
61
|
+
"react-dom": "~19.2.3",
|
|
62
|
+
"@dxos/react-ui": "0.8.4-main.ef1bc66f44",
|
|
63
|
+
"@dxos/ui-theme": "0.8.4-main.ef1bc66f44"
|
|
51
64
|
},
|
|
52
65
|
"publishConfig": {
|
|
53
66
|
"access": "public"
|
|
@@ -14,7 +14,7 @@ import { EmojiPickerBlock, type EmojiPickerProps, EmojiPickerToolbarButton } fro
|
|
|
14
14
|
const meta = {
|
|
15
15
|
title: 'ui/react-ui-pickers/EmojiPicker',
|
|
16
16
|
component: EmojiPicker,
|
|
17
|
-
decorators: [withTheme, withLayout({
|
|
17
|
+
decorators: [withTheme(), withLayout({ layout: 'column' })],
|
|
18
18
|
} satisfies Meta<typeof EmojiPicker>;
|
|
19
19
|
|
|
20
20
|
export default meta;
|
|
@@ -12,14 +12,15 @@ import {
|
|
|
12
12
|
ButtonGroup,
|
|
13
13
|
type ButtonProps,
|
|
14
14
|
Icon,
|
|
15
|
+
IconButton,
|
|
15
16
|
Popover,
|
|
16
17
|
type ThemedClassName,
|
|
17
18
|
Toolbar,
|
|
18
|
-
Tooltip,
|
|
19
19
|
useMediaQuery,
|
|
20
20
|
useThemeContext,
|
|
21
21
|
useTranslation,
|
|
22
22
|
} from '@dxos/react-ui';
|
|
23
|
+
import { osTranslations } from '@dxos/ui-theme';
|
|
23
24
|
|
|
24
25
|
import './emoji.css';
|
|
25
26
|
|
|
@@ -42,7 +43,7 @@ export const EmojiPickerToolbarButton = ({
|
|
|
42
43
|
defaultEmoji,
|
|
43
44
|
onChangeEmoji,
|
|
44
45
|
}: Omit<EmojiPickerProps, 'onClickClear'>) => {
|
|
45
|
-
const { t } = useTranslation(
|
|
46
|
+
const { t } = useTranslation(osTranslations);
|
|
46
47
|
const { themeMode } = useThemeContext();
|
|
47
48
|
|
|
48
49
|
const [_emojiValue, setEmojiValue] = useControllableState<string>({
|
|
@@ -60,14 +61,15 @@ export const EmojiPickerToolbarButton = ({
|
|
|
60
61
|
setEmojiPickerOpen(nextOpen);
|
|
61
62
|
}}
|
|
62
63
|
>
|
|
63
|
-
<
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
<Popover.Trigger asChild>
|
|
65
|
+
<Toolbar.IconButton
|
|
66
|
+
icon='ph--user-circle--regular'
|
|
67
|
+
label={t('select emoji label')}
|
|
68
|
+
iconOnly
|
|
69
|
+
tooltipSide='bottom'
|
|
70
|
+
disabled={disabled}
|
|
71
|
+
/>
|
|
72
|
+
</Popover.Trigger>
|
|
71
73
|
<Popover.Portal>
|
|
72
74
|
<Popover.Content
|
|
73
75
|
side='bottom'
|
|
@@ -111,7 +113,7 @@ export const EmojiPickerBlock = ({
|
|
|
111
113
|
triggerVariant = 'ghost',
|
|
112
114
|
classNames,
|
|
113
115
|
}: EmojiPickerProps) => {
|
|
114
|
-
const { t } = useTranslation(
|
|
116
|
+
const { t } = useTranslation(osTranslations);
|
|
115
117
|
const [isMd] = useMediaQuery('md');
|
|
116
118
|
|
|
117
119
|
const [emojiValue, setEmojiValue] = useControllableState<string>({
|
|
@@ -157,12 +159,15 @@ export const EmojiPickerBlock = ({
|
|
|
157
159
|
<Popover.Arrow />
|
|
158
160
|
</Popover.Content>
|
|
159
161
|
</Popover.Root>
|
|
160
|
-
<
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
<IconButton
|
|
163
|
+
icon='ph--arrow-counter-clockwise--regular'
|
|
164
|
+
iconOnly
|
|
165
|
+
label={t('clear label')}
|
|
166
|
+
tooltipSide='right'
|
|
167
|
+
variant={triggerVariant}
|
|
168
|
+
onClick={onClickClear}
|
|
169
|
+
disabled={disabled}
|
|
170
|
+
/>
|
|
166
171
|
</ButtonGroup>
|
|
167
172
|
);
|
|
168
173
|
};
|
|
@@ -30,7 +30,7 @@ const meta = {
|
|
|
30
30
|
title: 'ui/react-ui-pickers/HuePicker',
|
|
31
31
|
component: HuePicker,
|
|
32
32
|
render: DefaultStory,
|
|
33
|
-
decorators: [withTheme, withLayout({
|
|
33
|
+
decorators: [withTheme(), withLayout({ layout: 'column' })],
|
|
34
34
|
} satisfies Meta<typeof HuePicker>;
|
|
35
35
|
|
|
36
36
|
export default meta;
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { type ButtonProps, type ThemedClassName, useTranslation } from '@dxos/react-ui';
|
|
8
|
-
import { hues } from '@dxos/
|
|
7
|
+
import { type ButtonProps, type IconProps, type ThemedClassName, useTranslation } from '@dxos/react-ui';
|
|
8
|
+
import { getSize, hues, osTranslations } from '@dxos/ui-theme';
|
|
9
9
|
|
|
10
10
|
import { PickerButton, type PickerButtonProps } from '../PickerButton';
|
|
11
11
|
|
|
@@ -18,7 +18,7 @@ export type HuePickerProps = {
|
|
|
18
18
|
} & Pick<PickerButtonProps, 'disabled' | 'defaultValue' | 'value' | 'onChange' | 'onReset' | 'rootVariant'>;
|
|
19
19
|
|
|
20
20
|
export const HuePicker = (props: ThemedClassName<HuePickerProps>) => {
|
|
21
|
-
const { t } = useTranslation(
|
|
21
|
+
const { t } = useTranslation(osTranslations);
|
|
22
22
|
|
|
23
23
|
return (
|
|
24
24
|
<PickerButton
|
|
@@ -31,14 +31,10 @@ export const HuePicker = (props: ThemedClassName<HuePickerProps>) => {
|
|
|
31
31
|
);
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
const HuePreview = ({ value }: { value: string }) => {
|
|
35
|
-
const size = 16;
|
|
34
|
+
const HuePreview = ({ value, size = 5 }: { value: string; size?: IconProps['size'] }) => {
|
|
36
35
|
return (
|
|
37
|
-
<div className='flex
|
|
38
|
-
<svg
|
|
39
|
-
viewBox={`0 0 ${size} ${size}`}
|
|
40
|
-
className='is-[var(--hue-preview-size,1rem)] bs-[var(--hue-preview-size,1rem)]'
|
|
41
|
-
>
|
|
36
|
+
<div role='none' className='flex justify-center items-center'>
|
|
37
|
+
<svg viewBox={`0 0 ${size} ${size}`} className={getSize(size)}>
|
|
42
38
|
<rect x={0} y={0} width={size} height={size} fill={`var(--dx-${value}Fill)`} strokeWidth={4} />
|
|
43
39
|
</svg>
|
|
44
40
|
</div>
|
|
@@ -25,7 +25,7 @@ const meta = {
|
|
|
25
25
|
title: 'ui/react-ui-pickers/IconPicker',
|
|
26
26
|
component: IconPicker,
|
|
27
27
|
render: DefaultStory,
|
|
28
|
-
decorators: [withTheme, withLayout({
|
|
28
|
+
decorators: [withTheme(), withLayout({ layout: 'column' })],
|
|
29
29
|
} satisfies Meta<typeof IconPicker>;
|
|
30
30
|
|
|
31
31
|
export default meta;
|
|
@@ -5,9 +5,12 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
7
|
import { type ButtonProps, Icon, type IconProps, type ThemedClassName, useTranslation } from '@dxos/react-ui';
|
|
8
|
+
import { osTranslations } from '@dxos/ui-theme';
|
|
8
9
|
|
|
9
10
|
import { PickerButton, type PickerButtonProps } from '../PickerButton';
|
|
10
11
|
|
|
12
|
+
import { iconValues } from './icons';
|
|
13
|
+
|
|
11
14
|
export type IconPickerProps = {
|
|
12
15
|
disabled?: boolean;
|
|
13
16
|
defaultValue?: string;
|
|
@@ -16,11 +19,11 @@ export type IconPickerProps = {
|
|
|
16
19
|
onReset?: ButtonProps['onClick'];
|
|
17
20
|
} & Pick<
|
|
18
21
|
PickerButtonProps,
|
|
19
|
-
'disabled' | '
|
|
22
|
+
'disabled' | 'rootVariant' | 'iconSize' | 'defaultValue' | 'value' | 'onChange' | 'onReset'
|
|
20
23
|
>;
|
|
21
24
|
|
|
22
25
|
export const IconPicker = ({ ...props }: ThemedClassName<IconPickerProps>) => {
|
|
23
|
-
const { t } = useTranslation(
|
|
26
|
+
const { t } = useTranslation(osTranslations);
|
|
24
27
|
|
|
25
28
|
return (
|
|
26
29
|
<PickerButton
|
|
@@ -33,69 +36,6 @@ export const IconPicker = ({ ...props }: ThemedClassName<IconPickerProps>) => {
|
|
|
33
36
|
);
|
|
34
37
|
};
|
|
35
38
|
|
|
36
|
-
const IconPreview = ({ value,
|
|
37
|
-
return <Icon icon={`ph--${value}--regular`} size={
|
|
39
|
+
const IconPreview = ({ value, size }: { value: string; size?: IconProps['size'] }) => {
|
|
40
|
+
return <Icon icon={`ph--${value}--regular`} size={size} />;
|
|
38
41
|
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* https://phosphoricons.com
|
|
42
|
-
* NOTE: Select icons that we are unlikely to use for the UI.
|
|
43
|
-
*/
|
|
44
|
-
const icons = [
|
|
45
|
-
'ph--house-line--regular',
|
|
46
|
-
'ph--planet--regular',
|
|
47
|
-
'ph--piggy-bank--regular',
|
|
48
|
-
'ph--snowflake--regular',
|
|
49
|
-
'ph--virus--regular',
|
|
50
|
-
'ph--graph--regular',
|
|
51
|
-
'ph--air-traffic-control--regular',
|
|
52
|
-
'ph--asterisk--regular',
|
|
53
|
-
'ph--atom--regular',
|
|
54
|
-
'ph--basketball--regular',
|
|
55
|
-
'ph--butterfly--regular',
|
|
56
|
-
'ph--cactus--regular',
|
|
57
|
-
'ph--cake--regular',
|
|
58
|
-
'ph--calendar-dots--regular',
|
|
59
|
-
'ph--campfire--regular',
|
|
60
|
-
'ph--command--regular',
|
|
61
|
-
'ph--confetti--regular',
|
|
62
|
-
'ph--detective--regular',
|
|
63
|
-
'ph--disco-ball--regular',
|
|
64
|
-
'ph--dna--regular',
|
|
65
|
-
'ph--factory--regular',
|
|
66
|
-
'ph--flag-banner-fold--regular',
|
|
67
|
-
'ph--flask--regular',
|
|
68
|
-
'ph--flower-lotus--regular',
|
|
69
|
-
'ph--flying-saucer--regular',
|
|
70
|
-
'ph--game-controller--regular',
|
|
71
|
-
'ph--gavel--regular',
|
|
72
|
-
'ph--gift--regular',
|
|
73
|
-
'ph--guitar--regular',
|
|
74
|
-
'ph--hamburger--regular',
|
|
75
|
-
'ph--handshake--regular',
|
|
76
|
-
'ph--heart--regular',
|
|
77
|
-
'ph--lightbulb--regular',
|
|
78
|
-
'ph--lock--regular',
|
|
79
|
-
'ph--martini--regular',
|
|
80
|
-
'ph--medal-military--regular',
|
|
81
|
-
'ph--moped-front--regular',
|
|
82
|
-
'ph--office-chair--regular',
|
|
83
|
-
'ph--paint-brush-household--regular',
|
|
84
|
-
'ph--peace--regular',
|
|
85
|
-
'ph--person-simple-hike--regular',
|
|
86
|
-
'ph--piggy-bank--regular',
|
|
87
|
-
'ph--potted-plant--regular',
|
|
88
|
-
'ph--radioactive--regular',
|
|
89
|
-
'ph--rocket-launch--regular',
|
|
90
|
-
'ph--shield-star--regular',
|
|
91
|
-
'ph--shopping-cart--regular',
|
|
92
|
-
'ph--stethoscope--regular',
|
|
93
|
-
'ph--student--regular',
|
|
94
|
-
'ph--sun--regular',
|
|
95
|
-
'ph--tote--regular',
|
|
96
|
-
'ph--tree--regular',
|
|
97
|
-
'ph--users-three--regular',
|
|
98
|
-
'ph--yin-yang--regular',
|
|
99
|
-
];
|
|
100
|
-
|
|
101
|
-
const iconValues = icons.map((icon) => icon.match(/ph--(.+)--regular/)?.[1] ?? icon);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* https://phosphoricons.com
|
|
7
|
+
* NOTE: Select icons that we are unlikely to use for the UI.
|
|
8
|
+
*/
|
|
9
|
+
export const icons = [
|
|
10
|
+
'ph--house-line--regular',
|
|
11
|
+
'ph--planet--regular',
|
|
12
|
+
'ph--castle-turret--regular',
|
|
13
|
+
'ph--snowflake--regular',
|
|
14
|
+
'ph--virus--regular',
|
|
15
|
+
'ph--graph--regular',
|
|
16
|
+
'ph--air-traffic-control--regular',
|
|
17
|
+
'ph--asterisk--regular',
|
|
18
|
+
'ph--atom--regular',
|
|
19
|
+
'ph--basketball--regular',
|
|
20
|
+
'ph--butterfly--regular',
|
|
21
|
+
'ph--cactus--regular',
|
|
22
|
+
'ph--cake--regular',
|
|
23
|
+
'ph--calendar-dots--regular',
|
|
24
|
+
'ph--campfire--regular',
|
|
25
|
+
'ph--command--regular',
|
|
26
|
+
'ph--confetti--regular',
|
|
27
|
+
'ph--detective--regular',
|
|
28
|
+
'ph--disco-ball--regular',
|
|
29
|
+
'ph--dna--regular',
|
|
30
|
+
'ph--factory--regular',
|
|
31
|
+
'ph--flag-banner-fold--regular',
|
|
32
|
+
'ph--flask--regular',
|
|
33
|
+
'ph--flower-lotus--regular',
|
|
34
|
+
'ph--flying-saucer--regular',
|
|
35
|
+
'ph--game-controller--regular',
|
|
36
|
+
'ph--gavel--regular',
|
|
37
|
+
'ph--gift--regular',
|
|
38
|
+
'ph--guitar--regular',
|
|
39
|
+
'ph--hamburger--regular',
|
|
40
|
+
'ph--handshake--regular',
|
|
41
|
+
'ph--heart--regular',
|
|
42
|
+
'ph--lightbulb--regular',
|
|
43
|
+
'ph--lock--regular',
|
|
44
|
+
'ph--martini--regular',
|
|
45
|
+
'ph--medal-military--regular',
|
|
46
|
+
'ph--moped-front--regular',
|
|
47
|
+
'ph--office-chair--regular',
|
|
48
|
+
'ph--paint-brush-household--regular',
|
|
49
|
+
'ph--peace--regular',
|
|
50
|
+
'ph--person-simple-hike--regular',
|
|
51
|
+
'ph--piggy-bank--regular',
|
|
52
|
+
'ph--potted-plant--regular',
|
|
53
|
+
'ph--radioactive--regular',
|
|
54
|
+
'ph--rocket-launch--regular',
|
|
55
|
+
'ph--shield-star--regular',
|
|
56
|
+
'ph--shopping-cart--regular',
|
|
57
|
+
'ph--stethoscope--regular',
|
|
58
|
+
'ph--student--regular',
|
|
59
|
+
'ph--sun--regular',
|
|
60
|
+
'ph--tote--regular',
|
|
61
|
+
'ph--tree--regular',
|
|
62
|
+
'ph--users-three--regular',
|
|
63
|
+
'ph--yin-yang--regular',
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
export const iconValues = icons.map((icon) => icon.match(/ph--(.+)--regular/)?.[1] ?? icon);
|
|
@@ -8,7 +8,7 @@ import React, { type FC, useEffect, useState } from 'react';
|
|
|
8
8
|
import { Button, DropdownMenu, Icon, type IconProps, type ThemedClassName, Toolbar, Tooltip } from '@dxos/react-ui';
|
|
9
9
|
|
|
10
10
|
export type PickerButtonProps = ThemedClassName<{
|
|
11
|
-
Component: FC<{ value: string;
|
|
11
|
+
Component: FC<{ value: string; size?: IconProps['size'] }>;
|
|
12
12
|
label: string;
|
|
13
13
|
icon: string;
|
|
14
14
|
values: string[];
|
|
@@ -25,8 +25,8 @@ export const PickerButton = ({
|
|
|
25
25
|
Component,
|
|
26
26
|
disabled,
|
|
27
27
|
classNames,
|
|
28
|
-
defaultValue:
|
|
29
|
-
value:
|
|
28
|
+
defaultValue: defaultValueProp,
|
|
29
|
+
value: valueProp,
|
|
30
30
|
values,
|
|
31
31
|
label,
|
|
32
32
|
icon,
|
|
@@ -36,15 +36,14 @@ export const PickerButton = ({
|
|
|
36
36
|
iconSize = 5,
|
|
37
37
|
}: PickerButtonProps) => {
|
|
38
38
|
const [value, setValue] = useControllableState<string>({
|
|
39
|
-
prop:
|
|
40
|
-
defaultProp:
|
|
39
|
+
prop: valueProp,
|
|
40
|
+
defaultProp: defaultValueProp,
|
|
41
41
|
onChange,
|
|
42
42
|
});
|
|
43
43
|
// TODO(burdon): useControllableState doesn't update the prop when the value is changed. Replace it.
|
|
44
|
-
useEffect(() => setValue(
|
|
44
|
+
useEffect(() => setValue(valueProp), [valueProp]);
|
|
45
45
|
|
|
46
46
|
const [open, setOpen] = useState<boolean>(false);
|
|
47
|
-
|
|
48
47
|
const TriggerRoot = rootVariant === 'toolbar-button' ? Toolbar.Button : Button;
|
|
49
48
|
|
|
50
49
|
return (
|
|
@@ -53,7 +52,7 @@ export const PickerButton = ({
|
|
|
53
52
|
<DropdownMenu.Trigger asChild>
|
|
54
53
|
<TriggerRoot classNames={['gap-2 plb-1', classNames]} disabled={disabled}>
|
|
55
54
|
<span className='sr-only'>{label}</span>
|
|
56
|
-
{(value && <Component value={value}
|
|
55
|
+
{(value && <Component value={value} size={iconSize} />) || <Icon icon={icon} size={iconSize} />}
|
|
57
56
|
<Icon icon='ph--caret-down--bold' size={3} />
|
|
58
57
|
</TriggerRoot>
|
|
59
58
|
</DropdownMenu.Trigger>
|
|
@@ -69,7 +68,7 @@ export const PickerButton = ({
|
|
|
69
68
|
onCheckedChange={() => setValue(_value)}
|
|
70
69
|
classNames={'p-1 items-center justify-center aspect-square'}
|
|
71
70
|
>
|
|
72
|
-
<Component value={_value}
|
|
71
|
+
<Component value={_value} size={iconSize} />
|
|
73
72
|
</DropdownMenu.CheckboxItem>
|
|
74
73
|
);
|
|
75
74
|
})}
|