@oneblink/apps-react 8.6.0-beta.3 → 8.6.0-beta.5

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 (35) hide show
  1. package/dist/OneBlinkAutoSaveForm.js +2 -2
  2. package/dist/OneBlinkAutoSaveForm.js.map +1 -1
  3. package/dist/OneBlinkForm.js +2 -2
  4. package/dist/OneBlinkForm.js.map +1 -1
  5. package/dist/OneBlinkFormBase.d.ts +3 -3
  6. package/dist/OneBlinkFormBase.js +28 -7
  7. package/dist/OneBlinkFormBase.js.map +1 -1
  8. package/dist/OneBlinkReadOnlyForm.js +1 -1
  9. package/dist/OneBlinkReadOnlyForm.js.map +1 -1
  10. package/dist/components/renderer/OneBlinkFormElements.d.ts +3 -3
  11. package/dist/components/renderer/OneBlinkFormElements.js +2 -2
  12. package/dist/components/renderer/OneBlinkFormElements.js.map +1 -1
  13. package/dist/components/renderer/PageFormElements.d.ts +3 -3
  14. package/dist/components/renderer/PageFormElements.js +5 -5
  15. package/dist/components/renderer/PageFormElements.js.map +1 -1
  16. package/dist/form-elements/FormElementForm.js +2 -2
  17. package/dist/form-elements/FormElementForm.js.map +1 -1
  18. package/dist/form-elements/FormElementRepeatableSet.js +1 -1
  19. package/dist/form-elements/FormElementRepeatableSet.js.map +1 -1
  20. package/dist/form-elements/FormElementSection.d.ts +3 -2
  21. package/dist/form-elements/FormElementSection.js +14 -5
  22. package/dist/form-elements/FormElementSection.js.map +1 -1
  23. package/dist/hooks/useFormSubmissionAutoSaveState.d.ts +8 -4
  24. package/dist/hooks/useFormSubmissionAutoSaveState.js +16 -16
  25. package/dist/hooks/useFormSubmissionAutoSaveState.js.map +1 -1
  26. package/dist/hooks/useFormSubmissionState.d.ts +3 -3
  27. package/dist/hooks/useFormSubmissionState.js +1 -1
  28. package/dist/hooks/useFormSubmissionState.js.map +1 -1
  29. package/dist/hooks/useLookups.js +1 -1
  30. package/dist/hooks/useLookups.js.map +1 -1
  31. package/dist/services/form-validation/extensions.js +4 -9
  32. package/dist/services/form-validation/extensions.js.map +1 -1
  33. package/dist/types/form.d.ts +4 -2
  34. package/dist/types/form.js.map +1 -1
  35. package/package.json +2 -2
@@ -57,16 +57,11 @@ const validationExtensions = {
57
57
  },
