svelte-json-schema-form 0.0.2 → 0.0.4-alpha1

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 (111) hide show
  1. package/README.md +44 -26
  2. package/{src → dist/components}/Form.stories.svelte +1 -1
  3. package/dist/components/Form.stories.svelte.d.ts +3 -0
  4. package/{src → dist/components}/Form.svelte +39 -40
  5. package/dist/components/Form.svelte.d.ts +35 -0
  6. package/dist/components/formContext.d.ts +2 -0
  7. package/dist/components/formDefaultInputComponents.d.ts +15 -0
  8. package/{src/components → dist/components/inputs}/FormActionButton.svelte +10 -9
  9. package/dist/components/inputs/FormActionButton.svelte.d.ts +25 -0
  10. package/{src/components → dist/components/inputs}/FormArrayInput.svelte +12 -11
  11. package/dist/components/inputs/FormArrayInput.svelte.d.ts +25 -0
  12. package/{src/components → dist/components/inputs}/FormCheckboxInput.svelte +1 -1
  13. package/dist/components/inputs/FormCheckboxInput.svelte.d.ts +11 -0
  14. package/{src/components → dist/components/inputs}/FormInputWrapper.svelte +15 -11
  15. package/dist/components/inputs/FormInputWrapper.svelte.d.ts +15 -0
  16. package/{src/components → dist/components/inputs}/FormObjectInput.svelte +9 -8
  17. package/dist/components/inputs/FormObjectInput.svelte.d.ts +23 -0
  18. package/{src/components → dist/components/inputs}/FormTextInput.svelte +1 -2
  19. package/dist/components/inputs/FormTextInput.svelte.d.ts +13 -0
  20. package/dist/index.d.ts +7 -0
  21. package/dist/index.js +20 -0
  22. package/dist/vitest-examples/Welcome.svelte +8 -0
  23. package/dist/vitest-examples/Welcome.svelte.d.ts +13 -0
  24. package/dist/vitest-examples/greet.d.ts +1 -0
  25. package/dist/vitest-examples/greet.js +3 -0
  26. package/package.json +66 -36
  27. package/.storybook/main.ts +0 -19
  28. package/.storybook/preview.ts +0 -15
  29. package/.vscode/extensions.json +0 -3
  30. package/LICENSE +0 -21
  31. package/src/exports.js +0 -21
  32. package/src/utils/svelteObjectStore.js +0 -35
  33. package/storybook-static/assets/Color-6VNJS4EI-BwbyGRpv.js +0 -1
  34. package/storybook-static/assets/DocsRenderer-NNNQARDV-Dv5gTx4J.js +0 -401
  35. package/storybook-static/assets/Form.stories-B9d26ABq.js +0 -1
  36. package/storybook-static/assets/Hello.stories-iStloLVx.js +0 -1
  37. package/storybook-static/assets/WithTooltip-V3YHNWJZ-Cu4QOpJO.js +0 -1
  38. package/storybook-static/assets/_commonjsHelpers-Cpj98o6Y.js +0 -1
  39. package/storybook-static/assets/collect-stories-C_xzNuNF.js +0 -1
  40. package/storybook-static/assets/entry-preview-ayMb_JX6.js +0 -5
  41. package/storybook-static/assets/entry-preview-docs-Dn-BUk6f.js +0 -7
  42. package/storybook-static/assets/formatter-SWP5E3XI-BDUqP36L.js +0 -156
  43. package/storybook-static/assets/iframe-COBy1vQP.js +0 -7
  44. package/storybook-static/assets/index-Bdfa_YSh.js +0 -1
  45. package/storybook-static/assets/index-Bw8VTzHM.js +0 -1
  46. package/storybook-static/assets/index-C0DyA3Eb.js +0 -3
  47. package/storybook-static/assets/index-Da9FSDFk.js +0 -1
  48. package/storybook-static/assets/index-DrFu-skq.js +0 -6
  49. package/storybook-static/assets/preview-9J5W8ogQ.js +0 -7
  50. package/storybook-static/assets/preview-BAz7FMXc.js +0 -396
  51. package/storybook-static/assets/preview-BCp7Wgbt.js +0 -27
  52. package/storybook-static/assets/preview-B_0crF9I.js +0 -1
  53. package/storybook-static/assets/preview-BcxrGG1y.js +0 -20
  54. package/storybook-static/assets/preview-CIwosuWp.js +0 -1
  55. package/storybook-static/assets/preview-Cv3rAi2i.js +0 -7
  56. package/storybook-static/assets/preview-D8VCGkL0.js +0 -17
  57. package/storybook-static/assets/preview-Db4Idchh.js +0 -1
  58. package/storybook-static/assets/syntaxhighlighter-B5GMVT5T-CFyDre8b.js +0 -1
  59. package/storybook-static/favicon.svg +0 -7
  60. package/storybook-static/iframe.html +0 -458
  61. package/storybook-static/index.html +0 -135
  62. package/storybook-static/index.json +0 -1
  63. package/storybook-static/project.json +0 -1
  64. package/storybook-static/sb-addons/essentials-actions-2/manager-bundle.js +0 -3
  65. package/storybook-static/sb-addons/essentials-actions-2/manager-bundle.js.LEGAL.txt +0 -0
  66. package/storybook-static/sb-addons/essentials-backgrounds-3/manager-bundle.js +0 -12
  67. package/storybook-static/sb-addons/essentials-backgrounds-3/manager-bundle.js.LEGAL.txt +0 -0
  68. package/storybook-static/sb-addons/essentials-controls-1/manager-bundle.js +0 -63
  69. package/storybook-static/sb-addons/essentials-controls-1/manager-bundle.js.LEGAL.txt +0 -18
  70. package/storybook-static/sb-addons/essentials-measure-6/manager-bundle.js +0 -3
  71. package/storybook-static/sb-addons/essentials-measure-6/manager-bundle.js.LEGAL.txt +0 -0
  72. package/storybook-static/sb-addons/essentials-outline-7/manager-bundle.js +0 -3
  73. package/storybook-static/sb-addons/essentials-outline-7/manager-bundle.js.LEGAL.txt +0 -0
  74. package/storybook-static/sb-addons/essentials-toolbars-5/manager-bundle.js +0 -3
  75. package/storybook-static/sb-addons/essentials-toolbars-5/manager-bundle.js.LEGAL.txt +0 -0
  76. package/storybook-static/sb-addons/essentials-viewport-4/manager-bundle.js +0 -3
  77. package/storybook-static/sb-addons/essentials-viewport-4/manager-bundle.js.LEGAL.txt +0 -0
  78. package/storybook-static/sb-addons/interactions-8/manager-bundle.js +0 -12
  79. package/storybook-static/sb-addons/interactions-8/manager-bundle.js.LEGAL.txt +0 -0
  80. package/storybook-static/sb-addons/links-0/manager-bundle.js +0 -3
  81. package/storybook-static/sb-addons/links-0/manager-bundle.js.LEGAL.txt +0 -0
  82. package/storybook-static/sb-addons/svelte-csf-preset-10/manager-bundle.js +0 -3
  83. package/storybook-static/sb-addons/svelte-csf-preset-10/manager-bundle.js.LEGAL.txt +0 -0
  84. package/storybook-static/sb-addons/svelte-csf-preset-9/manager-bundle.js +0 -3
  85. package/storybook-static/sb-addons/svelte-csf-preset-9/manager-bundle.js.LEGAL.txt +0 -0
  86. package/storybook-static/sb-common-assets/fonts.css +0 -31
  87. package/storybook-static/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
  88. package/storybook-static/sb-common-assets/nunito-sans-bold.woff2 +0 -0
  89. package/storybook-static/sb-common-assets/nunito-sans-italic.woff2 +0 -0
  90. package/storybook-static/sb-common-assets/nunito-sans-regular.woff2 +0 -0
  91. package/storybook-static/sb-manager/WithTooltip-V3YHNWJZ-TRLNWEGW.js +0 -1
  92. package/storybook-static/sb-manager/chunk-4IYAVH3S.js +0 -348
  93. package/storybook-static/sb-manager/chunk-CXYKRFSY.js +0 -9
  94. package/storybook-static/sb-manager/chunk-LVLAH4SI.js +0 -7
  95. package/storybook-static/sb-manager/chunk-VFHDXWEA.js +0 -406
  96. package/storybook-static/sb-manager/chunk-ZEU7PDD3.js +0 -1
  97. package/storybook-static/sb-manager/formatter-SWP5E3XI-7BGIK6BL.js +0 -156
  98. package/storybook-static/sb-manager/globals-module-info.js +0 -1
  99. package/storybook-static/sb-manager/globals.js +0 -1
  100. package/storybook-static/sb-manager/index.js +0 -1
  101. package/storybook-static/sb-manager/runtime.js +0 -1
  102. package/storybook-static/sb-manager/syntaxhighlighter-B5GMVT5T-EA5ASEYD.js +0 -1
  103. package/storybook-static/sb-preview/globals.js +0 -1
  104. package/storybook-static/sb-preview/runtime.js +0 -112
  105. package/storybook-static/stories.json +0 -1
  106. package/svelte.config.js +0 -7
  107. package/tsconfig.json +0 -20
  108. package/tsconfig.node.json +0 -10
  109. package/vite.config.ts +0 -14
  110. /package/{src → dist/components}/formContext.js +0 -0
  111. /package/{src/formDefaultComponents.js → dist/components/formDefaultInputComponents.js} +0 -0
