@opensite/ui 1.9.8 → 2.0.0

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.
Files changed (131) hide show
  1. package/dist/contact-demo.cjs +106 -406
  2. package/dist/contact-demo.d.cts +36 -111
  3. package/dist/contact-demo.d.ts +36 -111
  4. package/dist/contact-demo.js +108 -405
  5. package/dist/contact-emergency.cjs +129 -158
  6. package/dist/contact-emergency.d.cts +23 -12
  7. package/dist/contact-emergency.d.ts +23 -12
  8. package/dist/contact-emergency.js +131 -159
  9. package/dist/contact-event.cjs +106 -147
  10. package/dist/contact-event.d.cts +36 -66
  11. package/dist/contact-event.d.ts +36 -66
  12. package/dist/contact-event.js +108 -148
  13. package/dist/contact-feedback.cjs +109 -102
  14. package/dist/contact-feedback.d.cts +36 -63
  15. package/dist/contact-feedback.d.ts +36 -63
  16. package/dist/contact-feedback.js +111 -103
  17. package/dist/contact-fitness.cjs +107 -148
  18. package/dist/contact-fitness.d.cts +36 -66
  19. package/dist/contact-fitness.d.ts +36 -66
  20. package/dist/contact-fitness.js +109 -149
  21. package/dist/contact-guest.cjs +107 -148
  22. package/dist/contact-guest.d.cts +35 -65
  23. package/dist/contact-guest.d.ts +35 -65
  24. package/dist/contact-guest.js +109 -149
  25. package/dist/contact-image.cjs +108 -149
  26. package/dist/contact-image.d.cts +35 -65
  27. package/dist/contact-image.d.ts +35 -65
  28. package/dist/contact-image.js +110 -150
  29. package/dist/contact-insurance.cjs +107 -148
  30. package/dist/contact-insurance.d.cts +36 -66
  31. package/dist/contact-insurance.d.ts +36 -66
  32. package/dist/contact-insurance.js +109 -149
  33. package/dist/contact-interview.cjs +106 -147
  34. package/dist/contact-interview.d.cts +20 -12
  35. package/dist/contact-interview.d.ts +20 -12
  36. package/dist/contact-interview.js +108 -148
  37. package/dist/contact-locations.cjs +106 -147
  38. package/dist/contact-locations.d.cts +21 -13
  39. package/dist/contact-locations.d.ts +21 -13
  40. package/dist/contact-locations.js +108 -148
  41. package/dist/contact-maintenance.cjs +103 -143
  42. package/dist/contact-maintenance.d.cts +21 -13
  43. package/dist/contact-maintenance.d.ts +21 -13
  44. package/dist/contact-maintenance.js +105 -144
  45. package/dist/contact-map.cjs +103 -143
  46. package/dist/contact-map.d.cts +20 -12
  47. package/dist/contact-map.d.ts +20 -12
  48. package/dist/contact-map.js +105 -144
  49. package/dist/contact-minimal.cjs +126 -242
  50. package/dist/contact-minimal.d.cts +36 -70
  51. package/dist/contact-minimal.d.ts +36 -70
  52. package/dist/contact-minimal.js +128 -243
  53. package/dist/contact-moving.cjs +103 -143
  54. package/dist/contact-moving.d.cts +20 -12
  55. package/dist/contact-moving.d.ts +20 -12
  56. package/dist/contact-moving.js +105 -144
  57. package/dist/contact-multistep.cjs +104 -144
  58. package/dist/contact-multistep.d.cts +21 -13
  59. package/dist/contact-multistep.d.ts +21 -13
  60. package/dist/contact-multistep.js +106 -145
  61. package/dist/contact-partnership.cjs +103 -143
  62. package/dist/contact-partnership.d.cts +19 -11
  63. package/dist/contact-partnership.d.ts +19 -11
  64. package/dist/contact-partnership.js +105 -144
  65. package/dist/contact-press.cjs +144 -150
  66. package/dist/contact-press.d.cts +21 -13
  67. package/dist/contact-press.d.ts +21 -13
  68. package/dist/contact-press.js +146 -151
  69. package/dist/contact-quote.cjs +144 -150
  70. package/dist/contact-quote.d.cts +19 -11
  71. package/dist/contact-quote.d.ts +19 -11
  72. package/dist/contact-quote.js +146 -151
  73. package/dist/contact-referral.cjs +144 -150
  74. package/dist/contact-referral.d.cts +20 -12
  75. package/dist/contact-referral.d.ts +20 -12
  76. package/dist/contact-referral.js +146 -151
  77. package/dist/contact-report.cjs +144 -150
  78. package/dist/contact-report.d.cts +21 -13
  79. package/dist/contact-report.d.ts +21 -13
  80. package/dist/contact-report.js +146 -151
  81. package/dist/contact-reservation.cjs +144 -150
  82. package/dist/contact-reservation.d.cts +20 -12
  83. package/dist/contact-reservation.d.ts +20 -12
  84. package/dist/contact-reservation.js +146 -151
  85. package/dist/contact-retreat.cjs +144 -150
  86. package/dist/contact-retreat.d.cts +21 -13
  87. package/dist/contact-retreat.d.ts +21 -13
  88. package/dist/contact-retreat.js +146 -151
  89. package/dist/contact-rsvp.cjs +144 -150
  90. package/dist/contact-rsvp.d.cts +20 -12
  91. package/dist/contact-rsvp.d.ts +20 -12
  92. package/dist/contact-rsvp.js +146 -151
  93. package/dist/contact-sales.cjs +131 -146
  94. package/dist/contact-sales.d.cts +34 -65
  95. package/dist/contact-sales.d.ts +34 -65
  96. package/dist/contact-sales.js +133 -147
  97. package/dist/contact-schedule.cjs +144 -150
  98. package/dist/contact-schedule.d.cts +20 -12
  99. package/dist/contact-schedule.d.ts +20 -12
  100. package/dist/contact-schedule.js +146 -151
  101. package/dist/contact-sponsorship.cjs +144 -150
  102. package/dist/contact-sponsorship.d.cts +21 -13
  103. package/dist/contact-sponsorship.d.ts +21 -13
  104. package/dist/contact-sponsorship.js +146 -151
  105. package/dist/contact-support.cjs +147 -120
  106. package/dist/contact-support.d.cts +21 -12
  107. package/dist/contact-support.d.ts +21 -12
  108. package/dist/contact-support.js +149 -121
  109. package/dist/contact-tenant.cjs +144 -150
  110. package/dist/contact-tenant.d.cts +20 -12
  111. package/dist/contact-tenant.d.ts +20 -12
  112. package/dist/contact-tenant.js +146 -151
  113. package/dist/contact-vendor.cjs +144 -150
  114. package/dist/contact-vendor.d.cts +20 -12
  115. package/dist/contact-vendor.d.ts +20 -12
  116. package/dist/contact-vendor.js +146 -151
  117. package/dist/contact-volunteer.cjs +144 -150
  118. package/dist/contact-volunteer.d.cts +20 -12
  119. package/dist/contact-volunteer.d.ts +20 -12
  120. package/dist/contact-volunteer.js +146 -151
  121. package/dist/contact-warranty.cjs +144 -150
  122. package/dist/contact-warranty.d.cts +20 -12
  123. package/dist/contact-warranty.d.ts +20 -12
  124. package/dist/contact-warranty.js +146 -151
  125. package/dist/contact-wedding.cjs +144 -150
  126. package/dist/contact-wedding.d.cts +20 -12
  127. package/dist/contact-wedding.d.ts +20 -12
  128. package/dist/contact-wedding.js +146 -151
  129. package/dist/registry.cjs +5791 -5883
  130. package/dist/registry.js +4527 -4619
  131. package/package.json +2 -2
