@iris-ui-kit/vue 0.2.21 → 0.2.23
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 +14 -5
- package/dist/admin.cjs.map +1 -1
- package/dist/admin.js +2 -2
- package/dist/async.cjs +48 -2
- package/dist/async.cjs.map +1 -1
- package/dist/async.d.cts +27 -3
- package/dist/async.d.ts +27 -3
- package/dist/async.js +1 -1
- package/dist/behaviors.cjs +87 -48
- package/dist/behaviors.cjs.map +1 -1
- package/dist/behaviors.d.cts +2 -2
- package/dist/behaviors.d.ts +2 -2
- package/dist/behaviors.js +1 -1
- package/dist/chunk-25NYWSXP.js +20 -0
- package/dist/chunk-25NYWSXP.js.map +1 -0
- package/dist/{chunk-CWXH44OF.js → chunk-3IH7IJ5S.js} +90 -51
- package/dist/chunk-3IH7IJ5S.js.map +1 -0
- package/dist/{chunk-ENKE2BPC.js → chunk-BEPH6PPL.js} +23 -5
- package/dist/chunk-BEPH6PPL.js.map +1 -0
- package/dist/{chunk-FG5USQSY.js → chunk-I7PR4ILF.js} +8 -3
- package/dist/chunk-I7PR4ILF.js.map +1 -0
- package/dist/{chunk-4FLIW67H.js → chunk-IAG64CHL.js} +21 -28
- package/dist/chunk-IAG64CHL.js.map +1 -0
- package/dist/chunk-NNOF7KUH.js +24 -0
- package/dist/chunk-NNOF7KUH.js.map +1 -0
- package/dist/{chunk-4WQOZ2OV.js → chunk-QQ25RKOO.js} +6 -4
- package/dist/chunk-QQ25RKOO.js.map +1 -0
- package/dist/chunk-SJB5DIIY.js +119 -0
- package/dist/chunk-SJB5DIIY.js.map +1 -0
- package/dist/form.cjs +28 -23
- package/dist/form.cjs.map +1 -1
- package/dist/form.d.cts +3 -2
- package/dist/form.d.ts +3 -2
- package/dist/form.js +2 -1
- package/dist/index.cjs +216 -91
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -18
- package/dist/index.js.map +1 -1
- package/dist/machine.cjs +11 -4
- package/dist/machine.cjs.map +1 -1
- package/dist/machine.d.cts +12 -3
- package/dist/machine.d.ts +12 -3
- package/dist/machine.js +1 -1
- package/dist/resource.cjs +7 -3
- package/dist/resource.cjs.map +1 -1
- package/dist/resource.d.cts +10 -1
- package/dist/resource.d.ts +10 -1
- package/dist/resource.js +1 -1
- package/dist/skeletons.cjs +21 -3
- package/dist/skeletons.cjs.map +1 -1
- package/dist/skeletons.d.cts +21 -0
- package/dist/skeletons.d.ts +21 -0
- package/dist/skeletons.js +1 -1
- package/dist/undo.cjs +6 -1
- package/dist/undo.cjs.map +1 -1
- package/dist/undo.d.cts +5 -0
- package/dist/undo.d.ts +5 -0
- package/dist/undo.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-4FLIW67H.js.map +0 -1
- package/dist/chunk-4WQOZ2OV.js.map +0 -1
- package/dist/chunk-CWXH44OF.js.map +0 -1
- package/dist/chunk-ENKE2BPC.js.map +0 -1
- package/dist/chunk-FG5USQSY.js.map +0 -1
- package/dist/chunk-TQB5LVOH.js +0 -17
- package/dist/chunk-TQB5LVOH.js.map +0 -1
- package/dist/chunk-XSLBANUV.js +0 -16
- package/dist/chunk-XSLBANUV.js.map +0 -1
- package/dist/chunk-ZY4NLITM.js +0 -73
- package/dist/chunk-ZY4NLITM.js.map +0 -1
package/dist/admin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { IrisAdminBreadcrumb, IrisAdminLayout, IrisAdminTabs, IrisNavMenu, createAdminPreferences, createTabsNav, filterNavByAccess, findNavNode, findNavPath, firstLeaf, flattenNav, isBranch, isClosable, localStorageAdminPreferencesStorage, nodeAllowsRoles, useAdminPreferences, useAdminShell, useTabsNav, visibleNav } from './chunk-
|
|
1
|
+
export { IrisAdminBreadcrumb, IrisAdminLayout, IrisAdminTabs, IrisNavMenu, createAdminPreferences, createTabsNav, filterNavByAccess, findNavNode, findNavPath, firstLeaf, flattenNav, isBranch, isClosable, localStorageAdminPreferencesStorage, nodeAllowsRoles, useAdminPreferences, useAdminShell, useTabsNav, visibleNav } from './chunk-QQ25RKOO.js';
|
|
2
2
|
import './chunk-3FJUCHCC.js';
|
|
3
|
-
import './chunk-
|
|
3
|
+
import './chunk-NNOF7KUH.js';
|
|
4
4
|
import './chunk-F77KIPOH.js';
|
|
5
5
|
import './chunk-3V46HGRC.js';
|
|
6
6
|
import './chunk-ZTPIXL7Q.js';
|
package/dist/async.cjs
CHANGED
|
@@ -5,8 +5,31 @@ var core = require('@iris-ui-kit/core');
|
|
|
5
5
|
|
|
6
6
|
// src/async/useAsyncResource.ts
|
|
7
7
|
function useAsyncResource(fetcher, options = {}) {
|
|
8
|
+
const holder = {
|
|
9
|
+
// isRef-only resolution. NEVER toValue() here: the element type is itself
|
|
10
|
+
// a function, so toValue(fetcher) would *invoke the fetcher at setup*
|
|
11
|
+
// (spurious request) and toValue(getter) would do the same. isRef narrows
|
|
12
|
+
// to the only unambiguous reactive form: ref(fetcher) / computed(() =>
|
|
13
|
+
// fetcher) / shallowRef(fetcher) — a ComputedRef IS a Ref.
|
|
14
|
+
// F3 elision point — the ONE explicit narrowing cast: after the isRef
|
|
15
|
+
// guard the else arm is `F | (() => F)`, and the bare-getter arm's return
|
|
16
|
+
// `F` (a function) is not assignable to `F` (TS2322). No runtime
|
|
17
|
+
// discriminant distinguishes a plain fetcher from a bare getter (both are
|
|
18
|
+
// functions), so the cast encodes exactly the documented F3 ambiguity and
|
|
19
|
+
// adds no unsafety beyond F3.
|
|
20
|
+
current: vue.isRef(fetcher) ? fetcher.value : fetcher
|
|
21
|
+
};
|
|
22
|
+
if (vue.isRef(fetcher)) {
|
|
23
|
+
vue.watch(
|
|
24
|
+
fetcher,
|
|
25
|
+
(next) => {
|
|
26
|
+
holder.current = next;
|
|
27
|
+
},
|
|
28
|
+
{ flush: "sync" }
|
|
29
|
+
);
|
|
30
|
+
}
|
|
8
31
|
const config = "initialData" in options ? { initialData: options.initialData } : {};
|
|
9
|
-
const resource = core.createAsyncResource(
|
|
32
|
+
const resource = core.createAsyncResource((...params) => holder.current(...params), config);
|
|
10
33
|
const state = vue.ref(resource.getState());
|
|
11
34
|
const unsubscribe = resource.subscribe((next) => {
|
|
12
35
|
state.value = next;
|
|
@@ -34,7 +57,30 @@ function useAsyncResource(fetcher, options = {}) {
|
|
|
34
57
|
};
|
|
35
58
|
}
|
|
36
59
|
function usePaginatedResource(fetcher, options = {}) {
|
|
37
|
-
const
|
|
60
|
+
const holder = {
|
|
61
|
+
// isRef-only resolution. NEVER toValue() here: the element type is itself
|
|
62
|
+
// a function, so toValue(fetcher) would *invoke the fetcher at setup*
|
|
63
|
+
// (spurious request) and toValue(getter) would do the same. isRef narrows
|
|
64
|
+
// to the only unambiguous reactive form: ref(fetcher) / computed(() =>
|
|
65
|
+
// fetcher) / shallowRef(fetcher) — a ComputedRef IS a Ref.
|
|
66
|
+
// F3 elision point — the ONE explicit narrowing cast: after the isRef
|
|
67
|
+
// guard the else arm is `F | (() => F)`, and the bare-getter arm's return
|
|
68
|
+
// `F` (a function) is not assignable to `F` (TS2322). No runtime
|
|
69
|
+
// discriminant distinguishes a plain fetcher from a bare getter (both are
|
|
70
|
+
// functions), so the cast encodes exactly the documented F3 ambiguity and
|
|
71
|
+
// adds no unsafety beyond F3.
|
|
72
|
+
current: vue.isRef(fetcher) ? fetcher.value : fetcher
|
|
73
|
+
};
|
|
74
|
+
if (vue.isRef(fetcher)) {
|
|
75
|
+
vue.watch(
|
|
76
|
+
fetcher,
|
|
77
|
+
(next) => {
|
|
78
|
+
holder.current = next;
|
|
79
|
+
},
|
|
80
|
+
{ flush: "sync" }
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
const resource = core.createPaginatedResource((query) => holder.current(query), {
|
|
38
84
|
pageSize: options.pageSize,
|
|
39
85
|
mode: options.mode
|
|
40
86
|
});
|
package/dist/async.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/async/useAsyncResource.ts","../src/async/usePagin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AA,CAAS,MAAM,KAAA,CAAM,MAAM,KAAK,CAAA;AAAA,IACvC,WAAWA,YAAAA,CAAS,MAAM,KAAA,CAAM,KAAA,CAAM,WAAW,SAAS,CAAA;AAAA,IAC1D,SAASA,YAAAA,CAAS,MAAM,KAAA,CAAM,KAAA,CAAM,WAAW,OAAO,CAAA;AAAA;AAAA;AAAA,IAGtD,OAAA,EAASA,aAAS,MAAM;AACtB,MAAA,KAAK,KAAA,CAAM,KAAA;AACX,MAAA,OAAO,SAAS,OAAA,EAAQ;AAAA,IAC1B,CAAC,CAAA;AAAA,IACD,UAAU,QAAA,CAAS,QAAA;AAAA,IACnB,UAAU,QAAA,CAAS,QAAA;AAAA,IACnB,SAAS,QAAA,CAAS,OAAA;AAAA,IAClB,aAAa,QAAA,CAAS;AAAA,GACxB;AACF","file":"async.cjs","sourcesContent":["import { computed, onBeforeUnmount, onMounted, ref, type ComputedRef, type Ref } from 'vue'\nimport {\n createAsyncResource,\n type AsyncResource,\n type AsyncResourceConfig,\n type AsyncState,\n type AsyncStatus,\n} from '@iris-ui-kit/core'\n\nexport interface UseAsyncResourceOptions<T> extends AsyncResourceConfig<T> {\n /** Run `load()` (no params) once on mount. Default `false`. */\n immediate?: boolean\n}\n\nexport interface UseAsyncResourceReturn<T, P extends unknown[]> {\n status: ComputedRef<AsyncStatus>\n data: ComputedRef<T | undefined>\n error: ComputedRef<unknown>\n isLoading: ComputedRef<boolean>\n isError: ComputedRef<boolean>\n load: AsyncResource<T, P>['load']\n reload: AsyncResource<T, P>['reload']\n mutate: AsyncResource<T, P>['mutate']\n cancel: AsyncResource<T, P>['cancel']\n reset: AsyncResource<T, P>['reset']\n}\n\n/**\n * Vue binding for the framework-agnostic async resource. Creates the resource\n * in `setup()` (runs once, so the fetcher closure stays live) and bridges its\n * state into computed refs.\n *\n * ```ts\n * const users = useAsyncResource(() => api.listUsers(), { immediate: true })\n * // <IrisTable :data=\"users.data.value ?? []\" :loading=\"users.isLoading.value\" />\n * ```\n */\nexport function useAsyncResource<T, P extends unknown[] = []>(\n fetcher: (...params: P) => Promise<T>,\n options: UseAsyncResourceOptions<T> = {},\n): UseAsyncResourceReturn<T, P> {\n const config: AsyncResourceConfig<T> =\n 'initialData' in options ? { initialData: options.initialData } : {}\n const resource = createAsyncResource<T, P>(fetcher, config)\n\n const state = ref(resource.getState()) as Ref<AsyncState<T>>\n const unsubscribe = resource.subscribe((next) => {\n state.value = next\n })\n onBeforeUnmount(() => {\n unsubscribe()\n // Abort any in-flight request on unmount so it can't write back into an\n // unmounted component (and cancels the underlying request when the fetcher\n // honors `signal`). Idempotent and safe with no in-flight load.\n resource.cancel()\n })\n\n if (options.immediate) {\n onMounted(() => {\n void resource.load(...([] as unknown as P))\n })\n }\n\n return {\n status: computed(() => state.value.status),\n data: computed(() => state.value.data),\n error: computed(() => state.value.error),\n isLoading: computed(() => state.value.status === 'loading'),\n isError: computed(() => state.value.status === 'error'),\n load: resource.load,\n reload: resource.reload,\n mutate: resource.mutate,\n cancel: resource.cancel,\n reset: resource.reset,\n }\n}\n","import { computed, onBeforeUnmount, onMounted, ref, type ComputedRef, type Ref } from 'vue'\nimport {\n createPaginatedResource,\n type PageQuery,\n type PageResult,\n type PaginatedResource,\n type PaginatedState,\n type PaginationMode,\n} from '@iris-ui-kit/core'\n\nexport interface UsePaginatedResourceOptions {\n pageSize?: number\n mode?: PaginationMode\n /** Load the first page on mount (page 1, or `loadMore` in infinite mode). */\n immediate?: boolean\n}\n\nexport interface UsePaginatedResourceReturn<T> {\n status: ComputedRef<PaginatedState<T>['status']>\n items: ComputedRef<T[]>\n page: ComputedRef<number>\n pageSize: ComputedRef<number>\n total: ComputedRef<number | undefined>\n error: ComputedRef<unknown>\n isLoading: ComputedRef<boolean>\n isError: ComputedRef<boolean>\n hasMore: ComputedRef<boolean>\n goToPage: PaginatedResource<T>['goToPage']\n loadMore: PaginatedResource<T>['loadMore']\n refresh: PaginatedResource<T>['refresh']\n setPageSize: PaginatedResource<T>['setPageSize']\n}\n\n/**\n * Vue binding for the server-side pagination resource. Created in `setup()`\n * (fetcher closure stays live) and bridged to computed refs.\n */\nexport function usePaginatedResource<T>(\n fetcher: (query: PageQuery) => Promise<PageResult<T>>,\n options: UsePaginatedResourceOptions = {},\n): UsePaginatedResourceReturn<T> {\n const resource = createPaginatedResource<T>(fetcher, {\n pageSize: options.pageSize,\n mode: options.mode,\n })\n\n const state = ref(resource.getState()) as Ref<PaginatedState<T>>\n const unsubscribe = resource.subscribe((next) => {\n state.value = next\n })\n onBeforeUnmount(unsubscribe)\n\n if (options.immediate) {\n onMounted(() => {\n void (options.mode === 'infinite' ? resource.loadMore() : resource.goToPage(1))\n })\n }\n\n return {\n status: computed(() => state.value.status),\n items: computed(() => state.value.items),\n page: computed(() => state.value.page),\n pageSize: computed(() => state.value.pageSize),\n total: computed(() => state.value.total),\n error: computed(() => state.value.error),\n isLoading: computed(() => state.value.status === 'loading'),\n isError: computed(() => state.value.status === 'error'),\n // Touch state so this recomputes on every store change; hasMore() then\n // reads the resource's fresh internal batch state.\n hasMore: computed(() => {\n void state.value\n return resource.hasMore()\n }),\n goToPage: resource.goToPage,\n loadMore: resource.loadMore,\n refresh: resource.refresh,\n setPageSize: resource.setPageSize,\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/async/useAsyncResource.ts","../src/async/usePaginatedResource.ts"],"names":["isRef","watch","createAsyncResource","ref","onBeforeUnmount","onMounted","computed","createPaginatedResource"],"mappings":";;;;;;AA2DO,SAAS,gBAAA,CACd,OAAA,EACA,OAAA,GAAsC,EAAC,EACT;AAK9B,EAAA,MAAM,MAAA,GAAoD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAYxD,OAAA,EAAUA,SAAA,CAAM,OAAO,CAAA,GAAI,QAAQ,KAAA,GAAQ;AAAA,GAC7C;AACA,EAAA,IAAIA,SAAA,CAAM,OAAO,CAAA,EAAG;AAMlB,IAAAC,SAAA;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UAAA,GAAa,QAAA,CAAS,UAAS,GAAI,QAAA,CAAS,SAAS,CAAC,CAAA,CAAA;AAAA,IAC/E,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,OAAO;AAAA,IACL,MAAA,EAAQC,YAAAA,CAAS,MAAM,KAAA,CAAM,MAAM,MAAM,CAAA;AAAA,IACzC,KAAA,EAAOA,YAAAA,CAAS,MAAM,KAAA,CAAM,MAAM,KAAK,CAAA;AAAA,IACvC,IAAA,EAAMA,YAAAA,CAAS,MAAM,KAAA,CAAM,MAAM,IAAI,CAAA;AAAA,IACrC,QAAA,EAAUA,YAAAA,CAAS,MAAM,KAAA,CAAM,MAAM,QAAQ,CAAA;AAAA,IAC7C,KAAA,EAAOA,YAAAA,CAAS,MAAM,KAAA,CAAM,MAAM,KAAK,CAAA;AAAA,IACvC,KAAA,EAAOA,YAAAA,CAAS,MAAM,KAAA,CAAM,MAAM,KAAK,CAAA;AAAA,IACvC,WAAWA,YAAAA,CAAS,MAAM,KAAA,CAAM,KAAA,CAAM,WAAW,SAAS,CAAA;AAAA,IAC1D,SAASA,YAAAA,CAAS,MAAM,KAAA,CAAM,KAAA,CAAM,WAAW,OAAO,CAAA;AAAA;AAAA;AAAA,IAGtD,OAAA,EAASA,aAAS,MAAM;AACtB,MAAA,KAAK,KAAA,CAAM,KAAA;AACX,MAAA,OAAO,SAAS,OAAA,EAAQ;AAAA,IAC1B,CAAC,CAAA;AAAA,IACD,UAAU,QAAA,CAAS,QAAA;AAAA,IACnB,UAAU,QAAA,CAAS,QAAA;AAAA,IACnB,SAAS,QAAA,CAAS,OAAA;AAAA,IAClB,aAAa,QAAA,CAAS;AAAA,GACxB;AACF","file":"async.cjs","sourcesContent":["import {\n computed,\n isRef,\n onBeforeUnmount,\n onMounted,\n ref,\n watch,\n type ComputedRef,\n type MaybeRefOrGetter,\n type Ref,\n} from 'vue'\nimport {\n createAsyncResource,\n type AsyncResource,\n type AsyncResourceConfig,\n type AsyncState,\n type AsyncStatus,\n} from '@iris-ui-kit/core'\n\nexport interface UseAsyncResourceOptions<T> extends AsyncResourceConfig<T> {\n /** Run `load()` (no params) once on mount. Default `false`. */\n immediate?: boolean\n}\n\nexport interface UseAsyncResourceReturn<T, P extends unknown[]> {\n status: ComputedRef<AsyncStatus>\n data: ComputedRef<T | undefined>\n error: ComputedRef<unknown>\n isLoading: ComputedRef<boolean>\n isError: ComputedRef<boolean>\n load: AsyncResource<T, P>['load']\n reload: AsyncResource<T, P>['reload']\n mutate: AsyncResource<T, P>['mutate']\n cancel: AsyncResource<T, P>['cancel']\n reset: AsyncResource<T, P>['reset']\n}\n\n/**\n * Vue binding for the framework-agnostic async resource. Creates the resource\n * in `setup()` (runs once, so the fetcher closure stays live) and bridges its\n * state into computed refs.\n *\n * ```ts\n * const users = useAsyncResource(() => api.listUsers(), { immediate: true })\n * // <IrisTable :data=\"users.data.value ?? []\" :loading=\"users.isLoading.value\" />\n * ```\n *\n * The fetcher may be reactive — pass `ref(fetcher)` or `computed(() => fetcher)`\n * and the *current* closure is used on every `load()`/`reload()`. Updating it\n * does NOT auto-refetch; call `reload()` yourself:\n *\n * ```ts\n * const users = useAsyncResource(computed(() => api.listUsers(props.id)), { immediate: true })\n * watch(() => props.id, () => void users.reload())\n * ```\n *\n * A bare getter `() => fetcher` is indistinguishable from a plain zero-arg\n * fetcher and is treated as one — use `computed`/`ref` for reactive fetchers.\n */\nexport function useAsyncResource<T, P extends unknown[] = []>(\n fetcher: MaybeRefOrGetter<(...params: P) => Promise<T>>,\n options: UseAsyncResourceOptions<T> = {},\n): UseAsyncResourceReturn<T, P> {\n // Plain-object holder (the Vue analog of React's `latest.current` ref):\n // core only ever sees the wrapper below, which re-reads `holder.current` at\n // call time — so `load()`, `reload()` and its `lastParams` replay all use\n // the fresh closure for the component's whole lifetime.\n const holder: { current: (...params: P) => Promise<T> } = {\n // isRef-only resolution. NEVER toValue() here: the element type is itself\n // a function, so toValue(fetcher) would *invoke the fetcher at setup*\n // (spurious request) and toValue(getter) would do the same. isRef narrows\n // to the only unambiguous reactive form: ref(fetcher) / computed(() =>\n // fetcher) / shallowRef(fetcher) — a ComputedRef IS a Ref.\n // F3 elision point — the ONE explicit narrowing cast: after the isRef\n // guard the else arm is `F | (() => F)`, and the bare-getter arm's return\n // `F` (a function) is not assignable to `F` (TS2322). No runtime\n // discriminant distinguishes a plain fetcher from a bare getter (both are\n // functions), so the cast encodes exactly the documented F3 ambiguity and\n // adds no unsafety beyond F3.\n current: (isRef(fetcher) ? fetcher.value : fetcher) as (...params: P) => Promise<T>,\n }\n if (isRef(fetcher)) {\n // Ref sources only. watch(fn, cb) would treat a plain function source as a\n // getter: evaluate it once at setup (spurious fetcher invocation) and track\n // its deps. flush: 'sync' (precedent useAdminShell.ts:67) guarantees a\n // load()/reload() in the same tick as the ref assignment sees the new\n // closure. Plain-object holder => the swap is not reactive, no re-render.\n watch(\n fetcher,\n (next) => {\n holder.current = next\n },\n { flush: 'sync' },\n )\n }\n\n const config: AsyncResourceConfig<T> =\n 'initialData' in options ? { initialData: options.initialData } : {}\n const resource = createAsyncResource<T, P>((...params) => holder.current(...params), config)\n\n const state = ref(resource.getState()) as Ref<AsyncState<T>>\n const unsubscribe = resource.subscribe((next) => {\n state.value = next\n })\n onBeforeUnmount(() => {\n unsubscribe()\n // Abort any in-flight request on unmount so it can't write back into an\n // unmounted component (and cancels the underlying request when the fetcher\n // honors `signal`). Idempotent and safe with no in-flight load.\n resource.cancel()\n })\n\n if (options.immediate) {\n onMounted(() => {\n void resource.load(...([] as unknown as P))\n })\n }\n\n return {\n status: computed(() => state.value.status),\n data: computed(() => state.value.data),\n error: computed(() => state.value.error),\n isLoading: computed(() => state.value.status === 'loading'),\n isError: computed(() => state.value.status === 'error'),\n load: resource.load,\n reload: resource.reload,\n mutate: resource.mutate,\n cancel: resource.cancel,\n reset: resource.reset,\n }\n}\n","import {\n computed,\n isRef,\n onBeforeUnmount,\n onMounted,\n ref,\n watch,\n type ComputedRef,\n type MaybeRefOrGetter,\n type Ref,\n} from 'vue'\nimport {\n createPaginatedResource,\n type PageQuery,\n type PageResult,\n type PaginatedResource,\n type PaginatedState,\n type PaginationMode,\n} from '@iris-ui-kit/core'\n\nexport interface UsePaginatedResourceOptions {\n pageSize?: number\n mode?: PaginationMode\n /** Load the first page on mount (page 1, or `loadMore` in infinite mode). */\n immediate?: boolean\n}\n\nexport interface UsePaginatedResourceReturn<T> {\n status: ComputedRef<PaginatedState<T>['status']>\n items: ComputedRef<T[]>\n page: ComputedRef<number>\n pageSize: ComputedRef<number>\n total: ComputedRef<number | undefined>\n error: ComputedRef<unknown>\n isLoading: ComputedRef<boolean>\n isError: ComputedRef<boolean>\n hasMore: ComputedRef<boolean>\n goToPage: PaginatedResource<T>['goToPage']\n loadMore: PaginatedResource<T>['loadMore']\n refresh: PaginatedResource<T>['refresh']\n setPageSize: PaginatedResource<T>['setPageSize']\n}\n\n/**\n * Vue binding for the server-side pagination resource. Created in `setup()`\n * (fetcher closure stays live) and bridged to computed refs.\n *\n * The fetcher may be reactive — pass `ref(fetcher)` or `computed(() => fetcher)`\n * and the *current* closure is used on every page load (`goToPage`/`loadMore`/\n * `refresh`). Updating it does NOT auto-refetch; trigger a load yourself:\n *\n * ```ts\n * const p = usePaginatedResource(computed(() => api.listUsers(props.id)))\n * watch(() => props.id, () => void p.refresh())\n * ```\n *\n * A bare getter `() => fetcher` is indistinguishable from a plain fetcher and\n * is treated as one — use `computed`/`ref` for reactive fetchers.\n */\nexport function usePaginatedResource<T>(\n fetcher: MaybeRefOrGetter<(query: PageQuery) => Promise<PageResult<T>>>,\n options: UsePaginatedResourceOptions = {},\n): UsePaginatedResourceReturn<T> {\n // Plain-object holder (the Vue analog of React's `latest.current` ref):\n // core only ever sees the wrapper below, which re-reads `holder.current` at\n // call time — so every page load (and `refresh`'s replay) uses the fresh\n // closure for the component's whole lifetime.\n const holder: { current: (query: PageQuery) => Promise<PageResult<T>> } = {\n // isRef-only resolution. NEVER toValue() here: the element type is itself\n // a function, so toValue(fetcher) would *invoke the fetcher at setup*\n // (spurious request) and toValue(getter) would do the same. isRef narrows\n // to the only unambiguous reactive form: ref(fetcher) / computed(() =>\n // fetcher) / shallowRef(fetcher) — a ComputedRef IS a Ref.\n // F3 elision point — the ONE explicit narrowing cast: after the isRef\n // guard the else arm is `F | (() => F)`, and the bare-getter arm's return\n // `F` (a function) is not assignable to `F` (TS2322). No runtime\n // discriminant distinguishes a plain fetcher from a bare getter (both are\n // functions), so the cast encodes exactly the documented F3 ambiguity and\n // adds no unsafety beyond F3.\n current: (isRef(fetcher) ? fetcher.value : fetcher) as (\n query: PageQuery,\n ) => Promise<PageResult<T>>,\n }\n if (isRef(fetcher)) {\n // Ref sources only. watch(fn, cb) would treat a plain function source as a\n // getter: evaluate it once at setup (spurious fetcher invocation) and track\n // its deps. flush: 'sync' (precedent useAdminShell.ts:67) guarantees a\n // page load in the same tick as the ref assignment sees the new closure.\n // Plain-object holder => the swap is not reactive, no re-render.\n watch(\n fetcher,\n (next) => {\n holder.current = next\n },\n { flush: 'sync' },\n )\n }\n\n const resource = createPaginatedResource<T>((query) => holder.current(query), {\n pageSize: options.pageSize,\n mode: options.mode,\n })\n\n const state = ref(resource.getState()) as Ref<PaginatedState<T>>\n const unsubscribe = resource.subscribe((next) => {\n state.value = next\n })\n onBeforeUnmount(unsubscribe)\n\n if (options.immediate) {\n onMounted(() => {\n void (options.mode === 'infinite' ? resource.loadMore() : resource.goToPage(1))\n })\n }\n\n return {\n status: computed(() => state.value.status),\n items: computed(() => state.value.items),\n page: computed(() => state.value.page),\n pageSize: computed(() => state.value.pageSize),\n total: computed(() => state.value.total),\n error: computed(() => state.value.error),\n isLoading: computed(() => state.value.status === 'loading'),\n isError: computed(() => state.value.status === 'error'),\n // Touch state so this recomputes on every store change; hasMore() then\n // reads the resource's fresh internal batch state.\n hasMore: computed(() => {\n void state.value\n return resource.hasMore()\n }),\n goToPage: resource.goToPage,\n loadMore: resource.loadMore,\n refresh: resource.refresh,\n setPageSize: resource.setPageSize,\n }\n}\n"]}
|
package/dist/async.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComputedRef } from 'vue';
|
|
1
|
+
import { ComputedRef, MaybeRefOrGetter } from 'vue';
|
|
2
2
|
import { AsyncResourceConfig, AsyncStatus, AsyncResource, PaginationMode, PaginatedState, PaginatedResource, PageQuery, PageResult } from '@iris-ui-kit/core';
|
|
3
3
|
|
|
4
4
|
interface UseAsyncResourceOptions<T> extends AsyncResourceConfig<T> {
|
|
@@ -26,8 +26,20 @@ interface UseAsyncResourceReturn<T, P extends unknown[]> {
|
|
|
26
26
|
* const users = useAsyncResource(() => api.listUsers(), { immediate: true })
|
|
27
27
|
* // <IrisTable :data="users.data.value ?? []" :loading="users.isLoading.value" />
|
|
28
28
|
* ```
|
|
29
|
+
*
|
|
30
|
+
* The fetcher may be reactive — pass `ref(fetcher)` or `computed(() => fetcher)`
|
|
31
|
+
* and the *current* closure is used on every `load()`/`reload()`. Updating it
|
|
32
|
+
* does NOT auto-refetch; call `reload()` yourself:
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* const users = useAsyncResource(computed(() => api.listUsers(props.id)), { immediate: true })
|
|
36
|
+
* watch(() => props.id, () => void users.reload())
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* A bare getter `() => fetcher` is indistinguishable from a plain zero-arg
|
|
40
|
+
* fetcher and is treated as one — use `computed`/`ref` for reactive fetchers.
|
|
29
41
|
*/
|
|
30
|
-
declare function useAsyncResource<T, P extends unknown[] = []>(fetcher: (...params: P) => Promise<T
|
|
42
|
+
declare function useAsyncResource<T, P extends unknown[] = []>(fetcher: MaybeRefOrGetter<(...params: P) => Promise<T>>, options?: UseAsyncResourceOptions<T>): UseAsyncResourceReturn<T, P>;
|
|
31
43
|
|
|
32
44
|
interface UsePaginatedResourceOptions {
|
|
33
45
|
pageSize?: number;
|
|
@@ -53,7 +65,19 @@ interface UsePaginatedResourceReturn<T> {
|
|
|
53
65
|
/**
|
|
54
66
|
* Vue binding for the server-side pagination resource. Created in `setup()`
|
|
55
67
|
* (fetcher closure stays live) and bridged to computed refs.
|
|
68
|
+
*
|
|
69
|
+
* The fetcher may be reactive — pass `ref(fetcher)` or `computed(() => fetcher)`
|
|
70
|
+
* and the *current* closure is used on every page load (`goToPage`/`loadMore`/
|
|
71
|
+
* `refresh`). Updating it does NOT auto-refetch; trigger a load yourself:
|
|
72
|
+
*
|
|
73
|
+
* ```ts
|
|
74
|
+
* const p = usePaginatedResource(computed(() => api.listUsers(props.id)))
|
|
75
|
+
* watch(() => props.id, () => void p.refresh())
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* A bare getter `() => fetcher` is indistinguishable from a plain fetcher and
|
|
79
|
+
* is treated as one — use `computed`/`ref` for reactive fetchers.
|
|
56
80
|
*/
|
|
57
|
-
declare function usePaginatedResource<T>(fetcher: (query: PageQuery) => Promise<PageResult<T
|
|
81
|
+
declare function usePaginatedResource<T>(fetcher: MaybeRefOrGetter<(query: PageQuery) => Promise<PageResult<T>>>, options?: UsePaginatedResourceOptions): UsePaginatedResourceReturn<T>;
|
|
58
82
|
|
|
59
83
|
export { type UseAsyncResourceOptions, type UseAsyncResourceReturn, type UsePaginatedResourceOptions, type UsePaginatedResourceReturn, useAsyncResource, usePaginatedResource };
|
package/dist/async.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComputedRef } from 'vue';
|
|
1
|
+
import { ComputedRef, MaybeRefOrGetter } from 'vue';
|
|
2
2
|
import { AsyncResourceConfig, AsyncStatus, AsyncResource, PaginationMode, PaginatedState, PaginatedResource, PageQuery, PageResult } from '@iris-ui-kit/core';
|
|
3
3
|
|
|
4
4
|
interface UseAsyncResourceOptions<T> extends AsyncResourceConfig<T> {
|
|
@@ -26,8 +26,20 @@ interface UseAsyncResourceReturn<T, P extends unknown[]> {
|
|
|
26
26
|
* const users = useAsyncResource(() => api.listUsers(), { immediate: true })
|
|
27
27
|
* // <IrisTable :data="users.data.value ?? []" :loading="users.isLoading.value" />
|
|
28
28
|
* ```
|
|
29
|
+
*
|
|
30
|
+
* The fetcher may be reactive — pass `ref(fetcher)` or `computed(() => fetcher)`
|
|
31
|
+
* and the *current* closure is used on every `load()`/`reload()`. Updating it
|
|
32
|
+
* does NOT auto-refetch; call `reload()` yourself:
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* const users = useAsyncResource(computed(() => api.listUsers(props.id)), { immediate: true })
|
|
36
|
+
* watch(() => props.id, () => void users.reload())
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* A bare getter `() => fetcher` is indistinguishable from a plain zero-arg
|
|
40
|
+
* fetcher and is treated as one — use `computed`/`ref` for reactive fetchers.
|
|
29
41
|
*/
|
|
30
|
-
declare function useAsyncResource<T, P extends unknown[] = []>(fetcher: (...params: P) => Promise<T
|
|
42
|
+
declare function useAsyncResource<T, P extends unknown[] = []>(fetcher: MaybeRefOrGetter<(...params: P) => Promise<T>>, options?: UseAsyncResourceOptions<T>): UseAsyncResourceReturn<T, P>;
|
|
31
43
|
|
|
32
44
|
interface UsePaginatedResourceOptions {
|
|
33
45
|
pageSize?: number;
|
|
@@ -53,7 +65,19 @@ interface UsePaginatedResourceReturn<T> {
|
|
|
53
65
|
/**
|
|
54
66
|
* Vue binding for the server-side pagination resource. Created in `setup()`
|
|
55
67
|
* (fetcher closure stays live) and bridged to computed refs.
|
|
68
|
+
*
|
|
69
|
+
* The fetcher may be reactive — pass `ref(fetcher)` or `computed(() => fetcher)`
|
|
70
|
+
* and the *current* closure is used on every page load (`goToPage`/`loadMore`/
|
|
71
|
+
* `refresh`). Updating it does NOT auto-refetch; trigger a load yourself:
|
|
72
|
+
*
|
|
73
|
+
* ```ts
|
|
74
|
+
* const p = usePaginatedResource(computed(() => api.listUsers(props.id)))
|
|
75
|
+
* watch(() => props.id, () => void p.refresh())
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* A bare getter `() => fetcher` is indistinguishable from a plain fetcher and
|
|
79
|
+
* is treated as one — use `computed`/`ref` for reactive fetchers.
|
|
56
80
|
*/
|
|
57
|
-
declare function usePaginatedResource<T>(fetcher: (query: PageQuery) => Promise<PageResult<T
|
|
81
|
+
declare function usePaginatedResource<T>(fetcher: MaybeRefOrGetter<(query: PageQuery) => Promise<PageResult<T>>>, options?: UsePaginatedResourceOptions): UsePaginatedResourceReturn<T>;
|
|
58
82
|
|
|
59
83
|
export { type UseAsyncResourceOptions, type UseAsyncResourceReturn, type UsePaginatedResourceOptions, type UsePaginatedResourceReturn, useAsyncResource, usePaginatedResource };
|
package/dist/async.js
CHANGED
package/dist/behaviors.cjs
CHANGED
|
@@ -127,6 +127,72 @@ function handlePosition(handle) {
|
|
|
127
127
|
s.cursor = HANDLE_CURSORS[handle];
|
|
128
128
|
return s;
|
|
129
129
|
}
|
|
130
|
+
var ResizableHandle = vue.defineComponent({
|
|
131
|
+
name: "ResizableHandle",
|
|
132
|
+
props: {
|
|
133
|
+
handle: { type: String, required: true },
|
|
134
|
+
disabled: { type: Boolean, default: false },
|
|
135
|
+
keepAspect: { type: Boolean, default: false },
|
|
136
|
+
minWidth: { type: Number, default: 40 },
|
|
137
|
+
minHeight: { type: Number, default: 40 },
|
|
138
|
+
maxWidth: { type: Number, default: Infinity },
|
|
139
|
+
maxHeight: { type: Number, default: Infinity },
|
|
140
|
+
/** Stable computed ref from the parent; read only (never mutated). */
|
|
141
|
+
sizeRef: { type: Object, required: true },
|
|
142
|
+
/** Stable setup-level callbacks from the parent. */
|
|
143
|
+
onUpdate: { type: Function, required: true },
|
|
144
|
+
onResizeStart: {
|
|
145
|
+
type: Function,
|
|
146
|
+
default: void 0
|
|
147
|
+
},
|
|
148
|
+
onResizeEnd: { type: Function, default: void 0 }
|
|
149
|
+
},
|
|
150
|
+
setup(props) {
|
|
151
|
+
const handleRef = vue.ref(null);
|
|
152
|
+
let startSize = { width: 0, height: 0 };
|
|
153
|
+
let aspect = 1;
|
|
154
|
+
useDrag({
|
|
155
|
+
handle: handleRef,
|
|
156
|
+
disabled: vue.computed(() => props.disabled),
|
|
157
|
+
onStart: () => {
|
|
158
|
+
startSize = { ...props.sizeRef.value };
|
|
159
|
+
aspect = startSize.width / Math.max(1, startSize.height);
|
|
160
|
+
props.onResizeStart?.(startSize);
|
|
161
|
+
},
|
|
162
|
+
onDrag: ({ dx, dy }) => {
|
|
163
|
+
const t = props.handle.includes("top");
|
|
164
|
+
const b = props.handle.includes("bottom");
|
|
165
|
+
const l = props.handle.includes("left");
|
|
166
|
+
const r = props.handle.includes("right");
|
|
167
|
+
let nextW = startSize.width;
|
|
168
|
+
let nextH = startSize.height;
|
|
169
|
+
if (r) nextW = startSize.width + dx;
|
|
170
|
+
if (l) nextW = startSize.width - dx;
|
|
171
|
+
if (b) nextH = startSize.height + dy;
|
|
172
|
+
if (t) nextH = startSize.height - dy;
|
|
173
|
+
if (props.keepAspect && (t || b) && (l || r)) {
|
|
174
|
+
nextH = nextW / aspect;
|
|
175
|
+
}
|
|
176
|
+
nextW = Math.max(props.minWidth, Math.min(props.maxWidth, nextW));
|
|
177
|
+
nextH = Math.max(props.minHeight, Math.min(props.maxHeight, nextH));
|
|
178
|
+
props.onUpdate({ width: nextW, height: nextH });
|
|
179
|
+
},
|
|
180
|
+
onEnd: () => props.onResizeEnd?.()
|
|
181
|
+
});
|
|
182
|
+
return () => vue.h("div", {
|
|
183
|
+
ref: (el) => {
|
|
184
|
+
handleRef.value = el ?? null;
|
|
185
|
+
},
|
|
186
|
+
"data-iris-resizable-handle": props.handle,
|
|
187
|
+
style: {
|
|
188
|
+
...handlePosition(props.handle),
|
|
189
|
+
touchAction: "none",
|
|
190
|
+
background: "transparent",
|
|
191
|
+
zIndex: "1"
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
});
|
|
130
196
|
var IrisResizable = vue.defineComponent({
|
|
131
197
|
name: "IrisResizable",
|
|
132
198
|
inheritAttrs: false,
|
|
@@ -159,53 +225,8 @@ var IrisResizable = vue.defineComponent({
|
|
|
159
225
|
if (!isControlled.value) internal.value = next;
|
|
160
226
|
emit("update:size", next);
|
|
161
227
|
};
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
let startSize = { width: 0, height: 0 };
|
|
165
|
-
let aspect = 1;
|
|
166
|
-
useDrag({
|
|
167
|
-
handle: handleRef,
|
|
168
|
-
disabled: vue.computed(() => props.disabled),
|
|
169
|
-
onStart: () => {
|
|
170
|
-
startSize = { ...size.value };
|
|
171
|
-
aspect = startSize.width / Math.max(1, startSize.height);
|
|
172
|
-
emit("resizeStart", startSize);
|
|
173
|
-
},
|
|
174
|
-
onDrag: ({ dx, dy }) => {
|
|
175
|
-
const t = handle.includes("top");
|
|
176
|
-
const b = handle.includes("bottom");
|
|
177
|
-
const l = handle.includes("left");
|
|
178
|
-
const r = handle.includes("right");
|
|
179
|
-
let nextW = startSize.width;
|
|
180
|
-
let nextH = startSize.height;
|
|
181
|
-
if (r) nextW = startSize.width + dx;
|
|
182
|
-
if (l) nextW = startSize.width - dx;
|
|
183
|
-
if (b) nextH = startSize.height + dy;
|
|
184
|
-
if (t) nextH = startSize.height - dy;
|
|
185
|
-
if (props.keepAspect && (t || b) && (l || r)) {
|
|
186
|
-
nextH = nextW / aspect;
|
|
187
|
-
}
|
|
188
|
-
nextW = Math.max(props.minWidth, Math.min(props.maxWidth, nextW));
|
|
189
|
-
nextH = Math.max(props.minHeight, Math.min(props.maxHeight, nextH));
|
|
190
|
-
setSize({ width: nextW, height: nextH });
|
|
191
|
-
},
|
|
192
|
-
onEnd: () => {
|
|
193
|
-
emit("resizeEnd", size.value);
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
return vue.h("div", {
|
|
197
|
-
ref: (el) => {
|
|
198
|
-
handleRef.value = el ?? null;
|
|
199
|
-
},
|
|
200
|
-
"data-iris-resizable-handle": handle,
|
|
201
|
-
style: {
|
|
202
|
-
...handlePosition(handle),
|
|
203
|
-
touchAction: "none",
|
|
204
|
-
background: "transparent",
|
|
205
|
-
zIndex: "1"
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
};
|
|
228
|
+
const emitResizeStart = (s) => emit("resizeStart", s);
|
|
229
|
+
const emitResizeEnd = () => emit("resizeEnd", size.value);
|
|
209
230
|
return () => vue.h(
|
|
210
231
|
"div",
|
|
211
232
|
{
|
|
@@ -220,7 +241,25 @@ var IrisResizable = vue.defineComponent({
|
|
|
220
241
|
...attrs.style ?? {}
|
|
221
242
|
}
|
|
222
243
|
},
|
|
223
|
-
[
|
|
244
|
+
[
|
|
245
|
+
slots.default?.(),
|
|
246
|
+
...props.handles.map(
|
|
247
|
+
(handle) => vue.h(ResizableHandle, {
|
|
248
|
+
key: handle,
|
|
249
|
+
handle,
|
|
250
|
+
disabled: props.disabled,
|
|
251
|
+
keepAspect: props.keepAspect,
|
|
252
|
+
minWidth: props.minWidth,
|
|
253
|
+
minHeight: props.minHeight,
|
|
254
|
+
maxWidth: props.maxWidth,
|
|
255
|
+
maxHeight: props.maxHeight,
|
|
256
|
+
sizeRef: size,
|
|
257
|
+
onUpdate: setSize,
|
|
258
|
+
onResizeStart: emitResizeStart,
|
|
259
|
+
onResizeEnd: emitResizeEnd
|
|
260
|
+
})
|
|
261
|
+
)
|
|
262
|
+
]
|
|
224
263
|
);
|
|
225
264
|
}
|
|
226
265
|
});
|