svelte-json-schema-form 0.0.3 → 0.0.4-alpha2
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/README.md +44 -26
- package/{src → dist/components}/Form.stories.svelte +1 -1
- package/dist/components/Form.stories.svelte.d.ts +3 -0
- package/{src → dist/components}/Form.svelte +39 -40
- package/dist/components/Form.svelte.d.ts +35 -0
- package/dist/components/formContext.d.ts +2 -0
- package/dist/components/formDefaultInputComponents.d.ts +15 -0
- package/dist/components/formDefaultInputComponents.js +15 -0
- package/{src/components → dist/components/inputs}/FormActionButton.svelte +10 -9
- package/dist/components/inputs/FormActionButton.svelte.d.ts +25 -0
- package/{src/components → dist/components/inputs}/FormArrayInput.svelte +12 -11
- package/dist/components/inputs/FormArrayInput.svelte.d.ts +25 -0
- package/{src/components → dist/components/inputs}/FormCheckboxInput.svelte +1 -1
- package/dist/components/inputs/FormCheckboxInput.svelte.d.ts +11 -0
- package/{src/components → dist/components/inputs}/FormInputWrapper.svelte +15 -11
- package/dist/components/inputs/FormInputWrapper.svelte.d.ts +15 -0
- package/{src/components → dist/components/inputs}/FormObjectInput.svelte +9 -8
- package/dist/components/inputs/FormObjectInput.svelte.d.ts +23 -0
- package/{src/components → dist/components/inputs}/FormTextInput.svelte +1 -2
- package/dist/components/inputs/FormTextInput.svelte.d.ts +13 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +20 -0
- package/dist/vitest-examples/Welcome.svelte +8 -0
- package/dist/vitest-examples/Welcome.svelte.d.ts +13 -0
- package/dist/vitest-examples/greet.d.ts +1 -0
- package/dist/vitest-examples/greet.js +3 -0
- package/package.json +66 -36
- package/.storybook/main.ts +0 -19
- package/.storybook/preview.ts +0 -15
- package/.vscode/extensions.json +0 -3
- package/LICENSE +0 -21
- package/src/exports.js +0 -21
- package/src/formDefaultComponents.js +0 -15
- package/src/utils/svelteObjectStore.js +0 -35
- package/storybook-static/assets/Color-6VNJS4EI-BwbyGRpv.js +0 -1
- package/storybook-static/assets/DocsRenderer-NNNQARDV-Dv5gTx4J.js +0 -401
- package/storybook-static/assets/Form.stories-B9d26ABq.js +0 -1
- package/storybook-static/assets/Hello.stories-iStloLVx.js +0 -1
- package/storybook-static/assets/WithTooltip-V3YHNWJZ-Cu4QOpJO.js +0 -1
- package/storybook-static/assets/_commonjsHelpers-Cpj98o6Y.js +0 -1
- package/storybook-static/assets/collect-stories-C_xzNuNF.js +0 -1
- package/storybook-static/assets/entry-preview-ayMb_JX6.js +0 -5
- package/storybook-static/assets/entry-preview-docs-Dn-BUk6f.js +0 -7
- package/storybook-static/assets/formatter-SWP5E3XI-BDUqP36L.js +0 -156
- package/storybook-static/assets/iframe-COBy1vQP.js +0 -7
- package/storybook-static/assets/index-Bdfa_YSh.js +0 -1
- package/storybook-static/assets/index-Bw8VTzHM.js +0 -1
- package/storybook-static/assets/index-C0DyA3Eb.js +0 -3
- package/storybook-static/assets/index-Da9FSDFk.js +0 -1
- package/storybook-static/assets/index-DrFu-skq.js +0 -6
- package/storybook-static/assets/preview-9J5W8ogQ.js +0 -7
- package/storybook-static/assets/preview-BAz7FMXc.js +0 -396
- package/storybook-static/assets/preview-BCp7Wgbt.js +0 -27
- package/storybook-static/assets/preview-B_0crF9I.js +0 -1
- package/storybook-static/assets/preview-BcxrGG1y.js +0 -20
- package/storybook-static/assets/preview-CIwosuWp.js +0 -1
- package/storybook-static/assets/preview-Cv3rAi2i.js +0 -7
- package/storybook-static/assets/preview-D8VCGkL0.js +0 -17
- package/storybook-static/assets/preview-Db4Idchh.js +0 -1
- package/storybook-static/assets/syntaxhighlighter-B5GMVT5T-CFyDre8b.js +0 -1
- package/storybook-static/favicon.svg +0 -7
- package/storybook-static/iframe.html +0 -458
- package/storybook-static/index.html +0 -135
- package/storybook-static/index.json +0 -1
- package/storybook-static/project.json +0 -1
- package/storybook-static/sb-addons/essentials-actions-2/manager-bundle.js +0 -3
- package/storybook-static/sb-addons/essentials-actions-2/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-backgrounds-3/manager-bundle.js +0 -12
- package/storybook-static/sb-addons/essentials-backgrounds-3/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-controls-1/manager-bundle.js +0 -63
- package/storybook-static/sb-addons/essentials-controls-1/manager-bundle.js.LEGAL.txt +0 -18
- package/storybook-static/sb-addons/essentials-measure-6/manager-bundle.js +0 -3
- package/storybook-static/sb-addons/essentials-measure-6/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-outline-7/manager-bundle.js +0 -3
- package/storybook-static/sb-addons/essentials-outline-7/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-toolbars-5/manager-bundle.js +0 -3
- package/storybook-static/sb-addons/essentials-toolbars-5/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-viewport-4/manager-bundle.js +0 -3
- package/storybook-static/sb-addons/essentials-viewport-4/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/interactions-8/manager-bundle.js +0 -12
- package/storybook-static/sb-addons/interactions-8/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/links-0/manager-bundle.js +0 -3
- package/storybook-static/sb-addons/links-0/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/svelte-csf-preset-10/manager-bundle.js +0 -3
- package/storybook-static/sb-addons/svelte-csf-preset-10/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/svelte-csf-preset-9/manager-bundle.js +0 -3
- package/storybook-static/sb-addons/svelte-csf-preset-9/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-common-assets/fonts.css +0 -31
- package/storybook-static/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-bold.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-italic.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-regular.woff2 +0 -0
- package/storybook-static/sb-manager/WithTooltip-V3YHNWJZ-TRLNWEGW.js +0 -1
- package/storybook-static/sb-manager/chunk-4IYAVH3S.js +0 -348
- package/storybook-static/sb-manager/chunk-CXYKRFSY.js +0 -9
- package/storybook-static/sb-manager/chunk-LVLAH4SI.js +0 -7
- package/storybook-static/sb-manager/chunk-VFHDXWEA.js +0 -406
- package/storybook-static/sb-manager/chunk-ZEU7PDD3.js +0 -1
- package/storybook-static/sb-manager/formatter-SWP5E3XI-7BGIK6BL.js +0 -156
- package/storybook-static/sb-manager/globals-module-info.js +0 -1
- package/storybook-static/sb-manager/globals.js +0 -1
- package/storybook-static/sb-manager/index.js +0 -1
- package/storybook-static/sb-manager/runtime.js +0 -1
- package/storybook-static/sb-manager/syntaxhighlighter-B5GMVT5T-EA5ASEYD.js +0 -1
- package/storybook-static/sb-preview/globals.js +0 -1
- package/storybook-static/sb-preview/runtime.js +0 -112
- package/storybook-static/stories.json +0 -1
- package/svelte.config.js +0 -7
- package/tsconfig.json +0 -20
- package/tsconfig.node.json +0 -10
- package/vite.config.ts +0 -14
- /package/{src → dist/components}/formContext.js +0 -0
package/README.md
CHANGED
|
@@ -1,47 +1,65 @@
|
|
|
1
|
-
# Svelte
|
|
1
|
+
# Svelte library
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Everything you need to build a Svelte library, powered by [`sv`](https://npmjs.com/package/sv).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Read more about creating a library [in the docs](https://svelte.dev/docs/kit/packaging).
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Creating a project
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
If you're seeing this, you've probably already done this step. Congrats!
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
```sh
|
|
12
|
+
# create a new project in the current directory
|
|
13
|
+
npx sv create
|
|
12
14
|
|
|
13
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
39
|
+
## Building
|
|
27
40
|
|
|
28
|
-
|
|
41
|
+
To build your library:
|
|
29
42
|
|
|
30
|
-
|
|
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
|
-
|
|
53
|
+
You can preview the production build with `npm run preview`.
|
|
33
54
|
|
|
34
|
-
|
|
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
|
-
|
|
57
|
+
## Publishing
|
|
37
58
|
|
|
38
|
-
|
|
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
|
-
|
|
61
|
+
To publish your library to [npm](https://www.npmjs.com):
|
|
41
62
|
|
|
42
|
-
```
|
|
43
|
-
|
|
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,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
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
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
|
-
...
|
|
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
|
-
|
|
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
|
-
...
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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,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/inputs/FormInputWrapper.svelte";
|
|
11
|
+
import FormArrayInput from "./components/inputs/FormArrayInput.svelte";
|
|
12
|
+
import FormObjectInput from "./components/inputs/FormObjectInput.svelte";
|
|
13
|
+
import FormTextInput from "./components/inputs/FormTextInput.svelte";
|
|
14
|
+
import FormCheckboxInput from "./components/inputs/FormCheckboxInput.svelte";
|
|
15
|
+
import FormActionButton from "./components/inputs/FormActionButton.svelte";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import FormInputWrapper from "./components/inputs/FormInputWrapper.svelte";
|
|
2
|
+
import FormArrayInput from "./components/inputs/FormArrayInput.svelte";
|
|
3
|
+
import FormObjectInput from "./components/inputs/FormObjectInput.svelte";
|
|
4
|
+
import FormTextInput from "./components/inputs/FormTextInput.svelte";
|
|
5
|
+
import FormCheckboxInput from "./components/inputs/FormCheckboxInput.svelte";
|
|
6
|
+
import FormActionButton from "./components/inputs/FormActionButton.svelte";
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
wrapper: FormInputWrapper,
|
|
10
|
+
arrayInput: FormArrayInput,
|
|
11
|
+
objectInput: FormObjectInput,
|
|
12
|
+
textInput: FormTextInput,
|
|
13
|
+
booleanInput: FormCheckboxInput,
|
|
14
|
+
actionButton: FormActionButton
|
|
15
|
+
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
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
|
+
};
|
|
@@ -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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
53
|
+
$effect(() => {
|
|
54
|
+
resetFormNode(valuePathParts, schemaPathParts);
|
|
55
|
+
});
|
|
52
56
|
|
|
53
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
+
};
|
|
@@ -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
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -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,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;
|