@cscfi/csc-ui 4.0.0-alpha.13 → 4.0.0-alpha.15

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 (41) hide show
  1. package/dist/csc-ui.js +8257 -7166
  2. package/dist/custom-elements.json +841 -44
  3. package/dist/docs/c-autocomplete/usage.md +25 -2
  4. package/dist/docs/c-button-group/usage.md +1 -1
  5. package/dist/docs/c-select/usage.md +25 -2
  6. package/dist/docs/c-tree-select/usage.md +156 -0
  7. package/dist/styles/css/tokens.css +2 -1
  8. package/dist/vscode.css-custom-data.json +97 -0
  9. package/dist/vscode.html-custom-data.json +94 -3
  10. package/dist/web-types.json +388 -15
  11. package/dist-types/components/c-autocomplete/CAutocomplete.vue.d.ts +32 -8
  12. package/dist-types/components/c-button/CButton.vue.d.ts +1 -1
  13. package/dist-types/components/c-button-group/CButtonGroup.vue.d.ts +1 -1
  14. package/dist-types/components/c-checkbox/CCheckbox.vue.d.ts +1 -1
  15. package/dist-types/components/c-data-table/CDataTable.vue.d.ts +5 -1
  16. package/dist-types/components/c-dropdown/CDropdown.vue.d.ts +27 -12
  17. package/dist-types/components/c-icon-button/CIconButton.vue.d.ts +1 -1
  18. package/dist-types/components/c-input/CInput.vue.d.ts +2 -2
  19. package/dist-types/components/c-otp-input/COtpInput.vue.d.ts +1 -1
  20. package/dist-types/components/c-pagination/CPagination.vue.d.ts +1 -1
  21. package/dist-types/components/c-radio-group/CRadioGroup.vue.d.ts +1 -1
  22. package/dist-types/components/c-select/CSelect.vue.d.ts +32 -8
  23. package/dist-types/components/c-switch/CSwitch.vue.d.ts +1 -1
  24. package/dist-types/components/c-tag/CTag.vue.d.ts +1 -1
  25. package/dist-types/components/c-text-field/CTextField.vue.d.ts +11 -4
  26. package/dist-types/components/c-tree-select/CTreeSelect.vue.d.ts +261 -0
  27. package/dist-types/index.d.ts +3 -0
  28. package/dist-types/shared/FormLabel.vue.d.ts +1 -1
  29. package/dist-types/shared/PanelHeadingRow.vue.d.ts +13 -0
  30. package/dist-types/shared/appDefaults.d.ts +75 -0
  31. package/dist-types/shared/defineElement.d.ts +1 -0
  32. package/dist-types/shared/lightDismiss.d.ts +35 -0
  33. package/dist-types/shared/modalStack.d.ts +4 -3
  34. package/dist-types/shared/pageLock.d.ts +26 -0
  35. package/dist-types/shared/popoverChain.d.ts +9 -6
  36. package/dist-types/shared/useAnchoredPanel.d.ts +89 -0
  37. package/dist-types/shared/useNarrowViewport.d.ts +19 -0
  38. package/dist-types/shared/useStatusAnnouncer.d.ts +33 -0
  39. package/dist-types/shared/visualViewport.d.ts +35 -0
  40. package/dist-types/tag-name-map.d.ts +137 -9
  41. package/package.json +13 -4
