@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,245 @@
|
|
|
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.makeUnitDefinitionsFactory = void 0;
|
|
7
|
+
const compact_1 = __importDefault(require("lodash/compact"));
|
|
8
|
+
const constant_1 = __importDefault(require("lodash/constant"));
|
|
9
|
+
const flatMap_1 = __importDefault(require("lodash/flatMap"));
|
|
10
|
+
const groupBy_1 = __importDefault(require("lodash/groupBy"));
|
|
11
|
+
const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
|
|
12
|
+
const mapValues_1 = __importDefault(require("lodash/mapValues"));
|
|
13
|
+
const sortBy_1 = __importDefault(require("lodash/sortBy"));
|
|
14
|
+
const trace_1 = require("@fibery/helpers/utils/trace");
|
|
15
|
+
const number_1 = require("../field-utils/number");
|
|
16
|
+
const text_1 = require("../field-utils/text");
|
|
17
|
+
const avatar_1 = require("../field-utils/avatar");
|
|
18
|
+
const comments_1 = require("../field-utils/comments");
|
|
19
|
+
const back_references_1 = require("../field-utils/back-references");
|
|
20
|
+
const relation_view_1 = require("../field-utils/relation-view");
|
|
21
|
+
const select_1 = require("@fibery/query-utils/src/select");
|
|
22
|
+
const common_1 = require("../unit-utils/common");
|
|
23
|
+
const not_found_1 = require("../unit-definitions/not-found");
|
|
24
|
+
const array_1 = require("@fibery/helpers/utils/array");
|
|
25
|
+
const user_role_1 = require("../field-utils/user-role");
|
|
26
|
+
const NoUnitsCreator = () => [];
|
|
27
|
+
const makeUnitDefinitionsFactory = (allUnitDefinitions) => {
|
|
28
|
+
const { BackReferencesList, Bool, BoolCheckbox, ColorInput, CommentsList, Text, TextInput, Email, EmailInput, Emoji, IconInput, JsonInput, Number, NumberInput, ProgressBar, ReferenceCombobox, ReferenceCollection, ReferenceCollectionList, ReferenceCollectionView, ReferenceCollectionCombobox, FileReference, FileCompactReference, FilesGallery, FileList, FileListItem, FileLList, FileLListItem, FileCollectionCount, FileCompactCollection, Date, DateTimeCombobox, DateRange, DateRangeCombobox, Avatar, AvatarCollection, AvatarInput, CollectionCount, Reference, ReferenceIcon, TypeIcon, TypeBadge, TypeBadgeAbbr, Title, TitleInput, Id, UserButton, Phone, PhoneInput, Location, LocationInput, SingleLocationPreview, GeometryPreview, RichText, RichTextSnippet, RichTextDocument, CommentsCollection, Url, UrlInput, UserRole, UserRoleInput, IconButton, } = allUnitDefinitions;
|
|
29
|
+
const unitsFactoryByBasicFieldType = {
|
|
30
|
+
"fibery/bool": () => [Bool, BoolCheckbox],
|
|
31
|
+
"fibery/date": () => [Date, DateTimeCombobox],
|
|
32
|
+
"fibery/date-range": () => [DateRange, DateRangeCombobox],
|
|
33
|
+
"fibery/date-time": () => [Date, DateTimeCombobox],
|
|
34
|
+
"fibery/date-time-range": () => [DateRange, DateRangeCombobox],
|
|
35
|
+
"fibery/text": (fieldObject) => {
|
|
36
|
+
const lookup = {
|
|
37
|
+
[text_1.TextUIMeta.Phone]: [Phone, PhoneInput, IconButton],
|
|
38
|
+
[text_1.TextUIMeta.Email]: [Email, EmailInput, IconButton],
|
|
39
|
+
[text_1.TextUIMeta.URL]: [Url, UrlInput, IconButton],
|
|
40
|
+
};
|
|
41
|
+
const key = fieldObject.rawMeta[text_1.TextUIMetaKey];
|
|
42
|
+
return lookup[key] || [Text, TextInput];
|
|
43
|
+
},
|
|
44
|
+
"fibery/url": () => [Url, UrlInput, IconButton],
|
|
45
|
+
"fibery/email": () => [Email, EmailInput, IconButton],
|
|
46
|
+
"fibery/emoji": () => [Emoji, IconInput],
|
|
47
|
+
"fibery/int": () => [Number, NumberInput],
|
|
48
|
+
"fibery/location": () => [SingleLocationPreview, Location, LocationInput],
|
|
49
|
+
"fibery/rich-text": NoUnitsCreator,
|
|
50
|
+
"fibery/rank": NoUnitsCreator,
|
|
51
|
+
"fibery/json-value": () => [GeometryPreview, JsonInput],
|
|
52
|
+
"fibery/uuid": NoUnitsCreator,
|
|
53
|
+
"fibery/decimal": (fieldObject) => [
|
|
54
|
+
Number,
|
|
55
|
+
NumberInput,
|
|
56
|
+
(0, number_1.parseNumberFieldMeta)(fieldObject).numberFormat === number_1.NumberFormat.PERCENT && ProgressBar,
|
|
57
|
+
],
|
|
58
|
+
"fibery/color": () => [ColorInput],
|
|
59
|
+
};
|
|
60
|
+
const fallbackFieldCreator = (fieldObject) => {
|
|
61
|
+
(0, trace_1.traceError)(`basicFieldCreators["${fieldObject.type}"] is not defined`);
|
|
62
|
+
return [];
|
|
63
|
+
};
|
|
64
|
+
const unitsFactoryByFieldKind = {
|
|
65
|
+
":field/basic": (fieldObject) => {
|
|
66
|
+
const creator = unitsFactoryByBasicFieldType[fieldObject.type] || fallbackFieldCreator;
|
|
67
|
+
return creator(fieldObject);
|
|
68
|
+
},
|
|
69
|
+
":field/reference": (fieldObject) => {
|
|
70
|
+
if (FileReference && FileCompactReference && fieldObject.typeObject.name === "fibery/file") {
|
|
71
|
+
return [FileLListItem, FileCompactReference, FileListItem, FileReference].filter(Boolean);
|
|
72
|
+
}
|
|
73
|
+
return [
|
|
74
|
+
(0, avatar_1.isAvatarExtensionEnabledType)(fieldObject.typeObject) && Avatar,
|
|
75
|
+
fieldObject.name === "workflow/state" && ReferenceIcon,
|
|
76
|
+
Reference,
|
|
77
|
+
ReferenceCombobox,
|
|
78
|
+
];
|
|
79
|
+
},
|
|
80
|
+
":field/reference-collection": (fieldObject, options) => {
|
|
81
|
+
const common = [CollectionCount, (0, avatar_1.isAvatarExtensionEnabledType)(fieldObject.typeObject) && AvatarCollection];
|
|
82
|
+
if ((0, relation_view_1.isRelationViewField)(fieldObject) && !options.isSharingMode) {
|
|
83
|
+
return [...common, ReferenceCollection, ReferenceCollectionCombobox, ReferenceCollectionView];
|
|
84
|
+
}
|
|
85
|
+
if ((0, back_references_1.isReferenceExtensionField)(fieldObject)) {
|
|
86
|
+
return [...common, BackReferencesList];
|
|
87
|
+
}
|
|
88
|
+
if ((0, comments_1.isCommentExtensionField)(fieldObject)) {
|
|
89
|
+
return [...common, CommentsList];
|
|
90
|
+
}
|
|
91
|
+
if (fieldObject.typeObject.name === "fibery/view") {
|
|
92
|
+
return [...common, ReferenceCollection, ReferenceCollectionCombobox, ReferenceCollectionList];
|
|
93
|
+
}
|
|
94
|
+
if (fieldObject.typeObject.name === "fibery/file") {
|
|
95
|
+
return [
|
|
96
|
+
FileLList,
|
|
97
|
+
FileCompactCollection ? FileCompactCollection : ReferenceCollection,
|
|
98
|
+
FileCollectionCount ? FileCollectionCount : CollectionCount,
|
|
99
|
+
FilesGallery,
|
|
100
|
+
FileList,
|
|
101
|
+
].filter(Boolean);
|
|
102
|
+
}
|
|
103
|
+
if (fieldObject.typeObject.isEnum) {
|
|
104
|
+
return [...common, ReferenceCollection, ReferenceCollectionCombobox];
|
|
105
|
+
}
|
|
106
|
+
if (fieldObject.cardinality === ":cardinality/many-to-many" && fieldObject.type === "fibery/user") {
|
|
107
|
+
return [...common, ReferenceCollection, ReferenceCollectionCombobox];
|
|
108
|
+
}
|
|
109
|
+
return [...common, ReferenceCollection, ReferenceCollectionCombobox, ReferenceCollectionList];
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
const getUnitsForField = (fieldObject, options = {}) => {
|
|
113
|
+
const makeUnit = (Unit) => Unit.makeUnit({ expression: [fieldObject.name] });
|
|
114
|
+
const { showHiddenFields } = options;
|
|
115
|
+
if (fieldObject.isPublicId) {
|
|
116
|
+
return [Id].filter(Boolean).map(makeUnit);
|
|
117
|
+
}
|
|
118
|
+
if (fieldObject.isTitle) {
|
|
119
|
+
return [Title, TitleInput].filter(Boolean).map(makeUnit);
|
|
120
|
+
}
|
|
121
|
+
if ((0, avatar_1.isAvatarExtensionField)(fieldObject)) {
|
|
122
|
+
return [Avatar, AvatarInput].filter(Boolean).map(makeUnit);
|
|
123
|
+
}
|
|
124
|
+
if (fieldObject.type === "Collaboration~Documents/Document") {
|
|
125
|
+
return [RichText, RichTextSnippet, RichTextDocument].filter(Boolean).map(makeUnit);
|
|
126
|
+
}
|
|
127
|
+
if (fieldObject.type === "comments/comment" && CommentsCollection) {
|
|
128
|
+
return [CommentsCollection].filter(Boolean).map(makeUnit);
|
|
129
|
+
}
|
|
130
|
+
if ((0, user_role_1.isUserRoleField)(fieldObject)) {
|
|
131
|
+
return [UserRole, UserRoleInput].filter(Boolean).map(makeUnit);
|
|
132
|
+
}
|
|
133
|
+
if (fieldObject.isHidden && !showHiddenFields) {
|
|
134
|
+
return [];
|
|
135
|
+
}
|
|
136
|
+
const unitsFactory = unitsFactoryByFieldKind[fieldObject.kind] || (0, constant_1.default)([]);
|
|
137
|
+
return (0, compact_1.default)(unitsFactory(fieldObject, options)).map(makeUnit);
|
|
138
|
+
};
|
|
139
|
+
const staticUnitsTypeOrder = [Id, AvatarCollection, TypeIcon, TypeBadge, TypeBadgeAbbr, Avatar, Title, UserButton]
|
|
140
|
+
.filter(Boolean)
|
|
141
|
+
.map(({ type }) => type);
|
|
142
|
+
function getTypeUnits() {
|
|
143
|
+
return [TypeIcon, TypeBadge, TypeBadgeAbbr].filter(Boolean).map((Unit) => Unit.makeUnit());
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* @returns flat list of all units for given type
|
|
147
|
+
*/
|
|
148
|
+
function getUnitsForType(typeObject, options = {}) {
|
|
149
|
+
const collection = (0, flatMap_1.default)(typeObject.fieldObjects.filter((x) => !x.isHidden), (fieldObject) => getUnitsForField(fieldObject, options).map((unit) => ({ unit, fieldObject }))).concat(getTypeUnits().map((unit) => ({ unit, fieldObject: typeObject.titleFieldObject })));
|
|
150
|
+
return (0, sortBy_1.default)(collection, ({ unit }) => {
|
|
151
|
+
const index = staticUnitsTypeOrder.indexOf(unit.type);
|
|
152
|
+
return index === -1 ? staticUnitsTypeOrder.length : index;
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* @returns list of units grouped by field
|
|
157
|
+
*/
|
|
158
|
+
function getUnitsForTypePerField(typeObject, options = {}) {
|
|
159
|
+
const collection = [];
|
|
160
|
+
for (const fieldObject of typeObject.fieldObjects) {
|
|
161
|
+
if (!fieldObject.isHidden) {
|
|
162
|
+
const units = getUnitsForField(fieldObject, options);
|
|
163
|
+
if (units.length > 0) {
|
|
164
|
+
collection.push({
|
|
165
|
+
fieldObject,
|
|
166
|
+
units,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return (0, sortBy_1.default)(collection, ({ units }) => {
|
|
172
|
+
return units
|
|
173
|
+
.map((unit) => {
|
|
174
|
+
const index = staticUnitsTypeOrder.indexOf(unit.type);
|
|
175
|
+
return index === -1 ? staticUnitsTypeOrder.length : index;
|
|
176
|
+
})
|
|
177
|
+
.sort((a, b) => a - b)[0];
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
const getHardcodedUnitsForView = (typeObject) => {
|
|
181
|
+
return [
|
|
182
|
+
TypeIcon && TypeIcon.makeUnit(),
|
|
183
|
+
Title && Title.makeUnit(),
|
|
184
|
+
...getUnitsForField(typeObject.fieldObjectsByName["fibery/creation-date"]),
|
|
185
|
+
...getUnitsForField(typeObject.fieldObjectsByName["fibery/container-app"]),
|
|
186
|
+
...getUnitsForField(typeObject.fieldObjectsByName["fibery/container-entity-id"]),
|
|
187
|
+
...getUnitsForField(typeObject.fieldObjectsByName["fibery/container-entity-type"]),
|
|
188
|
+
].filter(Boolean);
|
|
189
|
+
};
|
|
190
|
+
const unitDefinitionsByTypeLookup = (0, mapValues_1.default)((0, groupBy_1.default)(allUnitDefinitions, (x) => x.type), (value) => (0, array_1.single)(value));
|
|
191
|
+
const getUnitLabel = (fieldObject, unit) => {
|
|
192
|
+
const unitDefinition = unitDefinitionsByTypeLookup[unit.type];
|
|
193
|
+
if (!unitDefinition) {
|
|
194
|
+
return "";
|
|
195
|
+
}
|
|
196
|
+
return unitDefinition.getLabel({ typeObject: fieldObject.holderTypeObject, unit: unit });
|
|
197
|
+
};
|
|
198
|
+
const getUnitName = (unit) => {
|
|
199
|
+
const unitDefinition = unitDefinitionsByTypeLookup[unit.type];
|
|
200
|
+
if (!unitDefinition) {
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
return unitDefinition.name;
|
|
204
|
+
};
|
|
205
|
+
const getUnitDataDefinition = (unit) => {
|
|
206
|
+
if (unitDefinitionsByTypeLookup[unit.type]) {
|
|
207
|
+
return unitDefinitionsByTypeLookup[unit.type];
|
|
208
|
+
}
|
|
209
|
+
// eslint-disable-next-line no-console
|
|
210
|
+
console.warn(`Unit Definition of type "${unit.type}" does not exist.`);
|
|
211
|
+
return not_found_1.NotFound;
|
|
212
|
+
};
|
|
213
|
+
const getCardUnitsSelect = ({ schema, typeObject, units }) => {
|
|
214
|
+
const selects = units
|
|
215
|
+
.filter((unit) => {
|
|
216
|
+
return ((0, common_1.isUnitEnabled)(unit) &&
|
|
217
|
+
unit.kind !== "user-button" &&
|
|
218
|
+
unit.expression?.[0] !== "documents/documents" &&
|
|
219
|
+
unit.expression?.[0] !== "whiteboards/whiteboards");
|
|
220
|
+
})
|
|
221
|
+
.map((unit) => {
|
|
222
|
+
const unitExpressionErrors = (0, common_1.calculateUnitExpressionErrors)({ typeObject, unit });
|
|
223
|
+
if (unitExpressionErrors.length > 0) {
|
|
224
|
+
return {};
|
|
225
|
+
}
|
|
226
|
+
const UnitDefinition = getUnitDataDefinition(unit);
|
|
227
|
+
const select = UnitDefinition.getQuerySelect({ schema, typeObject, unit: unit });
|
|
228
|
+
(0, trace_1.assert)((0, isPlainObject_1.default)(select), "getQuerySelect must return object-shaped select");
|
|
229
|
+
return select;
|
|
230
|
+
});
|
|
231
|
+
return (0, select_1.mergeDenormalizedSelects)(selects);
|
|
232
|
+
};
|
|
233
|
+
return {
|
|
234
|
+
getTypeUnits,
|
|
235
|
+
getUnitsForType,
|
|
236
|
+
getUnitsForTypePerField,
|
|
237
|
+
getUnitsForField,
|
|
238
|
+
getHardcodedUnitsForView,
|
|
239
|
+
getUnitLabel,
|
|
240
|
+
getUnitName,
|
|
241
|
+
getCardUnitsSelect,
|
|
242
|
+
getUnitDataDefinition,
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
exports.makeUnitDefinitionsFactory = makeUnitDefinitionsFactory;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Schema, TypeObject } from "@fibery/schema";
|
|
2
|
+
import { NumberDisplaySettings } from "../field-utils/number";
|
|
3
|
+
import { $TSFixMe } from "../tsfixme";
|
|
4
|
+
import { FiberyObject } from "@fibery/expression-utils/src/types";
|
|
5
|
+
export type ButtonUnit = {
|
|
6
|
+
kind: "user-button";
|
|
7
|
+
type: "user-button" | "icon-button";
|
|
8
|
+
data: {
|
|
9
|
+
id: string;
|
|
10
|
+
typeId: string;
|
|
11
|
+
};
|
|
12
|
+
label: string;
|
|
13
|
+
checked?: boolean;
|
|
14
|
+
hideWhenEmpty?: boolean;
|
|
15
|
+
icon?: string;
|
|
16
|
+
};
|
|
17
|
+
export type UnitExpression = string[];
|
|
18
|
+
export type DbUnit = {
|
|
19
|
+
kind: "db";
|
|
20
|
+
type: "type-icon" | "type-badge" | "type-badge-abbr";
|
|
21
|
+
expression?: UnitExpression;
|
|
22
|
+
checked?: boolean;
|
|
23
|
+
hideWhenEmpty?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export type FieldUnit = {
|
|
26
|
+
kind: "field";
|
|
27
|
+
type: "avatar" | "avatar-collection" | "avatar-input" | "back-references-list" | "bool" | "bool-checkbox" | "collection-count" | "color-input" | "comments-list" | "date" | "date-time" | "date-time-combobox" | "date-range" | "date-range-combobox" | "email" | "email-input" | "emoji" | "field" | "files-gallery" | "files-list" | "files-list-item" | "files-l-list" | "files-l-list-item" | "file-reference" | "file-compact-collection" | "file-compact-reference" | "file-collection-count" | "geometry-preview" | "icon-button" | "icon-input" | "id" | "json-input" | "location" | "location-input" | "number" | "number-input" | "phone" | "phone-input" | "progress-bar" | "reference" | "reference-icon" | "reference-combobox" | "reference-collection" | "reference-collection-list" | "reference-collection-view" | "reference-collection-combobox" | "rich-text-snippet" | "rich-text-document" | "single-location-preview" | "text" | "text-input" | "title" | "title-input" | "url" | "url-input" | "user-role" | "user-role-input";
|
|
28
|
+
expression: UnitExpression;
|
|
29
|
+
checked?: boolean;
|
|
30
|
+
settings?: Record<string, unknown>;
|
|
31
|
+
hideWhenEmpty?: boolean;
|
|
32
|
+
};
|
|
33
|
+
export type Unit = FieldUnit | ButtonUnit | DbUnit;
|
|
34
|
+
type ToPure<T extends Unit> = Omit<T, "checked">;
|
|
35
|
+
export type PureUnit = ToPure<FieldUnit> | ToPure<ButtonUnit> | ToPure<DbUnit>;
|
|
36
|
+
export type UnitDataDefinition<T extends Unit> = {
|
|
37
|
+
type: string;
|
|
38
|
+
name: string;
|
|
39
|
+
canEdit: (params: {
|
|
40
|
+
typeObject: TypeObject;
|
|
41
|
+
unit: T;
|
|
42
|
+
}) => boolean;
|
|
43
|
+
makeUnit: (params?: {
|
|
44
|
+
expression: UnitExpression;
|
|
45
|
+
}) => PureUnit;
|
|
46
|
+
getLabel: (params: {
|
|
47
|
+
typeObject: TypeObject;
|
|
48
|
+
unit: T;
|
|
49
|
+
}) => string;
|
|
50
|
+
getQuerySelect: (params: {
|
|
51
|
+
typeObject: TypeObject;
|
|
52
|
+
unit: T;
|
|
53
|
+
schema: Schema;
|
|
54
|
+
}) => $TSFixMe;
|
|
55
|
+
calculateErrors: (params: {
|
|
56
|
+
typeObject: TypeObject;
|
|
57
|
+
unit: T;
|
|
58
|
+
}) => $TSFixMe[];
|
|
59
|
+
getExportValue: (params: {
|
|
60
|
+
typeObject: TypeObject;
|
|
61
|
+
unit: T;
|
|
62
|
+
object: FiberyObject;
|
|
63
|
+
displaySettings: NumberDisplaySettings;
|
|
64
|
+
}) => unknown;
|
|
65
|
+
canExport: (params: {
|
|
66
|
+
unit: T;
|
|
67
|
+
}) => boolean;
|
|
68
|
+
getExportLabel?: (params: {
|
|
69
|
+
typeObject: TypeObject;
|
|
70
|
+
unit: T;
|
|
71
|
+
}) => string;
|
|
72
|
+
};
|
|
73
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,77 +1,67 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/views",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "18.0.2",
|
|
4
4
|
"description": "Operations on view objects",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Fibery",
|
|
7
|
-
"main": "./lib/
|
|
8
|
-
"
|
|
7
|
+
"main": "./lib/index.js",
|
|
8
|
+
"types": "./lib/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
10
|
"/lib"
|
|
11
11
|
],
|
|
12
12
|
"private": false,
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./lib/index.d.ts",
|
|
16
|
+
"default": "./lib/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./src/*": {
|
|
19
|
+
"types": "./lib/src/*.d.ts",
|
|
20
|
+
"default": "./lib/src/*.js"
|
|
21
|
+
},
|
|
22
|
+
"./src/unit-definitions": {
|
|
23
|
+
"types": "./lib/src/unit-definitions/index.d.ts",
|
|
24
|
+
"default": "./lib/src/unit-definitions/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./src/units/canvas": {
|
|
27
|
+
"types": "./lib/src/units/canvas/index.d.ts",
|
|
28
|
+
"default": "./lib/src/units/canvas/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"fiberyDevExports": {
|
|
32
|
+
".": "./index.ts",
|
|
33
|
+
"./src/*": "./src/*"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"date-fns": "2.29.2",
|
|
37
|
+
"lodash": "4.17.21",
|
|
38
|
+
"moment": "2.29.4",
|
|
39
|
+
"@fibery/context-filters": "1.1.3",
|
|
40
|
+
"@fibery/expression-utils": "9.6.2",
|
|
41
|
+
"@fibery/schema": "10.2.13",
|
|
42
|
+
"@fibery/helpers": "1.4.0",
|
|
43
|
+
"@fibery/query-utils": "1.1.2"
|
|
44
|
+
},
|
|
13
45
|
"devDependencies": {
|
|
14
46
|
"@babel/core": "7.28.5",
|
|
15
47
|
"@swc/jest": "0.2.39",
|
|
48
|
+
"@types/lodash": "4.14.172",
|
|
16
49
|
"immutability-helper": "2.4.0",
|
|
17
50
|
"jest": "30.2.0",
|
|
18
51
|
"jest-junit": "16.0.0",
|
|
19
|
-
"
|
|
20
|
-
"microbundle": "0.15.1",
|
|
52
|
+
"typescript": "5.9.3",
|
|
21
53
|
"@fibery/babel-preset": "7.4.1",
|
|
22
|
-
"@fibery/
|
|
23
|
-
"@fibery/eslint-config": "8.6.2",
|
|
24
|
-
"@fibery/schema": "10.2.9"
|
|
54
|
+
"@fibery/eslint-config": "9.0.0"
|
|
25
55
|
},
|
|
26
56
|
"peerDependencies": {
|
|
27
|
-
"@fibery/expression-utils": "^9.
|
|
28
|
-
"@fibery/schema": "^10.2.
|
|
57
|
+
"@fibery/expression-utils": "^9.6.2",
|
|
58
|
+
"@fibery/schema": "^10.2.13",
|
|
29
59
|
"immutability-helper": "^2.4.0",
|
|
30
60
|
"lodash": "4.17.21"
|
|
31
61
|
},
|
|
32
|
-
"jest": {
|
|
33
|
-
"testEnvironment": "node",
|
|
34
|
-
"coveragePathIgnorePatterns": [
|
|
35
|
-
"/node_modules/"
|
|
36
|
-
],
|
|
37
|
-
"collectCoverageFrom": [
|
|
38
|
-
"src/**/*.{js,jsx,ts,tsx}",
|
|
39
|
-
"!src/**/*.d.ts"
|
|
40
|
-
],
|
|
41
|
-
"coverageReporters": [
|
|
42
|
-
"text",
|
|
43
|
-
"cobertura"
|
|
44
|
-
],
|
|
45
|
-
"testPathIgnorePatterns": [
|
|
46
|
-
"<rootDir>[/\\\\](build|docs|node_modules|scripts)[/\\\\]"
|
|
47
|
-
],
|
|
48
|
-
"transform": {
|
|
49
|
-
"^.+\\.(js|jsx|ts|tsx)$": [
|
|
50
|
-
"@swc/jest",
|
|
51
|
-
{
|
|
52
|
-
"jsc": {
|
|
53
|
-
"parser": {
|
|
54
|
-
"syntax": "typescript",
|
|
55
|
-
"tsx": true,
|
|
56
|
-
"decorators": true,
|
|
57
|
-
"dynamicImport": true
|
|
58
|
-
},
|
|
59
|
-
"transform": {
|
|
60
|
-
"react": {
|
|
61
|
-
"runtime": "automatic"
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
]
|
|
67
|
-
},
|
|
68
|
-
"testEnvironmentOptions": {
|
|
69
|
-
"url": "http://localhost"
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
62
|
"scripts": {
|
|
73
|
-
"build": "rm -rf lib &&
|
|
74
|
-
"test": "
|
|
63
|
+
"build": "rm -rf lib && pnpm exec tsc --project tsconfig.build.json",
|
|
64
|
+
"test": "jest",
|
|
75
65
|
"test:ci": "pnpm run test --reporters=default --reporters=jest-junit",
|
|
76
66
|
"test:coverage": "pnpm run test --coverage --coverageDirectory=${JEST_COVERAGE_RESULT_DIR:-$(pwd)}/coverage/view --reporters=default --reporters=jest-junit",
|
|
77
67
|
"lint": "eslint ."
|