@brightlocal/ui-components 3.4.0 → 3.5.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/AI_USAGE.md +22 -3
- package/README.md +177 -109
- package/component-meta.json +1061 -102
- package/dist/alert-dialog.cjs +1 -1
- package/dist/alert-dialog.d.ts +13 -2
- package/dist/alert-dialog.d.ts.map +1 -1
- package/dist/alert-dialog.js +4 -3
- package/dist/banner.cjs +1 -1
- package/dist/banner.d.ts +47 -11
- package/dist/banner.d.ts.map +1 -1
- package/dist/banner.js +156 -79
- package/dist/blocks/empty-state.cjs +1 -1
- package/dist/blocks/empty-state.d.ts +40 -5
- package/dist/blocks/empty-state.d.ts.map +1 -1
- package/dist/blocks/empty-state.js +59 -52
- package/dist/blocks/input-list.d.ts +1 -0
- package/dist/blocks/input-list.d.ts.map +1 -1
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +12 -6
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +64 -63
- package/dist/button.cjs +1 -1
- package/dist/button.d.ts.map +1 -1
- package/dist/button.js +47 -43
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +12 -0
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +115 -97
- package/dist/chart.cjs +6 -6
- package/dist/chart.d.ts +6 -10
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +281 -296
- package/dist/combobox.cjs +3 -3
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +430 -343
- package/dist/command.cjs +1 -1
- package/dist/command.d.ts +23 -2
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +212 -207
- package/dist/count-indicator.cjs +1 -0
- package/dist/count-indicator.d.ts +85 -0
- package/dist/count-indicator.d.ts.map +1 -0
- package/dist/count-indicator.js +72 -0
- package/dist/data-table.cjs +1 -1
- package/dist/data-table.d.ts +101 -11
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +593 -523
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.d.ts +26 -3
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +62 -47
- package/dist/drawer.cjs +1 -1
- package/dist/drawer.d.ts +8 -4
- package/dist/drawer.d.ts.map +1 -1
- package/dist/drawer.js +37 -38
- package/dist/file-upload.cjs +1 -0
- package/dist/file-upload.d.ts +546 -0
- package/dist/file-upload.d.ts.map +1 -0
- package/dist/file-upload.js +1103 -0
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +7 -2
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +52 -52
- package/dist/hooks/use-file-dropzone.cjs +1 -0
- package/dist/hooks/use-file-dropzone.d.ts +75 -0
- package/dist/hooks/use-file-dropzone.d.ts.map +1 -0
- package/dist/hooks/use-file-dropzone.js +133 -0
- package/dist/hover-card.cjs +1 -1
- package/dist/hover-card.d.ts +29 -16
- package/dist/hover-card.d.ts.map +1 -1
- package/dist/hover-card.js +153 -36
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +676 -640
- package/dist/input-chip.cjs +1 -1
- package/dist/input-chip.d.ts +30 -1
- package/dist/input-chip.d.ts.map +1 -1
- package/dist/input-chip.js +131 -115
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.d.ts +37 -2
- package/dist/input-group.d.ts.map +1 -1
- package/dist/input-group.js +131 -114
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.js +6 -6
- package/dist/lib/empty-canvas.cjs +1 -1
- package/dist/lib/empty-canvas.d.ts +27 -1
- package/dist/lib/empty-canvas.d.ts.map +1 -1
- package/dist/lib/empty-canvas.js +27 -23
- package/dist/lib/empty-chip.cjs +1 -1
- package/dist/lib/empty-chip.d.ts +19 -2
- package/dist/lib/empty-chip.d.ts.map +1 -1
- package/dist/lib/empty-chip.js +14 -9
- package/dist/lib/field-aria.cjs +1 -1
- package/dist/lib/field-aria.d.ts +4 -4
- package/dist/lib/field-aria.d.ts.map +1 -1
- package/dist/lib/field-aria.js +7 -5
- package/dist/lib/media-viewer-content.cjs +1 -1
- package/dist/lib/media-viewer-content.js +1 -1
- package/dist/lib/table-internal.cjs +1 -1
- package/dist/lib/table-internal.d.ts +19 -0
- package/dist/lib/table-internal.d.ts.map +1 -1
- package/dist/lib/table-internal.js +22 -7
- package/dist/list.cjs +1 -1
- package/dist/list.d.ts +13 -0
- package/dist/list.d.ts.map +1 -1
- package/dist/list.js +103 -82
- package/dist/logo-mark.cjs +1 -1
- package/dist/logo-mark.d.ts +18 -2
- package/dist/logo-mark.d.ts.map +1 -1
- package/dist/logo-mark.js +159 -79
- package/dist/media-empty.cjs +1 -1
- package/dist/media-empty.d.ts +50 -7
- package/dist/media-empty.d.ts.map +1 -1
- package/dist/media-empty.js +14 -13
- package/dist/media-viewer.cjs +1 -1
- package/dist/media-viewer.js +6 -6
- package/dist/multi-select-filter.cjs +1 -1
- package/dist/multi-select-filter.d.ts.map +1 -1
- package/dist/multi-select-filter.js +92 -101
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.d.ts +11 -0
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +17 -17
- package/dist/relative-date.d.ts +6 -0
- package/dist/relative-date.d.ts.map +1 -1
- package/dist/resizable.d.ts +1 -1
- package/dist/result-count.cjs +1 -1
- package/dist/result-count.d.ts +13 -16
- package/dist/result-count.d.ts.map +1 -1
- package/dist/result-count.js +24 -33
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +22 -3
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +152 -125
- package/dist/single-select-filter.cjs +1 -1
- package/dist/single-select-filter.d.ts.map +1 -1
- package/dist/single-select-filter.js +67 -76
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +77 -76
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.d.ts +39 -3
- package/dist/tabs.d.ts.map +1 -1
- package/dist/tabs.js +127 -76
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.d.ts +34 -0
- package/dist/textarea.d.ts.map +1 -1
- package/dist/textarea.js +115 -19
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.d.ts.map +1 -1
- package/dist/tooltip.js +137 -131
- package/dist/typography-text.cjs +1 -1
- package/dist/typography-text.d.ts +6 -2
- package/dist/typography-text.d.ts.map +1 -1
- package/dist/typography-text.js +14 -13
- package/package.json +3 -4
- package/src/blocks/empty-state.tsx +108 -48
- package/src/blocks/input-list.tsx +1 -0
- package/src/blocks/sidebar.tsx +39 -16
- package/src/components/alert-dialog.tsx +18 -2
- package/src/components/banner.tsx +247 -68
- package/src/components/button.tsx +27 -10
- package/src/components/card.tsx +89 -7
- package/src/components/chart.tsx +47 -67
- package/src/components/combobox.tsx +221 -12
- package/src/components/command.tsx +83 -37
- package/src/components/count-indicator.tsx +188 -0
- package/src/components/data-table.tsx +506 -159
- package/src/components/dialog.tsx +74 -5
- package/src/components/drawer.tsx +52 -32
- package/src/components/file-upload.tsx +2574 -0
- package/src/components/global-layout.tsx +18 -5
- package/src/components/hover-card.tsx +395 -65
- package/src/components/input-chip.tsx +67 -2
- package/src/components/input-group.tsx +89 -6
- package/src/components/list.tsx +40 -3
- package/src/components/logo-mark.tsx +109 -25
- package/src/components/media-empty.tsx +62 -7
- package/src/components/multi-select-filter.tsx +9 -16
- package/src/components/pagination.tsx +15 -2
- package/src/components/relative-date.tsx +6 -0
- package/src/components/result-count.tsx +27 -54
- package/src/components/sheet.tsx +86 -8
- package/src/components/single-select-filter.tsx +9 -16
- package/src/components/table.tsx +16 -1
- package/src/components/tabs.tsx +223 -41
- package/src/components/textarea.tsx +271 -4
- package/src/components/tooltip.tsx +29 -2
- package/src/components/typography-text.tsx +7 -2
- package/src/hooks/use-file-dropzone.ts +325 -0
- package/src/index.ts +3 -0
- package/src/lib/empty-canvas.tsx +47 -20
- package/src/lib/empty-chip.tsx +38 -3
- package/src/lib/field-aria.tsx +11 -6
- package/src/lib/table-internal.ts +38 -0
package/dist/tabs.d.ts
CHANGED
|
@@ -6,6 +6,17 @@ import * as TabsPrimitive from "@radix-ui/react-tabs";
|
|
|
6
6
|
* - `underline` — border-bottom tabs with an active primary underline
|
|
7
7
|
*/
|
|
8
8
|
type TabsVariant = "default" | "underline";
|
|
9
|
+
/**
|
|
10
|
+
* Horizontal alignment of triggers inside the tab list.
|
|
11
|
+
* - `"start"` — triggers sit at the left edge (default for underline)
|
|
12
|
+
* - `"center"` — triggers are centred; falls back to start on overflow
|
|
13
|
+
* (default for pill)
|
|
14
|
+
*
|
|
15
|
+
* @deprecated No consumer uses this — the variant-aware defaults cover every
|
|
16
|
+
* real case. Will be removed in a future major. Use `className="justify-center"`
|
|
17
|
+
* if you need to override.
|
|
18
|
+
*/
|
|
19
|
+
type TabsListAlign = "start" | "center";
|
|
9
20
|
/**
|
|
10
21
|
* Props for the Tabs component.
|
|
11
22
|
* Generic over the tab value type for type-safe `value` and `onValueChange`.
|
|
@@ -23,9 +34,18 @@ interface TabsProps<T extends string = string> extends Omit<React.ComponentProps
|
|
|
23
34
|
* @default "default"
|
|
24
35
|
*/
|
|
25
36
|
variant?: TabsVariant;
|
|
26
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Only mount a panel when its tab is first activated; once visited it stays
|
|
39
|
+
* mounted (hidden while inactive) unless `unmountOnExit` is also set.
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
27
42
|
lazyMount?: boolean;
|
|
28
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Unmount a panel's content when its tab becomes inactive. Off by default:
|
|
45
|
+
* inactive panels stay mounted and hidden, so form edits, scroll position
|
|
46
|
+
* and other local state survive a tab switch.
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
29
49
|
unmountOnExit?: boolean;
|
|
30
50
|
/** The controlled value of the active tab */
|
|
31
51
|
value?: T;
|
|
@@ -45,6 +65,22 @@ interface TabsListProps extends React.ComponentProps<typeof TabsPrimitive.List>
|
|
|
45
65
|
trackingEl?: string;
|
|
46
66
|
/** Tracking label for analytics context */
|
|
47
67
|
trackingLabel?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Horizontal alignment of triggers inside the list.
|
|
70
|
+
* Defaults to `"start"` for the underline variant and `"center"` for the
|
|
71
|
+
* pill variant.
|
|
72
|
+
*
|
|
73
|
+
* @deprecated No consumer uses this — the variant-aware defaults cover every
|
|
74
|
+
* real case. Will be removed in a future major. Use `className` if you need
|
|
75
|
+
* to override alignment.
|
|
76
|
+
*/
|
|
77
|
+
align?: TabsListAlign;
|
|
78
|
+
/**
|
|
79
|
+
* Stretch the list to its container and give every trigger an equal share
|
|
80
|
+
* of the width. Long labels wrap inside their trigger; they never truncate.
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
|
+
fullWidth?: boolean;
|
|
48
84
|
}
|
|
49
85
|
declare const TabsList: React.ForwardRefExoticComponent<Omit<TabsListProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
50
86
|
/**
|
|
@@ -80,5 +116,5 @@ interface TabsContentProps<T extends string = string> extends Omit<React.Compone
|
|
|
80
116
|
}
|
|
81
117
|
declare const TabsContent: <T extends string = string>(props: TabsContentProps<T> & React.RefAttributes<React.ComponentRef<typeof TabsPrimitive.Content>>) => React.ReactElement | null;
|
|
82
118
|
export { Tabs, TabsList, TabsTrigger, TabsContent };
|
|
83
|
-
export type { TabsProps, TabsListProps, TabsTriggerProps, TabsContentProps, TabsVariant, };
|
|
119
|
+
export type { TabsProps, TabsListProps, TabsListAlign, TabsTriggerProps, TabsContentProps, TabsVariant, };
|
|
84
120
|
//# sourceMappingURL=tabs.d.ts.map
|
package/dist/tabs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../src/components/tabs.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAA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ChE,KAAK,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,OAAO,CAAC,EAClD,OAAO,CACR;IACC,sCAAsC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kEAAkE;IAClE,KAAK,EAAE,CAAC,CAAC;CACV;AA+CD,QAAA,MAAM,WAAW,EAAyC,CACxD,CAAC,SAAS,MAAM,GAAG,MAAM,EAEzB,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,GACxB,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,aAAa,CAAC,OAAO,CAAC,CAAC,KACpE,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;AAI/B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;AAEpD,YAAY,EACV,SAAS,EACT,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,GACZ,CAAC"}
|
package/dist/tabs.js
CHANGED
|
@@ -1,26 +1,48 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import * as t from "react";
|
|
3
|
-
import { cn as
|
|
4
|
-
import { jsx as
|
|
5
|
-
import { cva as
|
|
6
|
-
import * as
|
|
7
|
-
var
|
|
3
|
+
import { cn as p } from "@brightlocal/ui-components/lib/utils";
|
|
4
|
+
import { jsx as w } from "react/jsx-runtime";
|
|
5
|
+
import { cva as y } from "class-variance-authority";
|
|
6
|
+
import * as m from "@radix-ui/react-tabs";
|
|
7
|
+
var x = t.createContext({
|
|
8
8
|
lazyMount: !1,
|
|
9
9
|
unmountOnExit: !1,
|
|
10
10
|
activeValue: void 0,
|
|
11
11
|
visitedTabs: /* @__PURE__ */ new Set(),
|
|
12
12
|
variant: "default"
|
|
13
|
-
}),
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
}), R = y([
|
|
14
|
+
"inline-flex max-w-full items-center",
|
|
15
|
+
"overscroll-x-contain [scrollbar-width:none]",
|
|
16
|
+
"data-overflowing:overflow-x-auto data-overflowing:overflow-y-hidden"
|
|
17
|
+
], {
|
|
18
|
+
variants: {
|
|
19
|
+
variant: {
|
|
20
|
+
default: "h-9 w-fit bg-muted rounded-lg p-1",
|
|
21
|
+
underline: "w-full gap-1 rounded-none shadow-[inset_0_-1px_0_var(--border)]"
|
|
22
|
+
},
|
|
23
|
+
align: {
|
|
24
|
+
start: "justify-start",
|
|
25
|
+
center: "justify-center-safe"
|
|
26
|
+
},
|
|
27
|
+
fullWidth: {
|
|
28
|
+
true: ["flex w-full items-stretch", "*:min-w-0 *:flex-1 *:basis-0 *:whitespace-normal *:wrap-anywhere *:text-center"],
|
|
29
|
+
false: ""
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
compoundVariants: [{
|
|
33
|
+
variant: "default",
|
|
34
|
+
fullWidth: !0,
|
|
35
|
+
className: "h-auto min-h-9 py-0.5"
|
|
36
|
+
}],
|
|
37
|
+
defaultVariants: {
|
|
38
|
+
variant: "default",
|
|
39
|
+
fullWidth: !1
|
|
40
|
+
}
|
|
41
|
+
}), L = y([
|
|
20
42
|
"inline-flex items-center justify-center gap-2",
|
|
21
43
|
"text-label whitespace-nowrap",
|
|
22
44
|
"cursor-pointer",
|
|
23
|
-
"
|
|
45
|
+
"outline-none",
|
|
24
46
|
"disabled:pointer-events-none disabled:opacity-50"
|
|
25
47
|
], {
|
|
26
48
|
variants: { variant: {
|
|
@@ -36,100 +58,129 @@ var m = t.createContext({
|
|
|
36
58
|
"dark:data-[state=active]:border-white/15 dark:data-[state=active]:bg-white/5"
|
|
37
59
|
],
|
|
38
60
|
underline: [
|
|
39
|
-
"
|
|
61
|
+
"px-3 py-1.5",
|
|
40
62
|
"rounded-none border-b-2 border-transparent bg-transparent",
|
|
41
63
|
"first:rounded-l-none last:rounded-r-none",
|
|
42
64
|
"text-muted-foreground hover:bg-transparent hover:text-foreground",
|
|
43
65
|
"data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:text-foreground",
|
|
44
66
|
"transition-[color,border-color,box-shadow] duration-fast ease-out",
|
|
45
|
-
"focus-visible:rounded-md focus-visible:shadow-default"
|
|
67
|
+
"focus-visible:rounded-md focus-visible:shadow-default",
|
|
68
|
+
"[&:focus:not(:focus-visible)]:shadow-none",
|
|
69
|
+
"[&[data-pointer-focus]:focus-visible]:shadow-none [&[data-pointer-focus]:focus-visible]:rounded-none"
|
|
46
70
|
]
|
|
47
71
|
} },
|
|
48
72
|
defaultVariants: { variant: "default" }
|
|
49
73
|
});
|
|
50
|
-
function
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
activeValue: l,
|
|
61
|
-
visitedTabs: k,
|
|
74
|
+
function S({ className: a, dataHook: d, trackingEl: u, trackingLabel: i, variant: e = "default", lazyMount: r = !1, unmountOnExit: s = !1, value: n, defaultValue: l, onValueChange: c, ...v }, o) {
|
|
75
|
+
const b = r || s, [T, g] = t.useState(l), f = n ?? T, [h, C] = t.useState(() => new Set(f != null ? [f] : []));
|
|
76
|
+
r && f != null && !h.has(f) && C(new Set(h).add(f));
|
|
77
|
+
const V = t.useCallback((k) => {
|
|
78
|
+
g(k), c?.(k);
|
|
79
|
+
}, [c]), N = t.useMemo(() => ({
|
|
80
|
+
lazyMount: r,
|
|
81
|
+
unmountOnExit: s,
|
|
82
|
+
activeValue: f,
|
|
83
|
+
visitedTabs: h,
|
|
62
84
|
variant: e
|
|
63
85
|
}), [
|
|
64
|
-
a,
|
|
65
86
|
r,
|
|
66
|
-
|
|
67
|
-
|
|
87
|
+
s,
|
|
88
|
+
f,
|
|
89
|
+
h,
|
|
68
90
|
e
|
|
69
91
|
]);
|
|
70
|
-
return /* @__PURE__ */
|
|
71
|
-
value:
|
|
72
|
-
children: /* @__PURE__ */
|
|
73
|
-
ref:
|
|
74
|
-
className:
|
|
75
|
-
"data-hook":
|
|
92
|
+
return /* @__PURE__ */ w(x.Provider, {
|
|
93
|
+
value: N,
|
|
94
|
+
children: /* @__PURE__ */ w(m.Root, {
|
|
95
|
+
ref: o,
|
|
96
|
+
className: p("flex max-w-full min-w-0 flex-col", e === "underline" ? "gap-6" : "gap-2", a),
|
|
97
|
+
"data-hook": d,
|
|
76
98
|
"data-slot": "tabs",
|
|
77
|
-
"data-tracking-el":
|
|
99
|
+
"data-tracking-el": u,
|
|
78
100
|
"data-tracking-label": i,
|
|
79
|
-
defaultValue:
|
|
80
|
-
value:
|
|
81
|
-
onValueChange:
|
|
82
|
-
...
|
|
101
|
+
defaultValue: b ? void 0 : l,
|
|
102
|
+
value: b ? f : n,
|
|
103
|
+
onValueChange: b ? V : c,
|
|
104
|
+
...v
|
|
83
105
|
})
|
|
84
106
|
});
|
|
85
107
|
}
|
|
86
|
-
var
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
return
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
108
|
+
var A = t.forwardRef(S);
|
|
109
|
+
A.displayName = "Tabs";
|
|
110
|
+
function O(a) {
|
|
111
|
+
const [d, u] = t.useState(!1);
|
|
112
|
+
return t.useLayoutEffect(() => {
|
|
113
|
+
if (!a || typeof ResizeObserver > "u") return;
|
|
114
|
+
const i = () => u(a.scrollWidth > a.clientWidth + 1), e = new ResizeObserver(i), r = () => {
|
|
115
|
+
e.disconnect(), e.observe(a);
|
|
116
|
+
for (const n of Array.from(a.children)) e.observe(n);
|
|
117
|
+
}, s = new MutationObserver(() => {
|
|
118
|
+
r(), i();
|
|
119
|
+
});
|
|
120
|
+
return r(), s.observe(a, { childList: !0 }), i(), () => {
|
|
121
|
+
e.disconnect(), s.disconnect();
|
|
122
|
+
};
|
|
123
|
+
}, [a]), d;
|
|
124
|
+
}
|
|
125
|
+
var W = t.forwardRef(({ className: a, dataHook: d, trackingEl: u, trackingLabel: i, align: e, fullWidth: r = !1, ...s }, n) => {
|
|
126
|
+
const { variant: l } = t.useContext(x), c = e ?? (l === "underline" ? "start" : "center"), [v, o] = t.useState(null), b = O(v), T = t.useCallback((g) => {
|
|
127
|
+
o(g), typeof n == "function" ? n(g) : n && (n.current = g);
|
|
128
|
+
}, [n]);
|
|
129
|
+
return /* @__PURE__ */ w(m.List, {
|
|
130
|
+
ref: T,
|
|
131
|
+
className: p(R({
|
|
132
|
+
variant: l,
|
|
133
|
+
align: c,
|
|
134
|
+
fullWidth: r
|
|
135
|
+
}), a),
|
|
136
|
+
"data-hook": d,
|
|
137
|
+
"data-overflowing": b ? "" : void 0,
|
|
94
138
|
"data-slot": "tabs-list",
|
|
95
|
-
"data-tracking-el":
|
|
139
|
+
"data-tracking-el": u,
|
|
96
140
|
"data-tracking-label": i,
|
|
97
|
-
...
|
|
141
|
+
...s
|
|
98
142
|
});
|
|
99
143
|
});
|
|
100
|
-
|
|
101
|
-
function
|
|
102
|
-
const { variant:
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
144
|
+
W.displayName = "TabsList";
|
|
145
|
+
function j({ className: a, dataHook: d, trackingEl: u, trackingLabel: i, onPointerDown: e, onBlur: r, ...s }, n) {
|
|
146
|
+
const { variant: l } = t.useContext(x), c = t.useCallback((o) => {
|
|
147
|
+
o.currentTarget.setAttribute("data-pointer-focus", ""), e?.(o);
|
|
148
|
+
}, [e]), v = t.useCallback((o) => {
|
|
149
|
+
o.currentTarget.removeAttribute("data-pointer-focus"), r?.(o);
|
|
150
|
+
}, [r]);
|
|
151
|
+
return /* @__PURE__ */ w(m.Trigger, {
|
|
152
|
+
ref: n,
|
|
153
|
+
className: p(L({ variant: l }), a),
|
|
154
|
+
"data-hook": d,
|
|
107
155
|
"data-slot": "tabs-trigger",
|
|
108
|
-
"data-tracking-el":
|
|
156
|
+
"data-tracking-el": u,
|
|
109
157
|
"data-tracking-label": i,
|
|
110
|
-
|
|
158
|
+
onBlur: v,
|
|
159
|
+
onPointerDown: c,
|
|
160
|
+
...s
|
|
111
161
|
});
|
|
112
162
|
}
|
|
113
|
-
var
|
|
114
|
-
|
|
115
|
-
function
|
|
116
|
-
const { lazyMount:
|
|
117
|
-
return
|
|
118
|
-
ref:
|
|
119
|
-
className:
|
|
120
|
-
"data-hook":
|
|
163
|
+
var I = t.forwardRef(j);
|
|
164
|
+
I.displayName = "TabsTrigger";
|
|
165
|
+
function _({ className: a, dataHook: d, trackingEl: u, trackingLabel: i, value: e, ...r }, s) {
|
|
166
|
+
const { lazyMount: n, unmountOnExit: l, activeValue: c, visitedTabs: v } = t.useContext(x), o = e === c;
|
|
167
|
+
return n && !o && !v.has(e) || l && !o ? null : /* @__PURE__ */ w(m.Content, {
|
|
168
|
+
ref: s,
|
|
169
|
+
className: p("flex-1 outline-none data-[state=inactive]:hidden", a),
|
|
170
|
+
"data-hook": d,
|
|
121
171
|
"data-slot": "tabs-content",
|
|
122
|
-
"data-tracking-el":
|
|
172
|
+
"data-tracking-el": u,
|
|
123
173
|
"data-tracking-label": i,
|
|
174
|
+
forceMount: l ? void 0 : !0,
|
|
124
175
|
value: e,
|
|
125
|
-
...
|
|
176
|
+
...r
|
|
126
177
|
});
|
|
127
178
|
}
|
|
128
|
-
var
|
|
129
|
-
|
|
179
|
+
var z = t.forwardRef(_);
|
|
180
|
+
z.displayName = "TabsContent";
|
|
130
181
|
export {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
182
|
+
A as Tabs,
|
|
183
|
+
z as TabsContent,
|
|
184
|
+
W as TabsList,
|
|
185
|
+
I as TabsTrigger
|
|
135
186
|
};
|
package/dist/textarea.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";const
|
|
1
|
+
"use client";const z=require("./_virtual/_rolldown/runtime.cjs"),G=require("./lib/field-aria.cjs"),J=require("./count-indicator.cjs");let r=require("react");r=z.__toESM(r,1);let K=require("@brightlocal/ui-components/lib/utils"),q=require("react/jsx-runtime"),P=require("class-variance-authority");var Q=(0,P.cva)(["flex w-full","border border-input bg-background rounded-sm","outline-none transition-[border-color,background-color,box-shadow] duration-fast ease-out","text-field","text-foreground","px-3 py-2","focus-visible:outline-none focus-visible:border-ring focus-visible:bg-background","focus-visible:shadow-default","disabled:cursor-not-allowed disabled:opacity-50","placeholder:text-muted-foreground"]);function U(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("field-sizing","content")}function C(i){return i===void 0?"":typeof i=="number"?`${i}px`:i}function X(i,f,x,h){const o=window.getComputedStyle(i),n=parseFloat(o.fontSize)||16,l=parseFloat(o.lineHeight)||n*1.2,b=(parseFloat(o.paddingTop)||0)+(parseFloat(o.paddingBottom)||0)+(parseFloat(o.borderTopWidth)||0)+(parseFloat(o.borderBottomWidth)||0),g=f*l+b,y=Math.max(x,f)*l+b;if(i.style.minHeight=`${g}px`,i.style.maxHeight=`${y}px`,h){i.style.height="";return}i.style.height=`${g}px`;const S=(parseFloat(o.borderTopWidth)||0)+(parseFloat(o.borderBottomWidth)||0),_=Math.min(Math.max(i.scrollHeight+S,g),y);i.style.height=`${_}px`}var M=r.forwardRef(({className:i,dataHook:f,error:x,limit:h,countLabels:o,autosize:n=!1,minRows:l=3,maxRows:b=10,rows:g,onInput:y,trackingEl:S,trackingLabel:_,"aria-describedby":$,onChange:j,...s},a)=>{const E=r.useId(),d=h!==void 0,p=s.value!==void 0,[A,k]=r.useState(()=>String(s.defaultValue??"").length),L=p?String(s.value).length:A,I=d&&L>h,N=e=>{p||k(e.target.value.length),j?.(e)},w=x||s["aria-invalid"]===!0||s["aria-invalid"]==="true",H=G.useFieldDescribedBy($),W=d?[...new Set([...H?.split(/\s+/).filter(Boolean)??[],E])].join(" "):H,c=r.useRef(null),O=r.useCallback(e=>{c.current=e;let t;return typeof a=="function"?t=a(e):a&&(a.current=e),()=>{c.current=null,typeof t=="function"?t():typeof a=="function"?a(null):a&&(a.current=null)}},[a]),[v,D]=r.useState(!1),u=r.useCallback(()=>{const e=c.current;!n||!e||X(e,l,b,v)},[n,l,b,v]);r.useLayoutEffect(()=>{n&&D(U())},[n]),r.useLayoutEffect(()=>{u()},[u,s.value]);const F=r.useRef(!1),B=r.useRef(s.style);B.current=s.style,r.useLayoutEffect(()=>{const e=c.current;if(n){F.current=!0;return}if(!e||!F.current)return;F.current=!1;const t=B.current;e.style.minHeight=C(t?.minHeight),e.style.maxHeight=C(t?.maxHeight),e.style.height=C(t?.height)},[n]),r.useEffect(()=>{const e=c.current?.form;if(!n||v||!e)return;let t=0;const m=()=>{cancelAnimationFrame(t),t=requestAnimationFrame(u)};return e.addEventListener("reset",m),()=>{cancelAnimationFrame(t),e.removeEventListener("reset",m)}},[n,v,u]),r.useEffect(()=>{const e=c.current?.form;if(!e||p||!d)return;const t=()=>queueMicrotask(()=>k(c.current?.value.length??0));return e.addEventListener("reset",t),()=>e.removeEventListener("reset",t)},[p,d]),r.useEffect(()=>{const e=c.current;if(!n||!e||typeof ResizeObserver>"u")return;let t=e.getBoundingClientRect().width;const m=new ResizeObserver(([V])=>{const T=V?.contentRect.width??t;T!==t&&(t=T,u())});return m.observe(e),()=>m.disconnect()},[n,u]);const R=(0,q.jsx)("textarea",{ref:O,"aria-describedby":W,"aria-invalid":w?"true":void 0,className:(0,K.cn)(Q(),n&&"field-sizing-content resize-none overflow-y-auto",w&&"border-destructive-40 focus-visible:border-destructive-40 focus-visible:shadow-destructive scroll-mb-16",!w&&I&&"border-destructive-40 focus-visible:border-destructive-40 focus-visible:shadow-destructive",d&&"pb-6",i),"data-hook":f,"data-slot":"textarea","data-tracking-el":S,"data-tracking-label":_,rows:n?l:g,...s,onChange:N,onInput:e=>{y?.(e),n&&!v&&(u(),queueMicrotask(u))}});return d?(0,q.jsxs)("div",{className:"relative w-full","data-slot":"textarea-wrapper",children:[R,(0,q.jsx)(J.CountIndicator,{className:"bg-background pointer-events-none absolute right-[9px] bottom-1.5 rounded-sm px-1",count:L,dataHook:`${f}-count`,id:E,labels:o,limit:h})]}):R});M.displayName="Textarea";exports.Textarea=M;
|
package/dist/textarea.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CountIndicatorLabels } from './count-indicator';
|
|
1
2
|
import * as React from "react";
|
|
2
3
|
interface TextareaProps extends Omit<React.ComponentProps<"textarea">, "dataHook" | "id"> {
|
|
3
4
|
/**
|
|
@@ -12,6 +13,39 @@ interface TextareaProps extends Omit<React.ComponentProps<"textarea">, "dataHook
|
|
|
12
13
|
* Whether the textarea has an error state
|
|
13
14
|
*/
|
|
14
15
|
error?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Shows a count such as `120 / 750` inside the field, bottom right. It
|
|
18
|
+
* counts characters and never blocks typing: over the limit the count turns
|
|
19
|
+
* red and the border takes the error colour. Show the error message and stop
|
|
20
|
+
* the save yourself. Pass a controlled `value` so the count stays in step.
|
|
21
|
+
*/
|
|
22
|
+
limit?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Screen reader copy for the count. Pass translations here; omitted entries
|
|
25
|
+
* use English. Only used with `limit`.
|
|
26
|
+
*/
|
|
27
|
+
countLabels?: Partial<CountIndicatorLabels>;
|
|
28
|
+
/**
|
|
29
|
+
* Grow the textarea with its content, from `minRows` up to `maxRows`, then
|
|
30
|
+
* scroll. Uses CSS `field-sizing: content` where the browser supports it and
|
|
31
|
+
* measures on input elsewhere. Works with controlled and uncontrolled values
|
|
32
|
+
* and follows width changes. Turns off the manual resize handle; `rows` is
|
|
33
|
+
* ignored (use `minRows`). While on, it owns the inline `height`,
|
|
34
|
+
* `minHeight` and `maxHeight`; switching it off restores those from `style`.
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
autosize?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Smallest height in text lines when `autosize` is on.
|
|
40
|
+
* @default 3
|
|
41
|
+
*/
|
|
42
|
+
minRows?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Largest height in text lines when `autosize` is on; longer content
|
|
45
|
+
* scrolls. Never less than `minRows`.
|
|
46
|
+
* @default 10
|
|
47
|
+
*/
|
|
48
|
+
maxRows?: number;
|
|
15
49
|
/**
|
|
16
50
|
* Optional tracking prop for analytics tracking element identifier
|
|
17
51
|
*/
|
package/dist/textarea.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textarea.d.ts","sourceRoot":"","sources":["../../src/components/textarea.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"textarea.d.ts","sourceRoot":"","sources":["../../src/components/textarea.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAkB,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAkF9E,UAAU,aAAc,SAAQ,IAAI,CAClC,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,EAChC,UAAU,GAAG,IAAI,CAClB;IACC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC5C;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,QAAA,MAAM,QAAQ,wGAyNb,CAAC;AAIF,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,YAAY,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/textarea.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useFieldDescribedBy as
|
|
2
|
+
import { useFieldDescribedBy as z } from "./lib/field-aria.js";
|
|
3
|
+
import { CountIndicator as G } from "./count-indicator.js";
|
|
3
4
|
import * as n from "react";
|
|
4
|
-
import { cn as
|
|
5
|
-
import { jsx as
|
|
6
|
-
import { cva as
|
|
7
|
-
var
|
|
5
|
+
import { cn as J } from "@brightlocal/ui-components/lib/utils";
|
|
6
|
+
import { jsx as A, jsxs as K } from "react/jsx-runtime";
|
|
7
|
+
import { cva as P } from "class-variance-authority";
|
|
8
|
+
var Q = P([
|
|
8
9
|
"flex w-full",
|
|
9
|
-
"border border-input bg-background rounded-
|
|
10
|
+
"border border-input bg-background rounded-sm",
|
|
10
11
|
"outline-none transition-[border-color,background-color,box-shadow] duration-fast ease-out",
|
|
11
12
|
"text-field",
|
|
12
13
|
"text-foreground",
|
|
@@ -15,21 +16,116 @@ var m = v([
|
|
|
15
16
|
"focus-visible:shadow-default",
|
|
16
17
|
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
17
18
|
"placeholder:text-muted-foreground"
|
|
18
|
-
])
|
|
19
|
-
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
]);
|
|
20
|
+
function U() {
|
|
21
|
+
return typeof CSS < "u" && typeof CSS.supports == "function" && CSS.supports("field-sizing", "content");
|
|
22
|
+
}
|
|
23
|
+
function k(o) {
|
|
24
|
+
return o === void 0 ? "" : typeof o == "number" ? `${o}px` : o;
|
|
25
|
+
}
|
|
26
|
+
function X(o, f, x, h) {
|
|
27
|
+
const s = window.getComputedStyle(o), r = parseFloat(s.fontSize) || 16, u = parseFloat(s.lineHeight) || r * 1.2, b = (parseFloat(s.paddingTop) || 0) + (parseFloat(s.paddingBottom) || 0) + (parseFloat(s.borderTopWidth) || 0) + (parseFloat(s.borderBottomWidth) || 0), g = f * u + b, v = Math.max(x, f) * u + b;
|
|
28
|
+
if (o.style.minHeight = `${g}px`, o.style.maxHeight = `${v}px`, h) {
|
|
29
|
+
o.style.height = "";
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
o.style.height = `${g}px`;
|
|
33
|
+
const S = (parseFloat(s.borderTopWidth) || 0) + (parseFloat(s.borderBottomWidth) || 0), w = Math.min(Math.max(o.scrollHeight + S, g), v);
|
|
34
|
+
o.style.height = `${w}px`;
|
|
35
|
+
}
|
|
36
|
+
var Y = n.forwardRef(({ className: o, dataHook: f, error: x, limit: h, countLabels: s, autosize: r = !1, minRows: u = 3, maxRows: b = 10, rows: g, onInput: v, trackingEl: S, trackingLabel: w, "aria-describedby": M, onChange: I, ...i }, a) => {
|
|
37
|
+
const E = n.useId(), d = h !== void 0, y = i.value !== void 0, [N, L] = n.useState(() => String(i.defaultValue ?? "").length), H = y ? String(i.value).length : N, W = d && H > h, j = (e) => {
|
|
38
|
+
y || L(e.target.value.length), I?.(e);
|
|
39
|
+
}, F = x || i["aria-invalid"] === !0 || i["aria-invalid"] === "true", R = z(M), q = d ? [.../* @__PURE__ */ new Set([...R?.split(/\s+/).filter(Boolean) ?? [], E])].join(" ") : R, c = n.useRef(null), O = n.useCallback((e) => {
|
|
40
|
+
c.current = e;
|
|
41
|
+
let t;
|
|
42
|
+
return typeof a == "function" ? t = a(e) : a && (a.current = e), () => {
|
|
43
|
+
c.current = null, typeof t == "function" ? t() : typeof a == "function" ? a(null) : a && (a.current = null);
|
|
44
|
+
};
|
|
45
|
+
}, [a]), [m, D] = n.useState(!1), l = n.useCallback(() => {
|
|
46
|
+
const e = c.current;
|
|
47
|
+
!r || !e || X(e, u, b, m);
|
|
48
|
+
}, [
|
|
49
|
+
r,
|
|
50
|
+
u,
|
|
51
|
+
b,
|
|
52
|
+
m
|
|
53
|
+
]);
|
|
54
|
+
n.useLayoutEffect(() => {
|
|
55
|
+
r && D(U());
|
|
56
|
+
}, [r]), n.useLayoutEffect(() => {
|
|
57
|
+
l();
|
|
58
|
+
}, [l, i.value]);
|
|
59
|
+
const C = n.useRef(!1), B = n.useRef(i.style);
|
|
60
|
+
B.current = i.style, n.useLayoutEffect(() => {
|
|
61
|
+
const e = c.current;
|
|
62
|
+
if (r) {
|
|
63
|
+
C.current = !0;
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (!e || !C.current) return;
|
|
67
|
+
C.current = !1;
|
|
68
|
+
const t = B.current;
|
|
69
|
+
e.style.minHeight = k(t?.minHeight), e.style.maxHeight = k(t?.maxHeight), e.style.height = k(t?.height);
|
|
70
|
+
}, [r]), n.useEffect(() => {
|
|
71
|
+
const e = c.current?.form;
|
|
72
|
+
if (!r || m || !e) return;
|
|
73
|
+
let t = 0;
|
|
74
|
+
const p = () => {
|
|
75
|
+
cancelAnimationFrame(t), t = requestAnimationFrame(l);
|
|
76
|
+
};
|
|
77
|
+
return e.addEventListener("reset", p), () => {
|
|
78
|
+
cancelAnimationFrame(t), e.removeEventListener("reset", p);
|
|
79
|
+
};
|
|
80
|
+
}, [
|
|
81
|
+
r,
|
|
82
|
+
m,
|
|
83
|
+
l
|
|
84
|
+
]), n.useEffect(() => {
|
|
85
|
+
const e = c.current?.form;
|
|
86
|
+
if (!e || y || !d) return;
|
|
87
|
+
const t = () => queueMicrotask(() => L(c.current?.value.length ?? 0));
|
|
88
|
+
return e.addEventListener("reset", t), () => e.removeEventListener("reset", t);
|
|
89
|
+
}, [y, d]), n.useEffect(() => {
|
|
90
|
+
const e = c.current;
|
|
91
|
+
if (!r || !e || typeof ResizeObserver > "u") return;
|
|
92
|
+
let t = e.getBoundingClientRect().width;
|
|
93
|
+
const p = new ResizeObserver(([V]) => {
|
|
94
|
+
const $ = V?.contentRect.width ?? t;
|
|
95
|
+
$ !== t && (t = $, l());
|
|
96
|
+
});
|
|
97
|
+
return p.observe(e), () => p.disconnect();
|
|
98
|
+
}, [r, l]);
|
|
99
|
+
const T = /* @__PURE__ */ A("textarea", {
|
|
100
|
+
ref: O,
|
|
101
|
+
"aria-describedby": q,
|
|
102
|
+
"aria-invalid": F ? "true" : void 0,
|
|
103
|
+
className: J(Q(), r && "field-sizing-content resize-none overflow-y-auto", F && "border-destructive-40 focus-visible:border-destructive-40 focus-visible:shadow-destructive scroll-mb-16", !F && W && "border-destructive-40 focus-visible:border-destructive-40 focus-visible:shadow-destructive", d && "pb-6", o),
|
|
104
|
+
"data-hook": f,
|
|
26
105
|
"data-slot": "textarea",
|
|
27
|
-
"data-tracking-el":
|
|
28
|
-
"data-tracking-label":
|
|
29
|
-
|
|
106
|
+
"data-tracking-el": S,
|
|
107
|
+
"data-tracking-label": w,
|
|
108
|
+
rows: r ? u : g,
|
|
109
|
+
...i,
|
|
110
|
+
onChange: j,
|
|
111
|
+
onInput: (e) => {
|
|
112
|
+
v?.(e), r && !m && (l(), queueMicrotask(l));
|
|
113
|
+
}
|
|
30
114
|
});
|
|
115
|
+
return d ? /* @__PURE__ */ K("div", {
|
|
116
|
+
className: "relative w-full",
|
|
117
|
+
"data-slot": "textarea-wrapper",
|
|
118
|
+
children: [T, /* @__PURE__ */ A(G, {
|
|
119
|
+
className: "bg-background pointer-events-none absolute right-[9px] bottom-1.5 rounded-sm px-1",
|
|
120
|
+
count: H,
|
|
121
|
+
dataHook: `${f}-count`,
|
|
122
|
+
id: E,
|
|
123
|
+
labels: s,
|
|
124
|
+
limit: h
|
|
125
|
+
})]
|
|
126
|
+
}) : T;
|
|
31
127
|
});
|
|
32
|
-
|
|
128
|
+
Y.displayName = "Textarea";
|
|
33
129
|
export {
|
|
34
|
-
|
|
130
|
+
Y as Textarea
|
|
35
131
|
};
|
package/dist/tooltip.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";const
|
|
1
|
+
"use client";const S=require("./_virtual/_rolldown/runtime.cjs"),u=require("./lib/compose-event-handlers.cjs");let e=require("react");e=S.__toESM(e,1);let A=require("@brightlocal/ui-components/lib/utils"),g=require("react/jsx-runtime"),J=require("@radix-ui/react-slot"),_=require("@radix-ui/react-popover");_=S.__toESM(_,1);var B=e.createContext({delayDuration:0,skipDelayDuration:0});function K({delayDuration:s=0,skipDelayDuration:f=0,children:v}){const T=e.useMemo(()=>({delayDuration:s,skipDelayDuration:f}),[s,f]);return(0,g.jsx)(B.Provider,{value:T,children:v})}var Q=200,F=e.createContext(null);function M(){const s=e.useContext(F);if(!s)throw new Error("Tooltip components must be used within <Tooltip>");return s}function W({open:s,defaultOpen:f=!1,onOpenChange:v,children:T}){const{delayDuration:x}=e.useContext(B),[y,w]=e.useState(f??!1),p=s!==void 0,n=p?s:y,[P,R]=e.useState(!1),C=e.useRef(void 0),m=e.useRef(void 0),l=e.useRef(null),d=e.useRef("hover"),a=e.useRef(null),h=e.useId(),r=e.useCallback(t=>{t||(d.current="hover"),p||w(t),v?.(t)},[p,v]),o=e.useCallback(()=>{C.current!==void 0&&(clearTimeout(C.current),C.current=void 0),m.current!==void 0&&(clearTimeout(m.current),m.current=void 0)},[]);e.useEffect(()=>o,[o]);const b=e.useCallback(()=>{if(o(),d.current==="touch"){if(n)return;d.current="hover"}x>0?m.current=setTimeout(()=>r(!0),x):r(!0)},[o,x,n,r]),i=e.useCallback(()=>{o(),!(d.current==="touch"&&n)&&(C.current=setTimeout(()=>r(!1),Q))},[o,n,r]),c=e.useCallback(t=>{t.pointerType!=="touch"&&b()},[b]),k=e.useCallback(t=>{t.pointerType!=="touch"&&(a.current=null,i())},[i]),H=e.useCallback(t=>{a.current=t.pointerType==="touch"?"touch":"mouse"},[]),D=e.useCallback(()=>{a.current=null},[]),O=e.useCallback(()=>{const t=a.current;a.current=null,t==="touch"&&(o(),n?r(!1):(d.current="touch",r(!0)))},[o,n,r]),j=e.useCallback(()=>{a.current||b()},[b]),E=e.useCallback(()=>{i()},[i]),I=e.useCallback(()=>{o()},[o]),L=e.useCallback(t=>{t.pointerType!=="touch"&&i()},[i]),N=e.useCallback(t=>{const q=t.target;q instanceof Node&&l.current?.contains(q)&&t.preventDefault()},[]),z=e.useCallback(t=>{t||(o(),r(!1))},[o,r]),U=e.useMemo(()=>({open:n,tooltipId:h,triggerRef:l,suppressDescribedBy:P,setSuppressDescribedBy:R,onTriggerPointerEnter:c,onTriggerPointerLeave:k,onTriggerPointerDown:H,onTriggerPointerCancel:D,onTriggerClick:O,onTriggerFocus:j,onTriggerBlur:E,onContentPointerEnter:I,onContentPointerLeave:L,onContentInteractOutside:N}),[n,h,P,c,k,H,D,O,j,E,I,L,N]);return(0,g.jsx)(F.Provider,{value:U,children:(0,g.jsx)(_.Root,{open:n,onOpenChange:z,children:T})})}var G=e.forwardRef(({dataHook:s,trackingEl:f,trackingLabel:v,asChild:T,children:x,onBlur:y,onClick:w,onFocus:p,onPointerCancel:n,onPointerDown:P,onPointerEnter:R,onPointerLeave:C,...m},l)=>{const{open:d,tooltipId:a,triggerRef:h,suppressDescribedBy:r,onTriggerPointerEnter:o,onTriggerPointerLeave:b,onTriggerPointerDown:i,onTriggerPointerCancel:c,onTriggerClick:k,onTriggerFocus:H,onTriggerBlur:D}=M(),O=e.useCallback(E=>{h.current=E,typeof l=="function"?l(E):l&&(l.current=E)},[l,h]),j=T?J.Slot:"button";return(0,g.jsx)(_.Anchor,{asChild:!0,children:(0,g.jsx)(j,{ref:O,"data-slot":"tooltip-trigger",...m,"aria-describedby":d&&!r?a:void 0,"data-hook":s,"data-tracking-el":f,"data-tracking-label":v,type:T?void 0:"button",onBlur:u.composeEventHandlers(y,D),onClick:u.composeEventHandlers(w,k),onFocus:u.composeEventHandlers(p,H),onPointerCancel:u.composeEventHandlers(n,c),onPointerDown:u.composeEventHandlers(P,i),onPointerEnter:u.composeEventHandlers(R,o),onPointerLeave:u.composeEventHandlers(C,b),children:x})})});G.displayName="TooltipTrigger";var V=e.forwardRef(({className:s,side:f="top",sideOffset:v=0,dataHook:T,trackingEl:x,trackingLabel:y,hideArrow:w=!1,children:p,onInteractOutside:n,onPointerEnter:P,onPointerLeave:R,...C},m)=>{const{tooltipId:l,triggerRef:d,suppressDescribedBy:a,setSuppressDescribedBy:h,onContentPointerEnter:r,onContentPointerLeave:o,onContentInteractOutside:b}=M(),i=typeof p=="string"?p.trim():null;return e.useLayoutEffect(()=>{const c=d.current?.getAttribute("aria-label")??null,k=i!==null&&c!==null&&i===c.trim();h(k)}),(0,g.jsx)(_.Portal,{children:(0,g.jsxs)(_.Content,{ref:m,className:(0,A.cn)("bg-secondary text-secondary-foreground text-body-xs z-50 w-max max-w-sm rounded-md px-3 py-1.5",A.FLOATING_CONTENT_ANIMATION,"**:data-[slot=tooltip-arrow]:-translate-y-px",s),"data-hook":T,"data-slot":"tooltip-content","data-tracking-el":x,"data-tracking-label":y,side:f,sideOffset:v,onCloseAutoFocus:c=>c.preventDefault(),onOpenAutoFocus:c=>c.preventDefault(),...C,role:"none",onInteractOutside:u.composeEventHandlers(n,b),onPointerEnter:u.composeEventHandlers(P,r),onPointerLeave:u.composeEventHandlers(R,o),children:[(0,g.jsx)("span",{id:a?void 0:l,role:"tooltip",children:p}),!w&&(0,g.jsx)(_.Arrow,{className:"fill-secondary","data-slot":"tooltip-arrow",height:7,width:14})]})})});V.displayName="TooltipContent";exports.Tooltip=W;exports.TooltipContent=V;exports.TooltipProvider=K;exports.TooltipTrigger=G;
|
package/dist/tooltip.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../src/components/tooltip.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,gBAAgB,MAAM,yBAAyB,CAAC;AAW5D,UAAU,oBAAoB;IAC5B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAA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