@brightlocal/ui-components 2.27.0 → 3.1.0
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/README.md +7 -1
- package/component-meta.json +568 -143
- package/deprecations.json +298 -1
- package/dist/accordion.cjs +1 -1
- package/dist/accordion.d.ts +36 -0
- package/dist/accordion.d.ts.map +1 -1
- package/dist/accordion.js +74 -61
- package/dist/alert-dialog.cjs +1 -1
- package/dist/alert-dialog.js +18 -18
- package/dist/alert.cjs +1 -1
- package/dist/alert.d.ts +11 -1
- package/dist/alert.d.ts.map +1 -1
- package/dist/alert.js +31 -28
- package/dist/avatar.cjs +1 -1
- package/dist/avatar.js +4 -4
- package/dist/badge.cjs +1 -1
- package/dist/badge.d.ts.map +1 -1
- package/dist/badge.js +15 -11
- package/dist/blocks/empty-state.cjs +1 -0
- package/dist/blocks/empty-state.d.ts +172 -0
- package/dist/blocks/empty-state.d.ts.map +1 -0
- package/dist/blocks/empty-state.js +147 -0
- package/dist/blocks/input-list.cjs +2 -2
- package/dist/blocks/input-list.d.ts.map +1 -1
- package/dist/blocks/input-list.js +124 -108
- package/dist/blocks/progress-state.cjs +1 -0
- package/dist/blocks/{progress-screen.d.ts → progress-state.d.ts} +30 -18
- package/dist/blocks/progress-state.d.ts.map +1 -0
- package/dist/blocks/{progress-screen.js → progress-state.js} +100 -71
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +160 -161
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.js +1 -1
- package/dist/button-group.cjs +1 -0
- package/dist/button-group.d.ts +36 -0
- package/dist/button-group.d.ts.map +1 -0
- package/dist/button-group.js +47 -0
- package/dist/button.cjs +1 -1
- package/dist/button.js +12 -12
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.d.ts.map +1 -1
- package/dist/calendar.js +37 -38
- package/dist/callout.cjs +1 -1
- package/dist/callout.d.ts +24 -2
- package/dist/callout.d.ts.map +1 -1
- package/dist/callout.js +57 -55
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +42 -3
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +102 -91
- package/dist/chart-empty.cjs +1 -0
- package/dist/chart-empty.d.ts +59 -0
- package/dist/chart-empty.d.ts.map +1 -0
- package/dist/chart-empty.js +29 -0
- package/dist/chart.cjs +6 -6
- package/dist/chart.d.ts +46 -13
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +172 -157
- package/dist/chip.cjs +1 -1
- package/dist/chip.d.ts +38 -4
- package/dist/chip.d.ts.map +1 -1
- package/dist/chip.js +100 -84
- package/dist/combobox.cjs +2 -2
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +81 -79
- package/dist/command.cjs +1 -1
- package/dist/command.d.ts +23 -1
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +248 -225
- package/dist/context-menu.cjs +1 -1
- package/dist/context-menu.d.ts.map +1 -1
- package/dist/context-menu.js +26 -29
- package/dist/data-table.cjs +1 -1
- package/dist/data-table.d.ts +75 -10
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +346 -334
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.d.ts +13 -5
- package/dist/date-picker.d.ts.map +1 -1
- package/dist/date-picker.js +54 -53
- package/dist/description.cjs +1 -1
- package/dist/description.js +5 -5
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.js +20 -20
- package/dist/drawer.cjs +1 -1
- package/dist/drawer.d.ts.map +1 -1
- package/dist/drawer.js +8 -11
- package/dist/dropdown-menu.cjs +1 -1
- package/dist/dropdown-menu.d.ts.map +1 -1
- package/dist/dropdown-menu.js +17 -20
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts +8 -1
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +96 -65
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +130 -12
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +146 -127
- package/dist/grid.cjs +1 -0
- package/dist/grid.d.ts +56 -0
- package/dist/grid.d.ts.map +1 -0
- package/dist/grid.js +32 -0
- package/dist/header.d.ts +13 -0
- package/dist/header.d.ts.map +1 -1
- package/dist/hooks/use-delayed-pending.cjs +1 -0
- package/dist/hooks/use-delayed-pending.d.ts +34 -0
- package/dist/hooks/use-delayed-pending.d.ts.map +1 -0
- package/dist/hooks/use-delayed-pending.js +17 -0
- package/dist/hooks/use-mobile.cjs +1 -0
- package/dist/hooks/use-mobile.js +8 -0
- package/dist/hover-card.cjs +1 -1
- package/dist/hover-card.js +13 -13
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +554 -527
- package/dist/input-chip.cjs +1 -1
- package/dist/input-chip.js +25 -25
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.js +9 -9
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.js +9 -9
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts +17 -9
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +73 -72
- package/dist/input.cjs +1 -1
- package/dist/input.js +9 -9
- package/dist/label.cjs +1 -1
- package/dist/label.d.ts.map +1 -1
- package/dist/label.js +25 -28
- package/dist/lib/block-illustration.cjs +1 -0
- package/dist/lib/block-illustration.d.ts +28 -0
- package/dist/lib/block-illustration.d.ts.map +1 -0
- package/dist/lib/block-illustration.js +21 -0
- package/dist/lib/empty-canvas.cjs +1 -0
- package/dist/lib/empty-canvas.d.ts +27 -0
- package/dist/lib/empty-canvas.d.ts.map +1 -0
- package/dist/lib/empty-canvas.js +62 -0
- package/dist/lib/empty-chip.cjs +1 -0
- package/dist/lib/empty-chip.d.ts +4 -0
- package/dist/lib/empty-chip.d.ts.map +1 -0
- package/dist/lib/empty-chip.js +13 -0
- package/dist/lib/optical-center.cjs +1 -0
- package/dist/lib/optical-center.d.ts +12 -0
- package/dist/lib/optical-center.d.ts.map +1 -0
- package/dist/lib/optical-center.js +11 -0
- package/dist/lib/utils.cjs +1 -1
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +28 -5
- package/dist/list.cjs +1 -1
- package/dist/list.d.ts.map +1 -1
- package/dist/list.js +62 -58
- package/dist/map.cjs +1 -1
- package/dist/map.d.ts +60 -2
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +187 -164
- package/dist/media-empty.cjs +1 -0
- package/dist/media-empty.d.ts +72 -0
- package/dist/media-empty.d.ts.map +1 -0
- package/dist/media-empty.js +45 -0
- package/dist/menubar.cjs +1 -1
- package/dist/menubar.d.ts.map +1 -1
- package/dist/menubar.js +17 -20
- package/dist/navigation-menu.cjs +1 -1
- package/dist/navigation-menu.js +7 -7
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.d.ts +130 -1
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +193 -102
- package/dist/progress.cjs +1 -1
- package/dist/progress.d.ts +2 -26
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +79 -118
- package/dist/scroll-area.cjs +1 -1
- package/dist/scroll-area.d.ts +15 -6
- package/dist/scroll-area.d.ts.map +1 -1
- package/dist/scroll-area.js +38 -36
- package/dist/select.cjs +2 -2
- package/dist/select.d.ts +13 -2
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +92 -87
- package/dist/separator.cjs +1 -1
- package/dist/separator.js +8 -8
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.js +2 -2
- package/dist/skeleton.cjs +1 -1
- package/dist/skeleton.d.ts +38 -3
- package/dist/skeleton.d.ts.map +1 -1
- package/dist/skeleton.js +43 -20
- package/dist/sonner.cjs +1 -1
- package/dist/sonner.js +26 -26
- package/dist/stepper.cjs +1 -1
- package/dist/stepper.js +40 -40
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +31 -28
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.js +1 -1
- package/dist/text-reveal-motion.d.ts +10 -0
- package/dist/text-reveal-motion.d.ts.map +1 -1
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.js +11 -11
- package/dist/toggle.cjs +1 -1
- package/dist/toggle.js +8 -8
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.js +8 -8
- package/dist/typography-heading.cjs +1 -0
- package/dist/typography-heading.d.ts +129 -0
- package/dist/typography-heading.d.ts.map +1 -0
- package/dist/typography-heading.js +95 -0
- package/dist/typography-text.cjs +1 -0
- package/dist/typography-text.d.ts +127 -0
- package/dist/typography-text.d.ts.map +1 -0
- package/dist/typography-text.js +92 -0
- package/dist/typography.d.ts +13 -0
- package/dist/typography.d.ts.map +1 -1
- package/package.json +35 -7
- package/src/blocks/empty-state.tsx +412 -0
- package/src/blocks/input-list.tsx +66 -36
- package/src/blocks/{progress-screen.tsx → progress-state.tsx} +154 -93
- package/src/blocks/sidebar.tsx +25 -26
- package/src/components/accordion.tsx +82 -27
- package/src/components/alert-dialog.tsx +2 -2
- package/src/components/alert.tsx +27 -13
- package/src/components/avatar.tsx +1 -1
- package/src/components/badge.tsx +8 -4
- package/src/components/breadcrumb.tsx +1 -1
- package/src/components/button-group.tsx +112 -0
- package/src/components/button.tsx +4 -4
- package/src/components/calendar.tsx +5 -6
- package/src/components/callout.tsx +48 -15
- package/src/components/card.tsx +89 -19
- package/src/components/chart-empty.tsx +116 -0
- package/src/components/chart.tsx +103 -32
- package/src/components/chip.tsx +88 -13
- package/src/components/combobox.tsx +12 -10
- package/src/components/command.tsx +64 -13
- package/src/components/context-menu.tsx +6 -9
- package/src/components/data-table.tsx +135 -20
- package/src/components/date-picker.tsx +18 -7
- package/src/components/description.tsx +1 -1
- package/src/components/dialog.tsx +2 -2
- package/src/components/drawer.tsx +2 -5
- package/src/components/dropdown-menu.tsx +8 -11
- package/src/components/field.tsx +89 -16
- package/src/components/global-layout.tsx +210 -39
- package/src/components/grid.tsx +130 -0
- package/src/components/header.tsx +13 -0
- package/src/components/hover-card.tsx +1 -1
- package/src/components/input-chip.tsx +1 -1
- package/src/components/input-group.tsx +1 -1
- package/src/components/input-otp.tsx +1 -1
- package/src/components/input-password.tsx +24 -12
- package/src/components/input.tsx +1 -1
- package/src/components/label.tsx +10 -13
- package/src/components/list.tsx +13 -9
- package/src/components/map.tsx +101 -5
- package/src/components/media-empty.tsx +156 -0
- package/src/components/menubar.tsx +7 -10
- package/src/components/navigation-menu.tsx +1 -1
- package/src/components/pagination.tsx +286 -1
- package/src/components/progress.tsx +35 -113
- package/src/components/scroll-area.tsx +23 -10
- package/src/components/select.tsx +35 -10
- package/src/components/separator.tsx +1 -1
- package/src/components/sheet.tsx +2 -2
- package/src/components/skeleton.tsx +78 -7
- package/src/components/sonner.tsx +2 -2
- package/src/components/stepper.tsx +3 -3
- package/src/components/table.tsx +6 -3
- package/src/components/tabs.tsx +1 -1
- package/src/components/text-reveal-motion.tsx +10 -0
- package/src/components/textarea.tsx +1 -1
- package/src/components/toggle.tsx +1 -1
- package/src/components/tooltip.tsx +1 -1
- package/src/components/typography-heading.tsx +253 -0
- package/src/components/typography-text.tsx +250 -0
- package/src/components/typography.tsx +13 -0
- package/src/hooks/use-delayed-pending.ts +60 -0
- package/src/index.ts +11 -1
- package/src/lib/block-illustration.tsx +88 -0
- package/src/lib/empty-canvas.tsx +128 -0
- package/src/lib/empty-chip.ts +24 -0
- package/src/lib/optical-center.tsx +45 -0
- package/src/lib/utils.ts +26 -0
- package/dist/blocks/progress-screen.cjs +0 -1
- package/dist/blocks/progress-screen.d.ts.map +0 -1
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
4
|
+
import { OpticalCenter } from "../lib/optical-center";
|
|
5
|
+
|
|
6
|
+
/* -------------------------------------------------------------------------------------------------
|
|
7
|
+
* Grid
|
|
8
|
+
*
|
|
9
|
+
* The layout primitive (DS-970): one component, one closed `variant` axis, and
|
|
10
|
+
* the modifiers each layout actually has — a discriminated union, so a prop
|
|
11
|
+
* that does not belong to a variant does not compile. The point is a learnable
|
|
12
|
+
* vocabulary: squads compose named layouts instead of hand-rolling flex/grid
|
|
13
|
+
* classNames, and the numbers those layouts agree on live here once.
|
|
14
|
+
*
|
|
15
|
+
* Variants ship as the family lands (see DS-970 for the inventory that sizes
|
|
16
|
+
* them):
|
|
17
|
+
*
|
|
18
|
+
* centered — one message held at the page body's OPTICAL centre.
|
|
19
|
+
* Shipped first because the single-message screens
|
|
20
|
+
* (`EmptyState size="lg"`, `ProgressState`) already share
|
|
21
|
+
* this agreement.
|
|
22
|
+
* stack / row / cards
|
|
23
|
+
* — vertical rhythm, inline cluster, responsive collections.
|
|
24
|
+
* Reserved: their closed props (gap scale, align, justify,
|
|
25
|
+
* cols) arrive with DS-970.
|
|
26
|
+
*
|
|
27
|
+
* `variant="centered"` is optical, not geometric: the content sits 38% down, not
|
|
28
|
+
* 50% (the derivation lives with the ratio in `lib/optical-center`). The ratio
|
|
29
|
+
* is the variant's only opinion and is deliberately not a prop. Not
|
|
30
|
+
* `CentredLayout`: that one owns the whole VIEWPORT (min-h-screen, background,
|
|
31
|
+
* padding) for pages outside the app shell — auth, invites. Grid owns nothing
|
|
32
|
+
* but the position inside whatever box it is given.
|
|
33
|
+
*
|
|
34
|
+
* The single-message blocks are deliberately NOT wired to this internally:
|
|
35
|
+
* `EmptyState size="lg"` is a pure visual block, and the page recipe is the
|
|
36
|
+
* composition `<Grid variant="centered"><EmptyState size="lg" /></Grid>` — so
|
|
37
|
+
* the same block can also sit in a custom position when a product needs one,
|
|
38
|
+
* without a prop to switch the layout off.
|
|
39
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The named layouts. Closed on purpose — a layout the vocabulary lacks is a
|
|
43
|
+
* signal to add a value here, not a className at the call site.
|
|
44
|
+
* (`stack`, `row`, `cards` are reserved for DS-970.)
|
|
45
|
+
*/
|
|
46
|
+
type GridVariant = "centered";
|
|
47
|
+
|
|
48
|
+
interface GridBaseProps extends React.ComponentPropsWithoutRef<"div"> {
|
|
49
|
+
/**
|
|
50
|
+
* Required data-hook attribute for automated testing.
|
|
51
|
+
* @example "locations-empty-center"
|
|
52
|
+
*/
|
|
53
|
+
dataHook: string;
|
|
54
|
+
/**
|
|
55
|
+
* Tracking element identifier for analytics.
|
|
56
|
+
*/
|
|
57
|
+
trackingEl?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Tracking label for analytics context.
|
|
60
|
+
*/
|
|
61
|
+
trackingLabel?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* One message at the page body's optical centre (38/62). Give it a page body
|
|
66
|
+
* to fill — it stretches with `flex-1` — and one message to hold.
|
|
67
|
+
*/
|
|
68
|
+
interface GridCenteredProps extends GridBaseProps {
|
|
69
|
+
variant: "centered";
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Props for the Grid primitive. `variant` discriminates the shapes; each
|
|
74
|
+
* variant carries only the modifiers it actually has.
|
|
75
|
+
*/
|
|
76
|
+
export type GridProps = GridCenteredProps;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The layout primitive: a closed vocabulary of named layouts instead of
|
|
80
|
+
* hand-rolled flex/grid classNames.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```tsx
|
|
84
|
+
* <GlobalLayoutBody dataHook="locations-body">
|
|
85
|
+
* <Grid dataHook="locations-empty-center" variant="centered">
|
|
86
|
+
* <EmptyState
|
|
87
|
+
* dataHook="locations-empty"
|
|
88
|
+
* illustration={<BusinessLocation aria-hidden />}
|
|
89
|
+
* size="lg"
|
|
90
|
+
* title={t("locations.empty.title")}
|
|
91
|
+
* />
|
|
92
|
+
* </Grid>
|
|
93
|
+
* </GlobalLayoutBody>
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
const Grid = React.forwardRef<HTMLDivElement, GridProps>(
|
|
97
|
+
(
|
|
98
|
+
{
|
|
99
|
+
className,
|
|
100
|
+
children,
|
|
101
|
+
dataHook,
|
|
102
|
+
variant,
|
|
103
|
+
trackingEl,
|
|
104
|
+
trackingLabel,
|
|
105
|
+
...props
|
|
106
|
+
},
|
|
107
|
+
ref
|
|
108
|
+
) => {
|
|
109
|
+
return (
|
|
110
|
+
<div
|
|
111
|
+
ref={ref}
|
|
112
|
+
className={cn("flex w-full flex-1 flex-col items-center", className)}
|
|
113
|
+
data-hook={dataHook}
|
|
114
|
+
data-slot="grid"
|
|
115
|
+
data-tracking-el={trackingEl ?? "grid"}
|
|
116
|
+
data-tracking-label={trackingLabel}
|
|
117
|
+
data-variant={variant}
|
|
118
|
+
{...props}
|
|
119
|
+
>
|
|
120
|
+
<OpticalCenter>{children}</OpticalCenter>
|
|
121
|
+
</div>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
Grid.displayName = "Grid";
|
|
127
|
+
|
|
128
|
+
export { Grid };
|
|
129
|
+
|
|
130
|
+
export type { GridVariant };
|
|
@@ -35,6 +35,19 @@ const headerVariants = cva("flex w-full items-center", {
|
|
|
35
35
|
* <Logo dataHook="header-logo" />
|
|
36
36
|
* <NavigationMenu dataHook="header-nav" />
|
|
37
37
|
* </Header>
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* // With the page title. The title is a TypographyHeading on the semantic
|
|
41
|
+
* // type scale (DS-714): text-heading-page — Poppins · Figma 600 · 24/32,
|
|
42
|
+
* // rendering one CSS weight lighter per the DS-305 offset. Never
|
|
43
|
+
* // hand-style it. `variant="page"` is level 1's default, written out so
|
|
44
|
+
* // the scale role is explicit. Exactly one page title per screen — a
|
|
45
|
+
* // second title is a section (`variant="section"`).
|
|
46
|
+
* <Header dataHook="page-header">
|
|
47
|
+
* <TypographyHeading level={1} variant="page" dataHook="page-title">
|
|
48
|
+
* All Locations
|
|
49
|
+
* </TypographyHeading>
|
|
50
|
+
* </Header>
|
|
38
51
|
*/
|
|
39
52
|
|
|
40
53
|
interface HeaderProps extends React.ComponentProps<"header"> {
|
|
@@ -89,7 +89,7 @@ const HoverCardTrigger = React.forwardRef<
|
|
|
89
89
|
ref={ref}
|
|
90
90
|
aria-disabled={disabled}
|
|
91
91
|
className={cn(
|
|
92
|
-
"text-link
|
|
92
|
+
"text-link text-label cursor-pointer underline",
|
|
93
93
|
disabled && "pointer-events-none cursor-not-allowed opacity-50",
|
|
94
94
|
className
|
|
95
95
|
)}
|
|
@@ -137,7 +137,7 @@ InputGroupAddon.displayName = "InputGroupAddon";
|
|
|
137
137
|
const inputGroupButtonVariants = cva(
|
|
138
138
|
[
|
|
139
139
|
"inline-flex items-center justify-center gap-2",
|
|
140
|
-
"text-
|
|
140
|
+
"text-label transition-colors duration-fast ease-out",
|
|
141
141
|
"outline-none focus-visible:shadow-default rounded-sm",
|
|
142
142
|
"disabled:pointer-events-none disabled:opacity-50",
|
|
143
143
|
"text-muted-foreground hover:text-foreground",
|
|
@@ -137,7 +137,7 @@ function InputOTPSlot({ index, className, ...props }: InputOTPSlotProps) {
|
|
|
137
137
|
// Base styles
|
|
138
138
|
"relative flex h-9 w-9 items-center justify-center",
|
|
139
139
|
"border-input bg-background border-y border-r",
|
|
140
|
-
"text-foreground duration-fast text-
|
|
140
|
+
"text-foreground duration-fast text-body transition-[border-color,box-shadow] ease-out outline-none",
|
|
141
141
|
"first:rounded-l-md first:border-l last:rounded-r-md",
|
|
142
142
|
// Focus state
|
|
143
143
|
"data-[active=true]:border-ring data-[active=true]:z-10",
|
|
@@ -114,17 +114,17 @@ function useInputPasswordContext() {
|
|
|
114
114
|
const context = React.useContext(InputPasswordContext);
|
|
115
115
|
if (!context) {
|
|
116
116
|
throw new Error(
|
|
117
|
-
"InputPassword compound components must be used within
|
|
117
|
+
"InputPassword compound components must be used within InputPassword"
|
|
118
118
|
);
|
|
119
119
|
}
|
|
120
120
|
return context;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
// ============================================================================
|
|
124
|
-
//
|
|
124
|
+
// InputPassword (root)
|
|
125
125
|
// ============================================================================
|
|
126
126
|
|
|
127
|
-
export interface
|
|
127
|
+
export interface InputPasswordProps<
|
|
128
128
|
T extends string = DefaultPasswordStrength,
|
|
129
129
|
> {
|
|
130
130
|
/**
|
|
@@ -192,16 +192,16 @@ export interface InputPasswordRootProps<
|
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
/**
|
|
195
|
-
*
|
|
195
|
+
* InputPassword - Root component that provides context for all InputPassword parts
|
|
196
196
|
*
|
|
197
197
|
* Generic type parameter T allows custom strength levels:
|
|
198
198
|
* @example
|
|
199
199
|
* // Using default levels
|
|
200
|
-
* <
|
|
200
|
+
* <InputPassword dataHook="password">...</InputPassword>
|
|
201
201
|
*
|
|
202
202
|
* // Using custom levels
|
|
203
203
|
* type MyStrength = "empty" | "slow" | "medium" | "fast";
|
|
204
|
-
* <
|
|
204
|
+
* <InputPassword<MyStrength>
|
|
205
205
|
* dataHook="password"
|
|
206
206
|
* strengthLevels={{
|
|
207
207
|
* empty: { label: "Enter password", value: 0, color: "bg-muted" },
|
|
@@ -217,9 +217,9 @@ export interface InputPasswordRootProps<
|
|
|
217
217
|
* }}
|
|
218
218
|
* >
|
|
219
219
|
* ...
|
|
220
|
-
* </
|
|
220
|
+
* </InputPassword>
|
|
221
221
|
*/
|
|
222
|
-
function
|
|
222
|
+
function InputPassword<T extends string = DefaultPasswordStrength>({
|
|
223
223
|
children,
|
|
224
224
|
dataHook,
|
|
225
225
|
trackingEl,
|
|
@@ -233,7 +233,7 @@ function InputPasswordRoot<T extends string = DefaultPasswordStrength>({
|
|
|
233
233
|
error,
|
|
234
234
|
id,
|
|
235
235
|
className,
|
|
236
|
-
}:
|
|
236
|
+
}: InputPasswordProps<T>) {
|
|
237
237
|
const [showPassword, setShowPassword] = React.useState(false);
|
|
238
238
|
const [internalPassword, setInternalPassword] = React.useState("");
|
|
239
239
|
const [strength, setStrength] = React.useState<string>("meter");
|
|
@@ -323,7 +323,18 @@ function InputPasswordRoot<T extends string = DefaultPasswordStrength>({
|
|
|
323
323
|
);
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
-
|
|
326
|
+
InputPassword.displayName = "InputPassword";
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* @deprecated Use `InputPassword` instead — family roots are bare names (DS-853).
|
|
330
|
+
*/
|
|
331
|
+
const InputPasswordRoot = InputPassword;
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* @deprecated Use `InputPasswordProps` instead — family roots are bare names (DS-853).
|
|
335
|
+
*/
|
|
336
|
+
export type InputPasswordRootProps<T extends string = DefaultPasswordStrength> =
|
|
337
|
+
InputPasswordProps<T>;
|
|
327
338
|
|
|
328
339
|
// ============================================================================
|
|
329
340
|
// InputPasswordField
|
|
@@ -501,7 +512,7 @@ export interface InputPasswordStrengthProps {
|
|
|
501
512
|
/**
|
|
502
513
|
* InputPasswordStrength - Password strength indicator
|
|
503
514
|
* Displays a progress bar and optional label showing password strength.
|
|
504
|
-
* Automatically uses the strength levels configured on
|
|
515
|
+
* Automatically uses the strength levels configured on InputPassword.
|
|
505
516
|
*/
|
|
506
517
|
function InputPasswordStrength({
|
|
507
518
|
className,
|
|
@@ -528,7 +539,7 @@ function InputPasswordStrength({
|
|
|
528
539
|
/>
|
|
529
540
|
{showLabel && (
|
|
530
541
|
<span
|
|
531
|
-
className="text-foreground w-10 shrink-0 text-right
|
|
542
|
+
className="text-foreground text-label w-10 shrink-0 text-right whitespace-nowrap"
|
|
532
543
|
data-hook={`${dataHook}-strength-label`}
|
|
533
544
|
>
|
|
534
545
|
{config.label}
|
|
@@ -546,6 +557,7 @@ InputPasswordStrength.displayName = "InputPasswordStrength";
|
|
|
546
557
|
// ============================================================================
|
|
547
558
|
|
|
548
559
|
export {
|
|
560
|
+
InputPassword,
|
|
549
561
|
InputPasswordRoot,
|
|
550
562
|
InputPasswordField,
|
|
551
563
|
InputPasswordToggle,
|
package/src/components/input.tsx
CHANGED
|
@@ -16,7 +16,7 @@ export const inputVariants = cva(
|
|
|
16
16
|
"border border-input bg-background rounded-sm",
|
|
17
17
|
"outline-none transition-[border-color,box-shadow,background-color] duration-fast ease-out",
|
|
18
18
|
// Typography
|
|
19
|
-
"text-
|
|
19
|
+
"text-body",
|
|
20
20
|
"text-foreground",
|
|
21
21
|
"overflow-hidden text-ellipsis",
|
|
22
22
|
// States - Focus
|
package/src/components/label.tsx
CHANGED
|
@@ -5,20 +5,17 @@ import * as LabelPrimitive from "@radix-ui/react-label";
|
|
|
5
5
|
import { cva } from "class-variance-authority";
|
|
6
6
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
7
7
|
|
|
8
|
-
const labelVariants = cva(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
optional: {
|
|
13
|
-
true: "after:ml-1 after:content-['(optional)']",
|
|
14
|
-
},
|
|
15
|
-
srOnly: {
|
|
16
|
-
true: "sr-only",
|
|
17
|
-
},
|
|
8
|
+
const labelVariants = cva(["text-label", "text-foreground"], {
|
|
9
|
+
variants: {
|
|
10
|
+
optional: {
|
|
11
|
+
true: "after:ml-1 after:content-['(optional)']",
|
|
18
12
|
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
srOnly: {
|
|
14
|
+
true: "sr-only",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
defaultVariants: {},
|
|
18
|
+
});
|
|
22
19
|
|
|
23
20
|
interface LabelProps extends React.ComponentPropsWithoutRef<"label"> {
|
|
24
21
|
/**
|
package/src/components/list.tsx
CHANGED
|
@@ -232,10 +232,7 @@ const ItemTitle = React.forwardRef<HTMLDivElement, ItemTitleProps>(
|
|
|
232
232
|
({ className, ...props }, ref) => (
|
|
233
233
|
<div
|
|
234
234
|
ref={ref}
|
|
235
|
-
className={cn(
|
|
236
|
-
"text-foreground text-base leading-normal font-medium",
|
|
237
|
-
className
|
|
238
|
-
)}
|
|
235
|
+
className={cn("text-foreground text-body", className)}
|
|
239
236
|
data-slot="item-title"
|
|
240
237
|
{...props}
|
|
241
238
|
/>
|
|
@@ -257,10 +254,7 @@ const ItemDescription = React.forwardRef<HTMLDivElement, ItemDescriptionProps>(
|
|
|
257
254
|
({ className, ...props }, ref) => (
|
|
258
255
|
<div
|
|
259
256
|
ref={ref}
|
|
260
|
-
className={cn(
|
|
261
|
-
"text-muted-foreground text-sm leading-normal font-normal",
|
|
262
|
-
className
|
|
263
|
-
)}
|
|
257
|
+
className={cn("text-body-sm text-muted-foreground", className)}
|
|
264
258
|
data-slot="item-description"
|
|
265
259
|
{...props}
|
|
266
260
|
/>
|
|
@@ -322,7 +316,17 @@ const ItemSubheader = React.forwardRef<HTMLLIElement, ItemSubheaderProps>(
|
|
|
322
316
|
<li
|
|
323
317
|
ref={ref}
|
|
324
318
|
className={cn(
|
|
325
|
-
|
|
319
|
+
// A subheader is a caption over its group of items — the same role as a
|
|
320
|
+
// menu or sidebar group label, so text-label-sm (DS-925).
|
|
321
|
+
// Padding is deliberately asymmetric: with the old symmetric py-2 the
|
|
322
|
+
// caption sat equidistant between the previous group and its own
|
|
323
|
+
// (17px each side over the list's 8px gap), so it read as a second
|
|
324
|
+
// title rather than a label for the group below. 16px above / 4px
|
|
325
|
+
// below binds it downwards. The space above only has a job when a
|
|
326
|
+
// group precedes it, so a subheader that opens the list stays tight —
|
|
327
|
+
// that keeps compact surfaces (the Map popover, which sets gap-0
|
|
328
|
+
// inside p-3) from opening up.
|
|
329
|
+
"text-muted-foreground text-label-sm flex items-center pt-4 pr-2 pb-1 pl-4 first:pt-2",
|
|
326
330
|
className
|
|
327
331
|
)}
|
|
328
332
|
data-hook={dataHook}
|
package/src/components/map.tsx
CHANGED
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { cva } from "class-variance-authority";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
Map as MapIcon,
|
|
7
|
+
RefreshCw,
|
|
8
|
+
Store,
|
|
9
|
+
TriangleAlert,
|
|
10
|
+
} from "@brightlocal/icons";
|
|
6
11
|
import {
|
|
7
12
|
GlobeyFixingFault,
|
|
8
13
|
MapBackground as MapBackgroundImage,
|
|
@@ -18,6 +23,7 @@ import {
|
|
|
18
23
|
type PopoverAnchorProps,
|
|
19
24
|
type PopoverContentProps,
|
|
20
25
|
} from "@brightlocal/ui-components/popover";
|
|
26
|
+
import { EmptyCanvas } from "../lib/empty-canvas";
|
|
21
27
|
|
|
22
28
|
// ──────────────────────────────────────
|
|
23
29
|
// MapTypeId
|
|
@@ -289,7 +295,7 @@ const mapGridPinColorMap: Record<ResolvedVariant, string> = Object.fromEntries(
|
|
|
289
295
|
) as Record<ResolvedVariant, string>;
|
|
290
296
|
|
|
291
297
|
const mapGridPinVariants = cva(
|
|
292
|
-
"inline-flex items-center justify-center rounded-full
|
|
298
|
+
"inline-flex items-center justify-center rounded-full text-label font-semibold text-foreground dark:text-neutral-900 border-2 border-white shadow-sm transition-shadow duration-fast ease-out hover:shadow-md",
|
|
293
299
|
{
|
|
294
300
|
variants: {
|
|
295
301
|
variant: {
|
|
@@ -1096,14 +1102,14 @@ const MapErrorState = React.forwardRef<HTMLDivElement, MapErrorStateProps>(
|
|
|
1096
1102
|
</div>
|
|
1097
1103
|
<div className="flex flex-col gap-2">
|
|
1098
1104
|
<h3
|
|
1099
|
-
className="text-foreground text-
|
|
1105
|
+
className="text-foreground text-heading-subsection"
|
|
1100
1106
|
data-slot="map-error-title"
|
|
1101
1107
|
>
|
|
1102
1108
|
{title}
|
|
1103
1109
|
</h3>
|
|
1104
1110
|
{message && (
|
|
1105
1111
|
<p
|
|
1106
|
-
className="text-muted-foreground text-sm"
|
|
1112
|
+
className="text-muted-foreground text-body-sm"
|
|
1107
1113
|
data-slot="map-error-message"
|
|
1108
1114
|
>
|
|
1109
1115
|
{message}
|
|
@@ -1131,6 +1137,94 @@ const MapErrorState = React.forwardRef<HTMLDivElement, MapErrorStateProps>(
|
|
|
1131
1137
|
|
|
1132
1138
|
MapErrorState.displayName = "MapErrorState";
|
|
1133
1139
|
|
|
1140
|
+
// ──────────────────────────────────────
|
|
1141
|
+
// MapEmpty
|
|
1142
|
+
// ──────────────────────────────────────
|
|
1143
|
+
|
|
1144
|
+
/**
|
|
1145
|
+
* Props for the MapEmpty component.
|
|
1146
|
+
*/
|
|
1147
|
+
interface MapEmptyProps extends Omit<
|
|
1148
|
+
React.ComponentProps<"div">,
|
|
1149
|
+
"children" | "title"
|
|
1150
|
+
> {
|
|
1151
|
+
/**
|
|
1152
|
+
* Required data-hook attribute for automated testing. The parts derive
|
|
1153
|
+
* theirs from it: `-icon`, `-message`.
|
|
1154
|
+
* @example "rankings-grid-map-empty"
|
|
1155
|
+
*/
|
|
1156
|
+
dataHook: string;
|
|
1157
|
+
/**
|
|
1158
|
+
* The glyph on the surface. The component sizes it.
|
|
1159
|
+
* @default <Map strokeWidth={2} />
|
|
1160
|
+
*/
|
|
1161
|
+
icon?: React.ReactNode;
|
|
1162
|
+
/**
|
|
1163
|
+
* The one line on the surface. Domain copy — "No ranking data yet" rather
|
|
1164
|
+
* than a bare "No data" — with no trailing period.
|
|
1165
|
+
* @default "No data yet"
|
|
1166
|
+
*/
|
|
1167
|
+
message?: string;
|
|
1168
|
+
/** Analytics element identifier */
|
|
1169
|
+
trackingEl?: string;
|
|
1170
|
+
/** Analytics label */
|
|
1171
|
+
trackingLabel?: string;
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
/**
|
|
1175
|
+
* A map surface with nothing to plot — the map's reserved box filled with a
|
|
1176
|
+
* muted surface, a bare icon, and one quiet line.
|
|
1177
|
+
*
|
|
1178
|
+
* The rule this exists to enforce: **a map never renders pinless with no
|
|
1179
|
+
* message.** An empty map and a broken map look identical, so silence here
|
|
1180
|
+
* reads as a fault every time.
|
|
1181
|
+
*
|
|
1182
|
+
* Unlike its `MapLoadingState` and `MapErrorState` siblings it does not draw
|
|
1183
|
+
* the decorative map background. Those two are telling the reader that a real
|
|
1184
|
+
* map is coming or has failed, so a map-shaped backdrop is honest; here there
|
|
1185
|
+
* is nothing to show, and a pinless map behind the message would recreate the
|
|
1186
|
+
* exact confusion the message is there to clear up.
|
|
1187
|
+
*
|
|
1188
|
+
* The surroundings must agree: KPI tiles beside an empty map show em-dashes and
|
|
1189
|
+
* drop their trend badges.
|
|
1190
|
+
*
|
|
1191
|
+
* @example
|
|
1192
|
+
* ```tsx
|
|
1193
|
+
* <div className="h-[500px]">
|
|
1194
|
+
* {hasRuns ? (
|
|
1195
|
+
* <GridMap dataHook="rankings-grid-map" {...gridMap} />
|
|
1196
|
+
* ) : (
|
|
1197
|
+
* <MapEmpty
|
|
1198
|
+
* dataHook="rankings-grid-map-empty"
|
|
1199
|
+
* message={t("rankings.map.empty")}
|
|
1200
|
+
* />
|
|
1201
|
+
* )}
|
|
1202
|
+
* </div>
|
|
1203
|
+
* ```
|
|
1204
|
+
*/
|
|
1205
|
+
const MapEmpty = React.forwardRef<HTMLDivElement, MapEmptyProps>(
|
|
1206
|
+
(
|
|
1207
|
+
{ className, dataHook, icon, message, trackingEl, trackingLabel, ...props },
|
|
1208
|
+
ref
|
|
1209
|
+
) => (
|
|
1210
|
+
/* `h-full w-full`, matching MapLoadingState: a map is always given its box
|
|
1211
|
+
by the consumer, and this fills it so nothing reflows when runs arrive. */
|
|
1212
|
+
<EmptyCanvas
|
|
1213
|
+
ref={ref}
|
|
1214
|
+
className={cn("h-full w-full rounded-lg", className)}
|
|
1215
|
+
dataHook={dataHook}
|
|
1216
|
+
icon={icon ?? <MapIcon strokeWidth={2} />}
|
|
1217
|
+
message={message ?? "No data yet"}
|
|
1218
|
+
slot="map-empty"
|
|
1219
|
+
trackingEl={trackingEl}
|
|
1220
|
+
trackingLabel={trackingLabel}
|
|
1221
|
+
{...props}
|
|
1222
|
+
/>
|
|
1223
|
+
)
|
|
1224
|
+
);
|
|
1225
|
+
|
|
1226
|
+
MapEmpty.displayName = "MapEmpty";
|
|
1227
|
+
|
|
1134
1228
|
// ──────────────────────────────────────
|
|
1135
1229
|
// MapLegendItem
|
|
1136
1230
|
// ──────────────────────────────────────
|
|
@@ -1166,7 +1260,7 @@ const MapLegendItem = React.forwardRef<HTMLSpanElement, MapLegendItemProps>(
|
|
|
1166
1260
|
<span
|
|
1167
1261
|
ref={ref}
|
|
1168
1262
|
className={cn(
|
|
1169
|
-
"text-foreground flex items-center gap-1
|
|
1263
|
+
"text-foreground text-body-xs flex items-center gap-1",
|
|
1170
1264
|
className
|
|
1171
1265
|
)}
|
|
1172
1266
|
data-hook={dataHook}
|
|
@@ -1498,6 +1592,7 @@ export {
|
|
|
1498
1592
|
MapControlButton,
|
|
1499
1593
|
MapLoadingState,
|
|
1500
1594
|
MapErrorState,
|
|
1595
|
+
MapEmpty,
|
|
1501
1596
|
MapLegend,
|
|
1502
1597
|
MapLegendItem,
|
|
1503
1598
|
MapPopover,
|
|
@@ -1521,6 +1616,7 @@ export type {
|
|
|
1521
1616
|
MapControlButtonProps,
|
|
1522
1617
|
MapLoadingStateProps,
|
|
1523
1618
|
MapErrorStateProps,
|
|
1619
|
+
MapEmptyProps,
|
|
1524
1620
|
MapLegendProps,
|
|
1525
1621
|
MapLegendItemProps,
|
|
1526
1622
|
MapPopoverProps,
|