@vllnt/ui 0.4.0-canary.sha36bfa21 → 0.4.0-canary.sha49f831b

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.
Files changed (105) hide show
  1. package/CHANGELOG.md +170 -6
  2. package/README.md +61 -3
  3. package/dist/components/atoms/accordion/accordion.js +28 -7
  4. package/dist/components/atoms/agent-activity/agent-activity.js +1 -1
  5. package/dist/components/atoms/ai-source-citation/ai-source-citation.js +1 -1
  6. package/dist/components/atoms/alert/alert.js +1 -1
  7. package/dist/components/atoms/alert-pulse/alert-pulse.js +7 -4
  8. package/dist/components/atoms/avatar/avatar.js +129 -24
  9. package/dist/components/atoms/badge/badge.js +84 -5
  10. package/dist/components/atoms/bottom-activity-strip/bottom-activity-strip.js +3 -2
  11. package/dist/components/atoms/breadcrumb/breadcrumb.js +89 -37
  12. package/dist/components/atoms/checklist/checklist.js +2 -2
  13. package/dist/components/atoms/curriculum/curriculum.js +4 -4
  14. package/dist/components/atoms/dialog/dialog.js +4 -2
  15. package/dist/components/atoms/drawer/drawer.js +1 -1
  16. package/dist/components/atoms/dropdown-menu/dropdown-menu.js +1 -1
  17. package/dist/components/atoms/floating-toolbar/floating-toolbar.js +23 -2
  18. package/dist/components/atoms/gauge-chart/gauge-chart.js +1 -1
  19. package/dist/components/atoms/glass-progress/glass-progress.js +1 -1
  20. package/dist/components/atoms/heat-overlay/heat-overlay.js +3 -2
  21. package/dist/components/atoms/jarvis-dock/jarvis-dock.js +2 -2
  22. package/dist/components/atoms/kbd/kbd.js +41 -11
  23. package/dist/components/atoms/keyboard-shortcuts-help/keyboard-shortcuts-help.js +1 -1
  24. package/dist/components/atoms/menubar/menubar.js +1 -1
  25. package/dist/components/atoms/meter/meter.js +2 -2
  26. package/dist/components/atoms/metric-cluster/metric-cluster.js +2 -1
  27. package/dist/components/atoms/policy-delivery-panel/policy-delivery-panel.js +19 -10
  28. package/dist/components/atoms/presence-stack/presence-stack.js +1 -1
  29. package/dist/components/atoms/progress-bar/progress-bar.js +190 -30
  30. package/dist/components/atoms/pull-quote/pull-quote.js +77 -0
  31. package/dist/components/atoms/quiz/quiz.js +2 -2
  32. package/dist/components/atoms/relationship-inspector/relationship-inspector.js +1 -1
  33. package/dist/components/atoms/routing-assignment-panel/routing-assignment-panel.js +20 -11
  34. package/dist/components/atoms/runtime-overview-panel/runtime-overview-panel.js +2 -1
  35. package/dist/components/atoms/scrim/scrim.js +32 -0
  36. package/dist/components/atoms/segmented-control/segmented-control.js +2 -2
  37. package/dist/components/atoms/select/select.js +3 -3
  38. package/dist/components/atoms/sheet/sheet.js +3 -2
  39. package/dist/components/atoms/skeleton/skeleton.js +1 -1
  40. package/dist/components/atoms/state-badge-overlay/state-badge-overlay.js +14 -16
  41. package/dist/components/atoms/stepper/stepper.js +1 -1
  42. package/dist/components/atoms/sticky-metric/sticky-metric.js +2 -1
  43. package/dist/components/atoms/table/table.js +1 -1
  44. package/dist/components/atoms/table-of-contents/table-of-contents.js +1 -1
  45. package/dist/components/atoms/table-of-contents-panel/table-of-contents-panel.js +4 -4
  46. package/dist/components/atoms/tabs/tabs.js +34 -11
  47. package/dist/components/atoms/tag-group/tag-group.js +10 -5
  48. package/dist/components/atoms/tags-input/tags-input.js +1 -1
  49. package/dist/components/atoms/thread-bubble/thread-bubble.js +1 -1
  50. package/dist/components/atoms/threshold-ring/threshold-ring.js +3 -2
  51. package/dist/components/atoms/timeline/timeline.js +15 -3
  52. package/dist/components/atoms/timeline-scrubber/timeline-scrubber.js +3 -2
  53. package/dist/components/atoms/tldr-section/tldr-section.js +5 -5
  54. package/dist/components/atoms/toggle/toggle.js +1 -1
  55. package/dist/components/atoms/view-switcher/view-switcher.js +1 -1
  56. package/dist/components/atoms/viewport-bookmarks/viewport-bookmarks.js +1 -1
  57. package/dist/components/atoms/watchlist/watchlist.js +1 -1
  58. package/dist/components/atoms/workspace-switcher/workspace-switcher.js +1 -1
  59. package/dist/components/index.js +38 -2
  60. package/dist/components/molecules/ai-artifact/ai-artifact.js +2 -12
  61. package/dist/components/molecules/approval-request/approval-request.js +168 -0
  62. package/dist/components/molecules/civilization-card/civilization-card.js +1 -1
  63. package/dist/components/molecules/completion-dialog/completion-dialog.js +1 -1
  64. package/dist/components/molecules/content-intro/content-intro.js +2 -2
  65. package/dist/components/molecules/conversation-thread/conversation-thread.js +5 -5
  66. package/dist/components/molecules/cookie-consent/cookie-consent.js +188 -80
  67. package/dist/components/molecules/copy-button/use-copy-to-clipboard.js +10 -12
  68. package/dist/components/molecules/countdown-timer/countdown-timer.js +1 -1
  69. package/dist/components/molecules/credit-badge/credit-badge.js +13 -16
  70. package/dist/components/molecules/filter-bar/filter-bar.js +2 -2
  71. package/dist/components/molecules/historical-figure-card/historical-figure-card.js +1 -1
  72. package/dist/components/molecules/plan-badge/plan-badge.js +12 -13
  73. package/dist/components/molecules/pricing-table/pricing-table.js +1 -1
  74. package/dist/components/molecules/progress-tracker/progress-tracker.js +8 -17
  75. package/dist/components/molecules/sidebar/sidebar.js +24 -9
  76. package/dist/components/molecules/tour/tour.js +1 -1
  77. package/dist/components/molecules/transaction-list/transaction-list.js +7 -9
  78. package/dist/components/molecules/tutorial-filters/tutorial-filters.js +2 -2
  79. package/dist/components/molecules/usage-breakdown/usage-breakdown.js +1 -1
  80. package/dist/components/organisms/access-matrix/access-matrix.js +271 -0
  81. package/dist/components/organisms/activity-heatmap/activity-heatmap.js +1 -1
  82. package/dist/components/organisms/code-block/code-block.js +145 -81
  83. package/dist/components/organisms/cta-band/cta-band.js +79 -0
  84. package/dist/components/organisms/flow-diagram/flow-controls.js +1 -1
  85. package/dist/components/organisms/flow-diagram/flow-fullscreen.js +1 -1
  86. package/dist/components/organisms/gantt-chart/gantt-chart.js +1 -1
  87. package/dist/components/organisms/historic-timeline/historic-timeline.js +1 -1
  88. package/dist/components/organisms/navbar-saas/navbar-saas.js +1 -1
  89. package/dist/components/organisms/order-summary/order-summary.js +172 -0
  90. package/dist/components/organisms/settings-list/settings-list.js +125 -0
  91. package/dist/components/organisms/share-dialog-people/share-dialog-people.js +412 -0
  92. package/dist/components/organisms/slideshow/slideshow.js +6 -6
  93. package/dist/components/organisms/subscription-card/subscription-card.js +10 -10
  94. package/dist/components/organisms/tutorial-complete/tutorial-complete.js +2 -2
  95. package/dist/components/organisms/tutorial-mdx/tutorial-mdx.js +1 -1
  96. package/dist/index.d.ts +1143 -82
  97. package/dist/index.js +10 -0
  98. package/dist/lib/copy-text.js +64 -0
  99. package/dist/lib/status-dot.js +33 -0
  100. package/dist/tailwind-preset.js +16 -0
  101. package/package.json +17 -4
  102. package/styles.css +48 -7
  103. package/themes/default.css +48 -7
  104. package/themes/presets.css +24 -24
  105. package/themes/products.css +146 -0