@@ -0,0 +1,75 @@
1
+ /**
2
+ * App-wide prop defaults (ADR-0048).
3
+ *
4
+ * A consumer sets a *defaultable* prop once for every instance of a tag —
5
+ * `labelOnTop` on every text field, one `texts` translation per list field —
6
+ * instead of repeating it per instance:
7
+ *
8
+ * applyDefaults({ 'c-text-field': { labelOnTop: true } });
9
+ *
10
+ * Only props tagged `@defaultable <built-in>` in their SFC take part; the
11
+ * analyzer derives the `AppDefaults` type and the `DEFAULTABLE_PROPS`
12
+ * allow-list from those tags (src/tag-name-map.ts). Each such prop declares
13
+ * `undefined` in `withDefaults` — so "unset" is observable — and resolves
14
+ * through `useAppDefault` below, in this order:
15
+ *
16
+ * host attribute → own property (non-nullish) → app default → built-in
17
+ *
18
+ * Why the host attribute comes first — two Vue `defineCustomElement` quirks:
19
+ * 1. A Boolean prop supplied via *attribute* (`<c-select hide-details>`)
20
+ * has been observed to reset to its default on the wrapper's re-render
21
+ * (it re-renders on every value change): the host attribute persists,
22
+ * but the prop flips. The attribute is the stable signal.
23
+ * 2. Binding `hide-details` to a nested `c-input` in a template is mangled
24
+ * on update — the key matches c-input's declared prop, so Vue treats it
25
+ * as a property, and the reset above reflects back out and removes the
26
+ * attribute. Wrappers therefore forward it through a plain
27
+ * `data-hide-details` attribute (no declared-prop collision, so Vue
28
+ * patches it reliably) that c-input reads back.
29
+ * Property writes reflect to attributes as well (`el.size = 'small'` writes
30
+ * `size="small"`, `el.labelOnTop = false` removes the attribute), so one
31
+ * attribute-first order is sound for Booleans, strings and numbers alike.
32
+ *
33
+ * The registry is a module-level `reactive()` object and every resolved
34
+ * computed depends on it, so a later `applyDefaults()` re-renders mounted
35
+ * elements (runtime language switching). Not provide/inject: the library
36
+ * coordinates through module singletons (modalStack, popoverChain,
37
+ * applyTheme), and a per-element app context would not be live for trees
38
+ * that are already mounted.
39
+ */
40
+ import { type ComputedRef } from 'vue';
41
+ import { type AppDefaults } from '../tag-name-map';
42
+ export type { AppDefaults } from '../tag-name-map';
43
+ export { DEFAULTABLE_PROPS } from '../tag-name-map';
44
+ /** A tag with at least one defaultable prop. */
45
+ export type DefaultableTag = keyof AppDefaults;
46
+ type Bucket<T extends DefaultableTag> = NonNullable<AppDefaults[T]>;
47
+ /** The value a resolved prop takes: the element member type, made required. */
48
+ type Resolved<T extends DefaultableTag, K extends keyof Bucket<T>> = Required<NonNullable<Bucket<T>[K]>>;
49
+ /**
50
+ * Set app-wide defaults. Merges with previously applied defaults tag by tag;
51
+ * a key set to `undefined` clears that key. An object prop (`texts`) is stored
52
+ * whole and merged key by key with the built-in and per-instance texts at each
53
+ * element. Live: mounted elements re-render. No-op outside the browser — a
54
+ * module-level registry must not leak across server requests, and custom
55
+ * elements never render on the server.
56
+ */
57
+ export declare function applyDefaults(defaults: AppDefaults): void;
58
+ /** Clear the app-wide defaults of the given tags, or of every tag when omitted. */
59
+ export declare function resetDefaults(tags?: DefaultableTag[]): void;
60
+ /**
61
+ * Per-instance resolver for defaultable props. Call once in setup, then one
62
+ * line per prop:
63
+ *
64
+ * const appDefault = useAppDefault('c-text-field', props);
65
+ * const labelOnTopResolved = appDefault('labelOnTop', false);
66
+ *
67
+ * Scalars: host attribute → own property (non-nullish) → app default →
68
+ * built-in, with Boolean coercion applied *after* the layer is chosen
69
+ * (`coerceBoolean(undefined)` is `false` and would swallow the fallthrough).
70
+ * Objects (`texts`): per-key merge, built-in ← app default ← own.
71
+ *
72
+ * A nullish own value counts as "unset" (Vue itself treats `null` as an
73
+ * explicit value; here it falls through to the app default).
74
+ */
75
+ export declare const useAppDefault: <T extends DefaultableTag>(tag: T, props: object) => <K extends keyof Bucket<T> & string>(key: K, builtIn: Resolved<T, K>) => ComputedRef<Resolved<T, K>>;
@@ -1,4 +1,5 @@
1
1
  import { type Component } from 'vue';
