@cscfi/csc-ui 4.0.0-alpha.23 → 4.0.0-alpha.24

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "name": "@cscfi/csc-ui",
4
- "version": "4.0.0-alpha.23",
4
+ "version": "4.0.0-alpha.24",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -38,7 +38,8 @@
38
38
  * release both outside the host close the panel; a press alone — the
39
39
  * start of every touch scroll — never does (`lightDismiss.ts`);
40
40
  * - focus return to the value field on `close(true)`;
41
- * - the OddBird anchor polyfill kick-off on an anchored open (Firefox).
41
+ * - the Floating UI placement on an anchored open without native anchor
42
+ * positioning (Firefox 140 ESR; ADR-0056).
42
43
  *
43
44
  * What stays in the consumer: the `@position-try --c-field-panel-above` /
44
45
  * `--c-field-panel-above-left` flip rules and `position-try-fallbacks` —
@@ -84,11 +85,11 @@ export interface UseAnchoredPanelOptions {
84
85
  field: Readonly<Ref<HTMLElement | null>>;
85
86
  /** Open as a fullscreen panel while true — the shared narrow-viewport predicate (`useNarrowViewport`). Absent: always anchored. */
86
87
  fullscreen?: Readonly<Ref<boolean>>;
87
- /** The custom element host: light dismiss keeps gestures whose composed path includes it; its shadow root is what the anchor polyfill runs against; it is what the page lock keeps interactive. */
88
+ /** The custom element host: light dismiss keeps gestures whose composed path includes it; it is what the page lock keeps interactive. */
88
89
  host: HTMLElement | null;
89
90
  /** Runs inside the native `toggle` handler once closed, before focus returns. */
90
91
  onClosed?: () => void;
91
- /** Runs inside the native `toggle` handler once open, after the polyfill kick-off / page lock and the dismiss listener — the consumer's open sequence goes here. */
92
+ /** 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. */
92
93
  onOpened?: () => void;
93
94
  /** The `popover="manual"` panel element. */
94
95
  panel: Readonly<Ref<HTMLElement | null>>;
@@ -10,10 +10,11 @@
10
10
  * cannot reference an `anchor-name` on an outer-tree element. Instead the
11
11
  * component keeps a *proxy anchor* — an inert, fixed-position box in its own
12
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.
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).
17
18
  */
18
19
  import { type Ref } from 'vue';
19
20
  export interface DesignatedTriggerHandle {
@@ -0,0 +1,58 @@
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. The result is a style string the
12
+ * component appends to its panel style — never written to `el.style` directly,
13
+ * which Vue's next `:style` patch would wipe.
14
+ *
15
+ * On a browser with native support every method is a no-op and `style` stays
16
+ * empty, so the native path is untouched. Floating UI is imported lazily, and
17
+ * preloaded at setup where it will be needed so the first open does not wait
18
+ * on it.
19
+ *
20
+ * Each consumer's `fallbacks` mirror its `position-try-fallbacks` rule; keep
21
+ * the two in step.
22
+ */
23
+ import { type Ref } from 'vue';
24
+ import type { CPlacement } from '../types';
25
+ type Side = 'bottom' | 'left' | 'right' | 'top';
26
+ /** True when the browser positions anchors without this fallback. */
27
+ export declare const supportsAnchorPositioning: () => boolean;
28
+ /** The `flip-block` try-tactic: mirror across the block axis. */
29
+ export declare const flipBlock: (placement: CPlacement) => CPlacement;
30
+ /** The `flip-inline` try-tactic: mirror across the inline axis. */
31
+ export declare const flipInline: (placement: CPlacement) => CPlacement;
32
+ /**
33
+ * `position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline`
34
+ * — the chain of `c-menu`, `c-tooltip` and `c-popover` — from `placement`.
35
+ */
36
+ export declare const flipChain: (placement: CPlacement) => CPlacement[];
37
+ export interface FallbackPosition {
38
+ /** Start positioning — call once the panel is open. */
39
+ start(): void;
40
+ /** Stop tracking — call when the panel closes. */
41
+ stop(): void;
42
+ /** Declarations to append to the panel's inline style; empty with native support. */
43
+ style: Readonly<Ref<string>>;
44
+ }
45
+ export interface UseFallbackPositionOptions {
46
+ /** Ordered fallback placements, mirroring the panel's `position-try-fallbacks`. */
47
+ fallbacks: (placement: CPlacement) => CPlacement[];
48
+ /** The `popover` panel. */
49
+ floating: Readonly<Ref<HTMLElement | null>>;
50
+ /** The trigger→panel gap in px on the resolved placement's side (negative pulls the panel in). */
51
+ gap: (side: Side) => number;
52
+ /** The preferred placement (the inline `position-area`). */
53
+ placement: () => CPlacement;
54
+ /** The element the panel sits against. */
55
+ reference: () => Element | null | undefined;
56
+ }
57
+ export declare const useFallbackPosition: (options: UseFallbackPositionOptions) => FallbackPosition;
58
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cscfi/csc-ui",
3
- "version": "4.0.0-alpha.23",
3
+ "version": "4.0.0-alpha.24",
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",
@@ -21,8 +21,8 @@
21
21
  "./custom-elements.json": "./dist/custom-elements.json"
22
22
  },
23
23
  "dependencies": {
24
+ "@floating-ui/dom": "^1.7.6",
24
25
  "@mdi/js": "^7.4.47",
25
- "@oddbird/css-anchor-positioning": "^0.9.0",
26
26
  "@tanstack/vue-table": "^8.21.3",
27
27
  "culori": "^4.0.2",
28
28
  "tailwind-merge": "^3.6.0",