@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
package/src/index.ts ADDED
@@ -0,0 +1,182 @@
1
+ export { AddressField } from './components/address-field';
2
+ // `AppearanceGroup` and `AppearanceOption` are deliberately not re-exported: they describe
3
+ // the props of a private child component, which a consumer can neither construct nor pass
4
+ // anything to. `AppearanceLayout` is, because it types the `layout` prop.
5
+ export {
6
+ AppearancePicker,
7
+ type AppearanceAlign,
8
+ type AppearanceLayout,
9
+ } from './components/appearance-picker';
10
+ export {
11
+ Badge,
12
+ badgeVariants,
13
+ toneClasses,
14
+ type BadgeVariants,
15
+ type Tone,
16
+ } from './components/badge';
17
+ export { BuildStamp } from './components/build-stamp';
18
+ export { Button, buttonVariants, type ButtonVariants } from './components/button';
19
+ export {
20
+ Card,
21
+ CardAction,
22
+ CardContent,
23
+ CardDescription,
24
+ CardFooter,
25
+ CardHeader,
26
+ CardTitle,
27
+ cardTitleVariants,
28
+ type CardTitleVariants,
29
+ } from './components/card';
30
+ export { Checkbox } from './components/checkbox';
31
+ export { ColourPicker } from './components/colour-picker';
32
+ export { Combobox } from './components/combobox';
33
+ export { ConfirmDialog } from './components/confirm-dialog';
34
+ export {
35
+ Box,
36
+ Section,
37
+ SectionAction,
38
+ SectionContent,
39
+ SectionDescription,
40
+ SectionHeader,
41
+ SectionTitle,
42
+ } from './components/containers';
43
+ export {
44
+ DataTable,
45
+ defaultVisibleKeys,
46
+ type DataTableColumn,
47
+ type DataTableSortChoice,
48
+ type TableSort,
49
+ } from './components/data-table';
50
+ export {
51
+ DEFAULT_DIALOG_EDGE,
52
+ DEFAULT_DIALOG_SIZE,
53
+ Dialog,
54
+ DIALOG_EDGES,
55
+ DIALOG_SIZES,
56
+ DialogSurface,
57
+ edgeTakesWidth,
58
+ TOAST_HOST_ATTRIBUTE,
59
+ } from './components/dialog';
60
+ export type { DialogEdge, DialogSize } from './components/dialog';
61
+ export { Dropdown, type DropdownItem } from './components/dropdown';
62
+ export { FilePreview } from './components/file-preview';
63
+ export { FileUpload } from './components/file-upload';
64
+ export { FilterCheckMenu, type FilterCheckOption } from './components/filter-check-menu';
65
+ export { FormField, type FormFieldLabelVariant } from './components/form-field';
66
+ export { FrameCentred, FrameSidebar, FrameSplit } from './components/frames';
67
+ export { IconPicker } from './components/icon-picker';
68
+ export { Input } from './components/input';
69
+ export { Keycap } from './components/keycap';
70
+ export { Label } from './components/label';
71
+ export {
72
+ MenuCheckboxItem,
73
+ MenuContent,
74
+ MenuGroup,
75
+ MenuItem,
76
+ MenuLabel,
77
+ MenuRadioGroup,
78
+ MenuRadioItem,
79
+ MenuRoot,
80
+ MenuSeparator,
81
+ MenuSub,
82
+ MenuSubContent,
83
+ MenuSubTrigger,
84
+ MenuTrigger,
85
+ menuItemHintClass,
86
+ menuLabelClass,
87
+ } from './components/menu';
88
+ export { MorphSelect } from './components/morph-select';
89
+ export { NavGroup, NavItem, NavSection, NavSidebar, type NavNode } from './components/nav';
90
+ export { Pagination } from './components/pagination';
91
+ export { PinField } from './components/pin-field';
92
+ export { PopoverPanel } from './components/popover-panel';
93
+ export { Rating } from './components/rating';
94
+ export { RecordAvatar } from './components/record-avatar';
95
+ export { RowActions, type RowAction } from './components/row-actions';
96
+ export { SearchSelect, type SearchSelectOption } from './components/search-select';
97
+ export { SegmentedChoice, type SegmentedOption } from './components/segmented-choice';
98
+ export {
99
+ Select,
100
+ SelectContent,
101
+ SelectGroup,
102
+ SelectItem,
103
+ SelectItemText,
104
+ SelectLabel,
105
+ SelectScrollDownButton,
106
+ SelectScrollUpButton,
107
+ SelectSeparator,
108
+ SelectTrigger,
109
+ SelectValue,
110
+ } from './components/select';
111
+ export { SplitButton, type SplitButtonItem } from './components/split-button';
112
+ export { Switch } from './components/switch';
113
+ export { Tabs, type TabItem } from './components/tabs';
114
+ export {
115
+ Table,
116
+ TableBody,
117
+ TableCaption,
118
+ TableCell,
119
+ TableEmpty,
120
+ TableFooter,
121
+ TableHead,
122
+ TableHeader,
123
+ TableRow,
124
+ } from './components/table';
125
+ export {
126
+ LimitedTextarea,
127
+ Textarea,
128
+ TextLimitCounter,
129
+ textLength,
130
+ textLimitFieldClass,
131
+ textLimitState,
132
+ type TextLimitState,
133
+ } from './components/textarea';
134
+ export { TimePicker } from './components/time-picker';
135
+ export { ToastHost } from './components/toast';
136
+ export { IdleTimer, SessionDialogs } from './components/session';
137
+ export { AutoFillDialog } from './components/autofill';
138
+ export { UpdateNotice } from './components/update-notice';
139
+ export { UserMenu } from './components/user-menu';
140
+ // The comment family, less its composer, which ships from its own subpath because its module
141
+ // graph reaches a family carrying optional peers (ADR 0014).
142
+ //
143
+ // `components/comments/index.ts` carries the whole reason and names the precedent. It is NOT
144
+ // repeated here on purpose: `entry.test.ts` reads THIS FILE as text and refuses the name of any
145
+ // door in it, comments included — which is the gate doing its job, since a barrel that mentions
146
+ // a door is one edit away from exporting it.
147
+ export {
148
+ CommentMessage,
149
+ CommentThread,
150
+ isBlankBody,
151
+ levelByKey,
152
+ levelOptions,
153
+ levelTone,
154
+ narrowestLevel,
155
+ toneInk,
156
+ } from './components/comments';
157
+ export type { CommentLevel, CommentNode } from './components/comments';
158
+ export { NotificationList } from './components/notification-list';
159
+ export type { Notification, NotificationFilter } from './components/notification-list';
160
+ export { ResultWindow } from './components/result-window';
161
+ export type { ResultRow, ResultSection } from './components/result-window';
162
+ export {
163
+ UPDATE_POLL_MS,
164
+ createUpdateCheck,
165
+ type UpdateCheck,
166
+ type UpdateCheckOptions,
167
+ } from './lib/updateCheck';
168
+ export {
169
+ IDLE_TIMER_ORANGE_MS,
170
+ SESSION_KEEPALIVE_MS,
171
+ SESSION_MARGIN_MS,
172
+ SESSION_WARNING_MS,
173
+ createSessionMonitor,
174
+ formatIdleRemaining,
175
+ formatRemaining,
176
+ type KeepAliveResult,
177
+ type SessionEndReason,
178
+ type SessionMonitor,
179
+ type SessionMonitorOptions,
180
+ type SessionPhase,
181
+ } from './lib/sessionMonitor';
182
+ export { cn } from './lib/cn';
package/src/lib/cn.ts ADDED
@@ -0,0 +1,21 @@
1
+ import { type ClassValue, clsx } from 'clsx';
2
+ import { twMerge } from 'tailwind-merge';
3
+
4
+ /**
5
+ * What `cn()` accepts, re-exported so that a component which types a `class` attribute names
6
+ * this module rather than `clsx`. An `import type` is erased at compile time, but
7
+ * `scripts/family-facts.mjs` reads imports as text and does not tell the two apart, so a family
8
+ * that named `clsx` for the type alone showed `clsx` as a runtime dependency on the facts bar a
9
+ * consumer reads. The components import it from here, where the dependency is real.
10
+ */
11
+ export type { ClassValue };
12
+
13
+ /**
14
+ * Join class lists and let the last utility of a kind win. Every component runs its
15
+ * variant classes and the caller's `class` through this, which is what makes
16
+ * `<Button size="xl" class="h-12" />` end up 12 high instead of carrying both heights
17
+ * and leaving the winner to stylesheet order.
18
+ */
19
+ export function cn(...inputs: ClassValue[]): string {
20
+ return twMerge(clsx(inputs));
21
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Arrow-key movement over the focusables of a popover panel, shared by the families that hang
3
+ * a list of controls on `PopoverPanel`.
4
+ *
5
+ * WHY THE ARROWS ARE NOT OPTIONAL. The shell supplies no focus trap, so each of these panels
6
+ * closes on Tab rather than strand focus in a portal at the end of the document — and Tab is
7
+ * fired for Shift+Tab too, so both directions dismiss. That spends the only key a browser
8
+ * gives a user for moving inside the panel. A panel that takes the Tab-close and adds no
9
+ * arrows leaves a keyboard user on whatever `open-auto-focus` put focus on, with no key that
10
+ * reaches anything else: the control is then pointer-only (WCAG 2.1.1). The arrows are what
11
+ * pay for the Tab-close, and the two belong together.
12
+ *
13
+ * WHY IT WRAPS. `CLAUDE.md`'s "Keyboard ends" names two shapes — a listbox clamps, a radio
14
+ * group wraps — and says which one a control takes follows from its shape. A checkbox menu in
15
+ * a popover is neither, so the rule does not decide it and taste must not: the ARIA menu
16
+ * pattern wraps, and that is the pattern a reader meets here, a short self-contained panel of
17
+ * choices. The listbox clamp exists so that two controls a user moves between interchangeably
18
+ * keep their place; nothing moves between one of these panels and a listbox.
19
+ *
20
+ * It is a module and not a copy in each family because two families need it today and a third
21
+ * is coming, and a second copy is what drifts.
22
+ */
23
+
24
+ /**
25
+ * The panel's focusables in DOM order, so an arrow key walks it top to bottom. `button` reaches
26
+ * reka's `role="checkbox"` controls, which render as buttons.
27
+ *
28
+ * `:not([disabled])` IS LOAD-BEARING, and leaving it out is a dead key rather than an untidy
29
+ * list. `.focus()` on a disabled button does nothing, so a disabled element left in the list
30
+ * takes a step and goes nowhere: `ColumnMenu` disables the last visible column's checkbox, and
31
+ * without this the arrows stalled on the element BEFORE that row going down and the element
32
+ * AFTER it going up — everything still reachable the other way round, which is why a wrap case
33
+ * cannot see it.
34
+ *
35
+ * `[aria-disabled="true"]` is deliberately NOT excluded, because such an element IS focusable —
36
+ * that is the whole difference between the two spellings. Both families' markup was read rather
37
+ * than assumed: neither sets `aria-disabled` in place of `disabled`, and reka's `CheckboxRoot`
38
+ * sets both at once on a disabled checkbox, so the filter above already covers the one site
39
+ * that disables anything.
40
+ */
41
+ export function panelFocusables(panel: HTMLElement | null): HTMLElement[] {
42
+ return Array.from(
43
+ panel?.querySelectorAll<HTMLElement>('button:not([disabled]), input:not([disabled])') ?? [],
44
+ );
45
+ }
46
+
47
+ /**
48
+ * Moves focus `delta` places through the panel, wrapping at both ends. With focus nowhere in
49
+ * the panel it enters at the first element going forwards and at the last going backwards,
50
+ * which is what a user pressing an arrow into the panel means by it.
51
+ */
52
+ export function movePanelFocus(panel: HTMLElement | null, delta: number): void {
53
+ const items = panelFocusables(panel);
54
+ if (items.length === 0) {
55
+ return;
56
+ }
57
+ const current = items.indexOf(document.activeElement as HTMLElement);
58
+ const next =
59
+ current === -1
60
+ ? delta > 0
61
+ ? 0
62
+ : items.length - 1
63
+ : (current + delta + items.length) % items.length;
64
+ items[next]?.focus();
65
+ }
@@ -0,0 +1,390 @@
1
+ import { readonly, ref, type Ref } from 'vue';
2
+
3
+ /** Why a session ended; it picks the logged-out message. */
4
+ export type SessionEndReason = 'idle' | 'expired' | 'elsewhere';
5
+ export type SessionPhase = 'stopped' | 'active' | 'warning' | 'ended';
6
+ /**
7
+ * What a keep-alive request answers: the session lifetime in minutes, 'unauthorized' when the
8
+ * server said 401 (the session is gone), null for any other failure (5xx during a deploy, 429, a
9
+ * network drop), which proves nothing about the session and must not end it.
10
+ */
11
+ export type KeepAliveResult = number | 'unauthorized' | null;
12
+
13
+ /** The warning dialog opens this long before the client deadline. */
14
+ export const SESSION_WARNING_MS = 120_000;
15
+ /** The client gives up this much earlier than the server, so the server session always outlives it. */
16
+ export const SESSION_MARGIN_MS = 60_000;
17
+ /** Activity pings the server at most this often. Must not exceed the margin. */
18
+ export const SESSION_KEEPALIVE_MS = 60_000;
19
+ /** An idle timer turns orange from here on. */
20
+ export const IDLE_TIMER_ORANGE_MS = 300_000;
21
+
22
+ const TICK_MS = 1_000;
23
+ /** Activity closer together than this is the same activity: spares the storage and other tabs. */
24
+ const ACTIVITY_THROTTLE_MS = 1_000;
25
+ const MOUSEMOVE_THROTTLE_MS = 5_000;
26
+ const ACTIVITY_EVENTS = ['pointerdown', 'keydown', 'wheel', 'touchstart', 'mousemove'] as const;
27
+
28
+ export interface SessionMonitorOptions {
29
+ /** One key per app, e.g. 'my-app.session'; its tabs share the activity under it. */
30
+ storageKey: string;
31
+ /**
32
+ * The keep-alive request: the lifetime in minutes; 'unauthorized' only for an HTTP 401; null
33
+ * for any other failure. Only a 401 ends the session, anything else is retried later.
34
+ */
35
+ keepAlive: () => Promise<KeepAliveResult>;
36
+ /** The logout request. Must not redirect; may throw (swallowed). */
37
+ logout: () => Promise<void>;
38
+ /** The application's way back to its sign-in page, e.g. a redirect with a return address. */
39
+ signInAgain: () => void;
40
+ /** Test seam, default Date.now. */
41
+ now?: () => number;
42
+ /** Test seam, default window.localStorage. */
43
+ storage?: Pick<Storage, 'getItem' | 'setItem'>;
44
+ /** Test seam: where activity and `storage` events are heard, default window. */
45
+ target?: EventTarget;
46
+ }
47
+
48
+ export interface SessionMonitor {
49
+ phase: Readonly<Ref<SessionPhase>>;
50
+ reason: Readonly<Ref<SessionEndReason | null>>;
51
+ /** Until the client deadline, ≥ 0. */
52
+ remainingMs: Readonly<Ref<number>>;
53
+ /** Phase is 'active' or 'warning'. Reactive: reads the phase. */
54
+ running(): boolean;
55
+ /** Idempotent while running. Counts as activity. */
56
+ start(lifetimeMinutes: number): void;
57
+ stayLoggedIn(): Promise<void>;
58
+ logoutNow(): Promise<void>;
59
+ /**
60
+ * Only while running and not already logging out (at zero or by logoutNow). Tells the other
61
+ * tabs unless the end came from one of them.
62
+ */
63
+ end(reason: SessionEndReason): void;
64
+ /** Tells the other tabs to end with 'elsewhere'. */
65
+ announceLogout(): void;
66
+ signInAgain(): void;
67
+ stop(): void;
68
+ }
69
+
70
+ /** 7_182_000 → '1:59:42', 254_000 → '4:14'. Rounds up, so '0:00' means zero. */
71
+ export function formatRemaining(ms: number): string {
72
+ const total = Math.max(0, Math.ceil(ms / 1_000));
73
+ const hours = Math.floor(total / 3_600);
74
+ const minutes = Math.floor((total % 3_600) / 60);
75
+ const seconds = String(total % 60).padStart(2, '0');
76
+
77
+ return hours > 0
78
+ ? `${hours}:${String(minutes).padStart(2, '0')}:${seconds}`
79
+ : `${minutes}:${seconds}`;
80
+ }
81
+
82
+ /**
83
+ * What an idle timer shows: whole minutes (rounded up) while a minute or more is left,
84
+ * seconds only in the last minute. 7_182_000 → 120 minutes, 59_000 → 59 seconds, 0 → 0 seconds.
85
+ */
86
+ export function formatIdleRemaining(ms: number): { value: number; unit: 'minutes' | 'seconds' } {
87
+ return ms >= 60_000
88
+ ? { value: Math.ceil(ms / 60_000), unit: 'minutes' }
89
+ : { value: Math.max(0, Math.ceil(ms / 1_000)), unit: 'seconds' };
90
+ }
91
+
92
+ /**
93
+ * Ends an idle session on the client before the server does, keeping the server alive while the
94
+ * user works. Tabs of one app share their last activity through localStorage, so a tab in the
95
+ * background never logs out a user who is busy in another one.
96
+ */
97
+ export function createSessionMonitor(options: SessionMonitorOptions): SessionMonitor {
98
+ const now = options.now ?? Date.now;
99
+ const endedKey = `${options.storageKey}.ended`;
100
+
101
+ const phase = ref<SessionPhase>('stopped');
102
+ const reason = ref<SessionEndReason | null>(null);
103
+ const remainingMs = ref(0);
104
+
105
+ let lifetimeMs = 0;
106
+ // In memory as well, so a throwing localStorage still leaves one working tab.
107
+ let lastActivity = 0;
108
+ let lastPing = 0;
109
+ let lastMouseMove = -Infinity;
110
+ let timer: ReturnType<typeof setInterval> | null = null;
111
+ let listening: EventTarget | null = null;
112
+ /** A stay request is on its way: zero must wait for its answer. */
113
+ let staying = false;
114
+ /**
115
+ * Logging out at zero or by the user: nothing else may happen any more. In particular the 401
116
+ * the application's own logout request may answer with must not turn into an 'expired' end.
117
+ */
118
+ let leaving = false;
119
+ /** Bumped by start() and stop(), so a logout still on its way cannot end a later session. */
120
+ let generation = 0;
121
+
122
+ function storage(): Pick<Storage, 'getItem' | 'setItem'> {
123
+ return options.storage ?? window.localStorage;
124
+ }
125
+
126
+ function running(): boolean {
127
+ return phase.value === 'active' || phase.value === 'warning';
128
+ }
129
+
130
+ function parseActivity(raw: string | null): number | null {
131
+ if (raw === null) {
132
+ return null;
133
+ }
134
+ try {
135
+ const value: unknown = JSON.parse(raw);
136
+ const activity = (value as { activity?: unknown } | null)?.activity;
137
+ return typeof activity === 'number' && Number.isFinite(activity) ? activity : null;
138
+ } catch {
139
+ return null;
140
+ }
141
+ }
142
+
143
+ function readSharedActivity(): number | null {
144
+ try {
145
+ return parseActivity(storage().getItem(options.storageKey));
146
+ } catch {
147
+ return null;
148
+ }
149
+ }
150
+
151
+ function write(key: string, value: unknown): void {
152
+ try {
153
+ storage().setItem(key, JSON.stringify(value));
154
+ } catch {
155
+ // Private mode, quota, policy: this tab carries on alone.
156
+ }
157
+ }
158
+
159
+ /** Takes over a newer activity from another tab. */
160
+ function adopt(activity: number | null): void {
161
+ if (activity !== null && activity > lastActivity) {
162
+ lastActivity = activity;
163
+ }
164
+ }
165
+
166
+ function touch(at: number): void {
167
+ lastActivity = at;
168
+ write(options.storageKey, { activity: at });
169
+ }
170
+
171
+ /** Recomputes the clock and the phase from the last activity; at zero it logs out. */
172
+ function update(): void {
173
+ if (!running() || leaving) {
174
+ return;
175
+ }
176
+ const left = Math.max(0, lastActivity + lifetimeMs - SESSION_MARGIN_MS - now());
177
+ remainingMs.value = left;
178
+ phase.value = left <= SESSION_WARNING_MS ? 'warning' : 'active';
179
+ if (left === 0 && !staying) {
180
+ void expire();
181
+ }
182
+ }
183
+
184
+ function tick(): void {
185
+ adopt(readSharedActivity());
186
+ update();
187
+ }
188
+
189
+ async function expire(): Promise<void> {
190
+ const mine = generation;
191
+ leaving = true;
192
+ teardown();
193
+ try {
194
+ await options.logout();
195
+ } catch {
196
+ // The server may already have ended it; the client ends either way.
197
+ }
198
+ if (generation === mine) {
199
+ finish('idle');
200
+ }
201
+ }
202
+
203
+ function ping(): void {
204
+ lastPing = now();
205
+ options.keepAlive().then(
206
+ (minutes) => {
207
+ if (minutes === 'unauthorized') {
208
+ end('expired');
209
+ } else if (minutes !== null && running()) {
210
+ lifetimeMs = minutes * 60_000;
211
+ update();
212
+ }
213
+ },
214
+ () => {
215
+ // keepAlive reports failure as null; a throw is a bug elsewhere, not an expiry.
216
+ // Either way the next activity pings again.
217
+ },
218
+ );
219
+ }
220
+
221
+ function onActivity(event: Event): void {
222
+ // While warning only the stay-signed-in action counts: page input might be a stray touch.
223
+ if (phase.value !== 'active' || leaving) {
224
+ return;
225
+ }
226
+ const at = now();
227
+ if (event.type === 'mousemove') {
228
+ if (at - lastMouseMove < MOUSEMOVE_THROTTLE_MS) {
229
+ return;
230
+ }
231
+ lastMouseMove = at;
232
+ }
233
+ if (at - lastActivity >= ACTIVITY_THROTTLE_MS) {
234
+ touch(at);
235
+ update();
236
+ }
237
+ if (at - lastPing >= SESSION_KEEPALIVE_MS) {
238
+ ping();
239
+ }
240
+ }
241
+
242
+ function onStorage(event: Event): void {
243
+ const { key, newValue } = event as StorageEvent;
244
+ if (key === endedKey && newValue !== null) {
245
+ end('elsewhere');
246
+ } else if (key === options.storageKey) {
247
+ adopt(parseActivity(newValue));
248
+ update();
249
+ }
250
+ }
251
+
252
+ function listen(): void {
253
+ const target = options.target ?? window;
254
+ listening = target;
255
+ // Capture, so a handler that stops propagation does not hide the activity.
256
+ for (const type of ACTIVITY_EVENTS) {
257
+ target.addEventListener(type, onActivity, { capture: true, passive: true });
258
+ }
259
+ target.addEventListener('storage', onStorage);
260
+ timer = setInterval(tick, TICK_MS);
261
+ }
262
+
263
+ function teardown(): void {
264
+ if (timer !== null) {
265
+ clearInterval(timer);
266
+ timer = null;
267
+ }
268
+ if (listening !== null) {
269
+ for (const type of ACTIVITY_EVENTS) {
270
+ listening.removeEventListener(type, onActivity, { capture: true });
271
+ }
272
+ listening.removeEventListener('storage', onStorage);
273
+ listening = null;
274
+ }
275
+ }
276
+
277
+ function start(lifetimeMinutes: number): void {
278
+ if (running()) {
279
+ return;
280
+ }
281
+ const at = now();
282
+ lifetimeMs = lifetimeMinutes * 60_000;
283
+ // start() follows the bootstrap's own request, which already kept the server alive.
284
+ lastPing = at;
285
+ lastActivity = 0;
286
+ lastMouseMove = -Infinity;
287
+ staying = false;
288
+ leaving = false;
289
+ generation++;
290
+ reason.value = null;
291
+ touch(at);
292
+ adopt(readSharedActivity());
293
+ phase.value = 'active';
294
+ listen();
295
+ update();
296
+ }
297
+
298
+ async function stayLoggedIn(): Promise<void> {
299
+ if (!running() || leaving || staying) {
300
+ return;
301
+ }
302
+ staying = true;
303
+ let minutes: KeepAliveResult;
304
+ try {
305
+ minutes = await options.keepAlive();
306
+ } catch {
307
+ minutes = null;
308
+ } finally {
309
+ staying = false;
310
+ }
311
+ if (!running() || leaving) {
312
+ return;
313
+ }
314
+ if (minutes === 'unauthorized') {
315
+ end('expired');
316
+ return;
317
+ }
318
+ if (minutes === null) {
319
+ // Not a 401: the session may well be alive. Stay in the warning so the user can retry.
320
+ return;
321
+ }
322
+ const at = now();
323
+ lifetimeMs = minutes * 60_000;
324
+ lastPing = at;
325
+ touch(at);
326
+ update();
327
+ }
328
+
329
+ async function logoutNow(): Promise<void> {
330
+ if (leaving) {
331
+ return;
332
+ }
333
+ leaving = true;
334
+ teardown();
335
+ try {
336
+ await options.logout();
337
+ } catch {
338
+ // Leaving anyway; the login page starts a fresh session.
339
+ }
340
+ announceLogout();
341
+ options.signInAgain();
342
+ }
343
+
344
+ /** Ignored while leaving: that path ends (or redirects) by itself. */
345
+ function end(why: SessionEndReason): void {
346
+ if (!leaving) {
347
+ finish(why);
348
+ }
349
+ }
350
+
351
+ function finish(why: SessionEndReason): void {
352
+ if (!running()) {
353
+ return;
354
+ }
355
+ teardown();
356
+ leaving = false;
357
+ phase.value = 'ended';
358
+ reason.value = why;
359
+ if (why !== 'elsewhere') {
360
+ write(endedKey, { reason: why, at: now() });
361
+ }
362
+ }
363
+
364
+ function announceLogout(): void {
365
+ write(endedKey, { reason: 'logout', at: now() });
366
+ }
367
+
368
+ function stop(): void {
369
+ teardown();
370
+ staying = false;
371
+ leaving = false;
372
+ generation++;
373
+ phase.value = 'stopped';
374
+ reason.value = null;
375
+ }
376
+
377
+ return {
378
+ phase: readonly(phase),
379
+ reason: readonly(reason),
380
+ remainingMs: readonly(remainingMs),
381
+ running,
382
+ start,
383
+ stayLoggedIn,
384
+ logoutNow,
385
+ end,
386
+ announceLogout,
387
+ signInAgain: () => options.signInAgain(),
388
+ stop,
389
+ };
390
+ }
@@ -0,0 +1,17 @@
1
+ import type { Slot, VNode } from 'vue';
2
+ import { Comment, Fragment, Text } from 'vue';
3
+
4
+ /** True when a slot is passed and its render yields something other than comments or whitespace. */
5
+ export function hasContent(slot: Slot | undefined): boolean {
6
+ if (!slot) return false;
7
+ const walk = (nodes: VNode[]): boolean =>
8
+ nodes.some((node) => {
9
+ if (node.type === Comment) return false;
10
+ if (node.type === Text)
11
+ return typeof node.children === 'string' && node.children.trim() !== '';
12
+ if (node.type === Fragment)
13
+ return Array.isArray(node.children) && walk(node.children as VNode[]);
14
+ return true;
15
+ });
16
+ return walk(slot());
17
+ }