form-craft-package 1.9.4 → 1.9.6-dev.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "form-craft-package",
3
- "version": "1.9.4",
3
+ "version": "1.9.6-dev.0",
4
4
  "main": "index.ts",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -1,5 +1,5 @@
1
1
  import { Form } from 'antd'
2
- import { memo, useEffect, useMemo, useRef } from 'react'
2
+ import { memo, useEffect, useMemo, useRef, useState } from 'react'
3
3
  import SignatureCanvas from 'react-signature-canvas'
4
4
  import { FormPreservedItemKeys, TranslationTextTypeEnum } from '../../../../enums'
5
5
  import { Button_FillerPortal } from '../../../common/button'
@@ -24,6 +24,7 @@ function LayoutRenderer_Signature({
24
24
  const sigCanvasRef = useRef<SignatureCanvas>(null)
25
25
  const savedSignatureBlobName = Form.useWatch(formItem.path, formRef)
26
26
  const { isGeneratingPdf, baseServerUrl } = useFormPreservedItemValues(formRef)
27
+ const [isReady, setIsReady] = useState(false)
27
28
 
28
29
  useEffect(() => {
29
30
  if (isDisabled) sigCanvasRef.current?.off()
@@ -35,6 +36,10 @@ function LayoutRenderer_Signature({
35
36
  [formItem.path],
36
37
  )
37
38
 
39
+ useEffect(() => {
40
+ setTimeout(() => setIsReady(true), 2000)
41
+ }, [])
42
+
38
43
  return (
39
44
  <Form.Item
40
45
  name={formItem.name}
@@ -60,7 +65,11 @@ function LayoutRenderer_Signature({
60
65
  }
61
66
  labelAlign="left"
62
67
  >
63
- {isNewFormDataPage(formDataId) && !isGeneratingPdf ? (
68
+ {isNewFormDataPage(formDataId) && !isReady ? (
69
+ <div className="h-[300px] rounded-md border-2 border-[#f0f0f0] text-center bg-gray-100 flex justify-center p-2">
70
+ Loading the signature canvas...
71
+ </div>
72
+ ) : isNewFormDataPage(formDataId) && !isGeneratingPdf ? (
64
73
  <SignatureCanvas
65
74
  ref={sigCanvasRef}
66
75
  canvasProps={{
@@ -30,7 +30,7 @@ function LayoutRenderer_LoadFormData({ formContext, elementProps }: ILayoutRende
30
30
 
31
31
  const [dataList, setDataList] = useState<{ data: IFormDataListData[]; total: number }>({ data: [], total: 0 })
32
32
  const dataProjectRef = useRef<{ [key: string]: string }>({})
33
- const reportDataApiCancelFuncRef = useRef<() => void | undefined>(undefined)
33
+ const reportDataApiCancelFuncRef = useRef<() => void | undefined>()
34
34
  const formJoinsRef = useRef<IFormJoin[]>([])
35
35
  const m2mForeignKeysRef = useRef<{ currentForm: string; otherForm: string } | undefined>()
36
36
 
@@ -1,8 +1,9 @@
1
1
  import { fetchFormDataAsLookup } from '.'
2
- import { FieldElementOptionSourceEnum } from '../../enums'
2
+ import { FieldElementOptionSourceEnum, TranslationTextTypeEnum } from '../../enums'
3
3
  import { IFormDataListColumn } from '../../types'
4
4
  import client from '../../api/client'
5
5
  import { REACT_QUERY_CLIENT } from '../../constants'
6
+ import { translationStore } from '../../components/common/custom-hooks/use-translation.hook/store'
6
7
 
7
8
  export async function processOptions(options: IFormDataListColumn[]): Promise<{ [key: string]: any }> {
8
9
  const groupedRequests = new Map<string, { [key: string]: number }>()
@@ -26,7 +27,7 @@ export async function processOptions(options: IFormDataListColumn[]): Promise<{
26
27
  groupedRequests.forEach((paths, formId) => {
27
28
  const cachedConfig = REACT_QUERY_CLIENT.getQueryData(['layoutConfig', String(formId)])
28
29
 
29
- if (cachedConfig) apiCallPromises.push(Promise.resolve({ _id: '-1', Data: extractByDotPaths(paths, cachedConfig) }))
30
+ if (cachedConfig) apiCallPromises.push(Promise.resolve({ _id: formId, Data: extractByDotPaths(paths, cachedConfig) }))
30
31
  else
31
32
  apiCallPromises.push(
32
33
  client.post(`/api/form/${formId}`, { project: JSON.stringify(paths) }).then((res) => res.data),
@@ -38,7 +39,7 @@ export async function processOptions(options: IFormDataListColumn[]): Promise<{
38
39
  const finalResult: { [key: string]: any } = {}
39
40
  const dynamicApiPromises: Promise<void>[] = []
40
41
 
41
- apiResults.forEach(({ Data }) => {
42
+ apiResults.forEach(({ _id, Data }) => {
42
43
  const elements = Data?.detailsConfig?.elements
43
44
  if (!elements) return
44
45
 
@@ -50,8 +51,15 @@ export async function processOptions(options: IFormDataListColumn[]): Promise<{
50
51
  if (optionSource.type === FieldElementOptionSourceEnum.Static) {
51
52
  const optionsArray = optionSource.options
52
53
  if (Array.isArray(optionsArray)) {
53
- optionsArray.forEach((opt: { id: string; value: any }) => {
54
- finalResult[opt.id] = opt.value
54
+ optionsArray.forEach((opt: { id: string }) => {
55
+ finalResult[opt.id] = translationStore.translate(
56
+ {
57
+ key: element.key,
58
+ type: TranslationTextTypeEnum.OptionValue,
59
+ subType: opt.id,
60
+ },
61
+ Number(_id),
62
+ )
55
63
  })
56
64
  }
57
65
  } else if (optionSource.type === FieldElementOptionSourceEnum.DynamicForm) {