@opensite/ui 2.1.9 → 2.2.2

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,26 @@ 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
- });
946
- }
947
- return null;
948
- }, [actionsSlot, actions]);
949
893
  const contactOptionsContent = React.useMemo(() => {
950
894
  if (contactOptionsSlot) return contactOptionsSlot;
951
895
  if (contactOptions && contactOptions.length > 0) {
@@ -1000,124 +944,104 @@ function ContactDark({
1000
944
  patternOpacity,
1001
945
  className,
1002
946
  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();
1055
- },
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,
947
+ children: /* @__PURE__ */ jsx("div", { className: "relative", children: /* @__PURE__ */ jsxs(
948
+ Card,
949
+ {
950
+ className: cn(
951
+ "grid gap-0 overflow-hidden grid-cols-1 lg:grid-cols-2 pt-0 pb-0",
952
+ cardClassName
953
+ ),
954
+ children: [
955
+ /* @__PURE__ */ jsx("div", { className: cn("p-6 lg:p-12", formPanelClassName), children: formEngineSetup ? /* @__PURE__ */ jsx(
956
+ FormEngine,
957
+ {
958
+ formEngineSetup: {
959
+ ...formEngineSetup,
960
+ formLayoutSettings: {
961
+ ...formEngineSetup.formLayoutSettings,
962
+ formLayout: "standard",
963
+ submitButtonSetup: {
964
+ ...formEngineSetup.formLayoutSettings?.submitButtonSetup,
965
+ submitLabel: /* @__PURE__ */ jsxs(Fragment, { children: [
966
+ buttonIcon,
967
+ buttonText
968
+ ] })
969
+ }
970
+ }
971
+ },
972
+ defaultFields: DEFAULT_FORM_FIELDS,
973
+ defaultStyleRules: DEFAULT_STYLE_RULES
974
+ }
975
+ ) : null }),
976
+ /* @__PURE__ */ jsxs(
977
+ "div",
978
+ {
979
+ className: cn(
980
+ "flex flex-col justify-between bg-primary p-6 text-primary-foreground lg:p-8",
981
+ infoPanelClassName
982
+ ),
983
+ children: [
984
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(
985
+ "div",
986
+ {
987
+ className: cn(
988
+ "pb-6 md:pb-8 border-b-2 border-border/50 mb-6 md:mb-8 text-left",
989
+ headerClassName
990
+ ),
991
+ children: [
992
+ heading && (typeof heading === "string" ? /* @__PURE__ */ jsx(
993
+ "h2",
1063
994
  {
1064
- field,
1065
- uploadProgress,
1066
- onFileUpload: uploadFiles,
1067
- onFileRemove: removeFile,
1068
- isUploading
995
+ className: cn(
996
+ "text-3xl font-bold tracking-tight text-pretty md:text-5xl",
997
+ headingClassName
998
+ ),
999
+ children: heading
1069
1000
  }
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
- ] }),
1001
+ ) : heading),
1002
+ description && (typeof description === "string" ? /* @__PURE__ */ jsx(
1003
+ "p",
1004
+ {
1005
+ className: cn(
1006
+ "leading-relaxed text-balance",
1007
+ descriptionClassName
1008
+ ),
1009
+ children: description
1010
+ }
1011
+ ) : description)
1012
+ ]
1013
+ }
1014
+ ) }),
1015
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-start gap-4", children: [
1016
+ contactHeading && (typeof contactHeading === "string" ? /* @__PURE__ */ jsx("h3", { className: "text-xl font-semibold", children: contactHeading }) : contactHeading),
1017
+ contactDescription && (typeof contactDescription === "string" ? /* @__PURE__ */ jsx("p", { className: "text-sm text-primary-foreground/80", children: contactDescription }) : contactDescription),
1104
1018
  /* @__PURE__ */ jsx(
1105
1019
  "div",
1106
1020
  {
1107
1021
  className: cn(
1108
- "mt-8 flex items-center gap-4",
1109
- socialLinksClassName
1022
+ "pt-6 md:pt-8 space-y-4",
1023
+ contactOptionsClassName
1110
1024
  ),
1111
- children: socialLinksContent
1025
+ children: contactOptionsContent
1112
1026
  }
1113
1027
  )
1114
- ]
1115
- }
1116
- )
1117
- ]
1118
- }
1119
- )
1120
- ] })
1028
+ ] }),
1029
+ /* @__PURE__ */ jsx(
1030
+ "div",
1031
+ {
1032
+ className: cn(
1033
+ "mt-8 flex items-center gap-4",
1034
+ socialLinksClassName
1035
+ ),
1036
+ children: socialLinksContent
1037
+ }
1038
+ )
1039
+ ]
1040
+ }
1041
+ )
1042
+ ]
1043
+ }
1044
+ ) })
1121
1045
  }
1122
1046
  );
1123
1047
  }