@welshare/questionnaire 0.1.1 → 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.
Files changed (96) hide show
  1. package/README.md +151 -0
  2. package/dist/esm/components/bmi-form.d.ts +68 -0
  3. package/dist/esm/components/bmi-form.d.ts.map +1 -0
  4. package/dist/esm/components/bmi-form.js +138 -0
  5. package/dist/esm/components/question-renderer.d.ts +6 -1
  6. package/dist/esm/components/question-renderer.d.ts.map +1 -1
  7. package/dist/esm/components/question-renderer.js +49 -14
  8. package/dist/esm/components/questions/decimal-question.d.ts +8 -1
  9. package/dist/esm/components/questions/decimal-question.d.ts.map +1 -1
  10. package/dist/esm/components/questions/decimal-question.js +19 -1
  11. package/dist/esm/components/questions/multiple-choice-question.d.ts.map +1 -1
  12. package/dist/esm/components/questions/multiple-choice-question.js +2 -2
  13. package/dist/esm/contexts/questionnaire-context.d.ts.map +1 -1
  14. package/dist/esm/contexts/questionnaire-context.js +3 -2
  15. package/dist/esm/index.d.ts +6 -2
  16. package/dist/esm/index.d.ts.map +1 -1
  17. package/dist/esm/index.js +5 -1
  18. package/dist/esm/lib/bmi-helpers.d.ts +50 -0
  19. package/dist/esm/lib/bmi-helpers.d.ts.map +1 -0
  20. package/dist/esm/lib/bmi-helpers.js +69 -0
  21. package/dist/esm/lib/constants.d.ts +94 -0
  22. package/dist/esm/lib/constants.d.ts.map +1 -0
  23. package/dist/esm/lib/constants.js +93 -0
  24. package/dist/esm/lib/questionnaire-utils.d.ts +21 -1
  25. package/dist/esm/lib/questionnaire-utils.d.ts.map +1 -1
  26. package/dist/esm/lib/questionnaire-utils.js +85 -4
  27. package/dist/esm/types/fhir.d.ts +1 -0
  28. package/dist/esm/types/fhir.d.ts.map +1 -1
  29. package/dist/esm/types/index.d.ts +25 -0
  30. package/dist/esm/types/index.d.ts.map +1 -1
  31. package/dist/styles.css +108 -0
  32. package/package.json +17 -6
  33. package/dist/node_modules/@welshare/questionnaire/.tshy/build.json +0 -8
  34. package/dist/node_modules/@welshare/questionnaire/.tshy/esm.json +0 -16
  35. package/dist/node_modules/@welshare/questionnaire/LICENSE +0 -7
  36. package/dist/node_modules/@welshare/questionnaire/README.md +0 -173
  37. package/dist/node_modules/@welshare/questionnaire/dist/esm/components/debug-section.d.ts +0 -44
  38. package/dist/node_modules/@welshare/questionnaire/dist/esm/components/debug-section.d.ts.map +0 -1
  39. package/dist/node_modules/@welshare/questionnaire/dist/esm/components/debug-section.js +0 -28
  40. package/dist/node_modules/@welshare/questionnaire/dist/esm/components/question-renderer.d.ts +0 -80
  41. package/dist/node_modules/@welshare/questionnaire/dist/esm/components/question-renderer.d.ts.map +0 -1
  42. package/dist/node_modules/@welshare/questionnaire/dist/esm/components/question-renderer.js +0 -159
  43. package/dist/node_modules/@welshare/questionnaire/dist/esm/components/questions/boolean-question.d.ts +0 -15
  44. package/dist/node_modules/@welshare/questionnaire/dist/esm/components/questions/boolean-question.d.ts.map +0 -1
  45. package/dist/node_modules/@welshare/questionnaire/dist/esm/components/questions/boolean-question.js +0 -19
  46. package/dist/node_modules/@welshare/questionnaire/dist/esm/components/questions/choice-question.d.ts +0 -19
  47. package/dist/node_modules/@welshare/questionnaire/dist/esm/components/questions/choice-question.d.ts.map +0 -1
  48. package/dist/node_modules/@welshare/questionnaire/dist/esm/components/questions/choice-question.js +0 -23
  49. package/dist/node_modules/@welshare/questionnaire/dist/esm/components/questions/decimal-question.d.ts +0 -12
  50. package/dist/node_modules/@welshare/questionnaire/dist/esm/components/questions/decimal-question.d.ts.map +0 -1
  51. package/dist/node_modules/@welshare/questionnaire/dist/esm/components/questions/decimal-question.js +0 -7
  52. package/dist/node_modules/@welshare/questionnaire/dist/esm/components/questions/integer-question.d.ts +0 -18
  53. package/dist/node_modules/@welshare/questionnaire/dist/esm/components/questions/integer-question.d.ts.map +0 -1
  54. package/dist/node_modules/@welshare/questionnaire/dist/esm/components/questions/integer-question.js +0 -24
  55. package/dist/node_modules/@welshare/questionnaire/dist/esm/components/questions/multiple-choice-question.d.ts +0 -20
  56. package/dist/node_modules/@welshare/questionnaire/dist/esm/components/questions/multiple-choice-question.d.ts.map +0 -1
  57. package/dist/node_modules/@welshare/questionnaire/dist/esm/components/questions/multiple-choice-question.js +0 -39
  58. package/dist/node_modules/@welshare/questionnaire/dist/esm/components/questions/string-question.d.ts +0 -12
  59. package/dist/node_modules/@welshare/questionnaire/dist/esm/components/questions/string-question.d.ts.map +0 -1
  60. package/dist/node_modules/@welshare/questionnaire/dist/esm/components/questions/string-question.js +0 -7
  61. package/dist/node_modules/@welshare/questionnaire/dist/esm/contexts/questionnaire-context.d.ts +0 -41
  62. package/dist/node_modules/@welshare/questionnaire/dist/esm/contexts/questionnaire-context.d.ts.map +0 -1
  63. package/dist/node_modules/@welshare/questionnaire/dist/esm/contexts/questionnaire-context.js +0 -350
  64. package/dist/node_modules/@welshare/questionnaire/dist/esm/index.d.ts +0 -7
  65. package/dist/node_modules/@welshare/questionnaire/dist/esm/index.d.ts.map +0 -1
  66. package/dist/node_modules/@welshare/questionnaire/dist/esm/index.js +0 -6
  67. package/dist/node_modules/@welshare/questionnaire/dist/esm/lib/questionnaire-utils.d.ts +0 -33
  68. package/dist/node_modules/@welshare/questionnaire/dist/esm/lib/questionnaire-utils.d.ts.map +0 -1
  69. package/dist/node_modules/@welshare/questionnaire/dist/esm/lib/questionnaire-utils.js +0 -99
  70. package/dist/node_modules/@welshare/questionnaire/dist/esm/package.json +0 -3
  71. package/dist/node_modules/@welshare/questionnaire/dist/esm/types/fhir.d.ts +0 -117
  72. package/dist/node_modules/@welshare/questionnaire/dist/esm/types/fhir.d.ts.map +0 -1
  73. package/dist/node_modules/@welshare/questionnaire/dist/esm/types/fhir.js +0 -3
  74. package/dist/node_modules/@welshare/questionnaire/dist/esm/types/index.d.ts +0 -51
  75. package/dist/node_modules/@welshare/questionnaire/dist/esm/types/index.d.ts.map +0 -1
  76. package/dist/node_modules/@welshare/questionnaire/dist/esm/types/index.js +0 -1
  77. package/dist/node_modules/@welshare/questionnaire/dist/styles.css +0 -467
  78. package/dist/node_modules/@welshare/questionnaire/dist/tokens.css +0 -130
  79. package/dist/node_modules/@welshare/questionnaire/package.json +0 -85
  80. package/dist/node_modules/@welshare/questionnaire/src/components/debug-section.tsx +0 -116
  81. package/dist/node_modules/@welshare/questionnaire/src/components/question-renderer.tsx +0 -368
  82. package/dist/node_modules/@welshare/questionnaire/src/components/questionnaire-styles.css +0 -467
  83. package/dist/node_modules/@welshare/questionnaire/src/components/questionnaire-tokens.css +0 -130
  84. package/dist/node_modules/@welshare/questionnaire/src/components/questions/boolean-question.tsx +0 -72
  85. package/dist/node_modules/@welshare/questionnaire/src/components/questions/choice-question.tsx +0 -68
  86. package/dist/node_modules/@welshare/questionnaire/src/components/questions/decimal-question.tsx +0 -32
  87. package/dist/node_modules/@welshare/questionnaire/src/components/questions/integer-question.tsx +0 -87
  88. package/dist/node_modules/@welshare/questionnaire/src/components/questions/multiple-choice-question.tsx +0 -119
  89. package/dist/node_modules/@welshare/questionnaire/src/components/questions/string-question.tsx +0 -31
  90. package/dist/node_modules/@welshare/questionnaire/src/contexts/questionnaire-context.tsx +0 -499
  91. package/dist/node_modules/@welshare/questionnaire/src/index.ts +0 -41
  92. package/dist/node_modules/@welshare/questionnaire/src/lib/__tests__/questionnaire-utils.test.ts +0 -578
  93. package/dist/node_modules/@welshare/questionnaire/src/lib/questionnaire-utils.ts +0 -122
  94. package/dist/node_modules/@welshare/questionnaire/src/types/fhir.ts +0 -126
  95. package/dist/node_modules/@welshare/questionnaire/src/types/index.ts +0 -44
  96. package/dist/node_modules/@welshare/questionnaire/tsconfig.json +0 -16
