@page-speed/forms 0.6.7 → 0.6.9

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.
package/dist/inputs.cjs CHANGED
@@ -1,53 +1,53 @@
1
1
  'use strict';
2
2
 
3
- var chunkUQ6JPOBF_cjs = require('./chunk-UQ6JPOBF.cjs');
3
+ var chunkI4EKHIVF_cjs = require('./chunk-I4EKHIVF.cjs');
4
4
  var chunkQMWZLGON_cjs = require('./chunk-QMWZLGON.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "Checkbox", {
9
9
  enumerable: true,
10
- get: function () { return chunkUQ6JPOBF_cjs.Checkbox; }
10
+ get: function () { return chunkI4EKHIVF_cjs.Checkbox; }
11
11
  });
12
12
  Object.defineProperty(exports, "CheckboxGroup", {
13
13
  enumerable: true,
14
- get: function () { return chunkUQ6JPOBF_cjs.CheckboxGroup; }
14
+ get: function () { return chunkI4EKHIVF_cjs.CheckboxGroup; }
15
15
  });
16
16
  Object.defineProperty(exports, "DatePicker", {
17
17
  enumerable: true,
18
- get: function () { return chunkUQ6JPOBF_cjs.DatePicker; }
18
+ get: function () { return chunkI4EKHIVF_cjs.DatePicker; }
19
19
  });
20
20
  Object.defineProperty(exports, "DateRangePicker", {
21
21
  enumerable: true,
22
- get: function () { return chunkUQ6JPOBF_cjs.DateRangePicker; }
22
+ get: function () { return chunkI4EKHIVF_cjs.DateRangePicker; }
23
23
  });
24
24
  Object.defineProperty(exports, "FileInput", {
25
25
  enumerable: true,
26
- get: function () { return chunkUQ6JPOBF_cjs.FileInput; }
26
+ get: function () { return chunkI4EKHIVF_cjs.FileInput; }
27
27
  });
28
28
  Object.defineProperty(exports, "MultiSelect", {
29
29
  enumerable: true,
30
- get: function () { return chunkUQ6JPOBF_cjs.MultiSelect; }
30
+ get: function () { return chunkI4EKHIVF_cjs.MultiSelect; }
31
31
  });
32
32
  Object.defineProperty(exports, "Radio", {
33
33
  enumerable: true,
34
- get: function () { return chunkUQ6JPOBF_cjs.Radio; }
34
+ get: function () { return chunkI4EKHIVF_cjs.Radio; }
35
35
  });
36
36
  Object.defineProperty(exports, "Select", {
37
37
  enumerable: true,
38
- get: function () { return chunkUQ6JPOBF_cjs.Select; }
38
+ get: function () { return chunkI4EKHIVF_cjs.Select; }
39
39
  });
40
40
  Object.defineProperty(exports, "Switch", {
41
41
  enumerable: true,
42
- get: function () { return chunkUQ6JPOBF_cjs.Switch; }
42
+ get: function () { return chunkI4EKHIVF_cjs.Switch; }
43
43
  });
44
44
  Object.defineProperty(exports, "TextArea", {
45
45
  enumerable: true,
46
- get: function () { return chunkUQ6JPOBF_cjs.TextArea; }
46
+ get: function () { return chunkI4EKHIVF_cjs.TextArea; }
47
47
  });
48
48
  Object.defineProperty(exports, "TimePicker", {
49
49
  enumerable: true,
50
- get: function () { return chunkUQ6JPOBF_cjs.TimePicker; }
50
+ get: function () { return chunkI4EKHIVF_cjs.TimePicker; }
51
51
  });
