@espressif/dashboard-ui-components 1.13.0 → 1.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/rules/dashboard-ui-consumption.md +42 -0
- package/.cursor/rules/dashboard-ui-consumption.mdc +40 -1
- package/CHANGELOG.md +272 -0
- package/README.md +68 -6
- package/dist/{alert.props-CcKo49Rb.d.ts → alert.props-BuLuWmXA.d.ts} +3 -3
- package/dist/common/copyright-card/copyright-card.js +1 -1
- package/dist/common/footer-card/footer-card.js +2 -2
- package/dist/common/index.d.ts +3 -0
- package/dist/common/my-account-menu/my-account-menu.js +2 -2
- package/dist/common/page-loader/page-loader.js +4 -1
- package/dist/common/profile-card/profile-card.js +2 -2
- package/dist/components/accordion/accordion.js +6 -11
- package/dist/components/alert/index.d.ts +5 -5
- package/dist/components/anchored-panel/anchored-panel.js +4 -4
- package/dist/components/async-multi-select/async-multi-select.js +8 -8
- package/dist/components/avatar/avatar.js +1 -1
- package/dist/components/badge/index.d.ts +1 -1
- package/dist/components/bottom-sheet/_hooks/use-sheet-drag.js +112 -0
- package/dist/components/bottom-sheet/bottom-sheet.js +84 -0
- package/dist/components/bottom-sheet/index.d.ts +50 -0
- package/dist/components/bottom-sheet/index.js +3 -0
- package/dist/components/bubble/bubble.js +1 -1
- package/dist/components/button/button.js +2 -2
- package/dist/components/button/flash-button.js +4 -4
- package/dist/components/calendar/calendar.js +5 -5
- package/dist/components/cards/animated-card/animated-card.js +1 -1
- package/dist/components/cards/basic-details-card.js +2 -2
- package/dist/components/cards/collapsible-card.js +1 -1
- package/dist/components/cards/index.d.ts +2 -2
- package/dist/components/cards/no-data-card/no-data-card.js +2 -2
- package/dist/components/cards/section-card.js +12 -12
- package/dist/components/cards/simple-card.js +2 -5
- package/dist/components/category-card/category-card.js +2 -2
- package/dist/components/chart/chart.js +4 -4
- package/dist/components/chart/donut-chart.js +1 -1
- package/dist/components/chart/treemap-chart.js +1 -1
- package/dist/components/choice-card/choice-card.js +3 -3
- package/dist/components/code-editor/code-editor.js +4 -3
- package/dist/components/data-table/table-header.js +1 -1
- package/dist/components/date-range-picker/date-range-picker.js +3 -3
- package/dist/components/dynamic-list/dynamic-list.js +14 -13
- package/dist/components/dynamic-list/index.d.ts +1 -1
- package/dist/components/error-display/full-size-error/full-size-error.js +2 -2
- package/dist/components/expandable-text/expandable-text-overlay.js +1 -1
- package/dist/components/facet-filters/filter-group.js +2 -2
- package/dist/components/feature-grid/feature-grid.js +3 -3
- package/dist/components/file-input/file-input.js +8 -8
- package/dist/components/file-upload/file-upload.js +4 -4
- package/dist/components/fullscreen-dialog/fullscreen-dialog.js +1 -1
- package/dist/components/gradient-ring-button/_hooks/use-ring-geometry.js +116 -0
- package/dist/components/gradient-ring-button/gradient-ring-button.js +44 -0
- package/dist/components/gradient-ring-button/gradient-ring.js +77 -0
- package/dist/components/gradient-ring-button/index.d.ts +66 -0
- package/dist/components/gradient-ring-button/index.js +3 -0
- package/dist/components/horizontal-stepper/horizontal-stepper.js +4 -8
- package/dist/components/horizontal-stepper/index.d.ts +1 -1
- package/dist/components/icon-avatar/index.d.ts +3 -3
- package/dist/components/icon-text-action-card/index.d.ts +4 -4
- package/dist/components/index.d.ts +9 -7
- package/dist/components/index.js +5 -1
- package/dist/components/key-value-manager/key-value-manager-add-popover.js +1 -1
- package/dist/components/key-value-manager/key-value-manager-table.js +1 -1
- package/dist/components/link/link.js +7 -7
- package/dist/components/list/list-item.utils.js +5 -4
- package/dist/components/list/list.js +1 -1
- package/dist/components/list-details/index.d.ts +2 -2
- package/dist/components/markdown-content/markdown-content.components.js +2 -2
- package/dist/components/media-card/media-card-reveal.js +2 -2
- package/dist/components/media-card/media-card.js +2 -2
- package/dist/components/monospace-content/index.d.ts +4 -4
- package/dist/components/monospace-content/monospace-content.js +9 -11
- package/dist/components/nav-bar/nav-bar-mobile-menu.js +3 -3
- package/dist/components/nav-bar/nav-bar.js +4 -4
- package/dist/components/notice-strip/notice-strip.js +1 -1
- package/dist/components/option-card-group/option-card-group.js +2 -2
- package/dist/components/overflow-badge-list/index.d.ts +2 -2
- package/dist/components/overflow-badge-list/overflow-badge-list.js +3 -3
- package/dist/components/page-banner/page-banner.js +1 -1
- package/dist/components/page-container/page-container.js +1 -1
- package/dist/components/pagination/pagination.js +1 -1
- package/dist/components/progress-bar/progress-bar.js +2 -2
- package/dist/components/qr-code/qr-code.js +2 -2
- package/dist/components/radio-group/radio-group.js +3 -3
- package/dist/components/range-field/range-field.js +9 -12
- package/dist/components/readout/readout.js +1 -1
- package/dist/components/requirement-list/requirement-list.js +5 -10
- package/dist/components/scrollable-sections/scrollable-sections.js +1 -1
- package/dist/components/search-field-shell.js +8 -8
- package/dist/components/selectable-card-list/selectable-card-list-shared.js +6 -6
- package/dist/components/showcase-card/showcase-card.js +2 -2
- package/dist/components/sidebar/sidebar.js +13 -15
- package/dist/components/simple-clickable-card/index.d.ts +4 -4
- package/dist/components/simple-clickable-card/simple-clickable-card-shared.js +17 -23
- package/dist/components/simple-info-card/index.d.ts +3 -3
- package/dist/components/simple-list/index.d.ts +1 -1
- package/dist/components/simple-list/simple-list.js +8 -8
- package/dist/components/simple-paginated-list/simple-paginated-list.js +1 -4
- package/dist/components/stat-card/stat-card.js +7 -13
- package/dist/components/status-badge/index.d.ts +3 -3
- package/dist/components/status-badge/status-badge.js +4 -4
- package/dist/components/status-card-list/status-card-list.js +6 -6
- package/dist/components/tag/index.d.ts +1 -1
- package/dist/components/tag/tag.js +4 -4
- package/dist/components/tag-input/tag-input.js +12 -12
- package/dist/components/timeline/timeline.js +2 -2
- package/dist/components/toast/index.d.ts +1 -1
- package/dist/components/toast/toast.js +2 -2
- package/dist/components/toolbar/index.d.ts +5 -2
- package/dist/components/toolbar/toolbar-button.js +1 -1
- package/dist/components/toolbar/toolbar.js +9 -3
- package/dist/components/trace/trace.js +1 -1
- package/dist/components/transfer-list/transfer-list.js +2 -2
- package/dist/components/typography/index.d.ts +12 -3
- package/dist/components/typography/typography-variants.js +98 -13
- package/dist/components/typography/typography.js +4 -2
- package/dist/components/user-type-badge/user-type-badge.js +4 -4
- package/dist/components/vertical-stepper/vertical-stepper.js +11 -7
- package/dist/core/alert.js +3 -3
- package/dist/core/animate-ui/components/animate/code-header.js +1 -1
- package/dist/core/animate-ui/components/animate/code.js +1 -1
- package/dist/core/animate-ui/components/animate/tabs.js +6 -6
- package/dist/core/animate-ui/components/animate/tooltip.js +1 -1
- package/dist/core/animate-ui/components/base/progress.js +2 -2
- package/dist/core/animate-ui/components/radix/accordion.js +2 -2
- package/dist/core/animate-ui/components/radix/dialog.js +2 -2
- package/dist/core/animate-ui/components/radix/dropdown-menu.js +6 -6
- package/dist/core/animate-ui/components/radix/sheet.js +2 -2
- package/dist/core/animate-ui/components/radix/sidebar.js +8 -8
- package/dist/core/animate-ui/components/radix/toggle-group.js +4 -4
- package/dist/core/animate-ui/components/radix/toggle.js +1 -1
- package/dist/core/animate-ui/primitives/animate/tooltip.js +3 -0
- package/dist/core/badge.js +1 -1
- package/dist/core/breadcrumb.js +1 -1
- package/dist/core/button/button.js +2 -2
- package/dist/core/button/craft-button.js +4 -4
- package/dist/core/button-group.js +1 -1
- package/dist/core/button.js +2 -2
- package/dist/core/card.js +2 -2
- package/dist/core/combobox/combobox.js +3 -3
- package/dist/core/command.js +5 -5
- package/dist/core/field-label-row.js +4 -4
- package/dist/core/form.js +2 -2
- package/dist/core/index.d.ts +1 -1
- package/dist/core/input/input.js +11 -11
- package/dist/core/input-otp/input-otp.js +12 -12
- package/dist/core/label.js +1 -1
- package/dist/core/select.js +6 -6
- package/dist/core/separator.js +1 -1
- package/dist/core/table.js +2 -2
- package/dist/core/textarea/textarea.js +9 -9
- package/dist/{icon-avatar.props-RYtw2eSW.d.ts → icon-avatar.props-BJe0-vva.d.ts} +1 -1
- package/dist/{icon-text-action-card.props-B2ggncUK.d.ts → icon-text-action-card.props-BU7yFi2Q.d.ts} +2 -2
- package/dist/index.d.ts +9 -7
- package/dist/index.js +6 -2
- package/dist/layouts/entry-layout/entry-layout.js +1 -1
- package/dist/layouts/index.d.ts +21 -6
- package/dist/layouts/index.js +1 -1
- package/dist/layouts/minimal-workspace-layout/minimal-workspace-layout.js +10 -18
- package/dist/layouts/minimal-workspace-layout/sidebar-trigger.js +35 -7
- package/dist/layouts/workspace-layout/footer/footer.js +1 -1
- package/dist/markdown/index.d.ts +4 -4
- package/dist/{section-card-B7c5uc08.d.ts → section-card-DqQeQkzU.d.ts} +1 -1
- package/dist/{simple-clickable-card.props-BrPCw7CR.d.ts → simple-clickable-card.props-BhhotZMp.d.ts} +2 -2
- package/dist/{status-badge.props-lKlEOfRt.d.ts → status-badge.props-BVe8CmQZ.d.ts} +1 -1
- package/dist/styles/type-scale.js +153 -0
- package/dist/tailwind-preset.js +120 -1
- package/dist/toast/index.d.ts +1 -1
- package/dist/utils/cn.js +16 -5
- package/dist/utils/color.js +10 -1
- package/dist/utils/index.d.ts +37 -3
- package/dist/utils/index.js +2 -1
- package/dist/utils/variant.js +76 -76
- package/dist/{variant-D81RhpbR.d.ts → variant-DjdaxfIA.d.ts} +6 -1
- package/package.json +6 -2
- package/src/styles/colors.css +23 -2
- package/src/styles/theme.css +8 -3
- package/src/styles/type-scale.css +152 -0
- package/tailwind.preset.ts +23 -0
|
@@ -93,10 +93,10 @@ var sizeStyles = {
|
|
|
93
93
|
headerTriggerPad: "-my-3 py-3 pl-3",
|
|
94
94
|
headerRightPad: "pl-3 pr-3",
|
|
95
95
|
gap: "gap-2",
|
|
96
|
-
primaryTypography: "
|
|
97
|
-
secondaryTypography: "
|
|
98
|
-
primary: "
|
|
99
|
-
secondary: "
|
|
96
|
+
primaryTypography: "type-heading",
|
|
97
|
+
secondaryTypography: "type-secondary",
|
|
98
|
+
primary: "type-heading text-foreground",
|
|
99
|
+
secondary: "type-secondary text-muted-foreground",
|
|
100
100
|
icon: "h-[18px] w-[18px] shrink-0",
|
|
101
101
|
chevron: "h-[18px] w-[18px]",
|
|
102
102
|
collapseTrigger: "h-[18px] w-[18px] min-h-[18px] min-w-[18px] !p-0 [&_svg]:!h-[18px] [&_svg]:!w-[18px] [&_svg]:!min-h-0 [&_svg]:!min-w-0"
|
|
@@ -108,10 +108,10 @@ var sizeStyles = {
|
|
|
108
108
|
headerTriggerPad: "-my-4 py-4 pl-4",
|
|
109
109
|
headerRightPad: "pl-3 pr-4",
|
|
110
110
|
gap: "gap-3",
|
|
111
|
-
primaryTypography: "
|
|
112
|
-
secondaryTypography: "
|
|
113
|
-
primary: "
|
|
114
|
-
secondary: "
|
|
111
|
+
primaryTypography: "type-heading",
|
|
112
|
+
secondaryTypography: "type-secondary",
|
|
113
|
+
primary: "type-heading text-foreground",
|
|
114
|
+
secondary: "type-secondary text-muted-foreground",
|
|
115
115
|
icon: "h-6 w-6 shrink-0",
|
|
116
116
|
chevron: "h-6 w-6",
|
|
117
117
|
collapseTrigger: "h-6 w-6 min-h-6 min-w-6 !p-0 [&_svg]:!h-6 [&_svg]:!w-6 [&_svg]:!min-h-0 [&_svg]:!min-w-0"
|
|
@@ -123,10 +123,10 @@ var sizeStyles = {
|
|
|
123
123
|
headerTriggerPad: "-my-6 py-6 pl-6",
|
|
124
124
|
headerRightPad: "pl-3 pr-6",
|
|
125
125
|
gap: "gap-4",
|
|
126
|
-
primaryTypography: "
|
|
127
|
-
secondaryTypography: "
|
|
128
|
-
primary: "
|
|
129
|
-
secondary: "
|
|
126
|
+
primaryTypography: "type-heading",
|
|
127
|
+
secondaryTypography: "type-secondary",
|
|
128
|
+
primary: "type-heading text-foreground",
|
|
129
|
+
secondary: "type-secondary text-muted-foreground",
|
|
130
130
|
icon: "h-8 w-8 shrink-0",
|
|
131
131
|
chevron: "h-8 w-8",
|
|
132
132
|
collapseTrigger: "h-8 w-8 min-h-8 min-w-8 !p-0 [&_svg]:!h-8 [&_svg]:!w-8 [&_svg]:!min-h-0 [&_svg]:!min-w-0"
|
|
@@ -12,11 +12,8 @@ var SimpleCard = React$1.forwardRef(({ noShadow, noBorder, transparent, title, d
|
|
|
12
12
|
className: cn(noShadow && elevation === void 0 && "shadow-none", noBorder && border === void 0 && "border-0", transparent && "bg-transparent", className),
|
|
13
13
|
children: [(title || description) && /* @__PURE__ */ jsxs(CardHeader, {
|
|
14
14
|
className: "space-y-1",
|
|
15
|
-
children: [title && /* @__PURE__ */ jsx(CardTitle, {
|
|
16
|
-
className: "
|
|
17
|
-
children: title
|
|
18
|
-
}), description && /* @__PURE__ */ jsx(CardDescription, {
|
|
19
|
-
className: "text-sm tracking-normal",
|
|
15
|
+
children: [title && /* @__PURE__ */ jsx(CardTitle, { children: title }), description && /* @__PURE__ */ jsx(CardDescription, {
|
|
16
|
+
className: "tracking-normal",
|
|
20
17
|
children: description
|
|
21
18
|
})]
|
|
22
19
|
}), /* @__PURE__ */ jsx(CardContent, { children })]
|
|
@@ -65,13 +65,13 @@ var CategoryCard = React$1.forwardRef(({ icon, title, description, value, tags,
|
|
|
65
65
|
/* @__PURE__ */ jsxs("span", {
|
|
66
66
|
className: "flex min-w-0 flex-col gap-1",
|
|
67
67
|
children: [/* @__PURE__ */ jsx("span", {
|
|
68
|
-
className: "
|
|
68
|
+
className: "type-heading text-foreground",
|
|
69
69
|
children: truncateTitle ? /* @__PURE__ */ jsx(TruncatedLineWithTooltip, {
|
|
70
70
|
tooltipContent: title,
|
|
71
71
|
children: title
|
|
72
72
|
}) : title
|
|
73
73
|
}), description != null && /* @__PURE__ */ jsx("span", {
|
|
74
|
-
className: cn("
|
|
74
|
+
className: cn("type-body text-muted-foreground", truncateDescription && "line-clamp-2"),
|
|
75
75
|
children: description
|
|
76
76
|
})]
|
|
77
77
|
}),
|
|
@@ -24,7 +24,7 @@ var ChartContainer = React$1.forwardRef(function ChartContainer({ id, className,
|
|
|
24
24
|
ref,
|
|
25
25
|
"data-slot": "chart",
|
|
26
26
|
"data-chart": chartId,
|
|
27
|
-
className: cn("flex w-full min-w-0 flex-col items-stretch aspect-video
|
|
27
|
+
className: cn("flex w-full min-w-0 flex-col items-stretch aspect-video type-caption [&_.recharts-responsive-container]:min-h-0 [&_.recharts-responsive-container]:w-full [&_.recharts-responsive-container]:min-w-0 [&_.recharts-responsive-container]:flex-1 [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden", className),
|
|
28
28
|
...props,
|
|
29
29
|
children: [/* @__PURE__ */ jsx(ChartStyle, {
|
|
30
30
|
id: chartId,
|
|
@@ -82,7 +82,7 @@ function ChartTooltipContent({ active, payload, className, indicator = "dot", hi
|
|
|
82
82
|
if (!active || !payload?.length) return null;
|
|
83
83
|
const nestLabel = payload.length === 1 && indicator !== "dot";
|
|
84
84
|
return /* @__PURE__ */ jsxs("div", {
|
|
85
|
-
className: cn("grid min-w-[10rem] items-start gap-2.5 rounded-[var(--espd-own-radius,var(--espd-radius-overlay,var(--radius-lg)))] border border-border/50 bg-background px-4 py-3
|
|
85
|
+
className: cn("grid min-w-[10rem] items-start gap-2.5 rounded-[var(--espd-own-radius,var(--espd-radius-overlay,var(--radius-lg)))] border border-border/50 bg-background px-4 py-3 type-caption shadow-[shadow:var(--espd-own-elevation,var(--espd-elevation-overlay,var(--shadow-xl)))]", className),
|
|
86
86
|
style: axes.style,
|
|
87
87
|
children: [!nestLabel ? tooltipLabel : null, /* @__PURE__ */ jsx("div", {
|
|
88
88
|
className: "grid gap-2.5",
|
|
@@ -134,7 +134,7 @@ function ChartLegendContent({ className, hideIcon = false, payload, verticalAlig
|
|
|
134
134
|
className: "h-4 w-4 shrink-0 rounded-sm",
|
|
135
135
|
style: { backgroundColor: item.color }
|
|
136
136
|
}), /* @__PURE__ */ jsx("span", {
|
|
137
|
-
className: "
|
|
137
|
+
className: "type-caption",
|
|
138
138
|
children: itemConfig?.label
|
|
139
139
|
})]
|
|
140
140
|
}, index);
|
|
@@ -169,7 +169,7 @@ function ChartLegendList({ items, layout = "rows", columns = 2, value = "value",
|
|
|
169
169
|
return /* @__PURE__ */ jsx("div", {
|
|
170
170
|
"data-slot": "chart-legend",
|
|
171
171
|
"data-layout": layout,
|
|
172
|
-
className: cn("@container w-full min-w-0
|
|
172
|
+
className: cn("@container w-full min-w-0 type-caption", className),
|
|
173
173
|
style,
|
|
174
174
|
...props,
|
|
175
175
|
children: /* @__PURE__ */ jsx("div", {
|
|
@@ -67,7 +67,7 @@ function DonutLegend({ config, order }) {
|
|
|
67
67
|
}));
|
|
68
68
|
if (items.length === 0) return null;
|
|
69
69
|
return /* @__PURE__ */ jsx("div", {
|
|
70
|
-
className: "flex flex-wrap items-center justify-center gap-x-4 gap-y-2 pt-3
|
|
70
|
+
className: "flex flex-wrap items-center justify-center gap-x-4 gap-y-2 pt-3 type-caption",
|
|
71
71
|
children: items.map(({ key, entry }) => {
|
|
72
72
|
return /* @__PURE__ */ jsxs("div", {
|
|
73
73
|
className: "flex items-center gap-1.5",
|
|
@@ -170,7 +170,7 @@ function TreemapLegend({ config, order, colorByKey }) {
|
|
|
170
170
|
}));
|
|
171
171
|
if (items.length === 0) return null;
|
|
172
172
|
return /* @__PURE__ */ jsx("div", {
|
|
173
|
-
className: "flex flex-wrap items-center justify-start gap-x-4 gap-y-2 pt-3
|
|
173
|
+
className: "flex flex-wrap items-center justify-start gap-x-4 gap-y-2 pt-3 type-caption",
|
|
174
174
|
children: items.map(({ key, entry }) => {
|
|
175
175
|
return /* @__PURE__ */ jsxs("div", {
|
|
176
176
|
className: "flex items-center gap-1.5",
|
|
@@ -24,7 +24,7 @@ function Tick() {
|
|
|
24
24
|
/** The lines under (or beside) the title: the meta, then the note in the primary colour. */
|
|
25
25
|
function Lines({ meta, note, wrap, disabled, className }) {
|
|
26
26
|
return /* @__PURE__ */ jsxs("span", {
|
|
27
|
-
className: cn("flex min-w-0 flex-col gap-0.5
|
|
27
|
+
className: cn("flex min-w-0 flex-col gap-0.5 type-secondary text-foreground-secondary", !wrap && "*:truncate", className),
|
|
28
28
|
children: [meta, note && /* @__PURE__ */ jsx("span", {
|
|
29
29
|
className: cn("font-medium", disabled ? "text-foreground-secondary" : "text-primary"),
|
|
30
30
|
children: note
|
|
@@ -60,7 +60,7 @@ function ChoiceCard(props) {
|
|
|
60
60
|
}), /* @__PURE__ */ jsxs("span", {
|
|
61
61
|
className: "flex min-w-0 flex-1 flex-col justify-center gap-0.5 py-2.5 pr-9 pl-1",
|
|
62
62
|
children: [/* @__PURE__ */ jsx("span", {
|
|
63
|
-
className: "line-clamp-2
|
|
63
|
+
className: "line-clamp-2 type-heading text-foreground",
|
|
64
64
|
children: title
|
|
65
65
|
}), /* @__PURE__ */ jsx(Lines, {
|
|
66
66
|
meta,
|
|
@@ -76,7 +76,7 @@ function ChoiceCard(props) {
|
|
|
76
76
|
}), /* @__PURE__ */ jsx("span", {
|
|
77
77
|
className: "relative block px-3 pt-1",
|
|
78
78
|
children: /* @__PURE__ */ jsx("span", {
|
|
79
|
-
className: "line-clamp-2
|
|
79
|
+
className: "line-clamp-2 type-heading text-foreground",
|
|
80
80
|
children: title
|
|
81
81
|
})
|
|
82
82
|
})]
|
|
@@ -16,9 +16,10 @@ import { Braces } from "lucide-react";
|
|
|
16
16
|
* the same grid cell, so any difference in font, size, spacing, padding or
|
|
17
17
|
* wrapping shows up as a caret that drifts from the characters. Ligatures are
|
|
18
18
|
* off because Shiki's token spans break them in the highlight layer but not
|
|
19
|
-
* in the textarea. 16px below `md
|
|
19
|
+
* in the textarea. `type-input` is 16px below `md`, which stops iOS Safari
|
|
20
|
+
* zooming on focus; `leading-normal` gives both layers the same line height.
|
|
20
21
|
*/
|
|
21
|
-
var layerClassName = "col-start-1 row-start-1 m-0 box-border border-0 p-4 font-mono
|
|
22
|
+
var layerClassName = "col-start-1 row-start-1 m-0 box-border border-0 p-4 font-mono type-input leading-normal tracking-normal [font-variant-ligatures:none]";
|
|
22
23
|
/** Highlight layer: Shiki's `<pre>` / `<code>` take their metrics from the layer. */
|
|
23
24
|
var highlightClassName = "[&_pre]:m-0 [&_pre]:p-0 [&_pre]:!bg-transparent [&_pre]:[font:inherit] [&_pre]:[white-space:inherit] [&_pre]:[overflow-wrap:inherit] [&_code]:[font:inherit]";
|
|
24
25
|
/**
|
|
@@ -230,7 +231,7 @@ var CodeEditor = React$1.forwardRef(({ className, style, radius, border, lang =
|
|
|
230
231
|
editor,
|
|
231
232
|
errorContent != null && /* @__PURE__ */ jsx("div", {
|
|
232
233
|
id: errorId,
|
|
233
|
-
className: "
|
|
234
|
+
className: "type-caption text-destructive",
|
|
234
235
|
children: errorContent
|
|
235
236
|
})
|
|
236
237
|
]
|
|
@@ -10,7 +10,7 @@ function DataTableHeader({ headerGroups, showBorder = false, stickyColumns }) {
|
|
|
10
10
|
children: headerGroups.map((headerGroup) => /* @__PURE__ */ jsx(TableRow, { children: headerGroup.headers.map((header, headerIndex) => {
|
|
11
11
|
const sticky = stickyCellProps(stickyColumns, header.column.id, showBorder ? "headBordered" : "head");
|
|
12
12
|
return /* @__PURE__ */ jsx(TableHead, {
|
|
13
|
-
className: cn("
|
|
13
|
+
className: cn("type-label text-gray-500 whitespace-nowrap", showBorder && headerIndex === 0 && "pl-4", sticky.className),
|
|
14
14
|
style: sticky.style,
|
|
15
15
|
children: header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())
|
|
16
16
|
}, header.id);
|
|
@@ -264,7 +264,7 @@ function DateRangePicker({ presets, presetLabels, allowCustom = false, lockEndTo
|
|
|
264
264
|
type: "button",
|
|
265
265
|
onClick: () => handlePresetClick(id),
|
|
266
266
|
onMouseEnter: () => setShowCalendar(false),
|
|
267
|
-
className: cn("flex w-full items-center justify-between gap-6 px-3 py-1.5 text-left
|
|
267
|
+
className: cn("flex w-full items-center justify-between gap-6 px-3 py-1.5 text-left type-label font-normal hover:bg-accent", selectedPresetId === id && "font-medium"),
|
|
268
268
|
children: [resolveLabel(id), selectedPresetId === id && /* @__PURE__ */ jsx(CheckIcon, { className: "size-4 shrink-0 text-primary" })]
|
|
269
269
|
}, id)),
|
|
270
270
|
allowCustom && /* @__PURE__ */ jsxs(Fragment$1, { children: [showPresetRows && /* @__PURE__ */ jsx("div", { className: "mx-1 my-1 h-px bg-border" }), /* @__PURE__ */ jsxs("button", {
|
|
@@ -278,14 +278,14 @@ function DateRangePicker({ presets, presetLabels, allowCustom = false, lockEndTo
|
|
|
278
278
|
onPointerEnter: (event) => {
|
|
279
279
|
if (event.pointerType === "mouse") openCalendarPanel();
|
|
280
280
|
},
|
|
281
|
-
className: cn("flex w-full items-center justify-between gap-6 px-3 py-1.5 text-left
|
|
281
|
+
className: cn("flex w-full items-center justify-between gap-6 px-3 py-1.5 text-left type-label font-normal hover:bg-accent", showCalendar && "bg-accent font-medium"),
|
|
282
282
|
children: [resolveLabel("custom"), /* @__PURE__ */ jsx(ChevronRightIcon, { className: cn("size-4 shrink-0 text-muted-foreground transition-transform duration-200", showCalendar && "rotate-90") })]
|
|
283
283
|
})] }),
|
|
284
284
|
showPresetRows && clearable && hasSelection && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", { className: "mx-1 my-1 h-px bg-border" }), /* @__PURE__ */ jsxs("button", {
|
|
285
285
|
type: "button",
|
|
286
286
|
onClick: handleClear,
|
|
287
287
|
onMouseEnter: () => setShowCalendar(false),
|
|
288
|
-
className: "flex w-full items-center justify-between gap-6 px-3 py-1.5 text-left
|
|
288
|
+
className: "flex w-full items-center justify-between gap-6 px-3 py-1.5 text-left type-label font-normal text-muted-foreground hover:bg-accent",
|
|
289
289
|
children: [clearLabel, /* @__PURE__ */ jsx(XIcon, { className: "size-4 shrink-0" })]
|
|
290
290
|
})] })
|
|
291
291
|
]
|
|
@@ -164,13 +164,18 @@ function rowUsesTagsPropertyArray(key, value, rowMeta) {
|
|
|
164
164
|
return isTagsPropertyKey(key) && isPlainStringArray(value) && !rowMeta?.valueRender && !rowMeta?.valueFormatter;
|
|
165
165
|
}
|
|
166
166
|
var CODE_DISPLAY_CLASSNAME = "min-w-0 w-full max-w-full max-h-[200px] text-start [&_pre]:text-start";
|
|
167
|
+
/**
|
|
168
|
+
* Text roles, the same at every `size` (size moves gaps, avatar and icon
|
|
169
|
+
* sizes only): the key is a field label, the value the muted line beside or
|
|
170
|
+
* under it.
|
|
171
|
+
*/
|
|
172
|
+
var LABEL_TYPOGRAPHY = "type-label font-semibold";
|
|
173
|
+
var VALUE_TYPOGRAPHY = "type-secondary";
|
|
167
174
|
var DYNAMIC_LIST_SIZE_STYLES = {
|
|
168
175
|
sm: {
|
|
169
176
|
listGap: "gap-4",
|
|
170
177
|
rowGap: "gap-3",
|
|
171
178
|
itemGap: "gap-1.5",
|
|
172
|
-
labelTypography: "text-xs font-semibold",
|
|
173
|
-
valueTypography: "text-xs",
|
|
174
179
|
avatarSize: "h-8 w-8",
|
|
175
180
|
avatarFallbackTypography: "text-[10px]",
|
|
176
181
|
rowIcon: "h-3 w-3 shrink-0"
|
|
@@ -179,8 +184,6 @@ var DYNAMIC_LIST_SIZE_STYLES = {
|
|
|
179
184
|
listGap: "gap-5",
|
|
180
185
|
rowGap: "gap-4",
|
|
181
186
|
itemGap: "gap-2",
|
|
182
|
-
labelTypography: "text-sm font-semibold",
|
|
183
|
-
valueTypography: "text-sm",
|
|
184
187
|
avatarSize: "h-10 w-10",
|
|
185
188
|
avatarFallbackTypography: "text-xs",
|
|
186
189
|
rowIcon: "h-3.5 w-3.5 shrink-0"
|
|
@@ -189,8 +192,6 @@ var DYNAMIC_LIST_SIZE_STYLES = {
|
|
|
189
192
|
listGap: "gap-6",
|
|
190
193
|
rowGap: "gap-5",
|
|
191
194
|
itemGap: "gap-3",
|
|
192
|
-
labelTypography: "text-base font-semibold",
|
|
193
|
-
valueTypography: "text-base",
|
|
194
195
|
avatarSize: "h-12 w-12",
|
|
195
196
|
avatarFallbackTypography: "text-sm",
|
|
196
197
|
rowIcon: "h-4 w-4 shrink-0"
|
|
@@ -256,7 +257,7 @@ function wrapTypedValue(value, rowMeta, key, opts, effectiveType) {
|
|
|
256
257
|
case "badge": return /* @__PURE__ */ jsx(Badge, {
|
|
257
258
|
variant: "solid",
|
|
258
259
|
color: "gray",
|
|
259
|
-
className: cn("w-fit max-w-full self-start font-medium",
|
|
260
|
+
className: cn("w-fit max-w-full self-start font-medium", VALUE_TYPOGRAPHY),
|
|
260
261
|
children: base
|
|
261
262
|
});
|
|
262
263
|
case "info": return /* @__PURE__ */ jsx(Alert, {
|
|
@@ -396,10 +397,10 @@ function DynamicList({ items, meta, className, size = "default", labelClassName,
|
|
|
396
397
|
className: cn("flex min-w-0 flex-1 flex-col sm:flex-row sm:gap-0", sizeStyles.itemGap, valueRowAlignStart ? "sm:items-start" : "sm:items-center"),
|
|
397
398
|
style: splitStyle,
|
|
398
399
|
children: [/* @__PURE__ */ jsx("span", {
|
|
399
|
-
className: cn("truncate sm:flex-none sm:basis-[var(--dynamic-list-key-width)]",
|
|
400
|
+
className: cn("truncate sm:flex-none sm:basis-[var(--dynamic-list-key-width)]", LABEL_TYPOGRAPHY, labelClassName),
|
|
400
401
|
children: labelText
|
|
401
402
|
}), /* @__PURE__ */ jsx("div", {
|
|
402
|
-
className: cn("flex min-w-0 text-muted-foreground sm:flex-none sm:basis-[var(--dynamic-list-value-width)] sm:justify-end",
|
|
403
|
+
className: cn("flex min-w-0 text-muted-foreground sm:flex-none sm:basis-[var(--dynamic-list-value-width)] sm:justify-end", VALUE_TYPOGRAPHY, usesBadgeArrayLayout ? "items-start sm:pt-0.5 text-start" : "items-center"),
|
|
403
404
|
children: /* @__PURE__ */ jsx("div", {
|
|
404
405
|
className: cn("min-w-0 max-w-full", !usesBadgeArrayLayout && "sm:truncate sm:text-end", valueClassName),
|
|
405
406
|
children: valueDisplay
|
|
@@ -411,11 +412,11 @@ function DynamicList({ items, meta, className, size = "default", labelClassName,
|
|
|
411
412
|
if (!needsBlockValueLayout) return /* @__PURE__ */ jsx(BasicDetailsCard, {
|
|
412
413
|
icon: hideIcon ? void 0 : rowIcon,
|
|
413
414
|
primaryText: /* @__PURE__ */ jsx("span", {
|
|
414
|
-
className: cn(
|
|
415
|
+
className: cn(LABEL_TYPOGRAPHY, labelClassName),
|
|
415
416
|
children: labelText
|
|
416
417
|
}),
|
|
417
418
|
secondaryText: /* @__PURE__ */ jsx("span", {
|
|
418
|
-
className: cn(
|
|
419
|
+
className: cn(VALUE_TYPOGRAPHY, valueClassName),
|
|
419
420
|
children: valueDisplay
|
|
420
421
|
})
|
|
421
422
|
}, key);
|
|
@@ -430,10 +431,10 @@ function DynamicList({ items, meta, className, size = "default", labelClassName,
|
|
|
430
431
|
}), /* @__PURE__ */ jsxs("div", {
|
|
431
432
|
className: cn("flex min-w-0 flex-1 flex-col", sizeStyles.itemGap),
|
|
432
433
|
children: [/* @__PURE__ */ jsx("span", {
|
|
433
|
-
className: cn(
|
|
434
|
+
className: cn(LABEL_TYPOGRAPHY, labelClassName),
|
|
434
435
|
children: labelText
|
|
435
436
|
}), /* @__PURE__ */ jsx("div", {
|
|
436
|
-
className: cn("min-w-0",
|
|
437
|
+
className: cn("min-w-0", VALUE_TYPOGRAPHY, valueClassName),
|
|
437
438
|
children: valueDisplay
|
|
438
439
|
})]
|
|
439
440
|
})]
|
|
@@ -34,7 +34,7 @@ interface DynamicListProps {
|
|
|
34
34
|
/** Optional per-item overrides keyed by `DynamicListEntry.key`. */
|
|
35
35
|
meta?: Record<string, DynamicListMetaEntry>;
|
|
36
36
|
className?: string;
|
|
37
|
-
/** Overall list spacing and
|
|
37
|
+
/** Overall list spacing (and the avatar size). Text keeps its type role at every size. Default: `"default"`. */
|
|
38
38
|
size?: DynamicListSize;
|
|
39
39
|
/** Extra classes for each row label. */
|
|
40
40
|
labelClassName?: string;
|
|
@@ -6,11 +6,11 @@ function FullSizeError({ title, children, illustration }) {
|
|
|
6
6
|
children: [
|
|
7
7
|
illustration,
|
|
8
8
|
title && /* @__PURE__ */ jsx("h3", {
|
|
9
|
-
className: "
|
|
9
|
+
className: "type-headline",
|
|
10
10
|
children: title
|
|
11
11
|
}),
|
|
12
12
|
/* @__PURE__ */ jsx("div", {
|
|
13
|
-
className: "text-muted-foreground
|
|
13
|
+
className: "type-body text-muted-foreground",
|
|
14
14
|
children
|
|
15
15
|
})
|
|
16
16
|
]
|
|
@@ -64,7 +64,7 @@ function ExpandableTextOverlay({ text, header, footer, closeLabel, origin, open,
|
|
|
64
64
|
}),
|
|
65
65
|
/* @__PURE__ */ jsx("p", {
|
|
66
66
|
tabIndex: 0,
|
|
67
|
-
className: "m-0 min-h-0 flex-1 overflow-y-auto overscroll-contain
|
|
67
|
+
className: "m-0 min-h-0 flex-1 overflow-y-auto overscroll-contain type-body whitespace-pre-line text-foreground-secondary outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
68
68
|
children: text
|
|
69
69
|
}),
|
|
70
70
|
footer && /* @__PURE__ */ jsx("div", {
|
|
@@ -53,7 +53,7 @@ function FilterGroup({ group, selected, onToggle, order, animate, labels }) {
|
|
|
53
53
|
/* @__PURE__ */ jsx("ul", {
|
|
54
54
|
className: "m-0 flex list-none flex-col gap-1 p-0",
|
|
55
55
|
children: view.visible.map((option) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("label", {
|
|
56
|
-
className: "flex cursor-pointer items-center gap-2 rounded-md px-1 py-1
|
|
56
|
+
className: "flex cursor-pointer items-center gap-2 rounded-md px-1 py-1 type-body text-foreground hover:bg-accent",
|
|
57
57
|
children: [
|
|
58
58
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
59
59
|
checked: selected.includes(option.value),
|
|
@@ -64,7 +64,7 @@ function FilterGroup({ group, selected, onToggle, order, animate, labels }) {
|
|
|
64
64
|
children: option.label
|
|
65
65
|
}),
|
|
66
66
|
/* @__PURE__ */ jsx("span", {
|
|
67
|
-
className: "font-mono text-
|
|
67
|
+
className: "type-caption font-mono text-foreground-muted",
|
|
68
68
|
children: option.count
|
|
69
69
|
})
|
|
70
70
|
]
|
|
@@ -85,15 +85,15 @@ var FeatureGrid = React$1.forwardRef(function FeatureGrid({ items, numbered = tr
|
|
|
85
85
|
className: cn("flex gap-3 border-r border-b border-border p-4 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset", index >= pageSize && "motion-safe:animate-rise-in"),
|
|
86
86
|
children: [numbered && /* @__PURE__ */ jsx("span", {
|
|
87
87
|
"aria-hidden": true,
|
|
88
|
-
className: "h-fit shrink-0 rounded-md bg-muted px-1.5 py-0.5 font-mono
|
|
88
|
+
className: "h-fit shrink-0 rounded-md bg-muted px-1.5 py-0.5 font-mono type-caption font-semibold text-muted-foreground",
|
|
89
89
|
children: numberOf(index, items.length)
|
|
90
90
|
}), /* @__PURE__ */ jsxs("div", {
|
|
91
91
|
className: "flex min-w-0 flex-col gap-1",
|
|
92
92
|
children: [/* @__PURE__ */ jsx(Title, {
|
|
93
|
-
className: "m-0
|
|
93
|
+
className: "m-0 type-heading text-foreground [overflow-wrap:anywhere]",
|
|
94
94
|
children: item.title
|
|
95
95
|
}), item.description != null && /* @__PURE__ */ jsx("p", {
|
|
96
|
-
className: "m-0
|
|
96
|
+
className: "m-0 type-body text-muted-foreground",
|
|
97
97
|
children: item.description
|
|
98
98
|
})]
|
|
99
99
|
})]
|
|
@@ -36,9 +36,9 @@ function mergeFiles(existing, incoming, multiple) {
|
|
|
36
36
|
return next;
|
|
37
37
|
}
|
|
38
38
|
var sizeClasses = {
|
|
39
|
-
sm: "h-8
|
|
40
|
-
default: "h-10
|
|
41
|
-
lg: "h-12
|
|
39
|
+
sm: "h-8 type-input",
|
|
40
|
+
default: "h-10 type-input",
|
|
41
|
+
lg: "h-12 type-input"
|
|
42
42
|
};
|
|
43
43
|
var iconSizeClasses = {
|
|
44
44
|
sm: "size-3.5",
|
|
@@ -246,12 +246,12 @@ var FileInput = React$1.forwardRef(function FileInput({ label, required, size, r
|
|
|
246
246
|
children: "*"
|
|
247
247
|
})]
|
|
248
248
|
}), hintContent && /* @__PURE__ */ jsx("span", {
|
|
249
|
-
className: "
|
|
249
|
+
className: "type-caption text-muted-foreground",
|
|
250
250
|
children: hintContent
|
|
251
251
|
})]
|
|
252
252
|
}),
|
|
253
253
|
!label && hintContent && /* @__PURE__ */ jsx("span", {
|
|
254
|
-
className: "
|
|
254
|
+
className: "type-caption text-muted-foreground",
|
|
255
255
|
children: hintContent
|
|
256
256
|
}),
|
|
257
257
|
/* @__PURE__ */ jsxs("div", {
|
|
@@ -303,17 +303,17 @@ var FileInput = React$1.forwardRef(function FileInput({ label, required, size, r
|
|
|
303
303
|
}),
|
|
304
304
|
errorContent && /* @__PURE__ */ jsx("div", {
|
|
305
305
|
id: `${inputId}-error`,
|
|
306
|
-
className: "
|
|
306
|
+
className: "type-caption text-destructive",
|
|
307
307
|
children: errorContent
|
|
308
308
|
}),
|
|
309
309
|
startHelperContent && !errorContent && /* @__PURE__ */ jsx("div", {
|
|
310
310
|
id: helperStartId,
|
|
311
|
-
className: "
|
|
311
|
+
className: "type-caption text-muted-foreground",
|
|
312
312
|
children: startHelperContent
|
|
313
313
|
}),
|
|
314
314
|
endHelperContent && !errorContent && /* @__PURE__ */ jsx("div", {
|
|
315
315
|
id: helperEndId,
|
|
316
|
-
className: "
|
|
316
|
+
className: "type-caption text-end text-muted-foreground",
|
|
317
317
|
children: endHelperContent
|
|
318
318
|
})
|
|
319
319
|
]
|
|
@@ -259,9 +259,9 @@ var FileUpload = React$1.forwardRef(function FileUpload({ className, title = "Dr
|
|
|
259
259
|
children: title
|
|
260
260
|
}), hasDescription ? /* @__PURE__ */ jsx(Typography, {
|
|
261
261
|
id: descriptionId,
|
|
262
|
-
variant: "
|
|
262
|
+
variant: "body",
|
|
263
263
|
as: "p",
|
|
264
|
-
className: "text-
|
|
264
|
+
className: "text-muted-foreground",
|
|
265
265
|
children: description
|
|
266
266
|
}) : null]
|
|
267
267
|
}),
|
|
@@ -293,9 +293,9 @@ var FileUpload = React$1.forwardRef(function FileUpload({ className, title = "Dr
|
|
|
293
293
|
className: "truncate font-semibold",
|
|
294
294
|
children: file.name
|
|
295
295
|
}), /* @__PURE__ */ jsx(Typography, {
|
|
296
|
-
variant: "
|
|
296
|
+
variant: "caption",
|
|
297
297
|
as: "p",
|
|
298
|
-
className: "text-
|
|
298
|
+
className: "text-muted-foreground",
|
|
299
299
|
children: formatFileSize(file.size)
|
|
300
300
|
})]
|
|
301
301
|
}),
|
|
@@ -45,7 +45,7 @@ function FullscreenDialog({ icon, iconSize = "lg", heading, secondaryText, child
|
|
|
45
45
|
})
|
|
46
46
|
}),
|
|
47
47
|
heading != null && /* @__PURE__ */ jsx("h1", {
|
|
48
|
-
className: "
|
|
48
|
+
className: "type-title mb-4 font-normal text-center text-muted-foreground shrink-0",
|
|
49
49
|
children: heading
|
|
50
50
|
}),
|
|
51
51
|
secondaryText != null && /* @__PURE__ */ jsx("div", {
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { useEffect, useLayoutEffect, useRef } from "react";
|
|
2
|
+
//#region src/components/gradient-ring-button/_hooks/use-ring-geometry.ts
|
|
3
|
+
/** The ring's width in px: the stroke, and the padding it sits in around the control (`p-0.5`). */
|
|
4
|
+
var RING_WIDTH = 2;
|
|
5
|
+
/** One full turn of the gradient while the control is engaged, in seconds, when none is given. */
|
|
6
|
+
var DEFAULT_TURN_SECONDS = 1.5;
|
|
7
|
+
/** How long after it appears a cued ring starts its one turn: once whatever it sits in has risen into place. */
|
|
8
|
+
var CUE_DELAY_MS = 800;
|
|
9
|
+
/** The pill's outline, a RING_WIDTH stroke centred half its width inside the control's edge. */
|
|
10
|
+
function place(wrap, svg) {
|
|
11
|
+
const { width, height } = wrap.getBoundingClientRect();
|
|
12
|
+
const inset = RING_WIDTH / 2;
|
|
13
|
+
const w = Math.max(width - RING_WIDTH, 0);
|
|
14
|
+
const h = Math.max(height - RING_WIDTH, 0);
|
|
15
|
+
for (const rect of svg.querySelectorAll("rect")) {
|
|
16
|
+
rect.setAttribute("x", String(inset));
|
|
17
|
+
rect.setAttribute("y", String(inset));
|
|
18
|
+
rect.setAttribute("width", String(w));
|
|
19
|
+
rect.setAttribute("height", String(h));
|
|
20
|
+
rect.setAttribute("rx", String(h / 2));
|
|
21
|
+
rect.setAttribute("ry", String(h / 2));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** Whether this SVG has the timeline methods the turn needs (jsdom, for one, has only some). */
|
|
25
|
+
function hasTimeline(svg) {
|
|
26
|
+
return [
|
|
27
|
+
"pauseAnimations",
|
|
28
|
+
"unpauseAnimations",
|
|
29
|
+
"animationsPaused",
|
|
30
|
+
"getCurrentTime",
|
|
31
|
+
"setCurrentTime"
|
|
32
|
+
].every((name) => typeof svg[name] === "function");
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Pointed at, or holding focus that came from the keyboard. `:hover` counts
|
|
36
|
+
* only where a pointer can hover: a touch screen keeps it true after a tap
|
|
37
|
+
* until the next tap elsewhere, and the ring would turn on and on.
|
|
38
|
+
*/
|
|
39
|
+
function engaged(wrap) {
|
|
40
|
+
return typeof window.matchMedia === "function" && window.matchMedia("(hover: hover)").matches && wrap.matches(":hover") || wrap.querySelector(":focus-visible") !== null;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Plays the ring's turn while it is engaged; let go, it finishes the turn it
|
|
44
|
+
* is on and pauses exactly at the start of the next, so it always rests as it
|
|
45
|
+
* began (start colour on the left, end colour on the right). Engaged again
|
|
46
|
+
* before then, it simply carries on. Returns the cleanup.
|
|
47
|
+
*/
|
|
48
|
+
function runWhileEngaged(wrap, svg, turn, cue) {
|
|
49
|
+
let settle;
|
|
50
|
+
svg.pauseAnimations();
|
|
51
|
+
svg.setCurrentTime(0);
|
|
52
|
+
function play() {
|
|
53
|
+
if (!engaged(wrap)) return;
|
|
54
|
+
clearTimeout(settle);
|
|
55
|
+
settle = void 0;
|
|
56
|
+
svg.unpauseAnimations();
|
|
57
|
+
}
|
|
58
|
+
function letGo() {
|
|
59
|
+
if (engaged(wrap) || svg.animationsPaused() || settle !== void 0) return;
|
|
60
|
+
const into = svg.getCurrentTime() % turn;
|
|
61
|
+
settle = setTimeout(() => {
|
|
62
|
+
settle = void 0;
|
|
63
|
+
svg.pauseAnimations();
|
|
64
|
+
svg.setCurrentTime(Math.round(svg.getCurrentTime() / turn) * turn);
|
|
65
|
+
}, (turn - into) * 1e3);
|
|
66
|
+
}
|
|
67
|
+
const cueing = cue ? setTimeout(() => {
|
|
68
|
+
svg.unpauseAnimations();
|
|
69
|
+
letGo();
|
|
70
|
+
}, CUE_DELAY_MS) : void 0;
|
|
71
|
+
const events = [
|
|
72
|
+
["pointerenter", play],
|
|
73
|
+
["focusin", play],
|
|
74
|
+
["pointerleave", letGo],
|
|
75
|
+
["focusout", letGo]
|
|
76
|
+
];
|
|
77
|
+
for (const [name, handler] of events) wrap.addEventListener(name, handler);
|
|
78
|
+
return () => {
|
|
79
|
+
clearTimeout(settle);
|
|
80
|
+
clearTimeout(cueing);
|
|
81
|
+
for (const [name, handler] of events) wrap.removeEventListener(name, handler);
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Keeps the ring's SVG outline the shape of its control (a pill is a
|
|
86
|
+
* rectangle whose corner radius is half its height, measured, since SVG
|
|
87
|
+
* cannot express it otherwise), and runs the ring's turn (`turn` seconds a
|
|
88
|
+
* revolution, the SMIL `dur`) only while the control is pointed at or focused
|
|
89
|
+
* from the keyboard. Cued, it also turns once by itself as it appears.
|
|
90
|
+
*/
|
|
91
|
+
function useRingGeometry(moving, turn, cue = false) {
|
|
92
|
+
const wrapRef = useRef(null);
|
|
93
|
+
const svgRef = useRef(null);
|
|
94
|
+
useLayoutEffect(() => {
|
|
95
|
+
const wrap = wrapRef.current;
|
|
96
|
+
const svg = svgRef.current;
|
|
97
|
+
if (!wrap || !svg) return;
|
|
98
|
+
place(wrap, svg);
|
|
99
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
100
|
+
const observer = new ResizeObserver(() => place(wrap, svg));
|
|
101
|
+
observer.observe(wrap);
|
|
102
|
+
return () => observer.disconnect();
|
|
103
|
+
}, []);
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
const wrap = wrapRef.current;
|
|
106
|
+
const svg = svgRef.current;
|
|
107
|
+
if (!moving || !wrap || !svg || !hasTimeline(svg)) return;
|
|
108
|
+
return runWhileEngaged(wrap, svg, turn, cue);
|
|
109
|
+
}, [moving, turn]);
|
|
110
|
+
return {
|
|
111
|
+
wrapRef,
|
|
112
|
+
svgRef
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
export { DEFAULT_TURN_SECONDS, RING_WIDTH, useRingGeometry };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn.js";
|
|
2
|
+
import { Button } from "../button/button.js";
|
|
3
|
+
import { DEFAULT_TURN_SECONDS } from "./_hooks/use-ring-geometry.js";
|
|
4
|
+
import { GradientRing } from "./gradient-ring.js";
|
|
5
|
+
import * as React$1 from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/gradient-ring-button/gradient-ring-button.tsx
|
|
8
|
+
/**
|
|
9
|
+
* The button inside the ring: clear in every state (the surface behind shows
|
|
10
|
+
* through; the ring is an SVG outline, so nothing behind needs covering),
|
|
11
|
+
* plain text, no shadow. Its own rings are off too: the ghost Button draws
|
|
12
|
+
* one on hover (2px, with a 2px offset painted in the page background) as
|
|
13
|
+
* well as on focus, and either covers the gradient ring with a dark band.
|
|
14
|
+
* The gradient ring is the hover and focus indicator instead.
|
|
15
|
+
*/
|
|
16
|
+
var CLEAR = "rounded-full border-0 bg-transparent font-semibold text-foreground shadow-none hover:bg-transparent hover:ring-0 hover:ring-offset-0 focus-visible:bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:outline-none active:bg-transparent";
|
|
17
|
+
/**
|
|
18
|
+
* A clear pill button with a 2px border in the theme's gradient tokens that
|
|
19
|
+
* turns clockwise while it is pointed at or focused from the keyboard, and
|
|
20
|
+
* settles back when let go (see `GradientRing`). For the one step into
|
|
21
|
+
* something new on a surface, where a filled primary button is too loud.
|
|
22
|
+
*
|
|
23
|
+
* Every prop of the styled Button passes through except `variant` and
|
|
24
|
+
* `color`. `disabled` fades the ring and holds it still; `fullWidth`
|
|
25
|
+
* (default `false`) makes the ring the full width too.
|
|
26
|
+
*/
|
|
27
|
+
var GradientRingButton = React$1.forwardRef(({ turnSeconds = DEFAULT_TURN_SECONDS, cue = false, fullWidth = false, disabled, className, ...props }, ref) => /* @__PURE__ */ jsx(GradientRing, {
|
|
28
|
+
wide: fullWidth,
|
|
29
|
+
quiet: Boolean(disabled),
|
|
30
|
+
cue,
|
|
31
|
+
turnSeconds,
|
|
32
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
33
|
+
ref,
|
|
34
|
+
...props,
|
|
35
|
+
variant: "ghost",
|
|
36
|
+
color: "gray",
|
|
37
|
+
fullWidth,
|
|
38
|
+
disabled,
|
|
39
|
+
className: cn(CLEAR, className)
|
|
40
|
+
})
|
|
41
|
+
}));
|
|
42
|
+
GradientRingButton.displayName = "GradientRingButton";
|
|
43
|
+
//#endregion
|
|
44
|
+
export { GradientRingButton };
|