@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.
@@ -2,7 +2,6 @@
2
2
  'use strict';
3
3
 
4
4
  var React = require('react');
5
- var forms = require('@page-speed/forms');
6
5
  var integration = require('@page-speed/forms/integration');
7
6
  var clsx = require('clsx');
8
7
  var tailwindMerge = require('tailwind-merge');
@@ -831,32 +830,12 @@ var Section = React__namespace.default.forwardRef(
831
830
  }
832
831
  );
833
832
  Section.displayName = "Section";
834
- var DEFAULT_CONTACT_ITEMS = [
835
- {
836
- icon: "lucide/phone",
837
- title: "Critical Hotline",
838
- subtitle: "+1 (555) 911-0000",
839
- href: "tel:+15559110000"
840
- },
841
- {
842
- icon: "lucide/mail",
843
- title: "Email Support",
844
- subtitle: "emergency@support.com",
845
- href: "mailto:emergency@support.com"
846
- },
847
- {
848
- icon: "lucide/message-circle",
849
- title: "Live Chat",
850
- subtitle: "24/7 Available",
851
- href: "#chat"
852
- },
853
- {
854
- icon: "lucide/map-pin",
855
- title: "Visit Us",
856
- subtitle: "123 Support Lane",
857
- href: "#location"
858
- }
859
- ];
833
+ var DEFAULT_STYLE_RULES = {
834
+ formContainer: "",
835
+ fieldsContainer: "",
836
+ fieldClassName: "",
837
+ formClassName: "space-y-4"
838
+ };
860
839
  var PRIORITIES = [
861
840
  {
862
841
  value: "critical",
@@ -931,82 +910,36 @@ var DEFAULT_FORM_FIELDS = [
931
910
  function ContactEmergency({
932
911
  heading,
933
912
  description,
934
- contactItems = DEFAULT_CONTACT_ITEMS,
913
+ contactItems,
935
914
  buttonText = "Submit Emergency Request",
936
915
  buttonIcon,
937
- actions,
938
- actionsSlot,
939
- formFields = DEFAULT_FORM_FIELDS,
940
- successMessage = "Thank you! Your emergency request has been received.",
916
+ formEngineSetup,
941
917
  className,
942
918
  headerClassName,
943
919
  headingClassName,
944
920
  descriptionClassName,
945
- formClassName,
946
- submitClassName,
947
- successMessageClassName,
948
- errorMessageClassName,
949
- spacing = "py-8 md:py-32",
950
- containerClassName = "w-full max-w-full relative z-10 px-6 sm:px-6 md:px-8 lg:px-8",
921
+ spacing = "py-16 md:py-32",
922
+ containerClassName = "px-6 sm:px-6 md:px-8 lg:px-8",
951
923
  background,
952
924
  pattern,
953
- patternOpacity,
954
- formConfig,
955
- onSubmit,
956
- onSuccess,
957
- onError
925
+ patternOpacity
958
926
  }) {
959
- const {
960
- uploadTokens,
961
- uploadProgress,
962
- isUploading,
963
- uploadFiles,
964
- removeFile,
965
- resetUpload
966
- } = integration.useFileUpload({ onError });
967
- const { form, submissionError, formMethod, resetSubmissionState } = integration.useContactForm({
968
- formFields,
969
- formConfig,
970
- onSubmit,
971
- onSuccess: (data) => {
972
- resetUpload();
973
- onSuccess?.(data);
974
- },
975
- onError,
976
- resetOnSuccess: formConfig?.resetOnSuccess !== false,
977
- uploadTokens
978
- });
979
- const otherFields = formFields.filter((f) => f.name !== "priority");
980
- const actionsContent = React.useMemo(() => {
981
- if (actionsSlot) return actionsSlot;
982
- if (actions && actions.length > 0) {
983
- return actions.map((action, index) => {
984
- const {
985
- label,
986
- icon,
987
- iconAfter,
988
- children,
989
- className: actionClassName,
990
- ...pressableProps
991
- } = action;
992
- return /* @__PURE__ */ jsxRuntime.jsx(
993
- Pressable,
994
- {
995
- asButton: true,
996
- className: actionClassName,
997
- ...pressableProps,
998
- children: children ?? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
999
- icon,
1000
- label,
1001
- iconAfter
1002
- ] })
1003
- },
1004
- index
1005
- );
1006
- });
927
+ const formStyleRules = React__namespace.useMemo(() => {
928
+ return {
929
+ formContainer: formEngineSetup?.formLayoutSettings?.styleRules?.formContainer ?? DEFAULT_STYLE_RULES.formContainer,
930
+ fieldsContainer: formEngineSetup?.formLayoutSettings?.styleRules?.fieldsContainer ?? DEFAULT_STYLE_RULES.fieldsContainer,
931
+ fieldClassName: formEngineSetup?.formLayoutSettings?.styleRules?.fieldClassName ?? DEFAULT_STYLE_RULES.fieldClassName,
932
+ formClassName: formEngineSetup?.formLayoutSettings?.styleRules?.formClassName ?? DEFAULT_STYLE_RULES.formClassName,
933
+ successMessageClassName: formEngineSetup?.formLayoutSettings?.styleRules?.successMessageClassName ?? DEFAULT_STYLE_RULES.successMessageClassName,
934
+ errorMessageClassName: formEngineSetup?.formLayoutSettings?.styleRules?.errorMessageClassName ?? DEFAULT_STYLE_RULES.errorMessageClassName
935
+ };
936
+ }, [formEngineSetup?.formLayoutSettings?.styleRules]);
937
+ const formFields = React__namespace.useMemo(() => {
938
+ if (formEngineSetup?.fields && formEngineSetup.fields.length > 0) {
939
+ return formEngineSetup.fields;
1007
940
  }
1008
- return null;
1009
- }, [actionsSlot, actions]);
941
+ return DEFAULT_FORM_FIELDS;
942
+ }, [formEngineSetup?.fields]);
1010
943
  return /* @__PURE__ */ jsxRuntime.jsx(
1011
944
  Section,
1012
945
  {
@@ -1016,126 +949,87 @@ function ContactEmergency({
1016
949
  patternOpacity,
1017
950
  className,
1018
951
  containerClassName,
1019
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative", children: /* @__PURE__ */ jsxRuntime.jsxs(
1020
- forms.Form,
1021
- {
1022
- form,
1023
- notificationConfig: {
1024
- submissionError,
1025
- successMessage
1026
- },
1027
- styleConfig: {
1028
- formClassName,
1029
- successMessageClassName,
1030
- errorMessageClassName
1031
- },
1032
- formConfig: {
1033
- endpoint: formConfig?.endpoint,
1034
- method: formMethod,
1035
- submissionConfig: formConfig?.submissionConfig
1036
- },
1037
- onNewSubmission: () => {
1038
- resetUpload();
1039
- resetSubmissionState();
1040
- },
1041
- children: [
1042
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("p-0 md:p-12"), children: [
1043
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid md:grid-cols-2 gap-12 md:gap-24", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-b border-border/60 p-6 md:border-b-0 md:border-r md:border-border/60", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col items-start gap-8 md:gap-12", children: /* @__PURE__ */ jsxRuntime.jsxs(
1044
- "div",
1045
- {
1046
- className: cn(
1047
- "flex flex-col items-start gap-4 text-left",
1048
- headerClassName
1049
- ),
1050
- children: [
1051
- heading && (typeof heading === "string" ? /* @__PURE__ */ jsxRuntime.jsx(
1052
- "h2",
1053
- {
1054
- className: cn(
1055
- "text-4xl lg:text-5xl xl:text-6xl font-bold",
1056
- headingClassName
1057
- ),
1058
- children: heading
1059
- }
1060
- ) : heading),
1061
- description && (typeof description === "string" ? /* @__PURE__ */ jsxRuntime.jsx(
1062
- "p",
1063
- {
1064
- className: cn(
1065
- "leading-relaxed",
1066
- descriptionClassName
1067
- ),
1068
- children: description
1069
- }
1070
- ) : description)
1071
- ]
1072
- }
1073
- ) }) }) }),
1074
- contactItems && contactItems.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4 md:gap-6 w-full", children: contactItems.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx(
1075
- Pressable,
1076
- {
1077
- href: item.href,
1078
- className: cn(
1079
- "rounded-md border bg-muted ring-2",
1080
- "text-muted-foreground px-4 py-3 flex",
1081
- "justify-start items-start transition-shadow",
1082
- "duration-500 hover:shadow-xl",
1083
- item.className
1084
- ),
1085
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
1086
- item.icon ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center p-2 rounded-xl border bg-primary text-primary-foreground", children: /* @__PURE__ */ jsxRuntime.jsx(
1087
- DynamicIcon,
1088
- {
1089
- name: item.icon,
1090
- size: item.iconSize ?? 24
1091
- }
1092
- ) }) : null,
1093
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1094
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-bold text-xs uppercase opacity-70", children: item.title }),
1095
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-md font-semibold", children: item.subtitle })
1096
- ] })
1097
- ] })
1098
- },
1099
- index
1100
- )) })
1101
- ] }) }),
1102
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
1103
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-12 gap-4", children: otherFields.map((field) => /* @__PURE__ */ jsxRuntime.jsx(
1104
- "div",
1105
- {
1106
- className: integration.getColumnSpanClass(field.columnSpan),
1107
- children: /* @__PURE__ */ jsxRuntime.jsx(
1108
- integration.DynamicFormField,
1109
- {
1110
- field,
1111
- uploadProgress,
1112
- onFileUpload: uploadFiles,
1113
- onFileRemove: removeFile,
1114
- isUploading
1115
- }
1116
- )
1117
- },
1118
- field.name
1119
- )) }),
1120
- actionsSlot || actions && actions.length > 0 ? actionsContent : /* @__PURE__ */ jsxRuntime.jsxs(
1121
- Pressable,
1122
- {
1123
- componentType: "button",
1124
- type: "submit",
1125
- className: cn("w-full", submitClassName),
1126
- size: "lg",
1127
- asButton: true,
1128
- disabled: form.isSubmitting,
1129
- children: [
1130
- buttonIcon,
1131
- buttonText
1132
- ]
1133
- }
1134
- )
1135
- ] }) })
1136
- ]
1137
- }
1138
- ) })
952
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid md:grid-cols-2 gap-12 md:gap-28", children: [
953
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-start justify-between h-full gap-8 md:gap-12", children: [
954
+ /* @__PURE__ */ jsxRuntime.jsxs(
955
+ "div",
956
+ {
957
+ className: cn(
958
+ "flex flex-col items-start gap-4 text-left",
959
+ headerClassName
960
+ ),
961
+ children: [
962
+ heading && (typeof heading === "string" ? /* @__PURE__ */ jsxRuntime.jsx(
963
+ "h2",
964
+ {
965
+ className: cn(
966
+ "text-4xl lg:text-5xl xl:text-6xl font-bold text-pretty",
967
+ headingClassName
968
+ ),
969
+ children: heading
970
+ }
971
+ ) : heading),
972
+ description && (typeof description === "string" ? /* @__PURE__ */ jsxRuntime.jsx(
973
+ "p",
974
+ {
975
+ className: cn(
976
+ "leading-relaxed text-pretty md:text-balance text-lg",
977
+ descriptionClassName
978
+ ),
979
+ children: description
980
+ }
981
+ ) : description)
982
+ ]
983
+ }
984
+ ),
985
+ contactItems && contactItems.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-1 gap-4 md:gap-6 w-full", children: contactItems.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx(
986
+ Pressable,
987
+ {
988
+ href: item.href,
989
+ className: cn(
990
+ "rounded-xl border bg-transparent hover:bg-muted ring-2",
991
+ "px-4 py-4 flex",
992
+ "justify-start items-start transition-all",
993
+ "duration-500 hover:text-muted-foreground",
994
+ item.className
995
+ ),
996
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4", children: [
997
+ item.icon ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center p-2 rounded-xl border bg-primary text-primary-foreground", children: /* @__PURE__ */ jsxRuntime.jsx(
998
+ DynamicIcon,
999
+ {
1000
+ name: item.icon,
1001
+ size: item.iconSize ?? 24
1002
+ }
1003
+ ) }) : null,
1004
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1005
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-bold text-xs uppercase opacity-70", children: item.title }),
1006
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-md font-medium", children: item.subtitle })
1007
+ ] })
1008
+ ] })
1009
+ },
1010
+ index
1011
+ )) })
1012
+ ] }) }),
1013
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6", children: formEngineSetup ? /* @__PURE__ */ jsxRuntime.jsx(
1014
+ integration.FormEngine,
1015
+ {
1016
+ ...formEngineSetup,
1017
+ formLayoutSettings: {
1018
+ ...formEngineSetup.formLayoutSettings,
1019
+ formLayout: "standard",
1020
+ submitButtonSetup: {
1021
+ ...formEngineSetup.formLayoutSettings?.submitButtonSetup,
1022
+ submitLabel: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1023
+ buttonIcon,
1024
+ buttonText
1025
+ ] })
1026
+ },
1027
+ styleRules: formStyleRules
1028
+ },
1029
+ fields: formFields
1030
+ }
1031
+ ) : null })
1032
+ ] })
1139
1033
  }
