@swiftbrowser/react 0.9.3 → 0.9.5
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 +24 -2
- package/dist/components/stacks.d.ts +7 -0
- package/dist/components/stacks.d.ts.map +1 -1
- package/dist/components/text.d.ts.map +1 -1
- package/dist/index.js +17 -2
- package/dist/index.js.map +1 -1
- package/dist/island.d.ts +10 -1
- package/dist/island.d.ts.map +1 -1
- package/dist/modifiers.d.ts +2 -0
- package/dist/modifiers.d.ts.map +1 -1
- package/dist/mount.d.ts +11 -0
- package/dist/mount.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -142,7 +142,8 @@ props: `<VStack alignment="leading" spacing={8}>`, `<Text font="headline">`,
|
|
|
142
142
|
|
|
143
143
|
Text is plain strings and numbers inside `<Text>`; nested `<Text>`s and
|
|
144
144
|
inline `<Image>`s make a rich text (`Text + Text`), and `italic`,
|
|
145
|
-
`underline`, `strikethrough` and `
|
|
145
|
+
`underline`, `strikethrough`, `tracking` and `monospacedDigit` (tabular
|
|
146
|
+
digits, also a modifier on any view) are its own props.
|
|
146
147
|
|
|
147
148
|
### Modifiers as props
|
|
148
149
|
|
|
@@ -215,6 +216,24 @@ content and actions render as root-level elements while presented;
|
|
|
215
216
|
`presentationDetents` inside a sheet sets its detents. `useDismiss()` inside
|
|
216
217
|
a pushed screen or a sheet pops or dismisses it.
|
|
217
218
|
|
|
219
|
+
Navigation is mirrored in the browser's history by default: pushing a
|
|
220
|
+
screen or presenting a sheet adds an entry, and the browser's back (a
|
|
221
|
+
phone's edge swipe, Android's back gesture, the toolbar button) pops or
|
|
222
|
+
dismisses it exactly as the bar's back button would, through the app's own
|
|
223
|
+
state. The renderer's own swipe back ignores touch meanwhile, so the
|
|
224
|
+
browser's edge swipe is the swipe back (a mouse drag from the edge still
|
|
225
|
+
pops, since no browser navigates on one). The app popping on its own takes the history back
|
|
226
|
+
with it, and forward returns to the entry that matches rather than
|
|
227
|
+
re-pushing. In a wide window a `NavigationSplitView` pushes nothing when
|
|
228
|
+
its sidebar's selection moves, so that is an entry of its own: choosing
|
|
229
|
+
another sidebar row adds one (the first choice does not), and back or
|
|
230
|
+
forward selects the row the entry recorded, through the row's own tap. The
|
|
231
|
+
URL is left alone: an app that maps screens to paths sets them with
|
|
232
|
+
`history.replaceState` on the entry the renderer made (a `pushState` of its
|
|
233
|
+
own would add a second entry for the same screen).
|
|
234
|
+
`<SwiftUIView history={false}>` (or `mount(..., { history: false })`) leaves
|
|
235
|
+
the history untouched, for an island in a page whose own router owns it.
|
|
236
|
+
|
|
218
237
|
### Toolbars
|
|
219
238
|
|
|
220
239
|
`ToolbarItem`'s `placement` takes SwiftUI's names. `secondaryAction` items
|
|
@@ -296,7 +315,10 @@ rows at a time as they scroll into view. `ScrollViewReader` hands a proxy
|
|
|
296
315
|
whose `scrollTo(id, anchor)` scrolls to the view marked `scrollID={id}`,
|
|
297
316
|
building lazy rows up to it first. `refreshable` (on a `List` or
|
|
298
317
|
`ScrollView`, or above one) runs an async action on a pull, with the
|
|
299
|
-
spinner while it runs. `
|
|
318
|
+
spinner while it runs. `defaultScrollAnchor="bottom"` on a `ScrollView`
|
|
319
|
+
opens it at its end and keeps the end in view as content is added while
|
|
320
|
+
the viewer is there (a chat); a viewer who scrolled up is left where they
|
|
321
|
+
are. `scrollTargetBehavior="paging"` or `"viewAligned"` on
|
|
300
322
|
a `ScrollView` snaps, with `scrollTargetLayout` on the stack inside.
|
|
301
323
|
Name a coordinate space with `coordinateSpace="page"` on the `ScrollView`
|
|
302
324
|
(or any view), and a `GeometryReader` inside reads its frame there with
|
|
@@ -2,6 +2,7 @@ import type { FrameAlignment, GridItem as GridItemProps, GridRowAlignment, HStac
|
|
|
2
2
|
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
|
+
import { type UnitPointValue } from '../values';
|
|
5
6
|
import { type ScrollSettings } from '../scrollEnvironment';
|
|
6
7
|
export interface VStackProps extends ViewModifiers {
|
|
7
8
|
alignment?: VStackAlignment;
|
|
@@ -34,6 +35,12 @@ export interface ScrollViewProps extends ViewModifiers {
|
|
|
34
35
|
scrollTargetBehavior?: 'viewAligned' | 'paging';
|
|
35
36
|
/** `.scrollDismissesKeyboard(.immediately)` */
|
|
36
37
|
scrollDismissesKeyboard?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* `.defaultScrollAnchor(_:)`: where the content starts (`"bottom"`: its end
|
|
40
|
+
* in view, as a chat) and stays when it grows while the viewer is there;
|
|
41
|
+
* a viewer who scrolled away is left where they are.
|
|
42
|
+
*/
|
|
43
|
+
defaultScrollAnchor?: UnitPointValue;
|
|
37
44
|
children?: ReactNode;
|
|
38
45
|
}
|
|
39
46
|
export declare function ScrollView(props: ScrollViewProps): ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stacks.d.ts","sourceRoot":"","sources":["../../src/components/stacks.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,IAAI,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAChK,OAAO,EAA+D,KAAK,GAAG,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEjI,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAA4C,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAChH,OAAO,EAYL,KAAK,cAAc,EACpB,MAAM,sBAAsB,CAAC;AAI9B,MAAM,WAAW,WAAY,SAAQ,aAAa;IAChD,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,y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F;IACpF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC;AAQD,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CAWlD;AAMD,MAAM,WAAW,UAAW,SAAQ,aAAa;IAC/C,KAAK,EAAE,SAAS,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAED,iGAAiG;AACjG,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CA4BlD;AAED,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACxD,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,2GAA2G;AAC3G,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,SAAS,CAapE;AAED,MAAM,WAAW,SAAU,SAAQ,aAAa;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,oFAAoF;AACpF,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAIhD"}
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { createContext, useContext, createElement, useRef, useLayoutEffect, useS
|
|
|
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
|
+
import { BrowserHistory } from "@swiftbrowser/web/src/browserHistory";
|
|
5
6
|
import { Renderer } from "@swiftbrowser/web/src/renderer";
|
|
6
7
|
import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
|
|
7
8
|
import { applyTypeSizeVariables } from "@swiftbrowser/web/src/typography";
|
|
@@ -439,6 +440,8 @@ function mount(screen, element, options = {}) {
|
|
|
439
440
|
renderer.setEnvironment({ colorScheme: environment.colorScheme, dynamicTypeSize: environment.dynamicTypeSize });
|
|
440
441
|
if (options.safeArea !== void 0) renderer.setSafeArea(options.safeArea);
|
|
441
442
|
root.setEnvironment(environment);
|
|
443
|
+
const browserHistory = (options.history ?? true) && typeof window !== "undefined" ? new BrowserHistory(renderer, screen) : null;
|
|
444
|
+
browserHistory?.enable();
|
|
442
445
|
const applyScheme = () => {
|
|
443
446
|
const scheme = preferred ?? pageScheme;
|
|
444
447
|
const device = screen.closest(".device");
|
|
@@ -472,6 +475,7 @@ function mount(screen, element, options = {}) {
|
|
|
472
475
|
},
|
|
473
476
|
unmount() {
|
|
474
477
|
observer?.disconnect();
|
|
478
|
+
browserHistory?.dispose();
|
|
475
479
|
screen.removeEventListener("sb:color-scheme", onPreferredScheme);
|
|
476
480
|
root.unmount();
|
|
477
481
|
renderer?.dispose();
|
|
@@ -513,6 +517,7 @@ function SwiftUIView({
|
|
|
513
517
|
contexts,
|
|
514
518
|
assets,
|
|
515
519
|
safeArea,
|
|
520
|
+
history = true,
|
|
516
521
|
className,
|
|
517
522
|
style
|
|
518
523
|
}) {
|
|
@@ -530,6 +535,7 @@ function SwiftUIView({
|
|
|
530
535
|
dynamicTypeSize,
|
|
531
536
|
safeArea: insetsOf(safeArea, fit),
|
|
532
537
|
contentHeight: fit === "content",
|
|
538
|
+
history,
|
|
533
539
|
...assets ? { assets } : {}
|
|
534
540
|
});
|
|
535
541
|
mounted.current = instance;
|
|
@@ -537,7 +543,7 @@ function SwiftUIView({
|
|
|
537
543
|
mounted.current = null;
|
|
538
544
|
instance.unmount();
|
|
539
545
|
};
|
|
540
|
-
}, [fit]);
|
|
546
|
+
}, [fit, history]);
|
|
541
547
|
useLayoutEffect(() => {
|
|
542
548
|
mounted.current?.root.render(tree);
|
|
543
549
|
});
|
|
@@ -955,6 +961,7 @@ function ScrollView(props) {
|
|
|
955
961
|
const scroll = { axes, ...refresh.props };
|
|
956
962
|
if (own.scrollTargetBehavior) scroll["snap"] = own.scrollTargetBehavior;
|
|
957
963
|
if (own.scrollDismissesKeyboard) scroll["dismissesKeyboard"] = true;
|
|
964
|
+
if (own.defaultScrollAnchor !== void 0) scroll["defaultScrollAnchor"] = unitPoint(own.defaultScrollAnchor);
|
|
958
965
|
const edgeEffect = edgeEffectProp(settings);
|
|
959
966
|
if (edgeEffect) scroll["edgeEffect"] = edgeEffect;
|
|
960
967
|
const content = marginedContent(own.children, settings.margins, axes === "horizontal" ? "horizontal" : "vertical");
|
|
@@ -1125,6 +1132,7 @@ function runStyleOf(props, inherited, nested) {
|
|
|
1125
1132
|
let runFont = props.font !== void 0 ? font(props.font) : void 0;
|
|
1126
1133
|
if (props.bold) runFont = { ...runFont ?? {}, weight: "bold" };
|
|
1127
1134
|
if (props.fontWeight) runFont = { ...runFont ?? {}, weight: props.fontWeight };
|
|
1135
|
+
if (props.monospacedDigit) runFont = { ...runFont ?? {}, monospacedDigit: true };
|
|
1128
1136
|
if (runFont) style.font = { ...style.font ?? {}, ...runFont };
|
|
1129
1137
|
if (props.foregroundStyle !== void 0) {
|
|
1130
1138
|
style.foreground = shapeStyle(Array.isArray(props.foregroundStyle) ? props.foregroundStyle[0] : props.foregroundStyle);
|
|
@@ -1654,6 +1662,7 @@ const MODIFIER_KEYS = /* @__PURE__ */ new Set([
|
|
|
1654
1662
|
"font",
|
|
1655
1663
|
"fontWeight",
|
|
1656
1664
|
"bold",
|
|
1665
|
+
"monospacedDigit",
|
|
1657
1666
|
"foregroundStyle",
|
|
1658
1667
|
"background",
|
|
1659
1668
|
"overlay",
|
|
@@ -1819,6 +1828,7 @@ const STYLED_KEYS = /* @__PURE__ */ new Set([
|
|
|
1819
1828
|
"font",
|
|
1820
1829
|
"fontWeight",
|
|
1821
1830
|
"bold",
|
|
1831
|
+
"monospacedDigit",
|
|
1822
1832
|
"foregroundStyle",
|
|
1823
1833
|
"background",
|
|
1824
1834
|
"frame",
|
|
@@ -1900,6 +1910,8 @@ function apply(key, value, node, sides) {
|
|
|
1900
1910
|
return styled({ font: { weight: value } }, node);
|
|
1901
1911
|
case "bold":
|
|
1902
1912
|
return value ? styled({ font: { weight: "bold" } }, node) : node;
|
|
1913
|
+
case "monospacedDigit":
|
|
1914
|
+
return value ? styled({ font: { monospacedDigit: true } }, node) : node;
|
|
1903
1915
|
case "foregroundStyle": {
|
|
1904
1916
|
if (!Array.isArray(value)) return styled({ foreground: shapeStyle(value) }, node);
|
|
1905
1917
|
const [primary, ...levels] = value;
|
|
@@ -2160,7 +2172,10 @@ function apply(key, value, node, sides) {
|
|
|
2160
2172
|
case "allowsHitTesting":
|
|
2161
2173
|
return value === false ? styled({ hitTesting: false }, node) : node;
|
|
2162
2174
|
case "ignoresSafeArea":
|
|
2163
|
-
return styled(
|
|
2175
|
+
return styled(
|
|
2176
|
+
value === true ? { ignoresSafeArea: "all", ignoresKeyboard: true } : { ignoresSafeArea: value },
|
|
2177
|
+
node
|
|
2178
|
+
);
|
|
2164
2179
|
case "rotation3DEffect": {
|
|
2165
2180
|
const spec = value;
|
|
2166
2181
|
const rotation = { angle: spec.angle, axis: spec.axis };
|