@airtable/blocks 0.0.0-experimental-f52bc4e5e-20250709 → 0.0.0-experimental-75d011284-20250904
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/dist/cjs/base/assert_run_context.js +12 -0
- package/dist/cjs/base/index.js +30 -30
- package/dist/cjs/base/models/abstract_model_with_async_data.js +154 -237
- package/dist/cjs/base/models/base.js +188 -267
- package/dist/cjs/base/models/create_aggregators.js +29 -46
- package/dist/cjs/base/models/cursor.js +206 -294
- package/dist/cjs/base/models/field.js +307 -395
- package/dist/cjs/base/models/grouped_record_query_result.js +219 -338
- package/dist/cjs/base/models/linked_records_query_result.js +450 -625
- package/dist/cjs/base/models/models.js +19 -22
- package/dist/cjs/base/models/mutations.js +267 -293
- package/dist/cjs/base/models/object_pool.js +117 -156
- package/dist/cjs/base/models/record.js +191 -256
- package/dist/cjs/base/models/record_coloring.js +6 -6
- package/dist/cjs/base/models/record_query_result.js +351 -435
- package/dist/cjs/base/models/record_store.js +403 -753
- package/dist/cjs/base/models/session.js +125 -153
- package/dist/cjs/base/models/table.js +457 -605
- package/dist/cjs/base/models/table_or_view_query_result.js +656 -920
- package/dist/cjs/base/models/view.js +284 -389
- package/dist/cjs/base/models/view_data_store.js +218 -356
- package/dist/cjs/base/models/view_metadata_query_result.js +109 -157
- package/dist/cjs/base/perform_record_action.js +89 -131
- package/dist/cjs/base/sdk.js +129 -184
- package/dist/cjs/base/settings_button.js +54 -74
- package/dist/cjs/base/types/airtable_interface.js +1 -1
- package/dist/cjs/base/types/mutations.js +5 -11
- package/dist/cjs/base/types/undo_redo.js +1 -1
- package/dist/cjs/base/types/view.js +1 -1
- package/dist/cjs/base/ui/base_provider.js +6 -8
- package/dist/cjs/base/ui/baymax_utils.js +436 -108
- package/dist/cjs/base/ui/block_wrapper.js +81 -106
- package/dist/cjs/base/ui/box.js +34 -60
- package/dist/cjs/base/ui/button.js +44 -74
- package/dist/cjs/base/ui/cell_renderer.js +132 -189
- package/dist/cjs/base/ui/choice_token.js +25 -42
- package/dist/cjs/base/ui/collaborator_token.js +31 -53
- package/dist/cjs/base/ui/color_palette.js +130 -173
- package/dist/cjs/base/ui/color_palette_synced.js +41 -70
- package/dist/cjs/base/ui/confirmation_dialog.js +70 -120
- package/dist/cjs/base/ui/control_sizes.js +24 -22
- package/dist/cjs/base/ui/create_detect_element_resize.js +6 -10
- package/dist/cjs/base/ui/css_helpers.js +1 -1
- package/dist/cjs/base/ui/dialog.js +57 -98
- package/dist/cjs/base/ui/dialog_close_button.js +52 -98
- package/dist/cjs/base/ui/expand_record.js +1 -2
- package/dist/cjs/base/ui/expand_record_list.js +3 -4
- package/dist/cjs/base/ui/expand_record_picker_async.js +28 -57
- package/dist/cjs/base/ui/field_icon.js +15 -33
- package/dist/cjs/base/ui/field_picker.js +25 -70
- package/dist/cjs/base/ui/field_picker_synced.js +18 -40
- package/dist/cjs/base/ui/form_field.js +27 -55
- package/dist/cjs/base/ui/geometry/geometry.js +5 -5
- package/dist/cjs/base/ui/geometry/point.js +10 -12
- package/dist/cjs/base/ui/geometry/rect.js +36 -52
- package/dist/cjs/base/ui/geometry/size.js +10 -12
- package/dist/cjs/base/ui/global_alert.js +31 -52
- package/dist/cjs/base/ui/heading.js +45 -94
- package/dist/cjs/base/ui/icon.js +39 -59
- package/dist/cjs/base/ui/icon_config.js +6 -12
- package/dist/cjs/base/ui/initialize_block.js +16 -35
- package/dist/cjs/base/ui/input.js +62 -101
- package/dist/cjs/base/ui/input_synced.js +17 -40
- package/dist/cjs/base/ui/key_codes.js +2 -3
- package/dist/cjs/base/ui/label.js +30 -55
- package/dist/cjs/base/ui/link.js +54 -87
- package/dist/cjs/base/ui/loader.js +15 -36
- package/dist/cjs/base/ui/modal.js +88 -127
- package/dist/cjs/base/ui/model_picker_select.js +18 -44
- package/dist/cjs/base/ui/popover.js +236 -328
- package/dist/cjs/base/ui/progress_bar.js +34 -47
- package/dist/cjs/base/ui/record_card.js +389 -478
- package/dist/cjs/base/ui/record_card_list.js +150 -224
- package/dist/cjs/base/ui/select.js +60 -116
- package/dist/cjs/base/ui/select_and_select_buttons_helpers.js +15 -39
- package/dist/cjs/base/ui/select_buttons.js +50 -83
- package/dist/cjs/base/ui/select_buttons_synced.js +17 -39
- package/dist/cjs/base/ui/select_synced.js +17 -39
- package/dist/cjs/base/ui/switch.js +42 -71
- package/dist/cjs/base/ui/switch_synced.js +16 -38
- package/dist/cjs/base/ui/synced.js +27 -48
- package/dist/cjs/base/ui/system/all_styles_set.js +4 -12
- package/dist/cjs/base/ui/system/appearance/appearance_set.js +10 -13
- package/dist/cjs/base/ui/system/appearance/background_color.js +3 -6
- package/dist/cjs/base/ui/system/appearance/border.js +3 -6
- package/dist/cjs/base/ui/system/appearance/border_radius.js +3 -6
- package/dist/cjs/base/ui/system/appearance/box_shadow.js +3 -6
- package/dist/cjs/base/ui/system/appearance/opacity.js +3 -6
- package/dist/cjs/base/ui/system/dimensions/dimensions_set.js +11 -13
- package/dist/cjs/base/ui/system/dimensions/height.js +3 -6
- package/dist/cjs/base/ui/system/dimensions/max_height.js +3 -6
- package/dist/cjs/base/ui/system/dimensions/max_width.js +3 -6
- package/dist/cjs/base/ui/system/dimensions/min_height.js +3 -6
- package/dist/cjs/base/ui/system/dimensions/min_width.js +3 -6
- package/dist/cjs/base/ui/system/dimensions/width.js +3 -6
- package/dist/cjs/base/ui/system/display.js +3 -6
- package/dist/cjs/base/ui/system/flex_container/align_content.js +3 -6
- package/dist/cjs/base/ui/system/flex_container/align_items.js +3 -6
- package/dist/cjs/base/ui/system/flex_container/flex_container_set.js +11 -13
- package/dist/cjs/base/ui/system/flex_container/flex_direction.js +3 -6
- package/dist/cjs/base/ui/system/flex_container/flex_wrap.js +3 -6
- package/dist/cjs/base/ui/system/flex_container/justify_content.js +3 -6
- package/dist/cjs/base/ui/system/flex_container/justify_items.js +3 -6
- package/dist/cjs/base/ui/system/flex_item/align_self.js +3 -6
- package/dist/cjs/base/ui/system/flex_item/flex.js +3 -6
- package/dist/cjs/base/ui/system/flex_item/flex_basis.js +3 -6
- package/dist/cjs/base/ui/system/flex_item/flex_grow.js +3 -6
- package/dist/cjs/base/ui/system/flex_item/flex_item_set.js +12 -13
- package/dist/cjs/base/ui/system/flex_item/flex_shrink.js +3 -6
- package/dist/cjs/base/ui/system/flex_item/justify_self.js +3 -6
- package/dist/cjs/base/ui/system/flex_item/order.js +3 -6
- package/dist/cjs/base/ui/system/index.js +104 -416
- package/dist/cjs/base/ui/system/overflow.js +3 -6
- package/dist/cjs/base/ui/system/position/bottom.js +4 -6
- package/dist/cjs/base/ui/system/position/left.js +4 -6
- package/dist/cjs/base/ui/system/position/position.js +3 -6
- package/dist/cjs/base/ui/system/position/position_set.js +11 -13
- package/dist/cjs/base/ui/system/position/right.js +4 -6
- package/dist/cjs/base/ui/system/position/top.js +4 -6
- package/dist/cjs/base/ui/system/position/z_index.js +3 -6
- package/dist/cjs/base/ui/system/spacing/margin.js +4 -6
- package/dist/cjs/base/ui/system/spacing/padding.js +4 -6
- package/dist/cjs/base/ui/system/spacing/spacing_set.js +7 -13
- package/dist/cjs/base/ui/system/typography/font_family.js +3 -6
- package/dist/cjs/base/ui/system/typography/font_size.js +3 -6
- package/dist/cjs/base/ui/system/typography/font_style.js +3 -6
- package/dist/cjs/base/ui/system/typography/font_weight.js +3 -6
- package/dist/cjs/base/ui/system/typography/letter_spacing.js +3 -6
- package/dist/cjs/base/ui/system/typography/line_height.js +3 -6
- package/dist/cjs/base/ui/system/typography/text_align.js +3 -6
- package/dist/cjs/base/ui/system/typography/text_color.js +3 -6
- package/dist/cjs/base/ui/system/typography/text_decoration.js +3 -6
- package/dist/cjs/base/ui/system/typography/text_transform.js +3 -6
- package/dist/cjs/base/ui/system/typography/typography_set.js +15 -13
- package/dist/cjs/base/ui/system/utils/ensure_numbers_are_within_scale.js +3 -4
- package/dist/cjs/base/ui/system/utils/get_style_props_for_responsive_prop.js +47 -87
- package/dist/cjs/base/ui/table_picker.js +18 -42
- package/dist/cjs/base/ui/table_picker_synced.js +17 -39
- package/dist/cjs/base/ui/text.js +40 -73
- package/dist/cjs/base/ui/text_button.js +51 -83
- package/dist/cjs/base/ui/theme/default_theme/button_variants.js +3 -3
- package/dist/cjs/base/ui/theme/default_theme/control_sizes.js +51 -45
- package/dist/cjs/base/ui/theme/default_theme/heading_styles.js +1 -1
- package/dist/cjs/base/ui/theme/default_theme/index.js +9 -15
- package/dist/cjs/base/ui/theme/default_theme/input_variants.js +3 -3
- package/dist/cjs/base/ui/theme/default_theme/link_variants.js +3 -3
- package/dist/cjs/base/ui/theme/default_theme/select_buttons_variants.js +4 -4
- package/dist/cjs/base/ui/theme/default_theme/select_variants.js +8 -17
- package/dist/cjs/base/ui/theme/default_theme/switch_variants.js +23 -29
- package/dist/cjs/base/ui/theme/default_theme/text_button_variants.js +5 -5
- package/dist/cjs/base/ui/theme/default_theme/text_styles.js +1 -1
- package/dist/cjs/base/ui/theme/default_theme/tokens.js +14 -14
- package/dist/cjs/base/ui/theme/theme_context.js +2 -2
- package/dist/cjs/base/ui/theme/use_theme.js +2 -2
- package/dist/cjs/base/ui/tooltip.js +134 -174
- package/dist/cjs/base/ui/types/aria_props.js +1 -23
- package/dist/cjs/base/ui/types/data_attributes_prop.js +1 -18
- package/dist/cjs/base/ui/types/tooltip_anchor_props.js +1 -17
- package/dist/cjs/base/ui/ui.js +48 -49
- package/dist/cjs/base/ui/unstable_standalone_ui.js +27 -27
- package/dist/cjs/base/ui/use_base.js +1 -1
- package/dist/cjs/base/ui/use_cursor.js +5 -4
- package/dist/cjs/base/ui/use_form_field.js +1 -1
- package/dist/cjs/base/ui/use_loadable.js +25 -91
- package/dist/cjs/base/ui/use_record_action_data.js +4 -3
- package/dist/cjs/base/ui/use_records.js +9 -13
- package/dist/cjs/base/ui/use_session.js +1 -1
- package/dist/cjs/base/ui/use_settings_button.js +4 -3
- package/dist/cjs/base/ui/use_styled_system.js +7 -14
- package/dist/cjs/base/ui/use_text_color_for_background_color.js +4 -3
- package/dist/cjs/base/ui/use_view_metadata.js +4 -4
- package/dist/cjs/base/ui/use_viewport.js +2 -2
- package/dist/cjs/base/ui/view_picker.js +26 -70
- package/dist/cjs/base/ui/view_picker_synced.js +18 -40
- package/dist/cjs/base/ui/viewport_constraint.js +67 -114
- package/dist/cjs/base/ui/with_styled_system.js +25 -61
- package/dist/cjs/base/undo_redo.js +21 -32
- package/dist/cjs/base/unstable_testing_utils.js +27 -27
- package/dist/cjs/base/viewport.js +268 -312
- package/dist/cjs/injected/airtable_interface.js +4 -4
- package/dist/cjs/interface/assert_run_context.js +12 -0
- package/dist/cjs/interface/index.js +4 -18
- package/dist/cjs/interface/models/base.js +15 -34
- package/dist/cjs/interface/models/field.js +5 -19
- package/dist/cjs/interface/models/models.js +8 -7
- package/dist/cjs/interface/models/mutations.js +50 -66
- package/dist/cjs/interface/models/record.js +29 -49
- package/dist/cjs/interface/models/record_store.js +25 -57
- package/dist/cjs/interface/models/session.js +2 -16
- package/dist/cjs/interface/models/table.js +66 -95
- package/dist/cjs/interface/sdk.js +61 -87
- package/dist/cjs/interface/types/airtable_interface.js +2 -2
- package/dist/cjs/interface/types/mutations.js +3 -10
- package/dist/cjs/interface/ui/block_wrapper.js +56 -48
- package/dist/cjs/interface/ui/initialize_block.js +13 -28
- package/dist/cjs/interface/ui/ui.js +20 -19
- package/dist/cjs/interface/ui/use_base.js +1 -1
- package/dist/cjs/interface/ui/use_custom_properties.js +19 -35
- package/dist/cjs/interface/ui/use_records.js +6 -5
- package/dist/cjs/interface/ui/use_run_info.js +2 -2
- package/dist/cjs/interface/ui/use_session.js +1 -1
- package/dist/cjs/shared/color_utils.js +9 -16
- package/dist/cjs/shared/colors.js +2 -2
- package/dist/cjs/shared/error_utils.js +9 -11
- package/dist/cjs/shared/event_tracker.js +3 -3
- package/dist/cjs/shared/global_config.js +337 -449
- package/dist/cjs/shared/models/abstract_model.js +72 -97
- package/dist/cjs/shared/models/base_core.js +394 -514
- package/dist/cjs/shared/models/field_core.js +236 -279
- package/dist/cjs/shared/models/mutations_core.js +283 -379
- package/dist/cjs/shared/models/record_core.js +174 -231
- package/dist/cjs/shared/models/record_store_core.js +119 -172
- package/dist/cjs/shared/models/session_core.js +116 -170
- package/dist/cjs/shared/models/table_core.js +1258 -1501
- package/dist/cjs/shared/private_utils.js +54 -124
- package/dist/cjs/shared/sdk_core.js +68 -70
- package/dist/cjs/shared/types/field_core.js +1 -1
- package/dist/cjs/shared/types/mutation_constants.js +4 -4
- package/dist/cjs/shared/types/mutations_core.js +1 -1
- package/dist/cjs/shared/types/permission_levels.js +1 -1
- package/dist/cjs/shared/ui/global_config_synced_component_helpers.js +9 -9
- package/dist/cjs/shared/ui/loader.js +14 -35
- package/dist/cjs/shared/ui/remote_utils.js +5 -7
- package/dist/cjs/shared/ui/sdk_context.js +4 -8
- package/dist/cjs/shared/ui/use_array_identity.js +2 -2
- package/dist/cjs/shared/ui/use_base.js +6 -5
- package/dist/cjs/shared/ui/use_color_scheme.js +3 -8
- package/dist/cjs/shared/ui/use_global_config.js +5 -4
- package/dist/cjs/shared/ui/use_session.js +6 -5
- package/dist/cjs/shared/ui/use_synced.js +7 -5
- package/dist/cjs/shared/ui/use_watchable.js +13 -42
- package/dist/cjs/shared/ui/with_hooks.js +6 -13
- package/dist/cjs/shared/unstable_private_utils.js +4 -6
- package/dist/cjs/shared/warning.js +5 -5
- package/dist/cjs/shared/watchable.js +110 -176
- package/dist/cjs/stats/block_stats.js +62 -85
- package/dist/cjs/testing/base/abstract_mock_airtable_interface.js +208 -0
- package/dist/cjs/testing/interface/abstract_mock_airtable_interface.js +124 -0
- package/dist/types/src/base/assert_run_context.d.ts +2 -0
- package/dist/types/src/base/assert_run_context.d.ts.map +1 -0
- package/dist/types/src/base/index.d.ts +1 -0
- package/dist/types/src/base/index.d.ts.map +1 -1
- package/dist/types/src/base/models/models.d.ts +1 -0
- package/dist/types/src/base/models/models.d.ts.map +1 -1
- package/dist/types/src/base/models/mutations.d.ts.map +1 -1
- package/dist/types/src/base/sdk.d.ts.map +1 -1
- package/dist/types/src/base/ui/block_wrapper.d.ts +1 -1
- package/dist/types/src/base/ui/box.d.ts.map +1 -1
- package/dist/types/src/base/ui/button.d.ts +0 -5
- package/dist/types/src/base/ui/button.d.ts.map +1 -1
- package/dist/types/src/base/ui/cell_renderer.d.ts +1 -22
- package/dist/types/src/base/ui/cell_renderer.d.ts.map +1 -1
- package/dist/types/src/base/ui/choice_token.d.ts +1 -21
- package/dist/types/src/base/ui/choice_token.d.ts.map +1 -1
- package/dist/types/src/base/ui/collaborator_token.d.ts +0 -20
- package/dist/types/src/base/ui/collaborator_token.d.ts.map +1 -1
- package/dist/types/src/base/ui/color_palette.d.ts +1 -32
- package/dist/types/src/base/ui/color_palette.d.ts.map +1 -1
- package/dist/types/src/base/ui/color_palette_synced.d.ts +0 -14
- package/dist/types/src/base/ui/color_palette_synced.d.ts.map +1 -1
- package/dist/types/src/base/ui/confirmation_dialog.d.ts +0 -17
- package/dist/types/src/base/ui/confirmation_dialog.d.ts.map +1 -1
- package/dist/types/src/base/ui/control_sizes.d.ts +0 -1
- package/dist/types/src/base/ui/control_sizes.d.ts.map +1 -1
- package/dist/types/src/base/ui/dialog.d.ts +1 -23
- package/dist/types/src/base/ui/dialog.d.ts.map +1 -1
- package/dist/types/src/base/ui/dialog_close_button.d.ts +2 -24
- package/dist/types/src/base/ui/dialog_close_button.d.ts.map +1 -1
- package/dist/types/src/base/ui/field_icon.d.ts +1 -17
- package/dist/types/src/base/ui/field_icon.d.ts.map +1 -1
- package/dist/types/src/base/ui/field_picker.d.ts +0 -23
- package/dist/types/src/base/ui/field_picker.d.ts.map +1 -1
- package/dist/types/src/base/ui/field_picker_synced.d.ts.map +1 -1
- package/dist/types/src/base/ui/form_field.d.ts +0 -4
- package/dist/types/src/base/ui/form_field.d.ts.map +1 -1
- package/dist/types/src/base/ui/heading.d.ts +1 -1
- package/dist/types/src/base/ui/heading.d.ts.map +1 -1
- package/dist/types/src/base/ui/icon.d.ts +0 -16
- package/dist/types/src/base/ui/icon.d.ts.map +1 -1
- package/dist/types/src/base/ui/icon_config.d.ts +50 -51
- package/dist/types/src/base/ui/icon_config.d.ts.map +1 -1
- package/dist/types/src/base/ui/initialize_block.d.ts.map +1 -1
- package/dist/types/src/base/ui/input.d.ts +12 -46
- package/dist/types/src/base/ui/input.d.ts.map +1 -1
- package/dist/types/src/base/ui/input_synced.d.ts.map +1 -1
- package/dist/types/src/base/ui/label.d.ts.map +1 -1
- package/dist/types/src/base/ui/link.d.ts +1 -5
- package/dist/types/src/base/ui/link.d.ts.map +1 -1
- package/dist/types/src/base/ui/loader.d.ts +3 -20
- package/dist/types/src/base/ui/loader.d.ts.map +1 -1
- package/dist/types/src/base/ui/modal.d.ts +1 -14
- package/dist/types/src/base/ui/modal.d.ts.map +1 -1
- package/dist/types/src/base/ui/model_picker_select.d.ts.map +1 -1
- package/dist/types/src/base/ui/popover.d.ts +1 -17
- package/dist/types/src/base/ui/popover.d.ts.map +1 -1
- package/dist/types/src/base/ui/progress_bar.d.ts +1 -24
- package/dist/types/src/base/ui/progress_bar.d.ts.map +1 -1
- package/dist/types/src/base/ui/record_card.d.ts +1 -23
- package/dist/types/src/base/ui/record_card.d.ts.map +1 -1
- package/dist/types/src/base/ui/record_card_list.d.ts +1 -18
- package/dist/types/src/base/ui/record_card_list.d.ts.map +1 -1
- package/dist/types/src/base/ui/select.d.ts +0 -44
- package/dist/types/src/base/ui/select.d.ts.map +1 -1
- package/dist/types/src/base/ui/select_and_select_buttons_helpers.d.ts +0 -2
- package/dist/types/src/base/ui/select_and_select_buttons_helpers.d.ts.map +1 -1
- package/dist/types/src/base/ui/select_buttons.d.ts +0 -22
- package/dist/types/src/base/ui/select_buttons.d.ts.map +1 -1
- package/dist/types/src/base/ui/select_buttons_synced.d.ts.map +1 -1
- package/dist/types/src/base/ui/select_synced.d.ts.map +1 -1
- package/dist/types/src/base/ui/switch.d.ts +0 -22
- package/dist/types/src/base/ui/switch.d.ts.map +1 -1
- package/dist/types/src/base/ui/switch_synced.d.ts.map +1 -1
- package/dist/types/src/base/ui/synced.d.ts +2 -8
- package/dist/types/src/base/ui/synced.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/all_styles_set.d.ts +0 -3
- package/dist/types/src/base/ui/system/all_styles_set.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/appearance/appearance_set.d.ts +0 -1
- package/dist/types/src/base/ui/system/appearance/appearance_set.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/appearance/background_color.d.ts +0 -1
- package/dist/types/src/base/ui/system/appearance/background_color.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/appearance/border.d.ts +0 -1
- package/dist/types/src/base/ui/system/appearance/border.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/appearance/border_radius.d.ts +0 -1
- package/dist/types/src/base/ui/system/appearance/border_radius.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/appearance/box_shadow.d.ts +0 -1
- package/dist/types/src/base/ui/system/appearance/box_shadow.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/appearance/opacity.d.ts +0 -1
- package/dist/types/src/base/ui/system/appearance/opacity.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/dimensions/dimensions_set.d.ts +0 -1
- package/dist/types/src/base/ui/system/dimensions/dimensions_set.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/dimensions/height.d.ts +0 -1
- package/dist/types/src/base/ui/system/dimensions/height.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/dimensions/max_height.d.ts +0 -1
- package/dist/types/src/base/ui/system/dimensions/max_height.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/dimensions/max_width.d.ts +0 -1
- package/dist/types/src/base/ui/system/dimensions/max_width.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/dimensions/min_height.d.ts +0 -1
- package/dist/types/src/base/ui/system/dimensions/min_height.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/dimensions/min_width.d.ts +0 -1
- package/dist/types/src/base/ui/system/dimensions/min_width.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/dimensions/width.d.ts +0 -1
- package/dist/types/src/base/ui/system/dimensions/width.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/display.d.ts +0 -1
- package/dist/types/src/base/ui/system/display.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_container/align_content.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_container/align_content.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_container/align_items.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_container/align_items.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_container/flex_container_set.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_container/flex_container_set.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_container/flex_direction.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_container/flex_direction.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_container/flex_wrap.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_container/flex_wrap.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_container/justify_content.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_container/justify_content.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_container/justify_items.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_container/justify_items.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_item/align_self.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_item/align_self.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_item/flex.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_item/flex.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_item/flex_basis.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_item/flex_basis.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_item/flex_grow.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_item/flex_grow.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_item/flex_item_set.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_item/flex_item_set.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_item/flex_shrink.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_item/flex_shrink.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_item/justify_self.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_item/justify_self.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/flex_item/order.d.ts +0 -1
- package/dist/types/src/base/ui/system/flex_item/order.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/index.d.ts +52 -52
- package/dist/types/src/base/ui/system/index.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/overflow.d.ts +0 -1
- package/dist/types/src/base/ui/system/overflow.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/position/bottom.d.ts +0 -1
- package/dist/types/src/base/ui/system/position/bottom.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/position/left.d.ts +0 -1
- package/dist/types/src/base/ui/system/position/left.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/position/position.d.ts +0 -1
- package/dist/types/src/base/ui/system/position/position.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/position/position_set.d.ts +0 -1
- package/dist/types/src/base/ui/system/position/position_set.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/position/right.d.ts +0 -1
- package/dist/types/src/base/ui/system/position/right.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/position/top.d.ts +0 -1
- package/dist/types/src/base/ui/system/position/top.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/position/z_index.d.ts +0 -1
- package/dist/types/src/base/ui/system/position/z_index.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/spacing/margin.d.ts +0 -1
- package/dist/types/src/base/ui/system/spacing/margin.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/spacing/padding.d.ts +0 -1
- package/dist/types/src/base/ui/system/spacing/padding.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/spacing/spacing_set.d.ts +0 -1
- package/dist/types/src/base/ui/system/spacing/spacing_set.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/typography/font_family.d.ts +0 -1
- package/dist/types/src/base/ui/system/typography/font_family.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/typography/font_size.d.ts +0 -1
- package/dist/types/src/base/ui/system/typography/font_size.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/typography/font_style.d.ts +0 -1
- package/dist/types/src/base/ui/system/typography/font_style.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/typography/font_weight.d.ts +0 -1
- package/dist/types/src/base/ui/system/typography/font_weight.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/typography/letter_spacing.d.ts +0 -1
- package/dist/types/src/base/ui/system/typography/letter_spacing.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/typography/line_height.d.ts +0 -1
- package/dist/types/src/base/ui/system/typography/line_height.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/typography/text_align.d.ts +0 -1
- package/dist/types/src/base/ui/system/typography/text_align.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/typography/text_color.d.ts +0 -1
- package/dist/types/src/base/ui/system/typography/text_color.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/typography/text_decoration.d.ts +0 -1
- package/dist/types/src/base/ui/system/typography/text_decoration.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/typography/text_transform.d.ts +0 -1
- package/dist/types/src/base/ui/system/typography/text_transform.d.ts.map +1 -1
- package/dist/types/src/base/ui/system/typography/typography_set.d.ts +0 -1
- package/dist/types/src/base/ui/system/typography/typography_set.d.ts.map +1 -1
- package/dist/types/src/base/ui/table_picker.d.ts +0 -21
- package/dist/types/src/base/ui/table_picker.d.ts.map +1 -1
- package/dist/types/src/base/ui/table_picker_synced.d.ts.map +1 -1
- package/dist/types/src/base/ui/text.d.ts +0 -3
- package/dist/types/src/base/ui/text.d.ts.map +1 -1
- package/dist/types/src/base/ui/text_button.d.ts +1 -5
- package/dist/types/src/base/ui/text_button.d.ts.map +1 -1
- package/dist/types/src/base/ui/theme/default_theme/index.d.ts +1 -1
- package/dist/types/src/base/ui/theme/theme_context.d.ts +1 -1
- package/dist/types/src/base/ui/theme/use_theme.d.ts +1 -1
- package/dist/types/src/base/ui/tooltip.d.ts +0 -16
- package/dist/types/src/base/ui/tooltip.d.ts.map +1 -1
- package/dist/types/src/base/ui/types/aria_props.d.ts.map +1 -1
- package/dist/types/src/base/ui/types/data_attributes_prop.d.ts +0 -4
- package/dist/types/src/base/ui/types/data_attributes_prop.d.ts.map +1 -1
- package/dist/types/src/base/ui/types/tooltip_anchor_props.d.ts +0 -7
- package/dist/types/src/base/ui/types/tooltip_anchor_props.d.ts.map +1 -1
- package/dist/types/src/base/ui/ui.d.ts +1 -0
- package/dist/types/src/base/ui/ui.d.ts.map +1 -1
- package/dist/types/src/base/ui/view_picker.d.ts +0 -23
- package/dist/types/src/base/ui/view_picker.d.ts.map +1 -1
- package/dist/types/src/base/ui/view_picker_synced.d.ts.map +1 -1
- package/dist/types/src/base/ui/viewport_constraint.d.ts +1 -14
- package/dist/types/src/base/ui/viewport_constraint.d.ts.map +1 -1
- package/dist/types/src/base/unstable_testing_utils.d.ts +1 -1
- package/dist/types/src/base/unstable_testing_utils.d.ts.map +1 -1
- package/dist/types/src/interface/assert_run_context.d.ts +2 -0
- package/dist/types/src/interface/assert_run_context.d.ts.map +1 -0
- package/dist/types/src/interface/index.d.ts +1 -6
- package/dist/types/src/interface/index.d.ts.map +1 -1
- package/dist/types/src/interface/models/models.d.ts +1 -0
- package/dist/types/src/interface/models/models.d.ts.map +1 -1
- package/dist/types/src/interface/models/mutations.d.ts.map +1 -1
- package/dist/types/src/interface/ui/initialize_block.d.ts.map +1 -1
- package/dist/types/src/interface/ui/ui.d.ts +1 -0
- package/dist/types/src/interface/ui/ui.d.ts.map +1 -1
- package/dist/types/src/interface/ui/use_custom_properties.d.ts +1 -1
- package/dist/types/src/shared/models/mutations_core.d.ts.map +1 -1
- package/dist/types/src/shared/private_utils.d.ts +0 -9
- package/dist/types/src/shared/private_utils.d.ts.map +1 -1
- package/dist/types/src/shared/ui/global_config_synced_component_helpers.d.ts +0 -2
- package/dist/types/src/shared/ui/global_config_synced_component_helpers.d.ts.map +1 -1
- package/dist/types/src/shared/ui/loader.d.ts.map +1 -1
- package/dist/types/src/shared/ui/with_hooks.d.ts +2 -2
- package/dist/types/src/shared/ui/with_hooks.d.ts.map +1 -1
- package/dist/types/src/testing/{abstract_mock_airtable_interface.d.ts → base/abstract_mock_airtable_interface.d.ts} +13 -13
- package/dist/types/src/testing/base/abstract_mock_airtable_interface.d.ts.map +1 -0
- package/dist/types/src/testing/interface/abstract_mock_airtable_interface.d.ts +51 -0
- package/dist/types/src/testing/interface/abstract_mock_airtable_interface.d.ts.map +1 -0
- package/package.json +13 -13
- package/dist/cjs/base/ui/system/utils/create_responsive_prop_type.js +0 -19
- package/dist/cjs/base/ui/system/utils/create_style_prop_types.js +0 -24
- package/dist/cjs/base/ui/system/utils/enum_prop_type_utils.js +0 -35
- package/dist/cjs/testing/abstract_mock_airtable_interface.js +0 -277
- package/dist/types/src/base/ui/system/utils/create_responsive_prop_type.d.ts +0 -2
- package/dist/types/src/base/ui/system/utils/create_responsive_prop_type.d.ts.map +0 -1
- package/dist/types/src/base/ui/system/utils/create_style_prop_types.d.ts +0 -4
- package/dist/types/src/base/ui/system/utils/create_style_prop_types.d.ts.map +0 -1
- package/dist/types/src/base/ui/system/utils/enum_prop_type_utils.d.ts +0 -21
- package/dist/types/src/base/ui/system/utils/enum_prop_type_utils.d.ts.map +0 -1
- package/dist/types/src/testing/abstract_mock_airtable_interface.d.ts.map +0 -1
|
@@ -1,32 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.symbol.js");
|
|
4
|
-
require("core-js/modules/es.symbol.description.js");
|
|
5
|
-
require("core-js/modules/es.array.from.js");
|
|
6
|
-
require("core-js/modules/es.array.iterator.js");
|
|
7
|
-
require("core-js/modules/es.array.slice.js");
|
|
8
|
-
require("core-js/modules/es.object.to-string.js");
|
|
9
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
10
|
-
require("core-js/modules/es.regexp.to-string.js");
|
|
11
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
12
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
13
3
|
Object.defineProperty(exports, "__esModule", {
|
|
14
4
|
value: true
|
|
15
5
|
});
|
|
16
6
|
exports.default = void 0;
|
|
17
7
|
exports.normalizeSortsOrGroups = normalizeSortsOrGroups;
|
|
18
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
19
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
20
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
21
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
22
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
23
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
24
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
25
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
26
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
27
|
-
require("core-js/modules/es.array.concat.js");
|
|
28
|
-
require("core-js/modules/es.array.map.js");
|
|
29
|
-
require("core-js/modules/es.string.starts-with.js");
|
|
30
8
|
var _colors = _interopRequireDefault(require("../../shared/colors"));
|
|
31
9
|
var _field_core = require("../../shared/types/field_core");
|
|
32
10
|
var _private_utils = require("../../shared/private_utils");
|
|
@@ -34,12 +12,10 @@ var _error_utils = require("../../shared/error_utils");
|
|
|
34
12
|
var _abstract_model_with_async_data = _interopRequireDefault(require("./abstract_model_with_async_data"));
|
|
35
13
|
var _field = _interopRequireDefault(require("./field"));
|
|
36
14
|
var _record_coloring = require("./record_coloring");
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /** @module @airtable/blocks/models: RecordQueryResult */ /** */
|
|
42
|
-
var WatchableRecordQueryResultKeys = Object.freeze({
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
/** @module @airtable/blocks/models: RecordQueryResult */ /** */
|
|
17
|
+
|
|
18
|
+
const WatchableRecordQueryResultKeys = Object.freeze({
|
|
43
19
|
records: 'records',
|
|
44
20
|
recordIds: 'recordIds',
|
|
45
21
|
cellValues: 'cellValues',
|
|
@@ -48,7 +24,7 @@ var WatchableRecordQueryResultKeys = Object.freeze({
|
|
|
48
24
|
groupLevels: 'groupLevels',
|
|
49
25
|
isDataLoaded: 'isDataLoaded'
|
|
50
26
|
});
|
|
51
|
-
|
|
27
|
+
const WatchableCellValuesInFieldKeyPrefix = 'cellValuesInField:';
|
|
52
28
|
|
|
53
29
|
// The string case is to accommodate cellValuesInField:$FieldId.
|
|
54
30
|
/**
|
|
@@ -222,14 +198,13 @@ var WatchableCellValuesInFieldKeyPrefix = 'cellValuesInField:';
|
|
|
222
198
|
* @internal
|
|
223
199
|
*/
|
|
224
200
|
function _normalizeSortOrGroup(table, sortOrGroup) {
|
|
225
|
-
|
|
226
|
-
var field = table.__getFieldMatching(sortOrGroup.field);
|
|
201
|
+
const field = table.__getFieldMatching(sortOrGroup.field);
|
|
227
202
|
if (sortOrGroup.direction !== undefined && sortOrGroup.direction !== 'asc' && sortOrGroup.direction !== 'desc') {
|
|
228
203
|
throw (0, _error_utils.spawnError)('Invalid sort direction: %s', sortOrGroup.direction);
|
|
229
204
|
}
|
|
230
205
|
return {
|
|
231
206
|
fieldId: field.id,
|
|
232
|
-
direction:
|
|
207
|
+
direction: sortOrGroup.direction ?? 'asc'
|
|
233
208
|
};
|
|
234
209
|
}
|
|
235
210
|
|
|
@@ -291,451 +266,392 @@ function normalizeSortsOrGroups(table, sortsOrGroups) {
|
|
|
291
266
|
*
|
|
292
267
|
* @docsPath models/query results/RecordQueryResult
|
|
293
268
|
*/
|
|
294
|
-
|
|
269
|
+
class RecordQueryResult extends _abstract_model_with_async_data.default {
|
|
270
|
+
// Abstract properties - classes extending QueryResult must override these:
|
|
271
|
+
/** @internal */
|
|
272
|
+
static _className = 'RecordQueryResult';
|
|
273
|
+
|
|
295
274
|
/**
|
|
296
|
-
*
|
|
275
|
+
* The record IDs in this QueryResult.
|
|
276
|
+
* Throws if data is not loaded yet.
|
|
277
|
+
* Can be watched.
|
|
297
278
|
*/
|
|
298
|
-
function RecordQueryResult(sdk, normalizedOpts) {
|
|
299
|
-
var _this;
|
|
300
|
-
(0, _classCallCheck2.default)(this, RecordQueryResult);
|
|
301
|
-
_this = _callSuper(this, RecordQueryResult, [sdk, (0, _private_utils.getLocallyUniqueId)('RecordQueryResult')]);
|
|
302
|
-
/** @internal */
|
|
303
|
-
(0, _defineProperty2.default)(_this, "_normalizedOpts", void 0);
|
|
304
|
-
/** @internal */
|
|
305
|
-
(0, _defineProperty2.default)(_this, "_recordStore", void 0);
|
|
306
|
-
/** @internal */
|
|
307
|
-
(0, _defineProperty2.default)(_this, "_recordColorChangeHandler", null);
|
|
308
|
-
_this._normalizedOpts = normalizedOpts;
|
|
309
|
-
_this._recordStore = normalizedOpts.recordStore;
|
|
310
|
-
return _this;
|
|
311
|
-
}
|
|
312
279
|
|
|
313
280
|
/**
|
|
281
|
+
* The set of record IDs in this QueryResult.
|
|
282
|
+
* Throws if data is not loaded yet.
|
|
283
|
+
*
|
|
314
284
|
* @internal
|
|
315
285
|
*/
|
|
316
|
-
(0, _inherits2.default)(RecordQueryResult, _AbstractModelWithAsy);
|
|
317
|
-
return (0, _createClass2.default)(RecordQueryResult, [{
|
|
318
|
-
key: "_serializedOpts",
|
|
319
|
-
get: function get() {
|
|
320
|
-
return JSON.stringify([this._normalizedOpts.sorts, this._normalizedOpts.fieldIdsOrNullIfAllFields, this._normalizedOpts.table.id, (0, _record_coloring.serialize)(this._normalizedOpts.recordColorMode)]);
|
|
321
|
-
}
|
|
322
286
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
}, {
|
|
329
|
-
key: "records",
|
|
330
|
-
get: function get() {
|
|
331
|
-
return this.recordIds.map(recordId => {
|
|
332
|
-
var record = this._recordStore.getRecordByIdIfExists(recordId);
|
|
333
|
-
(0, _error_utils.invariant)(record, 'Record missing in table');
|
|
334
|
-
return record;
|
|
335
|
-
});
|
|
336
|
-
}
|
|
287
|
+
/**
|
|
288
|
+
* The fields that were used to create this QueryResult.
|
|
289
|
+
* Null if fields were not specified, which means the QueryResult
|
|
290
|
+
* will load all fields in the table.
|
|
291
|
+
*/
|
|
337
292
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
293
|
+
/**
|
|
294
|
+
* @internal (since we may not be able to return parent model instances in the immutable models world)
|
|
295
|
+
* The table that records in this QueryResult are part of
|
|
296
|
+
*/
|
|
297
|
+
|
|
298
|
+
// provided properties + methods:
|
|
299
|
+
/** @internal */
|
|
300
|
+
static WatchableKeys = WatchableRecordQueryResultKeys;
|
|
301
|
+
/** @internal */
|
|
302
|
+
static WatchableCellValuesInFieldKeyPrefix = WatchableCellValuesInFieldKeyPrefix;
|
|
303
|
+
/** @internal */
|
|
304
|
+
static _isWatchableKey(key) {
|
|
305
|
+
return (0, _private_utils.isEnumValue)(WatchableRecordQueryResultKeys, key) || key.startsWith(WatchableCellValuesInFieldKeyPrefix);
|
|
306
|
+
}
|
|
307
|
+
/** @internal */
|
|
308
|
+
static _shouldLoadDataForKey(key) {
|
|
309
|
+
return key === RecordQueryResult.WatchableKeys.records || key === RecordQueryResult.WatchableKeys.recordIds || key === RecordQueryResult.WatchableKeys.cellValues || key === RecordQueryResult.WatchableKeys.recordColors || key === RecordQueryResult.WatchableKeys.groups || key === RecordQueryResult.WatchableKeys.groupLevels || key.startsWith(RecordQueryResult.WatchableCellValuesInFieldKeyPrefix);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** @internal */
|
|
313
|
+
static _normalizeOpts(table, recordStore, opts) {
|
|
314
|
+
const sorts = normalizeSortsOrGroups(table, opts.sorts) ?? null;
|
|
315
|
+
let fieldIdsOrNullIfAllFields = null;
|
|
316
|
+
if (opts.fields) {
|
|
317
|
+
(0, _error_utils.invariant)(Array.isArray(opts.fields), 'Must specify an array of fields');
|
|
318
|
+
fieldIdsOrNullIfAllFields = [];
|
|
319
|
+
for (const fieldOrFieldIdOrFieldName of opts.fields) {
|
|
320
|
+
if (!fieldOrFieldIdOrFieldName) {
|
|
321
|
+
// Filter out false-y values so users of this API
|
|
322
|
+
// can conveniently list conditional fields, e.g. [field1, isFoo && field2]
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
if (typeof fieldOrFieldIdOrFieldName !== 'string' && !(fieldOrFieldIdOrFieldName instanceof _field.default)) {
|
|
326
|
+
throw (0, _error_utils.spawnError)('Invalid value for field, expected a field, id, or name but got: %s', fieldOrFieldIdOrFieldName);
|
|
327
|
+
}
|
|
328
|
+
const field = table.__getFieldMatching(fieldOrFieldIdOrFieldName);
|
|
329
|
+
fieldIdsOrNullIfAllFields.push(field.id);
|
|
350
330
|
}
|
|
351
|
-
return record;
|
|
352
331
|
}
|
|
332
|
+
const recordColorMode = opts.recordColorMode || _record_coloring.modes.none();
|
|
333
|
+
switch (recordColorMode.type) {
|
|
334
|
+
case _record_coloring.ModeTypes.NONE:
|
|
335
|
+
break;
|
|
336
|
+
case _record_coloring.ModeTypes.BY_SELECT_FIELD:
|
|
337
|
+
(0, _error_utils.invariant)(recordColorMode.selectField.type === _field_core.FieldType.SINGLE_SELECT, 'Invalid field for coloring records by select field: expected a %s, but got a %s', _field_core.FieldType.SINGLE_SELECT, recordColorMode.selectField.type);
|
|
338
|
+
(0, _error_utils.invariant)(recordColorMode.selectField.parentTable === table, 'Invalid field for coloring records by select field: the single select field is not in the same table as the records');
|
|
339
|
+
if (fieldIdsOrNullIfAllFields) {
|
|
340
|
+
fieldIdsOrNullIfAllFields.push(recordColorMode.selectField.id);
|
|
341
|
+
}
|
|
342
|
+
break;
|
|
343
|
+
case _record_coloring.ModeTypes.BY_VIEW:
|
|
344
|
+
(0, _error_utils.invariant)(recordColorMode.view.parentTable === table, 'Invalid view for coloring records from view: the view is not in the same table as the records');
|
|
345
|
+
break;
|
|
346
|
+
default:
|
|
347
|
+
throw (0, _error_utils.spawnError)('Unknown record coloring mode type: %s', (0, _private_utils.cast)(recordColorMode).type);
|
|
348
|
+
}
|
|
349
|
+
(0, _error_utils.invariant)(table.id === recordStore.tableId, 'record store and table must match');
|
|
350
|
+
return {
|
|
351
|
+
sorts,
|
|
352
|
+
fieldIdsOrNullIfAllFields,
|
|
353
|
+
recordColorMode,
|
|
354
|
+
table,
|
|
355
|
+
recordStore
|
|
356
|
+
};
|
|
357
|
+
}
|
|
353
358
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
359
|
+
/** @internal */
|
|
360
|
+
|
|
361
|
+
/** @internal */
|
|
362
|
+
|
|
363
|
+
/** @internal */
|
|
364
|
+
_recordColorChangeHandler = null;
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* @internal
|
|
368
|
+
*/
|
|
369
|
+
constructor(sdk, normalizedOpts) {
|
|
370
|
+
super(sdk, (0, _private_utils.getLocallyUniqueId)('RecordQueryResult'));
|
|
371
|
+
this._normalizedOpts = normalizedOpts;
|
|
372
|
+
this._recordStore = normalizedOpts.recordStore;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* @internal
|
|
377
|
+
*/
|
|
378
|
+
get _serializedOpts() {
|
|
379
|
+
return JSON.stringify([this._normalizedOpts.sorts, this._normalizedOpts.fieldIdsOrNullIfAllFields, this._normalizedOpts.table.id, (0, _record_coloring.serialize)(this._normalizedOpts.recordColorMode)]);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* The records in this RecordQueryResult.
|
|
384
|
+
* Throws if data is not loaded yet.
|
|
385
|
+
* Can be watched.
|
|
386
|
+
*/
|
|
387
|
+
get records() {
|
|
388
|
+
return this.recordIds.map(recordId => {
|
|
389
|
+
const record = this._recordStore.getRecordByIdIfExists(recordId);
|
|
390
|
+
(0, _error_utils.invariant)(record, 'Record missing in table');
|
|
367
391
|
return record;
|
|
368
|
-
}
|
|
392
|
+
});
|
|
393
|
+
}
|
|
369
394
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
395
|
+
/**
|
|
396
|
+
* Get a specific record in the query result, or null if that record doesn't exist or is
|
|
397
|
+
* filtered out. Throws if data is not loaded yet. Watch using `'recordIds'`.
|
|
398
|
+
*
|
|
399
|
+
* @param recordId the ID of the {@link Record} you want
|
|
400
|
+
*/
|
|
401
|
+
getRecordByIdIfExists(recordId) {
|
|
402
|
+
const record = this._recordStore.getRecordByIdIfExists(recordId);
|
|
403
|
+
if (!record || !this.hasRecord(record)) {
|
|
404
|
+
return null;
|
|
377
405
|
}
|
|
406
|
+
return record;
|
|
407
|
+
}
|
|
378
408
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
return this._getOrGenerateRecordIdsSet()[recordId] === true;
|
|
409
|
+
/**
|
|
410
|
+
* Get a specific record in the query result, or throws if that record doesn't exist or is
|
|
411
|
+
* filtered out. Throws if data is not loaded yet. Watch using `'recordIds'`.
|
|
412
|
+
*
|
|
413
|
+
* @param recordId the ID of the {@link Record} you want
|
|
414
|
+
*/
|
|
415
|
+
getRecordById(recordId) {
|
|
416
|
+
const record = this.getRecordByIdIfExists(recordId);
|
|
417
|
+
if (!record) {
|
|
418
|
+
throw (0, _error_utils.spawnError)('No record with ID %s in this query result', recordId);
|
|
390
419
|
}
|
|
420
|
+
return record;
|
|
421
|
+
}
|
|
391
422
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
*/
|
|
399
|
-
}, {
|
|
400
|
-
key: "getRecordColor",
|
|
401
|
-
value: function getRecordColor(recordOrRecordId) {
|
|
402
|
-
var record = this._getRecord(recordOrRecordId);
|
|
403
|
-
var recordColorMode = this._normalizedOpts.recordColorMode;
|
|
404
|
-
switch (recordColorMode.type) {
|
|
405
|
-
case _record_coloring.ModeTypes.NONE:
|
|
406
|
-
return null;
|
|
407
|
-
case _record_coloring.ModeTypes.BY_SELECT_FIELD:
|
|
408
|
-
{
|
|
409
|
-
if (recordColorMode.selectField.type !== _field_core.FieldType.SINGLE_SELECT) {
|
|
410
|
-
return null;
|
|
411
|
-
}
|
|
412
|
-
var value = record.getCellValue(recordColorMode.selectField);
|
|
413
|
-
return value && typeof value === 'object' && typeof value.color === 'string' ? (0, _private_utils.assertEnumValue)(_colors.default, value.color) : null;
|
|
414
|
-
}
|
|
415
|
-
case _record_coloring.ModeTypes.BY_VIEW:
|
|
416
|
-
return this._recordStore.getViewDataStore(recordColorMode.view.id).getRecordColor(record);
|
|
417
|
-
// istanbul ignore next
|
|
418
|
-
default:
|
|
419
|
-
throw (0, _error_utils.spawnError)('Unknown record coloring mode type: %s', (0, _private_utils.cast)(recordColorMode).type);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
423
|
+
/**
|
|
424
|
+
* @internal
|
|
425
|
+
*/
|
|
426
|
+
_getRecord(recordOrRecordId) {
|
|
427
|
+
return this.getRecordById(typeof recordOrRecordId === 'string' ? recordOrRecordId : recordOrRecordId.id);
|
|
428
|
+
}
|
|
422
429
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
430
|
+
/**
|
|
431
|
+
* Check to see if a particular record or record id is present in this query result. Returns
|
|
432
|
+
* false if the record has been deleted or is filtered out.
|
|
433
|
+
*
|
|
434
|
+
* @param recordOrRecordId the record or record id to check the presence of
|
|
435
|
+
*/
|
|
436
|
+
hasRecord(recordOrRecordId) {
|
|
437
|
+
const recordId = typeof recordOrRecordId === 'string' ? recordOrRecordId : recordOrRecordId.id;
|
|
438
|
+
return this._getOrGenerateRecordIdsSet()[recordId] === true;
|
|
439
|
+
}
|
|
431
440
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
* Returns the array of keys that were watched.
|
|
450
|
-
*
|
|
451
|
-
* @param keys the keys to watch
|
|
452
|
-
* @param callback a function to call when those keys change
|
|
453
|
-
* @param context an optional context for `this` in `callback`.
|
|
454
|
-
*/
|
|
455
|
-
}, {
|
|
456
|
-
key: "watch",
|
|
457
|
-
value: function watch(keys, callback, context) {
|
|
458
|
-
var validKeys = (0, _get2.default)((0, _getPrototypeOf2.default)(RecordQueryResult.prototype), "watch", this).call(this, keys, callback, context);
|
|
459
|
-
var _iterator = _createForOfIteratorHelper(validKeys),
|
|
460
|
-
_step;
|
|
461
|
-
try {
|
|
462
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
463
|
-
var key = _step.value;
|
|
464
|
-
if (key === WatchableRecordQueryResultKeys.recordColors) {
|
|
465
|
-
this._watchRecordColorsIfNeeded();
|
|
441
|
+
/**
|
|
442
|
+
* Get the {@link Color} of a specific record in the query result. Returns null if the record
|
|
443
|
+
* has no color in this query result. Throws if the record isn't in the RecordQueryResult. Watch
|
|
444
|
+
* with the `'recordColors'` and `'recordIds` keys.
|
|
445
|
+
*
|
|
446
|
+
* @param recordOrRecordId the record or record ID you want the color of.
|
|
447
|
+
*/
|
|
448
|
+
getRecordColor(recordOrRecordId) {
|
|
449
|
+
const record = this._getRecord(recordOrRecordId);
|
|
450
|
+
const recordColorMode = this._normalizedOpts.recordColorMode;
|
|
451
|
+
switch (recordColorMode.type) {
|
|
452
|
+
case _record_coloring.ModeTypes.NONE:
|
|
453
|
+
return null;
|
|
454
|
+
case _record_coloring.ModeTypes.BY_SELECT_FIELD:
|
|
455
|
+
{
|
|
456
|
+
if (recordColorMode.selectField.type !== _field_core.FieldType.SINGLE_SELECT) {
|
|
457
|
+
return null;
|
|
466
458
|
}
|
|
459
|
+
const value = record.getCellValue(recordColorMode.selectField);
|
|
460
|
+
return value && typeof value === 'object' && typeof value.color === 'string' ? (0, _private_utils.assertEnumValue)(_colors.default, value.color) : null;
|
|
467
461
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
return validKeys;
|
|
462
|
+
case _record_coloring.ModeTypes.BY_VIEW:
|
|
463
|
+
return this._recordStore.getViewDataStore(recordColorMode.view.id).getRecordColor(record);
|
|
464
|
+
// istanbul ignore next
|
|
465
|
+
default:
|
|
466
|
+
throw (0, _error_utils.spawnError)('Unknown record coloring mode type: %s', (0, _private_utils.cast)(recordColorMode).type);
|
|
474
467
|
}
|
|
468
|
+
}
|
|
475
469
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
470
|
+
/**
|
|
471
|
+
* @internal
|
|
472
|
+
*/
|
|
473
|
+
_onChangeIsDataLoaded() {
|
|
474
|
+
this._onChange(WatchableRecordQueryResultKeys.isDataLoaded);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Get notified of changes to the query result.
|
|
479
|
+
*
|
|
480
|
+
* Watchable keys are:
|
|
481
|
+
* - `'records'`
|
|
482
|
+
* - `'recordIds'`
|
|
483
|
+
* - `'cellValues'`
|
|
484
|
+
* - `'recordColors'`
|
|
485
|
+
* - `'isDataLoaded'`
|
|
486
|
+
* - `'cellValuesInField:' + someFieldId`
|
|
487
|
+
*
|
|
488
|
+
* Every call to `.watch` should have a matching call to `.unwatch`.
|
|
489
|
+
*
|
|
490
|
+
* Watching a key that needs to load data asynchronously will automatically
|
|
491
|
+
* cause the data to be fetched. Once the data is available, the `callback`
|
|
492
|
+
* will be called.
|
|
493
|
+
*
|
|
494
|
+
* Returns the array of keys that were watched.
|
|
495
|
+
*
|
|
496
|
+
* @param keys the keys to watch
|
|
497
|
+
* @param callback a function to call when those keys change
|
|
498
|
+
* @param context an optional context for `this` in `callback`.
|
|
499
|
+
*/
|
|
500
|
+
watch(keys, callback, context) {
|
|
501
|
+
const validKeys = super.watch(keys, callback, context);
|
|
502
|
+
for (const key of validKeys) {
|
|
503
|
+
if (key === WatchableRecordQueryResultKeys.recordColors) {
|
|
504
|
+
this._watchRecordColorsIfNeeded();
|
|
507
505
|
}
|
|
508
|
-
return validKeys;
|
|
509
506
|
}
|
|
507
|
+
return validKeys;
|
|
508
|
+
}
|
|
510
509
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
510
|
+
/**
|
|
511
|
+
* Unwatch keys watched with `.watch`.
|
|
512
|
+
*
|
|
513
|
+
* Should be called with the same arguments given to `.watch`.
|
|
514
|
+
*
|
|
515
|
+
* Unwatching a key that needs to load data asynchronously will automatically
|
|
516
|
+
* cause the data to be unloaded.
|
|
517
|
+
*
|
|
518
|
+
* Returns the array of keys that were unwatched
|
|
519
|
+
*
|
|
520
|
+
* @param keys the keys to unwatch
|
|
521
|
+
* @param callback the function passed to `.watch` for these keys
|
|
522
|
+
* @param context the context that was passed to `.watch` for this `callback`
|
|
523
|
+
*/
|
|
524
|
+
unwatch(keys, callback, context) {
|
|
525
|
+
const validKeys = super.unwatch(keys, callback, context);
|
|
526
|
+
for (const key of validKeys) {
|
|
527
|
+
if (key === WatchableRecordQueryResultKeys.recordColors) {
|
|
528
|
+
this._unwatchRecordColorsIfPossible();
|
|
521
529
|
}
|
|
522
530
|
}
|
|
531
|
+
return validKeys;
|
|
532
|
+
}
|
|
523
533
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
key
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
if (model === this) {
|
|
533
|
-
this._onChange(WatchableRecordQueryResultKeys.recordColors, recordIds);
|
|
534
|
-
} else {
|
|
535
|
-
this._onChange(WatchableRecordQueryResultKeys.recordColors);
|
|
536
|
-
}
|
|
537
|
-
};
|
|
538
|
-
switch (recordColorMode.type) {
|
|
539
|
-
case _record_coloring.ModeTypes.NONE:
|
|
540
|
-
break;
|
|
541
|
-
case _record_coloring.ModeTypes.BY_SELECT_FIELD:
|
|
542
|
-
this.watch("".concat(WatchableCellValuesInFieldKeyPrefix).concat(recordColorMode.selectField.id), handler);
|
|
543
|
-
recordColorMode.selectField.watch('options', handler);
|
|
544
|
-
break;
|
|
545
|
-
case _record_coloring.ModeTypes.BY_VIEW:
|
|
546
|
-
{
|
|
547
|
-
this._recordStore.getViewDataStore(recordColorMode.view.id).watch('recordColors', handler);
|
|
548
|
-
break;
|
|
549
|
-
}
|
|
550
|
-
// istanbul ignore next
|
|
551
|
-
default:
|
|
552
|
-
throw (0, _error_utils.spawnError)('Unknown record coloring mode type: %s', (0, _private_utils.cast)(recordColorMode).type);
|
|
553
|
-
}
|
|
554
|
-
this._recordColorChangeHandler = handler;
|
|
534
|
+
/**
|
|
535
|
+
* @internal
|
|
536
|
+
*/
|
|
537
|
+
_watchRecordColorsIfNeeded() {
|
|
538
|
+
(0, _error_utils.invariant)(this._changeWatchersByKey[WatchableRecordQueryResultKeys.recordColors], 'method may only be called when `recordColors` key has been watched');
|
|
539
|
+
const watchCount = this._changeWatchersByKey[WatchableRecordQueryResultKeys.recordColors].length;
|
|
540
|
+
if (!this._recordColorChangeHandler && watchCount >= 1) {
|
|
541
|
+
this._watchRecordColors();
|
|
555
542
|
}
|
|
543
|
+
}
|
|
556
544
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
545
|
+
/**
|
|
546
|
+
* @internal
|
|
547
|
+
*/
|
|
548
|
+
_watchRecordColors() {
|
|
549
|
+
const recordColorMode = this._normalizedOpts.recordColorMode;
|
|
550
|
+
const handler = (model, key, recordIds) => {
|
|
551
|
+
if (model === this) {
|
|
552
|
+
this._onChange(WatchableRecordQueryResultKeys.recordColors, recordIds);
|
|
553
|
+
} else {
|
|
554
|
+
this._onChange(WatchableRecordQueryResultKeys.recordColors);
|
|
566
555
|
}
|
|
556
|
+
};
|
|
557
|
+
switch (recordColorMode.type) {
|
|
558
|
+
case _record_coloring.ModeTypes.NONE:
|
|
559
|
+
break;
|
|
560
|
+
case _record_coloring.ModeTypes.BY_SELECT_FIELD:
|
|
561
|
+
this.watch(`${WatchableCellValuesInFieldKeyPrefix}${recordColorMode.selectField.id}`, handler);
|
|
562
|
+
recordColorMode.selectField.watch('options', handler);
|
|
563
|
+
break;
|
|
564
|
+
case _record_coloring.ModeTypes.BY_VIEW:
|
|
565
|
+
{
|
|
566
|
+
this._recordStore.getViewDataStore(recordColorMode.view.id).watch('recordColors', handler);
|
|
567
|
+
break;
|
|
568
|
+
}
|
|
569
|
+
// istanbul ignore next
|
|
570
|
+
default:
|
|
571
|
+
throw (0, _error_utils.spawnError)('Unknown record coloring mode type: %s', (0, _private_utils.cast)(recordColorMode).type);
|
|
567
572
|
}
|
|
573
|
+
this._recordColorChangeHandler = handler;
|
|
574
|
+
}
|
|
568
575
|
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
var handler = this._recordColorChangeHandler;
|
|
577
|
-
(0, _error_utils.invariant)(handler, 'record color change handler must exist');
|
|
578
|
-
switch (recordColorMode.type) {
|
|
579
|
-
case _record_coloring.ModeTypes.NONE:
|
|
580
|
-
break;
|
|
581
|
-
case _record_coloring.ModeTypes.BY_SELECT_FIELD:
|
|
582
|
-
this.unwatch("".concat(WatchableCellValuesInFieldKeyPrefix).concat(recordColorMode.selectField.id), handler);
|
|
583
|
-
recordColorMode.selectField.unwatch('options', handler);
|
|
584
|
-
break;
|
|
585
|
-
case _record_coloring.ModeTypes.BY_VIEW:
|
|
586
|
-
{
|
|
587
|
-
if (!recordColorMode.view.isDeleted) {
|
|
588
|
-
this._recordStore.getViewDataStore(recordColorMode.view.id).unwatch('recordColors', handler);
|
|
589
|
-
}
|
|
590
|
-
break;
|
|
591
|
-
}
|
|
592
|
-
// istanbul ignore next
|
|
593
|
-
default:
|
|
594
|
-
throw (0, _error_utils.spawnError)('Unknown record coloring mode type: %s', (0, _private_utils.cast)(recordColorMode).type);
|
|
595
|
-
}
|
|
596
|
-
this._recordColorChangeHandler = null;
|
|
576
|
+
/**
|
|
577
|
+
* @internal
|
|
578
|
+
*/
|
|
579
|
+
_unwatchRecordColorsIfPossible() {
|
|
580
|
+
const watchCount = (this._changeWatchersByKey[WatchableRecordQueryResultKeys.recordColors] || []).length;
|
|
581
|
+
if (this._recordColorChangeHandler && watchCount === 0) {
|
|
582
|
+
this._unwatchRecordColors();
|
|
597
583
|
}
|
|
584
|
+
}
|
|
598
585
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
return _context.abrupt("return");
|
|
616
|
-
case 5:
|
|
617
|
-
return _context.abrupt("return");
|
|
618
|
-
case 6:
|
|
619
|
-
_context.next = 8;
|
|
620
|
-
return this._recordStore.getViewDataStore(recordColorMode.view.id).loadDataAsync();
|
|
621
|
-
case 8:
|
|
622
|
-
return _context.abrupt("return");
|
|
623
|
-
case 9:
|
|
624
|
-
throw (0, _error_utils.spawnUnknownSwitchCaseError)('record color mode type', recordColorMode, 'type');
|
|
625
|
-
case 10:
|
|
626
|
-
case "end":
|
|
627
|
-
return _context.stop();
|
|
628
|
-
}
|
|
629
|
-
}, _callee, this);
|
|
630
|
-
}));
|
|
631
|
-
function _loadRecordColorsAsync() {
|
|
632
|
-
return _loadRecordColorsAsync2.apply(this, arguments);
|
|
633
|
-
}
|
|
634
|
-
return _loadRecordColorsAsync;
|
|
635
|
-
}()
|
|
636
|
-
/**
|
|
637
|
-
* @internal
|
|
638
|
-
*/
|
|
639
|
-
)
|
|
640
|
-
}, {
|
|
641
|
-
key: "_unloadRecordColors",
|
|
642
|
-
value: function _unloadRecordColors() {
|
|
643
|
-
var recordColorMode = this._normalizedOpts.recordColorMode;
|
|
644
|
-
switch (recordColorMode.type) {
|
|
645
|
-
case _record_coloring.ModeTypes.NONE:
|
|
646
|
-
return;
|
|
647
|
-
case _record_coloring.ModeTypes.BY_SELECT_FIELD:
|
|
648
|
-
// handled as part of fieldIdsOrNullIfAllFields
|
|
649
|
-
return;
|
|
650
|
-
case _record_coloring.ModeTypes.BY_VIEW:
|
|
586
|
+
/**
|
|
587
|
+
* @internal
|
|
588
|
+
*/
|
|
589
|
+
_unwatchRecordColors() {
|
|
590
|
+
const recordColorMode = this._normalizedOpts.recordColorMode;
|
|
591
|
+
const handler = this._recordColorChangeHandler;
|
|
592
|
+
(0, _error_utils.invariant)(handler, 'record color change handler must exist');
|
|
593
|
+
switch (recordColorMode.type) {
|
|
594
|
+
case _record_coloring.ModeTypes.NONE:
|
|
595
|
+
break;
|
|
596
|
+
case _record_coloring.ModeTypes.BY_SELECT_FIELD:
|
|
597
|
+
this.unwatch(`${WatchableCellValuesInFieldKeyPrefix}${recordColorMode.selectField.id}`, handler);
|
|
598
|
+
recordColorMode.selectField.unwatch('options', handler);
|
|
599
|
+
break;
|
|
600
|
+
case _record_coloring.ModeTypes.BY_VIEW:
|
|
601
|
+
{
|
|
651
602
|
if (!recordColorMode.view.isDeleted) {
|
|
652
|
-
this._recordStore.getViewDataStore(recordColorMode.view.id).
|
|
603
|
+
this._recordStore.getViewDataStore(recordColorMode.view.id).unwatch('recordColors', handler);
|
|
653
604
|
}
|
|
654
605
|
break;
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
}
|
|
660
|
-
}], [{
|
|
661
|
-
key: "_isWatchableKey",
|
|
662
|
-
value: /** @internal */
|
|
663
|
-
function _isWatchableKey(key) {
|
|
664
|
-
return (0, _private_utils.isEnumValue)(WatchableRecordQueryResultKeys, key) || key.startsWith(WatchableCellValuesInFieldKeyPrefix);
|
|
606
|
+
}
|
|
607
|
+
// istanbul ignore next
|
|
608
|
+
default:
|
|
609
|
+
throw (0, _error_utils.spawnError)('Unknown record coloring mode type: %s', (0, _private_utils.cast)(recordColorMode).type);
|
|
665
610
|
}
|
|
666
|
-
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
611
|
+
this._recordColorChangeHandler = null;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* @internal
|
|
616
|
+
*/
|
|
617
|
+
async _loadRecordColorsAsync() {
|
|
618
|
+
const recordColorMode = this._normalizedOpts.recordColorMode;
|
|
619
|
+
switch (recordColorMode.type) {
|
|
620
|
+
case _record_coloring.ModeTypes.NONE:
|
|
621
|
+
return;
|
|
622
|
+
case _record_coloring.ModeTypes.BY_SELECT_FIELD:
|
|
623
|
+
// The select field id gets added to fieldIdsOrNullIfAllFields,
|
|
624
|
+
// so we don't need to handle it here
|
|
625
|
+
return;
|
|
626
|
+
case _record_coloring.ModeTypes.BY_VIEW:
|
|
627
|
+
await this._recordStore.getViewDataStore(recordColorMode.view.id).loadDataAsync();
|
|
628
|
+
return;
|
|
629
|
+
// istanbul ignore next
|
|
630
|
+
default:
|
|
631
|
+
throw (0, _error_utils.spawnUnknownSwitchCaseError)('record color mode type', recordColorMode, 'type');
|
|
671
632
|
}
|
|
633
|
+
}
|
|
672
634
|
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
var fieldOrFieldIdOrFieldName = _step3.value;
|
|
688
|
-
if (!fieldOrFieldIdOrFieldName) {
|
|
689
|
-
// Filter out false-y values so users of this API
|
|
690
|
-
// can conveniently list conditional fields, e.g. [field1, isFoo && field2]
|
|
691
|
-
continue;
|
|
692
|
-
}
|
|
693
|
-
if (typeof fieldOrFieldIdOrFieldName !== 'string' && !(fieldOrFieldIdOrFieldName instanceof _field.default)) {
|
|
694
|
-
throw (0, _error_utils.spawnError)('Invalid value for field, expected a field, id, or name but got: %s', fieldOrFieldIdOrFieldName);
|
|
695
|
-
}
|
|
696
|
-
var field = table.__getFieldMatching(fieldOrFieldIdOrFieldName);
|
|
697
|
-
fieldIdsOrNullIfAllFields.push(field.id);
|
|
698
|
-
}
|
|
699
|
-
} catch (err) {
|
|
700
|
-
_iterator3.e(err);
|
|
701
|
-
} finally {
|
|
702
|
-
_iterator3.f();
|
|
635
|
+
/**
|
|
636
|
+
* @internal
|
|
637
|
+
*/
|
|
638
|
+
_unloadRecordColors() {
|
|
639
|
+
const recordColorMode = this._normalizedOpts.recordColorMode;
|
|
640
|
+
switch (recordColorMode.type) {
|
|
641
|
+
case _record_coloring.ModeTypes.NONE:
|
|
642
|
+
return;
|
|
643
|
+
case _record_coloring.ModeTypes.BY_SELECT_FIELD:
|
|
644
|
+
// handled as part of fieldIdsOrNullIfAllFields
|
|
645
|
+
return;
|
|
646
|
+
case _record_coloring.ModeTypes.BY_VIEW:
|
|
647
|
+
if (!recordColorMode.view.isDeleted) {
|
|
648
|
+
this._recordStore.getViewDataStore(recordColorMode.view.id).unloadData();
|
|
703
649
|
}
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
break;
|
|
709
|
-
case _record_coloring.ModeTypes.BY_SELECT_FIELD:
|
|
710
|
-
(0, _error_utils.invariant)(recordColorMode.selectField.type === _field_core.FieldType.SINGLE_SELECT, 'Invalid field for coloring records by select field: expected a %s, but got a %s', _field_core.FieldType.SINGLE_SELECT, recordColorMode.selectField.type);
|
|
711
|
-
(0, _error_utils.invariant)(recordColorMode.selectField.parentTable === table, 'Invalid field for coloring records by select field: the single select field is not in the same table as the records');
|
|
712
|
-
if (fieldIdsOrNullIfAllFields) {
|
|
713
|
-
fieldIdsOrNullIfAllFields.push(recordColorMode.selectField.id);
|
|
714
|
-
}
|
|
715
|
-
break;
|
|
716
|
-
case _record_coloring.ModeTypes.BY_VIEW:
|
|
717
|
-
(0, _error_utils.invariant)(recordColorMode.view.parentTable === table, 'Invalid view for coloring records from view: the view is not in the same table as the records');
|
|
718
|
-
break;
|
|
719
|
-
default:
|
|
720
|
-
throw (0, _error_utils.spawnError)('Unknown record coloring mode type: %s', (0, _private_utils.cast)(recordColorMode).type);
|
|
721
|
-
}
|
|
722
|
-
(0, _error_utils.invariant)(table.id === recordStore.tableId, 'record store and table must match');
|
|
723
|
-
return {
|
|
724
|
-
sorts,
|
|
725
|
-
fieldIdsOrNullIfAllFields,
|
|
726
|
-
recordColorMode,
|
|
727
|
-
table,
|
|
728
|
-
recordStore
|
|
729
|
-
};
|
|
650
|
+
break;
|
|
651
|
+
// istanbul ignore next
|
|
652
|
+
default:
|
|
653
|
+
throw (0, _error_utils.spawnUnknownSwitchCaseError)('record color mode type', recordColorMode, 'type');
|
|
730
654
|
}
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
// Abstract properties - classes extending QueryResult must override these:
|
|
734
|
-
/** @internal */
|
|
735
|
-
(0, _defineProperty2.default)(RecordQueryResult, "_className", 'RecordQueryResult');
|
|
736
|
-
// provided properties + methods:
|
|
737
|
-
/** @internal */
|
|
738
|
-
(0, _defineProperty2.default)(RecordQueryResult, "WatchableKeys", WatchableRecordQueryResultKeys);
|
|
739
|
-
/** @internal */
|
|
740
|
-
(0, _defineProperty2.default)(RecordQueryResult, "WatchableCellValuesInFieldKeyPrefix", WatchableCellValuesInFieldKeyPrefix);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
741
657
|
var _default = exports.default = RecordQueryResult;
|