@podoba/react 0.0.52 → 0.0.53
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/package.json +4 -4
- package/src/components/asset-selection-surface.tsx +264 -67
- package/src/components/citation.examples.tsx +14 -0
- package/src/components/citation.tsx +27 -0
- package/src/components/column-layout.examples.tsx +34 -0
- package/src/components/column-layout.tsx +36 -0
- package/src/components/combobox.tsx +9 -4
- package/src/components/compact-settings-dialog.tsx +80 -21
- package/src/components/date-picker.tsx +49 -8
- package/src/components/delivery/send-to-print-modal.tsx +191 -225
- package/src/components/field-appearance.ts +11 -1
- package/src/components/icon-button.examples.tsx +16 -0
- package/src/components/icon-button.tsx +20 -0
- package/src/components/input.tsx +25 -12
- package/src/components/island-toolbar.examples.tsx +27 -0
- package/src/components/island-toolbar.tsx +39 -0
- package/src/components/media-asset-panel.examples.tsx +44 -5
- package/src/components/media-asset-panel.tsx +339 -28
- package/src/components/media-collection.examples.tsx +18 -0
- package/src/components/media-collection.tsx +206 -0
- package/src/components/number-field.tsx +18 -9
- package/src/components/preview-error.examples.tsx +20 -0
- package/src/components/preview-error.tsx +29 -0
- package/src/components/preview-metadata-card.examples.tsx +32 -0
- package/src/components/preview-metadata-card.tsx +112 -0
- package/src/components/search-field.tsx +27 -7
- package/src/components/select.tsx +81 -50
- package/src/components/settings-dialog-surface.tsx +553 -114
- package/src/components/template-catalog-card.tsx +309 -78
- package/src/components/textarea.tsx +160 -12
- package/src/components/tile.tsx +30 -16
- package/src/components/zoomable-image.examples.tsx +33 -0
- package/src/components/zoomable-image.tsx +185 -0
- package/src/index.ts +96 -78
|
@@ -11,11 +11,12 @@ import {
|
|
|
11
11
|
} from 'react-aria-components'
|
|
12
12
|
import {
|
|
13
13
|
fieldDescriptionClass,
|
|
14
|
+
fieldControlClasses,
|
|
15
|
+
type FieldAppearance,
|
|
14
16
|
fieldErrorClass,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
fieldLabelClasses,
|
|
18
|
+
type FieldLabelSize,
|
|
17
19
|
fieldStackClass,
|
|
18
|
-
outlinedFieldClasses,
|
|
19
20
|
type FieldSize,
|
|
20
21
|
} from './field-appearance'
|
|
21
22
|
|
|
@@ -30,6 +31,8 @@ const stepper =
|
|
|
30
31
|
|
|
31
32
|
export type NumberFieldProps = RACNumberFieldProps & {
|
|
32
33
|
/** Visible label (required for accessibility). */
|
|
34
|
+
appearance?: FieldAppearance
|
|
35
|
+
labelSize?: FieldLabelSize
|
|
33
36
|
label: ReactNode
|
|
34
37
|
description?: ReactNode
|
|
35
38
|
errorMessage?: string
|
|
@@ -38,14 +41,20 @@ export type NumberFieldProps = RACNumberFieldProps & {
|
|
|
38
41
|
size?: FieldSize
|
|
39
42
|
}
|
|
40
43
|
|
|
41
|
-
export const NumberField = ({
|
|
44
|
+
export const NumberField = ({
|
|
45
|
+
label,
|
|
46
|
+
labelSize = 'default',
|
|
47
|
+
appearance = 'outlined',
|
|
48
|
+
description,
|
|
49
|
+
errorMessage,
|
|
50
|
+
placeholder,
|
|
51
|
+
size = 'md',
|
|
52
|
+
...props
|
|
53
|
+
}: NumberFieldProps) => (
|
|
42
54
|
<RACNumberField {...props} className={`group ${fieldStackClass}`}>
|
|
43
|
-
<Label className={
|
|
55
|
+
<Label className={fieldLabelClasses[labelSize]}>{label}</Label>
|
|
44
56
|
<Group
|
|
45
|
-
className={
|
|
46
|
-
`flex w-full items-center overflow-hidden rounded-lg ${fieldSizeClasses[size]} ` +
|
|
47
|
-
outlinedFieldClasses({ focus: 'within', invalid: 'group' })
|
|
48
|
-
}
|
|
57
|
+
className={`flex w-full items-center overflow-hidden rounded-lg ${fieldControlClasses(appearance, size, true)}`}
|
|
49
58
|
>
|
|
50
59
|
<RACButton slot="decrement" className={`${stepper} border-r border-border`}>
|
|
51
60
|
–
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PreviewError } from './preview-error'
|
|
2
|
+
export const examples = {
|
|
3
|
+
default: () => (
|
|
4
|
+
<PreviewError title="Preview unavailable" description="Please try again." retryLabel="Retry" onRetry={() => {}} />
|
|
5
|
+
),
|
|
6
|
+
variants: () => <PreviewError title="Document unavailable" description="You do not have access to this document." />,
|
|
7
|
+
states: () => (
|
|
8
|
+
<PreviewError
|
|
9
|
+
title="Preview unavailable"
|
|
10
|
+
description="Please try again."
|
|
11
|
+
retryLabel="Retry"
|
|
12
|
+
onRetry={() => {}}
|
|
13
|
+
isPending
|
|
14
|
+
/>
|
|
15
|
+
),
|
|
16
|
+
}
|
|
17
|
+
export const meta = {
|
|
18
|
+
category: 'Composite',
|
|
19
|
+
description: 'Compact load error with an optional retry; no retry for unavailable access.',
|
|
20
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Button } from './button'
|
|
2
|
+
|
|
3
|
+
export function PreviewError({
|
|
4
|
+
title,
|
|
5
|
+
description,
|
|
6
|
+
retryLabel,
|
|
7
|
+
onRetry,
|
|
8
|
+
isPending = false,
|
|
9
|
+
}: {
|
|
10
|
+
title: string
|
|
11
|
+
description: string
|
|
12
|
+
retryLabel?: string
|
|
13
|
+
onRetry?: () => void
|
|
14
|
+
isPending?: boolean
|
|
15
|
+
}) {
|
|
16
|
+
return (
|
|
17
|
+
<div className="flex max-w-72 flex-col items-start py-3">
|
|
18
|
+
<h3 className="m-0 text-small font-medium text-fg">{title}</h3>
|
|
19
|
+
<p role="alert" className="mb-0 mt-2 text-label font-normal text-danger">
|
|
20
|
+
{description}
|
|
21
|
+
</p>
|
|
22
|
+
{onRetry && retryLabel ? (
|
|
23
|
+
<Button variant="secondary" size="sm" className="mt-5 self-start" onPress={onRetry} isPending={isPending}>
|
|
24
|
+
{retryLabel}
|
|
25
|
+
</Button>
|
|
26
|
+
) : null}
|
|
27
|
+
</div>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PreviewMetadataCard, PropertyTable, ColorSwatch } from './preview-metadata-card'
|
|
2
|
+
const metadata = (
|
|
3
|
+
<PropertyTable
|
|
4
|
+
label="Typography details"
|
|
5
|
+
rows={[
|
|
6
|
+
{ label: 'Family', value: 'System' },
|
|
7
|
+
{ label: 'Role', value: 'Heading' },
|
|
8
|
+
]}
|
|
9
|
+
/>
|
|
10
|
+
)
|
|
11
|
+
export const examples = {
|
|
12
|
+
default: () => (
|
|
13
|
+
<PreviewMetadataCard title="Heading" preview="A clear idea">
|
|
14
|
+
{metadata}
|
|
15
|
+
</PreviewMetadataCard>
|
|
16
|
+
),
|
|
17
|
+
variants: () => (
|
|
18
|
+
<PreviewMetadataCard title="Heading" preview="A clear idea" collapsible toggleLabel="Show typography details">
|
|
19
|
+
{metadata}
|
|
20
|
+
</PreviewMetadataCard>
|
|
21
|
+
),
|
|
22
|
+
states: () => (
|
|
23
|
+
<div className="flex gap-4">
|
|
24
|
+
<ColorSwatch color="#ffffff" label="White" />
|
|
25
|
+
<ColorSwatch color="#242423" label="Black" />
|
|
26
|
+
</div>
|
|
27
|
+
),
|
|
28
|
+
}
|
|
29
|
+
export const meta = {
|
|
30
|
+
category: 'Composite',
|
|
31
|
+
description: 'Preview panel with compact, optionally collapsed property table.',
|
|
32
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
import { IconButton } from './icon-button'
|
|
3
|
+
import { Disclosure, DisclosurePanel } from './disclosure'
|
|
4
|
+
import { uic } from '../utils/uic'
|
|
5
|
+
|
|
6
|
+
const Surface = uic('section', {
|
|
7
|
+
displayName: 'PreviewMetadataCard',
|
|
8
|
+
baseClass: 'min-w-0 overflow-hidden rounded-lg border border-border bg-surface',
|
|
9
|
+
})
|
|
10
|
+
/** A preview stays visible while its metadata may collapse independently. */
|
|
11
|
+
export function PreviewMetadataCard({
|
|
12
|
+
title,
|
|
13
|
+
preview,
|
|
14
|
+
children,
|
|
15
|
+
collapsible = false,
|
|
16
|
+
toggleLabel,
|
|
17
|
+
previewClassName = 'h-60',
|
|
18
|
+
actions,
|
|
19
|
+
}: {
|
|
20
|
+
title: ReactNode
|
|
21
|
+
preview: ReactNode
|
|
22
|
+
children: ReactNode
|
|
23
|
+
collapsible?: boolean
|
|
24
|
+
toggleLabel?: string
|
|
25
|
+
previewClassName?: string
|
|
26
|
+
actions?: ReactNode
|
|
27
|
+
}) {
|
|
28
|
+
const heading = (
|
|
29
|
+
<div className="flex min-w-0 items-center justify-between gap-3">
|
|
30
|
+
<h3 className="m-0 min-w-0 text-panel-heading font-medium text-fg">{title}</h3>
|
|
31
|
+
{actions}
|
|
32
|
+
{collapsible ? (
|
|
33
|
+
<IconButton slot="trigger" className="h-9 w-9 shrink-0 p-0" label={toggleLabel ?? ''}>
|
|
34
|
+
<svg
|
|
35
|
+
aria-hidden="true"
|
|
36
|
+
viewBox="0 0 24 24"
|
|
37
|
+
className="size-4 group-data-[expanded]/preview-metadata:rotate-180"
|
|
38
|
+
fill="none"
|
|
39
|
+
stroke="currentColor"
|
|
40
|
+
strokeWidth="1.5"
|
|
41
|
+
>
|
|
42
|
+
<path d="m6 9 6 6 6-6" />
|
|
43
|
+
</svg>
|
|
44
|
+
</IconButton>
|
|
45
|
+
) : null}
|
|
46
|
+
</div>
|
|
47
|
+
)
|
|
48
|
+
return (
|
|
49
|
+
<Surface>
|
|
50
|
+
<div
|
|
51
|
+
className={`relative flex min-w-0 items-center justify-center overflow-hidden bg-surface-muted p-5 ${previewClassName}`}
|
|
52
|
+
>
|
|
53
|
+
{preview}
|
|
54
|
+
</div>
|
|
55
|
+
{collapsible ? (
|
|
56
|
+
<Disclosure className="group/preview-metadata p-5">
|
|
57
|
+
{heading}
|
|
58
|
+
<DisclosurePanel className="mt-3">{children}</DisclosurePanel>
|
|
59
|
+
</Disclosure>
|
|
60
|
+
) : (
|
|
61
|
+
<div className="p-5">
|
|
62
|
+
{heading}
|
|
63
|
+
<div className="mt-4">{children}</div>
|
|
64
|
+
</div>
|
|
65
|
+
)}
|
|
66
|
+
</Surface>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
export function PropertyTable({
|
|
70
|
+
rows,
|
|
71
|
+
label,
|
|
72
|
+
}: {
|
|
73
|
+
rows: readonly { label: ReactNode; value: ReactNode }[]
|
|
74
|
+
label: string
|
|
75
|
+
}) {
|
|
76
|
+
return (
|
|
77
|
+
<table aria-label={label} className="w-full border-collapse text-label font-normal text-fg">
|
|
78
|
+
<tbody>
|
|
79
|
+
{rows.map((row, index) => (
|
|
80
|
+
<tr key={index} className="border-b border-border last:border-b-0">
|
|
81
|
+
<th scope="row" className="w-1/2 py-3 pe-3 text-start font-normal text-fg-muted">
|
|
82
|
+
{row.label}
|
|
83
|
+
</th>
|
|
84
|
+
<td className="border-s border-border py-3 ps-3 text-start font-normal">{row.value}</td>
|
|
85
|
+
</tr>
|
|
86
|
+
))}
|
|
87
|
+
</tbody>
|
|
88
|
+
</table>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
export function ColorSwatch({ color, label }: { color: string; label: string }) {
|
|
92
|
+
const hex = color.replace('#', ''),
|
|
93
|
+
full = hex.length === 3 ? [...hex].map((value) => value + value).join('') : hex
|
|
94
|
+
const rgb = /^[a-f\d]{6}$/i.test(full)
|
|
95
|
+
? [0, 2, 4].map((index) => parseInt(full.slice(index, index + 2), 16) / 255)
|
|
96
|
+
: [0, 0, 0]
|
|
97
|
+
const luminance = rgb.reduce(
|
|
98
|
+
(sum, value, index) =>
|
|
99
|
+
sum +
|
|
100
|
+
(0.2126 * (index === 0 ? 1 : 0) + 0.7152 * (index === 1 ? 1 : 0) + 0.0722 * (index === 2 ? 1 : 0)) *
|
|
101
|
+
(value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4),
|
|
102
|
+
0,
|
|
103
|
+
)
|
|
104
|
+
return (
|
|
105
|
+
<span
|
|
106
|
+
role="img"
|
|
107
|
+
aria-label={label}
|
|
108
|
+
className={`block size-5 shrink-0 rounded-full ${luminance > 0.8 ? 'border border-border' : ''}`}
|
|
109
|
+
style={{ backgroundColor: color }}
|
|
110
|
+
/>
|
|
111
|
+
)
|
|
112
|
+
}
|
|
@@ -9,10 +9,11 @@ import {
|
|
|
9
9
|
} from 'react-aria-components'
|
|
10
10
|
import {
|
|
11
11
|
fieldDescriptionClass,
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
fieldControlClasses,
|
|
13
|
+
type FieldAppearance,
|
|
14
|
+
fieldLabelClasses,
|
|
15
|
+
type FieldLabelSize,
|
|
14
16
|
fieldStackClass,
|
|
15
|
-
outlinedFieldClasses,
|
|
16
17
|
type FieldSize,
|
|
17
18
|
} from './field-appearance'
|
|
18
19
|
|
|
@@ -39,6 +40,8 @@ const SearchGlyph = () => (
|
|
|
39
40
|
)
|
|
40
41
|
|
|
41
42
|
export type SearchFieldProps = RACSearchFieldProps & {
|
|
43
|
+
appearance?: FieldAppearance
|
|
44
|
+
labelSize?: FieldLabelSize
|
|
42
45
|
label?: ReactNode
|
|
43
46
|
description?: ReactNode
|
|
44
47
|
placeholder?: string
|
|
@@ -46,21 +49,38 @@ export type SearchFieldProps = RACSearchFieldProps & {
|
|
|
46
49
|
size?: FieldSize
|
|
47
50
|
}
|
|
48
51
|
|
|
49
|
-
export const SearchField = ({
|
|
52
|
+
export const SearchField = ({
|
|
53
|
+
label,
|
|
54
|
+
labelSize = 'default',
|
|
55
|
+
appearance = 'outlined',
|
|
56
|
+
description,
|
|
57
|
+
placeholder,
|
|
58
|
+
size = 'md',
|
|
59
|
+
...props
|
|
60
|
+
}: SearchFieldProps) => (
|
|
50
61
|
<RACSearchField {...props} className={`group ${fieldStackClass}`}>
|
|
51
|
-
{label ? <Label className={
|
|
62
|
+
{label ? <Label className={fieldLabelClasses[labelSize]}>{label}</Label> : null}
|
|
52
63
|
<div className="relative flex items-center">
|
|
53
64
|
<SearchGlyph />
|
|
54
65
|
<RACInput
|
|
55
66
|
placeholder={placeholder}
|
|
56
67
|
className={
|
|
57
|
-
`w-full rounded-lg pl-10 pr-10 ${
|
|
68
|
+
`w-full rounded-lg pl-10 pr-10 ${fieldControlClasses(appearance, size)} ` +
|
|
58
69
|
'[&::-webkit-search-cancel-button]:hidden'
|
|
59
70
|
}
|
|
60
71
|
/>
|
|
61
72
|
{/* RAC hides this automatically when the field is empty. */}
|
|
62
73
|
<RACButton className="absolute right-2 flex h-7 w-7 cursor-pointer data-[disabled]:cursor-not-allowed items-center justify-center rounded-md text-fg-subtle outline-none transition-colors hover:bg-surface-muted hover:text-fg group-data-[empty]:hidden data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring">
|
|
63
|
-
<svg
|
|
74
|
+
<svg
|
|
75
|
+
width="14"
|
|
76
|
+
height="14"
|
|
77
|
+
viewBox="0 0 24 24"
|
|
78
|
+
fill="none"
|
|
79
|
+
stroke="currentColor"
|
|
80
|
+
strokeWidth="2"
|
|
81
|
+
strokeLinecap="round"
|
|
82
|
+
aria-hidden="true"
|
|
83
|
+
>
|
|
64
84
|
<path d="M6 6l12 12M18 6 6 18" />
|
|
65
85
|
</svg>
|
|
66
86
|
</RACButton>
|
|
@@ -17,7 +17,8 @@ import { useInFocusOverlay } from './focus-context'
|
|
|
17
17
|
import {
|
|
18
18
|
fieldDescriptionClass,
|
|
19
19
|
fieldErrorClass,
|
|
20
|
-
|
|
20
|
+
fieldLabelClasses,
|
|
21
|
+
type FieldLabelSize,
|
|
21
22
|
fieldSizeClasses,
|
|
22
23
|
fieldStackClass,
|
|
23
24
|
outlinedFieldClasses,
|
|
@@ -51,7 +52,8 @@ const SelectTrigger = uic(RACButton, {
|
|
|
51
52
|
'flex w-full cursor-pointer items-center justify-between gap-2.5 rounded-lg text-small text-fg outline-none transition-colors',
|
|
52
53
|
variants: {
|
|
53
54
|
appearance: {
|
|
54
|
-
filled:
|
|
55
|
+
filled:
|
|
56
|
+
'h-10.5 border-0 bg-surface-card px-4 py-3 font-normal leading-4.5 duration-200 motion-reduce:transition-none ' +
|
|
55
57
|
'data-[hovered]:bg-surface-muted group-data-[open]:bg-surface-card ' +
|
|
56
58
|
'data-[focus-visible]:outline-solid data-[focus-visible]:outline-2 data-[focus-visible]:outline-ring data-[focus-visible]:outline-offset-2 ' +
|
|
57
59
|
'group-data-[invalid]:ring-1 group-data-[invalid]:ring-danger ' +
|
|
@@ -73,16 +75,18 @@ const StyledSelectItem = uic(ListBoxItem, {
|
|
|
73
75
|
'flex cursor-pointer select-none items-center rounded-md text-small text-fg outline-none data-[disabled]:opacity-50 data-[disabled]:pointer-events-none',
|
|
74
76
|
variants: {
|
|
75
77
|
appearance: {
|
|
76
|
-
filled:
|
|
78
|
+
filled:
|
|
79
|
+
'min-w-0 overflow-hidden px-5 py-0 font-normal leading-4.5 max-md:min-h-11 ' +
|
|
77
80
|
'data-[hovered]:font-medium data-[focused]:font-medium data-[selected]:font-medium ' +
|
|
78
81
|
'data-[focus-visible]:outline-solid data-[focus-visible]:outline-2 data-[focus-visible]:outline-ring data-[focus-visible]:-outline-offset-2',
|
|
79
|
-
outlined:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
outlined:
|
|
83
|
+
'px-3 py-2 ' +
|
|
84
|
+
'data-[hovered]:bg-surface-muted data-[focused]:bg-surface-muted data-[selected]:font-medium ' +
|
|
85
|
+
'data-[disabled]:opacity-50 data-[disabled]:pointer-events-none',
|
|
82
86
|
},
|
|
83
87
|
},
|
|
84
88
|
defaultVariants: { appearance: 'outlined' },
|
|
85
|
-
}) as (props: ListBoxItemProps & { appearance?: FieldAppearance }) => ReactNode
|
|
89
|
+
}) as (props: ListBoxItemProps & { labelSize?: FieldLabelSize; appearance?: FieldAppearance }) => ReactNode
|
|
86
90
|
|
|
87
91
|
export const SelectItem = (props: ListBoxItemProps): ReactNode => {
|
|
88
92
|
const appearance = useContext(SelectAppearanceContext)
|
|
@@ -90,9 +94,19 @@ export const SelectItem = (props: ListBoxItemProps): ReactNode => {
|
|
|
90
94
|
// Manager's ItemText is a single ellipsized line. Keep the full value in the
|
|
91
95
|
// label/textValue so keyboard search and assistive technology don't see a cut-off label.
|
|
92
96
|
const { children, textValue, ...rest } = props
|
|
93
|
-
return
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
return (
|
|
98
|
+
<StyledSelectItem
|
|
99
|
+
{...rest}
|
|
100
|
+
appearance={appearance}
|
|
101
|
+
textValue={textValue ?? (typeof children === 'string' ? children : undefined)}
|
|
102
|
+
>
|
|
103
|
+
{(state) => (
|
|
104
|
+
<Text slot="label" className="min-w-0 truncate">
|
|
105
|
+
{typeof children === 'function' ? children(state) : children}
|
|
106
|
+
</Text>
|
|
107
|
+
)}
|
|
108
|
+
</StyledSelectItem>
|
|
109
|
+
)
|
|
96
110
|
}
|
|
97
111
|
|
|
98
112
|
const SelectListBox = uic(ListBox, {
|
|
@@ -104,14 +118,17 @@ const SelectListBox = uic(ListBox, {
|
|
|
104
118
|
const SelectPopover = uic(Popover, {
|
|
105
119
|
displayName: 'SelectPopover',
|
|
106
120
|
baseClass: 'overflow-hidden rounded-lg bg-surface-card shadow-lg',
|
|
107
|
-
variants: {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
121
|
+
variants: {
|
|
122
|
+
appearance: {
|
|
123
|
+
outlined: 'min-w-(--trigger-width)',
|
|
124
|
+
filled: 'w-(--trigger-width) max-w-(--select-popup-max-width)',
|
|
125
|
+
},
|
|
126
|
+
},
|
|
111
127
|
defaultVariants: { appearance: 'outlined' },
|
|
112
128
|
})
|
|
113
129
|
|
|
114
130
|
export type SelectProps<T extends object> = RACSelectProps<T> & {
|
|
131
|
+
labelSize?: FieldLabelSize
|
|
115
132
|
appearance?: FieldAppearance
|
|
116
133
|
/** Outlined trigger height, matching `Input`'s `size`. Ignored when filled. */
|
|
117
134
|
size?: FieldSize
|
|
@@ -126,7 +143,7 @@ export type SelectProps<T extends object> = RACSelectProps<T> & {
|
|
|
126
143
|
* i18n, so the consumer passes a translated string (otherwise RAC would fall
|
|
127
144
|
* back to its own hardcoded English "Select an item").
|
|
128
145
|
*/
|
|
129
|
-
placeholder
|
|
146
|
+
placeholder?: string
|
|
130
147
|
children: ReactNode
|
|
131
148
|
/** Optional class for the Select root. */
|
|
132
149
|
rootClassName?: string
|
|
@@ -136,6 +153,7 @@ export type SelectProps<T extends object> = RACSelectProps<T> & {
|
|
|
136
153
|
|
|
137
154
|
export const Select = <T extends object>({
|
|
138
155
|
label,
|
|
156
|
+
labelSize = 'default',
|
|
139
157
|
description,
|
|
140
158
|
errorMessage,
|
|
141
159
|
placeholder,
|
|
@@ -163,42 +181,55 @@ export const Select = <T extends object>({
|
|
|
163
181
|
|
|
164
182
|
return (
|
|
165
183
|
<SelectAppearanceContext.Provider value={appearance}>
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
{listbox}
|
|
171
|
-
{desc}
|
|
172
|
-
{err}
|
|
173
|
-
</>
|
|
174
|
-
) : (
|
|
175
|
-
<>
|
|
176
|
-
<SelectTrigger className={triggerClassName} appearance={appearance} fieldSize={appearance === 'outlined' ? size : undefined}>
|
|
177
|
-
{/* One line: a long value must not wrap out of the fixed-height box. */}
|
|
178
|
-
<SelectValue className="min-w-0 truncate data-[placeholder]:text-fg-muted" />
|
|
179
|
-
{/* gs chevron: 9.5px caret, dark (neutral-400 → fg), non-interactive. */}
|
|
180
|
-
<svg
|
|
181
|
-
width="9.5"
|
|
182
|
-
height="9.5"
|
|
183
|
-
viewBox="0 0 12 12"
|
|
184
|
-
fill="none"
|
|
185
|
-
aria-hidden="true"
|
|
186
|
-
className="pointer-events-none shrink-0 text-fg"
|
|
187
|
-
>
|
|
188
|
-
<path d="M3 4.5L6 7.5L9 4.5" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
|
|
189
|
-
</svg>
|
|
190
|
-
</SelectTrigger>
|
|
191
|
-
{desc}
|
|
192
|
-
{err}
|
|
193
|
-
{/* Filled uses the trigger width and Manager's 4px popup offset. */}
|
|
194
|
-
<SelectPopover appearance={appearance} offset={appearance === 'filled' ? 4 : undefined}
|
|
195
|
-
containerPadding={appearance === 'filled' ? 12 : undefined}
|
|
196
|
-
style={appearance === 'filled' ? filledPopoverStyle : undefined}>
|
|
184
|
+
<RACSelect {...props} placeholder={placeholder} className={`group ${fieldStackClass} ${rootClassName ?? ''}`}>
|
|
185
|
+
<Label className={isLabelHidden ? 'sr-only' : fieldLabelClasses[labelSize]}>{label}</Label>
|
|
186
|
+
{inFocus ? (
|
|
187
|
+
<>
|
|
197
188
|
{listbox}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
189
|
+
{desc}
|
|
190
|
+
{err}
|
|
191
|
+
</>
|
|
192
|
+
) : (
|
|
193
|
+
<>
|
|
194
|
+
<SelectTrigger
|
|
195
|
+
className={triggerClassName}
|
|
196
|
+
appearance={appearance}
|
|
197
|
+
fieldSize={appearance === 'outlined' ? size : undefined}
|
|
198
|
+
>
|
|
199
|
+
{/* One line: a long value must not wrap out of the fixed-height box. */}
|
|
200
|
+
<SelectValue className="min-w-0 truncate data-[placeholder]:text-fg-muted" />
|
|
201
|
+
{/* gs chevron: 9.5px caret, dark (neutral-400 → fg), non-interactive. */}
|
|
202
|
+
<svg
|
|
203
|
+
width="9.5"
|
|
204
|
+
height="9.5"
|
|
205
|
+
viewBox="0 0 12 12"
|
|
206
|
+
fill="none"
|
|
207
|
+
aria-hidden="true"
|
|
208
|
+
className="pointer-events-none shrink-0 text-fg"
|
|
209
|
+
>
|
|
210
|
+
<path
|
|
211
|
+
d="M3 4.5L6 7.5L9 4.5"
|
|
212
|
+
stroke="currentColor"
|
|
213
|
+
strokeWidth="1.5"
|
|
214
|
+
strokeLinecap="round"
|
|
215
|
+
strokeLinejoin="round"
|
|
216
|
+
/>
|
|
217
|
+
</svg>
|
|
218
|
+
</SelectTrigger>
|
|
219
|
+
{desc}
|
|
220
|
+
{err}
|
|
221
|
+
{/* Filled uses the trigger width and Manager's 4px popup offset. */}
|
|
222
|
+
<SelectPopover
|
|
223
|
+
appearance={appearance}
|
|
224
|
+
offset={appearance === 'filled' ? 4 : undefined}
|
|
225
|
+
containerPadding={appearance === 'filled' ? 12 : undefined}
|
|
226
|
+
style={appearance === 'filled' ? filledPopoverStyle : undefined}
|
|
227
|
+
>
|
|
228
|
+
{listbox}
|
|
229
|
+
</SelectPopover>
|
|
230
|
+
</>
|
|
231
|
+
)}
|
|
232
|
+
</RACSelect>
|
|
202
233
|
</SelectAppearanceContext.Provider>
|
|
203
234
|
)
|
|
204
235
|
}
|