@usefillo/dom 0.2.0
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/LICENSE +21 -0
- package/README.md +47 -0
- package/dist/index.d.ts +87 -0
- package/dist/index.js +920 -0
- package/dist/standalone.global.js +5741 -0
- package/dist/styles.css +382 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fillo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# @usefillo/dom
|
|
2
|
+
|
|
3
|
+
Framework-agnostic DOM renderer, web component, and standalone browser bundle for [Fillo](https://fillo.so) — forms that render **inside your own product**, no iframe. Use it with Vue, Svelte, Astro, or plain browser JavaScript.
|
|
4
|
+
|
|
5
|
+
### 📚 Full documentation → **[fillo.so/docs](https://fillo.so/docs)**
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm i @usefillo/dom
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { defineForm, renderForm } from "@usefillo/dom";
|
|
13
|
+
import "@usefillo/dom/styles.css"; // optional default theme — or bring your own
|
|
14
|
+
|
|
15
|
+
const form = defineForm({
|
|
16
|
+
id: "cust-feedback",
|
|
17
|
+
pages: [{ id: "p1", blocks: [
|
|
18
|
+
{ id: "email", kind: "email", label: "Work email", required: true },
|
|
19
|
+
{ id: "msg", kind: "long_text", label: "What should we know?" },
|
|
20
|
+
] }],
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
renderForm(document.querySelector("#fillo-form"), {
|
|
24
|
+
form,
|
|
25
|
+
onSubmit: async (data) => console.log(data),
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or drop it in with a single script tag — the bundle exposes a global `Fillo`:
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<div id="fillo-form"></div>
|
|
33
|
+
<script src="https://unpkg.com/@usefillo/dom/dist/standalone.global.js"></script>
|
|
34
|
+
<script>
|
|
35
|
+
const form = Fillo.defineForm({ id: "cust-feedback", pages: [/* … */] });
|
|
36
|
+
Fillo.renderForm(document.querySelector("#fillo-form"), { form });
|
|
37
|
+
</script>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Re-exports the core embedding surface from [`@usefillo/core`](https://www.npmjs.com/package/@usefillo/core) (`createClient`, `FilloClient`, `FormSchema`, validation/logic helpers, …).
|
|
41
|
+
|
|
42
|
+
## Links
|
|
43
|
+
|
|
44
|
+
- **Docs:** [fillo.so/docs](https://fillo.so/docs)
|
|
45
|
+
- **Website:** [fillo.so](https://fillo.so)
|
|
46
|
+
|
|
47
|
+
MIT licensed.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Field, FieldValue, FormSchema, FilloClient, ResponseData, FormPage, Block, CodeForm, FormTheme, FieldKind, FilloError } from '@usefillo/core';
|
|
2
|
+
export { CodeForm, Field, FieldKind, FieldValue, FileValue, FilloClient, FilloClientOptions, FilloError, FormController, FormControllerOptions, FormControllerState, FormSchema, FormTheme, ResponseData, createClient, createFormController, defineForm } from '@usefillo/core';
|
|
3
|
+
|
|
4
|
+
type FormStatus = "loading" | "idle" | "submitting" | "submitted" | "error" | "closed";
|
|
5
|
+
interface FilloDomApi {
|
|
6
|
+
form: FormSchema;
|
|
7
|
+
formId?: string;
|
|
8
|
+
client?: FilloClient;
|
|
9
|
+
data: ResponseData;
|
|
10
|
+
errors: Record<string, string>;
|
|
11
|
+
status: FormStatus;
|
|
12
|
+
pageIndex: number;
|
|
13
|
+
pageCount: number;
|
|
14
|
+
page: FormPage;
|
|
15
|
+
blocks: Block[];
|
|
16
|
+
isFirstPage: boolean;
|
|
17
|
+
isLastPage: boolean;
|
|
18
|
+
setValue: (fieldId: string, value: FieldValue, options?: {
|
|
19
|
+
render?: boolean;
|
|
20
|
+
}) => void;
|
|
21
|
+
next: () => void;
|
|
22
|
+
back: () => void;
|
|
23
|
+
submit: () => Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
interface FieldRenderContext {
|
|
26
|
+
field: Field;
|
|
27
|
+
value: FieldValue;
|
|
28
|
+
error: string | undefined;
|
|
29
|
+
api: FilloDomApi;
|
|
30
|
+
setValue: (value: FieldValue, options?: {
|
|
31
|
+
render?: boolean;
|
|
32
|
+
}) => void;
|
|
33
|
+
uploadFiles?: (field: Extract<Field, {
|
|
34
|
+
kind: "file_upload";
|
|
35
|
+
}>, files: File[]) => Promise<void>;
|
|
36
|
+
uploadProgress?: Map<string, number>;
|
|
37
|
+
}
|
|
38
|
+
type FieldRenderer = (context: FieldRenderContext) => HTMLElement | null;
|
|
39
|
+
interface RenderFormOptions {
|
|
40
|
+
form?: FormSchema | CodeForm;
|
|
41
|
+
client?: FilloClient;
|
|
42
|
+
formId?: string;
|
|
43
|
+
theme?: FormTheme;
|
|
44
|
+
initialData?: ResponseData;
|
|
45
|
+
className?: string;
|
|
46
|
+
components?: Partial<Record<FieldKind, FieldRenderer>>;
|
|
47
|
+
customComponents?: Record<string, FieldRenderer>;
|
|
48
|
+
onChange?: (data: ResponseData) => void;
|
|
49
|
+
onSubmitted?: (responseId: string | undefined, data: ResponseData) => void;
|
|
50
|
+
onSubmit?: (data: ResponseData) => Promise<void> | void;
|
|
51
|
+
onError?: (error: FilloError) => void;
|
|
52
|
+
renderSuccess?: (api: FilloDomApi) => HTMLElement;
|
|
53
|
+
renderError?: (error: FilloError) => HTMLElement;
|
|
54
|
+
}
|
|
55
|
+
interface FilloDomForm {
|
|
56
|
+
readonly element: HTMLElement;
|
|
57
|
+
readonly status: FormStatus;
|
|
58
|
+
readonly data: ResponseData;
|
|
59
|
+
readonly form: FormSchema | null;
|
|
60
|
+
setValue(fieldId: string, value: FieldValue): void;
|
|
61
|
+
next(): void;
|
|
62
|
+
back(): void;
|
|
63
|
+
submit(): Promise<void>;
|
|
64
|
+
destroy(): void;
|
|
65
|
+
}
|
|
66
|
+
declare function renderForm(target: HTMLElement | string, options: RenderFormOptions): FilloDomForm;
|
|
67
|
+
declare function createFormElement(options: RenderFormOptions): HTMLElement;
|
|
68
|
+
declare class FilloFormElement extends HTMLElement {
|
|
69
|
+
private instance;
|
|
70
|
+
private assignedForm;
|
|
71
|
+
private assignedClient;
|
|
72
|
+
private assignedTheme;
|
|
73
|
+
private assignedInitialData;
|
|
74
|
+
static get observedAttributes(): string[];
|
|
75
|
+
connectedCallback(): void;
|
|
76
|
+
disconnectedCallback(): void;
|
|
77
|
+
attributeChangedCallback(): void;
|
|
78
|
+
set form(value: FormSchema | CodeForm | undefined);
|
|
79
|
+
get form(): FormSchema | CodeForm | undefined;
|
|
80
|
+
set client(value: FilloClient | undefined);
|
|
81
|
+
set theme(value: FormTheme | undefined);
|
|
82
|
+
set initialData(value: ResponseData | undefined);
|
|
83
|
+
private mount;
|
|
84
|
+
}
|
|
85
|
+
declare function registerFilloElement(name?: string): void;
|
|
86
|
+
|
|
87
|
+
export { type FieldRenderContext, type FieldRenderer, type FilloDomApi, type FilloDomForm, FilloFormElement, type FormStatus, type RenderFormOptions, createFormElement, registerFilloElement, renderForm };
|