@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,44 +1,18 @@
|
|
|
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.regexp.exec.js");
|
|
7
|
-
require("core-js/modules/es.regexp.to-string.js");
|
|
8
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
9
3
|
Object.defineProperty(exports, "__esModule", {
|
|
10
4
|
value: true
|
|
11
5
|
});
|
|
12
6
|
exports.getLinkedTableId = exports.default = void 0;
|
|
13
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
14
|
-
require("core-js/modules/es.array.concat.js");
|
|
15
|
-
require("core-js/modules/es.array.filter.js");
|
|
16
|
-
require("core-js/modules/es.array.iterator.js");
|
|
17
|
-
require("core-js/modules/es.array.map.js");
|
|
18
|
-
require("core-js/modules/es.array.slice.js");
|
|
19
|
-
require("core-js/modules/es.object.to-string.js");
|
|
20
|
-
require("core-js/modules/es.promise.js");
|
|
21
|
-
require("core-js/modules/es.string.starts-with.js");
|
|
22
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
23
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
24
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
25
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
26
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
27
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
28
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
29
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
30
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
31
7
|
var _field_core = require("../../shared/types/field_core");
|
|
32
8
|
var _error_utils = require("../../shared/error_utils");
|
|
33
9
|
var _record_query_result = _interopRequireDefault(require("./record_query_result"));
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var options = field.options;
|
|
41
|
-
var linkedTableId = options && options.linkedTableId;
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
/** @module @airtable/blocks/models: RecordQueryResult */ /** */
|
|
12
|
+
|
|
13
|
+
const getLinkedTableId = field => {
|
|
14
|
+
const options = field.options;
|
|
15
|
+
const linkedTableId = options && options.linkedTableId;
|
|
42
16
|
(0, _error_utils.invariant)(typeof linkedTableId === 'string', 'linkedTableId must exist');
|
|
43
17
|
return linkedTableId;
|
|
44
18
|
};
|
|
@@ -54,58 +28,59 @@ exports.getLinkedTableId = getLinkedTableId;
|
|
|
54
28
|
*
|
|
55
29
|
* @docsPath models/query results/LinkedRecordsQueryResult
|
|
56
30
|
*/
|
|
57
|
-
|
|
58
|
-
/** @internal */
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
31
|
+
class LinkedRecordsQueryResult extends _record_query_result.default {
|
|
32
|
+
/** @internal */
|
|
33
|
+
static _className = 'LinkedRecordsQueryResult';
|
|
34
|
+
|
|
35
|
+
// the record containing the linked-record cell this is a query of.
|
|
36
|
+
/** @internal */
|
|
37
|
+
|
|
38
|
+
// the cell's field in the record
|
|
39
|
+
/** @internal */
|
|
40
|
+
|
|
41
|
+
// the table we're linking to
|
|
42
|
+
/** @internal */
|
|
43
|
+
|
|
44
|
+
// the records store for the origin table
|
|
45
|
+
/** @internal */
|
|
46
|
+
|
|
47
|
+
// the records store for the linked table
|
|
48
|
+
/** @internal */
|
|
49
|
+
|
|
50
|
+
// a RecordQueryResult containing all the rows in the linked table
|
|
51
|
+
/** @internal */
|
|
52
|
+
|
|
53
|
+
// is the query result currently valid. if the field config changes to link
|
|
54
|
+
// to another table or not be a linked record field at all, isValid will
|
|
55
|
+
// become false. once a LinkedRecordsQueryResult has become invalid, it will
|
|
56
|
+
// not become valid again.
|
|
57
|
+
/** @internal */
|
|
58
|
+
_isValid = true;
|
|
59
|
+
// a lazily-generated set of the record ids in the result set.
|
|
60
|
+
/** @internal */
|
|
61
|
+
_computedRecordIdsSet = null;
|
|
62
|
+
// a lazily-generated array of the record ids in the query result.
|
|
63
|
+
/** @internal */
|
|
64
|
+
_computedFilteredSortedRecordIds = null;
|
|
65
|
+
// how many times has each 'cellValuesInField:$FieldId' been watched?
|
|
66
|
+
/** @internal */
|
|
67
|
+
_cellValueChangeHandlerByFieldId = {};
|
|
68
|
+
|
|
69
|
+
/** @internal */
|
|
70
|
+
constructor(record, field, normalizedOpts, sdk) {
|
|
71
|
+
super(sdk, normalizedOpts);
|
|
96
72
|
(0, _error_utils.invariant)(record.parentTable === field.parentTable, 'record and field must belong to the same table');
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
73
|
+
this._record = record;
|
|
74
|
+
this._field = field;
|
|
75
|
+
this._linkedTable = normalizedOpts.table;
|
|
76
|
+
this._originRecordStore = this._sdk.base.__getRecordStore(this._record.parentTable.id);
|
|
77
|
+
this._linkedRecordStore = normalizedOpts.recordStore;
|
|
102
78
|
|
|
103
79
|
// we could rely on RecordQueryResult's reuse pool to make sure we get back
|
|
104
80
|
// the same RecordQueryResult every time, but that would make it much harder
|
|
105
81
|
// to make sure we unwatch everything from the old RecordQueryResult if e.g.
|
|
106
82
|
// the field config changes to point at a different table
|
|
107
|
-
|
|
108
|
-
return _this;
|
|
83
|
+
this._linkedQueryResult = this._linkedTable.__tableOrViewQueryResultPool.getObjectForReuse(this._sdk, this._linkedTable, normalizedOpts);
|
|
109
84
|
}
|
|
110
85
|
|
|
111
86
|
/**
|
|
@@ -117,612 +92,462 @@ var LinkedRecordsQueryResult = /*#__PURE__*/function (_RecordQueryResult) {
|
|
|
117
92
|
* will never become true again. Many fields will throw on attempting to
|
|
118
93
|
* access them, and watches will no longer fire.
|
|
119
94
|
*/
|
|
120
|
-
(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
get: function get() {
|
|
124
|
-
return this._isValid;
|
|
125
|
-
}
|
|
95
|
+
get isValid() {
|
|
96
|
+
return this._isValid;
|
|
97
|
+
}
|
|
126
98
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return this._linkedTable;
|
|
137
|
-
}
|
|
99
|
+
/**
|
|
100
|
+
* The table that records in this RecordQueryResult are part of
|
|
101
|
+
*
|
|
102
|
+
* @internal (since we may not be able to return parent model instances in the immutable models world)
|
|
103
|
+
*/
|
|
104
|
+
get parentTable() {
|
|
105
|
+
(0, _error_utils.invariant)(this.isValid, 'LinkedRecordsQueryResult is no longer valid');
|
|
106
|
+
return this._linkedTable;
|
|
107
|
+
}
|
|
138
108
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return this._computedFilteredSortedRecordIds;
|
|
152
|
-
}
|
|
109
|
+
/**
|
|
110
|
+
* Ordered array of all the linked record ids. Watchable.
|
|
111
|
+
*/
|
|
112
|
+
get recordIds() {
|
|
113
|
+
(0, _error_utils.invariant)(this.isValid, 'LinkedRecordsQueryResult is no longer valid');
|
|
114
|
+
(0, _error_utils.invariant)(this.isDataLoaded, 'LinkedRecordsQueryResult data is not loaded');
|
|
115
|
+
|
|
116
|
+
// record ids are lazily generated
|
|
117
|
+
this._generateComputedDataIfNeeded();
|
|
118
|
+
(0, _error_utils.invariant)(this._computedFilteredSortedRecordIds, 'no recordIds');
|
|
119
|
+
return this._computedFilteredSortedRecordIds;
|
|
120
|
+
}
|
|
153
121
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
});
|
|
166
|
-
}
|
|
122
|
+
/**
|
|
123
|
+
* Ordered array of all the linked records. Watchable.
|
|
124
|
+
*/
|
|
125
|
+
get records() {
|
|
126
|
+
(0, _error_utils.invariant)(this.isValid, 'LinkedRecordsQueryResult is no longer valid');
|
|
127
|
+
return this.recordIds.map(recordId => {
|
|
128
|
+
const record = this._linkedRecordStore.getRecordByIdIfExists(recordId);
|
|
129
|
+
(0, _error_utils.invariant)(record, 'No record for id: %s', recordId);
|
|
130
|
+
return record;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
167
133
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
return this._linkedQueryResult.fields;
|
|
176
|
-
}
|
|
134
|
+
/**
|
|
135
|
+
* The fields that were used to create this LinkedRecordsQueryResult.
|
|
136
|
+
*/
|
|
137
|
+
get fields() {
|
|
138
|
+
(0, _error_utils.invariant)(this.isValid, 'LinkedRecordsQueryResult is no longer valid');
|
|
139
|
+
return this._linkedQueryResult.fields;
|
|
140
|
+
}
|
|
177
141
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
_step;
|
|
186
|
-
try {
|
|
187
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
188
|
-
var key = _step.value;
|
|
189
|
-
if (key === _record_query_result.default.WatchableKeys.cellValues) {
|
|
190
|
-
this._watchLinkedQueryCellValuesIfNeededAfterWatch();
|
|
191
|
-
}
|
|
192
|
-
if (key.startsWith(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix)) {
|
|
193
|
-
var fieldId = key.substring(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix.length);
|
|
194
|
-
this._watchLinkedQueryCellValuesInFieldIfNeededAfterWatch(fieldId);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
} catch (err) {
|
|
198
|
-
_iterator.e(err);
|
|
199
|
-
} finally {
|
|
200
|
-
_iterator.f();
|
|
142
|
+
/** @inheritdoc */
|
|
143
|
+
watch(keys, callback, context) {
|
|
144
|
+
(0, _error_utils.invariant)(this.isValid, 'cannot watch an invalid LinkedRecordsQueryResult');
|
|
145
|
+
const validKeys = super.watch(keys, callback, context);
|
|
146
|
+
for (const key of validKeys) {
|
|
147
|
+
if (key === _record_query_result.default.WatchableKeys.cellValues) {
|
|
148
|
+
this._watchLinkedQueryCellValuesIfNeededAfterWatch();
|
|
201
149
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
/** @inheritdoc */
|
|
206
|
-
}, {
|
|
207
|
-
key: "unwatch",
|
|
208
|
-
value: function unwatch(keys, callback, context) {
|
|
209
|
-
var arrayKeys = Array.isArray(keys) ? keys : [keys];
|
|
210
|
-
var _iterator2 = _createForOfIteratorHelper(arrayKeys),
|
|
211
|
-
_step2;
|
|
212
|
-
try {
|
|
213
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
214
|
-
var key = _step2.value;
|
|
215
|
-
if (key === _record_query_result.default.WatchableKeys.cellValues) {
|
|
216
|
-
this._unwatchLinkedQueryCellValuesIfPossibleBeforeUnwatch();
|
|
217
|
-
}
|
|
218
|
-
if (key.startsWith(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix)) {
|
|
219
|
-
var fieldId = key.substring(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix.length);
|
|
220
|
-
this._unwatchLinkedQueryCellValuesInFieldIfPossibleBeforeUnwatch(fieldId);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
} catch (err) {
|
|
224
|
-
_iterator2.e(err);
|
|
225
|
-
} finally {
|
|
226
|
-
_iterator2.f();
|
|
150
|
+
if (key.startsWith(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix)) {
|
|
151
|
+
const fieldId = key.substring(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix.length);
|
|
152
|
+
this._watchLinkedQueryCellValuesInFieldIfNeededAfterWatch(fieldId);
|
|
227
153
|
}
|
|
228
|
-
return (0, _get2.default)((0, _getPrototypeOf2.default)(LinkedRecordsQueryResult.prototype), "unwatch", this).call(this, arrayKeys, callback, context);
|
|
229
154
|
}
|
|
155
|
+
return validKeys;
|
|
156
|
+
}
|
|
230
157
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
while (1) switch (_context.prev = _context.next) {
|
|
238
|
-
case 0:
|
|
239
|
-
_context.next = 2;
|
|
240
|
-
return (0, _get2.default)((0, _getPrototypeOf2.default)(LinkedRecordsQueryResult.prototype), "loadDataAsync", this).call(this);
|
|
241
|
-
case 2:
|
|
242
|
-
if (this.isDataLoaded) {
|
|
243
|
-
_context.next = 6;
|
|
244
|
-
break;
|
|
245
|
-
}
|
|
246
|
-
_context.next = 5;
|
|
247
|
-
return this.loadDataAsync();
|
|
248
|
-
case 5:
|
|
249
|
-
// there has to be an unloadData call for every loadDataAsync call.
|
|
250
|
-
// call it here to offset calling loadDataAsync a second time
|
|
251
|
-
this.unloadData();
|
|
252
|
-
case 6:
|
|
253
|
-
case "end":
|
|
254
|
-
return _context.stop();
|
|
255
|
-
}
|
|
256
|
-
}, _callee, this);
|
|
257
|
-
}));
|
|
258
|
-
function loadDataAsync() {
|
|
259
|
-
return _loadDataAsync2.apply(this, arguments);
|
|
158
|
+
/** @inheritdoc */
|
|
159
|
+
unwatch(keys, callback, context) {
|
|
160
|
+
const arrayKeys = Array.isArray(keys) ? keys : [keys];
|
|
161
|
+
for (const key of arrayKeys) {
|
|
162
|
+
if (key === _record_query_result.default.WatchableKeys.cellValues) {
|
|
163
|
+
this._unwatchLinkedQueryCellValuesIfPossibleBeforeUnwatch();
|
|
260
164
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
key: "_loadDataAsync",
|
|
265
|
-
value: (function () {
|
|
266
|
-
var _loadDataAsync3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
267
|
-
var initiallyLoaded, changedKeys, fieldIds, _iterator3, _step3, fieldId;
|
|
268
|
-
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
269
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
270
|
-
case 0:
|
|
271
|
-
this._record.__linkedRecordsQueryResultPool.registerObjectForReuseStrong(this);
|
|
272
|
-
this._watchOrigin();
|
|
273
|
-
this._watchLinkedQueryResult();
|
|
274
|
-
initiallyLoaded = this._linkedQueryResult.isDataLoaded;
|
|
275
|
-
_context2.next = 6;
|
|
276
|
-
return Promise.all([this._sdk.base.__getRecordStore(this._record.parentTable.id).loadCellValuesInFieldIdsAsync([this._field.id]), this._linkedQueryResult.loadDataAsync(), this._loadRecordColorsAsync()]);
|
|
277
|
-
case 6:
|
|
278
|
-
this._invalidateComputedData();
|
|
279
|
-
changedKeys = ['records', 'recordIds', 'recordColors']; // If the linked query result was not initially loaded, then the
|
|
280
|
-
// `cellValues` event will be emitted via `_onLinkedCellValuesChange`.
|
|
281
|
-
// Otherwise, it must be explicitly included here in order to promote
|
|
282
|
-
// consistency.
|
|
283
|
-
if (initiallyLoaded) {
|
|
284
|
-
changedKeys.push('cellValues');
|
|
285
|
-
}
|
|
286
|
-
fieldIds = this._normalizedOpts.fieldIdsOrNullIfAllFields || this.parentTable.fields.map(field => field.id);
|
|
287
|
-
_iterator3 = _createForOfIteratorHelper(fieldIds);
|
|
288
|
-
try {
|
|
289
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
290
|
-
fieldId = _step3.value;
|
|
291
|
-
changedKeys.push(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix + fieldId);
|
|
292
|
-
}
|
|
293
|
-
} catch (err) {
|
|
294
|
-
_iterator3.e(err);
|
|
295
|
-
} finally {
|
|
296
|
-
_iterator3.f();
|
|
297
|
-
}
|
|
298
|
-
return _context2.abrupt("return", changedKeys);
|
|
299
|
-
case 13:
|
|
300
|
-
case "end":
|
|
301
|
-
return _context2.stop();
|
|
302
|
-
}
|
|
303
|
-
}, _callee2, this);
|
|
304
|
-
}));
|
|
305
|
-
function _loadDataAsync() {
|
|
306
|
-
return _loadDataAsync3.apply(this, arguments);
|
|
307
|
-
}
|
|
308
|
-
return _loadDataAsync;
|
|
309
|
-
}() /** @internal */)
|
|
310
|
-
}, {
|
|
311
|
-
key: "_unloadData",
|
|
312
|
-
value: function _unloadData() {
|
|
313
|
-
// The inverse of this condition cannot be deterministically reproduced
|
|
314
|
-
// in the testing environment.
|
|
315
|
-
// istanbul ignore else
|
|
316
|
-
if (this.isValid) {
|
|
317
|
-
this._record.__linkedRecordsQueryResultPool.unregisterObjectForReuseStrong(this);
|
|
318
|
-
this._unwatchOrigin();
|
|
319
|
-
this._unwatchLinkedQueryResult();
|
|
320
|
-
this._originRecordStore.unloadCellValuesInFieldIds([this._field.id]);
|
|
321
|
-
this._linkedQueryResult.unloadData();
|
|
322
|
-
this._unloadRecordColors();
|
|
323
|
-
this._invalidateComputedData();
|
|
165
|
+
if (key.startsWith(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix)) {
|
|
166
|
+
const fieldId = key.substring(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix.length);
|
|
167
|
+
this._unwatchLinkedQueryCellValuesInFieldIfPossibleBeforeUnwatch(fieldId);
|
|
324
168
|
}
|
|
325
169
|
}
|
|
170
|
+
return super.unwatch(arrayKeys, callback, context);
|
|
171
|
+
}
|
|
326
172
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
173
|
+
/** @inheritdoc */
|
|
174
|
+
async loadDataAsync() {
|
|
175
|
+
await super.loadDataAsync();
|
|
176
|
+
|
|
177
|
+
// This condition cannot be deterministically reproduced in the testing
|
|
178
|
+
// environment.
|
|
179
|
+
// istanbul ignore if
|
|
180
|
+
if (!this.isDataLoaded) {
|
|
181
|
+
// data still might not be loaded after the promise resolves if the
|
|
182
|
+
// linked table changed. in that case, call again:
|
|
183
|
+
await this.loadDataAsync();
|
|
184
|
+
// there has to be an unloadData call for every loadDataAsync call.
|
|
185
|
+
// call it here to offset calling loadDataAsync a second time
|
|
186
|
+
this.unloadData();
|
|
336
187
|
}
|
|
188
|
+
}
|
|
337
189
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
190
|
+
/** @internal */
|
|
191
|
+
async _loadDataAsync() {
|
|
192
|
+
this._record.__linkedRecordsQueryResultPool.registerObjectForReuseStrong(this);
|
|
193
|
+
this._watchOrigin();
|
|
194
|
+
this._watchLinkedQueryResult();
|
|
195
|
+
const initiallyLoaded = this._linkedQueryResult.isDataLoaded;
|
|
196
|
+
await Promise.all([this._sdk.base.__getRecordStore(this._record.parentTable.id).loadCellValuesInFieldIdsAsync([this._field.id]), this._linkedQueryResult.loadDataAsync(), this._loadRecordColorsAsync()]);
|
|
197
|
+
this._invalidateComputedData();
|
|
198
|
+
const changedKeys = ['records', 'recordIds', 'recordColors'];
|
|
199
|
+
|
|
200
|
+
// If the linked query result was not initially loaded, then the
|
|
201
|
+
// `cellValues` event will be emitted via `_onLinkedCellValuesChange`.
|
|
202
|
+
// Otherwise, it must be explicitly included here in order to promote
|
|
203
|
+
// consistency.
|
|
204
|
+
if (initiallyLoaded) {
|
|
205
|
+
changedKeys.push('cellValues');
|
|
206
|
+
}
|
|
207
|
+
const fieldIds = this._normalizedOpts.fieldIdsOrNullIfAllFields || this.parentTable.fields.map(field => field.id);
|
|
208
|
+
for (const fieldId of fieldIds) {
|
|
209
|
+
changedKeys.push(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix + fieldId);
|
|
210
|
+
}
|
|
211
|
+
return changedKeys;
|
|
212
|
+
}
|
|
344
213
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
214
|
+
/** @internal */
|
|
215
|
+
_unloadData() {
|
|
216
|
+
// The inverse of this condition cannot be deterministically reproduced
|
|
217
|
+
// in the testing environment.
|
|
218
|
+
// istanbul ignore else
|
|
219
|
+
if (this.isValid) {
|
|
220
|
+
this._record.__linkedRecordsQueryResultPool.unregisterObjectForReuseStrong(this);
|
|
221
|
+
this._unwatchOrigin();
|
|
222
|
+
this._unwatchLinkedQueryResult();
|
|
223
|
+
this._originRecordStore.unloadCellValuesInFieldIds([this._field.id]);
|
|
224
|
+
this._linkedQueryResult.unloadData();
|
|
225
|
+
this._unloadRecordColors();
|
|
226
|
+
this._invalidateComputedData();
|
|
352
227
|
}
|
|
228
|
+
}
|
|
353
229
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
230
|
+
/**
|
|
231
|
+
* the key used to identify this query result in ObjectPool
|
|
232
|
+
*
|
|
233
|
+
* @hidden
|
|
234
|
+
*/
|
|
235
|
+
get __poolKey() {
|
|
236
|
+
return `${this._serializedOpts}::${this._field.id}::${this._linkedTable.id}::${this.isValid}`;
|
|
237
|
+
}
|
|
362
238
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
var countByFieldId = {};
|
|
368
|
-
var watchKeys = Object.keys(this._changeWatchersByKey).filter(key => {
|
|
369
|
-
return key.startsWith(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix);
|
|
370
|
-
});
|
|
371
|
-
var _iterator4 = _createForOfIteratorHelper(watchKeys),
|
|
372
|
-
_step4;
|
|
373
|
-
try {
|
|
374
|
-
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
375
|
-
var watchKey = _step4.value;
|
|
376
|
-
var fieldId = watchKey.slice(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix.length);
|
|
377
|
-
countByFieldId[fieldId] = this._changeWatchersByKey[watchKey].length;
|
|
378
|
-
}
|
|
379
|
-
} catch (err) {
|
|
380
|
-
_iterator4.e(err);
|
|
381
|
-
} finally {
|
|
382
|
-
_iterator4.f();
|
|
383
|
-
}
|
|
384
|
-
return countByFieldId;
|
|
385
|
-
}
|
|
239
|
+
/** @internal */
|
|
240
|
+
get _cellValuesWatchCount() {
|
|
241
|
+
return (this._changeWatchersByKey[_record_query_result.default.WatchableKeys.cellValues] || []).length;
|
|
242
|
+
}
|
|
386
243
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
if (this._cellValueWatchCountByFieldId[fieldId] === 1 && this.isValid) {
|
|
392
|
-
this._watchLinkedQueryCellValuesInField(fieldId);
|
|
393
|
-
}
|
|
244
|
+
/** @internal */
|
|
245
|
+
_watchLinkedQueryCellValuesIfNeededAfterWatch() {
|
|
246
|
+
if (this._cellValuesWatchCount === 1) {
|
|
247
|
+
this._watchLinkedQueryCellValues();
|
|
394
248
|
}
|
|
249
|
+
}
|
|
395
250
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
(0, _error_utils.invariant)(this._cellValueWatchCountByFieldId[fieldId], "cellValuesInField:%s over-free'd", fieldId);
|
|
401
|
-
if (this._cellValueWatchCountByFieldId[fieldId] === 1 && this.isValid) {
|
|
402
|
-
this._unwatchLinkedQueryCellValuesInField(fieldId);
|
|
403
|
-
}
|
|
251
|
+
/** @internal */
|
|
252
|
+
_unwatchLinkedQueryCellValuesIfPossibleBeforeUnwatch() {
|
|
253
|
+
if (this._cellValuesWatchCount === 1 && this.isValid) {
|
|
254
|
+
this._unwatchLinkedQueryCellValues();
|
|
404
255
|
}
|
|
256
|
+
}
|
|
405
257
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
// result
|
|
419
|
-
this._originRecordStore.watch('recordIds', this._onOriginRecordsChange, this);
|
|
420
|
-
// if the linked field in the origin table is deleted, we need to
|
|
421
|
-
// invalidate this result
|
|
422
|
-
this._record.parentTable.watch('fields', this._onOriginFieldsChange, this);
|
|
423
|
-
}
|
|
258
|
+
/** @internal */
|
|
259
|
+
get _cellValueWatchCountByFieldId() {
|
|
260
|
+
const countByFieldId = {};
|
|
261
|
+
const watchKeys = Object.keys(this._changeWatchersByKey).filter(key => {
|
|
262
|
+
return key.startsWith(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix);
|
|
263
|
+
});
|
|
264
|
+
for (const watchKey of watchKeys) {
|
|
265
|
+
const fieldId = watchKey.slice(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix.length);
|
|
266
|
+
countByFieldId[fieldId] = this._changeWatchersByKey[watchKey].length;
|
|
267
|
+
}
|
|
268
|
+
return countByFieldId;
|
|
269
|
+
}
|
|
424
270
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
this._record.unwatch("cellValueInField:".concat(this._field.id), this._onOriginCellValueChange, this);
|
|
430
|
-
this._field.unwatch('type', this._onOriginFieldConfigChange, this);
|
|
431
|
-
this._field.unwatch('options', this._onOriginFieldConfigChange, this);
|
|
432
|
-
this._originRecordStore.unwatch('recordIds', this._onOriginRecordsChange, this);
|
|
433
|
-
this._record.parentTable.unwatch('fields', this._onOriginFieldsChange, this);
|
|
271
|
+
/** @internal */
|
|
272
|
+
_watchLinkedQueryCellValuesInFieldIfNeededAfterWatch(fieldId) {
|
|
273
|
+
if (this._cellValueWatchCountByFieldId[fieldId] === 1 && this.isValid) {
|
|
274
|
+
this._watchLinkedQueryCellValuesInField(fieldId);
|
|
434
275
|
}
|
|
276
|
+
}
|
|
435
277
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
// this watch fire when they're added/removed and when they change
|
|
442
|
-
// order. we only care about order, because add/remove is handled by
|
|
443
|
-
// watching the origin record
|
|
444
|
-
this._linkedQueryResult.watch('recordIds', this._onLinkedRecordIdsChange, this);
|
|
278
|
+
/** @internal */
|
|
279
|
+
_unwatchLinkedQueryCellValuesInFieldIfPossibleBeforeUnwatch(fieldId) {
|
|
280
|
+
(0, _error_utils.invariant)(this._cellValueWatchCountByFieldId[fieldId], "cellValuesInField:%s over-free'd", fieldId);
|
|
281
|
+
if (this._cellValueWatchCountByFieldId[fieldId] === 1 && this.isValid) {
|
|
282
|
+
this._unwatchLinkedQueryCellValuesInField(fieldId);
|
|
445
283
|
}
|
|
284
|
+
}
|
|
446
285
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
286
|
+
/** @internal */
|
|
287
|
+
_watchOrigin() {
|
|
288
|
+
// if the cell values in the record change, we need to invalidate our
|
|
289
|
+
// cached data and notify watchers
|
|
290
|
+
this._record.watch(`cellValueInField:${this._field.id}`, this._onOriginCellValueChange, this);
|
|
291
|
+
// if the field config changes, we need to invalidate cached data,
|
|
292
|
+
// and potentially start watching a different table
|
|
293
|
+
this._field.watch('type', this._onOriginFieldConfigChange, this);
|
|
294
|
+
this._field.watch('options', this._onOriginFieldConfigChange, this);
|
|
295
|
+
// if the underlying record is deleted, we need to invalidate this
|
|
296
|
+
// result
|
|
297
|
+
this._originRecordStore.watch('recordIds', this._onOriginRecordsChange, this);
|
|
298
|
+
// if the linked field in the origin table is deleted, we need to
|
|
299
|
+
// invalidate this result
|
|
300
|
+
this._record.parentTable.watch('fields', this._onOriginFieldsChange, this);
|
|
301
|
+
}
|
|
453
302
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
303
|
+
/** @internal */
|
|
304
|
+
_unwatchOrigin() {
|
|
305
|
+
this._record.unwatch(`cellValueInField:${this._field.id}`, this._onOriginCellValueChange, this);
|
|
306
|
+
this._field.unwatch('type', this._onOriginFieldConfigChange, this);
|
|
307
|
+
this._field.unwatch('options', this._onOriginFieldConfigChange, this);
|
|
308
|
+
this._originRecordStore.unwatch('recordIds', this._onOriginRecordsChange, this);
|
|
309
|
+
this._record.parentTable.unwatch('fields', this._onOriginFieldsChange, this);
|
|
310
|
+
}
|
|
460
311
|
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
312
|
+
/** @internal */
|
|
313
|
+
_watchLinkedQueryResult() {
|
|
314
|
+
// in the linked table, all we care about is the set of recordIds.
|
|
315
|
+
// this watch fire when they're added/removed and when they change
|
|
316
|
+
// order. we only care about order, because add/remove is handled by
|
|
317
|
+
// watching the origin record
|
|
318
|
+
this._linkedQueryResult.watch('recordIds', this._onLinkedRecordIdsChange, this);
|
|
319
|
+
}
|
|
467
320
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
this._linkedQueryResult.watch(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix + fieldId, this._getOnLinkedCellValuesInFieldChange(fieldId), this);
|
|
473
|
-
}
|
|
321
|
+
/** @internal */
|
|
322
|
+
_unwatchLinkedQueryResult() {
|
|
323
|
+
this._linkedQueryResult.unwatch('recordIds', this._onLinkedRecordIdsChange, this);
|
|
324
|
+
}
|
|
474
325
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
this._linkedQueryResult.unwatch(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix + fieldId, this._getOnLinkedCellValuesInFieldChange(fieldId), this);
|
|
480
|
-
}
|
|
326
|
+
/** @internal */
|
|
327
|
+
_watchLinkedQueryCellValues() {
|
|
328
|
+
this._linkedQueryResult.watch('cellValues', this._onLinkedCellValuesChange, this);
|
|
329
|
+
}
|
|
481
330
|
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
if (!this.isDataLoaded || this._record.isDeleted) {
|
|
487
|
-
//TODO(jamesmoody-at): Adding this._dataOrNullIfDeleted as an exit condition here is a temporary fix to address an issue where
|
|
488
|
-
// we are not reseting isValid to true while restoring deleted records that contain linked record fields. It seems the only way
|
|
489
|
-
// to do this is by creating a new LinkRecordsQueryResult instance but it seems like we might be reusing the original instance
|
|
490
|
-
// that we've already set isValid to false with. We'll need to do more investigating to figure out the right way to restore these
|
|
491
|
-
// records while keeping the behavior of isValid consistent
|
|
492
|
-
return;
|
|
493
|
-
}
|
|
494
|
-
(0, _error_utils.invariant)(this.isValid, 'watch key change event whilst invalid');
|
|
495
|
-
this._invalidateComputedData();
|
|
331
|
+
/** @internal */
|
|
332
|
+
_unwatchLinkedQueryCellValues() {
|
|
333
|
+
this._linkedQueryResult.unwatch('cellValues', this._onLinkedCellValuesChange, this);
|
|
334
|
+
}
|
|
496
335
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
}
|
|
336
|
+
/** @internal */
|
|
337
|
+
_watchLinkedQueryCellValuesInField(fieldId) {
|
|
338
|
+
this._linkedQueryResult.watch(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix + fieldId, this._getOnLinkedCellValuesInFieldChange(fieldId), this);
|
|
339
|
+
}
|
|
502
340
|
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
341
|
+
/** @internal */
|
|
342
|
+
_unwatchLinkedQueryCellValuesInField(fieldId) {
|
|
343
|
+
this._linkedQueryResult.unwatch(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix + fieldId, this._getOnLinkedCellValuesInFieldChange(fieldId), this);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/** @internal */
|
|
347
|
+
_onLinkedRecordIdsChange() {
|
|
348
|
+
if (!this.isDataLoaded || this._record.isDeleted) {
|
|
349
|
+
//TODO(jamesmoody-at): Adding this._dataOrNullIfDeleted as an exit condition here is a temporary fix to address an issue where
|
|
350
|
+
// we are not reseting isValid to true while restoring deleted records that contain linked record fields. It seems the only way
|
|
351
|
+
// to do this is by creating a new LinkRecordsQueryResult instance but it seems like we might be reusing the original instance
|
|
352
|
+
// that we've already set isValid to false with. We'll need to do more investigating to figure out the right way to restore these
|
|
353
|
+
// records while keeping the behavior of isValid consistent
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
(0, _error_utils.invariant)(this.isValid, 'watch key change event whilst invalid');
|
|
357
|
+
this._invalidateComputedData();
|
|
358
|
+
|
|
359
|
+
// we don't actually know at this stage whether anything changed or
|
|
360
|
+
// not. it may have done though, so notify watchers
|
|
361
|
+
this._onChange('records');
|
|
362
|
+
this._onChange('recordIds');
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* This model doesn't use the `_data` computed property it inherits from
|
|
367
|
+
* AbstractModel. It implements the following method only so that internal
|
|
368
|
+
* checks for model deletion behave appropriately (the data itself is
|
|
369
|
+
* inconsequential).
|
|
370
|
+
*
|
|
371
|
+
* @internal
|
|
372
|
+
*/
|
|
373
|
+
get _dataOrNullIfDeleted() {
|
|
374
|
+
if (this._record.isDeleted || this._linkedRecordStore.isDeleted) {
|
|
375
|
+
return null;
|
|
518
376
|
}
|
|
377
|
+
return {};
|
|
378
|
+
}
|
|
519
379
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
key
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
recordIds
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
} else {
|
|
535
|
-
this._onChange('cellValues');
|
|
380
|
+
/** @internal */
|
|
381
|
+
_onLinkedCellValuesChange(queryResult, key, changes) {
|
|
382
|
+
(0, _error_utils.invariant)(this.isValid, 'watch key change event whilst invalid');
|
|
383
|
+
if (changes && changes.fieldIds && changes.recordIds) {
|
|
384
|
+
const recordIdsSet = this._getOrGenerateRecordIdsSet();
|
|
385
|
+
const recordIds = changes.recordIds.filter(id => recordIdsSet[id] === true);
|
|
386
|
+
if (recordIds.length) {
|
|
387
|
+
this._onChange('cellValues', {
|
|
388
|
+
fieldIds: changes.fieldIds,
|
|
389
|
+
recordIds
|
|
390
|
+
});
|
|
536
391
|
}
|
|
392
|
+
} else {
|
|
393
|
+
this._onChange('cellValues');
|
|
537
394
|
}
|
|
395
|
+
}
|
|
538
396
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
return;
|
|
552
|
-
}
|
|
397
|
+
/** @internal */
|
|
398
|
+
_getOnLinkedCellValuesInFieldChange(fieldId) {
|
|
399
|
+
if (!this._cellValueChangeHandlerByFieldId[fieldId]) {
|
|
400
|
+
this._cellValueChangeHandlerByFieldId[fieldId] = (queryResult, key, recordIds) => {
|
|
401
|
+
(0, _error_utils.invariant)(this.isValid, 'watch key change event whilst invalid');
|
|
402
|
+
|
|
403
|
+
// The linked record may finish loading before its parent. In
|
|
404
|
+
// that case, the appropriate events will be triggered by the
|
|
405
|
+
// `_loadDataAsync` method.
|
|
406
|
+
if (!this.isDataLoaded) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
553
409
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
}
|
|
569
|
-
} else {
|
|
570
|
-
this._onChange(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix + fieldId);
|
|
410
|
+
// The `else` branch will only be reached when the underlying
|
|
411
|
+
// `RecordOrViewQueryResult` is loaded, unloaded, and then
|
|
412
|
+
// loaded again. Because that query result is not directly
|
|
413
|
+
// exposed to consumers, the condition can only be met when the
|
|
414
|
+
// SDK is misused (e.g. repeatedly freeing related query
|
|
415
|
+
// results). The `else` branch attempts to handle that
|
|
416
|
+
// situation in a logical way, but it is not tested because it
|
|
417
|
+
// is fundamentally invalid.
|
|
418
|
+
// istanbul ignore else
|
|
419
|
+
if (Array.isArray(recordIds)) {
|
|
420
|
+
const recordIdsSet = this._getOrGenerateRecordIdsSet();
|
|
421
|
+
const filteredRecordIds = recordIds.filter(id => typeof id === 'string' && recordIdsSet[id] === true);
|
|
422
|
+
if (filteredRecordIds.length) {
|
|
423
|
+
this._onChange(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix + fieldId, filteredRecordIds);
|
|
571
424
|
}
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
|
|
425
|
+
} else {
|
|
426
|
+
this._onChange(_record_query_result.default.WatchableCellValuesInFieldKeyPrefix + fieldId);
|
|
427
|
+
}
|
|
428
|
+
};
|
|
575
429
|
}
|
|
430
|
+
return this._cellValueChangeHandlerByFieldId[fieldId];
|
|
431
|
+
}
|
|
576
432
|
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
433
|
+
/** @internal */
|
|
434
|
+
_onOriginCellValueChange() {
|
|
435
|
+
if (!this.isDataLoaded || this._field.isDeleted) {
|
|
436
|
+
//TODO(jamesmoody-at): Adding this._dataOrNullIfDeleted as an exit condition here is a temporary fix to address an issue where
|
|
437
|
+
// we are not resetting isValid to true while restoring deleted records that contain linked record fields. It seems the only way
|
|
438
|
+
// to do this is by creating a new LinkRecordsQueryResult instance but it seems like we might be reusing the original instance
|
|
439
|
+
// that we've already set isValid to false with. We'll need to do more investigating to figure out the right way to restore these
|
|
440
|
+
// records while keeping the behavior of isValid consistent
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
(0, _error_utils.invariant)(this.isValid, 'watch key change event whilst invalid');
|
|
444
|
+
|
|
445
|
+
// when the origin cell value (listing all the linked records) changes,
|
|
446
|
+
// invalidate all the data we have stored - we need to completely
|
|
447
|
+
// regenerate it
|
|
448
|
+
this._invalidateComputedData();
|
|
449
|
+
|
|
450
|
+
// notify watchers that our set of linked records has changed
|
|
451
|
+
this._onChange('records');
|
|
452
|
+
this._onChange('recordIds');
|
|
453
|
+
}
|
|
595
454
|
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
455
|
+
/** @internal */
|
|
456
|
+
_onOriginRecordsChange() {
|
|
457
|
+
if (this._record.isDeleted) {
|
|
458
|
+
this._isValid = false;
|
|
599
459
|
}
|
|
460
|
+
}
|
|
600
461
|
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
if (this._record.isDeleted) {
|
|
606
|
-
this._isValid = false;
|
|
607
|
-
}
|
|
462
|
+
/** @internal */
|
|
463
|
+
_onOriginFieldsChange() {
|
|
464
|
+
if (this._field.isDeleted) {
|
|
465
|
+
this._isValid = false;
|
|
608
466
|
}
|
|
467
|
+
}
|
|
609
468
|
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
key
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
469
|
+
/** @internal */
|
|
470
|
+
_onOriginFieldConfigChange() {
|
|
471
|
+
(0, _error_utils.invariant)(this.isValid, 'watch key change event whilst invalid');
|
|
472
|
+
const type = this._field.type;
|
|
473
|
+
if (type !== _field_core.FieldType.MULTIPLE_RECORD_LINKS) {
|
|
474
|
+
this._invalidateQueryResult();
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
const linkedTableId = getLinkedTableId(this._field);
|
|
478
|
+
if (linkedTableId !== this._linkedTable.id) {
|
|
479
|
+
this._invalidateQueryResult();
|
|
480
|
+
return;
|
|
617
481
|
}
|
|
482
|
+
}
|
|
618
483
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
(0, _error_utils.invariant)(this.isValid, 'watch key change event whilst invalid');
|
|
624
|
-
var type = this._field.type;
|
|
625
|
-
if (type !== _field_core.FieldType.MULTIPLE_RECORD_LINKS) {
|
|
626
|
-
this._invalidateQueryResult();
|
|
627
|
-
return;
|
|
628
|
-
}
|
|
629
|
-
var linkedTableId = getLinkedTableId(this._field);
|
|
630
|
-
if (linkedTableId !== this._linkedTable.id) {
|
|
631
|
-
this._invalidateQueryResult();
|
|
632
|
-
return;
|
|
633
|
-
}
|
|
484
|
+
/** @internal */
|
|
485
|
+
_invalidateQueryResult() {
|
|
486
|
+
if (this.isDataLoaded) {
|
|
487
|
+
this._unloadData();
|
|
634
488
|
}
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
}, {
|
|
638
|
-
key: "_invalidateQueryResult",
|
|
639
|
-
value: function _invalidateQueryResult() {
|
|
640
|
-
if (this.isDataLoaded) {
|
|
641
|
-
this._unloadData();
|
|
642
|
-
}
|
|
643
|
-
if (this._cellValuesWatchCount > 0) {
|
|
644
|
-
this._unwatchLinkedQueryCellValues();
|
|
645
|
-
}
|
|
646
|
-
for (var _i = 0, _Object$keys = Object.keys(this._cellValueWatchCountByFieldId); _i < _Object$keys.length; _i++) {
|
|
647
|
-
var fieldId = _Object$keys[_i];
|
|
648
|
-
this._unwatchLinkedQueryCellValuesInField(fieldId);
|
|
649
|
-
}
|
|
650
|
-
this._isValid = false;
|
|
651
|
-
this._onChange('records');
|
|
652
|
-
this._onChange('recordIds');
|
|
489
|
+
if (this._cellValuesWatchCount > 0) {
|
|
490
|
+
this._unwatchLinkedQueryCellValues();
|
|
653
491
|
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
}, {
|
|
657
|
-
key: "_invalidateComputedData",
|
|
658
|
-
value: function _invalidateComputedData() {
|
|
659
|
-
this._computedRecordIdsSet = null;
|
|
660
|
-
this._computedFilteredSortedRecordIds = null;
|
|
492
|
+
for (const fieldId of Object.keys(this._cellValueWatchCountByFieldId)) {
|
|
493
|
+
this._unwatchLinkedQueryCellValuesInField(fieldId);
|
|
661
494
|
}
|
|
495
|
+
this._isValid = false;
|
|
496
|
+
this._onChange('records');
|
|
497
|
+
this._onChange('recordIds');
|
|
498
|
+
}
|
|
662
499
|
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
500
|
+
/** @internal */
|
|
501
|
+
_invalidateComputedData() {
|
|
502
|
+
this._computedRecordIdsSet = null;
|
|
503
|
+
this._computedFilteredSortedRecordIds = null;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/** @internal */
|
|
507
|
+
_generateComputedDataIfNeeded() {
|
|
508
|
+
if (!this._computedRecordIdsSet) {
|
|
509
|
+
this._generateComputedData();
|
|
670
510
|
}
|
|
511
|
+
}
|
|
671
512
|
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
(0, _error_utils.invariant)(
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
// We need to use the query result as the source of truth for
|
|
690
|
-
// recordIds, since when the client deletes a record from the linked
|
|
691
|
-
// table, we update it optimistically but the origin cell value
|
|
692
|
-
// doesn't update until receiving the push payload.
|
|
693
|
-
if (this._linkedQueryResult.hasRecord(recordId)) {
|
|
694
|
-
recordIdsSet[recordId] = true;
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
} catch (err) {
|
|
698
|
-
_iterator5.e(err);
|
|
699
|
-
} finally {
|
|
700
|
-
_iterator5.f();
|
|
701
|
-
}
|
|
702
|
-
this._computedRecordIdsSet = recordIdsSet;
|
|
703
|
-
if (this._normalizedOpts.sorts && this._normalizedOpts.sorts.length) {
|
|
704
|
-
// when sorts are present, record order comes from the query result
|
|
705
|
-
this._computedFilteredSortedRecordIds = this._linkedQueryResult.recordIds.filter(recordId => recordIdsSet[recordId] === true);
|
|
706
|
-
} else {
|
|
707
|
-
// with no sorts, record order is the same as in the cell in the
|
|
708
|
-
// main Airtable UI. Since we generated recordIdsSet by iterating
|
|
709
|
-
// over the cell value, we're guaranteed that the key order matches
|
|
710
|
-
// the linked record order in the cell.
|
|
711
|
-
this._computedFilteredSortedRecordIds = Object.keys(recordIdsSet);
|
|
513
|
+
/** @internal */
|
|
514
|
+
_generateComputedData() {
|
|
515
|
+
const recordIdsSet = {};
|
|
516
|
+
const rawCellValue = this._record.getCellValue(this._field);
|
|
517
|
+
const cellValue = rawCellValue === null ? [] : rawCellValue;
|
|
518
|
+
(0, _error_utils.invariant)(Array.isArray(cellValue), 'cellValue should be array');
|
|
519
|
+
for (const linkedRecord of cellValue) {
|
|
520
|
+
(0, _error_utils.invariant)(linkedRecord && typeof linkedRecord === 'object', 'linked record should be object');
|
|
521
|
+
const recordId = linkedRecord.id;
|
|
522
|
+
(0, _error_utils.invariant)(typeof recordId === 'string', 'id should be present');
|
|
523
|
+
|
|
524
|
+
// We need to use the query result as the source of truth for
|
|
525
|
+
// recordIds, since when the client deletes a record from the linked
|
|
526
|
+
// table, we update it optimistically but the origin cell value
|
|
527
|
+
// doesn't update until receiving the push payload.
|
|
528
|
+
if (this._linkedQueryResult.hasRecord(recordId)) {
|
|
529
|
+
recordIdsSet[recordId] = true;
|
|
712
530
|
}
|
|
713
531
|
}
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
532
|
+
this._computedRecordIdsSet = recordIdsSet;
|
|
533
|
+
if (this._normalizedOpts.sorts && this._normalizedOpts.sorts.length) {
|
|
534
|
+
// when sorts are present, record order comes from the query result
|
|
535
|
+
this._computedFilteredSortedRecordIds = this._linkedQueryResult.recordIds.filter(recordId => recordIdsSet[recordId] === true);
|
|
536
|
+
} else {
|
|
537
|
+
// with no sorts, record order is the same as in the cell in the
|
|
538
|
+
// main Airtable UI. Since we generated recordIdsSet by iterating
|
|
539
|
+
// over the cell value, we're guaranteed that the key order matches
|
|
540
|
+
// the linked record order in the cell.
|
|
541
|
+
this._computedFilteredSortedRecordIds = Object.keys(recordIdsSet);
|
|
723
542
|
}
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
/** @internal */
|
|
727
|
-
(
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
/** @internal */
|
|
546
|
+
_getOrGenerateRecordIdsSet() {
|
|
547
|
+
this._generateComputedDataIfNeeded();
|
|
548
|
+
const recordIdsSet = this._computedRecordIdsSet;
|
|
549
|
+
(0, _error_utils.invariant)(recordIdsSet, 'recordIdsSet must exist');
|
|
550
|
+
return recordIdsSet;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
728
553
|
var _default = exports.default = LinkedRecordsQueryResult;
|