2
+ export declare const hyphenate: (key: string) => string;
2
3
  /**
3
4
  * Register a Vue SFC as a custom element under `tag`, with the shared Tailwind
4
5
  * utility stylesheet applied to its shadow root alongside the SFC's own styles.
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Light dismiss (CONTEXT.md "Light dismiss", ADR-0050): the platform's rule
3
+ * for closing a transient surface from the pointer, shared by every surface
4
+ * that implements dismissal itself — the anchored field panels
5
+ * (`useAnchoredPanel`), the popover chain and `c-menu`, all of which are
6
+ * `popover="manual"` and so get nothing from the browser.
7
+ *
8
+ * A native `popover="auto"` does not close on `pointerdown`: the browser
9
+ * remembers where the press landed and dismisses on the matching `pointerup`
10
+ * only when *both* fell outside. A touch scroll begins with a `pointerdown`
11
+ * and turns into `pointercancel`, never `pointerup`, so scrolling the page
12
+ * under an open surface leaves it open. The hand-rolled `pointerdown`
13
+ * listeners this module replaces closed the panel on the first touch of every
14
+ * scroll — the bug that made `c-tree-select` unusable on a phone.
15
+ *
16
+ * Listeners are capture-phase on `document`, like the ones they replace, so a
17
+ * consumer's `stopPropagation()` cannot hide an outside press from them.
18
+ */
19
+ /** Detach the listeners `attachPointerPair` / `attachLightDismiss` installed. Idempotent. */
20
+ export type Detach = () => void;
21
+ /**
22
+ * Report each completed primary-pointer press-and-release pair with both
23
+ * composed paths. A press that ends in `pointercancel` — a touch that became a
24
+ * scroll or a pan — is dropped, and a release with no press seen since attach
25
+ * (the gesture that opened the surface) is ignored.
26
+ */
27
+ export declare const attachPointerPair: (onPair: (down: EventTarget[], up: EventTarget[]) => void) => Detach;
28
+ export interface LightDismissOptions {
29
+ /** True when a composed event path passes through the surface's own inside (host subtree, panel, designated trigger). */
30
+ isInside(path: EventTarget[]): boolean;
31
+ /** The press and its release both landed outside: close the surface. */
32
+ onDismiss(): void;
33
+ }
34
+ /** The single-surface case: dismiss when press and release both landed outside. */
35
+ export declare const attachLightDismiss: (options: LightDismissOptions) => Detach;
@@ -13,9 +13,10 @@
13
13
  * below the toast band,
14
14
  * - **backdrop visibility**: exactly one backdrop — the active modal's — is
15
15
  * visible at a time,
16
- * - **inertness**: everything outside the active modal is `inert`, except
17
- * `c-toasts` (toasts stay interactive above any modal),
18
- * - **scroll lock** on the document while the stack is non-empty,
16
+ * - **inertness** and **scroll lock**, delegated to the shared page lock
17
+ * (`pageLock.ts`, ADR-0050): everything outside the active modal is
18
+ * `inert` except `c-toasts`, and the document stops scrolling while the
19
+ * stack is non-empty,
19
20
  * - **Escape routing** to the active modal only, and
20
21
  * - **focus restore** to the element focused when each modal opened.
21
22
  */
@@ -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;
@@ -11,12 +11,15 @@
11
11
  * inside a popover listens on its own host (bubble), i.e. *after* this
12
12
  * capture listener — that Escape closes both, exactly as it did when each
13
13
  * popover owned its own capture listener.
14
- * - **Pointerdown** closes every popover that does not *logically* contain
15
- * the event: from the innermost down, everything above the deepest member
16
- * whose own inside (host subtree, panel, designated trigger) contains the
17
- * composed path is closed. Containment is logical, not DOM ancestry — a
18
- * popover whose host lives elsewhere still shields its ancestors, because
19
- * ancestry is recorded in the chain itself, not re-derived from the DOM.
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.
20
23
  * - **Opening** a popover whose trigger sits inside an open member joins the
21
24
  * chain below it; one whose trigger is elsewhere replaces the chain.
22
25
  * Siblings therefore never coexist.
