@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/async/useAsyncResource.ts","../src/async/usePaginatedResource.ts"],"names":["isRef","watch","ref","onBeforeUnmount","onMounted","computed"],"mappings":";;;;AA2DO,SAAS,gBAAA,CACd,OAAA,EACA,OAAA,GAAsC,EAAC,EACT;AAK9B,EAAA,MAAM,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QAAA,CAAS;AAAA,GACxB;AACF","file":"chunk-SJB5DIIY.js","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"]}
|
|
@@ -30,6 +30,12 @@ var SkinProvider = defineComponent({
|
|
|
30
30
|
watch(current, () => {
|
|
31
31
|
if (applied) apply();
|
|
32
32
|
});
|
|
33
|
+
watch(
|
|
34
|
+
() => props.target,
|
|
35
|
+
() => {
|
|
36
|
+
if (applied) apply();
|
|
37
|
+
}
|
|
38
|
+
);
|
|
33
39
|
onBeforeUnmount(() => {
|
|
34
40
|
unsubscribe();
|
|
35
41
|
applied?.revert();
|
|
@@ -62,5 +68,5 @@ function useSkin() {
|
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
export { IrisSkinKey, SkinProvider, useSkin, useSkinContext };
|
|
65
|
-
//# sourceMappingURL=chunk-
|
|
66
|
-
//# sourceMappingURL=chunk-
|
|
71
|
+
//# sourceMappingURL=chunk-UPC4GN3F.js.map
|
|
72
|
+
//# sourceMappingURL=chunk-UPC4GN3F.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/skins/SkinProvider.ts","../src/skins/useSkin.ts"],"names":[],"mappings":";;;;;;AAyBO,IAAM,WAAA,0BAAoD,UAAU;AAOpE,IAAM,eAAe,eAAA,CAAgB;AAAA,EAC1C,IAAA,EAAM,kBAAA;AAAA,EACN,KAAA,EAAO;AAAA,IACL,MAAA,EAAQ,EAAE,IAAA,EAAM,MAAA,EAAgC,UAAU,IAAA,EAAK;AAAA,IAC/D,MAAA,EAAQ,EAAE,IAAA,EAAM,MAAA,EAAwC,SAAS,IAAA,EAAK;AAAA,IACtE,QAAA,EAAU,EAAE,IAAA,EAAM,M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,EAC/B;AACF,CAAC;AAEM,SAAS,cAAA,GAAkC;AAChD,EAAA,MAAM,GAAA,GAAM,OAAO,WAAW,CAAA;AAC9B,EAAA,IAAI,CAAC,GAAA,EAAK,MAAM,IAAI,MAAM,uDAAuD,CAAA;AACjF,EAAA,OAAO,GAAA;AACT;AC3DO,SAAS,OAAA,GAAyB;AACvC,EAAA,MAAM,EAAE,MAAA,EAAQ,OAAA,EAAQ,GAAI,cAAA,EAAe;AAC3C,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,QAAA,CAAS,MAAM,OAAA,CAAQ,KAAK,CAAA;AAAA,IAClC,SAAS,MAAA,CAAO,OAAA;AAAA,IAChB,UAAU,MAAA,CAAO,QAAA;AAAA,IACjB,gBAAgB,MAAA,CAAO,cAAA;AAAA,IACvB,OAAO,MAAA,CAAO,KAAA;AAAA,IACd,YAAY,MAAA,CAAO,UAAA;AAAA,IACnB,SAAS,MAAA,CAAO,OAAA;AAAA,IAChB,SAAS,MAAA,CAAO,OAAA;AAAA,IAChB,aAAa,MAAA,CAAO,WAAA;AAAA,IACpB,gBAAgB,MAAA,CAAO,cAAA;AAAA,IACvB,QAAQ,MAAA,CAAO;AAAA,GACjB;AACF","file":"chunk-UPC4GN3F.js","sourcesContent":["import {\n defineComponent,\n inject,\n onBeforeUnmount,\n onMounted,\n provide,\n ref,\n watch,\n type InjectionKey,\n type PropType,\n type Ref,\n} from 'vue'\nimport { injectGlobalStyles } from '@iris-ui-kit/theme'\nimport {\n applySkin,\n type ApplySkinResult,\n type ResolvedSkin,\n type SkinEngine,\n} from '@iris-ui-kit/skins'\n\nexport interface IrisSkinContext {\n engine: SkinEngine\n current: Ref<ResolvedSkin>\n}\n\nexport const IrisSkinKey: InjectionKey<IrisSkinContext> = Symbol('IrisSkin')\n\n/**\n * Renderless provider mirroring `<IrisThemeProvider>` for skins: subscribes to\n * the engine store, applies/reverts the resolved skin on the target element,\n * and provides the engine + current skin to descendants. Zero skin logic.\n */\nexport const SkinProvider = defineComponent({\n name: 'IrisSkinProvider',\n props: {\n engine: { type: Object as PropType<SkinEngine>, required: true },\n target: { type: Object as PropType<HTMLElement | null>, default: null },\n cspNonce: { type: String, default: undefined },\n },\n setup(props, { slots }) {\n const current = ref(props.engine.current()) as Ref<ResolvedSkin>\n const unsubscribe = props.engine.subscribe((next) => {\n current.value = next\n })\n\n let applied: ApplySkinResult | null = null\n const targetEl = () => props.target ?? document.documentElement\n const apply = () => {\n applied?.revert()\n applied = applySkin(current.value, targetEl())\n }\n\n onMounted(() => {\n injectGlobalStyles(props.cspNonce)\n apply()\n })\n watch(current, () => {\n if (applied) apply()\n })\n watch(\n () => props.target,\n () => {\n if (applied) apply()\n },\n )\n onBeforeUnmount(() => {\n unsubscribe()\n applied?.revert()\n applied = null\n })\n\n provide(IrisSkinKey, { engine: props.engine, current })\n return () => slots.default?.()\n },\n})\n\nexport function useSkinContext(): IrisSkinContext {\n const ctx = inject(IrisSkinKey)\n if (!ctx) throw new Error('[iris-ui] useSkin(): no <SkinProvider> ancestor found')\n return ctx\n}\n","import type { ComputedRef } from 'vue'\nimport { computed } from 'vue'\nimport type { ResolvedSkin, Skin, SkinMode, SkinPatch, SkinError } from '@iris-ui-kit/skins'\nimport { useSkinContext } from './SkinProvider'\n\nexport interface UseSkinReturn {\n skin: ComputedRef<ResolvedSkin>\n setSkin: (id: string) => void\n loadSkin: (source: string | Skin) => Promise<ResolvedSkin>\n useFromCatalog: (id: string) => Promise<ResolvedSkin>\n patch: (overrides: SkinPatch) => void\n resetPatch: () => void\n setMode: (mode: SkinMode) => void\n getMode: () => SkinMode\n /** Logical selected id (pre system-variant remap) — e.g. 'auto' while following the system. */\n getActiveId: () => string\n availableSkins: () => Skin[]\n errors: () => SkinError[]\n}\n\n/** Read + control the active skin from anywhere inside a `<SkinProvider>`. */\nexport function useSkin(): UseSkinReturn {\n const { engine, current } = useSkinContext()\n return {\n skin: computed(() => current.value),\n setSkin: engine.setSkin,\n loadSkin: engine.loadSkin,\n useFromCatalog: engine.useFromCatalog,\n patch: engine.patch,\n resetPatch: engine.resetPatch,\n setMode: engine.setMode,\n getMode: engine.getMode,\n getActiveId: engine.getActiveId,\n availableSkins: engine.availableSkins,\n errors: engine.errors,\n }\n}\n"]}
|
|
@@ -27,7 +27,7 @@ var ThemeProvider = defineComponent({
|
|
|
27
27
|
},
|
|
28
28
|
setup(props, { slots }) {
|
|
29
29
|
const current = ref(props.store.store.getState());
|
|
30
|
-
|
|
30
|
+
let unsubscribe = props.store.store.subscribe((next) => {
|
|
31
31
|
current.value = next;
|
|
32
32
|
});
|
|
33
33
|
let applied = null;
|
|
@@ -49,6 +49,24 @@ var ThemeProvider = defineComponent({
|
|
|
49
49
|
watch(current, () => {
|
|
50
50
|
if (applied) applyCurrent();
|
|
51
51
|
});
|
|
52
|
+
watch(
|
|
53
|
+
() => props.store,
|
|
54
|
+
(nextStore) => {
|
|
55
|
+
unsubscribe();
|
|
56
|
+
unsubscribe = nextStore.store.subscribe((next) => {
|
|
57
|
+
current.value = next;
|
|
58
|
+
});
|
|
59
|
+
current.value = nextStore.store.getState();
|
|
60
|
+
if (applied) applyCurrent();
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
watch(
|
|
64
|
+
() => props.target,
|
|
65
|
+
() => {
|
|
66
|
+
if (applied) applyCurrent();
|
|
67
|
+
if (dirApplied) applyDir();
|
|
68
|
+
}
|
|
69
|
+
);
|
|
52
70
|
watch(
|
|
53
71
|
() => props.dir,
|
|
54
72
|
() => {
|
|
@@ -95,5 +113,5 @@ function useColorScheme() {
|
|
|
95
113
|
}
|
|
96
114
|
|
|
97
115
|
export { IrisThemeKey, ThemeProvider, useColorScheme, useDirection, useTheme, useThemeContext };
|
|
98
|
-
//# sourceMappingURL=chunk-
|
|
99
|
-
//# sourceMappingURL=chunk-
|
|
116
|
+
//# sourceMappingURL=chunk-ZTPIXL7Q.js.map
|
|
117
|
+
//# sourceMappingURL=chunk-ZTPIXL7Q.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/theme/ThemeProvider.ts","../src/theme/useTheme.ts","../src/theme/useColorScheme.ts"],"names":["computed","ref","onBeforeUnmount"],"mappings":";;;;AA+BO,IAAM,YAAA,0BAAsD,WAAW;AAWvE,IAAM,gBAAgB,eAAA,CAAgB;AAAA,EAC3C,IAAA,EAAM,mBAAA;AAAA,EACN,KAAA,EAAO;AAAA,IACL,KAAA,EAAO;AAAA,MACL,IAAA,EAAM,MAAA;AAAA,MACN,QAAA,EAAU;AAAA,KACZ;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,IAAA,EAAM,MAAA;AAAA,MACN,OAAA,EAAS;AAAA,KACX;AAAA;AAAA,IAEA,GAAA,EAAK;AAAA,MACH,IAAA,EAAM,MAAA;AAAA,MACN,OAAA,EAAS;AAAA,KACX;AAAA;AAAA,IAEA,QAAA,EAAU;AAAA,MACR,IAAA,EAAM,MAAA;AAAA,MACN,OAAA,EAAS;AAAA;AACX,GACF;AAAA,EACA,KAAA,CAAM,KAAA,EAAO,EAAE,KAAA,EAAM,EAAG;AACtB,IAAA,MAAM,UAAU,GAAA,CAAI,KAAA,CAAM,KAAA,CAAM,KAAA,CAAM,UAAU,CAAA;AAChD,IAAA,IAAI,cAAc,KAAA,CAAM,KAAA,CAAM,KAAA,CAAM,SAAA,CAAU,CAAC,IAAA,KAAS;AACtD,MAAA,OAAA,CAAQ,KAAA,GAAQ,IAAA;AAAA,IAClB,CAAC,CAAA;AAED,IAAA,IAAI,OAAA,GAAmC,IAAA;AACvC,IAAA,IAAI,UAAA,GAA0C,IAAA;AAE9C,IAAA,MAAM,QAAA,GAAW,MAAM,KAAA,CAAM,MAAA,IAAU,QAAA,CAAS,eAAA;AAEhD,IAAA,MAAM,eAAe,MAAM;AACzB,MAAA,OAAA,EAAS,MAAA,EAAO;AAChB,MAAA,OAAA,GAAU,UAAA,CAAW,OAAA,CAAQ,KAAA,EAAO,QAAA,EAAU,CAAA;AAAA,IAChD,C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XL7Q.js","sourcesContent":["import {\n computed,\n defineComponent,\n inject,\n onBeforeUnmount,\n onMounted,\n provide,\n ref,\n watch,\n type ComputedRef,\n type InjectionKey,\n type PropType,\n type Ref,\n} from 'vue'\nimport {\n applyDirection,\n applyTheme,\n injectGlobalStyles,\n type ApplyDirectionResult,\n type ApplyThemeResult,\n type Direction,\n type ThemeStore,\n} from '@iris-ui-kit/theme'\nimport type { IrisTheme } from '@iris-ui-kit/tokens'\n\nexport interface IrisThemeContext {\n store: ThemeStore\n current: Ref<IrisTheme>\n dir: ComputedRef<Direction>\n}\n\nexport const IrisThemeKey: InjectionKey<IrisThemeContext> = Symbol('IrisTheme')\n\n/**\n * Renderless provider that:\n * 1. exposes the theme store to descendants via `provide`,\n * 2. applies the current theme to a target element on mount and on change,\n * 3. reverts the inline custom properties on unmount.\n *\n * `target` defaults to `document.documentElement`. Pass an element ref to\n * scope a theme to a subtree.\n */\nexport const ThemeProvider = defineComponent({\n name: 'IrisThemeProvider',\n props: {\n store: {\n type: Object as PropType<ThemeStore>,\n required: true,\n },\n target: {\n type: Object as PropType<HTMLElement | null>,\n default: null,\n },\n /** Writing direction; sets `dir` on the target for RTL. Default `'ltr'`. */\n dir: {\n type: String as PropType<Direction>,\n default: 'ltr',\n },\n /** CSP nonce for injected inline stylesheets. */\n cspNonce: {\n type: String,\n default: undefined,\n },\n },\n setup(props, { slots }) {\n const current = ref(props.store.store.getState()) as Ref<IrisTheme>\n let unsubscribe = props.store.store.subscribe((next) => {\n current.value = next\n })\n\n let applied: ApplyThemeResult | null = null\n let dirApplied: ApplyDirectionResult | null = null\n\n const targetEl = () => props.target ?? document.documentElement\n\n const applyCurrent = () => {\n applied?.revert()\n applied = applyTheme(current.value, targetEl())\n }\n\n const applyDir = () => {\n dirApplied?.revert()\n dirApplied = applyDirection(props.dir, targetEl())\n }\n\n onMounted(() => {\n injectGlobalStyles(props.cspNonce)\n applyCurrent()\n applyDir()\n })\n\n watch(current, () => {\n if (applied) applyCurrent()\n })\n\n watch(\n () => props.store,\n (nextStore) => {\n unsubscribe()\n unsubscribe = nextStore.store.subscribe((next) => {\n current.value = next\n })\n current.value = nextStore.store.getState()\n if (applied) applyCurrent()\n },\n )\n\n watch(\n () => props.target,\n () => {\n if (applied) applyCurrent()\n if (dirApplied) applyDir()\n },\n )\n\n watch(\n () => props.dir,\n () => {\n if (dirApplied) applyDir()\n },\n )\n\n onBeforeUnmount(() => {\n unsubscribe()\n applied?.revert()\n applied = null\n dirApplied?.revert()\n dirApplied = null\n })\n\n provide(IrisThemeKey, { store: props.store, current, dir: computed(() => props.dir) })\n\n return () => slots.default?.()\n },\n})\n\nexport function useThemeContext(): IrisThemeContext {\n const ctx = inject(IrisThemeKey)\n if (!ctx) {\n throw new Error('[iris-ui] useTheme(): no <ThemeProvider> ancestor found')\n }\n return ctx\n}\n\n/**\n * Current writing direction (`'ltr'` / `'rtl'`) from the nearest\n * `<ThemeProvider>`, or a static `'ltr'` ref when there is none.\n */\nexport function useDirection(): ComputedRef<Direction> {\n const ctx = inject(IrisThemeKey, null)\n return ctx ? ctx.dir : computed(() => 'ltr' as Direction)\n}\n","import { computed, type ComputedRef } from 'vue'\nimport type { IrisTheme } from '@iris-ui-kit/tokens'\nimport { useThemeContext } from './ThemeProvider'\n\nexport interface UseThemeReturn {\n /** Reactive ref to the active theme. */\n theme: ComputedRef<IrisTheme>\n /** Switch by name or by passing a theme directly. */\n setTheme: (target: string | IrisTheme) => void\n /** Map of all themes registered with the store. */\n availableThemes: Record<string, IrisTheme>\n}\n\n/**\n * Read and write the current theme from anywhere inside a <ThemeProvider>.\n *\n * @example\n * const { theme, setTheme } = useTheme()\n * theme.value.colors['iris.primary']\n * setTheme('dark')\n */\nexport function useTheme(): UseThemeReturn {\n const ctx = useThemeContext()\n return {\n theme: computed(() => ctx.current.value),\n setTheme: ctx.store.setTheme,\n availableThemes: ctx.store.availableThemes,\n }\n}\n","import { onBeforeUnmount, ref, type Ref } from 'vue'\nimport { getColorScheme, watchColorScheme, type ColorScheme } from '@iris-ui-kit/theme'\n\n/**\n * Reactive system color scheme (`'light'` / `'dark'`) from\n * `prefers-color-scheme`. SSR-safe (reports `'light'` until matchMedia is\n * available). Wire it to a theme store to auto-follow the system:\n *\n * ```ts\n * const scheme = useColorScheme()\n * watch(scheme, (s) => store.setTheme(s === 'dark' ? 'dark' : 'light'), { immediate: true })\n * ```\n */\nexport function useColorScheme(): Ref<ColorScheme> {\n const scheme = ref<ColorScheme>(getColorScheme())\n const stop = watchColorScheme((s) => {\n scheme.value = s\n })\n onBeforeUnmount(stop)\n return scheme\n}\n"]}
|
package/dist/form.cjs
CHANGED
|
@@ -59,13 +59,21 @@ var IrisForm = vue.defineComponent({
|
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
|
+
function useStore(store) {
|
|
63
|
+
const state = vue.shallowRef(store.getState());
|
|
64
|
+
vue.onScopeDispose(store.subscribe((next) => state.value = next));
|
|
65
|
+
return state;
|
|
66
|
+
}
|
|
67
|
+
function useStoreSelector(store, selector, equals) {
|
|
68
|
+
const slice = vue.shallowRef(selector(store.getState()));
|
|
69
|
+
vue.onScopeDispose(store.subscribeWith(selector, (v) => slice.value = v, equals));
|
|
70
|
+
return slice;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/form/useForm.ts
|
|
62
74
|
function useForm(config) {
|
|
63
75
|
const form = core.createFormStore(config);
|
|
64
|
-
const state =
|
|
65
|
-
const unsubscribe = form.subscribe((next) => {
|
|
66
|
-
state.value = next;
|
|
67
|
-
});
|
|
68
|
-
vue.onBeforeUnmount(unsubscribe);
|
|
76
|
+
const state = useStore(form.store);
|
|
69
77
|
return {
|
|
70
78
|
form,
|
|
71
79
|
state,
|
|
@@ -90,22 +98,24 @@ function useForm(config) {
|
|
|
90
98
|
}
|
|
91
99
|
function useField(name) {
|
|
92
100
|
const form = useFormContext();
|
|
93
|
-
const state = vue.ref(form.getState());
|
|
94
|
-
const unsubscribe = form.subscribe((next) => {
|
|
95
|
-
state.value = next;
|
|
96
|
-
});
|
|
97
|
-
vue.onBeforeUnmount(unsubscribe);
|
|
98
101
|
const key = core.formatPath(name);
|
|
99
|
-
const
|
|
100
|
-
const
|
|
102
|
+
const segments = core.parsePath(name);
|
|
103
|
+
const valueSlice = useStoreSelector(form.store, (s) => core.getByPath(s.values, segments));
|
|
104
|
+
const errorSlice = useStoreSelector(form.store, (s) => s.errors[key]);
|
|
105
|
+
const touchedSlice = useStoreSelector(form.store, (s) => Boolean(s.touched[key]));
|
|
106
|
+
const dirtySlice = useStoreSelector(form.store, (s) => Boolean(s.dirty[key]));
|
|
107
|
+
const value = vue.computed(() => valueSlice.value);
|
|
108
|
+
const error = vue.computed(() => errorSlice.value);
|
|
109
|
+
const touched = vue.computed(() => touchedSlice.value);
|
|
110
|
+
const dirty = vue.computed(() => dirtySlice.value);
|
|
101
111
|
return {
|
|
102
112
|
name,
|
|
103
113
|
value,
|
|
104
114
|
error,
|
|
105
|
-
touched
|
|
106
|
-
dirty
|
|
115
|
+
touched,
|
|
116
|
+
dirty,
|
|
107
117
|
setValue: (next) => form.setFieldValue(name, next),
|
|
108
|
-
setTouched: (
|
|
118
|
+
setTouched: (touched2 = true) => form.setFieldTouched(name, touched2),
|
|
109
119
|
fieldProps: vue.computed(() => ({
|
|
110
120
|
modelValue: value.value,
|
|
111
121
|
"onUpdate:modelValue": (next) => form.setFieldValue(name, next),
|
|
@@ -116,16 +126,11 @@ function useField(name) {
|
|
|
116
126
|
}
|
|
117
127
|
function useFieldArray(name) {
|
|
118
128
|
const form = useFormContext();
|
|
119
|
-
const
|
|
120
|
-
const
|
|
121
|
-
state.value = next;
|
|
122
|
-
});
|
|
123
|
-
vue.onBeforeUnmount(unsubscribe);
|
|
129
|
+
const raw = useStoreSelector(form.store, (s) => s.values[name]);
|
|
130
|
+
const fields = vue.computed(() => Array.isArray(raw.value) ? raw.value : []);
|
|
124
131
|
return {
|
|
125
132
|
name,
|
|
126
|
-
fields
|
|
127
|
-
() => Array.isArray(state.value.values[name]) ? state.value.values[name] : []
|
|
128
|
-
),
|
|
133
|
+
fields,
|
|
129
134
|
push: (item) => form.arrayPush(name, item),
|
|
130
135
|
remove: (index) => form.arrayRemove(name, index),
|
|
131
136
|
insert: (index, item) => form.arrayInsert(name, index, item),
|
package/dist/form.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/form/context.ts","../src/form/Form.ts","../src/form/useForm.ts","../src/form/useField.ts","../src/form/useFieldArray.ts"],"names":["inject","defineComponent","provide","ref","h","createFormStore","onBeforeUnmount","computed","formatPath","getByPath"],"mappings":";;;;;;AAQO,IAAM,gBAAA,0BAA+D,UAAU;AAE/E,SAAS,cAAA,GAAwC;AACtD,EAAA,MAAM,IAAA,GAAOA,UAAA,CAAO,gBAAA,EAAkB,IAAI,CAAA;AAC1C,EAAA,IAAI,CAAC,IAAA,EAAM;AACT,IAAA,MAAM,IAAI,MAAM,6DAA6D,CAAA;AAAA,EAC/E;AACA,EAAA,OAAO,IAAA;AACT;;;ACXA,SAAS,eAAA,CACP,QACA,MAAA,EACM;AACN,EAAA,IAAI,CAAC,MAAA,EAAQ;AACb,EAAA,MAAM,IAAA,GAAO,MAAA,CAAO,IAAA,CAAK,MAAM,CAAA;AAC/B,EAAA,IAAI,IAAA,CAAK,WAAW,CAAA,EAAG;AACvB,EAAA,MAAM,WAAW,MAAA,CAAO,gBAAA;AAAA,IACtB;AAAA,GACF;AACA,EAAA,KAAA,MAAW,EAAA,IAAM,KAAA,CAAM,IAAA,CAAK,QAAQ,CAAA,EAAG;AACrC,IAAA,MAAM,OAAO,EAAA,CAAG,YAAA,CAAa,MAAM,CAAA,IAAK,EAAA,CAAG,aAAa,iBAAiB,CAAA;AACzE,IAAA,IAAI,IAAA,IAAQ,IAAA,CAAK,QAAA,CAAS,IAAI,CAAA,EAAG;AAC/B,MAAA,EAAA,CAAG,KAAA,EAAM;AACT,MAAA,IAAI;AACF,QAAA,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AAM,OAAO,cAAA,EAAe;AAC5B,EAAA,MAAM,KAAA,GAAQJ,OAAAA,CAAI,IAAA,CAAK,QAAA,EAAU,CAAA;AACjC,EAAA,MAAM,WAAA,GAAc,IAAA,CAAK,SAAA,CAAU,CAAC,IAAA,KAAS;AAC3C,IAAA,KAAA,CAAM,KAAA,GAAQ,IAAA;AAAA,EAChB,CAAC,CAAA;AACD,EAAAG,oBAAgB,WAAW,CAAA;AAE3B,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,MAAA,EAAQC,YAAAA;AAAA,MACN,MAAO,KAAA,CAAM,OAAA,CAAQ,KAAA,CAAM,MAAM,MAAA,CAAO,IAAI,CAAC,CAAA,GAAI,KAAA,CAAM,KAAA,CAAM,MAAA,CAAO,IAAI,IAAI;AAAC,KAC/E;AAAA,IACA,MAAM,CAAC,IAAA,KAAS,IAAA,CAAK,SAAA,CAAU,MAAe,IAAa,CAAA;AAAA,IAC3D,QAAQ,CAAC,KAAA,KAAU,IAAA,CAAK,WAAA,CAAY,MAAe,KAAK,CAAA;AAAA,IACxD,MAAA,EAAQ,CAAC,KAAA,EAAO,IAAA,KAAS,KAAK,WAAA,CAAY,IAAA,EAAe,OAAO,IAAa,CAAA;AAAA,IAC7E,IAAA,EAAM,CAAC,IAAA,EAAM,EAAA,KAAO,KAAK,SAAA,CAAU,IAAA,EAAe,MAAM,EAAE,CAAA;AAAA,IAC1D,SAAS,CAAC,KAAA,KAAU,IAAA,CAAK,aAAA,CAAc,MAAM,KAAc;AAAA,GAC7D;AACF","file":"form.cjs","sourcesContent":["import { inject, type InjectionKey } from 'vue'\nimport type { FormStore, FormValues } from '@iris-ui-kit/core'\n\n/**\n * Provides the active form's {@link FormStore} to descendant fields so\n * `useField` can bind without prop drilling. The generic is erased at the\n * injection boundary; `useField<T>` re-applies the value type at the call site.\n */\nexport const FormInjectionKey: InjectionKey<FormStore<FormValues>> = Symbol('IrisForm')\n\nexport function useFormContext(): FormStore<FormValues> {\n const form = inject(FormInjectionKey, null)\n if (!form) {\n throw new Error('useField / useFormContext must be used within an <IrisForm>')\n }\n return form\n}\n","import { defineComponent, h, provide, ref, type PropType } from 'vue'\nimport type { FormStore, FormValues } from '@iris-ui-kit/core'\nimport { FormInjectionKey } from './context'\n\n/** Focus (and best-effort scroll to) the first errored named control in DOM order. */\nfunction focusFirstError(\n formEl: HTMLElement | null,\n errors: Record<string, string | undefined>,\n): void {\n if (!formEl) return\n const keys = Object.keys(errors)\n if (keys.length === 0) return\n const controls = formEl.querySelectorAll<HTMLElement>(\n 'input[name], select[name], textarea[name], [data-iris-field]',\n )\n for (const el of Array.from(controls)) {\n const name = el.getAttribute('name') ?? el.getAttribute('data-iris-field')\n if (name && keys.includes(name)) {\n el.focus()\n try {\n el.scrollIntoView({ block: 'center' })\n } catch {\n /* scrollIntoView is unavailable in jsdom — focus is the contract */\n }\n return\n }\n }\n}\n\n/**\n * Provides the form store to descendant `useField` calls and wires the native\n * `<form>` submit to `handleSubmit` (with `preventDefault`). Composition:\n *\n * ```html\n * <IrisForm :form=\"f.form\">\n * <IrisFormField label=\"Email\"><IrisInput v-bind=\"email.fieldProps.value\" /></IrisFormField>\n * <IrisButton type=\"submit\" :disabled=\"f.isSubmitting.value\">Save</IrisButton>\n * </IrisForm>\n * ```\n */\nexport const IrisForm = defineComponent({\n name: 'IrisForm',\n props: {\n /** The store from `useForm(...).form`. */\n form: {\n type: Object as PropType<FormStore<FormValues>>,\n required: true,\n },\n },\n setup(props, { slots }) {\n provide(FormInjectionKey, props.form)\n const formRef = ref<HTMLElement | null>(null)\n return () =>\n h(\n 'form',\n {\n ref: formRef,\n 'data-iris-form': '',\n onSubmit: (event: Event) => {\n event.preventDefault()\n // On a failed submit, move focus to the first errored field (a11y).\n void props.form\n .handleSubmit()\n .then(() => focusFirstError(formRef.value, props.form.getState().errors))\n },\n },\n slots.default?.(),\n )\n },\n})\n","import { computed, onBeforeUnmount, ref, type ComputedRef, type Ref } from 'vue'\nimport {\n createFormStore,\n type FieldErrors,\n type FieldFlags,\n type FormConfig,\n type FormState,\n type FormStore,\n type FormValues,\n} from '@iris-ui-kit/core'\n\nexport interface UseFormReturn<V extends FormValues> {\n /** The form store — pass to `<IrisForm :form=\"...\">`. */\n form: FormStore<V>\n /** The full reactive state snapshot. */\n state: Ref<FormState<V>>\n values: ComputedRef<V>\n errors: ComputedRef<FieldErrors<V>>\n touched: ComputedRef<FieldFlags<V>>\n dirty: ComputedRef<FieldFlags<V>>\n isSubmitting: ComputedRef<boolean>\n isValidating: ComputedRef<boolean>\n submitCount: ComputedRef<number>\n isValid: ComputedRef<boolean>\n setFieldValue: FormStore<V>['setFieldValue']\n setValues: FormStore<V>['setValues']\n setFieldTouched: FormStore<V>['setFieldTouched']\n setFieldError: FormStore<V>['setFieldError']\n setErrors: FormStore<V>['setErrors']\n validateField: FormStore<V>['validateField']\n validateForm: FormStore<V>['validateForm']\n handleSubmit: FormStore<V>['handleSubmit']\n reset: FormStore<V>['reset']\n}\n\n/**\n * Vue binding for the framework-agnostic form engine. Creates the store in\n * `setup()` (runs once) and bridges it into Vue reactivity via a `ref` updated\n * on each store change, cleaned up on unmount. Because `setup` runs once,\n * `onSubmit` / `validate` closures stay live against reactive state — no\n * stale-callback handling is needed (unlike the React adapter).\n */\nexport function useForm<V extends FormValues>(config: FormConfig<V>): UseFormReturn<V> {\n const form = createFormStore(config)\n const state = ref(form.getState()) as Ref<FormState<V>>\n const unsubscribe = form.subscribe((next) => {\n state.value = next\n })\n onBeforeUnmount(unsubscribe)\n\n return {\n form,\n state,\n values: computed(() => state.value.values),\n errors: computed(() => state.value.errors),\n touched: computed(() => state.value.touched),\n dirty: computed(() => state.value.dirty),\n isSubmitting: computed(() => state.value.isSubmitting),\n isValidating: computed(() => state.value.isValidating),\n submitCount: computed(() => state.value.submitCount),\n isValid: computed(() => Object.keys(state.value.errors).length === 0),\n setFieldValue: form.setFieldValue,\n setValues: form.setValues,\n setFieldTouched: form.setFieldTouched,\n setFieldError: form.setFieldError,\n setErrors: form.setErrors,\n validateField: form.validateField,\n validateForm: form.validateForm,\n handleSubmit: form.handleSubmit,\n reset: form.reset,\n }\n}\n","import { computed, onBeforeUnmount, ref, type ComputedRef, type Ref } from 'vue'\nimport { formatPath, getByPath, type FormState, type FormValues } from '@iris-ui-kit/core'\nimport { useFormContext } from './context'\n\nexport interface FieldBindProps {\n modelValue: unknown\n 'onUpdate:modelValue': (value: unknown) => void\n invalid: boolean\n onBlur: () => void\n}\n\nexport interface UseFieldReturn<T> {\n name: string\n value: ComputedRef<T>\n error: ComputedRef<string | undefined>\n touched: ComputedRef<boolean>\n dirty: ComputedRef<boolean>\n setValue: (value: T) => void\n setTouched: (touched?: boolean) => void\n /**\n * Bundle for `v-bind` onto a v-model'd Iris control (`IrisInput`,\n * `IrisSelect`, …): wires `modelValue` / `update:modelValue` / `invalid` /\n * `blur`. Use `value` + `setValue` directly for bespoke bindings.\n */\n fieldProps: ComputedRef<FieldBindProps>\n}\n\n/**\n * Binds a single field to the surrounding `<IrisForm>`. `T` is the value type\n * at the call site (the injection erases the form's generic).\n *\n * `name` may be a flat top-level key OR a nested PATH (`'address.city'`,\n * `'items[2].sku'`); a flat key is a 1-segment path and stays back-compatible\n * (v3 R19).\n */\nexport function useField<T = unknown>(name: string): UseFieldReturn<T> {\n const form = useFormContext()\n const state = ref(form.getState()) as Ref<FormState<FormValues>>\n const unsubscribe = form.subscribe((next) => {\n state.value = next\n })\n onBeforeUnmount(unsubscribe)\n\n // Canonical key for per-field state lookups (a flat key maps to itself).\n const key = formatPath(name)\n const value = computed(() => getByPath(state.value.values, name) as T)\n const error = computed(() => state.value.errors[key])\n\n return {\n name,\n value,\n error,\n touched: computed(() => Boolean(state.value.touched[key])),\n dirty: computed(() => Boolean(state.value.dirty[key])),\n setValue: (next) => form.setFieldValue(name, next as never),\n setTouched: (touched = true) => form.setFieldTouched(name, touched),\n fieldProps: computed(() => ({\n modelValue: value.value,\n 'onUpdate:modelValue': (next: unknown) => form.setFieldValue(name, next as never),\n invalid: Boolean(error.value),\n onBlur: () => form.setFieldTouched(name, true),\n })),\n }\n}\n","import { computed, onBeforeUnmount, ref, type ComputedRef, type Ref } from 'vue'\nimport type { FormState, FormValues } from '@iris-ui-kit/core'\nimport { useFormContext } from './context'\n\nexport interface UseFieldArrayReturn<T> {\n name: string\n /** Current array value (reactive). */\n fields: ComputedRef<T[]>\n /** Append an item. */\n push: (item: T) => void\n /** Remove the item at `index`. */\n remove: (index: number) => void\n /** Insert `item` at `index` (shifting the rest right). */\n insert: (index: number, item: T) => void\n /** Move the item from `from` to `to`. */\n move: (from: number, to: number) => void\n /** Replace the whole array. */\n replace: (items: T[]) => void\n}\n\n/**\n * Manage a dynamic array field (repeatable rows) inside an `<IrisForm>`. Mutators\n * delegate to the core {@link FormStore} array helpers (`arrayPush`/`arrayInsert`/\n * `arrayRemove`/`arrayMove`), which RE-KEY each element's error/touched/dirty/\n * validating state across the mutation — so a row's per-element validation state\n * FOLLOWS the row when rows are removed or reordered (removing `items[0]` shifts\n * `items[2]`'s error down to `items[1]`). `replace` swaps the whole array.\n */\nexport function useFieldArray<T = unknown>(name: string): UseFieldArrayReturn<T> {\n const form = useFormContext()\n const state = ref(form.getState()) as Ref<FormState<FormValues>>\n const unsubscribe = form.subscribe((next) => {\n state.value = next\n })\n onBeforeUnmount(unsubscribe)\n\n return {\n name,\n fields: computed(\n () => (Array.isArray(state.value.values[name]) ? state.value.values[name] : []) as T[],\n ),\n push: (item) => form.arrayPush(name as never, item as never),\n remove: (index) => form.arrayRemove(name as never, index),\n insert: (index, item) => form.arrayInsert(name as never, index, item as never),\n move: (from, to) => form.arrayMove(name as never, from, to),\n replace: (items) => form.setFieldValue(name, items as never),\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/form/context.ts","../src/form/Form.ts","../src/useStore.ts","../src/form/useForm.ts","../src/form/useField.ts","../src/form/useFieldArray.ts"],"names":["inject","defineComponent","provide","ref","h","shallowRef","onScopeDispose","createFormStore","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AC,IAAA,KAAkB,IAAA,CAAK,aAAA,CAAc,MAAM,IAAa,CAAA;AAAA,MAChF,OAAA,EAAS,OAAA,CAAQ,KAAA,CAAM,KAAK,CAAA;AAAA,MAC5B,MAAA,EAAQ,MAAM,IAAA,CAAK,eAAA,CAAgB,MAAM,IAAI;AAAA,KAC/C,CAAE;AAAA,GACJ;AACF;ACjDO,SAAS,cAA2B,IAAA,EAAsC;AAC/E,EAAA,MAAM,OAAO,cAAA,EAAe;AAQ5B,EAAA,MAAM,GAAA,GAAM,iBAAiB,IAAA,CAAK,KAAA,EAAO,CAAC,CAAA,KAAM,CAAA,CAAE,MAAA,CAAO,IAAI,CAAC,CAAA;AAC9D,EAAA,MAAM,MAAA,GAASA,YAAAA,CAAS,MAAO,KAAA,CAAM,OAAA,CAAQ,GAAA,CAAI,KAAK,CAAA,GAAI,GAAA,CAAI,KAAA,GAAQ,EAAU,CAAA;AAEhF,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAM,CAAC,IAAA,KAAS,IAAA,CAAK,SAAA,CAAU,MAAe,IAAa,CAAA;AAAA,IAC3D,QAAQ,CAAC,KAAA,KAAU,IAAA,CAAK,WAAA,CAAY,MAAe,KAAK,CAAA;AAAA,IACxD,MAAA,EAAQ,CAAC,KAAA,EAAO,IAAA,KAAS,KAAK,WAAA,CAAY,IAAA,EAAe,OAAO,IAAa,CAAA;AAAA,IAC7E,IAAA,EAAM,CAAC,IAAA,EAAM,EAAA,KAAO,KAAK,SAAA,CAAU,IAAA,EAAe,MAAM,EAAE,CAAA;AAAA,IAC1D,SAAS,CAAC,KAAA,KAAU,IAAA,CAAK,aAAA,CAAc,MAAM,KAAc;AAAA,GAC7D;AACF","file":"form.cjs","sourcesContent":["import { inject, type InjectionKey } from 'vue'\nimport type { FormStore, FormValues } from '@iris-ui-kit/core'\n\n/**\n * Provides the active form's {@link FormStore} to descendant fields so\n * `useField` can bind without prop drilling. The generic is erased at the\n * injection boundary; `useField<T>` re-applies the value type at the call site.\n */\nexport const FormInjectionKey: InjectionKey<FormStore<FormValues>> = Symbol('IrisForm')\n\nexport function useFormContext(): FormStore<FormValues> {\n const form = inject(FormInjectionKey, null)\n if (!form) {\n throw new Error('useField / useFormContext must be used within an <IrisForm>')\n }\n return form\n}\n","import { defineComponent, h, provide, ref, type PropType } from 'vue'\nimport type { FormStore, FormValues } from '@iris-ui-kit/core'\nimport { FormInjectionKey } from './context'\n\n/** Focus (and best-effort scroll to) the first errored named control in DOM order. */\nfunction focusFirstError(\n formEl: HTMLElement | null,\n errors: Record<string, string | undefined>,\n): void {\n if (!formEl) return\n const keys = Object.keys(errors)\n if (keys.length === 0) return\n const controls = formEl.querySelectorAll<HTMLElement>(\n 'input[name], select[name], textarea[name], [data-iris-field]',\n )\n for (const el of Array.from(controls)) {\n const name = el.getAttribute('name') ?? el.getAttribute('data-iris-field')\n if (name && keys.includes(name)) {\n el.focus()\n try {\n el.scrollIntoView({ block: 'center' })\n } catch {\n /* scrollIntoView is unavailable in jsdom — focus is the contract */\n }\n return\n }\n }\n}\n\n/**\n * Provides the form store to descendant `useField` calls and wires the native\n * `<form>` submit to `handleSubmit` (with `preventDefault`). Composition:\n *\n * ```html\n * <IrisForm :form=\"f.form\">\n * <IrisFormField label=\"Email\"><IrisInput v-bind=\"email.fieldProps.value\" /></IrisFormField>\n * <IrisButton type=\"submit\" :disabled=\"f.isSubmitting.value\">Save</IrisButton>\n * </IrisForm>\n * ```\n */\nexport const IrisForm = defineComponent({\n name: 'IrisForm',\n props: {\n /** The store from `useForm(...).form`. */\n form: {\n type: Object as PropType<FormStore<FormValues>>,\n required: true,\n },\n },\n setup(props, { slots }) {\n provide(FormInjectionKey, props.form)\n const formRef = ref<HTMLElement | null>(null)\n return () =>\n h(\n 'form',\n {\n ref: formRef,\n 'data-iris-form': '',\n onSubmit: (event: Event) => {\n event.preventDefault()\n // On a failed submit, move focus to the first errored field (a11y).\n void props.form\n .handleSubmit()\n .then(() => focusFirstError(formRef.value, props.form.getState().errors))\n },\n },\n slots.default?.(),\n )\n },\n})\n","import { shallowRef, onScopeDispose, type ShallowRef } from 'vue'\nimport type { ReadonlyStore, Store } from '@iris-ui-kit/core'\n\n/**\n * Bridge a framework-agnostic `@iris-ui-kit/core` store into a Vue ref — updates on\n * every store emission. The mirror of React's `useSyncExternalStore`, Solid's\n * `createSignal`, and Svelte's `readable`. Seeds synchronously from\n * `store.getState()` (SSR-safe); detaches on scope dispose.\n */\nexport function useStore<T>(store: ReadonlyStore<T>): Readonly<ShallowRef<T>> {\n const state = shallowRef(store.getState()) as ShallowRef<T>\n onScopeDispose(store.subscribe((next) => (state.value = next)))\n return state\n}\n\n/**\n * Subscribe to a DERIVED slice of a core store — the ref updates only when\n * `selector(state)` changes per `equals` (default `Object.is`), not on every\n * store emission. Built on {@link Store.subscribeWith}.\n */\nexport function useStoreSelector<T, U>(\n store: Store<T>,\n selector: (state: T) => U,\n equals?: (a: U, b: U) => boolean,\n): Readonly<ShallowRef<U>> {\n const slice = shallowRef(selector(store.getState())) as ShallowRef<U>\n onScopeDispose(store.subscribeWith(selector, (v) => (slice.value = v), equals))\n return slice\n}\n","import { computed, type ComputedRef, type Ref } from 'vue'\nimport {\n createFormStore,\n type FieldErrors,\n type FieldFlags,\n type FormConfig,\n type FormState,\n type FormStore,\n type FormValues,\n} from '@iris-ui-kit/core'\nimport { useStore } from '../useStore'\n\nexport interface UseFormReturn<V extends FormValues> {\n /** The form store — pass to `<IrisForm :form=\"...\">`. */\n form: FormStore<V>\n /** The full reactive state snapshot. */\n state: Ref<FormState<V>>\n values: ComputedRef<V>\n errors: ComputedRef<FieldErrors<V>>\n touched: ComputedRef<FieldFlags<V>>\n dirty: ComputedRef<FieldFlags<V>>\n isSubmitting: ComputedRef<boolean>\n isValidating: ComputedRef<boolean>\n submitCount: ComputedRef<number>\n isValid: ComputedRef<boolean>\n setFieldValue: FormStore<V>['setFieldValue']\n setValues: FormStore<V>['setValues']\n setFieldTouched: FormStore<V>['setFieldTouched']\n setFieldError: FormStore<V>['setFieldError']\n setErrors: FormStore<V>['setErrors']\n validateField: FormStore<V>['validateField']\n validateForm: FormStore<V>['validateForm']\n handleSubmit: FormStore<V>['handleSubmit']\n reset: FormStore<V>['reset']\n}\n\n/**\n * Vue binding for the framework-agnostic form engine. Creates the store in\n * `setup()` (runs once) and bridges it into Vue reactivity via `useStore` (a\n * shallow snapshot ref updated on each store change, detached on scope\n * dispose). Because `setup` runs once,\n * `onSubmit` / `validate` closures stay live against reactive state — no\n * stale-callback handling is needed (unlike the React adapter).\n */\nexport function useForm<V extends FormValues>(config: FormConfig<V>): UseFormReturn<V> {\n const form = createFormStore(config)\n\n // Whole-state bridge via the shared `useStore` (shallow, detached on scope\n // dispose — identical to the old `onBeforeUnmount` for setup-scope consumers,\n // and correct for nested scopes too). The published `state: Ref<FormState<V>>`\n // type is unchanged (R5); the runtime is a shallow snapshot — the store is the\n // only write path (it always was), so this localized cast is type-only. The\n // per-field narrowing payoff comes from `useField` / `useFieldArray`; the\n // form-level computeds below are whole-form aggregates by design.\n const state = useStore(form.store) as unknown as Ref<FormState<V>>\n\n return {\n form,\n state,\n values: computed(() => state.value.values),\n errors: computed(() => state.value.errors),\n touched: computed(() => state.value.touched),\n dirty: computed(() => state.value.dirty),\n isSubmitting: computed(() => state.value.isSubmitting),\n isValidating: computed(() => state.value.isValidating),\n submitCount: computed(() => state.value.submitCount),\n isValid: computed(() => Object.keys(state.value.errors).length === 0),\n setFieldValue: form.setFieldValue,\n setValues: form.setValues,\n setFieldTouched: form.setFieldTouched,\n setFieldError: form.setFieldError,\n setErrors: form.setErrors,\n validateField: form.validateField,\n validateForm: form.validateForm,\n handleSubmit: form.handleSubmit,\n reset: form.reset,\n }\n}\n","import { computed, type ComputedRef } from 'vue'\nimport { formatPath, getByPath, parsePath } from '@iris-ui-kit/core'\nimport { useFormContext } from './context'\nimport { useStoreSelector } from '../useStore'\n\nexport interface FieldBindProps {\n modelValue: unknown\n 'onUpdate:modelValue': (value: unknown) => void\n invalid: boolean\n onBlur: () => void\n}\n\nexport interface UseFieldReturn<T> {\n name: string\n value: ComputedRef<T>\n error: ComputedRef<string | undefined>\n touched: ComputedRef<boolean>\n dirty: ComputedRef<boolean>\n setValue: (value: T) => void\n setTouched: (touched?: boolean) => void\n /**\n * Bundle for `v-bind` onto a v-model'd Iris control (`IrisInput`,\n * `IrisSelect`, …): wires `modelValue` / `update:modelValue` / `invalid` /\n * `blur`. Use `value` + `setValue` directly for bespoke bindings.\n */\n fieldProps: ComputedRef<FieldBindProps>\n}\n\n/**\n * Binds a single field to the surrounding `<IrisForm>`. `T` is the value type\n * at the call site (the injection erases the form's generic).\n *\n * `name` may be a flat top-level key OR a nested PATH (`'address.city'`,\n * `'items[2].sku'`); a flat key is a 1-segment path and stays back-compatible\n * (v3 R19).\n */\nexport function useField<T = unknown>(name: string): UseFieldReturn<T> {\n const form = useFormContext()\n\n // Canonical key for per-field state lookups (a flat key maps to itself).\n const key = formatPath(name)\n // Hoisted once — selectors run on every store emission (core `subscribeWith`).\n const segments = parsePath(name)\n\n // Four narrow per-field slices, each Object.is-gated by core `subscribeWith`.\n // Core writes use structural sharing (`setByPath`, per-key flag spread-copies),\n // so an unrelated keystroke does NOT move these refs and this field's computeds\n // do not invalidate (previously a whole-form deep `ref` re-ran every field's\n // computeds on every emission). Selectors are allocation-free by construction.\n const valueSlice = useStoreSelector(form.store, (s) => getByPath(s.values, segments) as T)\n const errorSlice = useStoreSelector(form.store, (s) => s.errors[key])\n const touchedSlice = useStoreSelector(form.store, (s) => Boolean(s.touched[key]))\n const dirtySlice = useStoreSelector(form.store, (s) => Boolean(s.dirty[key]))\n\n // computed wrappers keep the published ComputedRef<T> member types exactly as\n // declared (a bare shallow ref is not assignable to ComputedRef in Vue 3.4+),\n // and each computed invalidates only when its own slice actually moves.\n const value = computed(() => valueSlice.value)\n const error = computed(() => errorSlice.value)\n const touched = computed(() => touchedSlice.value)\n const dirty = computed(() => dirtySlice.value)\n\n return {\n name,\n value,\n error,\n touched,\n dirty,\n setValue: (next) => form.setFieldValue(name, next as never),\n setTouched: (touched = true) => form.setFieldTouched(name, touched),\n fieldProps: computed(() => ({\n modelValue: value.value,\n 'onUpdate:modelValue': (next: unknown) => form.setFieldValue(name, next as never),\n invalid: Boolean(error.value),\n onBlur: () => form.setFieldTouched(name, true),\n })),\n }\n}\n","import { computed, type ComputedRef } from 'vue'\nimport { useFormContext } from './context'\nimport { useStoreSelector } from '../useStore'\n\nexport interface UseFieldArrayReturn<T> {\n name: string\n /** Current array value (reactive). */\n fields: ComputedRef<T[]>\n /** Append an item. */\n push: (item: T) => void\n /** Remove the item at `index`. */\n remove: (index: number) => void\n /** Insert `item` at `index` (shifting the rest right). */\n insert: (index: number, item: T) => void\n /** Move the item from `from` to `to`. */\n move: (from: number, to: number) => void\n /** Replace the whole array. */\n replace: (items: T[]) => void\n}\n\n/**\n * Manage a dynamic array field (repeatable rows) inside an `<IrisForm>`. Mutators\n * delegate to the core {@link FormStore} array helpers (`arrayPush`/`arrayInsert`/\n * `arrayRemove`/`arrayMove`), which RE-KEY each element's error/touched/dirty/\n * validating state across the mutation — so a row's per-element validation state\n * FOLLOWS the row when rows are removed or reordered (removing `items[0]` shifts\n * `items[2]`'s error down to `items[1]`). `replace` swaps the whole array.\n */\nexport function useFieldArray<T = unknown>(name: string): UseFieldArrayReturn<T> {\n const form = useFormContext()\n\n // One narrow slice for the whole array, Object.is-gated by core `subscribeWith`.\n // CRITICAL: the selector must not allocate — `(s) => s.values[name] ?? []` would\n // mint a fresh [] per emission and defeat the Object.is gate — so the `[]`\n // fallback lives in the computed wrapper (re-evaluated only when the raw slice\n // moves). Array mutations produce a fresh array (correct re-render); untouched\n // rows are unaffected.\n const raw = useStoreSelector(form.store, (s) => s.values[name])\n const fields = computed(() => (Array.isArray(raw.value) ? raw.value : []) as T[])\n\n return {\n name,\n fields,\n push: (item) => form.arrayPush(name as never, item as never),\n remove: (index) => form.arrayRemove(name as never, index),\n insert: (index, item) => form.arrayInsert(name as never, index, item as never),\n move: (from, to) => form.arrayMove(name as never, from, to),\n replace: (items) => form.setFieldValue(name, items as never),\n }\n}\n"]}
|
package/dist/form.d.cts
CHANGED
|
@@ -54,8 +54,9 @@ interface UseFormReturn<V extends FormValues> {
|
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* Vue binding for the framework-agnostic form engine. Creates the store in
|
|
57
|
-
* `setup()` (runs once) and bridges it into Vue reactivity via
|
|
58
|
-
* on each store change,
|
|
57
|
+
* `setup()` (runs once) and bridges it into Vue reactivity via `useStore` (a
|
|
58
|
+
* shallow snapshot ref updated on each store change, detached on scope
|
|
59
|
+
* dispose). Because `setup` runs once,
|
|
59
60
|
* `onSubmit` / `validate` closures stay live against reactive state — no
|
|
60
61
|
* stale-callback handling is needed (unlike the React adapter).
|
|
61
62
|
*/
|
package/dist/form.d.ts
CHANGED
|
@@ -54,8 +54,9 @@ interface UseFormReturn<V extends FormValues> {
|
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* Vue binding for the framework-agnostic form engine. Creates the store in
|
|
57
|
-
* `setup()` (runs once) and bridges it into Vue reactivity via
|
|
58
|
-
* on each store change,
|
|
57
|
+
* `setup()` (runs once) and bridges it into Vue reactivity via `useStore` (a
|
|
58
|
+
* shallow snapshot ref updated on each store change, detached on scope
|
|
59
|
+
* dispose). Because `setup` runs once,
|
|
59
60
|
* `onSubmit` / `validate` closures stay live against reactive state — no
|
|
60
61
|
* stale-callback handling is needed (unlike the React adapter).
|
|
61
62
|
*/
|
package/dist/form.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export { FormInjectionKey, IrisForm, useField, useFieldArray, useForm, useFormContext } from './chunk-
|
|
1
|
+
export { FormInjectionKey, IrisForm, useField, useFieldArray, useForm, useFormContext } from './chunk-IAG64CHL.js';
|
|
2
|
+
import './chunk-75GSYEJS.js';
|
|
2
3
|
//# sourceMappingURL=form.js.map
|
|
3
4
|
//# sourceMappingURL=form.js.map
|