create-nextjs-cms 0.7.0 → 0.7.2
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/LICENSE +21 -21
- package/README.md +71 -71
- package/dist/helpers/utils.js +16 -16
- package/dist/lib/section-creators.js +166 -166
- package/package.json +3 -3
- package/templates/default/.eslintrc.json +5 -5
- package/templates/default/.prettierignore +7 -7
- package/templates/default/.prettierrc.json +27 -27
- package/templates/default/CHANGELOG.md +140 -140
- package/templates/default/_gitignore +57 -57
- package/templates/default/app/(auth)/auth/login/LoginPage.tsx +192 -192
- package/templates/default/app/(auth)/auth/login/page.tsx +11 -11
- package/templates/default/app/(auth)/auth-locale-provider.tsx +34 -34
- package/templates/default/app/(auth)/layout.tsx +81 -81
- package/templates/default/app/(rootLayout)/(plugins)/[...slug]/page.tsx +40 -40
- package/templates/default/app/(rootLayout)/(plugins)/[...slug]/plugin-server-registry.ts +22 -22
- package/templates/default/app/(rootLayout)/admins/page.tsx +10 -10
- package/templates/default/app/(rootLayout)/browse/[section]/[page]/page.tsx +22 -22
- package/templates/default/app/(rootLayout)/categorized/[section]/page.tsx +15 -15
- package/templates/default/app/(rootLayout)/dashboard/page.tsx +63 -63
- package/templates/default/app/(rootLayout)/dashboard-new/page.tsx +7 -7
- package/templates/default/app/(rootLayout)/edit/[section]/[itemId]/page.tsx +17 -17
- package/templates/default/app/(rootLayout)/layout.tsx +81 -81
- package/templates/default/app/(rootLayout)/loading.tsx +10 -10
- package/templates/default/app/(rootLayout)/log/page.tsx +7 -7
- package/templates/default/app/(rootLayout)/new/[section]/page.tsx +15 -15
- package/templates/default/app/(rootLayout)/section/[section]/page.tsx +16 -16
- package/templates/default/app/(rootLayout)/settings/page.tsx +13 -13
- package/templates/default/app/_trpc/client.ts +3 -3
- package/templates/default/app/api/auth/csrf/route.ts +25 -25
- package/templates/default/app/api/auth/refresh/route.ts +10 -10
- package/templates/default/app/api/auth/session/route.ts +20 -20
- package/templates/default/app/api/editor/photo/route.ts +49 -49
- package/templates/default/app/api/photo/route.ts +27 -27
- package/templates/default/app/api/submit/section/item/[slug]/route.ts +66 -66
- package/templates/default/app/api/submit/section/item/route.ts +56 -56
- package/templates/default/app/api/submit/section/simple/route.ts +57 -57
- package/templates/default/app/api/trpc/[trpc]/route.ts +33 -33
- package/templates/default/app/api/video/route.ts +174 -174
- package/templates/default/app/globals.css +219 -219
- package/templates/default/app/providers.tsx +152 -152
- package/templates/default/cms.config.ts +49 -52
- package/templates/default/components/AdminCard.tsx +166 -166
- package/templates/default/components/AdminEditPage.tsx +124 -124
- package/templates/default/components/AdminPrivilegeCard.tsx +185 -185
- package/templates/default/components/AdminsPage.tsx +43 -43
- package/templates/default/components/AnalyticsPage.tsx +128 -128
- package/templates/default/components/BarChartBox.tsx +42 -42
- package/templates/default/components/BrowsePage.tsx +106 -106
- package/templates/default/components/CategorizedSectionPage.tsx +31 -31
- package/templates/default/components/CategoryDeleteConfirmPage.tsx +130 -130
- package/templates/default/components/CategorySectionSelectInput.tsx +140 -140
- package/templates/default/components/ConditionalFields.tsx +49 -49
- package/templates/default/components/ContainerBox.tsx +24 -24
- package/templates/default/components/DashboardNewPage.tsx +253 -253
- package/templates/default/components/DashboardPage.tsx +188 -188
- package/templates/default/components/DashboardPageAlt.tsx +45 -45
- package/templates/default/components/DefaultNavItems.tsx +3 -3
- package/templates/default/components/Dropzone.tsx +154 -154
- package/templates/default/components/EmailCard.tsx +138 -138
- package/templates/default/components/EmailPasswordForm.tsx +85 -85
- package/templates/default/components/EmailQuotaForm.tsx +73 -73
- package/templates/default/components/EmailsPage.tsx +49 -49
- package/templates/default/components/ErrorComponent.tsx +16 -16
- package/templates/default/components/GalleryPhoto.tsx +93 -93
- package/templates/default/components/InfoCard.tsx +93 -93
- package/templates/default/components/ItemEditPage.tsx +214 -214
- package/templates/default/components/Layout.tsx +84 -84
- package/templates/default/components/LoadingSpinners.tsx +67 -67
- package/templates/default/components/LogPage.tsx +107 -107
- package/templates/default/components/Modal.tsx +166 -166
- package/templates/default/components/Navbar.tsx +258 -258
- package/templates/default/components/NewAdminForm.tsx +173 -173
- package/templates/default/components/NewEmailForm.tsx +132 -132
- package/templates/default/components/NewPage.tsx +205 -205
- package/templates/default/components/NewVariantComponent.tsx +229 -229
- package/templates/default/components/PhotoGallery.tsx +35 -35
- package/templates/default/components/PieChartBox.tsx +101 -101
- package/templates/default/components/ProgressBar.tsx +48 -48
- package/templates/default/components/ProtectedDocument.tsx +78 -78
- package/templates/default/components/ProtectedImage.tsx +143 -143
- package/templates/default/components/ProtectedVideo.tsx +76 -76
- package/templates/default/components/SectionItemCard.tsx +144 -144
- package/templates/default/components/SectionItemStatusBadge.tsx +17 -17
- package/templates/default/components/SectionPage.tsx +125 -125
- package/templates/default/components/SelectBox.tsx +98 -98
- package/templates/default/components/SelectInputButtons.tsx +125 -125
- package/templates/default/components/SettingsPage.tsx +232 -232
- package/templates/default/components/Sidebar.tsx +201 -201
- package/templates/default/components/SidebarDropdownItem.tsx +80 -80
- package/templates/default/components/SidebarItem.tsx +20 -20
- package/templates/default/components/ThemeProvider.tsx +8 -8
- package/templates/default/components/TooltipComponent.tsx +27 -27
- package/templates/default/components/VariantCard.tsx +124 -124
- package/templates/default/components/VariantEditPage.tsx +230 -230
- package/templates/default/components/analytics/BounceRate.tsx +70 -70
- package/templates/default/components/analytics/LivePageViews.tsx +55 -55
- package/templates/default/components/analytics/LiveUsersCount.tsx +33 -33
- package/templates/default/components/analytics/MonthlyPageViews.tsx +42 -42
- package/templates/default/components/analytics/TopCountries.tsx +52 -52
- package/templates/default/components/analytics/TopDevices.tsx +46 -46
- package/templates/default/components/analytics/TopMediums.tsx +58 -58
- package/templates/default/components/analytics/TopSources.tsx +45 -45
- package/templates/default/components/analytics/TotalPageViews.tsx +41 -41
- package/templates/default/components/analytics/TotalSessions.tsx +41 -41
- package/templates/default/components/analytics/TotalUniqueUsers.tsx +41 -41
- package/templates/default/components/custom/RightHomeRoomVariantCard.tsx +138 -138
- package/templates/default/components/dndKit/Draggable.tsx +21 -21
- package/templates/default/components/dndKit/Droppable.tsx +20 -20
- package/templates/default/components/dndKit/SortableItem.tsx +18 -18
- package/templates/default/components/form/DateRangeFormInput.tsx +57 -57
- package/templates/default/components/form/Form.tsx +317 -317
- package/templates/default/components/form/FormInputElement.tsx +70 -70
- package/templates/default/components/form/FormInputs.tsx +112 -112
- package/templates/default/components/form/helpers/_section-hot-reload.js +1 -1
- package/templates/default/components/form/helpers/util.ts +17 -17
- package/templates/default/components/form/inputs/CheckboxFormInput.tsx +33 -33
- package/templates/default/components/form/inputs/ColorFormInput.tsx +44 -44
- package/templates/default/components/form/inputs/DateFormInput.tsx +156 -156
- package/templates/default/components/form/inputs/DocumentFormInput.tsx +222 -222
- package/templates/default/components/form/inputs/MapFormInput.tsx +140 -140
- package/templates/default/components/form/inputs/MultipleSelectFormInput.tsx +83 -83
- package/templates/default/components/form/inputs/NumberFormInput.tsx +42 -42
- package/templates/default/components/form/inputs/PasswordFormInput.tsx +47 -47
- package/templates/default/components/form/inputs/PhotoFormInput.tsx +219 -219
- package/templates/default/components/form/inputs/RichTextFormInput.tsx +135 -135
- package/templates/default/components/form/inputs/SelectFormInput.tsx +175 -175
- package/templates/default/components/form/inputs/SlugFormInput.tsx +129 -129
- package/templates/default/components/form/inputs/TagsFormInput.tsx +154 -154
- package/templates/default/components/form/inputs/TextFormInput.tsx +48 -48
- package/templates/default/components/form/inputs/TextareaFormInput.tsx +47 -47
- package/templates/default/components/form/inputs/VideoFormInput.tsx +118 -118
- package/templates/default/components/locale-dropdown.tsx +74 -74
- package/templates/default/components/locale-picker.tsx +85 -85
- package/templates/default/components/login-locale-dropdown.tsx +46 -46
- package/templates/default/components/multi-select.tsx +1144 -1144
- package/templates/default/components/pagination/Pagination.tsx +36 -36
- package/templates/default/components/pagination/PaginationButtons.tsx +147 -147
- package/templates/default/components/theme-toggle.tsx +37 -37
- package/templates/default/components/ui/accordion.tsx +53 -53
- package/templates/default/components/ui/alert-dialog.tsx +157 -157
- package/templates/default/components/ui/alert.tsx +46 -46
- package/templates/default/components/ui/badge.tsx +38 -38
- package/templates/default/components/ui/button.tsx +62 -62
- package/templates/default/components/ui/calendar.tsx +166 -166
- package/templates/default/components/ui/card.tsx +43 -43
- package/templates/default/components/ui/checkbox.tsx +29 -29
- package/templates/default/components/ui/command.tsx +137 -137
- package/templates/default/components/ui/custom-alert-dialog.tsx +113 -113
- package/templates/default/components/ui/custom-dialog.tsx +123 -123
- package/templates/default/components/ui/dialog.tsx +123 -123
- package/templates/default/components/ui/dropdown-menu.tsx +182 -182
- package/templates/default/components/ui/input-group.tsx +54 -54
- package/templates/default/components/ui/input.tsx +22 -22
- package/templates/default/components/ui/label.tsx +19 -19
- package/templates/default/components/ui/popover.tsx +42 -42
- package/templates/default/components/ui/progress.tsx +31 -31
- package/templates/default/components/ui/scroll-area.tsx +42 -42
- package/templates/default/components/ui/select.tsx +165 -165
- package/templates/default/components/ui/separator.tsx +28 -28
- package/templates/default/components/ui/sheet.tsx +103 -103
- package/templates/default/components/ui/switch.tsx +29 -29
- package/templates/default/components/ui/table.tsx +83 -83
- package/templates/default/components/ui/tabs.tsx +55 -55
- package/templates/default/components/ui/toast.tsx +113 -113
- package/templates/default/components/ui/toaster.tsx +35 -35
- package/templates/default/components/ui/tooltip.tsx +30 -30
- package/templates/default/components/ui/use-toast.ts +188 -188
- package/templates/default/components.json +21 -21
- package/templates/default/context/ModalProvider.tsx +53 -53
- package/templates/default/drizzle.config.ts +4 -4
- package/templates/default/dynamic-schemas/schema.ts +10 -0
- package/templates/default/env/env.js +130 -130
- package/templates/default/envConfig.ts +4 -4
- package/templates/default/hooks/useModal.ts +8 -8
- package/templates/default/lib/apiHelpers.ts +92 -92
- package/templates/default/lib/postinstall.js +14 -14
- package/templates/default/lib/utils.ts +6 -6
- package/templates/default/next-env.d.ts +6 -6
- package/templates/default/next.config.ts +23 -23
- package/templates/default/package.json +2 -4
- package/templates/default/postcss.config.mjs +6 -6
- package/templates/default/proxy.ts +32 -32
- package/templates/default/tsconfig.json +48 -48
|
@@ -1,140 +1,140 @@
|
|
|
1
|
-
import React, { useEffect } from 'react'
|
|
2
|
-
import { APIProvider, Map, Marker } from '@vis.gl/react-google-maps'
|
|
3
|
-
import ContainerBox from '@/components/ContainerBox'
|
|
4
|
-
import { Button } from '@/components/ui/button'
|
|
5
|
-
import TooltipComponent from '@/components/TooltipComponent'
|
|
6
|
-
import { useI18n } from 'nextjs-cms/translations/client'
|
|
7
|
-
import { MapFieldClientConfig } from 'nextjs-cms/core/fields'
|
|
8
|
-
import { useController, useFormContext } from 'react-hook-form'
|
|
9
|
-
import FormInputElement from '@/components/form/FormInputElement'
|
|
10
|
-
|
|
11
|
-
export default function MapFormInput({ input }: { input: MapFieldClientConfig }) {
|
|
12
|
-
const t = useI18n()
|
|
13
|
-
const { control } = useFormContext()
|
|
14
|
-
const {
|
|
15
|
-
field,
|
|
16
|
-
fieldState: { invalid, isTouched, isDirty, error },
|
|
17
|
-
} = useController({
|
|
18
|
-
name: input.name,
|
|
19
|
-
control,
|
|
20
|
-
defaultValue: input.value ?? undefined,
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
const [coords, setCoords] = React.useState<
|
|
24
|
-
| {
|
|
25
|
-
lat: number
|
|
26
|
-
lng: number
|
|
27
|
-
}
|
|
28
|
-
| undefined
|
|
29
|
-
>(() => {
|
|
30
|
-
if (input.value?.lat && input.value?.lng) {
|
|
31
|
-
return {
|
|
32
|
-
lat: input.value.lat,
|
|
33
|
-
lng: input.value.lng,
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
field.onChange(coords ? `${coords.lat},${coords.lng}` : undefined)
|
|
40
|
-
}, [coords])
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<FormInputElement
|
|
44
|
-
validationError={error}
|
|
45
|
-
value={
|
|
46
|
-
<span>
|
|
47
|
-
{input.value?.lat}, {input.value?.lng}
|
|
48
|
-
</span>
|
|
49
|
-
}
|
|
50
|
-
readonly={input.readonly}
|
|
51
|
-
label={input.label}
|
|
52
|
-
required={input.required}
|
|
53
|
-
>
|
|
54
|
-
<ContainerBox>
|
|
55
|
-
<div className='relative h-[500px] w-full overflow-hidden rounded-xl outline-0'>
|
|
56
|
-
<input
|
|
57
|
-
type='hidden'
|
|
58
|
-
value={coords ? `${coords.lat},${coords.lng}` : ''}
|
|
59
|
-
disabled={field.disabled}
|
|
60
|
-
name={field.name}
|
|
61
|
-
onChange={field.onChange}
|
|
62
|
-
onBlur={field.onBlur}
|
|
63
|
-
ref={field.ref}
|
|
64
|
-
/>
|
|
65
|
-
<APIProvider apiKey={process.env.NEXT_PUBLIC_GOOGLE_MAPS_API_KEY ?? ''}>
|
|
66
|
-
<Map
|
|
67
|
-
clickableIcons={false}
|
|
68
|
-
zoomControl={true}
|
|
69
|
-
onClick={(e) => {
|
|
70
|
-
e.stop()
|
|
71
|
-
setCoords(() => {
|
|
72
|
-
if (e.detail.latLng) {
|
|
73
|
-
return {
|
|
74
|
-
lat: e.detail.latLng.lat,
|
|
75
|
-
lng: e.detail.latLng.lng,
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
})
|
|
79
|
-
}}
|
|
80
|
-
zoom={input.zoom}
|
|
81
|
-
minZoom={input.minZoom}
|
|
82
|
-
restriction={{
|
|
83
|
-
latLngBounds: input.latLngBounds,
|
|
84
|
-
strictBounds: true,
|
|
85
|
-
}}
|
|
86
|
-
center={input.value ? { lat: input.value.lat, lng: input.value.lng } : input.center}
|
|
87
|
-
gestureHandling={'greedy'}
|
|
88
|
-
disableDefaultUI={true}
|
|
89
|
-
>
|
|
90
|
-
{coords?.lat && coords?.lng ? (
|
|
91
|
-
<Marker position={{ lat: coords.lat, lng: coords.lng }} />
|
|
92
|
-
) : null}
|
|
93
|
-
</Map>
|
|
94
|
-
</APIProvider>
|
|
95
|
-
</div>
|
|
96
|
-
|
|
97
|
-
<div className='my-2 flex flex-wrap gap-2'>
|
|
98
|
-
<Button
|
|
99
|
-
type='button'
|
|
100
|
-
size={'sm'}
|
|
101
|
-
disabled={!coords?.lat || !coords?.lng}
|
|
102
|
-
variant='default'
|
|
103
|
-
onClick={(e) => {
|
|
104
|
-
e.preventDefault()
|
|
105
|
-
e.stopPropagation()
|
|
106
|
-
setCoords(undefined)
|
|
107
|
-
}}
|
|
108
|
-
>
|
|
109
|
-
{t('removeMarker')}
|
|
110
|
-
</Button>
|
|
111
|
-
<TooltipComponent
|
|
112
|
-
delayDuration={100}
|
|
113
|
-
content={!(input.value?.lat && input.value?.lng) ? t('restoreMarkerTooltip') : null}
|
|
114
|
-
>
|
|
115
|
-
<Button
|
|
116
|
-
type='button'
|
|
117
|
-
size={'sm'}
|
|
118
|
-
disabled={!(input.value?.lat && input.value?.lng)}
|
|
119
|
-
variant='default'
|
|
120
|
-
onClick={(e) => {
|
|
121
|
-
e.preventDefault()
|
|
122
|
-
e.stopPropagation()
|
|
123
|
-
setCoords(() => {
|
|
124
|
-
if (input.value?.lat && input.value?.lng) {
|
|
125
|
-
return {
|
|
126
|
-
lat: input.value.lat,
|
|
127
|
-
lng: input.value.lng,
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
})
|
|
131
|
-
}}
|
|
132
|
-
>
|
|
133
|
-
{t('restoreMarker')}
|
|
134
|
-
</Button>
|
|
135
|
-
</TooltipComponent>
|
|
136
|
-
</div>
|
|
137
|
-
</ContainerBox>
|
|
138
|
-
</FormInputElement>
|
|
139
|
-
)
|
|
140
|
-
}
|
|
1
|
+
import React, { useEffect } from 'react'
|
|
2
|
+
import { APIProvider, Map, Marker } from '@vis.gl/react-google-maps'
|
|
3
|
+
import ContainerBox from '@/components/ContainerBox'
|
|
4
|
+
import { Button } from '@/components/ui/button'
|
|
5
|
+
import TooltipComponent from '@/components/TooltipComponent'
|
|
6
|
+
import { useI18n } from 'nextjs-cms/translations/client'
|
|
7
|
+
import { MapFieldClientConfig } from 'nextjs-cms/core/fields'
|
|
8
|
+
import { useController, useFormContext } from 'react-hook-form'
|
|
9
|
+
import FormInputElement from '@/components/form/FormInputElement'
|
|
10
|
+
|
|
11
|
+
export default function MapFormInput({ input }: { input: MapFieldClientConfig }) {
|
|
12
|
+
const t = useI18n()
|
|
13
|
+
const { control } = useFormContext()
|
|
14
|
+
const {
|
|
15
|
+
field,
|
|
16
|
+
fieldState: { invalid, isTouched, isDirty, error },
|
|
17
|
+
} = useController({
|
|
18
|
+
name: input.name,
|
|
19
|
+
control,
|
|
20
|
+
defaultValue: input.value ?? undefined,
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const [coords, setCoords] = React.useState<
|
|
24
|
+
| {
|
|
25
|
+
lat: number
|
|
26
|
+
lng: number
|
|
27
|
+
}
|
|
28
|
+
| undefined
|
|
29
|
+
>(() => {
|
|
30
|
+
if (input.value?.lat && input.value?.lng) {
|
|
31
|
+
return {
|
|
32
|
+
lat: input.value.lat,
|
|
33
|
+
lng: input.value.lng,
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
field.onChange(coords ? `${coords.lat},${coords.lng}` : undefined)
|
|
40
|
+
}, [coords])
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<FormInputElement
|
|
44
|
+
validationError={error}
|
|
45
|
+
value={
|
|
46
|
+
<span>
|
|
47
|
+
{input.value?.lat}, {input.value?.lng}
|
|
48
|
+
</span>
|
|
49
|
+
}
|
|
50
|
+
readonly={input.readonly}
|
|
51
|
+
label={input.label}
|
|
52
|
+
required={input.required}
|
|
53
|
+
>
|
|
54
|
+
<ContainerBox>
|
|
55
|
+
<div className='relative h-[500px] w-full overflow-hidden rounded-xl outline-0'>
|
|
56
|
+
<input
|
|
57
|
+
type='hidden'
|
|
58
|
+
value={coords ? `${coords.lat},${coords.lng}` : ''}
|
|
59
|
+
disabled={field.disabled}
|
|
60
|
+
name={field.name}
|
|
61
|
+
onChange={field.onChange}
|
|
62
|
+
onBlur={field.onBlur}
|
|
63
|
+
ref={field.ref}
|
|
64
|
+
/>
|
|
65
|
+
<APIProvider apiKey={process.env.NEXT_PUBLIC_GOOGLE_MAPS_API_KEY ?? ''}>
|
|
66
|
+
<Map
|
|
67
|
+
clickableIcons={false}
|
|
68
|
+
zoomControl={true}
|
|
69
|
+
onClick={(e) => {
|
|
70
|
+
e.stop()
|
|
71
|
+
setCoords(() => {
|
|
72
|
+
if (e.detail.latLng) {
|
|
73
|
+
return {
|
|
74
|
+
lat: e.detail.latLng.lat,
|
|
75
|
+
lng: e.detail.latLng.lng,
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
}}
|
|
80
|
+
zoom={input.zoom}
|
|
81
|
+
minZoom={input.minZoom}
|
|
82
|
+
restriction={{
|
|
83
|
+
latLngBounds: input.latLngBounds,
|
|
84
|
+
strictBounds: true,
|
|
85
|
+
}}
|
|
86
|
+
center={input.value ? { lat: input.value.lat, lng: input.value.lng } : input.center}
|
|
87
|
+
gestureHandling={'greedy'}
|
|
88
|
+
disableDefaultUI={true}
|
|
89
|
+
>
|
|
90
|
+
{coords?.lat && coords?.lng ? (
|
|
91
|
+
<Marker position={{ lat: coords.lat, lng: coords.lng }} />
|
|
92
|
+
) : null}
|
|
93
|
+
</Map>
|
|
94
|
+
</APIProvider>
|
|
95
|
+
</div>
|
|
96
|
+
|
|
97
|
+
<div className='my-2 flex flex-wrap gap-2'>
|
|
98
|
+
<Button
|
|
99
|
+
type='button'
|
|
100
|
+
size={'sm'}
|
|
101
|
+
disabled={!coords?.lat || !coords?.lng}
|
|
102
|
+
variant='default'
|
|
103
|
+
onClick={(e) => {
|
|
104
|
+
e.preventDefault()
|
|
105
|
+
e.stopPropagation()
|
|
106
|
+
setCoords(undefined)
|
|
107
|
+
}}
|
|
108
|
+
>
|
|
109
|
+
{t('removeMarker')}
|
|
110
|
+
</Button>
|
|
111
|
+
<TooltipComponent
|
|
112
|
+
delayDuration={100}
|
|
113
|
+
content={!(input.value?.lat && input.value?.lng) ? t('restoreMarkerTooltip') : null}
|
|
114
|
+
>
|
|
115
|
+
<Button
|
|
116
|
+
type='button'
|
|
117
|
+
size={'sm'}
|
|
118
|
+
disabled={!(input.value?.lat && input.value?.lng)}
|
|
119
|
+
variant='default'
|
|
120
|
+
onClick={(e) => {
|
|
121
|
+
e.preventDefault()
|
|
122
|
+
e.stopPropagation()
|
|
123
|
+
setCoords(() => {
|
|
124
|
+
if (input.value?.lat && input.value?.lng) {
|
|
125
|
+
return {
|
|
126
|
+
lat: input.value.lat,
|
|
127
|
+
lng: input.value.lng,
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
}}
|
|
132
|
+
>
|
|
133
|
+
{t('restoreMarker')}
|
|
134
|
+
</Button>
|
|
135
|
+
</TooltipComponent>
|
|
136
|
+
</div>
|
|
137
|
+
</ContainerBox>
|
|
138
|
+
</FormInputElement>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
import FormInputElement from '@/components/form/FormInputElement'
|
|
2
|
-
import { useEffect, useState } from 'react'
|
|
3
|
-
import { SelectMultipleFieldClientConfig, SelectOption } from 'nextjs-cms/core/fields'
|
|
4
|
-
import { useController, useFormContext } from 'react-hook-form'
|
|
5
|
-
import { MultiSelect, MultiSelectOption } from '@/components/multi-select'
|
|
6
|
-
|
|
7
|
-
export default function MultipleSelectFormInput({ input }: { input: SelectMultipleFieldClientConfig }) {
|
|
8
|
-
const { control } = useFormContext()
|
|
9
|
-
const {
|
|
10
|
-
field,
|
|
11
|
-
fieldState: { invalid, isTouched, isDirty, error },
|
|
12
|
-
} = useController({
|
|
13
|
-
name: input.name,
|
|
14
|
-
control,
|
|
15
|
-
defaultValue: input.value,
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
const [value, setValue] = useState<SelectOption[] | undefined>([])
|
|
19
|
-
|
|
20
|
-
// Convert SelectOption[] to MultiSelectOption[]
|
|
21
|
-
const convertToMultiSelectOptions = (options: SelectOption[] | undefined): MultiSelectOption[] => {
|
|
22
|
-
if (!options) return []
|
|
23
|
-
return options.map((option) => ({
|
|
24
|
-
label: option.label.toString(),
|
|
25
|
-
value: option.value.toString(),
|
|
26
|
-
}))
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Convert string[] to SelectOption[]
|
|
30
|
-
const convertFromStringArray = (values: string[], options: SelectOption[] | undefined): SelectOption[] => {
|
|
31
|
-
if (!options || !values) return []
|
|
32
|
-
return values
|
|
33
|
-
.map((value) => options.find((option) => option.value.toString() === value))
|
|
34
|
-
.filter(Boolean) as SelectOption[]
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Convert SelectOption[] to string[]
|
|
38
|
-
const convertToStringArray = (options: SelectOption[] | undefined): string[] => {
|
|
39
|
-
if (!options) return []
|
|
40
|
-
return options.map((option) => option.value.toString())
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
if (input.value && input.value?.length > 0) {
|
|
45
|
-
setValue(input.value)
|
|
46
|
-
}
|
|
47
|
-
}, [input.value])
|
|
48
|
-
|
|
49
|
-
const multiSelectOptions = convertToMultiSelectOptions(input.options)
|
|
50
|
-
const currentValue = convertToStringArray(field.value || [])
|
|
51
|
-
|
|
52
|
-
const handleValueChange = (newValues: string[]) => {
|
|
53
|
-
const selectOptions = convertFromStringArray(newValues, input.options)
|
|
54
|
-
field.onChange(selectOptions)
|
|
55
|
-
setValue(selectOptions)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<FormInputElement validationError={error} label={input.label} required={input.required}>
|
|
60
|
-
<input
|
|
61
|
-
type='hidden'
|
|
62
|
-
className='hidden'
|
|
63
|
-
disabled={field.disabled}
|
|
64
|
-
name={field.name}
|
|
65
|
-
onBlur={field.onBlur}
|
|
66
|
-
ref={field.ref}
|
|
67
|
-
value={JSON.stringify(field.value)}
|
|
68
|
-
/>
|
|
69
|
-
|
|
70
|
-
<MultiSelect
|
|
71
|
-
hideSelectAll={true}
|
|
72
|
-
variant='default'
|
|
73
|
-
maxCount={100}
|
|
74
|
-
options={multiSelectOptions}
|
|
75
|
-
onValueChange={handleValueChange}
|
|
76
|
-
defaultValue={currentValue}
|
|
77
|
-
// placeholder={input.label || 'Select options'}
|
|
78
|
-
disabled={field.disabled}
|
|
79
|
-
className='w-full py-3 ring-2 ring-gray-300'
|
|
80
|
-
/>
|
|
81
|
-
</FormInputElement>
|
|
82
|
-
)
|
|
83
|
-
}
|
|
1
|
+
import FormInputElement from '@/components/form/FormInputElement'
|
|
2
|
+
import { useEffect, useState } from 'react'
|
|
3
|
+
import { SelectMultipleFieldClientConfig, SelectOption } from 'nextjs-cms/core/fields'
|
|
4
|
+
import { useController, useFormContext } from 'react-hook-form'
|
|
5
|
+
import { MultiSelect, MultiSelectOption } from '@/components/multi-select'
|
|
6
|
+
|
|
7
|
+
export default function MultipleSelectFormInput({ input }: { input: SelectMultipleFieldClientConfig }) {
|
|
8
|
+
const { control } = useFormContext()
|
|
9
|
+
const {
|
|
10
|
+
field,
|
|
11
|
+
fieldState: { invalid, isTouched, isDirty, error },
|
|
12
|
+
} = useController({
|
|
13
|
+
name: input.name,
|
|
14
|
+
control,
|
|
15
|
+
defaultValue: input.value,
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
const [value, setValue] = useState<SelectOption[] | undefined>([])
|
|
19
|
+
|
|
20
|
+
// Convert SelectOption[] to MultiSelectOption[]
|
|
21
|
+
const convertToMultiSelectOptions = (options: SelectOption[] | undefined): MultiSelectOption[] => {
|
|
22
|
+
if (!options) return []
|
|
23
|
+
return options.map((option) => ({
|
|
24
|
+
label: option.label.toString(),
|
|
25
|
+
value: option.value.toString(),
|
|
26
|
+
}))
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Convert string[] to SelectOption[]
|
|
30
|
+
const convertFromStringArray = (values: string[], options: SelectOption[] | undefined): SelectOption[] => {
|
|
31
|
+
if (!options || !values) return []
|
|
32
|
+
return values
|
|
33
|
+
.map((value) => options.find((option) => option.value.toString() === value))
|
|
34
|
+
.filter(Boolean) as SelectOption[]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Convert SelectOption[] to string[]
|
|
38
|
+
const convertToStringArray = (options: SelectOption[] | undefined): string[] => {
|
|
39
|
+
if (!options) return []
|
|
40
|
+
return options.map((option) => option.value.toString())
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (input.value && input.value?.length > 0) {
|
|
45
|
+
setValue(input.value)
|
|
46
|
+
}
|
|
47
|
+
}, [input.value])
|
|
48
|
+
|
|
49
|
+
const multiSelectOptions = convertToMultiSelectOptions(input.options)
|
|
50
|
+
const currentValue = convertToStringArray(field.value || [])
|
|
51
|
+
|
|
52
|
+
const handleValueChange = (newValues: string[]) => {
|
|
53
|
+
const selectOptions = convertFromStringArray(newValues, input.options)
|
|
54
|
+
field.onChange(selectOptions)
|
|
55
|
+
setValue(selectOptions)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<FormInputElement validationError={error} label={input.label} required={input.required}>
|
|
60
|
+
<input
|
|
61
|
+
type='hidden'
|
|
62
|
+
className='hidden'
|
|
63
|
+
disabled={field.disabled}
|
|
64
|
+
name={field.name}
|
|
65
|
+
onBlur={field.onBlur}
|
|
66
|
+
ref={field.ref}
|
|
67
|
+
value={JSON.stringify(field.value)}
|
|
68
|
+
/>
|
|
69
|
+
|
|
70
|
+
<MultiSelect
|
|
71
|
+
hideSelectAll={true}
|
|
72
|
+
variant='default'
|
|
73
|
+
maxCount={100}
|
|
74
|
+
options={multiSelectOptions}
|
|
75
|
+
onValueChange={handleValueChange}
|
|
76
|
+
defaultValue={currentValue}
|
|
77
|
+
// placeholder={input.label || 'Select options'}
|
|
78
|
+
disabled={field.disabled}
|
|
79
|
+
className='w-full py-3 ring-2 ring-gray-300'
|
|
80
|
+
/>
|
|
81
|
+
</FormInputElement>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import FormInputElement from '@/components/form/FormInputElement'
|
|
3
|
-
import type { NumberFieldClientConfig } from 'nextjs-cms/core/fields'
|
|
4
|
-
import { useController, useFormContext } from 'react-hook-form'
|
|
5
|
-
import { isNumber, toNumber } from 'lodash-es'
|
|
6
|
-
|
|
7
|
-
export default function NumberFormInput({ input }: { input: NumberFieldClientConfig }) {
|
|
8
|
-
const { control } = useFormContext()
|
|
9
|
-
const {
|
|
10
|
-
field,
|
|
11
|
-
fieldState: { invalid, isTouched, isDirty, error },
|
|
12
|
-
} = useController({
|
|
13
|
-
name: input.name,
|
|
14
|
-
control,
|
|
15
|
-
defaultValue: isNumber(input.value) ? input.value : undefined,
|
|
16
|
-
disabled: input.readonly,
|
|
17
|
-
})
|
|
18
|
-
return (
|
|
19
|
-
<FormInputElement
|
|
20
|
-
validationError={error}
|
|
21
|
-
value={input.value}
|
|
22
|
-
label={input.label}
|
|
23
|
-
required={input.required}
|
|
24
|
-
readonly={input.readonly}
|
|
25
|
-
>
|
|
26
|
-
<input
|
|
27
|
-
type='number'
|
|
28
|
-
placeholder={input.label}
|
|
29
|
-
readOnly={field.disabled}
|
|
30
|
-
disabled={field.disabled}
|
|
31
|
-
name={field.name}
|
|
32
|
-
onChange={(event) =>
|
|
33
|
-
event.target.value ? field.onChange(toNumber(event.target.value)) : field.onChange(NaN)
|
|
34
|
-
}
|
|
35
|
-
onBlur={field.onBlur}
|
|
36
|
-
value={field.value}
|
|
37
|
-
ref={field.ref}
|
|
38
|
-
className='w-full rounded bg-input p-3 text-foreground shadow-xs outline-0 ring-2 ring-gray-300 hover:ring-gray-400 focus:ring-blue-500'
|
|
39
|
-
/>
|
|
40
|
-
</FormInputElement>
|
|
41
|
-
)
|
|
42
|
-
}
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import FormInputElement from '@/components/form/FormInputElement'
|
|
3
|
+
import type { NumberFieldClientConfig } from 'nextjs-cms/core/fields'
|
|
4
|
+
import { useController, useFormContext } from 'react-hook-form'
|
|
5
|
+
import { isNumber, toNumber } from 'lodash-es'
|
|
6
|
+
|
|
7
|
+
export default function NumberFormInput({ input }: { input: NumberFieldClientConfig }) {
|
|
8
|
+
const { control } = useFormContext()
|
|
9
|
+
const {
|
|
10
|
+
field,
|
|
11
|
+
fieldState: { invalid, isTouched, isDirty, error },
|
|
12
|
+
} = useController({
|
|
13
|
+
name: input.name,
|
|
14
|
+
control,
|
|
15
|
+
defaultValue: isNumber(input.value) ? input.value : undefined,
|
|
16
|
+
disabled: input.readonly,
|
|
17
|
+
})
|
|
18
|
+
return (
|
|
19
|
+
<FormInputElement
|
|
20
|
+
validationError={error}
|
|
21
|
+
value={input.value}
|
|
22
|
+
label={input.label}
|
|
23
|
+
required={input.required}
|
|
24
|
+
readonly={input.readonly}
|
|
25
|
+
>
|
|
26
|
+
<input
|
|
27
|
+
type='number'
|
|
28
|
+
placeholder={input.label}
|
|
29
|
+
readOnly={field.disabled}
|
|
30
|
+
disabled={field.disabled}
|
|
31
|
+
name={field.name}
|
|
32
|
+
onChange={(event) =>
|
|
33
|
+
event.target.value ? field.onChange(toNumber(event.target.value)) : field.onChange(NaN)
|
|
34
|
+
}
|
|
35
|
+
onBlur={field.onBlur}
|
|
36
|
+
value={field.value}
|
|
37
|
+
ref={field.ref}
|
|
38
|
+
className='w-full rounded bg-input p-3 text-foreground shadow-xs outline-0 ring-2 ring-gray-300 hover:ring-gray-400 focus:ring-blue-500'
|
|
39
|
+
/>
|
|
40
|
+
</FormInputElement>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import FormInputElement from '@/components/form/FormInputElement'
|
|
3
|
-
import { PasswordFieldClientConfig } from 'nextjs-cms/core/fields'
|
|
4
|
-
import { useController, useFormContext } from 'react-hook-form'
|
|
5
|
-
|
|
6
|
-
export default function PasswordFormInput({
|
|
7
|
-
input,
|
|
8
|
-
defaultValue,
|
|
9
|
-
direction,
|
|
10
|
-
}: {
|
|
11
|
-
input: PasswordFieldClientConfig
|
|
12
|
-
defaultValue?: string | null
|
|
13
|
-
direction?: 'row' | 'col'
|
|
14
|
-
}) {
|
|
15
|
-
const { control } = useFormContext()
|
|
16
|
-
const {
|
|
17
|
-
field,
|
|
18
|
-
fieldState: { invalid, isTouched, isDirty, error },
|
|
19
|
-
} = useController({
|
|
20
|
-
name: input.name,
|
|
21
|
-
control,
|
|
22
|
-
defaultValue: defaultValue ?? input.value ?? undefined,
|
|
23
|
-
disabled: input.readonly,
|
|
24
|
-
})
|
|
25
|
-
return (
|
|
26
|
-
<FormInputElement
|
|
27
|
-
validationError={error}
|
|
28
|
-
value={'********'}
|
|
29
|
-
readonly={input.readonly}
|
|
30
|
-
label={input.label}
|
|
31
|
-
required={input.required}
|
|
32
|
-
>
|
|
33
|
-
<input
|
|
34
|
-
placeholder={input.placeholder ? input.placeholder : input.label}
|
|
35
|
-
type='password'
|
|
36
|
-
readOnly={input.readonly}
|
|
37
|
-
disabled={field.disabled}
|
|
38
|
-
name={field.name}
|
|
39
|
-
onChange={field.onChange}
|
|
40
|
-
onBlur={field.onBlur}
|
|
41
|
-
value={field.value}
|
|
42
|
-
ref={field.ref}
|
|
43
|
-
className='w-full rounded bg-input p-3 text-foreground shadow-xs outline-0 ring-2 ring-gray-300 hover:ring-gray-400 focus:ring-blue-500'
|
|
44
|
-
/>
|
|
45
|
-
</FormInputElement>
|
|
46
|
-
)
|
|
47
|
-
}
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import FormInputElement from '@/components/form/FormInputElement'
|
|
3
|
+
import { PasswordFieldClientConfig } from 'nextjs-cms/core/fields'
|
|
4
|
+
import { useController, useFormContext } from 'react-hook-form'
|
|
5
|
+
|
|
6
|
+
export default function PasswordFormInput({
|
|
7
|
+
input,
|
|
8
|
+
defaultValue,
|
|
9
|
+
direction,
|
|
10
|
+
}: {
|
|
11
|
+
input: PasswordFieldClientConfig
|
|
12
|
+
defaultValue?: string | null
|
|
13
|
+
direction?: 'row' | 'col'
|
|
14
|
+
}) {
|
|
15
|
+
const { control } = useFormContext()
|
|
16
|
+
const {
|
|
17
|
+
field,
|
|
18
|
+
fieldState: { invalid, isTouched, isDirty, error },
|
|
19
|
+
} = useController({
|
|
20
|
+
name: input.name,
|
|
21
|
+
control,
|
|
22
|
+
defaultValue: defaultValue ?? input.value ?? undefined,
|
|
23
|
+
disabled: input.readonly,
|
|
24
|
+
})
|
|
25
|
+
return (
|
|
26
|
+
<FormInputElement
|
|
27
|
+
validationError={error}
|
|
28
|
+
value={'********'}
|
|
29
|
+
readonly={input.readonly}
|
|
30
|
+
label={input.label}
|
|
31
|
+
required={input.required}
|
|
32
|
+
>
|
|
33
|
+
<input
|
|
34
|
+
placeholder={input.placeholder ? input.placeholder : input.label}
|
|
35
|
+
type='password'
|
|
36
|
+
readOnly={input.readonly}
|
|
37
|
+
disabled={field.disabled}
|
|
38
|
+
name={field.name}
|
|
39
|
+
onChange={field.onChange}
|
|
40
|
+
onBlur={field.onBlur}
|
|
41
|
+
value={field.value}
|
|
42
|
+
ref={field.ref}
|
|
43
|
+
className='w-full rounded bg-input p-3 text-foreground shadow-xs outline-0 ring-2 ring-gray-300 hover:ring-gray-400 focus:ring-blue-500'
|
|
44
|
+
/>
|
|
45
|
+
</FormInputElement>
|
|
46
|
+
)
|
|
47
|
+
}
|