@fibery/views 17.0.4 → 18.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +17 -0
- package/lib/jest.config.d.ts +2 -0
- package/lib/jest.config.js +33 -0
- package/lib/src/field-utils/avatar.d.ts +20 -0
- package/lib/src/field-utils/avatar.js +42 -0
- package/lib/src/field-utils/back-references.d.ts +15 -0
- package/lib/src/field-utils/back-references.js +21 -0
- package/lib/src/field-utils/comments.d.ts +60 -0
- package/lib/src/field-utils/comments.js +46 -0
- package/lib/src/field-utils/date-time.d.ts +14 -0
- package/lib/src/field-utils/date-time.js +56 -0
- package/lib/src/field-utils/enum-value.d.ts +13 -0
- package/lib/src/field-utils/enum-value.js +29 -0
- package/lib/src/field-utils/file.d.ts +4 -0
- package/lib/src/field-utils/file.js +18 -0
- package/lib/src/field-utils/icon.d.ts +10 -0
- package/lib/src/field-utils/icon.js +26 -0
- package/lib/src/field-utils/number.d.ts +31 -0
- package/lib/src/field-utils/number.js +91 -0
- package/lib/src/field-utils/reference-collection.d.ts +18 -0
- package/lib/src/field-utils/reference-collection.js +45 -0
- package/lib/src/field-utils/reference.d.ts +7 -0
- package/lib/src/field-utils/reference.js +57 -0
- package/lib/src/field-utils/relation-view.d.ts +2 -0
- package/lib/src/field-utils/relation-view.js +12 -0
- package/lib/src/field-utils/rich-text.d.ts +12 -0
- package/lib/src/field-utils/rich-text.js +27 -0
- package/lib/src/field-utils/text.d.ts +35 -0
- package/lib/src/field-utils/text.js +40 -0
- package/lib/src/field-utils/user-active.d.ts +8 -0
- package/lib/src/field-utils/user-active.js +28 -0
- package/lib/src/field-utils/user-role.d.ts +6 -0
- package/lib/src/field-utils/user-role.js +25 -0
- package/lib/src/field-utils/workflow.d.ts +15 -0
- package/lib/src/field-utils/workflow.js +56 -0
- package/lib/src/index.d.ts +16 -0
- package/lib/src/index.js +258 -0
- package/lib/src/private/board.d.ts +11 -0
- package/lib/src/private/board.js +326 -0
- package/lib/src/private/calendar.d.ts +10 -0
- package/lib/src/private/calendar.js +122 -0
- package/lib/src/private/feed.d.ts +10 -0
- package/lib/src/private/feed.js +119 -0
- package/lib/src/private/form.d.ts +3 -0
- package/lib/src/private/form.js +61 -0
- package/lib/src/private/map.d.ts +10 -0
- package/lib/src/private/map.js +119 -0
- package/lib/src/private/smart-folder.d.ts +23 -0
- package/lib/src/private/smart-folder.js +274 -0
- package/lib/src/private/test-data/garbage-test.d.ts +649 -0
- package/lib/src/private/test-data/garbage-test.js +520 -0
- package/lib/src/private/test-data/kanban.d.ts +1123 -0
- package/lib/src/private/test-data/kanban.js +1203 -0
- package/lib/src/private/test-data/tasks.d.ts +3216 -0
- package/lib/src/private/test-data/tasks.js +2731 -0
- package/lib/src/private/timeline.d.ts +10 -0
- package/lib/src/private/timeline.js +323 -0
- package/lib/src/private/units.d.ts +6 -0
- package/lib/src/private/units.js +144 -0
- package/lib/src/private/utils.d.ts +17 -0
- package/lib/src/private/utils.js +267 -0
- package/lib/src/tsfixme.d.ts +1 -0
- package/lib/src/tsfixme.js +2 -0
- package/lib/src/unit-definitions/avatar-collection.d.ts +2 -0
- package/lib/src/unit-definitions/avatar-collection.js +53 -0
- package/lib/src/unit-definitions/avatar-input.d.ts +2 -0
- package/lib/src/unit-definitions/avatar-input.js +12 -0
- package/lib/src/unit-definitions/avatar.d.ts +2 -0
- package/lib/src/unit-definitions/avatar.js +80 -0
- package/lib/src/unit-definitions/back-references-list.d.ts +2 -0
- package/lib/src/unit-definitions/back-references-list.js +38 -0
- package/lib/src/unit-definitions/bool-checkbox.d.ts +2 -0
- package/lib/src/unit-definitions/bool-checkbox.js +25 -0
- package/lib/src/unit-definitions/bool.d.ts +2 -0
- package/lib/src/unit-definitions/bool.js +22 -0
- package/lib/src/unit-definitions/collection-count.d.ts +2 -0
- package/lib/src/unit-definitions/collection-count.js +32 -0
- package/lib/src/unit-definitions/color-input.d.ts +2 -0
- package/lib/src/unit-definitions/color-input.js +21 -0
- package/lib/src/unit-definitions/comments-list.d.ts +2 -0
- package/lib/src/unit-definitions/comments-list.js +25 -0
- package/lib/src/unit-definitions/date-range-combobox.d.ts +2 -0
- package/lib/src/unit-definitions/date-range-combobox.js +22 -0
- package/lib/src/unit-definitions/date-range.d.ts +2 -0
- package/lib/src/unit-definitions/date-range.js +22 -0
- package/lib/src/unit-definitions/date-time-combobox.d.ts +2 -0
- package/lib/src/unit-definitions/date-time-combobox.js +22 -0
- package/lib/src/unit-definitions/date.d.ts +2 -0
- package/lib/src/unit-definitions/date.js +22 -0
- package/lib/src/unit-definitions/email-input.d.ts +2 -0
- package/lib/src/unit-definitions/email-input.js +12 -0
- package/lib/src/unit-definitions/email.d.ts +2 -0
- package/lib/src/unit-definitions/email.js +17 -0
- package/lib/src/unit-definitions/emoji.d.ts +2 -0
- package/lib/src/unit-definitions/emoji.js +17 -0
- package/lib/src/unit-definitions/file-collection-count.d.ts +2 -0
- package/lib/src/unit-definitions/file-collection-count.js +30 -0
- package/lib/src/unit-definitions/file-compact-collection.d.ts +2 -0
- package/lib/src/unit-definitions/file-compact-collection.js +30 -0
- package/lib/src/unit-definitions/file-compact-reference.d.ts +2 -0
- package/lib/src/unit-definitions/file-compact-reference.js +36 -0
- package/lib/src/unit-definitions/file-reference.d.ts +2 -0
- package/lib/src/unit-definitions/file-reference.js +26 -0
- package/lib/src/unit-definitions/files-gallery.d.ts +2 -0
- package/lib/src/unit-definitions/files-gallery.js +30 -0
- package/lib/src/unit-definitions/files-l-list-item.d.ts +2 -0
- package/lib/src/unit-definitions/files-l-list-item.js +26 -0
- package/lib/src/unit-definitions/files-l-list.d.ts +2 -0
- package/lib/src/unit-definitions/files-l-list.js +30 -0
- package/lib/src/unit-definitions/files-list-item.d.ts +2 -0
- package/lib/src/unit-definitions/files-list-item.js +26 -0
- package/lib/src/unit-definitions/files-list.d.ts +2 -0
- package/lib/src/unit-definitions/files-list.js +30 -0
- package/lib/src/unit-definitions/geometry-preview.d.ts +2 -0
- package/lib/src/unit-definitions/geometry-preview.js +17 -0
- package/lib/src/unit-definitions/icon-button.d.ts +2 -0
- package/lib/src/unit-definitions/icon-button.js +29 -0
- package/lib/src/unit-definitions/icon-input.d.ts +2 -0
- package/lib/src/unit-definitions/icon-input.js +12 -0
- package/lib/src/unit-definitions/id.d.ts +2 -0
- package/lib/src/unit-definitions/id.js +29 -0
- package/lib/src/unit-definitions/index.d.ts +27 -0
- package/lib/src/unit-definitions/index.js +57 -0
- package/lib/src/unit-definitions/json-input.d.ts +2 -0
- package/lib/src/unit-definitions/json-input.js +21 -0
- package/lib/src/unit-definitions/location-input.d.ts +2 -0
- package/lib/src/unit-definitions/location-input.js +18 -0
- package/lib/src/unit-definitions/location.d.ts +2 -0
- package/lib/src/unit-definitions/location.js +17 -0
- package/lib/src/unit-definitions/not-found.d.ts +2 -0
- package/lib/src/unit-definitions/not-found.js +24 -0
- package/lib/src/unit-definitions/number-input.d.ts +2 -0
- package/lib/src/unit-definitions/number-input.js +22 -0
- package/lib/src/unit-definitions/number.d.ts +2 -0
- package/lib/src/unit-definitions/number.js +27 -0
- package/lib/src/unit-definitions/phone-input.d.ts +2 -0
- package/lib/src/unit-definitions/phone-input.js +12 -0
- package/lib/src/unit-definitions/phone.d.ts +2 -0
- package/lib/src/unit-definitions/phone.js +12 -0
- package/lib/src/unit-definitions/progress-bar.d.ts +2 -0
- package/lib/src/unit-definitions/progress-bar.js +32 -0
- package/lib/src/unit-definitions/reference-collection-combobox.d.ts +2 -0
- package/lib/src/unit-definitions/reference-collection-combobox.js +21 -0
- package/lib/src/unit-definitions/reference-collection-list.d.ts +2 -0
- package/lib/src/unit-definitions/reference-collection-list.js +22 -0
- package/lib/src/unit-definitions/reference-collection-view.d.ts +2 -0
- package/lib/src/unit-definitions/reference-collection-view.js +19 -0
- package/lib/src/unit-definitions/reference-collection.d.ts +2 -0
- package/lib/src/unit-definitions/reference-collection.js +27 -0
- package/lib/src/unit-definitions/reference-combobox.d.ts +2 -0
- package/lib/src/unit-definitions/reference-combobox.js +21 -0
- package/lib/src/unit-definitions/reference-icon.d.ts +2 -0
- package/lib/src/unit-definitions/reference-icon.js +12 -0
- package/lib/src/unit-definitions/reference.d.ts +2 -0
- package/lib/src/unit-definitions/reference.js +49 -0
- package/lib/src/unit-definitions/rich-text-document.d.ts +2 -0
- package/lib/src/unit-definitions/rich-text-document.js +22 -0
- package/lib/src/unit-definitions/rich-text-snippet.d.ts +2 -0
- package/lib/src/unit-definitions/rich-text-snippet.js +39 -0
- package/lib/src/unit-definitions/single-location-preview.d.ts +2 -0
- package/lib/src/unit-definitions/single-location-preview.js +17 -0
- package/lib/src/unit-definitions/text-input.d.ts +2 -0
- package/lib/src/unit-definitions/text-input.js +22 -0
- package/lib/src/unit-definitions/text.d.ts +2 -0
- package/lib/src/unit-definitions/text.js +22 -0
- package/lib/src/unit-definitions/title-input.d.ts +2 -0
- package/lib/src/unit-definitions/title-input.js +16 -0
- package/lib/src/unit-definitions/title.d.ts +2 -0
- package/lib/src/unit-definitions/title.js +34 -0
- package/lib/src/unit-definitions/type-badge-abbr.d.ts +2 -0
- package/lib/src/unit-definitions/type-badge-abbr.js +25 -0
- package/lib/src/unit-definitions/type-badge.d.ts +2 -0
- package/lib/src/unit-definitions/type-badge.js +25 -0
- package/lib/src/unit-definitions/type-icon.d.ts +2 -0
- package/lib/src/unit-definitions/type-icon.js +25 -0
- package/lib/src/unit-definitions/url-input.d.ts +2 -0
- package/lib/src/unit-definitions/url-input.js +12 -0
- package/lib/src/unit-definitions/url.d.ts +2 -0
- package/lib/src/unit-definitions/url.js +17 -0
- package/lib/src/unit-definitions/user-button.d.ts +2 -0
- package/lib/src/unit-definitions/user-button.js +23 -0
- package/lib/src/unit-definitions/user-role-input.d.ts +2 -0
- package/lib/src/unit-definitions/user-role-input.js +12 -0
- package/lib/src/unit-definitions/user-role.d.ts +2 -0
- package/lib/src/unit-definitions/user-role.js +29 -0
- package/lib/src/unit-utils/access.d.ts +9 -0
- package/lib/src/unit-utils/access.js +14 -0
- package/lib/src/unit-utils/can-edit-field.d.ts +6 -0
- package/lib/src/unit-utils/can-edit-field.js +8 -0
- package/lib/src/unit-utils/common.d.ts +14 -0
- package/lib/src/unit-utils/common.js +43 -0
- package/lib/src/unit-utils/decimal.d.ts +42 -0
- package/lib/src/unit-utils/decimal.js +414 -0
- package/lib/src/unit-utils/dynamic-keys.d.ts +7 -0
- package/lib/src/unit-utils/dynamic-keys.js +13 -0
- package/lib/src/unit-utils/enums.d.ts +27 -0
- package/lib/src/unit-utils/enums.js +69 -0
- package/lib/src/unit-utils/formatters.d.ts +50 -0
- package/lib/src/unit-utils/formatters.js +163 -0
- package/lib/src/unit-utils/get-export-value.d.ts +45 -0
- package/lib/src/unit-utils/get-export-value.js +83 -0
- package/lib/src/unit-utils/get-field-label.d.ts +6 -0
- package/lib/src/unit-utils/get-field-label.js +10 -0
- package/lib/src/unit-utils/get-unmatched-unit-label.d.ts +2 -0
- package/lib/src/unit-utils/get-unmatched-unit-label.js +9 -0
- package/lib/src/unit-utils/schema.d.ts +4 -0
- package/lib/src/unit-utils/schema.js +12 -0
- package/lib/src/units/board.d.ts +43 -0
- package/lib/src/units/board.js +51 -0
- package/lib/src/units/canvas/all-units-data-definitions.d.ts +18 -0
- package/lib/src/units/canvas/all-units-data-definitions.js +40 -0
- package/lib/src/units/canvas/index.d.ts +42 -0
- package/lib/src/units/canvas/index.js +48 -0
- package/lib/src/units/canvas/type-badge-abbr.d.ts +36 -0
- package/lib/src/units/canvas/type-badge-abbr.js +11 -0
- package/lib/src/units/canvas/type-badge.d.ts +36 -0
- package/lib/src/units/canvas/type-badge.js +11 -0
- package/lib/src/units/default.d.ts +43 -0
- package/lib/src/units/default.js +51 -0
- package/lib/src/units/gallery.d.ts +3 -0
- package/lib/src/units/gallery.js +18 -0
- package/lib/src/units/gantt.d.ts +44 -0
- package/lib/src/units/gantt.js +59 -0
- package/lib/src/units/get-unit-definitions-for-view-type.d.ts +2 -0
- package/lib/src/units/get-unit-definitions-for-view-type.js +64 -0
- package/lib/src/units/grid.d.ts +42 -0
- package/lib/src/units/grid.js +67 -0
- package/lib/src/units/list.d.ts +43 -0
- package/lib/src/units/list.js +49 -0
- package/lib/src/units/make-factory.d.ts +50 -0
- package/lib/src/units/make-factory.js +245 -0
- package/lib/src/units/types.d.ts +73 -0
- package/lib/src/units/types.js +2 -0
- package/package.json +42 -52
- package/lib/views.js +0 -1813
- /package/{index.js → lib/index.d.ts} +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function replaceNamesWithIdsInTimelineView(schema: any, view: any): any;
|
|
2
|
+
export function replaceIdsWithNamesInTimelineView(schema: any, view: any): any;
|
|
3
|
+
export function deleteExpressionWithNotFoundFieldsOrTypesInTimelineView(schema: any, view: any, ensureAxisInvariant: any, canGroupMetaItem?: (metaItem: any) => boolean): any;
|
|
4
|
+
export function fixUserSelectedUnitsInTimelineView(schema: any, view: any, { unitDefinitions, getDefaultUnitTypeForField }: {
|
|
5
|
+
unitDefinitions: any;
|
|
6
|
+
getDefaultUnitTypeForField: any;
|
|
7
|
+
}): any;
|
|
8
|
+
export function fixContextExpressionWithBrokenPath(schema: any, view: any, defaultContextExpression: any): any;
|
|
9
|
+
export function collectGarbage(view: any): any;
|
|
10
|
+
export function enableHideWhenEmptyForCheckedEditableUnits(view: any): any;
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.enableHideWhenEmptyForCheckedEditableUnits = exports.collectGarbage = exports.fixContextExpressionWithBrokenPath = exports.fixUserSelectedUnitsInTimelineView = exports.deleteExpressionWithNotFoundFieldsOrTypesInTimelineView = exports.replaceIdsWithNamesInTimelineView = exports.replaceNamesWithIdsInTimelineView = void 0;
|
|
7
|
+
const immutability_helper_1 = __importDefault(require("immutability-helper"));
|
|
8
|
+
const entries_1 = __importDefault(require("lodash/entries"));
|
|
9
|
+
const first_1 = __importDefault(require("lodash/first"));
|
|
10
|
+
const get_1 = __importDefault(require("lodash/get"));
|
|
11
|
+
const has_1 = __importDefault(require("lodash/has"));
|
|
12
|
+
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
13
|
+
const set_1 = __importDefault(require("lodash/set"));
|
|
14
|
+
const some_1 = __importDefault(require("lodash/some"));
|
|
15
|
+
const smart_folder_1 = require("./smart-folder");
|
|
16
|
+
const units_1 = require("./units");
|
|
17
|
+
const utils_1 = require("./utils");
|
|
18
|
+
const visitAxisSingle = (axis, visitor) => {
|
|
19
|
+
const fromType = (0, get_1.default)(axis, ["query", "q/from"]);
|
|
20
|
+
const firstOrNull = (x) => (0, first_1.default)(x) || null;
|
|
21
|
+
const axisResult = {
|
|
22
|
+
...axis,
|
|
23
|
+
filter: axis.filter ? visitor.visitFilter(fromType, axis.filter) : null,
|
|
24
|
+
query: axis.query && visitor.visitQueryExpression(axis.query),
|
|
25
|
+
contextExpression: (0, utils_1.visitContextExpression)(fromType, axis.contextExpression, visitor),
|
|
26
|
+
units: axis.units &&
|
|
27
|
+
axis.units
|
|
28
|
+
.map((unit) => (0, utils_1.visitViewUnit)(fromType, unit, visitor))
|
|
29
|
+
.filter((unit) => (0, utils_1.isUnitExpressionValid)(unit))
|
|
30
|
+
.map((unit, idx, units) => (visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit))
|
|
31
|
+
.filter((unit) => unit !== utils_1.REMOVE),
|
|
32
|
+
groupByExpression: axis.groupByExpression && firstOrNull(visitor.visitExpression(fromType, [axis.groupByExpression])),
|
|
33
|
+
};
|
|
34
|
+
if (!axisResult.query) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
if (!axisResult.units) {
|
|
38
|
+
delete axisResult.units;
|
|
39
|
+
}
|
|
40
|
+
return axisResult;
|
|
41
|
+
};
|
|
42
|
+
const visitAxis = (axis, visitor) => {
|
|
43
|
+
if (axis && Object.hasOwn(axis, "query")) {
|
|
44
|
+
return visitAxisSingle(axis, visitor);
|
|
45
|
+
}
|
|
46
|
+
if (axis && Object.hasOwn(axis, "enums")) {
|
|
47
|
+
const axisNew = (0, immutability_helper_1.default)(axis, {
|
|
48
|
+
enums: {
|
|
49
|
+
$apply: (enums) => visitor.visitEnums(enums),
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
const { enums } = axisNew;
|
|
53
|
+
return enums ? axisNew : null;
|
|
54
|
+
}
|
|
55
|
+
return axis;
|
|
56
|
+
};
|
|
57
|
+
const visitView = (view, visitor) => (0, immutability_helper_1.default)(view, {
|
|
58
|
+
"fibery/meta": {
|
|
59
|
+
y: {
|
|
60
|
+
$apply: (y) => visitAxis(y, visitor),
|
|
61
|
+
},
|
|
62
|
+
items: {
|
|
63
|
+
$apply: (items) => {
|
|
64
|
+
const removedItemsIndexes = items
|
|
65
|
+
.map((item, index) => (visitor.visitQueryExpression(item.query) ? null : index))
|
|
66
|
+
.filter((value) => value !== null);
|
|
67
|
+
return items
|
|
68
|
+
.map((item) => {
|
|
69
|
+
const fromType = (0, get_1.default)(item, ["query", "q/from"]);
|
|
70
|
+
const hasGroupingExpression = (0, has_1.default)(item, ["groupingExpression"]);
|
|
71
|
+
return fromType
|
|
72
|
+
? (0, immutability_helper_1.default)(item, {
|
|
73
|
+
yExpression: {
|
|
74
|
+
$apply: (yExpression) => yExpression ? visitor.visitExpression(fromType, yExpression) : yExpression,
|
|
75
|
+
},
|
|
76
|
+
startExpression: {
|
|
77
|
+
$apply: (startExpression) => startExpression ? visitor.visitExpression(fromType, startExpression) : startExpression,
|
|
78
|
+
},
|
|
79
|
+
endExpression: {
|
|
80
|
+
$apply: (endExpression) => endExpression ? visitor.visitExpression(fromType, endExpression) : endExpression,
|
|
81
|
+
},
|
|
82
|
+
secondaryStartExpression: {
|
|
83
|
+
$apply: (secondaryStartExpression) => secondaryStartExpression
|
|
84
|
+
? visitor.visitExpression(fromType, secondaryStartExpression)
|
|
85
|
+
: secondaryStartExpression,
|
|
86
|
+
},
|
|
87
|
+
secondaryEndExpression: {
|
|
88
|
+
$apply: (secondaryEndExpression) => secondaryEndExpression
|
|
89
|
+
? visitor.visitExpression(fromType, secondaryEndExpression)
|
|
90
|
+
: secondaryEndExpression,
|
|
91
|
+
},
|
|
92
|
+
contextExpression: {
|
|
93
|
+
$apply: (contextExpression) => (0, utils_1.visitContextExpression)(fromType, contextExpression, visitor),
|
|
94
|
+
},
|
|
95
|
+
filter: {
|
|
96
|
+
$apply: (filter) => (filter ? visitor.visitFilter(fromType, filter) : null),
|
|
97
|
+
},
|
|
98
|
+
query: {
|
|
99
|
+
$apply: (query) => (query ? visitor.visitQueryExpression(query) : null),
|
|
100
|
+
},
|
|
101
|
+
units: {
|
|
102
|
+
$apply: (units) => units
|
|
103
|
+
? units
|
|
104
|
+
.filter((unit) => Boolean(unit))
|
|
105
|
+
.map((unit) => (0, utils_1.visitViewUnit)(fromType, unit, visitor))
|
|
106
|
+
.filter((unit) => (0, utils_1.isUnitExpressionValid)(unit))
|
|
107
|
+
.map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit)
|
|
108
|
+
.filter((unit) => unit !== utils_1.REMOVE)
|
|
109
|
+
: undefined,
|
|
110
|
+
},
|
|
111
|
+
colorCoding: {
|
|
112
|
+
$apply: (colorCodings) => {
|
|
113
|
+
return (colorCodings &&
|
|
114
|
+
colorCodings
|
|
115
|
+
.map((colorCoding) => ({
|
|
116
|
+
...colorCoding,
|
|
117
|
+
expression: visitor.visitExpression(fromType, colorCoding.expression),
|
|
118
|
+
}))
|
|
119
|
+
.filter((colorCoding) => colorCoding.expression !== null));
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
dependencyExpression: {
|
|
123
|
+
$apply: (expression) => {
|
|
124
|
+
return expression && visitor.visitExpression(fromType, expression);
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
groupBy: {
|
|
128
|
+
$apply: (groupBy) => {
|
|
129
|
+
if (!groupBy) {
|
|
130
|
+
return groupBy;
|
|
131
|
+
}
|
|
132
|
+
const groupByIndexes = Object.keys(groupBy).map((key) => parseInt(key));
|
|
133
|
+
const removedItemsBeforeTargetLengths = groupByIndexes.map((groupByIndex) => removedItemsIndexes.filter((n) => n < groupByIndex).length);
|
|
134
|
+
return visitor.visitGroupByExpression(groupBy, fromType, removedItemsBeforeTargetLengths);
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
...(hasGroupingExpression
|
|
138
|
+
? {
|
|
139
|
+
groupingExpression: {
|
|
140
|
+
$apply: (groupingExpression) => {
|
|
141
|
+
if (!groupingExpression) {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
const groupingExpressionIndexes = Object.keys(groupingExpression).map((key) => parseInt(key));
|
|
145
|
+
const removedItemsBeforeTargetLengths = groupingExpressionIndexes.map((groupByIndex) => removedItemsIndexes.filter((n) => n < groupByIndex).length);
|
|
146
|
+
return visitor.visitGroupByExpression(groupingExpression, fromType, removedItemsBeforeTargetLengths);
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
}
|
|
150
|
+
: undefined),
|
|
151
|
+
})
|
|
152
|
+
: item;
|
|
153
|
+
})
|
|
154
|
+
.filter((item) => {
|
|
155
|
+
const { query } = item;
|
|
156
|
+
return query ? item : null;
|
|
157
|
+
});
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
milestones: {
|
|
161
|
+
$apply: (milestones) => {
|
|
162
|
+
if (!milestones) {
|
|
163
|
+
return milestones;
|
|
164
|
+
}
|
|
165
|
+
return milestones
|
|
166
|
+
.map((item) => {
|
|
167
|
+
const fromType = (0, get_1.default)(item, ["query", "q/from"]);
|
|
168
|
+
return fromType
|
|
169
|
+
? (0, immutability_helper_1.default)(item, {
|
|
170
|
+
dateExpression: {
|
|
171
|
+
$apply: (startExpression) => startExpression ? visitor.visitExpression(fromType, startExpression) : startExpression,
|
|
172
|
+
},
|
|
173
|
+
filter: {
|
|
174
|
+
$apply: (filter) => (filter ? visitor.visitFilter(fromType, filter) : null),
|
|
175
|
+
},
|
|
176
|
+
query: {
|
|
177
|
+
$apply: (query) => (query ? visitor.visitQueryExpression(query) : null),
|
|
178
|
+
},
|
|
179
|
+
contextExpression: {
|
|
180
|
+
$apply: (contextExpression) => (0, utils_1.visitContextExpression)(fromType, contextExpression, visitor),
|
|
181
|
+
},
|
|
182
|
+
})
|
|
183
|
+
: item;
|
|
184
|
+
})
|
|
185
|
+
.filter((item) => {
|
|
186
|
+
const { query } = item;
|
|
187
|
+
return query ? item : null;
|
|
188
|
+
});
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
const replaceNamesWithIdsInTimelineView = (schema, view) => {
|
|
194
|
+
const visitor = {
|
|
195
|
+
visitQueryExpression: (query) => (0, utils_1.replaceNamesWithIdsInQueryExpression)(schema, query),
|
|
196
|
+
visitFilter: (fromType, expression) => (0, utils_1.replaceNamesWithIdsInFilter)(schema, fromType, expression),
|
|
197
|
+
visitExpression: (fromType, expression) => (0, utils_1.replaceNamesWithIdsInExpression)(schema, fromType, expression),
|
|
198
|
+
visitEnums: (enums) => (0, entries_1.default)(enums).reduce((result, [type, axis]) => {
|
|
199
|
+
if (Object.hasOwn(schema.typeObjectsByName, type)) {
|
|
200
|
+
const typeObject = schema.typeObjectsByName[type];
|
|
201
|
+
result[typeObject.id] = visitAxisSingle(axis, visitor);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
result[type] = axis;
|
|
205
|
+
}
|
|
206
|
+
return result;
|
|
207
|
+
}, {}),
|
|
208
|
+
visitGroupByExpression: (groupBy, fromType) => (0, smart_folder_1.replaceNamesWithIdsInGroupByExpression)(schema, groupBy, fromType),
|
|
209
|
+
};
|
|
210
|
+
return visitView(view, visitor);
|
|
211
|
+
};
|
|
212
|
+
exports.replaceNamesWithIdsInTimelineView = replaceNamesWithIdsInTimelineView;
|
|
213
|
+
const replaceIdsWithNamesInTimelineView = (schema, view) => {
|
|
214
|
+
const visitor = {
|
|
215
|
+
visitQueryExpression: (query) => (0, utils_1.replaceIdsWithNamesInQueryExpression)(schema, query),
|
|
216
|
+
visitFilter: (fromType, expression) => (0, utils_1.replaceIdsWithNamesInFilter)(schema, fromType, expression),
|
|
217
|
+
visitExpression: (fromType, expression) => (0, utils_1.replaceIdsWithNamesInExpression)(schema, fromType, expression),
|
|
218
|
+
visitEnums: (enums) => (0, entries_1.default)(enums).reduce((result, [typeId, axis]) => {
|
|
219
|
+
if (Object.hasOwn(schema.typeObjectsById, typeId)) {
|
|
220
|
+
const typeObject = schema.typeObjectsById[typeId];
|
|
221
|
+
result[typeObject.name] = visitAxisSingle(axis, visitor);
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
result[typeId] = axis;
|
|
225
|
+
}
|
|
226
|
+
return result;
|
|
227
|
+
}, {}),
|
|
228
|
+
visitGroupByExpression: (groupBy, fromType) => (0, smart_folder_1.replaceIdsWithNamesInGroupByExpression)(schema, groupBy, fromType),
|
|
229
|
+
};
|
|
230
|
+
return visitView(view, visitor);
|
|
231
|
+
};
|
|
232
|
+
exports.replaceIdsWithNamesInTimelineView = replaceIdsWithNamesInTimelineView;
|
|
233
|
+
const ensureAxisAndItemExpressionInvariant = (view, canGroupMetaItem) => {
|
|
234
|
+
const actions = [];
|
|
235
|
+
const y = (0, get_1.default)(view, ["fibery/meta", "y"]);
|
|
236
|
+
const yQuery = (0, get_1.default)(view, ["fibery/meta", "y", "query"]);
|
|
237
|
+
const yGroupByExpression = (0, get_1.default)(view, ["fibery/meta", "y", "groupByExpression"]);
|
|
238
|
+
const items = (0, get_1.default)(view, ["fibery/meta", "items"]);
|
|
239
|
+
if (yQuery === null && yGroupByExpression !== null) {
|
|
240
|
+
actions.push(() => (0, set_1.default)(view, ["fibery/meta", "y", "groupByExpression"], null));
|
|
241
|
+
}
|
|
242
|
+
if (y === null) {
|
|
243
|
+
const resetActions = items.map((item) => () => (item.yExpression = null));
|
|
244
|
+
actions.push(...resetActions);
|
|
245
|
+
}
|
|
246
|
+
const filteredMetaItems = items.filter(canGroupMetaItem);
|
|
247
|
+
if (y !== null && (0, some_1.default)(filteredMetaItems, ({ yExpression }) => yExpression === null)) {
|
|
248
|
+
const resetActions = filteredMetaItems.map((item) => () => (item.yExpression = null));
|
|
249
|
+
actions.push(...resetActions);
|
|
250
|
+
actions.push(() => (0, set_1.default)(view, ["fibery/meta", "y"], null));
|
|
251
|
+
}
|
|
252
|
+
if (y !== null && (0, isEmpty_1.default)(items)) {
|
|
253
|
+
actions.push(() => (0, set_1.default)(view, ["fibery/meta", "y"], null));
|
|
254
|
+
}
|
|
255
|
+
actions.forEach((action) => action());
|
|
256
|
+
return view;
|
|
257
|
+
};
|
|
258
|
+
const deleteExpressionWithNotFoundFieldsOrTypesInTimelineView = (schema, view, ensureAxisInvariant, canGroupMetaItem = (metaItem) => true) => {
|
|
259
|
+
const visitor = {
|
|
260
|
+
visitQueryExpression: (queryExpression) => (0, utils_1.deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression)(schema, queryExpression),
|
|
261
|
+
visitFilter: (fromType, expression) => (0, utils_1.deleteExpressionWithNotFoundFieldsOrTypesInFilter)(schema, fromType, expression),
|
|
262
|
+
visitExpression: (fromType, expression) => (0, utils_1.deleteExpressionWithNotFoundFieldsOrTypesInExpression)(schema, fromType, expression),
|
|
263
|
+
visitEnums: (enums) => {
|
|
264
|
+
const enumsNew = (0, entries_1.default)(enums).reduce((result, [type, axis]) => {
|
|
265
|
+
if (Object.hasOwn(schema.typeObjectsByName, type)) {
|
|
266
|
+
const typeObject = schema.typeObjectsByName[type];
|
|
267
|
+
const axisResult = visitAxisSingle(axis, visitor);
|
|
268
|
+
if (axisResult) {
|
|
269
|
+
result[typeObject.name] = axisResult;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return result;
|
|
273
|
+
}, {});
|
|
274
|
+
return (0, isEmpty_1.default)(enumsNew) ? null : enumsNew;
|
|
275
|
+
},
|
|
276
|
+
visitGroupByExpression: (groupBy, fromType, removedItems) => (0, smart_folder_1.deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression)(schema, groupBy, fromType, removedItems),
|
|
277
|
+
};
|
|
278
|
+
const viewNew = visitView(view, visitor);
|
|
279
|
+
return ensureAxisInvariant ? ensureAxisAndItemExpressionInvariant(viewNew, canGroupMetaItem) : viewNew;
|
|
280
|
+
};
|
|
281
|
+
exports.deleteExpressionWithNotFoundFieldsOrTypesInTimelineView = deleteExpressionWithNotFoundFieldsOrTypesInTimelineView;
|
|
282
|
+
const fixUserSelectedUnitsInTimelineView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => {
|
|
283
|
+
return visitView(view, {
|
|
284
|
+
visitQueryExpression: (query) => query,
|
|
285
|
+
visitExpression: (_fromType, expression) => expression,
|
|
286
|
+
visitFilter: (_fromType, filter) => filter,
|
|
287
|
+
visitViewUnit: (fromType, unit, units) => (0, units_1.fixViewUnit)(schema, fromType, unit, units, { unitDefinitions, getDefaultUnitTypeForField }),
|
|
288
|
+
visitEnums: (enums) => enums,
|
|
289
|
+
visitGroupByExpression: (groupBy) => groupBy,
|
|
290
|
+
});
|
|
291
|
+
};
|
|
292
|
+
exports.fixUserSelectedUnitsInTimelineView = fixUserSelectedUnitsInTimelineView;
|
|
293
|
+
const fixContextExpressionWithBrokenPath = (schema, view, defaultContextExpression) => visitView(view, {
|
|
294
|
+
visitExpression: (_fromType, expression) => expression,
|
|
295
|
+
visitFilter: (_fromType, filter) => filter,
|
|
296
|
+
visitQueryExpression: (query) => query,
|
|
297
|
+
visitContextExpression: (fromType, expression) => (0, utils_1.resetContextExpressionIfBroken)(schema, fromType, expression, defaultContextExpression),
|
|
298
|
+
visitEnums: (enums) => enums,
|
|
299
|
+
visitGroupByExpression: (groupBy) => groupBy,
|
|
300
|
+
});
|
|
301
|
+
exports.fixContextExpressionWithBrokenPath = fixContextExpressionWithBrokenPath;
|
|
302
|
+
const collectGarbage = (view) => {
|
|
303
|
+
return visitView(view, {
|
|
304
|
+
visitQueryExpression: (query) => query,
|
|
305
|
+
visitFilter: (_fromType, filter) => filter,
|
|
306
|
+
visitExpression: (_fromType, expression) => expression,
|
|
307
|
+
visitViewUnit: (_fromType, unit) => (unit.checked ? unit : utils_1.REMOVE),
|
|
308
|
+
visitEnums: (enums) => enums,
|
|
309
|
+
visitGroupByExpression: (groupBy) => groupBy,
|
|
310
|
+
});
|
|
311
|
+
};
|
|
312
|
+
exports.collectGarbage = collectGarbage;
|
|
313
|
+
const enableHideWhenEmptyForCheckedEditableUnits = (view) => {
|
|
314
|
+
return visitView(view, {
|
|
315
|
+
visitQueryExpression: (queryExpression) => queryExpression,
|
|
316
|
+
visitExpression: (_fromType, expression) => expression,
|
|
317
|
+
visitFilter: (_fromType, filter) => filter,
|
|
318
|
+
visitViewUnit: (_fromType, unit) => (0, units_1.enableHideWhenEmptyForCheckedEditableUnit)(unit),
|
|
319
|
+
visitEnums: (enums) => enums,
|
|
320
|
+
visitGroupByExpression: (groupBy) => groupBy,
|
|
321
|
+
});
|
|
322
|
+
};
|
|
323
|
+
exports.enableHideWhenEmptyForCheckedEditableUnits = enableHideWhenEmptyForCheckedEditableUnits;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export function fixViewUnit(schema: any, fromType: any, unit: any, units: any, { unitDefinitions, getDefaultUnitTypeForField, migrateFileCollectionUnit }: {
|
|
2
|
+
unitDefinitions: any;
|
|
3
|
+
getDefaultUnitTypeForField: any;
|
|
4
|
+
migrateFileCollectionUnit?: boolean | undefined;
|
|
5
|
+
}): any;
|
|
6
|
+
export function enableHideWhenEmptyForCheckedEditableUnit(unit: any): any;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enableHideWhenEmptyForCheckedEditableUnit = exports.fixViewUnit = void 0;
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
const getField = (schema, fromType, field) => Object.hasOwn(schema.typeObjectsByName, fromType) &&
|
|
6
|
+
Object.hasOwn(schema.typeObjectsByName[fromType].fieldObjectsByName, field)
|
|
7
|
+
? schema.typeObjectsByName[fromType].fieldObjectsByName[field]
|
|
8
|
+
: undefined;
|
|
9
|
+
const getFieldType = (schema, fromType, field) => getField(schema, fromType, field)?.type;
|
|
10
|
+
const getFieldMeta = (schema, fromType, field) => getField(schema, fromType, field)?.rawMeta;
|
|
11
|
+
const getUnitTypeForTextField = (fieldMeta) => {
|
|
12
|
+
switch (fieldMeta["ui/type"]) {
|
|
13
|
+
case "email":
|
|
14
|
+
return "email";
|
|
15
|
+
case "url":
|
|
16
|
+
return "url";
|
|
17
|
+
case "phone":
|
|
18
|
+
return "phone";
|
|
19
|
+
default:
|
|
20
|
+
return "text";
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const getUnitKind = (unit) => {
|
|
24
|
+
if (unit.type === "user-button") {
|
|
25
|
+
return "user-button";
|
|
26
|
+
}
|
|
27
|
+
if (["type-icon", "type-badge", "type-badge-abbr"].includes(unit.type)) {
|
|
28
|
+
return "db";
|
|
29
|
+
}
|
|
30
|
+
return "field";
|
|
31
|
+
};
|
|
32
|
+
const migrateUnitOptsDefault = {
|
|
33
|
+
migrateFileCollectionUnit: true,
|
|
34
|
+
};
|
|
35
|
+
const migrateUnit = (schema, fromType, unit, units, opts = migrateUnitOptsDefault) => {
|
|
36
|
+
const { type, expression } = unit;
|
|
37
|
+
const kind = unit.kind || getUnitKind(unit);
|
|
38
|
+
if (type === "date-time") {
|
|
39
|
+
return {
|
|
40
|
+
...unit,
|
|
41
|
+
kind,
|
|
42
|
+
type: "date",
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (type === "date-time-range") {
|
|
46
|
+
return {
|
|
47
|
+
...unit,
|
|
48
|
+
kind,
|
|
49
|
+
type: "date-range",
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
if (type === "text") {
|
|
53
|
+
const [field] = expression;
|
|
54
|
+
const fieldType = getFieldType(schema, fromType, field);
|
|
55
|
+
if (fieldType === "fibery/email") {
|
|
56
|
+
return {
|
|
57
|
+
...unit,
|
|
58
|
+
kind,
|
|
59
|
+
type: "email",
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (["text", "email", "phone", "url"].includes(type)) {
|
|
64
|
+
const [field] = expression;
|
|
65
|
+
if (getFieldType(schema, fromType, field) === "fibery/text") {
|
|
66
|
+
return {
|
|
67
|
+
...unit,
|
|
68
|
+
kind,
|
|
69
|
+
type: getUnitTypeForTextField(getFieldMeta(schema, fromType, field)),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (type === "files-collection") {
|
|
74
|
+
const [field] = expression;
|
|
75
|
+
if (getFieldType(schema, fromType, field) === "fibery/file") {
|
|
76
|
+
return {
|
|
77
|
+
...unit,
|
|
78
|
+
kind,
|
|
79
|
+
type: opts.migrateFileCollectionUnit ? "file-collection-count" : "collection-count",
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (type === "avatar" && !expression) {
|
|
84
|
+
const isAvatarExntensionEnabled = schema.typeObjectsByName[fromType]?.installedMixins.has("avatar/avatar-mixin");
|
|
85
|
+
const hasAvatarExntensionField = getFieldType(schema, fromType, "avatar/avatars") === "fibery/file";
|
|
86
|
+
if (isAvatarExntensionEnabled && hasAvatarExntensionField) {
|
|
87
|
+
return {
|
|
88
|
+
...unit,
|
|
89
|
+
expression: ["avatar/avatars"],
|
|
90
|
+
kind,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (opts.migrateFileCollectionUnit && type === "collection-count") {
|
|
95
|
+
const [field] = expression;
|
|
96
|
+
const fieldObject = getField(schema, fromType, field);
|
|
97
|
+
if (fieldObject?.type === "fibery/file" && fieldObject?.isCollection) {
|
|
98
|
+
return {
|
|
99
|
+
...unit,
|
|
100
|
+
kind,
|
|
101
|
+
type: "file-collection-count",
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return { ...unit, kind };
|
|
106
|
+
};
|
|
107
|
+
const fixViewUnit = (schema, fromType, unit, units, { unitDefinitions, getDefaultUnitTypeForField, migrateFileCollectionUnit = true }) => {
|
|
108
|
+
const migrated = migrateUnit(schema, fromType, unit, units, { migrateFileCollectionUnit });
|
|
109
|
+
const field = unit.expression?.[0];
|
|
110
|
+
const fieldObject = getField(schema, fromType, field);
|
|
111
|
+
if (fieldObject) {
|
|
112
|
+
const allowedUnits = unitDefinitions.getUnitsForField(fieldObject);
|
|
113
|
+
if (allowedUnits.some((u) => u.type === migrated.type)) {
|
|
114
|
+
return migrated;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
if (unit.checked) {
|
|
118
|
+
const otherUnitsForField = units.filter((u) => u !== unit && u.expression && u.expression[0] === field);
|
|
119
|
+
const hasEnabledUnitForField = otherUnitsForField.some((u) => u.checked);
|
|
120
|
+
if (hasEnabledUnitForField) {
|
|
121
|
+
return utils_1.REMOVE;
|
|
122
|
+
}
|
|
123
|
+
const defaultUnitType = getDefaultUnitTypeForField(fieldObject, allowedUnits);
|
|
124
|
+
const defaultUnit = (defaultUnitType && otherUnitsForField.find((u) => u.type === defaultUnitType)) || otherUnitsForField[0];
|
|
125
|
+
if (defaultUnit) {
|
|
126
|
+
defaultUnit.checked = true;
|
|
127
|
+
return utils_1.REMOVE;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
return utils_1.REMOVE;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return migrated;
|
|
136
|
+
};
|
|
137
|
+
exports.fixViewUnit = fixViewUnit;
|
|
138
|
+
const enableHideWhenEmptyForCheckedEditableUnit = (unit) => {
|
|
139
|
+
if (unit.checked) {
|
|
140
|
+
return { ...unit, hideWhenEmpty: true };
|
|
141
|
+
}
|
|
142
|
+
return unit;
|
|
143
|
+
};
|
|
144
|
+
exports.enableHideWhenEmptyForCheckedEditableUnit = enableHideWhenEmptyForCheckedEditableUnit;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const REMOVE: unique symbol;
|
|
2
|
+
export function deleteExpressionWithNotFoundFieldsOrTypesInFilter(schema: any, fromType: any, filter: any): any;
|
|
3
|
+
export function deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema: any, queryExpression: any): Partial<any> | null;
|
|
4
|
+
export function replaceNamesWithIdsInExpression(schema: any, fromType: any, expression: any): any;
|
|
5
|
+
export function replaceIdsWithNamesInExpression(schema: any, fromTypeId: any, expression: any): any;
|
|
6
|
+
export function visitViewUnit(fromType: any, unit: any, visitor: any): any;
|
|
7
|
+
export function visitContextExpression(fromType: any, contextExpression: any, visitor: any): any;
|
|
8
|
+
export function replaceIdsWithNamesInQueryExpression(schema: any, queryExpression: any): any;
|
|
9
|
+
export function replaceIdsWithNamesInFilter(schema: any, fromType: any, filter: any): any;
|
|
10
|
+
export function replaceNamesWithIdsInFilter(schema: any, fromType: any, filter: any): any;
|
|
11
|
+
export function replaceNamesWithIdsInQueryExpression(schema: any, queryExpression: any): any;
|
|
12
|
+
export function deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema: any, fromType: any, expression: any): any;
|
|
13
|
+
export function resetContextExpressionIfBroken(schema: any, fromType: any, expression: any, defaultExpression: any): any;
|
|
14
|
+
export function isUnitExpressionValid(unit: any): boolean;
|
|
15
|
+
export function getFieldObjectsById(smartFolder: any, schema: any): any;
|
|
16
|
+
export function replaceIdsWithNamesInUnitGroupKey(unitGroupKey: any, fieldObjectsById: any): any;
|
|
17
|
+
export function replaceNamesWithIdsInUnitGroupKey(unitGroupKey: any, schema: any): any;
|