@@ -0,0 +1,89 @@
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 message 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 panel must sit flush under the field
18
+ * itself, so the `[part='message']` height is measured on open and pulled
19
+ * back with a negative block-start margin;
20
+ * - the fullscreen layout: chosen at `open()` from the `fullscreen`
21
+ * predicate and kept for the whole open (crossing the threshold while open
22
+ * closes the panel). The panel drops anchor positioning and follows the
23
+ * *visual* viewport — `visualViewport` resize / scroll while open — so the
24
+ * heading row and search input stay above the on-screen keyboard;
25
+ * `100dvh` where the API is missing. The page behind it is locked
26
+ * (`pageLock.ts`: inert except toasts, no document scroll);
27
+ * - open / close through `showPopover()` / `hidePopover()` on a
28
+ * `popover="manual"` panel, with the native `toggle` event as the single
29
+ * source of truth for `isOpen` (browser-initiated closes included);
30
+ * - light dismiss (CONTEXT.md "Light dismiss", ADR-0050): a press and its
31
+ * release both outside the host close the panel; a press alone — the
32
+ * start of every touch scroll — never does (`lightDismiss.ts`);
33
+ * - focus return to the value field on `close(true)`;
34
+ * - the OddBird anchor polyfill kick-off on an anchored open (Firefox).
35
+ *
36
+ * What stays in the consumer: the `@position-try --c-field-panel-above` /
37
+ * `--c-field-panel-above-left` flip rules and `position-try-fallbacks` —
38
+ * per-shadow-root escape-hatch CSS (ADR-0007; each element type has its own
39
+ * adopted sheet, so the block is copy-identical in every consumer) — the
40
+ * fullscreen `tv` variant (card fills the panel, list takes the rest, the
41
+ * heading row) and the open sequence (peek cap, focus, highlight seed,
42
+ * announcement), run from `onOpened` synchronously inside the `toggle`
43
+ * handler.
44
+ */
45
+ import { type ComputedRef, type MaybeRefOrGetter, type Ref } from 'vue';
46
+ /**
47
+ * The `anchor-name` every anchored field panel uses. Anchor names are
48
+ * tree-scoped, so one name serves every consumer's shadow root.
49
+ */
50
+ export declare const FIELD_PANEL_ANCHOR = "--c-field-panel-anchor";
51
+ export interface AnchoredPanel {
52
+ /** Inline style for the anchor wrapper: `anchor-name: --c-field-panel-anchor`. */
53
+ anchorStyle: string;
54
+ /** Hide the panel; `returnFocus` moves focus to `returnFocusTo` once the `toggle` event confirms the close. */
55
+ close(returnFocus?: boolean): void;
56
+ /** Open state — written only by the native `toggle` event (single source of truth, browser-initiated closes included). */
57
+ isOpen: Readonly<Ref<boolean>>;
58
+ /** The layout of the current open, fixed at `open()` for its whole duration; `'anchored'` — the resting shape, no heading row — while closed. */
59
+ layout: ComputedRef<PanelLayout>;
60
+ /** Bind as the panel's `@toggle` handler. */
61
+ onToggle(event: Event): void;
62
+ /** Choose the layout, measure (anchored: the anchor width and the field's message height), then `showPopover()`. */
63
+ open(): void;
64
+ /** Inline style for the panel: anchored — `position-anchor`, `position-area: bottom span-right`, `inset: auto`, the pinned width and the message pull-back; fullscreen — the visual viewport's box. */
65
+ panelStyle: ComputedRef<string>;
66
+ }
67
+ /** The two layouts one field panel takes (CONTEXT.md "Fullscreen panel"). */
68
+ export type PanelLayout = 'anchored' | 'fullscreen';
69
+ export interface UseAnchoredPanelOptions {
70
+ /** Shadow-DOM wrapper around the value field; carries `anchor-name`, and its rect pins the panel width. */
71
+ anchor: Readonly<Ref<HTMLElement | null>>;
72
+ /** `open()` is a no-op while this returns true (the field's `disabled`). */
73
+ disabled?: () => boolean;
74
+ /** The inner `c-input` host: its `[part='message']` height is pulled back so the panel sits flush under the field box. */
75
+ field: Readonly<Ref<HTMLElement | null>>;
76
+ /** Open as a fullscreen panel while true — the shared narrow-viewport predicate (`useNarrowViewport`). Absent: always anchored. */
77
+ fullscreen?: Readonly<Ref<boolean>>;
78
+ /** 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. */
79
+ host: HTMLElement | null;
80
+ /** Runs inside the native `toggle` handler once closed, before focus returns. */
81
+ onClosed?: () => void;
82
+ /** 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. */
83
+ onOpened?: () => void;
84
+ /** The `popover="manual"` panel element. */
85
+ panel: Readonly<Ref<HTMLElement | null>>;
86
+ /** Receives focus when the panel closes via `close(true)`. */
87
+ returnFocusTo: MaybeRefOrGetter<HTMLElement | null | undefined>;
88
+ }
89
+ export declare const useAnchoredPanel: (options: UseAnchoredPanelOptions) => AnchoredPanel;
@@ -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,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,35 @@
1
+ /**
2
+ * Visual viewport tracking for the **fullscreen panel** (CONTEXT.md,
3
+ * ADR-0050). A `position: fixed` top-layer surface sized with `100dvh` does
4
+ * not shrink when the on-screen keyboard opens on iOS — only the
5
+ * `visualViewport` API reports the visible box there. Both fullscreen
6
+ * implementations (the anchored-panel composable and `c-dropdown`'s dialog)
7
+ * follow it through this one helper while they are open.
8
+ */
9
+ /** Stop following the visual viewport. Idempotent. */
10
+ export type StopTracking = () => void;
11
+ /** The visible box, in CSS px relative to the layout viewport. */
12
+ export interface ViewportBox {
13
+ height: number;
14
+ left: number;
15
+ top: number;
16
+ width: number;
17
+ }
18
+ /** The current visual viewport box; `null` where the API is missing (then size with `100dvh`). */
19
+ export declare const readVisualViewport: () => null | ViewportBox;
20
+ /**
21
+ * Report the visual viewport's box now and on every resize / scroll of it
22
+ * (the keyboard opening and closing, the address bar collapsing, the browser
23
+ * panning a focused input into view). With no API the callback runs once
24
+ * with `null` and nothing is listened to.
25
+ */
26
+ export declare const trackVisualViewport: (onBox: (box: null | ViewportBox) => void) => StopTracking;
27
+ /**
28
+ * Inline declarations that make a `position: fixed` surface the visual
29
+ * viewport's box — or, with no box, the layout viewport (`100dvh`). Both
30
+ * override the UA popover / dialog defaults (`inset: 0`, fit-content sizing,
31
+ * auto margins).
32
+ */
33
+ export declare const fullscreenBoxStyle: (box: null | ViewportBox) => string;
34
+ /** The same box written straight onto an element's inline style (for a surface whose placement is imperative, like `c-dropdown`'s dialog). */
35
+ export declare const applyFullscreenBox: (el: HTMLElement, box: null | ViewportBox) => void;
@@ -5,13 +5,16 @@
5
5
  * Typed element interfaces for every registered custom element, plus the
