@opensite/ui 2.1.3 → 2.1.5

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.
@@ -1,9 +1,10 @@
1
1
  "use client";
2
- import { useFileUpload, FormEngine } from '@page-speed/forms/integration';
2
+ import * as React3 from 'react';
3
+ import React3__default from 'react';
4
+ import { FormEngine } from '@page-speed/forms/integration';
3
5
  import { clsx } from 'clsx';
4
6
  import { twMerge } from 'tailwind-merge';
5
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
- import React from 'react';
7
+ import { jsx, jsxs } from 'react/jsx-runtime';
7
8
 
8
9
  // components/blocks/contact/contact-vendor.tsx
9
10
  function cn(...inputs) {
@@ -41,7 +42,7 @@ var maxWidthStyles = {
41
42
  "4xl": "max-w-[1536px]",
42
43
  full: "max-w-full"
43
44
  };
44
- var Container = React.forwardRef(
45
+ var Container = React3__default.forwardRef(
45
46
  ({ children, maxWidth = "xl", className, as = "div", ...props }, ref) => {
46
47
  const Component = as;
47
48
  return /* @__PURE__ */ jsx(
@@ -346,7 +347,7 @@ var spacingStyles = {
346
347
  };
347
348
  var predefinedSpacings = ["none", "sm", "md", "lg", "xl"];
348
349
  var isPredefinedSpacing = (spacing) => predefinedSpacings.includes(spacing);
349
- var Section = React.forwardRef(
350
+ var Section = React3__default.forwardRef(
350
351
  ({
351
352
  id,
352
353
  title,
@@ -407,6 +408,14 @@ var Section = React.forwardRef(
407
408
  }
408
409
  );
409
410
  Section.displayName = "Section";
411
+ var DEFAULT_STYLE_RULES = {
412
+ formContainer: "",
413
+ fieldsContainer: "",
414
+ fieldClassName: "",
415
+ formClassName: "space-y-6",
416
+ successMessageClassName: "text-green-600 dark:text-green-400 mt-4 p-3 rounded-md bg-green-50 dark:bg-green-950/20",
417
+ errorMessageClassName: "text-red-600 dark:text-red-400 mt-4 p-3 rounded-md bg-red-50 dark:bg-red-950/20"
418
+ };
410
419
  var DEFAULT_FORM_FIELDS = [
411
420
  {
412
421
  name: "first_name",
@@ -453,40 +462,36 @@ var DEFAULT_FORM_FIELDS = [
453
462
  function ContactVendor({
454
463
  heading,
455
464
  description,
456
- buttonText = "Submit",
457
- buttonIcon,
458
- actions,
459
- actionsSlot,
460
- formFields = DEFAULT_FORM_FIELDS,
461
- successMessage = "Thank you! Your message has been sent successfully.",
462
465
  className,
466
+ formEngineSetup,
463
467
  containerClassName = "px-6 sm:px-6 md:px-8 lg:px-8",
464
468
  headerClassName,
465
469
  headingClassName,
466
470
  descriptionClassName,
467
471
  cardClassName,
468
472
  cardContentClassName,
469
- formClassName,
470
- submitClassName,
471
- successMessageClassName,
472
- errorMessageClassName,
473
- background = "white",
473
+ background,
474
474
  spacing = "xl",
475
475
  pattern,
476
- patternOpacity = 0.1,
477
- formConfig,
478
- onSubmit,
479
- onSuccess,
480
- onError
476
+ patternOpacity = 0.1
481
477
  }) {
482
- const {
483
- uploadTokens,
484
- uploadProgress,
485
- isUploading,
486
- uploadFiles,
487
- removeFile,
488
- resetUpload
489
- } = useFileUpload({ onError });
478
+ const formStyleRules = React3.useMemo(() => {
479
+ return {
480
+ formContainer: formEngineSetup?.formLayoutSettings?.styleRules?.formContainer ?? DEFAULT_STYLE_RULES.formContainer,
481
+ fieldsContainer: formEngineSetup?.formLayoutSettings?.styleRules?.fieldsContainer ?? DEFAULT_STYLE_RULES.fieldsContainer,
482
+ fieldClassName: formEngineSetup?.formLayoutSettings?.styleRules?.fieldClassName ?? DEFAULT_STYLE_RULES.fieldClassName,
483
+ formClassName: formEngineSetup?.formLayoutSettings?.styleRules?.formClassName ?? DEFAULT_STYLE_RULES.formClassName,
484
+ successMessageClassName: formEngineSetup?.formLayoutSettings?.styleRules?.successMessageClassName ?? DEFAULT_STYLE_RULES.successMessageClassName,
485
+ errorMessageClassName: formEngineSetup?.formLayoutSettings?.styleRules?.errorMessageClassName ?? DEFAULT_STYLE_RULES.errorMessageClassName
486
+ };
487
+ }, [formEngineSetup?.formLayoutSettings?.styleRules]);
488
+ const formFields = React3.useMemo(() => {
489
+ if (formEngineSetup && formEngineSetup?.fields && formEngineSetup?.fields?.length > 0) {
490
+ return formEngineSetup.fields;
491
+ } else {
492
+ return DEFAULT_FORM_FIELDS;
493
+ }
494
+ }, [formEngineSetup?.fields]);
490
495
  return /* @__PURE__ */ jsx(
491
496
  Section,
492
497
  {
@@ -507,7 +512,7 @@ function ContactVendor({
507
512
  ),
508
513
  children: heading
509
514
  }
510
- ) : /* @__PURE__ */ jsx("div", { className: headingClassName, children: heading })),
515
+ ) : heading),
511
516
  description && (typeof description === "string" ? /* @__PURE__ */ jsx(
512
517
  "p",
513
518
  {
@@ -517,42 +522,19 @@ function ContactVendor({
517
522
  ),
518
523
  children: description
519
524
  }
520
- ) : /* @__PURE__ */ jsx("div", { className: descriptionClassName, children: description }))
525
+ ) : description)
521
526
  ] }),
522
- /* @__PURE__ */ jsx(Card, { className: cn("mx-auto max-w-xl", cardClassName), children: /* @__PURE__ */ jsx(CardContent, { className: cn("p-6 lg:p-8", cardContentClassName), children: /* @__PURE__ */ jsx(
527
+ /* @__PURE__ */ jsx(Card, { className: cn("mx-auto max-w-xl", cardClassName), children: /* @__PURE__ */ jsx(CardContent, { className: cn("p-6 lg:p-8", cardContentClassName), children: formEngineSetup ? /* @__PURE__ */ jsx(
523
528
  FormEngine,
524
529
  {
525
- api: formConfig,
526
- fields: formFields,
530
+ ...formEngineSetup,
527
531
  formLayoutSettings: {
528
- formLayout: "standard",
529
- submitButtonSetup: {
530
- submitLabel: /* @__PURE__ */ jsxs(Fragment, { children: [
531
- buttonIcon,
532
- buttonText
533
- ] })
534
- },
535
- styleRules: {
536
- formClassName: cn("space-y-4", formClassName),
537
- successMessageClassName,
538
- errorMessageClassName
539
- }
540
- },
541
- successMessage,
542
- onSubmit,
543
- onSuccess: (data) => {
544
- resetUpload();
545
- onSuccess?.(data);
532
+ ...formEngineSetup.formLayoutSettings,
533
+ styleRules: formStyleRules
546
534
  },
547
- onError,
548
- resetOnSuccess: formConfig?.resetOnSuccess !== false,
549
- uploadTokens,
550
- uploadProgress,
551
- onFileUpload: uploadFiles,
552
- onFileRemove: removeFile,
553
- isUploading
535
+ fields: formFields
554
536
  }
555
- ) }) })
537
+ ) : null }) })
556
538
  ] })
557
539
  }
558
540
  );
@@ -406,6 +406,14 @@ var Section = React3__namespace.default.forwardRef(
406
406
  }
407
407
  );
