@oneblink/apps-react 5.7.0 → 5.8.0-beta.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.
Files changed (117) hide show
  1. package/dist/OneBlinkAutoSaveForm.d.ts +1 -1
  2. package/dist/OneBlinkFormBase.d.ts +5 -3
  3. package/dist/OneBlinkFormBase.js.map +1 -1
  4. package/dist/OneBlinkReadOnlyForm.d.ts +1 -1
  5. package/dist/OneBlinkReadOnlyForm.js +1 -0
  6. package/dist/OneBlinkReadOnlyForm.js.map +1 -1
  7. package/dist/PaymentReceipt.d.ts +1 -1
  8. package/dist/components/CopyToClipboardIconButton.d.ts +1 -1
  9. package/dist/components/CustomAccordion.d.ts +3 -3
  10. package/dist/components/ErrorSnackbar.d.ts +1 -1
  11. package/dist/components/ErrorSnackbar.js.map +1 -1
  12. package/dist/components/Lists.d.ts +1 -1
  13. package/dist/components/QuillHTML.d.ts +1 -1
  14. package/dist/components/formStore/FormStoreTableProvider.d.ts +1 -1
  15. package/dist/components/formStore/OneBlinkFormStoreClearFiltersButton.d.ts +1 -1
  16. package/dist/components/formStore/OneBlinkFormStoreColumnsButton.d.ts +1 -1
  17. package/dist/components/formStore/OneBlinkFormStoreDownloadButton.d.ts +1 -1
  18. package/dist/components/formStore/OneBlinkFormStoreProvider.d.ts +1 -1
  19. package/dist/components/formStore/OneBlinkFormStoreRefreshButton.d.ts +1 -1
  20. package/dist/components/formStore/OneBlinkFormStoreTable.d.ts +1 -1
  21. package/dist/components/formStore/display/ElementDisplay.d.ts +4 -4
  22. package/dist/components/formStore/table/ActionedByTableCell.d.ts +1 -1
  23. package/dist/components/formStore/table/ColumnFilters.d.ts +1 -1
  24. package/dist/components/formStore/table/FormElementTableCell.d.ts +1 -1
  25. package/dist/components/formStore/table/HeaderCellMoreButton.d.ts +1 -1
  26. package/dist/components/formStore/table/Pickers.d.ts +3 -3
  27. package/dist/components/formStore/table/TableCellCopyButton.d.ts +1 -1
  28. package/dist/components/messages/NoResourcesYet.d.ts +1 -1
  29. package/dist/components/payments/PaymentForm.d.ts +1 -1
  30. package/dist/components/payments/WestpacQuickStreamPaymentForm.d.ts +1 -1
  31. package/dist/components/receipts/Receipt.d.ts +1 -1
  32. package/dist/components/receipts/ReceiptButton.d.ts +1 -1
  33. package/dist/components/receipts/ReceiptList.d.ts +1 -1
  34. package/dist/components/receipts/ReceiptListItem.d.ts +1 -1
  35. package/dist/components/renderer/AnnotationModal.d.ts +1 -1
  36. package/dist/components/renderer/AutocompleteDropdown.d.ts +2 -2
  37. package/dist/components/renderer/CopyToClipboardButton.d.ts +1 -1
  38. package/dist/components/renderer/FormElementLabelContainer.d.ts +3 -3
  39. package/dist/components/renderer/FormElementOptions.d.ts +1 -1
  40. package/dist/components/renderer/LookupButton.d.ts +1 -1
  41. package/dist/components/renderer/LookupNotification.d.ts +1 -1
  42. package/dist/components/renderer/Modal.d.ts +2 -2
  43. package/dist/components/renderer/OnLoading.d.ts +1 -1
  44. package/dist/components/renderer/OneBlinkAppsErrorOriginalMessage.d.ts +1 -1
  45. package/dist/components/renderer/OneBlinkFormElements.d.ts +1 -1
  46. package/dist/components/renderer/PageFormElements.d.ts +1 -1
  47. package/dist/components/renderer/ProgressBar.d.ts +1 -1
  48. package/dist/components/renderer/attachments/AttachmentStatus.d.ts +1 -1
  49. package/dist/components/renderer/attachments/FileCard.d.ts +1 -1
  50. package/dist/components/renderer/attachments/FileCard.js +1 -1
  51. package/dist/components/renderer/attachments/FileCard.js.map +1 -1
  52. package/dist/components/renderer/attachments/FileCardContent.d.ts +1 -1
  53. package/dist/components/renderer/attachments/ImagePreviewUnavailable.d.ts +1 -1
  54. package/dist/form-elements/FormElementABN.d.ts +1 -1
  55. package/dist/form-elements/FormElementAPINSWLiquorLicence.d.ts +1 -1
  56. package/dist/form-elements/FormElementAPINSWLiquorLicence.js +17 -1
  57. package/dist/form-elements/FormElementAPINSWLiquorLicence.js.map +1 -1
  58. package/dist/form-elements/FormElementAutocomplete.d.ts +1 -1
  59. package/dist/form-elements/FormElementBSB.d.ts +1 -1
  60. package/dist/form-elements/FormElementBarcodeScanner.d.ts +1 -1
  61. package/dist/form-elements/FormElementBoolean.d.ts +1 -1
  62. package/dist/form-elements/FormElementCalculation.d.ts +1 -1
  63. package/dist/form-elements/FormElementCamera.d.ts +1 -1
  64. package/dist/form-elements/FormElementCaptcha.d.ts +1 -1
  65. package/dist/form-elements/FormElementCheckBoxes.d.ts +1 -1
  66. package/dist/form-elements/FormElementCivicaNameRecord.d.ts +1 -1
  67. package/dist/form-elements/FormElementCivicaStreetName.d.ts +1 -1
  68. package/dist/form-elements/FormElementCompliance.d.ts +1 -1
  69. package/dist/form-elements/FormElementDate.d.ts +1 -1
  70. package/dist/form-elements/FormElementDateTime.d.ts +1 -1
  71. package/dist/form-elements/FormElementEmail.d.ts +1 -1
  72. package/dist/form-elements/FormElementFiles.d.ts +1 -1
  73. package/dist/form-elements/FormElementFiles.js +1 -1
  74. package/dist/form-elements/FormElementFiles.js.map +1 -1
  75. package/dist/form-elements/FormElementForm.d.ts +1 -1
  76. package/dist/form-elements/FormElementFreshdeskDependentField.d.ts +1 -1
  77. package/dist/form-elements/FormElementGeoscapeAddress.d.ts +1 -1
  78. package/dist/form-elements/FormElementHTML.d.ts +1 -1
  79. package/dist/form-elements/FormElementHeading.d.ts +1 -1
  80. package/dist/form-elements/FormElementImage.d.ts +1 -1
  81. package/dist/form-elements/FormElementLocation.d.ts +1 -1
  82. package/dist/form-elements/FormElementNumber.d.ts +1 -1
  83. package/dist/form-elements/FormElementPointAddress.d.ts +1 -1
  84. package/dist/form-elements/FormElementRadio.d.ts +1 -1
  85. package/dist/form-elements/FormElementRepeatableSet.d.ts +1 -1
  86. package/dist/form-elements/FormElementSection.d.ts +1 -1
  87. package/dist/form-elements/FormElementSelect.d.ts +1 -1
  88. package/dist/form-elements/FormElementSignature.d.ts +1 -1
  89. package/dist/form-elements/FormElementSummary.d.ts +1 -1
  90. package/dist/form-elements/FormElementTelephone.d.ts +1 -1
  91. package/dist/form-elements/FormElementText.d.ts +1 -1
  92. package/dist/form-elements/FormElementTextarea.d.ts +1 -1
  93. package/dist/form-elements/FormElementTime.d.ts +1 -1
  94. package/dist/hooks/attachments/useAttachmentBlobs.d.ts +1 -1
  95. package/dist/hooks/useAuth.d.ts +1 -1
  96. package/dist/hooks/useDrafts.d.ts +1 -1
  97. package/dist/hooks/useDynamicOptionsLoaderState.d.ts +1 -1
  98. package/dist/hooks/useFlatpickrGuid.d.ts +1 -1
  99. package/dist/hooks/useFormElementLookups.d.ts +1 -1
  100. package/dist/hooks/useFormSubmissionModelContext.d.ts +1 -1
  101. package/dist/hooks/useIsHovering.d.ts +1 -1
  102. package/dist/hooks/useIsOffline.d.ts +1 -1
  103. package/dist/hooks/useIsPageVisible.d.ts +1 -1
  104. package/dist/hooks/useLogin.js.map +1 -1
  105. package/dist/hooks/usePendingSubmissions.d.ts +1 -1
  106. package/dist/styles/autocomplete.scss +3 -1
  107. package/dist/styles/camera.scss +12 -4
  108. package/dist/styles/compliance.scss +2 -2
  109. package/dist/styles/modal.scss +1 -1
  110. package/dist/styles/number.scss +15 -7
  111. package/dist/styles/ob-files.scss +7 -0
  112. package/dist/styles/ob-html.scss +8 -2
  113. package/dist/styles/renderer.scss +2 -0
  114. package/dist/styles/steps.scss +12 -4
  115. package/dist/styles.css +190 -182
  116. package/dist/styles.scss +14 -8
  117. package/package.json +39 -39
@@ -9,6 +9,6 @@ type Props = {
9
9
  displayValidationMessage: boolean;
10
10
  validationMessage: string | undefined;
11
11
  } & IsDirtyProps;
12
- declare function FormElementEmail({ id, element, value, onChange, validationMessage, displayValidationMessage, isDirty, setIsDirty, }: Props): JSX.Element;
12
+ declare function FormElementEmail({ id, element, value, onChange, validationMessage, displayValidationMessage, isDirty, setIsDirty, }: Props): React.JSX.Element;
13
13
  declare const _default: React.MemoExoticComponent<typeof FormElementEmail>;
14
14
  export default _default;
@@ -10,6 +10,6 @@ declare function FormElementFiles({ id, element, value, onChange, validationMess
10
10
  onChange: FormElementValueChangeHandler<attachmentsService.Attachment[]>;
11
11
  displayValidationMessage: boolean;
12
12
  validationMessage: string | undefined;
13
- } & IsDirtyProps): JSX.Element;
13
+ } & IsDirtyProps): React.JSX.Element;
14
14
  declare const _default: React.MemoExoticComponent<typeof FormElementFiles>;
15
15
  export default _default;
@@ -36,7 +36,7 @@ function FormElementFiles({ id, element, value, onChange, validationMessage, dis
36
36
  }),
37
37
  !element.readOnly &&
38
38
  (!element.maxEntries ||
39
- attachments.length < element.maxEntries) && (React.createElement("div", { className: "column is-one-quarter" },
39
+ attachments.length < element.maxEntries) && (React.createElement("div", { className: "column is-one-quarter-ob" },
40
40
  React.createElement("button", { type: "button", className: "button ob-files__add-new-button", onClick: handleAdd },
41
41
  React.createElement("i", { className: "material-icons icon-x-large" }, "add")))))),