1140
1034
  );
1141
1035
  }
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
- import { FormFieldConfig, PageSpeedFormConfig } from '@page-speed/forms/integration';
2
+ import { FormEngineProps } from '@page-speed/forms/integration';
3
3
  import { f as SectionBackground, g as SectionSpacing, t as PatternName } from './community-initiatives-Bz_A5vLU.cjs';
4
- import { A as ActionConfig } from './blocks-Cohq4eio.cjs';
5
4
  import 'react/jsx-runtime';
5
+ import './blocks-Cohq4eio.cjs';
6
6
  import 'class-variance-authority';
7
7
  import './button-variants-lRElsmTc.cjs';
8
8
  import 'class-variance-authority/types';
@@ -59,23 +59,9 @@ interface ContactEmergencyProps {
59
59
  */
60
60
  buttonIcon?: React.ReactNode;
61
61
  /**
62
- * Array of action configurations for custom buttons
62
+ * Full form engine setup and props
63
63
  */
64
- actions?: ActionConfig[];
65
- /**
66
- * Custom slot for rendering actions (overrides actions array)
67
- */
68
- actionsSlot?: React.ReactNode;
69
- /**
70
- * Array of form field configurations
71
- * If not provided, defaults to: priority, name, email, phone, subject, description
72
- */
73
- formFields?: FormFieldConfig[];
74
- /**
75
- * Success message to display after form submission
76
- * @default "Thank you! Your emergency request has been received."
77
- */
78
- successMessage?: React.ReactNode;
64
+ formEngineSetup?: FormEngineProps;
79
65
  /**
80
66
  * Additional CSS classes for the section
81
67
  */
@@ -96,22 +82,6 @@ interface ContactEmergencyProps {
96
82
  * Additional CSS classes for the description
97
83
  */
98
84
  descriptionClassName?: string;
99
- /**
100
- * Additional CSS classes for the form
101
- */
102
- formClassName?: string;
103
- /**
104
- * Additional CSS classes for the submit button
105
- */
106
- submitClassName?: string;
107
- /**
108
- * Additional CSS classes for the success message
109
- */
110
- successMessageClassName?: string;
111
- /**
112
- * Additional CSS classes for the error message
113
- */
114
- errorMessageClassName?: string;
115
85
  /**
116
86
  * Background style for the section
117
87
  */
@@ -128,22 +98,6 @@ interface ContactEmergencyProps {
128
98
  * Pattern overlay opacity (0-1)
129
99
  */
130
100
  patternOpacity?: number;
131
- /**
132
- * Form configuration for PageSpeed forms
133
- */
134
- formConfig?: PageSpeedFormConfig;
135
- /**
136
- * Custom submit handler
137
- */
138
- onSubmit?: (values: Record<string, any>) => void | Promise<void>;
139
- /**
140
- * Success callback
141
- */
142
- onSuccess?: (data: unknown) => void;
143
- /**
144
- * Error callback
145
- */
146
- onError?: (error: Error) => void;
147
101
  }
148
102
  /**
149
103
  * ContactEmergency - Urgent support form with priority level selection.
@@ -153,10 +107,10 @@ interface ContactEmergencyProps {
153
107
  * ```tsx
154
108
  * <ContactEmergency
155
109
  * heading="Urgent Support"
156
- * formConfig={{ endpoint: "/api/emergency", format: "json" }}
110
+ * formEngineSetup={{ formConfig: { endpoint: "/api/emergency", format: "json" } }}
157
111
  * />
158
112
  * ```
159
113
  */
160
- declare function ContactEmergency({ heading, description, contactItems, buttonText, buttonIcon, actions, actionsSlot, formFields, successMessage, className, headerClassName, headingClassName, descriptionClassName, formClassName, submitClassName, successMessageClassName, errorMessageClassName, spacing, containerClassName, background, pattern, patternOpacity, formConfig, onSubmit, onSuccess, onError, }: ContactEmergencyProps): React.JSX.Element;
114
+ declare function ContactEmergency({ heading, description, contactItems, buttonText, buttonIcon, formEngineSetup, className, headerClassName, headingClassName, descriptionClassName, spacing, containerClassName, background, pattern, patternOpacity, }: ContactEmergencyProps): React.JSX.Element;
161
115
 
162
116
  export { ContactEmergency, type ContactEmergencyProps };
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
- import { FormFieldConfig, PageSpeedFormConfig } from '@page-speed/forms/integration';
2
+ import { FormEngineProps } from '@page-speed/forms/integration';
3
3
  import { f as SectionBackground, g as SectionSpacing, t as PatternName } from './community-initiatives-Bi_ClKrO.js';
4
- import { A as ActionConfig } from './blocks-k17uluAz.js';
5
4
  import 'react/jsx-runtime';
5
+ import './blocks-k17uluAz.js';
6
6
  import 'class-variance-authority';
7
7
  import './button-variants-lRElsmTc.js';
8
8
  import 'class-variance-authority/types';
@@ -59,23 +59,9 @@ interface ContactEmergencyProps {
59
59
  */
60
60
  buttonIcon?: React.ReactNode;
61
61
  /**
62
- * Array of action configurations for custom buttons
62
+ * Full form engine setup and props
63
63
  */
64
- actions?: ActionConfig[];
65
- /**
66
- * Custom slot for rendering actions (overrides actions array)
67
- */
68
- actionsSlot?: React.ReactNode;
69
- /**
70
- * Array of form field configurations
71
- * If not provided, defaults to: priority, name, email, phone, subject, description
72
- */
73
- formFields?: FormFieldConfig[];
74
- /**
75
- * Success message to display after form submission
76
- * @default "Thank you! Your emergency request has been received."
77
- */
78
- successMessage?: React.ReactNode;
64
+ formEngineSetup?: FormEngineProps;
79
65
  /**
80
66
  * Additional CSS classes for the section
81
67
  */
@@ -96,22 +82,6 @@ interface ContactEmergencyProps {
96
82
  * Additional CSS classes for the description
97
83
  */
98
84
  descriptionClassName?: string;
99
- /**
100
- * Additional CSS classes for the form
101
- */
102
- formClassName?: string;
103
- /**
104
- * Additional CSS classes for the submit button
105
- */
106
- submitClassName?: string;
107
- /**
108
- * Additional CSS classes for the success message
109
- */
110
- successMessageClassName?: string;
111
- /**
112
- * Additional CSS classes for the error message
113
- */
114
- errorMessageClassName?: string;
115
85
  /**
116
86
  * Background style for the section
117
87
  */
@@ -128,22 +98,6 @@ interface ContactEmergencyProps {
128
98
  * Pattern overlay opacity (0-1)
129
99
  */
130
100
  patternOpacity?: number;
131
- /**
132
- * Form configuration for PageSpeed forms
133
- */
134
- formConfig?: PageSpeedFormConfig;
135
- /**
136
- * Custom submit handler
137
- */
138
- onSubmit?: (values: Record<string, any>) => void | Promise<void>;
139
- /**
140
- * Success callback
141
- */
142
- onSuccess?: (data: unknown) => void;
143
- /**
144
- * Error callback
145
- */
146
- onError?: (error: Error) => void;
147
101
  }
148
102
  /**
149
103
  * ContactEmergency - Urgent support form with priority level selection.
@@ -153,10 +107,10 @@ interface ContactEmergencyProps {
153
107
  * ```tsx
154
108
  * <ContactEmergency
155
109
  * heading="Urgent Support"
156
- * formConfig={{ endpoint: "/api/emergency", format: "json" }}
110
+ * formEngineSetup={{ formConfig: { endpoint: "/api/emergency", format: "json" } }}
157
111
  * />
158
112
  * ```
159
113
  */
160
- declare function ContactEmergency({ heading, description, contactItems, buttonText, buttonIcon, actions, actionsSlot, formFields, successMessage, className, headerClassName, headingClassName, descriptionClassName, formClassName, submitClassName, successMessageClassName, errorMessageClassName, spacing, containerClassName, background, pattern, patternOpacity, formConfig, onSubmit, onSuccess, onError, }: ContactEmergencyProps): React.JSX.Element;
114
+ declare function ContactEmergency({ heading, description, contactItems, buttonText, buttonIcon, formEngineSetup, className, headerClassName, headingClassName, descriptionClassName, spacing, containerClassName, background, pattern, patternOpacity, }: ContactEmergencyProps): React.JSX.Element;
161
115
 
162
116
  export { ContactEmergency, type ContactEmergencyProps };