@squadbase/vantage 0.6.1 → 0.6.2-dev1.0010f67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (346) hide show
  1. package/dist/add-4GHF2TX2.js +6 -0
  2. package/dist/add-4GHF2TX2.js.map +1 -0
  3. package/dist/{build-O5TVNH4E.js → build-U7GO26HR.js} +9 -9
  4. package/dist/{build-O5TVNH4E.js.map → build-U7GO26HR.js.map} +1 -1
  5. package/dist/{check-WFBEDHDR.js → check-MRVAIHG5.js} +7 -7
  6. package/dist/{check-WFBEDHDR.js.map → check-MRVAIHG5.js.map} +1 -1
  7. package/dist/chunk-2IAPIOPS.js +152 -0
  8. package/dist/chunk-2IAPIOPS.js.map +1 -0
  9. package/dist/chunk-3RJEOP3J.js +174 -0
  10. package/dist/chunk-3RJEOP3J.js.map +1 -0
  11. package/dist/chunk-77CISBMG.js +7581 -0
  12. package/dist/chunk-77CISBMG.js.map +1 -0
  13. package/dist/{chunk-QDZA5JSL.js → chunk-AABMKHEU.js} +4 -4
  14. package/dist/{chunk-QDZA5JSL.js.map → chunk-AABMKHEU.js.map} +1 -1
  15. package/dist/{chunk-PVTHHV7X.js → chunk-ANZLVSEP.js} +28 -7
  16. package/dist/chunk-ANZLVSEP.js.map +1 -0
  17. package/dist/chunk-CKWPK4RO.js +50 -0
  18. package/dist/chunk-CKWPK4RO.js.map +1 -0
  19. package/dist/chunk-EG4PX726.js +678 -0
  20. package/dist/chunk-EG4PX726.js.map +1 -0
  21. package/dist/{chunk-3G43C6OL.js → chunk-GNXCX4WE.js} +46 -3
  22. package/dist/chunk-GNXCX4WE.js.map +1 -0
  23. package/dist/chunk-NZ5QIIG4.js +74 -0
  24. package/dist/chunk-NZ5QIIG4.js.map +1 -0
  25. package/dist/{chunk-BCE22JSM.js → chunk-PJ4SPXHS.js} +52 -16
  26. package/dist/chunk-PJ4SPXHS.js.map +1 -0
  27. package/dist/{chunk-MXI3PZFT.js → chunk-QNOX7WLZ.js} +257 -210
  28. package/dist/chunk-QNOX7WLZ.js.map +1 -0
  29. package/dist/{chunk-ZVANIULZ.js → chunk-RNTDBX6S.js} +4 -4
  30. package/dist/{chunk-ZVANIULZ.js.map → chunk-RNTDBX6S.js.map} +1 -1
  31. package/dist/chunk-ROHNXP7J.js +123 -0
  32. package/dist/chunk-ROHNXP7J.js.map +1 -0
  33. package/dist/chunk-S5MDTHH7.js +466 -0
  34. package/dist/chunk-S5MDTHH7.js.map +1 -0
  35. package/dist/chunk-SDJTTMLK.js +1877 -0
  36. package/dist/chunk-SDJTTMLK.js.map +1 -0
  37. package/dist/{chunk-EP6JHXSR.js → chunk-SHZM3EXB.js} +68 -12
  38. package/dist/chunk-SHZM3EXB.js.map +1 -0
  39. package/dist/chunk-TRMHNMMZ.js +61 -0
  40. package/dist/chunk-TRMHNMMZ.js.map +1 -0
  41. package/dist/{chunk-A2UUGASH.js → chunk-U736PVHY.js} +2 -2
  42. package/dist/chunk-U736PVHY.js.map +1 -0
  43. package/dist/{chunk-JGRMRXXZ.js → chunk-UWSQUHX6.js} +4 -99
  44. package/dist/chunk-UWSQUHX6.js.map +1 -0
  45. package/dist/cli.js +15 -11
  46. package/dist/cli.js.map +1 -1
  47. package/dist/client/index.d.ts +34 -3
  48. package/dist/client/index.js +211 -12
  49. package/dist/client/index.js.map +1 -1
  50. package/dist/components/index.d.ts +1768 -30
  51. package/dist/components/index.js +7 -3
  52. package/dist/delta-text-CbrOaW83.d.ts +17 -0
  53. package/dist/{dev-NZRLOQCL.js → dev-O42JFQ64.js} +24 -13
  54. package/dist/dev-O42JFQ64.js.map +1 -0
  55. package/dist/doc/index.d.ts +219 -2
  56. package/dist/doc/index.js +525 -11
  57. package/dist/doc/index.js.map +1 -1
  58. package/dist/{docs-ZGDJUHJI.js → docs-JVP4RPKT.js} +3 -3
  59. package/dist/{docs-ZGDJUHJI.js.map → docs-JVP4RPKT.js.map} +1 -1
  60. package/dist/{doctor-VFKEMR54.js → doctor-YD3XAAOT.js} +8 -8
  61. package/dist/doctor-YD3XAAOT.js.map +1 -0
  62. package/dist/format-DihQkL1N.d.ts +249 -0
  63. package/dist/markdown/index.js +1 -1
  64. package/dist/markdown/index.js.map +1 -1
  65. package/dist/{preview-QDCIVVSR.js → preview-T6CLSQVX.js} +12 -4
  66. package/dist/preview-T6CLSQVX.js.map +1 -0
  67. package/dist/query/index.d.ts +0 -11
  68. package/dist/query/index.js +2 -2
  69. package/dist/{routes-RHP5FVGD.js → routes-PVKNT777.js} +6 -6
  70. package/dist/{routes-RHP5FVGD.js.map → routes-PVKNT777.js.map} +1 -1
  71. package/dist/{search-RFBELGY7.js → search-5LC4XPB5.js} +3 -3
  72. package/dist/{search-RFBELGY7.js.map → search-5LC4XPB5.js.map} +1 -1
  73. package/dist/slide/index.d.ts +272 -1
  74. package/dist/slide/index.js +1086 -19
  75. package/dist/slide/index.js.map +1 -1
  76. package/dist/table/index.js +14 -9
  77. package/dist/table/index.js.map +1 -1
  78. package/dist/ui/index.d.ts +148 -12
  79. package/dist/ui/index.js +1340 -87
  80. package/dist/ui/index.js.map +1 -1
  81. package/dist/{upgrade-GF2P67M6.js → upgrade-6DT7ADRP.js} +7 -7
  82. package/dist/{upgrade-GF2P67M6.js.map → upgrade-6DT7ADRP.js.map} +1 -1
  83. package/dist/vite/index.d.ts +10 -0
  84. package/dist/vite/index.js +4 -4
  85. package/docs/en/agent-skills.md +1 -1
  86. package/docs/en/changelog.md +26 -0
  87. package/docs/en/cli-reference.md +30 -0
  88. package/docs/en/components.md +42 -17
  89. package/docs/en/doc/delta-text.md +40 -0
  90. package/docs/en/doc/doc-action-items.md +49 -0
  91. package/docs/en/doc/doc-callout.md +38 -0
  92. package/docs/en/doc/doc-data-table.md +60 -0
  93. package/docs/en/doc/doc-executive-summary.md +64 -0
  94. package/docs/en/doc/doc-figure.md +56 -0
  95. package/docs/en/doc/doc-key-findings.md +61 -0
  96. package/docs/en/doc/doc-kpi-scorecard.md +80 -0
  97. package/docs/en/doc/doc-notes-and-sources.md +43 -0
  98. package/docs/en/doc/doc-report-header.md +46 -0
  99. package/docs/en/pages-and-metadata.md +15 -0
  100. package/docs/en/parts/area-chart.md +99 -0
  101. package/docs/en/parts/bar-chart.md +91 -0
  102. package/docs/en/parts/bar-list.md +50 -0
  103. package/docs/en/parts/category-bar.md +37 -0
  104. package/docs/en/parts/chart-frame.md +39 -0
  105. package/docs/en/parts/data-table.md +22 -0
  106. package/docs/en/parts/delta.md +51 -0
  107. package/docs/en/parts/donut-chart.md +72 -0
  108. package/docs/en/parts/format.md +43 -0
  109. package/docs/en/parts/funnel-steps.md +2 -1
  110. package/docs/en/parts/heatmap.md +53 -0
  111. package/docs/en/parts/kpi-card.md +58 -0
  112. package/docs/en/parts/legend.md +35 -0
  113. package/docs/en/parts/line-chart.md +94 -0
  114. package/docs/en/parts/metric-value.md +3 -2
  115. package/docs/en/parts/page-shell.md +1 -1
  116. package/docs/en/parts/progress-circle.md +33 -0
  117. package/docs/en/parts/sample-data.md +39 -0
  118. package/docs/en/parts/scatter-chart.md +56 -0
  119. package/docs/en/parts/sparkline.md +1 -1
  120. package/docs/en/parts/tracker.md +36 -0
  121. package/docs/en/parts/trend-indicator.md +17 -1
  122. package/docs/en/parts/updated-at.md +30 -0
  123. package/docs/en/parts/waterfall-chart.md +56 -0
  124. package/docs/en/routing.md +4 -2
  125. package/docs/en/slide/slide-chart-full.md +48 -0
  126. package/docs/en/slide/slide-chart-insight.md +52 -0
  127. package/docs/en/slide/slide-columns.md +46 -0
  128. package/docs/en/slide/slide-comparison.md +68 -0
  129. package/docs/en/slide/slide-cover.md +39 -0
  130. package/docs/en/slide/slide-exec-summary.md +47 -0
  131. package/docs/en/slide/slide-heading.md +38 -0
  132. package/docs/en/slide/slide-kpi-grid.md +55 -0
  133. package/docs/en/slide/slide-kpi-hero.md +58 -0
  134. package/docs/en/slide/slide-next-actions.md +49 -0
  135. package/docs/en/slide/slide-scorecard-table.md +54 -0
  136. package/docs/en/slide/slide-section.md +44 -0
  137. package/docs/en/slide/slide-source-line.md +34 -0
  138. package/docs/en/ui/alert-dialog.md +42 -0
  139. package/docs/en/ui/avatar.md +31 -0
  140. package/docs/en/ui/combobox.md +74 -0
  141. package/docs/en/ui/drawer.md +41 -0
  142. package/docs/en/ui/empty.md +1 -1
  143. package/docs/en/ui/error-state.md +4 -3
  144. package/docs/en/ui/field.md +42 -0
  145. package/docs/en/ui/hover-card.md +21 -0
  146. package/docs/en/ui/kbd.md +17 -0
  147. package/docs/en/ui/loading.md +1 -1
  148. package/docs/en/ui/pagination.md +36 -0
  149. package/docs/en/ui/radio-group.md +21 -0
  150. package/docs/en/ui/toast.md +44 -0
  151. package/docs/en/ui/toggle-group.md +4 -3
  152. package/docs/en/ui-and-theming.md +1 -1
  153. package/docs/index.json +1184 -114
  154. package/docs/ja/agent-skills.md +1 -1
  155. package/docs/ja/changelog.md +57 -0
  156. package/docs/ja/cli-reference.md +29 -0
  157. package/docs/ja/components.md +68 -101
  158. package/docs/ja/doc/delta-text.md +40 -0
  159. package/docs/ja/doc/doc-action-items.md +49 -0
  160. package/docs/ja/doc/doc-callout.md +38 -0
  161. package/docs/ja/doc/doc-data-table.md +60 -0
  162. package/docs/ja/doc/doc-executive-summary.md +64 -0
  163. package/docs/ja/doc/doc-figure.md +56 -0
  164. package/docs/ja/doc/doc-key-findings.md +61 -0
  165. package/docs/ja/doc/doc-kpi-scorecard.md +80 -0
  166. package/docs/ja/doc/doc-notes-and-sources.md +43 -0
  167. package/docs/ja/doc/doc-report-header.md +46 -0
  168. package/docs/ja/page-types/csv.md +83 -0
  169. package/docs/ja/page-types/doc.md +83 -0
  170. package/docs/ja/page-types/excel.md +82 -0
  171. package/docs/ja/page-types/slide.md +133 -0
  172. package/docs/ja/page-types.md +47 -0
  173. package/docs/ja/pages-and-metadata.md +15 -0
  174. package/docs/ja/parts/area-chart.md +85 -0
  175. package/docs/ja/parts/bar-chart.md +95 -0
  176. package/docs/ja/parts/bar-list.md +58 -0
  177. package/docs/ja/parts/category-bar.md +36 -0
  178. package/docs/ja/parts/chart-frame.md +36 -0
  179. package/docs/ja/parts/data-table.md +22 -0
  180. package/docs/ja/parts/delta.md +51 -0
  181. package/docs/ja/parts/donut-chart.md +66 -0
  182. package/docs/ja/parts/echart.md +3 -0
  183. package/docs/ja/parts/format.md +44 -0
  184. package/docs/ja/parts/funnel-steps.md +27 -8
  185. package/docs/ja/parts/heatmap.md +45 -0
  186. package/docs/ja/parts/kpi-card.md +56 -0
  187. package/docs/ja/parts/legend.md +36 -0
  188. package/docs/ja/parts/line-chart.md +84 -0
  189. package/docs/ja/parts/metric-value.md +3 -2
  190. package/docs/ja/parts/page-shell.md +1 -1
  191. package/docs/ja/parts/progress-circle.md +34 -0
  192. package/docs/ja/parts/sample-data.md +61 -0
  193. package/docs/ja/parts/scatter-chart.md +69 -0
  194. package/docs/ja/parts/sparkline.md +2 -2
  195. package/docs/ja/parts/tracker.md +32 -0
  196. package/docs/ja/parts/trend-indicator.md +17 -1
  197. package/docs/ja/parts/updated-at.md +27 -0
  198. package/docs/ja/parts/waterfall-chart.md +61 -0
  199. package/docs/ja/routing.md +8 -84
  200. package/docs/ja/slide/slide-chart-full.md +48 -0
  201. package/docs/ja/slide/slide-chart-insight.md +52 -0
  202. package/docs/ja/slide/slide-columns.md +46 -0
  203. package/docs/ja/slide/slide-comparison.md +68 -0
  204. package/docs/ja/slide/slide-cover.md +39 -0
  205. package/docs/ja/slide/slide-exec-summary.md +47 -0
  206. package/docs/ja/slide/slide-heading.md +38 -0
  207. package/docs/ja/slide/slide-kpi-grid.md +55 -0
  208. package/docs/ja/slide/slide-kpi-hero.md +58 -0
  209. package/docs/ja/slide/slide-next-actions.md +49 -0
  210. package/docs/ja/slide/slide-scorecard-table.md +54 -0
  211. package/docs/ja/slide/slide-section.md +44 -0
  212. package/docs/ja/slide/slide-source-line.md +34 -0
  213. package/docs/ja/ui/alert-dialog.md +41 -0
  214. package/docs/ja/ui/avatar.md +31 -0
  215. package/docs/ja/ui/combobox.md +74 -0
  216. package/docs/ja/ui/drawer.md +41 -0
  217. package/docs/ja/ui/empty.md +1 -1
  218. package/docs/ja/ui/error-state.md +4 -3
  219. package/docs/ja/ui/field.md +42 -0
  220. package/docs/ja/ui/hover-card.md +21 -0
  221. package/docs/ja/ui/kbd.md +16 -0
  222. package/docs/ja/ui/loading.md +1 -1
  223. package/docs/ja/ui/pagination.md +36 -0
  224. package/docs/ja/ui/radio-group.md +21 -0
  225. package/docs/ja/ui/toast.md +46 -0
  226. package/docs/ja/ui/toggle-group.md +4 -3
  227. package/docs/ja/ui-and-theming.md +14 -7
  228. package/package.json +43 -29
  229. package/registry/ui/accordion.tsx +76 -0
  230. package/registry/ui/alert-dialog.tsx +189 -0
  231. package/registry/ui/alert.tsx +80 -0
  232. package/registry/ui/app-shell.tsx +424 -0
  233. package/registry/ui/area-chart.tsx +3960 -0
  234. package/registry/ui/attention-list.tsx +465 -0
  235. package/registry/ui/avatar.tsx +110 -0
  236. package/registry/ui/badge.tsx +56 -0
  237. package/registry/ui/bar-chart.tsx +3954 -0
  238. package/registry/ui/bar-list.tsx +3998 -0
  239. package/registry/ui/box-plot-chart.tsx +4214 -0
  240. package/registry/ui/breadcrumb.tsx +128 -0
  241. package/registry/ui/button.tsx +62 -0
  242. package/registry/ui/calendar.tsx +223 -0
  243. package/registry/ui/card.tsx +107 -0
  244. package/registry/ui/category-bar.tsx +1498 -0
  245. package/registry/ui/chart-frame.tsx +1604 -0
  246. package/registry/ui/checkbox.tsx +30 -0
  247. package/registry/ui/collapsible.tsx +23 -0
  248. package/registry/ui/combobox.tsx +310 -0
  249. package/registry/ui/command.tsx +198 -0
  250. package/registry/ui/dashboard-card.tsx +217 -0
  251. package/registry/ui/data-table.tsx +896 -157
  252. package/registry/ui/date-range-picker.tsx +544 -0
  253. package/registry/ui/delta.tsx +350 -0
  254. package/registry/ui/dialog.tsx +161 -0
  255. package/registry/ui/donut-chart.tsx +4006 -0
  256. package/registry/ui/drawer.tsx +229 -0
  257. package/registry/ui/dropdown-menu.tsx +274 -0
  258. package/registry/ui/echart.tsx +1178 -0
  259. package/registry/ui/field.tsx +240 -0
  260. package/registry/ui/filter-bar.tsx +551 -0
  261. package/registry/ui/funnel-steps.tsx +3843 -0
  262. package/registry/ui/heatmap.tsx +2027 -0
  263. package/registry/ui/histogram-chart.tsx +4284 -0
  264. package/registry/ui/hover-card.tsx +52 -0
  265. package/registry/ui/input-group.tsx +160 -0
  266. package/registry/ui/input.tsx +24 -0
  267. package/registry/ui/kbd.tsx +30 -0
  268. package/registry/ui/kpi-card.tsx +905 -0
  269. package/registry/ui/label.tsx +22 -0
  270. package/registry/ui/legend.tsx +3817 -0
  271. package/registry/ui/line-chart.tsx +3958 -0
  272. package/registry/ui/metric-value.tsx +62 -0
  273. package/registry/ui/multi-select.tsx +382 -0
  274. package/registry/ui/page-shell.tsx +420 -0
  275. package/registry/ui/pagination.tsx +140 -0
  276. package/registry/ui/paired-chart.tsx +4086 -0
  277. package/registry/ui/placeholder.tsx +36 -0
  278. package/registry/ui/popover.tsx +92 -0
  279. package/registry/ui/progress-circle.tsx +1033 -0
  280. package/registry/ui/progress.tsx +85 -0
  281. package/registry/ui/radio-group.tsx +39 -0
  282. package/registry/ui/sample-data.tsx +230 -0
  283. package/registry/ui/scatter-chart.tsx +4503 -0
  284. package/registry/ui/scroll-area.tsx +56 -0
  285. package/registry/ui/searchable-select.tsx +352 -0
  286. package/registry/ui/section-header.tsx +43 -0
  287. package/registry/ui/segmented-control.tsx +76 -0
  288. package/registry/ui/select.tsx +255 -0
  289. package/registry/ui/separator.tsx +27 -0
  290. package/registry/ui/sheet.tsx +139 -0
  291. package/registry/ui/sidebar.tsx +725 -0
  292. package/registry/ui/skeleton.tsx +17 -0
  293. package/registry/ui/slider.tsx +56 -0
  294. package/registry/ui/sparkline.tsx +230 -0
  295. package/registry/ui/spinner.tsx +14 -0
  296. package/registry/ui/states.tsx +247 -0
  297. package/registry/ui/status-badge.tsx +286 -0
  298. package/registry/ui/switch.tsx +34 -0
  299. package/registry/ui/table.tsx +118 -0
  300. package/registry/ui/tabs.tsx +84 -0
  301. package/registry/ui/textarea.tsx +22 -0
  302. package/registry/ui/toast.tsx +250 -0
  303. package/registry/ui/toggle-group.tsx +91 -0
  304. package/registry/ui/toggle.tsx +47 -0
  305. package/registry/ui/tooltip.tsx +72 -0
  306. package/registry/ui/tracker.tsx +1015 -0
  307. package/registry/ui/trend-indicator.tsx +217 -0
  308. package/registry/ui/updated-at.tsx +276 -0
  309. package/registry/ui/waterfall-chart.tsx +4561 -0
  310. package/skills/vantage-add-feature/SKILL.md +9 -7
  311. package/skills/vantage-design/SKILL.md +62 -52
  312. package/skills/vantage-design/references/extract.md +26 -27
  313. package/skills/vantage-design/references/format.md +12 -172
  314. package/skills/vantage-design/references/presets.md +50 -110
  315. package/skills/vantage-pitfalls/SKILL.md +10 -1
  316. package/skills/vantage-slide/SKILL.md +71 -36
  317. package/templates/AGENTS.md +53 -16
  318. package/templates/agents/api.md +29 -0
  319. package/templates/agents/csv.md +2 -1
  320. package/templates/agents/doc.md +54 -3
  321. package/templates/agents/page.md +55 -10
  322. package/templates/agents/slide.md +90 -4
  323. package/templates/agents/xlsx.md +2 -1
  324. package/theme.css +287 -128
  325. package/dist/add-EISGSZAH.js +0 -6
  326. package/dist/add-EISGSZAH.js.map +0 -1
  327. package/dist/chunk-3G43C6OL.js.map +0 -1
  328. package/dist/chunk-5ZOP4SQR.js +0 -47
  329. package/dist/chunk-5ZOP4SQR.js.map +0 -1
  330. package/dist/chunk-A2UUGASH.js.map +0 -1
  331. package/dist/chunk-BCE22JSM.js.map +0 -1
  332. package/dist/chunk-DTDVSFRY.js +0 -29
  333. package/dist/chunk-DTDVSFRY.js.map +0 -1
  334. package/dist/chunk-EP6JHXSR.js.map +0 -1
  335. package/dist/chunk-JGRMRXXZ.js.map +0 -1
  336. package/dist/chunk-KLEIVDUV.js +0 -165
  337. package/dist/chunk-KLEIVDUV.js.map +0 -1
  338. package/dist/chunk-MXI3PZFT.js.map +0 -1
  339. package/dist/chunk-PLST5Q7T.js +0 -2221
  340. package/dist/chunk-PLST5Q7T.js.map +0 -1
  341. package/dist/chunk-PVTHHV7X.js.map +0 -1
  342. package/dist/chunk-T3FLAGI6.js +0 -316
  343. package/dist/chunk-T3FLAGI6.js.map +0 -1
  344. package/dist/dev-NZRLOQCL.js.map +0 -1
  345. package/dist/doctor-VFKEMR54.js.map +0 -1
  346. package/dist/preview-QDCIVVSR.js.map +0 -1