42
42
  isDisplayingValidationMessage && (React.createElement("div", { role: "alert", className: "has-margin-top-8" },
@@ -1 +1 @@
1
- {"version":3,"file":"FormElementFiles.js","sourceRoot":"","sources":["../../src/form-elements/FormElementFiles.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,yBAAyB,MAAM,kDAAkD,CAAA;AACxF,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAC/C,OAAO,cAAc,MAAM,qCAAqC,CAAA;AAChE,OAAO,EACL,oBAAoB,EACpB,6BAA6B,GAC9B,MAAM,6BAA6B,CAAA;AAGpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAE1E,MAAM,UAAU,oBAAoB,CAClC,KAAkD;IAElD,IAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QAClD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;KAC7B;IACD,OAAO,EAAE,CAAA;AACX,CA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AChC,6BAAK,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,kBAAkB;gBAC5C,6BAAK,SAAS,EAAC,2DAA2D,IACvE,iBAAiB,CACd,CACF,CACP,CACyB,CACxB,CACP,CAAA;AACH,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport { FormTypes } from '@oneblink/types'\nimport FormElementLabelContainer from '../components/renderer/FormElementLabelContainer'\nimport FormElementFile from './FormElementFile'\nimport useAttachments from '../hooks/attachments/useAttachments'\nimport {\n checkFileNameIsValid,\n checkFileNameExtensionIsValid,\n} from '../services/form-validation'\nimport { attachmentsService } from '@oneblink/apps'\nimport { FormElementValueChangeHandler, IsDirtyProps } from '../types/form'\nimport { LookupNotificationContext } from '../hooks/useLookupNotification'\n\nexport function stringifyAttachments(\n value: attachmentsService.Attachment[] | undefined,\n): string {\n if (value?.every((attachment) => !attachment.type)) {\n return JSON.stringify(value)\n }\n return ''\n}\n\nfunction FormElementFiles({\n id,\n element,\n value,\n onChange,\n validationMessage,\n displayValidationMessage,\n isDirty,\n setIsDirty,\n}: {\n id: string\n element: FormTypes.FilesElement\n value?: attachmentsService.Attachment[]\n onChange: FormElementValueChangeHandler<attachmentsService.Attachment[]>\n displayValidationMessage: boolean\n validationMessage: string | undefined\n} & IsDirtyProps) {\n const { addAttachments, removeAttachment, changeAttachment } = useAttachments(\n element,\n onChange,\n setIsDirty,\n )\n\n const inputRef = React.useRef<HTMLInputElement>(null)\n\n const handleAdd = React.useCallback(() => {\n if (!inputRef.current) return\n // RESET HTML FILE INPUT VALUE SO FILES PREVIOUSLY ADDED AND REMOVED ARE RECOGNISED\n inputRef.current.value = ''\n inputRef.current.click()\n }, [])\n\n const attachments = value || []\n\n const { isLookingUp } = React.useContext(LookupNotificationContext)\n const isDisplayingValidationMessage =\n (isDirty || displayValidationMessage) && !!validationMessage && !isLookingUp\n\n return (\n <div className=\"cypress-files-element\">\n <FormElementLabelContainer\n className=\"ob-files\"\n element={element}\n id={id}\n required={!!element.minEntries}\n >\n <input\n ref={inputRef}\n type=\"file\"\n name={element.name}\n id={id}\n className=\"file-input ob-input\"\n multiple={element.maxEntries !== 1}\n disabled={element.readOnly}\n onChange={(event) =>\n addAttachments(\n event.target.files ? Array.from(event.target.files) : [],\n )\n }\n />\n <div className=\"control cypress-files-control\">\n <div className=\"columns is-multiline\">\n {attachments.map((attachment, index) => {\n return (\n <FormElementFile\n key={attachment.type ? attachment._id : attachment.id}\n element={element}\n onRemove={removeAttachment}\n file={attachment}\n onChange={changeAttachment}\n disableUpload={\n (!!element.maxEntries &&\n attachments.length > element.maxEntries) ||\n !checkFileNameIsValid(element, attachment.fileName) ||\n !checkFileNameExtensionIsValid(element, attachment.fileName)\n }\n index={index}\n />\n )\n })}\n {!element.readOnly &&\n (!element.maxEntries ||\n attachments.length < element.maxEntries) && (\n <div className=\"column is-one-quarter\">\n <button\n type=\"button\"\n className=\"button ob-files__add-new-button\"\n onClick={handleAdd}\n >\n <i className=\"material-icons icon-x-large\">add</i>\n </button>\n </div>\n )}\n </div>\n </div>\n\n {isDisplayingValidationMessage && (\n <div role=\"alert\" className=\"has-margin-top-8\">\n <div className=\"has-text-danger ob-error__text cypress-validation-message\">\n {validationMessage}\n </div>\n </div>\n )}\n </FormElementLabelContainer>\n </div>\n )\n}\n\nexport default React.memo(FormElementFiles)\n"]}
1
+ {"version":3,"file":"FormElementFiles.js","sourceRoot":"","sources":["../../src/form-elements/FormElementFiles.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,yBAAyB,MAAM,kDAAkD,CAAA;AACxF,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAC/C,OAAO,cAAc,MAAM,qCAAqC,CAAA;AAChE,OAAO,EACL,oBAAoB,EACpB,6BAA6B,GAC9B,MAAM,6BAA6B,CAAA;AAGpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAA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4BAClB,WAAW,CAAC,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAC5C,6BAAK,SAAS,EAAC,0BAA0B;wBACvC,gCACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,iCAAiC,EAC3C,OAAO,EAAE,SAAS;4BAElB,2BAAG,SAAS,EAAC,6BAA6B,UAAQ,CAC3C,CACL,CACP,CACC,CACF;YAEL,6BAA6B,IAAI,CAChC,6BAAK,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,kBAAkB;gBAC5C,6BAAK,SAAS,EAAC,2DAA2D,IACvE,iBAAiB,CACd,CACF,CACP,CACyB,CACxB,CACP,CAAA;AACH,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport { FormTypes } from '@oneblink/types'\nimport FormElementLabelContainer from '../components/renderer/FormElementLabelContainer'\nimport FormElementFile from './FormElementFile'\nimport useAttachments from '../hooks/attachments/useAttachments'\nimport {\n checkFileNameIsValid,\n checkFileNameExtensionIsValid,\n} from '../services/form-validation'\nimport { attachmentsService } from '@oneblink/apps'\nimport { FormElementValueChangeHandler, IsDirtyProps } from '../types/form'\nimport { LookupNotificationContext } from '../hooks/useLookupNotification'\n\nexport function stringifyAttachments(\n value: attachmentsService.Attachment[] | undefined,\n): string {\n if (value?.every((attachment) => !attachment.type)) {\n return JSON.stringify(value)\n }\n return ''\n}\n\nfunction FormElementFiles({\n id,\n element,\n value,\n onChange,\n validationMessage,\n displayValidationMessage,\n isDirty,\n setIsDirty,\n}: {\n id: string\n element: FormTypes.FilesElement\n value?: attachmentsService.Attachment[]\n onChange: FormElementValueChangeHandler<attachmentsService.Attachment[]>\n displayValidationMessage: boolean\n validationMessage: string | undefined\n} & IsDirtyProps) {\n const { addAttachments, removeAttachment, changeAttachment } = useAttachments(\n element,\n onChange,\n setIsDirty,\n )\n\n const inputRef = React.useRef<HTMLInputElement>(null)\n\n const handleAdd = React.useCallback(() => {\n if (!inputRef.current) return\n // RESET HTML FILE INPUT VALUE SO FILES PREVIOUSLY ADDED AND REMOVED ARE RECOGNISED\n inputRef.current.value = ''\n inputRef.current.click()\n }, [])\n\n const attachments = value || []\n\n const { isLookingUp } = React.useContext(LookupNotificationContext)\n const isDisplayingValidationMessage =\n (isDirty || displayValidationMessage) && !!validationMessage && !isLookingUp\n\n return (\n <div className=\"cypress-files-element\">\n <FormElementLabelContainer\n className=\"ob-files\"\n element={element}\n id={id}\n required={!!element.minEntries}\n >\n <input\n ref={inputRef}\n type=\"file\"\n name={element.name}\n id={id}\n className=\"file-input ob-input\"\n multiple={element.maxEntries !== 1}\n disabled={element.readOnly}\n onChange={(event) =>\n addAttachments(\n event.target.files ? Array.from(event.target.files) : [],\n )\n }\n />\n <div className=\"control cypress-files-control\">\n <div className=\"columns is-multiline\">\n {attachments.map((attachment, index) => {\n return (\n <FormElementFile\n key={attachment.type ? attachment._id : attachment.id}\n element={element}\n onRemove={removeAttachment}\n file={attachment}\n onChange={changeAttachment}\n disableUpload={\n (!!element.maxEntries &&\n attachments.length > element.maxEntries) ||\n !checkFileNameIsValid(element, attachment.fileName) ||\n !checkFileNameExtensionIsValid(element, attachment.fileName)\n }\n index={index}\n />\n )\n })}\n {!element.readOnly &&\n (!element.maxEntries ||\n attachments.length < element.maxEntries) && (\n <div className=\"column is-one-quarter-ob\">\n <button\n type=\"button\"\n className=\"button ob-files__add-new-button\"\n onClick={handleAdd}\n >\n <i className=\"material-icons icon-x-large\">add</i>\n </button>\n </div>\n )}\n </div>\n </div>\n\n {isDisplayingValidationMessage && (\n <div role=\"alert\" className=\"has-margin-top-8\">\n <div className=\"has-text-danger ob-error__text cypress-validation-message\">\n {validationMessage}\n </div>\n </div>\n )}\n </FormElementLabelContainer>\n </div>\n )\n}\n\nexport default React.memo(FormElementFiles)\n"]}
@@ -13,6 +13,6 @@ export type Props = {
13
13
  formElementConditionallyShown: FormElementConditionallyShown | undefined;
14
14
  onUpdateFormElements: UpdateFormElementsHandler;
15
15
  };
16
- declare function FormElementForm({ formId, element, value, id, formElementValidation, displayValidationMessages, formElementConditionallyShown, onChange, onLookup, onUpdateFormElements, }: Props): JSX.Element;
16
+ declare function FormElementForm({ formId, element, value, id, formElementValidation, displayValidationMessages, formElementConditionallyShown, onChange, onLookup, onUpdateFormElements, }: Props): React.JSX.Element;
17
17
  declare const _default: React.MemoExoticComponent<typeof FormElementForm>;
18
18
  export default _default;
@@ -3,6 +3,6 @@ import { FormTypes } from '@oneblink/types';
3
3
  import { Props } from './FormElementForm';
4
4
  declare function FormElementFreshdeskDependentField({ element, onUpdateFormElements, ...props }: Omit<Props, 'element'> & {
5
5
  element: FormTypes.FreshdeskDependentFieldElement;
6
- }): JSX.Element;
6
+ }): React.JSX.Element;
7
7
  declare const _default: React.MemoExoticComponent<typeof FormElementFreshdeskDependentField>;
8
8
  export default _default;
@@ -10,6 +10,6 @@ type Props = {
10
10
  validationMessage: string | undefined;
11
11
  onChange: FormElementValueChangeHandler<GeoscapeTypes.GeoscapeAddress>;
12
12
  } & IsDirtyProps;
13
- declare function FormElementGeoscapeAddress({ formId, id, element, value, displayValidationMessage, validationMessage, onChange, isDirty, setIsDirty, }: Props): JSX.Element;
13
+ declare function FormElementGeoscapeAddress({ formId, id, element, value, displayValidationMessage, validationMessage, onChange, isDirty, setIsDirty, }: Props): React.JSX.Element;
14
14
  declare const _default: React.MemoExoticComponent<typeof FormElementGeoscapeAddress>;
15
15
  export default _default;
@@ -3,6 +3,6 @@ import { FormTypes } from '@oneblink/types';
3
3
  type Props = {
4
4
  element: FormTypes.HtmlElement;
5
5
  };
