@cscfi/csc-ui 4.0.0-alpha.5 → 4.0.0-alpha.7

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.
@@ -14,6 +14,14 @@ export interface CPopoverProps {
14
14
  open?: boolean;
15
15
  /** Preferred placement of the panel relative to the trigger. */
16
16
  position?: CPlacement;
17
+ /**
18
+ * Designated trigger: an element elsewhere in the document that opens the
19
+ * popover — its document ID, or the element itself. The same trigger
20
+ * concept as the `trigger` slot, supplied by reference: the popover wires
21
+ * click-to-toggle, ARIA and focus return onto it and anchors the panel to
22
+ * it. When both routes are supplied, this prop wins over the slot.
23
+ */
24
+ trigger?: HTMLElement | string;
17
25
  }
18
26
  declare const _default: typeof __VLS_export;
19
27
  export default _default;
@@ -22,6 +30,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<CPopov
22
30
  open: boolean;
23
31
  distance: number | string;
24
32
  position: CPlacement;
33
+ trigger: HTMLElement | string;
25
34
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
26
35
  trigger?: (props: {}) => any;
27
36
  } & {
@@ -14,7 +14,13 @@ declare var __VLS_1: {};
14
14
  type __VLS_Slots = {} & {
15
15
  default?: (props: typeof __VLS_1) => any;
16
16
  };
17
- declare const __VLS_base: import("vue").DefineComponent<CRadioProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<CRadioProps> & Readonly<{}>, {
17
+ declare const __VLS_base: import("vue").DefineComponent<CRadioProps, {
18
+ _syncGroupState: (state: {
19
+ checked: boolean;
20
+ disabled: boolean;
21
+ tabIndex: number;
22
+ }) => void;
23
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<CRadioProps> & Readonly<{}>, {
18
24
  value: string;
19
25
  disabled: boolean;
20
26
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -12,9 +12,19 @@ interface CTableProps {
12
12
  */
13
13
  responsive?: boolean;
14
14
  }
15
- declare const __VLS_export: import("vue").DefineComponent<CTableProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<CTableProps> & Readonly<{}>, {
15
+ declare var __VLS_1: {};
16
+ type __VLS_Slots = {} & {
17
+ default?: (props: typeof __VLS_1) => any;
18
+ };
19
+ declare const __VLS_base: import("vue").DefineComponent<CTableProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<CTableProps> & Readonly<{}>, {
16
20
  mobileBreakpoint: number;
17
21
  responsive: boolean;
18
22
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
23
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
19
24
  declare const _default: typeof __VLS_export;
20
25
  export default _default;
26
+ type __VLS_WithSlots<T, S> = T & {
27
+ new (): {
28
+ $slots: S;
29
+ };
30
+ };
@@ -0,0 +1 @@
1
+ export declare const ensureTableStyles: () => void;
@@ -18,6 +18,15 @@ export interface CTooltipProps {
18
18
  * @freeform
19
19
  */
20
20
  text?: string;
21
+ /**
22
+ * Designated trigger: an element elsewhere in the document that the
23
+ * tooltip describes — its document ID, or the element itself. The same
24
+ * trigger concept as the `trigger` slot, supplied by reference: the
25
+ * tooltip wires hover/focus, mirrors `aria-description` onto it and
26
+ * anchors the bubble to it. When both routes are supplied, this prop wins
27
+ * over the slot.
28
+ */
29
+ trigger?: HTMLElement | string;
21
30
  }
22
31
  declare const _default: typeof __VLS_export;
23
32
  export default _default;
@@ -26,6 +35,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<CToolt
26
35
  open: boolean;
27
36
  distance: number | string;
28
37
  position: CPlacement;
38
+ trigger: HTMLElement | string;
29
39
  delay: number | string;
30
40
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
31
41
  trigger?: (props: {}) => any;
@@ -0,0 +1,62 @@
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` open
11
+ * inside a popover listens on its own host (bubble), i.e. *after* this
12
+ * capture listener — that Escape closes both, exactly as it did when each
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.
20
+ * - **Opening** a popover whose trigger sits inside an open member joins the
21
+ * chain below it; one whose trigger is elsewhere replaces the chain.
22
+ * Siblings therefore never coexist.
23
+ * - **Closing** any member (Escape, light dismiss, `open` prop, unmount)
24
+ * closes its descendants — no orphaned floating panels.
25
+ *
26
+ * Why a shared module: each popover's Escape listener is capture-phase on
27
+ * `document`, and `preventDefault()` does not stop other listeners — two
28
+ * independent popovers cannot see each other's claim, so one press closed
29
+ * them all. Coordination needs a single owner, mirroring `modalStack.ts`.
30
+ */
31
+ export interface PopoverChainEntry {
32
+ /** Close this popover with no focus return (light dismiss / chain cleanup). */
33
+ close(): void;
34
+ /** True when `node` is inside this popover's own logical inside. */
35
+ containsNode(node: Node): boolean;
36
+ /** True when a composed event path passes through this popover's own inside. */
37
+ containsPath(path: EventTarget[]): boolean;
38
+ /**
39
+ * The node that chains this popover under an open ancestor: its designated
40
+ * trigger, else its slotted trigger, else its host.
41
+ */
42
+ getAnchorNode(): Node | null;
43
+ /** Escape routed here — this popover is the innermost. Decides focus return. */
44
+ onEscape(): void;
45
+ }
46
+ /**
47
+ * Shadow-piercing containment: like `Node.contains` but hopping from a shadow
48
+ * root to its host, so content inside a descendant component's shadow root
49
+ * (and slotted light DOM) counts as inside.
50
+ */
51
+ export declare const composedContains: (ancestor: Node, node: Node | null) => boolean;
52
+ /**
53
+ * Register an opening popover. Resolves its chain parent from where its
54
+ * anchor node sits; members that would become siblings are closed first.
55
+ * Idempotent.
56
+ */
57
+ export declare const enterChain: (entry: PopoverChainEntry) => void;
58
+ /**
59
+ * Unregister a closing popover (idempotent) and close its descendants —
60
+ * whatever closed it, nothing may stay floating above it.
61
+ */
62
+ export declare const leaveChain: (entry: PopoverChainEntry) => void;
@@ -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);
@@ -95,12 +95,18 @@ export interface CAlertElementEventMap {
95
95
  */
96
96
  dismiss: CustomEvent<void>;
97
97
  }
98
- export interface CAlertElement extends Omit<HTMLElement, 'dismissible' | 'type'> {
98
+ /** A persistent, in-flow status message: a tinted box whose type carries a status family's colours through the icon, heading and accent edge, while the body copy stays neutral. */
99
+ export interface CAlertElement extends Omit<HTMLElement, 'dismissible' | 'heading' | 'type'> {
99
100
  /**
100
101
  * Show a dismiss button. The alert only emits `dismiss` — removing it from
101
102
  * the page stays the consumer's job.
102
103
  */
103
104
  dismissible?: boolean;
105
+ /**
106
+ * Heading rendered above the message. The `heading` slot overrides it for
107
+ * rich content.
108
+ */
109
+ heading?: string;
104
110
  /** Type of the alert */
105
111
  type?: 'default' | 'error' | 'info' | 'success' | 'warning';
106
112
  addEventListener<K extends keyof CAlertElementEventMap>(type: K, listener: (this: CAlertElement, ev: CAlertElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
@@ -337,6 +343,7 @@ export interface CCheckboxElementEventMap {
337
343
  */
338
344
  'update:value': CustomEvent<boolean | number | string>;
339
345
  }
346
+ /** A form control for a single on/off choice: a native checkbox with a label, an optional hint, and validation messaging. */
340
347
  export interface CCheckboxElement extends Omit<HTMLElement, 'checked' | 'disabled' | 'errorMessage' | 'falseValue' | 'hideDetails' | 'hint' | 'hostId' | 'hostName' | 'indeterminate' | 'label' | 'required' | 'trueValue' | 'valid' | 'value'> {
341
348
  /** If `true`, the checkbox is selected. */
342
349
  checked?: boolean;
@@ -696,13 +703,22 @@ export interface CMenuElementEventMap {
696
703
  value: unknown;
697
704
  }>;
698
705
  }
699
- export interface CMenuElement extends Omit<HTMLElement, 'distance' | 'open' | 'position'> {
706
+ export interface CMenuElement extends Omit<HTMLElement, 'distance' | 'open' | 'position' | 'trigger'> {
700
707
  /** Distance from the trigger to the panel, in pixels. Defaults to `0`. */
701
708
  distance?: number | string;
702
709
  /** Whether the menu is open. Two-way: emits `change:open`. */
703
710
  open?: boolean;
704
711
  /** Preferred placement of the panel relative to the trigger. */
705
712
  position?: 'bottom-end' | 'bottom-start' | 'bottom' | 'left-end' | 'left-start' | 'left' | 'right-end' | 'right-start' | 'right' | 'top-end' | 'top-start' | 'top';
713
+ /**
714
+ * Designated trigger: an element elsewhere in the document that opens the
715
+ * menu — its document ID, or the element itself. The same trigger concept
716
+ * as the `trigger` slot, supplied by reference: the menu wires
717
+ * click-to-toggle, arrow-key opening, ARIA and focus return onto it and
718
+ * anchors the panel to it. When both routes are supplied, this prop wins
719
+ * over the slot.
720
+ */
721
+ trigger?: HTMLElement | string;
706
722
  addEventListener<K extends keyof CMenuElementEventMap>(type: K, listener: (this: CMenuElement, ev: CMenuElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
707
723
  addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
708
724
  removeEventListener<K extends keyof CMenuElementEventMap>(type: K, listener: (this: CMenuElement, ev: CMenuElementEventMap[K]) => void, options?: boolean | EventListenerOptions): void;
@@ -903,7 +919,7 @@ export interface CPopoverElementEventMap {
903
919
  'change:open': CustomEvent<boolean>;
904
920
  }
905
921
  /** A click-opened, non-modal surface anchored to its trigger, floating in the top layer; its content may be interactive. */
906
- export interface CPopoverElement extends Omit<HTMLElement, 'distance' | 'heading' | 'open' | 'position'> {
922
+ export interface CPopoverElement extends Omit<HTMLElement, 'distance' | 'heading' | 'open' | 'position' | 'trigger'> {
907
923
  /** Distance from the trigger to the panel, in pixels. Defaults to `0`. */
908
924
  distance?: number | string;
909
925
  /**
@@ -917,6 +933,14 @@ export interface CPopoverElement extends Omit<HTMLElement, 'distance' | 'heading
917
933
  open?: boolean;
918
934
  /** Preferred placement of the panel relative to the trigger. */
919
935
  position?: 'bottom-end' | 'bottom-start' | 'bottom' | 'left-end' | 'left-start' | 'left' | 'right-end' | 'right-start' | 'right' | 'top-end' | 'top-start' | 'top';
936
+ /**
937
+ * Designated trigger: an element elsewhere in the document that opens the
938
+ * popover — its document ID, or the element itself. The same trigger
939
+ * concept as the `trigger` slot, supplied by reference: the popover wires
940
+ * click-to-toggle, ARIA and focus return onto it and anchors the panel to
941
+ * it. When both routes are supplied, this prop wins over the slot.
942
+ */
943
+ trigger?: HTMLElement | string;
920
944
  addEventListener<K extends keyof CPopoverElementEventMap>(type: K, listener: (this: CPopoverElement, ev: CPopoverElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
921
945
  addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
922
946
  removeEventListener<K extends keyof CPopoverElementEventMap>(type: K, listener: (this: CPopoverElement, ev: CPopoverElementEventMap[K]) => void, options?: boolean | EventListenerOptions): void;
@@ -1241,6 +1265,7 @@ export interface CSwitchElementEventMap {
1241
1265
  */
1242
1266
  'update:value': CustomEvent<boolean | number | string>;
1243
1267
  }
1268
+ /** A toggle for a binary setting that takes effect immediately: a native switch control with a label, an optional hint, and validation messaging. */
1244
1269
  export interface CSwitchElement extends Omit<HTMLElement, 'checked' | 'disabled' | 'falseValue' | 'hostId' | 'label' | 'loading' | 'required' | 'trueValue' | 'value'> {
1245
1270
  /** If `true`, the checkbox is selected. */
1246
1271
  checked?: boolean;
@@ -1358,6 +1383,7 @@ export interface CTabItemsElement extends Omit<HTMLElement, 'disableAnimation' |
1358
1383
  /** Currently active tab */
1359
1384
  value?: number | string;
1360
1385
  }
1386
+ /** A styled wrapper for a table you author yourself: slot in a plain `<table>` and c-table gives it the CSC look plus an optional responsive card layout on narrow screens. The table stays in your own DOM — your stylesheets, your framework's rendering, and `::part()` selectors on components nested in cells (a `c-tag` status chip, a `c-pagination` footer) all keep working. */
1361
1387
  export interface CTableElement extends Omit<HTMLElement, 'mobileBreakpoint' | 'responsive'> {
1362
1388
  /** Mobile breakpoint in pixels */
1363
1389
  mobileBreakpoint?: number;
@@ -1558,7 +1584,7 @@ export interface CTooltipElementEventMap {
1558
1584
  'change:open': CustomEvent<boolean>;
1559
1585
  }
1560
1586
  /** A non-interactive text hint shown when its trigger is hovered or keyboard-focused, floating in the top layer on the inverted surface tier. */
1561
- export interface CTooltipElement extends Omit<HTMLElement, 'delay' | 'distance' | 'open' | 'position' | 'text'> {
1587
+ export interface CTooltipElement extends Omit<HTMLElement, 'delay' | 'distance' | 'open' | 'position' | 'text' | 'trigger'> {
1562
1588
  /**
1563
1589
  * Delay before the tooltip shows on hover, in milliseconds. Keyboard focus
1564
1590
  * shows the tooltip immediately, regardless of this value. Defaults to
@@ -1576,6 +1602,15 @@ export interface CTooltipElement extends Omit<HTMLElement, 'delay' | 'distance'
1576
1602
  * populated.
1577
1603
  */
1578
1604
  text?: string;
1605
+ /**
1606
+ * Designated trigger: an element elsewhere in the document that the
1607
+ * tooltip describes — its document ID, or the element itself. The same
1608
+ * trigger concept as the `trigger` slot, supplied by reference: the
1609
+ * tooltip wires hover/focus, mirrors `aria-description` onto it and
1610
+ * anchors the bubble to it. When both routes are supplied, this prop wins
1611
+ * over the slot.
1612
+ */
1613
+ trigger?: HTMLElement | string;
1579
1614
  addEventListener<K extends keyof CTooltipElementEventMap>(type: K, listener: (this: CTooltipElement, ev: CTooltipElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
1580
1615
  addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
1581
1616
  removeEventListener<K extends keyof CTooltipElementEventMap>(type: K, listener: (this: CTooltipElement, ev: CTooltipElementEventMap[K]) => void, options?: boolean | EventListenerOptions): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cscfi/csc-ui",
3
- "version": "4.0.0-alpha.5",
3
+ "version": "4.0.0-alpha.7",
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",