@oneblink/apps-react 2.10.0-beta.2 → 2.10.0-beta.4

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 (83) hide show
  1. package/dist/components/renderer/AutocompleteDropdown.d.ts +3 -2
  2. package/dist/components/renderer/AutocompleteDropdown.js +12 -5
  3. package/dist/components/renderer/AutocompleteDropdown.js.map +1 -1
  4. package/dist/components/renderer/OneBlinkFormElements.js +49 -41
  5. package/dist/components/renderer/OneBlinkFormElements.js.map +1 -1
  6. package/dist/form-elements/FormElementABN.d.ts +3 -3
  7. package/dist/form-elements/FormElementABN.js +1 -2
  8. package/dist/form-elements/FormElementABN.js.map +1 -1
  9. package/dist/form-elements/FormElementAutocomplete.d.ts +2 -2
  10. package/dist/form-elements/FormElementAutocomplete.js +4 -4
  11. package/dist/form-elements/FormElementAutocomplete.js.map +1 -1
  12. package/dist/form-elements/FormElementBSB.d.ts +3 -3
  13. package/dist/form-elements/FormElementBSB.js +1 -3
  14. package/dist/form-elements/FormElementBSB.js.map +1 -1
  15. package/dist/form-elements/FormElementBarcodeScanner.d.ts +3 -3
  16. package/dist/form-elements/FormElementBarcodeScanner.js +1 -2
  17. package/dist/form-elements/FormElementBarcodeScanner.js.map +1 -1
  18. package/dist/form-elements/FormElementBoolean.d.ts +3 -3
  19. package/dist/form-elements/FormElementBoolean.js +1 -3
  20. package/dist/form-elements/FormElementBoolean.js.map +1 -1
  21. package/dist/form-elements/FormElementCamera.d.ts +3 -3
  22. package/dist/form-elements/FormElementCamera.js +1 -2
  23. package/dist/form-elements/FormElementCamera.js.map +1 -1
  24. package/dist/form-elements/FormElementCivicaStreetName.d.ts +3 -3
  25. package/dist/form-elements/FormElementCivicaStreetName.js +2 -2
  26. package/dist/form-elements/FormElementCivicaStreetName.js.map +1 -1
  27. package/dist/form-elements/FormElementCompliance.d.ts +3 -3
  28. package/dist/form-elements/FormElementCompliance.js +3 -5
  29. package/dist/form-elements/FormElementCompliance.js.map +1 -1
  30. package/dist/form-elements/FormElementDate.d.ts +3 -3
  31. package/dist/form-elements/FormElementDate.js +1 -3
  32. package/dist/form-elements/FormElementDate.js.map +1 -1
  33. package/dist/form-elements/FormElementDateTime.d.ts +3 -3
  34. package/dist/form-elements/FormElementDateTime.js +1 -3
  35. package/dist/form-elements/FormElementDateTime.js.map +1 -1
  36. package/dist/form-elements/FormElementEmail.d.ts +3 -3
  37. package/dist/form-elements/FormElementEmail.js +1 -3
  38. package/dist/form-elements/FormElementEmail.js.map +1 -1
  39. package/dist/form-elements/FormElementFiles.d.ts +3 -3
  40. package/dist/form-elements/FormElementFiles.js +2 -2
  41. package/dist/form-elements/FormElementFiles.js.map +1 -1
  42. package/dist/form-elements/FormElementGeoscapeAddress.d.ts +3 -3
  43. package/dist/form-elements/FormElementGeoscapeAddress.js +2 -2
  44. package/dist/form-elements/FormElementGeoscapeAddress.js.map +1 -1
  45. package/dist/form-elements/FormElementLocation.d.ts +3 -3
  46. package/dist/form-elements/FormElementLocation.js +1 -2
  47. package/dist/form-elements/FormElementLocation.js.map +1 -1
  48. package/dist/form-elements/FormElementNumber.d.ts +3 -3
  49. package/dist/form-elements/FormElementNumber.js +1 -3
  50. package/dist/form-elements/FormElementNumber.js.map +1 -1
  51. package/dist/form-elements/FormElementPointAddress.d.ts +3 -3
  52. package/dist/form-elements/FormElementPointAddress.js +2 -2
  53. package/dist/form-elements/FormElementPointAddress.js.map +1 -1
  54. package/dist/form-elements/FormElementRadio.d.ts +3 -3
  55. package/dist/form-elements/FormElementRadio.js +1 -3
  56. package/dist/form-elements/FormElementRadio.js.map +1 -1
  57. package/dist/form-elements/FormElementRepeatableSet.d.ts +3 -3
  58. package/dist/form-elements/FormElementRepeatableSet.js +2 -3
  59. package/dist/form-elements/FormElementRepeatableSet.js.map +1 -1
  60. package/dist/form-elements/FormElementSelect.d.ts +3 -3
  61. package/dist/form-elements/FormElementSelect.js +1 -3
  62. package/dist/form-elements/FormElementSelect.js.map +1 -1
  63. package/dist/form-elements/FormElementSignature.d.ts +3 -2
  64. package/dist/form-elements/FormElementSignature.js +1 -3
  65. package/dist/form-elements/FormElementSignature.js.map +1 -1
  66. package/dist/form-elements/FormElementTelephone.d.ts +3 -3
  67. package/dist/form-elements/FormElementTelephone.js +1 -3
  68. package/dist/form-elements/FormElementTelephone.js.map +1 -1
  69. package/dist/form-elements/FormElementText.d.ts +3 -3
  70. package/dist/form-elements/FormElementText.js +1 -3
  71. package/dist/form-elements/FormElementText.js.map +1 -1
  72. package/dist/form-elements/FormElementTextarea.d.ts +3 -3
  73. package/dist/form-elements/FormElementTextarea.js +1 -3
  74. package/dist/form-elements/FormElementTextarea.js.map +1 -1
  75. package/dist/form-elements/FormElementTime.d.ts +3 -3
  76. package/dist/form-elements/FormElementTime.js +1 -3
  77. package/dist/form-elements/FormElementTime.js.map +1 -1
  78. package/dist/hooks/attachments/useAttachments.d.ts +2 -3
  79. package/dist/hooks/attachments/useAttachments.js +1 -4
  80. package/dist/hooks/attachments/useAttachments.js.map +1 -1
  81. package/dist/types/form.d.ts +4 -0
  82. package/dist/types/form.js.map +1 -1
  83. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useAttachments.js","sourceRoot":"","sources":["../../../src/hooks/attachments/useAttachments.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EACL,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,eAAe,MAAM,oBAAoB,CAAA;AAChD,OAAO,YAAY,MAAM,iBAAiB,CAAA;AAG1C,MAAM,cAAc,GAAG,CACrB,OAA+B,EAC/B,QAAwE,EACxE,EAAE;IACF,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAChC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,CAAA;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E;oBACb,OAAO,GAAG,CAAC,EAAE,KAAK,EAAE,CAAA;iBACrB;gBACD,OAAO,GAAG,CAAC,GAAG,KAAK,EAAE,CAAA;YACvB,CAAC,CAAC,CAAA;YACF,IAAI,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,MAAM,EAAE;gBAC1B,OAAO,cAAc,CAAA;aACtB;QACH,CAAC,CAAC,CAAA;QACF,IAAI,SAAS,CAAC,OAAO,EAAE;YACrB,UAAU,EAAE,CAAA;SACb;IACH,CAAC,EACD,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,CAAC,CAC3C,CAAA;IAED,MAAM,gBAAgB,GAAG,KAAK,CAAC,WAAW,CACxC,CAAC,EAAU,EAAE,UAAyC,EAAE,EAAE;QACxD,QAAQ,CAAC,OAAO,EAAE,CAAC,kBAAkB,EAAE,EAAE;YACvC,IAAI,CAAC,kBAAkB;gBAAE,OAAM;YAC/B,OAAO,kBAAkB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;gBACpC,kEAAkE;gBAClE,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG,KAAK,EAAE,EAAE;oBAC9B,OAAO,UAAU,CAAA;iBAClB;gBACD,OAAO,GAAG,CAAA;YACZ,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QACF,IAAI,SAAS,CAAC,OAAO,EAAE;YACrB,UAAU,EAAE,CAAA;SACb;IACH,CAAC,EACD,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,CAAC,CAC3C,CAAA;IAED,OAAO;QACL,OAAO;QACP,cAAc;QACd,gBAAgB;QAChB,gBAAgB;KACjB,CAAA;AACH,CAAC,CAAA;AAED,eAAe,cAAc,CAAA","sourcesContent":["import { FormTypes } from '@oneblink/types'\nimport * as React from 'react'\nimport {\n prepareNewAttachment,\n correctFileOrientation,\n} from '../../services/attachments'\nimport { attachmentsService } from '@oneblink/apps'\nimport { canvasToBlob } from '../../services/blob-utils'\nimport useBooleanState from '../useBooleanState'\nimport useIsMounted from '../useIsMounted'\nimport { FormElementValueChangeHandler } from '../../types/form'\n\nconst useAttachments = (\n element: FormTypes.FilesElement,\n onChange: FormElementValueChangeHandler<attachmentsService.Attachment[]>,\n) => {\n const isMounted = useIsMounted()\n const [isDirty, setIsDirty] = useBooleanState(false)\n\n const addAttachments = React.useCallback(\n async (files: File[]): Promise<void> => {\n if (!files.length) return\n const newAttachments: attachmentsService.AttachmentNew[] =\n await Promise.all(\n files.map(async (file) => {\n const result = await correctFileOrientation(file)\n if (result instanceof Blob) {\n return prepareNewAttachment(result, file.name, element)\n }\n\n const blob = await canvasToBlob(result)\n return prepareNewAttachment(blob, file.name, element)\n }),\n )\n\n onChange(element, (currentAttachments) => {\n if (!currentAttachments) return newAttachments\n return [...currentAttachments, ...newAttachments]\n })\n if (isMounted.current) {\n setIsDirty()\n }\n },\n [element, isMounted, onChange, setIsDirty],\n )\n\n const removeAttachment = React.useCallback(\n (id: string) => {\n onChange(element, (currentAttachments) => {\n const newAttachments = currentAttachments?.filter((att) => {\n // Return items that are not the removed id\n if (!att.type) {\n return att.id !== id\n }\n return att._id !== id\n })\n if (newAttachments?.length) {\n return newAttachments\n }\n })\n if (isMounted.current) {\n setIsDirty()\n }\n },\n [element, isMounted, onChange, setIsDirty],\n )\n\n const changeAttachment = React.useCallback(\n (id: string, attachment: attachmentsService.Attachment) => {\n onChange(element, (currentAttachments) => {\n if (!currentAttachments) return\n return currentAttachments.map((att) => {\n // Can only change attachments that are not uploaded (have a type)\n if (att.type && att._id === id) {\n return attachment\n }\n return att\n })\n })\n if (isMounted.current) {\n setIsDirty()\n }\n },\n [element, isMounted, onChange, setIsDirty],\n )\n\n return {\n isDirty,\n addAttachments,\n removeAttachment,\n changeAttachment,\n }\n}\n\nexport default useAttachments\n"]}
1
+ {"version":3,"file":"useAttachments.js","sourceRoot":"","sources":["../../../src/hooks/attachments/useAttachments.ts"],"names":[],"mappings":"A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CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,CAAC,CAC3C,CAAA;IAED,OAAO;QACL,cAAc;QACd,gBAAgB;QAChB,gBAAgB;KACjB,CAAA;AACH,CAAC,CAAA;AAED,eAAe,cAAc,CAAA","sourcesContent":["import { FormTypes } from '@oneblink/types'\nimport * as React from 'react'\nimport {\n prepareNewAttachment,\n correctFileOrientation,\n} from '../../services/attachments'\nimport { attachmentsService } from '@oneblink/apps'\nimport { canvasToBlob } from '../../services/blob-utils'\nimport useIsMounted from '../useIsMounted'\nimport { FormElementValueChangeHandler, IsDirtyProps } from '../../types/form'\n\nconst useAttachments = (\n element: FormTypes.FilesElement,\n onChange: FormElementValueChangeHandler<attachmentsService.Attachment[]>,\n setIsDirty: IsDirtyProps['setIsDirty'],\n) => {\n const isMounted = useIsMounted()\n\n const addAttachments = React.useCallback(\n async (files: File[]): Promise<void> => {\n if (!files.length) return\n const newAttachments: attachmentsService.AttachmentNew[] =\n await Promise.all(\n files.map(async (file) => {\n const result = await correctFileOrientation(file)\n if (result instanceof Blob) {\n return prepareNewAttachment(result, file.name, element)\n }\n\n const blob = await canvasToBlob(result)\n return prepareNewAttachment(blob, file.name, element)\n }),\n )\n\n onChange(element, (currentAttachments) => {\n if (!currentAttachments) return newAttachments\n return [...currentAttachments, ...newAttachments]\n })\n if (isMounted.current) {\n setIsDirty()\n }\n },\n [element, isMounted, onChange, setIsDirty],\n )\n\n const removeAttachment = React.useCallback(\n (id: string) => {\n onChange(element, (currentAttachments) => {\n const newAttachments = currentAttachments?.filter((att) => {\n // Return items that are not the removed id\n if (!att.type) {\n return att.id !== id\n }\n return att._id !== id\n })\n if (newAttachments?.length) {\n return newAttachments\n }\n })\n if (isMounted.current) {\n setIsDirty()\n }\n },\n [element, isMounted, onChange, setIsDirty],\n )\n\n const changeAttachment = React.useCallback(\n (id: string, attachment: attachmentsService.Attachment) => {\n onChange(element, (currentAttachments) => {\n if (!currentAttachments) return\n return currentAttachments.map((att) => {\n // Can only change attachments that are not uploaded (have a type)\n if (att.type && att._id === id) {\n return attachment\n }\n return att\n })\n })\n if (isMounted.current) {\n setIsDirty()\n }\n },\n [element, isMounted, onChange, setIsDirty],\n )\n\n return {\n addAttachments,\n removeAttachment,\n changeAttachment,\n }\n}\n\nexport default useAttachments\n"]}
@@ -41,4 +41,8 @@ export declare type SetFormSubmission = React.Dispatch<React.SetStateAction<{
41
41
  submission: FormSubmissionModel;
42
42
  lastElementUpdated: import('@oneblink/types').FormTypes.FormElement | undefined;
43
43
  }>>;
44
+ export declare type IsDirtyProps = {
45
+ isDirty: boolean;
46
+ setIsDirty: () => void;
47
+ };
44
48
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"form.js","sourceRoot":"","sources":["../../src/types/form.ts"],"names":[],"mappings":"AAAA,6DAA6D","sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\ntype FormElementKey = string\nexport type RepeatableSetEntryIndex = string\n\nexport type FormSubmissionModel = Record<FormElementKey, unknown>\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 FormElementsConditionallyShown = Record<\n FormElementKey,\n FormElementConditionallyShown\n>\n\nexport type FormElementConditionallyShownElement = {\n type: 'formElement'\n isHidden: boolean\n options?: import('@oneblink/types').FormTypes.ChoiceElementOption[]\n dependencyIsLoading?: boolean\n}\nexport type FormElementConditionallyShown =\n | undefined\n | FormElementConditionallyShownElement\n | {\n type: 'formElements'\n isHidden: boolean\n formElements: FormElementsConditionallyShown | undefined\n }\n | {\n type: 'repeatableSet'\n isHidden: boolean\n entries: Record<\n RepeatableSetEntryIndex,\n FormElementsConditionallyShown | undefined\n >\n }\n\nexport type FormElementValueChangeHandler<T = unknown> = (\n element: import('@oneblink/types').FormTypes.FormElement,\n value?: T | ((existingValue?: T) => T | undefined),\n) => void\n\nexport type FormElementLookupHandler = (\n setter: (data: {\n submission: FormSubmissionModel\n elements: import('@oneblink/types').FormTypes.FormElement[]\n lastElementUpdated:\n | import('@oneblink/types').FormTypes.FormElement\n | undefined\n }) => {\n submission: FormSubmissionModel\n elements: import('@oneblink/types').FormTypes.FormElement[]\n },\n) => void\n\nexport type SetFormSubmission = React.Dispatch<\n React.SetStateAction<{\n definition: import('@oneblink/types').FormTypes.Form\n submission: FormSubmissionModel\n lastElementUpdated:\n | import('@oneblink/types').FormTypes.FormElement\n | undefined\n }>\n>\n"]}
1
+ {"version":3,"file":"form.js","sourceRoot":"","sources":["../../src/types/form.ts"],"names":[],"mappings":"AAAA,6DAA6D","sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\ntype FormElementKey = string\nexport type RepeatableSetEntryIndex = string\n\nexport type FormSubmissionModel = Record<FormElementKey, unknown>\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 FormElementsConditionallyShown = Record<\n FormElementKey,\n FormElementConditionallyShown\n>\n\nexport type FormElementConditionallyShownElement = {\n type: 'formElement'\n isHidden: boolean\n options?: import('@oneblink/types').FormTypes.ChoiceElementOption[]\n dependencyIsLoading?: boolean\n}\nexport type FormElementConditionallyShown =\n | undefined\n | FormElementConditionallyShownElement\n | {\n type: 'formElements'\n isHidden: boolean\n formElements: FormElementsConditionallyShown | undefined\n }\n | {\n type: 'repeatableSet'\n isHidden: boolean\n entries: Record<\n RepeatableSetEntryIndex,\n FormElementsConditionallyShown | undefined\n >\n }\n\nexport type FormElementValueChangeHandler<T = unknown> = (\n element: import('@oneblink/types').FormTypes.FormElement,\n value?: T | ((existingValue?: T) => T | undefined),\n) => void\n\nexport type FormElementLookupHandler = (\n setter: (data: {\n submission: FormSubmissionModel\n elements: import('@oneblink/types').FormTypes.FormElement[]\n lastElementUpdated:\n | import('@oneblink/types').FormTypes.FormElement\n | undefined\n }) => {\n submission: FormSubmissionModel\n elements: import('@oneblink/types').FormTypes.FormElement[]\n },\n) => void\n\nexport type SetFormSubmission = React.Dispatch<\n React.SetStateAction<{\n definition: import('@oneblink/types').FormTypes.Form\n submission: FormSubmissionModel\n lastElementUpdated:\n | import('@oneblink/types').FormTypes.FormElement\n | undefined\n }>\n>\n\nexport type IsDirtyProps = {\n isDirty: boolean\n setIsDirty: () => void\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": "2.10.0-beta.2",
4
+ "version": "2.10.0-beta.4",
5
5
  "author": "OneBlink <developers@oneblink.io> (https://oneblink.io)",
6
6
  "bugs": {
7
7
  "url": "https://github.com/oneblink/apps-react/issues"