create-nextjs-cms 0.9.21 → 0.9.22
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 +1 -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/SelectFormInput.tsx +16 -16
- package/templates/default/components/form/inputs/VideoFormInput.tsx +270 -118
- package/templates/default/dynamic-schemas/schema.ts +202 -31
- package/templates/default/package.json +1 -1
package/package.json
CHANGED
|
@@ -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
|
+
}
|