@opensite/ui 2.1.9 → 2.2.1

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,8 +1,7 @@
1
1
  "use client";
2
2
  import * as React from 'react';
3
3
  import React__default from 'react';
4
- import { Form } from '@page-speed/forms';
5
- import { useFileUpload, useContactForm, getColumnSpanClass, DynamicFormField } from '@page-speed/forms/integration';
4
+ import { FormEngine } from '@page-speed/forms/integration';
6
5
  import { clsx } from 'clsx';
7
6
  import { twMerge } from 'tailwind-merge';
8
7
  import { cva } from 'class-variance-authority';
@@ -823,6 +822,12 @@ var Section = React__default.forwardRef(
823
822
  }
824
823
  );
825
824
  Section.displayName = "Section";
825
+ var DEFAULT_STYLE_RULES = {
826
+ formContainer: "",
827
+ fieldsContainer: "",
828
+ fieldClassName: "",
829
+ formClassName: "space-y-6"
830
+ };
826
831
  var DEFAULT_FORM_FIELDS = [
827
832
  {
828
833
  name: "firstName",
@@ -865,87 +870,42 @@ function ContactDark({
865
870
  contactDescription = "Fill up the form and our team will get back to you within 24 hours.",
866
871
  buttonText = "Submit",
867
872
  buttonIcon,
868
- actions,
869
- actionsSlot,
870
873
  contactOptions,
871
874
  contactOptionsSlot,
872
875
  socialLinks,
873
876
  socialLinksSlot,
874
- formFields = DEFAULT_FORM_FIELDS,
875
- successMessage = "Thank you! Your message has been sent successfully.",
877
+ formEngineSetup,
876
878
  className,
877
879
  headerClassName,
878
880
  headingClassName,
879
881
  descriptionClassName,
880
882
  cardClassName,
881
883
  formPanelClassName,
882
- formClassName,
883
- submitClassName,
884
884
  infoPanelClassName,
885
885
  contactOptionsClassName,
886
886
  socialLinksClassName,
887
- successMessageClassName,
888
- errorMessageClassName,
889
887
  background,
890
888
  spacing = "py-8 md:py-32",
891
889
  containerClassName = "px-6 sm:px-6 md:px-8 lg:px-8",
892
890
  pattern,
893
- patternOpacity,
894
- formConfig,
895
- onSubmit,
896
- onSuccess,
897
- onError
891
+ patternOpacity
898
892
  }) {
899
- const {
900
- uploadTokens,
901
- uploadProgress,
902
- isUploading,
903
- uploadFiles,
904
- removeFile,
905
- resetUpload
906
- } = useFileUpload({ onError });
907
- const { form, submissionError, formMethod, resetSubmissionState } = useContactForm({
908
- formFields,
909
- formConfig,
910
- onSubmit,
911
- onSuccess: (data) => {
912
- resetUpload();
913
- onSuccess?.(data);
914
- },
915
- onError,
916
- resetOnSuccess: formConfig?.resetOnSuccess !== false,
917
- uploadTokens
918
- });
919
- const actionsContent = React.useMemo(() => {
920
- if (actionsSlot) return actionsSlot;
921
- if (actions && actions.length > 0) {
922
- return actions.map((action, index) => {
923
- const {
924
- label,
925
- icon,
926
- iconAfter,
927
- children,
928
- className: actionClassName,
929
- ...pressableProps
930
- } = action;
931
- return /* @__PURE__ */ jsx(
932
- Pressable,
933
- {
934
- asButton: true,
935
- className: actionClassName,
936
- ...pressableProps,
937
- children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
938
- icon,
939
- label,
940
- iconAfter
941
- ] })
942
- },
943
- index
944
- );
945
- });
893
+ const formStyleRules = React.useMemo(() => {
894
+ return {
895
+ formContainer: formEngineSetup?.formLayoutSettings?.styleRules?.formContainer ?? DEFAULT_STYLE_RULES.formContainer,
896
+ fieldsContainer: formEngineSetup?.formLayoutSettings?.styleRules?.fieldsContainer ?? DEFAULT_STYLE_RULES.fieldsContainer,
897
+ fieldClassName: formEngineSetup?.formLayoutSettings?.styleRules?.fieldClassName ?? DEFAULT_STYLE_RULES.fieldClassName,
898
+ formClassName: formEngineSetup?.formLayoutSettings?.styleRules?.formClassName ?? DEFAULT_STYLE_RULES.formClassName,
899
+ successMessageClassName: formEngineSetup?.formLayoutSettings?.styleRules?.successMessageClassName ?? DEFAULT_STYLE_RULES.successMessageClassName,
900
+ errorMessageClassName: formEngineSetup?.formLayoutSettings?.styleRules?.errorMessageClassName ?? DEFAULT_STYLE_RULES.errorMessageClassName
901
+ };
902
+ }, [formEngineSetup?.formLayoutSettings?.styleRules]);
903
+ const formFields = React.useMemo(() => {
904
+ if (formEngineSetup?.fields && formEngineSetup.fields.length > 0) {
905
+ return formEngineSetup.fields;
946
906
  }
947
- return null;
948
- }, [actionsSlot, actions]);
907
+ return DEFAULT_FORM_FIELDS;
908
+ }, [formEngineSetup?.fields]);
949
909
  const contactOptionsContent = React.useMemo(() => {
950
910
  if (contactOptionsSlot) return contactOptionsSlot;
951
911
  if (contactOptions && contactOptions.length > 0) {
@@ -1000,124 +960,102 @@ function ContactDark({
1000
960
  patternOpacity,
1001
961
  className,
1002
962
  containerClassName,
1003
- children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
1004
- /* @__PURE__ */ jsxs("div", { className: cn("mb-10 text-center", headerClassName), children: [
1005
- heading && (typeof heading === "string" ? /* @__PURE__ */ jsx(
1006
- "h2",
1007
- {
1008
- className: cn(
1009
- "mb-3 text-3xl font-bold tracking-tight text-balance",
1010
- headingClassName
1011
- ),
1012
- children: heading
1013
- }
1014
- ) : /* @__PURE__ */ jsx("div", { className: headingClassName, children: heading })),
1015
- description && (typeof description === "string" ? /* @__PURE__ */ jsx(
1016
- "p",
1017
- {
1018
- className: cn(
1019
- "leading-relaxed text-balance",
1020
- descriptionClassName
1021
- ),
1022
- children: description
1023
- }
1024
- ) : /* @__PURE__ */ jsx("div", { className: descriptionClassName, children: description }))
1025
- ] }),
1026
- /* @__PURE__ */ jsxs(
1027
- Card,
1028
- {
1029
- className: cn(
1030
- "grid gap-0 overflow-hidden grid-cols-1 lg:grid-cols-2 pt-0 pb-0",
1031
- cardClassName
1032
- ),
1033
- children: [
1034
- /* @__PURE__ */ jsx("div", { className: cn("p-6 lg:p-12", formPanelClassName), children: /* @__PURE__ */ jsxs(
1035
- Form,
1036
- {
1037
- form,
1038
- notificationConfig: {
1039
- submissionError,
1040
- successMessage
1041
- },
1042
- styleConfig: {
1043
- formClassName: cn("space-y-6", formClassName),
1044
- successMessageClassName,
1045
- errorMessageClassName
1046
- },
1047
- formConfig: {
1048
- endpoint: formConfig?.endpoint,
1049
- method: formMethod,
1050
- submissionConfig: formConfig?.submissionConfig
1051
- },
1052
- onNewSubmission: () => {
1053
- resetUpload();
1054
- resetSubmissionState();
963
+ children: /* @__PURE__ */ jsx("div", { className: "relative", children: /* @__PURE__ */ jsxs(
964
+ Card,
965
+ {
966
+ className: cn(
967
+ "grid gap-0 overflow-hidden grid-cols-1 lg:grid-cols-2 pt-0 pb-0",
968
+ cardClassName
969
+ ),
970
+ children: [
971
+ /* @__PURE__ */ jsx("div", { className: cn("p-6 lg:p-12", formPanelClassName), children: formEngineSetup ? /* @__PURE__ */ jsx(
972
+ FormEngine,
973
+ {
974
+ ...formEngineSetup,
975
+ formLayoutSettings: {
976
+ ...formEngineSetup.formLayoutSettings,
977
+ formLayout: "standard",
978
+ submitButtonSetup: {
979
+ ...formEngineSetup.formLayoutSettings?.submitButtonSetup,
980
+ submitLabel: /* @__PURE__ */ jsxs(Fragment, { children: [
981
+ buttonIcon,
982
+ buttonText
983
+ ] })
1055
984
  },
1056
- children: [
1057
- /* @__PURE__ */ jsx("div", { className: "grid grid-cols-12 gap-6", children: formFields.map((field) => /* @__PURE__ */ jsx(
1058
- "div",
1059
- {
1060
- className: getColumnSpanClass(field.columnSpan),
1061
- children: /* @__PURE__ */ jsx(
1062
- DynamicFormField,
985
+ styleRules: formStyleRules
986
+ },
987
+ fields: formFields
988
+ }
989
+ ) : null }),
990
+ /* @__PURE__ */ jsxs(
991
+ "div",
992
+ {
993
+ className: cn(
994
+ "flex flex-col justify-between bg-primary p-6 text-primary-foreground lg:p-8",
995
+ infoPanelClassName
996
+ ),
997
+ children: [
998
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(
999
+ "div",
1000
+ {
1001
+ className: cn(
1002
+ "pb-6 md:pb-8 border-b-2 border-border/50 mb-6 md:mb-8 text-left",
1003
+ headerClassName
1004
+ ),
1005
+ children: [
1006
+ heading && (typeof heading === "string" ? /* @__PURE__ */ jsx(
1007
+ "h2",
1063
1008
  {
1064
- field,
1065
- uploadProgress,
1066
- onFileUpload: uploadFiles,
1067
- onFileRemove: removeFile,
1068
- isUploading
1009
+ className: cn(
1010
+ "text-3xl font-bold tracking-tight text-pretty md:text-5xl",
1011
+ headingClassName
1012
+ ),
1013
+ children: heading
1069
1014
  }
1070
- )
1071
- },
1072
- field.name
1073
- )) }),
1074
- actionsSlot || actions && actions.length > 0 ? actionsContent : /* @__PURE__ */ jsxs(
1075
- Pressable,
1076
- {
1077
- componentType: "button",
1078
- type: "submit",
1079
- className: cn("w-full", submitClassName),
1080
- asButton: true,
1081
- disabled: form.isSubmitting,
1082
- children: [
1083
- buttonIcon,
1084
- buttonText
1085
- ]
1086
- }
1087
- )
1088
- ]
1089
- }
1090
- ) }),
1091
- /* @__PURE__ */ jsxs(
1092
- "div",
1093
- {
1094
- className: cn(
1095
- "flex flex-col justify-between bg-primary p-6 text-primary-foreground lg:p-8",
1096
- infoPanelClassName
1097
- ),
1098
- children: [
1099
- /* @__PURE__ */ jsxs("div", { children: [
1100
- contactHeading && (typeof contactHeading === "string" ? /* @__PURE__ */ jsx("h3", { className: "mb-3 text-xl font-semibold", children: contactHeading }) : /* @__PURE__ */ jsx("div", { className: "mb-3", children: contactHeading })),
1101
- contactDescription && (typeof contactDescription === "string" ? /* @__PURE__ */ jsx("p", { className: "mb-8 text-sm text-primary-foreground/80", children: contactDescription }) : /* @__PURE__ */ jsx("div", { className: "mb-8", children: contactDescription })),
1102
- /* @__PURE__ */ jsx("div", { className: cn("space-y-4", contactOptionsClassName), children: contactOptionsContent })
1103
- ] }),
1015
+ ) : heading),
1016
+ description && (typeof description === "string" ? /* @__PURE__ */ jsx(
1017
+ "p",
1018
+ {
1019
+ className: cn(
1020
+ "leading-relaxed text-balance",
1021
+ descriptionClassName
1022
+ ),
1023
+ children: description
1024
+ }
1025
+ ) : description)
1026
+ ]
1027
+ }
1028
+ ) }),
1029
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-start gap-4", children: [
1030
+ contactHeading && (typeof contactHeading === "string" ? /* @__PURE__ */ jsx("h3", { className: "text-xl font-semibold", children: contactHeading }) : contactHeading),
1031
+ contactDescription && (typeof contactDescription === "string" ? /* @__PURE__ */ jsx("p", { className: "text-sm text-primary-foreground/80", children: contactDescription }) : contactDescription),
1104
1032
  /* @__PURE__ */ jsx(
1105
1033
  "div",
1106
1034
  {
1107
1035
  className: cn(
1108
- "mt-8 flex items-center gap-4",
1109
- socialLinksClassName
1036
+ "pt-6 md:pt-8 space-y-4",
1037
+ contactOptionsClassName
1110
1038
  ),
1111
- children: socialLinksContent
1039
+ children: contactOptionsContent
1112
1040
  }
1113
1041
  )
1114
- ]
1115
- }
1116
- )
1117
- ]
1118
- }
1119
- )
1120
- ] })
1042
+ ] }),
1043
+ /* @__PURE__ */ jsx(
1044
+ "div",
1045
+ {
1046
+ className: cn(
1047
+ "mt-8 flex items-center gap-4",
1048
+ socialLinksClassName
1049
+ ),
1050
+ children: socialLinksContent
1051
+ }
1052
+ )
1053
+ ]
1054
+ }
1055
+ )
1056
+ ]
1057
+ }
1058
+ ) })
1121
1059
  }
1122
1060
  );
1123
1061
  }