@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,337 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useUiLabels } from '@noix-dev/brix-core';
|
|
3
|
+
import { onClickOutside, useDebounceFn } from '@vueuse/core';
|
|
4
|
+
import { computed, nextTick, ref, useAttrs, useId, watch } from 'vue';
|
|
5
|
+
import type { HTMLAttributes } from 'vue';
|
|
6
|
+
import { cn } from '../../lib/cn';
|
|
7
|
+
import { XIcon } from '../icon';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A text field that searches a list and picks one entry from it. The list is the caller's:
|
|
11
|
+
* typing emits a debounced `search`, and `options` is whatever the caller answers with.
|
|
12
|
+
*
|
|
13
|
+
* It builds its own listbox rather than leaning on a headless library, so the keyboard is
|
|
14
|
+
* written out here: ArrowDown opens and moves down, ArrowUp moves up, Home and End jump,
|
|
15
|
+
* Enter chooses the highlighted option, Escape closes, and leaving the field closes. The
|
|
16
|
+
* field is always an `<input role="combobox">`, also while a value is chosen, so a keyboard
|
|
17
|
+
* can reach it and change the value without clearing it first.
|
|
18
|
+
*
|
|
19
|
+
* `id` and `aria-describedby` land on the input — which is what a `FormField` hands its
|
|
20
|
+
* control — and `class` on the outer box.
|
|
21
|
+
*/
|
|
22
|
+
defineOptions({ inheritAttrs: false });
|
|
23
|
+
|
|
24
|
+
interface Option {
|
|
25
|
+
id: number;
|
|
26
|
+
label: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const props = withDefaults(
|
|
30
|
+
defineProps<{
|
|
31
|
+
modelValue: number | null;
|
|
32
|
+
options: Option[];
|
|
33
|
+
/**
|
|
34
|
+
* A short caption inside the field, also its accessible name when it has no
|
|
35
|
+
* `FormField`.
|
|
36
|
+
*
|
|
37
|
+
* Read that second half as a warning, not a condition the component checks: it sets
|
|
38
|
+
* `aria-label` from this prop whenever it is given, and `aria-label` out-ranks a
|
|
39
|
+
* `<label for>`. So inside a `FormField` this silently replaces the field's visible
|
|
40
|
+
* label as the accessible name. Pass it only where there is no other label, or pass
|
|
41
|
+
* an `aria-label` of your own — that wins over this one.
|
|
42
|
+
*/
|
|
43
|
+
label?: string;
|
|
44
|
+
placeholder?: string;
|
|
45
|
+
/** Overrides the label contract's `noMatches` for this field's empty list. */
|
|
46
|
+
emptyText?: string;
|
|
47
|
+
loading?: boolean;
|
|
48
|
+
disabled?: boolean;
|
|
49
|
+
}>(),
|
|
50
|
+
{ placeholder: undefined, emptyText: undefined, loading: false, disabled: false },
|
|
51
|
+
);
|
|
52
|
+
const emit = defineEmits<{
|
|
53
|
+
(e: 'update:modelValue', id: number | null): void;
|
|
54
|
+
(e: 'search', term: string): void;
|
|
55
|
+
}>();
|
|
56
|
+
|
|
57
|
+
defineSlots<{
|
|
58
|
+
/** The glyph on the clear button. Defaults to the package's own cross. */
|
|
59
|
+
'clear-icon'?: () => unknown;
|
|
60
|
+
}>();
|
|
61
|
+
|
|
62
|
+
const labels = useUiLabels();
|
|
63
|
+
const attrs = useAttrs();
|
|
64
|
+
const rootAttrs = computed(() => ({ class: attrs.class, style: attrs.style }));
|
|
65
|
+
const inputAttrs = computed(() =>
|
|
66
|
+
Object.fromEntries(Object.entries(attrs).filter(([key]) => key !== 'class' && key !== 'style')),
|
|
67
|
+
);
|
|
68
|
+
/**
|
|
69
|
+
* `aria-invalid` is the one attribute that goes to two places. It has to be on the `<input>`,
|
|
70
|
+
* because that is the control assistive technology reads the state from — `inputAttrs` above
|
|
71
|
+
* already takes it there — and it has to be on the bordered wrapper, because that is the
|
|
72
|
+
* element the invalid edge is drawn on. Routing it only to the input, which is what this
|
|
73
|
+
* component did, left a field inside a `FormField` printing a red message with no red edge.
|
|
74
|
+
*/
|
|
75
|
+
const ariaInvalid = computed(() => attrs['aria-invalid'] as HTMLAttributes['aria-invalid']);
|
|
76
|
+
|
|
77
|
+
const listId = useId();
|
|
78
|
+
const root = ref<HTMLElement | null>(null);
|
|
79
|
+
const input = ref<HTMLInputElement | null>(null);
|
|
80
|
+
const open = ref(false);
|
|
81
|
+
const term = ref('');
|
|
82
|
+
const activeIndex = ref(-1);
|
|
83
|
+
|
|
84
|
+
const selectedLabel = computed(
|
|
85
|
+
() => props.options.find((o) => o.id === props.modelValue)?.label ?? '',
|
|
86
|
+
);
|
|
87
|
+
// While the list is open the field is for typing; closed, it shows what was chosen.
|
|
88
|
+
const shownValue = computed(() =>
|
|
89
|
+
open.value && !props.disabled ? term.value : selectedLabel.value,
|
|
90
|
+
);
|
|
91
|
+
const shownPlaceholder = computed(() =>
|
|
92
|
+
open.value && selectedLabel.value !== ''
|
|
93
|
+
? selectedLabel.value
|
|
94
|
+
: (props.placeholder ?? labels.value.search),
|
|
95
|
+
);
|
|
96
|
+
const showsList = computed(() => open.value && !props.disabled);
|
|
97
|
+
|
|
98
|
+
function optionId(option: Option): string {
|
|
99
|
+
return `${listId}-option-${option.id}`;
|
|
100
|
+
}
|
|
101
|
+
const activeDescendant = computed(() => {
|
|
102
|
+
const option = props.options[activeIndex.value];
|
|
103
|
+
return showsList.value && option !== undefined ? optionId(option) : undefined;
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const emitSearch = useDebounceFn((value: string) => emit('search', value), 250);
|
|
107
|
+
function onInput(event: Event): void {
|
|
108
|
+
const typed = (event.target as HTMLInputElement).value;
|
|
109
|
+
// Closed over a chosen value, the field is showing that value's label, and typing extends
|
|
110
|
+
// it. What the user means is a new search, so the label is taken back off. Doing it here,
|
|
111
|
+
// rather than on the key, also covers paste, composition and virtual keyboards.
|
|
112
|
+
const label = selectedLabel.value;
|
|
113
|
+
term.value =
|
|
114
|
+
!open.value && label !== '' && typed.startsWith(label) ? typed.slice(label.length) : typed;
|
|
115
|
+
open.value = true;
|
|
116
|
+
activeIndex.value = -1;
|
|
117
|
+
void emitSearch(term.value);
|
|
118
|
+
}
|
|
119
|
+
function show(): void {
|
|
120
|
+
if (props.disabled) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
open.value = true;
|
|
124
|
+
}
|
|
125
|
+
function close(): void {
|
|
126
|
+
open.value = false;
|
|
127
|
+
activeIndex.value = -1;
|
|
128
|
+
}
|
|
129
|
+
function pick(option: Option): void {
|
|
130
|
+
emit('update:modelValue', option.id);
|
|
131
|
+
close();
|
|
132
|
+
term.value = '';
|
|
133
|
+
}
|
|
134
|
+
function clear(): void {
|
|
135
|
+
emit('update:modelValue', null);
|
|
136
|
+
term.value = '';
|
|
137
|
+
// The button disappears with the value; keep the keyboard where it was.
|
|
138
|
+
input.value?.focus();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function move(to: number): void {
|
|
142
|
+
const last = props.options.length - 1;
|
|
143
|
+
if (last < 0) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
activeIndex.value = Math.min(Math.max(to, 0), last);
|
|
147
|
+
void nextTick(() => {
|
|
148
|
+
const option = props.options[activeIndex.value];
|
|
149
|
+
const el = option === undefined ? null : document.getElementById(optionId(option));
|
|
150
|
+
el?.scrollIntoView?.({ block: 'nearest' });
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function onKeydown(event: KeyboardEvent): void {
|
|
155
|
+
if (props.disabled) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
switch (event.key) {
|
|
159
|
+
case 'ArrowDown':
|
|
160
|
+
event.preventDefault();
|
|
161
|
+
if (!open.value) {
|
|
162
|
+
show();
|
|
163
|
+
const chosen = props.options.findIndex((o) => o.id === props.modelValue);
|
|
164
|
+
move(chosen >= 0 ? chosen : 0);
|
|
165
|
+
} else {
|
|
166
|
+
move(activeIndex.value + 1);
|
|
167
|
+
}
|
|
168
|
+
break;
|
|
169
|
+
case 'ArrowUp':
|
|
170
|
+
event.preventDefault();
|
|
171
|
+
if (!open.value) {
|
|
172
|
+
show();
|
|
173
|
+
move(props.options.length - 1);
|
|
174
|
+
} else {
|
|
175
|
+
move(activeIndex.value < 0 ? props.options.length - 1 : activeIndex.value - 1);
|
|
176
|
+
}
|
|
177
|
+
break;
|
|
178
|
+
case 'Home':
|
|
179
|
+
if (open.value) {
|
|
180
|
+
event.preventDefault();
|
|
181
|
+
move(0);
|
|
182
|
+
}
|
|
183
|
+
break;
|
|
184
|
+
case 'End':
|
|
185
|
+
if (open.value) {
|
|
186
|
+
event.preventDefault();
|
|
187
|
+
move(props.options.length - 1);
|
|
188
|
+
}
|
|
189
|
+
break;
|
|
190
|
+
case 'Enter':
|
|
191
|
+
if (open.value) {
|
|
192
|
+
// An open list owns Enter, so it never submits the form around it by accident.
|
|
193
|
+
//
|
|
194
|
+
// And Enter acts on the **active** option and on nothing else, so on a list
|
|
195
|
+
// narrowed to one entry it does nothing until ArrowDown highlights it. That is
|
|
196
|
+
// the ARIA combobox pattern rather than an oversight: a list with no highlight
|
|
197
|
+
// has no selection to confirm, and autoselecting the sole match would commit a
|
|
198
|
+
// value the user has not looked at. `SearchSelect` agrees, and a user moves
|
|
199
|
+
// between the two. The cost is one ArrowDown.
|
|
200
|
+
event.preventDefault();
|
|
201
|
+
const option = props.options[activeIndex.value];
|
|
202
|
+
if (option !== undefined) {
|
|
203
|
+
pick(option);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
break;
|
|
207
|
+
case 'Escape':
|
|
208
|
+
if (open.value) {
|
|
209
|
+
event.preventDefault();
|
|
210
|
+
close();
|
|
211
|
+
}
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Tab (or any focus move) out of the control closes the list. A move to the clear button stays
|
|
217
|
+
// inside. The list itself never takes focus: `@mousedown.prevent` keeps a click from moving it,
|
|
218
|
+
// and `tabindex="-1"` keeps Tab out of it — a scrolling list is otherwise a tab stop in Chrome.
|
|
219
|
+
function onFocusout(event: FocusEvent): void {
|
|
220
|
+
const next = event.relatedTarget;
|
|
221
|
+
if (next instanceof Node && root.value?.contains(next)) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
close();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
onClickOutside(root, close);
|
|
228
|
+
// New results arrive while the user may already be arrowing through the old ones: keep the
|
|
229
|
+
// highlight on the same entry if it is still there, and drop it if it is not.
|
|
230
|
+
watch(
|
|
231
|
+
() => props.options,
|
|
232
|
+
(next, previous) => {
|
|
233
|
+
const keptId = previous[activeIndex.value]?.id;
|
|
234
|
+
activeIndex.value = keptId === undefined ? -1 : next.findIndex((o) => o.id === keptId);
|
|
235
|
+
},
|
|
236
|
+
);
|
|
237
|
+
</script>
|
|
238
|
+
|
|
239
|
+
<template>
|
|
240
|
+
<div ref="root" v-bind="rootAttrs" class="relative" @focusout="onFocusout">
|
|
241
|
+
<div
|
|
242
|
+
:aria-invalid="ariaInvalid"
|
|
243
|
+
class="border-muted-foreground bg-background focus-within:ring-ring focus-within:ring-offset-background aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 flex items-center gap-2 rounded-md border px-2.5 py-2 text-sm focus-within:ring-2 focus-within:ring-offset-2 aria-invalid:ring-3"
|
|
244
|
+
:class="{ 'cursor-not-allowed opacity-50': props.disabled }"
|
|
245
|
+
>
|
|
246
|
+
<span
|
|
247
|
+
v-if="props.label"
|
|
248
|
+
aria-hidden="true"
|
|
249
|
+
class="text-[10px] font-bold text-muted-foreground uppercase"
|
|
250
|
+
>{{ props.label }}</span
|
|
251
|
+
>
|
|
252
|
+
<!-- `aria-controls` is gated on the open state because the `<ul>` it names is
|
|
253
|
+
`v-if`-gated: pointed at an absent id it is a dangling IDREF, which is
|
|
254
|
+
invalid ARIA. -->
|
|
255
|
+
<input
|
|
256
|
+
ref="input"
|
|
257
|
+
v-bind="inputAttrs"
|
|
258
|
+
data-testid="combobox-input"
|
|
259
|
+
type="text"
|
|
260
|
+
role="combobox"
|
|
261
|
+
autocomplete="off"
|
|
262
|
+
aria-autocomplete="list"
|
|
263
|
+
:aria-expanded="showsList"
|
|
264
|
+
:aria-controls="showsList ? listId : undefined"
|
|
265
|
+
:aria-activedescendant="activeDescendant"
|
|
266
|
+
:aria-label="(inputAttrs['aria-label'] as string | undefined) ?? props.label"
|
|
267
|
+
:value="shownValue"
|
|
268
|
+
:placeholder="shownPlaceholder"
|
|
269
|
+
:disabled="props.disabled"
|
|
270
|
+
:class="
|
|
271
|
+
cn(
|
|
272
|
+
'min-w-0 flex-1 bg-transparent outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed',
|
|
273
|
+
!open && selectedLabel !== '' && 'truncate',
|
|
274
|
+
)
|
|
275
|
+
"
|
|
276
|
+
@focus="show"
|
|
277
|
+
@click="show"
|
|
278
|
+
@input="onInput"
|
|
279
|
+
@keydown="onKeydown"
|
|
280
|
+
/>
|
|
281
|
+
<button
|
|
282
|
+
v-if="props.modelValue !== null && !props.disabled"
|
|
283
|
+
type="button"
|
|
284
|
+
:aria-label="labels.clearSelection"
|
|
285
|
+
class="text-muted-foreground hover:text-foreground"
|
|
286
|
+
@click="clear"
|
|
287
|
+
>
|
|
288
|
+
<slot name="clear-icon">
|
|
289
|
+
<XIcon />
|
|
290
|
+
</slot>
|
|
291
|
+
</button>
|
|
292
|
+
</div>
|
|
293
|
+
<ul
|
|
294
|
+
v-if="showsList"
|
|
295
|
+
:id="listId"
|
|
296
|
+
role="listbox"
|
|
297
|
+
tabindex="-1"
|
|
298
|
+
class="absolute z-20 mt-1 max-h-56 w-full overflow-auto rounded-md border border-border bg-popover p-1 shadow-lg"
|
|
299
|
+
@mousedown.prevent
|
|
300
|
+
>
|
|
301
|
+
<li v-if="props.loading" class="px-2 py-1.5 text-xs text-muted-foreground">
|
|
302
|
+
{{ labels.loadingResults }}
|
|
303
|
+
</li>
|
|
304
|
+
<li
|
|
305
|
+
v-else-if="props.options.length === 0"
|
|
306
|
+
class="px-2 py-1.5 text-xs text-muted-foreground"
|
|
307
|
+
>
|
|
308
|
+
{{ props.emptyText ?? labels.noMatches }}
|
|
309
|
+
</li>
|
|
310
|
+
<template v-else>
|
|
311
|
+
<li
|
|
312
|
+
v-for="(option, index) in props.options"
|
|
313
|
+
:id="optionId(option)"
|
|
314
|
+
:key="option.id"
|
|
315
|
+
role="option"
|
|
316
|
+
:aria-selected="option.id === props.modelValue"
|
|
317
|
+
:data-active="index === activeIndex ? '' : undefined"
|
|
318
|
+
:data-testid="`combobox-option-${option.id}`"
|
|
319
|
+
:class="
|
|
320
|
+
cn(
|
|
321
|
+
'cursor-pointer rounded px-2 py-1.5 text-sm',
|
|
322
|
+
option.id === props.modelValue && 'bg-muted font-semibold',
|
|
323
|
+
// The wash alone is 1.1-1.3:1 against the list, too faint to be the only sign of
|
|
324
|
+
// where the keyboard is, so the highlighted entry also takes the focus colour.
|
|
325
|
+
index === activeIndex &&
|
|
326
|
+
'bg-accent text-accent-foreground ring-2 ring-inset ring-ring',
|
|
327
|
+
)
|
|
328
|
+
"
|
|
329
|
+
@mousemove="activeIndex = index"
|
|
330
|
+
@click="pick(option)"
|
|
331
|
+
>
|
|
332
|
+
{{ option.label }}
|
|
333
|
+
</li>
|
|
334
|
+
</template>
|
|
335
|
+
</ul>
|
|
336
|
+
</div>
|
|
337
|
+
</template>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Combobox } from './Combobox.vue';
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { formatLabel, useUiLabels } from '@noix-dev/brix-core';
|
|
3
|
+
import { computed, ref, watch } from 'vue';
|
|
4
|
+
import { cn } from '../../lib/cn';
|
|
5
|
+
import { Button } from '../button';
|
|
6
|
+
import { RichEditor } from '../rich-editor';
|
|
7
|
+
import { SegmentedChoice } from '../segmented-choice';
|
|
8
|
+
import { TextLimitCounter, textLength } from '../textarea';
|
|
9
|
+
import { isBlankBody } from './commentBody';
|
|
10
|
+
import {
|
|
11
|
+
levelByKey,
|
|
12
|
+
levelOptions,
|
|
13
|
+
levelTone,
|
|
14
|
+
narrowestLevel,
|
|
15
|
+
toneInk,
|
|
16
|
+
type CommentLevel,
|
|
17
|
+
} from './commentLevels';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The box a comment is written in: the editor, a footer carrying who will be able to read it, and
|
|
21
|
+
* the one button that posts it.
|
|
22
|
+
*
|
|
23
|
+
* **It ships behind its own door, `@noix-dev/brix-vue/comment-composer`, and the message and the thread
|
|
24
|
+
* do not.** It renders `RichEditor`, which carries three tiptap packages as optional peers, and
|
|
25
|
+
* `pnpm proof` fails any module of the root barrel whose graph reaches that family (ADR 0014). So
|
|
26
|
+
* this is a red gate, not a preference. The alternative — taking the editor through a slot — was
|
|
27
|
+
* weighed and rejected: the approved record draws ONE box with the footer inside it, `RichEditor`
|
|
28
|
+
* already draws that box including the focus ring with the offset the control-state recipe wants,
|
|
29
|
+
* and a slotted editor either draws a second box inside this one or pushes the footer out of it.
|
|
30
|
+
* The precedent is exact: `ImageUpload` is behind a door because it statically imports the crop
|
|
31
|
+
* dialog, while `FileUpload`, its library-free sibling, stays in the barrel.
|
|
32
|
+
*
|
|
33
|
+
* **The re-entry guard latches here and releases on evidence.** `submit` is emitted once; a second
|
|
34
|
+
* press does nothing until either `modelValue` changes — any edit, and a successful post clears
|
|
35
|
+
* the draft — or `busy` falls from true to false, which is a failure the consumer reported. A
|
|
36
|
+
* guard that waited only on `busy` would be the original defect again, because the implementation
|
|
37
|
+
* that has that defect never passed one. A guard that never released would be worse. So both.
|
|
38
|
+
*
|
|
39
|
+
* **Four behaviours belong to this family, not to the consumer's vocabulary.** No silent
|
|
40
|
+
* escalation: an answer cannot reach further than the comment it answers, and a parent level this
|
|
41
|
+
* list no longer declares means the ceiling is UNKNOWN, which keeps only the narrowest level —
|
|
42
|
+
* never "no ceiling". The warning comes from a level's `external` flag and never from its name.
|
|
43
|
+
* The default is the narrowest level. One level list serves both writing and filtering.
|
|
44
|
+
*
|
|
45
|
+
* **It owns no submission.** No request, no optimistic row, no error state: `submit` is an
|
|
46
|
+
* instruction and `busy` is the consumer's answer (ADR 0017).
|
|
47
|
+
*/
|
|
48
|
+
const props = defineProps<{
|
|
49
|
+
/** The body as HTML. */
|
|
50
|
+
modelValue: string;
|
|
51
|
+
levels?: readonly CommentLevel[];
|
|
52
|
+
/** The chosen level's key. Controlled; without it the composer names the narrowest. */
|
|
53
|
+
level?: string;
|
|
54
|
+
/**
|
|
55
|
+
* The level of the comment being answered. `undefined` is a new comment, so nothing
|
|
56
|
+
* constrains the choice; a key that is not in `levels` is an **unknown** parent, and then
|
|
57
|
+
* only the narrowest level stays enabled.
|
|
58
|
+
*/
|
|
59
|
+
parentLevel?: string;
|
|
60
|
+
/** The consumer's own in-flight flag. Falling true to false releases the re-entry latch. */
|
|
61
|
+
busy?: boolean;
|
|
62
|
+
disabled?: boolean;
|
|
63
|
+
/** Characters of the HTML string, as the server measures it. With it, a counter is drawn. */
|
|
64
|
+
limit?: number;
|
|
65
|
+
sendLabel?: string;
|
|
66
|
+
sendingLabel?: string;
|
|
67
|
+
levelName?: string;
|
|
68
|
+
class?: string;
|
|
69
|
+
}>();
|
|
70
|
+
|
|
71
|
+
const emit = defineEmits<{
|
|
72
|
+
(e: 'update:modelValue', html: string): void;
|
|
73
|
+
(e: 'update:level', key: string): void;
|
|
74
|
+
(e: 'submit', payload: { body: string; level: string | undefined }): void;
|
|
75
|
+
}>();
|
|
76
|
+
|
|
77
|
+
const labels = useUiLabels();
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The reach a reply may not exceed. `undefined` is a new comment; a **number** is the reach of the
|
|
81
|
+
* comment being answered; `null` is a parent whose level this list no longer declares, where the
|
|
82
|
+
* ceiling is unknown. `levelOptions` keeps only the narrowest level for `null`, because unknown
|
|
83
|
+
* must not quietly mean unconstrained.
|
|
84
|
+
*/
|
|
85
|
+
const ceiling = computed<number | null | undefined>(() => {
|
|
86
|
+
if (props.parentLevel === undefined) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const parent = levelByKey(props.levels ?? [], props.parentLevel);
|
|
91
|
+
|
|
92
|
+
return parent === undefined ? null : parent.reach;
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The level that will actually be sent, which is not always the one the consumer named.
|
|
97
|
+
*
|
|
98
|
+
* **The ceiling constrains the PAYLOAD, not only the control.** Disabling the wider options is an
|
|
99
|
+
* affordance; it stops a reader choosing one, and it does nothing about a `level` prop that
|
|
100
|
+
* already names one. The specification leaves "whether the level choice is sticky between posts"
|
|
101
|
+
* to the builder, so a consumer that keeps `level` across a reply to a narrower comment arrives
|
|
102
|
+
* here with exactly that — and `SegmentedChoice` draws `aria-checked` from `modelValue` whether or
|
|
103
|
+
* not the option is disabled, so before this the composer drew the disabled widest option as
|
|
104
|
+
* SELECTED, printed "an answer cannot reach further than the comment it answers" underneath it,
|
|
105
|
+
* and submitted the wider level anyway.
|
|
106
|
+
*
|
|
107
|
+
* So a level that fails the ceiling is not the chosen level; the narrowest is. Where the ceiling
|
|
108
|
+
* is unknown only the narrowest is available at all. Where a named level cannot be resolved
|
|
109
|
+
* against `levels`, it cannot be shown to clear the ceiling either, so under a ceiling the
|
|
110
|
+
* narrowest wins — with no ceiling the consumer's key passes through untouched.
|
|
111
|
+
*
|
|
112
|
+
* It does **not** emit `update:level` for a clamp. The prop is the consumer's and the family does
|
|
113
|
+
* not rewrite it; it simply never acts on a value it cannot honour, which is the same rule
|
|
114
|
+
* `CommentThread` follows for a filter whose control it cannot draw. The control shows what will
|
|
115
|
+
* be sent, so the two can no longer disagree, and `submit` carries the level that actually went.
|
|
116
|
+
*/
|
|
117
|
+
const chosenKey = computed(() => {
|
|
118
|
+
const narrowest = narrowestLevel(props.levels ?? [])?.key;
|
|
119
|
+
const asked = props.level ?? narrowest;
|
|
120
|
+
|
|
121
|
+
if (ceiling.value === undefined) {
|
|
122
|
+
return asked;
|
|
123
|
+
}
|
|
124
|
+
if (ceiling.value === null) {
|
|
125
|
+
return narrowest;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const level = levelByKey(props.levels ?? [], asked);
|
|
129
|
+
|
|
130
|
+
return level !== undefined && level.reach <= ceiling.value ? asked : narrowest;
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const chosenLevel = computed(() => levelByKey(props.levels ?? [], chosenKey.value));
|
|
134
|
+
|
|
135
|
+
const options = computed(() => levelOptions(props.levels ?? [], ceiling.value));
|
|
136
|
+
|
|
137
|
+
/** One option fewer than two is a control that cannot be used (Review Focus 2). */
|
|
138
|
+
const showLevels = computed(() => (props.levels?.length ?? 0) > 1);
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Whether the ceiling actually takes something away. The line explaining why is drawn only then —
|
|
142
|
+
* on a new comment, or where the parent already sits at the widest level, it would be noise, and
|
|
143
|
+
* a line a reader learns to skip is worse than no line.
|
|
144
|
+
*/
|
|
145
|
+
const constrained = computed(() => options.value.some((option) => option.disabled === true));
|
|
146
|
+
|
|
147
|
+
const external = computed(() => chosenLevel.value?.external === true);
|
|
148
|
+
|
|
149
|
+
const externalTone = computed(() =>
|
|
150
|
+
chosenLevel.value === undefined
|
|
151
|
+
? undefined
|
|
152
|
+
: // `props.levels` is non-empty whenever `chosenLevel` resolves, since that is where it
|
|
153
|
+
// was resolved from, so there is no fallback list to supply here.
|
|
154
|
+
levelTone(props.levels ?? [], chosenLevel.value),
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
const sendText = computed(() => props.sendLabel ?? labels.value.commentsSend);
|
|
158
|
+
const sendingText = computed(() => props.sendingLabel ?? labels.value.commentsSending);
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The re-entry latch. Set when `submit` goes out, cleared only on evidence that the last one was
|
|
162
|
+
* dealt with: an edit, or a `busy` flag falling back down.
|
|
163
|
+
*/
|
|
164
|
+
const latched = ref(false);
|
|
165
|
+
|
|
166
|
+
watch(
|
|
167
|
+
() => props.modelValue,
|
|
168
|
+
() => {
|
|
169
|
+
latched.value = false;
|
|
170
|
+
},
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
watch(
|
|
174
|
+
() => props.busy,
|
|
175
|
+
(now, before) => {
|
|
176
|
+
// Falling only. A flag going UP is the consumer acknowledging the submit, not finishing it.
|
|
177
|
+
if (before === true && now !== true) {
|
|
178
|
+
latched.value = false;
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
function onSend(): void {
|
|
184
|
+
if (latched.value || props.disabled === true || isBlankBody(props.modelValue)) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
latched.value = true;
|
|
189
|
+
emit('submit', { body: props.modelValue, level: chosenKey.value });
|
|
190
|
+
}
|
|
191
|
+
</script>
|
|
192
|
+
|
|
193
|
+
<template>
|
|
194
|
+
<div
|
|
195
|
+
data-slot="comment-composer"
|
|
196
|
+
:class="
|
|
197
|
+
cn(
|
|
198
|
+
// The box, once, with the footer inside it. The resting edge is
|
|
199
|
+
// `--muted-foreground`, which is the rule for any active text field; the record
|
|
200
|
+
// draws `--border` there and `docs/design/README.md` carries both figures and the
|
|
201
|
+
// reason. `RichEditor` gives up its own identical box below.
|
|
202
|
+
'border-muted-foreground focus-within:border-ring focus-within:ring-ring focus-within:ring-offset-background bg-background overflow-hidden rounded-lg border outline-none focus-within:ring-2 focus-within:ring-offset-2',
|
|
203
|
+
props.class,
|
|
204
|
+
)
|
|
205
|
+
"
|
|
206
|
+
>
|
|
207
|
+
<div
|
|
208
|
+
v-if="$slots.header"
|
|
209
|
+
data-slot="comment-composer-header"
|
|
210
|
+
class="border-input bg-muted/40 border-b px-2.5 py-2"
|
|
211
|
+
>
|
|
212
|
+
<slot name="header" />
|
|
213
|
+
</div>
|
|
214
|
+
|
|
215
|
+
<!--
|
|
216
|
+
The editor drops its box and this one keeps it: `cn` is tailwind-merge, so
|
|
217
|
+
`rounded-none border-0 focus-within:ring-0 focus-within:ring-offset-0` removes
|
|
218
|
+
`rounded-lg`, `border`, `focus-within:ring-2` and `focus-within:ring-offset-2` from
|
|
219
|
+
what it would otherwise draw. Measured in the suite against the MERGED class list,
|
|
220
|
+
because a concatenated one would measure nothing.
|
|
221
|
+
-->
|
|
222
|
+
<RichEditor
|
|
223
|
+
:model-value="props.modelValue"
|
|
224
|
+
class="rounded-none border-0 focus-within:ring-0 focus-within:ring-offset-0"
|
|
225
|
+
@update:model-value="emit('update:modelValue', $event)"
|
|
226
|
+
/>
|
|
227
|
+
|
|
228
|
+
<div data-slot="comment-footer" class="border-input bg-muted/40 border-t px-2.5 py-2">
|
|
229
|
+
<div class="flex flex-wrap items-center gap-2.5">
|
|
230
|
+
<SegmentedChoice
|
|
231
|
+
v-if="showLevels"
|
|
232
|
+
data-testid="comment-levels"
|
|
233
|
+
:model-value="chosenKey ?? ''"
|
|
234
|
+
:options="options"
|
|
235
|
+
:group-label="props.levelName ?? labels.commentsLevelName"
|
|
236
|
+
:disabled="props.disabled"
|
|
237
|
+
testid-prefix="comment-level"
|
|
238
|
+
@update:model-value="emit('update:level', $event)"
|
|
239
|
+
/>
|
|
240
|
+
|
|
241
|
+
<slot name="hint" />
|
|
242
|
+
|
|
243
|
+
<!--
|
|
244
|
+
The count and the send sit in ONE right-hand group, and the auto margin is
|
|
245
|
+
the group's. Two `ms-auto` in one flex row do not both push right: the first
|
|
246
|
+
takes the free space before the counter and the second takes what is left
|
|
247
|
+
before the button, so the pair ends up split by a measured 112px hole where
|
|
248
|
+
this row's declared gap is 10px. And the margin cannot simply move to the
|
|
249
|
+
counter, because the counter is not always there — `TextLimitCounter` draws
|
|
250
|
+
nothing when `limit` is null, which would leave the send button with no auto
|
|
251
|
+
margin at all and put it back beside the level switch.
|
|
252
|
+
-->
|
|
253
|
+
<div class="ms-auto flex items-center gap-2.5">
|
|
254
|
+
<TextLimitCounter
|
|
255
|
+
:count="textLength(props.modelValue)"
|
|
256
|
+
:limit="props.limit ?? null"
|
|
257
|
+
/>
|
|
258
|
+
|
|
259
|
+
<Button
|
|
260
|
+
data-testid="comment-send"
|
|
261
|
+
type="button"
|
|
262
|
+
size="sm"
|
|
263
|
+
:disabled="props.disabled"
|
|
264
|
+
@click="onSend"
|
|
265
|
+
>{{ props.busy === true ? sendingText : sendText }}</Button
|
|
266
|
+
>
|
|
267
|
+
</div>
|
|
268
|
+
</div>
|
|
269
|
+
|
|
270
|
+
<!--
|
|
271
|
+
The record's `.leaves` row: the same 3px bar in the same ink the message draws for
|
|
272
|
+
that level, so the two surfaces read as one system. The warning follows the
|
|
273
|
+
`external` FLAG, never a name or a key.
|
|
274
|
+
-->
|
|
275
|
+
<p
|
|
276
|
+
v-if="external && externalTone !== undefined"
|
|
277
|
+
data-slot="comment-external"
|
|
278
|
+
class="mt-[9px] flex items-center gap-[7px] text-[12px]"
|
|
279
|
+
:class="toneInk(externalTone)"
|
|
280
|
+
>
|
|
281
|
+
<span
|
|
282
|
+
data-slot="comment-external-mark"
|
|
283
|
+
aria-hidden="true"
|
|
284
|
+
class="w-[3px] self-stretch rounded-sm bg-current"
|
|
285
|
+
/>
|
|
286
|
+
{{
|
|
287
|
+
formatLabel(labels.commentsExternalWarning, {
|
|
288
|
+
label: chosenLevel?.label ?? '',
|
|
289
|
+
})
|
|
290
|
+
}}
|
|
291
|
+
</p>
|
|
292
|
+
|
|
293
|
+
<p
|
|
294
|
+
v-if="constrained"
|
|
295
|
+
data-slot="comment-no-escalation"
|
|
296
|
+
class="text-muted-foreground mt-[9px] text-[12px]"
|
|
297
|
+
>
|
|
298
|
+
{{ labels.commentsNoEscalation }}
|
|
299
|
+
</p>
|
|
300
|
+
</div>
|
|
301
|
+
</div>
|
|
302
|
+
</template>
|