6
6
  * global `HTMLElementTagNameMap` augmentation that makes
7
7
  * `document.createElement('c-button')` and `querySelector('c-button')`
8
- * return the typed element.
8
+ * return the typed element. Also the `AppDefaults` map (tag → props a
9
+ * consumer may set app-wide with `applyDefaults()`) and its runtime twin
10
+ * `DEFAULTABLE_PROPS`, both derived from the `@defaultable` prop tags.
9
11
  */
10
12
  import type { CAutocompleteFilter, CAutocompleteItem, CAutocompleteTexts, CAutocompleteValue } from './components/c-autocomplete/CAutocomplete.vue';
11
13
  import type { CButtonGroupValue } from './components/c-button-group/CButtonGroup.vue';
12
14
  import type { CDataTableCellContent, CDataTableColumn, CDataTableExpandedContext, CDataTableRow, CDataTableSort, CDataTableTexts } from './components/c-data-table/CDataTable.vue';
13
15
  import type { CPaginationOptions } from './components/c-pagination/CPagination.vue';
14
16
  import type { CSelectTexts, CSelectValue } from './components/c-select/CSelect.vue';
17
+ import type { CTreeSelectFilter, CTreeSelectItem, CTreeSelectTexts, CTreeSelectValue } from './components/c-tree-select/CTreeSelect.vue';
15
18
  import type { CSelectItem, CToastMessage } from './types';
16
19
  type AccordionPrimitive = number | string;
17
20
  type AccordionValue = AccordionPrimitive | AccordionPrimitive[] | null;
@@ -522,6 +525,11 @@ export interface CDropdownElementEventMap {
522
525
  * state.
523
526
  */
524
527
  dropdownStateChange: CustomEvent<boolean>;
528
+ /**
529
+ * Fired when the select-all row is activated; the parent (c-select) toggles
530
+ * every listed enabled option.
531
+ */
532
+ selectall: CustomEvent<void>;
525
533
  /**
526
534
  * Fired when the user selects an option row, carrying the option's name
527
535
  * and value for the parent (c-select) to commit.
@@ -530,13 +538,10 @@ export interface CDropdownElementEventMap {
530
538
  name: string;
531
539
  value: number | string;
532
540
  }>;
533
- /**
534
- * Fired when the select-all row is activated; the parent (c-select) toggles
535
- * every listed enabled option.
536
- */
537
- selectall: CustomEvent<void>;
538
541
  }
