@akinon/akifilter 0.5.4 → 1.0.1

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.
Files changed (160) hide show
  1. package/README.md +44 -0
  2. package/dist/cjs/akifilter.d.ts +53 -0
  3. package/dist/cjs/akifilter.d.ts.map +1 -0
  4. package/dist/cjs/akifilter.js +360 -0
  5. package/dist/cjs/common/storage.d.ts +10 -0
  6. package/dist/cjs/common/storage.d.ts.map +1 -0
  7. package/dist/cjs/common/storage.js +124 -0
  8. package/dist/cjs/common/theme-overrides.d.ts +3 -0
  9. package/dist/cjs/common/theme-overrides.d.ts.map +1 -0
  10. package/dist/cjs/common/theme-overrides.js +6 -0
  11. package/dist/cjs/components/applied-filters.d.ts +14 -0
  12. package/dist/cjs/components/applied-filters.d.ts.map +1 -0
  13. package/dist/cjs/components/applied-filters.js +26 -0
  14. package/dist/cjs/components/filter-toolbar.d.ts +11 -0
  15. package/dist/cjs/components/filter-toolbar.d.ts.map +1 -0
  16. package/dist/cjs/components/filter-toolbar.js +17 -0
  17. package/dist/cjs/components/visibility-modal.d.ts +19 -0
  18. package/dist/cjs/components/visibility-modal.d.ts.map +1 -0
  19. package/dist/cjs/components/visibility-modal.js +30 -0
  20. package/dist/cjs/constants.d.ts +4 -0
  21. package/dist/cjs/constants.d.ts.map +1 -0
  22. package/dist/cjs/constants.js +6 -0
  23. package/dist/cjs/hooks/use-debounced-value.d.ts +2 -0
  24. package/dist/cjs/hooks/use-debounced-value.d.ts.map +1 -0
  25. package/dist/cjs/hooks/use-debounced-value.js +17 -0
  26. package/dist/cjs/i18n/index.d.ts +2 -4
  27. package/dist/cjs/i18n/index.d.ts.map +1 -1
  28. package/dist/cjs/i18n/index.js +1 -1
  29. package/dist/cjs/i18n/translations/en.d.ts +33 -3
  30. package/dist/cjs/i18n/translations/en.d.ts.map +1 -1
  31. package/dist/cjs/i18n/translations/en.js +33 -3
  32. package/dist/cjs/i18n/translations/tr.d.ts +33 -3
  33. package/dist/cjs/i18n/translations/tr.d.ts.map +1 -1
  34. package/dist/cjs/i18n/translations/tr.js +33 -3
  35. package/dist/cjs/index.d.ts +3 -14
  36. package/dist/cjs/index.d.ts.map +1 -1
  37. package/dist/cjs/index.js +17 -32
  38. package/dist/cjs/styles.css +179 -0
  39. package/dist/cjs/types.d.ts +11 -0
  40. package/dist/cjs/types.d.ts.map +1 -0
  41. package/dist/cjs/types.js +2 -0
  42. package/dist/cjs/utils/schema.d.ts +9 -0
  43. package/dist/cjs/utils/schema.d.ts.map +1 -0
  44. package/dist/cjs/utils/schema.js +61 -0
  45. package/dist/cjs/utils/values.d.ts +5 -0
  46. package/dist/cjs/utils/values.d.ts.map +1 -0
  47. package/dist/cjs/utils/values.js +44 -0
  48. package/dist/esm/akifilter.d.ts +53 -0
  49. package/dist/esm/akifilter.d.ts.map +1 -0
  50. package/dist/esm/akifilter.js +356 -0
  51. package/dist/esm/common/storage.d.ts +10 -0
  52. package/dist/esm/common/storage.d.ts.map +1 -0
  53. package/dist/esm/common/storage.js +114 -0
  54. package/dist/esm/common/theme-overrides.d.ts +3 -0
  55. package/dist/esm/common/theme-overrides.d.ts.map +1 -0
  56. package/dist/esm/common/theme-overrides.js +3 -0
  57. package/dist/esm/components/applied-filters.d.ts +14 -0
  58. package/dist/esm/components/applied-filters.d.ts.map +1 -0
  59. package/dist/esm/components/applied-filters.js +22 -0
  60. package/dist/esm/components/filter-toolbar.d.ts +11 -0
  61. package/dist/esm/components/filter-toolbar.d.ts.map +1 -0
  62. package/dist/esm/components/filter-toolbar.js +13 -0
  63. package/dist/esm/components/visibility-modal.d.ts +19 -0
  64. package/dist/esm/components/visibility-modal.d.ts.map +1 -0
  65. package/dist/esm/components/visibility-modal.js +26 -0
  66. package/dist/esm/constants.d.ts +4 -0
  67. package/dist/esm/constants.d.ts.map +1 -0
  68. package/dist/esm/constants.js +3 -0
  69. package/dist/esm/hooks/use-debounced-value.d.ts +2 -0
  70. package/dist/esm/hooks/use-debounced-value.d.ts.map +1 -0
  71. package/dist/esm/hooks/use-debounced-value.js +13 -0
  72. package/dist/esm/i18n/index.d.ts +2 -4
  73. package/dist/esm/i18n/index.d.ts.map +1 -1
  74. package/dist/esm/i18n/index.js +5 -5
  75. package/dist/esm/i18n/translations/en.d.ts +33 -3
  76. package/dist/esm/i18n/translations/en.d.ts.map +1 -1
  77. package/dist/esm/i18n/translations/en.js +33 -3
  78. package/dist/esm/i18n/translations/tr.d.ts +33 -3
  79. package/dist/esm/i18n/translations/tr.d.ts.map +1 -1
  80. package/dist/esm/i18n/translations/tr.js +33 -3
  81. package/dist/esm/index.d.ts +3 -14
  82. package/dist/esm/index.d.ts.map +1 -1
  83. package/dist/esm/index.js +3 -30
  84. package/dist/esm/styles.css +179 -0
  85. package/dist/esm/types.d.ts +11 -0
  86. package/dist/esm/types.d.ts.map +1 -0
  87. package/dist/esm/types.js +1 -0
  88. package/dist/esm/utils/schema.d.ts +9 -0
  89. package/dist/esm/utils/schema.d.ts.map +1 -0
  90. package/dist/esm/utils/schema.js +52 -0
  91. package/dist/esm/utils/values.d.ts +5 -0
  92. package/dist/esm/utils/values.d.ts.map +1 -0
  93. package/dist/esm/utils/values.js +39 -0
  94. package/package.json +39 -33
  95. package/dist/cjs/components/AppliedFilters/AppliedFilterItem.d.ts +0 -12
  96. package/dist/cjs/components/AppliedFilters/AppliedFilterItem.d.ts.map +0 -1
  97. package/dist/cjs/components/AppliedFilters/AppliedFilterItem.js +0 -62
  98. package/dist/cjs/components/AppliedFilters/common.d.ts +0 -6
  99. package/dist/cjs/components/AppliedFilters/common.d.ts.map +0 -1
  100. package/dist/cjs/components/AppliedFilters/common.js +0 -34
  101. package/dist/cjs/components/AppliedFilters/index.d.ts +0 -4
  102. package/dist/cjs/components/AppliedFilters/index.d.ts.map +0 -1
  103. package/dist/cjs/components/AppliedFilters/index.js +0 -26
  104. package/dist/cjs/components/AppliedFilters/styles.css +0 -65
  105. package/dist/cjs/components/ConditionalFilters/index.d.ts +0 -3
  106. package/dist/cjs/components/ConditionalFilters/index.d.ts.map +0 -1
  107. package/dist/cjs/components/ConditionalFilters/index.js +0 -32
  108. package/dist/cjs/components/FilterContext/index.d.ts +0 -45
  109. package/dist/cjs/components/FilterContext/index.d.ts.map +0 -1
  110. package/dist/cjs/components/FilterContext/index.js +0 -85
  111. package/dist/cjs/components/SelectShownFilters/index.d.ts +0 -7
  112. package/dist/cjs/components/SelectShownFilters/index.d.ts.map +0 -1
  113. package/dist/cjs/components/SelectShownFilters/index.js +0 -111
  114. package/dist/cjs/components/SelectShownFilters/styles.css +0 -99
  115. package/dist/cjs/components/ShownFilters/index.d.ts +0 -3
  116. package/dist/cjs/components/ShownFilters/index.d.ts.map +0 -1
  117. package/dist/cjs/components/ShownFilters/index.js +0 -45
  118. package/dist/cjs/components/index.d.ts +0 -6
  119. package/dist/cjs/components/index.d.ts.map +0 -1
  120. package/dist/cjs/components/index.js +0 -21
  121. package/dist/cjs/constants/index.d.ts +0 -56
  122. package/dist/cjs/constants/index.d.ts.map +0 -1
  123. package/dist/cjs/constants/index.js +0 -58
  124. package/dist/cjs/index.css +0 -67
  125. package/dist/cjs/utils/index.d.ts +0 -25
  126. package/dist/cjs/utils/index.d.ts.map +0 -1
  127. package/dist/cjs/utils/index.js +0 -40
  128. package/dist/esm/components/AppliedFilters/AppliedFilterItem.d.ts +0 -12
  129. package/dist/esm/components/AppliedFilters/AppliedFilterItem.d.ts.map +0 -1
  130. package/dist/esm/components/AppliedFilters/AppliedFilterItem.js +0 -58
  131. package/dist/esm/components/AppliedFilters/common.d.ts +0 -6
  132. package/dist/esm/components/AppliedFilters/common.d.ts.map +0 -1
  133. package/dist/esm/components/AppliedFilters/common.js +0 -29
  134. package/dist/esm/components/AppliedFilters/index.d.ts +0 -4
  135. package/dist/esm/components/AppliedFilters/index.d.ts.map +0 -1
  136. package/dist/esm/components/AppliedFilters/index.js +0 -22
  137. package/dist/esm/components/AppliedFilters/styles.css +0 -65
  138. package/dist/esm/components/ConditionalFilters/index.d.ts +0 -3
  139. package/dist/esm/components/ConditionalFilters/index.d.ts.map +0 -1
  140. package/dist/esm/components/ConditionalFilters/index.js +0 -28
  141. package/dist/esm/components/FilterContext/index.d.ts +0 -45
  142. package/dist/esm/components/FilterContext/index.d.ts.map +0 -1
  143. package/dist/esm/components/FilterContext/index.js +0 -80
  144. package/dist/esm/components/SelectShownFilters/index.d.ts +0 -7
  145. package/dist/esm/components/SelectShownFilters/index.d.ts.map +0 -1
  146. package/dist/esm/components/SelectShownFilters/index.js +0 -107
  147. package/dist/esm/components/SelectShownFilters/styles.css +0 -99
  148. package/dist/esm/components/ShownFilters/index.d.ts +0 -3
  149. package/dist/esm/components/ShownFilters/index.d.ts.map +0 -1
  150. package/dist/esm/components/ShownFilters/index.js +0 -41
  151. package/dist/esm/components/index.d.ts +0 -6
  152. package/dist/esm/components/index.d.ts.map +0 -1
  153. package/dist/esm/components/index.js +0 -5
  154. package/dist/esm/constants/index.d.ts +0 -56
  155. package/dist/esm/constants/index.d.ts.map +0 -1
  156. package/dist/esm/constants/index.js +0 -55
  157. package/dist/esm/index.css +0 -67
  158. package/dist/esm/utils/index.d.ts +0 -25
  159. package/dist/esm/utils/index.d.ts.map +0 -1
  160. package/dist/esm/utils/index.js +0 -35
