@swiftbrowser/react 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -3
- package/dist/components/split.d.ts +18 -4
- package/dist/components/split.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1272 -1251
- package/dist/index.js.map +1 -1
- package/dist/inspector.d.ts.map +1 -1
- package/dist/modifiers.d.ts +5 -1
- package/dist/modifiers.d.ts.map +1 -1
- package/dist/presentation.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { createContext, useContext, createElement, useRef, useLayoutEffect, useState,
|
|
1
|
+
import { createContext, useContext, createElement, useRef, useLayoutEffect, useState, Children, useEffect, isValidElement, Fragment, useId, cloneElement, useSyncExternalStore } from "react";
|
|
2
2
|
import { DefaultEventPriority, ConcurrentRoot } from "react-reconciler/constants";
|
|
3
3
|
import Reconciler from "react-reconciler";
|
|
4
4
|
import { horizontalSizeClassFor } from "@swiftbrowser/web/src/protocol";
|
|
5
5
|
import { Renderer } from "@swiftbrowser/web/src/renderer";
|
|
6
|
-
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
6
|
+
import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
|
|
7
7
|
import { applyTypeSizeVariables } from "@swiftbrowser/web/src/typography";
|
|
8
8
|
import { registerHostContent, notifyHostContentChange, unregisterHostContent } from "@swiftbrowser/web/src/hostContent";
|
|
9
9
|
import { createRoot } from "react-dom/client";
|
|
@@ -613,106 +613,6 @@ function DropDestination({ action, isTargeted, accepts, children }) {
|
|
|
613
613
|
children
|
|
614
614
|
);
|
|
615
615
|
}
|
|
616
|
-
function SheetPresenter({ isPresented, onDismiss, content, fullScreen }) {
|
|
617
|
-
const [presented, setPresented] = readBinding(isPresented);
|
|
618
|
-
if (!presented) return null;
|
|
619
|
-
const dismiss = () => {
|
|
620
|
-
setPresented(false);
|
|
621
|
-
onDismiss?.();
|
|
622
|
-
};
|
|
623
|
-
const detents = fullScreen ? ["full"] : ["large"];
|
|
624
|
-
return sb(
|
|
625
|
-
HOIST_KIND,
|
|
626
|
-
void 0,
|
|
627
|
-
void 0,
|
|
628
|
-
sb(
|
|
629
|
-
"sheet",
|
|
630
|
-
{ detents },
|
|
631
|
-
{ tap: dismiss },
|
|
632
|
-
/* @__PURE__ */ jsx(NavigationContext.Provider, { value: null, children: /* @__PURE__ */ jsx(DismissContext.Provider, { value: dismiss, children: content }) })
|
|
633
|
-
),
|
|
634
|
-
"root"
|
|
635
|
-
);
|
|
636
|
-
}
|
|
637
|
-
function presentationDetents(detents) {
|
|
638
|
-
const encoded = detents.map(
|
|
639
|
-
(detent) => typeof detent === "string" ? detent : "height" in detent ? `height:${detent.height}` : `fraction:${detent.fraction}`
|
|
640
|
-
);
|
|
641
|
-
return sb(PREF_KIND, { detents: encoded }, void 0, void 0, "sheet");
|
|
642
|
-
}
|
|
643
|
-
function AlertPresenter({ title, isPresented, message, actions, style }) {
|
|
644
|
-
const [presented, setPresented] = readBinding(isPresented);
|
|
645
|
-
if (!presented) return null;
|
|
646
|
-
const dismiss = () => setPresented(false);
|
|
647
|
-
return sb(
|
|
648
|
-
HOIST_KIND,
|
|
649
|
-
void 0,
|
|
650
|
-
void 0,
|
|
651
|
-
sb(
|
|
652
|
-
"alert",
|
|
653
|
-
{ title, message: message ?? null, style: style ?? "alert" },
|
|
654
|
-
{ tap: dismiss },
|
|
655
|
-
withEnvironment({ dismissAlert: dismiss }, actions)
|
|
656
|
-
),
|
|
657
|
-
"root"
|
|
658
|
-
);
|
|
659
|
-
}
|
|
660
|
-
function Lifecycle({ onAppear, onDisappear }) {
|
|
661
|
-
useEffect(() => {
|
|
662
|
-
onAppear?.();
|
|
663
|
-
return () => onDisappear?.();
|
|
664
|
-
}, []);
|
|
665
|
-
return null;
|
|
666
|
-
}
|
|
667
|
-
function Inspector({ isPresented, content, columnWidth, children }) {
|
|
668
|
-
const sizeClass = useHorizontalSizeClass();
|
|
669
|
-
const [presented, setPresented] = readBinding(isPresented);
|
|
670
|
-
if (sizeClass === "compact") {
|
|
671
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
672
|
-
children,
|
|
673
|
-
/* @__PURE__ */ jsx(SheetPresenter, { isPresented: [presented, setPresented], content })
|
|
674
|
-
] });
|
|
675
|
-
}
|
|
676
|
-
const panelContent = columnWidth !== void 0 ? sb("styled", { style: { inspectorColumnWidth: columnWidth } }, void 0, content) : content;
|
|
677
|
-
return sb("inspector", { presented }, void 0, [
|
|
678
|
-
/* @__PURE__ */ jsx(InspectorPart, { children }, "content"),
|
|
679
|
-
/* @__PURE__ */ jsx(InspectorPart, { children: sb("inspectorpanel", {}, void 0, panelContent) }, "panel")
|
|
680
|
-
]);
|
|
681
|
-
}
|
|
682
|
-
function InspectorPart({ children }) {
|
|
683
|
-
return children;
|
|
684
|
-
}
|
|
685
|
-
function Task({ id, action }) {
|
|
686
|
-
const latest = useRef(action);
|
|
687
|
-
latest.current = action;
|
|
688
|
-
useEffect(() => {
|
|
689
|
-
const controller = new AbortController();
|
|
690
|
-
Promise.resolve().then(() => latest.current(controller.signal)).catch((error) => {
|
|
691
|
-
if (!controller.signal.aborted) console.error(error);
|
|
692
|
-
});
|
|
693
|
-
return () => controller.abort();
|
|
694
|
-
}, [id]);
|
|
695
|
-
return null;
|
|
696
|
-
}
|
|
697
|
-
function OnChange({
|
|
698
|
-
value,
|
|
699
|
-
action,
|
|
700
|
-
initial
|
|
701
|
-
}) {
|
|
702
|
-
const previous = useRef(null);
|
|
703
|
-
const latest = useRef(action);
|
|
704
|
-
latest.current = action;
|
|
705
|
-
useEffect(() => {
|
|
706
|
-
const last = previous.current;
|
|
707
|
-
previous.current = { value };
|
|
708
|
-
if (last === null) {
|
|
709
|
-
if (initial) latest.current(value, value);
|
|
710
|
-
return;
|
|
711
|
-
}
|
|
712
|
-
if (!Object.is(last.value, value)) latest.current(last.value, value);
|
|
713
|
-
}, [value, initial]);
|
|
714
|
-
return null;
|
|
715
|
-
}
|
|
716
616
|
const HIERARCHY = { primary: 1, secondary: 2, tertiary: 3, quaternary: 4 };
|
|
717
617
|
function rgb(r2, g, b, a = 1) {
|
|
718
618
|
return { r: r2, g, b, a };
|
|
@@ -859,20 +759,6 @@ function insets(edges, amount) {
|
|
|
859
759
|
}
|
|
860
760
|
return result;
|
|
861
761
|
}
|
|
862
|
-
const ScrollRequestContext = createContext(null);
|
|
863
|
-
let nextSerial = 1;
|
|
864
|
-
function ScrollViewReader({ children }) {
|
|
865
|
-
const [request, setRequest] = useState(null);
|
|
866
|
-
const proxy = {
|
|
867
|
-
scrollTo: (id, anchor) => setRequest({ id, anchor: anchor === void 0 ? null : unitPoint(anchor), serial: nextSerial++ })
|
|
868
|
-
};
|
|
869
|
-
return /* @__PURE__ */ jsx(ScrollRequestContext.Provider, { value: request, children: children(proxy) });
|
|
870
|
-
}
|
|
871
|
-
function ScrollTarget({ id, children }) {
|
|
872
|
-
const request = useContext(ScrollRequestContext);
|
|
873
|
-
if (request && request.id === id) return styled({ scrollID: true, scrollTo: { anchor: request.anchor, serial: request.serial } }, children);
|
|
874
|
-
return styled({ scrollID: true }, children);
|
|
875
|
-
}
|
|
876
762
|
const ScrollSettingsContext = createContext({});
|
|
877
763
|
function edgesOf(edges) {
|
|
878
764
|
const list = Array.isArray(edges) ? edges : [edges];
|
|
@@ -931,413 +817,1051 @@ function marginedContent(children, margins, axis) {
|
|
|
931
817
|
const content = list.length === 1 ? list[0] : sb(axis === "horizontal" ? "hstack" : "vstack", { spacing: null, alignment: "center" }, void 0, children);
|
|
932
818
|
return sb("styled", { style: { padding: margins } }, void 0, content);
|
|
933
819
|
}
|
|
934
|
-
|
|
935
|
-
|
|
820
|
+
const ListSelectionContext = createContext(null);
|
|
821
|
+
function Row({ tag, onDelete, deletable, onMove, movable, index, containerIndex, children }) {
|
|
822
|
+
const selection = useContext(ListSelectionContext);
|
|
823
|
+
const selectable = selection !== null && tag !== void 0;
|
|
824
|
+
const canDelete = onDelete !== void 0 && deletable !== false;
|
|
825
|
+
const canMove = onMove !== void 0 && movable !== false;
|
|
826
|
+
if (!selectable && !canDelete && !canMove) return children;
|
|
827
|
+
const props = {};
|
|
828
|
+
if (selectable) {
|
|
829
|
+
props["selectable"] = true;
|
|
830
|
+
props["selected"] = selection.isSelected(tag);
|
|
831
|
+
}
|
|
832
|
+
if (canDelete) props["deletable"] = true;
|
|
833
|
+
if (canMove) props["movable"] = true;
|
|
834
|
+
return sb(
|
|
835
|
+
"listrow",
|
|
836
|
+
props,
|
|
837
|
+
{
|
|
838
|
+
tap: () => selectable && selection.select(tag),
|
|
839
|
+
delete: () => onDelete?.(),
|
|
840
|
+
move: (event) => {
|
|
841
|
+
const start = (containerIndex ?? index ?? 0) - (index ?? 0);
|
|
842
|
+
onMove?.(Math.max(0, event.to - start));
|
|
843
|
+
}
|
|
844
|
+
},
|
|
845
|
+
children
|
|
846
|
+
);
|
|
936
847
|
}
|
|
937
|
-
const
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
rectSelection: "crosshair",
|
|
946
|
-
columnResize: "col-resize",
|
|
947
|
-
rowResize: "row-resize"
|
|
948
|
-
};
|
|
949
|
-
function cursorFor(style) {
|
|
950
|
-
return CURSORS[style] ?? style;
|
|
848
|
+
const ScrollRequestContext = createContext(null);
|
|
849
|
+
let nextSerial = 1;
|
|
850
|
+
function ScrollViewReader({ children }) {
|
|
851
|
+
const [request, setRequest] = useState(null);
|
|
852
|
+
const proxy = {
|
|
853
|
+
scrollTo: (id, anchor) => setRequest({ id, anchor: anchor === void 0 ? null : unitPoint(anchor), serial: nextSerial++ })
|
|
854
|
+
};
|
|
855
|
+
return /* @__PURE__ */ jsx(ScrollRequestContext.Provider, { value: request, children: children(proxy) });
|
|
951
856
|
}
|
|
952
|
-
function
|
|
953
|
-
const
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
if (!serial.current) serial.current = { value: spec.value, count: 0 };
|
|
957
|
-
else if (!Object.is(serial.current.value, spec.value)) serial.current = { value: spec.value, count: serial.current.count + 1 };
|
|
958
|
-
}
|
|
959
|
-
if (!discrete && spec.isActive === false) return children;
|
|
960
|
-
const effect = { effect: spec.effect };
|
|
961
|
-
if (spec.direction) effect.direction = spec.direction;
|
|
962
|
-
if (spec.speed !== void 0) effect.speed = spec.speed;
|
|
963
|
-
if (spec.repeat !== void 0) effect.repeat = spec.repeat;
|
|
964
|
-
if (discrete) effect.trigger = serial.current.count;
|
|
965
|
-
return styled({ symbolEffect: effect }, children);
|
|
857
|
+
function ScrollTarget({ id, children }) {
|
|
858
|
+
const request = useContext(ScrollRequestContext);
|
|
859
|
+
if (request && request.id === id) return styled({ scrollID: true, scrollTo: { anchor: request.anchor, serial: request.serial } }, children);
|
|
860
|
+
return styled({ scrollID: true }, children);
|
|
966
861
|
}
|
|
967
|
-
|
|
968
|
-
|
|
862
|
+
const LAZY_BATCH = 12;
|
|
863
|
+
const LazyContext = createContext(null);
|
|
864
|
+
function LazyGroup({ rows, start = 0, wrap: wrap2 }) {
|
|
865
|
+
const axis = useContext(LazyContext);
|
|
866
|
+
const request = useContext(ScrollRequestContext);
|
|
867
|
+
const [count, setCount] = useState(LAZY_BATCH);
|
|
868
|
+
const target = request ? rows.findIndex((row) => rowMatches(row, request.id)) : -1;
|
|
869
|
+
const needed = target >= 0 ? Math.ceil((target + 1) / LAZY_BATCH) * LAZY_BATCH : 0;
|
|
870
|
+
useEffect(() => {
|
|
871
|
+
if (needed > count) setCount(needed);
|
|
872
|
+
}, [needed, count]);
|
|
873
|
+
const visible = Math.max(count, needed);
|
|
874
|
+
const shown = axis === null ? rows : rows.slice(0, visible);
|
|
875
|
+
const built = shown.map((row, index) => wrap2 ? wrap2(row, start + index) : row);
|
|
876
|
+
if (axis === null || shown.length >= rows.length) return built;
|
|
877
|
+
return [
|
|
878
|
+
...built,
|
|
879
|
+
createElement(
|
|
880
|
+
LazySpacer,
|
|
881
|
+
{ key: `lazy-${visible}`, axis, remaining: rows.length - shown.length, more: () => setCount(visible + LAZY_BATCH) }
|
|
882
|
+
)
|
|
883
|
+
];
|
|
969
884
|
}
|
|
970
|
-
|
|
971
|
-
return
|
|
972
|
-
escape: "Escape",
|
|
973
|
-
delete: "Backspace",
|
|
974
|
-
tab: "Tab",
|
|
975
|
-
space: " ",
|
|
976
|
-
upArrow: "ArrowUp",
|
|
977
|
-
downArrow: "ArrowDown",
|
|
978
|
-
leftArrow: "ArrowLeft",
|
|
979
|
-
rightArrow: "ArrowRight"
|
|
980
|
-
};
|
|
981
|
-
const isApple = () => typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent);
|
|
982
|
-
function matchesKey(event, key) {
|
|
983
|
-
const name = KEY_NAMES[key] ?? key;
|
|
984
|
-
return name.length === 1 ? event.key.toLowerCase() === name.toLowerCase() : event.key === name;
|
|
885
|
+
function LazySpacer({ axis, remaining, more }) {
|
|
886
|
+
return sb("lazyspacer", { axis, remaining }, { lazy: more });
|
|
985
887
|
}
|
|
986
|
-
function
|
|
987
|
-
if (
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
888
|
+
function rowMatches(row, id) {
|
|
889
|
+
if (row.key !== null && row.key === String(id)) return true;
|
|
890
|
+
let element = row;
|
|
891
|
+
for (let depth = 0; element && depth < 3; depth++) {
|
|
892
|
+
const props = element.props;
|
|
893
|
+
if (props.scrollID === id) return true;
|
|
894
|
+
element = isValidElement(props.children) ? props.children : null;
|
|
895
|
+
}
|
|
896
|
+
return false;
|
|
992
897
|
}
|
|
993
|
-
function
|
|
994
|
-
const
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
if (!shortcut || typeof document === "undefined") return;
|
|
999
|
-
const onKey = (event) => {
|
|
1000
|
-
if (event.defaultPrevented || !matchesShortcut(event, shortcut)) return;
|
|
1001
|
-
event.preventDefault();
|
|
1002
|
-
latest.current();
|
|
1003
|
-
};
|
|
1004
|
-
document.addEventListener("keydown", onKey);
|
|
1005
|
-
return () => document.removeEventListener("keydown", onKey);
|
|
1006
|
-
}, [key]);
|
|
898
|
+
function VStack(props) {
|
|
899
|
+
const { own, modifiers } = splitProps(props);
|
|
900
|
+
const stack = { spacing: own.spacing ?? null, alignment: own.alignment ?? "center" };
|
|
901
|
+
if (own.scrollTargetLayout) stack["scrollTarget"] = true;
|
|
902
|
+
return applyModifiers(sb("vstack", stack, void 0, own.children), modifiers);
|
|
1007
903
|
}
|
|
1008
|
-
function
|
|
1009
|
-
const
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
const onKey = (event) => {
|
|
1014
|
-
const target = event.target;
|
|
1015
|
-
if (event.defaultPrevented || target?.closest("input, textarea, [contenteditable]")) return;
|
|
1016
|
-
const { keys, action } = latest.current;
|
|
1017
|
-
if (keys && !keys.some((key) => matchesKey(event, key))) return;
|
|
1018
|
-
const modifiers = [];
|
|
1019
|
-
if (event.metaKey) modifiers.push("command");
|
|
1020
|
-
if (event.shiftKey) modifiers.push("shift");
|
|
1021
|
-
if (event.altKey) modifiers.push("option");
|
|
1022
|
-
if (event.ctrlKey) modifiers.push("control");
|
|
1023
|
-
const result = action({ key: event.key, characters: event.key.length === 1 ? event.key : "", modifiers, phase: event.repeat ? "repeat" : "down" });
|
|
1024
|
-
if (result === "handled") event.preventDefault();
|
|
1025
|
-
};
|
|
1026
|
-
document.addEventListener("keydown", onKey);
|
|
1027
|
-
return () => document.removeEventListener("keydown", onKey);
|
|
1028
|
-
}, []);
|
|
1029
|
-
return null;
|
|
904
|
+
function HStack(props) {
|
|
905
|
+
const { own, modifiers } = splitProps(props);
|
|
906
|
+
const stack = { spacing: own.spacing ?? null, alignment: own.alignment ?? "center" };
|
|
907
|
+
if (own.scrollTargetLayout) stack["scrollTarget"] = true;
|
|
908
|
+
return applyModifiers(sb("hstack", stack, void 0, own.children), modifiers);
|
|
1030
909
|
}
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
error: [24, 50, 24, 50, 24],
|
|
1035
|
-
selection: 8,
|
|
1036
|
-
increase: 10,
|
|
1037
|
-
decrease: 10,
|
|
1038
|
-
start: 14,
|
|
1039
|
-
stop: 14,
|
|
1040
|
-
alignment: 6,
|
|
1041
|
-
levelChange: 10,
|
|
1042
|
-
impact: 16
|
|
1043
|
-
};
|
|
1044
|
-
function SensoryFeedbackPlayer({ feedback, trigger }) {
|
|
1045
|
-
const first = useRef(true);
|
|
1046
|
-
useEffect(() => {
|
|
1047
|
-
if (first.current) {
|
|
1048
|
-
first.current = false;
|
|
1049
|
-
return;
|
|
1050
|
-
}
|
|
1051
|
-
if (typeof navigator !== "undefined" && typeof navigator.vibrate === "function") navigator.vibrate(PATTERNS[feedback]);
|
|
1052
|
-
}, [trigger, feedback]);
|
|
1053
|
-
return null;
|
|
910
|
+
function ZStack(props) {
|
|
911
|
+
const { own, modifiers } = splitProps(props);
|
|
912
|
+
return applyModifiers(sb("zstack", { alignment: own.alignment ?? "center" }, void 0, own.children), modifiers);
|
|
1054
913
|
}
|
|
1055
|
-
function
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
case "navigationBarLeading":
|
|
1059
|
-
case "cancellationAction":
|
|
1060
|
-
case "navigation":
|
|
1061
|
-
return "leading";
|
|
1062
|
-
case "principal":
|
|
1063
|
-
return "principal";
|
|
1064
|
-
case "bottomBar":
|
|
1065
|
-
return "bottom";
|
|
1066
|
-
default:
|
|
1067
|
-
return "trailing";
|
|
1068
|
-
}
|
|
914
|
+
function Spacer(props) {
|
|
915
|
+
const { own, modifiers } = splitProps(props);
|
|
916
|
+
return applyModifiers(sb("spacer", { minLength: own.minLength ?? null }), modifiers);
|
|
1069
917
|
}
|
|
1070
|
-
function
|
|
1071
|
-
const
|
|
1072
|
-
|
|
1073
|
-
const vertical = spec.axes !== "horizontal";
|
|
1074
|
-
let a = 1;
|
|
1075
|
-
let b = 0;
|
|
1076
|
-
if (spec.length) {
|
|
1077
|
-
const axis = horizontal ? "horizontal" : "vertical";
|
|
1078
|
-
b = spec.length(0, axis);
|
|
1079
|
-
a = (spec.length(1e3, axis) - b) / 1e3;
|
|
1080
|
-
} else if (spec.count !== void 0) {
|
|
1081
|
-
const n = Math.max(spec.count, 1);
|
|
1082
|
-
const span = Math.max(spec.span ?? 1, 1);
|
|
1083
|
-
const spacing = spec.spacing ?? 0;
|
|
1084
|
-
a = span / n;
|
|
1085
|
-
b = -spacing * (n - 1) * span / n + spacing * (span - 1);
|
|
1086
|
-
}
|
|
1087
|
-
return { ...horizontal ? { horizontal: true } : {}, ...vertical ? { vertical: true } : {}, a, b, alignment: spec.alignment ?? "center" };
|
|
918
|
+
function Divider(props) {
|
|
919
|
+
const { modifiers } = splitProps(props);
|
|
920
|
+
return applyModifiers(sb("divider", {}), modifiers);
|
|
1088
921
|
}
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
"
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
"
|
|
1095
|
-
|
|
1096
|
-
"
|
|
1097
|
-
"
|
|
1098
|
-
|
|
1099
|
-
"
|
|
1100
|
-
"
|
|
1101
|
-
"
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
"
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
"tint",
|
|
1113
|
-
"badge",
|
|
1114
|
-
"listRowInsets",
|
|
1115
|
-
"imageScale",
|
|
1116
|
-
"transition",
|
|
1117
|
-
"animation",
|
|
1118
|
-
"gridColumnAlignment",
|
|
1119
|
-
"gridCellColumns",
|
|
1120
|
-
"buttonStyle",
|
|
1121
|
-
"controlSize",
|
|
1122
|
-
"pickerStyle",
|
|
1123
|
-
"labelsHidden",
|
|
1124
|
-
"navigationTitle",
|
|
1125
|
-
"navigationBarTitleDisplayMode",
|
|
1126
|
-
"toolbar",
|
|
1127
|
-
"searchable",
|
|
1128
|
-
"navigationDestination",
|
|
1129
|
-
"sheet",
|
|
1130
|
-
"fullScreenCover",
|
|
1131
|
-
"alert",
|
|
1132
|
-
"confirmationDialog",
|
|
1133
|
-
"presentationDetents",
|
|
1134
|
-
"onTapGesture",
|
|
1135
|
-
"dragGesture",
|
|
1136
|
-
"onLongPressGesture",
|
|
1137
|
-
"contextMenu",
|
|
1138
|
-
"swipeActions",
|
|
1139
|
-
"onAppear",
|
|
1140
|
-
"onDisappear",
|
|
1141
|
-
"tag",
|
|
1142
|
-
"modifiers",
|
|
1143
|
-
"aspectRatio",
|
|
1144
|
-
"scaledToFit",
|
|
1145
|
-
"scaledToFill",
|
|
1146
|
-
"blur",
|
|
1147
|
-
"brightness",
|
|
1148
|
-
"contrast",
|
|
1149
|
-
"saturation",
|
|
1150
|
-
"grayscale",
|
|
1151
|
-
"hueRotation",
|
|
1152
|
-
"colorInvert",
|
|
1153
|
-
"colorMultiply",
|
|
1154
|
-
"blendMode",
|
|
1155
|
-
"mask",
|
|
1156
|
-
"position",
|
|
1157
|
-
"zIndex",
|
|
1158
|
-
"allowsHitTesting",
|
|
1159
|
-
"ignoresSafeArea",
|
|
1160
|
-
"rotation3DEffect",
|
|
1161
|
-
"gridCellAnchor",
|
|
1162
|
-
"alignmentGuide",
|
|
1163
|
-
"preferredColorScheme",
|
|
1164
|
-
"refreshable",
|
|
1165
|
-
"submitLabel",
|
|
1166
|
-
"labelStyle",
|
|
1167
|
-
"task",
|
|
1168
|
-
"onChangeOf",
|
|
1169
|
-
"scrollID",
|
|
1170
|
-
"draggable",
|
|
1171
|
-
"dropDestination",
|
|
1172
|
-
"inspector",
|
|
1173
|
-
"onHover",
|
|
1174
|
-
"help",
|
|
1175
|
-
"pointerStyle",
|
|
1176
|
-
"symbolEffect",
|
|
1177
|
-
"matchedGeometryEffect",
|
|
1178
|
-
"layoutValue",
|
|
1179
|
-
"safeAreaInset",
|
|
1180
|
-
"popover",
|
|
1181
|
-
"redacted",
|
|
1182
|
-
"keyboardShortcut",
|
|
1183
|
-
"onKeyPress",
|
|
1184
|
-
"sensoryFeedback",
|
|
1185
|
-
"textCase",
|
|
1186
|
-
"coordinateSpace",
|
|
1187
|
-
"contentTransition",
|
|
1188
|
-
"scrollEdgeEffectStyle",
|
|
1189
|
-
"scrollEdgeEffectHidden",
|
|
1190
|
-
"contentMargins",
|
|
1191
|
-
"containerRelativeFrame",
|
|
1192
|
-
"visualEffect",
|
|
1193
|
-
"scrollTransition"
|
|
1194
|
-
]);
|
|
1195
|
-
function splitProps(props) {
|
|
1196
|
-
const own = {};
|
|
1197
|
-
const modifiers = [];
|
|
1198
|
-
for (const [key, value] of Object.entries(props)) {
|
|
1199
|
-
if (MODIFIER_KEYS.has(key)) modifiers.push([key, value]);
|
|
1200
|
-
else own[key] = value;
|
|
922
|
+
function ScrollView(props) {
|
|
923
|
+
const { own, modifiers } = splitProps(props);
|
|
924
|
+
const refresh = useRefreshable(takeModifier(modifiers, "refreshable"));
|
|
925
|
+
const ownSettings = takeScrollSettings(modifiers);
|
|
926
|
+
const settings = useScrollSettings(ownSettings);
|
|
927
|
+
const axes = own.axes ?? "vertical";
|
|
928
|
+
const scroll = { axes, ...refresh.props };
|
|
929
|
+
if (own.scrollTargetBehavior) scroll["snap"] = own.scrollTargetBehavior;
|
|
930
|
+
if (own.scrollDismissesKeyboard) scroll["dismissesKeyboard"] = true;
|
|
931
|
+
const edgeEffect = edgeEffectProp(settings);
|
|
932
|
+
if (edgeEffect) scroll["edgeEffect"] = edgeEffect;
|
|
933
|
+
const content = marginedContent(own.children, settings.margins, axes === "horizontal" ? "horizontal" : "vertical");
|
|
934
|
+
return applyModifiers(sb("scrollview", scroll, refresh.handlers, providingScrollSettings(ownSettings, content)), modifiers);
|
|
935
|
+
}
|
|
936
|
+
function takeScrollSettings(modifiers) {
|
|
937
|
+
let settings = {};
|
|
938
|
+
const own = [];
|
|
939
|
+
for (const key of ["scrollEdgeEffectStyle", "scrollEdgeEffectHidden", "contentMargins"]) {
|
|
940
|
+
const value = takeModifier(modifiers, key);
|
|
941
|
+
if (value === void 0) continue;
|
|
942
|
+
if (key === "scrollEdgeEffectStyle") own.push(edgeStyleSettings(value));
|
|
943
|
+
else if (key === "scrollEdgeEffectHidden") own.push(edgeHiddenSettings(value));
|
|
944
|
+
else own.push(marginSettings(value));
|
|
1201
945
|
}
|
|
1202
|
-
|
|
946
|
+
for (const each of own) settings = mergeScrollSettings(settings, each);
|
|
947
|
+
return settings;
|
|
1203
948
|
}
|
|
1204
|
-
function
|
|
1205
|
-
|
|
1206
|
-
if (at < 0) return void 0;
|
|
1207
|
-
const [, value] = modifiers[at];
|
|
1208
|
-
modifiers.splice(at, 1);
|
|
1209
|
-
return value;
|
|
949
|
+
function providingScrollSettings(settings, children) {
|
|
950
|
+
return Object.keys(settings).length > 0 ? withScrollSettings(settings, children) : children;
|
|
1210
951
|
}
|
|
1211
|
-
function
|
|
1212
|
-
|
|
952
|
+
function useRefreshable(own) {
|
|
953
|
+
const environment = useViewEnvironment();
|
|
954
|
+
const refresh = own ?? environment.refresh;
|
|
955
|
+
const [refreshing, setRefreshing] = useState(false);
|
|
956
|
+
if (!refresh) return { props: {} };
|
|
957
|
+
return {
|
|
958
|
+
props: { refreshable: true, refreshing },
|
|
959
|
+
handlers: {
|
|
960
|
+
refresh: () => {
|
|
961
|
+
if (refreshing) return;
|
|
962
|
+
setRefreshing(true);
|
|
963
|
+
Promise.resolve().then(refresh).catch((error) => console.error(error)).finally(() => setRefreshing(false));
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
};
|
|
1213
967
|
}
|
|
1214
|
-
function
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
]);
|
|
1219
|
-
}
|
|
1220
|
-
function shapeSpecOf(element) {
|
|
1221
|
-
const spec = element.type.shape;
|
|
1222
|
-
if (!spec) return null;
|
|
1223
|
-
const radius = element.props.cornerRadius;
|
|
1224
|
-
return { kind: spec.kind, cornerRadius: spec.cornerRadius ?? radius ?? 0 };
|
|
1225
|
-
}
|
|
1226
|
-
function AnimatedStyle({ animation, value, children }) {
|
|
1227
|
-
const last = useRef({ value, token: 0 });
|
|
1228
|
-
if (!Object.is(last.current.value, value)) last.current = { value, token: last.current.token + 1 };
|
|
1229
|
-
return styled({ animation, animationToken: last.current.token }, children);
|
|
968
|
+
function Group(props) {
|
|
969
|
+
const { own, modifiers } = splitProps(props);
|
|
970
|
+
if (modifiers.length === 0) return own.children;
|
|
971
|
+
return Children.map(own.children, (child) => applyModifiers(child, modifiers));
|
|
1230
972
|
}
|
|
1231
|
-
function
|
|
1232
|
-
const
|
|
1233
|
-
|
|
973
|
+
function moveItems(items, offsets, to) {
|
|
974
|
+
const moving = new Set(offsets);
|
|
975
|
+
const picked = items.filter((_, index) => moving.has(index));
|
|
976
|
+
const rest = items.filter((_, index) => !moving.has(index));
|
|
977
|
+
const before = offsets.filter((offset) => offset < to).length;
|
|
978
|
+
const at = to - before;
|
|
979
|
+
return [...rest.slice(0, at), ...picked, ...rest.slice(at)];
|
|
1234
980
|
}
|
|
1235
|
-
function
|
|
1236
|
-
const
|
|
1237
|
-
const
|
|
1238
|
-
|
|
1239
|
-
|
|
981
|
+
function ForEach(props) {
|
|
982
|
+
const { own, modifiers } = splitProps(props);
|
|
983
|
+
const rows = own.data.map((element, index) => {
|
|
984
|
+
const key = own.id ? own.id(element, index) : keyOf(element, index);
|
|
985
|
+
const content = applyModifiers(own.children(element, index), modifiers);
|
|
986
|
+
if (!own.onDelete && !own.onMove) return createElement(Fragment, { key }, content);
|
|
987
|
+
const { onDelete, onMove } = own;
|
|
988
|
+
const row = { tag: key, index };
|
|
989
|
+
if (onDelete) {
|
|
990
|
+
row.onDelete = () => onDelete([index]);
|
|
991
|
+
row.deletable = !own.deleteDisabled?.(element, index);
|
|
992
|
+
}
|
|
993
|
+
if (onMove) {
|
|
994
|
+
row.onMove = (to) => onMove([index], to);
|
|
995
|
+
row.movable = !own.moveDisabled?.(element, index);
|
|
996
|
+
}
|
|
997
|
+
return createElement(Row, { key, ...row }, content);
|
|
998
|
+
});
|
|
999
|
+
return rows.length > LAZY_BATCH ? createElement(LazyGroup, { rows }) : rows;
|
|
1240
1000
|
}
|
|
1241
|
-
function
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
if (
|
|
1246
|
-
node = apply(key, value, node, sides);
|
|
1001
|
+
function keyOf(element, index) {
|
|
1002
|
+
if (typeof element === "string" || typeof element === "number") return element;
|
|
1003
|
+
if (typeof element === "object" && element !== null && "id" in element) {
|
|
1004
|
+
const id = element.id;
|
|
1005
|
+
if (typeof id === "string" || typeof id === "number") return id;
|
|
1247
1006
|
}
|
|
1248
|
-
return
|
|
1007
|
+
return index;
|
|
1249
1008
|
}
|
|
1250
|
-
function
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
if (typeof inShape === "object" && inShape !== null && "in" in inShape && isValidElement(inShape.in)) {
|
|
1266
|
-
return decorated("background", "center", node, cloneElement(inShape.in, { fill: inShape.fill }));
|
|
1009
|
+
function flattenChildren(children, options = {}) {
|
|
1010
|
+
const result = [];
|
|
1011
|
+
const visit = (node) => {
|
|
1012
|
+
if (node === null || node === void 0 || typeof node === "boolean") return;
|
|
1013
|
+
if (Array.isArray(node)) {
|
|
1014
|
+
node.forEach(visit);
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
if (!isValidElement(node)) return;
|
|
1018
|
+
const element = node;
|
|
1019
|
+
if (element.type === Fragment) {
|
|
1020
|
+
const inner = element.props["children"];
|
|
1021
|
+
if (element.key !== null && isValidElement(inner) && inner.key === null && inner.type !== Fragment) {
|
|
1022
|
+
visit({ ...inner, key: element.key });
|
|
1023
|
+
return;
|
|
1267
1024
|
}
|
|
1268
|
-
|
|
1025
|
+
visit(inner);
|
|
1026
|
+
return;
|
|
1269
1027
|
}
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
return decorated("overlay", spec.alignment ?? "center", node, spec.content);
|
|
1028
|
+
if (element.type === ForEach) {
|
|
1029
|
+
visit(ForEach(element.props));
|
|
1030
|
+
return;
|
|
1274
1031
|
}
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
return styled({ cornerRadius: value }, node);
|
|
1279
|
-
case "clipShape": {
|
|
1280
|
-
const spec = isValidElement(value) ? shapeSpecOf(value) : null;
|
|
1281
|
-
return styled({ cornerRadius: spec?.cornerRadius ?? 0 }, node);
|
|
1032
|
+
if (element.type === LazyGroup && !options.keepLazy) {
|
|
1033
|
+
visit(element.props.rows);
|
|
1034
|
+
return;
|
|
1282
1035
|
}
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1036
|
+
result.push(element);
|
|
1037
|
+
};
|
|
1038
|
+
visit(children);
|
|
1039
|
+
return result;
|
|
1040
|
+
}
|
|
1041
|
+
function GridItem(spec = {}) {
|
|
1042
|
+
const dimension = (n) => n === void 0 || n === Infinity ? "infinity" : n;
|
|
1043
|
+
let size;
|
|
1044
|
+
if (spec.size && "fixed" in spec.size) size = { kind: "fixed", value: spec.size.fixed };
|
|
1045
|
+
else if (spec.size && "adaptive" in spec.size) {
|
|
1046
|
+
size = { kind: "adaptive", minimum: spec.size.adaptive.minimum, maximum: dimension(spec.size.adaptive.maximum) };
|
|
1047
|
+
} else {
|
|
1048
|
+
const flexible = spec.size && "flexible" in spec.size ? spec.size.flexible : {};
|
|
1049
|
+
size = { kind: "flexible", minimum: flexible.minimum ?? 10, maximum: dimension(flexible.maximum) };
|
|
1050
|
+
}
|
|
1051
|
+
return { size, spacing: spec.spacing ?? null, alignment: spec.alignment ?? null };
|
|
1052
|
+
}
|
|
1053
|
+
GridItem.flexible = (options = {}) => GridItem({ size: { flexible: options }, spacing: options.spacing, alignment: options.alignment });
|
|
1054
|
+
GridItem.fixed = (value, options = {}) => GridItem({ size: { fixed: value }, spacing: options.spacing, alignment: options.alignment });
|
|
1055
|
+
GridItem.adaptive = (options) => GridItem({ size: { adaptive: options }, spacing: options.spacing, alignment: options.alignment });
|
|
1056
|
+
function LazyVGrid(props) {
|
|
1057
|
+
const { own, modifiers } = splitProps(props);
|
|
1058
|
+
return applyModifiers(
|
|
1059
|
+
sb("lazyvgrid", { columns: own.columns, spacing: own.spacing ?? null, alignment: own.alignment ?? "center" }, void 0, own.children),
|
|
1060
|
+
modifiers
|
|
1061
|
+
);
|
|
1062
|
+
}
|
|
1063
|
+
function LazyHGrid(props) {
|
|
1064
|
+
const { own, modifiers } = splitProps(props);
|
|
1065
|
+
return applyModifiers(
|
|
1066
|
+
sb("lazyhgrid", { rows: own.rows, spacing: own.spacing ?? null, alignment: own.alignment ?? "center" }, void 0, own.children),
|
|
1067
|
+
modifiers
|
|
1068
|
+
);
|
|
1069
|
+
}
|
|
1070
|
+
function Grid(props) {
|
|
1071
|
+
const { own, modifiers } = splitProps(props);
|
|
1072
|
+
return applyModifiers(
|
|
1073
|
+
sb(
|
|
1074
|
+
"grid",
|
|
1075
|
+
{ horizontalSpacing: own.horizontalSpacing ?? null, verticalSpacing: own.verticalSpacing ?? null, alignment: own.alignment ?? "center" },
|
|
1076
|
+
void 0,
|
|
1077
|
+
own.children
|
|
1078
|
+
),
|
|
1079
|
+
modifiers
|
|
1080
|
+
);
|
|
1081
|
+
}
|
|
1082
|
+
function GridRow(props) {
|
|
1083
|
+
const { own, modifiers } = splitProps(props);
|
|
1084
|
+
return applyModifiers(sb("gridrow", { alignment: own.alignment ?? null }, void 0, own.children), modifiers);
|
|
1085
|
+
}
|
|
1086
|
+
function runStyleOf(props, inherited, nested) {
|
|
1087
|
+
const style = { ...inherited };
|
|
1088
|
+
if (props.italic) style.italic = true;
|
|
1089
|
+
if (props.underline) style.underline = typeof props.underline === "object" && props.underline.color ? { color: color(props.underline.color) } : {};
|
|
1090
|
+
if (props.strikethrough) {
|
|
1091
|
+
style.strikethrough = typeof props.strikethrough === "object" && props.strikethrough.color ? { color: color(props.strikethrough.color) } : {};
|
|
1092
|
+
}
|
|
1093
|
+
const kerning = props.tracking ?? props.kerning;
|
|
1094
|
+
if (kerning !== void 0) style.kerning = kerning;
|
|
1095
|
+
if (props.baselineOffset !== void 0) style.baselineOffset = props.baselineOffset;
|
|
1096
|
+
if (props.link) style.link = props.link;
|
|
1097
|
+
if (nested) {
|
|
1098
|
+
let runFont = props.font !== void 0 ? font(props.font) : void 0;
|
|
1099
|
+
if (props.bold) runFont = { ...runFont ?? {}, weight: "bold" };
|
|
1100
|
+
if (props.fontWeight) runFont = { ...runFont ?? {}, weight: props.fontWeight };
|
|
1101
|
+
if (runFont) style.font = { ...style.font ?? {}, ...runFont };
|
|
1102
|
+
if (props.foregroundStyle !== void 0) style.foreground = shapeStyle(props.foregroundStyle);
|
|
1103
|
+
}
|
|
1104
|
+
return style;
|
|
1105
|
+
}
|
|
1106
|
+
function segmentsOf(children, style, into) {
|
|
1107
|
+
const visit = (node) => {
|
|
1108
|
+
if (node === null || node === void 0 || typeof node === "boolean") return;
|
|
1109
|
+
if (typeof node === "string" || typeof node === "number") {
|
|
1110
|
+
const last = into[into.length - 1];
|
|
1111
|
+
if (last && "text" in last && last.style === style) last.text += String(node);
|
|
1112
|
+
else into.push({ text: String(node), style });
|
|
1113
|
+
return;
|
|
1299
1114
|
}
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
return value ? styled({ fixedSize: value === true ? { horizontal: true, vertical: true } : value }, node) : node;
|
|
1304
|
-
case "offset": {
|
|
1305
|
-
const offset = value;
|
|
1306
|
-
return styled({ offset: { x: offset.x ?? 0, y: offset.y ?? 0 } }, node);
|
|
1115
|
+
if (Array.isArray(node)) {
|
|
1116
|
+
node.forEach(visit);
|
|
1117
|
+
return;
|
|
1307
1118
|
}
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
return styled(style, node);
|
|
1119
|
+
if (!isValidElement(node)) return;
|
|
1120
|
+
const element = node;
|
|
1121
|
+
if (element.type === Fragment) {
|
|
1122
|
+
visit(element.props["children"]);
|
|
1123
|
+
return;
|
|
1314
1124
|
}
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
if (spec.anchor !== void 0) style.scaleAnchor = unitPoint(spec.anchor);
|
|
1320
|
-
return styled(style, node);
|
|
1125
|
+
if (element.type === Text) {
|
|
1126
|
+
const props = element.props;
|
|
1127
|
+
segmentsOf(props.children, runStyleOf(props, style, true), into);
|
|
1128
|
+
return;
|
|
1321
1129
|
}
|
|
1322
|
-
|
|
1323
|
-
const
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
node
|
|
1327
|
-
);
|
|
1130
|
+
if (element.type === Image$1) {
|
|
1131
|
+
const props = element.props;
|
|
1132
|
+
into.push({ image: imageProps(props), style });
|
|
1133
|
+
return;
|
|
1328
1134
|
}
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1135
|
+
};
|
|
1136
|
+
visit(children);
|
|
1137
|
+
}
|
|
1138
|
+
function isPlainStyle(style) {
|
|
1139
|
+
return Object.keys(style).length === 0;
|
|
1140
|
+
}
|
|
1141
|
+
function Text(props) {
|
|
1142
|
+
const { own, modifiers } = splitProps(props);
|
|
1143
|
+
const environment = useViewEnvironment();
|
|
1144
|
+
const style = runStyleOf(props, {}, false);
|
|
1145
|
+
const segments = [];
|
|
1146
|
+
segmentsOf(own.children, style, segments);
|
|
1147
|
+
const textCase = takeModifier(modifiers, "textCase") ?? environment.textCase;
|
|
1148
|
+
if (textCase) {
|
|
1149
|
+
for (const segment of segments) {
|
|
1150
|
+
if ("text" in segment) segment.text = textCase === "uppercase" ? segment.text.toUpperCase() : segment.text.toLowerCase();
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
const redacted = takeModifier(modifiers, "redacted") ?? environment.redacted;
|
|
1154
|
+
const content = segments.map((segment) => "text" in segment ? segment.text : "").join("");
|
|
1155
|
+
const plain = segments.length <= 1 && (segments.length === 0 || "text" in segments[0] && isPlainStyle(segments[0].style));
|
|
1156
|
+
if (plain) return applyModifiers(placeholder(sb("text", { text: content }), redacted), modifiers);
|
|
1157
|
+
const runs = segments.map((segment) => {
|
|
1158
|
+
const run = { ...segment.style };
|
|
1159
|
+
if ("text" in segment) run["text"] = segment.text;
|
|
1160
|
+
else run["image"] = segment.image;
|
|
1161
|
+
return run;
|
|
1162
|
+
});
|
|
1163
|
+
const hasLinks = segments.some((segment) => segment.style.link);
|
|
1164
|
+
const handlers = hasLinks ? { link: (event) => openURL(event.value) } : void 0;
|
|
1165
|
+
return applyModifiers(placeholder(sb("text", { text: content, runs }, handlers), redacted), modifiers);
|
|
1166
|
+
}
|
|
1167
|
+
function placeholder(node, redacted) {
|
|
1168
|
+
if (!redacted) return node;
|
|
1169
|
+
return styled({ background: { hierarchical: 3 }, backgroundCornerRadius: 4 }, styled({ foreground: { name: "clear" } }, node));
|
|
1170
|
+
}
|
|
1171
|
+
function openURL(url) {
|
|
1172
|
+
if (typeof window !== "undefined") window.open(url, "_blank", "noopener");
|
|
1173
|
+
}
|
|
1174
|
+
function imageProps(props) {
|
|
1175
|
+
if (props.systemName !== void 0) return { systemName: props.systemName };
|
|
1176
|
+
if (props.url !== void 0) return { url: props.url, resizable: props.resizable ?? false, width: props.width ?? 0, height: props.height ?? 0 };
|
|
1177
|
+
return { name: props.name ?? "", resizable: props.resizable ?? false };
|
|
1178
|
+
}
|
|
1179
|
+
function Image$1(props) {
|
|
1180
|
+
const { modifiers } = splitProps(props);
|
|
1181
|
+
const environment = useViewEnvironment();
|
|
1182
|
+
const redacted = takeModifier(modifiers, "redacted") ?? environment.redacted;
|
|
1183
|
+
return applyModifiers(placeholder(sb("image", imageProps(props)), redacted), modifiers);
|
|
1184
|
+
}
|
|
1185
|
+
function Label(props) {
|
|
1186
|
+
const { own, modifiers } = splitProps(props);
|
|
1187
|
+
const environment = useViewEnvironment();
|
|
1188
|
+
const style = takeModifier(modifiers, "labelStyle") ?? environment.labelStyle ?? "automatic";
|
|
1189
|
+
const icon = own.icon ?? (own.systemImage !== void 0 ? /* @__PURE__ */ jsx(Image$1, { systemName: own.systemImage }) : own.image !== void 0 ? /* @__PURE__ */ jsx(Image$1, { name: own.image }) : null);
|
|
1190
|
+
const title = typeof own.title === "string" || typeof own.title === "number" ? /* @__PURE__ */ jsx(Text, { children: own.title }) : own.title;
|
|
1191
|
+
if (style === "iconOnly") return applyModifiers(icon, modifiers);
|
|
1192
|
+
if (style === "titleOnly") return applyModifiers(title, modifiers);
|
|
1193
|
+
return applyModifiers(
|
|
1194
|
+
/* @__PURE__ */ jsxs(HStack, { spacing: 8, children: [
|
|
1195
|
+
styled({ labelIcon: true }, icon),
|
|
1196
|
+
title
|
|
1197
|
+
] }),
|
|
1198
|
+
modifiers
|
|
1199
|
+
);
|
|
1200
|
+
}
|
|
1201
|
+
function LabeledContent(props) {
|
|
1202
|
+
const { own, modifiers } = splitProps(props);
|
|
1203
|
+
const label = typeof own.label === "string" || typeof own.label === "number" ? /* @__PURE__ */ jsx(Text, { children: own.label }) : own.label;
|
|
1204
|
+
const content = own.children ?? own.value;
|
|
1205
|
+
const value = typeof content === "string" || typeof content === "number" ? /* @__PURE__ */ jsx(Text, { children: content }) : content;
|
|
1206
|
+
return applyModifiers(
|
|
1207
|
+
/* @__PURE__ */ jsxs(HStack, { children: [
|
|
1208
|
+
label,
|
|
1209
|
+
sb("spacer", { minLength: null }),
|
|
1210
|
+
styled({ foreground: { hierarchical: 2 } }, value)
|
|
1211
|
+
] }),
|
|
1212
|
+
modifiers
|
|
1213
|
+
);
|
|
1214
|
+
}
|
|
1215
|
+
function Link(props) {
|
|
1216
|
+
const { own, modifiers } = splitProps(props);
|
|
1217
|
+
const label = own.title !== void 0 ? /* @__PURE__ */ jsx(Text, { children: own.title }) : own.children;
|
|
1218
|
+
return applyModifiers(sb("button", { role: null, style: "automatic" }, { tap: () => openURL(own.destination) }, label), modifiers);
|
|
1219
|
+
}
|
|
1220
|
+
const isPushedView = (value) => typeof value === "object" && value !== null && "view" in value && Object.keys(value).length === 1;
|
|
1221
|
+
function NavigationStack(props) {
|
|
1222
|
+
const enclosing = useNavigation();
|
|
1223
|
+
if (enclosing) return /* @__PURE__ */ jsx(FlattenedStack, { ...props });
|
|
1224
|
+
return /* @__PURE__ */ jsx(OwnStack, { ...props });
|
|
1225
|
+
}
|
|
1226
|
+
function FlattenedStack(props) {
|
|
1227
|
+
const { own, modifiers } = splitProps(props);
|
|
1228
|
+
return applyModifiers(
|
|
1229
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1230
|
+
own.destination && /* @__PURE__ */ jsx(RegisterDestination, { destination: own.destination }),
|
|
1231
|
+
own.children
|
|
1232
|
+
] }),
|
|
1233
|
+
modifiers
|
|
1234
|
+
);
|
|
1235
|
+
}
|
|
1236
|
+
function OwnStack(props) {
|
|
1237
|
+
const { own, modifiers } = splitProps(props);
|
|
1238
|
+
const [internalPath, setInternalPath] = useState([]);
|
|
1239
|
+
const [path, setPath] = own.path !== void 0 ? readBinding(own.path, own.onPathChange) : [internalPath, setInternalPath];
|
|
1240
|
+
const destination = useRef(null);
|
|
1241
|
+
destination.current = own.destination ?? null;
|
|
1242
|
+
const context = {
|
|
1243
|
+
push: (value) => setPath([...path, value]),
|
|
1244
|
+
pop: () => setPath(path.slice(0, -1)),
|
|
1245
|
+
registerDestination: (builder) => {
|
|
1246
|
+
destination.current = builder;
|
|
1247
|
+
}
|
|
1248
|
+
};
|
|
1249
|
+
const screens = [
|
|
1250
|
+
/* @__PURE__ */ jsx(Fragment, { children: sb("navscreen", { title: "", displayMode: "automatic", depth: 0 }, { tap: context.pop }, own.children) }, "root")
|
|
1251
|
+
];
|
|
1252
|
+
path.forEach((value, index) => {
|
|
1253
|
+
const pop = () => setPath(path.slice(0, index));
|
|
1254
|
+
screens.push(
|
|
1255
|
+
/* @__PURE__ */ jsx(Fragment, { children: sb(
|
|
1256
|
+
"navscreen",
|
|
1257
|
+
{ title: "", displayMode: "automatic", depth: index + 1 },
|
|
1258
|
+
{ tap: pop },
|
|
1259
|
+
/* @__PURE__ */ jsx(DismissContext.Provider, { value: pop, children: /* @__PURE__ */ jsx(PathScreen, { value, destination }) })
|
|
1260
|
+
) }, index + 1)
|
|
1261
|
+
);
|
|
1262
|
+
});
|
|
1263
|
+
return applyModifiers(
|
|
1264
|
+
sb("navstack", {}, void 0, /* @__PURE__ */ jsx(NavigationContext.Provider, { value: context, children: screens })),
|
|
1265
|
+
modifiers
|
|
1266
|
+
);
|
|
1267
|
+
}
|
|
1268
|
+
function PathScreen({ value, destination }) {
|
|
1269
|
+
if (isPushedView(value)) return value.view;
|
|
1270
|
+
return destination.current ? destination.current(value) : null;
|
|
1271
|
+
}
|
|
1272
|
+
function NavigationLink(props) {
|
|
1273
|
+
const { own, modifiers } = splitProps(props);
|
|
1274
|
+
const navigation = useNavigation();
|
|
1275
|
+
const label = own.title !== void 0 ? /* @__PURE__ */ jsx(Text, { children: own.title }) : own.children;
|
|
1276
|
+
const tap = () => {
|
|
1277
|
+
if (!navigation) return;
|
|
1278
|
+
if (own.destination !== void 0) navigation.push({ view: own.destination });
|
|
1279
|
+
else navigation.push(own.value);
|
|
1280
|
+
};
|
|
1281
|
+
return applyModifiers(sb("navlink", {}, { tap }, label), modifiers);
|
|
1282
|
+
}
|
|
1283
|
+
const SplitSelectionContext = createContext(null);
|
|
1284
|
+
function NavigationSplitView(props) {
|
|
1285
|
+
const { own, modifiers } = splitProps(props);
|
|
1286
|
+
const sizeClass = useHorizontalSizeClass();
|
|
1287
|
+
const [selected, setSelected] = useState(false);
|
|
1288
|
+
const reporters = useRef(/* @__PURE__ */ new Map());
|
|
1289
|
+
const [report] = useState(() => {
|
|
1290
|
+
const settle = () => setSelected([...reporters.current.values()].some((entry) => entry.selected));
|
|
1291
|
+
return {
|
|
1292
|
+
report: (key, nowSelected, clear2) => {
|
|
1293
|
+
reporters.current.set(key, { selected: nowSelected, clear: clear2 });
|
|
1294
|
+
settle();
|
|
1295
|
+
},
|
|
1296
|
+
retract: (key) => {
|
|
1297
|
+
if (reporters.current.delete(key)) settle();
|
|
1298
|
+
}
|
|
1299
|
+
};
|
|
1300
|
+
});
|
|
1301
|
+
const clear = () => {
|
|
1302
|
+
for (const entry of reporters.current.values()) if (entry.selected) entry.clear();
|
|
1303
|
+
};
|
|
1304
|
+
const [internal, setInternal] = useState("automatic");
|
|
1305
|
+
const [visibility, setVisibility] = own.columnVisibility !== void 0 ? readBinding(own.columnVisibility, own.onColumnVisibilityChange) : [internal, setInternal];
|
|
1306
|
+
if (sizeClass === "compact") {
|
|
1307
|
+
return applyModifiers(
|
|
1308
|
+
/* @__PURE__ */ jsx(SplitSelectionContext.Provider, { value: report, children: /* @__PURE__ */ jsx(CompactSplit, { sidebar: own.sidebar, detail: own.detail, selected, clear }) }),
|
|
1309
|
+
modifiers
|
|
1310
|
+
);
|
|
1311
|
+
}
|
|
1312
|
+
const sidebarVisible = visibility !== "detailOnly";
|
|
1313
|
+
const toggle = () => withAnimation(() => setVisibility(sidebarVisible ? "detailOnly" : "all"));
|
|
1314
|
+
const detail = isValidElement(own.detail) && own.detail.type === NavigationStack ? own.detail : /* @__PURE__ */ jsx(NavigationStack, { children: own.detail });
|
|
1315
|
+
return applyModifiers(
|
|
1316
|
+
sb("navsplit", { sidebarVisible }, { tap: toggle }, [
|
|
1317
|
+
/* @__PURE__ */ jsx(SplitColumn, { report, children: /* @__PURE__ */ jsx(NavigationStack, { children: own.sidebar }) }, "sidebar"),
|
|
1318
|
+
/* @__PURE__ */ jsx(SplitColumn, { report: null, children: detail }, "detail")
|
|
1319
|
+
]),
|
|
1320
|
+
modifiers
|
|
1321
|
+
);
|
|
1322
|
+
}
|
|
1323
|
+
function SplitColumn({ report, children }) {
|
|
1324
|
+
return /* @__PURE__ */ jsx(NavigationContext.Provider, { value: null, children: /* @__PURE__ */ jsx(SplitSelectionContext.Provider, { value: report, children }) });
|
|
1325
|
+
}
|
|
1326
|
+
function CompactSplit({ sidebar, detail, selected, clear }) {
|
|
1327
|
+
const [extra, setExtra] = useState([]);
|
|
1328
|
+
const base = selected ? [{ view: /* @__PURE__ */ jsx(DetailScope, { children: detail }) }] : [];
|
|
1329
|
+
const path = [...base, ...extra];
|
|
1330
|
+
const setPath = (next) => {
|
|
1331
|
+
if (selected && next.length === 0) {
|
|
1332
|
+
setExtra([]);
|
|
1333
|
+
clear();
|
|
1334
|
+
return;
|
|
1335
|
+
}
|
|
1336
|
+
setExtra(next.slice(base.length));
|
|
1337
|
+
};
|
|
1338
|
+
return /* @__PURE__ */ jsx(NavigationContext.Provider, { value: null, children: /* @__PURE__ */ jsx(NavigationStack, { path: [path, setPath], children: sidebar }) });
|
|
1339
|
+
}
|
|
1340
|
+
function DetailScope({ children }) {
|
|
1341
|
+
return /* @__PURE__ */ jsx(SplitSelectionContext.Provider, { value: null, children });
|
|
1342
|
+
}
|
|
1343
|
+
function useReportSplitSelection(split, selected, clear, active2 = true) {
|
|
1344
|
+
const key = useRef({}).current;
|
|
1345
|
+
useLayoutEffect(() => {
|
|
1346
|
+
if (active2) split?.report(key, selected, clear);
|
|
1347
|
+
else split?.retract(key);
|
|
1348
|
+
});
|
|
1349
|
+
useLayoutEffect(() => () => split?.retract(key), [split, key]);
|
|
1350
|
+
}
|
|
1351
|
+
function OutsideSplit({ children }) {
|
|
1352
|
+
return /* @__PURE__ */ jsx(SplitSelectionContext.Provider, { value: null, children });
|
|
1353
|
+
}
|
|
1354
|
+
function SheetPresenter({ isPresented, onDismiss, content, fullScreen }) {
|
|
1355
|
+
const [presented, setPresented] = readBinding(isPresented);
|
|
1356
|
+
if (!presented) return null;
|
|
1357
|
+
const dismiss = () => {
|
|
1358
|
+
setPresented(false);
|
|
1359
|
+
onDismiss?.();
|
|
1360
|
+
};
|
|
1361
|
+
const detents = fullScreen ? ["full"] : ["large"];
|
|
1362
|
+
return sb(
|
|
1363
|
+
HOIST_KIND,
|
|
1364
|
+
void 0,
|
|
1365
|
+
void 0,
|
|
1366
|
+
sb(
|
|
1367
|
+
"sheet",
|
|
1368
|
+
{ detents },
|
|
1369
|
+
{ tap: dismiss },
|
|
1370
|
+
/* @__PURE__ */ jsx(NavigationContext.Provider, { value: null, children: /* @__PURE__ */ jsx(OutsideSplit, { children: /* @__PURE__ */ jsx(DismissContext.Provider, { value: dismiss, children: content }) }) })
|
|
1371
|
+
),
|
|
1372
|
+
"root"
|
|
1373
|
+
);
|
|
1374
|
+
}
|
|
1375
|
+
function presentationDetents(detents) {
|
|
1376
|
+
const encoded = detents.map(
|
|
1377
|
+
(detent) => typeof detent === "string" ? detent : "height" in detent ? `height:${detent.height}` : `fraction:${detent.fraction}`
|
|
1378
|
+
);
|
|
1379
|
+
return sb(PREF_KIND, { detents: encoded }, void 0, void 0, "sheet");
|
|
1380
|
+
}
|
|
1381
|
+
function AlertPresenter({ title, isPresented, message, actions, style }) {
|
|
1382
|
+
const [presented, setPresented] = readBinding(isPresented);
|
|
1383
|
+
if (!presented) return null;
|
|
1384
|
+
const dismiss = () => setPresented(false);
|
|
1385
|
+
return sb(
|
|
1386
|
+
HOIST_KIND,
|
|
1387
|
+
void 0,
|
|
1388
|
+
void 0,
|
|
1389
|
+
sb(
|
|
1390
|
+
"alert",
|
|
1391
|
+
{ title, message: message ?? null, style: style ?? "alert" },
|
|
1392
|
+
{ tap: dismiss },
|
|
1393
|
+
withEnvironment({ dismissAlert: dismiss }, actions)
|
|
1394
|
+
),
|
|
1395
|
+
"root"
|
|
1396
|
+
);
|
|
1397
|
+
}
|
|
1398
|
+
function Lifecycle({ onAppear, onDisappear }) {
|
|
1399
|
+
useEffect(() => {
|
|
1400
|
+
onAppear?.();
|
|
1401
|
+
return () => onDisappear?.();
|
|
1402
|
+
}, []);
|
|
1403
|
+
return null;
|
|
1404
|
+
}
|
|
1405
|
+
function Inspector({ isPresented, content, columnWidth, children }) {
|
|
1406
|
+
const sizeClass = useHorizontalSizeClass();
|
|
1407
|
+
const [presented, setPresented] = readBinding(isPresented);
|
|
1408
|
+
if (sizeClass === "compact") {
|
|
1409
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1410
|
+
children,
|
|
1411
|
+
/* @__PURE__ */ jsx(SheetPresenter, { isPresented: [presented, setPresented], content })
|
|
1412
|
+
] });
|
|
1413
|
+
}
|
|
1414
|
+
const outside = /* @__PURE__ */ jsx(OutsideSplit, { children: content });
|
|
1415
|
+
const panelContent = columnWidth !== void 0 ? sb("styled", { style: { inspectorColumnWidth: columnWidth } }, void 0, outside) : outside;
|
|
1416
|
+
return sb("inspector", { presented }, void 0, [
|
|
1417
|
+
/* @__PURE__ */ jsx(InspectorPart, { children }, "content"),
|
|
1418
|
+
/* @__PURE__ */ jsx(InspectorPart, { children: sb("inspectorpanel", {}, void 0, panelContent) }, "panel")
|
|
1419
|
+
]);
|
|
1420
|
+
}
|
|
1421
|
+
function InspectorPart({ children }) {
|
|
1422
|
+
return children;
|
|
1423
|
+
}
|
|
1424
|
+
function Task({ id, action }) {
|
|
1425
|
+
const latest = useRef(action);
|
|
1426
|
+
latest.current = action;
|
|
1427
|
+
useEffect(() => {
|
|
1428
|
+
const controller = new AbortController();
|
|
1429
|
+
Promise.resolve().then(() => latest.current(controller.signal)).catch((error) => {
|
|
1430
|
+
if (!controller.signal.aborted) console.error(error);
|
|
1431
|
+
});
|
|
1432
|
+
return () => controller.abort();
|
|
1433
|
+
}, [id]);
|
|
1434
|
+
return null;
|
|
1435
|
+
}
|
|
1436
|
+
function OnChange({
|
|
1437
|
+
value,
|
|
1438
|
+
action,
|
|
1439
|
+
initial
|
|
1440
|
+
}) {
|
|
1441
|
+
const previous = useRef(null);
|
|
1442
|
+
const latest = useRef(action);
|
|
1443
|
+
latest.current = action;
|
|
1444
|
+
useEffect(() => {
|
|
1445
|
+
const last = previous.current;
|
|
1446
|
+
previous.current = { value };
|
|
1447
|
+
if (last === null) {
|
|
1448
|
+
if (initial) latest.current(value, value);
|
|
1449
|
+
return;
|
|
1450
|
+
}
|
|
1451
|
+
if (!Object.is(last.value, value)) latest.current(last.value, value);
|
|
1452
|
+
}, [value, initial]);
|
|
1453
|
+
return null;
|
|
1454
|
+
}
|
|
1455
|
+
function Hover({ action, children }) {
|
|
1456
|
+
return sb("styled", { style: { hover: true } }, { hover: (event) => action(event.value) }, children);
|
|
1457
|
+
}
|
|
1458
|
+
const CURSORS = {
|
|
1459
|
+
link: "pointer",
|
|
1460
|
+
automatic: "auto",
|
|
1461
|
+
default: "default",
|
|
1462
|
+
text: "text",
|
|
1463
|
+
verticalText: "vertical-text",
|
|
1464
|
+
grabIdle: "grab",
|
|
1465
|
+
grabActive: "grabbing",
|
|
1466
|
+
rectSelection: "crosshair",
|
|
1467
|
+
columnResize: "col-resize",
|
|
1468
|
+
rowResize: "row-resize"
|
|
1469
|
+
};
|
|
1470
|
+
function cursorFor(style) {
|
|
1471
|
+
return CURSORS[style] ?? style;
|
|
1472
|
+
}
|
|
1473
|
+
function SymbolEffect({ spec, children }) {
|
|
1474
|
+
const serial = useRef(null);
|
|
1475
|
+
const discrete = "value" in spec;
|
|
1476
|
+
if (discrete) {
|
|
1477
|
+
if (!serial.current) serial.current = { value: spec.value, count: 0 };
|
|
1478
|
+
else if (!Object.is(serial.current.value, spec.value)) serial.current = { value: spec.value, count: serial.current.count + 1 };
|
|
1479
|
+
}
|
|
1480
|
+
if (!discrete && spec.isActive === false) return children;
|
|
1481
|
+
const effect = { effect: spec.effect };
|
|
1482
|
+
if (spec.direction) effect.direction = spec.direction;
|
|
1483
|
+
if (spec.speed !== void 0) effect.speed = spec.speed;
|
|
1484
|
+
if (spec.repeat !== void 0) effect.repeat = spec.repeat;
|
|
1485
|
+
if (discrete) effect.trigger = serial.current.count;
|
|
1486
|
+
return styled({ symbolEffect: effect }, children);
|
|
1487
|
+
}
|
|
1488
|
+
function useNamespace() {
|
|
1489
|
+
return useId();
|
|
1490
|
+
}
|
|
1491
|
+
const KEY_NAMES = {
|
|
1492
|
+
return: "Enter",
|
|
1493
|
+
escape: "Escape",
|
|
1494
|
+
delete: "Backspace",
|
|
1495
|
+
tab: "Tab",
|
|
1496
|
+
space: " ",
|
|
1497
|
+
upArrow: "ArrowUp",
|
|
1498
|
+
downArrow: "ArrowDown",
|
|
1499
|
+
leftArrow: "ArrowLeft",
|
|
1500
|
+
rightArrow: "ArrowRight"
|
|
1501
|
+
};
|
|
1502
|
+
const isApple = () => typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent);
|
|
1503
|
+
function matchesKey(event, key) {
|
|
1504
|
+
const name = KEY_NAMES[key] ?? key;
|
|
1505
|
+
return name.length === 1 ? event.key.toLowerCase() === name.toLowerCase() : event.key === name;
|
|
1506
|
+
}
|
|
1507
|
+
function matchesShortcut(event, shortcut) {
|
|
1508
|
+
if (!matchesKey(event, shortcut.key)) return false;
|
|
1509
|
+
const wanted = new Set(shortcut.modifiers ?? ["command"]);
|
|
1510
|
+
const command = isApple() ? event.metaKey : event.ctrlKey;
|
|
1511
|
+
const control = isApple() ? event.ctrlKey : false;
|
|
1512
|
+
return command === wanted.has("command") && event.shiftKey === wanted.has("shift") && event.altKey === wanted.has("option") && control === (isApple() && wanted.has("control"));
|
|
1513
|
+
}
|
|
1514
|
+
function useKeyboardShortcut(shortcut, action) {
|
|
1515
|
+
const latest = useRef(action);
|
|
1516
|
+
latest.current = action;
|
|
1517
|
+
const key = shortcut ? `${shortcut.key}:${(shortcut.modifiers ?? ["command"]).join("+")}` : "";
|
|
1518
|
+
useEffect(() => {
|
|
1519
|
+
if (!shortcut || typeof document === "undefined") return;
|
|
1520
|
+
const onKey = (event) => {
|
|
1521
|
+
if (event.defaultPrevented || !matchesShortcut(event, shortcut)) return;
|
|
1522
|
+
event.preventDefault();
|
|
1523
|
+
latest.current();
|
|
1524
|
+
};
|
|
1525
|
+
document.addEventListener("keydown", onKey);
|
|
1526
|
+
return () => document.removeEventListener("keydown", onKey);
|
|
1527
|
+
}, [key]);
|
|
1528
|
+
}
|
|
1529
|
+
function KeyPressListener({ spec }) {
|
|
1530
|
+
const latest = useRef(spec);
|
|
1531
|
+
latest.current = spec;
|
|
1532
|
+
useEffect(() => {
|
|
1533
|
+
if (typeof document === "undefined") return;
|
|
1534
|
+
const onKey = (event) => {
|
|
1535
|
+
const target = event.target;
|
|
1536
|
+
if (event.defaultPrevented || target?.closest("input, textarea, [contenteditable]")) return;
|
|
1537
|
+
const { keys, action } = latest.current;
|
|
1538
|
+
if (keys && !keys.some((key) => matchesKey(event, key))) return;
|
|
1539
|
+
const modifiers = [];
|
|
1540
|
+
if (event.metaKey) modifiers.push("command");
|
|
1541
|
+
if (event.shiftKey) modifiers.push("shift");
|
|
1542
|
+
if (event.altKey) modifiers.push("option");
|
|
1543
|
+
if (event.ctrlKey) modifiers.push("control");
|
|
1544
|
+
const result = action({ key: event.key, characters: event.key.length === 1 ? event.key : "", modifiers, phase: event.repeat ? "repeat" : "down" });
|
|
1545
|
+
if (result === "handled") event.preventDefault();
|
|
1546
|
+
};
|
|
1547
|
+
document.addEventListener("keydown", onKey);
|
|
1548
|
+
return () => document.removeEventListener("keydown", onKey);
|
|
1549
|
+
}, []);
|
|
1550
|
+
return null;
|
|
1551
|
+
}
|
|
1552
|
+
const PATTERNS = {
|
|
1553
|
+
success: [12, 60, 18],
|
|
1554
|
+
warning: [18, 80, 18],
|
|
1555
|
+
error: [24, 50, 24, 50, 24],
|
|
1556
|
+
selection: 8,
|
|
1557
|
+
increase: 10,
|
|
1558
|
+
decrease: 10,
|
|
1559
|
+
start: 14,
|
|
1560
|
+
stop: 14,
|
|
1561
|
+
alignment: 6,
|
|
1562
|
+
levelChange: 10,
|
|
1563
|
+
impact: 16
|
|
1564
|
+
};
|
|
1565
|
+
function SensoryFeedbackPlayer({ feedback, trigger }) {
|
|
1566
|
+
const first = useRef(true);
|
|
1567
|
+
useEffect(() => {
|
|
1568
|
+
if (first.current) {
|
|
1569
|
+
first.current = false;
|
|
1570
|
+
return;
|
|
1571
|
+
}
|
|
1572
|
+
if (typeof navigator !== "undefined" && typeof navigator.vibrate === "function") navigator.vibrate(PATTERNS[feedback]);
|
|
1573
|
+
}, [trigger, feedback]);
|
|
1574
|
+
return null;
|
|
1575
|
+
}
|
|
1576
|
+
function toolbarPlacement(name) {
|
|
1577
|
+
switch (name) {
|
|
1578
|
+
case "topBarLeading":
|
|
1579
|
+
case "navigationBarLeading":
|
|
1580
|
+
case "cancellationAction":
|
|
1581
|
+
case "navigation":
|
|
1582
|
+
return "leading";
|
|
1583
|
+
case "principal":
|
|
1584
|
+
return "principal";
|
|
1585
|
+
case "bottomBar":
|
|
1586
|
+
return "bottom";
|
|
1587
|
+
case "secondaryAction":
|
|
1588
|
+
return "secondary";
|
|
1589
|
+
default:
|
|
1590
|
+
return "trailing";
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
function containerRelativeFrame(value) {
|
|
1594
|
+
const spec = typeof value === "string" ? { axes: value } : value;
|
|
1595
|
+
const horizontal = spec.axes !== "vertical";
|
|
1596
|
+
const vertical = spec.axes !== "horizontal";
|
|
1597
|
+
let a = 1;
|
|
1598
|
+
let b = 0;
|
|
1599
|
+
if (spec.length) {
|
|
1600
|
+
const axis = horizontal ? "horizontal" : "vertical";
|
|
1601
|
+
b = spec.length(0, axis);
|
|
1602
|
+
a = (spec.length(1e3, axis) - b) / 1e3;
|
|
1603
|
+
} else if (spec.count !== void 0) {
|
|
1604
|
+
const n = Math.max(spec.count, 1);
|
|
1605
|
+
const span = Math.max(spec.span ?? 1, 1);
|
|
1606
|
+
const spacing = spec.spacing ?? 0;
|
|
1607
|
+
a = span / n;
|
|
1608
|
+
b = -spacing * (n - 1) * span / n + spacing * (span - 1);
|
|
1609
|
+
}
|
|
1610
|
+
return { ...horizontal ? { horizontal: true } : {}, ...vertical ? { vertical: true } : {}, a, b, alignment: spec.alignment ?? "center" };
|
|
1611
|
+
}
|
|
1612
|
+
const MODIFIER_KEYS = /* @__PURE__ */ new Set([
|
|
1613
|
+
"padding",
|
|
1614
|
+
"font",
|
|
1615
|
+
"fontWeight",
|
|
1616
|
+
"bold",
|
|
1617
|
+
"foregroundStyle",
|
|
1618
|
+
"background",
|
|
1619
|
+
"overlay",
|
|
1620
|
+
"frame",
|
|
1621
|
+
"cornerRadius",
|
|
1622
|
+
"clipShape",
|
|
1623
|
+
"clipped",
|
|
1624
|
+
"opacity",
|
|
1625
|
+
"disabled",
|
|
1626
|
+
"hidden",
|
|
1627
|
+
"layoutPriority",
|
|
1628
|
+
"lineLimit",
|
|
1629
|
+
"multilineTextAlignment",
|
|
1630
|
+
"fixedSize",
|
|
1631
|
+
"offset",
|
|
1632
|
+
"rotationEffect",
|
|
1633
|
+
"scaleEffect",
|
|
1634
|
+
"shadow",
|
|
1635
|
+
"tint",
|
|
1636
|
+
"badge",
|
|
1637
|
+
"listRowInsets",
|
|
1638
|
+
"imageScale",
|
|
1639
|
+
"transition",
|
|
1640
|
+
"animation",
|
|
1641
|
+
"gridColumnAlignment",
|
|
1642
|
+
"gridCellColumns",
|
|
1643
|
+
"buttonStyle",
|
|
1644
|
+
"controlSize",
|
|
1645
|
+
"pickerStyle",
|
|
1646
|
+
"labelsHidden",
|
|
1647
|
+
"navigationTitle",
|
|
1648
|
+
"navigationBarTitleDisplayMode",
|
|
1649
|
+
"toolbarRole",
|
|
1650
|
+
"toolbar",
|
|
1651
|
+
"searchable",
|
|
1652
|
+
"navigationDestination",
|
|
1653
|
+
"sheet",
|
|
1654
|
+
"fullScreenCover",
|
|
1655
|
+
"alert",
|
|
1656
|
+
"confirmationDialog",
|
|
1657
|
+
"presentationDetents",
|
|
1658
|
+
"onTapGesture",
|
|
1659
|
+
"dragGesture",
|
|
1660
|
+
"onLongPressGesture",
|
|
1661
|
+
"contextMenu",
|
|
1662
|
+
"swipeActions",
|
|
1663
|
+
"onAppear",
|
|
1664
|
+
"onDisappear",
|
|
1665
|
+
"tag",
|
|
1666
|
+
"modifiers",
|
|
1667
|
+
"aspectRatio",
|
|
1668
|
+
"scaledToFit",
|
|
1669
|
+
"scaledToFill",
|
|
1670
|
+
"blur",
|
|
1671
|
+
"brightness",
|
|
1672
|
+
"contrast",
|
|
1673
|
+
"saturation",
|
|
1674
|
+
"grayscale",
|
|
1675
|
+
"hueRotation",
|
|
1676
|
+
"colorInvert",
|
|
1677
|
+
"colorMultiply",
|
|
1678
|
+
"blendMode",
|
|
1679
|
+
"mask",
|
|
1680
|
+
"position",
|
|
1681
|
+
"zIndex",
|
|
1682
|
+
"allowsHitTesting",
|
|
1683
|
+
"ignoresSafeArea",
|
|
1684
|
+
"rotation3DEffect",
|
|
1685
|
+
"gridCellAnchor",
|
|
1686
|
+
"alignmentGuide",
|
|
1687
|
+
"preferredColorScheme",
|
|
1688
|
+
"refreshable",
|
|
1689
|
+
"submitLabel",
|
|
1690
|
+
"labelStyle",
|
|
1691
|
+
"task",
|
|
1692
|
+
"onChangeOf",
|
|
1693
|
+
"scrollID",
|
|
1694
|
+
"draggable",
|
|
1695
|
+
"dropDestination",
|
|
1696
|
+
"inspector",
|
|
1697
|
+
"onHover",
|
|
1698
|
+
"help",
|
|
1699
|
+
"pointerStyle",
|
|
1700
|
+
"symbolEffect",
|
|
1701
|
+
"matchedGeometryEffect",
|
|
1702
|
+
"layoutValue",
|
|
1703
|
+
"safeAreaInset",
|
|
1704
|
+
"popover",
|
|
1705
|
+
"redacted",
|
|
1706
|
+
"keyboardShortcut",
|
|
1707
|
+
"onKeyPress",
|
|
1708
|
+
"sensoryFeedback",
|
|
1709
|
+
"textCase",
|
|
1710
|
+
"coordinateSpace",
|
|
1711
|
+
"contentTransition",
|
|
1712
|
+
"scrollEdgeEffectStyle",
|
|
1713
|
+
"scrollEdgeEffectHidden",
|
|
1714
|
+
"contentMargins",
|
|
1715
|
+
"containerRelativeFrame",
|
|
1716
|
+
"visualEffect",
|
|
1717
|
+
"scrollTransition"
|
|
1718
|
+
]);
|
|
1719
|
+
function splitProps(props) {
|
|
1720
|
+
const own = {};
|
|
1721
|
+
const modifiers = [];
|
|
1722
|
+
for (const [key, value] of Object.entries(props)) {
|
|
1723
|
+
if (MODIFIER_KEYS.has(key)) modifiers.push([key, value]);
|
|
1724
|
+
else own[key] = value;
|
|
1725
|
+
}
|
|
1726
|
+
return { own, modifiers };
|
|
1727
|
+
}
|
|
1728
|
+
function takeModifier(modifiers, key) {
|
|
1729
|
+
const at = modifiers.findIndex(([name]) => name === key);
|
|
1730
|
+
if (at < 0) return void 0;
|
|
1731
|
+
const [, value] = modifiers[at];
|
|
1732
|
+
modifiers.splice(at, 1);
|
|
1733
|
+
return value;
|
|
1734
|
+
}
|
|
1735
|
+
function styled(style, child) {
|
|
1736
|
+
return sb("styled", { style }, void 0, child);
|
|
1737
|
+
}
|
|
1738
|
+
function decorated(role, alignment, content, decoration) {
|
|
1739
|
+
return sb("decorated", { role, alignment }, void 0, [
|
|
1740
|
+
createElement(Fragment, { key: "content" }, content),
|
|
1741
|
+
createElement(Fragment, { key: "decoration" }, decoration)
|
|
1742
|
+
]);
|
|
1743
|
+
}
|
|
1744
|
+
function shapeSpecOf(element) {
|
|
1745
|
+
const spec = element.type.shape;
|
|
1746
|
+
if (!spec) return null;
|
|
1747
|
+
const radius = element.props.cornerRadius;
|
|
1748
|
+
return { kind: spec.kind, cornerRadius: spec.cornerRadius ?? radius ?? 0 };
|
|
1749
|
+
}
|
|
1750
|
+
function AnimatedStyle({ animation, value, children }) {
|
|
1751
|
+
const last = useRef({ value, token: 0 });
|
|
1752
|
+
if (!Object.is(last.current.value, value)) last.current = { value, token: last.current.token + 1 };
|
|
1753
|
+
return styled({ animation, animationToken: last.current.token }, children);
|
|
1754
|
+
}
|
|
1755
|
+
function Searchable({ text, onChange, prompt }) {
|
|
1756
|
+
const [value, setValue] = readBinding(text, onChange);
|
|
1757
|
+
return sb("searchfield", { text: value, placeholder: prompt ?? "Search" }, { text: (event) => setValue(event.value) });
|
|
1758
|
+
}
|
|
1759
|
+
function applyModifiers(element, modifiers) {
|
|
1760
|
+
const sides = [];
|
|
1761
|
+
const node = wrap(element, modifiers, sides);
|
|
1762
|
+
if (sides.length === 0) return node;
|
|
1763
|
+
return createElement(Fragment, null, node, ...sides);
|
|
1764
|
+
}
|
|
1765
|
+
function wrap(element, modifiers, sides) {
|
|
1766
|
+
let node = element;
|
|
1767
|
+
for (const [key, value] of modifiers) {
|
|
1768
|
+
if (value === void 0) continue;
|
|
1769
|
+
if (value === null && key !== "lineLimit" && key !== "badge") continue;
|
|
1770
|
+
node = apply(key, value, node, sides);
|
|
1771
|
+
}
|
|
1772
|
+
return node;
|
|
1773
|
+
}
|
|
1774
|
+
function apply(key, value, node, sides) {
|
|
1775
|
+
switch (key) {
|
|
1776
|
+
case "padding":
|
|
1777
|
+
return styled({ padding: padding(value) }, node);
|
|
1778
|
+
case "font":
|
|
1779
|
+
return styled({ font: font(value) }, node);
|
|
1780
|
+
case "fontWeight":
|
|
1781
|
+
return styled({ font: { weight: value } }, node);
|
|
1782
|
+
case "bold":
|
|
1783
|
+
return value ? styled({ font: { weight: "bold" } }, node) : node;
|
|
1784
|
+
case "foregroundStyle":
|
|
1785
|
+
return styled({ foreground: shapeStyle(value) }, node);
|
|
1786
|
+
case "background": {
|
|
1787
|
+
if (isValidElement(value)) return decorated("background", "center", node, value);
|
|
1788
|
+
const inShape = value;
|
|
1789
|
+
if (typeof inShape === "object" && inShape !== null && "in" in inShape && isValidElement(inShape.in)) {
|
|
1790
|
+
return decorated("background", "center", node, cloneElement(inShape.in, { fill: inShape.fill }));
|
|
1791
|
+
}
|
|
1792
|
+
return styled({ background: shapeStyle(value) }, node);
|
|
1793
|
+
}
|
|
1794
|
+
case "overlay": {
|
|
1795
|
+
if (isValidElement(value)) return decorated("overlay", "center", node, value);
|
|
1796
|
+
const spec = value;
|
|
1797
|
+
return decorated("overlay", spec.alignment ?? "center", node, spec.content);
|
|
1798
|
+
}
|
|
1799
|
+
case "frame":
|
|
1800
|
+
return styled({ frame: frame(value) }, node);
|
|
1801
|
+
case "cornerRadius":
|
|
1802
|
+
return styled({ cornerRadius: value }, node);
|
|
1803
|
+
case "clipShape": {
|
|
1804
|
+
const spec = isValidElement(value) ? shapeSpecOf(value) : null;
|
|
1805
|
+
return styled({ cornerRadius: spec?.cornerRadius ?? 0 }, node);
|
|
1806
|
+
}
|
|
1807
|
+
case "clipped":
|
|
1808
|
+
return value ? styled({ clipped: true }, node) : node;
|
|
1809
|
+
case "opacity":
|
|
1810
|
+
return styled({ opacity: value }, node);
|
|
1811
|
+
case "disabled":
|
|
1812
|
+
return value ? styled({ disabled: true }, node) : node;
|
|
1813
|
+
case "hidden":
|
|
1814
|
+
return value ? styled({ hidden: true }, node) : node;
|
|
1815
|
+
case "layoutPriority":
|
|
1816
|
+
return styled({ layoutPriority: value }, node);
|
|
1817
|
+
case "lineLimit": {
|
|
1818
|
+
if (Array.isArray(value)) {
|
|
1819
|
+
const [min, max] = value;
|
|
1820
|
+
return styled({ lineLimit: max, lineLimitMin: min }, node);
|
|
1821
|
+
}
|
|
1822
|
+
return styled({ lineLimit: value }, node);
|
|
1823
|
+
}
|
|
1824
|
+
case "multilineTextAlignment":
|
|
1825
|
+
return styled({ multilineTextAlignment: value }, node);
|
|
1826
|
+
case "fixedSize":
|
|
1827
|
+
return value ? styled({ fixedSize: value === true ? { horizontal: true, vertical: true } : value }, node) : node;
|
|
1828
|
+
case "offset": {
|
|
1829
|
+
const offset = value;
|
|
1830
|
+
return styled({ offset: { x: offset.x ?? 0, y: offset.y ?? 0 } }, node);
|
|
1831
|
+
}
|
|
1832
|
+
case "rotationEffect": {
|
|
1833
|
+
if (typeof value === "number") return styled({ rotation: value }, node);
|
|
1834
|
+
const spec = value;
|
|
1835
|
+
const style = { rotation: spec.degrees };
|
|
1836
|
+
if (spec.anchor !== void 0) style.rotationAnchor = unitPoint(spec.anchor);
|
|
1837
|
+
return styled(style, node);
|
|
1838
|
+
}
|
|
1839
|
+
case "scaleEffect": {
|
|
1840
|
+
if (typeof value === "number") return styled({ scale: { x: value, y: value } }, node);
|
|
1841
|
+
const spec = value;
|
|
1842
|
+
const style = { scale: { x: spec.x, y: spec.y } };
|
|
1843
|
+
if (spec.anchor !== void 0) style.scaleAnchor = unitPoint(spec.anchor);
|
|
1844
|
+
return styled(style, node);
|
|
1845
|
+
}
|
|
1846
|
+
case "shadow": {
|
|
1847
|
+
const shadow = value;
|
|
1848
|
+
return styled(
|
|
1849
|
+
{ shadow: { color: shadow.color ? color(shadow.color) : rgb(0, 0, 0, 0.33), radius: shadow.radius, x: shadow.x ?? 0, y: shadow.y ?? 0 } },
|
|
1850
|
+
node
|
|
1851
|
+
);
|
|
1852
|
+
}
|
|
1853
|
+
case "tint":
|
|
1854
|
+
return styled({ tint: color(value) }, node);
|
|
1855
|
+
case "badge":
|
|
1856
|
+
return styled({ badge: value === null ? null : String(value) }, node);
|
|
1857
|
+
case "listRowInsets":
|
|
1858
|
+
return styled({ listRowInsets: value }, node);
|
|
1859
|
+
case "imageScale":
|
|
1860
|
+
return styled({ imageScale: value }, node);
|
|
1861
|
+
case "transition":
|
|
1862
|
+
return styled({ transition: value }, node);
|
|
1863
|
+
case "animation": {
|
|
1864
|
+
const spec = value;
|
|
1341
1865
|
return createElement(AnimatedStyle, { animation: spec.animation ?? { type: "default" }, value: spec.value }, node);
|
|
1342
1866
|
}
|
|
1343
1867
|
case "gridColumnAlignment":
|
|
@@ -1356,510 +1880,261 @@ function apply(key, value, node, sides) {
|
|
|
1356
1880
|
sides.push(sb(PREF_KIND, { title: value }, void 0, void 0, "navscreen"));
|
|
1357
1881
|
return node;
|
|
1358
1882
|
case "navigationBarTitleDisplayMode":
|
|
1359
|
-
sides.push(sb(PREF_KIND, { displayMode: value }, void 0, void 0, "navscreen"));
|
|
1360
|
-
return node;
|
|
1361
|
-
case "toolbar":
|
|
1362
|
-
sides.push(sb(HOIST_KIND, void 0, void 0, value, "navscreen"));
|
|
1363
|
-
return node;
|
|
1364
|
-
case "searchable":
|
|
1365
|
-
sides.push(sb(HOIST_KIND, void 0, void 0, createElement(Searchable, value), "navscreen"));
|
|
1366
|
-
return node;
|
|
1367
|
-
case "navigationDestination":
|
|
1368
|
-
sides.push(createElement(RegisterDestination, { destination: value }));
|
|
1369
|
-
return node;
|
|
1370
|
-
case "sheet":
|
|
1371
|
-
sides.push(createElement(SheetPresenter, value));
|
|
1372
|
-
return node;
|
|
1373
|
-
case "fullScreenCover":
|
|
1374
|
-
sides.push(createElement(SheetPresenter, { ...value, fullScreen: true }));
|
|
1375
|
-
return node;
|
|
1376
|
-
case "alert":
|
|
1377
|
-
sides.push(createElement(AlertPresenter, value));
|
|
1378
|
-
return node;
|
|
1379
|
-
case "confirmationDialog":
|
|
1380
|
-
sides.push(createElement(AlertPresenter, { ...value, style: "dialog" }));
|
|
1381
|
-
return node;
|
|
1382
|
-
case "presentationDetents":
|
|
1383
|
-
sides.push(presentationDetents(value));
|
|
1384
|
-
return node;
|
|
1385
|
-
case "onTapGesture":
|
|
1386
|
-
return sb("tapgesture", {}, { tap: value }, node);
|
|
1387
|
-
case "dragGesture": {
|
|
1388
|
-
const drag = value;
|
|
1389
|
-
return sb(
|
|
1390
|
-
"gesture",
|
|
1391
|
-
{ drag: true, longPress: false, minimumDistance: drag.minimumDistance ?? 10, minimumDuration: 0.5 },
|
|
1392
|
-
{
|
|
1393
|
-
drag: (event) => {
|
|
1394
|
-
const dragValue = {
|
|
1395
|
-
translation: event.translation,
|
|
1396
|
-
location: event.location,
|
|
1397
|
-
startLocation: event.startLocation,
|
|
1398
|
-
velocity: event.velocity
|
|
1399
|
-
};
|
|
1400
|
-
if (event.phase === "ended" || event.phase === "cancelled") drag.onEnded?.(dragValue);
|
|
1401
|
-
else drag.onChanged?.(dragValue);
|
|
1402
|
-
}
|
|
1403
|
-
},
|
|
1404
|
-
node
|
|
1405
|
-
);
|
|
1406
|
-
}
|
|
1407
|
-
case "onLongPressGesture": {
|
|
1408
|
-
const spec = typeof value === "function" ? { action: value } : value;
|
|
1409
|
-
return sb(
|
|
1410
|
-
"gesture",
|
|
1411
|
-
{ drag: false, longPress: true, minimumDistance: 10, minimumDuration: spec.minimumDuration ?? 0.5 },
|
|
1412
|
-
{ longpress: () => spec.action() },
|
|
1413
|
-
node
|
|
1414
|
-
);
|
|
1415
|
-
}
|
|
1416
|
-
case "contextMenu":
|
|
1417
|
-
return sb("contextmenu", {}, void 0, [createElement(Fragment$1, { key: "content" }, node), createElement(Fragment$1, { key: "items" }, value)]);
|
|
1418
|
-
case "swipeActions": {
|
|
1419
|
-
const specs = Array.isArray(value) ? value : [value];
|
|
1420
|
-
const trailing = [];
|
|
1421
|
-
const leading = [];
|
|
1422
|
-
let fullSwipeTrailing = true;
|
|
1423
|
-
let fullSwipeLeading = true;
|
|
1424
|
-
for (const spec of specs) {
|
|
1425
|
-
const actions = Children.toArray(spec.children);
|
|
1426
|
-
if (spec.edge === "leading") {
|
|
1427
|
-
leading.push(...actions);
|
|
1428
|
-
fullSwipeLeading = spec.allowsFullSwipe ?? true;
|
|
1429
|
-
} else {
|
|
1430
|
-
trailing.push(...actions);
|
|
1431
|
-
fullSwipeTrailing = spec.allowsFullSwipe ?? true;
|
|
1432
|
-
}
|
|
1433
|
-
}
|
|
1434
|
-
return sb(
|
|
1435
|
-
"swipeactions",
|
|
1436
|
-
{ trailing: trailing.length, leading: leading.length, fullSwipeTrailing, fullSwipeLeading },
|
|
1437
|
-
void 0,
|
|
1438
|
-
[createElement(Fragment$1, { key: "content" }, node), ...trailing, ...leading]
|
|
1439
|
-
);
|
|
1440
|
-
}
|
|
1441
|
-
case "onAppear":
|
|
1442
|
-
sides.push(createElement(Lifecycle, { onAppear: value }));
|
|
1443
|
-
return node;
|
|
1444
|
-
case "onDisappear":
|
|
1445
|
-
sides.push(createElement(Lifecycle, { onDisappear: value }));
|
|
1446
|
-
return node;
|
|
1447
|
-
case "tag":
|
|
1448
|
-
return node;
|
|
1449
|
-
case "aspectRatio": {
|
|
1450
|
-
const spec = typeof value === "number" ? { ratio: value } : value;
|
|
1451
|
-
return styled({ aspectRatio: { ratio: spec.ratio ?? null, contentMode: spec.contentMode ?? "fit" } }, node);
|
|
1452
|
-
}
|
|
1453
|
-
case "scaledToFit":
|
|
1454
|
-
return value ? styled({ aspectRatio: { ratio: null, contentMode: "fit" } }, node) : node;
|
|
1455
|
-
case "scaledToFill":
|
|
1456
|
-
return value ? styled({ aspectRatio: { ratio: null, contentMode: "fill" } }, node) : node;
|
|
1457
|
-
case "blur":
|
|
1458
|
-
return styled({ blur: value }, node);
|
|
1459
|
-
case "brightness":
|
|
1460
|
-
return styled({ brightness: value }, node);
|
|
1461
|
-
case "contrast":
|
|
1462
|
-
return styled({ contrast: value }, node);
|
|
1463
|
-
case "saturation":
|
|
1464
|
-
return styled({ saturation: value }, node);
|
|
1465
|
-
case "grayscale":
|
|
1466
|
-
return styled({ grayscale: value }, node);
|
|
1467
|
-
case "hueRotation":
|
|
1468
|
-
return styled({ hueRotation: value }, node);
|
|
1469
|
-
case "colorInvert":
|
|
1470
|
-
return value ? styled({ colorInvert: true }, node) : node;
|
|
1471
|
-
case "colorMultiply":
|
|
1472
|
-
return styled({ colorMultiply: color(value) }, node);
|
|
1473
|
-
case "blendMode":
|
|
1474
|
-
return styled({ blendMode: value }, node);
|
|
1475
|
-
case "mask":
|
|
1476
|
-
return styled({ mask: shapeStyle(value) }, node);
|
|
1477
|
-
case "position":
|
|
1478
|
-
return styled({ position: value }, node);
|
|
1479
|
-
case "zIndex":
|
|
1480
|
-
return styled({ zIndex: value }, node);
|
|
1481
|
-
case "allowsHitTesting":
|
|
1482
|
-
return value === false ? styled({ hitTesting: false }, node) : node;
|
|
1483
|
-
case "ignoresSafeArea":
|
|
1484
|
-
return styled({ ignoresSafeArea: value === true ? "all" : value }, node);
|
|
1485
|
-
case "rotation3DEffect": {
|
|
1486
|
-
const spec = value;
|
|
1487
|
-
const rotation = { angle: spec.angle, axis: spec.axis };
|
|
1488
|
-
if (spec.anchor !== void 0) rotation.anchor = unitPoint(spec.anchor);
|
|
1489
|
-
if (spec.perspective !== void 0) rotation.perspective = spec.perspective;
|
|
1490
|
-
return styled({ rotation3D: rotation }, node);
|
|
1491
|
-
}
|
|
1492
|
-
case "gridCellAnchor":
|
|
1493
|
-
return styled({ gridCellAnchor: unitPoint(value) }, node);
|
|
1494
|
-
case "alignmentGuide": {
|
|
1495
|
-
const spec = value;
|
|
1496
|
-
const at = (width, height) => spec.value({ width, height });
|
|
1497
|
-
const a = at(0, 0);
|
|
1498
|
-
const round2 = (n) => Math.round(n * 1e6) / 1e6;
|
|
1499
|
-
const vertical = ["top", "bottom", "verticalCenter", "firstTextBaseline", "lastTextBaseline"].includes(spec.guide);
|
|
1500
|
-
const name = spec.guide === "horizontalCenter" || spec.guide === "verticalCenter" ? "center" : spec.guide;
|
|
1501
|
-
return styled(
|
|
1502
|
-
{
|
|
1503
|
-
alignmentGuide: {
|
|
1504
|
-
axis: vertical ? "vertical" : "horizontal",
|
|
1505
|
-
name,
|
|
1506
|
-
value: [round2(a), round2((at(100, 0) - a) / 100), round2((at(0, 100) - a) / 100)]
|
|
1507
|
-
}
|
|
1508
|
-
},
|
|
1509
|
-
node
|
|
1510
|
-
);
|
|
1511
|
-
}
|
|
1512
|
-
case "preferredColorScheme":
|
|
1513
|
-
sides.push(sb(PREF_KIND, { colorScheme: value }, void 0, void 0, "root"));
|
|
1514
|
-
return node;
|
|
1515
|
-
case "refreshable":
|
|
1516
|
-
return withEnvironment({ refresh: value }, node);
|
|
1517
|
-
case "submitLabel":
|
|
1518
|
-
return withEnvironment({ submitLabel: value }, node);
|
|
1519
|
-
case "labelStyle":
|
|
1520
|
-
return withEnvironment({ labelStyle: value }, node);
|
|
1521
|
-
case "task": {
|
|
1522
|
-
const spec = typeof value === "function" ? { id: void 0, action: value } : value;
|
|
1523
|
-
sides.push(createElement(Task, spec));
|
|
1524
|
-
return node;
|
|
1525
|
-
}
|
|
1526
|
-
case "onChangeOf":
|
|
1527
|
-
sides.push(createElement(OnChange, value));
|
|
1528
|
-
return node;
|
|
1529
|
-
case "scrollID":
|
|
1530
|
-
return createElement(ScrollTarget, { id: value }, node);
|
|
1531
|
-
case "draggable":
|
|
1532
|
-
return createElement(Draggable, { payload: value }, node);
|
|
1533
|
-
case "dropDestination":
|
|
1534
|
-
return createElement(DropDestination, value, node);
|
|
1535
|
-
case "inspector":
|
|
1536
|
-
return createElement(Inspector, value, node);
|
|
1537
|
-
case "onHover":
|
|
1538
|
-
return createElement(Hover, { action: value }, node);
|
|
1539
|
-
case "help":
|
|
1540
|
-
return styled({ help: value }, node);
|
|
1541
|
-
case "pointerStyle":
|
|
1542
|
-
return styled({ pointerStyle: cursorFor(value) }, node);
|
|
1543
|
-
case "symbolEffect":
|
|
1544
|
-
return createElement(SymbolEffect, { spec: value }, node);
|
|
1545
|
-
case "matchedGeometryEffect": {
|
|
1546
|
-
const spec = value;
|
|
1547
|
-
return styled({ matchedGeometry: `${spec.namespace ?? ""}:${spec.id}` }, node);
|
|
1548
|
-
}
|
|
1549
|
-
case "layoutValue":
|
|
1883
|
+
sides.push(sb(PREF_KIND, { displayMode: value }, void 0, void 0, "navscreen"));
|
|
1550
1884
|
return node;
|
|
1551
|
-
case "
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
return
|
|
1557
|
-
|
|
1558
|
-
|
|
1885
|
+
case "toolbarRole":
|
|
1886
|
+
sides.push(sb(PREF_KIND, { toolbarRole: value }, void 0, void 0, "navscreen"));
|
|
1887
|
+
return node;
|
|
1888
|
+
case "toolbar":
|
|
1889
|
+
sides.push(sb(HOIST_KIND, void 0, void 0, value, "navscreen"));
|
|
1890
|
+
return node;
|
|
1891
|
+
case "searchable":
|
|
1892
|
+
sides.push(sb(HOIST_KIND, void 0, void 0, createElement(Searchable, value), "navscreen"));
|
|
1893
|
+
return node;
|
|
1894
|
+
case "navigationDestination":
|
|
1895
|
+
sides.push(createElement(RegisterDestination, { destination: value }));
|
|
1896
|
+
return node;
|
|
1897
|
+
case "sheet":
|
|
1559
1898
|
sides.push(createElement(SheetPresenter, value));
|
|
1560
1899
|
return node;
|
|
1561
|
-
case "
|
|
1562
|
-
|
|
1563
|
-
case "keyboardShortcut":
|
|
1900
|
+
case "fullScreenCover":
|
|
1901
|
+
sides.push(createElement(SheetPresenter, { ...value, fullScreen: true }));
|
|
1564
1902
|
return node;
|
|
1565
|
-
case "
|
|
1566
|
-
sides.push(createElement(
|
|
1903
|
+
case "alert":
|
|
1904
|
+
sides.push(createElement(AlertPresenter, value));
|
|
1567
1905
|
return node;
|
|
1568
|
-
case "
|
|
1569
|
-
|
|
1570
|
-
sides.push(createElement(SensoryFeedbackPlayer, spec));
|
|
1906
|
+
case "confirmationDialog":
|
|
1907
|
+
sides.push(createElement(AlertPresenter, { ...value, style: "dialog" }));
|
|
1571
1908
|
return node;
|
|
1909
|
+
case "presentationDetents":
|
|
1910
|
+
sides.push(presentationDetents(value));
|
|
1911
|
+
return node;
|
|
1912
|
+
case "onTapGesture":
|
|
1913
|
+
return sb("tapgesture", {}, { tap: value }, node);
|
|
1914
|
+
case "dragGesture": {
|
|
1915
|
+
const drag = value;
|
|
1916
|
+
return sb(
|
|
1917
|
+
"gesture",
|
|
1918
|
+
{ drag: true, longPress: false, minimumDistance: drag.minimumDistance ?? 10, minimumDuration: 0.5 },
|
|
1919
|
+
{
|
|
1920
|
+
drag: (event) => {
|
|
1921
|
+
const dragValue = {
|
|
1922
|
+
translation: event.translation,
|
|
1923
|
+
location: event.location,
|
|
1924
|
+
startLocation: event.startLocation,
|
|
1925
|
+
velocity: event.velocity
|
|
1926
|
+
};
|
|
1927
|
+
if (event.phase === "ended" || event.phase === "cancelled") drag.onEnded?.(dragValue);
|
|
1928
|
+
else drag.onChanged?.(dragValue);
|
|
1929
|
+
}
|
|
1930
|
+
},
|
|
1931
|
+
node
|
|
1932
|
+
);
|
|
1572
1933
|
}
|
|
1573
|
-
case "
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
case "contentMargins":
|
|
1582
|
-
return withScrollSettings(marginSettings(value), node);
|
|
1583
|
-
case "containerRelativeFrame":
|
|
1584
|
-
return styled({ containerRelativeFrame: containerRelativeFrame(value) }, node);
|
|
1585
|
-
case "visualEffect":
|
|
1586
|
-
return createElement(VisualEffectView, { effect: value }, node);
|
|
1587
|
-
case "scrollTransition": {
|
|
1588
|
-
const spec = typeof value === "function" ? { transition: value } : value;
|
|
1589
|
-
return createElement(ScrollTransitionView, { spec }, node);
|
|
1590
|
-
}
|
|
1591
|
-
case "contentTransition": {
|
|
1592
|
-
if (value === "identity") return node;
|
|
1593
|
-
if (typeof value === "object") {
|
|
1594
|
-
const countsDown = value.numericText.countsDown;
|
|
1595
|
-
return styled({ contentTransition: { kind: "numericText", ...countsDown !== void 0 ? { countsDown } : {} } }, node);
|
|
1596
|
-
}
|
|
1597
|
-
return styled({ contentTransition: { kind: value } }, node);
|
|
1934
|
+
case "onLongPressGesture": {
|
|
1935
|
+
const spec = typeof value === "function" ? { action: value } : value;
|
|
1936
|
+
return sb(
|
|
1937
|
+
"gesture",
|
|
1938
|
+
{ drag: false, longPress: true, minimumDistance: 10, minimumDuration: spec.minimumDuration ?? 0.5 },
|
|
1939
|
+
{ longpress: () => spec.action() },
|
|
1940
|
+
node
|
|
1941
|
+
);
|
|
1598
1942
|
}
|
|
1599
|
-
case "
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1943
|
+
case "contextMenu":
|
|
1944
|
+
return sb("contextmenu", {}, void 0, [createElement(Fragment, { key: "content" }, node), createElement(Fragment, { key: "items" }, value)]);
|
|
1945
|
+
case "swipeActions": {
|
|
1946
|
+
const specs = Array.isArray(value) ? value : [value];
|
|
1947
|
+
const trailing = [];
|
|
1948
|
+
const leading = [];
|
|
1949
|
+
let fullSwipeTrailing = true;
|
|
1950
|
+
let fullSwipeLeading = true;
|
|
1951
|
+
for (const spec of specs) {
|
|
1952
|
+
const actions = Children.toArray(spec.children);
|
|
1953
|
+
if (spec.edge === "leading") {
|
|
1954
|
+
leading.push(...actions);
|
|
1955
|
+
fullSwipeLeading = spec.allowsFullSwipe ?? true;
|
|
1956
|
+
} else {
|
|
1957
|
+
trailing.push(...actions);
|
|
1958
|
+
fullSwipeTrailing = spec.allowsFullSwipe ?? true;
|
|
1959
|
+
}
|
|
1603
1960
|
}
|
|
1604
|
-
return
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1961
|
+
return sb(
|
|
1962
|
+
"swipeactions",
|
|
1963
|
+
{ trailing: trailing.length, leading: leading.length, fullSwipeTrailing, fullSwipeLeading },
|
|
1964
|
+
void 0,
|
|
1965
|
+
[createElement(Fragment, { key: "content" }, node), ...trailing, ...leading]
|
|
1966
|
+
);
|
|
1609
1967
|
}
|
|
1610
|
-
|
|
1611
|
-
}
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
props["selectable"] = true;
|
|
1622
|
-
props["selected"] = selection.isSelected(tag);
|
|
1623
|
-
}
|
|
1624
|
-
if (canDelete) props["deletable"] = true;
|
|
1625
|
-
if (canMove) props["movable"] = true;
|
|
1626
|
-
return sb(
|
|
1627
|
-
"listrow",
|
|
1628
|
-
props,
|
|
1629
|
-
{
|
|
1630
|
-
tap: () => selectable && selection.select(tag),
|
|
1631
|
-
delete: () => onDelete?.(),
|
|
1632
|
-
move: (event) => {
|
|
1633
|
-
const start = (containerIndex ?? index ?? 0) - (index ?? 0);
|
|
1634
|
-
onMove?.(Math.max(0, event.to - start));
|
|
1635
|
-
}
|
|
1636
|
-
},
|
|
1637
|
-
children
|
|
1638
|
-
);
|
|
1639
|
-
}
|
|
1640
|
-
const LAZY_BATCH = 12;
|
|
1641
|
-
const LazyContext = createContext(null);
|
|
1642
|
-
function LazyGroup({ rows, start = 0, wrap: wrap2 }) {
|
|
1643
|
-
const axis = useContext(LazyContext);
|
|
1644
|
-
const request = useContext(ScrollRequestContext);
|
|
1645
|
-
const [count, setCount] = useState(LAZY_BATCH);
|
|
1646
|
-
const target = request ? rows.findIndex((row) => rowMatches(row, request.id)) : -1;
|
|
1647
|
-
const needed = target >= 0 ? Math.ceil((target + 1) / LAZY_BATCH) * LAZY_BATCH : 0;
|
|
1648
|
-
useEffect(() => {
|
|
1649
|
-
if (needed > count) setCount(needed);
|
|
1650
|
-
}, [needed, count]);
|
|
1651
|
-
const visible = Math.max(count, needed);
|
|
1652
|
-
const shown = axis === null ? rows : rows.slice(0, visible);
|
|
1653
|
-
const built = shown.map((row, index) => wrap2 ? wrap2(row, start + index) : row);
|
|
1654
|
-
if (axis === null || shown.length >= rows.length) return built;
|
|
1655
|
-
return [
|
|
1656
|
-
...built,
|
|
1657
|
-
createElement(
|
|
1658
|
-
LazySpacer,
|
|
1659
|
-
{ key: `lazy-${visible}`, axis, remaining: rows.length - shown.length, more: () => setCount(visible + LAZY_BATCH) }
|
|
1660
|
-
)
|
|
1661
|
-
];
|
|
1662
|
-
}
|
|
1663
|
-
function LazySpacer({ axis, remaining, more }) {
|
|
1664
|
-
return sb("lazyspacer", { axis, remaining }, { lazy: more });
|
|
1665
|
-
}
|
|
1666
|
-
function rowMatches(row, id) {
|
|
1667
|
-
if (row.key !== null && row.key === String(id)) return true;
|
|
1668
|
-
let element = row;
|
|
1669
|
-
for (let depth = 0; element && depth < 3; depth++) {
|
|
1670
|
-
const props = element.props;
|
|
1671
|
-
if (props.scrollID === id) return true;
|
|
1672
|
-
element = isValidElement(props.children) ? props.children : null;
|
|
1673
|
-
}
|
|
1674
|
-
return false;
|
|
1675
|
-
}
|
|
1676
|
-
function VStack(props) {
|
|
1677
|
-
const { own, modifiers } = splitProps(props);
|
|
1678
|
-
const stack = { spacing: own.spacing ?? null, alignment: own.alignment ?? "center" };
|
|
1679
|
-
if (own.scrollTargetLayout) stack["scrollTarget"] = true;
|
|
1680
|
-
return applyModifiers(sb("vstack", stack, void 0, own.children), modifiers);
|
|
1681
|
-
}
|
|
1682
|
-
function HStack(props) {
|
|
1683
|
-
const { own, modifiers } = splitProps(props);
|
|
1684
|
-
const stack = { spacing: own.spacing ?? null, alignment: own.alignment ?? "center" };
|
|
1685
|
-
if (own.scrollTargetLayout) stack["scrollTarget"] = true;
|
|
1686
|
-
return applyModifiers(sb("hstack", stack, void 0, own.children), modifiers);
|
|
1687
|
-
}
|
|
1688
|
-
function ZStack(props) {
|
|
1689
|
-
const { own, modifiers } = splitProps(props);
|
|
1690
|
-
return applyModifiers(sb("zstack", { alignment: own.alignment ?? "center" }, void 0, own.children), modifiers);
|
|
1691
|
-
}
|
|
1692
|
-
function Spacer(props) {
|
|
1693
|
-
const { own, modifiers } = splitProps(props);
|
|
1694
|
-
return applyModifiers(sb("spacer", { minLength: own.minLength ?? null }), modifiers);
|
|
1695
|
-
}
|
|
1696
|
-
function Divider(props) {
|
|
1697
|
-
const { modifiers } = splitProps(props);
|
|
1698
|
-
return applyModifiers(sb("divider", {}), modifiers);
|
|
1699
|
-
}
|
|
1700
|
-
function ScrollView(props) {
|
|
1701
|
-
const { own, modifiers } = splitProps(props);
|
|
1702
|
-
const refresh = useRefreshable(takeModifier(modifiers, "refreshable"));
|
|
1703
|
-
const ownSettings = takeScrollSettings(modifiers);
|
|
1704
|
-
const settings = useScrollSettings(ownSettings);
|
|
1705
|
-
const axes = own.axes ?? "vertical";
|
|
1706
|
-
const scroll = { axes, ...refresh.props };
|
|
1707
|
-
if (own.scrollTargetBehavior) scroll["snap"] = own.scrollTargetBehavior;
|
|
1708
|
-
if (own.scrollDismissesKeyboard) scroll["dismissesKeyboard"] = true;
|
|
1709
|
-
const edgeEffect = edgeEffectProp(settings);
|
|
1710
|
-
if (edgeEffect) scroll["edgeEffect"] = edgeEffect;
|
|
1711
|
-
const content = marginedContent(own.children, settings.margins, axes === "horizontal" ? "horizontal" : "vertical");
|
|
1712
|
-
return applyModifiers(sb("scrollview", scroll, refresh.handlers, providingScrollSettings(ownSettings, content)), modifiers);
|
|
1713
|
-
}
|
|
1714
|
-
function takeScrollSettings(modifiers) {
|
|
1715
|
-
let settings = {};
|
|
1716
|
-
const own = [];
|
|
1717
|
-
for (const key of ["scrollEdgeEffectStyle", "scrollEdgeEffectHidden", "contentMargins"]) {
|
|
1718
|
-
const value = takeModifier(modifiers, key);
|
|
1719
|
-
if (value === void 0) continue;
|
|
1720
|
-
if (key === "scrollEdgeEffectStyle") own.push(edgeStyleSettings(value));
|
|
1721
|
-
else if (key === "scrollEdgeEffectHidden") own.push(edgeHiddenSettings(value));
|
|
1722
|
-
else own.push(marginSettings(value));
|
|
1723
|
-
}
|
|
1724
|
-
for (const each of own) settings = mergeScrollSettings(settings, each);
|
|
1725
|
-
return settings;
|
|
1726
|
-
}
|
|
1727
|
-
function providingScrollSettings(settings, children) {
|
|
1728
|
-
return Object.keys(settings).length > 0 ? withScrollSettings(settings, children) : children;
|
|
1729
|
-
}
|
|
1730
|
-
function useRefreshable(own) {
|
|
1731
|
-
const environment = useViewEnvironment();
|
|
1732
|
-
const refresh = own ?? environment.refresh;
|
|
1733
|
-
const [refreshing, setRefreshing] = useState(false);
|
|
1734
|
-
if (!refresh) return { props: {} };
|
|
1735
|
-
return {
|
|
1736
|
-
props: { refreshable: true, refreshing },
|
|
1737
|
-
handlers: {
|
|
1738
|
-
refresh: () => {
|
|
1739
|
-
if (refreshing) return;
|
|
1740
|
-
setRefreshing(true);
|
|
1741
|
-
Promise.resolve().then(refresh).catch((error) => console.error(error)).finally(() => setRefreshing(false));
|
|
1742
|
-
}
|
|
1968
|
+
case "onAppear":
|
|
1969
|
+
sides.push(createElement(Lifecycle, { onAppear: value }));
|
|
1970
|
+
return node;
|
|
1971
|
+
case "onDisappear":
|
|
1972
|
+
sides.push(createElement(Lifecycle, { onDisappear: value }));
|
|
1973
|
+
return node;
|
|
1974
|
+
case "tag":
|
|
1975
|
+
return node;
|
|
1976
|
+
case "aspectRatio": {
|
|
1977
|
+
const spec = typeof value === "number" ? { ratio: value } : value;
|
|
1978
|
+
return styled({ aspectRatio: { ratio: spec.ratio ?? null, contentMode: spec.contentMode ?? "fit" } }, node);
|
|
1743
1979
|
}
|
|
1744
|
-
|
|
1745
|
-
}
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1980
|
+
case "scaledToFit":
|
|
1981
|
+
return value ? styled({ aspectRatio: { ratio: null, contentMode: "fit" } }, node) : node;
|
|
1982
|
+
case "scaledToFill":
|
|
1983
|
+
return value ? styled({ aspectRatio: { ratio: null, contentMode: "fill" } }, node) : node;
|
|
1984
|
+
case "blur":
|
|
1985
|
+
return styled({ blur: value }, node);
|
|
1986
|
+
case "brightness":
|
|
1987
|
+
return styled({ brightness: value }, node);
|
|
1988
|
+
case "contrast":
|
|
1989
|
+
return styled({ contrast: value }, node);
|
|
1990
|
+
case "saturation":
|
|
1991
|
+
return styled({ saturation: value }, node);
|
|
1992
|
+
case "grayscale":
|
|
1993
|
+
return styled({ grayscale: value }, node);
|
|
1994
|
+
case "hueRotation":
|
|
1995
|
+
return styled({ hueRotation: value }, node);
|
|
1996
|
+
case "colorInvert":
|
|
1997
|
+
return value ? styled({ colorInvert: true }, node) : node;
|
|
1998
|
+
case "colorMultiply":
|
|
1999
|
+
return styled({ colorMultiply: color(value) }, node);
|
|
2000
|
+
case "blendMode":
|
|
2001
|
+
return styled({ blendMode: value }, node);
|
|
2002
|
+
case "mask":
|
|
2003
|
+
return styled({ mask: shapeStyle(value) }, node);
|
|
2004
|
+
case "position":
|
|
2005
|
+
return styled({ position: value }, node);
|
|
2006
|
+
case "zIndex":
|
|
2007
|
+
return styled({ zIndex: value }, node);
|
|
2008
|
+
case "allowsHitTesting":
|
|
2009
|
+
return value === false ? styled({ hitTesting: false }, node) : node;
|
|
2010
|
+
case "ignoresSafeArea":
|
|
2011
|
+
return styled({ ignoresSafeArea: value === true ? "all" : value }, node);
|
|
2012
|
+
case "rotation3DEffect": {
|
|
2013
|
+
const spec = value;
|
|
2014
|
+
const rotation = { angle: spec.angle, axis: spec.axis };
|
|
2015
|
+
if (spec.anchor !== void 0) rotation.anchor = unitPoint(spec.anchor);
|
|
2016
|
+
if (spec.perspective !== void 0) rotation.perspective = spec.perspective;
|
|
2017
|
+
return styled({ rotation3D: rotation }, node);
|
|
1770
2018
|
}
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
2019
|
+
case "gridCellAnchor":
|
|
2020
|
+
return styled({ gridCellAnchor: unitPoint(value) }, node);
|
|
2021
|
+
case "alignmentGuide": {
|
|
2022
|
+
const spec = value;
|
|
2023
|
+
const at = (width, height) => spec.value({ width, height });
|
|
2024
|
+
const a = at(0, 0);
|
|
2025
|
+
const round2 = (n) => Math.round(n * 1e6) / 1e6;
|
|
2026
|
+
const vertical = ["top", "bottom", "verticalCenter", "firstTextBaseline", "lastTextBaseline"].includes(spec.guide);
|
|
2027
|
+
const name = spec.guide === "horizontalCenter" || spec.guide === "verticalCenter" ? "center" : spec.guide;
|
|
2028
|
+
return styled(
|
|
2029
|
+
{
|
|
2030
|
+
alignmentGuide: {
|
|
2031
|
+
axis: vertical ? "vertical" : "horizontal",
|
|
2032
|
+
name,
|
|
2033
|
+
value: [round2(a), round2((at(100, 0) - a) / 100), round2((at(0, 100) - a) / 100)]
|
|
2034
|
+
}
|
|
2035
|
+
},
|
|
2036
|
+
node
|
|
2037
|
+
);
|
|
1774
2038
|
}
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
const result = [];
|
|
1789
|
-
const visit = (node) => {
|
|
1790
|
-
if (node === null || node === void 0 || typeof node === "boolean") return;
|
|
1791
|
-
if (Array.isArray(node)) {
|
|
1792
|
-
node.forEach(visit);
|
|
1793
|
-
return;
|
|
2039
|
+
case "preferredColorScheme":
|
|
2040
|
+
sides.push(sb(PREF_KIND, { colorScheme: value }, void 0, void 0, "root"));
|
|
2041
|
+
return node;
|
|
2042
|
+
case "refreshable":
|
|
2043
|
+
return withEnvironment({ refresh: value }, node);
|
|
2044
|
+
case "submitLabel":
|
|
2045
|
+
return withEnvironment({ submitLabel: value }, node);
|
|
2046
|
+
case "labelStyle":
|
|
2047
|
+
return withEnvironment({ labelStyle: value }, node);
|
|
2048
|
+
case "task": {
|
|
2049
|
+
const spec = typeof value === "function" ? { id: void 0, action: value } : value;
|
|
2050
|
+
sides.push(createElement(Task, spec));
|
|
2051
|
+
return node;
|
|
1794
2052
|
}
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
2053
|
+
case "onChangeOf":
|
|
2054
|
+
sides.push(createElement(OnChange, value));
|
|
2055
|
+
return node;
|
|
2056
|
+
case "scrollID":
|
|
2057
|
+
return createElement(ScrollTarget, { id: value }, node);
|
|
2058
|
+
case "draggable":
|
|
2059
|
+
return createElement(Draggable, { payload: value }, node);
|
|
2060
|
+
case "dropDestination":
|
|
2061
|
+
return createElement(DropDestination, value, node);
|
|
2062
|
+
case "inspector":
|
|
2063
|
+
return createElement(Inspector, value, node);
|
|
2064
|
+
case "onHover":
|
|
2065
|
+
return createElement(Hover, { action: value }, node);
|
|
2066
|
+
case "help":
|
|
2067
|
+
return styled({ help: value }, node);
|
|
2068
|
+
case "pointerStyle":
|
|
2069
|
+
return styled({ pointerStyle: cursorFor(value) }, node);
|
|
2070
|
+
case "symbolEffect":
|
|
2071
|
+
return createElement(SymbolEffect, { spec: value }, node);
|
|
2072
|
+
case "matchedGeometryEffect": {
|
|
2073
|
+
const spec = value;
|
|
2074
|
+
return styled({ matchedGeometry: `${spec.namespace ?? ""}:${spec.id}` }, node);
|
|
1805
2075
|
}
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
2076
|
+
case "layoutValue":
|
|
2077
|
+
return node;
|
|
2078
|
+
case "safeAreaInset": {
|
|
2079
|
+
const spec = value;
|
|
2080
|
+
const vertical = spec.edge === "top" || spec.edge === "bottom";
|
|
2081
|
+
const before = spec.edge === "top" || spec.edge === "leading";
|
|
2082
|
+
const children = before ? [createElement(Fragment, { key: "inset" }, spec.content), createElement(Fragment, { key: "content" }, node)] : [createElement(Fragment, { key: "content" }, node), createElement(Fragment, { key: "inset" }, spec.content)];
|
|
2083
|
+
return vertical ? sb("vstack", { spacing: spec.spacing ?? 0, alignment: spec.alignment ?? "center" }, void 0, children) : sb("hstack", { spacing: spec.spacing ?? 0, alignment: spec.alignment ?? "center" }, void 0, children);
|
|
1809
2084
|
}
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
return;
|
|
2085
|
+
case "popover":
|
|
2086
|
+
sides.push(createElement(SheetPresenter, value));
|
|
2087
|
+
return node;
|
|
2088
|
+
case "redacted":
|
|
2089
|
+
return withEnvironment({ redacted: Boolean(value) }, node);
|
|
2090
|
+
case "keyboardShortcut":
|
|
2091
|
+
return node;
|
|
2092
|
+
case "onKeyPress":
|
|
2093
|
+
sides.push(createElement(KeyPressListener, { spec: value }));
|
|
2094
|
+
return node;
|
|
2095
|
+
case "sensoryFeedback": {
|
|
2096
|
+
const spec = value;
|
|
2097
|
+
sides.push(createElement(SensoryFeedbackPlayer, spec));
|
|
2098
|
+
return node;
|
|
1813
2099
|
}
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
}
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
"grid",
|
|
1853
|
-
{ horizontalSpacing: own.horizontalSpacing ?? null, verticalSpacing: own.verticalSpacing ?? null, alignment: own.alignment ?? "center" },
|
|
1854
|
-
void 0,
|
|
1855
|
-
own.children
|
|
1856
|
-
),
|
|
1857
|
-
modifiers
|
|
1858
|
-
);
|
|
1859
|
-
}
|
|
1860
|
-
function GridRow(props) {
|
|
1861
|
-
const { own, modifiers } = splitProps(props);
|
|
1862
|
-
return applyModifiers(sb("gridrow", { alignment: own.alignment ?? null }, void 0, own.children), modifiers);
|
|
2100
|
+
case "textCase":
|
|
2101
|
+
return withEnvironment({ textCase: value }, node);
|
|
2102
|
+
case "coordinateSpace":
|
|
2103
|
+
return createElement(CoordinateSpace, { name: value }, node);
|
|
2104
|
+
case "scrollEdgeEffectStyle":
|
|
2105
|
+
return withScrollSettings(edgeStyleSettings(value), node);
|
|
2106
|
+
case "scrollEdgeEffectHidden":
|
|
2107
|
+
return withScrollSettings(edgeHiddenSettings(value), node);
|
|
2108
|
+
case "contentMargins":
|
|
2109
|
+
return withScrollSettings(marginSettings(value), node);
|
|
2110
|
+
case "containerRelativeFrame":
|
|
2111
|
+
return styled({ containerRelativeFrame: containerRelativeFrame(value) }, node);
|
|
2112
|
+
case "visualEffect":
|
|
2113
|
+
return createElement(VisualEffectView, { effect: value }, node);
|
|
2114
|
+
case "scrollTransition": {
|
|
2115
|
+
const spec = typeof value === "function" ? { transition: value } : value;
|
|
2116
|
+
return createElement(ScrollTransitionView, { spec }, node);
|
|
2117
|
+
}
|
|
2118
|
+
case "contentTransition": {
|
|
2119
|
+
if (value === "identity") return node;
|
|
2120
|
+
if (typeof value === "object") {
|
|
2121
|
+
const countsDown = value.numericText.countsDown;
|
|
2122
|
+
return styled({ contentTransition: { kind: "numericText", ...countsDown !== void 0 ? { countsDown } : {} } }, node);
|
|
2123
|
+
}
|
|
2124
|
+
return styled({ contentTransition: { kind: value } }, node);
|
|
2125
|
+
}
|
|
2126
|
+
case "modifiers": {
|
|
2127
|
+
let result = node;
|
|
2128
|
+
for (const extra of value) {
|
|
2129
|
+
result = wrap(result, Object.entries(extra), sides);
|
|
2130
|
+
}
|
|
2131
|
+
return result;
|
|
2132
|
+
}
|
|
2133
|
+
default: {
|
|
2134
|
+
const unknown = key;
|
|
2135
|
+
throw new Error(`Unknown modifier ${String(unknown)}`);
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
1863
2138
|
}
|
|
1864
2139
|
const NO_INSETS = { top: 0, leading: 0, bottom: 0, trailing: 0 };
|
|
1865
2140
|
const NO_GEOMETRY = { size: { width: 0, height: 0 }, origin: null, safeArea: NO_INSETS, scrollView: null };
|
|
@@ -2350,140 +2625,6 @@ class Path {
|
|
|
2350
2625
|
return this.svg();
|
|
2351
2626
|
}
|
|
2352
2627
|
}
|
|
2353
|
-
function runStyleOf(props, inherited, nested) {
|
|
2354
|
-
const style = { ...inherited };
|
|
2355
|
-
if (props.italic) style.italic = true;
|
|
2356
|
-
if (props.underline) style.underline = typeof props.underline === "object" && props.underline.color ? { color: color(props.underline.color) } : {};
|
|
2357
|
-
if (props.strikethrough) {
|
|
2358
|
-
style.strikethrough = typeof props.strikethrough === "object" && props.strikethrough.color ? { color: color(props.strikethrough.color) } : {};
|
|
2359
|
-
}
|
|
2360
|
-
const kerning = props.tracking ?? props.kerning;
|
|
2361
|
-
if (kerning !== void 0) style.kerning = kerning;
|
|
2362
|
-
if (props.baselineOffset !== void 0) style.baselineOffset = props.baselineOffset;
|
|
2363
|
-
if (props.link) style.link = props.link;
|
|
2364
|
-
if (nested) {
|
|
2365
|
-
let runFont = props.font !== void 0 ? font(props.font) : void 0;
|
|
2366
|
-
if (props.bold) runFont = { ...runFont ?? {}, weight: "bold" };
|
|
2367
|
-
if (props.fontWeight) runFont = { ...runFont ?? {}, weight: props.fontWeight };
|
|
2368
|
-
if (runFont) style.font = { ...style.font ?? {}, ...runFont };
|
|
2369
|
-
if (props.foregroundStyle !== void 0) style.foreground = shapeStyle(props.foregroundStyle);
|
|
2370
|
-
}
|
|
2371
|
-
return style;
|
|
2372
|
-
}
|
|
2373
|
-
function segmentsOf(children, style, into) {
|
|
2374
|
-
const visit = (node) => {
|
|
2375
|
-
if (node === null || node === void 0 || typeof node === "boolean") return;
|
|
2376
|
-
if (typeof node === "string" || typeof node === "number") {
|
|
2377
|
-
const last = into[into.length - 1];
|
|
2378
|
-
if (last && "text" in last && last.style === style) last.text += String(node);
|
|
2379
|
-
else into.push({ text: String(node), style });
|
|
2380
|
-
return;
|
|
2381
|
-
}
|
|
2382
|
-
if (Array.isArray(node)) {
|
|
2383
|
-
node.forEach(visit);
|
|
2384
|
-
return;
|
|
2385
|
-
}
|
|
2386
|
-
if (!isValidElement(node)) return;
|
|
2387
|
-
const element = node;
|
|
2388
|
-
if (element.type === Fragment$1) {
|
|
2389
|
-
visit(element.props["children"]);
|
|
2390
|
-
return;
|
|
2391
|
-
}
|
|
2392
|
-
if (element.type === Text) {
|
|
2393
|
-
const props = element.props;
|
|
2394
|
-
segmentsOf(props.children, runStyleOf(props, style, true), into);
|
|
2395
|
-
return;
|
|
2396
|
-
}
|
|
2397
|
-
if (element.type === Image$1) {
|
|
2398
|
-
const props = element.props;
|
|
2399
|
-
into.push({ image: imageProps(props), style });
|
|
2400
|
-
return;
|
|
2401
|
-
}
|
|
2402
|
-
};
|
|
2403
|
-
visit(children);
|
|
2404
|
-
}
|
|
2405
|
-
function isPlainStyle(style) {
|
|
2406
|
-
return Object.keys(style).length === 0;
|
|
2407
|
-
}
|
|
2408
|
-
function Text(props) {
|
|
2409
|
-
const { own, modifiers } = splitProps(props);
|
|
2410
|
-
const environment = useViewEnvironment();
|
|
2411
|
-
const style = runStyleOf(props, {}, false);
|
|
2412
|
-
const segments = [];
|
|
2413
|
-
segmentsOf(own.children, style, segments);
|
|
2414
|
-
const textCase = takeModifier(modifiers, "textCase") ?? environment.textCase;
|
|
2415
|
-
if (textCase) {
|
|
2416
|
-
for (const segment of segments) {
|
|
2417
|
-
if ("text" in segment) segment.text = textCase === "uppercase" ? segment.text.toUpperCase() : segment.text.toLowerCase();
|
|
2418
|
-
}
|
|
2419
|
-
}
|
|
2420
|
-
const redacted = takeModifier(modifiers, "redacted") ?? environment.redacted;
|
|
2421
|
-
const content = segments.map((segment) => "text" in segment ? segment.text : "").join("");
|
|
2422
|
-
const plain = segments.length <= 1 && (segments.length === 0 || "text" in segments[0] && isPlainStyle(segments[0].style));
|
|
2423
|
-
if (plain) return applyModifiers(placeholder(sb("text", { text: content }), redacted), modifiers);
|
|
2424
|
-
const runs = segments.map((segment) => {
|
|
2425
|
-
const run = { ...segment.style };
|
|
2426
|
-
if ("text" in segment) run["text"] = segment.text;
|
|
2427
|
-
else run["image"] = segment.image;
|
|
2428
|
-
return run;
|
|
2429
|
-
});
|
|
2430
|
-
const hasLinks = segments.some((segment) => segment.style.link);
|
|
2431
|
-
const handlers = hasLinks ? { link: (event) => openURL(event.value) } : void 0;
|
|
2432
|
-
return applyModifiers(placeholder(sb("text", { text: content, runs }, handlers), redacted), modifiers);
|
|
2433
|
-
}
|
|
2434
|
-
function placeholder(node, redacted) {
|
|
2435
|
-
if (!redacted) return node;
|
|
2436
|
-
return styled({ background: { hierarchical: 3 }, backgroundCornerRadius: 4 }, styled({ foreground: { name: "clear" } }, node));
|
|
2437
|
-
}
|
|
2438
|
-
function openURL(url) {
|
|
2439
|
-
if (typeof window !== "undefined") window.open(url, "_blank", "noopener");
|
|
2440
|
-
}
|
|
2441
|
-
function imageProps(props) {
|
|
2442
|
-
if (props.systemName !== void 0) return { systemName: props.systemName };
|
|
2443
|
-
if (props.url !== void 0) return { url: props.url, resizable: props.resizable ?? false, width: props.width ?? 0, height: props.height ?? 0 };
|
|
2444
|
-
return { name: props.name ?? "", resizable: props.resizable ?? false };
|
|
2445
|
-
}
|
|
2446
|
-
function Image$1(props) {
|
|
2447
|
-
const { modifiers } = splitProps(props);
|
|
2448
|
-
const environment = useViewEnvironment();
|
|
2449
|
-
const redacted = takeModifier(modifiers, "redacted") ?? environment.redacted;
|
|
2450
|
-
return applyModifiers(placeholder(sb("image", imageProps(props)), redacted), modifiers);
|
|
2451
|
-
}
|
|
2452
|
-
function Label(props) {
|
|
2453
|
-
const { own, modifiers } = splitProps(props);
|
|
2454
|
-
const environment = useViewEnvironment();
|
|
2455
|
-
const style = takeModifier(modifiers, "labelStyle") ?? environment.labelStyle ?? "automatic";
|
|
2456
|
-
const icon = own.icon ?? (own.systemImage !== void 0 ? /* @__PURE__ */ jsx(Image$1, { systemName: own.systemImage }) : own.image !== void 0 ? /* @__PURE__ */ jsx(Image$1, { name: own.image }) : null);
|
|
2457
|
-
const title = typeof own.title === "string" || typeof own.title === "number" ? /* @__PURE__ */ jsx(Text, { children: own.title }) : own.title;
|
|
2458
|
-
if (style === "iconOnly") return applyModifiers(icon, modifiers);
|
|
2459
|
-
if (style === "titleOnly") return applyModifiers(title, modifiers);
|
|
2460
|
-
return applyModifiers(
|
|
2461
|
-
/* @__PURE__ */ jsxs(HStack, { spacing: 8, children: [
|
|
2462
|
-
styled({ labelIcon: true }, icon),
|
|
2463
|
-
title
|
|
2464
|
-
] }),
|
|
2465
|
-
modifiers
|
|
2466
|
-
);
|
|
2467
|
-
}
|
|
2468
|
-
function LabeledContent(props) {
|
|
2469
|
-
const { own, modifiers } = splitProps(props);
|
|
2470
|
-
const label = typeof own.label === "string" || typeof own.label === "number" ? /* @__PURE__ */ jsx(Text, { children: own.label }) : own.label;
|
|
2471
|
-
const content = own.children ?? own.value;
|
|
2472
|
-
const value = typeof content === "string" || typeof content === "number" ? /* @__PURE__ */ jsx(Text, { children: content }) : content;
|
|
2473
|
-
return applyModifiers(
|
|
2474
|
-
/* @__PURE__ */ jsxs(HStack, { children: [
|
|
2475
|
-
label,
|
|
2476
|
-
sb("spacer", { minLength: null }),
|
|
2477
|
-
styled({ foreground: { hierarchical: 2 } }, value)
|
|
2478
|
-
] }),
|
|
2479
|
-
modifiers
|
|
2480
|
-
);
|
|
2481
|
-
}
|
|
2482
|
-
function Link(props) {
|
|
2483
|
-
const { own, modifiers } = splitProps(props);
|
|
2484
|
-
const label = own.title !== void 0 ? /* @__PURE__ */ jsx(Text, { children: own.title }) : own.children;
|
|
2485
|
-
return applyModifiers(sb("button", { role: null, style: "automatic" }, { tap: () => openURL(own.destination) }, label), modifiers);
|
|
2486
|
-
}
|
|
2487
2628
|
function Button(props) {
|
|
2488
2629
|
const { own, modifiers } = splitProps(props);
|
|
2489
2630
|
const environment = useViewEnvironment();
|
|
@@ -2554,7 +2695,7 @@ function collectText(node) {
|
|
|
2554
2695
|
if (Array.isArray(node)) return node.map(collectText).join("");
|
|
2555
2696
|
if (typeof node === "object" && "props" in node) {
|
|
2556
2697
|
const element = node;
|
|
2557
|
-
if (element.type === Fragment
|
|
2698
|
+
if (element.type === Fragment || element.type === Text) return collectText(element.props.children);
|
|
2558
2699
|
}
|
|
2559
2700
|
return "";
|
|
2560
2701
|
}
|
|
@@ -2567,11 +2708,11 @@ function Slider(props) {
|
|
|
2567
2708
|
const children = [];
|
|
2568
2709
|
if (own.label !== void 0 && !environment.labelsHidden) {
|
|
2569
2710
|
labels.push("label");
|
|
2570
|
-
children.push(/* @__PURE__ */ jsx(Fragment
|
|
2711
|
+
children.push(/* @__PURE__ */ jsx(Fragment, { children: own.label }, "label"));
|
|
2571
2712
|
}
|
|
2572
2713
|
if (own.minimumValueLabel !== void 0 || own.maximumValueLabel !== void 0) {
|
|
2573
2714
|
labels.push("min", "max");
|
|
2574
|
-
children.push(/* @__PURE__ */ jsx(Fragment
|
|
2715
|
+
children.push(/* @__PURE__ */ jsx(Fragment, { children: own.minimumValueLabel }, "min"), /* @__PURE__ */ jsx(Fragment, { children: own.maximumValueLabel }, "max"));
|
|
2575
2716
|
}
|
|
2576
2717
|
return applyModifiers(
|
|
2577
2718
|
sb("slider", { value, min, max, step: own.step ?? null, labels }, { slide: (event) => setValue(event.value) }, children.length ? children : void 0),
|
|
@@ -2633,9 +2774,9 @@ function ProgressView(props) {
|
|
|
2633
2774
|
}
|
|
2634
2775
|
const label = own.label ?? own.children;
|
|
2635
2776
|
const children = [];
|
|
2636
|
-
if (label !== void 0 && label !== null) children.push(/* @__PURE__ */ jsx(Fragment
|
|
2777
|
+
if (label !== void 0 && label !== null) children.push(/* @__PURE__ */ jsx(Fragment, { children: label }, "label"));
|
|
2637
2778
|
if (own.currentValueLabel !== void 0 && own.currentValueLabel !== null) {
|
|
2638
|
-
children.push(/* @__PURE__ */ jsx(Fragment
|
|
2779
|
+
children.push(/* @__PURE__ */ jsx(Fragment, { children: styled({ foreground: { hierarchical: 2 } }, own.currentValueLabel) }, "current"));
|
|
2639
2780
|
}
|
|
2640
2781
|
return applyModifiers(
|
|
2641
2782
|
sb(
|
|
@@ -2681,127 +2822,6 @@ function TextEditor(props) {
|
|
|
2681
2822
|
function buttonDisabled(modifiers) {
|
|
2682
2823
|
return modifiers.some(([key, value]) => key === "disabled" && value === true);
|
|
2683
2824
|
}
|
|
2684
|
-
const isPushedView = (value) => typeof value === "object" && value !== null && "view" in value && Object.keys(value).length === 1;
|
|
2685
|
-
function NavigationStack(props) {
|
|
2686
|
-
const enclosing = useNavigation();
|
|
2687
|
-
if (enclosing) return /* @__PURE__ */ jsx(FlattenedStack, { ...props });
|
|
2688
|
-
return /* @__PURE__ */ jsx(OwnStack, { ...props });
|
|
2689
|
-
}
|
|
2690
|
-
function FlattenedStack(props) {
|
|
2691
|
-
const { own, modifiers } = splitProps(props);
|
|
2692
|
-
return applyModifiers(
|
|
2693
|
-
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2694
|
-
own.destination && /* @__PURE__ */ jsx(RegisterDestination, { destination: own.destination }),
|
|
2695
|
-
own.children
|
|
2696
|
-
] }),
|
|
2697
|
-
modifiers
|
|
2698
|
-
);
|
|
2699
|
-
}
|
|
2700
|
-
function OwnStack(props) {
|
|
2701
|
-
const { own, modifiers } = splitProps(props);
|
|
2702
|
-
const [internalPath, setInternalPath] = useState([]);
|
|
2703
|
-
const [path, setPath] = own.path !== void 0 ? readBinding(own.path, own.onPathChange) : [internalPath, setInternalPath];
|
|
2704
|
-
const destination = useRef(null);
|
|
2705
|
-
destination.current = own.destination ?? null;
|
|
2706
|
-
const context = {
|
|
2707
|
-
push: (value) => setPath([...path, value]),
|
|
2708
|
-
pop: () => setPath(path.slice(0, -1)),
|
|
2709
|
-
registerDestination: (builder) => {
|
|
2710
|
-
destination.current = builder;
|
|
2711
|
-
}
|
|
2712
|
-
};
|
|
2713
|
-
const screens = [
|
|
2714
|
-
/* @__PURE__ */ jsx(Fragment$1, { children: sb("navscreen", { title: "", displayMode: "automatic", depth: 0 }, { tap: context.pop }, own.children) }, "root")
|
|
2715
|
-
];
|
|
2716
|
-
path.forEach((value, index) => {
|
|
2717
|
-
const pop = () => setPath(path.slice(0, index));
|
|
2718
|
-
screens.push(
|
|
2719
|
-
/* @__PURE__ */ jsx(Fragment$1, { children: sb(
|
|
2720
|
-
"navscreen",
|
|
2721
|
-
{ title: "", displayMode: "automatic", depth: index + 1 },
|
|
2722
|
-
{ tap: pop },
|
|
2723
|
-
/* @__PURE__ */ jsx(DismissContext.Provider, { value: pop, children: /* @__PURE__ */ jsx(PathScreen, { value, destination }) })
|
|
2724
|
-
) }, index + 1)
|
|
2725
|
-
);
|
|
2726
|
-
});
|
|
2727
|
-
return applyModifiers(
|
|
2728
|
-
sb("navstack", {}, void 0, /* @__PURE__ */ jsx(NavigationContext.Provider, { value: context, children: screens })),
|
|
2729
|
-
modifiers
|
|
2730
|
-
);
|
|
2731
|
-
}
|
|
2732
|
-
function PathScreen({ value, destination }) {
|
|
2733
|
-
if (isPushedView(value)) return value.view;
|
|
2734
|
-
return destination.current ? destination.current(value) : null;
|
|
2735
|
-
}
|
|
2736
|
-
function NavigationLink(props) {
|
|
2737
|
-
const { own, modifiers } = splitProps(props);
|
|
2738
|
-
const navigation = useNavigation();
|
|
2739
|
-
const label = own.title !== void 0 ? /* @__PURE__ */ jsx(Text, { children: own.title }) : own.children;
|
|
2740
|
-
const tap = () => {
|
|
2741
|
-
if (!navigation) return;
|
|
2742
|
-
if (own.destination !== void 0) navigation.push({ view: own.destination });
|
|
2743
|
-
else navigation.push(own.value);
|
|
2744
|
-
};
|
|
2745
|
-
return applyModifiers(sb("navlink", {}, { tap }, label), modifiers);
|
|
2746
|
-
}
|
|
2747
|
-
const SplitSelectionContext = createContext(null);
|
|
2748
|
-
function NavigationSplitView(props) {
|
|
2749
|
-
const { own, modifiers } = splitProps(props);
|
|
2750
|
-
const sizeClass = useHorizontalSizeClass();
|
|
2751
|
-
const [selected, setSelected] = useState(false);
|
|
2752
|
-
const clearRef = useRef(() => {
|
|
2753
|
-
});
|
|
2754
|
-
const report = {
|
|
2755
|
-
report: (nowSelected, clear2) => {
|
|
2756
|
-
clearRef.current = clear2;
|
|
2757
|
-
if (nowSelected !== selected) setSelected(nowSelected);
|
|
2758
|
-
}
|
|
2759
|
-
};
|
|
2760
|
-
const clear = () => clearRef.current();
|
|
2761
|
-
const [internal, setInternal] = useState("automatic");
|
|
2762
|
-
const [visibility, setVisibility] = own.columnVisibility !== void 0 ? readBinding(own.columnVisibility, own.onColumnVisibilityChange) : [internal, setInternal];
|
|
2763
|
-
if (sizeClass === "compact") {
|
|
2764
|
-
return applyModifiers(
|
|
2765
|
-
/* @__PURE__ */ jsx(SplitSelectionContext.Provider, { value: report, children: /* @__PURE__ */ jsx(CompactSplit, { sidebar: own.sidebar, detail: own.detail, selected, clear }) }),
|
|
2766
|
-
modifiers
|
|
2767
|
-
);
|
|
2768
|
-
}
|
|
2769
|
-
const sidebarVisible = visibility !== "detailOnly";
|
|
2770
|
-
const toggle = () => withAnimation(() => setVisibility(sidebarVisible ? "detailOnly" : "all"));
|
|
2771
|
-
const detail = isValidElement(own.detail) && own.detail.type === NavigationStack ? own.detail : /* @__PURE__ */ jsx(NavigationStack, { children: own.detail });
|
|
2772
|
-
return applyModifiers(
|
|
2773
|
-
sb("navsplit", { sidebarVisible }, { tap: toggle }, [
|
|
2774
|
-
/* @__PURE__ */ jsx(SplitColumn, { report, children: /* @__PURE__ */ jsx(NavigationStack, { children: own.sidebar }) }, "sidebar"),
|
|
2775
|
-
/* @__PURE__ */ jsx(SplitColumn, { report: null, children: detail }, "detail")
|
|
2776
|
-
]),
|
|
2777
|
-
modifiers
|
|
2778
|
-
);
|
|
2779
|
-
}
|
|
2780
|
-
function SplitColumn({ report, children }) {
|
|
2781
|
-
return /* @__PURE__ */ jsx(NavigationContext.Provider, { value: null, children: /* @__PURE__ */ jsx(SplitSelectionContext.Provider, { value: report, children }) });
|
|
2782
|
-
}
|
|
2783
|
-
function CompactSplit({ sidebar, detail, selected, clear }) {
|
|
2784
|
-
const [extra, setExtra] = useState([]);
|
|
2785
|
-
const base = selected ? [{ view: /* @__PURE__ */ jsx(DetailScope, { children: detail }) }] : [];
|
|
2786
|
-
const path = [...base, ...extra];
|
|
2787
|
-
const setPath = (next) => {
|
|
2788
|
-
if (selected && next.length === 0) {
|
|
2789
|
-
setExtra([]);
|
|
2790
|
-
clear();
|
|
2791
|
-
return;
|
|
2792
|
-
}
|
|
2793
|
-
setExtra(next.slice(base.length));
|
|
2794
|
-
};
|
|
2795
|
-
return /* @__PURE__ */ jsx(NavigationContext.Provider, { value: null, children: /* @__PURE__ */ jsx(NavigationStack, { path: [path, setPath], children: sidebar }) });
|
|
2796
|
-
}
|
|
2797
|
-
function DetailScope({ children }) {
|
|
2798
|
-
return /* @__PURE__ */ jsx(SplitSelectionContext.Provider, { value: null, children });
|
|
2799
|
-
}
|
|
2800
|
-
function useReportSplitSelection(split, selected, clear) {
|
|
2801
|
-
useLayoutEffect(() => {
|
|
2802
|
-
split?.report(selected, clear);
|
|
2803
|
-
});
|
|
2804
|
-
}
|
|
2805
2825
|
const NO_CLEAR = () => {
|
|
2806
2826
|
};
|
|
2807
2827
|
function List(props) {
|
|
@@ -2832,7 +2852,7 @@ function List(props) {
|
|
|
2832
2852
|
}
|
|
2833
2853
|
};
|
|
2834
2854
|
}
|
|
2835
|
-
useReportSplitSelection(split, selected, clearSelection);
|
|
2855
|
+
useReportSplitSelection(split, selected, clearSelection, own.selection !== void 0);
|
|
2836
2856
|
const refresh = useRefreshable(takeModifier(modifiers, "refreshable"));
|
|
2837
2857
|
Object.assign(listProps, refresh.props);
|
|
2838
2858
|
const ownSettings = takeScrollSettings(modifiers);
|
|
@@ -3066,8 +3086,8 @@ function Menu(props) {
|
|
|
3066
3086
|
const label = own.title !== void 0 ? /* @__PURE__ */ jsx(Text, { children: own.title }) : own.label;
|
|
3067
3087
|
return applyModifiers(
|
|
3068
3088
|
sb("menu", {}, void 0, [
|
|
3069
|
-
/* @__PURE__ */ jsx(Fragment
|
|
3070
|
-
/* @__PURE__ */ jsx(Fragment
|
|
3089
|
+
/* @__PURE__ */ jsx(Fragment, { children: sb("zstack", { alignment: "center" }, void 0, label) }, "label"),
|
|
3090
|
+
/* @__PURE__ */ jsx(Fragment, { children: own.children }, "items")
|
|
3071
3091
|
]),
|
|
3072
3092
|
modifiers
|
|
3073
3093
|
);
|
|
@@ -3354,7 +3374,7 @@ function Chart(props) {
|
|
|
3354
3374
|
const annotation = mark.props.annotation;
|
|
3355
3375
|
if (!annotation) return;
|
|
3356
3376
|
items.push(
|
|
3357
|
-
/* @__PURE__ */ jsx(Fragment
|
|
3377
|
+
/* @__PURE__ */ jsx(Fragment, { children: sb(
|
|
3358
3378
|
"chartitem",
|
|
3359
3379
|
{
|
|
3360
3380
|
role: "annotation",
|
|
@@ -3492,8 +3512,8 @@ function Gauge(props) {
|
|
|
3492
3512
|
const value = (own.value - min) / (max - min || 1);
|
|
3493
3513
|
const children = [];
|
|
3494
3514
|
const asView = (node) => typeof node === "string" || typeof node === "number" ? /* @__PURE__ */ jsx(Text, { children: node }) : node;
|
|
3495
|
-
if (own.label !== void 0) children.push(/* @__PURE__ */ jsx(Fragment
|
|
3496
|
-
if (own.currentValueLabel !== void 0) children.push(/* @__PURE__ */ jsx(Fragment
|
|
3515
|
+
if (own.label !== void 0) children.push(/* @__PURE__ */ jsx(Fragment, { children: asView(own.label) }, "label"));
|
|
3516
|
+
if (own.currentValueLabel !== void 0) children.push(/* @__PURE__ */ jsx(Fragment, { children: asView(own.currentValueLabel) }, "current"));
|
|
3497
3517
|
return applyModifiers(
|
|
3498
3518
|
sb(
|
|
3499
3519
|
"gauge",
|
|
@@ -3567,7 +3587,7 @@ function GroupBox(props) {
|
|
|
3567
3587
|
}
|
|
3568
3588
|
function ControlGroup(props) {
|
|
3569
3589
|
const { own, modifiers } = splitProps(props);
|
|
3570
|
-
return modifiers.length ? applyModifiers(/* @__PURE__ */ jsx(Fragment, { children: own.children }), modifiers) : own.children;
|
|
3590
|
+
return modifiers.length ? applyModifiers(/* @__PURE__ */ jsx(Fragment$1, { children: own.children }), modifiers) : own.children;
|
|
3571
3591
|
}
|
|
3572
3592
|
function DisclosureGroup(props) {
|
|
3573
3593
|
const { own, modifiers } = splitProps(props);
|
|
@@ -3901,10 +3921,10 @@ function Canvas(props) {
|
|
|
3901
3921
|
if (draw.scale.x !== 1 || draw.scale.y !== 1) view = styled({ scale: draw.scale }, view);
|
|
3902
3922
|
if (Math.abs(draw.rotation) > 1e-6) view = styled({ rotation: draw.rotation }, view);
|
|
3903
3923
|
if (draw.opacity !== 1) view = styled({ opacity: draw.opacity }, view);
|
|
3904
|
-
return /* @__PURE__ */ jsx(Fragment
|
|
3924
|
+
return /* @__PURE__ */ jsx(Fragment, { children: styled({ position: { x: draw.x, y: draw.y } }, view) }, index);
|
|
3905
3925
|
});
|
|
3906
3926
|
return applyModifiers(
|
|
3907
|
-
sb("zstack", { alignment: "topLeading" }, void 0, [/* @__PURE__ */ jsx(Fragment
|
|
3927
|
+
sb("zstack", { alignment: "topLeading" }, void 0, [/* @__PURE__ */ jsx(Fragment, { children: reader }, "canvas"), ...symbols]),
|
|
3908
3928
|
modifiers
|
|
3909
3929
|
);
|
|
3910
3930
|
}
|
|
@@ -4122,7 +4142,7 @@ function VideoPlayer(props) {
|
|
|
4122
4142
|
);
|
|
4123
4143
|
if (own.videoOverlay === void 0) return applyModifiers(video, modifiers);
|
|
4124
4144
|
return applyModifiers(
|
|
4125
|
-
sb("zstack", { alignment: "center" }, void 0, [/* @__PURE__ */ jsx(Fragment
|
|
4145
|
+
sb("zstack", { alignment: "center" }, void 0, [/* @__PURE__ */ jsx(Fragment, { children: video }, "video"), /* @__PURE__ */ jsx(Fragment, { children: own.videoOverlay }, "overlay")]),
|
|
4126
4146
|
modifiers
|
|
4127
4147
|
);
|
|
4128
4148
|
}
|
|
@@ -4295,6 +4315,7 @@ export {
|
|
|
4295
4315
|
NavigationLink,
|
|
4296
4316
|
NavigationSplitView,
|
|
4297
4317
|
NavigationStack,
|
|
4318
|
+
OutsideSplit,
|
|
4298
4319
|
Path,
|
|
4299
4320
|
PhaseAnimator,
|
|
4300
4321
|
Picker,
|