6
- declare function FormElementHTML({ element }: Props): JSX.Element;
6
+ declare function FormElementHTML({ element }: Props): React.JSX.Element;
7
7
  declare const _default: React.MemoExoticComponent<typeof FormElementHTML>;
8
8
  export default _default;
@@ -3,6 +3,6 @@ import { FormTypes } from '@oneblink/types';
3
3
  type Props = {
4
4
  element: FormTypes.HeadingElement;
5
5
  };
6
- declare function FormElementHeading({ element }: Props): JSX.Element;
6
+ declare function FormElementHeading({ element }: Props): React.JSX.Element;
7
7
  declare const _default: React.MemoExoticComponent<typeof FormElementHeading>;
8
8
  export default _default;
@@ -3,6 +3,6 @@ import { FormTypes } from '@oneblink/types';
3
3
  type Props = {
4
4
  element: FormTypes.ImageElement;
5
5
  };
6
- declare function FormElementImage({ element }: Props): JSX.Element;
6
+ declare function FormElementImage({ element }: Props): React.JSX.Element;
7
7
  declare const _default: React.MemoExoticComponent<typeof FormElementImage>;
8
8
  export default _default;
@@ -15,6 +15,6 @@ type Coords = {
15
15
  zoom?: number;
16
16
  };
17
17
  export declare const stringifyLocation: (location: Coords | undefined) => string | undefined;
18
- declare function FormElementLocation({ id, element, value, onChange, validationMessage, displayValidationMessage, isDirty, setIsDirty, }: Props): JSX.Element;
18
+ declare function FormElementLocation({ id, element, value, onChange, validationMessage, displayValidationMessage, isDirty, setIsDirty, }: Props): React.JSX.Element;
19
19
  declare const _default: React.MemoExoticComponent<typeof FormElementLocation>;
20
20
  export default _default;
@@ -9,6 +9,6 @@ type Props = {
9
9
  displayValidationMessage: boolean;
10
10
  validationMessage: string | undefined;
11
11
  } & IsDirtyProps;
12
- declare function FormElementNumber({ id, element, value, onChange, validationMessage, displayValidationMessage, isDirty, setIsDirty, }: Props): JSX.Element;
12
+ declare function FormElementNumber({ id, element, value, onChange, validationMessage, displayValidationMessage, isDirty, setIsDirty, }: Props): React.JSX.Element;
13
13
  declare const _default: React.MemoExoticComponent<typeof FormElementNumber>;
14
14
  export default _default;
@@ -10,6 +10,6 @@ type Props = {
10
10
  validationMessage: string | undefined;
11
11
  onChange: FormElementValueChangeHandler<PointTypes.PointAddress>;
12
12
  } & IsDirtyProps;
13
- declare function FormElementPointAddress({ formId, id, element, value, displayValidationMessage, validationMessage, onChange, isDirty, setIsDirty, }: Props): JSX.Element;
13
+ declare function FormElementPointAddress({ formId, id, element, value, displayValidationMessage, validationMessage, onChange, isDirty, setIsDirty, }: Props): React.JSX.Element;
14
14
  declare const _default: React.MemoExoticComponent<typeof FormElementPointAddress>;
15
15
  export default _default;
@@ -11,6 +11,6 @@ type Props = {
11
11
  conditionallyShownOptionsElement: FormElementConditionallyShownElement | undefined;
12
12
  onUpdateFormElements: UpdateFormElementsHandler;
13
13
  } & IsDirtyProps;
14
- declare function FormElementRadio({ id, element, value, onChange, conditionallyShownOptionsElement, validationMessage, displayValidationMessage, onUpdateFormElements, isDirty, setIsDirty, }: Props): JSX.Element;
14
+ declare function FormElementRadio({ id, element, value, onChange, conditionallyShownOptionsElement, validationMessage, displayValidationMessage, onUpdateFormElements, isDirty, setIsDirty, }: Props): React.JSX.Element;
15
15
  declare const _default: React.MemoExoticComponent<typeof FormElementRadio>;
16
16
  export default _default;
@@ -15,6 +15,6 @@ type Props = {
15
15
  onUpdateFormElements: UpdateFormElementsHandler;
16
16
  } & IsDirtyProps;
17
17
  export declare function useRepeatableSetIndexText(text: string): string;
18
- declare function FormElementRepeatableSet({ formId, element, value, formElementValidation, id, isEven, displayValidationMessage, formElementConditionallyShown, onChange, onLookup, onUpdateFormElements, isDirty, setIsDirty, }: Props): JSX.Element;
18
+ declare function FormElementRepeatableSet({ formId, element, value, formElementValidation, id, isEven, displayValidationMessage, formElementConditionallyShown, onChange, onLookup, onUpdateFormElements, isDirty, setIsDirty, }: Props): React.JSX.Element;
19
19
  declare const _default: React.MemoExoticComponent<typeof FormElementRepeatableSet>;
20
20
  export default _default;
@@ -3,6 +3,6 @@ import { FormTypes } from '@oneblink/types';
3
3
  import { Props } from '../components/renderer/OneBlinkFormElements';
4
4
  declare function FormElementSection<T extends FormTypes._NestedElementsElement>({ element, onLookup, displayValidationMessages, onUpdateFormElements, ...props }: Omit<Props<T>, 'elements'> & {
5
5
  element: FormTypes.SectionElement;
6
- }): JSX.Element;
6
+ }): React.JSX.Element;
7
7
  declare const _default: React.MemoExoticComponent<typeof FormElementSection>;
8
8
  export default _default;
@@ -11,6 +11,6 @@ type Props = {
11
11
  conditionallyShownOptionsElement: FormElementConditionallyShownElement | undefined;
12
12
  onUpdateFormElements: UpdateFormElementsHandler;
13
13
  } & IsDirtyProps;
14
- declare function FormElementSelect({ id, element, value, onChange, validationMessage, displayValidationMessage, conditionallyShownOptionsElement, onUpdateFormElements, isDirty, setIsDirty, }: Props): JSX.Element;
14
+ declare function FormElementSelect({ id, element, value, onChange, validationMessage, displayValidationMessage, conditionallyShownOptionsElement, onUpdateFormElements, isDirty, setIsDirty, }: Props): React.JSX.Element;
15
15
  declare const _default: React.MemoExoticComponent<typeof FormElementSelect>;
16
16
  export default _default;
@@ -11,6 +11,6 @@ type Props = {
11
11
  displayValidationMessage: boolean;
12
12
  validationMessage: string | undefined;
13
13
  } & IsDirtyProps;
14
- declare function FormElementSignature({ id, element, value, onChange, validationMessage, displayValidationMessage, setIsDirty, isDirty, }: Props): JSX.Element;
14
+ declare function FormElementSignature({ id, element, value, onChange, validationMessage, displayValidationMessage, setIsDirty, isDirty, }: Props): React.JSX.Element;
15
15
  declare const _default: React.MemoExoticComponent<typeof FormElementSignature>;
16
16
  export default _default;
@@ -6,6 +6,6 @@ type Props = {
6
6
  onChange: FormElementValueChangeHandler;
7
7
  value: unknown;
8
8
  };
9
- declare function FormElementSummary({ element, onChange, value }: Props): JSX.Element;
9
+ declare function FormElementSummary({ element, onChange, value }: Props): React.JSX.Element;
10
10
  declare const _default: React.MemoExoticComponent<typeof FormElementSummary>;
11
11
  export default _default;
@@ -9,6 +9,6 @@ type Props = {
9
9
  displayValidationMessage: boolean;
10
10
  validationMessage: string | undefined;
11
11
  } & IsDirtyProps;
12
- declare function FormElementTelephone({ id, element, value, onChange, validationMessage, displayValidationMessage, isDirty, setIsDirty, }: Props): JSX.Element;
12
+ declare function FormElementTelephone({ id, element, value, onChange, validationMessage, displayValidationMessage, isDirty, setIsDirty, }: Props): React.JSX.Element;
13
13
  declare const _default: React.MemoExoticComponent<typeof FormElementTelephone>;
14
14
  export default _default;
@@ -9,6 +9,6 @@ type Props = {
9
9
  displayValidationMessage: boolean;
10
10
  validationMessage: string | undefined;
11
11
  } & IsDirtyProps;
12
- declare function FormElementText({ id, element, value, onChange, validationMessage, displayValidationMessage, isDirty, setIsDirty, }: Props): JSX.Element;
12
+ declare function FormElementText({ id, element, value, onChange, validationMessage, displayValidationMessage, isDirty, setIsDirty, }: Props): React.JSX.Element;
13
13
  declare const _default: React.MemoExoticComponent<typeof FormElementText>;
14
14
  export default _default;
@@ -9,6 +9,6 @@ type Props = {
9
9
  displayValidationMessage: boolean;
10
10
  validationMessage: string | undefined;
11
11
  } & IsDirtyProps;
12
- declare function FormElementTextarea({ id, element, value, onChange, validationMessage, displayValidationMessage, isDirty, setIsDirty, }: Props): JSX.Element;
12
+ declare function FormElementTextarea({ id, element, value, onChange, validationMessage, displayValidationMessage, isDirty, setIsDirty, }: Props): React.JSX.Element;
13
13
  declare const _default: React.MemoExoticComponent<typeof FormElementTextarea>;
14
14
  export default _default;
@@ -9,6 +9,6 @@ type Props = {
9
9
  displayValidationMessage: boolean;
10
10
  validationMessage: string | undefined;
11
11
  } & IsDirtyProps;
12
- declare function FormElementTime({ id, element, value, onChange, validationMessage, displayValidationMessage, isDirty, setIsDirty, }: Props): JSX.Element;
12
+ declare function FormElementTime({ id, element, value, onChange, validationMessage, displayValidationMessage, isDirty, setIsDirty, }: Props): React.JSX.Element;
13
13
  declare const _default: React.MemoExoticComponent<typeof FormElementTime>;
14
14
  export default _default;
