@sparrowengg/integrations-templates-frontend 5.0.2 → 5.0.4
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/cjs/dynamic-mapping/components/configuration.js +1 -1
- package/dist/cjs/dynamic-mapping/components/configuration.js.map +1 -1
- package/dist/cjs/dynamic-mapping/helpers/derive-condition-data.js +1 -1
- package/dist/cjs/dynamic-mapping/helpers/derive-condition-data.js.map +1 -1
- package/dist/es/dynamic-mapping/components/configuration.js +1 -1
- package/dist/es/dynamic-mapping/components/configuration.js.map +1 -1
- package/dist/es/dynamic-mapping/helpers/derive-condition-data.js +1 -1
- package/dist/es/dynamic-mapping/helpers/derive-condition-data.js.map +1 -1
- package/package.json +1 -1
|
@@ -109,7 +109,7 @@ const Configuration = ({
|
|
|
109
109
|
} }, /* @__PURE__ */ React.createElement(
|
|
110
110
|
formInput.FormInput,
|
|
111
111
|
__spreadProps(__spreadValues(__spreadProps(__spreadValues({
|
|
112
|
-
helperText: field.helperText || "
|
|
112
|
+
helperText: field.helperText || "",
|
|
113
113
|
placeholder: field.placeholder || "",
|
|
114
114
|
className: "dm-sans",
|
|
115
115
|
disabled: field == null ? void 0 : field.disabled
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.js","sources":["../../../../src/dynamic-mapping/components/configuration.tsx"],"sourcesContent":["/* ----- Imports ----- */\n\nimport React, { useMemo } from 'react';\nimport { Box, Flex, Text, Switch, Checkbox, FormInput, FormLabel, IconButton } from '@sparrowengg/twigs-react';\nimport { CustomAddNewSelect } from './custom-add-new-select';\nimport { useConfigurationField } from '../hooks';\nimport { isConfigurationFieldVisible } from '../helpers';\n\n/* ----- Types / Interfaces ----- */\n\ninterface ConfigurationProps {\n field: any;\n configuredFields: any;\n responseImportType?: string | null;\n}\n\n/* ----- Main Component ----- */\n\n/**\n * Configuration field component with dynamic field type rendering\n * \n * @param {ConfigurationProps} props - Component props\n * @returns {JSX.Element | null} Configuration field component\n * \n * @example\n * <Configuration\n * field={configField}\n * configuredFields={fields}\n * />\n */\nexport const Configuration = ({\n field,\n configuredFields,\n responseImportType = null,\n}: ConfigurationProps): JSX.Element | null => {\n const { error, fieldValue, handleInputChange, handleCheckboxChange, handleSwitchChange } =\n useConfigurationField({\n field,\n configuredFields,\n });\n\n const isVisible = useMemo(\n () => isConfigurationFieldVisible(field, configuredFields),\n [field, configuredFields]\n );\n\n const checkboxDescription = useMemo(() => {\n if (field.fieldType !== 'checkbox') return '';\n if (field.value && typeof field.ifChecked === 'function') {\n return field.ifChecked();\n }\n if (!field.value && typeof field.ifUnchecked === 'function') {\n return field.ifUnchecked(responseImportType);\n }\n return '';\n }, [field, responseImportType]);\n\n if (!isVisible) return null;\n\n const renderSwitchField = () => (\n <Flex\n gap=\"$4\"\n alignItems=\"center\"\n css={{\n marginBlockStart: '$12',\n borderTop: '$borderWidths$xs solid $neutral200',\n paddingTop: '$16',\n }}\n >\n <Switch\n disabled={field?.disabled}\n size=\"sm\"\n checked={field?.value}\n onChange={handleSwitchChange}\n />\n <Text size=\"md\" weight=\"regular\" css={{ color: '$neutral900' }}>\n {field.label}\n </Text>\n </Flex>\n );\n\n const renderCheckboxField = () => (\n <Flex flexDirection=\"column\" alignItems=\"start\" gap=\"$4\">\n <Flex gap=\"$4\" alignItems=\"center\">\n <Checkbox\n disabled={field?.disabled}\n checked={!!fieldValue}\n onChange={(value) => handleCheckboxChange(value as boolean)}\n >\n <Text size=\"sm\" weight=\"regular\" css={{ color: '$neutral900' }}>\n {field.label}\n </Text>\n </Checkbox>\n </Flex>\n <Text size=\"sm\" weight=\"regular\" css={{ color: '$neutral500' }}>\n {checkboxDescription}\n </Text>\n </Flex>\n );\n\n const renderInputField = () => (\n <Flex\n className=\"dm-sans\"\n alignItems=\"center\"\n gap=\"$4\"\n css={{\n width: '100%',\n label: {\n fontSize: '$xs !important',\n },\n }}\n >\n <Box css={{\n width: field?.rightElement ? '90%' : '100%',\n flex: 1,\n }}>\n <FormInput\n helperText={field.helperText || '
|
|
1
|
+
{"version":3,"file":"configuration.js","sources":["../../../../src/dynamic-mapping/components/configuration.tsx"],"sourcesContent":["/* ----- Imports ----- */\n\nimport React, { useMemo } from 'react';\nimport { Box, Flex, Text, Switch, Checkbox, FormInput, FormLabel, IconButton } from '@sparrowengg/twigs-react';\nimport { CustomAddNewSelect } from './custom-add-new-select';\nimport { useConfigurationField } from '../hooks';\nimport { isConfigurationFieldVisible } from '../helpers';\n\n/* ----- Types / Interfaces ----- */\n\ninterface ConfigurationProps {\n field: any;\n configuredFields: any;\n responseImportType?: string | null;\n}\n\n/* ----- Main Component ----- */\n\n/**\n * Configuration field component with dynamic field type rendering\n * \n * @param {ConfigurationProps} props - Component props\n * @returns {JSX.Element | null} Configuration field component\n * \n * @example\n * <Configuration\n * field={configField}\n * configuredFields={fields}\n * />\n */\nexport const Configuration = ({\n field,\n configuredFields,\n responseImportType = null,\n}: ConfigurationProps): JSX.Element | null => {\n const { error, fieldValue, handleInputChange, handleCheckboxChange, handleSwitchChange } =\n useConfigurationField({\n field,\n configuredFields,\n });\n\n const isVisible = useMemo(\n () => isConfigurationFieldVisible(field, configuredFields),\n [field, configuredFields]\n );\n\n const checkboxDescription = useMemo(() => {\n if (field.fieldType !== 'checkbox') return '';\n if (field.value && typeof field.ifChecked === 'function') {\n return field.ifChecked();\n }\n if (!field.value && typeof field.ifUnchecked === 'function') {\n return field.ifUnchecked(responseImportType);\n }\n return '';\n }, [field, responseImportType]);\n\n if (!isVisible) return null;\n\n const renderSwitchField = () => (\n <Flex\n gap=\"$4\"\n alignItems=\"center\"\n css={{\n marginBlockStart: '$12',\n borderTop: '$borderWidths$xs solid $neutral200',\n paddingTop: '$16',\n }}\n >\n <Switch\n disabled={field?.disabled}\n size=\"sm\"\n checked={field?.value}\n onChange={handleSwitchChange}\n />\n <Text size=\"md\" weight=\"regular\" css={{ color: '$neutral900' }}>\n {field.label}\n </Text>\n </Flex>\n );\n\n const renderCheckboxField = () => (\n <Flex flexDirection=\"column\" alignItems=\"start\" gap=\"$4\">\n <Flex gap=\"$4\" alignItems=\"center\">\n <Checkbox\n disabled={field?.disabled}\n checked={!!fieldValue}\n onChange={(value) => handleCheckboxChange(value as boolean)}\n >\n <Text size=\"sm\" weight=\"regular\" css={{ color: '$neutral900' }}>\n {field.label}\n </Text>\n </Checkbox>\n </Flex>\n <Text size=\"sm\" weight=\"regular\" css={{ color: '$neutral500' }}>\n {checkboxDescription}\n </Text>\n </Flex>\n );\n\n const renderInputField = () => (\n <Flex\n className=\"dm-sans\"\n alignItems=\"center\"\n gap=\"$4\"\n css={{\n width: '100%',\n label: {\n fontSize: '$xs !important',\n },\n }}\n >\n <Box css={{\n width: field?.rightElement ? '90%' : '100%',\n flex: 1,\n }}>\n <FormInput\n helperText={field.helperText || ''}\n placeholder={field.placeholder || ''}\n className=\"dm-sans\"\n disabled={field?.disabled}\n {...(error.id === field.id && {\n error: error.errorMessage,\n errorBorder: error.error,\n })}\n label={field.label}\n value={typeof fieldValue === 'object' ? '' : fieldValue || ''}\n size=\"lg\"\n {...(field.pattern && {\n pattern: field.pattern,\n })}\n onChange={handleInputChange}\n />\n </Box>\n {field?.rightElement && (\n field.rightElement()\n )}\n </Flex>\n );\n\n const renderSelectField = () => (\n <Flex\n gap=\"$2\"\n flexDirection=\"column\"\n css={{\n cursor: 'pointer !important',\n '.twigs-select__indicator': {\n width: '14px !important',\n color: '#848484 !important',\n },\n }}\n >\n <FormLabel size=\"xs\" css={{ fontWeight: '$5' }}>\n {field.label}\n </FormLabel>\n <CustomAddNewSelect field={field} />\n </Flex>\n );\n\n switch (field.fieldType) {\n case 'switch':\n return renderSwitchField();\n case 'checkbox':\n return renderCheckboxField();\n case 'input':\n return renderInputField();\n default:\n return renderSelectField();\n }\n};\n"],"names":["useConfigurationField","useMemo","isConfigurationFieldVisible","Flex","Switch","Text","Checkbox","Box","FormInput","FormLabel","CustomAddNewSelect"],"mappings":";;;;;;;;;;;;;;;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AeE,QAAA,EAAU;AAAA,OAAA;AAAA,KAEb,CAAA;AAAA,IAAA,CACC,KAAA,IAAA,IAAA,GAAA,MAAA,GAAA,KAAA,CAAO,YAAA,KACP,KAAA,CAAM,YAAA;AAAa,GAErB;AAGF,EAAA,MAAM,oBAAoB,sBACxB,KAAA,CAAA,aAAA;AAAA,IAACL,SAAA;AAAA,IAAA;AAAA,MACC,GAAA,EAAI,IAAA;AAAA,MACJ,aAAA,EAAc,QAAA;AAAA,MACd,GAAA,EAAK;AAAA,QACH,MAAA,EAAQ,oBAAA;AAAA,QACR,0BAAA,EAA4B;AAAA,UAC1B,KAAA,EAAO,iBAAA;AAAA,UACP,KAAA,EAAO;AAAA;AACT;AACF,KAAA;AAAA,oBAEA,KAAA,CAAA,aAAA,CAACM,mBAAA,EAAA,EAAU,IAAA,EAAK,IAAA,EAAK,GAAA,EAAK,EAAE,UAAA,EAAY,IAAA,EAAK,EAAA,EAC1C,KAAA,CAAM,KACT,CAAA;AAAA,oBACA,KAAA,CAAA,aAAA,CAACC,yCAAmB,KAAA,EAAc;AAAA,GACpC;AAGF,EAAA,QAAQ,MAAM,SAAA;AAAW,IACvB,KAAK,QAAA;AACH,MAAA,OAAO,iBAAA,EAAkB;AAAA,IAC3B,KAAK,UAAA;AACH,MAAA,OAAO,mBAAA,EAAoB;AAAA,IAC7B,KAAK,OAAA;AACH,MAAA,OAAO,gBAAA,EAAiB;AAAA,IAC1B;AACE,MAAA,OAAO,iBAAA,EAAkB;AAAA;AAE/B;;;;"}
|
|
@@ -28,7 +28,7 @@ const transformFieldToConditionOption = (field) => {
|
|
|
28
28
|
}
|
|
29
29
|
const fieldLabel = field.label || field.name || String(field == null ? void 0 : field.rtxt) || String(field.value || field.id);
|
|
30
30
|
const fieldValue = String(field.value || field.id);
|
|
31
|
-
const fieldType = field.type || field.dataType || "SINGLE_LINE_TEXT";
|
|
31
|
+
const fieldType = field.type || field.questionType || field.dataType || "SINGLE_LINE_TEXT";
|
|
32
32
|
const choices = extractChoices(field);
|
|
33
33
|
return {
|
|
34
34
|
label: fieldLabel,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derive-condition-data.js","sources":["../../../../src/dynamic-mapping/helpers/derive-condition-data.ts"],"sourcesContent":["/* ----- Imports ----- */\n\nimport {\n ConditionDataGroup,\n ConditionDataOption,\n getOperatorsForFieldType,\n CONDITION_CATEGORY_LABELS,\n} from '../constants/condition-operators';\n\n/* ----- Types ----- */\n\ninterface SurveyFieldChoice {\n id: number | string;\n txt?: string;\n label?: string;\n other?: boolean;\n}\n\ninterface SurveyField {\n id: string | number;\n label?: string;\n name?: string;\n value?: string | number;\n type?: string;\n dataType?: string;\n fieldType?: string;\n isEnabled?: boolean;\n choices?: SurveyFieldChoice[];\n multiple_answers?: boolean;\n questionType?: string;\n rtxt?: string;\n properties?: { data?: Record<string, any> };\n}\n\ninterface SurveyData {\n questions?: SurveyField[];\n contactProperties?: SurveyField[];\n variables?: SurveyField[];\n expressions?: SurveyField[];\n property?: SurveyField[];\n derivedQuestions?: SurveyField[];\n}\n\n/* ----- Helper Functions ----- */\n\n/**\n * Extracts and transforms choices from a survey field into the\n * {label, value} format expected by the cascader dropdown value selectors.\n */\nconst extractChoices = (field: SurveyField): Array<{ label: string; value: string }> | undefined => {\n const fieldType = field.type || field.questionType || '';\n\n if (field.choices && field.choices.length > 0) {\n return field.choices\n .filter((c) => !c.other)\n .map((c) => ({\n label: c.txt || c.label || String(c.id),\n value: String(c.id),\n }));\n }\n\n if (fieldType === 'YesNo') {\n return [\n { label: field.properties?.data?.yes || 'Yes', value: 'yes' },\n { label: field.properties?.data?.no || 'No', value: 'no' },\n ];\n }\n\n return undefined;\n};\n\n/**\n * Transforms a survey field into a condition data option\n *\n * @param field - The survey field to transform\n * @returns Condition data option with operators based on field type\n */\nconst transformFieldToConditionOption = (field: SurveyField): ConditionDataOption | null => {\n if (!field.id && !field.value) {\n return null;\n }\n\n if (field.id === 'ALL') {\n return null;\n }\n\n const fieldLabel = field.label || field.name || String(field?.rtxt) || String(field.value || field.id);\n const fieldValue = String(field.value || field.id);\n const fieldType = field.type || field.dataType || 'SINGLE_LINE_TEXT';\n const choices = extractChoices(field);\n\n return {\n label: fieldLabel,\n value: fieldValue,\n operators: getOperatorsForFieldType(fieldType, choices),\n };\n};\n\n/**\n * Transforms a category of survey fields into condition data options\n *\n * @param fields - Array of survey fields\n * @returns Array of condition data options\n */\nconst transformFieldsToConditionOptions = (fields: SurveyField[] | undefined): ConditionDataOption[] => {\n if (!fields || !Array.isArray(fields) || fields.length === 0) {\n return [];\n }\n\n return fields\n .map(transformFieldToConditionOption)\n .filter((option): option is ConditionDataOption => option !== null);\n};\n\n/* ----- Main Export ----- */\n\n/**\n * Derives condition data from survey properties or mapping data\n *\n * This function transforms surveyProperties or ssMappingData into the\n * conditionData format expected by MappingCondition component.\n *\n * @param surveyData - Survey properties or mapping data containing field categories\n * @returns Array of condition data groups with operators based on field types\n *\n * @example\n * const conditionData = deriveConditionDataFromSurveyData({\n * questions: [{ id: 1, label: 'Q1', type: 'TextInput' }],\n * contactProperties: [{ id: 'email', label: 'Email', type: 'EMAIL' }],\n * });\n */\nexport const deriveConditionDataFromSurveyData = (\n surveyData: SurveyData | null | undefined\n): ConditionDataGroup[] => {\n if (!surveyData) {\n return [];\n }\n\n const result: ConditionDataGroup[] = [];\n\n // Define categories to process in order\n const categories: Array<keyof SurveyData> = [\n 'contactProperties',\n 'questions',\n 'variables',\n 'expressions',\n 'property',\n 'derivedQuestions',\n ];\n\n for (const category of categories) {\n const fields = surveyData[category];\n const options = transformFieldsToConditionOptions(fields);\n\n // Only add category if it has options\n if (options.length > 0) {\n result.push({\n label: CONDITION_CATEGORY_LABELS[category] || category,\n value: category,\n options,\n });\n }\n }\n\n return result;\n};\n\n/**\n * Checks if condition data is provided and valid\n *\n * @param conditionData - The condition data to validate\n * @returns True if conditionData is a non-empty array\n */\nexport const hasValidConditionData = (conditionData: unknown): conditionData is ConditionDataGroup[] => {\n return Array.isArray(conditionData) && conditionData.length > 0;\n};\n\n/**\n * Checks if mapping data has any actual content (excluding 'ALL' placeholders)\n *\n * This is useful to determine if the survey data has been populated\n * with real field data that can be used for condition data derivation.\n *\n * @param data - Survey data or mapping data to check\n * @returns True if any category has actual field data\n */\nexport const hasAnyMappingData = (data: SurveyData | null | undefined): boolean => {\n if (!data) return false;\n \n const categories: Array<keyof SurveyData> = [\n 'questions',\n 'contactProperties',\n 'variables',\n 'expressions',\n 'property',\n 'derivedQuestions',\n ];\n\n return categories.some((category) => {\n const fields = data[category];\n return Array.isArray(fields) && fields.some((item) => item?.id !== 'ALL');\n });\n};\n"],"names":["getOperatorsForFieldType","CONDITION_CATEGORY_LABELS"],"mappings":";;;;AAiDA,MAAM,cAAA,GAAiB,CAAC,KAAA,KAA4E;AAjDpG,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA;AAkDE,EAAA,MAAM,SAAA,GAAY,KAAA,CAAM,IAAA,IAAQ,KAAA,CAAM,YAAA,IAAgB,EAAA;AAEtD,EAAA,IAAI,KAAA,CAAM,OAAA,IAAW,KAAA,CAAM,OAAA,CAAQ,SAAS,CAAA,EAAG;AAC7C,IAAA,OAAO,KAAA,CAAM,OAAA,CACV,MAAA,CAAO,CAAC,CAAA,KAAM,CAAC,CAAA,CAAE,KAAK,CAAA,CACtB,GAAA,CAAI,CAAC,CAAA,MAAO;AAAA,MACX,OAAO,CAAA,CAAE,GAAA,IAAO,EAAE,KAAA,IAAS,MAAA,CAAO,EAAE,EAAE,CAAA;AAAA,MACtC,KAAA,EAAO,MAAA,CAAO,CAAA,CAAE,EAAE;AAAA,KACpB,CAAE,CAAA;AAAA,EACN;AAEA,EAAA,IAAI,cAAc,OAAA,EAAS;AACzB,IAAA,OAAO;AAAA,MACL,EAAE,KAAA,EAAA,CAAA,CAAO,EAAA,GAAA,CAAA,EAAA,GAAA,KAAA,CAAM,UAAA,KAAN,IAAA,GAAA,MAAA,GAAA,EAAA,CAAkB,SAAlB,IAAA,GAAA,MAAA,GAAA,EAAA,CAAwB,GAAA,KAAO,KAAA,EAAO,KAAA,EAAO,KAAA,EAAM;AAAA,MAC5D,EAAE,KAAA,EAAA,CAAA,CAAO,EAAA,GAAA,CAAA,EAAA,GAAA,KAAA,CAAM,UAAA,KAAN,IAAA,GAAA,MAAA,GAAA,EAAA,CAAkB,SAAlB,IAAA,GAAA,MAAA,GAAA,EAAA,CAAwB,EAAA,KAAM,IAAA,EAAM,KAAA,EAAO,IAAA;AAAK,KAC3D;AAAA,EACF;AAEA,EAAA,OAAO,MAAA;AACT,CAAA;AAQA,MAAM,+BAAA,GAAkC,CAAC,KAAA,KAAmD;AAC1F,EAAA,IAAI,CAAC,KAAA,CAAM,EAAA,IAAM,CAAC,MAAM,KAAA,EAAO;AAC7B,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,IAAI,KAAA,CAAM,OAAO,KAAA,EAAO;AACtB,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,MAAM,UAAA,GAAa,KAAA,CAAM,KAAA,IAAS,KAAA,CAAM,IAAA,IAAQ,MAAA,CAAO,KAAA,IAAA,IAAA,GAAA,MAAA,GAAA,KAAA,CAAO,IAAI,CAAA,IAAK,MAAA,CAAO,KAAA,CAAM,KAAA,IAAS,MAAM,EAAE,CAAA;AACrG,EAAA,MAAM,UAAA,GAAa,MAAA,CAAO,KAAA,CAAM,KAAA,IAAS,MAAM,EAAE,CAAA;AACjD,EAAA,MAAM,
|
|
1
|
+
{"version":3,"file":"derive-condition-data.js","sources":["../../../../src/dynamic-mapping/helpers/derive-condition-data.ts"],"sourcesContent":["/* ----- Imports ----- */\n\nimport {\n ConditionDataGroup,\n ConditionDataOption,\n getOperatorsForFieldType,\n CONDITION_CATEGORY_LABELS,\n} from '../constants/condition-operators';\n\n/* ----- Types ----- */\n\ninterface SurveyFieldChoice {\n id: number | string;\n txt?: string;\n label?: string;\n other?: boolean;\n}\n\ninterface SurveyField {\n id: string | number;\n label?: string;\n name?: string;\n value?: string | number;\n type?: string;\n dataType?: string;\n fieldType?: string;\n isEnabled?: boolean;\n choices?: SurveyFieldChoice[];\n multiple_answers?: boolean;\n questionType?: string;\n rtxt?: string;\n properties?: { data?: Record<string, any> };\n}\n\ninterface SurveyData {\n questions?: SurveyField[];\n contactProperties?: SurveyField[];\n variables?: SurveyField[];\n expressions?: SurveyField[];\n property?: SurveyField[];\n derivedQuestions?: SurveyField[];\n}\n\n/* ----- Helper Functions ----- */\n\n/**\n * Extracts and transforms choices from a survey field into the\n * {label, value} format expected by the cascader dropdown value selectors.\n */\nconst extractChoices = (field: SurveyField): Array<{ label: string; value: string }> | undefined => {\n const fieldType = field.type || field.questionType || '';\n\n if (field.choices && field.choices.length > 0) {\n return field.choices\n .filter((c) => !c.other)\n .map((c) => ({\n label: c.txt || c.label || String(c.id),\n value: String(c.id),\n }));\n }\n\n if (fieldType === 'YesNo') {\n return [\n { label: field.properties?.data?.yes || 'Yes', value: 'yes' },\n { label: field.properties?.data?.no || 'No', value: 'no' },\n ];\n }\n\n return undefined;\n};\n\n/**\n * Transforms a survey field into a condition data option\n *\n * @param field - The survey field to transform\n * @returns Condition data option with operators based on field type\n */\nconst transformFieldToConditionOption = (field: SurveyField): ConditionDataOption | null => {\n if (!field.id && !field.value) {\n return null;\n }\n\n if (field.id === 'ALL') {\n return null;\n }\n\n const fieldLabel = field.label || field.name || String(field?.rtxt) || String(field.value || field.id);\n const fieldValue = String(field.value || field.id);\n const fieldType = field.type || field.questionType || field.dataType || 'SINGLE_LINE_TEXT';\n const choices = extractChoices(field);\n\n return {\n label: fieldLabel,\n value: fieldValue,\n operators: getOperatorsForFieldType(fieldType, choices),\n };\n};\n\n/**\n * Transforms a category of survey fields into condition data options\n *\n * @param fields - Array of survey fields\n * @returns Array of condition data options\n */\nconst transformFieldsToConditionOptions = (fields: SurveyField[] | undefined): ConditionDataOption[] => {\n if (!fields || !Array.isArray(fields) || fields.length === 0) {\n return [];\n }\n\n return fields\n .map(transformFieldToConditionOption)\n .filter((option): option is ConditionDataOption => option !== null);\n};\n\n/* ----- Main Export ----- */\n\n/**\n * Derives condition data from survey properties or mapping data\n *\n * This function transforms surveyProperties or ssMappingData into the\n * conditionData format expected by MappingCondition component.\n *\n * @param surveyData - Survey properties or mapping data containing field categories\n * @returns Array of condition data groups with operators based on field types\n *\n * @example\n * const conditionData = deriveConditionDataFromSurveyData({\n * questions: [{ id: 1, label: 'Q1', type: 'TextInput' }],\n * contactProperties: [{ id: 'email', label: 'Email', type: 'EMAIL' }],\n * });\n */\nexport const deriveConditionDataFromSurveyData = (\n surveyData: SurveyData | null | undefined\n): ConditionDataGroup[] => {\n if (!surveyData) {\n return [];\n }\n\n const result: ConditionDataGroup[] = [];\n\n // Define categories to process in order\n const categories: Array<keyof SurveyData> = [\n 'contactProperties',\n 'questions',\n 'variables',\n 'expressions',\n 'property',\n 'derivedQuestions',\n ];\n\n for (const category of categories) {\n const fields = surveyData[category];\n const options = transformFieldsToConditionOptions(fields);\n\n // Only add category if it has options\n if (options.length > 0) {\n result.push({\n label: CONDITION_CATEGORY_LABELS[category] || category,\n value: category,\n options,\n });\n }\n }\n\n return result;\n};\n\n/**\n * Checks if condition data is provided and valid\n *\n * @param conditionData - The condition data to validate\n * @returns True if conditionData is a non-empty array\n */\nexport const hasValidConditionData = (conditionData: unknown): conditionData is ConditionDataGroup[] => {\n return Array.isArray(conditionData) && conditionData.length > 0;\n};\n\n/**\n * Checks if mapping data has any actual content (excluding 'ALL' placeholders)\n *\n * This is useful to determine if the survey data has been populated\n * with real field data that can be used for condition data derivation.\n *\n * @param data - Survey data or mapping data to check\n * @returns True if any category has actual field data\n */\nexport const hasAnyMappingData = (data: SurveyData | null | undefined): boolean => {\n if (!data) return false;\n \n const categories: Array<keyof SurveyData> = [\n 'questions',\n 'contactProperties',\n 'variables',\n 'expressions',\n 'property',\n 'derivedQuestions',\n ];\n\n return categories.some((category) => {\n const fields = data[category];\n return Array.isAr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A,GAAA,MAAA,GAAA,IAAA,CAAM,EAAA,MAAO,KAAK,CAAA;AAAA,EAC1E,CAAC,CAAA;AACH;;;;;;"}
|
|
@@ -107,7 +107,7 @@ const Configuration = ({
|
|
|
107
107
|
} }, /* @__PURE__ */ React__default.createElement(
|
|
108
108
|
FormInput,
|
|
109
109
|
__spreadProps(__spreadValues(__spreadProps(__spreadValues({
|
|
110
|
-
helperText: field.helperText || "
|
|
110
|
+
helperText: field.helperText || "",
|
|
111
111
|
placeholder: field.placeholder || "",
|
|
112
112
|
className: "dm-sans",
|
|
113
113
|
disabled: field == null ? void 0 : field.disabled
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.js","sources":["../../../../src/dynamic-mapping/components/configuration.tsx"],"sourcesContent":["/* ----- Imports ----- */\n\nimport React, { useMemo } from 'react';\nimport { Box, Flex, Text, Switch, Checkbox, FormInput, FormLabel, IconButton } from '@sparrowengg/twigs-react';\nimport { CustomAddNewSelect } from './custom-add-new-select';\nimport { useConfigurationField } from '../hooks';\nimport { isConfigurationFieldVisible } from '../helpers';\n\n/* ----- Types / Interfaces ----- */\n\ninterface ConfigurationProps {\n field: any;\n configuredFields: any;\n responseImportType?: string | null;\n}\n\n/* ----- Main Component ----- */\n\n/**\n * Configuration field component with dynamic field type rendering\n * \n * @param {ConfigurationProps} props - Component props\n * @returns {JSX.Element | null} Configuration field component\n * \n * @example\n * <Configuration\n * field={configField}\n * configuredFields={fields}\n * />\n */\nexport const Configuration = ({\n field,\n configuredFields,\n responseImportType = null,\n}: ConfigurationProps): JSX.Element | null => {\n const { error, fieldValue, handleInputChange, handleCheckboxChange, handleSwitchChange } =\n useConfigurationField({\n field,\n configuredFields,\n });\n\n const isVisible = useMemo(\n () => isConfigurationFieldVisible(field, configuredFields),\n [field, configuredFields]\n );\n\n const checkboxDescription = useMemo(() => {\n if (field.fieldType !== 'checkbox') return '';\n if (field.value && typeof field.ifChecked === 'function') {\n return field.ifChecked();\n }\n if (!field.value && typeof field.ifUnchecked === 'function') {\n return field.ifUnchecked(responseImportType);\n }\n return '';\n }, [field, responseImportType]);\n\n if (!isVisible) return null;\n\n const renderSwitchField = () => (\n <Flex\n gap=\"$4\"\n alignItems=\"center\"\n css={{\n marginBlockStart: '$12',\n borderTop: '$borderWidths$xs solid $neutral200',\n paddingTop: '$16',\n }}\n >\n <Switch\n disabled={field?.disabled}\n size=\"sm\"\n checked={field?.value}\n onChange={handleSwitchChange}\n />\n <Text size=\"md\" weight=\"regular\" css={{ color: '$neutral900' }}>\n {field.label}\n </Text>\n </Flex>\n );\n\n const renderCheckboxField = () => (\n <Flex flexDirection=\"column\" alignItems=\"start\" gap=\"$4\">\n <Flex gap=\"$4\" alignItems=\"center\">\n <Checkbox\n disabled={field?.disabled}\n checked={!!fieldValue}\n onChange={(value) => handleCheckboxChange(value as boolean)}\n >\n <Text size=\"sm\" weight=\"regular\" css={{ color: '$neutral900' }}>\n {field.label}\n </Text>\n </Checkbox>\n </Flex>\n <Text size=\"sm\" weight=\"regular\" css={{ color: '$neutral500' }}>\n {checkboxDescription}\n </Text>\n </Flex>\n );\n\n const renderInputField = () => (\n <Flex\n className=\"dm-sans\"\n alignItems=\"center\"\n gap=\"$4\"\n css={{\n width: '100%',\n label: {\n fontSize: '$xs !important',\n },\n }}\n >\n <Box css={{\n width: field?.rightElement ? '90%' : '100%',\n flex: 1,\n }}>\n <FormInput\n helperText={field.helperText || '
|
|
1
|
+
{"version":3,"file":"configuration.js","sources":["../../../../src/dynamic-mapping/components/configuration.tsx"],"sourcesContent":["/* ----- Imports ----- */\n\nimport React, { useMemo } from 'react';\nimport { Box, Flex, Text, Switch, Checkbox, FormInput, FormLabel, IconButton } from '@sparrowengg/twigs-react';\nimport { CustomAddNewSelect } from './custom-add-new-select';\nimport { useConfigurationField } from '../hooks';\nimport { isConfigurationFieldVisible } from '../helpers';\n\n/* ----- Types / Interfaces ----- */\n\ninterface ConfigurationProps {\n field: any;\n configuredFields: any;\n responseImportType?: string | null;\n}\n\n/* ----- Main Component ----- */\n\n/**\n * Configuration field component with dynamic field type rendering\n * \n * @param {ConfigurationProps} props - Component props\n * @returns {JSX.Element | null} Configuration field component\n * \n * @example\n * <Configuration\n * field={configField}\n * configuredFields={fields}\n * />\n */\nexport const Configuration = ({\n field,\n configuredFields,\n responseImportType = null,\n}: ConfigurationProps): JSX.Element | null => {\n const { error, fieldValue, handleInputChange, handleCheckboxChange, handleSwitchChange } =\n useConfigurationField({\n field,\n configuredFields,\n });\n\n const isVisible = useMemo(\n () => isConfigurationFieldVisible(field, configuredFields),\n [field, configuredFields]\n );\n\n const checkboxDescription = useMemo(() => {\n if (field.fieldType !== 'checkbox') return '';\n if (field.value && typeof field.ifChecked === 'function') {\n return field.ifChecked();\n }\n if (!field.value && typeof field.ifUnchecked === 'function') {\n return field.ifUnchecked(responseImportType);\n }\n return '';\n }, [field, responseImportType]);\n\n if (!isVisible) return null;\n\n const renderSwitchField = () => (\n <Flex\n gap=\"$4\"\n alignItems=\"center\"\n css={{\n marginBlockStart: '$12',\n borderTop: '$borderWidths$xs solid $neutral200',\n paddingTop: '$16',\n }}\n >\n <Switch\n disabled={field?.disabled}\n size=\"sm\"\n checked={field?.value}\n onChange={handleSwitchChange}\n />\n <Text size=\"md\" weight=\"regular\" css={{ color: '$neutral900' }}>\n {field.label}\n </Text>\n </Flex>\n );\n\n const renderCheckboxField = () => (\n <Flex flexDirection=\"column\" alignItems=\"start\" gap=\"$4\">\n <Flex gap=\"$4\" alignItems=\"center\">\n <Checkbox\n disabled={field?.disabled}\n checked={!!fieldValue}\n onChange={(value) => handleCheckboxChange(value as boolean)}\n >\n <Text size=\"sm\" weight=\"regular\" css={{ color: '$neutral900' }}>\n {field.label}\n </Text>\n </Checkbox>\n </Flex>\n <Text size=\"sm\" weight=\"regular\" css={{ color: '$neutral500' }}>\n {checkboxDescription}\n </Text>\n </Flex>\n );\n\n const renderInputField = () => (\n <Flex\n className=\"dm-sans\"\n alignItems=\"center\"\n gap=\"$4\"\n css={{\n width: '100%',\n label: {\n fontSize: '$xs !important',\n },\n }}\n >\n <Box css={{\n width: field?.rightElement ? '90%' : '100%',\n flex: 1,\n }}>\n <FormInput\n helperText={field.helperText || ''}\n placeholder={field.placeholder || ''}\n className=\"dm-sans\"\n disabled={field?.disabled}\n {...(error.id === field.id && {\n error: error.errorMessage,\n errorBorder: error.error,\n })}\n label={field.label}\n value={typeof fieldValue === 'object' ? '' : fieldValue || ''}\n size=\"lg\"\n {...(field.pattern && {\n pattern: field.pattern,\n })}\n onChange={handleInputChange}\n />\n </Box>\n {field?.rightElement && (\n field.rightElement()\n )}\n </Flex>\n );\n\n const renderSelectField = () => (\n <Flex\n gap=\"$2\"\n flexDirection=\"column\"\n css={{\n cursor: 'pointer !important',\n '.twigs-select__indicator': {\n width: '14px !important',\n color: '#848484 !important',\n },\n }}\n >\n <FormLabel size=\"xs\" css={{ fontWeight: '$5' }}>\n {field.label}\n </FormLabel>\n <CustomAddNewSelect field={field} />\n </Flex>\n );\n\n switch (field.fieldType) {\n case 'switch':\n return renderSwitchField();\n case 'checkbox':\n return renderCheckboxField();\n case 'input':\n return renderInputField();\n default:\n return renderSelectField();\n }\n};\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BO,MAAM,gBAAgB,CAAC;AAAA,EAC5B,KAAA;AAAA,EACA,gBAAA;AAAA,EACA,kBAAA,GAAqB;AACvB,CAAA,KAA8C;AAC5C,EAAA,MAAM,EAAE,KAAA,EAAO,UAAA,EAAY,mBAAmB,oBAAA,EAAsB,kBAAA,KAClE,qBAAA,CAAsB;AAAA,IACpB,KAAA;AAAA,IACA;AAAA,GACD,CAAA;AAEH,EAAA,MAAM,SAAA,GAAY,OAAA;AAAA,IAChB,MAAM,2BAAA,CAA4B,KAAA,EAAO,gBAAgB,CAAA;AAAA,IACzD,CAAC,OAAO,gBAAgB;AAAA,GAC1B;AAEA,EAAA,MAAM,mBAAA,GAAsB,QAAQ,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AAA,oBAEAA,cAAA,CAAA,aAAA,CAAC,SAAA,EAAA,EAAU,IAAA,EAAK,IAAA,EAAK,GAAA,EAAK,EAAE,UAAA,EAAY,IAAA,EAAK,EAAA,EAC1C,KAAA,CAAM,KACT,CAAA;AAAA,oBACAA,cAAA,CAAA,aAAA,CAAC,sBAAmB,KAAA,EAAc;AAAA,GACpC;AAGF,EAAA,QAAQ,MAAM,SAAA;AAAW,IACvB,KAAK,QAAA;AACH,MAAA,OAAO,iBAAA,EAAkB;AAAA,IAC3B,KAAK,UAAA;AACH,MAAA,OAAO,mBAAA,EAAoB;AAAA,IAC7B,KAAK,OAAA;AACH,MAAA,OAAO,gBAAA,EAAiB;AAAA,IAC1B;AACE,MAAA,OAAO,iBAAA,EAAkB;AAAA;AAE/B;;;;"}
|
|
@@ -26,7 +26,7 @@ const transformFieldToConditionOption = (field) => {
|
|
|
26
26
|
}
|
|
27
27
|
const fieldLabel = field.label || field.name || String(field == null ? void 0 : field.rtxt) || String(field.value || field.id);
|
|
28
28
|
const fieldValue = String(field.value || field.id);
|
|
29
|
-
const fieldType = field.type || field.dataType || "SINGLE_LINE_TEXT";
|
|
29
|
+
const fieldType = field.type || field.questionType || field.dataType || "SINGLE_LINE_TEXT";
|
|
30
30
|
const choices = extractChoices(field);
|
|
31
31
|
return {
|
|
32
32
|
label: fieldLabel,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derive-condition-data.js","sources":["../../../../src/dynamic-mapping/helpers/derive-condition-data.ts"],"sourcesContent":["/* ----- Imports ----- */\n\nimport {\n ConditionDataGroup,\n ConditionDataOption,\n getOperatorsForFieldType,\n CONDITION_CATEGORY_LABELS,\n} from '../constants/condition-operators';\n\n/* ----- Types ----- */\n\ninterface SurveyFieldChoice {\n id: number | string;\n txt?: string;\n label?: string;\n other?: boolean;\n}\n\ninterface SurveyField {\n id: string | number;\n label?: string;\n name?: string;\n value?: string | number;\n type?: string;\n dataType?: string;\n fieldType?: string;\n isEnabled?: boolean;\n choices?: SurveyFieldChoice[];\n multiple_answers?: boolean;\n questionType?: string;\n rtxt?: string;\n properties?: { data?: Record<string, any> };\n}\n\ninterface SurveyData {\n questions?: SurveyField[];\n contactProperties?: SurveyField[];\n variables?: SurveyField[];\n expressions?: SurveyField[];\n property?: SurveyField[];\n derivedQuestions?: SurveyField[];\n}\n\n/* ----- Helper Functions ----- */\n\n/**\n * Extracts and transforms choices from a survey field into the\n * {label, value} format expected by the cascader dropdown value selectors.\n */\nconst extractChoices = (field: SurveyField): Array<{ label: string; value: string }> | undefined => {\n const fieldType = field.type || field.questionType || '';\n\n if (field.choices && field.choices.length > 0) {\n return field.choices\n .filter((c) => !c.other)\n .map((c) => ({\n label: c.txt || c.label || String(c.id),\n value: String(c.id),\n }));\n }\n\n if (fieldType === 'YesNo') {\n return [\n { label: field.properties?.data?.yes || 'Yes', value: 'yes' },\n { label: field.properties?.data?.no || 'No', value: 'no' },\n ];\n }\n\n return undefined;\n};\n\n/**\n * Transforms a survey field into a condition data option\n *\n * @param field - The survey field to transform\n * @returns Condition data option with operators based on field type\n */\nconst transformFieldToConditionOption = (field: SurveyField): ConditionDataOption | null => {\n if (!field.id && !field.value) {\n return null;\n }\n\n if (field.id === 'ALL') {\n return null;\n }\n\n const fieldLabel = field.label || field.name || String(field?.rtxt) || String(field.value || field.id);\n const fieldValue = String(field.value || field.id);\n const fieldType = field.type || field.dataType || 'SINGLE_LINE_TEXT';\n const choices = extractChoices(field);\n\n return {\n label: fieldLabel,\n value: fieldValue,\n operators: getOperatorsForFieldType(fieldType, choices),\n };\n};\n\n/**\n * Transforms a category of survey fields into condition data options\n *\n * @param fields - Array of survey fields\n * @returns Array of condition data options\n */\nconst transformFieldsToConditionOptions = (fields: SurveyField[] | undefined): ConditionDataOption[] => {\n if (!fields || !Array.isArray(fields) || fields.length === 0) {\n return [];\n }\n\n return fields\n .map(transformFieldToConditionOption)\n .filter((option): option is ConditionDataOption => option !== null);\n};\n\n/* ----- Main Export ----- */\n\n/**\n * Derives condition data from survey properties or mapping data\n *\n * This function transforms surveyProperties or ssMappingData into the\n * conditionData format expected by MappingCondition component.\n *\n * @param surveyData - Survey properties or mapping data containing field categories\n * @returns Array of condition data groups with operators based on field types\n *\n * @example\n * const conditionData = deriveConditionDataFromSurveyData({\n * questions: [{ id: 1, label: 'Q1', type: 'TextInput' }],\n * contactProperties: [{ id: 'email', label: 'Email', type: 'EMAIL' }],\n * });\n */\nexport const deriveConditionDataFromSurveyData = (\n surveyData: SurveyData | null | undefined\n): ConditionDataGroup[] => {\n if (!surveyData) {\n return [];\n }\n\n const result: ConditionDataGroup[] = [];\n\n // Define categories to process in order\n const categories: Array<keyof SurveyData> = [\n 'contactProperties',\n 'questions',\n 'variables',\n 'expressions',\n 'property',\n 'derivedQuestions',\n ];\n\n for (const category of categories) {\n const fields = surveyData[category];\n const options = transformFieldsToConditionOptions(fields);\n\n // Only add category if it has options\n if (options.length > 0) {\n result.push({\n label: CONDITION_CATEGORY_LABELS[category] || category,\n value: category,\n options,\n });\n }\n }\n\n return result;\n};\n\n/**\n * Checks if condition data is provided and valid\n *\n * @param conditionData - The condition data to validate\n * @returns True if conditionData is a non-empty array\n */\nexport const hasValidConditionData = (conditionData: unknown): conditionData is ConditionDataGroup[] => {\n return Array.isArray(conditionData) && conditionData.length > 0;\n};\n\n/**\n * Checks if mapping data has any actual content (excluding 'ALL' placeholders)\n *\n * This is useful to determine if the survey data has been populated\n * with real field data that can be used for condition data derivation.\n *\n * @param data - Survey data or mapping data to check\n * @returns True if any category has actual field data\n */\nexport const hasAnyMappingData = (data: SurveyData | null | undefined): boolean => {\n if (!data) return false;\n \n const categories: Array<keyof SurveyData> = [\n 'questions',\n 'contactProperties',\n 'variables',\n 'expressions',\n 'property',\n 'derivedQuestions',\n ];\n\n return categories.some((category) => {\n const fields = data[category];\n return Array.isArray(fields) && fields.some((item) => item?.id !== 'ALL');\n });\n};\n"],"names":[],"mappings":";;AAiDA,MAAM,cAAA,GAAiB,CAA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AM,KAAA,EAAO;AAC7B,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,IAAI,KAAA,CAAM,OAAO,KAAA,EAAO;AACtB,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,MAAM,UAAA,GAAa,KAAA,CAAM,KAAA,IAAS,KAAA,CAAM,IAAA,IAAQ,MAAA,CAAO,KAAA,IAAA,IAAA,GAAA,MAAA,GAAA,KAAA,CAAO,IAAI,CAAA,IAAK,MAAA,CAAO,KAAA,CAAM,KAAA,IAAS,MAAM,EAAE,CAAA;AACrG,EAAA,MAAM,UAAA,GAAa,MAAA,CAAO,KAAA,CAAM,KAAA,IAAS,MAAM,EAAE,CAAA;AACjD,EAAA,MAAM,
|
|
1
|
+
{"version":3,"file":"derive-condition-data.js","sources":["../../../../src/dynamic-mapping/helpers/derive-condition-data.ts"],"sourcesContent":["/* ----- Imports ----- */\n\nimport {\n ConditionDataGroup,\n ConditionDataOption,\n getOperatorsForFieldType,\n CONDITION_CATEGORY_LABELS,\n} from '../constants/condition-operators';\n\n/* ----- Types ----- */\n\ninterface SurveyFieldChoice {\n id: number | string;\n txt?: string;\n label?: string;\n other?: boolean;\n}\n\ninterface SurveyField {\n id: string | number;\n label?: string;\n name?: string;\n value?: string | number;\n type?: string;\n dataType?: string;\n fieldType?: string;\n isEnabled?: boolean;\n choices?: SurveyFieldChoice[];\n multiple_answers?: boolean;\n questionType?: string;\n rtxt?: string;\n properties?: { data?: Record<string, any> };\n}\n\ninterface SurveyData {\n questions?: SurveyField[];\n contactProperties?: SurveyField[];\n variables?: SurveyField[];\n expressions?: SurveyField[];\n property?: SurveyField[];\n derivedQuestions?: SurveyField[];\n}\n\n/* ----- Helper Functions ----- */\n\n/**\n * Extracts and transforms choices from a survey field into the\n * {label, value} format expected by the cascader dropdown value selectors.\n */\nconst extractChoices = (field: SurveyField): Array<{ label: string; value: string }> | undefined => {\n const fieldType = field.type || field.questionType || '';\n\n if (field.choices && field.choices.length > 0) {\n return field.choices\n .filter((c) => !c.other)\n .map((c) => ({\n label: c.txt || c.label || String(c.id),\n value: String(c.id),\n }));\n }\n\n if (fieldType === 'YesNo') {\n return [\n { label: field.properties?.data?.yes || 'Yes', value: 'yes' },\n { label: field.properties?.data?.no || 'No', value: 'no' },\n ];\n }\n\n return undefined;\n};\n\n/**\n * Transforms a survey field into a condition data option\n *\n * @param field - The survey field to transform\n * @returns Condition data option with operators based on field type\n */\nconst transformFieldToConditionOption = (field: SurveyField): ConditionDataOption | null => {\n if (!field.id && !field.value) {\n return null;\n }\n\n if (field.id === 'ALL') {\n return null;\n }\n\n const fieldLabel = field.label || field.name || String(field?.rtxt) || String(field.value || field.id);\n const fieldValue = String(field.value || field.id);\n const fieldType = field.type || field.questionType || field.dataType || 'SINGLE_LINE_TEXT';\n const choices = extractChoices(field);\n\n return {\n label: fieldLabel,\n value: fieldValue,\n operators: getOperatorsForFieldType(fieldType, choices),\n };\n};\n\n/**\n * Transforms a category of survey fields into condition data options\n *\n * @param fields - Array of survey fields\n * @returns Array of condition data options\n */\nconst transformFieldsToConditionOptions = (fields: SurveyField[] | undefined): ConditionDataOption[] => {\n if (!fields || !Array.isArray(fields) || fields.length === 0) {\n return [];\n }\n\n return fields\n .map(transformFieldToConditionOption)\n .filter((option): option is ConditionDataOption => option !== null);\n};\n\n/* ----- Main Export ----- */\n\n/**\n * Derives condition data from survey properties or mapping data\n *\n * This function transforms surveyProperties or ssMappingData into the\n * conditionData format expected by MappingCondition component.\n *\n * @param surveyData - Survey properties or mapping data containing field categories\n * @returns Array of condition data groups with operators based on field types\n *\n * @example\n * const conditionData = deriveConditionDataFromSurveyData({\n * questions: [{ id: 1, label: 'Q1', type: 'TextInput' }],\n * contactProperties: [{ id: 'email', label: 'Email', type: 'EMAIL' }],\n * });\n */\nexport const deriveConditionDataFromSurveyData = (\n surveyData: SurveyData | null | undefined\n): ConditionDataGroup[] => {\n if (!surveyData) {\n return [];\n }\n\n const result: ConditionDataGroup[] = [];\n\n // Define categories to process in order\n const categories: Array<keyof SurveyData> = [\n 'contactProperties',\n 'questions',\n 'variables',\n 'expressions',\n 'property',\n 'derivedQuestions',\n ];\n\n for (const category of categories) {\n const fields = surveyData[category];\n const options = transformFieldsToConditionOptions(fields);\n\n // Only add category if it has options\n if (options.length > 0) {\n result.push({\n label: CONDITION_CATEGORY_LABELS[category] || category,\n value: category,\n options,\n });\n }\n }\n\n return result;\n};\n\n/**\n * Checks if condition data is provided and valid\n *\n * @param conditionData - The condition data to validate\n * @returns True if conditionData is a non-empty array\n */\nexport const hasValidConditionData = (conditionData: unknown): conditionData is ConditionDataGroup[] => {\n return Array.isArray(conditionData) && conditionData.length > 0;\n};\n\n/**\n * Checks if mapping data has any actual content (excluding 'ALL' placeholders)\n *\n * This is useful to determine if the survey data has been populated\n * with real field data that can be used for condition data derivation.\n *\n * @param data - Survey data or mapping data to check\n * @returns True if any category has actual field data\n */\nexport const hasAnyMappingData = (data: SurveyData | null | undefined): boolean => {\n if (!data) return false;\n \n const categories: Array<keyof SurveyData> = [\n 'questions',\n 'contactProperties',\n 'variables',\n 'expressions',\n 'property',\n 'derivedQuestions',\n ];\n\n return categories.some((category) => {\n const fields = data[category];\n return Array.isArray(fields) && fields.some((item) => item?.id !== 'ALL');\n });\n};\n"],"names":[],"mappings":";;AAiDA,MAAM,cAAA,GAAiB,CAAC,KAAA,KAA4E;AAjDpG,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA;AAkDE,EAAA,MAAM,SAAA,GAAY,KAAA,CAAM,IAAA,IAAQ,KAAA,CAAM,YAAA,IAAgB,EAAA;AAEtD,EAAA,IAAI,KAAA,CAAM,OAAA,IAAW,KAAA,CAAM,OAAA,CAAQ,SAAS,CAAA,EAAG;AAC7C,IAAA,OAAO,KAAA,CAAM,OAAA,CACV,MAAA,CAAO,CAAC,CAAA,KAAM,CAAC,CAAA,CAAE,KAAK,CAAA,CACtB,GAAA,CAAI,CAAC,CAAA,MAAO;AAAA,MACX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