@evaro/consultation-sdk 0.0.0-stage → 0.2.0-next.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 +51 -2
- package/dist/index.mjs +21053 -0
- package/dist/types/Consultation.d.ts +39 -0
- package/dist/types/api.d.ts +20 -0
- package/dist/types/draftQueue.d.ts +22 -0
- package/dist/types/events.d.ts +15 -0
- package/dist/types/flow/answer.d.ts +46 -0
- package/dist/types/flow/form.d.ts +67 -0
- package/dist/types/flow/path.d.ts +34 -0
- package/dist/types/flow/questionnaire.d.ts +133 -0
- package/dist/types/flow/useConsultationFlow.d.ts +36 -0
- package/dist/types/flow/validations.d.ts +6 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/sanitize.d.ts +2 -0
- package/dist/types/targets/diagnosisRequest.d.ts +3 -0
- package/dist/types/targets/index.d.ts +3 -0
- package/dist/types/types.d.ts +71 -0
- package/dist/types/ui/ErrorNotice.d.ts +4 -0
- package/dist/types/ui/FormFlow.d.ts +9 -0
- package/dist/types/ui/Knockout.d.ts +8 -0
- package/dist/types/ui/Question.d.ts +21 -0
- package/dist/types/ui/ReadOnlyAnswers.d.ts +9 -0
- package/dist/types/ui/ShadowRoot.d.ts +6 -0
- package/dist/types/ui/form/Blocks.d.ts +6 -0
- package/dist/types/ui/form/FormField.d.ts +38 -0
- package/dist/types/ui/form/inputs.d.ts +28 -0
- package/dist/types/ui/primitives.d.ts +37 -0
- package/dist/types/useTargetSave.d.ts +30 -0
- package/package.json +36 -4
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AnswerMap, AnswerValue } from '../../flow/answer';
|
|
2
|
+
type OptionLogic = iQuestion['options'][number]['logic'];
|
|
3
|
+
export type Answer = (question: iQuestion, value: AnswerValue, logic: OptionLogic | undefined) => void;
|
|
4
|
+
export interface InputProps {
|
|
5
|
+
question: iQuestion;
|
|
6
|
+
answers: AnswerMap;
|
|
7
|
+
optionHashes: AnswerMap;
|
|
8
|
+
onAnswer: Answer;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
/** Names the field for screen readers when no visible label sits next to it, as in a table cell. */
|
|
11
|
+
label?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const fieldClass = "w-full rounded-2xl border border-gray-300 bg-white px-4 text-sm font-normal text-gray-900 placeholder:text-gray-400 focus:border-primary-700 focus:ring-primary-700 disabled:opacity-60";
|
|
14
|
+
export declare const plainText: (html: string | undefined) => string;
|
|
15
|
+
/** Options as a joined pair of buttons, such as Yes / No. They are radio inputs, so the keyboard works as usual. */
|
|
16
|
+
export declare const Segmented: ({ question, answers, optionHashes, onAnswer, disabled, label }: InputProps) => import("react").JSX.Element;
|
|
17
|
+
/** A radio question as a dropdown. The native list opens outside the shadow root's styles but works everywhere. */
|
|
18
|
+
export declare const Select: ({ question, answers, optionHashes, onAnswer, disabled, label }: InputProps) => import("react").JSX.Element;
|
|
19
|
+
/** Free text, a phone number or a date. `multiline` draws the tall box used for notes. */
|
|
20
|
+
export declare const TextInput: ({ question, answers, onAnswer, disabled, label, multiline, placeholder }: InputProps & {
|
|
21
|
+
multiline?: boolean;
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
}) => import("react").JSX.Element;
|
|
24
|
+
/** Checkbox options as small ticks. A question with one option draws as one tick with its label. */
|
|
25
|
+
export declare const Checks: ({ question, answers, optionHashes, onAnswer, disabled }: InputProps) => import("react").JSX.Element;
|
|
26
|
+
/** Radio options that are not Yes / No, as a list of round buttons. */
|
|
27
|
+
export declare const Radios: ({ question, answers, optionHashes, onAnswer, disabled }: InputProps) => import("react").JSX.Element;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
export declare const CircularProgress: ({ size, className }: {
|
|
4
|
+
size?: number;
|
|
5
|
+
className?: string;
|
|
6
|
+
}) => React.JSX.Element;
|
|
7
|
+
export declare const CheckCircleIcon: ({ className }: {
|
|
8
|
+
className?: string;
|
|
9
|
+
}) => React.JSX.Element;
|
|
10
|
+
export declare const EmptyCircleIcon: () => React.JSX.Element;
|
|
11
|
+
export declare const ArrowLeftIcon: () => React.JSX.Element;
|
|
12
|
+
interface ButtonProps extends React.ComponentProps<'button'> {
|
|
13
|
+
variant?: 'text' | 'contained' | 'outlined' | 'consultation';
|
|
14
|
+
color?: 'primary' | 'secondary' | 'success';
|
|
15
|
+
fullWidth?: boolean;
|
|
16
|
+
loading?: boolean;
|
|
17
|
+
startIcon?: ReactNode;
|
|
18
|
+
}
|
|
19
|
+
export declare const Button: ({ variant, color, fullWidth, children, className, startIcon, disabled, loading, type, ...rest }: ButtonProps) => React.JSX.Element;
|
|
20
|
+
export interface TextFieldProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
21
|
+
error?: boolean;
|
|
22
|
+
label?: string;
|
|
23
|
+
helperText?: string;
|
|
24
|
+
multiline?: boolean;
|
|
25
|
+
rows?: number;
|
|
26
|
+
labelClassName?: string;
|
|
27
|
+
}
|
|
28
|
+
export declare const TextField: React.ForwardRefExoticComponent<TextFieldProps & React.RefAttributes<HTMLInputElement>>;
|
|
29
|
+
/** A masked `DD-MM-YYYY` text field, as in Connect. It needs no popover, so it works inside a shadow root. */
|
|
30
|
+
export declare const DatePicker: ({ onChange, ...props }: Omit<TextFieldProps, 'onChange'> & {
|
|
31
|
+
onChange: (value: string) => void;
|
|
32
|
+
}) => React.JSX.Element;
|
|
33
|
+
export declare const Accordion: ({ title, description }: {
|
|
34
|
+
title: string;
|
|
35
|
+
description: string;
|
|
36
|
+
}) => React.JSX.Element;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Answers, TargetAdapter } from './types';
|
|
2
|
+
export declare const DRAFT_DELAY_MS = 600;
|
|
3
|
+
export type SaveState = 'idle' | 'saving' | 'saved' | 'error';
|
|
4
|
+
export type SubmitState = 'idle' | 'submitting' | 'submitted' | 'error';
|
|
5
|
+
interface Options {
|
|
6
|
+
adapter: TargetAdapter | null;
|
|
7
|
+
/** The target's queue key. Its drafts and submits run one after another, and a reload of it waits for them. */
|
|
8
|
+
queueKey: string;
|
|
9
|
+
/** Bumped on every change the user makes. */
|
|
10
|
+
revision: number;
|
|
11
|
+
/** The answers a draft sends now. */
|
|
12
|
+
latestDraft: () => Answers;
|
|
13
|
+
onDone?: () => void;
|
|
14
|
+
/** Called once a submit has landed, before `onDone`. */
|
|
15
|
+
onSubmitted?: () => void;
|
|
16
|
+
/** The server refused a write because the answers changed in another place. */
|
|
17
|
+
onConflict: () => void;
|
|
18
|
+
/** A draft or the submit was saved. */
|
|
19
|
+
onSaved: () => void;
|
|
20
|
+
}
|
|
21
|
+
export declare const errorMessage: (error: unknown) => string;
|
|
22
|
+
export declare function useTargetSave({ adapter, queueKey, revision, latestDraft, onDone, onSubmitted, onConflict, onSaved }: Options): {
|
|
23
|
+
saveState: SaveState;
|
|
24
|
+
submitState: SubmitState;
|
|
25
|
+
submitError: string;
|
|
26
|
+
saveDraft: () => void;
|
|
27
|
+
submit: (answers: Answers) => void;
|
|
28
|
+
rejectSubmit: (message: string) => void;
|
|
29
|
+
};
|
|
30
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evaro/consultation-sdk",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0-next.0",
|
|
4
|
+
"description": "The Evaro consultation flow as a React component: one question at a time, follow-ups, jumps and the knockout screen.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"private": false,
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/TotalAccessHealth/consultation.git",
|
|
13
|
+
"directory": "sdk"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./dist/index.mjs",
|
|
17
|
+
"module": "./dist/index.mjs",
|
|
18
|
+
"types": "./dist/types/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/types/index.d.ts",
|
|
22
|
+
"import": "./dist/index.mjs",
|
|
23
|
+
"default": "./dist/index.mjs"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
30
|
+
"sideEffects": false,
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"react": "^19.0.0",
|
|
33
|
+
"react-dom": "^19.0.0"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"prepublishOnly": "pnpm -C .. build:sdk && pnpm -C .. test:sdk"
|
|
37
|
+
}
|
|
38
|
+
}
|