@tanstack/preact-form 0.0.1 → 1.29.4

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.
Files changed (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +35 -45
  3. package/dist/cjs/createFormHook.cjs +101 -0
  4. package/dist/cjs/createFormHook.cjs.map +1 -0
  5. package/dist/cjs/createFormHook.d.cts +80 -0
  6. package/dist/cjs/index.cjs +24 -0
  7. package/dist/cjs/index.cjs.map +1 -0
  8. package/dist/cjs/index.d.cts +8 -0
  9. package/dist/cjs/types.d.cts +17 -0
  10. package/dist/cjs/useField.cjs +109 -0
  11. package/dist/cjs/useField.cjs.map +1 -0
  12. package/dist/cjs/useField.d.cts +58 -0
  13. package/dist/cjs/useFieldGroup.cjs +48 -0
  14. package/dist/cjs/useFieldGroup.cjs.map +1 -0
  15. package/dist/cjs/useFieldGroup.d.cts +30 -0
  16. package/dist/cjs/useForm.cjs +74 -0
  17. package/dist/cjs/useForm.cjs.map +1 -0
  18. package/dist/cjs/useForm.d.cts +30 -0
  19. package/dist/cjs/useFormId.cjs +6 -0
  20. package/dist/cjs/useFormId.cjs.map +1 -0
  21. package/dist/cjs/useFormId.d.cts +2 -0
  22. package/dist/cjs/useIsomorphicLayoutEffect.cjs +6 -0
  23. package/dist/cjs/useIsomorphicLayoutEffect.cjs.map +1 -0
  24. package/dist/cjs/useIsomorphicLayoutEffect.d.cts +2 -0
  25. package/dist/cjs/useStore.cjs +24 -0
  26. package/dist/cjs/useStore.cjs.map +1 -0
  27. package/dist/cjs/useStore.d.cts +13 -0
  28. package/dist/esm/createFormHook.d.ts +80 -0
  29. package/dist/esm/createFormHook.js +101 -0
  30. package/dist/esm/createFormHook.js.map +1 -0
  31. package/dist/esm/index.d.ts +8 -0
  32. package/dist/esm/index.js +18 -0
  33. package/dist/esm/index.js.map +1 -0
  34. package/dist/esm/types.d.ts +17 -0
  35. package/dist/esm/useField.d.ts +58 -0
  36. package/dist/esm/useField.js +109 -0
  37. package/dist/esm/useField.js.map +1 -0
  38. package/dist/esm/useFieldGroup.d.ts +30 -0
  39. package/dist/esm/useFieldGroup.js +48 -0
  40. package/dist/esm/useFieldGroup.js.map +1 -0
  41. package/dist/esm/useForm.d.ts +30 -0
  42. package/dist/esm/useForm.js +74 -0
  43. package/dist/esm/useForm.js.map +1 -0
  44. package/dist/esm/useFormId.d.ts +2 -0
  45. package/dist/esm/useFormId.js +6 -0
  46. package/dist/esm/useFormId.js.map +1 -0
  47. package/dist/esm/useIsomorphicLayoutEffect.d.ts +2 -0
  48. package/dist/esm/useIsomorphicLayoutEffect.js +6 -0
  49. package/dist/esm/useIsomorphicLayoutEffect.js.map +1 -0
  50. package/dist/esm/useStore.d.ts +13 -0
  51. package/dist/esm/useStore.js +24 -0
  52. package/dist/esm/useStore.js.map +1 -0
  53. package/package.json +64 -8
  54. package/src/createFormHook.tsx +603 -0
  55. package/src/index.ts +10 -0
  56. package/src/types.ts +143 -0
  57. package/src/useField.tsx +779 -0
  58. package/src/useFieldGroup.tsx +259 -0
  59. package/src/useForm.tsx +281 -0
  60. package/src/useFormId.ts +3 -0
  61. package/src/useIsomorphicLayoutEffect.ts +4 -0
  62. package/src/useStore.ts +44 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFormId.js","sources":["../../src/useFormId.ts"],"sourcesContent":["import { useId } from 'preact/hooks'\n\nexport const useFormId = useId\n"],"names":[],"mappings":";AAEO,MAAM,YAAY;"}
@@ -0,0 +1,2 @@
1
+ import { useLayoutEffect } from 'preact/hooks';
2
+ export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
@@ -0,0 +1,6 @@
1
+ import { useLayoutEffect, useEffect } from "preact/hooks";
2
+ const useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
3
+ export {
4
+ useIsomorphicLayoutEffect
5
+ };
6
+ //# sourceMappingURL=useIsomorphicLayoutEffect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIsomorphicLayoutEffect.js","sources":["../../src/useIsomorphicLayoutEffect.ts"],"sourcesContent":["import { useEffect, useLayoutEffect } from 'preact/hooks'\n\nexport const useIsomorphicLayoutEffect =\n typeof window !== 'undefined' ? useLayoutEffect : useEffect\n"],"names":[],"mappings":";AAEO,MAAM,4BACX,OAAO,WAAW,cAAc,kBAAkB;"}
@@ -0,0 +1,13 @@
1
+ export type NoInfer<T> = [T][T extends any ? 0 : never];
2
+ type EqualityFn<T> = (objA: T, objB: T) => boolean;
3
+ interface UseStoreOptions<T> {
4
+ equal?: EqualityFn<T>;
5
+ }
6
+ type StoreLike<TState> = {
7
+ subscribe: (listener: (...args: Array<unknown>) => void) => {
8
+ unsubscribe: () => void;
9
+ } | (() => void);
10
+ readonly state: TState;
11
+ };
12
+ export declare function useStore<TState, TSelected = NoInfer<TState>>(store: StoreLike<TState>, selector?: (state: NoInfer<TState>) => TSelected, options?: UseStoreOptions<TSelected>): TSelected;
13
+ export {};
@@ -0,0 +1,24 @@
1
+ import { useStore as useStore$1 } from "@tanstack/preact-store";
2
+ function bridgeStore(store) {
3
+ return {
4
+ get state() {
5
+ return store.state;
6
+ },
7
+ // @tanstack/preact-store currently calls subscribe unbound.
8
+ subscribe: (listener) => {
9
+ const subscription = store.subscribe(listener);
10
+ return typeof subscription === "function" ? subscription : () => subscription.unsubscribe();
11
+ }
12
+ };
13
+ }
14
+ function useStore(store, selector, options) {
15
+ return useStore$1(
16
+ bridgeStore(store),
17
+ selector,
18
+ options
19
+ );
20
+ }
21
+ export {
22
+ useStore
23
+ };
24
+ //# sourceMappingURL=useStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStore.js","sources":["../../src/useStore.ts"],"sourcesContent":["import { useStore as usePreactStore } from '@tanstack/preact-store'\n\nexport type NoInfer<T> = [T][T extends any ? 0 : never]\n\ntype EqualityFn<T> = (objA: T, objB: T) => boolean\n\ninterface UseStoreOptions<T> {\n equal?: EqualityFn<T>\n}\n\ntype StoreLike<TState> = {\n subscribe: (\n listener: (...args: Array<unknown>) => void,\n ) => { unsubscribe: () => void } | (() => void)\n readonly state: TState\n}\n\nfunction bridgeStore<TState>(store: StoreLike<TState>) {\n return {\n get state() {\n return store.state\n },\n // @tanstack/preact-store currently calls subscribe unbound.\n subscribe: (listener: () => void) => {\n const subscription = store.subscribe(listener)\n\n return typeof subscription === 'function'\n ? subscription\n : () => subscription.unsubscribe()\n },\n }\n}\n\nexport function useStore<TState, TSelected = NoInfer<TState>>(\n store: StoreLike<TState>,\n selector?: (state: NoInfer<TState>) => TSelected,\n options?: UseStoreOptions<TSelected>,\n): TSelected {\n return usePreactStore(\n bridgeStore(store) as never,\n selector as never,\n options as never,\n ) as TSelected\n}\n"],"names":["usePreactStore"],"mappings":";AAiBA,SAAS,YAAoB,OAA0B;AACrD,SAAO;AAAA,IACL,IAAI,QAAQ;AACV,aAAO,MAAM;AAAA,IACf;AAAA;AAAA,IAEA,WAAW,CAAC,aAAyB;AACnC,YAAM,eAAe,MAAM,UAAU,QAAQ;AAE7C,aAAO,OAAO,iBAAiB,aAC3B,eACA,MAAM,aAAa,YAAA;AAAA,IACzB;AAAA,EAAA;AAEJ;AAEO,SAAS,SACd,OACA,UACA,SACW;AACX,SAAOA;AAAAA,IACL,YAAY,KAAK;AAAA,IACjB;AAAA,IACA;AAAA,EAAA;AAEJ;"}
package/package.json CHANGED
@@ -1,10 +1,66 @@
1
1
  {
2
2
  "name": "@tanstack/preact-form",
3
- "version": "0.0.1",
4
- "description": "OIDC trusted publishing setup package for @tanstack/preact-form",
5
- "keywords": [
6
- "oidc",
7
- "trusted-publishing",
8
- "setup"
9
- ]
10
- }
3
+ "version": "1.29.4",
4
+ "description": "Powerful, type-safe forms for Preact.",
5
+ "author": "tannerlinsley",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/TanStack/form.git",
10
+ "directory": "packages/preact-form"
11
+ },
12
+ "homepage": "https://tanstack.com/form",
13
+ "funding": {
14
+ "type": "github",
15
+ "url": "https://github.com/sponsors/tannerlinsley"
16
+ },
17
+ "type": "module",
18
+ "types": "dist/esm/index.d.ts",
19
+ "main": "dist/cjs/index.cjs",
20
+ "module": "dist/esm/index.js",
21
+ "exports": {
22
+ ".": {
23
+ "import": {
24
+ "types": "./dist/esm/index.d.ts",
25
+ "default": "./dist/esm/index.js"
26
+ },
27
+ "require": {
28
+ "types": "./dist/cjs/index.d.cts",
29
+ "default": "./dist/cjs/index.cjs"
30
+ }
31
+ },
32
+ "./package.json": "./package.json"
33
+ },
34
+ "sideEffects": false,
35
+ "files": [
36
+ "dist",
37
+ "src"
38
+ ],
39
+ "dependencies": {
40
+ "@tanstack/preact-store": "^0.10.2",
41
+ "@tanstack/form-core": "1.29.3"
42
+ },
43
+ "devDependencies": {
44
+ "@preact/preset-vite": "^2.10.2",
45
+ "@testing-library/preact": "^3.2.4",
46
+ "preact": "^10.26.4",
47
+ "vite": "^7.2.2"
48
+ },
49
+ "peerDependencies": {
50
+ "preact": ">10.11.0"
51
+ },
52
+ "scripts": {
53
+ "clean": "premove ./dist ./coverage",
54
+ "test:eslint": "eslint ./src ./tests",
55
+ "test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"",
56
+ "test:types:ts54": "node ../../node_modules/typescript54/lib/tsc.js",
57
+ "test:types:ts55": "node ../../node_modules/typescript55/lib/tsc.js",
58
+ "test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js",
59
+ "test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js",
60
+ "test:types:ts58": "tsc",
61
+ "test:lib": "vitest",
62
+ "test:lib:dev": "pnpm run test:lib --watch",
63
+ "test:build": "publint --strict",
64
+ "build": "vite build"
65
+ }
66
+ }