@formbox/htmx 0.4.4 → 0.6.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.
Files changed (49) hide show
  1. package/dist/index.d.ts +720 -52
  2. package/dist/index.js +140 -59
  3. package/dist/templates/AnswerList.html.hbs +3 -0
  4. package/dist/templates/AnswerScaffold.html.hbs +3 -0
  5. package/dist/templates/Checkbox.html.hbs +3 -0
  6. package/dist/templates/CheckboxList.html.hbs +3 -0
  7. package/dist/templates/CustomOptionForm.html.hbs +3 -0
  8. package/dist/templates/DateInput.html.hbs +3 -0
  9. package/dist/templates/DateTimeInput.html.hbs +3 -0
  10. package/dist/templates/DisplayRenderer.html.hbs +3 -0
  11. package/dist/templates/Errors.html.hbs +3 -0
  12. package/dist/templates/FileInput.html.hbs +3 -0
  13. package/dist/templates/Flyover.html.hbs +3 -0
  14. package/dist/templates/Footer.html.hbs +3 -0
  15. package/dist/templates/Form.html.hbs +22 -4
  16. package/dist/templates/FormDescription.html.hbs +10 -0
  17. package/dist/templates/FormTitle.html.hbs +10 -0
  18. package/dist/templates/GroupList.html.hbs +3 -0
  19. package/dist/templates/GroupScaffold.html.hbs +3 -0
  20. package/dist/templates/Header.html.hbs +3 -0
  21. package/dist/templates/Help.html.hbs +3 -0
  22. package/dist/templates/InputGroup.html.hbs +3 -0
  23. package/dist/templates/Label.html.hbs +3 -0
  24. package/dist/templates/LabelContent.html.hbs +15 -0
  25. package/dist/templates/LanguageSelector.html.hbs +3 -0
  26. package/dist/templates/Legal.html.hbs +3 -0
  27. package/dist/templates/Link.html.hbs +3 -0
  28. package/dist/templates/Media.html.hbs +29 -0
  29. package/dist/templates/MultiSelectInput.html.hbs +3 -0
  30. package/dist/templates/NumberInput.html.hbs +3 -0
  31. package/dist/templates/OptionDisplay.html.hbs +3 -0
  32. package/dist/templates/OptionsLoading.html.hbs +3 -0
  33. package/dist/templates/Pagination.html.hbs +24 -0
  34. package/dist/templates/QuestionScaffold.html.hbs +3 -0
  35. package/dist/templates/RadioButton.html.hbs +3 -0
  36. package/dist/templates/RadioButtonList.html.hbs +3 -0
  37. package/dist/templates/SelectInput.html.hbs +3 -0
  38. package/dist/templates/ShortTextStyle.html.hbs +10 -0
  39. package/dist/templates/SignatureInput.html.hbs +3 -0
  40. package/dist/templates/SliderInput.html.hbs +3 -0
  41. package/dist/templates/SpinnerInput.html.hbs +3 -0
  42. package/dist/templates/Stack.html.hbs +3 -0
  43. package/dist/templates/SubmitButton.html.hbs +13 -0
  44. package/dist/templates/TabContainer.html.hbs +3 -0
  45. package/dist/templates/Table.html.hbs +3 -0
  46. package/dist/templates/TextArea.html.hbs +3 -0
  47. package/dist/templates/TextInput.html.hbs +3 -0
  48. package/dist/templates/TimeInput.html.hbs +3 -0
  49. package/package.json +10 -12
