@oneblink/apps-react 2.8.0-beta.3 → 2.8.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 (88) hide show
  1. package/dist/OneBlinkAutoSaveForm.d.ts +1 -1
  2. package/dist/OneBlinkForm.d.ts +1 -1
  3. package/dist/OneBlinkFormBase.d.ts +3 -3
  4. package/dist/OneBlinkReadOnlyForm.d.ts +1 -1
  5. package/dist/components/CopyToClipboardIconButton.d.ts +1 -1
  6. package/dist/components/Lists.d.ts +2 -2
  7. package/dist/components/LoadingWithMessage.d.ts +1 -1
  8. package/dist/components/formStore/OneBlinkFormStoreProvider.d.ts +1 -1
  9. package/dist/components/formStore/table/ColumnFilters.d.ts +1 -1
  10. package/dist/components/formStore/table/FormElementTableCell.d.ts +1 -1
  11. package/dist/components/formStore/table/RepeatableSetCell.d.ts +1 -1
  12. package/dist/components/formStore/table/RepeatableSetCellAccordion.d.ts +1 -1
  13. package/dist/components/formStore/useFormStoreTableContext.d.ts +1 -1
  14. package/dist/components/messages/ErrorMessage.d.ts +1 -1
  15. package/dist/components/messages/LargeIconMessage.d.ts +2 -2
  16. package/dist/components/messages/NoResourcesYet.d.ts +1 -1
  17. package/dist/components/pickers/V4CompatibleDatePicker.d.ts +4 -4
  18. package/dist/components/pickers/V4CompatibleDateTimePicker.d.ts +4 -4
  19. package/dist/components/pickers/V4CompatibleTimePicker.d.ts +4 -4
  20. package/dist/components/receipts/Receipt.d.ts +1 -1
  21. package/dist/components/receipts/ReceiptButton.d.ts +1 -1
  22. package/dist/components/receipts/ReceiptList.d.ts +1 -1
  23. package/dist/components/receipts/ReceiptListItem.d.ts +1 -1
  24. package/dist/components/renderer/AutocompleteDropdown.d.ts +2 -2
  25. package/dist/components/renderer/CopyToClipboardButton.d.ts +1 -1
  26. package/dist/components/renderer/CustomisableButtonInner.d.ts +1 -1
  27. package/dist/components/renderer/FormElementOptions.d.ts +1 -1
  28. package/dist/components/renderer/LookupButton.d.ts +1 -1
  29. package/dist/components/renderer/LookupNotification.d.ts +1 -1
  30. package/dist/components/renderer/Modal.d.ts +1 -1
  31. package/dist/components/renderer/OnLoading.d.ts +1 -1
  32. package/dist/components/renderer/OneBlinkAppsErrorOriginalMessage.d.ts +1 -1
  33. package/dist/components/renderer/OneBlinkFormElements.d.ts +1 -1
  34. package/dist/components/renderer/PageFormElements.d.ts +1 -1
  35. package/dist/components/renderer/attachments/FileCard.d.ts +1 -1
  36. package/dist/form-elements/FormElementABN.d.ts +1 -1
  37. package/dist/form-elements/FormElementABN.js +3 -1
  38. package/dist/form-elements/FormElementABN.js.map +1 -1
  39. package/dist/form-elements/FormElementAutocomplete.d.ts +3 -3
  40. package/dist/form-elements/FormElementBSB.d.ts +1 -1
  41. package/dist/form-elements/FormElementBSB.js +3 -1
  42. package/dist/form-elements/FormElementBSB.js.map +1 -1
  43. package/dist/form-elements/FormElementBarcodeScanner.d.ts +1 -1
  44. package/dist/form-elements/FormElementBoolean.d.ts +1 -1
  45. package/dist/form-elements/FormElementCalculation.d.ts +1 -1
  46. package/dist/form-elements/FormElementCamera.d.ts +1 -1
  47. package/dist/form-elements/FormElementCaptcha.d.ts +1 -1
  48. package/dist/form-elements/FormElementCheckBoxes.d.ts +1 -1
  49. package/dist/form-elements/FormElementCivicaStreetName.d.ts +1 -1
  50. package/dist/form-elements/FormElementDate.d.ts +1 -1
  51. package/dist/form-elements/FormElementDateTime.d.ts +1 -1
  52. package/dist/form-elements/FormElementEmail.d.ts +1 -1
  53. package/dist/form-elements/FormElementFile.d.ts +1 -1
  54. package/dist/form-elements/FormElementForm.d.ts +1 -1
  55. package/dist/form-elements/FormElementGeoscapeAddress.d.ts +1 -1
  56. package/dist/form-elements/FormElementHTML.d.ts +1 -1
  57. package/dist/form-elements/FormElementHeading.d.ts +1 -1
  58. package/dist/form-elements/FormElementImage.d.ts +1 -1
  59. package/dist/form-elements/FormElementLocation.d.ts +2 -2
  60. package/dist/form-elements/FormElementNumber.d.ts +1 -1
  61. package/dist/form-elements/FormElementPointAddress.d.ts +1 -1
  62. package/dist/form-elements/FormElementRadio.d.ts +1 -1
  63. package/dist/form-elements/FormElementRepeatableSet.d.ts +1 -1
  64. package/dist/form-elements/FormElementSelect.d.ts +1 -1
  65. package/dist/form-elements/FormElementSignature.d.ts +1 -1
  66. package/dist/form-elements/FormElementSummary.d.ts +1 -1
  67. package/dist/form-elements/FormElementTelephone.d.ts +1 -1
  68. package/dist/form-elements/FormElementText.d.ts +1 -1
  69. package/dist/form-elements/FormElementTextarea.d.ts +1 -1
  70. package/dist/form-elements/FormElementTime.d.ts +1 -1
  71. package/dist/form-elements/OptionButton.d.ts +1 -1
  72. package/dist/hooks/attachments/useAttachment.d.ts +1 -1
  73. package/dist/hooks/attachments/useAttachmentBlobs.d.ts +4 -4
  74. package/dist/hooks/useAuth.d.ts +1 -1
  75. package/dist/hooks/useBooleanState.d.ts +3 -3
  76. package/dist/hooks/useExecutedLookupCallback.d.ts +2 -2
  77. package/dist/hooks/useFlatpickrGuid.d.ts +1 -1
  78. package/dist/hooks/useFormSubmissionModelContext.d.ts +1 -1
  79. package/dist/hooks/useInfiniteScrollDataLoad.d.ts +3 -3
  80. package/dist/hooks/useInjectPages.d.ts +1 -1
  81. package/dist/hooks/useIsPageVisible.d.ts +2 -2
  82. package/dist/hooks/useLoadDataState.d.ts +1 -1
  83. package/dist/hooks/useLookupNotification.d.ts +1 -1
  84. package/dist/services/form-validation.d.ts +1 -1
  85. package/dist/styles.css +437 -437
  86. package/dist/types/attachments.d.ts +1 -1
  87. package/dist/types/form.d.ts +11 -11
  88. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { OneBlinkFormUncontrolled } from './OneBlinkForm';