408
408
  Section.displayName = "Section";
409
+ var DEFAULT_STYLE_RULES = {
410
+ formContainer: "mt-10 flex justify-center items-center w-full max-w-md flex-col gap-4 sm:flex-row",
411
+ fieldsContainer: "",
412
+ fieldClassName: "",
413
+ formClassName: "",
414
+ successMessageClassName: "text-primary-foreground mt-4 p-3 rounded-md bg-primary",
415
+ errorMessageClassName: "text-destructive-foreground mt-4 p-3 rounded-md bg-destructive"
416
+ };
409
417
  var DEFAULT_FORM_FIELDS = [
410
418
  {
411
419
  name: "email",
@@ -419,12 +427,7 @@ var DEFAULT_FORM_FIELDS = [
419
427
  function HeroNewsletterMinimal({
420
428
  heading,
421
429
  description,
422
- formFields = DEFAULT_FORM_FIELDS,
423
- formConfig,
424
- onSubmit,
425
- onSuccess,
426
- onError,
427
- successMessage,
430
+ formEngineSetup,
428
431
  buttonAction,
429
432
  helperText,
430
433
  formSlot,
@@ -433,25 +436,33 @@ function HeroNewsletterMinimal({
433
436
  patternClassName,
434
437
  statsSlot,
435
438
  background,
436
- containerClassName = "px-6 sm:px-6 md:px-8 lg:px-8",
439
+ containerClassName = "pmx-auto w-full max-w-7xl relative z-10 px-6 sm:px-6 md:px-8 lg:px-8 flex flex-col items-center justify-center",
437
440
  spacing = "xl",
438
441
  pattern,
439
442
  patternOpacity,
440
443
  className,
441
444
  headingClassName,
442
445
  descriptionClassName,
443
- formClassName,
444
446
  disclaimerClassName,
445
447
  statsClassName
446
448
  }) {
447
- const {
448
- uploadTokens,
449
- uploadProgress,
450
- isUploading,
451
- uploadFiles,
452
- removeFile,
453
- resetUpload
454
- } = integration.useFileUpload({ onError });
449
+ const formStyleRules = React3__namespace.useMemo(() => {
450
+ return {
451
+ formContainer: formEngineSetup?.formLayoutSettings?.styleRules?.formContainer ?? DEFAULT_STYLE_RULES.formContainer,
452
+ fieldsContainer: formEngineSetup?.formLayoutSettings?.styleRules?.fieldsContainer ?? DEFAULT_STYLE_RULES.fieldsContainer,
453
+ fieldClassName: formEngineSetup?.formLayoutSettings?.styleRules?.fieldClassName ?? DEFAULT_STYLE_RULES.fieldClassName,
454
+ formClassName: formEngineSetup?.formLayoutSettings?.styleRules?.formClassName ?? DEFAULT_STYLE_RULES.formClassName,
455
+ successMessageClassName: formEngineSetup?.formLayoutSettings?.styleRules?.successMessageClassName ?? DEFAULT_STYLE_RULES.successMessageClassName,
456
+ errorMessageClassName: formEngineSetup?.formLayoutSettings?.styleRules?.errorMessageClassName ?? DEFAULT_STYLE_RULES.errorMessageClassName
457
+ };
458
+ }, [formEngineSetup?.formLayoutSettings?.styleRules]);
459
+ const formFields = React3__namespace.useMemo(() => {
460
+ if (formEngineSetup && formEngineSetup?.fields && formEngineSetup?.fields?.length > 0) {
461
+ return formEngineSetup.fields;
462
+ } else {
463
+ return DEFAULT_FORM_FIELDS;
464
+ }
465
+ }, [formEngineSetup?.fields]);
455
466
  const renderStats = React3__namespace.useMemo(() => {
456
467
  if (statsSlot) return statsSlot;
457
468
  if (!stats || stats.length === 0) return null;
@@ -480,6 +491,7 @@ function HeroNewsletterMinimal({
480
491
  }, [statsSlot, stats]);
481
492
  const renderForm = React3__namespace.useMemo(() => {
482
493
  if (formSlot) return formSlot;
494
+ if (!formEngineSetup) return null;
483
495
  const defaultButtonAction = {
484
496
  label: "Subscribe",
485
497
  variant: "default"
@@ -489,51 +501,33 @@ function HeroNewsletterMinimal({
489
501
  /* @__PURE__ */ jsxRuntime.jsx(
490
502
  integration.FormEngine,
491
503
  {
492
- api: formConfig,
493
- fields: formFields,
504
+ ...formEngineSetup,
494
505
  formLayoutSettings: {
506
+ ...formEngineSetup.formLayoutSettings,
495
507
  formLayout: "button-group",
496
508
  buttonGroupSetup: {
509
+ ...formEngineSetup.formLayoutSettings?.buttonGroupSetup,
497
510
  size: "lg",
498
511
  submitLabel: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
499
512
  action.label,
500
513
  action.iconAfter
501
514
  ] }),
502
515
  submitVariant: action.variant || "default"
503
- }
516
+ },
517
+ styleRules: formStyleRules
504
518
  },
505
- successMessage,
506
- onSubmit,
507
- onSuccess: (data) => {
508
- resetUpload();
509
- onSuccess?.(data);
510
- },
511
- onError,
512
- uploadTokens,
513
- uploadProgress,
514
- onFileUpload: uploadFiles,
515
- onFileRemove: removeFile,
516
- isUploading
519
+ fields: formFields
517
520
  }
518
521
  ),
519
522
  helperText && (typeof helperText === "string" ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: cn("text-sm mt-2 text-center"), children: helperText }) : helperText)
520
523
  ] });
521
524
  }, [
522
525
  formSlot,
523
- formFields,
524
- formConfig,
526
+ formEngineSetup,
525
527
  buttonAction,
526
- uploadTokens,
527
- uploadProgress,
528
- uploadFiles,
529
- removeFile,
530
- isUploading,
531
- successMessage,
532
- onSubmit,
533
- onSuccess,
534
- onError,
535
- helperText,
536
- resetUpload
528
+ formFields,
529
+ formStyleRules,
530
+ helperText
537
531
  ]);
538
532
  return /* @__PURE__ */ jsxRuntime.jsx(
539
533
  Section,
@@ -545,58 +539,40 @@ function HeroNewsletterMinimal({
545
539
  patternClassName,
546
540
  className,
547
541
  containerClassName,
548
- children: /* @__PURE__ */ jsxRuntime.jsxs(
549
- "div",
550
- {
551
- className: cn(
552
- "container flex flex-col items-center justify-center text-center",
553
- containerClassName
554
- ),
555
- children: [
556
- heading && (typeof heading === "string" ? /* @__PURE__ */ jsxRuntime.jsx(
557
- "h1",
558
- {
559
- className: cn(
560
- "max-w-3xl text-5xl font-bold tracking-tight md:text-6xl lg:text-7xl text-pretty",
561
- headingClassName
562
- ),
563
- children: heading
564
- }
565
- ) : heading),
566
- description && (typeof description === "string" ? /* @__PURE__ */ jsxRuntime.jsx(
567
- "p",
568
- {
569
- className: cn(
570
- "mt-6 max-w-full md:max-w-lg text-lg md:text-xl text-balance",
571
- descriptionClassName
572
- ),
573
- children: description
574
- }
575
- ) : description),
576
- /* @__PURE__ */ jsxRuntime.jsx(
577
- "div",
578
- {
579
- className: cn(
580
- "mt-10 flex w-full max-w-md flex-col gap-4 sm:flex-row",
581
- formClassName
582
- ),
583
- children: renderForm
584
- }
542
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center", children: [
543
+ heading && (typeof heading === "string" ? /* @__PURE__ */ jsxRuntime.jsx(
544
+ "h1",
545
+ {
546
+ className: cn(
547
+ "max-w-3xl text-5xl font-bold tracking-tight md:text-6xl lg:text-7xl text-pretty text-center",
548
+ headingClassName
585
549
  ),
586
- disclaimer && (typeof disclaimer === "string" ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: cn("mt-4 text-sm", disclaimerClassName), children: disclaimer }) : disclaimer),
587
- (statsSlot || stats && stats.length > 0) && /* @__PURE__ */ jsxRuntime.jsx(
588
- "div",
589
- {
590
- className: cn(
591
- "mt-16 flex flex-wrap items-center justify-center gap-8 md:gap-12",
592
- statsClassName
593
- ),
594
- children: renderStats
595
- }
596
- )
597
- ]
598
- }
599
- )
550
+ children: heading
551
+ }
552
+ ) : heading),
553
+ description && (typeof description === "string" ? /* @__PURE__ */ jsxRuntime.jsx(
554
+ "p",
555
+ {
556
+ className: cn(
557
+ "mt-6 max-w-full md:max-w-lg text-lg md:text-xl text-balance text-center",
558
+ descriptionClassName
559
+ ),
560
+ children: description
561
+ }
562
+ ) : description),
563
+ renderForm,
564
+ disclaimer && (typeof disclaimer === "string" ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: cn("mt-4 text-sm", disclaimerClassName), children: disclaimer }) : disclaimer),
565
+ (statsSlot || stats && stats.length > 0) && /* @__PURE__ */ jsxRuntime.jsx(
566
+ "div",
567
+ {
568
+ className: cn(
569
+ "mt-16 flex flex-wrap items-center justify-center gap-8 md:gap-12",
570
+ statsClassName
571
+ ),
572
+ children: renderStats
573
+ }
574
+ )
575
+ ] })
600
576
  }