@@ -1,18 +1,14 @@
1
1
  "use client";
2
2
  import * as React from 'react';
3
- import React__default from 'react';
4
- import { useForm, Form, Field } from '@page-speed/forms';
5
- import { TextInput as TextInput$1, TextArea as TextArea$1 } from '@page-speed/forms/inputs';
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';
6
6
  import { clsx } from 'clsx';
7
7
  import { twMerge } from 'tailwind-merge';
8
8
  import { cva } from 'class-variance-authority';
9
9
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
10
- import * as LabelPrimitive from '@radix-ui/react-label';
11
- import { submitPageSpeedForm, PageSpeedFormSubmissionError } from '@page-speed/forms/integration';
12
10
 
13
11
  // components/blocks/contact/contact-wedding.tsx
14
- var TextInput = TextInput$1;
15
- var TextArea = TextArea$1;
16
12
  function cn(...inputs) {
17
13
  return twMerge(clsx(inputs));
18
14
  }
@@ -457,22 +453,6 @@ function CardContent({ className, ...props }) {
457
453
  }
458
454
  );
459
455
  }
460
- function Label({
461
- className,
462
- ...props
463
- }) {
464
- return /* @__PURE__ */ jsx(
465
- LabelPrimitive.Root,
466
- {
467
- "data-slot": "label",
468
- className: cn(
469
- "flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
470
- className
471
- ),
472
- ...props
473
- }
474
- );
475
- }
476
456
  var maxWidthStyles = {
477
457
  sm: "max-w-screen-sm",
478
458
  md: "max-w-screen-md",
@@ -848,15 +828,60 @@ var Section = React__default.forwardRef(
848
828
  }
849
829
  );
