@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,29 @@
1
+ <script setup lang="ts">
2
+ import type { HTMLAttributes } from 'vue';
3
+ import { cn } from '../../lib/cn';
4
+
5
+ const props = withDefaults(
6
+ defineProps<{
7
+ class?: HTMLAttributes['class'];
8
+ size?: 'default' | 'sm';
9
+ }>(),
10
+ {
11
+ size: 'default',
12
+ },
13
+ );
14
+ </script>
15
+
16
+ <template>
17
+ <div
18
+ data-slot="card"
19
+ :data-size="size"
20
+ :class="
21
+ cn(
22
+ 'ring-foreground/10 bg-card text-card-foreground gap-4 overflow-hidden rounded-xl py-4 text-sm ring-1 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl group/card flex flex-col',
23
+ props.class,
24
+ )
25
+ "
26
+ >
27
+ <slot />
28
+ </div>
29
+ </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="card-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="card-content" :class="cn('px-4 group-data-[size=sm]/card:px-3', 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="card-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="card-footer"
13
+ :class="
14
+ cn(
15
+ 'bg-muted/50 rounded-b-xl border-t p-4 group-data-[size=sm]/card:p-3 flex items-center',
16
+ props.class,
17
+ )
18
+ "
19
+ >
20
+ <slot />
21
+ </div>
22
+ </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="card-header"
13
+ :class="
14
+ cn(
15
+ 'gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3 group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]',
16
+ props.class,
17
+ )
18
+ "
19
+ >
20
+ <slot />
21
+ </div>
22
+ </template>
@@ -0,0 +1,29 @@
1
+ <script setup lang="ts">
2
+ import type { HTMLAttributes } from 'vue';
3
+ import type { CardTitleVariants } from '.';
4
+ import { cn } from '../../lib/cn';
5
+ import { cardTitleVariants } from '.';
6
+
7
+ const props = withDefaults(
8
+ defineProps<{
9
+ /**
10
+ * `auto` (the default) lets the card decide, as it always has. Any explicit value
11
+ * takes the decision away from it — see `cardTitleVariants` for why that cannot
12
+ * be done from the outside with a class.
13
+ */
14
+ size?: CardTitleVariants['size'];
15
+ class?: HTMLAttributes['class'];
16
+ }>(),
17
+ { size: 'auto', class: undefined },
18
+ );
19
+ </script>
20
+
21
+ <template>
22
+ <div
23
+ data-slot="card-title"
24
+ :data-size="props.size"
25
+ :class="cn(cardTitleVariants({ size: props.size }), props.class)"
26
+ >
27
+ <slot />
28
+ </div>
29
+ </template>
@@ -0,0 +1,47 @@
1
+ import type { VariantProps } from 'class-variance-authority';
2
+ import { cva } from 'class-variance-authority';
3
+
4
+ export { default as Card } from './Card.vue';
5
+ export { default as CardAction } from './CardAction.vue';
6
+ export { default as CardContent } from './CardContent.vue';
7
+ export { default as CardDescription } from './CardDescription.vue';
8
+ export { default as CardFooter } from './CardFooter.vue';
9
+ export { default as CardHeader } from './CardHeader.vue';
10
+ export { default as CardTitle } from './CardTitle.vue';
11
+
12
+ /**
13
+ * The title's type size, and the one place in the card set where a caller can take the
14
+ * decision away from the card.
15
+ *
16
+ * `auto` is the default and the behaviour every existing card already has: the title is
17
+ * `text-base`, and a `size="sm"` card pulls it down to `text-sm` through the card's own
18
+ * group class. That group class is the reason this variant exists. It compiles to
19
+ * `.group\/card[data-size=sm] .group-data-\[size\=sm\]\/card\:text-sm`, specificity
20
+ * (0,2,0), which outranks a plain `text-3xl` (0,1,0) handed in through `class` — and
21
+ * `tailwind-merge` keeps both, because a bare utility and a variant of it are different
22
+ * keys to it, so `cn` cannot drop the loser. The result was that
23
+ * `<Card size="sm"><CardTitle class="text-3xl">` rendered at 14px with nothing anywhere
24
+ * to say why, which made the commonest dashboard shape — a small card carrying one large
25
+ * figure — impossible to build without `!text-3xl`.
26
+ *
27
+ * So an explicit size does not add a class, it REPLACES the pair: the group class is not
28
+ * emitted at all, and the only size left on the element is the one that was asked for. No
29
+ * specificity contest, nothing to override.
30
+ */
31
+ export const cardTitleVariants = cva('font-heading leading-snug font-medium', {
32
+ variants: {
33
+ size: {
34
+ auto: 'text-base group-data-[size=sm]/card:text-sm',
35
+ xs: 'text-xs',
36
+ sm: 'text-sm',
37
+ base: 'text-base',
38
+ lg: 'text-lg',
39
+ xl: 'text-xl',
40
+ '2xl': 'text-2xl',
41
+ '3xl': 'text-3xl',
42
+ },
43
+ },
44
+ defaultVariants: { size: 'auto' },
45
+ });
46
+
47
+ export type CardTitleVariants = VariantProps<typeof cardTitleVariants>;
@@ -0,0 +1,123 @@
1
+ <script lang="ts">
2
+ import { BarController, BarElement, CategoryScale, Chart, LinearScale, Tooltip } from 'chart.js';
3
+
4
+ // A plain (non-setup) <script> block runs once when the module is first
5
+ // evaluated — true module scope. Registering inside <script setup> instead
6
+ // would compile into the per-instance setup() body and re-run on every mount.
7
+ Chart.register(BarController, BarElement, CategoryScale, LinearScale, Tooltip);
8
+ </script>
9
+
10
+ <script setup lang="ts">
11
+ import type { ChartData, ChartOptions, TooltipItem } from 'chart.js';
12
+ import { computed } from 'vue';
13
+ import { Bar } from 'vue-chartjs';
14
+ import { cn } from '../../lib/cn';
15
+ import { useAppearanceRevision } from './appearanceRevision';
16
+ import { readRoleColor } from './chartColor';
17
+
18
+ /**
19
+ * Known limit: with no document the chart draws nothing, only its wrapper. A server-rendered page
20
+ * will therefore log a hydration mismatch when the client adds the canvas. A consumer who minds
21
+ * should wrap the chart in a client-only boundary. Server rendering is not otherwise supported.
22
+ */
23
+ const props = withDefaults(
24
+ defineProps<{
25
+ labels: string[];
26
+ values: number[];
27
+ /**
28
+ * The colour role the bars take, as the custom property's own name (`--primary`). A
29
+ * role and never a value, so the bars follow the theme; a consumer's theme may declare
30
+ * roles brix does not.
31
+ */
32
+ color?: string;
33
+ /**
34
+ * The opaque role the grid is composited over, since a translucent grid colour has
35
+ * nothing to blend with on a canvas. Name what the chart sits on.
36
+ */
37
+ ground?: string;
38
+ valueSuffix?: string;
39
+ /**
40
+ * The locale the numbers are grouped in. Left out, `Intl.NumberFormat` takes the
41
+ * runtime's own locale — deliberately, and not `'en-US'` or `'de-DE'`: a consumer who
42
+ * supplies a catalogue in their language should not get American digit grouping
43
+ * beside it. A caller who wants a fixed grouping names it here.
44
+ */
45
+ locale?: string;
46
+ class?: string;
47
+ }>(),
48
+ {
49
+ color: '--primary',
50
+ ground: '--card',
51
+ valueSuffix: undefined,
52
+ locale: undefined,
53
+ class: undefined,
54
+ },
55
+ );
56
+
57
+ const numberFormatter = computed(() => new Intl.NumberFormat(props.locale));
58
+ function formatValue(value: number | null): string {
59
+ return numberFormatter.value.format(value ?? 0);
60
+ }
61
+
62
+ /*
63
+ * Chart.js paints a <canvas>, so it can't pick up a role from CSS the way the rest of the
64
+ * package does: each role is read out of the stylesheet and resolved to a hex, and read
65
+ * again whenever the appearance changes. A role that is not declared throws, uncaught.
66
+ */
67
+ // Without a document there is no canvas to paint and nothing to read a role from, so the chart
68
+ // draws nothing; reading roles is left to the client. This is a different condition from a role
69
+ // that no theme declares, which `readRoleColor` still refuses on the client.
70
+ const hasDocument = typeof document !== 'undefined';
71
+ const revision = useAppearanceRevision();
72
+ const colours = computed(() => {
73
+ void revision.value;
74
+ return {
75
+ bar: readRoleColor(props.color, props.ground),
76
+ grid: readRoleColor('--border', props.ground),
77
+ tick: readRoleColor('--muted-foreground', props.ground),
78
+ };
79
+ });
80
+
81
+ const chartData = computed<ChartData<'bar'>>(() => ({
82
+ labels: props.labels,
83
+ datasets: [
84
+ {
85
+ data: props.values,
86
+ backgroundColor: colours.value.bar,
87
+ borderRadius: 5,
88
+ maxBarThickness: 28,
89
+ },
90
+ ],
91
+ }));
92
+
93
+ const chartOptions = computed<ChartOptions<'bar'>>(() => ({
94
+ indexAxis: 'y',
95
+ responsive: true,
96
+ maintainAspectRatio: false,
97
+ plugins: {
98
+ legend: { display: false },
99
+ tooltip: {
100
+ callbacks: {
101
+ label: (ctx: TooltipItem<'bar'>) =>
102
+ formatValue(ctx.parsed.x) + (props.valueSuffix ?? ''),
103
+ },
104
+ },
105
+ },
106
+ scales: {
107
+ x: {
108
+ grid: { color: colours.value.grid },
109
+ ticks: { color: colours.value.tick },
110
+ },
111
+ y: {
112
+ grid: { display: false },
113
+ ticks: { color: colours.value.tick },
114
+ },
115
+ },
116
+ }));
117
+ </script>
118
+
119
+ <template>
120
+ <div :class="cn('h-64 w-full', props.class)">
121
+ <Bar v-if="hasDocument" :data="chartData" :options="chartOptions" />
122
+ </div>
123
+ </template>
@@ -0,0 +1,149 @@
1
+ <script lang="ts">
2
+ import {
3
+ BarController,
4
+ BarElement,
5
+ CategoryScale,
6
+ Chart,
7
+ Legend,
8
+ LinearScale,
9
+ Tooltip,
10
+ } from 'chart.js';
11
+
12
+ // A plain (non-setup) <script> block runs once when the module is first
13
+ // evaluated — true module scope. Registering inside <script setup> instead
14
+ // would compile into the per-instance setup() body and re-run on every mount.
15
+ Chart.register(BarController, BarElement, CategoryScale, LinearScale, Tooltip, Legend);
16
+ </script>
17
+
18
+ <script setup lang="ts">
19
+ import type { ChartData, ChartOptions, TooltipItem } from 'chart.js';
20
+ import { computed } from 'vue';
21
+ import { Bar } from 'vue-chartjs';
22
+ import { cn } from '../../lib/cn';
23
+ import { useAppearanceRevision } from './appearanceRevision';
24
+ import { readRoleColor, SERIES_ROLES } from './chartColor';
25
+
26
+ interface StackDataset {
27
+ label: string;
28
+ values: number[];
29
+ /**
30
+ * The colour role this series takes, as the custom property's own name. Left out, the
31
+ * series takes the palette role at its own position: `--series-1` for the first, up to
32
+ * `--series-5`. A role and never a value.
33
+ */
34
+ color?: string;
35
+ }
36
+
37
+ /**
38
+ * Known limit: with no document the chart draws nothing, only its wrapper. A server-rendered page
39
+ * will therefore log a hydration mismatch when the client adds the canvas. A consumer who minds
40
+ * should wrap the chart in a client-only boundary. Server rendering is not otherwise supported.
41
+ */
42
+ const props = withDefaults(
43
+ defineProps<{
44
+ labels: string[];
45
+ datasets: StackDataset[];
46
+ /** The opaque role the grid is composited over: name what the chart sits on. */
47
+ ground?: string;
48
+ valueSuffix?: string;
49
+ /**
50
+ * The locale the numbers are grouped in. Left out, `Intl.NumberFormat` takes the
51
+ * runtime's own locale, as in the other numeric families.
52
+ */
53
+ locale?: string;
54
+ class?: string;
55
+ }>(),
56
+ { ground: '--card', valueSuffix: undefined, locale: undefined, class: undefined },
57
+ );
58
+
59
+ const numberFormatter = computed(() => new Intl.NumberFormat(props.locale));
60
+ function formatValue(value: number | null): string {
61
+ return numberFormatter.value.format(value ?? 0);
62
+ }
63
+
64
+ /**
65
+ * The role a series paints with. A series past the palette's last role has no default, and
66
+ * wrapping round would give two series one colour in silence, so it must name its own.
67
+ */
68
+ function seriesRole(dataset: StackDataset, index: number): string {
69
+ const role = dataset.color ?? SERIES_ROLES[index];
70
+ if (role === undefined) {
71
+ throw new Error(
72
+ `cannot paint a chart: series ${index + 1} names no colour and the palette has ` +
73
+ `${SERIES_ROLES.length} roles (${SERIES_ROLES[0]} to ${SERIES_ROLES.at(-1)}); ` +
74
+ 'give it a role in its color',
75
+ );
76
+ }
77
+ return role;
78
+ }
79
+
80
+ /*
81
+ * Chart.js paints a <canvas>, so it can't pick up a role from CSS the way the rest of the
82
+ * package does: each role is read out of the stylesheet and resolved to a hex, and read
83
+ * again whenever the appearance changes. A role that is not declared throws, uncaught.
84
+ */
85
+ // Without a document there is no canvas to paint and nothing to read a role from, so the chart
86
+ // draws nothing; reading roles is left to the client. This is a different condition from a role
87
+ // that no theme declares, which `readRoleColor` still refuses on the client.
88
+ const hasDocument = typeof document !== 'undefined';
89
+ const revision = useAppearanceRevision();
90
+ const colours = computed(() => {
91
+ void revision.value;
92
+ return {
93
+ series: props.datasets.map((dataset, index) =>
94
+ readRoleColor(seriesRole(dataset, index), props.ground),
95
+ ),
96
+ grid: readRoleColor('--border', props.ground),
97
+ tick: readRoleColor('--muted-foreground', props.ground),
98
+ };
99
+ });
100
+
101
+ const chartData = computed<ChartData<'bar'>>(() => ({
102
+ labels: props.labels,
103
+ datasets: props.datasets.map((dataset, index) => ({
104
+ label: dataset.label,
105
+ data: dataset.values,
106
+ backgroundColor: colours.value.series[index],
107
+ borderRadius: 4,
108
+ maxBarThickness: 26,
109
+ stack: 'stack',
110
+ })),
111
+ }));
112
+
113
+ const chartOptions = computed<ChartOptions<'bar'>>(() => ({
114
+ responsive: true,
115
+ maintainAspectRatio: false,
116
+ plugins: {
117
+ legend: {
118
+ display: true,
119
+ position: 'bottom',
120
+ labels: { color: colours.value.tick, boxWidth: 12, boxHeight: 12 },
121
+ },
122
+ tooltip: {
123
+ callbacks: {
124
+ label: (ctx: TooltipItem<'bar'>) =>
125
+ `${ctx.dataset.label}: ${formatValue(ctx.parsed.y)}${props.valueSuffix ?? ''}`,
126
+ },
127
+ },
128
+ },
129
+ scales: {
130
+ x: {
131
+ stacked: true,
132
+ grid: { display: false },
133
+ ticks: { color: colours.value.tick },
134
+ },
135
+ y: {
136
+ stacked: true,
137
+ beginAtZero: true,
138
+ grid: { color: colours.value.grid },
139
+ ticks: { color: colours.value.tick, precision: 0 },
140
+ },
141
+ },
142
+ }));
143
+ </script>
144
+
145
+ <template>
146
+ <div :class="cn('h-64 w-full', props.class)">
147
+ <Bar v-if="hasDocument" :data="chartData" :options="chartOptions" />
148
+ </div>
149
+ </template>
@@ -0,0 +1,22 @@
1
+ import { subscribeAppearance } from '@noix-dev/brix-core';
2
+ import { onBeforeUnmount, onMounted, ref, type Ref } from 'vue';
3
+
4
+ /**
5
+ * A counter that goes up whenever the appearance changes, for a computed to read so that it
6
+ * is evaluated again. Colours read for a canvas are not reactive, so nothing else would tell
7
+ * the chart that the theme moved.
8
+ *
9
+ * It follows `subscribeAppearance` and not the document, as that module's own documentation
10
+ * asks. The limit is the module's too: a host that writes `data-brix-theme` itself notifies nobody.
11
+ */
12
+ export function useAppearanceRevision(): Ref<number> {
13
+ const revision = ref(0);
14
+ let stop: (() => void) | undefined;
15
+ onMounted(() => {
16
+ stop = subscribeAppearance(() => {
17
+ revision.value += 1;
18
+ });
19
+ });
20
+ onBeforeUnmount(() => stop?.());
21
+ return revision;
22
+ }
@@ -0,0 +1,59 @@
1
+ import { canvasColor } from '@noix-dev/brix-tokens/canvasColor';
2
+
3
+ /**
4
+ * The five categorical series roles, in the order a multi-series chart takes them. The token
5
+ * contract declares and gates exactly these (contrast against the card, distance under three
6
+ * simulated dichromacies), so a sixth series has no role to default to.
7
+ */
8
+ export const SERIES_ROLES = [
9
+ '--series-1',
10
+ '--series-2',
11
+ '--series-3',
12
+ '--series-4',
13
+ '--series-5',
14
+ ] as const;
15
+
16
+ /**
17
+ * A custom property's value, read off `root` as the string the stylesheet declared.
18
+ * `getComputedStyle` answers an empty string for a property nothing declares.
19
+ */
20
+ function declaredValue(variable: string, root: Element): string {
21
+ return getComputedStyle(root).getPropertyValue(variable).trim();
22
+ }
23
+
24
+ /**
25
+ * The colour a chart's `<canvas>` paints with, for the role `variable` names.
26
+ *
27
+ * A canvas cannot take a colour from CSS, so the role is read out of the stylesheet and
28
+ * handed over as a string, and most of this repository's roles are declared in `oklch`,
29
+ * which chart.js cannot parse (it answers `undefined`, throws nothing, and the canvas keeps
30
+ * its previous fill). `canvasColor` is the step that turns the declared value into a hex;
31
+ * `ground` names the opaque role a translucent colour is composited over, because a canvas
32
+ * has no backdrop to blend with.
33
+ *
34
+ * It refuses, and does not fall back. A role is authored, not runtime data, so an empty
35
+ * value means no theme declares it, or the stylesheet has not applied yet. Either is the
36
+ * same failure on every render, which is better seen on the first one than painted over
37
+ * with a guess that looks plausible.
38
+ */
39
+ export function readRoleColor(
40
+ variable: string,
41
+ ground: string,
42
+ root: Element = document.documentElement,
43
+ ): string {
44
+ const declared = declaredValue(variable, root);
45
+ if (declared === '') {
46
+ throw new Error(
47
+ `cannot paint a chart: ${variable} is empty, so no active theme declares it ` +
48
+ 'or the stylesheet has not applied yet',
49
+ );
50
+ }
51
+ const groundValue = declaredValue(ground, root);
52
+ if (groundValue === '') {
53
+ throw new Error(
54
+ `cannot paint a chart: its ground ${ground} is empty, so no active theme declares it ` +
55
+ 'or the stylesheet has not applied yet',
56
+ );
57
+ }
58
+ return canvasColor(declared, groundValue);
59
+ }
@@ -0,0 +1,6 @@
1
+ export { default as BarChart } from './BarChart.vue';
2
+ export { default as StackedBarChart } from './StackedBarChart.vue';
3
+ // The five categorical series roles leave through this door too. A consumer drawing a legend
4
+ // swatch beside the canvas, or colouring anything to match a series, otherwise retypes the five
5
+ // names one package out — the drift that ruling 23 built a gate against inside this package.
6
+ export { SERIES_ROLES } from './chartColor';
@@ -0,0 +1,61 @@
1
+ <script setup lang="ts">
2
+ import { CheckboxIndicator, CheckboxRoot } from 'reka-ui';
3
+ import type { HTMLAttributes } from 'vue';
4
+ import { cn } from '../../lib/cn';
5
+ import { CheckIcon } from '../icon';
6
+
7
+ const props = defineProps<{
8
+ // 'indeterminate' is display-only: the box reports `aria-checked="mixed"`, and a click
9
+ // still emits a plain boolean for the caller to interpret.
10
+ modelValue: boolean | 'indeterminate';
11
+ disabled?: boolean;
12
+ id?: string;
13
+ class?: HTMLAttributes['class'];
14
+ }>();
15
+ const emits = defineEmits<{ (e: 'update:modelValue', value: boolean): void }>();
16
+
17
+ defineSlots<{
18
+ /** The tick drawn when the box is checked. Defaults to the package's own glyph. */
19
+ check?: () => unknown;
20
+ /** The dash drawn when the box is indeterminate. Defaults to a plain dash. */
21
+ indeterminate?: () => unknown;
22
+ }>();
23
+ </script>
24
+
25
+ <template>
26
+ <CheckboxRoot
27
+ :id="id"
28
+ :model-value="modelValue"
29
+ :disabled="disabled"
30
+ :class="
31
+ cn(
32
+ 'flex h-5 w-5 shrink-0 items-center justify-center rounded-md border border-muted-foreground transition',
33
+ 'data-[state=checked]:border-primary data-[state=checked]:bg-primary',
34
+ 'data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary',
35
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',
36
+ 'disabled:cursor-not-allowed disabled:opacity-50',
37
+ props.class,
38
+ )
39
+ "
40
+ @update:model-value="(v) => emits('update:modelValue', v === true)"
41
+ >
42
+ <CheckboxIndicator class="text-primary-foreground">
43
+ <slot v-if="modelValue === 'indeterminate'" name="indeterminate">
44
+ <svg
45
+ class="h-3.5 w-3.5"
46
+ viewBox="0 0 24 24"
47
+ fill="none"
48
+ stroke="currentColor"
49
+ stroke-width="3"
50
+ aria-hidden="true"
51
+ focusable="false"
52
+ >
53
+ <path stroke-linecap="round" stroke-linejoin="round" d="M6 12h12" />
54
+ </svg>
55
+ </slot>
56
+ <slot v-else name="check">
57
+ <CheckIcon class="h-3.5 w-3.5" stroke-width="3" />
58
+ </slot>
59
+ </CheckboxIndicator>
60
+ </CheckboxRoot>
61
+ </template>
@@ -0,0 +1 @@
1
+ export { default as Checkbox } from './Checkbox.vue';