@velion-la/onboarding-sdk-react-native 1.4.0-beta.7 → 1.4.0-beta.8
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/CHANGELOG.md +41 -0
- package/README.md +31 -1
- package/lib/commonjs/core/VelionOnboarding.js +52 -44
- package/lib/commonjs/core/VelionOnboarding.js.map +1 -1
- package/lib/commonjs/core/routingCommands.js +33 -0
- package/lib/commonjs/core/routingCommands.js.map +1 -1
- package/lib/commonjs/core/sessionStateMapper.js +48 -36
- package/lib/commonjs/core/sessionStateMapper.js.map +1 -1
- package/lib/commonjs/i18n/strings/en.js +27 -0
- package/lib/commonjs/i18n/strings/en.js.map +1 -1
- package/lib/commonjs/i18n/strings/es.js +27 -0
- package/lib/commonjs/i18n/strings/es.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/steps/CustomFormStep.js +348 -0
- package/lib/commonjs/steps/CustomFormStep.js.map +1 -0
- package/lib/commonjs/steps/EntityTypeSelectionStep.js +194 -0
- package/lib/commonjs/steps/EntityTypeSelectionStep.js.map +1 -0
- package/lib/commonjs/steps/customForm.js +251 -0
- package/lib/commonjs/steps/customForm.js.map +1 -0
- package/lib/commonjs/steps/entityType.js +30 -0
- package/lib/commonjs/steps/entityType.js.map +1 -0
- package/lib/commonjs/steps/submissionOutcome.js +101 -0
- package/lib/commonjs/steps/submissionOutcome.js.map +1 -0
- package/lib/commonjs/steps/unsupportedStep.js +33 -0
- package/lib/commonjs/steps/unsupportedStep.js.map +1 -0
- package/lib/commonjs/types/index.js +35 -3
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/ui/primitives/RadioCard.js +120 -0
- package/lib/commonjs/ui/primitives/RadioCard.js.map +1 -0
- package/lib/commonjs/ui/primitives/Select.js +60 -7
- package/lib/commonjs/ui/primitives/Select.js.map +1 -1
- package/lib/commonjs/ui/primitives/index.js +7 -0
- package/lib/commonjs/ui/primitives/index.js.map +1 -1
- package/lib/commonjs/utils/sdkVersion.js +1 -1
- package/lib/module/core/VelionOnboarding.js +53 -45
- package/lib/module/core/VelionOnboarding.js.map +1 -1
- package/lib/module/core/routingCommands.js +33 -0
- package/lib/module/core/routingCommands.js.map +1 -1
- package/lib/module/core/sessionStateMapper.js +47 -36
- package/lib/module/core/sessionStateMapper.js.map +1 -1
- package/lib/module/i18n/strings/en.js +27 -0
- package/lib/module/i18n/strings/en.js.map +1 -1
- package/lib/module/i18n/strings/es.js +27 -0
- package/lib/module/i18n/strings/es.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/steps/CustomFormStep.js +345 -0
- package/lib/module/steps/CustomFormStep.js.map +1 -0
- package/lib/module/steps/EntityTypeSelectionStep.js +189 -0
- package/lib/module/steps/EntityTypeSelectionStep.js.map +1 -0
- package/lib/module/steps/customForm.js +237 -0
- package/lib/module/steps/customForm.js.map +1 -0
- package/lib/module/steps/entityType.js +24 -0
- package/lib/module/steps/entityType.js.map +1 -0
- package/lib/module/steps/submissionOutcome.js +94 -0
- package/lib/module/steps/submissionOutcome.js.map +1 -0
- package/lib/module/steps/unsupportedStep.js +30 -0
- package/lib/module/steps/unsupportedStep.js.map +1 -0
- package/lib/module/types/index.js +42 -3
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/ui/primitives/RadioCard.js +116 -0
- package/lib/module/ui/primitives/RadioCard.js.map +1 -0
- package/lib/module/ui/primitives/Select.js +62 -9
- package/lib/module/ui/primitives/Select.js.map +1 -1
- package/lib/module/ui/primitives/index.js +1 -0
- package/lib/module/ui/primitives/index.js.map +1 -1
- package/lib/module/utils/sdkVersion.js +1 -1
- package/lib/typescript/core/VelionOnboarding.d.ts +11 -5
- package/lib/typescript/core/VelionOnboarding.d.ts.map +1 -1
- package/lib/typescript/core/routingCommands.d.ts +23 -0
- package/lib/typescript/core/routingCommands.d.ts.map +1 -1
- package/lib/typescript/core/sessionStateMapper.d.ts +13 -5
- package/lib/typescript/core/sessionStateMapper.d.ts.map +1 -1
- package/lib/typescript/i18n/strings/en.d.ts.map +1 -1
- package/lib/typescript/i18n/strings/es.d.ts +27 -0
- package/lib/typescript/i18n/strings/es.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/steps/CustomFormStep.d.ts +28 -0
- package/lib/typescript/steps/CustomFormStep.d.ts.map +1 -0
- package/lib/typescript/steps/EntityTypeSelectionStep.d.ts +24 -0
- package/lib/typescript/steps/EntityTypeSelectionStep.d.ts.map +1 -0
- package/lib/typescript/steps/customForm.d.ts +99 -0
- package/lib/typescript/steps/customForm.d.ts.map +1 -0
- package/lib/typescript/steps/entityType.d.ts +15 -0
- package/lib/typescript/steps/entityType.d.ts.map +1 -0
- package/lib/typescript/steps/submissionOutcome.d.ts +43 -0
- package/lib/typescript/steps/submissionOutcome.d.ts.map +1 -0
- package/lib/typescript/steps/types.d.ts +5 -0
- package/lib/typescript/steps/types.d.ts.map +1 -1
- package/lib/typescript/steps/unsupportedStep.d.ts +15 -0
- package/lib/typescript/steps/unsupportedStep.d.ts.map +1 -0
- package/lib/typescript/types/index.d.ts +107 -14
- package/lib/typescript/types/index.d.ts.map +1 -1
- package/lib/typescript/ui/primitives/RadioCard.d.ts +22 -0
- package/lib/typescript/ui/primitives/RadioCard.d.ts.map +1 -0
- package/lib/typescript/ui/primitives/Select.d.ts +9 -3
- package/lib/typescript/ui/primitives/Select.d.ts.map +1 -1
- package/lib/typescript/ui/primitives/index.d.ts +1 -0
- package/lib/typescript/ui/primitives/index.d.ts.map +1 -1
- package/lib/typescript/utils/sdkVersion.d.ts +1 -1
- package/package.json +1 -1
- package/src/core/VelionOnboarding.ts +59 -53
- package/src/core/routingCommands.ts +42 -0
- package/src/core/sessionStateMapper.ts +63 -52
- package/src/i18n/strings/en.ts +28 -0
- package/src/i18n/strings/es.ts +28 -0
- package/src/index.ts +7 -0
- package/src/steps/CustomFormStep.tsx +400 -0
- package/src/steps/EntityTypeSelectionStep.tsx +207 -0
- package/src/steps/customForm.ts +302 -0
- package/src/steps/entityType.ts +25 -0
- package/src/steps/submissionOutcome.ts +93 -0
- package/src/steps/types.ts +5 -0
- package/src/steps/unsupportedStep.ts +32 -0
- package/src/types/index.ts +117 -17
- package/src/ui/primitives/RadioCard.tsx +127 -0
- package/src/ui/primitives/Select.tsx +73 -7
- package/src/ui/primitives/index.ts +1 -0
- package/src/utils/sdkVersion.ts +1 -1
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SEARCHABLE_LIST_THRESHOLD = exports.MAX_TEXT_LENGTH = void 0;
|
|
7
|
+
exports.buildResponses = buildResponses;
|
|
8
|
+
exports.draftFromAnswer = draftFromAnswer;
|
|
9
|
+
exports.emptyDraft = emptyDraft;
|
|
10
|
+
exports.initialDrafts = initialDrafts;
|
|
11
|
+
exports.isRealIsoDate = isRealIsoDate;
|
|
12
|
+
exports.parseCustomFormConfig = parseCustomFormConfig;
|
|
13
|
+
exports.parseNumberInput = parseNumberInput;
|
|
14
|
+
exports.splitCustomFormErrors = splitCustomFormErrors;
|
|
15
|
+
exports.validateField = validateField;
|
|
16
|
+
exports.validateForm = validateForm;
|
|
17
|
+
/**
|
|
18
|
+
* @fileoverview Pure logic of the `CUSTOM_FORM` step: reading `form_fields`,
|
|
19
|
+
* the per-type validation and the `responses` payload (spike VON-131 §3.2).
|
|
20
|
+
*
|
|
21
|
+
* JSX-free so the rules run under Jest in the `node` environment. The server
|
|
22
|
+
* validates the same rules and is the authority; the SDK checks them only to
|
|
23
|
+
* answer before the round trip.
|
|
24
|
+
*
|
|
25
|
+
* | type | value sent | required means |
|
|
26
|
+
* |-----------|-----------------------------|---------------------------|
|
|
27
|
+
* | `TEXT` | string, trimmed, ≤ 255 | not empty after the trim |
|
|
28
|
+
* | `NUMBER` | JSON number (`,` or `.`) | present and finite |
|
|
29
|
+
* | `BOOLEAN` | `true` / `false` (Yes / No) | answered |
|
|
30
|
+
* | `DATE` | `"yyyy-MM-dd"`, a real date | a valid date |
|
|
31
|
+
* | `LIST` | one string of `options` | one of `options` |
|
|
32
|
+
*
|
|
33
|
+
* An optional field left unanswered is omitted from `responses`, never `null`.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/** Longest `TEXT` answer the backend accepts, after trimming. */
|
|
37
|
+
const MAX_TEXT_LENGTH = exports.MAX_TEXT_LENGTH = 255;
|
|
38
|
+
|
|
39
|
+
/** `LIST` fields with more options than this render a searchable picker. */
|
|
40
|
+
const SEARCHABLE_LIST_THRESHOLD = exports.SEARCHABLE_LIST_THRESHOLD = 8;
|
|
41
|
+
const KNOWN_TYPES = new Set(['TEXT', 'NUMBER', 'BOOLEAN', 'DATE', 'LIST']);
|
|
42
|
+
|
|
43
|
+
/** Prefix of every per-field key in the backend's 400 `errors`. */
|
|
44
|
+
const RESPONSES_ERROR_PREFIX = 'responses.';
|
|
45
|
+
|
|
46
|
+
/** A `form_fields` entry, normalized. */
|
|
47
|
+
|
|
48
|
+
/** The step config, normalized. */
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* What the form holds for one field while the person edits it: the text typed
|
|
52
|
+
* for `TEXT` / `NUMBER`, the choice for `BOOLEAN`, the ISO date for `DATE` and
|
|
53
|
+
* the option for `LIST` (`null` while unanswered).
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
/** Validation copy, from `StringsTable.custom_form`. */
|
|
57
|
+
|
|
58
|
+
function nonEmptyString(value) {
|
|
59
|
+
return typeof value === 'string' && value.trim() !== '' ? value.trim() : undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Reads `title`, `subtitle` and `form_fields` from the step config. Entries
|
|
64
|
+
* without a `field_key` are dropped. A field whose `type` is unknown is shown
|
|
65
|
+
* as `TEXT` when optional and reported in `unsupportedFields` when required.
|
|
66
|
+
*/
|
|
67
|
+
function parseCustomFormConfig(config) {
|
|
68
|
+
const title = nonEmptyString(config?.title);
|
|
69
|
+
const subtitle = nonEmptyString(config?.subtitle);
|
|
70
|
+
const rawFields = Array.isArray(config?.form_fields) ? config.form_fields : [];
|
|
71
|
+
const fields = [];
|
|
72
|
+
const unsupportedFields = [];
|
|
73
|
+
const seen = new Set();
|
|
74
|
+
for (const raw of rawFields) {
|
|
75
|
+
if (raw === null || typeof raw !== 'object') continue;
|
|
76
|
+
const entry = raw;
|
|
77
|
+
const fieldKey = nonEmptyString(entry.field_key);
|
|
78
|
+
if (!fieldKey || seen.has(fieldKey)) continue;
|
|
79
|
+
seen.add(fieldKey);
|
|
80
|
+
const required = entry.required === true;
|
|
81
|
+
const rawType = typeof entry.type === 'string' ? entry.type.trim().toUpperCase() : '';
|
|
82
|
+
if (!KNOWN_TYPES.has(rawType)) {
|
|
83
|
+
if (required) {
|
|
84
|
+
unsupportedFields.push({
|
|
85
|
+
fieldKey,
|
|
86
|
+
type: String(entry.type)
|
|
87
|
+
});
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const type = KNOWN_TYPES.has(rawType) ? rawType : 'TEXT';
|
|
92
|
+
const description = nonEmptyString(entry.description);
|
|
93
|
+
const options = type === 'LIST' && Array.isArray(entry.options) ? entry.options.filter(o => typeof o === 'string' && o !== '') : [];
|
|
94
|
+
fields.push({
|
|
95
|
+
fieldKey,
|
|
96
|
+
name: nonEmptyString(entry.name) ?? fieldKey,
|
|
97
|
+
...(description !== undefined && {
|
|
98
|
+
description
|
|
99
|
+
}),
|
|
100
|
+
type,
|
|
101
|
+
required,
|
|
102
|
+
options
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
...(title !== undefined && {
|
|
107
|
+
title
|
|
108
|
+
}),
|
|
109
|
+
...(subtitle !== undefined && {
|
|
110
|
+
subtitle
|
|
111
|
+
}),
|
|
112
|
+
fields,
|
|
113
|
+
unsupportedFields
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** True for a `yyyy-MM-dd` string naming a real calendar date. */
|
|
118
|
+
function isRealIsoDate(value) {
|
|
119
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
120
|
+
if (!m) return false;
|
|
121
|
+
const year = Number(m[1]);
|
|
122
|
+
const month = Number(m[2]);
|
|
123
|
+
const day = Number(m[3]);
|
|
124
|
+
const date = new Date(Date.UTC(year, month - 1, day));
|
|
125
|
+
return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Parses what the person typed in a `NUMBER` field. Either a comma or a dot is
|
|
130
|
+
* the decimal separator; thousands separators are not accepted. Returns `null`
|
|
131
|
+
* for blank or invalid text.
|
|
132
|
+
*/
|
|
133
|
+
function parseNumberInput(text) {
|
|
134
|
+
const normalized = text.trim().replace(',', '.');
|
|
135
|
+
if (!/^[+-]?(\d+(\.\d+)?|\.\d+)$/.test(normalized)) return null;
|
|
136
|
+
const value = Number(normalized);
|
|
137
|
+
return Number.isFinite(value) ? value : null;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** The empty draft of a field. */
|
|
141
|
+
function emptyDraft(field) {
|
|
142
|
+
return field.type === 'TEXT' || field.type === 'NUMBER' ? '' : null;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Draft seeded from a previous answer (`result.responses` on reverse
|
|
147
|
+
* navigation). An answer that no longer fits the field is ignored.
|
|
148
|
+
*/
|
|
149
|
+
function draftFromAnswer(field, answer) {
|
|
150
|
+
switch (field.type) {
|
|
151
|
+
case 'TEXT':
|
|
152
|
+
return typeof answer === 'string' ? answer : emptyDraft(field);
|
|
153
|
+
case 'NUMBER':
|
|
154
|
+
if (typeof answer === 'number' && Number.isFinite(answer)) return String(answer);
|
|
155
|
+
return typeof answer === 'string' && parseNumberInput(answer) !== null ? answer : emptyDraft(field);
|
|
156
|
+
case 'BOOLEAN':
|
|
157
|
+
return typeof answer === 'boolean' ? answer : null;
|
|
158
|
+
case 'DATE':
|
|
159
|
+
return typeof answer === 'string' && isRealIsoDate(answer) ? answer : null;
|
|
160
|
+
case 'LIST':
|
|
161
|
+
return typeof answer === 'string' && field.options.includes(answer) ? answer : null;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Initial drafts of every field. `stepResult` is the step's previous `result`
|
|
167
|
+
* (`{ responses: { <field_key>: value } }`), present after reverse navigation.
|
|
168
|
+
*/
|
|
169
|
+
function initialDrafts(fields, stepResult) {
|
|
170
|
+
const rawResponses = stepResult?.responses;
|
|
171
|
+
const responses = rawResponses !== null && typeof rawResponses === 'object' && !Array.isArray(rawResponses) ? rawResponses : {};
|
|
172
|
+
const drafts = {};
|
|
173
|
+
for (const field of fields) {
|
|
174
|
+
drafts[field.fieldKey] = draftFromAnswer(field, responses[field.fieldKey]);
|
|
175
|
+
}
|
|
176
|
+
return drafts;
|
|
177
|
+
}
|
|
178
|
+
function isUnanswered(field, draft) {
|
|
179
|
+
if (draft === null) return true;
|
|
180
|
+
return typeof draft === 'string' && (field.type === 'TEXT' || field.type === 'NUMBER') ? draft.trim() === '' : false;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Validates one field. Returns the message to show, or `null` when valid. */
|
|
184
|
+
function validateField(field, draft, messages) {
|
|
185
|
+
if (isUnanswered(field, draft)) {
|
|
186
|
+
return field.required ? messages.required : null;
|
|
187
|
+
}
|
|
188
|
+
switch (field.type) {
|
|
189
|
+
case 'TEXT':
|
|
190
|
+
return typeof draft === 'string' && draft.trim().length <= MAX_TEXT_LENGTH ? null : messages.textTooLong;
|
|
191
|
+
case 'NUMBER':
|
|
192
|
+
return typeof draft === 'string' && parseNumberInput(draft) !== null ? null : messages.invalidNumber;
|
|
193
|
+
case 'BOOLEAN':
|
|
194
|
+
return typeof draft === 'boolean' ? null : messages.invalidBoolean;
|
|
195
|
+
case 'DATE':
|
|
196
|
+
return typeof draft === 'string' && isRealIsoDate(draft) ? null : messages.invalidDate;
|
|
197
|
+
case 'LIST':
|
|
198
|
+
return typeof draft === 'string' && field.options.includes(draft) ? null : messages.invalidOption;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Validates every field; the result maps `field_key` to its message (empty when valid). */
|
|
203
|
+
function validateForm(fields, drafts, messages) {
|
|
204
|
+
const errors = {};
|
|
205
|
+
for (const field of fields) {
|
|
206
|
+
const message = validateField(field, drafts[field.fieldKey] ?? emptyDraft(field), messages);
|
|
207
|
+
if (message !== null) errors[field.fieldKey] = message;
|
|
208
|
+
}
|
|
209
|
+
return errors;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Builds the `responses` body from valid drafts: trimmed text, numbers as JSON
|
|
214
|
+
* numbers, and unanswered optional fields left out.
|
|
215
|
+
*/
|
|
216
|
+
function buildResponses(fields, drafts) {
|
|
217
|
+
const responses = {};
|
|
218
|
+
for (const field of fields) {
|
|
219
|
+
const draft = drafts[field.fieldKey] ?? emptyDraft(field);
|
|
220
|
+
if (isUnanswered(field, draft)) continue;
|
|
221
|
+
if (field.type === 'TEXT' && typeof draft === 'string') {
|
|
222
|
+
responses[field.fieldKey] = draft.trim();
|
|
223
|
+
} else if (field.type === 'NUMBER' && typeof draft === 'string') {
|
|
224
|
+
const value = parseNumberInput(draft);
|
|
225
|
+
if (value !== null) responses[field.fieldKey] = value;
|
|
226
|
+
} else if (draft !== null) {
|
|
227
|
+
responses[field.fieldKey] = draft;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return responses;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Splits the backend's per-field messages of a `CUSTOM_FORM` 400 into those of
|
|
235
|
+
* fields on screen (by `field_key`) and the rest (e.g. an unknown key), which
|
|
236
|
+
* the form shows in its banner.
|
|
237
|
+
*/
|
|
238
|
+
function splitCustomFormErrors(fields, errors) {
|
|
239
|
+
const keys = new Set(fields.map(f => f.fieldKey));
|
|
240
|
+
const byField = {};
|
|
241
|
+
const other = [];
|
|
242
|
+
for (const [path, message] of Object.entries(errors)) {
|
|
243
|
+
const fieldKey = path.startsWith(RESPONSES_ERROR_PREFIX) ? path.slice(RESPONSES_ERROR_PREFIX.length) : path;
|
|
244
|
+
if (keys.has(fieldKey)) byField[fieldKey] = message;else other.push(message);
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
byField,
|
|
248
|
+
other
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=customForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MAX_TEXT_LENGTH","exports","SEARCHABLE_LIST_THRESHOLD","KNOWN_TYPES","Set","RESPONSES_ERROR_PREFIX","nonEmptyString","value","trim","undefined","parseCustomFormConfig","config","title","subtitle","rawFields","Array","isArray","form_fields","fields","unsupportedFields","seen","raw","entry","fieldKey","field_key","has","add","required","rawType","type","toUpperCase","push","String","description","options","filter","o","name","isRealIsoDate","m","exec","year","Number","month","day","date","Date","UTC","getUTCFullYear","getUTCMonth","getUTCDate","parseNumberInput","text","normalized","replace","test","isFinite","emptyDraft","field","draftFromAnswer","answer","includes","initialDrafts","stepResult","rawResponses","responses","drafts","isUnanswered","draft","validateField","messages","length","textTooLong","invalidNumber","invalidBoolean","invalidDate","invalidOption","validateForm","errors","message","buildResponses","splitCustomFormErrors","keys","map","f","byField","other","path","Object","entries","startsWith","slice"],"sourceRoot":"../../../src","sources":["steps/customForm.ts"],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACO,MAAMA,eAAe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ACrC,IAAI7D,KAAK,KAAK,IAAI,EAAE0D,SAAS,CAACP,KAAK,CAACnC,QAAQ,CAAC,GAAGhB,KAAK;IACvD,CAAC,MAAM,IAAI6D,KAAK,KAAK,IAAI,EAAE;MACzBH,SAAS,CAACP,KAAK,CAACnC,QAAQ,CAAC,GAAG6C,KAAK;IACnC;EACF;EACA,OAAOH,SAAS;AAClB;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASgB,qBAAqBA,CACnC/D,MAAyC,EACzC4D,MAAwC,EACc;EACtD,MAAMI,IAAI,GAAG,IAAI9E,GAAG,CAACc,MAAM,CAACiE,GAAG,CAAEC,CAAC,IAAKA,CAAC,CAAC7D,QAAQ,CAAC,CAAC;EACnD,MAAM8D,OAA+B,GAAG,CAAC,CAAC;EAC1C,MAAMC,KAAe,GAAG,EAAE;EAC1B,KAAK,MAAM,CAACC,IAAI,EAAER,OAAO,CAAC,IAAIS,MAAM,CAACC,OAAO,CAACX,MAAM,CAAC,EAAE;IACpD,MAAMvD,QAAQ,GAAGgE,IAAI,CAACG,UAAU,CAACrF,sBAAsB,CAAC,GACpDkF,IAAI,CAACI,KAAK,CAACtF,sBAAsB,CAACkE,MAAM,CAAC,GACzCgB,IAAI;IACR,IAAIL,IAAI,CAACzD,GAAG,CAACF,QAAQ,CAAC,EAAE8D,OAAO,CAAC9D,QAAQ,CAAC,GAAGwD,OAAO,CAAC,KAC/CO,KAAK,CAACvD,IAAI,CAACgD,OAAO,CAAC;EAC1B;EACA,OAAO;IAAEM,OAAO;IAAEC;EAAM,CAAC;AAC3B","ignoreList":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ENTITY_TYPES = void 0;
|
|
7
|
+
exports.isEntityType = isEntityType;
|
|
8
|
+
exports.prefillEntityType = prefillEntityType;
|
|
9
|
+
/**
|
|
10
|
+
* @fileoverview Pure logic of the `ENTITY_TYPE_SELECTION` step. JSX-free so it
|
|
11
|
+
* runs under Jest in the `node` environment.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** The two choices, in the order the step shows them. */
|
|
15
|
+
const ENTITY_TYPES = exports.ENTITY_TYPES = ['HUMAN', 'LEGAL'];
|
|
16
|
+
|
|
17
|
+
/** Narrows an unknown value to an {@link EntityType}. */
|
|
18
|
+
function isEntityType(value) {
|
|
19
|
+
return value === 'HUMAN' || value === 'LEGAL';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The previous choice from the step's `result` (`{ selected_type }`, present on
|
|
24
|
+
* reverse navigation), or `null` when there is none.
|
|
25
|
+
*/
|
|
26
|
+
function prefillEntityType(stepResult) {
|
|
27
|
+
const value = stepResult?.selected_type;
|
|
28
|
+
return isEntityType(value) ? value : null;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=entityType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ENTITY_TYPES","exports","isEntityType","value","prefillEntityType","stepResult","selected_type"],"sourceRoot":"../../../src","sources":["steps/entityType.ts"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;;AAIA;AACO,MAAMA,YAAuC,GAAAC,OAAA,CAAAD,YAAA,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC;;AAEzE;AACO,SAASE,YAAYA,CAACC,KAAc,EAAuB;EAChE,OAAOA,KAAK,KAAK,OAAO,IAAIA,KAAK,KAAK,OAAO;AAC/C;;AAEA;AACA;AACA;AACA;AACO,SAASC,iBAAiBA,CAC/BC,UAA+C,EAC5B;EACnB,MAAMF,KAAK,GAAGE,UAAU,EAAEC,aAAa;EACvC,OAAOJ,YAAY,CAACC,KAAK,CAAC,GAAGA,KAAK,GAAG,IAAI;AAC3C","ignoreList":[]}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.STEP_NOT_CURRENT_CODE = void 0;
|
|
7
|
+
exports.backendErrorCode = backendErrorCode;
|
|
8
|
+
exports.backendFieldErrors = backendFieldErrors;
|
|
9
|
+
exports.classifySubmissionError = classifySubmissionError;
|
|
10
|
+
/**
|
|
11
|
+
* @fileoverview How a step reads a failed submit of `CUSTOM_FORM` or
|
|
12
|
+
* `ENTITY_TYPE_SELECTION` (VON-148 contract).
|
|
13
|
+
*
|
|
14
|
+
* | Response | Outcome | What the step does |
|
|
15
|
+
* |-----------------------------------------|------------|--------------------------------------------|
|
|
16
|
+
* | 400 `VAL-4000` with `errors` | `invalid` | shows each message next to its field |
|
|
17
|
+
* | 409 `VOB-40908` (not the current step) | `stale` | ends the step; the orchestrator re-routes |
|
|
18
|
+
* | request aborted by the flow | `aborted` | nothing: the flow already ended |
|
|
19
|
+
* | anything else | `failed` | banner + retry dialog, like the other steps|
|
|
20
|
+
*
|
|
21
|
+
* A `stale` submit cannot succeed by retrying: the session moved on (e.g. the
|
|
22
|
+
* same answer was already accepted). Ending the step hands control to the
|
|
23
|
+
* orchestrator's routing wait, whose fallback GET reads where the session
|
|
24
|
+
* really is, instead of a retry dialog that would loop on the same error. Same
|
|
25
|
+
* rule as the web SDK (OSDKW-41).
|
|
26
|
+
*
|
|
27
|
+
* JSX-free so it runs under Jest in the `node` environment.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/** Backend code: the step submitted is not the session's current step (409). */
|
|
31
|
+
const STEP_NOT_CURRENT_CODE = exports.STEP_NOT_CURRENT_CODE = 'VOB-40908';
|
|
32
|
+
|
|
33
|
+
/** Backend error body (`application/problem+json`), carried in `SdkError.cause`. */
|
|
34
|
+
|
|
35
|
+
function problemBodyOf(err) {
|
|
36
|
+
if (err === null || typeof err !== 'object') return undefined;
|
|
37
|
+
const cause = err.cause;
|
|
38
|
+
return cause !== null && typeof cause === 'object' ? cause : undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The backend error code (`VAL-4000`, `VOB-40908`, …) of a failed request, when it sent one. */
|
|
42
|
+
function backendErrorCode(err) {
|
|
43
|
+
const code = problemBodyOf(err)?.code;
|
|
44
|
+
return typeof code === 'string' ? code : undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Per-field messages of a 400: the `errors` object of the problem body, keyed
|
|
49
|
+
* by request path (`responses.<field_key>`, `selected_type`). Also reads the
|
|
50
|
+
* list form `[{ field, message }]`. Empty when the error carries none.
|
|
51
|
+
*/
|
|
52
|
+
function backendFieldErrors(err) {
|
|
53
|
+
const errors = problemBodyOf(err)?.errors;
|
|
54
|
+
const out = {};
|
|
55
|
+
if (Array.isArray(errors)) {
|
|
56
|
+
for (const item of errors) {
|
|
57
|
+
if (item === null || typeof item !== 'object') continue;
|
|
58
|
+
const {
|
|
59
|
+
field,
|
|
60
|
+
message,
|
|
61
|
+
code
|
|
62
|
+
} = item;
|
|
63
|
+
const text = typeof message === 'string' ? message : typeof code === 'string' ? code : '';
|
|
64
|
+
if (typeof field === 'string' && text !== '') out[field] = text;
|
|
65
|
+
}
|
|
66
|
+
} else if (errors !== null && typeof errors === 'object') {
|
|
67
|
+
for (const [key, value] of Object.entries(errors)) {
|
|
68
|
+
if (typeof value === 'string' && value !== '') out[key] = value;else if (Array.isArray(value) && typeof value[0] === 'string') out[key] = value[0];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
function isAbort(err) {
|
|
74
|
+
return err !== null && typeof err === 'object' && err.name === 'AbortError';
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Classifies a failed submit; see the table at the top of the file. */
|
|
78
|
+
function classifySubmissionError(err) {
|
|
79
|
+
if (isAbort(err)) return {
|
|
80
|
+
kind: 'aborted'
|
|
81
|
+
};
|
|
82
|
+
const code = backendErrorCode(err);
|
|
83
|
+
if (code === STEP_NOT_CURRENT_CODE) {
|
|
84
|
+
return {
|
|
85
|
+
kind: 'stale',
|
|
86
|
+
code
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const httpStatus = err?.httpStatus;
|
|
90
|
+
if (httpStatus === 400) {
|
|
91
|
+
const errors = backendFieldErrors(err);
|
|
92
|
+
if (Object.keys(errors).length > 0) return {
|
|
93
|
+
kind: 'invalid',
|
|
94
|
+
errors
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
kind: 'failed'
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=submissionOutcome.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["STEP_NOT_CURRENT_CODE","exports","problemBodyOf","err","undefined","cause","backendErrorCode","code","backendFieldErrors","errors","out","Array","isArray","item","field","message","text","key","value","Object","entries","isAbort","name","classifySubmissionError","kind","httpStatus","keys","length"],"sourceRoot":"../../../src","sources":["steps/submissionOutcome.ts"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACO,MAAMA,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,GAAG,WAAW;;AAQhD;;AAMA,SAASE,aAAaA,CAACC,GAAY,EAA2B;EAC5D,IAAIA,GAAG,KAAK,IAAI,IAAI,OAAOA,GAAG,KAAK,QAAQ,EAAE,OAAOC,SAAS;EAC7D,MAAMC,KAAK,GAAIF,GAAG,CAAyBE,KAAK;EAChD,OAAOA,KAAK,KAAK,IAAI,IAAI,OAAOA,KAAK,KAAK,QAAQ,GAAIA,KAAK,GAAmBD,SAAS;AACzF;;AAEA;AACO,SAASE,gBAAgBA,CAACH,GAAY,EAAsB;EACjE,MAAMI,IAAI,GAAGL,aAAa,CAACC,GAAG,CAAC,EAAEI,IAAI;EACrC,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GAAY,EAAW;EACtC,OACEA,GAAG,KAAK,IAAI,IACZ,OAAOA,GAAG,KAAK,QAAQ,IACtBA,GAAG,CAAwBmB,IAAI,KAAK,YAAY;AAErD;;AAEA;AACO,SAASC,uBAAuBA,CAACpB,GAAY,EAAqB;EACvE,IAAIkB,OAAO,CAAClB,GAAG,CAAC,EAAE,OAAO;IAAEqB,IAAI,EAAE;EAAU,CAAC;EAC5C,MAAMjB,IAAI,GAAGD,gBAAgB,CAACH,GAAG,CAAC;EAClC,IAAII,IAAI,KAAKP,qBAAqB,EAAE;IAClC,OAAO;MAAEwB,IAAI,EAAE,OAAO;MAAEjB;IAAK,CAAC;EAChC;EACA,MAAMkB,UAAU,GAAItB,GAAG,EAAsCsB,UAAU;EACvE,IAAIA,UAAU,KAAK,GAAG,EAAE;IACtB,MAAMhB,MAAM,GAAGD,kBAAkB,CAACL,GAAG,CAAC;IACtC,IAAIgB,MAAM,CAACO,IAAI,CAACjB,MAAM,CAAC,CAACkB,MAAM,GAAG,CAAC,EAAE,OAAO;MAAEH,IAAI,EAAE,SAAS;MAAEf;IAAO,CAAC;EACxE;EACA,OAAO;IAAEe,IAAI,EAAE;EAAS,CAAC;AAC3B","ignoreList":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.unsupportedStepError = unsupportedStepError;
|
|
7
|
+
var _types = require("../types");
|
|
8
|
+
var _i18n = require("../i18n");
|
|
9
|
+
/**
|
|
10
|
+
* @fileoverview The `UNSUPPORTED_STEP` error, shared by the orchestrator (a
|
|
11
|
+
* step code this SDK does not know) and `CUSTOM_FORM` (a required field of a
|
|
12
|
+
* type it does not know).
|
|
13
|
+
*
|
|
14
|
+
* JSX-free so the orchestrator tests can import it in the `node` environment.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Builds the error that ends the flow on a step this SDK cannot render. The
|
|
19
|
+
* localized `declineTitle` / `declineMessage` feed the built-in error screen;
|
|
20
|
+
* `message` is the English text for the host's logs.
|
|
21
|
+
*/
|
|
22
|
+
function unsupportedStepError(locale, stepCode, stepKey, message) {
|
|
23
|
+
const copy = (0, _i18n.getStrings)(locale).unsupported_step;
|
|
24
|
+
return {
|
|
25
|
+
code: _types.SdkErrorCode.UNSUPPORTED_STEP,
|
|
26
|
+
message,
|
|
27
|
+
stepCode,
|
|
28
|
+
stepKey,
|
|
29
|
+
declineTitle: copy.title,
|
|
30
|
+
declineMessage: copy.message
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=unsupportedStep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_types","require","_i18n","unsupportedStepError","locale","stepCode","stepKey","message","copy","getStrings","unsupported_step","code","SdkErrorCode","UNSUPPORTED_STEP","declineTitle","title","declineMessage"],"sourceRoot":"../../../src","sources":["steps/unsupportedStep.ts"],"mappings":";;;;;;AAQA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AATA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACO,SAASE,oBAAoBA,CAClCC,MAA0B,EAC1BC,QAAgB,EAChBC,OAAe,EACfC,OAAe,EACL;EACV,MAAMC,IAAI,GAAG,IAAAC,gBAAU,EAACL,MAAM,CAAC,CAACM,gBAAgB;EAChD,OAAO;IACLC,IAAI,EAAEC,mBAAY,CAACC,gBAAgB;IACnCN,OAAO;IACPF,QAAQ;IACRC,OAAO;IACPQ,YAAY,EAAEN,IAAI,CAACO,KAAK;IACxBC,cAAc,EAAER,IAAI,CAACD;EACvB,CAAC;AACH","ignoreList":[]}
|
|
@@ -29,13 +29,22 @@ exports.VELION_MSG_TOKEN_EXPIRED = exports.VELION_MSG_TOKEN = exports.VELION_MSG
|
|
|
29
29
|
* - `ECONOMIC_ACTIVITY_DECLARATION`: pick exactly one economic activity from a searchable list.
|
|
30
30
|
* - `TERMS_AND_CONDITIONS`: accept configured T&C items.
|
|
31
31
|
* - `FACE_MATCH`: server-side face comparison after liveness (no user input; SDK waits).
|
|
32
|
+
* - `CUSTOM_FORM`: form built from the workflow's `form_fields`. A workflow may hold
|
|
33
|
+
* several, told apart by their `step_key`.
|
|
34
|
+
* - `ENTITY_TYPE_SELECTION`: the person picks HUMAN or LEGAL; the backend branches on it.
|
|
35
|
+
*
|
|
36
|
+
* A code outside this list fails the flow with {@link SdkErrorCode.UNSUPPORTED_STEP}.
|
|
32
37
|
*/
|
|
33
38
|
/**
|
|
34
39
|
* Status of an individual onboarding step (matches backend OnboardingStepStatus).
|
|
35
40
|
*/
|
|
36
41
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
42
|
+
* Choice of the `ENTITY_TYPE_SELECTION` step (`selected_type`): a natural
|
|
43
|
+
* person (`HUMAN`) or a legal entity (`LEGAL`).
|
|
44
|
+
*/
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated The session DTO no longer carries an `onboarding_type`; the
|
|
47
|
+
* person picks it in `ENTITY_TYPE_SELECTION`. Use {@link EntityType}.
|
|
39
48
|
*/
|
|
40
49
|
/** Which face of the ID document is being captured. */
|
|
41
50
|
/**
|
|
@@ -75,7 +84,23 @@ exports.VELION_MSG_TOKEN_EXPIRED = exports.VELION_MSG_TOKEN = exports.VELION_MSG
|
|
|
75
84
|
/** STEP config for ECONOMIC_ACTIVITY_DECLARATION (`current_step.config`). */
|
|
76
85
|
/** STEP config for DOCUMENTS_OCR. */
|
|
77
86
|
/** STEP config for TERMS_AND_CONDITIONS. */
|
|
78
|
-
/**
|
|
87
|
+
/**
|
|
88
|
+
* Field types a `CUSTOM_FORM` can declare. The SDK renders a field whose type it
|
|
89
|
+
* does not know as `TEXT` when it is optional, and fails the step with
|
|
90
|
+
* `UNSUPPORTED_STEP` when it is required.
|
|
91
|
+
*/
|
|
92
|
+
/** One field of a `CUSTOM_FORM` (`config.form_fields[]`). */
|
|
93
|
+
/** STEP config for CUSTOM_FORM (`current_step.config`, SSE `step_config`). */
|
|
94
|
+
/** A `CUSTOM_FORM` answer, typed per {@link CustomFormFieldType}: DATE is `yyyy-MM-dd`, LIST one of `options`. */
|
|
95
|
+
/**
|
|
96
|
+
* POST /sessions/:id/custom-form/:stepKey. An optional field left unanswered is
|
|
97
|
+
* omitted, never sent as `null`.
|
|
98
|
+
*/
|
|
99
|
+
/** POST /sessions/:id/entity-type. */
|
|
100
|
+
/**
|
|
101
|
+
* Per-step runtime config cache carried by session state and SSE, keyed by the
|
|
102
|
+
* step instance (`step_key`, or the step code when the backend sends no key).
|
|
103
|
+
*/
|
|
79
104
|
/**
|
|
80
105
|
* Request body for POST /sessions/:sessionId/documents-init.
|
|
81
106
|
* Allowed values are defined by the backend; the SDK currently sends a fixed type until
|
|
@@ -203,6 +228,13 @@ let SdkErrorCode = exports.SdkErrorCode = /*#__PURE__*/function (SdkErrorCode) {
|
|
|
203
228
|
* mount the iframe to prevent execution of tampered/unsigned bundles.
|
|
204
229
|
*/
|
|
205
230
|
SdkErrorCode["INTEGRITY_FAILED"] = "INTEGRITY_FAILED";
|
|
231
|
+
/**
|
|
232
|
+
* The backend routed the session to a step this SDK version cannot render: a
|
|
233
|
+
* step code it does not know, or a `CUSTOM_FORM` with a required field of an
|
|
234
|
+
* unknown type. `stepCode` and `stepKey` name the step. The step is not
|
|
235
|
+
* skipped (the session would be declined); update the SDK to continue.
|
|
236
|
+
*/
|
|
237
|
+
SdkErrorCode["UNSUPPORTED_STEP"] = "UNSUPPORTED_STEP";
|
|
206
238
|
SdkErrorCode["UNKNOWN"] = "UNKNOWN";
|
|
207
239
|
return SdkErrorCode;
|
|
208
240
|
}({});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CameraErrorCode","exports","SdkErrorCode","VELION_MSG_INIT","VELION_MSG_READY","VELION_MSG_SUCCESS","VELION_MSG_ERROR","VELION_MSG_STEP_CHANGE","VELION_MSG_STEP_COMPLETE","VELION_MSG_TOKEN_EXPIRED","VELION_MSG_TOKEN"],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"names":["CameraErrorCode","exports","SdkErrorCode","VELION_MSG_INIT","VELION_MSG_READY","VELION_MSG_SUCCESS","VELION_MSG_ERROR","VELION_MSG_STEP_CHANGE","VELION_MSG_STEP_COMPLETE","VELION_MSG_TOKEN_EXPIRED","VELION_MSG_TOKEN"],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAsBA;AACA;AACA;AAQA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AAMA;AAMA;AAKA;AAQA;AACA;AACA;AACA;AAQA;AAQA;AAMA;AAaA;AAiBA;AAYA;AACA;AACA;AACA;AACA;AACA;AAQA;AAMA;AAaA;AAKA;AACA;AACA;AACA;AACA;AAGA;AAeA;AAUA;AAGA;AACA;AACA;AACA;AAKA;AAKA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AAUA;AACA;AACA;AAEA;AACA;AACA;AACA;AAHA,IAIYA,eAAe,GAAAC,OAAA,CAAAD,eAAA,0BAAfA,eAAe;EACzB;EADUA,eAAe;EAGzB;EAHUA,eAAe;EAKzB;AACF;AACA;AACA;EARYA,eAAe;EAUzB;AACF;AACA;AACA;EAbYA,eAAe;EAezB;AACF;AACA;AACA;AACA;EAnBYA,eAAe;EAqBzB;EArBUA,eAAe;EAuBzB;AACF;AACA;AACA;EA1BYA,eAAe;EA4BzB;EA5BUA,eAAe;EA8BzB;EA9BUA,eAAe;EAAA,OAAfA,eAAe;AAAA;AAkC3B;AACA;AACA;AAFA,IAGYE,YAAY,GAAAD,OAAA,CAAAC,YAAA,0BAAZA,YAAY;EACtB;EACA;EAFUA,YAAY;EAItB;EAJUA,YAAY;EAMtB;AACF;AACA;AACA;AACA;EAVYA,YAAY;EAYtB;EAZUA,YAAY;EActB;EAdUA,YAAY;EAgBtB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EAxBYA,YAAY;EA0BtB;AACF;AACA;AACA;AACA;AACA;AACA;EAhCYA,YAAY;EAmCtB;EACA;EApCUA,YAAY;EAsCtB;EAtCUA,YAAY;EAwCtB;EAxCUA,YAAY;EA0CtB;EA1CUA,YAAY;EA6CtB;EACA;AACF;AACA;AACA;EAjDYA,YAAY;EAoDtB;EACA;EArDUA,YAAY;EAuDtB;EAvDUA,YAAY;EA0DtB;EACA;EA3DUA,YAAY;EA6DtB;EA7DUA,YAAY;EA+DtB;EA/DUA,YAAY;EAkEtB;AACF;AACA;AACA;AACA;EAtEYA,YAAY;EAyEtB;AACF;AACA;AACA;AACA;EA7EYA,YAAY;EAgFtB;AACF;AACA;AACA;AACA;AACA;EArFYA,YAAY;EAAZA,YAAY;EAAA,OAAZA,YAAY;AAAA;AA2FxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA6CA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAwEA;AACA;AACA;AAMA;AACA;AACA;AACA;AAaA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AA6EA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAiOA;AACA;AACA;AAEA;AACA;AACA;AA4BA;AACA;AACA;AACA;AA6CA;AACA;AACA;AACA;AAyCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AA0BA;AACA;AACA;AACA;AACA;AA2BA;AACA;AACA;AACA;AACA;AACA;AAUA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AAqBA;AACA;AACA;AACA;AACA;AAYA;AACA;AACA;AACA;AAUA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AAMA;AACA;AACA;AAYA;AAUA;AAUA;AAMA;AAkBA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AAKA;AAKA;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA4CA;AACA;AACA;AAEA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AAMA;AACA;AACA;AAKA;AACA;AACA;AAKA;AACA;AACA;AACA;AAOA;AACA;AACA;AAOA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AASqB;AAErB;AACA;AACA;AACA;AAUA;AACA;AACA;AACA;AACA;AAWA;AACA;AACA;;AAEA;AACO,MAAMC,eAAe,GAAAF,OAAA,CAAAE,eAAA,GAAG,aAAsB;;AAErD;AACO,MAAMC,gBAAgB,GAAAH,OAAA,CAAAG,gBAAA,GAAG,cAAuB;AAChD,MAAMC,kBAAkB,GAAAJ,OAAA,CAAAI,kBAAA,GAAG,gBAAyB;AACpD,MAAMC,gBAAgB,GAAAL,OAAA,CAAAK,gBAAA,GAAG,cAAuB;AAChD,MAAMC,sBAAsB,GAAAN,OAAA,CAAAM,sBAAA,GAAG,oBAA6B;AAC5D,MAAMC,wBAAwB,GAAAP,OAAA,CAAAO,wBAAA,GAAG,sBAA+B;AAChE,MAAMC,wBAAwB,GAAAR,OAAA,CAAAQ,wBAAA,GAAG,sBAA+B;;AAEvE;AACO,MAAMC,gBAAgB,GAAAT,OAAA,CAAAS,gBAAA,GAAG,cAAuB;;AAYvD;;AAMA;;AAGA;;AAMA;;AAKA","ignoreList":[]}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RadioCard = RadioCard;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
var _Text = require("./Text");
|
|
9
|
+
var _theme = require("../theme");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
/**
|
|
12
|
+
* Single-choice option rendered as a tinted card with a radio dot.
|
|
13
|
+
*
|
|
14
|
+
* Same visual family as `Checkbox` `card`, but with `radio` semantics: one card
|
|
15
|
+
* of a group is selected at a time and pressing the selected one keeps it. Used
|
|
16
|
+
* by ENTITY_TYPE_SELECTION (HUMAN / LEGAL) and by the Yes / No answer of a
|
|
17
|
+
* CUSTOM_FORM `BOOLEAN` field, which must tell "no" apart from "not answered".
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
function RadioCard({
|
|
21
|
+
selected,
|
|
22
|
+
onPress,
|
|
23
|
+
title,
|
|
24
|
+
description,
|
|
25
|
+
disabled = false,
|
|
26
|
+
invalid = false,
|
|
27
|
+
style,
|
|
28
|
+
testID
|
|
29
|
+
}) {
|
|
30
|
+
const theme = (0, _theme.useTheme)();
|
|
31
|
+
const bgIdle = (0, _theme.mixHex)(theme.primaryColor, theme.backgroundColor, 8);
|
|
32
|
+
const bgActive = (0, _theme.mixHex)(theme.primaryColor, theme.backgroundColor, 14);
|
|
33
|
+
const borderColor = selected ? theme.primaryColor : invalid ? theme.errorColor : theme.borderColor;
|
|
34
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Pressable, {
|
|
35
|
+
accessibilityRole: "radio",
|
|
36
|
+
accessibilityState: {
|
|
37
|
+
disabled,
|
|
38
|
+
selected,
|
|
39
|
+
checked: selected
|
|
40
|
+
},
|
|
41
|
+
accessibilityLabel: title,
|
|
42
|
+
accessibilityHint: description,
|
|
43
|
+
disabled: disabled,
|
|
44
|
+
testID: testID,
|
|
45
|
+
onPress: onPress,
|
|
46
|
+
style: ({
|
|
47
|
+
pressed
|
|
48
|
+
}) => [styles.card, {
|
|
49
|
+
borderColor,
|
|
50
|
+
backgroundColor: selected ? bgActive : bgIdle,
|
|
51
|
+
borderRadius: theme.borderRadiusPx,
|
|
52
|
+
minHeight: Math.max(theme.inputHeightPx, 44)
|
|
53
|
+
}, pressed && !disabled && {
|
|
54
|
+
opacity: 0.85
|
|
55
|
+
}, disabled && styles.disabled, style],
|
|
56
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
57
|
+
style: [styles.ring, {
|
|
58
|
+
borderColor: selected ? theme.primaryColor : theme.borderColor
|
|
59
|
+
}],
|
|
60
|
+
children: selected ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
61
|
+
style: [styles.dot, {
|
|
62
|
+
backgroundColor: theme.primaryColor
|
|
63
|
+
}]
|
|
64
|
+
}) : null
|
|
65
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
66
|
+
style: styles.copy,
|
|
67
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.Text, {
|
|
68
|
+
style: [styles.title, {
|
|
69
|
+
color: theme.textColor
|
|
70
|
+
}],
|
|
71
|
+
children: title
|
|
72
|
+
}), description ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.Text, {
|
|
73
|
+
style: [styles.description, {
|
|
74
|
+
color: theme.textSecondaryColor
|
|
75
|
+
}],
|
|
76
|
+
children: description
|
|
77
|
+
}) : null]
|
|
78
|
+
})]
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
const styles = _reactNative.StyleSheet.create({
|
|
82
|
+
card: {
|
|
83
|
+
flexDirection: 'row',
|
|
84
|
+
alignItems: 'center',
|
|
85
|
+
gap: 10,
|
|
86
|
+
paddingHorizontal: 12,
|
|
87
|
+
paddingVertical: 10,
|
|
88
|
+
borderWidth: 1
|
|
89
|
+
},
|
|
90
|
+
disabled: {
|
|
91
|
+
opacity: 0.5
|
|
92
|
+
},
|
|
93
|
+
ring: {
|
|
94
|
+
width: 22,
|
|
95
|
+
height: 22,
|
|
96
|
+
borderWidth: 2,
|
|
97
|
+
borderRadius: 11,
|
|
98
|
+
alignItems: 'center',
|
|
99
|
+
justifyContent: 'center'
|
|
100
|
+
},
|
|
101
|
+
dot: {
|
|
102
|
+
width: 10,
|
|
103
|
+
height: 10,
|
|
104
|
+
borderRadius: 5
|
|
105
|
+
},
|
|
106
|
+
copy: {
|
|
107
|
+
flex: 1,
|
|
108
|
+
gap: 3
|
|
109
|
+
},
|
|
110
|
+
title: {
|
|
111
|
+
fontSize: 15,
|
|
112
|
+
fontWeight: '600',
|
|
113
|
+
lineHeight: 20
|
|
114
|
+
},
|
|
115
|
+
description: {
|
|
116
|
+
fontSize: 13,
|
|
117
|
+
lineHeight: 18
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
//# sourceMappingURL=RadioCard.js.map
|