@leav/ui 1.12.0-d2b12c32 → 1.12.0-e8c84be4

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.
@@ -0,0 +1,3 @@
1
+ export type Mockify<T> = {
2
+ [P in keyof T]?: T[P] extends (...args: any[]) => any ? jest.Mock<ReturnType<T[P]> extends never ? never : any> : T[P];
3
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/__mocks__/utils.ts"],"names":[],"mappings":"","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\nexport type Mockify<T> = {\n [P in keyof T]?: T[P] extends (...args: any[]) => any\n ? jest.Mock<ReturnType<T[P]> extends never ? never : any>\n : T[P];\n};\n"]}
@@ -1,2 +1,3 @@
1
- export declare const hasOnlyNoValueConditions: (attributeFormat: string) => boolean;
1
+ import { AttributeFormat } from '../../_gqlTypes';
2
+ export declare const hasOnlyNoValueConditions: (attributeFormat: AttributeFormat) => boolean;
2
3
  export declare const nullValueConditions: import("../../_gqlTypes").RecordFilterCondition[];
@@ -1 +1 @@
1
- {"version":3,"file":"conditionsHelper.js","sourceRoot":"","sources":["../../../src/components/Explorer/conditionsHelper.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAC,wBAAwB,EAAC,MAAM,WAAW,CAAC;AAEnD,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,eAAuB,EAAW,EAAE,CACzE,CAAC,eAAe,CAAC,KAAK,EAAE,eAAe,CAAC,UAAU,EAAE,eAAe,CAAC,SAAS,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAC7G,eAAe,CAClB,CAAC;AAEN,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAC/B,wBAAwB,CAAC,QAAQ;IACjC,wBAAwB,CAAC,YAAY;IACrC,wBAAwB,CAAC,KAAK;IAC9B,wBAAwB,CAAC,QAAQ;IACjC,wBAAwB,CAAC,SAAS;IAClC,wBAAwB,CAAC,UAAU;IACnC,wBAAwB,CAAC,UAAU;CACtC,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 {AttributeFormat} from '_ui/_gqlTypes';\nimport {AttributeConditionFilter} from '_ui/types';\n\nexport const hasOnlyNoValueConditions = (attributeFormat: string): boolean =>\n [AttributeFormat.color, AttributeFormat.date_range, AttributeFormat.encrypted, AttributeFormat.extended].includes(\n attributeFormat,\n );\n\nexport const nullValueConditions = [\n AttributeConditionFilter.IS_EMPTY,\n AttributeConditionFilter.IS_NOT_EMPTY,\n AttributeConditionFilter.TODAY,\n AttributeConditionFilter.TOMORROW,\n AttributeConditionFilter.YESTERDAY,\n AttributeConditionFilter.LAST_MONTH,\n AttributeConditionFilter.NEXT_MONTH,\n];\n"]}
1
+ {"version":3,"file":"conditionsHelper.js","sourceRoot":"","sources":["../../../src/components/Explorer/conditionsHelper.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAC,wBAAwB,EAAC,MAAM,WAAW,CAAC;AAEnD,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,eAAgC,EAAW,EAAE,CAClF,CAAC,eAAe,CAAC,KAAK,EAAE,eAAe,CAAC,UAAU,EAAE,eAAe,CAAC,SAAS,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAC7G,eAAe,CAClB,CAAC;AAEN,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAC/B,wBAAwB,CAAC,QAAQ;IACjC,wBAAwB,CAAC,YAAY;IACrC,wBAAwB,CAAC,KAAK;IAC9B,wBAAwB,CAAC,QAAQ;IACjC,wBAAwB,CAAC,SAAS;IAClC,wBAAwB,CAAC,UAAU;IACnC,wBAAwB,CAAC,UAAU;CACtC,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 {AttributeFormat} from '_ui/_gqlTypes';\nimport {AttributeConditionFilter} from '_ui/types';\n\nexport const hasOnlyNoValueConditions = (attributeFormat: AttributeFormat): boolean =>\n [AttributeFormat.color, AttributeFormat.date_range, AttributeFormat.encrypted, AttributeFormat.extended].includes(\n attributeFormat,\n );\n\nexport const nullValueConditions = [\n AttributeConditionFilter.IS_EMPTY,\n AttributeConditionFilter.IS_NOT_EMPTY,\n AttributeConditionFilter.TODAY,\n AttributeConditionFilter.TOMORROW,\n AttributeConditionFilter.YESTERDAY,\n AttributeConditionFilter.LAST_MONTH,\n AttributeConditionFilter.NEXT_MONTH,\n];\n"]}
@@ -1,2 +1,3 @@
1
- export declare const hasOnlyNoValueConditions: (attributeFormat: string) => boolean;
1
+ import { AttributeFormat } from '../../_gqlTypes';
2
+ export declare const hasOnlyNoValueConditions: (attributeFormat: AttributeFormat) => boolean;
2
3
  export declare const nullValueConditions: import("../../_gqlTypes").RecordFilterCondition[];
@@ -1 +1 @@
1
- {"version":3,"file":"conditionsHelper.js","sourceRoot":"","sources":["../../../src/components/Filters/conditionsHelper.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAC,wBAAwB,EAAC,MAAM,WAAW,CAAC;AAEnD,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,eAAuB,EAAW,EAAE,CACzE,CAAC,eAAe,CAAC,KAAK,EAAE,eAAe,CAAC,UAAU,EAAE,eAAe,CAAC,SAAS,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAC7G,eAAe,CAClB,CAAC;AAEN,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAC/B,wBAAwB,CAAC,QAAQ;IACjC,wBAAwB,CAAC,YAAY;IACrC,wBAAwB,CAAC,KAAK;IAC9B,wBAAwB,CAAC,QAAQ;IACjC,wBAAwB,CAAC,SAAS;IAClC,wBAAwB,CAAC,UAAU;IACnC,wBAAwB,CAAC,UAAU;CACtC,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 {AttributeFormat} from '_ui/_gqlTypes';\nimport {AttributeConditionFilter} from '_ui/types';\n\nexport const hasOnlyNoValueConditions = (attributeFormat: string): boolean =>\n [AttributeFormat.color, AttributeFormat.date_range, AttributeFormat.encrypted, AttributeFormat.extended].includes(\n attributeFormat,\n );\n\nexport const nullValueConditions = [\n AttributeConditionFilter.IS_EMPTY,\n AttributeConditionFilter.IS_NOT_EMPTY,\n AttributeConditionFilter.TODAY,\n AttributeConditionFilter.TOMORROW,\n AttributeConditionFilter.YESTERDAY,\n AttributeConditionFilter.LAST_MONTH,\n AttributeConditionFilter.NEXT_MONTH,\n];\n"]}
1
+ {"version":3,"file":"conditionsHelper.js","sourceRoot":"","sources":["../../../src/components/Filters/conditionsHelper.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAC,wBAAwB,EAAC,MAAM,WAAW,CAAC;AAEnD,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,eAAgC,EAAW,EAAE,CAClF,CAAC,eAAe,CAAC,KAAK,EAAE,eAAe,CAAC,UAAU,EAAE,eAAe,CAAC,SAAS,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAC7G,eAAe,CAClB,CAAC;AAEN,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAC/B,wBAAwB,CAAC,QAAQ;IACjC,wBAAwB,CAAC,YAAY;IACrC,wBAAwB,CAAC,KAAK;IAC9B,wBAAwB,CAAC,QAAQ;IACjC,wBAAwB,CAAC,SAAS;IAClC,wBAAwB,CAAC,UAAU;IACnC,wBAAwB,CAAC,UAAU;CACtC,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 {AttributeFormat} from '_ui/_gqlTypes';\nimport {AttributeConditionFilter} from '_ui/types';\n\nexport const hasOnlyNoValueConditions = (attributeFormat: AttributeFormat): boolean =>\n [AttributeFormat.color, AttributeFormat.date_range, AttributeFormat.encrypted, AttributeFormat.extended].includes(\n attributeFormat,\n );\n\nexport const nullValueConditions = [\n AttributeConditionFilter.IS_EMPTY,\n AttributeConditionFilter.IS_NOT_EMPTY,\n AttributeConditionFilter.TODAY,\n AttributeConditionFilter.TOMORROW,\n AttributeConditionFilter.YESTERDAY,\n AttributeConditionFilter.LAST_MONTH,\n AttributeConditionFilter.NEXT_MONTH,\n];\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CommonFilterItem.js","sourceRoot":"","sources":["../../../../src/components/Filters/filter-items/CommonFilterItem.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,cAAc,EAAC,MAAM,4CAA4C,CAAC;AAC1E,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,SAAS,EAAC,MAAM,YAAY,CAAC;AACrC,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAC,4BAA4B,EAAC,MAA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AEpB,uEAAuE;IACvE,IAAI,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,QAAQ,GAAG,KAAK,CAAC;QAEjB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAChB,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC;YACtB,MAAM,CAAC,cAAc,GAAG,CAAC,CAAC,eAAe,CAAC,CAAC;QAC/C,CAAC;IACL,CAAC;IAED,OAAO,CACH,KAAC,YAAY,IACT,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,CAAC,QAAQ,EACrB,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,KAAK,EAC7B,MAAM,EAAE,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,EAClC,aAAa,EAAE;YACX,SAAS,EAAE,YAAY;YACvB,cAAc,EAAE,GAAG,EAAE,CAAC,KAAC,cAAc,IAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,QAAQ,GAAI;SACrG,EACD,eAAe,SACjB,CACL,CAAC;AACN,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 {type FunctionComponent} from 'react';\nimport {FilterDropDown} from '../filter-items/filter-type/FilterDropDown';\nimport styled from 'styled-components';\nimport {KitFilter} from 'aristid-ds';\nimport {AttributeFormat} from '_ui/_gqlTypes';\nimport {getAttributeConditionOptions} from '../filter-items/filter-type/useConditionOptionsByType';\nimport {type TFunction} from 'i18next';\nimport {nullValueConditions} from '../conditionsHelper';\nimport {\n isUIFilterStandard,\n isUIFilterTree,\n isUIFilterWithSmartFilter,\n type IUIFilterStandard,\n type UIFilter,\n} from '../_types';\nimport {ACTIVE_ATTRIBUTE_ID} from '_ui/constants';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\n\nconst FilterStyled = styled(KitFilter)`\n flex: 0 0 auto;\n`;\nconst getFilterValues = (filter: UIFilter, t: TFunction): string[] => {\n if (filter.condition && nullValueConditions.includes(filter.condition)) {\n const conditionOption = getAttributeConditionOptions(t).find(option => option.value === filter.condition);\n return [conditionOption?.label ?? ''];\n }\n\n const filterValues: string[] = filter.withEmptyValues ? [t('filters.empty-value')] : [];\n\n if (isUIFilterTree(filter) || isUIFilterWithSmartFilter(filter)) {\n return [...filterValues, ...(filter.formattedValue ?? [])];\n }\n\n if (\n isUIFilterStandard(filter) &&\n [AttributeFormat.date, AttributeFormat.boolean].includes(filter.attribute.format)\n ) {\n return filter.formattedValue ? [...filterValues, filter.formattedValue] : filterValues;\n }\n\n const valuesList = filter.attribute.valuesList;\n if (!valuesList || !('linkedValues' in valuesList) || !filter.value) {\n return filterValues;\n }\n\n const valuesFilter = Array.isArray(filter.value) ? filter.value : [filter.value];\n const labels = (valuesList.linkedValues ?? [])\n .filter(val => valuesFilter.includes(val?.id))\n .map(val => val?.whoAmI?.label ?? '');\n return [...filterValues, ...labels];\n};\n\nexport interface ICommonFilterProps {\n filter: UIFilter;\n isPinned?: boolean;\n disabled?: boolean;\n readonly?: boolean;\n}\n\nconst isActiveAttribute = (filter: UIFilter): filter is IUIFilterStandard =>\n filter.attribute.format === AttributeFormat.boolean &&\n filter.attribute.id === ACTIVE_ATTRIBUTE_ID &&\n isUIFilterStandard(filter);\n\nexport const CommonFilterItem: FunctionComponent<ICommonFilterProps> = ({\n filter,\n isPinned = false,\n readonly = false,\n disabled,\n}) => {\n const {t} = useSharedTranslation();\n\n let canReset = true;\n\n // Active attribute is a special case, we need to handle it differently\n if (isActiveAttribute(filter)) {\n canReset = false;\n\n if (!filter.value) {\n filter.value = 'true';\n filter.formattedValue = t('explorer.true');\n }\n }\n\n return (\n <FilterStyled\n disabled={disabled}\n readonly={readonly}\n expandable={!readonly}\n label={filter.attribute.label}\n values={getFilterValues(filter, t)}\n dropDownProps={{\n placement: 'bottomLeft',\n dropdownRender: () => <FilterDropDown filter={filter} canReset={canReset} canRemove={!isPinned} />,\n }}\n showSingleValue\n />\n );\n};\n"]}
1
+ {"version":3,"file":"CommonFilterItem.js","sourceRoot":"","sources":["../../../../src/components/Filters/filter-items/CommonFilterItem.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,cAAc,EAAC,MAAM,4CAA4C,CAAC;AAC1E,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,SAAS,EAAC,MAAM,YAAY,CAAC;AACrC,OAAO,EAAC,eAAe,EAA6B,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAC,4BAA4B,EAAC,MAAM,uDAAuD,CAAC;AAEnG,OAAO,EAAC,mBAAmB,EAAC,MAAM,qBAAqB,CAAC;AACxD,OAAO,EACH,kBAAkB,EAClB,cAAc,EACd,yBAAyB,GAG5B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAC,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAClD,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAEpE,MAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;;CAErC,CAAC;AACF,MAAM,eAAe,GAAG,CAAC,MAAgB,EAAE,CAAY,EAAY,EAAE;IACjE,IAAI,MAAM,CAAC,SAAS,IAAI,mBAAmB,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAkC,CAAC,EAAE,CAAC;QAC9F,MAAM,eAAe,GAAG,4BAA4B,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,MAAM,CAAC,SAAS,CAAC,CAAC;QAC1G,OAAO,CAAC,eAAe,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,YAAY,GAAa,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAA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MAAM,iBAAiB,GAAG,CAAC,MAAgB,EAA+B,EAAE,CACxE,MAAM,CAAC,SAAS,CAAC,MAAM,KAAK,eAAe,CAAC,OAAO;IACnD,MAAM,CAAC,SAAS,CAAC,EAAE,KAAK,mBAAmB;IAC3C,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAE/B,MAAM,CAAC,MAAM,gBAAgB,GAA0C,CAAC,EACpE,MAAM,EACN,QAAQ,GAAG,KAAK,EAChB,QAAQ,GAAG,KAAK,EAChB,QAAQ,GACX,EAAE,EAAE;IACD,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,IAAI,QAAQ,GAAG,IAAI,CAAC;IAEpB,uEAAuE;IACvE,IAAI,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,QAAQ,GAAG,KAAK,CAAC;QAEjB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAChB,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC;YACtB,MAAM,CAAC,cAAc,GAAG,CAAC,CAAC,eAAe,CAAC,CAAC;QAC/C,CAAC;IACL,CAAC;IAED,OAAO,CACH,KAAC,YAAY,IACT,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,CAAC,QAAQ,EACrB,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,KAAK,EAC7B,MAAM,EAAE,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,EAClC,aAAa,EAAE;YACX,SAAS,EAAE,YAAY;YACvB,cAAc,EAAE,GAAG,EAAE,CAAC,KAAC,cAAc,IAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,QAAQ,GAAI;SACrG,EACD,eAAe,SACjB,CACL,CAAC;AACN,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 {type FunctionComponent} from 'react';\nimport {FilterDropDown} from '../filter-items/filter-type/FilterDropDown';\nimport styled from 'styled-components';\nimport {KitFilter} from 'aristid-ds';\nimport {AttributeFormat, type RecordFilterCondition} from '_ui/_gqlTypes';\nimport {getAttributeConditionOptions} from '../filter-items/filter-type/useConditionOptionsByType';\nimport {type TFunction} from 'i18next';\nimport {nullValueConditions} from '../conditionsHelper';\nimport {\n isUIFilterStandard,\n isUIFilterTree,\n isUIFilterWithSmartFilter,\n type IUIFilterStandard,\n type UIFilter,\n} from '../_types';\nimport {ACTIVE_ATTRIBUTE_ID} from '_ui/constants';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\n\nconst FilterStyled = styled(KitFilter)`\n flex: 0 0 auto;\n`;\nconst getFilterValues = (filter: UIFilter, t: TFunction): string[] => {\n if (filter.condition && nullValueConditions.includes(filter.condition as RecordFilterCondition)) {\n const conditionOption = getAttributeConditionOptions(t).find(option => option.value === filter.condition);\n return [conditionOption?.label ?? ''];\n }\n\n const filterValues: string[] = filter.withEmptyValues ? [t('filters.empty-value')] : [];\n\n if (isUIFilterTree(filter) || isUIFilterWithSmartFilter(filter)) {\n return [...filterValues, ...(filter.formattedValue ?? [])];\n }\n\n if (\n isUIFilterStandard(filter) &&\n [AttributeFormat.date, AttributeFormat.boolean].includes(filter.attribute.format)\n ) {\n return filter.formattedValue ? [...filterValues, filter.formattedValue] : filterValues;\n }\n\n const valuesList = filter.attribute.valuesList;\n if (!valuesList || !('linkedValues' in valuesList) || !filter.value) {\n return filterValues;\n }\n\n const valuesFilter = Array.isArray(filter.value) ? filter.value : [filter.value];\n const labels = (valuesList.linkedValues ?? [])\n .filter(val => valuesFilter.includes(val?.id))\n .map(val => val?.whoAmI?.label ?? '');\n return [...filterValues, ...labels];\n};\n\nexport interface ICommonFilterProps {\n filter: UIFilter;\n isPinned?: boolean;\n disabled?: boolean;\n readonly?: boolean;\n}\n\nconst isActiveAttribute = (filter: UIFilter): filter is IUIFilterStandard =>\n filter.attribute.format === AttributeFormat.boolean &&\n filter.attribute.id === ACTIVE_ATTRIBUTE_ID &&\n isUIFilterStandard(filter);\n\nexport const CommonFilterItem: FunctionComponent<ICommonFilterProps> = ({\n filter,\n isPinned = false,\n readonly = false,\n disabled,\n}) => {\n const {t} = useSharedTranslation();\n\n let canReset = true;\n\n // Active attribute is a special case, we need to handle it differently\n if (isActiveAttribute(filter)) {\n canReset = false;\n\n if (!filter.value) {\n filter.value = 'true';\n filter.formattedValue = t('explorer.true');\n }\n }\n\n return (\n <FilterStyled\n disabled={disabled}\n readonly={readonly}\n expandable={!readonly}\n label={filter.attribute.label}\n values={getFilterValues(filter, t)}\n dropDownProps={{\n placement: 'bottomLeft',\n dropdownRender: () => <FilterDropDown filter={filter} canReset={canReset} canRemove={!isPinned} />,\n }}\n showSingleValue\n />\n );\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"useConditionOptionsByType.js","sourceRoot":"","sources":["../../../../../src/components/Filters/filter-items/filter-type/useConditionOptionsByType.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,eAAe,EAA6B,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAC,wBAAwB,EAA2D,MAAM,WAAW,CAAC;AAE7G,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EACH,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,mBAAmB,GAEtB,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,kBAAkB,GAAqD;IAChF,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE;QACpB,wBAAwB,CAAC,QAAQ;QACjC,wBAAwB,CAAC,YAAY;QACrC,wBAAwB,CAAC,KAAK;QAC9B,wBAAwB,CAAC,SAAS;QAClC,wBAAwB,CAAC,UAAU;QACnC,wBAAwB,CAAC,QAAQ;QAC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AC,CAAC;KACV,CAAC;AACN,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 {AttributeFormat, type RecordFilterCondition} from '_ui/_gqlTypes';\nimport {AttributeConditionFilter, type AttributeConditionType, type ThroughConditionFilter} from '_ui/types';\nimport {type TFunction} from 'i18next';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {\n isUIFilterLink,\n isUIFilterStandard,\n isUIFilterThrough,\n isUIFilterTree,\n isUIFilterValueList,\n type UIFilter,\n} from '../../_types';\n\nexport const conditionsByFormat: Record<AttributeFormat, RecordFilterCondition[]> = {\n [AttributeFormat.text]: [\n AttributeConditionFilter.CONTAINS,\n AttributeConditionFilter.NOT_CONTAINS,\n AttributeConditionFilter.EQUAL,\n AttributeConditionFilter.NOT_EQUAL,\n AttributeConditionFilter.BEGIN_WITH,\n AttributeConditionFilter.END_WITH,\n AttributeConditionFilter.IS_EMPTY,\n AttributeConditionFilter.IS_NOT_EMPTY,\n ],\n [AttributeFormat.rich_text]: [\n AttributeConditionFilter.CONTAINS,\n AttributeConditionFilter.NOT_CONTAINS,\n AttributeConditionFilter.IS_EMPTY,\n AttributeConditionFilter.IS_NOT_EMPTY,\n ],\n [AttributeFormat.boolean]: [],\n [AttributeFormat.date]: [\n AttributeConditionFilter.EQUAL,\n AttributeConditionFilter.NOT_EQUAL,\n AttributeConditionFilter.GREATER_THAN,\n AttributeConditionFilter.LESS_THAN,\n AttributeConditionFilter.IS_EMPTY,\n AttributeConditionFilter.IS_NOT_EMPTY,\n AttributeConditionFilter.TODAY,\n AttributeConditionFilter.TOMORROW,\n AttributeConditionFilter.YESTERDAY,\n AttributeConditionFilter.LAST_MONTH,\n AttributeConditionFilter.NEXT_MONTH,\n AttributeConditionFilter.BETWEEN,\n ],\n [AttributeFormat.date_range]: [AttributeConditionFilter.IS_EMPTY, AttributeConditionFilter.IS_NOT_EMPTY],\n [AttributeFormat.encrypted]: [AttributeConditionFilter.IS_EMPTY, AttributeConditionFilter.IS_NOT_EMPTY],\n [AttributeFormat.extended]: [AttributeConditionFilter.IS_EMPTY, AttributeConditionFilter.IS_NOT_EMPTY],\n [AttributeFormat.color]: [],\n [AttributeFormat.numeric]: [\n AttributeConditionFilter.EQUAL,\n AttributeConditionFilter.NOT_EQUAL,\n AttributeConditionFilter.IS_EMPTY,\n AttributeConditionFilter.IS_NOT_EMPTY,\n AttributeConditionFilter.LESS_THAN,\n AttributeConditionFilter.GREATER_THAN,\n ],\n};\n\nexport const linkFilterConditions: Array<RecordFilterCondition | ThroughConditionFilter> = [\n // disable NOT_EQUAL for now because of backend condition filter issue\n ...conditionsByFormat[AttributeFormat.text].filter(f => f !== AttributeConditionFilter.NOT_EQUAL),\n AttributeConditionFilter.THROUGH,\n];\nexport const treeFilterConditions: RecordFilterCondition[] = [AttributeConditionFilter.EQUAL];\nexport const valueListTextConditions: RecordFilterCondition[] = [AttributeConditionFilter.EQUAL];\n\ninterface IUIFilterConditionOption<T> {\n label: string;\n value: T;\n textByFormat?: {[key in AttributeFormat]?: string};\n}\n\nexport const getAttributeConditionOptions = (t: TFunction): Array<IUIFilterConditionOption<AttributeConditionType>> => [\n {label: t('filters.contains'), value: AttributeConditionFilter.CONTAINS},\n {label: t('filters.not-contains'), value: AttributeConditionFilter.NOT_CONTAINS},\n {label: t('filters.equal'), value: AttributeConditionFilter.EQUAL},\n {label: t('filters.not-equal'), value: AttributeConditionFilter.NOT_EQUAL},\n {label: t('filters.begin-with'), value: AttributeConditionFilter.BEGIN_WITH},\n {label: t('filters.end-with'), value: AttributeConditionFilter.END_WITH},\n {\n label: t('filters.less-than'),\n textByFormat: {[AttributeFormat.date]: String(t('filters.before'))},\n value: AttributeConditionFilter.LESS_THAN,\n },\n {\n label: t('filters.greater-than'),\n textByFormat: {[AttributeFormat.date]: String(t('filters.after'))},\n value: AttributeConditionFilter.GREATER_THAN,\n },\n {label: t('filters.today'), value: AttributeConditionFilter.TODAY},\n {label: t('filters.tomorrow'), value: AttributeConditionFilter.TOMORROW},\n {label: t('filters.yesterday'), value: AttributeConditionFilter.YESTERDAY},\n {label: t('filters.last-month'), value: AttributeConditionFilter.LAST_MONTH},\n {label: t('filters.next-month'), value: AttributeConditionFilter.NEXT_MONTH},\n {label: t('filters.between'), value: AttributeConditionFilter.BETWEEN},\n {label: t('filters.start-on'), value: AttributeConditionFilter.START_ON},\n {label: t('filters.start-after'), value: AttributeConditionFilter.START_AFTER},\n {label: t('filters.start-before'), value: AttributeConditionFilter.START_BEFORE},\n {label: t('filters.end-on'), value: AttributeConditionFilter.END_ON},\n {label: t('filters.end-after'), value: AttributeConditionFilter.END_AFTER},\n {label: t('filters.end-before'), value: AttributeConditionFilter.END_BEFORE},\n {label: t('filters.is-empty'), value: AttributeConditionFilter.IS_EMPTY},\n {label: t('filters.is-not-empty'), value: AttributeConditionFilter.IS_NOT_EMPTY},\n {label: t('filters.values-count-equal'), value: AttributeConditionFilter.VALUES_COUNT_EQUAL},\n {label: t('filters.values-count-greater-than'), value: AttributeConditionFilter.VALUES_COUNT_GREATER_THAN},\n {label: t('filters.values-count-lower-than'), value: AttributeConditionFilter.VALUES_COUNT_LOWER_THAN},\n {label: t('filters.through'), value: AttributeConditionFilter.THROUGH},\n];\n\nexport const getFirstConditionByFilterType = (\n filter: UIFilter,\n): Array<RecordFilterCondition | ThroughConditionFilter> => {\n if (isUIFilterValueList(filter)) {\n return valueListTextConditions;\n }\n if (isUIFilterStandard(filter)) {\n return conditionsByFormat[filter.attribute.format] ?? [];\n }\n if (isUIFilterLink(filter)) {\n return linkFilterConditions ?? [];\n }\n if (isUIFilterTree(filter)) {\n return treeFilterConditions ?? [];\n }\n if (isUIFilterThrough(filter)) {\n return [AttributeConditionFilter.THROUGH];\n }\n return [];\n};\n\nexport const useConditionsOptionsByType = (filter: UIFilter) => {\n const {t} = useSharedTranslation();\n\n return {\n conditionOptionsByType: getAttributeConditionOptions(t)\n .filter(({value}) => {\n // Use special condition set for text fields with closed list values\n if (isUIFilterValueList(filter)) {\n return valueListTextConditions.includes(value);\n }\n if (isUIFilterStandard(filter)) {\n return conditionsByFormat[filter.attribute.format].includes(value);\n }\n if (isUIFilterLink(filter) || isUIFilterThrough(filter)) {\n return linkFilterConditions.includes(value);\n }\n if (isUIFilterTree(filter)) {\n return treeFilterConditions.includes(value);\n }\n })\n .map(option => ({\n ...option,\n label:\n isUIFilterStandard(filter) && option.textByFormat?.[filter.attribute.format]\n ? option.textByFormat?.[filter.attribute.format]\n : option.label,\n })),\n };\n};\n"]}
1
+ {"version":3,"file":"useConditionOptionsByType.js","sourceRoot":"","sources":["../../../../../src/components/Filters/filter-items/filter-type/useConditionOptionsByType.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,eAAe,EAA6B,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAC,wBAAwB,EAA2D,MAAM,WAAW,CAAC;AAE7G,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EACH,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,mBAAmB,GAEtB,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,kBAAkB,GAAqD;IAChF,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE;QACpB,wBAAwB,CAAC,QAAQ;QACjC,wBAAwB,CAAC,YAAY;QACrC,wBAAwB,CAAC,KAAK;QAC9B,wBAAwB,CAAC,SAAS;QAClC,wBAAwB,CAAC,UAAU;QACnC,wBAAwB,CAAC,QAAQ;QACjC,wBAAwB,CAAC,QAAQ;QACjC,wBAAwB,CAAC,YAAY;KACxC;IACD,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE;QACzB,wBAAwB,CAAC,QAAQ;QACjC,wBAAwB,CAAC,YAAY;QACrC,wBAAwB,CAAC,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AAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,OAAO;QACH,sBAAsB,EAAE,4BAA4B,CAAC,CAAC,CAAC;aAClD,MAAM,CAAC,CAAC,EAAC,KAAK,EAAC,EAAE,EAAE;YAChB,oEAAoE;YACpE,IAAI,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC9B,OAAO,uBAAuB,CAAC,QAAQ,CAAC,KAA8B,CAAC,CAAC;YAC5E,CAAC;YACD,IAAI,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC7B,OAAO,kBAAkB,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,KAA8B,CAAC,CAAC;YAChG,CAAC;YACD,IAAI,cAAc,CAAC,MAAM,CAAC,IAAI,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC;gBACtD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAChD,CAAC;YACD,IAAI,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;gBACzB,OAAO,oBAAoB,CAAC,QAAQ,CAAC,KAA8B,CAAC,CAAC;YACzE,CAAC;QACL,CAAC,CAAC;aACD,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACZ,GAAG,MAAM;YACT,KAAK,EACD,kBAAkB,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC;gBACxE,CAAC,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC;gBAChD,CAAC,CAAC,MAAM,CAAC,KAAK;SACzB,CAAC,CAAC;KACV,CAAC;AACN,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 {AttributeFormat, type RecordFilterCondition} from '_ui/_gqlTypes';\nimport {AttributeConditionFilter, type AttributeConditionType, type ThroughConditionFilter} from '_ui/types';\nimport {type TFunction} from 'i18next';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {\n isUIFilterLink,\n isUIFilterStandard,\n isUIFilterThrough,\n isUIFilterTree,\n isUIFilterValueList,\n type UIFilter,\n} from '../../_types';\n\nexport const conditionsByFormat: Record<AttributeFormat, RecordFilterCondition[]> = {\n [AttributeFormat.text]: [\n AttributeConditionFilter.CONTAINS,\n AttributeConditionFilter.NOT_CONTAINS,\n AttributeConditionFilter.EQUAL,\n AttributeConditionFilter.NOT_EQUAL,\n AttributeConditionFilter.BEGIN_WITH,\n AttributeConditionFilter.END_WITH,\n AttributeConditionFilter.IS_EMPTY,\n AttributeConditionFilter.IS_NOT_EMPTY,\n ],\n [AttributeFormat.rich_text]: [\n AttributeConditionFilter.CONTAINS,\n AttributeConditionFilter.NOT_CONTAINS,\n AttributeConditionFilter.IS_EMPTY,\n AttributeConditionFilter.IS_NOT_EMPTY,\n ],\n [AttributeFormat.boolean]: [],\n [AttributeFormat.date]: [\n AttributeConditionFilter.EQUAL,\n AttributeConditionFilter.NOT_EQUAL,\n AttributeConditionFilter.GREATER_THAN,\n AttributeConditionFilter.LESS_THAN,\n AttributeConditionFilter.IS_EMPTY,\n AttributeConditionFilter.IS_NOT_EMPTY,\n AttributeConditionFilter.TODAY,\n AttributeConditionFilter.TOMORROW,\n AttributeConditionFilter.YESTERDAY,\n AttributeConditionFilter.LAST_MONTH,\n AttributeConditionFilter.NEXT_MONTH,\n AttributeConditionFilter.BETWEEN,\n ],\n [AttributeFormat.date_range]: [AttributeConditionFilter.IS_EMPTY, AttributeConditionFilter.IS_NOT_EMPTY],\n [AttributeFormat.encrypted]: [AttributeConditionFilter.IS_EMPTY, AttributeConditionFilter.IS_NOT_EMPTY],\n [AttributeFormat.extended]: [AttributeConditionFilter.IS_EMPTY, AttributeConditionFilter.IS_NOT_EMPTY],\n [AttributeFormat.color]: [],\n [AttributeFormat.numeric]: [\n AttributeConditionFilter.EQUAL,\n AttributeConditionFilter.NOT_EQUAL,\n AttributeConditionFilter.IS_EMPTY,\n AttributeConditionFilter.IS_NOT_EMPTY,\n AttributeConditionFilter.LESS_THAN,\n AttributeConditionFilter.GREATER_THAN,\n ],\n};\n\nexport const linkFilterConditions: Array<RecordFilterCondition | ThroughConditionFilter> = [\n // disable NOT_EQUAL for now because of backend condition filter issue\n ...conditionsByFormat[AttributeFormat.text].filter(f => f !== AttributeConditionFilter.NOT_EQUAL),\n AttributeConditionFilter.THROUGH,\n];\nexport const treeFilterConditions: RecordFilterCondition[] = [AttributeConditionFilter.EQUAL];\nexport const valueListTextConditions: RecordFilterCondition[] = [AttributeConditionFilter.EQUAL];\n\ninterface IUIFilterConditionOption<T> {\n label: string;\n value: T;\n textByFormat?: {[key in AttributeFormat]?: string};\n}\n\nexport const getAttributeConditionOptions = (t: TFunction): Array<IUIFilterConditionOption<AttributeConditionType>> => [\n {label: t('filters.contains'), value: AttributeConditionFilter.CONTAINS},\n {label: t('filters.not-contains'), value: AttributeConditionFilter.NOT_CONTAINS},\n {label: t('filters.equal'), value: AttributeConditionFilter.EQUAL},\n {label: t('filters.not-equal'), value: AttributeConditionFilter.NOT_EQUAL},\n {label: t('filters.begin-with'), value: AttributeConditionFilter.BEGIN_WITH},\n {label: t('filters.end-with'), value: AttributeConditionFilter.END_WITH},\n {\n label: t('filters.less-than'),\n textByFormat: {[AttributeFormat.date]: String(t('filters.before'))},\n value: AttributeConditionFilter.LESS_THAN,\n },\n {\n label: t('filters.greater-than'),\n textByFormat: {[AttributeFormat.date]: String(t('filters.after'))},\n value: AttributeConditionFilter.GREATER_THAN,\n },\n {label: t('filters.today'), value: AttributeConditionFilter.TODAY},\n {label: t('filters.tomorrow'), value: AttributeConditionFilter.TOMORROW},\n {label: t('filters.yesterday'), value: AttributeConditionFilter.YESTERDAY},\n {label: t('filters.last-month'), value: AttributeConditionFilter.LAST_MONTH},\n {label: t('filters.next-month'), value: AttributeConditionFilter.NEXT_MONTH},\n {label: t('filters.between'), value: AttributeConditionFilter.BETWEEN},\n {label: t('filters.start-on'), value: AttributeConditionFilter.START_ON},\n {label: t('filters.start-after'), value: AttributeConditionFilter.START_AFTER},\n {label: t('filters.start-before'), value: AttributeConditionFilter.START_BEFORE},\n {label: t('filters.end-on'), value: AttributeConditionFilter.END_ON},\n {label: t('filters.end-after'), value: AttributeConditionFilter.END_AFTER},\n {label: t('filters.end-before'), value: AttributeConditionFilter.END_BEFORE},\n {label: t('filters.is-empty'), value: AttributeConditionFilter.IS_EMPTY},\n {label: t('filters.is-not-empty'), value: AttributeConditionFilter.IS_NOT_EMPTY},\n {label: t('filters.values-count-equal'), value: AttributeConditionFilter.VALUES_COUNT_EQUAL},\n {label: t('filters.values-count-greater-than'), value: AttributeConditionFilter.VALUES_COUNT_GREATER_THAN},\n {label: t('filters.values-count-lower-than'), value: AttributeConditionFilter.VALUES_COUNT_LOWER_THAN},\n {label: t('filters.through'), value: AttributeConditionFilter.THROUGH},\n];\n\nexport const getFirstConditionByFilterType = (\n filter: UIFilter,\n): Array<RecordFilterCondition | ThroughConditionFilter> => {\n if (isUIFilterValueList(filter)) {\n return valueListTextConditions;\n }\n if (isUIFilterStandard(filter)) {\n return conditionsByFormat[filter.attribute.format] ?? [];\n }\n if (isUIFilterLink(filter)) {\n return linkFilterConditions ?? [];\n }\n if (isUIFilterTree(filter)) {\n return treeFilterConditions ?? [];\n }\n if (isUIFilterThrough(filter)) {\n return [AttributeConditionFilter.THROUGH];\n }\n return [];\n};\n\nexport const useConditionsOptionsByType = (filter: UIFilter) => {\n const {t} = useSharedTranslation();\n\n return {\n conditionOptionsByType: getAttributeConditionOptions(t)\n .filter(({value}) => {\n // Use special condition set for text fields with closed list values\n if (isUIFilterValueList(filter)) {\n return valueListTextConditions.includes(value as RecordFilterCondition);\n }\n if (isUIFilterStandard(filter)) {\n return conditionsByFormat[filter.attribute.format].includes(value as RecordFilterCondition);\n }\n if (isUIFilterLink(filter) || isUIFilterThrough(filter)) {\n return linkFilterConditions.includes(value);\n }\n if (isUIFilterTree(filter)) {\n return treeFilterConditions.includes(value as RecordFilterCondition);\n }\n })\n .map(option => ({\n ...option,\n label:\n isUIFilterStandard(filter) && option.textByFormat?.[filter.attribute.format]\n ? option.textByFormat?.[filter.attribute.format]\n : option.label,\n })),\n };\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"useTransformFilters.js","sourceRoot":"","sources":["../../../src/components/Filters/useTransformFilters.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAGH,eAAe,EACf,aAAa,EAKb,qBAAqB,GAGxB,MAAM,eAAe,CAAC;AAgBvB,OAAO,EAAC,sBAAsB,EAAC,MAAM,WAAW,CAAC;AACjD,OAAO,EAAC,eAAe,EAAE,mBAAmB,EAAE,eAAe,EAAC,MAAM,0BAA0B,CAAC;AAC/F,OAAO,EAAC,oBAAoB,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,uBAAuB,EAAC,MAAM,sDAAsD,CAAC;AAC7F,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,mBAAmB,GAAG,CAAC,MAA4C,EAA8B,EAAE,CACrG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;AAEnB,MAAM,0BAA0B,GAAG,CAAC,MAAmB,EAAqC,EAAE,CAC1F,MAAM,CAAC,SAAS,KAAK,sBAAsB,CAAC,OAAO,IAAI,CAAC,CAAC,MAAM,CAAC,YAAY,IAAI,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;AAEtG,MAAM,qCAAqC,GAAG,CAC1C,MAAmB,EACnB,SAA6E,EACe,EAAE,CAC9F,uBAAuB,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC;IAClD,CAAC,aAAa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AAM,CAAC,SAAS,IAAI,qBAAqB,CAAC,KAAK;gBAC1D,eAAe,EAAE,MAAM,CAAC,eAAe,IAAI,KAAK;aACnD,CAAC;YACF,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACxB,CAAC;QAED,OAAO,GAAG,CAAC;IACf,CAAC,EAAE,EAAE,CAAC,CAAC;IAEX,OAAO;QACH,cAAc;QACd,WAAW;KACd,CAAC;AACN,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 AttributeDetailsLinkAttributeFragment,\n type AttributeDetailsTreeAttributeFragment,\n AttributeFormat,\n AttributeType,\n type ExplorerAttributesQuery,\n type ExplorerLinkAttributeQuery,\n type GetViewsListQuery,\n type LinkAttributeDetailsFragment,\n RecordFilterCondition,\n type StandardAttributeDetailsFragment,\n type ViewDetailsFilterFragment,\n} from '_ui/_gqlTypes';\nimport {\n type UIFilter,\n type IUIFilterBaseAttribute,\n type IUIFilterLink,\n type IUIFilterLinkValueList,\n type IUIFilterStandard,\n type IUIFilterStandardValueList,\n type IUIFilterThrough,\n type IUIFilterTree,\n type ValidFieldFilter,\n type ValidFieldFilterLinkValuesList,\n type ValidFieldFilterStandardValuesList,\n type ValidFieldFilterThrough,\n type ValidFilter,\n} from './_types';\nimport {ThroughConditionFilter} from '_ui/types';\nimport {isLinkAttribute, isStandardAttribute, isTreeAttribute} from '_ui/_utils/attributeType';\nimport {localizedTranslation} from '@leav/utils';\nimport {useLang} from '_ui/hooks';\nimport {valueListTextConditions} from './filter-items/filter-type/useConditionOptionsByType';\nimport dayjs from 'dayjs';\nimport {type TFunction} from 'i18next';\nimport {type ITreeFilters} from './context/useGetTreeFilters';\n\nconst _isValidFieldFilter = (filter: ViewDetailsFilterFragment | UIFilter): filter is ValidFieldFilter =>\n !!filter.field;\n\nconst _isValidFieldFilterThrough = (filter: ValidFilter): filter is ValidFieldFilterThrough =>\n filter.condition === ThroughConditionFilter.THROUGH && !!filter.subCondition && !!filter.subField;\n\nconst _isValidFieldFilterStandardValuesList = (\n filter: ValidFilter,\n attribute: NonNullable<ExplorerAttributesQuery['attributes']>['list'][number],\n): filter is ValidFieldFilterStandardValuesList & {attribute: StandardAttributeDetailsFragment} =>\n valueListTextConditions.includes(filter.condition) &&\n [AttributeType.simple, AttributeType.advanced].includes(attribute.type) &&\n 'valuesList' in attribute &&\n !!attribute.valuesList?.enable;\n\nconst _isValidFieldFilterLinkValuesList = (\n filter: ValidFilter,\n attribute: NonNullable<ExplorerAttributesQuery['attributes']>['list'][number],\n): filter is ValidFieldFilterLinkValuesList & {attribute: LinkAttributeDetailsFragment} =>\n valueListTextConditions.includes(filter.condition) &&\n [AttributeType.simple_link, AttributeType.advanced_link].includes(attribute.type) &&\n 'valuesList' in attribute &&\n !!attribute.valuesList?.enable;\n\ntype AttributeDetailsLinkAttributeWithPermissionsFragment = AttributeDetailsLinkAttributeFragment & {\n permissions: {\n access_attribute: boolean;\n };\n};\ntype AttributeDetailsTreeAttributeWithPermissionsFragment = AttributeDetailsTreeAttributeFragment & {\n permissions: {\n access_attribute: boolean;\n };\n};\n\nexport const isLinkAttributeDetails = (\n linkAttributeData: NonNullable<ExplorerLinkAttributeQuery['attributes']>['list'][number],\n): linkAttributeData is LinkAttributeDetailsFragment & {\n id: string;\n multiple_values: boolean;\n permissions: {\n access_attribute: boolean;\n edit_value: boolean;\n };\n} => 'linked_library' in linkAttributeData;\n\nexport type ValidFiltersArgument = GetViewsListQuery['views']['list'][number]['filters'] | UIFilter[];\n\nexport type AttributesById = Record<string, NonNullable<ExplorerAttributesQuery['attributes']>['list'][number]>;\n\nexport const useTransformFilters = () => {\n const {lang} = useLang();\n\n const toValidFilters = (filters: ValidFiltersArgument): ValidFilter[] =>\n (filters ?? []).reduce<ValidFilter[]>((acc, filter) => {\n if (!_isValidFieldFilter(filter)) {\n return acc;\n }\n const _isThroughFilter = filter.field.includes('.');\n\n if (_isThroughFilter) {\n // Hack because view filters does not have the necessary data to be transformed directly to UI filter,\n // we need to split the field to get the subCondition and subField for through filter, may be fix after LEAVC-569\n const [field, ...subFields] = filter.field.split('.');\n const throughFilter: ValidFieldFilterThrough = {\n field,\n subField: subFields.join('.'),\n value: filter.value ?? null,\n hidden: filter.hidden ?? false,\n condition: ThroughConditionFilter.THROUGH,\n subCondition: filter.condition,\n };\n acc.push(throughFilter);\n } else {\n acc.push(filter);\n }\n\n return acc;\n }, []);\n\n const toUIFilters = ({\n filters,\n treeFilters,\n attributesDataById,\n t,\n }: {\n filters: ValidFilter[];\n treeFilters: ITreeFilters;\n attributesDataById: AttributesById;\n t: TFunction;\n }): UIFilter[] =>\n (filters ?? []).reduce<UIFilter[]>((acc, filter) => {\n if (!attributesDataById[filter.field]) {\n console.warn(`Attribute ${filter.field} from user view not found in database.`);\n return acc;\n }\n\n const filterAttributeBase: IUIFilterBaseAttribute = {\n id: attributesDataById[filter.field].id,\n label: localizedTranslation(attributesDataById[filter.field].label, lang),\n type: attributesDataById[filter.field].type,\n };\n\n // filter is standardFilter\n if (isStandardAttribute(filterAttributeBase.type)) {\n const attributeData = attributesDataById[filter.field];\n if (_isValidFieldFilterStandardValuesList(filter, attributeData)) {\n const newFilter: IUIFilterStandardValueList = {\n field: filter.field,\n // TODO : save filter values as string[] when filter and handle fields with libraries\n value: filter.value ? [filter.value] : [],\n hidden: filter.hidden ?? false,\n id: window.crypto.randomUUID(),\n condition: (filter.condition as RecordFilterCondition) ?? null,\n attribute: {\n ...filterAttributeBase,\n format: attributeData.format!,\n valuesList: (attributeData as StandardAttributeDetailsFragment).valuesList!,\n },\n withEmptyValues: filter.withEmptyValues ?? false,\n };\n acc.push(newFilter);\n } else {\n let formattedValue: string;\n if (attributeData.format === AttributeFormat.boolean && filter.value) {\n formattedValue = filter.value === 'true' ? t('explorer.true') : t('explorer.false');\n }\n\n if (attributeData.format === AttributeFormat.date && filter.value) {\n formattedValue = dayjs(filter.value).format('YYYY-MM-DD');\n }\n\n const newFilter: IUIFilterStandard = {\n field: filter.field,\n value: filter.value ?? null,\n formattedValue,\n hidden: filter.hidden ?? false,\n id: window.crypto.randomUUID(),\n condition: (filter.condition as RecordFilterCondition) ?? null,\n attribute: {\n ...filterAttributeBase,\n format: attributeData.format!,\n },\n withEmptyValues: filter.withEmptyValues ?? false,\n };\n acc.push(newFilter);\n }\n }\n\n if (isLinkAttribute(filterAttributeBase.type)) {\n const attributeData = attributesDataById[\n filter.field\n ] as AttributeDetailsLinkAttributeWithPermissionsFragment;\n if (_isValidFieldFilterThrough(filter)) {\n const newFilter: IUIFilterThrough = {\n field: filter.field,\n value: filter.value ?? null,\n hidden: filter.hidden ?? false,\n id: window.crypto.randomUUID(),\n condition: filter.condition,\n attribute: {\n ...filterAttributeBase,\n linkedLibrary: attributeData.linked_library!,\n smartFilter: attributeData.smart_filter ?? undefined,\n },\n subCondition: filter.subCondition ?? null,\n subField: filter.subField,\n };\n acc.push(newFilter);\n } else if (_isValidFieldFilterLinkValuesList(filter, attributeData)) {\n const newFilter: IUIFilterLinkValueList = {\n field: filter.field,\n // TODO : save filter values as string[] when filter and handle fields with libraries\n value: filter.value ? [filter.value] : [],\n hidden: filter.hidden ?? false,\n id: window.crypto.randomUUID(),\n condition: filter.condition,\n attribute: {\n ...filterAttributeBase,\n linkedLibrary: attributeData.linked_library!,\n valuesList: (attributeData as LinkAttributeDetailsFragment).valuesList!,\n smartFilter: attributeData.smart_filter ?? undefined,\n },\n withEmptyValues: filter.withEmptyValues ?? false,\n };\n\n acc.push(newFilter);\n } else {\n const newFilter: IUIFilterLink = {\n field: filter.field,\n value: filter.value ?? null,\n hidden: filter.hidden ?? false,\n id: window.crypto.randomUUID(),\n condition: filter.condition,\n attribute: {\n ...filterAttributeBase,\n linkedLibrary: attributeData.linked_library!,\n smartFilter: attributeData.smart_filter ?? undefined,\n },\n };\n\n acc.push(newFilter);\n }\n }\n\n if (isTreeAttribute(filterAttributeBase.type) && !_isValidFieldFilterThrough(filter)) {\n const attributeData = attributesDataById[\n filter.field\n ] as AttributeDetailsTreeAttributeWithPermissionsFragment;\n const newFilter: IUIFilterTree = {\n field: [filter.field],\n // TODO : save filter values as string[] when tree filter and handle fields with libraries\n value: filter.value\n ? [filter.value]\n : treeFilters[filter.field]\n ? treeFilters[filter.field].map(tree => tree.value)\n : null,\n formattedValue: filter.value\n ? [filter.value]\n : treeFilters[filter.field]\n ? treeFilters[filter.field].map(tree => tree.label)\n : undefined,\n nodes: filter.value\n ? undefined\n : treeFilters[filter.field]\n ? treeFilters[filter.field].map(tree => ({libraryId: tree.libraryId, nodeId: tree.nodeId}))\n : undefined,\n hidden: filter.hidden ?? false,\n id: window.crypto.randomUUID(),\n attribute: {\n ...filterAttributeBase,\n linkedTree: attributeData.linked_tree!,\n },\n condition: filter.condition ?? RecordFilterCondition.EQUAL,\n withEmptyValues: filter.withEmptyValues ?? false,\n };\n acc.push(newFilter);\n }\n\n return acc;\n }, []);\n\n return {\n toValidFilters,\n toUIFilters,\n };\n};\n"]}
1
+ {"version":3,"file":"useTransformFilters.js","sourceRoot":"","sources":["../../../src/components/Filters/useTransformFilters.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAGH,eAAe,EACf,aAAa,EAKb,qBAAqB,GAGxB,MAAM,eAAe,CAAC;AAgBvB,OAAO,EAAC,sBAAsB,EAAC,MAAM,WAAW,CAAC;AACjD,OAAO,EAAC,eAAe,EAAE,mBAAmB,EAAE,eAAe,EAAC,MAAM,0BAA0B,CAAC;AAC/F,OAAO,EAAC,oBAAoB,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,uBAAuB,EAAC,MAAM,sDAAsD,CAAC;AAC7F,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,mBAAmB,GAA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AC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAC,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAC,CAAC,CAAC;wBAC3F,CAAC,CAAC,SAAS;gBACjB,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,KAAK;gBAC9B,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE;gBAC9B,SAAS,EAAE;oBACP,GAAG,mBAAmB;oBACtB,UAAU,EAAE,aAAa,CAAC,WAAY;iBACzC;gBACD,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,qBAAqB,CAAC,KAAK;gBAC1D,eAAe,EAAE,MAAM,CAAC,eAAe,IAAI,KAAK;aACnD,CAAC;YACF,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACxB,CAAC;QAED,OAAO,GAAG,CAAC;IACf,CAAC,EAAE,EAAE,CAAC,CAAC;IAEX,OAAO;QACH,cAAc;QACd,WAAW;KACd,CAAC;AACN,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 AttributeDetailsLinkAttributeFragment,\n type AttributeDetailsTreeAttributeFragment,\n AttributeFormat,\n AttributeType,\n type ExplorerAttributesQuery,\n type ExplorerLinkAttributeQuery,\n type GetViewsListQuery,\n type LinkAttributeDetailsFragment,\n RecordFilterCondition,\n type StandardAttributeDetailsFragment,\n type ViewDetailsFilterFragment,\n} from '_ui/_gqlTypes';\nimport {\n type UIFilter,\n type IUIFilterBaseAttribute,\n type IUIFilterLink,\n type IUIFilterLinkValueList,\n type IUIFilterStandard,\n type IUIFilterStandardValueList,\n type IUIFilterThrough,\n type IUIFilterTree,\n type ValidFieldFilter,\n type ValidFieldFilterLinkValuesList,\n type ValidFieldFilterStandardValuesList,\n type ValidFieldFilterThrough,\n type ValidFilter,\n} from './_types';\nimport {ThroughConditionFilter} from '_ui/types';\nimport {isLinkAttribute, isStandardAttribute, isTreeAttribute} from '_ui/_utils/attributeType';\nimport {localizedTranslation} from '@leav/utils';\nimport {useLang} from '_ui/hooks';\nimport {valueListTextConditions} from './filter-items/filter-type/useConditionOptionsByType';\nimport dayjs from 'dayjs';\nimport {type TFunction} from 'i18next';\nimport {type ITreeFilters} from './context/useGetTreeFilters';\n\nconst _isValidFieldFilter = (filter: ViewDetailsFilterFragment | UIFilter): filter is ValidFieldFilter =>\n !!filter.field;\n\nconst _isValidFieldFilterThrough = (filter: ValidFilter): filter is ValidFieldFilterThrough =>\n filter.condition === ThroughConditionFilter.THROUGH && !!filter.subCondition && !!filter.subField;\n\nconst _isValidFieldFilterStandardValuesList = (\n filter: ValidFilter,\n attribute: NonNullable<ExplorerAttributesQuery['attributes']>['list'][number],\n): filter is ValidFieldFilterStandardValuesList & {attribute: StandardAttributeDetailsFragment} =>\n valueListTextConditions.includes(filter.condition as RecordFilterCondition) &&\n [AttributeType.simple, AttributeType.advanced].includes(attribute.type) &&\n 'valuesList' in attribute &&\n !!attribute.valuesList?.enable;\n\nconst _isValidFieldFilterLinkValuesList = (\n filter: ValidFilter,\n attribute: NonNullable<ExplorerAttributesQuery['attributes']>['list'][number],\n): filter is ValidFieldFilterLinkValuesList & {attribute: LinkAttributeDetailsFragment} =>\n valueListTextConditions.includes(filter.condition as RecordFilterCondition) &&\n [AttributeType.simple_link, AttributeType.advanced_link].includes(attribute.type) &&\n 'valuesList' in attribute &&\n !!attribute.valuesList?.enable;\n\ntype AttributeDetailsLinkAttributeWithPermissionsFragment = AttributeDetailsLinkAttributeFragment & {\n permissions: {\n access_attribute: boolean;\n };\n};\ntype AttributeDetailsTreeAttributeWithPermissionsFragment = AttributeDetailsTreeAttributeFragment & {\n permissions: {\n access_attribute: boolean;\n };\n};\n\nexport const isLinkAttributeDetails = (\n linkAttributeData: NonNullable<ExplorerLinkAttributeQuery['attributes']>['list'][number],\n): linkAttributeData is LinkAttributeDetailsFragment & {\n id: string;\n multiple_values: boolean;\n permissions: {\n access_attribute: boolean;\n edit_value: boolean;\n };\n} => 'linked_library' in linkAttributeData;\n\nexport type ValidFiltersArgument = GetViewsListQuery['views']['list'][number]['filters'] | UIFilter[];\n\nexport type AttributesById = Record<string, NonNullable<ExplorerAttributesQuery['attributes']>['list'][number]>;\n\nexport const useTransformFilters = () => {\n const {lang} = useLang();\n\n const toValidFilters = (filters: ValidFiltersArgument): ValidFilter[] =>\n (filters ?? []).reduce<ValidFilter[]>((acc, filter) => {\n if (!_isValidFieldFilter(filter)) {\n return acc;\n }\n const _isThroughFilter = filter.field.includes('.');\n\n if (_isThroughFilter) {\n // Hack because view filters does not have the necessary data to be transformed directly to UI filter,\n // we need to split the field to get the subCondition and subField for through filter, may be fix after LEAVC-569\n const [field, ...subFields] = filter.field.split('.');\n const throughFilter: ValidFieldFilterThrough = {\n field,\n subField: subFields.join('.'),\n value: filter.value ?? null,\n hidden: filter.hidden ?? false,\n condition: ThroughConditionFilter.THROUGH,\n subCondition: filter.condition,\n };\n acc.push(throughFilter);\n } else {\n acc.push(filter);\n }\n\n return acc;\n }, []);\n\n const toUIFilters = ({\n filters,\n treeFilters,\n attributesDataById,\n t,\n }: {\n filters: ValidFilter[];\n treeFilters: ITreeFilters;\n attributesDataById: AttributesById;\n t: TFunction;\n }): UIFilter[] =>\n (filters ?? []).reduce<UIFilter[]>((acc, filter) => {\n if (!attributesDataById[filter.field]) {\n console.warn(`Attribute ${filter.field} from user view not found in database.`);\n return acc;\n }\n\n const filterAttributeBase: IUIFilterBaseAttribute = {\n id: attributesDataById[filter.field].id,\n label: localizedTranslation(attributesDataById[filter.field].label, lang),\n type: attributesDataById[filter.field].type,\n };\n\n // filter is standardFilter\n if (isStandardAttribute(filterAttributeBase.type)) {\n const attributeData = attributesDataById[filter.field];\n if (_isValidFieldFilterStandardValuesList(filter, attributeData)) {\n const newFilter: IUIFilterStandardValueList = {\n field: filter.field,\n // TODO : save filter values as string[] when filter and handle fields with libraries\n value: filter.value ? [filter.value] : [],\n hidden: filter.hidden ?? false,\n id: window.crypto.randomUUID(),\n condition: (filter.condition as RecordFilterCondition) ?? null,\n attribute: {\n ...filterAttributeBase,\n format: attributeData.format!,\n valuesList: (attributeData as StandardAttributeDetailsFragment).valuesList!,\n },\n withEmptyValues: filter.withEmptyValues ?? false,\n };\n acc.push(newFilter);\n } else {\n let formattedValue: string;\n if (attributeData.format === AttributeFormat.boolean && filter.value) {\n formattedValue = filter.value === 'true' ? t('explorer.true') : t('explorer.false');\n }\n\n if (attributeData.format === AttributeFormat.date && filter.value) {\n formattedValue = dayjs(filter.value).format('YYYY-MM-DD');\n }\n\n const newFilter: IUIFilterStandard = {\n field: filter.field,\n value: filter.value ?? null,\n formattedValue,\n hidden: filter.hidden ?? false,\n id: window.crypto.randomUUID(),\n condition: (filter.condition as RecordFilterCondition) ?? null,\n attribute: {\n ...filterAttributeBase,\n format: attributeData.format!,\n },\n withEmptyValues: filter.withEmptyValues ?? false,\n };\n acc.push(newFilter);\n }\n }\n\n if (isLinkAttribute(filterAttributeBase.type)) {\n const attributeData = attributesDataById[\n filter.field\n ] as AttributeDetailsLinkAttributeWithPermissionsFragment;\n if (_isValidFieldFilterThrough(filter)) {\n const newFilter: IUIFilterThrough = {\n field: filter.field,\n value: filter.value ?? null,\n hidden: filter.hidden ?? false,\n id: window.crypto.randomUUID(),\n condition: filter.condition,\n attribute: {\n ...filterAttributeBase,\n linkedLibrary: attributeData.linked_library!,\n smartFilter: attributeData.smart_filter ?? undefined,\n },\n subCondition: filter.subCondition ?? null,\n subField: filter.subField,\n };\n acc.push(newFilter);\n } else if (_isValidFieldFilterLinkValuesList(filter, attributeData)) {\n const newFilter: IUIFilterLinkValueList = {\n field: filter.field,\n // TODO : save filter values as string[] when filter and handle fields with libraries\n value: filter.value ? [filter.value] : [],\n hidden: filter.hidden ?? false,\n id: window.crypto.randomUUID(),\n condition: filter.condition,\n attribute: {\n ...filterAttributeBase,\n linkedLibrary: attributeData.linked_library!,\n valuesList: (attributeData as LinkAttributeDetailsFragment).valuesList!,\n smartFilter: attributeData.smart_filter ?? undefined,\n },\n withEmptyValues: filter.withEmptyValues ?? false,\n };\n\n acc.push(newFilter);\n } else {\n const newFilter: IUIFilterLink = {\n field: filter.field,\n value: filter.value ?? null,\n hidden: filter.hidden ?? false,\n id: window.crypto.randomUUID(),\n condition: filter.condition,\n attribute: {\n ...filterAttributeBase,\n linkedLibrary: attributeData.linked_library!,\n smartFilter: attributeData.smart_filter ?? undefined,\n },\n };\n\n acc.push(newFilter);\n }\n }\n\n if (isTreeAttribute(filterAttributeBase.type) && !_isValidFieldFilterThrough(filter)) {\n const attributeData = attributesDataById[\n filter.field\n ] as AttributeDetailsTreeAttributeWithPermissionsFragment;\n const newFilter: IUIFilterTree = {\n field: [filter.field],\n // TODO : save filter values as string[] when tree filter and handle fields with libraries\n value: filter.value\n ? [filter.value]\n : treeFilters[filter.field]\n ? treeFilters[filter.field].map(tree => tree.value)\n : null,\n formattedValue: filter.value\n ? [filter.value]\n : treeFilters[filter.field]\n ? treeFilters[filter.field].map(tree => tree.label)\n : undefined,\n nodes: filter.value\n ? undefined\n : treeFilters[filter.field]\n ? treeFilters[filter.field].map(tree => ({libraryId: tree.libraryId, nodeId: tree.nodeId}))\n : undefined,\n hidden: filter.hidden ?? false,\n id: window.crypto.randomUUID(),\n attribute: {\n ...filterAttributeBase,\n linkedTree: attributeData.linked_tree!,\n },\n condition: filter.condition ?? RecordFilterCondition.EQUAL,\n withEmptyValues: filter.withEmptyValues ?? false,\n };\n acc.push(newFilter);\n }\n\n return acc;\n }, []);\n\n return {\n toValidFilters,\n toUIFilters,\n };\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"useSharedTranslation.js","sourceRoot":"","sources":["../../../../src/hooks/useSharedTranslation/__mocks__/useSharedTranslation.ts"],"names":[],"mappings":"AAMA,MAAM,QAAQ,GAAkB;IAC5B,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE;QACL,WAAW,EAAE,CAAC,IAAI,CAAC;KACtB;IACD,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;CAC5B,CAAC;AAEF,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAEzG,eAAe,GAAG,EAAE;IAChB,MAAM,IAAI,GAAG,EAAC,CAAC,EAAE,KAAuB,EAAE,IAAI,EAAE,QAAgB,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC;IAE/E,OAAO,IAAI,CAAC;AAChB,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 {type Mockify} from '@leav/utils';\nimport {type TFunction, type i18n} from 'i18next';\n\nconst mockI18n: Mockify<i18n> = {\n language: 'fr',\n options: {\n fallbackLng: ['en'],\n },\n changeLanguage: jest.fn(),\n};\n\nconst mockT = (arg, variables) => `${[arg, ...(!!variables ? Object.values(variables) : [])].join('|')}`;\n\nexport default () => {\n const mock = {t: mockT as TFunction<any>, i18n: mockI18n as i18n, ready: true};\n\n return mock;\n};\n"]}
1
+ {"version":3,"file":"useSharedTranslation.js","sourceRoot":"","sources":["../../../../src/hooks/useSharedTranslation/__mocks__/useSharedTranslation.ts"],"names":[],"mappings":"AAMA,MAAM,QAAQ,GAAkB;IAC5B,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE;QACL,WAAW,EAAE,CAAC,IAAI,CAAC;KACtB;IACD,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;CAC5B,CAAC;AAEF,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAEzG,eAAe,GAAG,EAAE;IAChB,MAAM,IAAI,GAAG,EAAC,CAAC,EAAE,KAAuB,EAAE,IAAI,EAAE,QAAgB,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC;IAE/E,OAAO,IAAI,CAAC;AAChB,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 {type Mockify} from '_ui/__mocks__/utils';\nimport {type TFunction, type i18n} from 'i18next';\n\nconst mockI18n: Mockify<i18n> = {\n language: 'fr',\n options: {\n fallbackLng: ['en'],\n },\n changeLanguage: jest.fn(),\n};\n\nconst mockT = (arg, variables) => `${[arg, ...(!!variables ? Object.values(variables) : [])].join('|')}`;\n\nexport default () => {\n const mock = {t: mockT as TFunction<any>, i18n: mockI18n as i18n, ready: true};\n\n return mock;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leav/ui",
3
- "version": "1.12.0-d2b12c32",
3
+ "version": "1.12.0-e8c84be4",
4
4
  "description": "Shared React components and hooks",
5
5
  "scripts": {
6
6
  "prepublishOnly": "yarn build",
@@ -29,9 +29,9 @@
29
29
  "@babel/preset-react": "7.28.5",
30
30
  "@graphql-codegen/add": "5.0.3",
31
31
  "@graphql-codegen/cli": "6.2.1",
32
- "@graphql-codegen/typescript": "5.0.9",
32
+ "@graphql-codegen/typescript": "5.0.10",
33
33
  "@graphql-codegen/typescript-operations": "5.0.9",
34
- "@graphql-codegen/typescript-react-apollo": "4.4.1",
34
+ "@graphql-codegen/typescript-react-apollo": "4.4.2",
35
35
  "@testing-library/jest-dom": "5.17.0",
36
36
  "@testing-library/react": "14.3.1",
37
37
  "@testing-library/react-hooks": "8.0.1",
@@ -42,7 +42,7 @@
42
42
  "@types/lodash.isequal": "^4",
43
43
  "@types/react": "18.2.14",
44
44
  "@types/react-dom": "18.2.6",
45
- "aristid-ds": "15.3.1-637817c",
45
+ "aristid-ds": "15.3.1-886678",
46
46
  "babel-jest": "29.7.0",
47
47
  "graphql": "16.13.2",
48
48
  "i18next": "22.5.1",