@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/chunk-TQB5LVOH.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ref, onBeforeUnmount } from 'vue';
|
|
2
|
-
|
|
3
|
-
// src/machine/useMachine.ts
|
|
4
|
-
function useMachine(machine) {
|
|
5
|
-
const state = ref(machine.store.getState());
|
|
6
|
-
const unsubscribe = machine.store.subscribe((next) => {
|
|
7
|
-
state.value = next;
|
|
8
|
-
});
|
|
9
|
-
onBeforeUnmount(() => {
|
|
10
|
-
unsubscribe();
|
|
11
|
-
});
|
|
12
|
-
return { state, send: machine.send };
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export { useMachine };
|
|
16
|
-
//# sourceMappingURL=chunk-TQB5LVOH.js.map
|
|
17
|
-
//# sourceMappingURL=chunk-TQB5LVOH.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/machine/useMachine.ts"],"names":[],"mappings":";;;AAYO,SAAS,WACd,OAAA,EAIA;AACA,EAAA,MAAM,KAAA,GAAQ,GAAA,CAAI,OAAA,CAAQ,KAAA,CAAM,UAAU,CAAA;AAC1C,EAAA,MAAM,WAAA,GAAc,OAAA,CAAQ,KAAA,CAAM,SAAA,CAAU,CAAC,IAAA,KAAS;AACpD,IAAA,KAAA,CAAM,KAAA,GAAQ,IAAA;AAAA,EAChB,CAAC,CAAA;AACD,EAAA,eAAA,CAAgB,MAAM;AACpB,IAAA,WAAA,EAAY;AAAA,EACd,CAAC,CAAA;AACD,EAAA,OAAO,EAAE,KAAA,EAAO,IAAA,EAAM,OAAA,CAAQ,IAAA,EAAK;AACrC","file":"chunk-TQB5LVOH.js","sourcesContent":["import { onBeforeUnmount, ref, type Ref } from 'vue'\nimport type { Machine, MachineEvent, MachineState } from '@iris-ui-kit/core'\n\n/**\n * Bridge a framework-agnostic `Machine` into Vue reactivity.\n *\n * Returns a reactive ref of the current `{ value, context }` state and a\n * stable `send` function. Subscription is created eagerly and cleaned up on\n * unmount, so this hook is safe to call from any component's `setup()`.\n *\n * No primitive consumes this yet (Phase 0 ships the bridge for Phase 1).\n */\nexport function useMachine<TState extends string, TContext, TEvent extends MachineEvent>(\n machine: Machine<TState, TContext, TEvent>,\n): {\n state: Ref<MachineState<TState, TContext>>\n send: (event: TEvent) => void\n} {\n const state = ref(machine.store.getState()) as Ref<MachineState<TState, TContext>>\n const unsubscribe = machine.store.subscribe((next) => {\n state.value = next\n })\n onBeforeUnmount(() => {\n unsubscribe()\n })\n return { state, send: machine.send }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/provider/context.ts","../src/provider/IrisProvider.ts","../src/provider/hooks.ts"],"names":[],"mappings":";;;;;;;;AAiBO,IAAM,qBAAA,0BAAiE,iBAAiB;;;ACA/F,IAAM,cAAA,GAAiB,OAAA;AA4BhB,IAAM,eAAe,eAAA,CAAgB;AAAA,EAC1C,IAAA,EAAM,cAAA;AAAA,EACN,KAAA,EAAO;AAAA,IACL,KAAA,EAAO,EAAE,IAAA,EAAM,MAAA,EAAgC,SAAS,MAAA,EAAU;AAAA,IAClE,IAAA,EAAM,EAAE,IAAA,EAAM,MAAA,EAAgC,SAAS,MAAA,EAAU;AAAA,IACjE,GAAA,EAAK,EAAE,IAAA,EAAM,MAAA,EAAmC,SAAS,MAAA,EAAU;AAAA,IACnE,MAAA,EAAQ,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,MAAA,EAAU;AAAA,IAC3C,QAAA,EAAU,EAAE,IAAA,EAAM,MAAA,EAA4C,SAAS,MAAA,EAAU;AAAA,IACjF,OAAA,EAAS,EAAE,IAAA,EAAM,KAAA,EAAiC,SAAS,MAAA,EAAU;AAAA,IACrE,MAAA,EAAQ,EAAE,IAAA,EAAM,MAAA,EAAwC,SAAS,IAAA;AAAK,GACxE;AAAA,EACA,KAAA,CAAM,KAAA,EAAO,EAAE,KAAA,EAAM,EAAG;AAEtB,IAAA,MAAM,SAAA,GAAY,UAAA,CAAW,KAAA,CAAM,OAAA,IAAW,EAAE,CAAA;AAGhD,IAAA,IAAI,OAAA,GAAqC,IAAA;AACzC,IAAA,SAAA,CAAU,MAAM;AACd,MAAA,IAAI,OAAO,aAAa,WAAA,EAAa;AACrC,MAAA,MAAM,EAAA,GAAK,KAAA,CAAM,MAAA,IAAU,QAAA,CAAS,eAAA;AACpC,MAA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KAAA;AAEhC,IAAA,KAAA,MAAW,CAAA,IAAK,GAAA,CAAI,MAAA,CAAO,IAAA,EAAK,EAAG;AACjC,MAAA,IAAI,OAAO,MAAM,QAAA,IAAY,CAAA,CAAE,SAAS,CAAA,EAAA,EAAK,OAAO,EAAE,CAAA,EAAG;AAEvD,QAAA,IAAI,CAAC,UAAA,CAAW,GAAA,CAAI,OAAO,CAAA,EAAG;AAC5B,UAAA,UAAA,CAAW,GAAA,CAAI,SAAS,IAAI,CAAA;AAC5B,UAAA,OAAA,CAAQ,IAAA;AAAA,YACN,CAAA,sCAAA,EAAyC,OAAO,CAAA,UAAA,EACpC,CAAC,+CAA+C,CAAC,CAAA,GAAA;AAAA,WAC/D;AAAA,QACF;AACA,QAAA,OAAO,GAAA,CAAI,MAAA,CAAO,GAAA,CAAI,CAAC,CAAA;AAAA,MACzB;AAAA,IACF;AAAA,EACF;AAEA,EAAA,MAAM,IAAI,KAAA;AAAA,IACR,2BAA2B,OAAO,CAAA,mFAAA;AAAA,GAEpC;AACF","file":"chunk-W2JVHGFR.js","sourcesContent":["import { type InjectionKey } from 'vue'\n\n/**\n * Shape carried by the plugin-store context: the live store instances collected\n * from every installed plugin, plus the set of installed plugin names. Surfaced\n * to descendants through `usePluginStore` / `usePlugin`.\n */\nexport interface PluginStoreContext {\n stores: Map<string, unknown>\n installed: Set<string>\n}\n\n/**\n * Injection key for the {@link PluginStoreContext}. The name ends in `Key` (and\n * the type in `Context`) so the manifest's discover step never mistakes it for a\n * component export.\n */\nexport const PluginStoreContextKey: InjectionKey<PluginStoreContext> = Symbol('IrisPluginStore')\n","import {\n defineComponent,\n h,\n onBeforeUnmount,\n onMounted,\n provide,\n type PropType,\n type VNode,\n} from 'vue'\nimport { runPlugins, type IrisPlugin } from '@iris-ui-kit/core'\nimport { applyCssVars, type ApplyCssVarsResult, type ThemeStore } from '@iris-ui-kit/theme'\nimport type { SkinEngine } from '@iris-ui-kit/skins'\nimport { ThemeProvider } from '../theme'\nimport { SkinProvider } from '../skins'\nimport { IrisI18nProvider } from '../i18n'\nimport { PluginStoreContextKey } from './context'\n\nconst DEFAULT_LOCALE = 'en-US'\n\n/** Public prop surface of {@link IrisProvider}. */\nexport interface IrisProviderProps {\n /** Theme store; when present the inner `ThemeProvider` wraps the subtree. */\n theme?: ThemeStore\n /** Skin engine; when present the inner `SkinProvider` wraps the subtree. */\n skin?: SkinEngine\n /** Writing direction, forwarded to `ThemeProvider` when a theme is given. */\n dir?: 'ltr' | 'rtl'\n /** Active BCP-47 locale; defaults to `'en-US'`. */\n locale?: string\n /** User messages — merged OVER plugin-registered messages (user wins). */\n messages?: Record<string, string>\n /** Plugins to install; their tokens / messages / stores are collected once. */\n plugins?: IrisPlugin[]\n /** Element receiving the plugin token layer; defaults to `documentElement`. */\n target?: HTMLElement | null\n}\n\n/**\n * The single unified Iris entry point. Runs `plugins` through the core\n * `runPlugins` collector and wires the result into the theme (tokens), i18n\n * (messages) and a plugin-store context, composing the existing per-framework\n * providers. A thin bridge — the real logic lives in `@iris-ui-kit/core`.\n *\n * Render order when present: Theme → Skin → I18n → PluginContext → children.\n */\nexport const IrisProvider = defineComponent({\n name: 'IrisProvider',\n props: {\n theme: { type: Object as PropType<ThemeStore>, default: undefined },\n skin: { type: Object as PropType<SkinEngine>, default: undefined },\n dir: { type: String as PropType<'ltr' | 'rtl'>, default: undefined },\n locale: { type: String, default: undefined },\n messages: { type: Object as PropType<Record<string, string>>, default: undefined },\n plugins: { type: Array as PropType<IrisPlugin[]>, default: undefined },\n target: { type: Object as PropType<HTMLElement | null>, default: null },\n },\n setup(props, { slots }) {\n // Sync, pure, deterministic — computed once per setup over `plugins`.\n const collected = runPlugins(props.plugins ?? [])\n\n // tokens → additive CSS-var layer over the active theme; reverted on unmount.\n let applied: ApplyCssVarsResult | null = null\n onMounted(() => {\n if (typeof document === 'undefined') return\n const el = props.target ?? document.documentElement\n applied = applyCssVars(Object.entries(collected.tokens), el)\n })\n onBeforeUnmount(() => {\n applied?.revert()\n applied = null\n // Run plugin teardowns on unmount so eager stores / subscriptions /\n // timers don't leak. Idempotent and safe with no plugins.\n collected.teardown()\n })\n\n // stores + installed names → PluginStoreContext.\n provide(PluginStoreContextKey, {\n stores: collected.stores,\n installed: new Set((props.plugins ?? []).map((p) => p.name)),\n })\n\n return () => {\n const locale = props.locale ?? DEFAULT_LOCALE\n // Plugin messages as BASE, user messages WIN.\n const messages = { ...collected.messages[locale], ...(props.messages ?? {}) }\n\n // I18n always renders, wrapping children.\n let tree: VNode = h(\n IrisI18nProvider,\n { locale: props.locale, messages },\n { default: () => slots.default?.() },\n )\n // Skin wraps only when a `skin` engine is supplied.\n if (props.skin) {\n tree = h(\n SkinProvider,\n { engine: props.skin, target: props.target },\n { default: () => tree },\n )\n }\n // Theme wraps only when a `theme` store is supplied.\n if (props.theme) {\n tree = h(\n ThemeProvider,\n { store: props.theme, target: props.target, dir: props.dir ?? 'ltr' },\n { default: () => tree },\n )\n }\n return tree\n }\n },\n})\n","import { inject } from 'vue'\nimport { PluginStoreContextKey } from './context'\n\n/** Whether the named plugin is installed by the nearest `<IrisProvider>`. */\nexport function usePlugin(name: string): boolean {\n const ctx = inject(PluginStoreContextKey, null)\n return ctx ? ctx.installed.has(name) : false\n}\n\n// Tracks ambiguous store key warnings to avoid spamming the console.\nconst warnedKeys = new Map<string, boolean>()\n\n/**\n * Read a plugin-registered store by `key` (backward-compatible single-arg form).\n * Throws a clear error when used outside an `<IrisProvider>`.\n */\nexport function usePluginStore<T>(key: string): T\n\n/**\n * Read a plugin-registered store by `namespace` + `key`.\n */\nexport function usePluginStore<T>(namespace: string, key: string): T\n\nexport function usePluginStore<T>(nsOrKey: string, key?: string): T {\n const ctx = inject(PluginStoreContextKey, null)\n if (!ctx) {\n const displayKey = key !== undefined ? `${nsOrKey}::${key}` : nsOrKey\n throw new Error(`[iris-ui] usePluginStore(\"${displayKey}\"): no <IrisProvider> ancestor found`)\n }\n\n const fullKey = key !== undefined ? `${nsOrKey}::${key}` : nsOrKey\n\n // 1. Direct lookup\n let store = ctx.stores.get(fullKey) as T | undefined\n if (store !== undefined) return store\n\n // 2. Single-arg fallback\n if (key === undefined) {\n store = ctx.stores.get(nsOrKey) as T | undefined\n if (store !== undefined) return store\n\n for (const k of ctx.stores.keys()) {\n if (typeof k === 'string' && k.endsWith(`::${nsOrKey}`)) {\n // Warn at most once per ambiguous key.\n if (!warnedKeys.has(nsOrKey)) {\n warnedKeys.set(nsOrKey, true)\n console.warn(\n `[iris-ui] Ambiguous plugin store key \"${nsOrKey}\". ` +\n `Found \"${k}\". Use the namespaced form: usePluginStore(\"${k}\").`,\n )\n }\n return ctx.stores.get(k) as T\n }\n }\n }\n\n throw new Error(\n `[iris-ui] Plugin store \"${fullKey}\" not found. ` +\n `Ensure the plugin is installed in IrisProvider and the key is correct.`,\n )\n}\n"]}
|
package/dist/chunk-XSLBANUV.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { shallowRef, onBeforeUnmount } 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);
|
|
8
|
-
const state = shallowRef(controller.getState());
|
|
9
|
-
onBeforeUnmount(controller.subscribe((next) => state.value = next));
|
|
10
|
-
onBeforeUnmount(() => controller.destroy());
|
|
11
|
-
return { ...controller, state };
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { useResourceController };
|
|
15
|
-
//# sourceMappingURL=chunk-XSLBANUV.js.map
|
|
16
|
-
//# sourceMappingURL=chunk-XSLBANUV.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/resource/useResourceController.ts"],"names":[],"mappings":";;;;;AAmBO,SAAS,sBACd,MAAA,EAC0B;AAC1B,EAAA,MAAM,UAAA,GAAa,yBAAyB,MAAM,CAAA;AAClD,EAAA,MAAM,KAAA,GAAQ,UAAA,CAAW,UAAA,CAAW,QAAA,EAAU,CAAA;AAC9C,EAAA,eAAA,CAAgB,WAAW,SAAA,CAAU,CAAC,SAAU,KAAA,CAAM,KAAA,GAAQ,IAAK,CAAC,CAAA;AAGpE,EAAA,eAAA,CAAgB,MAAM,UAAA,CAAW,OAAA,EAAS,CAAA;AAC1C,EAAA,OAAO,EAAE,GAAG,UAAA,EAAY,KAAA,EAAM;AAChC","file":"chunk-XSLBANUV.js","sourcesContent":["import { onBeforeUnmount, 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 ~15-line thin bridge — all logic lives in `@iris-ui-kit/core`.\n */\nexport function useResourceController<T>(\n config: ResourceControllerConfig<T>,\n): UseResourceController<T> {\n const controller = createResourceController(config)\n const state = shallowRef(controller.getState())\n onBeforeUnmount(controller.subscribe((next) => (state.value = next)))\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 onBeforeUnmount(() => controller.destroy())\n return { ...controller, state }\n}\n"]}
|
package/dist/chunk-ZY4NLITM.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { ref, onBeforeUnmount, onMounted, computed } from 'vue';
|
|
2
|
-
import { createAsyncResource, createPaginatedResource } from '@iris-ui-kit/core';
|
|
3
|
-
|
|
4
|
-
// src/async/useAsyncResource.ts
|
|
5
|
-
function useAsyncResource(fetcher, options = {}) {
|
|
6
|
-
const config = "initialData" in options ? { initialData: options.initialData } : {};
|
|
7
|
-
const resource = createAsyncResource(fetcher, config);
|
|
8
|
-
const state = ref(resource.getState());
|
|
9
|
-
const unsubscribe = resource.subscribe((next) => {
|
|
10
|
-
state.value = next;
|
|
11
|
-
});
|
|
12
|
-
onBeforeUnmount(() => {
|
|
13
|
-
unsubscribe();
|
|
14
|
-
resource.cancel();
|
|
15
|
-
});
|
|
16
|
-
if (options.immediate) {
|
|
17
|
-
onMounted(() => {
|
|
18
|
-
void resource.load(...[]);
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
status: computed(() => state.value.status),
|
|
23
|
-
data: computed(() => state.value.data),
|
|
24
|
-
error: computed(() => state.value.error),
|
|
25
|
-
isLoading: computed(() => state.value.status === "loading"),
|
|
26
|
-
isError: computed(() => state.value.status === "error"),
|
|
27
|
-
load: resource.load,
|
|
28
|
-
reload: resource.reload,
|
|
29
|
-
mutate: resource.mutate,
|
|
30
|
-
cancel: resource.cancel,
|
|
31
|
-
reset: resource.reset
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function usePaginatedResource(fetcher, options = {}) {
|
|
35
|
-
const resource = createPaginatedResource(fetcher, {
|
|
36
|
-
pageSize: options.pageSize,
|
|
37
|
-
mode: options.mode
|
|
38
|
-
});
|
|
39
|
-
const state = ref(resource.getState());
|
|
40
|
-
const unsubscribe = resource.subscribe((next) => {
|
|
41
|
-
state.value = next;
|
|
42
|
-
});
|
|
43
|
-
onBeforeUnmount(unsubscribe);
|
|
44
|
-
if (options.immediate) {
|
|
45
|
-
onMounted(() => {
|
|
46
|
-
void (options.mode === "infinite" ? resource.loadMore() : resource.goToPage(1));
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
return {
|
|
50
|
-
status: computed(() => state.value.status),
|
|
51
|
-
items: computed(() => state.value.items),
|
|
52
|
-
page: computed(() => state.value.page),
|
|
53
|
-
pageSize: computed(() => state.value.pageSize),
|
|
54
|
-
total: computed(() => state.value.total),
|
|
55
|
-
error: computed(() => state.value.error),
|
|
56
|
-
isLoading: computed(() => state.value.status === "loading"),
|
|
57
|
-
isError: computed(() => state.value.status === "error"),
|
|
58
|
-
// Touch state so this recomputes on every store change; hasMore() then
|
|
59
|
-
// reads the resource's fresh internal batch state.
|
|
60
|
-
hasMore: computed(() => {
|
|
61
|
-
void state.value;
|
|
62
|
-
return resource.hasMore();
|
|
63
|
-
}),
|
|
64
|
-
goToPage: resource.goToPage,
|
|
65
|
-
loadMore: resource.loadMore,
|
|
66
|
-
refresh: resource.refresh,
|
|
67
|
-
setPageSize: resource.setPageSize
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export { useAsyncResource, usePaginatedResource };
|
|
72
|
-
//# sourceMappingURL=chunk-ZY4NLITM.js.map
|
|
73
|
-
//# sourceMappingURL=chunk-ZY4NLITM.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/async/useAsyncResource.ts","../src/async/usePaginatedResource.ts"],"names":["ref","onBeforeUnmount","onMounted","computed"],"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,GAAW,mBAAA,CAA0B,OAAA,EAAS,MAAM,CAAA;AAE1D,EAAA,MAAM,KAAA,GAAQ,GAAA,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,EAAA,eAAA,CAAgB,MAAM;AACpB,IAAA,WAAA,EAAY;AAIZ,IAAA,QAAA,CAAS,MAAA,EAAO;AAAA,EAClB,CAAC,CAAA;AA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B,IAAAC,UAAU,MAAM;AACd,MAAA,MAAM,OAAA,CAAQ,SAAS,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,QAAAA,CAAS,MAAM,KAAA,CAAM,MAAM,MAAM,CAAA;AAAA,IACzC,KAAA,EAAOA,QAAAA,CAAS,MAAM,KAAA,CAAM,MAAM,KAAK,CAAA;AAAA,IACvC,IAAA,EAAMA,QAAAA,CAAS,MAAM,KAAA,CAAM,MAAM,IAAI,CAAA;AAAA,IACrC,QAAA,EAAUA,QAAAA,CAAS,MAAM,KAAA,CAAM,MAAM,QAAQ,CAAA;AAAA,IAC7C,KAAA,EAAOA,QAAAA,CAAS,MAAM,KAAA,CAAM,MAAM,KAAK,CAAA;AAAA,IACvC,KAAA,EAAOA,QAAAA,CAAS,MAAM,KAAA,CAAM,MAAM,KAAK,CAAA;AAAA,IACvC,WAAWA,QAAAA,CAAS,MAAM,KAAA,CAAM,KAAA,CAAM,WAAW,SAAS,CAAA;AAAA,IAC1D,SAASA,QAAAA,CAAS,MAAM,KAAA,CAAM,KAAA,CAAM,WAAW,OAAO,CAAA;AAAA;AAAA;AAAA,IAGtD,OAAA,EAASA,SAAS,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":"chunk-ZY4NLITM.js","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"]}
|