@oneblink/apps-react 6.2.0-beta.4 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/payments/PaymentForm.js +3 -6
- package/dist/components/payments/PaymentForm.js.map +1 -1
- package/dist/form-elements/FormElementABN.js +12 -4
- package/dist/form-elements/FormElementABN.js.map +1 -1
- package/dist/form-elements/FormElementBSB.js +15 -7
- package/dist/form-elements/FormElementBSB.js.map +1 -1
- package/dist/styles/abn.scss +48 -0
- package/dist/styles/bsb.scss +49 -0
- package/dist/styles.css +94 -0
- package/dist/styles.scss +1 -0
- package/package.json +2 -2
@@ -14,12 +14,6 @@ function PaymentForm({ captchaSiteKey, onCompleted, onCancelled, appImageUrl, ti
|
|
14
14
|
}
|
15
15
|
const { formSubmissionResult, paymentSubmissionEvent } = await paymentService.getFormSubmissionResultPayment();
|
16
16
|
switch (paymentSubmissionEvent.type) {
|
17
|
-
case 'BPOINT':
|
18
|
-
case 'CP_PAY':
|
19
|
-
case 'NSW_GOV_PAY':
|
20
|
-
case 'WESTPAC_QUICK_WEB': {
|
21
|
-
throw new Error(`"${paymentSubmissionEvent.type}" payment events do not support a custom payment form.`);
|
22
|
-
}
|
23
17
|
case 'WESTPAC_QUICK_STREAM': {
|
24
18
|
const { supplierBusinessCode, publishableApiKey, isTestMode } = await paymentService.westpacQuickStream.getPaymentFormConfiguration({
|
25
19
|
formSubmissionPaymentId,
|
@@ -31,6 +25,9 @@ function PaymentForm({ captchaSiteKey, onCompleted, onCancelled, appImageUrl, ti
|
|
31
25
|
renderPaymentForm: () => (React.createElement(WestpacQuickStreamPaymentForm, { formSubmissionResult: formSubmissionResult, paymentSubmissionEvent: paymentSubmissionEvent, formSubmissionPaymentId: formSubmissionPaymentId, supplierBusinessCode: supplierBusinessCode, publishableApiKey: publishableApiKey, isTestMode: isTestMode, captchaSiteKey: captchaSiteKey, onCompleted: onCompleted, onCancelled: onCancelled, appImageUrl: appImageUrl, title: title })),
|
32
26
|
};
|
33
27
|
}
|
28
|
+
default: {
|
29
|
+
throw new Error(`"${paymentSubmissionEvent.type}" payment events do not support a custom payment form.`);
|
30
|
+
}
|
34
31
|
}
|
35
32
|
}, [
|
36
33
|
appImageUrl,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PaymentForm.js","sourceRoot":"","sources":["../../../src/components/payments/PaymentForm.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,6BAA6B,MAAM,iCAAiC,CAAA;AAC3E,OAAO,QAAQ,MAAM,sBAAsB,CAAA;AAC3C,OAAO,gBAAgB,MAAM,8BAA8B,CAAA;AAC3D,OAAO,SAAS,MAAM,uBAAuB,CAAA;AAC7C,OAAO,YAAY,MAAM,iBAAiB,CAAA;AAE1C,SAAS,WAAW,CAAC,EACnB,cAAc,EACd,WAAW,EACX,WAAW,EACX,WAAW,EACX,KAAK,GAUN;IACC,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAA;IAExB,MAAM,4BAA4B,GAAG,KAAK,CAAC,WAAW,CACpD,KAAK,EAAE,WAAwB,EAAE,EAAE;QACjC,MAAM,uBAAuB,GAAG,KAAK,CAAC,uBAAuB,CAAA;QAC7D,IAAI,OAAO,uBAAuB,KAAK,QAAQ,EAAE;YAC/C,MAAM,IAAI,KAAK,CACb,8DAA8D,CAC/D,CAAA;SACF;QAED,MAAM,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,GACpD,MAAM,cAAc,CAAC,8BAA8B,EAAE,CAAA;QACvD,QAAQ,sBAAsB,CAAC,IAAI,EAAE;YACnC,KAAK,
|
1
|
+
{"version":3,"file":"PaymentForm.js","sourceRoot":"","sources":["../../../src/components/payments/PaymentForm.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,KAAK,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WAAW,EACxB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,GACZ,CACH;iBACF,CAAA;aACF;YACD,OAAO,CAAC,CAAC;gBACP,MAAM,IAAI,KAAK,CACb,IAAI,sBAAsB,CAAC,IAAI,wDAAwD,CACxF,CAAA;aACF;SACF;IACH,CAAC,EACD;QACE,WAAW;QACX,cAAc;QACd,WAAW;QACX,WAAW;QACX,KAAK,CAAC,uBAAuB;QAC7B,KAAK;KACN,CACF,CAAA;IAED,MAAM,CAAC,KAAK,CAAC,GAAG,gBAAgB,CAAC,4BAA4B,CAAC,CAAA;IAE9D,QAAQ,KAAK,CAAC,MAAM,EAAE;QACpB,KAAK,SAAS,CAAC,CAAC;YACd,OAAO,CACL;gBACE,6BAAK,SAAS,EAAC,mCAAmC;oBAChD,oBAAC,SAAS,IAAC,SAAS,EAAC,mBAAmB,GAAa;oBACrD,qEAA6C,CACzC,CACE,CACX,CAAA;SACF;QACD,KAAK,OAAO,CAAC,CAAC;YACZ,OAAO,CACL,iCAAS,SAAS,EAAC,4CAA4C;gBAC7D,6BAAK,SAAS,EAAC,6EAA6E;oBAC1F,oBAAC,YAAY,IAAC,SAAS,EAAC,0DAA0D,YAEnE,CACX;gBACN,2BAAG,SAAS,EAAC,sEAAsE,IAChF,KAAK,CAAC,KAAK,CAAC,OAAO,CAClB,CACI,CACX,CAAA;SACF;QACD,KAAK,SAAS,CAAC,CAAC;YACd,OAAO,KAAK,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAA;SACxC;KACF;AACH,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA","sourcesContent":["import { paymentService } from '@oneblink/apps'\nimport { SubmissionTypes } from '@oneblink/types'\nimport React from 'react'\nimport WestpacQuickStreamPaymentForm from './WestpacQuickStreamPaymentForm'\nimport useQuery from '../../hooks/useQuery'\nimport useLoadDataState from '../../hooks/useLoadDataState'\nimport OnLoading from '../renderer/OnLoading'\nimport MaterialIcon from '../MaterialIcon'\n\nfunction PaymentForm({\n captchaSiteKey,\n onCompleted,\n onCancelled,\n appImageUrl,\n title,\n}: {\n captchaSiteKey: string\n onCompleted: (result: {\n formSubmissionPayment: SubmissionTypes.FormSubmissionPayment\n paymentReceiptUrl: string\n }) => void\n onCancelled: (result: { paymentReceiptUrl: string }) => void\n appImageUrl?: string\n title?: string\n}) {\n const query = useQuery()\n\n const loadPaymentFormConfiguration = React.useCallback(\n async (abortSignal: AbortSignal) => {\n const formSubmissionPaymentId = query.formSubmissionPaymentId\n if (typeof formSubmissionPaymentId !== 'string') {\n throw new Error(\n 'It looks like you are attempting to make an unknown payment.',\n )\n }\n\n const { formSubmissionResult, paymentSubmissionEvent } =\n await paymentService.getFormSubmissionResultPayment()\n switch (paymentSubmissionEvent.type) {\n case 'WESTPAC_QUICK_STREAM': {\n const { supplierBusinessCode, publishableApiKey, isTestMode } =\n await paymentService.westpacQuickStream.getPaymentFormConfiguration(\n {\n formSubmissionPaymentId,\n formSubmissionResult,\n paymentSubmissionEvent,\n abortSignal,\n },\n )\n return {\n renderPaymentForm: () => (\n <WestpacQuickStreamPaymentForm\n formSubmissionResult={formSubmissionResult}\n paymentSubmissionEvent={paymentSubmissionEvent}\n formSubmissionPaymentId={formSubmissionPaymentId}\n supplierBusinessCode={supplierBusinessCode}\n publishableApiKey={publishableApiKey}\n isTestMode={isTestMode}\n captchaSiteKey={captchaSiteKey}\n onCompleted={onCompleted}\n onCancelled={onCancelled}\n appImageUrl={appImageUrl}\n title={title}\n />\n ),\n }\n }\n default: {\n throw new Error(\n `\"${paymentSubmissionEvent.type}\" payment events do not support a custom payment form.`,\n )\n }\n }\n },\n [\n appImageUrl,\n captchaSiteKey,\n onCancelled,\n onCompleted,\n query.formSubmissionPaymentId,\n title,\n ],\n )\n\n const [state] = useLoadDataState(loadPaymentFormConfiguration)\n\n switch (state.status) {\n case 'LOADING': {\n return (\n <section>\n <div className=\"cypress-loading has-text-centered\">\n <OnLoading className=\"has-text-centered\"></OnLoading>\n <span>Loading payment configuration...</span>\n </div>\n </section>\n )\n }\n case 'ERROR': {\n return (\n <section className=\"cypress-payment-form-loading-error-message\">\n <div className=\"ob-payment-form__error-icon-container has-text-centered has-margin-bottom-8\">\n <MaterialIcon className=\"ob-payment-form__error-icon has-text-danger icon-x-large\">\n error\n </MaterialIcon>\n </div>\n <p className=\"ob-payment-form__error-message has-text-centered has-margin-bottom-4\">\n {state.error.message}\n </p>\n </section>\n )\n }\n case 'SUCCESS': {\n return state.result.renderPaymentForm()\n }\n }\n}\n\nexport default React.memo(PaymentForm)\n"]}
|
@@ -134,9 +134,13 @@ function FormElementABN({ id, element, value, onChange, validationMessage, displ
|
|
134
134
|
!isLoading) ||
|
135
135
|
error) &&
|
136
136
|
!isLookingUp;
|
137
|
+
const hasCopyButton = !!value && !!element.readOnly;
|
138
|
+
const hasLookupButton = element.isDataLookup || element.isElementLookup;
|
137
139
|
return (React.createElement("div", { className: "cypress-abn-element" },
|
138
140
|
React.createElement(FormElementLabelContainer, { className: "ob-abn", id: id, element: element, required: element.required },
|
139
|
-
React.createElement("div", { className:
|
141
|
+
React.createElement("div", { className: clsx('field has-addons', {
|
142
|
+
'no-addons-mobile': !hasCopyButton && !hasLookupButton,
|
143
|
+
}) },
|
140
144
|
React.createElement("div", { className: clsx('control is-expanded', {
|
141
145
|
'is-loading': isLoading,
|
142
146
|
}) },
|
@@ -151,13 +155,17 @@ function FormElementABN({ id, element, value, onChange, validationMessage, displ
|
|
151
155
|
setIsDirty();
|
152
156
|
removeFocus();
|
153
157
|
}, onFocus: setIsFocused, "aria-describedby": ariaDescribedby })),
|
154
|
-
value && (React.createElement(
|
155
|
-
|
156
|
-
!!element.readOnly && !!value && (React.createElement("div", { className: "control" },
|
158
|
+
value && (React.createElement(ABNDisplay, { abnRecord: value, className: "ob-abn__display-desktop" })),
|
159
|
+
hasCopyButton && (React.createElement("div", { className: "control" },
|
157
160
|
React.createElement(CopyToClipboardButton, { className: "button is-input-addon copy-button cypress-copy-to-clipboard-button", text: label }))),
|
158
161
|
React.createElement(LookupButton, { isInputButton: true, value: value, validationMessage: validationMessage, lookupButtonConfig: element.lookupButton })),
|
162
|
+
value && (React.createElement(ABNDisplay, { abnRecord: value, className: "ob-abn__display-mobile" })),
|
159
163
|
isDisplayingValidationMessage && (React.createElement("div", { role: "alert", className: "has-margin-top-8" },
|
160
164
|
React.createElement("div", { className: "has-text-danger ob-error__text cypress-validation-message" }, (error === null || error === void 0 ? void 0 : error.message) || validationMessage))))));
|
161
165
|
}
|
162
166
|
export default React.memo(FormElementABN);
|
167
|
+
const ABNDisplay = ({ abnRecord, className, }) => {
|
168
|
+
return (React.createElement("div", { className: `control ob-abn__record-control ${className}` },
|
169
|
+
React.createElement("a", { className: "button is-static ob-abn__record-button" }, abnService.displayBusinessNameFromABNRecord(abnRecord))));
|
170
|
+
};
|
163
171
|
//# sourceMappingURL=FormElementABN.js.map
|
@@ -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;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC1E,OAAO,yBAAyB,MAAM,oCAAoC,CAAA;AAW1E,SAAS,cAAc,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EAAE,OAAO,CAAC,YAAY,GACxC,CACE;YACL,6BAA6B,IAAI,CAChC,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, IsDirtyProps } from '../types/form'\nimport useAbnLookupAuthenticationGuid from '../hooks/useAbnLookupAuthenticationGuid'\nimport { abnService } from '@oneblink/sdk-core'\nimport { LookupNotificationContext } from '../hooks/useLookupNotification'\nimport useElementAriaDescribedby from '../hooks/useElementAriaDescribedby'\n\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} & IsDirtyProps\n\nfunction FormElementABN({\n id,\n element,\n value,\n onChange,\n validationMessage,\n displayValidationMessage,\n isDirty,\n setIsDirty,\n}: Props) {\n const ariaDescribedby = useElementAriaDescribedby(id, element)\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 [{ 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(element, {\n value: 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 const { isLookingUp } = React.useContext(LookupNotificationContext)\n const isDisplayingValidationMessage =\n (((isDirty || displayValidationMessage) &&\n !!validationMessage &&\n !isLoading) ||\n error) &&\n !isLookingUp\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, {\n value: undefined,\n })\n }\n }}\n required={element.required}\n disabled={element.readOnly}\n onBlur={() => {\n setIsDirty()\n removeFocus()\n }}\n onFocus={setIsFocused}\n aria-describedby={ariaDescribedby}\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 lookupButtonConfig={element.lookupButton}\n />\n </div>\n {isDisplayingValidationMessage && (\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,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;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC1E,OAAO,yBAAyB,MAAM,oCAAoC,CAAA;AAW1E,SAAS,cAAc,CAAC,EACtB,EAAE,EACF,OAAO,EACP,KAAK,EACL,QAAQ,EACR,iBAAiB,EACjB,wBAAwB,EACxB,OAAO,EACP,UAAU,GACJ;IACN,MAAM,eAAe,GAAG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C,kBAAkB,EAAE,OAAO,CAAC,YAAY,GACxC,CACE;YACL,KAAK,IAAI,CACR,oBAAC,UAAU,IAAC,SAAS,EAAE,KAAK,EAAE,SAAS,EAAC,wBAAwB,GAAG,CACpE;YACA,6BAA6B,IAAI,CAChC,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;AAEzC,MAAM,UAAU,GAAG,CAAC,EAClB,SAAS,EACT,SAAS,GAIV,EAAE,EAAE;IACH,OAAO,CACL,6BAAK,SAAS,EAAE,kCAAkC,SAAS,EAAE;QAC3D,2BAAG,SAAS,EAAC,wCAAwC,IAClD,UAAU,CAAC,gCAAgC,CAAC,SAAS,CAAC,CACrD,CACA,CACP,CAAA;AACH,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, IsDirtyProps } from '../types/form'\nimport useAbnLookupAuthenticationGuid from '../hooks/useAbnLookupAuthenticationGuid'\nimport { abnService } from '@oneblink/sdk-core'\nimport { LookupNotificationContext } from '../hooks/useLookupNotification'\nimport useElementAriaDescribedby from '../hooks/useElementAriaDescribedby'\n\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} & IsDirtyProps\n\nfunction FormElementABN({\n id,\n element,\n value,\n onChange,\n validationMessage,\n displayValidationMessage,\n isDirty,\n setIsDirty,\n}: Props) {\n const ariaDescribedby = useElementAriaDescribedby(id, element)\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 [{ 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(element, {\n value: 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 const { isLookingUp } = React.useContext(LookupNotificationContext)\n const isDisplayingValidationMessage =\n (((isDirty || displayValidationMessage) &&\n !!validationMessage &&\n !isLoading) ||\n error) &&\n !isLookingUp\n\n const hasCopyButton = !!value && !!element.readOnly\n const hasLookupButton = element.isDataLookup || element.isElementLookup\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\n className={clsx('field has-addons', {\n 'no-addons-mobile': !hasCopyButton && !hasLookupButton,\n })}\n >\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, {\n value: undefined,\n })\n }\n }}\n required={element.required}\n disabled={element.readOnly}\n onBlur={() => {\n setIsDirty()\n removeFocus()\n }}\n onFocus={setIsFocused}\n aria-describedby={ariaDescribedby}\n />\n </div>\n {value && (\n <ABNDisplay abnRecord={value} className=\"ob-abn__display-desktop\" />\n )}\n {hasCopyButton && (\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 lookupButtonConfig={element.lookupButton}\n />\n </div>\n {value && (\n <ABNDisplay abnRecord={value} className=\"ob-abn__display-mobile\" />\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 {error?.message || validationMessage}\n </div>\n </div>\n )}\n </FormElementLabelContainer>\n </div>\n )\n}\n\nexport default React.memo(FormElementABN)\n\nconst ABNDisplay = ({\n abnRecord,\n className,\n}: {\n abnRecord: MiscTypes.ABNRecord\n className: string\n}) => {\n return (\n <div className={`control ob-abn__record-control ${className}`}>\n <a className=\"button is-static ob-abn__record-button\">\n {abnService.displayBusinessNameFromABNRecord(abnRecord)}\n </a>\n </div>\n )\n}\n"]}
|
@@ -80,9 +80,13 @@ function FormElementBSB({ id, formId, element, value, onChange, validationMessag
|
|
80
80
|
!isLoading) ||
|
81
81
|
errorMessage) &&
|
82
82
|
!isLookingUp;
|
83
|
+
const hasCopyButton = !!value && !!element.readOnly;
|
84
|
+
const hasLookupButton = element.isDataLookup || element.isElementLookup;
|
83
85
|
return (React.createElement("div", { className: "cypress-bsb-element" },
|
84
86
|
React.createElement(FormElementLabelContainer, { className: "ob-bsb", id: id, element: element, required: element.required },
|
85
|
-
React.createElement("div", { className:
|
87
|
+
React.createElement("div", { className: clsx('field has-addons', {
|
88
|
+
'no-addons-mobile': !hasCopyButton && !hasLookupButton,
|
89
|
+
}) },
|
86
90
|
React.createElement("div", { className: clsx('control is-expanded', {
|
87
91
|
'is-loading': isLoading,
|
88
92
|
}) },
|
@@ -96,16 +100,20 @@ function FormElementBSB({ id, formId, element, value, onChange, validationMessag
|
|
96
100
|
}
|
97
101
|
setIsDirty();
|
98
102
|
}, "aria-describedby": ariaDescribedby })),
|
99
|
-
bsbRecord && (React.createElement(
|
100
|
-
|
101
|
-
bsbRecord.financialInstitutionMnemonic,
|
102
|
-
" - ",
|
103
|
-
bsbRecord.name))),
|
104
|
-
!!element.readOnly && !!value && (React.createElement("div", { className: "control" },
|
103
|
+
bsbRecord && (React.createElement(BSBDisplay, { bsbRecord: bsbRecord, className: "ob-bsb__display-desktop" })),
|
104
|
+
hasCopyButton && (React.createElement("div", { className: "control" },
|
105
105
|
React.createElement(CopyToClipboardButton, { className: "button is-input-addon copy-button cypress-copy-to-clipboard-button", text: text }))),
|
106
106
|
React.createElement(LookupButton, { isInputButton: true, value: value, validationMessage: validationMessage, lookupButtonConfig: element.lookupButton })),
|
107
|
+
bsbRecord && (React.createElement(BSBDisplay, { bsbRecord: bsbRecord, className: "ob-bsb__display-mobile" })),
|
107
108
|
isDisplayingValidationMessage && (React.createElement("div", { role: "alert", className: "has-margin-top-8" },
|
108
109
|
React.createElement("div", { className: "has-text-danger ob-error__text cypress-validation-message" }, errorMessage || validationMessage))))));
|
109
110
|
}
|
111
|
+
const BSBDisplay = ({ bsbRecord, className, }) => {
|
112
|
+
return (React.createElement("div", { className: `control ob-bsb__record-control ${className}` },
|
113
|
+
React.createElement("a", { className: "button is-static ob-bsb__record-button" },
|
114
|
+
bsbRecord.financialInstitutionMnemonic,
|
115
|
+
" - ",
|
116
|
+
bsbRecord.name)));
|
117
|
+
};
|
110
118
|
export default React.memo(FormElementBSB);
|
111
119
|
//# sourceMappingURL=FormElementBSB.js.map
|
@@ -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,YAAY,MAAM,qCAAqC,CAAA;AAE9D,OAAO,yBAAyB,MAAM,kDAAkD,CAAA;AAExF,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC1E,OAAO,yBAAyB,MAAM,oCAAoC,CAAA;AAc1E,SAAS,cAAc,CAAC,EACtB,EAAE,EACF,MAAM,EACN,OAAO,EACP,KAAK,EACL,QAAQ,EACR,iBAAiB,EACjB,wBAAwB,EACxB,OAAO,EACP,UAAU,GACJ;IACN,MAAM,eAAe,GAAG,yBAAyB,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;IAC9D,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,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,QAA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H,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 LookupButton from '../components/renderer/LookupButton'\nimport { FormTypes, MiscTypes } from '@oneblink/types'\nimport FormElementLabelContainer from '../components/renderer/FormElementLabelContainer'\nimport { FormElementValueChangeHandler, IsDirtyProps } from '../types/form'\nimport { formService } from '@oneblink/apps'\nimport { LookupNotificationContext } from '../hooks/useLookupNotification'\nimport useElementAriaDescribedby from '../hooks/useElementAriaDescribedby'\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} & IsDirtyProps\n\nfunction FormElementBSB({\n id,\n formId,\n element,\n value,\n onChange,\n validationMessage,\n displayValidationMessage,\n isDirty,\n setIsDirty,\n}: Props) {\n const ariaDescribedby = useElementAriaDescribedby(id, element)\n const [text, setText] = React.useState(typeof value === 'string' ? value : '')\n const isValidFormat = /\\d{3}-\\d{3}/.test(text)\n\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, {\n value: bsbRecord.bsb,\n })\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, {\n value: { isValidating: true, isInvalid: false },\n })\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, {\n value: { isInvalid: true, isValidating: false },\n })\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 const { isLookingUp } = React.useContext(LookupNotificationContext)\n const isDisplayingValidationMessage =\n (((isDirty || displayValidationMessage) &&\n !!validationMessage &&\n !isLoading) ||\n errorMessage) &&\n !isLookingUp\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, {\n value: undefined,\n })\n }\n setIsDirty()\n }}\n aria-describedby={ariaDescribedby}\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 lookupButtonConfig={element.lookupButton}\n />\n </div>\n {isDisplayingValidationMessage && (\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,YAAY,MAAM,qCAAqC,CAAA;AAE9D,OAAO,yBAAyB,MAAM,kDAAkD,CAAA;AAExF,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC1E,OAAO,yBAAyB,MAAM,oCAAoC,CAAA;AAc1E,SAAS,cAAc,CAAC,EACtB,EAAE,EACF,MAAM,EACN,OAAO,EACP,KAAK,EACL,QAAQ,EACR,iBAAiB,EACjB,wBAAwB,EACxB,OAAO,EACP,UAAU,GACJ;IACN,MAAM,eAAe,GAAG,yBAAyB,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;IAC9D,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,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAItE;QACD,SAAS,EAAE,KAAK;QACh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,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,MAAM,UAAU,GAAG,CAAC,EAClB,SAAS,EACT,SAAS,GAIV,EAAE,EAAE;IACH,OAAO,CACL,6BAAK,SAAS,EAAE,kCAAkC,SAAS,EAAE;QAC3D,2BAAG,SAAS,EAAC,wCAAwC;YAClD,SAAS,CAAC,4BAA4B;;YAAK,SAAS,CAAC,IAAI,CACxD,CACA,CACP,CAAA;AACH,CAAC,CAAA;AACD,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 LookupButton from '../components/renderer/LookupButton'\nimport { FormTypes, MiscTypes } from '@oneblink/types'\nimport FormElementLabelContainer from '../components/renderer/FormElementLabelContainer'\nimport { FormElementValueChangeHandler, IsDirtyProps } from '../types/form'\nimport { formService } from '@oneblink/apps'\nimport { LookupNotificationContext } from '../hooks/useLookupNotification'\nimport useElementAriaDescribedby from '../hooks/useElementAriaDescribedby'\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} & IsDirtyProps\n\nfunction FormElementBSB({\n id,\n formId,\n element,\n value,\n onChange,\n validationMessage,\n displayValidationMessage,\n isDirty,\n setIsDirty,\n}: Props) {\n const ariaDescribedby = useElementAriaDescribedby(id, element)\n const [text, setText] = React.useState(typeof value === 'string' ? value : '')\n const isValidFormat = /\\d{3}-\\d{3}/.test(text)\n\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, {\n value: bsbRecord.bsb,\n })\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, {\n value: { isValidating: true, isInvalid: false },\n })\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, {\n value: { isInvalid: true, isValidating: false },\n })\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 const { isLookingUp } = React.useContext(LookupNotificationContext)\n const isDisplayingValidationMessage =\n (((isDirty || displayValidationMessage) &&\n !!validationMessage &&\n !isLoading) ||\n errorMessage) &&\n !isLookingUp\n\n const hasCopyButton = !!value && !!element.readOnly\n const hasLookupButton = element.isDataLookup || element.isElementLookup\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\n className={clsx('field has-addons', {\n 'no-addons-mobile': !hasCopyButton && !hasLookupButton,\n })}\n >\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, {\n value: undefined,\n })\n }\n setIsDirty()\n }}\n aria-describedby={ariaDescribedby}\n />\n </div>\n {bsbRecord && (\n <BSBDisplay\n bsbRecord={bsbRecord}\n className=\"ob-bsb__display-desktop\"\n />\n )}\n {hasCopyButton && (\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 lookupButtonConfig={element.lookupButton}\n />\n </div>\n {bsbRecord && (\n <BSBDisplay\n bsbRecord={bsbRecord}\n className=\"ob-bsb__display-mobile\"\n />\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 {errorMessage || validationMessage}\n </div>\n </div>\n )}\n </FormElementLabelContainer>\n </div>\n )\n}\n\nconst BSBDisplay = ({\n bsbRecord,\n className,\n}: {\n bsbRecord: MiscTypes.BSBRecord\n className: string\n}) => {\n return (\n <div className={`control ob-bsb__record-control ${className}`}>\n <a className=\"button is-static ob-bsb__record-button\">\n {bsbRecord.financialInstitutionMnemonic} - {bsbRecord.name}\n </a>\n </div>\n )\n}\nexport default React.memo(FormElementBSB)\n"]}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
.ob-abn__display-mobile {
|
2
|
+
display: none;
|
3
|
+
@media only screen and (max-width: $mobile) {
|
4
|
+
display: block;
|
5
|
+
}
|
6
|
+
|
7
|
+
.ob-abn__record-button {
|
8
|
+
border-top: 0px;
|
9
|
+
border-top-left-radius: 0px;
|
10
|
+
border-top-right-radius: 0px;
|
11
|
+
width: 100%;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
.ob-abn__display-desktop {
|
16
|
+
@media only screen and (max-width: $mobile) {
|
17
|
+
display: none;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
.ob-abn .field .control:first-child .input {
|
22
|
+
@media only screen and (max-width: $mobile) {
|
23
|
+
border-bottom-left-radius: 0px;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
/** Styles copy or lookup button */
|
28
|
+
.ob-abn .field .control:last-child .button {
|
29
|
+
@media only screen and (max-width: $mobile) {
|
30
|
+
border-bottom-right-radius: 0px;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
/** Styles input field when there are no copy or lookup buttons */
|
35
|
+
.ob-abn
|
36
|
+
.field.has-addons.no-addons-mobile
|
37
|
+
.control:first-child:not(:only-child)
|
38
|
+
.input {
|
39
|
+
@media only screen and (max-width: $mobile) {
|
40
|
+
border-top-right-radius: 4px;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
.field.no-addons-mobile .control:not(:last-child) {
|
45
|
+
@media only screen and (max-width: $mobile) {
|
46
|
+
margin-right: 0px;
|
47
|
+
}
|
48
|
+
}
|
package/dist/styles/bsb.scss
CHANGED
@@ -8,3 +8,52 @@
|
|
8
8
|
text-overflow: ellipsis;
|
9
9
|
display: block;
|
10
10
|
}
|
11
|
+
|
12
|
+
.ob-bsb__display-mobile {
|
13
|
+
display: none;
|
14
|
+
@media only screen and (max-width: $mobile) {
|
15
|
+
display: block;
|
16
|
+
}
|
17
|
+
|
18
|
+
.ob-bsb__record-button {
|
19
|
+
border-top: 0px;
|
20
|
+
border-top-left-radius: 0px;
|
21
|
+
border-top-right-radius: 0px;
|
22
|
+
width: 100%;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
.ob-bsb__display-desktop {
|
27
|
+
@media only screen and (max-width: $mobile) {
|
28
|
+
display: none;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
.ob-bsb .field .control:first-child .input {
|
33
|
+
@media only screen and (max-width: $mobile) {
|
34
|
+
border-bottom-left-radius: 0px;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
/** Styles copy or lookup button */
|
39
|
+
.ob-bsb .field .control:last-child .button {
|
40
|
+
@media only screen and (max-width: $mobile) {
|
41
|
+
border-bottom-right-radius: 0px;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
/** Styles input field when there are no copy or lookup buttons */
|
46
|
+
.ob-bsb
|
47
|
+
.field.has-addons.no-addons-mobile
|
48
|
+
.control:first-child:not(:only-child)
|
49
|
+
.input {
|
50
|
+
@media only screen and (max-width: $mobile) {
|
51
|
+
border-top-right-radius: 4px;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
.field.no-addons-mobile .control:not(:last-child) {
|
56
|
+
@media only screen and (max-width: $mobile) {
|
57
|
+
margin-right: 0px;
|
58
|
+
}
|
59
|
+
}
|
package/dist/styles.css
CHANGED
@@ -9505,6 +9505,53 @@ textarea:disabled {
|
|
9505
9505
|
display: block;
|
9506
9506
|
}
|
9507
9507
|
|
9508
|
+
.ob-bsb__display-mobile {
|
9509
|
+
display: none;
|
9510
|
+
}
|
9511
|
+
@media only screen and (max-width: 768px) {
|
9512
|
+
.ob-bsb__display-mobile {
|
9513
|
+
display: block;
|
9514
|
+
}
|
9515
|
+
}
|
9516
|
+
.ob-bsb__display-mobile .ob-bsb__record-button {
|
9517
|
+
border-top: 0px;
|
9518
|
+
border-top-left-radius: 0px;
|
9519
|
+
border-top-right-radius: 0px;
|
9520
|
+
width: 100%;
|
9521
|
+
}
|
9522
|
+
|
9523
|
+
@media only screen and (max-width: 768px) {
|
9524
|
+
.ob-bsb__display-desktop {
|
9525
|
+
display: none;
|
9526
|
+
}
|
9527
|
+
}
|
9528
|
+
|
9529
|
+
@media only screen and (max-width: 768px) {
|
9530
|
+
.ob-bsb .field .control:first-child .input {
|
9531
|
+
border-bottom-left-radius: 0px;
|
9532
|
+
}
|
9533
|
+
}
|
9534
|
+
|
9535
|
+
/** Styles copy or lookup button */
|
9536
|
+
@media only screen and (max-width: 768px) {
|
9537
|
+
.ob-bsb .field .control:last-child .button {
|
9538
|
+
border-bottom-right-radius: 0px;
|
9539
|
+
}
|
9540
|
+
}
|
9541
|
+
|
9542
|
+
/** Styles input field when there are no copy or lookup buttons */
|
9543
|
+
@media only screen and (max-width: 768px) {
|
9544
|
+
.ob-bsb .field.has-addons.no-addons-mobile .control:first-child:not(:only-child) .input {
|
9545
|
+
border-top-right-radius: 4px;
|
9546
|
+
}
|
9547
|
+
}
|
9548
|
+
|
9549
|
+
@media only screen and (max-width: 768px) {
|
9550
|
+
.field.no-addons-mobile .control:not(:last-child) {
|
9551
|
+
margin-right: 0px;
|
9552
|
+
}
|
9553
|
+
}
|
9554
|
+
|
9508
9555
|
.ob-progress__attachment-wrapper .ob-progress__attachment-bar {
|
9509
9556
|
position: absolute;
|
9510
9557
|
bottom: 0;
|
@@ -9711,6 +9758,53 @@ textarea:disabled {
|
|
9711
9758
|
height: 500px;
|
9712
9759
|
}
|
9713
9760
|
|
9761
|
+
.ob-abn__display-mobile {
|
9762
|
+
display: none;
|
9763
|
+
}
|
9764
|
+
@media only screen and (max-width: 768px) {
|
9765
|
+
.ob-abn__display-mobile {
|
9766
|
+
display: block;
|
9767
|
+
}
|
9768
|
+
}
|
9769
|
+
.ob-abn__display-mobile .ob-abn__record-button {
|
9770
|
+
border-top: 0px;
|
9771
|
+
border-top-left-radius: 0px;
|
9772
|
+
border-top-right-radius: 0px;
|
9773
|
+
width: 100%;
|
9774
|
+
}
|
9775
|
+
|
9776
|
+
@media only screen and (max-width: 768px) {
|
9777
|
+
.ob-abn__display-desktop {
|
9778
|
+
display: none;
|
9779
|
+
}
|
9780
|
+
}
|
9781
|
+
|
9782
|
+
@media only screen and (max-width: 768px) {
|
9783
|
+
.ob-abn .field .control:first-child .input {
|
9784
|
+
border-bottom-left-radius: 0px;
|
9785
|
+
}
|
9786
|
+
}
|
9787
|
+
|
9788
|
+
/** Styles copy or lookup button */
|
9789
|
+
@media only screen and (max-width: 768px) {
|
9790
|
+
.ob-abn .field .control:last-child .button {
|
9791
|
+
border-bottom-right-radius: 0px;
|
9792
|
+
}
|
9793
|
+
}
|
9794
|
+
|
9795
|
+
/** Styles input field when there are no copy or lookup buttons */
|
9796
|
+
@media only screen and (max-width: 768px) {
|
9797
|
+
.ob-abn .field.has-addons.no-addons-mobile .control:first-child:not(:only-child) .input {
|
9798
|
+
border-top-right-radius: 4px;
|
9799
|
+
}
|
9800
|
+
}
|
9801
|
+
|
9802
|
+
@media only screen and (max-width: 768px) {
|
9803
|
+
.field.no-addons-mobile .control:not(:last-child) {
|
9804
|
+
margin-right: 0px;
|
9805
|
+
}
|
9806
|
+
}
|
9807
|
+
|
9714
9808
|
.flatpickr-calendar {
|
9715
9809
|
background: transparent;
|
9716
9810
|
opacity: 0;
|
package/dist/styles.scss
CHANGED
@@ -140,6 +140,7 @@ $section-padding-mobile: $section-padding-mobile-y $section-padding-mobile-x;
|
|
140
140
|
@import './styles/westpac-payment.scss';
|
141
141
|
@import './styles/api-nsw-liquor-licence.scss';
|
142
142
|
@import './styles/arcgis-web-map.scss';
|
143
|
+
@import './styles/abn.scss';
|
143
144
|
//
|
144
145
|
// Third Party
|
145
146
|
//
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@oneblink/apps-react",
|
3
3
|
"description": "Helper functions for OneBlink apps in ReactJS.",
|
4
|
-
"version": "6.2.0
|
4
|
+
"version": "6.2.0",
|
5
5
|
"author": "OneBlink <developers@oneblink.io> (https://oneblink.io)",
|
6
6
|
"bugs": {
|
7
7
|
"url": "https://github.com/oneblink/apps-react/issues"
|
@@ -46,7 +46,7 @@
|
|
46
46
|
"@mui/lab": "^5.0.0-alpha.152",
|
47
47
|
"@mui/material": "^5.15.6",
|
48
48
|
"@mui/x-date-pickers": "^6.19.2",
|
49
|
-
"@oneblink/apps": "^13.0.0-beta.
|
49
|
+
"@oneblink/apps": "^13.0.0-beta.5",
|
50
50
|
"@oneblink/release-cli": "^3.2.1",
|
51
51
|
"@oneblink/types": "github:oneblink/types",
|
52
52
|
"@types/blueimp-load-image": "^5.16.6",
|