850
830
  Section.displayName = "Section";
831
+ var DEFAULT_FORM_FIELDS = [
832
+ {
833
+ name: "first_name",
834
+ type: "text",
835
+ label: "First Name",
836
+ placeholder: "John",
837
+ required: true,
838
+ columnSpan: 6
839
+ },
840
+ {
841
+ name: "last_name",
842
+ type: "text",
843
+ label: "Last Name",
844
+ placeholder: "Doe",
845
+ required: true,
846
+ columnSpan: 6
847
+ },
848
+ {
849
+ name: "email",
850
+ type: "email",
851
+ label: "Email",
852
+ placeholder: "john@example.com",
853
+ required: true,
854
+ columnSpan: 12
855
+ },
856
+ {
857
+ name: "phone",
858
+ type: "tel",
859
+ label: "Phone",
860
+ placeholder: "+1 (555) 000-0000",
861
+ required: true,
862
+ columnSpan: 12
863
+ },
864
+ {
865
+ name: "message",
866
+ type: "textarea",
867
+ label: "Message",
868
+ placeholder: "Your message...",
869
+ required: true,
870
+ rows: 4,
871
+ columnSpan: 12
872
+ }
873
+ ];
851
874
  function ContactWedding({
852
875
  heading,
853
876
  description,
854
- buttonText,
877
+ buttonText = "Submit",
855
878
  buttonIcon,
856
879
  actions,
857
880
  actionsSlot,
881
+ formFields = DEFAULT_FORM_FIELDS,
882
+ successMessage = "Thank you! Your message has been sent successfully.",
858
883
  className,
859
- containerClassName,
884
+ containerClassName = "px-6 sm:px-6 md:px-8 lg:px-8",
860
885
  headerClassName,
861
886
  headingClassName,
862
887
  descriptionClassName,
@@ -864,6 +889,8 @@ function ContactWedding({
864
889
  cardContentClassName,
865
890
  formClassName,
866
891
  submitClassName,
892
+ successMessageClassName,
893
+ errorMessageClassName,
867
894
  background = "white",
868
895
  spacing = "xl",
869
896
  pattern,
@@ -873,65 +900,52 @@ function ContactWedding({
873
900
  onSuccess,
874
901
  onError
875
902
  }) {
876
- const form = useForm({
877
- initialValues: {
878
- first_name: "",
879
- last_name: "",
880
- email: "",
881
- phone: "",
882
- message: ""
883
- },
884
- validationSchema: {
885
- first_name: (value) => !value ? "First name is required" : void 0,
886
- last_name: (value) => !value ? "Last name is required" : void 0,
887
- email: (value) => {
888
- if (!value) return "Email is required";
889
- if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value))
890
- return "Please enter a valid email address";
891
- return void 0;
892
- },
893
- phone: (value) => !value ? "Phone is required" : void 0,
894
- message: (value) => !value ? "Message is required" : void 0
903
+ const {
904
+ uploadTokens,
905
+ uploadProgress,
906
+ isUploading,
907
+ uploadFiles,
908
+ removeFile,
909
+ resetUpload
910
+ } = useFileUpload({ onError });
911
+ const { form, submissionError, formMethod, resetSubmissionState } = useContactForm({
912
+ formFields,
913
+ formConfig,
914
+ onSubmit,
915
+ onSuccess: (data) => {
916
+ resetUpload();
917
+ onSuccess?.(data);
895
918
  },
896
- onSubmit: async (values, helpers) => {
897
- const shouldAutoSubmit = Boolean(formConfig?.endpoint);
898
- if (!shouldAutoSubmit && !onSubmit) {
899
- return;
900
- }
901
- try {
902
- let result;
903
- if (shouldAutoSubmit) {
904
- result = await submitPageSpeedForm(values, formConfig);
905
- }
906
- if (onSubmit) {
907
- await onSubmit(values);
908
- }
909
- if (shouldAutoSubmit || onSubmit) {
910
- if (formConfig?.resetOnSuccess !== false) {
911
- helpers.resetForm();
912
- }
913
- onSuccess?.(result);
914
- }
915
- } catch (error) {
916
- if (error instanceof PageSpeedFormSubmissionError && error.formErrors) {
917
- helpers.setErrors(error.formErrors);
918
- }
919
- onError?.(error);
920
- throw error;
921
- }
922
- }
919
+ onError,
920
+ resetOnSuccess: formConfig?.resetOnSuccess !== false,
921
+ uploadTokens
923
922
  });
924
- const formMethod = formConfig?.method?.toLowerCase() === "get" ? "get" : "post";
925
- const actionsContent = React.useMemo(() => {
923
+ const actionsContent = useMemo(() => {
926
924
  if (actionsSlot) return actionsSlot;
927
925
  if (actions && actions.length > 0) {
928
926
  return actions.map((action, index) => {
929
- const { label, icon, iconAfter, children, className: actionClassName, ...pressableProps } = action;
930
- return /* @__PURE__ */ jsx(Pressable, { asButton: true, className: actionClassName, ...pressableProps, children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
931
- icon,
927
+ const {
932
928
  label,
933
- iconAfter
934
- ] }) }, index);
929
+ icon,
930
+ iconAfter,
931
+ children,
932
+ className: actionClassName,
933
+ ...pressableProps
934
+ } = action;
935
+ return /* @__PURE__ */ jsx(
936
+ Pressable,
937
+ {
938
+ asButton: true,
939
+ className: actionClassName,
940
+ ...pressableProps,
941
+ children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
942
+ icon,
943
+ label,
944
+ iconAfter
945
+ ] })
946
+ },
947
+ index
948
+ );
935
949
  });
936
950
  }
937
951
  return null;
@@ -944,89 +958,70 @@ function ContactWedding({
944
958
  pattern,
945
959
  patternOpacity,
946
960
  className: cn("py-12", className),
947
- children: /* @__PURE__ */ jsxs("div", { className: cn("mx-auto max-w-4xl px-4", containerClassName), children: [
961
+ containerClassName,
962
+ children: /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-4xl", children: [
948
963
  /* @__PURE__ */ jsxs("div", { className: cn("mb-10 text-center", headerClassName), children: [
949
- /* @__PURE__ */ jsx("h2", { className: cn("mb-3 text-3xl font-bold tracking-tight", headingClassName), children: heading }),
950
- /* @__PURE__ */ jsx("p", { className: cn("leading-relaxed text-muted-foreground", descriptionClassName), children: description })
964
+ heading && (typeof heading === "string" ? /* @__PURE__ */ jsx(
965
+ "h2",
966
+ {
967
+ className: cn(
968
+ "mb-3 text-3xl font-bold tracking-tight text-balance",
969
+ headingClassName
970
+ ),
971
+ children: heading
972
+ }
973
+ ) : /* @__PURE__ */ jsx("div", { className: headingClassName, children: heading })),
974
+ description && (typeof description === "string" ? /* @__PURE__ */ jsx(
975
+ "p",
976
+ {
977
+ className: cn(
978
+ "leading-relaxed text-balance",
979
+ descriptionClassName
980
+ ),
981
+ children: description
982
+ }
983
+ ) : /* @__PURE__ */ jsx("div", { className: descriptionClassName, children: description }))
951
984
  ] }),
952
985
  /* @__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__ */ jsxs(
953
986
  Form,
954
987
  {
955
988
  form,
956
- action: formConfig?.endpoint,
957
- method: formMethod,
958
- className: cn("space-y-4", formClassName),
989
+ notificationConfig: {
990
+ submissionError,
991
+ successMessage
992
+ },
993
+ styleConfig: {
994
+ formClassName: cn("space-y-4", formClassName),
995
+ successMessageClassName,
996
+ errorMessageClassName
997
+ },
998
+ formConfig: {
999
+ endpoint: formConfig?.endpoint,
1000
+ method: formMethod,
1001
+ submissionConfig: formConfig?.submissionConfig
1002
+ },
1003
+ onNewSubmission: () => {
1004
+ resetUpload();
1005
+ resetSubmissionState();
1006
+ },
959
1007
  children: [
960
- /* @__PURE__ */ jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [
961
- /* @__PURE__ */ jsx(Field, { name: "first_name", children: ({ field, meta }) => /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
962
- /* @__PURE__ */ jsx(Label, { htmlFor: "first-name", children: "First Name" }),
963
- /* @__PURE__ */ jsx(
964
- TextInput,
965
- {
966
- ...field,
967
- id: "first-name",
968
- placeholder: "John",
969
- error: meta.touched && !!meta.error,
970
- "aria-label": "First Name"
971
- }
972
- )
973
- ] }) }),
974
- /* @__PURE__ */ jsx(Field, { name: "last_name", children: ({ field, meta }) => /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
975
- /* @__PURE__ */ jsx(Label, { htmlFor: "last-name", children: "Last Name" }),
976
- /* @__PURE__ */ jsx(
977
- TextInput,
1008
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-12 gap-6", children: formFields.map((field) => /* @__PURE__ */ jsx(
1009
+ "div",
1010
+ {
1011
+ className: getColumnSpanClass(field.columnSpan),
1012
+ children: /* @__PURE__ */ jsx(
1013
+ DynamicFormField,
978
1014
  {
979
- ...field,
980
- id: "last-name",
981
- placeholder: "Doe",
982
- error: meta.touched && !!meta.error,
983
- "aria-label": "Last Name"
1015
+ field,
1016
+ uploadProgress,
1017
+ onFileUpload: uploadFiles,
1018
+ onFileRemove: removeFile,
1019
+ isUploading
984
1020
  }
985
1021
  )
986
- ] }) })
987
- ] }),
988
- /* @__PURE__ */ jsx(Field, { name: "email", children: ({ field, meta }) => /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
989
- /* @__PURE__ */ jsx(Label, { htmlFor: "email", children: "Email" }),
990
- /* @__PURE__ */ jsx(
991
- TextInput,
992
- {
993
- ...field,
994
- id: "email",
995
- type: "email",
996
- placeholder: "john@example.com",
997
- error: meta.touched && !!meta.error,
998
- "aria-label": "Email"
999
- }
1000
- )
1001
- ] }) }),
1002
- /* @__PURE__ */ jsx(Field, { name: "phone", children: ({ field, meta }) => /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
1003
- /* @__PURE__ */ jsx(Label, { htmlFor: "phone", children: "Phone" }),
1004
- /* @__PURE__ */ jsx(
1005
- TextInput,
1006
- {
1007
- ...field,
1008
- id: "phone",
1009
- type: "tel",
1010
- placeholder: "+1 (555) 000-0000",
1011
- error: meta.touched && !!meta.error,
1012
- "aria-label": "Phone"
1013
- }
1014
- )
1015
- ] }) }),
1016
- /* @__PURE__ */ jsx(Field, { name: "message", children: ({ field, meta }) => /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
1017
- /* @__PURE__ */ jsx(Label, { htmlFor: "message", children: "Message" }),
1018
- /* @__PURE__ */ jsx(
1019
- TextArea,
1020
- {
1021
- ...field,
1022
- id: "message",
1023
- placeholder: "Your message...",
1024
- rows: 4,
1025
- error: meta.touched && !!meta.error,
1026
- "aria-label": "Message"
1027
- }
1028
- )
1029
- ] }) }),
1022
+ },
1023
+ field.name
1024
+ )) }),
1030
1025
  actionsSlot || actions && actions.length > 0 ? actionsContent : /* @__PURE__ */ jsxs(
1031
1026
  Pressable,
1032
1027
  {