@@ -14,6 +14,6 @@ type AttachmentBlobsContextValue = {
14
14
  type Props = {
15
15
  children: React.ReactNode;
16
16
  };
17
- export declare const AttachmentBlobsProvider: ({ children }: Props) => JSX.Element;
17
+ export declare const AttachmentBlobsProvider: ({ children }: Props) => React.JSX.Element;
18
18
  declare const useAttachmentBlobs: () => AttachmentBlobsContextValue;
19
19
  export default useAttachmentBlobs;
@@ -67,7 +67,7 @@ export declare function AuthContextProvider({ children, formsKeyToken, userToken
67
67
  * behalf of the user
68
68
  */
69
69
  userToken?: string;
70
- }): JSX.Element;
70
+ }): React.JSX.Element;
71
71
  /**
72
72
  * A React hook for containing state associated the current user. **This hook
73
73
  * requires [`<AuthContextProvider />`](./AuthContextProvider.html) to be
@@ -71,7 +71,7 @@ children, }: {
71
71
  formsAppId: number;
72
72
  isDraftsEnabled: boolean;
73
73
  children: React.ReactNode;
74
- }): JSX.Element;
74
+ }): React.JSX.Element;
75
75
  /**
76
76
  * React hook to get the context value for Drafts. Will throw an Error if used
77
77
  * outside of the `<DraftsContextProvider />` component.
@@ -11,6 +11,6 @@ export declare const FormElementOptionsContext: React.Context<OptionsSetResult[]
11
11
  export declare const FreshdeskFieldsStateContext: React.Context<LoadDataState<FreshdeskTypes.FreshdeskField[]> | undefined>;
12
12
  export declare function FormElementOptionsContextProvider({ children, }: {
13
13
  children: React.ReactNode;
14
- }): JSX.Element;
14
+ }): React.JSX.Element;
15
15
  export declare function useLoadDynamicOptionsEffect(formElement: FormTypes.FormElementWithOptions, onUpdateFormElements: UpdateFormElementsHandler): void;
16
16
  export {};
@@ -2,6 +2,6 @@ import * as React from 'react';
2
2
  type Props = {
3
3
  children: React.ReactNode;
4
4
  };
5
- export declare const FlatpickrGuidProvider: ({ children }: Props) => JSX.Element;
5
+ export declare const FlatpickrGuidProvider: ({ children }: Props) => React.JSX.Element;
6
6
  export default function useFlatpickrGuidCallback(): string;
7
7
  export {};
@@ -8,6 +8,6 @@ type FormElementLookupsContextValue = {
8
8
  };
9
9
  export declare function FormElementLookupsContextProvider({ children, }: {
10
10
  children: React.ReactNode;
11
- }): JSX.Element;
11
+ }): React.JSX.Element;
12
12
  export default function useFormElementLookups(): FormElementLookupsContextValue;
13
13
  export {};
@@ -12,6 +12,6 @@ export declare function FormSubmissionModelContextProvider({ children, model, el
12
12
  elements: FormTypes.FormElement[];
13
13
  formElementsConditionallyShown: FormElementsConditionallyShown | undefined;
14
14
  children: React.ReactNode;
15
- }): JSX.Element;
15
+ }): React.JSX.Element;
16
16
  export default function useFormSubmissionModel(): FormSubmissionModelContextValue;
17
17
  export declare function useFormSubmissionModelParent(): FormSubmissionModelContextValue;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
2
  declare const IsHoveringContext: React.Context<boolean>;
3
- export declare const IsHoveringProvider: React.ForwardRefExoticComponent<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>>;
3
+ export declare const IsHoveringProvider: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
4
4
  export declare function useIsHovering(): boolean;
5
5
  export default IsHoveringContext;
@@ -37,7 +37,7 @@ export declare const useNetworkChangeEffect: (type: 'online' | 'offline', listen
37
37
  */
