@iris-ui-kit/vue 0.2.25 → 0.2.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin.cjs +547 -236
- package/dist/admin.cjs.map +1 -1
- package/dist/admin.d.cts +4 -2
- package/dist/admin.d.ts +4 -2
- package/dist/admin.js +2 -2
- package/dist/behaviors.cjs +49 -0
- package/dist/behaviors.cjs.map +1 -1
- package/dist/behaviors.d.cts +57 -1
- package/dist/behaviors.d.ts +57 -1
- package/dist/behaviors.js +1 -1
- package/dist/{chunk-QQ25RKOO.js → chunk-ASFDGYIR.js} +543 -240
- package/dist/chunk-ASFDGYIR.js.map +1 -0
- package/dist/{chunk-WL67XCH5.js → chunk-IN3DQ55U.js} +2 -2
- package/dist/chunk-IN3DQ55U.js.map +1 -0
- package/dist/{chunk-7L6UB6MD.js → chunk-IOMKC5OI.js} +53 -5
- package/dist/chunk-IOMKC5OI.js.map +1 -0
- package/dist/{chunk-3FJUCHCC.js → chunk-IPR5JAVF.js} +11 -3
- package/dist/chunk-IPR5JAVF.js.map +1 -0
- package/dist/{chunk-BEPH6PPL.js → chunk-LWABTQCB.js} +57 -37
- package/dist/chunk-LWABTQCB.js.map +1 -0
- package/dist/{chunk-DNRQVM3Q.js → chunk-QBFYIDY7.js} +3 -2
- package/dist/chunk-QBFYIDY7.js.map +1 -0
- package/dist/data.cjs +1 -0
- package/dist/data.cjs.map +1 -1
- package/dist/data.d.cts +4 -2
- package/dist/data.d.ts +4 -2
- package/dist/data.js +1 -1
- package/dist/floating.cjs +9 -1
- package/dist/floating.cjs.map +1 -1
- package/dist/floating.d.cts +6 -0
- package/dist/floating.d.ts +6 -0
- package/dist/floating.js +1 -1
- package/dist/index.cjs +2063 -745
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +172 -8
- package/dist/index.d.ts +172 -8
- package/dist/index.js +1412 -475
- package/dist/index.js.map +1 -1
- package/dist/layouts.cjs.map +1 -1
- package/dist/layouts.d.cts +1 -1
- package/dist/layouts.d.ts +1 -1
- package/dist/layouts.js +1 -1
- package/dist/skeletons.cjs +55 -35
- package/dist/skeletons.cjs.map +1 -1
- package/dist/skeletons.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-3FJUCHCC.js.map +0 -1
- package/dist/chunk-7L6UB6MD.js.map +0 -1
- package/dist/chunk-BEPH6PPL.js.map +0 -1
- package/dist/chunk-DNRQVM3Q.js.map +0 -1
- package/dist/chunk-QQ25RKOO.js.map +0 -1
- package/dist/chunk-WL67XCH5.js.map +0 -1
package/dist/data.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useStore.ts","../src/data/useDataSource.ts","../src/data/useGroupedView.ts"],"names":["shallowRef","onScopeDispose","createDataSource","onMounted","createGroupedView","computed"],"mappings":";;;;;;AASO,SAAS,SAAY,KAAA,EAAkD;AAC5E,EAAA,MAAM,KAAA,GAAQA,cAAA,CAAW,KAAA,CAAM,QAAA,EAAU,CAAA;AACzC,EAAAC,kBAAA,CAAe,MAAM,SAAA,CAAU,CAAC,SAAU,KAAA,CAAM,KAAA,GAAQ,IAAK,CAAC,CAAA;AAC9D,EAAA,OAAO,KAAA;AACT;;;ACqBO,SAAS,cAAiB,MAAA,EAA+C;AAC9E,EAAA,MAAM,aAAaC,qBAAA,CAAiB,EAAE,GAAG,MAAA,EAAQ,SAAA,EAAW,OAAO,CAAA;AACnE,EAAA,MAAM,SAAA,GAAY,OAAO,SAAA,KAAc,KAAA;AAEvC,EAAA,IAAI,SAAA,EAAW;AACb,IAAAC,aAAA,CAAU,MAAM,KAAK,UAAA,CAAW,IAAA,EAAM,CAAA;AAAA,EACxC;AAGA,EAAAF,kBAAAA,CAAe,MAAM,UAAA,CAAW,OAAA,EAAS,CAAA;AAEzC,EAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,UAAA,CAAW,KAAK,CAAA;AACvC,EAAA,OAAO,EAAE,GAAG,UAAA,EAAY,KAAA,EAAM;AAChC;
|
|
1
|
+
{"version":3,"sources":["../src/useStore.ts","../src/data/useDataSource.ts","../src/data/useGroupedView.ts"],"names":["shallowRef","onScopeDispose","createDataSource","onMounted","createGroupedView","computed"],"mappings":";;;;;;AASO,SAAS,SAAY,KAAA,EAAkD;AAC5E,EAAA,MAAM,KAAA,GAAQA,cAAA,CAAW,KAAA,CAAM,QAAA,EAAU,CAAA;AACzC,EAAAC,kBAAA,CAAe,MAAM,SAAA,CAAU,CAAC,SAAU,KAAA,CAAM,KAAA,GAAQ,IAAK,CAAC,CAAA;AAC9D,EAAA,OAAO,KAAA;AACT;;;ACqBO,SAAS,cAAiB,MAAA,EAA+C;AAC9E,EAAA,MAAM,aAAaC,qBAAA,CAAiB,EAAE,GAAG,MAAA,EAAQ,SAAA,EAAW,OAAO,CAAA;AACnE,EAAA,MAAM,SAAA,GAAY,OAAO,SAAA,KAAc,KAAA;AAEvC,EAAA,IAAI,SAAA,EAAW;AACb,IAAAC,aAAA,CAAU,MAAM,KAAK,UAAA,CAAW,IAAA,EAAM,CAAA;AAAA,EACxC;AAGA,EAAAF,kBAAAA,CAAe,MAAM,UAAA,CAAW,OAAA,EAAS,CAAA;AAEzC,EAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,UAAA,CAAW,KAAK,CAAA;AACvC,EAAA,OAAO,EAAE,GAAG,UAAA,EAAY,KAAA,EAAM;AAChC;ACjBO,SAAS,eACd,MAAA,EACwB;AACxB,EAAA,MAAM,UAAA,GAAaG,uBAA0B,MAAM,CAAA;AACnD,EAAA,MAAM,QAAA,GAAW,QAAA,CAAS,UAAA,CAAW,KAAK,CAAA;AAC1C,EAAA,MAAM,KAAA,GAAQC,aAAS,MAAM;AAC3B,IAAA,MAAM,IAAI,QAAA,CAAS,KAAA;AACnB,IAAA,OAAO,CAAA,CAAE,KAAA;AAAA,EACX,CAAC,CAAA;AAED,EAAA,OAAO;AAAA,IACL,OAAO,UAAA,CAAW,KAAA;AAAA,IAClB,WAAW,UAAA,CAAW,SAAA;AAAA,IACtB,SAAS,CAAC,IAAA,EAAM,YAAY,UAAA,CAAW,OAAA,CAAQ,MAAM,OAAO,CAAA;AAAA,IAC5D,WAAA,EAAa,CAAC,GAAA,KAAQ,UAAA,CAAW,YAAY,GAAG,CAAA;AAAA,IAChD,WAAA,EAAa,CAAC,GAAA,KAAQ,UAAA,CAAW,YAAY,GAAG,CAAA;AAAA,IAChD,aAAA,EAAe,CAAC,GAAA,KAAQ,UAAA,CAAW,cAAc,GAAG,CAAA;AAAA,IACpD,SAAA,EAAW,MAAM,UAAA,CAAW,SAAA,EAAU;AAAA,IACtC,WAAA,EAAa,MAAM,UAAA,CAAW,WAAA,EAAY;AAAA,IAC1C,KAAA;AAAA,IACA,SAAA,EAAW,CAAC,OAAA,KAAY,UAAA,CAAW,UAAU,OAAO;AAAA,GACtD;AACF","file":"data.cjs","sourcesContent":["import { shallowRef, onScopeDispose, type ShallowRef } from 'vue'\nimport type { ReadonlyStore, Store } from '@iris-ui-kit/core'\n\n/**\n * Bridge a framework-agnostic `@iris-ui-kit/core` store into a Vue ref — updates on\n * every store emission. The mirror of React's `useSyncExternalStore`, Solid's\n * `createSignal`, and Svelte's `readable`. Seeds synchronously from\n * `store.getState()` (SSR-safe); detaches on scope dispose.\n */\nexport function useStore<T>(store: ReadonlyStore<T>): Readonly<ShallowRef<T>> {\n const state = shallowRef(store.getState()) as ShallowRef<T>\n onScopeDispose(store.subscribe((next) => (state.value = next)))\n return state\n}\n\n/**\n * Subscribe to a DERIVED slice of a core store — the ref updates only when\n * `selector(state)` changes per `equals` (default `Object.is`), not on every\n * store emission. Built on {@link Store.subscribeWith}.\n */\nexport function useStoreSelector<T, U>(\n store: Store<T>,\n selector: (state: T) => U,\n equals?: (a: U, b: U) => boolean,\n): Readonly<ShallowRef<U>> {\n const slice = shallowRef(selector(store.getState())) as ShallowRef<U>\n onScopeDispose(store.subscribeWith(selector, (v) => (slice.value = v), equals))\n return slice\n}\n","import { onMounted, onScopeDispose, type ShallowRef } from 'vue'\nimport {\n createDataSource,\n type DataSourceController,\n type DataSourceConfig,\n type DataSourceState,\n} from '@iris-ui-kit/core'\nimport { useStore } from '../useStore'\n\nexport interface UseDataSource<T> extends DataSourceController<T> {\n /**\n * The live data-source state as a reactive ref: rows, total, page/pageSize,\n * sort/multiSort, filters/filterRules, loading/loadingMore, hasMore,\n * selectedKeys, and the per-row pendingRows/rowErrors.\n */\n state: ShallowRef<DataSourceState<T>>\n}\n\n/**\n * Vue bridge over the framework-agnostic {@link createDataSource} — the unified\n * data engine (paged/infinite + multi-sort + typed filters + selection +\n * per-row + optimistic mutate). Creates the controller once in `setup()`,\n * mirrors its store into a reactive ref, and returns the controller plus its\n * live `state`. A thin bridge — all logic lives in `@iris-ui-kit/core`.\n *\n * Constructed with `immediate: false` so no fetch fires during `setup()`\n * (SSR-safe: server rendering never runs `onMounted`); the initial load is\n * kicked from `onMounted` when the caller's config says `immediate !== false`.\n * The `onMounted` registration is conditional on that flag — inside a bare\n * `effectScope` there is no component instance and Vue would warn on an\n * unconditional registration. The controller is torn down on scope dispose\n * (aborting any in-flight fetch), so a late response never writes back to a\n * torn-down instance.\n */\nexport function useDataSource<T>(config: DataSourceConfig<T>): UseDataSource<T> {\n const controller = createDataSource({ ...config, immediate: false })\n const immediate = config.immediate !== false\n\n if (immediate) {\n onMounted(() => void controller.load())\n }\n // Abort any in-flight fetch + detach the controller's internal subscriptions\n // on unmount (a late response must not write back to a torn-down instance).\n onScopeDispose(() => controller.destroy())\n\n const state = useStore(controller.store)\n return { ...controller, state }\n}\n","import { computed, type ComputedRef } from 'vue'\nimport {\n createGroupedView,\n type GroupedViewConfig,\n type GroupedViewState,\n type GroupedViewStore,\n} from '@iris-ui-kit/core'\nimport type { DataViewColumn } from '@iris-ui-kit/core'\nimport { useStore } from '../useStore'\n\nexport interface UseGroupedView<Row, K extends string | number = string> {\n store: ReturnType<typeof createGroupedView<Row, K>>['store']\n /** The composed expansion model (multiple-open) — bridge it like a Vue Table: `useStore(expansion.store)`. */\n expansion: ReturnType<typeof createGroupedView<Row, K>>['expansion']\n setRows: (rows: readonly Row[], columns?: readonly DataViewColumn<Row>[]) => void\n toggleGroup: (key: K) => void\n expandGroup: (key: K) => void\n collapseGroup: (key: K) => void\n expandAll: () => void\n collapseAll: () => void\n /** Reactive live grouped-view state. */\n state: ComputedRef<GroupedViewState<Row, K>>\n setConfig: (partial: Partial<GroupedViewConfig<Row, K>>) => void\n}\n\n/**\n * Vue bridge over the framework-agnostic {@link createGroupedView}.\n * Creates the controller once, subscribes its store to a reactive ref,\n * and returns the controller plus a computed `state`.\n */\nexport function useGroupedView<Row, K extends string | number = string>(\n config: GroupedViewConfig<Row, K>,\n): UseGroupedView<Row, K> {\n const controller = createGroupedView<Row, K>(config)\n const storeRef = useStore(controller.store)\n const state = computed(() => {\n const s = storeRef.value as GroupedViewStore<Row, K>\n return s.state\n })\n\n return {\n store: controller.store,\n expansion: controller.expansion,\n setRows: (rows, columns) => controller.setRows(rows, columns),\n toggleGroup: (key) => controller.toggleGroup(key),\n expandGroup: (key) => controller.expandGroup(key),\n collapseGroup: (key) => controller.collapseGroup(key),\n expandAll: () => controller.expandAll(),\n collapseAll: () => controller.collapseAll(),\n state,\n setConfig: (partial) => controller.setConfig(partial),\n }\n}\n"]}
|
package/dist/data.d.cts
CHANGED
|
@@ -28,8 +28,10 @@ interface UseDataSource<T> extends DataSourceController<T> {
|
|
|
28
28
|
*/
|
|
29
29
|
declare function useDataSource<T>(config: DataSourceConfig<T>): UseDataSource<T>;
|
|
30
30
|
|
|
31
|
-
interface UseGroupedView<Row, K = string> {
|
|
31
|
+
interface UseGroupedView<Row, K extends string | number = string> {
|
|
32
32
|
store: ReturnType<typeof createGroupedView<Row, K>>['store'];
|
|
33
|
+
/** The composed expansion model (multiple-open) — bridge it like a Vue Table: `useStore(expansion.store)`. */
|
|
34
|
+
expansion: ReturnType<typeof createGroupedView<Row, K>>['expansion'];
|
|
33
35
|
setRows: (rows: readonly Row[], columns?: readonly DataViewColumn<Row>[]) => void;
|
|
34
36
|
toggleGroup: (key: K) => void;
|
|
35
37
|
expandGroup: (key: K) => void;
|
|
@@ -45,6 +47,6 @@ interface UseGroupedView<Row, K = string> {
|
|
|
45
47
|
* Creates the controller once, subscribes its store to a reactive ref,
|
|
46
48
|
* and returns the controller plus a computed `state`.
|
|
47
49
|
*/
|
|
48
|
-
declare function useGroupedView<Row, K = string>(config: GroupedViewConfig<Row, K>): UseGroupedView<Row, K>;
|
|
50
|
+
declare function useGroupedView<Row, K extends string | number = string>(config: GroupedViewConfig<Row, K>): UseGroupedView<Row, K>;
|
|
49
51
|
|
|
50
52
|
export { type UseDataSource, type UseGroupedView, useDataSource, useGroupedView };
|
package/dist/data.d.ts
CHANGED
|
@@ -28,8 +28,10 @@ interface UseDataSource<T> extends DataSourceController<T> {
|
|
|
28
28
|
*/
|
|
29
29
|
declare function useDataSource<T>(config: DataSourceConfig<T>): UseDataSource<T>;
|
|
30
30
|
|
|
31
|
-
interface UseGroupedView<Row, K = string> {
|
|
31
|
+
interface UseGroupedView<Row, K extends string | number = string> {
|
|
32
32
|
store: ReturnType<typeof createGroupedView<Row, K>>['store'];
|
|
33
|
+
/** The composed expansion model (multiple-open) — bridge it like a Vue Table: `useStore(expansion.store)`. */
|
|
34
|
+
expansion: ReturnType<typeof createGroupedView<Row, K>>['expansion'];
|
|
33
35
|
setRows: (rows: readonly Row[], columns?: readonly DataViewColumn<Row>[]) => void;
|
|
34
36
|
toggleGroup: (key: K) => void;
|
|
35
37
|
expandGroup: (key: K) => void;
|
|
@@ -45,6 +47,6 @@ interface UseGroupedView<Row, K = string> {
|
|
|
45
47
|
* Creates the controller once, subscribes its store to a reactive ref,
|
|
46
48
|
* and returns the controller plus a computed `state`.
|
|
47
49
|
*/
|
|
48
|
-
declare function useGroupedView<Row, K = string>(config: GroupedViewConfig<Row, K>): UseGroupedView<Row, K>;
|
|
50
|
+
declare function useGroupedView<Row, K extends string | number = string>(config: GroupedViewConfig<Row, K>): UseGroupedView<Row, K>;
|
|
49
51
|
|
|
50
52
|
export { type UseDataSource, type UseGroupedView, useDataSource, useGroupedView };
|
package/dist/data.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { createClientDataSource, createDataSource, createGroupedView, useDataSource, useGroupedView } from './chunk-
|
|
1
|
+
export { createClientDataSource, createDataSource, createGroupedView, useDataSource, useGroupedView } from './chunk-QBFYIDY7.js';
|
|
2
2
|
import './chunk-75GSYEJS.js';
|
|
3
3
|
//# sourceMappingURL=data.js.map
|
|
4
4
|
//# sourceMappingURL=data.js.map
|
package/dist/floating.cjs
CHANGED
|
@@ -7,6 +7,7 @@ var dom = require('@floating-ui/dom');
|
|
|
7
7
|
function useFloating(options) {
|
|
8
8
|
const x = vue.ref(0);
|
|
9
9
|
const y = vue.ref(0);
|
|
10
|
+
const positioned = vue.ref(false);
|
|
10
11
|
const strategy = vue.ref(options.strategy ?? "absolute");
|
|
11
12
|
const finalPlacement = vue.ref(options.placement ?? "bottom");
|
|
12
13
|
const arrowX = vue.ref();
|
|
@@ -52,6 +53,7 @@ function useFloating(options) {
|
|
|
52
53
|
if (token !== epoch) return;
|
|
53
54
|
x.value = result.x;
|
|
54
55
|
y.value = result.y;
|
|
56
|
+
positioned.value = true;
|
|
55
57
|
finalPlacement.value = result.placement;
|
|
56
58
|
const arrowData = result.middlewareData.arrow;
|
|
57
59
|
arrowX.value = arrowData?.x;
|
|
@@ -64,6 +66,7 @@ function useFloating(options) {
|
|
|
64
66
|
cleanupAutoUpdate = null;
|
|
65
67
|
epoch++;
|
|
66
68
|
if (isOpen && anchorEl && floatingEl) {
|
|
69
|
+
positioned.value = false;
|
|
67
70
|
cleanupAutoUpdate = dom.autoUpdate(anchorEl, floatingEl, () => {
|
|
68
71
|
void update();
|
|
69
72
|
});
|
|
@@ -90,7 +93,11 @@ function useFloating(options) {
|
|
|
90
93
|
top: "0",
|
|
91
94
|
left: "0",
|
|
92
95
|
transform: `translate3d(${Math.round(x.value)}px, ${Math.round(y.value)}px, 0)`,
|
|
93
|
-
width: "max-content"
|
|
96
|
+
width: "max-content",
|
|
97
|
+
// Hidden until the first positioning cycle lands — prevents a flash at
|
|
98
|
+
// the viewport origin. visibility (not display:none) keeps the panel
|
|
99
|
+
// measurable so Floating UI can compute its real coordinates.
|
|
100
|
+
visibility: positioned.value ? "visible" : "hidden"
|
|
94
101
|
}));
|
|
95
102
|
return { x, y, strategy, finalPlacement, floatingStyles, update, arrowX, arrowY, arrowSide };
|
|
96
103
|
}
|
|
@@ -109,6 +116,7 @@ function useDismiss(options) {
|
|
|
109
116
|
const onPointerDown = (event) => {
|
|
110
117
|
if (!options.enabled.value) return;
|
|
111
118
|
if (isExcluded(event.target)) return;
|
|
119
|
+
if (options.excludePredicate?.(event.target)) return;
|
|
112
120
|
options.onDismiss();
|
|
113
121
|
};
|
|
114
122
|
const onKeyDown = (event) => {
|
package/dist/floating.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/primitives/floating/useFloating.ts","../src/primitives/floating/useDismiss.ts"],"names":["ref","shallowRef","offsetMiddleware","flipMiddleware","shiftMiddleware","sizeMiddleware","arrowMiddleware","computePosition","watch","autoUpdate","onScopeDispose","computed"],"mappings":";;;;;;AA6FO,SAAS,YAAY,OAAA,EAAgD;AAC1E,EAAA,MAAM,CAAA,GAAIA,QAAI,CAAC,CAAA;AACf,EAAA,MAAM,CAAA,GAAIA,QAAI,CAAC,CAAA;AACf,EAAA,MAAM,QAAA,GAAWA,OAAA,CAAc,OAAA,CAAQ,QAAA,IAAY,UAAU,CAAA;AAC7D,EAAA,MAAM,cAAA,GAAiBA,OAAA,CAAe,OAAA,CAAQ,SAAA,IAAa,QAAQ,CAAA;AACnE,EAAA,MAAM,SAASA,OAAA,EAAwB;AACvC,EAAA,MAAM,SAASA,OAAA,EAAwB;AAEvC,EAAA,MAAM,UAAA,GAAaC,cAAA,CAAyB,EAAE,CAAA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,CAAA;AAAA,IAC9D;AACA,IAAA,IAAI,MAAA,EAAQ;AACV,MAAA,QAAA,CAAS,gBAAA,CAAiB,WAAW,SAAS,CAAA;AAAA,IAChD;AAAA,EACF,CAAA;AAEA,EAAA,MAAM,SAAS,MAAM;AACnB,IAAA,IAAI,OAAO,aAAa,WAAA,EAAa;AACrC,IAAA,QAAA,CAAS,mBAAA,CAAoB,aAAA,EAAe,aAAA,EAAe,IAAI,CAAA;AAC/D,IAAA,QAAA,CAAS,mBAAA,CAAoB,WAAW,SAAS,CAAA;AAAA,EACnD,CAAA;AAEA,EAAAH,SAAAA;AAAA,IACE,OAAA,CAAQ,OAAA;AAAA,IACR,CAAC,OAAA,KAAY;AACX,MAAA,MAAA,EAAO;AACP,MAAA,IAAI,SAAS,MAAA,EAAO;AAAA,IACtB,CAAA;AAAA,IACA,EAAE,SAAA,EAAW,IAAA,EAAM,KAAA,EAAO,MAAA;AAAO,GACnC;AAEA,EAAAE,mBAAe,MAAM,CAAA;AACvB","file":"floating.cjs","sourcesContent":["import { computed, onScopeDispose, ref, shallowRef, watch, type ComputedRef, type Ref } from 'vue'\nimport {\n autoUpdate,\n computePosition,\n arrow as arrowMiddleware,\n flip as flipMiddleware,\n offset as offsetMiddleware,\n shift as shiftMiddleware,\n size as sizeMiddleware,\n type Middleware,\n type Placement,\n type Strategy,\n} from '@floating-ui/dom'\n\nexport interface UseFloatingOptions {\n /** Element the floating panel is positioned relative to. */\n anchor: Ref<HTMLElement | null | undefined>\n /** The floating element itself. */\n floating: Ref<HTMLElement | null | undefined>\n /** Whether the floating element is visible. Controls `autoUpdate` lifecycle. */\n open: Ref<boolean>\n /** Default placement. Floating UI may flip it if `flip` is true. */\n placement?: Placement\n /** CSS position strategy. */\n strategy?: Strategy\n /** Pixel offset between anchor and floating element. */\n offset?: number\n /** Flip to the opposite side when the requested side overflows. Default `true`. */\n flip?: boolean\n /** Shift along the cross-axis to stay in view. Default `true`. */\n shift?: boolean\n /**\n * Constrain the floating element to the available viewport space — sets\n * `maxWidth`/`maxHeight` (minus 8px padding) on it so a long dropdown/popover\n * never overflows the screen (pair with `overflow:auto` for scroll). Off by\n * default. Pass a number to override the viewport padding.\n */\n size?: boolean | number\n /** Extra Floating UI middleware to append. */\n middleware?: Middleware[]\n /**\n * Optional ref to an arrow element inside the floating panel. When provided,\n * `arrowX`, `arrowY`, and `arrowSide` in the return value are populated.\n */\n arrow?: Ref<HTMLElement | null | undefined>\n}\n\nexport interface UseFloatingReturn {\n /** Computed x coordinate (px). */\n x: Ref<number>\n /** Computed y coordinate (px). */\n y: Ref<number>\n /** Final strategy (echo of input). */\n strategy: Ref<Strategy>\n /** Final placement, possibly flipped from the input placement. */\n finalPlacement: Ref<Placement>\n /** Ready-to-bind inline style object for the floating element. */\n floatingStyles: ComputedRef<Record<string, string>>\n /** Trigger a manual recompute. Usually not needed — `autoUpdate` handles scrolling/resizing. */\n update: () => Promise<void>\n /** Arrow x offset (px). Present when `arrow` option is set. */\n arrowX: Ref<number | undefined>\n /** Arrow y offset (px). Present when `arrow` option is set. */\n arrowY: Ref<number | undefined>\n /**\n * Side of the floating element the arrow is on.\n * E.g. `'bottom'` placement → `'top'` (arrow at top pointing up).\n */\n arrowSide: ComputedRef<'top' | 'right' | 'bottom' | 'left' | undefined>\n}\n\n/**\n * Reactive Floating UI integration. Subscribes `autoUpdate` whenever\n * `open === true` and both refs are populated; tears it down on close,\n * unmount, or ref clearing. Returns `floatingStyles` ready to be spread onto\n * the floating element.\n *\n * Pure positioning — does NOT render anything, does NOT manage focus,\n * does NOT handle dismiss behavior. Those concerns live in the consuming\n * primitive (Popover, Tooltip, Dialog, Menu, ...).\n *\n * @example\n * const triggerEl = ref<HTMLElement | null>(null)\n * const contentEl = ref<HTMLElement | null>(null)\n * const open = ref(false)\n * const { floatingStyles } = useFloating({\n * anchor: triggerEl,\n * floating: contentEl,\n * open,\n * placement: 'bottom-start',\n * offset: 8,\n * })\n */\nexport function useFloating(options: UseFloatingOptions): UseFloatingReturn {\n const x = ref(0)\n const y = ref(0)\n const strategy = ref<Strategy>(options.strategy ?? 'absolute')\n const finalPlacement = ref<Placement>(options.placement ?? 'bottom')\n const arrowX = ref<number | undefined>()\n const arrowY = ref<number | undefined>()\n\n const middleware = shallowRef<Middleware[]>([])\n rebuildMiddleware()\n\n function rebuildMiddleware() {\n const mw: Middleware[] = []\n if (options.offset !== undefined) mw.push(offsetMiddleware(options.offset))\n if (options.flip !== false) mw.push(flipMiddleware())\n if (options.shift !== false) mw.push(shiftMiddleware({ padding: 8 }))\n if (options.size) {\n const padding = typeof options.size === 'number' ? options.size : 8\n mw.push(\n sizeMiddleware({\n padding,\n apply({ availableWidth, availableHeight, elements }) {\n Object.assign(elements.floating.style, {\n maxWidth: `${Math.max(0, Math.floor(availableWidth))}px`,\n maxHeight: `${Math.max(0, Math.floor(availableHeight))}px`,\n })\n },\n }),\n )\n }\n if (options.arrow?.value) mw.push(arrowMiddleware({ element: options.arrow.value }))\n if (options.middleware) mw.push(...options.middleware)\n middleware.value = mw\n }\n\n let cleanupAutoUpdate: (() => void) | null = null\n // Monotonic token bumped on every new positioning cycle and on teardown, so a\n // computePosition() that resolves after the panel closed/re-opened (or after a\n // newer update started) drops its result instead of applying stale coords.\n let epoch = 0\n\n async function update() {\n const a = options.anchor.value\n const f = options.floating.value\n if (!a || !f) return\n rebuildMiddleware()\n const token = ++epoch\n const result = await computePosition(a, f, {\n placement: options.placement ?? 'bottom',\n strategy: strategy.value,\n middleware: middleware.value,\n })\n if (token !== epoch) return\n x.value = result.x\n y.value = result.y\n finalPlacement.value = result.placement\n const arrowData = result.middlewareData.arrow as { x?: number; y?: number } | undefined\n arrowX.value = arrowData?.x\n arrowY.value = arrowData?.y\n }\n\n watch(\n [options.open, options.anchor, options.floating],\n ([isOpen, anchorEl, floatingEl]) => {\n cleanupAutoUpdate?.()\n cleanupAutoUpdate = null\n epoch++\n if (isOpen && anchorEl && floatingEl) {\n cleanupAutoUpdate = autoUpdate(anchorEl, floatingEl, () => {\n void update()\n })\n }\n },\n { flush: 'post', immediate: true },\n )\n\n onScopeDispose(() => {\n cleanupAutoUpdate?.()\n cleanupAutoUpdate = null\n epoch++\n })\n\n const OPPOSITE: Record<string, 'top' | 'right' | 'bottom' | 'left'> = {\n top: 'bottom',\n bottom: 'top',\n left: 'right',\n right: 'left',\n }\n const arrowSide = computed(\n () =>\n OPPOSITE[finalPlacement.value.split('-')[0]] as\n | 'top'\n | 'right'\n | 'bottom'\n | 'left'\n | undefined,\n )\n\n const floatingStyles = computed<Record<string, string>>(() => ({\n position: strategy.value,\n top: '0',\n left: '0',\n transform: `translate3d(${Math.round(x.value)}px, ${Math.round(y.value)}px, 0)`,\n width: 'max-content',\n }))\n\n return { x, y, strategy, finalPlacement, floatingStyles, update, arrowX, arrowY, arrowSide }\n}\n","import { onScopeDispose, watch, type Ref } from 'vue'\n\nexport interface UseDismissOptions {\n /** While true, the dismiss listeners are active. */\n enabled: Ref<boolean>\n /** Elements that, if clicked, should NOT trigger dismiss (typically trigger + content). */\n exclude: Array<Ref<HTMLElement | null | undefined>>\n /** Called when the user attempts to dismiss the surface. */\n onDismiss: () => void\n /** Close on Escape key. Default `true`. */\n escape?: boolean\n /** Close on pointerdown outside the excluded elements. Default `true`. */\n outsidePointerDown?: boolean\n}\n\n/**\n * Listen for the universal \"dismiss\" gestures: Escape key and outside\n * pointer-down. Used by Popover / Dialog / Menu / Combobox. Tooltip does\n * NOT use this — it dismisses on mouseleave/blur instead.\n *\n * Listeners are attached to `document` only while `enabled` is true, and\n * removed on disable / unmount. SSR-safe (no-op without `document`).\n */\nexport function useDismiss(options: UseDismissOptions): void {\n const escape = options.escape !== false\n const outsidePointerDown = options.outsidePointerDown !== false\n\n const isExcluded = (target: EventTarget | null): boolean => {\n if (!target || !(target instanceof Node)) return false\n for (const r of options.exclude) {\n const el = r.value\n if (!el) continue\n if (el === target || el.contains(target)) return true\n }\n return false\n }\n\n const onPointerDown = (event: PointerEvent) => {\n if (!options.enabled.value) return\n if (isExcluded(event.target)) return\n options.onDismiss()\n }\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (!options.enabled.value) return\n if (event.key === 'Escape') {\n event.stopPropagation()\n options.onDismiss()\n }\n }\n\n const attach = () => {\n if (typeof document === 'undefined') return\n if (outsidePointerDown) {\n document.addEventListener('pointerdown', onPointerDown, true)\n }\n if (escape) {\n document.addEventListener('keydown', onKeyDown)\n }\n }\n\n const detach = () => {\n if (typeof document === 'undefined') return\n document.removeEventListener('pointerdown', onPointerDown, true)\n document.removeEventListener('keydown', onKeyDown)\n }\n\n watch(\n options.enabled,\n (enabled) => {\n detach()\n if (enabled) attach()\n },\n { immediate: true, flush: 'post' },\n )\n\n onScopeDispose(detach)\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/primitives/floating/useFloating.ts","../src/primitives/floating/useDismiss.ts"],"names":["ref","shallowRef","offsetMiddleware","flipMiddleware","shiftMiddleware","sizeMiddleware","arrowMiddleware","computePosition","watch","autoUpdate","onScopeDispose","computed"],"mappings":";;;;;;AA6FO,SAAS,YAAY,OAAA,EAAgD;AAC1E,EAAA,MAAM,CAAA,GAAIA,QAAI,CAAC,CAAA;AACf,EAAA,MAAM,CAAA,GAAIA,QAAI,CAAC,CAAA;AAGf,EAAA,MAAM,UAAA,GAAaA,QAAI,KAAK,CAAA;AAC5B,EAAA,MAAM,QAAA,GAAWA,OAAA,CAAc,OAAA,CAAQ,QAAA,IAAY,UAAU,CAAA;AAC7D,EAAA,MAAM,cAAA,GAAiBA,OAAA,CAAe,OAAA,CAAQ,SAAA,IAAa,QAAQ,CAAA;AACnE,EAAA,MAAM,SAASA,OAAA,EAAwB;AACvC,EAAA,MAAM,SAASA,OAAA,EAAwB;AAEvC,EAAA,MAAM,UAAA,GAAaC,cAAA,CAAyB,EAAE,CAAA;AAC9C,EAAA,iBAAA,EAAkB;AAElB,EAAA,SAAS,iBAAA,GAAoB;AAC3B,IAAA,MAAM,KAAmB,EAAC;AAC1B,IAAA,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;AACnB,IAAA,IAAI,OAAO,aAAa,WAAA,EAAa;AACrC,IAAA,IAAI,kBAAA,EAAoB;AACtB,MAAA,QAAA,CAAS,gBAAA,CAAiB,aAAA,EAAe,aAAA,EAAe,IAAI,CAAA;AAAA,IAC9D;AACA,IAAA,IAAI,MAAA,EAAQ;AACV,MAAA,QAAA,CAAS,gBAAA,CAAiB,WAAW,SAAS,CAAA;AAAA,IAChD;AAAA,EACF,CAAA;AAEA,EAAA,MAAM,SAAS,MAAM;AACnB,IAAA,IAAI,OAAO,aAAa,WAAA,EAAa;AACrC,IAAA,QAAA,CAAS,mBAAA,CAAoB,aAAA,EAAe,aAAA,EAAe,IAAI,CAAA;AAC/D,IAAA,QAAA,CAAS,mBAAA,CAAoB,WAAW,SAAS,CAAA;AAAA,EACnD,CAAA;AAEA,EAAAH,SAAAA;AAAA,IACE,OAAA,CAAQ,OAAA;AAAA,IACR,CAAC,OAAA,KAAY;AACX,MAAA,MAAA,EAAO;AACP,MAAA,IAAI,SAAS,MAAA,EAAO;AAAA,IACtB,CAAA;AAAA,IACA,EAAE,SAAA,EAAW,IAAA,EAAM,KAAA,EAAO,MAAA;AAAO,GACnC;AAEA,EAAAE,mBAAe,MAAM,CAAA;AACvB","file":"floating.cjs","sourcesContent":["import { computed, onScopeDispose, ref, shallowRef, watch, type ComputedRef, type Ref } from 'vue'\nimport {\n autoUpdate,\n computePosition,\n arrow as arrowMiddleware,\n flip as flipMiddleware,\n offset as offsetMiddleware,\n shift as shiftMiddleware,\n size as sizeMiddleware,\n type Middleware,\n type Placement,\n type Strategy,\n} from '@floating-ui/dom'\n\nexport interface UseFloatingOptions {\n /** Element the floating panel is positioned relative to. */\n anchor: Ref<HTMLElement | null | undefined>\n /** The floating element itself. */\n floating: Ref<HTMLElement | null | undefined>\n /** Whether the floating element is visible. Controls `autoUpdate` lifecycle. */\n open: Ref<boolean>\n /** Default placement. Floating UI may flip it if `flip` is true. */\n placement?: Placement\n /** CSS position strategy. */\n strategy?: Strategy\n /** Pixel offset between anchor and floating element. */\n offset?: number\n /** Flip to the opposite side when the requested side overflows. Default `true`. */\n flip?: boolean\n /** Shift along the cross-axis to stay in view. Default `true`. */\n shift?: boolean\n /**\n * Constrain the floating element to the available viewport space — sets\n * `maxWidth`/`maxHeight` (minus 8px padding) on it so a long dropdown/popover\n * never overflows the screen (pair with `overflow:auto` for scroll). Off by\n * default. Pass a number to override the viewport padding.\n */\n size?: boolean | number\n /** Extra Floating UI middleware to append. */\n middleware?: Middleware[]\n /**\n * Optional ref to an arrow element inside the floating panel. When provided,\n * `arrowX`, `arrowY`, and `arrowSide` in the return value are populated.\n */\n arrow?: Ref<HTMLElement | null | undefined>\n}\n\nexport interface UseFloatingReturn {\n /** Computed x coordinate (px). */\n x: Ref<number>\n /** Computed y coordinate (px). */\n y: Ref<number>\n /** Final strategy (echo of input). */\n strategy: Ref<Strategy>\n /** Final placement, possibly flipped from the input placement. */\n finalPlacement: Ref<Placement>\n /** Ready-to-bind inline style object for the floating element. */\n floatingStyles: ComputedRef<Record<string, string>>\n /** Trigger a manual recompute. Usually not needed — `autoUpdate` handles scrolling/resizing. */\n update: () => Promise<void>\n /** Arrow x offset (px). Present when `arrow` option is set. */\n arrowX: Ref<number | undefined>\n /** Arrow y offset (px). Present when `arrow` option is set. */\n arrowY: Ref<number | undefined>\n /**\n * Side of the floating element the arrow is on.\n * E.g. `'bottom'` placement → `'top'` (arrow at top pointing up).\n */\n arrowSide: ComputedRef<'top' | 'right' | 'bottom' | 'left' | undefined>\n}\n\n/**\n * Reactive Floating UI integration. Subscribes `autoUpdate` whenever\n * `open === true` and both refs are populated; tears it down on close,\n * unmount, or ref clearing. Returns `floatingStyles` ready to be spread onto\n * the floating element.\n *\n * Pure positioning — does NOT render anything, does NOT manage focus,\n * does NOT handle dismiss behavior. Those concerns live in the consuming\n * primitive (Popover, Tooltip, Dialog, Menu, ...).\n *\n * @example\n * const triggerEl = ref<HTMLElement | null>(null)\n * const contentEl = ref<HTMLElement | null>(null)\n * const open = ref(false)\n * const { floatingStyles } = useFloating({\n * anchor: triggerEl,\n * floating: contentEl,\n * open,\n * placement: 'bottom-start',\n * offset: 8,\n * })\n */\nexport function useFloating(options: UseFloatingOptions): UseFloatingReturn {\n const x = ref(0)\n const y = ref(0)\n // True once the first positioning cycle lands. Until then the panel stays\n // `visibility: hidden` so it never flashes at the viewport origin (0,0).\n const positioned = ref(false)\n const strategy = ref<Strategy>(options.strategy ?? 'absolute')\n const finalPlacement = ref<Placement>(options.placement ?? 'bottom')\n const arrowX = ref<number | undefined>()\n const arrowY = ref<number | undefined>()\n\n const middleware = shallowRef<Middleware[]>([])\n rebuildMiddleware()\n\n function rebuildMiddleware() {\n const mw: Middleware[] = []\n if (options.offset !== undefined) mw.push(offsetMiddleware(options.offset))\n if (options.flip !== false) mw.push(flipMiddleware())\n if (options.shift !== false) mw.push(shiftMiddleware({ padding: 8 }))\n if (options.size) {\n const padding = typeof options.size === 'number' ? options.size : 8\n mw.push(\n sizeMiddleware({\n padding,\n apply({ availableWidth, availableHeight, elements }) {\n Object.assign(elements.floating.style, {\n maxWidth: `${Math.max(0, Math.floor(availableWidth))}px`,\n maxHeight: `${Math.max(0, Math.floor(availableHeight))}px`,\n })\n },\n }),\n )\n }\n if (options.arrow?.value) mw.push(arrowMiddleware({ element: options.arrow.value }))\n if (options.middleware) mw.push(...options.middleware)\n middleware.value = mw\n }\n\n let cleanupAutoUpdate: (() => void) | null = null\n // Monotonic token bumped on every new positioning cycle and on teardown, so a\n // computePosition() that resolves after the panel closed/re-opened (or after a\n // newer update started) drops its result instead of applying stale coords.\n let epoch = 0\n\n async function update() {\n const a = options.anchor.value\n const f = options.floating.value\n if (!a || !f) return\n rebuildMiddleware()\n const token = ++epoch\n const result = await computePosition(a, f, {\n placement: options.placement ?? 'bottom',\n strategy: strategy.value,\n middleware: middleware.value,\n })\n if (token !== epoch) return\n x.value = result.x\n y.value = result.y\n positioned.value = true\n finalPlacement.value = result.placement\n const arrowData = result.middlewareData.arrow as { x?: number; y?: number } | undefined\n arrowX.value = arrowData?.x\n arrowY.value = arrowData?.y\n }\n\n watch(\n [options.open, options.anchor, options.floating],\n ([isOpen, anchorEl, floatingEl]) => {\n cleanupAutoUpdate?.()\n cleanupAutoUpdate = null\n epoch++\n if (isOpen && anchorEl && floatingEl) {\n positioned.value = false\n cleanupAutoUpdate = autoUpdate(anchorEl, floatingEl, () => {\n void update()\n })\n }\n },\n { flush: 'post', immediate: true },\n )\n\n onScopeDispose(() => {\n cleanupAutoUpdate?.()\n cleanupAutoUpdate = null\n epoch++\n })\n\n const OPPOSITE: Record<string, 'top' | 'right' | 'bottom' | 'left'> = {\n top: 'bottom',\n bottom: 'top',\n left: 'right',\n right: 'left',\n }\n const arrowSide = computed(\n () =>\n OPPOSITE[finalPlacement.value.split('-')[0]] as\n 'top' | 'right' | 'bottom' | 'left' | undefined,\n )\n\n const floatingStyles = computed<Record<string, string>>(() => ({\n position: strategy.value,\n top: '0',\n left: '0',\n transform: `translate3d(${Math.round(x.value)}px, ${Math.round(y.value)}px, 0)`,\n width: 'max-content',\n // Hidden until the first positioning cycle lands — prevents a flash at\n // the viewport origin. visibility (not display:none) keeps the panel\n // measurable so Floating UI can compute its real coordinates.\n visibility: positioned.value ? 'visible' : 'hidden',\n }))\n\n return { x, y, strategy, finalPlacement, floatingStyles, update, arrowX, arrowY, arrowSide }\n}\n","import { onScopeDispose, watch, type Ref } from 'vue'\n\nexport interface UseDismissOptions {\n /** While true, the dismiss listeners are active. */\n enabled: Ref<boolean>\n /** Elements that, if clicked, should NOT trigger dismiss (typically trigger + content). */\n exclude: Array<Ref<HTMLElement | null | undefined>>\n /** Called when the user attempts to dismiss the surface. */\n onDismiss: () => void\n /** Close on Escape key. Default `true`. */\n escape?: boolean\n /** Close on pointerdown outside the excluded elements. Default `true`. */\n outsidePointerDown?: boolean\n /**\n * Extra \"inside\" test for pointerdown targets — e.g. teleported sibling\n * surfaces that belong to the same widget but live outside the excluded\n * refs' DOM trees.\n */\n excludePredicate?: (target: EventTarget | null) => boolean\n}\n\n/**\n * Listen for the universal \"dismiss\" gestures: Escape key and outside\n * pointer-down. Used by Popover / Dialog / Menu / Combobox. Tooltip does\n * NOT use this — it dismisses on mouseleave/blur instead.\n *\n * Listeners are attached to `document` only while `enabled` is true, and\n * removed on disable / unmount. SSR-safe (no-op without `document`).\n */\nexport function useDismiss(options: UseDismissOptions): void {\n const escape = options.escape !== false\n const outsidePointerDown = options.outsidePointerDown !== false\n\n const isExcluded = (target: EventTarget | null): boolean => {\n if (!target || !(target instanceof Node)) return false\n for (const r of options.exclude) {\n const el = r.value\n if (!el) continue\n if (el === target || el.contains(target)) return true\n }\n return false\n }\n\n const onPointerDown = (event: PointerEvent) => {\n if (!options.enabled.value) return\n if (isExcluded(event.target)) return\n if (options.excludePredicate?.(event.target)) return\n options.onDismiss()\n }\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (!options.enabled.value) return\n if (event.key === 'Escape') {\n event.stopPropagation()\n options.onDismiss()\n }\n }\n\n const attach = () => {\n if (typeof document === 'undefined') return\n if (outsidePointerDown) {\n document.addEventListener('pointerdown', onPointerDown, true)\n }\n if (escape) {\n document.addEventListener('keydown', onKeyDown)\n }\n }\n\n const detach = () => {\n if (typeof document === 'undefined') return\n document.removeEventListener('pointerdown', onPointerDown, true)\n document.removeEventListener('keydown', onKeyDown)\n }\n\n watch(\n options.enabled,\n (enabled) => {\n detach()\n if (enabled) attach()\n },\n { immediate: true, flush: 'post' },\n )\n\n onScopeDispose(detach)\n}\n"]}
|
package/dist/floating.d.cts
CHANGED
|
@@ -92,6 +92,12 @@ interface UseDismissOptions {
|
|
|
92
92
|
escape?: boolean;
|
|
93
93
|
/** Close on pointerdown outside the excluded elements. Default `true`. */
|
|
94
94
|
outsidePointerDown?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Extra "inside" test for pointerdown targets — e.g. teleported sibling
|
|
97
|
+
* surfaces that belong to the same widget but live outside the excluded
|
|
98
|
+
* refs' DOM trees.
|
|
99
|
+
*/
|
|
100
|
+
excludePredicate?: (target: EventTarget | null) => boolean;
|
|
95
101
|
}
|
|
96
102
|
/**
|
|
97
103
|
* Listen for the universal "dismiss" gestures: Escape key and outside
|
package/dist/floating.d.ts
CHANGED
|
@@ -92,6 +92,12 @@ interface UseDismissOptions {
|
|
|
92
92
|
escape?: boolean;
|
|
93
93
|
/** Close on pointerdown outside the excluded elements. Default `true`. */
|
|
94
94
|
outsidePointerDown?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Extra "inside" test for pointerdown targets — e.g. teleported sibling
|
|
97
|
+
* surfaces that belong to the same widget but live outside the excluded
|
|
98
|
+
* refs' DOM trees.
|
|
99
|
+
*/
|
|
100
|
+
excludePredicate?: (target: EventTarget | null) => boolean;
|
|
95
101
|
}
|
|
96
102
|
/**
|
|
97
103
|
* Listen for the universal "dismiss" gestures: Escape key and outside
|
package/dist/floating.js
CHANGED