@leav/ui 1.6.0-4feacea4 → 1.6.0-68930d4c

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.
@@ -1 +1 @@
1
- {"version":3,"file":"antdUtils.js","sourceRoot":"","sources":["../../../../src/components/RecordEdition/EditRecordContent/antdUtils.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAC,eAAe,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AAG7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,kBAAkB,GAAG,CAAC,SAAkB,EAAgC,EAAE,CAC3E,SAA6B,CAAC,IAAI,KAAK,SAAS,IAAK,SAA6B,CAAC,EAAE,KAAK,SAAS,CAAC;AAEzG,MAAM,kBAAkB,GAAG,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;AAE9E,MAAM,iBAAiB,GAAG,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AAE5E,MAAM,iBAAiB,GAAG,MAAM,CAAC,EAAE,CAC/B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC;AAElG,MAAM,kCAAkC,GAAG,CACvC,KAA8B,EAC9B,SAAqC,EACI,EAAE,CAC3C,SAAS,CAAC,IAAI,KAAK,aAAa,CAAC,WAAW;IAC5C,CAAC,SAAS,CAAC,IAAI,KAAK,aAAa,CAAC,aAAa,IAAI,SAAS,CAAC,eAAe,KAAK,KAAK,CAAC,CAAC;AAE5F,MAAM,mCAAmC,GAAG,CACxC,MAAiC,EACjC,SAAqC,EACO,EAAE,CAC9C,SAAS,CAAC,I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C,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;qBACvD,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,0BAA0B,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;QACtE,OAAO,GAAG,CAAC;IACf,CAAC;IAED,MAAM,aAAa,GAAG,KAA6C,CAAC;IAEpE,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,0BAA0B,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAEzE,OAAO,GAAG,CAAC;AACf,CAAC,EAAE,EAAE,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {\n type IRecordForm,\n type RecordFormElementAttribute,\n type RecordFormElementsValue,\n type RecordFormElementsValueLinkValue,\n type RecordFormElementsValueStandardValue,\n} from '_ui/hooks/useGetRecordForm';\nimport {AttributeFormat, AttributeType} from '_ui/_gqlTypes';\nimport {type IDateRangeValue} from '@leav/utils';\nimport {type Store} from 'antd/lib/form/interface';\nimport dayjs from 'dayjs';\n\nconst hasDateRangeValues = (dateRange: unknown): dateRange is IDateRangeValue =>\n (dateRange as IDateRangeValue).from !== undefined && (dateRange as IDateRangeValue).to !== undefined;\n\nconst getCalculatedValue = values => values.find(value => value.isCalculated);\n\nconst getInheritedValue = values => values.find(value => value.isInherited);\n\nconst getUserInputValue = values =>\n values.find(value => !value.isInherited && !value.isCalculated && value.raw_payload !== null);\n\nconst isRecordFormElementsValueLinkValue = (\n value: RecordFormElementsValue,\n attribute: RecordFormElementAttribute,\n): value is RecordFormElementsValueLinkValue =>\n attribute.type === AttributeType.simple_link ||\n (attribute.type === AttributeType.advanced_link && attribute.multiple_values === false);\n\nconst isRecordFormElementsValueLinkValues = (\n values: RecordFormElementsValue[],\n attribute: RecordFormElementAttribute,\n): values is RecordFormElementsValueLinkValue[] =>\n attribute.type === AttributeType.advanced_link && attribute.multiple_values === true;\n\nconst isRecordFormElementsMultipleValues = (attribute: RecordFormElementAttribute) =>\n attribute.type === AttributeType.advanced && attribute.multiple_values === true;\n\nconst formatStandardInitialValue = (\n standardValue: RecordFormElementsValueStandardValue,\n attribute: RecordFormElementAttribute,\n) => {\n if (!standardValue?.raw_payload) {\n return getEmptyInitialValue(attribute);\n }\n\n switch (attribute.format) {\n case AttributeFormat.color:\n case AttributeFormat.text:\n case AttributeFormat.rich_text:\n case AttributeFormat.boolean:\n return standardValue.raw_payload;\n case AttributeFormat.numeric:\n return Number(standardValue.raw_payload);\n case AttributeFormat.date:\n return dayjs.unix(Number(standardValue.raw_payload));\n case AttributeFormat.date_range:\n if (hasDateRangeValues(standardValue.raw_payload)) {\n return [\n dayjs.unix(Number(standardValue.raw_payload.from)),\n dayjs.unix(Number(standardValue.raw_payload.to)),\n ];\n } else if (typeof standardValue.raw_payload === 'string') {\n const convertedFieldValue = JSON.parse(standardValue.raw_payload) as any;\n return [dayjs.unix(Number(convertedFieldValue.from)), dayjs.unix(Number(convertedFieldValue.to))];\n }\n }\n};\n\nexport const EMPTY_INITIAL_VALUE_STRING = '';\nexport const EMPTY_INITIAL_VALUE_UNDEFINED = undefined;\n\nexport const getEmptyInitialValue = (attribute: RecordFormElementAttribute) => {\n if ([AttributeFormat.date_range, AttributeFormat.color].includes(attribute.format)) {\n return EMPTY_INITIAL_VALUE_UNDEFINED;\n }\n return EMPTY_INITIAL_VALUE_STRING;\n};\n\nexport const getAntdDisplayedValue = (\n values: RecordFormElementsValueStandardValue[],\n attribute: RecordFormElementAttribute,\n) =>\n formatStandardInitialValue(\n getUserInputValue(values) ?? getInheritedValue(values) ?? getCalculatedValue(values) ?? null,\n attribute,\n );\n\nexport const getAntdFormInitialValues = (recordForm: IRecordForm) =>\n recordForm.elements.reduce<Store>((acc, {attribute, values}) => {\n if (!attribute) {\n return acc;\n }\n\n const value = getUserInputValue(values) ?? getInheritedValue(values) ?? getCalculatedValue(values) ?? null;\n\n if (isRecordFormElementsValueLinkValue(value, attribute)) {\n acc[attribute.id] = value?.linkValue?.id;\n return acc;\n }\n\n if (isRecordFormElementsValueLinkValues(values, attribute)) {\n acc[attribute.id] = values.map(val => val?.linkValue?.id ?? undefined);\n return acc;\n }\n\n if (isRecordFormElementsMultipleValues(attribute)) {\n const userInputValues = values.filter(val => val.id_value);\n const calculatedValues = values.filter(val => val.isCalculated);\n const inheritedValues = values.filter(val => val.isInherited);\n\n const effectiveValues =\n userInputValues.length > 0\n ? userInputValues\n : calculatedValues.length > 0\n ? calculatedValues\n : inheritedValues.length > 0\n ? inheritedValues\n : [];\n\n acc[attribute.id] =\n effectiveValues.length === 0\n ? [getEmptyInitialValue(attribute)]\n : effectiveValues\n .sort((a, b) => Number(a.id_value) - Number(b.id_value))\n .map(val => formatStandardInitialValue(val, attribute));\n return acc;\n }\n\n const standardValue = value as RecordFormElementsValueStandardValue;\n\n acc[attribute.id] = formatStandardInitialValue(standardValue, attribute);\n\n return acc;\n }, {});\n"]}
1
+ {"version":3,"file":"antdUtils.js","sourceRoot":"","sources":["../../../../src/components/RecordEdition/EditRecordContent/antdUtils.ts"],"names":[],"mappings":"AAUA,OAAO,EAAC,eAAe,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AAG7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,kBAAkB,GAAG,CAAC,SAAkB,EAAgC,EAAE,CAC3E,SAA6B,CAAC,IAAI,KAAK,SAAS,IAAK,SAA6B,CAAC,EAAE,KAAK,SAAS,CAAC;AAEzG,MAAM,kBAAkB,GAAG,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;AAE9E,MAAM,iBAAiB,GAAG,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CA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,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAE9D,MAAM,eAAe,GACjB,eAAe,CAAC,MAAM,GAAG,CAAC;YACtB,CAAC,CAAC,eAAe;YACjB,CAAC,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC;gBAC3B,CAAC,CAAC,gBAAgB;gBAClB,CAAC,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC;oBAC1B,CAAC,CAAC,eAAe;oBACjB,CAAC,CAAC,EAAE,CAAC;QAEjB,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACb,eAAe,CAAC,MAAM,KAAK,CAAC;gBACxB,CAAC,CAAC,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;gBACnC,CAAC,CAAC,eAAe;qBACV,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;qBACvD,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,0BAA0B,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;QACtE,OAAO,GAAG,CAAC;IACf,CAAC;IAED,MAAM,aAAa,GAAG,KAA6C,CAAC;IAEpE,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,0BAA0B,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAEzE,OAAO,GAAG,CAAC;AACf,CAAC,EAAE,EAAE,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {\n type IRecordForm,\n type RecordFormElementAttribute,\n type RecordFormElementsValue,\n type RecordFormElementsValueLinkValue,\n type RecordFormElementsValueStandardValue,\n} from '_ui/hooks/useGetRecordForm';\nimport {AttributeFormat, AttributeType} from '_ui/_gqlTypes';\nimport {type IDateRangeValue} from '@leav/utils';\nimport {type Store} from 'antd/lib/form/interface';\nimport dayjs from 'dayjs';\n\nconst hasDateRangeValues = (dateRange: unknown): dateRange is IDateRangeValue =>\n (dateRange as IDateRangeValue).from !== undefined && (dateRange as IDateRangeValue).to !== undefined;\n\nconst getCalculatedValue = values => values.find(value => value.isCalculated);\n\nconst getInheritedValue = values => values.find(value => value.isInherited);\n\nconst getUserInputValue = values =>\n values.find(value => !value.isInherited && !value.isCalculated && value.raw_payload !== null);\n\nconst isRecordFormElementsValueLinkValue = (\n value: RecordFormElementsValue,\n attribute: RecordFormElementAttribute,\n): value is RecordFormElementsValueLinkValue =>\n attribute.type === AttributeType.simple_link ||\n (attribute.type === AttributeType.advanced_link && attribute.multiple_values === false);\n\nconst isRecordFormElementsValueLinkValues = (\n values: RecordFormElementsValue[],\n attribute: RecordFormElementAttribute,\n): values is RecordFormElementsValueLinkValue[] =>\n attribute.type === AttributeType.advanced_link && attribute.multiple_values === true;\n\nconst isRecordFormElementsMultipleValues = (attribute: RecordFormElementAttribute) =>\n attribute.type === AttributeType.advanced && attribute.multiple_values === true;\n\nconst formatStandardInitialValue = (\n standardValue: RecordFormElementsValueStandardValue,\n attribute: RecordFormElementAttribute,\n) => {\n if (!standardValue?.raw_payload) {\n return getEmptyInitialValue(attribute);\n }\n\n switch (attribute.format) {\n case AttributeFormat.color:\n case AttributeFormat.text:\n case AttributeFormat.rich_text:\n case AttributeFormat.boolean:\n return standardValue.raw_payload;\n case AttributeFormat.numeric:\n return Number(standardValue.raw_payload);\n case AttributeFormat.date:\n return dayjs.unix(Number(standardValue.raw_payload));\n case AttributeFormat.date_range:\n if (hasDateRangeValues(standardValue.raw_payload)) {\n return [\n dayjs.unix(Number(standardValue.raw_payload.from)),\n dayjs.unix(Number(standardValue.raw_payload.to)),\n ];\n } else if (typeof standardValue.raw_payload === 'string') {\n const convertedFieldValue = JSON.parse(standardValue.raw_payload) as any;\n return [dayjs.unix(Number(convertedFieldValue.from)), dayjs.unix(Number(convertedFieldValue.to))];\n }\n }\n};\n\nexport const EMPTY_INITIAL_VALUE_STRING = '';\nexport const EMPTY_INITIAL_VALUE_UNDEFINED = undefined;\n\nexport const getEmptyInitialValue = (attribute: RecordFormElementAttribute) => {\n if ([AttributeFormat.date_range, AttributeFormat.color].includes(attribute.format)) {\n return EMPTY_INITIAL_VALUE_UNDEFINED;\n }\n return EMPTY_INITIAL_VALUE_STRING;\n};\n\nexport const getAntdDisplayedValue = (\n values: RecordFormElementsValueStandardValue[],\n attribute: RecordFormElementAttribute,\n) =>\n formatStandardInitialValue(\n getUserInputValue(values) ?? getInheritedValue(values) ?? getCalculatedValue(values) ?? null,\n attribute,\n );\n\nexport const getAntdFormInitialValues = (recordForm: IRecordForm) =>\n recordForm.elements.reduce<Store>((acc, {attribute, values}) => {\n if (!attribute) {\n return acc;\n }\n\n const value = getUserInputValue(values) ?? getInheritedValue(values) ?? getCalculatedValue(values) ?? null;\n\n if (isRecordFormElementsValueLinkValue(value, attribute)) {\n acc[attribute.id] = value?.linkValue?.id;\n return acc;\n }\n\n if (isRecordFormElementsValueLinkValues(values, attribute)) {\n acc[attribute.id] = values.map(val => val?.linkValue?.id ?? undefined);\n return acc;\n }\n\n if (isRecordFormElementsMultipleValues(attribute)) {\n const userInputValues = values.filter(val => val.id_value);\n const calculatedValues = values.filter(val => val.isCalculated);\n const inheritedValues = values.filter(val => val.isInherited);\n\n const effectiveValues =\n userInputValues.length > 0\n ? userInputValues\n : calculatedValues.length > 0\n ? calculatedValues\n : inheritedValues.length > 0\n ? inheritedValues\n : [];\n\n acc[attribute.id] =\n effectiveValues.length === 0\n ? [getEmptyInitialValue(attribute)]\n : effectiveValues\n .sort((a, b) => Number(a.id_value) - Number(b.id_value))\n .map(val => formatStandardInitialValue(val, attribute));\n return acc;\n }\n\n const standardValue = value as RecordFormElementsValueStandardValue;\n\n acc[attribute.id] = formatStandardInitialValue(standardValue, attribute);\n\n return acc;\n }, {});\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leav/ui",
3
- "version": "1.6.0-4feacea4",
3
+ "version": "1.6.0-68930d4c",
4
4
  "description": "Shared React components and hooks",
5
5
  "scripts": {
6
6
  "prepublishOnly": "yarn build",
@@ -28,7 +28,7 @@
28
28
  "@babel/preset-env": "7.28.5",
29
29
  "@babel/preset-react": "7.28.5",
30
30
  "@graphql-codegen/add": "5.0.3",
31
- "@graphql-codegen/cli": "6.1.0",
31
+ "@graphql-codegen/cli": "6.1.1",
32
32
  "@graphql-codegen/typescript": "5.0.7",
33
33
  "@graphql-codegen/typescript-operations": "5.0.7",
34
34
  "@graphql-codegen/typescript-react-apollo": "4.4.0",
@@ -44,7 +44,7 @@
44
44
  "@types/react": "18.2.14",
45
45
  "@types/react-dom": "18.2.6",
46
46
  "@types/react-table": "7.7.20",
47
- "aristid-ds": "14.0.0-1689e29",
47
+ "aristid-ds": "14.0.0-ee1e09c",
48
48
  "babel-jest": "29.3.1",
49
49
  "graphql": "16.12.0",
50
50
  "i18next": "22.5.1",
@@ -55,25 +55,22 @@
55
55
  "react-dom": "18.2.0",
56
56
  "react-i18next": "12",
57
57
  "react-router-dom": "6.22.0",
58
- "styled-components": "6.0.8",
59
58
  "ts-jest": "29.4.6",
60
59
  "tsc-alias": "1.8.16",
61
60
  "typescript": "5.5.3",
62
- "vite": "7.2.6"
61
+ "vite": "7.3.1"
63
62
  },
64
63
  "peerDependencies": {
65
- "@ant-design/icons": ">=5.2",
66
64
  "@apollo/client": ">=3.8.1",
67
- "aristid-ds": "14.0.0-1689e29",
68
- "dayjs": "^1.11.13",
69
- "i18next": "22.5",
70
- "react": "18.2.0",
71
- "react-dom": "18.2.0",
72
- "react-i18next": "12",
73
- "react-router-dom": "6.22.0",
74
- "styled-components": ">=5.3"
65
+ "aristid-ds": "^14.0.0-ee1e09c",
66
+ "i18next": ">=22.5.1",
67
+ "react": "^18.2.0",
68
+ "react-dom": "^18.2.0",
69
+ "react-i18next": ">=12",
70
+ "react-router-dom": "^6.22.0"
75
71
  },
76
72
  "dependencies": {
73
+ "@ant-design/icons": "5.2.6",
77
74
  "@ckeditor/ckeditor5-build-inline": "39.0.2",
78
75
  "@ckeditor/ckeditor5-react": "6.1.0",
79
76
  "@dnd-kit/core": "6.1.0",
@@ -85,6 +82,7 @@
85
82
  "@fortawesome/react-fontawesome": "3.0.2",
86
83
  "@leav/utils": "1.6.0",
87
84
  "@uidotdev/usehooks": "2.4.1",
85
+ "dayjs": "^1.11.13",
88
86
  "dompurify": "3.2.4",
89
87
  "html-react-parser": "4.2.10",
90
88
  "i18next-resources-to-backend": "1.1.4",
@@ -93,6 +91,7 @@
93
91
  "react-markdown": "5.0.3",
94
92
  "react-table": "7.8.0",
95
93
  "react-table-sticky": "1.1.3",
94
+ "styled-components": "6.0.8",
96
95
  "xlsx": "0.18.5",
97
96
  "zod": "3.25.76"
98
97
  }