539
- export interface CDropdownElement extends Omit<HTMLElement, 'dropdownItemType' | 'hostId' | 'index' | 'items' | 'itemsPerPage' | 'multiple' | 'parent' | 'selectAllRow' | 'selected' | 'type'> {
542
+ export interface CDropdownElement extends Omit<HTMLElement, 'closeLabel' | 'dropdownItemType' | 'hostId' | 'index' | 'items' | 'itemsPerPage' | 'label' | 'multiple' | 'parent' | 'selectAllRow' | 'selected' | 'type'> {
543
+ /** Accessible label of the fullscreen panel's close button (narrow viewports) */
544
+ closeLabel?: string;
540
545
  /** Whether items are <c-option> elements or plain objects */
541
546
  dropdownItemType?: 'item' | 'option';
542
547
  /** Id used to build option/announce element ids */
@@ -547,6 +552,8 @@ export interface CDropdownElement extends Omit<HTMLElement, 'dropdownItemType' |
547
552
  items?: ArrayLike<DropdownItem>;
548
553
  /** Items per page before adding scroll */
549
554
  itemsPerPage?: number;
555
+ /** The parent field's label, shown as the fullscreen panel's heading (narrow viewports) */
556
+ label?: string;
550
557
  /**
551
558
  * Multi-select mode: rows toggle instead of committing, each carries a
552
559
  * decorative checkbox indicator, and the listbox is `aria-multiselectable`
@@ -560,8 +567,9 @@ export interface CDropdownElement extends Omit<HTMLElement, 'dropdownItemType' |
560
567
  */
561
568
  selectAllRow?: CDropdownSelectAllRow | null;
562
569
  /**
563
- * Values of the currently selected items in `multiple` mode; drives each
564
- * row's `aria-selected` and its indicator
570
+ * Values of the currently selected items — the picked values in `multiple`
571
+ * mode, the single value otherwise; drives each row's `aria-selected`, its
572
+ * indicator and the single-mode selected-row check
565
573
  */
566
574
  selected?: (number | string)[];
567
575
  /** Parent type — drives autocomplete-only behaviour (highlight, messages) */
@@ -1708,6 +1716,125 @@ export interface CTooltipElement extends Omit<HTMLElement, 'delay' | 'distance'
1708
1716
  removeEventListener<K extends keyof CTooltipElementEventMap>(type: K, listener: (this: CTooltipElement, ev: CTooltipElementEventMap[K]) => void, options?: boolean | EventListenerOptions): void;
1709
1717
  removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
1710
1718
  }
1719
+ /** Events dispatched by `<c-tree-select>`. */
1720
+ export interface CTreeSelectElementEventMap {
1721
+ /**
1722
+ * Fired when the selection changes — an item is committed or the selection
1723
+ * is cleared — carrying the new value: the item's value, the
1724
+ * `CTreeSelectSelection` with `return-object`, or `null` when cleared.
1725
+ */
1726
+ change: CustomEvent<CTreeSelectValue>;
1727
+ /**
1728
+ * Fired whenever the query changes — on every keystroke in the search
1729
+ * input, and with an empty string when the panel opens. Carries the query
1730
+ * string.
1731
+ */
1732
+ 'change:query': CustomEvent<string>;
1733
+ /**
1734
+ * Native bubbling input event dispatched alongside every value change so a
1735
+ * plain `v-model` stays in sync. Carries no detail.
1736
+ */
1737
+ input: CustomEvent<void>;
1738
+ /** Fired alongside `change` with the same detail — the `v-model` contract. */
1739
+ 'update:value': CustomEvent<CTreeSelectValue>;
1740
+ }
1741
+ /** A hierarchical value-selection component: a readonly value field that opens a panel for browsing a tree one level at a time, or searching it as a whole, to commit one item. */
1742
+ export interface CTreeSelectElement extends Omit<HTMLElement, 'allowBranch' | 'clearable' | 'disabled' | 'errorMessage' | 'filter' | 'hideDetails' | 'hint' | 'hostId' | 'items' | 'itemsPerPage' | 'label' | 'labelOnTop' | 'levelLabels' | 'name' | 'placeholder' | 'required' | 'returnObject' | 'shadow' | 'size' | 'texts' | 'valid' | 'value'> {
1743
+ /**
1744
+ * Let a branch be committed as the value: a pinned select-branch row heads
1745
+ * every level below the root, and matching branches are listed as search
1746
+ * results
1747
+ */
1748
+ allowBranch?: boolean;
1749
+ /** Make the selected value clearable */
1750
+ clearable?: boolean;
1751
+ /** Disable the field */
1752
+ disabled?: boolean;
1753
+ /** Error message shown in place of the hint while the field is invalid */
1754
+ errorMessage?: string;
1755
+ /**
1756
+ * Custom search predicate; receives the item, the query and the item's
1757
+ * ancestors. Functions have no attribute form — bind as a DOM property
1758
+ */
1759
+ filter?: CTreeSelectFilter;
1760
+ /** Hide the hint and error messages */
1761
+ hideDetails?: boolean;
1762
+ /** Hint text for the field */
1763
+ hint?: string;
1764
+ /** Id of the element */
1765
+ hostId?: string;
1766
+ /**
1767
+ * The tree to pick from. Arrays have no attribute form — bind as a DOM
1768
+ * property (`:items.prop` in Vue)
1769
+ */
1770
+ items?: CTreeSelectItem[];
1771
+ /** Items per page before the list scrolls */
1772
+ itemsPerPage?: number;
1773
+ /** Element label */
1774
+ label?: string;
1775
+ /** Label on top of the field */
1776
+ labelOnTop?: boolean;
1777
+ /**
1778
+ * Names of the levels, top level first, shown in the panel header; a
1779
+ * missing entry falls back to `texts.level(n)`. Arrays have no attribute
1780
+ * form — bind as a DOM property
1781
+ */
1782
+ levelLabels?: string[];
1783
+ /** Input field name */
1784
+ name?: string;
1785
+ /** Placeholder for the search input inside the panel */
1786
+ placeholder?: string;
1787
+ /** Set the field as required */
1788
+ required?: boolean;
1789
+ /**
1790
+ * Emit the committed item with its path as a `CTreeSelectSelection` instead
1791
+ * of its value
1792
+ */
1793
+ returnObject?: boolean;
1794
+ /** Shadow variant */
1795
+ shadow?: boolean;
1796
+ /** Field height: the 44px default or the 36px `small` box */
1797
+ size?: 'default' | 'small';
1798
+ /**
1799
+ * UI text overrides (i18n), merged over the English defaults. Objects have
1800
+ * no attribute form — bind as a DOM property (`:texts.prop` in Vue)
1801
+ */
1802
+ texts?: CTreeSelectTexts;
1803
+ /** Set the validity of the field */
1804
+ valid?: boolean;
1805
+ /**
1806
+ * Selected value: the committed item's value, or the `CTreeSelectSelection`
1807
+ * with `return-object`; `null` when nothing is selected
1808
+ */
1809
+ value?: CTreeSelectValue;
1810
+ addEventListener<K extends keyof CTreeSelectElementEventMap>(type: K, listener: (this: CTreeSelectElement, ev: CTreeSelectElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
1811
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
1812
+ removeEventListener<K extends keyof CTreeSelectElementEventMap>(type: K, listener: (this: CTreeSelectElement, ev: CTreeSelectElementEventMap[K]) => void, options?: boolean | EventListenerOptions): void;
1813
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
1814
+ }
1815
+ /**
1816
+ * Props a consumer may set for every instance of a tag with
1817
+ * `applyDefaults()` (`@defaultable` in the manifest), typed as the
1818
+ * element's own members. An explicit per-instance attribute or property
1819
+ * always wins over an app default.
1820
+ */
1821
+ export interface AppDefaults {
1822
+ 'c-autocomplete'?: Partial<Pick<CAutocompleteElement, 'hideDetails' | 'itemsPerPage' | 'labelOnTop' | 'shadow' | 'size' | 'texts'>>;
1823
+ 'c-data-table'?: Partial<Pick<CDataTableElement, 'texts'>>;
1824
+ 'c-select'?: Partial<Pick<CSelectElement, 'hideDetails' | 'itemsPerPage' | 'labelOnTop' | 'shadow' | 'size' | 'texts'>>;
1825
+ 'c-text-field'?: Partial<Pick<CTextFieldElement, 'hideDetails' | 'labelOnTop' | 'shadow' | 'size'>>;
1826
+ 'c-tree-select'?: Partial<Pick<CTreeSelectElement, 'hideDetails' | 'itemsPerPage' | 'labelOnTop' | 'shadow' | 'size' | 'texts'>>;
1827
+ }
1828
+ /** Runtime allow-list behind `applyDefaults()` validation — the same data as `AppDefaults`. */
1829
+ export declare const DEFAULTABLE_PROPS: {
1830
+ readonly 'c-autocomplete': readonly ["hideDetails", "itemsPerPage", "labelOnTop", "shadow", "size", "texts"];
1831
+ readonly 'c-data-table': readonly ["texts"];
1832
+ readonly 'c-select': readonly ["hideDetails", "itemsPerPage", "labelOnTop", "shadow", "size", "texts"];
1833
+ readonly 'c-text-field': readonly ["hideDetails", "labelOnTop", "shadow", "size"];
1834
+ readonly 'c-tree-select': readonly ["hideDetails", "itemsPerPage", "labelOnTop", "shadow", "size", "texts"];
1835
+ };
1836
+ /** Tags dispatching the v-model contract event `update:value` — the value controls (CONTEXT.md). */
1837
+ export declare const VALUE_TAGS: readonly ["c-accordion", "c-autocomplete", "c-button-group", "c-checkbox", "c-modal", "c-otp-input", "c-pagination", "c-radio-group", "c-select", "c-slider", "c-switch", "c-tabs", "c-text-field", "c-tree-select"];
1711
1838
  declare global {
1712
1839
  interface HTMLElementTagNameMap {
1713
1840
  'c-accordion': CAccordionElement;
@@ -1781,6 +1908,7 @@ declare global {
1781
1908
  'c-toasts': CToastsElement;
1782
1909
  'c-toolbar': CToolbarElement;
1783
1910
  'c-tooltip': CTooltipElement;
1911
+ 'c-tree-select': CTreeSelectElement;
1784
1912
  }
1785
1913
  }
1786
1914
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cscfi/csc-ui",
3
- "version": "4.0.0-alpha.13",
3
+ "version": "4.0.0-alpha.15",
4
4
  "description": "Vue 3-based replacement for @cscfi/csc-ui — same custom element tag names, Vue v-model contract.",
5
5
  "type": "module",
6
6
  "main": "./dist/csc-ui.js",
@@ -33,8 +33,9 @@
33
33
  "@eslint/js": "^9.28.0",
34
34
  "@stylistic/eslint-plugin": "^5.7.0",
35
35
  "@tailwindcss/vite": "^4.3.1",
36
- "@types/node": "^20.0.0",
36
+ "@types/node": "^24.0.0",
37
37
  "@vitejs/plugin-vue": "^6.0.7",
38
+ "@vitest/browser-playwright": "5.0.0",
38
39
  "custom-element-jet-brains-integration": "^1.7.0",
39
40
  "custom-element-vs-code-integration": "^1.5.0",
40
41
  "eslint": "^9.28.0",
@@ -44,12 +45,14 @@
44
45
  "eslint-plugin-prettier": "^5.5.6",
45
46
  "eslint-plugin-vue": "^10.9.2",
46
47
  "globals": "^17.7.0",
48
+ "playwright": "1.60.0",
47
49
  "prettier": "^3.8.5",
48
50
  "style-dictionary": "^3.9.0",
49
51
  "tailwindcss": "^4.3.1",
50
52
  "typescript": "^6.0.3",
51
53
  "typescript-eslint": "^8.62.0",
52
54
  "vite": "^8.1.0",
55
+ "vitest": "5.0.0",
53
56
  "vue-tsc": "^3.3.5"
54
57
  },
55
58
  "license": "MIT",
@@ -67,10 +70,16 @@
67
70
  "lint:a11y": "node scripts/check-host-attr-fallthrough.mjs",
68
71
  "lint:contrast": "node scripts/audit-contrast.mjs",
69
72
  "lint:ramp": "node scripts/check-ramp-parity.mjs",
70
- "lint:tokens": "node scripts/check-palette-utilities.mjs",
73
+ "lint:tokens": "node scripts/check-palette-utilities.mjs --strict",
71
74
  "style-dictionary:build": "style-dictionary build --config ./style-dictionary.config.cjs",
72
75
  "type-check": "vue-tsc --build --force",
73
76
  "chart:generate": "node scripts/generate-chart-data.mjs",
74
- "lint:chart": "node scripts/check-chart-parity.mjs"
77
+ "lint:chart": "node scripts/check-chart-parity.mjs",
78
+ "lint": "pnpm run lint:tokens && pnpm run lint:a11y && pnpm run lint:ramp && pnpm run lint:chart",
79
+ "test": "pnpm run style-dictionary:build && vitest run",
80
+ "test:watch": "vitest",
81
+ "test:browser": "vitest run --project browser",
82
+ "test:node": "vitest run --project node",
83
+ "test:update": "pnpm run style-dictionary:build && vitest run --project browser --update"
75
84
  }
76
85
  }