@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,35 +1,9 @@
|
|
|
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.filter.js");
|
|
6
|
-
require("core-js/modules/es.array.from.js");
|
|
7
|
-
require("core-js/modules/es.array.iterator.js");
|
|
8
|
-
require("core-js/modules/es.array.slice.js");
|
|
9
|
-
require("core-js/modules/es.object.get-own-property-descriptors.js");
|
|
10
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
11
|
-
require("core-js/modules/es.regexp.to-string.js");
|
|
12
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
13
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
14
3
|
Object.defineProperty(exports, "__esModule", {
|
|
15
4
|
value: true
|
|
16
5
|
});
|
|
17
6
|
exports.default = exports.WatchableTableKeys = void 0;
|
|
18
|
-
require("core-js/modules/es.array.find.js");
|
|
19
|
-
require("core-js/modules/es.array.includes.js");
|
|
20
|
-
require("core-js/modules/es.object.to-string.js");
|
|
21
|
-
require("core-js/modules/es.string.includes.js");
|
|
22
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
|
23
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
24
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
25
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
26
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
27
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
28
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
29
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
30
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
31
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
32
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
33
7
|
var _table_core = require("../../shared/models/table_core");
|
|
34
8
|
var _error_utils = require("../../shared/error_utils");
|
|
35
9
|
var _private_utils = require("../../shared/private_utils");
|
|
@@ -39,18 +13,15 @@ var _field = _interopRequireDefault(require("./field"));
|
|
|
39
13
|
var _table_or_view_query_result = _interopRequireDefault(require("./table_or_view_query_result"));
|
|
40
14
|
var _view = _interopRequireDefault(require("./view"));
|
|
41
15
|
var _object_pool = _interopRequireDefault(require("./object_pool"));
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
46
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
47
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
48
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /** @module @airtable/blocks/models: Table */ /** */
|
|
16
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
+
/** @module @airtable/blocks/models: Table */ /** */
|
|
18
|
+
|
|
49
19
|
// This doesn't follow our enum naming conventions because we want the keys
|
|
50
20
|
// to mirror the method/getter names on the model class.
|
|
51
|
-
|
|
21
|
+
const WatchableTableKeys = exports.WatchableTableKeys = Object.freeze({
|
|
22
|
+
..._table_core.WatchableTableKeysCore,
|
|
52
23
|
views: 'views'
|
|
53
|
-
})
|
|
24
|
+
});
|
|
54
25
|
|
|
55
26
|
/**
|
|
56
27
|
* A key in {@link Table} that can be watched.
|
|
@@ -59,610 +30,491 @@ var WatchableTableKeys = exports.WatchableTableKeys = Object.freeze(_objectSprea
|
|
|
59
30
|
* - `fields`
|
|
60
31
|
* - `views`
|
|
61
32
|
*/
|
|
33
|
+
|
|
62
34
|
/**
|
|
63
35
|
* Model class representing a table. Every {@link Base} has one or more tables.
|
|
64
36
|
*
|
|
65
37
|
* @docsPath models/Table
|
|
66
38
|
*/
|
|
67
|
-
|
|
39
|
+
class Table extends _table_core.TableCore {
|
|
40
|
+
/** @internal */
|
|
41
|
+
static _className = 'Table';
|
|
68
42
|
/** @internal */
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
(0, _classCallCheck2.default)(this, Table);
|
|
72
|
-
_this = _callSuper(this, Table, [parentBase, recordStore, tableId, sdk]);
|
|
73
|
-
/** @internal */
|
|
74
|
-
(0, _defineProperty2.default)(_this, "_viewModelsById", void 0);
|
|
75
|
-
/** @internal */
|
|
76
|
-
(0, _defineProperty2.default)(_this, "__tableOrViewQueryResultPool", void 0);
|
|
77
|
-
_this._viewModelsById = {}; // View instances are lazily created by getViewById.
|
|
78
|
-
_this.__tableOrViewQueryResultPool = new _object_pool.default(_table_or_view_query_result.default);
|
|
79
|
-
return _this;
|
|
43
|
+
static _isWatchableKey(key) {
|
|
44
|
+
return (0, _private_utils.isEnumValue)(WatchableTableKeys, key);
|
|
80
45
|
}
|
|
46
|
+
/** @internal */
|
|
81
47
|
|
|
82
48
|
/** @internal */
|
|
83
|
-
(0, _inherits2.default)(Table, _TableCore);
|
|
84
|
-
return (0, _createClass2.default)(Table, [{
|
|
85
|
-
key: "_constructField",
|
|
86
|
-
value: function _constructField(fieldId) {
|
|
87
|
-
return new _field.default(this.parentBase.__sdk, this, fieldId);
|
|
88
|
-
}
|
|
89
49
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
* // => 'https://airtable.com/appxxxxxxxxxxxxxx/tblxxxxxxxxxxxxxx'
|
|
97
|
-
* ```
|
|
98
|
-
*/
|
|
99
|
-
}, {
|
|
100
|
-
key: "url",
|
|
101
|
-
get: function get() {
|
|
102
|
-
return this._sdk.__airtableInterface.urlConstructor.getTableUrl(this.id);
|
|
103
|
-
}
|
|
50
|
+
/** @internal */
|
|
51
|
+
constructor(parentBase, recordStore, tableId, sdk) {
|
|
52
|
+
super(parentBase, recordStore, tableId, sdk);
|
|
53
|
+
this._viewModelsById = {}; // View instances are lazily created by getViewById.
|
|
54
|
+
this.__tableOrViewQueryResultPool = new _object_pool.default(_table_or_view_query_result.default);
|
|
55
|
+
}
|
|
104
56
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
57
|
+
/** @internal */
|
|
58
|
+
_constructField(fieldId) {
|
|
59
|
+
return new _field.default(this.parentBase.__sdk, this, fieldId);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The URL for the table. You can visit this URL in the browser to be taken to the table in the Airtable UI.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```js
|
|
67
|
+
* console.log(myTable.url);
|
|
68
|
+
* // => 'https://airtable.com/appxxxxxxxxxxxxxx/tblxxxxxxxxxxxxxx'
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
get url() {
|
|
72
|
+
return this._sdk.__airtableInterface.urlConstructor.getTableUrl(this.id);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Experimental, do not document yet. Allows fetching default cell values for
|
|
76
|
+
// a table or view. Before documenting, we should explore making this synchronous.
|
|
77
|
+
/**
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
80
|
+
// istanbul ignore next
|
|
81
|
+
async getDefaultCellValuesByFieldIdAsync(opts) {
|
|
82
|
+
const viewId = opts && opts.view ? opts.view.id : null;
|
|
83
|
+
const cellValuesByFieldId = await this._sdk.__airtableInterface.fetchDefaultCellValuesByFieldIdAsync(this._id, viewId);
|
|
84
|
+
return cellValuesByFieldId;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The views in this table. Can be watched to know when views are created,
|
|
89
|
+
* deleted, or reordered.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```js
|
|
93
|
+
* console.log(`This table has ${myTable.views.length} views`);
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
get views() {
|
|
97
|
+
// TODO(kasra): cache and freeze this so it isn't O(n)
|
|
98
|
+
const views = [];
|
|
99
|
+
this._data.viewOrder.forEach(viewId => {
|
|
100
|
+
const view = this.getViewById(viewId);
|
|
101
|
+
views.push(view);
|
|
102
|
+
});
|
|
103
|
+
return views;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Gets the view matching the given ID, or `null` if that view does not exist in this table.
|
|
107
|
+
*
|
|
108
|
+
* @param viewId The ID of the view.
|
|
109
|
+
* @example
|
|
110
|
+
* ```js
|
|
111
|
+
* const viewId = 'viwxxxxxxxxxxxxxx';
|
|
112
|
+
* const view = myTable.getViewByIdIfExists(viewId);
|
|
113
|
+
* if (view !== null) {
|
|
114
|
+
* console.log(view.name);
|
|
115
|
+
* } else {
|
|
116
|
+
* console.log('No view exists with that ID');
|
|
117
|
+
* }
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
getViewByIdIfExists(viewId) {
|
|
121
|
+
if (!this._data.viewsById[viewId]) {
|
|
122
|
+
return null;
|
|
123
|
+
} else {
|
|
124
|
+
if (!this._viewModelsById[viewId]) {
|
|
125
|
+
this._viewModelsById[viewId] = new _view.default(this._sdk, this, this._recordStore.getViewDataStore(viewId), viewId);
|
|
133
126
|
}
|
|
134
|
-
return
|
|
135
|
-
}()
|
|
136
|
-
/**
|
|
137
|
-
* The views in this table. Can be watched to know when views are created,
|
|
138
|
-
* deleted, or reordered.
|
|
139
|
-
*
|
|
140
|
-
* @example
|
|
141
|
-
* ```js
|
|
142
|
-
* console.log(`This table has ${myTable.views.length} views`);
|
|
143
|
-
* ```
|
|
144
|
-
*/
|
|
145
|
-
}, {
|
|
146
|
-
key: "views",
|
|
147
|
-
get: function get() {
|
|
148
|
-
// TODO(kasra): cache and freeze this so it isn't O(n)
|
|
149
|
-
var views = [];
|
|
150
|
-
this._data.viewOrder.forEach(viewId => {
|
|
151
|
-
var view = this.getViewById(viewId);
|
|
152
|
-
views.push(view);
|
|
153
|
-
});
|
|
154
|
-
return views;
|
|
127
|
+
return this._viewModelsById[viewId];
|
|
155
128
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
return null;
|
|
176
|
-
} else {
|
|
177
|
-
if (!this._viewModelsById[viewId]) {
|
|
178
|
-
this._viewModelsById[viewId] = new _view.default(this._sdk, this, this._recordStore.getViewDataStore(viewId), viewId);
|
|
179
|
-
}
|
|
180
|
-
return this._viewModelsById[viewId];
|
|
181
|
-
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Gets the view matching the given ID. Throws if that view does not exist in this table. Use
|
|
132
|
+
* {@link getViewByIdIfExists} instead if you are unsure whether a view exists with the given
|
|
133
|
+
* ID.
|
|
134
|
+
*
|
|
135
|
+
* @param viewId The ID of the view.
|
|
136
|
+
* @example
|
|
137
|
+
* ```js
|
|
138
|
+
* const viewId = 'viwxxxxxxxxxxxxxx';
|
|
139
|
+
* const view = myTable.getViewById(viewId);
|
|
140
|
+
* console.log(view.name);
|
|
141
|
+
* // => 'Grid view'
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
getViewById(viewId) {
|
|
145
|
+
const view = this.getViewByIdIfExists(viewId);
|
|
146
|
+
if (!view) {
|
|
147
|
+
throw (0, _error_utils.spawnError)("No view with ID %s in table '%s'", viewId, this.name);
|
|
182
148
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
149
|
+
return view;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Gets the view matching the given name, or `null` if no view exists with that name in this
|
|
153
|
+
* table.
|
|
154
|
+
*
|
|
155
|
+
* @param viewName The name of the view you're looking for.
|
|
156
|
+
* @example
|
|
157
|
+
* ```js
|
|
158
|
+
* const view = myTable.getViewByNameIfExists('Name');
|
|
159
|
+
* if (view !== null) {
|
|
160
|
+
* console.log(view.id);
|
|
161
|
+
* } else {
|
|
162
|
+
* console.log('No view exists with that name');
|
|
163
|
+
* }
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
getViewByNameIfExists(viewName) {
|
|
167
|
+
for (const [viewId, viewData] of (0, _private_utils.entries)(this._data.viewsById)) {
|
|
168
|
+
if (viewData.name === viewName) {
|
|
169
|
+
return this.getViewByIdIfExists(viewId);
|
|
203
170
|
}
|
|
204
|
-
return view;
|
|
205
171
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
_step;
|
|
226
|
-
try {
|
|
227
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
228
|
-
var _step$value = (0, _slicedToArray2.default)(_step.value, 2),
|
|
229
|
-
viewId = _step$value[0],
|
|
230
|
-
viewData = _step$value[1];
|
|
231
|
-
if (viewData.name === viewName) {
|
|
232
|
-
return this.getViewByIdIfExists(viewId);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
} catch (err) {
|
|
236
|
-
_iterator.e(err);
|
|
237
|
-
} finally {
|
|
238
|
-
_iterator.f();
|
|
239
|
-
}
|
|
240
|
-
return null;
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Gets the view matching the given name. Throws if no view exists with that name in this table.
|
|
176
|
+
* Use {@link getViewByNameIfExists} instead if you are unsure whether a view exists with the
|
|
177
|
+
* given name.
|
|
178
|
+
*
|
|
179
|
+
* @param viewName The name of the view you're looking for.
|
|
180
|
+
* @example
|
|
181
|
+
* ```js
|
|
182
|
+
* const view = myTable.getViewByName('Name');
|
|
183
|
+
* console.log(view.id);
|
|
184
|
+
* // => 'viwxxxxxxxxxxxxxx'
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
getViewByName(viewName) {
|
|
188
|
+
const view = this.getViewByNameIfExists(viewName);
|
|
189
|
+
if (!view) {
|
|
190
|
+
throw (0, _error_utils.spawnError)("No view named '%s' in table '%s'", viewName, this.name);
|
|
241
191
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
192
|
+
return view;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* The view matching the given ID or name. Returns `null` if no matching view exists within
|
|
196
|
+
* this table.
|
|
197
|
+
*
|
|
198
|
+
* This method is convenient when building an extension for a specific base, but for more generic
|
|
199
|
+
* extensions the best practice is to use the {@link getViewByIdIfExists} or
|
|
200
|
+
* {@link getViewByNameIfExists} methods instead.
|
|
201
|
+
*
|
|
202
|
+
* @param viewIdOrName The ID or name of the view you're looking for.
|
|
203
|
+
*/
|
|
204
|
+
getViewIfExists(viewIdOrName) {
|
|
205
|
+
return this.getViewByIdIfExists(viewIdOrName) ?? this.getViewByNameIfExists(viewIdOrName);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* The view matching the given ID or name. Throws if no matching view exists within this table.
|
|
209
|
+
* Use {@link getViewIfExists} instead if you are unsure whether a view exists with the given
|
|
210
|
+
* name/ID.
|
|
211
|
+
*
|
|
212
|
+
* This method is convenient when building an extension for a specific base, but for more generic
|
|
213
|
+
* extensions the best practice is to use the {@link getViewById} or {@link getViewByName} methods
|
|
214
|
+
* instead.
|
|
215
|
+
*
|
|
216
|
+
* @param viewIdOrName The ID or name of the view you're looking for.
|
|
217
|
+
*/
|
|
218
|
+
getView(viewIdOrName) {
|
|
219
|
+
const view = this.getViewIfExists(viewIdOrName);
|
|
220
|
+
if (!view) {
|
|
221
|
+
throw (0, _error_utils.spawnError)("No view with ID or name '%s' in table '%s'", viewIdOrName, this.name);
|
|
263
222
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
223
|
+
return view;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Select records from the table. Returns a {@link RecordQueryResult}.
|
|
227
|
+
*
|
|
228
|
+
* Consider using {@link useRecords} or {@link useRecordIds} instead, unless you need the
|
|
229
|
+
* features of a QueryResult (e.g. `queryResult.getRecordById`). Record hooks handle
|
|
230
|
+
* loading/unloading and updating your UI automatically, but manually `select`ing records is
|
|
231
|
+
* useful for one-off data processing.
|
|
232
|
+
*
|
|
233
|
+
* @param opts Options for the query, such as sorts and fields.
|
|
234
|
+
* @example
|
|
235
|
+
* ```js
|
|
236
|
+
* import {useBase, useRecords} from '@airtable/blocks/base/ui';
|
|
237
|
+
* import React from 'react';
|
|
238
|
+
*
|
|
239
|
+
* function TodoList() {
|
|
240
|
+
* const base = useBase();
|
|
241
|
+
* const table = base.getTableByName('Tasks');
|
|
242
|
+
*
|
|
243
|
+
* const queryResult = table.selectRecords();
|
|
244
|
+
* const records = useRecords(queryResult);
|
|
245
|
+
*
|
|
246
|
+
* return (
|
|
247
|
+
* <ul>
|
|
248
|
+
* {records.map(record => (
|
|
249
|
+
* <li key={record.id}>
|
|
250
|
+
* {record.name || 'Unnamed record'}
|
|
251
|
+
* </li>
|
|
252
|
+
* ))}
|
|
253
|
+
* </ul>
|
|
254
|
+
* );
|
|
255
|
+
* }
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
selectRecords(opts) {
|
|
259
|
+
const normalizedOpts = _record_query_result.default._normalizeOpts(this, this._recordStore, opts || {});
|
|
260
|
+
return this.__tableOrViewQueryResultPool.getObjectForReuse(this._sdk, this, normalizedOpts);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Select and load records from the table. Returns a {@link RecordQueryResult} promise where
|
|
264
|
+
* record data has been loaded.
|
|
265
|
+
*
|
|
266
|
+
* Consider using {@link useRecords} or {@link useRecordIds} instead, unless you need the
|
|
267
|
+
* features of a QueryResult (e.g. `queryResult.getRecordById`). Record hooks handle
|
|
268
|
+
* loading/unloading and updating your UI automatically, but manually `select`ing records is
|
|
269
|
+
* useful for one-off data processing.
|
|
270
|
+
*
|
|
271
|
+
* Once you've finished with your query, remember to call `queryResult.unloadData()`.
|
|
272
|
+
*
|
|
273
|
+
* @param opts Options for the query, such as sorts and fields.
|
|
274
|
+
* @example
|
|
275
|
+
* ```js
|
|
276
|
+
* async function logRecordCountAsync(table) {
|
|
277
|
+
* const query = await table.selectRecordsAsync();
|
|
278
|
+
* console.log(query.recordIds.length);
|
|
279
|
+
* query.unloadData();
|
|
280
|
+
* }
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
async selectRecordsAsync(opts) {
|
|
284
|
+
const queryResult = this.selectRecords(opts);
|
|
285
|
+
await queryResult.loadDataAsync();
|
|
286
|
+
return queryResult;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Returns the first view in the table where the type is one of `allowedViewTypes`, or `null` if
|
|
290
|
+
* no such view exists in the table.
|
|
291
|
+
*
|
|
292
|
+
* @param allowedViewTypes An array of view types or a single view type to match against.
|
|
293
|
+
* @param preferredViewOrViewId If a view or view ID is supplied and that view exists & has the
|
|
294
|
+
* correct type, that view will be returned before checking the other views in the table.
|
|
295
|
+
* @example
|
|
296
|
+
* ```js
|
|
297
|
+
* import {ViewType} from '@airtable/blocks/base/models';
|
|
298
|
+
* const firstCalendarView = myTable.getFirstViewOfType(ViewType.CALENDAR);
|
|
299
|
+
* if (firstCalendarView !== null) {
|
|
300
|
+
* console.log(firstCalendarView.name);
|
|
301
|
+
* } else {
|
|
302
|
+
* console.log('No calendar views exist in the table');
|
|
303
|
+
* }
|
|
304
|
+
* ```
|
|
305
|
+
*/
|
|
306
|
+
getFirstViewOfType(allowedViewTypes, preferredViewOrViewId) {
|
|
307
|
+
if (!Array.isArray(allowedViewTypes)) {
|
|
308
|
+
allowedViewTypes = (0, _private_utils.cast)([allowedViewTypes]);
|
|
279
309
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
*
|
|
285
|
-
* This method is convenient when building an extension for a specific base, but for more generic
|
|
286
|
-
* extensions the best practice is to use the {@link getViewById} or {@link getViewByName} methods
|
|
287
|
-
* instead.
|
|
288
|
-
*
|
|
289
|
-
* @param viewIdOrName The ID or name of the view you're looking for.
|
|
290
|
-
*/
|
|
291
|
-
}, {
|
|
292
|
-
key: "getView",
|
|
293
|
-
value: function getView(viewIdOrName) {
|
|
294
|
-
var view = this.getViewIfExists(viewIdOrName);
|
|
295
|
-
if (!view) {
|
|
296
|
-
throw (0, _error_utils.spawnError)("No view with ID or name '%s' in table '%s'", viewIdOrName, this.name);
|
|
310
|
+
if (preferredViewOrViewId) {
|
|
311
|
+
const preferredView = this.getViewByIdIfExists(typeof preferredViewOrViewId === 'string' ? preferredViewOrViewId : preferredViewOrViewId.id);
|
|
312
|
+
if (preferredView && allowedViewTypes.includes(preferredView.type)) {
|
|
313
|
+
return preferredView;
|
|
297
314
|
}
|
|
298
|
-
return view;
|
|
299
315
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
* import React from 'react';
|
|
313
|
-
*
|
|
314
|
-
* function TodoList() {
|
|
315
|
-
* const base = useBase();
|
|
316
|
-
* const table = base.getTableByName('Tasks');
|
|
317
|
-
*
|
|
318
|
-
* const queryResult = table.selectRecords();
|
|
319
|
-
* const records = useRecords(queryResult);
|
|
320
|
-
*
|
|
321
|
-
* return (
|
|
322
|
-
* <ul>
|
|
323
|
-
* {records.map(record => (
|
|
324
|
-
* <li key={record.id}>
|
|
325
|
-
* {record.name || 'Unnamed record'}
|
|
326
|
-
* </li>
|
|
327
|
-
* ))}
|
|
328
|
-
* </ul>
|
|
329
|
-
* );
|
|
330
|
-
* }
|
|
331
|
-
* ```
|
|
332
|
-
*/
|
|
333
|
-
}, {
|
|
334
|
-
key: "selectRecords",
|
|
335
|
-
value: function selectRecords(opts) {
|
|
336
|
-
var normalizedOpts = _record_query_result.default._normalizeOpts(this, this._recordStore, opts || {});
|
|
337
|
-
return this.__tableOrViewQueryResultPool.getObjectForReuse(this._sdk, this, normalizedOpts);
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* Select and load records from the table. Returns a {@link RecordQueryResult} promise where
|
|
341
|
-
* record data has been loaded.
|
|
342
|
-
*
|
|
343
|
-
* Consider using {@link useRecords} or {@link useRecordIds} instead, unless you need the
|
|
344
|
-
* features of a QueryResult (e.g. `queryResult.getRecordById`). Record hooks handle
|
|
345
|
-
* loading/unloading and updating your UI automatically, but manually `select`ing records is
|
|
346
|
-
* useful for one-off data processing.
|
|
347
|
-
*
|
|
348
|
-
* Once you've finished with your query, remember to call `queryResult.unloadData()`.
|
|
349
|
-
*
|
|
350
|
-
* @param opts Options for the query, such as sorts and fields.
|
|
351
|
-
* @example
|
|
352
|
-
* ```js
|
|
353
|
-
* async function logRecordCountAsync(table) {
|
|
354
|
-
* const query = await table.selectRecordsAsync();
|
|
355
|
-
* console.log(query.recordIds.length);
|
|
356
|
-
* query.unloadData();
|
|
357
|
-
* }
|
|
358
|
-
* ```
|
|
359
|
-
*/
|
|
360
|
-
}, {
|
|
361
|
-
key: "selectRecordsAsync",
|
|
362
|
-
value: (function () {
|
|
363
|
-
var _selectRecordsAsync = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(opts) {
|
|
364
|
-
var queryResult;
|
|
365
|
-
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
366
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
367
|
-
case 0:
|
|
368
|
-
queryResult = this.selectRecords(opts);
|
|
369
|
-
_context2.next = 3;
|
|
370
|
-
return queryResult.loadDataAsync();
|
|
371
|
-
case 3:
|
|
372
|
-
return _context2.abrupt("return", queryResult);
|
|
373
|
-
case 4:
|
|
374
|
-
case "end":
|
|
375
|
-
return _context2.stop();
|
|
376
|
-
}
|
|
377
|
-
}, _callee2, this);
|
|
378
|
-
}));
|
|
379
|
-
function selectRecordsAsync(_x2) {
|
|
380
|
-
return _selectRecordsAsync.apply(this, arguments);
|
|
316
|
+
return this.views.find(view => {
|
|
317
|
+
return allowedViewTypes.includes(view.type);
|
|
318
|
+
}) ?? null;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* @internal
|
|
322
|
+
*/
|
|
323
|
+
__getViewMatching(viewOrViewIdOrViewName) {
|
|
324
|
+
let view;
|
|
325
|
+
if (viewOrViewIdOrViewName instanceof _view.default) {
|
|
326
|
+
if (viewOrViewIdOrViewName.parentTable.id !== this.id) {
|
|
327
|
+
throw (0, _error_utils.spawnError)("View '%s' is from a different table than table '%s'", viewOrViewIdOrViewName.name, this.name);
|
|
381
328
|
}
|
|
382
|
-
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
*
|
|
388
|
-
* @param allowedViewTypes An array of view types or a single view type to match against.
|
|
389
|
-
* @param preferredViewOrViewId If a view or view ID is supplied and that view exists & has the
|
|
390
|
-
* correct type, that view will be returned before checking the other views in the table.
|
|
391
|
-
* @example
|
|
392
|
-
* ```js
|
|
393
|
-
* import {ViewType} from '@airtable/blocks/base/models';
|
|
394
|
-
* const firstCalendarView = myTable.getFirstViewOfType(ViewType.CALENDAR);
|
|
395
|
-
* if (firstCalendarView !== null) {
|
|
396
|
-
* console.log(firstCalendarView.name);
|
|
397
|
-
* } else {
|
|
398
|
-
* console.log('No calendar views exist in the table');
|
|
399
|
-
* }
|
|
400
|
-
* ```
|
|
401
|
-
*/
|
|
402
|
-
)
|
|
403
|
-
}, {
|
|
404
|
-
key: "getFirstViewOfType",
|
|
405
|
-
value: function getFirstViewOfType(allowedViewTypes, preferredViewOrViewId) {
|
|
406
|
-
var _this$views$find;
|
|
407
|
-
if (!Array.isArray(allowedViewTypes)) {
|
|
408
|
-
allowedViewTypes = (0, _private_utils.cast)([allowedViewTypes]);
|
|
329
|
+
view = viewOrViewIdOrViewName;
|
|
330
|
+
} else {
|
|
331
|
+
view = this.getViewByIdIfExists(viewOrViewIdOrViewName) || this.getViewByNameIfExists(viewOrViewIdOrViewName);
|
|
332
|
+
if (view === null) {
|
|
333
|
+
throw (0, _error_utils.spawnError)("View '%s' does not exist in table '%s'", viewOrViewIdOrViewName, this.name);
|
|
409
334
|
}
|
|
410
|
-
if (preferredViewOrViewId) {
|
|
411
|
-
var preferredView = this.getViewByIdIfExists(typeof preferredViewOrViewId === 'string' ? preferredViewOrViewId : preferredViewOrViewId.id);
|
|
412
|
-
if (preferredView && allowedViewTypes.includes(preferredView.type)) {
|
|
413
|
-
return preferredView;
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
return (_this$views$find = this.views.find(view => {
|
|
417
|
-
return allowedViewTypes.includes(view.type);
|
|
418
|
-
})) !== null && _this$views$find !== void 0 ? _this$views$find : null;
|
|
419
335
|
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
*/
|
|
423
|
-
}, {
|
|
424
|
-
key: "__getViewMatching",
|
|
425
|
-
value: function __getViewMatching(viewOrViewIdOrViewName) {
|
|
426
|
-
var view;
|
|
427
|
-
if (viewOrViewIdOrViewName instanceof _view.default) {
|
|
428
|
-
if (viewOrViewIdOrViewName.parentTable.id !== this.id) {
|
|
429
|
-
throw (0, _error_utils.spawnError)("View '%s' is from a different table than table '%s'", viewOrViewIdOrViewName.name, this.name);
|
|
430
|
-
}
|
|
431
|
-
view = viewOrViewIdOrViewName;
|
|
432
|
-
} else {
|
|
433
|
-
view = this.getViewByIdIfExists(viewOrViewIdOrViewName) || this.getViewByNameIfExists(viewOrViewIdOrViewName);
|
|
434
|
-
if (view === null) {
|
|
435
|
-
throw (0, _error_utils.spawnError)("View '%s' does not exist in table '%s'", viewOrViewIdOrViewName, this.name);
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
if (view.isDeleted) {
|
|
439
|
-
throw (0, _error_utils.spawnError)("View '%s' was deleted from table '%s'", view.name, this.name);
|
|
440
|
-
}
|
|
441
|
-
return view;
|
|
336
|
+
if (view.isDeleted) {
|
|
337
|
+
throw (0, _error_utils.spawnError)("View '%s' was deleted from table '%s'", view.name, this.name);
|
|
442
338
|
}
|
|
339
|
+
return view;
|
|
340
|
+
}
|
|
443
341
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
342
|
+
/**
|
|
343
|
+
* Checks whether the current user has permission to create a field in this table.
|
|
344
|
+
*
|
|
345
|
+
* Accepts partial input, in the same format as {@link createFieldAsync}.
|
|
346
|
+
*
|
|
347
|
+
* Returns `{hasPermission: true}` if the current user can update the specified record,
|
|
348
|
+
* `{hasPermission: false, reasonDisplayString: string}` otherwise. `reasonDisplayString` may be
|
|
349
|
+
* used to display an error message to the user.
|
|
350
|
+
*
|
|
351
|
+
* @param name name for the field. must be case-insensitive unique for the table
|
|
352
|
+
* @param type type for the field
|
|
353
|
+
* @param options options for the field. omit for fields without writable options
|
|
354
|
+
* @param description description for the field. omit to leave blank
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* ```js
|
|
358
|
+
* const createFieldCheckResult = table.checkPermissionsForCreateField();
|
|
359
|
+
*
|
|
360
|
+
* if (!createFieldCheckResult.hasPermission) {
|
|
361
|
+
* alert(createFieldCheckResult.reasonDisplayString);
|
|
362
|
+
* }
|
|
363
|
+
* ```
|
|
364
|
+
*/
|
|
365
|
+
checkPermissionsForCreateField(name, type, options, description) {
|
|
366
|
+
return this._sdk.__mutations.checkPermissionsForMutation({
|
|
367
|
+
type: _mutations.MutationTypes.CREATE_SINGLE_FIELD,
|
|
368
|
+
tableId: this.id,
|
|
369
|
+
id: undefined,
|
|
370
|
+
// Generated in createFieldAsync.
|
|
371
|
+
name,
|
|
372
|
+
config: type ? {
|
|
373
|
+
type: type,
|
|
374
|
+
// In field.options we translate options to null when it's undefined (no options),
|
|
375
|
+
// but the mutation expects config to match the PublicApiConfig, where it's
|
|
376
|
+
// not present at all (options: undefined will fail validation).
|
|
377
|
+
...(options ? {
|
|
479
378
|
options
|
|
480
|
-
} : null)
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
}
|
|
379
|
+
} : null)
|
|
380
|
+
} : undefined,
|
|
381
|
+
description
|
|
382
|
+
});
|
|
383
|
+
}
|
|
484
384
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
return this.checkPermissionsForCreateField(name, type, options, description).hasPermission;
|
|
510
|
-
}
|
|
385
|
+
/**
|
|
386
|
+
* An alias for `checkPermissionsForCreateField(name, type, options, description).hasPermission`.
|
|
387
|
+
*
|
|
388
|
+
* Checks whether the current user has permission to create a field in this table.
|
|
389
|
+
*
|
|
390
|
+
* Accepts partial input, in the same format as {@link createFieldAsync}.
|
|
391
|
+
*
|
|
392
|
+
* @param name name for the field. must be case-insensitive unique for the table
|
|
393
|
+
* @param type type for the field
|
|
394
|
+
* @param options options for the field. omit for fields without writable options
|
|
395
|
+
* @param description description for the field. omit to leave blank
|
|
396
|
+
*
|
|
397
|
+
* @example
|
|
398
|
+
* ```js
|
|
399
|
+
* const canCreateField = table.hasPermissionToCreateField();
|
|
400
|
+
*
|
|
401
|
+
* if (!canCreateField) {
|
|
402
|
+
* alert('not allowed!');
|
|
403
|
+
* }
|
|
404
|
+
* ```
|
|
405
|
+
*/
|
|
406
|
+
hasPermissionToCreateField(name, type, options, description) {
|
|
407
|
+
return this.checkPermissionsForCreateField(name, type, options, description).hasPermission;
|
|
408
|
+
}
|
|
511
409
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
description: description !== null && description !== void 0 ? description : null
|
|
588
|
-
});
|
|
589
|
-
case 3:
|
|
590
|
-
return _context3.abrupt("return", this.getFieldById(fieldId));
|
|
591
|
-
case 4:
|
|
592
|
-
case "end":
|
|
593
|
-
return _context3.stop();
|
|
594
|
-
}
|
|
595
|
-
}, _callee3, this);
|
|
596
|
-
}));
|
|
597
|
-
function createFieldAsync(_x3, _x4, _x5, _x6) {
|
|
598
|
-
return _createFieldAsync.apply(this, arguments);
|
|
599
|
-
}
|
|
600
|
-
return createFieldAsync;
|
|
601
|
-
}() /** @internal */)
|
|
602
|
-
}, {
|
|
603
|
-
key: "__triggerOnChangeForDirtyPaths",
|
|
604
|
-
value: function __triggerOnChangeForDirtyPaths(dirtyPaths) {
|
|
605
|
-
var didTableSchemaChange = false;
|
|
606
|
-
if ((0, _get2.default)((0, _getPrototypeOf2.default)(Table.prototype), "__triggerOnChangeForDirtyPaths", this).call(this, dirtyPaths)) {
|
|
607
|
-
didTableSchemaChange = true;
|
|
608
|
-
}
|
|
609
|
-
if (dirtyPaths.viewOrder) {
|
|
610
|
-
this._onChange(WatchableTableKeys.views);
|
|
611
|
-
didTableSchemaChange = true;
|
|
410
|
+
/**
|
|
411
|
+
* Creates a new field.
|
|
412
|
+
*
|
|
413
|
+
* Similar to creating a field from the Airtable UI, the new field will not be visible
|
|
414
|
+
* in views that have other hidden fields and views that are publicly shared.
|
|
415
|
+
*
|
|
416
|
+
* Throws an error if the user does not have permission to create a field, if invalid
|
|
417
|
+
* name, type or options are provided, or if creating fields of this type is not supported.
|
|
418
|
+
*
|
|
419
|
+
* Refer to {@link FieldType} for supported field types, the write format for options, and
|
|
420
|
+
* other specifics for certain field types.
|
|
421
|
+
*
|
|
422
|
+
* This action is asynchronous. Unlike new records, new fields are **not** created
|
|
423
|
+
* optimistically locally. You must `await` the returned promise before using the new
|
|
424
|
+
* field in your extension.
|
|
425
|
+
*
|
|
426
|
+
* @param name name for the field. must be case-insensitive unique
|
|
427
|
+
* @param type type for the field
|
|
428
|
+
* @param options options for the field. omit for fields without writable options
|
|
429
|
+
* @param description description for the field. is optional and will be `''` if not specified
|
|
430
|
+
* or if specified as `null`.
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* ```js
|
|
434
|
+
* async function createNewSingleLineTextField(table, name) {
|
|
435
|
+
* if (table.hasPermissionToCreateField(name, FieldType.SINGLE_LINE_TEXT)) {
|
|
436
|
+
* await table.createFieldAsync(name, FieldType.SINGLE_LINE_TEXT);
|
|
437
|
+
* }
|
|
438
|
+
* }
|
|
439
|
+
*
|
|
440
|
+
* async function createNewCheckboxField(table, name) {
|
|
441
|
+
* const options = {
|
|
442
|
+
* icon: 'check',
|
|
443
|
+
* color: 'greenBright',
|
|
444
|
+
* };
|
|
445
|
+
* if (table.hasPermissionToCreateField(name, FieldType.CHECKBOX, options)) {
|
|
446
|
+
* await table.createFieldAsync(name, FieldType.CHECKBOX, options);
|
|
447
|
+
* }
|
|
448
|
+
* }
|
|
449
|
+
*
|
|
450
|
+
* async function createNewDateField(table, name) {
|
|
451
|
+
* const options = {
|
|
452
|
+
* dateFormat: {
|
|
453
|
+
* name: 'iso',
|
|
454
|
+
* },
|
|
455
|
+
* };
|
|
456
|
+
* if (table.hasPermissionToCreateField(name, FieldType.DATE, options)) {
|
|
457
|
+
* await table.createFieldAsync(name, FieldType.DATE, options);
|
|
458
|
+
* }
|
|
459
|
+
* }
|
|
460
|
+
* ```
|
|
461
|
+
*/
|
|
462
|
+
async createFieldAsync(name, type, options, description) {
|
|
463
|
+
const fieldId = this._sdk.__airtableInterface.idGenerator.generateFieldId();
|
|
464
|
+
await this._sdk.__mutations.applyMutationAsync({
|
|
465
|
+
type: _mutations.MutationTypes.CREATE_SINGLE_FIELD,
|
|
466
|
+
tableId: this.id,
|
|
467
|
+
id: fieldId,
|
|
468
|
+
name,
|
|
469
|
+
config: {
|
|
470
|
+
type: type,
|
|
471
|
+
// In field.options we translate options to null when it's undefined (no options),
|
|
472
|
+
// but the mutation expects config to match the PublicApiConfig, where it's
|
|
473
|
+
// not present at all (options: undefined will fail validation).
|
|
474
|
+
...(options ? {
|
|
475
|
+
options
|
|
476
|
+
} : null)
|
|
477
|
+
},
|
|
478
|
+
// Coerce undefined to null so that only old SDKs pass "undefined" for description
|
|
479
|
+
// '' is permitted, as we already set empty descriptions to '' when editing descriptions
|
|
480
|
+
// from the UI
|
|
481
|
+
description: description ?? null
|
|
482
|
+
});
|
|
483
|
+
return this.getFieldById(fieldId);
|
|
484
|
+
}
|
|
612
485
|
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
} finally {
|
|
628
|
-
_iterator2.f();
|
|
486
|
+
/** @internal */
|
|
487
|
+
__triggerOnChangeForDirtyPaths(dirtyPaths) {
|
|
488
|
+
let didTableSchemaChange = false;
|
|
489
|
+
if (super.__triggerOnChangeForDirtyPaths(dirtyPaths)) {
|
|
490
|
+
didTableSchemaChange = true;
|
|
491
|
+
}
|
|
492
|
+
if (dirtyPaths.viewOrder) {
|
|
493
|
+
this._onChange(WatchableTableKeys.views);
|
|
494
|
+
didTableSchemaChange = true;
|
|
495
|
+
|
|
496
|
+
// Clean up deleted views
|
|
497
|
+
for (const [viewId, viewModel] of (0, _private_utils.entries)(this._viewModelsById)) {
|
|
498
|
+
if (viewModel.isDeleted) {
|
|
499
|
+
delete this._viewModelsById[viewId];
|
|
629
500
|
}
|
|
630
501
|
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
var view = this._viewModelsById[_viewId];
|
|
643
|
-
if (view) {
|
|
644
|
-
var didViewSchemaChange = view.__triggerOnChangeForDirtyPaths(dirtyViewPaths);
|
|
645
|
-
if (didViewSchemaChange) {
|
|
646
|
-
didTableSchemaChange = true;
|
|
647
|
-
}
|
|
648
|
-
}
|
|
502
|
+
}
|
|
503
|
+
if (dirtyPaths.viewsById) {
|
|
504
|
+
for (const [viewId, dirtyViewPaths] of (0, _private_utils.entries)(dirtyPaths.viewsById)) {
|
|
505
|
+
// Directly access from _viewModelsById to avoid creating
|
|
506
|
+
// a view model if it doesn't already exist. If it doesn't exist,
|
|
507
|
+
// nothing can be subscribed to any events on it.
|
|
508
|
+
const view = this._viewModelsById[viewId];
|
|
509
|
+
if (view) {
|
|
510
|
+
const didViewSchemaChange = view.__triggerOnChangeForDirtyPaths(dirtyViewPaths);
|
|
511
|
+
if (didViewSchemaChange) {
|
|
512
|
+
didTableSchemaChange = true;
|
|
649
513
|
}
|
|
650
|
-
} catch (err) {
|
|
651
|
-
_iterator3.e(err);
|
|
652
|
-
} finally {
|
|
653
|
-
_iterator3.f();
|
|
654
514
|
}
|
|
655
515
|
}
|
|
656
|
-
return didTableSchemaChange;
|
|
657
|
-
}
|
|
658
|
-
}], [{
|
|
659
|
-
key: "_isWatchableKey",
|
|
660
|
-
value: /** @internal */
|
|
661
|
-
function _isWatchableKey(key) {
|
|
662
|
-
return (0, _private_utils.isEnumValue)(WatchableTableKeys, key);
|
|
663
516
|
}
|
|
664
|
-
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
(0, _defineProperty2.default)(Table, "_className", 'Table');
|
|
517
|
+
return didTableSchemaChange;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
668
520
|
var _default = exports.default = Table;
|