@modelform/react-native 0.11.0 → 0.13.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 +41 -1
- package/dist/{chunk-KJR3ZKG4.js → chunk-CU4TMSZE.js} +399 -130
- package/dist/{chunk-AJEPW5KG.mjs → chunk-OFXIKI2L.mjs} +310 -41
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +20 -2
- package/dist/core/index.mjs +19 -1
- package/dist/core/manifest.d.ts +20 -1
- package/dist/core/speech.d.ts +36 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +698 -465
- package/dist/index.mjs +687 -454
- package/dist/ui/inputs/Dictation.d.ts +24 -0
- package/dist/ui/inputs/InputForm.d.ts +10 -1
- package/dist/ui/inputs/formContext.d.ts +5 -0
- package/dist/ui/speech.d.ts +29 -0
- package/package.json +1 -1
- package/schema/app.schema.json +3 -2
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,
|
|
@@ -127,6 +129,7 @@ import {
|
|
|
127
129
|
mappingProblem,
|
|
128
130
|
mappingRow,
|
|
129
131
|
mappingRows,
|
|
132
|
+
matchChoices,
|
|
130
133
|
metricChanges,
|
|
131
134
|
movePanel,
|
|
132
135
|
newDocument,
|
|
@@ -154,6 +157,9 @@ import {
|
|
|
154
157
|
parseLocalDateTime,
|
|
155
158
|
parseRange,
|
|
156
159
|
parseSnippet,
|
|
160
|
+
parseSpokenDuration,
|
|
161
|
+
parseSpokenNumber,
|
|
162
|
+
parseSpokenYesNo,
|
|
157
163
|
parseTemplate,
|
|
158
164
|
parseTime,
|
|
159
165
|
pasteSnippet,
|
|
@@ -178,6 +184,7 @@ import {
|
|
|
178
184
|
renameVariableInPanels,
|
|
179
185
|
repack,
|
|
180
186
|
repeatOptions,
|
|
187
|
+
requiredManifestVersion,
|
|
181
188
|
resizePanel,
|
|
182
189
|
resolveColor,
|
|
183
190
|
resolveFieldConfig,
|
|
@@ -201,9 +208,11 @@ import {
|
|
|
201
208
|
settleLayout,
|
|
202
209
|
snapToGrid,
|
|
203
210
|
splitPath,
|
|
211
|
+
spokenValue,
|
|
204
212
|
startOf,
|
|
205
213
|
stringifyCompact,
|
|
206
214
|
tabIdFor,
|
|
215
|
+
takesDictation,
|
|
207
216
|
templateNeeds,
|
|
208
217
|
templatePrompt,
|
|
209
218
|
textSuggestions,
|
|
@@ -233,7 +242,7 @@ import {
|
|
|
233
242
|
variableWithType,
|
|
234
243
|
visibleVariables,
|
|
235
244
|
zoomRange
|
|
236
|
-
} from "./chunk-
|
|
245
|
+
} from "./chunk-OFXIKI2L.mjs";
|
|
237
246
|
|
|
238
247
|
// src/ui/theme.tsx
|
|
239
248
|
import { createContext, useContext } from "react";
|
|
@@ -585,14 +594,14 @@ function usePanelLinks(panel) {
|
|
|
585
594
|
}
|
|
586
595
|
|
|
587
596
|
// src/ui/DashboardView.tsx
|
|
588
|
-
import { useCallback as useCallback3, useContext as useContext4, useMemo as useMemo9, useRef as
|
|
597
|
+
import { useCallback as useCallback3, useContext as useContext4, useMemo as useMemo9, useRef as useRef6, useState as useState12 } from "react";
|
|
589
598
|
import {
|
|
590
599
|
ActivityIndicator,
|
|
591
|
-
Pressable as
|
|
600
|
+
Pressable as Pressable13,
|
|
592
601
|
RefreshControl,
|
|
593
602
|
ScrollView as ScrollView6,
|
|
594
|
-
StyleSheet as
|
|
595
|
-
Text as
|
|
603
|
+
StyleSheet as StyleSheet15,
|
|
604
|
+
Text as Text14,
|
|
596
605
|
View as View13,
|
|
597
606
|
useWindowDimensions
|
|
598
607
|
} from "react-native";
|
|
@@ -628,12 +637,12 @@ function useInputForm() {
|
|
|
628
637
|
}
|
|
629
638
|
|
|
630
639
|
// src/ui/inputs/InputGroup.tsx
|
|
631
|
-
import { useMemo as useMemo2, useRef as
|
|
632
|
-
import { Pressable as
|
|
640
|
+
import { useMemo as useMemo2, useRef as useRef3, useState as useState7 } from "react";
|
|
641
|
+
import { Pressable as Pressable7, ScrollView as ScrollView4, StyleSheet as StyleSheet8, Text as Text8, View as View6 } from "react-native";
|
|
633
642
|
|
|
634
643
|
// src/ui/inputs/InputPanels.tsx
|
|
635
|
-
import { useEffect as
|
|
636
|
-
import { Platform, Pressable as
|
|
644
|
+
import { useEffect as useEffect3, useState as useState6 } from "react";
|
|
645
|
+
import { Platform, Pressable as Pressable6, ScrollView as ScrollView3, StyleSheet as StyleSheet7, Switch, Text as Text7, TextInput as TextInput2, View as View5 } from "react-native";
|
|
637
646
|
|
|
638
647
|
// src/ui/Toolbar.tsx
|
|
639
648
|
import { useState as useState3 } from "react";
|
|
@@ -1407,29 +1416,134 @@ var styles5 = StyleSheet5.create({
|
|
|
1407
1416
|
tooltipValue: { fontSize: 12, fontWeight: "600", marginLeft: "auto", paddingLeft: 8 }
|
|
1408
1417
|
});
|
|
1409
1418
|
|
|
1410
|
-
// src/ui/inputs/
|
|
1419
|
+
// src/ui/inputs/Dictation.tsx
|
|
1420
|
+
import { useEffect as useEffect2, useRef as useRef2, useState as useState5 } from "react";
|
|
1421
|
+
import { Pressable as Pressable5, StyleSheet as StyleSheet6, Text as Text6 } from "react-native";
|
|
1422
|
+
import Svg4, { Path as Path4 } from "react-native-svg";
|
|
1411
1423
|
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1424
|
+
var listening = null;
|
|
1425
|
+
var HINT_MS = 4e3;
|
|
1426
|
+
function useDictation(panel, value, onChange, choices) {
|
|
1427
|
+
const form = useInputForm();
|
|
1428
|
+
const speech = form.speech;
|
|
1429
|
+
const [on, setOn] = useState5(false);
|
|
1430
|
+
const [hint, setHint] = useState5(null);
|
|
1431
|
+
const session = useRef2(null);
|
|
1432
|
+
const latest = useRef2({ value, onChange, choices });
|
|
1433
|
+
useEffect2(() => {
|
|
1434
|
+
latest.current = { value, onChange, choices };
|
|
1435
|
+
});
|
|
1436
|
+
useEffect2(
|
|
1437
|
+
() => () => {
|
|
1438
|
+
session.current?.abort();
|
|
1439
|
+
},
|
|
1440
|
+
[]
|
|
1441
|
+
);
|
|
1442
|
+
useEffect2(() => {
|
|
1443
|
+
if (on || !hint) return;
|
|
1444
|
+
const t = setTimeout(() => setHint(null), HINT_MS);
|
|
1445
|
+
return () => clearTimeout(t);
|
|
1446
|
+
}, [on, hint]);
|
|
1447
|
+
const toggle = () => {
|
|
1448
|
+
if (!speech) return;
|
|
1449
|
+
if (session.current) {
|
|
1450
|
+
session.current.stop();
|
|
1451
|
+
return;
|
|
1452
|
+
}
|
|
1453
|
+
listening?.abort();
|
|
1454
|
+
setHint(null);
|
|
1455
|
+
let mine = null;
|
|
1456
|
+
let ended = false;
|
|
1457
|
+
const end = () => {
|
|
1458
|
+
ended = true;
|
|
1459
|
+
if (session.current === mine) session.current = null;
|
|
1460
|
+
if (listening === mine) listening = null;
|
|
1461
|
+
setOn(false);
|
|
1462
|
+
};
|
|
1463
|
+
try {
|
|
1464
|
+
mine = speech.start({
|
|
1465
|
+
lang: form.speechLang,
|
|
1466
|
+
hints: dictationHints(panel, choices),
|
|
1467
|
+
onText(text, final) {
|
|
1468
|
+
if (!final) return setHint(text ? `\u201C${text}\u201D` : null);
|
|
1469
|
+
const result = spokenValue(panel, text, latest.current.value, latest.current.choices);
|
|
1470
|
+
if ("value" in result) {
|
|
1471
|
+
latest.current.onChange(result.value);
|
|
1472
|
+
setHint(null);
|
|
1473
|
+
} else setHint(result.problem);
|
|
1474
|
+
},
|
|
1475
|
+
onError: (message) => setHint(message),
|
|
1476
|
+
onEnd: end
|
|
1477
|
+
});
|
|
1478
|
+
} catch {
|
|
1479
|
+
setHint("Dictation couldn\u2019t start");
|
|
1480
|
+
return;
|
|
1481
|
+
}
|
|
1482
|
+
if (!ended) {
|
|
1483
|
+
session.current = mine;
|
|
1484
|
+
listening = mine;
|
|
1485
|
+
setOn(true);
|
|
1486
|
+
}
|
|
1487
|
+
};
|
|
1488
|
+
return { available: !!speech && takesDictation(panel), listening: on, hint, toggle };
|
|
1489
|
+
}
|
|
1490
|
+
function MicButton({ dictation, title, size = 32 }) {
|
|
1491
|
+
const theme = useDashTheme();
|
|
1492
|
+
if (!dictation.available) return null;
|
|
1493
|
+
const on = dictation.listening;
|
|
1494
|
+
return /* @__PURE__ */ jsx8(
|
|
1495
|
+
Pressable5,
|
|
1496
|
+
{
|
|
1497
|
+
onPress: dictation.toggle,
|
|
1498
|
+
accessibilityRole: "button",
|
|
1499
|
+
accessibilityLabel: on ? "Stop dictating" : title ? `Dictate ${title}` : "Dictate",
|
|
1500
|
+
accessibilityState: { selected: on },
|
|
1501
|
+
hitSlop: 6,
|
|
1502
|
+
style: ({ pressed }) => [
|
|
1503
|
+
styles6.mic,
|
|
1504
|
+
{ width: size, height: size, borderRadius: size / 2, borderColor: on ? theme.accent : theme.border },
|
|
1505
|
+
{ backgroundColor: on ? theme.accent : pressed ? theme.grid : theme.surface }
|
|
1506
|
+
],
|
|
1507
|
+
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: [
|
|
1508
|
+
/* @__PURE__ */ jsx8(Path4, { d: "M12 3a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V6a3 3 0 0 0-3-3z" }),
|
|
1509
|
+
/* @__PURE__ */ jsx8(Path4, { d: "M19 11a7 7 0 0 1-14 0M12 18v3" })
|
|
1510
|
+
] })
|
|
1511
|
+
}
|
|
1512
|
+
);
|
|
1513
|
+
}
|
|
1514
|
+
function DictationHint({ dictation }) {
|
|
1515
|
+
const theme = useDashTheme();
|
|
1516
|
+
if (!dictation.hint) return null;
|
|
1517
|
+
return /* @__PURE__ */ jsx8(Text6, { style: [styles6.hint, { color: dictation.listening ? theme.textSecondary : theme.textMuted }], numberOfLines: 1, accessibilityLiveRegion: "polite", children: dictation.hint });
|
|
1518
|
+
}
|
|
1519
|
+
var styles6 = StyleSheet6.create({
|
|
1520
|
+
mic: { borderWidth: 1, alignItems: "center", justifyContent: "center" },
|
|
1521
|
+
hint: { fontSize: 12, fontStyle: "italic" }
|
|
1522
|
+
});
|
|
1523
|
+
|
|
1524
|
+
// src/ui/inputs/InputPanels.tsx
|
|
1525
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1412
1526
|
function InputPanelBody({ panel }) {
|
|
1413
1527
|
const form = useInputForm();
|
|
1414
1528
|
const metric = panel.options.metric;
|
|
1415
1529
|
const props = { panel, value: form.value(metric), onChange: (v) => form.setValue(metric, v) };
|
|
1416
1530
|
switch (panel.type) {
|
|
1417
1531
|
case "input-number":
|
|
1418
|
-
return /* @__PURE__ */
|
|
1532
|
+
return /* @__PURE__ */ jsx9(NumberInput, { ...props });
|
|
1419
1533
|
case "input-slider":
|
|
1420
|
-
return /* @__PURE__ */
|
|
1534
|
+
return /* @__PURE__ */ jsx9(SliderInput, { ...props });
|
|
1421
1535
|
case "input-select":
|
|
1422
|
-
return /* @__PURE__ */
|
|
1536
|
+
return /* @__PURE__ */ jsx9(SelectInput, { ...props });
|
|
1423
1537
|
case "input-toggle":
|
|
1424
|
-
return /* @__PURE__ */
|
|
1538
|
+
return /* @__PURE__ */ jsx9(ToggleInput, { ...props });
|
|
1425
1539
|
case "input-rating":
|
|
1426
|
-
return /* @__PURE__ */
|
|
1540
|
+
return /* @__PURE__ */ jsx9(RatingInput, { ...props });
|
|
1427
1541
|
case "input-text":
|
|
1428
|
-
return panel.options.suggest ? /* @__PURE__ */
|
|
1542
|
+
return panel.options.suggest ? /* @__PURE__ */ jsx9(SuggestTextInput, { ...props }) : /* @__PURE__ */ jsx9(FreeTextInput, { ...props });
|
|
1429
1543
|
case "input-counter":
|
|
1430
|
-
return /* @__PURE__ */
|
|
1544
|
+
return /* @__PURE__ */ jsx9(CounterInput, { panel });
|
|
1431
1545
|
case "input-duration":
|
|
1432
|
-
return /* @__PURE__ */
|
|
1546
|
+
return /* @__PURE__ */ jsx9(DurationInput, { ...props });
|
|
1433
1547
|
default:
|
|
1434
1548
|
return null;
|
|
1435
1549
|
}
|
|
@@ -1439,10 +1553,10 @@ var decimalsOf = (step) => (String(step).split(".")[1] ?? "").length;
|
|
|
1439
1553
|
function NumberInput({ panel, value, onChange }) {
|
|
1440
1554
|
const theme = useDashTheme();
|
|
1441
1555
|
const { step = 1, min, max, unit, placeholder } = panel.options;
|
|
1442
|
-
const [text, setText] =
|
|
1556
|
+
const [text, setText] = useState6(value == null ? "" : String(value));
|
|
1443
1557
|
const [size, onLayout] = useLayout();
|
|
1444
1558
|
const compact = size.width > 0 && size.width < COMPACT_NUMBER_WIDTH;
|
|
1445
|
-
const [syncedValue, setSyncedValue] =
|
|
1559
|
+
const [syncedValue, setSyncedValue] = useState6(value);
|
|
1446
1560
|
if (value !== syncedValue) {
|
|
1447
1561
|
setSyncedValue(value);
|
|
1448
1562
|
setText((t) => value == null ? "" : Number(t.replace(",", ".")) === value && t.trim() ? t : String(value));
|
|
@@ -1455,61 +1569,73 @@ function NumberInput({ panel, value, onChange }) {
|
|
|
1455
1569
|
const base = typeof value === "number" ? value : Number(text) || 0;
|
|
1456
1570
|
onChange(Number(clamp2(base + dir * step).toFixed(decimalsOf(step))));
|
|
1457
1571
|
};
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
/* @__PURE__ */
|
|
1461
|
-
/* @__PURE__ */
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1572
|
+
const dictation = useDictation(panel, value, onChange);
|
|
1573
|
+
return /* @__PURE__ */ jsxs7(View5, { style: styles7.dictated, children: [
|
|
1574
|
+
/* @__PURE__ */ jsxs7(View5, { style: [styles7.numberRow, compact && styles7.numberRowCompact], onLayout, children: [
|
|
1575
|
+
/* @__PURE__ */ jsx9(StepButton, { label: "\u2212", onPress: () => bump(-1), compact }),
|
|
1576
|
+
/* @__PURE__ */ jsxs7(View5, { style: [styles7.numberField, compact && styles7.numberFieldCompact, { borderColor: theme.border }], children: [
|
|
1577
|
+
/* @__PURE__ */ jsx9(
|
|
1578
|
+
TextInput2,
|
|
1579
|
+
{
|
|
1580
|
+
value: text,
|
|
1581
|
+
onChangeText: (t) => {
|
|
1582
|
+
setText(t);
|
|
1583
|
+
const n = Number(t.replace(",", "."));
|
|
1584
|
+
if (t.trim() && !Number.isNaN(n)) onChange(clamp2(integer ? Math.round(n) : n));
|
|
1585
|
+
else if (!t.trim()) onChange(null);
|
|
1586
|
+
},
|
|
1587
|
+
keyboardType,
|
|
1588
|
+
placeholder: placeholder ?? "\u2014",
|
|
1589
|
+
placeholderTextColor: theme.textMuted,
|
|
1590
|
+
style: [styles7.numberText, compact && styles7.numberTextCompact, { color: theme.text }],
|
|
1591
|
+
accessibilityLabel: unit ? `${panel.title} (${unit})` : panel.title,
|
|
1592
|
+
selectTextOnFocus: true
|
|
1593
|
+
}
|
|
1594
|
+
),
|
|
1595
|
+
unit && !compact ? /* @__PURE__ */ jsx9(Text7, { style: [styles7.unit, { color: theme.textMuted }], children: unit }) : null,
|
|
1596
|
+
/* @__PURE__ */ jsx9(MicButton, { dictation, title: panel.title, size: compact ? 24 : 28 })
|
|
1597
|
+
] }),
|
|
1598
|
+
/* @__PURE__ */ jsx9(StepButton, { label: "+", onPress: () => bump(1), compact })
|
|
1480
1599
|
] }),
|
|
1481
|
-
/* @__PURE__ */
|
|
1600
|
+
/* @__PURE__ */ jsx9(DictationHint, { dictation })
|
|
1482
1601
|
] });
|
|
1483
1602
|
}
|
|
1484
1603
|
function DurationInput({ panel, value, onChange }) {
|
|
1485
1604
|
const theme = useDashTheme();
|
|
1486
1605
|
const toDigits = (v) => typeof v === "number" ? formatClock(v).replace(/\D/g, "").replace(/^0+/, "") : "";
|
|
1487
|
-
const [digits, setDigits] =
|
|
1488
|
-
const [syncedValue, setSyncedValue] =
|
|
1606
|
+
const [digits, setDigits] = useState6(toDigits(value));
|
|
1607
|
+
const [syncedValue, setSyncedValue] = useState6(value);
|
|
1489
1608
|
if (value !== syncedValue) {
|
|
1490
1609
|
setSyncedValue(value);
|
|
1491
1610
|
setDigits((d) => value == null ? parseClockDigits(d) == null ? d : "" : parseClockDigits(d) === value ? d : toDigits(value));
|
|
1492
1611
|
}
|
|
1493
1612
|
const masked = digits ? maskClock(digits) : "";
|
|
1494
1613
|
const invalid = !!digits && parseClockDigits(digits) == null;
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
{
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1614
|
+
const dictation = useDictation(panel, value, onChange);
|
|
1615
|
+
return /* @__PURE__ */ jsxs7(View5, { style: styles7.dictated, children: [
|
|
1616
|
+
/* @__PURE__ */ jsxs7(View5, { style: [styles7.numberField, { borderColor: invalid ? theme.danger : theme.border }], children: [
|
|
1617
|
+
/* @__PURE__ */ jsx9(
|
|
1618
|
+
TextInput2,
|
|
1619
|
+
{
|
|
1620
|
+
value: masked,
|
|
1621
|
+
onChangeText: (t) => {
|
|
1622
|
+
const d = t.replace(/\D/g, "").replace(/^0+/, "").slice(0, 6);
|
|
1623
|
+
setDigits(d);
|
|
1624
|
+
onChange(parseClockDigits(d));
|
|
1625
|
+
},
|
|
1626
|
+
keyboardType: "number-pad",
|
|
1627
|
+
placeholder: panel.options.placeholder ?? "00:00.00",
|
|
1628
|
+
placeholderTextColor: theme.textMuted,
|
|
1629
|
+
style: [styles7.numberText, { color: invalid ? theme.danger : theme.text }],
|
|
1630
|
+
accessibilityLabel: panel.title,
|
|
1631
|
+
accessibilityHint: "Type the digits only, for example 13245 for 1 minute 32.45 seconds",
|
|
1632
|
+
selection: { start: masked.length, end: masked.length }
|
|
1633
|
+
}
|
|
1634
|
+
),
|
|
1635
|
+
/* @__PURE__ */ jsx9(MicButton, { dictation, title: panel.title, size: 28 })
|
|
1636
|
+
] }),
|
|
1637
|
+
/* @__PURE__ */ jsx9(DictationHint, { dictation })
|
|
1638
|
+
] });
|
|
1513
1639
|
}
|
|
1514
1640
|
function maskClock(digits) {
|
|
1515
1641
|
const p = digits.slice(-6).padStart(6, "0");
|
|
@@ -1517,14 +1643,14 @@ function maskClock(digits) {
|
|
|
1517
1643
|
}
|
|
1518
1644
|
function StepButton({ label, onPress, compact }) {
|
|
1519
1645
|
const theme = useDashTheme();
|
|
1520
|
-
return /* @__PURE__ */
|
|
1521
|
-
|
|
1646
|
+
return /* @__PURE__ */ jsx9(
|
|
1647
|
+
Pressable6,
|
|
1522
1648
|
{
|
|
1523
1649
|
onPress,
|
|
1524
1650
|
accessibilityRole: "button",
|
|
1525
1651
|
accessibilityLabel: label === "+" ? "Increase" : "Decrease",
|
|
1526
|
-
style: ({ pressed }) => [
|
|
1527
|
-
children: /* @__PURE__ */
|
|
1652
|
+
style: ({ pressed }) => [styles7.stepBtn, compact && styles7.stepBtnCompact, { borderColor: theme.border, backgroundColor: pressed ? theme.grid : theme.surface }],
|
|
1653
|
+
children: /* @__PURE__ */ jsx9(Text7, { style: [styles7.stepText, { color: theme.text }], children: label })
|
|
1528
1654
|
}
|
|
1529
1655
|
);
|
|
1530
1656
|
}
|
|
@@ -1548,17 +1674,17 @@ function SliderInput({ panel, value, onChange }) {
|
|
|
1548
1674
|
const raw = min + Math.min(1, Math.max(0, x / size.width)) * (max - min);
|
|
1549
1675
|
onChange(Number((Math.round((raw - min) / step) * step + min).toFixed(decimalsOf(step))));
|
|
1550
1676
|
};
|
|
1551
|
-
return /* @__PURE__ */
|
|
1552
|
-
/* @__PURE__ */
|
|
1553
|
-
!labels?.length && /* @__PURE__ */
|
|
1554
|
-
/* @__PURE__ */
|
|
1555
|
-
!labels?.length && /* @__PURE__ */
|
|
1677
|
+
return /* @__PURE__ */ jsxs7(View5, { style: styles7.sliderWrap, children: [
|
|
1678
|
+
/* @__PURE__ */ jsxs7(View5, { style: styles7.sliderLabels, children: [
|
|
1679
|
+
!labels?.length && /* @__PURE__ */ jsx9(Text7, { style: [styles7.minmax, { color: theme.textMuted }], children: min }),
|
|
1680
|
+
/* @__PURE__ */ jsx9(Text7, { style: [styles7.sliderValue, { color: theme.text }, !!labels?.length && styles7.sliderValueCentered], children: display }),
|
|
1681
|
+
!labels?.length && /* @__PURE__ */ jsx9(Text7, { style: [styles7.minmax, { color: theme.textMuted }], children: max })
|
|
1556
1682
|
] }),
|
|
1557
|
-
/* @__PURE__ */
|
|
1683
|
+
/* @__PURE__ */ jsxs7(
|
|
1558
1684
|
View5,
|
|
1559
1685
|
{
|
|
1560
1686
|
onLayout,
|
|
1561
|
-
style:
|
|
1687
|
+
style: styles7.sliderHit,
|
|
1562
1688
|
onStartShouldSetResponder: () => true,
|
|
1563
1689
|
onMoveShouldSetResponder: () => true,
|
|
1564
1690
|
onResponderTerminationRequest: () => false,
|
|
@@ -1569,29 +1695,29 @@ function SliderInput({ panel, value, onChange }) {
|
|
|
1569
1695
|
accessibilityActions: [{ name: "increment" }, { name: "decrement" }],
|
|
1570
1696
|
onAccessibilityAction: (e) => onChange(Math.min(max, Math.max(min, (v ?? min) + (e.nativeEvent.actionName === "increment" ? step : -step)))),
|
|
1571
1697
|
children: [
|
|
1572
|
-
/* @__PURE__ */
|
|
1698
|
+
/* @__PURE__ */ jsx9(View5, { pointerEvents: "none", style: [styles7.track, { backgroundColor: theme.grid }], children: /* @__PURE__ */ jsx9(
|
|
1573
1699
|
View5,
|
|
1574
1700
|
{
|
|
1575
1701
|
style: [
|
|
1576
|
-
|
|
1702
|
+
styles7.trackFill,
|
|
1577
1703
|
{ left: `${fillStart * 100}%`, width: `${v == null ? 0 : Math.abs(frac - origin) * 100}%`, backgroundColor: theme.accent }
|
|
1578
1704
|
]
|
|
1579
1705
|
}
|
|
1580
1706
|
) }),
|
|
1581
|
-
v != null && /* @__PURE__ */
|
|
1707
|
+
v != null && /* @__PURE__ */ jsx9(
|
|
1582
1708
|
View5,
|
|
1583
1709
|
{
|
|
1584
1710
|
pointerEvents: "none",
|
|
1585
|
-
style: [
|
|
1711
|
+
style: [styles7.thumb, { left: frac * size.width - 11, backgroundColor: theme.accent, borderColor: theme.surface }]
|
|
1586
1712
|
}
|
|
1587
1713
|
)
|
|
1588
1714
|
]
|
|
1589
1715
|
}
|
|
1590
1716
|
),
|
|
1591
|
-
!!labels?.length && /* @__PURE__ */
|
|
1717
|
+
!!labels?.length && /* @__PURE__ */ jsx9(View5, { style: styles7.tickRow, children: labels.map((l, i) => {
|
|
1592
1718
|
const last = labels.length - 1;
|
|
1593
|
-
const edge = i === 0 ?
|
|
1594
|
-
return /* @__PURE__ */
|
|
1719
|
+
const edge = i === 0 ? styles7.tickStart : i === last ? styles7.tickEnd : { left: `${i / last * 100}%` };
|
|
1720
|
+
return /* @__PURE__ */ jsx9(Text7, { style: [styles7.minmax, styles7.tick, edge, { color: theme.textMuted }], numberOfLines: 1, children: l }, i);
|
|
1595
1721
|
}) })
|
|
1596
1722
|
] });
|
|
1597
1723
|
}
|
|
@@ -1601,29 +1727,36 @@ function SelectInput({ panel, value, onChange }) {
|
|
|
1601
1727
|
const { choicesFrom, multi, placeholder } = panel.options;
|
|
1602
1728
|
const choices = (choicesFrom ? form.choices[choicesFrom] : panel.options.choices) ?? [];
|
|
1603
1729
|
const selected = Array.isArray(value) ? value : value == null ? [] : [value];
|
|
1604
|
-
|
|
1605
|
-
return /* @__PURE__ */
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1730
|
+
const dictation = useDictation(panel, value, onChange, choices);
|
|
1731
|
+
if (!choices.length && placeholder) return /* @__PURE__ */ jsx9(Text7, { style: { color: theme.textMuted }, children: placeholder });
|
|
1732
|
+
return /* @__PURE__ */ jsxs7(View5, { style: styles7.selectWrap, children: [
|
|
1733
|
+
/* @__PURE__ */ jsxs7(View5, { style: styles7.wrap, children: [
|
|
1734
|
+
choices.map((c) => {
|
|
1735
|
+
const on = selected.includes(c.value);
|
|
1736
|
+
return /* @__PURE__ */ jsx9(
|
|
1737
|
+
Chip,
|
|
1738
|
+
{
|
|
1739
|
+
label: c.label,
|
|
1740
|
+
selected: on,
|
|
1741
|
+
onPress: () => {
|
|
1742
|
+
if (!multi) return onChange(on ? null : c.value);
|
|
1743
|
+
const next = on ? selected.filter((s) => s !== c.value) : [...selected, c.value];
|
|
1744
|
+
onChange(next.length ? next : null);
|
|
1745
|
+
}
|
|
1746
|
+
},
|
|
1747
|
+
String(c.value)
|
|
1748
|
+
);
|
|
1749
|
+
}),
|
|
1750
|
+
choices.length > 0 && /* @__PURE__ */ jsx9(MicButton, { dictation, title: panel.title })
|
|
1751
|
+
] }),
|
|
1752
|
+
/* @__PURE__ */ jsx9(DictationHint, { dictation })
|
|
1753
|
+
] });
|
|
1621
1754
|
}
|
|
1622
1755
|
function ToggleInput({ panel, value, onChange }) {
|
|
1623
1756
|
const theme = useDashTheme();
|
|
1624
|
-
return /* @__PURE__ */
|
|
1625
|
-
/* @__PURE__ */
|
|
1626
|
-
/* @__PURE__ */
|
|
1757
|
+
return /* @__PURE__ */ jsxs7(View5, { style: styles7.toggleRow, children: [
|
|
1758
|
+
/* @__PURE__ */ jsx9(Text7, { style: { color: theme.textSecondary, flex: 1 }, children: value == null ? "Not set" : value ? "Yes" : "No" }),
|
|
1759
|
+
/* @__PURE__ */ jsx9(Switch, { value: !!value, onValueChange: (v) => onChange(v), trackColor: { true: theme.accent }, accessibilityLabel: panel.title })
|
|
1627
1760
|
] });
|
|
1628
1761
|
}
|
|
1629
1762
|
var MAX_RATING_LEVELS = 10;
|
|
@@ -1632,17 +1765,17 @@ function RatingInput({ panel, value, onChange }) {
|
|
|
1632
1765
|
const min = Math.round(panel.options.min ?? 1);
|
|
1633
1766
|
const max = Math.round(panel.options.max ?? 5);
|
|
1634
1767
|
const levels = Array.from({ length: Math.min(Math.max(0, max - min + 1), MAX_RATING_LEVELS) }, (_, i) => min + i);
|
|
1635
|
-
return /* @__PURE__ */
|
|
1768
|
+
return /* @__PURE__ */ jsx9(View5, { style: styles7.rating, children: levels.map((n) => {
|
|
1636
1769
|
const on = typeof value === "number" && n <= value;
|
|
1637
|
-
return /* @__PURE__ */
|
|
1638
|
-
|
|
1770
|
+
return /* @__PURE__ */ jsx9(
|
|
1771
|
+
Pressable6,
|
|
1639
1772
|
{
|
|
1640
1773
|
onPress: () => onChange(value === n ? null : n),
|
|
1641
1774
|
accessibilityRole: "button",
|
|
1642
1775
|
accessibilityLabel: `${n} of ${max}`,
|
|
1643
1776
|
accessibilityState: { selected: value === n },
|
|
1644
|
-
style: [
|
|
1645
|
-
children: /* @__PURE__ */
|
|
1777
|
+
style: [styles7.ratingDot, { borderColor: on ? theme.accent : theme.border, backgroundColor: on ? theme.accent : theme.surface }],
|
|
1778
|
+
children: /* @__PURE__ */ jsx9(Text7, { style: { color: on ? "#fff" : theme.textSecondary, fontWeight: "600" }, children: n })
|
|
1646
1779
|
},
|
|
1647
1780
|
n
|
|
1648
1781
|
);
|
|
@@ -1650,27 +1783,35 @@ function RatingInput({ panel, value, onChange }) {
|
|
|
1650
1783
|
}
|
|
1651
1784
|
function FreeTextInput({ panel, value, onChange }) {
|
|
1652
1785
|
const theme = useDashTheme();
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
{
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1786
|
+
const dictation = useDictation(panel, value, onChange);
|
|
1787
|
+
return /* @__PURE__ */ jsxs7(View5, { style: styles7.dictated, children: [
|
|
1788
|
+
/* @__PURE__ */ jsxs7(View5, { style: styles7.fill, children: [
|
|
1789
|
+
/* @__PURE__ */ jsx9(
|
|
1790
|
+
TextInput2,
|
|
1791
|
+
{
|
|
1792
|
+
value: typeof value === "string" ? value : "",
|
|
1793
|
+
onChangeText: (t) => onChange(t || null),
|
|
1794
|
+
placeholder: panel.options.placeholder ?? "Type here",
|
|
1795
|
+
placeholderTextColor: theme.textMuted,
|
|
1796
|
+
multiline: true,
|
|
1797
|
+
accessibilityLabel: panel.title,
|
|
1798
|
+
style: [styles7.textArea, dictation.available && styles7.textAreaWithMic, { color: theme.text, borderColor: theme.border }]
|
|
1799
|
+
}
|
|
1800
|
+
),
|
|
1801
|
+
dictation.available && /* @__PURE__ */ jsx9(View5, { style: styles7.textAreaMic, children: /* @__PURE__ */ jsx9(MicButton, { dictation, title: panel.title, size: 28 }) })
|
|
1802
|
+
] }),
|
|
1803
|
+
/* @__PURE__ */ jsx9(DictationHint, { dictation })
|
|
1804
|
+
] });
|
|
1664
1805
|
}
|
|
1665
1806
|
function SuggestTextInput({ panel, value, onChange }) {
|
|
1666
1807
|
const theme = useDashTheme();
|
|
1667
1808
|
const form = useInputForm();
|
|
1668
1809
|
const { metric, suggestWith, placeholder } = panel.options;
|
|
1669
|
-
const [entries, setEntries] =
|
|
1670
|
-
const [typed, setTyped] =
|
|
1810
|
+
const [entries, setEntries] = useState6([]);
|
|
1811
|
+
const [typed, setTyped] = useState6(false);
|
|
1671
1812
|
const text = typeof value === "string" ? value : "";
|
|
1672
1813
|
const { store } = form;
|
|
1673
|
-
|
|
1814
|
+
useEffect3(() => {
|
|
1674
1815
|
let run = 0;
|
|
1675
1816
|
const load = () => {
|
|
1676
1817
|
const mine = ++run;
|
|
@@ -1689,26 +1830,34 @@ function SuggestTextInput({ panel, value, onChange }) {
|
|
|
1689
1830
|
const query = typed ? text : "";
|
|
1690
1831
|
const fromScoped = textSuggestions(scoped, query);
|
|
1691
1832
|
const suggestions = (fromScoped.length ? fromScoped : textSuggestions(own, query)).filter((s) => s.toLowerCase() !== text.trim().toLowerCase());
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1833
|
+
const dictation = useDictation(panel, value, (v) => {
|
|
1834
|
+
setTyped(false);
|
|
1835
|
+
onChange(v);
|
|
1836
|
+
});
|
|
1837
|
+
return /* @__PURE__ */ jsxs7(View5, { style: styles7.suggest, children: [
|
|
1838
|
+
/* @__PURE__ */ jsxs7(View5, { style: styles7.lineRow, children: [
|
|
1839
|
+
/* @__PURE__ */ jsx9(
|
|
1840
|
+
TextInput2,
|
|
1841
|
+
{
|
|
1842
|
+
value: text,
|
|
1843
|
+
onChangeText: (t) => {
|
|
1844
|
+
setTyped(!!t);
|
|
1845
|
+
onChange(t || null);
|
|
1846
|
+
},
|
|
1847
|
+
placeholder: placeholder ?? "Type here",
|
|
1848
|
+
placeholderTextColor: theme.textMuted,
|
|
1849
|
+
style: [styles7.textLine, { color: theme.text, borderColor: theme.border }],
|
|
1850
|
+
accessibilityLabel: panel.title,
|
|
1851
|
+
autoCorrect: false,
|
|
1852
|
+
autoCapitalize: "words",
|
|
1853
|
+
returnKeyType: "done",
|
|
1854
|
+
selectTextOnFocus: true
|
|
1855
|
+
}
|
|
1856
|
+
),
|
|
1857
|
+
/* @__PURE__ */ jsx9(MicButton, { dictation, title: panel.title })
|
|
1858
|
+
] }),
|
|
1859
|
+
/* @__PURE__ */ jsx9(DictationHint, { dictation }),
|
|
1860
|
+
/* @__PURE__ */ jsx9(ScrollView3, { horizontal: true, keyboardShouldPersistTaps: "handled", showsHorizontalScrollIndicator: false, contentContainerStyle: styles7.wrap, children: suggestions.map((s) => /* @__PURE__ */ jsx9(
|
|
1712
1861
|
Chip,
|
|
1713
1862
|
{
|
|
1714
1863
|
label: s,
|
|
@@ -1725,28 +1874,28 @@ function CounterInput({ panel }) {
|
|
|
1725
1874
|
const theme = useDashTheme();
|
|
1726
1875
|
const { store } = useInputForm();
|
|
1727
1876
|
const { metric, increment = 1, unit } = panel.options;
|
|
1728
|
-
const [today, setToday] =
|
|
1729
|
-
|
|
1877
|
+
const [today, setToday] = useState6(0);
|
|
1878
|
+
useEffect3(() => {
|
|
1730
1879
|
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)));
|
|
1731
1880
|
load();
|
|
1732
1881
|
return store.subscribe(load);
|
|
1733
1882
|
}, [store, metric]);
|
|
1734
|
-
return /* @__PURE__ */
|
|
1735
|
-
/* @__PURE__ */
|
|
1736
|
-
/* @__PURE__ */
|
|
1883
|
+
return /* @__PURE__ */ jsxs7(View5, { style: styles7.counter, children: [
|
|
1884
|
+
/* @__PURE__ */ jsxs7(View5, { style: { flex: 1 }, children: [
|
|
1885
|
+
/* @__PURE__ */ jsxs7(Text7, { style: [styles7.counterValue, { color: theme.text }], children: [
|
|
1737
1886
|
today,
|
|
1738
|
-
unit ? /* @__PURE__ */
|
|
1887
|
+
unit ? /* @__PURE__ */ jsx9(Text7, { style: { fontSize: 14, color: theme.textMuted }, children: ` ${unit}` }) : null
|
|
1739
1888
|
] }),
|
|
1740
|
-
/* @__PURE__ */
|
|
1889
|
+
/* @__PURE__ */ jsx9(Text7, { style: { color: theme.textMuted, fontSize: 12 }, children: "today" })
|
|
1741
1890
|
] }),
|
|
1742
|
-
/* @__PURE__ */
|
|
1743
|
-
|
|
1891
|
+
/* @__PURE__ */ jsx9(
|
|
1892
|
+
Pressable6,
|
|
1744
1893
|
{
|
|
1745
1894
|
onPress: () => store.add([{ metric, ts: Date.now(), value: increment, text: null }]),
|
|
1746
1895
|
accessibilityRole: "button",
|
|
1747
1896
|
accessibilityLabel: `Add ${increment}`,
|
|
1748
|
-
style: ({ pressed }) => [
|
|
1749
|
-
children: /* @__PURE__ */
|
|
1897
|
+
style: ({ pressed }) => [styles7.counterBtn, { backgroundColor: theme.accent, opacity: pressed ? 0.8 : 1 }],
|
|
1898
|
+
children: /* @__PURE__ */ jsxs7(Text7, { style: styles7.counterBtnText, children: [
|
|
1750
1899
|
"+",
|
|
1751
1900
|
increment
|
|
1752
1901
|
] })
|
|
@@ -1754,7 +1903,13 @@ function CounterInput({ panel }) {
|
|
|
1754
1903
|
)
|
|
1755
1904
|
] });
|
|
1756
1905
|
}
|
|
1757
|
-
var
|
|
1906
|
+
var styles7 = StyleSheet7.create({
|
|
1907
|
+
fill: { flex: 1 },
|
|
1908
|
+
dictated: { flex: 1, gap: 4 },
|
|
1909
|
+
selectWrap: { gap: 4 },
|
|
1910
|
+
lineRow: { flexDirection: "row", alignItems: "center", gap: 8 },
|
|
1911
|
+
textAreaWithMic: { paddingRight: 44 },
|
|
1912
|
+
textAreaMic: { position: "absolute", top: 8, right: 8 },
|
|
1758
1913
|
numberRow: { flex: 1, flexDirection: "row", alignItems: "center", gap: 8 },
|
|
1759
1914
|
numberField: { flex: 1, flexDirection: "row", alignItems: "center", borderWidth: 1, borderRadius: 8, paddingHorizontal: 10, height: 44 },
|
|
1760
1915
|
// Android gives TextInput default padding that eats into narrow fields.
|
|
@@ -1785,7 +1940,7 @@ var styles6 = StyleSheet6.create({
|
|
|
1785
1940
|
rating: { flex: 1, flexDirection: "row", alignItems: "center", justifyContent: "space-between", gap: 6 },
|
|
1786
1941
|
ratingDot: { flex: 1, maxWidth: 52, aspectRatio: 1, borderRadius: 26, borderWidth: 1, alignItems: "center", justifyContent: "center" },
|
|
1787
1942
|
suggest: { flex: 1, gap: 8 },
|
|
1788
|
-
textLine: { height: 44, borderWidth: 1, borderRadius: 8, paddingHorizontal: 10, paddingVertical: 0, fontSize: 16 },
|
|
1943
|
+
textLine: { flex: 1, height: 44, borderWidth: 1, borderRadius: 8, paddingHorizontal: 10, paddingVertical: 0, fontSize: 16 },
|
|
1789
1944
|
textArea: { flex: 1, borderWidth: 1, borderRadius: 8, padding: 10, fontSize: 15, textAlignVertical: "top" },
|
|
1790
1945
|
counter: { flex: 1, flexDirection: "row", alignItems: "center", gap: 12 },
|
|
1791
1946
|
counterValue: { fontSize: 28, fontWeight: "600", fontVariant: ["tabular-nums"] },
|
|
@@ -1794,7 +1949,7 @@ var styles6 = StyleSheet6.create({
|
|
|
1794
1949
|
});
|
|
1795
1950
|
|
|
1796
1951
|
// src/ui/inputs/InputGroup.tsx
|
|
1797
|
-
import { jsx as
|
|
1952
|
+
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1798
1953
|
function titleText(v) {
|
|
1799
1954
|
if (v == null || v === "") return void 0;
|
|
1800
1955
|
if (Array.isArray(v)) return v.length ? v.join(", ") : void 0;
|
|
@@ -1823,11 +1978,11 @@ function InputGroupBody({ panel }) {
|
|
|
1823
1978
|
const theme = useDashTheme();
|
|
1824
1979
|
const form = useInputForm();
|
|
1825
1980
|
const group = form.group?.(panel);
|
|
1826
|
-
const [collapsed, setCollapsed] =
|
|
1827
|
-
const [drag, setDrag] =
|
|
1828
|
-
const [heights, setHeights] =
|
|
1829
|
-
const dragging =
|
|
1830
|
-
const [wasEdited, setWasEdited] =
|
|
1981
|
+
const [collapsed, setCollapsed] = useState7(/* @__PURE__ */ new Set());
|
|
1982
|
+
const [drag, setDrag] = useState7(null);
|
|
1983
|
+
const [heights, setHeights] = useState7({});
|
|
1984
|
+
const dragging = useRef3(null);
|
|
1985
|
+
const [wasEdited, setWasEdited] = useState7(group?.edited);
|
|
1831
1986
|
if (group && group.edited !== wasEdited) {
|
|
1832
1987
|
setWasEdited(group.edited);
|
|
1833
1988
|
if (!group.edited) setCollapsed(/* @__PURE__ */ new Set());
|
|
@@ -1868,12 +2023,12 @@ function InputGroupBody({ panel }) {
|
|
|
1868
2023
|
if (to <= i && i < drag.from) return room;
|
|
1869
2024
|
return 0;
|
|
1870
2025
|
};
|
|
1871
|
-
return /* @__PURE__ */
|
|
2026
|
+
return /* @__PURE__ */ jsxs8(ScrollView4, { style: styles8.fill, contentContainerStyle: styles8.list, nestedScrollEnabled: true, keyboardShouldPersistTaps: "handled", scrollEnabled: !drag, children: [
|
|
1872
2027
|
group.items.map((item, i) => {
|
|
1873
2028
|
const named = panel.options.titleFrom ? titleText(item.values[panel.options.titleFrom]) : void 0;
|
|
1874
2029
|
const title = named ?? `${label} ${i + 1}`;
|
|
1875
2030
|
const troubled = groupFields(panel).some((f) => group.fieldProblem(i, f.options.metric));
|
|
1876
|
-
return /* @__PURE__ */
|
|
2031
|
+
return /* @__PURE__ */ jsx10(
|
|
1877
2032
|
ItemCard,
|
|
1878
2033
|
{
|
|
1879
2034
|
panel,
|
|
@@ -1904,16 +2059,16 @@ function InputGroupBody({ panel }) {
|
|
|
1904
2059
|
item.key
|
|
1905
2060
|
);
|
|
1906
2061
|
}),
|
|
1907
|
-
group.canAdd && /* @__PURE__ */
|
|
1908
|
-
|
|
2062
|
+
group.canAdd && /* @__PURE__ */ jsx10(
|
|
2063
|
+
Pressable7,
|
|
1909
2064
|
{
|
|
1910
2065
|
onPress: () => {
|
|
1911
2066
|
collapseFilled();
|
|
1912
2067
|
group.add();
|
|
1913
2068
|
},
|
|
1914
2069
|
accessibilityRole: "button",
|
|
1915
|
-
style: ({ pressed }) => [
|
|
1916
|
-
children: /* @__PURE__ */
|
|
2070
|
+
style: ({ pressed }) => [styles8.add, { borderColor: theme.accent, opacity: pressed ? 0.7 : 1 }],
|
|
2071
|
+
children: /* @__PURE__ */ jsxs8(Text8, { style: { color: theme.accent, fontWeight: "600" }, children: [
|
|
1917
2072
|
"+ ",
|
|
1918
2073
|
panel.options.addLabel || `Add ${label.toLowerCase()}`
|
|
1919
2074
|
] })
|
|
@@ -1935,59 +2090,59 @@ function ItemCard({ panel, group, form, index, title, last, collapsed, onToggle,
|
|
|
1935
2090
|
}),
|
|
1936
2091
|
[form, group, index, item]
|
|
1937
2092
|
);
|
|
1938
|
-
const button = (text, onPress, a11y, disabled = false) => /* @__PURE__ */
|
|
1939
|
-
|
|
2093
|
+
const button = (text, onPress, a11y, disabled = false) => /* @__PURE__ */ jsx10(
|
|
2094
|
+
Pressable7,
|
|
1940
2095
|
{
|
|
1941
2096
|
onPress,
|
|
1942
2097
|
disabled,
|
|
1943
2098
|
accessibilityRole: "button",
|
|
1944
2099
|
accessibilityLabel: a11y,
|
|
1945
2100
|
hitSlop: 6,
|
|
1946
|
-
style: ({ pressed }) => [
|
|
1947
|
-
children: /* @__PURE__ */
|
|
2101
|
+
style: ({ pressed }) => [styles8.iconBtn, { opacity: disabled ? 0.3 : pressed ? 0.6 : 1 }],
|
|
2102
|
+
children: /* @__PURE__ */ jsx10(Text8, { style: { color: theme.textSecondary, fontSize: 15 }, children: text })
|
|
1948
2103
|
}
|
|
1949
2104
|
);
|
|
1950
2105
|
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 ") : "";
|
|
1951
|
-
return /* @__PURE__ */
|
|
2106
|
+
return /* @__PURE__ */ jsxs8(
|
|
1952
2107
|
View6,
|
|
1953
2108
|
{
|
|
1954
2109
|
onLayout: (e) => onLayout(e.nativeEvent.layout.height),
|
|
1955
2110
|
style: [
|
|
1956
|
-
|
|
2111
|
+
styles8.item,
|
|
1957
2112
|
{ borderColor: lifted ? theme.accent : theme.border, backgroundColor: theme.surface },
|
|
1958
2113
|
!!dragOffset && { transform: [{ translateY: dragOffset }] },
|
|
1959
2114
|
lifted && { zIndex: 1, opacity: 0.95 }
|
|
1960
2115
|
],
|
|
1961
2116
|
children: [
|
|
1962
|
-
/* @__PURE__ */
|
|
1963
|
-
/* @__PURE__ */
|
|
1964
|
-
/* @__PURE__ */
|
|
1965
|
-
/* @__PURE__ */
|
|
2117
|
+
/* @__PURE__ */ jsxs8(View6, { style: styles8.itemHeader, children: [
|
|
2118
|
+
/* @__PURE__ */ jsx10(View6, { ...handle, style: styles8.handle, accessibilityLabel: `Drag ${title} to reorder`, children: /* @__PURE__ */ jsx10(Text8, { style: { color: theme.textMuted, fontSize: 16 }, children: "\u2261" }) }),
|
|
2119
|
+
/* @__PURE__ */ jsxs8(Pressable7, { onPress: onToggle, style: styles8.titleArea, accessibilityRole: "button", accessibilityLabel: `${collapsed ? "Expand" : "Collapse"} ${title}`, accessibilityState: { expanded: !collapsed }, children: [
|
|
2120
|
+
/* @__PURE__ */ jsxs8(Text8, { style: [styles8.itemTitle, { color: theme.text }], numberOfLines: 1, children: [
|
|
1966
2121
|
collapsed ? "\u25B8 " : "\u25BE ",
|
|
1967
2122
|
title
|
|
1968
2123
|
] }),
|
|
1969
|
-
!!summary && /* @__PURE__ */
|
|
2124
|
+
!!summary && /* @__PURE__ */ jsx10(Text8, { style: [styles8.summary, { color: theme.textSecondary }], numberOfLines: 1, children: summary })
|
|
1970
2125
|
] }),
|
|
1971
2126
|
button("\u2191", () => group.move(index, -1), `Move ${title} up`, index === 0),
|
|
1972
2127
|
button("\u2193", () => group.move(index, 1), `Move ${title} down`, last),
|
|
1973
2128
|
button("\u29C9", onDuplicate, `Duplicate ${title}`, !group.canAdd),
|
|
1974
2129
|
button("\u2715", () => group.remove(index), `Remove ${title}`)
|
|
1975
2130
|
] }),
|
|
1976
|
-
!collapsed && /* @__PURE__ */
|
|
2131
|
+
!collapsed && /* @__PURE__ */ jsx10(InputFormContext.Provider, { value: scoped, children: /* @__PURE__ */ jsx10(View6, { style: styles8.fields, children: fields.map((f) => {
|
|
1977
2132
|
const problem = scoped.problem?.(f.options.metric);
|
|
1978
|
-
return /* @__PURE__ */
|
|
1979
|
-
/* @__PURE__ */
|
|
1980
|
-
!!f.title && /* @__PURE__ */
|
|
1981
|
-
!!problem && /* @__PURE__ */
|
|
2133
|
+
return /* @__PURE__ */ jsxs8(View6, { style: [styles8.field, { width: `${Math.min(24, Math.max(1, f.gridPos.w)) / 24 * 100}%` }], children: [
|
|
2134
|
+
/* @__PURE__ */ jsxs8(View6, { style: styles8.fieldHeader, children: [
|
|
2135
|
+
!!f.title && /* @__PURE__ */ jsx10(Text8, { style: [styles8.fieldTitle, { color: theme.textSecondary }], numberOfLines: 1, children: f.title }),
|
|
2136
|
+
!!problem && /* @__PURE__ */ jsx10(Text8, { style: [styles8.problem, { color: theme.danger }], numberOfLines: 1, accessibilityRole: "alert", children: problem })
|
|
1982
2137
|
] }),
|
|
1983
|
-
/* @__PURE__ */
|
|
2138
|
+
/* @__PURE__ */ jsx10(View6, { style: styles8.fieldBody, children: /* @__PURE__ */ jsx10(InputPanelBody, { panel: f }) })
|
|
1984
2139
|
] }, f.options.metric);
|
|
1985
2140
|
}) }) })
|
|
1986
2141
|
]
|
|
1987
2142
|
}
|
|
1988
2143
|
);
|
|
1989
2144
|
}
|
|
1990
|
-
var
|
|
2145
|
+
var styles8 = StyleSheet8.create({
|
|
1991
2146
|
fill: { flex: 1 },
|
|
1992
2147
|
list: { gap: 8, paddingBottom: 4 },
|
|
1993
2148
|
item: { borderWidth: 1, borderRadius: 8, padding: 8, gap: 6 },
|
|
@@ -2009,20 +2164,20 @@ var styles7 = StyleSheet7.create({
|
|
|
2009
2164
|
|
|
2010
2165
|
// src/ui/panels/GaugePanels.tsx
|
|
2011
2166
|
import { useMemo as useMemo4 } from "react";
|
|
2012
|
-
import { Pressable as
|
|
2013
|
-
import
|
|
2167
|
+
import { Pressable as Pressable9, StyleSheet as StyleSheet10, Text as Text10, View as View8 } from "react-native";
|
|
2168
|
+
import Svg6, { Path as Path6 } from "react-native-svg";
|
|
2014
2169
|
|
|
2015
2170
|
// src/ui/panels/StatPanel.tsx
|
|
2016
2171
|
import { useMemo as useMemo3 } from "react";
|
|
2017
|
-
import { Pressable as
|
|
2018
|
-
import
|
|
2019
|
-
import { jsx as
|
|
2172
|
+
import { Pressable as Pressable8, StyleSheet as StyleSheet9, Text as Text9, View as View7 } from "react-native";
|
|
2173
|
+
import Svg5, { Path as Path5 } from "react-native-svg";
|
|
2174
|
+
import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2020
2175
|
function StatPanel({ panel, frames }) {
|
|
2021
2176
|
const theme = useDashTheme();
|
|
2022
2177
|
const values = useMemo3(() => reducedValues(panel, frames, theme.scheme), [panel, frames, theme.scheme]);
|
|
2023
|
-
if (!values.length) return /* @__PURE__ */
|
|
2178
|
+
if (!values.length) return /* @__PURE__ */ jsx11(NoData, {});
|
|
2024
2179
|
const horizontal = panel.options?.orientation === "horizontal";
|
|
2025
|
-
return /* @__PURE__ */
|
|
2180
|
+
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)) });
|
|
2026
2181
|
}
|
|
2027
2182
|
function StatTile({ v, showName, panel }) {
|
|
2028
2183
|
const theme = useDashTheme();
|
|
@@ -2032,25 +2187,25 @@ function StatTile({ v, showName, panel }) {
|
|
|
2032
2187
|
const fontSize = Math.max(18, Math.min(56, size.height * (graph ? 0.4 : 0.5), size.width / 4.5));
|
|
2033
2188
|
const { resolve, openLinks } = usePanelLinks(panel);
|
|
2034
2189
|
const hasLinks = !!v.config.links?.length;
|
|
2035
|
-
return /* @__PURE__ */
|
|
2036
|
-
|
|
2190
|
+
return /* @__PURE__ */ jsxs9(
|
|
2191
|
+
Pressable8,
|
|
2037
2192
|
{
|
|
2038
2193
|
onLayout,
|
|
2039
2194
|
disabled: !hasLinks,
|
|
2040
2195
|
onPress: () => openLinks(valueLinks(panel, v, resolve), v.name),
|
|
2041
2196
|
accessibilityRole: hasLinks ? "link" : void 0,
|
|
2042
2197
|
style: ({ pressed }) => [
|
|
2043
|
-
|
|
2198
|
+
styles9.tile,
|
|
2044
2199
|
// With a sparkline, the number sits in the top half so the line runs beneath it.
|
|
2045
2200
|
graph && { justifyContent: "flex-start", paddingTop: 4 },
|
|
2046
2201
|
colorMode === "background" && { backgroundColor: withAlpha(v.stateColor, 0.14) },
|
|
2047
2202
|
pressed && { opacity: 0.7 }
|
|
2048
2203
|
],
|
|
2049
2204
|
children: [
|
|
2050
|
-
colorMode !== "none" && /* @__PURE__ */
|
|
2051
|
-
graph && size.width > 0 && /* @__PURE__ */
|
|
2052
|
-
showName && /* @__PURE__ */
|
|
2053
|
-
/* @__PURE__ */
|
|
2205
|
+
colorMode !== "none" && /* @__PURE__ */ jsx11(View7, { style: [styles9.accent, { backgroundColor: v.stateColor }] }),
|
|
2206
|
+
graph && size.width > 0 && /* @__PURE__ */ jsx11(Sparkline, { values: v.sparkline, width: size.width, height: size.height * 0.4, color: v.stateColor }),
|
|
2207
|
+
showName && /* @__PURE__ */ jsx11(Text9, { style: [styles9.name, { color: theme.textSecondary }], numberOfLines: 1, children: v.name }),
|
|
2208
|
+
/* @__PURE__ */ jsx11(Text9, { style: [styles9.value, { color: theme.text, fontSize }], numberOfLines: 1, adjustsFontSizeToFit: true, children: v.text })
|
|
2054
2209
|
]
|
|
2055
2210
|
}
|
|
2056
2211
|
);
|
|
@@ -2065,16 +2220,16 @@ function Sparkline({ values, width, height, color }) {
|
|
|
2065
2220
|
values.forEach((v, i) => {
|
|
2066
2221
|
if (v != null) line += `${line ? "L" : "M"}${x(i)},${y(v)}`;
|
|
2067
2222
|
});
|
|
2068
|
-
return /* @__PURE__ */
|
|
2069
|
-
/* @__PURE__ */
|
|
2070
|
-
/* @__PURE__ */
|
|
2223
|
+
return /* @__PURE__ */ jsxs9(Svg5, { width, height, style: styles9.spark, children: [
|
|
2224
|
+
/* @__PURE__ */ jsx11(Path5, { d: `${line}L${width},${height}L0,${height}Z`, fill: color, opacity: 0.1 }),
|
|
2225
|
+
/* @__PURE__ */ jsx11(Path5, { d: line, stroke: color, strokeWidth: 2, fill: "none", strokeLinejoin: "round" })
|
|
2071
2226
|
] });
|
|
2072
2227
|
}
|
|
2073
2228
|
function withAlpha(hex, alpha) {
|
|
2074
2229
|
if (!/^#[0-9a-f]{6}$/i.test(hex)) return hex;
|
|
2075
2230
|
return `${hex}${Math.round(alpha * 255).toString(16).padStart(2, "0")}`;
|
|
2076
2231
|
}
|
|
2077
|
-
var
|
|
2232
|
+
var styles9 = StyleSheet9.create({
|
|
2078
2233
|
grid: { flex: 1, gap: 8 },
|
|
2079
2234
|
tile: { flex: 1, justifyContent: "center", paddingLeft: 12, borderRadius: 6, overflow: "hidden" },
|
|
2080
2235
|
accent: { position: "absolute", left: 0, top: 6, bottom: 6, width: 3, borderRadius: 2 },
|
|
@@ -2084,13 +2239,13 @@ var styles8 = StyleSheet8.create({
|
|
|
2084
2239
|
});
|
|
2085
2240
|
|
|
2086
2241
|
// src/ui/panels/GaugePanels.tsx
|
|
2087
|
-
import { jsx as
|
|
2242
|
+
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2088
2243
|
var SWEEP = 240;
|
|
2089
2244
|
function GaugePanel({ panel, frames }) {
|
|
2090
2245
|
const theme = useDashTheme();
|
|
2091
2246
|
const values = useMemo4(() => reducedValues(panel, frames, theme.scheme), [panel, frames, theme.scheme]);
|
|
2092
|
-
if (!values.length) return /* @__PURE__ */
|
|
2093
|
-
return /* @__PURE__ */
|
|
2247
|
+
if (!values.length) return /* @__PURE__ */ jsx12(NoData, {});
|
|
2248
|
+
return /* @__PURE__ */ jsx12(View8, { style: styles10.row, children: values.map((v) => /* @__PURE__ */ jsx12(Gauge, { v, showName: values.length > 1, panel }, v.key)) });
|
|
2094
2249
|
}
|
|
2095
2250
|
function Gauge({ v, showName, panel }) {
|
|
2096
2251
|
const theme = useDashTheme();
|
|
@@ -2105,22 +2260,22 @@ function Gauge({ v, showName, panel }) {
|
|
|
2105
2260
|
const r = d / 2 - stroke;
|
|
2106
2261
|
const cx = size.width / 2;
|
|
2107
2262
|
const cy = size.height / 2 + d * 0.08;
|
|
2108
|
-
return /* @__PURE__ */
|
|
2109
|
-
|
|
2263
|
+
return /* @__PURE__ */ jsxs10(
|
|
2264
|
+
Pressable9,
|
|
2110
2265
|
{
|
|
2111
|
-
style: ({ pressed }) => [
|
|
2266
|
+
style: ({ pressed }) => [styles10.fill, pressed && { opacity: 0.7 }],
|
|
2112
2267
|
onLayout,
|
|
2113
2268
|
disabled: !hasLinks,
|
|
2114
2269
|
onPress: () => openLinks(valueLinks(panel, v, resolve), v.name),
|
|
2115
2270
|
accessibilityRole: hasLinks ? "link" : void 0,
|
|
2116
2271
|
children: [
|
|
2117
|
-
size.width > 0 && r > 0 && /* @__PURE__ */
|
|
2118
|
-
/* @__PURE__ */
|
|
2119
|
-
frac > 0 && /* @__PURE__ */
|
|
2272
|
+
size.width > 0 && r > 0 && /* @__PURE__ */ jsxs10(Svg6, { width: size.width, height: size.height, children: [
|
|
2273
|
+
/* @__PURE__ */ jsx12(Path6, { d: arc(cx, cy, r, 0, 1), stroke: withAlpha(v.stateColor, 0.18), strokeWidth: stroke, fill: "none", strokeLinecap: "round" }),
|
|
2274
|
+
frac > 0 && /* @__PURE__ */ jsx12(Path6, { d: arc(cx, cy, r, 0, frac), stroke: v.stateColor, strokeWidth: stroke, fill: "none", strokeLinecap: "round" })
|
|
2120
2275
|
] }),
|
|
2121
|
-
/* @__PURE__ */
|
|
2122
|
-
/* @__PURE__ */
|
|
2123
|
-
showName && /* @__PURE__ */
|
|
2276
|
+
/* @__PURE__ */ jsxs10(View8, { style: [StyleSheet10.absoluteFill, styles10.center, { top: d * 0.12 }], pointerEvents: "none", children: [
|
|
2277
|
+
/* @__PURE__ */ jsx12(Text10, { style: [styles10.value, { color: theme.text, fontSize: Math.max(14, d * 0.18) }], numberOfLines: 1, adjustsFontSizeToFit: true, children: v.text }),
|
|
2278
|
+
showName && /* @__PURE__ */ jsx12(Text10, { style: [styles10.name, { color: theme.textSecondary }], numberOfLines: 1, children: v.name })
|
|
2124
2279
|
] })
|
|
2125
2280
|
]
|
|
2126
2281
|
}
|
|
@@ -2138,33 +2293,33 @@ function BarGaugePanel({ panel, frames }) {
|
|
|
2138
2293
|
const theme = useDashTheme();
|
|
2139
2294
|
const values = useMemo4(() => reducedValues(panel, frames, theme.scheme), [panel, frames, theme.scheme]);
|
|
2140
2295
|
const { resolve, openLinks } = usePanelLinks(panel);
|
|
2141
|
-
if (!values.length) return /* @__PURE__ */
|
|
2142
|
-
return /* @__PURE__ */
|
|
2296
|
+
if (!values.length) return /* @__PURE__ */ jsx12(NoData, {});
|
|
2297
|
+
return /* @__PURE__ */ jsx12(View8, { style: styles10.bars, children: values.map((v) => {
|
|
2143
2298
|
const min = v.config.min ?? 0;
|
|
2144
2299
|
const max = v.config.max ?? Math.max(...values.map((o) => o.value ?? 0), 1);
|
|
2145
2300
|
const frac = v.value == null ? 0 : Math.min(1, Math.max(0, (v.value - min) / (max - min || 1)));
|
|
2146
2301
|
const color = v.config.thresholds || v.mapped?.color ? v.stateColor : resolveColor(v.config.color?.fixedColor, v.color);
|
|
2147
2302
|
const hasLinks = !!v.config.links?.length;
|
|
2148
|
-
return /* @__PURE__ */
|
|
2149
|
-
|
|
2303
|
+
return /* @__PURE__ */ jsxs10(
|
|
2304
|
+
Pressable9,
|
|
2150
2305
|
{
|
|
2151
|
-
style: ({ pressed }) => [
|
|
2306
|
+
style: ({ pressed }) => [styles10.barRow, pressed && { opacity: 0.7 }],
|
|
2152
2307
|
disabled: !hasLinks,
|
|
2153
2308
|
onPress: () => openLinks(valueLinks(panel, v, resolve), v.name),
|
|
2154
2309
|
accessibilityRole: hasLinks ? "link" : void 0,
|
|
2155
2310
|
children: [
|
|
2156
|
-
/* @__PURE__ */
|
|
2157
|
-
/* @__PURE__ */
|
|
2158
|
-
/* @__PURE__ */
|
|
2311
|
+
/* @__PURE__ */ jsxs10(View8, { style: styles10.barLabels, children: [
|
|
2312
|
+
/* @__PURE__ */ jsx12(Text10, { style: [styles10.name, { color: theme.textSecondary }], numberOfLines: 1, children: v.name }),
|
|
2313
|
+
/* @__PURE__ */ jsx12(Text10, { style: [styles10.barValue, { color: theme.text }], children: v.text })
|
|
2159
2314
|
] }),
|
|
2160
|
-
/* @__PURE__ */
|
|
2315
|
+
/* @__PURE__ */ jsx12(View8, { style: [styles10.track, { backgroundColor: withAlpha(color, 0.18) }], children: /* @__PURE__ */ jsx12(View8, { style: [styles10.meter, { width: `${frac * 100}%`, backgroundColor: color }] }) })
|
|
2161
2316
|
]
|
|
2162
2317
|
},
|
|
2163
2318
|
v.key
|
|
2164
2319
|
);
|
|
2165
2320
|
}) });
|
|
2166
2321
|
}
|
|
2167
|
-
var
|
|
2322
|
+
var styles10 = StyleSheet10.create({
|
|
2168
2323
|
fill: { flex: 1 },
|
|
2169
2324
|
row: { flex: 1, flexDirection: "row", gap: 8 },
|
|
2170
2325
|
center: { alignItems: "center", justifyContent: "center" },
|
|
@@ -2179,9 +2334,9 @@ var styles9 = StyleSheet9.create({
|
|
|
2179
2334
|
});
|
|
2180
2335
|
|
|
2181
2336
|
// src/ui/panels/GeomapPanel.tsx
|
|
2182
|
-
import { useEffect as
|
|
2183
|
-
import { Image, PixelRatio, Pressable as
|
|
2184
|
-
import
|
|
2337
|
+
import { useEffect as useEffect4, useMemo as useMemo5, useRef as useRef4, useState as useState8 } from "react";
|
|
2338
|
+
import { Image, PixelRatio, Pressable as Pressable10, StyleSheet as StyleSheet11, Text as Text11, View as View9 } from "react-native";
|
|
2339
|
+
import Svg7, { Path as Path7, Text as SvgText2 } from "react-native-svg";
|
|
2185
2340
|
|
|
2186
2341
|
// src/ui/geomap.ts
|
|
2187
2342
|
var TILE = 256;
|
|
@@ -2597,7 +2752,7 @@ function heatmapCells(px, py, weights, radius, blur, width, height, cell = 4) {
|
|
|
2597
2752
|
}
|
|
2598
2753
|
|
|
2599
2754
|
// src/ui/panels/GeomapPanel.tsx
|
|
2600
|
-
import { jsx as
|
|
2755
|
+
import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2601
2756
|
var HIT_PX = 24;
|
|
2602
2757
|
var DRAG_PX = 6;
|
|
2603
2758
|
var MAX_LABELS = 300;
|
|
@@ -2608,8 +2763,8 @@ function GeomapPanel({ panel, frames }) {
|
|
|
2608
2763
|
const { gazetteers, error } = useGazetteers(panel, frames);
|
|
2609
2764
|
const layers = useMemo5(() => geomapLayers(panel, frames, theme.scheme, retina, gazetteers), [panel, frames, theme.scheme, retina, gazetteers]);
|
|
2610
2765
|
const home = useMemo5(() => initialView(panel, layers, size.width, size.height), [panel, layers, size.width, size.height]);
|
|
2611
|
-
const [moved, setMoved] =
|
|
2612
|
-
const [picked, setPicked] =
|
|
2766
|
+
const [moved, setMoved] = useState8(null);
|
|
2767
|
+
const [picked, setPicked] = useState8(null);
|
|
2613
2768
|
const links = usePanelLinks(panel);
|
|
2614
2769
|
const view = moved ?? home;
|
|
2615
2770
|
const [minZoom, maxZoom] = zoomLimits(panel);
|
|
@@ -2650,7 +2805,7 @@ function GeomapPanel({ panel, frames }) {
|
|
|
2650
2805
|
}
|
|
2651
2806
|
return best;
|
|
2652
2807
|
};
|
|
2653
|
-
const gesture =
|
|
2808
|
+
const gesture = useRef4(null);
|
|
2654
2809
|
const responder = {
|
|
2655
2810
|
onStartShouldSetResponder: () => true,
|
|
2656
2811
|
// Keep the gesture while panning instead of handing it to the dashboard's scroll view.
|
|
@@ -2692,15 +2847,15 @@ function GeomapPanel({ panel, frames }) {
|
|
|
2692
2847
|
const attribution = [...new Set(layers.flatMap((l) => l.type === "tiles" && l.source.attribution ? [l.source.attribution] : []))].join(" ");
|
|
2693
2848
|
const legend = layers.flatMap((l) => l.type === "markers" || l.type === "route" ? l.legend : []);
|
|
2694
2849
|
const ready = size.width > 0 && size.height > 0;
|
|
2695
|
-
return /* @__PURE__ */
|
|
2696
|
-
/* @__PURE__ */
|
|
2850
|
+
return /* @__PURE__ */ jsxs11(View9, { style: styles11.fill, children: [
|
|
2851
|
+
/* @__PURE__ */ jsxs11(View9, { style: [styles11.fill, styles11.map, { backgroundColor: theme.grid }], onLayout, ...responder, children: [
|
|
2697
2852
|
ready && // Nothing inside takes touches, so locationX/Y are always relative to the map.
|
|
2698
|
-
/* @__PURE__ */
|
|
2853
|
+
/* @__PURE__ */ jsxs11(View9, { pointerEvents: "none", style: StyleSheet11.absoluteFill, children: [
|
|
2699
2854
|
layers.map(
|
|
2700
|
-
(l) => l.type === "tiles" ? /* @__PURE__ */
|
|
2855
|
+
(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)
|
|
2701
2856
|
),
|
|
2702
|
-
shown && /* @__PURE__ */
|
|
2703
|
-
|
|
2857
|
+
shown && /* @__PURE__ */ jsx13(Svg7, { width: size.width, height: size.height, style: StyleSheet11.absoluteFill, children: /* @__PURE__ */ jsx13(
|
|
2858
|
+
Path7,
|
|
2704
2859
|
{
|
|
2705
2860
|
d: symbolPath("circle", shown.px, shown.py, Math.max(shown.layer.type === "markers" ? shown.radius + 2 : 5, 5)),
|
|
2706
2861
|
fill: "none",
|
|
@@ -2709,7 +2864,7 @@ function GeomapPanel({ panel, frames }) {
|
|
|
2709
2864
|
}
|
|
2710
2865
|
) })
|
|
2711
2866
|
] }),
|
|
2712
|
-
shown && /* @__PURE__ */
|
|
2867
|
+
shown && /* @__PURE__ */ jsx13(
|
|
2713
2868
|
RowTooltip,
|
|
2714
2869
|
{
|
|
2715
2870
|
at: { x: shown.px, y: shown.py },
|
|
@@ -2721,23 +2876,23 @@ function GeomapPanel({ panel, frames }) {
|
|
|
2721
2876
|
onOpenLink: (l) => links.openLinks([l])
|
|
2722
2877
|
}
|
|
2723
2878
|
),
|
|
2724
|
-
controls.showZoom !== false && /* @__PURE__ */
|
|
2725
|
-
/* @__PURE__ */
|
|
2726
|
-
/* @__PURE__ */
|
|
2727
|
-
moved && /* @__PURE__ */
|
|
2879
|
+
controls.showZoom !== false && /* @__PURE__ */ jsxs11(View9, { style: styles11.zoom, children: [
|
|
2880
|
+
/* @__PURE__ */ jsx13(MapButton, { label: "+", onPress: () => zoomTo(view, Math.round(view.zoom) + 1) }),
|
|
2881
|
+
/* @__PURE__ */ jsx13(MapButton, { label: "\u2212", onPress: () => zoomTo(view, Math.round(view.zoom) - 1) }),
|
|
2882
|
+
moved && /* @__PURE__ */ jsx13(MapButton, { label: "\u27F2", onPress: () => setMoved(null) })
|
|
2728
2883
|
] }),
|
|
2729
|
-
error ? /* @__PURE__ */
|
|
2730
|
-
controls.showAttribution !== false && attribution ? /* @__PURE__ */
|
|
2884
|
+
error ? /* @__PURE__ */ jsx13(Text11, { pointerEvents: "none", style: [styles11.error, { color: theme.danger, backgroundColor: theme.surface }], numberOfLines: 2, children: error }) : null,
|
|
2885
|
+
controls.showAttribution !== false && attribution ? /* @__PURE__ */ jsx13(Text11, { pointerEvents: "none", style: [styles11.attribution, { color: theme.textSecondary, backgroundColor: theme.surface }], numberOfLines: 1, children: attribution }) : null
|
|
2731
2886
|
] }),
|
|
2732
|
-
legend.length > 0 && /* @__PURE__ */
|
|
2887
|
+
legend.length > 0 && /* @__PURE__ */ jsx13(Legend, { items: legend })
|
|
2733
2888
|
] });
|
|
2734
2889
|
}
|
|
2735
2890
|
var NONE = {};
|
|
2736
2891
|
function useGazetteers(panel, frames) {
|
|
2737
2892
|
const { resolve } = useDashboard();
|
|
2738
2893
|
const key = gazetteerPaths(panel, frames).join("\n");
|
|
2739
|
-
const [state, setState] =
|
|
2740
|
-
|
|
2894
|
+
const [state, setState] = useState8({ key: "", gazetteers: NONE });
|
|
2895
|
+
useEffect4(() => {
|
|
2741
2896
|
if (!key) return;
|
|
2742
2897
|
let live = true;
|
|
2743
2898
|
let ds;
|
|
@@ -2764,13 +2919,13 @@ function useGazetteers(panel, frames) {
|
|
|
2764
2919
|
}
|
|
2765
2920
|
function MapButton({ label, onPress }) {
|
|
2766
2921
|
const theme = useDashTheme();
|
|
2767
|
-
return /* @__PURE__ */
|
|
2922
|
+
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 }) });
|
|
2768
2923
|
}
|
|
2769
2924
|
function Tiles({ layer, view, width, height }) {
|
|
2770
2925
|
const tiles = visibleTiles(layer.source, view, width, height);
|
|
2771
|
-
return /* @__PURE__ */
|
|
2926
|
+
return /* @__PURE__ */ jsx13(View9, { style: [StyleSheet11.absoluteFill, { opacity: layer.opacity }], children: tiles.map((t) => (
|
|
2772
2927
|
// Half a pixel of overlap hides seams between scaled tiles.
|
|
2773
|
-
/* @__PURE__ */
|
|
2928
|
+
/* @__PURE__ */ jsx13(
|
|
2774
2929
|
Image,
|
|
2775
2930
|
{
|
|
2776
2931
|
source: { uri: t.url },
|
|
@@ -2787,12 +2942,12 @@ function DataLayerSvg({ layer, screen, width, height, textColor }) {
|
|
|
2787
2942
|
const px = screen.flatMap((s) => s.px);
|
|
2788
2943
|
const py = screen.flatMap((s) => s.py);
|
|
2789
2944
|
const weights = layer.points.flatMap((p) => p.sizes);
|
|
2790
|
-
return heatmapCells(px, py, weights, layer.radius, layer.blur, width, height).map((c) => /* @__PURE__ */
|
|
2945
|
+
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));
|
|
2791
2946
|
}
|
|
2792
2947
|
if (layer.type === "route") return routePaths(layer, screen);
|
|
2793
2948
|
return markerPaths(layer, screen, width, height, textColor);
|
|
2794
2949
|
}, [layer, screen, width, height, textColor]);
|
|
2795
|
-
return /* @__PURE__ */
|
|
2950
|
+
return /* @__PURE__ */ jsx13(Svg7, { width, height, style: [StyleSheet11.absoluteFill, { opacity: layer.opacity }], children: body });
|
|
2796
2951
|
}
|
|
2797
2952
|
function markerPaths(layer, screen, width, height, textColor) {
|
|
2798
2953
|
const byColor = /* @__PURE__ */ new Map();
|
|
@@ -2807,7 +2962,7 @@ function markerPaths(layer, screen, width, height, textColor) {
|
|
|
2807
2962
|
const label = p.labels?.[i];
|
|
2808
2963
|
if (label && labels.length < MAX_LABELS)
|
|
2809
2964
|
labels.push(
|
|
2810
|
-
/* @__PURE__ */
|
|
2965
|
+
/* @__PURE__ */ jsx13(
|
|
2811
2966
|
SvgText2,
|
|
2812
2967
|
{
|
|
2813
2968
|
x: px[i] + layer.labelOffset[0],
|
|
@@ -2824,7 +2979,7 @@ function markerPaths(layer, screen, width, height, textColor) {
|
|
|
2824
2979
|
});
|
|
2825
2980
|
const outline = layer.symbol === "cross" || layer.symbol === "x";
|
|
2826
2981
|
return [
|
|
2827
|
-
...[...byColor].map(([color, parts]) => /* @__PURE__ */
|
|
2982
|
+
...[...byColor].map(([color, parts]) => /* @__PURE__ */ jsx13(Path7, { d: parts.join(""), fill: outline ? "none" : color, fillOpacity: layer.fillOpacity, stroke: color, strokeWidth: outline ? 2 : 1 }, color)),
|
|
2828
2983
|
...labels
|
|
2829
2984
|
];
|
|
2830
2985
|
}
|
|
@@ -2837,7 +2992,7 @@ function routePaths(layer, screen) {
|
|
|
2837
2992
|
parts.push(`M${px[i]},${py[i]}L${px[i + 1]},${py[i + 1]}`);
|
|
2838
2993
|
}
|
|
2839
2994
|
});
|
|
2840
|
-
return [...byColor].map(([color, parts]) => /* @__PURE__ */
|
|
2995
|
+
return [...byColor].map(([color, parts]) => /* @__PURE__ */ jsx13(Path7, { d: parts.join(""), stroke: color, strokeWidth: layer.lineWidth, strokeLinecap: "round", fill: "none" }, color));
|
|
2841
2996
|
}
|
|
2842
2997
|
function resolvePicked(layers, screen, picked) {
|
|
2843
2998
|
const layer = layers.find((l) => l.key === picked.layer);
|
|
@@ -2855,7 +3010,7 @@ function resolvePicked(layers, screen, picked) {
|
|
|
2855
3010
|
py: s.py[picked.index]
|
|
2856
3011
|
};
|
|
2857
3012
|
}
|
|
2858
|
-
var
|
|
3013
|
+
var styles11 = StyleSheet11.create({
|
|
2859
3014
|
fill: { flex: 1 },
|
|
2860
3015
|
map: { overflow: "hidden", borderRadius: 4 },
|
|
2861
3016
|
zoom: { position: "absolute", top: 6, left: 6, gap: 4 },
|
|
@@ -2863,7 +3018,7 @@ var styles10 = StyleSheet10.create({
|
|
|
2863
3018
|
width: 28,
|
|
2864
3019
|
height: 28,
|
|
2865
3020
|
borderRadius: 4,
|
|
2866
|
-
borderWidth:
|
|
3021
|
+
borderWidth: StyleSheet11.hairlineWidth,
|
|
2867
3022
|
alignItems: "center",
|
|
2868
3023
|
justifyContent: "center"
|
|
2869
3024
|
},
|
|
@@ -2873,9 +3028,9 @@ var styles10 = StyleSheet10.create({
|
|
|
2873
3028
|
});
|
|
2874
3029
|
|
|
2875
3030
|
// src/ui/panels/OtherPanels.tsx
|
|
2876
|
-
import { useMemo as useMemo6, useState as
|
|
2877
|
-
import { Pressable as
|
|
2878
|
-
import
|
|
3031
|
+
import { useMemo as useMemo6, useState as useState9 } from "react";
|
|
3032
|
+
import { Pressable as Pressable11, ScrollView as ScrollView5, StyleSheet as StyleSheet12, Text as Text12, View as View10 } from "react-native";
|
|
3033
|
+
import Svg8, { Path as Path8 } from "react-native-svg";
|
|
2879
3034
|
|
|
2880
3035
|
// src/ui/table.ts
|
|
2881
3036
|
var DEFAULT_WIDTH = 120;
|
|
@@ -3013,7 +3168,7 @@ function sortedRows(columns, length, sort) {
|
|
|
3013
3168
|
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;
|
|
3014
3169
|
|
|
3015
3170
|
// src/ui/panels/OtherPanels.tsx
|
|
3016
|
-
import { jsx as
|
|
3171
|
+
import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3017
3172
|
function PieChartPanel({ panel, frames }) {
|
|
3018
3173
|
const theme = useDashTheme();
|
|
3019
3174
|
const [size, onLayout] = useLayout();
|
|
@@ -3021,7 +3176,7 @@ function PieChartPanel({ panel, frames }) {
|
|
|
3021
3176
|
() => reducedValues(panel, frames, theme.scheme).filter((v) => (v.value ?? 0) > 0),
|
|
3022
3177
|
[panel, frames, theme.scheme]
|
|
3023
3178
|
);
|
|
3024
|
-
if (!values.length) return /* @__PURE__ */
|
|
3179
|
+
if (!values.length) return /* @__PURE__ */ jsx14(NoData, {});
|
|
3025
3180
|
const total = values.reduce((a, v) => a + (v.value ?? 0), 0);
|
|
3026
3181
|
const r = Math.min(size.width, size.height) / 2 - 2;
|
|
3027
3182
|
const inner = panel.options?.pieType === "pie" ? 0 : r * 0.62;
|
|
@@ -3035,9 +3190,9 @@ function PieChartPanel({ panel, frames }) {
|
|
|
3035
3190
|
slices.push({ key: v.key, d: donutSlice(cx, cy, r, inner, angle + gap / 2, angle + sweep - gap / 2), color: v.color });
|
|
3036
3191
|
angle += sweep;
|
|
3037
3192
|
}
|
|
3038
|
-
return /* @__PURE__ */
|
|
3039
|
-
/* @__PURE__ */
|
|
3040
|
-
/* @__PURE__ */
|
|
3193
|
+
return /* @__PURE__ */ jsxs12(View10, { style: styles12.fill, children: [
|
|
3194
|
+
/* @__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)) }) }),
|
|
3195
|
+
/* @__PURE__ */ jsx14(
|
|
3041
3196
|
Legend,
|
|
3042
3197
|
{
|
|
3043
3198
|
items: values.map((v) => ({
|
|
@@ -3062,26 +3217,26 @@ function TablePanel({ panel, frames }) {
|
|
|
3062
3217
|
const { resolve, openLinks } = usePanelLinks(panel);
|
|
3063
3218
|
const frame = frames[0];
|
|
3064
3219
|
const columns = useMemo6(() => frame ? tableColumns(panel, frame, frames.length > 1) : [], [panel, frame, frames.length]);
|
|
3065
|
-
const [tapped, setSort] =
|
|
3220
|
+
const [tapped, setSort] = useState9();
|
|
3066
3221
|
const sort = tapped === void 0 ? initialSort(panel, columns) : tapped;
|
|
3067
3222
|
const order = useMemo6(() => sortedRows(columns, frame ? frameLength(frame) : 0, sort), [columns, frame, sort]);
|
|
3068
|
-
if (!frame || !frameLength(frame)) return /* @__PURE__ */
|
|
3223
|
+
if (!frame || !frameLength(frame)) return /* @__PURE__ */ jsx14(NoData, {});
|
|
3069
3224
|
const shown = order.slice(0, 500);
|
|
3070
3225
|
const rowColumn = columns.find((c) => c.applyToRow);
|
|
3071
3226
|
const footer = tableFooter(columns);
|
|
3072
|
-
return /* @__PURE__ */
|
|
3073
|
-
/* @__PURE__ */
|
|
3074
|
-
/* @__PURE__ */
|
|
3227
|
+
return /* @__PURE__ */ jsx14(ScrollView5, { horizontal: true, children: /* @__PURE__ */ jsxs12(View10, { style: styles12.fill, children: [
|
|
3228
|
+
/* @__PURE__ */ jsxs12(ScrollView5, { nestedScrollEnabled: true, style: styles12.fill, children: [
|
|
3229
|
+
/* @__PURE__ */ jsx14(View10, { style: [styles12.tr, { borderBottomColor: theme.border }], children: columns.map((c) => {
|
|
3075
3230
|
const active = sort?.key === c.key;
|
|
3076
|
-
return /* @__PURE__ */
|
|
3077
|
-
|
|
3231
|
+
return /* @__PURE__ */ jsx14(
|
|
3232
|
+
Pressable11,
|
|
3078
3233
|
{
|
|
3079
3234
|
onPress: () => setSort(nextSort(sort, c.key)),
|
|
3080
3235
|
accessibilityRole: "button",
|
|
3081
3236
|
accessibilityLabel: `Sort by ${c.name}`,
|
|
3082
3237
|
accessibilityState: { selected: active },
|
|
3083
3238
|
style: { width: c.width },
|
|
3084
|
-
children: /* @__PURE__ */
|
|
3239
|
+
children: /* @__PURE__ */ jsxs12(Text12, { style: [styles12.th, { color: active ? theme.text : theme.textSecondary, textAlign: c.align }], numberOfLines: 2, children: [
|
|
3085
3240
|
c.name,
|
|
3086
3241
|
active ? sort.desc ? " \u2193" : " \u2191" : ""
|
|
3087
3242
|
] })
|
|
@@ -3091,14 +3246,14 @@ function TablePanel({ panel, frames }) {
|
|
|
3091
3246
|
}) }),
|
|
3092
3247
|
shown.map((i) => {
|
|
3093
3248
|
const rowBg = rowColumn ? cellDisplay(rowColumn, rowColumn.field.values[i], theme.accent).background : void 0;
|
|
3094
|
-
return /* @__PURE__ */
|
|
3249
|
+
return /* @__PURE__ */ jsx14(View10, { style: [styles12.tr, { borderBottomColor: theme.grid }, rowBg ? { backgroundColor: rowBg } : null], children: columns.map((c) => {
|
|
3095
3250
|
const d = cellDisplay(c, c.field.values[i], theme.accent);
|
|
3096
3251
|
const bg = d.background ?? rowBg;
|
|
3097
3252
|
const linked = !!c.config.links?.length;
|
|
3098
3253
|
const color = d.color ?? (bg ? contrastText(bg, theme.text) : linked ? theme.accent : theme.text);
|
|
3099
|
-
const cellStyle = [
|
|
3100
|
-
return /* @__PURE__ */
|
|
3101
|
-
|
|
3254
|
+
const cellStyle = [styles12.td, { width: c.width }, d.background ? { backgroundColor: d.background } : null];
|
|
3255
|
+
return /* @__PURE__ */ jsxs12(
|
|
3256
|
+
Pressable11,
|
|
3102
3257
|
{
|
|
3103
3258
|
disabled: !linked,
|
|
3104
3259
|
onPress: () => openLinks(
|
|
@@ -3108,8 +3263,8 @@ function TablePanel({ panel, frames }) {
|
|
|
3108
3263
|
accessibilityRole: linked ? "link" : void 0,
|
|
3109
3264
|
style: ({ pressed }) => [cellStyle, pressed && { opacity: 0.6 }],
|
|
3110
3265
|
children: [
|
|
3111
|
-
d.gauge != null && /* @__PURE__ */
|
|
3112
|
-
/* @__PURE__ */
|
|
3266
|
+
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 }] }) }),
|
|
3267
|
+
/* @__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 })
|
|
3113
3268
|
]
|
|
3114
3269
|
},
|
|
3115
3270
|
c.key
|
|
@@ -3117,8 +3272,8 @@ function TablePanel({ panel, frames }) {
|
|
|
3117
3272
|
}) }, i);
|
|
3118
3273
|
})
|
|
3119
3274
|
] }),
|
|
3120
|
-
footer && /* @__PURE__ */
|
|
3121
|
-
line.label ? /* @__PURE__ */
|
|
3275
|
+
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: [
|
|
3276
|
+
line.label ? /* @__PURE__ */ jsx14(Text12, { style: { color: theme.textMuted, fontWeight: "400" }, children: `${line.label} ` }) : null,
|
|
3122
3277
|
line.text
|
|
3123
3278
|
] }, li)) }, c.key)) })
|
|
3124
3279
|
] }) });
|
|
@@ -3128,9 +3283,9 @@ function TextPanel({ panel }) {
|
|
|
3128
3283
|
const raw = panel.options?.content;
|
|
3129
3284
|
const content = typeof raw === "string" ? raw : "";
|
|
3130
3285
|
const text = panel.options?.mode === "html" ? content.replace(/<[^>]+>/g, "") : content;
|
|
3131
|
-
return /* @__PURE__ */
|
|
3286
|
+
return /* @__PURE__ */ jsx14(ScrollView5, { children: text.split(/\n{2,}/).map((block, i) => {
|
|
3132
3287
|
const heading = /^#{1,6}\s+/.test(block);
|
|
3133
|
-
return /* @__PURE__ */
|
|
3288
|
+
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);
|
|
3134
3289
|
}) });
|
|
3135
3290
|
}
|
|
3136
3291
|
function BarChartPanel({ panel, frames, width }) {
|
|
@@ -3139,13 +3294,13 @@ function BarChartPanel({ panel, frames, width }) {
|
|
|
3139
3294
|
const values = useMemo6(() => reducedValues(panel, frames, theme.scheme), [panel, frames, theme.scheme]);
|
|
3140
3295
|
const frame = frames[0];
|
|
3141
3296
|
const category = frame && barCategory(panel, frame);
|
|
3142
|
-
if (!frame || !values.length) return /* @__PURE__ */
|
|
3297
|
+
if (!frame || !values.length) return /* @__PURE__ */ jsx14(NoData, {});
|
|
3143
3298
|
const xField = panel.options?.xField;
|
|
3144
|
-
if (xField && !category) return /* @__PURE__ */
|
|
3299
|
+
if (xField && !category) return /* @__PURE__ */ jsx14(NoData, { message: `No field named \u201C${String(xField)}\u201D` });
|
|
3145
3300
|
const allNumeric = frame.fields.filter((f) => f.type === "number");
|
|
3146
3301
|
const at = (f) => values[allNumeric.indexOf(f)];
|
|
3147
3302
|
const numeric = category ? allNumeric.filter((f) => f !== category) : [];
|
|
3148
|
-
if (category && !numeric.length) return /* @__PURE__ */
|
|
3303
|
+
if (category && !numeric.length) return /* @__PURE__ */ jsx14(NoData, { message: `No number fields to draw besides \u201C${category.name}\u201D` });
|
|
3149
3304
|
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) }];
|
|
3150
3305
|
const labels = category ? categoryLabels(category) : values.map((v) => v.name);
|
|
3151
3306
|
const colorAt = (fi, i) => category ? fields[fi].color : values[i].color;
|
|
@@ -3160,34 +3315,34 @@ function BarChartPanel({ panel, frames, width }) {
|
|
|
3160
3315
|
const gridAxis = left ?? right;
|
|
3161
3316
|
const plotW = width - (left ? AXIS_W : 0) - (right ? AXIS_W : 0);
|
|
3162
3317
|
const every = Math.max(1, Math.ceil(labels.length / Math.max(1, Math.floor(plotW / 44))));
|
|
3163
|
-
const axisColumn = (axis) => /* @__PURE__ */
|
|
3164
|
-
|
|
3318
|
+
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(
|
|
3319
|
+
Text12,
|
|
3165
3320
|
{
|
|
3166
|
-
style: [
|
|
3321
|
+
style: [styles12.tick, { color: theme.textMuted, top: plot.height * (1 - barFraction(axis, t)) - 7 }, axis.side === "left" ? styles12.tickLeft : styles12.tickRight],
|
|
3167
3322
|
numberOfLines: 1,
|
|
3168
3323
|
children: formatValue(t, { ...axis.config, decimals: tickDecimals(axis.ticks) })
|
|
3169
3324
|
},
|
|
3170
3325
|
t
|
|
3171
3326
|
)) });
|
|
3172
|
-
return /* @__PURE__ */
|
|
3173
|
-
(left?.label || right?.label) && /* @__PURE__ */
|
|
3174
|
-
/* @__PURE__ */
|
|
3175
|
-
/* @__PURE__ */
|
|
3327
|
+
return /* @__PURE__ */ jsxs12(View10, { style: styles12.fill, children: [
|
|
3328
|
+
(left?.label || right?.label) && /* @__PURE__ */ jsxs12(View10, { style: styles12.axisLabels, children: [
|
|
3329
|
+
/* @__PURE__ */ jsx14(Text12, { style: [styles12.axisLabel, { color: theme.textMuted }], children: left?.label ?? "" }),
|
|
3330
|
+
/* @__PURE__ */ jsx14(Text12, { style: [styles12.axisLabel, { color: theme.textMuted }], children: right?.label ?? "" })
|
|
3176
3331
|
] }),
|
|
3177
|
-
/* @__PURE__ */
|
|
3332
|
+
/* @__PURE__ */ jsxs12(View10, { style: styles12.barRow, children: [
|
|
3178
3333
|
left && axisColumn(left),
|
|
3179
|
-
/* @__PURE__ */
|
|
3180
|
-
gridAxis && plot.height > 0 && gridAxis.ticks.map((t) => /* @__PURE__ */
|
|
3181
|
-
/* @__PURE__ */
|
|
3334
|
+
/* @__PURE__ */ jsxs12(View10, { style: styles12.fill, onLayout: onPlotLayout, children: [
|
|
3335
|
+
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)),
|
|
3336
|
+
/* @__PURE__ */ jsx14(View10, { style: styles12.barchart, children: labels.map((_, i) => /* @__PURE__ */ jsx14(View10, { style: styles12.barStack, children: fields.map((f, fi) => {
|
|
3182
3337
|
const axis = axisOf(fi);
|
|
3183
3338
|
const base = barFraction(axis, Math.min(Math.max(0, axis.bottom), axis.top));
|
|
3184
3339
|
const end = barFraction(axis, f.values[i] ?? 0);
|
|
3185
|
-
return /* @__PURE__ */
|
|
3340
|
+
return /* @__PURE__ */ jsx14(View10, { style: styles12.barSlot, children: /* @__PURE__ */ jsx14(
|
|
3186
3341
|
View10,
|
|
3187
3342
|
{
|
|
3188
3343
|
style: [
|
|
3189
|
-
|
|
3190
|
-
end < base &&
|
|
3344
|
+
styles12.bar,
|
|
3345
|
+
end < base && styles12.barDown,
|
|
3191
3346
|
{ bottom: `${Math.min(base, end) * 100}%`, height: `${Math.abs(end - base) * 100}%`, backgroundColor: colorAt(fi, i) }
|
|
3192
3347
|
]
|
|
3193
3348
|
}
|
|
@@ -3196,8 +3351,8 @@ function BarChartPanel({ panel, frames, width }) {
|
|
|
3196
3351
|
] }),
|
|
3197
3352
|
right && axisColumn(right)
|
|
3198
3353
|
] }),
|
|
3199
|
-
/* @__PURE__ */
|
|
3200
|
-
category && fields.length > 1 && /* @__PURE__ */
|
|
3354
|
+
/* @__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)) }),
|
|
3355
|
+
category && fields.length > 1 && /* @__PURE__ */ jsx14(Legend, { items: fields })
|
|
3201
3356
|
] });
|
|
3202
3357
|
}
|
|
3203
3358
|
var AXIS_W = 40;
|
|
@@ -3207,15 +3362,15 @@ function num2(v) {
|
|
|
3207
3362
|
return Number.isFinite(n) ? n : null;
|
|
3208
3363
|
}
|
|
3209
3364
|
function UnsupportedPanel({ panel }) {
|
|
3210
|
-
return /* @__PURE__ */
|
|
3365
|
+
return /* @__PURE__ */ jsx14(NoData, { message: `"${panel.type}" panels aren't supported yet` });
|
|
3211
3366
|
}
|
|
3212
|
-
var
|
|
3367
|
+
var styles12 = StyleSheet12.create({
|
|
3213
3368
|
fill: { flex: 1 },
|
|
3214
|
-
tr: { flexDirection: "row", borderBottomWidth:
|
|
3369
|
+
tr: { flexDirection: "row", borderBottomWidth: StyleSheet12.hairlineWidth },
|
|
3215
3370
|
th: { paddingVertical: 6, paddingHorizontal: 6, fontSize: 12, fontWeight: "600" },
|
|
3216
3371
|
td: { paddingVertical: 6, paddingHorizontal: 6, justifyContent: "center" },
|
|
3217
3372
|
cellText: { fontSize: 12 },
|
|
3218
|
-
footer: { borderBottomWidth: 0, borderTopWidth:
|
|
3373
|
+
footer: { borderBottomWidth: 0, borderTopWidth: StyleSheet12.hairlineWidth },
|
|
3219
3374
|
footerText: { fontWeight: "600", fontVariant: ["tabular-nums"] },
|
|
3220
3375
|
gaugeTrack: { position: "absolute", left: 6, right: 6, bottom: 3, height: 3, borderRadius: 2, overflow: "hidden" },
|
|
3221
3376
|
gaugeFill: { height: "100%", borderRadius: 2 },
|
|
@@ -3231,7 +3386,7 @@ var styles11 = StyleSheet11.create({
|
|
|
3231
3386
|
barDown: { borderTopLeftRadius: 0, borderTopRightRadius: 0, borderBottomLeftRadius: 4, borderBottomRightRadius: 4 },
|
|
3232
3387
|
barLabels: { flexDirection: "row", gap: 2 },
|
|
3233
3388
|
barLabel: { flex: 1, fontSize: 10, marginTop: 4, textAlign: "center" },
|
|
3234
|
-
gridLine: { position: "absolute", left: 0, right: 0, height:
|
|
3389
|
+
gridLine: { position: "absolute", left: 0, right: 0, height: StyleSheet12.hairlineWidth },
|
|
3235
3390
|
axis: { width: AXIS_W },
|
|
3236
3391
|
axisLeft: { paddingRight: 6 },
|
|
3237
3392
|
axisRight: { paddingLeft: 6 },
|
|
@@ -3243,10 +3398,10 @@ var styles11 = StyleSheet11.create({
|
|
|
3243
3398
|
});
|
|
3244
3399
|
|
|
3245
3400
|
// src/ui/panels/TimeSeriesPanel.tsx
|
|
3246
|
-
import { useId, useMemo as useMemo7, useRef as
|
|
3247
|
-
import { Pressable as
|
|
3248
|
-
import
|
|
3249
|
-
import { jsx as
|
|
3401
|
+
import { useId, useMemo as useMemo7, useRef as useRef5, useState as useState10 } from "react";
|
|
3402
|
+
import { Pressable as Pressable12, StyleSheet as StyleSheet13, Text as Text13, View as View11 } from "react-native";
|
|
3403
|
+
import Svg9, { Circle, ClipPath, Defs, G, Line, Path as Path9, Rect, Text as SvgText3 } from "react-native-svg";
|
|
3404
|
+
import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
3250
3405
|
var BASE_PAD = { top: 8, right: 8, bottom: 20, left: 44 };
|
|
3251
3406
|
var BAR_MAX = 24;
|
|
3252
3407
|
function TimeSeriesPanel({ panel, frames }) {
|
|
@@ -3254,20 +3409,20 @@ function TimeSeriesPanel({ panel, frames }) {
|
|
|
3254
3409
|
const { range: range3, setRawRange, pinned, setPinned } = useDashboard();
|
|
3255
3410
|
const { resolve, openLinks } = usePanelLinks(panel);
|
|
3256
3411
|
const [size, onLayout] = useLayout();
|
|
3257
|
-
const [hoverX, setHoverX] =
|
|
3258
|
-
const [preview, setPreview] =
|
|
3259
|
-
const [xZoom, setXZoom] =
|
|
3260
|
-
const pinch =
|
|
3261
|
-
const originX =
|
|
3412
|
+
const [hoverX, setHoverX] = useState10(null);
|
|
3413
|
+
const [preview, setPreview] = useState10(null);
|
|
3414
|
+
const [xZoom, setXZoom] = useState10(null);
|
|
3415
|
+
const pinch = useRef5(null);
|
|
3416
|
+
const originX = useRef5(0);
|
|
3262
3417
|
const id = useId();
|
|
3263
3418
|
const clipId = `plot${id.replace(/[^a-zA-Z0-9]/g, "")}`;
|
|
3264
|
-
const [touching, setTouching] =
|
|
3419
|
+
const [touching, setTouching] = useState10(false);
|
|
3265
3420
|
const numericX = panel.type === "trend";
|
|
3266
3421
|
const { series, xConfig } = useMemo7(
|
|
3267
3422
|
() => numericX ? styledXYSeries(panel, frames, theme.scheme) : { series: styledSeries(panel, frames, theme.scheme), xConfig: {} },
|
|
3268
3423
|
[numericX, panel, frames, theme.scheme]
|
|
3269
3424
|
);
|
|
3270
|
-
if (!series.length || series.every((s) => s.values.every((v) => v == null))) return /* @__PURE__ */
|
|
3425
|
+
if (!series.length || series.every((s) => s.values.every((v) => v == null))) return /* @__PURE__ */ jsx15(NoData, {});
|
|
3271
3426
|
const style = (s) => s.config.custom?.drawStyle ?? (panel.type === "graph" && panel.bars ? "bars" : "line");
|
|
3272
3427
|
const anyBars = series.some((s) => style(s) === "bars");
|
|
3273
3428
|
const anyFill = series.some((s) => (s.config.custom?.fillOpacity ?? 0) > 0);
|
|
@@ -3326,11 +3481,11 @@ function TimeSeriesPanel({ panel, frames }) {
|
|
|
3326
3481
|
)
|
|
3327
3482
|
) : [];
|
|
3328
3483
|
const isPinned = !!hover && pinned === id;
|
|
3329
|
-
return /* @__PURE__ */
|
|
3330
|
-
/* @__PURE__ */
|
|
3484
|
+
return /* @__PURE__ */ jsxs13(View11, { style: styles13.fill, children: [
|
|
3485
|
+
/* @__PURE__ */ jsx15(
|
|
3331
3486
|
View11,
|
|
3332
3487
|
{
|
|
3333
|
-
style:
|
|
3488
|
+
style: styles13.fill,
|
|
3334
3489
|
onStartShouldSetResponderCapture: twoFingers,
|
|
3335
3490
|
onMoveShouldSetResponderCapture: twoFingers,
|
|
3336
3491
|
onResponderTerminationRequest: () => false,
|
|
@@ -3342,10 +3497,10 @@ function TimeSeriesPanel({ panel, frames }) {
|
|
|
3342
3497
|
onResponderMove: onPinchMove,
|
|
3343
3498
|
onResponderRelease: () => onPinchEnd(true),
|
|
3344
3499
|
onResponderTerminate: () => onPinchEnd(false),
|
|
3345
|
-
children: /* @__PURE__ */
|
|
3500
|
+
children: /* @__PURE__ */ jsxs13(
|
|
3346
3501
|
View11,
|
|
3347
3502
|
{
|
|
3348
|
-
style:
|
|
3503
|
+
style: styles13.fill,
|
|
3349
3504
|
onLayout,
|
|
3350
3505
|
onStartShouldSetResponder: () => true,
|
|
3351
3506
|
onResponderGrant: (e) => {
|
|
@@ -3365,12 +3520,12 @@ function TimeSeriesPanel({ panel, frames }) {
|
|
|
3365
3520
|
setHoverX(null);
|
|
3366
3521
|
},
|
|
3367
3522
|
children: [
|
|
3368
|
-
size.width > 0 && /* @__PURE__ */
|
|
3369
|
-
ticks.map((t) => /* @__PURE__ */
|
|
3370
|
-
/* @__PURE__ */
|
|
3371
|
-
/* @__PURE__ */
|
|
3523
|
+
size.width > 0 && /* @__PURE__ */ jsxs13(Svg9, { width: size.width, height: size.height, children: [
|
|
3524
|
+
ticks.map((t) => /* @__PURE__ */ jsxs13(G, { children: [
|
|
3525
|
+
/* @__PURE__ */ jsx15(Line, { x1: PAD.left, x2: PAD.left + plotW, y1: y(t), y2: y(t), stroke: theme.grid, strokeWidth: 1 }),
|
|
3526
|
+
/* @__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) }) })
|
|
3372
3527
|
] }, t)),
|
|
3373
|
-
xTicks.map((t) => /* @__PURE__ */
|
|
3528
|
+
xTicks.map((t) => /* @__PURE__ */ jsx15(
|
|
3374
3529
|
SvgText3,
|
|
3375
3530
|
{
|
|
3376
3531
|
x: x(t),
|
|
@@ -3382,65 +3537,65 @@ function TimeSeriesPanel({ panel, frames }) {
|
|
|
3382
3537
|
},
|
|
3383
3538
|
t
|
|
3384
3539
|
)),
|
|
3385
|
-
/* @__PURE__ */
|
|
3386
|
-
/* @__PURE__ */
|
|
3387
|
-
/* @__PURE__ */
|
|
3540
|
+
/* @__PURE__ */ jsx15(AxisTitles, { x: xTitle, y: yTitle, plot: { left: PAD.left, top: PAD.top, width: plotW, height: plotH }, height: size.height }),
|
|
3541
|
+
/* @__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 }) }) }),
|
|
3542
|
+
/* @__PURE__ */ jsxs13(G, { clipPath: `url(#${clipId})`, children: [
|
|
3388
3543
|
barSeries.map(
|
|
3389
3544
|
(s, si) => s.times.map((t, i) => {
|
|
3390
3545
|
const v = s.values[i];
|
|
3391
3546
|
if (v == null || t < xFrom || t > xTo) return null;
|
|
3392
3547
|
const left = x(t) - groupW / 2 + si * (groupW / barSeries.length);
|
|
3393
|
-
return /* @__PURE__ */
|
|
3548
|
+
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}`);
|
|
3394
3549
|
})
|
|
3395
3550
|
),
|
|
3396
3551
|
series.filter((s) => style(s) !== "bars").map((s) => {
|
|
3397
3552
|
const fill = (s.config.custom?.fillOpacity ?? 0) / 100;
|
|
3398
3553
|
const showPoints = style(s) === "points" || s.config.custom?.showPoints === "always" || s.config.custom?.showPoints !== "never" && s.times.length <= plotW / 14;
|
|
3399
3554
|
const segs = segments(s, x, y, s.config.custom?.lineInterpolation === "stepAfter");
|
|
3400
|
-
return /* @__PURE__ */
|
|
3401
|
-
fill > 0 && segs.map((seg, i) => /* @__PURE__ */
|
|
3402
|
-
style(s) !== "points" && segs.map((seg, i) => /* @__PURE__ */
|
|
3555
|
+
return /* @__PURE__ */ jsxs13(G, { children: [
|
|
3556
|
+
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}`)),
|
|
3557
|
+
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}`)),
|
|
3403
3558
|
showPoints && s.times.map(
|
|
3404
|
-
(t, i) => s.values[i] == null ? null : /* @__PURE__ */
|
|
3559
|
+
(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)
|
|
3405
3560
|
)
|
|
3406
3561
|
] }, s.key);
|
|
3407
3562
|
}),
|
|
3408
|
-
hover && /* @__PURE__ */
|
|
3409
|
-
/* @__PURE__ */
|
|
3563
|
+
hover && /* @__PURE__ */ jsxs13(G, { children: [
|
|
3564
|
+
/* @__PURE__ */ jsx15(Line, { x1: x(hover.time), x2: x(hover.time), y1: PAD.top, y2: PAD.top + plotH, stroke: theme.textMuted, strokeWidth: 1 }),
|
|
3410
3565
|
hover.rows.map(
|
|
3411
|
-
(r) => r.value == null ? null : /* @__PURE__ */
|
|
3566
|
+
(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)
|
|
3412
3567
|
)
|
|
3413
3568
|
] })
|
|
3414
3569
|
] })
|
|
3415
3570
|
] }),
|
|
3416
|
-
xZoom && !preview && /* @__PURE__ */
|
|
3417
|
-
|
|
3571
|
+
xZoom && !preview && /* @__PURE__ */ jsx15(
|
|
3572
|
+
Pressable12,
|
|
3418
3573
|
{
|
|
3419
3574
|
onPress: () => setXZoom(null),
|
|
3420
3575
|
accessibilityRole: "button",
|
|
3421
3576
|
hitSlop: 8,
|
|
3422
|
-
style: ({ pressed }) => [
|
|
3423
|
-
children: /* @__PURE__ */
|
|
3577
|
+
style: ({ pressed }) => [styles13.reset, { backgroundColor: theme.surface, borderColor: theme.border }, pressed && { opacity: 0.7 }],
|
|
3578
|
+
children: /* @__PURE__ */ jsx15(Text13, { style: [styles13.resetText, { color: theme.accent }], children: "Reset zoom" })
|
|
3424
3579
|
}
|
|
3425
3580
|
),
|
|
3426
|
-
hover && /* @__PURE__ */
|
|
3581
|
+
hover && /* @__PURE__ */ jsxs13(
|
|
3427
3582
|
View11,
|
|
3428
3583
|
{
|
|
3429
3584
|
pointerEvents: isPinned ? "auto" : "none",
|
|
3430
3585
|
onStartShouldSetResponder: () => isPinned,
|
|
3431
3586
|
style: [
|
|
3432
|
-
|
|
3587
|
+
styles13.tooltip,
|
|
3433
3588
|
{ backgroundColor: theme.surface, borderColor: theme.border },
|
|
3434
3589
|
x(hover.time) > size.width / 2 ? { right: size.width - x(hover.time) + 8 } : { left: x(hover.time) + 8 }
|
|
3435
3590
|
],
|
|
3436
3591
|
children: [
|
|
3437
|
-
/* @__PURE__ */
|
|
3438
|
-
hover.rows.map((r) => /* @__PURE__ */
|
|
3439
|
-
/* @__PURE__ */
|
|
3440
|
-
/* @__PURE__ */
|
|
3441
|
-
/* @__PURE__ */
|
|
3592
|
+
/* @__PURE__ */ jsx15(Text13, { style: [styles13.tooltipTime, { color: theme.textMuted }], children: numericX ? formatValue(hover.time, xConfig) : formatTooltipTime(hover.time) }),
|
|
3593
|
+
hover.rows.map((r) => /* @__PURE__ */ jsxs13(View11, { style: styles13.tooltipRow, children: [
|
|
3594
|
+
/* @__PURE__ */ jsx15(View11, { style: [styles13.swatch, { backgroundColor: r.color }] }),
|
|
3595
|
+
/* @__PURE__ */ jsx15(Text13, { style: [styles13.tooltipName, { color: theme.textSecondary }], numberOfLines: 1, children: r.name }),
|
|
3596
|
+
/* @__PURE__ */ jsx15(Text13, { style: [styles13.tooltipValue, { color: theme.text }], children: formatValue(r.value, r.config) })
|
|
3442
3597
|
] }, r.key)),
|
|
3443
|
-
isPinned && /* @__PURE__ */
|
|
3598
|
+
isPinned && /* @__PURE__ */ jsx15(TooltipLinks, { links: hoverLinks, onOpen: (l) => openLinks([l]) })
|
|
3444
3599
|
]
|
|
3445
3600
|
}
|
|
3446
3601
|
)
|
|
@@ -3449,7 +3604,7 @@ function TimeSeriesPanel({ panel, frames }) {
|
|
|
3449
3604
|
)
|
|
3450
3605
|
}
|
|
3451
3606
|
),
|
|
3452
|
-
showLegend(panel, series.length) && /* @__PURE__ */
|
|
3607
|
+
showLegend(panel, series.length) && /* @__PURE__ */ jsx15(Legend, { items: series })
|
|
3453
3608
|
] });
|
|
3454
3609
|
}
|
|
3455
3610
|
function segments(s, x, y, step = false) {
|
|
@@ -3538,7 +3693,7 @@ function linkData(r, frames, xField) {
|
|
|
3538
3693
|
time: xField === void 0 ? r.time : void 0
|
|
3539
3694
|
};
|
|
3540
3695
|
}
|
|
3541
|
-
var
|
|
3696
|
+
var styles13 = StyleSheet13.create({
|
|
3542
3697
|
fill: { flex: 1 },
|
|
3543
3698
|
tooltip: {
|
|
3544
3699
|
position: "absolute",
|
|
@@ -3546,7 +3701,7 @@ var styles12 = StyleSheet12.create({
|
|
|
3546
3701
|
paddingHorizontal: 8,
|
|
3547
3702
|
paddingVertical: 6,
|
|
3548
3703
|
borderRadius: 6,
|
|
3549
|
-
borderWidth:
|
|
3704
|
+
borderWidth: StyleSheet13.hairlineWidth,
|
|
3550
3705
|
maxWidth: 220,
|
|
3551
3706
|
shadowColor: "#000",
|
|
3552
3707
|
shadowOpacity: 0.12,
|
|
@@ -3554,7 +3709,7 @@ var styles12 = StyleSheet12.create({
|
|
|
3554
3709
|
shadowOffset: { width: 0, height: 2 },
|
|
3555
3710
|
elevation: 3
|
|
3556
3711
|
},
|
|
3557
|
-
reset: { position: "absolute", top: 4, right: 8, paddingHorizontal: 8, paddingVertical: 3, borderRadius: 6, borderWidth:
|
|
3712
|
+
reset: { position: "absolute", top: 4, right: 8, paddingHorizontal: 8, paddingVertical: 3, borderRadius: 6, borderWidth: StyleSheet13.hairlineWidth },
|
|
3558
3713
|
resetText: { fontSize: 11, fontWeight: "600" },
|
|
3559
3714
|
tooltipTime: { fontSize: 11, marginBottom: 3 },
|
|
3560
3715
|
tooltipRow: { flexDirection: "row", alignItems: "center", gap: 6 },
|
|
@@ -3564,9 +3719,9 @@ var styles12 = StyleSheet12.create({
|
|
|
3564
3719
|
});
|
|
3565
3720
|
|
|
3566
3721
|
// src/ui/panels/XYChartPanel.tsx
|
|
3567
|
-
import { useId as useId2, useMemo as useMemo8, useState as
|
|
3568
|
-
import { StyleSheet as
|
|
3569
|
-
import
|
|
3722
|
+
import { useId as useId2, useMemo as useMemo8, useState as useState11 } from "react";
|
|
3723
|
+
import { StyleSheet as StyleSheet14, View as View12 } from "react-native";
|
|
3724
|
+
import Svg10, { Circle as Circle2, G as G2, Line as Line2, Path as Path10, Text as SvgText4 } from "react-native-svg";
|
|
3570
3725
|
|
|
3571
3726
|
// src/ui/xychart.ts
|
|
3572
3727
|
var byName = (name) => name ? { matcher: { id: "byName", options: name } } : void 0;
|
|
@@ -3697,15 +3852,15 @@ function xyDomain(values, config) {
|
|
|
3697
3852
|
}
|
|
3698
3853
|
|
|
3699
3854
|
// src/ui/panels/XYChartPanel.tsx
|
|
3700
|
-
import { jsx as
|
|
3855
|
+
import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
3701
3856
|
var AXIS = { left: 44, bottom: 20 };
|
|
3702
3857
|
var EDGE = 8;
|
|
3703
3858
|
var HIT_PX2 = 32;
|
|
3704
3859
|
function XYChartPanel({ panel, frames }) {
|
|
3705
3860
|
const theme = useDashTheme();
|
|
3706
3861
|
const [size, onLayout] = useLayout();
|
|
3707
|
-
const [touch, setTouch] =
|
|
3708
|
-
const [touching, setTouching] =
|
|
3862
|
+
const [touch, setTouch] = useState11(null);
|
|
3863
|
+
const [touching, setTouching] = useState11(false);
|
|
3709
3864
|
const id = useId2();
|
|
3710
3865
|
const { pinned, setPinned } = useDashboard();
|
|
3711
3866
|
const { resolve, openLinks } = usePanelLinks(panel);
|
|
@@ -3732,7 +3887,7 @@ function XYChartPanel({ panel, frames }) {
|
|
|
3732
3887
|
const points = series.map((s) => ({ px: s.xs.map(x), py: s.ys.map(y) }));
|
|
3733
3888
|
return { x, y, x0, x1, y0, y1, points, paths: series.map((s, i) => drawSeries(s, points[i].px, points[i].py)) };
|
|
3734
3889
|
}, [series, first, pad.left, pad.top, plotW, plotH]);
|
|
3735
|
-
if (!first || !layout || series.every((s) => !s.rows.length)) return /* @__PURE__ */
|
|
3890
|
+
if (!first || !layout || series.every((s) => !s.rows.length)) return /* @__PURE__ */ jsx16(NoData, {});
|
|
3736
3891
|
const xTicks = showX ? axisTicks(layout.x0, layout.x1, plotW < 220 ? 2 : plotW < 400 ? 3 : 5) : [];
|
|
3737
3892
|
const yTicks = showY ? axisTicks(layout.y0, layout.y1, plotH < 100 ? 2 : 4) : [];
|
|
3738
3893
|
const gridX = first.xConfig.custom?.axisGridShow !== false;
|
|
@@ -3741,11 +3896,11 @@ function XYChartPanel({ panel, frames }) {
|
|
|
3741
3896
|
const hoverLinks = hover ? rowLinks(panel, hover.series.frame, hover.series.rows[hover.index], frames.length > 1, resolve) : [];
|
|
3742
3897
|
const isPinned = !!hover && pinned === id;
|
|
3743
3898
|
const legendItems = series.filter((s) => !s.yConfig.custom?.hideFrom?.legend);
|
|
3744
|
-
return /* @__PURE__ */
|
|
3745
|
-
/* @__PURE__ */
|
|
3899
|
+
return /* @__PURE__ */ jsxs14(View12, { style: styles14.fill, children: [
|
|
3900
|
+
/* @__PURE__ */ jsxs14(
|
|
3746
3901
|
View12,
|
|
3747
3902
|
{
|
|
3748
|
-
style:
|
|
3903
|
+
style: styles14.fill,
|
|
3749
3904
|
onLayout,
|
|
3750
3905
|
onStartShouldSetResponder: () => true,
|
|
3751
3906
|
onResponderGrant: (e) => {
|
|
@@ -3764,14 +3919,14 @@ function XYChartPanel({ panel, frames }) {
|
|
|
3764
3919
|
setTouch(null);
|
|
3765
3920
|
},
|
|
3766
3921
|
children: [
|
|
3767
|
-
size.width > 0 && /* @__PURE__ */
|
|
3768
|
-
yTicks.map((t) => /* @__PURE__ */
|
|
3769
|
-
gridY && /* @__PURE__ */
|
|
3770
|
-
/* @__PURE__ */
|
|
3922
|
+
size.width > 0 && /* @__PURE__ */ jsxs14(Svg10, { width: size.width, height: size.height, children: [
|
|
3923
|
+
yTicks.map((t) => /* @__PURE__ */ jsxs14(G2, { children: [
|
|
3924
|
+
gridY && /* @__PURE__ */ jsx16(Line2, { x1: pad.left, x2: pad.left + plotW, y1: layout.y(t), y2: layout.y(t), stroke: theme.grid, strokeWidth: 1 }),
|
|
3925
|
+
/* @__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) }) })
|
|
3771
3926
|
] }, `y${t}`)),
|
|
3772
|
-
xTicks.map((t) => /* @__PURE__ */
|
|
3773
|
-
gridX && /* @__PURE__ */
|
|
3774
|
-
/* @__PURE__ */
|
|
3927
|
+
xTicks.map((t) => /* @__PURE__ */ jsxs14(G2, { children: [
|
|
3928
|
+
gridX && /* @__PURE__ */ jsx16(Line2, { x1: layout.x(t), x2: layout.x(t), y1: pad.top, y2: pad.top + plotH, stroke: theme.grid, strokeWidth: 1 }),
|
|
3929
|
+
/* @__PURE__ */ jsx16(
|
|
3775
3930
|
SvgText4,
|
|
3776
3931
|
{
|
|
3777
3932
|
x: layout.x(t),
|
|
@@ -3783,12 +3938,12 @@ function XYChartPanel({ panel, frames }) {
|
|
|
3783
3938
|
}
|
|
3784
3939
|
)
|
|
3785
3940
|
] }, `x${t}`)),
|
|
3786
|
-
/* @__PURE__ */
|
|
3787
|
-
series.map((s, si) => /* @__PURE__ */
|
|
3788
|
-
layout.paths[si].line && /* @__PURE__ */
|
|
3789
|
-
layout.paths[si].dots.map(([color, d]) => /* @__PURE__ */
|
|
3941
|
+
/* @__PURE__ */ jsx16(AxisTitles, { x: xTitle, y: yTitle, plot: { left: pad.left, top: pad.top, width: plotW, height: plotH }, height: size.height }),
|
|
3942
|
+
series.map((s, si) => /* @__PURE__ */ jsxs14(G2, { children: [
|
|
3943
|
+
layout.paths[si].line && /* @__PURE__ */ jsx16(Path10, { d: layout.paths[si].line, stroke: s.color, strokeWidth: s.lineWidth, fill: "none", strokeLinejoin: "round" }),
|
|
3944
|
+
layout.paths[si].dots.map(([color, d]) => /* @__PURE__ */ jsx16(Path10, { d, fill: color }, color))
|
|
3790
3945
|
] }, s.key)),
|
|
3791
|
-
hover && /* @__PURE__ */
|
|
3946
|
+
hover && /* @__PURE__ */ jsx16(
|
|
3792
3947
|
Circle2,
|
|
3793
3948
|
{
|
|
3794
3949
|
cx: hover.px,
|
|
@@ -3800,7 +3955,7 @@ function XYChartPanel({ panel, frames }) {
|
|
|
3800
3955
|
}
|
|
3801
3956
|
)
|
|
3802
3957
|
] }),
|
|
3803
|
-
hover && /* @__PURE__ */
|
|
3958
|
+
hover && /* @__PURE__ */ jsx16(
|
|
3804
3959
|
RowTooltip,
|
|
3805
3960
|
{
|
|
3806
3961
|
at: { x: hover.px, y: hover.py },
|
|
@@ -3815,7 +3970,7 @@ function XYChartPanel({ panel, frames }) {
|
|
|
3815
3970
|
]
|
|
3816
3971
|
}
|
|
3817
3972
|
),
|
|
3818
|
-
showLegend(panel, legendItems.length) && /* @__PURE__ */
|
|
3973
|
+
showLegend(panel, legendItems.length) && /* @__PURE__ */ jsx16(Legend, { items: legendItems })
|
|
3819
3974
|
] });
|
|
3820
3975
|
}
|
|
3821
3976
|
function drawSeries(s, px, py) {
|
|
@@ -3849,7 +4004,7 @@ function nearestPoint(series, points, at) {
|
|
|
3849
4004
|
});
|
|
3850
4005
|
return best;
|
|
3851
4006
|
}
|
|
3852
|
-
var
|
|
4007
|
+
var styles14 = StyleSheet14.create({
|
|
3853
4008
|
fill: { flex: 1 }
|
|
3854
4009
|
});
|
|
3855
4010
|
|
|
@@ -3877,7 +4032,7 @@ function panelComponent(type) {
|
|
|
3877
4032
|
}
|
|
3878
4033
|
|
|
3879
4034
|
// src/ui/DashboardView.tsx
|
|
3880
|
-
import { jsx as
|
|
4035
|
+
import { jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3881
4036
|
var GAP2 = 8;
|
|
3882
4037
|
var SIDE = 12;
|
|
3883
4038
|
var TITLE_H = 28;
|
|
@@ -3895,44 +4050,44 @@ function DashboardView({ mode = "auto", header, footer, refreshable }) {
|
|
|
3895
4050
|
() => layoutDashboard(dashboard, layoutMode, { values: variables, info: variableInfo2 }),
|
|
3896
4051
|
[dashboard, layoutMode, variables, variableInfo2]
|
|
3897
4052
|
);
|
|
3898
|
-
const [toggled, setToggled] =
|
|
4053
|
+
const [toggled, setToggled] = useState12({});
|
|
3899
4054
|
const { seen, viewportH, onScroll, onViewportLayout, onSectionLayout } = useSeenSections(window.height);
|
|
3900
4055
|
const maxPanelH = Math.max(MIN_PANEL_H, viewportH - SIDE * 2);
|
|
3901
4056
|
const contentW = width - SIDE * 2;
|
|
3902
4057
|
const canRefresh = refreshable ?? dashboard.panels.some((p) => panelHasQueries(p) || p.panels?.some(panelHasQueries));
|
|
3903
|
-
return /* @__PURE__ */
|
|
3904
|
-
width > 0 && /* @__PURE__ */
|
|
4058
|
+
return /* @__PURE__ */ jsxs15(View13, { style: [styles15.fill, { backgroundColor: theme.background }], onLayout, children: [
|
|
4059
|
+
width > 0 && /* @__PURE__ */ jsxs15(
|
|
3905
4060
|
ScrollView6,
|
|
3906
4061
|
{
|
|
3907
4062
|
onScroll,
|
|
3908
4063
|
onScrollBeginDrag: () => setPinned(null),
|
|
3909
4064
|
onLayout: onViewportLayout,
|
|
3910
4065
|
scrollEventThrottle: 100,
|
|
3911
|
-
contentContainerStyle: [
|
|
4066
|
+
contentContainerStyle: [styles15.content, { paddingLeft: SIDE + insets.left, paddingRight: SIDE + insets.right }],
|
|
3912
4067
|
keyboardShouldPersistTaps: "handled",
|
|
3913
|
-
refreshControl: canRefresh ? /* @__PURE__ */
|
|
4068
|
+
refreshControl: canRefresh ? /* @__PURE__ */ jsx17(RefreshControl, { refreshing: false, onRefresh: refresh }) : void 0,
|
|
3914
4069
|
children: [
|
|
3915
4070
|
header,
|
|
3916
4071
|
sections.map((section) => {
|
|
3917
4072
|
const collapsed = toggled[section.key] ?? section.collapsed;
|
|
3918
|
-
return /* @__PURE__ */
|
|
3919
|
-
section.row && /* @__PURE__ */
|
|
3920
|
-
|
|
4073
|
+
return /* @__PURE__ */ jsxs15(View13, { style: styles15.section, onLayout: (e) => onSectionLayout(section.key, e), children: [
|
|
4074
|
+
section.row && /* @__PURE__ */ jsxs15(
|
|
4075
|
+
Pressable13,
|
|
3921
4076
|
{
|
|
3922
4077
|
onPress: () => setToggled((t) => ({ ...t, [section.key]: !collapsed })),
|
|
3923
|
-
style:
|
|
4078
|
+
style: styles15.rowHeader,
|
|
3924
4079
|
accessibilityRole: "button",
|
|
3925
4080
|
accessibilityState: { expanded: !collapsed },
|
|
3926
4081
|
children: [
|
|
3927
|
-
/* @__PURE__ */
|
|
3928
|
-
/* @__PURE__ */
|
|
4082
|
+
/* @__PURE__ */ jsx17(Text14, { style: [styles15.chevron, { color: theme.textMuted }], children: collapsed ? "\u25B8" : "\u25BE" }),
|
|
4083
|
+
/* @__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 }) })
|
|
3929
4084
|
]
|
|
3930
4085
|
}
|
|
3931
4086
|
),
|
|
3932
|
-
!collapsed && layoutMode === "grid" && /* @__PURE__ */
|
|
3933
|
-
!collapsed && layoutMode === "phone" && section.rows.map((row, ri) => /* @__PURE__ */
|
|
4087
|
+
!collapsed && layoutMode === "grid" && /* @__PURE__ */ jsx17(GridSection, { grid: section.grid, width: contentW, maxPanelH, deferred: !seen.has(section.key) }),
|
|
4088
|
+
!collapsed && layoutMode === "phone" && section.rows.map((row, ri) => /* @__PURE__ */ jsx17(View13, { style: styles15.row, children: row.cells.map((cell) => {
|
|
3934
4089
|
const w = (contentW + GAP2) * (cell.span / GRID_COLUMNS) - GAP2;
|
|
3935
|
-
return /* @__PURE__ */
|
|
4090
|
+
return /* @__PURE__ */ jsx17(PanelCard, { panel: cell.panel, width: w, height: Math.min(gridUnitsToPx(row.h), maxPanelH), deferred: !seen.has(section.key) }, cell.key);
|
|
3936
4091
|
}) }, ri))
|
|
3937
4092
|
] }, section.key);
|
|
3938
4093
|
})
|
|
@@ -3946,13 +4101,13 @@ function GridSection({ grid, width, maxPanelH, deferred }) {
|
|
|
3946
4101
|
const colW = (width + GAP2) / GRID_COLUMNS;
|
|
3947
4102
|
const tallest = Math.max(0, ...grid.cells.map((c) => gridUnitsToPx(c.h)));
|
|
3948
4103
|
const scale = tallest > maxPanelH ? maxPanelH / tallest : 1;
|
|
3949
|
-
return /* @__PURE__ */
|
|
4104
|
+
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)) });
|
|
3950
4105
|
}
|
|
3951
4106
|
function useSeenSections(viewportHeight) {
|
|
3952
|
-
const [seen, setSeen] =
|
|
3953
|
-
const view =
|
|
3954
|
-
const [viewportH, setViewportH] =
|
|
3955
|
-
const positions =
|
|
4107
|
+
const [seen, setSeen] = useState12(/* @__PURE__ */ new Set());
|
|
4108
|
+
const view = useRef6({ y: 0, h: viewportHeight });
|
|
4109
|
+
const [viewportH, setViewportH] = useState12(viewportHeight);
|
|
4110
|
+
const positions = useRef6(/* @__PURE__ */ new Map());
|
|
3956
4111
|
const reveal = useCallback3(() => {
|
|
3957
4112
|
const { y, h } = view.current;
|
|
3958
4113
|
setSeen((prev) => {
|
|
@@ -3991,14 +4146,14 @@ function useSeenSections(viewportHeight) {
|
|
|
3991
4146
|
}
|
|
3992
4147
|
function PanelCard(props) {
|
|
3993
4148
|
const { panel, width, height } = props;
|
|
3994
|
-
return /* @__PURE__ */
|
|
4149
|
+
return /* @__PURE__ */ jsx17(RenderBoundary, { resetKeys: [panel, width, height], fallback: (error) => /* @__PURE__ */ jsx17(PanelError, { panel, width, height, error }), children: /* @__PURE__ */ jsx17(PanelCardContent, { ...props }) });
|
|
3995
4150
|
}
|
|
3996
4151
|
function PanelError({ panel, width, height, error }) {
|
|
3997
4152
|
const theme = useDashTheme();
|
|
3998
|
-
return /* @__PURE__ */
|
|
3999
|
-
!!panel.title && /* @__PURE__ */
|
|
4000
|
-
/* @__PURE__ */
|
|
4001
|
-
/* @__PURE__ */
|
|
4153
|
+
return /* @__PURE__ */ jsxs15(View13, { style: [styles15.card, { width, height, backgroundColor: theme.surface, borderColor: theme.danger }], accessibilityRole: "alert", children: [
|
|
4154
|
+
!!panel.title && /* @__PURE__ */ jsx17(Text14, { style: [styles15.title, styles15.errorTitle, { color: theme.text }], numberOfLines: 1, children: panel.title }),
|
|
4155
|
+
/* @__PURE__ */ jsx17(Text14, { style: [styles15.errorText, { color: theme.danger }], children: "This panel couldn\u2019t be shown." }),
|
|
4156
|
+
/* @__PURE__ */ jsx17(Text14, { style: [styles15.errorText, { color: theme.textMuted }], numberOfLines: 3, children: error.message })
|
|
4002
4157
|
] });
|
|
4003
4158
|
}
|
|
4004
4159
|
function PanelCardContent({ panel, width, height, deferred }) {
|
|
@@ -4012,23 +4167,23 @@ function PanelCardContent({ panel, width, height, deferred }) {
|
|
|
4012
4167
|
const hasLinks = !!panel.links?.length;
|
|
4013
4168
|
const hasTitle = !!panel.title || hasLinks || !!problem;
|
|
4014
4169
|
const title = panel.title ? interpolate(panel.title, { values: variables, info: variableInfo2, scoped: panel.scopedVars, timezone: dashboard.timezone }) : "";
|
|
4015
|
-
return /* @__PURE__ */
|
|
4016
|
-
hasTitle && /* @__PURE__ */
|
|
4017
|
-
/* @__PURE__ */
|
|
4018
|
-
!!problem && /* @__PURE__ */
|
|
4019
|
-
hasLinks && /* @__PURE__ */
|
|
4020
|
-
|
|
4170
|
+
return /* @__PURE__ */ jsxs15(View13, { style: [styles15.card, { width, height, backgroundColor: theme.surface, borderColor: theme.border }], children: [
|
|
4171
|
+
hasTitle && /* @__PURE__ */ jsxs15(View13, { style: styles15.titleRow, children: [
|
|
4172
|
+
/* @__PURE__ */ jsx17(Text14, { style: [styles15.title, { color: theme.text }], numberOfLines: 1, children: title }),
|
|
4173
|
+
!!problem && /* @__PURE__ */ jsx17(Text14, { style: [styles15.problem, { color: theme.danger }], numberOfLines: 1, accessibilityRole: "alert", children: problem }),
|
|
4174
|
+
hasLinks && /* @__PURE__ */ jsx17(
|
|
4175
|
+
Pressable13,
|
|
4021
4176
|
{
|
|
4022
4177
|
onPress: () => openLinks(resolve(panel.links), title || void 0),
|
|
4023
4178
|
accessibilityRole: "button",
|
|
4024
4179
|
accessibilityLabel: panel.links.length === 1 ? panel.links[0].title || "Open link" : "Panel links",
|
|
4025
4180
|
hitSlop: 10,
|
|
4026
|
-
style: ({ pressed }) => [
|
|
4027
|
-
children: /* @__PURE__ */
|
|
4181
|
+
style: ({ pressed }) => [styles15.titleLink, pressed && { opacity: 0.6 }],
|
|
4182
|
+
children: /* @__PURE__ */ jsx17(LinkIcon, { color: theme.textMuted })
|
|
4028
4183
|
}
|
|
4029
4184
|
)
|
|
4030
4185
|
] }),
|
|
4031
|
-
/* @__PURE__ */
|
|
4186
|
+
/* @__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 }) })
|
|
4032
4187
|
] });
|
|
4033
4188
|
}
|
|
4034
4189
|
function DataPanelBody({ panel, width, height }) {
|
|
@@ -4037,14 +4192,14 @@ function DataPanelBody({ panel, width, height }) {
|
|
|
4037
4192
|
const data = usePanelData(panel, width, needsData);
|
|
4038
4193
|
const Component2 = panelComponent(panel.type);
|
|
4039
4194
|
if (needsData && data.error) {
|
|
4040
|
-
return /* @__PURE__ */
|
|
4195
|
+
return /* @__PURE__ */ jsx17(View13, { style: styles15.center, children: /* @__PURE__ */ jsx17(Text14, { style: [styles15.error, { color: theme.danger }], numberOfLines: 4, children: data.error }) });
|
|
4041
4196
|
}
|
|
4042
4197
|
if (needsData && data.loading && !data.frames.length) {
|
|
4043
|
-
return /* @__PURE__ */
|
|
4198
|
+
return /* @__PURE__ */ jsx17(View13, { style: styles15.center, children: /* @__PURE__ */ jsx17(ActivityIndicator, { color: theme.textMuted }) });
|
|
4044
4199
|
}
|
|
4045
|
-
return /* @__PURE__ */
|
|
4200
|
+
return /* @__PURE__ */ jsx17(Component2, { panel, frames: data.frames, width, height });
|
|
4046
4201
|
}
|
|
4047
|
-
var
|
|
4202
|
+
var styles15 = StyleSheet15.create({
|
|
4048
4203
|
fill: { flex: 1 },
|
|
4049
4204
|
content: { padding: SIDE, paddingBottom: 32, gap: GAP2 },
|
|
4050
4205
|
section: { gap: GAP2 },
|
|
@@ -4053,7 +4208,7 @@ var styles14 = StyleSheet14.create({
|
|
|
4053
4208
|
rowTitle: { fontSize: 15, fontWeight: "600" },
|
|
4054
4209
|
row: { flexDirection: "row", gap: GAP2 },
|
|
4055
4210
|
gridCell: { position: "absolute" },
|
|
4056
|
-
card: { borderRadius: 10, borderWidth:
|
|
4211
|
+
card: { borderRadius: 10, borderWidth: StyleSheet15.hairlineWidth, paddingHorizontal: 12, paddingVertical: 8, overflow: "hidden" },
|
|
4057
4212
|
titleRow: { flexDirection: "row", alignItems: "flex-start", gap: 8, height: TITLE_H - 8, marginBottom: 8 },
|
|
4058
4213
|
title: { flex: 1, fontSize: 13, fontWeight: "600" },
|
|
4059
4214
|
titleLink: { paddingTop: 1 },
|
|
@@ -4066,11 +4221,76 @@ var styles14 = StyleSheet14.create({
|
|
|
4066
4221
|
});
|
|
4067
4222
|
|
|
4068
4223
|
// src/ui/inputs/InputForm.tsx
|
|
4069
|
-
import { useCallback as useCallback4, useEffect as
|
|
4070
|
-
import { Pressable as
|
|
4071
|
-
|
|
4224
|
+
import { useCallback as useCallback4, useEffect as useEffect5, useMemo as useMemo10, useState as useState13 } from "react";
|
|
4225
|
+
import { Platform as Platform2, Pressable as Pressable14, StyleSheet as StyleSheet16, Text as Text15, View as View14 } from "react-native";
|
|
4226
|
+
|
|
4227
|
+
// src/ui/speech.ts
|
|
4228
|
+
var WEB_ERRORS = {
|
|
4229
|
+
"not-allowed": "Microphone access is blocked for this site",
|
|
4230
|
+
"service-not-allowed": "Speech recognition isn\u2019t allowed in this browser",
|
|
4231
|
+
"audio-capture": "No microphone found",
|
|
4232
|
+
network: "Speech recognition needs an internet connection",
|
|
4233
|
+
"no-speech": "Didn\u2019t hear anything",
|
|
4234
|
+
"language-not-supported": "Speech recognition doesn\u2019t support this language"
|
|
4235
|
+
};
|
|
4236
|
+
function webSpeechRecognizer() {
|
|
4237
|
+
const g = globalThis;
|
|
4238
|
+
const Recognition = g.SpeechRecognition ?? g.webkitSpeechRecognition;
|
|
4239
|
+
if (!Recognition) return null;
|
|
4240
|
+
return {
|
|
4241
|
+
start(o) {
|
|
4242
|
+
const r = new Recognition();
|
|
4243
|
+
if (o.lang) r.lang = o.lang;
|
|
4244
|
+
r.interimResults = true;
|
|
4245
|
+
r.continuous = false;
|
|
4246
|
+
r.maxAlternatives = 1;
|
|
4247
|
+
let delivered = false;
|
|
4248
|
+
let aborted = false;
|
|
4249
|
+
let lastText = "";
|
|
4250
|
+
r.onresult = (e) => {
|
|
4251
|
+
let text = "";
|
|
4252
|
+
let final = true;
|
|
4253
|
+
for (let i = 0; i < e.results.length; i++) {
|
|
4254
|
+
text += e.results[i][0].transcript;
|
|
4255
|
+
if (!e.results[i].isFinal) final = false;
|
|
4256
|
+
}
|
|
4257
|
+
lastText = text.trim();
|
|
4258
|
+
if (final) delivered = true;
|
|
4259
|
+
o.onText(lastText, final);
|
|
4260
|
+
};
|
|
4261
|
+
r.onerror = (e) => {
|
|
4262
|
+
if (e.error === "aborted") return;
|
|
4263
|
+
o.onError(WEB_ERRORS[e.error] ?? "Speech recognition stopped");
|
|
4264
|
+
};
|
|
4265
|
+
r.onend = () => {
|
|
4266
|
+
if (!delivered && !aborted && lastText) o.onText(lastText, true);
|
|
4267
|
+
o.onEnd();
|
|
4268
|
+
};
|
|
4269
|
+
try {
|
|
4270
|
+
r.start();
|
|
4271
|
+
} catch {
|
|
4272
|
+
queueMicrotask(() => {
|
|
4273
|
+
o.onError("Speech recognition couldn\u2019t start");
|
|
4274
|
+
o.onEnd();
|
|
4275
|
+
});
|
|
4276
|
+
}
|
|
4277
|
+
return {
|
|
4278
|
+
stop: () => r.stop(),
|
|
4279
|
+
abort: () => {
|
|
4280
|
+
aborted = true;
|
|
4281
|
+
r.abort();
|
|
4282
|
+
}
|
|
4283
|
+
};
|
|
4284
|
+
}
|
|
4285
|
+
};
|
|
4286
|
+
}
|
|
4287
|
+
|
|
4288
|
+
// src/ui/inputs/InputForm.tsx
|
|
4289
|
+
import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
4072
4290
|
var NO_CHOICES = {};
|
|
4073
4291
|
var NO_DEFAULTS = {};
|
|
4292
|
+
var webSpeech;
|
|
4293
|
+
var defaultSpeech = () => Platform2.OS === "web" ? webSpeech ??= webSpeechRecognizer() : null;
|
|
4074
4294
|
function savedValues(panels, entries) {
|
|
4075
4295
|
const values = {};
|
|
4076
4296
|
for (const p of panels) {
|
|
@@ -4100,19 +4320,20 @@ function baseItems(group, editing, last) {
|
|
|
4100
4320
|
return values.map((v, i) => ({ key: `b${i}`, values: v, edited: [] }));
|
|
4101
4321
|
}
|
|
4102
4322
|
var nextItemKey = 1;
|
|
4103
|
-
function InputForm({ dashboard, store, onSaved, choices = NO_CHOICES, header, timestamp, defaults: given = NO_DEFAULTS, beforeSave, editing }) {
|
|
4323
|
+
function InputForm({ dashboard, store, onSaved, choices = NO_CHOICES, header, timestamp, defaults: given = NO_DEFAULTS, beforeSave, editing, speech: givenSpeech, speechLang }) {
|
|
4324
|
+
const speech = givenSpeech === void 0 ? defaultSpeech() : givenSpeech;
|
|
4104
4325
|
const theme = useDashTheme();
|
|
4105
4326
|
const panels = useMemo10(() => plainInputPanels(dashboard), [dashboard]);
|
|
4106
4327
|
const groups = useMemo10(() => inputGroups(dashboard), [dashboard]);
|
|
4107
4328
|
const saved = useMemo10(() => editing ? savedValues(panels, editing) : NO_DEFAULTS, [panels, editing]);
|
|
4108
|
-
const [defaults, setDefaults] =
|
|
4109
|
-
const [edits, setEdits] =
|
|
4110
|
-
const [last, setLast] =
|
|
4111
|
-
const [groupEdits, setGroupEdits] =
|
|
4112
|
-
const [offsetMs, setOffsetMs] =
|
|
4113
|
-
const [status, setStatus] =
|
|
4114
|
-
const [checked, setChecked] =
|
|
4115
|
-
|
|
4329
|
+
const [defaults, setDefaults] = useState13({});
|
|
4330
|
+
const [edits, setEdits] = useState13({});
|
|
4331
|
+
const [last, setLast] = useState13({});
|
|
4332
|
+
const [groupEdits, setGroupEdits] = useState13({});
|
|
4333
|
+
const [offsetMs, setOffsetMs] = useState13(0);
|
|
4334
|
+
const [status, setStatus] = useState13(null);
|
|
4335
|
+
const [checked, setChecked] = useState13(false);
|
|
4336
|
+
useEffect5(() => {
|
|
4116
4337
|
let run = 0;
|
|
4117
4338
|
const load = async () => {
|
|
4118
4339
|
const mine = ++run;
|
|
@@ -4152,6 +4373,8 @@ function InputForm({ dashboard, store, onSaved, choices = NO_CHOICES, header, ti
|
|
|
4152
4373
|
isDirty: (m) => m in edits,
|
|
4153
4374
|
store,
|
|
4154
4375
|
choices,
|
|
4376
|
+
speech,
|
|
4377
|
+
speechLang,
|
|
4155
4378
|
problem: (m) => {
|
|
4156
4379
|
const p = panels.find((x) => x.options.metric === m);
|
|
4157
4380
|
return p && (checked || m in edits) ? inputProblem(p, value(m)) : void 0;
|
|
@@ -4161,7 +4384,7 @@ function InputForm({ dashboard, store, onSaved, choices = NO_CHOICES, header, ti
|
|
|
4161
4384
|
setGroupEdits((all) => ({ ...all, [groupKey(g)]: update(all[groupKey(g)] ?? base[groupKey(g)] ?? []) }));
|
|
4162
4385
|
})
|
|
4163
4386
|
};
|
|
4164
|
-
}, [edits, saved, defaults, given, store, choices, panels, checked, itemsOf, last, groupEdits, base]);
|
|
4387
|
+
}, [edits, saved, defaults, given, store, choices, speech, speechLang, panels, checked, itemsOf, last, groupEdits, base]);
|
|
4165
4388
|
const dirty = Object.keys(edits).length + groups.reduce((n, g) => n + groupChanges(base[groupKey(g)] ?? [], groupEdits[groupKey(g)]), 0);
|
|
4166
4389
|
const recordedGroups = useCallback4(
|
|
4167
4390
|
() => groups.filter((g) => editing || groupKey(g) in groupEdits || groupFields(g).some((f) => f.options.record === "always")),
|
|
@@ -4195,14 +4418,14 @@ function InputForm({ dashboard, store, onSaved, choices = NO_CHOICES, header, ti
|
|
|
4195
4418
|
setStatus(`Saved ${added.length} ${added.length === 1 ? "value" : "values"}`);
|
|
4196
4419
|
onSaved?.(added.length, added);
|
|
4197
4420
|
}, [panels, edits, state, offsetMs, store, onSaved, header, timestamp, beforeSave, editing, recordedGroups, itemsOf]);
|
|
4198
|
-
return /* @__PURE__ */
|
|
4421
|
+
return /* @__PURE__ */ jsx18(InputFormContext.Provider, { value: state, children: /* @__PURE__ */ jsx18(DashboardProvider, { dashboard, children: /* @__PURE__ */ jsx18(
|
|
4199
4422
|
DashboardView,
|
|
4200
4423
|
{
|
|
4201
|
-
header: header !== void 0 ? header : /* @__PURE__ */
|
|
4202
|
-
footer: /* @__PURE__ */
|
|
4203
|
-
/* @__PURE__ */
|
|
4204
|
-
dirty > 0 && /* @__PURE__ */
|
|
4205
|
-
|
|
4424
|
+
header: header !== void 0 ? header : /* @__PURE__ */ jsx18(TimestampPicker, { offsetMs, onChange: setOffsetMs }),
|
|
4425
|
+
footer: /* @__PURE__ */ jsxs16(View14, { style: [styles16.footer, { backgroundColor: theme.surface, borderTopColor: theme.border }], children: [
|
|
4426
|
+
/* @__PURE__ */ jsx18(Text15, { style: [styles16.status, { color: status?.startsWith("Can\u2019t") ? theme.danger : theme.textSecondary }], children: status ?? (dirty ? `${dirty} unsaved ${dirty === 1 ? "change" : "changes"}` : "Nothing to save") }),
|
|
4427
|
+
dirty > 0 && /* @__PURE__ */ jsx18(
|
|
4428
|
+
Pressable14,
|
|
4206
4429
|
{
|
|
4207
4430
|
onPress: () => {
|
|
4208
4431
|
setEdits({});
|
|
@@ -4210,19 +4433,19 @@ function InputForm({ dashboard, store, onSaved, choices = NO_CHOICES, header, ti
|
|
|
4210
4433
|
setChecked(false);
|
|
4211
4434
|
setStatus(null);
|
|
4212
4435
|
},
|
|
4213
|
-
style:
|
|
4436
|
+
style: styles16.secondary,
|
|
4214
4437
|
accessibilityRole: "button",
|
|
4215
|
-
children: /* @__PURE__ */
|
|
4438
|
+
children: /* @__PURE__ */ jsx18(Text15, { style: { color: theme.textSecondary, fontWeight: "500" }, children: "Discard" })
|
|
4216
4439
|
}
|
|
4217
4440
|
),
|
|
4218
|
-
/* @__PURE__ */
|
|
4219
|
-
|
|
4441
|
+
/* @__PURE__ */ jsx18(
|
|
4442
|
+
Pressable14,
|
|
4220
4443
|
{
|
|
4221
4444
|
onPress: save,
|
|
4222
4445
|
disabled: !dirty,
|
|
4223
4446
|
accessibilityRole: "button",
|
|
4224
|
-
style: ({ pressed }) => [
|
|
4225
|
-
children: /* @__PURE__ */
|
|
4447
|
+
style: ({ pressed }) => [styles16.save, { backgroundColor: theme.accent, opacity: !dirty ? 0.4 : pressed ? 0.8 : 1 }],
|
|
4448
|
+
children: /* @__PURE__ */ jsx18(Text15, { style: styles16.saveText, children: "Save" })
|
|
4226
4449
|
}
|
|
4227
4450
|
)
|
|
4228
4451
|
] })
|
|
@@ -4281,33 +4504,33 @@ async function replace(store, ids, entries) {
|
|
|
4281
4504
|
var HOUR = 36e5;
|
|
4282
4505
|
function TimestampPicker({ offsetMs, onChange }) {
|
|
4283
4506
|
const theme = useDashTheme();
|
|
4284
|
-
const [now, setNow] =
|
|
4285
|
-
|
|
4507
|
+
const [now, setNow] = useState13(() => Date.now());
|
|
4508
|
+
useEffect5(() => {
|
|
4286
4509
|
const id = setInterval(() => setNow(Date.now()), 3e4);
|
|
4287
4510
|
return () => clearInterval(id);
|
|
4288
4511
|
}, []);
|
|
4289
4512
|
const when = new Date(now + offsetMs);
|
|
4290
4513
|
const step = (ms) => () => onChange(Math.min(0, offsetMs + ms));
|
|
4291
|
-
return /* @__PURE__ */
|
|
4292
|
-
/* @__PURE__ */
|
|
4293
|
-
/* @__PURE__ */
|
|
4294
|
-
/* @__PURE__ */
|
|
4514
|
+
return /* @__PURE__ */ jsxs16(View14, { style: [styles16.when, { backgroundColor: theme.surface, borderColor: theme.border }], children: [
|
|
4515
|
+
/* @__PURE__ */ jsxs16(View14, { style: { flex: 1 }, children: [
|
|
4516
|
+
/* @__PURE__ */ jsx18(Text15, { style: [styles16.whenLabel, { color: theme.textMuted }], children: "Recording for" }),
|
|
4517
|
+
/* @__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" }) })
|
|
4295
4518
|
] }),
|
|
4296
4519
|
[
|
|
4297
4520
|
["\u22121d", -24 * HOUR],
|
|
4298
4521
|
["\u22121h", -HOUR],
|
|
4299
4522
|
["+1h", HOUR]
|
|
4300
|
-
].map(([label, ms]) => /* @__PURE__ */
|
|
4301
|
-
offsetMs !== 0 && /* @__PURE__ */
|
|
4523
|
+
].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)),
|
|
4524
|
+
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" }) })
|
|
4302
4525
|
] });
|
|
4303
4526
|
}
|
|
4304
|
-
var
|
|
4305
|
-
footer: { flexDirection: "row", alignItems: "center", gap: 12, paddingHorizontal: 16, paddingVertical: 10, borderTopWidth:
|
|
4527
|
+
var styles16 = StyleSheet16.create({
|
|
4528
|
+
footer: { flexDirection: "row", alignItems: "center", gap: 12, paddingHorizontal: 16, paddingVertical: 10, borderTopWidth: StyleSheet16.hairlineWidth },
|
|
4306
4529
|
status: { flex: 1, fontSize: 13 },
|
|
4307
4530
|
secondary: { paddingHorizontal: 8, paddingVertical: 10 },
|
|
4308
4531
|
save: { paddingHorizontal: 22, paddingVertical: 10, borderRadius: 8 },
|
|
4309
4532
|
saveText: { color: "#fff", fontWeight: "600", fontSize: 15 },
|
|
4310
|
-
when: { flexDirection: "row", alignItems: "center", gap: 6, padding: 12, borderRadius: 10, borderWidth:
|
|
4533
|
+
when: { flexDirection: "row", alignItems: "center", gap: 6, padding: 12, borderRadius: 10, borderWidth: StyleSheet16.hairlineWidth },
|
|
4311
4534
|
whenLabel: { fontSize: 11 },
|
|
4312
4535
|
whenValue: { fontSize: 15, fontWeight: "600" },
|
|
4313
4536
|
stepBtn: { paddingHorizontal: 10, paddingVertical: 6, borderRadius: 6, borderWidth: 1 }
|
|
@@ -4324,6 +4547,7 @@ export {
|
|
|
4324
4547
|
ConfigLoader,
|
|
4325
4548
|
DASHBOARD_DS,
|
|
4326
4549
|
DEFAULT_GAZETTEER,
|
|
4550
|
+
DICTATION_TYPES,
|
|
4327
4551
|
DOCUMENT_GUIDE,
|
|
4328
4552
|
DashThemeProvider,
|
|
4329
4553
|
DashboardProvider,
|
|
@@ -4389,6 +4613,7 @@ export {
|
|
|
4389
4613
|
dashboardSourceIds,
|
|
4390
4614
|
defaultFetchJson,
|
|
4391
4615
|
describeRange,
|
|
4616
|
+
dictationHints,
|
|
4392
4617
|
diffJson,
|
|
4393
4618
|
documentChanges,
|
|
4394
4619
|
documentIdFor,
|
|
@@ -4456,6 +4681,7 @@ export {
|
|
|
4456
4681
|
mappingProblem,
|
|
4457
4682
|
mappingRow,
|
|
4458
4683
|
mappingRows,
|
|
4684
|
+
matchChoices,
|
|
4459
4685
|
metricChanges,
|
|
4460
4686
|
movePanel,
|
|
4461
4687
|
newDocument,
|
|
@@ -4483,6 +4709,9 @@ export {
|
|
|
4483
4709
|
parseLocalDateTime,
|
|
4484
4710
|
parseRange,
|
|
4485
4711
|
parseSnippet,
|
|
4712
|
+
parseSpokenDuration,
|
|
4713
|
+
parseSpokenNumber,
|
|
4714
|
+
parseSpokenYesNo,
|
|
4486
4715
|
parseTemplate,
|
|
4487
4716
|
parseTime,
|
|
4488
4717
|
pasteSnippet,
|
|
@@ -4508,6 +4737,7 @@ export {
|
|
|
4508
4737
|
renameVariableInPanels,
|
|
4509
4738
|
repack,
|
|
4510
4739
|
repeatOptions,
|
|
4740
|
+
requiredManifestVersion,
|
|
4511
4741
|
resizePanel,
|
|
4512
4742
|
resolveColor,
|
|
4513
4743
|
resolveFieldConfig,
|
|
@@ -4531,9 +4761,11 @@ export {
|
|
|
4531
4761
|
settleLayout,
|
|
4532
4762
|
snapToGrid,
|
|
4533
4763
|
splitPath,
|
|
4764
|
+
spokenValue,
|
|
4534
4765
|
startOf,
|
|
4535
4766
|
stringifyCompact,
|
|
4536
4767
|
tabIdFor,
|
|
4768
|
+
takesDictation,
|
|
4537
4769
|
templateNeeds,
|
|
4538
4770
|
templatePrompt,
|
|
4539
4771
|
textSuggestions,
|
|
@@ -4566,5 +4798,6 @@ export {
|
|
|
4566
4798
|
variableWithQuery,
|
|
4567
4799
|
variableWithType,
|
|
4568
4800
|
visibleVariables,
|
|
4801
|
+
webSpeechRecognizer,
|
|
4569
4802
|
zoomRange
|
|
4570
4803
|
};
|