@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.
- package/LICENSE +21 -0
- package/README.md +74 -2
- package/package.json +117 -3
- package/src/components/address-field/AddressField.vue +337 -0
- package/src/components/address-field/index.ts +1 -0
- package/src/components/appearance-picker/AppearancePicker.vue +502 -0
- package/src/components/appearance-picker/AppearanceSegment.vue +175 -0
- package/src/components/appearance-picker/index.ts +44 -0
- package/src/components/autofill/AutoFillDialog.vue +264 -0
- package/src/components/autofill/index.ts +1 -0
- package/src/components/badge/Badge.vue +23 -0
- package/src/components/badge/index.ts +106 -0
- package/src/components/build-stamp/BuildStamp.vue +62 -0
- package/src/components/build-stamp/index.ts +1 -0
- package/src/components/button/Button.vue +31 -0
- package/src/components/button/index.ts +122 -0
- package/src/components/card/Card.vue +29 -0
- package/src/components/card/CardAction.vue +17 -0
- package/src/components/card/CardContent.vue +14 -0
- package/src/components/card/CardDescription.vue +14 -0
- package/src/components/card/CardFooter.vue +22 -0
- package/src/components/card/CardHeader.vue +22 -0
- package/src/components/card/CardTitle.vue +29 -0
- package/src/components/card/index.ts +47 -0
- package/src/components/chart/BarChart.vue +123 -0
- package/src/components/chart/StackedBarChart.vue +149 -0
- package/src/components/chart/appearanceRevision.ts +22 -0
- package/src/components/chart/chartColor.ts +59 -0
- package/src/components/chart/index.ts +6 -0
- package/src/components/checkbox/Checkbox.vue +61 -0
- package/src/components/checkbox/index.ts +1 -0
- package/src/components/code-editor/CodeEditor.vue +352 -0
- package/src/components/code-editor/index.ts +9 -0
- package/src/components/code-editor/syntaxTheme.ts +110 -0
- package/src/components/colour-picker/ColourPicker.vue +421 -0
- package/src/components/colour-picker/index.ts +1 -0
- package/src/components/combobox/Combobox.vue +337 -0
- package/src/components/combobox/index.ts +1 -0
- package/src/components/comments/CommentComposer.vue +302 -0
- package/src/components/comments/CommentMessage.vue +259 -0
- package/src/components/comments/CommentThread.vue +250 -0
- package/src/components/comments/commentBody.ts +185 -0
- package/src/components/comments/commentLevels.ts +139 -0
- package/src/components/comments/commentNode.ts +35 -0
- package/src/components/comments/composer.ts +20 -0
- package/src/components/comments/index.ts +29 -0
- package/src/components/confirm-dialog/ConfirmDialog.vue +153 -0
- package/src/components/confirm-dialog/index.ts +1 -0
- package/src/components/containers/Box.vue +42 -0
- package/src/components/containers/Section.vue +88 -0
- package/src/components/containers/SectionAction.vue +17 -0
- package/src/components/containers/SectionContent.vue +14 -0
- package/src/components/containers/SectionDescription.vue +14 -0
- package/src/components/containers/SectionHeader.vue +22 -0
- package/src/components/containers/SectionTitle.vue +17 -0
- package/src/components/containers/index.ts +9 -0
- package/src/components/data-table/ColumnMenu.vue +241 -0
- package/src/components/data-table/DataTable.vue +447 -0
- package/src/components/data-table/ExpandCaret.vue +34 -0
- package/src/components/data-table/SortableHead.vue +184 -0
- package/src/components/data-table/TableLoadingRow.vue +13 -0
- package/src/components/data-table/TableProgressRow.vue +26 -0
- package/src/components/data-table/columns.ts +13 -0
- package/src/components/data-table/index.ts +3 -0
- package/src/components/data-table/pinned.ts +19 -0
- package/src/components/data-table/rowActivation.ts +14 -0
- package/src/components/data-table/sort.ts +13 -0
- package/src/components/data-table/types.ts +23 -0
- package/src/components/date-picker/CalendarPanel.vue +432 -0
- package/src/components/date-picker/DateField.vue +293 -0
- package/src/components/date-picker/DatePicker.vue +147 -0
- package/src/components/date-picker/UntilDatePicker.vue +96 -0
- package/src/components/date-picker/dateFieldGuard.ts +87 -0
- package/src/components/date-picker/index.ts +4 -0
- package/src/components/date-picker/useDateField.ts +37 -0
- package/src/components/date-range-picker/DateRangePicker.vue +247 -0
- package/src/components/date-range-picker/index.ts +1 -0
- package/src/components/date-time-picker/DateTimePicker.vue +291 -0
- package/src/components/date-time-picker/index.ts +1 -0
- package/src/components/dialog/Dialog.vue +250 -0
- package/src/components/dialog/DialogSurface.vue +214 -0
- package/src/components/dialog/dialogEdges.ts +65 -0
- package/src/components/dialog/dialogSizes.ts +35 -0
- package/src/components/dialog/index.ts +12 -0
- package/src/components/dialog/toastHost.ts +18 -0
- package/src/components/dropdown/Dropdown.vue +101 -0
- package/src/components/dropdown/DropdownItems.vue +154 -0
- package/src/components/dropdown/dropdown.ts +64 -0
- package/src/components/dropdown/index.ts +2 -0
- package/src/components/file-preview/FilePreview.vue +78 -0
- package/src/components/file-preview/index.ts +1 -0
- package/src/components/file-upload/FileUpload.vue +234 -0
- package/src/components/file-upload/index.ts +1 -0
- package/src/components/filter-check-menu/FilterCheckMenu.vue +562 -0
- package/src/components/filter-check-menu/filterCheckOption.ts +10 -0
- package/src/components/filter-check-menu/index.ts +2 -0
- package/src/components/form-field/FormField.vue +74 -0
- package/src/components/form-field/index.ts +2 -0
- package/src/components/form-field/types.ts +5 -0
- package/src/components/frames/FrameCentred.vue +137 -0
- package/src/components/frames/FrameSidebar.vue +113 -0
- package/src/components/frames/FrameSplit.vue +109 -0
- package/src/components/frames/index.ts +3 -0
- package/src/components/icon/BellIcon.vue +27 -0
- package/src/components/icon/BoldIcon.vue +31 -0
- package/src/components/icon/CalendarDaysIcon.vue +33 -0
- package/src/components/icon/CheckIcon.vue +31 -0
- package/src/components/icon/ChevronDownIcon.vue +30 -0
- package/src/components/icon/ChevronLeftIcon.vue +31 -0
- package/src/components/icon/ChevronRightIcon.vue +31 -0
- package/src/components/icon/ChevronUpIcon.vue +30 -0
- package/src/components/icon/CircleAlertIcon.vue +29 -0
- package/src/components/icon/ClockIcon.vue +31 -0
- package/src/components/icon/Columns3Icon.vue +32 -0
- package/src/components/icon/FlipHorizontalIcon.vue +29 -0
- package/src/components/icon/ItalicIcon.vue +28 -0
- package/src/components/icon/LinkIcon.vue +27 -0
- package/src/components/icon/ListIcon.vue +29 -0
- package/src/components/icon/ListOrderedIcon.vue +28 -0
- package/src/components/icon/PenLineIcon.vue +31 -0
- package/src/components/icon/PlusIcon.vue +28 -0
- package/src/components/icon/RotateCcwIcon.vue +28 -0
- package/src/components/icon/RotateCwIcon.vue +28 -0
- package/src/components/icon/SearchIcon.vue +31 -0
- package/src/components/icon/StarIcon.vue +29 -0
- package/src/components/icon/TriangleAlertIcon.vue +29 -0
- package/src/components/icon/UnderlineIcon.vue +27 -0
- package/src/components/icon/Undo2Icon.vue +28 -0
- package/src/components/icon/XIcon.vue +31 -0
- package/src/components/icon/ZoomInIcon.vue +30 -0
- package/src/components/icon/ZoomOutIcon.vue +29 -0
- package/src/components/icon/index.ts +37 -0
- package/src/components/icon-picker/IconPicker.vue +560 -0
- package/src/components/icon-picker/index.ts +1 -0
- package/src/components/image-crop-dialog/CropRatioRow.vue +132 -0
- package/src/components/image-crop-dialog/CropVariantStrip.vue +277 -0
- package/src/components/image-crop-dialog/ImageCropDialog.vue +1541 -0
- package/src/components/image-crop-dialog/index.ts +16 -0
- package/src/components/image-upload/ImageUpload.vue +345 -0
- package/src/components/image-upload/index.ts +2 -0
- package/src/components/input/Input.vue +48 -0
- package/src/components/input/index.ts +1 -0
- package/src/components/keycap/Keycap.vue +49 -0
- package/src/components/keycap/index.ts +1 -0
- package/src/components/label/Label.vue +26 -0
- package/src/components/label/index.ts +1 -0
- package/src/components/menu/MenuCheckboxItem.vue +63 -0
- package/src/components/menu/MenuContent.vue +45 -0
- package/src/components/menu/MenuGroup.vue +22 -0
- package/src/components/menu/MenuItem.vue +34 -0
- package/src/components/menu/MenuLabel.vue +22 -0
- package/src/components/menu/MenuRadioGroup.vue +22 -0
- package/src/components/menu/MenuRadioItem.vue +50 -0
- package/src/components/menu/MenuRoot.vue +25 -0
- package/src/components/menu/MenuSeparator.vue +27 -0
- package/src/components/menu/MenuSub.vue +29 -0
- package/src/components/menu/MenuSubContent.vue +48 -0
- package/src/components/menu/MenuSubTrigger.vue +49 -0
- package/src/components/menu/MenuTrigger.vue +22 -0
- package/src/components/menu/index.ts +20 -0
- package/src/components/menu/menuClasses.ts +74 -0
- package/src/components/morph-select/MorphSelect.vue +150 -0
- package/src/components/morph-select/index.ts +1 -0
- package/src/components/nav/NavFlyout.vue +343 -0
- package/src/components/nav/NavGroup.vue +306 -0
- package/src/components/nav/NavItem.vue +243 -0
- package/src/components/nav/NavNodes.ts +66 -0
- package/src/components/nav/NavSection.vue +105 -0
- package/src/components/nav/NavSidebar.vue +137 -0
- package/src/components/nav/index.ts +5 -0
- package/src/components/nav/navChain.ts +112 -0
- package/src/components/nav/navClasses.ts +229 -0
- package/src/components/nav/navNode.ts +10 -0
- package/src/components/nav/navRegistry.ts +24 -0
- package/src/components/notification-list/NotificationList.vue +314 -0
- package/src/components/notification-list/index.ts +2 -0
- package/src/components/notification-list/notifications.ts +21 -0
- package/src/components/pagination/Pagination.vue +296 -0
- package/src/components/pagination/index.ts +1 -0
- package/src/components/pin-field/PinField.vue +332 -0
- package/src/components/pin-field/index.ts +1 -0
- package/src/components/popover-panel/PopoverPanel.vue +115 -0
- package/src/components/popover-panel/index.ts +5 -0
- package/src/components/rating/Rating.vue +201 -0
- package/src/components/rating/index.ts +1 -0
- package/src/components/record-avatar/RecordAvatar.vue +76 -0
- package/src/components/record-avatar/index.ts +1 -0
- package/src/components/result-window/ResultWindow.vue +399 -0
- package/src/components/result-window/index.ts +2 -0
- package/src/components/result-window/results.ts +75 -0
- package/src/components/rich-editor/RichEditor.vue +370 -0
- package/src/components/rich-editor/RichEditorLinkDialog.vue +133 -0
- package/src/components/rich-editor/index.ts +8 -0
- package/src/components/row-actions/RowActions.vue +262 -0
- package/src/components/row-actions/index.ts +2 -0
- package/src/components/row-actions/rowActions.ts +44 -0
- package/src/components/search-select/SearchSelect.vue +599 -0
- package/src/components/search-select/index.ts +2 -0
- package/src/components/search-select/types.ts +14 -0
- package/src/components/segmented-choice/SegmentedChoice.vue +136 -0
- package/src/components/segmented-choice/index.ts +2 -0
- package/src/components/segmented-choice/segmentedOption.ts +6 -0
- package/src/components/select/Select.vue +18 -0
- package/src/components/select/SelectContent.vue +73 -0
- package/src/components/select/SelectGroup.vue +21 -0
- package/src/components/select/SelectItem.vue +47 -0
- package/src/components/select/SelectItemText.vue +12 -0
- package/src/components/select/SelectLabel.vue +17 -0
- package/src/components/select/SelectScrollDownButton.vue +36 -0
- package/src/components/select/SelectScrollUpButton.vue +36 -0
- package/src/components/select/SelectSeparator.vue +19 -0
- package/src/components/select/SelectTrigger.vue +52 -0
- package/src/components/select/SelectValue.vue +12 -0
- package/src/components/select/index.ts +11 -0
- package/src/components/session/IdleTimer.vue +71 -0
- package/src/components/session/SessionDialogs.vue +177 -0
- package/src/components/session/index.ts +2 -0
- package/src/components/split-button/SplitButton.vue +122 -0
- package/src/components/split-button/index.ts +2 -0
- package/src/components/split-button/splitButtonItem.ts +7 -0
- package/src/components/switch/Switch.vue +60 -0
- package/src/components/switch/index.ts +1 -0
- package/src/components/table/Table.vue +51 -0
- package/src/components/table/TableBody.vue +14 -0
- package/src/components/table/TableCaption.vue +17 -0
- package/src/components/table/TableCell.vue +22 -0
- package/src/components/table/TableEmpty.vue +72 -0
- package/src/components/table/TableFooter.vue +17 -0
- package/src/components/table/TableHead.vue +22 -0
- package/src/components/table/TableHeader.vue +14 -0
- package/src/components/table/TableRow.vue +22 -0
- package/src/components/table/index.ts +9 -0
- package/src/components/tabs/Tabs.vue +173 -0
- package/src/components/tabs/index.ts +2 -0
- package/src/components/tabs/tabItem.ts +12 -0
- package/src/components/textarea/LimitedTextarea.vue +81 -0
- package/src/components/textarea/TextLimitCounter.vue +107 -0
- package/src/components/textarea/Textarea.vue +42 -0
- package/src/components/textarea/index.ts +4 -0
- package/src/components/textarea/textLimit.ts +43 -0
- package/src/components/time-picker/TimePicker.vue +522 -0
- package/src/components/time-picker/index.ts +1 -0
- package/src/components/toast/ToastHost.vue +276 -0
- package/src/components/toast/index.ts +1 -0
- package/src/components/update-notice/UpdateNotice.vue +103 -0
- package/src/components/update-notice/index.ts +1 -0
- package/src/components/user-menu/UserMenu.vue +154 -0
- package/src/components/user-menu/index.ts +1 -0
- package/src/index.ts +182 -0
- package/src/lib/cn.ts +21 -0
- package/src/lib/panelFocus.ts +65 -0
- package/src/lib/sessionMonitor.ts +390 -0
- package/src/lib/slotContent.ts +17 -0
- package/src/lib/updateCheck.ts +133 -0
- package/src/styles.css +82 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/** Elements that are content without carrying any text of their own. */
|
|
2
|
+
const EMBEDDED_TAGS = new Set([
|
|
3
|
+
'img',
|
|
4
|
+
'video',
|
|
5
|
+
'audio',
|
|
6
|
+
'iframe',
|
|
7
|
+
'picture',
|
|
8
|
+
'svg',
|
|
9
|
+
'canvas',
|
|
10
|
+
'object',
|
|
11
|
+
'embed',
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
/** Elements whose children are not markup and are not shown to a reader. */
|
|
15
|
+
const RAW_TEXT_TAGS = new Set(['script', 'style']);
|
|
16
|
+
|
|
17
|
+
/** The start of a tag: `<name`, `</name`. A hyphen is part of the name, so `<img-x>` is not an img. */
|
|
18
|
+
const TAG_NAME = /^<\/?([a-zA-Z][a-zA-Z0-9-]*)/;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Named references that render as a space. Case-sensitive on purpose: HTML's named references
|
|
22
|
+
* are, and `&NBSP;` is not one of them — a reader sees those six letters.
|
|
23
|
+
*/
|
|
24
|
+
const NAMED_SPACE: Readonly<Record<string, string>> = {
|
|
25
|
+
Tab: '\t',
|
|
26
|
+
NewLine: '\n',
|
|
27
|
+
nbsp: '\u00a0',
|
|
28
|
+
NonBreakingSpace: '\u00a0',
|
|
29
|
+
ensp: '\u2002',
|
|
30
|
+
emsp: '\u2003',
|
|
31
|
+
numsp: '\u2007',
|
|
32
|
+
puncsp: '\u2008',
|
|
33
|
+
thinsp: '\u2009',
|
|
34
|
+
hairsp: '\u200a',
|
|
35
|
+
ZeroWidthSpace: '\u200b',
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Everything that occupies no visible width.
|
|
40
|
+
*
|
|
41
|
+
* `\s` already covers ASCII whitespace, every space separator, the line and paragraph
|
|
42
|
+
* separators and the byte-order mark. What it leaves are the zero-width characters, which are
|
|
43
|
+
* the format category: `trim()` does not strip one, so a body of a single zero-width space
|
|
44
|
+
* would otherwise read as content.
|
|
45
|
+
*/
|
|
46
|
+
const BLANK_CHARS = /[\s\p{Cf}]/gu;
|
|
47
|
+
|
|
48
|
+
/** What a scan of the markup found: the text in the element flow, and whether anything is embedded. */
|
|
49
|
+
interface Scan {
|
|
50
|
+
text: string;
|
|
51
|
+
embedded: boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Walk the markup once, collecting the text a reader would see and noting any embedded element.
|
|
56
|
+
*
|
|
57
|
+
* It is a scan rather than a pair of regexes because the regexes were wrong in three ways that
|
|
58
|
+
* a test with no `>` in an attribute could not see: `<[^>]*>` ends a tag at the first `>`, so
|
|
59
|
+
* `<p title="a > b">` left `b">` behind as text; a search for `<img` in the raw string fired on
|
|
60
|
+
* `<a title="<img>">` and on a comment holding the same four characters; and nothing dropped a
|
|
61
|
+
* comment's or a script's contents. It is not a parser — it builds no tree, and needs none.
|
|
62
|
+
*/
|
|
63
|
+
function scan(html: string): Scan {
|
|
64
|
+
let text = '';
|
|
65
|
+
let embedded = false;
|
|
66
|
+
let at = 0;
|
|
67
|
+
|
|
68
|
+
while (at < html.length) {
|
|
69
|
+
const open = html.indexOf('<', at);
|
|
70
|
+
|
|
71
|
+
if (open === -1) {
|
|
72
|
+
text += html.slice(at);
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
text += html.slice(at, open);
|
|
77
|
+
|
|
78
|
+
if (html.startsWith('<!--', open)) {
|
|
79
|
+
const end = html.indexOf('-->', open + 4);
|
|
80
|
+
|
|
81
|
+
at = end === -1 ? html.length : end + 3;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (html.startsWith('<!', open) || html.startsWith('<?', open)) {
|
|
86
|
+
const end = html.indexOf('>', open + 2);
|
|
87
|
+
|
|
88
|
+
at = end === -1 ? html.length : end + 1;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const name = TAG_NAME.exec(html.slice(open));
|
|
93
|
+
|
|
94
|
+
if (name === null) {
|
|
95
|
+
// A `<` that starts no tag is text, which is how `3 < 5` reads.
|
|
96
|
+
text += '<';
|
|
97
|
+
at = open + 1;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const tag = name[1]!.toLowerCase();
|
|
102
|
+
|
|
103
|
+
if (EMBEDDED_TAGS.has(tag)) {
|
|
104
|
+
embedded = true;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Find this tag's end, stepping over any `>` inside a quoted attribute value.
|
|
108
|
+
let cursor = open + name[0].length;
|
|
109
|
+
let quote = '';
|
|
110
|
+
|
|
111
|
+
while (cursor < html.length) {
|
|
112
|
+
const char = html[cursor]!;
|
|
113
|
+
|
|
114
|
+
if (quote !== '') {
|
|
115
|
+
if (char === quote) {
|
|
116
|
+
quote = '';
|
|
117
|
+
}
|
|
118
|
+
} else if (char === '"' || char === "'") {
|
|
119
|
+
quote = char;
|
|
120
|
+
} else if (char === '>') {
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
cursor += 1;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
at = cursor + 1;
|
|
127
|
+
|
|
128
|
+
// A raw-text element's children are not markup: skip to its closing tag.
|
|
129
|
+
if (RAW_TEXT_TAGS.has(tag) && !name[0].startsWith('</')) {
|
|
130
|
+
const close = html.toLowerCase().indexOf(`</${tag}`, at);
|
|
131
|
+
|
|
132
|
+
at = close === -1 ? html.length : close;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return { text, embedded };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function codePoint(value: number): string | undefined {
|
|
140
|
+
return Number.isInteger(value) && value >= 0 && value <= 0x10ffff
|
|
141
|
+
? String.fromCodePoint(value)
|
|
142
|
+
: undefined;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Numeric and named references, enough of them to tell a space from a word. */
|
|
146
|
+
function decodeSpaces(text: string): string {
|
|
147
|
+
return text
|
|
148
|
+
.replace(
|
|
149
|
+
/&#[xX]([0-9a-fA-F]+);?/g,
|
|
150
|
+
(whole, hex: string) => codePoint(parseInt(hex, 16)) ?? whole,
|
|
151
|
+
)
|
|
152
|
+
.replace(/&#(\d+);?/g, (whole, digits: string) => codePoint(Number(digits)) ?? whole)
|
|
153
|
+
.replace(/&([a-zA-Z]+);?/g, (whole, name: string) => NAMED_SPACE[name] ?? whole);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Whether a comment body holds nothing a reader would see.
|
|
158
|
+
*
|
|
159
|
+
* **Why this is not `trim()`.** A rich editor's document is `<p></p>` before anything is typed,
|
|
160
|
+
* and that string is truthy — so a composer guarding with `body.trim()` posts an empty comment
|
|
161
|
+
* the moment somebody presses the button, which is what one of the two implementations this
|
|
162
|
+
* family replaces does today. The check has to read the markup.
|
|
163
|
+
*
|
|
164
|
+
* **Why it is not "has no text" either.** A comment whose whole content is one image carries no
|
|
165
|
+
* text and is not blank. So the rule is: no text in the element flow, AND no embedded element.
|
|
166
|
+
* Text that is not in the flow does not count — a `title` on a link, a comment, the body of a
|
|
167
|
+
* `<script>` — and neither does anything of zero visible width.
|
|
168
|
+
*
|
|
169
|
+
* It is a scan rather than a DOM parse on purpose: this runs on every keystroke's worth of model
|
|
170
|
+
* value, it must give the same answer on a server as in a browser, and the input is HTML the
|
|
171
|
+
* consumer has already sanitised.
|
|
172
|
+
*/
|
|
173
|
+
export function isBlankBody(html: string | null | undefined): boolean {
|
|
174
|
+
if (html === null || html === undefined) {
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const { text, embedded } = scan(html);
|
|
179
|
+
|
|
180
|
+
if (embedded) {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return decodeSpaces(text).replace(BLANK_CHARS, '') === '';
|
|
185
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { toneClasses, type Tone } from '../badge';
|
|
2
|
+
import type { SegmentedOption } from '../segmented-choice';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The visibility-level model: the mechanics the family owns, over a vocabulary the consumer
|
|
6
|
+
* declares.
|
|
7
|
+
*
|
|
8
|
+
* **Nothing here reads meaning out of a key or a label.** A level that leaves the organisation
|
|
9
|
+
* says so with `external`, and how far a level reaches is `reach`. Deriving either from a name
|
|
10
|
+
* is the defect this separation exists to prevent: one of the two implementations this family
|
|
11
|
+
* replaces picks a colour with `value.includes('internal')`, so renaming a level there changes
|
|
12
|
+
* what a reader sees and nothing says it did.
|
|
13
|
+
*
|
|
14
|
+
* Placeholder vocabulary only, everywhere in this package and in the playground. A tenant's own
|
|
15
|
+
* level names are not a design system's wording.
|
|
16
|
+
*/
|
|
17
|
+
export interface CommentLevel {
|
|
18
|
+
/** The consumer's own key. The family never reads meaning out of it. */
|
|
19
|
+
key: string;
|
|
20
|
+
/** What a reader sees. The consumer's words, never the package's. */
|
|
21
|
+
label: string;
|
|
22
|
+
/** How far it reaches. Lower is more private, so "wider than" is computable. */
|
|
23
|
+
reach: number;
|
|
24
|
+
/** True where the level leaves the organisation. This drives the warning — not the name. */
|
|
25
|
+
external?: boolean;
|
|
26
|
+
/** The marker's badge tone. Without one the family picks by position; see `levelTone`. */
|
|
27
|
+
tone?: Tone;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The narrowest level: the lowest `reach`, and **on a tie the earliest declared**.
|
|
32
|
+
*
|
|
33
|
+
* The tie-break is declaration order rather than key or label, because ordering by either would
|
|
34
|
+
* make renaming a level move a composer's default — a change of wording that silently changes
|
|
35
|
+
* who can read the next comment.
|
|
36
|
+
*/
|
|
37
|
+
export function narrowestLevel(levels: readonly CommentLevel[]): CommentLevel | undefined {
|
|
38
|
+
return levels.reduce<CommentLevel | undefined>(
|
|
39
|
+
(narrowest, level) =>
|
|
40
|
+
narrowest === undefined || level.reach < narrowest.reach ? level : narrowest,
|
|
41
|
+
undefined,
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The level with this key, or `undefined` — including for a key the consumer no longer declares.
|
|
47
|
+
*
|
|
48
|
+
* The `null`/`undefined` early return is not redundant with the comparison below it, though it
|
|
49
|
+
* looks it: a level object arriving from untyped data with no `key` of its own would otherwise
|
|
50
|
+
* match a missing key and be returned as the answer.
|
|
51
|
+
*/
|
|
52
|
+
export function levelByKey(
|
|
53
|
+
levels: readonly CommentLevel[],
|
|
54
|
+
key: string | null | undefined,
|
|
55
|
+
): CommentLevel | undefined {
|
|
56
|
+
return key === null || key === undefined
|
|
57
|
+
? undefined
|
|
58
|
+
: levels.find((level) => level.key === key);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The tone a level's marker draws. A declared `tone` wins. Otherwise it follows **position in
|
|
63
|
+
* reach order**: the narrowest is `purple`, the widest is `green`, everything between is `blue`,
|
|
64
|
+
* and a single level is `purple` — it is the narrowest, and nothing is wider than it.
|
|
65
|
+
*
|
|
66
|
+
* It is deliberately **not** derived from `external`. The warning is what `external` drives; a
|
|
67
|
+
* colour is not a warning, and a consumer whose widest level stays inside the house still wants
|
|
68
|
+
* its widest level to look like the end of the row. Where the two disagree, `tone` is the
|
|
69
|
+
* consumer's override.
|
|
70
|
+
*/
|
|
71
|
+
export function levelTone(levels: readonly CommentLevel[], level: CommentLevel): Tone {
|
|
72
|
+
if (level.tone !== undefined) {
|
|
73
|
+
return level.tone;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const reaches = levels.map((one) => one.reach);
|
|
77
|
+
const lowest = Math.min(...reaches, level.reach);
|
|
78
|
+
const highest = Math.max(...reaches, level.reach);
|
|
79
|
+
|
|
80
|
+
if (level.reach === lowest) {
|
|
81
|
+
return 'purple';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return level.reach === highest ? 'green' : 'blue';
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* A tone's **text** utilities, so an edge can draw the same ink as the badge beside it with
|
|
89
|
+
* `bg-current` instead of restating a colour.
|
|
90
|
+
*
|
|
91
|
+
* It reads `badge/index.ts`'s shipped map rather than holding a second copy: a tone added there
|
|
92
|
+
* cannot leave a level edge with no colour, and a palette change moves both at once. The classes
|
|
93
|
+
* themselves are written literally in that file, which is what makes Tailwind compile them — a
|
|
94
|
+
* class this function returned but nobody wrote would resolve to nothing.
|
|
95
|
+
*/
|
|
96
|
+
export function toneInk(tone: Tone): string {
|
|
97
|
+
return toneClasses[tone]
|
|
98
|
+
.split(/\s+/)
|
|
99
|
+
.filter((token) => {
|
|
100
|
+
const utility = token.slice(token.lastIndexOf(':') + 1);
|
|
101
|
+
|
|
102
|
+
return utility.startsWith('text-');
|
|
103
|
+
})
|
|
104
|
+
.join(' ');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The options a level switch draws, in the consumer's declaration order.
|
|
109
|
+
*
|
|
110
|
+
* **Not the thread's filter**, which builds its own list: a filter needs an "all levels" entry
|
|
111
|
+
* that is not a level, and it disables nothing — a reader may filter to any level whether or not
|
|
112
|
+
* a reply could reach it.
|
|
113
|
+
*
|
|
114
|
+
* `ceiling` is the reach a reply may not exceed — the level of the comment it answers. Omit it
|
|
115
|
+
* for a new comment, where nothing constrains the choice.
|
|
116
|
+
*
|
|
117
|
+
* **`null` means the ceiling is unknown**, which happens when the comment being answered names a
|
|
118
|
+
* level the consumer no longer declares. Then every level but the narrowest is disabled. Unknown
|
|
119
|
+
* must not quietly mean "no ceiling": that is exactly the silent escalation the guard exists to
|
|
120
|
+
* stop, and the narrowest level is reachable whatever the parent's was.
|
|
121
|
+
*
|
|
122
|
+
* A NUMBER below every declared reach disables every level, the narrowest included. That is not
|
|
123
|
+
* reachable through the intended path — a numeric ceiling is a declared level's own `reach`, so
|
|
124
|
+
* some level always clears it — and a caller that computes one another way gets what it asked
|
|
125
|
+
* for rather than a silent floor.
|
|
126
|
+
*/
|
|
127
|
+
export function levelOptions(
|
|
128
|
+
levels: readonly CommentLevel[],
|
|
129
|
+
ceiling?: number | null,
|
|
130
|
+
): SegmentedOption[] {
|
|
131
|
+
const narrowest = ceiling === null ? narrowestLevel(levels) : undefined;
|
|
132
|
+
|
|
133
|
+
return levels.map((level) => ({
|
|
134
|
+
value: level.key,
|
|
135
|
+
label: level.label,
|
|
136
|
+
disabled:
|
|
137
|
+
ceiling === null ? level !== narrowest : ceiling !== undefined && level.reach > ceiling,
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Tone } from '../badge';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* One comment as a consumer hands it over, with at most one level of answers.
|
|
5
|
+
*
|
|
6
|
+
* It is a plain data shape, not a class and not a store: `CommentThread` reads it and draws it.
|
|
7
|
+
* Loading, paging, read state, permissions and masking stay with the consumer (ADR 0017), so
|
|
8
|
+
* there is no `canEdit`, no `masked` and no `page` here.
|
|
9
|
+
*/
|
|
10
|
+
export interface CommentNode {
|
|
11
|
+
id: string | number;
|
|
12
|
+
author: string;
|
|
13
|
+
initials?: string;
|
|
14
|
+
avatarSrc?: string | null;
|
|
15
|
+
/** HTML. **The consumer sanitises it** — see `CommentMessage`'s own contract. */
|
|
16
|
+
body?: string;
|
|
17
|
+
/** Already formatted, by the consumer. */
|
|
18
|
+
timestamp?: string;
|
|
19
|
+
/** The machine value for `<time datetime>`. */
|
|
20
|
+
datetime?: string;
|
|
21
|
+
role?: string;
|
|
22
|
+
roleTone?: Tone;
|
|
23
|
+
/**
|
|
24
|
+
* The key of a level in the thread's `levels`. A key that is not in that list draws no
|
|
25
|
+
* marker at all: the server offered the level once and the consumer's list has moved on,
|
|
26
|
+
* and a marker nobody can name is worse than none.
|
|
27
|
+
*/
|
|
28
|
+
levelKey?: string;
|
|
29
|
+
unread?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* **One level deep.** An answer's own `answers` are not drawn, because neither of the two
|
|
32
|
+
* implementations this family replaces draws a second level and the suite pins that.
|
|
33
|
+
*/
|
|
34
|
+
answers?: CommentNode[];
|
|
35
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// The comment composer's door (ADR 0014), reached as `@noix-dev/brix-vue/comment-composer`.
|
|
2
|
+
//
|
|
3
|
+
// It is behind a door for the reason `ImageUpload` is: not because it carries a library itself,
|
|
4
|
+
// but because it statically imports a family that does. `CommentComposer` renders `RichEditor`,
|
|
5
|
+
// which carries `@tiptap/vue-3`, `@tiptap/starter-kit` and `@tiptap/extension-link` as optional
|
|
6
|
+
// peers, and `pnpm proof` fails any module of the root barrel whose graph reaches that family.
|
|
7
|
+
// Proven rather than assumed: exporting this component from `src/index.ts` on purpose reddens
|
|
8
|
+
// that gate, naming both module ids.
|
|
9
|
+
//
|
|
10
|
+
// `CommentMessage` and `CommentThread` reach no library and stay in the barrel, the way
|
|
11
|
+
// `FileUpload` does beside `ImageUpload`.
|
|
12
|
+
//
|
|
13
|
+
// **One name, and no prop types beside it**, though the plan said "plus the prop types". They
|
|
14
|
+
// are not needed here: `CommentLevel` and `CommentNode` are exported from the root barrel, and
|
|
15
|
+
// a type-only import compiles away, so a consumer behind this door names them from `@noix-dev/brix-vue`
|
|
16
|
+
// without any module of this family's graph reaching their bundle. `date-picker`'s door exports
|
|
17
|
+
// `DateFieldGuard` because that whole family is behind a door and the barrel carries none of it
|
|
18
|
+
// — not a precedent for re-exporting a type the barrel already has. The narrower door is also
|
|
19
|
+
// the one `entry.test.ts` holds to an exact key list.
|
|
20
|
+
export { default as CommentComposer } from './CommentComposer.vue';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// The comment family.
|
|
2
|
+
//
|
|
3
|
+
// **Reached from `src/index.ts`, which is one of the two things that make this directory a
|
|
4
|
+
// family** — the other is the `exports` map entry for `./comment-composer` pointing into it, so
|
|
5
|
+
// `family-facts.mjs` would find this directory through either door alone. A directory becomes a
|
|
6
|
+
// family the moment the public surface reaches it, and four things move together when it does:
|
|
7
|
+
// `facts.generated.json` gains an entry, the catalogue spec's three counted sentences each gain
|
|
8
|
+
// a family, `catalogue.ts` needs a shipped entry, and `catalogue.test.ts` holds that entry to a
|
|
9
|
+
// route and a page. Exporting from here alone reddens `numbers:check` and `catalogue.test.ts`
|
|
10
|
+
// with no page to show for it, which is why the export, the page, the route and the counts
|
|
11
|
+
// arrived in one commit rather than one per artefact.
|
|
12
|
+
//
|
|
13
|
+
// `CommentComposer` is deliberately NOT here either: it renders `RichEditor`, which
|
|
14
|
+
// carries three editor packages as optional peers, and `pnpm proof` fails any module of the root
|
|
15
|
+
// barrel whose graph reaches that family (ADR 0014). It ships from `./composer.ts`, behind
|
|
16
|
+
// `@noix-dev/brix-vue/comment-composer`, the way `ImageUpload` ships behind its own door for importing
|
|
17
|
+
// the cropper dialog while `FileUpload` stays in the barrel.
|
|
18
|
+
export { default as CommentMessage } from './CommentMessage.vue';
|
|
19
|
+
export { default as CommentThread } from './CommentThread.vue';
|
|
20
|
+
export type { CommentNode } from './commentNode';
|
|
21
|
+
export {
|
|
22
|
+
levelByKey,
|
|
23
|
+
levelOptions,
|
|
24
|
+
levelTone,
|
|
25
|
+
narrowestLevel,
|
|
26
|
+
toneInk,
|
|
27
|
+
type CommentLevel,
|
|
28
|
+
} from './commentLevels';
|
|
29
|
+
export { isBlankBody } from './commentBody';
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useUiLabels } from '@noix-dev/brix-core';
|
|
3
|
+
import { type ComponentPublicInstance, ref } from 'vue';
|
|
4
|
+
import { Button } from '../button';
|
|
5
|
+
import { Dialog } from '../dialog';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The one question asked before something that is hard to take back.
|
|
9
|
+
*
|
|
10
|
+
* Deleting and changing a record's state both go through it, which is why the tone is a prop
|
|
11
|
+
* rather than two components: the shape of the question is the same, only the colour of the
|
|
12
|
+
* answer differs.
|
|
13
|
+
*
|
|
14
|
+
* It does not close itself on confirm. The caller does, once the server has agreed: a refusal
|
|
15
|
+
* ("this job still has parts on order") has to be able to keep the dialog open and say so,
|
|
16
|
+
* with the reader's decision still on screen. `error` is where that refusal is shown.
|
|
17
|
+
*
|
|
18
|
+
* COMPOSITION. This is `Dialog` and nothing else: the overlay, the portal, the focus trap and
|
|
19
|
+
* the stacking are its, and a class passed here reaches its panel. Three of its props are used
|
|
20
|
+
* on purpose.
|
|
21
|
+
*
|
|
22
|
+
* - `hideClose` — the dialog is answered with its own two buttons, so there is no cross.
|
|
23
|
+
* - `persistent`, **while `busy`** — Escape and a press outside must not dismiss a dialog whose
|
|
24
|
+
* action is in flight, because the refusal that might come back would have nowhere to show.
|
|
25
|
+
* When nothing is running they still dismiss it, which is the same as Cancel.
|
|
26
|
+
* - `role="alertdialog"` when `tone` is `danger`: a destructive confirmation interrupts, and an
|
|
27
|
+
* alert dialog is announced as one. It rides in as an attribute (`Dialog` has no `role`
|
|
28
|
+
* prop; reka binds its own `dialog` before the consumer's attributes, so this wins). A
|
|
29
|
+
* neutral confirmation keeps reka's `dialog`.
|
|
30
|
+
*
|
|
31
|
+
* FOCUS. Enter must not delete. reka hands the focus to the first focusable element of the
|
|
32
|
+
* content when it opens, and `Dialog` forwards that event; here it is cancelled and the focus
|
|
33
|
+
* goes to Cancel, the way out. That does not depend on where the buttons sit in the markup:
|
|
34
|
+
* reordering the footer cannot make the destructive button the default.
|
|
35
|
+
*
|
|
36
|
+
* COLOUR. Everything here is a role, measured against the panel (`--popover`), which in dark is
|
|
37
|
+
* *lighter* than the page, so no figure taken against `--background` applies:
|
|
38
|
+
* - the warning band is `--destructive` at full strength as its edge (4.90-6.86:1 against the
|
|
39
|
+
* panel; the source's pale edge, and a halved one, measure 1.5-2.1:1) around a 10% wash of the
|
|
40
|
+
* same role carrying `--destructive-on-wash` ink (4.63-5.88:1). The wash is 10% in both
|
|
41
|
+
* modes: 20% would pull the ink to 3.83-4.91:1 in dark;
|
|
42
|
+
* - the refusal is `--destructive` text on the bare panel (4.90-6.86:1);
|
|
43
|
+
* - the subject sits in a `--muted` tint inside a `--border` hairline, which is decoration
|
|
44
|
+
* (1.23-1.37:1) around text that carries the information (`--foreground`, 13.5-19.3:1).
|
|
45
|
+
* - the destructive button is `Button`'s own `destructive` variant with no colour of its own,
|
|
46
|
+
* so it looks the same here as on a page. Its resting ink is 4.63-5.88:1 over the panel
|
|
47
|
+
* (hover is the variant's known-failing, parked state).
|
|
48
|
+
* No `dark:` utility is written in this file; the roles already flip.
|
|
49
|
+
*/
|
|
50
|
+
const props = withDefaults(
|
|
51
|
+
defineProps<{
|
|
52
|
+
open: boolean;
|
|
53
|
+
/** The question, as a question: "Delete the repair job?" */
|
|
54
|
+
title: string;
|
|
55
|
+
/** What is acted on, named. Never "this item". */
|
|
56
|
+
subject?: string;
|
|
57
|
+
/** One line on what happens. */
|
|
58
|
+
description?: string;
|
|
59
|
+
/** A consequence the title cannot carry, set off in its own band. */
|
|
60
|
+
warning?: string;
|
|
61
|
+
/** Defaults to the `confirm` label of the contract. */
|
|
62
|
+
confirmLabel?: string;
|
|
63
|
+
/** Defaults to the `cancel` label of the contract. */
|
|
64
|
+
cancelLabel?: string;
|
|
65
|
+
/** `danger` paints the confirm button destructive and makes the dialog an alert dialog. */
|
|
66
|
+
tone?: 'default' | 'danger';
|
|
67
|
+
/** Locks both buttons so a second click cannot send a second request. */
|
|
68
|
+
busy?: boolean;
|
|
69
|
+
/** A refusal from the server. Shown in place; the dialog stays open. */
|
|
70
|
+
error?: string | null;
|
|
71
|
+
}>(),
|
|
72
|
+
{ tone: 'default' },
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const emit = defineEmits<{
|
|
76
|
+
(e: 'update:open', value: boolean): void;
|
|
77
|
+
(e: 'confirm'): void;
|
|
78
|
+
}>();
|
|
79
|
+
|
|
80
|
+
const labels = useUiLabels();
|
|
81
|
+
|
|
82
|
+
/** A component ref, so the element is behind `$el`. */
|
|
83
|
+
const cancel = ref<ComponentPublicInstance | null>(null);
|
|
84
|
+
|
|
85
|
+
function focusTheWayOut(event: Event): void {
|
|
86
|
+
event.preventDefault();
|
|
87
|
+
(cancel.value?.$el as HTMLElement | undefined)?.focus();
|
|
88
|
+
}
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
<template>
|
|
92
|
+
<Dialog
|
|
93
|
+
:open="props.open"
|
|
94
|
+
:title="props.title"
|
|
95
|
+
:description="props.description ?? props.title"
|
|
96
|
+
:persistent="props.busy"
|
|
97
|
+
hide-close
|
|
98
|
+
size="md"
|
|
99
|
+
v-bind="props.tone === 'danger' ? { role: 'alertdialog' } : {}"
|
|
100
|
+
@update:open="(v: boolean) => emit('update:open', v)"
|
|
101
|
+
@open-auto-focus="focusTheWayOut"
|
|
102
|
+
>
|
|
103
|
+
<div class="flex flex-col gap-2.5">
|
|
104
|
+
<p v-if="props.description" class="text-muted-foreground text-sm">
|
|
105
|
+
{{ props.description }}
|
|
106
|
+
</p>
|
|
107
|
+
<p
|
|
108
|
+
v-if="props.subject"
|
|
109
|
+
data-testid="confirm-dialog-subject"
|
|
110
|
+
class="border-border bg-muted/30 rounded-[10px] border px-2.5 py-2 text-sm font-semibold"
|
|
111
|
+
>
|
|
112
|
+
{{ props.subject }}
|
|
113
|
+
</p>
|
|
114
|
+
<p
|
|
115
|
+
v-if="props.warning"
|
|
116
|
+
data-testid="confirm-dialog-warning"
|
|
117
|
+
class="border-destructive bg-destructive/10 text-destructive-on-wash rounded-[10px] border px-2.5 py-1.5 text-xs"
|
|
118
|
+
>
|
|
119
|
+
{{ props.warning }}
|
|
120
|
+
</p>
|
|
121
|
+
<p
|
|
122
|
+
v-if="props.error"
|
|
123
|
+
role="alert"
|
|
124
|
+
data-testid="confirm-dialog-error"
|
|
125
|
+
class="text-destructive text-xs"
|
|
126
|
+
>
|
|
127
|
+
{{ props.error }}
|
|
128
|
+
</p>
|
|
129
|
+
</div>
|
|
130
|
+
|
|
131
|
+
<template #footer>
|
|
132
|
+
<Button
|
|
133
|
+
ref="cancel"
|
|
134
|
+
type="button"
|
|
135
|
+
variant="outline"
|
|
136
|
+
data-testid="confirm-dialog-cancel"
|
|
137
|
+
:disabled="props.busy"
|
|
138
|
+
@click="emit('update:open', false)"
|
|
139
|
+
>
|
|
140
|
+
{{ props.cancelLabel ?? labels.cancel }}
|
|
141
|
+
</Button>
|
|
142
|
+
<Button
|
|
143
|
+
type="button"
|
|
144
|
+
:variant="props.tone === 'danger' ? 'destructive' : 'default'"
|
|
145
|
+
data-testid="confirm-dialog-confirm"
|
|
146
|
+
:disabled="props.busy"
|
|
147
|
+
@click="emit('confirm')"
|
|
148
|
+
>
|
|
149
|
+
{{ props.confirmLabel ?? labels.confirm }}
|
|
150
|
+
</Button>
|
|
151
|
+
</template>
|
|
152
|
+
</Dialog>
|
|
153
|
+
</template>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ConfirmDialog } from './ConfirmDialog.vue';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* The plainest container in the package: a border, a radius, padding and the page surface, with
|
|
4
|
+
* no head and no divider.
|
|
5
|
+
*
|
|
6
|
+
* Two authorities, each fixing something different:
|
|
7
|
+
*
|
|
8
|
+
* - The approved design record (`docs/design/wave-3-layout.html`, "The containers") fixes WHAT a
|
|
9
|
+
* `Box` is: bordered, rounded, padded, with no head and no divider. That absence is what
|
|
10
|
+
* separates it from `Card`, which has a header, a footer and a ring. The record is a schematic
|
|
11
|
+
* drawn at reduced scale (9px radius, 11px/12px padding), so its figures are not shipping
|
|
12
|
+
* figures and are not used here.
|
|
13
|
+
* - `Card` fixes HOW BIG. Card is `rounded-xl` with `py-4` and `px-4` on its parts, so a `Box`
|
|
14
|
+
* beside a `Card` shares its radius and padding step (`rounded-xl`, `p-4`), though not its
|
|
15
|
+
* content inset: a `border border-border` line (the record's `1px solid var(--border)`) takes
|
|
16
|
+
* 1px of the padding where Card draws a foreground ring outside the box.
|
|
17
|
+
* - The record paints `.uibox` with `var(--background)`, the page surface, so `Box` carries
|
|
18
|
+
* `bg-background` where `Card` carries `bg-card`. On a tinted ground the two therefore differ.
|
|
19
|
+
*
|
|
20
|
+
* Border, radius and padding are fixed by the record, so none is a prop: `class`, merged through
|
|
21
|
+
* `cn`, is how a caller overrides one. There is no `size` step like Card's `data-[size=sm]`.
|
|
22
|
+
*
|
|
23
|
+
* `data-slot="box"` is deliberate. `form-section`, `page-head`, `page-identity`, `status-band`,
|
|
24
|
+
* `record-fields` and `collab-block` stay the application's markup (wave 2), and a container
|
|
25
|
+
* claiming one of those names would change the density axis of every consuming page.
|
|
26
|
+
*/
|
|
27
|
+
import type { HTMLAttributes } from 'vue';
|
|
28
|
+
import { cn } from '../../lib/cn';
|
|
29
|
+
|
|
30
|
+
const props = defineProps<{
|
|
31
|
+
class?: HTMLAttributes['class'];
|
|
32
|
+
}>();
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<template>
|
|
36
|
+
<div
|
|
37
|
+
data-slot="box"
|
|
38
|
+
:class="cn('border-border bg-background rounded-xl border p-4', props.class)"
|
|
39
|
+
>
|
|
40
|
+
<slot />
|
|
41
|
+
</div>
|
|
42
|
+
</template>
|