@tryghost/shade 0.1.0-alpha.3 → 0.1.0-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -64
- package/es/components/page-templates/list-page.js +2 -1
- package/es/components/page-templates/list-page.js.map +1 -1
- package/es/components/patterns/filter-bar.js +4 -6
- package/es/components/patterns/filter-bar.js.map +1 -1
- package/es/components/patterns/filters.js +35 -22
- package/es/components/patterns/filters.js.map +1 -1
- package/es/components/patterns/gh-chart.js +6 -3
- package/es/components/patterns/gh-chart.js.map +1 -1
- package/es/components/patterns/image-upload.js +20 -15
- package/es/components/patterns/image-upload.js.map +1 -1
- package/es/components/patterns/page-header.js +18 -43
- package/es/components/patterns/page-header.js.map +1 -1
- package/es/components/patterns/setting-group-variants.js +1 -1
- package/es/components/patterns/setting-group-variants.js.map +1 -1
- package/es/components/patterns/setting-group.js +2 -2
- package/es/components/patterns/setting-group.js.map +1 -1
- package/es/components/patterns/settings-modal.js +2 -2
- package/es/components/patterns/settings-modal.js.map +1 -1
- package/es/components/patterns/share-modal.js +3 -15
- package/es/components/patterns/share-modal.js.map +1 -1
- package/es/components/ui/alert-dialog.js +3 -5
- package/es/components/ui/alert-dialog.js.map +1 -1
- package/es/components/ui/avatar.js +8 -4
- package/es/components/ui/avatar.js.map +1 -1
- package/es/components/ui/badge-variants.js +1 -1
- package/es/components/ui/badge-variants.js.map +1 -1
- package/es/components/ui/banner-variants.js +13 -5
- package/es/components/ui/banner-variants.js.map +1 -1
- package/es/components/ui/banner.js +2 -0
- package/es/components/ui/banner.js.map +1 -1
- package/es/components/ui/button-variants.js +2 -33
- package/es/components/ui/button-variants.js.map +1 -1
- package/es/components/ui/button.js +17 -5
- package/es/components/ui/button.js.map +1 -1
- package/es/components/ui/calendar.js +5 -6
- package/es/components/ui/calendar.js.map +1 -1
- package/es/components/ui/card-variants.js +3 -2
- package/es/components/ui/card-variants.js.map +1 -1
- package/es/components/ui/card.js +7 -4
- package/es/components/ui/card.js.map +1 -1
- package/es/components/ui/chart.js +2 -29
- package/es/components/ui/chart.js.map +1 -1
- package/es/components/ui/checkbox.js +1 -1
- package/es/components/ui/checkbox.js.map +1 -1
- package/es/components/ui/combobox.js +2 -2
- package/es/components/ui/combobox.js.map +1 -1
- package/es/components/ui/copy-field.js +2 -4
- package/es/components/ui/copy-field.js.map +1 -1
- package/es/components/ui/data-list.js +2 -4
- package/es/components/ui/data-list.js.map +1 -1
- package/es/components/ui/dialog.js +34 -10
- package/es/components/ui/dialog.js.map +1 -1
- package/es/components/ui/dropzone-variants.js +26 -10
- package/es/components/ui/dropzone-variants.js.map +1 -1
- package/es/components/ui/dropzone.js +2 -2
- package/es/components/ui/dropzone.js.map +1 -1
- package/es/components/ui/field.js +2 -2
- package/es/components/ui/field.js.map +1 -1
- package/es/components/ui/floating-sidebar.js +20 -8
- package/es/components/ui/floating-sidebar.js.map +1 -1
- package/es/components/ui/image-overlay-button.js +2 -2
- package/es/components/ui/image-overlay-button.js.map +1 -1
- package/es/components/ui/indicator-variants.js +2 -2
- package/es/components/ui/indicator-variants.js.map +1 -1
- package/es/components/ui/input-group-variants.js +5 -5
- package/es/components/ui/input-group-variants.js.map +1 -1
- package/es/components/ui/input-group.js +4 -7
- package/es/components/ui/input-group.js.map +1 -1
- package/es/components/ui/input-surface.js +3 -3
- package/es/components/ui/input-surface.js.map +1 -1
- package/es/components/ui/input.js +1 -1
- package/es/components/ui/input.js.map +1 -1
- package/es/components/ui/navbar.js +1 -3
- package/es/components/ui/navbar.js.map +1 -1
- package/es/components/ui/pagemenu.js +51 -15
- package/es/components/ui/pagemenu.js.map +1 -1
- package/es/components/ui/radio-group-variants.js +1 -1
- package/es/components/ui/radio-group-variants.js.map +1 -1
- package/es/components/ui/select-variants.js +6 -14
- package/es/components/ui/select-variants.js.map +1 -1
- package/es/components/ui/select.js +1 -4
- package/es/components/ui/select.js.map +1 -1
- package/es/components/ui/sheet.js +1 -1
- package/es/components/ui/sheet.js.map +1 -1
- package/es/components/ui/sidebar.js +1 -1
- package/es/components/ui/simple-pagination.js +4 -7
- package/es/components/ui/simple-pagination.js.map +1 -1
- package/es/components/ui/sticky-footer.js +1 -1
- package/es/components/ui/sticky-footer.js.map +1 -1
- package/es/components/ui/table.js +2 -2
- package/es/components/ui/table.js.map +1 -1
- package/es/components/ui/tabs-variants.js +23 -1
- package/es/components/ui/tabs-variants.js.map +1 -1
- package/es/components/ui/tabs.js +102 -21
- package/es/components/ui/tabs.js.map +1 -1
- package/es/components/ui/textarea.js +1 -1
- package/es/components/ui/textarea.js.map +1 -1
- package/es/components/ui/toast.js +2 -0
- package/es/components/ui/toggle-group.js +1 -3
- package/es/components/ui/toggle-group.js.map +1 -1
- package/es/components/ui/toggle-variants.js +1 -7
- package/es/components/ui/toggle-variants.js.map +1 -1
- package/es/components/ui/toggle.js +1 -2
- package/es/components/ui/toggle.js.map +1 -1
- package/es/components/ui/token-field.js +4 -4
- package/es/components/ui/token-field.js.map +1 -1
- package/es/components/ui/tooltip.js +8 -17
- package/es/components/ui/tooltip.js.map +1 -1
- package/es/components.js +6 -5
- package/es/index.js +6 -5
- package/es/lib/date-utils.js +151 -0
- package/es/lib/date-utils.js.map +1 -0
- package/es/lib/ds-utils.js +16 -72
- package/es/lib/ds-utils.js.map +1 -1
- package/es/lib/utils.js +3 -2
- package/es/providers/header-tooltip-provider.js +1 -4
- package/es/providers/header-tooltip-provider.js.map +1 -1
- package/es/providers/shade-context.js +1 -1
- package/es/providers/shade-context.js.map +1 -1
- package/es/providers/shade-provider.js +3 -3
- package/es/providers/shade-provider.js.map +1 -1
- package/es/shade-app.js +3 -3
- package/es/shade-app.js.map +1 -1
- package/es/shade-scope.js +2 -2
- package/es/shade-scope.js.map +1 -1
- package/es/tokens.js +56 -8
- package/es/tokens.js.map +1 -1
- package/es/utils.js +3 -2
- package/package.json +6 -6
- package/styles.css +119 -12
- package/tailwind.theme.css +235 -187
- package/theme-variables.css +398 -42
- package/types/components/page-templates/list-page.d.ts +2 -1
- package/types/components/page-templates/list-page.d.ts.map +1 -1
- package/types/components/patterns/filter-bar.d.ts.map +1 -1
- package/types/components/patterns/filters.d.ts +2 -4
- package/types/components/patterns/filters.d.ts.map +1 -1
- package/types/components/patterns/gh-chart.d.ts.map +1 -1
- package/types/components/patterns/image-upload.d.ts.map +1 -1
- package/types/components/patterns/page-header.d.ts +6 -11
- package/types/components/patterns/page-header.d.ts.map +1 -1
- package/types/components/patterns/settings-modal.d.ts.map +1 -1
- package/types/components/patterns/share-modal.d.ts +1 -1
- package/types/components/patterns/share-modal.d.ts.map +1 -1
- package/types/components/ui/avatar.d.ts.map +1 -1
- package/types/components/ui/banner-variants.d.ts +1 -1
- package/types/components/ui/banner-variants.d.ts.map +1 -1
- package/types/components/ui/banner.d.ts.map +1 -1
- package/types/components/ui/button-variants.d.ts +0 -1
- package/types/components/ui/button-variants.d.ts.map +1 -1
- package/types/components/ui/button.d.ts +6 -1
- package/types/components/ui/button.d.ts.map +1 -1
- package/types/components/ui/calendar.d.ts.map +1 -1
- package/types/components/ui/card-variants.d.ts +1 -1
- package/types/components/ui/card-variants.d.ts.map +1 -1
- package/types/components/ui/card.d.ts +1 -1
- package/types/components/ui/card.d.ts.map +1 -1
- package/types/components/ui/chart.d.ts +1 -17
- package/types/components/ui/chart.d.ts.map +1 -1
- package/types/components/ui/combobox.d.ts.map +1 -1
- package/types/components/ui/copy-field.d.ts.map +1 -1
- package/types/components/ui/data-list.d.ts.map +1 -1
- package/types/components/ui/dialog.d.ts +11 -2
- package/types/components/ui/dialog.d.ts.map +1 -1
- package/types/components/ui/dropzone-variants.d.ts +2 -1
- package/types/components/ui/dropzone-variants.d.ts.map +1 -1
- package/types/components/ui/floating-sidebar.d.ts +6 -0
- package/types/components/ui/floating-sidebar.d.ts.map +1 -1
- package/types/components/ui/image-overlay-button.d.ts +1 -1
- package/types/components/ui/image-overlay-button.d.ts.map +1 -1
- package/types/components/ui/input-group-variants.d.ts.map +1 -1
- package/types/components/ui/input-group.d.ts.map +1 -1
- package/types/components/ui/input-surface.d.ts +3 -3
- package/types/components/ui/input-surface.d.ts.map +1 -1
- package/types/components/ui/navbar.d.ts.map +1 -1
- package/types/components/ui/pagemenu.d.ts +3 -0
- package/types/components/ui/pagemenu.d.ts.map +1 -1
- package/types/components/ui/select-variants.d.ts +0 -1
- package/types/components/ui/select-variants.d.ts.map +1 -1
- package/types/components/ui/select.d.ts +1 -1
- package/types/components/ui/select.d.ts.map +1 -1
- package/types/components/ui/sheet.d.ts.map +1 -1
- package/types/components/ui/simple-pagination.d.ts.map +1 -1
- package/types/components/ui/tabs-variants.d.ts +5 -1
- package/types/components/ui/tabs-variants.d.ts.map +1 -1
- package/types/components/ui/tabs.d.ts.map +1 -1
- package/types/components/ui/toast.d.ts +2 -0
- package/types/components/ui/toast.d.ts.map +1 -0
- package/types/components/ui/toggle-group.d.ts +4 -6
- package/types/components/ui/toggle-group.d.ts.map +1 -1
- package/types/components/ui/toggle-variants.d.ts +0 -1
- package/types/components/ui/toggle-variants.d.ts.map +1 -1
- package/types/components/ui/toggle.d.ts +2 -3
- package/types/components/ui/toggle.d.ts.map +1 -1
- package/types/components/ui/token-field.d.ts +3 -3
- package/types/components/ui/token-field.d.ts.map +1 -1
- package/types/components/ui/tooltip.d.ts.map +1 -1
- package/types/components.d.ts +1 -0
- package/types/components.d.ts.map +1 -1
- package/types/lib/date-utils.d.ts +17 -0
- package/types/lib/date-utils.d.ts.map +1 -0
- package/types/lib/ds-utils.d.ts +2 -16
- package/types/lib/ds-utils.d.ts.map +1 -1
- package/types/lib/utils.d.ts +1 -0
- package/types/lib/utils.d.ts.map +1 -1
- package/types/providers/header-tooltip-provider.d.ts.map +1 -1
- package/types/providers/shade-context.d.ts +2 -1
- package/types/providers/shade-context.d.ts.map +1 -1
- package/types/providers/shade-provider.d.ts +1 -1
- package/types/providers/shade-provider.d.ts.map +1 -1
- package/types/shade-app.d.ts +5 -2
- package/types/shade-app.d.ts.map +1 -1
- package/types/tokens.d.ts +1 -1
- package/types/tokens.d.ts.map +1 -1
- package/types/utils.d.ts +2 -1
- package/types/utils.d.ts.map +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { calculateYAxisWidth, cn,
|
|
1
|
+
import { calculateYAxisWidth, cn, formatNumber, getYRange } from "../../lib/ds-utils.js";
|
|
2
|
+
import { formatDisplayDateWithRange } from "../../lib/date-utils.js";
|
|
3
|
+
import { useShade } from "../../providers/shade-context.js";
|
|
2
4
|
import { AlignedAxisTick, ChartContainer, ChartTooltip } from "../ui/chart.js";
|
|
3
5
|
import { Area, AreaChart, CartesianGrid, XAxis, YAxis } from "recharts";
|
|
4
6
|
import { TrendingDown, TrendingUp } from "lucide-react";
|
|
@@ -49,6 +51,7 @@ var GhCustomTooltipContent = ({ active, payload, range, showHours, color }) => {
|
|
|
49
51
|
});
|
|
50
52
|
};
|
|
51
53
|
var GhAreaChart = ({ data, range, yAxisRange, color = "var(--chart-blue)", id, className, syncId, allowDataOverflow = false, showYAxisValues = true, showHorizontalLines = true, dataFormatter = formatNumber, showHours = false, tooltipContent }) => {
|
|
54
|
+
const { admin7Design } = useShade();
|
|
52
55
|
const yRange = yAxisRange || [getYRange(data).min, getYRange(data).max];
|
|
53
56
|
const chartConfig = { value: { label: data[0]?.label || "Value" } };
|
|
54
57
|
const baseValue = yRange[0];
|
|
@@ -125,11 +128,11 @@ var GhAreaChart = ({ data, range, yAxisRange, color = "var(--chart-blue)", id, c
|
|
|
125
128
|
children: [/* @__PURE__ */ jsx("stop", {
|
|
126
129
|
offset: "5%",
|
|
127
130
|
stopColor: color,
|
|
128
|
-
stopOpacity: .8
|
|
131
|
+
stopOpacity: admin7Design ? .5 : .8
|
|
129
132
|
}), /* @__PURE__ */ jsx("stop", {
|
|
130
133
|
offset: "95%",
|
|
131
134
|
stopColor: color,
|
|
132
|
-
stopOpacity: .1
|
|
135
|
+
stopOpacity: admin7Design ? .5 : .1
|
|
133
136
|
})]
|
|
134
137
|
}) }),
|
|
135
138
|
/* @__PURE__ */ jsx(Area, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gh-chart.js","names":[],"sources":["../../../src/components/patterns/gh-chart.tsx"],"sourcesContent":["import {\n calculateYAxisWidth,\n cn,\n formatDisplayDateWithRange,\n formatNumber,\n getYRange,\n} from '@/lib/utils';\nimport React from 'react';\nimport { AlignedAxisTick, ChartConfig, ChartContainer, ChartTooltip } from '@/components/ui/chart';\nimport { Area, AreaChart, CartesianGrid, XAxis, YAxis } from 'recharts';\nimport { TrendingDown, TrendingUp } from 'lucide-react';\n\n// A Ghost specific charts for analytics re-using ShadCN/UI and Recharts components\n\ninterface TooltipPayload {\n value: number;\n payload: {\n date?: string;\n formattedValue?: string;\n label?: string;\n diffValue?: null | number;\n formattedDiffValue?: null | string;\n };\n}\n\ninterface TooltipProps {\n active?: boolean;\n payload?: TooltipPayload[];\n range?: number;\n showHours?: boolean;\n color?: string;\n}\n\nconst GhCustomTooltipContent = ({ active, payload, range, showHours, color }: TooltipProps) => {\n if (!active || !payload?.length) {\n return null;\n }\n\n const { date, formattedValue, label, diffValue, formattedDiffValue } = payload[0].payload;\n const displayValue = formattedValue || payload[0].value;\n\n return (\n <div className=\"min-w-[120px] rounded-lg border bg-background px-3 py-2 shadow-lg\">\n {date && (\n <div className=\"text-sm text-foreground\">\n {formatDisplayDateWithRange(date, range || 0, showHours)}\n </div>\n )}\n <div className=\"flex items-start gap-2\">\n <span\n className=\"mt-1.5 inline-block size-2 rounded-full opacity-50\"\n style={{ backgroundColor: color || 'var(--chart-blue)' }}\n ></span>\n <div className=\"flex grow items-start justify-between gap-5\">\n {label && <div className=\"text-sm text-muted-foreground\">{label}</div>}\n <div className=\"flex flex-col items-end font-mono font-medium\">\n {displayValue}\n\n {diffValue ? (\n diffValue < 0 && (\n <div className=\"flex items-center gap-0.5 text-state-danger\">\n <TrendingDown size={14} strokeWidth={1.5} />\n <span>{formattedDiffValue}</span>\n </div>\n )\n ) : (\n <></>\n )}\n {diffValue ? (\n diffValue > 0 && (\n <div className=\"flex items-center gap-0.5 text-state-success\">\n <TrendingUp size={14} strokeWidth={1.5} />\n <span>{formattedDiffValue}</span>\n </div>\n )\n ) : (\n <></>\n )}\n {/* {diffValue !== undefined ? diffValue === 0 && (\n <span>—</span>\n ) : <></>} */}\n </div>\n </div>\n </div>\n </div>\n );\n};\n\nexport type GhAreaChartDataItem = {\n date: string;\n value: number;\n formattedValue: string;\n label: string;\n};\n\ninterface GhAreaChartProps {\n data: GhAreaChartDataItem[];\n range: number;\n yAxisRange?: [number, number];\n color?: string;\n id: string;\n className?: string;\n syncId?: string;\n allowDataOverflow?: boolean;\n showYAxisValues?: boolean;\n showHorizontalLines?: boolean;\n dataFormatter?: (value: number) => string;\n showHours?: boolean;\n tooltipContent?: React.ReactElement;\n}\n\nconst GhAreaChart: React.FC<GhAreaChartProps> = ({\n data,\n range,\n yAxisRange,\n color = 'var(--chart-blue)',\n id,\n className,\n syncId,\n allowDataOverflow = false,\n showYAxisValues = true,\n showHorizontalLines = true,\n dataFormatter = formatNumber,\n showHours = false,\n tooltipContent,\n}) => {\n const yRange = yAxisRange || [getYRange(data).min, getYRange(data).max];\n const chartConfig = {\n value: {\n label: data[0]?.label || 'Value',\n },\n } satisfies ChartConfig;\n\n // Use yRange as domain and set baseValue to the minimum\n const baseValue = yRange[0];\n\n // Calculate midpoint and create ticks array\n const midValue = (yRange[0] + yRange[1]) / 2;\n const isWholeMid = Number.isInteger(midValue);\n const yTicks = isWholeMid ? [yRange[0], midValue, yRange[1]] : yRange;\n\n const xTickHoursOnly = showHours && range === 1;\n const xTicks = data.length > 0 ? [...new Set([data[0].date, data[data.length - 1].date])] : [];\n\n return (\n <ChartContainer className={cn('w-full', className)} config={chartConfig}>\n <AreaChart\n data={data}\n margin={{\n left: 4,\n right: 4,\n top: showHorizontalLines ? 24 : 4,\n }}\n syncId={syncId}\n >\n <CartesianGrid horizontal={showHorizontalLines} stroke=\"var(--border)\" vertical={false} />\n <XAxis\n axisLine={{ stroke: 'var(--border)', strokeWidth: 1 }}\n dataKey=\"date\"\n interval={0}\n tick={(props) => (\n <AlignedAxisTick\n {...props}\n formatter={(value) =>\n formatDisplayDateWithRange(String(value), range, showHours, xTickHoursOnly)\n }\n textAnchor={xTicks.length === 1 ? 'middle' : undefined}\n />\n )}\n tickFormatter={(value) => formatDisplayDateWithRange(String(value), range, showHours)}\n tickLine={false}\n tickMargin={10}\n ticks={xTicks}\n />\n <YAxis\n allowDataOverflow={allowDataOverflow}\n axisLine={false}\n domain={allowDataOverflow ? undefined : yRange}\n scale=\"linear\"\n tickFormatter={(value: number) => {\n return dataFormatter(value);\n }}\n tickLine={false}\n ticks={yTicks}\n width={showYAxisValues ? calculateYAxisWidth(yRange, dataFormatter) : 0}\n />\n <ChartTooltip\n content={\n tooltipContent || (\n <GhCustomTooltipContent color={color} range={range} showHours={showHours} />\n )\n }\n cursor={true}\n isAnimationActive={false}\n position={{ y: 10 }}\n />\n <defs>\n <linearGradient id={`fillChart-${id}`} x1=\"0\" x2=\"0\" y1=\"0\" y2=\"1\">\n <stop offset=\"5%\" stopColor={color} stopOpacity={0.8} />\n <stop offset=\"95%\" stopColor={color} stopOpacity={0.1} />\n </linearGradient>\n </defs>\n <Area\n baseValue={baseValue}\n dataKey=\"value\"\n fill={`url(#fillChart-${id})`}\n fillOpacity={0.2}\n isAnimationActive={false}\n stroke={color}\n strokeWidth={1.5}\n type=\"linear\"\n />\n </AreaChart>\n </ChartContainer>\n );\n};\n\nexport { GhAreaChart, GhCustomTooltipContent };\n\nexport type { TooltipProps };\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"gh-chart.js","names":[],"sources":["../../../src/components/patterns/gh-chart.tsx"],"sourcesContent":["import {\n calculateYAxisWidth,\n cn,\n formatDisplayDateWithRange,\n formatNumber,\n getYRange,\n} from '@/lib/utils';\nimport React from 'react';\nimport { AlignedAxisTick, ChartConfig, ChartContainer, ChartTooltip } from '@/components/ui/chart';\nimport { Area, AreaChart, CartesianGrid, XAxis, YAxis } from 'recharts';\nimport { TrendingDown, TrendingUp } from 'lucide-react';\nimport { useShade } from '@/providers/shade-context';\n\n// A Ghost specific charts for analytics re-using ShadCN/UI and Recharts components\n\ninterface TooltipPayload {\n value: number;\n payload: {\n date?: string;\n formattedValue?: string;\n label?: string;\n diffValue?: null | number;\n formattedDiffValue?: null | string;\n };\n}\n\ninterface TooltipProps {\n active?: boolean;\n payload?: TooltipPayload[];\n range?: number;\n showHours?: boolean;\n color?: string;\n}\n\nconst GhCustomTooltipContent = ({ active, payload, range, showHours, color }: TooltipProps) => {\n if (!active || !payload?.length) {\n return null;\n }\n\n const { date, formattedValue, label, diffValue, formattedDiffValue } = payload[0].payload;\n const displayValue = formattedValue || payload[0].value;\n\n return (\n <div className=\"min-w-[120px] rounded-lg border bg-background px-3 py-2 shadow-lg\">\n {date && (\n <div className=\"text-sm text-foreground\">\n {formatDisplayDateWithRange(date, range || 0, showHours)}\n </div>\n )}\n <div className=\"flex items-start gap-2\">\n <span\n className=\"mt-1.5 inline-block size-2 rounded-full opacity-50\"\n style={{ backgroundColor: color || 'var(--chart-blue)' }}\n ></span>\n <div className=\"flex grow items-start justify-between gap-5\">\n {label && <div className=\"text-sm text-muted-foreground\">{label}</div>}\n <div className=\"flex flex-col items-end font-mono font-medium\">\n {displayValue}\n\n {diffValue ? (\n diffValue < 0 && (\n <div className=\"flex items-center gap-0.5 text-state-danger\">\n <TrendingDown size={14} strokeWidth={1.5} />\n <span>{formattedDiffValue}</span>\n </div>\n )\n ) : (\n <></>\n )}\n {diffValue ? (\n diffValue > 0 && (\n <div className=\"flex items-center gap-0.5 text-state-success\">\n <TrendingUp size={14} strokeWidth={1.5} />\n <span>{formattedDiffValue}</span>\n </div>\n )\n ) : (\n <></>\n )}\n {/* {diffValue !== undefined ? diffValue === 0 && (\n <span>—</span>\n ) : <></>} */}\n </div>\n </div>\n </div>\n </div>\n );\n};\n\nexport type GhAreaChartDataItem = {\n date: string;\n value: number;\n formattedValue: string;\n label: string;\n};\n\ninterface GhAreaChartProps {\n data: GhAreaChartDataItem[];\n range: number;\n yAxisRange?: [number, number];\n color?: string;\n id: string;\n className?: string;\n syncId?: string;\n allowDataOverflow?: boolean;\n showYAxisValues?: boolean;\n showHorizontalLines?: boolean;\n dataFormatter?: (value: number) => string;\n showHours?: boolean;\n tooltipContent?: React.ReactElement;\n}\n\nconst GhAreaChart: React.FC<GhAreaChartProps> = ({\n data,\n range,\n yAxisRange,\n color = 'var(--chart-blue)',\n id,\n className,\n syncId,\n allowDataOverflow = false,\n showYAxisValues = true,\n showHorizontalLines = true,\n dataFormatter = formatNumber,\n showHours = false,\n tooltipContent,\n}) => {\n const { admin7Design } = useShade();\n const yRange = yAxisRange || [getYRange(data).min, getYRange(data).max];\n const chartConfig = {\n value: {\n label: data[0]?.label || 'Value',\n },\n } satisfies ChartConfig;\n\n // Use yRange as domain and set baseValue to the minimum\n const baseValue = yRange[0];\n\n // Calculate midpoint and create ticks array\n const midValue = (yRange[0] + yRange[1]) / 2;\n const isWholeMid = Number.isInteger(midValue);\n const yTicks = isWholeMid ? [yRange[0], midValue, yRange[1]] : yRange;\n\n const xTickHoursOnly = showHours && range === 1;\n const xTicks = data.length > 0 ? [...new Set([data[0].date, data[data.length - 1].date])] : [];\n\n return (\n <ChartContainer className={cn('w-full', className)} config={chartConfig}>\n <AreaChart\n data={data}\n margin={{\n left: 4,\n right: 4,\n top: showHorizontalLines ? 24 : 4,\n }}\n syncId={syncId}\n >\n <CartesianGrid horizontal={showHorizontalLines} stroke=\"var(--border)\" vertical={false} />\n <XAxis\n axisLine={{ stroke: 'var(--border)', strokeWidth: 1 }}\n dataKey=\"date\"\n interval={0}\n tick={(props) => (\n <AlignedAxisTick\n {...props}\n formatter={(value) =>\n formatDisplayDateWithRange(String(value), range, showHours, xTickHoursOnly)\n }\n textAnchor={xTicks.length === 1 ? 'middle' : undefined}\n />\n )}\n tickFormatter={(value) => formatDisplayDateWithRange(String(value), range, showHours)}\n tickLine={false}\n tickMargin={10}\n ticks={xTicks}\n />\n <YAxis\n allowDataOverflow={allowDataOverflow}\n axisLine={false}\n domain={allowDataOverflow ? undefined : yRange}\n scale=\"linear\"\n tickFormatter={(value: number) => {\n return dataFormatter(value);\n }}\n tickLine={false}\n ticks={yTicks}\n width={showYAxisValues ? calculateYAxisWidth(yRange, dataFormatter) : 0}\n />\n <ChartTooltip\n content={\n tooltipContent || (\n <GhCustomTooltipContent color={color} range={range} showHours={showHours} />\n )\n }\n cursor={true}\n isAnimationActive={false}\n position={{ y: 10 }}\n />\n <defs>\n <linearGradient id={`fillChart-${id}`} x1=\"0\" x2=\"0\" y1=\"0\" y2=\"1\">\n {/* admin7Design charts are flat: an even tint under the line. */}\n <stop offset=\"5%\" stopColor={color} stopOpacity={admin7Design ? 0.5 : 0.8} />\n <stop offset=\"95%\" stopColor={color} stopOpacity={admin7Design ? 0.5 : 0.1} />\n </linearGradient>\n </defs>\n <Area\n baseValue={baseValue}\n dataKey=\"value\"\n fill={`url(#fillChart-${id})`}\n fillOpacity={0.2}\n isAnimationActive={false}\n stroke={color}\n strokeWidth={1.5}\n type=\"linear\"\n />\n </AreaChart>\n </ChartContainer>\n );\n};\n\nexport { GhAreaChart, GhCustomTooltipContent };\n\nexport type { TooltipProps };\n"],"mappings":";;;;;;;;;AAkCA,IAAM,0BAA0B,EAAE,QAAQ,SAAS,OAAO,WAAW,YAA0B;CAC7F,IAAI,CAAC,UAAU,CAAC,SAAS,QACvB,OAAO;CAGT,MAAM,EAAE,MAAM,gBAAgB,OAAO,WAAW,uBAAuB,QAAQ,EAAE,CAAC;CAClF,MAAM,eAAe,kBAAkB,QAAQ,EAAE,CAAC;CAElD,OACE,qBAAC,OAAD;EAAK,WAAU;YAAf,CACG,QACC,oBAAC,OAAD;GAAK,WAAU;aACZ,2BAA2B,MAAM,SAAS,GAAG,SAAS;EACpD,CAAA,GAEP,qBAAC,OAAD;GAAK,WAAU;aA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AAA,GAC5E,oBAAC,QAAD;MAAM,QAAO;MAAM,WAAW;MAAO,aAAa,eAAe,KAAM;KAAM,CAAA,CAC/D;OACZ,CAAA;IACN,oBAAC,MAAD;KACa;KACX,SAAQ;KACR,MAAM,kBAAkB,GAAG;KAC3B,aAAa;KACb,mBAAmB;KACnB,QAAQ;KACR,aAAa;KACb,MAAK;IACN,CAAA;GACQ;;CACG,CAAA;AAEpB"}
|
|
@@ -7,20 +7,26 @@ import { imageOverlayButton } from "../ui/image-overlay-button.js";
|
|
|
7
7
|
import * as React$1 from "react";
|
|
8
8
|
import { jsx } from "react/jsx-runtime";
|
|
9
9
|
//#region src/components/patterns/image-upload.tsx
|
|
10
|
-
var ImageUpload = React$1.forwardRef(({ className, ...props }, ref) =>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
var ImageUpload = React$1.forwardRef(({ className, ...props }, ref) => {
|
|
11
|
+
const { admin7Design } = useShade();
|
|
12
|
+
return /* @__PURE__ */ jsx("div", {
|
|
13
|
+
ref,
|
|
14
|
+
className: cn("relative rounded-md", !admin7Design && "overflow-hidden", className),
|
|
15
|
+
"data-slot": "image-upload",
|
|
16
|
+
...props
|
|
17
|
+
});
|
|
18
|
+
});
|
|
16
19
|
ImageUpload.displayName = "ImageUpload";
|
|
17
|
-
var ImageUploadDropzone = React$1.forwardRef(({ className, variant = "filled", ...props }, ref) =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
var ImageUploadDropzone = React$1.forwardRef(({ className, variant = "filled", ...props }, ref) => {
|
|
21
|
+
const { admin7Design } = useShade();
|
|
22
|
+
return /* @__PURE__ */ jsx(Dropzone, {
|
|
23
|
+
ref,
|
|
24
|
+
className: cn("size-full", !admin7Design && "text-foreground", className),
|
|
25
|
+
"data-slot": "image-upload-dropzone",
|
|
26
|
+
variant,
|
|
27
|
+
...props
|
|
28
|
+
});
|
|
29
|
+
});
|
|
24
30
|
ImageUploadDropzone.displayName = "ImageUploadDropzone";
|
|
25
31
|
var ImageUploadPreview = React$1.forwardRef(({ background, className, ...props }, ref) => /* @__PURE__ */ jsx("div", {
|
|
26
32
|
ref,
|
|
@@ -46,10 +52,9 @@ var ImageUploadActions = React$1.forwardRef(({ className, ...props }, ref) => /*
|
|
|
46
52
|
}));
|
|
47
53
|
ImageUploadActions.displayName = "ImageUploadActions";
|
|
48
54
|
var ImageUploadAction = React$1.forwardRef(({ className, size = "icon", variant = "ghost", ...props }, ref) => {
|
|
49
|
-
const { isAdmin7 } = useShade();
|
|
50
55
|
return /* @__PURE__ */ jsx(Button, {
|
|
51
56
|
ref,
|
|
52
|
-
className: cn("size-8", imageOverlayButton(
|
|
57
|
+
className: cn("size-8", imageOverlayButton(), className),
|
|
53
58
|
"data-slot": "image-upload-action",
|
|
54
59
|
size,
|
|
55
60
|
variant,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-upload.js","names":[],"sources":["../../../src/components/patterns/image-upload.tsx"],"sourcesContent":["import * as React from 'react';\nimport { type VariantProps } from 'class-variance-authority';\n\nimport { imageUploadPreviewVariants } from '@/components/patterns/image-upload-variants';\nimport { Button, type ButtonProps } from '@/components/ui/button';\nimport { Dropzone, type DropzoneProps } from '@/components/ui/dropzone';\nimport { cn } from '@/lib/utils';\nimport { imageOverlayButton } from '@/components/ui/image-overlay-button';\nimport { useShade } from '@/providers/shade-context';\n\nconst ImageUpload = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ({ className, ...props }, ref) => (\n
|
|
1
|
+
{"version":3,"file":"image-upload.js","names":[],"sources":["../../../src/components/patterns/image-upload.tsx"],"sourcesContent":["import * as React from 'react';\nimport { type VariantProps } from 'class-variance-authority';\n\nimport { imageUploadPreviewVariants } from '@/components/patterns/image-upload-variants';\nimport { Button, type ButtonProps } from '@/components/ui/button';\nimport { Dropzone, type DropzoneProps } from '@/components/ui/dropzone';\nimport { cn } from '@/lib/utils';\nimport { imageOverlayButton } from '@/components/ui/image-overlay-button';\nimport { useShade } from '@/providers/shade-context';\n\n// In Admin 7, previews own clipping so dropzone borders and focus rings remain visible.\nconst ImageUpload = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ({ className, ...props }, ref) => {\n const { admin7Design } = useShade();\n return (\n <div\n ref={ref}\n className={cn('relative rounded-md', !admin7Design && 'overflow-hidden', className)}\n data-slot=\"image-upload\"\n {...props}\n />\n );\n },\n);\nImageUpload.displayName = 'ImageUpload';\n\nconst ImageUploadDropzone = React.forwardRef<HTMLDivElement, DropzoneProps>(\n ({ className, variant = 'filled', ...props }, ref) => {\n const { admin7Design } = useShade();\n return (\n <Dropzone\n ref={ref}\n className={cn('size-full', !admin7Design && 'text-foreground', className)}\n data-slot=\"image-upload-dropzone\"\n variant={variant}\n {...props}\n />\n );\n },\n);\nImageUploadDropzone.displayName = 'ImageUploadDropzone';\n\nexport interface ImageUploadPreviewProps\n extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof imageUploadPreviewVariants> {}\n\nconst ImageUploadPreview = React.forwardRef<HTMLDivElement, ImageUploadPreviewProps>(\n ({ background, className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn(imageUploadPreviewVariants({ background }), className)}\n data-slot=\"image-upload-preview\"\n data-testid=\"image-upload-container\"\n {...props}\n />\n ),\n);\nImageUploadPreview.displayName = 'ImageUploadPreview';\n\nconst ImageUploadImage = React.forwardRef<\n HTMLImageElement,\n React.ImgHTMLAttributes<HTMLImageElement>\n>(({ alt = '', className, ...props }, ref) => (\n <img\n ref={ref}\n alt={alt}\n className={cn('size-full object-cover', className)}\n data-slot=\"image-upload-image\"\n {...props}\n />\n));\nImageUploadImage.displayName = 'ImageUploadImage';\n\nconst ImageUploadActions = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn(\n 'absolute top-2 right-2 flex gap-1 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100 [@media(hover:none)]:opacity-100',\n className,\n )}\n data-slot=\"image-upload-actions\"\n {...props}\n />\n ),\n);\nImageUploadActions.displayName = 'ImageUploadActions';\n\nconst ImageUploadAction = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ className, size = 'icon', variant = 'ghost', ...props }, ref) => {\n return (\n <Button\n ref={ref}\n className={cn('size-8', imageOverlayButton(), className)}\n data-slot=\"image-upload-action\"\n size={size}\n variant={variant}\n {...props}\n />\n );\n },\n);\nImageUploadAction.displayName = 'ImageUploadAction';\n\nexport {\n ImageUpload,\n ImageUploadAction,\n ImageUploadActions,\n ImageUploadDropzone,\n ImageUploadImage,\n ImageUploadPreview,\n};\n"],"mappings":";;;;;;;;;AAWA,IAAM,cAAc,QAAM,YACvB,EAAE,WAAW,GAAG,SAAS,QAAQ;CAChC,MAAM,EAAE,iBAAiB,SAAS;CAClC,OACE,oBAAC,OAAD;EACO;EACL,WAAW,GAAG,uBAAuB,CAAC,gBAAgB,mBAAmB,SAAS;EAClF,aAAU;EACV,GAAI;CACL,CAAA;AAEL,CACF;AACA,YAAY,cAAc;AAE1B,IAAM,sBAAsB,QAAM,YAC/B,EAAE,WAAW,UAAU,UAAU,GAAG,SAAS,QAAQ;CACpD,MAAM,EAAE,iBAAiB,SAAS;CAClC,OACE,oBAAC,UAAD;EACO;EACL,WAAW,GAAG,aAAa,CAAC,gBAAgB,mBAAmB,SAAS;EACxE,aAAU;EACD;EACT,GAAI;CACL,CAAA;AAEL,CACF;AACA,oBAAoB,cAAc;AAKlC,IAAM,qBAAqB,QAAM,YAC9B,EAAE,YAAY,WAAW,GAAG,SAAS,QACpC,oBAAC,OAAD;CACO;CACL,WAAW,GAAG,2BAA2B,EAAE,WAAW,CAAC,GAAG,SAAS;CACnE,aAAU;CACV,eAAY;CACZ,GAAI;AACL,CAAA,CAEL;AACA,mBAAmB,cAAc;AAEjC,IAAM,mBAAmB,QAAM,YAG5B,EAAE,MAAM,IAAI,WAAW,GAAG,SAAS,QACpC,oBAAC,OAAD;CACO;CACA;CACL,WAAW,GAAG,0BAA0B,SAAS;CACjD,aAAU;CACV,GAAI;AACL,CAAA,CACF;AACD,iBAAiB,cAAc;AAE/B,IAAM,qBAAqB,QAAM,YAC9B,EAAE,WAAW,GAAG,SAAS,QACxB,oBAAC,OAAD;CACO;CACL,WAAW,GACT,0JACA,SACF;CACA,aAAU;CACV,GAAI;AACL,CAAA,CAEL;AACA,mBAAmB,cAAc;AAEjC,IAAM,oBAAoB,QAAM,YAC7B,EAAE,WAAW,OAAO,QAAQ,UAAU,SAAS,GAAG,SAAS,QAAQ;CAClE,OACE,oBAAC,QAAD;EACO;EACL,WAAW,GAAG,UAAU,mBAAmB,GAAG,SAAS;EACvD,aAAU;EACJ;EACG;EACT,GAAI;CACL,CAAA;AAEL,CACF;AACA,kBAAkB,cAAc"}
|
|
@@ -15,15 +15,12 @@ import { ListFilter } from "lucide-react";
|
|
|
15
15
|
import React from "react";
|
|
16
16
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
17
17
|
import { createPortal } from "react-dom";
|
|
18
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
19
18
|
//#region src/components/patterns/page-header.tsx
|
|
20
19
|
/**
|
|
21
|
-
* Header tooltips
|
|
22
|
-
*
|
|
20
|
+
* Header tooltips never belong on primary actions. A tooltip without a label
|
|
21
|
+
* shows only the shortcut, for a control whose text already names it.
|
|
23
22
|
*/
|
|
24
23
|
function PageHeaderTooltip({ children, label, shortcut }) {
|
|
25
|
-
const { isAdmin7 } = useShade();
|
|
26
|
-
if (!isAdmin7) return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
27
24
|
return /* @__PURE__ */ jsxs(Tooltip, { children: [children, /* @__PURE__ */ jsx(TooltipContent, {
|
|
28
25
|
side: "bottom",
|
|
29
26
|
variant: "white",
|
|
@@ -34,35 +31,20 @@ function PageHeaderTooltip({ children, label, shortcut }) {
|
|
|
34
31
|
})
|
|
35
32
|
})] });
|
|
36
33
|
}
|
|
37
|
-
var PageHeaderTooltipTrigger = React.forwardRef(({ children, asChild, ...props }, ref) => {
|
|
38
|
-
const { isAdmin7 } = useShade();
|
|
39
|
-
return isAdmin7 ? /* @__PURE__ */ jsx(TooltipTrigger, {
|
|
40
|
-
ref,
|
|
41
|
-
asChild,
|
|
42
|
-
...props,
|
|
43
|
-
children
|
|
44
|
-
}) : /* @__PURE__ */ jsx(asChild ? Slot : "button", {
|
|
45
|
-
ref,
|
|
46
|
-
...props,
|
|
47
|
-
children
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
PageHeaderTooltipTrigger.displayName = "PageHeaderTooltipTrigger";
|
|
51
34
|
var PrimaryActionContext = React.createContext(false);
|
|
52
|
-
var PageHeaderAction = React.forwardRef(({ label, iconOnly = false, primary: primaryProp, shortcut, tooltip = iconOnly || Boolean(shortcut),
|
|
53
|
-
const { isAdmin7 } = useShade();
|
|
35
|
+
var PageHeaderAction = React.forwardRef(({ label, iconOnly = false, primary: primaryProp, shortcut, tooltip = iconOnly || Boolean(shortcut), className, ...props }, ref) => {
|
|
54
36
|
const primaryContext = React.useContext(PrimaryActionContext);
|
|
55
37
|
const primary = primaryProp ?? primaryContext;
|
|
56
38
|
const button = /* @__PURE__ */ jsx(Button, {
|
|
57
39
|
ref,
|
|
58
40
|
"aria-keyshortcuts": shortcut,
|
|
59
41
|
"aria-label": label,
|
|
60
|
-
className: cn(
|
|
61
|
-
size:
|
|
62
|
-
variant:
|
|
42
|
+
className: cn("[&_svg]:stroke-2!", className),
|
|
43
|
+
size: iconOnly ? "icon" : void 0,
|
|
44
|
+
variant: primary ? "default" : "ghost",
|
|
63
45
|
...props
|
|
64
46
|
});
|
|
65
|
-
return primary || !
|
|
47
|
+
return primary || !tooltip ? button : /* @__PURE__ */ jsx(PageHeaderTooltip, {
|
|
66
48
|
label: iconOnly || !shortcut ? label : void 0,
|
|
67
49
|
shortcut,
|
|
68
50
|
children: /* @__PURE__ */ jsx(TooltipTrigger, {
|
|
@@ -83,19 +65,19 @@ var PageHeaderFilterTrigger = React.forwardRef((props, ref) => /* @__PURE__ */ j
|
|
|
83
65
|
}));
|
|
84
66
|
PageHeaderFilterTrigger.displayName = "PageHeaderFilterTrigger";
|
|
85
67
|
var PageHeaderSelectTrigger = React.forwardRef(({ label, tooltip = true, className, ...props }, ref) => {
|
|
86
|
-
const { controlShape
|
|
68
|
+
const { controlShape } = useShade();
|
|
87
69
|
const trigger = /* @__PURE__ */ jsx(SelectTrigger, {
|
|
88
70
|
ref,
|
|
89
71
|
"aria-label": label,
|
|
90
|
-
className: cn("w-auto
|
|
72
|
+
className: cn("w-auto gap-1.5 font-medium [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2! [&>svg]:mr-0", className),
|
|
91
73
|
shape: controlShape,
|
|
92
|
-
showChevron:
|
|
93
|
-
variant:
|
|
74
|
+
showChevron: false,
|
|
75
|
+
variant: "ghost",
|
|
94
76
|
...props
|
|
95
77
|
});
|
|
96
78
|
return tooltip ? /* @__PURE__ */ jsx(PageHeaderTooltip, {
|
|
97
79
|
label,
|
|
98
|
-
children: /* @__PURE__ */ jsx(
|
|
80
|
+
children: /* @__PURE__ */ jsx(TooltipTrigger, {
|
|
99
81
|
asChild: true,
|
|
100
82
|
children: trigger
|
|
101
83
|
})
|
|
@@ -205,19 +187,15 @@ function PageHeaderLeft({ className, children }) {
|
|
|
205
187
|
});
|
|
206
188
|
}
|
|
207
189
|
function PageHeaderActionGroupPrimary({ children, className }) {
|
|
208
|
-
const { isAdmin7 } = useShade();
|
|
209
190
|
if (React.Children.toArray(children).length === 0) return null;
|
|
210
191
|
return /* @__PURE__ */ jsx(PrimaryActionContext.Provider, {
|
|
211
192
|
value: true,
|
|
212
|
-
children:
|
|
193
|
+
children: /* @__PURE__ */ jsx(Inline, {
|
|
213
194
|
className: cn("ms-3 shrink-0 first:ms-0", className),
|
|
214
195
|
"data-page-header": "primary",
|
|
215
196
|
gap: "none",
|
|
216
197
|
children
|
|
217
|
-
})
|
|
218
|
-
className,
|
|
219
|
-
children
|
|
220
|
-
}) : children
|
|
198
|
+
})
|
|
221
199
|
});
|
|
222
200
|
}
|
|
223
201
|
function PageHeaderActionGroupMobileMenu({ children }) {
|
|
@@ -258,7 +236,6 @@ var useShouldCollapseActionGroup = (breakpoint) => {
|
|
|
258
236
|
return shouldCollapse;
|
|
259
237
|
};
|
|
260
238
|
var PageHeaderActionGroup = Object.assign(function PageHeaderActionGroup({ className, children, mobileMenuBreakpoint = DEFAULT_MOBILE_MENU_BREAKPOINT }) {
|
|
261
|
-
const { isAdmin7 } = useShade();
|
|
262
239
|
const gap = "sm";
|
|
263
240
|
const childNodes = React.Children.toArray(children);
|
|
264
241
|
const desktopChildren = [];
|
|
@@ -315,10 +292,7 @@ var PageHeaderActionGroup = Object.assign(function PageHeaderActionGroup({ class
|
|
|
315
292
|
className: "ml-auto",
|
|
316
293
|
"data-page-header": "action-group-mobile",
|
|
317
294
|
gap,
|
|
318
|
-
children: [mobileMenu, primaryAction
|
|
319
|
-
"data-page-header": "action-group-mobile-primary",
|
|
320
|
-
children: primaryAction
|
|
321
|
-
}))]
|
|
295
|
+
children: [mobileMenu, primaryAction]
|
|
322
296
|
})
|
|
323
297
|
}) });
|
|
324
298
|
}, {
|
|
@@ -342,7 +316,8 @@ function PageHeaderActions({ className, children }) {
|
|
|
342
316
|
* The main row contains `Left` (Breadcrumb + Title) and `Actions`.
|
|
343
317
|
* Compose optional ViewBar and FilterBar rows beside it in ListPage.Header.
|
|
344
318
|
* `Title` accepts an inline `Count` and stacked `Description`/`Meta` children.
|
|
345
|
-
* See
|
|
319
|
+
* See the design contract for the action ordering and interaction rules:
|
|
320
|
+
* https://shade.ghost.org/docs/components/patterns/page-header.md (generated from page-header.mdx).
|
|
346
321
|
*/
|
|
347
322
|
var PageHeader = Object.assign(function PageHeader({ className, children, sticky = true, blurredBackground = true }) {
|
|
348
323
|
return /* @__PURE__ */ jsx("header", {
|
|
@@ -370,7 +345,7 @@ var PageHeader = Object.assign(function PageHeader({ className, children, sticky
|
|
|
370
345
|
FilterTrigger: PageHeaderFilterTrigger,
|
|
371
346
|
SelectTrigger: PageHeaderSelectTrigger,
|
|
372
347
|
Tooltip: PageHeaderTooltip,
|
|
373
|
-
TooltipTrigger
|
|
348
|
+
TooltipTrigger
|
|
374
349
|
});
|
|
375
350
|
//#endregion
|
|
376
351
|
export { PageHeader, PageHeaderActionGroup, PageHeaderActionGroupMobileMenu, PageHeaderActionGroupMobileMenuContent, PageHeaderActionGroupMobileMenuTrigger, PageHeaderActionGroupPrimary, PageHeaderActions, PageHeaderBreadcrumb, PageHeaderCount, PageHeaderDescription, PageHeaderLeft, PageHeaderMeta, PageHeaderTitle };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-header.js","names":[],"sources":["../../../src/components/patterns/page-header.tsx"],"sourcesContent":["import { HeaderTooltipProvider } from '@/providers/header-tooltip-provider';\nimport { useShade } from '@/providers/shade-context';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuTrigger,\n} from '@/components/ui/dropdown-menu';\nimport { Button, type ButtonProps } from '@/components/ui/button';\nimport { SelectTrigger } from '@/components/ui/select';\nimport { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';\nimport { Kbd } from '@/components/ui/kbd';\nimport { H1 } from '@/components/layout/heading';\nimport { Inline, Stack, Text } from '@/components/primitives';\nimport { cn } from '@/lib/utils';\n\nimport React from 'react';\nimport { createPortal } from 'react-dom';\nimport { ListFilter } from 'lucide-react';\nimport { PageHeaderLargeTitleContext } from './page-header-large-title';\nimport { Slot } from '@radix-ui/react-slot';\n\ntype PropsWithChildrenAndClassName = React.PropsWithChildren & {\n className?: string;\n};\n\ntype PageHeaderProps = PropsWithChildrenAndClassName & {\n sticky?: boolean;\n blurredBackground?: boolean;\n};\n\n/**\n * Header tooltips require Admin 7 and never belong on primary actions. A tooltip\n * without a label shows only the shortcut, for a control whose text already names it.\n */\nfunction PageHeaderTooltip({\n children,\n label,\n shortcut,\n}: React.PropsWithChildren<{ label?: string; shortcut?: string }>) {\n const { isAdmin7 } = useShade();\n if (!isAdmin7) {\n return <>{children}</>;\n }\n return (\n <Tooltip>\n {children}\n <TooltipContent side=\"bottom\" variant=\"white\">\n <Inline align=\"center\" gap=\"sm\">\n {label}\n {shortcut && <Kbd>{shortcut}</Kbd>}\n </Inline>\n </TooltipContent>\n </Tooltip>\n );\n}\n\nconst PageHeaderTooltipTrigger = React.forwardRef<\n React.ElementRef<typeof TooltipTrigger>,\n React.ComponentPropsWithoutRef<typeof TooltipTrigger>\n>(({ children, asChild, ...props }, ref) => {\n const { isAdmin7 } = useShade();\n const PlainTrigger = asChild ? Slot : 'button';\n return isAdmin7 ? (\n <TooltipTrigger ref={ref} asChild={asChild} {...props}>\n {children}\n </TooltipTrigger>\n ) : (\n <PlainTrigger ref={ref} {...props}>\n {children}\n </PlainTrigger>\n );\n});\nPageHeaderTooltipTrigger.displayName = 'PageHeaderTooltipTrigger';\n\nconst PrimaryActionContext = React.createContext(false);\n\ntype PageHeaderActionProps = ButtonProps & {\n label: string;\n iconOnly?: boolean;\n primary?: boolean;\n shortcut?: string;\n /** Show an explanation for a changing value; static labels need no tooltip. */\n tooltip?: boolean;\n /** Temporary compatibility for existing screens; new headers use the defaults. */\n fallbackVariant?: ButtonProps['variant'];\n fallbackSize?: ButtonProps['size'];\n};\n\nconst PageHeaderAction = React.forwardRef<HTMLButtonElement, PageHeaderActionProps>(\n (\n {\n label,\n iconOnly = false,\n primary: primaryProp,\n shortcut,\n tooltip = iconOnly || Boolean(shortcut),\n fallbackVariant = 'outline',\n fallbackSize,\n className,\n ...props\n },\n ref,\n ) => {\n const { isAdmin7 } = useShade();\n const primaryContext = React.useContext(PrimaryActionContext);\n const primary = primaryProp ?? primaryContext;\n const button = (\n <Button\n ref={ref}\n aria-keyshortcuts={shortcut}\n aria-label={label}\n className={cn(isAdmin7 && '[&_svg]:stroke-2!', className)}\n size={isAdmin7 ? (iconOnly ? 'icon' : undefined) : fallbackSize}\n variant={isAdmin7 ? (primary ? 'default' : 'ghost') : fallbackVariant}\n {...props}\n />\n );\n // A labelled action already shows its name, so its shortcut tooltip shows the keys alone.\n const tooltipLabel = iconOnly || !shortcut ? label : undefined;\n return primary || !isAdmin7 || !tooltip ? (\n button\n ) : (\n <PageHeaderTooltip label={tooltipLabel} shortcut={shortcut}>\n <TooltipTrigger asChild>{button}</TooltipTrigger>\n </PageHeaderTooltip>\n );\n },\n);\nPageHeaderAction.displayName = 'PageHeaderAction';\n\nconst PageHeaderFilterTrigger = React.forwardRef<\n HTMLButtonElement,\n Omit<PageHeaderActionProps, 'label'>\n>((props, ref) => (\n <PageHeaderAction\n ref={ref}\n data-slot=\"filters-add\"\n label=\"Filter\"\n shortcut=\"F\"\n type=\"button\"\n {...props}\n >\n <ListFilter className=\"size-4\" />\n Filter\n </PageHeaderAction>\n));\nPageHeaderFilterTrigger.displayName = 'PageHeaderFilterTrigger';\n\nconst PageHeaderSelectTrigger = React.forwardRef<\n React.ElementRef<typeof SelectTrigger>,\n React.ComponentPropsWithoutRef<typeof SelectTrigger> & { label: string; tooltip?: boolean }\n>(({ label, tooltip = true, className, ...props }, ref) => {\n const { controlShape, isAdmin7 } = useShade();\n const trigger = (\n <SelectTrigger\n ref={ref}\n aria-label={label}\n className={cn(\n 'w-auto',\n isAdmin7 &&\n 'gap-1.5 font-medium [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2! [&>svg]:mr-0',\n className,\n )}\n shape={controlShape}\n showChevron={!isAdmin7}\n variant={isAdmin7 ? 'ghost' : 'default'}\n {...props}\n />\n );\n return tooltip ? (\n <PageHeaderTooltip label={label}>\n <PageHeaderTooltipTrigger asChild>{trigger}</PageHeaderTooltipTrigger>\n </PageHeaderTooltip>\n ) : (\n trigger\n );\n});\nPageHeaderSelectTrigger.displayName = 'PageHeaderSelectTrigger';\n\n// ---------------------------------------------------------------------------\n// Title-block primitives\n// ---------------------------------------------------------------------------\n\nfunction PageHeaderBreadcrumb({ className, children }: PropsWithChildrenAndClassName) {\n return (\n <Inline\n align=\"center\"\n className={cn('pt-1 text-sm text-muted-foreground', className)}\n data-page-header=\"breadcrumb\"\n gap=\"sm\"\n >\n {children}\n </Inline>\n );\n}\n\nfunction PageHeaderCount({ className, children }: PropsWithChildrenAndClassName) {\n return (\n <Text\n as=\"span\"\n className={cn('ml-1 text-base tabular-nums', className)}\n data-page-header=\"count\"\n tone=\"secondary\"\n weight=\"regular\"\n >\n {children}\n </Text>\n );\n}\n\nfunction PageHeaderDescription({ className, children }: PropsWithChildrenAndClassName) {\n return (\n <Text as=\"p\" className={className} data-page-header=\"description\" size=\"sm\" tone=\"secondary\">\n {children}\n </Text>\n );\n}\n\nfunction PageHeaderMeta({ className, children }: PropsWithChildrenAndClassName) {\n return (\n <Text\n as=\"p\"\n className={cn('mt-0.5', className)}\n data-page-header=\"meta\"\n size=\"sm\"\n tone=\"secondary\"\n >\n {children}\n </Text>\n );\n}\n\n/**\n * `Title` accepts heading text plus optional `Count`, `Description`, and `Meta`\n * children. `Count` flows inline inside the H1; `Description` and `Meta` stack\n * below the heading.\n */\nfunction PageHeaderTitle({ className, children }: PropsWithChildrenAndClassName) {\n const largeTitle = React.useContext(PageHeaderLargeTitleContext);\n const registerLargeTitle = largeTitle?.registerTitle;\n React.useLayoutEffect(() => registerLargeTitle?.(), [registerLargeTitle]);\n\n const headingChildren: React.ReactNode[] = [];\n const subTextChildren: React.ReactNode[] = [];\n\n React.Children.forEach(children, (child) => {\n if (!React.isValidElement(child)) {\n headingChildren.push(child);\n return;\n }\n\n switch (child.type) {\n case PageHeaderDescription:\n case PageHeaderMeta:\n subTextChildren.push(child);\n break;\n default:\n headingChildren.push(child);\n }\n });\n\n // Shown large above the page's header, the title is that heading; the one\n // in the header is a stand-in, fading in as the header takes over\n if (largeTitle) {\n return (\n <>\n <H1\n aria-hidden=\"true\"\n className={cn(\n 'large-title-header-title text-lg font-semibold tracking-[0.1px] whitespace-nowrap',\n className,\n )}\n data-page-header=\"title\"\n >\n {headingChildren}\n </H1>\n {largeTitle.slot &&\n createPortal(\n <Stack data-page-header=\"large-title\" gap=\"none\">\n <H1\n className=\"flex items-baseline gap-3 font-medium tracking-[-0.03em] whitespace-nowrap [&_[data-page-header=count]]:tracking-normal\"\n data-large-title=\"\"\n // Inline, over Text's own line height\n style={{ fontSize: 'var(--large-title-size)', lineHeight: 1.15 }}\n >\n {headingChildren}\n </H1>\n {subTextChildren}\n </Stack>,\n largeTitle.slot,\n )}\n </>\n );\n }\n\n const heading = (\n <H1\n className={cn('text-lg font-semibold tracking-[0.1px] whitespace-nowrap', className)}\n data-page-header=\"title\"\n >\n {headingChildren}\n </H1>\n );\n\n if (subTextChildren.length > 0) {\n return (\n <Stack data-page-header=\"title-body\" gap=\"none\">\n {heading}\n {subTextChildren}\n </Stack>\n );\n }\n\n return heading;\n}\n\n// ---------------------------------------------------------------------------\n// Main row — Left (stack: Breadcrumb + Title) + Actions\n// ---------------------------------------------------------------------------\n\nfunction PageHeaderLeft({ className, children }: PropsWithChildrenAndClassName) {\n return (\n <Stack\n className={cn('h-full min-h-(--control-height) min-w-0', className)}\n data-page-header=\"left\"\n gap=\"xs\"\n justify=\"center\"\n >\n {children}\n </Stack>\n );\n}\n\ntype PageHeaderActionGroupPrimaryProps = PropsWithChildrenAndClassName;\nfunction PageHeaderActionGroupPrimary({ children, className }: PageHeaderActionGroupPrimaryProps) {\n const { isAdmin7 } = useShade();\n if (React.Children.toArray(children).length === 0) {\n return null;\n }\n return (\n <PrimaryActionContext.Provider value={true}>\n {isAdmin7 ? (\n <Inline\n className={cn('ms-3 shrink-0 first:ms-0', className)}\n data-page-header=\"primary\"\n gap=\"none\"\n >\n {children}\n </Inline>\n ) : className ? (\n <Slot className={className}>{children}</Slot>\n ) : (\n children\n )}\n </PrimaryActionContext.Provider>\n );\n}\n\ntype PageHeaderActionGroupMobileMenuProps = React.PropsWithChildren;\nfunction PageHeaderActionGroupMobileMenu({ children }: PageHeaderActionGroupMobileMenuProps) {\n return <DropdownMenu>{children}</DropdownMenu>;\n}\n\ntype PageHeaderActionGroupMobileMenuTriggerProps = React.ComponentPropsWithoutRef<\n typeof DropdownMenuTrigger\n>;\nfunction PageHeaderActionGroupMobileMenuTrigger({\n children,\n ...props\n}: PageHeaderActionGroupMobileMenuTriggerProps) {\n return (\n <DropdownMenuTrigger asChild {...props}>\n {children}\n </DropdownMenuTrigger>\n );\n}\n\ntype PageHeaderActionGroupMobileMenuContentProps = React.ComponentPropsWithoutRef<\n typeof DropdownMenuContent\n>;\nfunction PageHeaderActionGroupMobileMenuContent({\n children,\n ...props\n}: PageHeaderActionGroupMobileMenuContentProps) {\n return (\n <DropdownMenuContent align=\"end\" sideOffset={8} {...props}>\n {children}\n </DropdownMenuContent>\n );\n}\n\nconst DEFAULT_MOBILE_MENU_BREAKPOINT = 640;\n\nconst isBelowBreakpoint = (breakpoint: number) => {\n if (typeof window === 'undefined') {\n return false;\n }\n\n return window.innerWidth < breakpoint;\n};\n\nconst useShouldCollapseActionGroup = (breakpoint: number) => {\n const [shouldCollapse, setShouldCollapse] = React.useState(() => isBelowBreakpoint(breakpoint));\n\n React.useEffect(() => {\n const onResize = () => {\n setShouldCollapse(isBelowBreakpoint(breakpoint));\n };\n\n onResize();\n window.addEventListener('resize', onResize);\n\n return () => {\n window.removeEventListener('resize', onResize);\n };\n }, [breakpoint]);\n\n return shouldCollapse;\n};\n\ntype PageHeaderActionGroupProps = PropsWithChildrenAndClassName & {\n mobileMenuBreakpoint?: number;\n};\ntype PageHeaderActionGroupComponent = React.FC<PageHeaderActionGroupProps> & {\n Primary: React.FC<PageHeaderActionGroupPrimaryProps>;\n MobileMenu: React.FC<PageHeaderActionGroupMobileMenuProps>;\n MobileMenuTrigger: React.FC<PageHeaderActionGroupMobileMenuTriggerProps>;\n MobileMenuContent: React.FC<PageHeaderActionGroupMobileMenuContentProps>;\n};\n\nconst PageHeaderActionGroup: PageHeaderActionGroupComponent = Object.assign(\n function PageHeaderActionGroup({\n className,\n children,\n mobileMenuBreakpoint = DEFAULT_MOBILE_MENU_BREAKPOINT,\n }: PageHeaderActionGroupProps) {\n const { isAdmin7 } = useShade();\n const gap = 'sm';\n const childNodes = React.Children.toArray(children);\n const desktopChildren: React.ReactNode[] = [];\n let mobileMenu: React.ReactElement | null = null;\n let primaryAction: React.ReactNode = null;\n const shouldCollapse = useShouldCollapseActionGroup(mobileMenuBreakpoint);\n\n childNodes.forEach((child) => {\n if (!React.isValidElement(child)) {\n desktopChildren.push(child);\n return;\n }\n\n const childElement = child as React.ReactElement<{ children?: React.ReactNode }>;\n\n if (childElement.type === PageHeaderActionGroupMobileMenu) {\n mobileMenu = childElement;\n return;\n }\n\n if (childElement.type === PageHeaderActionGroupPrimary) {\n primaryAction = childElement;\n desktopChildren.push(childElement);\n return;\n }\n\n desktopChildren.push(childElement);\n });\n\n if (!mobileMenu) {\n return (\n <HeaderTooltipProvider>\n <Inline\n align=\"center\"\n className={className}\n data-page-header=\"action-group\"\n gap={gap}\n justify=\"end\"\n >\n {children}\n </Inline>\n </HeaderTooltipProvider>\n );\n }\n\n if (!shouldCollapse) {\n return (\n <HeaderTooltipProvider>\n <Inline\n align=\"center\"\n className={className}\n data-page-header=\"action-group\"\n gap={gap}\n justify=\"end\"\n >\n <Inline align=\"center\" data-page-header=\"action-group-desktop\" gap={gap} justify=\"end\">\n {desktopChildren}\n </Inline>\n </Inline>\n </HeaderTooltipProvider>\n );\n }\n\n return (\n <HeaderTooltipProvider>\n <Inline\n align=\"center\"\n className={className}\n data-page-header=\"action-group\"\n gap={gap}\n justify=\"end\"\n >\n <Inline\n align=\"center\"\n className=\"ml-auto\"\n data-page-header=\"action-group-mobile\"\n gap={gap}\n >\n {mobileMenu}\n {primaryAction &&\n (isAdmin7 ? (\n primaryAction\n ) : (\n <div data-page-header=\"action-group-mobile-primary\">{primaryAction}</div>\n ))}\n </Inline>\n </Inline>\n </HeaderTooltipProvider>\n );\n },\n {\n Primary: PageHeaderActionGroupPrimary,\n MobileMenu: PageHeaderActionGroupMobileMenu,\n MobileMenuTrigger: PageHeaderActionGroupMobileMenuTrigger,\n MobileMenuContent: PageHeaderActionGroupMobileMenuContent,\n },\n);\n\nfunction PageHeaderActions({ className, children }: PropsWithChildrenAndClassName) {\n return (\n <HeaderTooltipProvider>\n <Inline\n align=\"center\"\n className={cn('min-h-(--control-height) shrink-0', className)}\n data-page-header=\"actions\"\n gap=\"lg\"\n >\n {children}\n </Inline>\n </HeaderTooltipProvider>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Root\n// ---------------------------------------------------------------------------\n\ntype PageHeaderComponent = React.FC<PageHeaderProps> & {\n Left: React.FC<PropsWithChildrenAndClassName>;\n Breadcrumb: React.FC<PropsWithChildrenAndClassName>;\n Title: React.FC<PropsWithChildrenAndClassName>;\n Count: React.FC<PropsWithChildrenAndClassName>;\n Description: React.FC<PropsWithChildrenAndClassName>;\n Meta: React.FC<PropsWithChildrenAndClassName>;\n Actions: React.FC<PropsWithChildrenAndClassName>;\n ActionGroup: PageHeaderActionGroupComponent;\n Action: typeof PageHeaderAction;\n FilterTrigger: typeof PageHeaderFilterTrigger;\n SelectTrigger: typeof PageHeaderSelectTrigger;\n Tooltip: typeof PageHeaderTooltip;\n TooltipTrigger: typeof PageHeaderTooltipTrigger;\n};\n\n/**\n * PageHeader is the canonical page-chrome component for Ghost Admin pages.\n *\n * The main row contains `Left` (Breadcrumb + Title) and `Actions`.\n * Compose optional ViewBar and FilterBar rows beside it in ListPage.Header.\n * `Title` accepts an inline `Count` and stacked `Description`/`Meta` children.\n * See page-header.mdx for the action ordering and interaction contract.\n */\nconst PageHeader: PageHeaderComponent = Object.assign(\n function PageHeader({\n className,\n children,\n sticky = true,\n blurredBackground = true,\n }: PageHeaderProps) {\n return (\n <header\n className={cn(\n 'flex flex-col',\n sticky && 'sticky top-0 z-50',\n blurredBackground &&\n 'bg-gradient-to-b from-background via-background/70 to-background/70 backdrop-blur-md',\n className,\n )}\n data-page-header=\"page-header\"\n >\n <Inline align=\"start\" className=\"w-full\" data-page-header=\"main\" gap=\"lg\" justify=\"between\">\n {children}\n </Inline>\n </header>\n );\n },\n {\n Left: PageHeaderLeft,\n Breadcrumb: PageHeaderBreadcrumb,\n Title: PageHeaderTitle,\n Count: PageHeaderCount,\n Description: PageHeaderDescription,\n Meta: PageHeaderMeta,\n Actions: PageHeaderActions,\n ActionGroup: PageHeaderActionGroup,\n Action: PageHeaderAction,\n FilterTrigger: PageHeaderFilterTrigger,\n SelectTrigger: PageHeaderSelectTrigger,\n Tooltip: PageHeaderTooltip,\n TooltipTrigger: PageHeaderTooltipTrigger,\n },\n);\n\nexport {\n PageHeader,\n PageHeaderLeft,\n PageHeaderBreadcrumb,\n PageHeaderTitle,\n PageHeaderCount,\n PageHeaderDescription,\n PageHeaderMeta,\n PageHeaderActions,\n PageHeaderActionGroup,\n PageHeaderActionGroupPrimary,\n PageHeaderActionGroupMobileMenu,\n PageHeaderActionGroupMobileMenuTrigger,\n PageHeaderActionGroupMobileMenuContent,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAkCA,SAAS,kBAAkB,EACzB,UACA,OACA,YACiE;CACjE,MAAM,EAAE,aAAa,SAAS;CAC9B,IAAI,CAAC,UACH,OAAO,oBAAA,YAAA,EAAG,SAAW,CAAA;CAEvB,OACE,qBAAC,SAAD,EAAA,UAAA,CACG,UACD,oBAAC,gBAAD;EAAgB,MAAK;EAAS,SAAQ;YACpC,qBAAC,QAAD;GAAQ,OAAM;GAAS,KAAI;aAA3B,CACG,OACA,YAAY,oBAAC,KAAD,EAAA,UAAM,SAAc,CAAA,CAC3B;;CACM,CAAA,CACT,EAAA,CAAA;AAEb;AAEA,IAAM,2BAA2B,MAAM,YAGpC,EAAE,UAAU,SAAS,GAAG,SAAS,QA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;YAEjB,oBAAC,QAAD;GAAQ,OAAM;GAAQ,WAAU;GAAS,oBAAiB;GAAO,KAAI;GAAK,SAAQ;GAC/E;EACK,CAAA;CACF,CAAA;AAEZ,GACA;CACE,MAAM;CACN,YAAY;CACZ,OAAO;CACP,OAAO;CACP,aAAa;CACb,MAAM;CACN,SAAS;CACT,aAAa;CACb,QAAQ;CACR,eAAe;CACf,eAAe;CACf,SAAS;CACT,gBAAgB;AAClB,CACF"}
|
|
1
|
+
{"version":3,"file":"page-header.js","names":[],"sources":["../../../src/components/patterns/page-header.tsx"],"sourcesContent":["import { HeaderTooltipProvider } from '@/providers/header-tooltip-provider';\nimport { useShade } from '@/providers/shade-context';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuTrigger,\n} from '@/components/ui/dropdown-menu';\nimport { Button, type ButtonProps } from '@/components/ui/button';\nimport { SelectTrigger } from '@/components/ui/select';\nimport { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';\nimport { Kbd } from '@/components/ui/kbd';\nimport { H1 } from '@/components/layout/heading';\nimport { Inline, Stack, Text } from '@/components/primitives';\nimport { cn } from '@/lib/utils';\n\nimport React from 'react';\nimport { createPortal } from 'react-dom';\nimport { ListFilter } from 'lucide-react';\nimport { PageHeaderLargeTitleContext } from './page-header-large-title';\n\ntype PropsWithChildrenAndClassName = React.PropsWithChildren & {\n className?: string;\n};\n\ntype PageHeaderProps = PropsWithChildrenAndClassName & {\n sticky?: boolean;\n blurredBackground?: boolean;\n};\n\n/**\n * Header tooltips never belong on primary actions. A tooltip without a label\n * shows only the shortcut, for a control whose text already names it.\n */\nfunction PageHeaderTooltip({\n children,\n label,\n shortcut,\n}: React.PropsWithChildren<{ label?: string; shortcut?: string }>) {\n return (\n <Tooltip>\n {children}\n <TooltipContent side=\"bottom\" variant=\"white\">\n <Inline align=\"center\" gap=\"sm\">\n {label}\n {shortcut && <Kbd>{shortcut}</Kbd>}\n </Inline>\n </TooltipContent>\n </Tooltip>\n );\n}\n\nconst PrimaryActionContext = React.createContext(false);\n\ntype PageHeaderActionProps = ButtonProps & {\n label: string;\n iconOnly?: boolean;\n primary?: boolean;\n shortcut?: string;\n /** Show an explanation for a changing value; static labels need no tooltip. */\n tooltip?: boolean;\n};\n\nconst PageHeaderAction = React.forwardRef<HTMLButtonElement, PageHeaderActionProps>(\n (\n {\n label,\n iconOnly = false,\n primary: primaryProp,\n shortcut,\n tooltip = iconOnly || Boolean(shortcut),\n className,\n ...props\n },\n ref,\n ) => {\n const primaryContext = React.useContext(PrimaryActionContext);\n const primary = primaryProp ?? primaryContext;\n const button = (\n <Button\n ref={ref}\n aria-keyshortcuts={shortcut}\n aria-label={label}\n className={cn('[&_svg]:stroke-2!', className)}\n size={iconOnly ? 'icon' : undefined}\n variant={primary ? 'default' : 'ghost'}\n {...props}\n />\n );\n // A labelled action already shows its name, so its shortcut tooltip shows the keys alone.\n const tooltipLabel = iconOnly || !shortcut ? label : undefined;\n return primary || !tooltip ? (\n button\n ) : (\n <PageHeaderTooltip label={tooltipLabel} shortcut={shortcut}>\n <TooltipTrigger asChild>{button}</TooltipTrigger>\n </PageHeaderTooltip>\n );\n },\n);\nPageHeaderAction.displayName = 'PageHeaderAction';\n\nconst PageHeaderFilterTrigger = React.forwardRef<\n HTMLButtonElement,\n Omit<PageHeaderActionProps, 'label'>\n>((props, ref) => (\n <PageHeaderAction\n ref={ref}\n data-slot=\"filters-add\"\n label=\"Filter\"\n shortcut=\"F\"\n type=\"button\"\n {...props}\n >\n <ListFilter className=\"size-4\" />\n Filter\n </PageHeaderAction>\n));\nPageHeaderFilterTrigger.displayName = 'PageHeaderFilterTrigger';\n\nconst PageHeaderSelectTrigger = React.forwardRef<\n React.ElementRef<typeof SelectTrigger>,\n React.ComponentPropsWithoutRef<typeof SelectTrigger> & { label: string; tooltip?: boolean }\n>(({ label, tooltip = true, className, ...props }, ref) => {\n const { controlShape } = useShade();\n const trigger = (\n <SelectTrigger\n ref={ref}\n aria-label={label}\n className={cn(\n 'w-auto gap-1.5 font-medium [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2! [&>svg]:mr-0',\n className,\n )}\n shape={controlShape}\n showChevron={false}\n variant=\"ghost\"\n {...props}\n />\n );\n return tooltip ? (\n <PageHeaderTooltip label={label}>\n <TooltipTrigger asChild>{trigger}</TooltipTrigger>\n </PageHeaderTooltip>\n ) : (\n trigger\n );\n});\nPageHeaderSelectTrigger.displayName = 'PageHeaderSelectTrigger';\n\n// ---------------------------------------------------------------------------\n// Title-block primitives\n// ---------------------------------------------------------------------------\n\nfunction PageHeaderBreadcrumb({ className, children }: PropsWithChildrenAndClassName) {\n return (\n <Inline\n align=\"center\"\n className={cn('pt-1 text-sm text-muted-foreground', className)}\n data-page-header=\"breadcrumb\"\n gap=\"sm\"\n >\n {children}\n </Inline>\n );\n}\n\nfunction PageHeaderCount({ className, children }: PropsWithChildrenAndClassName) {\n return (\n <Text\n as=\"span\"\n className={cn('ml-1 text-base tabular-nums', className)}\n data-page-header=\"count\"\n tone=\"secondary\"\n weight=\"regular\"\n >\n {children}\n </Text>\n );\n}\n\nfunction PageHeaderDescription({ className, children }: PropsWithChildrenAndClassName) {\n return (\n <Text as=\"p\" className={className} data-page-header=\"description\" size=\"sm\" tone=\"secondary\">\n {children}\n </Text>\n );\n}\n\nfunction PageHeaderMeta({ className, children }: PropsWithChildrenAndClassName) {\n return (\n <Text\n as=\"p\"\n className={cn('mt-0.5', className)}\n data-page-header=\"meta\"\n size=\"sm\"\n tone=\"secondary\"\n >\n {children}\n </Text>\n );\n}\n\n/**\n * `Title` accepts heading text plus optional `Count`, `Description`, and `Meta`\n * children. `Count` flows inline inside the H1; `Description` and `Meta` stack\n * below the heading.\n */\nfunction PageHeaderTitle({ className, children }: PropsWithChildrenAndClassName) {\n const largeTitle = React.useContext(PageHeaderLargeTitleContext);\n const registerLargeTitle = largeTitle?.registerTitle;\n React.useLayoutEffect(() => registerLargeTitle?.(), [registerLargeTitle]);\n\n const headingChildren: React.ReactNode[] = [];\n const subTextChildren: React.ReactNode[] = [];\n\n React.Children.forEach(children, (child) => {\n if (!React.isValidElement(child)) {\n headingChildren.push(child);\n return;\n }\n\n switch (child.type) {\n case PageHeaderDescription:\n case PageHeaderMeta:\n subTextChildren.push(child);\n break;\n default:\n headingChildren.push(child);\n }\n });\n\n // Shown large above the page's header, the title is that heading; the one\n // in the header is a stand-in, fading in as the header takes over\n if (largeTitle) {\n return (\n <>\n <H1\n aria-hidden=\"true\"\n className={cn(\n 'large-title-header-title text-lg font-semibold tracking-[0.1px] whitespace-nowrap',\n className,\n )}\n data-page-header=\"title\"\n >\n {headingChildren}\n </H1>\n {largeTitle.slot &&\n createPortal(\n <Stack data-page-header=\"large-title\" gap=\"none\">\n <H1\n className=\"flex items-baseline gap-3 font-medium tracking-[-0.03em] whitespace-nowrap [&_[data-page-header=count]]:tracking-normal\"\n data-large-title=\"\"\n // Inline, over Text's own line height\n style={{ fontSize: 'var(--large-title-size)', lineHeight: 1.15 }}\n >\n {headingChildren}\n </H1>\n {subTextChildren}\n </Stack>,\n largeTitle.slot,\n )}\n </>\n );\n }\n\n const heading = (\n <H1\n className={cn('text-lg font-semibold tracking-[0.1px] whitespace-nowrap', className)}\n data-page-header=\"title\"\n >\n {headingChildren}\n </H1>\n );\n\n if (subTextChildren.length > 0) {\n return (\n <Stack data-page-header=\"title-body\" gap=\"none\">\n {heading}\n {subTextChildren}\n </Stack>\n );\n }\n\n return heading;\n}\n\n// ---------------------------------------------------------------------------\n// Main row — Left (stack: Breadcrumb + Title) + Actions\n// ---------------------------------------------------------------------------\n\nfunction PageHeaderLeft({ className, children }: PropsWithChildrenAndClassName) {\n return (\n <Stack\n className={cn('h-full min-h-(--control-height) min-w-0', className)}\n data-page-header=\"left\"\n gap=\"xs\"\n justify=\"center\"\n >\n {children}\n </Stack>\n );\n}\n\ntype PageHeaderActionGroupPrimaryProps = PropsWithChildrenAndClassName;\nfunction PageHeaderActionGroupPrimary({ children, className }: PageHeaderActionGroupPrimaryProps) {\n if (React.Children.toArray(children).length === 0) {\n return null;\n }\n return (\n <PrimaryActionContext.Provider value={true}>\n <Inline\n className={cn('ms-3 shrink-0 first:ms-0', className)}\n data-page-header=\"primary\"\n gap=\"none\"\n >\n {children}\n </Inline>\n </PrimaryActionContext.Provider>\n );\n}\n\ntype PageHeaderActionGroupMobileMenuProps = React.PropsWithChildren;\nfunction PageHeaderActionGroupMobileMenu({ children }: PageHeaderActionGroupMobileMenuProps) {\n return <DropdownMenu>{children}</DropdownMenu>;\n}\n\ntype PageHeaderActionGroupMobileMenuTriggerProps = React.ComponentPropsWithoutRef<\n typeof DropdownMenuTrigger\n>;\nfunction PageHeaderActionGroupMobileMenuTrigger({\n children,\n ...props\n}: PageHeaderActionGroupMobileMenuTriggerProps) {\n return (\n <DropdownMenuTrigger asChild {...props}>\n {children}\n </DropdownMenuTrigger>\n );\n}\n\ntype PageHeaderActionGroupMobileMenuContentProps = React.ComponentPropsWithoutRef<\n typeof DropdownMenuContent\n>;\nfunction PageHeaderActionGroupMobileMenuContent({\n children,\n ...props\n}: PageHeaderActionGroupMobileMenuContentProps) {\n return (\n <DropdownMenuContent align=\"end\" sideOffset={8} {...props}>\n {children}\n </DropdownMenuContent>\n );\n}\n\nconst DEFAULT_MOBILE_MENU_BREAKPOINT = 640;\n\nconst isBelowBreakpoint = (breakpoint: number) => {\n if (typeof window === 'undefined') {\n return false;\n }\n\n return window.innerWidth < breakpoint;\n};\n\nconst useShouldCollapseActionGroup = (breakpoint: number) => {\n const [shouldCollapse, setShouldCollapse] = React.useState(() => isBelowBreakpoint(breakpoint));\n\n React.useEffect(() => {\n const onResize = () => {\n setShouldCollapse(isBelowBreakpoint(breakpoint));\n };\n\n onResize();\n window.addEventListener('resize', onResize);\n\n return () => {\n window.removeEventListener('resize', onResize);\n };\n }, [breakpoint]);\n\n return shouldCollapse;\n};\n\ntype PageHeaderActionGroupProps = PropsWithChildrenAndClassName & {\n mobileMenuBreakpoint?: number;\n};\ntype PageHeaderActionGroupComponent = React.FC<PageHeaderActionGroupProps> & {\n Primary: React.FC<PageHeaderActionGroupPrimaryProps>;\n MobileMenu: React.FC<PageHeaderActionGroupMobileMenuProps>;\n MobileMenuTrigger: React.FC<PageHeaderActionGroupMobileMenuTriggerProps>;\n MobileMenuContent: React.FC<PageHeaderActionGroupMobileMenuContentProps>;\n};\n\nconst PageHeaderActionGroup: PageHeaderActionGroupComponent = Object.assign(\n function PageHeaderActionGroup({\n className,\n children,\n mobileMenuBreakpoint = DEFAULT_MOBILE_MENU_BREAKPOINT,\n }: PageHeaderActionGroupProps) {\n const gap = 'sm';\n const childNodes = React.Children.toArray(children);\n const desktopChildren: React.ReactNode[] = [];\n let mobileMenu: React.ReactElement | null = null;\n let primaryAction: React.ReactNode = null;\n const shouldCollapse = useShouldCollapseActionGroup(mobileMenuBreakpoint);\n\n childNodes.forEach((child) => {\n if (!React.isValidElement(child)) {\n desktopChildren.push(child);\n return;\n }\n\n const childElement = child as React.ReactElement<{ children?: React.ReactNode }>;\n\n if (childElement.type === PageHeaderActionGroupMobileMenu) {\n mobileMenu = childElement;\n return;\n }\n\n if (childElement.type === PageHeaderActionGroupPrimary) {\n primaryAction = childElement;\n desktopChildren.push(childElement);\n return;\n }\n\n desktopChildren.push(childElement);\n });\n\n if (!mobileMenu) {\n return (\n <HeaderTooltipProvider>\n <Inline\n align=\"center\"\n className={className}\n data-page-header=\"action-group\"\n gap={gap}\n justify=\"end\"\n >\n {children}\n </Inline>\n </HeaderTooltipProvider>\n );\n }\n\n if (!shouldCollapse) {\n return (\n <HeaderTooltipProvider>\n <Inline\n align=\"center\"\n className={className}\n data-page-header=\"action-group\"\n gap={gap}\n justify=\"end\"\n >\n <Inline align=\"center\" data-page-header=\"action-group-desktop\" gap={gap} justify=\"end\">\n {desktopChildren}\n </Inline>\n </Inline>\n </HeaderTooltipProvider>\n );\n }\n\n return (\n <HeaderTooltipProvider>\n <Inline\n align=\"center\"\n className={className}\n data-page-header=\"action-group\"\n gap={gap}\n justify=\"end\"\n >\n <Inline\n align=\"center\"\n className=\"ml-auto\"\n data-page-header=\"action-group-mobile\"\n gap={gap}\n >\n {mobileMenu}\n {primaryAction}\n </Inline>\n </Inline>\n </HeaderTooltipProvider>\n );\n },\n {\n Primary: PageHeaderActionGroupPrimary,\n MobileMenu: PageHeaderActionGroupMobileMenu,\n MobileMenuTrigger: PageHeaderActionGroupMobileMenuTrigger,\n MobileMenuContent: PageHeaderActionGroupMobileMenuContent,\n },\n);\n\nfunction PageHeaderActions({ className, children }: PropsWithChildrenAndClassName) {\n return (\n <HeaderTooltipProvider>\n <Inline\n align=\"center\"\n className={cn('min-h-(--control-height) shrink-0', className)}\n data-page-header=\"actions\"\n gap=\"lg\"\n >\n {children}\n </Inline>\n </HeaderTooltipProvider>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Root\n// ---------------------------------------------------------------------------\n\ntype PageHeaderComponent = React.FC<PageHeaderProps> & {\n Left: React.FC<PropsWithChildrenAndClassName>;\n Breadcrumb: React.FC<PropsWithChildrenAndClassName>;\n Title: React.FC<PropsWithChildrenAndClassName>;\n Count: React.FC<PropsWithChildrenAndClassName>;\n Description: React.FC<PropsWithChildrenAndClassName>;\n Meta: React.FC<PropsWithChildrenAndClassName>;\n Actions: React.FC<PropsWithChildrenAndClassName>;\n ActionGroup: PageHeaderActionGroupComponent;\n Action: typeof PageHeaderAction;\n FilterTrigger: typeof PageHeaderFilterTrigger;\n SelectTrigger: typeof PageHeaderSelectTrigger;\n Tooltip: typeof PageHeaderTooltip;\n TooltipTrigger: typeof TooltipTrigger;\n};\n\n/**\n * PageHeader is the canonical page-chrome component for Ghost Admin pages.\n *\n * The main row contains `Left` (Breadcrumb + Title) and `Actions`.\n * Compose optional ViewBar and FilterBar rows beside it in ListPage.Header.\n * `Title` accepts an inline `Count` and stacked `Description`/`Meta` children.\n * See the design contract for the action ordering and interaction rules:\n * https://shade.ghost.org/docs/components/patterns/page-header.md (generated from page-header.mdx).\n */\nconst PageHeader: PageHeaderComponent = Object.assign(\n function PageHeader({\n className,\n children,\n sticky = true,\n blurredBackground = true,\n }: PageHeaderProps) {\n return (\n <header\n className={cn(\n 'flex flex-col',\n sticky && 'sticky top-0 z-50',\n blurredBackground &&\n 'bg-gradient-to-b from-background via-background/70 to-background/70 backdrop-blur-md',\n className,\n )}\n data-page-header=\"page-header\"\n >\n <Inline align=\"start\" className=\"w-full\" data-page-header=\"main\" gap=\"lg\" justify=\"between\">\n {children}\n </Inline>\n </header>\n );\n },\n {\n Left: PageHeaderLeft,\n Breadcrumb: PageHeaderBreadcrumb,\n Title: PageHeaderTitle,\n Count: PageHeaderCount,\n Description: PageHeaderDescription,\n Meta: PageHeaderMeta,\n Actions: PageHeaderActions,\n ActionGroup: PageHeaderActionGroup,\n Action: PageHeaderAction,\n FilterTrigger: PageHeaderFilterTrigger,\n SelectTrigger: PageHeaderSelectTrigger,\n Tooltip: PageHeaderTooltip,\n TooltipTrigger,\n },\n);\n\nexport {\n PageHeader,\n PageHeaderLeft,\n PageHeaderBreadcrumb,\n PageHeaderTitle,\n PageHeaderCount,\n PageHeaderDescription,\n PageHeaderMeta,\n PageHeaderActions,\n PageHeaderActionGroup,\n PageHeaderActionGroupPrimary,\n PageHeaderActionGroupMobileMenu,\n PageHeaderActionGroupMobileMenuTrigger,\n PageHeaderActionGroupMobileMenuContent,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiCA,SAAS,kBAAkB,EACzB,UACA,OACA,YACiE;CACjE,OACE,qBAAC,SAAD,EAAA,UAAA,CACG,UACD,oBAAC,gBAAD;EAAgB,MAAK;EAAS,SAAQ;YACpC,qBAAC,QAAD;GAAQ,OAAM;GAAS,KAAI;aAA3B,CACG,OACA,YAAY,oBAAC,KAAD,EAAA,UAAM,SAAc,CAAA,CAC3B;;CACM,CAAA,CACT,EAAA,CAAA;AAEb;AAEA,IAAM,uBAAuB,MAAM,cAAc,KAAK;AAWtD,IAAM,mBAAmB,MA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ACE,oBAAC,uBAAD,EAAA,UACE,oBAAC,QAAD;EACE,OAAM;EACK;EACX,oBAAiB;EACZ;EACL,SAAQ;YAER,qBAAC,QAAD;GACE,OAAM;GACN,WAAU;GACV,oBAAiB;GACZ;aAJP,CAMG,YACA,aACK;;CACF,CAAA,EACa,CAAA;AAE3B,GACA;CACE,SAAS;CACT,YAAY;CACZ,mBAAmB;CACnB,mBAAmB;AACrB,CACF;AAEA,SAAS,kBAAkB,EAAE,WAAW,YAA2C;CACjF,OACE,oBAAC,uBAAD,EAAA,UACE,oBAAC,QAAD;EACE,OAAM;EACN,WAAW,GAAG,qCAAqC,SAAS;EAC5D,oBAAiB;EACjB,KAAI;EAEH;CACK,CAAA,EACa,CAAA;AAE3B;;;;;;;;;;AA+BA,IAAM,aAAkC,OAAO,OAC7C,SAAS,WAAW,EAClB,WACA,UACA,SAAS,MACT,oBAAoB,QACF;CAClB,OACE,oBAAC,UAAD;EACE,WAAW,GACT,iBACA,UAAU,qBACV,qBACE,wFACF,SACF;EACA,oBAAiB;YAEjB,oBAAC,QAAD;GAAQ,OAAM;GAAQ,WAAU;GAAS,oBAAiB;GAAO,KAAI;GAAK,SAAQ;GAC/E;EACK,CAAA;CACF,CAAA;AAEZ,GACA;CACE,MAAM;CACN,YAAY;CACZ,OAAO;CACP,OAAO;CACP,aAAa;CACb,MAAM;CACN,SAAS;CACT,aAAa;CACb,QAAQ;CACR,eAAe;CACf,eAAe;CACf,SAAS;CACT;AACF,CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { cva } from "class-variance-authority";
|
|
2
2
|
//#region src/components/patterns/setting-group-variants.ts
|
|
3
|
-
var settingGroupVariants = cva("group/setting-group relative flex flex-col gap-6 rounded-
|
|
3
|
+
var settingGroupVariants = cva("group/setting-group relative flex flex-col gap-6 rounded-card text-card-foreground transition-all", {
|
|
4
4
|
variants: {
|
|
5
5
|
variant: {
|
|
6
6
|
outline: "border border-border-default bg-card p-5 hover:shadow-sm md:p-7",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setting-group-variants.js","names":[],"sources":["../../../src/components/patterns/setting-group-variants.ts"],"sourcesContent":["import { cva } from 'class-variance-authority';\n\nconst settingGroupVariants = cva(\n 'group/setting-group relative flex flex-col gap-6 rounded-
|
|
1
|
+
{"version":3,"file":"setting-group-variants.js","names":[],"sources":["../../../src/components/patterns/setting-group-variants.ts"],"sourcesContent":["import { cva } from 'class-variance-authority';\n\nconst settingGroupVariants = cva(\n 'group/setting-group relative flex flex-col gap-6 rounded-card text-card-foreground transition-all',\n {\n variants: {\n variant: {\n outline: 'border border-border-default bg-card p-5 hover:shadow-sm md:p-7',\n plain: 'bg-transparent',\n },\n highlighted: {\n true: 'shadow-sm',\n false: '',\n },\n },\n defaultVariants: {\n variant: 'outline',\n highlighted: false,\n },\n },\n);\n\nexport { settingGroupVariants };\n"],"mappings":";;AAEA,IAAM,uBAAuB,IAC3B,qGACA;CACE,UAAU;EACR,SAAS;GACP,SAAS;GACT,OAAO;EACT;EACA,aAAa;GACX,MAAM;GACN,OAAO;EACT;CACF;CACA,iBAAiB;EACf,SAAS;EACT,aAAa;CACf;AACF,CACF"}
|
|
@@ -38,7 +38,7 @@ SettingGroupDetails.displayName = "SettingGroupDetails";
|
|
|
38
38
|
var SettingGroupTitle = React$1.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(Text, {
|
|
39
39
|
ref,
|
|
40
40
|
as: "h5",
|
|
41
|
-
className: cn("md:text-lg", className),
|
|
41
|
+
className: cn("section-heading settings-heading md:text-lg", className),
|
|
42
42
|
leading: "supertight",
|
|
43
43
|
weight: "semibold",
|
|
44
44
|
...props
|
|
@@ -46,7 +46,7 @@ var SettingGroupTitle = React$1.forwardRef(({ className, ...props }, ref) => /*
|
|
|
46
46
|
SettingGroupTitle.displayName = "SettingGroupTitle";
|
|
47
47
|
var SettingGroupDescription = React$1.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(Text, {
|
|
48
48
|
ref,
|
|
49
|
-
className: cn("mr-5 hidden text-pretty group-data-[editing=false]/setting-group:block md:block", className),
|
|
49
|
+
className: cn("mr-5 hidden text-pretty group-data-[editing=false]/setting-group:block in-data-[admin7-design=true]:text-muted-foreground md:block", className),
|
|
50
50
|
...props
|
|
51
51
|
}));
|
|
52
52
|
SettingGroupDescription.displayName = "SettingGroupDescription";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setting-group.js","names":[],"sources":["../../../src/components/patterns/setting-group.tsx"],"sourcesContent":["import * as React from 'react';\nimport { type VariantProps } from 'class-variance-authority';\n\nimport { settingGroupVariants } from '@/components/patterns/setting-group-variants';\nimport { Grid } from '@/components/primitives/grid';\nimport { Inline } from '@/components/primitives/inline';\nimport { Stack } from '@/components/primitives/stack';\nimport { Text } from '@/components/primitives/text';\nimport { cn } from '@/lib/utils';\n\ninterface SettingGroupProps\n extends React.ComponentPropsWithoutRef<'div'>, VariantProps<typeof settingGroupVariants> {\n editing?: boolean;\n}\n\nconst SettingGroup = React.forwardRef<HTMLDivElement, SettingGroupProps>(\n ({ className, variant, highlighted, editing = false, ...props }, ref) => (\n <div\n ref={ref}\n className={cn(settingGroupVariants({ variant, highlighted, className }))}\n data-editing={editing}\n {...props}\n />\n ),\n);\nSettingGroup.displayName = 'SettingGroup';\n\nconst SettingGroupHeader = React.forwardRef<\n HTMLElement,\n React.ComponentPropsWithoutRef<typeof Inline>\n>(({ className, ...props }, ref) => (\n <Inline\n ref={ref}\n align=\"start\"\n as=\"div\"\n className={cn('relative z-10 w-full', className)}\n gap=\"lg\"\n justify=\"between\"\n {...props}\n />\n));\nSettingGroupHeader.displayName = 'SettingGroupHeader';\n\nconst SettingGroupDetails = React.forwardRef<\n HTMLDivElement,\n React.ComponentPropsWithoutRef<typeof Stack>\n>(({ className, ...props }, ref) => (\n <Stack ref={ref} className={cn('min-w-0', className)} gap=\"xs\" {...props} />\n));\nSettingGroupDetails.displayName = 'SettingGroupDetails';\n\nconst SettingGroupTitle = React.forwardRef<\n HTMLElement,\n React.ComponentPropsWithoutRef<typeof Text>\n>(({ className, ...props }, ref) => (\n <Text\n ref={ref}\n as=\"h5\"\n className={cn('md:text-lg', className)}\n leading=\"supertight\"\n weight=\"semibold\"\n {...props}\n />\n));\nSettingGroupTitle.displayName = 'SettingGroupTitle';\n\nconst SettingGroupDescription = React.forwardRef<\n HTMLElement,\n React.ComponentPropsWithoutRef<typeof Text>\n>(({ className, ...props }, ref) => (\n <Text\n ref={ref}\n className={cn(\n 'mr-5 hidden text-pretty group-data-[editing=false]/setting-group:block md:block',\n className,\n )}\n {...props}\n />\n));\nSettingGroupDescription.displayName = 'SettingGroupDescription';\n\nconst SettingGroupActions = React.forwardRef<HTMLDivElement, React.ComponentPropsWithoutRef<'div'>>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={cn('shrink-0 [&_button]:text-control!', className)} {...props} />\n ),\n);\nSettingGroupActions.displayName = 'SettingGroupActions';\n\ninterface SettingGroupContentProps extends React.ComponentPropsWithoutRef<'div'> {\n columns?: 1 | 2;\n}\n\nconst SettingGroupContent = React.forwardRef<HTMLDivElement, SettingGroupContentProps>(\n ({ children, className, columns = 1, ...props }, ref) => {\n if (columns === 2) {\n return (\n <Grid\n ref={ref}\n className={cn('grid-cols-1 gap-x-8 gap-y-6 md:grid-cols-2', className)}\n columns={1}\n gap=\"none\"\n {...props}\n >\n {children}\n </Grid>\n );\n }\n\n return (\n <Stack ref={ref} className={cn('gap-y-7', className)} gap=\"none\" {...props}>\n {children}\n </Stack>\n );\n },\n);\nSettingGroupContent.displayName = 'SettingGroupContent';\n\nconst SettingGroupValue = React.forwardRef<\n HTMLDivElement,\n React.ComponentPropsWithoutRef<typeof Stack>\n>(({ className, ...props }, ref) => (\n <Stack ref={ref} className={className} gap=\"none\" {...props} />\n));\nSettingGroupValue.displayName = 'SettingGroupValue';\n\nconst SettingGroupValueTitle = React.forwardRef<\n HTMLElement,\n React.ComponentPropsWithoutRef<typeof Text>\n>(({ className, ...props }, ref) => (\n <Text ref={ref} as=\"h6\" className={cn('text-base', className)} weight=\"semibold\" {...props} />\n));\nSettingGroupValueTitle.displayName = 'SettingGroupValueTitle';\n\nconst SettingGroupValueContent = React.forwardRef<\n HTMLElement,\n React.ComponentPropsWithoutRef<typeof Inline>\n>(({ className, ...props }, ref) => (\n <Inline ref={ref} as=\"div\" className={className} gap=\"none\" {...props} />\n));\nSettingGroupValueContent.displayName = 'SettingGroupValueContent';\n\nexport {\n SettingGroup,\n SettingGroupActions,\n SettingGroupContent,\n SettingGroupDescription,\n SettingGroupDetails,\n SettingGroupHeader,\n SettingGroupTitle,\n SettingGroupValue,\n SettingGroupValueContent,\n SettingGroupValueTitle,\n};\nexport type { SettingGroupContentProps, SettingGroupProps };\n"],"mappings":";;;;;;;;;AAeA,IAAM,eAAe,QAAM,YACxB,EAAE,WAAW,SAAS,aAAa,UAAU,OAAO,GAAG,SAAS,QAC/D,oBAAC,OAAD;CACO;CACL,WAAW,GAAG,qBAAqB;EAAE;EAAS;EAAa;CAAU,CAAC,CAAC;CACvE,gBAAc;CACd,GAAI;AACL,CAAA,CAEL;AACA,aAAa,cAAc;AAE3B,IAAM,qBAAqB,QAAM,YAG9B,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,QAAD;CACO;CACL,OAAM;CACN,IAAG;CACH,WAAW,GAAG,wBAAwB,SAAS;CAC/C,KAAI;CACJ,SAAQ;CACR,GAAI;AACL,CAAA,CACF;AACD,mBAAmB,cAAc;AAEjC,IAAM,sBAAsB,QAAM,YAG/B,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,OAAD;CAAY;CAAK,WAAW,GAAG,WAAW,SAAS;CAAG,KAAI;CAAK,GAAI;AAAQ,CAAA,CAC5E;AACD,oBAAoB,cAAc;AAElC,IAAM,oBAAoB,QAAM,YAG7B,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,MAAD;CACO;CACL,IAAG;CACH,WAAW,GAAG,
|
|
1
|
+
{"version":3,"file":"setting-group.js","names":[],"sources":["../../../src/components/patterns/setting-group.tsx"],"sourcesContent":["import * as React from 'react';\nimport { type VariantProps } from 'class-variance-authority';\n\nimport { settingGroupVariants } from '@/components/patterns/setting-group-variants';\nimport { Grid } from '@/components/primitives/grid';\nimport { Inline } from '@/components/primitives/inline';\nimport { Stack } from '@/components/primitives/stack';\nimport { Text } from '@/components/primitives/text';\nimport { cn } from '@/lib/utils';\n\ninterface SettingGroupProps\n extends React.ComponentPropsWithoutRef<'div'>, VariantProps<typeof settingGroupVariants> {\n editing?: boolean;\n}\n\nconst SettingGroup = React.forwardRef<HTMLDivElement, SettingGroupProps>(\n ({ className, variant, highlighted, editing = false, ...props }, ref) => (\n <div\n ref={ref}\n className={cn(settingGroupVariants({ variant, highlighted, className }))}\n data-editing={editing}\n {...props}\n />\n ),\n);\nSettingGroup.displayName = 'SettingGroup';\n\nconst SettingGroupHeader = React.forwardRef<\n HTMLElement,\n React.ComponentPropsWithoutRef<typeof Inline>\n>(({ className, ...props }, ref) => (\n <Inline\n ref={ref}\n align=\"start\"\n as=\"div\"\n className={cn('relative z-10 w-full', className)}\n gap=\"lg\"\n justify=\"between\"\n {...props}\n />\n));\nSettingGroupHeader.displayName = 'SettingGroupHeader';\n\nconst SettingGroupDetails = React.forwardRef<\n HTMLDivElement,\n React.ComponentPropsWithoutRef<typeof Stack>\n>(({ className, ...props }, ref) => (\n <Stack ref={ref} className={cn('min-w-0', className)} gap=\"xs\" {...props} />\n));\nSettingGroupDetails.displayName = 'SettingGroupDetails';\n\nconst SettingGroupTitle = React.forwardRef<\n HTMLElement,\n React.ComponentPropsWithoutRef<typeof Text>\n>(({ className, ...props }, ref) => (\n <Text\n ref={ref}\n as=\"h5\"\n className={cn('section-heading settings-heading md:text-lg', className)}\n leading=\"supertight\"\n weight=\"semibold\"\n {...props}\n />\n));\nSettingGroupTitle.displayName = 'SettingGroupTitle';\n\nconst SettingGroupDescription = React.forwardRef<\n HTMLElement,\n React.ComponentPropsWithoutRef<typeof Text>\n>(({ className, ...props }, ref) => (\n <Text\n ref={ref}\n className={cn(\n 'mr-5 hidden text-pretty group-data-[editing=false]/setting-group:block in-data-[admin7-design=true]:text-muted-foreground md:block',\n className,\n )}\n {...props}\n />\n));\nSettingGroupDescription.displayName = 'SettingGroupDescription';\n\nconst SettingGroupActions = React.forwardRef<HTMLDivElement, React.ComponentPropsWithoutRef<'div'>>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={cn('shrink-0 [&_button]:text-control!', className)} {...props} />\n ),\n);\nSettingGroupActions.displayName = 'SettingGroupActions';\n\ninterface SettingGroupContentProps extends React.ComponentPropsWithoutRef<'div'> {\n columns?: 1 | 2;\n}\n\nconst SettingGroupContent = React.forwardRef<HTMLDivElement, SettingGroupContentProps>(\n ({ children, className, columns = 1, ...props }, ref) => {\n if (columns === 2) {\n return (\n <Grid\n ref={ref}\n className={cn('grid-cols-1 gap-x-8 gap-y-6 md:grid-cols-2', className)}\n columns={1}\n gap=\"none\"\n {...props}\n >\n {children}\n </Grid>\n );\n }\n\n return (\n <Stack ref={ref} className={cn('gap-y-7', className)} gap=\"none\" {...props}>\n {children}\n </Stack>\n );\n },\n);\nSettingGroupContent.displayName = 'SettingGroupContent';\n\nconst SettingGroupValue = React.forwardRef<\n HTMLDivElement,\n React.ComponentPropsWithoutRef<typeof Stack>\n>(({ className, ...props }, ref) => (\n <Stack ref={ref} className={className} gap=\"none\" {...props} />\n));\nSettingGroupValue.displayName = 'SettingGroupValue';\n\nconst SettingGroupValueTitle = React.forwardRef<\n HTMLElement,\n React.ComponentPropsWithoutRef<typeof Text>\n>(({ className, ...props }, ref) => (\n <Text ref={ref} as=\"h6\" className={cn('text-base', className)} weight=\"semibold\" {...props} />\n));\nSettingGroupValueTitle.displayName = 'SettingGroupValueTitle';\n\nconst SettingGroupValueContent = React.forwardRef<\n HTMLElement,\n React.ComponentPropsWithoutRef<typeof Inline>\n>(({ className, ...props }, ref) => (\n <Inline ref={ref} as=\"div\" className={className} gap=\"none\" {...props} />\n));\nSettingGroupValueContent.displayName = 'SettingGroupValueContent';\n\nexport {\n SettingGroup,\n SettingGroupActions,\n SettingGroupContent,\n SettingGroupDescription,\n SettingGroupDetails,\n SettingGroupHeader,\n SettingGroupTitle,\n SettingGroupValue,\n SettingGroupValueContent,\n SettingGroupValueTitle,\n};\nexport type { SettingGroupContentProps, SettingGroupProps };\n"],"mappings":";;;;;;;;;AAeA,IAAM,eAAe,QAAM,YACxB,EAAE,WAAW,SAAS,aAAa,UAAU,OAAO,GAAG,SAAS,QAC/D,oBAAC,OAAD;CACO;CACL,WAAW,GAAG,qBAAqB;EAAE;EAAS;EAAa;CAAU,CAAC,CAAC;CACvE,gBAAc;CACd,GAAI;AACL,CAAA,CAEL;AACA,aAAa,cAAc;AAE3B,IAAM,qBAAqB,QAAM,YAG9B,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,QAAD;CACO;CACL,OAAM;CACN,IAAG;CACH,WAAW,GAAG,wBAAwB,SAAS;CAC/C,KAAI;CACJ,SAAQ;CACR,GAAI;AACL,CAAA,CACF;AACD,mBAAmB,cAAc;AAEjC,IAAM,sBAAsB,QAAM,YAG/B,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,OAAD;CAAY;CAAK,WAAW,GAAG,WAAW,SAAS;CAAG,KAAI;CAAK,GAAI;AAAQ,CAAA,CAC5E;AACD,oBAAoB,cAAc;AAElC,IAAM,oBAAoB,QAAM,YAG7B,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,MAAD;CACO;CACL,IAAG;CACH,WAAW,GAAG,+CAA+C,SAAS;CACtE,SAAQ;CACR,QAAO;CACP,GAAI;AACL,CAAA,CACF;AACD,kBAAkB,cAAc;AAEhC,IAAM,0BAA0B,QAAM,YAGnC,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,MAAD;CACO;CACL,WAAW,GACT,sIACA,SACF;CACA,GAAI;AACL,CAAA,CACF;AACD,wBAAwB,cAAc;AAEtC,IAAM,sBAAsB,QAAM,YAC/B,EAAE,WAAW,GAAG,SAAS,QACxB,oBAAC,OAAD;CAAU;CAAK,WAAW,GAAG,qCAAqC,SAAS;CAAG,GAAI;AAAQ,CAAA,CAE9F;AACA,oBAAoB,cAAc;AAMlC,IAAM,sBAAsB,QAAM,YAC/B,EAAE,UAAU,WAAW,UAAU,GAAG,GAAG,SAAS,QAAQ;CACvD,IAAI,YAAY,GACd,OACE,oBAAC,MAAD;EACO;EACL,WAAW,GAAG,8CAA8C,SAAS;EACrE,SAAS;EACT,KAAI;EACJ,GAAI;EAEH;CACG,CAAA;CAIV,OACE,oBAAC,OAAD;EAAY;EAAK,WAAW,GAAG,WAAW,SAAS;EAAG,KAAI;EAAO,GAAI;EAClE;CACI,CAAA;AAEX,CACF;AACA,oBAAoB,cAAc;AAElC,IAAM,oBAAoB,QAAM,YAG7B,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,OAAD;CAAY;CAAgB;CAAW,KAAI;CAAO,GAAI;AAAQ,CAAA,CAC/D;AACD,kBAAkB,cAAc;AAEhC,IAAM,yBAAyB,QAAM,YAGlC,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,MAAD;CAAW;CAAK,IAAG;CAAK,WAAW,GAAG,aAAa,SAAS;CAAG,QAAO;CAAW,GAAI;AAAQ,CAAA,CAC9F;AACD,uBAAuB,cAAc;AAErC,IAAM,2BAA2B,QAAM,YAGpC,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,QAAD;CAAa;CAAK,IAAG;CAAiB;CAAW,KAAI;CAAO,GAAI;AAAQ,CAAA,CACzE;AACD,yBAAyB,cAAc"}
|
|
@@ -3,11 +3,11 @@ import { cn } from "../../lib/ds-utils.js";
|
|
|
3
3
|
import { Box } from "../primitives/box.js";
|
|
4
4
|
import { Inline } from "../primitives/inline.js";
|
|
5
5
|
import { Text } from "../primitives/text.js";
|
|
6
|
+
import { LoadingIndicator } from "../ui/loading-indicator.js";
|
|
6
7
|
import { Button } from "../ui/button.js";
|
|
7
8
|
import { DirtyConfirmDialog } from "./dirty-confirm-dialog.js";
|
|
8
9
|
import { useDirtyConfirmation } from "./use-dirty-confirmation.js";
|
|
9
10
|
import { settingsModalVariants } from "./settings-modal-variants.js";
|
|
10
|
-
import { LoadingIndicator } from "../ui/loading-indicator.js";
|
|
11
11
|
import { StickyFooter } from "../ui/sticky-footer.js";
|
|
12
12
|
import { X } from "lucide-react";
|
|
13
13
|
import { forwardRef, useEffect, useState } from "react";
|
|
@@ -136,7 +136,7 @@ var SettingsModal = forwardRef(({ "aria-label": ariaLabel, className, size = "md
|
|
|
136
136
|
});
|
|
137
137
|
const titleContent = title && /* @__PURE__ */ jsx(Text, {
|
|
138
138
|
as: "h3",
|
|
139
|
-
className: "md:text-2xl",
|
|
139
|
+
className: "in-data-[admin7-design=true]:font-title md:text-2xl",
|
|
140
140
|
leading: "heading",
|
|
141
141
|
size: "xl",
|
|
142
142
|
weight: "bold",
|