@tscircuit/fake-snippets 0.0.68 → 0.0.69
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/bun-tests/fake-snippets-api/routes/packages/update.test.ts +104 -0
- package/bun.lock +15 -25
- package/dist/bundle.js +17 -5
- package/dist/index.d.ts +5 -0
- package/dist/index.js +2 -1
- package/dist/schema.d.ts +8 -0
- package/dist/schema.js +2 -1
- package/fake-snippets-api/lib/db/schema.ts +4 -0
- package/fake-snippets-api/routes/api/packages/create.ts +1 -0
- package/fake-snippets-api/routes/api/packages/update.ts +11 -2
- package/package.json +3 -3
- package/src/components/ViewPackagePage/components/mobile-sidebar.tsx +1 -0
- package/src/components/ViewPackagePage/components/package-header.tsx +21 -11
- package/src/components/ViewPackagePage/components/repo-page-content.tsx +23 -7
- package/src/components/ViewPackagePage/components/sidebar-about-section.tsx +1 -0
- package/src/components/dialogs/edit-package-details-dialog.tsx +33 -2
- package/src/hooks/use-package-details-form.ts +15 -1
- package/src/index.css +13 -0
package/dist/index.d.ts
CHANGED
|
@@ -508,6 +508,7 @@ declare const packageSchema: z.ZodObject<{
|
|
|
508
508
|
ai_description: z.ZodNullable<z.ZodString>;
|
|
509
509
|
latest_license: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
510
510
|
ai_usage_instructions: z.ZodNullable<z.ZodString>;
|
|
511
|
+
default_view: z.ZodOptional<z.ZodDefault<z.ZodEnum<["files", "3d", "pcb", "schematic"]>>>;
|
|
511
512
|
}, "strip", z.ZodTypeAny, {
|
|
512
513
|
name: string;
|
|
513
514
|
unscoped_name: string;
|
|
@@ -536,6 +537,7 @@ declare const packageSchema: z.ZodObject<{
|
|
|
536
537
|
ai_usage_instructions: string | null;
|
|
537
538
|
snippet_type?: "board" | "package" | "model" | "footprint" | undefined;
|
|
538
539
|
latest_license?: string | null | undefined;
|
|
540
|
+
default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
|
|
539
541
|
}, {
|
|
540
542
|
name: string;
|
|
541
543
|
unscoped_name: string;
|
|
@@ -564,6 +566,7 @@ declare const packageSchema: z.ZodObject<{
|
|
|
564
566
|
is_source_from_github?: boolean | undefined;
|
|
565
567
|
website?: string | null | undefined;
|
|
566
568
|
latest_license?: string | null | undefined;
|
|
569
|
+
default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
|
|
567
570
|
}>;
|
|
568
571
|
type Package = z.infer<typeof packageSchema>;
|
|
569
572
|
declare const jlcpcbOrderStateSchema: z.ZodObject<{
|
|
@@ -778,6 +781,7 @@ declare const createDatabase: ({ seed }?: {
|
|
|
778
781
|
ai_usage_instructions: string | null;
|
|
779
782
|
snippet_type?: "board" | "package" | "model" | "footprint" | undefined;
|
|
780
783
|
latest_license?: string | null | undefined;
|
|
784
|
+
default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
|
|
781
785
|
}[];
|
|
782
786
|
orders: {
|
|
783
787
|
error: z.objectOutputType<{
|
|
@@ -1068,6 +1072,7 @@ declare const createDatabase: ({ seed }?: {
|
|
|
1068
1072
|
ai_usage_instructions: string | null;
|
|
1069
1073
|
snippet_type?: "board" | "package" | "model" | "footprint" | undefined;
|
|
1070
1074
|
latest_license?: string | null | undefined;
|
|
1075
|
+
default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
|
|
1071
1076
|
}[];
|
|
1072
1077
|
orders: {
|
|
1073
1078
|
error: z.objectOutputType<{
|
package/dist/index.js
CHANGED
|
@@ -187,7 +187,8 @@ var packageSchema = z.object({
|
|
|
187
187
|
star_count: z.number().default(0),
|
|
188
188
|
ai_description: z.string().nullable(),
|
|
189
189
|
latest_license: z.string().nullable().optional(),
|
|
190
|
-
ai_usage_instructions: z.string().nullable()
|
|
190
|
+
ai_usage_instructions: z.string().nullable(),
|
|
191
|
+
default_view: z.enum(["files", "3d", "pcb", "schematic"]).default("files").optional()
|
|
191
192
|
});
|
|
192
193
|
var jlcpcbOrderStateSchema = z.object({
|
|
193
194
|
jlcpcb_order_state_id: z.string(),
|
package/dist/schema.d.ts
CHANGED
|
@@ -633,6 +633,7 @@ declare const packageSchema: z.ZodObject<{
|
|
|
633
633
|
ai_description: z.ZodNullable<z.ZodString>;
|
|
634
634
|
latest_license: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
635
635
|
ai_usage_instructions: z.ZodNullable<z.ZodString>;
|
|
636
|
+
default_view: z.ZodOptional<z.ZodDefault<z.ZodEnum<["files", "3d", "pcb", "schematic"]>>>;
|
|
636
637
|
}, "strip", z.ZodTypeAny, {
|
|
637
638
|
name: string;
|
|
638
639
|
unscoped_name: string;
|
|
@@ -661,6 +662,7 @@ declare const packageSchema: z.ZodObject<{
|
|
|
661
662
|
ai_usage_instructions: string | null;
|
|
662
663
|
snippet_type?: "board" | "package" | "model" | "footprint" | undefined;
|
|
663
664
|
latest_license?: string | null | undefined;
|
|
665
|
+
default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
|
|
664
666
|
}, {
|
|
665
667
|
name: string;
|
|
666
668
|
unscoped_name: string;
|
|
@@ -689,6 +691,7 @@ declare const packageSchema: z.ZodObject<{
|
|
|
689
691
|
is_source_from_github?: boolean | undefined;
|
|
690
692
|
website?: string | null | undefined;
|
|
691
693
|
latest_license?: string | null | undefined;
|
|
694
|
+
default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
|
|
692
695
|
}>;
|
|
693
696
|
type Package = z.infer<typeof packageSchema>;
|
|
694
697
|
declare const jlcpcbOrderStateSchema: z.ZodObject<{
|
|
@@ -1068,6 +1071,7 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1068
1071
|
ai_description: z.ZodNullable<z.ZodString>;
|
|
1069
1072
|
latest_license: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1070
1073
|
ai_usage_instructions: z.ZodNullable<z.ZodString>;
|
|
1074
|
+
default_view: z.ZodOptional<z.ZodDefault<z.ZodEnum<["files", "3d", "pcb", "schematic"]>>>;
|
|
1071
1075
|
}, "strip", z.ZodTypeAny, {
|
|
1072
1076
|
name: string;
|
|
1073
1077
|
unscoped_name: string;
|
|
@@ -1096,6 +1100,7 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1096
1100
|
ai_usage_instructions: string | null;
|
|
1097
1101
|
snippet_type?: "board" | "package" | "model" | "footprint" | undefined;
|
|
1098
1102
|
latest_license?: string | null | undefined;
|
|
1103
|
+
default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
|
|
1099
1104
|
}, {
|
|
1100
1105
|
name: string;
|
|
1101
1106
|
unscoped_name: string;
|
|
@@ -1124,6 +1129,7 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1124
1129
|
is_source_from_github?: boolean | undefined;
|
|
1125
1130
|
website?: string | null | undefined;
|
|
1126
1131
|
latest_license?: string | null | undefined;
|
|
1132
|
+
default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
|
|
1127
1133
|
}>, "many">>;
|
|
1128
1134
|
orders: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1129
1135
|
order_id: z.ZodString;
|
|
@@ -1572,6 +1578,7 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1572
1578
|
ai_usage_instructions: string | null;
|
|
1573
1579
|
snippet_type?: "board" | "package" | "model" | "footprint" | undefined;
|
|
1574
1580
|
latest_license?: string | null | undefined;
|
|
1581
|
+
default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
|
|
1575
1582
|
}[];
|
|
1576
1583
|
orders: {
|
|
1577
1584
|
error: z.objectOutputType<{
|
|
@@ -1788,6 +1795,7 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1788
1795
|
is_source_from_github?: boolean | undefined;
|
|
1789
1796
|
website?: string | null | undefined;
|
|
1790
1797
|
latest_license?: string | null | undefined;
|
|
1798
|
+
default_view?: "files" | "3d" | "pcb" | "schematic" | undefined;
|
|
1791
1799
|
}[] | undefined;
|
|
1792
1800
|
orders?: {
|
|
1793
1801
|
error: z.objectInputType<{
|
package/dist/schema.js
CHANGED
|
@@ -182,7 +182,8 @@ var packageSchema = z.object({
|
|
|
182
182
|
star_count: z.number().default(0),
|
|
183
183
|
ai_description: z.string().nullable(),
|
|
184
184
|
latest_license: z.string().nullable().optional(),
|
|
185
|
-
ai_usage_instructions: z.string().nullable()
|
|
185
|
+
ai_usage_instructions: z.string().nullable(),
|
|
186
|
+
default_view: z.enum(["files", "3d", "pcb", "schematic"]).default("files").optional()
|
|
186
187
|
});
|
|
187
188
|
var jlcpcbOrderStateSchema = z.object({
|
|
188
189
|
jlcpcb_order_state_id: z.string(),
|
|
@@ -219,6 +219,10 @@ export const packageSchema = z.object({
|
|
|
219
219
|
ai_description: z.string().nullable(),
|
|
220
220
|
latest_license: z.string().nullable().optional(),
|
|
221
221
|
ai_usage_instructions: z.string().nullable(),
|
|
222
|
+
default_view: z
|
|
223
|
+
.enum(["files", "3d", "pcb", "schematic"])
|
|
224
|
+
.default("files")
|
|
225
|
+
.optional(),
|
|
222
226
|
})
|
|
223
227
|
export type Package = z.infer<typeof packageSchema>
|
|
224
228
|
|
|
@@ -55,6 +55,7 @@ export default withRouteSpec({
|
|
|
55
55
|
is_public: is_private === true ? false : true,
|
|
56
56
|
is_unlisted: is_private === true ? true : (is_unlisted ?? false),
|
|
57
57
|
ai_usage_instructions: "placeholder ai usage instructions",
|
|
58
|
+
default_view: "files",
|
|
58
59
|
})
|
|
59
60
|
|
|
60
61
|
if (!newPackage) {
|
|
@@ -20,6 +20,7 @@ export default withRouteSpec({
|
|
|
20
20
|
website: z.string().optional(),
|
|
21
21
|
is_private: z.boolean().optional(),
|
|
22
22
|
is_unlisted: z.boolean().optional(),
|
|
23
|
+
default_view: z.enum(["files", "3d", "pcb", "schematic"]).optional(),
|
|
23
24
|
})
|
|
24
25
|
.transform((data) => ({
|
|
25
26
|
...data,
|
|
@@ -30,8 +31,15 @@ export default withRouteSpec({
|
|
|
30
31
|
package: packageSchema,
|
|
31
32
|
}),
|
|
32
33
|
})(async (req, ctx) => {
|
|
33
|
-
const {
|
|
34
|
-
|
|
34
|
+
const {
|
|
35
|
+
package_id,
|
|
36
|
+
name,
|
|
37
|
+
description,
|
|
38
|
+
website,
|
|
39
|
+
is_private,
|
|
40
|
+
is_unlisted,
|
|
41
|
+
default_view,
|
|
42
|
+
} = req.jsonBody
|
|
35
43
|
|
|
36
44
|
const packageIndex = ctx.db.packages.findIndex(
|
|
37
45
|
(p) => p.package_id === package_id,
|
|
@@ -77,6 +85,7 @@ export default withRouteSpec({
|
|
|
77
85
|
is_public:
|
|
78
86
|
is_private !== undefined ? !is_private : existingPackage.is_public,
|
|
79
87
|
is_unlisted: is_unlisted ?? existingPackage.is_unlisted,
|
|
88
|
+
default_view: default_view ?? existingPackage.default_view,
|
|
80
89
|
updated_at: new Date().toISOString(),
|
|
81
90
|
})
|
|
82
91
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/fake-snippets",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.69",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@tscircuit/layout": "^0.0.29",
|
|
76
76
|
"@tscircuit/math-utils": "^0.0.10",
|
|
77
77
|
"@tscircuit/mm": "^0.0.8",
|
|
78
|
-
"@tscircuit/props": "^0.0.
|
|
78
|
+
"@tscircuit/props": "^0.0.186",
|
|
79
79
|
"@types/file-saver": "^2.0.7",
|
|
80
80
|
"@types/ms": "^0.7.34",
|
|
81
81
|
"@typescript/ata": "^0.9.7",
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
"@tailwindcss/typography": "^0.5.16",
|
|
148
148
|
"@tscircuit/core": "^0.0.384",
|
|
149
149
|
"@tscircuit/prompt-benchmarks": "^0.0.28",
|
|
150
|
-
"@tscircuit/runframe": "^0.0.
|
|
150
|
+
"@tscircuit/runframe": "^0.0.494",
|
|
151
151
|
"@types/babel__standalone": "^7.1.7",
|
|
152
152
|
"@types/bun": "^1.1.10",
|
|
153
153
|
"@types/country-list": "^2.1.4",
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useEffect } from "react"
|
|
2
2
|
import { Link } from "wouter"
|
|
3
|
-
|
|
4
|
-
import { TypeBadge } from "@/components/TypeBadge"
|
|
5
3
|
import { Button } from "@/components/ui/button"
|
|
6
4
|
import { Skeleton } from "@/components/ui/skeleton"
|
|
7
5
|
import {
|
|
@@ -10,7 +8,7 @@ import {
|
|
|
10
8
|
TooltipProvider,
|
|
11
9
|
TooltipTrigger,
|
|
12
10
|
} from "@/components/ui/tooltip"
|
|
13
|
-
import {
|
|
11
|
+
import { Lock, Globe } from "lucide-react"
|
|
14
12
|
import { GitFork, Package, Star } from "lucide-react"
|
|
15
13
|
|
|
16
14
|
import { useForkPackageMutation } from "@/hooks/use-fork-package-mutation"
|
|
@@ -106,13 +104,25 @@ export default function PackageHeader({
|
|
|
106
104
|
{packageName}
|
|
107
105
|
</Link>
|
|
108
106
|
</h1>
|
|
109
|
-
{packageInfo?.name &&
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
107
|
+
{packageInfo?.name && (
|
|
108
|
+
<div
|
|
109
|
+
className={`select-none inline-flex items-center px-2 py-1 rounded text-xs font-medium ${
|
|
110
|
+
isPrivate
|
|
111
|
+
? "bg-gray-100 text-gray-700 border border-gray-200"
|
|
112
|
+
: "bg-blue-50 text-blue-700 border border-blue-200"
|
|
113
|
+
}`}
|
|
114
|
+
>
|
|
115
|
+
{isPrivate ? (
|
|
116
|
+
<>
|
|
117
|
+
<Lock className="w-3 h-3 mr-1 flex-shrink-0" />
|
|
118
|
+
<span className="leading-none">Private</span>
|
|
119
|
+
</>
|
|
120
|
+
) : (
|
|
121
|
+
<>
|
|
122
|
+
<Globe className="w-3 h-3 mr-1 flex-shrink-0" />
|
|
123
|
+
<span className="leading-none">Public</span>
|
|
124
|
+
</>
|
|
125
|
+
)}
|
|
116
126
|
</div>
|
|
117
127
|
)}
|
|
118
128
|
</>
|
|
@@ -19,6 +19,7 @@ import PackageHeader from "./package-header"
|
|
|
19
19
|
import { useGlobalStore } from "@/hooks/use-global-store"
|
|
20
20
|
import { useLocation } from "wouter"
|
|
21
21
|
import { Package } from "fake-snippets-api/lib/db/schema"
|
|
22
|
+
import { useCurrentPackageCircuitJson } from "../hooks/use-current-package-circuit-json"
|
|
22
23
|
|
|
23
24
|
interface PackageFile {
|
|
24
25
|
package_file_id: string
|
|
@@ -43,22 +44,37 @@ export default function RepoPageContent({
|
|
|
43
44
|
onFileClicked,
|
|
44
45
|
onEditClicked,
|
|
45
46
|
}: RepoPageContentProps) {
|
|
46
|
-
const [location, setLocation] = useLocation()
|
|
47
47
|
const [activeView, setActiveView] = useState<string>("files")
|
|
48
48
|
const session = useGlobalStore((s) => s.session)
|
|
49
|
+
const { circuitJson, isLoading: isCircuitJsonLoading } =
|
|
50
|
+
useCurrentPackageCircuitJson()
|
|
49
51
|
|
|
50
|
-
// Handle hash-based view
|
|
52
|
+
// Handle initial view selection and hash-based view changes
|
|
51
53
|
useEffect(() => {
|
|
52
|
-
|
|
54
|
+
if (isCircuitJsonLoading) return
|
|
53
55
|
const hash = window.location.hash.slice(1)
|
|
54
|
-
// Valid views
|
|
55
56
|
const validViews = ["files", "3d", "pcb", "schematic", "bom"]
|
|
57
|
+
const circuitDependentViews = ["3d", "pcb", "schematic", "bom"]
|
|
56
58
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
const availableViews = circuitJson
|
|
60
|
+
? validViews
|
|
61
|
+
: validViews.filter((view) => !circuitDependentViews.includes(view))
|
|
62
|
+
|
|
63
|
+
if (hash && availableViews.includes(hash)) {
|
|
59
64
|
setActiveView(hash)
|
|
65
|
+
} else if (
|
|
66
|
+
packageInfo?.default_view &&
|
|
67
|
+
availableViews.includes(packageInfo.default_view)
|
|
68
|
+
) {
|
|
69
|
+
setActiveView(packageInfo.default_view)
|
|
70
|
+
window.location.hash = packageInfo.default_view
|
|
71
|
+
} else {
|
|
72
|
+
setActiveView("files")
|
|
73
|
+
if (!hash || !availableViews.includes(hash)) {
|
|
74
|
+
window.location.hash = "files"
|
|
75
|
+
}
|
|
60
76
|
}
|
|
61
|
-
}, [])
|
|
77
|
+
}, [packageInfo?.default_view, circuitJson, isCircuitJsonLoading])
|
|
62
78
|
|
|
63
79
|
const importantFilePaths = packageFiles
|
|
64
80
|
?.filter((pf) => isPackageFileImportant(pf.file_path))
|
|
@@ -35,6 +35,7 @@ interface EditPackageDetailsDialogProps {
|
|
|
35
35
|
currentDescription: string
|
|
36
36
|
currentWebsite: string
|
|
37
37
|
currentLicense?: string | null
|
|
38
|
+
currentDefaultView?: string
|
|
38
39
|
isPrivate?: boolean
|
|
39
40
|
packageName: string
|
|
40
41
|
packageReleaseId: string | null
|
|
@@ -43,6 +44,7 @@ interface EditPackageDetailsDialogProps {
|
|
|
43
44
|
newDescription: string,
|
|
44
45
|
newWebsite: string,
|
|
45
46
|
newLicense: string | null,
|
|
47
|
+
newDefaultView: string,
|
|
46
48
|
) => void
|
|
47
49
|
}
|
|
48
50
|
|
|
@@ -53,6 +55,7 @@ export const EditPackageDetailsDialog = ({
|
|
|
53
55
|
currentDescription,
|
|
54
56
|
currentWebsite,
|
|
55
57
|
currentLicense,
|
|
58
|
+
currentDefaultView = "files",
|
|
56
59
|
isPrivate = false,
|
|
57
60
|
packageName,
|
|
58
61
|
packageReleaseId,
|
|
@@ -68,12 +71,14 @@ export const EditPackageDetailsDialog = ({
|
|
|
68
71
|
setFormData,
|
|
69
72
|
websiteError,
|
|
70
73
|
hasLicenseChanged,
|
|
74
|
+
hasDefaultViewChanged,
|
|
71
75
|
hasChanges,
|
|
72
76
|
isFormValid,
|
|
73
77
|
} = usePackageDetailsForm({
|
|
74
78
|
initialDescription: currentDescription,
|
|
75
79
|
initialWebsite: currentWebsite,
|
|
76
80
|
initialLicense: currentLicense || null,
|
|
81
|
+
initialDefaultView: currentDefaultView,
|
|
77
82
|
isDialogOpen: open,
|
|
78
83
|
initialVisibility: isPrivate ? "private" : "public",
|
|
79
84
|
})
|
|
@@ -108,6 +113,7 @@ export const EditPackageDetailsDialog = ({
|
|
|
108
113
|
description: formData.description,
|
|
109
114
|
website: formData.website,
|
|
110
115
|
is_private: formData.visibility == "private",
|
|
116
|
+
default_view: formData.defaultView,
|
|
111
117
|
})
|
|
112
118
|
const privacyUpdateResponse = await axios.post("/snippets/update", {
|
|
113
119
|
snippet_id: packageId,
|
|
@@ -149,6 +155,7 @@ export const EditPackageDetailsDialog = ({
|
|
|
149
155
|
website: formData.website,
|
|
150
156
|
license: formData.license,
|
|
151
157
|
visibility: formData.visibility,
|
|
158
|
+
defaultView: formData.defaultView,
|
|
152
159
|
}
|
|
153
160
|
},
|
|
154
161
|
onMutate: async () => {
|
|
@@ -160,11 +167,12 @@ export const EditPackageDetailsDialog = ({
|
|
|
160
167
|
website: formData.website,
|
|
161
168
|
license: formData.license,
|
|
162
169
|
is_private: formData.visibility == "private",
|
|
170
|
+
default_view: formData.defaultView,
|
|
163
171
|
}))
|
|
164
172
|
return { previous }
|
|
165
173
|
},
|
|
166
174
|
onSuccess: (data) => {
|
|
167
|
-
onUpdate?.(data.description, data.website, data.license)
|
|
175
|
+
onUpdate?.(data.description, data.website, data.license, data.defaultView)
|
|
168
176
|
onOpenChange(false)
|
|
169
177
|
qc.invalidateQueries([
|
|
170
178
|
"packageFile",
|
|
@@ -218,7 +226,7 @@ export const EditPackageDetailsDialog = ({
|
|
|
218
226
|
</DialogContent>
|
|
219
227
|
</Dialog>
|
|
220
228
|
<Dialog open={open !== showConfirmDelete} onOpenChange={onOpenChange}>
|
|
221
|
-
<DialogContent className="sm:max-w-[500px] lg:h-[
|
|
229
|
+
<DialogContent className="sm:max-w-[500px] lg:h-[85vh] sm:h-[90vh] overflow-y-auto no-scrollbar w-[95vw] h-[80vh] p-6 gap-6 rounded-2xl shadow-lg">
|
|
222
230
|
<div className="flex flex-col gap-10">
|
|
223
231
|
<DialogHeader>
|
|
224
232
|
<DialogTitle>Edit Package Details</DialogTitle>
|
|
@@ -310,6 +318,29 @@ export const EditPackageDetailsDialog = ({
|
|
|
310
318
|
</SelectContent>
|
|
311
319
|
</Select>
|
|
312
320
|
</div>
|
|
321
|
+
<div className="space-y-1">
|
|
322
|
+
<Label htmlFor="defaultView">Default View</Label>
|
|
323
|
+
<Select
|
|
324
|
+
value={formData.defaultView}
|
|
325
|
+
onValueChange={(value) =>
|
|
326
|
+
setFormData((prev) => ({
|
|
327
|
+
...prev,
|
|
328
|
+
defaultView: value,
|
|
329
|
+
}))
|
|
330
|
+
}
|
|
331
|
+
disabled={updatePackageDetailsMutation.isLoading}
|
|
332
|
+
>
|
|
333
|
+
<SelectTrigger className="w-full">
|
|
334
|
+
<SelectValue placeholder="Select default view" />
|
|
335
|
+
</SelectTrigger>
|
|
336
|
+
<SelectContent className="!z-[999]">
|
|
337
|
+
<SelectItem value="files">Files</SelectItem>
|
|
338
|
+
<SelectItem value="3d">3D</SelectItem>
|
|
339
|
+
<SelectItem value="pcb">PCB</SelectItem>
|
|
340
|
+
<SelectItem value="schematic">Schematic</SelectItem>
|
|
341
|
+
</SelectContent>
|
|
342
|
+
</Select>
|
|
343
|
+
</div>
|
|
313
344
|
</div>
|
|
314
345
|
|
|
315
346
|
<details
|
|
@@ -15,6 +15,7 @@ interface PackageDetailsForm {
|
|
|
15
15
|
website: string
|
|
16
16
|
license: string | null
|
|
17
17
|
visibility: string
|
|
18
|
+
defaultView: string
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
interface UsePackageDetailsFormProps {
|
|
@@ -22,6 +23,7 @@ interface UsePackageDetailsFormProps {
|
|
|
22
23
|
initialWebsite: string
|
|
23
24
|
initialLicense: string | null
|
|
24
25
|
initialVisibility: string
|
|
26
|
+
initialDefaultView: string
|
|
25
27
|
isDialogOpen: boolean
|
|
26
28
|
}
|
|
27
29
|
|
|
@@ -30,6 +32,7 @@ export const usePackageDetailsForm = ({
|
|
|
30
32
|
initialWebsite,
|
|
31
33
|
initialLicense,
|
|
32
34
|
initialVisibility,
|
|
35
|
+
initialDefaultView,
|
|
33
36
|
isDialogOpen,
|
|
34
37
|
}: UsePackageDetailsFormProps) => {
|
|
35
38
|
const [formData, setFormData] = useState<PackageDetailsForm>({
|
|
@@ -37,6 +40,7 @@ export const usePackageDetailsForm = ({
|
|
|
37
40
|
website: initialWebsite,
|
|
38
41
|
license: initialLicense || null,
|
|
39
42
|
visibility: initialVisibility,
|
|
43
|
+
defaultView: initialDefaultView,
|
|
40
44
|
})
|
|
41
45
|
const [websiteError, setWebsiteError] = useState<string | null>(null)
|
|
42
46
|
|
|
@@ -47,6 +51,7 @@ export const usePackageDetailsForm = ({
|
|
|
47
51
|
website: initialWebsite,
|
|
48
52
|
license: initialLicense || null,
|
|
49
53
|
visibility: initialVisibility,
|
|
54
|
+
defaultView: initialDefaultView,
|
|
50
55
|
})
|
|
51
56
|
setWebsiteError(null)
|
|
52
57
|
}
|
|
@@ -56,6 +61,7 @@ export const usePackageDetailsForm = ({
|
|
|
56
61
|
initialWebsite,
|
|
57
62
|
initialLicense,
|
|
58
63
|
initialVisibility,
|
|
64
|
+
initialDefaultView,
|
|
59
65
|
])
|
|
60
66
|
|
|
61
67
|
useEffect(() => {
|
|
@@ -76,18 +82,25 @@ export const usePackageDetailsForm = ({
|
|
|
76
82
|
[formData.visibility, initialVisibility],
|
|
77
83
|
)
|
|
78
84
|
|
|
85
|
+
const hasDefaultViewChanged = useMemo(
|
|
86
|
+
() => formData.defaultView !== initialDefaultView,
|
|
87
|
+
[formData.defaultView, initialDefaultView],
|
|
88
|
+
)
|
|
89
|
+
|
|
79
90
|
const hasChanges = useMemo(
|
|
80
91
|
() =>
|
|
81
92
|
formData.description !== initialDescription ||
|
|
82
93
|
formData.website !== initialWebsite ||
|
|
83
94
|
formData.license !== initialLicense ||
|
|
84
|
-
formData.visibility !== initialVisibility
|
|
95
|
+
formData.visibility !== initialVisibility ||
|
|
96
|
+
formData.defaultView !== initialDefaultView,
|
|
85
97
|
[
|
|
86
98
|
formData,
|
|
87
99
|
initialDescription,
|
|
88
100
|
initialWebsite,
|
|
89
101
|
initialLicense,
|
|
90
102
|
initialVisibility,
|
|
103
|
+
initialDefaultView,
|
|
91
104
|
],
|
|
92
105
|
)
|
|
93
106
|
|
|
@@ -99,6 +112,7 @@ export const usePackageDetailsForm = ({
|
|
|
99
112
|
websiteError,
|
|
100
113
|
hasLicenseChanged,
|
|
101
114
|
hasVisibilityChanged,
|
|
115
|
+
hasDefaultViewChanged,
|
|
102
116
|
hasChanges,
|
|
103
117
|
isFormValid,
|
|
104
118
|
}
|
package/src/index.css
CHANGED
|
@@ -7,6 +7,19 @@
|
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
/* add the code bellow */
|
|
11
|
+
@layer utilities {
|
|
12
|
+
/* Hide scrollbar for Chrome, Safari and Opera */
|
|
13
|
+
.no-scrollbar::-webkit-scrollbar {
|
|
14
|
+
display: none;
|
|
15
|
+
}
|
|
16
|
+
/* Hide scrollbar for IE, Edge and Firefox */
|
|
17
|
+
.no-scrollbar {
|
|
18
|
+
-ms-overflow-style: none; /* IE and Edge */
|
|
19
|
+
scrollbar-width: none; /* Firefox */
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
10
23
|
.shiki {
|
|
11
24
|
font-family: "Fira Code", monospace;
|
|
12
25
|
font-size: 14px;
|