@oneblink/apps-react 5.5.0-beta.4 → 5.5.0-beta.6

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.
@@ -248,7 +248,7 @@ function LookupNotificationComponent({ autoLookupValue, stringifyAutoLookupValue
248
248
  }) },
249
249
  React.createElement("div", { className: "notification has-margin-top-7 has-text-centered" },
250
250
  hasLookupFailed && (React.createElement(React.Fragment, null,
251
- React.createElement("button", { type: "button", className: "delete fade-in", onClick: () => setIsLookingUp(false) }),
251
+ React.createElement("button", { type: "button", className: "delete fade-in", onClick: () => setIsLookingUp(false), "aria-label": "lookup-failure-close-button" }),
252
252
  React.createElement("div", null, isOffline && isNotStaticLookup ? (React.createElement("div", null,
253
253
  React.createElement("i", { className: "material-icons fade-in has-text-warning" }, "wifi_off"),
254
254
  React.createElement("p", { className: "fade-in" }, "It looks like you're offline. Please try again when connectivity is restored."))) : (React.createElement("div", null,
@@ -1 +1 @@
1
- {"version":3,"file":"LookupNotification.js","sourceRoot":"","sources":["../../../src/components/renderer/LookupNotification.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA;AACpE,OAAO,EAAE,MAAM,EAAe,MAAM,gBAAgB,CAAA;AAGpD,OAAO,YAAY,MAAM,0BAA0B,CAAA;AACnD,OAAO,SAAS,MAAM,aAAa,CAAA;AACnC,OAAO,mBAAmB,MAAM,sCAAsC,CAAA;AACtE,OAAO,EACL,yBAAyB,GAE1B,MAAM,mCAAmC,CAAA;AAC1C,OAAO,iBAAiB,MAAM,+BAA+B,CAAA;AAC7D,OAAO,cAAc,MAAM,4BAA4B,CAAA;AACvD,OAAO,sBAAsB,MAAM,2CAA2C,CAAA;AAC9E,OAAO,iBAAiB,MAAM,+BAA+B,CAAA;AAC7D,OAAO,YAAY,MAAM,0B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AAI,CAAC,OAAO,CAAA;SACnB;QACD,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;KAChD;IAED,OAAO,IAA+B,CAAA;AACxC,CAAC","sourcesContent":["import * as React from 'react'\nimport clsx from 'clsx'\nimport { generateHeaders } from '@oneblink/apps/dist/services/fetch'\nimport { Sentry, formService } from '@oneblink/apps'\nimport { FormTypes, SubmissionTypes } from '@oneblink/types'\n\nimport useIsOffline from '../../hooks/useIsOffline'\nimport OnLoading from './OnLoading'\nimport generateDefaultData from '../../services/generate-default-data'\nimport {\n LookupNotificationContext,\n LookupNotificationContextValue,\n} from '../../hooks/useLookupNotification'\nimport useFormDefinition from '../../hooks/useFormDefinition'\nimport useInjectPages from '../../hooks/useInjectPages'\nimport useFormSubmissionModel from '../../hooks/useFormSubmissionModelContext'\nimport useFormIsReadOnly from '../../hooks/useFormIsReadOnly'\nimport useIsMounted from '../../hooks/useIsMounted'\nimport useFormElementLookups from '../../hooks/useFormElementLookups'\nimport mergeExecutedLookups from '../../utils/merge-executed-lookups'\n\nimport { FormElementLookupHandler, ExecutedLookups } from '../../types/form'\nimport ErrorMessage from '../messages/ErrorMessage'\n\ntype FetchLookupPayload = {\n element: FormTypes.LookupFormElement\n definition?: FormTypes.Form\n submission: SubmissionTypes.S3SubmissionData['submission']\n}\ntype Props = {\n autoLookupValue?: unknown\n stringifyAutoLookupValue?: (autoLookupValue: unknown) => string\n element: FormTypes.LookupFormElement\n onLookup: FormElementLookupHandler\n children: React.ReactNode\n}\n\nfunction LookupNotificationComponent({\n autoLookupValue,\n stringifyAutoLookupValue,\n element,\n onLookup,\n children,\n}: Props) {\n const isMounted = useIsMounted()\n const isOffline = useIsOffline()\n const definition = useFormDefinition()\n const injectPagesAfter = useInjectPages()\n const { isLoading, formElementLookups, loadError, onTryAgain } =\n useFormElementLookups()\n\n const [onCancelLookup, setOnCancelLookup] = React.useState<\n (() => void) | undefined\n >(undefined)\n const [isLookingUp, setIsLookingUp] = React.useState(false)\n const [hasLookupFailed, setHasLookupFailed] = React.useState(false)\n const [hasLookupSucceeded, setHasLookupSucceeded] = React.useState(false)\n const [isCancellable, setIsCancellable] = React.useState(false)\n const [isDisabled, setIsDisabled] = React.useState(false)\n const [lookupErrorHTML, setLookupErrorHTML] = React.useState<string | null>(\n null,\n )\n const formIsReadOnly = useFormIsReadOnly()\n const { formSubmissionModel: model } = useFormSubmissionModel()\n\n const formElementElementLookup = React.useMemo(() => {\n return formElementLookups.find(\n ({ id }) => element.isElementLookup && id === element.elementLookupId,\n )\n }, [element.elementLookupId, element.isElementLookup, formElementLookups])\n\n const formElementDataLookup = React.useMemo(() => {\n return formElementLookups.find(\n ({ id }) => element.isDataLookup && id === element.dataLookupId,\n )\n }, [element.dataLookupId, element.isDataLookup, formElementLookups])\n\n const runLookupOnClear = React.useMemo<boolean>(() => {\n return !!(\n formElementDataLookup?.runLookupOnClear ||\n formElementElementLookup?.runLookupOnClear\n )\n }, [\n formElementDataLookup?.runLookupOnClear,\n formElementElementLookup?.runLookupOnClear,\n ])\n\n const excludeDefinition = React.useMemo(() => {\n return !!(\n (formElementDataLookup?.type !== 'STATIC_DATA' &&\n formElementDataLookup?.excludeDefinition) ||\n (formElementElementLookup?.type !== 'STATIC_DATA' &&\n formElementElementLookup?.excludeDefinition)\n )\n }, [formElementDataLookup, formElementElementLookup])\n\n const mergeLookupData = React.useCallback(\n ({\n newValue,\n dataLookupResult,\n elementLookupResult,\n executedLookup,\n }: {\n newValue: unknown\n dataLookupResult:\n | SubmissionTypes.S3SubmissionData['submission']\n | undefined\n elementLookupResult: FormTypes.FormElement[] | undefined\n executedLookup: ExecutedLookups\n }) => {\n const executedLookupResult = executedLookup?.[element.name]\n if (elementLookupResult && executedLookupResult !== false) {\n if (elementLookupResult[0] && elementLookupResult[0].type === 'page') {\n injectPagesAfter(\n element,\n elementLookupResult as FormTypes.PageElement[],\n dataLookupResult,\n )\n return\n }\n }\n\n onLookup(({ submission, elements, executedLookups }) => {\n let allElements: FormTypes.FormElement[] = elements\n if (\n Array.isArray(elementLookupResult) &&\n executedLookupResult !== false\n ) {\n const indexOfElement = elements.findIndex(\n ({ id }) => id === element.id,\n )\n if (indexOfElement === -1) {\n console.log('Could not find element', element)\n } else {\n // Filter out already injected elements if lookup was successful\n allElements = elements.filter(\n // @ts-expect-error Sorry typescript, we need to check a property you don't approve of :(\n (e) => e.injectedByElementId !== element.id,\n )\n allElements.splice(\n indexOfElement + 1,\n 0,\n ...elementLookupResult.map((e) => {\n // @ts-expect-error Sorry typescript, we need to check a property you don't approve of :(\n e.injectedByElementId = element.id\n return e\n }),\n )\n }\n }\n\n return {\n elements: allElements,\n submission: generateDefaultData(allElements, {\n ...submission,\n [element.name]: newValue,\n ...dataLookupResult,\n }),\n executedLookups: mergeExecutedLookups({\n dataLookupResult,\n currentSubmission: submission,\n executedLookups: {\n ...executedLookups,\n ...executedLookup,\n },\n }),\n }\n })\n },\n [element, injectPagesAfter, onLookup],\n )\n\n const isNotStaticLookup = React.useMemo(() => {\n return (\n (formElementDataLookup && formElementDataLookup.type !== 'STATIC_DATA') ||\n (formElementElementLookup &&\n formElementElementLookup.type !== 'STATIC_DATA')\n )\n }, [formElementDataLookup, formElementElementLookup])\n\n const triggerLookup = React.useCallback<\n LookupNotificationContextValue['onLookup']\n >(\n async ({ newValue, abortController, continueLookupOnAbort }) => {\n // No lookups for read only forms\n if (formIsReadOnly) return\n\n setIsLookingUp(true)\n\n if (isOffline && isNotStaticLookup) {\n setHasLookupFailed(true)\n return\n }\n\n setIsDisabled(true)\n setIsCancellable(false)\n setHasLookupFailed(false)\n setHasLookupSucceeded(false)\n setLookupErrorHTML(null)\n setOnCancelLookup(() => () => {\n if (isMounted.current) {\n setIsLookingUp(false)\n }\n abortController.abort()\n })\n\n // After certain amount of time, show the cancel button\n const isCancellableTimeout = setTimeout(() => {\n setIsCancellable(!abortController.signal.aborted)\n }, 5000)\n\n const payload: FetchLookupPayload = {\n element,\n definition: !excludeDefinition ? definition : undefined,\n submission: {\n ...model,\n [element.name]: newValue,\n },\n }\n\n try {\n const [dataLookupResult, elementLookupResult] = await Promise.all([\n fetchLookup(formElementDataLookup, payload, abortController.signal),\n fetchLookup(\n formElementElementLookup,\n payload,\n abortController.signal,\n ),\n ])\n\n mergeLookupData({\n newValue,\n dataLookupResult: dataLookupResult as\n | SubmissionTypes.S3SubmissionData['submission']\n | undefined,\n elementLookupResult: elementLookupResult as\n | FormTypes.FormElement[]\n | undefined,\n executedLookup: { [element.name]: true },\n })\n\n if (isMounted.current) {\n setHasLookupSucceeded(true)\n }\n\n // After certain amount of time, hide the lookup succeeded message\n setTimeout(() => {\n if (isMounted.current) {\n setIsLookingUp(false)\n }\n }, 750)\n } catch (error) {\n if (!isMounted.current) {\n return\n }\n\n if (abortController.signal.aborted) {\n console.log('Fetch aborted')\n if (!continueLookupOnAbort) {\n setIsLookingUp(false)\n }\n return\n }\n\n setHasLookupFailed(true)\n mergeLookupData({\n newValue: model[element.name],\n dataLookupResult: {},\n elementLookupResult: [],\n executedLookup: { [element.name]: false },\n })\n setLookupErrorHTML(\n typeof error === 'string'\n ? error\n : 'It looks like something went wrong.<br/>Please try again.<br />If the issue continues, please contact support.',\n )\n } finally {\n clearTimeout(isCancellableTimeout)\n if (isMounted.current) {\n setIsDisabled(false)\n setOnCancelLookup(undefined)\n }\n }\n },\n [\n definition,\n element,\n excludeDefinition,\n formElementDataLookup,\n formElementElementLookup,\n formIsReadOnly,\n isMounted,\n isNotStaticLookup,\n isOffline,\n mergeLookupData,\n model,\n ],\n )\n\n // For certain elements, do not add click event\n // instead, watch model for changes and trigger lookup function.\n // We add this stringify function here to allow the value to be\n // an object which may have a reference change, but the values\n // have not changed. e.g. the 'location' element's value\n const autoLookupValueString = stringifyAutoLookupValue\n ? stringifyAutoLookupValue(autoLookupValue)\n : autoLookupValue\n React.useEffect(() => {\n if (isLoading || loadError) {\n return\n }\n const hasLookupRan = hasLookupFailed || hasLookupSucceeded\n\n // For lookups configured with `runLookupOnClear` set to true, we want to\n // allow empty values for `autoLookupValue`, but only if the lookup has\n // been ran previously. This prevents the lookup running on load with an empty value.\n if (\n (autoLookupValue === undefined || autoLookupValue === null) &&\n (!runLookupOnClear || !hasLookupRan)\n ) {\n setIsLookingUp(false)\n return\n }\n const abortController = new AbortController()\n triggerLookup({\n newValue: autoLookupValue,\n abortController,\n continueLookupOnAbort: true,\n })\n return () => {\n abortController.abort()\n }\n // Wants to use \"triggerLookup\" as a dependency,\n // however, this will change on any change made on any\n // element. Checking if \"value\" has changed is enough\n // to trigger a lookup when the correct dependencies change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [autoLookupValueString, isLoading])\n\n const contextValue = React.useMemo(\n () => ({\n isLookup: true,\n isDisabled,\n isLoading,\n onLookup: triggerLookup,\n allowLookupOnEmptyValue: runLookupOnClear,\n isLookingUp,\n }),\n [isDisabled, isLoading, runLookupOnClear, triggerLookup, isLookingUp],\n )\n\n return (\n <LookupNotificationContext.Provider value={contextValue}>\n {children}\n\n {loadError && (\n <ErrorMessage\n title=\"Error Loading Configuration\"\n onTryAgain={onTryAgain}\n >\n <span className=\"cypress-lookup-notification-loading-error\">\n {loadError.message}\n </span>\n </ErrorMessage>\n )}\n\n <div\n className={clsx('ob-lookup__notification', {\n 'is-looking-up': isLookingUp,\n 'is-extended':\n hasLookupFailed || (isCancellable && !hasLookupSucceeded),\n })}\n >\n <div className=\"notification has-margin-top-7 has-text-centered\">\n {hasLookupFailed && (\n <>\n <button\n type=\"button\"\n className=\"delete fade-in\"\n onClick={() => setIsLookingUp(false)}\n />\n\n <div>\n {isOffline && isNotStaticLookup ? (\n <div>\n <i className=\"material-icons fade-in has-text-warning\">\n wifi_off\n </i>\n <p className=\"fade-in\">\n It looks like you&apos;re offline. Please try again when\n connectivity is restored.\n </p>\n </div>\n ) : (\n <div>\n <i className=\"material-icons fade-in has-text-danger\">\n error_outline\n </i>\n <p\n className=\"fade-in\"\n // eslint-disable-next-line react/no-danger\n dangerouslySetInnerHTML={{\n __html: lookupErrorHTML || '',\n }}\n />\n </div>\n )}\n </div>\n </>\n )}\n\n {hasLookupSucceeded && (\n <i className=\"material-icons has-text-success fade-in\">\n check_circle_outline\n </i>\n )}\n\n {!hasLookupSucceeded && !hasLookupFailed && <OnLoading small />}\n\n {isCancellable && !hasLookupSucceeded && !hasLookupFailed && (\n <div className=\"has-margin-top-5 fade-in\">\n <p>Taking longer than expected?</p>\n <button\n type=\"button\"\n className=\"button has-margin-top-8\"\n onClick={onCancelLookup}\n >\n Cancel\n </button>\n </div>\n )}\n </div>\n </div>\n </LookupNotificationContext.Provider>\n )\n}\n\nexport default function LookupNotification(props: Props) {\n if (props.element.isDataLookup || props.element.isElementLookup) {\n return <LookupNotificationComponent {...props} />\n }\n\n return <>{props.children}</>\n}\n\nasync function fetchLookup(\n formElementLookup: formService.FormElementLookupResult | undefined,\n payload: FetchLookupPayload,\n abortSignal: AbortSignal,\n): Promise<\n | SubmissionTypes.S3SubmissionData['submission']\n | FormTypes.FormElement[]\n | undefined\n> {\n if (!formElementLookup) {\n return\n }\n\n if (formElementLookup.records) {\n const elementName = payload.element.name\n const inputValue = payload.submission[elementName]\n\n const matchingRecord = formElementLookup.records.find(\n (r) =>\n (r.inputType === 'UNDEFINED' && !inputValue) ||\n (r.inputType !== 'UNDEFINED' && r.inputValue === inputValue),\n )\n\n // insert prefill values\n return matchingRecord?.preFills.reduce<\n SubmissionTypes.S3SubmissionData['submission']\n >((lookupResult, prefill) => {\n switch (prefill.type) {\n case 'TEXT':\n lookupResult[prefill.formElementName] = prefill.text\n break\n case 'NUMBER':\n lookupResult[prefill.formElementName] = prefill.number\n break\n case 'CLEAR':\n lookupResult[prefill.formElementName] = undefined\n break\n }\n return lookupResult\n }, {})\n }\n\n if (!formElementLookup.url) {\n console.log(\n 'Could not find dynamic URL or static records for form element lookup:',\n formElementLookup,\n )\n throw new Error('Could not find element lookup configuration')\n }\n\n const headers = await generateHeaders()\n console.log(\n `Attempting a ${formElementLookup.type} lookup request to:`,\n formElementLookup.url,\n )\n const response = await fetch(formElementLookup.url, {\n method: 'POST',\n headers,\n body: JSON.stringify(payload),\n signal: abortSignal,\n })\n\n const data = await response.json()\n console.log(\n 'Response from lookup to: POST',\n formElementLookup.url,\n response.status,\n data,\n )\n\n if (!response.ok) {\n Sentry.captureException(\n new Error(`Received ${response.status} status code from lookup`),\n )\n if (response.status === 400 && data && data.message) {\n throw data.message\n }\n throw new Error('Invalid response from lookup')\n }\n\n return data as FormTypes.FormElement[]\n}\n"]}
1
+ {"version":3,"file":"LookupNotification.js","sourceRoot":"","sources":["../../../src/components/renderer/LookupNotification.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA;AACpE,OAAO,EAAE,MAAM,EAAe,MAAM,gBAAgB,CAAA;AAGpD,OAAO,YAAY,MAAM,0BAA0B,CAAA;AACnD,OAAO,SAAS,MAAM,aAAa,CAAA;AACnC,OAAO,mBAAmB,MAAM,sCAAsC,CAAA;AACtE,OAAO,EACL,yBAAyB,GAE1B,MAAM,mCAAmC,CAAA;AAC1C,OAAO,iBAAiB,MAAM,+BAA+B,CAAA;AAC7D,OAAO,cAAc,MAAM,4BAA4B,CAAA;AACvD,OAAO,sBAAsB,MAAM,2CAA2C,CAAA;AAC9E,OAAO,iBAAiB,MAAM,+BAA+B,CAAA;AAC7D,OAAO,YAAY,MAAM,0BAA0B,CAAA;AACnD,OAAO,qBAAqB,MAAM,mCAAmC,CAAA;AACrE,OAAO,oBAAoB,MAAM,oCAAoC,CAAA;AAGrE,OAAO,YAAY,MAAM,0BAA0B,CAAA;AAenD,SAAS,2BAA2B,CAAC,EACnC,eAAe,EACf,wBAAwB,EACxB,OAAO,EACP,QAAQ,EACR,QAAQ,GACF;IACN,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAChC,MAAM,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,CAAC,EAAE,EAAE,CAAC,CAAA;KACP;IAED,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE;QAC1B,OAAO,CAAC,GAAG,CACT,uEAAuE,EACvE,iBAAiB,CAClB,CAAA;QACD,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;KAC/D;IAED,MAAM,OAAO,GAAG,MAAM,eAAe,EAAE,CAAA;IACvC,OAAO,CAAC,GAAG,CACT,gBAAgB,iBAAiB,CAAC,IAAI,qBAAqB,EAC3D,iBAAiB,CAAC,GAAG,CACtB,CAAA;IACD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,iBAAiB,CAAC,GAAG,EAAE;QAClD,MAAM,EAAE,MAAM;QACd,OAAO;QACP,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;QAC7B,MAAM,EAAE,WAAW;KACpB,CAAC,CAAA;IAEF,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IAClC,OAAO,CAAC,GAAG,CACT,+BAA+B,EAC/B,iBAAiB,CAAC,GAAG,EACrB,QAAQ,CAAC,MAAM,EACf,IAAI,CACL,CAAA;IAED,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;QAChB,MAAM,CAAC,gBAAgB,CACrB,IAAI,KAAK,CAAC,YAAY,QAAQ,CAAC,MAAM,0BAA0B,CAAC,CACjE,CAAA;QACD,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE;YACnD,MAAM,IAAI,CAAC,OAAO,CAAA;SACnB;QACD,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;KAChD;IAED,OAAO,IAA+B,CAAA;AACxC,CAAC","sourcesContent":["import * as React from 'react'\nimport clsx from 'clsx'\nimport { generateHeaders } from '@oneblink/apps/dist/services/fetch'\nimport { Sentry, formService } from '@oneblink/apps'\nimport { FormTypes, SubmissionTypes } from '@oneblink/types'\n\nimport useIsOffline from '../../hooks/useIsOffline'\nimport OnLoading from './OnLoading'\nimport generateDefaultData from '../../services/generate-default-data'\nimport {\n LookupNotificationContext,\n LookupNotificationContextValue,\n} from '../../hooks/useLookupNotification'\nimport useFormDefinition from '../../hooks/useFormDefinition'\nimport useInjectPages from '../../hooks/useInjectPages'\nimport useFormSubmissionModel from '../../hooks/useFormSubmissionModelContext'\nimport useFormIsReadOnly from '../../hooks/useFormIsReadOnly'\nimport useIsMounted from '../../hooks/useIsMounted'\nimport useFormElementLookups from '../../hooks/useFormElementLookups'\nimport mergeExecutedLookups from '../../utils/merge-executed-lookups'\n\nimport { FormElementLookupHandler, ExecutedLookups } from '../../types/form'\nimport ErrorMessage from '../messages/ErrorMessage'\n\ntype FetchLookupPayload = {\n element: FormTypes.LookupFormElement\n definition?: FormTypes.Form\n submission: SubmissionTypes.S3SubmissionData['submission']\n}\ntype Props = {\n autoLookupValue?: unknown\n stringifyAutoLookupValue?: (autoLookupValue: unknown) => string\n element: FormTypes.LookupFormElement\n onLookup: FormElementLookupHandler\n children: React.ReactNode\n}\n\nfunction LookupNotificationComponent({\n autoLookupValue,\n stringifyAutoLookupValue,\n element,\n onLookup,\n children,\n}: Props) {\n const isMounted = useIsMounted()\n const isOffline = useIsOffline()\n const definition = useFormDefinition()\n const injectPagesAfter = useInjectPages()\n const { isLoading, formElementLookups, loadError, onTryAgain } =\n useFormElementLookups()\n\n const [onCancelLookup, setOnCancelLookup] = React.useState<\n (() => void) | undefined\n >(undefined)\n const [isLookingUp, setIsLookingUp] = React.useState(false)\n const [hasLookupFailed, setHasLookupFailed] = React.useState(false)\n const [hasLookupSucceeded, setHasLookupSucceeded] = React.useState(false)\n const [isCancellable, setIsCancellable] = React.useState(false)\n const [isDisabled, setIsDisabled] = React.useState(false)\n const [lookupErrorHTML, setLookupErrorHTML] = React.useState<string | null>(\n null,\n )\n const formIsReadOnly = useFormIsReadOnly()\n const { formSubmissionModel: model } = useFormSubmissionModel()\n\n const formElementElementLookup = React.useMemo(() => {\n return formElementLookups.find(\n ({ id }) => element.isElementLookup && id === element.elementLookupId,\n )\n }, [element.elementLookupId, element.isElementLookup, formElementLookups])\n\n const formElementDataLookup = React.useMemo(() => {\n return formElementLookups.find(\n ({ id }) => element.isDataLookup && id === element.dataLookupId,\n )\n }, [element.dataLookupId, element.isDataLookup, formElementLookups])\n\n const runLookupOnClear = React.useMemo<boolean>(() => {\n return !!(\n formElementDataLookup?.runLookupOnClear ||\n formElementElementLookup?.runLookupOnClear\n )\n }, [\n formElementDataLookup?.runLookupOnClear,\n formElementElementLookup?.runLookupOnClear,\n ])\n\n const excludeDefinition = React.useMemo(() => {\n return !!(\n (formElementDataLookup?.type !== 'STATIC_DATA' &&\n formElementDataLookup?.excludeDefinition) ||\n (formElementElementLookup?.type !== 'STATIC_DATA' &&\n formElementElementLookup?.excludeDefinition)\n )\n }, [formElementDataLookup, formElementElementLookup])\n\n const mergeLookupData = React.useCallback(\n ({\n newValue,\n dataLookupResult,\n elementLookupResult,\n executedLookup,\n }: {\n newValue: unknown\n dataLookupResult:\n | SubmissionTypes.S3SubmissionData['submission']\n | undefined\n elementLookupResult: FormTypes.FormElement[] | undefined\n executedLookup: ExecutedLookups\n }) => {\n const executedLookupResult = executedLookup?.[element.name]\n if (elementLookupResult && executedLookupResult !== false) {\n if (elementLookupResult[0] && elementLookupResult[0].type === 'page') {\n injectPagesAfter(\n element,\n elementLookupResult as FormTypes.PageElement[],\n dataLookupResult,\n )\n return\n }\n }\n\n onLookup(({ submission, elements, executedLookups }) => {\n let allElements: FormTypes.FormElement[] = elements\n if (\n Array.isArray(elementLookupResult) &&\n executedLookupResult !== false\n ) {\n const indexOfElement = elements.findIndex(\n ({ id }) => id === element.id,\n )\n if (indexOfElement === -1) {\n console.log('Could not find element', element)\n } else {\n // Filter out already injected elements if lookup was successful\n allElements = elements.filter(\n // @ts-expect-error Sorry typescript, we need to check a property you don't approve of :(\n (e) => e.injectedByElementId !== element.id,\n )\n allElements.splice(\n indexOfElement + 1,\n 0,\n ...elementLookupResult.map((e) => {\n // @ts-expect-error Sorry typescript, we need to check a property you don't approve of :(\n e.injectedByElementId = element.id\n return e\n }),\n )\n }\n }\n\n return {\n elements: allElements,\n submission: generateDefaultData(allElements, {\n ...submission,\n [element.name]: newValue,\n ...dataLookupResult,\n }),\n executedLookups: mergeExecutedLookups({\n dataLookupResult,\n currentSubmission: submission,\n executedLookups: {\n ...executedLookups,\n ...executedLookup,\n },\n }),\n }\n })\n },\n [element, injectPagesAfter, onLookup],\n )\n\n const isNotStaticLookup = React.useMemo(() => {\n return (\n (formElementDataLookup && formElementDataLookup.type !== 'STATIC_DATA') ||\n (formElementElementLookup &&\n formElementElementLookup.type !== 'STATIC_DATA')\n )\n }, [formElementDataLookup, formElementElementLookup])\n\n const triggerLookup = React.useCallback<\n LookupNotificationContextValue['onLookup']\n >(\n async ({ newValue, abortController, continueLookupOnAbort }) => {\n // No lookups for read only forms\n if (formIsReadOnly) return\n\n setIsLookingUp(true)\n\n if (isOffline && isNotStaticLookup) {\n setHasLookupFailed(true)\n return\n }\n\n setIsDisabled(true)\n setIsCancellable(false)\n setHasLookupFailed(false)\n setHasLookupSucceeded(false)\n setLookupErrorHTML(null)\n setOnCancelLookup(() => () => {\n if (isMounted.current) {\n setIsLookingUp(false)\n }\n abortController.abort()\n })\n\n // After certain amount of time, show the cancel button\n const isCancellableTimeout = setTimeout(() => {\n setIsCancellable(!abortController.signal.aborted)\n }, 5000)\n\n const payload: FetchLookupPayload = {\n element,\n definition: !excludeDefinition ? definition : undefined,\n submission: {\n ...model,\n [element.name]: newValue,\n },\n }\n\n try {\n const [dataLookupResult, elementLookupResult] = await Promise.all([\n fetchLookup(formElementDataLookup, payload, abortController.signal),\n fetchLookup(\n formElementElementLookup,\n payload,\n abortController.signal,\n ),\n ])\n\n mergeLookupData({\n newValue,\n dataLookupResult: dataLookupResult as\n | SubmissionTypes.S3SubmissionData['submission']\n | undefined,\n elementLookupResult: elementLookupResult as\n | FormTypes.FormElement[]\n | undefined,\n executedLookup: { [element.name]: true },\n })\n\n if (isMounted.current) {\n setHasLookupSucceeded(true)\n }\n\n // After certain amount of time, hide the lookup succeeded message\n setTimeout(() => {\n if (isMounted.current) {\n setIsLookingUp(false)\n }\n }, 750)\n } catch (error) {\n if (!isMounted.current) {\n return\n }\n\n if (abortController.signal.aborted) {\n console.log('Fetch aborted')\n if (!continueLookupOnAbort) {\n setIsLookingUp(false)\n }\n return\n }\n\n setHasLookupFailed(true)\n mergeLookupData({\n newValue: model[element.name],\n dataLookupResult: {},\n elementLookupResult: [],\n executedLookup: { [element.name]: false },\n })\n setLookupErrorHTML(\n typeof error === 'string'\n ? error\n : 'It looks like something went wrong.<br/>Please try again.<br />If the issue continues, please contact support.',\n )\n } finally {\n clearTimeout(isCancellableTimeout)\n if (isMounted.current) {\n setIsDisabled(false)\n setOnCancelLookup(undefined)\n }\n }\n },\n [\n definition,\n element,\n excludeDefinition,\n formElementDataLookup,\n formElementElementLookup,\n formIsReadOnly,\n isMounted,\n isNotStaticLookup,\n isOffline,\n mergeLookupData,\n model,\n ],\n )\n\n // For certain elements, do not add click event\n // instead, watch model for changes and trigger lookup function.\n // We add this stringify function here to allow the value to be\n // an object which may have a reference change, but the values\n // have not changed. e.g. the 'location' element's value\n const autoLookupValueString = stringifyAutoLookupValue\n ? stringifyAutoLookupValue(autoLookupValue)\n : autoLookupValue\n React.useEffect(() => {\n if (isLoading || loadError) {\n return\n }\n const hasLookupRan = hasLookupFailed || hasLookupSucceeded\n\n // For lookups configured with `runLookupOnClear` set to true, we want to\n // allow empty values for `autoLookupValue`, but only if the lookup has\n // been ran previously. This prevents the lookup running on load with an empty value.\n if (\n (autoLookupValue === undefined || autoLookupValue === null) &&\n (!runLookupOnClear || !hasLookupRan)\n ) {\n setIsLookingUp(false)\n return\n }\n const abortController = new AbortController()\n triggerLookup({\n newValue: autoLookupValue,\n abortController,\n continueLookupOnAbort: true,\n })\n return () => {\n abortController.abort()\n }\n // Wants to use \"triggerLookup\" as a dependency,\n // however, this will change on any change made on any\n // element. Checking if \"value\" has changed is enough\n // to trigger a lookup when the correct dependencies change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [autoLookupValueString, isLoading])\n\n const contextValue = React.useMemo(\n () => ({\n isLookup: true,\n isDisabled,\n isLoading,\n onLookup: triggerLookup,\n allowLookupOnEmptyValue: runLookupOnClear,\n isLookingUp,\n }),\n [isDisabled, isLoading, runLookupOnClear, triggerLookup, isLookingUp],\n )\n\n return (\n <LookupNotificationContext.Provider value={contextValue}>\n {children}\n\n {loadError && (\n <ErrorMessage\n title=\"Error Loading Configuration\"\n onTryAgain={onTryAgain}\n >\n <span className=\"cypress-lookup-notification-loading-error\">\n {loadError.message}\n </span>\n </ErrorMessage>\n )}\n\n <div\n className={clsx('ob-lookup__notification', {\n 'is-looking-up': isLookingUp,\n 'is-extended':\n hasLookupFailed || (isCancellable && !hasLookupSucceeded),\n })}\n >\n <div className=\"notification has-margin-top-7 has-text-centered\">\n {hasLookupFailed && (\n <>\n <button\n type=\"button\"\n className=\"delete fade-in\"\n onClick={() => setIsLookingUp(false)}\n aria-label=\"lookup-failure-close-button\"\n />\n\n <div>\n {isOffline && isNotStaticLookup ? (\n <div>\n <i className=\"material-icons fade-in has-text-warning\">\n wifi_off\n </i>\n <p className=\"fade-in\">\n It looks like you&apos;re offline. Please try again when\n connectivity is restored.\n </p>\n </div>\n ) : (\n <div>\n <i className=\"material-icons fade-in has-text-danger\">\n error_outline\n </i>\n <p\n className=\"fade-in\"\n // eslint-disable-next-line react/no-danger\n dangerouslySetInnerHTML={{\n __html: lookupErrorHTML || '',\n }}\n />\n </div>\n )}\n </div>\n </>\n )}\n\n {hasLookupSucceeded && (\n <i className=\"material-icons has-text-success fade-in\">\n check_circle_outline\n </i>\n )}\n\n {!hasLookupSucceeded && !hasLookupFailed && <OnLoading small />}\n\n {isCancellable && !hasLookupSucceeded && !hasLookupFailed && (\n <div className=\"has-margin-top-5 fade-in\">\n <p>Taking longer than expected?</p>\n <button\n type=\"button\"\n className=\"button has-margin-top-8\"\n onClick={onCancelLookup}\n >\n Cancel\n </button>\n </div>\n )}\n </div>\n </div>\n </LookupNotificationContext.Provider>\n )\n}\n\nexport default function LookupNotification(props: Props) {\n if (props.element.isDataLookup || props.element.isElementLookup) {\n return <LookupNotificationComponent {...props} />\n }\n\n return <>{props.children}</>\n}\n\nasync function fetchLookup(\n formElementLookup: formService.FormElementLookupResult | undefined,\n payload: FetchLookupPayload,\n abortSignal: AbortSignal,\n): Promise<\n | SubmissionTypes.S3SubmissionData['submission']\n | FormTypes.FormElement[]\n | undefined\n> {\n if (!formElementLookup) {\n return\n }\n\n if (formElementLookup.records) {\n const elementName = payload.element.name\n const inputValue = payload.submission[elementName]\n\n const matchingRecord = formElementLookup.records.find(\n (r) =>\n (r.inputType === 'UNDEFINED' && !inputValue) ||\n (r.inputType !== 'UNDEFINED' && r.inputValue === inputValue),\n )\n\n // insert prefill values\n return matchingRecord?.preFills.reduce<\n SubmissionTypes.S3SubmissionData['submission']\n >((lookupResult, prefill) => {\n switch (prefill.type) {\n case 'TEXT':\n lookupResult[prefill.formElementName] = prefill.text\n break\n case 'NUMBER':\n lookupResult[prefill.formElementName] = prefill.number\n break\n case 'CLEAR':\n lookupResult[prefill.formElementName] = undefined\n break\n }\n return lookupResult\n }, {})\n }\n\n if (!formElementLookup.url) {\n console.log(\n 'Could not find dynamic URL or static records for form element lookup:',\n formElementLookup,\n )\n throw new Error('Could not find element lookup configuration')\n }\n\n const headers = await generateHeaders()\n console.log(\n `Attempting a ${formElementLookup.type} lookup request to:`,\n formElementLookup.url,\n )\n const response = await fetch(formElementLookup.url, {\n method: 'POST',\n headers,\n body: JSON.stringify(payload),\n signal: abortSignal,\n })\n\n const data = await response.json()\n console.log(\n 'Response from lookup to: POST',\n formElementLookup.url,\n response.status,\n data,\n )\n\n if (!response.ok) {\n Sentry.captureException(\n new Error(`Received ${response.status} status code from lookup`),\n )\n if (response.status === 400 && data && data.message) {\n throw data.message\n }\n throw new Error('Invalid response from lookup')\n }\n\n return data as FormTypes.FormElement[]\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import clsx from 'clsx';
3
- import { Radio } from '@mui/material';
3
+ import { Radio, RadioGroup } from '@mui/material';
4
4
  import FormElementOptions from '../components/renderer/FormElementOptions';
5
5
  import useFormElementOptions from '../hooks/useFormElementOptions';
6
6
  import OptionButton from './OptionButton';
@@ -18,7 +18,7 @@ function FormElementRadio({ id, element, value, onChange, conditionallyShownOpti
18
18
  const isDisplayingValidationMessage = (isDirty || displayValidationMessage) && !!validationMessage && !isLookingUp;
19
19
  return (React.createElement("div", { className: "cypress-radio-element" },
20
20
  React.createElement(FormElementLabelContainer, { className: "ob-radio", id: id, element: element, required: element.required },
21
- React.createElement(FormElementOptions, { options: element.options, conditionallyShownOptionsElement: conditionallyShownOptionsElement }, !element.buttons ? (React.createElement("div", { className: "ob-radio-container" }, filteredOptions.map((option) => (React.createElement("div", { className: "control", key: option.value },
21
+ React.createElement(FormElementOptions, { options: element.options, conditionallyShownOptionsElement: conditionallyShownOptionsElement }, !element.buttons ? (React.createElement(RadioGroup, { className: "ob-radio-container" }, filteredOptions.map((option) => (React.createElement("div", { className: "control", key: option.value },
22
22
  React.createElement("label", { className: "radio ob-radio__input-label cypress-radio-label", htmlFor: `${id}_${option.value}` },
23
23
  React.createElement(Radio, { color: "primary", className: "ob-radio__input cypress-radio-control", classes: {
24
24
  checked: 'ob-radio__input-checked',
@@ -1 +1 @@
1
- {"version":3,"file":"FormElementRadio.js","sourceRoot":"","sources":["../../src/form-elements/FormElementRadio.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAErC,OAAO,kBAAkB,MAAM,2CAA2C,CAAA;AAC1E,OAAO,qBA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I,CAChC,6BAAK,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,kBAAkB;gBAC5C,6BAAK,SAAS,EAAC,2DAA2D,IACvE,iBAAiB,CACd,CACF,CACP,CACyB,CACxB,CACP,CAAA;AACH,CAAC;AACD,eAAe,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport clsx from 'clsx'\nimport { Radio } from '@mui/material'\n\nimport FormElementOptions from '../components/renderer/FormElementOptions'\nimport useFormElementOptions from '../hooks/useFormElementOptions'\nimport { FormTypes } from '@oneblink/types'\nimport OptionButton from './OptionButton'\nimport FormElementLabelContainer from '../components/renderer/FormElementLabelContainer'\nimport {\n FormElementValueChangeHandler,\n FormElementConditionallyShownElement,\n IsDirtyProps,\n UpdateFormElementsHandler,\n} from '../types/form'\nimport { LookupNotificationContext } from '../hooks/useLookupNotification'\n\ntype Props = {\n id: string\n element: FormTypes.RadioButtonElement\n value: unknown\n onChange: FormElementValueChangeHandler<string>\n displayValidationMessage: boolean\n validationMessage: string | undefined\n conditionallyShownOptionsElement:\n | FormElementConditionallyShownElement\n | undefined\n onUpdateFormElements: UpdateFormElementsHandler\n} & IsDirtyProps\n\nfunction FormElementRadio({\n id,\n element,\n value,\n onChange,\n conditionallyShownOptionsElement,\n validationMessage,\n displayValidationMessage,\n onUpdateFormElements,\n isDirty,\n setIsDirty,\n}: Props) {\n const filteredOptions = useFormElementOptions({\n element,\n value,\n onChange,\n conditionallyShownOptionsElement,\n onUpdateFormElements,\n })\n\n const { isLookingUp } = React.useContext(LookupNotificationContext)\n const isDisplayingValidationMessage =\n (isDirty || displayValidationMessage) && !!validationMessage && !isLookingUp\n\n return (\n <div className=\"cypress-radio-element\">\n <FormElementLabelContainer\n className=\"ob-radio\"\n id={id}\n element={element}\n required={element.required}\n >\n <FormElementOptions\n options={element.options}\n conditionallyShownOptionsElement={conditionallyShownOptionsElement}\n >\n {!element.buttons ? (\n <div className=\"ob-radio-container\">\n {filteredOptions.map((option) => (\n <div className=\"control\" key={option.value}>\n <label\n className=\"radio ob-radio__input-label cypress-radio-label\"\n htmlFor={`${id}_${option.value}`}\n >\n <Radio\n color=\"primary\"\n className=\"ob-radio__input cypress-radio-control\"\n classes={{\n checked: 'ob-radio__input-checked',\n }}\n disableRipple\n value={option.value || ''}\n id={`${id}_${option.value}`}\n disabled={element.readOnly}\n checked={value === option.value}\n onChange={(e) => {\n setIsDirty()\n onChange(element, {\n value: e.target.value,\n })\n }}\n />\n {` ${option.label}`}\n </label>\n </div>\n ))}\n </div>\n ) : (\n <div className=\"buttons ob-buttons ob-buttons-radio cypress-radio-button-group\">\n {filteredOptions.map((option) => {\n const isSelected = value === option.value\n return (\n <div className=\"ob-button-radio-container\" key={option.value}>\n <OptionButton\n element={element}\n option={option}\n isSelected={isSelected}\n onClick={() => {\n setIsDirty()\n onChange(element, {\n value: option.value,\n })\n }}\n className={clsx(\n 'button ob-button ob-button__input ob-radio__button cypress-radio-button-control',\n {\n 'is-primary': isSelected,\n 'is-light': !isSelected,\n },\n )}\n />\n </div>\n )\n })}\n </div>\n )}\n </FormElementOptions>\n\n {isDisplayingValidationMessage && (\n <div role=\"alert\" className=\"has-margin-top-8\">\n <div className=\"has-text-danger ob-error__text cypress-validation-message\">\n {validationMessage}\n </div>\n </div>\n )}\n </FormElementLabelContainer>\n </div>\n )\n}\nexport default React.memo(FormElementRadio)\n"]}
1
+ {"version":3,"file":"FormElementRadio.js","sourceRoot":"","sources":["../../src/form-elements/FormElementRadio.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,kBAAkB,MAAM,2CAA2C,CAAA;AAC1E,OAAO,qBAAqB,MAAM,gCAAgC,CAAA;AAElE,OAAO,YAAY,MAAM,gBAAgB,CAAA;AACzC,OAA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BAC5C,6BAAK,SAAS,EAAC,2DAA2D,IACvE,iBAAiB,CACd,CACF,CACP,CACyB,CACxB,CACP,CAAA;AACH,CAAC;AACD,eAAe,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport clsx from 'clsx'\nimport { Radio, RadioGroup } from '@mui/material'\n\nimport FormElementOptions from '../components/renderer/FormElementOptions'\nimport useFormElementOptions from '../hooks/useFormElementOptions'\nimport { FormTypes } from '@oneblink/types'\nimport OptionButton from './OptionButton'\nimport FormElementLabelContainer from '../components/renderer/FormElementLabelContainer'\nimport {\n FormElementValueChangeHandler,\n FormElementConditionallyShownElement,\n IsDirtyProps,\n UpdateFormElementsHandler,\n} from '../types/form'\nimport { LookupNotificationContext } from '../hooks/useLookupNotification'\n\ntype Props = {\n id: string\n element: FormTypes.RadioButtonElement\n value: unknown\n onChange: FormElementValueChangeHandler<string>\n displayValidationMessage: boolean\n validationMessage: string | undefined\n conditionallyShownOptionsElement:\n | FormElementConditionallyShownElement\n | undefined\n onUpdateFormElements: UpdateFormElementsHandler\n} & IsDirtyProps\n\nfunction FormElementRadio({\n id,\n element,\n value,\n onChange,\n conditionallyShownOptionsElement,\n validationMessage,\n displayValidationMessage,\n onUpdateFormElements,\n isDirty,\n setIsDirty,\n}: Props) {\n const filteredOptions = useFormElementOptions({\n element,\n value,\n onChange,\n conditionallyShownOptionsElement,\n onUpdateFormElements,\n })\n\n const { isLookingUp } = React.useContext(LookupNotificationContext)\n const isDisplayingValidationMessage =\n (isDirty || displayValidationMessage) && !!validationMessage && !isLookingUp\n\n return (\n <div className=\"cypress-radio-element\">\n <FormElementLabelContainer\n className=\"ob-radio\"\n id={id}\n element={element}\n required={element.required}\n >\n <FormElementOptions\n options={element.options}\n conditionallyShownOptionsElement={conditionallyShownOptionsElement}\n >\n {!element.buttons ? (\n <RadioGroup className=\"ob-radio-container\">\n {filteredOptions.map((option) => (\n <div className=\"control\" key={option.value}>\n <label\n className=\"radio ob-radio__input-label cypress-radio-label\"\n htmlFor={`${id}_${option.value}`}\n >\n <Radio\n color=\"primary\"\n className=\"ob-radio__input cypress-radio-control\"\n classes={{\n checked: 'ob-radio__input-checked',\n }}\n disableRipple\n value={option.value || ''}\n id={`${id}_${option.value}`}\n disabled={element.readOnly}\n checked={value === option.value}\n onChange={(e) => {\n setIsDirty()\n onChange(element, {\n value: e.target.value,\n })\n }}\n />\n {` ${option.label}`}\n </label>\n </div>\n ))}\n </RadioGroup>\n ) : (\n <div className=\"buttons ob-buttons ob-buttons-radio cypress-radio-button-group\">\n {filteredOptions.map((option) => {\n const isSelected = value === option.value\n return (\n <div className=\"ob-button-radio-container\" key={option.value}>\n <OptionButton\n element={element}\n option={option}\n isSelected={isSelected}\n onClick={() => {\n setIsDirty()\n onChange(element, {\n value: option.value,\n })\n }}\n className={clsx(\n 'button ob-button ob-button__input ob-radio__button cypress-radio-button-control',\n {\n 'is-primary': isSelected,\n 'is-light': !isSelected,\n },\n )}\n />\n </div>\n )\n })}\n </div>\n )}\n </FormElementOptions>\n\n {isDisplayingValidationMessage && (\n <div role=\"alert\" className=\"has-margin-top-8\">\n <div className=\"has-text-danger ob-error__text cypress-validation-message\">\n {validationMessage}\n </div>\n </div>\n )}\n </FormElementLabelContainer>\n </div>\n )\n}\nexport default React.memo(FormElementRadio)\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oneblink/apps-react",
3
3
  "description": "Helper functions for OneBlink apps in ReactJS.",
4
- "version": "5.5.0-beta.4",
4
+ "version": "5.5.0-beta.6",
5
5
  "author": "OneBlink <developers@oneblink.io> (https://oneblink.io)",
6
6
  "bugs": {
7
7
  "url": "https://github.com/oneblink/apps-react/issues"