@@ -1,29 +0,0 @@
1
- /* eslint-disable */
2
- import { TreeSelect } from '@akinon/ui-tree-select';
3
- import { overallDateFormat } from '../../constants';
4
- import { getTreeNodeByValue } from '../../utils';
5
- export const isFileObject = (value) => (value === null || value === void 0 ? void 0 : value.originFileObj) !== undefined;
6
- export const getModifiedFilterValue = ({ filterItem, filterValue }) => {
7
- var _a, _b, _c;
8
- switch (filterItem === null || filterItem === void 0 ? void 0 : filterItem.widget) {
9
- case 'select':
10
- if (((_a = filterItem === null || filterItem === void 0 ? void 0 : filterItem.widgetProps) === null || _a === void 0 ? void 0 : _a.mode) === 'multiple') {
11
- return filterValue === null || filterValue === void 0 ? void 0 : filterValue.map((value) => {
12
- const optionObject = filterItem.options.find((option) => option.value === value);
13
- return (optionObject === null || optionObject === void 0 ? void 0 : optionObject.label) || value;
14
- }).join(', ');
15
- }
16
- const optionObject = filterItem.options.find((option) => option.value === filterValue);
17
- return (optionObject === null || optionObject === void 0 ? void 0 : optionObject.label) || filterValue;
18
- case 'date-picker':
19
- return filterValue === null || filterValue === void 0 ? void 0 : filterValue.format(overallDateFormat);
20
- case 'checkbox-group':
21
- return filterValue === null || filterValue === void 0 ? void 0 : filterValue.map(() => 'Yes').join(', ');
22
- case TreeSelect:
23
- const tree = (_b = filterItem === null || filterItem === void 0 ? void 0 : filterItem.widgetProps) === null || _b === void 0 ? void 0 : _b.treeData;
24
- const label = (_c = getTreeNodeByValue({ tree, nodeValue: filterValue })) === null || _c === void 0 ? void 0 : _c.value;
25
- return label || filterValue;
26
- default:
27
- return filterValue;
28
- }
29
- };
@@ -1,4 +0,0 @@
1
- import './styles.css';
2
- import React from 'react';
3
- export declare const AppliedFilters: () => React.JSX.Element;
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/AppliedFilters/index.tsx"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAMtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,eAAO,MAAM,cAAc,yBAyC1B,CAAC"}
@@ -1,22 +0,0 @@
1
- import './styles.css';
2
- import { Icon } from '@akinon/icons';
3
- import { Col, Row } from '@akinon/ui-layout';
4
- import { Space } from '@akinon/ui-space';
5
- import { Text } from '@akinon/ui-typography';
6
- import React from 'react';
7
- import { useFilterContext } from '../FilterContext';
8
- import { AppliedFilterItem } from './AppliedFilterItem';
9
- export const AppliedFilters = () => {
10
- var _a;
11
- const { state: { appliedFilters }, dispatch } = useFilterContext();
12
- const handleOnResetFilters = () => {
13
- dispatch({ type: 'SET_APPLIED_FILTERS', payload: { appliedFilters: {} } });
14
- };
15
- return (React.createElement(Row, { align: "middle", className: "applied_filters" },
16
- React.createElement(Col, { className: "applied_filters__list" },
17
- React.createElement(Space, null,
18
- React.createElement(Text, { className: "applied_filters__label" }, "Active filters:"),
19
- React.createElement(Space, { className: "applied_filters__items", "data-testid": "appliedFilters" }, (_a = Object.entries(appliedFilters)) === null || _a === void 0 ? void 0 : _a.map(([filterKey, filterValue], i) => filterValue !== undefined && (React.createElement(AppliedFilterItem, { filterKeyValue: [filterKey, filterValue], key: i })))))),
20
- React.createElement(Col, { className: "applied_filters__clear-filters" },
21
- React.createElement(Icon, { icon: "bin", size: 35, className: "applied_filters__reset-filters-icon", onClick: handleOnResetFilters }))));
22
- };
@@ -1,65 +0,0 @@
1
- .akinon-filter .applied_filters {
2
- padding: 5px 6px;
3
- background-color: #2b344c;
4
- border-radius: 5px;
5
- }
6
-
7
- .applied_filters .applied_filters__list {
8
- flex: 1;
9
- background-color: #1e1e2d;
10
- padding: 6px 16px;
11
- border-radius: 3px;
12
- }
13
-
14
- .applied_filters .applied_filters__label.akinon-typography {
15
- color: white;
16
- font-size: 14px;
17
- font-weight: 600;
18
- }
19
-
20
- .applied_filters .applied_filters__reset-filters-icon {
21
- cursor: pointer;
22
- color: white;
23
- font-size: 20px;
24
- padding: 6px;
25
- margin: 6px;
26
- }
27
-
28
- .applied_filters .applied_filters__items {
29
- flex-wrap: wrap;
30
- }
31
-
32
- .akinon-filter .active-filter-item {
33
- font-size: 14px;
34
- background-color: white;
35
- padding: 1px 4px;
36
- border-radius: 3px;
37
- line-height: 1rem;
38
- }
39
-
40
- .active-filter-item .akinon-space-item {
41
- display: flex;
42
- justify-content: center;
43
- }
44
-
45
- .active-filter-item .active-filter-item__label.akinon-typography,
46
- .active-filter-item .active-filter-item__value.akinon-typography {
47
- color: #4a4a4a;
48
- }
49
-
50
- .active-filter-item .active-filter-item__label.akinon-typography {
51
- font-weight: 600;
52
- }
53
-
54
- .active-filter-item .active-filter-item__value.akinon-typography {
55
- font-weight: 500;
56
- }
57
-
58
- .active-filter-item .active-filter-item__remove-filter-icon {
59
- cursor: pointer;
60
- background-color: #4482ff;
61
- color: white;
62
- font-size: 5px;
63
- padding: 5px;
64
- border-radius: 99px;
65
- }
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- export declare const ConditionalFilters: () => React.JSX.Element | null;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/ConditionalFilters/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,eAAO,MAAM,kBAAkB,gCAyC9B,CAAC"}
@@ -1,28 +0,0 @@
1
- import { FormBuilderWatch } from '@akinon/akiform-builder';
2
- import { Paragraph } from '@akinon/ui-typography';
3
- import React from 'react';
4
- import { useFilterContext } from '../FilterContext';
5
- export const ConditionalFilters = () => {
6
- const { dispatch, state, conditionalFiltersSchema } = useFilterContext();
7
- const { appliedFilters } = state;
8
- const [formResetCount, setFormResetCount] = React.useState(0);
9
- // reset form state when conditionalFiltersSchema changes
10
- React.useEffect(() => {
11
- setFormResetCount(formResetCount + 1);
12
- }, [conditionalFiltersSchema]);
13
- // second form created just to reset antd form state when conditionalFiltersSchema changes.
14
- const handleFormChange = (allValues) => {
15
- dispatch({
16
- type: 'SET_APPLIED_FILTERS',
17
- payload: {
18
- appliedFilters: Object.assign(Object.assign({}, appliedFilters), allValues)
19
- }
20
- });
21
- };
22
- if (!conditionalFiltersSchema)
23
- return null;
24
- return (React.createElement(React.Fragment, null,
25
- React.createElement(Paragraph, { className: "akinon-filter__header" }, "COMMON PARAMETER FILTERS"),
26
- React.createElement("div", null,
27
- React.createElement(FormBuilderWatch, { builderFields: conditionalFiltersSchema, handleChange: handleFormChange, key: formResetCount, isDebounced: true }))));
28
- };
@@ -1,45 +0,0 @@
1
- import { FormField } from '@akinon/akiform-builder';
2
- import React, { Dispatch } from 'react';
3
- import type { FilterProps } from '../..';
4
- export type FilterState = {
5
- mainPath: string;
6
- appliedFilters: {
7
- [key: string]: string | number | boolean | undefined;
8
- };
9
- applicableFilters: FormField[];
10
- shownFilters: string[];
11
- recreateShownFiltersCount: number;
12
- };
13
- export type FilterAction = {
14
- type: 'SET_APPLIED_FILTERS';
15
- payload: {
16
- appliedFilters: FilterState['appliedFilters'];
17
- };
18
- } | {
19
- type: 'SET_APPLICABLE_FILTERS';
20
- payload: {
21
- applicableFilters: FilterState['applicableFilters'];
22
- };
23
- } | {
24
- type: 'SET_SHOWN_FILTERS';
25
- payload: {
26
- shownFilters: FilterState['shownFilters'];
27
- };
28
- };
29
- export type FilterContext = {
30
- state: FilterState;
31
- dispatch: Dispatch<FilterAction>;
32
- conditionalFiltersSchema: FilterProps['conditionalFiltersSchema'];
33
- };
34
- type FilterContextProviderProps = FilterProps & {
35
- children: React.ReactNode;
36
- };
37
- /**
38
- * FilterContextProvider manages both filter context and antd form state.
39
- * Reason for not separating antd form state from filter context is that antd
40
- * form state is tightly coupled with filter context state.
41
- */
42
- export declare const FilterContextProvider: ({ children, filterSchema, customMainPath, useAppliedFilters, conditionalFiltersSchema }: FilterContextProviderProps) => React.JSX.Element;
43
- export declare function useFilterContext(): FilterContext;
44
- export {};
45
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/FilterContext/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAE,EAAiB,QAAQ,EAAyB,MAAM,OAAO,CAAC;AAI9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAGzC,MAAM,MAAM,WAAW,GAAG;IAExB,QAAQ,EAAE,MAAM,CAAC;IAEjB,cAAc,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAA;KAAE,CAAC;IAEzE,iBAAiB,EAAE,SAAS,EAAE,CAAC;IAE/B,YAAY,EAAE,MAAM,EAAE,CAAC;IAEvB,yBAAyB,EAAE,MAAM,CAAC;CACnC,CAAC;AAQF,MAAM,MAAM,YAAY,GACpB;IACE,IAAI,EAAE,qBAAqB,CAAC;IAC5B,OAAO,EAAE;QAAE,cAAc,EAAE,WAAW,CAAC,gBAAgB,CAAC,CAAA;KAAE,CAAC;CAC5D,GACD;IACE,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE;QAAE,iBAAiB,EAAE,WAAW,CAAC,mBAAmB,CAAC,CAAA;KAAE,CAAC;CAClE,GACD;IACE,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,EAAE;QAAE,YAAY,EAAE,WAAW,CAAC,cAAc,CAAC,CAAA;KAAE,CAAC;CACxD,CAAC;AAEN,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IACjC,wBAAwB,EAAE,WAAW,CAAC,0BAA0B,CAAC,CAAC;CACnE,CAAC;AAEF,KAAK,0BAA0B,GAAG,WAAW,GAAG;IAC9C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAIF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,4FAM/B,0BAA0B,sBA2F5B,CAAC;AAEF,wBAAgB,gBAAgB,kBAM/B"}
@@ -1,80 +0,0 @@
1
- import React, { createContext, useContext, useEffect } from 'react';
2
- import { useLocation } from 'react-router-dom';
3
- import { useImmerReducer } from 'use-immer';
4
- import { getPathFragments } from '../../utils';
5
- const FilterContext = createContext(undefined);
6
- /**
7
- * FilterContextProvider manages both filter context and antd form state.
8
- * Reason for not separating antd form state from filter context is that antd
9
- * form state is tightly coupled with filter context state.
10
- */
11
- export const FilterContextProvider = ({ children, filterSchema, customMainPath, useAppliedFilters, conditionalFiltersSchema }) => {
12
- const { pathname } = useLocation();
13
- const mainPath = customMainPath
14
- ? customMainPath
15
- : getPathFragments(pathname).mainPath;
16
- if (!mainPath) {
17
- throw new Error('mainPath is not defined');
18
- }
19
- // load appliedFilters from local storage
20
- const localAppliedFilters = JSON.parse(localStorage.getItem(`appliedFilters-${mainPath}`) || '{}');
21
- // get applied filters from parent component
22
- const parentAppliedFilters = useAppliedFilters[0];
23
- // load shownFilters from local storage
24
- const localShownFilters = JSON.parse(localStorage.getItem(`shownFilters-${mainPath}`) || '[]');
25
- const initialState = {
26
- mainPath,
27
- // if parentAppliedFilters is not empty, use it. Otherwise, use localAppliedFilters. don't merge them to prevent conflicts since you want parent to have the control
28
- appliedFilters: Object.keys(parentAppliedFilters).length > 0
29
- ? parentAppliedFilters
30
- : localAppliedFilters,
31
- applicableFilters: filterSchema,
32
- // if localShownFilters is not defined, only show first 8 filters
33
- shownFilters: localShownFilters.length
34
- ? localShownFilters
35
- : filterSchema.map(filter => filter.key).slice(0, 8),
36
- recreateShownFiltersCount: 0
37
- };
38
- const [state, dispatch] = useImmerReducer((draft, action) => {
39
- switch (action.type) {
40
- case 'SET_APPLIED_FILTERS':
41
- // console.log('SET_APPLIED_FILTERS', action.payload.appliedFilters);
42
- draft.appliedFilters = action.payload.appliedFilters;
43
- return;
44
- case 'SET_APPLICABLE_FILTERS':
45
- // console.log('SET_APPLICABLE_FILTERS');
46
- draft.applicableFilters = action.payload.applicableFilters;
47
- return;
48
- case 'SET_SHOWN_FILTERS':
49
- // console.log('SET_SHOWN_FILTERS', action.payload.shownFilters);
50
- draft.shownFilters = action.payload.shownFilters;
51
- draft.recreateShownFiltersCount = draft.recreateShownFiltersCount + 1;
52
- return;
53
- }
54
- }, initialState);
55
- useEffect(() => {
56
- // send applied filters to parent component
57
- useAppliedFilters[1](state.appliedFilters);
58
- // save current appliedFilters to local storage to persist them
59
- localStorage.setItem(`appliedFilters-${mainPath}`, JSON.stringify(state.appliedFilters));
60
- }, [state.appliedFilters]);
61
- // save current shownFilters to local storage to persist them
62
- useEffect(() => {
63
- localStorage.setItem(`shownFilters-${mainPath}`, JSON.stringify(state.shownFilters));
64
- }, [state.shownFilters]);
65
- useEffect(() => {
66
- dispatch({
67
- type: 'SET_APPLICABLE_FILTERS',
68
- payload: { applicableFilters: filterSchema }
69
- });
70
- }, [filterSchema]);
71
- // console.log('form state', state);
72
- return (React.createElement(FilterContext.Provider, { value: { state, dispatch, conditionalFiltersSchema } }, children));
73
- };
74
- export function useFilterContext() {
75
- const context = useContext(FilterContext);
76
- if (context === undefined) {
77
- throw new Error('useFilterContext must be used within a FilterProvider');
78
- }
79
- return context;
80
- }
@@ -1,7 +0,0 @@
1
- import './styles.css';
2
- import React from 'react';
3
- /**
4
- * Via this component, user can select which filters to show in the UI from applicableFilters.
5
- */
6
- export declare const SelectShownFilters: () => React.JSX.Element;
7
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/SelectShownFilters/index.tsx"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AActB,OAAO,KAAmB,MAAM,OAAO,CAAC;AAWxC;;GAEG;AACH,eAAO,MAAM,kBAAkB,yBA+J9B,CAAC"}
@@ -1,107 +0,0 @@
1
- import './styles.css';
2
- import { FormBuilderWatch } from '@akinon/akiform-builder';
3
- import { Icon } from '@akinon/icons';
4
- import { Input } from '@akinon/ui-input';
5
- import { Pagination } from '@akinon/ui-pagination';
6
- import { Divider } from '@akinon/ui-divider';
7
- import { Modal } from '@akinon/ui-modal';
8
- import { Space } from '@akinon/ui-space';
9
- import React, { useState } from 'react';
10
- import { useFilterContext } from '../FilterContext';
11
- // import {
12
- // getModalFormInitialValues,
13
- // getModalFormMeta,
14
- // transformFiltersFormMetaFieldsToModalFormMetaFields
15
- // } from './common';
16
- // import useOnModalCancel from './hooks/useOnModalCancel';
17
- // TODO includeFileFilter
18
- /**
19
- * Via this component, user can select which filters to show in the UI from applicableFilters.
20
- */
21
- export const SelectShownFilters = () => {
22
- const [search, setSearch] = useState('');
23
- const [pagination, setPagination] = useState({
24
- current: 1,
25
- pageSize: 60
26
- });
27
- const { state, dispatch } = useFilterContext();
28
- const { applicableFilters, shownFilters } = state;
29
- // create checkbox form item for each filter, which will determine whether to show it or not
30
- const modalFormItems = [];
31
- applicableFilters.forEach((filter) => {
32
- var _a;
33
- if (search &&
34
- !((_a = filter.placeholder) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(search.toLowerCase())) &&
35
- !filter.label.toLowerCase().includes(search.toLowerCase())) {
36
- return;
37
- }
38
- modalFormItems.push({
39
- key: filter.key,
40
- label: filter.placeholder || filter.label || filter.key,
41
- type: 'checkbox',
42
- value: shownFilters.includes(filter.key),
43
- props: {
44
- labelRightAligned: true
45
- }
46
- });
47
- });
48
- const modalFormItemsPaginated = modalFormItems.slice((pagination.current - 1) * pagination.pageSize, pagination.current * pagination.pageSize);
49
- // export const transformFiltersFormMetaFieldsToModalFormMetaFields = (filtersFormMetaFields) =>
50
- // filtersFormMetaFields.map((metaField) => ({
51
- // key: metaField.key,
52
- // widget: WidgetType.CHECKBOX,
53
- // children: metaField.placeholder,
54
- // }));
55
- const [isModalOpen, setIsModalOpen] = useState(false);
56
- // const onModalCancel = useOnModalCancel({
57
- // setCurrentFiltersFormMeta,
58
- // modalForm,
59
- // setIsModalOpen,
60
- // staticFiltersFormMetaFields,
61
- // dynamicFiltersFormMetaFields
62
- // });
63
- // const modalFormInitialValues = getModalFormInitialValues(
64
- // currentFiltersFormMeta
65
- // );
66
- // const modalFormMetaFields =
67
- // transformFiltersFormMetaFieldsToModalFormMetaFields([
68
- // ...staticFiltersFormMetaFields,
69
- // ...dynamicFiltersFormMetaFields
70
- // ]);
71
- const handleOpenModalIconClick = () => {
72
- setIsModalOpen(true);
73
- };
74
- const onModalCancel = () => {
75
- setIsModalOpen(false);
76
- };
77
- const handleModalFormValuesChange = (allValues) => {
78
- // select true values from allValues
79
- const shownFilters = Object.keys(allValues).filter(key => allValues[key] === true);
80
- dispatch({
81
- type: 'SET_SHOWN_FILTERS',
82
- payload: { shownFilters }
83
- });
84
- };
85
- // const addFileToFilters = selectFile => {
86
- // setFilters({
87
- // pagePath: mainPath,
88
- // filters: { ...pageFilters, filter_file: selectFile.file }
89
- // });
90
- // };
91
- return (React.createElement(Space, { className: "filter-options" },
92
- React.createElement("div", { className: "filter-options__item", onClick: handleOpenModalIconClick },
93
- React.createElement(Icon, { icon: "filter" })),
94
- React.createElement(Modal, { className: "filter-options__modal", onCancel: onModalCancel, open: isModalOpen, destroyOnClose: true, footer: null, width: '80%', "data-testid": "filter-options-modal" },
95
- React.createElement("div", { className: "filter-options__modal-header" },
96
- React.createElement("div", { className: "filter-options__modal-header-banner" }),
97
- React.createElement("h1", { className: "filter-options__modal-header-title" }, "Select Shown Filters")),
98
- React.createElement(Divider, null),
99
- React.createElement("div", { className: "filter-options__modal-control" },
100
- React.createElement(Input, { placeholder: "Search", onChange: e => setSearch(e.target.value), className: "filter-options__modal-search" }),
101
- React.createElement("div", { className: "filter-options__modal-pagination" },
102
- React.createElement(Pagination, { current: pagination.current, pageSize: pagination.pageSize, total: modalFormItems.length, onChange: (page, pageSize) => {
103
- setPagination({ current: page, pageSize });
104
- }, showSizeChanger: false, simple: true }))),
105
- React.createElement("div", { className: "filter-options__modal-form" },
106
- React.createElement(FormBuilderWatch, { builderFields: modalFormItemsPaginated, handleChange: handleModalFormValuesChange, isDebounced: false })))));
107
- };
@@ -1,99 +0,0 @@
1
- .filter-options .filter-options__item {
2
- display: flex;
3
- align-items: center;
4
- justify-content: center;
5
- height: 36px;
6
- width: 36px;
7
- background-color: #4482ff;
8
- color: var(--color-neutral-50);
9
- border-radius: 5px;
10
- cursor: pointer;
11
- }
12
-
13
- .filter-options .filter-options__filter-modal-open-icon {
14
- color: white;
15
- font-size: 23px;
16
- }
17
-
18
- .filter-options .filter-options__modal-header {
19
- position: relative;
20
- display: flex;
21
- align-items: center;
22
- }
23
-
24
- .filter-options .filter-options__modal-header-banner {
25
- position: absolute;
26
- left: 0;
27
- width: 4px;
28
- height: 16px;
29
- background-color: #ff5163;
30
- left: -22px;
31
- }
32
-
33
- .filter-options .filter-options__modal-header-title {
34
- font-size: 20px;
35
- color: white;
36
- font-weight: 500;
37
- margin: 0;
38
- }
39
-
40
- .filter-options .filter-options__modal-divider.akinon-divider-horizontal {
41
- background-color: #363d51;
42
- width: calc(100% + 44px);
43
- margin: 15px;
44
- margin-left: -22px;
45
- }
46
-
47
- .filter-options .filter-options__modal-control {
48
- display: flex;
49
- justify-content: space-between;
50
- align-items: center;
51
- margin-bottom: 15px;
52
- }
53
-
54
- .filter-options .filter-options__modal-search {
55
- width: 250px;
56
- }
57
-
58
- .filter-options .filter-options__modal-form.akinon-form {
59
- margin: 32px 44px 0;
60
- }
61
-
62
- .filter-options .filter-options__export-item {
63
- display: flex;
64
- flex-direction: column;
65
- justify-content: center;
66
- align-items: center;
67
- }
68
-
69
- .filter-options .filter-options__export-icon {
70
- color: white;
71
- }
72
-
73
- .filter-options .filter-options__export-label.akinon-typography {
74
- text-transform: uppercase;
75
- color: white;
76
- font-size: 11px;
77
- font-weight: bold;
78
- line-height: 14px;
79
- }
80
-
81
- .filter-options__modal.akinon-modal .akinon-checkbox-wrapper {
82
- color: white;
83
- }
84
-
85
- .filter-options__modal.akinon-modal
86
- .akinon-checkbox-checked
87
- .akinon-checkbox-inner {
88
- background-color: #6c7ebe;
89
- border-color: #6c7ebe;
90
-
91
- &:hover {
92
- border-color: #6c7ebe;
93
- }
94
- }
95
-
96
- .filter-options__modal-form .akinon-form {
97
- display: grid;
98
- grid-template-columns: 1fr 1fr 1fr 1fr;
99
- }
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- export declare const ShownFilters: () => React.JSX.Element;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/ShownFilters/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,eAAO,MAAM,YAAY,yBAkExB,CAAC"}
@@ -1,41 +0,0 @@
1
- import { FormBuilderWatch } from '@akinon/akiform-builder';
2
- import { Paragraph } from '@akinon/ui-typography';
3
- import React from 'react';
4
- import { useFilterContext } from '../FilterContext';
5
- export const ShownFilters = () => {
6
- const { state, dispatch } = useFilterContext();
7
- const { applicableFilters, shownFilters, appliedFilters, recreateShownFiltersCount } = state;
8
- // derive form items from applicableFilters and shownFilters
9
- const shownApplicableFilters = applicableFilters.filter(filter => shownFilters.includes(filter.key));
10
- // create form items from shownApplicableFilters and appliedFilters.
11
- // the shownApplicableFilters determines the schema of the form items and
12
- // appliedFilters determines the values of the form items
13
- const formItems = shownApplicableFilters.map(filter => {
14
- return Object.assign(Object.assign({}, filter), { value: appliedFilters[filter.key], props: Object.assign(Object.assign({}, ((filter === null || filter === void 0 ? void 0 : filter.props) || {})), { labelRightAligned: true }) });
15
- });
16
- // remove the label from the form items since label is not used in design
17
- formItems.forEach(item => {
18
- if (item.type === 'checkbox')
19
- return;
20
- delete item.label;
21
- });
22
- const handleChange = (changedValues) => {
23
- Object.keys(changedValues).forEach(key => {
24
- const value = changedValues[key];
25
- if (value &&
26
- typeof value.isValid === 'function' &&
27
- typeof value.format === 'function') {
28
- changedValues[key] = value.format('YYYY-MM-DD');
29
- }
30
- });
31
- dispatch({
32
- type: 'SET_APPLIED_FILTERS',
33
- payload: {
34
- appliedFilters: changedValues
35
- }
36
- });
37
- };
38
- return (React.createElement("div", { className: "shown-filters", "data-testid": "shown-filters" },
39
- React.createElement(Paragraph, { className: "akinon-filter__header" }, "MAIN FILTERS"),
40
- React.createElement(FormBuilderWatch, { key: recreateShownFiltersCount, builderFields: formItems, handleChange: handleChange, isDebounced: true })));
41
- };
@@ -1,6 +0,0 @@
1
- export * from './AppliedFilters';
2
- export * from './ConditionalFilters';
3
- export * from './FilterContext';
4
- export * from './SelectShownFilters';
5
- export * from './ShownFilters';
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.tsx"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC"}
@@ -1,5 +0,0 @@
1
- export * from './AppliedFilters';
2
- export * from './ConditionalFilters';
3
- export * from './FilterContext';
4
- export * from './SelectShownFilters';
5
- export * from './ShownFilters';
@@ -1,56 +0,0 @@
1
- export declare const defaultDateFormat = "DD/MM/YYYY";
2
- export declare const defaultDateValueFormat = "YYYY-MM-DD";
3
- export declare const defaultTimeFormat = "HH:mm";
4
- export declare const defaultTimeFormatWithSeconds = "HH:mm:ss";
5
- export declare const defaultTimeFormatWithTimeZone = "HH:mm:ssZZ";
6
- export declare const timeFormatWithTimeZone = "HH:mmZ";
7
- export declare const timeFormatWithDateAndTime = "LLL";
8
- export declare const dateWithMonthName = "DD MMMM";
9
- export declare const dateWithMonthNameAndYear = "DD MMMM YYYY";
10
- export declare const overallDateFormat = "DD-MM-YYYY HH:mm:ss";
11
- export declare const dateTimeLocalSecondsFormat = "YYYY-MM-DDTHH:mm:ss.SSS";
12
- export declare const fullDateTimeWithZoneFormat = "YYYY-MM-DDTHH:mm:ss.SSS\\Z";
13
- export declare const defaultDateTimeValueFormat = "YYYY-MM-DD HH:mm:ss";
14
- export declare const defaultDateTimeFormat = "DD/MM/YYYY HH:mm";
15
- export declare const defaultDateTimeFormatIntl: {
16
- year: string;
17
- month: string;
18
- day: string;
19
- hour: string;
20
- minute: string;
21
- hour12: boolean;
22
- };
23
- export declare const defaultDateTimeFormatWithTimeZone = "YYYY-MM-DD HH:mmZ";
24
- export declare const dateTimeFormat = "YYYY-MM-DD HH:mm";
25
- export declare const tokenHeaderKEY = "Bearer";
26
- export declare const tokenStorageKey = "tkn";
27
- export declare const googleMapApiKey = "AIzaSyB7GLs4svXGax91fiW-gH1wInjmde7cEHk";
28
- export declare const permissionSlugSuffix = "-v2";
29
- export declare const readResponseMessageKey = "readResponseMessages";
30
- export declare const platformLanguage = "platform_language";
31
- export declare const contextChannel = "contextChannel";
32
- export declare const allowedFileTypes = ".xls, .csv";
33
- export declare const allowedFileTypesAndXlsx: string;
34
- export declare const allowedImageTypes = ".png,.jpeg,.jpg,.bmp";
35
- export declare const allowedHtmlTypes = ".html";
36
- export declare const omsDashboardStorageKeyName = "oms_dashboardFilters";
37
- export declare const dateManipulationKeys: {
38
- END_OF: string;
39
- SUBTRACT: string;
40
- ADD: string;
41
- };
42
- export declare const sampleDate = "2022-01-01";
43
- export declare const defaultRowKey = "id";
44
- export declare const Breakpoint: {
45
- MOBILE: string;
46
- TABLET: string;
47
- DESKTOP: string;
48
- LARGE_DESKTOP: string;
49
- };
50
- export declare const defaultBreakpoints: {
51
- MOBILE: number;
52
- TABLET: number;
53
- DESKTOP: number;
54
- LARGE_DESKTOP: number;
55
- };
56
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/constants/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,eAAe,CAAC;AAC9C,eAAO,MAAM,sBAAsB,eAAe,CAAC;AACnD,eAAO,MAAM,iBAAiB,UAAU,CAAC;AACzC,eAAO,MAAM,4BAA4B,aAAa,CAAC;AACvD,eAAO,MAAM,6BAA6B,eAAe,CAAC;AAC1D,eAAO,MAAM,sBAAsB,WAAW,CAAC;AAC/C,eAAO,MAAM,yBAAyB,QAAQ,CAAC;AAC/C,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAC3C,eAAO,MAAM,wBAAwB,iBAAiB,CAAC;AACvD,eAAO,MAAM,iBAAiB,wBAAwB,CAAC;AACvD,eAAO,MAAM,0BAA0B,4BAA4B,CAAC;AACpE,eAAO,MAAM,0BAA0B,+BAA+B,CAAC;AAEvE,eAAO,MAAM,0BAA0B,wBAA8D,CAAC;AACtG,eAAO,MAAM,qBAAqB,qBAA8C,CAAC;AACjF,eAAO,MAAM,yBAAyB;;;;;;;CAOrC,CAAC;AAEF,eAAO,MAAM,iCAAiC,sBAAwD,CAAC;AACvG,eAAO,MAAM,cAAc,qBAAmD,CAAC;AAE/E,eAAO,MAAM,cAAc,WAAW,CAAC;AACvC,eAAO,MAAM,eAAe,QAAQ,CAAC;AAErC,eAAO,MAAM,eAAe,4CAA4C,CAAC;AAEzE,eAAO,MAAM,oBAAoB,QAAQ,CAAC;AAE1C,eAAO,MAAM,sBAAsB,yBAAyB,CAAC;AAE7D,eAAO,MAAM,gBAAgB,sBAAsB,CAAC;AAEpD,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAE/C,eAAO,MAAM,gBAAgB,eAAe,CAAC;AAE7C,eAAO,MAAM,uBAAuB,QAA+B,CAAC;AAEpE,eAAO,MAAM,iBAAiB,yBAAyB,CAAC;AAExD,eAAO,MAAM,gBAAgB,UAAU,CAAC;AAExC,eAAO,MAAM,0BAA0B,yBAAyB,CAAC;AAEjE,eAAO,MAAM,oBAAoB;;;;CAIhC,CAAC;AAEF,eAAO,MAAM,UAAU,eAAe,CAAC;AAEvC,eAAO,MAAM,aAAa,OAAO,CAAC;AAElC,eAAO,MAAM,UAAU;;;;;CAKtB,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;;CAK9B,CAAC"}