@formbox/htmx 0.6.0 → 0.7.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
@@ -113,7 +113,18 @@ const templates = {
113
113
  ...compileTemplates({
114
114
  Form: `
115
115
  <form{{{attrs attributes}}} hx-target="#questionnaire-app" hx-swap="morphdom">
116
- {{{fields}}}
116
+ {{{hiddenFields}}}
117
+ {{{shortTextStyle}}}
118
+ {{{titleHtml}}}
119
+ {{{descriptionHtml}}}
120
+ {{{languageSelector}}}
121
+ {{{errors}}}
122
+ {{{before}}}
123
+ {{{children}}}
124
+ {{{after}}}
125
+ {{{signature}}}
126
+ {{{paginationHtml}}}
127
+ {{{submitButton}}}
117
128
  </form>
118
129
  `,
119
130
  }),
@@ -162,7 +173,7 @@ Create one renderer instance for one request/render cycle:
162
173
 
163
174
  1. `new QuestionnaireRenderer(options)` creates a request-local renderer.
164
175
  2. `await renderer.process(formData)` applies submitted form state and returns submit result.
165
- 3. `await renderer.render()` returns HTML fields for the current renderer state.
176
+ 3. `await renderer.render()` returns form HTML for the current renderer state.
166
177
  4. `renderer.getQuestionnaireResponse()` reads the current FHIR response.
167
178
  5. `renderer.dispose()` releases the underlying renderer store.
168
179
 
@@ -256,7 +267,18 @@ const templates = {
256
267
  Form: `
257
268
  <form{{{attrs attributes}}}>
258
269
  ${csrf}
259
- {{{fields}}}
270
+ {{{hiddenFields}}}
271
+ {{{shortTextStyle}}}
272
+ {{{titleHtml}}}
273
+ {{{descriptionHtml}}}
274
+ {{{languageSelector}}}
275
+ {{{errors}}}
276
+ {{{before}}}
277
+ {{{children}}}
278
+ {{{after}}}
279
+ {{{signature}}}
280
+ {{{paginationHtml}}}
281
+ {{{submitButton}}}
260
282
  </form>
261
283
  `,
262
284
  }),
@@ -305,8 +327,21 @@ Callbacks and Handlebars strings can be mixed:
305
327
  ```ts
306
328
  const templates = compileTemplates({
307
329
  TextInput: `<input{{{fieldAttributes}}}{{{attr "id" id}}}>`,
308
- Form({ attributes, fields }) {
309
- return `<form${htmlAttributes(attributes)}>${fields}</form>`;
330
+ Form(properties) {
331
+ return `<form${htmlAttributes(properties.attributes)}>${[
332
+ properties.hiddenFields,
333
+ properties.shortTextStyle,
334
+ properties.titleHtml ?? "",
335
+ properties.descriptionHtml ?? "",
336
+ properties.languageSelector ?? "",
337
+ properties.errors ?? "",
338
+ properties.before ?? "",
339
+ properties.children,
340
+ properties.after ?? "",
341
+ properties.signature ?? "",
342
+ properties.paginationHtml ?? "",
343
+ properties.submitButton,
344
+ ].join("")}</form>`;
310
345
  },
311
346
  });
312
347
  ```
@@ -348,8 +383,9 @@ Available Handlebars helpers:
348
383
  - `{{{attrs attributes}}}` renders an object of escaped HTML attributes.
349
384
  - `{{{fieldAttributes}}}` renders `data-fb-link-id`, `data-fb-field`, `name`, and `hx-include` for the current field.
350
385
 
351
- Use triple braces for renderer-provided HTML slots such as `fields`, `children`,
352
- `label`, `errors`, and `customOptionForm`.
386
+ Use triple braces for renderer-provided HTML slots such as `hiddenFields`,
387
+ `children`, `paginationHtml`, `submitButton`, `label`, `errors`, and
388
+ `customOptionForm`.
353
389
 
