@fibery/views 19.0.0 → 19.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.
- package/lib/src/index.d.ts +28 -16
- package/lib/src/index.js +1 -1
- package/lib/src/private/board.d.ts +15 -11
- package/lib/src/private/board.js +8 -7
- package/lib/src/private/calendar.d.ts +14 -10
- package/lib/src/private/calendar.js +4 -3
- package/lib/src/private/feed.d.ts +14 -10
- package/lib/src/private/feed.js +4 -3
- package/lib/src/private/form.d.ts +25 -3
- package/lib/src/private/form.js +3 -3
- package/lib/src/private/map.d.ts +14 -10
- package/lib/src/private/map.js +4 -3
- package/lib/src/private/smart-folder.d.ts +23 -15
- package/lib/src/private/smart-folder.js +16 -13
- package/lib/src/private/timeline.d.ts +39 -10
- package/lib/src/private/timeline.js +8 -6
- package/lib/src/private/units.d.ts +10 -6
- package/lib/src/private/units.js +32 -24
- package/lib/src/private/utils.d.ts +64 -17
- package/lib/src/private/utils.js +26 -20
- package/lib/src/truthy.d.ts +1 -0
- package/lib/src/truthy.js +7 -0
- package/lib/src/unit-definitions/avatar-collection.js +2 -3
- package/lib/src/unit-definitions/avatar.js +3 -5
- package/lib/src/unit-definitions/collection-count.js +4 -2
- package/lib/src/unit-definitions/file-collection-count.js +9 -7
- package/lib/src/unit-definitions/file-compact-collection.js +9 -7
- package/lib/src/unit-definitions/file-compact-reference.js +2 -11
- package/lib/src/unit-definitions/file-reference.js +6 -4
- package/lib/src/unit-definitions/files-gallery.js +9 -7
- package/lib/src/unit-definitions/files-l-list-item.js +6 -4
- package/lib/src/unit-definitions/files-l-list.js +9 -7
- package/lib/src/unit-definitions/files-list-item.js +6 -4
- package/lib/src/unit-definitions/files-list.js +9 -7
- package/lib/src/unit-definitions/number.js +2 -4
- package/lib/src/unit-definitions/progress-bar.js +1 -4
- package/lib/src/unit-definitions/rich-text-snippet.d.ts +1 -0
- package/lib/src/unit-definitions/rich-text-snippet.js +6 -11
- package/lib/src/unit-utils/get-export-value.js +2 -1
- package/lib/src/unit-utils/wrap-normalized-in-expression.d.ts +3 -0
- package/lib/src/unit-utils/wrap-normalized-in-expression.js +14 -0
- package/lib/src/units/board.d.ts +4 -4
- package/lib/src/units/canvas/index.d.ts +4 -4
- package/lib/src/units/default.d.ts +4 -4
- package/lib/src/units/gantt.d.ts +4 -4
- package/lib/src/units/grid.d.ts +4 -4
- package/lib/src/units/list.d.ts +4 -4
- package/lib/src/units/make-factory.d.ts +2 -3
- package/lib/src/units/make-factory.js +18 -7
- package/lib/src/units/types.d.ts +1 -1
- package/package.json +18 -18
- package/lib/jest.config.cjs +0 -34
- package/lib/jest.config.d.cts +0 -3
package/lib/src/index.d.ts
CHANGED
|
@@ -1,16 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export
|
|
16
|
-
export
|
|
1
|
+
import type { Expression } from "@fibery/expression-utils/src/types";
|
|
2
|
+
import type { FieldObject, Schema } from "@fibery/schema";
|
|
3
|
+
import type { UnitDefinitions, ViewRecord } from "./private/utils";
|
|
4
|
+
import type { Unit } from "./units/types";
|
|
5
|
+
export { deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder, replaceIdsWithNamesInSmartFolder, replaceNamesWithIdsInSmartFolder, } from "./private/smart-folder";
|
|
6
|
+
export declare const deleteExpressionWithNotFoundFieldsOrTypesInView: (schema: Schema, view: ViewRecord, ensureAxisInvariant?: boolean) => any;
|
|
7
|
+
export declare const fixUserSelectedUnits: (schema: Schema, view: ViewRecord, { unitDefinitions, getDefaultUnitTypeForField, }: {
|
|
8
|
+
unitDefinitions: UnitDefinitions;
|
|
9
|
+
getDefaultUnitTypeForField: (fieldObject: FieldObject, allowedUnits: Unit[]) => string | undefined;
|
|
10
|
+
}) => any;
|
|
11
|
+
export declare const fixContextExpressionWithBrokenPath: (schema: Schema, view: ViewRecord, defaultContextExpression: Expression) => any;
|
|
12
|
+
/**
|
|
13
|
+
* Removes garbage from view's meta to reduce the size.
|
|
14
|
+
*/
|
|
15
|
+
export declare const collectGarbage: (schema: Schema, view: ViewRecord) => unknown;
|
|
16
|
+
export declare const replaceNamesWithIdsInView: (schema: Schema, view: ViewRecord) => any;
|
|
17
|
+
export declare const replaceIdsWithNamesInView: (schema: Schema, view: ViewRecord) => any;
|
|
18
|
+
type ViewMeta = {
|
|
19
|
+
items: {
|
|
20
|
+
query: {
|
|
21
|
+
"q/from": string;
|
|
22
|
+
};
|
|
23
|
+
}[];
|
|
24
|
+
};
|
|
25
|
+
export declare const getViewCardTypes: ({ "fibery/meta": { items } }: {
|
|
26
|
+
"fibery/meta": ViewMeta;
|
|
27
|
+
}) => string[];
|
|
28
|
+
export declare const migrateHideWhenEmptyToUnitsLevel: (view: ViewRecord) => any;
|
package/lib/src/index.js
CHANGED
|
@@ -80,7 +80,7 @@ const deleteExpressionWithNotFoundFieldsOrTypesInView = (schema, view, ensureAxi
|
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
exports.deleteExpressionWithNotFoundFieldsOrTypesInView = deleteExpressionWithNotFoundFieldsOrTypesInView;
|
|
83
|
-
const fixUserSelectedUnits = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => {
|
|
83
|
+
const fixUserSelectedUnits = (schema, view, { unitDefinitions, getDefaultUnitTypeForField, }) => {
|
|
84
84
|
switch (view["fibery/type"]) {
|
|
85
85
|
case "board":
|
|
86
86
|
case "gallery":
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import type { Expression } from "@fibery/expression-utils/src/types";
|
|
2
|
+
import type { FieldObject, Schema } from "@fibery/schema";
|
|
3
|
+
import type { UnitDefinitions, ViewRecord } from "./utils";
|
|
4
|
+
import { Unit } from "@fibery/views/src/units/types";
|
|
5
|
+
export declare const replaceIdsWithNamesInBoardView: (schema: Schema, view: ViewRecord) => any;
|
|
6
|
+
export declare const replaceNamesWithIdsInBoardView: (schema: Schema, view: ViewRecord) => any;
|
|
7
|
+
export declare const deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView: (schema: Schema, view: ViewRecord, ensureAxisInvariant?: boolean) => any;
|
|
8
|
+
export declare const fixUserSelectedUnitsInBoardView: (schema: Schema, view: ViewRecord, { unitDefinitions, getDefaultUnitTypeForField, }: {
|
|
9
|
+
unitDefinitions: UnitDefinitions;
|
|
10
|
+
getDefaultUnitTypeForField: (fieldObject: FieldObject, allowedUnits: Unit[]) => string | undefined;
|
|
11
|
+
}) => any;
|
|
12
|
+
export declare const fixContextExpressionWithBrokenPath: (schema: Schema, view: ViewRecord, defaultContextExpression: Expression) => any;
|
|
13
|
+
export declare const collectGarbage: (view: ViewRecord) => any;
|
|
14
|
+
export declare const enableHideWhenEmptyForCovers: (view: ViewRecord) => any;
|
|
15
|
+
export declare const enableHideWhenEmptyForCheckedEditableUnits: (view: ViewRecord) => any;
|
package/lib/src/private/board.js
CHANGED
|
@@ -11,6 +11,7 @@ const get_1 = __importDefault(require("lodash/get"));
|
|
|
11
11
|
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
12
12
|
const set_1 = __importDefault(require("lodash/set"));
|
|
13
13
|
const some_1 = __importDefault(require("lodash/some"));
|
|
14
|
+
const truthy_1 = require("../truthy");
|
|
14
15
|
const units_1 = require("./units");
|
|
15
16
|
const utils_2 = require("./utils");
|
|
16
17
|
const visitQueryExpressionHolder = (queryHolder, visitor) => {
|
|
@@ -49,11 +50,11 @@ const visitAxisUnits = (axis, fromType, visitor) => {
|
|
|
49
50
|
units: {
|
|
50
51
|
$apply: (units) => units
|
|
51
52
|
? units
|
|
52
|
-
.filter(
|
|
53
|
+
.filter(truthy_1.truthy)
|
|
53
54
|
.map((unit) => (0, utils_2.visitViewUnit)(fromType, unit, visitor))
|
|
54
|
-
.filter(
|
|
55
|
+
.filter(utils_2.isUnitExpressionValid)
|
|
55
56
|
.map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit)
|
|
56
|
-
.filter(
|
|
57
|
+
.filter(utils_2.skipRemove)
|
|
57
58
|
: undefined,
|
|
58
59
|
},
|
|
59
60
|
})
|
|
@@ -161,9 +162,9 @@ const visitView = (view, visitor) => (0, immutability_helper_1.default)(view, {
|
|
|
161
162
|
units: {
|
|
162
163
|
$apply: (units) => units
|
|
163
164
|
? units
|
|
164
|
-
.filter(
|
|
165
|
+
.filter(truthy_1.truthy)
|
|
165
166
|
.map((unit) => (0, utils_2.visitViewUnit)(fromType, unit, visitor))
|
|
166
|
-
.filter(
|
|
167
|
+
.filter(utils_2.isUnitExpressionValid)
|
|
167
168
|
.map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit)
|
|
168
169
|
.filter((unit) => unit !== utils_2.REMOVE)
|
|
169
170
|
: undefined,
|
|
@@ -255,7 +256,7 @@ const deleteExpressionWithNotFoundFieldsOrTypesViewVisitor = (schema) => {
|
|
|
255
256
|
};
|
|
256
257
|
return visitor;
|
|
257
258
|
};
|
|
258
|
-
const fixUserSelectedUnitsViewVisitor = (schema, { unitDefinitions, getDefaultUnitTypeForField }) => {
|
|
259
|
+
const fixUserSelectedUnitsViewVisitor = (schema, { unitDefinitions, getDefaultUnitTypeForField, }) => {
|
|
259
260
|
return {
|
|
260
261
|
visitQueryExpression: (queryExpression) => queryExpression,
|
|
261
262
|
visitFilter: (_fromType, filter) => filter,
|
|
@@ -273,7 +274,7 @@ const deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView = (schema, v
|
|
|
273
274
|
return ensureAxisInvariant ? ensureAxisAndItemExpressionInvariant(viewNew) : viewNew;
|
|
274
275
|
};
|
|
275
276
|
exports.deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView = deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView;
|
|
276
|
-
const fixUserSelectedUnitsInBoardView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => {
|
|
277
|
+
const fixUserSelectedUnitsInBoardView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField, }) => {
|
|
277
278
|
return visitView(view, fixUserSelectedUnitsViewVisitor(schema, { unitDefinitions, getDefaultUnitTypeForField }));
|
|
278
279
|
};
|
|
279
280
|
exports.fixUserSelectedUnitsInBoardView = fixUserSelectedUnitsInBoardView;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import type { Expression } from "@fibery/expression-utils/src/types";
|
|
2
|
+
import type { FieldObject, Schema } from "@fibery/schema";
|
|
3
|
+
import type { UnitDefinitions, ViewRecord } from "./utils";
|
|
4
|
+
import { Unit } from "@fibery/views/src/units/types";
|
|
5
|
+
export declare const replaceNamesWithIdsInCalendarView: (schema: Schema, view: ViewRecord) => any;
|
|
6
|
+
export declare const replaceIdsWithNamesInCalendarView: (schema: Schema, view: ViewRecord) => any;
|
|
7
|
+
export declare const deleteExpressionWithNotFoundFieldsOrTypesInCalendarView: (schema: Schema, view: ViewRecord) => any;
|
|
8
|
+
export declare const fixUserSelectedUnitsInCalendarView: (schema: Schema, view: ViewRecord, { unitDefinitions, getDefaultUnitTypeForField, }: {
|
|
9
|
+
unitDefinitions: UnitDefinitions;
|
|
10
|
+
getDefaultUnitTypeForField: (fieldObject: FieldObject, allowedUnits: Unit[]) => string | undefined;
|
|
11
|
+
}) => any;
|
|
12
|
+
export declare const fixContextExpressionWithBrokenPath: (schema: Schema, view: ViewRecord, defaultContextExpression: Expression) => any;
|
|
13
|
+
export declare const collectGarbage: (view: ViewRecord) => any;
|
|
14
|
+
export declare const enableHideWhenEmptyForCheckedUnits: (view: ViewRecord) => any;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.enableHideWhenEmptyForCheckedUnits = exports.collectGarbage = exports.fixContextExpressionWithBrokenPath = exports.fixUserSelectedUnitsInCalendarView = exports.deleteExpressionWithNotFoundFieldsOrTypesInCalendarView = exports.replaceIdsWithNamesInCalendarView = exports.replaceNamesWithIdsInCalendarView = void 0;
|
|
7
7
|
const immutability_helper_1 = __importDefault(require("immutability-helper"));
|
|
8
8
|
const get_1 = __importDefault(require("lodash/get"));
|
|
9
|
+
const truthy_1 = require("../truthy");
|
|
9
10
|
const units_1 = require("./units");
|
|
10
11
|
const utils_1 = require("./utils");
|
|
11
12
|
const visitView = (view, visitor) => (0, immutability_helper_1.default)(view, {
|
|
@@ -34,9 +35,9 @@ const visitView = (view, visitor) => (0, immutability_helper_1.default)(view, {
|
|
|
34
35
|
units: {
|
|
35
36
|
$apply: (units) => units
|
|
36
37
|
? units
|
|
37
|
-
.filter(
|
|
38
|
+
.filter(truthy_1.truthy)
|
|
38
39
|
.map((unit) => (0, utils_1.visitViewUnit)(fromType, unit, visitor))
|
|
39
|
-
.filter(
|
|
40
|
+
.filter(utils_1.isUnitExpressionValid)
|
|
40
41
|
.map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit)
|
|
41
42
|
.filter((unit) => unit !== utils_1.REMOVE)
|
|
42
43
|
: undefined,
|
|
@@ -84,7 +85,7 @@ const deleteExpressionWithNotFoundFieldsOrTypesInCalendarView = (schema, view) =
|
|
|
84
85
|
visitExpression: (fromType, expression) => (0, utils_1.deleteExpressionWithNotFoundFieldsOrTypesInExpression)(schema, fromType, expression),
|
|
85
86
|
});
|
|
86
87
|
exports.deleteExpressionWithNotFoundFieldsOrTypesInCalendarView = deleteExpressionWithNotFoundFieldsOrTypesInCalendarView;
|
|
87
|
-
const fixUserSelectedUnitsInCalendarView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => {
|
|
88
|
+
const fixUserSelectedUnitsInCalendarView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField, }) => {
|
|
88
89
|
return visitView(view, {
|
|
89
90
|
visitExpression: (_fromType, expression) => expression,
|
|
90
91
|
visitFilter: (_fromType, filter) => filter,
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import type { Expression } from "@fibery/expression-utils/src/types";
|
|
2
|
+
import type { FieldObject, Schema } from "@fibery/schema";
|
|
3
|
+
import type { UnitDefinitions, ViewRecord } from "./utils";
|
|
4
|
+
import { Unit } from "@fibery/views/src/units/types";
|
|
5
|
+
export declare const replaceNamesWithIdsInFeedView: (schema: Schema, view: ViewRecord) => any;
|
|
6
|
+
export declare const replaceIdsWithNamesInFeedView: (schema: Schema, view: ViewRecord) => any;
|
|
7
|
+
export declare const deleteExpressionWithNotFoundFieldsOrTypesInFeedView: (schema: Schema, view: ViewRecord) => any;
|
|
8
|
+
export declare const fixUserSelectedUnitsInFeedView: (schema: Schema, view: ViewRecord, { unitDefinitions, getDefaultUnitTypeForField, }: {
|
|
9
|
+
unitDefinitions: UnitDefinitions;
|
|
10
|
+
getDefaultUnitTypeForField: (fieldObject: FieldObject, allowedUnits: Unit[]) => string | undefined;
|
|
11
|
+
}) => any;
|
|
12
|
+
export declare const fixContextExpressionWithBrokenPath: (schema: Schema, view: ViewRecord, defaultContextExpression: Expression) => any;
|
|
13
|
+
export declare const collectGarbage: (view: ViewRecord) => any;
|
|
14
|
+
export declare const enableHideWhenEmptyForCheckedUnits: (view: ViewRecord) => any;
|
package/lib/src/private/feed.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.enableHideWhenEmptyForCheckedUnits = exports.collectGarbage = exports.fixContextExpressionWithBrokenPath = exports.fixUserSelectedUnitsInFeedView = exports.deleteExpressionWithNotFoundFieldsOrTypesInFeedView = exports.replaceIdsWithNamesInFeedView = exports.replaceNamesWithIdsInFeedView = void 0;
|
|
7
7
|
const immutability_helper_1 = __importDefault(require("immutability-helper"));
|
|
8
8
|
const get_1 = __importDefault(require("lodash/get"));
|
|
9
|
+
const truthy_1 = require("../truthy");
|
|
9
10
|
const units_1 = require("./units");
|
|
10
11
|
const utils_1 = require("./utils");
|
|
11
12
|
const visitView = (view, visitor) => (0, immutability_helper_1.default)(view, {
|
|
@@ -31,9 +32,9 @@ const visitView = (view, visitor) => (0, immutability_helper_1.default)(view, {
|
|
|
31
32
|
units: {
|
|
32
33
|
$apply: (units) => units
|
|
33
34
|
? units
|
|
34
|
-
.filter(
|
|
35
|
+
.filter(truthy_1.truthy)
|
|
35
36
|
.map((unit) => (0, utils_1.visitViewUnit)(fromType, unit, visitor))
|
|
36
|
-
.filter(
|
|
37
|
+
.filter(utils_1.isUnitExpressionValid)
|
|
37
38
|
.map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit)
|
|
38
39
|
.filter((unit) => unit !== utils_1.REMOVE)
|
|
39
40
|
: undefined,
|
|
@@ -81,7 +82,7 @@ const deleteExpressionWithNotFoundFieldsOrTypesInFeedView = (schema, view) => vi
|
|
|
81
82
|
visitExpression: (fromType, expression) => (0, utils_1.deleteExpressionWithNotFoundFieldsOrTypesInExpression)(schema, fromType, expression),
|
|
82
83
|
});
|
|
83
84
|
exports.deleteExpressionWithNotFoundFieldsOrTypesInFeedView = deleteExpressionWithNotFoundFieldsOrTypesInFeedView;
|
|
84
|
-
const fixUserSelectedUnitsInFeedView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => {
|
|
85
|
+
const fixUserSelectedUnitsInFeedView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField, }) => {
|
|
85
86
|
return visitView(view, {
|
|
86
87
|
visitExpression: (_fromType, expression) => expression,
|
|
87
88
|
visitFilter: (_fromType, filter) => filter,
|
|
@@ -1,3 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { Schema } from "@fibery/schema";
|
|
2
|
+
import type { ViewRecord } from "./utils";
|
|
3
|
+
type FormField = {
|
|
4
|
+
id: string;
|
|
5
|
+
[k: string]: unknown;
|
|
6
|
+
};
|
|
7
|
+
export declare const replaceNamesWithIdsInFormView: (schema: Schema, view: ViewRecord) => {
|
|
8
|
+
"fibery/meta": {
|
|
9
|
+
typeId: string | undefined;
|
|
10
|
+
fields: FormField[] | undefined;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare const replaceIdsWithNamesInFormView: (schema: Schema, view: ViewRecord) => {
|
|
14
|
+
"fibery/meta": {
|
|
15
|
+
typeId: string | undefined;
|
|
16
|
+
fields: FormField[] | undefined;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export declare const deleteExpressionWithNotFoundFieldsOrTypesInFormView: (schema: Schema, view: ViewRecord) => {
|
|
20
|
+
"fibery/meta": {
|
|
21
|
+
typeId: string | undefined;
|
|
22
|
+
fields: FormField[] | undefined;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export {};
|
package/lib/src/private/form.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.deleteExpressionWithNotFoundFieldsOrTypesInFormView = exports.replaceIdsWithNamesInFormView = exports.replaceNamesWithIdsInFormView = void 0;
|
|
4
4
|
const replaceNamesWithIdsInFormView = (schema, view) => {
|
|
5
5
|
const typeId = view["fibery/meta"]?.typeId;
|
|
6
|
-
const typeObject = Object.hasOwn(schema.typeObjectsByName, typeId) ? schema.typeObjectsByName[typeId] : null;
|
|
6
|
+
const typeObject = typeId && Object.hasOwn(schema.typeObjectsByName, typeId) ? schema.typeObjectsByName[typeId] : null;
|
|
7
7
|
const fields = view["fibery/meta"]?.fields;
|
|
8
8
|
const fieldsInIdsTerms = fields &&
|
|
9
9
|
fields.map((field) => {
|
|
@@ -24,7 +24,7 @@ const replaceNamesWithIdsInFormView = (schema, view) => {
|
|
|
24
24
|
exports.replaceNamesWithIdsInFormView = replaceNamesWithIdsInFormView;
|
|
25
25
|
const replaceIdsWithNamesInFormView = (schema, view) => {
|
|
26
26
|
const typeId = view["fibery/meta"]?.typeId;
|
|
27
|
-
const typeObject = Object.hasOwn(schema.typeObjectsById, typeId) ? schema.typeObjectsById[typeId] : null;
|
|
27
|
+
const typeObject = typeId && Object.hasOwn(schema.typeObjectsById, typeId) ? schema.typeObjectsById[typeId] : null;
|
|
28
28
|
const fields = view["fibery/meta"]?.fields;
|
|
29
29
|
const fieldsInNameTerms = fields &&
|
|
30
30
|
fields.map((field) => {
|
|
@@ -46,7 +46,7 @@ exports.replaceIdsWithNamesInFormView = replaceIdsWithNamesInFormView;
|
|
|
46
46
|
const deleteExpressionWithNotFoundFieldsOrTypesInFormView = (schema, view) => {
|
|
47
47
|
// we expect view in names terms here.
|
|
48
48
|
const typeName = view["fibery/meta"]?.typeId;
|
|
49
|
-
const typeObject = Object.hasOwn(schema.typeObjectsByName, typeName) ? schema.typeObjectsByName[typeName] : null;
|
|
49
|
+
const typeObject = typeName && Object.hasOwn(schema.typeObjectsByName, typeName) ? schema.typeObjectsByName[typeName] : null;
|
|
50
50
|
const fields = view["fibery/meta"]?.fields;
|
|
51
51
|
const existingFields = fields && fields.filter((field) => typeObject && Object.hasOwn(typeObject.fieldObjectsByName, field.id));
|
|
52
52
|
return {
|
package/lib/src/private/map.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import type { Expression } from "@fibery/expression-utils/src/types";
|
|
2
|
+
import type { FieldObject, Schema } from "@fibery/schema";
|
|
3
|
+
import type { UnitDefinitions, ViewRecord } from "./utils";
|
|
4
|
+
import { Unit } from "@fibery/views/src/units/types";
|
|
5
|
+
export declare const replaceNamesWithIdsInMapView: (schema: Schema, view: ViewRecord) => any;
|
|
6
|
+
export declare const replaceIdsWithNamesInMapView: (schema: Schema, view: ViewRecord) => any;
|
|
7
|
+
export declare const deleteExpressionWithNotFoundFieldsOrTypesInMapView: (schema: Schema, view: ViewRecord) => any;
|
|
8
|
+
export declare const fixUserSelectedUnitsInMapView: (schema: Schema, view: ViewRecord, { unitDefinitions, getDefaultUnitTypeForField, }: {
|
|
9
|
+
unitDefinitions: UnitDefinitions;
|
|
10
|
+
getDefaultUnitTypeForField: (fieldObject: FieldObject, allowedUnits: Unit[]) => string | undefined;
|
|
11
|
+
}) => any;
|
|
12
|
+
export declare const fixContextExpressionWithBrokenPath: (schema: Schema, view: ViewRecord, defaultContextExpression: Expression) => any;
|
|
13
|
+
export declare const collectGarbage: (view: ViewRecord) => any;
|
|
14
|
+
export declare const enableHideWhenEmptyForCheckedUnits: (view: ViewRecord) => any;
|
package/lib/src/private/map.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.enableHideWhenEmptyForCheckedUnits = exports.collectGarbage = exports.fixContextExpressionWithBrokenPath = exports.fixUserSelectedUnitsInMapView = exports.deleteExpressionWithNotFoundFieldsOrTypesInMapView = exports.replaceIdsWithNamesInMapView = exports.replaceNamesWithIdsInMapView = void 0;
|
|
7
7
|
const immutability_helper_1 = __importDefault(require("immutability-helper"));
|
|
8
8
|
const get_1 = __importDefault(require("lodash/get"));
|
|
9
|
+
const truthy_1 = require("../truthy");
|
|
9
10
|
const units_1 = require("./units");
|
|
10
11
|
const utils_1 = require("./utils");
|
|
11
12
|
const visitView = (view, visitor) => (0, immutability_helper_1.default)(view, {
|
|
@@ -31,9 +32,9 @@ const visitView = (view, visitor) => (0, immutability_helper_1.default)(view, {
|
|
|
31
32
|
units: {
|
|
32
33
|
$apply: (units) => units
|
|
33
34
|
? units
|
|
34
|
-
.filter(
|
|
35
|
+
.filter(truthy_1.truthy)
|
|
35
36
|
.map((unit) => (0, utils_1.visitViewUnit)(fromType, unit, visitor))
|
|
36
|
-
.filter(
|
|
37
|
+
.filter(utils_1.isUnitExpressionValid)
|
|
37
38
|
.map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit)
|
|
38
39
|
.filter((unit) => unit !== utils_1.REMOVE)
|
|
39
40
|
: undefined,
|
|
@@ -81,7 +82,7 @@ const deleteExpressionWithNotFoundFieldsOrTypesInMapView = (schema, view) => vis
|
|
|
81
82
|
visitExpression: (fromType, expression) => (0, utils_1.deleteExpressionWithNotFoundFieldsOrTypesInExpression)(schema, fromType, expression),
|
|
82
83
|
});
|
|
83
84
|
exports.deleteExpressionWithNotFoundFieldsOrTypesInMapView = deleteExpressionWithNotFoundFieldsOrTypesInMapView;
|
|
84
|
-
const fixUserSelectedUnitsInMapView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => {
|
|
85
|
+
const fixUserSelectedUnitsInMapView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField, }) => {
|
|
85
86
|
return visitView(view, {
|
|
86
87
|
visitQueryExpression: (query) => query,
|
|
87
88
|
visitFilter: (_fromType, filter) => filter,
|
|
@@ -1,23 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
}
|
|
4
|
-
|
|
1
|
+
import type { Expression } from "@fibery/expression-utils/src/types";
|
|
2
|
+
import type { FieldObject, Schema } from "@fibery/schema";
|
|
3
|
+
import type { UnitDefinitions, ViewRecord } from "./utils";
|
|
4
|
+
import { Unit } from "@fibery/views/src/units/types";
|
|
5
|
+
type GroupByEntry = {
|
|
6
|
+
expression: Expression;
|
|
7
|
+
[k: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
type GroupByExpression = Record<string, GroupByEntry>;
|
|
10
|
+
export declare const deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression: (schema: Schema, groupByExpression: GroupByExpression | null, fromType: string, removedItems: number[]) => any;
|
|
11
|
+
export declare const replaceIdsWithNamesInGroupByExpression: (schema: Schema, groupByExpression: GroupByExpression | null, fromType: string) => {
|
|
5
12
|
[k: string]: {
|
|
6
13
|
expression: any;
|
|
7
14
|
};
|
|
8
15
|
} | null;
|
|
9
|
-
export
|
|
16
|
+
export declare const replaceNamesWithIdsInGroupByExpression: (schema: Schema, groupByExpression: GroupByExpression | null, fromType: string) => {
|
|
10
17
|
[k: string]: {
|
|
11
18
|
expression: any;
|
|
12
19
|
};
|
|
13
20
|
} | null;
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
unitDefinitions:
|
|
20
|
-
getDefaultUnitTypeForField:
|
|
21
|
-
})
|
|
22
|
-
export
|
|
23
|
-
export
|
|
21
|
+
export declare const replaceNamesWithIdsInSmartFolder: (schema: Schema, smartFolder: ViewRecord) => any;
|
|
22
|
+
export declare const replaceIdsWithNamesInSmartFolder: (schema: Schema, smartFolder: ViewRecord) => any;
|
|
23
|
+
export declare const deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder: (schema: Schema, smartFolder: ViewRecord) => any;
|
|
24
|
+
export declare const fixContextExpressionWithBrokenPath: (schema: Schema, view: ViewRecord, defaultContextExpression: Expression) => any;
|
|
25
|
+
export declare const fixUserSelectedUnitsInSmartFolder: (schema: Schema, view: ViewRecord, { unitDefinitions, getDefaultUnitTypeForField, }: {
|
|
26
|
+
unitDefinitions: UnitDefinitions;
|
|
27
|
+
getDefaultUnitTypeForField: (fieldObject: FieldObject, allowedUnits: Unit[]) => string | undefined;
|
|
28
|
+
}) => any;
|
|
29
|
+
export declare const collectGarbage: (view: ViewRecord) => any;
|
|
30
|
+
export declare const enableHideWhenEmptyForCheckedUnits: (view: ViewRecord) => any;
|
|
31
|
+
export {};
|
|
@@ -7,6 +7,7 @@ exports.enableHideWhenEmptyForCheckedUnits = exports.collectGarbage = exports.fi
|
|
|
7
7
|
const visitors_1 = require("@fibery/expression-utils/src/visitors");
|
|
8
8
|
const immutability_helper_1 = __importDefault(require("immutability-helper"));
|
|
9
9
|
const get_1 = __importDefault(require("lodash/get"));
|
|
10
|
+
const truthy_1 = require("../truthy");
|
|
10
11
|
const isEqual_1 = __importDefault(require("lodash/isEqual"));
|
|
11
12
|
const units_1 = require("./units");
|
|
12
13
|
const utils_1 = require("./utils");
|
|
@@ -16,7 +17,7 @@ const visitSmartFolder = (smartFolder, visitor) => (0, immutability_helper_1.def
|
|
|
16
17
|
$apply: (items = []) => {
|
|
17
18
|
const isOldSmartFolder = !items.every((item) => Object.hasOwn(item, "groupBy"));
|
|
18
19
|
const removedItemsIndexes = items
|
|
19
|
-
.map((item, index) =>
|
|
20
|
+
.map((item, index) => visitor.visitQueryExpression(item.query) ? null : index)
|
|
20
21
|
.filter((value) => value !== null);
|
|
21
22
|
return items
|
|
22
23
|
.map((item) => {
|
|
@@ -76,9 +77,9 @@ const visitSmartFolder = (smartFolder, visitor) => (0, immutability_helper_1.def
|
|
|
76
77
|
$apply: (units) => {
|
|
77
78
|
return units
|
|
78
79
|
? units
|
|
79
|
-
.filter(
|
|
80
|
+
.filter(truthy_1.truthy)
|
|
80
81
|
.map((unit) => (0, utils_1.visitViewUnit)(fromType, unit, visitor))
|
|
81
|
-
.filter(
|
|
82
|
+
.filter(utils_1.isUnitExpressionValid)
|
|
82
83
|
.map((unit, index, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit)
|
|
83
84
|
.filter((unit) => unit !== utils_1.REMOVE)
|
|
84
85
|
: undefined;
|
|
@@ -153,7 +154,7 @@ const deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression = (schema, gr
|
|
|
153
154
|
}
|
|
154
155
|
return null;
|
|
155
156
|
})
|
|
156
|
-
.filter(
|
|
157
|
+
.filter(truthy_1.truthy);
|
|
157
158
|
return entries.length > 0 ? Object.fromEntries(entries) : null;
|
|
158
159
|
};
|
|
159
160
|
exports.deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression = deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression;
|
|
@@ -228,23 +229,25 @@ const fixContextExpressionWithBrokenPath = (schema, view, defaultContextExpressi
|
|
|
228
229
|
visitContextExpression: (fromType, expression) => (0, utils_1.resetContextExpressionIfBroken)(schema, fromType, expression, defaultContextExpression),
|
|
229
230
|
});
|
|
230
231
|
exports.fixContextExpressionWithBrokenPath = fixContextExpressionWithBrokenPath;
|
|
231
|
-
const fixUserSelectedUnitsInSmartFolder = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => {
|
|
232
|
+
const fixUserSelectedUnitsInSmartFolder = (schema, view, { unitDefinitions, getDefaultUnitTypeForField, }) => {
|
|
232
233
|
return visitSmartFolder(view, {
|
|
233
234
|
visitQueryExpression: (query) => query,
|
|
234
235
|
visitGroupByExpression: (groupBy) => groupBy,
|
|
235
236
|
visitFilter: (_fromType, filter) => filter,
|
|
236
237
|
visitExpression: (_fromType, expression) => expression,
|
|
237
238
|
visitViewUnit: (fromType, unit, units) => {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
if (unit.
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
snippetUnitForField.checked
|
|
239
|
+
if (unit.kind !== "user-button") {
|
|
240
|
+
// Migration: "rich-text" is a legacy unit type not in the current type system
|
|
241
|
+
if (unit.type === "rich-text" && view?.["fibery/type"] === "grid") {
|
|
242
|
+
if (unit.checked) {
|
|
243
|
+
const snippetsUnits = units.filter((x) => x.kind === "field" && x.type === "rich-text-snippet");
|
|
244
|
+
const snippetUnitForField = snippetsUnits.find((x) => (0, isEqual_1.default)(x.expression, unit.expression));
|
|
245
|
+
if (snippetUnitForField && !snippetUnitForField.checked) {
|
|
246
|
+
snippetUnitForField.checked = true;
|
|
247
|
+
}
|
|
245
248
|
}
|
|
249
|
+
return utils_1.REMOVE;
|
|
246
250
|
}
|
|
247
|
-
return utils_1.REMOVE;
|
|
248
251
|
}
|
|
249
252
|
return (0, units_1.fixViewUnit)(schema, fromType, unit, units, { unitDefinitions, getDefaultUnitTypeForField });
|
|
250
253
|
},
|
|
@@ -1,10 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import type { Expression, Query } from "@fibery/expression-utils/src/types";
|
|
2
|
+
import type { FieldObject, Schema } from "@fibery/schema";
|
|
3
|
+
import type { UnitDefinitions, ViewFilter, ViewRecord } from "./utils";
|
|
4
|
+
import { Unit } from "@fibery/views/src/units/types";
|
|
5
|
+
type GroupByEntry = {
|
|
6
|
+
expression: Expression;
|
|
7
|
+
[k: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
type GroupByExpression = Record<string, GroupByEntry>;
|
|
10
|
+
type TimelineMetaItem = {
|
|
11
|
+
query?: Query | null;
|
|
12
|
+
filter?: ViewFilter | null;
|
|
13
|
+
yExpression?: Expression | null;
|
|
14
|
+
startExpression?: Expression | null;
|
|
15
|
+
endExpression?: Expression | null;
|
|
16
|
+
secondaryStartExpression?: Expression | null;
|
|
17
|
+
secondaryEndExpression?: Expression | null;
|
|
18
|
+
contextExpression?: Expression | null;
|
|
19
|
+
units?: Unit[] | null;
|
|
20
|
+
colorCoding?: {
|
|
21
|
+
expression: Expression;
|
|
22
|
+
[k: string]: unknown;
|
|
23
|
+
}[] | null;
|
|
24
|
+
dependencyExpression?: Expression | null;
|
|
25
|
+
groupBy?: GroupByExpression | null;
|
|
26
|
+
groupingExpression?: GroupByExpression | null;
|
|
27
|
+
[k: string]: unknown;
|
|
28
|
+
};
|
|
29
|
+
export declare const replaceNamesWithIdsInTimelineView: (schema: Schema, view: ViewRecord) => any;
|
|
30
|
+
export declare const replaceIdsWithNamesInTimelineView: (schema: Schema, view: ViewRecord) => any;
|
|
31
|
+
export declare const deleteExpressionWithNotFoundFieldsOrTypesInTimelineView: (schema: Schema, view: ViewRecord, ensureAxisInvariant: boolean, canGroupMetaItem?: (_metaItem: TimelineMetaItem) => boolean) => any;
|
|
32
|
+
export declare const fixUserSelectedUnitsInTimelineView: (schema: Schema, view: ViewRecord, { unitDefinitions, getDefaultUnitTypeForField, }: {
|
|
33
|
+
unitDefinitions: UnitDefinitions;
|
|
34
|
+
getDefaultUnitTypeForField: (fieldObject: FieldObject, allowedUnits: Unit[]) => string | undefined;
|
|
35
|
+
}) => any;
|
|
36
|
+
export declare const fixContextExpressionWithBrokenPath: (schema: Schema, view: ViewRecord, defaultContextExpression: Expression) => any;
|
|
37
|
+
export declare const collectGarbage: (view: ViewRecord) => any;
|
|
38
|
+
export declare const enableHideWhenEmptyForCheckedEditableUnits: (view: ViewRecord) => any;
|
|
39
|
+
export {};
|
|
@@ -13,6 +13,7 @@ const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
|
13
13
|
const set_1 = __importDefault(require("lodash/set"));
|
|
14
14
|
const some_1 = __importDefault(require("lodash/some"));
|
|
15
15
|
const smart_folder_1 = require("./smart-folder");
|
|
16
|
+
const truthy_1 = require("../truthy");
|
|
16
17
|
const units_1 = require("./units");
|
|
17
18
|
const utils_1 = require("./utils");
|
|
18
19
|
const visitAxisSingle = (axis, visitor) => {
|
|
@@ -26,10 +27,11 @@ const visitAxisSingle = (axis, visitor) => {
|
|
|
26
27
|
units: axis.units &&
|
|
27
28
|
axis.units
|
|
28
29
|
.map((unit) => (0, utils_1.visitViewUnit)(fromType, unit, visitor))
|
|
29
|
-
.filter(
|
|
30
|
+
.filter(utils_1.isUnitExpressionValid)
|
|
30
31
|
.map((unit, idx, units) => (visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit))
|
|
31
32
|
.filter((unit) => unit !== utils_1.REMOVE),
|
|
32
|
-
groupByExpression: axis.groupByExpression &&
|
|
33
|
+
groupByExpression: axis.groupByExpression &&
|
|
34
|
+
firstOrNull(visitor.visitExpression(fromType, [axis.groupByExpression])),
|
|
33
35
|
};
|
|
34
36
|
if (!axisResult.query) {
|
|
35
37
|
return null;
|
|
@@ -101,9 +103,9 @@ const visitView = (view, visitor) => (0, immutability_helper_1.default)(view, {
|
|
|
101
103
|
units: {
|
|
102
104
|
$apply: (units) => units
|
|
103
105
|
? units
|
|
104
|
-
.filter(
|
|
106
|
+
.filter(truthy_1.truthy)
|
|
105
107
|
.map((unit) => (0, utils_1.visitViewUnit)(fromType, unit, visitor))
|
|
106
|
-
.filter(
|
|
108
|
+
.filter(utils_1.isUnitExpressionValid)
|
|
107
109
|
.map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit)
|
|
108
110
|
.filter((unit) => unit !== utils_1.REMOVE)
|
|
109
111
|
: undefined,
|
|
@@ -255,7 +257,7 @@ const ensureAxisAndItemExpressionInvariant = (view, canGroupMetaItem) => {
|
|
|
255
257
|
actions.forEach((action) => action());
|
|
256
258
|
return view;
|
|
257
259
|
};
|
|
258
|
-
const deleteExpressionWithNotFoundFieldsOrTypesInTimelineView = (schema, view, ensureAxisInvariant, canGroupMetaItem = (
|
|
260
|
+
const deleteExpressionWithNotFoundFieldsOrTypesInTimelineView = (schema, view, ensureAxisInvariant, canGroupMetaItem = (_metaItem) => true) => {
|
|
259
261
|
const visitor = {
|
|
260
262
|
visitQueryExpression: (queryExpression) => (0, utils_1.deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression)(schema, queryExpression),
|
|
261
263
|
visitFilter: (fromType, expression) => (0, utils_1.deleteExpressionWithNotFoundFieldsOrTypesInFilter)(schema, fromType, expression),
|
|
@@ -279,7 +281,7 @@ const deleteExpressionWithNotFoundFieldsOrTypesInTimelineView = (schema, view, e
|
|
|
279
281
|
return ensureAxisInvariant ? ensureAxisAndItemExpressionInvariant(viewNew, canGroupMetaItem) : viewNew;
|
|
280
282
|
};
|
|
281
283
|
exports.deleteExpressionWithNotFoundFieldsOrTypesInTimelineView = deleteExpressionWithNotFoundFieldsOrTypesInTimelineView;
|
|
282
|
-
const fixUserSelectedUnitsInTimelineView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => {
|
|
284
|
+
const fixUserSelectedUnitsInTimelineView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField, }) => {
|
|
283
285
|
return visitView(view, {
|
|
284
286
|
visitQueryExpression: (query) => query,
|
|
285
287
|
visitExpression: (_fromType, expression) => expression,
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
1
|
+
import type { FieldObject, Schema } from "@fibery/schema";
|
|
2
|
+
import type { UnitDefinitions } from "./utils";
|
|
3
|
+
import { REMOVE } from "./utils";
|
|
4
|
+
import { Unit } from "@fibery/views/src/units/types";
|
|
5
|
+
export declare const fixViewUnit: (schema: Schema, fromType: string, unit: Unit, units: Unit[], { unitDefinitions, getDefaultUnitTypeForField, migrateFileCollectionUnit, }: {
|
|
6
|
+
unitDefinitions: UnitDefinitions;
|
|
7
|
+
getDefaultUnitTypeForField: (fieldObject: FieldObject, allowedUnits: Unit[]) => string | undefined;
|
|
8
|
+
migrateFileCollectionUnit?: boolean;
|
|
9
|
+
}) => Unit | typeof REMOVE;
|
|
10
|
+
export declare const enableHideWhenEmptyForCheckedEditableUnit: (unit: Unit) => Unit;
|