@zoho_apptics/apptics-js-sdk 2.0.0-beta.1 → 2.0.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/CHANGELOG.md +127 -16
- package/README.md +357 -215
- package/dist/apptics-pn-sw.js +3 -0
- package/dist/apptics-pn-sw.js.map +1 -0
- package/dist/apptics.esm.min.js +2 -2
- package/dist/apptics.esm.min.js.map +1 -1
- package/dist/apptics.min.js +2 -2
- package/dist/apptics.min.js.map +1 -1
- package/dist/chunks/batch-Axq9sTzR.min.js +3 -0
- package/dist/chunks/batch-Axq9sTzR.min.js.map +1 -0
- package/dist/chunks/lifecycle-Cvg78jN_.min.js +3 -0
- package/dist/chunks/lifecycle-Cvg78jN_.min.js.map +1 -0
- package/dist/chunks/send-DBpesydB.min.js +3 -0
- package/dist/chunks/send-DBpesydB.min.js.map +1 -0
- package/dist/chunks/transport-B21X39p4.min.js +3 -0
- package/dist/chunks/transport-B21X39p4.min.js.map +1 -0
- package/dist/cjs/core/attempts.js +1 -1
- package/dist/cjs/core/batch.js +4 -4
- package/dist/cjs/core/consent.d.ts +17 -4
- package/dist/cjs/core/consent.js +81 -14
- package/dist/cjs/core/console-call.d.ts +23 -0
- package/dist/cjs/core/console-call.js +63 -0
- package/dist/cjs/core/constants.d.ts +66 -17
- package/dist/cjs/core/constants.js +76 -19
- package/dist/cjs/core/db.js +31 -7
- package/dist/cjs/core/debug.d.ts +6 -4
- package/dist/cjs/core/debug.js +36 -12
- package/dist/cjs/core/env.d.ts +0 -3
- package/dist/cjs/core/env.js +1 -9
- package/dist/cjs/core/framework-id.d.ts +1 -1
- package/dist/cjs/core/framework-id.js +3 -3
- package/dist/cjs/core/guard.js +19 -4
- package/dist/cjs/core/hooks.d.ts +29 -0
- package/dist/cjs/core/hooks.js +12 -1
- package/dist/cjs/core/locks.js +1 -1
- package/dist/cjs/core/logger.js +1 -1
- package/dist/cjs/core/shield.d.ts +31 -0
- package/dist/cjs/core/shield.js +129 -0
- package/dist/cjs/core/state.d.ts +11 -5
- package/dist/cjs/core/state.js +4 -4
- package/dist/cjs/core/storage.d.ts +7 -0
- package/dist/cjs/core/storage.js +28 -9
- package/dist/cjs/core/stylesheet.js +1 -1
- package/dist/cjs/core/transport.d.ts +15 -4
- package/dist/cjs/core/transport.js +72 -25
- package/dist/cjs/core/utils.js +1 -1
- package/dist/cjs/core/validate.js +6 -5
- package/dist/cjs/device/appversion.d.ts +10 -1
- package/dist/cjs/device/appversion.js +26 -3
- package/dist/cjs/device/index.d.ts +17 -2
- package/dist/cjs/device/index.js +251 -35
- package/dist/cjs/engagement/api-rules.js +1 -1
- package/dist/cjs/engagement/auto-api.js +4 -3
- package/dist/cjs/engagement/auto-screen.js +10 -6
- package/dist/cjs/engagement/defined-events.d.ts +2 -3
- package/dist/cjs/engagement/defined-events.js +10 -16
- package/dist/cjs/engagement/send.js +7 -3
- package/dist/cjs/engagement/session.d.ts +17 -0
- package/dist/cjs/engagement/session.js +154 -23
- package/dist/cjs/engagement/track.d.ts +4 -4
- package/dist/cjs/engagement/track.js +23 -17
- package/dist/cjs/errors/send.js +2 -2
- package/dist/cjs/errors/track.d.ts +2 -1
- package/dist/cjs/errors/track.js +8 -5
- package/dist/cjs/feedback/controls.d.ts +36 -4
- package/dist/cjs/feedback/controls.js +302 -67
- package/dist/cjs/feedback/i18n/index.d.ts +31 -0
- package/dist/cjs/feedback/i18n/index.js +187 -0
- package/dist/cjs/feedback/i18n/strings.d.ts +9 -0
- package/dist/cjs/feedback/i18n/strings.js +8 -0
- package/dist/cjs/feedback/index.js +1 -1
- package/dist/cjs/feedback/logs.d.ts +3 -6
- package/dist/cjs/feedback/logs.js +12 -21
- package/dist/cjs/feedback/quartz.js +5 -2
- package/dist/cjs/feedback/send.d.ts +6 -3
- package/dist/cjs/feedback/send.js +59 -41
- package/dist/cjs/feedback/styles.js +2 -2
- package/dist/cjs/feedback/template.d.ts +4 -2
- package/dist/cjs/feedback/template.js +73 -44
- package/dist/cjs/feedback/ui.d.ts +47 -4
- package/dist/cjs/feedback/ui.js +351 -97
- package/dist/cjs/heatmap/send.d.ts +2 -0
- package/dist/cjs/heatmap/send.js +3 -5
- package/dist/cjs/heatmap/track.js +13 -9
- package/dist/cjs/index.d.ts +1 -2
- package/dist/cjs/index.js +55 -18
- package/dist/cjs/lifecycle.d.ts +13 -2
- package/dist/cjs/lifecycle.js +233 -118
- package/dist/cjs/pushnotification/display.d.ts +65 -0
- package/dist/cjs/pushnotification/display.js +112 -0
- package/dist/cjs/pushnotification/index.d.ts +20 -0
- package/dist/cjs/pushnotification/index.js +96 -0
- package/dist/cjs/pushnotification/kept-opens.d.ts +23 -0
- package/dist/cjs/pushnotification/kept-opens.js +64 -0
- package/dist/cjs/pushnotification/notify.d.ts +45 -0
- package/dist/cjs/pushnotification/notify.js +476 -0
- package/dist/cjs/pushnotification/payload.d.ts +65 -0
- package/dist/cjs/pushnotification/payload.js +279 -0
- package/dist/cjs/pushnotification/session.d.ts +46 -0
- package/dist/cjs/pushnotification/session.js +413 -0
- package/dist/cjs/pushnotification/stats.d.ts +45 -0
- package/dist/cjs/pushnotification/stats.js +244 -0
- package/dist/cjs/pushnotification/wms.d.ts +30 -0
- package/dist/cjs/pushnotification/wms.js +374 -0
- package/dist/cjs/remoteconfig/country.js +1 -1
- package/dist/cjs/remoteconfig/custom.js +4 -3
- package/dist/cjs/remoteconfig/evaluate.js +1 -1
- package/dist/cjs/remoteconfig/fetch.d.ts +17 -10
- package/dist/cjs/remoteconfig/fetch.js +146 -32
- package/dist/cjs/remoteconfig/index.d.ts +9 -5
- package/dist/cjs/remoteconfig/index.js +24 -32
- package/dist/cjs/remoteconfig/store.d.ts +15 -7
- package/dist/cjs/remoteconfig/store.js +68 -35
- package/dist/cjs/remoteconfig/tz-countries.js +1 -1
- package/dist/cjs/{core → remotelog}/callsite.d.ts +5 -4
- package/dist/cjs/{core → remotelog}/callsite.js +6 -5
- package/dist/cjs/remotelog/gate.js +1 -1
- package/dist/cjs/remotelog/logger.js +2 -2
- package/dist/cjs/remotelog/send.js +6 -5
- package/dist/cjs/remotelogger/index.js +1 -1
- package/dist/cjs/scheduler.d.ts +3 -1
- package/dist/cjs/scheduler.js +34 -25
- package/dist/cjs/sw/apptics-pn-sw.d.ts +83 -0
- package/dist/cjs/sw/timers.d.ts +44 -0
- package/dist/cjs/types.d.ts +90 -29
- package/dist/cjs/user/index.d.ts +7 -0
- package/dist/cjs/user/index.js +25 -3
- package/dist/esm/core/attempts.js +1 -1
- package/dist/esm/core/batch.js +4 -4
- package/dist/esm/core/consent.d.ts +17 -4
- package/dist/esm/core/consent.js +84 -20
- package/dist/esm/core/console-call.d.ts +23 -0
- package/dist/esm/core/console-call.js +60 -0
- package/dist/esm/core/constants.d.ts +66 -17
- package/dist/esm/core/constants.js +73 -20
- package/dist/esm/core/db.js +31 -7
- package/dist/esm/core/debug.d.ts +6 -4
- package/dist/esm/core/debug.js +37 -13
- package/dist/esm/core/env.d.ts +0 -3
- package/dist/esm/core/env.js +2 -9
- package/dist/esm/core/framework-id.d.ts +1 -1
- package/dist/esm/core/framework-id.js +3 -3
- package/dist/esm/core/guard.js +19 -4
- package/dist/esm/core/hooks.d.ts +29 -0
- package/dist/esm/core/hooks.js +12 -1
- package/dist/esm/core/locks.js +1 -1
- package/dist/esm/core/logger.js +1 -1
- package/dist/esm/core/shield.d.ts +31 -0
- package/dist/esm/core/shield.js +119 -0
- package/dist/esm/core/state.d.ts +11 -5
- package/dist/esm/core/state.js +4 -4
- package/dist/esm/core/storage.d.ts +7 -0
- package/dist/esm/core/storage.js +28 -11
- package/dist/esm/core/stylesheet.js +1 -1
- package/dist/esm/core/transport.d.ts +15 -4
- package/dist/esm/core/transport.js +73 -28
- package/dist/esm/core/utils.js +1 -1
- package/dist/esm/core/validate.js +6 -5
- package/dist/esm/device/appversion.d.ts +10 -1
- package/dist/esm/device/appversion.js +26 -4
- package/dist/esm/device/index.d.ts +17 -2
- package/dist/esm/device/index.js +255 -42
- package/dist/esm/engagement/api-rules.js +1 -1
- package/dist/esm/engagement/auto-api.js +4 -3
- package/dist/esm/engagement/auto-screen.js +10 -6
- package/dist/esm/engagement/defined-events.d.ts +2 -3
- package/dist/esm/engagement/defined-events.js +10 -16
- package/dist/esm/engagement/send.js +7 -3
- package/dist/esm/engagement/session.d.ts +17 -0
- package/dist/esm/engagement/session.js +152 -24
- package/dist/esm/engagement/track.d.ts +4 -4
- package/dist/esm/engagement/track.js +24 -18
- package/dist/esm/errors/send.js +2 -2
- package/dist/esm/errors/track.d.ts +2 -1
- package/dist/esm/errors/track.js +8 -5
- package/dist/esm/feedback/controls.d.ts +36 -4
- package/dist/esm/feedback/controls.js +298 -68
- package/dist/esm/feedback/i18n/index.d.ts +31 -0
- package/dist/esm/feedback/i18n/index.js +178 -0
- package/dist/esm/feedback/i18n/strings.d.ts +9 -0
- package/dist/esm/feedback/i18n/strings.js +4 -0
- package/dist/esm/feedback/index.js +1 -1
- package/dist/esm/feedback/logs.d.ts +3 -6
- package/dist/esm/feedback/logs.js +12 -21
- package/dist/esm/feedback/quartz.js +5 -2
- package/dist/esm/feedback/send.d.ts +6 -3
- package/dist/esm/feedback/send.js +61 -44
- package/dist/esm/feedback/styles.js +2 -2
- package/dist/esm/feedback/template.d.ts +4 -2
- package/dist/esm/feedback/template.js +73 -44
- package/dist/esm/feedback/ui.d.ts +47 -4
- package/dist/esm/feedback/ui.js +353 -99
- package/dist/esm/heatmap/send.d.ts +2 -0
- package/dist/esm/heatmap/send.js +3 -5
- package/dist/esm/heatmap/track.js +13 -9
- package/dist/esm/index.d.ts +1 -2
- package/dist/esm/index.js +58 -21
- package/dist/esm/lifecycle.d.ts +13 -2
- package/dist/esm/lifecycle.js +238 -125
- package/dist/esm/pushnotification/display.d.ts +65 -0
- package/dist/esm/pushnotification/display.js +95 -0
- package/dist/esm/pushnotification/index.d.ts +20 -0
- package/dist/esm/pushnotification/index.js +91 -0
- package/dist/esm/pushnotification/kept-opens.d.ts +23 -0
- package/dist/esm/pushnotification/kept-opens.js +62 -0
- package/dist/esm/pushnotification/notify.d.ts +45 -0
- package/dist/esm/pushnotification/notify.js +469 -0
- package/dist/esm/pushnotification/payload.d.ts +65 -0
- package/dist/esm/pushnotification/payload.js +272 -0
- package/dist/esm/pushnotification/session.d.ts +46 -0
- package/dist/esm/pushnotification/session.js +402 -0
- package/dist/esm/pushnotification/stats.d.ts +45 -0
- package/dist/esm/pushnotification/stats.js +238 -0
- package/dist/esm/pushnotification/wms.d.ts +30 -0
- package/dist/esm/pushnotification/wms.js +368 -0
- package/dist/esm/remoteconfig/country.js +1 -1
- package/dist/esm/remoteconfig/custom.js +4 -3
- package/dist/esm/remoteconfig/evaluate.js +1 -1
- package/dist/esm/remoteconfig/fetch.d.ts +17 -10
- package/dist/esm/remoteconfig/fetch.js +147 -33
- package/dist/esm/remoteconfig/index.d.ts +9 -5
- package/dist/esm/remoteconfig/index.js +24 -32
- package/dist/esm/remoteconfig/store.d.ts +15 -7
- package/dist/esm/remoteconfig/store.js +68 -36
- package/dist/esm/remoteconfig/tz-countries.js +1 -1
- package/dist/esm/{core → remotelog}/callsite.d.ts +5 -4
- package/dist/esm/{core → remotelog}/callsite.js +6 -5
- package/dist/esm/remotelog/gate.js +1 -1
- package/dist/esm/remotelog/logger.js +2 -2
- package/dist/esm/remotelog/send.js +6 -5
- package/dist/esm/remotelogger/index.js +1 -1
- package/dist/esm/scheduler.d.ts +3 -1
- package/dist/esm/scheduler.js +35 -27
- package/dist/esm/sw/apptics-pn-sw.d.ts +83 -0
- package/dist/esm/sw/timers.d.ts +44 -0
- package/dist/esm/types.d.ts +90 -29
- package/dist/esm/user/index.d.ts +7 -0
- package/dist/esm/user/index.js +26 -5
- package/dist/feedback.esm.min.js +2 -2
- package/dist/feedback.esm.min.js.map +1 -1
- package/dist/pushnotification.esm.min.js +3 -0
- package/dist/pushnotification.esm.min.js.map +1 -0
- package/dist/remoteconfig.esm.min.js +3 -0
- package/dist/remoteconfig.esm.min.js.map +1 -0
- package/dist/remotelogger.esm.min.js +3 -0
- package/dist/remotelogger.esm.min.js.map +1 -0
- package/package.json +17 -3
- package/dist/chunks/lifecycle-VYr43KcB.min.js +0 -3
- package/dist/chunks/lifecycle-VYr43KcB.min.js.map +0 -1
- package/dist/cjs/auto-init.d.ts +0 -8
- package/dist/cjs/auto-init.js +0 -32
- package/dist/esm/auto-init.d.ts +0 -8
- package/dist/esm/auto-init.js +0 -29
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @zoho_apptics/apptics-js-sdk v2.0.0
|
|
1
|
+
/*! @zoho_apptics/apptics-js-sdk v2.0.0 | (c) Zoho Corporation Private Limited | see LICENSE */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var logger = require('../core/logger.js');
|
|
@@ -7,6 +7,8 @@ var storage = require('../core/storage.js');
|
|
|
7
7
|
var utils = require('../core/utils.js');
|
|
8
8
|
var state = require('../core/state.js');
|
|
9
9
|
var logs = require('./logs.js');
|
|
10
|
+
var shield = require('../core/shield.js');
|
|
11
|
+
var index = require('./i18n/index.js');
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* The three controls at the top and bottom of the feedback form: the user picker, the
|
|
@@ -16,11 +18,21 @@ var logs = require('./logs.js');
|
|
|
16
18
|
* control can be wired (and read back) on its own.
|
|
17
19
|
*/
|
|
18
20
|
const ANONYMOUS = 'anonymous'; // no i18n
|
|
19
|
-
const ANONYMOUS_LABEL = 'Anonymous'; // no i18n
|
|
20
21
|
/** Read by core/transport when it builds the feedback request's parameters. */
|
|
21
22
|
const userChoice = { anonymous: true, userid: '', groupid: '' }; // no i18n
|
|
22
23
|
/** Whether the next submission carries the stored logs and diagnostics. Unset means "decide from what is stored". */
|
|
23
24
|
const logChoice = {};
|
|
25
|
+
/** The picker's selected entry: 'anonymous' or a user's address. Read when the form is rebuilt in another language. */
|
|
26
|
+
var pickedValue = ANONYMOUS;
|
|
27
|
+
/** The entry the user picker has selected, for the same form rebuilt in another language. */
|
|
28
|
+
function pickedUser() {
|
|
29
|
+
return pickedValue;
|
|
30
|
+
}
|
|
31
|
+
var viewerShown = null;
|
|
32
|
+
/** The viewer's title key and content while it is open, else null. */
|
|
33
|
+
function shownViewer() {
|
|
34
|
+
return viewerShown;
|
|
35
|
+
}
|
|
24
36
|
function resetUserChoice() {
|
|
25
37
|
userChoice.anonymous = true;
|
|
26
38
|
userChoice.userid = ''; // no i18n
|
|
@@ -59,8 +71,9 @@ function storedUsers() {
|
|
|
59
71
|
var users = storage.user_defaults.item('users'); // no i18n
|
|
60
72
|
return Array.isArray(users) ? users : [];
|
|
61
73
|
}
|
|
74
|
+
/** The picker's entries: Anonymous, named by its key, then each address as it is. */
|
|
62
75
|
function pickerItems(users) {
|
|
63
|
-
var items = [{ value: ANONYMOUS, label:
|
|
76
|
+
var items = [{ value: ANONYMOUS, label: '', key: 'fdk.user.anonymous' }]; // no i18n
|
|
64
77
|
var seen = {};
|
|
65
78
|
users.forEach(function (user) {
|
|
66
79
|
var mam = user && user.mam;
|
|
@@ -90,9 +103,10 @@ function tickIcon() {
|
|
|
90
103
|
}
|
|
91
104
|
/**
|
|
92
105
|
* The "User" dropdown above the description. It lists Anonymous plus every registered user, and
|
|
93
|
-
* starts on the active one (status 1) unless the caller asked for anonymous
|
|
106
|
+
* starts on the active one (status 1) unless the caller asked for anonymous; `keep`, the entry a
|
|
107
|
+
* form rebuilt in another language had selected, wins over both while it is still listed.
|
|
94
108
|
*/
|
|
95
|
-
function wireUserPicker(modal, forceAnonymous) {
|
|
109
|
+
function wireUserPicker(modal, forceAnonymous, keep) {
|
|
96
110
|
var trigger = modal.querySelector('#zasdkEmailTrigger'); // no i18n
|
|
97
111
|
var panel = modal.querySelector('#zasdkEmailPanel'); // no i18n
|
|
98
112
|
var label = modal.querySelector('#zasdkEmailLabel'); // no i18n
|
|
@@ -105,6 +119,7 @@ function wireUserPicker(modal, forceAnonymous) {
|
|
|
105
119
|
var items = pickerItems(users);
|
|
106
120
|
var selected = ANONYMOUS;
|
|
107
121
|
resetUserChoice();
|
|
122
|
+
pickedValue = ANONYMOUS;
|
|
108
123
|
if (!forceAnonymous) {
|
|
109
124
|
var active = null;
|
|
110
125
|
users.forEach(function (user) {
|
|
@@ -116,8 +131,12 @@ function wireUserPicker(modal, forceAnonymous) {
|
|
|
116
131
|
select(String(active.mam));
|
|
117
132
|
}
|
|
118
133
|
}
|
|
134
|
+
if (keep !== undefined && items.some(function (item) { return item.value === keep; })) {
|
|
135
|
+
select(keep);
|
|
136
|
+
}
|
|
119
137
|
function select(value) {
|
|
120
138
|
selected = value;
|
|
139
|
+
pickedValue = value;
|
|
121
140
|
userChoice.anonymous = value === ANONYMOUS;
|
|
122
141
|
var matched = null;
|
|
123
142
|
if (!userChoice.anonymous) {
|
|
@@ -129,7 +148,7 @@ function wireUserPicker(modal, forceAnonymous) {
|
|
|
129
148
|
}
|
|
130
149
|
userChoice.userid = matched ? String(matched.userid || '') : ''; // no i18n
|
|
131
150
|
userChoice.groupid = matched ? String(matched.groupid || '') : ''; // no i18n
|
|
132
|
-
label.textContent = userChoice.anonymous ?
|
|
151
|
+
label.textContent = userChoice.anonymous ? index.getLocale('fdk.user.anonymous') : value; // no i18n
|
|
133
152
|
render();
|
|
134
153
|
}
|
|
135
154
|
function render() {
|
|
@@ -137,7 +156,7 @@ function wireUserPicker(modal, forceAnonymous) {
|
|
|
137
156
|
if (items.length === 0) {
|
|
138
157
|
var empty = document.createElement('div'); // no i18n
|
|
139
158
|
empty.className = 'zasdk-select-empty'; // no i18n
|
|
140
|
-
empty.textContent = '
|
|
159
|
+
empty.textContent = index.getLocale('fdk.user.none'); // no i18n
|
|
141
160
|
list.appendChild(empty);
|
|
142
161
|
return;
|
|
143
162
|
}
|
|
@@ -147,7 +166,7 @@ function wireUserPicker(modal, forceAnonymous) {
|
|
|
147
166
|
option.className = 'zasdk-select-option' + (isSelected ? ' zasdk-option-selected' : ''); // no i18n
|
|
148
167
|
option.setAttribute('data-value', item.value); // no i18n
|
|
149
168
|
var text = document.createElement('span'); // no i18n
|
|
150
|
-
text.textContent = item.label;
|
|
169
|
+
text.textContent = item.key ? index.getLocale(item.key) : item.label;
|
|
151
170
|
option.appendChild(text);
|
|
152
171
|
if (isSelected) {
|
|
153
172
|
option.appendChild(tickIcon());
|
|
@@ -155,49 +174,200 @@ function wireUserPicker(modal, forceAnonymous) {
|
|
|
155
174
|
list.appendChild(option);
|
|
156
175
|
});
|
|
157
176
|
}
|
|
158
|
-
trigger.addEventListener('click', function (event) {
|
|
177
|
+
trigger.addEventListener('click', shield.shield('AppticsFeedback', function (event) {
|
|
159
178
|
event.stopPropagation();
|
|
160
179
|
var open = panel.style.display !== 'none'; // no i18n
|
|
161
180
|
panel.style.display = open ? 'none' : 'block'; // no i18n
|
|
162
181
|
if (!open) {
|
|
163
182
|
render();
|
|
164
183
|
}
|
|
165
|
-
});
|
|
166
|
-
list.addEventListener('click', function (event) {
|
|
184
|
+
}));
|
|
185
|
+
list.addEventListener('click', shield.shield('AppticsFeedback', function (event) {
|
|
167
186
|
var option = event.target.closest('.zasdk-select-option'); // no i18n
|
|
168
187
|
if (!option) {
|
|
169
188
|
return;
|
|
170
189
|
}
|
|
171
190
|
select(String(option.getAttribute('data-value'))); // no i18n
|
|
172
191
|
panel.style.display = 'none'; // no i18n
|
|
173
|
-
});
|
|
192
|
+
}));
|
|
174
193
|
// closing on focusout rather than a document click keeps it working inside a shadow root
|
|
175
194
|
dropdown.setAttribute('tabindex', '0'); // no i18n
|
|
176
|
-
dropdown.addEventListener('focusout', function (event) {
|
|
195
|
+
dropdown.addEventListener('focusout', shield.shield('AppticsFeedback', function (event) {
|
|
177
196
|
if (!dropdown.contains(event.relatedTarget)) {
|
|
178
197
|
panel.style.display = 'none'; // no i18n
|
|
179
198
|
}
|
|
180
|
-
});
|
|
199
|
+
}));
|
|
181
200
|
render();
|
|
182
201
|
}
|
|
183
|
-
/**
|
|
184
|
-
function
|
|
202
|
+
/** A language's own name, its label without the English name in brackets: Deutsch, Español – México. */
|
|
203
|
+
function ownName(label) {
|
|
204
|
+
var cut = label.indexOf(' ('); // no i18n
|
|
205
|
+
return cut === -1 ? label : label.slice(0, cut);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* The language dropdown in the header. It lists every language the form has, English first, each
|
|
209
|
+
* by its own name; picking one is remembered for the next form and hands over to `picked`, which
|
|
210
|
+
* builds this one again in it. Built as the user picker is, and closed the same way (focusout, so
|
|
211
|
+
* it works in a shadow root), with the keys a listbox takes: arrows to move, Enter or Space to
|
|
212
|
+
* pick, Escape to close.
|
|
213
|
+
*/
|
|
214
|
+
function wireLangPicker(modal, picked) {
|
|
215
|
+
var dropdown = modal.querySelector('#zasdkLangDropdown'); // no i18n
|
|
216
|
+
var trigger = modal.querySelector('#zasdkLangTrigger'); // no i18n
|
|
217
|
+
var panel = modal.querySelector('#zasdkLangPanel'); // no i18n
|
|
218
|
+
var list = modal.querySelector('#zasdkLangList'); // no i18n
|
|
219
|
+
if (!dropdown || !trigger || !panel || !list) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
var label = modal.querySelector('#zasdkLangLabel'); // no i18n
|
|
223
|
+
var current = index.feedbackLocale();
|
|
224
|
+
index.FEEDBACK_LOCALES.forEach(function (locale) {
|
|
225
|
+
if (label && locale.code === current) {
|
|
226
|
+
label.textContent = ownName(locale.label);
|
|
227
|
+
// the trigger cuts a long name such as "Português – Portugal" short; hovering shows it whole
|
|
228
|
+
label.title = label.textContent;
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
function isOpen() {
|
|
232
|
+
return panel.style.display !== 'none'; // no i18n
|
|
233
|
+
}
|
|
234
|
+
function options() {
|
|
235
|
+
return Array.prototype.slice.call(list.querySelectorAll('[role="option"]')); // no i18n
|
|
236
|
+
}
|
|
237
|
+
function render() {
|
|
238
|
+
var current = index.feedbackLocale();
|
|
239
|
+
list.innerHTML = ''; // no i18n
|
|
240
|
+
index.FEEDBACK_LOCALES.forEach(function (locale) {
|
|
241
|
+
var on = locale.code === current;
|
|
242
|
+
var option = document.createElement('li'); // no i18n
|
|
243
|
+
option.className = 'zasdk-select-option' + (on ? ' zasdk-option-selected' : ''); // no i18n
|
|
244
|
+
option.setAttribute('role', 'option'); // no i18n
|
|
245
|
+
option.setAttribute('tabindex', '-1'); // no i18n
|
|
246
|
+
option.setAttribute('data-value', locale.code); // no i18n
|
|
247
|
+
option.setAttribute('aria-selected', on ? 'true' : 'false'); // no i18n
|
|
248
|
+
// each name in its own language, so a screen reader says it as it is written
|
|
249
|
+
option.setAttribute('lang', locale.bcp47); // no i18n
|
|
250
|
+
var text = document.createElement('span'); // no i18n
|
|
251
|
+
text.textContent = locale.label;
|
|
252
|
+
option.appendChild(text);
|
|
253
|
+
if (on) {
|
|
254
|
+
option.appendChild(tickIcon());
|
|
255
|
+
}
|
|
256
|
+
list.appendChild(option);
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
function open() {
|
|
260
|
+
render();
|
|
261
|
+
panel.style.display = 'block'; // no i18n
|
|
262
|
+
trigger.setAttribute('aria-expanded', 'true'); // no i18n
|
|
263
|
+
var current = list.querySelector('[aria-selected="true"]') || options()[0]; // no i18n
|
|
264
|
+
if (current) {
|
|
265
|
+
try {
|
|
266
|
+
current.focus({ preventScroll: false });
|
|
267
|
+
}
|
|
268
|
+
catch (err) { /* focus is a courtesy */ }
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
function close(focusTrigger) {
|
|
272
|
+
panel.style.display = 'none'; // no i18n
|
|
273
|
+
trigger.setAttribute('aria-expanded', 'false'); // no i18n
|
|
274
|
+
if (focusTrigger) {
|
|
275
|
+
try {
|
|
276
|
+
trigger.focus();
|
|
277
|
+
}
|
|
278
|
+
catch (err) { /* focus is a courtesy */ }
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
function pick(code) {
|
|
282
|
+
close(false);
|
|
283
|
+
if (code === index.feedbackLocale()) {
|
|
284
|
+
try {
|
|
285
|
+
trigger.focus();
|
|
286
|
+
}
|
|
287
|
+
catch (err) { /* focus is a courtesy */ }
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
index.setFeedbackLocale(code);
|
|
291
|
+
picked();
|
|
292
|
+
}
|
|
293
|
+
// macOS Safari and Firefox do not focus a button on mousedown, so focus would fall to the body,
|
|
294
|
+
// focusout would close the list, and the click would then open it again; keeping focus where it
|
|
295
|
+
// is lets the click alone decide. Keyboard use (Enter, Space, arrows) does not go through mousedown.
|
|
296
|
+
trigger.addEventListener('mousedown', function (event) {
|
|
297
|
+
event.preventDefault();
|
|
298
|
+
});
|
|
299
|
+
trigger.addEventListener('click', shield.shield('AppticsFeedback', function (event) {
|
|
300
|
+
event.stopPropagation();
|
|
301
|
+
if (isOpen()) {
|
|
302
|
+
close(true);
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
open();
|
|
306
|
+
}
|
|
307
|
+
}));
|
|
308
|
+
list.addEventListener('click', shield.shield('AppticsFeedback', function (event) {
|
|
309
|
+
var option = event.target.closest('[role="option"]'); // no i18n
|
|
310
|
+
if (option) {
|
|
311
|
+
pick(String(option.getAttribute('data-value'))); // no i18n
|
|
312
|
+
}
|
|
313
|
+
}));
|
|
314
|
+
dropdown.addEventListener('keydown', shield.shield('AppticsFeedback', function (event) {
|
|
315
|
+
var key = event.key;
|
|
316
|
+
if (!isOpen()) {
|
|
317
|
+
if (event.target === trigger && (key === 'ArrowDown' || key === 'ArrowUp')) { // no i18n
|
|
318
|
+
event.preventDefault();
|
|
319
|
+
open();
|
|
320
|
+
}
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
var all = options();
|
|
324
|
+
// the key's target is the focused option; document.activeElement would be a shadow host
|
|
325
|
+
var at = all.indexOf(event.target);
|
|
326
|
+
if (key === 'Escape') { // no i18n
|
|
327
|
+
// closes the list only: the form's own Escape, on the document, never hears it
|
|
328
|
+
event.preventDefault();
|
|
329
|
+
event.stopPropagation();
|
|
330
|
+
close(true);
|
|
331
|
+
}
|
|
332
|
+
else if (key === 'ArrowDown' || key === 'ArrowUp' || key === 'Home' || key === 'End') { // no i18n
|
|
333
|
+
event.preventDefault();
|
|
334
|
+
var next = key === 'Home' ? 0 : key === 'End' ? all.length - 1 // no i18n
|
|
335
|
+
: Math.max(0, Math.min(all.length - 1, at + (key === 'ArrowDown' ? 1 : -1))); // no i18n
|
|
336
|
+
if (all[next]) {
|
|
337
|
+
all[next].focus();
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
else if ((key === 'Enter' || key === ' ') && at !== -1) { // no i18n
|
|
341
|
+
event.preventDefault();
|
|
342
|
+
pick(String(all[at].getAttribute('data-value'))); // no i18n
|
|
343
|
+
}
|
|
344
|
+
}));
|
|
345
|
+
dropdown.addEventListener('focusout', shield.shield('AppticsFeedback', function (event) {
|
|
346
|
+
if (!dropdown.contains(event.relatedTarget)) {
|
|
347
|
+
close(false);
|
|
348
|
+
}
|
|
349
|
+
}));
|
|
350
|
+
}
|
|
351
|
+
/** Shows `content` in the viewer panel over the form, under the title `titleKey` names. */
|
|
352
|
+
function openViewer(modal, titleKey, content) {
|
|
185
353
|
var viewer = modal.querySelector('#zasdkDataViewer'); // no i18n
|
|
186
354
|
var viewerTitle = modal.querySelector('#zasdkViewerTitle'); // no i18n
|
|
187
355
|
var viewerContent = modal.querySelector('#zasdkViewerContent'); // no i18n
|
|
188
356
|
if (!viewer || !viewerTitle || !viewerContent) {
|
|
189
357
|
return;
|
|
190
358
|
}
|
|
191
|
-
viewerTitle.textContent =
|
|
192
|
-
|
|
359
|
+
viewerTitle.textContent = index.getLocale(titleKey);
|
|
360
|
+
// the logs and diagnostics are data, shown as they are; only the empty note is the form's
|
|
361
|
+
viewerContent.textContent = content ? content : index.getLocale('fdk.viewer.empty'); // no i18n
|
|
193
362
|
viewer.style.display = 'flex'; // no i18n
|
|
363
|
+
viewerShown = { titleKey: titleKey, content: content };
|
|
194
364
|
}
|
|
195
365
|
/**
|
|
196
366
|
* The two "Include …" switches and the viewer behind their View links. A row is shown only when
|
|
197
367
|
* there is something to include, and is then on by default, so a submission carries what the app
|
|
198
|
-
* recorded unless the user turns it off.
|
|
368
|
+
* recorded unless the user turns it off. `keep` is what a form rebuilt in another language had.
|
|
199
369
|
*/
|
|
200
|
-
function wireLogControls(modal, opts) {
|
|
370
|
+
function wireLogControls(modal, opts, keep) {
|
|
201
371
|
var logToggle = modal.querySelector('#zasdkIncludeLogToggle'); // no i18n
|
|
202
372
|
var diagToggle = modal.querySelector('#zasdkIncludeDiagToggle'); // no i18n
|
|
203
373
|
var section = modal.querySelector('.zasdk-toggles-section'); // no i18n
|
|
@@ -211,8 +381,18 @@ function wireLogControls(modal, opts) {
|
|
|
211
381
|
}
|
|
212
382
|
var logRow = logToggle.closest('.zasdk-toggle-row'); // no i18n
|
|
213
383
|
var diagRow = diagToggle.closest('.zasdk-toggle-row'); // no i18n
|
|
214
|
-
|
|
215
|
-
logChoice.
|
|
384
|
+
var kept = keep || {};
|
|
385
|
+
logChoice.includeLog = typeof kept.includeLog === 'boolean' ? kept.includeLog : opts.includeLog === true ? true : undefined; // no i18n
|
|
386
|
+
logChoice.includeDyninfo = typeof kept.includeDyninfo === 'boolean' ? kept.includeDyninfo : opts.includeDyninfo === true ? true : undefined; // no i18n
|
|
387
|
+
// a rebuilt form shows the switches as the user left them from the start, not once the reads are back
|
|
388
|
+
if (typeof kept.includeLog === 'boolean')
|
|
389
|
+
logToggle.checked = kept.includeLog; // no i18n
|
|
390
|
+
if (typeof kept.includeDyninfo === 'boolean')
|
|
391
|
+
diagToggle.checked = kept.includeDyninfo; // no i18n
|
|
392
|
+
viewerShown = null;
|
|
393
|
+
if (kept.viewer) {
|
|
394
|
+
openViewer(modal, kept.viewer.titleKey, kept.viewer.content);
|
|
395
|
+
}
|
|
216
396
|
// hidden until the reads come back, so an empty section never flashes into view
|
|
217
397
|
section.style.display = 'none'; // no i18n
|
|
218
398
|
Promise.all([logs.hasLogLines(), logs.hasDiagnostics()]).then(function ([anyLogs, anyDiagnostics]) {
|
|
@@ -223,38 +403,39 @@ function wireLogControls(modal, opts) {
|
|
|
223
403
|
if (separator)
|
|
224
404
|
separator.style.display = anyLogs && anyDiagnostics ? '' : 'none'; // no i18n
|
|
225
405
|
section.style.display = anyLogs || anyDiagnostics ? '' : 'none'; // no i18n
|
|
226
|
-
// on when there is data, unless the caller
|
|
227
|
-
logToggle.checked = opts.includeLog === true || anyLogs;
|
|
228
|
-
diagToggle.checked = opts.includeDyninfo === true || anyDiagnostics;
|
|
406
|
+
// on when there is data, unless the caller, or the user before a language was picked, decided
|
|
407
|
+
logToggle.checked = typeof kept.includeLog === 'boolean' ? kept.includeLog : opts.includeLog === true || anyLogs; // no i18n
|
|
408
|
+
diagToggle.checked = typeof kept.includeDyninfo === 'boolean' ? kept.includeDyninfo : opts.includeDyninfo === true || anyDiagnostics; // no i18n
|
|
229
409
|
logChoice.includeLog = logToggle.checked;
|
|
230
410
|
logChoice.includeDyninfo = diagToggle.checked;
|
|
231
411
|
}).catch(function (err) {
|
|
232
412
|
logger.Console.warn('apptics: could not read the stored logs: ' + String(err)); // no i18n
|
|
233
413
|
});
|
|
234
|
-
logToggle.addEventListener('change', function () {
|
|
414
|
+
logToggle.addEventListener('change', shield.shield('AppticsFeedback', function () {
|
|
235
415
|
logChoice.includeLog = logToggle.checked;
|
|
236
|
-
});
|
|
237
|
-
diagToggle.addEventListener('change', function () {
|
|
416
|
+
}));
|
|
417
|
+
diagToggle.addEventListener('change', shield.shield('AppticsFeedback', function () {
|
|
238
418
|
logChoice.includeDyninfo = diagToggle.checked;
|
|
239
|
-
});
|
|
419
|
+
}));
|
|
240
420
|
if (viewLogs) {
|
|
241
|
-
viewLogs.addEventListener('click', function () {
|
|
242
|
-
logs.logText().then(function (text) {
|
|
243
|
-
openViewer(modal, '
|
|
244
|
-
});
|
|
245
|
-
});
|
|
421
|
+
viewLogs.addEventListener('click', shield.shield('AppticsFeedback', function () {
|
|
422
|
+
shield.quietly('AppticsFeedback', logs.logText().then(function (text) {
|
|
423
|
+
openViewer(modal, 'fdk.viewer.logs', text); // no i18n
|
|
424
|
+
}));
|
|
425
|
+
}));
|
|
246
426
|
}
|
|
247
427
|
if (viewDiag) {
|
|
248
|
-
viewDiag.addEventListener('click', function () {
|
|
249
|
-
logs.diagnosticsText().then(function (text) {
|
|
250
|
-
openViewer(modal, '
|
|
251
|
-
});
|
|
252
|
-
});
|
|
428
|
+
viewDiag.addEventListener('click', shield.shield('AppticsFeedback', function () {
|
|
429
|
+
shield.quietly('AppticsFeedback', logs.diagnosticsText().then(function (text) {
|
|
430
|
+
openViewer(modal, 'fdk.viewer.diag', text); // no i18n
|
|
431
|
+
}));
|
|
432
|
+
}));
|
|
253
433
|
}
|
|
254
434
|
if (viewerClose && viewer) {
|
|
255
|
-
viewerClose.addEventListener('click', function () {
|
|
435
|
+
viewerClose.addEventListener('click', shield.shield('AppticsFeedback', function () {
|
|
256
436
|
viewer.style.display = 'none'; // no i18n
|
|
257
|
-
|
|
437
|
+
viewerShown = null;
|
|
438
|
+
}));
|
|
258
439
|
}
|
|
259
440
|
}
|
|
260
441
|
/**
|
|
@@ -267,41 +448,90 @@ function wireDrag(box) {
|
|
|
267
448
|
if (!header) {
|
|
268
449
|
return;
|
|
269
450
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
451
|
+
makeDraggable(box, header, function (target) {
|
|
452
|
+
// the close button and the language dropdown are not drag handles
|
|
453
|
+
return !!target.closest('.zasdk-close, .zasdk-lang-slot'); // no i18n
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
/** Where the recording timer was last dragged to, so the next recording's timer starts there. */
|
|
457
|
+
var timerSpot = null;
|
|
458
|
+
/**
|
|
459
|
+
* Lets the recording timer be dragged anywhere on the page. A press that moves it is a drag, and
|
|
460
|
+
* does not also stop the recording, as a plain click on it does. Call before the click listener
|
|
461
|
+
* is added, so a drag's click is stopped ahead of it.
|
|
462
|
+
*/
|
|
463
|
+
function wireTimerDrag(timer) {
|
|
464
|
+
if (timerSpot) {
|
|
465
|
+
placeAt(timer, timerSpot.left, timerSpot.top);
|
|
466
|
+
}
|
|
467
|
+
makeDraggable(timer, timer, undefined, function (left, top) {
|
|
468
|
+
timerSpot = { left: left, top: top };
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
/** Puts a fixed box at left/top, inside the viewport. */
|
|
472
|
+
function placeAt(box, left, top) {
|
|
473
|
+
box.style.right = 'auto'; // no i18n
|
|
474
|
+
box.style.bottom = 'auto'; // no i18n
|
|
475
|
+
box.style.left = Math.max(0, Math.min(left, window.innerWidth - box.offsetWidth)) + 'px'; // no i18n
|
|
476
|
+
box.style.top = Math.max(0, Math.min(top, window.innerHeight - box.offsetHeight)) + 'px'; // no i18n
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Moves `box` with the mouse or a finger pressed on `handle`. `skip` says which presses are not a
|
|
480
|
+
* drag; `moved` hears where the box ended up. A click that ends a drag goes no further.
|
|
481
|
+
*/
|
|
482
|
+
function makeDraggable(box, handle, skip, moved) {
|
|
483
|
+
var startX = 0, startY = 0, boxLeft = 0, boxTop = 0, dragging = false, dragged = false;
|
|
484
|
+
handle.addEventListener('pointerdown', shield.shield('AppticsFeedback', function (event) {
|
|
485
|
+
if (event.button !== 0 || (skip && skip(event.target))) {
|
|
486
|
+
return;
|
|
281
487
|
}
|
|
488
|
+
var rect = box.getBoundingClientRect();
|
|
282
489
|
dragging = true;
|
|
490
|
+
dragged = false;
|
|
283
491
|
startX = event.clientX;
|
|
284
492
|
startY = event.clientY;
|
|
285
|
-
boxLeft =
|
|
286
|
-
boxTop =
|
|
287
|
-
|
|
493
|
+
boxLeft = rect.left;
|
|
494
|
+
boxTop = rect.top;
|
|
495
|
+
handle.style.cursor = 'move'; // no i18n
|
|
496
|
+
// the moves and the release come to the handle however far the pointer goes, so nothing
|
|
497
|
+
// is left listening on the document once the box is gone
|
|
498
|
+
try {
|
|
499
|
+
handle.setPointerCapture(event.pointerId);
|
|
500
|
+
}
|
|
501
|
+
catch (err) { /* a pointer already released */ }
|
|
288
502
|
event.preventDefault();
|
|
289
|
-
});
|
|
290
|
-
|
|
503
|
+
}));
|
|
504
|
+
handle.addEventListener('pointermove', shield.shield('AppticsFeedback', function (event) {
|
|
291
505
|
if (!dragging) {
|
|
292
506
|
return;
|
|
293
507
|
}
|
|
294
|
-
var
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
box.style.top = Math.max(0, Math.min(top, window.innerHeight - box.offsetHeight)) + 'px'; // no i18n
|
|
298
|
-
});
|
|
299
|
-
document.addEventListener('mouseup', function () {
|
|
300
|
-
if (dragging) {
|
|
301
|
-
dragging = false;
|
|
302
|
-
header.style.cursor = 'grab'; // no i18n
|
|
508
|
+
var dx = event.clientX - startX, dy = event.clientY - startY;
|
|
509
|
+
if (!dragged && Math.abs(dx) < 4 && Math.abs(dy) < 4) {
|
|
510
|
+
return; // a press that wobbles is still a click
|
|
303
511
|
}
|
|
304
|
-
|
|
512
|
+
dragged = true;
|
|
513
|
+
placeAt(box, boxLeft + dx, boxTop + dy);
|
|
514
|
+
}));
|
|
515
|
+
function stop() {
|
|
516
|
+
if (!dragging) {
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
dragging = false;
|
|
520
|
+
handle.style.cursor = ''; // no i18n
|
|
521
|
+
if (dragged && moved) {
|
|
522
|
+
moved(parseInt(box.style.left, 10), parseInt(box.style.top, 10));
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
var onStop = shield.shield('AppticsFeedback', stop); // no i18n
|
|
526
|
+
handle.addEventListener('pointerup', onStop); // no i18n
|
|
527
|
+
handle.addEventListener('pointercancel', onStop); // no i18n
|
|
528
|
+
box.addEventListener('click', shield.shield('AppticsFeedback', function (event) {
|
|
529
|
+
if (dragged) {
|
|
530
|
+
dragged = false;
|
|
531
|
+
event.stopImmediatePropagation();
|
|
532
|
+
event.preventDefault();
|
|
533
|
+
}
|
|
534
|
+
}), true);
|
|
305
535
|
}
|
|
306
536
|
// core/transport asks for the picked user when it builds the feedback request's parameters
|
|
307
537
|
hooks.hooks.feedbackUser = function () {
|
|
@@ -310,7 +540,12 @@ hooks.hooks.feedbackUser = function () {
|
|
|
310
540
|
|
|
311
541
|
exports.chooseUserForSend = chooseUserForSend;
|
|
312
542
|
exports.logChoice = logChoice;
|
|
543
|
+
exports.ownName = ownName;
|
|
544
|
+
exports.pickedUser = pickedUser;
|
|
545
|
+
exports.shownViewer = shownViewer;
|
|
313
546
|
exports.userChoice = userChoice;
|
|
314
547
|
exports.wireDrag = wireDrag;
|
|
548
|
+
exports.wireLangPicker = wireLangPicker;
|
|
315
549
|
exports.wireLogControls = wireLogControls;
|
|
550
|
+
exports.wireTimerDrag = wireTimerDrag;
|
|
316
551
|
exports.wireUserPicker = wireUserPicker;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The feedback form's languages: the dropdown's text (own name, then the English name) and the
|
|
3
|
+
* BCP 47 tag the form root gets as its lang. English comes first and is the fallback for every key.
|
|
4
|
+
*/
|
|
5
|
+
export declare const FEEDBACK_LOCALES: readonly {
|
|
6
|
+
code: string;
|
|
7
|
+
label: string;
|
|
8
|
+
bcp47: string;
|
|
9
|
+
}[];
|
|
10
|
+
/** The locale for the browser's language preferences: the first that matches, else English. */
|
|
11
|
+
export declare function matchLocale(preferences: readonly string[]): string;
|
|
12
|
+
/** The stored pick if there is one, else what the browser asks for, else English. */
|
|
13
|
+
export declare function feedbackLocale(): string;
|
|
14
|
+
/** Remembers the language the user picked; a code the form doesn't have is ignored. */
|
|
15
|
+
export declare function setFeedbackLocale(code: string): void;
|
|
16
|
+
/** What fills a text's $1, $2...: a list, or one value on its own, as UI 2.0's getLocale takes them. */
|
|
17
|
+
export type LocaleParams = readonly (string | number)[] | string | number | null;
|
|
18
|
+
/**
|
|
19
|
+
* The text for a key in the form's language, else in English, else the key, with $1, $2... filled
|
|
20
|
+
* from params: UI 2.0's getLocale, so a key reads the same in both. getLocale('fdk.size.used', ['2 KB', '10 MB']).
|
|
21
|
+
*/
|
|
22
|
+
export declare function getLocale(key: string, params?: LocaleParams): string;
|
|
23
|
+
/**
|
|
24
|
+
* The English text for a key, whatever the form shows: for the errors a developer reads, which stay
|
|
25
|
+
* in English as the console warnings do, though they say what the form says.
|
|
26
|
+
*/
|
|
27
|
+
export declare function english(key: string, params?: LocaleParams): string;
|
|
28
|
+
/** The BCP 47 tag of the current language, for the form root's lang. */
|
|
29
|
+
export declare function feedbackLang(): string;
|
|
30
|
+
/** A count's text: the key's .one form for 1, its .other form for everything else. */
|
|
31
|
+
export declare function plural(count: number, key: string): string;
|