@sybilion/uilib 1.4.36 → 1.4.40
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 +2 -0
- package/dist/agent-glossary/workspace.generated.ts +1 -0
- package/dist/agent-glossary/workspace.index.md +1 -0
- package/dist/agent-glossary/workspace.md +1 -0
- package/dist/esm/src/components/ui/AppHeader/AppHeader.styl.js +1 -1
- package/dist/esm/src/components/ui/Banner/Banner.styl.js +1 -1
- package/dist/esm/src/components/ui/Card/Card.styl.js +1 -1
- package/dist/esm/src/components/ui/Chart/Chart.js +1 -2
- package/dist/esm/src/components/ui/Chip/Chip.js +9 -2
- package/dist/esm/src/components/ui/Chip/Chip.styl.js +2 -2
- package/dist/esm/src/components/ui/Dialog/Dialog.styl.js +1 -1
- package/dist/esm/src/components/ui/Drawer/Drawer.styl.js +1 -1
- package/dist/esm/src/components/ui/DropdownMenu/DropdownMenu.styl.js +1 -1
- package/dist/esm/src/components/ui/Input/Input.styl.js +1 -1
- package/dist/esm/src/components/ui/Logo/Logo.styl.js +1 -1
- package/dist/esm/src/components/ui/MobileAdaptiveSelector/MobileAdaptiveSelector.styl.js +1 -1
- package/dist/esm/src/components/ui/Page/PageHeader/PageHeader.styl.js +1 -1
- package/dist/esm/src/components/ui/Page/PageTabs/PageTabs.styl.js +1 -1
- package/dist/esm/src/components/ui/Select/Select.js +314 -6
- package/dist/esm/src/components/ui/Select/Select.styl.js +2 -2
- package/dist/esm/src/components/ui/Sheet/Sheet.styl.js +1 -1
- package/dist/esm/src/components/ui/SupplyChainMap/SupplyChainMap.js +384 -0
- package/dist/esm/src/components/ui/SupplyChainMap/SupplyChainMap.styl.js +7 -0
- package/dist/esm/src/components/ui/SupplyChainMap/map-colors.js +44 -0
- package/dist/esm/src/components/ui/SupplyChainMap/map-disclosure.js +142 -0
- package/dist/esm/src/components/ui/SupplyChainMap/map-labels.js +55 -0
- package/dist/esm/src/components/ui/SupplyChainMap/map-projection.js +186 -0
- package/dist/esm/src/components/ui/SupplyChainMap/supply-chain-map-clusters.js +96 -0
- package/dist/esm/src/components/ui/SupplyChainMap/supply-chain-map-draw.js +66 -0
- package/dist/esm/src/components/ui/SupplyChainMap/supply-chain-map-scene.js +59 -0
- package/dist/esm/src/components/ui/SupplyChainMap/supply-chain-map-types.js +10 -0
- package/dist/esm/src/components/ui/SupplyChainMap/use-map-base-renderer.js +122 -0
- package/dist/esm/src/components/ui/Table/Table.styl.js +1 -1
- package/dist/esm/src/components/ui/Tabs/Tabs.styl.js +1 -1
- package/dist/esm/src/components/ui/Tooltip/Tooltip.styl.js +1 -1
- package/dist/esm/src/components/widgets/DriverCard/DriverPerformanceChart.js +1 -2
- package/dist/esm/src/components/widgets/SybilionAppHeader/SybilionAppHeader.styl.js +1 -1
- package/dist/esm/src/index.js +2 -0
- package/dist/esm/types/src/components/ui/Chip/Chip.d.ts +1 -1
- package/dist/esm/types/src/components/ui/Chip/Chip.types.d.ts +2 -0
- package/dist/esm/types/src/components/ui/Chip/index.d.ts +1 -1
- package/dist/esm/types/src/components/ui/Select/Select.d.ts +3 -3
- package/dist/esm/types/src/components/ui/Select/Select.types.d.ts +3 -1
- package/dist/esm/types/src/components/ui/SupplyChainMap/SupplyChainMap.contract.test.d.ts +1 -0
- package/dist/esm/types/src/components/ui/SupplyChainMap/SupplyChainMap.d.ts +2 -0
- package/dist/esm/types/src/components/ui/SupplyChainMap/SupplyChainMap.example.d.ts +1 -0
- package/dist/esm/types/src/components/ui/SupplyChainMap/SupplyChainMap.render.worker.d.ts +15 -0
- package/dist/esm/types/src/components/ui/SupplyChainMap/SupplyChainMap.types.d.ts +10 -0
- package/dist/esm/types/src/components/ui/SupplyChainMap/index.d.ts +3 -0
- package/dist/esm/types/src/components/ui/SupplyChainMap/map-colors.d.ts +43 -0
- package/dist/esm/types/src/components/ui/SupplyChainMap/map-disclosure.d.ts +35 -0
- package/dist/esm/types/src/components/ui/SupplyChainMap/map-disclosure.test.d.ts +1 -0
- package/dist/esm/types/src/components/ui/SupplyChainMap/map-labels.d.ts +14 -0
- package/dist/esm/types/src/components/ui/SupplyChainMap/map-labels.test.d.ts +1 -0
- package/dist/esm/types/src/components/ui/SupplyChainMap/map-projection.d.ts +83 -0
- package/dist/esm/types/src/components/ui/SupplyChainMap/map-projection.test.d.ts +1 -0
- package/dist/esm/types/src/components/ui/SupplyChainMap/supply-chain-map-clusters.d.ts +25 -0
- package/dist/esm/types/src/components/ui/SupplyChainMap/supply-chain-map-clusters.test.d.ts +1 -0
- package/dist/esm/types/src/components/ui/SupplyChainMap/supply-chain-map-draw.d.ts +30 -0
- package/dist/esm/types/src/components/ui/SupplyChainMap/supply-chain-map-scene.d.ts +28 -0
- package/dist/esm/types/src/components/ui/SupplyChainMap/supply-chain-map-scene.test.d.ts +1 -0
- package/dist/esm/types/src/components/ui/SupplyChainMap/supply-chain-map-types.d.ts +31 -0
- package/dist/esm/types/src/components/ui/SupplyChainMap/use-map-base-renderer.d.ts +14 -0
- package/dist/esm/types/src/docs/pages/BannerPage.d.ts +1 -0
- package/dist/esm/types/src/docs/pages/SupplyChainMapPage.d.ts +1 -0
- package/dist/esm/types/src/index.d.ts +1 -0
- package/dist/esm/types/src/lib/logger.d.ts +1 -0
- package/package.json +7 -1
- package/src/components/ui/AppHeader/AppHeader.styl +2 -2
- package/src/components/ui/Banner/Banner.styl +1 -1
- package/src/components/ui/Card/Card.styl +3 -1
- package/src/components/ui/Chip/AGENT.md +1 -1
- package/src/components/ui/Chip/Chip.styl +66 -6
- package/src/components/ui/Chip/Chip.styl.d.ts +4 -0
- package/src/components/ui/Chip/Chip.tsx +15 -1
- package/src/components/ui/Chip/Chip.types.ts +3 -0
- package/src/components/ui/Chip/index.ts +1 -1
- package/src/components/ui/Dialog/Dialog.styl +2 -2
- package/src/components/ui/Drawer/Drawer.styl +2 -2
- package/src/components/ui/DropdownMenu/DropdownMenu.styl +2 -2
- package/src/components/ui/Input/Input.styl +9 -13
- package/src/components/ui/Logo/Logo.styl +1 -1
- package/src/components/ui/MobileAdaptiveSelector/MobileAdaptiveSelector.styl +1 -1
- package/src/components/ui/Page/PageHeader/PageHeader.styl +1 -1
- package/src/components/ui/Page/PageTabs/PageTabs.styl +3 -0
- package/src/components/ui/Select/AGENT.md +3 -1
- package/src/components/ui/Select/Select.styl +38 -6
- package/src/components/ui/Select/Select.styl.d.ts +28 -25
- package/src/components/ui/Select/Select.tsx +512 -5
- package/src/components/ui/Select/Select.types.ts +3 -1
- package/src/components/ui/Sheet/Sheet.styl +2 -2
- package/src/components/ui/SupplyChainMap/AGENT.md +45 -0
- package/src/components/ui/SupplyChainMap/SupplyChainMap.contract.test.ts +45 -0
- package/src/components/ui/SupplyChainMap/SupplyChainMap.example.tsx +176 -0
- package/src/components/ui/SupplyChainMap/SupplyChainMap.render.worker.ts +63 -0
- package/src/components/ui/SupplyChainMap/SupplyChainMap.styl +221 -0
- package/src/components/ui/SupplyChainMap/SupplyChainMap.styl.d.ts +25 -0
- package/src/components/ui/SupplyChainMap/SupplyChainMap.tsx +720 -0
- package/src/components/ui/SupplyChainMap/SupplyChainMap.types.ts +15 -0
- package/src/components/ui/SupplyChainMap/index.ts +11 -0
- package/src/components/ui/SupplyChainMap/map-colors.ts +66 -0
- package/src/components/ui/SupplyChainMap/map-disclosure.test.ts +237 -0
- package/src/components/ui/SupplyChainMap/map-disclosure.ts +226 -0
- package/src/components/ui/SupplyChainMap/map-labels.test.ts +102 -0
- package/src/components/ui/SupplyChainMap/map-labels.ts +85 -0
- package/src/components/ui/SupplyChainMap/map-projection.test.ts +172 -0
- package/src/components/ui/SupplyChainMap/map-projection.ts +281 -0
- package/src/components/ui/SupplyChainMap/supply-chain-map-clusters.test.ts +182 -0
- package/src/components/ui/SupplyChainMap/supply-chain-map-clusters.ts +127 -0
- package/src/components/ui/SupplyChainMap/supply-chain-map-draw.ts +114 -0
- package/src/components/ui/SupplyChainMap/supply-chain-map-scene.test.ts +196 -0
- package/src/components/ui/SupplyChainMap/supply-chain-map-scene.ts +118 -0
- package/src/components/ui/SupplyChainMap/supply-chain-map-types.ts +45 -0
- package/src/components/ui/SupplyChainMap/use-map-base-renderer.ts +145 -0
- package/src/components/ui/Table/Table.styl +4 -3
- package/src/components/ui/Tabs/Tabs.styl +4 -0
- package/src/components/ui/Tooltip/Tooltip.styl +7 -2
- package/src/components/widgets/SybilionAppHeader/SybilionAppHeader.styl +4 -4
- package/src/declarations.d.ts +4 -0
- package/src/docs/pages/BannerPage.tsx +83 -0
- package/src/docs/pages/ChipPage.tsx +20 -1
- package/src/docs/pages/FeedbackOverviewPage.tsx +7 -1
- package/src/docs/pages/SelectPage.tsx +30 -1
- package/src/docs/pages/SupplyChainMapPage.tsx +21 -0
- package/src/docs/registry.ts +12 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { type GeoProjection, geoNaturalEarth1 } from 'd3-geo';
|
|
2
|
+
|
|
3
|
+
import type { EntityGeo, MapEdge, MapEntity } from './supply-chain-map-types';
|
|
4
|
+
|
|
5
|
+
export type MapSceneNode = {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
type: string;
|
|
9
|
+
lat: number;
|
|
10
|
+
lng: number;
|
|
11
|
+
precision?: EntityGeo['precision'];
|
|
12
|
+
place?: string;
|
|
13
|
+
country?: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type MapSceneArc = {
|
|
17
|
+
id: string;
|
|
18
|
+
fromEntity: string;
|
|
19
|
+
toEntity: string;
|
|
20
|
+
relation: string;
|
|
21
|
+
from: [number, number];
|
|
22
|
+
to: [number, number];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type SupplyChainMapScene = {
|
|
26
|
+
nodes: MapSceneNode[];
|
|
27
|
+
arcs: MapSceneArc[];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function isValidCoordinate(lat: number, lng: number): boolean {
|
|
31
|
+
return (
|
|
32
|
+
Number.isFinite(lat) &&
|
|
33
|
+
Number.isFinite(lng) &&
|
|
34
|
+
lat >= -90 &&
|
|
35
|
+
lat <= 90 &&
|
|
36
|
+
lng >= -180 &&
|
|
37
|
+
lng <= 180
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function buildConfirmedMapScene(
|
|
42
|
+
entities: readonly MapEntity[],
|
|
43
|
+
edges: readonly MapEdge[],
|
|
44
|
+
): SupplyChainMapScene {
|
|
45
|
+
const nodes = entities.flatMap<MapSceneNode>(entity => {
|
|
46
|
+
const geo = entity.geo;
|
|
47
|
+
if (
|
|
48
|
+
entity.status !== 'confirmed' ||
|
|
49
|
+
!geo ||
|
|
50
|
+
!isValidCoordinate(geo.lat, geo.lng)
|
|
51
|
+
) {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
return [
|
|
55
|
+
{
|
|
56
|
+
id: entity.id,
|
|
57
|
+
name: entity.name,
|
|
58
|
+
type: entity.type,
|
|
59
|
+
lat: geo.lat,
|
|
60
|
+
lng: geo.lng,
|
|
61
|
+
precision: geo.precision,
|
|
62
|
+
place: geo.place,
|
|
63
|
+
country: geo.country,
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
});
|
|
67
|
+
const nodesById = new Map(nodes.map(node => [node.id, node]));
|
|
68
|
+
const arcs = edges.flatMap<MapSceneArc>(edge => {
|
|
69
|
+
if (edge.status !== 'confirmed') return [];
|
|
70
|
+
const from = nodesById.get(edge.from_entity);
|
|
71
|
+
const to = nodesById.get(edge.to_entity);
|
|
72
|
+
if (!from || !to) return [];
|
|
73
|
+
return [
|
|
74
|
+
{
|
|
75
|
+
id: edge.id,
|
|
76
|
+
fromEntity: from.id,
|
|
77
|
+
toEntity: to.id,
|
|
78
|
+
relation: edge.relation,
|
|
79
|
+
from: [from.lng, from.lat],
|
|
80
|
+
to: [to.lng, to.lat],
|
|
81
|
+
},
|
|
82
|
+
];
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
return { nodes, arcs };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function resolveMapSelection(
|
|
89
|
+
selected: MapSceneNode | null,
|
|
90
|
+
nodes: readonly MapSceneNode[],
|
|
91
|
+
): MapSceneNode | null {
|
|
92
|
+
if (!selected) return null;
|
|
93
|
+
return nodes.find(node => node.id === selected.id) ?? null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function projectNaturalEarthPoint(
|
|
97
|
+
coordinates: [number, number],
|
|
98
|
+
width: number,
|
|
99
|
+
height: number,
|
|
100
|
+
padding = 12,
|
|
101
|
+
): [number, number] | null {
|
|
102
|
+
if (width <= 0 || height <= 0) return null;
|
|
103
|
+
return createNaturalEarthProjection(width, height, padding)(coordinates);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function createNaturalEarthProjection(
|
|
107
|
+
width: number,
|
|
108
|
+
height: number,
|
|
109
|
+
padding = 12,
|
|
110
|
+
): GeoProjection {
|
|
111
|
+
return geoNaturalEarth1().fitExtent(
|
|
112
|
+
[
|
|
113
|
+
[padding, padding],
|
|
114
|
+
[width - padding, height - padding],
|
|
115
|
+
],
|
|
116
|
+
{ type: 'Sphere' },
|
|
117
|
+
);
|
|
118
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Minimal graph types the map needs. Compatible with onboarding Entity/Edge. */
|
|
2
|
+
|
|
3
|
+
export type GraphStatus = 'draft' | 'confirmed' | 'rejected';
|
|
4
|
+
|
|
5
|
+
export type GeoPrecision = 'city' | 'region' | 'country';
|
|
6
|
+
|
|
7
|
+
export type EntityGeo = {
|
|
8
|
+
lat: number;
|
|
9
|
+
lng: number;
|
|
10
|
+
precision: GeoPrecision;
|
|
11
|
+
place?: string;
|
|
12
|
+
country?: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type MapEntity = {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
type: string;
|
|
19
|
+
status: GraphStatus;
|
|
20
|
+
geo?: EntityGeo | null;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type MapEdge = {
|
|
24
|
+
id: string;
|
|
25
|
+
from_entity: string;
|
|
26
|
+
to_entity: string;
|
|
27
|
+
relation: string;
|
|
28
|
+
status: GraphStatus;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/** Optional dimming overlay. Compatible with cascade-overlay CascadeOverlay. */
|
|
32
|
+
export type MapCascadeOverlay = {
|
|
33
|
+
pathIds: string[];
|
|
34
|
+
onPathIds: Set<string>;
|
|
35
|
+
laneIds: Set<string>;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export function activeMapCascade(
|
|
39
|
+
overlay: MapCascadeOverlay | undefined | null,
|
|
40
|
+
): MapCascadeOverlay | undefined {
|
|
41
|
+
if (!overlay) return undefined;
|
|
42
|
+
return overlay.onPathIds.size > 0 || overlay.laneIds.size > 0
|
|
43
|
+
? overlay
|
|
44
|
+
: undefined;
|
|
45
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { type RefObject, useEffect, useRef, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { MapWorkerIn, MapWorkerOut } from './SupplyChainMap.render.worker';
|
|
4
|
+
import {
|
|
5
|
+
type MapDrawCommand,
|
|
6
|
+
type MapHitLane,
|
|
7
|
+
paintSupplyChainMap,
|
|
8
|
+
resizeMapCanvas,
|
|
9
|
+
} from './supply-chain-map-draw';
|
|
10
|
+
|
|
11
|
+
export type MapRendererMode = 'pending' | 'worker' | 'main';
|
|
12
|
+
|
|
13
|
+
function canUseOffscreenWorker(canvas: HTMLCanvasElement): boolean {
|
|
14
|
+
return (
|
|
15
|
+
typeof Worker !== 'undefined' &&
|
|
16
|
+
typeof OffscreenCanvas !== 'undefined' &&
|
|
17
|
+
typeof canvas.transferControlToOffscreen === 'function'
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function paintOnMain(
|
|
22
|
+
canvas: HTMLCanvasElement,
|
|
23
|
+
command: MapDrawCommand,
|
|
24
|
+
): MapHitLane[] {
|
|
25
|
+
resizeMapCanvas(canvas, command.width, command.height, command.dpr);
|
|
26
|
+
const ctx = canvas.getContext('2d');
|
|
27
|
+
if (!ctx) return [];
|
|
28
|
+
return paintSupplyChainMap(ctx, command);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Paints the basemap (land / ocean / graticule / arcs) on an OffscreenCanvas in
|
|
33
|
+
* a Worker when the browser allows it, so projection and rasterization do not
|
|
34
|
+
* hitch the main thread during pan/zoom. Falls back to the same paint path on
|
|
35
|
+
* the main thread. `canvasKey` must be set on the <canvas> so a transferred
|
|
36
|
+
* canvas can be replaced if we drop back to main-thread painting.
|
|
37
|
+
*/
|
|
38
|
+
export function useMapBaseRenderer(
|
|
39
|
+
canvasRef: RefObject<HTMLCanvasElement | null>,
|
|
40
|
+
command: MapDrawCommand | null,
|
|
41
|
+
onHitLanes: (lanes: MapHitLane[]) => void,
|
|
42
|
+
enabled = true,
|
|
43
|
+
): { mode: MapRendererMode; canvasKey: number } {
|
|
44
|
+
const [mode, setMode] = useState<MapRendererMode>('pending');
|
|
45
|
+
const [canvasKey, setCanvasKey] = useState(0);
|
|
46
|
+
const forceMainRef = useRef(false);
|
|
47
|
+
const ownsCanvasRef = useRef(true);
|
|
48
|
+
const workerRef = useRef<Worker | null>(null);
|
|
49
|
+
const onHitLanesRef = useRef(onHitLanes);
|
|
50
|
+
onHitLanesRef.current = onHitLanes;
|
|
51
|
+
const commandRef = useRef(command);
|
|
52
|
+
commandRef.current = command;
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
ownsCanvasRef.current = true;
|
|
56
|
+
if (!enabled) {
|
|
57
|
+
setMode('pending');
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const canvas = canvasRef.current;
|
|
61
|
+
if (!canvas || forceMainRef.current || !canUseOffscreenWorker(canvas)) {
|
|
62
|
+
setMode('main');
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let worker: Worker;
|
|
67
|
+
try {
|
|
68
|
+
// Bundlers (webpack docs, Vite, Next) resolve this worker entry.
|
|
69
|
+
// Published Rollup output may keep a .ts URL — paint then falls back
|
|
70
|
+
// to the main-thread path below.
|
|
71
|
+
worker = new Worker(
|
|
72
|
+
new URL('./SupplyChainMap.render.worker.ts', import.meta.url),
|
|
73
|
+
);
|
|
74
|
+
} catch {
|
|
75
|
+
forceMainRef.current = true;
|
|
76
|
+
setMode('main');
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const remountOnMain = () => {
|
|
81
|
+
worker.terminate();
|
|
82
|
+
workerRef.current = null;
|
|
83
|
+
if (forceMainRef.current && !ownsCanvasRef.current) return;
|
|
84
|
+
forceMainRef.current = true;
|
|
85
|
+
ownsCanvasRef.current = false;
|
|
86
|
+
setMode('main');
|
|
87
|
+
setCanvasKey(n => n + 1);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
try {
|
|
91
|
+
const offscreen = canvas.transferControlToOffscreen();
|
|
92
|
+
ownsCanvasRef.current = false;
|
|
93
|
+
const init: MapWorkerIn = { type: 'init', canvas: offscreen };
|
|
94
|
+
worker.postMessage(init, [offscreen]);
|
|
95
|
+
} catch {
|
|
96
|
+
worker.terminate();
|
|
97
|
+
workerRef.current = null;
|
|
98
|
+
forceMainRef.current = true;
|
|
99
|
+
ownsCanvasRef.current = false;
|
|
100
|
+
setMode('main');
|
|
101
|
+
setCanvasKey(n => n + 1);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
worker.onmessage = (event: MessageEvent<MapWorkerOut>) => {
|
|
106
|
+
if (event.data.type === 'hitLanes') {
|
|
107
|
+
onHitLanesRef.current(event.data.lanes);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
remountOnMain();
|
|
111
|
+
};
|
|
112
|
+
workerRef.current = worker;
|
|
113
|
+
setMode('worker');
|
|
114
|
+
|
|
115
|
+
const latest = commandRef.current;
|
|
116
|
+
if (latest) {
|
|
117
|
+
const draw: MapWorkerIn = { type: 'draw', command: latest };
|
|
118
|
+
worker.postMessage(draw);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return () => {
|
|
122
|
+
worker.terminate();
|
|
123
|
+
workerRef.current = null;
|
|
124
|
+
};
|
|
125
|
+
}, [canvasRef, canvasKey, enabled]);
|
|
126
|
+
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
if (!command || mode === 'pending') return;
|
|
129
|
+
const worker = workerRef.current;
|
|
130
|
+
if (mode === 'worker' && worker) {
|
|
131
|
+
const draw: MapWorkerIn = { type: 'draw', command };
|
|
132
|
+
worker.postMessage(draw);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const canvas = canvasRef.current;
|
|
136
|
+
if (!canvas || mode !== 'main' || !ownsCanvasRef.current) return;
|
|
137
|
+
try {
|
|
138
|
+
onHitLanesRef.current(paintOnMain(canvas, command));
|
|
139
|
+
} catch {
|
|
140
|
+
ownsCanvasRef.current = false;
|
|
141
|
+
}
|
|
142
|
+
}, [canvasRef, canvasKey, command, mode]);
|
|
143
|
+
|
|
144
|
+
return { mode, canvasKey };
|
|
145
|
+
}
|
|
@@ -81,12 +81,12 @@
|
|
|
81
81
|
// .withBackground &
|
|
82
82
|
// border-top 1px solid var(--border)
|
|
83
83
|
|
|
84
|
-
tr:
|
|
85
|
-
border-
|
|
84
|
+
tr:first-child
|
|
85
|
+
border-top 1px solid var(--border)
|
|
86
86
|
|
|
87
87
|
.tableRow
|
|
88
88
|
position relative
|
|
89
|
-
border-
|
|
89
|
+
border-top 1px solid var(--border)
|
|
90
90
|
transition-property background-color, color, border-color, text-decoration-color, fill, stroke
|
|
91
91
|
transition-timing-function cubic-bezier(0.4, 0, 0.2, 1)
|
|
92
92
|
transition-duration 150ms
|
|
@@ -98,6 +98,7 @@
|
|
|
98
98
|
border-bottom-right-radius var(--p-3)
|
|
99
99
|
|
|
100
100
|
.tableBody &:hover
|
|
101
|
+
.tableBody &:focus-within
|
|
101
102
|
&[data-state="selected"]
|
|
102
103
|
background-color var(--muted-50)
|
|
103
104
|
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
.variant-link > &
|
|
19
19
|
background-color transparent !important
|
|
20
|
+
box-shadow inset 0 -2px 0 0px var(--border)
|
|
20
21
|
|
|
21
22
|
.variant-button &
|
|
22
23
|
.variant-outline &
|
|
@@ -143,6 +144,9 @@
|
|
|
143
144
|
flex 1
|
|
144
145
|
outline none
|
|
145
146
|
|
|
147
|
+
&[hidden]
|
|
148
|
+
display none !important
|
|
149
|
+
|
|
146
150
|
// Sizes (md = default styles above)
|
|
147
151
|
.root
|
|
148
152
|
&.variant-button
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
@import '../../../lib/theme.styl';
|
|
2
2
|
|
|
3
|
+
// Radix Popper wraps Content with inline z-index:auto. Content z-index does
|
|
4
|
+
// not compete with sticky AppHeader (100); the wrapper must carry the layer.
|
|
5
|
+
:global([data-radix-popper-content-wrapper]:has([data-slot='tooltip-content']))
|
|
6
|
+
z-index 1100 !important
|
|
7
|
+
|
|
3
8
|
.tooltipContent
|
|
4
|
-
z-index
|
|
9
|
+
z-index 1100
|
|
5
10
|
width fit-content
|
|
6
11
|
min-width 100%
|
|
7
12
|
padding 6px 12px
|
|
@@ -72,7 +77,7 @@
|
|
|
72
77
|
animation fade-out 0.1s ease-in
|
|
73
78
|
|
|
74
79
|
.tooltipArrow
|
|
75
|
-
z-index
|
|
80
|
+
z-index 1100
|
|
76
81
|
width 10px
|
|
77
82
|
height 10px
|
|
78
83
|
transform translateY(calc(-50% + .5px)) rotate(45deg)
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
.logoArea
|
|
19
19
|
position absolute
|
|
20
20
|
top 22px
|
|
21
|
-
left
|
|
21
|
+
left 28px
|
|
22
22
|
z-index 10
|
|
23
23
|
|
|
24
24
|
display flex
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
gap var(--p-2)
|
|
27
27
|
|
|
28
28
|
@media (max-width MOBILE)
|
|
29
|
-
left
|
|
29
|
+
left 16px
|
|
30
30
|
|
|
31
31
|
// Top-level shell + expanded sidebar: fixed logo when header scrolls; absolute when header is sticky.
|
|
32
32
|
@media (min-width MOBILE)
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
|
|
38
38
|
:global([data-slot='sidebar-wrapper'][data-state='expanded']:not([data-slot='app-shell'] [data-slot='sidebar-wrapper']) [data-slot='app-shell']:not([data-slot='app-shell'] [data-slot='app-shell'])) :global(header[data-sticky='true']) &:global(:not([data-slot='app-shell'] [data-slot='app-shell'] *))
|
|
39
39
|
position absolute
|
|
40
|
-
left calc(-1 * var(--sidebar-width) +
|
|
40
|
+
left calc(-1 * var(--sidebar-width) + 40px)
|
|
41
41
|
|
|
42
42
|
// Nested shell (e.g. docs embed): absolute within header; offset into sidebar when expanded.
|
|
43
43
|
:global([data-slot='app-shell'] [data-slot='sidebar-wrapper'][data-state='expanded'] [data-slot='app-shell']) &
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
|
|
57
57
|
font-weight 400
|
|
58
58
|
font-size 1.5rem
|
|
59
|
-
color var(--
|
|
59
|
+
color var(--foreground)
|
|
60
60
|
text-decoration none
|
|
61
61
|
white-space nowrap
|
|
62
62
|
|
package/src/declarations.d.ts
CHANGED
|
@@ -4,6 +4,10 @@ declare const DOCS_ROUTER_BASENAME: string;
|
|
|
4
4
|
|
|
5
5
|
declare module '*.png';
|
|
6
6
|
declare module '*.json';
|
|
7
|
+
declare module 'world-atlas/countries-110m.json' {
|
|
8
|
+
const value: unknown;
|
|
9
|
+
export default value;
|
|
10
|
+
}
|
|
7
11
|
|
|
8
12
|
declare module '*.svg' {
|
|
9
13
|
import type { FC, SVGProps } from 'react';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Banner } from '#uilib/components/ui/Banner';
|
|
4
|
+
import { Button } from '#uilib/components/ui/Button';
|
|
5
|
+
import { PageContentSection } from '#uilib/components/ui/Page';
|
|
6
|
+
import { AlertTriangleIcon } from 'lucide-react';
|
|
7
|
+
|
|
8
|
+
import { AppPageHeader } from '../components/AppPageHeader/AppPageHeader';
|
|
9
|
+
import { DocsHeaderActions } from '../docsHeaderActions';
|
|
10
|
+
|
|
11
|
+
export default function BannerPage() {
|
|
12
|
+
const [dismissed, setDismissed] = useState(false);
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<>
|
|
16
|
+
<AppPageHeader
|
|
17
|
+
breadcrumbs={[{ label: 'Banner' }]}
|
|
18
|
+
title="Banner"
|
|
19
|
+
subheader="Inline notice with optional icon and dismiss control."
|
|
20
|
+
actions={<DocsHeaderActions />}
|
|
21
|
+
/>
|
|
22
|
+
<PageContentSection
|
|
23
|
+
style={{ display: 'flex', flexDirection: 'column', gap: '2rem' }}
|
|
24
|
+
>
|
|
25
|
+
<section>
|
|
26
|
+
<h3 style={{ marginBottom: '1rem' }}>Default</h3>
|
|
27
|
+
<p
|
|
28
|
+
style={{
|
|
29
|
+
marginBottom: '0.75rem',
|
|
30
|
+
color: 'var(--muted-foreground)',
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
Defaults to <code>InfoIcon</code>. Children can include text and
|
|
34
|
+
links.
|
|
35
|
+
</p>
|
|
36
|
+
<Banner>
|
|
37
|
+
Forecast refresh completed.{' '}
|
|
38
|
+
<a href="#banner">View latest signals</a>
|
|
39
|
+
</Banner>
|
|
40
|
+
</section>
|
|
41
|
+
<section>
|
|
42
|
+
<h3 style={{ marginBottom: '1rem' }}>Custom icon</h3>
|
|
43
|
+
<Banner icon={AlertTriangleIcon}>
|
|
44
|
+
Quota is almost reached. Upgrade before the next billing cycle.
|
|
45
|
+
</Banner>
|
|
46
|
+
</section>
|
|
47
|
+
<section>
|
|
48
|
+
<h3 style={{ marginBottom: '1rem' }}>No icon</h3>
|
|
49
|
+
<p
|
|
50
|
+
style={{
|
|
51
|
+
marginBottom: '0.75rem',
|
|
52
|
+
color: 'var(--muted-foreground)',
|
|
53
|
+
}}
|
|
54
|
+
>
|
|
55
|
+
Pass <code>{'icon={false}'}</code> to hide the leading icon.
|
|
56
|
+
</p>
|
|
57
|
+
<Banner icon={false}>Session expires in 15 minutes.</Banner>
|
|
58
|
+
</section>
|
|
59
|
+
<section>
|
|
60
|
+
<h3 style={{ marginBottom: '1rem' }}>Dismissible</h3>
|
|
61
|
+
<p
|
|
62
|
+
style={{
|
|
63
|
+
marginBottom: '0.75rem',
|
|
64
|
+
color: 'var(--muted-foreground)',
|
|
65
|
+
}}
|
|
66
|
+
>
|
|
67
|
+
Pass <code>onClose</code> to show a ghost close button.
|
|
68
|
+
</p>
|
|
69
|
+
{dismissed ? (
|
|
70
|
+
<Button type="button" size="sm" onClick={() => setDismissed(false)}>
|
|
71
|
+
Show banner
|
|
72
|
+
</Button>
|
|
73
|
+
) : (
|
|
74
|
+
<Banner onClose={() => setDismissed(true)}>
|
|
75
|
+
New dataset columns are available. Review the mapping before
|
|
76
|
+
refresh.
|
|
77
|
+
</Banner>
|
|
78
|
+
)}
|
|
79
|
+
</section>
|
|
80
|
+
</PageContentSection>
|
|
81
|
+
</>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Chip } from '#uilib/components/ui/Chip';
|
|
2
|
-
import type { ChipVariant } from '#uilib/components/ui/Chip';
|
|
2
|
+
import type { ChipSize, ChipVariant } from '#uilib/components/ui/Chip';
|
|
3
3
|
import ChipGuidance from '#uilib/components/ui/Chip/AGENT.md';
|
|
4
4
|
import { PageContentSection } from '#uilib/components/ui/Page';
|
|
5
5
|
|
|
@@ -18,6 +18,8 @@ const VARIANTS: ChipVariant[] = [
|
|
|
18
18
|
'yellow',
|
|
19
19
|
];
|
|
20
20
|
|
|
21
|
+
const SIZES: ChipSize[] = ['xs', 'sm', 'md', 'lg'];
|
|
22
|
+
|
|
21
23
|
export default function ChipPage() {
|
|
22
24
|
return (
|
|
23
25
|
<>
|
|
@@ -48,6 +50,23 @@ export default function ChipPage() {
|
|
|
48
50
|
))}
|
|
49
51
|
</div>
|
|
50
52
|
</section>
|
|
53
|
+
<section>
|
|
54
|
+
<h3 style={{ marginBottom: '1rem' }}>Sizes</h3>
|
|
55
|
+
<div
|
|
56
|
+
style={{
|
|
57
|
+
display: 'flex',
|
|
58
|
+
flexWrap: 'wrap',
|
|
59
|
+
gap: '0.75rem',
|
|
60
|
+
alignItems: 'center',
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
{SIZES.map(s => (
|
|
64
|
+
<Chip key={s} size={s} variant="line">
|
|
65
|
+
{s}
|
|
66
|
+
</Chip>
|
|
67
|
+
))}
|
|
68
|
+
</div>
|
|
69
|
+
</section>
|
|
51
70
|
<section>
|
|
52
71
|
<h3 style={{ marginBottom: '1rem' }}>Filters</h3>
|
|
53
72
|
<div
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Banner } from '#uilib/components/ui/Banner';
|
|
1
2
|
import { PageContentSection } from '#uilib/components/ui/Page';
|
|
2
3
|
import { Progress } from '#uilib/components/ui/Progress';
|
|
3
4
|
import { Skeleton } from '#uilib/components/ui/Skeleton';
|
|
@@ -22,12 +23,17 @@ export default function FeedbackOverviewPage() {
|
|
|
22
23
|
<AppPageHeader
|
|
23
24
|
breadcrumbs={[{ label: 'Overview' }]}
|
|
24
25
|
title="Overview"
|
|
25
|
-
subheader="
|
|
26
|
+
subheader="Inline notices, progress, loading placeholders, and animated status text."
|
|
26
27
|
actions={<DocsHeaderActions />}
|
|
27
28
|
/>
|
|
28
29
|
<PageContentSection
|
|
29
30
|
style={{ display: 'flex', flexDirection: 'column', gap: '2.5rem' }}
|
|
30
31
|
>
|
|
32
|
+
<section>
|
|
33
|
+
<h3 style={{ marginBottom: '1rem' }}>Banner</h3>
|
|
34
|
+
<Banner>Forecast refresh completed.</Banner>
|
|
35
|
+
</section>
|
|
36
|
+
|
|
31
37
|
<section>
|
|
32
38
|
<h3 style={{ marginBottom: '1rem' }}>Progress</h3>
|
|
33
39
|
<div style={panelStyle}>
|
|
@@ -64,7 +64,7 @@ export default function SelectPage() {
|
|
|
64
64
|
<AppPageHeader
|
|
65
65
|
breadcrumbs={[{ label: 'Select' }]}
|
|
66
66
|
title="Select"
|
|
67
|
-
subheader="Variants, sizes, placeholder, darker trigger, and
|
|
67
|
+
subheader="Variants, sizes, placeholder, darker trigger, disabled, and searchable."
|
|
68
68
|
actions={<DocsHeaderActions />}
|
|
69
69
|
/>
|
|
70
70
|
<DocsGuidance source={selectGuidance} />
|
|
@@ -191,6 +191,35 @@ export default function SelectPage() {
|
|
|
191
191
|
))}
|
|
192
192
|
</div>
|
|
193
193
|
</section>
|
|
194
|
+
<section>
|
|
195
|
+
<h3 style={{ marginBottom: '1rem' }}>Searchable</h3>
|
|
196
|
+
<p
|
|
197
|
+
style={{
|
|
198
|
+
marginBottom: '0.75rem',
|
|
199
|
+
color: 'var(--muted-foreground)',
|
|
200
|
+
}}
|
|
201
|
+
>
|
|
202
|
+
Pass <code>searchable</code> on <code>Select</code>. The trigger is
|
|
203
|
+
an input; typing filters options.
|
|
204
|
+
</p>
|
|
205
|
+
<Select searchable defaultValue="apple">
|
|
206
|
+
<SelectTrigger style={{ width: 240 }}>
|
|
207
|
+
<SelectValue placeholder="Search fruit" />
|
|
208
|
+
</SelectTrigger>
|
|
209
|
+
<SelectContent>
|
|
210
|
+
{[
|
|
211
|
+
...FRUIT_OPTIONS,
|
|
212
|
+
{ value: 'mango', label: 'Mango' },
|
|
213
|
+
{ value: 'kiwi', label: 'Kiwi' },
|
|
214
|
+
{ value: 'pear', label: 'Pear' },
|
|
215
|
+
].map(o => (
|
|
216
|
+
<SelectItem key={o.value} value={o.value}>
|
|
217
|
+
{o.label}
|
|
218
|
+
</SelectItem>
|
|
219
|
+
))}
|
|
220
|
+
</SelectContent>
|
|
221
|
+
</Select>
|
|
222
|
+
</section>
|
|
194
223
|
<section>
|
|
195
224
|
<h3 style={{ marginBottom: '1rem' }}>Disabled</h3>
|
|
196
225
|
<div style={{ overflowX: 'auto' }}>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import supplyChainMapGuidance from '#uilib/components/ui/SupplyChainMap/AGENT.md';
|
|
2
|
+
import { SupplyChainMapExample } from '#uilib/components/ui/SupplyChainMap/SupplyChainMap.example';
|
|
3
|
+
|
|
4
|
+
import { AppPageHeader } from '../components/AppPageHeader/AppPageHeader';
|
|
5
|
+
import { DocsGuidance } from '../components/DocsGuidance/DocsGuidance';
|
|
6
|
+
import { DocsHeaderActions } from '../docsHeaderActions';
|
|
7
|
+
|
|
8
|
+
export default function SupplyChainMapPage() {
|
|
9
|
+
return (
|
|
10
|
+
<>
|
|
11
|
+
<AppPageHeader
|
|
12
|
+
breadcrumbs={[{ label: 'Supply chain map' }]}
|
|
13
|
+
title="SupplyChainMap"
|
|
14
|
+
subheader="Interactive Natural Earth map for confirmed sites and routes — clustering, zoom, labels, and flyTo."
|
|
15
|
+
actions={<DocsHeaderActions />}
|
|
16
|
+
/>
|
|
17
|
+
<DocsGuidance source={supplyChainMapGuidance} />
|
|
18
|
+
<SupplyChainMapExample />
|
|
19
|
+
</>
|
|
20
|
+
);
|
|
21
|
+
}
|
package/src/docs/registry.ts
CHANGED
|
@@ -86,6 +86,12 @@ export const DOC_REGISTRY: DocEntry[] = [
|
|
|
86
86
|
section: 'Feedback',
|
|
87
87
|
load: () => import('./pages/FeedbackOverviewPage'),
|
|
88
88
|
},
|
|
89
|
+
{
|
|
90
|
+
slug: 'banner',
|
|
91
|
+
title: 'Banner',
|
|
92
|
+
section: 'Feedback',
|
|
93
|
+
load: () => import('./pages/BannerPage'),
|
|
94
|
+
},
|
|
89
95
|
{
|
|
90
96
|
slug: 'notifications',
|
|
91
97
|
title: 'Notifications',
|
|
@@ -591,6 +597,12 @@ export const DOC_REGISTRY: DocEntry[] = [
|
|
|
591
597
|
section: 'Media',
|
|
592
598
|
load: () => import('./pages/WorldMapPage'),
|
|
593
599
|
},
|
|
600
|
+
{
|
|
601
|
+
slug: 'supply-chain-map',
|
|
602
|
+
title: 'SupplyChainMap',
|
|
603
|
+
section: 'Media',
|
|
604
|
+
load: () => import('./pages/SupplyChainMapPage'),
|
|
605
|
+
},
|
|
594
606
|
];
|
|
595
607
|
|
|
596
608
|
export const docPageComponents: Record<
|
package/src/index.ts
CHANGED
|
@@ -82,6 +82,7 @@ export * from './components/ui/ToggleGroup';
|
|
|
82
82
|
export * from './components/ui/Tooltip';
|
|
83
83
|
export * from './components/ui/VimeoEmbed';
|
|
84
84
|
export * from './components/ui/WorldMap';
|
|
85
|
+
export * from './components/ui/SupplyChainMap';
|
|
85
86
|
export * from './components/ui/WorkspaceAppSwitcher';
|
|
86
87
|
export * from './components/widgets/SidebarDatasetsItemsGrouped';
|
|
87
88
|
export * from './components/widgets/DriverCard';
|