@burdenoff/microfe-coolandlovely 2026.1102.11 → 2026.1107.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/dist/coolandlovely/hooks/contextNavigationTarget.d.ts +19 -0
- package/dist/coolandlovely/hooks/contextNavigationTarget.d.ts.map +1 -0
- package/dist/coolandlovely/hooks/contextNavigationTarget.js +23 -0
- package/dist/coolandlovely/hooks/contextNavigationTarget.js.map +1 -0
- package/dist/coolandlovely/hooks/useContextNavigation.d.ts.map +1 -1
- package/dist/coolandlovely/hooks/useContextNavigation.js +15 -21
- package/dist/coolandlovely/hooks/useContextNavigation.js.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Query keys that carry the host's selected context. Nothing else is copied. */
|
|
2
|
+
export declare const CONTEXT_QUERY_KEYS: readonly ["org", "workspace", "project", "tenant"];
|
|
3
|
+
/**
|
|
4
|
+
* Build a navigation target that keeps the selected context.
|
|
5
|
+
*
|
|
6
|
+
* `sources` are read in priority order; the first one that carries a key wins.
|
|
7
|
+
* The caller passes the live address-bar query first and the router location
|
|
8
|
+
* second: the host shell writes context keys with `history.replaceState` after
|
|
9
|
+
* a context switch (fe-libs ActiveContextProvider), which React Router does not
|
|
10
|
+
* observe, so the router location can be missing a key (typically `project`)
|
|
11
|
+
* that the address bar already shows. The router query stays as the fallback
|
|
12
|
+
* for embeddings that use an in-memory router.
|
|
13
|
+
*
|
|
14
|
+
* The target's own query and hash are kept; a context key in the source
|
|
15
|
+
* replaces the same key in the target so a link can never point at a different
|
|
16
|
+
* context than the one selected.
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildContextNavigationTarget(path: string, sources: ReadonlyArray<string | null | undefined>): string;
|
|
19
|
+
//# sourceMappingURL=contextNavigationTarget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextNavigationTarget.d.ts","sourceRoot":"","sources":["../../../src/coolandlovely/hooks/contextNavigationTarget.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,eAAO,MAAM,kBAAkB,oDAAqD,CAAC;AAErF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,aAAa,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAChD,MAAM,CAqBR"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/coolandlovely/hooks/contextNavigationTarget.ts
|
|
2
|
+
var e = [
|
|
3
|
+
"org",
|
|
4
|
+
"workspace",
|
|
5
|
+
"project",
|
|
6
|
+
"tenant"
|
|
7
|
+
];
|
|
8
|
+
function t(t, n) {
|
|
9
|
+
let r = t.indexOf("#"), i = r === -1 ? t : t.slice(0, r), a = r === -1 ? void 0 : t.slice(r + 1), o = i.indexOf("?"), s = o === -1 ? i : i.slice(0, o), c = o === -1 ? "" : i.slice(o + 1), l = n.map((e) => new URLSearchParams(e ?? "")), u = new URLSearchParams(c);
|
|
10
|
+
for (let t of e) for (let e of l) {
|
|
11
|
+
let n = e.get(t);
|
|
12
|
+
if (n) {
|
|
13
|
+
u.set(t, n);
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
let d = u.toString();
|
|
18
|
+
return `${s}${d ? `?${d}` : ""}${a === void 0 ? "" : `#${a}`}`;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { e as CONTEXT_QUERY_KEYS, t as buildContextNavigationTarget };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=contextNavigationTarget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextNavigationTarget.js","names":[],"sources":["../../../src/coolandlovely/hooks/contextNavigationTarget.ts"],"sourcesContent":["/** Query keys that carry the host's selected context. Nothing else is copied. */\nexport const CONTEXT_QUERY_KEYS = ['org', 'workspace', 'project', 'tenant'] as const;\n\n/**\n * Build a navigation target that keeps the selected context.\n *\n * `sources` are read in priority order; the first one that carries a key wins.\n * The caller passes the live address-bar query first and the router location\n * second: the host shell writes context keys with `history.replaceState` after\n * a context switch (fe-libs ActiveContextProvider), which React Router does not\n * observe, so the router location can be missing a key (typically `project`)\n * that the address bar already shows. The router query stays as the fallback\n * for embeddings that use an in-memory router.\n *\n * The target's own query and hash are kept; a context key in the source\n * replaces the same key in the target so a link can never point at a different\n * context than the one selected.\n */\nexport function buildContextNavigationTarget(\n path: string,\n sources: ReadonlyArray<string | null | undefined>\n): string {\n const hashIndex = path.indexOf('#');\n const beforeHash = hashIndex === -1 ? path : path.slice(0, hashIndex);\n const fragment = hashIndex === -1 ? undefined : path.slice(hashIndex + 1);\n const queryIndex = beforeHash.indexOf('?');\n const pathname = queryIndex === -1 ? beforeHash : beforeHash.slice(0, queryIndex);\n const existingQuery = queryIndex === -1 ? '' : beforeHash.slice(queryIndex + 1);\n\n const parsedSources = sources.map((source) => new URLSearchParams(source ?? ''));\n const context = new URLSearchParams(existingQuery);\n for (const key of CONTEXT_QUERY_KEYS) {\n for (const source of parsedSources) {\n const value = source.get(key);\n if (value) {\n context.set(key, value);\n break;\n }\n }\n }\n const query = context.toString();\n return `${pathname}${query ? `?${query}` : ''}${fragment === undefined ? '' : `#${fragment}`}`;\n}\n"],"mappings":";AACA,IAAa,IAAqB;CAAC;CAAO;CAAa;CAAW;AAAQ;AAiB1E,SAAgB,EACd,GACA,GACQ;CACR,IAAM,IAAY,EAAK,QAAQ,GAAG,GAC5B,IAAa,MAAc,KAAK,IAAO,EAAK,MAAM,GAAG,CAAS,GAC9D,IAAW,MAAc,KAAK,KAAA,IAAY,EAAK,MAAM,IAAY,CAAC,GAClE,IAAa,EAAW,QAAQ,GAAG,GACnC,IAAW,MAAe,KAAK,IAAa,EAAW,MAAM,GAAG,CAAU,GAC1E,IAAgB,MAAe,KAAK,KAAK,EAAW,MAAM,IAAa,CAAC,GAExE,IAAgB,EAAQ,KAAK,MAAW,IAAI,gBAAgB,KAAU,EAAE,CAAC,GACzE,IAAU,IAAI,gBAAgB,CAAa;CACjD,KAAK,IAAM,KAAO,GAChB,KAAK,IAAM,KAAU,GAAe;EAClC,IAAM,IAAQ,EAAO,IAAI,CAAG;EAC5B,IAAI,GAAO;GACT,EAAQ,IAAI,GAAK,CAAK;GACtB;EACF;CACF;CAEF,IAAM,IAAQ,EAAQ,SAAS;CAC/B,OAAO,GAAG,IAAW,IAAQ,IAAI,MAAU,KAAK,MAAa,KAAA,IAAY,KAAK,IAAI;AACpF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useContextNavigation.d.ts","sourceRoot":"","sources":["../../../src/coolandlovely/hooks/useContextNavigation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useContextNavigation.d.ts","sourceRoot":"","sources":["../../../src/coolandlovely/hooks/useContextNavigation.ts"],"names":[],"mappings":"AAUA,wFAAwF;AACxF,wBAAgB,oBAAoB,WAKzB,MAAM,8BAOhB"}
|
|
@@ -1,31 +1,25 @@
|
|
|
1
1
|
import { useCoolAndLovely as e } from "../context/CoolAndLovelyContext.js";
|
|
2
2
|
import "../context/index.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { buildContextNavigationTarget as t } from "./contextNavigationTarget.js";
|
|
4
|
+
import { useCallback as n } from "react";
|
|
5
|
+
import { useLocation as r, useNavigate as i } from "react-router";
|
|
5
6
|
//#region src/coolandlovely/hooks/useContextNavigation.ts
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"tenant"
|
|
15
|
-
]) {
|
|
16
|
-
let t = n.get(e);
|
|
17
|
-
t && d.set(e, t);
|
|
18
|
-
}
|
|
19
|
-
let f = `${l}${d.size ? `?${d}` : ""}${c === void 0 ? "" : `#${c}`}`;
|
|
20
|
-
t ? (a ?? o)(f) : i(f);
|
|
7
|
+
function a() {
|
|
8
|
+
return typeof window > "u" ? null : window.location.search;
|
|
9
|
+
}
|
|
10
|
+
function o() {
|
|
11
|
+
let { navigateTo: o, navigate: s } = e(), c = i(), { search: l } = r();
|
|
12
|
+
return n((e, n = !1) => {
|
|
13
|
+
let r = t(e, [a(), l]);
|
|
14
|
+
n ? (s ?? c)(r) : o(r);
|
|
21
15
|
}, [
|
|
22
|
-
i,
|
|
23
|
-
a,
|
|
24
16
|
o,
|
|
25
|
-
s
|
|
17
|
+
s,
|
|
18
|
+
c,
|
|
19
|
+
l
|
|
26
20
|
]);
|
|
27
21
|
}
|
|
28
22
|
//#endregion
|
|
29
|
-
export {
|
|
23
|
+
export { o as useContextNavigation };
|
|
30
24
|
|
|
31
25
|
//# sourceMappingURL=useContextNavigation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useContextNavigation.js","names":[],"sources":["../../../src/coolandlovely/hooks/useContextNavigation.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useLocation, useNavigate } from 'react-router';\nimport { useCoolAndLovely } from '../context';\n\n/** Preserve the host's selected context when entering or leaving a marketplace flow. */\nexport function useContextNavigation() {\n const { navigateTo, navigate } = useCoolAndLovely();\n const routerNavigate = useNavigate();\n const { search } = useLocation();\n return useCallback(\n (path: string, absolute = false) => {\n const
|
|
1
|
+
{"version":3,"file":"useContextNavigation.js","names":[],"sources":["../../../src/coolandlovely/hooks/useContextNavigation.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useLocation, useNavigate } from 'react-router';\nimport { useCoolAndLovely } from '../context';\nimport { buildContextNavigationTarget } from './contextNavigationTarget';\n\n/** Read the live address-bar query at click time, outside the router's snapshot. */\nfunction liveWindowSearch(): string | null {\n return typeof window === 'undefined' ? null : window.location.search;\n}\n\n/** Preserve the host's selected context when entering or leaving a marketplace flow. */\nexport function useContextNavigation() {\n const { navigateTo, navigate } = useCoolAndLovely();\n const routerNavigate = useNavigate();\n const { search } = useLocation();\n return useCallback(\n (path: string, absolute = false) => {\n const target = buildContextNavigationTarget(path, [liveWindowSearch(), search]);\n if (absolute) (navigate ?? routerNavigate)(target);\n else navigateTo(target);\n },\n [navigateTo, navigate, routerNavigate, search]\n );\n}\n"],"mappings":";;;;;;AAMA,SAAS,IAAkC;CACzC,OAAO,OAAO,SAAW,MAAc,OAAO,OAAO,SAAS;AAChE;AAGA,SAAgB,IAAuB;CACrC,IAAM,EAAE,eAAY,gBAAa,EAAiB,GAC5C,IAAiB,EAAY,GAC7B,EAAE,cAAW,EAAY;CAC/B,OAAO,GACJ,GAAc,IAAW,OAAU;EAClC,IAAM,IAAS,EAA6B,GAAM,CAAC,EAAiB,GAAG,CAAM,CAAC;EAC9E,AAAI,KAAW,KAAY,EAAA,CAAgB,CAAM,IAC5C,EAAW,CAAM;CACxB,GACA;EAAC;EAAY;EAAU;EAAgB;CAAM,CAC/C;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@burdenoff/microfe-coolandlovely",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.1107.1",
|
|
4
4
|
"description": "Burdenoff CoolAndLovely Microfrontend",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"lint:sanity": "if [ \"${CI:-}\" = \"true\" ]; then bun run lint; else bun run lint -- --cache --cache-location .eslintcache; fi",
|
|
35
35
|
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
36
36
|
"type:check": "bash scripts/build-limits.sh tsc --noEmit",
|
|
37
|
-
"sanity": "bash scripts/build-limits.sh --gate bash -c 'bun run codegen && bun run test:dependency-compat && bun run test:price-inputs && bun run test:query-scope && bun run lint:sanity && bun run format && bun run type:check && bun run build'",
|
|
37
|
+
"sanity": "bash scripts/build-limits.sh --gate bash -c 'bun run codegen && bun run test:dependency-compat && bun run test:price-inputs && bun run test:query-scope && bun run test:context-navigation && bun run lint:sanity && bun run format && bun run type:check && bun run build'",
|
|
38
38
|
"storybook": "storybook dev -p 6006",
|
|
39
39
|
"build-storybook": "storybook build",
|
|
40
40
|
"test:storybook": "test-storybook",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"format:check": "prettier --check \"src/**/*.{ts,tsx}\"",
|
|
48
48
|
"test:dependency-compat": "bun test scripts/tests/schema-loader.compatibility.test.ts",
|
|
49
49
|
"test:query-scope": "bun test src/coolandlovely/context/__tests__/QueryScope.test.tsx",
|
|
50
|
+
"test:context-navigation": "bun test src/coolandlovely/hooks/__tests__",
|
|
50
51
|
"test:price-inputs": "bun test src/coolandlovely/components/prices/__tests__"
|
|
51
52
|
},
|
|
52
53
|
"dependencies": {
|