@podoba/react 0.0.42 → 0.0.44
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 +3 -3
- package/src/components/asset-selection-surface.tsx +1 -1
- package/src/components/button.tsx +1 -1
- package/src/components/collapsible-card.tsx +1 -1
- package/src/components/combobox.tsx +26 -19
- package/src/components/compact-settings-dialog.tsx +2 -2
- package/src/components/date-field.tsx +26 -13
- package/src/components/date-picker.tsx +17 -9
- package/src/components/date-selection-calendar.tsx +2 -2
- package/src/components/delivery/send-to-print-modal.tsx +1 -1
- package/src/components/dialog.tsx +1 -1
- package/src/components/field-appearance.ts +44 -0
- package/src/components/focus-field.tsx +1 -1
- package/src/components/input.tsx +19 -20
- package/src/components/multiselect.tsx +19 -7
- package/src/components/number-field.tsx +18 -11
- package/src/components/rich-text-editor.tsx +1 -1
- package/src/components/search-field.tsx +15 -8
- package/src/components/select.tsx +30 -17
- package/src/components/side-panel.tsx +1 -1
- package/src/components/table.tsx +1 -1
- package/src/components/tag-group.tsx +1 -1
- package/src/components/textarea.tsx +12 -9
- package/src/components/tile.tsx +2 -2
- package/src/components/toast.tsx +1 -1
- package/src/editor/block-editor.tsx +1 -1
- package/src/layout/app-shell.tsx +1 -1
- package/src/layout/topbar.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@podoba/react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.44",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "podoba React components — React Aria Components + Tailwind primitives + layout, built with uic.",
|
|
6
6
|
"repository": {
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"typecheck": "tsc --build"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@podoba/tokens": "^0.0.
|
|
32
|
-
"@podoba/tailwind": "^0.0.
|
|
31
|
+
"@podoba/tokens": "^0.0.44",
|
|
32
|
+
"@podoba/tailwind": "^0.0.44",
|
|
33
33
|
"react-aria-components": "1.18.0",
|
|
34
34
|
"class-variance-authority": "0.7.1",
|
|
35
35
|
"clsx": "2.1.1",
|
|
@@ -89,7 +89,7 @@ export function AssetLibraryPreview({ label, selected, aspectRatio, tags, onPres
|
|
|
89
89
|
}) {
|
|
90
90
|
return <AriaButton aria-label={label} aria-pressed={selected} onPress={onPress}
|
|
91
91
|
style={{ aspectRatio }}
|
|
92
|
-
className={`group relative block min-h-[150px] max-h-[800px] w-full overflow-hidden rounded-none border p-0 transition-transform duration-200 ease-[ease] hover:-translate-y-0.5 hover:shadow-xs hover:border-[#aba89c] active:translate-y-0 focus-visible:ring-2 focus-visible:ring-accent-blue focus-visible:ring-offset-2 motion-reduce:transition-none ${selected ? 'border-accent-blue bg-accent-blue/10' : 'border-border bg-surface-card'}`}>
|
|
92
|
+
className={`group relative block min-h-[150px] max-h-[800px] w-full cursor-pointer overflow-hidden rounded-none border p-0 transition-transform duration-200 ease-[ease] hover:-translate-y-0.5 hover:shadow-xs hover:border-[#aba89c] active:translate-y-0 focus-visible:ring-2 focus-visible:ring-accent-blue focus-visible:ring-offset-2 motion-reduce:transition-none ${selected ? 'border-accent-blue bg-accent-blue/10' : 'border-border bg-surface-card'}`}>
|
|
93
93
|
{children}
|
|
94
94
|
{tags.length ? <span data-testid="asset-card-overlay" className="pointer-events-none absolute inset-x-0 bottom-0 flex flex-wrap items-center gap-1 bg-gradient-to-t from-black/70 to-transparent p-3 opacity-0 transition-opacity duration-250 ease-[ease] group-hover:opacity-100 group-focus-visible:opacity-100 motion-reduce:transition-none">
|
|
95
95
|
{tags.slice(0, 3).map(tag => <span key={tag} className="ms-3 inline-flex h-6 items-center rounded-full bg-surface-muted px-2.5 text-label font-medium leading-5 text-(--color-neutral-600)">{tag}</span>)}
|
|
@@ -13,7 +13,7 @@ export const Button = uic(RACButton, {
|
|
|
13
13
|
// on every size — size variants change PADDING ONLY, never the text scale. The
|
|
14
14
|
// source eases background-color, color, box-shadow and border-color over 120ms `ease`.
|
|
15
15
|
baseClass:
|
|
16
|
-
'inline-flex items-center justify-center gap-2 rounded-full text-compact leading-4 ' +
|
|
16
|
+
'inline-flex cursor-pointer items-center justify-center gap-2 rounded-full text-compact leading-4 ' +
|
|
17
17
|
'transition-[background-color,color,box-shadow,border-color] duration-120 ease-[ease] motion-reduce:transition-none ' +
|
|
18
18
|
'outline-none data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring data-[focus-visible]:ring-offset-2 ' +
|
|
19
19
|
// Inactive states (disabled / pending) soften the LABEL ONLY and leave every
|
|
@@ -102,7 +102,7 @@ export function CollapsibleCard({
|
|
|
102
102
|
<RACButton
|
|
103
103
|
slot="trigger"
|
|
104
104
|
className={
|
|
105
|
-
'flex w-full items-center justify-between gap-4 rounded-lg p-6 text-left outline-none ' +
|
|
105
|
+
'flex w-full cursor-pointer items-center justify-between gap-4 rounded-lg p-6 text-left outline-none ' +
|
|
106
106
|
'data-[disabled]:cursor-not-allowed data-[disabled]:opacity-60 ' +
|
|
107
107
|
'data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring data-[focus-visible]:ring-inset'
|
|
108
108
|
}
|
|
@@ -17,14 +17,22 @@ import {
|
|
|
17
17
|
} from 'react-aria-components'
|
|
18
18
|
import { uic } from '../utils/uic'
|
|
19
19
|
import { useInFocusOverlay } from './focus-context'
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
fieldDescriptionClass,
|
|
22
|
+
fieldErrorClass,
|
|
23
|
+
fieldLabelClass,
|
|
24
|
+
fieldSizeClasses,
|
|
25
|
+
fieldStackClass,
|
|
26
|
+
outlinedFieldClasses,
|
|
27
|
+
type FieldSize,
|
|
28
|
+
} from './field-appearance'
|
|
21
29
|
|
|
22
30
|
/**
|
|
23
31
|
* ComboBox — a filterable single-select: a text input that narrows a listbox as
|
|
24
32
|
* you type. Built on React Aria Components `ComboBox` (typeahead, keyboard nav,
|
|
25
|
-
* ARIA all handled).
|
|
26
|
-
*
|
|
27
|
-
* options as `ComboBoxItem` children.
|
|
33
|
+
* ARIA all handled). The input uses the shared outlined skin and `size` scale,
|
|
34
|
+
* so it is the same box as an outlined `Input` or `Select`, and it shares
|
|
35
|
+
* `Select`'s cream dropdown. Pass options as `ComboBoxItem` children.
|
|
28
36
|
*/
|
|
29
37
|
const Chevron = () => (
|
|
30
38
|
<svg width="9.5" height="9.5" viewBox="0 0 12 12" fill="none" aria-hidden="true" className="text-fg">
|
|
@@ -32,17 +40,13 @@ const Chevron = () => (
|
|
|
32
40
|
</svg>
|
|
33
41
|
)
|
|
34
42
|
|
|
35
|
-
//
|
|
36
|
-
//
|
|
43
|
+
// The shared outlined skin, with room on the right for the toggle. Invalid is
|
|
44
|
+
// owned by the ComboBox root, so it comes through `group-data-invalid`.
|
|
37
45
|
const ComboBoxInput = uic(RACInput, {
|
|
38
46
|
displayName: 'ComboBoxInput',
|
|
39
|
-
baseClass:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
'data-[hovered]:border-fg-subtle ' +
|
|
43
|
-
'data-[focused]:border-brand-green data-[focused]:ring-2 data-[focused]:ring-ring ' +
|
|
44
|
-
'group-data-[invalid]:border-danger group-data-[invalid]:ring-2 group-data-[invalid]:ring-danger ' +
|
|
45
|
-
'data-[disabled]:bg-surface-muted data-[disabled]:opacity-60',
|
|
47
|
+
baseClass: `w-full rounded-lg pl-4 pr-11 ${outlinedFieldClasses({ invalid: 'group' })}`,
|
|
48
|
+
variants: { fieldSize: fieldSizeClasses },
|
|
49
|
+
defaultVariants: { fieldSize: 'md' },
|
|
46
50
|
})
|
|
47
51
|
|
|
48
52
|
export const ComboBoxItem = uic(ListBoxItem, {
|
|
@@ -61,6 +65,8 @@ export type ComboBoxProps<T extends object> = RACComboBoxProps<T> & {
|
|
|
61
65
|
errorMessage?: string
|
|
62
66
|
/** Placeholder shown in the empty input. */
|
|
63
67
|
placeholder?: string
|
|
68
|
+
/** Input height, matching `Input`'s `size`. */
|
|
69
|
+
size?: FieldSize
|
|
64
70
|
children: ReactNode
|
|
65
71
|
}
|
|
66
72
|
|
|
@@ -69,6 +75,7 @@ export const ComboBox = <T extends object>({
|
|
|
69
75
|
description,
|
|
70
76
|
errorMessage,
|
|
71
77
|
placeholder,
|
|
78
|
+
size = 'md',
|
|
72
79
|
children,
|
|
73
80
|
selectedKey,
|
|
74
81
|
onSelectionChange,
|
|
@@ -86,8 +93,8 @@ export const ComboBox = <T extends object>({
|
|
|
86
93
|
// only fills its listbox while open, so compose Autocomplete + ListBox here).
|
|
87
94
|
if (inFocus) {
|
|
88
95
|
return (
|
|
89
|
-
<div className=
|
|
90
|
-
<span className=
|
|
96
|
+
<div className={fieldStackClass}>
|
|
97
|
+
<span className={fieldLabelClass}>{label}</span>
|
|
91
98
|
<Autocomplete filter={contains}>
|
|
92
99
|
<SearchField aria-label={typeof label === 'string' ? label : 'Search'}>
|
|
93
100
|
<RACInput
|
|
@@ -122,13 +129,13 @@ export const ComboBox = <T extends object>({
|
|
|
122
129
|
selectedKey={selectedKey}
|
|
123
130
|
onSelectionChange={onSelectionChange}
|
|
124
131
|
{...props}
|
|
125
|
-
className=
|
|
132
|
+
className={`group ${fieldStackClass}`}
|
|
126
133
|
>
|
|
127
|
-
<Label className=
|
|
134
|
+
<Label className={fieldLabelClass}>{label}</Label>
|
|
128
135
|
<div className="relative">
|
|
129
|
-
<ComboBoxInput placeholder={placeholder} />
|
|
136
|
+
<ComboBoxInput placeholder={placeholder} fieldSize={size} />
|
|
130
137
|
{/* RAC uses this Button to toggle the listbox open/closed. */}
|
|
131
|
-
<RACButton className="absolute inset-y-0 right-0 flex w-11 items-center justify-center rounded-r-lg outline-none data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring">
|
|
138
|
+
<RACButton className="absolute inset-y-0 right-0 flex w-11 cursor-pointer data-[disabled]:cursor-not-allowed items-center justify-center rounded-r-lg outline-none data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring">
|
|
132
139
|
<Chevron />
|
|
133
140
|
</RACButton>
|
|
134
141
|
</div>
|
|
@@ -9,11 +9,11 @@ export const MemberSelectionGrid = uic('ul', { displayName: 'MemberSelectionGrid
|
|
|
9
9
|
export const TeamSelectionGrid = uic('ul', { displayName: 'TeamSelectionGrid', baseClass: 'm-0 mt-8 grid list-none grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-4 p-0' })
|
|
10
10
|
export const MemberSelectionCard = uic(AriaButton, {
|
|
11
11
|
displayName: 'MemberSelectionCard',
|
|
12
|
-
baseClass: 'flex w-full items-center gap-3 rounded-lg border border-border bg-surface-card p-4 text-start text-fg outline-none transition-all duration-200 data-[hovered]:-translate-y-0.5 data-[hovered]:border-brand-primary data-[hovered]:shadow-[0_4px_12px_rgba(0,0,0,0.1)] aria-pressed:border-brand-primary aria-pressed:bg-surface-muted data-[disabled]:cursor-default data-[disabled]:opacity-60 data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring',
|
|
12
|
+
baseClass: 'flex w-full cursor-pointer items-center gap-3 rounded-lg border border-border bg-surface-card p-4 text-start text-fg outline-none transition-all duration-200 data-[hovered]:-translate-y-0.5 data-[hovered]:border-brand-primary data-[hovered]:shadow-[0_4px_12px_rgba(0,0,0,0.1)] aria-pressed:border-brand-primary aria-pressed:bg-surface-muted data-[disabled]:cursor-default data-[disabled]:opacity-60 data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring',
|
|
13
13
|
})
|
|
14
14
|
export const TeamSelectionCard = uic(AriaButton, {
|
|
15
15
|
displayName: 'TeamSelectionCard',
|
|
16
|
-
baseClass: 'block w-full rounded-md border-2 border-border bg-transparent p-4 text-start text-fg outline-none transition-all duration-200 data-[hovered]:border-brand-primary aria-pressed:border-brand-primary aria-pressed:bg-surface-muted data-[disabled]:cursor-default data-[disabled]:opacity-60 data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring',
|
|
16
|
+
baseClass: 'block w-full cursor-pointer rounded-md border-2 border-border bg-transparent p-4 text-start text-fg outline-none transition-all duration-200 data-[hovered]:border-brand-primary aria-pressed:border-brand-primary aria-pressed:bg-surface-muted data-[disabled]:cursor-default data-[disabled]:opacity-60 data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring',
|
|
17
17
|
})
|
|
18
18
|
export const MemberSelectionInfo = uic('span', { displayName: 'MemberSelectionInfo', baseClass: 'min-w-0 flex-1' })
|
|
19
19
|
export const MemberSelectionName = uic('span', { displayName: 'MemberSelectionName', baseClass: 'mb-1 block text-heading5 font-medium text-fg' })
|
|
@@ -12,7 +12,15 @@ import {
|
|
|
12
12
|
type TimeFieldProps as RACTimeFieldProps,
|
|
13
13
|
type TimeValue,
|
|
14
14
|
} from 'react-aria-components'
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
fieldDescriptionClass,
|
|
17
|
+
fieldErrorClass,
|
|
18
|
+
fieldLabelClass,
|
|
19
|
+
fieldSizeClasses,
|
|
20
|
+
fieldStackClass,
|
|
21
|
+
outlinedFieldClasses,
|
|
22
|
+
type FieldSize,
|
|
23
|
+
} from './field-appearance'
|
|
16
24
|
|
|
17
25
|
/**
|
|
18
26
|
* DateField / TimeField — segmented, keyboard-first date and time entry (type or
|
|
@@ -28,21 +36,24 @@ export const segmentClass =
|
|
|
28
36
|
'data-[focused]:bg-brand-green data-[focused]:text-fg ' +
|
|
29
37
|
'data-[disabled]:opacity-50 data-[type=literal]:px-0 data-[type=literal]:text-fg-muted'
|
|
30
38
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
// The shared outlined box around the segments. Focus sits on a segment, so the
|
|
40
|
+
// wrapper shows it via focus-within; invalid lives on the field root.
|
|
41
|
+
export const dateInputClass = (size: FieldSize = 'md') =>
|
|
42
|
+
`flex w-full items-center gap-0.5 rounded-lg px-4 ${fieldSizeClasses[size]} ` +
|
|
43
|
+
outlinedFieldClasses({ focus: 'within', invalid: 'group' })
|
|
35
44
|
|
|
36
45
|
export type DateFieldProps<T extends DateValue> = RACDateFieldProps<T> & {
|
|
37
46
|
label: ReactNode
|
|
47
|
+
/** Field height, matching `Input`'s `size`. */
|
|
48
|
+
size?: FieldSize
|
|
38
49
|
description?: ReactNode
|
|
39
50
|
errorMessage?: string
|
|
40
51
|
}
|
|
41
52
|
|
|
42
|
-
export const DateField = <T extends DateValue>({ label, description, errorMessage, ...props }: DateFieldProps<T>) => (
|
|
43
|
-
<RACDateField {...props} className=
|
|
44
|
-
<Label className=
|
|
45
|
-
<DateInput className={dateInputClass}>{(segment) => <DateSegment segment={segment} className={segmentClass} />}</DateInput>
|
|
53
|
+
export const DateField = <T extends DateValue>({ label, description, errorMessage, size, ...props }: DateFieldProps<T>) => (
|
|
54
|
+
<RACDateField {...props} className={`group ${fieldStackClass}`}>
|
|
55
|
+
<Label className={fieldLabelClass}>{label}</Label>
|
|
56
|
+
<DateInput className={dateInputClass(size)}>{(segment) => <DateSegment segment={segment} className={segmentClass} />}</DateInput>
|
|
46
57
|
{description ? (
|
|
47
58
|
<Text slot="description" className={fieldDescriptionClass}>
|
|
48
59
|
{description}
|
|
@@ -54,14 +65,16 @@ export const DateField = <T extends DateValue>({ label, description, errorMessag
|
|
|
54
65
|
|
|
55
66
|
export type TimeFieldProps<T extends TimeValue> = RACTimeFieldProps<T> & {
|
|
56
67
|
label: ReactNode
|
|
68
|
+
/** Field height, matching `Input`'s `size`. */
|
|
69
|
+
size?: FieldSize
|
|
57
70
|
description?: ReactNode
|
|
58
71
|
errorMessage?: string
|
|
59
72
|
}
|
|
60
73
|
|
|
61
|
-
export const TimeField = <T extends TimeValue>({ label, description, errorMessage, ...props }: TimeFieldProps<T>) => (
|
|
62
|
-
<RACTimeField {...props} className=
|
|
63
|
-
<Label className=
|
|
64
|
-
<DateInput className={dateInputClass}>{(segment) => <DateSegment segment={segment} className={segmentClass} />}</DateInput>
|
|
74
|
+
export const TimeField = <T extends TimeValue>({ label, description, errorMessage, size, ...props }: TimeFieldProps<T>) => (
|
|
75
|
+
<RACTimeField {...props} className={`group ${fieldStackClass}`}>
|
|
76
|
+
<Label className={fieldLabelClass}>{label}</Label>
|
|
77
|
+
<DateInput className={dateInputClass(size)}>{(segment) => <DateSegment segment={segment} className={segmentClass} />}</DateInput>
|
|
65
78
|
{description ? (
|
|
66
79
|
<Text slot="description" className={fieldDescriptionClass}>
|
|
67
80
|
{description}
|
|
@@ -23,7 +23,13 @@ import {
|
|
|
23
23
|
import { clsx } from 'clsx'
|
|
24
24
|
import { dateInputClass, segmentClass } from './date-field'
|
|
25
25
|
import { useInFocusOverlay } from './focus-context'
|
|
26
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
fieldDescriptionClass,
|
|
28
|
+
fieldErrorClass,
|
|
29
|
+
fieldLabelClass,
|
|
30
|
+
fieldStackClass,
|
|
31
|
+
type FieldSize,
|
|
32
|
+
} from './field-appearance'
|
|
27
33
|
|
|
28
34
|
/**
|
|
29
35
|
* DatePicker — a `DateField` with a calendar popover. Built on React Aria
|
|
@@ -32,8 +38,8 @@ import { fieldDescriptionClass, fieldErrorClass } from './field-appearance'
|
|
|
32
38
|
* to `"minute"` for a datetime picker (adds time segments to the field).
|
|
33
39
|
*/
|
|
34
40
|
const navButton =
|
|
35
|
-
'flex h-8 w-8 items-center justify-center rounded-md text-fg-muted outline-none transition-colors ' +
|
|
36
|
-
'hover:bg-surface-muted hover:text-fg data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring data-[disabled]:opacity-40'
|
|
41
|
+
'flex h-8 w-8 cursor-pointer items-center justify-center rounded-md text-fg-muted outline-none transition-colors ' +
|
|
42
|
+
'hover:bg-surface-muted hover:text-fg data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring data-[disabled]:cursor-not-allowed data-[disabled]:opacity-40'
|
|
37
43
|
|
|
38
44
|
const Chevron = ({ dir }: { dir: 'left' | 'right' }) => (
|
|
39
45
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
@@ -42,7 +48,7 @@ const Chevron = ({ dir }: { dir: 'left' | 'right' }) => (
|
|
|
42
48
|
)
|
|
43
49
|
|
|
44
50
|
const calendarCellClass =
|
|
45
|
-
'flex h-9 w-9 cursor-pointer items-center justify-center rounded-md text-small text-fg outline-none transition-colors ' +
|
|
51
|
+
'flex h-9 w-9 cursor-pointer items-center justify-center rounded-md text-small text-fg outline-none transition-colors data-[disabled]:cursor-not-allowed data-[unavailable]:cursor-not-allowed ' +
|
|
46
52
|
// #25: out-of-month and unavailable days stay de-emphasised, but they are dates a
|
|
47
53
|
// user reads and (outside-month) can click — `fg-muted`, not the 2.10:1 decorative grey.
|
|
48
54
|
'data-[outside-month]:text-fg-muted data-[hovered]:bg-surface-muted ' +
|
|
@@ -78,26 +84,28 @@ function CalendarBody() {
|
|
|
78
84
|
|
|
79
85
|
export type DatePickerProps<T extends DateValue> = RACDatePickerProps<T> & {
|
|
80
86
|
label: ReactNode
|
|
87
|
+
/** Field height, matching `Input`'s `size`. */
|
|
88
|
+
size?: FieldSize
|
|
81
89
|
description?: ReactNode
|
|
82
90
|
errorMessage?: string
|
|
83
91
|
}
|
|
84
92
|
|
|
85
|
-
export const DatePicker = <T extends DateValue>({ label, description, errorMessage, ...props }: DatePickerProps<T>) => {
|
|
93
|
+
export const DatePicker = <T extends DateValue>({ label, description, errorMessage, size, ...props }: DatePickerProps<T>) => {
|
|
86
94
|
// In a focus overlay, show the calendar inline (open) instead of a popover.
|
|
87
95
|
const inFocus = useInFocusOverlay()
|
|
88
96
|
return (
|
|
89
|
-
<RACDatePicker {...props} className=
|
|
90
|
-
<Label className=
|
|
97
|
+
<RACDatePicker {...props} className={`group ${fieldStackClass}`}>
|
|
98
|
+
<Label className={fieldLabelClass}>{label}</Label>
|
|
91
99
|
{/* In focus mode the field is bare + large and the calendar is borderless,
|
|
92
100
|
so field + calendar read as one seamless editor rather than boxes. */}
|
|
93
|
-
<Group className={inFocus ? 'flex w-full items-center' : `${dateInputClass} pr-2`}>
|
|
101
|
+
<Group className={inFocus ? 'flex w-full items-center' : `${dateInputClass(size)} pr-2`}>
|
|
94
102
|
<DateInput className={clsx('flex flex-1 items-center gap-0.5', inFocus && 'text-display font-medium')}>
|
|
95
103
|
{(segment) => <DateSegment segment={segment} className={segmentClass} />}
|
|
96
104
|
</DateInput>
|
|
97
105
|
{inFocus ? null : (
|
|
98
106
|
<RACButton
|
|
99
107
|
aria-label="Open calendar"
|
|
100
|
-
className="flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-fg-muted outline-none transition-colors hover:bg-surface-muted hover:text-fg data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring"
|
|
108
|
+
className="flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-md text-fg-muted outline-none data-[disabled]:cursor-not-allowed transition-colors hover:bg-surface-muted hover:text-fg data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring"
|
|
101
109
|
>
|
|
102
110
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
103
111
|
<rect x="3" y="4" width="18" height="18" rx="2" />
|
|
@@ -5,11 +5,11 @@ export const CalendarDialogContent = uic('div', { displayName: 'CalendarDialogCo
|
|
|
5
5
|
export const CalendarDateHint = uic('p', { displayName: 'CalendarDateHint', baseClass: 'm-0 min-h-9 text-small font-normal text-fg-workflow-muted', style: { maxWidth: '48ch' } })
|
|
6
6
|
const Frame = uic('div', { displayName: 'DateSelectionCalendar', baseClass: 'mt-6 overflow-hidden border border-border bg-surface' })
|
|
7
7
|
const Header = uic('div', { displayName: 'DateSelectionCalendarHeader', baseClass: 'flex min-h-15 items-center border-b border-border px-5' })
|
|
8
|
-
const Navigation = uic(AriaButton, { displayName: 'DateSelectionCalendarNavigation', baseClass: 'mx-1.5 inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-sm bg-transparent text-2xl font-normal leading-none text-fg outline-none data-[hovered]:bg-surface-card data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring' })
|
|
8
|
+
const Navigation = uic(AriaButton, { displayName: 'DateSelectionCalendarNavigation', baseClass: 'mx-1.5 inline-flex h-9 w-9 shrink-0 cursor-pointer items-center justify-center rounded-sm bg-transparent text-2xl font-normal leading-none text-fg outline-none data-[hovered]:bg-surface-card data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring' })
|
|
9
9
|
const Month = uic('div', { displayName: 'DateSelectionCalendarMonth', baseClass: 'flex-1 text-center text-small font-normal text-fg' })
|
|
10
10
|
const Week = uic('div', { displayName: 'DateSelectionCalendarWeek', baseClass: 'grid grid-cols-7 border-b border-border last:border-b-0' })
|
|
11
11
|
const Weekday = uic('div', { displayName: 'DateSelectionCalendarWeekday', baseClass: 'border-e border-border px-3 pb-2 pt-4 text-center font-mono text-small font-normal tracking-normal text-fg-workflow-muted last:border-e-0' })
|
|
12
|
-
const Day = uic(AriaButton, { displayName: 'DateSelectionCalendarDay', baseClass: 'inline-flex min-h-16 w-full items-center justify-center rounded-none border-e border-border bg-transparent text-small font-normal text-fg outline-none last:border-e-0 data-[hovered]:bg-surface-card data-[focus-visible]:ring-2 data-[focus-visible]:ring-inset data-[focus-visible]:ring-ring data-[disabled]:cursor-not-allowed' })
|
|
12
|
+
const Day = uic(AriaButton, { displayName: 'DateSelectionCalendarDay', baseClass: 'inline-flex min-h-16 w-full cursor-pointer items-center justify-center rounded-none border-e border-border bg-transparent text-small font-normal text-fg outline-none last:border-e-0 data-[hovered]:bg-surface-card data-[focus-visible]:ring-2 data-[focus-visible]:ring-inset data-[focus-visible]:ring-ring data-[disabled]:cursor-not-allowed' })
|
|
13
13
|
const Placeholder = uic('div', { displayName: 'DateSelectionCalendarPlaceholder', baseClass: 'min-h-16 border-e border-border last:border-e-0' })
|
|
14
14
|
|
|
15
15
|
export interface DateSelectionCell {
|
|
@@ -284,7 +284,7 @@ export function SendToPrintModal({
|
|
|
284
284
|
type="button"
|
|
285
285
|
onClick={close}
|
|
286
286
|
aria-label={labels.closeLabel ?? 'Close'}
|
|
287
|
-
className="-mr-1 -mt-1 inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-fg-subtle outline-none transition-colors hover:bg-surface-muted hover:text-fg focus-visible:ring-2 focus-visible:ring-ring"
|
|
287
|
+
className="-mr-1 -mt-1 inline-flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-md text-fg-subtle outline-none transition-colors hover:bg-surface-muted hover:text-fg focus-visible:ring-2 focus-visible:ring-ring"
|
|
288
288
|
>
|
|
289
289
|
<svg
|
|
290
290
|
width="18"
|
|
@@ -199,7 +199,7 @@ export const Dialog = ({
|
|
|
199
199
|
// gs close: 32px square (`h-8 w-8`), medium radius (`rounded-md`),
|
|
200
200
|
// tertiary icon color (`text-fg-subtle`) → primary (`text-fg`) +
|
|
201
201
|
// subtle hover bg on hover. Smooth color transition.
|
|
202
|
-
className={`${isCompact ? 'absolute top-[calc(var(--spacing)*3.375)] end-4 max-md:end-3' : '-mr-1 -mt-1'} inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-fg-subtle outline-none transition-colors hover:bg-surface-muted hover:text-fg focus-visible:ring-2 focus-visible:ring-ring motion-reduce:transition-none`}
|
|
202
|
+
className={`${isCompact ? 'absolute top-[calc(var(--spacing)*3.375)] end-4 max-md:end-3' : '-mr-1 -mt-1'} inline-flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-md text-fg-subtle outline-none transition-colors hover:bg-surface-muted hover:text-fg focus-visible:ring-2 focus-visible:ring-ring motion-reduce:transition-none`}
|
|
203
203
|
>
|
|
204
204
|
<svg
|
|
205
205
|
width={isCompact ? 15 : 18}
|
|
@@ -22,3 +22,47 @@ export const fieldDescriptionClass = 'text-small text-fg-muted'
|
|
|
22
22
|
|
|
23
23
|
/** gs `.errorText`: 16px, line-height normal, error red (`danger`, 4.83:1 on white). */
|
|
24
24
|
export const fieldErrorClass = 'text-body leading-[normal] text-danger'
|
|
25
|
+
|
|
26
|
+
/** Field label, shared by every labelled form control (gs 17px/20px field label). */
|
|
27
|
+
export const fieldLabelClass = 'text-panel-heading font-medium text-fg'
|
|
28
|
+
|
|
29
|
+
/** Label, control, description and error stack. */
|
|
30
|
+
export const fieldStackClass = 'flex flex-col gap-3'
|
|
31
|
+
|
|
32
|
+
/** Outlined control heights. `md` is the default, so every outlined field in a
|
|
33
|
+
* form is the same 40px box unless the consumer opts into another size. */
|
|
34
|
+
export const FIELD_SIZES = ['sm', 'md', 'lg', 'tall'] as const
|
|
35
|
+
export type FieldSize = (typeof FIELD_SIZES)[number]
|
|
36
|
+
export const fieldSizeClasses: Record<FieldSize, string> = {
|
|
37
|
+
sm: 'h-8',
|
|
38
|
+
md: 'h-10',
|
|
39
|
+
lg: 'h-12',
|
|
40
|
+
tall: 'h-control-tall',
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// The outlined skin, split by where its state lives. Every class is spelled out
|
|
44
|
+
// in full so Tailwind's scanner sees it; don't build these from fragments.
|
|
45
|
+
const outlinedBase =
|
|
46
|
+
'border border-border bg-surface text-small text-fg ' +
|
|
47
|
+
'outline-none transition-colors duration-200 motion-reduce:transition-none placeholder:text-fg-muted ' +
|
|
48
|
+
'data-[hovered]:border-fg-subtle ' +
|
|
49
|
+
'data-[disabled]:bg-surface-muted data-[disabled]:opacity-60 data-[disabled]:pointer-events-none'
|
|
50
|
+
const outlinedFocus = {
|
|
51
|
+
// A focusable element (input, trigger button) marks itself focused.
|
|
52
|
+
self: 'data-[focused]:border-brand-green data-[focused]:ring-2 data-[focused]:ring-ring',
|
|
53
|
+
// A wrapper (Group, DateInput) marks focus on any child.
|
|
54
|
+
within: 'data-[focus-within]:border-brand-green data-[focus-within]:ring-2 data-[focus-within]:ring-ring',
|
|
55
|
+
}
|
|
56
|
+
const outlinedInvalid = {
|
|
57
|
+
self: 'data-[invalid]:border-danger data-[invalid]:ring-2 data-[invalid]:ring-danger',
|
|
58
|
+
// Invalid is owned by the field root (which carries `group`).
|
|
59
|
+
group: 'group-data-[invalid]:border-danger group-data-[invalid]:ring-2 group-data-[invalid]:ring-danger',
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Bordered white field skin, the default appearance of every form control.
|
|
63
|
+
* Pick where focus and invalid state are exposed for the element being styled. */
|
|
64
|
+
export const outlinedFieldClasses = ({
|
|
65
|
+
focus = 'self',
|
|
66
|
+
invalid = 'self',
|
|
67
|
+
}: { focus?: keyof typeof outlinedFocus; invalid?: keyof typeof outlinedInvalid } = {}) =>
|
|
68
|
+
`${outlinedBase} ${outlinedFocus[focus]} ${outlinedInvalid[invalid]}`
|
|
@@ -182,7 +182,7 @@ export function FocusField({
|
|
|
182
182
|
type="button"
|
|
183
183
|
onClick={ctx.close}
|
|
184
184
|
aria-label="Close"
|
|
185
|
-
className="absolute right-3 top-3 inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-fg-subtle outline-none transition-colors hover:bg-surface-muted hover:text-fg focus-visible:ring-2 focus-visible:ring-ring"
|
|
185
|
+
className="absolute right-3 top-3 inline-flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-md text-fg-subtle outline-none transition-colors hover:bg-surface-muted hover:text-fg focus-visible:ring-2 focus-visible:ring-ring"
|
|
186
186
|
>
|
|
187
187
|
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" aria-hidden="true">
|
|
188
188
|
<path d="M6 6l12 12M18 6 6 18" />
|
package/src/components/input.tsx
CHANGED
|
@@ -8,7 +8,17 @@ import {
|
|
|
8
8
|
type TextFieldProps,
|
|
9
9
|
} from 'react-aria-components'
|
|
10
10
|
import { uic } from '../utils/uic'
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
fieldDescriptionClass,
|
|
13
|
+
fieldErrorClass,
|
|
14
|
+
fieldLabelClass,
|
|
15
|
+
fieldSizeClasses,
|
|
16
|
+
fieldStackClass,
|
|
17
|
+
filledFieldClasses,
|
|
18
|
+
outlinedFieldClasses,
|
|
19
|
+
type FieldAppearance,
|
|
20
|
+
type FieldSize,
|
|
21
|
+
} from './field-appearance'
|
|
12
22
|
|
|
13
23
|
/**
|
|
14
24
|
* Input — labelled single-line text field.
|
|
@@ -26,29 +36,18 @@ const StyledInput = uic(RACInput, {
|
|
|
26
36
|
// surface-card — and in dark theme surface-card and surface are the SAME colour
|
|
27
37
|
// (#242423) — so a borderless cream field vanishes on both. Inverted: active =
|
|
28
38
|
// surface, disabled = the muted cream. border #eceae1 → border · hover #aba89c →
|
|
29
|
-
// fg-subtle · focus #75e7b8 → brand-green · error → danger.
|
|
30
|
-
//
|
|
31
|
-
//
|
|
39
|
+
// fg-subtle · focus #75e7b8 → brand-green · error → danger. That outlined skin
|
|
40
|
+
// lives in `outlinedFieldClasses` and every outlined control uses it, so they
|
|
41
|
+
// all render the same box; `fieldSize` adds the single-line height on top.
|
|
32
42
|
baseClass: 'w-full rounded-lg px-4',
|
|
33
43
|
variants: {
|
|
34
44
|
appearance: {
|
|
35
45
|
filled: filledFieldClasses,
|
|
36
|
-
outlined:
|
|
37
|
-
'outline-none transition-colors duration-200 placeholder:text-fg-muted ' +
|
|
38
|
-
'data-[hovered]:border-fg-subtle ' +
|
|
39
|
-
'data-[focused]:border-brand-green data-[focused]:ring-2 data-[focused]:ring-ring ' +
|
|
40
|
-
'data-[invalid]:border-danger data-[invalid]:ring-2 data-[invalid]:ring-danger ' +
|
|
41
|
-
'data-[disabled]:bg-surface-muted data-[disabled]:opacity-60 data-[disabled]:pointer-events-none',
|
|
46
|
+
outlined: outlinedFieldClasses(),
|
|
42
47
|
},
|
|
43
48
|
// `fieldSize` (not `size`) to avoid colliding with the native <input size>
|
|
44
49
|
// attribute, which RAC's Input inherits (a numeric prop).
|
|
45
|
-
fieldSize: {
|
|
46
|
-
sm: 'h-8',
|
|
47
|
-
md: 'h-10',
|
|
48
|
-
filled: 'h-10.5 py-3',
|
|
49
|
-
lg: 'h-12',
|
|
50
|
-
tall: 'h-control-tall',
|
|
51
|
-
},
|
|
50
|
+
fieldSize: { ...fieldSizeClasses, filled: 'h-10.5 py-3' },
|
|
52
51
|
},
|
|
53
52
|
defaultVariants: {
|
|
54
53
|
appearance: 'outlined',
|
|
@@ -66,7 +65,7 @@ export type InputProps = TextFieldProps & {
|
|
|
66
65
|
/** Error message; pass a string for a static error or rely on validation. */
|
|
67
66
|
errorMessage?: string
|
|
68
67
|
placeholder?: string
|
|
69
|
-
size?:
|
|
68
|
+
size?: FieldSize
|
|
70
69
|
/** Optional class for the TextField root. */
|
|
71
70
|
rootClassName?: string
|
|
72
71
|
/** Optional class for the inner native input (for product-specific composition). */
|
|
@@ -74,8 +73,8 @@ export type InputProps = TextFieldProps & {
|
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
export const Input = ({ label, description, errorMessage, placeholder, size, appearance = 'outlined', rootClassName, inputClassName, ...props }: InputProps) => (
|
|
77
|
-
<TextField {...props} className={
|
|
78
|
-
<Label className=
|
|
76
|
+
<TextField {...props} className={`${fieldStackClass} w-full ${rootClassName ?? ''}`}>
|
|
77
|
+
<Label className={fieldLabelClass}>{label}</Label>
|
|
79
78
|
<StyledInput className={inputClassName} placeholder={placeholder} appearance={appearance} fieldSize={size ?? (appearance === 'filled' ? 'filled' : undefined)} />
|
|
80
79
|
{description ? (
|
|
81
80
|
<Text slot="description" className={fieldDescriptionClass}>
|
|
@@ -14,7 +14,15 @@ import {
|
|
|
14
14
|
import { clsx } from 'clsx'
|
|
15
15
|
import { uic } from '../utils/uic'
|
|
16
16
|
import { useInFocusOverlay } from './focus-context'
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
fieldDescriptionClass,
|
|
19
|
+
fieldErrorClass,
|
|
20
|
+
fieldLabelClass,
|
|
21
|
+
fieldSizeClasses,
|
|
22
|
+
fieldStackClass,
|
|
23
|
+
outlinedFieldClasses,
|
|
24
|
+
type FieldSize,
|
|
25
|
+
} from './field-appearance'
|
|
18
26
|
|
|
19
27
|
/**
|
|
20
28
|
* MultiSelect — a dropdown that selects several options at once.
|
|
@@ -77,6 +85,8 @@ export type MultiSelectProps = {
|
|
|
77
85
|
searchable?: boolean
|
|
78
86
|
isDisabled?: boolean
|
|
79
87
|
isInvalid?: boolean
|
|
88
|
+
/** Trigger height, matching `Input`'s `size`. */
|
|
89
|
+
size?: FieldSize
|
|
80
90
|
className?: string
|
|
81
91
|
}
|
|
82
92
|
|
|
@@ -92,6 +102,7 @@ export const MultiSelect = ({
|
|
|
92
102
|
searchable,
|
|
93
103
|
isDisabled,
|
|
94
104
|
isInvalid,
|
|
105
|
+
size = 'md',
|
|
95
106
|
className,
|
|
96
107
|
}: MultiSelectProps) => {
|
|
97
108
|
const labelId = useId()
|
|
@@ -147,8 +158,10 @@ export const MultiSelect = ({
|
|
|
147
158
|
const err = isInvalid && errorMessage ? <span className={fieldErrorClass}>{errorMessage}</span> : null
|
|
148
159
|
|
|
149
160
|
return (
|
|
150
|
-
|
|
151
|
-
|
|
161
|
+
// `data-invalid` on the root drives the trigger's invalid border, as RAC does
|
|
162
|
+
// for the other fields.
|
|
163
|
+
<div className={clsx('group', fieldStackClass, className)} data-invalid={isInvalid || undefined}>
|
|
164
|
+
<span id={labelId} className={fieldLabelClass}>
|
|
152
165
|
{label}
|
|
153
166
|
</span>
|
|
154
167
|
{inFocus ? (
|
|
@@ -166,10 +179,9 @@ export const MultiSelect = ({
|
|
|
166
179
|
isDisabled={isDisabled}
|
|
167
180
|
onPress={() => setOpen(true)}
|
|
168
181
|
className={clsx(
|
|
169
|
-
'flex
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
isInvalid ? 'border-danger ring-2 ring-danger' : 'border-border',
|
|
182
|
+
'flex w-full cursor-pointer items-center justify-between gap-2.5 rounded-lg px-4',
|
|
183
|
+
fieldSizeClasses[size],
|
|
184
|
+
outlinedFieldClasses({ invalid: 'group' }),
|
|
173
185
|
)}
|
|
174
186
|
>
|
|
175
187
|
<span className={clsx('truncate', chosen.length === 0 && 'text-fg-muted')}>{summary}</span>
|
|
@@ -9,7 +9,15 @@ import {
|
|
|
9
9
|
type NumberFieldProps as RACNumberFieldProps,
|
|
10
10
|
Text,
|
|
11
11
|
} from 'react-aria-components'
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
fieldDescriptionClass,
|
|
14
|
+
fieldErrorClass,
|
|
15
|
+
fieldLabelClass,
|
|
16
|
+
fieldSizeClasses,
|
|
17
|
+
fieldStackClass,
|
|
18
|
+
outlinedFieldClasses,
|
|
19
|
+
type FieldSize,
|
|
20
|
+
} from './field-appearance'
|
|
13
21
|
|
|
14
22
|
/**
|
|
15
23
|
* NumberField — numeric input with steppers, min/max and locale-aware formatting
|
|
@@ -17,8 +25,8 @@ import { fieldDescriptionClass, fieldErrorClass } from './field-appearance'
|
|
|
17
25
|
* Components `NumberField`; styled to match the other form fields.
|
|
18
26
|
*/
|
|
19
27
|
const stepper =
|
|
20
|
-
'flex h-full w-9 shrink-0 items-center justify-center text-body text-fg-muted outline-none transition-colors ' +
|
|
21
|
-
'hover:bg-surface-muted hover:text-fg data-[pressed]:bg-surface-muted data-[disabled]:opacity-40'
|
|
28
|
+
'flex h-full w-9 shrink-0 cursor-pointer items-center justify-center text-body text-fg-muted outline-none transition-colors ' +
|
|
29
|
+
'hover:bg-surface-muted hover:text-fg data-[pressed]:bg-surface-muted data-[disabled]:cursor-not-allowed data-[disabled]:opacity-40'
|
|
22
30
|
|
|
23
31
|
export type NumberFieldProps = RACNumberFieldProps & {
|
|
24
32
|
/** Visible label (required for accessibility). */
|
|
@@ -26,18 +34,17 @@ export type NumberFieldProps = RACNumberFieldProps & {
|
|
|
26
34
|
description?: ReactNode
|
|
27
35
|
errorMessage?: string
|
|
28
36
|
placeholder?: string
|
|
37
|
+
/** Field height, matching `Input`'s `size`. */
|
|
38
|
+
size?: FieldSize
|
|
29
39
|
}
|
|
30
40
|
|
|
31
|
-
export const NumberField = ({ label, description, errorMessage, placeholder, ...props }: NumberFieldProps) => (
|
|
32
|
-
<RACNumberField {...props} className=
|
|
33
|
-
<Label className=
|
|
41
|
+
export const NumberField = ({ label, description, errorMessage, placeholder, size = 'md', ...props }: NumberFieldProps) => (
|
|
42
|
+
<RACNumberField {...props} className={`group ${fieldStackClass}`}>
|
|
43
|
+
<Label className={fieldLabelClass}>{label}</Label>
|
|
34
44
|
<Group
|
|
35
45
|
className={
|
|
36
|
-
|
|
37
|
-
'
|
|
38
|
-
'data-[focus-within]:border-brand-green data-[focus-within]:ring-2 data-[focus-within]:ring-ring ' +
|
|
39
|
-
'group-data-[invalid]:border-danger group-data-[invalid]:ring-2 group-data-[invalid]:ring-danger ' +
|
|
40
|
-
'data-[disabled]:bg-surface-muted data-[disabled]:opacity-60'
|
|
46
|
+
`flex w-full items-center overflow-hidden rounded-lg ${fieldSizeClasses[size]} ` +
|
|
47
|
+
outlinedFieldClasses({ focus: 'within', invalid: 'group' })
|
|
41
48
|
}
|
|
42
49
|
>
|
|
43
50
|
<RACButton slot="decrement" className={`${stepper} border-r border-border`}>
|
|
@@ -138,7 +138,7 @@ export function RichTextEditor({
|
|
|
138
138
|
title={t.title}
|
|
139
139
|
onMouseDown={(e) => e.preventDefault()}
|
|
140
140
|
onClick={() => t.run(exec)}
|
|
141
|
-
className="rounded border-0 bg-transparent px-2.5 py-0.5 text-label text-fg-muted transition-colors hover:bg-surface hover:text-fg"
|
|
141
|
+
className="cursor-pointer rounded border-0 bg-transparent px-2.5 py-0.5 text-label text-fg-muted transition-colors hover:bg-surface hover:text-fg"
|
|
142
142
|
>
|
|
143
143
|
{t.label}
|
|
144
144
|
</button>
|
|
@@ -7,7 +7,14 @@ import {
|
|
|
7
7
|
type SearchFieldProps as RACSearchFieldProps,
|
|
8
8
|
Text,
|
|
9
9
|
} from 'react-aria-components'
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
fieldDescriptionClass,
|
|
12
|
+
fieldLabelClass,
|
|
13
|
+
fieldSizeClasses,
|
|
14
|
+
fieldStackClass,
|
|
15
|
+
outlinedFieldClasses,
|
|
16
|
+
type FieldSize,
|
|
17
|
+
} from './field-appearance'
|
|
11
18
|
|
|
12
19
|
/**
|
|
13
20
|
* SearchField — a text input for search, with a clear (✕) button that appears
|
|
@@ -35,24 +42,24 @@ export type SearchFieldProps = RACSearchFieldProps & {
|
|
|
35
42
|
label?: ReactNode
|
|
36
43
|
description?: ReactNode
|
|
37
44
|
placeholder?: string
|
|
45
|
+
/** Field height, matching `Input`'s `size`. */
|
|
46
|
+
size?: FieldSize
|
|
38
47
|
}
|
|
39
48
|
|
|
40
|
-
export const SearchField = ({ label, description, placeholder, ...props }: SearchFieldProps) => (
|
|
41
|
-
<RACSearchField {...props} className=
|
|
42
|
-
{label ? <Label className=
|
|
49
|
+
export const SearchField = ({ label, description, placeholder, size = 'md', ...props }: SearchFieldProps) => (
|
|
50
|
+
<RACSearchField {...props} className={`group ${fieldStackClass}`}>
|
|
51
|
+
{label ? <Label className={fieldLabelClass}>{label}</Label> : null}
|
|
43
52
|
<div className="relative flex items-center">
|
|
44
53
|
<SearchGlyph />
|
|
45
54
|
<RACInput
|
|
46
55
|
placeholder={placeholder}
|
|
47
56
|
className={
|
|
48
|
-
|
|
49
|
-
'placeholder:text-fg-muted data-[hovered]:border-fg-subtle ' +
|
|
50
|
-
'data-[focused]:border-brand-green data-[focused]:ring-2 data-[focused]:ring-ring ' +
|
|
57
|
+
`w-full rounded-lg pl-10 pr-10 ${fieldSizeClasses[size]} ${outlinedFieldClasses()} ` +
|
|
51
58
|
'[&::-webkit-search-cancel-button]:hidden'
|
|
52
59
|
}
|
|
53
60
|
/>
|
|
54
61
|
{/* RAC hides this automatically when the field is empty. */}
|
|
55
|
-
<RACButton className="absolute right-2 flex h-7 w-7 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">
|
|
62
|
+
<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">
|
|
56
63
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" aria-hidden="true">
|
|
57
64
|
<path d="M6 6l12 12M18 6 6 18" />
|
|
58
65
|
</svg>
|
|
@@ -14,7 +14,16 @@ import {
|
|
|
14
14
|
} from 'react-aria-components'
|
|
15
15
|
import { uic } from '../utils/uic'
|
|
16
16
|
import { useInFocusOverlay } from './focus-context'
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
fieldDescriptionClass,
|
|
19
|
+
fieldErrorClass,
|
|
20
|
+
fieldLabelClass,
|
|
21
|
+
fieldSizeClasses,
|
|
22
|
+
fieldStackClass,
|
|
23
|
+
outlinedFieldClasses,
|
|
24
|
+
type FieldAppearance,
|
|
25
|
+
type FieldSize,
|
|
26
|
+
} from './field-appearance'
|
|
18
27
|
|
|
19
28
|
const SelectAppearanceContext = createContext<FieldAppearance>('outlined')
|
|
20
29
|
const filledPopoverStyle: CSSProperties & { '--select-popup-max-width': string } = {
|
|
@@ -27,31 +36,31 @@ const filledPopoverStyle: CSSProperties & { '--select-popup-max-width': string }
|
|
|
27
36
|
* RAC handles the listbox ARIA pattern, keyboard navigation, typeahead and
|
|
28
37
|
* focus management. Styling via `uic`. Pass options as `SelectItem` children.
|
|
29
38
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
39
|
+
* The outlined trigger uses the shared outlined skin and `size` scale, so it is
|
|
40
|
+
* the same box as an `Input` of the same size and a mixed form lines up. The
|
|
41
|
+
* filled trigger follows gs-platform's designer spec (Figma GraphicStandard 1.5,
|
|
42
|
+
* node 2115-4271, `Select.module.scss`). gs token map:
|
|
33
43
|
* hover border #aba89c → fg-subtle · text #0d0d0d → fg · placeholder → fg-muted ·
|
|
34
44
|
* 8px radius → rounded-lg · 6px item radius → rounded-md · error → danger.
|
|
35
45
|
*/
|
|
36
46
|
const SelectTrigger = uic(RACButton, {
|
|
37
47
|
displayName: 'SelectTrigger',
|
|
38
|
-
// Filled follows the Manager's borderless control
|
|
39
|
-
//
|
|
48
|
+
// Filled follows the Manager's borderless control. Outlined is the shared
|
|
49
|
+
// outlined skin; its height comes from `fieldSize`.
|
|
40
50
|
baseClass:
|
|
41
|
-
'flex w-full items-center justify-between gap-2.5 rounded-lg
|
|
51
|
+
'flex w-full cursor-pointer items-center justify-between gap-2.5 rounded-lg text-small text-fg outline-none transition-colors',
|
|
42
52
|
variants: {
|
|
43
53
|
appearance: {
|
|
44
|
-
filled: 'min-h-control-tall border-0 bg-surface-card py-5 font-normal leading-4.5 duration-200 motion-reduce:transition-none ' +
|
|
54
|
+
filled: 'min-h-control-tall border-0 bg-surface-card px-5 py-5 font-normal leading-4.5 duration-200 motion-reduce:transition-none ' +
|
|
45
55
|
'data-[hovered]:bg-surface-muted group-data-[open]:bg-surface-card ' +
|
|
46
56
|
'data-[focus-visible]:outline-solid data-[focus-visible]:outline-2 data-[focus-visible]:outline-ring data-[focus-visible]:outline-offset-2 ' +
|
|
47
57
|
'group-data-[invalid]:ring-1 group-data-[invalid]:ring-danger ' +
|
|
48
58
|
'data-[disabled]:bg-surface-card data-[disabled]:opacity-50 data-[disabled]:cursor-not-allowed',
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
'data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring ' +
|
|
52
|
-
'group-data-[invalid]:border-danger group-data-[invalid]:ring-2 group-data-[invalid]:ring-danger ' +
|
|
53
|
-
'data-[disabled]:bg-surface-muted data-[disabled]:opacity-60 data-[disabled]:pointer-events-none',
|
|
59
|
+
// Invalid lives on the Select root, not on the trigger button.
|
|
60
|
+
outlined: `px-4 ${outlinedFieldClasses({ invalid: 'group' })}`,
|
|
54
61
|
},
|
|
62
|
+
// Outlined only: filled keeps its fixed Manager height.
|
|
63
|
+
fieldSize: fieldSizeClasses,
|
|
55
64
|
},
|
|
56
65
|
defaultVariants: { appearance: 'outlined' },
|
|
57
66
|
})
|
|
@@ -104,6 +113,8 @@ const SelectPopover = uic(Popover, {
|
|
|
104
113
|
|
|
105
114
|
export type SelectProps<T extends object> = RACSelectProps<T> & {
|
|
106
115
|
appearance?: FieldAppearance
|
|
116
|
+
/** Outlined trigger height, matching `Input`'s `size`. Ignored when filled. */
|
|
117
|
+
size?: FieldSize
|
|
107
118
|
/** Keep the accessible label without reserving an empty label row. */
|
|
108
119
|
isLabelHidden?: boolean
|
|
109
120
|
/** Visible label (required for accessibility). */
|
|
@@ -132,6 +143,7 @@ export const Select = <T extends object>({
|
|
|
132
143
|
rootClassName,
|
|
133
144
|
triggerClassName,
|
|
134
145
|
appearance = 'outlined',
|
|
146
|
+
size = 'md',
|
|
135
147
|
isLabelHidden = false,
|
|
136
148
|
...props
|
|
137
149
|
}: SelectProps<T>) => {
|
|
@@ -151,8 +163,8 @@ export const Select = <T extends object>({
|
|
|
151
163
|
|
|
152
164
|
return (
|
|
153
165
|
<SelectAppearanceContext.Provider value={appearance}>
|
|
154
|
-
<RACSelect {...props} placeholder={placeholder} className={`group
|
|
155
|
-
<Label className={isLabelHidden ? 'sr-only' :
|
|
166
|
+
<RACSelect {...props} placeholder={placeholder} className={`group ${fieldStackClass} ${rootClassName ?? ''}`}>
|
|
167
|
+
<Label className={isLabelHidden ? 'sr-only' : fieldLabelClass}>{label}</Label>
|
|
156
168
|
{inFocus ? (
|
|
157
169
|
<>
|
|
158
170
|
{listbox}
|
|
@@ -161,8 +173,9 @@ export const Select = <T extends object>({
|
|
|
161
173
|
</>
|
|
162
174
|
) : (
|
|
163
175
|
<>
|
|
164
|
-
<SelectTrigger className={triggerClassName} appearance={appearance}>
|
|
165
|
-
|
|
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" />
|
|
166
179
|
{/* gs chevron: 9.5px caret, dark (neutral-400 → fg), non-interactive. */}
|
|
167
180
|
<svg
|
|
168
181
|
width="9.5"
|
|
@@ -61,7 +61,7 @@ const SidePanelSurface = uic(RACModal, {
|
|
|
61
61
|
const SidePanelClose = uic(RACButton, {
|
|
62
62
|
displayName: 'SidePanel.Close',
|
|
63
63
|
baseClass:
|
|
64
|
-
'inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-full text-fg-subtle outline-none ' +
|
|
64
|
+
'inline-flex h-11 w-11 shrink-0 cursor-pointer items-center justify-center rounded-full text-fg-subtle outline-none ' +
|
|
65
65
|
'transition-colors hover:bg-surface-muted hover:text-fg ' +
|
|
66
66
|
'data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring data-[focus-visible]:ring-offset-2',
|
|
67
67
|
})
|
package/src/components/table.tsx
CHANGED
|
@@ -137,7 +137,7 @@ export function Table<Row>({
|
|
|
137
137
|
<button
|
|
138
138
|
type="button"
|
|
139
139
|
onClick={() => toggleSort(column.key)}
|
|
140
|
-
className={`inline-flex items-center gap-1 outline-none transition-colors hover:text-fg focus-visible:text-fg ${
|
|
140
|
+
className={`inline-flex cursor-pointer items-center gap-1 outline-none transition-colors hover:text-fg focus-visible:text-fg ${
|
|
141
141
|
align === 'right' ? 'flex-row-reverse' : ''
|
|
142
142
|
} ${active ? 'text-fg' : ''}`}
|
|
143
143
|
>
|
|
@@ -54,7 +54,7 @@ export const Tag = ({ children, textValue, ...props }: RACTagProps) => (
|
|
|
54
54
|
{allowsRemoving ? (
|
|
55
55
|
<RACButton
|
|
56
56
|
slot="remove"
|
|
57
|
-
className="-mr-1 flex h-4 w-4 items-center justify-center rounded-full text-fg-subtle outline-none transition-colors hover:bg-surface-muted hover:text-fg data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring"
|
|
57
|
+
className="-mr-1 flex h-4 w-4 cursor-pointer data-[disabled]:cursor-not-allowed items-center justify-center rounded-full text-fg-subtle outline-none transition-colors hover:bg-surface-muted hover:text-fg data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring"
|
|
58
58
|
>
|
|
59
59
|
<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3" strokeLinecap="round" aria-hidden="true">
|
|
60
60
|
<path d="M6 6l12 12M18 6 6 18" />
|
|
@@ -8,7 +8,15 @@ import {
|
|
|
8
8
|
type TextFieldProps,
|
|
9
9
|
} from 'react-aria-components'
|
|
10
10
|
import { uic } from '../utils/uic'
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
fieldDescriptionClass,
|
|
13
|
+
fieldErrorClass,
|
|
14
|
+
fieldLabelClass,
|
|
15
|
+
fieldStackClass,
|
|
16
|
+
filledFieldClasses,
|
|
17
|
+
outlinedFieldClasses,
|
|
18
|
+
type FieldAppearance,
|
|
19
|
+
} from './field-appearance'
|
|
12
20
|
|
|
13
21
|
/**
|
|
14
22
|
* Textarea — labelled multi-line text field.
|
|
@@ -31,12 +39,7 @@ const StyledTextArea = uic(RACTextArea, {
|
|
|
31
39
|
variants: {
|
|
32
40
|
appearance: {
|
|
33
41
|
filled: filledFieldClasses,
|
|
34
|
-
outlined:
|
|
35
|
-
'outline-none transition-colors duration-200 placeholder:text-fg-muted ' +
|
|
36
|
-
'data-[hovered]:border-fg-subtle ' +
|
|
37
|
-
'data-[focused]:border-brand-green data-[focused]:ring-2 data-[focused]:ring-ring ' +
|
|
38
|
-
'data-[invalid]:border-danger data-[invalid]:ring-danger ' +
|
|
39
|
-
'data-[disabled]:bg-surface-muted data-[disabled]:opacity-60 data-[disabled]:pointer-events-none',
|
|
42
|
+
outlined: outlinedFieldClasses(),
|
|
40
43
|
},
|
|
41
44
|
},
|
|
42
45
|
defaultVariants: { appearance: 'outlined' },
|
|
@@ -60,8 +63,8 @@ export type TextareaProps = TextFieldProps & {
|
|
|
60
63
|
export const Textarea = ({ label, description, errorMessage, placeholder, rows, textAreaClassName, appearance = 'outlined', ...props }: TextareaProps) => (
|
|
61
64
|
// Label and gap match `Input` in both appearances (gs 17px/20px field label,
|
|
62
65
|
// 12px to the control), so a Title + Description pair reads as one form.
|
|
63
|
-
<TextField {...props} className=
|
|
64
|
-
<Label className=
|
|
66
|
+
<TextField {...props} className={`${fieldStackClass} w-full`}>
|
|
67
|
+
<Label className={fieldLabelClass}>{label}</Label>
|
|
65
68
|
<StyledTextArea className={textAreaClassName} placeholder={placeholder} rows={rows} appearance={appearance} />
|
|
66
69
|
{description ? (
|
|
67
70
|
<Text slot="description" className={fieldDescriptionClass}>
|
package/src/components/tile.tsx
CHANGED
|
@@ -45,7 +45,7 @@ const THEME: Record<TileTheme, string> = {
|
|
|
45
45
|
const baseSurface = 'flex h-full min-h-[200px] flex-col gap-6 overflow-hidden rounded-lg p-4'
|
|
46
46
|
|
|
47
47
|
/** Focus treatment for interactive tiles; generic tiles do not lift or cast a shadow. */
|
|
48
|
-
const interactive = 'no-underline outline-none focus-visible:ring-2 focus-visible:ring-ring'
|
|
48
|
+
const interactive = 'cursor-pointer no-underline outline-none focus-visible:ring-2 focus-visible:ring-ring'
|
|
49
49
|
|
|
50
50
|
export type TileProps = {
|
|
51
51
|
/** Surface theme (gs's Figma palette). */
|
|
@@ -233,7 +233,7 @@ function MediaHero({
|
|
|
233
233
|
type="button"
|
|
234
234
|
aria-label={closeLabel}
|
|
235
235
|
onClick={() => setPlaying(false)}
|
|
236
|
-
className="absolute right-4 top-4 z-20 flex h-8 w-8 items-center justify-center rounded-full bg-black/60 text-white outline-none transition-colors hover:bg-black/80 focus-visible:ring-2 focus-visible:ring-white/70"
|
|
236
|
+
className="absolute right-4 top-4 z-20 flex h-8 w-8 cursor-pointer items-center justify-center rounded-full bg-black/60 text-white outline-none transition-colors hover:bg-black/80 focus-visible:ring-2 focus-visible:ring-white/70"
|
|
237
237
|
>
|
|
238
238
|
<CloseIcon className="h-4 w-4" />
|
|
239
239
|
</button>
|
package/src/components/toast.tsx
CHANGED
|
@@ -159,7 +159,7 @@ export const ToastRegion = ({
|
|
|
159
159
|
<RACButton
|
|
160
160
|
slot="close"
|
|
161
161
|
aria-label={closeLabel}
|
|
162
|
-
className="inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-fg-subtle outline-none transition-colors hover:bg-surface-muted hover:text-fg data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring"
|
|
162
|
+
className="inline-flex h-6 w-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-fg-subtle outline-none transition-colors hover:bg-surface-muted hover:text-fg data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring"
|
|
163
163
|
>
|
|
164
164
|
<CloseIcon />
|
|
165
165
|
</RACButton>
|
|
@@ -135,7 +135,7 @@ export function canOpenSlash(state: EditorState, from: number): boolean {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
const btn =
|
|
138
|
-
'inline-flex h-8 min-w-8 items-center justify-center rounded-md px-2 text-small text-fg-muted transition-colors hover:bg-surface-muted hover:text-fg data-[active=true]:bg-surface-muted data-[active=true]:text-fg'
|
|
138
|
+
'inline-flex h-8 min-w-8 cursor-pointer items-center justify-center rounded-md px-2 text-small text-fg-muted transition-colors hover:bg-surface-muted hover:text-fg data-[active=true]:bg-surface-muted data-[active=true]:text-fg'
|
|
139
139
|
|
|
140
140
|
/** Marks the bubble toolbar toggles. `active` keys read off the useEditorState
|
|
141
141
|
* snapshot below — Tiptap 3 does NOT re-render on transactions, so a plain
|
package/src/layout/app-shell.tsx
CHANGED
|
@@ -170,7 +170,7 @@ export const AppShell = ({
|
|
|
170
170
|
aria-controls={drawerOpen ? drawerId : undefined}
|
|
171
171
|
onPress={() => setDrawerOpen((open) => !open)}
|
|
172
172
|
className={
|
|
173
|
-
'ms-6 flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-fg outline-none ' +
|
|
173
|
+
'ms-6 flex h-9 w-9 shrink-0 cursor-pointer items-center justify-center rounded-md text-fg outline-none ' +
|
|
174
174
|
'transition-colors hover:bg-surface-muted md:hidden ' +
|
|
175
175
|
'data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring'
|
|
176
176
|
}
|
package/src/layout/topbar.tsx
CHANGED
|
@@ -194,7 +194,7 @@ export const UserMenu = ({ trigger, triggerLabel, onAction, children }: UserMenu
|
|
|
194
194
|
<RACButton
|
|
195
195
|
aria-label={triggerLabel}
|
|
196
196
|
className={
|
|
197
|
-
'flex h-9 items-center gap-2 rounded-md px-2 text-small font-medium text-fg outline-none ' +
|
|
197
|
+
'flex h-9 cursor-pointer items-center gap-2 rounded-md px-2 text-small font-medium text-fg outline-none ' +
|
|
198
198
|
'transition-colors hover:bg-surface-muted ' +
|
|
199
199
|
'data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring'
|
|
200
200
|
}
|