lanceJiang 1 рік тому
батько
коміт
582fdad8e2

+ 5 - 4
src/components/packages/utils/device.js

@@ -1,4 +1,5 @@
-const isPc = () => !window.navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)
-export {
-  isPc
-}
+const isPc = () =>
+	!window.navigator.userAgent.match(
+		/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
+	)
+export { isPc }

+ 248 - 246
src/components/packages/utils/field.js

@@ -2,277 +2,279 @@ import _ from 'lodash-es'
 import { nanoid } from './nanoid'
 const fieldsRe = /^(input|textarea|number|radio|checkbox|select|time|date|rate|switch|slider|html|cascader|uploadfile|signature|region|subform)$/
 const deepTraversal = (node, fn) => {
-  fn(node)
-  const nodes = node.type === 'subform' ? node.list[0] : (node.list || node.rows || node.columns || node.children || [])
-  nodes.forEach(e => {
-    deepTraversal(e, fn)
-  })
+	fn(node)
+	const nodes = node.type === 'subform' ? node.list[0] : node.list || node.rows || node.columns || node.children || []
+	nodes.forEach(e => {
+		deepTraversal(e, fn)
+	})
 }
 const wrapElement = (element, fn) => {
-  const result = element
-  deepTraversal(result, (node) => {
-    if (Array.isArray(node)) return false
-    if (!node.style) {
-      node.style = {}
-    }
-    if (!node.id) {
-      // node.id = nanoid()
+	const result = element
+	deepTraversal(result, node => {
+		if (Array.isArray(node)) return false
+		if (!node.style) {
+			node.style = {}
+		}
+		if (!node.id) {
+			// node.id = nanoid()
 			node.id = new Date().getTime()
-    }
-    if (!node.key) {
-      node.key = `${node.type}${node.id}`
-    }
-    if (/^(grid|tabs|collapse|table|divider)$/.test(node.type)) {
-      node.style = {
-        width: '100%'
-      }
-    }
-    if (checkIsField(node)) {
-      node.style = {
-        width: {
-          pc: '100%',
-          mobile: '100%'
-        }
-      }
-    }
-    if (/^(tabs)$/.test(node.type)) {
-      node.columns = new Array(3).fill('').map((e, index) => {
-        const data = renderFieldData('tabsCol')
-        data.label = `Tab ${index + 1}`
-        data.options = {}
-        return data
-      })
-    }
-    if (/^(collapse)$/.test(node.type)) {
-      node.columns = new Array(3).fill('').map((e, index) => {
-        const data = renderFieldData('collapseCol')
-        data.label = `Tab ${index + 1}`
-        data.options = {}
-        return data
-      })
-    }
-    fn && fn(node)
-  })
-  return result
+		}
+		if (!node.key) {
+			node.key = `${node.type}${node.id}`
+		}
+		if (/^(grid|tabs|collapse|table|divider)$/.test(node.type)) {
+			node.style = {
+				width: '100%'
+			}
+		}
+		if (checkIsField(node)) {
+			node.style = {
+				width: {
+					pc: '100%',
+					mobile: '100%'
+				}
+			}
+		}
+		if (/^(tabs)$/.test(node.type)) {
+			node.columns = new Array(3).fill('').map((e, index) => {
+				const data = renderFieldData('tabsCol')
+				data.label = `Tab ${index + 1}`
+				data.options = {}
+				return data
+			})
+		}
+		if (/^(collapse)$/.test(node.type)) {
+			node.columns = new Array(3).fill('').map((e, index) => {
+				const data = renderFieldData('collapseCol')
+				data.label = `Tab ${index + 1}`
+				data.options = {}
+				return data
+			})
+		}
+		fn && fn(node)
+	})
+	return result
 }
