lm-web-controls 1.5.1 → 1.5.12
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/CHANGES.md +108 -108
- package/MIGRATION.md +95 -95
- package/dist/controls/careerApplicationForm/index.js +1 -1
- package/dist/styles/style.css +3 -3
- package/package.json +53 -53
- package/readme.md +221 -221
- package/types/lm-web-controls.d.ts +592 -592
package/CHANGES.md
CHANGED
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
# Next.js Migration - Changes Summary
|
|
2
|
-
|
|
3
|
-
## Files Modified
|
|
4
|
-
|
|
5
|
-
### Components Updated with Next.js Image and Link
|
|
6
|
-
|
|
7
|
-
1. **src/controls/relatedPosts/index.tsx**
|
|
8
|
-
- Added: `import Image from "next/image"`
|
|
9
|
-
- Added: `import Link from "next/link"`
|
|
10
|
-
- Changed: `<a>` tags → `<Link>` components
|
|
11
|
-
- Changed: `<img>` tags → `<Image>` components with width={400}, height={250}
|
|
12
|
-
|
|
13
|
-
2. **src/controls/post/index.tsx**
|
|
14
|
-
- Added: `import Image from "next/image"`
|
|
15
|
-
- Added: `import Link from "next/link"`
|
|
16
|
-
- Changed: `<img>` tag → `<Image>` component with width={1200}, height={675}
|
|
17
|
-
- Changed: `<a>` tag → `<Link>` component for category link
|
|
18
|
-
|
|
19
|
-
3. **src/controls/paymentIcons/index.tsx**
|
|
20
|
-
- Added: `import Image from "next/image"`
|
|
21
|
-
- Changed: `<img>` tag → `<Image>` component with width={120}, height={40}
|
|
22
|
-
- Removed: `loading="lazy"` attribute (Next.js handles lazy loading automatically)
|
|
23
|
-
|
|
24
|
-
4. **src/controls/instaFeed/index.tsx**
|
|
25
|
-
- Added: `import Image from "next/image"`
|
|
26
|
-
- Changed: `<img>` tags → `<Image>` components with width={400}, height={400}
|
|
27
|
-
|
|
28
|
-
5. **src/controls/featuredBlog/index.tsx**
|
|
29
|
-
- Added: `import Image from "next/image"`
|
|
30
|
-
- Added: `import Link from "next/link"`
|
|
31
|
-
- Changed: `<img>` tag → `<Image>` component with width={1200}, height={675}
|
|
32
|
-
- Changed: 3 `<a>` tags → `<Link>` components (category, title, read more)
|
|
33
|
-
|
|
34
|
-
6. **src/controls/faq/index.tsx**
|
|
35
|
-
- Added: `import Image from "next/image"`
|
|
36
|
-
- Changed: `<img>` tag → `<Image>` component with width={24}, height={24} for toggle icon
|
|
37
|
-
|
|
38
|
-
7. **src/controls/blogList/index.tsx**
|
|
39
|
-
- Added: `import Image from "next/image"`
|
|
40
|
-
- Added: `import Link from "next/link"`
|
|
41
|
-
- Changed: `<img>` tags → `<Image>` components with width={600}, height={400}
|
|
42
|
-
- Changed: 3 `<a>` tags → `<Link>` components (image link, title link, read more link)
|
|
43
|
-
|
|
44
|
-
8. **src/controls/authorCard/index.tsx**
|
|
45
|
-
- Added: `import Image from "next/image"`
|
|
46
|
-
- Changed: `<img>` tag → `<Image>` component with width={80}, height={80}
|
|
47
|
-
- Note: Social links remain as `<a>` tags (external links with target="_blank")
|
|
48
|
-
|
|
49
|
-
### Components with Regular Anchor Tags (Intentionally Not Changed)
|
|
50
|
-
|
|
51
|
-
9. **src/controls/email/index.tsx**
|
|
52
|
-
- Added comment explaining mailto links should remain as regular anchor tags
|
|
53
|
-
- Uses `<a href="mailto:...">` - Not suitable for Next.js Link
|
|
54
|
-
|
|
55
|
-
10. **src/controls/copyright/index.tsx**
|
|
56
|
-
- Added comment explaining external links should remain as regular anchor tags
|
|
57
|
-
- Uses `<a href="..." target="_blank">` - External link to leadmetrics.ai
|
|
58
|
-
|
|
59
|
-
### Configuration Files
|
|
60
|
-
|
|
61
|
-
11. **package.json**
|
|
62
|
-
- Added: `"next": ">=13.0.0"` to peerDependencies
|
|
63
|
-
|
|
64
|
-
### Documentation
|
|
65
|
-
|
|
66
|
-
12. **MIGRATION.md** (New file)
|
|
67
|
-
- Comprehensive migration guide
|
|
68
|
-
- Breaking changes documentation
|
|
69
|
-
- Next.js configuration instructions
|
|
70
|
-
- Image sizing reference
|
|
71
|
-
- Benefits explanation
|
|
72
|
-
|
|
73
|
-
## Summary Statistics
|
|
74
|
-
|
|
75
|
-
- **Total components modified:** 8
|
|
76
|
-
- **Total Image imports added:** 8
|
|
77
|
-
- **Total Link imports added:** 5
|
|
78
|
-
- **Total `<img>` tags replaced:** ~10
|
|
79
|
-
- **Total `<a>` tags replaced:** ~15
|
|
80
|
-
- **Components with intentional `<a>` tags:** 3 (email, copyright, authorCard social links)
|
|
81
|
-
|
|
82
|
-
## Key Changes
|
|
83
|
-
|
|
84
|
-
### All Next.js Images Include:
|
|
85
|
-
- `width` and `height` props for proper aspect ratio
|
|
86
|
-
- `alt` attribute for accessibility
|
|
87
|
-
- Automatic lazy loading (removed manual loading="lazy")
|
|
88
|
-
|
|
89
|
-
### All Next.js Links:
|
|
90
|
-
- Use `href` prop instead of HTML href attribute
|
|
91
|
-
- Automatically prefetch for better performance
|
|
92
|
-
- Provide client-side navigation
|
|
93
|
-
|
|
94
|
-
## Testing Recommendations
|
|
95
|
-
|
|
96
|
-
1. **Visual Testing:** Verify all images render correctly with proper aspect ratios
|
|
97
|
-
2. **Navigation Testing:** Test all links to ensure proper navigation
|
|
98
|
-
3. **Performance Testing:** Check Lighthouse scores for improvements
|
|
99
|
-
4. **Responsive Testing:** Test on various screen sizes
|
|
100
|
-
5. **External Links:** Verify email and external links still work correctly
|
|
101
|
-
|
|
102
|
-
## Next Steps for Users
|
|
103
|
-
|
|
104
|
-
1. Ensure Next.js 13.0.0+ is installed
|
|
105
|
-
2. Configure image domains in next.config.js
|
|
106
|
-
3. Update CSS if needed for Next.js Image wrapper structure
|
|
107
|
-
4. Test all components in their Next.js application
|
|
108
|
-
5. Review and adjust image sizes if needed for specific use cases
|
|
1
|
+
# Next.js Migration - Changes Summary
|
|
2
|
+
|
|
3
|
+
## Files Modified
|
|
4
|
+
|
|
5
|
+
### Components Updated with Next.js Image and Link
|
|
6
|
+
|
|
7
|
+
1. **src/controls/relatedPosts/index.tsx**
|
|
8
|
+
- Added: `import Image from "next/image"`
|
|
9
|
+
- Added: `import Link from "next/link"`
|
|
10
|
+
- Changed: `<a>` tags → `<Link>` components
|
|
11
|
+
- Changed: `<img>` tags → `<Image>` components with width={400}, height={250}
|
|
12
|
+
|
|
13
|
+
2. **src/controls/post/index.tsx**
|
|
14
|
+
- Added: `import Image from "next/image"`
|
|
15
|
+
- Added: `import Link from "next/link"`
|
|
16
|
+
- Changed: `<img>` tag → `<Image>` component with width={1200}, height={675}
|
|
17
|
+
- Changed: `<a>` tag → `<Link>` component for category link
|
|
18
|
+
|
|
19
|
+
3. **src/controls/paymentIcons/index.tsx**
|
|
20
|
+
- Added: `import Image from "next/image"`
|
|
21
|
+
- Changed: `<img>` tag → `<Image>` component with width={120}, height={40}
|
|
22
|
+
- Removed: `loading="lazy"` attribute (Next.js handles lazy loading automatically)
|
|
23
|
+
|
|
24
|
+
4. **src/controls/instaFeed/index.tsx**
|
|
25
|
+
- Added: `import Image from "next/image"`
|
|
26
|
+
- Changed: `<img>` tags → `<Image>` components with width={400}, height={400}
|
|
27
|
+
|
|
28
|
+
5. **src/controls/featuredBlog/index.tsx**
|
|
29
|
+
- Added: `import Image from "next/image"`
|
|
30
|
+
- Added: `import Link from "next/link"`
|
|
31
|
+
- Changed: `<img>` tag → `<Image>` component with width={1200}, height={675}
|
|
32
|
+
- Changed: 3 `<a>` tags → `<Link>` components (category, title, read more)
|
|
33
|
+
|
|
34
|
+
6. **src/controls/faq/index.tsx**
|
|
35
|
+
- Added: `import Image from "next/image"`
|
|
36
|
+
- Changed: `<img>` tag → `<Image>` component with width={24}, height={24} for toggle icon
|
|
37
|
+
|
|
38
|
+
7. **src/controls/blogList/index.tsx**
|
|
39
|
+
- Added: `import Image from "next/image"`
|
|
40
|
+
- Added: `import Link from "next/link"`
|
|
41
|
+
- Changed: `<img>` tags → `<Image>` components with width={600}, height={400}
|
|
42
|
+
- Changed: 3 `<a>` tags → `<Link>` components (image link, title link, read more link)
|
|
43
|
+
|
|
44
|
+
8. **src/controls/authorCard/index.tsx**
|
|
45
|
+
- Added: `import Image from "next/image"`
|
|
46
|
+
- Changed: `<img>` tag → `<Image>` component with width={80}, height={80}
|
|
47
|
+
- Note: Social links remain as `<a>` tags (external links with target="_blank")
|
|
48
|
+
|
|
49
|
+
### Components with Regular Anchor Tags (Intentionally Not Changed)
|
|
50
|
+
|
|
51
|
+
9. **src/controls/email/index.tsx**
|
|
52
|
+
- Added comment explaining mailto links should remain as regular anchor tags
|
|
53
|
+
- Uses `<a href="mailto:...">` - Not suitable for Next.js Link
|
|
54
|
+
|
|
55
|
+
10. **src/controls/copyright/index.tsx**
|
|
56
|
+
- Added comment explaining external links should remain as regular anchor tags
|
|
57
|
+
- Uses `<a href="..." target="_blank">` - External link to leadmetrics.ai
|
|
58
|
+
|
|
59
|
+
### Configuration Files
|
|
60
|
+
|
|
61
|
+
11. **package.json**
|
|
62
|
+
- Added: `"next": ">=13.0.0"` to peerDependencies
|
|
63
|
+
|
|
64
|
+
### Documentation
|
|
65
|
+
|
|
66
|
+
12. **MIGRATION.md** (New file)
|
|
67
|
+
- Comprehensive migration guide
|
|
68
|
+
- Breaking changes documentation
|
|
69
|
+
- Next.js configuration instructions
|
|
70
|
+
- Image sizing reference
|
|
71
|
+
- Benefits explanation
|
|
72
|
+
|
|
73
|
+
## Summary Statistics
|
|
74
|
+
|
|
75
|
+
- **Total components modified:** 8
|
|
76
|
+
- **Total Image imports added:** 8
|
|
77
|
+
- **Total Link imports added:** 5
|
|
78
|
+
- **Total `<img>` tags replaced:** ~10
|
|
79
|
+
- **Total `<a>` tags replaced:** ~15
|
|
80
|
+
- **Components with intentional `<a>` tags:** 3 (email, copyright, authorCard social links)
|
|
81
|
+
|
|
82
|
+
## Key Changes
|
|
83
|
+
|
|
84
|
+
### All Next.js Images Include:
|
|
85
|
+
- `width` and `height` props for proper aspect ratio
|
|
86
|
+
- `alt` attribute for accessibility
|
|
87
|
+
- Automatic lazy loading (removed manual loading="lazy")
|
|
88
|
+
|
|
89
|
+
### All Next.js Links:
|
|
90
|
+
- Use `href` prop instead of HTML href attribute
|
|
91
|
+
- Automatically prefetch for better performance
|
|
92
|
+
- Provide client-side navigation
|
|
93
|
+
|
|
94
|
+
## Testing Recommendations
|
|
95
|
+
|
|
96
|
+
1. **Visual Testing:** Verify all images render correctly with proper aspect ratios
|
|
97
|
+
2. **Navigation Testing:** Test all links to ensure proper navigation
|
|
98
|
+
3. **Performance Testing:** Check Lighthouse scores for improvements
|
|
99
|
+
4. **Responsive Testing:** Test on various screen sizes
|
|
100
|
+
5. **External Links:** Verify email and external links still work correctly
|
|
101
|
+
|
|
102
|
+
## Next Steps for Users
|
|
103
|
+
|
|
104
|
+
1. Ensure Next.js 13.0.0+ is installed
|
|
105
|
+
2. Configure image domains in next.config.js
|
|
106
|
+
3. Update CSS if needed for Next.js Image wrapper structure
|
|
107
|
+
4. Test all components in their Next.js application
|
|
108
|
+
5. Review and adjust image sizes if needed for specific use cases
|
package/MIGRATION.md
CHANGED
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
# Migration Guide - Next.js Image and Link Components
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
This package has been updated to use Next.js `Image` and `Link` components instead of standard HTML `<img>` and `<a>` tags for better performance and SEO in Next.js projects.
|
|
5
|
-
|
|
6
|
-
## Breaking Changes
|
|
7
|
-
|
|
8
|
-
### Requirements
|
|
9
|
-
- **Next.js 13.0.0 or higher** is now required
|
|
10
|
-
- This package is now specifically designed for Next.js projects
|
|
11
|
-
|
|
12
|
-
### Components Updated
|
|
13
|
-
|
|
14
|
-
The following components now use Next.js Image and Link:
|
|
15
|
-
|
|
16
|
-
1. **RelatedPosts** - Uses `Image` and `Link`
|
|
17
|
-
2. **Post** - Uses `Image` and `Link`
|
|
18
|
-
3. **PaymentIcons** - Uses `Image` for custom payment icons
|
|
19
|
-
4. **InstaFeed** - Uses `Image`
|
|
20
|
-
5. **FeaturedBlog** - Uses `Image` and `Link`
|
|
21
|
-
6. **FAQ** - Uses `Image` for toggle icons
|
|
22
|
-
7. **BlogList** - Uses `Image` and `Link`
|
|
23
|
-
8. **AuthorCard** - Uses `Image`
|
|
24
|
-
|
|
25
|
-
### Components with Regular Anchor Tags
|
|
26
|
-
|
|
27
|
-
The following components still use regular `<a>` tags for specific reasons:
|
|
28
|
-
|
|
29
|
-
1. **Email** - Uses `<a>` with `mailto:` protocol (not suitable for Next.js Link)
|
|
30
|
-
2. **Copyright** - Uses `<a>` for external link with `target="_blank"`
|
|
31
|
-
3. **AuthorCard** - Uses `<a>` for social links with `target="_blank"` and `rel="noopener noreferrer"`
|
|
32
|
-
|
|
33
|
-
## Next.js Configuration
|
|
34
|
-
|
|
35
|
-
### Image Domains
|
|
36
|
-
If you're using external images, you need to configure Next.js to allow those domains in your `next.config.js`:
|
|
37
|
-
|
|
38
|
-
```javascript
|
|
39
|
-
/** @type {import('next').NextConfig} */
|
|
40
|
-
const nextConfig = {
|
|
41
|
-
images: {
|
|
42
|
-
remotePatterns: [
|
|
43
|
-
{
|
|
44
|
-
protocol: 'https',
|
|
45
|
-
hostname: 'your-image-domain.com',
|
|
46
|
-
},
|
|
47
|
-
// Add other domains as needed
|
|
48
|
-
],
|
|
49
|
-
},
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
module.exports = nextConfig
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### Image Sizing
|
|
56
|
-
All images now include default width and height attributes:
|
|
57
|
-
- **Featured images**: 1200x675 (16:9 aspect ratio)
|
|
58
|
-
- **Blog list images**: 600x400
|
|
59
|
-
- **Related post images**: 400x250
|
|
60
|
-
- **Instagram feed images**: 400x400 (square)
|
|
61
|
-
- **Payment icons**: 120x40
|
|
62
|
-
- **FAQ icons**: 24x24
|
|
63
|
-
- **Author avatars**: 80x80
|
|
64
|
-
|
|
65
|
-
Images use `style={{ width: '100%', height: 'auto' }}` or `style={{ width: 'auto', height: '100%' }}` to maintain aspect ratios while being responsive.
|
|
66
|
-
|
|
67
|
-
## CSS Considerations
|
|
68
|
-
|
|
69
|
-
The switch from `<img>` to Next.js `Image` component means:
|
|
70
|
-
- Images are wrapped in a `<span>` container by default
|
|
71
|
-
- Inline styles are applied via the `style` prop
|
|
72
|
-
- CSS classes work the same way via the `className` prop
|
|
73
|
-
|
|
74
|
-
If you have specific CSS targeting images, you may need to adjust selectors to account for Next.js Image's wrapper structure.
|
|
75
|
-
|
|
76
|
-
## Benefits
|
|
77
|
-
|
|
78
|
-
### Performance Improvements
|
|
79
|
-
- **Automatic image optimization** - Images are automatically optimized and served in modern formats (WebP, AVIF)
|
|
80
|
-
- **Lazy loading** - Images load only when they enter the viewport
|
|
81
|
-
- **Responsive images** - Automatic srcset generation for different screen sizes
|
|
82
|
-
- **Placeholder support** - Can add blur placeholders while images load
|
|
83
|
-
|
|
84
|
-
### SEO Improvements
|
|
85
|
-
- **Client-side navigation** - Link component provides faster navigation without full page reloads
|
|
86
|
-
- **Prefetching** - Links are automatically prefetched for faster page transitions
|
|
87
|
-
- **Better Core Web Vitals** - Optimized images improve LCP and CLS scores
|
|
88
|
-
|
|
89
|
-
## TypeScript
|
|
90
|
-
|
|
91
|
-
Next.js types are included as peer dependencies. The package expects Next.js to be installed in your project.
|
|
92
|
-
|
|
93
|
-
## Questions or Issues?
|
|
94
|
-
|
|
95
|
-
If you encounter any issues during migration, please open an issue on the repository with details about your setup and the specific problem you're facing.
|
|
1
|
+
# Migration Guide - Next.js Image and Link Components
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
This package has been updated to use Next.js `Image` and `Link` components instead of standard HTML `<img>` and `<a>` tags for better performance and SEO in Next.js projects.
|
|
5
|
+
|
|
6
|
+
## Breaking Changes
|
|
7
|
+
|
|
8
|
+
### Requirements
|
|
9
|
+
- **Next.js 13.0.0 or higher** is now required
|
|
10
|
+
- This package is now specifically designed for Next.js projects
|
|
11
|
+
|
|
12
|
+
### Components Updated
|
|
13
|
+
|
|
14
|
+
The following components now use Next.js Image and Link:
|
|
15
|
+
|
|
16
|
+
1. **RelatedPosts** - Uses `Image` and `Link`
|
|
17
|
+
2. **Post** - Uses `Image` and `Link`
|
|
18
|
+
3. **PaymentIcons** - Uses `Image` for custom payment icons
|
|
19
|
+
4. **InstaFeed** - Uses `Image`
|
|
20
|
+
5. **FeaturedBlog** - Uses `Image` and `Link`
|
|
21
|
+
6. **FAQ** - Uses `Image` for toggle icons
|
|
22
|
+
7. **BlogList** - Uses `Image` and `Link`
|
|
23
|
+
8. **AuthorCard** - Uses `Image`
|
|
24
|
+
|
|
25
|
+
### Components with Regular Anchor Tags
|
|
26
|
+
|
|
27
|
+
The following components still use regular `<a>` tags for specific reasons:
|
|
28
|
+
|
|
29
|
+
1. **Email** - Uses `<a>` with `mailto:` protocol (not suitable for Next.js Link)
|
|
30
|
+
2. **Copyright** - Uses `<a>` for external link with `target="_blank"`
|
|
31
|
+
3. **AuthorCard** - Uses `<a>` for social links with `target="_blank"` and `rel="noopener noreferrer"`
|
|
32
|
+
|
|
33
|
+
## Next.js Configuration
|
|
34
|
+
|
|
35
|
+
### Image Domains
|
|
36
|
+
If you're using external images, you need to configure Next.js to allow those domains in your `next.config.js`:
|
|
37
|
+
|
|
38
|
+
```javascript
|
|
39
|
+
/** @type {import('next').NextConfig} */
|
|
40
|
+
const nextConfig = {
|
|
41
|
+
images: {
|
|
42
|
+
remotePatterns: [
|
|
43
|
+
{
|
|
44
|
+
protocol: 'https',
|
|
45
|
+
hostname: 'your-image-domain.com',
|
|
46
|
+
},
|
|
47
|
+
// Add other domains as needed
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
module.exports = nextConfig
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Image Sizing
|
|
56
|
+
All images now include default width and height attributes:
|
|
57
|
+
- **Featured images**: 1200x675 (16:9 aspect ratio)
|
|
58
|
+
- **Blog list images**: 600x400
|
|
59
|
+
- **Related post images**: 400x250
|
|
60
|
+
- **Instagram feed images**: 400x400 (square)
|
|
61
|
+
- **Payment icons**: 120x40
|
|
62
|
+
- **FAQ icons**: 24x24
|
|
63
|
+
- **Author avatars**: 80x80
|
|
64
|
+
|
|
65
|
+
Images use `style={{ width: '100%', height: 'auto' }}` or `style={{ width: 'auto', height: '100%' }}` to maintain aspect ratios while being responsive.
|
|
66
|
+
|
|
67
|
+
## CSS Considerations
|
|
68
|
+
|
|
69
|
+
The switch from `<img>` to Next.js `Image` component means:
|
|
70
|
+
- Images are wrapped in a `<span>` container by default
|
|
71
|
+
- Inline styles are applied via the `style` prop
|
|
72
|
+
- CSS classes work the same way via the `className` prop
|
|
73
|
+
|
|
74
|
+
If you have specific CSS targeting images, you may need to adjust selectors to account for Next.js Image's wrapper structure.
|
|
75
|
+
|
|
76
|
+
## Benefits
|
|
77
|
+
|
|
78
|
+
### Performance Improvements
|
|
79
|
+
- **Automatic image optimization** - Images are automatically optimized and served in modern formats (WebP, AVIF)
|
|
80
|
+
- **Lazy loading** - Images load only when they enter the viewport
|
|
81
|
+
- **Responsive images** - Automatic srcset generation for different screen sizes
|
|
82
|
+
- **Placeholder support** - Can add blur placeholders while images load
|
|
83
|
+
|
|
84
|
+
### SEO Improvements
|
|
85
|
+
- **Client-side navigation** - Link component provides faster navigation without full page reloads
|
|
86
|
+
- **Prefetching** - Links are automatically prefetched for faster page transitions
|
|
87
|
+
- **Better Core Web Vitals** - Optimized images improve LCP and CLS scores
|
|
88
|
+
|
|
89
|
+
## TypeScript
|
|
90
|
+
|
|
91
|
+
Next.js types are included as peer dependencies. The package expects Next.js to be installed in your project.
|
|
92
|
+
|
|
93
|
+
## Questions or Issues?
|
|
94
|
+
|
|
95
|
+
If you encounter any issues during migration, please open an issue on the repository with details about your setup and the specific problem you're facing.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{__awaiter as e,__generator as r,__assign as n}from"../../_virtual/_tslib.js";import a,{useState as t,useEffect as l}from"react";import{Formik as i,Form as o,ErrorMessage as c}from"formik";import*as m from"yup";import{toast as s}from"react-toastify";import u from"react-phone-input-2";var p=function(e){return e.replace(/<script.*?>[\s\S]*?<\/script>/gi,"").replace(/<[^>]*>/g,"").replace(/[\u202E\u202D]/g,"").replace(/[^A-Za-z0-9\s'.-]/g,"").replace(/\s+/g," ").trim()},d=function(e){return e.replace(/<script.*?>[\s\S]*?<\/script>/gi,"").replace(/<[^>]*>/g,"").replace(/["'<>]/g,"").trim()},v=/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/,g=/^[\+]?[0-9]{7,15}$/,E=function(e){return void 0===e&&(e=[]),m.object().shape({name:m.string().required("Please enter your name").min(3,"Name must be at least 3 characters"),email:m.string().required("Please enter your email").email("Please enter a valid email").matches(v,"Please enter a valid email"),mobile:m.string().required("Please enter your mobile number").min(7,"Phone number must be at least 7 digits").max(16,"Phone number cannot exceed 15 digits").matches(g,"Please enter a valid phone number (only digits and optional + prefix)"),resume:m.mixed().required("Please upload your resume").test("fileSize","File size should be less than 5MB",function(e){return!e||e.size<=5242880}).test("fileType","Only PDF, DOC, and DOCX files are allowed",function(e){return!e||["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"].includes(e.type)}),experience:m.number().nullable().transform(function(e,r){return""===String(r).trim()?null:e}).typeError("Experience must be a number"),currency:m.string().required("Please select a currency"),currentSalary:m.number().nullable().transform(function(e,r){return""===String(r).trim()?null:e}).typeError("Current Salary must be a number"),expectedSalary:m.number().nullable().transform(function(e,r){return""===String(r).trim()?null:e}).typeError("Expected Salary must be a number"),noticePeriod:m.number().nullable().transform(function(e,r){return""===String(r).trim()?null:e}).typeError("Notice Period must be a number"),nationality:m.string().when([],{is:function(){return e.includes("nationality")},then:function(e){return e.required("Please enter your nationality")},otherwise:function(e){return e.nullable()}}),coverLetter:m.string().nullable(),linkedInUrl:m.string().url("Please enter a valid URL").nullable(),photo:m.mixed().nullable().test("fileSize","File size should be less than 5MB",function(e){return!e||e.size<=5242880}).test("fileType","Only JPG, JPEG, and PNG files are allowed",function(e){return!e||["image/jpeg","image/png","image/jpg"].includes(e.type)}),relevantExperience:m.number().nullable().transform(function(e,r){return""===String(r).trim()?null:e}).typeError("Relevant Experience must be a number"),currentLocation:m.string().nullable(),reasonForLeaving:m.string().nullable(),highestEducation:m.string().nullable(),dateOfBirth:m.string().nullable(),currentCompany:m.string().nullable(),companyUrl:m.string().url("Please enter a valid URL").nullable(),consent:m.boolean().nullable()})};function f(m){var v=this,g=m.closeIcon,f=m.jobId,h=m.jobTitle,y=m.primaryColor,b=m.onSubmit,N=m.title,C=m.description,S=m.triggerAttribute,x=void 0===S?"data-career-apply":S,L=m.classNames,B=void 0===L?{}:L,P=m.placeholders,D=void 0===P?{}:P,U=m.visibleFields,M=void 0===U?[]:U,w=m.consentText,F=t(!1),R=F[0],k=F[1],A=t(""),I=A[0],O=A[1],K=t(""),z=K[0],j=K[1],G=function(e,r){return r||e};l(function(){var e=function(e){e.target.closest("[".concat(x,"]"))&&(e.preventDefault(),e.stopPropagation(),k(!0))};return document.addEventListener("click",e),function(){document.removeEventListener("click",e)}},[x]);var $=function(e,r,n,a){var t,l=null===(t=e.target.files)||void 0===t?void 0:t[0];l&&(r(n,l),a(l.name.replace(/<[^>]*>/g,"").replace(/["'\\]/g,"").trim()))};if(!R)return null;var T=y?{"--job-detail-primary":y}:void 0;return a.createElement("div",{className:G("career-modal-wrapper",B.modal)},a.createElement("div",{className:G("career-modal-container",B.container),style:T},a.createElement("button",{className:G("career-modal-close-button",B.closeButton),onClick:function(){k(!1),O(""),j("")},title:"Close"},g),a.createElement("div",{className:"career-modal-scroll-content"},a.createElement("h2",{className:G("career-modal-title",B.title)},N||(h?"Apply for ".concat(h):"Submit Your Application")),C&&a.createElement("p",{className:G("career-modal-description",B.description)},C),a.createElement("div",{className:"career-modal-form-wrapper"},a.createElement(i,{validationSchema:E(M),onSubmit:function(a,t){return e(v,[a,t],void 0,function(e,a){var t,l,i,o,c,m,u,v,g,E,y,N,C=a.setSubmitting,S=a.resetForm;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,3,4]),t=p(e.name),a=e.email,l=a.replace(/[^A-Za-z0-9@._+-]/g,"").replace(/\s+/g,"").trim(),i=function(e){return e.replace(/[^0-9+]/g,"").replace(/\s+/g,"").trim()}(e.mobile),o=e.nationality?p(e.nationality):"",c=e.coverLetter?function(e){return e.replace(/<script.*?>[\s\S]*?<\/script>/gi,"").replace(/<[^>]*>/g,"").trim()}(e.coverLetter):"",m=e.linkedInUrl?d(e.linkedInUrl):"",u=e.currentLocation?p(e.currentLocation):"",v=e.reasonForLeaving?p(e.reasonForLeaving):"",g=e.highestEducation?p(e.highestEducation):"",E=e.dateOfBirth?p(e.dateOfBirth):"",y=e.currentCompany?p(e.currentCompany):"",N=e.companyUrl?d(e.companyUrl):"","undefined"!=typeof window&&window.dataLayer&&window.dataLayer.push(n(n({event:f?"career_application_submit":"candidate_application_submit"},f&&{jobId:f,jobTitle:h||"Unknown Position"}),{applicantName:t})),[4,b(n(n({},f&&{jobId:f}),{name:t,email:l,mobile:i,resume:e.resume,experience:e.experience,currency:e.currency,currentSalary:e.currentSalary,expectedSalary:e.expectedSalary,noticePeriod:e.noticePeriod,nationality:o,coverLetter:c,photo:e.photo,linkedInUrl:m,relevantExperience:e.relevantExperience,currentLocation:u,reasonForLeaving:v,highestEducation:g,dateOfBirth:E,currentCompany:y,companyUrl:N,consent:e.consent}))];case 1:return r.sent(),s.success("Application submitted successfully!"),S(),O(""),j(""),k(!1),[3,4];case 2:return r.sent(),s.error("Failed to submit application. Please try again."),[3,4];case 3:return C(!1),[7];case 4:return[2]}var a})})},initialValues:{name:"",email:"",mobile:"",resume:null,experience:null,currency:"",currentSalary:null,expectedSalary:null,noticePeriod:null,nationality:"",coverLetter:"",photo:null,linkedInUrl:"",relevantExperience:null,currentLocation:"",reasonForLeaving:"",highestEducation:"",dateOfBirth:"",currentCompany:"",companyUrl:"",consent:!1}},function(e){var r,n,t,l,i,m=e.handleSubmit,s=e.handleChange,p=e.handleBlur,d=e.setFieldValue,v=e.values,g=e.isSubmitting;return a.createElement(o,{className:G("career-modal-form",B.form),noValidate:!0,onSubmit:m},a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.name||"Full Name*",name:"name",onChange:s,onBlur:p,value:v.name}),a.createElement(c,{name:"name",component:"div",className:G("career-form-error-message",B.errorMessage)})),a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.email||"Email*",name:"email",type:"email",onChange:s,onBlur:p,value:v.email}),a.createElement(c,{name:"email",component:"div",className:G("career-form-error-message",B.errorMessage)})),a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement(u,{country:"ae",placeholder:D.mobile||"Mobile Number*",value:v.mobile,onChange:function(e){return d("mobile","+"+e)},onBlur:p,inputProps:{name:"mobile"},containerClass:G("career-form-input career-phone-input",B.input),inputClass:"career-phone-input-field",buttonClass:"career-phone-input-button",dropdownClass:"career-phone-input-dropdown"}),a.createElement(c,{name:"mobile",component:"div",className:G("career-form-error-message",B.errorMessage)})),a.createElement("div",{className:G("career-optional-fields-grid",B.optionalFieldsGrid)},M.includes("experience")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.experience||"Experience (Years)",name:"experience",type:"number",onChange:s,onBlur:p,value:null!==(r=v.experience)&&void 0!==r?r:""}),a.createElement(c,{name:"experience",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("currency")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("select",{className:G("career-form-input",B.input),name:"currency",onChange:s,onBlur:p,value:v.currency},a.createElement("option",{value:""},D.currency||"Select Currency*"),a.createElement("option",{value:"USD"},"USD - $ (US Dollar)"),a.createElement("option",{value:"EUR"},"EUR - € (Euro)"),a.createElement("option",{value:"INR"},"INR - ₹ (Indian Rupee)"),a.createElement("option",{value:"AED"},"AED - د.إ (UAE Dirham)"),a.createElement("option",{value:"SAR"},"SAR - ﷼ (Saudi Riyal)"),a.createElement("option",{value:"GBP"},"GBP - £ (British Pound)"),a.createElement("option",{value:"JPY"},"JPY - ¥ (Japanese Yen)"),a.createElement("option",{value:"AUD"},"AUD - A$ (Australian Dollar)"),a.createElement("option",{value:"CAD"},"CAD - C$ (Canadian Dollar)"),a.createElement("option",{value:"CHF"},"CHF - Fr (Swiss Franc)"),a.createElement("option",{value:"CNY"},"CNY - ¥ (Chinese Yuan)"),a.createElement("option",{value:"SGD"},"SGD - S$ (Singapore Dollar)"),a.createElement("option",{value:"HKD"},"HKD - HK$ (Hong Kong Dollar)"),a.createElement("option",{value:"NZD"},"NZD - NZ$ (New Zealand Dollar)"),a.createElement("option",{value:"SEK"},"SEK - kr (Swedish Krona)"),a.createElement("option",{value:"NOK"},"NOK - kr (Norwegian Krone)"),a.createElement("option",{value:"DKK"},"DKK - kr (Danish Krone)"),a.createElement("option",{value:"ZAR"},"ZAR - R (South African Rand)"),a.createElement("option",{value:"BRL"},"BRL - R$ (Brazilian Real)"),a.createElement("option",{value:"MXN"},"MXN - $ (Mexican Peso)")),a.createElement(c,{name:"currency",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("currentSalary")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.currentSalary||"Current Salary (e.g. 50000)",name:"currentSalary",type:"number",onChange:s,onBlur:p,value:null!==(n=v.currentSalary)&&void 0!==n?n:""}),a.createElement(c,{name:"currentSalary",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("expectedSalary")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.expectedSalary||"Expected Salary (e.g. 60000)",name:"expectedSalary",type:"number",onChange:s,onBlur:p,value:null!==(t=v.expectedSalary)&&void 0!==t?t:""}),a.createElement(c,{name:"expectedSalary",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("noticePeriod")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.noticePeriod||"Notice Period (Months)",name:"noticePeriod",type:"number",onChange:s,onBlur:p,value:null!==(l=v.noticePeriod)&&void 0!==l?l:""}),a.createElement(c,{name:"noticePeriod",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("nationality")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.nationality||"Nationality*",name:"nationality",onChange:s,onBlur:p,value:v.nationality}),a.createElement(c,{name:"nationality",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("linkedInUrl")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.linkedInUrl||"LinkedIn URL",name:"linkedInUrl",type:"url",onChange:s,onBlur:p,value:v.linkedInUrl}),a.createElement(c,{name:"linkedInUrl",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("relevantExperience")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.relevantExperience||"Relevant Experience (Years)",name:"relevantExperience",type:"number",onChange:s,onBlur:p,value:null!==(i=v.relevantExperience)&&void 0!==i?i:""}),a.createElement(c,{name:"relevantExperience",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("currentLocation")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.currentLocation||"Current Location",name:"currentLocation",onChange:s,onBlur:p,value:v.currentLocation}),a.createElement(c,{name:"currentLocation",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("reasonForLeaving")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.reasonForLeaving||"Reason for Leaving",name:"reasonForLeaving",onChange:s,onBlur:p,value:v.reasonForLeaving}),a.createElement(c,{name:"reasonForLeaving",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("highestEducation")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.highestEducation||"Highest Education",name:"highestEducation",onChange:s,onBlur:p,value:v.highestEducation}),a.createElement(c,{name:"highestEducation",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("dateOfBirth")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.dateOfBirth||"Date of Birth",name:"dateOfBirth",type:"date",onChange:s,onBlur:p,value:v.dateOfBirth}),a.createElement(c,{name:"dateOfBirth",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("currentCompany")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.currentCompany||"Current Company Name",name:"currentCompany",onChange:s,onBlur:p,value:v.currentCompany}),a.createElement(c,{name:"currentCompany",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("companyUrl")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.companyUrl||"Company Website",name:"companyUrl",type:"url",onChange:s,onBlur:p,value:v.companyUrl}),a.createElement(c,{name:"companyUrl",component:"div",className:G("career-form-error-message",B.errorMessage)}))),M.includes("coverLetter")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("textarea",{className:G("career-form-textarea",B.textarea),placeholder:D.coverLetter||"Cover Letter",name:"coverLetter",onChange:s,onBlur:p,value:v.coverLetter,rows:4}),a.createElement(c,{name:"coverLetter",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("photo")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("label",{className:G("career-file-label",B.fileLabel)},a.createElement("input",{type:"file",name:"photo",accept:".jpg,.jpeg,.png",onChange:function(e){return $(e,d,"photo",j)},onBlur:p,className:G("career-file-input",B.fileInput)}),a.createElement("span",{className:"career-file-button"},z||D.photo||"Upload Photo (JPG, PNG)")),z&&a.createElement("div",{style:{marginTop:"0.5rem",fontSize:"0.875rem",color:"#4b5563"}},"Selected: ",z),a.createElement(c,{name:"photo",component:"div",className:G("career-form-error-message",B.errorMessage)})),a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("label",{className:G("career-file-label",B.fileLabel)},a.createElement("input",{type:"file",name:"resume",accept:".pdf,.doc,.docx",onChange:function(e){return $(e,d,"resume",O)},onBlur:p,className:G("career-file-input",B.fileInput)}),a.createElement("span",{className:"career-file-button"},I||D.resume||"Upload Resume (PDF, DOC, DOCX)*")),I&&a.createElement("div",{style:{marginTop:"0.5rem",fontSize:"0.875rem",color:"#4b5563"}},"Selected: ",I),a.createElement("div",{style:{marginTop:"0.5rem",fontSize:"0.75rem",color:"#6b7280",lineHeight:"1.4"}},a.createElement("div",null,"• Accepted formats: PDF, DOC, DOCX"),a.createElement("div",null,"• Maximum file size: 5 MB")),a.createElement(c,{name:"resume",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("consent")&&w&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.5rem",fontSize:"0.875rem",color:"#374151",cursor:"pointer"}},a.createElement("input",{type:"checkbox",name:"consent",checked:v.consent,onChange:function(e){return d("consent",e.target.checked)},onBlur:p,style:{marginTop:"0.125rem",width:"1rem",height:"1rem"}}),a.createElement("span",null,w)),a.createElement(c,{name:"consent",component:"div",className:G("career-form-error-message",B.errorMessage)})),a.createElement("div",{className:"career-form-button-container"},a.createElement("button",{className:G("career-form-submit-button",B.submitButton),type:"submit",disabled:g},g?"Submitting...":"Submit Application")))})))))}export{f as CareerApplicationForm};
|
|
2
|
+
import{__awaiter as e,__generator as r,__assign as n}from"../../_virtual/_tslib.js";import a,{useState as t,useEffect as l}from"react";import{Formik as i,Form as o,ErrorMessage as c}from"formik";import*as m from"yup";import{toast as s}from"react-toastify";import u from"react-phone-input-2";var p=function(e){return e.replace(/<script.*?>[\s\S]*?<\/script>/gi,"").replace(/<[^>]*>/g,"").replace(/[\u202E\u202D]/g,"").replace(/[^A-Za-z0-9\s'.-]/g,"").replace(/\s+/g," ").trim()},d=function(e){return e.replace(/<script.*?>[\s\S]*?<\/script>/gi,"").replace(/<[^>]*>/g,"").replace(/["'<>]/g,"").trim()},v=/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/,g=/^[\+]?[0-9]{7,15}$/,E=function(e){return void 0===e&&(e=[]),m.object().shape({name:m.string().required("Please enter your name").min(3,"Name must be at least 3 characters"),email:m.string().required("Please enter your email").email("Please enter a valid email").matches(v,"Please enter a valid email"),mobile:m.string().required("Please enter your mobile number").min(7,"Phone number must be at least 7 digits").max(16,"Phone number cannot exceed 15 digits").matches(g,"Please enter a valid phone number (only digits and optional + prefix)"),resume:m.mixed().required("Please upload your resume").test("fileSize","File size should be less than 5MB",function(e){return!e||e.size<=5242880}).test("fileType","Only PDF, DOC, and DOCX files are allowed",function(e){return!e||["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"].includes(e.type)}),experience:m.number().nullable().transform(function(e,r){return""===String(r).trim()?null:e}).typeError("Experience must be a number"),currency:m.string().required("Please select a currency"),currentSalary:m.number().nullable().transform(function(e,r){return""===String(r).trim()?null:e}).typeError("Current Salary must be a number"),expectedSalary:m.number().nullable().transform(function(e,r){return""===String(r).trim()?null:e}).typeError("Expected Salary must be a number"),noticePeriod:m.number().nullable().transform(function(e,r){return""===String(r).trim()?null:e}).typeError("Notice Period must be a number"),nationality:m.string().when([],{is:function(){return e.includes("nationality")},then:function(e){return e.required("Please enter your nationality")},otherwise:function(e){return e.nullable()}}),coverLetter:m.string().nullable(),linkedInUrl:m.string().url("Please enter a valid URL").nullable(),photo:m.mixed().nullable().test("fileSize","File size should be less than 5MB",function(e){return!e||e.size<=5242880}).test("fileType","Only JPG, JPEG, and PNG files are allowed",function(e){return!e||["image/jpeg","image/png","image/jpg"].includes(e.type)}),relevantExperience:m.number().nullable().transform(function(e,r){return""===String(r).trim()?null:e}).typeError("Relevant Experience must be a number"),currentLocation:m.string().nullable(),reasonForLeaving:m.string().nullable(),highestEducation:m.string().nullable(),dateOfBirth:m.string().nullable(),currentCompany:m.string().nullable(),companyUrl:m.string().url("Please enter a valid URL").nullable(),consent:m.boolean().nullable()})};function f(m){var v=this,g=m.closeIcon,f=m.jobId,h=m.jobTitle,y=m.primaryColor,b=m.onSubmit,N=m.title,C=m.description,S=m.triggerAttribute,x=void 0===S?"data-career-apply":S,L=m.classNames,B=void 0===L?{}:L,P=m.placeholders,D=void 0===P?{}:P,U=m.visibleFields,M=void 0===U?[]:U,w=m.consentText,F=t(!1),k=F[0],R=F[1],A=t(""),I=A[0],O=A[1],K=t(""),j=K[0],z=K[1],G=function(e,r){return r||e};l(function(){var e=function(e){e.target.closest("[".concat(x,"]"))&&(e.preventDefault(),e.stopPropagation(),R(!0))};return document.addEventListener("click",e),function(){document.removeEventListener("click",e)}},[x]);var $=function(e,r,n,a){var t,l=null===(t=e.target.files)||void 0===t?void 0:t[0];l&&(r(n,l),a(l.name.replace(/<[^>]*>/g,"").replace(/["'\\]/g,"").trim()))};if(!k)return null;var Y=y?{"--job-detail-primary":y}:void 0;return a.createElement("div",{className:G("career-modal-wrapper",B.modal)},a.createElement("div",{className:G("career-modal-container",B.container),style:Y},a.createElement("button",{className:G("career-modal-close-button",B.closeButton),onClick:function(){R(!1),O(""),z("")},title:"Close"},g),a.createElement("div",{className:"career-modal-scroll-content"},a.createElement("h2",{className:G("career-modal-title",B.title)},N||(h?"Apply for ".concat(h):"Submit Your Application")),C&&a.createElement("p",{className:G("career-modal-description",B.description)},C),a.createElement("div",{className:"career-modal-form-wrapper"},a.createElement(i,{validationSchema:E(M),onSubmit:function(a,t){return e(v,[a,t],void 0,function(e,a){var t,l,i,o,c,m,u,v,g,E,y,N,C=a.setSubmitting,S=a.resetForm;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,3,4]),t=p(e.name),a=e.email,l=a.replace(/[^A-Za-z0-9@._+-]/g,"").replace(/\s+/g,"").trim(),i=function(e){return e.replace(/[^0-9+]/g,"").replace(/\s+/g,"").trim()}(e.mobile),o=e.nationality?p(e.nationality):"",c=e.coverLetter?function(e){return e.replace(/<script.*?>[\s\S]*?<\/script>/gi,"").replace(/<[^>]*>/g,"").trim()}(e.coverLetter):"",m=e.linkedInUrl?d(e.linkedInUrl):"",u=e.currentLocation?p(e.currentLocation):"",v=e.reasonForLeaving?p(e.reasonForLeaving):"",g=e.highestEducation?p(e.highestEducation):"",E=e.dateOfBirth?p(e.dateOfBirth):"",y=e.currentCompany?p(e.currentCompany):"",N=e.companyUrl?d(e.companyUrl):"","undefined"!=typeof window&&window.dataLayer&&window.dataLayer.push(n(n({event:f?"career_application_submit":"candidate_application_submit"},f&&{jobId:f,jobTitle:h||"Unknown Position"}),{applicantName:t})),[4,b(n(n({},f&&{jobId:f}),{name:t,email:l,mobile:i,resume:e.resume,experience:e.experience,currency:e.currency,currentSalary:e.currentSalary,expectedSalary:e.expectedSalary,noticePeriod:e.noticePeriod,nationality:o,coverLetter:c,photo:e.photo,linkedInUrl:m,relevantExperience:e.relevantExperience,currentLocation:u,reasonForLeaving:v,highestEducation:g,dateOfBirth:E,currentCompany:y,companyUrl:N,consent:e.consent}))];case 1:return r.sent(),s.success("Application submitted successfully!"),S(),O(""),z(""),R(!1),[3,4];case 2:return r.sent(),s.error("Failed to submit application. Please try again."),[3,4];case 3:return C(!1),[7];case 4:return[2]}var a})})},initialValues:{name:"",email:"",mobile:"",resume:null,experience:null,currency:"",currentSalary:null,expectedSalary:null,noticePeriod:null,nationality:"",coverLetter:"",photo:null,linkedInUrl:"",relevantExperience:null,currentLocation:"",reasonForLeaving:"",highestEducation:"",dateOfBirth:"",currentCompany:"",companyUrl:"",consent:!1}},function(e){var r,n,t,l,i,m=e.handleSubmit,s=e.handleChange,p=e.handleBlur,d=e.setFieldValue,v=e.values,g=e.isSubmitting;return a.createElement(o,{className:G("career-modal-form",B.form),noValidate:!0,onSubmit:m},a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.name||"Full Name*",name:"name",onChange:s,onBlur:p,value:v.name}),a.createElement(c,{name:"name",component:"div",className:G("career-form-error-message",B.errorMessage)})),a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.email||"Email*",name:"email",type:"email",onChange:s,onBlur:p,value:v.email}),a.createElement(c,{name:"email",component:"div",className:G("career-form-error-message",B.errorMessage)})),a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement(u,{country:"ae",placeholder:D.mobile||"Mobile Number*",value:v.mobile,onChange:function(e){return d("mobile","+"+e)},onBlur:p,inputProps:{name:"mobile"},containerClass:G("career-form-input career-phone-input",B.input),inputClass:"career-phone-input-field",buttonClass:"career-phone-input-button",dropdownClass:"career-phone-input-dropdown"}),a.createElement(c,{name:"mobile",component:"div",className:G("career-form-error-message",B.errorMessage)})),a.createElement("div",{className:G("career-optional-fields-grid",B.optionalFieldsGrid)},M.includes("experience")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.experience||"Experience (Years)",name:"experience",type:"number",onChange:s,onBlur:p,value:null!==(r=v.experience)&&void 0!==r?r:""}),a.createElement(c,{name:"experience",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("currency")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("select",{className:G("career-form-input",B.input),name:"currency",onChange:s,onBlur:p,value:v.currency},a.createElement("option",{value:""},D.currency||"Select Currency*"),a.createElement("option",{value:"USD"},"USD - $ (US Dollar)"),a.createElement("option",{value:"EUR"},"EUR - € (Euro)"),a.createElement("option",{value:"INR"},"INR - ₹ (Indian Rupee)"),a.createElement("option",{value:"AED"},"AED - د.إ (UAE Dirham)"),a.createElement("option",{value:"SAR"},"SAR - ﷼ (Saudi Riyal)"),a.createElement("option",{value:"GBP"},"GBP - £ (British Pound)"),a.createElement("option",{value:"JPY"},"JPY - ¥ (Japanese Yen)"),a.createElement("option",{value:"AUD"},"AUD - A$ (Australian Dollar)"),a.createElement("option",{value:"CAD"},"CAD - C$ (Canadian Dollar)"),a.createElement("option",{value:"CHF"},"CHF - Fr (Swiss Franc)"),a.createElement("option",{value:"CNY"},"CNY - ¥ (Chinese Yuan)"),a.createElement("option",{value:"SGD"},"SGD - S$ (Singapore Dollar)"),a.createElement("option",{value:"HKD"},"HKD - HK$ (Hong Kong Dollar)"),a.createElement("option",{value:"NZD"},"NZD - NZ$ (New Zealand Dollar)"),a.createElement("option",{value:"SEK"},"SEK - kr (Swedish Krona)"),a.createElement("option",{value:"NOK"},"NOK - kr (Norwegian Krone)"),a.createElement("option",{value:"DKK"},"DKK - kr (Danish Krone)"),a.createElement("option",{value:"ZAR"},"ZAR - R (South African Rand)"),a.createElement("option",{value:"BRL"},"BRL - R$ (Brazilian Real)"),a.createElement("option",{value:"MXN"},"MXN - $ (Mexican Peso)")),a.createElement(c,{name:"currency",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("currentSalary")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.currentSalary||"Current Salary (e.g. 50000)",name:"currentSalary",type:"number",onChange:s,onBlur:p,value:null!==(n=v.currentSalary)&&void 0!==n?n:""}),a.createElement(c,{name:"currentSalary",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("expectedSalary")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.expectedSalary||"Expected Salary (e.g. 60000)",name:"expectedSalary",type:"number",onChange:s,onBlur:p,value:null!==(t=v.expectedSalary)&&void 0!==t?t:""}),a.createElement(c,{name:"expectedSalary",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("noticePeriod")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.noticePeriod||"Notice Period (Months)",name:"noticePeriod",type:"number",onChange:s,onBlur:p,value:null!==(l=v.noticePeriod)&&void 0!==l?l:""}),a.createElement(c,{name:"noticePeriod",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("nationality")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.nationality||"Nationality*",name:"nationality",onChange:s,onBlur:p,value:v.nationality}),a.createElement(c,{name:"nationality",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("linkedInUrl")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.linkedInUrl||"LinkedIn URL",name:"linkedInUrl",type:"url",onChange:s,onBlur:p,value:v.linkedInUrl}),a.createElement(c,{name:"linkedInUrl",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("relevantExperience")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.relevantExperience||"Relevant Experience (Years)",name:"relevantExperience",type:"number",onChange:s,onBlur:p,value:null!==(i=v.relevantExperience)&&void 0!==i?i:""}),a.createElement(c,{name:"relevantExperience",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("currentLocation")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.currentLocation||"Current Location",name:"currentLocation",onChange:s,onBlur:p,value:v.currentLocation}),a.createElement(c,{name:"currentLocation",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("reasonForLeaving")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.reasonForLeaving||"Reason for Leaving",name:"reasonForLeaving",onChange:s,onBlur:p,value:v.reasonForLeaving}),a.createElement(c,{name:"reasonForLeaving",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("highestEducation")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.highestEducation||"Highest Education",name:"highestEducation",onChange:s,onBlur:p,value:v.highestEducation}),a.createElement(c,{name:"highestEducation",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("dateOfBirth")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.dateOfBirth||"Date of Birth",name:"dateOfBirth",type:"text",onChange:s,onBlur:p,value:v.dateOfBirth}),a.createElement(c,{name:"dateOfBirth",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("currentCompany")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.currentCompany||"Current Company Name",name:"currentCompany",onChange:s,onBlur:p,value:v.currentCompany}),a.createElement(c,{name:"currentCompany",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("companyUrl")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("input",{className:G("career-form-input",B.input),placeholder:D.companyUrl||"Company Website",name:"companyUrl",type:"url",onChange:s,onBlur:p,value:v.companyUrl}),a.createElement(c,{name:"companyUrl",component:"div",className:G("career-form-error-message",B.errorMessage)}))),M.includes("coverLetter")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("textarea",{className:G("career-form-textarea",B.textarea),placeholder:D.coverLetter||"Cover Letter",name:"coverLetter",onChange:s,onBlur:p,value:v.coverLetter,rows:4}),a.createElement(c,{name:"coverLetter",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("photo")&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("label",{className:G("career-file-label",B.fileLabel)},a.createElement("input",{type:"file",name:"photo",accept:".jpg,.jpeg,.png",onChange:function(e){return $(e,d,"photo",z)},onBlur:p,className:G("career-file-input",B.fileInput)}),a.createElement("span",{className:"career-file-button"},j||D.photo||"Upload Photo (JPG, PNG)")),j&&a.createElement("div",{style:{marginTop:"0.5rem",fontSize:"0.875rem",color:"#4b5563"}},"Selected: ",j),a.createElement(c,{name:"photo",component:"div",className:G("career-form-error-message",B.errorMessage)})),a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("label",{className:G("career-file-label",B.fileLabel)},a.createElement("input",{type:"file",name:"resume",accept:".pdf,.doc,.docx",onChange:function(e){return $(e,d,"resume",O)},onBlur:p,className:G("career-file-input",B.fileInput)}),a.createElement("span",{className:"career-file-button"},I||D.resume||"Upload Resume (PDF, DOC, DOCX)*")),I&&a.createElement("div",{className:"career-selected-file-name"},"Selected: ",I),a.createElement("div",{className:"career-accepted-doc-formats"},a.createElement("div",null,"• Accepted formats: PDF, DOC, DOCX"),a.createElement("div",null,"• Maximum file size: 5 MB")),a.createElement(c,{name:"resume",component:"div",className:G("career-form-error-message",B.errorMessage)})),M.includes("consent")&&w&&a.createElement("div",{className:G("career-input-container",B.inputContainer)},a.createElement("label",{className:"career-consent-label"},a.createElement("input",{type:"checkbox",name:"consent",checked:v.consent,onChange:function(e){return d("consent",e.target.checked)},onBlur:p,className:"career-consent-checkbox"}),a.createElement("span",null,w)),a.createElement(c,{name:"consent",component:"div",className:G("career-form-error-message",B.errorMessage)})),a.createElement("div",{className:"career-form-button-container"},a.createElement("button",{className:G("career-form-submit-button",B.submitButton),type:"submit",disabled:g},g?"Submitting...":"Submit Application")))})))))}export{f as CareerApplicationForm};
|