@@ -17,6 +17,7 @@ import {
17
17
  Minimize2,
18
18
  Pencil
19
19
  } from "lucide-react";
20
+ import { copyText } from "../../../lib/copy-text.js";
20
21
  import { cn } from "../../../lib/utils.js";
21
22
  import { Badge } from "../../atoms/badge/badge.js";
22
23
  import { Button } from "../../atoms/button/button.js";
@@ -92,17 +93,6 @@ function buildFilename({
92
93
  const safeBase = slug.length > 0 ? slug : "artifact";
93
94
  return `${safeBase}.${pickExtension(type, language)}`;
94
95
  }
95
- async function writeToClipboard(value) {
96
- if (typeof navigator === "undefined" || typeof navigator.clipboard?.writeText !== "function") {
97
- return false;
98
- }
99
- try {
100
- await navigator.clipboard.writeText(value);
101
- return true;
102
- } catch {
103
- return false;
104
- }
105
- }
106
96
  function downloadValueAsFile(value, filename) {
107
97
  if (typeof document === "undefined") return;
108
98
  const blob = new Blob([value], { type: "text/plain;charset=utf-8" });
@@ -167,7 +157,7 @@ function useArtifactController(options) {
167
157
  [filename, language, title, type]
168
158
  );
169
159
  const copy = useCallback(async () => {
170
- const ok = await writeToClipboard(value);
160
+ const ok = await copyText(value);
171
161
  if (!ok) return false;
172
162
  flagCopied();
173
163
  return true;
@@ -0,0 +1,168 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { cva } from "class-variance-authority";
5
+ import { cn } from "../../../lib/utils.js";
6
+ import { Badge } from "../../atoms/badge/badge.js";
7
+ import { Button } from "../../atoms/button/button.js";
8
+ import { Checkbox } from "../../atoms/checkbox/checkbox.js";
9
+ import { Label } from "../../atoms/label/label.js";
10
+ const DEFAULT_APPROVE_LABEL = "Approve";
11
+ const DEFAULT_DENY_LABEL = "Deny";
12
+ const DEFAULT_REMEMBER_LABEL = "Remember my choice";
13
+ const DEFAULT_RISK_LABELS = {
14
+ high: "High risk",
15
+ low: "Low risk",
16
+ medium: "Medium risk"
17
+ };
18
+ const DEFAULT_STATUS_LABELS = {
19
+ approved: "Approved",
20
+ denied: "Denied",
21
+ expired: "Expired",
22
+ pending: "Pending"
23
+ };
24
+ const surfaceVariants = cva(
25
+ "flex w-full min-w-0 flex-col gap-3 border text-sm",
26
+ {
27
+ defaultVariants: {
28
+ placement: "inline"
29
+ },
30
+ variants: {
31
+ placement: {
32
+ dialog: "max-w-lg gap-4 rounded-lg bg-background p-6 text-foreground shadow-lg",
33
+ hud: "max-w-sm rounded-md bg-popover p-3 text-popover-foreground shadow-md",
34
+ inline: "rounded-lg bg-card p-4 text-card-foreground"
35
+ }
36
+ }
37
+ }
38
+ );
39
+ const riskVariants = cva("", {
40
+ defaultVariants: {
41
+ risk: "low"
42
+ },
43
+ variants: {
44
+ risk: {
45
+ high: "border-destructive/40 bg-destructive/10 text-destructive",
46
+ low: "border-border bg-muted text-muted-foreground",
47
+ medium: "border-warning/40 bg-warning/10 text-warning"
48
+ }
49
+ }
50
+ });
51
+ const statusVariants = cva("", {
52
+ defaultVariants: {
53
+ status: "pending"
54
+ },
55
+ variants: {
56
+ status: {
57
+ approved: "border-success/40 bg-success/10 text-success",
58
+ denied: "border-destructive/40 bg-destructive/10 text-destructive",
59
+ expired: "border-border bg-muted text-muted-foreground",
60
+ pending: "border-info/40 bg-info/10 text-info"
61
+ }
62
+ }
63
+ });
64
+ function resolveLabel(custom, fallback) {
65
+ return custom !== void 0 && custom.trim() !== "" ? custom : fallback;
66
+ }
67
+ function RememberRow({
68
+ checked,
69
+ label,
70
+ onCheckedChange
71
+ }) {
72
+ const rememberId = React.useId();
73
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
74
+ /* @__PURE__ */ jsx(
75
+ Checkbox,
76
+ {
77
+ checked,
78
+ id: rememberId,
79
+ onCheckedChange: (state) => {
80
+ onCheckedChange?.(state === true);
81
+ }
82
+ }
83
+ ),
84
+ /* @__PURE__ */ jsx(
85
+ Label,
86
+ {
87
+ className: "font-normal leading-snug text-muted-foreground",
88
+ htmlFor: rememberId,
89
+ children: resolveLabel(label, DEFAULT_REMEMBER_LABEL)
90
+ }
91
+ )
92
+ ] });
93
+ }
94
+ function ApprovalRequestFooter({
95
+ approveLabel,
96
+ denyLabel,
97
+ onApprove,
98
+ onDeny
99
+ }) {
100
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", children: [
101
+ /* @__PURE__ */ jsx(Button, { onClick: onDeny, type: "button", variant: "outline", children: denyLabel }),
102
+ /* @__PURE__ */ jsx(Button, { onClick: onApprove, type: "button", children: approveLabel })
103
+ ] });
104
+ }
105
+ const ApprovalRequest = ({
106
+ action,
107
+ className,
108
+ detail,
109
+ labels,
110
+ onApprove,
111
+ onDeny,
112
+ placement = "inline",
113
+ ref: reference,
114
+ remember,
115
+ risk = "low",
116
+ status = "pending",
117
+ title,
118
+ ...props
119
+ }) => {
120
+ const titleId = React.useId();
121
+ const isPending = status === "pending";
122
+ return /* @__PURE__ */ jsxs(
123
+ "fieldset",
124
+ {
125
+ "aria-labelledby": titleId,
126
+ className: cn(surfaceVariants({ placement }), className),
127
+ ref: reference,
128
+ ...props,
129
+ children: [
130
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
131
+ /* @__PURE__ */ jsx(Badge, { className: riskVariants({ risk }), variant: "outline", children: resolveLabel(labels?.risk?.[risk], DEFAULT_RISK_LABELS[risk]) }),
132
+ /* @__PURE__ */ jsx(
133
+ Badge,
134
+ {
135
+ className: statusVariants({ status }),
136
+ role: "status",
137
+ variant: "outline",
138
+ children: resolveLabel(
139
+ labels?.status?.[status],
140
+ DEFAULT_STATUS_LABELS[status]
141
+ )
142
+ }
143
+ )
144
+ ] }),
145
+ /* @__PURE__ */ jsx("p", { className: "text-base font-semibold leading-snug", id: titleId, children: title }),
146
+ detail ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: detail }) : null,
147
+ /* @__PURE__ */ jsx("code", { className: "block whitespace-pre-wrap break-words rounded-md border bg-muted px-3 py-2 font-mono text-sm text-foreground", children: action }),
148
+ isPending ? /* @__PURE__ */ jsxs(Fragment, { children: [
149
+ /* @__PURE__ */ jsx("hr", { className: "border-border" }),
150
+ remember ? /* @__PURE__ */ jsx(RememberRow, { ...remember }) : null,
151
+ /* @__PURE__ */ jsx(
152
+ ApprovalRequestFooter,
153
+ {
154
+ approveLabel: resolveLabel(labels?.approve, DEFAULT_APPROVE_LABEL),
155
+ denyLabel: resolveLabel(labels?.deny, DEFAULT_DENY_LABEL),
156
+ onApprove,
157
+ onDeny
158
+ }
159
+ )
160
+ ] }) : null
161
+ ]
162
+ }
163
+ );
164
+ };
165
+ ApprovalRequest.displayName = "ApprovalRequest";
166
+ export {
167
+ ApprovalRequest
168
+ };
@@ -93,7 +93,7 @@ function EraTimeline({ era, label }) {
93
93
  role: "img",
94
94
  children: [
95
95
  /* @__PURE__ */ jsx("span", { className: "text-xs font-medium uppercase tracking-wide text-muted-foreground", children: eraLabel }),
96
- /* @__PURE__ */ jsx("div", { className: "relative h-1.5 w-full rounded-full bg-muted", children: /* @__PURE__ */ jsx(
96
+ /* @__PURE__ */ jsx("div", { className: "relative h-1.5 w-full rounded-full bg-secondary", children: /* @__PURE__ */ jsx(
97
97
  "span",
98
98
  {
99
99
  className: "absolute h-full rounded-full bg-primary",
@@ -12,7 +12,7 @@ function DialogCloseButton({
12
12
  DialogPrimitive.Close,
13
13
  {
14
14
  "aria-label": "Close",
15
- className: "absolute right-4 top-4 rounded-sm opacity-70 hover:opacity-100 transition-opacity focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
15
+ className: "absolute right-3 top-3 inline-flex min-h-6 min-w-6 items-center justify-center rounded-sm p-1 opacity-70 hover:opacity-100 transition-opacity focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
16
16
  children: closeIcon ?? /* @__PURE__ */ jsx(
17
17
  "svg",
18
18
  {
@@ -27,7 +27,7 @@ function ContentIntroToc({
27
27
  return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
28
28
  "button",
29
29
  {
30
- className: "w-full flex items-center gap-3 p-2 -m-2 rounded-lg hover:bg-muted/50 transition-colors text-left",
30
+ className: "w-full flex items-center gap-3 p-2 -m-2 rounded-lg hover:bg-secondary/50 transition-colors text-left",
31
31
  onClick: () => {
32
32
  onGoToSection(index);
33
33
  },
@@ -38,7 +38,7 @@ function ContentIntroToc({
38
38
  {
39
39
  className: cn(
40
40
  "flex-shrink-0 size-6 rounded-full flex items-center justify-center text-xs font-medium tabular-nums transition-colors",
41
- isLoading && "animate-pulse bg-muted motion-reduce:animate-none",
41
+ isLoading && "animate-pulse bg-secondary motion-reduce:animate-none",
42
42
  !isLoading && isCompleted && "bg-foreground text-background",
43
43
  !isLoading && !isCompleted && "bg-muted"
44
44
  ),
@@ -29,7 +29,7 @@ function MessageActions({ messageId }) {
29
29
  "button",
30
30
  {
31
31
  "aria-label": "Retry message",
32
- className: "rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
32
+ className: "rounded p-1 text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground",
33
33
  onClick: () => {
34
34
  onRetry(messageId);
35
35
  },
@@ -42,7 +42,7 @@ function MessageActions({ messageId }) {
42
42
  "button",
43
43
  {
44
44
  "aria-label": "Positive feedback",
45
- className: "rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
45
+ className: "rounded p-1 text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground",
46
46
  onClick: () => {
47
47
  onFeedback(messageId, "positive");
48
48
  },
@@ -54,7 +54,7 @@ function MessageActions({ messageId }) {
54
54
  "button",
55
55
  {
56
56
  "aria-label": "Negative feedback",
57
- className: "rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
57
+ className: "rounded p-1 text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground",
58
58
  onClick: () => {
59
59
  onFeedback(messageId, "negative");
60
60
  },
@@ -290,7 +290,7 @@ const ConversationSuggestions = ({
290
290
  children: suggestions.map((suggestion) => /* @__PURE__ */ jsx(
291
291
  "button",
292
292
  {
293
- className: "rounded-full border bg-background px-4 py-2 text-sm transition-colors hover:bg-muted",
293
+ className: "rounded-full border bg-background px-4 py-2 text-sm transition-colors hover:bg-secondary",
294
294
  onClick: () => onSend?.(suggestion),
295
295
  type: "button",
296
296
  children: suggestion
@@ -312,7 +312,7 @@ const ConversationScrollButton = ({
312
312
  {
313
313
  "aria-label": "Scroll to bottom",
314
314
  className: cn(
315
- "absolute bottom-4 right-4 flex size-8 items-center justify-center rounded-full border bg-background shadow-md transition-colors hover:bg-muted",
315
+ "absolute bottom-4 right-4 flex size-8 items-center justify-center rounded-full border bg-background shadow-md transition-colors hover:bg-secondary",
316
316
  className
317
317
  ),
318
318
  onClick: scrollToBottom,
@@ -1,33 +1,158 @@
1
1
  "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
- import { useCallback, useEffect, useState } from "react";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { useCallback, useEffect, useId, useState } from "react";
4
4
  import { cva } from "class-variance-authority";
5
5
  import { X } from "lucide-react";
6
6
  import { cn } from "../../../lib/utils.js";
7
7
  import { Button } from "../../atoms/button/button.js";
8
8
  const cookieConsentVariants = cva(
9
- // Base: safe-area-inset for notched devices
10
- // Desktop: compact single-line layout, height matches button
11
- "fixed z-50 rounded-lg border bg-background shadow-lg transition-all duration-300 max-w-[calc(100vw-2rem)] p-4 sm:py-1.5 sm:px-3",
9
+ "fixed z-50 border bg-background transition-all duration-300 motion-reduce:transition-none",
12
10
  {
11
+ compoundVariants: [
12
+ {
13
+ class: "bottom-4 left-1/2 -translate-x-1/2 mb-safe",
14
+ layout: "card",
15
+ position: "bottom-center"
16
+ },
17
+ {
18
+ class: "bottom-4 left-4 right-4 sm:right-auto mb-safe ml-safe",
19
+ layout: "card",
20
+ position: "bottom-left"
21
+ },
22
+ {
23
+ class: "bottom-4 right-4 left-4 sm:left-auto mb-safe mr-safe",
24
+ layout: "card",
25
+ position: "bottom-right"
26
+ }
27
+ ],
13
28
  defaultVariants: {
29
+ layout: "card",
14
30
  position: "bottom-left"
15
31
  },
16
32
  variants: {
33
+ layout: {
34
+ bar: "inset-x-0 bottom-0 w-full border-x-0 border-b-0 pb-safe",
35
+ card: "max-w-[calc(100vw-2rem)] rounded-lg p-4 shadow-lg sm:px-3 sm:py-1.5"
36
+ },
17
37
  position: {
18
- // Mobile: 16px (1rem) from edges, respects safe area
19
- // Desktop: 16px from edges
20
- "bottom-center": "bottom-4 left-1/2 -translate-x-1/2 mb-safe",
21
- "bottom-left": "bottom-4 left-4 right-4 sm:right-auto mb-safe ml-safe",
22
- "bottom-right": "bottom-4 right-4 left-4 sm:left-auto mb-safe mr-safe"
38
+ "bottom-center": "",
39
+ "bottom-left": "",
40
+ "bottom-right": ""
23
41
  }
24
42
  }
25
43
  }
26
44
  );
45
+ const DEFAULT_LABELS = {
46
+ close: "Close cookie consent",
47
+ region: "Cookie consent"
48
+ };
49
+ const ACTION_VARIANTS = {
50
+ "accept-primary": { accept: "default", decline: "ghost" },
51
+ equal: { accept: "outline", decline: "outline" }
52
+ };
53
+ function ConsentActions({
54
+ acceptText,
55
+ actions,
56
+ buttonClassName,
57
+ buttonSize,
58
+ declineText,
59
+ linkClassName,
60
+ onAccept,
61
+ onDecline,
62
+ settingsHref,
63
+ settingsText
64
+ }) {
65
+ const variants = ACTION_VARIANTS[actions];
66
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
67
+ settingsHref ? /* @__PURE__ */ jsx(
68
+ "a",
69
+ {
70
+ className: cn(
71
+ "text-sm text-muted-foreground underline underline-offset-4 hover:text-foreground",
72
+ linkClassName
73
+ ),
74
+ href: settingsHref,
75
+ children: settingsText
76
+ }
77
+ ) : null,
78
+ declineText ? /* @__PURE__ */ jsx(
79
+ Button,
80
+ {
81
+ className: buttonClassName,
82
+ onClick: onDecline,
83
+ size: buttonSize,
84
+ type: "button",
85
+ variant: variants.decline,
86
+ children: declineText
87
+ }
88
+ ) : null,
89
+ /* @__PURE__ */ jsx(
90
+ Button,
91
+ {
92
+ className: buttonClassName,
93
+ onClick: onAccept,
94
+ size: buttonSize,
95
+ type: "button",
96
+ variant: variants.accept,
97
+ children: acceptText
98
+ }
99
+ )
100
+ ] });
101
+ }
102
+ function CardBody({
103
+ actionProps,
104
+ heading,
105
+ message
106
+ }) {
107
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
108
+ heading,
109
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 sm:hidden", children: [
110
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: message }),
111
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx(ConsentActions, { ...actionProps, buttonSize: "sm" }) })
112
+ ] }),
113
+ /* @__PURE__ */ jsxs("div", { className: "hidden sm:flex sm:items-center sm:gap-3", children: [
114
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: message }),
115
+ /* @__PURE__ */ jsx(
116
+ ConsentActions,
117
+ {
118
+ ...actionProps,
119
+ buttonClassName: "h-7 px-3 text-xs",
120
+ linkClassName: "whitespace-nowrap"
121
+ }
122
+ )
123
+ ] })
124
+ ] });
125
+ }
126
+ function BarBody({
127
+ actionProps,
128
+ heading,
129
+ message,
130
+ reserveClose
131
+ }) {
132
+ return /* @__PURE__ */ jsxs(
133
+ "div",
134
+ {
135
+ className: cn(
136
+ "flex flex-col gap-3 p-4 md:flex-row md:items-center md:justify-between md:gap-6 md:px-6",
137
+ reserveClose && "pr-10 md:pr-12"
138
+ ),
139
+ children: [
140
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
141
+ heading,
142
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: message })
143
+ ] }),
144
+ /* @__PURE__ */ jsx("div", { className: "flex flex-wrap items-center gap-2 md:shrink-0 md:gap-3", children: /* @__PURE__ */ jsx(ConsentActions, { ...actionProps }) })
145
+ ]
146
+ }
147
+ );
148
+ }
27
149
  const CookieConsent = ({
28
150
  acceptText = "Accept",
151
+ actions = "accept-primary",
29
152
  className,
30
153
  declineText,
154
+ labels,
155
+ layout = "card",
31
156
  message = "This site uses cookies to improve your experience.",
32
157
  onAccept,
33
158
  onDecline,
@@ -38,10 +163,12 @@ const CookieConsent = ({
38
163
  settingsHref,
39
164
  settingsText = "Learn more",
40
165
  showCloseButton = false,
166
+ title,
41
167
  ...props
42
168
  }) => {
43
169
  const [isVisible, setIsVisible] = useState(false);
44
170
  const [isAnimatingOut, setIsAnimatingOut] = useState(false);
171
+ const titleId = useId();
45
172
  useEffect(() => {
46
173
  if (open) {
47
174
  const timer = setTimeout(() => {
@@ -74,13 +201,35 @@ const CookieConsent = ({
74
201
  handleClose();
75
202
  }, [onDecline, handleClose]);
76
203
  if (!open && !isAnimatingOut) return null;
204
+ const isBar = layout === "bar";
205
+ const heading = title ? /* @__PURE__ */ jsx(
206
+ "h2",
207
+ {
208
+ className: cn(
209
+ "text-sm font-medium text-foreground",
210
+ !isBar && "mb-2 sm:mb-1"
211
+ ),
212
+ id: titleId,
213
+ children: title
214
+ }
215
+ ) : null;
216
+ const actionProps = {
217
+ acceptText,
218
+ actions,
219
+ declineText,
220
+ onAccept: handleAccept,
221
+ onDecline: handleDecline,
222
+ settingsHref,
223
+ settingsText
224
+ };
77
225
  return /* @__PURE__ */ jsxs(
78
226
  "div",
79
227
  {
80
- "aria-label": "Cookie consent",
228
+ "aria-label": heading ? void 0 : labels?.region ?? DEFAULT_LABELS.region,
229
+ "aria-labelledby": heading ? titleId : void 0,
81
230
  "aria-live": "polite",
82
231
  className: cn(
83
- cookieConsentVariants({ position }),
232
+ cookieConsentVariants({ layout, position }),
84
233
  // Animation states
85
234
  isVisible && !isAnimatingOut ? "translate-y-0 opacity-100" : "translate-y-4 opacity-0",
86
235
  className
@@ -89,79 +238,38 @@ const CookieConsent = ({
89
238
  role: "dialog",
90
239
  ...props,
91
240
  children: [
92
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 sm:hidden", children: [
93
- /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: message }),
94
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
95
- settingsHref ? /* @__PURE__ */ jsx(
96
- "a",
97
- {
98
- className: "text-sm text-muted-foreground underline underline-offset-4 hover:text-foreground",
99
- href: settingsHref,
100
- children: settingsText
101
- }
102
- ) : null,
103
- declineText ? /* @__PURE__ */ jsx(
104
- Button,
105
- {
106
- onClick: handleDecline,
107
- size: "sm",
108
- type: "button",
109
- variant: "ghost",
110
- children: declineText
111
- }
112
- ) : null,
113
- /* @__PURE__ */ jsx(
114
- Button,
115
- {
116
- onClick: handleAccept,
117
- size: "sm",
118
- type: "button",
119
- variant: "default",
120
- children: acceptText
121
- }
122
- )
123
- ] })
124
- ] }),
125
- /* @__PURE__ */ jsxs("div", { className: "hidden sm:flex sm:items-center sm:gap-3", children: [
126
- /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: message }),
127
- settingsHref ? /* @__PURE__ */ jsx(
128
- "a",
129
- {
130
- className: "text-sm text-muted-foreground underline underline-offset-4 hover:text-foreground whitespace-nowrap",
131
- href: settingsHref,
132
- children: settingsText
133
- }
134
- ) : null,
135
- declineText ? /* @__PURE__ */ jsx(
136
- Button,
137
- {
138
- className: "h-7 px-3 text-xs",
139
- onClick: handleDecline,
140
- type: "button",
141
- variant: "ghost",
142
- children: declineText
143
- }
144
- ) : null,
241
+ isBar ? /* @__PURE__ */ jsx(
242
+ BarBody,
243
+ {
244
+ actionProps,
245
+ heading,
246
+ message,
247
+ reserveClose: showCloseButton
248
+ }
249
+ ) : /* @__PURE__ */ jsx(
250
+ CardBody,
251
+ {
252
+ actionProps,
253
+ heading,
254
+ message
255
+ }
256
+ ),
257
+ showCloseButton ? (
258
+ // The button is the 24px hit area (WCAG 2.5.8); -m-px keeps the 22px
259
+ // circle drawn by the span where the button used to sit.
145
260
  /* @__PURE__ */ jsx(
146
- Button,
261
+ "button",
147
262
  {
148
- className: "h-7 px-3 text-xs",
149
- onClick: handleAccept,
263
+ "aria-label": labels?.close ?? DEFAULT_LABELS.close,
264
+ className: cn(
265
+ "absolute -m-px grid size-6 place-items-center text-muted-foreground hover:text-foreground",
266
+ isBar ? "right-2 top-2" : "-right-2 -top-2"
267
+ ),
268
+ onClick: handleClose,
150
269
  type: "button",
151
- variant: "default",
152
- children: acceptText
270
+ children: /* @__PURE__ */ jsx("span", { className: "rounded-full border bg-background p-1", children: /* @__PURE__ */ jsx(X, { className: "size-3" }) })
153
271
  }
154
272
  )
155
- ] }),
156
- showCloseButton ? /* @__PURE__ */ jsx(
157
- "button",
158
- {
159
- "aria-label": "Close cookie consent",
160
- className: "absolute -right-2 -top-2 rounded-full border bg-background p-1 text-muted-foreground hover:text-foreground",
161
- onClick: handleClose,
162
- type: "button",
163
- children: /* @__PURE__ */ jsx(X, { className: "size-3" })
164
- }
165
273
  ) : null
166
274
  ]
167
275
  }
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { useCallback, useEffect, useRef, useState } from "react";
3
+ import { copyText } from "../../../lib/copy-text.js";
3
4
  const FALLBACK_TIMEOUT_MS = 2e3;
4
5
  function useCopyToClipboard(options = {}) {
5
6
  const { timeout = FALLBACK_TIMEOUT_MS } = options;
@@ -18,20 +19,17 @@ function useCopyToClipboard(options = {}) {
18
19
  }, []);
19
20
  const copy = useCallback(
20
21
  async (value) => {
21
- try {
22
- if (typeof navigator === "undefined" || typeof navigator.clipboard?.writeText !== "function") {
23
- return false;
24
- }
25
- await navigator.clipboard.writeText(value);
26
- if (timerRef.current !== void 0) clearTimeout(timerRef.current);
27
- setCopied(true);
28
- timerRef.current = setTimeout(() => {
29
- setCopied(false);
30
- }, timeout);
31
- return true;
32
- } catch {
22
+ const ok = await copyText(value);
23
+ if (timerRef.current !== void 0) clearTimeout(timerRef.current);
24
+ if (!ok) {
25
+ setCopied(false);
33
26
  return false;
34
27
  }
28
+ setCopied(true);
29
+ timerRef.current = setTimeout(() => {
30
+ setCopied(false);
31
+ }, timeout);
32
+ return true;
35
33
  },
36
34
  [timeout]
37
35
  );
@@ -97,7 +97,7 @@ function TimerProgress({
97
97
  /* @__PURE__ */ jsx("span", { children: startedAt ? "SLA elapsed" : "Time remaining" }),
98
98
  /* @__PURE__ */ jsx("span", { children: statusText })
99
99
  ] }),
100
- /* @__PURE__ */ jsx("div", { className: "h-2 overflow-hidden rounded-full bg-muted", children: /* @__PURE__ */ jsx(
100
+ /* @__PURE__ */ jsx("div", { className: "h-2 overflow-hidden rounded-full bg-secondary", children: /* @__PURE__ */ jsx(
101
101
  "div",
102
102
  {
103
103
  className: cn("h-full transition-all", toneClassName),