58
58
  nestedElements(value, { formElement, formElements, formElementsConditionallyShown, executedLookups, captchaType, isOffline, }) {
59
59
  if (formElements) {
60
- const executedLookupsValue = executedLookups !== undefined &&
60
+ const nestedExecutedLookupsValue = executedLookups !== undefined &&
61
61
  typeof executedLookups !== 'boolean' &&
62
62
  !Array.isArray(executedLookups)
63
63
  ? executedLookups[formElement.name]
64
64
  : {};
65
- const nestedExecutedLookups = executedLookupsValue !== undefined &&
66
- typeof executedLookupsValue !== 'boolean' &&
67
- !Array.isArray(executedLookupsValue)
68
- ? executedLookupsValue[formElement.name]
69
- : {};
70
65
  const formElementConditionallyShown = formElementsConditionallyShown === null || formElementsConditionallyShown === void 0 ? void 0 : formElementsConditionallyShown[formElement.name];
71
66
  const errors = validateSubmission({
72
67
  elements: formElements,
@@ -74,9 +69,9 @@ const validationExtensions = {
74
69
  formElementsConditionallyShown: (formElementConditionallyShown === null || formElementConditionallyShown === void 0 ? void 0 : formElementConditionallyShown.type) === 'formElements'
75
70
  ? formElementConditionallyShown.formElements
76
71
  : undefined,
77
- executedLookups: typeof nestedExecutedLookups !== 'boolean' &&
78
- !Array.isArray(nestedExecutedLookups)
79
- ? nestedExecutedLookups
72
+ executedLookups: typeof nestedExecutedLookupsValue !== 'boolean' &&
73
+ !Array.isArray(nestedExecutedLookupsValue)
74
+ ? nestedExecutedLookupsValue
80
75
  : {},
81
76
  captchaType,
82
77
  isOffline,
@@ -1 +1 @@
1
- {"version":3,"file":"extensions.js","sourceRoot":"","sources":["../../../src/services/form-validation/extensions.ts"],"names":[],"mappings":"AAOA,OAAO,kBAAkB,MAAM,sBAAsB,CAAA;AACrD,OAAO,EACL,+BAA+B,EAC/B,oBAAoB,EACpB,mBAAmB,G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AAE,CAAA;YACR,MAAM,6BAA6B,GACjC,8BAA8B,aAA9B,8BAA8B,uBAA9B,8BAA8B,CAAG,WAAW,CAAC,IAAI,CAAC,CAAA;YACpD,MAAM,MAAM,GAAG,kBAAkB,CAAC;gBAChC,QAAQ,EAAE,YAA+C;gBACzD,UAAU,EAAE,KAAuD;gBACnE,8BAA8B,EAC5B,CAAA,6BAA6B,aAA7B,6BAA6B,uBAA7B,6BAA6B,CAAE,IAAI,MAAK,cAAc;oBACpD,CAAC,CAAC,6BAA6B,CAAC,YAAY;oBAC5C,CAAC,CAAC,SAAS;gBACf,eAAe,EACb,OAAO,qBAAqB,KAAK,SAAS;oBAC1C,CAAC,KAAK,CAAC,OAAO,CAAC,qBAAqB,CAAC;oBACnC,CAAC,CAAC,qBAAqB;oBACvB,CAAC,CAAC,EAAE;gBACR,WAAW;gBACX,SAAS;aACV,CAAC,CAAA;YACF,IAAI,MAAM,EAAE,CAAC;gBACX,OAAO;oBACL,IAAI,EAAE,cAAuB;oBAC7B,YAAY,EAAE,MAAM;iBACrB,CAAA;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,CAAC,SAAkB,EAAE,OAAe;QACzC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IACnC,CAAC;CACF,CAAA;AAED,eAAe,oBAAoB,CAAA","sourcesContent":["import { FormTypes, SubmissionTypes } from '@oneblink/types'\nimport { FormElementBinaryStorageValue } from '../../types/attachments'\nimport {\n CaptchaType,\n ExecutedLookups,\n FormElementsConditionallyShown,\n} from '../../types/form'\nimport validateSubmission from './validateSubmission'\nimport {\n generateLookupValidationMessage,\n getInvalidAttachment,\n validateAttachments,\n} from './validators'\nimport { validators } from './validate-dot-js'\nimport { Value as FormElementComplianceValue } from '../../form-elements/FormElementCompliance'\n\nconst validationExtensions = {\n lookups({\n executedLookups,\n formElement,\n }: {\n formElement: FormTypes.LookupFormElement & FormTypes.FormElementRequired\n executedLookups: ExecutedLookups\n }): string[] {\n if (!formElement.isDataLookup && !formElement.isElementLookup) {\n return []\n }\n\n // Lookups must only be executed on required form elements\n if (formElement && !formElement.required) {\n return []\n }\n\n const elementExecutedLookups = executedLookups?.[formElement.name]\n if (elementExecutedLookups === true) {\n return []\n }\n\n return [generateLookupValidationMessage(formElement.lookupButton)]\n },\n\n presence(\n value: unknown,\n { required, requiredMessage }: FormTypes.FormElementRequired,\n message: string,\n ) {\n if (required) {\n return validators.presence(value, {\n message: requiredMessage || message,\n })\n }\n return []\n },\n\n regex<DefaultValue>(\n value: unknown,\n formElement: FormTypes.FormElementWithInput<DefaultValue>,\n ) {\n if (formElement.regexPattern) {\n return validators.regexValidation(value, {\n pattern: formElement.regexPattern,\n flags: formElement.regexFlags,\n message: formElement.regexMessage,\n })\n }\n return []\n },\n\n attachment(value: unknown): string[] {\n const attachmentError = getInvalidAttachment(value)\n if (attachmentError) {\n return [attachmentError.errorMessage]\n }\n return []\n },\n\n attachments(\n value:\n | FormElementBinaryStorageValue[]\n | FormElementComplianceValue\n | undefined,\n ) {\n if (Array.isArray(value)) {\n return validateAttachments(value)\n }\n return validateAttachments(\n value?.files as FormElementBinaryStorageValue[] | undefined,\n )\n },\n\n numberRegex(value: unknown, formElement: FormTypes.NumberElement) {\n if (\n formElement.regexPattern &&\n typeof value === 'number' &&\n !Number.isNaN(value)\n ) {\n return validationExtensions.regex(value.toString(), formElement)\n }\n return []\n },\n\n nestedElements(\n value: unknown,\n {\n formElement,\n formElements,\n formElementsConditionallyShown,\n executedLookups,\n captchaType,\n isOffline,\n }: {\n formElement: FormTypes.FormElementWithName\n formElements: FormTypes.FormElementWithName[] | undefined\n formElementsConditionallyShown: FormElementsConditionallyShown | undefined\n executedLookups: ExecutedLookups\n captchaType: CaptchaType\n isOffline: boolean\n },\n ) {\n if (formElements) {\n const executedLookupsValue =\n executedLookups !== undefined &&\n typeof executedLookups !== 'boolean' &&\n !Array.isArray(executedLookups)\n ? executedLookups[formElement.name]\n : {}\n const nestedExecutedLookups =\n executedLookupsValue !== undefined &&\n typeof executedLookupsValue !== 'boolean' &&\n !Array.isArray(executedLookupsValue)\n ? executedLookupsValue[formElement.name]\n : {}\n const formElementConditionallyShown =\n formElementsConditionallyShown?.[formElement.name]\n const errors = validateSubmission({\n elements: formElements as FormTypes.FormElementWithName[],\n submission: value as SubmissionTypes.S3SubmissionData['submission'],\n formElementsConditionallyShown:\n formElementConditionallyShown?.type === 'formElements'\n ? formElementConditionallyShown.formElements\n : undefined,\n executedLookups:\n typeof nestedExecutedLookups !== 'boolean' &&\n !Array.isArray(nestedExecutedLookups)\n ? nestedExecutedLookups\n : {},\n captchaType,\n isOffline,\n })\n if (errors) {\n return {\n type: 'formElements' as const,\n formElements: errors,\n }\n }\n }\n },\n\n offline(isOffline: boolean, message: string) {\n return isOffline ? [message] : []\n },\n}\n\nexport default validationExtensions\n"]}
1
+ {"version":3,"file":"extensions.js","sourceRoot":"","sources":["../../../src/services/form-validation/extensions.ts"],"names":[],"mappings":"AAOA,OAAO,kBAAkB,MAAM,sBAAsB,CAAA;AACrD,OAAO,EACL,+BAA+B,EAC/B,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAG9C,MAAM,oBAAoB,GAAG;IAC3B,OAAO,CAAC,EACN,eAAe,EACf,WAAW,GAIZ;QACC,IAAI,CAAC,WAAW,CAAC,YAAY,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC;YAC9D,OAAO,EAAE,CAAA;QACX,CAAC;QAED,0DAA0D;QAC1D,IAAI,WAAW,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;YACzC,OAAO,EAAE,CAAA;QACX,CAAC;QAED,MAAM,sBAAsB,GAAG,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAG,WAAW,CAAC,IAAI,CAAC,CAAA;QAClE,IAAI,sBAAsB,KAAK,I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SAAkB,EAAE,OAAe;QACzC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IACnC,CAAC;CACF,CAAA;AAED,eAAe,oBAAoB,CAAA","sourcesContent":["import { FormTypes, SubmissionTypes } from '@oneblink/types'\nimport { FormElementBinaryStorageValue } from '../../types/attachments'\nimport {\n CaptchaType,\n ExecutedLookups,\n FormElementsConditionallyShown,\n} from '../../types/form'\nimport validateSubmission from './validateSubmission'\nimport {\n generateLookupValidationMessage,\n getInvalidAttachment,\n validateAttachments,\n} from './validators'\nimport { validators } from './validate-dot-js'\nimport { Value as FormElementComplianceValue } from '../../form-elements/FormElementCompliance'\n\nconst validationExtensions = {\n lookups({\n executedLookups,\n formElement,\n }: {\n formElement: FormTypes.LookupFormElement & FormTypes.FormElementRequired\n executedLookups: ExecutedLookups\n }): string[] {\n if (!formElement.isDataLookup && !formElement.isElementLookup) {\n return []\n }\n\n // Lookups must only be executed on required form elements\n if (formElement && !formElement.required) {\n return []\n }\n\n const elementExecutedLookups = executedLookups?.[formElement.name]\n if (elementExecutedLookups === true) {\n return []\n }\n\n return [generateLookupValidationMessage(formElement.lookupButton)]\n },\n\n presence(\n value: unknown,\n { required, requiredMessage }: FormTypes.FormElementRequired,\n message: string,\n ) {\n if (required) {\n return validators.presence(value, {\n message: requiredMessage || message,\n })\n }\n return []\n },\n\n regex<DefaultValue>(\n value: unknown,\n formElement: FormTypes.FormElementWithInput<DefaultValue>,\n ) {\n if (formElement.regexPattern) {\n return validators.regexValidation(value, {\n pattern: formElement.regexPattern,\n flags: formElement.regexFlags,\n message: formElement.regexMessage,\n })\n }\n return []\n },\n\n attachment(value: unknown): string[] {\n const attachmentError = getInvalidAttachment(value)\n if (attachmentError) {\n return [attachmentError.errorMessage]\n }\n return []\n },\n\n attachments(\n value:\n | FormElementBinaryStorageValue[]\n | FormElementComplianceValue\n | undefined,\n ) {\n if (Array.isArray(value)) {\n return validateAttachments(value)\n }\n return validateAttachments(\n value?.files as FormElementBinaryStorageValue[] | undefined,\n )\n },\n\n numberRegex(value: unknown, formElement: FormTypes.NumberElement) {\n if (\n formElement.regexPattern &&\n typeof value === 'number' &&\n !Number.isNaN(value)\n ) {\n return validationExtensions.regex(value.toString(), formElement)\n }\n return []\n },\n\n nestedElements(\n value: unknown,\n {\n formElement,\n formElements,\n formElementsConditionallyShown,\n executedLookups,\n captchaType,\n isOffline,\n }: {\n formElement: FormTypes.FormElementWithName\n formElements: FormTypes.FormElementWithName[] | undefined\n formElementsConditionallyShown: FormElementsConditionallyShown | undefined\n executedLookups: ExecutedLookups\n captchaType: CaptchaType\n isOffline: boolean\n },\n ) {\n if (formElements) {\n const nestedExecutedLookupsValue =\n executedLookups !== undefined &&\n typeof executedLookups !== 'boolean' &&\n !Array.isArray(executedLookups)\n ? executedLookups[formElement.name]\n : {}\n\n const formElementConditionallyShown =\n formElementsConditionallyShown?.[formElement.name]\n const errors = validateSubmission({\n elements: formElements as FormTypes.FormElementWithName[],\n submission: value as SubmissionTypes.S3SubmissionData['submission'],\n formElementsConditionallyShown:\n formElementConditionallyShown?.type === 'formElements'\n ? formElementConditionallyShown.formElements\n : undefined,\n executedLookups:\n typeof nestedExecutedLookupsValue !== 'boolean' &&\n !Array.isArray(nestedExecutedLookupsValue)\n ? nestedExecutedLookupsValue\n : {},\n captchaType,\n isOffline,\n })\n if (errors) {\n return {\n type: 'formElements' as const,\n formElements: errors,\n }\n }\n }\n },\n\n offline(isOffline: boolean, message: string) {\n return isOffline ? [message] : []\n },\n}\n\nexport default validationExtensions\n"]}
@@ -1,4 +1,5 @@
1
1
  import { FormTypes, SubmissionTypes, IntegrationTypes } from '@oneblink/types';
2
+ import { NewS3SubmissionData } from '@oneblink/types/typescript/submissions';
2
3
  export { FormElementConditionallyShownElement, FormElementConditionallyShown, FormElementsConditionallyShown, } from '@oneblink/sdk-core/dist/conditionalLogicService';
3
4
  export type FormElementKey = string;
4
5
  export type RepeatableSetEntryIndex = string;
@@ -23,12 +24,13 @@ export type NestedFormElementValueChangeHandler<T = unknown> = ValueChangeHandle
23
24
  value?: T | ((existingValue?: T) => T | undefined);
24
25
  executedLookups: ExecutedLookupValue | ((currentExecutedLookups: ExecutedLookupValue) => ExecutedLookupValue);
25
26
  }>;
27
+ export type SectionState = NewS3SubmissionData['sectionState'];
26
28
  export type FormElementLookupHandler = (setter: (data: {
27
29
  submission: SubmissionTypes.S3SubmissionData['submission'];
28
30
  elements: FormTypes.FormElement[];
29
31
  lastElementUpdated: FormTypes.FormElement | undefined;
30
32
  executedLookups: ExecutedLookups;
31
- collapsedSectionIds: string[] | undefined;
33
+ sectionState: SectionState | undefined;
32
34
  }) => {
33
35
  submission: SubmissionTypes.S3SubmissionData['submission'];
34
36
  elements: FormTypes.FormElement[];
@@ -40,7 +42,7 @@ export type SetFormSubmission = React.Dispatch<React.SetStateAction<{
40
42
  submission: SubmissionTypes.S3SubmissionData['submission'];
41
43
  lastElementUpdated: FormTypes.FormElement | undefined;
42
44
  executedLookups: ExecutedLookups;
43
- collapsedSectionIds: string[] | undefined;
45
+ sectionState: SectionState | undefined;
44
46
  }>>;
45
47
  export type IsDirtyProps = {
46
48
  isDirty: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"form.js","sourceRoot":"","sources":["../../src/types/form.ts"],"names":[],"mappings":"","sourcesContent":["import { FormTypes, SubmissionTypes, IntegrationTypes } from '@oneblink/types'\n\nexport {\n FormElementConditionallyShownElement,\n FormElementConditionallyShown,\n FormElementsConditionallyShown,\n} from '@oneblink/sdk-core/dist/conditionalLogicService'\n\nexport type FormElementKey = string\nexport type RepeatableSetEntryIndex = string\n\nexport type FormElementsValidation = Record<\n FormElementKey,\n FormElementValidation\n>\n\nexport type FormElementValidation =\n | undefined\n | string\n | {\n type: 'formElements'\n formElements: FormElementsValidation | undefined\n }\n | {\n type: 'repeatableSet'\n set: string | undefined\n entries: Record<\n RepeatableSetEntryIndex,\n FormElementsValidation | undefined\n >\n }\n\nexport type ExecutedLookups =\n | {\n [elementName: string]:\n | boolean\n | ExecutedLookups\n | ExecutedLookups[]\n | undefined\n }\n | undefined\n\nexport type ExecutedLookupValue = NonNullable<ExecutedLookups>[string]\n\ntype ValueChangeHandler<U extends Record<string, unknown>> = (\n element: FormTypes.FormElement,\n opts: U,\n) => void\n\nexport type FormElementValueChangeHandler<T = unknown> = ValueChangeHandler<{\n value?: T | ((existingValue?: T) => T | undefined)\n}>\n\nexport type NestedFormElementValueChangeHandler<T = unknown> =\n ValueChangeHandler<{\n value?: T | ((existingValue?: T) => T | undefined)\n executedLookups:\n | ExecutedLookupValue\n | ((currentExecutedLookups: ExecutedLookupValue) => ExecutedLookupValue)\n }>\n\nexport type FormElementLookupHandler = (\n setter: (data: {\n submission: SubmissionTypes.S3SubmissionData['submission']\n elements: FormTypes.FormElement[]\n lastElementUpdated: FormTypes.FormElement | undefined\n executedLookups: ExecutedLookups\n collapsedSectionIds: string[] | undefined\n }) => {\n submission: SubmissionTypes.S3SubmissionData['submission']\n elements: FormTypes.FormElement[]\n executedLookups: ExecutedLookups\n },\n) => void\n\nexport type UpdateFormElementsHandler = (\n setter: (element: FormTypes.FormElement[]) => FormTypes.FormElement[],\n) => void\n\nexport type SetFormSubmission = React.Dispatch<\n React.SetStateAction<{\n definition: FormTypes.Form\n submission: SubmissionTypes.S3SubmissionData['submission']\n lastElementUpdated: FormTypes.FormElement | undefined\n executedLookups: ExecutedLookups\n collapsedSectionIds: string[] | undefined\n }>\n>\n\nexport type IsDirtyProps = {\n isDirty: boolean\n setIsDirty: () => void\n}\n\nexport type CaptchaType = NonNullable<\n IntegrationTypes.IntegrationRecaptcha['configuration']['domains'][number]['type']\n>\n"]}
1
+ {"version":3,"file":"form.js","sourceRoot":"","sources":["../../src/types/form.ts"],"names":[],"mappings":"","sourcesContent":["import { FormTypes, SubmissionTypes, IntegrationTypes } from '@oneblink/types'\nimport { NewS3SubmissionData } from '@oneblink/types/typescript/submissions'\n\nexport {\n FormElementConditionallyShownElement,\n FormElementConditionallyShown,\n FormElementsConditionallyShown,\n} from '@oneblink/sdk-core/dist/conditionalLogicService'\n\nexport type FormElementKey = string\nexport type RepeatableSetEntryIndex = string\n\nexport type FormElementsValidation = Record<\n FormElementKey,\n FormElementValidation\n>\n\nexport type FormElementValidation =\n | undefined\n | string\n | {\n type: 'formElements'\n formElements: FormElementsValidation | undefined\n }\n | {\n type: 'repeatableSet'\n set: string | undefined\n entries: Record<\n RepeatableSetEntryIndex,\n FormElementsValidation | undefined\n >\n }\n\nexport type ExecutedLookups =\n | {\n [elementName: string]:\n | boolean\n | ExecutedLookups\n | ExecutedLookups[]\n | undefined\n }\n | undefined\n\nexport type ExecutedLookupValue = NonNullable<ExecutedLookups>[string]\n\ntype ValueChangeHandler<U extends Record<string, unknown>> = (\n element: FormTypes.FormElement,\n opts: U,\n) => void\n\nexport type FormElementValueChangeHandler<T = unknown> = ValueChangeHandler<{\n value?: T | ((existingValue?: T) => T | undefined)\n}>\n\nexport type NestedFormElementValueChangeHandler<T = unknown> =\n ValueChangeHandler<{\n value?: T | ((existingValue?: T) => T | undefined)\n executedLookups:\n | ExecutedLookupValue\n | ((currentExecutedLookups: ExecutedLookupValue) => ExecutedLookupValue)\n }>\n\nexport type SectionState = NewS3SubmissionData['sectionState']\n\nexport type FormElementLookupHandler = (\n setter: (data: {\n submission: SubmissionTypes.S3SubmissionData['submission']\n elements: FormTypes.FormElement[]\n lastElementUpdated: FormTypes.FormElement | undefined\n executedLookups: ExecutedLookups\n sectionState: SectionState | undefined\n }) => {\n submission: SubmissionTypes.S3SubmissionData['submission']\n elements: FormTypes.FormElement[]\n executedLookups: ExecutedLookups\n },\n) => void\n\nexport type UpdateFormElementsHandler = (\n setter: (element: FormTypes.FormElement[]) => FormTypes.FormElement[],\n) => void\n\nexport type SetFormSubmission = React.Dispatch<\n React.SetStateAction<{\n definition: FormTypes.Form\n submission: SubmissionTypes.S3SubmissionData['submission']\n lastElementUpdated: FormTypes.FormElement | undefined\n executedLookups: ExecutedLookups\n sectionState: SectionState | undefined\n }>\n>\n\nexport type IsDirtyProps = {\n isDirty: boolean\n setIsDirty: () => void\n}\n\nexport type CaptchaType = NonNullable<\n IntegrationTypes.IntegrationRecaptcha['configuration']['domains'][number]['type']\n>\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oneblink/apps-react",
3
3
  "description": "Helper functions for OneBlink apps in ReactJS.",
4
- "version": "8.6.0-beta.3",
4
+ "version": "8.6.0-beta.5",
5
5
  "author": "OneBlink <developers@oneblink.io> (https://oneblink.io)",
6
6
  "bugs": {
7
7
  "url": "https://github.com/oneblink/apps-react/issues"
@@ -47,7 +47,7 @@
47
47
  "@mui/lab": "^5.0.0-alpha.152",
48
48
  "@mui/material": "^5.15.6",
49
49
  "@mui/x-date-pickers": "^6.20.2",
50
- "@oneblink/apps": "^22.2.0-beta.3",
50
+ "@oneblink/apps": "^23.0.0-beta.3",
51
51
  "@oneblink/release-cli": "^3.3.1-beta.4",
52
52
  "@oneblink/types": "github:oneblink/types",
53
53
  "@types/blueimp-load-image": "^5.16.6",