3
- type Props = React.ComponentProps<typeof OneBlinkFormUncontrolled> & {
3
+ declare type Props = React.ComponentProps<typeof OneBlinkFormUncontrolled> & {
4
4
  autoSaveKey: string;
5
5
  removeAutoSaveDataBeforeSubmit?: boolean;
6
6
  removeAutoSaveDataBeforeSaveDraft?: boolean;
@@ -3,7 +3,7 @@ import { FormTypes } from '@oneblink/types';
3
3
  import { BaseProps, ControlledProps } from './OneBlinkFormBase';
4
4
  import { FormSubmissionModel } from './types/form';
5
5
  declare const OneBlinkFormControlled: React.NamedExoticComponent<BaseProps & ControlledProps>;
6
- type UncontrolledProps = {
6
+ declare type UncontrolledProps = {
7
7
  form: FormTypes.Form;
8
8
  initialSubmission?: FormSubmissionModel;
9
9
  };
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { submissionService } from '@oneblink/apps';
3
3
  import { FormTypes, FormsAppsTypes } from '@oneblink/types';
4
4
  import { FormSubmissionModel, SetFormSubmission } from './types/form';
5
- export type BaseProps = {
5
+ export declare type BaseProps = {
6
6
  onCancel: () => unknown;
7
7
  onSubmit: (newFormSubmission: submissionService.NewFormSubmission) => unknown;
8
8
  disabled?: boolean;
@@ -18,12 +18,12 @@ export type BaseProps = {
18
18
  handleNavigateAway?: () => unknown;
19
19
  isInfoPage?: 'YES' | 'NO' | 'CALCULATED';
20
20
  };
21
- export type ControlledProps = {
21
+ export declare type ControlledProps = {
22
22
  definition: FormTypes.Form;
23
23
  submission: FormSubmissionModel;
24
24
  setFormSubmission: SetFormSubmission;
25
25
  };
26
- type Props = BaseProps & ControlledProps & {
26
+ declare type Props = BaseProps & ControlledProps & {
27
27
  isReadOnly: boolean;
28
28
  };
29
29
  declare function OneBlinkFormBase({ googleMapsApiKey, abnLookupAuthenticationGuid, captchaSiteKey, definition, disabled, isPreview, submission, isReadOnly, onCancel, onSubmit, onSaveDraft, setFormSubmission, buttons, primaryColour, attachmentRetentionInDays, allowSubmitWithPendingAttachments, handleNavigateAway, isInfoPage: isInfoPageProp, }: Props): JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { FormTypes } from '@oneblink/types';
3
3
  import { FormSubmissionModel } from './types/form';
4
- type Props = {
4
+ declare type Props = {
5
5
  form: FormTypes.Form;
6
6
  initialSubmission?: FormSubmissionModel;
7
7
  googleMapsApiKey?: string;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { IconButton } from '@mui/material';
3
- type Props = {
3
+ declare type Props = {
4
4
  text: string;
5
5
  large?: boolean;
6
6
  noMarginY?: boolean;
@@ -1,12 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import { Theme } from '@mui/material';
3
- type ListItemsProps = {
3
+ declare type ListItemsProps = {
4
4
  children: React.ReactNode;
5
5
  disablePadding?: boolean;
6
6
  };
7
7
  export declare const OrderedList: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<Theme> & ListItemsProps, React.DetailedHTMLProps<React.OlHTMLAttributes<HTMLOListElement>, HTMLOListElement>, {}>;
8
8
  export declare const UnorderedList: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<Theme> & ListItemsProps, React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>, {}>;
9
- type ListProps = {
9
+ declare type ListProps = {
10
10
  spaced?: boolean;
11
11
  };
12
12
  export declare const ListItem: import("@emotion/styled").StyledComponent<Omit<import("@mui/system").SystemProps<Theme> & {
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- type Props = {
2
+ declare type Props = {
3
3
  message?: string;
4
4
  };
5
5
  declare const _default: React.NamedExoticComponent<Props>;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { FormTypes } from '@oneblink/types';
3
- export type FormStoreElementsContextValue = FormTypes.FormElementWithName[];
3
+ export declare type FormStoreElementsContextValue = FormTypes.FormElementWithName[];
4
4
  export declare const FormStoreElementsContext: React.Context<FormStoreElementsContextValue>;
5
5
  export declare function OneBlinkFormStoreProvider({ form, children, }: {
6
6
  form: FormTypes.Form;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { FormStoreRecord } from '@oneblink/types/typescript/submissions';
3
3
  import { HeaderGroup } from 'react-table';
4
- type Props = {
4
+ declare type Props = {
5
5
  filter: NonNullable<HeaderGroup<FormStoreRecord>['filter']>;
6
6
  };
7
7
  declare function ColumnFilters({ filter }: Props): JSX.Element | null;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { FormTypes, SubmissionTypes } from '@oneblink/types';
3
- type Props = {
3
+ declare type Props = {
4
4
  formElement: FormTypes.FormElement;
5
5
  submission: SubmissionTypes.S3SubmissionData['submission'] | undefined;
6
6
  allowCopy: boolean;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { FormTypes } from '@oneblink/types';
3
- type Props = {
3
+ declare type Props = {
4
4
  value: Array<Record<string, unknown>>;
5
5
  formElement: FormTypes.RepeatableSetElement;
6
6
  };
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- type Props = {
2
+ declare type Props = {
3
3
  isOpen: boolean;
4
4
  onChange: () => void;
5
5
  title: string;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import useFormStoreTable from './table/useFormStoreTable';
3
- export type FormStoreTableContextValue = ReturnType<typeof useFormStoreTable> | undefined;
3
+ export declare type FormStoreTableContextValue = ReturnType<typeof useFormStoreTable> | undefined;
4
4
  export declare const FormStoreTableContext: React.Context<FormStoreTableContextValue>;
5
5
  export default function useFormStoreTableContext(): {
6
6
  readonly form: import("@oneblink/types/typescript/forms").Form;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { Props as LargeIconMessageProps } from './LargeIconMessage';
3
- type Props = {
3
+ declare type Props = {
4
4
  IconComponent?: LargeIconMessageProps['IconComponent'];
5
5
  title: string;
6
6
  gutterTop?: boolean;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { CommonProps } from '@mui/material/OverridableComponent';
3
- type Variant = 'primary' | 'success' | 'error' | 'warning';
4
- export type Props = {
3
+ declare type Variant = 'primary' | 'success' | 'error' | 'warning';
4
+ export declare type Props = {
5
5
  IconComponent: React.ComponentType<{
6
6
  color: Variant;
7
7
  style: React.CSSProperties;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { Props as LargeIconMessageProps } from './LargeIconMessage';
3
- type Props = {
3
+ declare type Props = {
4
4
  IconComponent: LargeIconMessageProps['IconComponent'];
5
5
  title: string;
6
6
  gutterBottom?: boolean;
@@ -1,10 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import { MobileDatePickerProps } from '@mui/x-date-pickers';
3
3
  import { TextField, IconButton } from '@mui/material';
4
- type RemainingPickerProps = Omit<MobileDatePickerProps<string | Date, Date>, 'onError' | 'renderInput' | 'toolbarFormat' | 'rightArrowIcon' | 'leftArrowIcon' | 'maxDate' | 'minDate' | 'inputFormat'>;
5
- type TextFieldProps = React.ComponentProps<typeof TextField>;
6
- type IconButtonProps = React.ComponentProps<typeof IconButton>;
7
- type Props = RemainingPickerProps & {
4
+ declare type RemainingPickerProps = Omit<MobileDatePickerProps<string | Date, Date>, 'onError' | 'renderInput' | 'toolbarFormat' | 'rightArrowIcon' | 'leftArrowIcon' | 'maxDate' | 'minDate' | 'inputFormat'>;
5
+ declare type TextFieldProps = React.ComponentProps<typeof TextField>;
6
+ declare type IconButtonProps = React.ComponentProps<typeof IconButton>;
7
+ declare type Props = RemainingPickerProps & {
8
8
  name?: TextFieldProps['name'];
9
9
  label?: TextFieldProps['label'];
10
10
  maxDate?: string | Date;
@@ -1,10 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import { MobileDateTimePickerProps } from '@mui/x-date-pickers';
3
3
  import { TextField, IconButton } from '@mui/material';
4
- type RemainingPickerProps = Omit<MobileDateTimePickerProps<string | Date, Date>, 'onError' | 'renderInput' | 'toolbarFormat' | 'timeIcon' | 'dateRangeIcon' | 'rightArrowIcon' | 'leftArrowIcon' | 'maxDate' | 'minDate' | 'inputFormat'>;
5
- type TextFieldProps = React.ComponentProps<typeof TextField>;
6
- type IconButtonProps = React.ComponentProps<typeof IconButton>;
7
- type Props = RemainingPickerProps & {
4
+ declare type RemainingPickerProps = Omit<MobileDateTimePickerProps<string | Date, Date>, 'onError' | 'renderInput' | 'toolbarFormat' | 'timeIcon' | 'dateRangeIcon' | 'rightArrowIcon' | 'leftArrowIcon' | 'maxDate' | 'minDate' | 'inputFormat'>;
5
+ declare type TextFieldProps = React.ComponentProps<typeof TextField>;
6
+ declare type IconButtonProps = React.ComponentProps<typeof IconButton>;
7
+ declare type Props = RemainingPickerProps & {
8
8
  name?: TextFieldProps['name'];
9
9
  label?: TextFieldProps['label'];
10
10
  maxDate?: string | Date;
@@ -1,10 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import { MobileTimePickerProps } from '@mui/x-date-pickers';
3
3
  import { TextField, IconButton } from '@mui/material';
4
- type RemainingPickerProps = Omit<MobileTimePickerProps<string | Date, Date>, 'onError' | 'renderInput' | 'toolbarFormat' | 'rightArrowIcon' | 'leftArrowIcon' | 'maxDate' | 'minDate' | 'inputFormat'>;
5
- type TextFieldProps = React.ComponentProps<typeof TextField>;
6
- type IconButtonProps = React.ComponentProps<typeof IconButton>;
7
- type Props = RemainingPickerProps & {
4
+ declare type RemainingPickerProps = Omit<MobileTimePickerProps<string | Date, Date>, 'onError' | 'renderInput' | 'toolbarFormat' | 'rightArrowIcon' | 'leftArrowIcon' | 'maxDate' | 'minDate' | 'inputFormat'>;
5
+ declare type TextFieldProps = React.ComponentProps<typeof TextField>;
6
+ declare type IconButtonProps = React.ComponentProps<typeof IconButton>;
7
+ declare type Props = RemainingPickerProps & {
8
8
  name?: TextFieldProps['name'];
9
9
  label?: TextFieldProps['label'];
10
10
  margin?: TextFieldProps['margin'];
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- type Props = {
2
+ declare type Props = {
3
3
  className: string;
4
4
  containerClassName: string;
5
5
  children: React.ReactNode;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- type Props = {
2
+ declare type Props = {
3
3
  className: string;
4
4
  label: string;
5
5
  isDisabled?: boolean;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- type Props = {
2
+ declare type Props = {
3
3
  successIconClassName: string;
4
4
  warningIconClassName?: string;
5
5
  warningMessageClassName?: string;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- type Props = {
2
+ declare type Props = {
3
3
  className: string;
4
4
  valueClassName: string;
5
5
  icon?: string;
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
- type AutocompleteOption<T> = {
2
+ declare type AutocompleteOption<T> = {
3
3
  label: string;
4
4
  value: string;
5
5
  data?: T;
6
6
  };
7
- type Props<T> = {
7
+ declare type Props<T> = {
8
8
  id: string;
9
9
  label: string;
10
10
  value: unknown | undefined;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- type Props = {
2
+ declare type Props = {
3
3
  text: string;
4
4
  className?: string;
5
5
  };
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- type Props = {
2
+ declare type Props = {
3
3
  label: string;
4
4
  icon?: string;
5
5
  };
@@ -1,7 +1,7 @@
1
1
  import { FormTypes } from '@oneblink/types';
2
2
  import * as React from 'react';
3
3
  import { FormElementConditionallyShownElement } from '../../types/form';
4
- type Props = {
4
+ declare type Props = {
5
5
  options: FormTypes.ChoiceElementOption[] | undefined;
6
6
  conditionallyShownOptionsElement: FormElementConditionallyShownElement | undefined;
7
7
  children: React.ReactNode;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- type Props = {
2
+ declare type Props = {
3
3
  value: unknown | undefined;
4
4
  validationMessage: string | undefined;
5
5
  hasMarginTop?: boolean;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { FormTypes } from '@oneblink/types';
3
3
  import { FormElementLookupHandler } from '../../types/form';
4
- type Props = {
4
+ declare type Props = {
5
5
  autoLookupValue?: unknown;
6
6
  stringifyAutoLookupValue?: (autoLookupValue: unknown) => string;
7
7
  element: FormTypes.LookupFormElement;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- type Props = {
2
+ declare type Props = {
3
3
  isOpen: boolean;
4
4
  title: string;
5
5
  children: React.ReactNode;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- type Props = {
2
+ declare type Props = {
3
3
  className?: string;
4
4
  small?: boolean;
5
5
  large?: boolean;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- type Props = {
2
+ declare type Props = {
3
3
  error?: Error;
4
4
  };
5
5
  declare function OneBlinkAppsErrorOriginalMessage({ error }: Props): JSX.Element | null;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { FormTypes } from '@oneblink/types';
3
3
  import { FormElementLookupHandler, FormElementsConditionallyShown, FormElementsValidation, FormElementValueChangeHandler, FormSubmissionModel } from '../../types/form';
4
- export type Props<T extends FormTypes._NestedElementsElement> = {
4
+ export declare type Props<T extends FormTypes._NestedElementsElement> = {
5
5
  formId: number;
6
6
  elements: FormTypes.FormElement[];
7
7
  formElementsConditionallyShown: FormElementsConditionallyShown | undefined;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { FormTypes } from '@oneblink/types';
3
3
  import { FormElementsConditionallyShown, FormElementsValidation, FormElementValueChangeHandler, FormSubmissionModel, SetFormSubmission } from '../../types/form';
4
- export type Props = {
4
+ export declare type Props = {
5
5
  formId: number;
6
6
  isActive: boolean;
7
7
  pageElement: FormTypes.PageElement;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { FormTypes } from '@oneblink/types';
3
- type Props = {
3
+ declare type Props = {
4
4
  element: FormTypes.FilesElement;
5
5
  isUploading?: boolean;
6
6
  isUploadPaused?: boolean;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { FormTypes, MiscTypes } from '@oneblink/types';
3
3
  import { FormElementValueChangeHandler } from '../types/form';
4
- type Props = {
4
+ declare type Props = {
5
5
  id: string;
6
6
  element: FormTypes.ABNElement;
7
7
  value: MiscTypes.ABNRecord | undefined;
@@ -130,7 +130,9 @@ function FormElementABN({ id, element, value, onChange, validationMessage, displ
130
130
  React.createElement("div", { className: clsx('control is-expanded', {
131
131
  'is-loading': isLoading,
132
132
  }) },
133
- React.createElement(InputMask, { mask: isFocused || value ? '99 999 999 999' : '999 999 999', maskChar: " ", type: "text", id: id, name: element.name, className: "input ob-input cypress-abn-control", placeholder: element.placeholderValue, value: label, onChange: (e) => {
133
+ React.createElement(InputMask, { mask: isFocused || value ? '99 999 999 999' : '999 999 999',
134
+ // @ts-expect-error "react-input-mask" types do not match code
135
+ maskChar: " ", type: "text", id: id, name: element.name, className: "input ob-input cypress-abn-control", placeholder: element.placeholderValue, value: label, onChange: (e) => {
134
136
  setLabel(e.target.value);
135
137
  if (value) {
136
138
  onChange(element, undefined);
@@ -1 +1 @@
1
- {"version":3,"file":"FormElementABN.js","sourceRoot":"","sources":["../../src/form-elements/FormElementABN.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,SAAS,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,qBAAqB,MAAM,8CAA8C,CAAA;AAChF,OAAO,eAAe,MAAM,0BAA0B,CAAA;AACtD,OAAO,YAAY,MAAM,qCAAqC,CAAA;AAE9D,OAAO,yBAAyB,MAAM,kDAAkD,CAAA;AAExF,OAAO,8BAA8B,MAAM,yCAAyC,CAAA;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAU/C,SAAS,cAAc,CAAC,EACtB,EAAE,EACF,OAAO,EACP,KAAK,EACL,QAAQ,EACR,iBAAiB,EACjB,wBAAwB,GAClB;IACN,MAAM,2BAA2B,GAAG,8BAA8B,EAAE,CAAA;IACpE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CACtC,KAAK,CAAC,CAAC,CAAC,U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O,EAAE,SAAS,CAAC,CAAA;6BAC7B;wBACH,CAAC,EACD,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAC1B,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAC1B,MAAM,EAAE,GAAG,EAAE;4BACX,UAAU,EAAE,CAAA;4BACZ,WAAW,EAAE,CAAA;wBACf,CAAC,EACD,OAAO,EAAE,YAAY,GACrB,CACE;gBACL,KAAK,IAAI,CACR,6BAAK,SAAS,EAAC,gCAAgC;oBAC7C,2BAAG,SAAS,EAAC,wCAAwC,IAClD,UAAU,CAAC,gCAAgC,CAAC,KAAK,CAAC,CACjD,CACA,CACP;gBACA,CAAC,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC,KAAK,IAAI,CAChC,6BAAK,SAAS,EAAC,SAAS;oBACtB,oBAAC,qBAAqB,IACpB,SAAS,EAAC,oEAAoE,EAC9E,IAAI,EAAE,KAAK,GACX,CACE,CACP;gBACD,oBAAC,YAAY,IACX,aAAa,QACb,KAAK,EAAE,KAAK,EACZ,iBAAiB,EAAE,iBAAiB,GACpC,CACE;YACL,CAAC,CAAC,CAAC,OAAO,IAAI,wBAAwB,CAAC;gBACtC,CAAC,CAAC,iBAAiB;gBACnB,CAAC,SAAS,CAAC;gBACX,KAAK,CAAC,IAAI,CACV,6BAAK,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,kBAAkB;gBAC5C,6BAAK,SAAS,EAAC,2DAA2D,IACvE,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,KAAI,iBAAiB,CAChC,CACF,CACP,CACyB,CACxB,CACP,CAAA;AACH,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport clsx from 'clsx'\nimport InputMask from 'react-input-mask'\nimport { parseString } from 'xml2js'\nimport CopyToClipboardButton from '../components/renderer/CopyToClipboardButton'\nimport useBooleanState from '../hooks/useBooleanState'\nimport LookupButton from '../components/renderer/LookupButton'\nimport { FormTypes, MiscTypes } from '@oneblink/types'\nimport FormElementLabelContainer from '../components/renderer/FormElementLabelContainer'\nimport { FormElementValueChangeHandler } from '../types/form'\nimport useAbnLookupAuthenticationGuid from '../hooks/useAbnLookupAuthenticationGuid'\nimport { abnService } from '@oneblink/sdk-core'\ntype Props = {\n id: string\n element: FormTypes.ABNElement\n value: MiscTypes.ABNRecord | undefined\n onChange: FormElementValueChangeHandler<MiscTypes.ABNRecord>\n displayValidationMessage: boolean\n validationMessage: string | undefined\n}\n\nfunction FormElementABN({\n id,\n element,\n value,\n onChange,\n validationMessage,\n displayValidationMessage,\n}: Props) {\n const abnLookupAuthenticationGuid = useAbnLookupAuthenticationGuid()\n const [label, setLabel] = React.useState(\n value ? abnService.getABNNumberFromABNRecord(value) || '' : '',\n )\n const [isFocused, setIsFocused, removeFocus] = useBooleanState(false)\n const [isDirty, setIsDirty] = useBooleanState(false)\n const [{ isLoading, error }, setState] = React.useState<{\n isLoading: boolean\n error: Error | null\n }>({\n isLoading: false,\n error: null,\n })\n\n React.useEffect(() => {\n const searchString = label.replace(/[^\\d]/g, '')\n const isSearchStringValid =\n searchString.length === 11 || (searchString.length === 9 && !isFocused)\n\n const currentABNNumber = value\n ? abnService.getABNNumberFromABNRecord(value)\n : ''\n if (!isSearchStringValid || currentABNNumber === searchString) {\n return\n }\n\n setState({\n isLoading: true,\n error: null,\n })\n\n const abortController = new AbortController()\n const fetchRecord = async () => {\n try {\n const urlSearchParams = new URLSearchParams()\n urlSearchParams.append('searchString', searchString)\n urlSearchParams.append('includeHistoricalDetails', 'N')\n if (abnLookupAuthenticationGuid) {\n urlSearchParams.append(\n 'authenticationGuid',\n abnLookupAuthenticationGuid,\n )\n }\n\n const url =\n searchString.length === 11\n ? 'https://abr.business.gov.au/abrxmlsearch/AbrXmlSearch.asmx/SearchByABNv202001'\n : 'https://abr.business.gov.au/abrxmlsearch/AbrXmlSearch.asmx/SearchByASICv201408'\n const response = await fetch(`${url}?${urlSearchParams.toString()}`, {\n mode: 'cors',\n signal: abortController.signal,\n })\n const text = await response.text()\n if (!response.ok) {\n throw new Error(text)\n }\n\n const result = await new Promise<{\n ABRPayloadSearchResults: {\n response: {\n businessEntity201408?: MiscTypes.ABNRecord\n businessEntity202001: MiscTypes.ABNRecord\n exception?: {\n exceptionDescription: string\n exceptionCode: string\n }\n }\n }\n }>((resolve, reject) => {\n parseString(\n text,\n {\n explicitArray: false,\n },\n (err, result) => {\n if (err) {\n reject(err)\n } else {\n resolve(result)\n }\n },\n )\n })\n if (result.ABRPayloadSearchResults.response.exception) {\n throw new Error(\n result.ABRPayloadSearchResults.response.exception.exceptionDescription,\n )\n }\n\n if (result.ABRPayloadSearchResults.response.businessEntity201408) {\n result.ABRPayloadSearchResults.response.businessEntity202001 =\n result.ABRPayloadSearchResults.response.businessEntity201408\n }\n\n if (\n !Array.isArray(\n result.ABRPayloadSearchResults.response.businessEntity202001\n .businessName,\n )\n ) {\n result.ABRPayloadSearchResults.response.businessEntity202001.businessName =\n [\n result.ABRPayloadSearchResults.response.businessEntity202001\n .businessName,\n ]\n }\n\n if (!abortController.signal.aborted) {\n onChange(\n element,\n result.ABRPayloadSearchResults.response.businessEntity202001,\n )\n setState({\n isLoading: false,\n error: null,\n })\n }\n } catch (err) {\n if (!abortController.signal.aborted) {\n setState({\n isLoading: false,\n error: err as Error,\n })\n }\n }\n }\n\n fetchRecord()\n\n return () => {\n abortController.abort()\n }\n }, [abnLookupAuthenticationGuid, element, isFocused, label, onChange, value])\n\n // Ensure the label is set if the value is set outside of this component\n React.useEffect(() => {\n if (value) {\n const newLabel = abnService.getABNNumberFromABNRecord(value)\n if (!newLabel) {\n // Record in value had no ABN Number. This should never happen\n return\n }\n if (label !== newLabel) {\n setLabel(\n newLabel.split('').reduce((memo, character, index) => {\n switch (index) {\n case 2:\n case 5:\n case 8: {\n return `${memo} ${character}`\n }\n default: {\n return `${memo}${character}`\n }\n }\n }, ''),\n )\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [value])\n\n return (\n <div className=\"cypress-abn-element\">\n <FormElementLabelContainer\n className=\"ob-abn\"\n id={id}\n element={element}\n required={element.required}\n >\n <div className=\"field has-addons\">\n <div\n className={clsx('control is-expanded', {\n 'is-loading': isLoading,\n })}\n >\n <InputMask\n mask={isFocused || value ? '99 999 999 999' : '999 999 999'}\n maskChar=\" \"\n type=\"text\"\n id={id}\n name={element.name}\n className=\"input ob-input cypress-abn-control\"\n placeholder={element.placeholderValue}\n value={label}\n onChange={(e) => {\n setLabel(e.target.value)\n if (value) {\n onChange(element, undefined)\n }\n }}\n required={element.required}\n disabled={element.readOnly}\n onBlur={() => {\n setIsDirty()\n removeFocus()\n }}\n onFocus={setIsFocused}\n />\n </div>\n {value && (\n <div className=\"control ob-abn__record-control\">\n <a className=\"button is-static ob-abn__record-button\">\n {abnService.displayBusinessNameFromABNRecord(value)}\n </a>\n </div>\n )}\n {!!element.readOnly && !!value && (\n <div className=\"control\">\n <CopyToClipboardButton\n className=\"button is-input-addon copy-button cypress-copy-to-clipboard-button\"\n text={label}\n />\n </div>\n )}\n <LookupButton\n isInputButton\n value={value}\n validationMessage={validationMessage}\n />\n </div>\n {(((isDirty || displayValidationMessage) &&\n !!validationMessage &&\n !isLoading) ||\n error) && (\n <div role=\"alert\" className=\"has-margin-top-8\">\n <div className=\"has-text-danger ob-error__text cypress-validation-message\">\n {error?.message || validationMessage}\n </div>\n </div>\n )}\n </FormElementLabelContainer>\n </div>\n )\n}\n\nexport default React.memo(FormElementABN)\n"]}
1
+ {"version":3,"file":"FormElementABN.js","sourceRoot":"","sources":["../../src/form-elements/FormElementABN.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,SAAS,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,qBAAq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tC,CAAC,CAAC,iBAAiB;gBACnB,CAAC,SAAS,CAAC;gBACX,KAAK,CAAC,IAAI,CACV,6BAAK,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,kBAAkB;gBAC5C,6BAAK,SAAS,EAAC,2DAA2D,IACvE,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,KAAI,iBAAiB,CAChC,CACF,CACP,CACyB,CACxB,CACP,CAAA;AACH,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport clsx from 'clsx'\nimport InputMask from 'react-input-mask'\nimport { parseString } from 'xml2js'\nimport CopyToClipboardButton from '../components/renderer/CopyToClipboardButton'\nimport useBooleanState from '../hooks/useBooleanState'\nimport LookupButton from '../components/renderer/LookupButton'\nimport { FormTypes, MiscTypes } from '@oneblink/types'\nimport FormElementLabelContainer from '../components/renderer/FormElementLabelContainer'\nimport { FormElementValueChangeHandler } from '../types/form'\nimport useAbnLookupAuthenticationGuid from '../hooks/useAbnLookupAuthenticationGuid'\nimport { abnService } from '@oneblink/sdk-core'\ntype Props = {\n id: string\n element: FormTypes.ABNElement\n value: MiscTypes.ABNRecord | undefined\n onChange: FormElementValueChangeHandler<MiscTypes.ABNRecord>\n displayValidationMessage: boolean\n validationMessage: string | undefined\n}\n\nfunction FormElementABN({\n id,\n element,\n value,\n onChange,\n validationMessage,\n displayValidationMessage,\n}: Props) {\n const abnLookupAuthenticationGuid = useAbnLookupAuthenticationGuid()\n const [label, setLabel] = React.useState(\n value ? abnService.getABNNumberFromABNRecord(value) || '' : '',\n )\n const [isFocused, setIsFocused, removeFocus] = useBooleanState(false)\n const [isDirty, setIsDirty] = useBooleanState(false)\n const [{ isLoading, error }, setState] = React.useState<{\n isLoading: boolean\n error: Error | null\n }>({\n isLoading: false,\n error: null,\n })\n\n React.useEffect(() => {\n const searchString = label.replace(/[^\\d]/g, '')\n const isSearchStringValid =\n searchString.length === 11 || (searchString.length === 9 && !isFocused)\n\n const currentABNNumber = value\n ? abnService.getABNNumberFromABNRecord(value)\n : ''\n if (!isSearchStringValid || currentABNNumber === searchString) {\n return\n }\n\n setState({\n isLoading: true,\n error: null,\n })\n\n const abortController = new AbortController()\n const fetchRecord = async () => {\n try {\n const urlSearchParams = new URLSearchParams()\n urlSearchParams.append('searchString', searchString)\n urlSearchParams.append('includeHistoricalDetails', 'N')\n if (abnLookupAuthenticationGuid) {\n urlSearchParams.append(\n 'authenticationGuid',\n abnLookupAuthenticationGuid,\n )\n }\n\n const url =\n searchString.length === 11\n ? 'https://abr.business.gov.au/abrxmlsearch/AbrXmlSearch.asmx/SearchByABNv202001'\n : 'https://abr.business.gov.au/abrxmlsearch/AbrXmlSearch.asmx/SearchByASICv201408'\n const response = await fetch(`${url}?${urlSearchParams.toString()}`, {\n mode: 'cors',\n signal: abortController.signal,\n })\n const text = await response.text()\n if (!response.ok) {\n throw new Error(text)\n }\n\n const result = await new Promise<{\n ABRPayloadSearchResults: {\n response: {\n businessEntity201408?: MiscTypes.ABNRecord\n businessEntity202001: MiscTypes.ABNRecord\n exception?: {\n exceptionDescription: string\n exceptionCode: string\n }\n }\n }\n }>((resolve, reject) => {\n parseString(\n text,\n {\n explicitArray: false,\n },\n (err, result) => {\n if (err) {\n reject(err)\n } else {\n resolve(result)\n }\n },\n )\n })\n if (result.ABRPayloadSearchResults.response.exception) {\n throw new Error(\n result.ABRPayloadSearchResults.response.exception.exceptionDescription,\n )\n }\n\n if (result.ABRPayloadSearchResults.response.businessEntity201408) {\n result.ABRPayloadSearchResults.response.businessEntity202001 =\n result.ABRPayloadSearchResults.response.businessEntity201408\n }\n\n if (\n !Array.isArray(\n result.ABRPayloadSearchResults.response.businessEntity202001\n .businessName,\n )\n ) {\n result.ABRPayloadSearchResults.response.businessEntity202001.businessName =\n [\n result.ABRPayloadSearchResults.response.businessEntity202001\n .businessName,\n ]\n }\n\n if (!abortController.signal.aborted) {\n onChange(\n element,\n result.ABRPayloadSearchResults.response.businessEntity202001,\n )\n setState({\n isLoading: false,\n error: null,\n })\n }\n } catch (err) {\n if (!abortController.signal.aborted) {\n setState({\n isLoading: false,\n error: err as Error,\n })\n }\n }\n }\n\n fetchRecord()\n\n return () => {\n abortController.abort()\n }\n }, [abnLookupAuthenticationGuid, element, isFocused, label, onChange, value])\n\n // Ensure the label is set if the value is set outside of this component\n React.useEffect(() => {\n if (value) {\n const newLabel = abnService.getABNNumberFromABNRecord(value)\n if (!newLabel) {\n // Record in value had no ABN Number. This should never happen\n return\n }\n if (label !== newLabel) {\n setLabel(\n newLabel.split('').reduce((memo, character, index) => {\n switch (index) {\n case 2:\n case 5:\n case 8: {\n return `${memo} ${character}`\n }\n default: {\n return `${memo}${character}`\n }\n }\n }, ''),\n )\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [value])\n\n return (\n <div className=\"cypress-abn-element\">\n <FormElementLabelContainer\n className=\"ob-abn\"\n id={id}\n element={element}\n required={element.required}\n >\n <div className=\"field has-addons\">\n <div\n className={clsx('control is-expanded', {\n 'is-loading': isLoading,\n })}\n >\n <InputMask\n mask={isFocused || value ? '99 999 999 999' : '999 999 999'}\n // @ts-expect-error \"react-input-mask\" types do not match code\n maskChar=\" \"\n type=\"text\"\n id={id}\n name={element.name}\n className=\"input ob-input cypress-abn-control\"\n placeholder={element.placeholderValue}\n value={label}\n onChange={(e) => {\n setLabel(e.target.value)\n if (value) {\n onChange(element, undefined)\n }\n }}\n required={element.required}\n disabled={element.readOnly}\n onBlur={() => {\n setIsDirty()\n removeFocus()\n }}\n onFocus={setIsFocused}\n />\n </div>\n {value && (\n <div className=\"control ob-abn__record-control\">\n <a className=\"button is-static ob-abn__record-button\">\n {abnService.displayBusinessNameFromABNRecord(value)}\n </a>\n </div>\n )}\n {!!element.readOnly && !!value && (\n <div className=\"control\">\n <CopyToClipboardButton\n className=\"button is-input-addon copy-button cypress-copy-to-clipboard-button\"\n text={label}\n />\n </div>\n )}\n <LookupButton\n isInputButton\n value={value}\n validationMessage={validationMessage}\n />\n </div>\n {(((isDirty || displayValidationMessage) &&\n !!validationMessage &&\n !isLoading) ||\n error) && (\n <div role=\"alert\" className=\"has-margin-top-8\">\n <div className=\"has-text-danger ob-error__text cypress-validation-message\">\n {error?.message || validationMessage}\n </div>\n </div>\n )}\n </FormElementLabelContainer>\n </div>\n )\n}\n\nexport default React.memo(FormElementABN)\n"]}
@@ -1,17 +1,17 @@
1
1
  import * as React from 'react';
2
2
  import { FormTypes } from '@oneblink/types';
3
3
  import { FormElementValueChangeHandler, FormElementConditionallyShownElement } from '../types/form';
4
- type _BaseProps = {
4
+ declare type _BaseProps = {
5
5
  id: string;
6
6
  element: FormTypes.AutoCompleteElement;
7
7
  value: unknown | undefined;
8
8
  displayValidationMessage: boolean;
9
9
  validationMessage: string | undefined;
10
10
  };
11
- type _AutocompleteConditionallyShowOptionProps = {
11
+ declare type _AutocompleteConditionallyShowOptionProps = {
12
12
  conditionallyShownOptionsElement: FormElementConditionallyShownElement | undefined;
13
13
  };
14
- type Props = _BaseProps & _AutocompleteConditionallyShowOptionProps & {
14
+ declare type Props = _BaseProps & _AutocompleteConditionallyShowOptionProps & {
15
15
  onChange: FormElementValueChangeHandler<string>;
16
16
  };
17
17
  declare function FormElementAutocomplete({ conditionallyShownOptionsElement, onChange, ...props }: Props): JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { FormTypes } from '@oneblink/types';
3
3
  import { FormElementValueChangeHandler } from '../types/form';
4
- type Props = {
4
+ declare type Props = {
5
5
  id: string;
6
6
  formId: number;
7
7
  element: FormTypes.BSBElement;
@@ -73,7 +73,9 @@ function FormElementBSB({ id, formId, element, value, onChange, validationMessag
73
73
  React.createElement("div", { className: clsx('control is-expanded', {
74
74
  'is-loading': isLoading,
75
75
  }) },
76
- React.createElement(InputMask, { mask: "999-999", maskChar: "x", type: "text", placeholder: element.placeholderValue, id: id, name: element.name, className: "input ob-input cypress-bsb-control", value: text, onChange: (e) => {
76
+ React.createElement(InputMask, { mask: "999-999",
77
+ // @ts-expect-error "react-input-mask" types do not match code
78
+ maskChar: "x", type: "text", placeholder: element.placeholderValue, id: id, name: element.name, className: "input ob-input cypress-bsb-control", value: text, onChange: (e) => {
77
79
  setText(e.target.value);
78
80
  }, required: element.required, disabled: element.readOnly, onBlur: () => {
79
81
  if (text === 'xxx-xxx') {
@@ -1 +1 @@
1
- {"version":3,"file":"FormElementBSB.js","sourceRoot":"","sources":["../../src/form-elements/FormElementBSB.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,SAAS,MAAM,kBAAkB,CAAA;AACxC,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,qBAAqB,MAAM,8CAA8C,CAAA;AAChF,OAAO,eAAe,MAAM,0BAA0B,CAAA;AACtD,OAAO,YAAY,MAAM,qCAAqC,CAAA;AAE9D,OAAO,yBAAyB,MAAM,kDAAkD,CAAA;AAExF,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAc5C,SAAS,cAAc,CAAC,EACtB,EAAE,EACF,MAAM,EACN,OAAO,EACP,KAAK,EACL,QAAQ,EACR,iBAAiB,EACjB,wBAAwB,GAClB;IACN,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;IAC9E,MAAM,aAAa,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAE9C,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,CAAA;IACpD,MAAM,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAItE;QACD,SAAS,EAAE,KAAK;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EAAE,GAAG,EAAE;4BACX,IAAI,IAAI,KAAK,SAAS,EAAE;gCACtB,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;6BAC7B;4BACD,UAAU,EAAE,CAAA;wBACd,CAAC,GACD,CACE;gBACL,SAAS,IAAI,CACZ,6BAAK,SAAS,EAAC,gCAAgC;oBAC7C,2BAAG,SAAS,EAAC,wCAAwC;wBAClD,SAAS,CAAC,4BAA4B;;wBAAK,SAAS,CAAC,IAAI,CACxD,CACA,CACP;gBACA,CAAC,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC,KAAK,IAAI,CAChC,6BAAK,SAAS,EAAC,SAAS;oBACtB,oBAAC,qBAAqB,IACpB,SAAS,EAAC,oEAAoE,EAC9E,IAAI,EAAE,IAAI,GACV,CACE,CACP;gBACD,oBAAC,YAAY,IACX,aAAa,QACb,KAAK,EAAE,KAAK,EACZ,iBAAiB,EAAE,iBAAiB,GACpC,CACE;YACL,CAAC,CAAC,CAAC,OAAO,IAAI,wBAAwB,CAAC;gBACtC,CAAC,CAAC,iBAAiB;gBACnB,CAAC,SAAS,CAAC;gBACX,YAAY,CAAC,IAAI,CACjB,6BAAK,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,kBAAkB;gBAC5C,6BAAK,SAAS,EAAC,2DAA2D,IACvE,YAAY,IAAI,iBAAiB,CAC9B,CACF,CACP,CACyB,CACxB,CACP,CAAA;AACH,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport InputMask from 'react-input-mask'\nimport clsx from 'clsx'\nimport CopyToClipboardButton from '../components/renderer/CopyToClipboardButton'\nimport useBooleanState from '../hooks/useBooleanState'\nimport LookupButton from '../components/renderer/LookupButton'\nimport { FormTypes, MiscTypes } from '@oneblink/types'\nimport FormElementLabelContainer from '../components/renderer/FormElementLabelContainer'\nimport { FormElementValueChangeHandler } from '../types/form'\nimport { formService } from '@oneblink/apps'\n\ntype Props = {\n id: string\n formId: number\n element: FormTypes.BSBElement\n value: unknown\n onChange: FormElementValueChangeHandler<\n string | { isInvalid: boolean; isValidating: boolean }\n >\n displayValidationMessage: boolean\n validationMessage: string | undefined\n}\n\nfunction FormElementBSB({\n id,\n formId,\n element,\n value,\n onChange,\n validationMessage,\n displayValidationMessage,\n}: Props) {\n const [text, setText] = React.useState(typeof value === 'string' ? value : '')\n const isValidFormat = /\\d{3}-\\d{3}/.test(text)\n\n const [isDirty, setIsDirty] = useBooleanState(false)\n const [{ isLoading, errorMessage, bsbRecord }, setState] = React.useState<{\n isLoading: boolean\n errorMessage: string | null\n bsbRecord: MiscTypes.BSBRecord | null\n }>({\n isLoading: false,\n errorMessage: null,\n bsbRecord: null,\n })\n\n React.useEffect(() => {\n if (bsbRecord) {\n onChange(element, bsbRecord.bsb)\n }\n }, [bsbRecord, element, onChange, value])\n\n React.useEffect(() => {\n if (text === '') {\n return\n }\n\n if (!isValidFormat) {\n setState({\n isLoading: false,\n errorMessage: null,\n bsbRecord: null,\n })\n return\n }\n\n setState({\n isLoading: true,\n errorMessage: null,\n bsbRecord: null,\n })\n\n const abortController = new AbortController()\n const getBSBRecord = async () => {\n onChange(element, { isValidating: true, isInvalid: false })\n try {\n const bsbRecord = await formService.getBSBRecord(\n formId,\n text,\n abortController.signal,\n )\n if (!abortController.signal.aborted) {\n setState({\n isLoading: false,\n errorMessage: null,\n bsbRecord,\n })\n }\n } catch (error) {\n console.warn('Error validating BSB number', error)\n if (!abortController.signal.aborted) {\n onChange(element, { isInvalid: true, isValidating: false })\n setState({\n isLoading: false,\n errorMessage: `The BSB number \"${text}\" does not exist`,\n bsbRecord: null,\n })\n }\n }\n }\n\n getBSBRecord()\n\n return () => {\n abortController.abort()\n }\n }, [formId, isValidFormat, text, onChange, element])\n\n return (\n <div className=\"cypress-bsb-element\">\n <FormElementLabelContainer\n className=\"ob-bsb\"\n id={id}\n element={element}\n required={element.required}\n >\n <div className=\"field has-addons\">\n <div\n className={clsx('control is-expanded', {\n 'is-loading': isLoading,\n })}\n >\n <InputMask\n mask=\"999-999\"\n maskChar=\"x\"\n type=\"text\"\n placeholder={element.placeholderValue}\n id={id}\n name={element.name}\n className=\"input ob-input cypress-bsb-control\"\n value={text}\n onChange={(e) => {\n setText(e.target.value)\n }}\n required={element.required}\n disabled={element.readOnly}\n onBlur={() => {\n if (text === 'xxx-xxx') {\n onChange(element, undefined)\n }\n setIsDirty()\n }}\n />\n </div>\n {bsbRecord && (\n <div className=\"control ob-bsb__record-control\">\n <a className=\"button is-static ob-bsb__record-button\">\n {bsbRecord.financialInstitutionMnemonic} - {bsbRecord.name}\n </a>\n </div>\n )}\n {!!element.readOnly && !!value && (\n <div className=\"control\">\n <CopyToClipboardButton\n className=\"button is-input-addon copy-button cypress-copy-to-clipboard-button\"\n text={text}\n />\n </div>\n )}\n <LookupButton\n isInputButton\n value={value}\n validationMessage={validationMessage}\n />\n </div>\n {(((isDirty || displayValidationMessage) &&\n !!validationMessage &&\n !isLoading) ||\n errorMessage) && (\n <div role=\"alert\" className=\"has-margin-top-8\">\n <div className=\"has-text-danger ob-error__text cypress-validation-message\">\n {errorMessage || validationMessage}\n </div>\n </div>\n )}\n </FormElementLabelContainer>\n </div>\n )\n}\n\nexport default React.memo(FormElementBSB)\n"]}
1
+ {"version":3,"file":"FormElementBSB.js","sourceRoot":"","sources":["../../src/form-elements/FormElementBSB.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,SAAS,MAAM,kBAAkB,CAAA;AACxC,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,qBAAqB,MAAM,8CAA8C,CAAA;AAChF,OAAO,eAAe,MAAM,0BAA0B,CAAA;AACtD,OAAO,YAAY,MAAM,qCAAqC,CAAA;AAE9D,OAAO,yBAAyB,MAAM,kDAAkD,CAAA;AAExF,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAc5C,SA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iB;gBACnB,CAAC,SAAS,CAAC;gBACX,YAAY,CAAC,IAAI,CACjB,6BAAK,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,kBAAkB;gBAC5C,6BAAK,SAAS,EAAC,2DAA2D,IACvE,YAAY,IAAI,iBAAiB,CAC9B,CACF,CACP,CACyB,CACxB,CACP,CAAA;AACH,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport InputMask from 'react-input-mask'\nimport clsx from 'clsx'\nimport CopyToClipboardButton from '../components/renderer/CopyToClipboardButton'\nimport useBooleanState from '../hooks/useBooleanState'\nimport LookupButton from '../components/renderer/LookupButton'\nimport { FormTypes, MiscTypes } from '@oneblink/types'\nimport FormElementLabelContainer from '../components/renderer/FormElementLabelContainer'\nimport { FormElementValueChangeHandler } from '../types/form'\nimport { formService } from '@oneblink/apps'\n\ntype Props = {\n id: string\n formId: number\n element: FormTypes.BSBElement\n value: unknown\n onChange: FormElementValueChangeHandler<\n string | { isInvalid: boolean; isValidating: boolean }\n >\n displayValidationMessage: boolean\n validationMessage: string | undefined\n}\n\nfunction FormElementBSB({\n id,\n formId,\n element,\n value,\n onChange,\n validationMessage,\n displayValidationMessage,\n}: Props) {\n const [text, setText] = React.useState(typeof value === 'string' ? value : '')\n const isValidFormat = /\\d{3}-\\d{3}/.test(text)\n\n const [isDirty, setIsDirty] = useBooleanState(false)\n const [{ isLoading, errorMessage, bsbRecord }, setState] = React.useState<{\n isLoading: boolean\n errorMessage: string | null\n bsbRecord: MiscTypes.BSBRecord | null\n }>({\n isLoading: false,\n errorMessage: null,\n bsbRecord: null,\n })\n\n React.useEffect(() => {\n if (bsbRecord) {\n onChange(element, bsbRecord.bsb)\n }\n }, [bsbRecord, element, onChange, value])\n\n React.useEffect(() => {\n if (text === '') {\n return\n }\n\n if (!isValidFormat) {\n setState({\n isLoading: false,\n errorMessage: null,\n bsbRecord: null,\n })\n return\n }\n\n setState({\n isLoading: true,\n errorMessage: null,\n bsbRecord: null,\n })\n\n const abortController = new AbortController()\n const getBSBRecord = async () => {\n onChange(element, { isValidating: true, isInvalid: false })\n try {\n const bsbRecord = await formService.getBSBRecord(\n formId,\n text,\n abortController.signal,\n )\n if (!abortController.signal.aborted) {\n setState({\n isLoading: false,\n errorMessage: null,\n bsbRecord,\n })\n }\n } catch (error) {\n console.warn('Error validating BSB number', error)\n if (!abortController.signal.aborted) {\n onChange(element, { isInvalid: true, isValidating: false })\n setState({\n isLoading: false,\n errorMessage: `The BSB number \"${text}\" does not exist`,\n bsbRecord: null,\n })\n }\n }\n }\n\n getBSBRecord()\n\n return () => {\n abortController.abort()\n }\n }, [formId, isValidFormat, text, onChange, element])\n\n return (\n <div className=\"cypress-bsb-element\">\n <FormElementLabelContainer\n className=\"ob-bsb\"\n id={id}\n element={element}\n required={element.required}\n >\n <div className=\"field has-addons\">\n <div\n className={clsx('control is-expanded', {\n 'is-loading': isLoading,\n })}\n >\n <InputMask\n mask=\"999-999\"\n // @ts-expect-error \"react-input-mask\" types do not match code\n maskChar=\"x\"\n type=\"text\"\n placeholder={element.placeholderValue}\n id={id}\n name={element.name}\n className=\"input ob-input cypress-bsb-control\"\n value={text}\n onChange={(e) => {\n setText(e.target.value)\n }}\n required={element.required}\n disabled={element.readOnly}\n onBlur={() => {\n if (text === 'xxx-xxx') {\n onChange(element, undefined)\n }\n setIsDirty()\n }}\n />\n </div>\n {bsbRecord && (\n <div className=\"control ob-bsb__record-control\">\n <a className=\"button is-static ob-bsb__record-button\">\n {bsbRecord.financialInstitutionMnemonic} - {bsbRecord.name}\n </a>\n </div>\n )}\n {!!element.readOnly && !!value && (\n <div className=\"control\">\n <CopyToClipboardButton\n className=\"button is-input-addon copy-button cypress-copy-to-clipboard-button\"\n text={text}\n />\n </div>\n )}\n <LookupButton\n isInputButton\n value={value}\n validationMessage={validationMessage}\n />\n </div>\n {(((isDirty || displayValidationMessage) &&\n !!validationMessage &&\n !isLoading) ||\n errorMessage) && (\n <div role=\"alert\" className=\"has-margin-top-8\">\n <div className=\"has-text-danger ob-error__text cypress-validation-message\">\n {errorMessage || validationMessage}\n </div>\n </div>\n )}\n </FormElementLabelContainer>\n </div>\n )\n}\n\nexport default React.memo(FormElementBSB)\n"]}
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { FormTypes } from '@oneblink/types';
3
3
  import { FormElementValueChangeHandler } from '../types/form';
4
- type Props = {
4
+ declare type Props = {
5
5
  id: string;
6
6
  element: FormTypes.BarcodeScannerElement;
7
7
  value: unknown | undefined;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { FormTypes } from '@oneblink/types';
3
3
  import { FormElementValueChangeHandler } from '../types/form';
4
- type Props = {
4
+ declare type Props = {
5
5
  id: string;
6
6
  element: FormTypes.BooleanElement;
7
7
  value: unknown;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { FormTypes } from '@oneblink/types';
3
3
  import { FormElementValueChangeHandler } from '../types/form';
4
- type Props = {
4
+ declare type Props = {
5
5
  element: FormTypes.CalculationElement;
6
6
  onChange: FormElementValueChangeHandler<number>;
7
7
  value: unknown | undefined;
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { FormTypes } from '@oneblink/types';
3
3
  import { FormElementBinaryStorageValue } from '../types/attachments';
4
4
  import { FormElementValueChangeHandler } from '../types/form';
5
- type Props = {
5
+ declare type Props = {
6
6
  id: string;
7
7
  element: FormTypes.CameraElement;
8
8
  value: FormElementBinaryStorageValue;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { FormTypes } from '@oneblink/types';
3
3
  import { FormElementValueChangeHandler } from '../types/form';
4
- type Props = {
4
+ declare type Props = {
5
5
  element: FormTypes.CaptchaElement;
6
6
  onChange: FormElementValueChangeHandler<string>;
7
7
  displayValidationMessage: boolean;