354
390
  Default templates and user templates use the same data shape. The package does
355
391
  not keep a separate JSX fallback path.
package/dist/index.d.ts CHANGED
@@ -289,10 +289,6 @@ export declare type FormDescriptionTemplateProperties = {
289
289
  readonly description: string;
290
290
  };
291
291
 
292
- declare type FormFieldsProperties = Omit<FormTemplateProperties, "attributes" | "fields">;
293
-
294
- export declare function formFieldsTemplate(properties: FormFieldsProperties): string;
295
-
296
292
  declare type FormPagination = {
297
293
  current: number;
298
294
  total: number;
@@ -323,7 +319,6 @@ export declare type FormTemplateProperties = Omit<TemplateBase<FormProperties>,
323
319
  readonly before?: string | undefined;
324
320
  readonly children: string;
325
321
  readonly errors?: string | undefined;
326
- readonly fields: string;
327
322
  readonly hiddenFields: string;
328
323
  readonly attributes: HtmlAttributes;
329
324
  readonly titleHtml?: string | undefined;
package/dist/index.js CHANGED
@@ -59715,22 +59715,6 @@ function mediaHtml(templates, attachment, fallbackLabel, id2) {
59715
59715
  isLink: kind === "link"
59716
59716
  });
59717
59717
  }
59718
- function formFieldsTemplate(properties) {
59719
- return [
59720
- properties.hiddenFields,
59721
- properties.shortTextStyle,
59722
- properties.titleHtml ?? "",
59723
- properties.descriptionHtml ?? "",
59724
- properties.languageSelector ?? "",
59725
- properties.errors ?? "",
59726
- properties.before ?? "",
59727
- properties.children,
59728
- properties.after ?? "",
59729
- properties.signature ?? "",
59730
- properties.paginationHtml ?? "",
59731
- properties.submitButton
59732
- ].join("");
59733
- }
59734
59718
  function pageHiddenField(currentPage) {
59735
59719
  return `<input type="hidden" name="${PAGE_FIELD}" value="${String(currentPage ?? 1)}">`;
59736
59720
  }
@@ -61623,11 +61607,9 @@ function Form(properties) {
61623
61607
  submitLabel,
61624
61608
  submitButton
61625
61609
  };
61626
- const fields = formFieldsTemplate(formProperties);
61627
61610
  return renderTemplate(templates.Form, {
61628
61611
  ...formProperties,
61629
- attributes: { id: id2, ...defaultAttributes(action2) },
61630
- fields
61612
+ attributes: { id: id2, ...defaultAttributes(action2) }
61631
61613
  });
61632
61614
  }
61633
61615
  function formatPageString(template, page) {
@@ -7,7 +7,6 @@ Purpose:
7
7
  Inputs:
8
8
  - attributes: native form attributes generated by the renderer.
9
9
  - hiddenFields: renderer-owned hidden protocol field html.
10
- - fields: legacy full rendered field html.
11
10
  - customExtensions: source extension values, if supplied.
12
11
  - shortTextStyle: responsive short-label CSS markup when short labels are present.
13
12
  - titleHtml/descriptionHtml/languageSelector/errors/before/children/after/signature: rendered form sections.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formbox/htmx",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Server-rendered HTMX HTML renderer for Formbox FHIR Questionnaires",
5
5
  "private": false,
6
6
  "type": "module",
@@ -40,8 +40,8 @@
40
40
  "vite": "^7.3.1",
41
41
  "vite-plugin-dts": "^4.5.4",
42
42
  "vitest": "^4.0.17",
43
- "@formbox/theme": "0.4.1",
44
- "@formbox/renderer": "0.4.1"
43
+ "@formbox/renderer": "0.4.1",
44
+ "@formbox/theme": "0.4.1"
45
45
  },
46
46
  "scripts": {
47
47
  "build": "tsc -b ./tsconfig.lib.json && vite build",