@cscfi/csc-ui 4.0.0-alpha.2 → 4.0.0-alpha.20
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/dist/csc-ui.js +10192 -7248
- package/dist/custom-elements.json +2278 -257
- package/dist/docs/c-alert/usage.md +24 -0
- package/dist/docs/c-autocomplete/usage.md +152 -0
- package/dist/docs/c-button-group/usage.md +14 -1
- package/dist/docs/c-checkbox/usage.md +53 -0
- package/dist/docs/c-main/usage.md +21 -1
- package/dist/docs/c-menu/usage.md +15 -0
- package/dist/docs/c-menu-item/usage.md +6 -0
- package/dist/docs/c-option-value/usage.md +1 -0
- package/dist/docs/c-popover/usage.md +33 -0
- package/dist/docs/c-progress-bar/usage.md +23 -0
- package/dist/docs/c-progress-circle/usage.md +25 -0
- package/dist/docs/c-radio/usage.md +45 -0
- package/dist/docs/c-radio-group/usage.md +67 -0
- package/dist/docs/c-select/usage.md +127 -0
- package/dist/docs/c-side-navigation/usage.md +21 -0
- package/dist/docs/c-spinner/usage.md +21 -0
- package/dist/docs/c-switch/usage.md +36 -0
- package/dist/docs/c-tab-buttons/usage.md +7 -0
- package/dist/docs/c-table/usage.md +14 -0
- package/dist/docs/c-toolbar/usage.md +17 -0
- package/dist/docs/c-tooltip/usage.md +30 -0
- package/dist/docs/c-tree-select/usage.md +156 -0
- package/dist/styles/css/tailwind-theme.css +32 -0
- package/dist/styles/css/tokens.css +707 -197
- package/dist/vscode.css-custom-data.json +286 -19
- package/dist/vscode.html-custom-data.json +334 -51
- package/dist/web-types.json +1200 -190
- package/dist-types/components/c-alert/CAlert.vue.d.ts +18 -4
- package/dist-types/components/c-autocomplete/CAutocomplete.vue.d.ts +118 -18
- package/dist-types/components/c-button/CButton.vue.d.ts +1 -1
- package/dist-types/components/c-button-group/CButtonGroup.vue.d.ts +1 -1
- package/dist-types/components/c-checkbox/CCheckbox.vue.d.ts +3 -3
- package/dist-types/components/c-data-table/CDataTable.vue.d.ts +6 -2
- package/dist-types/components/c-dropdown/CDropdown.vue.d.ts +48 -5
- package/dist-types/components/c-icon/CIcon.vue.d.ts +1 -1
- package/dist-types/components/c-icon-button/CIconButton.vue.d.ts +1 -1
- package/dist-types/components/c-input/CInput.vue.d.ts +6 -2
- package/dist-types/components/c-login-button/CLoginButton.vue.d.ts +4 -2
- package/dist-types/components/c-main/CMain.vue.d.ts +9 -2
- package/dist-types/components/c-menu/CMenu.vue.d.ts +14 -4
- package/dist-types/components/c-menu-item/CMenuItem.vue.d.ts +30 -3
- package/dist-types/components/c-otp-input/COtpInput.vue.d.ts +1 -1
- package/dist-types/components/c-pagination/CPagination.vue.d.ts +1 -1
- package/dist-types/components/c-popover/CPopover.vue.d.ts +43 -0
- package/dist-types/components/c-progress-circle/CProgressCircle.vue.d.ts +32 -0
- package/dist-types/components/c-radio/CRadio.vue.d.ts +7 -11
- package/dist-types/components/c-radio-group/CRadioGroup.vue.d.ts +9 -47
- package/dist-types/components/c-select/CSelect.vue.d.ts +115 -24
- package/dist-types/components/c-side-navigation/CSideNavigation.vue.d.ts +1 -1
- package/dist-types/components/c-spinner/CSpinner.vue.d.ts +1 -1
- package/dist-types/components/c-switch/CSwitch.vue.d.ts +1 -1
- package/dist-types/components/c-table/CTable.vue.d.ts +11 -1
- package/dist-types/components/c-table/injectTableStyles.d.ts +1 -0
- package/dist-types/components/c-tag/CTag.vue.d.ts +8 -1
- package/dist-types/components/c-text-field/CTextField.vue.d.ts +15 -4
- package/dist-types/components/c-toolbar/CToolbar.vue.d.ts +10 -1
- package/dist-types/components/c-tooltip/CTooltip.vue.d.ts +49 -0
- package/dist-types/components/c-tree-select/CTreeSelect.vue.d.ts +261 -0
- package/dist-types/index.d.ts +14 -2
- package/dist-types/shared/FieldMessage.vue.d.ts +21 -0
- package/dist-types/shared/PanelHeadingRow.vue.d.ts +13 -0
- package/dist-types/shared/SelectionIndicator.vue.d.ts +21 -0
- package/dist-types/shared/appDefaults.d.ts +75 -0
- package/dist-types/shared/defineElement.d.ts +1 -0
- package/dist-types/shared/lightDismiss.d.ts +35 -0
- package/dist-types/shared/modalStack.d.ts +4 -3
- package/dist-types/shared/optionLabel.d.ts +18 -0
- package/dist-types/shared/pageLock.d.ts +26 -0
- package/dist-types/shared/peekCap.d.ts +35 -0
- package/dist-types/shared/popoverChain.d.ts +65 -0
- package/dist-types/shared/positionArea.d.ts +13 -0
- package/dist-types/shared/selectAll.d.ts +29 -0
- package/dist-types/shared/splitMatches.d.ts +18 -0
- package/dist-types/shared/useAnchoredPanel.d.ts +98 -0
- package/dist-types/shared/useDesignatedTrigger.d.ts +40 -0
- package/dist-types/shared/useHostStates.d.ts +25 -0
- package/dist-types/shared/useNarrowViewport.d.ts +19 -0
- package/dist-types/shared/useScrollStrip.d.ts +39 -0
- package/dist-types/shared/useStatusAnnouncer.d.ts +33 -0
- package/dist-types/shared/visualViewport.d.ts +51 -0
- package/dist-types/tag-name-map.d.ts +440 -51
- package/dist-types/theme/chart-data.d.ts +51 -0
- package/dist-types/theme/ramp.d.ts +38 -0
- package/dist-types/theme/themeMode.d.ts +51 -0
- package/dist-types/types.d.ts +13 -0
- package/package.json +19 -8
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The select-all row (CONTEXT.md, ADR-0046): the selection maths `c-select`
|
|
3
|
+
* and `c-autocomplete` share in `multiple` mode.
|
|
4
|
+
*
|
|
5
|
+
* `listed` is the enabled options currently in the list, in list order —
|
|
6
|
+
* every option in c-select, the current matches in c-autocomplete; callers
|
|
7
|
+
* filter disabled options out first. Duplicate option values collapse in the
|
|
8
|
+
* Set maths, exactly as they do when a single row is toggled.
|
|
9
|
+
*/
|
|
10
|
+
/** `c-select` ↔ `c-dropdown` `index` contract: the select-all row is highlighted. */
|
|
11
|
+
export declare const SELECT_ALL_INDEX = -1;
|
|
12
|
+
export type SelectAllState = 'all' | 'none' | 'some';
|
|
13
|
+
export interface SelectAllListedOption {
|
|
14
|
+
label: string;
|
|
15
|
+
value: number | string;
|
|
16
|
+
}
|
|
17
|
+
/** What the row's indicator shows: none, some (indeterminate) or all listed selected. */
|
|
18
|
+
export declare const selectAllState: (listed: readonly (number | string)[], selected: ReadonlySet<number | string>) => SelectAllState;
|
|
19
|
+
/**
|
|
20
|
+
* The next selection after the row is activated. Every listed option already
|
|
21
|
+
* selected → drop the listed values (the others keep their order); otherwise
|
|
22
|
+
* append the unselected listed options in list order (selection order,
|
|
23
|
+
* ADR-0044). `added` / `removed` let a caller keep per-value bookkeeping.
|
|
24
|
+
*/
|
|
25
|
+
export declare const toggleAllValues: <T>(current: readonly T[], listed: readonly SelectAllListedOption[], valueOf: (v: T) => number | string, make: (o: SelectAllListedOption) => T) => {
|
|
26
|
+
added: SelectAllListedOption[];
|
|
27
|
+
next: T[];
|
|
28
|
+
removed: (number | string)[];
|
|
29
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Split a label into the runs that equal the query and the runs between them
|
|
3
|
+
* — the shape `c-autocomplete`'s match marking renders as text and
|
|
4
|
+
* `<mark part="match">` nodes (ADR-0045).
|
|
5
|
+
*
|
|
6
|
+
* The query is matched literally (regex metacharacters escaped — the 3.x
|
|
7
|
+
* implementation built an unescaped RegExp and threw on `c++` or `(`) and
|
|
8
|
+
* case-insensitively via the `i` flag on the original string, so indices never
|
|
9
|
+
* drift the way a lowercased `indexOf` can when case mapping changes a
|
|
10
|
+
* string's length. Every occurrence is marked, left to right, without
|
|
11
|
+
* overlap; adjacent occurrences yield adjacent marks. An empty query yields
|
|
12
|
+
* one plain run (or nothing for empty text).
|
|
13
|
+
*/
|
|
14
|
+
export interface MatchSegment {
|
|
15
|
+
match: boolean;
|
|
16
|
+
text: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const splitMatches: (text: string, query: string) => MatchSegment[];
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anchored field panel (CONTEXT.md "Autocomplete", "Tree select", "Top
|
|
3
|
+
* layer", "Fullscreen panel"; ADR-0008, ADR-0009, ADR-0047, ADR-0050): the
|
|
4
|
+
* lifecycle shared by the value-selection fields that keep a readonly value
|
|
5
|
+
* field in place and open a native popover panel — `c-autocomplete` and
|
|
6
|
+
* `c-tree-select`. One panel, two layouts: **anchored** under the field, or
|
|
7
|
+
* — on a **narrow viewport** — a **fullscreen panel** covering the viewport.
|
|
8
|
+
*
|
|
9
|
+
* What it owns:
|
|
10
|
+
* - the anchor. CSS anchor names are tree-scoped, so the consumer wraps its
|
|
11
|
+
* value field in a shadow-DOM box carrying `anchor-name`; `anchorStyle`
|
|
12
|
+
* supplies that declaration and `panelStyle` the matching
|
|
13
|
+
* `position-anchor` / `position-area` plus the panel width pinned to the
|
|
14
|
+
* anchor's rect on open;
|
|
15
|
+
* - the field-box pull-back. The anchor wrapper spans the whole inner
|
|
16
|
+
* `c-input`, INCLUDING its hint / error message area (reserved unless
|
|
17
|
+
* `hide-details` is set), the gap above it and an on-top label. The
|
|
18
|
+
* panel must sit flush against the field box itself — the same 0px every
|
|
19
|
+
* dropdown keeps (`c-select`'s listbox, `c-menu`'s default `distance`) —
|
|
20
|
+
* so on open the distance from the anchor's bottom edge to the field
|
|
21
|
+
* box's bottom edge is measured and pulled back with a negative
|
|
22
|
+
* block-start margin, and the distance from the anchor's top edge to the
|
|
23
|
+
* field box's top edge is published as `--_c-field-panel-top-offset` for
|
|
24
|
+
* the consumer's flipped-above `@position-try` rules;
|
|
25
|
+
* - the fullscreen layout: chosen at `open()` from the `fullscreen`
|
|
26
|
+
* predicate and kept for the whole open (crossing the threshold while open
|
|
27
|
+
* closes the panel). The panel drops anchor positioning and becomes the
|
|
28
|
+
* surface — `position: fixed; inset: 0`, the layout viewport, which the
|
|
29
|
+
* on-screen keyboard overlays but never shrinks — while the card inside it
|
|
30
|
+
* follows the *visual* viewport (`visualViewport` resize / scroll while
|
|
31
|
+
* open; `cardStyle`), so the heading row and search input stay above the
|
|
32
|
+
* keyboard and the page never shows beside them. The page behind it is
|
|
33
|
+
* locked (`pageLock.ts`: inert except toasts, no document scroll);
|
|
34
|
+
* - open / close through `showPopover()` / `hidePopover()` on a
|
|
35
|
+
* `popover="manual"` panel, with the native `toggle` event as the single
|
|
36
|
+
* source of truth for `isOpen` (browser-initiated closes included);
|
|
37
|
+
* - light dismiss (CONTEXT.md "Light dismiss", ADR-0050): a press and its
|
|
38
|
+
* release both outside the host close the panel; a press alone — the
|
|
39
|
+
* start of every touch scroll — never does (`lightDismiss.ts`);
|
|
40
|
+
* - focus return to the value field on `close(true)`;
|
|
41
|
+
* - the OddBird anchor polyfill kick-off on an anchored open (Firefox).
|
|
42
|
+
*
|
|
43
|
+
* What stays in the consumer: the `@position-try --c-field-panel-above` /
|
|
44
|
+
* `--c-field-panel-above-left` flip rules and `position-try-fallbacks` —
|
|
45
|
+
* per-shadow-root escape-hatch CSS (ADR-0007; each element type has its own
|
|
46
|
+
* adopted sheet, so the block is copy-identical in every consumer) — the
|
|
47
|
+
* fullscreen `tv` variant (the panel paints the surface, the card sheds its
|
|
48
|
+
* anchored chrome, the list takes the rest, the heading row) and the open
|
|
49
|
+
* sequence (peek cap, focus, highlight seed, announcement), run from
|
|
50
|
+
* `onOpened` synchronously inside the `toggle` handler.
|
|
51
|
+
*/
|
|
52
|
+
import { type ComputedRef, type MaybeRefOrGetter, type Ref } from 'vue';
|
|
53
|
+
/**
|
|
54
|
+
* The `anchor-name` every anchored field panel uses. Anchor names are
|
|
55
|
+
* tree-scoped, so one name serves every consumer's shadow root.
|
|
56
|
+
*/
|
|
57
|
+
export declare const FIELD_PANEL_ANCHOR = "--c-field-panel-anchor";
|
|
58
|
+
export interface AnchoredPanel {
|
|
59
|
+
/** Inline style for the anchor wrapper: `anchor-name: --c-field-panel-anchor`. */
|
|
60
|
+
anchorStyle: string;
|
|
61
|
+
/** Inline style for the card inside the panel: empty while anchored; fullscreen — the visual viewport's box inside the surface (the whole surface with no API). */
|
|
62
|
+
cardStyle: ComputedRef<string>;
|
|
63
|
+
/** Hide the panel; `returnFocus` moves focus to `returnFocusTo` once the `toggle` event confirms the close. */
|
|
64
|
+
close(returnFocus?: boolean): void;
|
|
65
|
+
/** Open state — written only by the native `toggle` event (single source of truth, browser-initiated closes included). */
|
|
66
|
+
isOpen: Readonly<Ref<boolean>>;
|
|
67
|
+
/** The layout of the current open, fixed at `open()` for its whole duration; `'anchored'` — the resting shape, no heading row — while closed. */
|
|
68
|
+
layout: ComputedRef<PanelLayout>;
|
|
69
|
+
/** Bind as the panel's `@toggle` handler. */
|
|
70
|
+
onToggle(event: Event): void;
|
|
71
|
+
/** Choose the layout, measure (anchored: the anchor width and the field box's offsets from the anchor's edges), then `showPopover()`. */
|
|
72
|
+
open(): void;
|
|
73
|
+
/** Inline style for the panel: anchored — `position-anchor`, `position-area: bottom span-right`, `inset: auto`, the pinned width, the field-box pull-back and `--_c-field-panel-top-offset`; fullscreen — the surface, the layout viewport's box. */
|
|
74
|
+
panelStyle: ComputedRef<string>;
|
|
75
|
+
}
|
|
76
|
+
/** The two layouts one field panel takes (CONTEXT.md "Fullscreen panel"). */
|
|
77
|
+
export type PanelLayout = 'anchored' | 'fullscreen';
|
|
78
|
+
export interface UseAnchoredPanelOptions {
|
|
79
|
+
/** Shadow-DOM wrapper around the value field; carries `anchor-name`, and its rect pins the panel width. */
|
|
80
|
+
anchor: Readonly<Ref<HTMLElement | null>>;
|
|
81
|
+
/** `open()` is a no-op while this returns true (the field's `disabled`). */
|
|
82
|
+
disabled?: () => boolean;
|
|
83
|
+
/** The inner `c-input` host: the offsets between its field box (`.c-input__slot`) and the anchor's edges are pulled back so the panel sits flush against the field box. */
|
|
84
|
+
field: Readonly<Ref<HTMLElement | null>>;
|
|
85
|
+
/** Open as a fullscreen panel while true — the shared narrow-viewport predicate (`useNarrowViewport`). Absent: always anchored. */
|
|
86
|
+
fullscreen?: Readonly<Ref<boolean>>;
|
|
87
|
+
/** The custom element host: light dismiss keeps gestures whose composed path includes it; its shadow root is what the anchor polyfill runs against; it is what the page lock keeps interactive. */
|
|
88
|
+
host: HTMLElement | null;
|
|
89
|
+
/** Runs inside the native `toggle` handler once closed, before focus returns. */
|
|
90
|
+
onClosed?: () => void;
|
|
91
|
+
/** Runs inside the native `toggle` handler once open, after the polyfill kick-off / page lock and the dismiss listener — the consumer's open sequence goes here. */
|
|
92
|
+
onOpened?: () => void;
|
|
93
|
+
/** The `popover="manual"` panel element. */
|
|
94
|
+
panel: Readonly<Ref<HTMLElement | null>>;
|
|
95
|
+
/** Receives focus when the panel closes via `close(true)`. */
|
|
96
|
+
returnFocusTo: MaybeRefOrGetter<HTMLElement | null | undefined>;
|
|
97
|
+
}
|
|
98
|
+
export declare const useAnchoredPanel: (options: UseAnchoredPanelOptions) => AnchoredPanel;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Designated trigger (CONTEXT.md "Trigger", ADR-0038): the `trigger` prop
|
|
3
|
+
* route of supplying an overlay component's trigger — an element elsewhere in
|
|
4
|
+
* the document, designated by ID or by reference, instead of projected into
|
|
5
|
+
* the `trigger` slot. The two routes are the same concept: the component
|
|
6
|
+
* wires its usual opening interaction and ARIA onto the designated element,
|
|
7
|
+
* exactly as it does for a slotted one.
|
|
8
|
+
*
|
|
9
|
+
* Positioning: CSS anchor names are tree-scoped, so the shadow-DOM panel
|
|
10
|
+
* cannot reference an `anchor-name` on an outer-tree element. Instead the
|
|
11
|
+
* component keeps a *proxy anchor* — an inert, fixed-position box in its own
|
|
12
|
+
* shadow root carrying the anchor name — and this composable pins it over
|
|
13
|
+
* the designated trigger's rect while the panel is open (a rAF loop, the
|
|
14
|
+
* same tracking strategy the OddBird polyfill uses). `position-area`
|
|
15
|
+
* placement and the `position-try-fallbacks` flip/shift keep working
|
|
16
|
+
* unchanged; only the measurement is JS.
|
|
17
|
+
*/
|
|
18
|
+
import { type Ref } from 'vue';
|
|
19
|
+
export interface DesignatedTriggerHandle {
|
|
20
|
+
/** The resolved designated trigger; null when the prop is unset/unresolved. */
|
|
21
|
+
element: Readonly<Ref<HTMLElement | null>>;
|
|
22
|
+
/** Re-resolve the prop (an ID may match only after later DOM insertion). */
|
|
23
|
+
resolve(): HTMLElement | null;
|
|
24
|
+
/** Pin the proxy over the trigger every frame until `stopTracking`. */
|
|
25
|
+
startTracking(): void;
|
|
26
|
+
stopTracking(): void;
|
|
27
|
+
}
|
|
28
|
+
export interface UseDesignatedTriggerOptions {
|
|
29
|
+
/** Tag name for console warnings (e.g. `c-popover`). */
|
|
30
|
+
componentName: string;
|
|
31
|
+
/** Interaction listeners kept installed on the designated element. */
|
|
32
|
+
listeners: Record<string, EventListener>;
|
|
33
|
+
/** Resolved element changed — mirror/clean ARIA here. */
|
|
34
|
+
onElementChange?: (el: HTMLElement | null, prev: HTMLElement | null) => void;
|
|
35
|
+
/** The in-shadow proxy anchor to pin over the designated trigger. */
|
|
36
|
+
proxy: Ref<HTMLElement | null>;
|
|
37
|
+
/** The raw `trigger` prop: a document ID or an element reference. */
|
|
38
|
+
source: () => HTMLElement | string | undefined;
|
|
39
|
+
}
|
|
40
|
+
export declare const useDesignatedTrigger: (options: UseDesignatedTriggerOptions) => DesignatedTriggerHandle;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host custom-state exposure — the single path for publishing a component's
|
|
3
|
+
* internal state to consumer CSS as `:state(<name>)` selectors (ADR-0035).
|
|
4
|
+
*
|
|
5
|
+
* Selection controls keep their live state (checked, indeterminate, …) on a
|
|
6
|
+
* hidden `<input>` inside the shadow root, where no consumer selector can see
|
|
7
|
+
* it. `ElementInternals.states` republishes it on the host, so a consumer can
|
|
8
|
+
* write per-state `::part()` rules:
|
|
9
|
+
*
|
|
10
|
+
* c-checkbox:state(checked)::part(indicator) { background: green; }
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
*
|
|
14
|
+
* const setState = useHostStates();
|
|
15
|
+
* watch(isChecked, (on) => setState('checked', on), { immediate: true });
|
|
16
|
+
*
|
|
17
|
+
* Each exposed state name is public API — curated like parts, documented with
|
|
18
|
+
* a `@cssstate` docblock tag so it lands in the manifest.
|
|
19
|
+
*
|
|
20
|
+
* `attachInternals()` may be called only once per element; this composable
|
|
21
|
+
* owns that call. Everything degrades to a silent no-op where internals or
|
|
22
|
+
* `states` are unavailable (SSR, tests, an ancient browser) — the component
|
|
23
|
+
* still renders and behaves, only the `:state()` selector surface is absent.
|
|
24
|
+
*/
|
|
25
|
+
export declare const useHostStates: () => ((name: string, on: boolean) => void);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Narrow viewport (CONTEXT.md "Narrow viewport", ADR-0050): the one shared
|
|
3
|
+
* predicate under which a value-selection field opens a **fullscreen panel**
|
|
4
|
+
* instead of an anchored one. Measured on the window, never on a component's
|
|
5
|
+
* own box — the panel fills the viewport, so only the viewport is relevant.
|
|
6
|
+
* The 760px threshold is c-dropdown's Stencil-era media query, kept so
|
|
7
|
+
* existing `c-select` consumers see no behaviour change.
|
|
8
|
+
*/
|
|
9
|
+
import { type Ref } from 'vue';
|
|
10
|
+
/** The media query every fullscreen-panel switch evaluates. */
|
|
11
|
+
export declare const NARROW_VIEWPORT_QUERY = "(max-width: 760px)";
|
|
12
|
+
/** One-off read; `false` where there is no window (SSR). */
|
|
13
|
+
export declare const isNarrowViewport: () => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* A live `Ref` that follows the media query. Registers its listener for the
|
|
16
|
+
* lifetime of the current effect scope (a component's setup, or an
|
|
17
|
+
* `effectScope()` in a spec); with no scope the listener stays for the page.
|
|
18
|
+
*/
|
|
19
|
+
export declare const useNarrowViewport: () => Readonly<Ref<boolean>>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scroll strip: a single-row list that scrolls sideways when it is wider
|
|
3
|
+
* than its box — the tab strip of `c-tab-buttons` (CONTEXT.md "Tab
|
|
4
|
+
* buttons"). Built on a native horizontal scroll container with its
|
|
5
|
+
* scrollbar hidden, so touch panning, momentum and keyboard focus
|
|
6
|
+
* scrolling come from the browser; this composable adds what a bare
|
|
7
|
+
* scroller lacks: overflow state for edge arrows, an arrow step, mouse
|
|
8
|
+
* drag, a vertical-wheel translation and a `reveal` that brings one child
|
|
9
|
+
* into view without scrolling the page.
|
|
10
|
+
*/
|
|
11
|
+
import type { Ref } from 'vue';
|
|
12
|
+
export interface ScrollStrip {
|
|
13
|
+
/** Scroll back by half the visible width. */
|
|
14
|
+
back(): void;
|
|
15
|
+
/** True while the strip can scroll back (its start is out of view). */
|
|
16
|
+
canBack: Ref<boolean>;
|
|
17
|
+
/** True while the strip can scroll forward (its end is out of view). */
|
|
18
|
+
canForward: Ref<boolean>;
|
|
19
|
+
/** Scroll forward by half the visible width. */
|
|
20
|
+
forward(): void;
|
|
21
|
+
/**
|
|
22
|
+
* Mouse drag scrolling: bind to the scroller's `pointerdown`. Touch and
|
|
23
|
+
* pen pan natively and are ignored here. A drag that moved swallows the
|
|
24
|
+
* `click` it would otherwise end in.
|
|
25
|
+
*/
|
|
26
|
+
onPointerDown(event: PointerEvent): void;
|
|
27
|
+
/**
|
|
28
|
+
* Translate a vertical wheel into horizontal scrolling while the strip
|
|
29
|
+
* overflows: bind to the scroller's `wheel`.
|
|
30
|
+
*/
|
|
31
|
+
onWheel(event: WheelEvent): void;
|
|
32
|
+
/** True while the content is wider than the scroller. */
|
|
33
|
+
overflowing: Ref<boolean>;
|
|
34
|
+
/** Scroll the strip just enough to bring `el` fully into view. */
|
|
35
|
+
reveal(el: Element | null | undefined): void;
|
|
36
|
+
/** Re-read the overflow state (after content changed size). */
|
|
37
|
+
update(): void;
|
|
38
|
+
}
|
|
39
|
+
export declare const useScrollStrip: (scroller: Ref<HTMLElement | null>) => ScrollStrip;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debounced polite live region for a component's status text — the
|
|
3
|
+
* announcer behind the visually hidden `aria-live="polite" aria-atomic="true"`
|
|
4
|
+
* region a value-selection field renders (`c-autocomplete`, `c-tree-select`).
|
|
5
|
+
*
|
|
6
|
+
* The 1400 ms debounce is the cadence every list panel in the library uses
|
|
7
|
+
* (`c-dropdown` / `c-select` keep their own copies for now — `set()` is the
|
|
8
|
+
* seam for a later refit): a screen reader must not hear every keystroke's
|
|
9
|
+
* intermediate count, only where the user came to rest. `announce()` takes a
|
|
10
|
+
* *compose* thunk rather than a string on purpose — it runs when the timer
|
|
11
|
+
* fires, so it reads the state current *then* (a fetch landing during the
|
|
12
|
+
* debounce is announced correctly).
|
|
13
|
+
*
|
|
14
|
+
* The region itself stays a template snippet in the consumer: it has no
|
|
15
|
+
* `part` and no slot, so a shared SFC would add an analyzer-scanned import
|
|
16
|
+
* and a child instance for no contract gain.
|
|
17
|
+
*/
|
|
18
|
+
import { type Ref } from 'vue';
|
|
19
|
+
export interface StatusAnnouncer {
|
|
20
|
+
/** Schedule an announcement. `compose` runs when the debounce fires, so it reads the state current *then*; every call restarts the timer. */
|
|
21
|
+
announce(compose: () => string): void;
|
|
22
|
+
/** Drop a pending announcement (also runs on unmount). */
|
|
23
|
+
cancel(): void;
|
|
24
|
+
/** Write immediately, dropping any pending announcement. */
|
|
25
|
+
set(text: string): void;
|
|
26
|
+
/** The live text; bind as the content of the `aria-live="polite" aria-atomic="true"` region. */
|
|
27
|
+
text: Readonly<Ref<string>>;
|
|
28
|
+
}
|
|
29
|
+
export interface UseStatusAnnouncerOptions {
|
|
30
|
+
/** Debounce before a scheduled announcement lands, in ms. Default 1400. */
|
|
31
|
+
delay?: number;
|
|
32
|
+
}
|
|
33
|
+
export declare const useStatusAnnouncer: ({ delay, }?: UseStatusAnnouncerOptions) => StatusAnnouncer;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visual viewport tracking for the **fullscreen panel** (CONTEXT.md,
|
|
3
|
+
* ADR-0050). Two layers. The *surface* — the panel element itself,
|
|
4
|
+
* `position: fixed; inset: 0` — spans the layout viewport, which the
|
|
5
|
+
* on-screen keyboard overlays but never shrinks, so it covers everything
|
|
6
|
+
* visible whatever the keyboard does. The *content box* inside it (heading
|
|
7
|
+
* row, search input, list) follows `visualViewport` — the only API that sees
|
|
8
|
+
* the iOS keyboard — so it ends above the keyboard. A late or wrong box then
|
|
9
|
+
* shows more surface, never the page. Both fullscreen implementations (the
|
|
10
|
+
* anchored-panel composable and `c-dropdown`'s dialog) go through this one
|
|
11
|
+
* helper while they are open.
|
|
12
|
+
*/
|
|
13
|
+
/** Stop following the visual viewport. Idempotent. */
|
|
14
|
+
export type StopTracking = () => void;
|
|
15
|
+
/** The visible box, in CSS px relative to the layout viewport. */
|
|
16
|
+
export interface ViewportBox {
|
|
17
|
+
height: number;
|
|
18
|
+
left: number;
|
|
19
|
+
top: number;
|
|
20
|
+
width: number;
|
|
21
|
+
}
|
|
22
|
+
/** The current visual viewport box; `null` where the API is missing (then the content box fills the surface). */
|
|
23
|
+
export declare const readVisualViewport: () => null | ViewportBox;
|
|
24
|
+
/**
|
|
25
|
+
* Report the visual viewport's box now and on every resize / scroll of it
|
|
26
|
+
* (the keyboard opening and closing, the address bar collapsing, the browser
|
|
27
|
+
* panning a focused input into view). With no API the callback runs once
|
|
28
|
+
* with `null` and nothing is listened to.
|
|
29
|
+
*/
|
|
30
|
+
export declare const trackVisualViewport: (onBox: (box: null | ViewportBox) => void) => StopTracking;
|
|
31
|
+
/**
|
|
32
|
+
* Inline declarations that make a top-layer element the surface: the layout
|
|
33
|
+
* viewport's box. Overrides the UA popover / dialog defaults (`inset: 0` is
|
|
34
|
+
* theirs too, but with fit-content sizing and auto margins).
|
|
35
|
+
*/
|
|
36
|
+
export declare const FULLSCREEN_SURFACE_STYLE = "position:fixed;inset:0;margin:0;width:auto;height:auto;";
|
|
37
|
+
/**
|
|
38
|
+
* Inline declarations placing the content box inside the surface on the
|
|
39
|
+
* visual viewport's box; with no box (no API) it fills the surface.
|
|
40
|
+
*/
|
|
41
|
+
export declare const contentBoxStyle: (box: null | ViewportBox) => string;
|
|
42
|
+
/**
|
|
43
|
+
* `FULLSCREEN_SURFACE_STYLE` written straight onto an element's inline style,
|
|
44
|
+
* for a surface whose placement is imperative (`c-dropdown`'s dialog). Margins
|
|
45
|
+
* are left to its classes.
|
|
46
|
+
*/
|
|
47
|
+
export declare const applyFullscreenSurface: (el: HTMLElement) => void;
|
|
48
|
+
/** `contentBoxStyle(box)` written straight onto an element's inline style. */
|
|
49
|
+
export declare const applyContentBox: (el: HTMLElement, box: null | ViewportBox) => void;
|
|
50
|
+
/** Remove exactly what `applyContentBox` set. */
|
|
51
|
+
export declare const clearContentBox: (el: HTMLElement) => void;
|