@vendure-io/ui 3.0.0-next.4 → 3.0.0-next.6
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 +12 -11
- package/src/components/atoms/alert-dialog.tsx +1 -4
- package/src/components/atoms/alert.tsx +59 -35
- package/src/components/atoms/badge.tsx +2 -2
- package/src/components/atoms/breadcrumb.tsx +154 -59
- package/src/components/atoms/button-group.tsx +1 -1
- package/src/components/atoms/button.tsx +2 -2
- package/src/components/atoms/calendar.tsx +2 -2
- package/src/components/atoms/card.tsx +15 -2
- package/src/components/atoms/carousel.tsx +33 -7
- package/src/components/atoms/chart.tsx +3 -3
- package/src/components/atoms/checkbox.tsx +1 -1
- package/src/components/atoms/combobox.tsx +60 -36
- package/src/components/atoms/command.tsx +17 -7
- package/src/components/atoms/context-menu.tsx +5 -5
- package/src/components/atoms/dialog.tsx +30 -14
- package/src/components/atoms/dropdown-menu.tsx +1 -1
- package/src/components/atoms/hover-card.tsx +1 -1
- package/src/components/atoms/input-group.tsx +30 -12
- package/src/components/atoms/input-otp.tsx +2 -2
- package/src/components/atoms/input.tsx +13 -3
- package/src/components/atoms/menubar.tsx +2 -2
- package/src/components/atoms/native-select.tsx +1 -1
- package/src/components/atoms/navigation-menu.tsx +3 -3
- package/src/components/atoms/pagination.tsx +52 -15
- package/src/components/atoms/popover.tsx +1 -1
- package/src/components/atoms/select.tsx +3 -3
- package/src/components/atoms/sheet.tsx +35 -15
- package/src/components/atoms/sidebar.tsx +224 -36
- package/src/components/atoms/skeleton.tsx +6 -3
- package/src/components/atoms/spinner.tsx +7 -2
- package/src/components/atoms/tabs.tsx +6 -2
- package/src/components/atoms/textarea.tsx +1 -1
- package/src/components/atoms/toggle.tsx +1 -1
- package/src/components/molecules/action-needed.tsx +483 -0
- package/src/components/molecules/anonymized-token.tsx +70 -25
- package/src/components/molecules/app-shell.tsx +14 -5
- package/src/components/molecules/checklist/checklist.tsx +47 -17
- package/src/components/molecules/chip.tsx +37 -19
- package/src/components/molecules/choice-card.tsx +117 -9
- package/src/components/molecules/code-block/package-manager-storage.ts +50 -0
- package/src/components/molecules/code-block/process-code.ts +1 -1
- package/src/components/molecules/code-block.tsx +58 -47
- package/src/components/molecules/combobox-free-text.tsx +75 -20
- package/src/components/molecules/confirm-dialog.tsx +17 -5
- package/src/components/molecules/copyable-text.tsx +10 -8
- package/src/components/molecules/data-table/data-table-filters.tsx +36 -6
- package/src/components/molecules/data-table/data-table-helpers.tsx +109 -3
- package/src/components/molecules/data-table/data-table-row-count-storage.tsx +88 -0
- package/src/components/molecules/data-table/data-table-selection-storage.tsx +33 -15
- package/src/components/molecules/data-table/data-table-types.tsx +156 -29
- package/src/components/molecules/data-table/data-table-view-options.tsx +14 -4
- package/src/components/molecules/data-table/data-table.tsx +156 -75
- package/src/components/molecules/data-table/table-pagination.tsx +142 -38
- package/src/components/molecules/date-picker.tsx +58 -25
- package/src/components/molecules/date-range-picker.tsx +59 -24
- package/src/components/molecules/date-time-picker.tsx +63 -25
- package/src/components/molecules/date-time.tsx +38 -3
- package/src/components/molecules/elapsed-time.tsx +61 -12
- package/src/components/molecules/file-dropzone.tsx +151 -40
- package/src/components/molecules/format-provider.tsx +14 -4
- package/src/components/molecules/id-chip-chrome.tsx +114 -0
- package/src/components/molecules/id-chip.tsx +13 -115
- package/src/components/molecules/issued-secret.tsx +35 -25
- package/src/components/molecules/live-indicator.tsx +1 -1
- package/src/components/molecules/money.tsx +44 -3
- package/src/components/molecules/multi-select.tsx +62 -16
- package/src/components/molecules/page-header.tsx +6 -2
- package/src/components/molecules/password-input.tsx +11 -10
- package/src/components/molecules/relative-time.tsx +88 -16
- package/src/components/molecules/search-trigger.tsx +5 -3
- package/src/components/molecules/secret-value.tsx +35 -19
- package/src/components/molecules/skip-link.tsx +11 -9
- package/src/components/molecules/stat-card.tsx +145 -33
- package/src/components/molecules/state-views/empty-state.tsx +16 -12
- package/src/components/molecules/state-views/error-state.tsx +36 -20
- package/src/components/molecules/state-views/loading-state.tsx +18 -6
- package/src/components/molecules/state-views/skeleton-parts.tsx +6 -4
- package/src/components/molecules/status-badge.tsx +11 -35
- package/src/components/molecules/time-tooltip.tsx +55 -1
- package/src/hooks/use-copy.ts +3 -1
- package/src/lib/deprecated.ts +71 -0
- package/src/lib/field-surface.ts +7 -7
- package/src/lib/format-messages.ts +368 -0
- package/src/lib/highlight.ts +1 -1
- package/src/lib/menu-item.tsx +1 -1
- package/src/lib/tint-recipes.ts +10 -5
- package/src/lib/utils.ts +19 -1
- package/src/lib/dialog-padding.ts +0 -48
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
import { Skeleton } from '@vendure-io/ui/components/atoms/skeleton';
|
|
2
4
|
import { Spinner } from '@vendure-io/ui/components/atoms/spinner';
|
|
3
5
|
import { cn } from '@vendure-io/ui/lib/utils';
|
|
4
6
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
5
7
|
import { Children } from 'react';
|
|
8
|
+
import { warnDeprecated } from '../../../lib/deprecated.ts';
|
|
9
|
+
import { useMessages } from '../../../lib/format-messages.ts';
|
|
6
10
|
|
|
7
11
|
const loadingStateVariants = cva('flex w-full min-w-0 flex-col gap-3', {
|
|
8
12
|
variants: {
|
|
@@ -25,9 +29,14 @@ export interface LoadingStateProps
|
|
|
25
29
|
rows?: number;
|
|
26
30
|
/** Classes applied to each skeleton row (e.g. `h-10` for tighter lists). */
|
|
27
31
|
rowClassName?: string;
|
|
28
|
-
/** Visible label. An sr-only `
|
|
32
|
+
/** Visible label. An sr-only `loadingLabel` is always rendered for assistive tech. */
|
|
29
33
|
label?: React.ReactNode;
|
|
30
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Sr-only text announced to assistive tech.
|
|
36
|
+
* @default `messages.loadingState.loading`, "Loading…"
|
|
37
|
+
*/
|
|
38
|
+
loadingLabel?: string;
|
|
39
|
+
/** @deprecated Use `loadingLabel`. Removed in 4.0. */
|
|
31
40
|
srLabel?: string;
|
|
32
41
|
/**
|
|
33
42
|
* Milliseconds before the placeholder appears. A load that ends sooner never
|
|
@@ -51,8 +60,8 @@ const DELAYED_ENTRY =
|
|
|
51
60
|
|
|
52
61
|
/**
|
|
53
62
|
* Placeholder shell for in-flight list/detail queries. Renders as an
|
|
54
|
-
* `aria-live` `<output>` with an always-present sr-only `
|
|
55
|
-
* "Loading…",
|
|
63
|
+
* `aria-live` `<output>` with an always-present sr-only `loadingLabel` (defaults to
|
|
64
|
+
* "Loading…", or `FormatProvider`'s `messages.loadingState.loading`).
|
|
56
65
|
* `skeleton` (default) draws N shimmer rows, or the skeleton parts passed as
|
|
57
66
|
* children; `spinner` centers the `Spinner` atom for compact or unknown-height
|
|
58
67
|
* regions. Nothing shows for the first `delay` ms (150 by default).
|
|
@@ -62,13 +71,16 @@ function LoadingState({
|
|
|
62
71
|
rows = 5,
|
|
63
72
|
rowClassName,
|
|
64
73
|
label,
|
|
65
|
-
|
|
74
|
+
loadingLabel,
|
|
75
|
+
srLabel,
|
|
66
76
|
delay = 150,
|
|
67
77
|
children,
|
|
68
78
|
className,
|
|
69
79
|
style,
|
|
70
80
|
...props
|
|
71
81
|
}: LoadingStateProps) {
|
|
82
|
+
if (srLabel !== undefined) warnDeprecated('LoadingState', 'srLabel', 'loadingLabel');
|
|
83
|
+
const t = useMessages('loadingState', { loading: loadingLabel ?? srLabel });
|
|
72
84
|
return (
|
|
73
85
|
<output
|
|
74
86
|
data-slot="loading-state"
|
|
@@ -81,7 +93,7 @@ function LoadingState({
|
|
|
81
93
|
}
|
|
82
94
|
{...props}
|
|
83
95
|
>
|
|
84
|
-
<span className="sr-only">{
|
|
96
|
+
<span className="sr-only">{t.loading}</span>
|
|
85
97
|
{variant === 'spinner' ? (
|
|
86
98
|
<>
|
|
87
99
|
{/* aria-hidden overrides the atom's role="status": the <output> is
|
|
@@ -35,18 +35,20 @@ import * as React from 'react';
|
|
|
35
35
|
* One text line of placeholder: a box exactly one line box tall (`1lh` of the
|
|
36
36
|
* inherited text style) with a bar centred in it. Size it with a text utility
|
|
37
37
|
* (`text-xs`, `text-style-page-title`) and its width with `w-*`. The building
|
|
38
|
-
* block of every other part; stack several for a paragraph.
|
|
38
|
+
* block of every other part; stack several for a paragraph. It is a <span>, so
|
|
39
|
+
* it can also stand in for a value inside a paragraph: give it `inline-flex`
|
|
40
|
+
* and a width there.
|
|
39
41
|
*/
|
|
40
|
-
function SkeletonLine({ className, ...props }: React.ComponentProps<'
|
|
42
|
+
function SkeletonLine({ className, ...props }: React.ComponentProps<'span'>) {
|
|
41
43
|
return (
|
|
42
|
-
<
|
|
44
|
+
<span
|
|
43
45
|
data-skeleton="line"
|
|
44
46
|
aria-hidden="true"
|
|
45
47
|
className={cn('flex h-lh w-full items-center', className)}
|
|
46
48
|
{...props}
|
|
47
49
|
>
|
|
48
50
|
<Skeleton className="h-[0.8lh] w-full" />
|
|
49
|
-
</
|
|
51
|
+
</span>
|
|
50
52
|
);
|
|
51
53
|
}
|
|
52
54
|
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { mergeProps } from '@base-ui/react/merge-props';
|
|
2
2
|
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
-
import { contentInsetPull } from '@vendure-io/ui/lib/content-inset';
|
|
4
3
|
import type { Tone } from '@vendure-io/ui/lib/state-dictionary';
|
|
4
|
+
import { toneIcons } from '@vendure-io/ui/lib/tone-icons';
|
|
5
|
+
import { cn } from '@vendure-io/ui/lib/utils';
|
|
6
|
+
import { cva } from 'class-variance-authority';
|
|
7
|
+
import type * as React from 'react';
|
|
8
|
+
import { isValidElement } from 'react';
|
|
9
|
+
import { contentInsetPull } from '../../lib/content-inset.ts';
|
|
5
10
|
import {
|
|
6
11
|
statusChipFill,
|
|
7
12
|
statusChipLabel,
|
|
8
13
|
statusChipRing,
|
|
9
14
|
statusToneText,
|
|
10
15
|
statusToneVars,
|
|
11
|
-
} from '
|
|
12
|
-
import { toneIcons } from '@vendure-io/ui/lib/tone-icons';
|
|
13
|
-
import { cn } from '@vendure-io/ui/lib/utils';
|
|
14
|
-
import { cva } from 'class-variance-authority';
|
|
15
|
-
import type * as React from 'react';
|
|
16
|
-
import { isValidElement } from 'react';
|
|
16
|
+
} from '../../lib/tint-recipes.ts';
|
|
17
17
|
// Relative: `time-tooltip` is internal.
|
|
18
18
|
import { InStatusDetail } from './time-tooltip.tsx';
|
|
19
19
|
|
|
@@ -62,31 +62,12 @@ const rowRevealClass = [
|
|
|
62
62
|
|
|
63
63
|
const chipLabel = statusChipLabel;
|
|
64
64
|
|
|
65
|
-
// Code written for 2.x puts its own icon in `children`. Its `<svg>` is then a
|
|
66
|
-
// direct child of the badge, and the tone icon (or spinner) hides, so the
|
|
67
|
-
// badge shows one icon. A dot stays: 2.x had it too.
|
|
68
|
-
const ownIconHidesToneIcon = '[&:has(>svg)>[data-marker=icon]]:hidden';
|
|
69
|
-
|
|
70
|
-
// That own icon takes the tone colour, as the tone icon does, so two badges
|
|
71
|
-
// of one state look the same. The rule is in `:where()`, so it has no
|
|
72
|
-
// specificity: a colour class on the icon wins. Static per tone for
|
|
73
|
-
// Tailwind's scanner, matching `statusToneText`.
|
|
74
|
-
const ownIconToneText: Record<Tone, string> = {
|
|
75
|
-
neutral: '[:where(&>svg)]:text-neutral-text',
|
|
76
|
-
info: '[:where(&>svg)]:text-info-text',
|
|
77
|
-
success: '[:where(&>svg)]:text-success-text',
|
|
78
|
-
warning: '[:where(&>svg)]:text-warning-text',
|
|
79
|
-
critical: '[:where(&>svg)]:text-destructive-text',
|
|
80
|
-
progress: '[:where(&>svg)]:text-info-text',
|
|
81
|
-
};
|
|
82
|
-
|
|
83
65
|
const statusBadgeVariants = cva(
|
|
84
66
|
[
|
|
85
67
|
'inline-flex w-fit shrink-0 items-center justify-center overflow-hidden whitespace-nowrap rounded-lg font-medium',
|
|
86
68
|
statusChipFill,
|
|
87
69
|
statusChipRing,
|
|
88
70
|
chipLabel,
|
|
89
|
-
ownIconHidesToneIcon,
|
|
90
71
|
'outline-1 outline-transparent -outline-offset-1',
|
|
91
72
|
contentInsetPull,
|
|
92
73
|
],
|
|
@@ -126,7 +107,6 @@ const bareVariants = cva(
|
|
|
126
107
|
[
|
|
127
108
|
'inline-flex w-fit shrink-0 items-center gap-1.5 whitespace-nowrap font-medium',
|
|
128
109
|
chipLabel,
|
|
129
|
-
ownIconHidesToneIcon,
|
|
130
110
|
contentInsetPull,
|
|
131
111
|
],
|
|
132
112
|
{
|
|
@@ -245,10 +225,8 @@ interface StatusBadgeProps extends useRender.ComponentProps<'span'> {
|
|
|
245
225
|
* shows the dot. `appearance="icon"` always shows a marker: the tone icon,
|
|
246
226
|
* or for pending a still dot. A `bare` pending badge shows that dot too.
|
|
247
227
|
*
|
|
248
|
-
* Put the icon here, not in `children`: the chip sizes and colours it
|
|
249
|
-
*
|
|
250
|
-
* chip still shows one icon, in the tone colour unless you give it one,
|
|
251
|
-
* at the size you gave it.
|
|
228
|
+
* Put the icon here, not in `children`: the chip sizes and colours it, and
|
|
229
|
+
* an icon in `children` shows next to the tone icon.
|
|
252
230
|
*/
|
|
253
231
|
icon?: React.ReactNode;
|
|
254
232
|
/**
|
|
@@ -349,12 +327,10 @@ function StatusBadge({
|
|
|
349
327
|
</>
|
|
350
328
|
);
|
|
351
329
|
} else {
|
|
352
|
-
classes =
|
|
330
|
+
classes =
|
|
353
331
|
appearance === 'bare'
|
|
354
332
|
? bareVariants({ tone, size, reveal })
|
|
355
|
-
: statusBadgeVariants({ tone, size, reveal })
|
|
356
|
-
ownIconToneText[tone],
|
|
357
|
-
);
|
|
333
|
+
: statusBadgeVariants({ tone, size, reveal });
|
|
358
334
|
content = (
|
|
359
335
|
<>
|
|
360
336
|
<StatusBadgeMarker
|
|
@@ -12,6 +12,7 @@ import { formatElapsed } from '../../lib/format-elapsed.ts';
|
|
|
12
12
|
import { cn } from '../../lib/utils.ts';
|
|
13
13
|
// Relative: this module is internal (mapped to null in the package exports).
|
|
14
14
|
import { Tooltip, TooltipContent, TooltipTrigger } from '../atoms/tooltip.tsx';
|
|
15
|
+
import { SkeletonLine } from './state-views/skeleton-parts.tsx';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* True inside the second line of a StatusBadge (`detail`). A time there is a
|
|
@@ -137,4 +138,57 @@ function useReadersClock(): boolean {
|
|
|
137
138
|
);
|
|
138
139
|
}
|
|
139
140
|
|
|
140
|
-
|
|
141
|
+
/**
|
|
142
|
+
* A typical text for the skeleton width. Formatting can throw (an invalid
|
|
143
|
+
* locale, a throwing `format`); the skeleton then uses `fallback`.
|
|
144
|
+
*/
|
|
145
|
+
function sampleText(format: () => string, fallback: string): string {
|
|
146
|
+
try {
|
|
147
|
+
return format();
|
|
148
|
+
} catch {
|
|
149
|
+
return fallback;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
interface TimeSkeletonProps extends Omit<React.ComponentProps<'span'>, 'children'> {
|
|
154
|
+
/** A typical rendered text; the skeleton is as many `ch` wide as it is long. */
|
|
155
|
+
sample: string;
|
|
156
|
+
/** Visually hidden text for screen readers. */
|
|
157
|
+
loadingLabel: string;
|
|
158
|
+
/** The `data-slot` of the component it stands in for. */
|
|
159
|
+
slot: string;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* The loading state of DateTime, RelativeTime and ElapsedTime: one text line
|
|
164
|
+
* of skeleton, as wide as a typical value, so the line does not move when the
|
|
165
|
+
* time arrives. It needs no clock, so the
|
|
166
|
+
* server and the browser render the same markup. The width follows the
|
|
167
|
+
* locale: pin it with FormatProvider in SSR, as the text needs anyway.
|
|
168
|
+
*/
|
|
169
|
+
function TimeSkeleton({
|
|
170
|
+
sample,
|
|
171
|
+
loadingLabel,
|
|
172
|
+
slot,
|
|
173
|
+
className,
|
|
174
|
+
style,
|
|
175
|
+
...props
|
|
176
|
+
}: TimeSkeletonProps) {
|
|
177
|
+
return (
|
|
178
|
+
<span
|
|
179
|
+
data-slot={slot}
|
|
180
|
+
aria-busy="true"
|
|
181
|
+
className={cn('inline-flex max-w-full tabular-nums', className)}
|
|
182
|
+
style={{ width: `${Math.max(sample.length, 4)}ch`, ...style }}
|
|
183
|
+
{...props}
|
|
184
|
+
>
|
|
185
|
+
{/* A zero-width space gives the skeleton a text baseline, so it sits on
|
|
186
|
+
the line like the text and a baseline-aligned row does not grow. */}
|
|
187
|
+
<span aria-hidden="true">{'\u200b'}</span>
|
|
188
|
+
<SkeletonLine />
|
|
189
|
+
<span className="sr-only">{loadingLabel}</span>
|
|
190
|
+
</span>
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export { InStatusDetail, sampleText, TimeSkeleton, TimeSpan, TimeTooltip, toTime, useReadersClock };
|
package/src/hooks/use-copy.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { type ClipboardSource, writeToClipboard } from '@vendure-io/ui/lib/clipboard';
|
|
4
3
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { type ClipboardSource, writeToClipboard } from '../lib/clipboard.ts';
|
|
5
5
|
|
|
6
6
|
interface UseCopyOptions {
|
|
7
7
|
/** How long `copied` stays true after a successful copy, in ms. */
|
|
@@ -53,3 +53,5 @@ export function useCopy({ timeout = 2000 }: UseCopyOptions = {}): UseCopyReturn
|
|
|
53
53
|
|
|
54
54
|
return { copied, copy };
|
|
55
55
|
}
|
|
56
|
+
|
|
57
|
+
export type { ClipboardSource };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Deprecated 2.x and early 3.0 names that still work in 3.x. Remove this
|
|
2
|
+
// module and every caller in 4.0.
|
|
3
|
+
import { isDevelopment } from './env.ts';
|
|
4
|
+
|
|
5
|
+
const warned = new Set<string>();
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Warns once per component and old name, in development only:
|
|
9
|
+
* "<Component>: `<old>` is deprecated, use `<new>`. It will be removed in 4.0."
|
|
10
|
+
*/
|
|
11
|
+
export function warnDeprecated(component: string, oldName: string, newName: string): void {
|
|
12
|
+
if (!isDevelopment) return;
|
|
13
|
+
const key = `${component}\u0000${oldName}`;
|
|
14
|
+
if (warned.has(key)) return;
|
|
15
|
+
warned.add(key);
|
|
16
|
+
console.warn(
|
|
17
|
+
`${component}: \`${oldName}\` is deprecated, use \`${newName}\`. It will be removed in 4.0.`,
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Test hook: forget which warnings were shown. */
|
|
22
|
+
export function resetDeprecationWarnings(): void {
|
|
23
|
+
warned.clear();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Moves a value stored under a pre-3.0 key to its new key. When the new key is
|
|
28
|
+
* absent and the old key holds a value, the value is copied to the new key and
|
|
29
|
+
* the old key is deleted. Call it before reading the new key. Storage errors
|
|
30
|
+
* (private mode, a full quota, no window) are ignored.
|
|
31
|
+
*/
|
|
32
|
+
export function migrateStorageKey(
|
|
33
|
+
area: 'localStorage' | 'sessionStorage',
|
|
34
|
+
oldKey: string,
|
|
35
|
+
newKey: string,
|
|
36
|
+
): void {
|
|
37
|
+
try {
|
|
38
|
+
// Reading the storage itself can throw (a sandboxed frame, blocked cookies).
|
|
39
|
+
const storage: Storage | undefined = globalThis[area];
|
|
40
|
+
if (!storage) return;
|
|
41
|
+
if (storage.getItem(newKey) !== null) return;
|
|
42
|
+
const value = storage.getItem(oldKey);
|
|
43
|
+
if (value === null) return;
|
|
44
|
+
storage.setItem(newKey, value);
|
|
45
|
+
storage.removeItem(oldKey);
|
|
46
|
+
} catch {
|
|
47
|
+
// Storage is unavailable; the reader falls back to its default.
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The 2.x physical sides of Sidebar and SheetContent. */
|
|
52
|
+
export type PhysicalSide = 'left' | 'right';
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Turns a physical 2.x side into the logical side that puts the panel on the
|
|
56
|
+
* same edge, and warns. `left` is the start edge left to right and the end
|
|
57
|
+
* edge right to left. The direction comes from the nearest DirectionProvider
|
|
58
|
+
* or `dir` prop, then from `<html dir>`. Other sides pass through.
|
|
59
|
+
*/
|
|
60
|
+
export function logicalSide<S extends string>(
|
|
61
|
+
component: string,
|
|
62
|
+
side: S | PhysicalSide,
|
|
63
|
+
dir: string | undefined,
|
|
64
|
+
): S | 'start' | 'end' {
|
|
65
|
+
if (side !== 'left' && side !== 'right') return side;
|
|
66
|
+
const logical = side === 'left' ? 'start' : 'end';
|
|
67
|
+
warnDeprecated(component, `side="${side}"`, `side="${logical}"`);
|
|
68
|
+
const documentDir = typeof document === 'undefined' ? undefined : document.documentElement.dir;
|
|
69
|
+
const rtl = (dir === 'ltr' || dir === 'rtl' ? dir : documentDir) === 'rtl';
|
|
70
|
+
return (side === 'left') !== rtl ? 'start' : 'end';
|
|
71
|
+
}
|
package/src/lib/field-surface.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The v3 field surface: the `
|
|
3
|
-
* `border` colour, the
|
|
2
|
+
* The v3 field surface: the `field` fill with a 1px inset hairline in the
|
|
3
|
+
* `border` colour (an `inset-ring`), the xl (8px) radius, the same corner as a Button, and a 2px ring drawn inside the field
|
|
4
4
|
* on keyboard focus, over the hairline. An invalid field turns the hairline
|
|
5
|
-
* and the ring destructive. The hairline is a shadow
|
|
6
|
-
* field keeps its size; forced-colors mode, which drops shadows, gets a real
|
|
5
|
+
* and the ring destructive. The hairline is an inset ring, a box-shadow and not a
|
|
6
|
+
* border, so the field keeps its size; forced-colors mode, which drops shadows, gets a real
|
|
7
7
|
* border.
|
|
8
8
|
*
|
|
9
9
|
* Input, Textarea, Select, Combobox, NativeSelect and the date pickers share
|
|
10
10
|
* it. Each field adds its own height, padding and text size.
|
|
11
11
|
*/
|
|
12
12
|
const fieldBase =
|
|
13
|
-
'bg-
|
|
13
|
+
'bg-field inset-ring inset-ring-border rounded-xl outline-none transition-shadow duration-quick ease-soft forced-colors:border';
|
|
14
14
|
|
|
15
|
-
export const fieldSurface = `${fieldBase} focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring aria-invalid:
|
|
15
|
+
export const fieldSurface = `${fieldBase} focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring aria-invalid:inset-ring-destructive aria-invalid:focus-visible:outline-destructive`;
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* The field surface for a field whose focus and invalid state sit on an
|
|
@@ -20,7 +20,7 @@ export const fieldSurface = `${fieldBase} focus-visible:outline-solid focus-visi
|
|
|
20
20
|
* destructive when a control inside is `aria-invalid`. ComboboxChips and the
|
|
21
21
|
* InputOTP group use it.
|
|
22
22
|
*/
|
|
23
|
-
export const fieldSurfaceWithin = `${fieldBase} focus-within:outline-solid focus-within:outline-2 focus-within:-outline-offset-2 focus-within:outline-ring has-aria-invalid:
|
|
23
|
+
export const fieldSurfaceWithin = `${fieldBase} focus-within:outline-solid focus-within:outline-2 focus-within:-outline-offset-2 focus-within:outline-ring has-aria-invalid:inset-ring-destructive has-aria-invalid:focus-within:outline-destructive`;
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* A ghost Button drawn as a field: the trigger of DatePicker, DateRangePicker
|