@swiftbrowser/react 0.9.7 → 0.9.9
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 +13 -0
- package/dist/components/stacks.d.ts +9 -0
- package/dist/components/stacks.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +76 -32
- package/dist/index.js.map +1 -1
- package/dist/island.d.ts +10 -1
- package/dist/island.d.ts.map +1 -1
- package/dist/mount.d.ts +8 -0
- package/dist/mount.d.ts.map +1 -1
- package/dist/scrollReader.d.ts +29 -3
- package/dist/scrollReader.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -231,6 +231,13 @@ forward selects the row the entry recorded, through the row's own tap. The
|
|
|
231
231
|
URL is left alone: an app that maps screens to paths sets them with
|
|
232
232
|
`history.replaceState` on the entry the renderer made (a `pushState` of its
|
|
233
233
|
own would add a second entry for the same screen).
|
|
234
|
+
On a phone, a `fill` island follows the on-screen keyboard (`keyboard`,
|
|
235
|
+
on by default for `fill`, or `mount(..., { keyboard: true })`): its height
|
|
236
|
+
becomes a bottom inset, so a field, a bottom search field or a chat's
|
|
237
|
+
composer rises above it and a list stops above it, as on iOS, instead of
|
|
238
|
+
the browser panning the page to the field. A `content` island leaves the
|
|
239
|
+
page to the browser.
|
|
240
|
+
|
|
234
241
|
`<SwiftUIView history={false}>` (or `mount(..., { history: false })`) leaves
|
|
235
242
|
the history untouched, for an island in a page whose own router owns it.
|
|
236
243
|
|
|
@@ -320,6 +327,12 @@ opens it at its end and keeps the end in view as content is added while
|
|
|
320
327
|
the viewer is there (a chat); a viewer who scrolled up is left where they
|
|
321
328
|
are. `scrollTargetBehavior="paging"` or `"viewAligned"` on
|
|
322
329
|
a `ScrollView` snaps, with `scrollTargetLayout` on the stack inside.
|
|
330
|
+
`scrollPosition={[id, setId]}` on a `ScrollView` is `.scrollPosition(id:)`:
|
|
331
|
+
when scrolling settles it is set to the `scrollID` of the view at the
|
|
332
|
+
scroll view's leading edge (or `scrollPositionAnchor`), and setting it
|
|
333
|
+
scrolls there, on that scroll view's axes only. `proxy.scrollTo(id, anchor,
|
|
334
|
+
{ axes: 'horizontal' })` limits a reader's scroll the same way, so a pager
|
|
335
|
+
inside a list leaves the list where it is.
|
|
323
336
|
Name a coordinate space with `coordinateSpace="page"` on the `ScrollView`
|
|
324
337
|
(or any view), and a `GeometryReader` inside reads its frame there with
|
|
325
338
|
`proxy.frame({ named: 'page' })`, updated as the page scrolls.
|
|
@@ -3,6 +3,8 @@ import { type Key, type ReactElement, type ReactNode } from 'react';
|
|
|
3
3
|
import type { EventHandlers } from '../host/instance';
|
|
4
4
|
import { type ModifierEntry, type ViewModifiers } from '../modifiers';
|
|
5
5
|
import { type UnitPointValue } from '../values';
|
|
6
|
+
import { type ScrollPositionValue } from '../scrollReader';
|
|
7
|
+
import type { BindingValue } from '../binding';
|
|
6
8
|
import { type ScrollSettings } from '../scrollEnvironment';
|
|
7
9
|
export interface VStackProps extends ViewModifiers {
|
|
8
10
|
alignment?: VStackAlignment;
|
|
@@ -41,6 +43,13 @@ export interface ScrollViewProps extends ViewModifiers {
|
|
|
41
43
|
* a viewer who scrolled away is left where they are.
|
|
42
44
|
*/
|
|
43
45
|
defaultScrollAnchor?: UnitPointValue;
|
|
46
|
+
/**
|
|
47
|
+
* `.scrollPosition(id:anchor:)`: the `scrollID` of the view at the anchor
|
|
48
|
+
* (the leading edge unless `scrollPositionAnchor` says otherwise), set
|
|
49
|
+
* when scrolling settles; setting it scrolls there.
|
|
50
|
+
*/
|
|
51
|
+
scrollPosition?: BindingValue<ScrollPositionValue>;
|
|
52
|
+
scrollPositionAnchor?: UnitPointValue;
|
|
44
53
|
children?: ReactNode;
|
|
45
54
|
}
|
|
46
55
|
export declare function ScrollView(props: ScrollViewProps): ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stacks.d.ts","sourceRoot":"","sources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,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAWhD;AAED,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,SAAS,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,CAGtD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type { ContentMarginsValue, ScrollEdgeEffectHiddenValue, ScrollEdgeEffect
|
|
|
17
17
|
export type { SheetModifier, AlertModifier, DetentValue } from './presentation';
|
|
18
18
|
export * from './values';
|
|
19
19
|
export { Path, type CGRect, type Point } from './path';
|
|
20
|
-
export { ScrollViewReader, type ScrollViewProxy } from './scrollReader';
|
|
20
|
+
export { ScrollViewReader, type ScrollViewProxy, type ScrollPositionValue } from './scrollReader';
|
|
21
21
|
export { useCoordinateSpaces } from './coordinateSpace';
|
|
22
22
|
export * from './components/stacks';
|
|
23
23
|
export * from './components/text';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,EAAE,KAAK,OAAO,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EACL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eAAe,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAClG,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACtD,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,KAAK,gBAAgB,EAAE,KAAK,aAAa,EAAE,KAAK,QAAQ,EAAE,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ 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 { BrowserHistory } from "@swiftbrowser/web/src/browserHistory";
|
|
6
|
+
import { watchKeyboard } from "@swiftbrowser/web/src/deviceMode";
|
|
6
7
|
import { Renderer } from "@swiftbrowser/web/src/renderer";
|
|
7
8
|
import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
|
|
8
9
|
import { applyTypeSizeVariables } from "@swiftbrowser/web/src/typography";
|
|
@@ -442,6 +443,7 @@ function mount(screen, element, options = {}) {
|
|
|
442
443
|
root.setEnvironment(environment);
|
|
443
444
|
const browserHistory = (options.history ?? true) && typeof window !== "undefined" ? new BrowserHistory(renderer, screen) : null;
|
|
444
445
|
browserHistory?.enable();
|
|
446
|
+
const stopKeyboard = options.keyboard && typeof window !== "undefined" ? watchKeyboard((height) => renderer?.setKeyboard(height), { root: screen }) : null;
|
|
445
447
|
const applyScheme = () => {
|
|
446
448
|
const scheme = preferred ?? pageScheme;
|
|
447
449
|
const device = screen.closest(".device");
|
|
@@ -475,6 +477,7 @@ function mount(screen, element, options = {}) {
|
|
|
475
477
|
},
|
|
476
478
|
unmount() {
|
|
477
479
|
observer?.disconnect();
|
|
480
|
+
stopKeyboard?.();
|
|
478
481
|
browserHistory?.dispose();
|
|
479
482
|
screen.removeEventListener("sb:color-scheme", onPreferredScheme);
|
|
480
483
|
root.unmount();
|
|
@@ -518,6 +521,7 @@ function SwiftUIView({
|
|
|
518
521
|
assets,
|
|
519
522
|
safeArea,
|
|
520
523
|
history = true,
|
|
524
|
+
keyboard = fit === "fill",
|
|
521
525
|
className,
|
|
522
526
|
style
|
|
523
527
|
}) {
|
|
@@ -536,6 +540,7 @@ function SwiftUIView({
|
|
|
536
540
|
safeArea: insetsOf(safeArea, fit),
|
|
537
541
|
contentHeight: fit === "content",
|
|
538
542
|
history,
|
|
543
|
+
keyboard,
|
|
539
544
|
...assets ? { assets } : {}
|
|
540
545
|
});
|
|
541
546
|
mounted.current = instance;
|
|
@@ -543,7 +548,7 @@ function SwiftUIView({
|
|
|
543
548
|
mounted.current = null;
|
|
544
549
|
instance.unmount();
|
|
545
550
|
};
|
|
546
|
-
}, [fit, history]);
|
|
551
|
+
}, [fit, history, keyboard]);
|
|
547
552
|
useLayoutEffect(() => {
|
|
548
553
|
mounted.current?.root.render(tree);
|
|
549
554
|
});
|
|
@@ -792,6 +797,56 @@ function insets(edges, amount) {
|
|
|
792
797
|
}
|
|
793
798
|
return result;
|
|
794
799
|
}
|
|
800
|
+
function command(request) {
|
|
801
|
+
return request.axes ? { anchor: request.anchor, serial: request.serial, axes: request.axes } : { anchor: request.anchor, serial: request.serial };
|
|
802
|
+
}
|
|
803
|
+
const ScrollRequestContext = createContext(null);
|
|
804
|
+
let nextSerial = 1;
|
|
805
|
+
function ScrollViewReader({ children }) {
|
|
806
|
+
const [request, setRequest] = useState(null);
|
|
807
|
+
const proxy = {
|
|
808
|
+
scrollTo: (id, anchor, options) => setRequest({ id, anchor: anchor === void 0 ? null : unitPoint(anchor), serial: nextSerial++, ...options?.axes ? { axes: options.axes } : {} })
|
|
809
|
+
};
|
|
810
|
+
return /* @__PURE__ */ jsx(ScrollRequestContext.Provider, { value: request, children: children(proxy) });
|
|
811
|
+
}
|
|
812
|
+
function ScrollTarget({ id, children }) {
|
|
813
|
+
const request = useContext(ScrollRequestContext);
|
|
814
|
+
const position = useContext(ScrollPositionContext);
|
|
815
|
+
const on = position ? { scrollposition: () => position.report(id) } : void 0;
|
|
816
|
+
if (request && request.id === id) return sb("styled", { style: { scrollID: true, scrollTo: command(request) } }, on, children);
|
|
817
|
+
if (on) return sb("styled", { style: { scrollID: true } }, on, children);
|
|
818
|
+
return styled({ scrollID: true }, children);
|
|
819
|
+
}
|
|
820
|
+
const ScrollPositionContext = createContext(null);
|
|
821
|
+
function useScrollPosition(binding, anchor, axes) {
|
|
822
|
+
const bound = binding !== void 0;
|
|
823
|
+
const [value, set] = bound ? readBinding(binding) : [null, () => void 0];
|
|
824
|
+
const last = useRef(void 0);
|
|
825
|
+
const reported = useRef(void 0);
|
|
826
|
+
const request = useRef(null);
|
|
827
|
+
const outer = useContext(ScrollRequestContext);
|
|
828
|
+
const point = anchor === void 0 ? null : unitPoint(anchor);
|
|
829
|
+
if (value !== last.current) {
|
|
830
|
+
last.current = value;
|
|
831
|
+
if (value !== null && value !== reported.current) request.current = { id: value, anchor: point, serial: nextSerial++, axes };
|
|
832
|
+
reported.current = void 0;
|
|
833
|
+
}
|
|
834
|
+
if (!bound) return null;
|
|
835
|
+
const props = { reportsPosition: true };
|
|
836
|
+
if (point) props["positionAnchor"] = point;
|
|
837
|
+
const own = request.current;
|
|
838
|
+
const current = own && (!outer || own.serial > outer.serial) ? own : outer;
|
|
839
|
+
const context = {
|
|
840
|
+
report: (id) => {
|
|
841
|
+
reported.current = id;
|
|
842
|
+
set(id);
|
|
843
|
+
}
|
|
844
|
+
};
|
|
845
|
+
return {
|
|
846
|
+
props,
|
|
847
|
+
provide: (children) => /* @__PURE__ */ jsx(ScrollPositionContext.Provider, { value: context, children: /* @__PURE__ */ jsx(ScrollRequestContext.Provider, { value: current, children }) })
|
|
848
|
+
};
|
|
849
|
+
}
|
|
795
850
|
const ScrollSettingsContext = createContext({});
|
|
796
851
|
function edgesOf(edges) {
|
|
797
852
|
const list = Array.isArray(edges) ? edges : [edges];
|
|
@@ -878,20 +933,6 @@ function Row({ tag, onDelete, deletable, onMove, movable, index, containerIndex,
|
|
|
878
933
|
children
|
|
879
934
|
);
|
|
880
935
|
}
|
|
881
|
-
const ScrollRequestContext = createContext(null);
|
|
882
|
-
let nextSerial = 1;
|
|
883
|
-
function ScrollViewReader({ children }) {
|
|
884
|
-
const [request, setRequest] = useState(null);
|
|
885
|
-
const proxy = {
|
|
886
|
-
scrollTo: (id, anchor) => setRequest({ id, anchor: anchor === void 0 ? null : unitPoint(anchor), serial: nextSerial++ })
|
|
887
|
-
};
|
|
888
|
-
return /* @__PURE__ */ jsx(ScrollRequestContext.Provider, { value: request, children: children(proxy) });
|
|
889
|
-
}
|
|
890
|
-
function ScrollTarget({ id, children }) {
|
|
891
|
-
const request = useContext(ScrollRequestContext);
|
|
892
|
-
if (request && request.id === id) return styled({ scrollID: true, scrollTo: { anchor: request.anchor, serial: request.serial } }, children);
|
|
893
|
-
return styled({ scrollID: true }, children);
|
|
894
|
-
}
|
|
895
936
|
const LAZY_BATCH = 12;
|
|
896
937
|
const LazyContext = createContext(null);
|
|
897
938
|
function LazyGroup({ rows, start = 0, wrap: wrap2 }) {
|
|
@@ -964,8 +1005,11 @@ function ScrollView(props) {
|
|
|
964
1005
|
if (own.defaultScrollAnchor !== void 0) scroll["defaultScrollAnchor"] = unitPoint(own.defaultScrollAnchor);
|
|
965
1006
|
const edgeEffect = edgeEffectProp(settings);
|
|
966
1007
|
if (edgeEffect) scroll["edgeEffect"] = edgeEffect;
|
|
1008
|
+
const position = useScrollPosition(own.scrollPosition, own.scrollPositionAnchor, axes);
|
|
1009
|
+
if (position) Object.assign(scroll, position.props);
|
|
967
1010
|
const content = marginedContent(own.children, settings.margins, axes === "horizontal" ? "horizontal" : "vertical");
|
|
968
|
-
|
|
1011
|
+
const inner = providingScrollSettings(ownSettings, content);
|
|
1012
|
+
return applyModifiers(sb("scrollview", scroll, refresh.handlers, position ? position.provide(inner) : inner), modifiers);
|
|
969
1013
|
}
|
|
970
1014
|
function takeScrollSettings(modifiers) {
|
|
971
1015
|
let settings = {};
|
|
@@ -1555,9 +1599,9 @@ function matchesKey(event, key) {
|
|
|
1555
1599
|
function matchesShortcut(event, shortcut) {
|
|
1556
1600
|
if (!matchesKey(event, shortcut.key)) return false;
|
|
1557
1601
|
const wanted = new Set(shortcut.modifiers ?? ["command"]);
|
|
1558
|
-
const
|
|
1602
|
+
const command2 = isApple() ? event.metaKey : event.ctrlKey;
|
|
1559
1603
|
const control = isApple() ? event.ctrlKey : false;
|
|
1560
|
-
return
|
|
1604
|
+
return command2 === wanted.has("command") && event.shiftKey === wanted.has("shift") && event.altKey === wanted.has("option") && control === (isApple() && wanted.has("control"));
|
|
1561
1605
|
}
|
|
1562
1606
|
function useKeyboardShortcut(shortcut, action) {
|
|
1563
1607
|
const latest = useRef(action);
|
|
@@ -4022,18 +4066,18 @@ class GraphicsContext {
|
|
|
4022
4066
|
}
|
|
4023
4067
|
stroke(path, with_, options = {}) {
|
|
4024
4068
|
const o = typeof options === "number" ? { lineWidth: options } : options;
|
|
4025
|
-
const
|
|
4026
|
-
if (o.lineCap)
|
|
4027
|
-
if (o.lineJoin)
|
|
4028
|
-
if (o.miterLimit !== void 0)
|
|
4029
|
-
if (o.dash)
|
|
4030
|
-
if (o.dashPhase !== void 0)
|
|
4031
|
-
this.push(
|
|
4069
|
+
const command2 = { op: "stroke", path: path.svg(), shading: shading(with_), lineWidth: o.lineWidth ?? 1 };
|
|
4070
|
+
if (o.lineCap) command2.lineCap = o.lineCap;
|
|
4071
|
+
if (o.lineJoin) command2.lineJoin = o.lineJoin;
|
|
4072
|
+
if (o.miterLimit !== void 0) command2.miterLimit = o.miterLimit;
|
|
4073
|
+
if (o.dash) command2.dash = o.dash;
|
|
4074
|
+
if (o.dashPhase !== void 0) command2.dashPhase = o.dashPhase;
|
|
4075
|
+
this.push(command2);
|
|
4032
4076
|
return this;
|
|
4033
4077
|
}
|
|
4034
4078
|
/** `draw(Text(...), at:anchor:)` */
|
|
4035
4079
|
drawText(text, at, options = {}) {
|
|
4036
|
-
const
|
|
4080
|
+
const command2 = {
|
|
4037
4081
|
op: "text",
|
|
4038
4082
|
text,
|
|
4039
4083
|
x: at.x,
|
|
@@ -4041,14 +4085,14 @@ class GraphicsContext {
|
|
|
4041
4085
|
anchor: unitPoint(options.anchor ?? "center"),
|
|
4042
4086
|
shading: shading(options.color ?? "primary")
|
|
4043
4087
|
};
|
|
4044
|
-
if (options.font !== void 0)
|
|
4045
|
-
this.push(
|
|
4088
|
+
if (options.font !== void 0) command2.font = font(options.font);
|
|
4089
|
+
this.push(command2);
|
|
4046
4090
|
return this;
|
|
4047
4091
|
}
|
|
4048
4092
|
/** `draw(Image(...), at:anchor:)` or `draw(_:in:)` with `size`. */
|
|
4049
4093
|
drawImage(image, at, options = {}) {
|
|
4050
4094
|
const props = "url" in image ? { ...image, resizable: true } : "name" in image ? { name: image.name, resizable: true } : image;
|
|
4051
|
-
const
|
|
4095
|
+
const command2 = {
|
|
4052
4096
|
op: "image",
|
|
4053
4097
|
image: props,
|
|
4054
4098
|
x: at.x,
|
|
@@ -4057,17 +4101,17 @@ class GraphicsContext {
|
|
|
4057
4101
|
...options.size ? { width: options.size.width, height: options.size.height } : {},
|
|
4058
4102
|
...options.color !== void 0 ? { shading: shading(options.color) } : {}
|
|
4059
4103
|
};
|
|
4060
|
-
this.push(
|
|
4104
|
+
this.push(command2);
|
|
4061
4105
|
return this;
|
|
4062
4106
|
}
|
|
4063
|
-
push(
|
|
4107
|
+
push(command2) {
|
|
4064
4108
|
const state = {};
|
|
4065
4109
|
if (this.state.transform.some((v, i) => v !== IDENTITY[i])) state.transform = this.state.transform.map((v) => Math.round(v * 1e4) / 1e4);
|
|
4066
4110
|
if (this.state.opacity !== 1) state.opacity = this.state.opacity;
|
|
4067
4111
|
if (this.state.blendMode) state.blendMode = this.state.blendMode;
|
|
4068
4112
|
if (this.state.clips.length) state.clips = [...this.state.clips];
|
|
4069
4113
|
if (this.state.filters.length) state.filters = [...this.state.filters];
|
|
4070
|
-
this.commands.push({ ...state, ...
|
|
4114
|
+
this.commands.push({ ...state, ...command2 });
|
|
4071
4115
|
}
|
|
4072
4116
|
}
|
|
4073
4117
|
function Canvas(props) {
|