blocks-dusted 0.1.12 → 0.1.13
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/src/installers/patchRenderBlocks.js +1 -1
- package/src/registry/validateTemplateManifest.js +2 -1
- package/templates/blocks/BannerDD790432/Component.tsx +63 -0
- package/templates/blocks/BannerDD790432/config.ts +54 -0
- package/templates/blocks/BannerDD790432/manifest.json +80 -0
- package/templates/blocks/Button47/Component.tsx +124 -0
- package/templates/blocks/Button47/config.ts +75 -0
- package/templates/blocks/Button47/link.ts +22 -0
- package/templates/blocks/Button47/manifest.json +105 -0
- package/templates/blocks/Button47/styles.module.scss +75 -0
- package/templates/blocks/DD-Accordion/Component.tsx +55 -36
- package/templates/blocks/DD-Accordion/config.ts +71 -59
- package/templates/blocks/DD-AnimText/Component.tsx +50 -32
- package/templates/blocks/DD-AnimText/config.ts +296 -295
- package/templates/blocks/DD-AsideNav/Component.tsx +323 -319
- package/templates/blocks/DD-Banner/Component.tsx +54 -51
- package/templates/blocks/DD-BookCall/Component.tsx +535 -535
- package/templates/blocks/DD-ButtonPop/Component.tsx +118 -117
- package/templates/blocks/DD-Card/Component.tsx +4 -4
- package/templates/blocks/DD-CardTemplate01/Component.tsx +139 -140
- package/templates/blocks/DD-CardsWithVariantV3/Component.tsx +472 -0
- package/templates/blocks/DD-CardsWithVariantV3/ElectricBorder/index.tsx +203 -0
- package/templates/blocks/DD-CardsWithVariantV3/ElectricBorder/styles.ts +87 -0
- package/templates/blocks/DD-CardsWithVariantV3/ElectricBorder/useInjectStyle.ts +39 -0
- package/templates/blocks/DD-CardsWithVariantV3/config.ts +326 -0
- package/templates/blocks/DD-CardsWithVariantV3/manifest.json +110 -0
- package/templates/blocks/DD-Carousel-A/Component.tsx +251 -249
- package/templates/blocks/DD-Carousel-B/Component.tsx +405 -403
- package/templates/blocks/DD-ComparisonTable/Component.tsx +255 -256
- package/templates/blocks/DD-Contact/Component.tsx +433 -435
- package/templates/blocks/DD-Counter/Component.tsx +11 -6
- package/templates/blocks/DD-DeliCard/Component.tsx +303 -0
- package/templates/blocks/DD-DeliCard/config.ts +186 -0
- package/templates/blocks/DD-DeliCard/manifest.json +94 -0
- package/templates/blocks/DD-FeatCat/Component.tsx +302 -302
- package/templates/blocks/DD-FeatProd/CircularGallery.tsx +1179 -0
- package/templates/blocks/DD-FeatProd/Component.tsx +484 -0
- package/templates/blocks/DD-FeatProd/config.ts +173 -0
- package/templates/blocks/DD-FeatProd/manifest.json +93 -0
- package/templates/blocks/DD-FeatServ/Component.tsx +607 -0
- package/templates/blocks/DD-FeatServ/config.ts +213 -0
- package/templates/blocks/DD-FeatServ/manifest.json +113 -0
- package/templates/blocks/DD-FeatStrip/Component.tsx +584 -585
- package/templates/blocks/DD-FluidBtn/ButtonsEyeCatching.tsx +627 -628
- package/templates/blocks/DD-FluidBtn/Component.tsx +46 -43
- package/templates/blocks/DD-GooeyInfo/Component.tsx +150 -149
- package/templates/blocks/DD-GooeyInfo/config.ts +136 -135
- package/templates/blocks/DD-Hero/Component.tsx +296 -297
- package/templates/blocks/DD-HeroPlas/Component.tsx +50 -0
- package/templates/blocks/DD-HeroPlas/ThreeScene.tsx +109 -0
- package/templates/blocks/DD-HeroPlas/config.ts +33 -0
- package/templates/blocks/DD-HeroPlas/manifest.json +88 -0
- package/templates/blocks/DD-HorizontalScroll/Component.tsx +937 -936
- package/templates/blocks/DD-Icon/Component.tsx +46 -81
- package/templates/blocks/DD-IconButton/Component.tsx +13 -20
- package/templates/blocks/DD-IdTag/Component.tsx +22 -21
- package/templates/blocks/DD-LineAnim/Component.tsx +42 -36
- package/templates/blocks/DD-LogoMarq/Component.tsx +38 -48
- package/templates/blocks/DD-Lottie/Component.tsx +11 -3
- package/templates/blocks/DD-MasonaryMedia/Component.tsx +544 -545
- package/templates/blocks/DD-MasonaryMedia/config.ts +389 -389
- package/templates/blocks/DD-Masonry/Component.tsx +654 -644
- package/templates/blocks/DD-Masonry/config.ts +475 -475
- package/templates/blocks/DD-MaterialSwatches/Component.tsx +85 -0
- package/templates/blocks/DD-MaterialSwatches/config.ts +232 -0
- package/templates/blocks/DD-MaterialSwatches/manifest.json +84 -0
- package/templates/blocks/DD-MaterialSwatches/material.ts +107 -0
- package/templates/blocks/DD-NineCanvas/Component.tsx +129 -0
- package/templates/blocks/DD-NineCanvas/RenderBlocks.tsx +244 -0
- package/templates/blocks/DD-NineCanvas/allowedCanvasBlocks.ts +6 -0
- package/templates/blocks/DD-NineCanvas/blockComponents.tsx +8 -0
- package/templates/blocks/DD-NineCanvas/canvas/CanvasGrid.tsx +316 -0
- package/templates/blocks/DD-NineCanvas/canvas/RadialNav.tsx +432 -0
- package/templates/blocks/DD-NineCanvas/canvas/canvas-panels.css +889 -0
- package/templates/blocks/DD-NineCanvas/canvas/icons/custom-icons.tsx +364 -0
- package/templates/blocks/DD-NineCanvas/config.ts +61 -0
- package/templates/blocks/DD-NineCanvas/manifest.json +165 -0
- package/templates/blocks/DD-NineCanvas/styles.scss +152 -0
- package/templates/blocks/DD-NineCanvas/tooltip/get-strict-context.tsx +26 -0
- package/templates/blocks/DD-NineCanvas/tooltip/primitives.tsx +178 -0
- package/templates/blocks/DD-NineCanvas/tooltip/tooltip.tsx +71 -0
- package/templates/blocks/DD-NineCanvas/tooltip/use-controlled-state.tsx +33 -0
- package/templates/blocks/DD-NineCanvas/utilities/FadeOnScroll.tsx +68 -0
- package/templates/blocks/DD-NineCanvas/utilities/ParallaxWrapper.tsx +157 -0
- package/templates/blocks/DD-NineCanvas/utilities/renderCustomCSS.ts +5 -0
- package/templates/blocks/DD-NineCanvas/utilities/webglCleanup.ts +27 -0
- package/templates/blocks/DD-PayloadAIAssistant/Component.tsx +78 -0
- package/templates/blocks/DD-PayloadAIAssistant/DustedBot.tsx +590 -0
- package/templates/blocks/DD-PayloadAIAssistant/config.ts +37 -0
- package/templates/blocks/DD-PayloadAIAssistant/demo.css +125 -0
- package/templates/blocks/DD-PayloadAIAssistant/manifest.json +93 -0
- package/templates/blocks/DD-PayloadAIAssistant/source-defaults.ts +17 -0
- package/templates/blocks/DD-PayloadAIAssistant/styles.ts +306 -0
- package/templates/blocks/DD-Pricing/Component.tsx +2 -3
- package/templates/blocks/DD-Pricing/config.ts +215 -215
- package/templates/blocks/DD-Process/Component.tsx +2 -2
- package/templates/blocks/DD-ProjHeader/Component.tsx +93 -91
- package/templates/blocks/DD-ProjSlider/Component.tsx +1 -1
- package/templates/blocks/DD-Section/Component.tsx +265 -266
- package/templates/blocks/DD-Separator/Component.tsx +66 -66
- package/templates/blocks/DD-Services/Component.tsx +176 -176
- package/templates/blocks/DD-ShowcaseGrid/Component.tsx +306 -307
- package/templates/blocks/DD-Slider-A/Component.tsx +2 -2
- package/templates/blocks/DD-StackCards/Component.tsx +172 -171
- package/templates/blocks/DD-Team/Component.tsx +247 -247
- package/templates/blocks/DD-TeamCards/Component.tsx +251 -251
- package/templates/blocks/DD-TechStack/Component.tsx +173 -174
- package/templates/blocks/DD-TestMarq/Component.tsx +158 -132
- package/templates/blocks/DD-Testim/Component.tsx +247 -247
- package/templates/blocks/DD-Testim2/Component.tsx +265 -256
- package/templates/blocks/DD-Testimonials/Component.tsx +139 -139
- package/templates/blocks/DD-Thanks/Component.tsx +1 -1
- package/templates/blocks/DD-Work/Component.tsx +318 -318
- package/templates/blocks/DD-Work-B/Component.tsx +294 -294
- package/templates/blocks/DDHG-CTASection2/Component.tsx +183 -184
- package/templates/blocks/DDHG-HighlightArc/Component.tsx +6 -3
- package/templates/blocks/DDHG-LogoMarquee/Component.tsx +45 -8
- package/templates/blocks/DDHG-NavCodeGrid/Component.tsx +1 -3
- package/templates/blocks/DDHG-ServiceDetails/ServiceDetailCard.tsx +9 -22
- package/templates/blocks/DDHG-ServiceHero/Component.tsx +10 -10
- package/templates/blocks/DDHG-TeamCards/Component.tsx +6 -35
- package/templates/blocks/Form/Checkbox/index.tsx +45 -0
- package/templates/blocks/Form/Component.tsx +163 -0
- package/templates/blocks/Form/Country/index.tsx +65 -0
- package/templates/blocks/Form/Country/options.ts +982 -0
- package/templates/blocks/Form/Email/index.tsx +38 -0
- package/templates/blocks/Form/Error/index.tsx +15 -0
- package/templates/blocks/Form/Message/index.tsx +13 -0
- package/templates/blocks/Form/Number/index.tsx +36 -0
- package/templates/blocks/Form/Select/index.tsx +63 -0
- package/templates/blocks/Form/State/index.tsx +64 -0
- package/templates/blocks/Form/State/options.ts +52 -0
- package/templates/blocks/Form/Text/index.tsx +32 -0
- package/templates/blocks/Form/Textarea/index.tsx +40 -0
- package/templates/blocks/Form/Width/index.tsx +13 -0
- package/templates/blocks/Form/config.ts +51 -0
- package/templates/blocks/Form/fields.tsx +21 -0
- package/templates/blocks/Form/manifest.json +168 -0
- package/templates/blocks/MediaBlock/Component.tsx +67 -0
- package/templates/blocks/MediaBlock/config.ts +14 -0
- package/templates/blocks/MediaBlock/manifest.json +92 -0
- package/templates/blocks/TransitionsDustedShowcase/Component.tsx +9 -0
- package/templates/blocks/TransitionsDustedShowcase/config.ts +13 -0
- package/templates/blocks/TransitionsDustedShowcase/manifest.json +80 -0
- package/templates/blocks/rawHtml/Component.tsx +25 -0
- package/templates/blocks/rawHtml/config.ts +56 -0
- package/templates/blocks/rawHtml/manifest.json +80 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { useEffect, useRef } from 'react'
|
|
4
3
|
import Image from 'next/image'
|
|
5
4
|
import Link from 'next/link'
|
|
6
5
|
import { Globe, Briefcase, Camera } from 'lucide-react'
|
|
@@ -42,35 +41,12 @@ export const DDHGTeamCards: React.FC<DDHGTeamCardsProps> = ({
|
|
|
42
41
|
customCSS,
|
|
43
42
|
members,
|
|
44
43
|
}) => {
|
|
45
|
-
const ref = useRef<HTMLDivElement>(null)
|
|
46
|
-
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
const observer = new IntersectionObserver(
|
|
49
|
-
(entries) => {
|
|
50
|
-
entries.forEach((entry) => {
|
|
51
|
-
if (entry.isIntersecting) {
|
|
52
|
-
entry.target.querySelectorAll<HTMLElement>('.reveal').forEach((el, i) => {
|
|
53
|
-
setTimeout(() => {
|
|
54
|
-
el.style.opacity = '1'
|
|
55
|
-
el.style.transform = 'translateY(0)'
|
|
56
|
-
}, i * 100)
|
|
57
|
-
})
|
|
58
|
-
observer.unobserve(entry.target)
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
},
|
|
62
|
-
{ threshold: 0.1 },
|
|
63
|
-
)
|
|
64
|
-
if (ref.current) observer.observe(ref.current)
|
|
65
|
-
return () => observer.disconnect()
|
|
66
|
-
}, [])
|
|
67
|
-
|
|
68
44
|
return (
|
|
69
|
-
<div id={sectionId ?? undefined} className={cn('px-5 md:px-8
|
|
45
|
+
<div id={sectionId ?? undefined} className={cn('w-full px-5 py-8 md:px-8', customClassName)}>
|
|
70
46
|
{customCSS && <style dangerouslySetInnerHTML={{ __html: customCSS }} />}
|
|
71
|
-
<div className="max-w-7xl
|
|
47
|
+
<div className="mx-auto w-full max-w-7xl">
|
|
72
48
|
{members && members.length > 0 && (
|
|
73
|
-
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3
|
|
49
|
+
<div className="grid w-full grid-cols-1 gap-5 md:grid-cols-2 md:gap-6 lg:grid-cols-3">
|
|
74
50
|
{members.map((member, i) => {
|
|
75
51
|
const imageDoc = getMediaDoc(member.image)
|
|
76
52
|
const imageUrl = getMediaUrl(imageDoc?.url)
|
|
@@ -83,12 +59,7 @@ export const DDHGTeamCards: React.FC<DDHGTeamCardsProps> = ({
|
|
|
83
59
|
return (
|
|
84
60
|
<div
|
|
85
61
|
key={member.id != null ? `id-${member.id}` : `idx-${i}`}
|
|
86
|
-
className="
|
|
87
|
-
style={{
|
|
88
|
-
opacity: 0,
|
|
89
|
-
transform: 'translateY(20px)',
|
|
90
|
-
transition: `opacity 0.9s ease ${i * 0.1}s, transform 0.9s ease ${i * 0.1}s`,
|
|
91
|
-
}}
|
|
62
|
+
className="group relative overflow-hidden cursor-pointer rounded-md squircle border-none border-stone-300/0 bg-stone-100/50 transition-all duration-300 hover:shadow-2xl dark:border-stone-700/0 h-[28rem] dark:bg-stone-900/50 md:h-[32rem]"
|
|
92
63
|
>
|
|
93
64
|
{imageDoc && imageUrl && (
|
|
94
65
|
<div className="relative w-full h-full overflow-hidden brightness-100 group-hover:brightness-50 transition-all duration-300">
|
|
@@ -122,8 +93,8 @@ export const DDHGTeamCards: React.FC<DDHGTeamCardsProps> = ({
|
|
|
122
93
|
)}
|
|
123
94
|
{member.role && (
|
|
124
95
|
<p
|
|
125
|
-
className="text-xs
|
|
126
|
-
style={{ fontFamily: "'Inter', sans-serif", fontWeight:
|
|
96
|
+
className="text-xs font-bold uppercase tracking-wider md:text-sm text-blue-600 dark:text-blue-500 drop-shadow-md"
|
|
97
|
+
style={{ fontFamily: "'Inter', sans-serif", fontWeight: 700 }}
|
|
127
98
|
>
|
|
128
99
|
{member.role}
|
|
129
100
|
</p>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { CheckboxField } from '@payloadcms/plugin-form-builder/types'
|
|
2
|
+
import type { FieldErrorsImpl, FieldValues, UseFormRegister } from 'react-hook-form'
|
|
3
|
+
|
|
4
|
+
import { useFormContext } from 'react-hook-form'
|
|
5
|
+
|
|
6
|
+
import { Checkbox as CheckboxUi } from '@/components/ui/checkbox'
|
|
7
|
+
import { Label } from '@/components/ui/label'
|
|
8
|
+
import React from 'react'
|
|
9
|
+
|
|
10
|
+
import { Error } from '../Error'
|
|
11
|
+
import { Width } from '../Width'
|
|
12
|
+
|
|
13
|
+
export const Checkbox: React.FC<
|
|
14
|
+
CheckboxField & {
|
|
15
|
+
errors: Partial<FieldErrorsImpl>
|
|
16
|
+
register: UseFormRegister<FieldValues>
|
|
17
|
+
}
|
|
18
|
+
> = ({ name, defaultValue, errors, label, register, required, width }) => {
|
|
19
|
+
const props = register(name, { required: required })
|
|
20
|
+
const { setValue } = useFormContext()
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Width width={width}>
|
|
24
|
+
<div className="flex items-center gap-2">
|
|
25
|
+
<CheckboxUi
|
|
26
|
+
defaultChecked={defaultValue}
|
|
27
|
+
id={name}
|
|
28
|
+
{...props}
|
|
29
|
+
onCheckedChange={(checked) => {
|
|
30
|
+
setValue(props.name, checked)
|
|
31
|
+
}}
|
|
32
|
+
/>
|
|
33
|
+
<Label htmlFor={name}>
|
|
34
|
+
{required && (
|
|
35
|
+
<span className="required">
|
|
36
|
+
* <span className="sr-only">(required)</span>
|
|
37
|
+
</span>
|
|
38
|
+
)}
|
|
39
|
+
{label}
|
|
40
|
+
</Label>
|
|
41
|
+
</div>
|
|
42
|
+
{errors[name] && <Error name={name} />}
|
|
43
|
+
</Width>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import type { FormFieldBlock, Form as FormType } from '@payloadcms/plugin-form-builder/types'
|
|
3
|
+
|
|
4
|
+
import { useRouter } from 'next/navigation'
|
|
5
|
+
import React, { useCallback, useState } from 'react'
|
|
6
|
+
import { useForm, FormProvider } from 'react-hook-form'
|
|
7
|
+
import RichText from '@/components/RichText'
|
|
8
|
+
import { Button } from '@/components/ui/button'
|
|
9
|
+
import type { DefaultTypedEditorState } from '@payloadcms/richtext-lexical'
|
|
10
|
+
|
|
11
|
+
import { fields } from './fields'
|
|
12
|
+
import { getClientSideURL } from '@/utilities/getURL'
|
|
13
|
+
|
|
14
|
+
export type FormBlockType = {
|
|
15
|
+
blockName?: string
|
|
16
|
+
blockType?: 'formBlock'
|
|
17
|
+
enableIntro: boolean
|
|
18
|
+
form: FormType
|
|
19
|
+
introContent?: DefaultTypedEditorState
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const FormBlock: React.FC<
|
|
23
|
+
{
|
|
24
|
+
id?: string
|
|
25
|
+
} & FormBlockType
|
|
26
|
+
> = (props) => {
|
|
27
|
+
const {
|
|
28
|
+
enableIntro,
|
|
29
|
+
form: formFromProps,
|
|
30
|
+
form: { id: formID, confirmationMessage, confirmationType, redirect, submitButtonLabel } = {},
|
|
31
|
+
introContent,
|
|
32
|
+
} = props
|
|
33
|
+
|
|
34
|
+
const formMethods = useForm({
|
|
35
|
+
defaultValues: formFromProps.fields,
|
|
36
|
+
})
|
|
37
|
+
const {
|
|
38
|
+
control,
|
|
39
|
+
formState: { errors },
|
|
40
|
+
handleSubmit,
|
|
41
|
+
register,
|
|
42
|
+
} = formMethods
|
|
43
|
+
|
|
44
|
+
const [isLoading, setIsLoading] = useState(false)
|
|
45
|
+
const [hasSubmitted, setHasSubmitted] = useState<boolean>()
|
|
46
|
+
const [error, setError] = useState<{ message: string; status?: string } | undefined>()
|
|
47
|
+
const router = useRouter()
|
|
48
|
+
|
|
49
|
+
const onSubmit = useCallback(
|
|
50
|
+
(data: FormFieldBlock[]) => {
|
|
51
|
+
let loadingTimerID: ReturnType<typeof setTimeout>
|
|
52
|
+
const submitForm = async () => {
|
|
53
|
+
setError(undefined)
|
|
54
|
+
|
|
55
|
+
const dataToSend = Object.entries(data).map(([name, value]) => ({
|
|
56
|
+
field: name,
|
|
57
|
+
value,
|
|
58
|
+
}))
|
|
59
|
+
|
|
60
|
+
// delay loading indicator by 1s
|
|
61
|
+
loadingTimerID = setTimeout(() => {
|
|
62
|
+
setIsLoading(true)
|
|
63
|
+
}, 1000)
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
const req = await fetch(`${getClientSideURL()}/api/form-submissions`, {
|
|
67
|
+
body: JSON.stringify({
|
|
68
|
+
form: formID,
|
|
69
|
+
submissionData: dataToSend,
|
|
70
|
+
}),
|
|
71
|
+
headers: {
|
|
72
|
+
'Content-Type': 'application/json',
|
|
73
|
+
},
|
|
74
|
+
method: 'POST',
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
const res = await req.json()
|
|
78
|
+
|
|
79
|
+
clearTimeout(loadingTimerID)
|
|
80
|
+
|
|
81
|
+
if (req.status >= 400) {
|
|
82
|
+
setIsLoading(false)
|
|
83
|
+
|
|
84
|
+
setError({
|
|
85
|
+
message: res.errors?.[0]?.message || 'Internal Server Error',
|
|
86
|
+
status: res.status,
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
return
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
setIsLoading(false)
|
|
93
|
+
setHasSubmitted(true)
|
|
94
|
+
|
|
95
|
+
if (confirmationType === 'redirect' && redirect) {
|
|
96
|
+
const { url } = redirect
|
|
97
|
+
|
|
98
|
+
const redirectUrl = url
|
|
99
|
+
|
|
100
|
+
if (redirectUrl) router.push(redirectUrl)
|
|
101
|
+
}
|
|
102
|
+
} catch (err) {
|
|
103
|
+
console.warn(err)
|
|
104
|
+
setIsLoading(false)
|
|
105
|
+
setError({
|
|
106
|
+
message: 'Something went wrong.',
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
void submitForm()
|
|
112
|
+
},
|
|
113
|
+
[router, formID, redirect, confirmationType],
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<div className="container lg:max-w-[48rem]">
|
|
118
|
+
{enableIntro && introContent && !hasSubmitted && (
|
|
119
|
+
<RichText className="mb-8 lg:mb-12" data={introContent} enableGutter={false} />
|
|
120
|
+
)}
|
|
121
|
+
<div className="p-4 lg:p-6 border border-border rounded-[0.8rem]">
|
|
122
|
+
<FormProvider {...formMethods}>
|
|
123
|
+
{!isLoading && hasSubmitted && confirmationType === 'message' && (
|
|
124
|
+
<RichText data={confirmationMessage} />
|
|
125
|
+
)}
|
|
126
|
+
{isLoading && !hasSubmitted && <p>Loading, please wait...</p>}
|
|
127
|
+
{error && <div>{`${error.status || '500'}: ${error.message || ''}`}</div>}
|
|
128
|
+
{!hasSubmitted && (
|
|
129
|
+
<form id={formID} onSubmit={handleSubmit(onSubmit)}>
|
|
130
|
+
<div className="mb-4 last:mb-0">
|
|
131
|
+
{formFromProps &&
|
|
132
|
+
formFromProps.fields &&
|
|
133
|
+
formFromProps.fields?.map((field, index) => {
|
|
134
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
135
|
+
const Field: React.FC<any> = fields?.[field.blockType as keyof typeof fields]
|
|
136
|
+
if (Field) {
|
|
137
|
+
return (
|
|
138
|
+
<div className="mb-6 last:mb-0" key={index}>
|
|
139
|
+
<Field
|
|
140
|
+
form={formFromProps}
|
|
141
|
+
{...field}
|
|
142
|
+
{...formMethods}
|
|
143
|
+
control={control}
|
|
144
|
+
errors={errors}
|
|
145
|
+
register={register}
|
|
146
|
+
/>
|
|
147
|
+
</div>
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
return null
|
|
151
|
+
})}
|
|
152
|
+
</div>
|
|
153
|
+
|
|
154
|
+
<Button form={formID} type="submit" variant="default">
|
|
155
|
+
{submitButtonLabel}
|
|
156
|
+
</Button>
|
|
157
|
+
</form>
|
|
158
|
+
)}
|
|
159
|
+
</FormProvider>
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
)
|
|
163
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { CountryField } from '@payloadcms/plugin-form-builder/types'
|
|
2
|
+
import type { Control, FieldErrorsImpl } from 'react-hook-form'
|
|
3
|
+
|
|
4
|
+
import { Label } from '@/components/ui/label'
|
|
5
|
+
import {
|
|
6
|
+
Select,
|
|
7
|
+
SelectContent,
|
|
8
|
+
SelectItem,
|
|
9
|
+
SelectTrigger,
|
|
10
|
+
SelectValue,
|
|
11
|
+
} from '@/components/ui/select'
|
|
12
|
+
import React from 'react'
|
|
13
|
+
import { Controller } from 'react-hook-form'
|
|
14
|
+
|
|
15
|
+
import { Error } from '../Error'
|
|
16
|
+
import { Width } from '../Width'
|
|
17
|
+
import { countryOptions } from './options'
|
|
18
|
+
|
|
19
|
+
export const Country: React.FC<
|
|
20
|
+
CountryField & {
|
|
21
|
+
control: Control
|
|
22
|
+
errors: Partial<FieldErrorsImpl>
|
|
23
|
+
}
|
|
24
|
+
> = ({ name, control, errors, label, required, width }) => {
|
|
25
|
+
return (
|
|
26
|
+
<Width width={width}>
|
|
27
|
+
<Label className="" htmlFor={name}>
|
|
28
|
+
{label}
|
|
29
|
+
|
|
30
|
+
{required && (
|
|
31
|
+
<span className="required">
|
|
32
|
+
* <span className="sr-only">(required)</span>
|
|
33
|
+
</span>
|
|
34
|
+
)}
|
|
35
|
+
</Label>
|
|
36
|
+
<Controller
|
|
37
|
+
control={control}
|
|
38
|
+
defaultValue=""
|
|
39
|
+
name={name}
|
|
40
|
+
render={({ field: { onChange, value } }) => {
|
|
41
|
+
const controlledValue = countryOptions.find((t) => t.value === value)
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Select onValueChange={(val) => onChange(val)} value={controlledValue?.value}>
|
|
45
|
+
<SelectTrigger className="w-full" id={name}>
|
|
46
|
+
<SelectValue placeholder={label} />
|
|
47
|
+
</SelectTrigger>
|
|
48
|
+
<SelectContent>
|
|
49
|
+
{countryOptions.map(({ label, value }) => {
|
|
50
|
+
return (
|
|
51
|
+
<SelectItem key={value} value={value}>
|
|
52
|
+
{label}
|
|
53
|
+
</SelectItem>
|
|
54
|
+
)
|
|
55
|
+
})}
|
|
56
|
+
</SelectContent>
|
|
57
|
+
</Select>
|
|
58
|
+
)
|
|
59
|
+
}}
|
|
60
|
+
rules={{ required }}
|
|
61
|
+
/>
|
|
62
|
+
{errors[name] && <Error name={name} />}
|
|
63
|
+
</Width>
|
|
64
|
+
)
|
|
65
|
+
}
|