create-nextjs-cms 0.9.21 → 0.9.23
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/package.json +2 -2
- package/templates/default/app/(rootLayout)/(plugins)/[...slug]/page.tsx +47 -40
- package/templates/default/app/(rootLayout)/(plugins)/[...slug]/plugin-server-registry.ts +16 -16
- package/templates/default/app/(rootLayout)/admins/page.tsx +1 -1
- package/templates/default/app/(rootLayout)/browse/[section]/[page]/page.tsx +1 -1
- package/templates/default/app/(rootLayout)/categorized/[section]/page.tsx +1 -1
- package/templates/default/app/(rootLayout)/dashboard/page.tsx +10 -3
- package/templates/default/app/(rootLayout)/edit/[section]/[itemId]/page.tsx +1 -1
- package/templates/default/app/(rootLayout)/layout.tsx +1 -1
- package/templates/default/app/(rootLayout)/new/[section]/page.tsx +1 -1
- package/templates/default/app/(rootLayout)/section/[section]/page.tsx +1 -1
- package/templates/default/app/(rootLayout)/settings/page.tsx +1 -1
- package/templates/default/app/_trpc/client.tsx +6 -0
- package/templates/default/app/_trpc/server.ts +9 -0
- package/templates/default/app/_trpc/types.ts +6 -0
- package/templates/default/app/api/document/route.ts +1 -1
- package/templates/default/app/api/photo/route.ts +1 -1
- package/templates/default/app/api/trpc/[trpc]/route.ts +3 -33
- package/templates/default/app/api/video/route.ts +1 -1
- package/templates/default/app/providers.tsx +20 -152
- package/templates/default/components/AdminCard.tsx +1 -1
- package/templates/default/components/AdminPrivilegeCard.tsx +1 -1
- package/templates/default/components/CategorySectionSelectInput.tsx +1 -1
- package/templates/default/components/ItemEditPage.tsx +1 -1
- package/templates/default/components/NewAdminForm.tsx +1 -1
- package/templates/default/components/NewPage.tsx +1 -1
- package/templates/default/components/NewVariantComponent.tsx +1 -1
- package/templates/default/components/ProtectedImage.tsx +1 -1
- package/templates/default/components/SectionItemCard.tsx +1 -1
- package/templates/default/components/SectionPage.tsx +1 -1
- package/templates/default/components/Sidebar.tsx +25 -0
- package/templates/default/components/SidebarPluginGroup.tsx +63 -0
- package/templates/default/components/VariantCard.tsx +1 -1
- package/templates/default/components/VariantEditPage.tsx +1 -1
- package/templates/default/components/analytics/BounceRate.tsx +1 -1
- package/templates/default/components/analytics/LivePageViews.tsx +1 -1
- package/templates/default/components/analytics/LiveUsersCount.tsx +1 -1
- package/templates/default/components/analytics/MonthlyPageViews.tsx +1 -1
- package/templates/default/components/analytics/TopCountries.tsx +1 -1
- package/templates/default/components/analytics/TopDevices.tsx +1 -1
- package/templates/default/components/analytics/TopMediums.tsx +1 -1
- package/templates/default/components/analytics/TopSources.tsx +1 -1
- package/templates/default/components/analytics/TotalPageViews.tsx +1 -1
- package/templates/default/components/analytics/TotalSessions.tsx +1 -1
- package/templates/default/components/analytics/TotalUniqueUsers.tsx +1 -1
- package/templates/default/components/custom/RightHomeRoomVariantCard.tsx +1 -1
- package/templates/default/components/form/Form.tsx +9 -1
- package/templates/default/components/form/FormInputs.tsx +138 -136
- package/templates/default/components/form/helpers/_section-hot-reload.js +1 -1
- package/templates/default/components/form/inputs/DocumentFormInput.tsx +270 -222
- package/templates/default/components/form/inputs/RichTextFormInput.tsx +1 -1
- package/templates/default/components/form/inputs/SelectFormInput.tsx +16 -16
- package/templates/default/components/form/inputs/TextFormInput.tsx +1 -1
- package/templates/default/components/form/inputs/VideoFormInput.tsx +270 -118
- package/templates/default/dynamic-schemas/schema.ts +226 -13
- package/templates/default/next-env.d.ts +1 -1
- package/templates/default/package.json +1 -1
- package/templates/default/app/_trpc/client.ts +0 -3
|
@@ -5,6 +5,7 @@ import Image from 'next/image'
|
|
|
5
5
|
import { SidebarProps } from 'nextjs-cms/core/types'
|
|
6
6
|
import SidebarItem from '@/components/SidebarItem'
|
|
7
7
|
import SidebarDropdownItem from '@/components/SidebarDropdownItem'
|
|
8
|
+
import SidebarPluginGroup from '@/components/SidebarPluginGroup'
|
|
8
9
|
import { ScrollArea } from '@/components/ui/scroll-area'
|
|
9
10
|
import { useI18n } from 'nextjs-cms/translations/client'
|
|
10
11
|
import ProtectedImage from '@/components/ProtectedImage'
|
|
@@ -89,6 +90,30 @@ const Sidebar = (props: SidebarProps & { logoUrlPath: string; logoText: string;
|
|
|
89
90
|
</div>
|
|
90
91
|
)}
|
|
91
92
|
|
|
93
|
+
{navItems.plugin_sections && navItems.plugin_sections.length > 0 && (
|
|
94
|
+
<div className='border-primary/40 mx-3 flex flex-col border-b py-2'>
|
|
95
|
+
<h2 className='my-2 text-start text-xs text-gray-300'>{t('plugins')}</h2>
|
|
96
|
+
{navItems.plugin_sections.map((item, index) => {
|
|
97
|
+
if (item.kind === 'group') {
|
|
98
|
+
return (
|
|
99
|
+
<SidebarPluginGroup
|
|
100
|
+
closeSideBar={props.closeSideBar}
|
|
101
|
+
key={index}
|
|
102
|
+
group={item}
|
|
103
|
+
/>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
return (
|
|
107
|
+
<SidebarItem
|
|
108
|
+
closeSideBar={props.closeSideBar}
|
|
109
|
+
key={index}
|
|
110
|
+
item={item}
|
|
111
|
+
/>
|
|
112
|
+
)
|
|
113
|
+
})}
|
|
114
|
+
</div>
|
|
115
|
+
)}
|
|
116
|
+
|
|
92
117
|
{navItems.cat_sections && navItems.cat_sections.length > 0 && (
|
|
93
118
|
<div className='border-primary/40 mx-3 flex flex-col border-b py-2'>
|
|
94
119
|
<h2 className='my-2 text-start text-xs text-gray-300'>{t('categorySections')}</h2>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import Link from 'next/link'
|
|
2
|
+
import classNames from 'classnames'
|
|
3
|
+
import { useState } from 'react'
|
|
4
|
+
import { useAutoAnimate } from '@formkit/auto-animate/react'
|
|
5
|
+
import { ChevronDownIcon, ChevronUpIcon } from 'lucide-react'
|
|
6
|
+
import type { SidebarPluginGroupProps } from 'nextjs-cms/core/types'
|
|
7
|
+
import SectionIcon from '@/components/SectionIcon'
|
|
8
|
+
|
|
9
|
+
export default function SidebarPluginGroup({ group, closeSideBar }: SidebarPluginGroupProps) {
|
|
10
|
+
const [parent] = useAutoAnimate()
|
|
11
|
+
const [open, setOpen] = useState(false)
|
|
12
|
+
return (
|
|
13
|
+
<div ref={parent}>
|
|
14
|
+
<div
|
|
15
|
+
className={classNames({
|
|
16
|
+
'flex cursor-pointer text-white hover:bg-indigo-900 dark:hover:bg-emerald-600': true,
|
|
17
|
+
'gap-4 rounded-md p-2': true,
|
|
18
|
+
'rounded-b-none bg-indigo-700 dark:bg-emerald-600': open,
|
|
19
|
+
})}
|
|
20
|
+
onClick={() => setOpen((prev) => !prev)}
|
|
21
|
+
>
|
|
22
|
+
<li className='relative flex w-full items-center justify-between gap-2'>
|
|
23
|
+
<span className='flex items-center gap-2 text-start'>
|
|
24
|
+
{group.icon && <SectionIcon name={group.icon} className='size-4' />}
|
|
25
|
+
<span>{group.title}</span>
|
|
26
|
+
</span>
|
|
27
|
+
<span>
|
|
28
|
+
{open ? (
|
|
29
|
+
<ChevronUpIcon className='h-5 w-5' />
|
|
30
|
+
) : (
|
|
31
|
+
<ChevronDownIcon className='h-5 w-5' />
|
|
32
|
+
)}
|
|
33
|
+
</span>
|
|
34
|
+
</li>
|
|
35
|
+
</div>
|
|
36
|
+
{open && (
|
|
37
|
+
<div
|
|
38
|
+
className={classNames({
|
|
39
|
+
'rounded border border-t-0 border-indigo-700/50 text-white dark:border-emerald-600/50': true,
|
|
40
|
+
'flex flex-col items-stretch rounded-md rounded-t-none py-2': true,
|
|
41
|
+
})}
|
|
42
|
+
>
|
|
43
|
+
{group.children.map((child, index) => (
|
|
44
|
+
<Link
|
|
45
|
+
key={index}
|
|
46
|
+
onClick={closeSideBar}
|
|
47
|
+
href={child.path}
|
|
48
|
+
className={classNames({
|
|
49
|
+
'flex rounded text-white hover:underline': true,
|
|
50
|
+
'mx-3 gap-2 p-2': true,
|
|
51
|
+
})}
|
|
52
|
+
>
|
|
53
|
+
<li className='flex flex-row items-center gap-2'>
|
|
54
|
+
{child.icon && <SectionIcon name={child.icon} className='size-4' />}
|
|
55
|
+
<span>{child.title}</span>
|
|
56
|
+
</li>
|
|
57
|
+
</Link>
|
|
58
|
+
))}
|
|
59
|
+
</div>
|
|
60
|
+
)}
|
|
61
|
+
</div>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
@@ -3,7 +3,7 @@ import ContainerBox from '@/components/ContainerBox'
|
|
|
3
3
|
import React from 'react'
|
|
4
4
|
import { Variant } from 'nextjs-cms/core/types'
|
|
5
5
|
import useModal from '@/hooks/useModal'
|
|
6
|
-
import { useAxiosPrivate } from 'nextjs-cms/
|
|
6
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client'
|
|
7
7
|
import { handleVariantDeletion } from '@/lib/apiHelpers'
|
|
8
8
|
import { useToast } from '@/components/ui/use-toast'
|
|
9
9
|
import { Button } from '@/components/ui/button'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { useAxiosPrivate } from 'nextjs-cms/
|
|
3
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client'
|
|
4
4
|
import { getVariantPage } from '@/lib/apiHelpers'
|
|
5
5
|
import React, { RefObject, useEffect, useRef, useState } from 'react'
|
|
6
6
|
import { useQuery } from '@tanstack/react-query'
|
|
@@ -5,7 +5,7 @@ import React, { useEffect } from 'react'
|
|
|
5
5
|
import { useQuery } from '@tanstack/react-query'
|
|
6
6
|
import { getAnalytics } from '@/lib/apiHelpers'
|
|
7
7
|
import { PieChartDataItem } from 'nextjs-cms/core/types'
|
|
8
|
-
import { useAxiosPrivate } from 'nextjs-cms/
|
|
8
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client'
|
|
9
9
|
import { useTheme } from 'next-themes'
|
|
10
10
|
|
|
11
11
|
export const BounceRate = ({ fromDate, toDate }: { fromDate: Date | string | null; toDate: Date | string | null }) => {
|
|
@@ -2,7 +2,7 @@ import { useI18n } from 'nextjs-cms/translations/client'
|
|
|
2
2
|
import { Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'
|
|
3
3
|
import ContainerBox from '@/components/ContainerBox'
|
|
4
4
|
import React, { useEffect } from 'react'
|
|
5
|
-
import { useAxiosPrivate } from 'nextjs-cms/
|
|
5
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client'
|
|
6
6
|
import { useQuery } from '@tanstack/react-query'
|
|
7
7
|
import { getAnalytics } from '@/lib/apiHelpers'
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@ import { useI18n } from 'nextjs-cms/translations/client'
|
|
|
2
2
|
import { formatNumber } from 'nextjs-cms/utils'
|
|
3
3
|
import ContainerBox from '@/components/ContainerBox'
|
|
4
4
|
import React from 'react'
|
|
5
|
-
import { useAxiosPrivate } from 'nextjs-cms/
|
|
5
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client'
|
|
6
6
|
import { useQuery } from '@tanstack/react-query'
|
|
7
7
|
import { getAnalytics } from '@/lib/apiHelpers'
|
|
8
8
|
import LoadingSpinners from '@/components/LoadingSpinners'
|
|
@@ -4,7 +4,7 @@ import React from 'react'
|
|
|
4
4
|
import { useTheme } from 'next-themes'
|
|
5
5
|
import { useQuery } from '@tanstack/react-query'
|
|
6
6
|
import { getAnalytics } from '@/lib/apiHelpers'
|
|
7
|
-
import { useAxiosPrivate } from 'nextjs-cms/
|
|
7
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client'
|
|
8
8
|
|
|
9
9
|
export const MonthlyPageViews = ({
|
|
10
10
|
fromDate,
|
|
@@ -4,7 +4,7 @@ import { Badge } from '@/components/ui/badge'
|
|
|
4
4
|
import { formatNumber } from 'nextjs-cms/utils'
|
|
5
5
|
import ContainerBox from '@/components/ContainerBox'
|
|
6
6
|
import React from 'react'
|
|
7
|
-
import { useAxiosPrivate } from 'nextjs-cms/
|
|
7
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client'
|
|
8
8
|
import { useQuery } from '@tanstack/react-query'
|
|
9
9
|
import { getAnalytics } from '@/lib/apiHelpers'
|
|
10
10
|
import LoadingSpinners from '@/components/LoadingSpinners'
|
|
@@ -4,7 +4,7 @@ import { Badge } from '@/components/ui/badge'
|
|
|
4
4
|
import { formatNumber } from 'nextjs-cms/utils'
|
|
5
5
|
import ContainerBox from '@/components/ContainerBox'
|
|
6
6
|
import React from 'react'
|
|
7
|
-
import { useAxiosPrivate } from 'nextjs-cms/
|
|
7
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client'
|
|
8
8
|
import { useQuery } from '@tanstack/react-query'
|
|
9
9
|
import { getAnalytics } from '@/lib/apiHelpers'
|
|
10
10
|
import LoadingSpinners from '@/components/LoadingSpinners'
|
|
@@ -4,7 +4,7 @@ import { Badge } from '@/components/ui/badge'
|
|
|
4
4
|
import { formatNumber } from 'nextjs-cms/utils'
|
|
5
5
|
import ContainerBox from '@/components/ContainerBox'
|
|
6
6
|
import React, { useEffect } from 'react'
|
|
7
|
-
import { useAxiosPrivate } from 'nextjs-cms/
|
|
7
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client'
|
|
8
8
|
import { useQuery } from '@tanstack/react-query'
|
|
9
9
|
import { getAnalytics } from '@/lib/apiHelpers'
|
|
10
10
|
import LoadingSpinners from '@/components/LoadingSpinners'
|
|
@@ -4,7 +4,7 @@ import { Badge } from '@/components/ui/badge'
|
|
|
4
4
|
import { formatNumber } from 'nextjs-cms/utils'
|
|
5
5
|
import ContainerBox from '@/components/ContainerBox'
|
|
6
6
|
import React from 'react'
|
|
7
|
-
import { useAxiosPrivate } from 'nextjs-cms/
|
|
7
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client'
|
|
8
8
|
import { useQuery } from '@tanstack/react-query'
|
|
9
9
|
import { getAnalytics } from '@/lib/apiHelpers'
|
|
10
10
|
import LoadingSpinners from '@/components/LoadingSpinners'
|
|
@@ -2,7 +2,7 @@ import { useI18n } from 'nextjs-cms/translations/client'
|
|
|
2
2
|
import { formatNumber } from 'nextjs-cms/utils'
|
|
3
3
|
import ContainerBox from '@/components/ContainerBox'
|
|
4
4
|
import React from 'react'
|
|
5
|
-
import { useAxiosPrivate } from 'nextjs-cms/
|
|
5
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client'
|
|
6
6
|
import { useQuery } from '@tanstack/react-query'
|
|
7
7
|
import { getAnalytics } from '@/lib/apiHelpers'
|
|
8
8
|
import LoadingSpinners from '@/components/LoadingSpinners'
|
|
@@ -2,7 +2,7 @@ import { useI18n } from 'nextjs-cms/translations/client'
|
|
|
2
2
|
import { formatNumber } from 'nextjs-cms/utils'
|
|
3
3
|
import ContainerBox from '@/components/ContainerBox'
|
|
4
4
|
import React from 'react'
|
|
5
|
-
import { useAxiosPrivate } from 'nextjs-cms/
|
|
5
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client'
|
|
6
6
|
import { useQuery } from '@tanstack/react-query'
|
|
7
7
|
import { getAnalytics } from '@/lib/apiHelpers'
|
|
8
8
|
import LoadingSpinners from '@/components/LoadingSpinners'
|
|
@@ -2,7 +2,7 @@ import { useI18n } from 'nextjs-cms/translations/client'
|
|
|
2
2
|
import { formatNumber } from 'nextjs-cms/utils'
|
|
3
3
|
import ContainerBox from '@/components/ContainerBox'
|
|
4
4
|
import React from 'react'
|
|
5
|
-
import { useAxiosPrivate } from 'nextjs-cms/
|
|
5
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client'
|
|
6
6
|
import { useQuery } from '@tanstack/react-query'
|
|
7
7
|
import { getAnalytics } from '@/lib/apiHelpers'
|
|
8
8
|
import LoadingSpinners from '@/components/LoadingSpinners'
|
|
@@ -3,7 +3,7 @@ import ContainerBox from '@/components/ContainerBox'
|
|
|
3
3
|
import React from 'react'
|
|
4
4
|
import { Variant } from 'nextjs-cms/core/types'
|
|
5
5
|
import useModal from '@/hooks/useModal'
|
|
6
|
-
import { useAxiosPrivate } from 'nextjs-cms/
|
|
6
|
+
import { useAxiosPrivate } from 'nextjs-cms/api/client'
|
|
7
7
|
import { handleVariantDeletion } from '@/lib/apiHelpers'
|
|
8
8
|
import { useToast } from '@/components/ui/use-toast'
|
|
9
9
|
import { Button } from '@/components/ui/button'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RouterOutputs } from '
|
|
1
|
+
import type { RouterOutputs } from '@/app/_trpc/types'
|
|
2
2
|
import React, { RefObject, useCallback, useEffect } from 'react'
|
|
3
3
|
import ContainerBox from '@/components/ContainerBox'
|
|
4
4
|
import Dropzone, { DropzoneHandles } from '@/components/Dropzone'
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
SelectFieldClientConfig,
|
|
25
25
|
SelectMultipleFieldClientConfig,
|
|
26
26
|
SlugFieldClientConfig,
|
|
27
|
+
TagsFieldClientConfig,
|
|
27
28
|
TextAreaFieldClientConfig,
|
|
28
29
|
TextFieldClientConfig,
|
|
29
30
|
VideoFieldClientConfig,
|
|
@@ -44,6 +45,7 @@ import {
|
|
|
44
45
|
selectFieldSchema,
|
|
45
46
|
selectMultipleFieldSchema,
|
|
46
47
|
slugFieldSchema,
|
|
48
|
+
tagsFieldSchema,
|
|
47
49
|
textareaFieldSchema,
|
|
48
50
|
textFieldSchema,
|
|
49
51
|
videoFieldSchema,
|
|
@@ -230,6 +232,12 @@ export default function Form({
|
|
|
230
232
|
})
|
|
231
233
|
break
|
|
232
234
|
|
|
235
|
+
case 'tags':
|
|
236
|
+
schema = schema.extend({
|
|
237
|
+
[input.name]: tagsFieldSchema(input as TagsFieldClientConfig, language),
|
|
238
|
+
})
|
|
239
|
+
break
|
|
240
|
+
|
|
233
241
|
case 'slug':
|
|
234
242
|
schema = schema.extend({
|
|
235
243
|
[input.name]: slugFieldSchema(input as SlugFieldClientConfig, language),
|
|
@@ -1,136 +1,138 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import DateFormInput from '@/components/form/inputs/DateFormInput'
|
|
6
|
-
import DateRangeFormInput from '@/components/form/inputs/DateRangeFormInput'
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import MultipleSelectFormInput from '@/components/form/inputs/MultipleSelectFormInput'
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import {
|
|
21
|
-
CheckboxFieldClientConfig,
|
|
22
|
-
ColorFieldClientConfig,
|
|
23
|
-
DateFieldClientConfig,
|
|
24
|
-
DateRangeFieldClientConfig,
|
|
25
|
-
DocumentFieldClientConfig,
|
|
26
|
-
MapFieldClientConfig,
|
|
27
|
-
NumberFieldClientConfig,
|
|
28
|
-
PasswordFieldClientConfig,
|
|
29
|
-
PhotoFieldClientConfig,
|
|
30
|
-
RichTextFieldClientConfig,
|
|
31
|
-
SelectFieldClientConfig,
|
|
32
|
-
SelectMultipleFieldClientConfig,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
} from 'nextjs-cms/core/fields'
|
|
39
|
-
|
|
40
|
-
export default function FormInputs({
|
|
41
|
-
inputs,
|
|
42
|
-
sectionName,
|
|
43
|
-
submitSuccessCount = 0,
|
|
44
|
-
}: {
|
|
45
|
-
inputs: FieldClientConfig[]
|
|
46
|
-
sectionName: string
|
|
47
|
-
submitSuccessCount?: number
|
|
48
|
-
}) {
|
|
49
|
-
return (
|
|
50
|
-
<>
|
|
51
|
-
{inputs?.length > 0 &&
|
|
52
|
-
inputs?.map((input) => {
|
|
53
|
-
switch (input.type) {
|
|
54
|
-
case 'color':
|
|
55
|
-
return <ColorFormInput input={input as ColorFieldClientConfig} key={input.name} />
|
|
56
|
-
case 'number':
|
|
57
|
-
return <NumberFormInput input={input as NumberFieldClientConfig} key={input.name} />
|
|
58
|
-
case 'text':
|
|
59
|
-
return <TextFormInput input={input as TextFieldClientConfig} key={input.name} />
|
|
60
|
-
case 'date':
|
|
61
|
-
return <DateFormInput input={input as DateFieldClientConfig} key={input.name} />
|
|
62
|
-
case 'date_range':
|
|
63
|
-
return (
|
|
64
|
-
<DateRangeFormInput
|
|
65
|
-
input={input as DateRangeFieldClientConfig}
|
|
66
|
-
key={(input as DateRangeFieldClientConfig).startName}
|
|
67
|
-
/>
|
|
68
|
-
)
|
|
69
|
-
case 'rich_text':
|
|
70
|
-
return <RichTextFormInput input={input as RichTextFieldClientConfig} key={input.name} />
|
|
71
|
-
case 'textarea':
|
|
72
|
-
return <TextareaFormInput input={input as TextAreaFieldClientConfig} key={input.name} />
|
|
73
|
-
case 'select':
|
|
74
|
-
return (
|
|
75
|
-
<SelectFormInput
|
|
76
|
-
sectionName={sectionName}
|
|
77
|
-
input={input as SelectFieldClientConfig}
|
|
78
|
-
key={input.name}
|
|
79
|
-
/>
|
|
80
|
-
)
|
|
81
|
-
case 'select_multiple':
|
|
82
|
-
return (
|
|
83
|
-
<MultipleSelectFormInput
|
|
84
|
-
input={input as SelectMultipleFieldClientConfig}
|
|
85
|
-
key={input.name}
|
|
86
|
-
/>
|
|
87
|
-
)
|
|
88
|
-
case 'photo':
|
|
89
|
-
return (
|
|
90
|
-
<PhotoFormInput
|
|
91
|
-
sectionName={sectionName}
|
|
92
|
-
input={input as PhotoFieldClientConfig}
|
|
93
|
-
submitSuccessCount={submitSuccessCount}
|
|
94
|
-
key={input.name}
|
|
95
|
-
/>
|
|
96
|
-
)
|
|
97
|
-
case 'video':
|
|
98
|
-
return (
|
|
99
|
-
<VideoFormInput
|
|
100
|
-
sectionName={sectionName}
|
|
101
|
-
input={input as VideoFieldClientConfig}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
case '
|
|
116
|
-
return
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
case '
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return <
|
|
130
|
-
|
|
131
|
-
return
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
1
|
+
import type { FieldClientConfig } from 'nextjs-cms/core/fields'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import CheckboxFormInput from '@/components/form/inputs/CheckboxFormInput'
|
|
4
|
+
import ColorFormInput from '@/components/form/inputs/ColorFormInput'
|
|
5
|
+
import DateFormInput from '@/components/form/inputs/DateFormInput'
|
|
6
|
+
import DateRangeFormInput from '@/components/form/inputs/DateRangeFormInput'
|
|
7
|
+
import DocumentFormInput from '@/components/form/inputs/DocumentFormInput'
|
|
8
|
+
import MapFormInput from '@/components/form/inputs/MapFormInput'
|
|
9
|
+
import MultipleSelectFormInput from '@/components/form/inputs/MultipleSelectFormInput'
|
|
10
|
+
import NumberFormInput from '@/components/form/inputs/NumberFormInput'
|
|
11
|
+
import PasswordFormInput from '@/components/form/inputs/PasswordFormInput'
|
|
12
|
+
import PhotoFormInput from '@/components/form/inputs/PhotoFormInput'
|
|
13
|
+
import RichTextFormInput from '@/components/form/inputs/RichTextFormInput'
|
|
14
|
+
import SelectFormInput from '@/components/form/inputs/SelectFormInput'
|
|
15
|
+
import SlugFormInput from '@/components/form/inputs/SlugFormInput'
|
|
16
|
+
import TagsFormInput from '@/components/form/inputs/TagsFormInput'
|
|
17
|
+
import TextareaFormInput from '@/components/form/inputs/TextareaFormInput'
|
|
18
|
+
import TextFormInput from '@/components/form/inputs/TextFormInput'
|
|
19
|
+
import VideoFormInput from '@/components/form/inputs/VideoFormInput'
|
|
20
|
+
import {
|
|
21
|
+
CheckboxFieldClientConfig,
|
|
22
|
+
ColorFieldClientConfig,
|
|
23
|
+
DateFieldClientConfig,
|
|
24
|
+
DateRangeFieldClientConfig,
|
|
25
|
+
DocumentFieldClientConfig,
|
|
26
|
+
MapFieldClientConfig,
|
|
27
|
+
NumberFieldClientConfig,
|
|
28
|
+
PasswordFieldClientConfig,
|
|
29
|
+
PhotoFieldClientConfig,
|
|
30
|
+
RichTextFieldClientConfig,
|
|
31
|
+
SelectFieldClientConfig,
|
|
32
|
+
SelectMultipleFieldClientConfig,
|
|
33
|
+
SlugFieldClientConfig,
|
|
34
|
+
TagsFieldClientConfig,
|
|
35
|
+
TextAreaFieldClientConfig,
|
|
36
|
+
TextFieldClientConfig,
|
|
37
|
+
VideoFieldClientConfig,
|
|
38
|
+
} from 'nextjs-cms/core/fields'
|
|
39
|
+
|
|
40
|
+
export default function FormInputs({
|
|
41
|
+
inputs,
|
|
42
|
+
sectionName,
|
|
43
|
+
submitSuccessCount = 0,
|
|
44
|
+
}: {
|
|
45
|
+
inputs: FieldClientConfig[]
|
|
46
|
+
sectionName: string
|
|
47
|
+
submitSuccessCount?: number
|
|
48
|
+
}) {
|
|
49
|
+
return (
|
|
50
|
+
<>
|
|
51
|
+
{inputs?.length > 0 &&
|
|
52
|
+
inputs?.map((input) => {
|
|
53
|
+
switch (input.type) {
|
|
54
|
+
case 'color':
|
|
55
|
+
return <ColorFormInput input={input as ColorFieldClientConfig} key={input.name} />
|
|
56
|
+
case 'number':
|
|
57
|
+
return <NumberFormInput input={input as NumberFieldClientConfig} key={input.name} />
|
|
58
|
+
case 'text':
|
|
59
|
+
return <TextFormInput input={input as TextFieldClientConfig} key={input.name} />
|
|
60
|
+
case 'date':
|
|
61
|
+
return <DateFormInput input={input as DateFieldClientConfig} key={input.name} />
|
|
62
|
+
case 'date_range':
|
|
63
|
+
return (
|
|
64
|
+
<DateRangeFormInput
|
|
65
|
+
input={input as DateRangeFieldClientConfig}
|
|
66
|
+
key={(input as DateRangeFieldClientConfig).startName}
|
|
67
|
+
/>
|
|
68
|
+
)
|
|
69
|
+
case 'rich_text':
|
|
70
|
+
return <RichTextFormInput input={input as RichTextFieldClientConfig} key={input.name} />
|
|
71
|
+
case 'textarea':
|
|
72
|
+
return <TextareaFormInput input={input as TextAreaFieldClientConfig} key={input.name} />
|
|
73
|
+
case 'select':
|
|
74
|
+
return (
|
|
75
|
+
<SelectFormInput
|
|
76
|
+
sectionName={sectionName}
|
|
77
|
+
input={input as SelectFieldClientConfig}
|
|
78
|
+
key={input.name}
|
|
79
|
+
/>
|
|
80
|
+
)
|
|
81
|
+
case 'select_multiple':
|
|
82
|
+
return (
|
|
83
|
+
<MultipleSelectFormInput
|
|
84
|
+
input={input as SelectMultipleFieldClientConfig}
|
|
85
|
+
key={input.name}
|
|
86
|
+
/>
|
|
87
|
+
)
|
|
88
|
+
case 'photo':
|
|
89
|
+
return (
|
|
90
|
+
<PhotoFormInput
|
|
91
|
+
sectionName={sectionName}
|
|
92
|
+
input={input as PhotoFieldClientConfig}
|
|
93
|
+
submitSuccessCount={submitSuccessCount}
|
|
94
|
+
key={input.name}
|
|
95
|
+
/>
|
|
96
|
+
)
|
|
97
|
+
case 'video':
|
|
98
|
+
return (
|
|
99
|
+
<VideoFormInput
|
|
100
|
+
sectionName={sectionName}
|
|
101
|
+
input={input as VideoFieldClientConfig}
|
|
102
|
+
submitSuccessCount={submitSuccessCount}
|
|
103
|
+
key={input.name}
|
|
104
|
+
/>
|
|
105
|
+
)
|
|
106
|
+
case 'document':
|
|
107
|
+
return (
|
|
108
|
+
<DocumentFormInput
|
|
109
|
+
sectionName={sectionName}
|
|
110
|
+
input={input as DocumentFieldClientConfig}
|
|
111
|
+
submitSuccessCount={submitSuccessCount}
|
|
112
|
+
key={input.name}
|
|
113
|
+
/>
|
|
114
|
+
)
|
|
115
|
+
case 'password':
|
|
116
|
+
return <PasswordFormInput input={input as PasswordFieldClientConfig} key={input.name} />
|
|
117
|
+
case 'tags':
|
|
118
|
+
return (
|
|
119
|
+
<TagsFormInput
|
|
120
|
+
input={input as TagsFieldClientConfig}
|
|
121
|
+
sectionName={sectionName}
|
|
122
|
+
key={input.name}
|
|
123
|
+
/>
|
|
124
|
+
)
|
|
125
|
+
case 'map':
|
|
126
|
+
return <MapFormInput input={input as MapFieldClientConfig} key={input.name} />
|
|
127
|
+
case 'checkbox':
|
|
128
|
+
// case 'permission':
|
|
129
|
+
return <CheckboxFormInput input={input as CheckboxFieldClientConfig} key={input.name} />
|
|
130
|
+
case 'slug':
|
|
131
|
+
return <SlugFormInput input={input as SlugFieldClientConfig} key={input.name} />
|
|
132
|
+
default:
|
|
133
|
+
return null
|
|
134
|
+
}
|
|
135
|
+
})}
|
|
136
|
+
</>
|
|
137
|
+
)
|
|
138
|
+
}
|