52
52
  Object.defineProperty(exports, "TextInput", {
53
53
  enumerable: true,
package/dist/inputs.js CHANGED
@@ -1,4 +1,4 @@
1
- export { Checkbox, CheckboxGroup, DatePicker, DateRangePicker, FileInput, MultiSelect, Radio, Select, Switch, TextArea, TimePicker } from './chunk-ML6FGUYS.js';
1
+ export { Checkbox, CheckboxGroup, DatePicker, DateRangePicker, FileInput, MultiSelect, Radio, Select, Switch, TextArea, TimePicker } from './chunk-AI5Q4N6D.js';
2
2
  export { TextInput } from './chunk-J37BGNM6.js';
3
3
  //# sourceMappingURL=inputs.js.map
4
4
  //# sourceMappingURL=inputs.js.map
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkL4I35PDU_cjs = require('./chunk-L4I35PDU.cjs');
4
- var chunkUQ6JPOBF_cjs = require('./chunk-UQ6JPOBF.cjs');
4
+ var chunkI4EKHIVF_cjs = require('./chunk-I4EKHIVF.cjs');
5
5
  var chunkQMWZLGON_cjs = require('./chunk-QMWZLGON.cjs');
6
6
  var React2 = require('react');
7
7
 
@@ -674,7 +674,7 @@ function DynamicFormField({
674
674
  "aria-label": field.label
675
675
  }
676
676
  ), field.type === "textarea" && /* @__PURE__ */ React2__namespace.createElement(
677
- chunkUQ6JPOBF_cjs.TextArea,
677
+ chunkI4EKHIVF_cjs.TextArea,
678
678
  {
679
679
  ...formField,
680
680
  id: fieldId,
@@ -685,7 +685,7 @@ function DynamicFormField({
685
685
  "aria-label": field.label
686
686
  }
687
687
  ), field.type === "select" && field.options && /* @__PURE__ */ React2__namespace.createElement(
688
- chunkUQ6JPOBF_cjs.Select,
688
+ chunkI4EKHIVF_cjs.Select,
689
689
  {
690
690
  ...formField,
691
691
  id: fieldId,
@@ -696,7 +696,7 @@ function DynamicFormField({
696
696
  "aria-label": field.label
697
697
  }
698
698
  ), field.type === "multi-select" && field.options && /* @__PURE__ */ React2__namespace.createElement(
699
- chunkUQ6JPOBF_cjs.MultiSelect,
699
+ chunkI4EKHIVF_cjs.MultiSelect,
700
700
  {
701
701
  ...formField,
702
702
  id: fieldId,
@@ -707,7 +707,7 @@ function DynamicFormField({
707
707
  "aria-label": field.label
708
708
  }
709
709
  ), field.type === "radio" && field.options && /* @__PURE__ */ React2__namespace.createElement(
710
- chunkUQ6JPOBF_cjs.Radio,
710
+ chunkI4EKHIVF_cjs.Radio,
711
711
  {
712
712
  ...formField,
713
713
  id: fieldId,
@@ -721,7 +721,7 @@ function DynamicFormField({
721
721
  "aria-label": field.label
722
722
  }
723
723
  ), field.type === "checkbox" && /* @__PURE__ */ React2__namespace.createElement(
724
- chunkUQ6JPOBF_cjs.Checkbox,
724
+ chunkI4EKHIVF_cjs.Checkbox,
725
725
  {
726
726
  ...formField,
727
727
  id: fieldId,
@@ -735,7 +735,7 @@ function DynamicFormField({
735
735
  "aria-label": field.label
736
736
  }
737
737
  ), field.type === "checkbox-group" && field.options && /* @__PURE__ */ React2__namespace.createElement(
738
- chunkUQ6JPOBF_cjs.CheckboxGroup,
738
+ chunkI4EKHIVF_cjs.CheckboxGroup,
739
739
  {
740
740
  ...formField,
741
741
  id: fieldId,
@@ -749,7 +749,7 @@ function DynamicFormField({
749
749
  "aria-label": field.label
750
750
  }
751
751
  ), (field.type === "date-picker" || field.type === "date") && /* @__PURE__ */ React2__namespace.createElement(
752
- chunkUQ6JPOBF_cjs.DatePicker,
752
+ chunkI4EKHIVF_cjs.DatePicker,
753
753
  {
754
754
  ...formField,
755
755
  id: fieldId,
@@ -759,7 +759,7 @@ function DynamicFormField({
759
759
  "aria-label": field.label
760
760
  }
761
761
  ), field.type === "date-range" && /* @__PURE__ */ React2__namespace.createElement(
762
- chunkUQ6JPOBF_cjs.DateRangePicker,
762
+ chunkI4EKHIVF_cjs.DateRangePicker,
763
763
  {
764
764
  ...formField,
765
765
  id: fieldId,
@@ -769,7 +769,7 @@ function DynamicFormField({
769
769
  "aria-label": field.label
770
770
  }
771
771
  ), field.type === "time" && /* @__PURE__ */ React2__namespace.createElement(
772
- chunkUQ6JPOBF_cjs.TimePicker,
772
+ chunkI4EKHIVF_cjs.TimePicker,
773
773
  {
774
774
  ...formField,
775
775
  id: fieldId,
@@ -779,7 +779,7 @@ function DynamicFormField({
779
779
  "aria-label": field.label
780
780
  }
781
781
  ), field.type === "file" && /* @__PURE__ */ React2__namespace.createElement(
782
- chunkUQ6JPOBF_cjs.FileInput,
782
+ chunkI4EKHIVF_cjs.FileInput,
783
783
  {
784
784
  ...formField,
785
785
  id: fieldId,
@@ -816,22 +816,40 @@ var DEFAULT_SUBMIT_LABEL = "Submit";
816
816
  var DEFAULT_BUTTON_GROUP_LABEL = "Subscribe";
817
817
  var DEFAULT_BUTTON_VARIANT = "default";
818
818
  var DEFAULT_BUTTON_GROUP_SIZE = "default";
819
- function FormEngine({
820
- api,
821
- fields,
822
- formLayoutSettings,
823
- successMessage,
824
- onSubmit,
825
- onSuccess,
826
- onError,
827
- navigate,
828
- resetOnSuccess,
829
- uploadTokens: externalUploadTokens,
830
- onFileUpload: externalOnFileUpload,
831
- onFileRemove: externalOnFileRemove,
832
- isUploading: externalIsUploading,
833
- uploadProgress: externalUploadProgress
834
- }) {
819
+ function FormEngine(props) {
820
+ const {
821
+ formEngineSetup,
822
+ defaultFields,
823
+ defaultStyleRules,
824
+ api: directApi,
825
+ fields: directFields,
826
+ formLayoutSettings: directFormLayoutSettings,
827
+ successMessage: directSuccessMessage,
828
+ onSubmit: directOnSubmit,
829
+ onSuccess: directOnSuccess,
830
+ onError: directOnError,
831
+ navigate: directNavigate,
832
+ resetOnSuccess: directResetOnSuccess,
833
+ uploadTokens: directUploadTokens,
834
+ onFileUpload: directOnFileUpload,
835
+ onFileRemove: directOnFileRemove,
836
+ isUploading: directIsUploading,
837
+ uploadProgress: directUploadProgress
838
+ } = props;
839
+ const api = directApi ?? formEngineSetup?.api;
840
+ const fields = directFields ?? formEngineSetup?.fields;
841
+ const formLayoutSettings = directFormLayoutSettings ?? formEngineSetup?.formLayoutSettings;
842
+ const successMessage = directSuccessMessage ?? formEngineSetup?.successMessage;
843
+ const onSubmit = directOnSubmit ?? formEngineSetup?.onSubmit;
844
+ const onSuccess = directOnSuccess ?? formEngineSetup?.onSuccess;
845
+ const onError = directOnError ?? formEngineSetup?.onError;
846
+ const navigate = directNavigate ?? formEngineSetup?.navigate;
847
+ const resetOnSuccess = directResetOnSuccess ?? formEngineSetup?.resetOnSuccess;
848
+ const externalUploadTokens = directUploadTokens ?? formEngineSetup?.uploadTokens;
849
+ const externalOnFileUpload = directOnFileUpload ?? formEngineSetup?.onFileUpload;
850
+ const externalOnFileRemove = directOnFileRemove ?? formEngineSetup?.onFileRemove;
851
+ const externalIsUploading = directIsUploading ?? formEngineSetup?.isUploading;
852
+ const externalUploadProgress = directUploadProgress ?? formEngineSetup?.uploadProgress;
835
853
  const {
836
854
  styleRules: userStyleRules,
837
855
  formLayout = "standard",
@@ -839,16 +857,21 @@ function FormEngine({
839
857
  submitButtonSetup
840
858
  } = formLayoutSettings ?? {};
841
859
  const isButtonGroup = formLayout === "button-group";
860
+ const formFields = React2__namespace.useMemo(() => {
861
+ if (fields && fields.length > 0) return fields;
862
+ if (defaultFields && defaultFields.length > 0) return defaultFields;
863
+ return [];
864
+ }, [fields, defaultFields]);
842
865
  const styleRules = React2__namespace.useMemo(
843
866
  () => ({
844
- formContainer: userStyleRules?.formContainer ?? DEFAULT_STYLE_RULES.formContainer,
845
- fieldsContainer: userStyleRules?.fieldsContainer ?? DEFAULT_STYLE_RULES.fieldsContainer,
846
- fieldClassName: userStyleRules?.fieldClassName ?? DEFAULT_STYLE_RULES.fieldClassName,
847
- formClassName: userStyleRules?.formClassName ?? DEFAULT_STYLE_RULES.formClassName,
848
- successMessageClassName: userStyleRules?.successMessageClassName ?? DEFAULT_STYLE_RULES.successMessageClassName,
849
- errorMessageClassName: userStyleRules?.errorMessageClassName ?? DEFAULT_STYLE_RULES.errorMessageClassName
867
+ formContainer: userStyleRules?.formContainer ?? defaultStyleRules?.formContainer ?? DEFAULT_STYLE_RULES.formContainer,
868
+ fieldsContainer: userStyleRules?.fieldsContainer ?? defaultStyleRules?.fieldsContainer ?? DEFAULT_STYLE_RULES.fieldsContainer,
869
+ fieldClassName: userStyleRules?.fieldClassName ?? defaultStyleRules?.fieldClassName ?? DEFAULT_STYLE_RULES.fieldClassName,
870
+ formClassName: userStyleRules?.formClassName ?? defaultStyleRules?.formClassName ?? DEFAULT_STYLE_RULES.formClassName,
871
+ successMessageClassName: userStyleRules?.successMessageClassName ?? defaultStyleRules?.successMessageClassName ?? DEFAULT_STYLE_RULES.successMessageClassName,
872
+ errorMessageClassName: userStyleRules?.errorMessageClassName ?? defaultStyleRules?.errorMessageClassName ?? DEFAULT_STYLE_RULES.errorMessageClassName
850
873
  }),
851
- [userStyleRules]
874
+ [userStyleRules, defaultStyleRules]
852
875
  );
853
876
  const {
854
877
  uploadTokens: internalUploadTokens,
@@ -864,7 +887,7 @@ function FormEngine({
864
887
  const onFileUpload = externalOnFileUpload ?? internalUploadFiles;
865
888
  const onFileRemove = externalOnFileRemove ?? internalRemoveFile;
866
889
  const { form, submissionError, formMethod, resetSubmissionState } = useContactForm({
867
- formFields: fields,
890
+ formFields,
868
891
  formConfig: api,
869
892
  onSubmit,
870
893
  onSuccess: (data) => {
@@ -899,7 +922,7 @@ function FormEngine({
899
922
  chunkL4I35PDU_cjs.Form,
900
923
  {
901
924
  form,
902
- fields: isButtonGroup ? fields : void 0,
925
+ fields: isButtonGroup ? formFields : void 0,
903
926
  formConfig: legacyFormConfig,
904
927
  method: formMethod,
905
928
  notificationConfig: {
@@ -917,11 +940,11 @@ function FormEngine({
917
940
  "div",
918
941
  {
919
942
  className: chunkQMWZLGON_cjs.cn(
920
- "grid grid-cols-12 gap-6",
943
+ "grid grid-cols-12 gap-6 md:gap-10",
921
944
  styleRules?.fieldsContainer
922
945
  )
923
946
  },
924
- fields.map((field) => /* @__PURE__ */ React2__namespace.createElement(
947
+ formFields.map((field) => /* @__PURE__ */ React2__namespace.createElement(
925
948
  "div",
926
949
  {
927
950
  key: field.name,