@vendure-io/ui 2.0.0-beta.9 → 2.0.0-rc.1
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/LICENSE.md +34 -0
- package/package.json +9 -7
- package/src/components/atoms/alert-dialog.tsx +1 -1
- package/src/components/atoms/alert.tsx +1 -1
- package/src/components/atoms/badge.tsx +1 -1
- package/src/components/atoms/button.tsx +2 -2
- package/src/components/atoms/card.tsx +39 -4
- package/src/components/atoms/checkbox.tsx +1 -1
- package/src/components/atoms/combobox.tsx +24 -5
- package/src/components/atoms/command.tsx +16 -5
- package/src/components/atoms/context-menu.tsx +1 -1
- package/src/components/atoms/dialog.tsx +1 -1
- package/src/components/atoms/drawer.tsx +134 -35
- package/src/components/atoms/dropdown-menu.tsx +1 -1
- package/src/components/atoms/field.tsx +2 -2
- package/src/components/atoms/input.tsx +1 -1
- package/src/components/atoms/item.tsx +4 -1
- package/src/components/atoms/menubar.tsx +1 -1
- package/src/components/atoms/native-select.tsx +1 -1
- package/src/components/atoms/navigation-menu.tsx +5 -2
- package/src/components/atoms/progress.tsx +1 -1
- package/src/components/atoms/radio-group.tsx +1 -1
- package/src/components/atoms/scroll-area.tsx +1 -2
- package/src/components/atoms/select.tsx +1 -1
- package/src/components/atoms/sheet.tsx +1 -1
- package/src/components/atoms/sidebar.tsx +6 -4
- package/src/components/atoms/slider.tsx +2 -2
- package/src/components/atoms/switch.tsx +1 -1
- package/src/components/atoms/table.tsx +34 -2
- package/src/components/atoms/tabs.tsx +64 -1
- package/src/components/atoms/textarea.tsx +1 -1
- package/src/components/atoms/toggle-group.tsx +1 -1
- package/src/components/atoms/toggle.tsx +5 -2
- package/src/components/molecules/chip.tsx +7 -2
- package/src/components/molecules/code-block/file-type-icons.tsx +123 -0
- package/src/components/molecules/code-block/process-code.ts +60 -0
- package/src/components/molecules/code-block/transform-command.tsx +177 -0
- package/src/components/molecules/code-block.tsx +25 -443
- package/src/components/molecules/combobox-free-text.tsx +23 -2
- package/src/components/molecules/copyable-text.tsx +14 -1
- package/src/components/molecules/data-table/data-table-bulk-actions.tsx +12 -13
- package/src/components/molecules/data-table/data-table-types.tsx +50 -2
- package/src/components/molecules/data-table/data-table-view-options.tsx +2 -1
- package/src/components/molecules/data-table/data-table.tsx +188 -96
- package/src/components/molecules/date-picker.tsx +3 -1
- package/src/components/molecules/date-range-picker.tsx +3 -1
- package/src/components/molecules/date-time-picker.tsx +3 -1
- package/src/components/molecules/file-dropzone.tsx +15 -5
- package/src/components/molecules/illustrations/empty-database.tsx +8 -5
- package/src/components/molecules/illustrations/error.tsx +19 -17
- package/src/components/molecules/illustrations/expired.tsx +55 -0
- package/src/components/molecules/illustrations/first-run.tsx +3 -1
- package/src/components/molecules/illustrations/no-activity.tsx +35 -14
- package/src/components/molecules/illustrations/no-customers.tsx +66 -0
- package/src/components/molecules/illustrations/no-documents.tsx +4 -3
- package/src/components/molecules/illustrations/no-invoices.tsx +45 -0
- package/src/components/molecules/illustrations/no-notifications.tsx +7 -8
- package/src/components/molecules/illustrations/no-orders.tsx +25 -17
- package/src/components/molecules/illustrations/no-plugins.tsx +21 -31
- package/src/components/molecules/illustrations/no-products.tsx +53 -0
- package/src/components/molecules/illustrations/no-projects.tsx +54 -0
- package/src/components/molecules/illustrations/no-promotions.tsx +49 -0
- package/src/components/molecules/illustrations/no-subscription.tsx +72 -0
- package/src/components/molecules/illustrations/not-found.tsx +17 -15
- package/src/components/molecules/illustrations/offline.tsx +12 -10
- package/src/components/molecules/illustrations/payment-failed.tsx +53 -0
- package/src/components/molecules/illustrations/success.tsx +43 -0
- package/src/components/molecules/inline-code.tsx +26 -0
- package/src/components/molecules/page-header.tsx +7 -3
- package/src/components/molecules/stat-card.tsx +13 -12
- package/src/components/molecules/state-views/empty-state.tsx +12 -1
- package/src/components/molecules/state-views/loading-state.tsx +7 -3
- package/src/lib/highlight.ts +37 -1
- package/src/lib/state-dictionary.ts +18 -5
- package/src/lib/utils.ts +0 -19
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { IllustrationProps } from '@vendure-io/ui/components/molecules/illustrations/illustration-types';
|
|
2
|
+
import { cn } from '@vendure-io/ui/lib/utils';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A coupon with notched sides and a percent sign, its tear-off stub marked
|
|
6
|
+
* with a star. For a promotions, discounts, or coupon codes list with nothing
|
|
7
|
+
* set up yet. Not for an empty product catalog (use `NoProductsIllustration`)
|
|
8
|
+
* or a search that matched no promotions (use `NoResultsIllustration`).
|
|
9
|
+
*/
|
|
10
|
+
function NoPromotionsIllustration({ className, size = 160 }: IllustrationProps) {
|
|
11
|
+
return (
|
|
12
|
+
<svg
|
|
13
|
+
viewBox="0 0 160 120"
|
|
14
|
+
width={size}
|
|
15
|
+
height={(size * 120) / 160}
|
|
16
|
+
fill="none"
|
|
17
|
+
strokeWidth={1.5}
|
|
18
|
+
strokeLinecap="round"
|
|
19
|
+
strokeLinejoin="round"
|
|
20
|
+
aria-hidden="true"
|
|
21
|
+
focusable="false"
|
|
22
|
+
className={cn('shrink-0', className)}
|
|
23
|
+
>
|
|
24
|
+
<ellipse cx="80" cy="104" rx="32" ry="5" className="fill-muted" />
|
|
25
|
+
|
|
26
|
+
{/* coupon */}
|
|
27
|
+
<path
|
|
28
|
+
d="M40,38 L120,38 Q124,38 124,42 L124,54 A6,6 0 0,0 124,66 L124,78 Q124,82 120,82 L40,82 Q36,82 36,78 L36,66 A6,6 0 0,0 36,54 L36,42 Q36,38 40,38 Z"
|
|
29
|
+
className="fill-surface stroke-muted-foreground"
|
|
30
|
+
/>
|
|
31
|
+
|
|
32
|
+
{/* perforation */}
|
|
33
|
+
<line x1="96" y1="42" x2="96" y2="78" className="stroke-border" strokeDasharray="2 4" />
|
|
34
|
+
|
|
35
|
+
{/* percent sign */}
|
|
36
|
+
<circle cx="56" cy="52" r="4" className="stroke-muted-foreground" />
|
|
37
|
+
<circle cx="76" cy="68" r="4" className="stroke-muted-foreground" />
|
|
38
|
+
<line x1="76" y1="48" x2="56" y2="72" className="stroke-muted-foreground" />
|
|
39
|
+
|
|
40
|
+
{/* star on the stub — the one brand accent */}
|
|
41
|
+
<polygon
|
|
42
|
+
points="110,53 111.7,57.65 116.66,57.84 112.76,60.9 114.11,65.66 110,62.9 105.89,65.66 107.24,60.9 103.34,57.84 108.3,57.65"
|
|
43
|
+
className="fill-brand"
|
|
44
|
+
/>
|
|
45
|
+
</svg>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { NoPromotionsIllustration };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { IllustrationProps } from '@vendure-io/ui/components/molecules/illustrations/illustration-types';
|
|
2
|
+
import { cn } from '@vendure-io/ui/lib/utils';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A pricing card in front of two dashed plan cards, with a plan name pill and
|
|
6
|
+
* feature rows that are still empty. For a project or account with no
|
|
7
|
+
* plan or subscription yet, next to a "Choose a plan" or "Start a trial"
|
|
8
|
+
* action. Not for a trial that ran out (use `ExpiredIllustration`) or a plan
|
|
9
|
+
* whose payment failed (use `PaymentFailedIllustration`).
|
|
10
|
+
*/
|
|
11
|
+
function NoSubscriptionIllustration({ className, size = 160 }: IllustrationProps) {
|
|
12
|
+
return (
|
|
13
|
+
<svg
|
|
14
|
+
viewBox="0 0 160 120"
|
|
15
|
+
width={size}
|
|
16
|
+
height={(size * 120) / 160}
|
|
17
|
+
fill="none"
|
|
18
|
+
strokeWidth={1.5}
|
|
19
|
+
strokeLinecap="round"
|
|
20
|
+
strokeLinejoin="round"
|
|
21
|
+
aria-hidden="true"
|
|
22
|
+
focusable="false"
|
|
23
|
+
className={cn('shrink-0', className)}
|
|
24
|
+
>
|
|
25
|
+
<ellipse cx="80" cy="104" rx="34" ry="5" className="fill-muted" />
|
|
26
|
+
|
|
27
|
+
{/* other plans, not chosen */}
|
|
28
|
+
<rect
|
|
29
|
+
x="30"
|
|
30
|
+
y="34"
|
|
31
|
+
width="34"
|
|
32
|
+
height="50"
|
|
33
|
+
rx="3"
|
|
34
|
+
className="stroke-border"
|
|
35
|
+
strokeDasharray="3 4"
|
|
36
|
+
/>
|
|
37
|
+
<rect
|
|
38
|
+
x="96"
|
|
39
|
+
y="34"
|
|
40
|
+
width="34"
|
|
41
|
+
height="50"
|
|
42
|
+
rx="3"
|
|
43
|
+
className="stroke-border"
|
|
44
|
+
strokeDasharray="3 4"
|
|
45
|
+
/>
|
|
46
|
+
|
|
47
|
+
{/* plan card */}
|
|
48
|
+
<rect
|
|
49
|
+
x="56"
|
|
50
|
+
y="22"
|
|
51
|
+
width="48"
|
|
52
|
+
height="72"
|
|
53
|
+
rx="4"
|
|
54
|
+
className="fill-surface stroke-muted-foreground"
|
|
55
|
+
/>
|
|
56
|
+
<line x1="64" y1="44" x2="90" y2="44" className="stroke-muted-foreground" />
|
|
57
|
+
|
|
58
|
+
{/* feature rows, nothing included yet */}
|
|
59
|
+
<circle cx="67" cy="58" r="2.5" className="stroke-border" />
|
|
60
|
+
<line x1="73" y1="58" x2="96" y2="58" className="stroke-border" strokeDasharray="3 4" />
|
|
61
|
+
<circle cx="67" cy="68" r="2.5" className="stroke-border" />
|
|
62
|
+
<line x1="73" y1="68" x2="92" y2="68" className="stroke-border" strokeDasharray="3 4" />
|
|
63
|
+
<circle cx="67" cy="78" r="2.5" className="stroke-border" />
|
|
64
|
+
<line x1="73" y1="78" x2="96" y2="78" className="stroke-border" strokeDasharray="3 4" />
|
|
65
|
+
|
|
66
|
+
{/* plan name pill — the one brand accent */}
|
|
67
|
+
<rect x="64" y="30" width="20" height="7" rx="3.5" className="fill-brand" />
|
|
68
|
+
</svg>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export { NoSubscriptionIllustration };
|
|
@@ -4,7 +4,9 @@ import { cn } from '@vendure-io/ui/lib/utils';
|
|
|
4
4
|
/**
|
|
5
5
|
* A compass whose needle points off a dashed trail that dead-ends in an "x".
|
|
6
6
|
* For 404s and missing-resource errors — pass as `illustration` to
|
|
7
|
-
* `ErrorState` alongside a "Go back" action.
|
|
7
|
+
* `ErrorState` alongside a "Go back" action. Not for a search that matched
|
|
8
|
+
* nothing (use `NoResultsIllustration`) or a resource the user may not see
|
|
9
|
+
* (use `AccessDeniedIllustration`).
|
|
8
10
|
*/
|
|
9
11
|
function NotFoundIllustration({ className, size = 160 }: IllustrationProps) {
|
|
10
12
|
return (
|
|
@@ -23,24 +25,24 @@ function NotFoundIllustration({ className, size = 160 }: IllustrationProps) {
|
|
|
23
25
|
<ellipse cx="80" cy="104" rx="30" ry="5" className="fill-muted" />
|
|
24
26
|
|
|
25
27
|
{/* map, folded corner */}
|
|
26
|
-
<rect x="
|
|
27
|
-
<polygon points="
|
|
28
|
+
<rect x="34" y="30" width="60" height="44" rx="2" className="fill-surface stroke-border" />
|
|
29
|
+
<polygon points="94,30 94,42 82,30" className="fill-muted stroke-border" />
|
|
28
30
|
|
|
29
|
-
{/* trail off the
|
|
30
|
-
<path d="
|
|
31
|
-
<line x1="
|
|
32
|
-
<line x1="
|
|
31
|
+
{/* trail off the map, lost */}
|
|
32
|
+
<path d="M86,68 Q104,84 120,70" className="stroke-border" strokeDasharray="3 4" />
|
|
33
|
+
<line x1="120" y1="62" x2="128" y2="70" className="stroke-muted-foreground" />
|
|
34
|
+
<line x1="128" y1="62" x2="120" y2="70" className="stroke-muted-foreground" />
|
|
33
35
|
|
|
34
36
|
{/* compass */}
|
|
35
|
-
<circle cx="
|
|
36
|
-
<line x1="
|
|
37
|
-
<line x1="
|
|
38
|
-
<line x1="
|
|
39
|
-
<line x1="
|
|
40
|
-
<polygon points="
|
|
37
|
+
<circle cx="68" cy="58" r="20" className="fill-surface stroke-muted-foreground" />
|
|
38
|
+
<line x1="68" y1="40" x2="68" y2="44" className="stroke-border" />
|
|
39
|
+
<line x1="68" y1="72" x2="68" y2="76" className="stroke-border" />
|
|
40
|
+
<line x1="50" y1="58" x2="54" y2="58" className="stroke-border" />
|
|
41
|
+
<line x1="82" y1="58" x2="86" y2="58" className="stroke-border" />
|
|
42
|
+
<polygon points="68,58 74,44 68,50" className="fill-muted-foreground" />
|
|
41
43
|
{/* needle tip — the one brand accent */}
|
|
42
|
-
<polygon points="
|
|
43
|
-
<circle cx="
|
|
44
|
+
<polygon points="68,58 62,72 68,66" className="fill-brand" />
|
|
45
|
+
<circle cx="68" cy="58" r="2" className="fill-surface stroke-muted-foreground" />
|
|
44
46
|
</svg>
|
|
45
47
|
);
|
|
46
48
|
}
|
|
@@ -2,8 +2,10 @@ import type { IllustrationProps } from '@vendure-io/ui/components/molecules/illu
|
|
|
2
2
|
import { cn } from '@vendure-io/ui/lib/utils';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* A cloud cut by a diagonal slash,
|
|
6
|
-
* network/connectivity failures — pass as `illustration` to `ErrorState
|
|
5
|
+
* A cloud cut by a diagonal slash, under a signal glyph whose arcs fade out.
|
|
6
|
+
* For network/connectivity failures — pass as `illustration` to `ErrorState`
|
|
7
|
+
* with a "Try again" action. Not for a server-side failure while the network
|
|
8
|
+
* is fine (use `ErrorIllustration`).
|
|
7
9
|
*/
|
|
8
10
|
function OfflineIllustration({ className, size = 160 }: IllustrationProps) {
|
|
9
11
|
return (
|
|
@@ -21,21 +23,21 @@ function OfflineIllustration({ className, size = 160 }: IllustrationProps) {
|
|
|
21
23
|
>
|
|
22
24
|
<ellipse cx="80" cy="104" rx="28" ry="5" className="fill-muted" />
|
|
23
25
|
|
|
24
|
-
{/* fading signal, cut off */}
|
|
25
|
-
<path d="
|
|
26
|
-
<path d="M65,
|
|
26
|
+
{/* fading signal arcs, cut off */}
|
|
27
|
+
<path d="M72,26 a12,12 0 0,1 16,0" className="stroke-border" strokeDasharray="2 4" />
|
|
28
|
+
<path d="M65,19 a22,22 0 0,1 30,0" className="stroke-border" strokeDasharray="2 5" />
|
|
29
|
+
|
|
30
|
+
{/* signal source — the one brand accent */}
|
|
31
|
+
<circle cx="80" cy="33" r="3" className="fill-brand" />
|
|
27
32
|
|
|
28
33
|
{/* cloud */}
|
|
29
34
|
<path
|
|
30
|
-
d="
|
|
35
|
+
d="M58,82 C52,82 48,77 48,71 C48,65 53,60 59,60 C60,52 67,46 76,46 C84,46 91,51 93,58 C94,58 95,57 97,57 C105,57 112,64 112,72 C112,80 105,87 97,87 L64,87 C60,87 58,85 58,82 Z"
|
|
31
36
|
className="fill-surface stroke-muted-foreground"
|
|
32
37
|
/>
|
|
33
38
|
|
|
34
39
|
{/* slash */}
|
|
35
|
-
<line x1="
|
|
36
|
-
|
|
37
|
-
{/* reconnect dot — the one brand accent */}
|
|
38
|
-
<circle cx="104" cy="74" r="4" className="fill-brand" />
|
|
40
|
+
<line x1="46" y1="48" x2="114" y2="92" className="stroke-muted-foreground" />
|
|
39
41
|
</svg>
|
|
40
42
|
);
|
|
41
43
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { IllustrationProps } from '@vendure-io/ui/components/molecules/illustrations/illustration-types';
|
|
2
|
+
import { cn } from '@vendure-io/ui/lib/utils';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A payment card with a declined badge on its corner and an unfilled number
|
|
6
|
+
* line. For a payment that did not go through: a failed charge, a past-due
|
|
7
|
+
* invoice, or a checkout that was canceled before payment. Pair it with a
|
|
8
|
+
* "Pay now" or "Update payment method" action. Not for a project with no plan
|
|
9
|
+
* at all (use `NoSubscriptionIllustration`) or a generic failure (use
|
|
10
|
+
* `ErrorIllustration`).
|
|
11
|
+
*/
|
|
12
|
+
function PaymentFailedIllustration({ className, size = 160 }: IllustrationProps) {
|
|
13
|
+
return (
|
|
14
|
+
<svg
|
|
15
|
+
viewBox="0 0 160 120"
|
|
16
|
+
width={size}
|
|
17
|
+
height={(size * 120) / 160}
|
|
18
|
+
fill="none"
|
|
19
|
+
strokeWidth={1.5}
|
|
20
|
+
strokeLinecap="round"
|
|
21
|
+
strokeLinejoin="round"
|
|
22
|
+
aria-hidden="true"
|
|
23
|
+
focusable="false"
|
|
24
|
+
className={cn('shrink-0', className)}
|
|
25
|
+
>
|
|
26
|
+
<ellipse cx="78" cy="104" rx="32" ry="5" className="fill-muted" />
|
|
27
|
+
|
|
28
|
+
{/* card */}
|
|
29
|
+
<rect
|
|
30
|
+
x="38"
|
|
31
|
+
y="36"
|
|
32
|
+
width="74"
|
|
33
|
+
height="48"
|
|
34
|
+
rx="5"
|
|
35
|
+
className="fill-surface stroke-muted-foreground"
|
|
36
|
+
/>
|
|
37
|
+
|
|
38
|
+
{/* card number, not filled in */}
|
|
39
|
+
<line x1="48" y1="70" x2="88" y2="70" className="stroke-border" strokeDasharray="3 4" />
|
|
40
|
+
<line x1="48" y1="76" x2="64" y2="76" className="stroke-border" />
|
|
41
|
+
|
|
42
|
+
{/* chip — the one brand accent */}
|
|
43
|
+
<rect x="48" y="50" width="14" height="10" rx="2" className="fill-brand" />
|
|
44
|
+
|
|
45
|
+
{/* declined badge */}
|
|
46
|
+
<circle cx="112" cy="38" r="10" className="fill-surface stroke-muted-foreground" />
|
|
47
|
+
<line x1="108" y1="34" x2="116" y2="42" className="stroke-muted-foreground" />
|
|
48
|
+
<line x1="116" y1="34" x2="108" y2="42" className="stroke-muted-foreground" />
|
|
49
|
+
</svg>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { PaymentFailedIllustration };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { IllustrationProps } from '@vendure-io/ui/components/molecules/illustrations/illustration-types';
|
|
2
|
+
import { cn } from '@vendure-io/ui/lib/utils';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A round seal with a solid check and short rays around it. For a finished
|
|
6
|
+
* task or a queue with nothing left to do: a sign-in handed back to the
|
|
7
|
+
* terminal, a plan that is now active, a review queue that is empty. Not for
|
|
8
|
+
* a notifications panel with nothing new (use `NoNotificationsIllustration`)
|
|
9
|
+
* or a first-run prompt (use `FirstRunIllustration`).
|
|
10
|
+
*/
|
|
11
|
+
function SuccessIllustration({ className, size = 160 }: IllustrationProps) {
|
|
12
|
+
return (
|
|
13
|
+
<svg
|
|
14
|
+
viewBox="0 0 160 120"
|
|
15
|
+
width={size}
|
|
16
|
+
height={(size * 120) / 160}
|
|
17
|
+
fill="none"
|
|
18
|
+
strokeWidth={1.5}
|
|
19
|
+
strokeLinecap="round"
|
|
20
|
+
strokeLinejoin="round"
|
|
21
|
+
aria-hidden="true"
|
|
22
|
+
focusable="false"
|
|
23
|
+
className={cn('shrink-0', className)}
|
|
24
|
+
>
|
|
25
|
+
<ellipse cx="80" cy="104" rx="28" ry="5" className="fill-muted" />
|
|
26
|
+
|
|
27
|
+
{/* rays */}
|
|
28
|
+
<line x1="80" y1="27" x2="80" y2="21" className="stroke-border" />
|
|
29
|
+
<line x1="101.9" y1="36.1" x2="106.2" y2="31.8" className="stroke-border" />
|
|
30
|
+
<line x1="58.1" y1="36.1" x2="53.8" y2="31.8" className="stroke-border" />
|
|
31
|
+
<line x1="111" y1="58" x2="117" y2="58" className="stroke-border" />
|
|
32
|
+
<line x1="49" y1="58" x2="43" y2="58" className="stroke-border" />
|
|
33
|
+
|
|
34
|
+
{/* seal */}
|
|
35
|
+
<circle cx="80" cy="58" r="26" className="fill-surface stroke-muted-foreground" />
|
|
36
|
+
|
|
37
|
+
{/* check — the one brand accent */}
|
|
38
|
+
<polygon points="65,57.5 69.5,53 77,60.5 91,46.5 95.5,51 77,69.5" className="fill-brand" />
|
|
39
|
+
</svg>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { SuccessIllustration };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { cn } from '@vendure-io/ui/lib/utils';
|
|
2
|
+
import type * as React from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Code in running text: a prop, a flag, a package name, a file path. The
|
|
6
|
+
* `code-inline` fill tints the host surface, so the code stays a step apart
|
|
7
|
+
* from the page, a card, or an inset well. The text is `text-foreground`, so it
|
|
8
|
+
* keeps full contrast inside a `text-muted-foreground` paragraph.
|
|
9
|
+
*
|
|
10
|
+
* Multi-line code uses `CodeBlock`. A value the user copies elsewhere uses
|
|
11
|
+
* `CopyableText` or `IdChip`. A keystroke uses `Kbd`.
|
|
12
|
+
*/
|
|
13
|
+
function InlineCode({ className, ...props }: React.ComponentProps<'code'>) {
|
|
14
|
+
return (
|
|
15
|
+
<code
|
|
16
|
+
data-slot="inline-code"
|
|
17
|
+
className={cn(
|
|
18
|
+
'bg-code-inline border-code-inline-border text-foreground rounded border px-1 py-px font-mono',
|
|
19
|
+
className,
|
|
20
|
+
)}
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { InlineCode };
|
|
@@ -6,12 +6,16 @@ import type * as React from 'react';
|
|
|
6
6
|
// header and lets variance in the wild (back links, badge rows beside the title,
|
|
7
7
|
// mono subtitles) live as free children rather than as an ever-growing prop set.
|
|
8
8
|
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* The header row: title/description on the left, actions on the right. The row
|
|
11
|
+
* wraps, so on a narrow screen the actions move below the title instead of
|
|
12
|
+
* squeezing it.
|
|
13
|
+
*/
|
|
10
14
|
function PageHeader({ className, ...props }: React.ComponentProps<'header'>) {
|
|
11
15
|
return (
|
|
12
16
|
<header
|
|
13
17
|
data-slot="page-header"
|
|
14
|
-
className={cn('flex items-start justify-between gap-4', className)}
|
|
18
|
+
className={cn('flex flex-wrap items-start justify-between gap-4', className)}
|
|
15
19
|
{...props}
|
|
16
20
|
/>
|
|
17
21
|
);
|
|
@@ -48,7 +52,7 @@ function PageHeaderDescription({ className, ...props }: React.ComponentProps<'p'
|
|
|
48
52
|
);
|
|
49
53
|
}
|
|
50
54
|
|
|
51
|
-
/** Right-hand action slot (buttons, menus).
|
|
55
|
+
/** Right-hand action slot (buttons, menus). Moves below the title when the row has no room. */
|
|
52
56
|
function PageHeaderActions({ className, ...props }: React.ComponentProps<'div'>) {
|
|
53
57
|
return (
|
|
54
58
|
<div
|
|
@@ -4,25 +4,26 @@ import { cva } from 'class-variance-authority';
|
|
|
4
4
|
import { ArrowDown, ArrowUp } from 'lucide-react';
|
|
5
5
|
import type { ComponentProps, ReactNode } from 'react';
|
|
6
6
|
|
|
7
|
-
// Delta
|
|
8
|
-
// good for this metric (revenue up vs. refund-rate down), and the token
|
|
9
|
-
// derived from that
|
|
10
|
-
//
|
|
7
|
+
// Delta color follows the outcome, not the direction: `goodWhen` says which
|
|
8
|
+
// way is good for this metric (revenue up vs. refund-rate down), and the token
|
|
9
|
+
// is derived from that, never a hardcoded green/red: good → success,
|
|
10
|
+
// bad → destructive, flat → muted. The subtle foregrounds are the text-safe
|
|
11
|
+
// tone steps: the solid tones fall below 4.5:1 in dark mode.
|
|
11
12
|
const statCardDeltaVariants = cva('inline-flex items-center gap-0.5 text-xs font-medium', {
|
|
12
13
|
variants: {
|
|
13
|
-
|
|
14
|
-
good: 'text-success',
|
|
15
|
-
bad: 'text-destructive',
|
|
14
|
+
outcome: {
|
|
15
|
+
good: 'text-success-subtle-foreground',
|
|
16
|
+
bad: 'text-destructive-subtle-foreground',
|
|
16
17
|
flat: 'text-muted-foreground',
|
|
17
18
|
},
|
|
18
19
|
},
|
|
19
20
|
defaultVariants: {
|
|
20
|
-
|
|
21
|
+
outcome: 'flat',
|
|
21
22
|
},
|
|
22
23
|
});
|
|
23
24
|
|
|
24
25
|
interface StatCardDelta {
|
|
25
|
-
/** Raw percentage change, e.g. `-3.2`. Sign drives the arrow and
|
|
26
|
+
/** Raw percentage change, e.g. `-3.2`. Sign drives the arrow and color. */
|
|
26
27
|
value: number;
|
|
27
28
|
/** Suffix after the number. Default `'%'`. */
|
|
28
29
|
label?: string;
|
|
@@ -47,10 +48,10 @@ interface StatCardProps extends ComponentProps<typeof Card> {
|
|
|
47
48
|
|
|
48
49
|
function StatCardDeltaBadge({ value, label = '%', goodWhen = 'up' }: StatCardDelta) {
|
|
49
50
|
const direction = value > 0 ? 'up' : value < 0 ? 'down' : 'flat';
|
|
50
|
-
const
|
|
51
|
+
const outcome = direction === 'flat' ? 'flat' : direction === goodWhen ? 'good' : 'bad';
|
|
51
52
|
|
|
52
53
|
return (
|
|
53
|
-
<span data-slot="stat-card-delta" className={statCardDeltaVariants({
|
|
54
|
+
<span data-slot="stat-card-delta" className={statCardDeltaVariants({ outcome })}>
|
|
54
55
|
{direction === 'up' ? (
|
|
55
56
|
<ArrowUp aria-hidden="true" className="size-3" />
|
|
56
57
|
) : direction === 'down' ? (
|
|
@@ -131,4 +132,4 @@ function StatCard({
|
|
|
131
132
|
);
|
|
132
133
|
}
|
|
133
134
|
|
|
134
|
-
export { StatCard,
|
|
135
|
+
export { StatCard, type StatCardProps, type StatCardDelta };
|
|
@@ -25,6 +25,12 @@ export interface EmptyStateProps extends Omit<React.ComponentProps<typeof Empty>
|
|
|
25
25
|
description?: React.ReactNode;
|
|
26
26
|
/** Actions/CTA — rendered in the content slot below the header. */
|
|
27
27
|
children?: React.ReactNode;
|
|
28
|
+
/**
|
|
29
|
+
* Draw the dashed box. Defaults to `true`. Set `false` when the empty state
|
|
30
|
+
* fills a region that already has a frame, such as a table body: the table
|
|
31
|
+
* owns its perimeter.
|
|
32
|
+
*/
|
|
33
|
+
bordered?: boolean;
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
/**
|
|
@@ -42,6 +48,7 @@ function EmptyState({
|
|
|
42
48
|
title,
|
|
43
49
|
description,
|
|
44
50
|
children,
|
|
51
|
+
bordered = true,
|
|
45
52
|
className,
|
|
46
53
|
...props
|
|
47
54
|
}: EmptyStateProps) {
|
|
@@ -57,7 +64,11 @@ function EmptyState({
|
|
|
57
64
|
) : null;
|
|
58
65
|
|
|
59
66
|
return (
|
|
60
|
-
<Empty
|
|
67
|
+
<Empty
|
|
68
|
+
data-slot="empty-state"
|
|
69
|
+
className={cn(bordered ? 'border' : 'rounded-none', className)}
|
|
70
|
+
{...props}
|
|
71
|
+
>
|
|
61
72
|
<EmptyHeader>
|
|
62
73
|
{resolvedIllustration ? (
|
|
63
74
|
<EmptyMedia>{resolvedIllustration}</EmptyMedia>
|
|
@@ -24,13 +24,16 @@ export interface LoadingStateProps
|
|
|
24
24
|
rows?: number;
|
|
25
25
|
/** Classes applied to each skeleton row (e.g. `h-10` for tighter lists). */
|
|
26
26
|
rowClassName?: string;
|
|
27
|
-
/** Visible label. An sr-only
|
|
27
|
+
/** Visible label. An sr-only `srLabel` is always rendered for assistive tech. */
|
|
28
28
|
label?: React.ReactNode;
|
|
29
|
+
/** Sr-only label announced to assistive tech. Override for host i18n. @default "Loading…" */
|
|
30
|
+
srLabel?: string;
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
/**
|
|
32
34
|
* Placeholder shell for in-flight list/detail queries. Renders as an
|
|
33
|
-
* `aria-live` `<output>` with an always-present sr-only
|
|
35
|
+
* `aria-live` `<output>` with an always-present sr-only `srLabel` (defaults to
|
|
36
|
+
* "Loading…", overridable for host i18n).
|
|
34
37
|
* `skeleton` (default) draws N shimmer rows; `spinner` centers the `Spinner`
|
|
35
38
|
* atom for compact or unknown-height regions.
|
|
36
39
|
*/
|
|
@@ -39,6 +42,7 @@ function LoadingState({
|
|
|
39
42
|
rows = 5,
|
|
40
43
|
rowClassName,
|
|
41
44
|
label,
|
|
45
|
+
srLabel = 'Loading…',
|
|
42
46
|
className,
|
|
43
47
|
...props
|
|
44
48
|
}: LoadingStateProps) {
|
|
@@ -49,7 +53,7 @@ function LoadingState({
|
|
|
49
53
|
className={cn(loadingStateVariants({ variant }), className)}
|
|
50
54
|
{...props}
|
|
51
55
|
>
|
|
52
|
-
<span className="sr-only">
|
|
56
|
+
<span className="sr-only">{srLabel}</span>
|
|
53
57
|
{variant === 'spinner' ? (
|
|
54
58
|
<>
|
|
55
59
|
{/* aria-hidden overrides the atom's role="status": the <output> is
|
package/src/lib/highlight.ts
CHANGED
|
@@ -85,6 +85,9 @@ async function highlightCode(code: string, language: SupportedLanguage): Promise
|
|
|
85
85
|
light: 'github-light',
|
|
86
86
|
dark: 'github-dark-default',
|
|
87
87
|
},
|
|
88
|
+
// github-light's orange (#e36209, used for GraphQL fields, CSS properties
|
|
89
|
+
// and similar) is 3.5:1 on a white card. #a35200 is 5.6:1 and keeps the hue.
|
|
90
|
+
colorReplacements: { 'github-light': { '#e36209': '#a35200' } },
|
|
88
91
|
transformers: [
|
|
89
92
|
transformerNotationDiff({ matchAlgorithm: 'v3' }),
|
|
90
93
|
transformerNotationHighlight({ matchAlgorithm: 'v3' }),
|
|
@@ -137,5 +140,38 @@ function normalizeLanguage(lang?: string): SupportedLanguage {
|
|
|
137
140
|
return 'ini';
|
|
138
141
|
}
|
|
139
142
|
|
|
140
|
-
|
|
143
|
+
/**
|
|
144
|
+
* Bundled grammars whose `//` / `#` comment syntax lets the `[!code ...]`
|
|
145
|
+
* notation transformers match. Only languages with a loader above can qualify:
|
|
146
|
+
* anything else falls back to the `ini` grammar, which renders the notation
|
|
147
|
+
* comment as literal text instead of consuming it.
|
|
148
|
+
*/
|
|
149
|
+
const NOTATION_TRANSFORMER_LANGUAGES = new Set<SupportedLanguage>([
|
|
150
|
+
'javascript',
|
|
151
|
+
'typescript',
|
|
152
|
+
'jsx',
|
|
153
|
+
'tsx',
|
|
154
|
+
'python',
|
|
155
|
+
'bash',
|
|
156
|
+
'shellscript',
|
|
157
|
+
'yaml',
|
|
158
|
+
]);
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Whether `[!code ...]` notations in `lang` survive highlighting. Alias-aware:
|
|
162
|
+
* the check runs on the normalized language, so `ts`, `py`, `sh`, … qualify
|
|
163
|
+
* through their canonical grammar. Callers should strip notations when this
|
|
164
|
+
* returns false, or they render as literal text.
|
|
165
|
+
*/
|
|
166
|
+
function supportsNotationComments(lang?: string): boolean {
|
|
167
|
+
return NOTATION_TRANSFORMER_LANGUAGES.has(normalizeLanguage(lang));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export {
|
|
171
|
+
NOTATION_TRANSFORMER_LANGUAGES,
|
|
172
|
+
getHighlighter,
|
|
173
|
+
highlightCode,
|
|
174
|
+
normalizeLanguage,
|
|
175
|
+
supportsNotationComments,
|
|
176
|
+
};
|
|
141
177
|
export type { SupportedLanguage };
|
|
@@ -77,20 +77,33 @@ export function defineStateEntries<S extends string>(entries: Record<S, StateEnt
|
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
79
|
* The universal map — the only state strings this package ships. Every entry
|
|
80
|
-
* has one
|
|
80
|
+
* has one tone regardless of domain. The rules behind the tones:
|
|
81
81
|
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
82
|
+
* - A state an actor ended on purpose is `neutral`, not `critical`:
|
|
83
|
+
* `cancelled`, `expired` and `revoked` are outcomes, not failures.
|
|
84
|
+
* `critical` is for failures and refusals (`failed`, `error`, `rejected`).
|
|
85
|
+
* - A dormant state is `neutral` (`disabled`, `inactive`); its live
|
|
86
|
+
* counterpart is `success` (`enabled`, `active`).
|
|
87
|
+
* - `pending` is `progress`: it waits on a step that the system or another
|
|
88
|
+
* party completes, and it will change without the viewer acting. A domain
|
|
89
|
+
* where pending means "waiting for this user" declares its own `warning`
|
|
90
|
+
* entry in its own map.
|
|
91
|
+
*
|
|
92
|
+
* `running` is deliberately absent: it has no single tone (a running job is
|
|
93
|
+
* `progress`, a running service is `success`), so every domain must decide it
|
|
94
|
+
* explicitly in its own map.
|
|
86
95
|
*/
|
|
87
96
|
export const commonStates = defineStateEntries({
|
|
88
97
|
enabled: { tone: 'success', defaultLabel: 'Enabled' },
|
|
89
98
|
disabled: { tone: 'neutral', defaultLabel: 'Disabled' },
|
|
99
|
+
active: { tone: 'success', defaultLabel: 'Active' },
|
|
100
|
+
inactive: { tone: 'neutral', defaultLabel: 'Inactive' },
|
|
101
|
+
pending: { tone: 'progress', defaultLabel: 'Pending' },
|
|
90
102
|
completed: { tone: 'success', defaultLabel: 'Completed' },
|
|
91
103
|
failed: { tone: 'critical', defaultLabel: 'Failed' },
|
|
92
104
|
cancelled: { tone: 'neutral', defaultLabel: 'Cancelled' },
|
|
93
105
|
expired: { tone: 'neutral', defaultLabel: 'Expired' },
|
|
106
|
+
revoked: { tone: 'neutral', defaultLabel: 'Revoked' },
|
|
94
107
|
draft: { tone: 'neutral', defaultLabel: 'Draft' },
|
|
95
108
|
suspended: { tone: 'warning', defaultLabel: 'Suspended' },
|
|
96
109
|
approved: { tone: 'success', defaultLabel: 'Approved' },
|
package/src/lib/utils.ts
CHANGED
|
@@ -4,22 +4,3 @@ import { twMerge } from 'tailwind-merge';
|
|
|
4
4
|
export function cn(...inputs: ClassValue[]): string {
|
|
5
5
|
return twMerge(clsx(inputs));
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
export function slugify(str: string): string {
|
|
9
|
-
return str
|
|
10
|
-
.toLowerCase()
|
|
11
|
-
.trim()
|
|
12
|
-
.replace(/[^\w\s-]/g, '')
|
|
13
|
-
.replace(/[\s_-]+/g, '-')
|
|
14
|
-
.replace(/^-+|-+$/g, '');
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function hashString(str: string): number {
|
|
18
|
-
let hash = 0;
|
|
19
|
-
for (let i = 0; i < str.length; i++) {
|
|
20
|
-
const char = str.charCodeAt(i);
|
|
21
|
-
hash = (hash << 5) - hash + char;
|
|
22
|
-
hash |= 0;
|
|
23
|
-
}
|
|
24
|
-
return Math.abs(hash);
|
|
25
|
-
}
|