@modelform/react-native 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -0
- package/dist/{chunk-YUSXYDXG.mjs → chunk-72OFPTDE.mjs} +492 -0
- package/dist/{chunk-G67L7TFK.js → chunk-XWSPLZNC.js} +594 -102
- package/dist/core/formFill.d.ts +89 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +36 -2
- package/dist/core/index.mjs +35 -1
- package/dist/core/speech.d.ts +36 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +861 -467
- package/dist/index.mjs +849 -455
- package/dist/ui/inputs/Dictation.d.ts +30 -0
- package/dist/ui/inputs/InputForm.d.ts +17 -1
- package/dist/ui/inputs/VoiceFill.d.ts +28 -0
- package/dist/ui/inputs/formContext.d.ts +7 -0
- package/dist/ui/speech.d.ts +34 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
ConfigLoader,
|
|
9
9
|
DASHBOARD_DS,
|
|
10
10
|
DEFAULT_GAZETTEER,
|
|
11
|
+
DICTATION_TYPES,
|
|
11
12
|
DOCUMENT_GUIDE,
|
|
12
13
|
EDITABLE_VARIABLE_TYPES,
|
|
13
14
|
EXAMPLE_TEMPLATE,
|
|
@@ -62,6 +63,7 @@ import {
|
|
|
62
63
|
dashboardSourceIds,
|
|
63
64
|
defaultFetchJson,
|
|
64
65
|
describeRange,
|
|
66
|
+
dictationHints,
|
|
65
67
|
diffJson,
|
|
66
68
|
documentChanges,
|
|
67
69
|
documentIdFor,
|
|
@@ -78,6 +80,10 @@ import {
|
|
|
78
80
|
fetchJsonWithToken,
|
|
79
81
|
fieldDisplayName,
|
|
80
82
|
fieldMatches,
|
|
83
|
+
fillForm,
|
|
84
|
+
fillHints,
|
|
85
|
+
fillPrompt,
|
|
86
|
+
fillSchema,
|
|
81
87
|
fixDocumentPrompt,
|
|
82
88
|
fixTemplatePrompt,
|
|
83
89
|
formatClock,
|
|
@@ -127,7 +133,9 @@ import {
|
|
|
127
133
|
mappingProblem,
|
|
128
134
|
mappingRow,
|
|
129
135
|
mappingRows,
|
|
136
|
+
matchChoices,
|
|
130
137
|
metricChanges,
|
|
138
|
+
modelFiller,
|
|
131
139
|
movePanel,
|
|
132
140
|
newDocument,
|
|
133
141
|
newPanel,
|
|
@@ -149,11 +157,15 @@ import {
|
|
|
149
157
|
parseClockDigits,
|
|
150
158
|
parseDashboardLink,
|
|
151
159
|
parseDuration,
|
|
160
|
+
parseFillAnswer,
|
|
152
161
|
parseGazetteer,
|
|
153
162
|
parseJsonText,
|
|
154
163
|
parseLocalDateTime,
|
|
155
164
|
parseRange,
|
|
156
165
|
parseSnippet,
|
|
166
|
+
parseSpokenDuration,
|
|
167
|
+
parseSpokenNumber,
|
|
168
|
+
parseSpokenYesNo,
|
|
157
169
|
parseTemplate,
|
|
158
170
|
parseTime,
|
|
159
171
|
pasteSnippet,
|
|
@@ -166,6 +178,7 @@ import {
|
|
|
166
178
|
queryParam,
|
|
167
179
|
readConfigFiles,
|
|
168
180
|
readDocumentAnswer,
|
|
181
|
+
readFill,
|
|
169
182
|
readTemplateAnswer,
|
|
170
183
|
readingOrder,
|
|
171
184
|
reduce,
|
|
@@ -188,6 +201,8 @@ import {
|
|
|
188
201
|
resolveVariables,
|
|
189
202
|
revalidateBundle,
|
|
190
203
|
rowsToMappings,
|
|
204
|
+
ruleFill,
|
|
205
|
+
ruleFiller,
|
|
191
206
|
sameSave,
|
|
192
207
|
sampleEntries,
|
|
193
208
|
screenDocuments,
|
|
@@ -202,9 +217,11 @@ import {
|
|
|
202
217
|
settleLayout,
|
|
203
218
|
snapToGrid,
|
|
204
219
|
splitPath,
|
|
220
|
+
spokenValue,
|
|
205
221
|
startOf,
|
|
206
222
|
stringifyCompact,
|
|
207
223
|
tabIdFor,
|
|
224
|
+
takesDictation,
|
|
208
225
|
templateNeeds,
|
|
209
226
|
templatePrompt,
|
|
210
227
|
textSuggestions,
|
|
@@ -234,7 +251,7 @@ import {
|
|
|
234
251
|
variableWithType,
|
|
235
252
|
visibleVariables,
|
|
236
253
|
zoomRange
|
|
237
|
-
} from "./chunk-
|
|
254
|
+
} from "./chunk-72OFPTDE.mjs";
|
|
238
255
|
|
|
239
256
|
// src/ui/theme.tsx
|
|
240
257
|
import { createContext, useContext } from "react";
|
|
@@ -586,14 +603,14 @@ function usePanelLinks(panel) {
|
|
|
586
603
|
}
|
|
587
604
|
|
|
588
605
|
// src/ui/DashboardView.tsx
|
|
589
|
-
import { useCallback as useCallback3, useContext as useContext4, useMemo as useMemo9, useRef as
|
|
606
|
+
import { useCallback as useCallback3, useContext as useContext4, useMemo as useMemo9, useRef as useRef6, useState as useState12 } from "react";
|
|
590
607
|
import {
|
|
591
608
|
ActivityIndicator,
|
|
592
|
-
Pressable as
|
|
609
|
+
Pressable as Pressable13,
|
|
593
610
|
RefreshControl,
|
|
594
611
|
ScrollView as ScrollView6,
|
|
595
|
-
StyleSheet as
|
|
596
|
-
Text as
|
|
612
|
+
StyleSheet as StyleSheet15,
|
|
613
|
+
Text as Text14,
|
|
597
614
|
View as View13,
|
|
598
615
|
useWindowDimensions
|
|
599
616
|
} from "react-native";
|
|
@@ -629,12 +646,12 @@ function useInputForm() {
|
|
|
629
646
|
}
|
|
630
647
|
|
|
631
648
|
// src/ui/inputs/InputGroup.tsx
|
|
632
|
-
import { useMemo as useMemo2, useRef as
|
|
633
|
-
import { Pressable as
|
|
649
|
+
import { useMemo as useMemo2, useRef as useRef3, useState as useState7 } from "react";
|
|
650
|
+
import { Pressable as Pressable7, ScrollView as ScrollView4, StyleSheet as StyleSheet8, Text as Text8, View as View6 } from "react-native";
|
|
634
651
|
|
|
635
652
|
// src/ui/inputs/InputPanels.tsx
|
|
636
|
-
import { useEffect as
|
|
637
|
-
import { Platform, Pressable as
|
|
653
|
+
import { useEffect as useEffect3, useState as useState6 } from "react";
|
|
654
|
+
import { Platform, Pressable as Pressable6, ScrollView as ScrollView3, StyleSheet as StyleSheet7, Switch, Text as Text7, TextInput as TextInput2, View as View5 } from "react-native";
|
|
638
655
|
|
|
639
656
|
// src/ui/Toolbar.tsx
|
|
640
657
|
import { useState as useState3 } from "react";
|
|
@@ -1408,29 +1425,143 @@ var styles5 = StyleSheet5.create({
|
|
|
1408
1425
|
tooltipValue: { fontSize: 12, fontWeight: "600", marginLeft: "auto", paddingLeft: 8 }
|
|
1409
1426
|
});
|
|
1410
1427
|
|
|
1411
|
-
// src/ui/inputs/
|
|
1428
|
+
// src/ui/inputs/Dictation.tsx
|
|
1429
|
+
import { useEffect as useEffect2, useRef as useRef2, useState as useState5 } from "react";
|
|
1430
|
+
import { Pressable as Pressable5, StyleSheet as StyleSheet6, Text as Text6 } from "react-native";
|
|
1431
|
+
import Svg4, { Path as Path4 } from "react-native-svg";
|
|
1412
1432
|
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1433
|
+
var listening = null;
|
|
1434
|
+
function stopListening() {
|
|
1435
|
+
listening?.abort();
|
|
1436
|
+
listening = null;
|
|
1437
|
+
}
|
|
1438
|
+
function claimListening(session, done = false) {
|
|
1439
|
+
if (done) {
|
|
1440
|
+
if (listening === session) listening = null;
|
|
1441
|
+
} else listening = session;
|
|
1442
|
+
}
|
|
1443
|
+
var HINT_MS = 4e3;
|
|
1444
|
+
function useDictation(panel, value, onChange, choices) {
|
|
1445
|
+
const form = useInputForm();
|
|
1446
|
+
const speech = form.speech;
|
|
1447
|
+
const [on, setOn] = useState5(false);
|
|
1448
|
+
const [hint, setHint] = useState5(null);
|
|
1449
|
+
const session = useRef2(null);
|
|
1450
|
+
const latest = useRef2({ value, onChange, choices });
|
|
1451
|
+
useEffect2(() => {
|
|
1452
|
+
latest.current = { value, onChange, choices };
|
|
1453
|
+
});
|
|
1454
|
+
useEffect2(
|
|
1455
|
+
() => () => {
|
|
1456
|
+
session.current?.abort();
|
|
1457
|
+
},
|
|
1458
|
+
[]
|
|
1459
|
+
);
|
|
1460
|
+
useEffect2(() => {
|
|
1461
|
+
if (on || !hint) return;
|
|
1462
|
+
const t = setTimeout(() => setHint(null), HINT_MS);
|
|
1463
|
+
return () => clearTimeout(t);
|
|
1464
|
+
}, [on, hint]);
|
|
1465
|
+
const toggle = () => {
|
|
1466
|
+
if (!speech) return;
|
|
1467
|
+
if (session.current) {
|
|
1468
|
+
session.current.stop();
|
|
1469
|
+
return;
|
|
1470
|
+
}
|
|
1471
|
+
stopListening();
|
|
1472
|
+
setHint(null);
|
|
1473
|
+
let mine = null;
|
|
1474
|
+
let ended = false;
|
|
1475
|
+
const end = () => {
|
|
1476
|
+
ended = true;
|
|
1477
|
+
if (session.current === mine) session.current = null;
|
|
1478
|
+
claimListening(mine, true);
|
|
1479
|
+
setOn(false);
|
|
1480
|
+
};
|
|
1481
|
+
try {
|
|
1482
|
+
mine = speech.start({
|
|
1483
|
+
lang: form.speechLang,
|
|
1484
|
+
hints: dictationHints(panel, choices),
|
|
1485
|
+
onText(text, final) {
|
|
1486
|
+
if (!final) return setHint(text ? `\u201C${text}\u201D` : null);
|
|
1487
|
+
const result = spokenValue(panel, text, latest.current.value, latest.current.choices);
|
|
1488
|
+
if ("value" in result) {
|
|
1489
|
+
latest.current.onChange(result.value);
|
|
1490
|
+
setHint(null);
|
|
1491
|
+
} else setHint(result.problem);
|
|
1492
|
+
},
|
|
1493
|
+
onError: (message) => setHint(message),
|
|
1494
|
+
onEnd: end
|
|
1495
|
+
});
|
|
1496
|
+
} catch {
|
|
1497
|
+
setHint("Dictation couldn\u2019t start");
|
|
1498
|
+
return;
|
|
1499
|
+
}
|
|
1500
|
+
if (!ended) {
|
|
1501
|
+
session.current = mine;
|
|
1502
|
+
claimListening(mine);
|
|
1503
|
+
setOn(true);
|
|
1504
|
+
}
|
|
1505
|
+
};
|
|
1506
|
+
return { available: !!speech && takesDictation(panel), listening: on, hint, toggle };
|
|
1507
|
+
}
|
|
1508
|
+
function MicButton({ dictation, title, label, size = 32 }) {
|
|
1509
|
+
const theme = useDashTheme();
|
|
1510
|
+
if (!dictation.available) return null;
|
|
1511
|
+
const on = dictation.listening;
|
|
1512
|
+
return /* @__PURE__ */ jsx8(
|
|
1513
|
+
Pressable5,
|
|
1514
|
+
{
|
|
1515
|
+
onPress: dictation.toggle,
|
|
1516
|
+
accessibilityRole: "button",
|
|
1517
|
+
accessibilityLabel: on ? "Stop dictating" : label ?? (title ? `Dictate ${title}` : "Dictate"),
|
|
1518
|
+
accessibilityState: { selected: on },
|
|
1519
|
+
hitSlop: 6,
|
|
1520
|
+
style: ({ pressed }) => [
|
|
1521
|
+
styles6.mic,
|
|
1522
|
+
{ width: size, height: size, borderRadius: size / 2, borderColor: on ? theme.accent : theme.border },
|
|
1523
|
+
{ backgroundColor: on ? theme.accent : pressed ? theme.grid : theme.surface }
|
|
1524
|
+
],
|
|
1525
|
+
children: /* @__PURE__ */ jsxs6(Svg4, { width: size * 0.55, height: size * 0.55, viewBox: "0 0 24 24", fill: "none", stroke: on ? "#fff" : theme.textSecondary, strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
1526
|
+
/* @__PURE__ */ jsx8(Path4, { d: "M12 3a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V6a3 3 0 0 0-3-3z" }),
|
|
1527
|
+
/* @__PURE__ */ jsx8(Path4, { d: "M19 11a7 7 0 0 1-14 0M12 18v3" })
|
|
1528
|
+
] })
|
|
1529
|
+
}
|
|
1530
|
+
);
|
|
1531
|
+
}
|
|
1532
|
+
function DictationHint({ dictation }) {
|
|
1533
|
+
const theme = useDashTheme();
|
|
1534
|
+
if (!dictation.hint) return null;
|
|
1535
|
+
return /* @__PURE__ */ jsx8(Text6, { style: [styles6.hint, { color: dictation.listening ? theme.textSecondary : theme.textMuted }], numberOfLines: 1, accessibilityLiveRegion: "polite", children: dictation.hint });
|
|
1536
|
+
}
|
|
1537
|
+
var styles6 = StyleSheet6.create({
|
|
1538
|
+
mic: { borderWidth: 1, alignItems: "center", justifyContent: "center" },
|
|
1539
|
+
hint: { fontSize: 12, fontStyle: "italic" }
|
|
1540
|
+
});
|
|
1541
|
+
|
|
1542
|
+
// src/ui/inputs/InputPanels.tsx
|
|
1543
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1413
1544
|
function InputPanelBody({ panel }) {
|
|
1414
1545
|
const form = useInputForm();
|
|
1415
1546
|
const metric = panel.options.metric;
|
|
1416
1547
|
const props = { panel, value: form.value(metric), onChange: (v) => form.setValue(metric, v) };
|
|
1417
1548
|
switch (panel.type) {
|
|
1418
1549
|
case "input-number":
|
|
1419
|
-
return /* @__PURE__ */
|
|
1550
|
+
return /* @__PURE__ */ jsx9(NumberInput, { ...props });
|
|
1420
1551
|
case "input-slider":
|
|
1421
|
-
return /* @__PURE__ */
|
|
1552
|
+
return /* @__PURE__ */ jsx9(SliderInput, { ...props });
|
|
1422
1553
|
case "input-select":
|
|
1423
|
-
return /* @__PURE__ */
|
|
1554
|
+
return /* @__PURE__ */ jsx9(SelectInput, { ...props });
|
|
1424
1555
|
case "input-toggle":
|
|
1425
|
-
return /* @__PURE__ */
|
|
1556
|
+
return /* @__PURE__ */ jsx9(ToggleInput, { ...props });
|
|
1426
1557
|
case "input-rating":
|
|
1427
|
-
return /* @__PURE__ */
|
|
1558
|
+
return /* @__PURE__ */ jsx9(RatingInput, { ...props });
|
|
1428
1559
|
case "input-text":
|
|
1429
|
-
return panel.options.suggest ? /* @__PURE__ */
|
|
1560
|
+
return panel.options.suggest ? /* @__PURE__ */ jsx9(SuggestTextInput, { ...props }) : /* @__PURE__ */ jsx9(FreeTextInput, { ...props });
|
|
1430
1561
|
case "input-counter":
|
|
1431
|
-
return /* @__PURE__ */
|
|
1562
|
+
return /* @__PURE__ */ jsx9(CounterInput, { panel });
|
|
1432
1563
|
case "input-duration":
|
|
1433
|
-
return /* @__PURE__ */
|
|
1564
|
+
return /* @__PURE__ */ jsx9(DurationInput, { ...props });
|
|
1434
1565
|
default:
|
|
1435
1566
|
return null;
|
|
1436
1567
|
}
|
|
@@ -1440,10 +1571,10 @@ var decimalsOf = (step) => (String(step).split(".")[1] ?? "").length;
|
|
|
1440
1571
|
function NumberInput({ panel, value, onChange }) {
|
|
1441
1572
|
const theme = useDashTheme();
|
|
1442
1573
|
const { step = 1, min, max, unit, placeholder } = panel.options;
|
|
1443
|
-
const [text, setText] =
|
|
1574
|
+
const [text, setText] = useState6(value == null ? "" : String(value));
|
|
1444
1575
|
const [size, onLayout] = useLayout();
|
|
1445
1576
|
const compact = size.width > 0 && size.width < COMPACT_NUMBER_WIDTH;
|
|
1446
|
-
const [syncedValue, setSyncedValue] =
|
|
1577
|
+
const [syncedValue, setSyncedValue] = useState6(value);
|
|
1447
1578
|
if (value !== syncedValue) {
|
|
1448
1579
|
setSyncedValue(value);
|
|
1449
1580
|
setText((t) => value == null ? "" : Number(t.replace(",", ".")) === value && t.trim() ? t : String(value));
|
|
@@ -1456,61 +1587,73 @@ function NumberInput({ panel, value, onChange }) {
|
|
|
1456
1587
|
const base = typeof value === "number" ? value : Number(text) || 0;
|
|
1457
1588
|
onChange(Number(clamp2(base + dir * step).toFixed(decimalsOf(step))));
|
|
1458
1589
|
};
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
/* @__PURE__ */
|
|
1462
|
-
/* @__PURE__ */
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1590
|
+
const dictation = useDictation(panel, value, onChange);
|
|
1591
|
+
return /* @__PURE__ */ jsxs7(View5, { style: styles7.dictated, children: [
|
|
1592
|
+
/* @__PURE__ */ jsxs7(View5, { style: [styles7.numberRow, compact && styles7.numberRowCompact], onLayout, children: [
|
|
1593
|
+
/* @__PURE__ */ jsx9(StepButton, { label: "\u2212", onPress: () => bump(-1), compact }),
|
|
1594
|
+
/* @__PURE__ */ jsxs7(View5, { style: [styles7.numberField, compact && styles7.numberFieldCompact, { borderColor: theme.border }], children: [
|
|
1595
|
+
/* @__PURE__ */ jsx9(
|
|
1596
|
+
TextInput2,
|
|
1597
|
+
{
|
|
1598
|
+
value: text,
|
|
1599
|
+
onChangeText: (t) => {
|
|
1600
|
+
setText(t);
|
|
1601
|
+
const n = Number(t.replace(",", "."));
|
|
1602
|
+
if (t.trim() && !Number.isNaN(n)) onChange(clamp2(integer ? Math.round(n) : n));
|
|
1603
|
+
else if (!t.trim()) onChange(null);
|
|
1604
|
+
},
|
|
1605
|
+
keyboardType,
|
|
1606
|
+
placeholder: placeholder ?? "\u2014",
|
|
1607
|
+
placeholderTextColor: theme.textMuted,
|
|
1608
|
+
style: [styles7.numberText, compact && styles7.numberTextCompact, { color: theme.text }],
|
|
1609
|
+
accessibilityLabel: unit ? `${panel.title} (${unit})` : panel.title,
|
|
1610
|
+
selectTextOnFocus: true
|
|
1611
|
+
}
|
|
1612
|
+
),
|
|
1613
|
+
unit && !compact ? /* @__PURE__ */ jsx9(Text7, { style: [styles7.unit, { color: theme.textMuted }], children: unit }) : null,
|
|
1614
|
+
/* @__PURE__ */ jsx9(MicButton, { dictation, title: panel.title, size: compact ? 24 : 28 })
|
|
1615
|
+
] }),
|
|
1616
|
+
/* @__PURE__ */ jsx9(StepButton, { label: "+", onPress: () => bump(1), compact })
|
|
1481
1617
|
] }),
|
|
1482
|
-
/* @__PURE__ */
|
|
1618
|
+
/* @__PURE__ */ jsx9(DictationHint, { dictation })
|
|
1483
1619
|
] });
|
|
1484
1620
|
}
|
|
1485
1621
|
function DurationInput({ panel, value, onChange }) {
|
|
1486
1622
|
const theme = useDashTheme();
|
|
1487
1623
|
const toDigits = (v) => typeof v === "number" ? formatClock(v).replace(/\D/g, "").replace(/^0+/, "") : "";
|
|
1488
|
-
const [digits, setDigits] =
|
|
1489
|
-
const [syncedValue, setSyncedValue] =
|
|
1624
|
+
const [digits, setDigits] = useState6(toDigits(value));
|
|
1625
|
+
const [syncedValue, setSyncedValue] = useState6(value);
|
|
1490
1626
|
if (value !== syncedValue) {
|
|
1491
1627
|
setSyncedValue(value);
|
|
1492
1628
|
setDigits((d) => value == null ? parseClockDigits(d) == null ? d : "" : parseClockDigits(d) === value ? d : toDigits(value));
|
|
1493
1629
|
}
|
|
1494
1630
|
const masked = digits ? maskClock(digits) : "";
|
|
1495
1631
|
const invalid = !!digits && parseClockDigits(digits) == null;
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
{
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1632
|
+
const dictation = useDictation(panel, value, onChange);
|
|
1633
|
+
return /* @__PURE__ */ jsxs7(View5, { style: styles7.dictated, children: [
|
|
1634
|
+
/* @__PURE__ */ jsxs7(View5, { style: [styles7.numberField, { borderColor: invalid ? theme.danger : theme.border }], children: [
|
|
1635
|
+
/* @__PURE__ */ jsx9(
|
|
1636
|
+
TextInput2,
|
|
1637
|
+
{
|
|
1638
|
+
value: masked,
|
|
1639
|
+
onChangeText: (t) => {
|
|
1640
|
+
const d = t.replace(/\D/g, "").replace(/^0+/, "").slice(0, 6);
|
|
1641
|
+
setDigits(d);
|
|
1642
|
+
onChange(parseClockDigits(d));
|
|
1643
|
+
},
|
|
1644
|
+
keyboardType: "number-pad",
|
|
1645
|
+
placeholder: panel.options.placeholder ?? "00:00.00",
|
|
1646
|
+
placeholderTextColor: theme.textMuted,
|
|
1647
|
+
style: [styles7.numberText, { color: invalid ? theme.danger : theme.text }],
|
|
1648
|
+
accessibilityLabel: panel.title,
|
|
1649
|
+
accessibilityHint: "Type the digits only, for example 13245 for 1 minute 32.45 seconds",
|
|
1650
|
+
selection: { start: masked.length, end: masked.length }
|
|
1651
|
+
}
|
|
1652
|
+
),
|
|
1653
|
+
/* @__PURE__ */ jsx9(MicButton, { dictation, title: panel.title, size: 28 })
|
|
1654
|
+
] }),
|
|
1655
|
+
/* @__PURE__ */ jsx9(DictationHint, { dictation })
|
|
1656
|
+
] });
|
|
1514
1657
|
}
|
|
1515
1658
|
function maskClock(digits) {
|
|
1516
1659
|
const p = digits.slice(-6).padStart(6, "0");
|
|
@@ -1518,14 +1661,14 @@ function maskClock(digits) {
|
|
|
1518
1661
|
}
|
|
1519
1662
|
function StepButton({ label, onPress, compact }) {
|
|
1520
1663
|
const theme = useDashTheme();
|
|
1521
|
-
return /* @__PURE__ */
|
|
1522
|
-
|
|
1664
|
+
return /* @__PURE__ */ jsx9(
|
|
1665
|
+
Pressable6,
|
|
1523
1666
|
{
|
|
1524
1667
|
onPress,
|
|
1525
1668
|
accessibilityRole: "button",
|
|
1526
1669
|
accessibilityLabel: label === "+" ? "Increase" : "Decrease",
|
|
1527
|
-
style: ({ pressed }) => [
|
|
1528
|
-
children: /* @__PURE__ */
|
|
1670
|
+
style: ({ pressed }) => [styles7.stepBtn, compact && styles7.stepBtnCompact, { borderColor: theme.border, backgroundColor: pressed ? theme.grid : theme.surface }],
|
|
1671
|
+
children: /* @__PURE__ */ jsx9(Text7, { style: [styles7.stepText, { color: theme.text }], children: label })
|
|
1529
1672
|
}
|
|
1530
1673
|
);
|
|
1531
1674
|
}
|
|
@@ -1549,17 +1692,17 @@ function SliderInput({ panel, value, onChange }) {
|
|
|
1549
1692
|
const raw = min + Math.min(1, Math.max(0, x / size.width)) * (max - min);
|
|
1550
1693
|
onChange(Number((Math.round((raw - min) / step) * step + min).toFixed(decimalsOf(step))));
|
|
1551
1694
|
};
|
|
1552
|
-
return /* @__PURE__ */
|
|
1553
|
-
/* @__PURE__ */
|
|
1554
|
-
!labels?.length && /* @__PURE__ */
|
|
1555
|
-
/* @__PURE__ */
|
|
1556
|
-
!labels?.length && /* @__PURE__ */
|
|
1695
|
+
return /* @__PURE__ */ jsxs7(View5, { style: styles7.sliderWrap, children: [
|
|
1696
|
+
/* @__PURE__ */ jsxs7(View5, { style: styles7.sliderLabels, children: [
|
|
1697
|
+
!labels?.length && /* @__PURE__ */ jsx9(Text7, { style: [styles7.minmax, { color: theme.textMuted }], children: min }),
|
|
1698
|
+
/* @__PURE__ */ jsx9(Text7, { style: [styles7.sliderValue, { color: theme.text }, !!labels?.length && styles7.sliderValueCentered], children: display }),
|
|
1699
|
+
!labels?.length && /* @__PURE__ */ jsx9(Text7, { style: [styles7.minmax, { color: theme.textMuted }], children: max })
|
|
1557
1700
|
] }),
|
|
1558
|
-
/* @__PURE__ */
|
|
1701
|
+
/* @__PURE__ */ jsxs7(
|
|
1559
1702
|
View5,
|
|
1560
1703
|
{
|
|
1561
1704
|
onLayout,
|
|
1562
|
-
style:
|
|
1705
|
+
style: styles7.sliderHit,
|
|
1563
1706
|
onStartShouldSetResponder: () => true,
|
|
1564
1707
|
onMoveShouldSetResponder: () => true,
|
|
1565
1708
|
onResponderTerminationRequest: () => false,
|
|
@@ -1570,29 +1713,29 @@ function SliderInput({ panel, value, onChange }) {
|
|
|
1570
1713
|
accessibilityActions: [{ name: "increment" }, { name: "decrement" }],
|
|
1571
1714
|
onAccessibilityAction: (e) => onChange(Math.min(max, Math.max(min, (v ?? min) + (e.nativeEvent.actionName === "increment" ? step : -step)))),
|
|
1572
1715
|
children: [
|
|
1573
|
-
/* @__PURE__ */
|
|
1716
|
+
/* @__PURE__ */ jsx9(View5, { pointerEvents: "none", style: [styles7.track, { backgroundColor: theme.grid }], children: /* @__PURE__ */ jsx9(
|
|
1574
1717
|
View5,
|
|
1575
1718
|
{
|
|
1576
1719
|
style: [
|
|
1577
|
-
|
|
1720
|
+
styles7.trackFill,
|
|
1578
1721
|
{ left: `${fillStart * 100}%`, width: `${v == null ? 0 : Math.abs(frac - origin) * 100}%`, backgroundColor: theme.accent }
|
|
1579
1722
|
]
|
|
1580
1723
|
}
|
|
1581
1724
|
) }),
|
|
1582
|
-
v != null && /* @__PURE__ */
|
|
1725
|
+
v != null && /* @__PURE__ */ jsx9(
|
|
1583
1726
|
View5,
|
|
1584
1727
|
{
|
|
1585
1728
|
pointerEvents: "none",
|
|
1586
|
-
style: [
|
|
1729
|
+
style: [styles7.thumb, { left: frac * size.width - 11, backgroundColor: theme.accent, borderColor: theme.surface }]
|
|
1587
1730
|
}
|
|
1588
1731
|
)
|
|
1589
1732
|
]
|
|
1590
1733
|
}
|
|
1591
1734
|
),
|
|
1592
|
-
!!labels?.length && /* @__PURE__ */
|
|
1735
|
+
!!labels?.length && /* @__PURE__ */ jsx9(View5, { style: styles7.tickRow, children: labels.map((l, i) => {
|
|
1593
1736
|
const last = labels.length - 1;
|
|
1594
|
-
const edge = i === 0 ?
|
|
1595
|
-
return /* @__PURE__ */
|
|
1737
|
+
const edge = i === 0 ? styles7.tickStart : i === last ? styles7.tickEnd : { left: `${i / last * 100}%` };
|
|
1738
|
+
return /* @__PURE__ */ jsx9(Text7, { style: [styles7.minmax, styles7.tick, edge, { color: theme.textMuted }], numberOfLines: 1, children: l }, i);
|
|
1596
1739
|
}) })
|
|
1597
1740
|
] });
|
|
1598
1741
|
}
|
|
@@ -1602,29 +1745,36 @@ function SelectInput({ panel, value, onChange }) {
|
|
|
1602
1745
|
const { choicesFrom, multi, placeholder } = panel.options;
|
|
1603
1746
|
const choices = (choicesFrom ? form.choices[choicesFrom] : panel.options.choices) ?? [];
|
|
1604
1747
|
const selected = Array.isArray(value) ? value : value == null ? [] : [value];
|
|
1605
|
-
|
|
1606
|
-
return /* @__PURE__ */
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1748
|
+
const dictation = useDictation(panel, value, onChange, choices);
|
|
1749
|
+
if (!choices.length && placeholder) return /* @__PURE__ */ jsx9(Text7, { style: { color: theme.textMuted }, children: placeholder });
|
|
1750
|
+
return /* @__PURE__ */ jsxs7(View5, { style: styles7.selectWrap, children: [
|
|
1751
|
+
/* @__PURE__ */ jsxs7(View5, { style: styles7.wrap, children: [
|
|
1752
|
+
choices.map((c) => {
|
|
1753
|
+
const on = selected.includes(c.value);
|
|
1754
|
+
return /* @__PURE__ */ jsx9(
|
|
1755
|
+
Chip,
|
|
1756
|
+
{
|
|
1757
|
+
label: c.label,
|
|
1758
|
+
selected: on,
|
|
1759
|
+
onPress: () => {
|
|
1760
|
+
if (!multi) return onChange(on ? null : c.value);
|
|
1761
|
+
const next = on ? selected.filter((s) => s !== c.value) : [...selected, c.value];
|
|
1762
|
+
onChange(next.length ? next : null);
|
|
1763
|
+
}
|
|
1764
|
+
},
|
|
1765
|
+
String(c.value)
|
|
1766
|
+
);
|
|
1767
|
+
}),
|
|
1768
|
+
choices.length > 0 && /* @__PURE__ */ jsx9(MicButton, { dictation, title: panel.title })
|
|
1769
|
+
] }),
|
|
1770
|
+
/* @__PURE__ */ jsx9(DictationHint, { dictation })
|
|
1771
|
+
] });
|
|
1622
1772
|
}
|
|
1623
1773
|
function ToggleInput({ panel, value, onChange }) {
|
|
1624
1774
|
const theme = useDashTheme();
|
|
1625
|
-
return /* @__PURE__ */
|
|
1626
|
-
/* @__PURE__ */
|
|
1627
|
-
/* @__PURE__ */
|
|
1775
|
+
return /* @__PURE__ */ jsxs7(View5, { style: styles7.toggleRow, children: [
|
|
1776
|
+
/* @__PURE__ */ jsx9(Text7, { style: { color: theme.textSecondary, flex: 1 }, children: value == null ? "Not set" : value ? "Yes" : "No" }),
|
|
1777
|
+
/* @__PURE__ */ jsx9(Switch, { value: !!value, onValueChange: (v) => onChange(v), trackColor: { true: theme.accent }, accessibilityLabel: panel.title })
|
|
1628
1778
|
] });
|
|
1629
1779
|
}
|
|
1630
1780
|
var MAX_RATING_LEVELS = 10;
|
|
@@ -1633,17 +1783,17 @@ function RatingInput({ panel, value, onChange }) {
|
|
|
1633
1783
|
const min = Math.round(panel.options.min ?? 1);
|
|
1634
1784
|
const max = Math.round(panel.options.max ?? 5);
|
|
1635
1785
|
const levels = Array.from({ length: Math.min(Math.max(0, max - min + 1), MAX_RATING_LEVELS) }, (_, i) => min + i);
|
|
1636
|
-
return /* @__PURE__ */
|
|
1786
|
+
return /* @__PURE__ */ jsx9(View5, { style: styles7.rating, children: levels.map((n) => {
|
|
1637
1787
|
const on = typeof value === "number" && n <= value;
|
|
1638
|
-
return /* @__PURE__ */
|
|
1639
|
-
|
|
1788
|
+
return /* @__PURE__ */ jsx9(
|
|
1789
|
+
Pressable6,
|
|
1640
1790
|
{
|
|
1641
1791
|
onPress: () => onChange(value === n ? null : n),
|
|
1642
1792
|
accessibilityRole: "button",
|
|
1643
1793
|
accessibilityLabel: `${n} of ${max}`,
|
|
1644
1794
|
accessibilityState: { selected: value === n },
|
|
1645
|
-
style: [
|
|
1646
|
-
children: /* @__PURE__ */
|
|
1795
|
+
style: [styles7.ratingDot, { borderColor: on ? theme.accent : theme.border, backgroundColor: on ? theme.accent : theme.surface }],
|
|
1796
|
+
children: /* @__PURE__ */ jsx9(Text7, { style: { color: on ? "#fff" : theme.textSecondary, fontWeight: "600" }, children: n })
|
|
1647
1797
|
},
|
|
1648
1798
|
n
|
|
1649
1799
|
);
|
|
@@ -1651,27 +1801,35 @@ function RatingInput({ panel, value, onChange }) {
|
|
|
1651
1801
|
}
|
|
1652
1802
|
function FreeTextInput({ panel, value, onChange }) {
|
|
1653
1803
|
const theme = useDashTheme();
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
{
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1804
|
+
const dictation = useDictation(panel, value, onChange);
|
|
1805
|
+
return /* @__PURE__ */ jsxs7(View5, { style: styles7.dictated, children: [
|
|
1806
|
+
/* @__PURE__ */ jsxs7(View5, { style: styles7.fill, children: [
|
|
1807
|
+
/* @__PURE__ */ jsx9(
|
|
1808
|
+
TextInput2,
|
|
1809
|
+
{
|
|
1810
|
+
value: typeof value === "string" ? value : "",
|
|
1811
|
+
onChangeText: (t) => onChange(t || null),
|
|
1812
|
+
placeholder: panel.options.placeholder ?? "Type here",
|
|
1813
|
+
placeholderTextColor: theme.textMuted,
|
|
1814
|
+
multiline: true,
|
|
1815
|
+
accessibilityLabel: panel.title,
|
|
1816
|
+
style: [styles7.textArea, dictation.available && styles7.textAreaWithMic, { color: theme.text, borderColor: theme.border }]
|
|
1817
|
+
}
|
|
1818
|
+
),
|
|
1819
|
+
dictation.available && /* @__PURE__ */ jsx9(View5, { style: styles7.textAreaMic, children: /* @__PURE__ */ jsx9(MicButton, { dictation, title: panel.title, size: 28 }) })
|
|
1820
|
+
] }),
|
|
1821
|
+
/* @__PURE__ */ jsx9(DictationHint, { dictation })
|
|
1822
|
+
] });
|
|
1665
1823
|
}
|
|
1666
1824
|
function SuggestTextInput({ panel, value, onChange }) {
|
|
1667
1825
|
const theme = useDashTheme();
|
|
1668
1826
|
const form = useInputForm();
|
|
1669
1827
|
const { metric, suggestWith, placeholder } = panel.options;
|
|
1670
|
-
const [entries, setEntries] =
|
|
1671
|
-
const [typed, setTyped] =
|
|
1828
|
+
const [entries, setEntries] = useState6([]);
|
|
1829
|
+
const [typed, setTyped] = useState6(false);
|
|
1672
1830
|
const text = typeof value === "string" ? value : "";
|
|
1673
1831
|
const { store } = form;
|
|
1674
|
-
|
|
1832
|
+
useEffect3(() => {
|
|
1675
1833
|
let run = 0;
|
|
1676
1834
|
const load = () => {
|
|
1677
1835
|
const mine = ++run;
|
|
@@ -1690,26 +1848,34 @@ function SuggestTextInput({ panel, value, onChange }) {
|
|
|
1690
1848
|
const query = typed ? text : "";
|
|
1691
1849
|
const fromScoped = textSuggestions(scoped, query);
|
|
1692
1850
|
const suggestions = (fromScoped.length ? fromScoped : textSuggestions(own, query)).filter((s) => s.toLowerCase() !== text.trim().toLowerCase());
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1851
|
+
const dictation = useDictation(panel, value, (v) => {
|
|
1852
|
+
setTyped(false);
|
|
1853
|
+
onChange(v);
|
|
1854
|
+
});
|
|
1855
|
+
return /* @__PURE__ */ jsxs7(View5, { style: styles7.suggest, children: [
|
|
1856
|
+
/* @__PURE__ */ jsxs7(View5, { style: styles7.lineRow, children: [
|
|
1857
|
+
/* @__PURE__ */ jsx9(
|
|
1858
|
+
TextInput2,
|
|
1859
|
+
{
|
|
1860
|
+
value: text,
|
|
1861
|
+
onChangeText: (t) => {
|
|
1862
|
+
setTyped(!!t);
|
|
1863
|
+
onChange(t || null);
|
|
1864
|
+
},
|
|
1865
|
+
placeholder: placeholder ?? "Type here",
|
|
1866
|
+
placeholderTextColor: theme.textMuted,
|
|
1867
|
+
style: [styles7.textLine, { color: theme.text, borderColor: theme.border }],
|
|
1868
|
+
accessibilityLabel: panel.title,
|
|
1869
|
+
autoCorrect: false,
|
|
1870
|
+
autoCapitalize: "words",
|
|
1871
|
+
returnKeyType: "done",
|
|
1872
|
+
selectTextOnFocus: true
|
|
1873
|
+
}
|
|
1874
|
+
),
|
|
1875
|
+
/* @__PURE__ */ jsx9(MicButton, { dictation, title: panel.title })
|
|
1876
|
+
] }),
|
|
1877
|
+
/* @__PURE__ */ jsx9(DictationHint, { dictation }),
|
|
1878
|
+
/* @__PURE__ */ jsx9(ScrollView3, { horizontal: true, keyboardShouldPersistTaps: "handled", showsHorizontalScrollIndicator: false, contentContainerStyle: styles7.wrap, children: suggestions.map((s) => /* @__PURE__ */ jsx9(
|
|
1713
1879
|
Chip,
|
|
1714
1880
|
{
|
|
1715
1881
|
label: s,
|
|
@@ -1726,28 +1892,28 @@ function CounterInput({ panel }) {
|
|
|
1726
1892
|
const theme = useDashTheme();
|
|
1727
1893
|
const { store } = useInputForm();
|
|
1728
1894
|
const { metric, increment = 1, unit } = panel.options;
|
|
1729
|
-
const [today, setToday] =
|
|
1730
|
-
|
|
1895
|
+
const [today, setToday] = useState6(0);
|
|
1896
|
+
useEffect3(() => {
|
|
1731
1897
|
const load = () => store.list({ metrics: [metric], from: startOf(/* @__PURE__ */ new Date(), "d").getTime() }).then((rows) => setToday(rows.reduce((a, e) => a + (e.value ?? 0), 0)));
|
|
1732
1898
|
load();
|
|
1733
1899
|
return store.subscribe(load);
|
|
1734
1900
|
}, [store, metric]);
|
|
1735
|
-
return /* @__PURE__ */
|
|
1736
|
-
/* @__PURE__ */
|
|
1737
|
-
/* @__PURE__ */
|
|
1901
|
+
return /* @__PURE__ */ jsxs7(View5, { style: styles7.counter, children: [
|
|
1902
|
+
/* @__PURE__ */ jsxs7(View5, { style: { flex: 1 }, children: [
|
|
1903
|
+
/* @__PURE__ */ jsxs7(Text7, { style: [styles7.counterValue, { color: theme.text }], children: [
|
|
1738
1904
|
today,
|
|
1739
|
-
unit ? /* @__PURE__ */
|
|
1905
|
+
unit ? /* @__PURE__ */ jsx9(Text7, { style: { fontSize: 14, color: theme.textMuted }, children: ` ${unit}` }) : null
|
|
1740
1906
|
] }),
|
|
1741
|
-
/* @__PURE__ */
|
|
1907
|
+
/* @__PURE__ */ jsx9(Text7, { style: { color: theme.textMuted, fontSize: 12 }, children: "today" })
|
|
1742
1908
|
] }),
|
|
1743
|
-
/* @__PURE__ */
|
|
1744
|
-
|
|
1909
|
+
/* @__PURE__ */ jsx9(
|
|
1910
|
+
Pressable6,
|
|
1745
1911
|
{
|
|
1746
1912
|
onPress: () => store.add([{ metric, ts: Date.now(), value: increment, text: null }]),
|
|
1747
1913
|
accessibilityRole: "button",
|
|
1748
1914
|
accessibilityLabel: `Add ${increment}`,
|
|
1749
|
-
style: ({ pressed }) => [
|
|
1750
|
-
children: /* @__PURE__ */
|
|
1915
|
+
style: ({ pressed }) => [styles7.counterBtn, { backgroundColor: theme.accent, opacity: pressed ? 0.8 : 1 }],
|
|
1916
|
+
children: /* @__PURE__ */ jsxs7(Text7, { style: styles7.counterBtnText, children: [
|
|
1751
1917
|
"+",
|
|
1752
1918
|
increment
|
|
1753
1919
|
] })
|
|
@@ -1755,7 +1921,13 @@ function CounterInput({ panel }) {
|
|
|
1755
1921
|
)
|
|
1756
1922
|
] });
|
|
1757
1923
|
}
|
|
1758
|
-
var
|
|
1924
|
+
var styles7 = StyleSheet7.create({
|
|
1925
|
+
fill: { flex: 1 },
|
|
1926
|
+
dictated: { flex: 1, gap: 4 },
|
|
1927
|
+
selectWrap: { gap: 4 },
|
|
1928
|
+
lineRow: { flexDirection: "row", alignItems: "center", gap: 8 },
|
|
1929
|
+
textAreaWithMic: { paddingRight: 44 },
|
|
1930
|
+
textAreaMic: { position: "absolute", top: 8, right: 8 },
|
|
1759
1931
|
numberRow: { flex: 1, flexDirection: "row", alignItems: "center", gap: 8 },
|
|
1760
1932
|
numberField: { flex: 1, flexDirection: "row", alignItems: "center", borderWidth: 1, borderRadius: 8, paddingHorizontal: 10, height: 44 },
|
|
1761
1933
|
// Android gives TextInput default padding that eats into narrow fields.
|
|
@@ -1786,7 +1958,7 @@ var styles6 = StyleSheet6.create({
|
|
|
1786
1958
|
rating: { flex: 1, flexDirection: "row", alignItems: "center", justifyContent: "space-between", gap: 6 },
|
|
1787
1959
|
ratingDot: { flex: 1, maxWidth: 52, aspectRatio: 1, borderRadius: 26, borderWidth: 1, alignItems: "center", justifyContent: "center" },
|
|
1788
1960
|
suggest: { flex: 1, gap: 8 },
|
|
1789
|
-
textLine: { height: 44, borderWidth: 1, borderRadius: 8, paddingHorizontal: 10, paddingVertical: 0, fontSize: 16 },
|
|
1961
|
+
textLine: { flex: 1, height: 44, borderWidth: 1, borderRadius: 8, paddingHorizontal: 10, paddingVertical: 0, fontSize: 16 },
|
|
1790
1962
|
textArea: { flex: 1, borderWidth: 1, borderRadius: 8, padding: 10, fontSize: 15, textAlignVertical: "top" },
|
|
1791
1963
|
counter: { flex: 1, flexDirection: "row", alignItems: "center", gap: 12 },
|
|
1792
1964
|
counterValue: { fontSize: 28, fontWeight: "600", fontVariant: ["tabular-nums"] },
|
|
@@ -1795,7 +1967,7 @@ var styles6 = StyleSheet6.create({
|
|
|
1795
1967
|
});
|
|
1796
1968
|
|
|
1797
1969
|
// src/ui/inputs/InputGroup.tsx
|
|
1798
|
-
import { jsx as
|
|
1970
|
+
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1799
1971
|
function titleText(v) {
|
|
1800
1972
|
if (v == null || v === "") return void 0;
|
|
1801
1973
|
if (Array.isArray(v)) return v.length ? v.join(", ") : void 0;
|
|
@@ -1824,11 +1996,11 @@ function InputGroupBody({ panel }) {
|
|
|
1824
1996
|
const theme = useDashTheme();
|
|
1825
1997
|
const form = useInputForm();
|
|
1826
1998
|
const group = form.group?.(panel);
|
|
1827
|
-
const [collapsed, setCollapsed] =
|
|
1828
|
-
const [drag, setDrag] =
|
|
1829
|
-
const [heights, setHeights] =
|
|
1830
|
-
const dragging =
|
|
1831
|
-
const [wasEdited, setWasEdited] =
|
|
1999
|
+
const [collapsed, setCollapsed] = useState7(/* @__PURE__ */ new Set());
|
|
2000
|
+
const [drag, setDrag] = useState7(null);
|
|
2001
|
+
const [heights, setHeights] = useState7({});
|
|
2002
|
+
const dragging = useRef3(null);
|
|
2003
|
+
const [wasEdited, setWasEdited] = useState7(group?.edited);
|
|
1832
2004
|
if (group && group.edited !== wasEdited) {
|
|
1833
2005
|
setWasEdited(group.edited);
|
|
1834
2006
|
if (!group.edited) setCollapsed(/* @__PURE__ */ new Set());
|
|
@@ -1869,12 +2041,12 @@ function InputGroupBody({ panel }) {
|
|
|
1869
2041
|
if (to <= i && i < drag.from) return room;
|
|
1870
2042
|
return 0;
|
|
1871
2043
|
};
|
|
1872
|
-
return /* @__PURE__ */
|
|
2044
|
+
return /* @__PURE__ */ jsxs8(ScrollView4, { style: styles8.fill, contentContainerStyle: styles8.list, nestedScrollEnabled: true, keyboardShouldPersistTaps: "handled", scrollEnabled: !drag, children: [
|
|
1873
2045
|
group.items.map((item, i) => {
|
|
1874
2046
|
const named = panel.options.titleFrom ? titleText(item.values[panel.options.titleFrom]) : void 0;
|
|
1875
2047
|
const title = named ?? `${label} ${i + 1}`;
|
|
1876
2048
|
const troubled = groupFields(panel).some((f) => group.fieldProblem(i, f.options.metric));
|
|
1877
|
-
return /* @__PURE__ */
|
|
2049
|
+
return /* @__PURE__ */ jsx10(
|
|
1878
2050
|
ItemCard,
|
|
1879
2051
|
{
|
|
1880
2052
|
panel,
|
|
@@ -1905,16 +2077,16 @@ function InputGroupBody({ panel }) {
|
|
|
1905
2077
|
item.key
|
|
1906
2078
|
);
|
|
1907
2079
|
}),
|
|
1908
|
-
group.canAdd && /* @__PURE__ */
|
|
1909
|
-
|
|
2080
|
+
group.canAdd && /* @__PURE__ */ jsx10(
|
|
2081
|
+
Pressable7,
|
|
1910
2082
|
{
|
|
1911
2083
|
onPress: () => {
|
|
1912
2084
|
collapseFilled();
|
|
1913
2085
|
group.add();
|
|
1914
2086
|
},
|
|
1915
2087
|
accessibilityRole: "button",
|
|
1916
|
-
style: ({ pressed }) => [
|
|
1917
|
-
children: /* @__PURE__ */
|
|
2088
|
+
style: ({ pressed }) => [styles8.add, { borderColor: theme.accent, opacity: pressed ? 0.7 : 1 }],
|
|
2089
|
+
children: /* @__PURE__ */ jsxs8(Text8, { style: { color: theme.accent, fontWeight: "600" }, children: [
|
|
1918
2090
|
"+ ",
|
|
1919
2091
|
panel.options.addLabel || `Add ${label.toLowerCase()}`
|
|
1920
2092
|
] })
|
|
@@ -1936,59 +2108,59 @@ function ItemCard({ panel, group, form, index, title, last, collapsed, onToggle,
|
|
|
1936
2108
|
}),
|
|
1937
2109
|
[form, group, index, item]
|
|
1938
2110
|
);
|
|
1939
|
-
const button = (text, onPress, a11y, disabled = false) => /* @__PURE__ */
|
|
1940
|
-
|
|
2111
|
+
const button = (text, onPress, a11y, disabled = false) => /* @__PURE__ */ jsx10(
|
|
2112
|
+
Pressable7,
|
|
1941
2113
|
{
|
|
1942
2114
|
onPress,
|
|
1943
2115
|
disabled,
|
|
1944
2116
|
accessibilityRole: "button",
|
|
1945
2117
|
accessibilityLabel: a11y,
|
|
1946
2118
|
hitSlop: 6,
|
|
1947
|
-
style: ({ pressed }) => [
|
|
1948
|
-
children: /* @__PURE__ */
|
|
2119
|
+
style: ({ pressed }) => [styles8.iconBtn, { opacity: disabled ? 0.3 : pressed ? 0.6 : 1 }],
|
|
2120
|
+
children: /* @__PURE__ */ jsx10(Text8, { style: { color: theme.textSecondary, fontSize: 15 }, children: text })
|
|
1949
2121
|
}
|
|
1950
2122
|
);
|
|
1951
2123
|
const summary = collapsed ? fields.filter((f) => f.options.metric !== panel.options.titleFrom).map((f) => summaryText(f, item.values[f.options.metric])).filter(Boolean).join(" \xB7 ") : "";
|
|
1952
|
-
return /* @__PURE__ */
|
|
2124
|
+
return /* @__PURE__ */ jsxs8(
|
|
1953
2125
|
View6,
|
|
1954
2126
|
{
|
|
1955
2127
|
onLayout: (e) => onLayout(e.nativeEvent.layout.height),
|
|
1956
2128
|
style: [
|
|
1957
|
-
|
|
2129
|
+
styles8.item,
|
|
1958
2130
|
{ borderColor: lifted ? theme.accent : theme.border, backgroundColor: theme.surface },
|
|
1959
2131
|
!!dragOffset && { transform: [{ translateY: dragOffset }] },
|
|
1960
2132
|
lifted && { zIndex: 1, opacity: 0.95 }
|
|
1961
2133
|
],
|
|
1962
2134
|
children: [
|
|
1963
|
-
/* @__PURE__ */
|
|
1964
|
-
/* @__PURE__ */
|
|
1965
|
-
/* @__PURE__ */
|
|
1966
|
-
/* @__PURE__ */
|
|
2135
|
+
/* @__PURE__ */ jsxs8(View6, { style: styles8.itemHeader, children: [
|
|
2136
|
+
/* @__PURE__ */ jsx10(View6, { ...handle, style: styles8.handle, accessibilityLabel: `Drag ${title} to reorder`, children: /* @__PURE__ */ jsx10(Text8, { style: { color: theme.textMuted, fontSize: 16 }, children: "\u2261" }) }),
|
|
2137
|
+
/* @__PURE__ */ jsxs8(Pressable7, { onPress: onToggle, style: styles8.titleArea, accessibilityRole: "button", accessibilityLabel: `${collapsed ? "Expand" : "Collapse"} ${title}`, accessibilityState: { expanded: !collapsed }, children: [
|
|
2138
|
+
/* @__PURE__ */ jsxs8(Text8, { style: [styles8.itemTitle, { color: theme.text }], numberOfLines: 1, children: [
|
|
1967
2139
|
collapsed ? "\u25B8 " : "\u25BE ",
|
|
1968
2140
|
title
|
|
1969
2141
|
] }),
|
|
1970
|
-
!!summary && /* @__PURE__ */
|
|
2142
|
+
!!summary && /* @__PURE__ */ jsx10(Text8, { style: [styles8.summary, { color: theme.textSecondary }], numberOfLines: 1, children: summary })
|
|
1971
2143
|
] }),
|
|
1972
2144
|
button("\u2191", () => group.move(index, -1), `Move ${title} up`, index === 0),
|
|
1973
2145
|
button("\u2193", () => group.move(index, 1), `Move ${title} down`, last),
|
|
1974
2146
|
button("\u29C9", onDuplicate, `Duplicate ${title}`, !group.canAdd),
|
|
1975
2147
|
button("\u2715", () => group.remove(index), `Remove ${title}`)
|
|
1976
2148
|
] }),
|
|
1977
|
-
!collapsed && /* @__PURE__ */
|
|
2149
|
+
!collapsed && /* @__PURE__ */ jsx10(InputFormContext.Provider, { value: scoped, children: /* @__PURE__ */ jsx10(View6, { style: styles8.fields, children: fields.map((f) => {
|
|
1978
2150
|
const problem = scoped.problem?.(f.options.metric);
|
|
1979
|
-
return /* @__PURE__ */
|
|
1980
|
-
/* @__PURE__ */
|
|
1981
|
-
!!f.title && /* @__PURE__ */
|
|
1982
|
-
!!problem && /* @__PURE__ */
|
|
2151
|
+
return /* @__PURE__ */ jsxs8(View6, { style: [styles8.field, { width: `${Math.min(24, Math.max(1, f.gridPos.w)) / 24 * 100}%` }], children: [
|
|
2152
|
+
/* @__PURE__ */ jsxs8(View6, { style: styles8.fieldHeader, children: [
|
|
2153
|
+
!!f.title && /* @__PURE__ */ jsx10(Text8, { style: [styles8.fieldTitle, { color: theme.textSecondary }], numberOfLines: 1, children: f.title }),
|
|
2154
|
+
!!problem && /* @__PURE__ */ jsx10(Text8, { style: [styles8.problem, { color: theme.danger }], numberOfLines: 1, accessibilityRole: "alert", children: problem })
|
|
1983
2155
|
] }),
|
|
1984
|
-
/* @__PURE__ */
|
|
2156
|
+
/* @__PURE__ */ jsx10(View6, { style: styles8.fieldBody, children: /* @__PURE__ */ jsx10(InputPanelBody, { panel: f }) })
|
|
1985
2157
|
] }, f.options.metric);
|
|
1986
2158
|
}) }) })
|
|
1987
2159
|
]
|
|
1988
2160
|
}
|
|
1989
2161
|
);
|
|
1990
2162
|
}
|
|
1991
|
-
var
|
|
2163
|
+
var styles8 = StyleSheet8.create({
|
|
1992
2164
|
fill: { flex: 1 },
|
|
1993
2165
|
list: { gap: 8, paddingBottom: 4 },
|
|
1994
2166
|
item: { borderWidth: 1, borderRadius: 8, padding: 8, gap: 6 },
|
|
@@ -2010,20 +2182,20 @@ var styles7 = StyleSheet7.create({
|
|
|
2010
2182
|
|
|
2011
2183
|
// src/ui/panels/GaugePanels.tsx
|
|
2012
2184
|
import { useMemo as useMemo4 } from "react";
|
|
2013
|
-
import { Pressable as
|
|
2014
|
-
import
|
|
2185
|
+
import { Pressable as Pressable9, StyleSheet as StyleSheet10, Text as Text10, View as View8 } from "react-native";
|
|
2186
|
+
import Svg6, { Path as Path6 } from "react-native-svg";
|
|
2015
2187
|
|
|
2016
2188
|
// src/ui/panels/StatPanel.tsx
|
|
2017
2189
|
import { useMemo as useMemo3 } from "react";
|
|
2018
|
-
import { Pressable as
|
|
2019
|
-
import
|
|
2020
|
-
import { jsx as
|
|
2190
|
+
import { Pressable as Pressable8, StyleSheet as StyleSheet9, Text as Text9, View as View7 } from "react-native";
|
|
2191
|
+
import Svg5, { Path as Path5 } from "react-native-svg";
|
|
2192
|
+
import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2021
2193
|
function StatPanel({ panel, frames }) {
|
|
2022
2194
|
const theme = useDashTheme();
|
|
2023
2195
|
const values = useMemo3(() => reducedValues(panel, frames, theme.scheme), [panel, frames, theme.scheme]);
|
|
2024
|
-
if (!values.length) return /* @__PURE__ */
|
|
2196
|
+
if (!values.length) return /* @__PURE__ */ jsx11(NoData, {});
|
|
2025
2197
|
const horizontal = panel.options?.orientation === "horizontal";
|
|
2026
|
-
return /* @__PURE__ */
|
|
2198
|
+
return /* @__PURE__ */ jsx11(View7, { style: [styles9.grid, { flexDirection: horizontal ? "column" : "row" }], children: values.map((v) => /* @__PURE__ */ jsx11(StatTile, { v, showName: values.length > 1, panel }, v.key)) });
|
|
2027
2199
|
}
|
|
2028
2200
|
function StatTile({ v, showName, panel }) {
|
|
2029
2201
|
const theme = useDashTheme();
|
|
@@ -2033,25 +2205,25 @@ function StatTile({ v, showName, panel }) {
|
|
|
2033
2205
|
const fontSize = Math.max(18, Math.min(56, size.height * (graph ? 0.4 : 0.5), size.width / 4.5));
|
|
2034
2206
|
const { resolve, openLinks } = usePanelLinks(panel);
|
|
2035
2207
|
const hasLinks = !!v.config.links?.length;
|
|
2036
|
-
return /* @__PURE__ */
|
|
2037
|
-
|
|
2208
|
+
return /* @__PURE__ */ jsxs9(
|
|
2209
|
+
Pressable8,
|
|
2038
2210
|
{
|
|
2039
2211
|
onLayout,
|
|
2040
2212
|
disabled: !hasLinks,
|
|
2041
2213
|
onPress: () => openLinks(valueLinks(panel, v, resolve), v.name),
|
|
2042
2214
|
accessibilityRole: hasLinks ? "link" : void 0,
|
|
2043
2215
|
style: ({ pressed }) => [
|
|
2044
|
-
|
|
2216
|
+
styles9.tile,
|
|
2045
2217
|
// With a sparkline, the number sits in the top half so the line runs beneath it.
|
|
2046
2218
|
graph && { justifyContent: "flex-start", paddingTop: 4 },
|
|
2047
2219
|
colorMode === "background" && { backgroundColor: withAlpha(v.stateColor, 0.14) },
|
|
2048
2220
|
pressed && { opacity: 0.7 }
|
|
2049
2221
|
],
|
|
2050
2222
|
children: [
|
|
2051
|
-
colorMode !== "none" && /* @__PURE__ */
|
|
2052
|
-
graph && size.width > 0 && /* @__PURE__ */
|
|
2053
|
-
showName && /* @__PURE__ */
|
|
2054
|
-
/* @__PURE__ */
|
|
2223
|
+
colorMode !== "none" && /* @__PURE__ */ jsx11(View7, { style: [styles9.accent, { backgroundColor: v.stateColor }] }),
|
|
2224
|
+
graph && size.width > 0 && /* @__PURE__ */ jsx11(Sparkline, { values: v.sparkline, width: size.width, height: size.height * 0.4, color: v.stateColor }),
|
|
2225
|
+
showName && /* @__PURE__ */ jsx11(Text9, { style: [styles9.name, { color: theme.textSecondary }], numberOfLines: 1, children: v.name }),
|
|
2226
|
+
/* @__PURE__ */ jsx11(Text9, { style: [styles9.value, { color: theme.text, fontSize }], numberOfLines: 1, adjustsFontSizeToFit: true, children: v.text })
|
|
2055
2227
|
]
|
|
2056
2228
|
}
|
|
2057
2229
|
);
|
|
@@ -2066,16 +2238,16 @@ function Sparkline({ values, width, height, color }) {
|
|
|
2066
2238
|
values.forEach((v, i) => {
|
|
2067
2239
|
if (v != null) line += `${line ? "L" : "M"}${x(i)},${y(v)}`;
|
|
2068
2240
|
});
|
|
2069
|
-
return /* @__PURE__ */
|
|
2070
|
-
/* @__PURE__ */
|
|
2071
|
-
/* @__PURE__ */
|
|
2241
|
+
return /* @__PURE__ */ jsxs9(Svg5, { width, height, style: styles9.spark, children: [
|
|
2242
|
+
/* @__PURE__ */ jsx11(Path5, { d: `${line}L${width},${height}L0,${height}Z`, fill: color, opacity: 0.1 }),
|
|
2243
|
+
/* @__PURE__ */ jsx11(Path5, { d: line, stroke: color, strokeWidth: 2, fill: "none", strokeLinejoin: "round" })
|
|
2072
2244
|
] });
|
|
2073
2245
|
}
|
|
2074
2246
|
function withAlpha(hex, alpha) {
|
|
2075
2247
|
if (!/^#[0-9a-f]{6}$/i.test(hex)) return hex;
|
|
2076
2248
|
return `${hex}${Math.round(alpha * 255).toString(16).padStart(2, "0")}`;
|
|
2077
2249
|
}
|
|
2078
|
-
var
|
|
2250
|
+
var styles9 = StyleSheet9.create({
|
|
2079
2251
|
grid: { flex: 1, gap: 8 },
|
|
2080
2252
|
tile: { flex: 1, justifyContent: "center", paddingLeft: 12, borderRadius: 6, overflow: "hidden" },
|
|
2081
2253
|
accent: { position: "absolute", left: 0, top: 6, bottom: 6, width: 3, borderRadius: 2 },
|
|
@@ -2085,13 +2257,13 @@ var styles8 = StyleSheet8.create({
|
|
|
2085
2257
|
});
|
|
2086
2258
|
|
|
2087
2259
|
// src/ui/panels/GaugePanels.tsx
|
|
2088
|
-
import { jsx as
|
|
2260
|
+
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2089
2261
|
var SWEEP = 240;
|
|
2090
2262
|
function GaugePanel({ panel, frames }) {
|
|
2091
2263
|
const theme = useDashTheme();
|
|
2092
2264
|
const values = useMemo4(() => reducedValues(panel, frames, theme.scheme), [panel, frames, theme.scheme]);
|
|
2093
|
-
if (!values.length) return /* @__PURE__ */
|
|
2094
|
-
return /* @__PURE__ */
|
|
2265
|
+
if (!values.length) return /* @__PURE__ */ jsx12(NoData, {});
|
|
2266
|
+
return /* @__PURE__ */ jsx12(View8, { style: styles10.row, children: values.map((v) => /* @__PURE__ */ jsx12(Gauge, { v, showName: values.length > 1, panel }, v.key)) });
|
|
2095
2267
|
}
|
|
2096
2268
|
function Gauge({ v, showName, panel }) {
|
|
2097
2269
|
const theme = useDashTheme();
|
|
@@ -2106,22 +2278,22 @@ function Gauge({ v, showName, panel }) {
|
|
|
2106
2278
|
const r = d / 2 - stroke;
|
|
2107
2279
|
const cx = size.width / 2;
|
|
2108
2280
|
const cy = size.height / 2 + d * 0.08;
|
|
2109
|
-
return /* @__PURE__ */
|
|
2110
|
-
|
|
2281
|
+
return /* @__PURE__ */ jsxs10(
|
|
2282
|
+
Pressable9,
|
|
2111
2283
|
{
|
|
2112
|
-
style: ({ pressed }) => [
|
|
2284
|
+
style: ({ pressed }) => [styles10.fill, pressed && { opacity: 0.7 }],
|
|
2113
2285
|
onLayout,
|
|
2114
2286
|
disabled: !hasLinks,
|
|
2115
2287
|
onPress: () => openLinks(valueLinks(panel, v, resolve), v.name),
|
|
2116
2288
|
accessibilityRole: hasLinks ? "link" : void 0,
|
|
2117
2289
|
children: [
|
|
2118
|
-
size.width > 0 && r > 0 && /* @__PURE__ */
|
|
2119
|
-
/* @__PURE__ */
|
|
2120
|
-
frac > 0 && /* @__PURE__ */
|
|
2290
|
+
size.width > 0 && r > 0 && /* @__PURE__ */ jsxs10(Svg6, { width: size.width, height: size.height, children: [
|
|
2291
|
+
/* @__PURE__ */ jsx12(Path6, { d: arc(cx, cy, r, 0, 1), stroke: withAlpha(v.stateColor, 0.18), strokeWidth: stroke, fill: "none", strokeLinecap: "round" }),
|
|
2292
|
+
frac > 0 && /* @__PURE__ */ jsx12(Path6, { d: arc(cx, cy, r, 0, frac), stroke: v.stateColor, strokeWidth: stroke, fill: "none", strokeLinecap: "round" })
|
|
2121
2293
|
] }),
|
|
2122
|
-
/* @__PURE__ */
|
|
2123
|
-
/* @__PURE__ */
|
|
2124
|
-
showName && /* @__PURE__ */
|
|
2294
|
+
/* @__PURE__ */ jsxs10(View8, { style: [StyleSheet10.absoluteFill, styles10.center, { top: d * 0.12 }], pointerEvents: "none", children: [
|
|
2295
|
+
/* @__PURE__ */ jsx12(Text10, { style: [styles10.value, { color: theme.text, fontSize: Math.max(14, d * 0.18) }], numberOfLines: 1, adjustsFontSizeToFit: true, children: v.text }),
|
|
2296
|
+
showName && /* @__PURE__ */ jsx12(Text10, { style: [styles10.name, { color: theme.textSecondary }], numberOfLines: 1, children: v.name })
|
|
2125
2297
|
] })
|
|
2126
2298
|
]
|
|
2127
2299
|
}
|
|
@@ -2139,33 +2311,33 @@ function BarGaugePanel({ panel, frames }) {
|
|
|
2139
2311
|
const theme = useDashTheme();
|
|
2140
2312
|
const values = useMemo4(() => reducedValues(panel, frames, theme.scheme), [panel, frames, theme.scheme]);
|
|
2141
2313
|
const { resolve, openLinks } = usePanelLinks(panel);
|
|
2142
|
-
if (!values.length) return /* @__PURE__ */
|
|
2143
|
-
return /* @__PURE__ */
|
|
2314
|
+
if (!values.length) return /* @__PURE__ */ jsx12(NoData, {});
|
|
2315
|
+
return /* @__PURE__ */ jsx12(View8, { style: styles10.bars, children: values.map((v) => {
|
|
2144
2316
|
const min = v.config.min ?? 0;
|
|
2145
2317
|
const max = v.config.max ?? Math.max(...values.map((o) => o.value ?? 0), 1);
|
|
2146
2318
|
const frac = v.value == null ? 0 : Math.min(1, Math.max(0, (v.value - min) / (max - min || 1)));
|
|
2147
2319
|
const color = v.config.thresholds || v.mapped?.color ? v.stateColor : resolveColor(v.config.color?.fixedColor, v.color);
|
|
2148
2320
|
const hasLinks = !!v.config.links?.length;
|
|
2149
|
-
return /* @__PURE__ */
|
|
2150
|
-
|
|
2321
|
+
return /* @__PURE__ */ jsxs10(
|
|
2322
|
+
Pressable9,
|
|
2151
2323
|
{
|
|
2152
|
-
style: ({ pressed }) => [
|
|
2324
|
+
style: ({ pressed }) => [styles10.barRow, pressed && { opacity: 0.7 }],
|
|
2153
2325
|
disabled: !hasLinks,
|
|
2154
2326
|
onPress: () => openLinks(valueLinks(panel, v, resolve), v.name),
|
|
2155
2327
|
accessibilityRole: hasLinks ? "link" : void 0,
|
|
2156
2328
|
children: [
|
|
2157
|
-
/* @__PURE__ */
|
|
2158
|
-
/* @__PURE__ */
|
|
2159
|
-
/* @__PURE__ */
|
|
2329
|
+
/* @__PURE__ */ jsxs10(View8, { style: styles10.barLabels, children: [
|
|
2330
|
+
/* @__PURE__ */ jsx12(Text10, { style: [styles10.name, { color: theme.textSecondary }], numberOfLines: 1, children: v.name }),
|
|
2331
|
+
/* @__PURE__ */ jsx12(Text10, { style: [styles10.barValue, { color: theme.text }], children: v.text })
|
|
2160
2332
|
] }),
|
|
2161
|
-
/* @__PURE__ */
|
|
2333
|
+
/* @__PURE__ */ jsx12(View8, { style: [styles10.track, { backgroundColor: withAlpha(color, 0.18) }], children: /* @__PURE__ */ jsx12(View8, { style: [styles10.meter, { width: `${frac * 100}%`, backgroundColor: color }] }) })
|
|
2162
2334
|
]
|
|
2163
2335
|
},
|
|
2164
2336
|
v.key
|
|
2165
2337
|
);
|
|
2166
2338
|
}) });
|
|
2167
2339
|
}
|
|
2168
|
-
var
|
|
2340
|
+
var styles10 = StyleSheet10.create({
|
|
2169
2341
|
fill: { flex: 1 },
|
|
2170
2342
|
row: { flex: 1, flexDirection: "row", gap: 8 },
|
|
2171
2343
|
center: { alignItems: "center", justifyContent: "center" },
|
|
@@ -2180,9 +2352,9 @@ var styles9 = StyleSheet9.create({
|
|
|
2180
2352
|
});
|
|
2181
2353
|
|
|
2182
2354
|
// src/ui/panels/GeomapPanel.tsx
|
|
2183
|
-
import { useEffect as
|
|
2184
|
-
import { Image, PixelRatio, Pressable as
|
|
2185
|
-
import
|
|
2355
|
+
import { useEffect as useEffect4, useMemo as useMemo5, useRef as useRef4, useState as useState8 } from "react";
|
|
2356
|
+
import { Image, PixelRatio, Pressable as Pressable10, StyleSheet as StyleSheet11, Text as Text11, View as View9 } from "react-native";
|
|
2357
|
+
import Svg7, { Path as Path7, Text as SvgText2 } from "react-native-svg";
|
|
2186
2358
|
|
|
2187
2359
|
// src/ui/geomap.ts
|
|
2188
2360
|
var TILE = 256;
|
|
@@ -2598,7 +2770,7 @@ function heatmapCells(px, py, weights, radius, blur, width, height, cell = 4) {
|
|
|
2598
2770
|
}
|
|
2599
2771
|
|
|
2600
2772
|
// src/ui/panels/GeomapPanel.tsx
|
|
2601
|
-
import { jsx as
|
|
2773
|
+
import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2602
2774
|
var HIT_PX = 24;
|
|
2603
2775
|
var DRAG_PX = 6;
|
|
2604
2776
|
var MAX_LABELS = 300;
|
|
@@ -2609,8 +2781,8 @@ function GeomapPanel({ panel, frames }) {
|
|
|
2609
2781
|
const { gazetteers, error } = useGazetteers(panel, frames);
|
|
2610
2782
|
const layers = useMemo5(() => geomapLayers(panel, frames, theme.scheme, retina, gazetteers), [panel, frames, theme.scheme, retina, gazetteers]);
|
|
2611
2783
|
const home = useMemo5(() => initialView(panel, layers, size.width, size.height), [panel, layers, size.width, size.height]);
|
|
2612
|
-
const [moved, setMoved] =
|
|
2613
|
-
const [picked, setPicked] =
|
|
2784
|
+
const [moved, setMoved] = useState8(null);
|
|
2785
|
+
const [picked, setPicked] = useState8(null);
|
|
2614
2786
|
const links = usePanelLinks(panel);
|
|
2615
2787
|
const view = moved ?? home;
|
|
2616
2788
|
const [minZoom, maxZoom] = zoomLimits(panel);
|
|
@@ -2651,7 +2823,7 @@ function GeomapPanel({ panel, frames }) {
|
|
|
2651
2823
|
}
|
|
2652
2824
|
return best;
|
|
2653
2825
|
};
|
|
2654
|
-
const gesture =
|
|
2826
|
+
const gesture = useRef4(null);
|
|
2655
2827
|
const responder = {
|
|
2656
2828
|
onStartShouldSetResponder: () => true,
|
|
2657
2829
|
// Keep the gesture while panning instead of handing it to the dashboard's scroll view.
|
|
@@ -2693,15 +2865,15 @@ function GeomapPanel({ panel, frames }) {
|
|
|
2693
2865
|
const attribution = [...new Set(layers.flatMap((l) => l.type === "tiles" && l.source.attribution ? [l.source.attribution] : []))].join(" ");
|
|
2694
2866
|
const legend = layers.flatMap((l) => l.type === "markers" || l.type === "route" ? l.legend : []);
|
|
2695
2867
|
const ready = size.width > 0 && size.height > 0;
|
|
2696
|
-
return /* @__PURE__ */
|
|
2697
|
-
/* @__PURE__ */
|
|
2868
|
+
return /* @__PURE__ */ jsxs11(View9, { style: styles11.fill, children: [
|
|
2869
|
+
/* @__PURE__ */ jsxs11(View9, { style: [styles11.fill, styles11.map, { backgroundColor: theme.grid }], onLayout, ...responder, children: [
|
|
2698
2870
|
ready && // Nothing inside takes touches, so locationX/Y are always relative to the map.
|
|
2699
|
-
/* @__PURE__ */
|
|
2871
|
+
/* @__PURE__ */ jsxs11(View9, { pointerEvents: "none", style: StyleSheet11.absoluteFill, children: [
|
|
2700
2872
|
layers.map(
|
|
2701
|
-
(l) => l.type === "tiles" ? /* @__PURE__ */
|
|
2873
|
+
(l) => l.type === "tiles" ? /* @__PURE__ */ jsx13(Tiles, { layer: l, view, width: size.width, height: size.height }, l.key) : /* @__PURE__ */ jsx13(DataLayerSvg, { layer: l, screen: screen.get(l.key) ?? [], width: size.width, height: size.height, textColor: theme.text }, l.key)
|
|
2702
2874
|
),
|
|
2703
|
-
shown && /* @__PURE__ */
|
|
2704
|
-
|
|
2875
|
+
shown && /* @__PURE__ */ jsx13(Svg7, { width: size.width, height: size.height, style: StyleSheet11.absoluteFill, children: /* @__PURE__ */ jsx13(
|
|
2876
|
+
Path7,
|
|
2705
2877
|
{
|
|
2706
2878
|
d: symbolPath("circle", shown.px, shown.py, Math.max(shown.layer.type === "markers" ? shown.radius + 2 : 5, 5)),
|
|
2707
2879
|
fill: "none",
|
|
@@ -2710,7 +2882,7 @@ function GeomapPanel({ panel, frames }) {
|
|
|
2710
2882
|
}
|
|
2711
2883
|
) })
|
|
2712
2884
|
] }),
|
|
2713
|
-
shown && /* @__PURE__ */
|
|
2885
|
+
shown && /* @__PURE__ */ jsx13(
|
|
2714
2886
|
RowTooltip,
|
|
2715
2887
|
{
|
|
2716
2888
|
at: { x: shown.px, y: shown.py },
|
|
@@ -2722,23 +2894,23 @@ function GeomapPanel({ panel, frames }) {
|
|
|
2722
2894
|
onOpenLink: (l) => links.openLinks([l])
|
|
2723
2895
|
}
|
|
2724
2896
|
),
|
|
2725
|
-
controls.showZoom !== false && /* @__PURE__ */
|
|
2726
|
-
/* @__PURE__ */
|
|
2727
|
-
/* @__PURE__ */
|
|
2728
|
-
moved && /* @__PURE__ */
|
|
2897
|
+
controls.showZoom !== false && /* @__PURE__ */ jsxs11(View9, { style: styles11.zoom, children: [
|
|
2898
|
+
/* @__PURE__ */ jsx13(MapButton, { label: "+", onPress: () => zoomTo(view, Math.round(view.zoom) + 1) }),
|
|
2899
|
+
/* @__PURE__ */ jsx13(MapButton, { label: "\u2212", onPress: () => zoomTo(view, Math.round(view.zoom) - 1) }),
|
|
2900
|
+
moved && /* @__PURE__ */ jsx13(MapButton, { label: "\u27F2", onPress: () => setMoved(null) })
|
|
2729
2901
|
] }),
|
|
2730
|
-
error ? /* @__PURE__ */
|
|
2731
|
-
controls.showAttribution !== false && attribution ? /* @__PURE__ */
|
|
2902
|
+
error ? /* @__PURE__ */ jsx13(Text11, { pointerEvents: "none", style: [styles11.error, { color: theme.danger, backgroundColor: theme.surface }], numberOfLines: 2, children: error }) : null,
|
|
2903
|
+
controls.showAttribution !== false && attribution ? /* @__PURE__ */ jsx13(Text11, { pointerEvents: "none", style: [styles11.attribution, { color: theme.textSecondary, backgroundColor: theme.surface }], numberOfLines: 1, children: attribution }) : null
|
|
2732
2904
|
] }),
|
|
2733
|
-
legend.length > 0 && /* @__PURE__ */
|
|
2905
|
+
legend.length > 0 && /* @__PURE__ */ jsx13(Legend, { items: legend })
|
|
2734
2906
|
] });
|
|
2735
2907
|
}
|
|
2736
2908
|
var NONE = {};
|
|
2737
2909
|
function useGazetteers(panel, frames) {
|
|
2738
2910
|
const { resolve } = useDashboard();
|
|
2739
2911
|
const key = gazetteerPaths(panel, frames).join("\n");
|
|
2740
|
-
const [state, setState] =
|
|
2741
|
-
|
|
2912
|
+
const [state, setState] = useState8({ key: "", gazetteers: NONE });
|
|
2913
|
+
useEffect4(() => {
|
|
2742
2914
|
if (!key) return;
|
|
2743
2915
|
let live = true;
|
|
2744
2916
|
let ds;
|
|
@@ -2765,13 +2937,13 @@ function useGazetteers(panel, frames) {
|
|
|
2765
2937
|
}
|
|
2766
2938
|
function MapButton({ label, onPress }) {
|
|
2767
2939
|
const theme = useDashTheme();
|
|
2768
|
-
return /* @__PURE__ */
|
|
2940
|
+
return /* @__PURE__ */ jsx13(Pressable10, { onPress, hitSlop: 4, style: [styles11.button, { backgroundColor: theme.surface, borderColor: theme.border }], children: /* @__PURE__ */ jsx13(Text11, { style: [styles11.buttonText, { color: theme.text }], children: label }) });
|
|
2769
2941
|
}
|
|
2770
2942
|
function Tiles({ layer, view, width, height }) {
|
|
2771
2943
|
const tiles = visibleTiles(layer.source, view, width, height);
|
|
2772
|
-
return /* @__PURE__ */
|
|
2944
|
+
return /* @__PURE__ */ jsx13(View9, { style: [StyleSheet11.absoluteFill, { opacity: layer.opacity }], children: tiles.map((t) => (
|
|
2773
2945
|
// Half a pixel of overlap hides seams between scaled tiles.
|
|
2774
|
-
/* @__PURE__ */
|
|
2946
|
+
/* @__PURE__ */ jsx13(
|
|
2775
2947
|
Image,
|
|
2776
2948
|
{
|
|
2777
2949
|
source: { uri: t.url },
|
|
@@ -2788,12 +2960,12 @@ function DataLayerSvg({ layer, screen, width, height, textColor }) {
|
|
|
2788
2960
|
const px = screen.flatMap((s) => s.px);
|
|
2789
2961
|
const py = screen.flatMap((s) => s.py);
|
|
2790
2962
|
const weights = layer.points.flatMap((p) => p.sizes);
|
|
2791
|
-
return heatmapCells(px, py, weights, layer.radius, layer.blur, width, height).map((c) => /* @__PURE__ */
|
|
2963
|
+
return heatmapCells(px, py, weights, layer.radius, layer.blur, width, height).map((c) => /* @__PURE__ */ jsx13(Path7, { d: c.d, fill: c.color, fillOpacity: c.opacity }, c.color));
|
|
2792
2964
|
}
|
|
2793
2965
|
if (layer.type === "route") return routePaths(layer, screen);
|
|
2794
2966
|
return markerPaths(layer, screen, width, height, textColor);
|
|
2795
2967
|
}, [layer, screen, width, height, textColor]);
|
|
2796
|
-
return /* @__PURE__ */
|
|
2968
|
+
return /* @__PURE__ */ jsx13(Svg7, { width, height, style: [StyleSheet11.absoluteFill, { opacity: layer.opacity }], children: body });
|
|
2797
2969
|
}
|
|
2798
2970
|
function markerPaths(layer, screen, width, height, textColor) {
|
|
2799
2971
|
const byColor = /* @__PURE__ */ new Map();
|
|
@@ -2808,7 +2980,7 @@ function markerPaths(layer, screen, width, height, textColor) {
|
|
|
2808
2980
|
const label = p.labels?.[i];
|
|
2809
2981
|
if (label && labels.length < MAX_LABELS)
|
|
2810
2982
|
labels.push(
|
|
2811
|
-
/* @__PURE__ */
|
|
2983
|
+
/* @__PURE__ */ jsx13(
|
|
2812
2984
|
SvgText2,
|
|
2813
2985
|
{
|
|
2814
2986
|
x: px[i] + layer.labelOffset[0],
|
|
@@ -2825,7 +2997,7 @@ function markerPaths(layer, screen, width, height, textColor) {
|
|
|
2825
2997
|
});
|
|
2826
2998
|
const outline = layer.symbol === "cross" || layer.symbol === "x";
|
|
2827
2999
|
return [
|
|
2828
|
-
...[...byColor].map(([color, parts]) => /* @__PURE__ */
|
|
3000
|
+
...[...byColor].map(([color, parts]) => /* @__PURE__ */ jsx13(Path7, { d: parts.join(""), fill: outline ? "none" : color, fillOpacity: layer.fillOpacity, stroke: color, strokeWidth: outline ? 2 : 1 }, color)),
|
|
2829
3001
|
...labels
|
|
2830
3002
|
];
|
|
2831
3003
|
}
|
|
@@ -2838,7 +3010,7 @@ function routePaths(layer, screen) {
|
|
|
2838
3010
|
parts.push(`M${px[i]},${py[i]}L${px[i + 1]},${py[i + 1]}`);
|
|
2839
3011
|
}
|
|
2840
3012
|
});
|
|
2841
|
-
return [...byColor].map(([color, parts]) => /* @__PURE__ */
|
|
3013
|
+
return [...byColor].map(([color, parts]) => /* @__PURE__ */ jsx13(Path7, { d: parts.join(""), stroke: color, strokeWidth: layer.lineWidth, strokeLinecap: "round", fill: "none" }, color));
|
|
2842
3014
|
}
|
|
2843
3015
|
function resolvePicked(layers, screen, picked) {
|
|
2844
3016
|
const layer = layers.find((l) => l.key === picked.layer);
|
|
@@ -2856,7 +3028,7 @@ function resolvePicked(layers, screen, picked) {
|
|
|
2856
3028
|
py: s.py[picked.index]
|
|
2857
3029
|
};
|
|
2858
3030
|
}
|
|
2859
|
-
var
|
|
3031
|
+
var styles11 = StyleSheet11.create({
|
|
2860
3032
|
fill: { flex: 1 },
|
|
2861
3033
|
map: { overflow: "hidden", borderRadius: 4 },
|
|
2862
3034
|
zoom: { position: "absolute", top: 6, left: 6, gap: 4 },
|
|
@@ -2864,7 +3036,7 @@ var styles10 = StyleSheet10.create({
|
|
|
2864
3036
|
width: 28,
|
|
2865
3037
|
height: 28,
|
|
2866
3038
|
borderRadius: 4,
|
|
2867
|
-
borderWidth:
|
|
3039
|
+
borderWidth: StyleSheet11.hairlineWidth,
|
|
2868
3040
|
alignItems: "center",
|
|
2869
3041
|
justifyContent: "center"
|
|
2870
3042
|
},
|
|
@@ -2874,9 +3046,9 @@ var styles10 = StyleSheet10.create({
|
|
|
2874
3046
|
});
|
|
2875
3047
|
|
|
2876
3048
|
// src/ui/panels/OtherPanels.tsx
|
|
2877
|
-
import { useMemo as useMemo6, useState as
|
|
2878
|
-
import { Pressable as
|
|
2879
|
-
import
|
|
3049
|
+
import { useMemo as useMemo6, useState as useState9 } from "react";
|
|
3050
|
+
import { Pressable as Pressable11, ScrollView as ScrollView5, StyleSheet as StyleSheet12, Text as Text12, View as View10 } from "react-native";
|
|
3051
|
+
import Svg8, { Path as Path8 } from "react-native-svg";
|
|
2880
3052
|
|
|
2881
3053
|
// src/ui/table.ts
|
|
2882
3054
|
var DEFAULT_WIDTH = 120;
|
|
@@ -3014,7 +3186,7 @@ function sortedRows(columns, length, sort) {
|
|
|
3014
3186
|
var compareText = typeof Intl !== "undefined" && typeof Intl.Collator === "function" ? new Intl.Collator(void 0, { numeric: true, sensitivity: "base" }).compare : (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
3015
3187
|
|
|
3016
3188
|
// src/ui/panels/OtherPanels.tsx
|
|
3017
|
-
import { jsx as
|
|
3189
|
+
import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3018
3190
|
function PieChartPanel({ panel, frames }) {
|
|
3019
3191
|
const theme = useDashTheme();
|
|
3020
3192
|
const [size, onLayout] = useLayout();
|
|
@@ -3022,7 +3194,7 @@ function PieChartPanel({ panel, frames }) {
|
|
|
3022
3194
|
() => reducedValues(panel, frames, theme.scheme).filter((v) => (v.value ?? 0) > 0),
|
|
3023
3195
|
[panel, frames, theme.scheme]
|
|
3024
3196
|
);
|
|
3025
|
-
if (!values.length) return /* @__PURE__ */
|
|
3197
|
+
if (!values.length) return /* @__PURE__ */ jsx14(NoData, {});
|
|
3026
3198
|
const total = values.reduce((a, v) => a + (v.value ?? 0), 0);
|
|
3027
3199
|
const r = Math.min(size.width, size.height) / 2 - 2;
|
|
3028
3200
|
const inner = panel.options?.pieType === "pie" ? 0 : r * 0.62;
|
|
@@ -3036,9 +3208,9 @@ function PieChartPanel({ panel, frames }) {
|
|
|
3036
3208
|
slices.push({ key: v.key, d: donutSlice(cx, cy, r, inner, angle + gap / 2, angle + sweep - gap / 2), color: v.color });
|
|
3037
3209
|
angle += sweep;
|
|
3038
3210
|
}
|
|
3039
|
-
return /* @__PURE__ */
|
|
3040
|
-
/* @__PURE__ */
|
|
3041
|
-
/* @__PURE__ */
|
|
3211
|
+
return /* @__PURE__ */ jsxs12(View10, { style: styles12.fill, children: [
|
|
3212
|
+
/* @__PURE__ */ jsx14(View10, { style: styles12.fill, onLayout, children: r > 0 && /* @__PURE__ */ jsx14(Svg8, { width: size.width, height: size.height, children: slices.map((s) => /* @__PURE__ */ jsx14(Path8, { d: s.d, fill: s.color }, s.key)) }) }),
|
|
3213
|
+
/* @__PURE__ */ jsx14(
|
|
3042
3214
|
Legend,
|
|
3043
3215
|
{
|
|
3044
3216
|
items: values.map((v) => ({
|
|
@@ -3063,26 +3235,26 @@ function TablePanel({ panel, frames }) {
|
|
|
3063
3235
|
const { resolve, openLinks } = usePanelLinks(panel);
|
|
3064
3236
|
const frame = frames[0];
|
|
3065
3237
|
const columns = useMemo6(() => frame ? tableColumns(panel, frame, frames.length > 1) : [], [panel, frame, frames.length]);
|
|
3066
|
-
const [tapped, setSort] =
|
|
3238
|
+
const [tapped, setSort] = useState9();
|
|
3067
3239
|
const sort = tapped === void 0 ? initialSort(panel, columns) : tapped;
|
|
3068
3240
|
const order = useMemo6(() => sortedRows(columns, frame ? frameLength(frame) : 0, sort), [columns, frame, sort]);
|
|
3069
|
-
if (!frame || !frameLength(frame)) return /* @__PURE__ */
|
|
3241
|
+
if (!frame || !frameLength(frame)) return /* @__PURE__ */ jsx14(NoData, {});
|
|
3070
3242
|
const shown = order.slice(0, 500);
|
|
3071
3243
|
const rowColumn = columns.find((c) => c.applyToRow);
|
|
3072
3244
|
const footer = tableFooter(columns);
|
|
3073
|
-
return /* @__PURE__ */
|
|
3074
|
-
/* @__PURE__ */
|
|
3075
|
-
/* @__PURE__ */
|
|
3245
|
+
return /* @__PURE__ */ jsx14(ScrollView5, { horizontal: true, children: /* @__PURE__ */ jsxs12(View10, { style: styles12.fill, children: [
|
|
3246
|
+
/* @__PURE__ */ jsxs12(ScrollView5, { nestedScrollEnabled: true, style: styles12.fill, children: [
|
|
3247
|
+
/* @__PURE__ */ jsx14(View10, { style: [styles12.tr, { borderBottomColor: theme.border }], children: columns.map((c) => {
|
|
3076
3248
|
const active = sort?.key === c.key;
|
|
3077
|
-
return /* @__PURE__ */
|
|
3078
|
-
|
|
3249
|
+
return /* @__PURE__ */ jsx14(
|
|
3250
|
+
Pressable11,
|
|
3079
3251
|
{
|
|
3080
3252
|
onPress: () => setSort(nextSort(sort, c.key)),
|
|
3081
3253
|
accessibilityRole: "button",
|
|
3082
3254
|
accessibilityLabel: `Sort by ${c.name}`,
|
|
3083
3255
|
accessibilityState: { selected: active },
|
|
3084
3256
|
style: { width: c.width },
|
|
3085
|
-
children: /* @__PURE__ */
|
|
3257
|
+
children: /* @__PURE__ */ jsxs12(Text12, { style: [styles12.th, { color: active ? theme.text : theme.textSecondary, textAlign: c.align }], numberOfLines: 2, children: [
|
|
3086
3258
|
c.name,
|
|
3087
3259
|
active ? sort.desc ? " \u2193" : " \u2191" : ""
|
|
3088
3260
|
] })
|
|
@@ -3092,14 +3264,14 @@ function TablePanel({ panel, frames }) {
|
|
|
3092
3264
|
}) }),
|
|
3093
3265
|
shown.map((i) => {
|
|
3094
3266
|
const rowBg = rowColumn ? cellDisplay(rowColumn, rowColumn.field.values[i], theme.accent).background : void 0;
|
|
3095
|
-
return /* @__PURE__ */
|
|
3267
|
+
return /* @__PURE__ */ jsx14(View10, { style: [styles12.tr, { borderBottomColor: theme.grid }, rowBg ? { backgroundColor: rowBg } : null], children: columns.map((c) => {
|
|
3096
3268
|
const d = cellDisplay(c, c.field.values[i], theme.accent);
|
|
3097
3269
|
const bg = d.background ?? rowBg;
|
|
3098
3270
|
const linked = !!c.config.links?.length;
|
|
3099
3271
|
const color = d.color ?? (bg ? contrastText(bg, theme.text) : linked ? theme.accent : theme.text);
|
|
3100
|
-
const cellStyle = [
|
|
3101
|
-
return /* @__PURE__ */
|
|
3102
|
-
|
|
3272
|
+
const cellStyle = [styles12.td, { width: c.width }, d.background ? { backgroundColor: d.background } : null];
|
|
3273
|
+
return /* @__PURE__ */ jsxs12(
|
|
3274
|
+
Pressable11,
|
|
3103
3275
|
{
|
|
3104
3276
|
disabled: !linked,
|
|
3105
3277
|
onPress: () => openLinks(
|
|
@@ -3109,8 +3281,8 @@ function TablePanel({ panel, frames }) {
|
|
|
3109
3281
|
accessibilityRole: linked ? "link" : void 0,
|
|
3110
3282
|
style: ({ pressed }) => [cellStyle, pressed && { opacity: 0.6 }],
|
|
3111
3283
|
children: [
|
|
3112
|
-
d.gauge != null && /* @__PURE__ */
|
|
3113
|
-
/* @__PURE__ */
|
|
3284
|
+
d.gauge != null && /* @__PURE__ */ jsx14(View10, { style: [styles12.gaugeTrack, { backgroundColor: theme.grid }], children: /* @__PURE__ */ jsx14(View10, { style: [styles12.gaugeFill, { width: `${d.gauge * 100}%`, backgroundColor: d.gaugeColor ?? theme.accent }] }) }),
|
|
3285
|
+
/* @__PURE__ */ jsx14(Text12, { style: [styles12.cellText, { color, textAlign: c.align }, c.field.type === "number" && styles12.num], numberOfLines: c.wrap ? void 0 : 1, children: d.text })
|
|
3114
3286
|
]
|
|
3115
3287
|
},
|
|
3116
3288
|
c.key
|
|
@@ -3118,8 +3290,8 @@ function TablePanel({ panel, frames }) {
|
|
|
3118
3290
|
}) }, i);
|
|
3119
3291
|
})
|
|
3120
3292
|
] }),
|
|
3121
|
-
footer && /* @__PURE__ */
|
|
3122
|
-
line.label ? /* @__PURE__ */
|
|
3293
|
+
footer && /* @__PURE__ */ jsx14(View10, { style: [styles12.tr, styles12.footer, { borderTopColor: theme.border }], children: columns.map((c, ci) => /* @__PURE__ */ jsx14(View10, { style: [styles12.td, { width: c.width }], children: footer[ci].map((line, li) => /* @__PURE__ */ jsxs12(Text12, { style: [styles12.cellText, styles12.footerText, { color: theme.text, textAlign: c.align }], numberOfLines: 1, children: [
|
|
3294
|
+
line.label ? /* @__PURE__ */ jsx14(Text12, { style: { color: theme.textMuted, fontWeight: "400" }, children: `${line.label} ` }) : null,
|
|
3123
3295
|
line.text
|
|
3124
3296
|
] }, li)) }, c.key)) })
|
|
3125
3297
|
] }) });
|
|
@@ -3129,9 +3301,9 @@ function TextPanel({ panel }) {
|
|
|
3129
3301
|
const raw = panel.options?.content;
|
|
3130
3302
|
const content = typeof raw === "string" ? raw : "";
|
|
3131
3303
|
const text = panel.options?.mode === "html" ? content.replace(/<[^>]+>/g, "") : content;
|
|
3132
|
-
return /* @__PURE__ */
|
|
3304
|
+
return /* @__PURE__ */ jsx14(ScrollView5, { children: text.split(/\n{2,}/).map((block, i) => {
|
|
3133
3305
|
const heading = /^#{1,6}\s+/.test(block);
|
|
3134
|
-
return /* @__PURE__ */
|
|
3306
|
+
return /* @__PURE__ */ jsx14(Text12, { style: [styles12.para, { color: heading ? theme.text : theme.textSecondary }, heading && styles12.heading], children: block.replace(/^#{1,6}\s+/, "").replace(/\*\*(.+?)\*\*/g, "$1").replace(/\[(.+?)\]\(.+?\)/g, "$1") }, i);
|
|
3135
3307
|
}) });
|
|
3136
3308
|
}
|
|
3137
3309
|
function BarChartPanel({ panel, frames, width }) {
|
|
@@ -3140,13 +3312,13 @@ function BarChartPanel({ panel, frames, width }) {
|
|
|
3140
3312
|
const values = useMemo6(() => reducedValues(panel, frames, theme.scheme), [panel, frames, theme.scheme]);
|
|
3141
3313
|
const frame = frames[0];
|
|
3142
3314
|
const category = frame && barCategory(panel, frame);
|
|
3143
|
-
if (!frame || !values.length) return /* @__PURE__ */
|
|
3315
|
+
if (!frame || !values.length) return /* @__PURE__ */ jsx14(NoData, {});
|
|
3144
3316
|
const xField = panel.options?.xField;
|
|
3145
|
-
if (xField && !category) return /* @__PURE__ */
|
|
3317
|
+
if (xField && !category) return /* @__PURE__ */ jsx14(NoData, { message: `No field named \u201C${String(xField)}\u201D` });
|
|
3146
3318
|
const allNumeric = frame.fields.filter((f) => f.type === "number");
|
|
3147
3319
|
const at = (f) => values[allNumeric.indexOf(f)];
|
|
3148
3320
|
const numeric = category ? allNumeric.filter((f) => f !== category) : [];
|
|
3149
|
-
if (category && !numeric.length) return /* @__PURE__ */
|
|
3321
|
+
if (category && !numeric.length) return /* @__PURE__ */ jsx14(NoData, { message: `No number fields to draw besides \u201C${category.name}\u201D` });
|
|
3150
3322
|
const fields = category ? numeric.map((f) => ({ key: f.name, name: at(f)?.name ?? f.name, color: at(f)?.color ?? theme.accent, config: at(f)?.config ?? {}, values: f.values.map(num2) })) : [{ key: "reduced", name: "", color: theme.accent, config: values[0].config, values: values.map((v) => v.value) }];
|
|
3151
3323
|
const labels = category ? categoryLabels(category) : values.map((v) => v.name);
|
|
3152
3324
|
const colorAt = (fi, i) => category ? fields[fi].color : values[i].color;
|
|
@@ -3161,34 +3333,34 @@ function BarChartPanel({ panel, frames, width }) {
|
|
|
3161
3333
|
const gridAxis = left ?? right;
|
|
3162
3334
|
const plotW = width - (left ? AXIS_W : 0) - (right ? AXIS_W : 0);
|
|
3163
3335
|
const every = Math.max(1, Math.ceil(labels.length / Math.max(1, Math.floor(plotW / 44))));
|
|
3164
|
-
const axisColumn = (axis) => /* @__PURE__ */
|
|
3165
|
-
|
|
3336
|
+
const axisColumn = (axis) => /* @__PURE__ */ jsx14(View10, { style: [styles12.axis, axis.side === "left" ? styles12.axisLeft : styles12.axisRight], children: plot.height > 0 && axis.ticks.map((t) => /* @__PURE__ */ jsx14(
|
|
3337
|
+
Text12,
|
|
3166
3338
|
{
|
|
3167
|
-
style: [
|
|
3339
|
+
style: [styles12.tick, { color: theme.textMuted, top: plot.height * (1 - barFraction(axis, t)) - 7 }, axis.side === "left" ? styles12.tickLeft : styles12.tickRight],
|
|
3168
3340
|
numberOfLines: 1,
|
|
3169
3341
|
children: formatValue(t, { ...axis.config, decimals: tickDecimals(axis.ticks) })
|
|
3170
3342
|
},
|
|
3171
3343
|
t
|
|
3172
3344
|
)) });
|
|
3173
|
-
return /* @__PURE__ */
|
|
3174
|
-
(left?.label || right?.label) && /* @__PURE__ */
|
|
3175
|
-
/* @__PURE__ */
|
|
3176
|
-
/* @__PURE__ */
|
|
3345
|
+
return /* @__PURE__ */ jsxs12(View10, { style: styles12.fill, children: [
|
|
3346
|
+
(left?.label || right?.label) && /* @__PURE__ */ jsxs12(View10, { style: styles12.axisLabels, children: [
|
|
3347
|
+
/* @__PURE__ */ jsx14(Text12, { style: [styles12.axisLabel, { color: theme.textMuted }], children: left?.label ?? "" }),
|
|
3348
|
+
/* @__PURE__ */ jsx14(Text12, { style: [styles12.axisLabel, { color: theme.textMuted }], children: right?.label ?? "" })
|
|
3177
3349
|
] }),
|
|
3178
|
-
/* @__PURE__ */
|
|
3350
|
+
/* @__PURE__ */ jsxs12(View10, { style: styles12.barRow, children: [
|
|
3179
3351
|
left && axisColumn(left),
|
|
3180
|
-
/* @__PURE__ */
|
|
3181
|
-
gridAxis && plot.height > 0 && gridAxis.ticks.map((t) => /* @__PURE__ */
|
|
3182
|
-
/* @__PURE__ */
|
|
3352
|
+
/* @__PURE__ */ jsxs12(View10, { style: styles12.fill, onLayout: onPlotLayout, children: [
|
|
3353
|
+
gridAxis && plot.height > 0 && gridAxis.ticks.map((t) => /* @__PURE__ */ jsx14(View10, { style: [styles12.gridLine, { backgroundColor: theme.grid, top: plot.height * (1 - barFraction(gridAxis, t)) }] }, t)),
|
|
3354
|
+
/* @__PURE__ */ jsx14(View10, { style: styles12.barchart, children: labels.map((_, i) => /* @__PURE__ */ jsx14(View10, { style: styles12.barStack, children: fields.map((f, fi) => {
|
|
3183
3355
|
const axis = axisOf(fi);
|
|
3184
3356
|
const base = barFraction(axis, Math.min(Math.max(0, axis.bottom), axis.top));
|
|
3185
3357
|
const end = barFraction(axis, f.values[i] ?? 0);
|
|
3186
|
-
return /* @__PURE__ */
|
|
3358
|
+
return /* @__PURE__ */ jsx14(View10, { style: styles12.barSlot, children: /* @__PURE__ */ jsx14(
|
|
3187
3359
|
View10,
|
|
3188
3360
|
{
|
|
3189
3361
|
style: [
|
|
3190
|
-
|
|
3191
|
-
end < base &&
|
|
3362
|
+
styles12.bar,
|
|
3363
|
+
end < base && styles12.barDown,
|
|
3192
3364
|
{ bottom: `${Math.min(base, end) * 100}%`, height: `${Math.abs(end - base) * 100}%`, backgroundColor: colorAt(fi, i) }
|
|
3193
3365
|
]
|
|
3194
3366
|
}
|
|
@@ -3197,8 +3369,8 @@ function BarChartPanel({ panel, frames, width }) {
|
|
|
3197
3369
|
] }),
|
|
3198
3370
|
right && axisColumn(right)
|
|
3199
3371
|
] }),
|
|
3200
|
-
/* @__PURE__ */
|
|
3201
|
-
category && fields.length > 1 && /* @__PURE__ */
|
|
3372
|
+
/* @__PURE__ */ jsx14(View10, { style: [styles12.barLabels, { marginLeft: left ? AXIS_W : 0, marginRight: right ? AXIS_W : 0 }], children: labels.map((label, i) => /* @__PURE__ */ jsx14(Text12, { style: [styles12.barLabel, { color: theme.textMuted }], numberOfLines: 1, children: i % every === 0 ? label : " " }, i)) }),
|
|
3373
|
+
category && fields.length > 1 && /* @__PURE__ */ jsx14(Legend, { items: fields })
|
|
3202
3374
|
] });
|
|
3203
3375
|
}
|
|
3204
3376
|
var AXIS_W = 40;
|
|
@@ -3208,15 +3380,15 @@ function num2(v) {
|
|
|
3208
3380
|
return Number.isFinite(n) ? n : null;
|
|
3209
3381
|
}
|
|
3210
3382
|
function UnsupportedPanel({ panel }) {
|
|
3211
|
-
return /* @__PURE__ */
|
|
3383
|
+
return /* @__PURE__ */ jsx14(NoData, { message: `"${panel.type}" panels aren't supported yet` });
|
|
3212
3384
|
}
|
|
3213
|
-
var
|
|
3385
|
+
var styles12 = StyleSheet12.create({
|
|
3214
3386
|
fill: { flex: 1 },
|
|
3215
|
-
tr: { flexDirection: "row", borderBottomWidth:
|
|
3387
|
+
tr: { flexDirection: "row", borderBottomWidth: StyleSheet12.hairlineWidth },
|
|
3216
3388
|
th: { paddingVertical: 6, paddingHorizontal: 6, fontSize: 12, fontWeight: "600" },
|
|
3217
3389
|
td: { paddingVertical: 6, paddingHorizontal: 6, justifyContent: "center" },
|
|
3218
3390
|
cellText: { fontSize: 12 },
|
|
3219
|
-
footer: { borderBottomWidth: 0, borderTopWidth:
|
|
3391
|
+
footer: { borderBottomWidth: 0, borderTopWidth: StyleSheet12.hairlineWidth },
|
|
3220
3392
|
footerText: { fontWeight: "600", fontVariant: ["tabular-nums"] },
|
|
3221
3393
|
gaugeTrack: { position: "absolute", left: 6, right: 6, bottom: 3, height: 3, borderRadius: 2, overflow: "hidden" },
|
|
3222
3394
|
gaugeFill: { height: "100%", borderRadius: 2 },
|
|
@@ -3232,7 +3404,7 @@ var styles11 = StyleSheet11.create({
|
|
|
3232
3404
|
barDown: { borderTopLeftRadius: 0, borderTopRightRadius: 0, borderBottomLeftRadius: 4, borderBottomRightRadius: 4 },
|
|
3233
3405
|
barLabels: { flexDirection: "row", gap: 2 },
|
|
3234
3406
|
barLabel: { flex: 1, fontSize: 10, marginTop: 4, textAlign: "center" },
|
|
3235
|
-
gridLine: { position: "absolute", left: 0, right: 0, height:
|
|
3407
|
+
gridLine: { position: "absolute", left: 0, right: 0, height: StyleSheet12.hairlineWidth },
|
|
3236
3408
|
axis: { width: AXIS_W },
|
|
3237
3409
|
axisLeft: { paddingRight: 6 },
|
|
3238
3410
|
axisRight: { paddingLeft: 6 },
|
|
@@ -3244,10 +3416,10 @@ var styles11 = StyleSheet11.create({
|
|
|
3244
3416
|
});
|
|
3245
3417
|
|
|
3246
3418
|
// src/ui/panels/TimeSeriesPanel.tsx
|
|
3247
|
-
import { useId, useMemo as useMemo7, useRef as
|
|
3248
|
-
import { Pressable as
|
|
3249
|
-
import
|
|
3250
|
-
import { jsx as
|
|
3419
|
+
import { useId, useMemo as useMemo7, useRef as useRef5, useState as useState10 } from "react";
|
|
3420
|
+
import { Pressable as Pressable12, StyleSheet as StyleSheet13, Text as Text13, View as View11 } from "react-native";
|
|
3421
|
+
import Svg9, { Circle, ClipPath, Defs, G, Line, Path as Path9, Rect, Text as SvgText3 } from "react-native-svg";
|
|
3422
|
+
import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
3251
3423
|
var BASE_PAD = { top: 8, right: 8, bottom: 20, left: 44 };
|
|
3252
3424
|
var BAR_MAX = 24;
|
|
3253
3425
|
function TimeSeriesPanel({ panel, frames }) {
|
|
@@ -3255,20 +3427,20 @@ function TimeSeriesPanel({ panel, frames }) {
|
|
|
3255
3427
|
const { range: range3, setRawRange, pinned, setPinned } = useDashboard();
|
|
3256
3428
|
const { resolve, openLinks } = usePanelLinks(panel);
|
|
3257
3429
|
const [size, onLayout] = useLayout();
|
|
3258
|
-
const [hoverX, setHoverX] =
|
|
3259
|
-
const [preview, setPreview] =
|
|
3260
|
-
const [xZoom, setXZoom] =
|
|
3261
|
-
const pinch =
|
|
3262
|
-
const originX =
|
|
3430
|
+
const [hoverX, setHoverX] = useState10(null);
|
|
3431
|
+
const [preview, setPreview] = useState10(null);
|
|
3432
|
+
const [xZoom, setXZoom] = useState10(null);
|
|
3433
|
+
const pinch = useRef5(null);
|
|
3434
|
+
const originX = useRef5(0);
|
|
3263
3435
|
const id = useId();
|
|
3264
3436
|
const clipId = `plot${id.replace(/[^a-zA-Z0-9]/g, "")}`;
|
|
3265
|
-
const [touching, setTouching] =
|
|
3437
|
+
const [touching, setTouching] = useState10(false);
|
|
3266
3438
|
const numericX = panel.type === "trend";
|
|
3267
3439
|
const { series, xConfig } = useMemo7(
|
|
3268
3440
|
() => numericX ? styledXYSeries(panel, frames, theme.scheme) : { series: styledSeries(panel, frames, theme.scheme), xConfig: {} },
|
|
3269
3441
|
[numericX, panel, frames, theme.scheme]
|
|
3270
3442
|
);
|
|
3271
|
-
if (!series.length || series.every((s) => s.values.every((v) => v == null))) return /* @__PURE__ */
|
|
3443
|
+
if (!series.length || series.every((s) => s.values.every((v) => v == null))) return /* @__PURE__ */ jsx15(NoData, {});
|
|
3272
3444
|
const style = (s) => s.config.custom?.drawStyle ?? (panel.type === "graph" && panel.bars ? "bars" : "line");
|
|
3273
3445
|
const anyBars = series.some((s) => style(s) === "bars");
|
|
3274
3446
|
const anyFill = series.some((s) => (s.config.custom?.fillOpacity ?? 0) > 0);
|
|
@@ -3327,11 +3499,11 @@ function TimeSeriesPanel({ panel, frames }) {
|
|
|
3327
3499
|
)
|
|
3328
3500
|
) : [];
|
|
3329
3501
|
const isPinned = !!hover && pinned === id;
|
|
3330
|
-
return /* @__PURE__ */
|
|
3331
|
-
/* @__PURE__ */
|
|
3502
|
+
return /* @__PURE__ */ jsxs13(View11, { style: styles13.fill, children: [
|
|
3503
|
+
/* @__PURE__ */ jsx15(
|
|
3332
3504
|
View11,
|
|
3333
3505
|
{
|
|
3334
|
-
style:
|
|
3506
|
+
style: styles13.fill,
|
|
3335
3507
|
onStartShouldSetResponderCapture: twoFingers,
|
|
3336
3508
|
onMoveShouldSetResponderCapture: twoFingers,
|
|
3337
3509
|
onResponderTerminationRequest: () => false,
|
|
@@ -3343,10 +3515,10 @@ function TimeSeriesPanel({ panel, frames }) {
|
|
|
3343
3515
|
onResponderMove: onPinchMove,
|
|
3344
3516
|
onResponderRelease: () => onPinchEnd(true),
|
|
3345
3517
|
onResponderTerminate: () => onPinchEnd(false),
|
|
3346
|
-
children: /* @__PURE__ */
|
|
3518
|
+
children: /* @__PURE__ */ jsxs13(
|
|
3347
3519
|
View11,
|
|
3348
3520
|
{
|
|
3349
|
-
style:
|
|
3521
|
+
style: styles13.fill,
|
|
3350
3522
|
onLayout,
|
|
3351
3523
|
onStartShouldSetResponder: () => true,
|
|
3352
3524
|
onResponderGrant: (e) => {
|
|
@@ -3366,12 +3538,12 @@ function TimeSeriesPanel({ panel, frames }) {
|
|
|
3366
3538
|
setHoverX(null);
|
|
3367
3539
|
},
|
|
3368
3540
|
children: [
|
|
3369
|
-
size.width > 0 && /* @__PURE__ */
|
|
3370
|
-
ticks.map((t) => /* @__PURE__ */
|
|
3371
|
-
/* @__PURE__ */
|
|
3372
|
-
/* @__PURE__ */
|
|
3541
|
+
size.width > 0 && /* @__PURE__ */ jsxs13(Svg9, { width: size.width, height: size.height, children: [
|
|
3542
|
+
ticks.map((t) => /* @__PURE__ */ jsxs13(G, { children: [
|
|
3543
|
+
/* @__PURE__ */ jsx15(Line, { x1: PAD.left, x2: PAD.left + plotW, y1: y(t), y2: y(t), stroke: theme.grid, strokeWidth: 1 }),
|
|
3544
|
+
/* @__PURE__ */ jsx15(SvgText3, { x: PAD.left - 6, y: y(t) + 3, fontSize: 10, fill: theme.textMuted, textAnchor: "end", children: formatValue(t, { ...unitConfig, decimals: tickDecimals(ticks) }) })
|
|
3373
3545
|
] }, t)),
|
|
3374
|
-
xTicks.map((t) => /* @__PURE__ */
|
|
3546
|
+
xTicks.map((t) => /* @__PURE__ */ jsx15(
|
|
3375
3547
|
SvgText3,
|
|
3376
3548
|
{
|
|
3377
3549
|
x: x(t),
|
|
@@ -3383,65 +3555,65 @@ function TimeSeriesPanel({ panel, frames }) {
|
|
|
3383
3555
|
},
|
|
3384
3556
|
t
|
|
3385
3557
|
)),
|
|
3386
|
-
/* @__PURE__ */
|
|
3387
|
-
/* @__PURE__ */
|
|
3388
|
-
/* @__PURE__ */
|
|
3558
|
+
/* @__PURE__ */ jsx15(AxisTitles, { x: xTitle, y: yTitle, plot: { left: PAD.left, top: PAD.top, width: plotW, height: plotH }, height: size.height }),
|
|
3559
|
+
/* @__PURE__ */ jsx15(Defs, { children: /* @__PURE__ */ jsx15(ClipPath, { id: clipId, children: /* @__PURE__ */ jsx15(Rect, { x: PAD.left - 6, y: 0, width: plotW + 12, height: size.height }) }) }),
|
|
3560
|
+
/* @__PURE__ */ jsxs13(G, { clipPath: `url(#${clipId})`, children: [
|
|
3389
3561
|
barSeries.map(
|
|
3390
3562
|
(s, si) => s.times.map((t, i) => {
|
|
3391
3563
|
const v = s.values[i];
|
|
3392
3564
|
if (v == null || t < xFrom || t > xTo) return null;
|
|
3393
3565
|
const left = x(t) - groupW / 2 + si * (groupW / barSeries.length);
|
|
3394
|
-
return /* @__PURE__ */
|
|
3566
|
+
return /* @__PURE__ */ jsx15(Path9, { d: barPath(left, barW, y(Math.max(v, 0)), y(Math.min(v, 0)), v >= 0), fill: s.color }, `${s.key}-${i}`);
|
|
3395
3567
|
})
|
|
3396
3568
|
),
|
|
3397
3569
|
series.filter((s) => style(s) !== "bars").map((s) => {
|
|
3398
3570
|
const fill = (s.config.custom?.fillOpacity ?? 0) / 100;
|
|
3399
3571
|
const showPoints = style(s) === "points" || s.config.custom?.showPoints === "always" || s.config.custom?.showPoints !== "never" && s.times.length <= plotW / 14;
|
|
3400
3572
|
const segs = segments(s, x, y, s.config.custom?.lineInterpolation === "stepAfter");
|
|
3401
|
-
return /* @__PURE__ */
|
|
3402
|
-
fill > 0 && segs.map((seg, i) => /* @__PURE__ */
|
|
3403
|
-
style(s) !== "points" && segs.map((seg, i) => /* @__PURE__ */
|
|
3573
|
+
return /* @__PURE__ */ jsxs13(G, { children: [
|
|
3574
|
+
fill > 0 && segs.map((seg, i) => /* @__PURE__ */ jsx15(Path9, { d: `${seg.d}L${seg.lastX},${y(Math.max(yMin, 0))}L${seg.firstX},${y(Math.max(yMin, 0))}Z`, fill: s.color, opacity: fill }, `f${i}`)),
|
|
3575
|
+
style(s) !== "points" && segs.map((seg, i) => /* @__PURE__ */ jsx15(Path9, { d: seg.d, stroke: s.color, strokeWidth: s.config.custom?.lineWidth ?? 2, fill: "none", strokeLinejoin: "round", strokeLinecap: "round" }, `l${i}`)),
|
|
3404
3576
|
showPoints && s.times.map(
|
|
3405
|
-
(t, i) => s.values[i] == null ? null : /* @__PURE__ */
|
|
3577
|
+
(t, i) => s.values[i] == null ? null : /* @__PURE__ */ jsx15(Circle, { cx: x(t), cy: y(s.values[i]), r: 4, fill: s.color, stroke: theme.surface, strokeWidth: 2 }, i)
|
|
3406
3578
|
)
|
|
3407
3579
|
] }, s.key);
|
|
3408
3580
|
}),
|
|
3409
|
-
hover && /* @__PURE__ */
|
|
3410
|
-
/* @__PURE__ */
|
|
3581
|
+
hover && /* @__PURE__ */ jsxs13(G, { children: [
|
|
3582
|
+
/* @__PURE__ */ jsx15(Line, { x1: x(hover.time), x2: x(hover.time), y1: PAD.top, y2: PAD.top + plotH, stroke: theme.textMuted, strokeWidth: 1 }),
|
|
3411
3583
|
hover.rows.map(
|
|
3412
|
-
(r) => r.value == null ? null : /* @__PURE__ */
|
|
3584
|
+
(r) => r.value == null ? null : /* @__PURE__ */ jsx15(Circle, { cx: x(r.time), cy: y(r.value), r: 5, fill: r.color, stroke: theme.surface, strokeWidth: 2 }, r.key)
|
|
3413
3585
|
)
|
|
3414
3586
|
] })
|
|
3415
3587
|
] })
|
|
3416
3588
|
] }),
|
|
3417
|
-
xZoom && !preview && /* @__PURE__ */
|
|
3418
|
-
|
|
3589
|
+
xZoom && !preview && /* @__PURE__ */ jsx15(
|
|
3590
|
+
Pressable12,
|
|
3419
3591
|
{
|
|
3420
3592
|
onPress: () => setXZoom(null),
|
|
3421
3593
|
accessibilityRole: "button",
|
|
3422
3594
|
hitSlop: 8,
|
|
3423
|
-
style: ({ pressed }) => [
|
|
3424
|
-
children: /* @__PURE__ */
|
|
3595
|
+
style: ({ pressed }) => [styles13.reset, { backgroundColor: theme.surface, borderColor: theme.border }, pressed && { opacity: 0.7 }],
|
|
3596
|
+
children: /* @__PURE__ */ jsx15(Text13, { style: [styles13.resetText, { color: theme.accent }], children: "Reset zoom" })
|
|
3425
3597
|
}
|
|
3426
3598
|
),
|
|
3427
|
-
hover && /* @__PURE__ */
|
|
3599
|
+
hover && /* @__PURE__ */ jsxs13(
|
|
3428
3600
|
View11,
|
|
3429
3601
|
{
|
|
3430
3602
|
pointerEvents: isPinned ? "auto" : "none",
|
|
3431
3603
|
onStartShouldSetResponder: () => isPinned,
|
|
3432
3604
|
style: [
|
|
3433
|
-
|
|
3605
|
+
styles13.tooltip,
|
|
3434
3606
|
{ backgroundColor: theme.surface, borderColor: theme.border },
|
|
3435
3607
|
x(hover.time) > size.width / 2 ? { right: size.width - x(hover.time) + 8 } : { left: x(hover.time) + 8 }
|
|
3436
3608
|
],
|
|
3437
3609
|
children: [
|
|
3438
|
-
/* @__PURE__ */
|
|
3439
|
-
hover.rows.map((r) => /* @__PURE__ */
|
|
3440
|
-
/* @__PURE__ */
|
|
3441
|
-
/* @__PURE__ */
|
|
3442
|
-
/* @__PURE__ */
|
|
3610
|
+
/* @__PURE__ */ jsx15(Text13, { style: [styles13.tooltipTime, { color: theme.textMuted }], children: numericX ? formatValue(hover.time, xConfig) : formatTooltipTime(hover.time) }),
|
|
3611
|
+
hover.rows.map((r) => /* @__PURE__ */ jsxs13(View11, { style: styles13.tooltipRow, children: [
|
|
3612
|
+
/* @__PURE__ */ jsx15(View11, { style: [styles13.swatch, { backgroundColor: r.color }] }),
|
|
3613
|
+
/* @__PURE__ */ jsx15(Text13, { style: [styles13.tooltipName, { color: theme.textSecondary }], numberOfLines: 1, children: r.name }),
|
|
3614
|
+
/* @__PURE__ */ jsx15(Text13, { style: [styles13.tooltipValue, { color: theme.text }], children: formatValue(r.value, r.config) })
|
|
3443
3615
|
] }, r.key)),
|
|
3444
|
-
isPinned && /* @__PURE__ */
|
|
3616
|
+
isPinned && /* @__PURE__ */ jsx15(TooltipLinks, { links: hoverLinks, onOpen: (l) => openLinks([l]) })
|
|
3445
3617
|
]
|
|
3446
3618
|
}
|
|
3447
3619
|
)
|
|
@@ -3450,7 +3622,7 @@ function TimeSeriesPanel({ panel, frames }) {
|
|
|
3450
3622
|
)
|
|
3451
3623
|
}
|
|
3452
3624
|
),
|
|
3453
|
-
showLegend(panel, series.length) && /* @__PURE__ */
|
|
3625
|
+
showLegend(panel, series.length) && /* @__PURE__ */ jsx15(Legend, { items: series })
|
|
3454
3626
|
] });
|
|
3455
3627
|
}
|
|
3456
3628
|
function segments(s, x, y, step = false) {
|
|
@@ -3539,7 +3711,7 @@ function linkData(r, frames, xField) {
|
|
|
3539
3711
|
time: xField === void 0 ? r.time : void 0
|
|
3540
3712
|
};
|
|
3541
3713
|
}
|
|
3542
|
-
var
|
|
3714
|
+
var styles13 = StyleSheet13.create({
|
|
3543
3715
|
fill: { flex: 1 },
|
|
3544
3716
|
tooltip: {
|
|
3545
3717
|
position: "absolute",
|
|
@@ -3547,7 +3719,7 @@ var styles12 = StyleSheet12.create({
|
|
|
3547
3719
|
paddingHorizontal: 8,
|
|
3548
3720
|
paddingVertical: 6,
|
|
3549
3721
|
borderRadius: 6,
|
|
3550
|
-
borderWidth:
|
|
3722
|
+
borderWidth: StyleSheet13.hairlineWidth,
|
|
3551
3723
|
maxWidth: 220,
|
|
3552
3724
|
shadowColor: "#000",
|
|
3553
3725
|
shadowOpacity: 0.12,
|
|
@@ -3555,7 +3727,7 @@ var styles12 = StyleSheet12.create({
|
|
|
3555
3727
|
shadowOffset: { width: 0, height: 2 },
|
|
3556
3728
|
elevation: 3
|
|
3557
3729
|
},
|
|
3558
|
-
reset: { position: "absolute", top: 4, right: 8, paddingHorizontal: 8, paddingVertical: 3, borderRadius: 6, borderWidth:
|
|
3730
|
+
reset: { position: "absolute", top: 4, right: 8, paddingHorizontal: 8, paddingVertical: 3, borderRadius: 6, borderWidth: StyleSheet13.hairlineWidth },
|
|
3559
3731
|
resetText: { fontSize: 11, fontWeight: "600" },
|
|
3560
3732
|
tooltipTime: { fontSize: 11, marginBottom: 3 },
|
|
3561
3733
|
tooltipRow: { flexDirection: "row", alignItems: "center", gap: 6 },
|
|
@@ -3565,9 +3737,9 @@ var styles12 = StyleSheet12.create({
|
|
|
3565
3737
|
});
|
|
3566
3738
|
|
|
3567
3739
|
// src/ui/panels/XYChartPanel.tsx
|
|
3568
|
-
import { useId as useId2, useMemo as useMemo8, useState as
|
|
3569
|
-
import { StyleSheet as
|
|
3570
|
-
import
|
|
3740
|
+
import { useId as useId2, useMemo as useMemo8, useState as useState11 } from "react";
|
|
3741
|
+
import { StyleSheet as StyleSheet14, View as View12 } from "react-native";
|
|
3742
|
+
import Svg10, { Circle as Circle2, G as G2, Line as Line2, Path as Path10, Text as SvgText4 } from "react-native-svg";
|
|
3571
3743
|
|
|
3572
3744
|
// src/ui/xychart.ts
|
|
3573
3745
|
var byName = (name) => name ? { matcher: { id: "byName", options: name } } : void 0;
|
|
@@ -3698,15 +3870,15 @@ function xyDomain(values, config) {
|
|
|
3698
3870
|
}
|
|
3699
3871
|
|
|
3700
3872
|
// src/ui/panels/XYChartPanel.tsx
|
|
3701
|
-
import { jsx as
|
|
3873
|
+
import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
3702
3874
|
var AXIS = { left: 44, bottom: 20 };
|
|
3703
3875
|
var EDGE = 8;
|
|
3704
3876
|
var HIT_PX2 = 32;
|
|
3705
3877
|
function XYChartPanel({ panel, frames }) {
|
|
3706
3878
|
const theme = useDashTheme();
|
|
3707
3879
|
const [size, onLayout] = useLayout();
|
|
3708
|
-
const [touch, setTouch] =
|
|
3709
|
-
const [touching, setTouching] =
|
|
3880
|
+
const [touch, setTouch] = useState11(null);
|
|
3881
|
+
const [touching, setTouching] = useState11(false);
|
|
3710
3882
|
const id = useId2();
|
|
3711
3883
|
const { pinned, setPinned } = useDashboard();
|
|
3712
3884
|
const { resolve, openLinks } = usePanelLinks(panel);
|
|
@@ -3733,7 +3905,7 @@ function XYChartPanel({ panel, frames }) {
|
|
|
3733
3905
|
const points = series.map((s) => ({ px: s.xs.map(x), py: s.ys.map(y) }));
|
|
3734
3906
|
return { x, y, x0, x1, y0, y1, points, paths: series.map((s, i) => drawSeries(s, points[i].px, points[i].py)) };
|
|
3735
3907
|
}, [series, first, pad.left, pad.top, plotW, plotH]);
|
|
3736
|
-
if (!first || !layout || series.every((s) => !s.rows.length)) return /* @__PURE__ */
|
|
3908
|
+
if (!first || !layout || series.every((s) => !s.rows.length)) return /* @__PURE__ */ jsx16(NoData, {});
|
|
3737
3909
|
const xTicks = showX ? axisTicks(layout.x0, layout.x1, plotW < 220 ? 2 : plotW < 400 ? 3 : 5) : [];
|
|
3738
3910
|
const yTicks = showY ? axisTicks(layout.y0, layout.y1, plotH < 100 ? 2 : 4) : [];
|
|
3739
3911
|
const gridX = first.xConfig.custom?.axisGridShow !== false;
|
|
@@ -3742,11 +3914,11 @@ function XYChartPanel({ panel, frames }) {
|
|
|
3742
3914
|
const hoverLinks = hover ? rowLinks(panel, hover.series.frame, hover.series.rows[hover.index], frames.length > 1, resolve) : [];
|
|
3743
3915
|
const isPinned = !!hover && pinned === id;
|
|
3744
3916
|
const legendItems = series.filter((s) => !s.yConfig.custom?.hideFrom?.legend);
|
|
3745
|
-
return /* @__PURE__ */
|
|
3746
|
-
/* @__PURE__ */
|
|
3917
|
+
return /* @__PURE__ */ jsxs14(View12, { style: styles14.fill, children: [
|
|
3918
|
+
/* @__PURE__ */ jsxs14(
|
|
3747
3919
|
View12,
|
|
3748
3920
|
{
|
|
3749
|
-
style:
|
|
3921
|
+
style: styles14.fill,
|
|
3750
3922
|
onLayout,
|
|
3751
3923
|
onStartShouldSetResponder: () => true,
|
|
3752
3924
|
onResponderGrant: (e) => {
|
|
@@ -3765,14 +3937,14 @@ function XYChartPanel({ panel, frames }) {
|
|
|
3765
3937
|
setTouch(null);
|
|
3766
3938
|
},
|
|
3767
3939
|
children: [
|
|
3768
|
-
size.width > 0 && /* @__PURE__ */
|
|
3769
|
-
yTicks.map((t) => /* @__PURE__ */
|
|
3770
|
-
gridY && /* @__PURE__ */
|
|
3771
|
-
/* @__PURE__ */
|
|
3940
|
+
size.width > 0 && /* @__PURE__ */ jsxs14(Svg10, { width: size.width, height: size.height, children: [
|
|
3941
|
+
yTicks.map((t) => /* @__PURE__ */ jsxs14(G2, { children: [
|
|
3942
|
+
gridY && /* @__PURE__ */ jsx16(Line2, { x1: pad.left, x2: pad.left + plotW, y1: layout.y(t), y2: layout.y(t), stroke: theme.grid, strokeWidth: 1 }),
|
|
3943
|
+
/* @__PURE__ */ jsx16(SvgText4, { x: pad.left - 6, y: layout.y(t) + 3, fontSize: 10, fill: theme.textMuted, textAnchor: "end", children: formatValue(t, { ...first.yConfig, decimals: first.yConfig.decimals ?? tickDecimals(yTicks) }) })
|
|
3772
3944
|
] }, `y${t}`)),
|
|
3773
|
-
xTicks.map((t) => /* @__PURE__ */
|
|
3774
|
-
gridX && /* @__PURE__ */
|
|
3775
|
-
/* @__PURE__ */
|
|
3945
|
+
xTicks.map((t) => /* @__PURE__ */ jsxs14(G2, { children: [
|
|
3946
|
+
gridX && /* @__PURE__ */ jsx16(Line2, { x1: layout.x(t), x2: layout.x(t), y1: pad.top, y2: pad.top + plotH, stroke: theme.grid, strokeWidth: 1 }),
|
|
3947
|
+
/* @__PURE__ */ jsx16(
|
|
3776
3948
|
SvgText4,
|
|
3777
3949
|
{
|
|
3778
3950
|
x: layout.x(t),
|
|
@@ -3784,12 +3956,12 @@ function XYChartPanel({ panel, frames }) {
|
|
|
3784
3956
|
}
|
|
3785
3957
|
)
|
|
3786
3958
|
] }, `x${t}`)),
|
|
3787
|
-
/* @__PURE__ */
|
|
3788
|
-
series.map((s, si) => /* @__PURE__ */
|
|
3789
|
-
layout.paths[si].line && /* @__PURE__ */
|
|
3790
|
-
layout.paths[si].dots.map(([color, d]) => /* @__PURE__ */
|
|
3959
|
+
/* @__PURE__ */ jsx16(AxisTitles, { x: xTitle, y: yTitle, plot: { left: pad.left, top: pad.top, width: plotW, height: plotH }, height: size.height }),
|
|
3960
|
+
series.map((s, si) => /* @__PURE__ */ jsxs14(G2, { children: [
|
|
3961
|
+
layout.paths[si].line && /* @__PURE__ */ jsx16(Path10, { d: layout.paths[si].line, stroke: s.color, strokeWidth: s.lineWidth, fill: "none", strokeLinejoin: "round" }),
|
|
3962
|
+
layout.paths[si].dots.map(([color, d]) => /* @__PURE__ */ jsx16(Path10, { d, fill: color }, color))
|
|
3791
3963
|
] }, s.key)),
|
|
3792
|
-
hover && /* @__PURE__ */
|
|
3964
|
+
hover && /* @__PURE__ */ jsx16(
|
|
3793
3965
|
Circle2,
|
|
3794
3966
|
{
|
|
3795
3967
|
cx: hover.px,
|
|
@@ -3801,7 +3973,7 @@ function XYChartPanel({ panel, frames }) {
|
|
|
3801
3973
|
}
|
|
3802
3974
|
)
|
|
3803
3975
|
] }),
|
|
3804
|
-
hover && /* @__PURE__ */
|
|
3976
|
+
hover && /* @__PURE__ */ jsx16(
|
|
3805
3977
|
RowTooltip,
|
|
3806
3978
|
{
|
|
3807
3979
|
at: { x: hover.px, y: hover.py },
|
|
@@ -3816,7 +3988,7 @@ function XYChartPanel({ panel, frames }) {
|
|
|
3816
3988
|
]
|
|
3817
3989
|
}
|
|
3818
3990
|
),
|
|
3819
|
-
showLegend(panel, legendItems.length) && /* @__PURE__ */
|
|
3991
|
+
showLegend(panel, legendItems.length) && /* @__PURE__ */ jsx16(Legend, { items: legendItems })
|
|
3820
3992
|
] });
|
|
3821
3993
|
}
|
|
3822
3994
|
function drawSeries(s, px, py) {
|
|
@@ -3850,7 +4022,7 @@ function nearestPoint(series, points, at) {
|
|
|
3850
4022
|
});
|
|
3851
4023
|
return best;
|
|
3852
4024
|
}
|
|
3853
|
-
var
|
|
4025
|
+
var styles14 = StyleSheet14.create({
|
|
3854
4026
|
fill: { flex: 1 }
|
|
3855
4027
|
});
|
|
3856
4028
|
|
|
@@ -3878,7 +4050,7 @@ function panelComponent(type) {
|
|
|
3878
4050
|
}
|
|
3879
4051
|
|
|
3880
4052
|
// src/ui/DashboardView.tsx
|
|
3881
|
-
import { jsx as
|
|
4053
|
+
import { jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3882
4054
|
var GAP2 = 8;
|
|
3883
4055
|
var SIDE = 12;
|
|
3884
4056
|
var TITLE_H = 28;
|
|
@@ -3896,44 +4068,44 @@ function DashboardView({ mode = "auto", header, footer, refreshable }) {
|
|
|
3896
4068
|
() => layoutDashboard(dashboard, layoutMode, { values: variables, info: variableInfo2 }),
|
|
3897
4069
|
[dashboard, layoutMode, variables, variableInfo2]
|
|
3898
4070
|
);
|
|
3899
|
-
const [toggled, setToggled] =
|
|
4071
|
+
const [toggled, setToggled] = useState12({});
|
|
3900
4072
|
const { seen, viewportH, onScroll, onViewportLayout, onSectionLayout } = useSeenSections(window.height);
|
|
3901
4073
|
const maxPanelH = Math.max(MIN_PANEL_H, viewportH - SIDE * 2);
|
|
3902
4074
|
const contentW = width - SIDE * 2;
|
|
3903
4075
|
const canRefresh = refreshable ?? dashboard.panels.some((p) => panelHasQueries(p) || p.panels?.some(panelHasQueries));
|
|
3904
|
-
return /* @__PURE__ */
|
|
3905
|
-
width > 0 && /* @__PURE__ */
|
|
4076
|
+
return /* @__PURE__ */ jsxs15(View13, { style: [styles15.fill, { backgroundColor: theme.background }], onLayout, children: [
|
|
4077
|
+
width > 0 && /* @__PURE__ */ jsxs15(
|
|
3906
4078
|
ScrollView6,
|
|
3907
4079
|
{
|
|
3908
4080
|
onScroll,
|
|
3909
4081
|
onScrollBeginDrag: () => setPinned(null),
|
|
3910
4082
|
onLayout: onViewportLayout,
|
|
3911
4083
|
scrollEventThrottle: 100,
|
|
3912
|
-
contentContainerStyle: [
|
|
4084
|
+
contentContainerStyle: [styles15.content, { paddingLeft: SIDE + insets.left, paddingRight: SIDE + insets.right }],
|
|
3913
4085
|
keyboardShouldPersistTaps: "handled",
|
|
3914
|
-
refreshControl: canRefresh ? /* @__PURE__ */
|
|
4086
|
+
refreshControl: canRefresh ? /* @__PURE__ */ jsx17(RefreshControl, { refreshing: false, onRefresh: refresh }) : void 0,
|
|
3915
4087
|
children: [
|
|
3916
4088
|
header,
|
|
3917
4089
|
sections.map((section) => {
|
|
3918
4090
|
const collapsed = toggled[section.key] ?? section.collapsed;
|
|
3919
|
-
return /* @__PURE__ */
|
|
3920
|
-
section.row && /* @__PURE__ */
|
|
3921
|
-
|
|
4091
|
+
return /* @__PURE__ */ jsxs15(View13, { style: styles15.section, onLayout: (e) => onSectionLayout(section.key, e), children: [
|
|
4092
|
+
section.row && /* @__PURE__ */ jsxs15(
|
|
4093
|
+
Pressable13,
|
|
3922
4094
|
{
|
|
3923
4095
|
onPress: () => setToggled((t) => ({ ...t, [section.key]: !collapsed })),
|
|
3924
|
-
style:
|
|
4096
|
+
style: styles15.rowHeader,
|
|
3925
4097
|
accessibilityRole: "button",
|
|
3926
4098
|
accessibilityState: { expanded: !collapsed },
|
|
3927
4099
|
children: [
|
|
3928
|
-
/* @__PURE__ */
|
|
3929
|
-
/* @__PURE__ */
|
|
4100
|
+
/* @__PURE__ */ jsx17(Text14, { style: [styles15.chevron, { color: theme.textMuted }], children: collapsed ? "\u25B8" : "\u25BE" }),
|
|
4101
|
+
/* @__PURE__ */ jsx17(Text14, { style: [styles15.rowTitle, { color: theme.text }], numberOfLines: 2, children: interpolate(section.row.title ?? "", { values: variables, info: variableInfo2, scoped: section.row.scopedVars, timezone: dashboard.timezone }) })
|
|
3930
4102
|
]
|
|
3931
4103
|
}
|
|
3932
4104
|
),
|
|
3933
|
-
!collapsed && layoutMode === "grid" && /* @__PURE__ */
|
|
3934
|
-
!collapsed && layoutMode === "phone" && section.rows.map((row, ri) => /* @__PURE__ */
|
|
4105
|
+
!collapsed && layoutMode === "grid" && /* @__PURE__ */ jsx17(GridSection, { grid: section.grid, width: contentW, maxPanelH, deferred: !seen.has(section.key) }),
|
|
4106
|
+
!collapsed && layoutMode === "phone" && section.rows.map((row, ri) => /* @__PURE__ */ jsx17(View13, { style: styles15.row, children: row.cells.map((cell) => {
|
|
3935
4107
|
const w = (contentW + GAP2) * (cell.span / GRID_COLUMNS) - GAP2;
|
|
3936
|
-
return /* @__PURE__ */
|
|
4108
|
+
return /* @__PURE__ */ jsx17(PanelCard, { panel: cell.panel, width: w, height: Math.min(gridUnitsToPx(row.h), maxPanelH), deferred: !seen.has(section.key) }, cell.key);
|
|
3937
4109
|
}) }, ri))
|
|
3938
4110
|
] }, section.key);
|
|
3939
4111
|
})
|
|
@@ -3947,13 +4119,13 @@ function GridSection({ grid, width, maxPanelH, deferred }) {
|
|
|
3947
4119
|
const colW = (width + GAP2) / GRID_COLUMNS;
|
|
3948
4120
|
const tallest = Math.max(0, ...grid.cells.map((c) => gridUnitsToPx(c.h)));
|
|
3949
4121
|
const scale = tallest > maxPanelH ? maxPanelH / tallest : 1;
|
|
3950
|
-
return /* @__PURE__ */
|
|
4122
|
+
return /* @__PURE__ */ jsx17(View13, { style: { height: gridUnitsToPx(grid.h) * scale }, children: grid.cells.map((cell) => /* @__PURE__ */ jsx17(View13, { style: [styles15.gridCell, { left: cell.x * colW, top: gridOffsetPx(cell.y) * scale }], children: /* @__PURE__ */ jsx17(PanelCard, { panel: cell.panel, width: cell.w * colW - GAP2, height: gridUnitsToPx(cell.h) * scale, deferred }) }, cell.key)) });
|
|
3951
4123
|
}
|
|
3952
4124
|
function useSeenSections(viewportHeight) {
|
|
3953
|
-
const [seen, setSeen] =
|
|
3954
|
-
const view =
|
|
3955
|
-
const [viewportH, setViewportH] =
|
|
3956
|
-
const positions =
|
|
4125
|
+
const [seen, setSeen] = useState12(/* @__PURE__ */ new Set());
|
|
4126
|
+
const view = useRef6({ y: 0, h: viewportHeight });
|
|
4127
|
+
const [viewportH, setViewportH] = useState12(viewportHeight);
|
|
4128
|
+
const positions = useRef6(/* @__PURE__ */ new Map());
|
|
3957
4129
|
const reveal = useCallback3(() => {
|
|
3958
4130
|
const { y, h } = view.current;
|
|
3959
4131
|
setSeen((prev) => {
|
|
@@ -3992,14 +4164,14 @@ function useSeenSections(viewportHeight) {
|
|
|
3992
4164
|
}
|
|
3993
4165
|
function PanelCard(props) {
|
|
3994
4166
|
const { panel, width, height } = props;
|
|
3995
|
-
return /* @__PURE__ */
|
|
4167
|
+
return /* @__PURE__ */ jsx17(RenderBoundary, { resetKeys: [panel, width, height], fallback: (error) => /* @__PURE__ */ jsx17(PanelError, { panel, width, height, error }), children: /* @__PURE__ */ jsx17(PanelCardContent, { ...props }) });
|
|
3996
4168
|
}
|
|
3997
4169
|
function PanelError({ panel, width, height, error }) {
|
|
3998
4170
|
const theme = useDashTheme();
|
|
3999
|
-
return /* @__PURE__ */
|
|
4000
|
-
!!panel.title && /* @__PURE__ */
|
|
4001
|
-
/* @__PURE__ */
|
|
4002
|
-
/* @__PURE__ */
|
|
4171
|
+
return /* @__PURE__ */ jsxs15(View13, { style: [styles15.card, { width, height, backgroundColor: theme.surface, borderColor: theme.danger }], accessibilityRole: "alert", children: [
|
|
4172
|
+
!!panel.title && /* @__PURE__ */ jsx17(Text14, { style: [styles15.title, styles15.errorTitle, { color: theme.text }], numberOfLines: 1, children: panel.title }),
|
|
4173
|
+
/* @__PURE__ */ jsx17(Text14, { style: [styles15.errorText, { color: theme.danger }], children: "This panel couldn\u2019t be shown." }),
|
|
4174
|
+
/* @__PURE__ */ jsx17(Text14, { style: [styles15.errorText, { color: theme.textMuted }], numberOfLines: 3, children: error.message })
|
|
4003
4175
|
] });
|
|
4004
4176
|
}
|
|
4005
4177
|
function PanelCardContent({ panel, width, height, deferred }) {
|
|
@@ -4011,25 +4183,27 @@ function PanelCardContent({ panel, width, height, deferred }) {
|
|
|
4011
4183
|
const form = useContext4(InputFormContext);
|
|
4012
4184
|
const problem = group ? form?.group?.(panel)?.problem : isInputPanel(panel) ? form?.problem?.(panel.options.metric) : void 0;
|
|
4013
4185
|
const hasLinks = !!panel.links?.length;
|
|
4014
|
-
const
|
|
4186
|
+
const filled = !group && isInputPanel(panel) && !!form?.filled?.(panel.options.metric);
|
|
4187
|
+
const hasTitle = !!panel.title || hasLinks || !!problem || filled;
|
|
4015
4188
|
const title = panel.title ? interpolate(panel.title, { values: variables, info: variableInfo2, scoped: panel.scopedVars, timezone: dashboard.timezone }) : "";
|
|
4016
|
-
return /* @__PURE__ */
|
|
4017
|
-
hasTitle && /* @__PURE__ */
|
|
4018
|
-
/* @__PURE__ */
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4189
|
+
return /* @__PURE__ */ jsxs15(View13, { style: [styles15.card, { width, height, backgroundColor: theme.surface, borderColor: filled ? theme.accent : theme.border }, filled && { borderWidth: 2 }], children: [
|
|
4190
|
+
hasTitle && /* @__PURE__ */ jsxs15(View13, { style: styles15.titleRow, children: [
|
|
4191
|
+
/* @__PURE__ */ jsx17(Text14, { style: [styles15.title, { color: theme.text }], numberOfLines: 1, children: title }),
|
|
4192
|
+
filled && !problem && /* @__PURE__ */ jsx17(Text14, { style: [styles15.problem, { color: theme.accent }], numberOfLines: 1, children: "From voice" }),
|
|
4193
|
+
!!problem && /* @__PURE__ */ jsx17(Text14, { style: [styles15.problem, { color: theme.danger }], numberOfLines: 1, accessibilityRole: "alert", children: problem }),
|
|
4194
|
+
hasLinks && /* @__PURE__ */ jsx17(
|
|
4195
|
+
Pressable13,
|
|
4022
4196
|
{
|
|
4023
4197
|
onPress: () => openLinks(resolve(panel.links), title || void 0),
|
|
4024
4198
|
accessibilityRole: "button",
|
|
4025
4199
|
accessibilityLabel: panel.links.length === 1 ? panel.links[0].title || "Open link" : "Panel links",
|
|
4026
4200
|
hitSlop: 10,
|
|
4027
|
-
style: ({ pressed }) => [
|
|
4028
|
-
children: /* @__PURE__ */
|
|
4201
|
+
style: ({ pressed }) => [styles15.titleLink, pressed && { opacity: 0.6 }],
|
|
4202
|
+
children: /* @__PURE__ */ jsx17(LinkIcon, { color: theme.textMuted })
|
|
4029
4203
|
}
|
|
4030
4204
|
)
|
|
4031
4205
|
] }),
|
|
4032
|
-
/* @__PURE__ */
|
|
4206
|
+
/* @__PURE__ */ jsx17(View13, { style: styles15.body, children: deferred && !input ? null : input ? group ? /* @__PURE__ */ jsx17(InputGroupBody, { panel }) : /* @__PURE__ */ jsx17(InputPanelBody, { panel }) : /* @__PURE__ */ jsx17(DataPanelBody, { panel, width: width - 24, height: height - (hasTitle ? TITLE_H : 0) - 16 }) })
|
|
4033
4207
|
] });
|
|
4034
4208
|
}
|
|
4035
4209
|
function DataPanelBody({ panel, width, height }) {
|
|
@@ -4038,14 +4212,14 @@ function DataPanelBody({ panel, width, height }) {
|
|
|
4038
4212
|
const data = usePanelData(panel, width, needsData);
|
|
4039
4213
|
const Component2 = panelComponent(panel.type);
|
|
4040
4214
|
if (needsData && data.error) {
|
|
4041
|
-
return /* @__PURE__ */
|
|
4215
|
+
return /* @__PURE__ */ jsx17(View13, { style: styles15.center, children: /* @__PURE__ */ jsx17(Text14, { style: [styles15.error, { color: theme.danger }], numberOfLines: 4, children: data.error }) });
|
|
4042
4216
|
}
|
|
4043
4217
|
if (needsData && data.loading && !data.frames.length) {
|
|
4044
|
-
return /* @__PURE__ */
|
|
4218
|
+
return /* @__PURE__ */ jsx17(View13, { style: styles15.center, children: /* @__PURE__ */ jsx17(ActivityIndicator, { color: theme.textMuted }) });
|
|
4045
4219
|
}
|
|
4046
|
-
return /* @__PURE__ */
|
|
4220
|
+
return /* @__PURE__ */ jsx17(Component2, { panel, frames: data.frames, width, height });
|
|
4047
4221
|
}
|
|
4048
|
-
var
|
|
4222
|
+
var styles15 = StyleSheet15.create({
|
|
4049
4223
|
fill: { flex: 1 },
|
|
4050
4224
|
content: { padding: SIDE, paddingBottom: 32, gap: GAP2 },
|
|
4051
4225
|
section: { gap: GAP2 },
|
|
@@ -4054,7 +4228,7 @@ var styles14 = StyleSheet14.create({
|
|
|
4054
4228
|
rowTitle: { fontSize: 15, fontWeight: "600" },
|
|
4055
4229
|
row: { flexDirection: "row", gap: GAP2 },
|
|
4056
4230
|
gridCell: { position: "absolute" },
|
|
4057
|
-
card: { borderRadius: 10, borderWidth:
|
|
4231
|
+
card: { borderRadius: 10, borderWidth: StyleSheet15.hairlineWidth, paddingHorizontal: 12, paddingVertical: 8, overflow: "hidden" },
|
|
4058
4232
|
titleRow: { flexDirection: "row", alignItems: "flex-start", gap: 8, height: TITLE_H - 8, marginBottom: 8 },
|
|
4059
4233
|
title: { flex: 1, fontSize: 13, fontWeight: "600" },
|
|
4060
4234
|
titleLink: { paddingTop: 1 },
|
|
@@ -4067,11 +4241,154 @@ var styles14 = StyleSheet14.create({
|
|
|
4067
4241
|
});
|
|
4068
4242
|
|
|
4069
4243
|
// src/ui/inputs/InputForm.tsx
|
|
4070
|
-
import { useCallback as useCallback4, useEffect as
|
|
4071
|
-
import { Pressable as
|
|
4072
|
-
|
|
4244
|
+
import { useCallback as useCallback4, useEffect as useEffect6, useMemo as useMemo10, useState as useState14 } from "react";
|
|
4245
|
+
import { Platform as Platform2, Pressable as Pressable14, StyleSheet as StyleSheet16, Text as Text15, View as View14 } from "react-native";
|
|
4246
|
+
|
|
4247
|
+
// src/ui/speech.ts
|
|
4248
|
+
var WEB_ERRORS = {
|
|
4249
|
+
"not-allowed": "Microphone access is blocked for this site",
|
|
4250
|
+
"service-not-allowed": "Speech recognition isn\u2019t allowed in this browser",
|
|
4251
|
+
"audio-capture": "No microphone found",
|
|
4252
|
+
network: "Speech recognition needs an internet connection",
|
|
4253
|
+
"no-speech": "Didn\u2019t hear anything",
|
|
4254
|
+
"language-not-supported": "Speech recognition doesn\u2019t support this language"
|
|
4255
|
+
};
|
|
4256
|
+
function webSpeechRecognizer() {
|
|
4257
|
+
const g = globalThis;
|
|
4258
|
+
const Recognition = g.SpeechRecognition ?? g.webkitSpeechRecognition;
|
|
4259
|
+
if (!Recognition) return null;
|
|
4260
|
+
return {
|
|
4261
|
+
start(o) {
|
|
4262
|
+
const r = new Recognition();
|
|
4263
|
+
if (o.lang) r.lang = o.lang;
|
|
4264
|
+
r.interimResults = true;
|
|
4265
|
+
r.continuous = !!o.continuous;
|
|
4266
|
+
r.maxAlternatives = 1;
|
|
4267
|
+
let delivered = false;
|
|
4268
|
+
let aborted = false;
|
|
4269
|
+
let lastText = "";
|
|
4270
|
+
r.onresult = (e) => {
|
|
4271
|
+
let text = "";
|
|
4272
|
+
let final = true;
|
|
4273
|
+
for (let i = 0; i < e.results.length; i++) {
|
|
4274
|
+
text += e.results[i][0].transcript;
|
|
4275
|
+
if (!e.results[i].isFinal) final = false;
|
|
4276
|
+
}
|
|
4277
|
+
lastText = text.trim();
|
|
4278
|
+
if (o.continuous) final = false;
|
|
4279
|
+
if (final) delivered = true;
|
|
4280
|
+
o.onText(lastText, final);
|
|
4281
|
+
};
|
|
4282
|
+
r.onerror = (e) => {
|
|
4283
|
+
if (e.error === "aborted") return;
|
|
4284
|
+
o.onError(WEB_ERRORS[e.error] ?? "Speech recognition stopped");
|
|
4285
|
+
};
|
|
4286
|
+
r.onend = () => {
|
|
4287
|
+
if (!delivered && !aborted && lastText) o.onText(lastText, true);
|
|
4288
|
+
o.onEnd();
|
|
4289
|
+
};
|
|
4290
|
+
try {
|
|
4291
|
+
r.start();
|
|
4292
|
+
} catch {
|
|
4293
|
+
queueMicrotask(() => {
|
|
4294
|
+
o.onError("Speech recognition couldn\u2019t start");
|
|
4295
|
+
o.onEnd();
|
|
4296
|
+
});
|
|
4297
|
+
}
|
|
4298
|
+
return {
|
|
4299
|
+
stop: () => r.stop(),
|
|
4300
|
+
abort: () => {
|
|
4301
|
+
aborted = true;
|
|
4302
|
+
r.abort();
|
|
4303
|
+
}
|
|
4304
|
+
};
|
|
4305
|
+
}
|
|
4306
|
+
};
|
|
4307
|
+
}
|
|
4308
|
+
|
|
4309
|
+
// src/ui/inputs/VoiceFill.tsx
|
|
4310
|
+
import { useEffect as useEffect5, useRef as useRef7, useState as useState13 } from "react";
|
|
4311
|
+
function useVoiceFill({ speech, lang, filler, form, onFilled, onError }) {
|
|
4312
|
+
const [on, setOn] = useState13(false);
|
|
4313
|
+
const [filling, setFilling] = useState13(false);
|
|
4314
|
+
const [heard, setHeard] = useState13(null);
|
|
4315
|
+
const session = useRef7(null);
|
|
4316
|
+
const alive = useRef7(true);
|
|
4317
|
+
const latest = useRef7({ form, filler, onFilled, onError });
|
|
4318
|
+
useEffect5(() => {
|
|
4319
|
+
latest.current = { form, filler, onFilled, onError };
|
|
4320
|
+
});
|
|
4321
|
+
useEffect5(() => {
|
|
4322
|
+
alive.current = true;
|
|
4323
|
+
return () => {
|
|
4324
|
+
alive.current = false;
|
|
4325
|
+
session.current?.abort();
|
|
4326
|
+
};
|
|
4327
|
+
}, []);
|
|
4328
|
+
const fill = async (said) => {
|
|
4329
|
+
const { form: f, filler: run } = latest.current;
|
|
4330
|
+
if (!run) return;
|
|
4331
|
+
setFilling(true);
|
|
4332
|
+
let result;
|
|
4333
|
+
try {
|
|
4334
|
+
result = await run(f, said);
|
|
4335
|
+
} catch {
|
|
4336
|
+
result = { values: {}, problems: [{ key: "", problem: "Couldn\u2019t fill the form" }] };
|
|
4337
|
+
}
|
|
4338
|
+
if (!alive.current) return;
|
|
4339
|
+
setFilling(false);
|
|
4340
|
+
latest.current.onFilled(result, said);
|
|
4341
|
+
};
|
|
4342
|
+
const toggle = () => {
|
|
4343
|
+
if (!speech || !filler) return;
|
|
4344
|
+
if (session.current) {
|
|
4345
|
+
session.current.stop();
|
|
4346
|
+
return;
|
|
4347
|
+
}
|
|
4348
|
+
stopListening();
|
|
4349
|
+
setHeard(null);
|
|
4350
|
+
let mine = null;
|
|
4351
|
+
let ended = false;
|
|
4352
|
+
const end = () => {
|
|
4353
|
+
ended = true;
|
|
4354
|
+
if (session.current === mine) session.current = null;
|
|
4355
|
+
claimListening(mine, true);
|
|
4356
|
+
if (alive.current) {
|
|
4357
|
+
setOn(false);
|
|
4358
|
+
setHeard(null);
|
|
4359
|
+
}
|
|
4360
|
+
};
|
|
4361
|
+
try {
|
|
4362
|
+
mine = speech.start({
|
|
4363
|
+
lang,
|
|
4364
|
+
hints: fillHints(form),
|
|
4365
|
+
continuous: true,
|
|
4366
|
+
onText(text, final) {
|
|
4367
|
+
if (!final) return setHeard(text || null);
|
|
4368
|
+
if (text.trim()) fill(text.trim());
|
|
4369
|
+
},
|
|
4370
|
+
onError: (message) => alive.current && latest.current.onError(message),
|
|
4371
|
+
onEnd: end
|
|
4372
|
+
});
|
|
4373
|
+
} catch {
|
|
4374
|
+
onError("Dictation couldn\u2019t start");
|
|
4375
|
+
return;
|
|
4376
|
+
}
|
|
4377
|
+
if (!ended) {
|
|
4378
|
+
session.current = mine;
|
|
4379
|
+
claimListening(mine);
|
|
4380
|
+
setOn(true);
|
|
4381
|
+
}
|
|
4382
|
+
};
|
|
4383
|
+
return { available: !!speech && !!filler && form.fields.length > 0, listening: on, filling, heard, toggle };
|
|
4384
|
+
}
|
|
4385
|
+
|
|
4386
|
+
// src/ui/inputs/InputForm.tsx
|
|
4387
|
+
import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
4073
4388
|
var NO_CHOICES = {};
|
|
4074
4389
|
var NO_DEFAULTS = {};
|
|
4390
|
+
var webSpeech;
|
|
4391
|
+
var defaultSpeech = () => Platform2.OS === "web" ? webSpeech ??= webSpeechRecognizer() : null;
|
|
4075
4392
|
function savedValues(panels, entries) {
|
|
4076
4393
|
const values = {};
|
|
4077
4394
|
for (const p of panels) {
|
|
@@ -4101,19 +4418,23 @@ function baseItems(group, editing, last) {
|
|
|
4101
4418
|
return values.map((v, i) => ({ key: `b${i}`, values: v, edited: [] }));
|
|
4102
4419
|
}
|
|
4103
4420
|
var nextItemKey = 1;
|
|
4104
|
-
function InputForm({ dashboard, store, onSaved, choices = NO_CHOICES, header, timestamp, defaults: given = NO_DEFAULTS, beforeSave, editing }) {
|
|
4421
|
+
function InputForm({ dashboard, store, onSaved, choices = NO_CHOICES, header, timestamp, defaults: given = NO_DEFAULTS, beforeSave, editing, speech: givenSpeech, speechLang, filler = ruleFiller }) {
|
|
4422
|
+
const speech = givenSpeech === void 0 ? defaultSpeech() : givenSpeech;
|
|
4105
4423
|
const theme = useDashTheme();
|
|
4106
4424
|
const panels = useMemo10(() => plainInputPanels(dashboard), [dashboard]);
|
|
4107
4425
|
const groups = useMemo10(() => inputGroups(dashboard), [dashboard]);
|
|
4108
4426
|
const saved = useMemo10(() => editing ? savedValues(panels, editing) : NO_DEFAULTS, [panels, editing]);
|
|
4109
|
-
const [defaults, setDefaults] =
|
|
4110
|
-
const [edits, setEdits] =
|
|
4111
|
-
const [last, setLast] =
|
|
4112
|
-
const [groupEdits, setGroupEdits] =
|
|
4113
|
-
const [offsetMs, setOffsetMs] =
|
|
4114
|
-
const [status, setStatus] =
|
|
4115
|
-
const [checked, setChecked] =
|
|
4116
|
-
|
|
4427
|
+
const [defaults, setDefaults] = useState14({});
|
|
4428
|
+
const [edits, setEdits] = useState14({});
|
|
4429
|
+
const [last, setLast] = useState14({});
|
|
4430
|
+
const [groupEdits, setGroupEdits] = useState14({});
|
|
4431
|
+
const [offsetMs, setOffsetMs] = useState14(0);
|
|
4432
|
+
const [status, setStatus] = useState14(null);
|
|
4433
|
+
const [checked, setChecked] = useState14(false);
|
|
4434
|
+
const [filled, setFilled] = useState14({});
|
|
4435
|
+
const [beforeFill, setBeforeFill] = useState14(null);
|
|
4436
|
+
const fillable = useMemo10(() => fillForm(dashboard, choices), [dashboard, choices]);
|
|
4437
|
+
useEffect6(() => {
|
|
4117
4438
|
let run = 0;
|
|
4118
4439
|
const load = async () => {
|
|
4119
4440
|
const mine = ++run;
|
|
@@ -4149,10 +4470,19 @@ function InputForm({ dashboard, store, onSaved, choices = NO_CHOICES, header, ti
|
|
|
4149
4470
|
setValue: (m, v) => {
|
|
4150
4471
|
setStatus(null);
|
|
4151
4472
|
setEdits((e) => ({ ...e, [m]: v }));
|
|
4473
|
+
setFilled((f) => {
|
|
4474
|
+
if (!(m in f)) return f;
|
|
4475
|
+
const { [m]: _, ...rest } = f;
|
|
4476
|
+
return rest;
|
|
4477
|
+
});
|
|
4478
|
+
setBeforeFill(null);
|
|
4152
4479
|
},
|
|
4153
4480
|
isDirty: (m) => m in edits,
|
|
4481
|
+
filled: (m) => m in filled,
|
|
4154
4482
|
store,
|
|
4155
4483
|
choices,
|
|
4484
|
+
speech,
|
|
4485
|
+
speechLang,
|
|
4156
4486
|
problem: (m) => {
|
|
4157
4487
|
const p = panels.find((x) => x.options.metric === m);
|
|
4158
4488
|
return p && (checked || m in edits) ? inputProblem(p, value(m)) : void 0;
|
|
@@ -4162,7 +4492,30 @@ function InputForm({ dashboard, store, onSaved, choices = NO_CHOICES, header, ti
|
|
|
4162
4492
|
setGroupEdits((all) => ({ ...all, [groupKey(g)]: update(all[groupKey(g)] ?? base[groupKey(g)] ?? []) }));
|
|
4163
4493
|
})
|
|
4164
4494
|
};
|
|
4165
|
-
}, [edits, saved, defaults, given, store, choices, panels, checked, itemsOf, last, groupEdits, base]);
|
|
4495
|
+
}, [edits, saved, defaults, given, store, choices, speech, speechLang, panels, checked, itemsOf, last, groupEdits, base, filled]);
|
|
4496
|
+
const clearFill = () => {
|
|
4497
|
+
setFilled({});
|
|
4498
|
+
setBeforeFill(null);
|
|
4499
|
+
};
|
|
4500
|
+
const onFilled = useCallback4(
|
|
4501
|
+
(result, said) => {
|
|
4502
|
+
const keys = Object.keys(result.values);
|
|
4503
|
+
const label = (key) => fillable.fields.find((f) => f.key === key)?.label ?? key;
|
|
4504
|
+
const problem = result.problems[0];
|
|
4505
|
+
const problemText = problem ? problem.key ? `${label(problem.key)}: ${problem.problem.charAt(0).toLowerCase()}${problem.problem.slice(1)}` : problem.problem : "";
|
|
4506
|
+
if (!keys.length) {
|
|
4507
|
+
setStatus(problem ? `Couldn\u2019t fill. ${problemText}` : `Didn\u2019t catch any fields in \u201C${said}\u201D`);
|
|
4508
|
+
return;
|
|
4509
|
+
}
|
|
4510
|
+
setBeforeFill(edits);
|
|
4511
|
+
setEdits({ ...edits, ...result.values });
|
|
4512
|
+
setFilled(Object.fromEntries(keys.map((k) => [k, true])));
|
|
4513
|
+
const more = result.problems.length > 1 ? ` (+${result.problems.length - 1} more)` : "";
|
|
4514
|
+
setStatus(`Filled ${keys.length} ${keys.length === 1 ? "field" : "fields"}. Check, then Save${problem ? `. ${problemText}${more}` : ""}`);
|
|
4515
|
+
},
|
|
4516
|
+
[fillable, edits]
|
|
4517
|
+
);
|
|
4518
|
+
const voice = useVoiceFill({ speech, lang: speechLang, filler, form: fillable, onFilled, onError: setStatus });
|
|
4166
4519
|
const dirty = Object.keys(edits).length + groups.reduce((n, g) => n + groupChanges(base[groupKey(g)] ?? [], groupEdits[groupKey(g)]), 0);
|
|
4167
4520
|
const recordedGroups = useCallback4(
|
|
4168
4521
|
() => groups.filter((g) => editing || groupKey(g) in groupEdits || groupFields(g).some((f) => f.options.record === "always")),
|
|
@@ -4192,38 +4545,61 @@ function InputForm({ dashboard, store, onSaved, choices = NO_CHOICES, header, ti
|
|
|
4192
4545
|
setEdits({});
|
|
4193
4546
|
setGroupEdits({});
|
|
4194
4547
|
setChecked(false);
|
|
4548
|
+
clearFill();
|
|
4195
4549
|
setOffsetMs(0);
|
|
4196
4550
|
setStatus(`Saved ${added.length} ${added.length === 1 ? "value" : "values"}`);
|
|
4197
4551
|
onSaved?.(added.length, added);
|
|
4198
4552
|
}, [panels, edits, state, offsetMs, store, onSaved, header, timestamp, beforeSave, editing, recordedGroups, itemsOf]);
|
|
4199
|
-
return /* @__PURE__ */
|
|
4553
|
+
return /* @__PURE__ */ jsx18(InputFormContext.Provider, { value: state, children: /* @__PURE__ */ jsx18(DashboardProvider, { dashboard, children: /* @__PURE__ */ jsx18(
|
|
4200
4554
|
DashboardView,
|
|
4201
4555
|
{
|
|
4202
|
-
header: header !== void 0 ? header : /* @__PURE__ */
|
|
4203
|
-
footer: /* @__PURE__ */
|
|
4204
|
-
/* @__PURE__ */
|
|
4205
|
-
|
|
4206
|
-
|
|
4556
|
+
header: header !== void 0 ? header : /* @__PURE__ */ jsx18(TimestampPicker, { offsetMs, onChange: setOffsetMs }),
|
|
4557
|
+
footer: /* @__PURE__ */ jsxs16(View14, { style: [styles16.footer, { backgroundColor: theme.surface, borderTopColor: theme.border }], children: [
|
|
4558
|
+
voice.available && /* @__PURE__ */ jsx18(MicButton, { dictation: voice, label: "Fill the form by voice", size: 36 }),
|
|
4559
|
+
/* @__PURE__ */ jsx18(
|
|
4560
|
+
Text15,
|
|
4561
|
+
{
|
|
4562
|
+
style: [styles16.status, { color: status?.startsWith("Can\u2019t") || status?.startsWith("Couldn\u2019t") ? theme.danger : theme.textSecondary }],
|
|
4563
|
+
accessibilityLiveRegion: "polite",
|
|
4564
|
+
children: voice.listening ? voice.heard ? `\u201C${voice.heard}\u201D` : "Listening\u2026 say each field\u2019s name and its value, then tap to stop" : voice.filling ? "Filling\u2026" : status ?? (dirty ? `${dirty} unsaved ${dirty === 1 ? "change" : "changes"}` : "Nothing to save")
|
|
4565
|
+
}
|
|
4566
|
+
),
|
|
4567
|
+
beforeFill && /* @__PURE__ */ jsx18(
|
|
4568
|
+
Pressable14,
|
|
4569
|
+
{
|
|
4570
|
+
onPress: () => {
|
|
4571
|
+
setEdits(beforeFill);
|
|
4572
|
+
clearFill();
|
|
4573
|
+
setStatus(null);
|
|
4574
|
+
},
|
|
4575
|
+
style: styles16.secondary,
|
|
4576
|
+
accessibilityRole: "button",
|
|
4577
|
+
children: /* @__PURE__ */ jsx18(Text15, { style: { color: theme.textSecondary, fontWeight: "500" }, children: "Undo" })
|
|
4578
|
+
}
|
|
4579
|
+
),
|
|
4580
|
+
dirty > 0 && !beforeFill && /* @__PURE__ */ jsx18(
|
|
4581
|
+
Pressable14,
|
|
4207
4582
|
{
|
|
4208
4583
|
onPress: () => {
|
|
4209
4584
|
setEdits({});
|
|
4210
4585
|
setGroupEdits({});
|
|
4211
4586
|
setChecked(false);
|
|
4587
|
+
clearFill();
|
|
4212
4588
|
setStatus(null);
|
|
4213
4589
|
},
|
|
4214
|
-
style:
|
|
4590
|
+
style: styles16.secondary,
|
|
4215
4591
|
accessibilityRole: "button",
|
|
4216
|
-
children: /* @__PURE__ */
|
|
4592
|
+
children: /* @__PURE__ */ jsx18(Text15, { style: { color: theme.textSecondary, fontWeight: "500" }, children: "Discard" })
|
|
4217
4593
|
}
|
|
4218
4594
|
),
|
|
4219
|
-
/* @__PURE__ */
|
|
4220
|
-
|
|
4595
|
+
/* @__PURE__ */ jsx18(
|
|
4596
|
+
Pressable14,
|
|
4221
4597
|
{
|
|
4222
4598
|
onPress: save,
|
|
4223
4599
|
disabled: !dirty,
|
|
4224
4600
|
accessibilityRole: "button",
|
|
4225
|
-
style: ({ pressed }) => [
|
|
4226
|
-
children: /* @__PURE__ */
|
|
4601
|
+
style: ({ pressed }) => [styles16.save, { backgroundColor: theme.accent, opacity: !dirty ? 0.4 : pressed ? 0.8 : 1 }],
|
|
4602
|
+
children: /* @__PURE__ */ jsx18(Text15, { style: styles16.saveText, children: "Save" })
|
|
4227
4603
|
}
|
|
4228
4604
|
)
|
|
4229
4605
|
] })
|
|
@@ -4282,33 +4658,33 @@ async function replace(store, ids, entries) {
|
|
|
4282
4658
|
var HOUR = 36e5;
|
|
4283
4659
|
function TimestampPicker({ offsetMs, onChange }) {
|
|
4284
4660
|
const theme = useDashTheme();
|
|
4285
|
-
const [now, setNow] =
|
|
4286
|
-
|
|
4661
|
+
const [now, setNow] = useState14(() => Date.now());
|
|
4662
|
+
useEffect6(() => {
|
|
4287
4663
|
const id = setInterval(() => setNow(Date.now()), 3e4);
|
|
4288
4664
|
return () => clearInterval(id);
|
|
4289
4665
|
}, []);
|
|
4290
4666
|
const when = new Date(now + offsetMs);
|
|
4291
4667
|
const step = (ms) => () => onChange(Math.min(0, offsetMs + ms));
|
|
4292
|
-
return /* @__PURE__ */
|
|
4293
|
-
/* @__PURE__ */
|
|
4294
|
-
/* @__PURE__ */
|
|
4295
|
-
/* @__PURE__ */
|
|
4668
|
+
return /* @__PURE__ */ jsxs16(View14, { style: [styles16.when, { backgroundColor: theme.surface, borderColor: theme.border }], children: [
|
|
4669
|
+
/* @__PURE__ */ jsxs16(View14, { style: { flex: 1 }, children: [
|
|
4670
|
+
/* @__PURE__ */ jsx18(Text15, { style: [styles16.whenLabel, { color: theme.textMuted }], children: "Recording for" }),
|
|
4671
|
+
/* @__PURE__ */ jsx18(Text15, { style: [styles16.whenValue, { color: theme.text }], children: offsetMs === 0 ? "Now" : when.toLocaleString(void 0, { weekday: "short", month: "short", day: "numeric", hour: "numeric", minute: "2-digit" }) })
|
|
4296
4672
|
] }),
|
|
4297
4673
|
[
|
|
4298
4674
|
["\u22121d", -24 * HOUR],
|
|
4299
4675
|
["\u22121h", -HOUR],
|
|
4300
4676
|
["+1h", HOUR]
|
|
4301
|
-
].map(([label, ms]) => /* @__PURE__ */
|
|
4302
|
-
offsetMs !== 0 && /* @__PURE__ */
|
|
4677
|
+
].map(([label, ms]) => /* @__PURE__ */ jsx18(Pressable14, { onPress: step(ms), style: [styles16.stepBtn, { borderColor: theme.border }], accessibilityRole: "button", children: /* @__PURE__ */ jsx18(Text15, { style: { color: theme.text, fontSize: 13 }, children: label }) }, label)),
|
|
4678
|
+
offsetMs !== 0 && /* @__PURE__ */ jsx18(Pressable14, { onPress: () => onChange(0), style: [styles16.stepBtn, { borderColor: theme.accent }], accessibilityRole: "button", children: /* @__PURE__ */ jsx18(Text15, { style: { color: theme.accent, fontSize: 13, fontWeight: "600" }, children: "Now" }) })
|
|
4303
4679
|
] });
|
|
4304
4680
|
}
|
|
4305
|
-
var
|
|
4306
|
-
footer: { flexDirection: "row", alignItems: "center", gap: 12, paddingHorizontal: 16, paddingVertical: 10, borderTopWidth:
|
|
4681
|
+
var styles16 = StyleSheet16.create({
|
|
4682
|
+
footer: { flexDirection: "row", alignItems: "center", gap: 12, paddingHorizontal: 16, paddingVertical: 10, borderTopWidth: StyleSheet16.hairlineWidth },
|
|
4307
4683
|
status: { flex: 1, fontSize: 13 },
|
|
4308
4684
|
secondary: { paddingHorizontal: 8, paddingVertical: 10 },
|
|
4309
4685
|
save: { paddingHorizontal: 22, paddingVertical: 10, borderRadius: 8 },
|
|
4310
4686
|
saveText: { color: "#fff", fontWeight: "600", fontSize: 15 },
|
|
4311
|
-
when: { flexDirection: "row", alignItems: "center", gap: 6, padding: 12, borderRadius: 10, borderWidth:
|
|
4687
|
+
when: { flexDirection: "row", alignItems: "center", gap: 6, padding: 12, borderRadius: 10, borderWidth: StyleSheet16.hairlineWidth },
|
|
4312
4688
|
whenLabel: { fontSize: 11 },
|
|
4313
4689
|
whenValue: { fontSize: 15, fontWeight: "600" },
|
|
4314
4690
|
stepBtn: { paddingHorizontal: 10, paddingVertical: 6, borderRadius: 6, borderWidth: 1 }
|
|
@@ -4325,6 +4701,7 @@ export {
|
|
|
4325
4701
|
ConfigLoader,
|
|
4326
4702
|
DASHBOARD_DS,
|
|
4327
4703
|
DEFAULT_GAZETTEER,
|
|
4704
|
+
DICTATION_TYPES,
|
|
4328
4705
|
DOCUMENT_GUIDE,
|
|
4329
4706
|
DashThemeProvider,
|
|
4330
4707
|
DashboardProvider,
|
|
@@ -4390,6 +4767,7 @@ export {
|
|
|
4390
4767
|
dashboardSourceIds,
|
|
4391
4768
|
defaultFetchJson,
|
|
4392
4769
|
describeRange,
|
|
4770
|
+
dictationHints,
|
|
4393
4771
|
diffJson,
|
|
4394
4772
|
documentChanges,
|
|
4395
4773
|
documentIdFor,
|
|
@@ -4406,6 +4784,10 @@ export {
|
|
|
4406
4784
|
fetchJsonWithToken,
|
|
4407
4785
|
fieldDisplayName,
|
|
4408
4786
|
fieldMatches,
|
|
4787
|
+
fillForm,
|
|
4788
|
+
fillHints,
|
|
4789
|
+
fillPrompt,
|
|
4790
|
+
fillSchema,
|
|
4409
4791
|
fixDocumentPrompt,
|
|
4410
4792
|
fixTemplatePrompt,
|
|
4411
4793
|
formatClock,
|
|
@@ -4457,7 +4839,9 @@ export {
|
|
|
4457
4839
|
mappingProblem,
|
|
4458
4840
|
mappingRow,
|
|
4459
4841
|
mappingRows,
|
|
4842
|
+
matchChoices,
|
|
4460
4843
|
metricChanges,
|
|
4844
|
+
modelFiller,
|
|
4461
4845
|
movePanel,
|
|
4462
4846
|
newDocument,
|
|
4463
4847
|
newPanel,
|
|
@@ -4479,11 +4863,15 @@ export {
|
|
|
4479
4863
|
parseClockDigits,
|
|
4480
4864
|
parseDashboardLink,
|
|
4481
4865
|
parseDuration,
|
|
4866
|
+
parseFillAnswer,
|
|
4482
4867
|
parseGazetteer,
|
|
4483
4868
|
parseJsonText,
|
|
4484
4869
|
parseLocalDateTime,
|
|
4485
4870
|
parseRange,
|
|
4486
4871
|
parseSnippet,
|
|
4872
|
+
parseSpokenDuration,
|
|
4873
|
+
parseSpokenNumber,
|
|
4874
|
+
parseSpokenYesNo,
|
|
4487
4875
|
parseTemplate,
|
|
4488
4876
|
parseTime,
|
|
4489
4877
|
pasteSnippet,
|
|
@@ -4496,6 +4884,7 @@ export {
|
|
|
4496
4884
|
queryParam,
|
|
4497
4885
|
readConfigFiles,
|
|
4498
4886
|
readDocumentAnswer,
|
|
4887
|
+
readFill,
|
|
4499
4888
|
readTemplateAnswer,
|
|
4500
4889
|
readingOrder,
|
|
4501
4890
|
reduce,
|
|
@@ -4519,6 +4908,8 @@ export {
|
|
|
4519
4908
|
resolveVariables,
|
|
4520
4909
|
revalidateBundle,
|
|
4521
4910
|
rowsToMappings,
|
|
4911
|
+
ruleFill,
|
|
4912
|
+
ruleFiller,
|
|
4522
4913
|
sameSave,
|
|
4523
4914
|
sampleEntries,
|
|
4524
4915
|
screenDocuments,
|
|
@@ -4533,9 +4924,11 @@ export {
|
|
|
4533
4924
|
settleLayout,
|
|
4534
4925
|
snapToGrid,
|
|
4535
4926
|
splitPath,
|
|
4927
|
+
spokenValue,
|
|
4536
4928
|
startOf,
|
|
4537
4929
|
stringifyCompact,
|
|
4538
4930
|
tabIdFor,
|
|
4931
|
+
takesDictation,
|
|
4539
4932
|
templateNeeds,
|
|
4540
4933
|
templatePrompt,
|
|
4541
4934
|
textSuggestions,
|
|
@@ -4568,5 +4961,6 @@ export {
|
|
|
4568
4961
|
variableWithQuery,
|
|
4569
4962
|
variableWithType,
|
|
4570
4963
|
visibleVariables,
|
|
4964
|
+
webSpeechRecognizer,
|
|
4571
4965
|
zoomRange
|
|
4572
4966
|
};
|