@iris-ui-kit/vue 0.2.20 → 0.2.22
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 +36 -6
- package/dist/admin.cjs.map +1 -1
- package/dist/admin.js +4 -4
- 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/chunk-25NYWSXP.js +20 -0
- package/dist/chunk-25NYWSXP.js.map +1 -0
- package/dist/{chunk-I6D5VXQK.js → chunk-3V46HGRC.js} +4 -3
- package/dist/chunk-3V46HGRC.js.map +1 -0
- package/dist/{chunk-QLUIKEMJ.js → chunk-ENKE2BPC.js} +3 -3
- package/dist/{chunk-QLUIKEMJ.js.map → chunk-ENKE2BPC.js.map} +1 -1
- package/dist/{chunk-4FLIW67H.js → chunk-IAG64CHL.js} +21 -28
- package/dist/chunk-IAG64CHL.js.map +1 -0
- package/dist/{chunk-W2JVHGFR.js → chunk-MO7AAXA6.js} +33 -13
- package/dist/chunk-MO7AAXA6.js.map +1 -0
- package/dist/chunk-NNOF7KUH.js +24 -0
- package/dist/chunk-NNOF7KUH.js.map +1 -0
- package/dist/{chunk-MMQKSFME.js → chunk-QQ25RKOO.js} +9 -5
- 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/{chunk-H7HVVPYR.js → chunk-UPC4GN3F.js} +8 -2
- package/dist/chunk-UPC4GN3F.js.map +1 -0
- package/dist/{chunk-72PZMU6R.js → chunk-ZTPIXL7Q.js} +21 -3
- package/dist/chunk-ZTPIXL7Q.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 +166 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +38 -16
- package/dist/index.js.map +1 -1
- package/dist/layouts.cjs +2 -1
- package/dist/layouts.cjs.map +1 -1
- package/dist/layouts.js +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/provider.cjs +53 -9
- package/dist/provider.cjs.map +1 -1
- package/dist/provider.js +3 -3
- 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 +2 -1
- package/dist/skeletons.cjs.map +1 -1
- package/dist/skeletons.js +2 -2
- package/dist/skins.cjs +6 -0
- package/dist/skins.cjs.map +1 -1
- package/dist/skins.js +1 -1
- package/dist/theme.cjs +19 -1
- package/dist/theme.cjs.map +1 -1
- package/dist/theme.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-4FLIW67H.js.map +0 -1
- package/dist/chunk-72PZMU6R.js.map +0 -1
- package/dist/chunk-H7HVVPYR.js.map +0 -1
- package/dist/chunk-I6D5VXQK.js.map +0 -1
- package/dist/chunk-MMQKSFME.js.map +0 -1
- package/dist/chunk-TQB5LVOH.js +0 -17
- package/dist/chunk-TQB5LVOH.js.map +0 -1
- package/dist/chunk-W2JVHGFR.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,9 +1,9 @@
|
|
|
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
|
-
import './chunk-
|
|
6
|
-
import './chunk-
|
|
5
|
+
import './chunk-3V46HGRC.js';
|
|
6
|
+
import './chunk-ZTPIXL7Q.js';
|
|
7
7
|
import './chunk-W3B6E5GN.js';
|
|
8
8
|
import './chunk-75GSYEJS.js';
|
|
9
9
|
import './chunk-TCAXRWT6.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/usePaginatedResource.ts"],"names":["createAsyncResource","ref","onBeforeUnmount","onMounted","computed","createPaginatedResource"],"mappings":";;;;;;AAqCO,SAAS,gBAAA,CACd,OAAA,EACA,OAAA,GAAsC,EAAC,EACT;AAC9B,EAAA,MAAM,MAAA,GACJ,iBAAiB,OAAA,GAAU,EAAE,aAAa,OAAA,CAAQ,WAAA,KAAgB,EAAC;AACrE,EAAA,MAAM,QAAA,GAAWA,wBAAA,CAA0B,OAAA,EAAS,MAAM,CAAA;AAE1D,EAAA,MAAM,KAAA,GAAQC,OAAA,CAAI,QAAA,CAAS,QAAA,EAAU,CAAA;AACrC,EAAA,MAAM,WAAA,GAAc,QAAA,CAAS,SAAA,CAAU,CAAC,IAAA,KAAS;AAC/C,IAAA,KAAA,CAAM,KAAA,GAAQ,IAAA;AAAA,EAChB,CAAC,CAAA;AACD,EAAAC,mBAAA,CAAgB,MAAM;AACpB,IAAA,WAAA,EAAY;AAIZ,IAAA,QAAA,CAAS,MAAA,EAAO;AAAA,EAClB,CAAC,CAAA;AAED,EAAA,IAAI,QAAQ,SAAA,EAAW;AACrB,IAAAC,aAAA,CAAU,MAAM;AACd,MAAA,KAAK,QAAA,CAAS,IAAA,CAAK,GAAI,EAAmB,CAAA;AAAA,IAC5C,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,OAAO;AAAA,IACL,MAAA,EAAQC,YAAA,CAAS,MAAM,KAAA,CAAM,MAAM,MAAM,C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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 { 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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AAA,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
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { onMounted, onScopeDispose, shallowRef } from 'vue';
|
|
2
|
+
import { createResourceController } from '@iris-ui-kit/core';
|
|
3
|
+
export { createClientFetcher, createResourceController } from '@iris-ui-kit/core';
|
|
4
|
+
|
|
5
|
+
// src/resource/useResourceController.ts
|
|
6
|
+
function useResourceController(config) {
|
|
7
|
+
const controller = createResourceController({ ...config, immediate: false });
|
|
8
|
+
const immediate = config.immediate !== false;
|
|
9
|
+
if (immediate) {
|
|
10
|
+
onMounted(() => void controller.load());
|
|
11
|
+
}
|
|
12
|
+
onScopeDispose(() => controller.destroy());
|
|
13
|
+
const state = shallowRef(controller.getState());
|
|
14
|
+
onScopeDispose(controller.subscribe((next) => state.value = next));
|
|
15
|
+
return { ...controller, state };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { useResourceController };
|
|
19
|
+
//# sourceMappingURL=chunk-25NYWSXP.js.map
|
|
20
|
+
//# sourceMappingURL=chunk-25NYWSXP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/resource/useResourceController.ts"],"names":[],"mappings":";;;;;AA4BO,SAAS,sBACd,MAAA,EAC0B;AAC1B,EAAA,MAAM,aAAa,wBAAA,CAAyB,EAAE,GAAG,MAAA,EAAQ,SAAA,EAAW,OAAO,CAAA;AAC3E,EAAA,MAAM,SAAA,GAAY,OAAO,SAAA,KAAc,KAAA;AAEvC,EAAA,IAAI,SAAA,EAAW;AACb,IAAA,SAAA,CAAU,MAAM,KAAK,UAAA,CAAW,IAAA,EAAM,CAAA;AAAA,EACxC;AAKA,EAAA,cAAA,CAAe,MAAM,UAAA,CAAW,OAAA,EAAS,CAAA;AAEzC,EAAA,MAAM,KAAA,GAAQ,UAAA,CAAW,UAAA,CAAW,QAAA,EAAU,CAAA;AAC9C,EAAA,cAAA,CAAe,WAAW,SAAA,CAAU,CAAC,SAAU,KAAA,CAAM,KAAA,GAAQ,IAAK,CAAC,CAAA;AACnE,EAAA,OAAO,EAAE,GAAG,UAAA,EAAY,KAAA,EAAM;AAChC","file":"chunk-25NYWSXP.js","sourcesContent":["import { onMounted, onScopeDispose, shallowRef, type ShallowRef } from 'vue'\nimport {\n createResourceController,\n type ResourceController,\n type ResourceControllerConfig,\n type ResourceState,\n} from '@iris-ui-kit/core'\n\nexport interface UseResourceController<T> extends ResourceController<T> {\n /** The live resource state as a reactive ref (rows, total, page, loading, selectedKeys). */\n state: ShallowRef<ResourceState<T>>\n}\n\n/**\n * Vue bridge over the framework-agnostic {@link createResourceController} (L4\n * CRUD list composite). Creates the controller once in `setup()`, mirrors its\n * store into a `shallowRef`, and returns the controller plus that live `state`.\n * 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 request and detaching the state mirror), so a late\n * response never writes back to a torn-down instance.\n */\nexport function useResourceController<T>(\n config: ResourceControllerConfig<T>,\n): UseResourceController<T> {\n const controller = createResourceController({ ...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 scope dispose (a late response must not write back to a torn-down\n // instance). Fires on unmount inside a component scope and on `scope.stop()`\n // inside a bare effectScope.\n onScopeDispose(() => controller.destroy())\n\n const state = shallowRef(controller.getState())\n onScopeDispose(controller.subscribe((next) => (state.value = next)))\n return { ...controller, state }\n}\n"]}
|
|
@@ -27,7 +27,8 @@ var IrisSidebarLayout = defineComponent({
|
|
|
27
27
|
() => props.collapsed,
|
|
28
28
|
(value) => {
|
|
29
29
|
if (value !== void 0) internalCollapsed.value = value;
|
|
30
|
-
}
|
|
30
|
+
},
|
|
31
|
+
{ immediate: true }
|
|
31
32
|
);
|
|
32
33
|
const setCollapsed = (value) => {
|
|
33
34
|
if (!isControlled.value) internalCollapsed.value = value;
|
|
@@ -163,5 +164,5 @@ var IrisHeaderLayout = defineComponent({
|
|
|
163
164
|
});
|
|
164
165
|
|
|
165
166
|
export { IrisHeaderLayout, IrisSidebarLayout };
|
|
166
|
-
//# sourceMappingURL=chunk-
|
|
167
|
-
//# sourceMappingURL=chunk-
|
|
167
|
+
//# sourceMappingURL=chunk-3V46HGRC.js.map
|
|
168
|
+
//# sourceMappingURL=chunk-3V46HGRC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/layouts/SidebarLayout.ts","../src/layouts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,UAAU,MAAA;AAAO,WACvD;AAAA,UACA,MAAM,OAAA;AAAU,SAClB;AAAA,QACA,MAAM,MAAA,GACFA,CAAAA;AAAA,UACE,QAAA;AAAA,UACA;AAAA,YACE,IAAA,EAAM,aAAA;AAAA,YACN,kBAAA,EAAoB,EAAA;AAAA,YACpB,KAAA,EAAO;AAAA,cACL,UAAA,EAAY,GAAA;AAAA,cACZ,MAAA,EAAQ,KAAA,CAAM,KAAA,CAAM,YAAY,CAAA;AAAA,cAChC,SAAA,EAAW,8BAAA;AAAA,cACX,UAAA,EAAY;AAAA;AACd,WACF;AAAA,UACA,MAAM,MAAA;AAAO,SACf,GACA;AAAA;AACN,KACF;AAAA,EACJ;AACF,CAAC","file":"chunk-3V46HGRC.js","sourcesContent":["import { computed, defineComponent, h, ref, watch } from 'vue'\n\n/**\n * Two-column layout with a collapsible sidebar.\n *\n * Slots:\n * - `sidebar` — content rendered in the sidebar (kept mounted across collapses).\n * - `default` — the main content area.\n *\n * Use `:collapsed` for controlled mode or `:default-collapsed` for the\n * uncontrolled initial state. When collapsed, the sidebar shrinks to\n * `:collapsed-width` so icon-only navigation still fits.\n */\nexport const IrisSidebarLayout = defineComponent({\n name: 'IrisSidebarLayout',\n inheritAttrs: false,\n props: {\n collapsed: { type: Boolean, default: undefined },\n defaultCollapsed: { type: Boolean, default: false },\n /** Sidebar width when expanded (px or CSS length). */\n width: { type: [Number, String], default: 240 },\n /** Sidebar width when collapsed. */\n collapsedWidth: { type: [Number, String], default: 60 },\n /** Sidebar position. */\n side: { type: String as () => 'left' | 'right', default: 'left' },\n },\n emits: {\n 'update:collapsed': (_value: boolean) => true,\n },\n setup(props, { slots, attrs, emit }) {\n const isControlled = computed(() => props.collapsed !== undefined)\n const internalCollapsed = ref(props.defaultCollapsed)\n const collapsed = computed(() =>\n isControlled.value ? Boolean(props.collapsed) : internalCollapsed.value,\n )\n\n // Sync controlled prop changes into internal state on first run so a later\n // detach to uncontrolled mode preserves the last-known value. `immediate`\n // fires the watcher on mount; the `value !== undefined` guard keeps the\n // first run a no-op for pure-uncontrolled mounts so `defaultCollapsed`\n // stays untouched.\n watch(\n () => props.collapsed,\n (value) => {\n if (value !== undefined) internalCollapsed.value = value\n },\n { immediate: true },\n )\n\n const setCollapsed = (value: boolean) => {\n if (!isControlled.value) internalCollapsed.value = value\n emit('update:collapsed', value)\n }\n\n const asLen = (v: number | string) => (typeof v === 'number' ? `${v}px` : v)\n\n return () => {\n const sidebarStyle: Record<string, string> = {\n width: collapsed.value ? asLen(props.collapsedWidth) : asLen(props.width),\n flexShrink: '0',\n background: 'var(--iris-surface)',\n borderRight: props.side === 'left' ? '1px solid var(--iris-border)' : 'none',\n borderLeft: props.side === 'right' ? '1px solid var(--iris-border)' : 'none',\n transition: 'width 180ms ease',\n overflow: 'hidden',\n display: 'flex',\n flexDirection: 'column',\n }\n const mainStyle: Record<string, string> = {\n flex: '1',\n minWidth: '0',\n overflow: 'auto',\n background: 'var(--iris-background)',\n }\n const direction = props.side === 'right' ? 'row-reverse' : 'row'\n\n return h(\n 'div',\n {\n ...attrs,\n 'data-iris-sidebar-layout': '',\n 'data-collapsed': collapsed.value ? '' : undefined,\n 'data-side': props.side,\n style: {\n display: 'flex',\n flexDirection: direction,\n width: '100%',\n height: '100%',\n minHeight: '0',\n color: 'var(--iris-foreground)',\n ...((attrs.style as Record<string, string> | undefined) ?? {}),\n },\n },\n [\n h(\n 'aside',\n {\n role: 'complementary',\n 'data-iris-sidebar': '',\n 'data-collapsed': collapsed.value ? '' : undefined,\n style: sidebarStyle,\n },\n slots.sidebar?.({ collapsed: collapsed.value, setCollapsed }),\n ),\n h('div', { 'data-iris-sidebar-main': '', style: mainStyle }, slots.default?.()),\n ],\n )\n }\n },\n})\n","import { defineComponent, h, type PropType } from 'vue'\n\n/**\n * Two-region vertical layout: a sticky header on top, scrollable main below.\n *\n * Slots:\n * - `header` — fixed at top.\n * - `footer` — optional fixed at bottom.\n * - `default` — scrollable main region.\n */\nexport const IrisHeaderLayout = defineComponent({\n name: 'IrisHeaderLayout',\n inheritAttrs: false,\n props: {\n /** Header height (px or CSS length). Default `'auto'`. */\n headerHeight: { type: [Number, String] as PropType<number | string>, default: 'auto' },\n /** Footer height (px or CSS length). Default `'auto'`. */\n footerHeight: { type: [Number, String] as PropType<number | string>, default: 'auto' },\n /** When true, header sticks via `position: sticky` instead of static. */\n sticky: { type: Boolean, default: true },\n },\n setup(props, { slots, attrs }) {\n const asLen = (v: number | string) => (typeof v === 'number' ? `${v}px` : v)\n return () =>\n h(\n 'div',\n {\n ...attrs,\n 'data-iris-header-layout': '',\n style: {\n display: 'flex',\n flexDirection: 'column',\n width: '100%',\n height: '100%',\n minHeight: '0',\n background: 'var(--iris-background)',\n color: 'var(--iris-foreground)',\n ...((attrs.style as Record<string, string> | undefined) ?? {}),\n },\n },\n [\n slots.header\n ? h(\n 'header',\n {\n role: 'banner',\n 'data-iris-header': '',\n style: {\n flexShrink: '0',\n height: asLen(props.headerHeight),\n borderBottom: '1px solid var(--iris-border)',\n background: 'var(--iris-surface)',\n position: props.sticky ? 'sticky' : 'static',\n top: '0',\n zIndex: '50',\n },\n },\n slots.header(),\n )\n : null,\n h(\n 'main',\n {\n role: 'main',\n 'data-iris-header-main': '',\n style: { flex: '1', minHeight: '0', overflow: 'auto' },\n },\n slots.default?.(),\n ),\n slots.footer\n ? h(\n 'footer',\n {\n role: 'contentinfo',\n 'data-iris-footer': '',\n style: {\n flexShrink: '0',\n height: asLen(props.footerHeight),\n borderTop: '1px solid var(--iris-border)',\n background: 'var(--iris-surface)',\n },\n },\n slots.footer(),\n )\n : null,\n ],\n )\n },\n})\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IrisContainer, IrisStack, IrisDashboardGrid, IrisDashboardCard } from './chunk-3R3QDLJC.js';
|
|
2
2
|
import { findFirstElement, mergeSlotProps } from './chunk-F77KIPOH.js';
|
|
3
|
-
import { IrisSidebarLayout, IrisHeaderLayout } from './chunk-
|
|
3
|
+
import { IrisSidebarLayout, IrisHeaderLayout } from './chunk-3V46HGRC.js';
|
|
4
4
|
import { useI18n } from './chunk-TCAXRWT6.js';
|
|
5
5
|
import { defineComponent, ref, computed, h, useId, cloneVNode, Fragment, watch } from 'vue';
|
|
6
6
|
|
|
@@ -1193,5 +1193,5 @@ var IrisDashboardTemplate = defineComponent({
|
|
|
1193
1193
|
});
|
|
1194
1194
|
|
|
1195
1195
|
export { IrisAlert, IrisButton, IrisCheckbox, IrisDashboardTemplate, IrisDivider, IrisFormField, IrisInput, IrisLoginTemplate, IrisPasswordInput };
|
|
1196
|
-
//# sourceMappingURL=chunk-
|
|
1197
|
-
//# sourceMappingURL=chunk-
|
|
1196
|
+
//# sourceMappingURL=chunk-ENKE2BPC.js.map
|
|
1197
|
+
//# sourceMappingURL=chunk-ENKE2BPC.js.map
|