@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,16 @@
1
+ export { default as ImageCropDialog } from './ImageCropDialog.vue';
2
+ export type { ImageCropDialogLabels } from './ImageCropDialog.vue';
3
+ // The crop types beside the component that takes them, as the spec asks: a caller who already
4
+ // imports the dialog should not have to reach into a second package to type the `variants` it is
5
+ // given and the `crops` it hands back. TYPES ONLY, and the geometry stays in `@noix-dev/brix-core`: a
6
+ // type is erased at build time, while a function imported through this door would drag `cropperjs`
7
+ // into a consumer that renders no cropper — which is the reason the door exists. It opens no new
8
+ // one either, so ADR 0014's list is still eight.
9
+ export type {
10
+ CropRatio,
11
+ CropRect,
12
+ CropResult,
13
+ CropSelection,
14
+ CropVariant,
15
+ Quarter,
16
+ } from '@noix-dev/brix-core';
@@ -0,0 +1,345 @@
1
+ <script setup lang="ts">
2
+ import { useUiLabels, type CropResult, type CropVariant } from '@noix-dev/brix-core';
3
+ import { computed, onBeforeUnmount, ref } from 'vue';
4
+ import { Button } from '../button';
5
+ import { FilePreview } from '../file-preview';
6
+ import { FileUpload } from '../file-upload';
7
+ import { ImageCropDialog, type ImageCropDialogLabels } from '../image-crop-dialog';
8
+
9
+ /**
10
+ * Pick an image or a PDF, crop it, and hand both the crop and the original on: a dropzone
11
+ * while there is no file, and a thumbnail with "adjust crop" and "remove" once there is one.
12
+ * Controlled: it keeps no file of its own, so `hasFile`, `previewUrl` and `recropUrl` say what
13
+ * is stored, and `select`, `recrop`, `remove` and `error` say what the user did.
14
+ *
15
+ * **THE DOOR.** It statically imports the crop dialog, which carries `cropperjs`, an optional
16
+ * peer, so it is behind a subpath too (ADR 0014, amended): import it from
17
+ * `@noix-dev/brix-vue/image-upload`, and install `cropperjs` (`^2.3.1`) beside it.
18
+ *
19
+ * FLOW. A picked image opens the dialog on an object URL this component creates and revokes.
20
+ * A PDF goes through `convertPdf` first (the consumer owns the rendering) and the converted
21
+ * image is what is cropped and handed on as `original`. A re-crop opens the dialog on
22
+ * `recropUrl`, which belongs to the caller and is never revoked, and emits `recrop` with the
23
+ * cropped file only. `disabled`, `busy` and a running conversion block every action.
24
+ *
25
+ * ROUND. `round` is about the picture, not about the crop: it makes the dropzone and the
26
+ * preview circular and leaves `aspectRatio` and the file the dialog produces exactly as they
27
+ * were. An avatar is cropped to whatever ratio the caller says and merely shown round.
28
+ *
29
+ * CROP VARIANTS. `variants` is forwarded to the dialog as it was given, and nothing here reads
30
+ * it: one picked picture, one dialog, one file per named shape (`ImageCropDialog` holds the
31
+ * geometry, the strip and the wording). What comes back out is `crops` on `select` and on
32
+ * `recrop`, beside the file this component has always emitted — and that file is the FIRST
33
+ * variant's, because the first variant is the primary one. A consumer who reads `cropped` alone
34
+ * therefore keeps working against a set, and stores the primary shape's crop where it used to
35
+ * store the single one: the same slot, cut to the first variant's rectangle rather than to
36
+ * `aspectRatio`, which `variants` supersedes. The key is **absent** from the payload, rather than
37
+ * present and undefined, whenever the dialog sent no list: a dialog with no variants, and a
38
+ * variants dialog whose picture never loaded, both emit one argument, so `variants` being set
39
+ * decides nothing about the payload and `'crops' in payload` is the question to ask.
40
+ *
41
+ * WORDING. Everything comes from the labels contract (`uploadDropzone`, `uploadHint`,
42
+ * `uploadRecrop`, `uploadRemove`, `uploadConverting`, `uploadConvertError`,
43
+ * `uploadPreviewPending`, and the dialog's own `crop*` strings). `labels` overrides member by
44
+ * member and whatever it omits keeps the contract's wording; `label` and `hint` are the two
45
+ * dropzone lines, and an explicit `hint` of `''` hides the helper line.
46
+ *
47
+ * ICONS. This component renders no glyph of its own, so it has no icon slot (ADR 0013): the
48
+ * dropzone's two and the crop dialog's eight belong to `FileUpload` and `ImageCropDialog`, which
49
+ * each carry their own slot with the drawn glyph as its default. A consumer who needs one of
50
+ * them replaced asks for it here, and adding a slot later is additive where removing one is not.
51
+ *
52
+ * COLOUR. Every colour is a role, and nothing here is a swatch. The two actions are `Button`
53
+ * in its outline variant, which owns their ground, edge, ink, hover and focus ring, and the
54
+ * converting line is `--muted-foreground`, the ink every caption uses. The source drew the
55
+ * buttons by hand with eight fixed-palette utilities each (a white ground, a grey ink, a grey
56
+ * ring, a dark-mode variant of each) and the line with two: eighteen sites, of which sixteen
57
+ * left with the two hand-drawn buttons and two became `--muted-foreground`.
58
+ */
59
+
60
+ /** Every string of the upload chain; an omitted member keeps the labels contract's wording. */
61
+ export interface ImageUploadLabels {
62
+ /** Helper line under the dropzone label. */
63
+ hint: string;
64
+ recrop: string;
65
+ remove: string;
66
+ converting: string;
67
+ /** Fallback when `convertPdf` rejects with something that is not an `Error`. */
68
+ convertError: string;
69
+ /** Dropzone headline. */
70
+ fileLabel: string;
71
+ /** Placeholder shown while the thumbnail is still being generated. */
72
+ previewLabel: string;
73
+ cropTitle: string;
74
+ cropClose: string;
75
+ zoomIn: string;
76
+ zoomOut: string;
77
+ rotateLeft: string;
78
+ rotateRight: string;
79
+ flip: string;
80
+ cropReset: string;
81
+ cropCancel: string;
82
+ cropProcessing: string;
83
+ cropApply: string;
84
+ /** Shown instead of the crop stage when the source image cannot be loaded. */
85
+ cropLoadError: string;
86
+ cropLoadErrorHint: string;
87
+ /**
88
+ * The crop variants, for an upload that was given `variants`: the strip's heading and the
89
+ * marker on a shape nobody has framed, the ratio row's heading and its chip for a shape that
90
+ * allows exactly one, and the footer's count, its sentence naming the shapes that are not set,
91
+ * and its apply button for a set of more than one. They carry through to the dialog like every
92
+ * other string here — a consumer who reaches the crop through this component can override all
93
+ * of it, or none of it, in one place.
94
+ */
95
+ cropVariants: string;
96
+ cropVariantAuto: string;
97
+ cropAspectRatio: string;
98
+ cropRatioOnly: string;
99
+ cropRatioFree: string;
100
+ cropVariantsStatus: string;
101
+ cropVariantsPending: string;
102
+ cropApplyAll: string;
103
+ }
104
+
105
+ const props = withDefaults(
106
+ defineProps<{
107
+ previewUrl: string | null;
108
+ recropUrl: string | null;
109
+ hasFile: boolean;
110
+ aspectRatio?: number;
111
+ accept?: string;
112
+ disabled?: boolean;
113
+ busy?: boolean;
114
+ /** Circular avatar-style preview and dropzone. The crop itself is unaffected: `aspectRatio` still drives it. */
115
+ round?: boolean;
116
+ /** Dropzone headline. When set it wins over `labels.fileLabel`. */
117
+ label?: string;
118
+ /** Dropzone helper line; `''` hides it. When set it wins over `labels.hint`. */
119
+ hint?: string;
120
+ /** Overrides the contract's wording member by member. */
121
+ labels?: Partial<ImageUploadLabels>;
122
+ /** The cropped file's format: JPEG for photos and scans, PNG where transparency matters (logos). */
123
+ outputType?: 'image/jpeg' | 'image/png';
124
+ /** Turns a picked PDF into an image; the consumer owns the rendering. */
125
+ convertPdf: (file: File) => Promise<File>;
126
+ /**
127
+ * Named crop shapes cut from the one photograph, handed to the dialog as given. `select` and
128
+ * `recrop` then carry the dialog's `crops` beside `cropped`, which is the first variant's file.
129
+ */
130
+ variants?: CropVariant[];
131
+ }>(),
132
+ {
133
+ accept: 'image/jpeg,image/png,application/pdf',
134
+ round: false,
135
+ outputType: 'image/jpeg',
136
+ },
137
+ );
138
+
139
+ const contract = useUiLabels();
140
+ const text = computed(() => ({
141
+ recrop: props.labels?.recrop ?? contract.value.uploadRecrop,
142
+ remove: props.labels?.remove ?? contract.value.uploadRemove,
143
+ converting: props.labels?.converting ?? contract.value.uploadConverting,
144
+ convertError: props.labels?.convertError ?? contract.value.uploadConvertError,
145
+ previewLabel: props.labels?.previewLabel ?? contract.value.uploadPreviewPending,
146
+ }));
147
+
148
+ // `undefined` members must be dropped, not passed: the dialog spreads its `labels` over the
149
+ // contract, and a spread `undefined` would blank the string instead of leaving it alone.
150
+ const cropDialogLabels = computed(() => {
151
+ const given = props.labels ?? {};
152
+ const mapped: Partial<ImageCropDialogLabels> = {
153
+ close: given.cropClose,
154
+ zoomIn: given.zoomIn,
155
+ zoomOut: given.zoomOut,
156
+ rotateLeft: given.rotateLeft,
157
+ rotateRight: given.rotateRight,
158
+ flip: given.flip,
159
+ reset: given.cropReset,
160
+ cancel: given.cropCancel,
161
+ processing: given.cropProcessing,
162
+ apply: given.cropApply,
163
+ loadError: given.cropLoadError,
164
+ loadErrorHint: given.cropLoadErrorHint,
165
+ variants: given.cropVariants,
166
+ auto: given.cropVariantAuto,
167
+ aspectRatio: given.cropAspectRatio,
168
+ ratioOnly: given.cropRatioOnly,
169
+ ratioFree: given.cropRatioFree,
170
+ variantsStatus: given.cropVariantsStatus,
171
+ variantsPending: given.cropVariantsPending,
172
+ applyAll: given.cropApplyAll,
173
+ };
174
+ return Object.fromEntries(
175
+ Object.entries(mapped).filter(([, value]) => value !== undefined),
176
+ ) as Partial<ImageCropDialogLabels>;
177
+ });
178
+
179
+ // Only applied when `round` is true. `cn` merges it over FileUpload's rectangular dropzone
180
+ // classes (rounded-xl becomes rounded-full, px/py become p, gap-3 becomes gap-1).
181
+ const roundDropzoneClass =
182
+ 'h-20 w-20 shrink-0 flex-col items-center justify-center gap-1 overflow-hidden rounded-full p-2 text-center';
183
+
184
+ const emit = defineEmits<{
185
+ (e: 'select', payload: { cropped: File; original: File; crops?: CropResult[] }): void;
186
+ (e: 'recrop', payload: { cropped: File; crops?: CropResult[] }): void;
187
+ (e: 'remove'): void;
188
+ (e: 'error', message: string): void;
189
+ }>();
190
+
191
+ const dialogOpen = ref(false);
192
+ const dialogSrc = ref<string | null>(null);
193
+ const isRecrop = ref(false);
194
+ const pendingOriginal = ref<File | null>(null);
195
+ const convertingPdf = ref(false);
196
+ // The object URL we created for a fresh pick, kept apart from `dialogSrc` because a re-crop
197
+ // points `dialogSrc` at the caller-owned `recropUrl`, which we must never revoke.
198
+ const createdObjectUrl = ref<string | null>(null);
199
+
200
+ const isBlocked = computed(
201
+ () => props.disabled === true || props.busy === true || convertingPdf.value,
202
+ );
203
+
204
+ function revokeCreatedUrl(): void {
205
+ if (createdObjectUrl.value) {
206
+ URL.revokeObjectURL(createdObjectUrl.value);
207
+ createdObjectUrl.value = null;
208
+ }
209
+ }
210
+
211
+ function closeDialog(): void {
212
+ dialogOpen.value = false;
213
+ dialogSrc.value = null;
214
+ pendingOriginal.value = null;
215
+ isRecrop.value = false;
216
+ revokeCreatedUrl();
217
+ }
218
+
219
+ async function handleFileSelected(file: File): Promise<void> {
220
+ if (isBlocked.value) {
221
+ return;
222
+ }
223
+ revokeCreatedUrl();
224
+
225
+ let original = file;
226
+ if (file.type === 'application/pdf') {
227
+ convertingPdf.value = true;
228
+ try {
229
+ original = await props.convertPdf(file);
230
+ } catch (error) {
231
+ emit('error', error instanceof Error ? error.message : text.value.convertError);
232
+ return;
233
+ } finally {
234
+ convertingPdf.value = false;
235
+ }
236
+ }
237
+
238
+ pendingOriginal.value = original;
239
+ isRecrop.value = false;
240
+ const url = URL.createObjectURL(original);
241
+ createdObjectUrl.value = url;
242
+ dialogSrc.value = url;
243
+ dialogOpen.value = true;
244
+ }
245
+
246
+ function openRecrop(): void {
247
+ if (isBlocked.value || !props.recropUrl) {
248
+ return;
249
+ }
250
+ revokeCreatedUrl();
251
+ pendingOriginal.value = null;
252
+ isRecrop.value = true;
253
+ dialogSrc.value = props.recropUrl;
254
+ dialogOpen.value = true;
255
+ }
256
+
257
+ // `crops` is present in the payload only when the dialog sent it: a variants dialog whose
258
+ // picture never loaded sends one argument, like a dialog with none, so the prop decides nothing.
259
+ function handleApply(cropped: File, crops?: CropResult[]): void {
260
+ const carried = crops === undefined ? {} : { crops };
261
+ if (isRecrop.value) {
262
+ emit('recrop', { cropped, ...carried });
263
+ } else if (pendingOriginal.value) {
264
+ emit('select', { cropped, original: pendingOriginal.value, ...carried });
265
+ }
266
+ closeDialog();
267
+ }
268
+
269
+ function handleRemove(): void {
270
+ if (isBlocked.value) {
271
+ return;
272
+ }
273
+ emit('remove');
274
+ }
275
+
276
+ onBeforeUnmount(revokeCreatedUrl);
277
+ </script>
278
+
279
+ <template>
280
+ <div class="space-y-2">
281
+ <FileUpload
282
+ v-if="!hasFile"
283
+ :accept="accept"
284
+ :label="label ?? labels?.fileLabel"
285
+ :hint="hint ?? labels?.hint"
286
+ :disabled="disabled"
287
+ :loading="busy || convertingPdf"
288
+ :class="round ? roundDropzoneClass : undefined"
289
+ @select="handleFileSelected"
290
+ />
291
+ <!-- Wraps rather than overflowing: this sits in narrow columns, where the preview and
292
+ the buttons side by side do not fit. Below the wrap point the button column takes
293
+ the full width; wide containers keep the side-by-side row. -->
294
+ <div v-else class="flex flex-wrap items-start gap-3">
295
+ <FilePreview
296
+ :preview-url="previewUrl"
297
+ :has-file="hasFile"
298
+ :round="round"
299
+ :label="text.previewLabel"
300
+ />
301
+ <div class="flex min-w-0 flex-1 basis-32 flex-col gap-2">
302
+ <Button
303
+ variant="outline"
304
+ size="sm"
305
+ data-testid="image-upload-recrop"
306
+ :disabled="isBlocked || !recropUrl"
307
+ class="w-full"
308
+ @click="openRecrop"
309
+ >
310
+ {{ text.recrop }}
311
+ </Button>
312
+ <Button
313
+ variant="outline"
314
+ size="sm"
315
+ data-testid="image-upload-remove"
316
+ :disabled="isBlocked"
317
+ class="w-full"
318
+ @click="handleRemove"
319
+ >
320
+ {{ text.remove }}
321
+ </Button>
322
+ </div>
323
+ </div>
324
+
325
+ <p
326
+ v-if="convertingPdf"
327
+ data-testid="image-upload-pdf-converting"
328
+ class="text-muted-foreground text-xs"
329
+ >
330
+ {{ text.converting }}
331
+ </p>
332
+
333
+ <ImageCropDialog
334
+ :open="dialogOpen"
335
+ :src="dialogSrc"
336
+ :aspect-ratio="aspectRatio"
337
+ :title="labels?.cropTitle"
338
+ :labels="cropDialogLabels"
339
+ :output-type="outputType"
340
+ :variants="variants"
341
+ @apply="handleApply"
342
+ @cancel="closeDialog"
343
+ />
344
+ </div>
345
+ </template>
@@ -0,0 +1,2 @@
1
+ export { default as ImageUpload } from './ImageUpload.vue';
2
+ export type { ImageUploadLabels } from './ImageUpload.vue';
@@ -0,0 +1,48 @@
1
+ <script setup lang="ts">
2
+ import type { HTMLAttributes } from 'vue';
3
+ import { useVModel } from '@vueuse/core';
4
+ import { cn } from '../../lib/cn';
5
+
6
+ const props = defineProps<{
7
+ defaultValue?: string | number;
8
+ modelValue?: string | number;
9
+ /**
10
+ * `default` is the compact field of a dense screen. `lg` is the roomier,
11
+ * phone-friendly field for a full-width entry surface; it only changes geometry, the
12
+ * focus/invalid/disabled tokens stay.
13
+ */
14
+ size?: 'default' | 'lg';
15
+ class?: HTMLAttributes['class'];
16
+ }>();
17
+
18
+ const emits = defineEmits<{
19
+ (e: 'update:modelValue', payload: string | number): void;
20
+ }>();
21
+
22
+ const modelValue = useVModel(props, 'modelValue', emits, {
23
+ passive: true,
24
+ defaultValue: props.defaultValue,
25
+ });
26
+ </script>
27
+
28
+ <template>
29
+ <input
30
+ v-model="modelValue"
31
+ data-slot="input"
32
+ :class="
33
+ cn(
34
+ // Focus, invalid and disabled are CLAUDE.md's control-state recipe: a
35
+ // full-strength ring on a `--background` gap, and no halved edges. The
36
+ // halo this field used to focus with, `ring-ring/50` with no gap, measured
37
+ // 1.79-3.92 against the page.
38
+ 'dark:bg-input/30 border-muted-foreground focus-visible:border-ring focus-visible:ring-ring focus-visible:ring-offset-background aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive disabled:bg-input/50 dark:disabled:bg-input/80 h-8 rounded-lg border bg-transparent px-2.5 py-1 text-base transition-colors file:h-6 file:text-sm file:font-medium focus-visible:ring-2 focus-visible:ring-offset-2 aria-invalid:ring-3 md:text-sm w-full min-w-0 outline-none file:inline-flex file:border-0 file:bg-transparent file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50',
39
+ // `md:text-[15px]` matters: the compact base drops to `md:text-sm` and would win.
40
+ // The shadow is a 4% tint of the theme's own `--brand`, not a literal
41
+ // colour, so the field's elevation follows the mounted theme.
42
+ props.size === 'lg' &&
43
+ 'h-12 rounded-xl bg-background px-4 text-[15px] shadow-[0_1px_2px_color-mix(in_srgb,var(--brand)_4%,transparent)] md:text-[15px]',
44
+ props.class,
45
+ )
46
+ "
47
+ />
48
+ </template>
@@ -0,0 +1 @@
1
+ export { default as Input } from './Input.vue';
@@ -0,0 +1,49 @@
1
+ <script setup lang="ts">
2
+ import type { HTMLAttributes } from 'vue';
3
+ import { cn } from '../../lib/cn';
4
+
5
+ /**
6
+ * A keyboard shortcut drawn as keys: `['Ctrl', 'K']` is two caps with a `+` between them.
7
+ *
8
+ * **The keys are a prop, and there is no slot for a glyph.** A key's text _is_ its name, so
9
+ * `keys` is a list of strings and each one lands in a `<kbd>`, which is what a screen reader
10
+ * announces as a key. A named slot would invite an icon where a character belongs, and an
11
+ * icon has no text for that announcement to read. Write the character itself (`⌘`, `↵`, `⇧`)
12
+ * when the key is drawn as one. Icons are slots elsewhere in this package (ADR 0013) because
13
+ * an icon is a drawing the caller owns; a key name is not.
14
+ *
15
+ * **Why this is not the menu's hint class.** `menuItemHintClass` is quiet text at the end of a
16
+ * row: it takes the row's highlighted ink and draws no key face, no border and no separate
17
+ * keys, and it is a class on a caller's own element rather than an element. This is the
18
+ * thing that class is not: one element per key, with a face. Any component that shows a
19
+ * keyboard hint can use it, which is why it has its own directory rather than living inside
20
+ * the first family that wanted one.
21
+ *
22
+ * Every colour is a role token or the surrounding ink. The face is `--muted` under
23
+ * `--foreground` rather than `--muted-foreground`: role on role is not a gated pair, and
24
+ * `--muted-foreground` over `--muted` is below AA in one theme (see the note in
25
+ * `../badge/index.ts`). Each face carries its own background, so a keycap can sit on any
26
+ * surface. The separator is the one part that does not: it names no colour and inherits the
27
+ * ink around it (`currentColor`), so it matches the text it sits among on a page, a card or
28
+ * a primary button alike, with no pairing of its own. The edge is `--border`, which is below
29
+ * 3:1 and recorded as decoration in `contract.json`; the cue is the key's name.
30
+ *
31
+ * An empty `keys` renders no keys, no separator and an empty wrapper.
32
+ */
33
+ const props = defineProps<{ keys: string[]; class?: HTMLAttributes['class'] }>();
34
+ </script>
35
+
36
+ <template>
37
+ <span
38
+ data-slot="keycap"
39
+ :class="cn('inline-flex items-center gap-1 whitespace-nowrap', props.class)"
40
+ >
41
+ <template v-for="(key, index) in props.keys" :key="index">
42
+ <span v-if="index > 0" data-slot="keycap-separator" class="text-[10.5px]">+</span>
43
+ <kbd
44
+ class="border-border bg-muted text-foreground inline-flex min-w-[1.5em] items-center justify-center rounded-md border border-b-2 px-1.5 py-px font-sans text-[10.5px] leading-4 font-semibold"
45
+ >{{ key }}</kbd
46
+ >
47
+ </template>
48
+ </span>
49
+ </template>
@@ -0,0 +1 @@
1
+ export { default as Keycap } from './Keycap.vue';
@@ -0,0 +1,26 @@
1
+ <script setup lang="ts">
2
+ import type { LabelProps } from 'reka-ui';
3
+ import type { HTMLAttributes } from 'vue';
4
+ import { reactiveOmit } from '@vueuse/core';
5
+ import { Label as RekaLabel } from 'reka-ui';
6
+ import { cn } from '../../lib/cn';
7
+
8
+ const props = defineProps<LabelProps & { class?: HTMLAttributes['class'] }>();
9
+
10
+ const delegatedProps = reactiveOmit(props, 'class');
11
+ </script>
12
+
13
+ <template>
14
+ <RekaLabel
15
+ data-slot="label"
16
+ v-bind="delegatedProps"
17
+ :class="
18
+ cn(
19
+ 'gap-2 text-sm leading-none font-medium group-data-[disabled=true]:opacity-50 peer-disabled:opacity-50 flex items-center select-none group-data-[disabled=true]:pointer-events-none peer-disabled:cursor-not-allowed',
20
+ props.class,
21
+ )
22
+ "
23
+ >
24
+ <slot />
25
+ </RekaLabel>
26
+ </template>
@@ -0,0 +1 @@
1
+ export { default as Label } from './Label.vue';
@@ -0,0 +1,63 @@
1
+ <script setup lang="ts">
2
+ import type { DropdownMenuCheckboxItemEmits, DropdownMenuCheckboxItemProps } from 'reka-ui';
3
+ import type { HTMLAttributes } from 'vue';
4
+ import { reactiveOmit } from '@vueuse/core';
5
+ import { DropdownMenuCheckboxItem, DropdownMenuItemIndicator, useForwardPropsEmits } from 'reka-ui';
6
+ import { cn } from '../../lib/cn';
7
+ import { CheckIcon } from '../icon';
8
+ import { menuRowClass, menuTickLayoutClass } from './menuClasses';
9
+
10
+ /**
11
+ * A row that is either ticked or not: the label, and a tick at the right of a ticked one.
12
+ * `v-model` holds the state, which is `true`, `false` or `'indeterminate'`; the third reports
13
+ * `aria-checked="mixed"` and draws the tick, because something under the row is on.
14
+ *
15
+ * Choosing it flips the state and then closes the menu, as any row does. Ticking several rows
16
+ * in one pass is the use that wants the menu to stay, and `@select` with `preventDefault()` on
17
+ * the event is how: the flip still happens, the close does not.
18
+ *
19
+ * The tick is `indicator-icon`, a named slot (ADR 0013) that defaults to the package's own
20
+ * glyph, and the default slot's scope is `{ checked, modelValue }` — one value under the two
21
+ * names the library hands over, typed as the library types it rather than as `unknown`, so a
22
+ * consumer's `v-slot="{ checked }"` narrows to `boolean | 'indeterminate'` and a branch on the
23
+ * third state typechecks. `disabled` fades the row and flips nothing.
24
+ */
25
+ defineOptions({ inheritAttrs: false });
26
+
27
+ /**
28
+ * The state the row hands its slot, read off the library's own prop rather than restated: it
29
+ * is the type the library declares both the prop and the slot with, so the two cannot drift.
30
+ */
31
+ type Checked = NonNullable<DropdownMenuCheckboxItemProps['modelValue']>;
32
+
33
+ const props = defineProps<DropdownMenuCheckboxItemProps & { class?: HTMLAttributes['class'] }>();
34
+ const emits = defineEmits<DropdownMenuCheckboxItemEmits>();
35
+
36
+ defineSlots<{
37
+ /** The row's label, with the state as `{ checked, modelValue }`. */
38
+ default?: (props: { checked: Checked; modelValue: Checked }) => unknown;
39
+ /** The tick drawn on a ticked row. Defaults to the package's own glyph. */
40
+ 'indicator-icon'?: () => unknown;
41
+ }>();
42
+
43
+ const delegatedProps = reactiveOmit(props, 'class');
44
+ const forwarded = useForwardPropsEmits(delegatedProps, emits);
45
+ </script>
46
+
47
+ <template>
48
+ <DropdownMenuCheckboxItem
49
+ v-slot="{ checked, modelValue }"
50
+ data-slot="menu-checkbox-item"
51
+ v-bind="{ ...$attrs, ...forwarded }"
52
+ :class="cn(menuRowClass, menuTickLayoutClass, props.class)"
53
+ >
54
+ <span class="pointer-events-none absolute right-2 flex size-4 items-center justify-center">
55
+ <DropdownMenuItemIndicator>
56
+ <slot name="indicator-icon">
57
+ <CheckIcon />
58
+ </slot>
59
+ </DropdownMenuItemIndicator>
60
+ </span>
61
+ <slot v-bind="{ checked, modelValue }" />
62
+ </DropdownMenuCheckboxItem>
63
+ </template>
@@ -0,0 +1,45 @@
1
+ <script setup lang="ts">
2
+ import type { DropdownMenuContentEmits, DropdownMenuContentProps } from 'reka-ui';
3
+ import type { HTMLAttributes } from 'vue';
4
+ import { reactiveOmit } from '@vueuse/core';
5
+ import { DropdownMenuContent, DropdownMenuPortal, useForwardPropsEmits } from 'reka-ui';
6
+ import { cn } from '../../lib/cn';
7
+ import { menuPanelClass } from './menuClasses';
8
+
9
+ /**
10
+ * The panel of a dropdown menu, with the portal that draws it. Composes inside a `MenuRoot`,
11
+ * after its `MenuTrigger`.
12
+ *
13
+ * The portal has no `to`, so the panel lands as a child of `document.body`, which is also the
14
+ * only place the playground's contrast walk can see it (a portal aimed at a container inside
15
+ * the application shell is invisible to it). It aligns to the end of its trigger and sits four
16
+ * pixels off it; both are defaults a family can pass over. `class` reaches the panel, and
17
+ * a `min-w-*` replaces the default floor.
18
+ *
19
+ * It is one of the menu family's parts (`MenuRoot`, `MenuTrigger`, `MenuGroup`, `MenuLabel`,
20
+ * `MenuRadioGroup`, the rows, and `MenuSub` with its own trigger and panel are the others),
21
+ * exported from the package barrel.
22
+ */
23
+ defineOptions({ inheritAttrs: false });
24
+
25
+ const props = withDefaults(
26
+ defineProps<DropdownMenuContentProps & { class?: HTMLAttributes['class'] }>(),
27
+ { align: 'end', sideOffset: 4 },
28
+ );
29
+ const emits = defineEmits<DropdownMenuContentEmits>();
30
+
31
+ const delegatedProps = reactiveOmit(props, 'class');
32
+ const forwarded = useForwardPropsEmits(delegatedProps, emits);
33
+ </script>
34
+
35
+ <template>
36
+ <DropdownMenuPortal>
37
+ <DropdownMenuContent
38
+ data-slot="menu-content"
39
+ v-bind="{ ...$attrs, ...forwarded }"
40
+ :class="cn(menuPanelClass, props.class)"
41
+ >
42
+ <slot />
43
+ </DropdownMenuContent>
44
+ </DropdownMenuPortal>
45
+ </template>
@@ -0,0 +1,22 @@
1
+ <script setup lang="ts">
2
+ import type { DropdownMenuGroupProps } from 'reka-ui';
3
+ import { DropdownMenuGroup, useForwardProps } from 'reka-ui';
4
+
5
+ /**
6
+ * A group of rows inside a `MenuContent`. Put a `MenuLabel` first inside it and the group is
7
+ * named by that heading (`role="group"`, `aria-labelledby`); a `MenuLabel` outside a group has
8
+ * no id and labels nothing, so the two are used together.
9
+ *
10
+ * This is a thin wrapper over the underlying library's group and exists so the package owns its
11
+ * own surface. It adds no styling and no behaviour; every prop passes through.
12
+ */
13
+ const props = defineProps<DropdownMenuGroupProps>();
14
+
15
+ const forwarded = useForwardProps(props);
16
+ </script>
17
+
18
+ <template>
19
+ <DropdownMenuGroup v-bind="forwarded">
20
+ <slot />
21
+ </DropdownMenuGroup>
22
+ </template>
@@ -0,0 +1,34 @@
1
+ <script setup lang="ts">
2
+ import type { DropdownMenuItemEmits, DropdownMenuItemProps } from 'reka-ui';
3
+ import type { HTMLAttributes } from 'vue';
4
+ import { reactiveOmit } from '@vueuse/core';
5
+ import { DropdownMenuItem, useForwardPropsEmits } from 'reka-ui';
6
+ import { cn } from '../../lib/cn';
7
+ import { menuItemLayoutClass, menuRowClass } from './menuClasses';
8
+
9
+ /**
10
+ * One action row of a menu: a label and, if the caller draws one, a hint at the right (give
11
+ * it `menuItemHintClass`, so it follows the row's highlighted ink). Emits `select` when
12
+ * chosen, which also closes the menu. `disabled` fades it and takes it out of the focus path.
13
+ *
14
+ * The layout (label and hint at either end, no wrapping) is a default: a `class` that says
15
+ * `justify-start whitespace-normal` replaces it.
16
+ */
17
+ defineOptions({ inheritAttrs: false });
18
+
19
+ const props = defineProps<DropdownMenuItemProps & { class?: HTMLAttributes['class'] }>();
20
+ const emits = defineEmits<DropdownMenuItemEmits>();
21
+
22
+ const delegatedProps = reactiveOmit(props, 'class');
23
+ const forwarded = useForwardPropsEmits(delegatedProps, emits);
24
+ </script>
25
+
26
+ <template>
27
+ <DropdownMenuItem
28
+ data-slot="menu-item"
29
+ v-bind="{ ...$attrs, ...forwarded }"
30
+ :class="cn(menuRowClass, menuItemLayoutClass, props.class)"
31
+ >
32
+ <slot />
33
+ </DropdownMenuItem>
34
+ </template>