601
577
  );
602
578
  }
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { f as SectionBackground, g as SectionSpacing, t as PatternName } from './community-initiatives-r_NhxVet.cjs';
3
- import { FormFieldConfig, PageSpeedFormConfig } from '@page-speed/forms/integration';
3
+ import { FormEngineProps } from '@page-speed/forms/integration';
4
4
  import { A as ActionConfig, S as StatItem } from './blocks-DP3Vofl4.cjs';
5
5
  import 'react/jsx-runtime';
6
6
  import 'class-variance-authority';
@@ -17,29 +17,9 @@ interface HeroNewsletterMinimalProps {
17
17
  */
18
18
  description?: React.ReactNode;
19
19
  /**
20
- * Form field configuration
20
+ * Full form engine setup and props
21
21
  */
22
- formFields?: FormFieldConfig[];
23
- /**
24
- * Form configuration for submission
25
- */
26
- formConfig?: PageSpeedFormConfig;
27
- /**
28
- * Custom submit handler
29
- */
30
- onSubmit?: (values: Record<string, any>) => void | Promise<void>;
31
- /**
32
- * Success callback
33
- */
34
- onSuccess?: (data: unknown) => void;
35
- /**
36
- * Error callback
37
- */
38
- onError?: (error: Error) => void;
39
- /**
40
- * Success message to display
41
- */
42
- successMessage?: React.ReactNode;
22
+ formEngineSetup?: FormEngineProps;
43
23
  /**
44
24
  * Submit button configuration
45
25
  */
@@ -95,10 +75,6 @@ interface HeroNewsletterMinimalProps {
95
75
  * Additional CSS classes for the description
96
76
  */
97
77
  descriptionClassName?: string;
98
- /**
99
- * Additional CSS classes for the form container
100
- */
101
- formClassName?: string;
102
78
  /**
103
79
  * Additional CSS classes for the input
104
80
  */
@@ -116,6 +92,6 @@ interface HeroNewsletterMinimalProps {
116
92
  */
117
93
  patternClassName?: string;
118
94
  }
119
- declare function HeroNewsletterMinimal({ heading, description, formFields, formConfig, onSubmit, onSuccess, onError, successMessage, buttonAction, helperText, formSlot, disclaimer, stats, patternClassName, statsSlot, background, containerClassName, spacing, pattern, patternOpacity, className, headingClassName, descriptionClassName, formClassName, disclaimerClassName, statsClassName, }: HeroNewsletterMinimalProps): React.JSX.Element;
95
+ declare function HeroNewsletterMinimal({ heading, description, formEngineSetup, buttonAction, helperText, formSlot, disclaimer, stats, patternClassName, statsSlot, background, containerClassName, spacing, pattern, patternOpacity, className, headingClassName, descriptionClassName, disclaimerClassName, statsClassName, }: HeroNewsletterMinimalProps): React.JSX.Element;
120
96
 
121
97
  export { HeroNewsletterMinimal, type HeroNewsletterMinimalProps };
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { f as SectionBackground, g as SectionSpacing, t as PatternName } from './community-initiatives-DmVsuoHE.js';
3
- import { FormFieldConfig, PageSpeedFormConfig } from '@page-speed/forms/integration';
3
+ import { FormEngineProps } from '@page-speed/forms/integration';
4
4
  import { A as ActionConfig, S as StatItem } from './blocks-XLPGq8A5.js';
5
5
  import 'react/jsx-runtime';
6
6
  import 'class-variance-authority';
@@ -17,29 +17,9 @@ interface HeroNewsletterMinimalProps {
17
17
  */
18
18
  description?: React.ReactNode;
19
19
  /**
20
- * Form field configuration
20
+ * Full form engine setup and props
21
21
  */
22
- formFields?: FormFieldConfig[];
23
- /**
24
- * Form configuration for submission
25
- */
26
- formConfig?: PageSpeedFormConfig;
27
- /**
28
- * Custom submit handler
29
- */
30
- onSubmit?: (values: Record<string, any>) => void | Promise<void>;
31
- /**
32
- * Success callback
33
- */
34
- onSuccess?: (data: unknown) => void;
35
- /**
36
- * Error callback
37
- */
38
- onError?: (error: Error) => void;
39
- /**
40
- * Success message to display
41
- */
42
- successMessage?: React.ReactNode;
22
+ formEngineSetup?: FormEngineProps;
43
23
  /**
44
24
  * Submit button configuration
45
25
  */
@@ -95,10 +75,6 @@ interface HeroNewsletterMinimalProps {
95
75
  * Additional CSS classes for the description
96
76
  */
97
77
  descriptionClassName?: string;
98
- /**
99
- * Additional CSS classes for the form container
100
- */
101
- formClassName?: string;
102
78
  /**
103
79
  * Additional CSS classes for the input
104
80
  */
@@ -116,6 +92,6 @@ interface HeroNewsletterMinimalProps {
116
92
  */
117
93
  patternClassName?: string;
118
94
  }
119
- declare function HeroNewsletterMinimal({ heading, description, formFields, formConfig, onSubmit, onSuccess, onError, successMessage, buttonAction, helperText, formSlot, disclaimer, stats, patternClassName, statsSlot, background, containerClassName, spacing, pattern, patternOpacity, className, headingClassName, descriptionClassName, formClassName, disclaimerClassName, statsClassName, }: HeroNewsletterMinimalProps): React.JSX.Element;
95
+ declare function HeroNewsletterMinimal({ heading, description, formEngineSetup, buttonAction, helperText, formSlot, disclaimer, stats, patternClassName, statsSlot, background, containerClassName, spacing, pattern, patternOpacity, className, headingClassName, descriptionClassName, disclaimerClassName, statsClassName, }: HeroNewsletterMinimalProps): React.JSX.Element;
120
96
 
121
97
  export { HeroNewsletterMinimal, type HeroNewsletterMinimalProps };