package/dist/styles.css CHANGED
@@ -465,3 +465,111 @@
465
465
  }
466
466
  }
467
467
 
468
+ /* === Question Label Row with Helper === */
469
+ .wq-question-label-row {
470
+ display: flex;
471
+ justify-content: space-between;
472
+ align-items: center;
473
+ gap: var(--wq-spacing-sm, 0.5rem);
474
+ }
475
+
476
+ .wq-question-helper-trigger {
477
+ flex-shrink: 0;
478
+ }
479
+
480
+ /* === BMI Form === */
481
+ .wq-bmi-form {
482
+ display: flex;
483
+ flex-direction: column;
484
+ gap: var(--wq-space-lg);
485
+ }
486
+
487
+ .wq-bmi-unit-toggle {
488
+ display: inline-flex;
489
+ background-color: var(--wq-color-background);
490
+ border-radius: var(--wq-radius-md);
491
+ padding: 4px;
492
+ gap: 4px;
493
+ align-self: flex-start;
494
+ }
495
+
496
+ .wq-bmi-unit-option {
497
+ padding: 8px 24px;
498
+ border: none;
499
+ background-color: transparent;
500
+ border-radius: calc(var(--wq-radius-md) - 2px);
501
+ cursor: pointer;
502
+ transition: all var(--wq-transition-fast);
503
+ font-size: var(--wq-font-size-base);
504
+ font-weight: var(--wq-font-weight-medium);
505
+ color: var(--wq-color-text-secondary);
506
+ font-family: inherit;
507
+ white-space: nowrap;
508
+ }
509
+
510
+ .wq-bmi-unit-option:hover {
511
+ background-color: rgba(0, 0, 0, 0.05);
512
+ }
513
+
514
+ .wq-bmi-unit-option.wq-selected {
515
+ background-color: var(--wq-color-surface);
516
+ color: var(--wq-color-text-primary);
517
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
518
+ }
519
+
520
+ .wq-bmi-field {
521
+ display: flex;
522
+ flex-direction: column;
523
+ gap: var(--wq-space-sm);
524
+ }
525
+
526
+ .wq-bmi-label {
527
+ font-size: var(--wq-font-size-base);
528
+ font-weight: var(--wq-font-weight-medium);
529
+ color: var(--wq-color-text-primary);
530
+ }
531
+
532
+ .wq-bmi-input-group {
533
+ display: flex;
534
+ align-items: center;
535
+ gap: var(--wq-space-sm);
536
+ }
537
+
538
+ .wq-bmi-input-group input {
539
+ flex: 1;
540
+ }
541
+
542
+ .wq-bmi-imperial-height {
543
+ display: flex;
544
+ gap: var(--wq-space-md);
545
+ }
546
+
547
+ .wq-bmi-imperial-height .wq-bmi-input-group {
548
+ flex: 1;
549
+ }
550
+
551
+ .wq-bmi-unit {
552
+ font-size: var(--wq-font-size-sm);
553
+ font-weight: var(--wq-font-weight-normal);
554
+ color: var(--wq-color-text-tertiary);
555
+ white-space: nowrap;
556
+ }
557
+
558
+ .wq-bmi-result {
559
+ background-color: var(--wq-color-background);
560
+ cursor: not-allowed;
561
+ }
562
+
563
+ .wq-bmi-info {
564
+ padding: var(--wq-space-md);
565
+ background-color: var(--wq-color-surface);
566
+ border-radius: var(--wq-radius-md);
567
+ border: var(--wq-border-width) solid var(--wq-color-border);
568
+ }
569
+
570
+ .wq-text-secondary {
571
+ font-size: var(--wq-font-size-sm);
572
+ color: var(--wq-color-text-secondary);
573
+ margin: 0;
574
+ line-height: 1.5;
575
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@welshare/questionnaire",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "FHIR Questionnaire components for React with state management and validation",
5
5
  "keywords": [
6
6
  "react",
@@ -35,15 +35,20 @@
35
35
  "@vitest/ui": "^3.2.4",
36
36
  "@vitest/coverage-v8": "^3.2.4",
37
37
  "jsdom": "^26.1.0",
38
- "@workspace/typescript-config": "0.0.0",
39
- "@workspace/eslint-config": "0.0.0"
38
+ "storybook": "^10.1.11",
39
+ "@storybook/react": "^10.1.11",
40
+ "@storybook/react-vite": "^10.1.11",
41
+ "@workspace/eslint-config": "0.0.0",
42
+ "@workspace/typescript-config": "0.0.0"
40
43
  },
41
44
  "tshy": {
42
45
  "dialects": [
43
46
  "esm"
44
47
  ],
48
+ "selfLink": false,
45
49
  "exclude": [
46
- "src/**/__tests__/**"
50
+ "src/**/__tests__/**",
51
+ "src/**/*.stories.tsx"
47
52
  ],
48
53
  "exports": {
49
54
  "./package.json": "./package.json",
@@ -74,11 +79,17 @@
74
79
  },
75
80
  "scripts": {
76
81
  "lint": "eslint . --max-warnings 25",
77
- "build": "tshy && npm run build:css",
82
+ "build": "tshy && pnpm run build:css",
78
83
  "build:css": "cp src/components/questionnaire-tokens.css dist/tokens.css && cp src/components/questionnaire-styles.css dist/styles.css",
79
84
  "build:clean": "rm -rf ./dist",
80
85
  "test": "vitest",
81
86
  "test:run": "vitest run",
82
- "test:coverage": "vitest run --coverage"
87
+ "test:coverage": "vitest run --coverage",
88
+ "audit": "pnpm audit --audit-level=moderate",
89
+ "audit:fix": "pnpm audit fix",
90
+ "check:deps": "pnpm outdated",
91
+ "verify:publish": "bash scripts/verify-publish.sh",
92
+ "storybook": "storybook dev -p 6006",
93
+ "build-storybook": "storybook build"
83
94
  }
84
95
  }
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "../tsconfig.json",
3
- "compilerOptions": {
4
- "rootDir": "../src",
5
- "module": "nodenext",
6
- "moduleResolution": "nodenext"
7
- }
8
- }
@@ -1,16 +0,0 @@
1
- {
2
- "extends": "./build.json",
3
- "include": [
4
- "../src/**/*.ts",
5
- "../src/**/*.mts",
6
- "../src/**/*.tsx",
7
- "../src/**/*.json"
8
- ],
9
- "exclude": [
10
- "../src/**/__tests__/**",
11
- "../src/package.json"
12
- ],
13
- "compilerOptions": {
14
- "outDir": "../.tshy-build/esm"
15
- }
16
- }
@@ -1,7 +0,0 @@
1
- Copyright © 2026 Welshare Health UG (haftungsbeschränkt)
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,173 +0,0 @@
1
- # @welshare/questionnaire
2
-
3
- FHIR R4 Questionnaire components for React with state management, validation, and theming.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install @welshare/questionnaire
9
- ```
10
-
11
- ## Quick Start
12
-
13
- ```tsx
14
- import { useState, useEffect } from 'react';
15
- import {
16
- QuestionnaireProvider,
17
- useQuestionnaire,
18
- QuestionRenderer,
19
- getVisiblePages,
20
- type Questionnaire,
21
- } from '@welshare/questionnaire';
22
- import '@welshare/questionnaire/tokens.css';
23
- import '@welshare/questionnaire/styles.css';
24
-
25
- function QuestionnairePage() {
26
- const { questionnaire, isPageValid } = useQuestionnaire();
27
- const pages = getVisiblePages(questionnaire);
28
- const [currentPageIndex, setCurrentPageIndex] = useState(0);
29
- const currentPage = pages[currentPageIndex];
30
-
31
- return (
32
- <div>
33
- <h1>{questionnaire.title}</h1>
34
- {currentPage?.item?.map((item) => (
35
- <QuestionRenderer key={item.linkId} item={item} />
36
- ))}
37
- <button
38
- onClick={() => setCurrentPageIndex(currentPageIndex + 1)}
39
- disabled={!isPageValid(currentPage?.item || [])}
40
- >
41
- Next
42
- </button>
43
- </div>
44
- );
45
- }
46
-
47
- function App() {
48
- const [questionnaire, setQuestionnaire] = useState<Questionnaire | null>(null);
49
-
50
- useEffect(() => {
51
- fetch('/api/questionnaire/your-id')
52
- .then(res => res.json())
53
- .then(setQuestionnaire);
54
- }, []);
55
-
56
- if (!questionnaire) return <div>Loading...</div>;
57
-
58
- return (
59
- <QuestionnaireProvider questionnaire={questionnaire}>
60
- <QuestionnairePage />
61
- </QuestionnaireProvider>
62
- );
63
- }
64
- ```
65
-
66
- ## API
67
-
68
- ### QuestionnaireProvider
69
-
70
- **Props:**
71
- - `questionnaire: Questionnaire` - FHIR Questionnaire object
72
- - `questionnaireId?: string` - Optional ID override (defaults to `questionnaire.id`)
73
- - `useNestedStructure?: boolean` - Nested or flat response structure (default: `true`)
74
-
75
- ### useQuestionnaire Hook
76
-
77
- ```tsx
78
- const {
79
- questionnaire, response,
80
- updateAnswer, updateMultipleAnswers,
81
- getAnswer, getAnswers,
82
- isPageValid, getRequiredQuestions, getUnansweredRequiredQuestions,
83
- markValidationErrors, clearValidationErrors, hasValidationError,
84
- debugMode, toggleDebugMode,
85
- } = useQuestionnaire();
86
- ```
87
-
88
- ### QuestionRenderer
89
-
90
- **Props:**
91
- - `item: QuestionnaireItem` - Questionnaire item to render
92
- - `className?: string` - Container CSS classes
93
- - `inputClassName?: string` - Input CSS classes
94
- - `choiceClassName?: string` - Choice option CSS classes
95
- - `renderRadioInput?: (props: RadioInputProps) => ReactNode` - Custom radio renderer
96
- - `renderCheckboxInput?: (props: CheckboxInputProps) => ReactNode` - Custom checkbox renderer
97
-
98
- **Supported Types:** `choice`, `boolean`, `integer`, `decimal`, `string`, `text`
99
-
100
- ### Utilities
101
-
102
- - `getVisiblePages(questionnaire)` - Get visible page groups
103
- - `calculateProgress(currentIndex, total)` - Calculate progress percentage
104
- - `getAllQuestionsFromPage(pageItem)` - Get all questions from a page
105
-
106
- ## Theming
107
-
108
- Override CSS custom properties:
109
-
110
- ```css
111
- :root {
112
- --wq-color-primary-500: #3b82f6;
113
- --wq-space-lg: 1.5rem;
114
- --wq-font-size-base: 1rem;
115
- }
116
- ```
117
-
118
- ### Custom Input Renderers
119
-
120
- ```tsx
121
- <QuestionRenderer
122
- item={item}
123
- renderRadioInput={(props) => (
124
- <input type="radio" checked={props.checked} onChange={props.onChange} />
125
- )}
126
- renderCheckboxInput={(props) => (
127
- <input type="checkbox" checked={props.checked} onChange={props.onChange} />
128
- )}
129
- />
130
- ```
131
-
132
- **Renderer Props:** `linkId`, `valueCoding`, `valueInteger`, `checked`, `disabled`, `onChange`, `label`, `index`
133
-
134
- ## FHIR Extensions
135
-
136
- ### Hidden Questions
137
- ```json
138
- {
139
- "extension": [{
140
- "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-hidden",
141
- "valueBoolean": true
142
- }]
143
- }
144
- ```
145
-
146
- ### Slider Controls
147
- ```json
148
- {
149
- "extension": [{
150
- "url": "http://codes.welshare.app/StructureDefinition/questionnaire-slider-control",
151
- "extension": [
152
- { "url": "minValue", "valueInteger": 0 },
153
- { "url": "maxValue", "valueInteger": 100 },
154
- { "url": "step", "valueInteger": 1 },
155
- { "url": "unit", "valueString": "minutes" }
156
- ]
157
- }]
158
- }
159
- ```
160
-
161
- ### Exclusive Options
162
- ```json
163
- {
164
- "extension": [{
165
- "url": "http://codes.welshare.app/StructureDefinition/questionnaire-exclusive-option",
166
- "valueString": "none-of-the-above-code"
167
- }]
168
- }
169
- ```
170
-
171
- ## License
172
-
173
- MIT © Welshare UG (haftungsbeschränkt)
@@ -1,44 +0,0 @@
1
- import type { QuestionnaireItem, QuestionnaireResponseAnswer, Coding } from "../types/fhir.js";
2
- export interface DebugSectionProps {
3
- /**
4
- * The questionnaire item to display debug information for
5
- */
6
- item: QuestionnaireItem;
7
- /**
8
- * The current answer (for single-answer questions)
9
- */
10
- currentAnswer?: QuestionnaireResponseAnswer;
11
- /**
12
- * The current answers (for multi-answer questions)
13
- */
14
- currentAnswers?: QuestionnaireResponseAnswer[];
15
- /**
16
- * Optional LOINC code to display
17
- */
18
- loincCode?: Coding;
19
- /**
20
- * Additional CSS class names
21
- */
22
- className?: string;
23
- }
24
- /**
25
- * DebugSection component displays debug information for a questionnaire item.
26
- *
27
- * This component is designed to be reusable and can be moved to the shared package.
28
- * It displays:
29
- * - LOINC code link (if available)
30
- * - Collapsible FHIR question definition
31
- * - Collapsible selected answer(s) in FHIR format
32
- *
33
- * @example
34
- * ```tsx
35
- * <DebugSection
36
- * item={questionItem}
37
- * currentAnswer={answer}
38
- * currentAnswers={answers}
39
- * loincCode={loincCode}
40
- * />
41
- * ```
42
- */
43
- export declare const DebugSection: ({ item, currentAnswer, currentAnswers, loincCode, className, }: DebugSectionProps) => import("react/jsx-runtime").JSX.Element;
44
- //# sourceMappingURL=debug-section.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"debug-section.d.ts","sourceRoot":"","sources":["../../../src/components/debug-section.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,iBAAiB,EACjB,2BAA2B,EAC3B,MAAM,EACP,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,IAAI,EAAE,iBAAiB,CAAC;IACxB;;OAEG;IACH,aAAa,CAAC,EAAE,2BAA2B,CAAC;IAC5C;;OAEG;IACH,cAAc,CAAC,EAAE,2BAA2B,EAAE,CAAC;IAC/C;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,YAAY,GAAI,gEAM1B,iBAAiB,4CA4DnB,CAAC"}
@@ -1,28 +0,0 @@
1
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- import { useState } from "react";
3
- /**
4
- * DebugSection component displays debug information for a questionnaire item.
5
- *
6
- * This component is designed to be reusable and can be moved to the shared package.
7
- * It displays:
8
- * - LOINC code link (if available)
9
- * - Collapsible FHIR question definition
10
- * - Collapsible selected answer(s) in FHIR format
11
- *
12
- * @example
13
- * ```tsx
14
- * <DebugSection
15
- * item={questionItem}
16
- * currentAnswer={answer}
17
- * currentAnswers={answers}
18
- * loincCode={loincCode}
19
- * />
20
- * ```
21
- */
22
- export const DebugSection = ({ item, currentAnswer, currentAnswers = [], loincCode, className = "", }) => {
23
- const [isQuestionDefOpen, setIsQuestionDefOpen] = useState(false);
24
- const [isAnswersOpen, setIsAnswersOpen] = useState(false);
25
- return (_jsxs("div", { className: `wq-debug-section ${className}`, children: [loincCode && loincCode.code && (_jsx("div", { className: "wq-loinc-link-section", children: _jsxs("a", { href: `https://loinc.org/${loincCode.code}`, target: "_blank", rel: "noopener noreferrer", className: "wq-loinc-link", children: ["\uD83D\uDCCB LOINC Specification: ", loincCode.code] }) })), _jsxs("div", { className: "wq-debug-collapsible", children: [_jsxs("button", { className: "wq-debug-collapsible-header", onClick: () => setIsQuestionDefOpen(!isQuestionDefOpen), type: "button", children: [_jsx("span", { className: `chevron ${isQuestionDefOpen ? "open" : ""}`, children: "\u25B6" }), _jsx("span", { className: "wq-debug-title", children: "FHIR Question Definition" })] }), isQuestionDefOpen && (_jsx("pre", { className: "wq-debug-json", children: JSON.stringify(item, null, 2) }))] }), (currentAnswer || currentAnswers.length > 0) && (_jsxs("div", { className: "wq-debug-collapsible", children: [_jsxs("button", { className: "wq-debug-collapsible-header", onClick: () => setIsAnswersOpen(!isAnswersOpen), type: "button", children: [_jsx("span", { className: `chevron ${isAnswersOpen ? "open" : ""}`, children: "\u25B6" }), _jsx("span", { className: "wq-debug-title", children: "Selected Answer(s) (FHIR Format)" })] }), isAnswersOpen && (_jsx("pre", { className: "wq-debug-json", children: item.repeats
26
- ? JSON.stringify(currentAnswers, null, 2)
27
- : JSON.stringify(currentAnswer, null, 2) }))] }))] }));
28
- };
@@ -1,80 +0,0 @@
1
- import { type ReactNode } from "react";
2
- import type { QuestionnaireItem } from "../types/fhir.js";
3
- import { RadioInputProps, CheckboxInputProps } from "../types/index.js";
4
- export interface QuestionRendererProps {
5
- item: QuestionnaireItem;
6
- /**
7
- * Additional class names for the question container
8
- * Will be appended to the default wq-question-container class
9
- */
10
- className?: string;
11
- /**
12
- * Additional class names for input elements
13
- * Will be appended to the default wq-question-input class
14
- */
15
- inputClassName?: string;
16
- /**
17
- * Additional class names for choice options
18
- * Will be appended to the default wq-choice-option class
19
- */
20
- choiceClassName?: string;
21
- /**
22
- * Custom renderer for radio button inputs.
23
- * When provided, this function will be called to render each radio option,
24
- * giving clients full control over styling and structure.
25
- *
26
- * @example
27
- * ```tsx
28
- * <QuestionRenderer
29
- * item={item}
30
- * renderRadioInput={(props) => (
31
- * <div className="custom-radio-wrapper">
32
- * <input
33
- * type="radio"
34
- * checked={props.checked}
35
- * onChange={props.onChange}
36
- * className="custom-radio"
37
- * />
38
- * <label>{props.label}</label>
39
- * </div>
40
- * )}
41
- * />
42
- * ```
43
- */
44
- renderRadioInput?: (props: RadioInputProps) => ReactNode;
45
- /**
46
- * Custom renderer for checkbox inputs.
47
- * When provided, this function will be called to render each checkbox option,
48
- * giving clients full control over styling and structure.
49
- *
50
- * @example
51
- * ```tsx
52
- * <QuestionRenderer
53
- * item={item}
54
- * renderCheckboxInput={(props) => (
55
- * <div className="custom-checkbox-wrapper">
56
- * <input
57
- * type="checkbox"
58
- * checked={props.checked}
59
- * onChange={props.onChange}
60
- * className="custom-checkbox"
61
- * />
62
- * <label>{props.label}</label>
63
- * </div>
64
- * )}
65
- * />
66
- * ```
67
- */
68
- renderCheckboxInput?: (props: CheckboxInputProps) => ReactNode;
69
- }
70
- /**
71
- * Wrapper component that combines the library's QuestionRenderer with debug functionality.
72
- *
73
- * This component:
74
- * - Renders the library's QuestionRenderer with custom radio/checkbox renderers
75
- * - Adds DebugSection below it when debug mode is enabled
76
- *
77
- * Uses custom input renderers to maintain the app's design system styling.
78
- */
79
- export declare const QuestionRenderer: (rendererProps: QuestionRendererProps) => import("react/jsx-runtime").JSX.Element;
80
- //# sourceMappingURL=question-renderer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"question-renderer.d.ts","sourceRoot":"","sources":["../../../src/components/question-renderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAQ1D,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAExE,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,iBAAiB,CAAC;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,SAAS,CAAC;IACzD;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,SAAS,CAAC;CAChE;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAI,eAAe,qBAAqB,4CAyBpE,CAAC"}