@brightlocal/ui-components 3.0.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 +2 -1
- package/component-meta.json +90 -19
- package/deprecations.json +113 -3
- 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/blocks/empty-state.cjs +1 -1
- package/dist/blocks/empty-state.d.ts.map +1 -1
- package/dist/blocks/empty-state.js +41 -49
- 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 +1 -1
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +20 -2
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +83 -75
- package/dist/chart.cjs +2 -2
- package/dist/chart.d.ts +40 -12
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +86 -71
- 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 +95 -81
- 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 +250 -224
- package/dist/data-table.cjs +1 -1
- package/dist/data-table.d.ts +32 -1
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +340 -330
- 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/field.cjs +1 -1
- package/dist/field.d.ts +8 -1
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +79 -52
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +105 -13
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +146 -129
- package/dist/grid.d.ts +2 -2
- package/dist/hooks/use-mobile.cjs +1 -0
- package/dist/hooks/use-mobile.js +8 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +547 -538
- 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 +26 -25
- 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/pagination.cjs +1 -1
- package/dist/pagination.d.ts +3 -0
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +57 -57
- 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 +87 -83
- package/dist/typography-heading.cjs +1 -1
- package/dist/typography-heading.d.ts +13 -0
- package/dist/typography-heading.d.ts.map +1 -1
- package/dist/typography-heading.js +32 -21
- package/dist/typography-text.cjs +1 -1
- package/dist/typography-text.d.ts +14 -0
- package/dist/typography-text.d.ts.map +1 -1
- package/dist/typography-text.js +35 -24
- package/package.json +1 -1
- package/src/blocks/empty-state.tsx +9 -21
- package/src/components/accordion.tsx +82 -27
- package/src/components/button-group.tsx +112 -0
- package/src/components/button.tsx +1 -1
- package/src/components/card.tsx +38 -3
- package/src/components/chart.tsx +63 -18
- package/src/components/chip.tsx +83 -10
- package/src/components/command.tsx +55 -3
- package/src/components/data-table.tsx +67 -7
- package/src/components/date-picker.tsx +18 -7
- package/src/components/field.tsx +81 -12
- package/src/components/global-layout.tsx +176 -38
- package/src/components/grid.tsx +2 -2
- package/src/components/input-password.tsx +23 -11
- package/src/components/pagination.tsx +10 -3
- package/src/components/scroll-area.tsx +23 -10
- package/src/components/select.tsx +30 -6
- package/src/components/typography-heading.tsx +24 -0
- package/src/components/typography-text.tsx +26 -1
- package/src/index.ts +1 -0
- package/src/lib/empty-chip.ts +24 -0
|
@@ -66,8 +66,10 @@ const ScrollArea = React.forwardRef<
|
|
|
66
66
|
>
|
|
67
67
|
{children}
|
|
68
68
|
</ScrollAreaPrimitive.Viewport>
|
|
69
|
-
<
|
|
70
|
-
{scrollOrientation === "both" &&
|
|
69
|
+
<ScrollAreaScrollbar />
|
|
70
|
+
{scrollOrientation === "both" && (
|
|
71
|
+
<ScrollAreaScrollbar orientation="horizontal" />
|
|
72
|
+
)}
|
|
71
73
|
<ScrollAreaPrimitive.Corner />
|
|
72
74
|
</ScrollAreaPrimitive.Root>
|
|
73
75
|
);
|
|
@@ -77,9 +79,9 @@ const ScrollArea = React.forwardRef<
|
|
|
77
79
|
ScrollArea.displayName = "ScrollArea";
|
|
78
80
|
|
|
79
81
|
/**
|
|
80
|
-
* Props for the
|
|
82
|
+
* Props for the ScrollAreaScrollbar component.
|
|
81
83
|
*/
|
|
82
|
-
interface
|
|
84
|
+
interface ScrollAreaScrollbarProps extends React.ComponentProps<
|
|
83
85
|
typeof ScrollAreaPrimitive.ScrollAreaScrollbar
|
|
84
86
|
> {
|
|
85
87
|
/**
|
|
@@ -102,11 +104,11 @@ interface ScrollBarProps extends React.ComponentProps<
|
|
|
102
104
|
}
|
|
103
105
|
|
|
104
106
|
/**
|
|
105
|
-
*
|
|
107
|
+
* ScrollAreaScrollbar provides a styled scrollbar for ScrollArea.
|
|
106
108
|
*/
|
|
107
|
-
const
|
|
109
|
+
const ScrollAreaScrollbar = React.forwardRef<
|
|
108
110
|
React.ComponentRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
|
|
109
|
-
|
|
111
|
+
ScrollAreaScrollbarProps
|
|
110
112
|
>(
|
|
111
113
|
(
|
|
112
114
|
{
|
|
@@ -146,8 +148,19 @@ const ScrollBar = React.forwardRef<
|
|
|
146
148
|
}
|
|
147
149
|
);
|
|
148
150
|
|
|
149
|
-
|
|
151
|
+
ScrollAreaScrollbar.displayName = "ScrollAreaScrollbar";
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* @deprecated Use `ScrollAreaScrollbar` instead — family parts carry the
|
|
155
|
+
* `ScrollArea` family prefix (DS-853).
|
|
156
|
+
*/
|
|
157
|
+
const ScrollBar = ScrollAreaScrollbar;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @deprecated Use `ScrollAreaScrollbarProps` instead (DS-853).
|
|
161
|
+
*/
|
|
162
|
+
type ScrollBarProps = ScrollAreaScrollbarProps;
|
|
150
163
|
|
|
151
|
-
export { ScrollArea, ScrollBar };
|
|
164
|
+
export { ScrollArea, ScrollAreaScrollbar, ScrollBar };
|
|
152
165
|
|
|
153
|
-
export type { ScrollAreaProps, ScrollBarProps };
|
|
166
|
+
export type { ScrollAreaProps, ScrollAreaScrollbarProps, ScrollBarProps };
|
|
@@ -403,11 +403,21 @@ SelectLabel.displayName = "SelectLabel";
|
|
|
403
403
|
* </div>
|
|
404
404
|
* </SelectItem>
|
|
405
405
|
*/
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
406
|
+
/**
|
|
407
|
+
* Props for the SelectItem component.
|
|
408
|
+
*/
|
|
409
|
+
interface SelectItemProps extends React.ComponentProps<
|
|
410
|
+
typeof SelectPrimitive.Item
|
|
411
|
+
> {
|
|
412
|
+
/**
|
|
413
|
+
* Secondary hint rendered after the item label (e.g. "Latest").
|
|
414
|
+
* Rendered outside the item's text value, so it shows in the open list
|
|
415
|
+
* but never leaks into the trigger's selected-value rendering.
|
|
416
|
+
*/
|
|
417
|
+
hint?: React.ReactNode;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
function SelectItem({ className, children, hint, ...props }: SelectItemProps) {
|
|
411
421
|
const itemStyles = cn(
|
|
412
422
|
// Base layout
|
|
413
423
|
"relative flex w-full cursor-default select-none items-center gap-2",
|
|
@@ -441,6 +451,15 @@ function SelectItem({
|
|
|
441
451
|
</span>
|
|
442
452
|
|
|
443
453
|
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
|
454
|
+
|
|
455
|
+
{hint != null && (
|
|
456
|
+
<span
|
|
457
|
+
className="text-label-sm text-muted-foreground ml-auto"
|
|
458
|
+
data-slot="select-item-hint"
|
|
459
|
+
>
|
|
460
|
+
{hint}
|
|
461
|
+
</span>
|
|
462
|
+
)}
|
|
444
463
|
</SelectPrimitive.Item>
|
|
445
464
|
);
|
|
446
465
|
}
|
|
@@ -524,4 +543,9 @@ export {
|
|
|
524
543
|
SelectValue,
|
|
525
544
|
};
|
|
526
545
|
|
|
527
|
-
export type {
|
|
546
|
+
export type {
|
|
547
|
+
SelectContentProps,
|
|
548
|
+
SelectItemProps,
|
|
549
|
+
SelectProps,
|
|
550
|
+
SelectTriggerProps,
|
|
551
|
+
};
|
|
@@ -74,6 +74,15 @@ const typographyHeadingVariants = cva("", {
|
|
|
74
74
|
true: "tabular-nums",
|
|
75
75
|
false: "proportional-nums",
|
|
76
76
|
},
|
|
77
|
+
// Boolean on purpose (no `false` class): unlike tabular there is no
|
|
78
|
+
// inherited context to undo — either the element clips or it doesn't.
|
|
79
|
+
// `block` is load-bearing: an inline asChild child (e.g. a `span`) cannot
|
|
80
|
+
// clip — overflow does not apply to non-replaced inlines — so the variant
|
|
81
|
+
// forces a block container. A no-op on the default h1–h6 (already block)
|
|
82
|
+
// and on flex/grid items (blockified by the layout).
|
|
83
|
+
truncate: {
|
|
84
|
+
true: "block truncate",
|
|
85
|
+
},
|
|
77
86
|
},
|
|
78
87
|
defaultVariants: {
|
|
79
88
|
color: "default",
|
|
@@ -140,6 +149,19 @@ interface TypographyHeadingProps extends React.ComponentProps<"h1"> {
|
|
|
140
149
|
* TypographyText `metric` (plus `tabular` if it must align), not a heading.
|
|
141
150
|
*/
|
|
142
151
|
tabular?: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Clip overflowing text to a single line with an ellipsis — card titles in
|
|
154
|
+
* a fixed-width grid, panel headers beside actions; anywhere a title can
|
|
155
|
+
* outgrow its container. The surrounding layout must still allow the
|
|
156
|
+
* element to shrink: inside a flex row the element (or its wrapper) needs
|
|
157
|
+
* `min-w-0`, and in a grid column `minmax(0, …)` — otherwise the box grows
|
|
158
|
+
* instead of clipping. Forces `display: block` (an inline box cannot
|
|
159
|
+
* clip), so an inline `asChild` child becomes a block while truncating —
|
|
160
|
+
* a no-op on the default h1–h6. Single-line only by design; a multi-line
|
|
161
|
+
* clamp can follow if demand appears.
|
|
162
|
+
* @default false
|
|
163
|
+
*/
|
|
164
|
+
truncate?: boolean;
|
|
143
165
|
/**
|
|
144
166
|
* Render as a different element using Radix Slot pattern.
|
|
145
167
|
* When true, merges props onto the child element.
|
|
@@ -186,6 +208,7 @@ const TypographyHeading = React.forwardRef<
|
|
|
186
208
|
color = "default",
|
|
187
209
|
align,
|
|
188
210
|
tabular,
|
|
211
|
+
truncate = false,
|
|
189
212
|
asChild = false,
|
|
190
213
|
dataHook,
|
|
191
214
|
trackingEl,
|
|
@@ -205,6 +228,7 @@ const TypographyHeading = React.forwardRef<
|
|
|
205
228
|
color,
|
|
206
229
|
align,
|
|
207
230
|
tabular,
|
|
231
|
+
truncate,
|
|
208
232
|
}),
|
|
209
233
|
className
|
|
210
234
|
)}
|
|
@@ -67,6 +67,16 @@ const typographyTextVariants = cva("", {
|
|
|
67
67
|
center: "text-center",
|
|
68
68
|
right: "text-right",
|
|
69
69
|
},
|
|
70
|
+
// Boolean on purpose (no `false` class): unlike tabular there is no
|
|
71
|
+
// inherited context to undo — either the element clips or it doesn't.
|
|
72
|
+
// `block` is load-bearing: an inline box (the default `span` for metric,
|
|
73
|
+
// `code` for code, or an inline asChild child) cannot clip — overflow
|
|
74
|
+
// does not apply to non-replaced inlines — so the variant forces a block
|
|
75
|
+
// container. A no-op on the body variants (`p` is already block) and on
|
|
76
|
+
// flex/grid items (blockified by the layout).
|
|
77
|
+
truncate: {
|
|
78
|
+
true: "block truncate",
|
|
79
|
+
},
|
|
70
80
|
},
|
|
71
81
|
defaultVariants: {
|
|
72
82
|
variant: "body",
|
|
@@ -125,6 +135,20 @@ interface TypographyTextProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
125
135
|
* @example "center"
|
|
126
136
|
*/
|
|
127
137
|
align?: TypographyTextAlign;
|
|
138
|
+
/**
|
|
139
|
+
* Clip overflowing text to a single line with an ellipsis — table cells,
|
|
140
|
+
* list rows, dropdown options; anywhere text can outgrow its container.
|
|
141
|
+
* The surrounding layout must still allow the element to shrink: inside a
|
|
142
|
+
* flex row the element (or its wrapper) needs `min-w-0`, and in a grid
|
|
143
|
+
* column `minmax(0, …)` — otherwise the box grows instead of clipping.
|
|
144
|
+
* Forces `display: block` (an inline box cannot clip), so an inline
|
|
145
|
+
* default element (`metric`'s span, `code`'s code) or an inline `asChild`
|
|
146
|
+
* child becomes a block while truncating.
|
|
147
|
+
* Single-line only by design; a multi-line clamp can follow if demand
|
|
148
|
+
* appears.
|
|
149
|
+
* @default false
|
|
150
|
+
*/
|
|
151
|
+
truncate?: boolean;
|
|
128
152
|
/**
|
|
129
153
|
* Render as a different element using Radix Slot pattern.
|
|
130
154
|
* When true, merges props onto the child element.
|
|
@@ -176,6 +200,7 @@ const TypographyText = React.forwardRef<HTMLElement, TypographyTextProps>(
|
|
|
176
200
|
color = "default",
|
|
177
201
|
tabular,
|
|
178
202
|
align,
|
|
203
|
+
truncate = false,
|
|
179
204
|
asChild = false,
|
|
180
205
|
dataHook,
|
|
181
206
|
trackingEl,
|
|
@@ -202,7 +227,7 @@ const TypographyText = React.forwardRef<HTMLElement, TypographyTextProps>(
|
|
|
202
227
|
<Comp
|
|
203
228
|
ref={ref}
|
|
204
229
|
className={cn(
|
|
205
|
-
typographyTextVariants({ variant, color, tabular, align }),
|
|
230
|
+
typographyTextVariants({ variant, color, tabular, align, truncate }),
|
|
206
231
|
className
|
|
207
232
|
)}
|
|
208
233
|
data-hook={dataHook}
|
package/src/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from "./components/badge";
|
|
|
8
8
|
export * from "./components/brand-illustration-motif";
|
|
9
9
|
export * from "./components/breadcrumb";
|
|
10
10
|
export * from "./components/button";
|
|
11
|
+
export * from "./components/button-group";
|
|
11
12
|
export * from "./components/calendar";
|
|
12
13
|
export * from "./components/callout";
|
|
13
14
|
export * from "./components/card";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
|
|
3
|
+
/* -------------------------------------------------------------------------------------------------
|
|
4
|
+
* Empty chip (internal)
|
|
5
|
+
*
|
|
6
|
+
* The icon chip every "nothing here" moment shares — EmptyState at card
|
|
7
|
+
* scope, and CommandEmpty / ComboboxEmpty at popover scope. 40px of
|
|
8
|
+
* `bg-muted` around a 16px glyph. It lives once so the two cannot drift: the
|
|
9
|
+
* popover form used to be hand-rolled in consumer code with these classes
|
|
10
|
+
* copied in.
|
|
11
|
+
*
|
|
12
|
+
* A canvas drops the chip — but a canvas is a different component, so there
|
|
13
|
+
* is no variant for that here.
|
|
14
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
15
|
+
|
|
16
|
+
export const emptyChipStyles = cva(
|
|
17
|
+
"bg-muted text-muted-foreground flex size-10 items-center justify-center rounded-full",
|
|
18
|
+
{
|
|
19
|
+
variants: {
|
|
20
|
+
align: { center: "", left: "shrink-0" },
|
|
21
|
+
},
|
|
22
|
+
defaultVariants: { align: "center" },
|
|
23
|
+
}
|
|
24
|
+
);
|