@@ -0,0 +1,29 @@
1
+ {{!--
2
+ Template: Media
3
+
4
+ Purpose:
5
+ - Renders item or answer-option attachment media and fallback links.
6
+
7
+ Inputs:
8
+ - attachment: source attachment object.
9
+ - id: stable media id when available.
10
+ - label: accessible fallback label.
11
+ - source: resolved URL or data URL, if available.
12
+ - contentType: lower-cased attachment content type, if available.
13
+ - kind/isFallback/isImage/isAudio/isVideo/isLink: selected media rendering branch.
14
+ --}}
15
+ {{#if isFallback}}
16
+ <span>{{label}}</span>
17
+ {{/if}}
18
+ {{#if isImage}}
19
+ <img{{{attr "src" source}}}{{{attr "alt" label}}}>
20
+ {{/if}}
21
+ {{#if isAudio}}
22
+ <audio controls{{{attr "id" id}}}{{{attr "src" source}}}></audio>
23
+ {{/if}}
24
+ {{#if isVideo}}
25
+ <video controls{{{attr "id" id}}}{{{attr "src" source}}}></video>
26
+ {{/if}}
27
+ {{#if isLink}}
28
+ <a{{{attr "id" id}}}{{{attr "href" source}}} target="_blank" rel="noreferrer">{{label}}</a>
29
+ {{/if}}
@@ -1,6 +1,9 @@
1
1
  {{!--
2
2
  Template: MultiSelectInput
3
3
 
4
+ Purpose:
5
+ - Renders a searchable multi-select choice control and preserved selections.
6
+
4
7
  Inputs:
5
8
  - id: fieldset id.
6
9
  - options: items with id, token, label, selected, disabled, and hiddenInput.
@@ -1,6 +1,9 @@
1
1
  {{!--
2
2
  Template: NumberInput
3
3
 
4
+ Purpose:
5
+ - Renders a numeric answer control with unit and comparator context.
6
+
4
7
  Inputs:
5
8
  - id: control id.
6
9
  - value/inputValue: numeric answer value prepared for the native input.
@@ -1,6 +1,9 @@
1
1
  {{!--
2
2
  Template: OptionDisplay
3
3
 
4
+ Purpose:
5
+ - Renders the visible content for one answer option.
6
+
4
7
  Inputs:
5
8
  - children: rendered option text.
6
9
  - prefix: optional option prefix.
@@ -1,6 +1,9 @@
1
1
  {{!--
2
2
  Template: OptionsLoading
3
3
 
4
+ Purpose:
5
+ - Renders the loading indicator for asynchronously resolved answer options.
6
+
4
7
  Inputs:
5
8
  - isLoading: true when options are loading.
6
9
  - loadingLabel: loading message text.
@@ -0,0 +1,24 @@
1
+ {{!--
2
+ Template: Pagination
3
+
4
+ Purpose:
5
+ - Renders page navigation controls for paginated questionnaires.
6
+
7
+ Inputs:
8
+ - current/total: current page number and total page count.
9
+ - disabledPrev/disabledNext: whether each navigation action is unavailable.
10
+ - actionName: form action field name.
11
+ - previousAction/nextAction: submitted action values for page navigation.
12
+ - previousId/nextId: stable button ids.
13
+ - previousLabel/nextLabel: visible button labels.
14
+ - navigationLabel/currentLabel/previousTargetLabel/nextTargetLabel: accessible pagination labels.
15
+ --}}
16
+ <nav>
17
+ {{#unless disabledPrev}}
18
+ <button type="submit"{{{attr "id" previousId}}}{{{attr "name" actionName}}}{{{attr "value" previousAction}}}>{{previousLabel}}</button>
19
+ {{/unless}}
20
+ <span>{{current}} / {{total}}</span>
21
+ {{#unless disabledNext}}
22
+ <button type="submit"{{{attr "id" nextId}}}{{{attr "name" actionName}}}{{{attr "value" nextAction}}}>{{nextLabel}}</button>
23
+ {{/unless}}
24
+ </nav>
@@ -1,6 +1,9 @@
1
1
  {{!--
2
2
  Template: QuestionScaffold
3
3
 
4
+ Purpose:
5
+ - Renders a question wrapper with header, errors, answer controls, and expanded content.
6
+
4
7
  Inputs:
5
8
  - linkId: question link id.
6
9
  - header/children/expandedChildren/errors/signature: rendered question sections.
@@ -1,6 +1,9 @@
1
1
  {{!--
2
2
  Template: RadioButton
3
3
 
4
+ Purpose:
5
+ - Renders one radio answer option input and its visible label.
6
+
4
7
  Inputs:
5
8
  - id: control id.
6
9
  - groupName: source radio group name, if supplied.
@@ -1,6 +1,9 @@
1
1
  {{!--
2
2
  Template: RadioButtonList
3
3
 
4
+ Purpose:
5
+ - Renders a single-select choice question as a radio option list.
6
+
4
7
  Inputs:
5
8
  - id: fieldset id.
6
9
  - options: items with id, token, label, checked, and disabled.
@@ -1,6 +1,9 @@
1
1
  {{!--
2
2
  Template: SelectInput
3
3
 
4
+ Purpose:
5
+ - Renders a select/open-choice dropdown with search and custom-option controls.
6
+
4
7
  Inputs:
5
8
  - id: select id.
6
9
  - value: selected option token.
@@ -0,0 +1,10 @@
1
+ {{!--
2
+ Template: ShortTextStyle
3
+
4
+ Purpose:
5
+ - Renders responsive CSS that swaps long labels for short labels on narrow screens.
6
+
7
+ Inputs:
8
+ - no inputs.
9
+ --}}
10
+ <style>[data-fb-label-short]{display:none}@media (max-width:40rem){[data-fb-label-full]{display:none}[data-fb-label-short]{display:inline}}</style>
@@ -1,6 +1,9 @@
1
1
  {{!--
2
2
  Template: SignatureInput
3
3
 
4
+ Purpose:
5
+ - Renders a signature answer control and its submitted value field.
6
+
4
7
  Inputs:
5
8
  - id: control id.
6
9
  - value/inputValue: serialized signature value.
@@ -1,6 +1,9 @@
1
1
  {{!--
2
2
  Template: SliderInput
3
3
 
4
+ Purpose:
5
+ - Renders a numeric answer as a range slider.
6
+
4
7
  Inputs:
5
8
  - id: control id.
6
9
  - value/inputValue: numeric answer value prepared for the native range input.
@@ -1,6 +1,9 @@
1
1
  {{!--
2
2
  Template: SpinnerInput
3
3
 
4
+ Purpose:
5
+ - Renders a numeric answer as a stepper-style input.
6
+
4
7
  Inputs:
5
8
  - id: control id.
6
9
  - value/inputValue: numeric answer value prepared for the native number input.
@@ -1,6 +1,9 @@
1
1
  {{!--
2
2
  Template: Stack
3
3
 
4
+ Purpose:
5
+ - Renders a generic stack of child content.
6
+
4
7
  Inputs:
5
8
  - children: rendered stacked content.
6
9
  --}}
@@ -0,0 +1,13 @@
1
+ {{!--
2
+ Template: SubmitButton
3
+
4
+ Purpose:
5
+ - Renders the main form submit action.
6
+
7
+ Inputs:
8
+ - id: stable submit button id.
9
+ - actionName: form action field name.
10
+ - value: submitted action value.
11
+ - label: visible submit label.
12
+ --}}
13
+ <button type="submit"{{{attr "id" id}}}{{{attr "name" actionName}}}{{{attr "value" value}}}>{{label}}</button>
@@ -1,6 +1,9 @@
1
1
  {{!--
2
2
  Template: TabContainer
3
3
 
4
+ Purpose:
5
+ - Renders tabbed group navigation and the active panel content.
6
+
4
7
  Inputs:
5
8
  - linkId: tab group link id.
6
9
  - header/errors: rendered tab group sections.
@@ -1,6 +1,9 @@
1
1
  {{!--
2
2
  Template: Table
3
3
 
4
+ Purpose:
5
+ - Renders matrix-style controls from prepared columns, rows, and cells.
6
+
4
7
  Inputs:
5
8
  - hasRowHeader: true when rows need a header column.
6
9
  - columns: column items with token, content, errors, width, widthStyle, and isLoading.
@@ -1,6 +1,9 @@
1
1
  {{!--
2
2
  Template: TextArea
3
3
 
4
+ Purpose:
5
+ - Renders a multi-line text answer control.
6
+
4
7
  Inputs:
5
8
  - id: control id.
6
9
  - value: submitted text value.
@@ -1,6 +1,9 @@
1
1
  {{!--
2
2
  Template: TextInput
3
3
 
4
+ Purpose:
5
+ - Renders a scalar text-style answer control.
6
+
4
7
  Inputs:
5
8
  - id: control id.
6
9
  - type/inputType: requested and rendered native input type.
@@ -1,6 +1,9 @@
1
1
  {{!--
2
2
  Template: TimeInput
3
3
 
4
+ Purpose:
5
+ - Renders a time answer control.
6
+
4
7
  Inputs:
5
8
  - id: control id.
6
9
  - value: submitted time string.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formbox/htmx",
3
- "version": "0.4.4",
3
+ "version": "0.6.0",
4
4
  "description": "Server-rendered HTMX HTML renderer for Formbox FHIR Questionnaires",
5
5
  "private": false,
6
6
  "type": "module",
@@ -26,29 +26,27 @@
26
26
  "fhirpath": "^4.6.0",
27
27
  "handlebars": "^4.7.9",
28
28
  "mobx": "^6.15.0",
29
- "mobx-react-lite": "^4.1.1",
30
29
  "mobx-utils": "^6.1.1",
31
- "react": "^19.2.3",
32
- "react-dom": "^19.2.3",
33
- "@formbox/renderer": "0.4.1",
34
- "@formbox/strings": "0.4.1",
35
- "@formbox/theme": "0.4.1",
36
- "@formbox/fhir": "0.4.1"
30
+ "preact": "^10.29.2",
31
+ "preact-render-to-string": "^6.7.0",
32
+ "@formbox/fhir": "0.4.1",
33
+ "@formbox/strings": "0.4.1"
37
34
  },
38
35
  "devDependencies": {
39
36
  "@playwright/test": "^1.60.0",
40
37
  "@types/react": "^19.2.8",
41
- "@types/react-dom": "^19.2.3",
42
38
  "htmx.org": "^2.0.10",
43
39
  "typescript": "~5.9.3",
44
40
  "vite": "^7.3.1",
45
41
  "vite-plugin-dts": "^4.5.4",
46
- "vitest": "^4.0.17"
42
+ "vitest": "^4.0.17",
43
+ "@formbox/theme": "0.4.1",
44
+ "@formbox/renderer": "0.4.1"
47
45
  },
48
46
  "scripts": {
49
47
  "build": "tsc -b ./tsconfig.lib.json && vite build",
50
- "demo": "bun run ./demo/server.ts",
51
- "dev": "bun run ./demo/server.ts",
48
+ "demo": "bun run build && bun ./demo/server.ts",
49
+ "dev": "bun run build && bun ./demo/server.ts",
52
50
  "lint": "eslint .",
53
51
  "test:e2e": "pnpm run build && playwright test e2e",
54
52
  "typecheck": "tsc --noEmit -p tsconfig.lib.json",