@tscircuit/fake-snippets 0.0.108 → 0.0.110
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/.github/workflows/bun-formatcheck.yml +2 -2
- package/.github/workflows/bun-pver-release.yml +3 -3
- package/.github/workflows/bun-test.yml +1 -1
- package/.github/workflows/bun-typecheck.yml +2 -2
- package/.github/workflows/update-snapshots.yml +1 -1
- package/README.md +4 -0
- package/api/generated-index.js +37 -3
- package/biome.json +2 -1
- package/bun-tests/fake-snippets-api/fixtures/get-test-server.ts +31 -3
- package/bun-tests/fake-snippets-api/fixtures/preload.ts +18 -0
- package/bun-tests/fake-snippets-api/routes/orgs/add_member.test.ts +26 -0
- package/bun-tests/fake-snippets-api/routes/orgs/create.test.ts +37 -0
- package/bun-tests/fake-snippets-api/routes/orgs/get.test.ts +52 -0
- package/bun-tests/fake-snippets-api/routes/orgs/list.test.ts +17 -0
- package/bun-tests/fake-snippets-api/routes/orgs/list_members.test.ts +23 -0
- package/bun-tests/fake-snippets-api/routes/orgs/remove_member.test.ts +81 -0
- package/bun-tests/fake-snippets-api/routes/orgs/update.test.ts +99 -0
- package/bun-tests/fake-snippets-api/routes/package_builds/get.test.ts +1 -1
- package/bun-tests/fake-snippets-api/routes/package_files/create.test.ts +15 -13
- package/bun-tests/fake-snippets-api/routes/package_files/create_or_update.test.ts +26 -24
- package/bun-tests/fake-snippets-api/routes/package_files/delete.test.ts +9 -9
- package/bun-tests/fake-snippets-api/routes/package_files/download.test.ts +4 -4
- package/bun-tests/fake-snippets-api/routes/package_files/get.test.ts +38 -28
- package/bun-tests/fake-snippets-api/routes/package_files/list.test.ts +23 -15
- package/bun-tests/fake-snippets-api/routes/package_releases/create.test.ts +33 -0
- package/bun-tests/fake-snippets-api/routes/package_releases/get.test.ts +4 -4
- package/bun-tests/fake-snippets-api/routes/package_releases/get_image_generation_fields.test.ts +38 -0
- package/bun-tests/fake-snippets-api/routes/packages/create.test.ts +19 -0
- package/bun-tests/fake-snippets-api/routes/packages/fork.test.ts +3 -4
- package/bun-tests/fake-snippets-api/routes/packages/get.test.ts +30 -0
- package/bun-tests/fake-snippets-api/routes/packages/images.test.ts +4 -2
- package/bun-tests/fake-snippets-api/routes/packages/list-1.test.ts +34 -0
- package/bun.lock +389 -450
- package/bunfig.toml +2 -1
- package/dist/bundle.js +1255 -625
- package/dist/index.d.ts +296 -4
- package/dist/index.js +325 -24
- package/dist/schema.d.ts +282 -1
- package/dist/schema.js +54 -2
- package/fake-snippets-api/lib/db/autoload-dev-packages.ts +31 -20
- package/fake-snippets-api/lib/db/db-client.ts +214 -3
- package/fake-snippets-api/lib/db/schema.ts +62 -0
- package/fake-snippets-api/lib/db/seed.ts +100 -0
- package/fake-snippets-api/lib/middleware/with-session-auth.ts +1 -1
- package/fake-snippets-api/lib/package_file/get-package-file-id-from-file-descriptor.ts +2 -2
- package/fake-snippets-api/lib/public-mapping/public-map-org.ts +32 -0
- package/fake-snippets-api/lib/public-mapping/public-map-package-build.ts +10 -0
- package/fake-snippets-api/lib/public-mapping/public-map-package-release.ts +17 -0
- package/fake-snippets-api/routes/api/orgs/add_member.ts +52 -0
- package/fake-snippets-api/routes/api/orgs/create.ts +46 -0
- package/fake-snippets-api/routes/api/orgs/get.ts +39 -0
- package/fake-snippets-api/routes/api/orgs/list.ts +31 -0
- package/fake-snippets-api/routes/api/orgs/list_members.ts +67 -0
- package/fake-snippets-api/routes/api/orgs/remove_member.ts +46 -0
- package/fake-snippets-api/routes/api/orgs/update.ts +93 -0
- package/fake-snippets-api/routes/api/package_files/get.ts +3 -6
- package/fake-snippets-api/routes/api/package_files/list.ts +7 -4
- package/fake-snippets-api/routes/api/packages/create.ts +54 -10
- package/fake-snippets-api/routes/api/packages/get.ts +23 -0
- package/fake-snippets-api/routes/api/packages/images/[owner_github_username]/[unscoped_name]/[view_format].ts +13 -11
- package/fake-snippets-api/routes/api/packages/list.ts +29 -2
- package/fake-snippets-api/routes/api/packages/update_ai_description.ts +37 -0
- package/package.json +27 -24
- package/renovate.json +1 -1
- package/scripts/generate-sitemap.ts +1 -1
- package/src/App.tsx +29 -10
- package/src/ContextProviders.tsx +25 -2
- package/src/components/CircuitJsonImportDialog.tsx +1 -1
- package/src/components/CmdKMenu.tsx +281 -247
- package/src/components/DownloadButtonAndMenu.tsx +133 -36
- package/src/components/FileSidebar.tsx +41 -50
- package/src/components/Footer.tsx +8 -10
- package/src/components/Header.tsx +19 -32
- package/src/components/Header2.tsx +16 -32
- package/src/components/HeaderDropdown.tsx +13 -8
- package/src/components/HeaderLogin.tsx +44 -16
- package/src/components/HiddenFilesDropdown.tsx +0 -2
- package/src/components/NotFound.tsx +5 -5
- package/src/components/PackageBreadcrumb.tsx +6 -12
- package/src/components/PackageCard.tsx +0 -1
- package/src/components/PackageSearchResults.tsx +1 -1
- package/src/components/PrefetchPageLink.tsx +7 -1
- package/src/components/ProfileRouter.tsx +32 -0
- package/src/components/SearchComponent.tsx +12 -8
- package/src/components/UserCard.tsx +80 -0
- package/src/components/ViewPackagePage/components/ShikiCodeViewer.tsx +20 -11
- package/src/components/ViewPackagePage/components/build-status.tsx +1 -1
- package/src/components/ViewPackagePage/components/important-files-view.tsx +174 -87
- package/src/components/ViewPackagePage/components/main-content-header.tsx +8 -4
- package/src/components/ViewPackagePage/components/main-content-view-selector.tsx +1 -2
- package/src/components/ViewPackagePage/components/mobile-sidebar.tsx +54 -20
- package/src/components/ViewPackagePage/components/package-header.tsx +26 -37
- package/src/components/ViewPackagePage/components/preview-image-squares.tsx +11 -19
- package/src/components/ViewPackagePage/components/repo-page-content.tsx +33 -25
- package/src/components/ViewPackagePage/components/sidebar-about-section.tsx +16 -10
- package/src/components/ViewPackagePage/components/sidebar-releases-section.tsx +11 -11
- package/src/components/ViewPackagePage/components/sidebar.tsx +0 -2
- package/src/components/ViewPackagePage/components/tab-views/files-view.tsx +18 -17
- package/src/components/ViewPackagePage/components/tab-views/pcb-view.tsx +1 -2
- package/src/components/ViewPackagePage/components/tab-views/schematic-view.tsx +2 -1
- package/src/components/ViewPackagePage/components/theme-toggle.tsx +0 -2
- package/src/components/ViewPackagePage/hooks/use-toast.tsx +0 -1
- package/src/components/dialogs/GitHubRepositorySelector.tsx +56 -49
- package/src/components/dialogs/edit-package-details-dialog.tsx +5 -6
- package/src/components/dialogs/import-component-dialog.tsx +16 -9
- package/src/components/dialogs/import-package-dialog.tsx +3 -2
- package/src/components/dialogs/new-package-save-prompt-dialog.tsx +190 -0
- package/src/components/organization/OrganizationCard.tsx +204 -0
- package/src/components/organization/OrganizationCardSkeleton.tsx +55 -0
- package/src/components/organization/OrganizationHeader.tsx +154 -0
- package/src/components/organization/OrganizationMembers.tsx +146 -0
- package/src/components/package-port/CodeAndPreview.tsx +32 -46
- package/src/components/package-port/CodeEditor.tsx +28 -31
- package/src/components/package-port/CodeEditorHeader.tsx +128 -63
- package/src/components/package-port/EditorNav.tsx +32 -49
- package/src/components/preview/ConnectedPackagesList.tsx +8 -8
- package/src/components/preview/ConnectedRepoOverview.tsx +102 -2
- package/src/components/preview/PackageReleasesDashboard.tsx +53 -36
- package/src/components/ui/tree-view.tsx +6 -3
- package/src/hooks/use-add-org-member-mutation.ts +51 -0
- package/src/hooks/use-create-org-mutation.ts +38 -0
- package/src/hooks/use-create-package-mutation.ts +3 -0
- package/src/hooks/use-current-package-id.ts +5 -30
- package/src/hooks/use-current-package-info.ts +29 -5
- package/src/hooks/use-current-package-release.ts +4 -3
- package/src/hooks/use-download-zip.ts +2 -2
- package/src/hooks/use-global-store.ts +6 -4
- package/src/hooks/use-jlcpcb-component-import.tsx +164 -0
- package/src/hooks/use-list-org-members.ts +27 -0
- package/src/hooks/use-list-user-orgs.ts +25 -0
- package/src/hooks/use-org-by-github-handle.ts +26 -0
- package/src/hooks/use-org.ts +24 -0
- package/src/hooks/use-organization.ts +42 -0
- package/src/hooks/use-package-as-snippet.ts +4 -2
- package/src/hooks/use-package-builds.ts +6 -2
- package/src/hooks/use-package-files.ts +5 -3
- package/src/hooks/use-package-release-by-id-or-version.ts +29 -20
- package/src/hooks/use-package-release-images.ts +105 -0
- package/src/hooks/use-package-release.ts +2 -2
- package/src/hooks/use-package-stars.ts +80 -4
- package/src/hooks/use-preview-images.ts +6 -3
- package/src/hooks/use-remove-org-member-mutation.ts +32 -0
- package/src/hooks/use-update-ai-description-mutation.ts +42 -0
- package/src/hooks/use-update-org-mutation.ts +41 -0
- package/src/hooks/use-warn-user-on-page-change.ts +71 -4
- package/src/hooks/useFileManagement.ts +183 -35
- package/src/hooks/useOptimizedPackageFilesLoader.ts +136 -0
- package/src/hooks/usePackageFilesLoader.ts +2 -2
- package/src/hooks/useUpdatePackageFilesMutation.ts +15 -1
- package/src/lib/download-fns/download-circuit-png.ts +11 -3
- package/src/lib/download-fns/download-gltf-from-circuit-json.ts +44 -0
- package/src/lib/download-fns/download-kicad-files.ts +12 -11
- package/src/lib/normalize-svg-for-tile.ts +50 -0
- package/src/lib/posthog.ts +11 -9
- package/src/lib/react-query-api-failure-tracking.ts +148 -0
- package/src/lib/sentry.ts +14 -0
- package/src/lib/templates/blank-circuit-board-template.ts +0 -4
- package/src/lib/ts-lib-cache.ts +122 -7
- package/src/lib/utils/checkIfManualEditsImported.ts +4 -4
- package/src/lib/utils/findTargetFile.ts +45 -10
- package/src/lib/utils/isComponentExported.ts +10 -0
- package/src/main.tsx +2 -1
- package/src/pages/authorize.tsx +0 -2
- package/src/pages/create-organization.tsx +168 -0
- package/src/pages/dashboard.tsx +38 -6
- package/src/pages/datasheet.tsx +1 -1
- package/src/pages/datasheets.tsx +3 -3
- package/src/pages/editor.tsx +4 -6
- package/src/pages/landing.tsx +6 -7
- package/src/pages/latest.tsx +3 -0
- package/src/pages/organization-profile.tsx +199 -0
- package/src/pages/organization-settings.tsx +566 -0
- package/src/pages/package-editor.tsx +21 -21
- package/src/pages/preview-release.tsx +76 -136
- package/src/pages/quickstart.tsx +159 -123
- package/src/pages/release-detail.tsx +119 -31
- package/src/pages/search.tsx +192 -57
- package/src/pages/settings-redirect.tsx +44 -0
- package/src/pages/trending.tsx +29 -20
- package/src/pages/user-profile.tsx +58 -7
- package/src/pages/view-package.tsx +21 -26
- package/vite.config.ts +9 -0
- package/fake-snippets-api/routes/api/autocomplete/create_autocomplete.ts +0 -133
- package/src/components/Footer2.tsx +0 -100
- package/src/components/JLCPCBImportDialog.tsx +0 -280
- package/src/components/PackageBuildsPage/LogContent.tsx +0 -72
- package/src/components/PackageBuildsPage/PackageBuildDetailsPage.tsx +0 -115
- package/src/components/PackageBuildsPage/build-preview-content.tsx +0 -27
- package/src/components/PackageBuildsPage/collapsible-section.tsx +0 -63
- package/src/components/PackageBuildsPage/package-build-details-panel.tsx +0 -166
- package/src/components/PackageBuildsPage/package-build-header.tsx +0 -79
- package/src/components/PageSearchComponent.tsx +0 -148
- package/src/components/ShippingInformationForm.tsx +0 -423
- package/src/components/StaticViewSnippetHeader.tsx +0 -70
- package/src/components/ViewPackagePage/components/file-explorer.tsx +0 -67
- package/src/components/ViewPackagePage/components/readme-view.tsx +0 -58
- package/src/components/ViewPackagePage/components/repo-header-button.tsx +0 -36
- package/src/components/ViewPackagePage/components/repo-header.tsx +0 -4
- package/src/components/ViewPackagePage/components/sidebar-contributors-section.tsx +0 -31
- package/src/components/ViewSnippetHeader.tsx +0 -181
- package/src/components/ui/input-otp.tsx +0 -69
- package/src/pages/package-builds.tsx +0 -33
- package/src/pages/settings.tsx +0 -25
|
@@ -1,423 +0,0 @@
|
|
|
1
|
-
import React, { useReducer, useEffect, useState } from "react"
|
|
2
|
-
import { Button } from "@/components/ui/button"
|
|
3
|
-
import { Input } from "@/components/ui/input"
|
|
4
|
-
import { useToast } from "@/hooks/use-toast"
|
|
5
|
-
import { useAxios } from "@/hooks/use-axios"
|
|
6
|
-
import { useQuery, useMutation, useQueryClient } from "react-query"
|
|
7
|
-
import { Loader2 } from "lucide-react"
|
|
8
|
-
import { getNames } from "country-list"
|
|
9
|
-
import states from "states-us"
|
|
10
|
-
import { Alert, AlertDescription } from "@/components/ui/alert"
|
|
11
|
-
import { SearchableSelect } from "@/components/ui/searchable-select"
|
|
12
|
-
|
|
13
|
-
const USA = "United States of America"
|
|
14
|
-
|
|
15
|
-
type ShippingInfo = {
|
|
16
|
-
firstName: string
|
|
17
|
-
lastName: string
|
|
18
|
-
companyName: string
|
|
19
|
-
address: string
|
|
20
|
-
apartment: string
|
|
21
|
-
city: string
|
|
22
|
-
state: string
|
|
23
|
-
zipCode: string
|
|
24
|
-
country: string
|
|
25
|
-
phone: string
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
type Action =
|
|
29
|
-
| { type: "SET_FIELD"; field: keyof ShippingInfo; value: string }
|
|
30
|
-
| { type: "SET_ALL"; payload: ShippingInfo }
|
|
31
|
-
|
|
32
|
-
const initialState: ShippingInfo = {
|
|
33
|
-
firstName: "",
|
|
34
|
-
lastName: "",
|
|
35
|
-
companyName: "",
|
|
36
|
-
address: "",
|
|
37
|
-
apartment: "",
|
|
38
|
-
zipCode: "",
|
|
39
|
-
country: USA,
|
|
40
|
-
city: "",
|
|
41
|
-
state: "",
|
|
42
|
-
phone: "",
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const shippingPlaceholders: ShippingInfo = {
|
|
46
|
-
firstName: "Enter your first name",
|
|
47
|
-
lastName: "Enter your last name",
|
|
48
|
-
companyName: "Enter company name (optional)",
|
|
49
|
-
address: "Enter your street address",
|
|
50
|
-
apartment: "Apartment, suite, unit etc. (optional)",
|
|
51
|
-
zipCode: "Enter your zip code",
|
|
52
|
-
country: "Select your country",
|
|
53
|
-
city: "Enter your city",
|
|
54
|
-
state: "Enter your state",
|
|
55
|
-
phone: "Enter your phone number",
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const ShippingInformationForm: React.FC = () => {
|
|
59
|
-
const [form, setField] = useReducer(
|
|
60
|
-
(state: ShippingInfo, action: Action): ShippingInfo => {
|
|
61
|
-
switch (action.type) {
|
|
62
|
-
case "SET_FIELD":
|
|
63
|
-
return { ...state, [action.field]: action.value }
|
|
64
|
-
case "SET_ALL":
|
|
65
|
-
return action.payload
|
|
66
|
-
default:
|
|
67
|
-
return state
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
initialState,
|
|
71
|
-
)
|
|
72
|
-
const { toast } = useToast()
|
|
73
|
-
const axios = useAxios()
|
|
74
|
-
const queryClient = useQueryClient()
|
|
75
|
-
const [countries] = useState(getNames())
|
|
76
|
-
const [isPhoneValid, setIsPhoneValid] = useState(true)
|
|
77
|
-
|
|
78
|
-
const { data: account, isLoading: isLoadingAccount } = useQuery(
|
|
79
|
-
"account",
|
|
80
|
-
async () => {
|
|
81
|
-
const response = await axios.get("/accounts/get")
|
|
82
|
-
return response.data.account
|
|
83
|
-
},
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
const updateShippingMutation = useMutation(
|
|
87
|
-
(shippingInfo: ShippingInfo) =>
|
|
88
|
-
axios.post("/accounts/update", { shippingInfo }),
|
|
89
|
-
{
|
|
90
|
-
onSuccess: () => {
|
|
91
|
-
queryClient.invalidateQueries("account")
|
|
92
|
-
toast({
|
|
93
|
-
title: "Success",
|
|
94
|
-
description: "Shipping information updated successfully",
|
|
95
|
-
})
|
|
96
|
-
},
|
|
97
|
-
onError: () => {
|
|
98
|
-
toast({
|
|
99
|
-
title: "Error",
|
|
100
|
-
description: "Failed to update shipping information",
|
|
101
|
-
variant: "destructive",
|
|
102
|
-
})
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
)
|
|
106
|
-
|
|
107
|
-
useEffect(() => {
|
|
108
|
-
if (account?.shippingInfo) {
|
|
109
|
-
setField({
|
|
110
|
-
type: "SET_ALL",
|
|
111
|
-
payload: {
|
|
112
|
-
...account.shippingInfo,
|
|
113
|
-
country: account.shippingInfo.country || USA,
|
|
114
|
-
},
|
|
115
|
-
})
|
|
116
|
-
}
|
|
117
|
-
}, [account])
|
|
118
|
-
|
|
119
|
-
const handleSubmit = async (e: React.FormEvent) => {
|
|
120
|
-
e.preventDefault()
|
|
121
|
-
updateShippingMutation.mutate(form)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (isLoadingAccount) {
|
|
125
|
-
return (
|
|
126
|
-
<div className="flex justify-center items-center h-64">
|
|
127
|
-
<Loader2 className="w-8 h-8 animate-spin" />
|
|
128
|
-
</div>
|
|
129
|
-
)
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return (
|
|
133
|
-
<div className="space-y-4">
|
|
134
|
-
<div>
|
|
135
|
-
<label
|
|
136
|
-
htmlFor="country"
|
|
137
|
-
className="block text-sm font-medium text-gray-700"
|
|
138
|
-
>
|
|
139
|
-
Country <span className="text-red-500">*</span>
|
|
140
|
-
</label>
|
|
141
|
-
<SearchableSelect
|
|
142
|
-
options={countries.map((country) => ({
|
|
143
|
-
value: country,
|
|
144
|
-
label: country,
|
|
145
|
-
}))}
|
|
146
|
-
value={form.country}
|
|
147
|
-
onChange={(value) =>
|
|
148
|
-
setField({ type: "SET_FIELD", field: "country", value })
|
|
149
|
-
}
|
|
150
|
-
resourceType="country"
|
|
151
|
-
/>
|
|
152
|
-
{form.country !== USA && (
|
|
153
|
-
<Alert variant="destructive" className="mt-2">
|
|
154
|
-
<AlertDescription>
|
|
155
|
-
Currently, only shipping to the US is supported.{" "}
|
|
156
|
-
<a
|
|
157
|
-
href={`https://github.com/tscircuit/tscircuit.com/issues/new?title=${encodeURIComponent("Shipping to " + form.country)}&body=${encodeURIComponent("Please add support for shipping to " + form.country + ".")}`}
|
|
158
|
-
target="_blank"
|
|
159
|
-
rel="noopener noreferrer"
|
|
160
|
-
className="font-medium underline"
|
|
161
|
-
>
|
|
162
|
-
Create an Issue
|
|
163
|
-
</a>
|
|
164
|
-
</AlertDescription>
|
|
165
|
-
</Alert>
|
|
166
|
-
)}
|
|
167
|
-
</div>
|
|
168
|
-
<div>
|
|
169
|
-
<label
|
|
170
|
-
htmlFor="companyName"
|
|
171
|
-
className="block text-sm font-medium text-gray-700"
|
|
172
|
-
>
|
|
173
|
-
Company Name
|
|
174
|
-
</label>
|
|
175
|
-
<Input
|
|
176
|
-
id="companyName"
|
|
177
|
-
value={form.companyName}
|
|
178
|
-
onChange={(e) =>
|
|
179
|
-
setField({
|
|
180
|
-
type: "SET_FIELD",
|
|
181
|
-
field: "companyName",
|
|
182
|
-
value: e.target.value,
|
|
183
|
-
})
|
|
184
|
-
}
|
|
185
|
-
placeholder={shippingPlaceholders.companyName}
|
|
186
|
-
disabled={updateShippingMutation.isLoading}
|
|
187
|
-
/>
|
|
188
|
-
</div>
|
|
189
|
-
<div className="flex gap-4">
|
|
190
|
-
<div className="flex-1">
|
|
191
|
-
<label
|
|
192
|
-
htmlFor="firstName"
|
|
193
|
-
className="block text-sm font-medium text-gray-700"
|
|
194
|
-
>
|
|
195
|
-
First Name <span className="text-red-500">*</span>
|
|
196
|
-
</label>
|
|
197
|
-
<Input
|
|
198
|
-
id="firstName"
|
|
199
|
-
value={form.firstName}
|
|
200
|
-
onChange={(e) =>
|
|
201
|
-
setField({
|
|
202
|
-
type: "SET_FIELD",
|
|
203
|
-
field: "firstName",
|
|
204
|
-
value: e.target.value,
|
|
205
|
-
})
|
|
206
|
-
}
|
|
207
|
-
placeholder={shippingPlaceholders.firstName}
|
|
208
|
-
disabled={updateShippingMutation.isLoading}
|
|
209
|
-
required
|
|
210
|
-
/>
|
|
211
|
-
</div>
|
|
212
|
-
<div className="flex-1">
|
|
213
|
-
<label
|
|
214
|
-
htmlFor="lastName"
|
|
215
|
-
className="block text-sm font-medium text-gray-700"
|
|
216
|
-
>
|
|
217
|
-
Last Name <span className="text-red-500">*</span>
|
|
218
|
-
</label>
|
|
219
|
-
<Input
|
|
220
|
-
id="lastName"
|
|
221
|
-
value={form.lastName}
|
|
222
|
-
onChange={(e) =>
|
|
223
|
-
setField({
|
|
224
|
-
type: "SET_FIELD",
|
|
225
|
-
field: "lastName",
|
|
226
|
-
value: e.target.value,
|
|
227
|
-
})
|
|
228
|
-
}
|
|
229
|
-
placeholder={shippingPlaceholders.lastName}
|
|
230
|
-
disabled={updateShippingMutation.isLoading}
|
|
231
|
-
required
|
|
232
|
-
/>
|
|
233
|
-
</div>
|
|
234
|
-
</div>
|
|
235
|
-
<div>
|
|
236
|
-
<label
|
|
237
|
-
htmlFor="address"
|
|
238
|
-
className="block text-sm font-medium text-gray-700"
|
|
239
|
-
>
|
|
240
|
-
Address <span className="text-red-500">*</span>
|
|
241
|
-
</label>
|
|
242
|
-
<Input
|
|
243
|
-
id="address"
|
|
244
|
-
value={form.address}
|
|
245
|
-
onChange={(e) =>
|
|
246
|
-
setField({
|
|
247
|
-
type: "SET_FIELD",
|
|
248
|
-
field: "address",
|
|
249
|
-
value: e.target.value,
|
|
250
|
-
})
|
|
251
|
-
}
|
|
252
|
-
placeholder={shippingPlaceholders.address}
|
|
253
|
-
disabled={updateShippingMutation.isLoading}
|
|
254
|
-
required
|
|
255
|
-
/>
|
|
256
|
-
</div>
|
|
257
|
-
<div>
|
|
258
|
-
<label
|
|
259
|
-
htmlFor="apartment"
|
|
260
|
-
className="block text-sm font-medium text-gray-700"
|
|
261
|
-
>
|
|
262
|
-
Apartment, suite, unit etc.
|
|
263
|
-
</label>
|
|
264
|
-
<Input
|
|
265
|
-
id="apartment"
|
|
266
|
-
value={form.apartment}
|
|
267
|
-
onChange={(e) =>
|
|
268
|
-
setField({
|
|
269
|
-
type: "SET_FIELD",
|
|
270
|
-
field: "apartment",
|
|
271
|
-
value: e.target.value,
|
|
272
|
-
})
|
|
273
|
-
}
|
|
274
|
-
placeholder={shippingPlaceholders.apartment}
|
|
275
|
-
disabled={updateShippingMutation.isLoading}
|
|
276
|
-
/>
|
|
277
|
-
</div>
|
|
278
|
-
<div className="flex gap-4">
|
|
279
|
-
<div className="flex-1">
|
|
280
|
-
<label
|
|
281
|
-
htmlFor="city"
|
|
282
|
-
className="block text-sm font-medium text-gray-700"
|
|
283
|
-
>
|
|
284
|
-
Town / City <span className="text-red-500">*</span>
|
|
285
|
-
</label>
|
|
286
|
-
<Input
|
|
287
|
-
id="city"
|
|
288
|
-
value={form.city}
|
|
289
|
-
onChange={(e) =>
|
|
290
|
-
setField({
|
|
291
|
-
type: "SET_FIELD",
|
|
292
|
-
field: "city",
|
|
293
|
-
value: e.target.value,
|
|
294
|
-
})
|
|
295
|
-
}
|
|
296
|
-
placeholder={shippingPlaceholders.city}
|
|
297
|
-
disabled={updateShippingMutation.isLoading}
|
|
298
|
-
required
|
|
299
|
-
/>
|
|
300
|
-
</div>
|
|
301
|
-
<div className="flex-1">
|
|
302
|
-
<label
|
|
303
|
-
htmlFor="state"
|
|
304
|
-
className="block text-sm font-medium text-gray-700"
|
|
305
|
-
>
|
|
306
|
-
State{" "}
|
|
307
|
-
{form.country === USA && <span className="text-red-500">*</span>}
|
|
308
|
-
</label>
|
|
309
|
-
{form.country === USA ? (
|
|
310
|
-
<SearchableSelect
|
|
311
|
-
options={states.map((state) => ({
|
|
312
|
-
value: state.name,
|
|
313
|
-
label: state.name,
|
|
314
|
-
}))}
|
|
315
|
-
value={form.state}
|
|
316
|
-
onChange={(value) =>
|
|
317
|
-
setField({ type: "SET_FIELD", field: "state", value })
|
|
318
|
-
}
|
|
319
|
-
resourceType="state"
|
|
320
|
-
/>
|
|
321
|
-
) : (
|
|
322
|
-
<Input
|
|
323
|
-
id="state"
|
|
324
|
-
value={form.state}
|
|
325
|
-
onChange={(e) =>
|
|
326
|
-
setField({
|
|
327
|
-
type: "SET_FIELD",
|
|
328
|
-
field: "state",
|
|
329
|
-
value: e.target.value,
|
|
330
|
-
})
|
|
331
|
-
}
|
|
332
|
-
placeholder={shippingPlaceholders.state}
|
|
333
|
-
disabled={updateShippingMutation.isLoading}
|
|
334
|
-
/>
|
|
335
|
-
)}
|
|
336
|
-
</div>
|
|
337
|
-
</div>
|
|
338
|
-
<div>
|
|
339
|
-
<label
|
|
340
|
-
htmlFor="zipCode"
|
|
341
|
-
className="block text-sm font-medium text-gray-700"
|
|
342
|
-
>
|
|
343
|
-
Postcode / Zip <span className="text-red-500">*</span>
|
|
344
|
-
</label>
|
|
345
|
-
<Input
|
|
346
|
-
id="zipCode"
|
|
347
|
-
value={form.zipCode}
|
|
348
|
-
onChange={(e) =>
|
|
349
|
-
setField({
|
|
350
|
-
type: "SET_FIELD",
|
|
351
|
-
field: "zipCode",
|
|
352
|
-
value: e.target.value,
|
|
353
|
-
})
|
|
354
|
-
}
|
|
355
|
-
placeholder={shippingPlaceholders.zipCode}
|
|
356
|
-
disabled={updateShippingMutation.isLoading}
|
|
357
|
-
required
|
|
358
|
-
/>
|
|
359
|
-
</div>
|
|
360
|
-
<div>
|
|
361
|
-
<label
|
|
362
|
-
htmlFor="phone"
|
|
363
|
-
className="block text-sm font-medium text-gray-700"
|
|
364
|
-
>
|
|
365
|
-
Phone <span className="text-red-500">*</span>
|
|
366
|
-
</label>
|
|
367
|
-
<div>
|
|
368
|
-
<Input
|
|
369
|
-
id="phone"
|
|
370
|
-
type="tel"
|
|
371
|
-
value={form.phone}
|
|
372
|
-
onChange={(e) => {
|
|
373
|
-
setIsPhoneValid(true)
|
|
374
|
-
setField({
|
|
375
|
-
type: "SET_FIELD",
|
|
376
|
-
field: "phone",
|
|
377
|
-
value: e.target.value,
|
|
378
|
-
})
|
|
379
|
-
}}
|
|
380
|
-
onBlur={() => {
|
|
381
|
-
const phoneRegex =
|
|
382
|
-
/^(\+\d{1,2}\s?)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/
|
|
383
|
-
setIsPhoneValid(phoneRegex.test(form.phone))
|
|
384
|
-
}}
|
|
385
|
-
placeholder={shippingPlaceholders.phone}
|
|
386
|
-
disabled={updateShippingMutation.isLoading}
|
|
387
|
-
required
|
|
388
|
-
/>
|
|
389
|
-
<p className="text-xs text-gray-500 mt-1">
|
|
390
|
-
Format: (123) 456-7890 or +1 123-456-7890
|
|
391
|
-
</p>
|
|
392
|
-
{!isPhoneValid && form.phone && (
|
|
393
|
-
<Alert variant="destructive" className="mt-2">
|
|
394
|
-
<AlertDescription>
|
|
395
|
-
Please enter a valid phone number.
|
|
396
|
-
</AlertDescription>
|
|
397
|
-
</Alert>
|
|
398
|
-
)}
|
|
399
|
-
</div>
|
|
400
|
-
</div>
|
|
401
|
-
<Button
|
|
402
|
-
type="submit"
|
|
403
|
-
disabled={
|
|
404
|
-
updateShippingMutation.isLoading ||
|
|
405
|
-
form.country !== USA ||
|
|
406
|
-
!isPhoneValid
|
|
407
|
-
}
|
|
408
|
-
onClick={handleSubmit}
|
|
409
|
-
>
|
|
410
|
-
{updateShippingMutation.isLoading ? (
|
|
411
|
-
<>
|
|
412
|
-
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
|
413
|
-
Updating...
|
|
414
|
-
</>
|
|
415
|
-
) : (
|
|
416
|
-
"Update"
|
|
417
|
-
)}
|
|
418
|
-
</Button>
|
|
419
|
-
</div>
|
|
420
|
-
)
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
export default ShippingInformationForm
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import React from "react"
|
|
2
|
-
import { TypeBadge } from "@/components/TypeBadge"
|
|
3
|
-
import { Button } from "@/components/ui/button"
|
|
4
|
-
import { ChevronLeft, Eye, GitFork, Star } from "lucide-react"
|
|
5
|
-
import { Link } from "wouter"
|
|
6
|
-
|
|
7
|
-
export default function StaticViewSnippetHeader({
|
|
8
|
-
author,
|
|
9
|
-
snippetName,
|
|
10
|
-
}: {
|
|
11
|
-
author: string
|
|
12
|
-
snippetName: string
|
|
13
|
-
}) {
|
|
14
|
-
const snippet_data = {
|
|
15
|
-
owner_name: author,
|
|
16
|
-
unscoped_name: snippetName,
|
|
17
|
-
//sample values
|
|
18
|
-
snippet_type: "board",
|
|
19
|
-
is_starred: false,
|
|
20
|
-
star_count: 0,
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<header className="bg-white border-b border-gray-200 py-4 px-6">
|
|
25
|
-
<div className="flex items-center justify-between">
|
|
26
|
-
<div className="flex items-center">
|
|
27
|
-
<h1 className="text-xl font-bold mr-2">
|
|
28
|
-
<Link
|
|
29
|
-
href={`/${snippet_data.owner_name}`}
|
|
30
|
-
className="text-blue-600"
|
|
31
|
-
>
|
|
32
|
-
{snippet_data.owner_name}
|
|
33
|
-
</Link>
|
|
34
|
-
<span className="px-1 text-gray-500">/</span>
|
|
35
|
-
<Link
|
|
36
|
-
className="text-blue-600"
|
|
37
|
-
href={`/${snippet_data.owner_name}/${snippet_data.unscoped_name}`}
|
|
38
|
-
>
|
|
39
|
-
{snippet_data.unscoped_name}
|
|
40
|
-
</Link>
|
|
41
|
-
</h1>
|
|
42
|
-
{snippet_data.snippet_type && (
|
|
43
|
-
<TypeBadge type={snippet_data.snippet_type} />
|
|
44
|
-
)}
|
|
45
|
-
</div>
|
|
46
|
-
<div className="flex items-center space-x-2">
|
|
47
|
-
<Button
|
|
48
|
-
size="sm"
|
|
49
|
-
disabled
|
|
50
|
-
aria-label="Loading placeholder"
|
|
51
|
-
className="loading-placeholder"
|
|
52
|
-
>
|
|
53
|
-
<Star className="w-4 h-4 mr-2" />
|
|
54
|
-
Star
|
|
55
|
-
</Button>
|
|
56
|
-
|
|
57
|
-
<Button
|
|
58
|
-
size="sm"
|
|
59
|
-
disabled
|
|
60
|
-
aria-label="Loading placeholder"
|
|
61
|
-
className="loading-placeholder"
|
|
62
|
-
>
|
|
63
|
-
<GitFork className="w-4 h-4 mr-2" />
|
|
64
|
-
Fork
|
|
65
|
-
</Button>
|
|
66
|
-
</div>
|
|
67
|
-
</div>
|
|
68
|
-
</header>
|
|
69
|
-
)
|
|
70
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { Clock, FileText, Folder, Tag } from "lucide-react"
|
|
2
|
-
import { useCurrentPackageInfo } from "@/hooks/use-current-package-info"
|
|
3
|
-
import { usePackageReleaseById } from "@/hooks/use-package-release"
|
|
4
|
-
import { Skeleton } from "@/components/ui/skeleton"
|
|
5
|
-
import { timeAgo } from "@/lib/utils/timeAgo"
|
|
6
|
-
|
|
7
|
-
export default function FileExplorer() {
|
|
8
|
-
const { packageInfo } = useCurrentPackageInfo()
|
|
9
|
-
const { data: packageRelease } = usePackageReleaseById(
|
|
10
|
-
packageInfo?.latest_package_release_id,
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<div className="border border-gray-200 dark:border-[#30363d] rounded-md overflow-hidden">
|
|
15
|
-
<div className="flex items-center px-4 py-2 md:py-3 bg-gray-100 dark:bg-[#161b22] border-b border-gray-200 dark:border-[#30363d]">
|
|
16
|
-
{/* Desktop view */}
|
|
17
|
-
<div className="hidden md:flex items-center text-xs">
|
|
18
|
-
<Tag className="h-4 w-4 mr-1 text-gray-500 dark:text-[#8b949e]" />
|
|
19
|
-
{packageRelease?.version ? (
|
|
20
|
-
<span className="text-gray-500 dark:text-[#8b949e]">
|
|
21
|
-
v{packageRelease.version}
|
|
22
|
-
</span>
|
|
23
|
-
) : (
|
|
24
|
-
<Skeleton className="h-4 w-16" />
|
|
25
|
-
)}
|
|
26
|
-
<div className="ml-2 text-green-500 dark:text-[#3fb950]">✓</div>
|
|
27
|
-
</div>
|
|
28
|
-
<div className="hidden md:flex ml-auto items-center text-xs text-gray-500 dark:text-[#8b949e]">
|
|
29
|
-
<Clock className="h-4 w-4 mr-1" />
|
|
30
|
-
{packageRelease?.created_at ? (
|
|
31
|
-
<span>{timeAgo(new Date(packageRelease.created_at))}</span>
|
|
32
|
-
) : (
|
|
33
|
-
<Skeleton className="h-4 w-16" />
|
|
34
|
-
)}
|
|
35
|
-
<div className="ml-4 flex items-center">
|
|
36
|
-
<Tag className="h-4 w-4 mr-1" />
|
|
37
|
-
{packageRelease ? (
|
|
38
|
-
<span>v{packageRelease.version}</span>
|
|
39
|
-
) : (
|
|
40
|
-
<Skeleton className="h-4 w-16" />
|
|
41
|
-
)}
|
|
42
|
-
</div>
|
|
43
|
-
</div>
|
|
44
|
-
|
|
45
|
-
{/* Mobile view */}
|
|
46
|
-
<div className="md:hidden flex items-center justify-between w-full">
|
|
47
|
-
<div className="flex items-center">
|
|
48
|
-
<span className="text-xs text-gray-500 dark:text-[#8b949e]">
|
|
49
|
-
v{packageRelease?.version}
|
|
50
|
-
</span>
|
|
51
|
-
<div className="ml-1 text-green-500 dark:text-[#3fb950]">✓</div>
|
|
52
|
-
</div>
|
|
53
|
-
<div className="flex items-center space-x-3 text-xs text-gray-500 dark:text-[#8b949e]">
|
|
54
|
-
<div className="flex items-center">
|
|
55
|
-
<Clock className="h-3 w-3 mr-0.5" />
|
|
56
|
-
<span>2d</span>
|
|
57
|
-
</div>
|
|
58
|
-
<div className="flex items-center">
|
|
59
|
-
<Tag className="h-3 w-3 mr-0.5" />
|
|
60
|
-
<span>12</span>
|
|
61
|
-
</div>
|
|
62
|
-
</div>
|
|
63
|
-
</div>
|
|
64
|
-
</div>
|
|
65
|
-
</div>
|
|
66
|
-
)
|
|
67
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Edit, FileText, List } from "lucide-react"
|
|
2
|
-
|
|
3
|
-
export default function ReadmeView() {
|
|
4
|
-
return (
|
|
5
|
-
<div className="mt-4 border border-gray-200 dark:border-[#30363d] rounded-md overflow-hidden">
|
|
6
|
-
<div className="flex items-center px-4 py-2 bg-gray-100 dark:bg-[#161b22] border-b border-gray-200 dark:border-[#30363d]">
|
|
7
|
-
<div className="flex items-center">
|
|
8
|
-
<FileText className="h-4 w-4 mr-2" />
|
|
9
|
-
<span className="font-semibold">README</span>
|
|
10
|
-
</div>
|
|
11
|
-
<div className="ml-4 px-2 py-0.5 bg-gray-200 dark:bg-[#30363d] rounded-md text-xs">
|
|
12
|
-
MIT license
|
|
13
|
-
</div>
|
|
14
|
-
<div className="ml-auto flex items-center">
|
|
15
|
-
<Edit className="h-4 w-4 mr-1" />
|
|
16
|
-
<List className="h-4 w-4 ml-2" />
|
|
17
|
-
</div>
|
|
18
|
-
</div>
|
|
19
|
-
<div className="p-4 bg-white dark:bg-[#0d1117]">
|
|
20
|
-
<h2 className="text-2xl font-bold mb-4">@tscircuit/core</h2>
|
|
21
|
-
<p className="mb-4">
|
|
22
|
-
The core logic used to build Circuit JSON from tscircuit React
|
|
23
|
-
elements.
|
|
24
|
-
</p>
|
|
25
|
-
<div className="mb-4">
|
|
26
|
-
<a
|
|
27
|
-
href="#"
|
|
28
|
-
className="text-blue-600 dark:text-[#58a6ff] hover:underline"
|
|
29
|
-
>
|
|
30
|
-
tscircuit
|
|
31
|
-
</a>
|
|
32
|
-
<span className="mx-2">•</span>
|
|
33
|
-
<a
|
|
34
|
-
href="#"
|
|
35
|
-
className="text-blue-600 dark:text-[#58a6ff] hover:underline"
|
|
36
|
-
>
|
|
37
|
-
Development Guide
|
|
38
|
-
</a>
|
|
39
|
-
<span className="mx-2">•</span>
|
|
40
|
-
<a
|
|
41
|
-
href="#"
|
|
42
|
-
className="text-blue-600 dark:text-[#58a6ff] hover:underline"
|
|
43
|
-
>
|
|
44
|
-
Core Benchmarks
|
|
45
|
-
</a>
|
|
46
|
-
</div>
|
|
47
|
-
<p>
|
|
48
|
-
You can use{" "}
|
|
49
|
-
<code className="bg-gray-100 dark:bg-[#161b22] px-1 py-0.5 rounded">
|
|
50
|
-
core
|
|
51
|
-
</code>{" "}
|
|
52
|
-
to create Circuit JSON, which can then be converted into Gerbers,
|
|
53
|
-
viewed online, and much
|
|
54
|
-
</p>
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
57
|
-
)
|
|
58
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Badge } from "@/components/ui/badge"
|
|
2
|
-
import { Button } from "@/components/ui/button"
|
|
3
|
-
import { ChevronDown } from "lucide-react"
|
|
4
|
-
import type { ReactNode } from "react"
|
|
5
|
-
|
|
6
|
-
interface RepoHeaderButtonProps {
|
|
7
|
-
icon: ReactNode
|
|
8
|
-
label: string
|
|
9
|
-
count?: number
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default function RepoHeaderButton({
|
|
13
|
-
icon,
|
|
14
|
-
label,
|
|
15
|
-
count,
|
|
16
|
-
}: RepoHeaderButtonProps) {
|
|
17
|
-
return (
|
|
18
|
-
<Button
|
|
19
|
-
variant="outline"
|
|
20
|
-
size="sm"
|
|
21
|
-
className="border-gray-300 dark:border-[#30363d] bg-gray-100 hover:bg-gray-200 dark:bg-[#21262d] dark:hover:bg-[#30363d] text-gray-700 dark:text-[#c9d1d9]"
|
|
22
|
-
>
|
|
23
|
-
{icon}
|
|
24
|
-
{label}
|
|
25
|
-
{count !== undefined && (
|
|
26
|
-
<Badge
|
|
27
|
-
variant="outline"
|
|
28
|
-
className="ml-2 text-xs rounded-full px-2 py-0.5 bg-transparent border-gray-300 dark:border-[#30363d]"
|
|
29
|
-
>
|
|
30
|
-
{count}
|
|
31
|
-
</Badge>
|
|
32
|
-
)}
|
|
33
|
-
<ChevronDown className="h-4 w-4 ml-1" />
|
|
34
|
-
</Button>
|
|
35
|
-
)
|
|
36
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Badge } from "@/components/ui/badge"
|
|
2
|
-
|
|
3
|
-
export default function SidebarContributorsSection() {
|
|
4
|
-
return (
|
|
5
|
-
<div>
|
|
6
|
-
<div className="flex items-center justify-between mb-2">
|
|
7
|
-
<h2 className="text-lg font-semibold">Contributors</h2>
|
|
8
|
-
<Badge
|
|
9
|
-
variant="outline"
|
|
10
|
-
className="text-xs rounded-full px-2 py-0.5 bg-transparent border-gray-300 dark:border-[#30363d]"
|
|
11
|
-
>
|
|
12
|
-
18
|
|
13
|
-
</Badge>
|
|
14
|
-
</div>
|
|
15
|
-
<div className="flex flex-wrap gap-1 mb-2">
|
|
16
|
-
{[...Array(10)].map((_, i) => (
|
|
17
|
-
<div
|
|
18
|
-
key={i}
|
|
19
|
-
className="w-8 h-8 rounded-full bg-gradient-to-br from-blue-500 to-purple-500"
|
|
20
|
-
></div>
|
|
21
|
-
))}
|
|
22
|
-
</div>
|
|
23
|
-
<a
|
|
24
|
-
href="#"
|
|
25
|
-
className="text-blue-600 dark:text-[#58a6ff] hover:underline text-sm"
|
|
26
|
-
>
|
|
27
|
-
+ 4 contributors
|
|
28
|
-
</a>
|
|
29
|
-
</div>
|
|
30
|
-
)
|
|
31
|
-
}
|