@tscircuit/runframe 0.0.346 → 0.0.348
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/{chunk-ODEVX3CY.js → chunk-CRYLRRYE.js} +1149 -4
- package/dist/preview.d.ts +36 -2
- package/dist/preview.js +7 -3
- package/dist/runner.d.ts +1 -1
- package/dist/runner.js +153 -1204
- package/dist/standalone-preview.min.js +383 -383
- package/dist/standalone.min.js +713 -713
- package/package.json +2 -2
package/dist/runner.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
+
API_BASE,
|
|
3
|
+
AlertDialog,
|
|
4
|
+
AlertDialogCancel,
|
|
5
|
+
AlertDialogContent,
|
|
6
|
+
AlertDialogDescription,
|
|
7
|
+
AlertDialogFooter,
|
|
8
|
+
AlertDialogHeader,
|
|
9
|
+
AlertDialogTitle,
|
|
2
10
|
BomTable,
|
|
3
11
|
Button,
|
|
4
12
|
CadViewer,
|
|
@@ -11,20 +19,24 @@ import {
|
|
|
11
19
|
DropdownMenuSubContent,
|
|
12
20
|
DropdownMenuSubTrigger,
|
|
13
21
|
DropdownMenuTrigger,
|
|
22
|
+
Input,
|
|
14
23
|
PCBViewer,
|
|
15
24
|
PcbViewerWithContainerHeight,
|
|
16
25
|
SchematicViewer,
|
|
17
26
|
Tabs,
|
|
18
27
|
TabsList,
|
|
19
28
|
TabsTrigger,
|
|
20
|
-
buttonVariants,
|
|
21
29
|
cn,
|
|
22
|
-
|
|
23
|
-
|
|
30
|
+
debug_default,
|
|
31
|
+
linkify,
|
|
32
|
+
useOrderDialog,
|
|
33
|
+
useOrderDialogCli,
|
|
34
|
+
useRunFrameStore
|
|
35
|
+
} from "./chunk-CRYLRRYE.js";
|
|
24
36
|
|
|
25
37
|
// lib/components/RunFrame/RunFrame.tsx
|
|
26
38
|
import { createCircuitWebWorker } from "@tscircuit/eval/worker";
|
|
27
|
-
import
|
|
39
|
+
import Debug from "debug";
|
|
28
40
|
import { Loader2, Play, Square } from "lucide-react";
|
|
29
41
|
import { useEffect, useReducer, useRef as useRef2, useState } from "react";
|
|
30
42
|
|
|
@@ -77,178 +89,11 @@ var getChangesBetweenFsMaps = (fsMap1, fsMap2) => {
|
|
|
77
89
|
return changes;
|
|
78
90
|
};
|
|
79
91
|
|
|
80
|
-
// lib/components/
|
|
81
|
-
import { applyEditEventsToManualEditsFile } from "@tscircuit/core";
|
|
82
|
-
|
|
83
|
-
// lib/utils/debug.ts
|
|
84
|
-
import Debug from "debug";
|
|
85
|
-
var debug = Debug("run-frame");
|
|
86
|
-
var debug_default = debug;
|
|
87
|
-
|
|
88
|
-
// lib/components/RunFrameWithApi/store.ts
|
|
92
|
+
// lib/components/RunFrame/runner-store/use-runner-store.ts
|
|
89
93
|
import { create } from "zustand";
|
|
90
94
|
import { devtools } from "zustand/middleware";
|
|
91
|
-
|
|
92
|
-
// lib/components/RunFrameWithApi/api-base.ts
|
|
93
|
-
var API_BASE = window.API_BASE_URL ?? "/api";
|
|
94
|
-
|
|
95
|
-
// lib/components/RunFrameWithApi/store.ts
|
|
96
|
-
var debug2 = debug_default.extend("store");
|
|
97
|
-
async function upsertFileApi(path, content) {
|
|
98
|
-
const response = await fetch(`${API_BASE}/files/upsert`, {
|
|
99
|
-
method: "POST",
|
|
100
|
-
headers: { "Content-Type": "application/json" },
|
|
101
|
-
body: JSON.stringify({ file_path: path, text_content: content })
|
|
102
|
-
});
|
|
103
|
-
const data = await response.json();
|
|
104
|
-
return data.file;
|
|
105
|
-
}
|
|
106
|
-
async function getFileApi(path) {
|
|
107
|
-
const response = await fetch(
|
|
108
|
-
`${API_BASE}/files/get?file_path=${encodeURIComponent(path)}`
|
|
109
|
-
);
|
|
110
|
-
const data = await response.json();
|
|
111
|
-
return data.file;
|
|
112
|
-
}
|
|
113
|
-
async function getEvents(since) {
|
|
114
|
-
const url = since ? `${API_BASE}/events/list?since=${encodeURIComponent(since)}` : `${API_BASE}/events/list`;
|
|
115
|
-
const response = await fetch(url);
|
|
116
|
-
const data = await response.json();
|
|
117
|
-
return data.event_list;
|
|
118
|
-
}
|
|
119
|
-
async function getInitialFilesApi() {
|
|
120
|
-
const response = await fetch(`${API_BASE}/files/list`);
|
|
121
|
-
const { file_list } = await response.json();
|
|
122
|
-
const fileMap = /* @__PURE__ */ new Map();
|
|
123
|
-
for (const file of file_list) {
|
|
124
|
-
const fullFile = await getFileApi(file.file_path);
|
|
125
|
-
fileMap.set(file.file_path, fullFile.text_content);
|
|
126
|
-
}
|
|
127
|
-
return fileMap;
|
|
128
|
-
}
|
|
129
|
-
var useRunFrameStore = create()(
|
|
95
|
+
var useRunnerStore = create()(
|
|
130
96
|
devtools(
|
|
131
|
-
(set, get) => ({
|
|
132
|
-
fsMap: /* @__PURE__ */ new Map(),
|
|
133
|
-
lastEventTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
134
|
-
isPolling: false,
|
|
135
|
-
error: null,
|
|
136
|
-
circuitJson: null,
|
|
137
|
-
lastManualEditsChangeSentAt: 0,
|
|
138
|
-
recentEvents: [],
|
|
139
|
-
simulateScenarioOrder: void 0,
|
|
140
|
-
loadInitialFiles: async () => {
|
|
141
|
-
const fsMap = await getInitialFilesApi();
|
|
142
|
-
debug2("loaded initial files", { fsMap });
|
|
143
|
-
set({ fsMap });
|
|
144
|
-
},
|
|
145
|
-
upsertFile: async (path, content) => {
|
|
146
|
-
try {
|
|
147
|
-
const file = await upsertFileApi(path, content);
|
|
148
|
-
set((state) => ({
|
|
149
|
-
fsMap: new Map(state.fsMap).set(file.file_path, file.text_content)
|
|
150
|
-
}));
|
|
151
|
-
} catch (error) {
|
|
152
|
-
set({ error });
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
|
-
getFile: async (path) => {
|
|
156
|
-
try {
|
|
157
|
-
const file = await getFileApi(path);
|
|
158
|
-
set((state) => ({
|
|
159
|
-
fsMap: new Map(state.fsMap).set(file.file_path, file.text_content)
|
|
160
|
-
}));
|
|
161
|
-
} catch (error) {
|
|
162
|
-
set({ error });
|
|
163
|
-
}
|
|
164
|
-
},
|
|
165
|
-
setCircuitJson: (circuitJson) => {
|
|
166
|
-
if (circuitJson === get().circuitJson) return;
|
|
167
|
-
set({ circuitJson });
|
|
168
|
-
},
|
|
169
|
-
startPolling: () => {
|
|
170
|
-
const poll = async () => {
|
|
171
|
-
const state = get();
|
|
172
|
-
if (!state.isPolling) return;
|
|
173
|
-
try {
|
|
174
|
-
const events = await getEvents(state.lastEventTime);
|
|
175
|
-
if (events.length > 0) {
|
|
176
|
-
set((state2) => ({
|
|
177
|
-
recentEvents: [...state2.recentEvents, ...events].slice(0, 100)
|
|
178
|
-
// TODO sort
|
|
179
|
-
// .sort((a, b) => b.created_at.localeCompare(a.created_at)),
|
|
180
|
-
}));
|
|
181
|
-
const newLastEventTime = events[events.length - 1].created_at;
|
|
182
|
-
const updates = new Map(state.fsMap);
|
|
183
|
-
for (const event of events) {
|
|
184
|
-
if (event.event_type === "FILE_UPDATED") {
|
|
185
|
-
const file = await getFileApi(event.file_path);
|
|
186
|
-
if (event.file_path === "manual_edits.json" && Date.now() - state.lastManualEditsChangeSentAt < 1e3) {
|
|
187
|
-
continue;
|
|
188
|
-
}
|
|
189
|
-
updates.set(file.file_path, file.text_content);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
set({
|
|
193
|
-
fsMap: updates,
|
|
194
|
-
lastEventTime: newLastEventTime
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
} catch (error) {
|
|
198
|
-
set({ error });
|
|
199
|
-
}
|
|
200
|
-
setTimeout(poll, 1e3);
|
|
201
|
-
};
|
|
202
|
-
set({ isPolling: true });
|
|
203
|
-
poll();
|
|
204
|
-
},
|
|
205
|
-
stopPolling: () => {
|
|
206
|
-
set({ isPolling: false });
|
|
207
|
-
},
|
|
208
|
-
pushEvent: async (event) => {
|
|
209
|
-
await fetch(`${window.API_BASE_URL ?? ""}/api/events/create`, {
|
|
210
|
-
method: "POST",
|
|
211
|
-
headers: {
|
|
212
|
-
"Content-Type": "application/json"
|
|
213
|
-
},
|
|
214
|
-
body: JSON.stringify(event)
|
|
215
|
-
});
|
|
216
|
-
},
|
|
217
|
-
applyEditEventsAndUpdateManualEditsJson: async (editEvents) => {
|
|
218
|
-
debug2("applyEditEventsAndUpdateManualEditsJson", { editEvents });
|
|
219
|
-
const state = get();
|
|
220
|
-
if (!state.circuitJson) return;
|
|
221
|
-
const manualEditsJson = state.fsMap.get("manual-edits.json");
|
|
222
|
-
const manualEdits = manualEditsJson ? JSON.parse(manualEditsJson) : {};
|
|
223
|
-
const updatedManualEditsFileContent = applyEditEventsToManualEditsFile({
|
|
224
|
-
circuitJson: state.circuitJson,
|
|
225
|
-
editEvents,
|
|
226
|
-
manualEditsFile: manualEdits
|
|
227
|
-
});
|
|
228
|
-
debug2("updatedManualEditsFileContent", updatedManualEditsFileContent);
|
|
229
|
-
set((state2) => ({
|
|
230
|
-
lastManualEditsChangeSentAt: Date.now(),
|
|
231
|
-
fsMap: new Map(state2.fsMap).set(
|
|
232
|
-
"manual-edits.json",
|
|
233
|
-
JSON.stringify(updatedManualEditsFileContent)
|
|
234
|
-
)
|
|
235
|
-
}));
|
|
236
|
-
await upsertFileApi(
|
|
237
|
-
"manual-edits.json",
|
|
238
|
-
JSON.stringify(updatedManualEditsFileContent, null, 2)
|
|
239
|
-
);
|
|
240
|
-
},
|
|
241
|
-
setSimulateScenarioOrder: (scenarioOrder) => set({ simulateScenarioOrder: scenarioOrder })
|
|
242
|
-
}),
|
|
243
|
-
{ name: "run-frame-store" }
|
|
244
|
-
)
|
|
245
|
-
);
|
|
246
|
-
|
|
247
|
-
// lib/components/RunFrame/runner-store/use-runner-store.ts
|
|
248
|
-
import { create as create2 } from "zustand";
|
|
249
|
-
import { devtools as devtools2 } from "zustand/middleware";
|
|
250
|
-
var useRunnerStore = create2()(
|
|
251
|
-
devtools2(
|
|
252
97
|
(set) => ({
|
|
253
98
|
lastRunEvalVersion: void 0,
|
|
254
99
|
setLastRunEvalVersion: (version) => {
|
|
@@ -289,7 +134,7 @@ function useMutex() {
|
|
|
289
134
|
// lib/components/RunFrame/RunFrame.tsx
|
|
290
135
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
291
136
|
var numRenderPhases = 26;
|
|
292
|
-
var
|
|
137
|
+
var debug = Debug("run-frame:RunFrame");
|
|
293
138
|
var RunFrame = (props) => {
|
|
294
139
|
const [circuitJson, setCircuitJson] = useRunFrameStore((s) => [
|
|
295
140
|
s.circuitJson,
|
|
@@ -320,7 +165,7 @@ var RunFrame = (props) => {
|
|
|
320
165
|
props.defaultActiveTab ?? "pcb"
|
|
321
166
|
);
|
|
322
167
|
useEffect(() => {
|
|
323
|
-
if (props.debug)
|
|
168
|
+
if (props.debug) Debug.enable("run-frame*");
|
|
324
169
|
}, [props.debug]);
|
|
325
170
|
const fsMap = props.fsMap instanceof Map ? props.fsMap : Object.entries(props.fsMap ?? {}).reduce(
|
|
326
171
|
(m, [k, v]) => m.set(k, v),
|
|
@@ -342,11 +187,11 @@ var RunFrame = (props) => {
|
|
|
342
187
|
if (lastFsMapRef.current && circuitJson) {
|
|
343
188
|
const changes = getChangesBetweenFsMaps(lastFsMapRef.current, fsMap);
|
|
344
189
|
if (Object.keys(changes).length > 0) {
|
|
345
|
-
|
|
190
|
+
debug("code changes detected");
|
|
346
191
|
} else if (lastEntrypointRef.current !== props.entrypoint) {
|
|
347
|
-
|
|
192
|
+
debug("render triggered by entrypoint change");
|
|
348
193
|
} else if (!wasTriggeredByRunButton) {
|
|
349
|
-
|
|
194
|
+
debug("render triggered without changes to fsMap, skipping");
|
|
350
195
|
return;
|
|
351
196
|
}
|
|
352
197
|
}
|
|
@@ -358,7 +203,7 @@ var RunFrame = (props) => {
|
|
|
358
203
|
lastRunCountTriggerRef.current = runCountTrigger;
|
|
359
204
|
setIsRunning(true);
|
|
360
205
|
const runWorker = async () => {
|
|
361
|
-
|
|
206
|
+
debug("running render worker");
|
|
362
207
|
setError(null);
|
|
363
208
|
const renderLog2 = { progress: 0 };
|
|
364
209
|
let evalVersion = props.evalVersion ?? "latest";
|
|
@@ -445,21 +290,21 @@ var RunFrame = (props) => {
|
|
|
445
290
|
return;
|
|
446
291
|
}
|
|
447
292
|
const $renderResult = worker.renderUntilSettled();
|
|
448
|
-
|
|
293
|
+
debug("waiting for initial circuit json...");
|
|
449
294
|
let circuitJson2 = await worker.getCircuitJson().catch((e) => {
|
|
450
|
-
|
|
295
|
+
debug("error getting initial circuit json", e);
|
|
451
296
|
props.onError?.(e);
|
|
452
297
|
setError({ error: e.message, stack: e.stack });
|
|
453
298
|
setIsRunning(false);
|
|
454
299
|
return null;
|
|
455
300
|
});
|
|
456
301
|
if (!circuitJson2) return;
|
|
457
|
-
|
|
302
|
+
debug("got initial circuit json");
|
|
458
303
|
setCircuitJson(circuitJson2);
|
|
459
304
|
props.onCircuitJsonChange?.(circuitJson2);
|
|
460
305
|
props.onInitialRender?.({ circuitJson: circuitJson2 });
|
|
461
306
|
await $renderResult;
|
|
462
|
-
|
|
307
|
+
debug("getting final circuit json");
|
|
463
308
|
circuitJson2 = await worker.getCircuitJson();
|
|
464
309
|
props.onCircuitJsonChange?.(circuitJson2);
|
|
465
310
|
setCircuitJson(circuitJson2);
|
|
@@ -569,11 +414,11 @@ var RunFrame = (props) => {
|
|
|
569
414
|
};
|
|
570
415
|
|
|
571
416
|
// lib/components/RunFrameWithApi/RunFrameWithApi.tsx
|
|
572
|
-
import
|
|
417
|
+
import Debug2 from "debug";
|
|
573
418
|
|
|
574
419
|
// lib/hooks/use-edit-event-controller.ts
|
|
575
420
|
import { useState as useState2, useCallback as useCallback2, useEffect as useEffect2 } from "react";
|
|
576
|
-
var
|
|
421
|
+
var debug2 = debug_default.extend("useEditEventController");
|
|
577
422
|
var useEditEventController = () => {
|
|
578
423
|
const applyEditEventsAndUpdateManualEditsJson = useRunFrameStore(
|
|
579
424
|
(s) => s.applyEditEventsAndUpdateManualEditsJson
|
|
@@ -599,7 +444,7 @@ var useEditEventController = () => {
|
|
|
599
444
|
const markRenderStarted = useCallback2(() => {
|
|
600
445
|
setIsRendering(true);
|
|
601
446
|
if (editEvents.length === 0) return;
|
|
602
|
-
|
|
447
|
+
debug2("removing edit events that are applied");
|
|
603
448
|
setEditEvents((prev) => prev.filter((ee) => !ee._applied));
|
|
604
449
|
}, [editEvents]);
|
|
605
450
|
const markRenderComplete = useCallback2(() => {
|
|
@@ -655,15 +500,15 @@ var useSyncPageTitle = () => {
|
|
|
655
500
|
|
|
656
501
|
// lib/components/RunFrameWithApi/RunFrameWithApi.tsx
|
|
657
502
|
import { useEffect as useEffect4 } from "react";
|
|
658
|
-
import { applyEditEventsToManualEditsFile
|
|
503
|
+
import { applyEditEventsToManualEditsFile } from "@tscircuit/core";
|
|
659
504
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
660
|
-
var
|
|
505
|
+
var debug3 = Debug2("run-frame:RunFrameWithApi");
|
|
661
506
|
var guessEntrypoint = (files) => files.find((file) => file.includes("entrypoint.")) ?? files.find((file) => file.includes("index.")) ?? files.find((file) => file.includes("main.")) ?? files.find((file) => file.endsWith(".tsx"));
|
|
662
507
|
var guessManualEditsFilePath = (files) => files.find((file) => file.includes("manual-edits.")) ?? files.find((file) => file.includes("manual-edit.")) ?? files.find((file) => file.endsWith(".json"));
|
|
663
508
|
var RunFrameWithApi = (props) => {
|
|
664
509
|
const { apiBaseUrl, leftHeaderContent } = props;
|
|
665
510
|
useEffect4(() => {
|
|
666
|
-
if (props.debug)
|
|
511
|
+
if (props.debug) Debug2.enable("run-frame*");
|
|
667
512
|
}, [props.debug]);
|
|
668
513
|
const { startPolling, stopPolling, loadInitialFiles } = useRunFrameStore(
|
|
669
514
|
(s) => ({
|
|
@@ -703,11 +548,11 @@ var RunFrameWithApi = (props) => {
|
|
|
703
548
|
defaultToFullScreen: props.defaultToFullScreen,
|
|
704
549
|
showToggleFullScreen: props.showToggleFullScreen,
|
|
705
550
|
onInitialRender: () => {
|
|
706
|
-
|
|
551
|
+
debug3("onInitialRender / markRenderStarted");
|
|
707
552
|
markRenderStarted();
|
|
708
553
|
},
|
|
709
554
|
onRenderFinished: () => {
|
|
710
|
-
|
|
555
|
+
debug3("onRenderFinished / markRenderComplete");
|
|
711
556
|
markRenderComplete();
|
|
712
557
|
},
|
|
713
558
|
editEvents: editEventsForRender,
|
|
@@ -726,7 +571,7 @@ var RunFrameWithApi = (props) => {
|
|
|
726
571
|
const updatedManualEdits = JSON.parse(
|
|
727
572
|
manualEditsFile ?? "{}"
|
|
728
573
|
);
|
|
729
|
-
|
|
574
|
+
applyEditEventsToManualEditsFile({
|
|
730
575
|
circuitJson,
|
|
731
576
|
editEvents: [ee],
|
|
732
577
|
manualEditsFile: updatedManualEdits
|
|
@@ -768,7 +613,7 @@ function useLocalStorageState(key, initialValue) {
|
|
|
768
613
|
}
|
|
769
614
|
|
|
770
615
|
// lib/components/RunFrameForCli/LeftHeader.tsx
|
|
771
|
-
import { useEffect as
|
|
616
|
+
import { useEffect as useEffect8, useMemo as useMemo2, useState as useState6 } from "react";
|
|
772
617
|
|
|
773
618
|
// lib/components/RunFrameForCli/SelectSnippetDialog.tsx
|
|
774
619
|
import { useState as useState4 } from "react";
|
|
@@ -875,117 +720,12 @@ var useEventHandler = (callback) => {
|
|
|
875
720
|
// lib/components/RunFrameForCli/LeftHeader.tsx
|
|
876
721
|
import "lucide-react";
|
|
877
722
|
|
|
878
|
-
// lib/components/ui/alert-dialog.tsx
|
|
879
|
-
import * as React from "react";
|
|
880
|
-
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
|
|
881
|
-
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
882
|
-
var AlertDialog = AlertDialogPrimitive.Root;
|
|
883
|
-
var AlertDialogPortal = AlertDialogPrimitive.Portal;
|
|
884
|
-
var AlertDialogOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx4(
|
|
885
|
-
AlertDialogPrimitive.Overlay,
|
|
886
|
-
{
|
|
887
|
-
className: cn(
|
|
888
|
-
"rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",
|
|
889
|
-
className
|
|
890
|
-
),
|
|
891
|
-
...props,
|
|
892
|
-
ref
|
|
893
|
-
}
|
|
894
|
-
));
|
|
895
|
-
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
|
|
896
|
-
var AlertDialogContent = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxs3(AlertDialogPortal, { children: [
|
|
897
|
-
/* @__PURE__ */ jsx4(AlertDialogOverlay, {}),
|
|
898
|
-
/* @__PURE__ */ jsx4(
|
|
899
|
-
AlertDialogPrimitive.Content,
|
|
900
|
-
{
|
|
901
|
-
ref,
|
|
902
|
-
className: cn(
|
|
903
|
-
"rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",
|
|
904
|
-
className
|
|
905
|
-
),
|
|
906
|
-
...props
|
|
907
|
-
}
|
|
908
|
-
)
|
|
909
|
-
] }));
|
|
910
|
-
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
|
|
911
|
-
var AlertDialogHeader = ({
|
|
912
|
-
className,
|
|
913
|
-
...props
|
|
914
|
-
}) => /* @__PURE__ */ jsx4(
|
|
915
|
-
"div",
|
|
916
|
-
{
|
|
917
|
-
className: cn(
|
|
918
|
-
"rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",
|
|
919
|
-
className
|
|
920
|
-
),
|
|
921
|
-
...props
|
|
922
|
-
}
|
|
923
|
-
);
|
|
924
|
-
AlertDialogHeader.displayName = "AlertDialogHeader";
|
|
925
|
-
var AlertDialogFooter = ({
|
|
926
|
-
className,
|
|
927
|
-
...props
|
|
928
|
-
}) => /* @__PURE__ */ jsx4(
|
|
929
|
-
"div",
|
|
930
|
-
{
|
|
931
|
-
className: cn(
|
|
932
|
-
"rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",
|
|
933
|
-
className
|
|
934
|
-
),
|
|
935
|
-
...props
|
|
936
|
-
}
|
|
937
|
-
);
|
|
938
|
-
AlertDialogFooter.displayName = "AlertDialogFooter";
|
|
939
|
-
var AlertDialogTitle = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx4(
|
|
940
|
-
AlertDialogPrimitive.Title,
|
|
941
|
-
{
|
|
942
|
-
ref,
|
|
943
|
-
className: cn("rf-text-lg rf-font-semibold", className),
|
|
944
|
-
...props
|
|
945
|
-
}
|
|
946
|
-
));
|
|
947
|
-
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
|
|
948
|
-
var AlertDialogDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx4(
|
|
949
|
-
AlertDialogPrimitive.Description,
|
|
950
|
-
{
|
|
951
|
-
ref,
|
|
952
|
-
className: cn(
|
|
953
|
-
"rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",
|
|
954
|
-
className
|
|
955
|
-
),
|
|
956
|
-
...props
|
|
957
|
-
}
|
|
958
|
-
));
|
|
959
|
-
AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName;
|
|
960
|
-
var AlertDialogAction = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx4(
|
|
961
|
-
AlertDialogPrimitive.Action,
|
|
962
|
-
{
|
|
963
|
-
ref,
|
|
964
|
-
className: cn(buttonVariants(), className),
|
|
965
|
-
...props
|
|
966
|
-
}
|
|
967
|
-
));
|
|
968
|
-
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
|
|
969
|
-
var AlertDialogCancel = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx4(
|
|
970
|
-
AlertDialogPrimitive.Cancel,
|
|
971
|
-
{
|
|
972
|
-
ref,
|
|
973
|
-
className: cn(
|
|
974
|
-
buttonVariants({ variant: "outline" }),
|
|
975
|
-
"rf-mt-2 sm:rf-mt-0",
|
|
976
|
-
className
|
|
977
|
-
),
|
|
978
|
-
...props
|
|
979
|
-
}
|
|
980
|
-
));
|
|
981
|
-
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
|
|
982
|
-
|
|
983
723
|
// lib/components/ui/checkbox.tsx
|
|
984
|
-
import * as
|
|
724
|
+
import * as React from "react";
|
|
985
725
|
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
986
726
|
import { Check } from "lucide-react";
|
|
987
|
-
import { jsx as
|
|
988
|
-
var Checkbox =
|
|
727
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
728
|
+
var Checkbox = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx4(
|
|
989
729
|
CheckboxPrimitive.Root,
|
|
990
730
|
{
|
|
991
731
|
ref,
|
|
@@ -994,13 +734,13 @@ var Checkbox = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__
|
|
|
994
734
|
className
|
|
995
735
|
),
|
|
996
736
|
...props,
|
|
997
|
-
children: /* @__PURE__ */
|
|
737
|
+
children: /* @__PURE__ */ jsx4(
|
|
998
738
|
CheckboxPrimitive.Indicator,
|
|
999
739
|
{
|
|
1000
740
|
className: cn(
|
|
1001
741
|
"rf-flex rf-items-center rf-justify-center rf-text-current"
|
|
1002
742
|
),
|
|
1003
|
-
children: /* @__PURE__ */
|
|
743
|
+
children: /* @__PURE__ */ jsx4(Check, { className: "rf-h-4 rf-w-4" })
|
|
1004
744
|
}
|
|
1005
745
|
)
|
|
1006
746
|
}
|
|
@@ -1012,27 +752,6 @@ import "react";
|
|
|
1012
752
|
import { useState as useState5, useEffect as useEffect7 } from "react";
|
|
1013
753
|
import { Loader2 as Loader22, Search, ExternalLink } from "lucide-react";
|
|
1014
754
|
|
|
1015
|
-
// lib/components/ui/input.tsx
|
|
1016
|
-
import * as React3 from "react";
|
|
1017
|
-
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
1018
|
-
var Input = React3.forwardRef(
|
|
1019
|
-
({ className, type, ...props }, ref) => {
|
|
1020
|
-
return /* @__PURE__ */ jsx6(
|
|
1021
|
-
"input",
|
|
1022
|
-
{
|
|
1023
|
-
type,
|
|
1024
|
-
className: cn(
|
|
1025
|
-
"rf-flex rf-h-9 rf-w-full rf-rounded-md rf-border rf-border-zinc-200 rf-bg-white rf-px-3 rf-py-1 rf-text-sm rf-shadow-sm rf-transition-colors file:rf-border-0 file:rf-bg-transparent file:rf-text-sm file:rf-font-medium placeholder:rf-text-zinc-500 focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 dark:rf-border-zinc-800 dark:rf-bg-zinc-950 dark:rf-placeholder-zinc-400 dark:focus-visible:rf-ring-zinc-300",
|
|
1026
|
-
className
|
|
1027
|
-
),
|
|
1028
|
-
ref,
|
|
1029
|
-
...props
|
|
1030
|
-
}
|
|
1031
|
-
);
|
|
1032
|
-
}
|
|
1033
|
-
);
|
|
1034
|
-
Input.displayName = "Input";
|
|
1035
|
-
|
|
1036
755
|
// lib/components/ImportComponentDialog/jlc-api.ts
|
|
1037
756
|
var searchJLCComponents = async (query, limit = 10) => {
|
|
1038
757
|
try {
|
|
@@ -1099,7 +818,7 @@ var mapTscircuitSnippetToSearchResult = (tscircuitSnippet) => {
|
|
|
1099
818
|
|
|
1100
819
|
// lib/components/ImportComponentDialog/ImportComponentDialog.tsx
|
|
1101
820
|
import { createSvgUrl as createPngUrl } from "@tscircuit/create-snippet-url";
|
|
1102
|
-
import { jsx as
|
|
821
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1103
822
|
var ImportComponentDialog = ({
|
|
1104
823
|
isOpen,
|
|
1105
824
|
onClose,
|
|
@@ -1161,26 +880,26 @@ var ImportComponentDialog = ({
|
|
|
1161
880
|
setDetailsComponent(component);
|
|
1162
881
|
setDetailsOpen(true);
|
|
1163
882
|
};
|
|
1164
|
-
return /* @__PURE__ */
|
|
1165
|
-
/* @__PURE__ */
|
|
1166
|
-
/* @__PURE__ */
|
|
1167
|
-
/* @__PURE__ */
|
|
1168
|
-
/* @__PURE__ */
|
|
883
|
+
return /* @__PURE__ */ jsxs3(AlertDialog, { open: isOpen, onOpenChange: () => onClose(), children: [
|
|
884
|
+
/* @__PURE__ */ jsxs3(AlertDialogContent, { className: "rf-max-w-3xl rf-w-full rf-max-h-[90vh] rf-overflow-y-auto rf-flex rf-flex-col", children: [
|
|
885
|
+
/* @__PURE__ */ jsxs3(AlertDialogHeader, { children: [
|
|
886
|
+
/* @__PURE__ */ jsx5(AlertDialogTitle, { children: "Import Component" }),
|
|
887
|
+
/* @__PURE__ */ jsx5(AlertDialogDescription, { children: "Search for components from tscircuit.com or JLCPCB parts library." })
|
|
1169
888
|
] }),
|
|
1170
|
-
/* @__PURE__ */
|
|
889
|
+
/* @__PURE__ */ jsxs3(
|
|
1171
890
|
Tabs,
|
|
1172
891
|
{
|
|
1173
892
|
value: activeTab,
|
|
1174
893
|
onValueChange: (value) => setActiveTab(value),
|
|
1175
894
|
children: [
|
|
1176
|
-
/* @__PURE__ */
|
|
1177
|
-
/* @__PURE__ */
|
|
1178
|
-
/* @__PURE__ */
|
|
895
|
+
/* @__PURE__ */ jsxs3(TabsList, { className: "rf-grid rf-w-full rf-grid-cols-2", children: [
|
|
896
|
+
/* @__PURE__ */ jsx5(TabsTrigger, { value: "tscircuit.com", children: "tscircuit.com" }),
|
|
897
|
+
/* @__PURE__ */ jsx5(TabsTrigger, { value: "jlcpcb", children: "JLCPCB Parts" })
|
|
1179
898
|
] }),
|
|
1180
|
-
/* @__PURE__ */
|
|
1181
|
-
/* @__PURE__ */
|
|
1182
|
-
/* @__PURE__ */
|
|
1183
|
-
/* @__PURE__ */
|
|
899
|
+
/* @__PURE__ */ jsxs3("div", { className: "rf-flex rf-items-center rf-gap-2 rf-mt-4", children: [
|
|
900
|
+
/* @__PURE__ */ jsxs3("div", { className: "rf-relative rf-flex-grow", children: [
|
|
901
|
+
/* @__PURE__ */ jsx5(Search, { className: "rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground" }),
|
|
902
|
+
/* @__PURE__ */ jsx5(
|
|
1184
903
|
Input,
|
|
1185
904
|
{
|
|
1186
905
|
placeholder: activeTab === "tscircuit.com" ? "Search components..." : "Search JLCPCB parts (e.g. C14663)...",
|
|
@@ -1191,22 +910,22 @@ var ImportComponentDialog = ({
|
|
|
1191
910
|
}
|
|
1192
911
|
)
|
|
1193
912
|
] }),
|
|
1194
|
-
/* @__PURE__ */
|
|
913
|
+
/* @__PURE__ */ jsx5(Button, { onClick: handleSearch, disabled: isLoading, children: isLoading ? /* @__PURE__ */ jsx5(Loader22, { className: "rf-h-4 rf-w-4 rf-animate-spin" }) : "Search" })
|
|
1195
914
|
] }),
|
|
1196
|
-
/* @__PURE__ */
|
|
915
|
+
/* @__PURE__ */ jsx5("div", { className: "rf-mt-4 rf-flex-1 rf-min-h-[200px] !rf-max-h-[40vh] !rf-overflow-y-auto rf-border rf-rounded-md", children: searchResults.length > 0 ? /* @__PURE__ */ jsx5("div", { className: "rf-divide-y", children: searchResults.map((result) => /* @__PURE__ */ jsxs3(
|
|
1197
916
|
"div",
|
|
1198
917
|
{
|
|
1199
918
|
className: `rf-p-3 rf-flex rf-items-center rf-justify-between rf-cursor-pointer hover:rf-bg-zinc-100 ${selectedComponent?.id === result.id ? "rf-bg-zinc-100" : ""}`,
|
|
1200
919
|
onClick: () => setSelectedComponent(result),
|
|
1201
920
|
children: [
|
|
1202
|
-
/* @__PURE__ */
|
|
1203
|
-
/* @__PURE__ */
|
|
1204
|
-
/* @__PURE__ */
|
|
1205
|
-
result.partNumber && /* @__PURE__ */
|
|
921
|
+
/* @__PURE__ */ jsxs3("div", { children: [
|
|
922
|
+
/* @__PURE__ */ jsx5("div", { className: "rf-font-medium", children: result.name }),
|
|
923
|
+
/* @__PURE__ */ jsxs3("div", { className: "rf-text-sm rf-text-zinc-500", children: [
|
|
924
|
+
result.partNumber && /* @__PURE__ */ jsx5("span", { className: "rf-mr-2", children: result.partNumber }),
|
|
1206
925
|
result.description
|
|
1207
926
|
] })
|
|
1208
927
|
] }),
|
|
1209
|
-
/* @__PURE__ */
|
|
928
|
+
/* @__PURE__ */ jsx5("div", { className: "rf-flex rf-gap-2", children: result.source === "tscircuit.com" && /* @__PURE__ */ jsx5(
|
|
1210
929
|
Button,
|
|
1211
930
|
{
|
|
1212
931
|
variant: "outline",
|
|
@@ -1221,16 +940,16 @@ var ImportComponentDialog = ({
|
|
|
1221
940
|
]
|
|
1222
941
|
},
|
|
1223
942
|
result.id
|
|
1224
|
-
)) }) : isLoading ? /* @__PURE__ */
|
|
1225
|
-
/* @__PURE__ */
|
|
1226
|
-
/* @__PURE__ */
|
|
1227
|
-
] }) : /* @__PURE__ */
|
|
943
|
+
)) }) : isLoading ? /* @__PURE__ */ jsxs3("div", { className: "rf-p-8 rf-text-center rf-text-zinc-500", children: [
|
|
944
|
+
/* @__PURE__ */ jsx5(Loader22, { className: "rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2" }),
|
|
945
|
+
/* @__PURE__ */ jsx5("p", { children: "Searching..." })
|
|
946
|
+
] }) : /* @__PURE__ */ jsx5("div", { className: "rf-p-8 rf-text-center rf-text-zinc-500", children: hasSearched ? "No results found" : "Enter a search term to find components" }) })
|
|
1228
947
|
]
|
|
1229
948
|
}
|
|
1230
949
|
),
|
|
1231
|
-
/* @__PURE__ */
|
|
1232
|
-
/* @__PURE__ */
|
|
1233
|
-
/* @__PURE__ */
|
|
950
|
+
/* @__PURE__ */ jsxs3(AlertDialogFooter, { children: [
|
|
951
|
+
/* @__PURE__ */ jsx5(AlertDialogCancel, { onClick: onClose, children: "Cancel" }),
|
|
952
|
+
/* @__PURE__ */ jsx5(
|
|
1234
953
|
Button,
|
|
1235
954
|
{
|
|
1236
955
|
onClick: () => {
|
|
@@ -1245,58 +964,58 @@ var ImportComponentDialog = ({
|
|
|
1245
964
|
)
|
|
1246
965
|
] })
|
|
1247
966
|
] }),
|
|
1248
|
-
/* @__PURE__ */
|
|
1249
|
-
/* @__PURE__ */
|
|
1250
|
-
/* @__PURE__ */
|
|
1251
|
-
/* @__PURE__ */
|
|
1252
|
-
/* @__PURE__ */
|
|
1253
|
-
detailsComponent?.partNumber && /* @__PURE__ */
|
|
967
|
+
/* @__PURE__ */ jsx5(AlertDialog, { open: detailsOpen, onOpenChange: setDetailsOpen, children: /* @__PURE__ */ jsxs3(AlertDialogContent, { className: "!rf-max-h-[70%] !rf-overflow-y-auto rf-flex rf-flex-col !rf-max-w-[60vw] !rf-overflow-x-hidden", children: [
|
|
968
|
+
/* @__PURE__ */ jsxs3(AlertDialogHeader, { children: [
|
|
969
|
+
/* @__PURE__ */ jsx5(AlertDialogTitle, { children: detailsComponent?.name }),
|
|
970
|
+
/* @__PURE__ */ jsx5(AlertDialogDescription, { children: "Detailed information about the selected component" }),
|
|
971
|
+
/* @__PURE__ */ jsxs3("div", { className: "rf-text-sm rf-text-muted-foreground", children: [
|
|
972
|
+
detailsComponent?.partNumber && /* @__PURE__ */ jsx5("div", { className: "rf-font-mono rf-text-sm rf-mb-2", children: detailsComponent.partNumber }),
|
|
1254
973
|
detailsComponent?.description
|
|
1255
974
|
] })
|
|
1256
975
|
] }),
|
|
1257
|
-
detailsComponent?.source === "jlcpcb" && /* @__PURE__ */
|
|
1258
|
-
/* @__PURE__ */
|
|
1259
|
-
/* @__PURE__ */
|
|
1260
|
-
detailsComponent.package && /* @__PURE__ */
|
|
1261
|
-
/* @__PURE__ */
|
|
1262
|
-
/* @__PURE__ */
|
|
976
|
+
detailsComponent?.source === "jlcpcb" && /* @__PURE__ */ jsxs3("div", { className: "rf-my-4 rf-border rf-rounded-md rf-p-4", children: [
|
|
977
|
+
/* @__PURE__ */ jsx5("div", { className: "rf-text-sm rf-font-medium rf-mb-2", children: "JLCPCB Details" }),
|
|
978
|
+
/* @__PURE__ */ jsxs3("div", { className: "rf-grid rf-grid-cols-2 rf-gap-2", children: [
|
|
979
|
+
detailsComponent.package && /* @__PURE__ */ jsxs3("div", { className: "rf-flex rf-flex-col", children: [
|
|
980
|
+
/* @__PURE__ */ jsx5("span", { className: "rf-text-xs rf-text-zinc-500", children: "Package" }),
|
|
981
|
+
/* @__PURE__ */ jsx5("span", { className: "rf-font-medium", children: detailsComponent.package })
|
|
1263
982
|
] }),
|
|
1264
|
-
detailsComponent.price !== void 0 && /* @__PURE__ */
|
|
1265
|
-
/* @__PURE__ */
|
|
1266
|
-
/* @__PURE__ */
|
|
983
|
+
detailsComponent.price !== void 0 && /* @__PURE__ */ jsxs3("div", { className: "rf-flex rf-flex-col", children: [
|
|
984
|
+
/* @__PURE__ */ jsx5("span", { className: "rf-text-xs rf-text-zinc-500", children: "Price" }),
|
|
985
|
+
/* @__PURE__ */ jsxs3("span", { className: "rf-font-medium", children: [
|
|
1267
986
|
"$",
|
|
1268
987
|
detailsComponent.price.toFixed(4)
|
|
1269
988
|
] })
|
|
1270
989
|
] })
|
|
1271
990
|
] })
|
|
1272
991
|
] }),
|
|
1273
|
-
detailsComponent?.source === "tscircuit.com" && /* @__PURE__ */
|
|
1274
|
-
/* @__PURE__ */
|
|
1275
|
-
/* @__PURE__ */
|
|
1276
|
-
/* @__PURE__ */
|
|
1277
|
-
/* @__PURE__ */
|
|
992
|
+
detailsComponent?.source === "tscircuit.com" && /* @__PURE__ */ jsxs3("div", { className: "rf-my-4 rf-border rf-rounded-md rf-p-4 !rf-max-w-[60vw] !rf-overflow-x-hidden", children: [
|
|
993
|
+
/* @__PURE__ */ jsx5("div", { className: "rf-text-sm rf-font-medium rf-mb-2", children: "tscircuit Details" }),
|
|
994
|
+
/* @__PURE__ */ jsx5("div", { className: "rf-grid rf-grid-cols-2 rf-gap-2", children: detailsComponent.owner && /* @__PURE__ */ jsxs3("div", { className: "rf-flex rf-flex-col", children: [
|
|
995
|
+
/* @__PURE__ */ jsx5("span", { className: "rf-text-xs rf-text-zinc-500", children: "Owner" }),
|
|
996
|
+
/* @__PURE__ */ jsx5("span", { className: "rf-font-medium", children: detailsComponent.owner })
|
|
1278
997
|
] }) }),
|
|
1279
|
-
detailsComponent.code && /* @__PURE__ */
|
|
1280
|
-
/* @__PURE__ */
|
|
1281
|
-
/* @__PURE__ */
|
|
998
|
+
detailsComponent.code && /* @__PURE__ */ jsxs3("div", { className: "rf-mt-2", children: [
|
|
999
|
+
/* @__PURE__ */ jsx5("div", { className: "rf-text-xs rf-text-zinc-500 rf-mb-1", children: "Code Preview" }),
|
|
1000
|
+
/* @__PURE__ */ jsxs3("pre", { className: "rf-bg-zinc-50 rf-p-2 rf-rounded rf-text-xs rf-font-mono rf-max-h-32 rf-overflow-y-auto", children: [
|
|
1282
1001
|
detailsComponent.code.substring(0, 500),
|
|
1283
1002
|
detailsComponent.code.length > 500 && "..."
|
|
1284
1003
|
] })
|
|
1285
1004
|
] })
|
|
1286
1005
|
] }),
|
|
1287
|
-
/* @__PURE__ */
|
|
1288
|
-
/* @__PURE__ */
|
|
1289
|
-
detailsComponent?.source === "tscircuit.com" && detailsComponent.code ? /* @__PURE__ */
|
|
1006
|
+
/* @__PURE__ */ jsxs3("div", { className: "rf-my-4 rf-border rf-rounded-md rf-p-4", children: [
|
|
1007
|
+
/* @__PURE__ */ jsx5("div", { className: "rf-text-sm rf-font-medium rf-mb-2", children: "Preview" }),
|
|
1008
|
+
detailsComponent?.source === "tscircuit.com" && detailsComponent.code ? /* @__PURE__ */ jsx5("div", { className: "rf-flex rf-justify-center", children: /* @__PURE__ */ jsx5("div", { className: "rf-border rf-rounded rf-p-4 rf-bg-zinc-50", children: /* @__PURE__ */ jsx5(
|
|
1290
1009
|
"img",
|
|
1291
1010
|
{
|
|
1292
1011
|
src: createPngUrl(detailsComponent.code, "pcb"),
|
|
1293
1012
|
alt: detailsComponent.name,
|
|
1294
1013
|
className: "rf-w-full rf-aspect-video rf-object-contain"
|
|
1295
1014
|
}
|
|
1296
|
-
) }) }) : /* @__PURE__ */
|
|
1015
|
+
) }) }) : /* @__PURE__ */ jsx5("div", { className: "rf-text-center rf-text-zinc-500 rf-p-4", children: "No preview available" })
|
|
1297
1016
|
] }),
|
|
1298
|
-
/* @__PURE__ */
|
|
1299
|
-
/* @__PURE__ */
|
|
1017
|
+
/* @__PURE__ */ jsxs3("div", { className: "rf-flex rf-justify-between", children: [
|
|
1018
|
+
/* @__PURE__ */ jsxs3(
|
|
1300
1019
|
Button,
|
|
1301
1020
|
{
|
|
1302
1021
|
variant: "outline",
|
|
@@ -1311,11 +1030,11 @@ var ImportComponentDialog = ({
|
|
|
1311
1030
|
" ",
|
|
1312
1031
|
detailsComponent?.source === "jlcpcb" ? "JLCPCB" : "tscircuit.com",
|
|
1313
1032
|
" ",
|
|
1314
|
-
/* @__PURE__ */
|
|
1033
|
+
/* @__PURE__ */ jsx5(ExternalLink, { className: "rf-h-3 rf-w-3" })
|
|
1315
1034
|
]
|
|
1316
1035
|
}
|
|
1317
1036
|
),
|
|
1318
|
-
/* @__PURE__ */
|
|
1037
|
+
/* @__PURE__ */ jsx5(
|
|
1319
1038
|
Button,
|
|
1320
1039
|
{
|
|
1321
1040
|
onClick: () => {
|
|
@@ -1467,800 +1186,28 @@ var importComponentFromJlcpcb = async (jlcpcbPartNumber) => {
|
|
|
1467
1186
|
return { filePath };
|
|
1468
1187
|
};
|
|
1469
1188
|
|
|
1470
|
-
// lib/components/OrderDialog/useOrderDialog.tsx
|
|
1471
|
-
import { useState as useState9 } from "react";
|
|
1472
|
-
|
|
1473
|
-
// lib/components/OrderDialog/OrderDialog.tsx
|
|
1474
|
-
import ky3 from "ky";
|
|
1475
|
-
import { useState as useState8 } from "react";
|
|
1476
|
-
import { QueryClient, QueryClientProvider } from "react-query";
|
|
1477
|
-
|
|
1478
|
-
// lib/components/OrderDialog/CheckoutOrder.tsx
|
|
1479
|
-
import { MapPin } from "lucide-react";
|
|
1480
|
-
import { useState as useState6 } from "react";
|
|
1481
|
-
import { toast as toast2 } from "react-hot-toast";
|
|
1482
|
-
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1483
|
-
var CheckoutOrder = ({
|
|
1484
|
-
finalCost,
|
|
1485
|
-
onConfirmCheckout,
|
|
1486
|
-
onCancel
|
|
1487
|
-
}) => {
|
|
1488
|
-
const [selectedAddressId, setSelectedAddressId] = useState6(
|
|
1489
|
-
null
|
|
1490
|
-
);
|
|
1491
|
-
const [savedAddresses] = useState6([
|
|
1492
|
-
{
|
|
1493
|
-
id: 1,
|
|
1494
|
-
name: "Home",
|
|
1495
|
-
street: "123 Main St",
|
|
1496
|
-
city: "San Francisco",
|
|
1497
|
-
state: "CA",
|
|
1498
|
-
zipCode: "94105",
|
|
1499
|
-
country: "USA",
|
|
1500
|
-
isDefault: true
|
|
1501
|
-
},
|
|
1502
|
-
{
|
|
1503
|
-
id: 2,
|
|
1504
|
-
name: "Office",
|
|
1505
|
-
street: "456 Market St",
|
|
1506
|
-
city: "San Francisco",
|
|
1507
|
-
state: "CA",
|
|
1508
|
-
zipCode: "94103",
|
|
1509
|
-
country: "USA",
|
|
1510
|
-
isDefault: false
|
|
1511
|
-
}
|
|
1512
|
-
]);
|
|
1513
|
-
const [addressForm, setAddressForm] = useState6({
|
|
1514
|
-
name: "",
|
|
1515
|
-
street: "",
|
|
1516
|
-
city: "",
|
|
1517
|
-
state: "",
|
|
1518
|
-
zipCode: "",
|
|
1519
|
-
country: ""
|
|
1520
|
-
});
|
|
1521
|
-
const handleInputChange = (e) => {
|
|
1522
|
-
const { name, value } = e.target;
|
|
1523
|
-
setAddressForm((prev) => ({
|
|
1524
|
-
...prev,
|
|
1525
|
-
[name]: value
|
|
1526
|
-
}));
|
|
1527
|
-
};
|
|
1528
|
-
const handleSelectAddress = (addressId) => {
|
|
1529
|
-
setSelectedAddressId(addressId);
|
|
1530
|
-
const selectedAddress = savedAddresses.find((addr) => addr.id === addressId);
|
|
1531
|
-
if (selectedAddress) {
|
|
1532
|
-
setAddressForm({
|
|
1533
|
-
name: selectedAddress.name,
|
|
1534
|
-
street: selectedAddress.street,
|
|
1535
|
-
city: selectedAddress.city,
|
|
1536
|
-
state: selectedAddress.state,
|
|
1537
|
-
zipCode: selectedAddress.zipCode,
|
|
1538
|
-
country: selectedAddress.country
|
|
1539
|
-
});
|
|
1540
|
-
}
|
|
1541
|
-
};
|
|
1542
|
-
const handleConfirmCheckout = () => {
|
|
1543
|
-
if (!selectedAddressId && (!addressForm.street || !addressForm.city || !addressForm.zipCode)) {
|
|
1544
|
-
toast2.error("Please provide a complete shipping address.");
|
|
1545
|
-
return;
|
|
1546
|
-
}
|
|
1547
|
-
toast2.success("Your PCB order has been placed successfully.");
|
|
1548
|
-
onConfirmCheckout();
|
|
1549
|
-
};
|
|
1550
|
-
return /* @__PURE__ */ jsxs5("div", { className: "rf-bg-white rf-rounded-xl rf-p-6 rf-mx-auto", children: [
|
|
1551
|
-
/* @__PURE__ */ jsx8("h2", { className: "rf-text-2xl rf-font-bold rf-mb-6", children: "Checkout" }),
|
|
1552
|
-
/* @__PURE__ */ jsxs5("div", { className: "rf-grid rf-grid-cols-1 md:rf-grid-cols-2 rf-gap-8", children: [
|
|
1553
|
-
/* @__PURE__ */ jsxs5("div", { className: "rf-space-y-6", children: [
|
|
1554
|
-
/* @__PURE__ */ jsx8("h3", { className: "rf-text-lg rf-font-semibold", children: "Shipping Address" }),
|
|
1555
|
-
savedAddresses.length > 0 && /* @__PURE__ */ jsxs5("div", { className: "rf-space-y-4", children: [
|
|
1556
|
-
/* @__PURE__ */ jsx8("div", { className: "rf-text-sm rf-font-medium rf-text-gray-500", children: "Saved Addresses" }),
|
|
1557
|
-
/* @__PURE__ */ jsx8("div", { className: "rf-flex rf-flex-wrap rf-gap-3", children: savedAddresses.map((address) => /* @__PURE__ */ jsxs5(
|
|
1558
|
-
"button",
|
|
1559
|
-
{
|
|
1560
|
-
type: "button",
|
|
1561
|
-
onClick: () => handleSelectAddress(address.id),
|
|
1562
|
-
className: cn(
|
|
1563
|
-
"rf-flex rf-items-center rf-gap-2 rf-px-3 rf-py-2 rf-text-sm rf-rounded-md rf-border rf-transition-colors",
|
|
1564
|
-
selectedAddressId === address.id ? "rf-border-blue-500 rf-bg-blue-50 rf-text-blue-700" : "rf-border-gray-200 rf-hover:bg-gray-50"
|
|
1565
|
-
),
|
|
1566
|
-
children: [
|
|
1567
|
-
/* @__PURE__ */ jsx8(MapPin, { className: "rf-h-4 rf-w-4" }),
|
|
1568
|
-
/* @__PURE__ */ jsx8("span", { children: address.name }),
|
|
1569
|
-
address.isDefault && /* @__PURE__ */ jsx8("span", { className: "rf-inline-flex rf-items-center rf-rounded-full rf-bg-blue-100 rf-px-2 rf-py-0.5 rf-text-xs rf-font-medium rf-text-blue-800", children: "Default" })
|
|
1570
|
-
]
|
|
1571
|
-
},
|
|
1572
|
-
address.id
|
|
1573
|
-
)) })
|
|
1574
|
-
] }),
|
|
1575
|
-
/* @__PURE__ */ jsxs5("div", { className: "rf-space-y-4", children: [
|
|
1576
|
-
/* @__PURE__ */ jsx8("div", { className: "rf-grid rf-grid-cols-2 rf-gap-4", children: /* @__PURE__ */ jsxs5("div", { className: "rf-space-y-2", children: [
|
|
1577
|
-
/* @__PURE__ */ jsx8("label", { htmlFor: "name", children: "Address Name" }),
|
|
1578
|
-
/* @__PURE__ */ jsx8(
|
|
1579
|
-
Input,
|
|
1580
|
-
{
|
|
1581
|
-
id: "name",
|
|
1582
|
-
name: "name",
|
|
1583
|
-
placeholder: "Home, Office, etc.",
|
|
1584
|
-
value: addressForm.name,
|
|
1585
|
-
onChange: handleInputChange
|
|
1586
|
-
}
|
|
1587
|
-
)
|
|
1588
|
-
] }) }),
|
|
1589
|
-
/* @__PURE__ */ jsxs5("div", { className: "rf-space-y-2", children: [
|
|
1590
|
-
/* @__PURE__ */ jsx8("label", { htmlFor: "street", children: "Street Address" }),
|
|
1591
|
-
/* @__PURE__ */ jsx8(
|
|
1592
|
-
Input,
|
|
1593
|
-
{
|
|
1594
|
-
id: "street",
|
|
1595
|
-
name: "street",
|
|
1596
|
-
placeholder: "123 Main St",
|
|
1597
|
-
value: addressForm.street,
|
|
1598
|
-
onChange: handleInputChange
|
|
1599
|
-
}
|
|
1600
|
-
)
|
|
1601
|
-
] }),
|
|
1602
|
-
/* @__PURE__ */ jsxs5("div", { className: "rf-grid rf-grid-cols-2 rf-gap-4", children: [
|
|
1603
|
-
/* @__PURE__ */ jsxs5("div", { className: "rf-space-y-2", children: [
|
|
1604
|
-
/* @__PURE__ */ jsx8("label", { htmlFor: "city", children: "City" }),
|
|
1605
|
-
/* @__PURE__ */ jsx8(
|
|
1606
|
-
Input,
|
|
1607
|
-
{
|
|
1608
|
-
id: "city",
|
|
1609
|
-
name: "city",
|
|
1610
|
-
placeholder: "City",
|
|
1611
|
-
value: addressForm.city,
|
|
1612
|
-
onChange: handleInputChange
|
|
1613
|
-
}
|
|
1614
|
-
)
|
|
1615
|
-
] }),
|
|
1616
|
-
/* @__PURE__ */ jsxs5("div", { className: "rf-space-y-2", children: [
|
|
1617
|
-
/* @__PURE__ */ jsx8("label", { htmlFor: "state", children: "State" }),
|
|
1618
|
-
/* @__PURE__ */ jsx8(
|
|
1619
|
-
Input,
|
|
1620
|
-
{
|
|
1621
|
-
id: "state",
|
|
1622
|
-
name: "state",
|
|
1623
|
-
placeholder: "State",
|
|
1624
|
-
value: addressForm.state,
|
|
1625
|
-
onChange: handleInputChange
|
|
1626
|
-
}
|
|
1627
|
-
)
|
|
1628
|
-
] })
|
|
1629
|
-
] }),
|
|
1630
|
-
/* @__PURE__ */ jsxs5("div", { className: "rf-grid rf-grid-cols-2 rf-gap-4", children: [
|
|
1631
|
-
/* @__PURE__ */ jsxs5("div", { className: "rf-space-y-2", children: [
|
|
1632
|
-
/* @__PURE__ */ jsx8("label", { htmlFor: "zipCode", children: "Zip Code" }),
|
|
1633
|
-
/* @__PURE__ */ jsx8(
|
|
1634
|
-
Input,
|
|
1635
|
-
{
|
|
1636
|
-
id: "zipCode",
|
|
1637
|
-
name: "zipCode",
|
|
1638
|
-
placeholder: "Zip Code",
|
|
1639
|
-
value: addressForm.zipCode,
|
|
1640
|
-
onChange: handleInputChange
|
|
1641
|
-
}
|
|
1642
|
-
)
|
|
1643
|
-
] }),
|
|
1644
|
-
/* @__PURE__ */ jsxs5("div", { className: "rf-space-y-2", children: [
|
|
1645
|
-
/* @__PURE__ */ jsx8("label", { htmlFor: "country", children: "Country" }),
|
|
1646
|
-
/* @__PURE__ */ jsx8(
|
|
1647
|
-
Input,
|
|
1648
|
-
{
|
|
1649
|
-
id: "country",
|
|
1650
|
-
name: "country",
|
|
1651
|
-
placeholder: "Country",
|
|
1652
|
-
value: addressForm.country,
|
|
1653
|
-
onChange: handleInputChange
|
|
1654
|
-
}
|
|
1655
|
-
)
|
|
1656
|
-
] })
|
|
1657
|
-
] })
|
|
1658
|
-
] })
|
|
1659
|
-
] }),
|
|
1660
|
-
/* @__PURE__ */ jsxs5("div", { className: "rf-bg-gray-50 rf-p-6 rf-rounded-lg", children: [
|
|
1661
|
-
/* @__PURE__ */ jsx8("h3", { className: "rf-text-lg rf-font-semibold rf-mb-4", children: "Order Summary" }),
|
|
1662
|
-
/* @__PURE__ */ jsxs5("div", { className: "rf-space-y-4", children: [
|
|
1663
|
-
/* @__PURE__ */ jsxs5("div", { className: "rf-flex rf-justify-between rf-py-2 rf-border-b rf-border-gray-200", children: [
|
|
1664
|
-
/* @__PURE__ */ jsx8("span", { className: "rf-text-gray-600", children: "PCB Manufacturing" }),
|
|
1665
|
-
/* @__PURE__ */ jsxs5("span", { className: "rf-font-medium", children: [
|
|
1666
|
-
"$",
|
|
1667
|
-
(finalCost * 0.6).toFixed(2)
|
|
1668
|
-
] })
|
|
1669
|
-
] }),
|
|
1670
|
-
/* @__PURE__ */ jsxs5("div", { className: "rf-flex rf-justify-between rf-py-2 rf-border-b rf-border-gray-200", children: [
|
|
1671
|
-
/* @__PURE__ */ jsx8("span", { className: "rf-text-gray-600", children: "Components" }),
|
|
1672
|
-
/* @__PURE__ */ jsxs5("span", { className: "rf-font-medium", children: [
|
|
1673
|
-
"$",
|
|
1674
|
-
(finalCost * 0.3).toFixed(2)
|
|
1675
|
-
] })
|
|
1676
|
-
] }),
|
|
1677
|
-
/* @__PURE__ */ jsxs5("div", { className: "rf-flex rf-justify-between rf-py-2 rf-border-b rf-border-gray-200", children: [
|
|
1678
|
-
/* @__PURE__ */ jsx8("span", { className: "rf-text-gray-600", children: "Assembly" }),
|
|
1679
|
-
/* @__PURE__ */ jsxs5("span", { className: "rf-font-medium", children: [
|
|
1680
|
-
"$",
|
|
1681
|
-
(finalCost * 0.1).toFixed(2)
|
|
1682
|
-
] })
|
|
1683
|
-
] }),
|
|
1684
|
-
/* @__PURE__ */ jsxs5("div", { className: "rf-flex rf-justify-between rf-py-2 rf-border-b rf-border-gray-200", children: [
|
|
1685
|
-
/* @__PURE__ */ jsx8("span", { className: "rf-text-gray-600", children: "Shipping" }),
|
|
1686
|
-
/* @__PURE__ */ jsx8("span", { className: "rf-font-medium", children: "$15.00" })
|
|
1687
|
-
] }),
|
|
1688
|
-
/* @__PURE__ */ jsxs5("div", { className: "rf-flex rf-justify-between rf-py-2 rf-text-lg rf-font-bold", children: [
|
|
1689
|
-
/* @__PURE__ */ jsx8("span", { children: "Total" }),
|
|
1690
|
-
/* @__PURE__ */ jsxs5("span", { children: [
|
|
1691
|
-
"$",
|
|
1692
|
-
(finalCost + 15).toFixed(2)
|
|
1693
|
-
] })
|
|
1694
|
-
] }),
|
|
1695
|
-
/* @__PURE__ */ jsxs5("div", { className: "rf-pt-4", children: [
|
|
1696
|
-
/* @__PURE__ */ jsx8(
|
|
1697
|
-
Button,
|
|
1698
|
-
{
|
|
1699
|
-
onClick: handleConfirmCheckout,
|
|
1700
|
-
className: "rf-w-full rf-bg-gray-700 rf-hover:bg-gray-800 rf-text-white rf-py-3",
|
|
1701
|
-
children: "Confirm and Place Order"
|
|
1702
|
-
}
|
|
1703
|
-
),
|
|
1704
|
-
/* @__PURE__ */ jsx8(
|
|
1705
|
-
Button,
|
|
1706
|
-
{
|
|
1707
|
-
variant: "outline",
|
|
1708
|
-
onClick: onCancel,
|
|
1709
|
-
className: "rf-w-full rf-mt-3",
|
|
1710
|
-
children: "Cancel"
|
|
1711
|
-
}
|
|
1712
|
-
)
|
|
1713
|
-
] })
|
|
1714
|
-
] })
|
|
1715
|
-
] })
|
|
1716
|
-
] })
|
|
1717
|
-
] });
|
|
1718
|
-
};
|
|
1719
|
-
|
|
1720
|
-
// lib/components/ui/select.tsx
|
|
1721
|
-
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
1722
|
-
import { Check as Check2, ChevronDown, ChevronUp } from "lucide-react";
|
|
1723
|
-
import * as React5 from "react";
|
|
1724
|
-
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1725
|
-
var Select = SelectPrimitive.Root;
|
|
1726
|
-
var SelectValue = SelectPrimitive.Value;
|
|
1727
|
-
var SelectTrigger = React5.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs6(
|
|
1728
|
-
SelectPrimitive.Trigger,
|
|
1729
|
-
{
|
|
1730
|
-
ref,
|
|
1731
|
-
className: cn(
|
|
1732
|
-
"rf-flex rf-h-10 rf-w-full rf-items-center rf-justify-between rf-rounded-md rf-border rf-border-input rf-bg-background rf-px-3 rf-py-2 rf-text-sm rf-ring-offset-background rf-placeholder:text-muted-foreground focus:rf-outline-none focus:rf-ring-2 focus:rf-ring-ring focus:rf-ring-offset-2 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 [&>span]:rf-line-clamp-1",
|
|
1733
|
-
className
|
|
1734
|
-
),
|
|
1735
|
-
...props,
|
|
1736
|
-
children: [
|
|
1737
|
-
children,
|
|
1738
|
-
/* @__PURE__ */ jsx9(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx9(ChevronDown, { className: "rf-h-4 rf-w-4 rf-opacity-50" }) })
|
|
1739
|
-
]
|
|
1740
|
-
}
|
|
1741
|
-
));
|
|
1742
|
-
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
1743
|
-
var SelectScrollUpButton = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx9(
|
|
1744
|
-
SelectPrimitive.ScrollUpButton,
|
|
1745
|
-
{
|
|
1746
|
-
ref,
|
|
1747
|
-
className: cn(
|
|
1748
|
-
"rf-flex rf-cursor-default rf-items-center rf-justify-center rf-py-1",
|
|
1749
|
-
className
|
|
1750
|
-
),
|
|
1751
|
-
...props,
|
|
1752
|
-
children: /* @__PURE__ */ jsx9(ChevronUp, { className: "rf-h-4 rf-w-4" })
|
|
1753
|
-
}
|
|
1754
|
-
));
|
|
1755
|
-
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
1756
|
-
var SelectScrollDownButton = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx9(
|
|
1757
|
-
SelectPrimitive.ScrollDownButton,
|
|
1758
|
-
{
|
|
1759
|
-
ref,
|
|
1760
|
-
className: cn(
|
|
1761
|
-
"rf-flex rf-cursor-default rf-items-center rf-justify-center rf-py-1",
|
|
1762
|
-
className
|
|
1763
|
-
),
|
|
1764
|
-
...props,
|
|
1765
|
-
children: /* @__PURE__ */ jsx9(ChevronDown, { className: "rf-h-4 rf-w-4" })
|
|
1766
|
-
}
|
|
1767
|
-
));
|
|
1768
|
-
SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
|
|
1769
|
-
var SelectContent = React5.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsx9(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsxs6(
|
|
1770
|
-
SelectPrimitive.Content,
|
|
1771
|
-
{
|
|
1772
|
-
ref,
|
|
1773
|
-
className: cn(
|
|
1774
|
-
"rf-relative rf-z-[100] rf-max-h-96 rf-min-w-[8rem] rf-overflow-hidden rf-rounded-md rf-border rf-bg-white rf-text-black rf-shadow-md data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[side=bottom]:rf-slide-in-from-top-2 data-[side=left]:rf-slide-in-from-right-2 data-[side=right]:rf-slide-in-from-left-2 data-[side=top]:rf-slide-in-from-bottom-2",
|
|
1775
|
-
position === "popper" && "data-[side=bottom]:rf-translate-y-1 data-[side=left]:-rf-translate-x-1 data-[side=right]:rf-translate-x-1 data-[side=top]:-rf-translate-y-1",
|
|
1776
|
-
className
|
|
1777
|
-
),
|
|
1778
|
-
position,
|
|
1779
|
-
...props,
|
|
1780
|
-
children: [
|
|
1781
|
-
/* @__PURE__ */ jsx9(SelectScrollUpButton, {}),
|
|
1782
|
-
/* @__PURE__ */ jsx9(
|
|
1783
|
-
SelectPrimitive.Viewport,
|
|
1784
|
-
{
|
|
1785
|
-
className: cn(
|
|
1786
|
-
"rf-p-1",
|
|
1787
|
-
position === "popper" && "rf-h-[var(--radix-select-trigger-height)] rf-w-full rf-min-w-[var(--radix-select-trigger-width)]"
|
|
1788
|
-
),
|
|
1789
|
-
children
|
|
1790
|
-
}
|
|
1791
|
-
),
|
|
1792
|
-
/* @__PURE__ */ jsx9(SelectScrollDownButton, {})
|
|
1793
|
-
]
|
|
1794
|
-
}
|
|
1795
|
-
) }));
|
|
1796
|
-
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
1797
|
-
var SelectLabel = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx9(
|
|
1798
|
-
SelectPrimitive.Label,
|
|
1799
|
-
{
|
|
1800
|
-
ref,
|
|
1801
|
-
className: cn(
|
|
1802
|
-
"rf-py-1.5 rf-pl-8 rf-pr-2 rf-text-sm rf-font-semibold",
|
|
1803
|
-
className
|
|
1804
|
-
),
|
|
1805
|
-
...props
|
|
1806
|
-
}
|
|
1807
|
-
));
|
|
1808
|
-
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
1809
|
-
var SelectItem = React5.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs6(
|
|
1810
|
-
SelectPrimitive.Item,
|
|
1811
|
-
{
|
|
1812
|
-
ref,
|
|
1813
|
-
className: cn(
|
|
1814
|
-
"rf-relative rf-flex rf-w-full rf-cursor-default rf-select-none rf-items-center rf-rounded-sm rf-py-1.5 rf-pl-8 rf-pr-2 rf-text-sm rf-text-gray-800 rf-outline-none focus:rf-bg-gray-100 focus:rf-text-gray-900 data-[disabled]:rf-pointer-events-none data-[disabled]:rf-opacity-50",
|
|
1815
|
-
className
|
|
1816
|
-
),
|
|
1817
|
-
...props,
|
|
1818
|
-
children: [
|
|
1819
|
-
/* @__PURE__ */ jsx9("span", { className: "rf-absolute rf-left-2 rf-flex rf-h-3.5 rf-w-3.5 rf-items-center rf-justify-center", children: /* @__PURE__ */ jsx9(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx9(Check2, { className: "rf-h-4 rf-w-4" }) }) }),
|
|
1820
|
-
/* @__PURE__ */ jsx9(SelectPrimitive.ItemText, { children })
|
|
1821
|
-
]
|
|
1822
|
-
}
|
|
1823
|
-
));
|
|
1824
|
-
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
1825
|
-
var SelectSeparator = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx9(
|
|
1826
|
-
SelectPrimitive.Separator,
|
|
1827
|
-
{
|
|
1828
|
-
ref,
|
|
1829
|
-
className: cn("-rf-mx-1 rf-my-1 rf-h-px rf-bg-muted", className),
|
|
1830
|
-
...props
|
|
1831
|
-
}
|
|
1832
|
-
));
|
|
1833
|
-
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
1834
|
-
|
|
1835
|
-
// lib/components/ui/skeleton.tsx
|
|
1836
|
-
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
1837
|
-
function Skeleton({
|
|
1838
|
-
className,
|
|
1839
|
-
...props
|
|
1840
|
-
}) {
|
|
1841
|
-
return /* @__PURE__ */ jsx10(
|
|
1842
|
-
"div",
|
|
1843
|
-
{
|
|
1844
|
-
className: cn("rf-animate-pulse rf-rounded-md rf-bg-muted", className),
|
|
1845
|
-
...props
|
|
1846
|
-
}
|
|
1847
|
-
);
|
|
1848
|
-
}
|
|
1849
|
-
|
|
1850
|
-
// lib/components/OrderDialog/InitialOrder.tsx
|
|
1851
|
-
import { ArrowDown } from "lucide-react";
|
|
1852
|
-
import { useEffect as useEffect8 } from "react";
|
|
1853
|
-
import { useState as useState7 } from "react";
|
|
1854
|
-
import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1855
|
-
var InitialOrderScreen = ({
|
|
1856
|
-
onCancel,
|
|
1857
|
-
onContinue
|
|
1858
|
-
}) => {
|
|
1859
|
-
const productCategories = [
|
|
1860
|
-
{ id: "prototype", name: "Prototype" },
|
|
1861
|
-
{ id: "development", name: "Development board" }
|
|
1862
|
-
];
|
|
1863
|
-
const [isLoading, setIsLoading] = useState7(false);
|
|
1864
|
-
const [estimatedCost, setEstimatedCost] = useState7(null);
|
|
1865
|
-
const [selectedCategory, setSelectedCategory] = useState7("prototype");
|
|
1866
|
-
useEffect8(() => {
|
|
1867
|
-
handleGetEstimate();
|
|
1868
|
-
}, []);
|
|
1869
|
-
const handleSelectCategory = (category) => {
|
|
1870
|
-
setSelectedCategory(category);
|
|
1871
|
-
setEstimatedCost(null);
|
|
1872
|
-
setTimeout(() => {
|
|
1873
|
-
handleGetEstimate();
|
|
1874
|
-
}, 0);
|
|
1875
|
-
};
|
|
1876
|
-
const handleGetEstimate = () => {
|
|
1877
|
-
if (!selectedCategory) return;
|
|
1878
|
-
setIsLoading(true);
|
|
1879
|
-
setEstimatedCost(null);
|
|
1880
|
-
setTimeout(() => {
|
|
1881
|
-
const cost = Math.floor(Math.random() * 150) + 50;
|
|
1882
|
-
setEstimatedCost(cost);
|
|
1883
|
-
setIsLoading(false);
|
|
1884
|
-
}, 1500);
|
|
1885
|
-
};
|
|
1886
|
-
return /* @__PURE__ */ jsxs7("div", { className: "rf-flex rf-flex-col rf-bg-white rf-rounded-xl rf-p-8 rf-max-w-md rf-w-full rf-mx-auto", children: [
|
|
1887
|
-
/* @__PURE__ */ jsx11("h2", { className: "rf-text-3xl rf-font-bold rf-text-center rf-mb-8", children: "Order PCB" }),
|
|
1888
|
-
/* @__PURE__ */ jsxs7("div", { className: "rf-mb-8", children: [
|
|
1889
|
-
/* @__PURE__ */ jsx11(
|
|
1890
|
-
"label",
|
|
1891
|
-
{
|
|
1892
|
-
htmlFor: "category",
|
|
1893
|
-
className: "rf-block rf-text-sm rf-font-medium rf-text-gray-700 rf-mb-2",
|
|
1894
|
-
children: "Select Product Category"
|
|
1895
|
-
}
|
|
1896
|
-
),
|
|
1897
|
-
/* @__PURE__ */ jsxs7(
|
|
1898
|
-
Select,
|
|
1899
|
-
{
|
|
1900
|
-
onValueChange: handleSelectCategory,
|
|
1901
|
-
value: selectedCategory || void 0,
|
|
1902
|
-
children: [
|
|
1903
|
-
/* @__PURE__ */ jsx11(SelectTrigger, { className: "rf-w-full", children: /* @__PURE__ */ jsx11(SelectValue, { placeholder: "Select a category" }) }),
|
|
1904
|
-
/* @__PURE__ */ jsx11(SelectContent, { children: productCategories.map((category) => /* @__PURE__ */ jsx11(SelectItem, { value: category.id, children: category.name }, category.id)) })
|
|
1905
|
-
]
|
|
1906
|
-
}
|
|
1907
|
-
)
|
|
1908
|
-
] }),
|
|
1909
|
-
isLoading ? /* @__PURE__ */ jsxs7("div", { className: "rf-flex rf-flex-col rf-items-center rf-mb-8", children: [
|
|
1910
|
-
/* @__PURE__ */ jsxs7("div", { className: "rf-animate-pulse rf-flex rf-space-x-2 rf-items-center rf-mb-3", children: [
|
|
1911
|
-
/* @__PURE__ */ jsx11(ArrowDown, { className: "rf-h-5 rf-w-5 rf-text-gray-400" }),
|
|
1912
|
-
/* @__PURE__ */ jsx11("span", { className: "rf-text-gray-500", children: "Fetching estimate..." })
|
|
1913
|
-
] }),
|
|
1914
|
-
/* @__PURE__ */ jsx11(Skeleton, { className: "rf-h-6 rf-w-3/4 rf-mb-2" }),
|
|
1915
|
-
/* @__PURE__ */ jsx11(Skeleton, { className: "rf-h-6 rf-w-1/2" })
|
|
1916
|
-
] }) : estimatedCost !== null ? /* @__PURE__ */ jsxs7("div", { className: "rf-bg-gray-50 rf-p-4 rf-rounded-lg rf-mb-8", children: [
|
|
1917
|
-
/* @__PURE__ */ jsx11("p", { className: "rf-text-sm rf-text-gray-600 rf-mb-2", children: "Estimated Cost:" }),
|
|
1918
|
-
/* @__PURE__ */ jsxs7("p", { className: "rf-text-2xl rf-font-bold rf-text-gray-900", children: [
|
|
1919
|
-
"$",
|
|
1920
|
-
estimatedCost.toFixed(2)
|
|
1921
|
-
] }),
|
|
1922
|
-
/* @__PURE__ */ jsx11("p", { className: "rf-text-xs rf-text-gray-500 rf-mt-1", children: "Pricing may vary based on specifications" })
|
|
1923
|
-
] }) : null,
|
|
1924
|
-
/* @__PURE__ */ jsxs7("div", { className: "rf-flex rf-justify-between rf-mt-auto", children: [
|
|
1925
|
-
/* @__PURE__ */ jsx11(
|
|
1926
|
-
Button,
|
|
1927
|
-
{
|
|
1928
|
-
variant: "outline",
|
|
1929
|
-
onClick: onCancel,
|
|
1930
|
-
className: "rf-px-8 rf-border-red-500 rf-text-red-500 hover:rf-bg-red-50 hover:rf-text-red-600",
|
|
1931
|
-
children: "Cancel"
|
|
1932
|
-
}
|
|
1933
|
-
),
|
|
1934
|
-
/* @__PURE__ */ jsx11(
|
|
1935
|
-
Button,
|
|
1936
|
-
{
|
|
1937
|
-
onClick: estimatedCost !== null ? onContinue : handleGetEstimate,
|
|
1938
|
-
disabled: !selectedCategory || isLoading,
|
|
1939
|
-
className: estimatedCost !== null ? "rf-px-8 rf-bg-gray-700 hover:rf-bg-gray-800" : "rf-px-8 rf-bg-blue-600 hover:rf-bg-blue-700",
|
|
1940
|
-
children: estimatedCost !== null ? "Continue" : "Get Estimate"
|
|
1941
|
-
}
|
|
1942
|
-
)
|
|
1943
|
-
] })
|
|
1944
|
-
] });
|
|
1945
|
-
};
|
|
1946
|
-
|
|
1947
|
-
// lib/components/OrderDialog/StepwiseProgress.tsx
|
|
1948
|
-
import ky2 from "ky";
|
|
1949
|
-
|
|
1950
|
-
// lib/components/ui/progress.tsx
|
|
1951
|
-
import * as React6 from "react";
|
|
1952
|
-
import * as ProgressPrimitive from "@radix-ui/react-progress";
|
|
1953
|
-
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
1954
|
-
var Progress = React6.forwardRef(({ className, value, ...props }, ref) => /* @__PURE__ */ jsx12(
|
|
1955
|
-
ProgressPrimitive.Root,
|
|
1956
|
-
{
|
|
1957
|
-
ref,
|
|
1958
|
-
className: cn(
|
|
1959
|
-
"rf-relative rf-h-2 rf-w-full rf-overflow-hidden rf-rounded-full rf-bg-zinc-100 dark:rf-bg-zinc-800",
|
|
1960
|
-
className
|
|
1961
|
-
),
|
|
1962
|
-
...props,
|
|
1963
|
-
children: /* @__PURE__ */ jsx12(
|
|
1964
|
-
ProgressPrimitive.Indicator,
|
|
1965
|
-
{
|
|
1966
|
-
className: "rf-h-full rf-w-full rf-flex-1 rf-bg-zinc-900 rf-transition-all dark:rf-bg-zinc-50",
|
|
1967
|
-
style: { transform: `translateX(-${100 - (value || 0)}%)` }
|
|
1968
|
-
}
|
|
1969
|
-
)
|
|
1970
|
-
}
|
|
1971
|
-
));
|
|
1972
|
-
Progress.displayName = "Progress";
|
|
1973
|
-
|
|
1974
|
-
// lib/components/OrderDialog/StepwiseProgress.tsx
|
|
1975
|
-
import { ArrowDown as ArrowDown2, Check as Check3, Loader2 as Loader23 } from "lucide-react";
|
|
1976
|
-
import { useQuery } from "react-query";
|
|
1977
|
-
|
|
1978
|
-
// lib/utils/order-steps.ts
|
|
1979
|
-
var orderSteps = [
|
|
1980
|
-
{ order_step_id: 1, key: "are_gerbers_generated", title: "Generate Gerbers" },
|
|
1981
|
-
{ order_step_id: 2, key: "are_gerbers_uploaded", title: "Upload Gerbers" },
|
|
1982
|
-
{ order_step_id: 3, key: "is_gerber_analyzed", title: "Analyze Gerber" },
|
|
1983
|
-
{
|
|
1984
|
-
order_step_id: 4,
|
|
1985
|
-
key: "are_initial_costs_calculated",
|
|
1986
|
-
title: "Calculate Initial Costs"
|
|
1987
|
-
},
|
|
1988
|
-
{ order_step_id: 5, key: "is_pcb_added_to_cart", title: "Add PCB to Cart" },
|
|
1989
|
-
{ order_step_id: 6, key: "is_bom_uploaded", title: "Upload BOM" },
|
|
1990
|
-
{ order_step_id: 7, key: "is_pnp_uploaded", title: "Upload PnP" },
|
|
1991
|
-
{ order_step_id: 8, key: "is_bom_pnp_analyzed", title: "Analyze BOM & PnP" },
|
|
1992
|
-
{
|
|
1993
|
-
order_step_id: 9,
|
|
1994
|
-
key: "is_bom_parsing_complete",
|
|
1995
|
-
title: "BOM Parsing Complete"
|
|
1996
|
-
},
|
|
1997
|
-
{
|
|
1998
|
-
order_step_id: 10,
|
|
1999
|
-
key: "are_components_available",
|
|
2000
|
-
title: "Components Available"
|
|
2001
|
-
},
|
|
2002
|
-
{
|
|
2003
|
-
order_step_id: 11,
|
|
2004
|
-
key: "is_patch_map_generated",
|
|
2005
|
-
title: "Generate Patch Map"
|
|
2006
|
-
},
|
|
2007
|
-
{
|
|
2008
|
-
order_step_id: 12,
|
|
2009
|
-
key: "is_json_merge_file_created",
|
|
2010
|
-
title: "Create JSON Merge File"
|
|
2011
|
-
},
|
|
2012
|
-
{
|
|
2013
|
-
order_step_id: 13,
|
|
2014
|
-
key: "is_dfm_result_generated",
|
|
2015
|
-
title: "Generate DFM Result"
|
|
2016
|
-
},
|
|
2017
|
-
{ order_step_id: 14, key: "are_files_downloaded", title: "Download Files" },
|
|
2018
|
-
{
|
|
2019
|
-
order_step_id: 15,
|
|
2020
|
-
key: "are_product_categories_fetched",
|
|
2021
|
-
title: "Fetch Product Categories"
|
|
2022
|
-
},
|
|
2023
|
-
{
|
|
2024
|
-
order_step_id: 16,
|
|
2025
|
-
key: "are_final_costs_calculated",
|
|
2026
|
-
title: "Calculate Final Costs"
|
|
2027
|
-
},
|
|
2028
|
-
{
|
|
2029
|
-
order_step_id: 17,
|
|
2030
|
-
key: "is_json_merge_file_updated",
|
|
2031
|
-
title: "Update JSON Merge File"
|
|
2032
|
-
},
|
|
2033
|
-
{ order_step_id: 18, key: "is_added_to_cart", title: "Add to Cart" }
|
|
2034
|
-
].map((step, index) => ({
|
|
2035
|
-
...step,
|
|
2036
|
-
completed: false,
|
|
2037
|
-
active: index === 0
|
|
2038
|
-
// First step starts as active
|
|
2039
|
-
}));
|
|
2040
|
-
|
|
2041
|
-
// lib/components/OrderDialog/StepwiseProgress.tsx
|
|
2042
|
-
import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2043
|
-
var StepwiseProgressPanel = ({
|
|
2044
|
-
orderId,
|
|
2045
|
-
title = "Order PCB",
|
|
2046
|
-
onCancel,
|
|
2047
|
-
loading: externalLoading = false,
|
|
2048
|
-
setStage
|
|
2049
|
-
}) => {
|
|
2050
|
-
const { data, isLoading } = useQuery({
|
|
2051
|
-
queryKey: ["orderState", orderId],
|
|
2052
|
-
queryFn: async () => {
|
|
2053
|
-
const response = await ky2.get("registry/orders/get", {
|
|
2054
|
-
searchParams: { order_id: orderId },
|
|
2055
|
-
headers: {
|
|
2056
|
-
Authorization: `Bearer account-1234`
|
|
2057
|
-
}
|
|
2058
|
-
}).json();
|
|
2059
|
-
if (response.orderState.current_step === "is_added_to_cart") {
|
|
2060
|
-
setStage("checkout");
|
|
2061
|
-
}
|
|
2062
|
-
return response;
|
|
2063
|
-
},
|
|
2064
|
-
refetchInterval: 2e3,
|
|
2065
|
-
refetchIntervalInBackground: true
|
|
2066
|
-
});
|
|
2067
|
-
const steps = orderSteps.map((step) => {
|
|
2068
|
-
if (!data?.orderState) return step;
|
|
2069
|
-
const currentStepIndex = orderSteps.findIndex(
|
|
2070
|
-
(orderStep) => orderStep.key === data.orderState.current_step
|
|
2071
|
-
);
|
|
2072
|
-
const stepIndex = orderSteps.findIndex(
|
|
2073
|
-
(orderStep) => orderStep.key === step.key
|
|
2074
|
-
);
|
|
2075
|
-
return {
|
|
2076
|
-
...step,
|
|
2077
|
-
completed: stepIndex < currentStepIndex,
|
|
2078
|
-
active: stepIndex === currentStepIndex
|
|
2079
|
-
};
|
|
2080
|
-
});
|
|
2081
|
-
const completedSteps = steps.filter((step) => step.completed);
|
|
2082
|
-
const activeStep = steps.find((step) => step.active);
|
|
2083
|
-
const lastCompletedStep = completedSteps[completedSteps.length - 1];
|
|
2084
|
-
const totalSteps = steps.length;
|
|
2085
|
-
const progress = Math.round(completedSteps.length / totalSteps * 100);
|
|
2086
|
-
const loading = isLoading || externalLoading;
|
|
2087
|
-
return /* @__PURE__ */ jsxs8("div", { className: "rf-flex rf-flex-col rf-bg-white rf-rounded-xl rf-p-6 rf-max-w-xl rf-w-full rf-mx-auto", children: [
|
|
2088
|
-
/* @__PURE__ */ jsxs8("div", { className: "rf-flex rf-items-center rf-justify-between rf-mb-6", children: [
|
|
2089
|
-
/* @__PURE__ */ jsx13("h2", { className: "rf-text-2xl rf-font-bold", children: title }),
|
|
2090
|
-
/* @__PURE__ */ jsxs8("div", { className: "rf-text-sm rf-text-muted-foreground", children: [
|
|
2091
|
-
completedSteps.length,
|
|
2092
|
-
" of ",
|
|
2093
|
-
totalSteps,
|
|
2094
|
-
" completed"
|
|
2095
|
-
] })
|
|
2096
|
-
] }),
|
|
2097
|
-
/* @__PURE__ */ jsx13(Progress, { value: progress, className: "rf-h-2 rf-mb-8" }),
|
|
2098
|
-
/* @__PURE__ */ jsxs8("div", { className: "rf-space-y-6 rf-mb-8", children: [
|
|
2099
|
-
lastCompletedStep && /* @__PURE__ */ jsxs8("div", { className: "rf-flex rf-items-start rf-gap-4", children: [
|
|
2100
|
-
/* @__PURE__ */ jsx13("div", { className: "rf-flex-shrink-0 rf-mt-0.5", children: /* @__PURE__ */ jsx13("div", { className: "rf-w-8 rf-h-8 rf-rounded-full rf-bg-green-100 rf-flex rf-items-center rf-justify-center", children: /* @__PURE__ */ jsx13(Check3, { className: "rf-h-5 rf-w-5 rf-text-green-600" }) }) }),
|
|
2101
|
-
/* @__PURE__ */ jsxs8("div", { className: "rf-flex-1", children: [
|
|
2102
|
-
/* @__PURE__ */ jsx13("p", { className: "rf-text-sm rf-font-medium rf-text-muted-foreground", children: "Last Completed" }),
|
|
2103
|
-
/* @__PURE__ */ jsxs8("p", { className: "rf-font-medium rf-text-green-600", children: [
|
|
2104
|
-
lastCompletedStep.order_step_id,
|
|
2105
|
-
". ",
|
|
2106
|
-
lastCompletedStep.title
|
|
2107
|
-
] })
|
|
2108
|
-
] })
|
|
2109
|
-
] }),
|
|
2110
|
-
lastCompletedStep && activeStep && /* @__PURE__ */ jsx13("div", { className: "rf-pl-4", children: /* @__PURE__ */ jsx13(ArrowDown2, { className: "rf-h-5 rf-w-5 rf-text-muted-foreground" }) }),
|
|
2111
|
-
activeStep && /* @__PURE__ */ jsxs8("div", { className: "rf-flex rf-items-start rf-gap-4", children: [
|
|
2112
|
-
/* @__PURE__ */ jsx13("div", { className: "rf-flex-shrink-0 rf-mt-0.5", children: /* @__PURE__ */ jsx13("div", { className: "rf-w-8 rf-h-8 rf-rounded-full rf-bg-blue-100 rf-flex rf-items-center rf-justify-center", children: loading ? /* @__PURE__ */ jsx13(Loader23, { className: "rf-h-5 rf-w-5 rf-text-blue-600 rf-animate-spin" }) : /* @__PURE__ */ jsx13("div", { className: "rf-h-2.5 rf-w-2.5 rf-rounded-full rf-bg-blue-600" }) }) }),
|
|
2113
|
-
/* @__PURE__ */ jsxs8("div", { className: "rf-flex-1", children: [
|
|
2114
|
-
/* @__PURE__ */ jsx13("p", { className: "rf-text-sm rf-font-medium rf-text-muted-foreground", children: "Current Step" }),
|
|
2115
|
-
/* @__PURE__ */ jsxs8("p", { className: "rf-font-medium rf-text-blue-600", children: [
|
|
2116
|
-
activeStep.order_step_id,
|
|
2117
|
-
". ",
|
|
2118
|
-
activeStep.title
|
|
2119
|
-
] })
|
|
2120
|
-
] })
|
|
2121
|
-
] })
|
|
2122
|
-
] }),
|
|
2123
|
-
/* @__PURE__ */ jsx13("div", { className: "rf-flex rf-justify-end rf-gap-3 rf-mt-auto", children: onCancel && /* @__PURE__ */ jsx13(Button, { variant: "outline", onClick: onCancel, className: "rf-px-6", children: "Cancel" }) })
|
|
2124
|
-
] });
|
|
2125
|
-
};
|
|
2126
|
-
|
|
2127
|
-
// lib/components/OrderDialog/OrderDialog.tsx
|
|
2128
|
-
import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2129
|
-
var queryClient = new QueryClient();
|
|
2130
|
-
var OrderDialog = ({
|
|
2131
|
-
isOpen,
|
|
2132
|
-
onClose,
|
|
2133
|
-
stage,
|
|
2134
|
-
setStage,
|
|
2135
|
-
circuitJson
|
|
2136
|
-
}) => {
|
|
2137
|
-
const [order, setOrder] = useState8(null);
|
|
2138
|
-
const [loading, setLoading] = useState8(false);
|
|
2139
|
-
const createOrder = async () => {
|
|
2140
|
-
const { order: order2 } = await ky3.post("registry/orders/create", {
|
|
2141
|
-
json: {
|
|
2142
|
-
circuit_json: circuitJson
|
|
2143
|
-
},
|
|
2144
|
-
headers: {
|
|
2145
|
-
Authorization: `Bearer account-1234`
|
|
2146
|
-
}
|
|
2147
|
-
}).json();
|
|
2148
|
-
return order2;
|
|
2149
|
-
};
|
|
2150
|
-
const handleInitialContinue = async () => {
|
|
2151
|
-
const order2 = await createOrder();
|
|
2152
|
-
setOrder(order2);
|
|
2153
|
-
setStage("progress");
|
|
2154
|
-
};
|
|
2155
|
-
return /* @__PURE__ */ jsx14(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx14(AlertDialog, { open: isOpen, onOpenChange: onClose, children: /* @__PURE__ */ jsx14(AlertDialogContent, { className: "!rf-max-w-[660px] !rf-p-0", children: /* @__PURE__ */ jsxs9("div", { className: "rf-relative rf-w-full", children: [
|
|
2156
|
-
stage === "initial" && /* @__PURE__ */ jsx14(
|
|
2157
|
-
InitialOrderScreen,
|
|
2158
|
-
{
|
|
2159
|
-
onCancel: onClose,
|
|
2160
|
-
onContinue: handleInitialContinue
|
|
2161
|
-
}
|
|
2162
|
-
),
|
|
2163
|
-
stage === "progress" && order?.order_id && /* @__PURE__ */ jsx14(
|
|
2164
|
-
StepwiseProgressPanel,
|
|
2165
|
-
{
|
|
2166
|
-
onCancel: onClose,
|
|
2167
|
-
loading,
|
|
2168
|
-
orderId: order?.order_id,
|
|
2169
|
-
setStage
|
|
2170
|
-
}
|
|
2171
|
-
),
|
|
2172
|
-
stage === "checkout" && /* @__PURE__ */ jsx14(
|
|
2173
|
-
CheckoutOrder,
|
|
2174
|
-
{
|
|
2175
|
-
finalCost: 0,
|
|
2176
|
-
onConfirmCheckout: () => onClose(),
|
|
2177
|
-
onCancel: () => onClose()
|
|
2178
|
-
}
|
|
2179
|
-
)
|
|
2180
|
-
] }) }) }) });
|
|
2181
|
-
};
|
|
2182
|
-
|
|
2183
|
-
// lib/components/OrderDialog/CliOrderDialog.tsx
|
|
2184
|
-
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
2185
|
-
var CliOrderDialog = ({
|
|
2186
|
-
isOpen,
|
|
2187
|
-
onClose,
|
|
2188
|
-
stage,
|
|
2189
|
-
setStage
|
|
2190
|
-
}) => {
|
|
2191
|
-
const circuitJson = useRunFrameStore((state) => state.circuitJson);
|
|
2192
|
-
return /* @__PURE__ */ jsx15(
|
|
2193
|
-
OrderDialog,
|
|
2194
|
-
{
|
|
2195
|
-
isOpen,
|
|
2196
|
-
onClose,
|
|
2197
|
-
stage,
|
|
2198
|
-
setStage,
|
|
2199
|
-
circuitJson
|
|
2200
|
-
}
|
|
2201
|
-
);
|
|
2202
|
-
};
|
|
2203
|
-
|
|
2204
|
-
// lib/components/OrderDialog/useOrderDialog.tsx
|
|
2205
|
-
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
2206
|
-
var OrderDialogComponent = ({
|
|
2207
|
-
isOpen,
|
|
2208
|
-
onClose,
|
|
2209
|
-
stage,
|
|
2210
|
-
setStage
|
|
2211
|
-
}) => {
|
|
2212
|
-
return /* @__PURE__ */ jsx16(
|
|
2213
|
-
CliOrderDialog,
|
|
2214
|
-
{
|
|
2215
|
-
isOpen,
|
|
2216
|
-
onClose,
|
|
2217
|
-
stage,
|
|
2218
|
-
setStage
|
|
2219
|
-
}
|
|
2220
|
-
);
|
|
2221
|
-
};
|
|
2222
|
-
var useOrderDialog = () => {
|
|
2223
|
-
const [isOpen, setIsOpen] = useState9(false);
|
|
2224
|
-
const [stage, setStage] = useState9("initial");
|
|
2225
|
-
const [isRegistryConnected, setIsRegistryConnected] = useState9(false);
|
|
2226
|
-
const handleClose = () => {
|
|
2227
|
-
setIsOpen(false);
|
|
2228
|
-
setStage("initial");
|
|
2229
|
-
};
|
|
2230
|
-
return {
|
|
2231
|
-
isOpen,
|
|
2232
|
-
stage,
|
|
2233
|
-
isRegistryConnected,
|
|
2234
|
-
open: () => setIsOpen(true),
|
|
2235
|
-
close: handleClose,
|
|
2236
|
-
setStage,
|
|
2237
|
-
OrderDialog: OrderDialogComponent
|
|
2238
|
-
// returns reference and not factory
|
|
2239
|
-
};
|
|
2240
|
-
};
|
|
2241
|
-
|
|
2242
1189
|
// lib/components/RunFrameForCli/LeftHeader.tsx
|
|
2243
|
-
import { Fragment as Fragment2, jsx as
|
|
1190
|
+
import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2244
1191
|
var RunframeCliLeftHeader = (props) => {
|
|
2245
1192
|
const lastRunEvalVersion = useRunnerStore((s) => s.lastRunEvalVersion);
|
|
2246
|
-
const [snippetName, setSnippetName] =
|
|
2247
|
-
const [hasUnsavedChanges, setHasUnsavedChanges] =
|
|
2248
|
-
const [hasNeverBeenSaved, setHasNeverBeenSaved] =
|
|
2249
|
-
const [isSaving, setIsSaving] =
|
|
2250
|
-
const [requestToSaveSentAt, setRequestToSaveSentAt] =
|
|
1193
|
+
const [snippetName, setSnippetName] = useState6(null);
|
|
1194
|
+
const [hasUnsavedChanges, setHasUnsavedChanges] = useState6(false);
|
|
1195
|
+
const [hasNeverBeenSaved, setHasNeverBeenSaved] = useState6(true);
|
|
1196
|
+
const [isSaving, setIsSaving] = useState6(false);
|
|
1197
|
+
const [requestToSaveSentAt, setRequestToSaveSentAt] = useState6(
|
|
2251
1198
|
null
|
|
2252
1199
|
);
|
|
2253
|
-
const [availableSnippets, setAvailableSnippets] =
|
|
1200
|
+
const [availableSnippets, setAvailableSnippets] = useState6(
|
|
2254
1201
|
null
|
|
2255
1202
|
);
|
|
2256
|
-
const [isSelectSnippetDialogOpen, setIsSelectSnippetDialogOpen] =
|
|
2257
|
-
const [notificationMessage, setNotificationMessage] =
|
|
1203
|
+
const [isSelectSnippetDialogOpen, setIsSelectSnippetDialogOpen] = useState6(false);
|
|
1204
|
+
const [notificationMessage, setNotificationMessage] = useState6(
|
|
2258
1205
|
null
|
|
2259
1206
|
);
|
|
2260
|
-
const [errorMessage, setErrorMessage] =
|
|
2261
|
-
const [isError, setIsError] =
|
|
2262
|
-
const [isExporting, setisExporting] =
|
|
2263
|
-
const orderDialog =
|
|
1207
|
+
const [errorMessage, setErrorMessage] = useState6(null);
|
|
1208
|
+
const [isError, setIsError] = useState6(false);
|
|
1209
|
+
const [isExporting, setisExporting] = useState6(false);
|
|
1210
|
+
const orderDialog = useOrderDialogCli();
|
|
2264
1211
|
const pushEvent = useRunFrameStore((state) => state.pushEvent);
|
|
2265
1212
|
const recentEvents = useRunFrameStore((state) => state.recentEvents);
|
|
2266
1213
|
const firstRenderTime = useMemo2(() => Date.now(), []);
|
|
@@ -2288,7 +1235,7 @@ var RunframeCliLeftHeader = (props) => {
|
|
|
2288
1235
|
setisExporting(false);
|
|
2289
1236
|
}
|
|
2290
1237
|
});
|
|
2291
|
-
|
|
1238
|
+
useEffect8(() => {
|
|
2292
1239
|
if (!isSaving || requestToSaveSentAt === null) return;
|
|
2293
1240
|
const eventsSinceRequestToSave = recentEvents.filter(
|
|
2294
1241
|
(event) => new Date(event.created_at).valueOf() > requestToSaveSentAt
|
|
@@ -2330,12 +1277,12 @@ var RunframeCliLeftHeader = (props) => {
|
|
|
2330
1277
|
});
|
|
2331
1278
|
};
|
|
2332
1279
|
const circuitJson = useRunFrameStore((state) => state.circuitJson);
|
|
2333
|
-
const [isImportDialogOpen, setIsImportDialogOpen] =
|
|
2334
|
-
return /* @__PURE__ */
|
|
2335
|
-
/* @__PURE__ */
|
|
2336
|
-
/* @__PURE__ */
|
|
2337
|
-
/* @__PURE__ */
|
|
2338
|
-
/* @__PURE__ */
|
|
1280
|
+
const [isImportDialogOpen, setIsImportDialogOpen] = useState6(false);
|
|
1281
|
+
return /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
1282
|
+
/* @__PURE__ */ jsxs4(DropdownMenu, { children: [
|
|
1283
|
+
/* @__PURE__ */ jsx6(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx6("div", { className: "rf-whitespace-nowrap rf-text-xs font-medium rf-p-2 rf-mx-1 rf-cursor-pointer rf-relative", children: "File" }) }),
|
|
1284
|
+
/* @__PURE__ */ jsxs4(DropdownMenuContent, { children: [
|
|
1285
|
+
/* @__PURE__ */ jsx6(
|
|
2339
1286
|
DropdownMenuItem,
|
|
2340
1287
|
{
|
|
2341
1288
|
className: "rf-text-xs",
|
|
@@ -2344,7 +1291,7 @@ var RunframeCliLeftHeader = (props) => {
|
|
|
2344
1291
|
children: isSaving ? "Saving..." : "Push"
|
|
2345
1292
|
}
|
|
2346
1293
|
),
|
|
2347
|
-
parseInt(window.location.port) > 5e3 && /* @__PURE__ */
|
|
1294
|
+
parseInt(window.location.port) > 5e3 && /* @__PURE__ */ jsx6(
|
|
2348
1295
|
DropdownMenuItem,
|
|
2349
1296
|
{
|
|
2350
1297
|
className: "rf-text-xs",
|
|
@@ -2354,7 +1301,7 @@ var RunframeCliLeftHeader = (props) => {
|
|
|
2354
1301
|
children: "Order"
|
|
2355
1302
|
}
|
|
2356
1303
|
),
|
|
2357
|
-
/* @__PURE__ */
|
|
1304
|
+
/* @__PURE__ */ jsx6(
|
|
2358
1305
|
DropdownMenuItem,
|
|
2359
1306
|
{
|
|
2360
1307
|
className: "rf-text-xs",
|
|
@@ -2363,8 +1310,8 @@ var RunframeCliLeftHeader = (props) => {
|
|
|
2363
1310
|
children: "Import"
|
|
2364
1311
|
}
|
|
2365
1312
|
),
|
|
2366
|
-
/* @__PURE__ */
|
|
2367
|
-
/* @__PURE__ */
|
|
1313
|
+
/* @__PURE__ */ jsxs4(DropdownMenuSub, { children: [
|
|
1314
|
+
/* @__PURE__ */ jsx6(
|
|
2368
1315
|
DropdownMenuSubTrigger,
|
|
2369
1316
|
{
|
|
2370
1317
|
className: "rf-text-xs",
|
|
@@ -2372,7 +1319,7 @@ var RunframeCliLeftHeader = (props) => {
|
|
|
2372
1319
|
children: isExporting ? "Exporting..." : "Export"
|
|
2373
1320
|
}
|
|
2374
1321
|
),
|
|
2375
|
-
/* @__PURE__ */
|
|
1322
|
+
/* @__PURE__ */ jsx6(DropdownMenuPortal, { children: /* @__PURE__ */ jsx6(DropdownMenuSubContent, { children: availableExports.map((exp, i) => /* @__PURE__ */ jsx6(
|
|
2376
1323
|
DropdownMenuItem,
|
|
2377
1324
|
{
|
|
2378
1325
|
onSelect: () => {
|
|
@@ -2387,16 +1334,16 @@ var RunframeCliLeftHeader = (props) => {
|
|
|
2387
1334
|
});
|
|
2388
1335
|
},
|
|
2389
1336
|
disabled: isExporting,
|
|
2390
|
-
children: /* @__PURE__ */
|
|
1337
|
+
children: /* @__PURE__ */ jsx6("span", { className: "rf-text-xs", children: exp.name })
|
|
2391
1338
|
},
|
|
2392
1339
|
i
|
|
2393
1340
|
)) }) })
|
|
2394
1341
|
] }),
|
|
2395
|
-
/* @__PURE__ */
|
|
2396
|
-
/* @__PURE__ */
|
|
2397
|
-
/* @__PURE__ */
|
|
2398
|
-
/* @__PURE__ */
|
|
2399
|
-
/* @__PURE__ */
|
|
1342
|
+
/* @__PURE__ */ jsxs4(DropdownMenuSub, { children: [
|
|
1343
|
+
/* @__PURE__ */ jsx6(DropdownMenuSubTrigger, { className: "rf-text-xs", children: "Advanced" }),
|
|
1344
|
+
/* @__PURE__ */ jsx6(DropdownMenuPortal, { children: /* @__PURE__ */ jsxs4(DropdownMenuSubContent, { children: [
|
|
1345
|
+
/* @__PURE__ */ jsx6(DropdownMenuItem, { className: "rf-flex rf-items-center rf-gap-2", children: /* @__PURE__ */ jsxs4("div", { className: "rf-flex rf-items-center rf-gap-2", children: [
|
|
1346
|
+
/* @__PURE__ */ jsx6(
|
|
2400
1347
|
Checkbox,
|
|
2401
1348
|
{
|
|
2402
1349
|
id: "load-latest-eval",
|
|
@@ -2406,7 +1353,7 @@ var RunframeCliLeftHeader = (props) => {
|
|
|
2406
1353
|
}
|
|
2407
1354
|
}
|
|
2408
1355
|
),
|
|
2409
|
-
/* @__PURE__ */
|
|
1356
|
+
/* @__PURE__ */ jsx6(
|
|
2410
1357
|
"label",
|
|
2411
1358
|
{
|
|
2412
1359
|
htmlFor: "load-latest-eval",
|
|
@@ -2415,31 +1362,31 @@ var RunframeCliLeftHeader = (props) => {
|
|
|
2415
1362
|
}
|
|
2416
1363
|
)
|
|
2417
1364
|
] }) }),
|
|
2418
|
-
lastRunEvalVersion && /* @__PURE__ */
|
|
1365
|
+
lastRunEvalVersion && /* @__PURE__ */ jsx6(DropdownMenuItem, { className: "rf-flex rf-items-center rf-gap-2", children: /* @__PURE__ */ jsx6("div", { className: "rf-flex rf-items-center rf-gap-2", children: /* @__PURE__ */ jsxs4("span", { className: "rf-text-xs", children: [
|
|
2419
1366
|
"@tscircuit/eval@",
|
|
2420
1367
|
lastRunEvalVersion
|
|
2421
1368
|
] }) }) }),
|
|
2422
|
-
/* @__PURE__ */
|
|
1369
|
+
/* @__PURE__ */ jsx6(
|
|
2423
1370
|
DropdownMenuItem,
|
|
2424
1371
|
{
|
|
2425
1372
|
className: "rf-flex rf-items-center rf-gap-2",
|
|
2426
1373
|
onClick: () => {
|
|
2427
1374
|
window.open("/api/admin", "_blank");
|
|
2428
1375
|
},
|
|
2429
|
-
children: /* @__PURE__ */
|
|
1376
|
+
children: /* @__PURE__ */ jsx6("div", { className: "rf-flex rf-items-center rf-gap-2", children: /* @__PURE__ */ jsx6("span", { className: "rf-text-xs", children: "CLI Admin Panel" }) })
|
|
2430
1377
|
}
|
|
2431
1378
|
)
|
|
2432
1379
|
] }) })
|
|
2433
1380
|
] })
|
|
2434
1381
|
] }),
|
|
2435
|
-
/* @__PURE__ */
|
|
2436
|
-
/* @__PURE__ */
|
|
2437
|
-
/* @__PURE__ */
|
|
2438
|
-
/* @__PURE__ */
|
|
1382
|
+
/* @__PURE__ */ jsx6(AlertDialog, { open: isError, onOpenChange: setIsError, children: /* @__PURE__ */ jsxs4(AlertDialogContent, { children: [
|
|
1383
|
+
/* @__PURE__ */ jsxs4(AlertDialogHeader, { children: [
|
|
1384
|
+
/* @__PURE__ */ jsx6(AlertDialogTitle, { children: "Error Saving Snippet" }),
|
|
1385
|
+
/* @__PURE__ */ jsx6(AlertDialogDescription, { children: errorMessage })
|
|
2439
1386
|
] }),
|
|
2440
|
-
/* @__PURE__ */
|
|
1387
|
+
/* @__PURE__ */ jsx6(AlertDialogFooter, { children: /* @__PURE__ */ jsx6(AlertDialogCancel, { onClick: () => setIsError(false), children: "Dismiss" }) })
|
|
2441
1388
|
] }) }),
|
|
2442
|
-
/* @__PURE__ */
|
|
1389
|
+
/* @__PURE__ */ jsx6(
|
|
2443
1390
|
SelectSnippetDialog,
|
|
2444
1391
|
{
|
|
2445
1392
|
snippetNames: availableSnippets ?? [],
|
|
@@ -2458,7 +1405,7 @@ var RunframeCliLeftHeader = (props) => {
|
|
|
2458
1405
|
}
|
|
2459
1406
|
)
|
|
2460
1407
|
] }),
|
|
2461
|
-
/* @__PURE__ */
|
|
1408
|
+
/* @__PURE__ */ jsx6(
|
|
2462
1409
|
ImportComponentDialog,
|
|
2463
1410
|
{
|
|
2464
1411
|
isOpen: isImportDialogOpen,
|
|
@@ -2491,8 +1438,8 @@ var RunframeCliLeftHeader = (props) => {
|
|
|
2491
1438
|
}
|
|
2492
1439
|
}
|
|
2493
1440
|
),
|
|
2494
|
-
/* @__PURE__ */
|
|
2495
|
-
/* @__PURE__ */
|
|
1441
|
+
/* @__PURE__ */ jsx6(Toaster, { position: "top-center", reverseOrder: false }),
|
|
1442
|
+
/* @__PURE__ */ jsx6(
|
|
2496
1443
|
orderDialog.OrderDialog,
|
|
2497
1444
|
{
|
|
2498
1445
|
isOpen: orderDialog.isOpen,
|
|
@@ -2505,21 +1452,21 @@ var RunframeCliLeftHeader = (props) => {
|
|
|
2505
1452
|
};
|
|
2506
1453
|
|
|
2507
1454
|
// lib/components/RunFrameForCli/RunFrameForCli.tsx
|
|
2508
|
-
import { jsx as
|
|
1455
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2509
1456
|
var RunFrameForCli = (props) => {
|
|
2510
1457
|
const [shouldLoadLatestEval, setLoadLatestEval] = useLocalStorageState(
|
|
2511
1458
|
"load-latest-eval",
|
|
2512
1459
|
true
|
|
2513
1460
|
);
|
|
2514
|
-
return /* @__PURE__ */
|
|
1461
|
+
return /* @__PURE__ */ jsx7(
|
|
2515
1462
|
RunFrameWithApi,
|
|
2516
1463
|
{
|
|
2517
1464
|
debug: props.debug,
|
|
2518
1465
|
forceLatestEvalVersion: shouldLoadLatestEval,
|
|
2519
1466
|
defaultToFullScreen: true,
|
|
2520
1467
|
showToggleFullScreen: false,
|
|
2521
|
-
leftHeaderContent: /* @__PURE__ */
|
|
2522
|
-
/* @__PURE__ */
|
|
1468
|
+
leftHeaderContent: /* @__PURE__ */ jsxs5("div", { className: "rf-flex rf-items-center rf-justify-between", children: [
|
|
1469
|
+
/* @__PURE__ */ jsx7(
|
|
2523
1470
|
RunframeCliLeftHeader,
|
|
2524
1471
|
{
|
|
2525
1472
|
shouldLoadLatestEval,
|
|
@@ -2546,5 +1493,7 @@ export {
|
|
|
2546
1493
|
SchematicViewer,
|
|
2547
1494
|
guessEntrypoint,
|
|
2548
1495
|
guessManualEditsFilePath,
|
|
2549
|
-
linkify
|
|
1496
|
+
linkify,
|
|
1497
|
+
useOrderDialog,
|
|
1498
|
+
useOrderDialogCli
|
|
2550
1499
|
};
|