38
38
  export declare function IsOfflineContextProvider({ children, }: {
39
39
  children: React.ReactNode;
40
- }): JSX.Element;
40
+ }): React.JSX.Element;
41
41
  /**
42
42
  * This function is a react hook for determining whether an application is in an
43
43
  * offline state.
@@ -4,6 +4,6 @@ type Props = {
4
4
  isPageVisible: IsPageVisibleContextValue;
5
5
  children: React.ReactNode;
6
6
  };
7
- export declare function IsPageVisibleProvider({ isPageVisible, children }: Props): JSX.Element;
7
+ export declare function IsPageVisibleProvider({ isPageVisible, children }: Props): React.JSX.Element;
8
8
  export default function useIsPageVisible(): boolean;
9
9
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"useLogin.js","sourceRoot":"","sources":["../../src/hooks/useLogin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEpD,OAAO,YAAY,MAAM,gBAAgB,CAAA;AACzC,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C,CAAC,CAAA,oBAAoB,aAApB,oBAAoB,uBAApB,oBAAoB,CAAE,eAAe,CAAA;QAC1D,mBAAmB;QACnB,aAAa;QACb,0BAA0B;QAC1B,uBAAuB;QACvB,kBAAkB;QAClB,kBAAkB;QAClB,mBAAmB;QACnB,wBAAwB;QACxB,+BAA+B;QAC/B,2BAA2B;QAC3B,sBAAsB;QACtB,+BAA+B;QAC/B,yBAAyB,EAAE,CAAC,CAAC,8BAA8B;QAC3D,4BAA4B;QAC5B,sBAAsB;QACtB,aAAa;QACb,kBAAkB;QAClB,kBAAkB;QAClB,cAAc;QACd,qBAAqB;QACrB,8BAA8B;KAC/B,CAAA;AACH,CAAC","sourcesContent":["import * as React from 'react'\nimport { authService, Sentry } from '@oneblink/apps'\n\nimport useIsMounted from './useIsMounted'\nimport useBooleanState from './useBooleanState'\n\n/**\n * This function is a react hook to help writing your own login screen.\n *\n * ## Example\n *\n * ```jsx\n * import * as React from 'react'\n * import { useHistory } from 'react-router-dom'\n * import { useLogin } from '@oneblink/apps-react'\n *\n * function App() {\n * const history = useHistory()\n *\n * const [username, setUsername] = React.useState('')\n * const [password, setPassword] = React.useState('')\n * const [newPasswordConfirmed, setNewPasswordConfirmed] = React.useState('')\n * const [newPassword, setNewPassword] = React.useState('')\n * const [code, setCode] = React.useState('')\n *\n * const onLogin = React.useCallback(() => {\n * history.push('/')\n * }, [history])\n *\n * const {\n * // Login\n * loginWithGoogle,\n * loginWithUsernamePassword,\n * isLoggingIn,\n * // Reset Temp Password\n * isPasswordTemporary,\n * isResettingTemporaryPassword,\n * resetTemporaryPassword,\n * // MFA Password\n * isMfaCodeRequired,\n * isSubmittingMfaCode,\n * submitMfaCode,\n * // Login Errors\n * loginError,\n * clearLoginError,\n * // Showing Forgot Password\n * isShowingForgotPassword,\n * showForgotPassword,\n * hideForgotPassword,\n * // Sending Forgot Password Code\n * isSendingForgotPasswordCode,\n * sendForgotPasswordCode,\n * // Resetting Forgotten Password\n * hasSentForgotPasswordCode,\n * isResettingForgottenPassword,\n * resetForgottenPassword,\n * // Forgot Password Errors\n * forgotPasswordError,\n * clearForgotPasswordError,\n * // Validation\n * usernameValidation,\n * passwordValidation,\n * codeValidation,\n * newPasswordValidation,\n * newPasswordConfirmedValidation,\n * } = useLogin({\n * username,\n * password,\n * newPassword,\n * newPasswordConfirmed,\n * code,\n * onLogin,\n * })\n *\n * if (hasSentForgotPasswordCode) {\n * return (\n * <form\n * onSubmit={(e) => {\n * e.preventDefault()\n * resetForgottenPassword()\n * }}\n * >\n * <p>We have sent you a password reset code via email. Enter it below to reset your password.</p>\n *\n * <input\n * type=\"password\"\n * placeholder=\"Code\"\n * value={code}\n * onChange={(e) => setCode(e.target.value)}\n * />\n *\n * <input\n * type=\"password\"\n * placeholder=\"New Password\"\n * value={newPassword}\n * onChange={(e) => setNewPassword(e.target.value)}\n * />\n *\n * <input\n * type=\"password\"\n * placeholder=\"Confirm Password\"\n * value={newPassword}\n * onChange={(e) => setNewPasswordConfirmed(e.target.value)}\n * />\n *\n * <button\n * type=\"submit\"\n * disabled={isResettingForgottenPassword || codeValidation.isInvalid || newPasswordValidation.isInvalid || newPasswordConfirmedValidation.isInvalid}\n * >\n * Change Password\n * </button>\n *\n * <p>Password Requirements</p>\n * <p>Contains a lowercase letter: {validation.hasLowercaseLetter ? 'Yes' : 'No'}</p>\n * <p>Contains an upper case letter: {validation.hasUpperCaseLetter ? 'Yes' : 'No'}</p>\n * <p>Contains a number: {validation.hasNumber ? 'Yes' : 'No'}</p>\n * <p>Contains a special character: {validation.hasSpecialCharacter ? 'Yes' : 'No'}</p>\n * <p>Contains at least 8 characters: {validation.hasMinLength ? 'Yes' : 'No'}</p>\n *\n * {forgotPasswordError && (\n * <p>{forgotPasswordError.message}</p>\n * <button type=\"button\" onClick={clearForgotPasswordError}>Clear Error</button>\n * )}\n * </form>\n * )\n * }\n *\n * if (isShowingForgotPassword) {\n * return (\n * <form\n * onSubmit={(e) => {\n * e.preventDefault()\n * sendForgotPasswordCode()\n * }}\n * >\n * <p>Enter your email address and we will send you a code to reset your password.</p>\n *\n * <input\n * type=\"email\"\n * placeholder=\"Email Address\"\n * value={username}\n * onChange={(e) => setUsername(e.target.value)}\n * />\n *\n * <p>\n * <a onClick={hideForgotPassword}>Remembered your password?</a>\n * </p>\n *\n * <button\n * type=\"submit\"\n * disabled={isSendingForgotPasswordCode || usernameValidation.isInvalid}\n * >\n * Reset Password\n * </button>\n *\n * {forgotPasswordError && (\n * <p>{forgotPasswordError.message}</p>\n * <button type=\"button\" onClick={clearForgotPasswordError}>Clear Error</button>\n * )}\n * </form>\n * )\n * }\n *\n * if (isPasswordTemporary) {\n * return (\n * <form\n * onSubmit={(e) => {\n * e.preventDefault()\n * resetTemporaryPassword()\n * }}\n * >\n * <p>The password you entered was only temporary and must be reset for security purposes. Please enter your new password below to continue.</p>\n *\n * <input\n * type=\"password\"\n * placeholder=\"New Password\"\n * value={newPassword}\n * onChange={(e) => setNewPassword(e.target.value)}\n * />\n *\n * <input\n * type=\"password\"\n * placeholder=\"Confirm Password\"\n * value={newPassword}\n * onChange={(e) => setNewPasswordConfirmed(e.target.value)}\n * />\n *\n * <button\n * type=\"submit\"\n * disabled={isResettingTemporaryPassword || newPasswordValidation.isInvalid || newPasswordConfirmedValidation.isInvalid}\n * >\n * Change Password &amp; Sign In\n * </button>\n *\n * <p>Password Requirements</p>\n * <p>Contains a lowercase letter: {validation.hasLowercaseLetter ? 'Yes' : 'No'}</p>\n * <p>Contains an upper case letter: {validation.hasUpperCaseLetter ? 'Yes' : 'No'}</p>\n * <p>Contains a number: {validation.hasNumber ? 'Yes' : 'No'}</p>\n * <p>Contains a special character: {validation.hasSpecialCharacter ? 'Yes' : 'No'}</p>\n * <p>Contains at least 8 characters: {validation.hasMinLength ? 'Yes' : 'No'}</p>\n *\n * {loginError && (\n * <p>{loginError.message}</p>\n * <button type=\"button\" onClick={clearLoginError}>Clear Error</button>\n * )}\n * </form>\n * )\n * }\n *\n * if (isMfaCodeRequired) {\n * return (\n * <form\n * onSubmit={(e) => {\n * e.preventDefault()\n * submitMfaCode()\n * }}\n * >\n * <p>Enter the 6-digit code found in your authenticator app.</p>\n *\n * <input\n * type=\"password\"\n * placeholder=\"Code\"\n * value={code}\n * onChange={(e) => setCode(e.target.value)}\n * />\n *\n * <button\n * type=\"submit\"\n * disabled={isSubmittingMfaCode || codeValidation.isInvalid}\n * >\n * Sign In\n * </button>\n *\n * {loginError && (\n * <p>{loginError.message}</p>\n * <button type=\"button\" onClick={clearLoginError}>Clear Error</button>\n * )}\n * </form>\n * )\n * }\n *\n * return (\n * <form\n * onSubmit={(e) => {\n * e.preventDefault()\n * loginWithUsernamePassword()\n * }}\n * >\n * <p>Sign in with your email address and password.</p>\n * <input\n * type=\"email\"\n * placeholder=\"Email Address\"\n * value={username}\n * onChange={(e) => setUsername(e.target.value)}\n * />\n *\n * <input\n * type=\"password\"\n * placeholder=\"New Password\"\n * value={newPassword}\n * onChange={(e) => setNewPassword(e.target.value)}\n * />\n *\n * <p>\n * <a onClick={showForgotPassword}>Forgot your password?</a>\n * </p>\n *\n * <button\n * type=\"submit\"\n * disabled={isLoggingIn || usernameValidation.isInvalid || passwordValidation.isInvalid}\n * >\n * {children}\n * </button>\n *\n * <p>or</p>\n *\n * <button\n * type=\"button\"\n * onClick={loginWithGoogle}\n * >\n * <img\n * alt=\"Google\"\n * src=\"google-sign-in.png\"\n * />\n * <span>Sign in with Google</span>\n * </button>\n *\n * {loginError && (\n * <p>{loginError.message}</p>\n * <button type=\"button\" onClick={clearLoginError}>Clear Error</button>\n * )}\n * </form>\n * )\n * }\n *\n * const root = document.getElementById('root')\n * if (root) {\n * ReactDOM.render(<App />, root)\n * }\n * ```\n *\n * @param options\n * @returns\n * @group Hooks\n */\nexport default function useLogin({\n username,\n password,\n newPassword,\n newPasswordConfirmed,\n code,\n}: {\n /** The email address entered by the user. */\n username: string\n /** The password entered by the user. */\n password: string\n /** The new password entered by the user if changing their password. */\n newPassword: string\n /**\n * The new password repeated by the user if changing their password to ensure\n * they do type it in wrong.\n */\n newPasswordConfirmed: string\n /**\n * The code sent to the user after requesting a password reset by starting the\n * \"forgot password\" process.\n */\n code: string\n}): UseLoginValue {\n const isMounted = useIsMounted()\n\n // Validation\n const usernameValidation = React.useMemo(() => {\n return {\n isInvalid: !username.trim(),\n }\n }, [username])\n\n const passwordValidation = React.useMemo(() => {\n return {\n isInvalid: !password.trim(),\n }\n }, [password])\n\n const codeValidation = React.useMemo(() => {\n return {\n isInvalid: !code.trim(),\n }\n }, [code])\n\n const newPasswordValidation = React.useMemo(() => {\n const validation = {\n hasLowercaseLetter: /[a-z]+/.test(newPassword),\n hasUpperCaseLetter: /[A-Z]+/.test(newPassword),\n hasNumber: /\\d+/.test(newPassword),\n hasSpecialCharacter: /[\\^$*.[\\]{}()?|\\-\"!@#%&/,><':;|_~`]+/.test(\n newPassword,\n ),\n hasMinLength: newPassword.length >= 8,\n isInvalid: true,\n }\n validation.isInvalid =\n !validation.hasLowercaseLetter ||\n !validation.hasUpperCaseLetter ||\n !validation.hasNumber ||\n !validation.hasSpecialCharacter ||\n !validation.hasMinLength\n return validation\n }, [newPassword])\n\n const newPasswordConfirmedValidation = React.useMemo(() => {\n return {\n isInvalid: newPassword !== newPasswordConfirmed,\n }\n }, [newPassword, newPasswordConfirmed])\n\n // Login, Reset Password, MFA\n const [\n {\n isResettingTemporaryPassword,\n isLoggingIn,\n loginError,\n loginAttemptResponse,\n isSubmittingMfaCode,\n },\n setLoginState,\n ] = React.useState<{\n isResettingTemporaryPassword: boolean\n isLoggingIn: boolean\n loginError: null | Error\n loginAttemptResponse: authService.LoginAttemptResponse | undefined\n isSubmittingMfaCode: boolean\n }>({\n isResettingTemporaryPassword: false,\n isLoggingIn: false,\n loginError: null,\n loginAttemptResponse: undefined,\n isSubmittingMfaCode: false,\n })\n const clearLoginError = React.useCallback(\n () =>\n setLoginState((current) => ({\n ...current,\n loginError: null,\n })),\n [],\n )\n const loginWithUsernamePassword = React.useCallback(async () => {\n if (usernameValidation.isInvalid) {\n setLoginState((current) => ({\n ...current,\n loginError: new Error('Please enter a valid email address'),\n }))\n return\n }\n if (passwordValidation.isInvalid) {\n setLoginState((current) => ({\n ...current,\n loginError: new Error('Please enter a valid password'),\n }))\n return\n }\n\n setLoginState((currentState) => ({\n ...currentState,\n isLoggingIn: true,\n loginError: null,\n }))\n\n try {\n const newLoginAttemptResponse = await authService.loginUsernamePassword(\n username,\n password,\n )\n if (isMounted.current) {\n setLoginState((currentState) => ({\n ...currentState,\n isLoggingIn: false,\n loginAttemptResponse: newLoginAttemptResponse,\n }))\n }\n } catch (error) {\n Sentry.captureException(error)\n if (isMounted.current) {\n setLoginState((currentState) => ({\n ...currentState,\n isLoggingIn: false,\n loginError: error as Error,\n }))\n }\n }\n }, [\n isMounted,\n password,\n passwordValidation.isInvalid,\n username,\n usernameValidation.isInvalid,\n ])\n\n const resetTemporaryPassword = React.useCallback(async () => {\n const resetTemporaryPasswordCallback =\n loginAttemptResponse?.resetPasswordCallback\n if (!resetTemporaryPasswordCallback) {\n return\n }\n\n if (newPasswordValidation.isInvalid) {\n setLoginState((current) => ({\n ...current,\n loginError: new Error('Please enter a valid password'),\n }))\n return\n }\n\n if (newPasswordConfirmedValidation.isInvalid) {\n setLoginState((current) => ({\n ...current,\n loginError: new Error('Please confirm your new password'),\n }))\n return\n }\n\n setLoginState((current) => ({\n ...current,\n isResettingPassword: true,\n loginError: null,\n }))\n\n try {\n const resetPasswordResponse = await resetTemporaryPasswordCallback(\n newPassword,\n )\n if (isMounted.current) {\n setLoginState((currentState) => ({\n ...currentState,\n isResettingTemporaryPassword: false,\n loginAttemptResponse: resetPasswordResponse,\n }))\n }\n } catch (error) {\n Sentry.captureException(error)\n if (isMounted.current) {\n setLoginState((current) => ({\n ...current,\n isResettingPassword: false,\n loginError: error as Error,\n }))\n }\n }\n }, [\n isMounted,\n loginAttemptResponse?.resetPasswordCallback,\n newPassword,\n newPasswordConfirmedValidation.isInvalid,\n newPasswordValidation.isInvalid,\n ])\n\n const submitMfaCode = React.useCallback(async () => {\n const mfaCodeCallback = loginAttemptResponse?.mfaCodeCallback\n if (!mfaCodeCallback) {\n return\n }\n\n setLoginState((current) => ({\n ...current,\n isSubmittingMfaCode: true,\n loginError: null,\n }))\n\n try {\n const mfaResponse = await mfaCodeCallback(code)\n if (isMounted.current) {\n setLoginState((currentState) => ({\n ...currentState,\n isSubmittingMfaCode: false,\n loginAttemptResponse: mfaResponse,\n }))\n }\n } catch (error) {\n Sentry.captureException(error)\n if (isMounted.current) {\n setLoginState((current) => ({\n ...current,\n isSubmittingMfaCode: false,\n loginError: error as Error,\n }))\n }\n }\n }, [code, isMounted, loginAttemptResponse?.mfaCodeCallback])\n\n // Forgot Password\n const [isShowingForgotPassword, showForgotPassword, hideForgotPassword] =\n useBooleanState(false)\n const [\n {\n resetForgottenPasswordCallback,\n isSendingForgotPasswordCode,\n isResettingForgottenPassword,\n forgotPasswordError,\n },\n setForgotPasswordState,\n ] = React.useState<{\n isSendingForgotPasswordCode: boolean\n forgotPasswordError: null | Error\n resetForgottenPasswordCallback:\n | null\n | ((code: string, newPassword: string) => void)\n isResettingForgottenPassword: boolean\n }>({\n isSendingForgotPasswordCode: false,\n forgotPasswordError: null,\n resetForgottenPasswordCallback: null,\n isResettingForgottenPassword: false,\n })\n const clearForgotPasswordError = React.useCallback(\n () =>\n setForgotPasswordState((current) => ({\n ...current,\n forgotPasswordError: null,\n })),\n [],\n )\n const sendForgotPasswordCode = React.useCallback(async () => {\n if (usernameValidation.isInvalid) {\n setForgotPasswordState((current) => ({\n ...current,\n forgotPasswordError: new Error('Please enter a valid email address'),\n }))\n return\n }\n\n setForgotPasswordState({\n isSendingForgotPasswordCode: true,\n resetForgottenPasswordCallback: null,\n forgotPasswordError: null,\n isResettingForgottenPassword: false,\n })\n\n try {\n const newResetForgottenPasswordCallback =\n await authService.forgotPassword(username)\n if (isMounted.current) {\n setForgotPasswordState({\n isSendingForgotPasswordCode: false,\n resetForgottenPasswordCallback: newResetForgottenPasswordCallback,\n forgotPasswordError: null,\n isResettingForgottenPassword: false,\n })\n }\n } catch (error) {\n Sentry.captureException(error)\n if (isMounted.current) {\n setForgotPasswordState({\n isSendingForgotPasswordCode: false,\n resetForgottenPasswordCallback: null,\n forgotPasswordError: error as Error,\n isResettingForgottenPassword: false,\n })\n }\n }\n }, [isMounted, username, usernameValidation.isInvalid])\n\n const resetForgottenPassword = React.useCallback(async () => {\n if (!resetForgottenPasswordCallback) {\n return\n }\n\n if (codeValidation.isInvalid) {\n setForgotPasswordState((current) => ({\n ...current,\n forgotPasswordError: new Error(\n 'Please enter the code that was sent to your email address',\n ),\n }))\n }\n if (newPasswordValidation.isInvalid) {\n setForgotPasswordState((current) => ({\n ...current,\n forgotPasswordError: new Error('Please enter a valid password'),\n }))\n return\n }\n if (newPasswordConfirmedValidation.isInvalid) {\n setForgotPasswordState((current) => ({\n ...current,\n forgotPasswordError: new Error('Please confirm your new password'),\n }))\n return\n }\n\n setForgotPasswordState((current) => ({\n ...current,\n isChangingPassword: true,\n forgotPasswordError: null,\n }))\n\n try {\n await resetForgottenPasswordCallback(code, newPassword)\n if (isMounted.current) {\n setForgotPasswordState({\n isSendingForgotPasswordCode: false,\n resetForgottenPasswordCallback: null,\n forgotPasswordError: null,\n isResettingForgottenPassword: false,\n })\n hideForgotPassword()\n }\n } catch (error) {\n Sentry.captureException(error)\n if (isMounted.current) {\n setForgotPasswordState((current) => ({\n ...current,\n isChangingPassword: false,\n forgotPasswordError: error as Error,\n }))\n }\n }\n }, [\n resetForgottenPasswordCallback,\n codeValidation.isInvalid,\n newPasswordValidation.isInvalid,\n newPasswordConfirmedValidation.isInvalid,\n code,\n newPassword,\n isMounted,\n hideForgotPassword,\n ])\n\n const loginWithGoogle = React.useCallback(() => {\n authService.loginHostedUI('Google')\n }, [])\n\n return {\n // Login\n /** Open redirect user to the Google sign in */\n loginWithGoogle,\n loginWithUsernamePassword,\n isLoggingIn,\n loginError,\n clearLoginError,\n // Reset Temp Password\n isPasswordTemporary: !!loginAttemptResponse?.resetPasswordCallback,\n isResettingTemporaryPassword,\n resetTemporaryPassword,\n // MFA Code\n isMfaCodeRequired: !!loginAttemptResponse?.mfaCodeCallback,\n isSubmittingMfaCode,\n submitMfaCode,\n // Showing Forgot Password\n isShowingForgotPassword,\n showForgotPassword,\n hideForgotPassword,\n forgotPasswordError,\n clearForgotPasswordError,\n // Sending Forgot Password Code\n isSendingForgotPasswordCode,\n sendForgotPasswordCode,\n // Resetting Forgotten Password\n hasSentForgotPasswordCode: !!resetForgottenPasswordCallback,\n isResettingForgottenPassword,\n resetForgottenPassword,\n // Validation\n usernameValidation,\n passwordValidation,\n codeValidation,\n newPasswordValidation,\n newPasswordConfirmedValidation,\n }\n}\n\nexport interface UseLoginValue {\n /** Open redirect user to the Google sign-in page. */\n loginWithGoogle: () => void\n /**\n * Attempt to use the `username` and `password` arguments to create a session.\n * Will call `onLogin()` if successful, otherwise will set `loginError`.\n */\n loginWithUsernamePassword: () => void\n /** `true` while processing `loginWithUsernamePassword()`. */\n isLoggingIn: boolean\n /**\n * `true` if the user logged in using a temporary password. Prompt the user\n * for a new password and call `resetTemporaryPassword()`.\n */\n isPasswordTemporary: boolean\n /**\n * Attempt to use `newPassword` and `newPasswordConfirmed` arguments to reset\n * the user's password and create a session. Will call `onLogin()` if\n * successful, otherwise will set `loginError`.\n */\n resetTemporaryPassword: () => void\n /**\n * Set if an error occurs while processing `loginWithUsernamePassword()` or\n * `resetTemporaryPassword()`.\n */\n loginError: Error | null\n /** Set `loginError` back to `null`. */\n clearLoginError: () => void\n /** `true` while processing `resetTemporaryPassword()`. */\n isResettingTemporaryPassword: boolean\n /** `true` when showing the forgot password flow. */\n isShowingForgotPassword: boolean\n /** Set `isShowingForgotPassword` to `true`. */\n showForgotPassword: () => void\n /** Set `isShowingForgotPassword` to `false`. */\n hideForgotPassword: () => void\n /**\n * Attempt to use the `username` argument to start the forgot password\n * process. This will send the user an email with a code to enter. A failed\n * request will set `forgotPasswordError`.\n */\n sendForgotPasswordCode: () => void\n /** `true` while processing `sendForgotPasswordCode()`. */\n isSendingForgotPasswordCode: boolean\n /** `true` if the forgot password code has been successfully sent to the user. */\n hasSentForgotPasswordCode: boolean\n /**\n * Attempt to use the `code`, `newPassword`, and `newPasswordConfirmed`\n * arguments to reset the user's password. A failed request will set\n * `forgotPasswordError`.\n */\n resetForgottenPassword: () => void\n /** `true` while processing `resetForgottenPassword()`. */\n isResettingForgottenPassword: boolean\n /**\n * Set if an error occurs while processing `sendForgotPasswordCode()` or\n * `resetForgottenPassword()`.\n */\n forgotPasswordError: Error | null\n /** Set `forgotPasswordError` back to `null`. */\n clearForgotPasswordError: () => void\n usernameValidation: {\n /** `true` if the `username` argument is invalid. */\n isInvalid: boolean\n }\n passwordValidation: {\n /** `true` if the `password` argument is invalid. */\n isInvalid: boolean\n }\n codeValidation: {\n /** `true` if the `code` argument is invalid. */\n isInvalid: boolean\n }\n newPasswordValidation: {\n /** `true` if the `newPassword` argument is invalid. */\n isInvalid: boolean\n /**\n * `true` if the `newPassword` argument has a lowercase letter (required to\n * be valid).\n */\n hasLowercaseLetter: boolean\n /**\n * `true` if the `newPassword` argument has an uppercase letter (required to\n * be valid).\n */\n hasUpperCaseLetter: boolean\n /** `true` if the `newPassword` argument has a number (required to be valid). */\n hasNumber: boolean\n /**\n * `true` if the `newPassword` argument has a special character (required to\n * be valid).\n */\n hasSpecialCharacter: boolean\n /**\n * `true` if the `newPassword` argument has at least the minimum number of\n * characters (required to be valid).\n */\n hasMinLength: boolean\n }\n newPasswordConfirmedValidation: {\n /**\n * `true` if the `newPasswordConfirmed` argument is invalid (must match the\n * `newPassword` argument).\n */\n isInvalid: boolean\n }\n /**\n * `true` if the user logged in using MFA and a code is required to finish the\n * login attempt. Prompt the user for a code and call `submitMfaCode()`.\n */\n isMfaCodeRequired: boolean\n /** `true` while processing `submitMfaCode()`. */\n isSubmittingMfaCode: boolean\n /**\n * Attempt to use `code` argument to submit the MFA code and create a session.\n * Will call `onLogin()` if successful, otherwise will set `loginError`.\n */\n submitMfaCode: () => void\n}\n"]}
1
+ {"version":3,"file":"useLogin.js","sourceRoot":"","sources":["../../src/hooks/useLogin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEpD,OAAO,YAAY,MAAM,gBAAgB,CAAA;AACzC,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0SG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC/B,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,oBAAoB,EACpB,IAAI,GAkBL;IACC,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAEhC,aAAa;IACb,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAC5C,OAAO;YACL,SAAS,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE;SAC5B,CAAA;IACH,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAA;IAEd,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAC5C,OAAO;YACL,SAAS,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE;SAC5B,CAAA;IACH,CAAC,EAAE,CAAC,QAAQ,C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MAAM,eAAe,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QAC7C,WAAW,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;IACrC,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO;QACL,QAAQ;QACR,+CAA+C;QAC/C,eAAe;QACf,yBAAyB;QACzB,WAAW;QACX,UAAU;QACV,eAAe;QACf,sBAAsB;QACtB,mBAAmB,EAAE,CAAC,CAAC,CAAA,oBAAoB,aAApB,oBAAoB,uBAApB,oBAAoB,CAAE,qBAAqB,CAAA;QAClE,4BAA4B;QAC5B,sBAAsB;QACtB,WAAW;QACX,iBAAiB,EAAE,CAAC,CAAC,CAAA,oBAAoB,aAApB,oBAAoB,uBAApB,oBAAoB,CAAE,eAAe,CAAA;QAC1D,mBAAmB;QACnB,aAAa;QACb,0BAA0B;QAC1B,uBAAuB;QACvB,kBAAkB;QAClB,kBAAkB;QAClB,mBAAmB;QACnB,wBAAwB;QACxB,+BAA+B;QAC/B,2BAA2B;QAC3B,sBAAsB;QACtB,+BAA+B;QAC/B,yBAAyB,EAAE,CAAC,CAAC,8BAA8B;QAC3D,4BAA4B;QAC5B,sBAAsB;QACtB,aAAa;QACb,kBAAkB;QAClB,kBAAkB;QAClB,cAAc;QACd,qBAAqB;QACrB,8BAA8B;KAC/B,CAAA;AACH,CAAC","sourcesContent":["import * as React from 'react'\nimport { authService, Sentry } from '@oneblink/apps'\n\nimport useIsMounted from './useIsMounted'\nimport useBooleanState from './useBooleanState'\n\n/**\n * This function is a react hook to help writing your own login screen.\n *\n * ## Example\n *\n * ```jsx\n * import * as React from 'react'\n * import { useHistory } from 'react-router-dom'\n * import { useLogin } from '@oneblink/apps-react'\n *\n * function App() {\n * const history = useHistory()\n *\n * const [username, setUsername] = React.useState('')\n * const [password, setPassword] = React.useState('')\n * const [newPasswordConfirmed, setNewPasswordConfirmed] = React.useState('')\n * const [newPassword, setNewPassword] = React.useState('')\n * const [code, setCode] = React.useState('')\n *\n * const onLogin = React.useCallback(() => {\n * history.push('/')\n * }, [history])\n *\n * const {\n * // Login\n * loginWithGoogle,\n * loginWithUsernamePassword,\n * isLoggingIn,\n * // Reset Temp Password\n * isPasswordTemporary,\n * isResettingTemporaryPassword,\n * resetTemporaryPassword,\n * // MFA Password\n * isMfaCodeRequired,\n * isSubmittingMfaCode,\n * submitMfaCode,\n * // Login Errors\n * loginError,\n * clearLoginError,\n * // Showing Forgot Password\n * isShowingForgotPassword,\n * showForgotPassword,\n * hideForgotPassword,\n * // Sending Forgot Password Code\n * isSendingForgotPasswordCode,\n * sendForgotPasswordCode,\n * // Resetting Forgotten Password\n * hasSentForgotPasswordCode,\n * isResettingForgottenPassword,\n * resetForgottenPassword,\n * // Forgot Password Errors\n * forgotPasswordError,\n * clearForgotPasswordError,\n * // Validation\n * usernameValidation,\n * passwordValidation,\n * codeValidation,\n * newPasswordValidation,\n * newPasswordConfirmedValidation,\n * } = useLogin({\n * username,\n * password,\n * newPassword,\n * newPasswordConfirmed,\n * code,\n * onLogin,\n * })\n *\n * if (hasSentForgotPasswordCode) {\n * return (\n * <form\n * onSubmit={(e) => {\n * e.preventDefault()\n * resetForgottenPassword()\n * }}\n * >\n * <p>We have sent you a password reset code via email. Enter it below to reset your password.</p>\n *\n * <input\n * type=\"password\"\n * placeholder=\"Code\"\n * value={code}\n * onChange={(e) => setCode(e.target.value)}\n * />\n *\n * <input\n * type=\"password\"\n * placeholder=\"New Password\"\n * value={newPassword}\n * onChange={(e) => setNewPassword(e.target.value)}\n * />\n *\n * <input\n * type=\"password\"\n * placeholder=\"Confirm Password\"\n * value={newPassword}\n * onChange={(e) => setNewPasswordConfirmed(e.target.value)}\n * />\n *\n * <button\n * type=\"submit\"\n * disabled={isResettingForgottenPassword || codeValidation.isInvalid || newPasswordValidation.isInvalid || newPasswordConfirmedValidation.isInvalid}\n * >\n * Change Password\n * </button>\n *\n * <p>Password Requirements</p>\n * <p>Contains a lowercase letter: {validation.hasLowercaseLetter ? 'Yes' : 'No'}</p>\n * <p>Contains an upper case letter: {validation.hasUpperCaseLetter ? 'Yes' : 'No'}</p>\n * <p>Contains a number: {validation.hasNumber ? 'Yes' : 'No'}</p>\n * <p>Contains a special character: {validation.hasSpecialCharacter ? 'Yes' : 'No'}</p>\n * <p>Contains at least 8 characters: {validation.hasMinLength ? 'Yes' : 'No'}</p>\n *\n * {forgotPasswordError && (\n * <p>{forgotPasswordError.message}</p>\n * <button type=\"button\" onClick={clearForgotPasswordError}>Clear Error</button>\n * )}\n * </form>\n * )\n * }\n *\n * if (isShowingForgotPassword) {\n * return (\n * <form\n * onSubmit={(e) => {\n * e.preventDefault()\n * sendForgotPasswordCode()\n * }}\n * >\n * <p>Enter your email address and we will send you a code to reset your password.</p>\n *\n * <input\n * type=\"email\"\n * placeholder=\"Email Address\"\n * value={username}\n * onChange={(e) => setUsername(e.target.value)}\n * />\n *\n * <p>\n * <a onClick={hideForgotPassword}>Remembered your password?</a>\n * </p>\n *\n * <button\n * type=\"submit\"\n * disabled={isSendingForgotPasswordCode || usernameValidation.isInvalid}\n * >\n * Reset Password\n * </button>\n *\n * {forgotPasswordError && (\n * <p>{forgotPasswordError.message}</p>\n * <button type=\"button\" onClick={clearForgotPasswordError}>Clear Error</button>\n * )}\n * </form>\n * )\n * }\n *\n * if (isPasswordTemporary) {\n * return (\n * <form\n * onSubmit={(e) => {\n * e.preventDefault()\n * resetTemporaryPassword()\n * }}\n * >\n * <p>The password you entered was only temporary and must be reset for security purposes. Please enter your new password below to continue.</p>\n *\n * <input\n * type=\"password\"\n * placeholder=\"New Password\"\n * value={newPassword}\n * onChange={(e) => setNewPassword(e.target.value)}\n * />\n *\n * <input\n * type=\"password\"\n * placeholder=\"Confirm Password\"\n * value={newPassword}\n * onChange={(e) => setNewPasswordConfirmed(e.target.value)}\n * />\n *\n * <button\n * type=\"submit\"\n * disabled={isResettingTemporaryPassword || newPasswordValidation.isInvalid || newPasswordConfirmedValidation.isInvalid}\n * >\n * Change Password &amp; Sign In\n * </button>\n *\n * <p>Password Requirements</p>\n * <p>Contains a lowercase letter: {validation.hasLowercaseLetter ? 'Yes' : 'No'}</p>\n * <p>Contains an upper case letter: {validation.hasUpperCaseLetter ? 'Yes' : 'No'}</p>\n * <p>Contains a number: {validation.hasNumber ? 'Yes' : 'No'}</p>\n * <p>Contains a special character: {validation.hasSpecialCharacter ? 'Yes' : 'No'}</p>\n * <p>Contains at least 8 characters: {validation.hasMinLength ? 'Yes' : 'No'}</p>\n *\n * {loginError && (\n * <p>{loginError.message}</p>\n * <button type=\"button\" onClick={clearLoginError}>Clear Error</button>\n * )}\n * </form>\n * )\n * }\n *\n * if (isMfaCodeRequired) {\n * return (\n * <form\n * onSubmit={(e) => {\n * e.preventDefault()\n * submitMfaCode()\n * }}\n * >\n * <p>Enter the 6-digit code found in your authenticator app.</p>\n *\n * <input\n * type=\"password\"\n * placeholder=\"Code\"\n * value={code}\n * onChange={(e) => setCode(e.target.value)}\n * />\n *\n * <button\n * type=\"submit\"\n * disabled={isSubmittingMfaCode || codeValidation.isInvalid}\n * >\n * Sign In\n * </button>\n *\n * {loginError && (\n * <p>{loginError.message}</p>\n * <button type=\"button\" onClick={clearLoginError}>Clear Error</button>\n * )}\n * </form>\n * )\n * }\n *\n * return (\n * <form\n * onSubmit={(e) => {\n * e.preventDefault()\n * loginWithUsernamePassword()\n * }}\n * >\n * <p>Sign in with your email address and password.</p>\n * <input\n * type=\"email\"\n * placeholder=\"Email Address\"\n * value={username}\n * onChange={(e) => setUsername(e.target.value)}\n * />\n *\n * <input\n * type=\"password\"\n * placeholder=\"New Password\"\n * value={newPassword}\n * onChange={(e) => setNewPassword(e.target.value)}\n * />\n *\n * <p>\n * <a onClick={showForgotPassword}>Forgot your password?</a>\n * </p>\n *\n * <button\n * type=\"submit\"\n * disabled={isLoggingIn || usernameValidation.isInvalid || passwordValidation.isInvalid}\n * >\n * {children}\n * </button>\n *\n * <p>or</p>\n *\n * <button\n * type=\"button\"\n * onClick={loginWithGoogle}\n * >\n * <img\n * alt=\"Google\"\n * src=\"google-sign-in.png\"\n * />\n * <span>Sign in with Google</span>\n * </button>\n *\n * {loginError && (\n * <p>{loginError.message}</p>\n * <button type=\"button\" onClick={clearLoginError}>Clear Error</button>\n * )}\n * </form>\n * )\n * }\n *\n * const root = document.getElementById('root')\n * if (root) {\n * ReactDOM.render(<App />, root)\n * }\n * ```\n *\n * @param options\n * @returns\n * @group Hooks\n */\nexport default function useLogin({\n username,\n password,\n newPassword,\n newPasswordConfirmed,\n code,\n}: {\n /** The email address entered by the user. */\n username: string\n /** The password entered by the user. */\n password: string\n /** The new password entered by the user if changing their password. */\n newPassword: string\n /**\n * The new password repeated by the user if changing their password to ensure\n * they do type it in wrong.\n */\n newPasswordConfirmed: string\n /**\n * The code sent to the user after requesting a password reset by starting the\n * \"forgot password\" process.\n */\n code: string\n}): UseLoginValue {\n const isMounted = useIsMounted()\n\n // Validation\n const usernameValidation = React.useMemo(() => {\n return {\n isInvalid: !username.trim(),\n }\n }, [username])\n\n const passwordValidation = React.useMemo(() => {\n return {\n isInvalid: !password.trim(),\n }\n }, [password])\n\n const codeValidation = React.useMemo(() => {\n return {\n isInvalid: !code.trim(),\n }\n }, [code])\n\n const newPasswordValidation = React.useMemo(() => {\n const validation = {\n hasLowercaseLetter: /[a-z]+/.test(newPassword),\n hasUpperCaseLetter: /[A-Z]+/.test(newPassword),\n hasNumber: /\\d+/.test(newPassword),\n hasSpecialCharacter: /[\\^$*.[\\]{}()?|\\-\"!@#%&/,><':;|_~`]+/.test(\n newPassword,\n ),\n hasMinLength: newPassword.length >= 8,\n isInvalid: true,\n }\n validation.isInvalid =\n !validation.hasLowercaseLetter ||\n !validation.hasUpperCaseLetter ||\n !validation.hasNumber ||\n !validation.hasSpecialCharacter ||\n !validation.hasMinLength\n return validation\n }, [newPassword])\n\n const newPasswordConfirmedValidation = React.useMemo(() => {\n return {\n isInvalid: newPassword !== newPasswordConfirmed,\n }\n }, [newPassword, newPasswordConfirmed])\n\n // Login, Reset Password, MFA\n const [\n {\n isResettingTemporaryPassword,\n isLoggingIn,\n loginError,\n loginAttemptResponse,\n isSubmittingMfaCode,\n },\n setLoginState,\n ] = React.useState<{\n isResettingTemporaryPassword: boolean\n isLoggingIn: boolean\n loginError: null | Error\n loginAttemptResponse: authService.LoginAttemptResponse | undefined\n isSubmittingMfaCode: boolean\n }>({\n isResettingTemporaryPassword: false,\n isLoggingIn: false,\n loginError: null,\n loginAttemptResponse: undefined,\n isSubmittingMfaCode: false,\n })\n const clearLoginError = React.useCallback(\n () =>\n setLoginState((current) => ({\n ...current,\n loginError: null,\n })),\n [],\n )\n const loginWithUsernamePassword = React.useCallback(async () => {\n if (usernameValidation.isInvalid) {\n setLoginState((current) => ({\n ...current,\n loginError: new Error('Please enter a valid email address'),\n }))\n return\n }\n if (passwordValidation.isInvalid) {\n setLoginState((current) => ({\n ...current,\n loginError: new Error('Please enter a valid password'),\n }))\n return\n }\n\n setLoginState((currentState) => ({\n ...currentState,\n isLoggingIn: true,\n loginError: null,\n }))\n\n try {\n const newLoginAttemptResponse = await authService.loginUsernamePassword(\n username,\n password,\n )\n if (isMounted.current) {\n setLoginState((currentState) => ({\n ...currentState,\n isLoggingIn: false,\n loginAttemptResponse: newLoginAttemptResponse,\n }))\n }\n } catch (error) {\n Sentry.captureException(error)\n if (isMounted.current) {\n setLoginState((currentState) => ({\n ...currentState,\n isLoggingIn: false,\n loginError: error as Error,\n }))\n }\n }\n }, [\n isMounted,\n password,\n passwordValidation.isInvalid,\n username,\n usernameValidation.isInvalid,\n ])\n\n const resetTemporaryPassword = React.useCallback(async () => {\n const resetTemporaryPasswordCallback =\n loginAttemptResponse?.resetPasswordCallback\n if (!resetTemporaryPasswordCallback) {\n return\n }\n\n if (newPasswordValidation.isInvalid) {\n setLoginState((current) => ({\n ...current,\n loginError: new Error('Please enter a valid password'),\n }))\n return\n }\n\n if (newPasswordConfirmedValidation.isInvalid) {\n setLoginState((current) => ({\n ...current,\n loginError: new Error('Please confirm your new password'),\n }))\n return\n }\n\n setLoginState((current) => ({\n ...current,\n isResettingPassword: true,\n loginError: null,\n }))\n\n try {\n const resetPasswordResponse =\n await resetTemporaryPasswordCallback(newPassword)\n if (isMounted.current) {\n setLoginState((currentState) => ({\n ...currentState,\n isResettingTemporaryPassword: false,\n loginAttemptResponse: resetPasswordResponse,\n }))\n }\n } catch (error) {\n Sentry.captureException(error)\n if (isMounted.current) {\n setLoginState((current) => ({\n ...current,\n isResettingPassword: false,\n loginError: error as Error,\n }))\n }\n }\n }, [\n isMounted,\n loginAttemptResponse?.resetPasswordCallback,\n newPassword,\n newPasswordConfirmedValidation.isInvalid,\n newPasswordValidation.isInvalid,\n ])\n\n const submitMfaCode = React.useCallback(async () => {\n const mfaCodeCallback = loginAttemptResponse?.mfaCodeCallback\n if (!mfaCodeCallback) {\n return\n }\n\n setLoginState((current) => ({\n ...current,\n isSubmittingMfaCode: true,\n loginError: null,\n }))\n\n try {\n const mfaResponse = await mfaCodeCallback(code)\n if (isMounted.current) {\n setLoginState((currentState) => ({\n ...currentState,\n isSubmittingMfaCode: false,\n loginAttemptResponse: mfaResponse,\n }))\n }\n } catch (error) {\n Sentry.captureException(error)\n if (isMounted.current) {\n setLoginState((current) => ({\n ...current,\n isSubmittingMfaCode: false,\n loginError: error as Error,\n }))\n }\n }\n }, [code, isMounted, loginAttemptResponse?.mfaCodeCallback])\n\n // Forgot Password\n const [isShowingForgotPassword, showForgotPassword, hideForgotPassword] =\n useBooleanState(false)\n const [\n {\n resetForgottenPasswordCallback,\n isSendingForgotPasswordCode,\n isResettingForgottenPassword,\n forgotPasswordError,\n },\n setForgotPasswordState,\n ] = React.useState<{\n isSendingForgotPasswordCode: boolean\n forgotPasswordError: null | Error\n resetForgottenPasswordCallback:\n | null\n | ((code: string, newPassword: string) => void)\n isResettingForgottenPassword: boolean\n }>({\n isSendingForgotPasswordCode: false,\n forgotPasswordError: null,\n resetForgottenPasswordCallback: null,\n isResettingForgottenPassword: false,\n })\n const clearForgotPasswordError = React.useCallback(\n () =>\n setForgotPasswordState((current) => ({\n ...current,\n forgotPasswordError: null,\n })),\n [],\n )\n const sendForgotPasswordCode = React.useCallback(async () => {\n if (usernameValidation.isInvalid) {\n setForgotPasswordState((current) => ({\n ...current,\n forgotPasswordError: new Error('Please enter a valid email address'),\n }))\n return\n }\n\n setForgotPasswordState({\n isSendingForgotPasswordCode: true,\n resetForgottenPasswordCallback: null,\n forgotPasswordError: null,\n isResettingForgottenPassword: false,\n })\n\n try {\n const newResetForgottenPasswordCallback =\n await authService.forgotPassword(username)\n if (isMounted.current) {\n setForgotPasswordState({\n isSendingForgotPasswordCode: false,\n resetForgottenPasswordCallback: newResetForgottenPasswordCallback,\n forgotPasswordError: null,\n isResettingForgottenPassword: false,\n })\n }\n } catch (error) {\n Sentry.captureException(error)\n if (isMounted.current) {\n setForgotPasswordState({\n isSendingForgotPasswordCode: false,\n resetForgottenPasswordCallback: null,\n forgotPasswordError: error as Error,\n isResettingForgottenPassword: false,\n })\n }\n }\n }, [isMounted, username, usernameValidation.isInvalid])\n\n const resetForgottenPassword = React.useCallback(async () => {\n if (!resetForgottenPasswordCallback) {\n return\n }\n\n if (codeValidation.isInvalid) {\n setForgotPasswordState((current) => ({\n ...current,\n forgotPasswordError: new Error(\n 'Please enter the code that was sent to your email address',\n ),\n }))\n }\n if (newPasswordValidation.isInvalid) {\n setForgotPasswordState((current) => ({\n ...current,\n forgotPasswordError: new Error('Please enter a valid password'),\n }))\n return\n }\n if (newPasswordConfirmedValidation.isInvalid) {\n setForgotPasswordState((current) => ({\n ...current,\n forgotPasswordError: new Error('Please confirm your new password'),\n }))\n return\n }\n\n setForgotPasswordState((current) => ({\n ...current,\n isChangingPassword: true,\n forgotPasswordError: null,\n }))\n\n try {\n await resetForgottenPasswordCallback(code, newPassword)\n if (isMounted.current) {\n setForgotPasswordState({\n isSendingForgotPasswordCode: false,\n resetForgottenPasswordCallback: null,\n forgotPasswordError: null,\n isResettingForgottenPassword: false,\n })\n hideForgotPassword()\n }\n } catch (error) {\n Sentry.captureException(error)\n if (isMounted.current) {\n setForgotPasswordState((current) => ({\n ...current,\n isChangingPassword: false,\n forgotPasswordError: error as Error,\n }))\n }\n }\n }, [\n resetForgottenPasswordCallback,\n codeValidation.isInvalid,\n newPasswordValidation.isInvalid,\n newPasswordConfirmedValidation.isInvalid,\n code,\n newPassword,\n isMounted,\n hideForgotPassword,\n ])\n\n const loginWithGoogle = React.useCallback(() => {\n authService.loginHostedUI('Google')\n }, [])\n\n return {\n // Login\n /** Open redirect user to the Google sign in */\n loginWithGoogle,\n loginWithUsernamePassword,\n isLoggingIn,\n loginError,\n clearLoginError,\n // Reset Temp Password\n isPasswordTemporary: !!loginAttemptResponse?.resetPasswordCallback,\n isResettingTemporaryPassword,\n resetTemporaryPassword,\n // MFA Code\n isMfaCodeRequired: !!loginAttemptResponse?.mfaCodeCallback,\n isSubmittingMfaCode,\n submitMfaCode,\n // Showing Forgot Password\n isShowingForgotPassword,\n showForgotPassword,\n hideForgotPassword,\n forgotPasswordError,\n clearForgotPasswordError,\n // Sending Forgot Password Code\n isSendingForgotPasswordCode,\n sendForgotPasswordCode,\n // Resetting Forgotten Password\n hasSentForgotPasswordCode: !!resetForgottenPasswordCallback,\n isResettingForgottenPassword,\n resetForgottenPassword,\n // Validation\n usernameValidation,\n passwordValidation,\n codeValidation,\n newPasswordValidation,\n newPasswordConfirmedValidation,\n }\n}\n\nexport interface UseLoginValue {\n /** Open redirect user to the Google sign-in page. */\n loginWithGoogle: () => void\n /**\n * Attempt to use the `username` and `password` arguments to create a session.\n * Will call `onLogin()` if successful, otherwise will set `loginError`.\n */\n loginWithUsernamePassword: () => void\n /** `true` while processing `loginWithUsernamePassword()`. */\n isLoggingIn: boolean\n /**\n * `true` if the user logged in using a temporary password. Prompt the user\n * for a new password and call `resetTemporaryPassword()`.\n */\n isPasswordTemporary: boolean\n /**\n * Attempt to use `newPassword` and `newPasswordConfirmed` arguments to reset\n * the user's password and create a session. Will call `onLogin()` if\n * successful, otherwise will set `loginError`.\n */\n resetTemporaryPassword: () => void\n /**\n * Set if an error occurs while processing `loginWithUsernamePassword()` or\n * `resetTemporaryPassword()`.\n */\n loginError: Error | null\n /** Set `loginError` back to `null`. */\n clearLoginError: () => void\n /** `true` while processing `resetTemporaryPassword()`. */\n isResettingTemporaryPassword: boolean\n /** `true` when showing the forgot password flow. */\n isShowingForgotPassword: boolean\n /** Set `isShowingForgotPassword` to `true`. */\n showForgotPassword: () => void\n /** Set `isShowingForgotPassword` to `false`. */\n hideForgotPassword: () => void\n /**\n * Attempt to use the `username` argument to start the forgot password\n * process. This will send the user an email with a code to enter. A failed\n * request will set `forgotPasswordError`.\n */\n sendForgotPasswordCode: () => void\n /** `true` while processing `sendForgotPasswordCode()`. */\n isSendingForgotPasswordCode: boolean\n /** `true` if the forgot password code has been successfully sent to the user. */\n hasSentForgotPasswordCode: boolean\n /**\n * Attempt to use the `code`, `newPassword`, and `newPasswordConfirmed`\n * arguments to reset the user's password. A failed request will set\n * `forgotPasswordError`.\n */\n resetForgottenPassword: () => void\n /** `true` while processing `resetForgottenPassword()`. */\n isResettingForgottenPassword: boolean\n /**\n * Set if an error occurs while processing `sendForgotPasswordCode()` or\n * `resetForgottenPassword()`.\n */\n forgotPasswordError: Error | null\n /** Set `forgotPasswordError` back to `null`. */\n clearForgotPasswordError: () => void\n usernameValidation: {\n /** `true` if the `username` argument is invalid. */\n isInvalid: boolean\n }\n passwordValidation: {\n /** `true` if the `password` argument is invalid. */\n isInvalid: boolean\n }\n codeValidation: {\n /** `true` if the `code` argument is invalid. */\n isInvalid: boolean\n }\n newPasswordValidation: {\n /** `true` if the `newPassword` argument is invalid. */\n isInvalid: boolean\n /**\n * `true` if the `newPassword` argument has a lowercase letter (required to\n * be valid).\n */\n hasLowercaseLetter: boolean\n /**\n * `true` if the `newPassword` argument has an uppercase letter (required to\n * be valid).\n */\n hasUpperCaseLetter: boolean\n /** `true` if the `newPassword` argument has a number (required to be valid). */\n hasNumber: boolean\n /**\n * `true` if the `newPassword` argument has a special character (required to\n * be valid).\n */\n hasSpecialCharacter: boolean\n /**\n * `true` if the `newPassword` argument has at least the minimum number of\n * characters (required to be valid).\n */\n hasMinLength: boolean\n }\n newPasswordConfirmedValidation: {\n /**\n * `true` if the `newPasswordConfirmed` argument is invalid (must match the\n * `newPassword` argument).\n */\n isInvalid: boolean\n }\n /**\n * `true` if the user logged in using MFA and a code is required to finish the\n * login attempt. Prompt the user for a code and call `submitMfaCode()`.\n */\n isMfaCodeRequired: boolean\n /** `true` while processing `submitMfaCode()`. */\n isSubmittingMfaCode: boolean\n /**\n * Attempt to use `code` argument to submit the MFA code and create a session.\n * Will call `onLogin()` if successful, otherwise will set `loginError`.\n */\n submitMfaCode: () => void\n}\n"]}
@@ -91,7 +91,7 @@ export declare function PendingSubmissionsContextProvider({ isPendingQueueEnable
91
91
  successNotificationTimeoutMs?: number;
92
92
  /** Your application components */
93
93
  children: React.ReactNode;
94
- }): JSX.Element;
94
+ }): React.JSX.Element;
95
95
  /**
96
96
  * React hook to get the context value for Pending Submissions. Will throw an
97
97
  * Error if used outside of the `<PendingSubmissionsContextProvider />`
@@ -9,7 +9,9 @@
9
9
  overflow-y: auto;
10
10
 
11
11
  a.dropdown-item {
12
- transition: background-color 0.25s, color 0.25s;
12
+ transition:
13
+ background-color 0.25s,
14
+ color 0.25s;
13
15
  }
14
16
  }
15
17
  }
@@ -56,10 +56,18 @@
56
56
  }
57
57
 
58
58
  .ob-annotation__button-colour {
59
- -webkit-transition: min-width 0.2s, height 0.2s;
60
- -moz-transition: min-width 0.2s, height 0.2s;
61
- -o-transition: min-width 0.2s, height 0.2s;
62
- transition: min-width 0.2s, height 0.2s;
59
+ -webkit-transition:
60
+ min-width 0.2s,
61
+ height 0.2s;
62
+ -moz-transition:
63
+ min-width 0.2s,
64
+ height 0.2s;
65
+ -o-transition:
66
+ min-width 0.2s,
67
+ height 0.2s;
68
+ transition:
69
+ min-width 0.2s,
70
+ height 0.2s;
63
71
  outline: none;
64
72
  min-width: 50px;
65
73
  height: 50px;
@@ -1,9 +1,9 @@
1
1
  .ob-compliance {
2
- &.odd>.ob-compliance__container {
2
+ &.odd > .ob-compliance__container {
3
3
  background-color: $white;
4
4
  }
5
5
 
6
- &.even>.ob-compliance__container {
6
+ &.even > .ob-compliance__container {
7
7
  background-color: $white-bis;
8
8
  }
9
9
  }
@@ -22,7 +22,7 @@
22
22
 
23
23
  .modal-card {
24
24
  box-shadow: $elevation-3;
25
- border-radius: $radius-small;
25
+ border-radius: $radius-small;
26
26
  outline: none;
27
27
  }
28
28