package/README.md CHANGED
@@ -1,47 +1,65 @@
1
- # Svelte + TS + Vite
1
+ # Svelte library
2
2
 
3
- This template should help get you started developing with Svelte and TypeScript in Vite.
3
+ Everything you need to build a Svelte library, powered by [`sv`](https://npmjs.com/package/sv).
4
4
 
5
- ## Recommended IDE Setup
5
+ Read more about creating a library [in the docs](https://svelte.dev/docs/kit/packaging).
6
6
 
7
- [VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode).
7
+ ## Creating a project
8
8
 
9
- ## Need an official Svelte framework?
9
+ If you're seeing this, you've probably already done this step. Congrats!
10
10
 
11
- Check out [SvelteKit](https://github.com/sveltejs/kit#readme), which is also powered by Vite. Deploy anywhere with its serverless-first approach and adapt to various platforms, with out of the box support for TypeScript, SCSS, and Less, and easily-added support for mdsvex, GraphQL, PostCSS, Tailwind CSS, and more.
11
+ ```sh
12
+ # create a new project in the current directory
13
+ npx sv create
12
14
 
13
- ## Technical considerations
15
+ # create a new project in my-app
16
+ npx sv create my-app
17
+ ```
18
+
19
+ To recreate this project with the same configuration:
14
20
 
15
- **Why use this over SvelteKit?**
21
+ ```sh
22
+ # recreate this project
23
+ npx sv@0.14.1 create --template library --types jsdoc --add prettier eslint vitest="usages:unit,component" --install npm svelte-json-schema-form
24
+ ```
16
25
 
17
- - It brings its own routing solution which might not be preferable for some users.
18
- - It is first and foremost a framework that just happens to use Vite under the hood, not a Vite app.
26
+ ## Developing
19
27
 
20
- This template contains as little as possible to get started with Vite + TypeScript + Svelte, while taking into account the developer experience with regards to HMR and intellisense. It demonstrates capabilities on par with the other `create-vite` templates and is a good starting point for beginners dipping their toes into a Vite + Svelte project.
28
+ Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
21
29
 
22
- Should you later need the extended capabilities and extensibility provided by SvelteKit, the template has been structured similarly to SvelteKit so that it is easy to migrate.
30
+ ```sh
31
+ npm run dev
32
+
33
+ # or start the server and open the app in a new browser tab
34
+ npm run dev -- --open
35
+ ```
23
36
 
24
- **Why `global.d.ts` instead of `compilerOptions.types` inside `jsconfig.json` or `tsconfig.json`?**
37
+ Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app.
25
38
 
26
- Setting `compilerOptions.types` shuts out all other types not explicitly listed in the configuration. Using triple-slash references keeps the default TypeScript setting of accepting type information from the entire workspace, while also adding `svelte` and `vite/client` type information.
39
+ ## Building
27
40
 
28
- **Why include `.vscode/extensions.json`?**
41
+ To build your library:
29
42
 
30
- Other templates indirectly recommend extensions via the README, but this file allows VS Code to prompt the user to install the recommended extension upon opening the project.
43
+ ```sh
44
+ npm pack
45
+ ```
46
+
47
+ To create a production version of your showcase app:
48
+
49
+ ```sh
50
+ npm run build
51
+ ```
31
52
 
32
- **Why enable `allowJs` in the TS template?**
53
+ You can preview the production build with `npm run preview`.
33
54
 
34
- While `allowJs: false` would indeed prevent the use of `.js` files in the project, it does not prevent the use of JavaScript syntax in `.svelte` files. In addition, it would force `checkJs: false`, bringing the worst of both worlds: not being able to guarantee the entire codebase is TypeScript, and also having worse typechecking for the existing JavaScript. In addition, there are valid use cases in which a mixed codebase may be relevant.
55
+ > To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
35
56
 
36
- **Why is HMR not preserving my local component state?**
57
+ ## Publishing
37
58
 
38
- HMR state preservation comes with a number of gotchas! It has been disabled by default in both `svelte-hmr` and `@sveltejs/vite-plugin-svelte` due to its often surprising behavior. You can read the details [here](https://github.com/rixo/svelte-hmr#svelte-hmr).
59
+ Go into the `package.json` and give your package the desired name through the `"name"` option. Also consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)).
39
60
 
40
- If you have state that's important to retain within a component, consider creating an external store which would not be replaced by HMR.
61
+ To publish your library to [npm](https://www.npmjs.com):
41
62
 
42
- ```ts
43
- // store.ts
44
- // An extremely simple external store
45
- import { writable } from 'svelte/store'
46
- export default writable(0)
63
+ ```sh
64
+ npm publish
47
65
  ```
@@ -1,4 +1,4 @@
1
- <script context="module">
1
+ <script>
2
2
  import {
3
3
  Template,
4
4
  Story
@@ -0,0 +1,3 @@
1
+ export default Form;
2
+ type Form = any;
3
+ declare const Form: any;
@@ -1,32 +1,35 @@
1
1
  <script>
2
2
  import {
3
3
  onMount,
4
- setContext,
5
- createEventDispatcher
4
+ setContext
6
5
  } from "svelte";
7
6
  import { FormController } from "json-form-core";
8
7
  import defaultContext from "./formContext.js";
9
- import defaultComponents from "./formDefaultComponents.js";
8
+ import defaultInputComponents from "./formDefaultInputComponents.js";
9
+
10
+ let {
11
+ context = defaultContext,
12
+ logger = undefined,
13
+ store = undefined,
14
+ schema = undefined,
15
+ extras = undefined,
16
+ fragments = undefined,
17
+ loadFragments = undefined,
18
+ paths = {},
19
+ components = {},
20
+ onevent = () => {}
21
+ } = $props();
22
+
23
+ let value = $state();
10
24
 
11
- export let context = defaultContext;
12
-
13
- export let logger = undefined; // fallback logger if one is not supplied
14
-
15
- export let store = undefined; // if undefined, a new one will be created
16
- export let schema = undefined; // will be applied in store, if not undefined
17
- export let value = undefined; // will be applied in store, if not undefined
18
- export let extras = undefined; // will be applied in store, if not undefined
19
- export let fragments = undefined; // will be applied in store, if not undefined
20
- export let loadFragments = undefined; // async getter to load fragment configs as they are found
21
-
22
- export let paths = {};
25
+ // svelte-compatible read-only store for components
26
+ const componentsStore = {
27
+ subscribe: (callback) => formController.subscribeComponents(callback)
28
+ };
23
29
 
24
- export let components = {}; // svelte input components
30
+ const WrapperComponent = $derived($componentsStore?.wrapper);
25
31
 
26
32
  // TODO set in store, not here
27
-
28
- const dispatch = createEventDispatcher();
29
-
30
33
  export const formController = new FormController({
31
34
  store, // if no store is set, it will be created
32
35
  schema, // if schema is set, it will be set in the store
@@ -35,7 +38,7 @@
35
38
  loadFragments,
36
39
  paths: paths,
37
40
  components: {
38
- ...defaultComponents,
41
+ ...defaultInputComponents,
39
42
  ...components
40
43
  },
41
44
  logger: logger
@@ -43,29 +46,25 @@
43
46
 
44
47
  // dispatch all events from form controller
45
48
  formController.allOn((eventName, ...eventArgs) => {
46
- dispatch('event', {
49
+ onevent({
47
50
  type: eventName,
48
51
  args: eventArgs
49
52
  });
50
53
  });
51
54
 
52
55
  // set components in store when they change
53
- $: {
56
+ $effect(() => {
54
57
  formController.store.set(['components'], {
55
- ...defaultComponents,
58
+ ...defaultInputComponents,
56
59
  ...components
57
60
  });
58
- }
59
-
60
- $: if(logger) {
61
- console.log("SETTING LOGGER!")
62
- formController.logger = logger;
63
- }
61
+ });
64
62
 
65
- // svelte-compatible read-only store for components
66
- const componentsStore = {
67
- subscribe: (callback) => formController.subscribeComponents(callback)
68
- };
63
+ $effect(() => {
64
+ if(logger) {
65
+ formController.logger = logger;
66
+ }
67
+ });
69
68
 
70
69
  setContext(context, formController); // make form controller available to all children
71
70
 
@@ -89,7 +88,6 @@
89
88
  */
90
89
 
91
90
  onMount(() => {
92
- window.formController = formController;
93
91
  const unsubscribeValue = formController.subscribeValue((storeValue) => {
94
92
  value = storeValue;
95
93
  });
@@ -100,9 +98,10 @@
100
98
  });
101
99
  </script>
102
100
 
103
- <svelte:component
104
- this={$componentsStore.wrapper}
105
- formController={formController}
106
- schemaPathParts={[]}
107
- valuePathParts={[]}
108
- />
101
+ {#if WrapperComponent}
102
+ <WrapperComponent
103
+ formController={formController}
104
+ schemaPathParts={[]}
105
+ valuePathParts={[]}
106
+ />
107
+ {/if}
@@ -0,0 +1,35 @@
1
+ export default Form;
2
+ type Form = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<$$ComponentProps>): void;
5
+ } & {
6
+ formController: FormController;
7
+ };
8
+ declare const Form: import("svelte").Component<{
9
+ context?: typeof defaultContext;
10
+ logger?: any;
11
+ store?: any;
12
+ schema?: any;
13
+ extras?: any;
14
+ fragments?: any;
15
+ loadFragments?: any;
16
+ paths?: Record<string, any>;
17
+ components?: Record<string, any>;
18
+ onevent?: Function;
19
+ }, {
20
+ formController: FormController;
21
+ }, "">;
22
+ type $$ComponentProps = {
23
+ context?: typeof defaultContext;
24
+ logger?: any;
25
+ store?: any;
26
+ schema?: any;
27
+ extras?: any;
28
+ fragments?: any;
29
+ loadFragments?: any;
30
+ paths?: Record<string, any>;
31
+ components?: Record<string, any>;
32
+ onevent?: Function;
33
+ };
34
+ import defaultContext from "./formContext.js";
35
+ import { FormController } from "json-form-core";
@@ -0,0 +1,2 @@
1
+ export default context;
2
+ declare const context: unique symbol;
@@ -0,0 +1,15 @@
1
+ declare namespace _default {
2
+ export { FormInputWrapper as wrapper };
3
+ export { FormArrayInput as arrayInput };
4
+ export { FormObjectInput as objectInput };
5
+ export { FormTextInput as textInput };
6
+ export { FormCheckboxInput as booleanInput };
7
+ export { FormActionButton as actionButton };
8
+ }
9
+ export default _default;
10
+ import FormInputWrapper from "./components/FormInputWrapper.svelte";
11
+ import FormArrayInput from "./components/FormArrayInput.svelte";
12
+ import FormObjectInput from "./components/FormObjectInput.svelte";
13
+ import FormTextInput from "./components/FormTextInput.svelte";
14
+ import FormCheckboxInput from "./components/FormCheckboxInput.svelte";
15
+ import FormActionButton from "./components/FormActionButton.svelte";
@@ -1,13 +1,14 @@
1
1
  <script>
2
- export let components;
3
- export let formController;
4
- export let formNode;
5
- export let valuePathParts;
6
- export let schemaPathParts;
7
-
8
- export let schema;
9
- export let value = {};
10
- export let overrides;
2
+ let {
3
+ components,
4
+ formController,
5
+ formNode,
6
+ valuePathParts,
7
+ schemaPathParts,
8
+ schema,
9
+ value = {},
10
+ overrides
11
+ } = $props();
11
12
 
12
13
  const handleButtonClick = () => {
13
14
  const emitEventType = typeof schema.emit === 'object'
@@ -0,0 +1,25 @@
1
+ export default FormActionButton;
2
+ type FormActionButton = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<$$ComponentProps>): void;
5
+ };
6
+ declare const FormActionButton: import("svelte").Component<{
7
+ components: any;
8
+ formController: any;
9
+ formNode: any;
10
+ valuePathParts: any;
11
+ schemaPathParts: any;
12
+ schema: any;
13
+ value?: Record<string, any>;
14
+ overrides: any;
15
+ }, {}, "">;
16
+ type $$ComponentProps = {
17
+ components: any;
18
+ formController: any;
19
+ formNode: any;
20
+ valuePathParts: any;
21
+ schemaPathParts: any;
22
+ schema: any;
23
+ value?: Record<string, any>;
24
+ overrides: any;
25
+ };
@@ -1,21 +1,22 @@
1
1
  <script>
2
- export let components;
3
- export let formController; // TODO remove
4
- export let formNode;
5
- export let valuePathParts;
6
- export let schemaPathParts;
7
-
8
- export let schema; // form schema
9
- export let value = []; // values of items in array
10
- export let extras = undefined; // extras only for the array element
2
+ let {
3
+ components,
4
+ formController,
5
+ formNode,
6
+ valuePathParts,
7
+ schemaPathParts,
8
+ schema,
9
+ value = [],
10
+ extras = undefined
11
+ } = $props();
11
12
 
12
13
  // extras tree for children of the array
13
- $: extrasChildrenStore = {
14
+ let extrasChildrenStore = $derived({
14
15
  subscribe: (callback) => formNode.subscribeExtrasChildren(callback),
15
16
  set: (extras) => {
16
17
  formNode.extrasChildren = extras;
17
18
  }
18
- }
19
+ })
19
20
 
20
21
  const addItem = () => {
21
22
  const newItemIndex = value.length;
@@ -0,0 +1,25 @@
1
+ export default FormArrayInput;
2
+ type FormArrayInput = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<$$ComponentProps>): void;
5
+ };
6
+ declare const FormArrayInput: import("svelte").Component<{
7
+ components: any;
8
+ formController: any;
9
+ formNode: any;
10
+ valuePathParts: any;
11
+ schemaPathParts: any;
12
+ schema: any;
13
+ value?: any[];
14
+ extras?: any;
15
+ }, {}, "">;
16
+ type $$ComponentProps = {
17
+ components: any;
18
+ formController: any;
19
+ formNode: any;
20
+ valuePathParts: any;
21
+ schemaPathParts: any;
22
+ schema: any;
23
+ value?: any[];
24
+ extras?: any;
25
+ };
@@ -1,5 +1,5 @@
1
1
  <script>
2
- export let value = undefined;
2
+ let { value = undefined } = $props();
3
3
  </script>
4
4
 
5
5
  <div style="border: 1px solid #ff0000; padding: 5px;">
@@ -0,0 +1,11 @@
1
+ export default FormCheckboxInput;
2
+ type FormCheckboxInput = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<$$ComponentProps>): void;
5
+ };
6
+ declare const FormCheckboxInput: import("svelte").Component<{
7
+ value?: any;
8
+ }, {}, "">;
9
+ type $$ComponentProps = {
10
+ value?: any;
11
+ };
@@ -1,14 +1,16 @@
1
1
  <script>
2
- export let valuePathParts;
3
- export let schemaPathParts;
4
- export let formController;
2
+ let {
3
+ valuePathParts,
4
+ schemaPathParts,
5
+ formController
6
+ } = $props();
5
7
 
6
8
  // TODO add the ability to override the value path, or the ability to not save at all
7
- let formNode;
8
- let schemaStore;
9
- let valueStore;
10
- let extrasStore;
11
- let components; // Svelte-specific
9
+ let formNode = $state(undefined);
10
+ let schemaStore = $state(undefined);
11
+ let valueStore = $state(undefined);
12
+ let extrasStore = $state(undefined);
13
+ let components = $state(undefined); // Svelte-specific
12
14
 
13
15
  const resetFormNode = (valuePathParts, schemaPathParts) => {
14
16
  console.log("RESET INPUT WRAPPER", valuePathParts, schemaPathParts);
@@ -48,11 +50,13 @@
48
50
  */
49
51
  }
50
52
 
51
- $: resetFormNode(valuePathParts, schemaPathParts);
53
+ $effect(() => {
54
+ resetFormNode(valuePathParts, schemaPathParts);
55
+ });
52
56
 
53
- $: component = (components && $schemaStore && components[$schemaStore.component])
57
+ let component = $derived((components && $schemaStore && components[$schemaStore.component])
54
58
  ? components[$schemaStore.component]
55
- : undefined;
59
+ : undefined);
56
60
  </script>
57
61
 
58
62
  {#if $schemaStore}
@@ -0,0 +1,15 @@
1
+ export default FormInputWrapper;
2
+ type FormInputWrapper = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<$$ComponentProps>): void;
5
+ };
6
+ declare const FormInputWrapper: import("svelte").Component<{
7
+ valuePathParts: any;
8
+ schemaPathParts: any;
9
+ formController: any;
10
+ }, {}, "">;
11
+ type $$ComponentProps = {
12
+ valuePathParts: any;
13
+ schemaPathParts: any;
14
+ formController: any;
15
+ };
@@ -1,12 +1,13 @@
1
1
  <script>
2
- export let components;
3
- export let formController;
4
- export let valuePathParts;
5
- export let schemaPathParts;
6
-
7
- export let schema;
8
- export let value = {};
9
- export let overrides;
2
+ let {
3
+ components,
4
+ formController,
5
+ valuePathParts,
6
+ schemaPathParts,
7
+ schema,
8
+ value = {},
9
+ overrides
10
+ } = $props();
10
11
  </script>
11
12
 
12
13
  <!-- TODO allow overriding path parts -->
@@ -0,0 +1,23 @@
1
+ export default FormObjectInput;
2
+ type FormObjectInput = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<$$ComponentProps>): void;
5
+ };
6
+ declare const FormObjectInput: import("svelte").Component<{
7
+ components: any;
8
+ formController: any;
9
+ valuePathParts: any;
10
+ schemaPathParts: any;
11
+ schema: any;
12
+ value?: Record<string, any>;
13
+ overrides: any;
14
+ }, {}, "">;
15
+ type $$ComponentProps = {
16
+ components: any;
17
+ formController: any;
18
+ valuePathParts: any;
19
+ schemaPathParts: any;
20
+ schema: any;
21
+ value?: Record<string, any>;
22
+ overrides: any;
23
+ };
@@ -1,6 +1,5 @@
1
1
  <script>
2
- export let value = undefined;
3
- export let extras = undefined;
2
+ let { value = undefined, extras = undefined } = $props();
4
3
  </script>
5
4
 
6
5
  <div style="border: 1px solid #ff0000; padding: 5px;">
@@ -0,0 +1,13 @@
1
+ export default FormTextInput;
2
+ type FormTextInput = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<$$ComponentProps>): void;
5
+ };
6
+ declare const FormTextInput: import("svelte").Component<{
7
+ value?: any;
8
+ extras?: any;
9
+ }, {}, "">;
10
+ type $$ComponentProps = {
11
+ value?: any;
12
+ extras?: any;
13
+ };
@@ -0,0 +1,7 @@
1
+ import Form from "./components/Form.svelte";
2
+ import formContext from "./components/formContext.js";
3
+ import FormInputWrapper from "./components/inputs/FormInputWrapper.svelte";
4
+ import FormArrayInput from "./components/inputs/FormArrayInput.svelte";
5
+ import FormObjectInput from "./components/inputs/FormObjectInput.svelte";
6
+ import FormTextInput from "./components/inputs/FormTextInput.svelte";
7
+ export { Form, formContext, FormInputWrapper, FormArrayInput, FormObjectInput, FormTextInput };
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ // Reexport your entry components here
2
+ import Form from "./components/Form.svelte";
3
+ import formContext from "./components/formContext.js";
4
+
5
+ // inputs
6
+ import FormInputWrapper from "./components/inputs/FormInputWrapper.svelte";
7
+ import FormArrayInput from "./components/inputs/FormArrayInput.svelte";
8
+ import FormObjectInput from "./components/inputs/FormObjectInput.svelte";
9
+ import FormTextInput from "./components/inputs/FormTextInput.svelte";
10
+
11
+ export {
12
+ Form,
13
+ formContext,
14
+
15
+ // inputs
16
+ FormInputWrapper,
17
+ FormArrayInput,
18
+ FormObjectInput,
19
+ FormTextInput
20
+ }
@@ -0,0 +1,8 @@
1
+ <script>
2
+ import { greet } from './greet';
3
+
4
+ let { host = 'SvelteKit', guest = 'Vitest' } = $props();
5
+ </script>
6
+
7
+ <h1>{greet(host)}</h1>
8
+ <p>{greet(guest)}</p>
@@ -0,0 +1,13 @@
1
+ export default Welcome;
2
+ type Welcome = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<$$ComponentProps>): void;
5
+ };
6
+ declare const Welcome: import("svelte").Component<{
7
+ host?: string;
8
+ guest?: string;
9
+ }, {}, "">;
10
+ type $$ComponentProps = {
11
+ host?: string;
12
+ guest?: string;
13
+ };
@@ -0,0 +1 @@
1
+ export function greet(name: any): string;
@@ -0,0 +1,3 @@
1
+ export function greet(name) {
2
+ return 'Hello, ' + name + '!';
3
+ }