@noix-dev/brix-vue 0.0.0-stage → 0.2.0

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 (255) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +74 -2
  3. package/package.json +117 -3
  4. package/src/components/address-field/AddressField.vue +337 -0
  5. package/src/components/address-field/index.ts +1 -0
  6. package/src/components/appearance-picker/AppearancePicker.vue +502 -0
  7. package/src/components/appearance-picker/AppearanceSegment.vue +175 -0
  8. package/src/components/appearance-picker/index.ts +44 -0
  9. package/src/components/autofill/AutoFillDialog.vue +264 -0
  10. package/src/components/autofill/index.ts +1 -0
  11. package/src/components/badge/Badge.vue +23 -0
  12. package/src/components/badge/index.ts +106 -0
  13. package/src/components/build-stamp/BuildStamp.vue +62 -0
  14. package/src/components/build-stamp/index.ts +1 -0
  15. package/src/components/button/Button.vue +31 -0
  16. package/src/components/button/index.ts +122 -0
  17. package/src/components/card/Card.vue +29 -0
  18. package/src/components/card/CardAction.vue +17 -0
  19. package/src/components/card/CardContent.vue +14 -0
  20. package/src/components/card/CardDescription.vue +14 -0
  21. package/src/components/card/CardFooter.vue +22 -0
  22. package/src/components/card/CardHeader.vue +22 -0
  23. package/src/components/card/CardTitle.vue +29 -0
  24. package/src/components/card/index.ts +47 -0
  25. package/src/components/chart/BarChart.vue +123 -0
  26. package/src/components/chart/StackedBarChart.vue +149 -0
  27. package/src/components/chart/appearanceRevision.ts +22 -0
  28. package/src/components/chart/chartColor.ts +59 -0
  29. package/src/components/chart/index.ts +6 -0
  30. package/src/components/checkbox/Checkbox.vue +61 -0
  31. package/src/components/checkbox/index.ts +1 -0
  32. package/src/components/code-editor/CodeEditor.vue +352 -0
  33. package/src/components/code-editor/index.ts +9 -0
  34. package/src/components/code-editor/syntaxTheme.ts +110 -0
  35. package/src/components/colour-picker/ColourPicker.vue +421 -0
  36. package/src/components/colour-picker/index.ts +1 -0
  37. package/src/components/combobox/Combobox.vue +337 -0
  38. package/src/components/combobox/index.ts +1 -0
  39. package/src/components/comments/CommentComposer.vue +302 -0
  40. package/src/components/comments/CommentMessage.vue +259 -0
  41. package/src/components/comments/CommentThread.vue +250 -0
  42. package/src/components/comments/commentBody.ts +185 -0
  43. package/src/components/comments/commentLevels.ts +139 -0
  44. package/src/components/comments/commentNode.ts +35 -0
  45. package/src/components/comments/composer.ts +20 -0
  46. package/src/components/comments/index.ts +29 -0
  47. package/src/components/confirm-dialog/ConfirmDialog.vue +153 -0
  48. package/src/components/confirm-dialog/index.ts +1 -0
  49. package/src/components/containers/Box.vue +42 -0
  50. package/src/components/containers/Section.vue +88 -0
  51. package/src/components/containers/SectionAction.vue +17 -0
  52. package/src/components/containers/SectionContent.vue +14 -0
  53. package/src/components/containers/SectionDescription.vue +14 -0
  54. package/src/components/containers/SectionHeader.vue +22 -0
  55. package/src/components/containers/SectionTitle.vue +17 -0
  56. package/src/components/containers/index.ts +9 -0
  57. package/src/components/data-table/ColumnMenu.vue +241 -0
  58. package/src/components/data-table/DataTable.vue +447 -0
  59. package/src/components/data-table/ExpandCaret.vue +34 -0
  60. package/src/components/data-table/SortableHead.vue +184 -0
  61. package/src/components/data-table/TableLoadingRow.vue +13 -0
  62. package/src/components/data-table/TableProgressRow.vue +26 -0
  63. package/src/components/data-table/columns.ts +13 -0
  64. package/src/components/data-table/index.ts +3 -0
  65. package/src/components/data-table/pinned.ts +19 -0
  66. package/src/components/data-table/rowActivation.ts +14 -0
  67. package/src/components/data-table/sort.ts +13 -0
  68. package/src/components/data-table/types.ts +23 -0
  69. package/src/components/date-picker/CalendarPanel.vue +432 -0
  70. package/src/components/date-picker/DateField.vue +293 -0
  71. package/src/components/date-picker/DatePicker.vue +147 -0
  72. package/src/components/date-picker/UntilDatePicker.vue +96 -0
  73. package/src/components/date-picker/dateFieldGuard.ts +87 -0
  74. package/src/components/date-picker/index.ts +4 -0
  75. package/src/components/date-picker/useDateField.ts +37 -0
  76. package/src/components/date-range-picker/DateRangePicker.vue +247 -0
  77. package/src/components/date-range-picker/index.ts +1 -0
  78. package/src/components/date-time-picker/DateTimePicker.vue +291 -0
  79. package/src/components/date-time-picker/index.ts +1 -0
  80. package/src/components/dialog/Dialog.vue +250 -0
  81. package/src/components/dialog/DialogSurface.vue +214 -0
  82. package/src/components/dialog/dialogEdges.ts +65 -0
  83. package/src/components/dialog/dialogSizes.ts +35 -0
  84. package/src/components/dialog/index.ts +12 -0
  85. package/src/components/dialog/toastHost.ts +18 -0
  86. package/src/components/dropdown/Dropdown.vue +101 -0
  87. package/src/components/dropdown/DropdownItems.vue +154 -0
  88. package/src/components/dropdown/dropdown.ts +64 -0
  89. package/src/components/dropdown/index.ts +2 -0
  90. package/src/components/file-preview/FilePreview.vue +78 -0
  91. package/src/components/file-preview/index.ts +1 -0
  92. package/src/components/file-upload/FileUpload.vue +234 -0
  93. package/src/components/file-upload/index.ts +1 -0
  94. package/src/components/filter-check-menu/FilterCheckMenu.vue +562 -0
  95. package/src/components/filter-check-menu/filterCheckOption.ts +10 -0
  96. package/src/components/filter-check-menu/index.ts +2 -0
  97. package/src/components/form-field/FormField.vue +74 -0
  98. package/src/components/form-field/index.ts +2 -0
  99. package/src/components/form-field/types.ts +5 -0
  100. package/src/components/frames/FrameCentred.vue +137 -0
  101. package/src/components/frames/FrameSidebar.vue +113 -0
  102. package/src/components/frames/FrameSplit.vue +109 -0
  103. package/src/components/frames/index.ts +3 -0
  104. package/src/components/icon/BellIcon.vue +27 -0
  105. package/src/components/icon/BoldIcon.vue +31 -0
  106. package/src/components/icon/CalendarDaysIcon.vue +33 -0
  107. package/src/components/icon/CheckIcon.vue +31 -0
  108. package/src/components/icon/ChevronDownIcon.vue +30 -0
  109. package/src/components/icon/ChevronLeftIcon.vue +31 -0
  110. package/src/components/icon/ChevronRightIcon.vue +31 -0
  111. package/src/components/icon/ChevronUpIcon.vue +30 -0
  112. package/src/components/icon/CircleAlertIcon.vue +29 -0
  113. package/src/components/icon/ClockIcon.vue +31 -0
  114. package/src/components/icon/Columns3Icon.vue +32 -0
  115. package/src/components/icon/FlipHorizontalIcon.vue +29 -0
  116. package/src/components/icon/ItalicIcon.vue +28 -0
  117. package/src/components/icon/LinkIcon.vue +27 -0
  118. package/src/components/icon/ListIcon.vue +29 -0
  119. package/src/components/icon/ListOrderedIcon.vue +28 -0
  120. package/src/components/icon/PenLineIcon.vue +31 -0
  121. package/src/components/icon/PlusIcon.vue +28 -0
  122. package/src/components/icon/RotateCcwIcon.vue +28 -0
  123. package/src/components/icon/RotateCwIcon.vue +28 -0
  124. package/src/components/icon/SearchIcon.vue +31 -0
  125. package/src/components/icon/StarIcon.vue +29 -0
  126. package/src/components/icon/TriangleAlertIcon.vue +29 -0
  127. package/src/components/icon/UnderlineIcon.vue +27 -0
  128. package/src/components/icon/Undo2Icon.vue +28 -0
  129. package/src/components/icon/XIcon.vue +31 -0
  130. package/src/components/icon/ZoomInIcon.vue +30 -0
  131. package/src/components/icon/ZoomOutIcon.vue +29 -0
  132. package/src/components/icon/index.ts +37 -0
  133. package/src/components/icon-picker/IconPicker.vue +560 -0
  134. package/src/components/icon-picker/index.ts +1 -0
  135. package/src/components/image-crop-dialog/CropRatioRow.vue +132 -0
  136. package/src/components/image-crop-dialog/CropVariantStrip.vue +277 -0
  137. package/src/components/image-crop-dialog/ImageCropDialog.vue +1541 -0
  138. package/src/components/image-crop-dialog/index.ts +16 -0
  139. package/src/components/image-upload/ImageUpload.vue +345 -0
  140. package/src/components/image-upload/index.ts +2 -0
  141. package/src/components/input/Input.vue +48 -0
  142. package/src/components/input/index.ts +1 -0
  143. package/src/components/keycap/Keycap.vue +49 -0
  144. package/src/components/keycap/index.ts +1 -0
  145. package/src/components/label/Label.vue +26 -0
  146. package/src/components/label/index.ts +1 -0
  147. package/src/components/menu/MenuCheckboxItem.vue +63 -0
  148. package/src/components/menu/MenuContent.vue +45 -0
  149. package/src/components/menu/MenuGroup.vue +22 -0
  150. package/src/components/menu/MenuItem.vue +34 -0
  151. package/src/components/menu/MenuLabel.vue +22 -0
  152. package/src/components/menu/MenuRadioGroup.vue +22 -0
  153. package/src/components/menu/MenuRadioItem.vue +50 -0
  154. package/src/components/menu/MenuRoot.vue +25 -0
  155. package/src/components/menu/MenuSeparator.vue +27 -0
  156. package/src/components/menu/MenuSub.vue +29 -0
  157. package/src/components/menu/MenuSubContent.vue +48 -0
  158. package/src/components/menu/MenuSubTrigger.vue +49 -0
  159. package/src/components/menu/MenuTrigger.vue +22 -0
  160. package/src/components/menu/index.ts +20 -0
  161. package/src/components/menu/menuClasses.ts +74 -0
  162. package/src/components/morph-select/MorphSelect.vue +150 -0
  163. package/src/components/morph-select/index.ts +1 -0
  164. package/src/components/nav/NavFlyout.vue +343 -0
  165. package/src/components/nav/NavGroup.vue +306 -0
  166. package/src/components/nav/NavItem.vue +243 -0
  167. package/src/components/nav/NavNodes.ts +66 -0
  168. package/src/components/nav/NavSection.vue +105 -0
  169. package/src/components/nav/NavSidebar.vue +137 -0
  170. package/src/components/nav/index.ts +5 -0
  171. package/src/components/nav/navChain.ts +112 -0
  172. package/src/components/nav/navClasses.ts +229 -0
  173. package/src/components/nav/navNode.ts +10 -0
  174. package/src/components/nav/navRegistry.ts +24 -0
  175. package/src/components/notification-list/NotificationList.vue +314 -0
  176. package/src/components/notification-list/index.ts +2 -0
  177. package/src/components/notification-list/notifications.ts +21 -0
  178. package/src/components/pagination/Pagination.vue +296 -0
  179. package/src/components/pagination/index.ts +1 -0
  180. package/src/components/pin-field/PinField.vue +332 -0
  181. package/src/components/pin-field/index.ts +1 -0
  182. package/src/components/popover-panel/PopoverPanel.vue +115 -0
  183. package/src/components/popover-panel/index.ts +5 -0
  184. package/src/components/rating/Rating.vue +201 -0
  185. package/src/components/rating/index.ts +1 -0
  186. package/src/components/record-avatar/RecordAvatar.vue +76 -0
  187. package/src/components/record-avatar/index.ts +1 -0
  188. package/src/components/result-window/ResultWindow.vue +399 -0
  189. package/src/components/result-window/index.ts +2 -0
  190. package/src/components/result-window/results.ts +75 -0
  191. package/src/components/rich-editor/RichEditor.vue +370 -0
  192. package/src/components/rich-editor/RichEditorLinkDialog.vue +133 -0
  193. package/src/components/rich-editor/index.ts +8 -0
  194. package/src/components/row-actions/RowActions.vue +262 -0
  195. package/src/components/row-actions/index.ts +2 -0
  196. package/src/components/row-actions/rowActions.ts +44 -0
  197. package/src/components/search-select/SearchSelect.vue +599 -0
  198. package/src/components/search-select/index.ts +2 -0
  199. package/src/components/search-select/types.ts +14 -0
  200. package/src/components/segmented-choice/SegmentedChoice.vue +136 -0
  201. package/src/components/segmented-choice/index.ts +2 -0
  202. package/src/components/segmented-choice/segmentedOption.ts +6 -0
  203. package/src/components/select/Select.vue +18 -0
  204. package/src/components/select/SelectContent.vue +73 -0
  205. package/src/components/select/SelectGroup.vue +21 -0
  206. package/src/components/select/SelectItem.vue +47 -0
  207. package/src/components/select/SelectItemText.vue +12 -0
  208. package/src/components/select/SelectLabel.vue +17 -0
  209. package/src/components/select/SelectScrollDownButton.vue +36 -0
  210. package/src/components/select/SelectScrollUpButton.vue +36 -0
  211. package/src/components/select/SelectSeparator.vue +19 -0
  212. package/src/components/select/SelectTrigger.vue +52 -0
  213. package/src/components/select/SelectValue.vue +12 -0
  214. package/src/components/select/index.ts +11 -0
  215. package/src/components/session/IdleTimer.vue +71 -0
  216. package/src/components/session/SessionDialogs.vue +177 -0
  217. package/src/components/session/index.ts +2 -0
  218. package/src/components/split-button/SplitButton.vue +122 -0
  219. package/src/components/split-button/index.ts +2 -0
  220. package/src/components/split-button/splitButtonItem.ts +7 -0
  221. package/src/components/switch/Switch.vue +60 -0
  222. package/src/components/switch/index.ts +1 -0
  223. package/src/components/table/Table.vue +51 -0
  224. package/src/components/table/TableBody.vue +14 -0
  225. package/src/components/table/TableCaption.vue +17 -0
  226. package/src/components/table/TableCell.vue +22 -0
  227. package/src/components/table/TableEmpty.vue +72 -0
  228. package/src/components/table/TableFooter.vue +17 -0
  229. package/src/components/table/TableHead.vue +22 -0
  230. package/src/components/table/TableHeader.vue +14 -0
  231. package/src/components/table/TableRow.vue +22 -0
  232. package/src/components/table/index.ts +9 -0
  233. package/src/components/tabs/Tabs.vue +173 -0
  234. package/src/components/tabs/index.ts +2 -0
  235. package/src/components/tabs/tabItem.ts +12 -0
  236. package/src/components/textarea/LimitedTextarea.vue +81 -0
  237. package/src/components/textarea/TextLimitCounter.vue +107 -0
  238. package/src/components/textarea/Textarea.vue +42 -0
  239. package/src/components/textarea/index.ts +4 -0
  240. package/src/components/textarea/textLimit.ts +43 -0
  241. package/src/components/time-picker/TimePicker.vue +522 -0
  242. package/src/components/time-picker/index.ts +1 -0
  243. package/src/components/toast/ToastHost.vue +276 -0
  244. package/src/components/toast/index.ts +1 -0
  245. package/src/components/update-notice/UpdateNotice.vue +103 -0
  246. package/src/components/update-notice/index.ts +1 -0
  247. package/src/components/user-menu/UserMenu.vue +154 -0
  248. package/src/components/user-menu/index.ts +1 -0
  249. package/src/index.ts +182 -0
  250. package/src/lib/cn.ts +21 -0
  251. package/src/lib/panelFocus.ts +65 -0
  252. package/src/lib/sessionMonitor.ts +390 -0
  253. package/src/lib/slotContent.ts +17 -0
  254. package/src/lib/updateCheck.ts +133 -0
  255. package/src/styles.css +82 -0
