@btndprojects/loam-ui-native 0.1.1 → 0.2.1
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/dist/accordion/index.js +5 -3
- package/dist/adaptive/index.js +6 -2
- package/dist/alert/index.js +5 -2
- package/dist/analyzer/index.js +9 -6
- package/dist/announcement/index.js +8 -5
- package/dist/audio-player/index.js +5 -3
- package/dist/avatar/index.js +5 -2
- package/dist/avatar-group/index.js +7 -3
- package/dist/badge/index.js +7 -4
- package/dist/banner/index.js +5 -2
- package/dist/board/index.js +11 -6
- package/dist/button/index.js +6 -3
- package/dist/camera-permission/index.js +15 -12
- package/dist/capture-result/index.js +19 -16
- package/dist/card/index.js +6 -3
- package/dist/card-form/index.js +12 -8
- package/dist/carousel/index.js +4 -2
- package/dist/chart/index.js +8 -5
- package/dist/charts/index.js +8 -6
- package/dist/chat/index.js +16 -0
- package/dist/checkbox/index.js +6 -4
- package/dist/checklist/index.js +11 -8
- package/dist/checkout/index.js +16 -11
- package/dist/chip/index.js +7 -4
- package/dist/{chunk-XNUVB5OL.js → chunk-2OLKPG4E.js} +92 -28
- package/dist/{chunk-RUZHTGKB.js → chunk-2PKYGLQ6.js} +71 -40
- package/dist/{chunk-UC2WGUP3.js → chunk-2SWKL3AJ.js} +91 -252
- package/dist/{chunk-AI4DWZCD.js → chunk-2SY63FCH.js} +63 -16
- package/dist/{chunk-F5XNPWS7.js → chunk-2TXERVVA.js} +92 -35
- package/dist/chunk-36EC2T6P.js +581 -0
- package/dist/chunk-3DUWIYV5.js +437 -0
- package/dist/{chunk-JNY4ZHAR.js → chunk-3QMEOFW5.js} +275 -71
- package/dist/chunk-3WEZCGHX.js +265 -0
- package/dist/chunk-46MMSDGL.js +194 -0
- package/dist/{chunk-7O2FMUPT.js → chunk-4IZXHVFJ.js} +297 -92
- package/dist/{chunk-LAECSR4H.js → chunk-5LAAAXFP.js} +14 -8
- package/dist/{chunk-2A5NIQAK.js → chunk-5RENVKBQ.js} +134 -46
- package/dist/{chunk-2ZZ7TDJ4.js → chunk-5UTRIXQ6.js} +37 -31
- package/dist/{chunk-LOE5YNN3.js → chunk-5VFZRGVD.js} +37 -10
- package/dist/{chunk-52X2VYTD.js → chunk-67IZZ2MJ.js} +115 -60
- package/dist/{chunk-UYG5L34B.js → chunk-6YAQBXB3.js} +10 -4
- package/dist/{chunk-BTTFCMKG.js → chunk-74FLKD24.js} +94 -23
- package/dist/{chunk-ITTYJZWX.js → chunk-7BUIKDD6.js} +73 -18
- package/dist/{chunk-423B7SPN.js → chunk-7OVVSVEZ.js} +273 -109
- package/dist/chunk-AEB7KCHQ.js +287 -0
- package/dist/chunk-APCWFOZW.js +28 -0
- package/dist/chunk-AWKQIE5I.js +139 -0
- package/dist/{chunk-VCDBXW5H.js → chunk-B7N4ASYE.js} +86 -42
- package/dist/{chunk-IVNRBPGC.js → chunk-C4GTDLRC.js} +104 -20
- package/dist/{chunk-4ZAHCY44.js → chunk-C6APNDVA.js} +12 -5
- package/dist/{chunk-4SZYY6AN.js → chunk-CMTVNF3D.js} +18 -13
- package/dist/{chunk-HZ6CNMAF.js → chunk-CPTOADB2.js} +151 -96
- package/dist/chunk-D5N5QWI7.js +1325 -0
- package/dist/{chunk-IIQTAY3J.js → chunk-DN7MNQIP.js} +113 -29
- package/dist/{chunk-47FWHGUN.js → chunk-DVGBZ3TX.js} +84 -23
- package/dist/chunk-DW3L54DQ.js +305 -0
- package/dist/{chunk-3ARE4TES.js → chunk-E2E3I5W2.js} +69 -18
- package/dist/{chunk-DHWADYZX.js → chunk-EDCBJV7J.js} +41 -28
- package/dist/{chunk-WSW6ZFAQ.js → chunk-ENP3BMZU.js} +4 -4
- package/dist/{chunk-OOPPQH27.js → chunk-EVOIGUBI.js} +43 -19
- package/dist/{chunk-VEAYTRPX.js → chunk-EY4DD67D.js} +165 -97
- package/dist/{chunk-223Q2T2Q.js → chunk-F3H33DQX.js} +132 -61
- package/dist/{chunk-CYRBHQQZ.js → chunk-F5B3UINI.js} +68 -35
- package/dist/{chunk-6X6PQ443.js → chunk-FAJI7BSC.js} +20 -9
- package/dist/{chunk-MOUJOP55.js → chunk-FUMHAAF3.js} +96 -29
- package/dist/{chunk-6HT2LP62.js → chunk-FV6HMP7W.js} +192 -73
- package/dist/{chunk-S7F6XLTK.js → chunk-FYWNRX4F.js} +76 -47
- package/dist/{chunk-YG3ZJHGU.js → chunk-FZGAAOKS.js} +30 -8
- package/dist/{chunk-YDGVJETP.js → chunk-G3AFC24V.js} +1 -1
- package/dist/{chunk-EJBDRVIH.js → chunk-G6UESEVN.js} +15 -8
- package/dist/chunk-GDKVKNR2.js +339 -0
- package/dist/chunk-GEIGMWNF.js +10 -0
- package/dist/{chunk-JUAMLEHX.js → chunk-H7DWSL4O.js} +24 -12
- package/dist/chunk-HJFFOOJ4.js +1 -0
- package/dist/{chunk-RW6ZL2FQ.js → chunk-HJLPZA4X.js} +106 -21
- package/dist/chunk-HYEOQWT7.js +647 -0
- package/dist/chunk-I2KLQ2HA.js +19 -0
- package/dist/{chunk-CJ5EOYZE.js → chunk-I4FHVKEC.js} +11 -5
- package/dist/{chunk-JNH2TYIN.js → chunk-IDM7JJMO.js} +19 -5
- package/dist/{chunk-O4AEHWII.js → chunk-IPUNJMAQ.js} +141 -49
- package/dist/{chunk-J7Q7VCVC.js → chunk-IT6FUXXG.js} +13 -6
- package/dist/{chunk-QJJ6MADV.js → chunk-IVKMZ7BB.js} +80 -28
- package/dist/{chunk-Z7H7VSFZ.js → chunk-IXKWIFWZ.js} +17 -6
- package/dist/chunk-J64KGCGX.js +55 -0
- package/dist/chunk-JBMLWFSJ.js +270 -0
- package/dist/{chunk-4BXMXBJO.js → chunk-JJLPBRVZ.js} +22 -11
- package/dist/chunk-JLC6PM5S.js +406 -0
- package/dist/chunk-JUYWSSKW.js +335 -0
- package/dist/{chunk-7CFF4HXS.js → chunk-JV5YOTOB.js} +49 -11
- package/dist/{chunk-LZLHELAG.js → chunk-KFJGFLMW.js} +29 -8
- package/dist/{chunk-O7AE6DAF.js → chunk-KQZ3GLHR.js} +18 -8
- package/dist/{chunk-N32RGOA5.js → chunk-LKFC4CS7.js} +80 -24
- package/dist/{chunk-YC6WORFL.js → chunk-LMPHCVJJ.js} +82 -50
- package/dist/{chunk-3WPW4KUN.js → chunk-LQP4KEXZ.js} +45 -13
- package/dist/{chunk-TKQYWZ5V.js → chunk-LUMVGO2K.js} +47 -31
- package/dist/{chunk-AWJOCGFZ.js → chunk-M656FYNH.js} +25 -13
- package/dist/{chunk-35OFI3JG.js → chunk-MKSNFG7H.js} +73 -20
- package/dist/{chunk-4GBOGOTV.js → chunk-NBEF4EPJ.js} +16 -6
- package/dist/chunk-NNCOFLNE.js +24 -0
- package/dist/{chunk-4YQOR7JM.js → chunk-NTQ2F3AU.js} +73 -20
- package/dist/{chunk-QCDXZBC5.js → chunk-O5V4TG3V.js} +126 -44
- package/dist/{chunk-U7TFM2JA.js → chunk-OJQUBQWA.js} +3 -3
- package/dist/{chunk-VQHPQEUH.js → chunk-OWAMM2DK.js} +13 -6
- package/dist/chunk-PID3NJB7.js +405 -0
- package/dist/{chunk-HET4LLMX.js → chunk-PMMTGBBS.js} +27 -17
- package/dist/{chunk-RIBDXGUG.js → chunk-PNF3NKB5.js} +49 -16
- package/dist/{chunk-JXJB2X6M.js → chunk-Q6NKEPRE.js} +81 -32
- package/dist/chunk-QDZGFXQD.js +176 -0
- package/dist/{chunk-SYNOJOQO.js → chunk-QEYFDRHR.js} +60 -26
- package/dist/{chunk-VBOXAEPI.js → chunk-QHAITQIF.js} +97 -22
- package/dist/{chunk-VXDZFJGP.js → chunk-QHTVYA65.js} +230 -76
- package/dist/{chunk-TUTI5HOZ.js → chunk-QIKT7LIB.js} +14 -8
- package/dist/{chunk-3ENTMPQY.js → chunk-QP3KMOVF.js} +82 -42
- package/dist/{chunk-GNNJ4GCC.js → chunk-QPWDDJJ4.js} +62 -148
- package/dist/{chunk-QWCMU5B2.js → chunk-QRUMA22E.js} +205 -80
- package/dist/{chunk-ZVFE5QGU.js → chunk-QYPE5JX3.js} +50 -10
- package/dist/{chunk-PUPM2YGF.js → chunk-ROCUG24E.js} +76 -36
- package/dist/{chunk-NQYBUO3K.js → chunk-RU3ZPNL6.js} +333 -142
- package/dist/{chunk-TOXAGRDQ.js → chunk-RXSCIO6W.js} +14 -5
- package/dist/{chunk-FMYDDECK.js → chunk-SATMR6SG.js} +631 -203
- package/dist/{chunk-4YIP3CWS.js → chunk-SHHY5OMK.js} +7 -5
- package/dist/chunk-SKWO3SZF.js +2284 -0
- package/dist/{chunk-YF4NSSMT.js → chunk-SWS5JQIF.js} +41 -13
- package/dist/{chunk-CUMUNPXY.js → chunk-T5LTPKX6.js} +15 -7
- package/dist/{chunk-H6NIOQHK.js → chunk-TDMG26JI.js} +26 -6
- package/dist/{chunk-UWFLYMAR.js → chunk-TLCIR6RG.js} +267 -126
- package/dist/{chunk-SBMNWWBV.js → chunk-TN2ZNJUI.js} +47 -9
- package/dist/{chunk-5YNTNN5A.js → chunk-TQVAIKFD.js} +106 -41
- package/dist/chunk-TRGFFU6A.js +1456 -0
- package/dist/{chunk-2GK6PHGE.js → chunk-TY4MTKQJ.js} +100 -22
- package/dist/{chunk-AZRX6SAC.js → chunk-U23FYWME.js} +15 -7
- package/dist/{chunk-PZXZJBMP.js → chunk-U5NLHYV6.js} +26 -12
- package/dist/chunk-UQEN55EY.js +1 -0
- package/dist/chunk-UQGBTPXH.js +218 -0
- package/dist/chunk-UXGIW7OK.js +116 -0
- package/dist/{chunk-PJXUJYS6.js → chunk-UYGDJWMN.js} +55 -30
- package/dist/{chunk-QDYDBCFP.js → chunk-V2OEB75Z.js} +50 -51
- package/dist/{chunk-LSS54GLJ.js → chunk-VAOAKWUK.js} +34 -13
- package/dist/{chunk-DM5QUKKO.js → chunk-VDPK5CY4.js} +18 -6
- package/dist/chunk-W23G6JLF.js +37 -0
- package/dist/{chunk-CDRZHT42.js → chunk-W63AJTM7.js} +276 -12
- package/dist/{chunk-XXXEFXY5.js → chunk-W74TXYFB.js} +13 -5
- package/dist/{chunk-LRJNDEIA.js → chunk-WRDSPUE7.js} +144 -29
- package/dist/{chunk-C2NTXVWM.js → chunk-XBZGDDMR.js} +11 -4
- package/dist/{chunk-BV3B2HYZ.js → chunk-XIDTBCBA.js} +189 -131
- package/dist/{chunk-YTFKPRUK.js → chunk-XN4KG3P4.js} +348 -153
- package/dist/chunk-XQXMLMH3.js +211 -0
- package/dist/{chunk-HPPW424V.js → chunk-XTORZWRF.js} +19 -8
- package/dist/{chunk-P23EQNRQ.js → chunk-YAAHPATV.js} +181 -30
- package/dist/{chunk-KMI5ML5I.js → chunk-YXOAPXMU.js} +57 -18
- package/dist/{chunk-RJQOOHT2.js → chunk-ZECZOOSB.js} +59 -28
- package/dist/{chunk-QKXCPTFS.js → chunk-ZLTO5VQI.js} +121 -31
- package/dist/{chunk-BEDBFJND.js → chunk-ZVATDZOM.js} +16 -18
- package/dist/coachmark/index.js +6 -3
- package/dist/code-block/index.js +5 -3
- package/dist/color-field/index.js +6 -4
- package/dist/commerce/index.js +19 -16
- package/dist/connectivity/index.js +5 -2
- package/dist/context-menu/index.js +5 -3
- package/dist/copy-button/index.js +4 -2
- package/dist/data-grid/index.js +21 -16
- package/dist/date-range-picker/index.js +11 -8
- package/dist/description-list/index.js +3 -1
- package/dist/dialog/index.js +4 -2
- package/dist/empty-state/index.js +4 -2
- package/dist/error-summary/index.js +4 -2
- package/dist/fab/index.js +5 -2
- package/dist/file-manager/index.js +28 -0
- package/dist/file-upload/index.js +10 -7
- package/dist/filter-bar/index.js +9 -6
- package/dist/flow-run/index.js +15 -12
- package/dist/form/index.js +5 -3
- package/dist/gallery/index.js +5 -2
- package/dist/hold-to-confirm/index.js +4 -2
- package/dist/index.d.ts +9557 -2985
- package/dist/index.js +355 -122
- package/dist/infinite-list/index.js +4 -2
- package/dist/inline-edit/index.js +6 -4
- package/dist/input/index.js +5 -3
- package/dist/interactions/index.js +2 -1
- package/dist/invoice/index.js +13 -9
- package/dist/kbd/index.js +5 -1
- package/dist/keyboard/index.js +4 -2
- package/dist/list-row/index.js +6 -4
- package/dist/log-viewer/index.js +4 -2
- package/dist/map-view/index.js +5 -3
- package/dist/markdown/index.js +9 -6
- package/dist/metric/index.js +7 -4
- package/dist/money/index.js +9 -3
- package/dist/nav-drawer/index.js +4 -2
- package/dist/nav-header/index.js +9 -0
- package/dist/navigation/index.js +5 -2
- package/dist/notification-center/index.js +12 -10
- package/dist/number-roll/index.js +5 -2
- package/dist/one-handed/index.js +5 -3
- package/dist/os-surfaces/index.js +6 -3
- package/dist/otp/index.js +7 -4
- package/dist/page-header/index.js +1 -0
- package/dist/pagination/index.js +6 -0
- package/dist/payment-method/index.js +14 -10
- package/dist/payment-status/index.js +17 -14
- package/dist/permission/index.js +5 -2
- package/dist/picker/index.js +11 -6
- package/dist/progress/index.js +6 -3
- package/dist/pull-to-refresh/index.js +4 -2
- package/dist/radio-group/index.js +6 -4
- package/dist/rating/index.js +5 -2
- package/dist/receivables/index.js +21 -16
- package/dist/refund/index.js +18 -14
- package/dist/save-status/index.js +5 -3
- package/dist/scroll-area/index.js +3 -1
- package/dist/search-field/index.js +8 -0
- package/dist/segmented-control/index.js +4 -3
- package/dist/sheet/index.js +5 -3
- package/dist/skeleton/index.js +3 -1
- package/dist/slider/index.js +4 -2
- package/dist/sortable/index.js +7 -0
- package/dist/spinner/index.js +3 -1
- package/dist/split-button/index.js +9 -6
- package/dist/spotlight/index.js +3 -1
- package/dist/stage-timeline/index.js +5 -3
- package/dist/status-dot/index.js +4 -2
- package/dist/stepper/index.js +7 -4
- package/dist/streaming-text/index.js +3 -2
- package/dist/survey/index.js +18 -15
- package/dist/switch/index.js +5 -3
- package/dist/system-state/index.js +7 -4
- package/dist/tab-bar/index.js +5 -2
- package/dist/tabs/index.js +4 -2
- package/dist/tags-input/index.js +10 -0
- package/dist/textarea/index.js +6 -4
- package/dist/thinking/index.js +3 -1
- package/dist/time-field/index.js +12 -0
- package/dist/time-range-control/index.js +22 -0
- package/dist/timeline/index.js +4 -2
- package/dist/toast/index.js +4 -2
- package/dist/toolbar/index.js +4 -2
- package/dist/tour/index.js +12 -9
- package/dist/truncation-notice/index.js +5 -2
- package/dist/update-notice/index.js +12 -9
- package/dist/video-player/index.js +5 -2
- package/dist/viewfinder/index.js +6 -4
- package/dist/widget/index.js +7 -4
- package/dist/wizard/index.js +7 -4
- package/package.json +13 -12
- package/dist/chunk-6N33LFQA.js +0 -35
- package/dist/chunk-GDKZTW34.js +0 -395
- package/dist/chunk-GL7B2DOW.js +0 -134
- package/dist/chunk-NKB7BZYK.js +0 -167
- package/dist/chunk-OETCUXQP.js +0 -134
- package/dist/chunk-OPXFZ4Y5.js +0 -204
- package/dist/chunk-Q72LJOVE.js +0 -169
- package/dist/chunk-RNGLIHFA.js +0 -191
- package/dist/chunk-RQ3HASCC.js +0 -6
- package/dist/chunk-RSOJT5YW.js +0 -124
- package/dist/chunk-TKVFVF5D.js +0 -95
- package/dist/chunk-XOSCY2CW.js +0 -242
- package/dist/header/index.js +0 -5
- package/dist/search-bar/index.js +0 -5
- /package/dist/{chunk-3ECPOSKO.js → chunk-3UG6JUCV.js} +0 -0
- /package/dist/{chunk-JRLTGLN4.js → chunk-5WWRTEPS.js} +0 -0
- /package/dist/{chunk-RTIKSY6A.js → chunk-5Z5ZYMOJ.js} +0 -0
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { storageKey, readStored, writeStored } from './chunk-NNCOFLNE.js';
|
|
2
|
+
import { Slider } from './chunk-TDMG26JI.js';
|
|
3
|
+
import { Textarea } from './chunk-74FLKD24.js';
|
|
4
|
+
import { Picker } from './chunk-PID3NJB7.js';
|
|
5
|
+
import { Progress } from './chunk-5UTRIXQ6.js';
|
|
6
|
+
import { Sheet } from './chunk-QYPE5JX3.js';
|
|
7
|
+
import { Chip } from './chunk-2SY63FCH.js';
|
|
8
|
+
import { Input } from './chunk-7BUIKDD6.js';
|
|
9
|
+
import { Button } from './chunk-E2E3I5W2.js';
|
|
10
|
+
import { useLabels } from './chunk-APCWFOZW.js';
|
|
11
|
+
import { Icon } from './chunk-UXGIW7OK.js';
|
|
12
|
+
import { useResolvedMotion, springConfig } from './chunk-J64KGCGX.js';
|
|
10
13
|
import * as React2 from 'react';
|
|
11
|
-
import { View, Text, Pressable } from 'react-native';
|
|
14
|
+
import { View, Text, Pressable, Animated } from 'react-native';
|
|
12
15
|
import { createStyleSheet, useStyles, useLoamTheme } from '@btndprojects/loam-theme-native';
|
|
13
|
-
import { PMF_OPTIONS, scaleShape, resolveQuestion, resolveText, resolveHiddenFields, surveyPages, nextPageIndex, visibleQuestions, visiblePages, pickSurveyEnding, surveyCompletion, isQuestionRequired, isAnswerEmpty, prevPageIndex,
|
|
16
|
+
import { PMF_OPTIONS, scaleShape, resolveQuestion, resolveText, resolveHiddenFields, surveyPages, nextPageIndex, visibleQuestions, visiblePages, pickSurveyEnding, surveyCompletion, isQuestionRequired, isAnswerEmpty, prevPageIndex, validatePage, branchedEndingId } from '@btndprojects/loam-engage';
|
|
14
17
|
export { PMF_OPTIONS, SURVEY_OPERATORS, cesScore, csatScore, isAnswerEmpty, isPageVisible, matchSurveyCondition, nextPageIndex, npsBand, npsScore, prevPageIndex, scaleShape, surveyPages, surveyProgress, validatePage, visiblePages, visibleQuestions } from '@btndprojects/loam-engage';
|
|
15
18
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
16
19
|
|
|
@@ -27,7 +30,24 @@ var SURVEY_FIELD_LABELS = {
|
|
|
27
30
|
rankHint: "Most important at the top",
|
|
28
31
|
moveUp: "Move up",
|
|
29
32
|
moveDown: "Move down",
|
|
30
|
-
choosePlaceholder: "Choose one"
|
|
33
|
+
choosePlaceholder: "Choose one",
|
|
34
|
+
emailPlaceholder: "you@company.com",
|
|
35
|
+
score: (value, top, ends) => `Score ${value} of ${top}${ends.map((end) => ` \u2014 ${end}`).join("")}`,
|
|
36
|
+
matrixScore: (row, value, points) => `${row}: ${value} of ${points}`,
|
|
37
|
+
selectedOfCap: (picked, cap) => `${picked} of up to ${cap} selected`,
|
|
38
|
+
answeredOf: (done, total) => `${done} / ${total} answered`
|
|
39
|
+
};
|
|
40
|
+
var SURVEY_LABELS = {
|
|
41
|
+
...SURVEY_FIELD_LABELS,
|
|
42
|
+
back: "Back",
|
|
43
|
+
next: "Continue",
|
|
44
|
+
submit: "Send",
|
|
45
|
+
skip: "Skip",
|
|
46
|
+
close: "Close",
|
|
47
|
+
dismiss: "Dismiss survey",
|
|
48
|
+
doneTitle: "Thank you \u2014 logged.",
|
|
49
|
+
progress: (title, position, total) => `${title} \u2014 page ${position} of ${total}`,
|
|
50
|
+
validation: {}
|
|
31
51
|
};
|
|
32
52
|
var SURVEY_OTHER_PREFIX = "Other: ";
|
|
33
53
|
function SurveyField({
|
|
@@ -38,7 +58,7 @@ function SurveyField({
|
|
|
38
58
|
children
|
|
39
59
|
}) {
|
|
40
60
|
const { styles } = useStyles(sheet);
|
|
41
|
-
const labels =
|
|
61
|
+
const labels = useLabels("survey", SURVEY_LABELS, labelOverrides);
|
|
42
62
|
return (
|
|
43
63
|
// No accessible name on the wrapper: the question text is a visible label
|
|
44
64
|
// and every control below carries its own, so naming the group as well
|
|
@@ -56,16 +76,22 @@ function SurveyField({
|
|
|
56
76
|
);
|
|
57
77
|
}
|
|
58
78
|
function SurveyFieldError({ children }) {
|
|
59
|
-
const theme = useLoamTheme();
|
|
79
|
+
const theme = useLoamTheme("survey");
|
|
60
80
|
const { styles } = useStyles(sheet);
|
|
61
81
|
return /* @__PURE__ */ jsxs(View, { accessibilityLiveRegion: "polite", style: styles.errorRow, children: [
|
|
62
82
|
/* @__PURE__ */ jsx(Icon, { name: "alert-circle", size: theme.icon.xs, color: theme.color.danger }),
|
|
63
83
|
/* @__PURE__ */ jsx(Text, { style: styles.errorText, children })
|
|
64
84
|
] });
|
|
65
85
|
}
|
|
66
|
-
function SurveyScale({
|
|
67
|
-
|
|
86
|
+
function SurveyScale({
|
|
87
|
+
question,
|
|
88
|
+
value,
|
|
89
|
+
onChange,
|
|
90
|
+
labels: labelOverrides
|
|
91
|
+
}) {
|
|
92
|
+
const theme = useLoamTheme("survey");
|
|
68
93
|
const { styles } = useStyles(sheet);
|
|
94
|
+
const labels = useLabels("survey", SURVEY_LABELS, labelOverrides);
|
|
69
95
|
const { count, from } = scaleShape(question);
|
|
70
96
|
const top = from + count - 1;
|
|
71
97
|
return /* @__PURE__ */ jsxs(View, { style: styles.stackSm, children: [
|
|
@@ -73,16 +99,16 @@ function SurveyScale({ question, value, onChange }) {
|
|
|
73
99
|
const v = from + i;
|
|
74
100
|
const on = value === v;
|
|
75
101
|
const ends = [
|
|
76
|
-
v === from && question.low ?
|
|
77
|
-
v === top && question.high ?
|
|
78
|
-
].
|
|
102
|
+
v === from && question.low ? question.low : "",
|
|
103
|
+
v === top && question.high ? question.high : ""
|
|
104
|
+
].filter(Boolean);
|
|
79
105
|
return /* @__PURE__ */ jsx(
|
|
80
106
|
Pressable,
|
|
81
107
|
{
|
|
82
108
|
accessibilityRole: "radio",
|
|
83
109
|
accessibilityState: { checked: on },
|
|
84
110
|
"aria-checked": on,
|
|
85
|
-
accessibilityLabel:
|
|
111
|
+
accessibilityLabel: labels.score(v, top, ends),
|
|
86
112
|
onPress: () => onChange(v, true),
|
|
87
113
|
style: ({ pressed }) => [
|
|
88
114
|
styles.scaleCell,
|
|
@@ -107,7 +133,7 @@ function SurveyOptionRow({
|
|
|
107
133
|
role = "radio",
|
|
108
134
|
disabled = false
|
|
109
135
|
}) {
|
|
110
|
-
const theme = useLoamTheme();
|
|
136
|
+
const theme = useLoamTheme("survey");
|
|
111
137
|
const { styles } = useStyles(sheet);
|
|
112
138
|
return /* @__PURE__ */ jsxs(
|
|
113
139
|
Pressable,
|
|
@@ -124,7 +150,17 @@ function SurveyOptionRow({
|
|
|
124
150
|
pressed && !checked ? { backgroundColor: theme.state.pressed } : null
|
|
125
151
|
],
|
|
126
152
|
children: [
|
|
127
|
-
/* @__PURE__ */ jsx(
|
|
153
|
+
/* @__PURE__ */ jsx(
|
|
154
|
+
View,
|
|
155
|
+
{
|
|
156
|
+
style: [
|
|
157
|
+
styles.mark,
|
|
158
|
+
role === "checkbox" ? styles.markSquare : null,
|
|
159
|
+
checked ? styles.markOn : null
|
|
160
|
+
],
|
|
161
|
+
children: checked ? role === "checkbox" ? /* @__PURE__ */ jsx(Icon, { name: "check", size: theme.icon.xs, color: theme.color.accentInk }) : /* @__PURE__ */ jsx(View, { style: styles.markDot }) : null
|
|
162
|
+
}
|
|
163
|
+
),
|
|
128
164
|
/* @__PURE__ */ jsx(Text, { style: [styles.optionLabel, checked ? styles.optionLabelOn : null], children: label })
|
|
129
165
|
]
|
|
130
166
|
}
|
|
@@ -137,7 +173,7 @@ function SurveyOptions({
|
|
|
137
173
|
labels: labelOverrides
|
|
138
174
|
}) {
|
|
139
175
|
const { styles } = useStyles(sheet);
|
|
140
|
-
const labels =
|
|
176
|
+
const labels = useLabels("survey", SURVEY_LABELS, labelOverrides);
|
|
141
177
|
const options = question.options ?? (question.type === "pmf" ? PMF_RESOLVED : []);
|
|
142
178
|
const raw = typeof value === "string" ? value : void 0;
|
|
143
179
|
const isOther = Boolean(question.other && raw?.startsWith(SURVEY_OTHER_PREFIX));
|
|
@@ -172,8 +208,12 @@ function SurveyOptions({
|
|
|
172
208
|
) : null
|
|
173
209
|
] });
|
|
174
210
|
}
|
|
175
|
-
function SurveyCheckboxList({
|
|
176
|
-
|
|
211
|
+
function SurveyCheckboxList({
|
|
212
|
+
question,
|
|
213
|
+
value,
|
|
214
|
+
onChange
|
|
215
|
+
}) {
|
|
216
|
+
const theme = useLoamTheme("survey");
|
|
177
217
|
const { styles } = useStyles(sheet);
|
|
178
218
|
const picked = Array.isArray(value) ? [...value] : [];
|
|
179
219
|
const atCap = question.maxSelections != null && picked.length >= question.maxSelections;
|
|
@@ -228,7 +268,7 @@ function SurveyRank({
|
|
|
228
268
|
labels: labelOverrides
|
|
229
269
|
}) {
|
|
230
270
|
const { styles } = useStyles(sheet);
|
|
231
|
-
const labels =
|
|
271
|
+
const labels = useLabels("survey", SURVEY_LABELS, labelOverrides);
|
|
232
272
|
const declared = question.items ?? [];
|
|
233
273
|
const labelOf = (v) => declared.find((x) => x.value === v)?.label ?? v;
|
|
234
274
|
const items = Array.isArray(value) ? [...value] : declared.map((x) => x.value);
|
|
@@ -269,42 +309,61 @@ function SurveyRank({
|
|
|
269
309
|
)
|
|
270
310
|
] }, item)) });
|
|
271
311
|
}
|
|
272
|
-
function SurveyMatrix({
|
|
273
|
-
|
|
312
|
+
function SurveyMatrix({
|
|
313
|
+
question,
|
|
314
|
+
value,
|
|
315
|
+
onChange,
|
|
316
|
+
labels: labelOverrides
|
|
317
|
+
}) {
|
|
318
|
+
const theme = useLoamTheme("survey");
|
|
274
319
|
const { styles } = useStyles(sheet);
|
|
320
|
+
const labels = useLabels("survey", SURVEY_LABELS, labelOverrides);
|
|
275
321
|
const rows = question.rows ?? [];
|
|
276
322
|
const points = question.points ?? 5;
|
|
277
323
|
const current = value ?? {};
|
|
278
324
|
return /* @__PURE__ */ jsx(View, { style: styles.stackMd, children: rows.map((row) => /* @__PURE__ */ jsxs(View, { style: styles.matrixCard, children: [
|
|
279
325
|
/* @__PURE__ */ jsx(Text, { style: styles.matrixStatement, children: row.label }),
|
|
280
|
-
/* @__PURE__ */ jsx(
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
326
|
+
/* @__PURE__ */ jsx(
|
|
327
|
+
View,
|
|
328
|
+
{
|
|
329
|
+
accessibilityRole: "radiogroup",
|
|
330
|
+
accessibilityLabel: row.label,
|
|
331
|
+
style: styles.matrixRow,
|
|
332
|
+
children: Array.from({ length: points }, (_, i) => i + 1).map((v) => {
|
|
333
|
+
const on = current[row.value] === v;
|
|
334
|
+
return /* @__PURE__ */ jsx(
|
|
335
|
+
Pressable,
|
|
336
|
+
{
|
|
337
|
+
accessibilityRole: "radio",
|
|
338
|
+
accessibilityState: { checked: on },
|
|
339
|
+
"aria-checked": on,
|
|
340
|
+
accessibilityLabel: labels.matrixScore(row.label, v, points),
|
|
341
|
+
onPress: () => onChange({ ...current, [row.value]: v }),
|
|
342
|
+
style: ({ pressed }) => [
|
|
343
|
+
styles.matrixScore,
|
|
344
|
+
on ? styles.matrixScoreOn : null,
|
|
345
|
+
pressed && !on ? { backgroundColor: theme.state.pressed } : null
|
|
346
|
+
],
|
|
347
|
+
children: /* @__PURE__ */ jsx(Text, { style: [styles.matrixNumber, on ? styles.scaleNumberOn : null], children: v })
|
|
348
|
+
},
|
|
349
|
+
v
|
|
350
|
+
);
|
|
351
|
+
})
|
|
352
|
+
}
|
|
353
|
+
),
|
|
300
354
|
/* @__PURE__ */ jsxs(View, { style: styles.endsRow, children: [
|
|
301
355
|
/* @__PURE__ */ jsx(Text, { style: styles.endLabel, children: question.low }),
|
|
302
356
|
/* @__PURE__ */ jsx(Text, { style: styles.endLabel, children: question.high })
|
|
303
357
|
] })
|
|
304
358
|
] }, row.value)) });
|
|
305
359
|
}
|
|
306
|
-
function SurveyConsent({
|
|
307
|
-
|
|
360
|
+
function SurveyConsent({
|
|
361
|
+
question,
|
|
362
|
+
value,
|
|
363
|
+
onChange,
|
|
364
|
+
error
|
|
365
|
+
}) {
|
|
366
|
+
const theme = useLoamTheme("survey");
|
|
308
367
|
const { styles } = useStyles(sheet);
|
|
309
368
|
const on = value === true;
|
|
310
369
|
return /* @__PURE__ */ jsxs(View, { style: styles.stackSm, children: [
|
|
@@ -360,20 +419,36 @@ function SurveyBoolean({
|
|
|
360
419
|
labels: labelOverrides
|
|
361
420
|
}) {
|
|
362
421
|
const { styles } = useStyles(sheet);
|
|
363
|
-
const labels =
|
|
364
|
-
return /* @__PURE__ */ jsx(
|
|
365
|
-
|
|
422
|
+
const labels = useLabels("survey", SURVEY_LABELS, labelOverrides);
|
|
423
|
+
return /* @__PURE__ */ jsx(
|
|
424
|
+
View,
|
|
366
425
|
{
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
426
|
+
style: styles.booleanRow,
|
|
427
|
+
accessibilityRole: "radiogroup",
|
|
428
|
+
accessibilityLabel: question.text,
|
|
429
|
+
children: [
|
|
430
|
+
[labels.yes, true],
|
|
431
|
+
[labels.no, false]
|
|
432
|
+
].map(([label, val]) => /* @__PURE__ */ jsx(View, { style: styles.grow, children: /* @__PURE__ */ jsx(
|
|
433
|
+
Button,
|
|
434
|
+
{
|
|
435
|
+
size: "lg",
|
|
436
|
+
fullWidth: true,
|
|
437
|
+
variant: value === val ? "primary" : "outline",
|
|
438
|
+
accessibilityLabel: label,
|
|
439
|
+
onPress: () => onChange(val, true),
|
|
440
|
+
children: label
|
|
441
|
+
}
|
|
442
|
+
) }, label))
|
|
373
443
|
}
|
|
374
|
-
)
|
|
444
|
+
);
|
|
375
445
|
}
|
|
376
|
-
function SurveyOpenText({
|
|
446
|
+
function SurveyOpenText({
|
|
447
|
+
question,
|
|
448
|
+
value,
|
|
449
|
+
onChange,
|
|
450
|
+
error
|
|
451
|
+
}) {
|
|
377
452
|
const text = typeof value === "string" ? value : "";
|
|
378
453
|
return /* @__PURE__ */ jsx(
|
|
379
454
|
Textarea,
|
|
@@ -388,7 +463,14 @@ function SurveyOpenText({ question, value, onChange, error }) {
|
|
|
388
463
|
}
|
|
389
464
|
);
|
|
390
465
|
}
|
|
391
|
-
function SurveyTextInput({
|
|
466
|
+
function SurveyTextInput({
|
|
467
|
+
question,
|
|
468
|
+
value,
|
|
469
|
+
onChange,
|
|
470
|
+
error,
|
|
471
|
+
labels: labelOverrides
|
|
472
|
+
}) {
|
|
473
|
+
const labels = useLabels("survey", SURVEY_LABELS, labelOverrides);
|
|
392
474
|
const t = question.type;
|
|
393
475
|
const text = value == null ? "" : String(value);
|
|
394
476
|
return /* @__PURE__ */ jsx(
|
|
@@ -399,7 +481,7 @@ function SurveyTextInput({ question, value, onChange, error }) {
|
|
|
399
481
|
keyboardType: t === "number" ? "number-pad" : t === "email" ? "email-address" : "default",
|
|
400
482
|
autoCapitalize: t === "email" ? "none" : "sentences",
|
|
401
483
|
autoComplete: t === "email" ? "email" : void 0,
|
|
402
|
-
placeholder: question.placeholder ?? (t === "email" ?
|
|
484
|
+
placeholder: question.placeholder ?? (t === "email" ? labels.emailPlaceholder : void 0),
|
|
403
485
|
error: Boolean(error),
|
|
404
486
|
value: text,
|
|
405
487
|
onChangeText: (next) => onChange(t === "number" ? next.replace(/[^\d.-]/g, "") : next)
|
|
@@ -412,7 +494,7 @@ function SurveyDropdown({
|
|
|
412
494
|
onChange,
|
|
413
495
|
labels: labelOverrides
|
|
414
496
|
}) {
|
|
415
|
-
const labels =
|
|
497
|
+
const labels = useLabels("survey", SURVEY_LABELS, labelOverrides);
|
|
416
498
|
return /* @__PURE__ */ jsx(
|
|
417
499
|
Picker,
|
|
418
500
|
{
|
|
@@ -440,7 +522,7 @@ function SurveyQuestionField({
|
|
|
440
522
|
const props = { ...control, question };
|
|
441
523
|
const { value, error, labels } = props;
|
|
442
524
|
const t = question.type;
|
|
443
|
-
const merged =
|
|
525
|
+
const merged = useLabels("survey", SURVEY_LABELS, labels);
|
|
444
526
|
if (t === "consent") return /* @__PURE__ */ jsx(SurveyConsent, { ...props });
|
|
445
527
|
const foot = (node) => node;
|
|
446
528
|
if (t === "nps" || t === "csat" || t === "ces" || t === "scale") {
|
|
@@ -459,7 +541,7 @@ function SurveyQuestionField({
|
|
|
459
541
|
error,
|
|
460
542
|
labels,
|
|
461
543
|
foot: foot(
|
|
462
|
-
cap ? /* @__PURE__ */ jsx(Text, { style: styles.metaText, children: t === "multi" ?
|
|
544
|
+
cap ? /* @__PURE__ */ jsx(Text, { style: styles.metaText, children: t === "multi" ? merged.selectedOfCap(picked.length, cap) : `${picked.length} / ${cap}` }) : null
|
|
463
545
|
),
|
|
464
546
|
children: t === "multi" ? /* @__PURE__ */ jsx(SurveyCheckboxList, { ...props }) : /* @__PURE__ */ jsx(SurveyChips, { ...props })
|
|
465
547
|
}
|
|
@@ -494,12 +576,7 @@ function SurveyQuestionField({
|
|
|
494
576
|
question,
|
|
495
577
|
error,
|
|
496
578
|
labels,
|
|
497
|
-
foot: /* @__PURE__ */
|
|
498
|
-
Object.keys(current).length,
|
|
499
|
-
" / ",
|
|
500
|
-
(question.rows ?? []).length,
|
|
501
|
-
" answered"
|
|
502
|
-
] }),
|
|
579
|
+
foot: /* @__PURE__ */ jsx(Text, { style: styles.metaText, children: merged.answeredOf(Object.keys(current).length, (question.rows ?? []).length) }),
|
|
503
580
|
children: /* @__PURE__ */ jsx(SurveyMatrix, { ...props })
|
|
504
581
|
}
|
|
505
582
|
);
|
|
@@ -684,7 +761,7 @@ var sheet = createStyleSheet((theme) => ({
|
|
|
684
761
|
color: theme.color.text
|
|
685
762
|
},
|
|
686
763
|
matrixRow: { flexDirection: "row", gap: theme.space[5] },
|
|
687
|
-
|
|
764
|
+
matrixScore: {
|
|
688
765
|
flex: 1,
|
|
689
766
|
height: theme.space[40],
|
|
690
767
|
alignItems: "center",
|
|
@@ -694,7 +771,7 @@ var sheet = createStyleSheet((theme) => ({
|
|
|
694
771
|
borderColor: theme.color.borderStrong,
|
|
695
772
|
backgroundColor: theme.color.surface
|
|
696
773
|
},
|
|
697
|
-
|
|
774
|
+
matrixScoreOn: { borderColor: theme.color.accent, backgroundColor: theme.color.accent },
|
|
698
775
|
matrixNumber: {
|
|
699
776
|
fontFamily: theme.font.mono,
|
|
700
777
|
fontSize: theme.type.footnote.fontSize,
|
|
@@ -729,39 +806,41 @@ var sheet = createStyleSheet((theme) => ({
|
|
|
729
806
|
fontVariant: ["tabular-nums"]
|
|
730
807
|
}
|
|
731
808
|
}));
|
|
732
|
-
var DEFAULT_LABELS = {
|
|
733
|
-
...SURVEY_FIELD_LABELS,
|
|
734
|
-
back: "Back",
|
|
735
|
-
next: "Continue",
|
|
736
|
-
submit: "Send",
|
|
737
|
-
skip: "Skip",
|
|
738
|
-
close: "Close",
|
|
739
|
-
dismiss: "Dismiss survey",
|
|
740
|
-
doneTitle: "Thank you \u2014 logged."
|
|
741
|
-
};
|
|
742
809
|
var TAP_TO_COMMIT = /* @__PURE__ */ new Set(["nps", "csat", "ces", "scale", "pmf", "boolean", "choice"]);
|
|
743
810
|
function SurveyPager({ total, index }) {
|
|
744
|
-
const theme = useLoamTheme();
|
|
811
|
+
const theme = useLoamTheme("survey");
|
|
745
812
|
const { styles } = useStyles(sheetStyles);
|
|
746
|
-
return /* @__PURE__ */ jsx(
|
|
813
|
+
return /* @__PURE__ */ jsx(
|
|
747
814
|
View,
|
|
748
815
|
{
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
816
|
+
accessibilityElementsHidden: true,
|
|
817
|
+
importantForAccessibility: "no-hide-descendants",
|
|
818
|
+
style: styles.pager,
|
|
819
|
+
children: Array.from({ length: total }, (_, i) => /* @__PURE__ */ jsx(
|
|
820
|
+
View,
|
|
821
|
+
{
|
|
822
|
+
style: [
|
|
823
|
+
styles.pagerDot,
|
|
824
|
+
i === index ? { width: theme.space[16], backgroundColor: theme.color.accent } : { backgroundColor: i < index ? theme.color.text3 : theme.color.borderStrong }
|
|
825
|
+
]
|
|
826
|
+
},
|
|
827
|
+
i
|
|
828
|
+
))
|
|
829
|
+
}
|
|
830
|
+
);
|
|
756
831
|
}
|
|
757
832
|
function SurveyDoneCard({
|
|
758
|
-
title
|
|
833
|
+
title: titleProp,
|
|
759
834
|
body,
|
|
760
835
|
action,
|
|
761
836
|
onClose,
|
|
762
|
-
closeLabel
|
|
837
|
+
closeLabel: closeLabelProp,
|
|
838
|
+
labels: labelOverrides
|
|
763
839
|
}) {
|
|
764
|
-
const
|
|
840
|
+
const labels = useLabels("survey", SURVEY_LABELS, labelOverrides);
|
|
841
|
+
const title = titleProp ?? labels.doneTitle;
|
|
842
|
+
const closeLabel = closeLabelProp ?? labels.close;
|
|
843
|
+
const theme = useLoamTheme("survey");
|
|
765
844
|
const { styles } = useStyles(sheetStyles);
|
|
766
845
|
return /* @__PURE__ */ jsxs(View, { style: styles.doneBody, children: [
|
|
767
846
|
/* @__PURE__ */ jsxs(View, { style: styles.doneHead, children: [
|
|
@@ -788,9 +867,13 @@ function Survey({
|
|
|
788
867
|
onDismiss,
|
|
789
868
|
onAction,
|
|
790
869
|
onEvent,
|
|
791
|
-
autoAdvance =
|
|
870
|
+
autoAdvance = false,
|
|
871
|
+
persistKey,
|
|
872
|
+
storage,
|
|
792
873
|
autoCloseMs,
|
|
793
874
|
dismissible = true,
|
|
875
|
+
showProgress = true,
|
|
876
|
+
skippable = true,
|
|
794
877
|
locale,
|
|
795
878
|
hiddenFields,
|
|
796
879
|
metadata,
|
|
@@ -798,9 +881,9 @@ function Survey({
|
|
|
798
881
|
labels: labelOverrides,
|
|
799
882
|
motion = "full"
|
|
800
883
|
}) {
|
|
801
|
-
const theme = useLoamTheme();
|
|
884
|
+
const theme = useLoamTheme("survey");
|
|
802
885
|
const { styles } = useStyles(sheetStyles);
|
|
803
|
-
const labels =
|
|
886
|
+
const labels = useLabels("survey", SURVEY_LABELS, labelOverrides);
|
|
804
887
|
const fallbackLocale = survey.defaultLocale;
|
|
805
888
|
const t = React2.useCallback(
|
|
806
889
|
(value) => resolveText(value, locale, fallbackLocale),
|
|
@@ -808,23 +891,66 @@ function Survey({
|
|
|
808
891
|
);
|
|
809
892
|
const ctx = React2.useMemo(
|
|
810
893
|
() => ({
|
|
811
|
-
hidden: resolveHiddenFields(survey.hiddenFields, {
|
|
894
|
+
hidden: resolveHiddenFields(survey.hiddenFields, {
|
|
895
|
+
supplied: hiddenFields,
|
|
896
|
+
urlParams,
|
|
897
|
+
metadata
|
|
898
|
+
}),
|
|
812
899
|
metadata,
|
|
813
900
|
urlParams
|
|
814
901
|
}),
|
|
815
902
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
816
903
|
[]
|
|
817
904
|
);
|
|
818
|
-
const
|
|
905
|
+
const savedKey = persistKey ? storageKey("survey", persistKey) : void 0;
|
|
906
|
+
const saved = React2.useMemo(
|
|
907
|
+
() => savedKey ? readStored(storage, savedKey) : null,
|
|
908
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
909
|
+
[]
|
|
910
|
+
);
|
|
911
|
+
const [uncontrolled, setUncontrolled] = React2.useState(
|
|
912
|
+
saved?.answers ?? defaultAnswers ?? {}
|
|
913
|
+
);
|
|
819
914
|
const answers = answersProp ?? uncontrolled;
|
|
820
915
|
const pages = surveyPages(survey);
|
|
821
916
|
const firstPage = React2.useMemo(() => nextPageIndex(survey, answers, null, ctx), []);
|
|
822
|
-
const [uncontrolledPage, setUncontrolledPage] = React2.useState(
|
|
917
|
+
const [uncontrolledPage, setUncontrolledPage] = React2.useState(
|
|
918
|
+
typeof saved?.page === "number" && saved.page >= 0 && saved.page < pages.length ? saved.page : Math.max(0, firstPage)
|
|
919
|
+
);
|
|
823
920
|
const pageIdx = pageProp ?? uncontrolledPage;
|
|
921
|
+
const level = useResolvedMotion(motion, "survey");
|
|
922
|
+
const pageFade = React2.useRef(new Animated.Value(1)).current;
|
|
923
|
+
const pageShift = React2.useRef(new Animated.Value(0)).current;
|
|
924
|
+
const shownPage = React2.useRef(pageIdx);
|
|
925
|
+
React2.useEffect(() => {
|
|
926
|
+
if (shownPage.current === pageIdx) return;
|
|
927
|
+
const direction = pageIdx > shownPage.current || pageIdx < 0 ? 1 : -1;
|
|
928
|
+
shownPage.current = pageIdx;
|
|
929
|
+
if (level === "none") return;
|
|
930
|
+
pageFade.setValue(0);
|
|
931
|
+
pageShift.setValue(level === "full" ? direction * theme.space.s6 : 0);
|
|
932
|
+
Animated.parallel([
|
|
933
|
+
Animated.spring(pageFade, {
|
|
934
|
+
...springConfig(theme, "de"),
|
|
935
|
+
toValue: 1,
|
|
936
|
+
useNativeDriver: true
|
|
937
|
+
}),
|
|
938
|
+
Animated.spring(pageShift, {
|
|
939
|
+
...springConfig(theme, "ds"),
|
|
940
|
+
toValue: 0,
|
|
941
|
+
useNativeDriver: true
|
|
942
|
+
})
|
|
943
|
+
]).start();
|
|
944
|
+
}, [pageIdx, level, pageFade, pageShift, theme]);
|
|
824
945
|
const page = pages[pageIdx];
|
|
825
946
|
const [errors, setErrors] = React2.useState({});
|
|
826
947
|
const [submitted, setSubmitted] = React2.useState(firstPage < 0);
|
|
827
948
|
const finished = submitted || pageIdx < 0;
|
|
949
|
+
React2.useEffect(() => {
|
|
950
|
+
if (!savedKey || !storage) return;
|
|
951
|
+
if (finished) storage.removeItem?.(savedKey);
|
|
952
|
+
else writeStored(storage, savedKey, { answers: uncontrolled, page: uncontrolledPage });
|
|
953
|
+
}, [savedKey, storage, finished, uncontrolled, uncontrolledPage]);
|
|
828
954
|
const [trail, setTrail] = React2.useState([]);
|
|
829
955
|
const [endingId, setEndingId] = React2.useState(void 0);
|
|
830
956
|
const emit = React2.useCallback(
|
|
@@ -919,7 +1045,7 @@ function Survey({
|
|
|
919
1045
|
[onSubmit, survey, ctx]
|
|
920
1046
|
);
|
|
921
1047
|
const advance = () => {
|
|
922
|
-
const found = validatePage(page, answers, ctx, locale, fallbackLocale);
|
|
1048
|
+
const found = validatePage(page, answers, ctx, locale, fallbackLocale, labels.validation);
|
|
923
1049
|
if (Object.keys(found).length) {
|
|
924
1050
|
setErrors(found);
|
|
925
1051
|
emitRef.current("survey_validation_failed", {
|
|
@@ -961,7 +1087,7 @@ function Survey({
|
|
|
961
1087
|
);
|
|
962
1088
|
const ending = pickSurveyEnding(survey, answers, ctx, endingId);
|
|
963
1089
|
const doneCta = ending?.cta;
|
|
964
|
-
const closeAfter = autoCloseMs ??
|
|
1090
|
+
const closeAfter = autoCloseMs ?? 0;
|
|
965
1091
|
React2.useEffect(() => {
|
|
966
1092
|
if (!finished || closeAfter <= 0) return;
|
|
967
1093
|
const t2 = setTimeout(() => dismiss("done"), closeAfter);
|
|
@@ -978,8 +1104,17 @@ function Survey({
|
|
|
978
1104
|
SurveyDoneCard,
|
|
979
1105
|
{
|
|
980
1106
|
title: t(ending?.title) ?? labels.doneTitle,
|
|
981
|
-
body: t(ending?.body)
|
|
982
|
-
action: doneCta ? /* @__PURE__ */ jsx(
|
|
1107
|
+
body: t(ending?.body),
|
|
1108
|
+
action: doneCta ? /* @__PURE__ */ jsx(
|
|
1109
|
+
Button,
|
|
1110
|
+
{
|
|
1111
|
+
size: "md",
|
|
1112
|
+
variant: "outline",
|
|
1113
|
+
trailingIcon: "arrow-right",
|
|
1114
|
+
onPress: () => onAction?.(doneCta.action),
|
|
1115
|
+
children: t(doneCta.label)
|
|
1116
|
+
}
|
|
1117
|
+
) : null,
|
|
983
1118
|
onClose: () => dismiss("done"),
|
|
984
1119
|
closeLabel: labels.close
|
|
985
1120
|
}
|
|
@@ -990,7 +1125,7 @@ function Survey({
|
|
|
990
1125
|
/* @__PURE__ */ jsx(Text, { style: styles.kicker, children: title }),
|
|
991
1126
|
page?.title ? /* @__PURE__ */ jsx(Text, { style: styles.pageTitle, children: t(page.title) }) : null
|
|
992
1127
|
] }),
|
|
993
|
-
answered.length > 1 ? /* @__PURE__ */ jsxs(Text, { style: styles.counter, children: [
|
|
1128
|
+
showProgress && answered.length > 1 ? /* @__PURE__ */ jsxs(Text, { style: styles.counter, children: [
|
|
994
1129
|
position,
|
|
995
1130
|
" / ",
|
|
996
1131
|
answered.length
|
|
@@ -1007,37 +1142,43 @@ function Survey({
|
|
|
1007
1142
|
}
|
|
1008
1143
|
) : null
|
|
1009
1144
|
] }),
|
|
1010
|
-
/* @__PURE__ */ jsx(
|
|
1145
|
+
showProgress ? /* @__PURE__ */ jsx(
|
|
1011
1146
|
Progress,
|
|
1012
1147
|
{
|
|
1013
1148
|
size: "sm",
|
|
1014
1149
|
value: Math.max(0, position - 1),
|
|
1015
1150
|
max: Math.max(1, answered.length),
|
|
1016
|
-
accessibilityLabel:
|
|
1151
|
+
accessibilityLabel: labels.progress(title, position, answered.length),
|
|
1017
1152
|
motion
|
|
1018
1153
|
}
|
|
1019
|
-
),
|
|
1154
|
+
) : null,
|
|
1020
1155
|
survey.intro && position === 1 ? /* @__PURE__ */ jsx(Text, { style: styles.intro, children: t(survey.intro) }) : null,
|
|
1021
|
-
/* @__PURE__ */ jsx(
|
|
1022
|
-
|
|
1156
|
+
/* @__PURE__ */ jsx(
|
|
1157
|
+
Animated.View,
|
|
1023
1158
|
{
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1159
|
+
style: [styles.questions, { opacity: pageFade, transform: [{ translateX: pageShift }] }],
|
|
1160
|
+
children: questions.map((q) => /* @__PURE__ */ jsx(
|
|
1161
|
+
SurveyQuestionField,
|
|
1162
|
+
{
|
|
1163
|
+
question: q,
|
|
1164
|
+
locale,
|
|
1165
|
+
defaultLocale: fallbackLocale,
|
|
1166
|
+
value: answers[q.id],
|
|
1167
|
+
error: errors[q.id],
|
|
1168
|
+
labels,
|
|
1169
|
+
onChange: (value, commit) => setAnswer(q, value, commit)
|
|
1170
|
+
},
|
|
1171
|
+
q.id
|
|
1172
|
+
))
|
|
1173
|
+
}
|
|
1174
|
+
),
|
|
1034
1175
|
/* @__PURE__ */ jsxs(View, { style: styles.footer, children: [
|
|
1035
|
-
canBack ? /* @__PURE__ */ jsx(Button, { size: "
|
|
1036
|
-
|
|
1037
|
-
allOptional && answered.length > 1 ? /* @__PURE__ */ jsx(
|
|
1176
|
+
canBack ? /* @__PURE__ */ jsx(Button, { size: "lg", variant: "outline", leadingIcon: "arrow-left", onPress: back, children: labels.back }) : null,
|
|
1177
|
+
/* @__PURE__ */ jsx(View, { style: styles.grow }),
|
|
1178
|
+
skippable && allOptional && answered.length > 1 ? /* @__PURE__ */ jsx(
|
|
1038
1179
|
Button,
|
|
1039
1180
|
{
|
|
1040
|
-
size: "
|
|
1181
|
+
size: "lg",
|
|
1041
1182
|
variant: "ghost",
|
|
1042
1183
|
onPress: () => {
|
|
1043
1184
|
emitRef.current("survey_page_skipped", { page: page?.id });
|