form-craft-package 1.11.10 → 1.11.12

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.11.10",
3
+ "version": "1.11.12",
4
4
  "main": "index.ts",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -370,7 +370,7 @@ export const TemplateLayout = ({
370
370
  return (
371
371
  <Layout className="fc-layout min-h-screen">
372
372
  <Header
373
- className="fc-header sticky top-0 z-40 flex items-center shadow-sm justify-between px-1 overflow-visible"
373
+ className="fc-header sticky top-0 z-40 flex items-center shadow-sm justify-between px-1 overflow-hidden"
374
374
  style={{ height: headerHeight, lineHeight: 'normal' }}
375
375
  >
376
376
  <div className="flex">
@@ -254,7 +254,8 @@ const handleFilterValues = async (
254
254
  let stringifiedFilter = JSON.stringify((config as IFilterCustom).config)
255
255
 
256
256
  const placeholder = isNumber || isBoolean ? `"${VALUE_REPLACEMENT_PLACEHOLDER}"` : VALUE_REPLACEMENT_PLACEHOLDER
257
- stringifiedFilter = stringifiedFilter.replaceAll(placeholder, value).replaceAll('@', '$')
257
+ const resolvedValue = !isNumber && !isBoolean ? value.replace(/\s+/g, '').split('').join('\\\\s*') : value
258
+ stringifiedFilter = stringifiedFilter.replaceAll(placeholder, resolvedValue).replaceAll('@', '$')
258
259
 
259
260
  if (value2) stringifiedFilter = stringifiedFilter.replaceAll(VALUE_REPLACEMENT_PLACEHOLDER2, value2)
260
261
 
@@ -139,12 +139,12 @@ export const useSendNotificationAction = ({
139
139
  [formTemplateReports, formId, formDataId, companyKey],
140
140
  )
141
141
 
142
- const onSendNotification = useCallback(
143
- async (
144
- notifActionProps: IButtonProps_SendNotification,
145
- newFormDataId?: string,
146
- extraAttachments: IEmail_Attachment[] = [],
147
- ) => {
142
+ const onSendNotification = useCallback(
143
+ async (
144
+ notifActionProps: IButtonProps_SendNotification,
145
+ newFormDataId?: string,
146
+ extraAttachments: IEmail_Attachment[] = [],
147
+ ) => {
148
148
  const { notificationId } = notifActionProps
149
149
 
150
150
  const { joins = [], notifications } = formNotifications
@@ -164,14 +164,14 @@ export const useSendNotificationAction = ({
164
164
 
165
165
  const hasAttachments = Array.isArray(formNotif.attachments) && formNotif.attachments.length > 0
166
166
 
167
- let formTemplateReportAttachments: IEmail_Attachment[] = []
168
- if (hasAttachments) {
169
- setDataLoadingType?.(FormLoadingModalTypeEnum.GeneratingReport)
170
- formTemplateReportAttachments = await handleTemplateReport(formNotif.attachments!, targetFormDataId)
171
- }
172
- const additionalEmailAttachments = [...formTemplateReportAttachments, ...extraAttachments]
173
-
174
- setDataLoadingType?.(FormLoadingModalTypeEnum.SendingNotification)
167
+ let formTemplateReportAttachments: IEmail_Attachment[] = []
168
+ if (hasAttachments) {
169
+ setDataLoadingType?.(FormLoadingModalTypeEnum.GeneratingReport)
170
+ formTemplateReportAttachments = await handleTemplateReport(formNotif.attachments!, targetFormDataId)
171
+ }
172
+ const additionalEmailAttachments = [...formTemplateReportAttachments, ...extraAttachments]
173
+
174
+ setDataLoadingType?.(FormLoadingModalTypeEnum.SendingNotification)
175
175
 
176
176
  try {
177
177
  const notifConfigRes = await client.get(`/api/notificationconfig/${notificationId}/data`)
@@ -180,12 +180,12 @@ export const useSendNotificationAction = ({
180
180
  const notificationRequests = await buildNotificationRequests({
181
181
  notificationId: formNotif.id,
182
182
  notificationConfig: notifConfigRes.data.data,
183
- formNotification: formNotif,
184
- replacementData: formDataRes.data,
185
- formId,
186
- fileBaseUrl,
187
- additionalEmailAttachments,
188
- })
183
+ formNotification: formNotif,
184
+ replacementData: formDataRes.data,
185
+ formId,
186
+ fileBaseUrl,
187
+ additionalEmailAttachments,
188
+ })
189
189
 
190
190
  if (!notificationRequests.length) {
191
191
  onFinal()
@@ -224,14 +224,14 @@ function LayoutRenderer_Gallery({
224
224
  <Empty description={emptyDescription || 'No pictures uploaded'} />
225
225
  )}
226
226
  </Form.Item>
227
- <GalleryUploadModal
228
- isOpen={isUploadModalOpen}
229
- formContext={formContext}
230
- formItem={formItem}
231
- elementProps={elementProps}
232
- elementKey={elementKey}
233
- textConditions={textConditions}
234
- isDisabled={isDisabled}
227
+ <GalleryUploadModal
228
+ isOpen={isUploadModalOpen}
229
+ formContext={formContext}
230
+ formItem={formItem}
231
+ elementProps={elementProps}
232
+ elementKey={elementKey}
233
+ textConditions={textConditions}
234
+ isDisabled={isDisabled}
235
235
  onDiscardSuccess={() => setIsUploadModalOpen(false)}
236
236
  onSaveSuccess={(uploadedBlobNames) => {
237
237
  formRef?.setFieldValue(formItem.path, [
@@ -1,56 +1,56 @@
1
- import client from '../../../../../api/client'
2
- import { isNewFormDataPage, resolveConditionalText } from '../../../../../functions'
3
- import { saveFile } from '../../../../../functions/forms/form'
4
- import {
5
- ButtonActionCategoryEnum,
6
- EmailAttachmentTypeEnum,
7
- TranslationTextSubTypeEnum,
8
- TranslationTextTypeEnum,
9
- } from '../../../../../enums'
10
- import { RcFile, UploadFile, UploadProps } from 'antd/es/upload'
11
- import { Form, Modal, Spin, Upload } from 'antd'
12
- import { useCallback, useEffect, useMemo, useState } from 'react'
13
- import { FaUpload } from 'react-icons/fa6'
14
- import { useSendNotificationAction } from '../1-dynamic-button/use-send-notification.hook'
15
- import { Button_FillerPortal } from '../../../../common/button'
16
- import { useNotification, useTranslation } from '../../../../common/custom-hooks'
17
- import useGetCurrentBreakpoint from '../../../../common/custom-hooks/use-window-width.hook'
18
- import { IElementBaseProps } from '..'
19
- import { IFormContext } from '../../1-row'
20
- import { IEmail_Attachment, IGalleryElementProps } from '../../../../../types'
21
-
22
- export default function GalleryUploadModal({
23
- isOpen,
24
- formContext,
25
- formItem,
26
- elementProps,
27
- elementKey,
28
- textConditions,
29
- onDiscardSuccess,
30
- onSaveSuccess,
31
- }: {
32
- isOpen: boolean
33
- formContext: IFormContext
34
- elementProps: IGalleryElementProps
35
- onDiscardSuccess: () => void
36
- onSaveSuccess: (blobNames: string[]) => void
37
- } & IElementBaseProps) {
1
+ import client from '../../../../../api/client'
2
+ import { isNewFormDataPage, resolveConditionalText } from '../../../../../functions'
3
+ import { saveFile } from '../../../../../functions/forms/form'
4
+ import {
5
+ ButtonActionCategoryEnum,
6
+ EmailAttachmentTypeEnum,
7
+ TranslationTextSubTypeEnum,
8
+ TranslationTextTypeEnum,
9
+ } from '../../../../../enums'
10
+ import { RcFile, UploadFile, UploadProps } from 'antd/es/upload'
11
+ import { Form, Modal, Spin, Upload } from 'antd'
12
+ import { useCallback, useEffect, useMemo, useState } from 'react'
13
+ import { FaUpload } from 'react-icons/fa6'
14
+ import { useSendNotificationAction } from '../1-dynamic-button/use-send-notification.hook'
15
+ import { Button_FillerPortal } from '../../../../common/button'
16
+ import { useNotification, useTranslation } from '../../../../common/custom-hooks'
17
+ import useGetCurrentBreakpoint from '../../../../common/custom-hooks/use-window-width.hook'
18
+ import { IElementBaseProps } from '..'
19
+ import { IFormContext } from '../../1-row'
20
+ import { IEmail_Attachment, IGalleryElementProps } from '../../../../../types'
21
+
22
+ export default function GalleryUploadModal({
23
+ isOpen,
24
+ formContext,
25
+ formItem,
26
+ elementProps,
27
+ elementKey,
28
+ textConditions,
29
+ onDiscardSuccess,
30
+ onSaveSuccess,
31
+ }: {
32
+ isOpen: boolean
33
+ formContext: IFormContext
34
+ elementProps: IGalleryElementProps
35
+ onDiscardSuccess: () => void
36
+ onSaveSuccess: (blobNames: string[]) => void
37
+ } & IElementBaseProps) {
38
38
  const { formRef, formDataId, companyKey, formId } = formContext
39
39
  const { t } = useTranslation(formId)
40
40
  const currentBreakpoint = useGetCurrentBreakpoint()
41
41
  const { warningModal } = useNotification()
42
42
 
43
43
  const [uploadedFiles, setUploadedFiles] = useState<UploadFile[]>([])
44
- const [isUploadLoading, setIsUploadLoading] = useState(false)
45
- const [isSaving, setIsSaving] = useState(false)
46
- const [isDiscarding, setIsDiscarding] = useState(false)
47
- const [isSendingNotification, setIsSendingNotification] = useState(false)
48
- const onSendNotification = useSendNotificationAction({
49
- ...formContext,
50
- onSuccess: () => {},
51
- onError: () => {},
52
- onFinal: () => {},
53
- })
44
+ const [isUploadLoading, setIsUploadLoading] = useState(false)
45
+ const [isSaving, setIsSaving] = useState(false)
46
+ const [isDiscarding, setIsDiscarding] = useState(false)
47
+ const [isSendingNotification, setIsSendingNotification] = useState(false)
48
+ const onSendNotification = useSendNotificationAction({
49
+ ...formContext,
50
+ onSuccess: () => {},
51
+ onError: () => {},
52
+ onFinal: () => {},
53
+ })
54
54
 
55
55
  const allValues = Form.useWatch([], { form: formRef, preserve: true })
56
56
 
@@ -139,11 +139,11 @@ export default function GalleryUploadModal({
139
139
  }
140
140
  }, [onDiscardSuccess, uploadedBlobNames])
141
141
 
142
- const saveUploadedFiles = useCallback(async () => {
143
- if (!formId || !formDataId || isNewFormDataPage(formDataId)) return
144
-
145
- setIsSaving(true)
146
- try {
142
+ const saveUploadedFiles = useCallback(async () => {
143
+ if (!formId || !formDataId || isNewFormDataPage(formDataId)) return
144
+
145
+ setIsSaving(true)
146
+ try {
147
147
  const formDataRes = await client.get(`/api/formdata/${formId}/${formDataId}`)
148
148
  const parsedData = JSON.parse(formDataRes.data.data)
149
149
  const fieldPath = Array.isArray(formItem.path) ? formItem.path : [formItem.path]
@@ -156,65 +156,65 @@ export default function GalleryUploadModal({
156
156
  ...(Array.isArray(existingBlobNames) ? existingBlobNames : []),
157
157
  ...uploadedBlobNames,
158
158
  ]
159
- const res = await client.put(`/api/formdata/${formId}/${formDataId}`, {
160
- name: formDataRes.data.name,
161
- version: formDataRes.data.version,
162
- private: formDataRes.data.private,
163
- data: JSON.stringify(parsedData),
164
- })
165
- if (res.status === 200) {
166
- const shouldSendNotification = elementProps.sendNotification && !!elementProps.notificationId
167
- const savedBlobNames = [...uploadedBlobNames]
168
-
169
- if (shouldSendNotification) {
170
- const extraAttachments: IEmail_Attachment[] = uploadedFiles
171
- .map((file) => {
172
- const blobName =
173
- typeof file.response === 'object' && file.response
174
- ? (file.response as { blobName?: string }).blobName
175
- : undefined
176
- if (!blobName) return null
177
-
178
- return {
179
- blobName,
180
- fileName: file.name,
181
- type: EmailAttachmentTypeEnum.Image,
182
- }
183
- })
184
- .filter((attachment): attachment is IEmail_Attachment => !!attachment)
185
-
186
- setIsSendingNotification(true)
187
- try {
188
- await onSendNotification(
189
- {
190
- category: ButtonActionCategoryEnum.SendNotification,
191
- notificationId: elementProps.notificationId!,
192
- },
193
- formDataId,
194
- extraAttachments,
195
- )
196
- } finally {
197
- setIsSendingNotification(false)
198
- }
199
- }
200
-
201
- setUploadedFiles([])
202
- onSaveSuccess(savedBlobNames)
203
- }
204
- } finally {
205
- setIsSaving(false)
206
- }
207
- }, [
208
- elementProps.notificationId,
209
- elementProps.sendNotification,
210
- formDataId,
211
- formId,
212
- formItem.path,
213
- onSaveSuccess,
214
- onSendNotification,
215
- uploadedFiles,
216
- uploadedBlobNames,
217
- ])
159
+ const res = await client.put(`/api/formdata/${formId}/${formDataId}`, {
160
+ name: formDataRes.data.name,
161
+ version: formDataRes.data.version,
162
+ private: formDataRes.data.private,
163
+ data: JSON.stringify(parsedData),
164
+ })
165
+ if (res.status === 200) {
166
+ const shouldSendNotification = elementProps.sendNotification && !!elementProps.notificationId
167
+ const savedBlobNames = [...uploadedBlobNames]
168
+
169
+ if (shouldSendNotification) {
170
+ const extraAttachments: IEmail_Attachment[] = uploadedFiles
171
+ .map((file) => {
172
+ const blobName =
173
+ typeof file.response === 'object' && file.response
174
+ ? (file.response as { blobName?: string }).blobName
175
+ : undefined
176
+ if (!blobName) return null
177
+
178
+ return {
179
+ blobName,
180
+ fileName: file.name,
181
+ type: EmailAttachmentTypeEnum.Image,
182
+ }
183
+ })
184
+ .filter((attachment): attachment is IEmail_Attachment => !!attachment)
185
+
186
+ setIsSendingNotification(true)
187
+ try {
188
+ await onSendNotification(
189
+ {
190
+ category: ButtonActionCategoryEnum.SendNotification,
191
+ notificationId: elementProps.notificationId!,
192
+ },
193
+ formDataId,
194
+ extraAttachments,
195
+ )
196
+ } finally {
197
+ setIsSendingNotification(false)
198
+ }
199
+ }
200
+
201
+ setUploadedFiles([])
202
+ onSaveSuccess(savedBlobNames)
203
+ }
204
+ } finally {
205
+ setIsSaving(false)
206
+ }
207
+ }, [
208
+ elementProps.notificationId,
209
+ elementProps.sendNotification,
210
+ formDataId,
211
+ formId,
212
+ formItem.path,
213
+ onSaveSuccess,
214
+ onSendNotification,
215
+ uploadedFiles,
216
+ uploadedBlobNames,
217
+ ])
218
218
 
219
219
  return (
220
220
  <Modal
@@ -225,29 +225,29 @@ export default function GalleryUploadModal({
225
225
  title={title || 'Upload pictures'}
226
226
  footer={
227
227
  <div className="flex justify-between">
228
- <Button_FillerPortal
229
- outline
230
- disabled={isUploadLoading || isSendingNotification}
231
- loading={isDiscarding}
232
- onClick={discardUploadedFiles}
233
- >
234
- {discardText || 'Discard & Close'}
235
- </Button_FillerPortal>
236
- <Button_FillerPortal
237
- primary
238
- disabled={isUploadLoading || isDiscarding || isSendingNotification}
239
- loading={isSaving || isSendingNotification}
240
- onClick={saveUploadedFiles}
241
- >
242
- {saveText || 'Save Pictures'}
243
- </Button_FillerPortal>
244
- </div>
245
- }
246
- >
247
- <Spin spinning={isUploadLoading || isSendingNotification}>
248
- <Upload.Dragger {...uploadProps} fileList={uploadedFiles}>
249
- <div className="flex flex-col items-center">
250
- <FaUpload size={24} className="text-primary" />
228
+ <Button_FillerPortal
229
+ outline
230
+ disabled={isUploadLoading || isSendingNotification}
231
+ loading={isDiscarding}
232
+ onClick={discardUploadedFiles}
233
+ >
234
+ {discardText || 'Discard & Close'}
235
+ </Button_FillerPortal>
236
+ <Button_FillerPortal
237
+ primary
238
+ disabled={isUploadLoading || isDiscarding || isSendingNotification}
239
+ loading={isSaving || isSendingNotification}
240
+ onClick={saveUploadedFiles}
241
+ >
242
+ {saveText || 'Save Pictures'}
243
+ </Button_FillerPortal>
244
+ </div>
245
+ }
246
+ >
247
+ <Spin spinning={isUploadLoading || isSendingNotification}>
248
+ <Upload.Dragger {...uploadProps} fileList={uploadedFiles}>
249
+ <div className="flex flex-col items-center">
250
+ <FaUpload size={24} className="text-primary" />
251
251
  <span className="font-semibold mt-2 text-secondary">
252
252
  {text || 'Click or drag image files to this area'}
253
253
  </span>
@@ -186,14 +186,14 @@ export interface IGalleryElement extends BaseFormLayoutElement {
186
186
  elementType: ElementTypeEnum.Gallery
187
187
  props: IGalleryElementProps
188
188
  }
189
- export interface IGalleryElementProps {
190
- hasNoLabel?: boolean
191
- grid?: Partial<Record<DeviceBreakpointEnum, IGalleryElementGridConfig | null>>
192
- uploadButtonConditions?: IFormLayoutElementConditions
193
- deleteButtonConditions?: IFormLayoutElementConditions
194
- sendNotification?: boolean
195
- notificationId?: number
196
- }
189
+ export interface IGalleryElementProps {
190
+ hasNoLabel?: boolean
191
+ grid?: Partial<Record<DeviceBreakpointEnum, IGalleryElementGridConfig | null>>
192
+ uploadButtonConditions?: IFormLayoutElementConditions
193
+ deleteButtonConditions?: IFormLayoutElementConditions
194
+ sendNotification?: boolean
195
+ notificationId?: number
196
+ }
197
197
  export interface IGalleryElementGridConfig {
198
198
  count?: number | null
199
199
  row?: number | null
@@ -1,7 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(xargs grep:*)"
5
- ]
6
- }
7
- }