@stealthscale/provider-router 0.1.0 → 0.4.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 +77 -13
- package/dist/cyclonedx/bom.json +1 -1
- package/dist/index.d.ts +294 -203
- package/dist/index.js +2 -689
- package/dist/pages/link.js +162 -0
- package/dist/pages/link.props.js +3 -0
- package/dist/pages/pages.json +20 -0
- package/dist/shared-D7o15Y7B.js +813 -0
- package/locales/en/specimen/route-link.json +16 -0
- package/package.json +31 -24
- package/dist/rolldown-runtime-BBjsoOtd.js +0 -27
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { E as RouteLink, O as useRouteHref, a as createLink } from "../shared-D7o15Y7B.js";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { Matrix, specimen, useWords } from "@stealthscale/specimen";
|
|
5
|
+
import { Link } from "@stealthscale/component-navigation";
|
|
6
|
+
import { Text } from "@stealthscale/component-typography";
|
|
7
|
+
//#region \0rolldown/runtime.js
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __exportAll = (all, no_symbols) => {
|
|
10
|
+
let target = {};
|
|
11
|
+
for (var name in all) __defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/examples/open.example.tsx
|
|
20
|
+
var open_example_exports = /* @__PURE__ */ __exportAll({
|
|
21
|
+
Open: () => Open,
|
|
22
|
+
source: () => source$1
|
|
23
|
+
});
|
|
24
|
+
function Open(props) {
|
|
25
|
+
const $ = c(5);
|
|
26
|
+
const { t } = useWords("route-link");
|
|
27
|
+
let t0;
|
|
28
|
+
if ($[0] !== t) {
|
|
29
|
+
t0 = t("opens");
|
|
30
|
+
$[0] = t;
|
|
31
|
+
$[1] = t0;
|
|
32
|
+
} else t0 = $[1];
|
|
33
|
+
let t1;
|
|
34
|
+
if ($[2] !== props || $[3] !== t0) {
|
|
35
|
+
t1 = /* @__PURE__ */ jsx(RouteLink, {
|
|
36
|
+
...props,
|
|
37
|
+
children: t0
|
|
38
|
+
});
|
|
39
|
+
$[2] = props;
|
|
40
|
+
$[3] = t0;
|
|
41
|
+
$[4] = t1;
|
|
42
|
+
} else t1 = $[4];
|
|
43
|
+
return t1;
|
|
44
|
+
}
|
|
45
|
+
const source$1 = "import { type ReactElement } from \"react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { RouteLink } from \"@stealthscale/provider-router\";\n\nexport function Open(props: Parameters<typeof RouteLink>[0]): ReactElement {\n const { t } = useWords(\"route-link\");\n\n return <RouteLink {...props}>{t(\"opens\")}</RouteLink>;\n}\n";
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/examples/sentence.example.tsx
|
|
48
|
+
var sentence_example_exports = /* @__PURE__ */ __exportAll({
|
|
49
|
+
Sentence: () => Sentence,
|
|
50
|
+
source: () => source
|
|
51
|
+
});
|
|
52
|
+
const StyledLink = createLink(Link);
|
|
53
|
+
function Sentence() {
|
|
54
|
+
const $ = c(14);
|
|
55
|
+
const { t } = useWords("route-link");
|
|
56
|
+
let t0;
|
|
57
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
58
|
+
t0 = {
|
|
59
|
+
group: "actions",
|
|
60
|
+
name: "button"
|
|
61
|
+
};
|
|
62
|
+
$[0] = t0;
|
|
63
|
+
} else t0 = $[0];
|
|
64
|
+
const href = useRouteHref("catalogue/componentsPage", t0);
|
|
65
|
+
let t1;
|
|
66
|
+
if ($[1] !== t) {
|
|
67
|
+
t1 = t("before");
|
|
68
|
+
$[1] = t;
|
|
69
|
+
$[2] = t1;
|
|
70
|
+
} else t1 = $[2];
|
|
71
|
+
let t2;
|
|
72
|
+
if ($[3] !== t) {
|
|
73
|
+
t2 = t("named");
|
|
74
|
+
$[3] = t;
|
|
75
|
+
$[4] = t2;
|
|
76
|
+
} else t2 = $[4];
|
|
77
|
+
let t3;
|
|
78
|
+
if ($[5] !== href || $[6] !== t2) {
|
|
79
|
+
t3 = /* @__PURE__ */ jsx(StyledLink, {
|
|
80
|
+
to: href,
|
|
81
|
+
children: t2
|
|
82
|
+
});
|
|
83
|
+
$[5] = href;
|
|
84
|
+
$[6] = t2;
|
|
85
|
+
$[7] = t3;
|
|
86
|
+
} else t3 = $[7];
|
|
87
|
+
let t4;
|
|
88
|
+
if ($[8] !== t) {
|
|
89
|
+
t4 = t("after");
|
|
90
|
+
$[8] = t;
|
|
91
|
+
$[9] = t4;
|
|
92
|
+
} else t4 = $[9];
|
|
93
|
+
let t5;
|
|
94
|
+
if ($[10] !== t1 || $[11] !== t3 || $[12] !== t4) {
|
|
95
|
+
t5 = /* @__PURE__ */ jsxs(Text, { children: [
|
|
96
|
+
t1,
|
|
97
|
+
" ",
|
|
98
|
+
t3,
|
|
99
|
+
" ",
|
|
100
|
+
t4
|
|
101
|
+
] });
|
|
102
|
+
$[10] = t1;
|
|
103
|
+
$[11] = t3;
|
|
104
|
+
$[12] = t4;
|
|
105
|
+
$[13] = t5;
|
|
106
|
+
} else t5 = $[13];
|
|
107
|
+
return t5;
|
|
108
|
+
}
|
|
109
|
+
const source = "import { type ReactElement } from \"react\";\n\nimport { Link } from \"@stealthscale/component-navigation\";\nimport { Text } from \"@stealthscale/component-typography\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { createLink, useRouteHref } from \"@stealthscale/provider-router\";\n\nconst StyledLink = createLink(Link);\n\nexport function Sentence(): ReactElement {\n const { t } = useWords(\"route-link\");\n const href = useRouteHref(\"catalogue/componentsPage\", { group: \"actions\", name: \"button\" });\n\n return (\n <Text>\n {t(\"before\")} <StyledLink to={href}>{t(\"named\")}</StyledLink> {t(\"after\")}\n </Text>\n );\n}\n";
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/link.specimen.tsx
|
|
112
|
+
/**
|
|
113
|
+
* Catalogue page for the route link.
|
|
114
|
+
*
|
|
115
|
+
* @remarks
|
|
116
|
+
* `RouteLink` has no recipe, so both scenes are hand-written, and the open example is imported
|
|
117
|
+
* on its own as well, because the props reader finds `RouteLink` through the example files a
|
|
118
|
+
* specimen imports directly. The links resolve against the
|
|
119
|
+
* catalogue plugin's routes, because the catalogue's route map is the one mounted around a
|
|
120
|
+
* specimen. The resolving scene renders the open example once per route ID and states the first
|
|
121
|
+
* ID as `Scene.props`. The sentence scene resolves an ID and its parameters with `useRouteHref`
|
|
122
|
+
* and links to the path through `createLink(Link)`, which gives the link the navigation package's
|
|
123
|
+
* styles. The layout and typography packages are development dependencies, because only the
|
|
124
|
+
* catalogue reads this file. The words are keys under `route-link` in
|
|
125
|
+
* `locales/en/specimen/route-link.json`.
|
|
126
|
+
*/
|
|
127
|
+
/**
|
|
128
|
+
* IDs of the catalogue plugin's two section indexes, which name no parameters.
|
|
129
|
+
*/
|
|
130
|
+
const ROUTES = ["catalogue/components", "catalogue/foundations"];
|
|
131
|
+
/**
|
|
132
|
+
* Hand-written scene for route IDs resolved through the route map.
|
|
133
|
+
*/
|
|
134
|
+
const resolving = {
|
|
135
|
+
about: "route-link.resolving.about",
|
|
136
|
+
draw: () => /* @__PURE__ */ jsx(Matrix, {
|
|
137
|
+
knob: "to",
|
|
138
|
+
of: ROUTES,
|
|
139
|
+
children: (to) => /* @__PURE__ */ jsx(Open, { to })
|
|
140
|
+
}),
|
|
141
|
+
example: open_example_exports,
|
|
142
|
+
props: { to: ROUTES[0] },
|
|
143
|
+
title: "route-link.resolving.title"
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Hand-written scene for a route link inside a sentence.
|
|
147
|
+
*/
|
|
148
|
+
const inline = {
|
|
149
|
+
about: "route-link.inline.about",
|
|
150
|
+
draw: Sentence,
|
|
151
|
+
example: sentence_example_exports,
|
|
152
|
+
title: "route-link.inline.title"
|
|
153
|
+
};
|
|
154
|
+
var link_specimen_default = specimen({
|
|
155
|
+
about: "route-link.about",
|
|
156
|
+
id: "foundations/router/link",
|
|
157
|
+
imports: "import { RouteLink } from \"@stealthscale/provider-router\";",
|
|
158
|
+
scenes: [resolving, inline],
|
|
159
|
+
title: "route-link.title"
|
|
160
|
+
});
|
|
161
|
+
//#endregion
|
|
162
|
+
export { link_specimen_default as default, inline, resolving };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export const dropped = {"RouteLinkProps": {"conditions": 0, "foreign": 288}};
|
|
2
|
+
export const parts = {"RouteLinkProps": [{"accepts": "ParsedLocation<{}>", "fallback": "", "kind": "option", "name": "_fromLocation", "refers": ["history.HistoryLocation", "history.HistoryState", "router-core.ParsedLocation"], "required": false, "says": ""}, {"accepts": "ActiveOptions", "fallback": "{exact:true,includeHash:true}", "kind": "option", "name": "activeOptions", "refers": ["router-core.ActiveOptions"], "required": false, "says": "Configurable options to determine if the link should be considered active or not"}, {"accepts": "boolean", "fallback": "false", "kind": "option", "name": "disabled", "refers": [], "required": false, "says": "Control whether the link should be disabled or not If set to `true`, the link will be rendered without an `href` attribute"}, {"accepts": "string", "fallback": "", "kind": "option", "name": "from", "refers": [], "required": false, "says": ""}, {"accepts": "true | Updater<string>", "fallback": "", "kind": "option", "name": "hash", "refers": [], "required": false, "says": ""}, {"accepts": "boolean | ScrollIntoViewOptions", "fallback": "true", "kind": "option", "name": "hashScrollIntoView", "refers": [], "required": false, "says": "If set to `true`, the router will scroll the element with an id matching the hash into view with default `ScrollIntoViewOptions`. If set to `false`, the router will not scroll the element with an id matching the hash into view. If set to `ScrollIntoViewOptions`, the router will scroll the element with an id matching the hash into view with the provided options."}, {"accepts": "string", "fallback": "", "kind": "option", "name": "href", "refers": [], "required": false, "says": "This can be used instead of `to` to navigate to a fully built href, e.g. pointing to an external target."}, {"accepts": "boolean", "fallback": "false", "kind": "option", "name": "ignoreBlocker", "refers": [], "required": false, "says": "If `true`, navigation will ignore any blockers that might prevent it."}, {"accepts": "ToMaskOptions<AnyRouter, string, string>", "fallback": "", "kind": "option", "name": "mask", "refers": ["router-core.AnyRouter", "router-core.MakeOptionalPathParams", "router-core.MakeOptionalSearchParams", "router-core.OptionalToOptions"], "required": false, "says": ""}, {"accepts": "Params", "fallback": "", "kind": "option", "name": "params", "refers": ["kit.Params"], "required": false, "says": "The parameters of the route's path, typed by the reference. The parameters of the route's path, typed by the reference where one was given."}, {"accepts": "\"intent\" | \"render\" | \"viewport\" | false", "fallback": "", "kind": "option", "name": "preload", "refers": [], "required": false, "says": "The preloading strategy for this link - `false` - No preloading - `'intent'` - Preload the linked route when the user focuses, hovers over, or touches the link - `'viewport'` - Preload the linked route when it enters the viewport - `'render'` - Preload the linked route as soon as it renders"}, {"accepts": "number", "fallback": "", "kind": "option", "name": "preloadDelay", "refers": [], "required": false, "says": "Delays focus, hover, and viewport preloading by this many milliseconds. Touch intent preloads immediately. If focus or hover ends, or the link leaves the viewport before this delay, the preload will be cancelled."}, {"accepts": "number", "fallback": "", "kind": "option", "name": "preloadIntentProximity", "refers": [], "required": false, "says": "When the preload strategy is set to `intent`, this controls the proximity of the link to the cursor before it is preloaded. If the user exits this proximity before this delay, the preload will be cancelled."}, {"accepts": "boolean", "fallback": "false", "kind": "option", "name": "reloadDocument", "refers": [], "required": false, "says": "If `true`, navigation to a route inside of router will trigger a full page load instead of the traditional SPA navigation."}, {"accepts": "boolean", "fallback": "false", "kind": "option", "name": "replace", "refers": [], "required": false, "says": "`replace` is a boolean that determines whether the navigation should replace the current history entry or push a new one."}, {"accepts": "boolean", "fallback": "true", "kind": "option", "name": "resetScroll", "refers": [], "required": false, "says": "Defaults to `true` so that the scroll position will be reset to 0,0 after the location is committed to the browser history. If `false`, the scroll position will not be reset to 0,0 after the location is committed to history."}, {"accepts": "NoInfer<Search>", "fallback": "", "kind": "option", "name": "search", "refers": [], "required": false, "says": "The search to open the route with, typed by the reference where one was given."}, {"accepts": "boolean", "fallback": "", "kind": "option", "name": "startTransition", "refers": [], "required": false, "says": ""}, {"accepts": "true | NonNullableUpdater<ParsedHistoryState, HistoryState>", "fallback": "", "kind": "option", "name": "state", "refers": ["history.HistoryState"], "required": false, "says": ""}, {"accepts": "string", "fallback": "", "kind": "option", "name": "target", "refers": [], "required": false, "says": "The standard anchor tag target attribute"}, {"accepts": "RouteTarget<Params, Search>", "fallback": "", "kind": "option", "name": "to", "refers": ["kit.Params", "kit.RouteRef", "kit.RouteTarget", "kit.Search"], "required": true, "says": "A reference to the route, or the bare id of one."}, {"accepts": "\"path\"", "fallback": "", "kind": "option", "name": "unsafeRelative", "refers": [], "required": false, "says": ""}, {"accepts": "boolean | ViewTransitionOptions", "fallback": "false", "kind": "option", "name": "viewTransition", "refers": ["router-core.ViewTransitionOptions"], "required": false, "says": "If set to `true`, the router will wrap the resulting navigation in a `document.startViewTransition()` call. If `ViewTransitionOptions`, route navigations will be called using `document.startViewTransition({update, types})` where `types` will be the strings array passed with `ViewTransitionOptions[\"types\"]`. If the browser does not support viewTransition types, the navigation will fall back to normal `document.startTransition()`, same as if `true` was passed."}]};
|
|
3
|
+
export const shapes = {"kit.RouteTarget": [{"accepts": "", "name": "string", "says": ""}, {"accepts": "", "name": "RouteRef<Params, Search>", "says": ""}], "kit.RouteRef": [{"accepts": "{ readonly params: Params; readonly search: Search; }", "name": "~types", "says": "The parameters and the search, in the type alone."}, {"accepts": "string", "name": "id", "says": "The full id the route was declared under."}], "router-core.ViewTransitionOptions": [{"accepts": "string[] | ((locationChangeInfo: { fromLocation?: ParsedLocation<{}>; toLocation: ParsedLocation<{}>; pathChanged: boolean; hrefChanged: boolean; hashChanged: boolean; }) => false | string[])", "name": "types", "says": ""}], "router-core.ParsedLocation": [{"accepts": "string", "name": "href", "says": "The full path of the location, including pathname, search, and hash. Does not include the origin. Is the equivalent of calling `url.replace(url.origin, '')`"}, {"accepts": "string", "name": "pathname", "says": ""}, {"accepts": "{}", "name": "search", "says": "The parsed search parameters of the location in object form."}, {"accepts": "string", "name": "searchStr", "says": "The search string of the location, including the leading question mark."}, {"accepts": "ParsedHistoryState", "name": "state", "says": "The in-memory state of the location as it *may* exist in the browser's history."}, {"accepts": "string", "name": "hash", "says": "The hash of the location, excluding the leading hash character. (e.g., '123' instead of '#123')"}, {"accepts": "ParsedLocation<{}>", "name": "maskedLocation", "says": "The masked location of the location."}, {"accepts": "boolean", "name": "unmaskOnReload", "says": "Whether to unmask the location on reload."}, {"accepts": "string", "name": "publicHref", "says": ""}, {"accepts": "boolean", "name": "external", "says": ""}], "history.HistoryState": [{"accepts": "HistoryLocation", "name": "__tempLocation", "says": ""}, {"accepts": "string", "name": "__tempKey", "says": ""}, {"accepts": "boolean | ScrollIntoViewOptions", "name": "__hashScrollIntoViewOptions", "says": ""}], "history.HistoryLocation": [{"accepts": "ParsedHistoryState", "name": "state", "says": ""}, {"accepts": "string", "name": "href", "says": ""}, {"accepts": "string", "name": "pathname", "says": ""}, {"accepts": "string", "name": "search", "says": ""}, {"accepts": "string", "name": "hash", "says": ""}], "router-core.OptionalToOptions": [{"accepts": "string", "name": "to", "says": "The internal route path to navigate to. This should be a relative or absolute path within your application. For external URLs, use the `href` property instead."}], "router-core.MakeOptionalSearchParams": [{"accepts": "any", "name": "search", "says": ""}], "router-core.MakeOptionalPathParams": [{"accepts": "any", "name": "params", "says": ""}], "router-core.ActiveOptions": [{"accepts": "boolean", "name": "exact", "says": "If true, the link will be active if the current route matches the `to` route path exactly (no children routes)"}, {"accepts": "boolean", "name": "includeHash", "says": "If true, the link will only be active if the current URL hash matches the `hash` prop"}, {"accepts": "boolean", "name": "includeSearch", "says": "If true, the link will only be active if the current URL search params inclusively match the `search` prop"}, {"accepts": "boolean", "name": "explicitUndefined", "says": "This modifies the `includeSearch` behavior. If true, properties in `search` that are explicitly `undefined` must NOT be present in the current URL search params for the link to be active."}]};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"format": 1,
|
|
3
|
+
"pages": [
|
|
4
|
+
{
|
|
5
|
+
"about": "route-link.about",
|
|
6
|
+
"group": "",
|
|
7
|
+
"id": "foundations/router/link",
|
|
8
|
+
"module": "link.js",
|
|
9
|
+
"namespace": "",
|
|
10
|
+
"props": "link.props.js",
|
|
11
|
+
"specimen": "src/link.specimen.tsx",
|
|
12
|
+
"title": "route-link.title"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"requires": {
|
|
16
|
+
"@stealthscale/component-navigation": "^0.3.0",
|
|
17
|
+
"@stealthscale/component-typography": "^0.3.0",
|
|
18
|
+
"@stealthscale/specimen": "^0.3.0"
|
|
19
|
+
}
|
|
20
|
+
}
|