@squadbase/vantage 0.6.2 → 0.7.0-stg.18ca87d
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/dist/add-4GHF2TX2.js +6 -0
- package/dist/add-4GHF2TX2.js.map +1 -0
- package/dist/{build-O5TVNH4E.js → build-U7GO26HR.js} +9 -9
- package/dist/{build-O5TVNH4E.js.map → build-U7GO26HR.js.map} +1 -1
- package/dist/{check-WFBEDHDR.js → check-MRVAIHG5.js} +7 -7
- package/dist/{check-WFBEDHDR.js.map → check-MRVAIHG5.js.map} +1 -1
- package/dist/chunk-2IAPIOPS.js +152 -0
- package/dist/chunk-2IAPIOPS.js.map +1 -0
- package/dist/chunk-3RJEOP3J.js +174 -0
- package/dist/chunk-3RJEOP3J.js.map +1 -0
- package/dist/chunk-77CISBMG.js +7581 -0
- package/dist/chunk-77CISBMG.js.map +1 -0
- package/dist/{chunk-QDZA5JSL.js → chunk-AABMKHEU.js} +4 -4
- package/dist/{chunk-QDZA5JSL.js.map → chunk-AABMKHEU.js.map} +1 -1
- package/dist/{chunk-PVTHHV7X.js → chunk-ANZLVSEP.js} +28 -7
- package/dist/chunk-ANZLVSEP.js.map +1 -0
- package/dist/chunk-CKWPK4RO.js +50 -0
- package/dist/chunk-CKWPK4RO.js.map +1 -0
- package/dist/chunk-EG4PX726.js +678 -0
- package/dist/chunk-EG4PX726.js.map +1 -0
- package/dist/{chunk-3G43C6OL.js → chunk-GNXCX4WE.js} +46 -3
- package/dist/chunk-GNXCX4WE.js.map +1 -0
- package/dist/chunk-NZ5QIIG4.js +74 -0
- package/dist/chunk-NZ5QIIG4.js.map +1 -0
- package/dist/{chunk-BCE22JSM.js → chunk-PJ4SPXHS.js} +52 -16
- package/dist/chunk-PJ4SPXHS.js.map +1 -0
- package/dist/{chunk-RPZAALCX.js → chunk-QNOX7WLZ.js} +256 -165
- package/dist/chunk-QNOX7WLZ.js.map +1 -0
- package/dist/{chunk-ZVANIULZ.js → chunk-RNTDBX6S.js} +4 -4
- package/dist/{chunk-ZVANIULZ.js.map → chunk-RNTDBX6S.js.map} +1 -1
- package/dist/{chunk-PXRX5PEC.js → chunk-ROHNXP7J.js} +73 -4
- package/dist/chunk-ROHNXP7J.js.map +1 -0
- package/dist/chunk-S5MDTHH7.js +466 -0
- package/dist/chunk-S5MDTHH7.js.map +1 -0
- package/dist/chunk-SDJTTMLK.js +1877 -0
- package/dist/chunk-SDJTTMLK.js.map +1 -0
- package/dist/{chunk-EP6JHXSR.js → chunk-SHZM3EXB.js} +68 -12
- package/dist/chunk-SHZM3EXB.js.map +1 -0
- package/dist/chunk-TRMHNMMZ.js +61 -0
- package/dist/chunk-TRMHNMMZ.js.map +1 -0
- package/dist/{chunk-A2UUGASH.js → chunk-U736PVHY.js} +2 -2
- package/dist/chunk-U736PVHY.js.map +1 -0
- package/dist/{chunk-JGRMRXXZ.js → chunk-UWSQUHX6.js} +4 -99
- package/dist/chunk-UWSQUHX6.js.map +1 -0
- package/dist/cli.js +15 -11
- package/dist/cli.js.map +1 -1
- package/dist/client/index.d.ts +34 -3
- package/dist/client/index.js +211 -12
- package/dist/client/index.js.map +1 -1
- package/dist/components/index.d.ts +1768 -30
- package/dist/components/index.js +7 -4
- package/dist/delta-text-CbrOaW83.d.ts +17 -0
- package/dist/{dev-NZRLOQCL.js → dev-O42JFQ64.js} +24 -13
- package/dist/dev-O42JFQ64.js.map +1 -0
- package/dist/doc/index.d.ts +215 -2
- package/dist/doc/index.js +423 -5
- package/dist/doc/index.js.map +1 -1
- package/dist/{docs-ZGDJUHJI.js → docs-JVP4RPKT.js} +3 -3
- package/dist/{docs-ZGDJUHJI.js.map → docs-JVP4RPKT.js.map} +1 -1
- package/dist/{doctor-VFKEMR54.js → doctor-YD3XAAOT.js} +8 -8
- package/dist/doctor-YD3XAAOT.js.map +1 -0
- package/dist/format-DihQkL1N.d.ts +249 -0
- package/dist/markdown/index.js +1 -1
- package/dist/markdown/index.js.map +1 -1
- package/dist/{preview-QDCIVVSR.js → preview-T6CLSQVX.js} +12 -4
- package/dist/preview-T6CLSQVX.js.map +1 -0
- package/dist/query/index.d.ts +0 -11
- package/dist/query/index.js +2 -2
- package/dist/{routes-RHP5FVGD.js → routes-PVKNT777.js} +6 -6
- package/dist/{routes-RHP5FVGD.js.map → routes-PVKNT777.js.map} +1 -1
- package/dist/{search-RFBELGY7.js → search-5LC4XPB5.js} +3 -3
- package/dist/{search-RFBELGY7.js.map → search-5LC4XPB5.js.map} +1 -1
- package/dist/slide/index.d.ts +272 -1
- package/dist/slide/index.js +1086 -19
- package/dist/slide/index.js.map +1 -1
- package/dist/table/index.js +14 -10
- package/dist/table/index.js.map +1 -1
- package/dist/ui/index.d.ts +148 -12
- package/dist/ui/index.js +1340 -88
- package/dist/ui/index.js.map +1 -1
- package/dist/{upgrade-GF2P67M6.js → upgrade-6DT7ADRP.js} +7 -7
- package/dist/{upgrade-GF2P67M6.js.map → upgrade-6DT7ADRP.js.map} +1 -1
- package/dist/vite/index.d.ts +10 -0
- package/dist/vite/index.js +4 -4
- package/docs/en/agent-skills.md +1 -1
- package/docs/en/changelog.md +82 -0
- package/docs/en/cli-reference.md +30 -0
- package/docs/en/components.md +42 -17
- package/docs/en/doc/delta-text.md +40 -0
- package/docs/en/doc/doc-action-items.md +49 -0
- package/docs/en/doc/doc-callout.md +38 -0
- package/docs/en/doc/doc-data-table.md +60 -0
- package/docs/en/doc/doc-executive-summary.md +64 -0
- package/docs/en/doc/doc-figure.md +56 -0
- package/docs/en/doc/doc-key-findings.md +61 -0
- package/docs/en/doc/doc-kpi-scorecard.md +80 -0
- package/docs/en/doc/doc-notes-and-sources.md +43 -0
- package/docs/en/doc/doc-report-header.md +46 -0
- package/docs/en/pages-and-metadata.md +15 -0
- package/docs/en/parts/area-chart.md +99 -0
- package/docs/en/parts/bar-chart.md +91 -0
- package/docs/en/parts/bar-list.md +50 -0
- package/docs/en/parts/category-bar.md +37 -0
- package/docs/en/parts/chart-frame.md +39 -0
- package/docs/en/parts/data-table.md +22 -0
- package/docs/en/parts/delta.md +51 -0
- package/docs/en/parts/donut-chart.md +72 -0
- package/docs/en/parts/format.md +43 -0
- package/docs/en/parts/funnel-steps.md +2 -1
- package/docs/en/parts/heatmap.md +53 -0
- package/docs/en/parts/kpi-card.md +58 -0
- package/docs/en/parts/legend.md +35 -0
- package/docs/en/parts/line-chart.md +94 -0
- package/docs/en/parts/metric-value.md +3 -2
- package/docs/en/parts/page-shell.md +1 -1
- package/docs/en/parts/progress-circle.md +33 -0
- package/docs/en/parts/sample-data.md +39 -0
- package/docs/en/parts/scatter-chart.md +56 -0
- package/docs/en/parts/sparkline.md +1 -1
- package/docs/en/parts/tracker.md +36 -0
- package/docs/en/parts/trend-indicator.md +17 -1
- package/docs/en/parts/updated-at.md +30 -0
- package/docs/en/parts/waterfall-chart.md +56 -0
- package/docs/en/slide/slide-chart-full.md +48 -0
- package/docs/en/slide/slide-chart-insight.md +52 -0
- package/docs/en/slide/slide-columns.md +46 -0
- package/docs/en/slide/slide-comparison.md +68 -0
- package/docs/en/slide/slide-cover.md +39 -0
- package/docs/en/slide/slide-exec-summary.md +47 -0
- package/docs/en/slide/slide-heading.md +38 -0
- package/docs/en/slide/slide-kpi-grid.md +55 -0
- package/docs/en/slide/slide-kpi-hero.md +58 -0
- package/docs/en/slide/slide-next-actions.md +49 -0
- package/docs/en/slide/slide-scorecard-table.md +54 -0
- package/docs/en/slide/slide-section.md +44 -0
- package/docs/en/slide/slide-source-line.md +34 -0
- package/docs/en/ui/alert-dialog.md +42 -0
- package/docs/en/ui/avatar.md +31 -0
- package/docs/en/ui/combobox.md +74 -0
- package/docs/en/ui/drawer.md +41 -0
- package/docs/en/ui/empty.md +1 -1
- package/docs/en/ui/error-state.md +4 -3
- package/docs/en/ui/field.md +42 -0
- package/docs/en/ui/hover-card.md +21 -0
- package/docs/en/ui/kbd.md +17 -0
- package/docs/en/ui/loading.md +1 -1
- package/docs/en/ui/pagination.md +36 -0
- package/docs/en/ui/radio-group.md +21 -0
- package/docs/en/ui/toast.md +44 -0
- package/docs/en/ui/toggle-group.md +4 -3
- package/docs/en/ui-and-theming.md +1 -1
- package/docs/index.json +1184 -114
- package/docs/ja/agent-skills.md +1 -1
- package/docs/ja/changelog.md +84 -0
- package/docs/ja/cli-reference.md +29 -0
- package/docs/ja/components.md +68 -101
- package/docs/ja/doc/delta-text.md +40 -0
- package/docs/ja/doc/doc-action-items.md +49 -0
- package/docs/ja/doc/doc-callout.md +38 -0
- package/docs/ja/doc/doc-data-table.md +60 -0
- package/docs/ja/doc/doc-executive-summary.md +64 -0
- package/docs/ja/doc/doc-figure.md +56 -0
- package/docs/ja/doc/doc-key-findings.md +61 -0
- package/docs/ja/doc/doc-kpi-scorecard.md +80 -0
- package/docs/ja/doc/doc-notes-and-sources.md +43 -0
- package/docs/ja/doc/doc-report-header.md +46 -0
- package/docs/ja/page-types/csv.md +83 -0
- package/docs/ja/page-types/doc.md +83 -0
- package/docs/ja/page-types/excel.md +82 -0
- package/docs/ja/page-types/slide.md +133 -0
- package/docs/ja/page-types.md +47 -0
- package/docs/ja/pages-and-metadata.md +15 -0
- package/docs/ja/parts/area-chart.md +85 -0
- package/docs/ja/parts/bar-chart.md +95 -0
- package/docs/ja/parts/bar-list.md +58 -0
- package/docs/ja/parts/category-bar.md +36 -0
- package/docs/ja/parts/chart-frame.md +36 -0
- package/docs/ja/parts/data-table.md +22 -0
- package/docs/ja/parts/delta.md +51 -0
- package/docs/ja/parts/donut-chart.md +66 -0
- package/docs/ja/parts/echart.md +3 -0
- package/docs/ja/parts/format.md +44 -0
- package/docs/ja/parts/funnel-steps.md +27 -8
- package/docs/ja/parts/heatmap.md +45 -0
- package/docs/ja/parts/kpi-card.md +56 -0
- package/docs/ja/parts/legend.md +36 -0
- package/docs/ja/parts/line-chart.md +84 -0
- package/docs/ja/parts/metric-value.md +3 -2
- package/docs/ja/parts/page-shell.md +1 -1
- package/docs/ja/parts/progress-circle.md +34 -0
- package/docs/ja/parts/sample-data.md +61 -0
- package/docs/ja/parts/scatter-chart.md +69 -0
- package/docs/ja/parts/sparkline.md +2 -2
- package/docs/ja/parts/tracker.md +32 -0
- package/docs/ja/parts/trend-indicator.md +17 -1
- package/docs/ja/parts/updated-at.md +27 -0
- package/docs/ja/parts/waterfall-chart.md +61 -0
- package/docs/ja/routing.md +8 -86
- package/docs/ja/slide/slide-chart-full.md +48 -0
- package/docs/ja/slide/slide-chart-insight.md +52 -0
- package/docs/ja/slide/slide-columns.md +46 -0
- package/docs/ja/slide/slide-comparison.md +68 -0
- package/docs/ja/slide/slide-cover.md +39 -0
- package/docs/ja/slide/slide-exec-summary.md +47 -0
- package/docs/ja/slide/slide-heading.md +38 -0
- package/docs/ja/slide/slide-kpi-grid.md +55 -0
- package/docs/ja/slide/slide-kpi-hero.md +58 -0
- package/docs/ja/slide/slide-next-actions.md +49 -0
- package/docs/ja/slide/slide-scorecard-table.md +54 -0
- package/docs/ja/slide/slide-section.md +44 -0
- package/docs/ja/slide/slide-source-line.md +34 -0
- package/docs/ja/ui/alert-dialog.md +41 -0
- package/docs/ja/ui/avatar.md +31 -0
- package/docs/ja/ui/combobox.md +74 -0
- package/docs/ja/ui/drawer.md +41 -0
- package/docs/ja/ui/empty.md +1 -1
- package/docs/ja/ui/error-state.md +4 -3
- package/docs/ja/ui/field.md +42 -0
- package/docs/ja/ui/hover-card.md +21 -0
- package/docs/ja/ui/kbd.md +16 -0
- package/docs/ja/ui/loading.md +1 -1
- package/docs/ja/ui/pagination.md +36 -0
- package/docs/ja/ui/radio-group.md +21 -0
- package/docs/ja/ui/toast.md +46 -0
- package/docs/ja/ui/toggle-group.md +4 -3
- package/docs/ja/ui-and-theming.md +14 -7
- package/package.json +43 -29
- package/registry/ui/accordion.tsx +76 -0
- package/registry/ui/alert-dialog.tsx +189 -0
- package/registry/ui/alert.tsx +80 -0
- package/registry/ui/app-shell.tsx +424 -0
- package/registry/ui/area-chart.tsx +3960 -0
- package/registry/ui/attention-list.tsx +465 -0
- package/registry/ui/avatar.tsx +110 -0
- package/registry/ui/badge.tsx +56 -0
- package/registry/ui/bar-chart.tsx +3954 -0
- package/registry/ui/bar-list.tsx +3998 -0
- package/registry/ui/box-plot-chart.tsx +4214 -0
- package/registry/ui/breadcrumb.tsx +128 -0
- package/registry/ui/button.tsx +62 -0
- package/registry/ui/calendar.tsx +223 -0
- package/registry/ui/card.tsx +107 -0
- package/registry/ui/category-bar.tsx +1498 -0
- package/registry/ui/chart-frame.tsx +1604 -0
- package/registry/ui/checkbox.tsx +30 -0
- package/registry/ui/collapsible.tsx +23 -0
- package/registry/ui/combobox.tsx +310 -0
- package/registry/ui/command.tsx +198 -0
- package/registry/ui/dashboard-card.tsx +217 -0
- package/registry/ui/data-table.tsx +896 -157
- package/registry/ui/date-range-picker.tsx +544 -0
- package/registry/ui/delta.tsx +350 -0
- package/registry/ui/dialog.tsx +161 -0
- package/registry/ui/donut-chart.tsx +4006 -0
- package/registry/ui/drawer.tsx +229 -0
- package/registry/ui/dropdown-menu.tsx +274 -0
- package/registry/ui/echart.tsx +1178 -0
- package/registry/ui/field.tsx +240 -0
- package/registry/ui/filter-bar.tsx +551 -0
- package/registry/ui/funnel-steps.tsx +3843 -0
- package/registry/ui/heatmap.tsx +2027 -0
- package/registry/ui/histogram-chart.tsx +4284 -0
- package/registry/ui/hover-card.tsx +52 -0
- package/registry/ui/input-group.tsx +160 -0
- package/registry/ui/input.tsx +24 -0
- package/registry/ui/kbd.tsx +30 -0
- package/registry/ui/kpi-card.tsx +905 -0
- package/registry/ui/label.tsx +22 -0
- package/registry/ui/legend.tsx +3817 -0
- package/registry/ui/line-chart.tsx +3958 -0
- package/registry/ui/metric-value.tsx +62 -0
- package/registry/ui/multi-select.tsx +382 -0
- package/registry/ui/page-shell.tsx +420 -0
- package/registry/ui/pagination.tsx +140 -0
- package/registry/ui/paired-chart.tsx +4086 -0
- package/registry/ui/placeholder.tsx +36 -0
- package/registry/ui/popover.tsx +92 -0
- package/registry/ui/progress-circle.tsx +1033 -0
- package/registry/ui/progress.tsx +85 -0
- package/registry/ui/radio-group.tsx +39 -0
- package/registry/ui/sample-data.tsx +230 -0
- package/registry/ui/scatter-chart.tsx +4503 -0
- package/registry/ui/scroll-area.tsx +56 -0
- package/registry/ui/searchable-select.tsx +352 -0
- package/registry/ui/section-header.tsx +43 -0
- package/registry/ui/segmented-control.tsx +76 -0
- package/registry/ui/select.tsx +255 -0
- package/registry/ui/separator.tsx +27 -0
- package/registry/ui/sheet.tsx +139 -0
- package/registry/ui/sidebar.tsx +725 -0
- package/registry/ui/skeleton.tsx +17 -0
- package/registry/ui/slider.tsx +56 -0
- package/registry/ui/sparkline.tsx +230 -0
- package/registry/ui/spinner.tsx +14 -0
- package/registry/ui/states.tsx +247 -0
- package/registry/ui/status-badge.tsx +286 -0
- package/registry/ui/switch.tsx +34 -0
- package/registry/ui/table.tsx +118 -0
- package/registry/ui/tabs.tsx +84 -0
- package/registry/ui/textarea.tsx +22 -0
- package/registry/ui/toast.tsx +250 -0
- package/registry/ui/toggle-group.tsx +91 -0
- package/registry/ui/toggle.tsx +47 -0
- package/registry/ui/tooltip.tsx +72 -0
- package/registry/ui/tracker.tsx +1015 -0
- package/registry/ui/trend-indicator.tsx +217 -0
- package/registry/ui/updated-at.tsx +276 -0
- package/registry/ui/waterfall-chart.tsx +4561 -0
- package/skills/vantage-add-feature/SKILL.md +14 -7
- package/skills/vantage-design/SKILL.md +62 -52
- package/skills/vantage-design/references/extract.md +26 -27
- package/skills/vantage-design/references/format.md +12 -172
- package/skills/vantage-design/references/presets.md +50 -110
- package/skills/vantage-pitfalls/SKILL.md +10 -1
- package/skills/vantage-slide/SKILL.md +71 -36
- package/templates/AGENTS.md +54 -16
- package/templates/agents/api.md +36 -0
- package/templates/agents/csv.md +2 -1
- package/templates/agents/doc.md +52 -3
- package/templates/agents/page.md +91 -10
- package/templates/agents/slide.md +90 -4
- package/templates/agents/xlsx.md +2 -1
- package/theme.css +247 -132
- package/dist/add-EISGSZAH.js +0 -6
- package/dist/add-EISGSZAH.js.map +0 -1
- package/dist/chunk-3G43C6OL.js.map +0 -1
- package/dist/chunk-5ZOP4SQR.js +0 -47
- package/dist/chunk-5ZOP4SQR.js.map +0 -1
- package/dist/chunk-A2UUGASH.js.map +0 -1
- package/dist/chunk-BCE22JSM.js.map +0 -1
- package/dist/chunk-DTDVSFRY.js +0 -29
- package/dist/chunk-DTDVSFRY.js.map +0 -1
- package/dist/chunk-EP6JHXSR.js.map +0 -1
- package/dist/chunk-JGRMRXXZ.js.map +0 -1
- package/dist/chunk-KLEIVDUV.js +0 -165
- package/dist/chunk-KLEIVDUV.js.map +0 -1
- package/dist/chunk-LSRMRIXA.js +0 -2227
- package/dist/chunk-LSRMRIXA.js.map +0 -1
- package/dist/chunk-PVTHHV7X.js.map +0 -1
- package/dist/chunk-PXRX5PEC.js.map +0 -1
- package/dist/chunk-RPZAALCX.js.map +0 -1
- package/dist/chunk-T3FLAGI6.js +0 -316
- package/dist/chunk-T3FLAGI6.js.map +0 -1
- package/dist/dev-NZRLOQCL.js.map +0 -1
- package/dist/doctor-VFKEMR54.js.map +0 -1
- package/dist/preview-QDCIVVSR.js.map +0 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copied by `vantage add ui skeleton`. This file is yours to edit.
|
|
2
|
+
// Generated from @squadbase/squadkit registry/ui/skeleton.tsx by `pnpm run registry` (in Vantage, edit packages/squadkit, not registry/).
|
|
3
|
+
"use client"
|
|
4
|
+
|
|
5
|
+
import { cn } from "@squadbase/vantage/ui"
|
|
6
|
+
|
|
7
|
+
function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
|
|
8
|
+
return (
|
|
9
|
+
<div
|
|
10
|
+
data-slot="skeleton"
|
|
11
|
+
className={cn("animate-pulse motion-reduce:animate-none rounded-md bg-muted", className)}
|
|
12
|
+
{...props}
|
|
13
|
+
/>
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { Skeleton }
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Copied by `vantage add ui slider`. This file is yours to edit.
|
|
2
|
+
// Generated from @squadbase/squadkit registry/ui/slider.tsx by `pnpm run registry` (in Vantage, edit packages/squadkit, not registry/).
|
|
3
|
+
"use client"
|
|
4
|
+
|
|
5
|
+
import { Slider as SliderPrimitive } from "@base-ui/react/slider"
|
|
6
|
+
|
|
7
|
+
import { cn } from "@squadbase/vantage/ui"
|
|
8
|
+
|
|
9
|
+
function Slider({
|
|
10
|
+
className,
|
|
11
|
+
defaultValue,
|
|
12
|
+
value,
|
|
13
|
+
min = 0,
|
|
14
|
+
max = 100,
|
|
15
|
+
...props
|
|
16
|
+
}: SliderPrimitive.Root.Props) {
|
|
17
|
+
const _values = Array.isArray(value)
|
|
18
|
+
? value
|
|
19
|
+
: Array.isArray(defaultValue)
|
|
20
|
+
? defaultValue
|
|
21
|
+
: [min, max]
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<SliderPrimitive.Root
|
|
25
|
+
className={cn("data-horizontal:w-full data-vertical:h-full", className)}
|
|
26
|
+
data-slot="slider"
|
|
27
|
+
defaultValue={defaultValue}
|
|
28
|
+
value={value}
|
|
29
|
+
min={min}
|
|
30
|
+
max={max}
|
|
31
|
+
thumbAlignment="edge"
|
|
32
|
+
{...props}
|
|
33
|
+
>
|
|
34
|
+
<SliderPrimitive.Control className="relative flex w-full touch-none items-center select-none data-disabled:opacity-50 data-vertical:h-full data-vertical:min-h-40 data-vertical:w-auto data-vertical:flex-col">
|
|
35
|
+
<SliderPrimitive.Track
|
|
36
|
+
data-slot="slider-track"
|
|
37
|
+
className="relative grow overflow-hidden rounded-full bg-muted select-none data-horizontal:h-1 data-horizontal:w-full data-vertical:h-full data-vertical:w-1"
|
|
38
|
+
>
|
|
39
|
+
<SliderPrimitive.Indicator
|
|
40
|
+
data-slot="slider-range"
|
|
41
|
+
className="bg-primary select-none data-horizontal:h-full data-vertical:w-full"
|
|
42
|
+
/>
|
|
43
|
+
</SliderPrimitive.Track>
|
|
44
|
+
{Array.from({ length: _values.length }, (_, index) => (
|
|
45
|
+
<SliderPrimitive.Thumb
|
|
46
|
+
data-slot="slider-thumb"
|
|
47
|
+
key={index}
|
|
48
|
+
className="relative block size-3 shrink-0 rounded-full border border-ring bg-background ring-ring/50 transition-[color,box-shadow] select-none after:absolute after:-inset-2 hover:ring-3 focus-visible:ring-3 focus-visible:outline-hidden active:ring-3 disabled:pointer-events-none disabled:opacity-50"
|
|
49
|
+
/>
|
|
50
|
+
))}
|
|
51
|
+
</SliderPrimitive.Control>
|
|
52
|
+
</SliderPrimitive.Root>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { Slider }
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
// Copied by `vantage add ui sparkline`. This file is yours to edit.
|
|
2
|
+
// Generated from @squadbase/squadkit registry/charts/sparkline.tsx by `pnpm run registry` (in Vantage, edit packages/squadkit, not registry/).
|
|
3
|
+
"use client"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Sparkline — an inline trend micro-chart. Deliberately *not* an `EChart`: a
|
|
7
|
+
* sparkline sits inside table cells and KPI tiles by the dozen, where one
|
|
8
|
+
* ECharts instance per cell would be wasteful. This renders a single stateless
|
|
9
|
+
* `<svg>` instead, so hundreds of them stay cheap.
|
|
10
|
+
*/
|
|
11
|
+
import { forwardRef, useEffect, useState, type SVGAttributes } from "react"
|
|
12
|
+
|
|
13
|
+
import { cn } from "@squadbase/vantage/ui"
|
|
14
|
+
import type { ChartHighlight } from "@squadbase/vantage/components"
|
|
15
|
+
|
|
16
|
+
export type SparklineVariant = "line" | "bar"
|
|
17
|
+
|
|
18
|
+
export interface SparklineDataPoint {
|
|
19
|
+
value: number
|
|
20
|
+
label?: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface SparklineProps extends SVGAttributes<SVGSVGElement> {
|
|
24
|
+
data: SparklineDataPoint[]
|
|
25
|
+
variant?: SparklineVariant
|
|
26
|
+
height?: number
|
|
27
|
+
/** Tailwind text-colour class; drives both stroke and fill via `currentColor`. */
|
|
28
|
+
color?: string
|
|
29
|
+
area?: boolean
|
|
30
|
+
/** マウント時に線を引く / 棒を伸ばす。既定 `false`(`prefers-reduced-motion` では常に無効)。 */
|
|
31
|
+
animate?: boolean
|
|
32
|
+
/**
|
|
33
|
+
* 点の強調(Tufte 流)。`"auto"` は最新・最大・最小の 3 点だけに小さな点を打つ
|
|
34
|
+
* (最新は系列の色、最大・最小は muted)。`"latest"` は最新の 1 点だけ、`"none"` は線だけ。`variant="line"` のときだけ効く。既定 `"auto"`。
|
|
35
|
+
*/
|
|
36
|
+
highlight?: ChartHighlight | "latest"
|
|
37
|
+
/** 指定すると `role="img"` で読み上げ対象にする。省略時は装飾として `aria-hidden`。 */
|
|
38
|
+
"aria-label"?: string
|
|
39
|
+
className?: string
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const VB_WIDTH = 100
|
|
43
|
+
|
|
44
|
+
/** Map raw values onto SVG y-coordinates (inverted, padded). */
|
|
45
|
+
function normalizeData(values: number[], height: number, vPad = 2): number[] {
|
|
46
|
+
const min = Math.min(...values)
|
|
47
|
+
const max = Math.max(...values)
|
|
48
|
+
const range = max - min
|
|
49
|
+
const drawHeight = height - vPad * 2
|
|
50
|
+
if (range === 0) return values.map(() => vPad + drawHeight / 2)
|
|
51
|
+
return values.map((v) => height - vPad - ((v - min) / range) * drawHeight)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function buildLinePath(ys: number[]): string {
|
|
55
|
+
if (ys.length === 0) return ""
|
|
56
|
+
const step = ys.length > 1 ? VB_WIDTH / (ys.length - 1) : 0
|
|
57
|
+
return ys
|
|
58
|
+
.map((y, i) => `${i === 0 ? "M" : "L"}${(i * step).toFixed(2)},${y.toFixed(2)}`)
|
|
59
|
+
.join(" ")
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function buildAreaPath(ys: number[], height: number): string {
|
|
63
|
+
if (ys.length === 0) return ""
|
|
64
|
+
const step = ys.length > 1 ? VB_WIDTH / (ys.length - 1) : 0
|
|
65
|
+
const lastX = ((ys.length - 1) * step).toFixed(2)
|
|
66
|
+
return `${buildLinePath(ys)} L${lastX},${height} L0,${height} Z`
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type SparklinePointKind = "latest" | "max" | "min"
|
|
70
|
+
|
|
71
|
+
export interface SparklinePoint {
|
|
72
|
+
kind: SparklinePointKind
|
|
73
|
+
index: number
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The points a Tufte-style sparkline marks: the latest, the max and the min.
|
|
78
|
+
* A point that is both latest and max/min is drawn once, as `latest`; a flat
|
|
79
|
+
* series marks only the latest. Ties pick the most recent occurrence.
|
|
80
|
+
*/
|
|
81
|
+
export function sparklineHighlightPoints(values: number[]): SparklinePoint[] {
|
|
82
|
+
if (values.length === 0) return []
|
|
83
|
+
const last = values.length - 1
|
|
84
|
+
const points: SparklinePoint[] = [{ kind: "latest", index: last }]
|
|
85
|
+
let maxI = 0
|
|
86
|
+
let minI = 0
|
|
87
|
+
let max = values[0] as number
|
|
88
|
+
let min = max
|
|
89
|
+
values.forEach((v, i) => {
|
|
90
|
+
if (v >= max) [max, maxI] = [v, i]
|
|
91
|
+
if (v <= min) [min, minI] = [v, i]
|
|
92
|
+
})
|
|
93
|
+
const latest = values[last] as number
|
|
94
|
+
if (max === min) return points
|
|
95
|
+
if (max !== latest) points.push({ kind: "max", index: maxI })
|
|
96
|
+
if (min !== latest) points.push({ kind: "min", index: minI })
|
|
97
|
+
return points
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
interface BarRect {
|
|
101
|
+
x: number
|
|
102
|
+
y: number
|
|
103
|
+
w: number
|
|
104
|
+
h: number
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function buildBarRects(ys: number[], height: number, gap = 1): BarRect[] {
|
|
108
|
+
const barW = Math.max(1, VB_WIDTH / ys.length - gap)
|
|
109
|
+
return ys.map((y, i) => ({ x: i * (barW + gap), y, w: barW, h: height - y }))
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Rows not given yet (a draft fills props in steps): draw the empty state, keep the same array between renders. */
|
|
113
|
+
const NO_ROWS: never[] = []
|
|
114
|
+
|
|
115
|
+
export const Sparkline = forwardRef<SVGSVGElement, SparklineProps>(function Sparkline(
|
|
116
|
+
{
|
|
117
|
+
data = NO_ROWS,
|
|
118
|
+
variant = "line",
|
|
119
|
+
height = 40,
|
|
120
|
+
color = "text-chart-1",
|
|
121
|
+
area = false,
|
|
122
|
+
animate = false,
|
|
123
|
+
highlight = "auto",
|
|
124
|
+
"aria-label": ariaLabel,
|
|
125
|
+
className,
|
|
126
|
+
...props
|
|
127
|
+
},
|
|
128
|
+
ref,
|
|
129
|
+
) {
|
|
130
|
+
const [mounted, setMounted] = useState(false)
|
|
131
|
+
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
if (animate) setMounted(true)
|
|
134
|
+
}, [animate])
|
|
135
|
+
|
|
136
|
+
if (data.length === 0) return null
|
|
137
|
+
|
|
138
|
+
const values = data.map((d) => d.value)
|
|
139
|
+
const ys = normalizeData(values, height)
|
|
140
|
+
const step = ys.length > 1 ? VB_WIDTH / (ys.length - 1) : 0
|
|
141
|
+
const points =
|
|
142
|
+
variant !== "line"
|
|
143
|
+
? []
|
|
144
|
+
: highlight === "auto"
|
|
145
|
+
? sparklineHighlightPoints(values)
|
|
146
|
+
: highlight === "latest"
|
|
147
|
+
? [{ kind: "latest" as const, index: values.length - 1 }]
|
|
148
|
+
: []
|
|
149
|
+
|
|
150
|
+
return (
|
|
151
|
+
<svg
|
|
152
|
+
ref={ref}
|
|
153
|
+
data-slot="sparkline"
|
|
154
|
+
viewBox={`0 0 ${VB_WIDTH} ${height}`}
|
|
155
|
+
preserveAspectRatio="none"
|
|
156
|
+
width="100%"
|
|
157
|
+
height={height}
|
|
158
|
+
role={ariaLabel ? "img" : undefined}
|
|
159
|
+
aria-label={ariaLabel}
|
|
160
|
+
aria-hidden={ariaLabel ? undefined : true}
|
|
161
|
+
className={cn("overflow-visible", className)}
|
|
162
|
+
{...props}
|
|
163
|
+
>
|
|
164
|
+
{variant === "line" && (
|
|
165
|
+
<>
|
|
166
|
+
{area && (
|
|
167
|
+
<path
|
|
168
|
+
d={buildAreaPath(ys, height)}
|
|
169
|
+
strokeWidth={0}
|
|
170
|
+
className={cn("fill-current opacity-15", color)}
|
|
171
|
+
/>
|
|
172
|
+
)}
|
|
173
|
+
<path
|
|
174
|
+
d={buildLinePath(ys)}
|
|
175
|
+
fill="none"
|
|
176
|
+
strokeWidth={1.5}
|
|
177
|
+
strokeLinecap="round"
|
|
178
|
+
strokeLinejoin="round"
|
|
179
|
+
vectorEffect="non-scaling-stroke"
|
|
180
|
+
pathLength={animate ? 1 : undefined}
|
|
181
|
+
strokeDasharray={animate ? 1 : undefined}
|
|
182
|
+
strokeDashoffset={animate ? (mounted ? 0 : 1) : undefined}
|
|
183
|
+
className={cn("stroke-current", animate && "motion-reduce:transition-none!", color)}
|
|
184
|
+
style={animate ? { transition: "stroke-dashoffset 0.6s ease-in-out" } : undefined}
|
|
185
|
+
/>
|
|
186
|
+
{/* A zero-length round-capped stroke with a non-scaling width stays a
|
|
187
|
+
circle even though the viewBox stretches (`preserveAspectRatio="none"`). */}
|
|
188
|
+
{points.map((p) => {
|
|
189
|
+
const x = (p.index * step).toFixed(2)
|
|
190
|
+
const y = (ys[p.index] ?? 0).toFixed(2)
|
|
191
|
+
return (
|
|
192
|
+
<path
|
|
193
|
+
key={p.kind}
|
|
194
|
+
data-slot="sparkline-point"
|
|
195
|
+
data-point={p.kind}
|
|
196
|
+
d={`M${x},${y} L${x},${y}`}
|
|
197
|
+
fill="none"
|
|
198
|
+
strokeWidth={p.kind === "latest" ? 5 : 4}
|
|
199
|
+
strokeLinecap="round"
|
|
200
|
+
vectorEffect="non-scaling-stroke"
|
|
201
|
+
className={cn("stroke-current", p.kind === "latest" ? color : "text-muted-foreground")}
|
|
202
|
+
/>
|
|
203
|
+
)
|
|
204
|
+
})}
|
|
205
|
+
</>
|
|
206
|
+
)}
|
|
207
|
+
|
|
208
|
+
{variant === "bar" &&
|
|
209
|
+
buildBarRects(ys, height).map((rect, i) => (
|
|
210
|
+
<rect
|
|
211
|
+
key={i}
|
|
212
|
+
x={rect.x}
|
|
213
|
+
y={animate ? (mounted ? rect.y : height) : rect.y}
|
|
214
|
+
width={rect.w}
|
|
215
|
+
height={animate ? (mounted ? rect.h : 0) : rect.h}
|
|
216
|
+
rx={0.5}
|
|
217
|
+
className={cn("fill-current", animate && "motion-reduce:transition-none!", color)}
|
|
218
|
+
style={
|
|
219
|
+
animate
|
|
220
|
+
? {
|
|
221
|
+
transition: `height 0.4s ease-out ${i * 0.02}s, y 0.4s ease-out ${i * 0.02}s`,
|
|
222
|
+
}
|
|
223
|
+
: undefined
|
|
224
|
+
}
|
|
225
|
+
/>
|
|
226
|
+
))}
|
|
227
|
+
</svg>
|
|
228
|
+
)
|
|
229
|
+
})
|
|
230
|
+
Sparkline.displayName = "Sparkline"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copied by `vantage add ui spinner`. This file is yours to edit.
|
|
2
|
+
// Generated from @squadbase/squadkit registry/ui/spinner.tsx by `pnpm run registry` (in Vantage, edit packages/squadkit, not registry/).
|
|
3
|
+
"use client"
|
|
4
|
+
|
|
5
|
+
import { cn } from "@squadbase/vantage/ui"
|
|
6
|
+
import { Loader2Icon } from "lucide-react"
|
|
7
|
+
|
|
8
|
+
function Spinner({ className, ...props }: React.ComponentProps<"svg">) {
|
|
9
|
+
return (
|
|
10
|
+
<Loader2Icon data-slot="spinner" role="status" aria-label="Loading" className={cn("size-4 animate-spin", className)} {...props} />
|
|
11
|
+
)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { Spinner }
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// Copied by `vantage add ui states`. This file is yours to edit.
|
|
2
|
+
// Generated from @squadbase/squadkit registry/ui/states.tsx by `pnpm run registry` (in Vantage, edit packages/squadkit, not registry/).
|
|
3
|
+
"use client"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Loading / Empty / ErrorState — the three non-data states of a panel, worded for
|
|
7
|
+
* business users. Defaults follow the page language (`<html lang>`: Japanese for `ja`, else
|
|
8
|
+
* English) and say what is happening, not why the system failed: keep raw errors
|
|
9
|
+
* ("upstream timeout after 30s") in `details`, which stays folded behind "Show details" (ja: "詳細を表示").
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* import { ErrorState } from "@/components/ui/states"
|
|
13
|
+
* // Vantage: import { ErrorState } from "@squadbase/vantage/ui"
|
|
14
|
+
*
|
|
15
|
+
* <ErrorState
|
|
16
|
+
* title="売上を読み込めませんでした"
|
|
17
|
+
* message="データソースから時間内に応答がありませんでした。しばらくしてから再試行してください。"
|
|
18
|
+
* details={error.message}
|
|
19
|
+
* action={<Button variant="outline" onClick={retry}>再試行する</Button>}
|
|
20
|
+
* />
|
|
21
|
+
*/
|
|
22
|
+
import type { ReactNode } from "react"
|
|
23
|
+
import { cn } from "@squadbase/vantage/ui"
|
|
24
|
+
import { useSyncExternalStore } from "react"
|
|
25
|
+
|
|
26
|
+
/* ---------- inlined from @squadbase/squadkit registry/lib/locale.ts (internal to @squadbase/vantage) ---------- */
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The display language of the parts and the defaults that follow it.
|
|
30
|
+
*
|
|
31
|
+
* The language comes from `<html lang>`: a tag starting with `ja` reads Japanese, anything else English.
|
|
32
|
+
* Without a usable `lang` (missing, invalid, or no `document` — SSR, Node) the locale is `FALLBACK_LOCALE`
|
|
33
|
+
* (`en-US`). A `locale` passed explicitly (a prop, an argument) always wins.
|
|
34
|
+
*
|
|
35
|
+
* Parts read the locale through `useLocale` (`hooks/use-locale`) and pass it down; the pure helpers here
|
|
36
|
+
* and in `format` / `comparison` / `chart-*` take it as an argument and fall back to `documentLocale()`.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/** The language of the built-in wording: Japanese or English. */
|
|
40
|
+
type UiLanguage = "ja" | "en"
|
|
41
|
+
|
|
42
|
+
/** The locale used when `<html lang>` gives none (and on the server). */
|
|
43
|
+
const FALLBACK_LOCALE = "en-US"
|
|
44
|
+
|
|
45
|
+
/** `"ja"` when `locale` starts with `ja` (`ja`, `ja-JP`), else `"en"`. A missing locale is `"en"`. */
|
|
46
|
+
function uiLanguage(locale: string | null | undefined): UiLanguage {
|
|
47
|
+
return typeof locale === "string" && locale.trim().toLowerCase().startsWith("ja") ? "ja" : "en"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** A BCP 47 tag in its canonical form (`en-gb` → `en-GB`), or `FALLBACK_LOCALE` when it is empty or invalid. */
|
|
51
|
+
function normalizeLocale(tag: string | null | undefined): string {
|
|
52
|
+
const value = tag?.trim()
|
|
53
|
+
if (!value) return FALLBACK_LOCALE
|
|
54
|
+
try {
|
|
55
|
+
return Intl.getCanonicalLocales(value)[0] ?? FALLBACK_LOCALE
|
|
56
|
+
} catch {
|
|
57
|
+
return FALLBACK_LOCALE
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The locale of the page: `document.documentElement.lang`, canonicalized. `FALLBACK_LOCALE` when it is empty or
|
|
63
|
+
* invalid, or there is no `document`. Parts read it through `useLocale`, never while rendering.
|
|
64
|
+
*/
|
|
65
|
+
function documentLocale(): string {
|
|
66
|
+
if (typeof document === "undefined") return FALLBACK_LOCALE
|
|
67
|
+
return normalizeLocale(document.documentElement?.getAttribute("lang"))
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** `locale` when given, else the page's locale (`documentLocale()`). */
|
|
71
|
+
function resolveLocale(locale?: string | null): string {
|
|
72
|
+
return locale || documentLocale()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Picks the wording table of the locale's language. */
|
|
76
|
+
function pickLocale<T>(table: { ja: T; en: T }, locale?: string | null): T {
|
|
77
|
+
return table[uiLanguage(resolveLocale(locale))]
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** The currency `format="currency"` uses without a `currency`: JPY for Japanese, USD otherwise. */
|
|
81
|
+
function defaultCurrency(locale?: string | null): string {
|
|
82
|
+
return uiLanguage(resolveLocale(locale)) === "ja" ? "JPY" : "USD"
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** The month a fiscal year starts in (1–12) when none is given: April for Japanese, January otherwise. */
|
|
86
|
+
function defaultFiscalYearStartMonth(locale?: string | null): number {
|
|
87
|
+
return uiLanguage(resolveLocale(locale)) === "ja" ? 4 : 1
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** A day of the week, 0 = Sunday … 6 = Saturday (the `Date#getDay` / date-fns numbering). */
|
|
91
|
+
type WeekDay = 0 | 1 | 2 | 3 | 4 | 5 | 6
|
|
92
|
+
|
|
93
|
+
/** Locales whose week starts on Sunday when the runtime has no week data. */
|
|
94
|
+
const SUNDAY_FIRST = new Set(["en", "en-US", "en-CA"])
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The first day of the week: Monday for Japanese; otherwise the locale's convention from `Intl.Locale`
|
|
98
|
+
* (`en-US` Sunday, `en-GB` Monday). Without week data in the runtime: Sunday for `en` / `en-US` / `en-CA`,
|
|
99
|
+
* Monday for the rest.
|
|
100
|
+
*/
|
|
101
|
+
function weekStartsOn(locale?: string | null): WeekDay {
|
|
102
|
+
const tag = normalizeLocale(resolveLocale(locale))
|
|
103
|
+
if (uiLanguage(tag) === "ja") return 1
|
|
104
|
+
try {
|
|
105
|
+
const info = new Intl.Locale(tag) as Intl.Locale & {
|
|
106
|
+
getWeekInfo?: () => { firstDay: number }
|
|
107
|
+
weekInfo?: { firstDay: number }
|
|
108
|
+
}
|
|
109
|
+
const firstDay = info.getWeekInfo?.().firstDay ?? info.weekInfo?.firstDay
|
|
110
|
+
if (typeof firstDay === "number" && firstDay >= 1 && firstDay <= 7) return (firstDay % 7) as WeekDay
|
|
111
|
+
} catch {
|
|
112
|
+
// Fall through to the table below.
|
|
113
|
+
}
|
|
114
|
+
return SUNDAY_FIRST.has(tag) ? 0 : 1
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* ---------- inlined from @squadbase/squadkit registry/hooks/use-locale.ts (internal to @squadbase/vantage) ---------- */
|
|
118
|
+
|
|
119
|
+
const listeners = new Set<() => void>()
|
|
120
|
+
let observer: MutationObserver | null = null
|
|
121
|
+
|
|
122
|
+
/** One observer on `<html lang>` for every subscribed part. */
|
|
123
|
+
function subscribe(onChange: () => void): () => void {
|
|
124
|
+
if (typeof document === "undefined" || typeof MutationObserver === "undefined") return () => {}
|
|
125
|
+
listeners.add(onChange)
|
|
126
|
+
if (!observer) {
|
|
127
|
+
observer = new MutationObserver(() => {
|
|
128
|
+
for (const listener of [...listeners]) listener()
|
|
129
|
+
})
|
|
130
|
+
observer.observe(document.documentElement, { attributes: true, attributeFilter: ["lang"] })
|
|
131
|
+
}
|
|
132
|
+
return () => {
|
|
133
|
+
listeners.delete(onChange)
|
|
134
|
+
if (listeners.size === 0 && observer) {
|
|
135
|
+
observer.disconnect()
|
|
136
|
+
observer = null
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const serverLocale = () => FALLBACK_LOCALE
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The page's locale (`<html lang>`), following changes made while the page runs. On the server and during
|
|
145
|
+
* hydration it is `FALLBACK_LOCALE` (`en-US`), so the markup matches; it switches right after.
|
|
146
|
+
*/
|
|
147
|
+
function useDocumentLocale(): string {
|
|
148
|
+
return useSyncExternalStore(subscribe, documentLocale, serverLocale)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** The locale a part renders in: its `locale` prop when given, else the page's (`useDocumentLocale`). */
|
|
152
|
+
function useLocale(locale?: string | null): string {
|
|
153
|
+
const page = useDocumentLocale()
|
|
154
|
+
return locale || page
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/* ---------- end of inlined code ---------- */
|
|
158
|
+
|
|
159
|
+
const TEXT = {
|
|
160
|
+
ja: {
|
|
161
|
+
loading: "読み込んでいます…",
|
|
162
|
+
empty: "表示できるデータがありません",
|
|
163
|
+
errorTitle: "データを読み込めませんでした",
|
|
164
|
+
errorMessage: "時間をおいて再試行してください。解決しない場合は管理者にお問い合わせください。",
|
|
165
|
+
details: "詳細を表示",
|
|
166
|
+
},
|
|
167
|
+
en: {
|
|
168
|
+
loading: "Loading…",
|
|
169
|
+
empty: "No data to display",
|
|
170
|
+
errorTitle: "Couldn't load the data",
|
|
171
|
+
errorMessage: "Try again in a moment. If the problem continues, contact your administrator.",
|
|
172
|
+
details: "Show details",
|
|
173
|
+
},
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const useText = () => TEXT[uiLanguage(useLocale())]
|
|
177
|
+
|
|
178
|
+
export function Loading({ label, className }: { label?: string; className?: string }) {
|
|
179
|
+
const t = useText()
|
|
180
|
+
return (
|
|
181
|
+
<div className={cn("flex min-h-[30vh] items-center justify-center", className)} role="status" aria-live="polite">
|
|
182
|
+
<div className="flex items-center gap-3 text-sm text-muted-foreground">
|
|
183
|
+
<span className="h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" />
|
|
184
|
+
{label ?? t.loading}
|
|
185
|
+
</div>
|
|
186
|
+
</div>
|
|
187
|
+
)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export function Empty({
|
|
191
|
+
title,
|
|
192
|
+
description,
|
|
193
|
+
icon,
|
|
194
|
+
action,
|
|
195
|
+
className,
|
|
196
|
+
}: {
|
|
197
|
+
title?: string
|
|
198
|
+
description?: string
|
|
199
|
+
icon?: ReactNode
|
|
200
|
+
action?: ReactNode
|
|
201
|
+
className?: string
|
|
202
|
+
}) {
|
|
203
|
+
const t = useText()
|
|
204
|
+
return (
|
|
205
|
+
<div className={cn("flex flex-col items-center justify-center gap-2 p-10 text-center", className)}>
|
|
206
|
+
{icon ? <div className="text-3xl text-muted-foreground">{icon}</div> : null}
|
|
207
|
+
<p className="font-medium">{title ?? t.empty}</p>
|
|
208
|
+
{description ? <p className="max-w-sm text-sm text-muted-foreground">{description}</p> : null}
|
|
209
|
+
{action ? <div className="mt-2">{action}</div> : null}
|
|
210
|
+
</div>
|
|
211
|
+
)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export function ErrorState({
|
|
215
|
+
title,
|
|
216
|
+
message,
|
|
217
|
+
details,
|
|
218
|
+
action,
|
|
219
|
+
className,
|
|
220
|
+
}: {
|
|
221
|
+
title?: string
|
|
222
|
+
/** What happened and what to do next, in plain words. */
|
|
223
|
+
message?: ReactNode
|
|
224
|
+
/** Technical detail (error message, status code), folded behind "Show details" (ja: "詳細を表示"). */
|
|
225
|
+
details?: ReactNode
|
|
226
|
+
action?: ReactNode
|
|
227
|
+
className?: string
|
|
228
|
+
}) {
|
|
229
|
+
const t = useText()
|
|
230
|
+
const shownMessage = message === undefined ? t.errorMessage : message
|
|
231
|
+
return (
|
|
232
|
+
<div
|
|
233
|
+
className={cn("rounded-xl border border-destructive/30 bg-destructive/5 p-6", className)}
|
|
234
|
+
role="alert"
|
|
235
|
+
>
|
|
236
|
+
<p className="font-semibold text-destructive">{title ?? t.errorTitle}</p>
|
|
237
|
+
{shownMessage ? <p className="mt-1 text-sm text-muted-foreground">{shownMessage}</p> : null}
|
|
238
|
+
{details ? (
|
|
239
|
+
<details className="mt-2 text-xs text-muted-foreground">
|
|
240
|
+
<summary className="cursor-pointer select-none">{t.details}</summary>
|
|
241
|
+
<div className="mt-1 font-mono break-all">{details}</div>
|
|
242
|
+
</details>
|
|
243
|
+
) : null}
|
|
244
|
+
{action ? <div className="mt-3">{action}</div> : null}
|
|
245
|
+
</div>
|
|
246
|
+
)
|
|
247
|
+
}
|