@cscfi/csc-ui 4.0.0-alpha.3 → 4.0.0-alpha.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/csc-ui.js +14305 -8019
  2. package/dist/custom-elements.json +8952 -4605
  3. package/dist/docs/c-alert/usage.md +24 -0
  4. package/dist/docs/c-autocomplete/usage.md +152 -0
  5. package/dist/docs/c-breadcrumb/usage.md +104 -0
  6. package/dist/docs/c-breadcrumb-item/usage.md +1 -0
  7. package/dist/docs/c-button-group/usage.md +14 -1
  8. package/dist/docs/c-checkbox/usage.md +53 -0
  9. package/dist/docs/c-date-picker/usage.md +224 -0
  10. package/dist/docs/c-main/usage.md +21 -1
  11. package/dist/docs/c-menu/usage.md +15 -0
  12. package/dist/docs/c-menu-item/usage.md +6 -0
  13. package/dist/docs/c-number-field/usage.md +112 -0
  14. package/dist/docs/c-option-value/usage.md +1 -0
  15. package/dist/docs/c-popover/usage.md +33 -0
  16. package/dist/docs/c-progress-bar/usage.md +23 -0
  17. package/dist/docs/c-progress-circle/usage.md +25 -0
  18. package/dist/docs/c-radio/usage.md +45 -0
  19. package/dist/docs/c-radio-group/usage.md +67 -0
  20. package/dist/docs/c-select/usage.md +127 -0
  21. package/dist/docs/c-side-navigation/usage.md +21 -0
  22. package/dist/docs/c-spinner/usage.md +21 -0
  23. package/dist/docs/c-switch/usage.md +36 -0
  24. package/dist/docs/c-tab-buttons/usage.md +7 -0
  25. package/dist/docs/c-table/usage.md +14 -0
  26. package/dist/docs/c-text-field/usage.md +106 -0
  27. package/dist/docs/c-time-picker/usage.md +170 -0
  28. package/dist/docs/c-toolbar/usage.md +17 -0
  29. package/dist/docs/c-tooltip/usage.md +30 -0
  30. package/dist/docs/c-tree-select/usage.md +156 -0
  31. package/dist/floating-ui.dom-DvzxEaDJ.js +1292 -0
  32. package/dist/styles/css/tailwind-theme.css +33 -0
  33. package/dist/styles/css/tokens.css +719 -197
  34. package/dist/vscode.css-custom-data.json +474 -20
  35. package/dist/vscode.html-custom-data.json +659 -57
  36. package/dist/web-types.json +2813 -697
  37. package/dist-types/components/c-alert/CAlert.vue.d.ts +18 -4
  38. package/dist-types/components/c-autocomplete/CAutocomplete.vue.d.ts +118 -21
  39. package/dist-types/components/c-breadcrumb/CBreadcrumb.vue.d.ts +35 -0
  40. package/dist-types/components/c-breadcrumb/fit.d.ts +29 -0
  41. package/dist-types/components/c-breadcrumb-item/CBreadcrumbItem.vue.d.ts +31 -0
  42. package/dist-types/components/c-button/CButton.vue.d.ts +4 -4
  43. package/dist-types/components/c-button-group/CButtonGroup.vue.d.ts +1 -1
  44. package/dist-types/components/c-checkbox/CCheckbox.vue.d.ts +3 -3
  45. package/dist-types/components/c-data-table/CDataTable.vue.d.ts +6 -2
  46. package/dist-types/components/c-date-picker/CDatePicker.vue.d.ts +282 -0
  47. package/dist-types/components/c-date-picker/dates.d.ts +119 -0
  48. package/dist-types/components/c-dropdown/CDropdown.vue.d.ts +50 -7
  49. package/dist-types/components/c-icon-button/CIconButton.vue.d.ts +1 -1
  50. package/dist-types/components/c-input/CInput.vue.d.ts +6 -6
  51. package/dist-types/components/c-list-item/CListItem.vue.d.ts +1 -1
  52. package/dist-types/components/c-main/CMain.vue.d.ts +10 -2
  53. package/dist-types/components/c-menu/CMenu.vue.d.ts +13 -3
  54. package/dist-types/components/c-menu-item/CMenuItem.vue.d.ts +30 -3
  55. package/dist-types/components/c-number-field/CNumberField.vue.d.ts +174 -0
  56. package/dist-types/components/c-number-field/numbers.d.ts +58 -0
  57. package/dist-types/components/c-otp-input/COtpInput.vue.d.ts +1 -1
  58. package/dist-types/components/c-pagination/CPagination.vue.d.ts +1 -1
  59. package/dist-types/components/c-popover/CPopover.vue.d.ts +43 -0
  60. package/dist-types/components/c-progress-circle/CProgressCircle.vue.d.ts +32 -0
  61. package/dist-types/components/c-radio/CRadio.vue.d.ts +7 -11
  62. package/dist-types/components/c-radio-group/CRadioGroup.vue.d.ts +10 -48
  63. package/dist-types/components/c-select/CSelect.vue.d.ts +115 -27
  64. package/dist-types/components/c-side-navigation/CSideNavigation.vue.d.ts +1 -1
  65. package/dist-types/components/c-side-navigation-item/CSideNavigationItem.vue.d.ts +1 -1
  66. package/dist-types/components/c-slider/CSlider.vue.d.ts +3 -3
  67. package/dist-types/components/c-sub-navigation-item/CSubNavigationItem.vue.d.ts +1 -1
  68. package/dist-types/components/c-tab-buttons/CTabButtons.vue.d.ts +1 -1
  69. package/dist-types/components/c-table/CTable.vue.d.ts +11 -1
  70. package/dist-types/components/c-table/injectTableStyles.d.ts +1 -0
  71. package/dist-types/components/c-tag/CTag.vue.d.ts +7 -0
  72. package/dist-types/components/c-tags/CTags.vue.d.ts +1 -1
  73. package/dist-types/components/c-text-field/CTextField.vue.d.ts +27 -10
  74. package/dist-types/components/c-time-picker/CTimePicker.vue.d.ts +210 -0
  75. package/dist-types/components/c-time-picker/times.d.ts +82 -0
  76. package/dist-types/components/c-toasts/CToasts.vue.d.ts +1 -1
  77. package/dist-types/components/c-toolbar/CToolbar.vue.d.ts +10 -1
  78. package/dist-types/components/c-tooltip/CTooltip.vue.d.ts +49 -0
  79. package/dist-types/components/c-tree-select/CTreeSelect.vue.d.ts +261 -0
  80. package/dist-types/index.d.ts +19 -2
  81. package/dist-types/shared/FieldMessage.vue.d.ts +21 -0
  82. package/dist-types/shared/PanelHeadingRow.vue.d.ts +13 -0
  83. package/dist-types/shared/SelectionIndicator.vue.d.ts +21 -0
  84. package/dist-types/shared/TypedField.vue.d.ts +46 -0
  85. package/dist-types/shared/appDefaults.d.ts +75 -0
  86. package/dist-types/shared/defineElement.d.ts +1 -0
  87. package/dist-types/shared/inputMask.d.ts +106 -0
  88. package/dist-types/shared/lightDismiss.d.ts +35 -0
  89. package/dist-types/shared/modalStack.d.ts +4 -3
  90. package/dist-types/shared/optionLabel.d.ts +18 -0
  91. package/dist-types/shared/pageLock.d.ts +26 -0
  92. package/dist-types/shared/peekCap.d.ts +35 -0
  93. package/dist-types/shared/popoverChain.d.ts +65 -0
  94. package/dist-types/shared/positionArea.d.ts +13 -0
  95. package/dist-types/shared/reducedMotion.d.ts +10 -0
  96. package/dist-types/shared/selectAll.d.ts +29 -0
  97. package/dist-types/shared/splitMatches.d.ts +18 -0
  98. package/dist-types/shared/useAnchoredPanel.d.ts +102 -0
  99. package/dist-types/shared/useDesignatedTrigger.d.ts +41 -0
  100. package/dist-types/shared/useFallbackPosition.d.ts +63 -0
  101. package/dist-types/shared/useHostStates.d.ts +25 -0
  102. package/dist-types/shared/useKeyboardModality.d.ts +7 -0
  103. package/dist-types/shared/useNarrowViewport.d.ts +19 -0
  104. package/dist-types/shared/useScrollStrip.d.ts +39 -0
  105. package/dist-types/shared/useStatusAnnouncer.d.ts +33 -0
  106. package/dist-types/shared/useTypedField.d.ts +103 -0
  107. package/dist-types/shared/visualViewport.d.ts +51 -0
  108. package/dist-types/tag-name-map.d.ts +769 -54
  109. package/dist-types/theme/chart-data.d.ts +51 -0
  110. package/dist-types/theme/ramp.d.ts +38 -0
  111. package/dist-types/theme/themeMode.d.ts +51 -0
  112. package/dist-types/types.d.ts +7 -0
  113. package/package.json +21 -9
  114. package/dist/css-anchor-positioning-fn-RTxo68pt.js +0 -6447
  115. package/dist-types/shared/anchorPolyfill.d.ts +0 -24
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The label of a slotted `<c-option>` — what a value-selection field shows
3
+ * for the option in its row, its closed field and its tags, and what
4
+ * `c-autocomplete`'s filter matches (ADR-0045).
5
+ *
6
+ * Resolution chain:
7
+ * 1. the option's `name` (the property, else the attribute — the element may
8
+ * not be upgraded yet when a parent reads it during mount);
9
+ * 2. else the text of its first `<c-option-value>`, the label region: it
10
+ * lets an option carry richer content (a description, an icon) that is
11
+ * not part of the label;
12
+ * 3. else the option's whole text content.
13
+ *
14
+ * Trimmed; an empty `name` counts as absent. Callers keep their own last
15
+ * resort (the raw value) so a label is never blank.
16
+ */
17
+ export declare const optionValueElement: (option: Element) => Element | null;
18
+ export declare const optionLabel: (option: HTMLElement) => string;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Page lock (ADR-0014, ADR-0050): library-owned modality for surfaces that
3
+ * must own the page without entering the browser's modal top layer — which
4
+ * would inert the toasts. While any holder is registered, everything outside
5
+ * the *active* holder's host is `inert` (a `c-toasts` anywhere stays
6
+ * interactive) and document scroll is locked.
7
+ *
8
+ * Holders form a stack; the most recently locked host is the active one. The
9
+ * modal stack pushes each opening `c-modal` here, and a **fullscreen panel**
10
+ * pushes its field's host — so a select opened inside a modal on a phone
11
+ * inerts the modal's other content along with the page, and closing it hands
12
+ * the page back to the modal. Consumer-set `inert` is never touched.
13
+ */
14
+ /** True while `host` holds the lock (active or below another holder). */
15
+ export declare const isPageLockedBy: (host: HTMLElement) => boolean;
16
+ /**
17
+ * Register `host` as the active holder: everything outside it goes inert and
18
+ * the document stops scrolling. Idempotent for a host already holding.
19
+ */
20
+ export declare const lockPage: (host: HTMLElement) => void;
21
+ /**
22
+ * Release `host` (idempotent). The next holder down, if any, becomes active
23
+ * and the inert set is re-derived for it; with no holder left the page is
24
+ * fully interactive and scrolls again.
25
+ */
26
+ export declare const unlockPage: (host: HTMLElement) => void;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The peek (CONTEXT.md, ADR-0043).
3
+ *
4
+ * A transient list panel — the menu and submenu panels, `c-dropdown`'s
5
+ * listbox, `c-autocomplete`'s options list — hides its scrollbar. In its
6
+ * place an overflowing list must end at an item row's midpoint: the
7
+ * half-visible row is the one cue that more rows follow. This module computes
8
+ * that cap from the real row boxes, so mixed-height menus (items, labels,
9
+ * dividers) and taller slotted option rows cut correctly.
10
+ */
11
+ export interface PeekCapOptions {
12
+ /**
13
+ * Upper bound for the list's `max-height`, in px. `Infinity` for none.
14
+ * `applyPeekCap` defaults it to the list's stylesheet `max-height`.
15
+ */
16
+ ceiling?: number;
17
+ /** Full rows shown before the peek. `0` (or less): no row cap. */
18
+ itemsPerPage?: number;
19
+ /** Item rows in visual order — only these can be the peek row. */
20
+ rows: readonly HTMLElement[];
21
+ }
22
+ /**
23
+ * The `max-height` (px) that ends `list` at a row midpoint, or `null` when
24
+ * the content fits and needs no cap. Rows are located relative to the list's
25
+ * scroll content (rect deltas plus `scrollTop`), so the result is independent
26
+ * of the panel's positioning scheme and of any cap currently applied.
27
+ */
28
+ export declare const peekCap: (list: HTMLElement, { ceiling, itemsPerPage, rows }: PeekCapOptions) => null | number;
29
+ /**
30
+ * Write the peek cap as the list's inline `max-height` (cleared when no cap
31
+ * is needed). Without `ceiling` the list's stylesheet `max-height` (e.g.
32
+ * `max-h-[80vh]`, or a consumer's `::part()` override) is the ceiling; the
33
+ * inline value is cleared first so that stylesheet value is what gets read.
34
+ */
35
+ export declare const applyPeekCap: (list: HTMLElement, options: PeekCapOptions) => void;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Popover chain controller (CONTEXT.md "Popover chain", ADR-0038).
3
+ *
4
+ * The ordered set of currently open `c-popover`s, each logically nested in
5
+ * the one before it. This module is the single owner of popover dismissal:
6
+ *
7
+ * - **Escape** peels the innermost popover only, one per press. The listener
8
+ * is capture-phase and calls `preventDefault()`, so an enclosing
9
+ * `c-modal`'s bubble-phase controller sees the claimed key and does not
10
+ * close itself (ADR-0014). Known pre-existing limitation: a `c-menu`, or a
11
+ * `c-breadcrumb`'s fold panel, open inside a popover listens on its own
12
+ * host (bubble), i.e. *after* this capture listener — that Escape closes
13
+ * both, exactly as it did when each popover owned its own capture listener.
14
+ * - **Light dismiss** (CONTEXT.md, ADR-0050) closes every popover that does
15
+ * not *logically* contain the pointer gesture. A press and its release are
16
+ * paired (`lightDismiss.ts` — a press alone, the start of every touch
17
+ * scroll, closes nothing); from the innermost down, everything above the
18
+ * deepest member whose own inside (host subtree, panel, designated
19
+ * trigger) contains either composed path is closed. Containment is
20
+ * logical, not DOM ancestry — a popover whose host lives elsewhere still
21
+ * shields its ancestors, because ancestry is recorded in the chain itself,
22
+ * not re-derived from the DOM.
23
+ * - **Opening** a popover whose trigger sits inside an open member joins the
24
+ * chain below it; one whose trigger is elsewhere replaces the chain.
25
+ * Siblings therefore never coexist.
26
+ * - **Closing** any member (Escape, light dismiss, `open` prop, unmount)
27
+ * closes its descendants — no orphaned floating panels.
28
+ *
29
+ * Why a shared module: each popover's Escape listener is capture-phase on
30
+ * `document`, and `preventDefault()` does not stop other listeners — two
31
+ * independent popovers cannot see each other's claim, so one press closed
32
+ * them all. Coordination needs a single owner, mirroring `modalStack.ts`.
33
+ */
34
+ export interface PopoverChainEntry {
35
+ /** Close this popover with no focus return (light dismiss / chain cleanup). */
36
+ close(): void;
37
+ /** True when `node` is inside this popover's own logical inside. */
38
+ containsNode(node: Node): boolean;
39
+ /** True when a composed event path passes through this popover's own inside. */
40
+ containsPath(path: EventTarget[]): boolean;
41
+ /**
42
+ * The node that chains this popover under an open ancestor: its designated
43
+ * trigger, else its slotted trigger, else its host.
44
+ */
45
+ getAnchorNode(): Node | null;
46
+ /** Escape routed here — this popover is the innermost. Decides focus return. */
47
+ onEscape(): void;
48
+ }
49
+ /**
50
+ * Shadow-piercing containment: like `Node.contains` but hopping from a shadow
51
+ * root to its host, so content inside a descendant component's shadow root
52
+ * (and slotted light DOM) counts as inside.
53
+ */
54
+ export declare const composedContains: (ancestor: Node, node: Node | null) => boolean;
55
+ /**
56
+ * Register an opening popover. Resolves its chain parent from where its
57
+ * anchor node sits; members that would become siblings are closed first.
58
+ * Idempotent.
59
+ */
60
+ export declare const enterChain: (entry: PopoverChainEntry) => void;
61
+ /**
62
+ * Unregister a closing popover (idempotent) and close its descendants —
63
+ * whatever closed it, nothing may stay floating above it.
64
+ */
65
+ export declare const leaveChain: (entry: PopoverChainEntry) => void;
@@ -0,0 +1,13 @@
1
+ import type { CPlacement } from '../types';
2
+ /**
3
+ * `CPlacement` → CSS `position-area`, shared by the anchor-positioned overlay
4
+ * components (`c-menu`, `c-tooltip`, `c-popover`; ADR-0008). Native flip/shift
5
+ * comes from each component's `position-try-fallbacks` escape-hatch rule.
6
+ */
7
+ export declare const POSITION_AREA: Record<CPlacement, string>;
8
+ /**
9
+ * The logical axis of a placement's side — the axis the trigger→panel gap
10
+ * margin is applied on (both sides, so the gap survives the position-try
11
+ * flip fallbacks).
12
+ */
13
+ export declare const placementAxis: (position: CPlacement) => "block" | "inline";
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The OS-level reduced-motion preference (CONTEXT.md "Reduced motion",
3
+ * ADR-0057). CSS motion honours it from the shared utility sheet; this is the
4
+ * read for motion a script drives — the ripple, smooth strip scrolling, the
5
+ * tabs indicator, the modal keyframes. Read at the moment of use, not once at
6
+ * mount, so a preference toggled while the page is open is picked up.
7
+ *
8
+ * Returns false where `matchMedia` is missing (SSR, a bare test runtime).
9
+ */
10
+ export declare const prefersReducedMotion: () => boolean;
@@ -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,102 @@
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`,
6
+ * `c-tree-select` and `c-date-picker` (whose field is editable and whose
7
+ * calendar keeps its own width: `matchWidth: false`, ADR-0058). One panel, two layouts: **anchored** under the field, or
8
+ * — on a **narrow viewport** — a **fullscreen panel** covering the viewport.
9
+ *
10
+ * What it owns:
11
+ * - the anchor. CSS anchor names are tree-scoped, so the consumer wraps its
12
+ * value field in a shadow-DOM box carrying `anchor-name`; `anchorStyle`
13
+ * supplies that declaration and `panelStyle` the matching
14
+ * `position-anchor` / `position-area` plus the panel width pinned to the
15
+ * anchor's rect on open;
16
+ * - the field-box pull-back. The anchor wrapper spans the whole inner
17
+ * `c-input`, INCLUDING its hint / error message area (reserved unless
18
+ * `hide-details` is set), the gap above it and an on-top label. The
19
+ * panel must sit flush against the field box itself — the same 0px every
20
+ * dropdown keeps (`c-select`'s listbox, `c-menu`'s default `distance`) —
21
+ * so on open the distance from the anchor's bottom edge to the field
22
+ * box's bottom edge is measured and pulled back with a negative
23
+ * block-start margin, and the distance from the anchor's top edge to the
24
+ * field box's top edge is published as `--_c-field-panel-top-offset` for
25
+ * the consumer's flipped-above `@position-try` rules;
26
+ * - the fullscreen layout: chosen at `open()` from the `fullscreen`
27
+ * predicate and kept for the whole open (crossing the threshold while open
28
+ * closes the panel). The panel drops anchor positioning and becomes the
29
+ * surface — `position: fixed; inset: 0`, the layout viewport, which the
30
+ * on-screen keyboard overlays but never shrinks — while the card inside it
31
+ * follows the *visual* viewport (`visualViewport` resize / scroll while
32
+ * open; `cardStyle`), so the heading row and search input stay above the
33
+ * keyboard and the page never shows beside them. The page behind it is
34
+ * locked (`pageLock.ts`: inert except toasts, no document scroll);
35
+ * - open / close through `showPopover()` / `hidePopover()` on a
36
+ * `popover="manual"` panel, with the native `toggle` event as the single
37
+ * source of truth for `isOpen` (browser-initiated closes included);
38
+ * - light dismiss (CONTEXT.md "Light dismiss", ADR-0050): a press and its
39
+ * release both outside the host close the panel; a press alone — the
40
+ * start of every touch scroll — never does (`lightDismiss.ts`);
41
+ * - focus return to the value field on `close(true)`;
42
+ * - the Floating UI placement on an anchored open without native anchor
43
+ * positioning (Firefox 140 ESR; ADR-0056).
44
+ *
45
+ * What stays in the consumer: the `@position-try --c-field-panel-above` /
46
+ * `--c-field-panel-above-left` flip rules and `position-try-fallbacks` —
47
+ * per-shadow-root escape-hatch CSS (ADR-0007; each element type has its own
48
+ * adopted sheet, so the block is copy-identical in every consumer) — the
49
+ * fullscreen `tv` variant (the panel paints the surface, the card sheds its
50
+ * anchored chrome, the list takes the rest, the heading row) and the open
51
+ * sequence (peek cap, focus, highlight seed, announcement), run from
52
+ * `onOpened` synchronously inside the `toggle` handler.
53
+ */
54
+ import { type ComputedRef, type MaybeRefOrGetter, type Ref } from 'vue';
55
+ /**
56
+ * The `anchor-name` every anchored field panel uses. Anchor names are
57
+ * tree-scoped, so one name serves every consumer's shadow root.
58
+ */
59
+ export declare const FIELD_PANEL_ANCHOR = "--c-field-panel-anchor";
60
+ export interface AnchoredPanel {
61
+ /** Inline style for the anchor wrapper: `anchor-name: --c-field-panel-anchor`. */
62
+ anchorStyle: string;
63
+ /** 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). */
64
+ cardStyle: ComputedRef<string>;
65
+ /** Hide the panel; `returnFocus` moves focus to `returnFocusTo` once the `toggle` event confirms the close. */
66
+ close(returnFocus?: boolean): void;
67
+ /** Open state — written only by the native `toggle` event (single source of truth, browser-initiated closes included). */
68
+ isOpen: Readonly<Ref<boolean>>;
69
+ /** The layout of the current open, fixed at `open()` for its whole duration; `'anchored'` — the resting shape, no heading row — while closed. */
70
+ layout: ComputedRef<PanelLayout>;
71
+ /** Bind as the panel's `@toggle` handler. */
72
+ onToggle(event: Event): void;
73
+ /** Choose the layout, measure (anchored: the anchor width and the field box's offsets from the anchor's edges), then `showPopover()`. */
74
+ open(): void;
75
+ /** 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. */
76
+ panelStyle: ComputedRef<string>;
77
+ }
78
+ /** The two layouts one field panel takes (CONTEXT.md "Fullscreen panel"). */
79
+ export type PanelLayout = 'anchored' | 'fullscreen';
80
+ export interface UseAnchoredPanelOptions {
81
+ /** Shadow-DOM wrapper around the value field; carries `anchor-name`, and its rect pins the panel width. */
82
+ anchor: Readonly<Ref<HTMLElement | null>>;
83
+ /** `open()` is a no-op while this returns true (the field's `disabled`). */
84
+ disabled?: () => boolean;
85
+ /** 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. */
86
+ field: Readonly<Ref<HTMLElement | null>>;
87
+ /** Open as a fullscreen panel while true — the shared narrow-viewport predicate (`useNarrowViewport`). Absent: always anchored. */
88
+ fullscreen?: Readonly<Ref<boolean>>;
89
+ /** The custom element host: light dismiss keeps gestures whose composed path includes it; it is what the page lock keeps interactive. */
90
+ host: HTMLElement | null;
91
+ /** Pin the anchored panel's width to the anchor's (default `true`). `false` lets the card size the panel — a calendar keeps its own width whatever the field's. */
92
+ matchWidth?: boolean;
93
+ /** Runs inside the native `toggle` handler once closed, before focus returns. */
94
+ onClosed?: () => void;
95
+ /** Runs inside the native `toggle` handler once open, after the fallback positioning / page lock and the dismiss listener — the consumer's open sequence goes here. */
96
+ onOpened?: () => void;
97
+ /** The `popover="manual"` panel element. */
98
+ panel: Readonly<Ref<HTMLElement | null>>;
99
+ /** Receives focus when the panel closes via `close(true)`. */
100
+ returnFocusTo: MaybeRefOrGetter<HTMLElement | null | undefined>;
101
+ }
102
+ export declare const useAnchoredPanel: (options: UseAnchoredPanelOptions) => AnchoredPanel;
@@ -0,0 +1,41 @@
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).
14
+ * `position-area` placement and the `position-try-fallbacks` flip/shift keep
15
+ * working unchanged; only the measurement is JS. Without native anchor
16
+ * positioning the proxy is unused: Floating UI places the panel against the
17
+ * designated element directly (`useFallbackPosition`, ADR-0056).
18
+ */
19
+ import { type Ref } from 'vue';
20
+ export interface DesignatedTriggerHandle {
21
+ /** The resolved designated trigger; null when the prop is unset/unresolved. */
22
+ element: Readonly<Ref<HTMLElement | null>>;
23
+ /** Re-resolve the prop (an ID may match only after later DOM insertion). */
24
+ resolve(): HTMLElement | null;
25
+ /** Pin the proxy over the trigger every frame until `stopTracking`. */
26
+ startTracking(): void;
27
+ stopTracking(): void;
28
+ }
29
+ export interface UseDesignatedTriggerOptions {
30
+ /** Tag name for console warnings (e.g. `c-popover`). */
31
+ componentName: string;
32
+ /** Interaction listeners kept installed on the designated element. */
33
+ listeners: Record<string, EventListener>;
34
+ /** Resolved element changed — mirror/clean ARIA here. */
35
+ onElementChange?: (el: HTMLElement | null, prev: HTMLElement | null) => void;
36
+ /** The in-shadow proxy anchor to pin over the designated trigger. */
37
+ proxy: Ref<HTMLElement | null>;
38
+ /** The raw `trigger` prop: a document ID or an element reference. */
39
+ source: () => HTMLElement | string | undefined;
40
+ }
41
+ export declare const useDesignatedTrigger: (options: UseDesignatedTriggerOptions) => DesignatedTriggerHandle;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Anchored-panel positioning for browsers without CSS anchor positioning
3
+ * (Firefox 140 ESR; ADR-0056).
4
+ *
5
+ * The overlay components place their top-layer panels with native CSS anchor
6
+ * positioning — `anchor-name` / `position-anchor` / `position-area` plus a
7
+ * `position-try-fallbacks` chain. A browser without the feature drops those
8
+ * declarations, so this composable computes the same placement with
9
+ * `@floating-ui/dom` instead: the preferred placement, then the component's
10
+ * fallback chain in the native order (first one that fits wins, the preferred
11
+ * one when none fits), the gap as an offset. When even the chosen placement
12
+ * overflows, the panel is shifted back inside the viewport on both axes, as a
13
+ * native `position-area` box is kept inside its containing block — a panel
14
+ * larger than the viewport starts at its top/left edge. The clamp applies to
15
+ * the margin box natively, so the gap pads the viewport on the placement's
16
+ * axis. The result is a style string the
17
+ * component appends to its panel style — never written to `el.style` directly,
18
+ * which Vue's next `:style` patch would wipe.
19
+ *
20
+ * On a browser with native support every method is a no-op and `style` stays
21
+ * empty, so the native path is untouched. Floating UI is imported lazily, and
22
+ * preloaded at setup where it will be needed so the first open does not wait
23
+ * on it.
24
+ *
25
+ * Each consumer's `fallbacks` mirror its `position-try-fallbacks` rule; keep
26
+ * the two in step.
27
+ */
28
+ import { type Ref } from 'vue';
29
+ import type { CPlacement } from '../types';
30
+ type Side = 'bottom' | 'left' | 'right' | 'top';
31
+ /** True when the browser positions anchors without this fallback. */
32
+ export declare const supportsAnchorPositioning: () => boolean;
33
+ /** The `flip-block` try-tactic: mirror across the block axis. */
34
+ export declare const flipBlock: (placement: CPlacement) => CPlacement;
35
+ /** The `flip-inline` try-tactic: mirror across the inline axis. */
36
+ export declare const flipInline: (placement: CPlacement) => CPlacement;
37
+ /**
38
+ * `position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline`
39
+ * — the chain of `c-menu`, `c-tooltip` and `c-popover` — from `placement`.
40
+ */
41
+ export declare const flipChain: (placement: CPlacement) => CPlacement[];
42
+ export interface FallbackPosition {
43
+ /** Start positioning — call once the panel is open. */
44
+ start(): void;
45
+ /** Stop tracking — call when the panel closes. */
46
+ stop(): void;
47
+ /** Declarations to append to the panel's inline style; empty with native support. */
48
+ style: Readonly<Ref<string>>;
49
+ }
50
+ export interface UseFallbackPositionOptions {
51
+ /** Ordered fallback placements, mirroring the panel's `position-try-fallbacks`. */
52
+ fallbacks: (placement: CPlacement) => CPlacement[];
53
+ /** The `popover` panel. */
54
+ floating: Readonly<Ref<HTMLElement | null>>;
55
+ /** The trigger→panel gap in px on the resolved placement's side (negative pulls the panel in). */
56
+ gap: (side: Side) => number;
57
+ /** The preferred placement (the inline `position-area`). */
58
+ placement: () => CPlacement;
59
+ /** The element the panel sits against. */
60
+ reference: () => Element | null | undefined;
61
+ }
62
+ export declare const useFallbackPosition: (options: UseFallbackPositionOptions) => FallbackPosition;
63
+ export {};
@@ -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,7 @@
1
+ /**
2
+ * Track the host's keyboard modality for the lifetime of the current effect
3
+ * scope. Returns `focusOptions`, which adds `focusVisible: true` to a script
4
+ * focus under keyboard modality and otherwise leaves the browser to decide —
5
+ * never `focusVisible: false`.
6
+ */
7
+ export declare const useKeyboardModality: (host: HTMLElement | null | undefined) => ((options?: FocusOptions) => FocusOptions);
@@ -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;