@@ -0,0 +1,551 @@
1
+ // Copied by `vantage add ui filter-bar`. This file is yours to edit.
2
+ // Generated from @squadbase/squadkit registry/components/filter-bar.tsx by `pnpm run registry` (in Vantage, edit packages/squadkit, not registry/).
3
+ "use client"
4
+
5
+ /**
6
+ * FilterBar — a compound filter row. `<FilterBar>` holds the (always
7
+ * controlled) filter values on context; the select, multi-select, active-chip
8
+ * and clear parts read and update them. `FilterBarPreset` builds the whole row
9
+ * from a `FilterConfig[]`.
10
+ */
11
+ import {
12
+ createContext,
13
+ forwardRef,
14
+ useContext,
15
+ type HTMLAttributes,
16
+ type ReactNode,
17
+ } from "react"
18
+ import { ChevronDown, X } from "lucide-react"
19
+
20
+ import { cn } from "@squadbase/vantage/ui"
21
+ import { Badge } from "@squadbase/vantage/ui"
22
+ import { Button } from "@squadbase/vantage/ui"
23
+ import { Checkbox } from "@squadbase/vantage/ui"
24
+ import { Popover, PopoverContent, PopoverTrigger } from "@squadbase/vantage/ui"
25
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@squadbase/vantage/ui"
26
+ import type { FilterConfig, FilterOption, FilterValues } from "@squadbase/vantage/components"
27
+ import { useSyncExternalStore } from "react"
28
+
29
+ /* ---------- inlined from @squadbase/squadkit registry/lib/locale.ts (internal to @squadbase/vantage) ---------- */
30
+
31
+ /**
32
+ * The display language of the parts and the defaults that follow it.
33
+ *
34
+ * The language comes from `<html lang>`: a tag starting with `ja` reads Japanese, anything else English.
35
+ * Without a usable `lang` (missing, invalid, or no `document` — SSR, Node) the locale is `FALLBACK_LOCALE`
36
+ * (`en-US`). A `locale` passed explicitly (a prop, an argument) always wins.
37
+ *
38
+ * Parts read the locale through `useLocale` (`hooks/use-locale`) and pass it down; the pure helpers here
39
+ * and in `format` / `comparison` / `chart-*` take it as an argument and fall back to `documentLocale()`.
40
+ */
41
+
42
+ /** The language of the built-in wording: Japanese or English. */
43
+ type UiLanguage = "ja" | "en"
44
+
45
+ /** The locale used when `<html lang>` gives none (and on the server). */
46
+ const FALLBACK_LOCALE = "en-US"
47
+
48
+ /** `"ja"` when `locale` starts with `ja` (`ja`, `ja-JP`), else `"en"`. A missing locale is `"en"`. */
49
+ function uiLanguage(locale: string | null | undefined): UiLanguage {
50
+ return typeof locale === "string" && locale.trim().toLowerCase().startsWith("ja") ? "ja" : "en"
51
+ }
52
+
53
+ /** A BCP 47 tag in its canonical form (`en-gb` → `en-GB`), or `FALLBACK_LOCALE` when it is empty or invalid. */
54
+ function normalizeLocale(tag: string | null | undefined): string {
55
+ const value = tag?.trim()
56
+ if (!value) return FALLBACK_LOCALE
57
+ try {
58
+ return Intl.getCanonicalLocales(value)[0] ?? FALLBACK_LOCALE
59
+ } catch {
60
+ return FALLBACK_LOCALE
61
+ }
62
+ }
63
+
64
+ /**
65
+ * The locale of the page: `document.documentElement.lang`, canonicalized. `FALLBACK_LOCALE` when it is empty or
66
+ * invalid, or there is no `document`. Parts read it through `useLocale`, never while rendering.
67
+ */
68
+ function documentLocale(): string {
69
+ if (typeof document === "undefined") return FALLBACK_LOCALE
70
+ return normalizeLocale(document.documentElement?.getAttribute("lang"))
71
+ }
72
+
73
+ /** `locale` when given, else the page's locale (`documentLocale()`). */
74
+ function resolveLocale(locale?: string | null): string {
75
+ return locale || documentLocale()
76
+ }
77
+
78
+ /** Picks the wording table of the locale's language. */
79
+ function pickLocale<T>(table: { ja: T; en: T }, locale?: string | null): T {
80
+ return table[uiLanguage(resolveLocale(locale))]
81
+ }
82
+
83
+ /** The currency `format="currency"` uses without a `currency`: JPY for Japanese, USD otherwise. */
84
+ function defaultCurrency(locale?: string | null): string {
85
+ return uiLanguage(resolveLocale(locale)) === "ja" ? "JPY" : "USD"
86
+ }
87
+
88
+ /** The month a fiscal year starts in (1–12) when none is given: April for Japanese, January otherwise. */
89
+ function defaultFiscalYearStartMonth(locale?: string | null): number {
90
+ return uiLanguage(resolveLocale(locale)) === "ja" ? 4 : 1
91
+ }
92
+
93
+ /** A day of the week, 0 = Sunday … 6 = Saturday (the `Date#getDay` / date-fns numbering). */
94
+ type WeekDay = 0 | 1 | 2 | 3 | 4 | 5 | 6
95
+
96
+ /** Locales whose week starts on Sunday when the runtime has no week data. */
97
+ const SUNDAY_FIRST = new Set(["en", "en-US", "en-CA"])
98
+
99
+ /**
100
+ * The first day of the week: Monday for Japanese; otherwise the locale's convention from `Intl.Locale`
101
+ * (`en-US` Sunday, `en-GB` Monday). Without week data in the runtime: Sunday for `en` / `en-US` / `en-CA`,
102
+ * Monday for the rest.
103
+ */
104
+ function weekStartsOn(locale?: string | null): WeekDay {
105
+ const tag = normalizeLocale(resolveLocale(locale))
106
+ if (uiLanguage(tag) === "ja") return 1
107
+ try {
108
+ const info = new Intl.Locale(tag) as Intl.Locale & {
109
+ getWeekInfo?: () => { firstDay: number }
110
+ weekInfo?: { firstDay: number }
111
+ }
112
+ const firstDay = info.getWeekInfo?.().firstDay ?? info.weekInfo?.firstDay
113
+ if (typeof firstDay === "number" && firstDay >= 1 && firstDay <= 7) return (firstDay % 7) as WeekDay
114
+ } catch {
115
+ // Fall through to the table below.
116
+ }
117
+ return SUNDAY_FIRST.has(tag) ? 0 : 1
118
+ }
119
+
120
+ /* ---------- inlined from @squadbase/squadkit registry/hooks/use-locale.ts (internal to @squadbase/vantage) ---------- */
121
+
122
+ const listeners = new Set<() => void>()
123
+ let observer: MutationObserver | null = null
124
+
125
+ /** One observer on `<html lang>` for every subscribed part. */
126
+ function subscribe(onChange: () => void): () => void {
127
+ if (typeof document === "undefined" || typeof MutationObserver === "undefined") return () => {}
128
+ listeners.add(onChange)
129
+ if (!observer) {
130
+ observer = new MutationObserver(() => {
131
+ for (const listener of [...listeners]) listener()
132
+ })
133
+ observer.observe(document.documentElement, { attributes: true, attributeFilter: ["lang"] })
134
+ }
135
+ return () => {
136
+ listeners.delete(onChange)
137
+ if (listeners.size === 0 && observer) {
138
+ observer.disconnect()
139
+ observer = null
140
+ }
141
+ }
142
+ }
143
+
144
+ const serverLocale = () => FALLBACK_LOCALE
145
+
146
+ /**
147
+ * The page's locale (`<html lang>`), following changes made while the page runs. On the server and during
148
+ * hydration it is `FALLBACK_LOCALE` (`en-US`), so the markup matches; it switches right after.
149
+ */
150
+ function useDocumentLocale(): string {
151
+ return useSyncExternalStore(subscribe, documentLocale, serverLocale)
152
+ }
153
+
154
+ /** The locale a part renders in: its `locale` prop when given, else the page's (`useDocumentLocale`). */
155
+ function useLocale(locale?: string | null): string {
156
+ const page = useDocumentLocale()
157
+ return locale || page
158
+ }
159
+
160
+ /* ---------- end of inlined code ---------- */
161
+
162
+ /* --------------------------------------------------------------- context */
163
+
164
+ interface FilterBarContextValue {
165
+ /** Current filter values (controlled from outside) */
166
+ value: FilterValues
167
+ /** Notify the parent of a value change */
168
+ onChange: (next: FilterValues) => void
169
+ /** Optional clear callback — undefined means no clear button */
170
+ onClear?: () => void
171
+ }
172
+
173
+ const FilterBarContext = createContext<FilterBarContextValue | null>(null)
174
+
175
+ const TEXT = {
176
+ ja: {
177
+ filters: "フィルター",
178
+ selected: (count: number) => ` (${count}件選択中)`,
179
+ remove: (filter: string, option: string) => `${filter}: ${option} を削除`,
180
+ clear: "クリア",
181
+ clearAll: "すべてのフィルターをクリア",
182
+ },
183
+ en: {
184
+ filters: "Filters",
185
+ selected: (count: number) => ` (${count} selected)`,
186
+ remove: (filter: string, option: string) => `Remove ${filter}: ${option}`,
187
+ clear: "Clear",
188
+ clearAll: "Clear all filters",
189
+ },
190
+ }
191
+
192
+ const useText = () => TEXT[uiLanguage(useLocale())]
193
+
194
+ function useFilterBar(): FilterBarContextValue {
195
+ const ctx = useContext(FilterBarContext)
196
+ if (!ctx) throw new Error("useFilterBar must be used within <FilterBar>")
197
+ return ctx
198
+ }
199
+
200
+ /* ------------------------------------------------------------------ root */
201
+
202
+ export interface FilterBarProps extends Omit<HTMLAttributes<HTMLDivElement>, "onChange"> {
203
+ value: FilterValues
204
+ onChange: (values: FilterValues) => void
205
+ onClear?: () => void
206
+ className?: string
207
+ children?: ReactNode
208
+ }
209
+
210
+ export const FilterBar = forwardRef<HTMLDivElement, FilterBarProps>(
211
+ ({ value, onChange, onClear, className, children, ...props }, ref) => {
212
+ const t = useText()
213
+ return (
214
+ <FilterBarContext.Provider value={{ value, onChange, onClear }}>
215
+ <div
216
+ ref={ref}
217
+ role="search"
218
+ aria-label={t.filters}
219
+ data-slot="filter-bar"
220
+ className={cn("flex flex-wrap items-center gap-2", className)}
221
+ {...props}
222
+ >
223
+ {children}
224
+ </div>
225
+ </FilterBarContext.Provider>
226
+ )
227
+ },
228
+ )
229
+ FilterBar.displayName = "FilterBar"
230
+
231
+ /* ---------------------------------------------------------------- select */
232
+
233
+ export interface FilterBarSelectProps {
234
+ filterKey: string
235
+ label: string
236
+ options: FilterOption[]
237
+ placeholder?: string
238
+ /**
239
+ * 渡すと、選択肢の先頭に「絞り込まない」項目をこの文言で足す(例: `"すべて"`)。選ぶとこのキーを値から外す(`undefined`)ので、
240
+ * アクティブチップにも出ない。絞り込んでいないときのトリガーは `placeholder`(既定は `label`)のまま。既定は足さない。
241
+ * @example allLabel="すべて"
242
+ */
243
+ allLabel?: string
244
+ className?: string
245
+ }
246
+
247
+ /** 「すべて」項目の値。実際の選択肢の値と衝突しない内部用の印で、`onChange` には渡らない。 */
248
+ const ALL_VALUE = "__squadkit_all__"
249
+
250
+ export function FilterBarSelect({
251
+ filterKey,
252
+ label,
253
+ options,
254
+ placeholder,
255
+ allLabel,
256
+ className,
257
+ }: FilterBarSelectProps) {
258
+ const { value, onChange } = useFilterBar()
259
+ const hasAll = allLabel !== undefined
260
+ const items = hasAll ? [{ value: ALL_VALUE, label: allLabel }, ...options] : options
261
+ const current = value[filterKey] as string | undefined
262
+
263
+ // Base UI reports `null` when the selection is cleared — drop the key so
264
+ // "no filter" reads as absent rather than as an empty string. "すべて" does the same.
265
+ const handleChange = (selected: string | null) =>
266
+ onChange({ ...value, [filterKey]: selected === null || selected === ALL_VALUE ? undefined : selected })
267
+
268
+ return (
269
+ <Select
270
+ // FilterOption is already `{ value, label }` — Base UI uses it to show the
271
+ // label (not the raw value) in the trigger.
272
+ items={items}
273
+ value={current ?? ""}
274
+ onValueChange={handleChange}
275
+ >
276
+ <SelectTrigger size="sm" aria-label={label} data-slot="filter-bar-select" className={className}>
277
+ <SelectValue placeholder={placeholder ?? label} />
278
+ </SelectTrigger>
279
+ <SelectContent>
280
+ {hasAll && <SelectItem value={ALL_VALUE}>{allLabel}</SelectItem>}
281
+ {options.map((option) => (
282
+ <SelectItem key={option.value} value={option.value} disabled={option.disabled}>
283
+ {option.label}
284
+ </SelectItem>
285
+ ))}
286
+ </SelectContent>
287
+ </Select>
288
+ )
289
+ }
290
+ FilterBarSelect.displayName = "FilterBarSelect"
291
+
292
+ /* ---------------------------------------------------------- multi-select */
293
+
294
+ export interface FilterBarMultiSelectProps {
295
+ filterKey: string
296
+ label: string
297
+ options: FilterOption[]
298
+ placeholder?: string
299
+ className?: string
300
+ }
301
+
302
+ export function FilterBarMultiSelect({
303
+ filterKey,
304
+ label,
305
+ options,
306
+ placeholder,
307
+ className,
308
+ }: FilterBarMultiSelectProps) {
309
+ const { value, onChange } = useFilterBar()
310
+ const t = useText()
311
+ const selected = (value[filterKey] as string[] | undefined) ?? []
312
+
313
+ const handleToggle = (option: string) => {
314
+ const next = selected.includes(option)
315
+ ? selected.filter((v) => v !== option)
316
+ : [...selected, option]
317
+ // Drop the key entirely when nothing is left, so "no filter" reads as absent.
318
+ onChange({ ...value, [filterKey]: next.length > 0 ? next : undefined })
319
+ }
320
+
321
+ return (
322
+ <Popover>
323
+ <PopoverTrigger
324
+ render={<Button variant="outline" size="sm" className={cn("h-8 gap-1", className)} />}
325
+ aria-label={`${placeholder ?? label}${selected.length > 0 ? t.selected(selected.length) : ""}`}
326
+ data-slot="filter-bar-multi-select"
327
+ >
328
+ {placeholder ?? label}
329
+ {selected.length > 0 && (
330
+ <Badge variant="secondary" className="ml-1 px-1.5 py-0 text-xs">
331
+ {selected.length}
332
+ </Badge>
333
+ )}
334
+ <ChevronDown className="size-3.5 opacity-50" aria-hidden="true" />
335
+ </PopoverTrigger>
336
+ <PopoverContent align="start" className="w-56 p-2">
337
+ <div className="flex flex-col gap-1" role="group" aria-label={label}>
338
+ {options.map((option) => (
339
+ <label
340
+ key={option.value}
341
+ className="flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-accent"
342
+ >
343
+ <Checkbox
344
+ checked={selected.includes(option.value)}
345
+ disabled={option.disabled}
346
+ onCheckedChange={() => handleToggle(option.value)}
347
+ />
348
+ {option.label}
349
+ </label>
350
+ ))}
351
+ </div>
352
+ </PopoverContent>
353
+ </Popover>
354
+ )
355
+ }
356
+ FilterBarMultiSelect.displayName = "FilterBarMultiSelect"
357
+
358
+ /* ---------------------------------------------------------- active chips */
359
+
360
+ export interface FilterBarActiveChipsProps {
361
+ /** Filter configs used to resolve option labels. Without them, raw values show. */
362
+ filters?: FilterConfig[]
363
+ className?: string
364
+ }
365
+
366
+ interface ActiveChip {
367
+ key: string
368
+ filterLabel: string
369
+ optionLabel: string
370
+ optionValue?: string
371
+ isMulti: boolean
372
+ }
373
+
374
+ export function FilterBarActiveChips({ filters, className }: FilterBarActiveChipsProps) {
375
+ const { value, onChange } = useFilterBar()
376
+ const t = useText()
377
+
378
+ const getActiveChips = (): ActiveChip[] => {
379
+ const chips: ActiveChip[] = []
380
+
381
+ const pushRaw = (key: string, v: string | string[]) => {
382
+ if (typeof v === "string") {
383
+ chips.push({ key, filterLabel: key, optionLabel: v, isMulti: false })
384
+ } else {
385
+ for (const val of v) {
386
+ chips.push({ key, filterLabel: key, optionLabel: val, optionValue: val, isMulti: true })
387
+ }
388
+ }
389
+ }
390
+
391
+ for (const [key, v] of Object.entries(value)) {
392
+ if (v === undefined || v === "") continue
393
+
394
+ const filter = filters?.find((f) => f.key === key)
395
+ if (!filter) {
396
+ pushRaw(key, v)
397
+ continue
398
+ }
399
+
400
+ if (filter.type === "select" && typeof v === "string") {
401
+ const option = filter.options?.find((o) => o.value === v)
402
+ chips.push({
403
+ key,
404
+ filterLabel: filter.label,
405
+ optionLabel: option?.label ?? v,
406
+ isMulti: false,
407
+ })
408
+ } else if (filter.type === "multi-select" && Array.isArray(v)) {
409
+ for (const val of v) {
410
+ const option = filter.options?.find((o) => o.value === val)
411
+ chips.push({
412
+ key,
413
+ filterLabel: filter.label,
414
+ optionLabel: option?.label ?? val,
415
+ optionValue: val,
416
+ isMulti: true,
417
+ })
418
+ }
419
+ }
420
+ }
421
+
422
+ return chips
423
+ }
424
+
425
+ const handleRemoveFilter = (key: string, optionValue?: string) => {
426
+ if (optionValue !== undefined) {
427
+ const current = (value[key] as string[] | undefined) ?? []
428
+ const next = current.filter((v) => v !== optionValue)
429
+ onChange({ ...value, [key]: next.length > 0 ? next : undefined })
430
+ } else {
431
+ onChange({ ...value, [key]: undefined })
432
+ }
433
+ }
434
+
435
+ const activeChips = getActiveChips()
436
+
437
+ if (activeChips.length === 0) return null
438
+
439
+ return (
440
+ <>
441
+ {activeChips.map((chip) => (
442
+ <Badge
443
+ key={`${chip.key}-${chip.optionValue ?? "single"}`}
444
+ variant="secondary"
445
+ className={cn("gap-1 pr-1", className)}
446
+ data-slot="filter-bar-chip"
447
+ >
448
+ <span className="text-xs text-muted-foreground">{chip.filterLabel}:</span>
449
+ {chip.optionLabel}
450
+ <button
451
+ type="button"
452
+ className="ml-0.5 rounded-full p-0.5 hover:bg-muted-foreground/20"
453
+ onClick={() => handleRemoveFilter(chip.key, chip.optionValue)}
454
+ aria-label={t.remove(chip.filterLabel, chip.optionLabel)}
455
+ >
456
+ <X className="size-3" aria-hidden="true" />
457
+ </button>
458
+ </Badge>
459
+ ))}
460
+ </>
461
+ )
462
+ }
463
+ FilterBarActiveChips.displayName = "FilterBarActiveChips"
464
+
465
+ /* ----------------------------------------------------------- clear button */
466
+
467
+ export interface FilterBarClearButtonProps {
468
+ /** Override the button label. Defaults to "Clear" (ja: "クリア"). */
469
+ label?: string
470
+ className?: string
471
+ }
472
+
473
+ export function FilterBarClearButton({ label, className }: FilterBarClearButtonProps) {
474
+ const { value, onClear } = useFilterBar()
475
+ const t = useText()
476
+ const hasActiveFilters = Object.values(value).some((v) =>
477
+ Array.isArray(v) ? v.length > 0 : v !== undefined && v !== "",
478
+ )
479
+ if (!hasActiveFilters || !onClear) return null
480
+
481
+ return (
482
+ <Button
483
+ variant="ghost"
484
+ size="sm"
485
+ className={cn("h-7 px-2 text-xs", className)}
486
+ onClick={onClear}
487
+ aria-label={t.clearAll}
488
+ data-slot="filter-bar-clear-button"
489
+ >
490
+ {label ?? t.clear}
491
+ </Button>
492
+ )
493
+ }
494
+ FilterBarClearButton.displayName = "FilterBarClearButton"
495
+
496
+ /* ------------------------------------------------------------------ preset */
497
+
498
+ export interface FilterBarPresetProps {
499
+ filters: FilterConfig[]
500
+ value: FilterValues
501
+ onChange: (values: FilterValues) => void
502
+ onClear?: () => void
503
+ className?: string
504
+ }
505
+
506
+ /** Not given yet (a draft fills props in steps): render empty, keep the same value between renders. */
507
+ const NO_FILTERS: never[] = []
508
+ const NO_FILTER_VALUES: FilterValues = {}
509
+
510
+ /** The whole row built from a `FilterConfig[]`. */
511
+ export function FilterBarPreset({
512
+ filters = NO_FILTERS,
513
+ value = NO_FILTER_VALUES,
514
+ onChange,
515
+ onClear,
516
+ className,
517
+ }: FilterBarPresetProps) {
518
+ return (
519
+ <FilterBar value={value} onChange={onChange} onClear={onClear} className={className}>
520
+ {filters.map((filter) => {
521
+ if (filter.type === "select") {
522
+ return (
523
+ <FilterBarSelect
524
+ key={filter.key}
525
+ filterKey={filter.key}
526
+ label={filter.label}
527
+ placeholder={filter.placeholder}
528
+ allLabel={filter.allLabel}
529
+ options={filter.options ?? []}
530
+ />
531
+ )
532
+ }
533
+ if (filter.type === "multi-select") {
534
+ return (
535
+ <FilterBarMultiSelect
536
+ key={filter.key}
537
+ filterKey={filter.key}
538
+ label={filter.label}
539
+ placeholder={filter.placeholder}
540
+ options={filter.options ?? []}
541
+ />
542
+ )
543
+ }
544
+ return null
545
+ })}
546
+ <FilterBarActiveChips filters={filters} />
547
+ {onClear && <FilterBarClearButton />}
548
+ </FilterBar>
549
+ )
550
+ }
551
+ FilterBarPreset.displayName = "FilterBarPreset"