@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
- import React__default, { useMemo } from 'react';
4
- import { Form } from '@page-speed/forms';
5
- import { useFileUpload, useContactForm, getColumnSpanClass, DynamicFormField } from '@page-speed/forms/integration';
3
+ import React__default from 'react';
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';
@@ -810,32 +809,12 @@ var Section = React__default.forwardRef(
810
809
  }
811
810
  );
812
811
  Section.displayName = "Section";
813
- var DEFAULT_CONTACT_ITEMS = [
814
- {
815
- icon: "lucide/phone",
816
- title: "Critical Hotline",
817
- subtitle: "+1 (555) 911-0000",
818
- href: "tel:+15559110000"
819
- },
820
- {
821
- icon: "lucide/mail",
822
- title: "Email Support",
823
- subtitle: "emergency@support.com",
824
- href: "mailto:emergency@support.com"
825
- },
826
- {
827
- icon: "lucide/message-circle",
828
- title: "Live Chat",
829
- subtitle: "24/7 Available",
830
- href: "#chat"
831
- },
832
- {
833
- icon: "lucide/map-pin",
834
- title: "Visit Us",
835
- subtitle: "123 Support Lane",
836
- href: "#location"
837
- }
838
- ];
812
+ var DEFAULT_STYLE_RULES = {
813
+ formContainer: "",
814
+ fieldsContainer: "",
815
+ fieldClassName: "",
816
+ formClassName: "space-y-4"
817
+ };
839
818
  var PRIORITIES = [
840
819
  {
841
820
  value: "critical",
@@ -910,82 +889,36 @@ var DEFAULT_FORM_FIELDS = [
910
889
  function ContactEmergency({
911
890
  heading,
912
891
  description,
913
- contactItems = DEFAULT_CONTACT_ITEMS,
892
+ contactItems,
914
893
  buttonText = "Submit Emergency Request",
915
894
  buttonIcon,
916
- actions,
917
- actionsSlot,
918
- formFields = DEFAULT_FORM_FIELDS,
919
- successMessage = "Thank you! Your emergency request has been received.",
895
+ formEngineSetup,
920
896
  className,
921
897
  headerClassName,
922
898
  headingClassName,
923
899
  descriptionClassName,
924
- formClassName,
925
- submitClassName,
926
- successMessageClassName,
927
- errorMessageClassName,
928
- spacing = "py-8 md:py-32",
929
- containerClassName = "w-full max-w-full relative z-10 px-6 sm:px-6 md:px-8 lg:px-8",
900
+ spacing = "py-16 md:py-32",
901
+ containerClassName = "px-6 sm:px-6 md:px-8 lg:px-8",
930
902
  background,
931
903
  pattern,
932
- patternOpacity,
933
- formConfig,
934
- onSubmit,
935
- onSuccess,
936
- onError
904
+ patternOpacity
937
905
  }) {
938
- const {
939
- uploadTokens,
940
- uploadProgress,
941
- isUploading,
942
- uploadFiles,
943
- removeFile,
944
- resetUpload
945
- } = useFileUpload({ onError });
946
- const { form, submissionError, formMethod, resetSubmissionState } = useContactForm({
947
- formFields,
948
- formConfig,
949
- onSubmit,
950
- onSuccess: (data) => {
951
- resetUpload();
952
- onSuccess?.(data);
953
- },
954
- onError,
955
- resetOnSuccess: formConfig?.resetOnSuccess !== false,
956
- uploadTokens
957
- });
958
- const otherFields = formFields.filter((f) => f.name !== "priority");
959
- const actionsContent = useMemo(() => {
960
- if (actionsSlot) return actionsSlot;
961
- if (actions && actions.length > 0) {
962
- return actions.map((action, index) => {
963
- const {
964
- label,
965
- icon,
966
- iconAfter,
967
- children,
968
- className: actionClassName,
969
- ...pressableProps
970
- } = action;
971
- return /* @__PURE__ */ jsx(
972
- Pressable,
973
- {
974
- asButton: true,
975
- className: actionClassName,
976
- ...pressableProps,
977
- children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
978
- icon,
979
- label,
980
- iconAfter
981
- ] })
982
- },
983
- index
984
- );
985
- });
906
+ const formStyleRules = React.useMemo(() => {
907
+ return {
908
+ formContainer: formEngineSetup?.formLayoutSettings?.styleRules?.formContainer ?? DEFAULT_STYLE_RULES.formContainer,
909
+ fieldsContainer: formEngineSetup?.formLayoutSettings?.styleRules?.fieldsContainer ?? DEFAULT_STYLE_RULES.fieldsContainer,
910
+ fieldClassName: formEngineSetup?.formLayoutSettings?.styleRules?.fieldClassName ?? DEFAULT_STYLE_RULES.fieldClassName,
911
+ formClassName: formEngineSetup?.formLayoutSettings?.styleRules?.formClassName ?? DEFAULT_STYLE_RULES.formClassName,
912
+ successMessageClassName: formEngineSetup?.formLayoutSettings?.styleRules?.successMessageClassName ?? DEFAULT_STYLE_RULES.successMessageClassName,
913
+ errorMessageClassName: formEngineSetup?.formLayoutSettings?.styleRules?.errorMessageClassName ?? DEFAULT_STYLE_RULES.errorMessageClassName
914
+ };
915
+ }, [formEngineSetup?.formLayoutSettings?.styleRules]);
916
+ const formFields = React.useMemo(() => {
917
+ if (formEngineSetup?.fields && formEngineSetup.fields.length > 0) {
918
+ return formEngineSetup.fields;
986
919
  }
987
- return null;
988
- }, [actionsSlot, actions]);
920
+ return DEFAULT_FORM_FIELDS;
921
+ }, [formEngineSetup?.fields]);
989
922
  return /* @__PURE__ */ jsx(
990
923
  Section,
991
924
  {
@@ -995,126 +928,87 @@ function ContactEmergency({
995
928
  patternOpacity,
996
929
  className,
997
930
  containerClassName,
998
- children: /* @__PURE__ */ jsx("div", { className: "relative", children: /* @__PURE__ */ jsxs(
999
- Form,
1000
- {
1001
- form,
1002
- notificationConfig: {
1003
- submissionError,
1004
- successMessage
1005
- },
1006
- styleConfig: {
1007
- formClassName,
1008
- successMessageClassName,
1009
- errorMessageClassName
1010
- },
1011
- formConfig: {
1012
- endpoint: formConfig?.endpoint,
1013
- method: formMethod,
1014
- submissionConfig: formConfig?.submissionConfig
1015
- },
1016
- onNewSubmission: () => {
1017
- resetUpload();
1018
- resetSubmissionState();
1019
- },
1020
- children: [
1021
- /* @__PURE__ */ jsx("div", { className: "flex", children: /* @__PURE__ */ jsxs("div", { className: cn("p-0 md:p-12"), children: [
1022
- /* @__PURE__ */ jsx("div", { className: "grid md:grid-cols-2 gap-12 md:gap-24", children: /* @__PURE__ */ jsx("div", { className: "border-b border-border/60 p-6 md:border-b-0 md:border-r md:border-border/60", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col items-start gap-8 md:gap-12", children: /* @__PURE__ */ jsxs(
1023
- "div",
1024
- {
1025
- className: cn(
1026
- "flex flex-col items-start gap-4 text-left",
1027
- headerClassName
1028
- ),
1029
- children: [
1030
- heading && (typeof heading === "string" ? /* @__PURE__ */ jsx(
1031
- "h2",
1032
- {
1033
- className: cn(
1034
- "text-4xl lg:text-5xl xl:text-6xl font-bold",
1035
- headingClassName
1036
- ),
1037
- children: heading
1038
- }
1039
- ) : heading),
1040
- description && (typeof description === "string" ? /* @__PURE__ */ jsx(
1041
- "p",
1042
- {
1043
- className: cn(
1044
- "leading-relaxed",
1045
- descriptionClassName
1046
- ),
1047
- children: description
1048
- }
1049
- ) : description)
1050
- ]
1051
- }
1052
- ) }) }) }),
1053
- contactItems && contactItems.length > 0 && /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4 md:gap-6 w-full", children: contactItems.map((item, index) => /* @__PURE__ */ jsx(
1054
- Pressable,
1055
- {
1056
- href: item.href,
1057
- className: cn(
1058
- "rounded-md border bg-muted ring-2",
1059
- "text-muted-foreground px-4 py-3 flex",
1060
- "justify-start items-start transition-shadow",
1061
- "duration-500 hover:shadow-xl",
1062
- item.className
1063
- ),
1064
- children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
1065
- item.icon ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-2 rounded-xl border bg-primary text-primary-foreground", children: /* @__PURE__ */ jsx(
1066
- DynamicIcon,
1067
- {
1068
- name: item.icon,
1069
- size: item.iconSize ?? 24
1070
- }
1071
- ) }) : null,
1072
- /* @__PURE__ */ jsxs("div", { children: [
1073
- /* @__PURE__ */ jsx("p", { className: "font-bold text-xs uppercase opacity-70", children: item.title }),
1074
- /* @__PURE__ */ jsx("p", { className: "text-md font-semibold", children: item.subtitle })
1075
- ] })
1076
- ] })
1077
- },
1078
- index
1079
- )) })
1080
- ] }) }),
1081
- /* @__PURE__ */ jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
1082
- /* @__PURE__ */ jsx("div", { className: "grid grid-cols-12 gap-4", children: otherFields.map((field) => /* @__PURE__ */ jsx(
1083
- "div",
1084
- {
1085
- className: getColumnSpanClass(field.columnSpan),
1086
- children: /* @__PURE__ */ jsx(
1087
- DynamicFormField,
1088
- {
1089
- field,
1090
- uploadProgress,
1091
- onFileUpload: uploadFiles,
1092
- onFileRemove: removeFile,
1093
- isUploading
1094
- }
1095
- )
1096
- },
1097
- field.name
1098
- )) }),
1099
- actionsSlot || actions && actions.length > 0 ? actionsContent : /* @__PURE__ */ jsxs(
1100
- Pressable,
1101
- {
1102
- componentType: "button",
1103
- type: "submit",
1104
- className: cn("w-full", submitClassName),
1105
- size: "lg",
1106
- asButton: true,
1107
- disabled: form.isSubmitting,
1108
- children: [
1109
- buttonIcon,
1110
- buttonText
1111
- ]
1112
- }
1113
- )
1114
- ] }) })
1115
- ]
1116
- }
1117
- ) })
931
+ children: /* @__PURE__ */ jsxs("div", { className: "grid md:grid-cols-2 gap-12 md:gap-28", children: [
932
+ /* @__PURE__ */ jsx("div", { className: "h-full", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-start justify-between h-full gap-8 md:gap-12", children: [
933
+ /* @__PURE__ */ jsxs(
934
+ "div",
935
+ {
936
+ className: cn(
937
+ "flex flex-col items-start gap-4 text-left",
938
+ headerClassName
939
+ ),
940
+ children: [
941
+ heading && (typeof heading === "string" ? /* @__PURE__ */ jsx(
942
+ "h2",
943
+ {
944
+ className: cn(
945
+ "text-4xl lg:text-5xl xl:text-6xl font-bold text-pretty",
946
+ headingClassName
947
+ ),
948
+ children: heading
949
+ }
950
+ ) : heading),
951
+ description && (typeof description === "string" ? /* @__PURE__ */ jsx(
952
+ "p",
953
+ {
954
+ className: cn(
955
+ "leading-relaxed text-pretty md:text-balance text-lg",
956
+ descriptionClassName
957
+ ),
958
+ children: description
959
+ }
960
+ ) : description)
961
+ ]
962
+ }
963
+ ),
964
+ contactItems && contactItems.length > 0 && /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 gap-4 md:gap-6 w-full", children: contactItems.map((item, index) => /* @__PURE__ */ jsx(
965
+ Pressable,
966
+ {
967
+ href: item.href,
968
+ className: cn(
969
+ "rounded-xl border bg-transparent hover:bg-muted ring-2",
970
+ "px-4 py-4 flex",
971
+ "justify-start items-start transition-all",
972
+ "duration-500 hover:text-muted-foreground",
973
+ item.className
974
+ ),
975
+ children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4", children: [
976
+ item.icon ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-2 rounded-xl border bg-primary text-primary-foreground", children: /* @__PURE__ */ jsx(
977
+ DynamicIcon,
978
+ {
979
+ name: item.icon,
980
+ size: item.iconSize ?? 24
981
+ }
982
+ ) }) : null,
983
+ /* @__PURE__ */ jsxs("div", { children: [
984
+ /* @__PURE__ */ jsx("p", { className: "font-bold text-xs uppercase opacity-70", children: item.title }),
985
+ /* @__PURE__ */ jsx("p", { className: "text-md font-medium", children: item.subtitle })
986
+ ] })
987
+ ] })
988
+ },
989
+ index
990
+ )) })
991
+ ] }) }),
992
+ /* @__PURE__ */ jsx("div", { className: "p-6", children: formEngineSetup ? /* @__PURE__ */ jsx(
993
+ FormEngine,
994
+ {
995
+ ...formEngineSetup,
996
+ formLayoutSettings: {
997
+ ...formEngineSetup.formLayoutSettings,
998
+ formLayout: "standard",
999
+ submitButtonSetup: {
1000
+ ...formEngineSetup.formLayoutSettings?.submitButtonSetup,
1001
+ submitLabel: /* @__PURE__ */ jsxs(Fragment, { children: [
1002
+ buttonIcon,
1003
+ buttonText
1004
+ ] })
1005
+ },
1006
+ styleRules: formStyleRules
1007
+ },
1008
+ fields: formFields
1009
+ }
1010
+ ) : null })
1011
+ ] })
1118
1012
  }
1119
1013
  );
1120
1014
  }
@@ -677,7 +677,7 @@ function ContactFaq({
677
677
  ),
678
678
  children: formHeading
679
679
  }
680
- ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: formHeadingClassName, children: formHeading })),
680
+ ) : formHeading),
681
681
  formEngineSetup ? /* @__PURE__ */ jsxRuntime.jsx(
682
682
  integration.FormEngine,
683
683
  {
@@ -655,7 +655,7 @@ function ContactFaq({
655
655
  ),
656
656
  children: formHeading
657
657
  }
658
- ) : /* @__PURE__ */ jsx("div", { className: formHeadingClassName, children: formHeading })),
658
+ ) : formHeading),
659
659
  formEngineSetup ? /* @__PURE__ */ jsx(
660
660
  FormEngine,
661
661
  {