-const renderFieldData = (type) => {
-  const result = {
-    id: nanoid(),
-    type,
-    label: '',
-    list: [],
-    style: {}
-  }
-  return result
+const renderFieldData = type => {
+	const result = {
+		id: nanoid(),
+		type,
+		label: '',
+		list: [],
+		style: {}
+	}
+	return result
 }
 const excludes = ['grid', 'col', 'table', 'tr', 'td', 'tabs', 'tabsCol', 'collapse', 'collapseCol', 'divider', 'inline']
 const flatNodes = (nodes, excludes, fn, excludesFn) => {
-  return nodes.reduce((res, node, currentIndex) => {
-    if (excludes.indexOf(node.type) === -1) {
-      res.push(node)
-      fn && fn(nodes, node, currentIndex)
-    } else {
-      excludesFn && excludesFn(nodes, node, currentIndex)
-    }
-    const children = node.type === 'subform' ? node.list[0] : (node.list || node.rows || node.columns || node.children || [])
-    res = res.concat(flatNodes(children, excludes, fn, excludesFn))
-    return res
-  }, [])
+	return nodes.reduce((res, node, currentIndex) => {
+		if (excludes.indexOf(node.type) === -1) {
+			res.push(node)
+			fn && fn(nodes, node, currentIndex)
+		} else {
+			excludesFn && excludesFn(nodes, node, currentIndex)
+		}
+		const children = node.type === 'subform' ? node.list[0] : node.list || node.rows || node.columns || node.children || []
+		res = res.concat(flatNodes(children, excludes, fn, excludesFn))
+		return res
+	}, [])
 }
-const getAllFields = (store) => flatNodes(store, excludes)
-const pickfields = (list) => {
-  return flatNodes(list, excludes)
+const getAllFields = store => flatNodes(store, excludes)
+const pickfields = list => {
+	return flatNodes(list, excludes)
 }
-const processField = (list) => flatNodes(list, excludes, (nodes, node, currentIndex) => {
-  nodes[currentIndex] = node.id
-})
-const disassemblyData1 = (data) => {
-  const result = {
-    list: data.list,
-    config: data.config,
-    fields: processField(data.list),
-    data: data.data,
-    logic: data.logic
-  }
-  return result
+const processField = list =>
+	flatNodes(list, excludes, (nodes, node, currentIndex) => {
+		nodes[currentIndex] = node.id
+	})
+const disassemblyData1 = data => {
+	const result = {
+		list: data.list,
+		config: data.config,
+		fields: processField(data.list),
+		data: data.data,
+		logic: data.logic
+	}
+	return result
 }
-const combinationData1 = (data) => {
-  const result = {
-    list: data.list,
-    config: data.config,
-    data: data.data,
-    fields: data.fields,
-    logic: data.logic
-  }
-  const fn = (nodes, node, currentIndex) => {
-    const cur = _.find(data.fields, { id: node })
-    if (!_.isEmpty(cur)) {
-      if (cur.type === 'subform') {
-        flatNodes(cur.list[0], excludes, fn)
-      }
-      nodes[currentIndex] = cur
-    }
-  }
-  flatNodes(data.list, excludes, fn)
-  return result
+const combinationData1 = data => {
+	const result = {
+		list: data.list,
+		config: data.config,
+		data: data.data,
+		fields: data.fields,
+		logic: data.logic
+	}
+	const fn = (nodes, node, currentIndex) => {
+		const cur = _.find(data.fields, { id: node })
+		if (!_.isEmpty(cur)) {
+			if (cur.type === 'subform') {
+				flatNodes(cur.list[0], excludes, fn)
+			}
+			nodes[currentIndex] = cur
+		}
+	}
+	flatNodes(data.list, excludes, fn)
+	return result
 }
 const combinationData2 = (list, fields) => {
-  const fn = (nodes, node, currentIndex) => {
-    const cur = _.find(fields, { id: node })
-    if (!_.isEmpty(cur)) {
-      if (cur.type === 'subform') {
-        flatNodes(cur.list[0], excludes, fn)
-      }
-      nodes[currentIndex] = cur
-    }
-  }
-  flatNodes(list, excludes, fn)
+	const fn = (nodes, node, currentIndex) => {
+		const cur = _.find(fields, { id: node })
+		if (!_.isEmpty(cur)) {
+			if (cur.type === 'subform') {
+				flatNodes(cur.list[0], excludes, fn)
+			}
+			nodes[currentIndex] = cur
+		}
+	}
+	flatNodes(list, excludes, fn)
 }
 const repairLayout = (layout, fields) => {
-  flatNodes(layout, excludes, (nodes, node, currentIndex) => {
-    if (_.isString(node)) {
-      if (!_.isEmpty(_.find(fields, { id: node }))) {
-        nodes.splice(currentIndex, 1)
-      }
-    }
-  })
-  const temporary = []
-  flatNodes(layout, excludes, null, (nodes, node, currentIndex) => {
-    if (node.type === 'inline') {
-      if (!node.columns.length) {
-        temporary.unshift({
-          nodes,
-          currentIndex
-        })
-      }
-    }
-  })
-  temporary.forEach(e => {
-    e.nodes.splice(e.currentIndex, 1)
-  })
+	flatNodes(layout, excludes, (nodes, node, currentIndex) => {
+		if (_.isString(node)) {
+			if (!_.isEmpty(_.find(fields, { id: node }))) {
+				nodes.splice(currentIndex, 1)
+			}
+		}
+	})
+	const temporary = []
+	flatNodes(layout, excludes, null, (nodes, node, currentIndex) => {
+		if (node.type === 'inline') {
+			if (!node.columns.length) {
+				temporary.unshift({
+					nodes,
+					currentIndex
+				})
+			}
+		}
+	})
+	temporary.forEach(e => {
+		e.nodes.splice(e.currentIndex, 1)
+	})
 }
-const disassemblyData2 = (list) => {
-  flatNodes(list, excludes, (nodes, node, currentIndex) => {
-    nodes[currentIndex] = node.id && node.id
-  })
+const disassemblyData2 = list => {
+	flatNodes(list, excludes, (nodes, node, currentIndex) => {
+		nodes[currentIndex] = node.id && node.id
+	})
 }
-const checkIslineChildren = (node) => node.context.parent.type === 'inline'
-const checkIsField = (node) => fieldsRe.test(node.type)
+const checkIslineChildren = node => node.context.parent.type === 'inline'
+const checkIsField = node => fieldsRe.test(node.type)
 const calculateAverage = (count, total = 100) => {
-  const base = Number((total / count).toFixed(2))
-  const result = []
-  for (let i = 0; i < count; i++) {
-    // result.push(base + (i < rest ? 1 : 0))
-    result.push(base)
-  }
-  return result
+	const base = Number((total / count).toFixed(2))
+	const result = []
+	for (let i = 0; i < count; i++) {
+		// result.push(base + (i < rest ? 1 : 0))
+		result.push(base)
+	}
+	return result
 }
 const syncWidthByPlatform = (node, platform, syncFullplatform = false, value) => {
-  // debugger
-  const isArray = _.isArray(node)
-  if (!isArray) {
-    if (_.isObject(node.style.width)) {
-      if (syncFullplatform) {
-        node.style.width.pc = node.style.width.mobile = value + '%'
-      } else {
-        node.style.width[platform] = value + '%'
-      }
-    } else {
-      node.style.width = value + '%'
-    }
-  }
-  const otherNodes = isArray ? node : node.context.parent.columns.filter(e => e !== node)
-  const averageWidths = calculateAverage(otherNodes.length, isArray ? 100 : 100 - value)
-  otherNodes.forEach((node, index) => {
-    const isFieldWidth = _.isObject(node.style.width)
-    if (isFieldWidth) {
-      if (syncFullplatform) {
-        node.style.width.pc = node.style.width.mobile = averageWidths[index] + '%'
-      } else {
-        node.style.width[platform] = averageWidths[index] + '%'
-      }
-    } else {
-      node.style.width = averageWidths[index] + '%'
-    }
-  })
+	// debugger
+	const isArray = _.isArray(node)
+	if (!isArray) {
+		if (_.isObject(node.style.width)) {
+			if (syncFullplatform) {
+				node.style.width.pc = node.style.width.mobile = value + '%'
+			} else {
+				node.style.width[platform] = value + '%'
+			}
+		} else {
+			node.style.width = value + '%'
+		}
+	}
+	const otherNodes = isArray ? node : node.context.parent.columns.filter(e => e !== node)
+	const averageWidths = calculateAverage(otherNodes.length, isArray ? 100 : 100 - value)
+	otherNodes.forEach((node, index) => {
+		const isFieldWidth = _.isObject(node.style.width)
+		if (isFieldWidth) {
+			if (syncFullplatform) {
+				node.style.width.pc = node.style.width.mobile = averageWidths[index] + '%'
+			} else {
+				node.style.width[platform] = averageWidths[index] + '%'
+			}
+		} else {
+			node.style.width = averageWidths[index] + '%'
+		}
+	})
 }
-const transferLabelPath = (node) => {
-  const inputTypeFlag = node.type === 'input' // input框
-  const selectTypeFlag = node.type === 'select' // select框
-  const cascaderTypeFlag = node.type === 'cascader' // cascader
-  let defaultFields = ''
-  if (inputTypeFlag || selectTypeFlag || cascaderTypeFlag) {
-    defaultFields = `${node.type}.${node.options.renderType - 1}`
-  } else {
-    defaultFields = `${node.type}`
-  }
-  return `er.fields.${defaultFields}`
+const transferLabelPath = node => {
+	const inputTypeFlag = node.type === 'input' // input框
+	const selectTypeFlag = node.type === 'select' // select框
+	const cascaderTypeFlag = node.type === 'cascader' // cascader
+	let defaultFields = ''
+	if (inputTypeFlag || selectTypeFlag || cascaderTypeFlag) {
+		defaultFields = `${node.type}.${node.options.renderType - 1}`
+	} else {
+		defaultFields = `${node.type}`
+	}
+	return `er.fields.${defaultFields}`
 }
 const fieldLabel = (t, node) => t(transferLabelPath(node))
 const transferData = (lang, path, locale, options = {}) => {
-  let result = ''
-  if (_.isEmpty(options)) {
-    result = _.get(locale[lang], path, '')
-  } else {
-    result = _.template(_.get(locale[lang], path, ''))(options)
-  }
-  return result
+	let result = ''
+	if (_.isEmpty(options)) {
+		result = _.get(locale[lang], path, '')
+	} else {
+		result = _.template(_.get(locale[lang], path, ''))(options)
+	}
+	return result
 }
-const isNull = (e) => e === '' || e === null || e === undefined
-const checkIsInSubform = (node) => {
-  if (!node) return false
-  let result = false
-  let parent = node.context.parent
-  while (parent && !result) {
-    if (parent.type === 'subform') {
-      result = true
-    }
-    parent = parent.context?.parent
-  }
-  return result
+const isNull = e => e === '' || e === null || e === undefined
+const checkIsInSubform = node => {
+	if (!node) return false
+	let result = false
+	let parent = node.context.parent
+	while (parent && !result) {
+		if (parent.type === 'subform') {
+			result = true
+		}
+		parent = parent.context?.parent
+	}
+	return result
 }
-const getSubFormValues = (subform) => subform.list.map(e => {
-  const cur = {}
-  const children = []
-  e.forEach(e => {
-    e.columns.forEach(e => {
-      children.push(e)
-    })
-  })
-  children.forEach(e => {
-    cur[e.key] = e.options.defaultValue
-  })
-  return cur
-})
-const findSubFormAllFields = (subform) => {
-  const result = []
-  subform.list.forEach(e => {
-    e.forEach(e => {
-      result.push(...e.columns)
-    })
-  })
-  return result
+const getSubFormValues = subform =>
+	subform.list.map(e => {
+		const cur = {}
+		const children = []
+		e.forEach(e => {
+			e.columns.forEach(e => {
+				children.push(e)
+			})
+		})
+		children.forEach(e => {
+			cur[e.key] = e.options.defaultValue
+		})
+		return cur
+	})
+const findSubFormAllFields = subform => {
+	const result = []
+	subform.list.forEach(e => {
+		e.forEach(e => {
+			result.push(...e.columns)
+		})
+	})
+	return result
 }
 export {
-  syncWidthByPlatform,
-  wrapElement,
-  deepTraversal,
-  renderFieldData,
-  getAllFields,
-  disassemblyData1,
-  combinationData1,
-  disassemblyData2,
-  combinationData2,
-  checkIslineChildren,
-  checkIsField,
-  pickfields,
-  fieldLabel,
-  transferData,
-  transferLabelPath,
-  isNull,
-  repairLayout,
-  checkIsInSubform,
-  getSubFormValues,
-  findSubFormAllFields,
-  processField
+	syncWidthByPlatform,
+	wrapElement,
+	deepTraversal,
+	renderFieldData,
+	getAllFields,
+	disassemblyData1,
+	combinationData1,
+	disassemblyData2,
+	combinationData2,
+	checkIslineChildren,
+	checkIsField,
+	pickfields,
+	fieldLabel,
+	transferData,
+	transferLabelPath,
+	isNull,
+	repairLayout,
+	checkIsInSubform,
+	getSubFormValues,
+	findSubFormAllFields,
+	processField
 }

+ 25 - 28
src/components/packages/utils/fileData.js

@@ -1,31 +1,28 @@
 const dataURLtoFile = (dataurl, filename) => {
-  const arr = dataurl.split(',')
-  const mime = arr[0].match(/:(.*?);/)[1]
-  const bstr = atob(arr[1])
-  let n = bstr.length
-  const u8arr = new Uint8Array(n)
-  while (n--) {
-    u8arr[n] = bstr.charCodeAt(n)
-  }
-  return new File([u8arr], filename, { type: mime })
+	const arr = dataurl.split(',')
+	const mime = arr[0].match(/:(.*?);/)[1]
+	const bstr = atob(arr[1])
+	let n = bstr.length
+	const u8arr = new Uint8Array(n)
+	while (n--) {
+		u8arr[n] = bstr.charCodeAt(n)
+	}
+	return new File([u8arr], filename, { type: mime })
 }
-const filetoDataURL = (dataurl) => {
-  return new Promise((resolve, reject) => {
-    const image = new Image()
-    image.src = dataurl
-    image.onload = function () {
-      const canvas = document.createElement('canvas')
-      canvas.width = image.width
-      canvas.height = image.height
-      const ctx = canvas.getContext('2d')
-      ctx.drawImage(image, 0, 0, image.width, image.height)
-      const ext = image.src.substring(image.src.lastIndexOf('.') + 1).toLowerCase()
-      const dataURL = canvas.toDataURL('image/' + ext)
-      resolve(dataURL)
-    }
-  })
-}
-export {
-  dataURLtoFile,
-  filetoDataURL
+const filetoDataURL = dataurl => {
+	return new Promise((resolve, reject) => {
+		const image = new Image()
+		image.src = dataurl
+		image.onload = function () {
+			const canvas = document.createElement('canvas')
+			canvas.width = image.width
+			canvas.height = image.height
+			const ctx = canvas.getContext('2d')
+			ctx.drawImage(image, 0, 0, image.width, image.height)
+			const ext = image.src.substring(image.src.lastIndexOf('.') + 1).toLowerCase()
+			const dataURL = canvas.toDataURL('image/' + ext)
+			resolve(dataURL)
+		}
+	})
 }
+export { dataURLtoFile, filetoDataURL }

+ 20 - 20
src/components/packages/utils/generateOptions.js

@@ -1,26 +1,26 @@
 import { nanoid } from './nanoid'
 import { globalConfig } from '@ER/formEditor/componentsConfig.js'
 import _ from 'lodash-es'
-export const generateOptions = (len) => {
-  const result = []
-  while (len--) {
-    result.push({
-      label: 'Option',
-      value: nanoid()
-    })
-  }
-  return result
+export const generateOptions = len => {
+	const result = []
+	while (len--) {
+		result.push({
+			label: 'Option',
+			value: nanoid()
+		})
+	}
+	return result
 }
 export const generateData = (layoutType = 1) => {
-  const result = {
-    config: _.cloneDeep(globalConfig)
-  }
-  result.logic = result.data = {}
-  if (layoutType === 1) {
-    result.list = []
-  }
-  if (layoutType === 2) {
-    result.layout = []
-  }
-  return result
+	const result = {
+		config: _.cloneDeep(globalConfig)
+	}
+	result.logic = result.data = {}
+	if (layoutType === 1) {
+		result.list = []
+	}
+	if (layoutType === 2) {
+		result.layout = []
+	}
+	return result
 }

+ 4 - 4
src/components/packages/utils/index.js

@@ -2,10 +2,10 @@ import _ from 'lodash-es'
 const importModules = import.meta.glob('./*.js', { eager: true })
 const modules = {}
 _.forIn(importModules, (func, path) => {
-  Object.keys(func).forEach((key) => {
-    modules[key] = func[key]
-  })
+	Object.keys(func).forEach(key => {
+		modules[key] = func[key]
+	})
 })
 export default {
-  ...modules
+	...modules
 }

+ 42 - 42
src/components/packages/utils/logic.js

@@ -1,48 +1,48 @@
 import _ from 'lodash-es'
 export const checkIdExistInLogic = (fieldId, logic) => {
-  return new RegExp(`"${fieldId}"`).test(JSON.stringify(logic))
+	return new RegExp(`"${fieldId}"`).test(JSON.stringify(logic))
 }
 export const removeLogicDataByid = (fieldId, logic) => {
-  for (const rules of Object.values(logic)) {
-    for (let i0 = 0; i0 < rules.length; i0++) {
-      const conditions = _.get(rules[i0], 'ifRules.filters[0].conditions', [])
-      for (let i1 = 0; i1 < conditions.length; i1++) {
-        if (conditions[i1].property === fieldId) {
-          conditions.splice(i1--, 1)
-        }
-      }
-      if (!conditions.length) {
-        rules.splice(i0--, 1)
-      }
-    }
-  }
-  for (const key in logic) {
-    if (!logic[key].length) {
-      delete logic[key]
-    }
-  }
+	for (const rules of Object.values(logic)) {
+		for (let i0 = 0; i0 < rules.length; i0++) {
+			const conditions = _.get(rules[i0], 'ifRules.filters[0].conditions', [])
+			for (let i1 = 0; i1 < conditions.length; i1++) {
+				if (conditions[i1].property === fieldId) {
+					conditions.splice(i1--, 1)
+				}
+			}
+			if (!conditions.length) {
+				rules.splice(i0--, 1)
+			}
+		}
+	}
+	for (const key in logic) {
+		if (!logic[key].length) {
+			delete logic[key]
+		}
+	}
 
-  for (const rules of Object.values(logic)) {
-    for (let i0 = 0; i0 < rules.length; i0++) {
-      const conditions = _.get(rules[i0], 'thenRules.filters[0].conditions', [])
-      for (let i1 = 0; i1 < conditions.length; i1++) {
-        for (let i2 = 0; i2 < conditions[i1].value.length; i2++) {
-          if (conditions[i1].value[i2] === fieldId) {
-            conditions[i1].value.splice(i2--, 1)
-          }
-        }
-        if (!conditions[i1].value.length) {
-          conditions.splice(i1--, 1)
-        }
-      }
-      if (!conditions.length) {
-        rules.splice(i0--, 1)
-      }
-    }
-  }
-  for (const key in logic) {
-    if (!logic[key].length) {
-      delete logic[key]
-    }
-  }
+	for (const rules of Object.values(logic)) {
+		for (let i0 = 0; i0 < rules.length; i0++) {
+			const conditions = _.get(rules[i0], 'thenRules.filters[0].conditions', [])
+			for (let i1 = 0; i1 < conditions.length; i1++) {
+				for (let i2 = 0; i2 < conditions[i1].value.length; i2++) {
+					if (conditions[i1].value[i2] === fieldId) {
+						conditions[i1].value.splice(i2--, 1)
+					}
+				}
+				if (!conditions[i1].value.length) {
+					conditions.splice(i1--, 1)
+				}
+			}
+			if (!conditions.length) {
+				rules.splice(i0--, 1)
+			}
+		}
+	}
+	for (const key in logic) {
+		if (!logic[key].length) {
+			delete logic[key]
+		}
+	}
 }

+ 2 - 4
src/components/packages/utils/nanoid.js

@@ -1,5 +1,3 @@
 import { nanoid as nanoidAlias } from 'nanoid'
-const nanoid = () => import.meta.env.MODE === 'test' && import.meta.env.TESTIDTYPE !== 'nanoid' ? '{{test-id-nanoid}}' : nanoidAlias()
-export {
-  nanoid
-}
+const nanoid = () => (import.meta.env.MODE === 'test' && import.meta.env.TESTIDTYPE !== 'nanoid' ? '{{test-id-nanoid}}' : nanoidAlias())
+export { nanoid }

+ 15 - 20
src/components/packages/utils/test.js

@@ -1,23 +1,18 @@
 const addTestId = (id, type = 'attr') => {
-  let result = ''
-  if (import.meta.env.MODE === 'test') {
-    if (type === 'attr') {
-      result = { 'data-test-id': `er-formEditor-${id}` }
-    }
-    if (type === 'id') {
-      result = `er-filter-${id}`
-    }
-  }
-  return result
+	let result = ''
+	if (import.meta.env.MODE === 'test') {
+		if (type === 'attr') {
+			result = { 'data-test-id': `er-formEditor-${id}` }
+		}
+		if (type === 'id') {
+			result = `er-filter-${id}`
+		}
+	}
+	return result
 }
-const getTestId = (id, type = 'attr') => type === 'attr' ? `[data-test-id="er-formEditor-${id}"]` : `.er-filter-${id}`
-const addAttrs = (obj) => {
-  return import.meta.env.MODE === 'test' ? { 'data-test-attrs': JSON.stringify(obj) } : {}
-}
-const getAttrs = (el) => JSON.parse(el.getAttribute('data-test-attrs'))
-export {
-  addTestId,
-  getTestId,
-  addAttrs,
-  getAttrs
+const getTestId = (id, type = 'attr') => (type === 'attr' ? `[data-test-id="er-formEditor-${id}"]` : `.er-filter-${id}`)
+const addAttrs = obj => {
+	return import.meta.env.MODE === 'test' ? { 'data-test-attrs': JSON.stringify(obj) } : {}
 }
+const getAttrs = el => JSON.parse(el.getAttribute('data-test-attrs'))
+export { addTestId, getTestId, addAttrs, getAttrs }

+ 1 - 1
src/components/packages/utils/utils.js

@@ -1 +1 @@
-export const isEmpty = (v) => (v === '' || v === null || v === undefined || (Array.isArray(v) && !v.length))
+export const isEmpty = v => v === '' || v === null || v === undefined || (Array.isArray(v) && !v.length)