@@ -0,0 +1,88 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * The container a page is made of: a bordered, rounded surface with a header (title, optional
4
+ * description, optional action) over a content region the application fills.
5
+ *
6
+ * Parts: `SectionHeader`, `SectionTitle`, `SectionDescription`, `SectionAction`,
7
+ * `SectionContent`. `SectionHeader` is not in the plan's file list; it is added because without
8
+ * a wrapper nothing could own the header's grid (title, description and action would be loose
9
+ * children of the root), exactly as `CardHeader` owns it for `Card`.
10
+ *
11
+ * Two authorities, each fixing something different:
12
+ *
13
+ * - The approved design record (`docs/design/wave-3-layout.html`, "The containers") fixes WHAT a
14
+ * `Section` is and how its parts are arranged: a card-surface (`var(--card)` /
15
+ * `var(--card-foreground)`), a header with a divider under it, an accent bar on the header's
16
+ * left edge, the action at the header's right, and a content region the Section draws nothing
17
+ * in. It is a schematic at reduced scale (12.5px headings, 11.5px sub-lines, 13px padding,
18
+ * 10px radius), so none of its figures is used here.
19
+ * - `Card` fixes HOW BIG: `rounded-xl`, `text-sm`, `gap-4`, `p-4`/`px-4` on the parts, the
20
+ * title's `font-heading text-base leading-snug font-medium`, the description's
21
+ * `text-muted-foreground text-sm`. `Section` carries `bg-card text-card-foreground`, which the
22
+ * record and `Card` agree on.
23
+ *
24
+ * The header's grid is a deliberate copy of `CardHeader`'s: `has-data-[slot=…]` switches reserve
25
+ * the action column and the second row only when an action or description is present. Sharing
26
+ * `CardHeader` would couple two families through a private part, so the class string is
27
+ * repeated, with the container renamed (`section-header`) so the two never answer one query.
28
+ *
29
+ * `accent` is an open string, never a union. A fixed list would bake one theme's vocabulary
30
+ * into a package whose premise is interchangeable themes. The component only puts the name on a
31
+ * `data-brix-accent` attribute of its root and reads no colour itself. The value is trimmed, and an
32
+ * empty or whitespace-only name counts as no accent, so a bound value that arrives as blanks
33
+ * does not turn a bar on.
34
+ *
35
+ * WHAT AN ACCENT REBINDS IS FAR MORE THAN A BAR. A theme's accent set (`[data-brix-accent='…']` in
36
+ * `kingfisher.css`) rebinds the brand tokens for the whole subtree: `--primary`, `--ring`,
37
+ * `--primary-on-wash`, `--accent-base`, `--accent-tint` and `--accent-head-ink` (the last is
38
+ * dormant: no utility reads it yet). `Button` fills `bg-primary` and everything in the
39
+ * package focuses with `ring-ring`, so every primary button and every focus ring inside an
40
+ * accented section takes the accent's colour, not only the bar. This is the first component in
41
+ * the package to set `data-brix-accent`, so it introduces that capability. (`teal` matches the theme's own brand for `--primary`,
42
+ * `--ring` and `--accent-base`, so no button or ring changes under it, while the tint does
43
+ * move: `#e7efef` against `#eef2f2`.)
44
+ *
45
+ * The bar is drawn with `--accent-base` and exists only when `accent` is set and non-empty. It is
46
+ * bound to the header's DIRECT parent AND requires that parent to be a section root
47
+ * (`[data-slot=section][data-brix-accent]`), so an unaccented section nested inside an accented one
48
+ * draws none, and a header placed directly under an application's own `data-brix-accent` wrapper
49
+ * draws none. The cost to a caller: `SectionHeader` must be a direct child of `Section`, or the
50
+ * accent bar does not draw. `--accent-base` has a theme-level binding (`var(--brand)`) in all
51
+ * three themes, so an accented section draws a brand-coloured bar under every theme. What only
52
+ * kingfisher ships is accent SETS, which rebind per name: an accent name changes the colours
53
+ * only under kingfisher, while under graphite and noix every name draws the same brand-coloured
54
+ * bar (`packages/tokens/src/index.css` documents the role). That is the honest outcome of the
55
+ * mechanism, not a defect to work around. The accent rules the spec writes under the navigation
56
+ * family (`NavSection`) are applied here by this plan's reading, not by quotation.
57
+ *
58
+ * The root pads `py-4` like Card, except that the top padding is dropped when a direct-child
59
+ * `section-header` is present, because the header's own `p-4` supplies it. A section without a
60
+ * header therefore keeps its `pt-4` and the content does not sit against the top border.
61
+ *
62
+ * `data-slot="section"` is deliberate. `form-section`, `page-head`, `page-identity`,
63
+ * `status-band`, `record-fields` and `collab-block` stay the application's markup (wave 2), and a
64
+ * container claiming one would change the density axis of every consuming page.
65
+ */
66
+ import type { HTMLAttributes } from 'vue';
67
+ import { cn } from '../../lib/cn';
68
+
69
+ const props = defineProps<{
70
+ class?: HTMLAttributes['class'];
71
+ accent?: string;
72
+ }>();
73
+ </script>
74
+
75
+ <template>
76
+ <div
77
+ data-slot="section"
78
+ :data-brix-accent="props.accent?.trim() || undefined"
79
+ :class="
80
+ cn(
81
+ 'border-border bg-card text-card-foreground flex flex-col gap-4 overflow-hidden rounded-xl border py-4 text-sm has-[>[data-slot=section-header]]:pt-0',
82
+ props.class,
83
+ )
84
+ "
85
+ >
86
+ <slot />
87
+ </div>
88
+ </template>
@@ -0,0 +1,17 @@
1
+ <script setup lang="ts">
2
+ import type { HTMLAttributes } from 'vue';
3
+ import { cn } from '../../lib/cn';
4
+
5
+ const props = defineProps<{
6
+ class?: HTMLAttributes['class'];
7
+ }>();
8
+ </script>
9
+
10
+ <template>
11
+ <div
12
+ data-slot="section-action"
13
+ :class="cn('col-start-2 row-span-2 row-start-1 self-start justify-self-end', props.class)"
14
+ >
15
+ <slot />
16
+ </div>
17
+ </template>
@@ -0,0 +1,14 @@
1
+ <script setup lang="ts">
2
+ import type { HTMLAttributes } from 'vue';
3
+ import { cn } from '../../lib/cn';
4
+
5
+ const props = defineProps<{
6
+ class?: HTMLAttributes['class'];
7
+ }>();
8
+ </script>
9
+
10
+ <template>
11
+ <div data-slot="section-content" :class="cn('px-4', props.class)">
12
+ <slot />
13
+ </div>
14
+ </template>
@@ -0,0 +1,14 @@
1
+ <script setup lang="ts">
2
+ import type { HTMLAttributes } from 'vue';
3
+ import { cn } from '../../lib/cn';
4
+
5
+ const props = defineProps<{
6
+ class?: HTMLAttributes['class'];
7
+ }>();
8
+ </script>
9
+
10
+ <template>
11
+ <div data-slot="section-description" :class="cn('text-muted-foreground text-sm', props.class)">
12
+ <slot />
13
+ </div>
14
+ </template>
@@ -0,0 +1,22 @@
1
+ <script setup lang="ts">
2
+ import type { HTMLAttributes } from 'vue';
3
+ import { cn } from '../../lib/cn';
4
+
5
+ const props = defineProps<{
6
+ class?: HTMLAttributes['class'];
7
+ }>();
8
+ </script>
9
+
10
+ <template>
11
+ <div
12
+ data-slot="section-header"
13
+ :class="
14
+ cn(
15
+ 'border-border gap-1 border-b p-4 relative grid auto-rows-min items-start has-data-[slot=section-action]:grid-cols-[1fr_auto] has-data-[slot=section-description]:grid-rows-[auto_auto] [[data-slot=section][data-brix-accent]>&]:before:bg-accent-base [[data-slot=section][data-brix-accent]>&]:before:absolute [[data-slot=section][data-brix-accent]>&]:before:inset-y-0 [[data-slot=section][data-brix-accent]>&]:before:left-0 [[data-slot=section][data-brix-accent]>&]:before:w-[3px]',
16
+ props.class,
17
+ )
18
+ "
19
+ >
20
+ <slot />
21
+ </div>
22
+ </template>
@@ -0,0 +1,17 @@
1
+ <script setup lang="ts">
2
+ import type { HTMLAttributes } from 'vue';
3
+ import { cn } from '../../lib/cn';
4
+
5
+ const props = defineProps<{
6
+ class?: HTMLAttributes['class'];
7
+ }>();
8
+ </script>
9
+
10
+ <template>
11
+ <div
12
+ data-slot="section-title"
13
+ :class="cn('font-heading text-base leading-snug font-medium', props.class)"
14
+ >
15
+ <slot />
16
+ </div>
17
+ </template>
@@ -0,0 +1,9 @@
1
+ // The containers family. Each container is exported here by name; add the next one as one more
2
+ // `export { default as X } from './X.vue';` line, keeping the list alphabetical.
3
+ export { default as Box } from './Box.vue';
4
+ export { default as Section } from './Section.vue';
5
+ export { default as SectionAction } from './SectionAction.vue';
6
+ export { default as SectionContent } from './SectionContent.vue';
7
+ export { default as SectionDescription } from './SectionDescription.vue';
8
+ export { default as SectionHeader } from './SectionHeader.vue';
9
+ export { default as SectionTitle } from './SectionTitle.vue';
@@ -0,0 +1,241 @@
1
+ <script setup lang="ts">
2
+ import { formatLabel, useUiLabels } from '@noix-dev/brix-core';
3
+ import { computed, ref, useId, watch } from 'vue';
4
+ import { cn } from '../../lib/cn';
5
+ import { movePanelFocus } from '../../lib/panelFocus';
6
+ import { buttonVariants } from '../button';
7
+ import { Checkbox } from '../checkbox';
8
+ import { ChevronDownIcon, Columns3Icon, SearchIcon } from '../icon';
9
+ import { PopoverPanel } from '../popover-panel';
10
+ import type { DataTableColumn } from './types';
11
+
12
+ /**
13
+ * The control that hides and shows a table's columns: a trigger, and a panel of checkboxes
14
+ * with a search field, a show-all and a reset.
15
+ *
16
+ * THE PANEL is the `PopoverPanel` shell, named by its trigger (so the trigger's text, the
17
+ * contract's `tableColumns`, is the panel's name). The shell supplies dismissal on an outside
18
+ * press, Escape with focus back on the trigger, and the portal; it supplies no focus trap, so
19
+ * Tab here closes the panel rather than leave focus in a portal at the end of the document.
20
+ * Focus goes to the search field when the panel opens.
21
+ *
22
+ * THE ARROWS ARE WHAT PAY FOR THAT TAB-CLOSE. Tab fires for Shift+Tab too, so both directions
23
+ * dismiss, which leaves ArrowDown and ArrowUp as the only keys that reach a checkbox, show-all
24
+ * or reset from the search field. `movePanelFocus` is shared with `FilterCheckMenu`, which
25
+ * takes the same bargain, and carries the reason it wraps.
26
+ *
27
+ * ALWAYS-VISIBLE columns are never offered for toggling, and a column that is the last visible
28
+ * toggleable one cannot be unchecked, so the table never ends up with nothing to show through
29
+ * this control. The reason is on the row twice: as a tooltip, and as text a reader who never
30
+ * hovers can reach (`aria-describedby`).
31
+ *
32
+ * WORDING comes from the label contract: `tableColumns`, `tableColumnsShowAll`,
33
+ * `tableColumnsKeepOne`, `tableColumnHiddenByDefault`, `tableColumnOff`, plus the shared
34
+ * `search`, `searchIn`, `noMatches` and `reset`.
35
+ *
36
+ * THE GLYPHS are slots (ADR 0013): `columns-icon` and `chevron-icon` on the trigger, and
37
+ * `search-icon` in the panel.
38
+ */
39
+ const props = defineProps<{
40
+ columns: DataTableColumn[];
41
+ visibleKeys: string[];
42
+ }>();
43
+
44
+ const emit = defineEmits<{
45
+ (e: 'update:visibleKeys', keys: string[]): void;
46
+ (e: 'reset'): void;
47
+ }>();
48
+
49
+ defineSlots<{
50
+ /** The trigger's leading glyph. Defaults to three columns in a box. */
51
+ 'columns-icon'?: () => unknown;
52
+ /** The trigger's trailing glyph. Defaults to a chevron pointing down. */
53
+ 'chevron-icon'?: () => unknown;
54
+ /** The search field's glyph. Defaults to a magnifier. */
55
+ 'search-icon'?: () => unknown;
56
+ }>();
57
+
58
+ const labels = useUiLabels();
59
+ const hintId = useId();
60
+
61
+ const open = ref(false);
62
+ const term = ref('');
63
+ const panelEl = ref<HTMLElement | null>(null);
64
+ const searchEl = ref<HTMLInputElement | null>(null);
65
+
66
+ // Always-visible columns (e.g. the actions column) are never offered for toggling.
67
+ const toggleable = computed(() => props.columns.filter((c) => !c.alwaysVisible));
68
+ const visibleSet = computed(() => new Set(props.visibleKeys));
69
+ const visibleToggleableCount = computed(
70
+ () => toggleable.value.filter((c) => visibleSet.value.has(c.key)).length,
71
+ );
72
+
73
+ const filtered = computed(() => {
74
+ const needle = term.value.trim().toLowerCase();
75
+ if (needle === '') {
76
+ return toggleable.value;
77
+ }
78
+ return toggleable.value.filter((c) => c.label.toLowerCase().includes(needle));
79
+ });
80
+
81
+ function isChecked(column: DataTableColumn): boolean {
82
+ return visibleSet.value.has(column.key);
83
+ }
84
+
85
+ // The last visible toggleable column stays checked so the table never ends up empty.
86
+ function isLocked(column: DataTableColumn): boolean {
87
+ return isChecked(column) && visibleToggleableCount.value <= 1;
88
+ }
89
+
90
+ // Keys are emitted in column-definition order; always-visible keys already present are kept.
91
+ function emitKeys(isOn: (column: DataTableColumn) => boolean): void {
92
+ emit(
93
+ 'update:visibleKeys',
94
+ props.columns.filter((c) => isOn(c)).map((c) => c.key),
95
+ );
96
+ }
97
+
98
+ function toggle(column: DataTableColumn, checked: boolean): void {
99
+ if (!checked && isLocked(column)) {
100
+ return;
101
+ }
102
+ emitKeys((c) => (c.key === column.key ? checked : visibleSet.value.has(c.key)));
103
+ }
104
+
105
+ function showAll(): void {
106
+ emitKeys((c) => (c.alwaysVisible ? visibleSet.value.has(c.key) : true));
107
+ }
108
+
109
+ // The query belongs to one opening, not to the menu: reopened on a stale query it would show a
110
+ // few columns and no sign of why.
111
+ watch(open, (isOpen) => {
112
+ if (!isOpen) {
113
+ term.value = '';
114
+ }
115
+ });
116
+
117
+ // The shell would focus the panel's first tabbable element, which is the search field only by
118
+ // the accident of its position. Say so.
119
+ function onOpenAutoFocus(event: Event): void {
120
+ event.preventDefault();
121
+ searchEl.value?.focus();
122
+ }
123
+
124
+ // In DOM order, so the arrows walk the panel top to bottom: search, checkboxes, show-all, reset.
125
+ function moveFocus(delta: number): void {
126
+ movePanelFocus(panelEl.value, delta);
127
+ }
128
+ </script>
129
+
130
+ <template>
131
+ <PopoverPanel v-model:open="open" @open-auto-focus="onOpenAutoFocus">
132
+ <template #trigger>
133
+ <button
134
+ type="button"
135
+ data-testid="column-menu-trigger"
136
+ :class="cn(buttonVariants({ variant: 'outline', size: 'sm' }))"
137
+ >
138
+ <slot name="columns-icon"><Columns3Icon /></slot>
139
+ <span>{{ labels.tableColumns }}</span>
140
+ <slot name="chevron-icon"><ChevronDownIcon class="text-muted-foreground" /></slot>
141
+ </button>
142
+ </template>
143
+
144
+ <template #panel>
145
+ <div
146
+ ref="panelEl"
147
+ data-testid="column-menu-panel"
148
+ class="w-64 max-w-full"
149
+ @keydown.down.prevent="moveFocus(1)"
150
+ @keydown.up.prevent="moveFocus(-1)"
151
+ @keydown.tab="open = false"
152
+ >
153
+ <!-- The field's own focus indication, on the wrapper because the input draws no
154
+ edge of its own: `focus-within:`, inset, as `IconPicker`'s search field has
155
+ it. Inset for the recipe's third reason — the panel is `overflow-y-auto`, and
156
+ a scrolling axis clips the other one too, so the 4px an outset ring and its
157
+ gap need are not there. `--ring` over `--popover` measures 9.34 12.11 9.65
158
+ 6.46 3.28 7.51 in the six theme/mode pairs, every one over 3:1. -->
159
+ <div
160
+ class="border-border focus-within:ring-ring -mx-2 -mt-2 flex items-center gap-2 border-b px-2.5 py-1.5 focus-within:ring-2 focus-within:ring-inset"
161
+ >
162
+ <slot name="search-icon"
163
+ ><SearchIcon class="text-muted-foreground size-3.5 shrink-0"
164
+ /></slot>
165
+ <input
166
+ ref="searchEl"
167
+ v-model="term"
168
+ type="text"
169
+ data-testid="column-menu-search"
170
+ :placeholder="labels.search"
171
+ :aria-label="formatLabel(labels.searchIn, { label: labels.tableColumns })"
172
+ class="placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent text-sm outline-none"
173
+ />
174
+ </div>
175
+
176
+ <ul class="max-h-64 overflow-auto pt-1">
177
+ <li v-for="column in filtered" :key="column.key">
178
+ <label
179
+ :title="isLocked(column) ? labels.tableColumnsKeepOne : undefined"
180
+ :class="
181
+ cn(
182
+ 'hover:bg-muted flex cursor-pointer items-center gap-2 rounded px-2 py-1 text-sm',
183
+ isLocked(column) && 'cursor-not-allowed',
184
+ )
185
+ "
186
+ >
187
+ <Checkbox
188
+ class="size-4 rounded"
189
+ :data-testid="`column-menu-option-${column.key}`"
190
+ :aria-describedby="isLocked(column) ? hintId : undefined"
191
+ :model-value="isChecked(column)"
192
+ :disabled="isLocked(column)"
193
+ @update:model-value="(checked) => toggle(column, checked)"
194
+ />
195
+ <span class="min-w-0 flex-1 truncate">{{ column.label }}</span>
196
+ <span
197
+ v-if="column.defaultVisible === false"
198
+ :data-testid="`column-menu-tag-off-${column.key}`"
199
+ :title="labels.tableColumnHiddenByDefault"
200
+ class="bg-muted text-muted-foreground shrink-0 rounded px-1 text-[10px] leading-4 font-medium uppercase"
201
+ >{{ labels.tableColumnOff }}</span
202
+ >
203
+ </label>
204
+ </li>
205
+ <li
206
+ v-if="filtered.length === 0"
207
+ data-testid="column-menu-empty"
208
+ class="text-muted-foreground px-2 py-1.5 text-xs"
209
+ >
210
+ {{ labels.noMatches }}
211
+ </li>
212
+ </ul>
213
+ <!-- The reason a locked row cannot be unchecked, for a reader who never hovers. -->
214
+ <span v-if="visibleToggleableCount <= 1" :id="hintId" class="sr-only">{{
215
+ labels.tableColumnsKeepOne
216
+ }}</span>
217
+
218
+ <div
219
+ class="border-border -mx-2 -mb-2 mt-1 flex items-center justify-between gap-2 border-t px-2.5 py-1.5 text-xs"
220
+ >
221
+ <button
222
+ type="button"
223
+ data-testid="column-menu-show-all"
224
+ class="text-primary-on-wash focus-visible:ring-ring focus-visible:ring-offset-background rounded font-medium outline-none hover:underline focus-visible:ring-2 focus-visible:ring-offset-2"
225
+ @click="showAll"
226
+ >
227
+ {{ labels.tableColumnsShowAll }}
228
+ </button>
229
+ <button
230
+ type="button"
231
+ data-testid="column-menu-reset"
232
+ class="text-muted-foreground hover:text-foreground focus-visible:ring-ring focus-visible:ring-offset-background rounded outline-none hover:underline focus-visible:ring-2 focus-visible:ring-offset-2"
233
+ @click="emit('reset')"
234
+ >
235
+ {{ labels.reset }}
236
+ </button>
237
+ </div>
238
+ </div>
239
+ </template>
240
+ </PopoverPanel>
241
+ </template>