@celestia-island/hikari 0.55.411 → 0.55.413
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/package.json +1 -1
- package/src/components/HkSearchInput.tsx +45 -2
- package/src/components/HkUserPicker.scss +111 -12
- package/src/components/HkUserPicker.singleScroll.contract.test.ts +81 -0
- package/src/components/HkUserPicker.test.tsx +245 -105
- package/src/components/HkUserPicker.tsx +430 -161
- package/src/components/_menu-item.scss +15 -4
package/package.json
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
defineComponent,
|
|
3
|
+
onUnmounted,
|
|
4
|
+
ref,
|
|
5
|
+
useAttrs,
|
|
6
|
+
watch,
|
|
7
|
+
type PropType,
|
|
8
|
+
type StyleValue,
|
|
9
|
+
} from "vue";
|
|
2
10
|
import { useI18n } from "../i18n/context";
|
|
3
11
|
import "./HkSearchInput.scss";
|
|
4
12
|
|
|
@@ -18,6 +26,19 @@ const clearIcon = (
|
|
|
18
26
|
|
|
19
27
|
export default defineComponent({
|
|
20
28
|
name: "HkSearchInput",
|
|
29
|
+
// The styled box and the control are two nodes: the box is a chrome
|
|
30
|
+
// wrapper (`.hk-search-input`), the `<input>` inside it is the actual
|
|
31
|
+
// field. Undeclared attributes therefore belong on the FIELD, not the
|
|
32
|
+
// box — the HkInput contract. A consumer that wires this search field
|
|
33
|
+
// as the combobox of a list surface (HkUserPicker) passes `aria-label`,
|
|
34
|
+
// `aria-controls`, `aria-activedescendant` / `aria-expanded`; the old
|
|
35
|
+
// auto-fallthrough onto the wrapper left the input itself unnamed and
|
|
36
|
+
// the active row unpublished. `class` / `style` stay on the wrapper
|
|
37
|
+
// (its historical home). `role` is DECLARED below rather than passed as
|
|
38
|
+
// an attribute: it carries no dash, so the JSX attribute passthrough
|
|
39
|
+
// cannot accept it (the house rule is the same for `role` on HkInput —
|
|
40
|
+
// HkTagInput reaches for a native input when it needs one).
|
|
41
|
+
inheritAttrs: false,
|
|
21
42
|
props: {
|
|
22
43
|
modelValue: { type: String, default: "" },
|
|
23
44
|
placeholder: { type: String, default: undefined },
|
|
@@ -28,6 +49,10 @@ export default defineComponent({
|
|
|
28
49
|
},
|
|
29
50
|
debounce: { type: Number, default: 0 },
|
|
30
51
|
clearAriaLabel: { type: String, default: "" },
|
|
52
|
+
/** Role of the FIELD element itself — "combobox" when a panel (the
|
|
53
|
+
* HkUserPicker popover) owns a list of options behind this search
|
|
54
|
+
* box. Undefined keeps the native searchbox semantics. */
|
|
55
|
+
role: { type: String, default: undefined },
|
|
31
56
|
},
|
|
32
57
|
emits: {
|
|
33
58
|
"update:modelValue": (_value: string) => true,
|
|
@@ -36,9 +61,22 @@ export default defineComponent({
|
|
|
36
61
|
},
|
|
37
62
|
setup(props, { emit }) {
|
|
38
63
|
const { t } = useI18n();
|
|
64
|
+
const attrs = useAttrs();
|
|
39
65
|
const inputRef = ref<HTMLInputElement | null>(null);
|
|
40
66
|
let debounceTimer: ReturnType<typeof setTimeout> | null = null;
|
|
41
67
|
|
|
68
|
+
/** Undeclared attributes minus the two that keep the wrapper's
|
|
69
|
+
* historical meaning — every other one (aria wiring, `name`, an
|
|
70
|
+
* extra listener) is the FIELD's. */
|
|
71
|
+
const fieldAttrs = () => {
|
|
72
|
+
const { class: _class, style: _style, ...rest } = attrs as Record<string, unknown>;
|
|
73
|
+
return rest;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/** `style` is the one wrapper-bound attribute that needs typing: it
|
|
77
|
+
* rides the box beside `class`. */
|
|
78
|
+
const wrapperStyle = () => (attrs as { style?: StyleValue }).style;
|
|
79
|
+
|
|
42
80
|
function flushSearch(val: string) {
|
|
43
81
|
emit("search", val);
|
|
44
82
|
}
|
|
@@ -88,12 +126,17 @@ export default defineComponent({
|
|
|
88
126
|
];
|
|
89
127
|
|
|
90
128
|
return () => (
|
|
91
|
-
<div
|
|
129
|
+
<div
|
|
130
|
+
class={[...wrapperClass, (attrs as Record<string, unknown>).class]}
|
|
131
|
+
style={wrapperStyle()}
|
|
132
|
+
>
|
|
92
133
|
<span class="hk-search-input-icon">{searchIcon}</span>
|
|
93
134
|
<input
|
|
135
|
+
{...fieldAttrs()}
|
|
94
136
|
ref={inputRef}
|
|
95
137
|
type="search"
|
|
96
138
|
class="hk-search-input-field"
|
|
139
|
+
role={props.role}
|
|
97
140
|
value={props.modelValue}
|
|
98
141
|
placeholder={props.placeholder ?? t("hikari::searchInput.placeholder", "Search…")}
|
|
99
142
|
disabled={props.disabled}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
// HkUserPicker (components/HkUserPicker.tsx) — the tag field
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// HkUserPicker (components/HkUserPicker.tsx) — the tag field plus the
|
|
2
|
+
// anchored search panel it opens. The surface itself (desktop popout,
|
|
3
|
+
// phone bottom sheet, Escape / outside-click dismissal, the back-gesture
|
|
4
|
+
// layer) is HkSelectPanel's; this sheet only carries the content column
|
|
5
|
+
// that lives inside it. Tokens follow the house scale (--space-*,
|
|
6
|
+
// --radius-*, rgb(var(--color-*)), --hi-color-*).
|
|
7
|
+
//
|
|
8
|
+
// ONE SCROLLBAR: the panel content mounts NO scroll region of its own —
|
|
9
|
+
// the surface owns THE scrollbar and scrolls the search field together
|
|
10
|
+
// with the rows as one band (the HkAffixPicker / HkTagInput contract).
|
|
11
|
+
// Every rule below is geometry for that single content column.
|
|
4
12
|
|
|
5
13
|
@use "./menu-item" as mi;
|
|
6
14
|
|
|
@@ -38,6 +46,12 @@
|
|
|
38
46
|
border-color: var(--hi-color-primary, #7aa2f7);
|
|
39
47
|
box-shadow: 0 0 0 3px color-mix(in srgb, var(--hi-color-primary, #7aa2f7) 12%, transparent);
|
|
40
48
|
}
|
|
49
|
+
|
|
50
|
+
/* The field wearing the open panel's state — the HkSelect trigger's
|
|
51
|
+
* data-state face, expressed on the field's own class. */
|
|
52
|
+
&.is-open {
|
|
53
|
+
border-color: var(--hi-color-primary, #7aa2f7);
|
|
54
|
+
}
|
|
41
55
|
}
|
|
42
56
|
|
|
43
57
|
.hk-user-picker-tag {
|
|
@@ -91,18 +105,50 @@
|
|
|
91
105
|
}
|
|
92
106
|
}
|
|
93
107
|
|
|
108
|
+
/* ── Panel content ──────────────────────────────────────────────────── */
|
|
109
|
+
|
|
110
|
+
/* The content column inside HkSelectPanel. `.hk-user-picker-dialog` is the
|
|
111
|
+
* SAME column as the mirror renders it (the Rust UserPickerComponent still
|
|
112
|
+
* draws the modal form of this component) — one shared rule so the
|
|
113
|
+
* vendored sheet cannot style one form and drop the other. */
|
|
114
|
+
.hk-user-picker-panel,
|
|
94
115
|
.hk-user-picker-dialog {
|
|
95
116
|
display: flex;
|
|
96
117
|
flex-direction: column;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.hk-user-picker-panel {
|
|
121
|
+
gap: var(--space-8, 0.5rem);
|
|
122
|
+
/* The surface's own 8px inset is the ONE horizontal inset (no padding
|
|
123
|
+
* here), and the popout host already owns the width contract: its
|
|
124
|
+
* `min-width` tracks the field (matchAnchorWidth) and its own
|
|
125
|
+
* `max-width` tracks the viewport gutter. The panel therefore just
|
|
126
|
+
* fills the host and lets its TEXT cells carry the width cap below —
|
|
127
|
+
* an un-capped email column would otherwise push `width: max-content`
|
|
128
|
+
* past the field it hangs from. */
|
|
129
|
+
min-width: 0;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.hk-user-picker-dialog {
|
|
133
|
+
/* Legacy modal body rhythm + inset (see above). */
|
|
97
134
|
gap: var(--space-12, 0.75rem);
|
|
98
135
|
padding: var(--space-4, 0.25rem) 0;
|
|
99
136
|
}
|
|
100
137
|
|
|
138
|
+
.hk-user-picker-search {
|
|
139
|
+
display: flex;
|
|
140
|
+
flex-direction: column;
|
|
141
|
+
min-width: 0;
|
|
142
|
+
}
|
|
143
|
+
|
|
101
144
|
.hk-user-picker-rows {
|
|
102
145
|
display: flex;
|
|
103
146
|
flex-direction: column;
|
|
104
|
-
|
|
105
|
-
|
|
147
|
+
/* HkSelect's option rhythm (the popout's own gap token). */
|
|
148
|
+
gap: var(--space-2, 0.125rem);
|
|
149
|
+
/* The opening state is a single hint line — this floor keeps the panel
|
|
150
|
+
* from collapsing to a sliver between queries. */
|
|
151
|
+
min-height: 2.25rem;
|
|
106
152
|
}
|
|
107
153
|
|
|
108
154
|
.hk-user-picker-note {
|
|
@@ -113,18 +159,48 @@
|
|
|
113
159
|
text-align: center;
|
|
114
160
|
}
|
|
115
161
|
|
|
162
|
+
/* The failed state's retry affordance — the note IS the button (the
|
|
163
|
+
* historic failed/retry semantics: click re-runs the same query). */
|
|
164
|
+
.hk-user-picker-retry {
|
|
165
|
+
width: 100%;
|
|
166
|
+
margin: 0;
|
|
167
|
+
padding: var(--space-12, 0.75rem) 0;
|
|
168
|
+
border: none;
|
|
169
|
+
border-radius: var(--radius-md, 0.5rem);
|
|
170
|
+
background: transparent;
|
|
171
|
+
font-family: inherit;
|
|
172
|
+
font-size: 0.75rem;
|
|
173
|
+
color: var(--hi-color-primary, #7aa2f7);
|
|
174
|
+
text-align: center;
|
|
175
|
+
cursor: pointer;
|
|
176
|
+
|
|
177
|
+
&:hover {
|
|
178
|
+
text-decoration: underline;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
&:focus-visible {
|
|
182
|
+
outline: none;
|
|
183
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--hi-color-primary, #7aa2f7) 12%, transparent);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
116
187
|
.hk-user-picker-row {
|
|
117
188
|
/* Unified menu-item spec (_menu-item.scss): metrics, reserved border,
|
|
118
|
-
* guarded hover, checked face, focus ring; the sheet reach
|
|
119
|
-
* the
|
|
120
|
-
*
|
|
121
|
-
* emits the grammar's `data-checked` for the multi-mode draft
|
|
122
|
-
* beside the legacy `.is-selected` class (tests/hosts key on it)
|
|
189
|
+
* guarded hover, checked/active face, focus ring; the mobile sheet reach
|
|
190
|
+
* comes from the panel registration list (this picker rides the
|
|
191
|
+
* HkSelectPanel surface, whose phone form is .hk-select-sheet-panel).
|
|
192
|
+
* The tsx emits the grammar's `data-checked` for the multi-mode draft
|
|
193
|
+
* pick beside the legacy `.is-selected` class (tests/hosts key on it)
|
|
194
|
+
* and `data-active` for the keyboard cursor. */
|
|
123
195
|
@include mi.item;
|
|
124
196
|
/* The picker's row carries trailing state controls, so the content
|
|
125
197
|
* spreads edge-to-edge instead of hugging the start. */
|
|
126
198
|
justify-content: space-between;
|
|
127
199
|
text-align: left;
|
|
200
|
+
/* Layout axis only: the row is a flex child of the content column and
|
|
201
|
+
* must be able to shrink under the capped measure (the long-email
|
|
202
|
+
* ellipsis below depends on it). */
|
|
203
|
+
min-width: 0;
|
|
128
204
|
}
|
|
129
205
|
|
|
130
206
|
.hk-user-picker-row-main {
|
|
@@ -140,6 +216,10 @@
|
|
|
140
216
|
white-space: nowrap;
|
|
141
217
|
overflow: hidden;
|
|
142
218
|
text-overflow: ellipsis;
|
|
219
|
+
/* The width cap lives on the TEXT cells (not on the panel): the popout
|
|
220
|
+
* host sizes to `max-content`, so a long email/name is what decides how
|
|
221
|
+
* wide the panel grows — capped here, ellipsized above. */
|
|
222
|
+
max-width: 28rem;
|
|
143
223
|
}
|
|
144
224
|
|
|
145
225
|
.hk-user-picker-row-email {
|
|
@@ -148,6 +228,7 @@
|
|
|
148
228
|
white-space: nowrap;
|
|
149
229
|
overflow: hidden;
|
|
150
230
|
text-overflow: ellipsis;
|
|
231
|
+
max-width: 28rem;
|
|
151
232
|
}
|
|
152
233
|
|
|
153
234
|
.hk-user-picker-row-check {
|
|
@@ -156,9 +237,27 @@
|
|
|
156
237
|
font-weight: 700;
|
|
157
238
|
}
|
|
158
239
|
|
|
240
|
+
/* ── Multi-mode footer (draft count + Cancel / Confirm) ─────────────── */
|
|
241
|
+
|
|
242
|
+
.hk-user-picker-footer {
|
|
243
|
+
display: flex;
|
|
244
|
+
flex-wrap: wrap;
|
|
245
|
+
align-items: center;
|
|
246
|
+
gap: var(--space-8, 0.5rem);
|
|
247
|
+
padding-top: var(--space-8, 0.5rem);
|
|
248
|
+
border-top: 1px solid rgb(var(--color-border) / 25%);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.hk-user-picker-actions {
|
|
252
|
+
display: flex;
|
|
253
|
+
align-items: center;
|
|
254
|
+
gap: var(--space-8, 0.5rem);
|
|
255
|
+
/* Pinned to the trailing edge; the count takes whatever room is left. */
|
|
256
|
+
margin-inline-start: auto;
|
|
257
|
+
}
|
|
258
|
+
|
|
159
259
|
.hk-user-picker-count {
|
|
160
260
|
margin: 0;
|
|
161
261
|
font-size: 0.6875rem;
|
|
162
262
|
color: rgb(var(--color-text) / 55%);
|
|
163
|
-
|
|
164
|
-
}
|
|
263
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source contract: ONE SCROLLBAR PER WINDOW for the user picker's panel.
|
|
3
|
+
*
|
|
4
|
+
* The picker moved off HkModal onto the anchored HkSelectPanel surface
|
|
5
|
+
* (2026-11 user direction). That surface owns the window and THE one
|
|
6
|
+
* scrollbar (desktop popout / phone sheet's list band); the content column
|
|
7
|
+
* this component renders inside it must therefore mount no scroll region
|
|
8
|
+
* of its own — a second nested scrollbar inside the same window is the
|
|
9
|
+
* contract violation the affix picker was reported for in 2026-09.
|
|
10
|
+
*
|
|
11
|
+
* The cap travels through HkSelectPanel's `maxHeight` prop (the surface
|
|
12
|
+
* publishes it as `--hk-select-panel-max-height`), never as a local
|
|
13
|
+
* max-height on our own band.
|
|
14
|
+
*/
|
|
15
|
+
import { describe, expect, it } from "vitest";
|
|
16
|
+
import { readFileSync } from "node:fs";
|
|
17
|
+
import { dirname, join } from "node:path";
|
|
18
|
+
import { fileURLToPath } from "node:url";
|
|
19
|
+
|
|
20
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
21
|
+
const scss = readFileSync(join(here, "HkUserPicker.scss"), "utf-8");
|
|
22
|
+
const tsx = readFileSync(join(here, "HkUserPicker.tsx"), "utf-8");
|
|
23
|
+
|
|
24
|
+
/** The balanced `{...}` block that FOLLOWS `at` — a naive `[^}]*` would
|
|
25
|
+
* stop at the first nested `}` and let properties appended after a future
|
|
26
|
+
* nested block evade the pin. */
|
|
27
|
+
function blockAt(src: string, at: number): string {
|
|
28
|
+
const open = src.indexOf("{", at);
|
|
29
|
+
expect(open, "selector block exists").toBeGreaterThanOrEqual(0);
|
|
30
|
+
let depth = 0;
|
|
31
|
+
for (let i = open; i < src.length; i++) {
|
|
32
|
+
if (src[i] === "{") depth++;
|
|
33
|
+
else if (src[i] === "}") {
|
|
34
|
+
depth--;
|
|
35
|
+
if (depth === 0) return src.slice(open, i + 1);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return "";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** EVERY rule whose selector text contains `selector` — a family that
|
|
42
|
+
* splits its declarations over several blocks (the shared content-column
|
|
43
|
+
* pair plus the panel-specific cap) must be clean in all of them. */
|
|
44
|
+
function blocksOf(src: string, selector: string): string[] {
|
|
45
|
+
const out: string[] = [];
|
|
46
|
+
let at = src.indexOf(selector);
|
|
47
|
+
while (at >= 0) {
|
|
48
|
+
out.push(blockAt(src, at));
|
|
49
|
+
at = src.indexOf(selector, at + 1);
|
|
50
|
+
}
|
|
51
|
+
expect(out.length, `${selector} rule exists`).toBeGreaterThan(0);
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function expectNoScroll(src: string, selector: string): void {
|
|
56
|
+
for (const block of blocksOf(src, selector)) {
|
|
57
|
+
expect(block, `${selector} mounts no local cap`).not.toMatch(/max-height/);
|
|
58
|
+
expect(block, `${selector} mounts no scroll region`).not.toMatch(/overflow/);
|
|
59
|
+
expect(block, `${selector} mounts no scrollbar styling`).not.toMatch(/scrollbar-width/);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
describe("HkUserPicker single-scrollbar-per-window contract", () => {
|
|
64
|
+
it("the content column and the row band mount no scroll region of their own", () => {
|
|
65
|
+
expectNoScroll(scss, ".hk-user-picker-panel");
|
|
66
|
+
expectNoScroll(scss, ".hk-user-picker-rows");
|
|
67
|
+
expectNoScroll(scss, ".hk-user-picker-search");
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("the cap rides the surface's maxHeight prop, and the picker owns no scrollbar machinery", () => {
|
|
71
|
+
expect(tsx, "the anchored surface renders").toContain("<HkSelectPanel");
|
|
72
|
+
expect(tsx, "the cap is published to the surface").toMatch(/maxHeight="[^"]+"/);
|
|
73
|
+
expect(tsx).not.toContain("attachOverlayScrollbars");
|
|
74
|
+
expect(tsx).not.toContain("OverlayScrollbarHandle");
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("no modal: the anchored panel is the ONE window this component opens", () => {
|
|
78
|
+
expect(tsx).not.toContain('from "./HkModal"');
|
|
79
|
+
expect(tsx).not.toContain("<HkModal");
|
|
80
|
+
});
|
|
81
|
+
});
|