@fibery/views 19.1.1 → 20.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/_virtual/_rolldown/runtime.js +13 -0
- package/lib/errors.d.ts +4 -0
- package/lib/errors.js +4 -0
- package/lib/field-utils/avatar.d.ts +23 -0
- package/lib/field-utils/avatar.js +35 -0
- package/lib/field-utils/back-references.d.ts +18 -0
- package/lib/field-utils/back-references.js +15 -0
- package/lib/field-utils/comments.d.ts +63 -0
- package/lib/field-utils/comments.js +41 -0
- package/lib/field-utils/date-time.d.ts +17 -0
- package/lib/field-utils/date-time.js +31 -0
- package/lib/field-utils/enum-value.d.ts +16 -0
- package/lib/field-utils/enum-value.js +26 -0
- package/lib/field-utils/file.d.ts +7 -0
- package/lib/field-utils/file.js +14 -0
- package/lib/field-utils/icon.d.ts +13 -0
- package/lib/field-utils/icon.js +17 -0
- package/lib/field-utils/number.d.ts +34 -0
- package/lib/field-utils/number.js +64 -0
- package/lib/field-utils/reference-collection.d.ts +16 -0
- package/lib/field-utils/reference-collection.js +49 -0
- package/lib/field-utils/reference.d.ts +10 -0
- package/lib/field-utils/reference.js +55 -0
- package/lib/field-utils/relation-view.d.ts +5 -0
- package/lib/field-utils/relation-view.js +7 -0
- package/lib/field-utils/rich-text.d.ts +16 -0
- package/lib/field-utils/rich-text.js +33 -0
- package/lib/field-utils/text.d.ts +38 -0
- package/lib/field-utils/text.js +37 -0
- package/lib/field-utils/user-active.d.ts +11 -0
- package/lib/field-utils/user-active.js +24 -0
- package/lib/field-utils/user-role.d.ts +9 -0
- package/lib/field-utils/user-role.js +23 -0
- package/lib/field-utils/workflow.d.ts +18 -0
- package/lib/field-utils/workflow.js +48 -0
- package/lib/index.d.ts +34 -1
- package/lib/index.js +169 -16
- package/lib/meta-validation.d.ts +13 -0
- package/lib/meta-validation.js +53 -0
- package/lib/private/board.d.ts +18 -0
- package/lib/private/board.js +234 -0
- package/lib/private/calendar.d.ts +17 -0
- package/lib/private/calendar.js +82 -0
- package/lib/private/feed.d.ts +17 -0
- package/lib/private/feed.js +81 -0
- package/lib/private/form.d.ts +27 -0
- package/lib/private/form.js +57 -0
- package/lib/private/map.d.ts +17 -0
- package/lib/private/map.js +81 -0
- package/lib/private/smart-folder.d.ts +33 -0
- package/lib/private/smart-folder.js +165 -0
- package/lib/private/timeline.d.ts +41 -0
- package/lib/private/timeline.js +223 -0
- package/lib/private/units.d.ts +12 -0
- package/lib/private/units.js +131 -0
- package/lib/private/utils.d.ts +66 -0
- package/lib/private/utils.js +179 -0
- package/lib/tsfixme.d.ts +4 -0
- package/lib/tsfixme.js +0 -0
- package/lib/unit-definitions/avatar-collection.d.ts +5 -0
- package/lib/unit-definitions/avatar-collection.js +59 -0
- package/lib/unit-definitions/avatar-input.d.ts +5 -0
- package/lib/unit-definitions/avatar-input.js +12 -0
- package/lib/unit-definitions/avatar.d.ts +5 -0
- package/lib/unit-definitions/avatar.js +95 -0
- package/lib/unit-definitions/back-references-list.d.ts +5 -0
- package/lib/unit-definitions/back-references-list.js +39 -0
- package/lib/unit-definitions/bool-checkbox.d.ts +5 -0
- package/lib/unit-definitions/bool-checkbox.js +25 -0
- package/lib/unit-definitions/bool.d.ts +5 -0
- package/lib/unit-definitions/bool.js +25 -0
- package/lib/unit-definitions/collection-count.d.ts +5 -0
- package/lib/unit-definitions/collection-count.js +35 -0
- package/lib/unit-definitions/color-input.d.ts +5 -0
- package/lib/unit-definitions/color-input.js +24 -0
- package/lib/unit-definitions/comments-list.d.ts +5 -0
- package/lib/unit-definitions/comments-list.js +27 -0
- package/lib/unit-definitions/date-range-combobox.d.ts +5 -0
- package/lib/unit-definitions/date-range-combobox.js +25 -0
- package/lib/unit-definitions/date-range.d.ts +5 -0
- package/lib/unit-definitions/date-range.js +25 -0
- package/lib/unit-definitions/date-time-combobox.d.ts +5 -0
- package/lib/unit-definitions/date-time-combobox.js +25 -0
- package/lib/unit-definitions/date.d.ts +5 -0
- package/lib/unit-definitions/date.js +25 -0
- package/lib/unit-definitions/email-input.d.ts +5 -0
- package/lib/unit-definitions/email-input.js +12 -0
- package/lib/unit-definitions/email.d.ts +5 -0
- package/lib/unit-definitions/email.js +17 -0
- package/lib/unit-definitions/emoji.d.ts +5 -0
- package/lib/unit-definitions/emoji.js +17 -0
- package/lib/unit-definitions/file-collection-count.d.ts +5 -0
- package/lib/unit-definitions/file-collection-count.js +34 -0
- package/lib/unit-definitions/file-compact-collection.d.ts +5 -0
- package/lib/unit-definitions/file-compact-collection.js +34 -0
- package/lib/unit-definitions/file-compact-reference.d.ts +5 -0
- package/lib/unit-definitions/file-compact-reference.js +47 -0
- package/lib/unit-definitions/file-reference.d.ts +5 -0
- package/lib/unit-definitions/file-reference.js +30 -0
- package/lib/unit-definitions/files-gallery.d.ts +5 -0
- package/lib/unit-definitions/files-gallery.js +34 -0
- package/lib/unit-definitions/files-l-list-item.d.ts +5 -0
- package/lib/unit-definitions/files-l-list-item.js +30 -0
- package/lib/unit-definitions/files-l-list.d.ts +5 -0
- package/lib/unit-definitions/files-l-list.js +34 -0
- package/lib/unit-definitions/files-list-item.d.ts +5 -0
- package/lib/unit-definitions/files-list-item.js +30 -0
- package/lib/unit-definitions/files-list.d.ts +5 -0
- package/lib/unit-definitions/files-list.js +34 -0
- package/lib/unit-definitions/geometry-preview.d.ts +5 -0
- package/lib/unit-definitions/geometry-preview.js +17 -0
- package/lib/unit-definitions/icon-button.d.ts +5 -0
- package/lib/unit-definitions/icon-button.js +41 -0
- package/lib/unit-definitions/icon-input.d.ts +5 -0
- package/lib/unit-definitions/icon-input.js +12 -0
- package/lib/unit-definitions/id.d.ts +5 -0
- package/lib/unit-definitions/id.js +30 -0
- package/lib/unit-definitions/index.d.ts +28 -0
- package/lib/unit-definitions/index.js +60 -0
- package/lib/unit-definitions/json-input.d.ts +5 -0
- package/lib/unit-definitions/json-input.js +24 -0
- package/lib/unit-definitions/location-input.d.ts +5 -0
- package/lib/unit-definitions/location-input.js +18 -0
- package/lib/unit-definitions/location.d.ts +5 -0
- package/lib/unit-definitions/location.js +17 -0
- package/lib/unit-definitions/not-found.d.ts +5 -0
- package/lib/unit-definitions/not-found.js +22 -0
- package/lib/unit-definitions/number-input.d.ts +5 -0
- package/lib/unit-definitions/number-input.js +25 -0
- package/lib/unit-definitions/number.d.ts +5 -0
- package/lib/unit-definitions/number.js +31 -0
- package/lib/unit-definitions/phone-input.d.ts +5 -0
- package/lib/unit-definitions/phone-input.js +12 -0
- package/lib/unit-definitions/phone.d.ts +5 -0
- package/lib/unit-definitions/phone.js +12 -0
- package/lib/unit-definitions/progress-bar.d.ts +5 -0
- package/lib/unit-definitions/progress-bar.js +32 -0
- package/lib/unit-definitions/reference-collection-combobox.d.ts +5 -0
- package/lib/unit-definitions/reference-collection-combobox.js +21 -0
- package/lib/unit-definitions/reference-collection-list.d.ts +5 -0
- package/lib/unit-definitions/reference-collection-list.js +21 -0
- package/lib/unit-definitions/reference-collection-view.d.ts +5 -0
- package/lib/unit-definitions/reference-collection-view.js +19 -0
- package/lib/unit-definitions/reference-collection.d.ts +5 -0
- package/lib/unit-definitions/reference-collection.js +30 -0
- package/lib/unit-definitions/reference-combobox.d.ts +5 -0
- package/lib/unit-definitions/reference-combobox.js +21 -0
- package/lib/unit-definitions/reference-icon.d.ts +5 -0
- package/lib/unit-definitions/reference-icon.js +12 -0
- package/lib/unit-definitions/reference.d.ts +5 -0
- package/lib/unit-definitions/reference.js +63 -0
- package/lib/unit-definitions/rich-text-document.d.ts +5 -0
- package/lib/unit-definitions/rich-text-document.js +26 -0
- package/lib/unit-definitions/rich-text-snippet.d.ts +6 -0
- package/lib/unit-definitions/rich-text-snippet.js +35 -0
- package/lib/unit-definitions/single-location-preview.d.ts +5 -0
- package/lib/unit-definitions/single-location-preview.js +17 -0
- package/lib/unit-definitions/text-input.d.ts +5 -0
- package/lib/unit-definitions/text-input.js +25 -0
- package/lib/unit-definitions/text.d.ts +5 -0
- package/lib/unit-definitions/text.js +25 -0
- package/lib/unit-definitions/title-input.d.ts +5 -0
- package/lib/unit-definitions/title-input.js +19 -0
- package/lib/unit-definitions/title.d.ts +5 -0
- package/lib/unit-definitions/title.js +33 -0
- package/lib/unit-definitions/type-badge-abbr.d.ts +5 -0
- package/lib/unit-definitions/type-badge-abbr.js +28 -0
- package/lib/unit-definitions/type-badge.d.ts +5 -0
- package/lib/unit-definitions/type-badge.js +28 -0
- package/lib/unit-definitions/type-icon.d.ts +5 -0
- package/lib/unit-definitions/type-icon.js +28 -0
- package/lib/unit-definitions/url-input.d.ts +5 -0
- package/lib/unit-definitions/url-input.js +12 -0
- package/lib/unit-definitions/url.d.ts +5 -0
- package/lib/unit-definitions/url.js +17 -0
- package/lib/unit-definitions/user-button.d.ts +5 -0
- package/lib/unit-definitions/user-button.js +26 -0
- package/lib/unit-definitions/user-role-input.d.ts +5 -0
- package/lib/unit-definitions/user-role-input.js +12 -0
- package/lib/unit-definitions/user-role.d.ts +5 -0
- package/lib/unit-definitions/user-role.js +35 -0
- package/lib/unit-utils/access.d.ts +12 -0
- package/lib/unit-utils/access.js +9 -0
- package/lib/unit-utils/can-edit-field.d.ts +9 -0
- package/lib/unit-utils/can-edit-field.js +7 -0
- package/lib/unit-utils/common.d.ts +17 -0
- package/lib/unit-utils/common.js +39 -0
- package/lib/unit-utils/decimal.d.ts +44 -0
- package/lib/unit-utils/decimal.js +248 -0
- package/lib/unit-utils/dynamic-keys.d.ts +10 -0
- package/lib/unit-utils/dynamic-keys.js +12 -0
- package/lib/unit-utils/enums.d.ts +30 -0
- package/lib/unit-utils/enums.js +48 -0
- package/lib/unit-utils/formatters.d.ts +53 -0
- package/lib/unit-utils/formatters.js +128 -0
- package/lib/unit-utils/get-export-value.d.ts +48 -0
- package/lib/unit-utils/get-export-value.js +83 -0
- package/lib/unit-utils/get-field-label.d.ts +9 -0
- package/lib/unit-utils/get-field-label.js +11 -0
- package/lib/unit-utils/get-unmatched-unit-label.d.ts +5 -0
- package/lib/unit-utils/get-unmatched-unit-label.js +5 -0
- package/lib/unit-utils/schema.d.ts +7 -0
- package/lib/unit-utils/schema.js +9 -0
- package/lib/unit-utils/wrap-normalized-in-expression.d.ts +6 -0
- package/lib/unit-utils/wrap-normalized-in-expression.js +15 -0
- package/lib/units/board.d.ts +50 -0
- package/lib/units/board.js +24 -0
- package/lib/units/canvas/all-units-data-definitions.d.ts +19 -0
- package/lib/units/canvas/all-units-data-definitions.js +42 -0
- package/lib/units/canvas/index.d.ts +49 -0
- package/lib/units/canvas/index.js +27 -0
- package/lib/units/canvas/type-badge-abbr.d.ts +42 -0
- package/lib/units/canvas/type-badge-abbr.js +11 -0
- package/lib/units/canvas/type-badge.d.ts +42 -0
- package/lib/units/canvas/type-badge.js +11 -0
- package/lib/units/default.d.ts +50 -0
- package/lib/units/default.js +23 -0
- package/lib/units/gallery.d.ts +7 -0
- package/lib/units/gallery.js +21 -0
- package/lib/units/gantt.d.ts +51 -0
- package/lib/units/gantt.js +28 -0
- package/lib/units/get-unit-definitions-for-view-type.d.ts +5 -0
- package/lib/units/get-unit-definitions-for-view-type.js +22 -0
- package/lib/units/grid.d.ts +49 -0
- package/lib/units/grid.js +81 -0
- package/lib/units/list.d.ts +52 -0
- package/lib/units/list.js +23 -0
- package/lib/units/make-factory.d.ts +53 -0
- package/lib/units/make-factory.js +272 -0
- package/lib/units/types.d.ts +75 -0
- package/lib/units/types.js +0 -0
- package/package.json +18 -40
- package/lib/src/errors.d.ts +0 -2
- package/lib/src/errors.js +0 -6
- package/lib/src/field-utils/avatar.d.ts +0 -20
- package/lib/src/field-utils/avatar.js +0 -42
- package/lib/src/field-utils/back-references.d.ts +0 -15
- package/lib/src/field-utils/back-references.js +0 -21
- package/lib/src/field-utils/comments.d.ts +0 -60
- package/lib/src/field-utils/comments.js +0 -46
- package/lib/src/field-utils/date-time.d.ts +0 -14
- package/lib/src/field-utils/date-time.js +0 -56
- package/lib/src/field-utils/enum-value.d.ts +0 -13
- package/lib/src/field-utils/enum-value.js +0 -29
- package/lib/src/field-utils/file.d.ts +0 -4
- package/lib/src/field-utils/file.js +0 -18
- package/lib/src/field-utils/icon.d.ts +0 -10
- package/lib/src/field-utils/icon.js +0 -26
- package/lib/src/field-utils/number.d.ts +0 -31
- package/lib/src/field-utils/number.js +0 -91
- package/lib/src/field-utils/reference-collection.d.ts +0 -13
- package/lib/src/field-utils/reference-collection.js +0 -67
- package/lib/src/field-utils/reference.d.ts +0 -7
- package/lib/src/field-utils/reference.js +0 -57
- package/lib/src/field-utils/relation-view.d.ts +0 -2
- package/lib/src/field-utils/relation-view.js +0 -12
- package/lib/src/field-utils/rich-text.d.ts +0 -13
- package/lib/src/field-utils/rich-text.js +0 -38
- package/lib/src/field-utils/text.d.ts +0 -35
- package/lib/src/field-utils/text.js +0 -40
- package/lib/src/field-utils/user-active.d.ts +0 -8
- package/lib/src/field-utils/user-active.js +0 -23
- package/lib/src/field-utils/user-role.d.ts +0 -6
- package/lib/src/field-utils/user-role.js +0 -25
- package/lib/src/field-utils/workflow.d.ts +0 -15
- package/lib/src/field-utils/workflow.js +0 -53
- package/lib/src/index.d.ts +0 -30
- package/lib/src/index.js +0 -263
- package/lib/src/meta-validation.d.ts +0 -10
- package/lib/src/meta-validation.js +0 -78
- package/lib/src/private/board.d.ts +0 -15
- package/lib/src/private/board.js +0 -327
- package/lib/src/private/calendar.d.ts +0 -14
- package/lib/src/private/calendar.js +0 -123
- package/lib/src/private/feed.d.ts +0 -14
- package/lib/src/private/feed.js +0 -120
- package/lib/src/private/form.d.ts +0 -25
- package/lib/src/private/form.js +0 -61
- package/lib/src/private/map.d.ts +0 -14
- package/lib/src/private/map.js +0 -120
- package/lib/src/private/smart-folder.d.ts +0 -31
- package/lib/src/private/smart-folder.js +0 -277
- package/lib/src/private/test-data/garbage-test.d.ts +0 -649
- package/lib/src/private/test-data/garbage-test.js +0 -520
- package/lib/src/private/test-data/kanban.d.ts +0 -1123
- package/lib/src/private/test-data/kanban.js +0 -1203
- package/lib/src/private/test-data/tasks.d.ts +0 -3216
- package/lib/src/private/test-data/tasks.js +0 -2731
- package/lib/src/private/timeline.d.ts +0 -39
- package/lib/src/private/timeline.js +0 -325
- package/lib/src/private/units.d.ts +0 -10
- package/lib/src/private/units.js +0 -165
- package/lib/src/private/utils.d.ts +0 -64
- package/lib/src/private/utils.js +0 -273
- package/lib/src/truthy.d.ts +0 -1
- package/lib/src/truthy.js +0 -7
- package/lib/src/tsfixme.d.ts +0 -1
- package/lib/src/tsfixme.js +0 -2
- package/lib/src/unit-definitions/avatar-collection.d.ts +0 -2
- package/lib/src/unit-definitions/avatar-collection.js +0 -54
- package/lib/src/unit-definitions/avatar-input.d.ts +0 -2
- package/lib/src/unit-definitions/avatar-input.js +0 -12
- package/lib/src/unit-definitions/avatar.d.ts +0 -2
- package/lib/src/unit-definitions/avatar.js +0 -88
- package/lib/src/unit-definitions/back-references-list.d.ts +0 -2
- package/lib/src/unit-definitions/back-references-list.js +0 -38
- package/lib/src/unit-definitions/bool-checkbox.d.ts +0 -2
- package/lib/src/unit-definitions/bool-checkbox.js +0 -25
- package/lib/src/unit-definitions/bool.d.ts +0 -2
- package/lib/src/unit-definitions/bool.js +0 -22
- package/lib/src/unit-definitions/collection-count.d.ts +0 -2
- package/lib/src/unit-definitions/collection-count.js +0 -32
- package/lib/src/unit-definitions/color-input.d.ts +0 -2
- package/lib/src/unit-definitions/color-input.js +0 -21
- package/lib/src/unit-definitions/comments-list.d.ts +0 -2
- package/lib/src/unit-definitions/comments-list.js +0 -25
- package/lib/src/unit-definitions/date-range-combobox.d.ts +0 -2
- package/lib/src/unit-definitions/date-range-combobox.js +0 -22
- package/lib/src/unit-definitions/date-range.d.ts +0 -2
- package/lib/src/unit-definitions/date-range.js +0 -22
- package/lib/src/unit-definitions/date-time-combobox.d.ts +0 -2
- package/lib/src/unit-definitions/date-time-combobox.js +0 -22
- package/lib/src/unit-definitions/date.d.ts +0 -2
- package/lib/src/unit-definitions/date.js +0 -22
- package/lib/src/unit-definitions/email-input.d.ts +0 -2
- package/lib/src/unit-definitions/email-input.js +0 -12
- package/lib/src/unit-definitions/email.d.ts +0 -2
- package/lib/src/unit-definitions/email.js +0 -17
- package/lib/src/unit-definitions/emoji.d.ts +0 -2
- package/lib/src/unit-definitions/emoji.js +0 -17
- package/lib/src/unit-definitions/file-collection-count.d.ts +0 -2
- package/lib/src/unit-definitions/file-collection-count.js +0 -32
- package/lib/src/unit-definitions/file-compact-collection.d.ts +0 -2
- package/lib/src/unit-definitions/file-compact-collection.js +0 -32
- package/lib/src/unit-definitions/file-compact-reference.d.ts +0 -2
- package/lib/src/unit-definitions/file-compact-reference.js +0 -37
- package/lib/src/unit-definitions/file-reference.d.ts +0 -2
- package/lib/src/unit-definitions/file-reference.js +0 -28
- package/lib/src/unit-definitions/files-gallery.d.ts +0 -2
- package/lib/src/unit-definitions/files-gallery.js +0 -32
- package/lib/src/unit-definitions/files-l-list-item.d.ts +0 -2
- package/lib/src/unit-definitions/files-l-list-item.js +0 -28
- package/lib/src/unit-definitions/files-l-list.d.ts +0 -2
- package/lib/src/unit-definitions/files-l-list.js +0 -32
- package/lib/src/unit-definitions/files-list-item.d.ts +0 -2
- package/lib/src/unit-definitions/files-list-item.js +0 -28
- package/lib/src/unit-definitions/files-list.d.ts +0 -2
- package/lib/src/unit-definitions/files-list.js +0 -32
- package/lib/src/unit-definitions/geometry-preview.d.ts +0 -2
- package/lib/src/unit-definitions/geometry-preview.js +0 -17
- package/lib/src/unit-definitions/icon-button.d.ts +0 -2
- package/lib/src/unit-definitions/icon-button.js +0 -29
- package/lib/src/unit-definitions/icon-input.d.ts +0 -2
- package/lib/src/unit-definitions/icon-input.js +0 -12
- package/lib/src/unit-definitions/id.d.ts +0 -2
- package/lib/src/unit-definitions/id.js +0 -29
- package/lib/src/unit-definitions/index.d.ts +0 -27
- package/lib/src/unit-definitions/index.js +0 -57
- package/lib/src/unit-definitions/json-input.d.ts +0 -2
- package/lib/src/unit-definitions/json-input.js +0 -21
- package/lib/src/unit-definitions/location-input.d.ts +0 -2
- package/lib/src/unit-definitions/location-input.js +0 -18
- package/lib/src/unit-definitions/location.d.ts +0 -2
- package/lib/src/unit-definitions/location.js +0 -17
- package/lib/src/unit-definitions/not-found.d.ts +0 -2
- package/lib/src/unit-definitions/not-found.js +0 -24
- package/lib/src/unit-definitions/number-input.d.ts +0 -2
- package/lib/src/unit-definitions/number-input.js +0 -22
- package/lib/src/unit-definitions/number.d.ts +0 -2
- package/lib/src/unit-definitions/number.js +0 -25
- package/lib/src/unit-definitions/phone-input.d.ts +0 -2
- package/lib/src/unit-definitions/phone-input.js +0 -12
- package/lib/src/unit-definitions/phone.d.ts +0 -2
- package/lib/src/unit-definitions/phone.js +0 -12
- package/lib/src/unit-definitions/progress-bar.d.ts +0 -2
- package/lib/src/unit-definitions/progress-bar.js +0 -29
- package/lib/src/unit-definitions/reference-collection-combobox.d.ts +0 -2
- package/lib/src/unit-definitions/reference-collection-combobox.js +0 -21
- package/lib/src/unit-definitions/reference-collection-list.d.ts +0 -2
- package/lib/src/unit-definitions/reference-collection-list.js +0 -22
- package/lib/src/unit-definitions/reference-collection-view.d.ts +0 -2
- package/lib/src/unit-definitions/reference-collection-view.js +0 -19
- package/lib/src/unit-definitions/reference-collection.d.ts +0 -2
- package/lib/src/unit-definitions/reference-collection.js +0 -28
- package/lib/src/unit-definitions/reference-combobox.d.ts +0 -2
- package/lib/src/unit-definitions/reference-combobox.js +0 -21
- package/lib/src/unit-definitions/reference-icon.d.ts +0 -2
- package/lib/src/unit-definitions/reference-icon.js +0 -12
- package/lib/src/unit-definitions/reference.d.ts +0 -2
- package/lib/src/unit-definitions/reference.js +0 -61
- package/lib/src/unit-definitions/rich-text-document.d.ts +0 -2
- package/lib/src/unit-definitions/rich-text-document.js +0 -22
- package/lib/src/unit-definitions/rich-text-snippet.d.ts +0 -3
- package/lib/src/unit-definitions/rich-text-snippet.js +0 -34
- package/lib/src/unit-definitions/single-location-preview.d.ts +0 -2
- package/lib/src/unit-definitions/single-location-preview.js +0 -17
- package/lib/src/unit-definitions/text-input.d.ts +0 -2
- package/lib/src/unit-definitions/text-input.js +0 -22
- package/lib/src/unit-definitions/text.d.ts +0 -2
- package/lib/src/unit-definitions/text.js +0 -22
- package/lib/src/unit-definitions/title-input.d.ts +0 -2
- package/lib/src/unit-definitions/title-input.js +0 -16
- package/lib/src/unit-definitions/title.d.ts +0 -2
- package/lib/src/unit-definitions/title.js +0 -34
- package/lib/src/unit-definitions/type-badge-abbr.d.ts +0 -2
- package/lib/src/unit-definitions/type-badge-abbr.js +0 -25
- package/lib/src/unit-definitions/type-badge.d.ts +0 -2
- package/lib/src/unit-definitions/type-badge.js +0 -25
- package/lib/src/unit-definitions/type-icon.d.ts +0 -2
- package/lib/src/unit-definitions/type-icon.js +0 -25
- package/lib/src/unit-definitions/url-input.d.ts +0 -2
- package/lib/src/unit-definitions/url-input.js +0 -12
- package/lib/src/unit-definitions/url.d.ts +0 -2
- package/lib/src/unit-definitions/url.js +0 -17
- package/lib/src/unit-definitions/user-button.d.ts +0 -2
- package/lib/src/unit-definitions/user-button.js +0 -23
- package/lib/src/unit-definitions/user-role-input.d.ts +0 -2
- package/lib/src/unit-definitions/user-role-input.js +0 -12
- package/lib/src/unit-definitions/user-role.d.ts +0 -2
- package/lib/src/unit-definitions/user-role.js +0 -29
- package/lib/src/unit-utils/access.d.ts +0 -9
- package/lib/src/unit-utils/access.js +0 -14
- package/lib/src/unit-utils/can-edit-field.d.ts +0 -6
- package/lib/src/unit-utils/can-edit-field.js +0 -8
- package/lib/src/unit-utils/common.d.ts +0 -14
- package/lib/src/unit-utils/common.js +0 -43
- package/lib/src/unit-utils/decimal.d.ts +0 -42
- package/lib/src/unit-utils/decimal.js +0 -418
- package/lib/src/unit-utils/dynamic-keys.d.ts +0 -7
- package/lib/src/unit-utils/dynamic-keys.js +0 -13
- package/lib/src/unit-utils/enums.d.ts +0 -27
- package/lib/src/unit-utils/enums.js +0 -69
- package/lib/src/unit-utils/formatters.d.ts +0 -50
- package/lib/src/unit-utils/formatters.js +0 -163
- package/lib/src/unit-utils/get-export-value.d.ts +0 -45
- package/lib/src/unit-utils/get-export-value.js +0 -83
- package/lib/src/unit-utils/get-field-label.d.ts +0 -6
- package/lib/src/unit-utils/get-field-label.js +0 -10
- package/lib/src/unit-utils/get-unmatched-unit-label.d.ts +0 -2
- package/lib/src/unit-utils/get-unmatched-unit-label.js +0 -9
- package/lib/src/unit-utils/schema.d.ts +0 -4
- package/lib/src/unit-utils/schema.js +0 -12
- package/lib/src/unit-utils/wrap-normalized-in-expression.d.ts +0 -3
- package/lib/src/unit-utils/wrap-normalized-in-expression.js +0 -14
- package/lib/src/units/board.d.ts +0 -46
- package/lib/src/units/board.js +0 -51
- package/lib/src/units/canvas/all-units-data-definitions.d.ts +0 -18
- package/lib/src/units/canvas/all-units-data-definitions.js +0 -40
- package/lib/src/units/canvas/index.d.ts +0 -45
- package/lib/src/units/canvas/index.js +0 -48
- package/lib/src/units/canvas/type-badge-abbr.d.ts +0 -36
- package/lib/src/units/canvas/type-badge-abbr.js +0 -11
- package/lib/src/units/canvas/type-badge.d.ts +0 -36
- package/lib/src/units/canvas/type-badge.js +0 -11
- package/lib/src/units/default.d.ts +0 -46
- package/lib/src/units/default.js +0 -51
- package/lib/src/units/gallery.d.ts +0 -3
- package/lib/src/units/gallery.js +0 -18
- package/lib/src/units/gantt.d.ts +0 -47
- package/lib/src/units/gantt.js +0 -59
- package/lib/src/units/get-unit-definitions-for-view-type.d.ts +0 -2
- package/lib/src/units/get-unit-definitions-for-view-type.js +0 -64
- package/lib/src/units/grid.d.ts +0 -45
- package/lib/src/units/grid.js +0 -71
- package/lib/src/units/list.d.ts +0 -46
- package/lib/src/units/list.js +0 -49
- package/lib/src/units/make-factory.d.ts +0 -51
- package/lib/src/units/make-factory.js +0 -261
- package/lib/src/units/types.d.ts +0 -73
- package/lib/src/units/types.js +0 -2
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { REMOVE, deleteExpressionWithNotFoundFieldsOrTypesInExpression, deleteExpressionWithNotFoundFieldsOrTypesInFilter, deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression, getFieldObjectsById, isUnitExpressionValid, replaceIdsWithNamesInExpression, replaceIdsWithNamesInFilter, replaceIdsWithNamesInQueryExpression, replaceIdsWithNamesInUnitGroupKey, replaceNamesWithIdsInExpression, replaceNamesWithIdsInFilter, replaceNamesWithIdsInQueryExpression, replaceNamesWithIdsInUnitGroupKey, resetContextExpressionIfBroken, visitContextExpression, visitViewUnit } from "./utils.js";
|
|
2
|
+
import { enableHideWhenEmptyForCheckedEditableUnit, fixViewUnit } from "./units.js";
|
|
3
|
+
import { truthy } from "@fibery/helpers/src/_";
|
|
4
|
+
import immutableUpdate from "immutability-helper";
|
|
5
|
+
import get from "lodash/get.js";
|
|
6
|
+
import { replaceIdsWithNamesVisitor, replaceNamesWithIdsVisitor } from "@fibery/expression-utils/src/visitors";
|
|
7
|
+
import isEqual from "lodash/isEqual.js";
|
|
8
|
+
//#region src/private/smart-folder.ts
|
|
9
|
+
const visitSmartFolder = (smartFolder, visitor) => immutableUpdate(smartFolder, { "fibery/meta": {
|
|
10
|
+
items: { $apply: (items = []) => {
|
|
11
|
+
const isOldSmartFolder = !items.every((item) => Object.hasOwn(item, "groupBy"));
|
|
12
|
+
const removedItemsIndexes = items.map((item, index) => visitor.visitQueryExpression(item.query) ? null : index).filter((value) => value !== null);
|
|
13
|
+
return items.map((item) => {
|
|
14
|
+
if (isOldSmartFolder) return item;
|
|
15
|
+
const fromType = get(item, ["query", "q/from"]);
|
|
16
|
+
return fromType ? immutableUpdate(item, { groupBy: { $apply: (groupBy) => {
|
|
17
|
+
if (!groupBy) return null;
|
|
18
|
+
const removedItemsBeforeTargetLengths = Object.keys(groupBy).map((key) => parseInt(key)).map((groupByIndex) => removedItemsIndexes.filter((n) => n < groupByIndex).length);
|
|
19
|
+
return visitor.visitGroupByExpression(groupBy, fromType, removedItemsBeforeTargetLengths);
|
|
20
|
+
} } }) : item;
|
|
21
|
+
}).map((item) => {
|
|
22
|
+
if (isOldSmartFolder) return item;
|
|
23
|
+
const fromType = get(item, ["query", "q/from"]);
|
|
24
|
+
return fromType ? immutableUpdate(item, { groupingExpression: { $apply: (groupingExpression) => {
|
|
25
|
+
if (!groupingExpression) return null;
|
|
26
|
+
const removedItemsBeforeTargetLengths = Object.keys(groupingExpression).map((key) => parseInt(key)).map((groupByIndex) => removedItemsIndexes.filter((n) => n < groupByIndex).length);
|
|
27
|
+
return visitor.visitGroupByExpression(groupingExpression, fromType, removedItemsBeforeTargetLengths);
|
|
28
|
+
} } }) : item;
|
|
29
|
+
}).map((item) => {
|
|
30
|
+
const fromType = get(item, ["query", "q/from"]);
|
|
31
|
+
return fromType ? immutableUpdate(item, {
|
|
32
|
+
filter: { $apply: (filter) => filter ? visitor.visitFilter(fromType, filter) : null },
|
|
33
|
+
query: { $apply: (query) => {
|
|
34
|
+
const visitedQuery = visitor.visitQueryExpression(query);
|
|
35
|
+
return query ? visitedQuery : null;
|
|
36
|
+
} },
|
|
37
|
+
units: { $apply: (units) => {
|
|
38
|
+
return units ? units.filter(truthy).map((unit) => visitViewUnit(fromType, unit, visitor)).filter(isUnitExpressionValid).map((unit, index, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter((unit) => unit !== REMOVE) : void 0;
|
|
39
|
+
} },
|
|
40
|
+
contextExpression: { $apply: (contextExpression) => visitContextExpression(fromType, contextExpression, visitor) },
|
|
41
|
+
colorCoding: { $apply: (colorCodings) => {
|
|
42
|
+
return colorCodings ? colorCodings.map((colorCoding) => ({
|
|
43
|
+
...colorCoding,
|
|
44
|
+
expression: visitor.visitExpression(fromType, colorCoding.expression)
|
|
45
|
+
})).filter((colorCoding) => colorCoding.expression !== null) : void 0;
|
|
46
|
+
} }
|
|
47
|
+
}) : item;
|
|
48
|
+
}).filter((item) => {
|
|
49
|
+
const { query } = item;
|
|
50
|
+
return query ? item : null;
|
|
51
|
+
});
|
|
52
|
+
} },
|
|
53
|
+
columnOrderWithIds: { $apply: (columnOrderWithIds) => {
|
|
54
|
+
if (!visitor.visitUnitGroupKey || !columnOrderWithIds) return columnOrderWithIds;
|
|
55
|
+
return columnOrderWithIds.map((key) => visitor.visitUnitGroupKey(key));
|
|
56
|
+
} },
|
|
57
|
+
pinnedColumnsWithIds: { $apply: (pinnedColumnsWithIds) => {
|
|
58
|
+
if (!visitor.visitUnitGroupKey || !pinnedColumnsWithIds) return pinnedColumnsWithIds;
|
|
59
|
+
return pinnedColumnsWithIds.map((key) => visitor.visitUnitGroupKey(key));
|
|
60
|
+
} },
|
|
61
|
+
columnAggFunc: { $apply: (columnAggFunc) => {
|
|
62
|
+
if (!visitor.visitUnitGroupKey || !columnAggFunc) return columnAggFunc;
|
|
63
|
+
return Object.fromEntries(Object.entries(columnAggFunc).map(([key, value]) => {
|
|
64
|
+
return [visitor.visitUnitGroupKey(key), value];
|
|
65
|
+
}));
|
|
66
|
+
} }
|
|
67
|
+
} });
|
|
68
|
+
const deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression = (schema, groupByExpression, fromType, removedItems) => {
|
|
69
|
+
if (!groupByExpression) return null;
|
|
70
|
+
const entries = Object.entries(groupByExpression).map(([index, { expression }], groupByIndex) => {
|
|
71
|
+
const visitedExpression = deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression);
|
|
72
|
+
if (visitedExpression) return [`${parseInt(index) - removedItems[groupByIndex]}`, { expression: visitedExpression }];
|
|
73
|
+
return null;
|
|
74
|
+
}).filter(truthy);
|
|
75
|
+
return entries.length > 0 ? Object.fromEntries(entries) : null;
|
|
76
|
+
};
|
|
77
|
+
const replaceIdsWithNamesInGroupByExpression = (schema, groupByExpression, fromType) => {
|
|
78
|
+
if (!groupByExpression) return null;
|
|
79
|
+
return Object.fromEntries(Object.entries(groupByExpression).map(([index, { expression }]) => {
|
|
80
|
+
if (Object.hasOwn(schema.typeObjectsById, fromType)) {
|
|
81
|
+
const typeObject = schema.typeObjectsById[fromType];
|
|
82
|
+
return [index, { expression: replaceIdsWithNamesVisitor(typeObject).visitExpression(expression) }];
|
|
83
|
+
} else return [index, { expression }];
|
|
84
|
+
}));
|
|
85
|
+
};
|
|
86
|
+
const replaceNamesWithIdsInGroupByExpression = (schema, groupByExpression, fromType) => {
|
|
87
|
+
if (!groupByExpression) return null;
|
|
88
|
+
return Object.fromEntries(Object.entries(groupByExpression).map(([index, { expression }]) => {
|
|
89
|
+
if (Object.hasOwn(schema.typeObjectsByName, fromType)) {
|
|
90
|
+
const typeObject = schema.typeObjectsByName[fromType];
|
|
91
|
+
return [index, { expression: replaceNamesWithIdsVisitor(typeObject).visitExpression(expression) }];
|
|
92
|
+
} else return [index, { expression }];
|
|
93
|
+
}));
|
|
94
|
+
};
|
|
95
|
+
const replaceNamesWithIdsInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
|
|
96
|
+
visitQueryExpression: (query) => replaceNamesWithIdsInQueryExpression(schema, query),
|
|
97
|
+
visitFilter: (fromType, expression) => replaceNamesWithIdsInFilter(schema, fromType, expression),
|
|
98
|
+
visitGroupByExpression: (groupBy, fromType) => replaceNamesWithIdsInGroupByExpression(schema, groupBy, fromType),
|
|
99
|
+
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
|
|
100
|
+
visitUnitGroupKey: (unitGroupKey) => replaceNamesWithIdsInUnitGroupKey(unitGroupKey, schema)
|
|
101
|
+
});
|
|
102
|
+
const replaceIdsWithNamesInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
|
|
103
|
+
visitQueryExpression: (query) => replaceIdsWithNamesInQueryExpression(schema, query),
|
|
104
|
+
visitFilter: (fromType, expression) => replaceIdsWithNamesInFilter(schema, fromType, expression),
|
|
105
|
+
visitGroupByExpression: (groupBy, fromType) => replaceIdsWithNamesInGroupByExpression(schema, groupBy, fromType),
|
|
106
|
+
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression),
|
|
107
|
+
visitUnitGroupKey: (unitGroupKey) => replaceIdsWithNamesInUnitGroupKey(unitGroupKey, getFieldObjectsById(smartFolder, schema))
|
|
108
|
+
});
|
|
109
|
+
const deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
|
|
110
|
+
visitQueryExpression: (query) => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, query),
|
|
111
|
+
visitGroupByExpression: (groupBy, fromType, removedItems) => deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression(schema, groupBy, fromType, removedItems),
|
|
112
|
+
visitFilter: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInFilter(schema, fromType, expression),
|
|
113
|
+
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
|
|
114
|
+
});
|
|
115
|
+
const fixContextExpressionWithBrokenPath = (schema, view, defaultContextExpression) => visitSmartFolder(view, {
|
|
116
|
+
visitQueryExpression: (query) => query,
|
|
117
|
+
visitGroupByExpression: (groupBy) => groupBy,
|
|
118
|
+
visitExpression: (_fromType, expression) => expression,
|
|
119
|
+
visitFilter: (_fromType, filter) => filter,
|
|
120
|
+
visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
|
|
121
|
+
});
|
|
122
|
+
const fixUserSelectedUnitsInSmartFolder = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => {
|
|
123
|
+
return visitSmartFolder(view, {
|
|
124
|
+
visitQueryExpression: (query) => query,
|
|
125
|
+
visitGroupByExpression: (groupBy) => groupBy,
|
|
126
|
+
visitFilter: (_fromType, filter) => filter,
|
|
127
|
+
visitExpression: (_fromType, expression) => expression,
|
|
128
|
+
visitViewUnit: (fromType, unit, units) => {
|
|
129
|
+
if (unit.kind !== "user-button") {
|
|
130
|
+
if (unit.type === "rich-text" && view?.["fibery/type"] === "grid") {
|
|
131
|
+
if (unit.checked) {
|
|
132
|
+
const snippetUnitForField = units.filter((x) => x.kind === "field" && x.type === "rich-text-snippet").find((x) => isEqual(x.expression, unit.expression));
|
|
133
|
+
if (snippetUnitForField && !snippetUnitForField.checked) snippetUnitForField.checked = true;
|
|
134
|
+
}
|
|
135
|
+
return REMOVE;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return fixViewUnit(schema, fromType, unit, units, {
|
|
139
|
+
unitDefinitions,
|
|
140
|
+
getDefaultUnitTypeForField
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
const collectGarbage = (view) => {
|
|
146
|
+
return visitSmartFolder(view, {
|
|
147
|
+
visitQueryExpression: (query) => query,
|
|
148
|
+
visitFilter: (_fromType, filter) => filter,
|
|
149
|
+
visitGroupByExpression: (groupBy) => groupBy,
|
|
150
|
+
visitExpression: (_fromType, expression) => expression,
|
|
151
|
+
visitViewUnit: (_fromType, unit) => unit.checked ? unit : REMOVE
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
const enableHideWhenEmptyForCheckedUnits = (view) => {
|
|
155
|
+
return visitSmartFolder(view, {
|
|
156
|
+
visitQueryExpression: (queryExpression) => queryExpression,
|
|
157
|
+
visitGroupByExpression: (groupBy) => groupBy,
|
|
158
|
+
visitExpression: (_fromType, expression) => expression,
|
|
159
|
+
visitFilter: (_fromType, filter) => filter,
|
|
160
|
+
visitEnums: (enums) => enums,
|
|
161
|
+
visitViewUnit: (_fromType, unit) => enableHideWhenEmptyForCheckedEditableUnit(unit)
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
//#endregion
|
|
165
|
+
export { collectGarbage, deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression, deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder, enableHideWhenEmptyForCheckedUnits, fixContextExpressionWithBrokenPath, fixUserSelectedUnitsInSmartFolder, replaceIdsWithNamesInGroupByExpression, replaceIdsWithNamesInSmartFolder, replaceNamesWithIdsInGroupByExpression, replaceNamesWithIdsInSmartFolder };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { UnitDefinitions, ViewFilter, ViewRecord } from "./utils.js";
|
|
2
|
+
import { FieldObject, Schema } from "@fibery/schema";
|
|
3
|
+
import { Expression, Query } from "@fibery/expression-utils/src/types";
|
|
4
|
+
import { Unit } from "@fibery/views/src/units/types";
|
|
5
|
+
//#region src/private/timeline.d.ts
|
|
6
|
+
type GroupByEntry = {
|
|
7
|
+
expression: Expression;
|
|
8
|
+
[k: string]: unknown;
|
|
9
|
+
};
|
|
10
|
+
type GroupByExpression = Record<string, GroupByEntry>;
|
|
11
|
+
type TimelineMetaItem = {
|
|
12
|
+
query?: Query | null;
|
|
13
|
+
filter?: ViewFilter | null;
|
|
14
|
+
yExpression?: Expression | null;
|
|
15
|
+
startExpression?: Expression | null;
|
|
16
|
+
endExpression?: Expression | null;
|
|
17
|
+
secondaryStartExpression?: Expression | null;
|
|
18
|
+
secondaryEndExpression?: Expression | null;
|
|
19
|
+
contextExpression?: Expression | null;
|
|
20
|
+
units?: Unit[] | null;
|
|
21
|
+
colorCoding?: {
|
|
22
|
+
expression: Expression;
|
|
23
|
+
[k: string]: unknown;
|
|
24
|
+
}[] | null;
|
|
25
|
+
dependencyExpression?: Expression | null;
|
|
26
|
+
groupBy?: GroupByExpression | null;
|
|
27
|
+
groupingExpression?: GroupByExpression | null;
|
|
28
|
+
[k: string]: unknown;
|
|
29
|
+
};
|
|
30
|
+
declare const replaceNamesWithIdsInTimelineView: (schema: Schema, view: ViewRecord) => any;
|
|
31
|
+
declare const replaceIdsWithNamesInTimelineView: (schema: Schema, view: ViewRecord) => any;
|
|
32
|
+
declare const deleteExpressionWithNotFoundFieldsOrTypesInTimelineView: (schema: Schema, view: ViewRecord, ensureAxisInvariant: boolean, canGroupMetaItem?: (_metaItem: TimelineMetaItem) => boolean) => any;
|
|
33
|
+
declare const fixUserSelectedUnitsInTimelineView: (schema: Schema, view: ViewRecord, { unitDefinitions, getDefaultUnitTypeForField }: {
|
|
34
|
+
unitDefinitions: UnitDefinitions;
|
|
35
|
+
getDefaultUnitTypeForField: (fieldObject: FieldObject, allowedUnits: Unit[]) => string | undefined;
|
|
36
|
+
}) => any;
|
|
37
|
+
declare const fixContextExpressionWithBrokenPath: (schema: Schema, view: ViewRecord, defaultContextExpression: Expression) => any;
|
|
38
|
+
declare const collectGarbage: (view: ViewRecord) => any;
|
|
39
|
+
declare const enableHideWhenEmptyForCheckedEditableUnits: (view: ViewRecord) => any;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { collectGarbage, deleteExpressionWithNotFoundFieldsOrTypesInTimelineView, enableHideWhenEmptyForCheckedEditableUnits, fixContextExpressionWithBrokenPath, fixUserSelectedUnitsInTimelineView, replaceIdsWithNamesInTimelineView, replaceNamesWithIdsInTimelineView };
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { REMOVE, deleteExpressionWithNotFoundFieldsOrTypesInExpression, deleteExpressionWithNotFoundFieldsOrTypesInFilter, deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression, isUnitExpressionValid, replaceIdsWithNamesInExpression, replaceIdsWithNamesInFilter, replaceIdsWithNamesInQueryExpression, replaceNamesWithIdsInExpression, replaceNamesWithIdsInFilter, replaceNamesWithIdsInQueryExpression, resetContextExpressionIfBroken, visitContextExpression, visitViewUnit } from "./utils.js";
|
|
2
|
+
import { enableHideWhenEmptyForCheckedEditableUnit, fixViewUnit } from "./units.js";
|
|
3
|
+
import { deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression, replaceIdsWithNamesInGroupByExpression, replaceNamesWithIdsInGroupByExpression } from "./smart-folder.js";
|
|
4
|
+
import { truthy } from "@fibery/helpers/src/_";
|
|
5
|
+
import immutableUpdate from "immutability-helper";
|
|
6
|
+
import get from "lodash/get.js";
|
|
7
|
+
import entries from "lodash/entries.js";
|
|
8
|
+
import isEmpty from "lodash/isEmpty.js";
|
|
9
|
+
import set from "lodash/set.js";
|
|
10
|
+
import some from "lodash/some.js";
|
|
11
|
+
import has from "lodash/has.js";
|
|
12
|
+
//#region src/private/timeline.ts
|
|
13
|
+
const visitAxisSingle = (axis, visitor) => {
|
|
14
|
+
const fromType = get(axis, ["query", "q/from"]);
|
|
15
|
+
const firstOrNull = (x) => Array.isArray(x) ? x[0] : null;
|
|
16
|
+
const axisResult = {
|
|
17
|
+
...axis,
|
|
18
|
+
filter: axis.filter ? visitor.visitFilter(fromType, axis.filter) : null,
|
|
19
|
+
query: axis.query && visitor.visitQueryExpression(axis.query),
|
|
20
|
+
contextExpression: visitContextExpression(fromType, axis.contextExpression, visitor),
|
|
21
|
+
units: axis.units && axis.units.map((unit) => visitViewUnit(fromType, unit, visitor)).filter(isUnitExpressionValid).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter((unit) => unit !== REMOVE),
|
|
22
|
+
groupByExpression: axis.groupByExpression && firstOrNull(visitor.visitExpression(fromType, [axis.groupByExpression]))
|
|
23
|
+
};
|
|
24
|
+
if (!axisResult.query) return null;
|
|
25
|
+
if (!axisResult.units) delete axisResult.units;
|
|
26
|
+
return axisResult;
|
|
27
|
+
};
|
|
28
|
+
const visitAxis = (axis, visitor) => {
|
|
29
|
+
if (axis && Object.hasOwn(axis, "query")) return visitAxisSingle(axis, visitor);
|
|
30
|
+
if (axis && Object.hasOwn(axis, "enums")) {
|
|
31
|
+
const axisNew = immutableUpdate(axis, { enums: { $apply: (enums) => visitor.visitEnums(enums) } });
|
|
32
|
+
const { enums } = axisNew;
|
|
33
|
+
return enums ? axisNew : null;
|
|
34
|
+
}
|
|
35
|
+
return axis;
|
|
36
|
+
};
|
|
37
|
+
const visitView = (view, visitor) => immutableUpdate(view, { "fibery/meta": {
|
|
38
|
+
y: { $apply: (y) => visitAxis(y, visitor) },
|
|
39
|
+
items: { $apply: (items) => {
|
|
40
|
+
const removedItemsIndexes = items.map((item, index) => visitor.visitQueryExpression(item.query) ? null : index).filter((value) => value !== null);
|
|
41
|
+
return items.map((item) => {
|
|
42
|
+
const fromType = get(item, ["query", "q/from"]);
|
|
43
|
+
const hasGroupingExpression = has(item, ["groupingExpression"]);
|
|
44
|
+
return fromType ? immutableUpdate(item, {
|
|
45
|
+
yExpression: { $apply: (yExpression) => yExpression ? visitor.visitExpression(fromType, yExpression) : yExpression },
|
|
46
|
+
startExpression: { $apply: (startExpression) => startExpression ? visitor.visitExpression(fromType, startExpression) : startExpression },
|
|
47
|
+
endExpression: { $apply: (endExpression) => endExpression ? visitor.visitExpression(fromType, endExpression) : endExpression },
|
|
48
|
+
secondaryStartExpression: { $apply: (secondaryStartExpression) => secondaryStartExpression ? visitor.visitExpression(fromType, secondaryStartExpression) : secondaryStartExpression },
|
|
49
|
+
secondaryEndExpression: { $apply: (secondaryEndExpression) => secondaryEndExpression ? visitor.visitExpression(fromType, secondaryEndExpression) : secondaryEndExpression },
|
|
50
|
+
contextExpression: { $apply: (contextExpression) => visitContextExpression(fromType, contextExpression, visitor) },
|
|
51
|
+
filter: { $apply: (filter) => filter ? visitor.visitFilter(fromType, filter) : null },
|
|
52
|
+
query: { $apply: (query) => query ? visitor.visitQueryExpression(query) : null },
|
|
53
|
+
units: { $apply: (units) => units ? units.filter(truthy).map((unit) => visitViewUnit(fromType, unit, visitor)).filter(isUnitExpressionValid).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter((unit) => unit !== REMOVE) : void 0 },
|
|
54
|
+
colorCoding: { $apply: (colorCodings) => {
|
|
55
|
+
return colorCodings && colorCodings.map((colorCoding) => ({
|
|
56
|
+
...colorCoding,
|
|
57
|
+
expression: visitor.visitExpression(fromType, colorCoding.expression)
|
|
58
|
+
})).filter((colorCoding) => colorCoding.expression !== null);
|
|
59
|
+
} },
|
|
60
|
+
dependencyExpression: { $apply: (expression) => {
|
|
61
|
+
return expression && visitor.visitExpression(fromType, expression);
|
|
62
|
+
} },
|
|
63
|
+
groupBy: { $apply: (groupBy) => {
|
|
64
|
+
if (!groupBy) return groupBy;
|
|
65
|
+
const removedItemsBeforeTargetLengths = Object.keys(groupBy).map((key) => parseInt(key)).map((groupByIndex) => removedItemsIndexes.filter((n) => n < groupByIndex).length);
|
|
66
|
+
return visitor.visitGroupByExpression(groupBy, fromType, removedItemsBeforeTargetLengths);
|
|
67
|
+
} },
|
|
68
|
+
...hasGroupingExpression ? { groupingExpression: { $apply: (groupingExpression) => {
|
|
69
|
+
if (!groupingExpression) return null;
|
|
70
|
+
const removedItemsBeforeTargetLengths = Object.keys(groupingExpression).map((key) => parseInt(key)).map((groupByIndex) => removedItemsIndexes.filter((n) => n < groupByIndex).length);
|
|
71
|
+
return visitor.visitGroupByExpression(groupingExpression, fromType, removedItemsBeforeTargetLengths);
|
|
72
|
+
} } } : void 0
|
|
73
|
+
}) : item;
|
|
74
|
+
}).filter((item) => {
|
|
75
|
+
const { query } = item;
|
|
76
|
+
return query ? item : null;
|
|
77
|
+
});
|
|
78
|
+
} },
|
|
79
|
+
milestones: { $apply: (milestones) => {
|
|
80
|
+
if (!milestones) return milestones;
|
|
81
|
+
return milestones.map((item) => {
|
|
82
|
+
const fromType = get(item, ["query", "q/from"]);
|
|
83
|
+
return fromType ? immutableUpdate(item, {
|
|
84
|
+
dateExpression: { $apply: (startExpression) => startExpression ? visitor.visitExpression(fromType, startExpression) : startExpression },
|
|
85
|
+
filter: { $apply: (filter) => filter ? visitor.visitFilter(fromType, filter) : null },
|
|
86
|
+
query: { $apply: (query) => query ? visitor.visitQueryExpression(query) : null },
|
|
87
|
+
contextExpression: { $apply: (contextExpression) => visitContextExpression(fromType, contextExpression, visitor) }
|
|
88
|
+
}) : item;
|
|
89
|
+
}).filter((item) => {
|
|
90
|
+
const { query } = item;
|
|
91
|
+
return query ? item : null;
|
|
92
|
+
});
|
|
93
|
+
} }
|
|
94
|
+
} });
|
|
95
|
+
const replaceNamesWithIdsInTimelineView = (schema, view) => {
|
|
96
|
+
const visitor = {
|
|
97
|
+
visitQueryExpression: (query) => replaceNamesWithIdsInQueryExpression(schema, query),
|
|
98
|
+
visitFilter: (fromType, expression) => replaceNamesWithIdsInFilter(schema, fromType, expression),
|
|
99
|
+
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
|
|
100
|
+
visitEnums: (enums) => entries(enums).reduce((result, [type, axis]) => {
|
|
101
|
+
if (Object.hasOwn(schema.typeObjectsByName, type)) {
|
|
102
|
+
const typeObject = schema.typeObjectsByName[type];
|
|
103
|
+
result[typeObject.id] = visitAxisSingle(axis, visitor);
|
|
104
|
+
} else result[type] = axis;
|
|
105
|
+
return result;
|
|
106
|
+
}, {}),
|
|
107
|
+
visitGroupByExpression: (groupBy, fromType) => replaceNamesWithIdsInGroupByExpression(schema, groupBy, fromType)
|
|
108
|
+
};
|
|
109
|
+
return visitView(view, visitor);
|
|
110
|
+
};
|
|
111
|
+
const replaceIdsWithNamesInTimelineView = (schema, view) => {
|
|
112
|
+
const visitor = {
|
|
113
|
+
visitQueryExpression: (query) => replaceIdsWithNamesInQueryExpression(schema, query),
|
|
114
|
+
visitFilter: (fromType, expression) => replaceIdsWithNamesInFilter(schema, fromType, expression),
|
|
115
|
+
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression),
|
|
116
|
+
visitEnums: (enums) => entries(enums).reduce((result, [typeId, axis]) => {
|
|
117
|
+
if (Object.hasOwn(schema.typeObjectsById, typeId)) {
|
|
118
|
+
const typeObject = schema.typeObjectsById[typeId];
|
|
119
|
+
result[typeObject.name] = visitAxisSingle(axis, visitor);
|
|
120
|
+
} else result[typeId] = axis;
|
|
121
|
+
return result;
|
|
122
|
+
}, {}),
|
|
123
|
+
visitGroupByExpression: (groupBy, fromType) => replaceIdsWithNamesInGroupByExpression(schema, groupBy, fromType)
|
|
124
|
+
};
|
|
125
|
+
return visitView(view, visitor);
|
|
126
|
+
};
|
|
127
|
+
const ensureAxisAndItemExpressionInvariant = (view, canGroupMetaItem) => {
|
|
128
|
+
const actions = [];
|
|
129
|
+
const y = get(view, ["fibery/meta", "y"]);
|
|
130
|
+
const yQuery = get(view, [
|
|
131
|
+
"fibery/meta",
|
|
132
|
+
"y",
|
|
133
|
+
"query"
|
|
134
|
+
]);
|
|
135
|
+
const yGroupByExpression = get(view, [
|
|
136
|
+
"fibery/meta",
|
|
137
|
+
"y",
|
|
138
|
+
"groupByExpression"
|
|
139
|
+
]);
|
|
140
|
+
const items = get(view, ["fibery/meta", "items"]);
|
|
141
|
+
if (yQuery === null && yGroupByExpression !== null) actions.push(() => set(view, [
|
|
142
|
+
"fibery/meta",
|
|
143
|
+
"y",
|
|
144
|
+
"groupByExpression"
|
|
145
|
+
], null));
|
|
146
|
+
if (y === null) {
|
|
147
|
+
const resetActions = items.map((item) => () => item.yExpression = null);
|
|
148
|
+
actions.push(...resetActions);
|
|
149
|
+
}
|
|
150
|
+
const filteredMetaItems = items.filter(canGroupMetaItem);
|
|
151
|
+
if (y !== null && some(filteredMetaItems, ({ yExpression }) => yExpression === null)) {
|
|
152
|
+
const resetActions = filteredMetaItems.map((item) => () => item.yExpression = null);
|
|
153
|
+
actions.push(...resetActions);
|
|
154
|
+
actions.push(() => set(view, ["fibery/meta", "y"], null));
|
|
155
|
+
}
|
|
156
|
+
if (y !== null && isEmpty(items)) actions.push(() => set(view, ["fibery/meta", "y"], null));
|
|
157
|
+
actions.forEach((action) => action());
|
|
158
|
+
return view;
|
|
159
|
+
};
|
|
160
|
+
const deleteExpressionWithNotFoundFieldsOrTypesInTimelineView = (schema, view, ensureAxisInvariant, canGroupMetaItem = (_metaItem) => true) => {
|
|
161
|
+
const visitor = {
|
|
162
|
+
visitQueryExpression: (queryExpression) => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, queryExpression),
|
|
163
|
+
visitFilter: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInFilter(schema, fromType, expression),
|
|
164
|
+
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression),
|
|
165
|
+
visitEnums: (enums) => {
|
|
166
|
+
const enumsNew = entries(enums).reduce((result, [type, axis]) => {
|
|
167
|
+
if (Object.hasOwn(schema.typeObjectsByName, type)) {
|
|
168
|
+
const typeObject = schema.typeObjectsByName[type];
|
|
169
|
+
const axisResult = visitAxisSingle(axis, visitor);
|
|
170
|
+
if (axisResult) result[typeObject.name] = axisResult;
|
|
171
|
+
}
|
|
172
|
+
return result;
|
|
173
|
+
}, {});
|
|
174
|
+
return isEmpty(enumsNew) ? null : enumsNew;
|
|
175
|
+
},
|
|
176
|
+
visitGroupByExpression: (groupBy, fromType, removedItems) => deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression(schema, groupBy, fromType, removedItems)
|
|
177
|
+
};
|
|
178
|
+
const viewNew = visitView(view, visitor);
|
|
179
|
+
return ensureAxisInvariant ? ensureAxisAndItemExpressionInvariant(viewNew, canGroupMetaItem) : viewNew;
|
|
180
|
+
};
|
|
181
|
+
const fixUserSelectedUnitsInTimelineView = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => {
|
|
182
|
+
return visitView(view, {
|
|
183
|
+
visitQueryExpression: (query) => query,
|
|
184
|
+
visitExpression: (_fromType, expression) => expression,
|
|
185
|
+
visitFilter: (_fromType, filter) => filter,
|
|
186
|
+
visitViewUnit: (fromType, unit, units) => fixViewUnit(schema, fromType, unit, units, {
|
|
187
|
+
unitDefinitions,
|
|
188
|
+
getDefaultUnitTypeForField
|
|
189
|
+
}),
|
|
190
|
+
visitEnums: (enums) => enums,
|
|
191
|
+
visitGroupByExpression: (groupBy) => groupBy
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
const fixContextExpressionWithBrokenPath = (schema, view, defaultContextExpression) => visitView(view, {
|
|
195
|
+
visitExpression: (_fromType, expression) => expression,
|
|
196
|
+
visitFilter: (_fromType, filter) => filter,
|
|
197
|
+
visitQueryExpression: (query) => query,
|
|
198
|
+
visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression),
|
|
199
|
+
visitEnums: (enums) => enums,
|
|
200
|
+
visitGroupByExpression: (groupBy) => groupBy
|
|
201
|
+
});
|
|
202
|
+
const collectGarbage = (view) => {
|
|
203
|
+
return visitView(view, {
|
|
204
|
+
visitQueryExpression: (query) => query,
|
|
205
|
+
visitFilter: (_fromType, filter) => filter,
|
|
206
|
+
visitExpression: (_fromType, expression) => expression,
|
|
207
|
+
visitViewUnit: (_fromType, unit) => unit.checked ? unit : REMOVE,
|
|
208
|
+
visitEnums: (enums) => enums,
|
|
209
|
+
visitGroupByExpression: (groupBy) => groupBy
|
|
210
|
+
});
|
|
211
|
+
};
|
|
212
|
+
const enableHideWhenEmptyForCheckedEditableUnits = (view) => {
|
|
213
|
+
return visitView(view, {
|
|
214
|
+
visitQueryExpression: (queryExpression) => queryExpression,
|
|
215
|
+
visitExpression: (_fromType, expression) => expression,
|
|
216
|
+
visitFilter: (_fromType, filter) => filter,
|
|
217
|
+
visitViewUnit: (_fromType, unit) => enableHideWhenEmptyForCheckedEditableUnit(unit),
|
|
218
|
+
visitEnums: (enums) => enums,
|
|
219
|
+
visitGroupByExpression: (groupBy) => groupBy
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
//#endregion
|
|
223
|
+
export { collectGarbage, deleteExpressionWithNotFoundFieldsOrTypesInTimelineView, enableHideWhenEmptyForCheckedEditableUnits, fixContextExpressionWithBrokenPath, fixUserSelectedUnitsInTimelineView, replaceIdsWithNamesInTimelineView, replaceNamesWithIdsInTimelineView };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { REMOVE, UnitDefinitions } from "./utils.js";
|
|
2
|
+
import { FieldObject, Schema } from "@fibery/schema";
|
|
3
|
+
import { Unit } from "@fibery/views/src/units/types";
|
|
4
|
+
//#region src/private/units.d.ts
|
|
5
|
+
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
|
+
declare const enableHideWhenEmptyForCheckedEditableUnit: (unit: Unit) => Unit;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { enableHideWhenEmptyForCheckedEditableUnit, fixViewUnit };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { REMOVE } from "./utils.js";
|
|
2
|
+
import { getFieldObjectsByFieldExpression } from "@fibery/expression-utils/src/utils";
|
|
3
|
+
//#region src/private/units.ts
|
|
4
|
+
const getField = (schema, fromType, field) => Object.hasOwn(schema.typeObjectsByName, fromType) && Object.hasOwn(schema.typeObjectsByName[fromType].fieldObjectsByName, field) ? schema.typeObjectsByName[fromType].fieldObjectsByName[field] : void 0;
|
|
5
|
+
const getFieldType = (schema, fromType, field) => getField(schema, fromType, field)?.type;
|
|
6
|
+
const getFieldMeta = (schema, fromType, field) => getField(schema, fromType, field)?.rawMeta;
|
|
7
|
+
const getFieldByExpression = (schema, fromType, expression) => {
|
|
8
|
+
let currentType = fromType;
|
|
9
|
+
let fieldObject;
|
|
10
|
+
for (const part of expression) {
|
|
11
|
+
fieldObject = getField(schema, currentType, part);
|
|
12
|
+
if (!fieldObject) return null;
|
|
13
|
+
currentType = fieldObject.type;
|
|
14
|
+
}
|
|
15
|
+
return fieldObject ?? null;
|
|
16
|
+
};
|
|
17
|
+
const getUnitTypeForTextField = (fieldMeta) => {
|
|
18
|
+
switch (fieldMeta["ui/type"]) {
|
|
19
|
+
case "email": return "email";
|
|
20
|
+
case "url": return "url";
|
|
21
|
+
case "phone": return "phone";
|
|
22
|
+
default: return "text";
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const getUnitKind = (unit) => {
|
|
26
|
+
if (unit.type === "user-button") return "user-button";
|
|
27
|
+
if ([
|
|
28
|
+
"type-icon",
|
|
29
|
+
"type-badge",
|
|
30
|
+
"type-badge-abbr"
|
|
31
|
+
].includes(unit.type)) return "db";
|
|
32
|
+
return "field";
|
|
33
|
+
};
|
|
34
|
+
const migrateUnitOptsDefault = { migrateFileCollectionUnit: true };
|
|
35
|
+
const migrateUnit = (schema, fromType, unit, units, opts = migrateUnitOptsDefault) => {
|
|
36
|
+
const kind = unit.kind || getUnitKind(unit);
|
|
37
|
+
if (unit.type === "date-time") return {
|
|
38
|
+
...unit,
|
|
39
|
+
kind,
|
|
40
|
+
type: "date"
|
|
41
|
+
};
|
|
42
|
+
if (unit.type === "date-time-range") return {
|
|
43
|
+
...unit,
|
|
44
|
+
kind,
|
|
45
|
+
type: "date-range"
|
|
46
|
+
};
|
|
47
|
+
if (unit.type === "text") {
|
|
48
|
+
const [field] = unit.expression;
|
|
49
|
+
if (getFieldType(schema, fromType, field) === "fibery/email") return {
|
|
50
|
+
...unit,
|
|
51
|
+
kind,
|
|
52
|
+
type: "email"
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (unit.type === "text" || unit.type === "email" || unit.type === "phone" || unit.type === "url") {
|
|
56
|
+
const [field] = unit.expression;
|
|
57
|
+
if (getFieldType(schema, fromType, field) === "fibery/text") return {
|
|
58
|
+
...unit,
|
|
59
|
+
kind,
|
|
60
|
+
type: getUnitTypeForTextField(getFieldMeta(schema, fromType, field))
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (unit.type === "files-collection") {
|
|
64
|
+
const [field] = unit.expression;
|
|
65
|
+
if (getFieldType(schema, fromType, field) === "fibery/file") return {
|
|
66
|
+
...unit,
|
|
67
|
+
kind,
|
|
68
|
+
type: opts.migrateFileCollectionUnit ? "file-collection-count" : "collection-count"
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if (unit.type === "avatar" && !unit.expression) {
|
|
72
|
+
const isAvatarExntensionEnabled = schema.typeObjectsByName[fromType]?.installedMixins.has("avatar/avatar-mixin");
|
|
73
|
+
const hasAvatarExntensionField = getFieldType(schema, fromType, "avatar/avatars") === "fibery/file";
|
|
74
|
+
if (isAvatarExntensionEnabled && hasAvatarExntensionField) return {
|
|
75
|
+
...unit,
|
|
76
|
+
expression: ["avatar/avatars"],
|
|
77
|
+
kind
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
if (opts.migrateFileCollectionUnit && unit.type === "collection-count") {
|
|
81
|
+
const [field] = unit.expression;
|
|
82
|
+
const fieldObject = getField(schema, fromType, field);
|
|
83
|
+
if (fieldObject?.type === "fibery/file" && fieldObject?.isCollection) return {
|
|
84
|
+
...unit,
|
|
85
|
+
kind,
|
|
86
|
+
type: "file-collection-count"
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
...unit,
|
|
91
|
+
kind
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
const expressionFrom = (unit) => unit.expression;
|
|
95
|
+
const fixViewUnit = (schema, fromType, unit, units, { unitDefinitions, getDefaultUnitTypeForField, migrateFileCollectionUnit = true }) => {
|
|
96
|
+
const migrated = migrateUnit(schema, fromType, unit, units, { migrateFileCollectionUnit });
|
|
97
|
+
const expression = expressionFrom(unit) ?? [];
|
|
98
|
+
const fieldObject = getFieldByExpression(schema, fromType, expression);
|
|
99
|
+
if (fieldObject) {
|
|
100
|
+
const typeObject = schema.typeObjectsByName[fromType];
|
|
101
|
+
const parentFieldObjects = typeObject && expression.length > 1 ? getFieldObjectsByFieldExpression({
|
|
102
|
+
typeObject,
|
|
103
|
+
expression
|
|
104
|
+
}).slice(0, -1) : [];
|
|
105
|
+
const allowedUnits = unitDefinitions.getUnitsForField(fieldObject, { parentFieldObjects });
|
|
106
|
+
if (allowedUnits.some((u) => u.type === migrated.type)) return migrated;
|
|
107
|
+
else if (unit.checked) {
|
|
108
|
+
const otherUnitsForField = units.filter((u) => {
|
|
109
|
+
const uExpression = expressionFrom(u);
|
|
110
|
+
return u !== unit && uExpression && expressionFrom(unit) && uExpression.join("/") === expression.join("/");
|
|
111
|
+
});
|
|
112
|
+
if (otherUnitsForField.some((u) => u.checked)) return REMOVE;
|
|
113
|
+
const defaultUnitType = getDefaultUnitTypeForField(fieldObject, allowedUnits);
|
|
114
|
+
const defaultUnit = defaultUnitType && otherUnitsForField.find((u) => u.type === defaultUnitType) || otherUnitsForField[0];
|
|
115
|
+
if (defaultUnit) {
|
|
116
|
+
defaultUnit.checked = true;
|
|
117
|
+
return REMOVE;
|
|
118
|
+
}
|
|
119
|
+
} else return REMOVE;
|
|
120
|
+
}
|
|
121
|
+
return migrated;
|
|
122
|
+
};
|
|
123
|
+
const enableHideWhenEmptyForCheckedEditableUnit = (unit) => {
|
|
124
|
+
if (unit.checked) return {
|
|
125
|
+
...unit,
|
|
126
|
+
hideWhenEmpty: true
|
|
127
|
+
};
|
|
128
|
+
return unit;
|
|
129
|
+
};
|
|
130
|
+
//#endregion
|
|
131
|
+
export { enableHideWhenEmptyForCheckedEditableUnit, fixViewUnit };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { FieldObject, Schema } from "@fibery/schema";
|
|
2
|
+
import { Expression, Query } from "@fibery/expression-utils/src/types";
|
|
3
|
+
import { Unit } from "@fibery/views/src/units/types";
|
|
4
|
+
//#region src/private/utils.d.ts
|
|
5
|
+
declare const REMOVE: unique symbol;
|
|
6
|
+
declare const skipRemove: (unit: Unit | typeof REMOVE) => unit is Unit;
|
|
7
|
+
type ViewVisitor = {
|
|
8
|
+
visitExpression: (fromType: string, expression: Expression) => Expression | null;
|
|
9
|
+
visitFilter: (fromType: string, filter: ViewFilter | null) => ViewFilter | null;
|
|
10
|
+
visitQueryExpression: (query: Query) => Query | null;
|
|
11
|
+
visitViewUnit?: (fromType: string, unit: Unit, units: Unit[]) => Unit | typeof REMOVE;
|
|
12
|
+
visitContextExpression?: (fromType: string, expression: Expression) => Expression;
|
|
13
|
+
visitGroupByExpression?: (groupBy: Record<string, unknown>, fromType: string, removedItems?: number[]) => Record<string, unknown> | null;
|
|
14
|
+
visitEnums?: (enums: Record<string, unknown>) => Record<string, unknown> | null;
|
|
15
|
+
visitUnitGroupKey?: (key: string) => string;
|
|
16
|
+
};
|
|
17
|
+
type UnitDefinitions = {
|
|
18
|
+
getUnitsForField: (fieldObject: FieldObject, options?: {
|
|
19
|
+
parentFieldObjects?: FieldObject[];
|
|
20
|
+
}) => Unit[];
|
|
21
|
+
};
|
|
22
|
+
type ViewRecord = Record<string, unknown>;
|
|
23
|
+
type ViewFilterLeaf = {
|
|
24
|
+
kind: string;
|
|
25
|
+
value: {
|
|
26
|
+
expression: Expression | null;
|
|
27
|
+
[k: string]: unknown;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
type ViewFilterGroup = {
|
|
31
|
+
kind: "group";
|
|
32
|
+
value: ViewFilter[];
|
|
33
|
+
};
|
|
34
|
+
type ViewFilter = ViewFilterLeaf | ViewFilterGroup;
|
|
35
|
+
declare const deleteExpressionWithNotFoundFieldsOrTypesInFilter: (schema: Schema, fromType: string, filter: ViewFilter) => ViewFilter | null;
|
|
36
|
+
declare const deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression: (schema: Schema, queryExpression: Query) => Query | null;
|
|
37
|
+
declare const replaceNamesWithIdsInExpression: (schema: Schema, fromType: string, expression: Expression) => any;
|
|
38
|
+
declare const replaceIdsWithNamesInExpression: (schema: Schema, fromTypeId: string, expression: Expression) => any;
|
|
39
|
+
declare const visitViewUnit: (fromType: string, unit: Unit, visitor: Pick<ViewVisitor, "visitExpression">) => Unit;
|
|
40
|
+
declare const visitContextExpression: (fromType: string, contextExpression: Expression | null | undefined, visitor: Pick<ViewVisitor, "visitExpression" | "visitContextExpression">) => string | Expression[] | null | undefined;
|
|
41
|
+
declare const replaceIdsWithNamesInQueryExpression: (schema: Schema, queryExpression: Query) => {
|
|
42
|
+
"q/select"?: Expression | import("@fibery/expression-utils").Select;
|
|
43
|
+
"q/offset"?: number;
|
|
44
|
+
"q/order-by"?: any;
|
|
45
|
+
"q/limit"?: import("@fibery/expression-utils/src/types").QueryLimit;
|
|
46
|
+
"q/where"?: any;
|
|
47
|
+
"q/from": string;
|
|
48
|
+
};
|
|
49
|
+
declare const replaceIdsWithNamesInFilter: (schema: Schema, fromType: string, filter: ViewFilter | null) => ViewFilter | null;
|
|
50
|
+
declare const replaceNamesWithIdsInFilter: (schema: Schema, fromType: string, filter: ViewFilter | null) => ViewFilter | null;
|
|
51
|
+
declare const replaceNamesWithIdsInQueryExpression: (schema: Schema, queryExpression: Query) => {
|
|
52
|
+
"q/select"?: Expression | import("@fibery/expression-utils").Select;
|
|
53
|
+
"q/offset"?: number;
|
|
54
|
+
"q/order-by"?: any;
|
|
55
|
+
"q/limit"?: import("@fibery/expression-utils/src/types").QueryLimit;
|
|
56
|
+
"q/where"?: any;
|
|
57
|
+
"q/from": string;
|
|
58
|
+
};
|
|
59
|
+
declare const deleteExpressionWithNotFoundFieldsOrTypesInExpression: (schema: Schema, fromType: string, expression: Expression) => any;
|
|
60
|
+
declare const resetContextExpressionIfBroken: (schema: Schema, fromType: string, expression: Expression, defaultExpression: Expression) => any;
|
|
61
|
+
declare const isUnitExpressionValid: (unit: Record<string, unknown>) => boolean;
|
|
62
|
+
declare const getFieldObjectsById: (smartFolder: Record<string, unknown>, schema: Schema) => Record<string, FieldObject>;
|
|
63
|
+
declare const replaceIdsWithNamesInUnitGroupKey: (unitGroupKey: string, fieldObjectsById: Record<string, FieldObject>) => string;
|
|
64
|
+
declare const replaceNamesWithIdsInUnitGroupKey: (unitGroupKey: string, schema: Schema) => string;
|
|
65
|
+
//#endregion
|
|
66
|
+
export { REMOVE, UnitDefinitions, ViewFilter, ViewRecord, ViewVisitor, deleteExpressionWithNotFoundFieldsOrTypesInExpression, deleteExpressionWithNotFoundFieldsOrTypesInFilter, deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression, getFieldObjectsById, isUnitExpressionValid, replaceIdsWithNamesInExpression, replaceIdsWithNamesInFilter, replaceIdsWithNamesInQueryExpression, replaceIdsWithNamesInUnitGroupKey, replaceNamesWithIdsInExpression, replaceNamesWithIdsInFilter, replaceNamesWithIdsInQueryExpression, replaceNamesWithIdsInUnitGroupKey, resetContextExpressionIfBroken, skipRemove, visitContextExpression, visitViewUnit };
|