@usefillo/dom 0.3.1 → 0.4.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/README.md CHANGED
@@ -9,10 +9,21 @@ npm i @usefillo/dom
9
9
  ```
10
10
 
11
11
  ```ts
12
- import { createClient, defineForm, renderForm } from "@usefillo/dom";
12
+ import { renderForm } from "@usefillo/dom";
13
13
  import "@usefillo/dom/styles.css"; // optional default theme — or bring your own
14
14
 
15
- const client = createClient({ key: "pk_…" }); // collects responses in Fillo
15
+ renderForm(document.querySelector("#fillo-form"), {
16
+ formId: "cust-feedback",
17
+ onSubmitted: (id) => console.log("response", id),
18
+ });
19
+ ```
20
+
21
+ Published `formId` embeds can fetch and submit without a publishable key. Use `createClient({ key })` only when syncing code-defined schemas, or when you need to point the SDK at a custom API origin.
22
+
23
+ ```ts
24
+ import { createClient, defineForm, renderForm } from "@usefillo/dom";
25
+
26
+ const client = createClient({ key: "pk_…" }); // Settings → Code-defined forms
16
27
  const form = defineForm({
17
28
  id: "cust-feedback",
18
29
  pages: [{ id: "p1", blocks: [
@@ -34,11 +45,16 @@ Or drop it in with a single script tag — the bundle exposes a global `Fillo`:
34
45
  <div id="fillo-form"></div>
35
46
  <script src="https://unpkg.com/@usefillo/dom/dist/standalone.global.js"></script>
36
47
  <script>
48
+ const client = Fillo.createClient({ key: "pk_…" });
37
49
  const form = Fillo.defineForm({ id: "cust-feedback", pages: [/* … */] });
38
- Fillo.renderForm(document.querySelector("#fillo-form"), { form });
50
+ Fillo.renderForm(document.querySelector("#fillo-form"), { form, client });
39
51
  </script>
40
52
  ```
41
53
 
54
+ For tiny feedback widgets, set `settings.submitMode: "auto"` on a select/rating/checkbox/dropdown/linear scale form. The default renderer hides the first submit button, submits after a complete discrete answer, and brings the submit button back if that answer opens a text or upload follow-up. Add `submissionLimit: "once_per_visitor"` for browser-scoped one-response feedback.
55
+
56
+ The default stylesheet follows system dark mode for unthemed embeds. Pass `theme: { colorScheme: "dark" }` or `"light"` when the host surface is known.
57
+
42
58
  Re-exports the core embedding surface from [`@usefillo/core`](https://www.npmjs.com/package/@usefillo/core) (`createClient`, `FilloClient`, `FormSchema`, validation/logic helpers, …).
43
59
 
44
60
  ## Links
package/dist/index.d.ts CHANGED
@@ -26,6 +26,7 @@ interface FieldRenderContext {
26
26
  field: Field;
27
27
  value: FieldValue;
28
28
  error: string | undefined;
29
+ ids: FilloDomFieldIds;
29
30
  api: FilloDomApi;
30
31
  setValue: (value: FieldValue, options?: {
31
32
  render?: boolean;
@@ -35,6 +36,13 @@ interface FieldRenderContext {
35
36
  }>, files: File[]) => Promise<void>;
36
37
  uploadProgress?: Map<string, number>;
37
38
  }
39
+ interface FilloDomFieldIds {
40
+ inputId: string;
41
+ labelId: string;
42
+ descriptionId: string;
43
+ errorId: string;
44
+ name: string;
45
+ }
38
46
  type FieldRenderer = (context: FieldRenderContext) => HTMLElement | null;
39
47
  interface RenderFormOptions {
40
48
  form?: FormSchema | CodeForm;
@@ -50,12 +58,6 @@ interface RenderFormOptions {
50
58
  onError?: (error: FilloError) => void;
51
59
  renderSuccess?: (api: FilloDomApi) => HTMLElement;
52
60
  renderError?: (error: FilloError) => HTMLElement;
53
- /**
54
- * Show the "Powered by Fillo" badge. Normally resolved from the workspace
55
- * plan by the server; removing it on a free workspace violates the Fillo
56
- * terms.
57
- */
58
- poweredBy?: boolean;
59
61
  }
60
62
  interface FilloDomForm {
61
63
  readonly element: HTMLElement;
@@ -97,4 +99,4 @@ declare function registerFilloElement(name?: string): void;
97
99
  */
98
100
  declare function createFormController(options: FormControllerOptions): FormController;
99
101
 
100
- export { type FieldRenderContext, type FieldRenderer, type FilloDomApi, type FilloDomForm, FilloFormElement, type FormStatus, type RenderFormOptions, createFormController, createFormElement, registerFilloElement, renderForm };
102
+ export { type FieldRenderContext, type FieldRenderer, type FilloDomApi, type FilloDomFieldIds, type FilloDomForm, FilloFormElement, type FormStatus, type RenderFormOptions, createFormController, createFormElement, registerFilloElement, renderForm };