@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,42 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.symbol.js");
|
|
4
|
-
require("core-js/modules/es.symbol.description.js");
|
|
5
|
-
require("core-js/modules/es.array.from.js");
|
|
6
|
-
require("core-js/modules/es.array.iterator.js");
|
|
7
|
-
require("core-js/modules/es.array.slice.js");
|
|
8
|
-
require("core-js/modules/es.object.get-own-property-descriptors.js");
|
|
9
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
10
|
-
require("core-js/modules/es.regexp.to-string.js");
|
|
11
|
-
require("core-js/modules/es.weak-map.js");
|
|
12
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
|
13
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
14
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
15
3
|
Object.defineProperty(exports, "__esModule", {
|
|
16
4
|
value: true
|
|
17
5
|
});
|
|
18
|
-
exports.
|
|
19
|
-
require("core-js/modules/es.array.filter.js");
|
|
20
|
-
require("core-js/modules/es.array.find.js");
|
|
21
|
-
require("core-js/modules/es.array.map.js");
|
|
22
|
-
require("core-js/modules/es.object.to-string.js");
|
|
23
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
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 _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
28
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
29
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
30
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
6
|
+
exports.default = exports.RecordCard = void 0;
|
|
31
7
|
var _emotion = require("emotion");
|
|
32
8
|
var React = _interopRequireWildcard(require("react"));
|
|
33
9
|
var _core = require("@styled-system/core");
|
|
34
10
|
var _private_utils = require("../../shared/private_utils");
|
|
35
11
|
var _error_utils = require("../../shared/error_utils");
|
|
36
12
|
var _field_core = require("../../shared/types/field_core");
|
|
37
|
-
var _field = _interopRequireDefault(require("../models/field"));
|
|
38
13
|
var _record = _interopRequireDefault(require("../models/record"));
|
|
39
|
-
var _view = _interopRequireDefault(require("../models/view"));
|
|
40
14
|
var _use_watchable = _interopRequireDefault(require("../../shared/ui/use_watchable"));
|
|
41
15
|
var _with_hooks = _interopRequireDefault(require("../../shared/ui/with_hooks"));
|
|
42
16
|
var _sdk_context = require("../../shared/ui/sdk_context");
|
|
@@ -47,21 +21,15 @@ var _key_codes = require("./key_codes");
|
|
|
47
21
|
var _use_styled_system = _interopRequireDefault(require("./use_styled_system"));
|
|
48
22
|
var _system = require("./system");
|
|
49
23
|
var _with_styled_system = require("./with_styled_system");
|
|
50
|
-
var _tooltip_anchor_props = require("./types/tooltip_anchor_props");
|
|
51
24
|
var _use_view_metadata = _interopRequireDefault(require("./use_view_metadata"));
|
|
52
25
|
var _cell_renderer = _interopRequireDefault(require("./cell_renderer"));
|
|
53
26
|
var _expand_record = _interopRequireDefault(require("./expand_record"));
|
|
54
|
-
function
|
|
27
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
28
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
55
29
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
56
|
-
function
|
|
57
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
58
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
59
|
-
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)); }
|
|
60
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
61
|
-
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; }
|
|
62
|
-
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/ui: RecordCard */ /** */
|
|
30
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } /** @module @airtable/blocks/ui: RecordCard */ /** */
|
|
63
31
|
// Mirrored from client_server_shared_config_settings
|
|
64
|
-
|
|
32
|
+
const FALLBACK_RECORD_NAME_FOR_DISPLAY = 'Unnamed record';
|
|
65
33
|
|
|
66
34
|
/**
|
|
67
35
|
* Style props for the {@link RecordCard} component. Accepts:
|
|
@@ -72,18 +40,19 @@ var FALLBACK_RECORD_NAME_FOR_DISPLAY = 'Unnamed record';
|
|
|
72
40
|
* @noInheritDoc
|
|
73
41
|
*/
|
|
74
42
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
var CARD_PADDING = 12;
|
|
43
|
+
const styleParser = (0, _core.compose)(_system.flexItemSet, _system.positionSet, _system.margin);
|
|
44
|
+
const CARD_PADDING = 12;
|
|
78
45
|
|
|
79
46
|
/** @hidden */
|
|
80
47
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
48
|
+
const CellValueAndFieldLabel = _ref => {
|
|
49
|
+
let {
|
|
50
|
+
record,
|
|
51
|
+
cellValue,
|
|
52
|
+
field,
|
|
53
|
+
width,
|
|
54
|
+
renderInvalidCellValue
|
|
55
|
+
} = _ref;
|
|
87
56
|
(0, _use_watchable.default)(field, ['name', 'type', 'options']);
|
|
88
57
|
return /*#__PURE__*/React.createElement(_box.default, {
|
|
89
58
|
style: {
|
|
@@ -112,17 +81,6 @@ var CellValueAndFieldLabel = _ref => {
|
|
|
112
81
|
renderInvalidCellValue: renderInvalidCellValue
|
|
113
82
|
}));
|
|
114
83
|
};
|
|
115
|
-
CellValueAndFieldLabel.propTypes = {
|
|
116
|
-
record: _propTypes.default.instanceOf(_record.default),
|
|
117
|
-
// NOTE: this currently will not work for linked record fields, since CellRenderer
|
|
118
|
-
// cannot currently handle all cell types.
|
|
119
|
-
// TODO(jb): make the constraints for rendering cell values less strict than the
|
|
120
|
-
// constraints we put on updating cell values.
|
|
121
|
-
cellValue: _propTypes.default.any,
|
|
122
|
-
field: _propTypes.default.instanceOf(_field.default).isRequired,
|
|
123
|
-
width: _propTypes.default.number.isRequired,
|
|
124
|
-
renderInvalidCellValue: _propTypes.default.func
|
|
125
|
-
};
|
|
126
84
|
|
|
127
85
|
/**
|
|
128
86
|
* Props for the {@link RecordCard} component. Also accepts:
|
|
@@ -133,23 +91,23 @@ CellValueAndFieldLabel.propTypes = {
|
|
|
133
91
|
*/
|
|
134
92
|
|
|
135
93
|
// TODO(jb): move this stuff into the field model when we decide on an api for it.
|
|
136
|
-
|
|
94
|
+
const FormulaicFieldTypes = {
|
|
137
95
|
[_field_core.FieldType.FORMULA]: true,
|
|
138
96
|
[_field_core.FieldType.ROLLUP]: true,
|
|
139
97
|
[_field_core.FieldType.MULTIPLE_LOOKUP_VALUES]: true
|
|
140
98
|
};
|
|
141
|
-
|
|
99
|
+
const isFieldFormulaic = field => {
|
|
142
100
|
return (0, _private_utils.has)(FormulaicFieldTypes, field.type);
|
|
143
101
|
};
|
|
144
|
-
|
|
102
|
+
const getFieldResultType = field => {
|
|
145
103
|
if (field.type === _field_core.FieldType.COUNT) {
|
|
146
104
|
return _field_core.FieldType.NUMBER;
|
|
147
105
|
}
|
|
148
106
|
if (isFieldFormulaic(field)) {
|
|
149
107
|
(0, _error_utils.invariant)(field.options, 'options');
|
|
150
|
-
|
|
108
|
+
const result = field.options.result;
|
|
151
109
|
if (typeof result === 'object' && result) {
|
|
152
|
-
|
|
110
|
+
const resultType = result.type;
|
|
153
111
|
(0, _error_utils.invariant)(typeof resultType === 'string', 'resultType must be string');
|
|
154
112
|
return resultType;
|
|
155
113
|
} else {
|
|
@@ -167,17 +125,22 @@ var getFieldResultType = field => {
|
|
|
167
125
|
* attachment thumbnail image to fit inside the square attachment preview. Left and top margin
|
|
168
126
|
* are used to center non-square images.
|
|
169
127
|
*/
|
|
170
|
-
|
|
128
|
+
const calculateAttachmentDimensionsAndMargin = (attachment, containerSize) => {
|
|
171
129
|
if (!attachment || !attachment.thumbnails || !attachment.thumbnails.large) {
|
|
172
130
|
return {};
|
|
173
131
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
132
|
+
const {
|
|
133
|
+
thumbnails: {
|
|
134
|
+
large: {
|
|
135
|
+
width: thumbWidth,
|
|
136
|
+
height: thumbHeight
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
} = attachment;
|
|
140
|
+
const height = Math.min(containerSize, thumbHeight);
|
|
141
|
+
const width = Math.round(thumbWidth * height / thumbHeight);
|
|
142
|
+
const marginTop = Math.round((containerSize - height) / 2);
|
|
143
|
+
const marginLeft = Math.round((containerSize - width) / 2);
|
|
181
144
|
return {
|
|
182
145
|
height,
|
|
183
146
|
width,
|
|
@@ -194,443 +157,391 @@ var calculateAttachmentDimensionsAndMargin = (attachment, containerSize) => {
|
|
|
194
157
|
* @docsPath UI/components/RecordCard
|
|
195
158
|
* @component
|
|
196
159
|
*/
|
|
197
|
-
|
|
160
|
+
class RecordCard extends React.Component {
|
|
198
161
|
/** @hidden */
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
162
|
+
static defaultProps = {
|
|
163
|
+
width: 568,
|
|
164
|
+
height: 80,
|
|
165
|
+
className: '',
|
|
166
|
+
style: {}
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
/** @hidden */
|
|
170
|
+
constructor(props) {
|
|
171
|
+
super(props);
|
|
172
|
+
this._onClick = this._onClick.bind(this);
|
|
173
|
+
this._validateProps(props);
|
|
206
174
|
}
|
|
207
175
|
/** @hidden */
|
|
208
|
-
(
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
176
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
177
|
+
this._validateProps(nextProps);
|
|
178
|
+
}
|
|
179
|
+
/** @internal */
|
|
180
|
+
_validateProps(props) {
|
|
181
|
+
const {
|
|
182
|
+
record,
|
|
183
|
+
view,
|
|
184
|
+
fields,
|
|
185
|
+
attachmentCoverField
|
|
186
|
+
} = props;
|
|
187
|
+
if (record && record instanceof _record.default && record.isDeleted) {
|
|
188
|
+
throw (0, _error_utils.spawnError)('Record %s is deleted', record.id);
|
|
213
189
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
fields = props.fields,
|
|
221
|
-
attachmentCoverField = props.attachmentCoverField;
|
|
222
|
-
if (record && record instanceof _record.default && record.isDeleted) {
|
|
223
|
-
throw (0, _error_utils.spawnError)('Record %s is deleted', record.id);
|
|
224
|
-
}
|
|
225
|
-
if (!record) {
|
|
226
|
-
throw (0, _error_utils.spawnError)('Must provide record');
|
|
227
|
-
}
|
|
228
|
-
if (record && record instanceof _record.default && attachmentCoverField) {
|
|
229
|
-
if (attachmentCoverField.parentTable.id !== record.parentTable.id) {
|
|
230
|
-
throw (0, _error_utils.spawnError)('Attachment cover field %s must have the same parent table as record (record ID %s, table ID %s)', attachmentCoverField.id, record.id, record.parentTable.id);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
if (record && record instanceof _record.default && fields) {
|
|
234
|
-
var _iterator = _createForOfIteratorHelper(fields),
|
|
235
|
-
_step;
|
|
236
|
-
try {
|
|
237
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
238
|
-
var field = _step.value;
|
|
239
|
-
if (!field.isDeleted && field.parentTable.id !== record.parentTable.id) {
|
|
240
|
-
throw (0, _error_utils.spawnError)('Field %s must have the same parent table as record (record ID %s, table ID %s)', field.id, record.id, record.parentTable.id);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
} catch (err) {
|
|
244
|
-
_iterator.e(err);
|
|
245
|
-
} finally {
|
|
246
|
-
_iterator.f();
|
|
247
|
-
}
|
|
190
|
+
if (!record) {
|
|
191
|
+
throw (0, _error_utils.spawnError)('Must provide record');
|
|
192
|
+
}
|
|
193
|
+
if (record && record instanceof _record.default && attachmentCoverField) {
|
|
194
|
+
if (attachmentCoverField.parentTable.id !== record.parentTable.id) {
|
|
195
|
+
throw (0, _error_utils.spawnError)('Attachment cover field %s must have the same parent table as record (record ID %s, table ID %s)', attachmentCoverField.id, record.id, record.parentTable.id);
|
|
248
196
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
197
|
+
}
|
|
198
|
+
if (record && record instanceof _record.default && fields) {
|
|
199
|
+
for (const field of fields) {
|
|
200
|
+
if (!field.isDeleted && field.parentTable.id !== record.parentTable.id) {
|
|
201
|
+
throw (0, _error_utils.spawnError)('Field %s must have the same parent table as record (record ID %s, table ID %s)', field.id, record.id, record.parentTable.id);
|
|
252
202
|
}
|
|
253
203
|
}
|
|
254
204
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
value: function _onClick(e) {
|
|
259
|
-
if (this.props.onClick) {
|
|
260
|
-
this.props.onClick(e);
|
|
205
|
+
if (record && record instanceof _record.default && view && !view.isDeleted) {
|
|
206
|
+
if (view.parentTable.id !== record.parentTable.id) {
|
|
207
|
+
throw (0, _error_utils.spawnError)('View %s must have the same parent table as record (record ID %s, table ID %s)', view.id, record.id, record.parentTable.id);
|
|
261
208
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
)
|
|
268
|
-
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/** @internal */
|
|
212
|
+
_onClick(e) {
|
|
213
|
+
if (this.props.onClick) {
|
|
214
|
+
this.props.onClick(e);
|
|
215
|
+
}
|
|
216
|
+
// Explicitly check if `hasOnClick` is false, which is only set by the Tooltip wrapper.
|
|
217
|
+
// When wrapped in Tooltip, `onClick` will always exist because Tooltip supplies it. We use
|
|
218
|
+
// `hasOnClick`, to account for whether the user defined their own `onClick`. We only want
|
|
219
|
+
// to run this default expandRecord behavior if the user did not supply their own `onClick`.
|
|
220
|
+
if (this.props.onClick === undefined || this.props.hasOnClick === false // TODO (stephen): remove tooltip anchor props
|
|
221
|
+
) {
|
|
222
|
+
// NOTE: `null` disables the default click behavior.
|
|
269
223
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
224
|
+
const {
|
|
225
|
+
record
|
|
226
|
+
} = this.props;
|
|
227
|
+
const recordModel = record && record instanceof _record.default ? record : null;
|
|
228
|
+
if (recordModel) {
|
|
229
|
+
if ((0, _key_codes.isCommandModifierKeyEvent)(e) || e.shiftKey) {
|
|
230
|
+
// No-op, let the <a> tag handle opening in new tab or window.
|
|
231
|
+
} else {
|
|
232
|
+
e.preventDefault();
|
|
233
|
+
const opts = this.props.expandRecordOptions || {};
|
|
234
|
+
(0, _expand_record.default)(recordModel, opts);
|
|
280
235
|
}
|
|
281
236
|
}
|
|
282
237
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
if (firstAttachmentFieldInView === undefined) {
|
|
307
|
-
return null;
|
|
308
|
-
}
|
|
309
|
-
return firstAttachmentFieldInView;
|
|
310
|
-
} else {
|
|
238
|
+
}
|
|
239
|
+
/** @internal */
|
|
240
|
+
_getAttachmentCover(fieldsToUse) {
|
|
241
|
+
const attachmentField = this._getAttachmentField(fieldsToUse);
|
|
242
|
+
return attachmentField ? this._getFirstAttachmentInField(attachmentField) : null;
|
|
243
|
+
}
|
|
244
|
+
/** @internal */
|
|
245
|
+
_getAttachmentField(fieldsToUse) {
|
|
246
|
+
const {
|
|
247
|
+
attachmentCoverField
|
|
248
|
+
} = this.props;
|
|
249
|
+
if (attachmentCoverField && !attachmentCoverField.isDeleted && this._isAttachment(attachmentCoverField)) {
|
|
250
|
+
return attachmentCoverField;
|
|
251
|
+
} else if (attachmentCoverField === undefined) {
|
|
252
|
+
// The attachment field in this case is either coming from the view
|
|
253
|
+
// if there is a view, or from the table's arbitrary field ordering
|
|
254
|
+
// if there is no view.
|
|
255
|
+
// TODO: use the real cover field if the view is gallery or kanban instead of
|
|
256
|
+
// the first attachment field
|
|
257
|
+
const firstAttachmentFieldInView = fieldsToUse.find(field => {
|
|
258
|
+
return this._isAttachment(field);
|
|
259
|
+
});
|
|
260
|
+
if (firstAttachmentFieldInView === undefined) {
|
|
311
261
|
return null;
|
|
312
262
|
}
|
|
263
|
+
return firstAttachmentFieldInView;
|
|
264
|
+
} else {
|
|
265
|
+
return null;
|
|
313
266
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
var cellValue = record[field.id];
|
|
267
|
+
}
|
|
268
|
+
/** @internal */
|
|
269
|
+
_isAttachment(field) {
|
|
270
|
+
return getFieldResultType(field) === _field_core.FieldType.MULTIPLE_ATTACHMENTS;
|
|
271
|
+
}
|
|
272
|
+
/** @internal */
|
|
273
|
+
_getCellValue(field) {
|
|
274
|
+
const {
|
|
275
|
+
record
|
|
276
|
+
} = this.props;
|
|
277
|
+
if (record && record instanceof _record.default) {
|
|
278
|
+
return record.getCellValue(field.id);
|
|
279
|
+
} else {
|
|
280
|
+
const cellValue = record[field.id];
|
|
329
281
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}
|
|
282
|
+
// To validate public cell values, we only have validateCellValueForUpdate
|
|
283
|
+
// However, this is not implemented for computed fields (since you can't update them)
|
|
284
|
+
// so we just skip the check.
|
|
285
|
+
// TODO(emma): actually check this somehow.
|
|
286
|
+
if (!field.isComputed) {
|
|
287
|
+
const airtableInterface = this.props.sdk.__airtableInterface;
|
|
288
|
+
const appInterface = this.props.sdk.__appInterface;
|
|
289
|
+
const validationResult = airtableInterface.fieldTypeProvider.validateCellValueForUpdate(appInterface, cellValue, null, field._data);
|
|
290
|
+
if (!validationResult.isValid) {
|
|
291
|
+
throw (0, _error_utils.spawnError)(validationResult.reason);
|
|
341
292
|
}
|
|
342
|
-
return cellValue;
|
|
343
293
|
}
|
|
294
|
+
return cellValue;
|
|
344
295
|
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
attachmentsInField = this._getCellValue(attachmentField);
|
|
355
|
-
}
|
|
356
|
-
return attachmentsInField && attachmentsInField.length > 0 ? attachmentsInField[0] : null;
|
|
296
|
+
}
|
|
297
|
+
/** @internal */
|
|
298
|
+
_getFirstAttachmentInField(attachmentField) {
|
|
299
|
+
let attachmentsInField;
|
|
300
|
+
if (attachmentField.type === _field_core.FieldType.MULTIPLE_LOOKUP_VALUES) {
|
|
301
|
+
const cellValue = this._getCellValue(attachmentField);
|
|
302
|
+
attachmentsInField = cellValue ? cellValue.map(cv => cv.value) : [];
|
|
303
|
+
} else {
|
|
304
|
+
attachmentsInField = this._getCellValue(attachmentField);
|
|
357
305
|
}
|
|
358
|
-
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
return (0, _private_utils.uniqBy)(fieldsToUse, field => field.id);
|
|
306
|
+
return attachmentsInField && attachmentsInField.length > 0 ? attachmentsInField[0] : null;
|
|
307
|
+
}
|
|
308
|
+
/** @internal */
|
|
309
|
+
_getFields() {
|
|
310
|
+
const {
|
|
311
|
+
viewMetadata,
|
|
312
|
+
fields,
|
|
313
|
+
record
|
|
314
|
+
} = this.props;
|
|
315
|
+
let fieldsToUse;
|
|
316
|
+
if (fields) {
|
|
317
|
+
fieldsToUse = fields.filter(field => !field.isDeleted);
|
|
318
|
+
} else if (viewMetadata && !viewMetadata.isDeleted) {
|
|
319
|
+
fieldsToUse = viewMetadata.visibleFields;
|
|
320
|
+
} else if (record && record instanceof _record.default && !record.isDeleted) {
|
|
321
|
+
const parentTable = record.parentTable;
|
|
322
|
+
fieldsToUse = parentTable.fields;
|
|
323
|
+
} else {
|
|
324
|
+
console.warn('RecordCard: no fields, view, or record, so rendering an empty card'); // eslint-disable-line no-console
|
|
325
|
+
fieldsToUse = [];
|
|
379
326
|
}
|
|
380
|
-
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
327
|
+
return (0, _private_utils.uniqBy)(fieldsToUse, field => field.id);
|
|
328
|
+
}
|
|
329
|
+
/** @internal */
|
|
330
|
+
_getPossibleFieldsForCard() {
|
|
331
|
+
const fields = this._getFields();
|
|
385
332
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
width: minCellWidth,
|
|
417
|
-
fieldId: field.id
|
|
418
|
-
});
|
|
419
|
-
runningWidth += minCellWidth;
|
|
420
|
-
} else {
|
|
421
|
-
break;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
333
|
+
// remove primary field if it exists
|
|
334
|
+
return fields.filter(field => {
|
|
335
|
+
return !field.isPrimaryField;
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
/** @internal */
|
|
339
|
+
_getWidthAndFieldIdArray(cellContainerWidth, fieldsToUse) {
|
|
340
|
+
const widthAndFieldIdArray = [];
|
|
341
|
+
let runningWidth = 0;
|
|
342
|
+
const airtableInterface = this.props.sdk.__airtableInterface;
|
|
343
|
+
const appInterface = this.props.sdk.__appInterface;
|
|
344
|
+
for (const field of fieldsToUse) {
|
|
345
|
+
const uiConfig = airtableInterface.fieldTypeProvider.getUiConfig(appInterface, field._data);
|
|
346
|
+
const desiredWidth = uiConfig.desiredCellWidthForRecordCard;
|
|
347
|
+
if (runningWidth + desiredWidth < cellContainerWidth) {
|
|
348
|
+
widthAndFieldIdArray.push({
|
|
349
|
+
width: desiredWidth,
|
|
350
|
+
fieldId: field.id
|
|
351
|
+
});
|
|
352
|
+
runningWidth += desiredWidth;
|
|
353
|
+
} else {
|
|
354
|
+
const minCellWidth = uiConfig.minimumCellWidthForRecordCard;
|
|
355
|
+
if (runningWidth + minCellWidth < cellContainerWidth) {
|
|
356
|
+
widthAndFieldIdArray.push({
|
|
357
|
+
width: minCellWidth,
|
|
358
|
+
fieldId: field.id
|
|
359
|
+
});
|
|
360
|
+
runningWidth += minCellWidth;
|
|
361
|
+
} else {
|
|
362
|
+
break;
|
|
424
363
|
}
|
|
425
|
-
} catch (err) {
|
|
426
|
-
_iterator2.e(err);
|
|
427
|
-
} finally {
|
|
428
|
-
_iterator2.f();
|
|
429
|
-
}
|
|
430
|
-
if (runningWidth < cellContainerWidth && widthAndFieldIdArray.length > 0) {
|
|
431
|
-
var lastWidthAndFieldId = widthAndFieldIdArray[widthAndFieldIdArray.length - 1];
|
|
432
|
-
lastWidthAndFieldId.width += cellContainerWidth - runningWidth;
|
|
433
364
|
}
|
|
434
|
-
return widthAndFieldIdArray;
|
|
435
365
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
value: function _getRecord() {
|
|
440
|
-
var record = this.props.record;
|
|
441
|
-
if (record && record instanceof _record.default) {
|
|
442
|
-
return record;
|
|
443
|
-
} else {
|
|
444
|
-
return null;
|
|
445
|
-
}
|
|
366
|
+
if (runningWidth < cellContainerWidth && widthAndFieldIdArray.length > 0) {
|
|
367
|
+
const lastWidthAndFieldId = widthAndFieldIdArray[widthAndFieldIdArray.length - 1];
|
|
368
|
+
lastWidthAndFieldId.width += cellContainerWidth - runningWidth;
|
|
446
369
|
}
|
|
447
|
-
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
var fieldsById = (0, _private_utils.keyBy)(fieldsToUse, o => o.id);
|
|
459
|
-
return widthAndFieldIdArray.map(widthAndFieldId => {
|
|
460
|
-
var field = fieldsById[widthAndFieldId.fieldId];
|
|
461
|
-
return /*#__PURE__*/React.createElement(CellValueAndFieldLabel, (0, _extends2.default)({
|
|
462
|
-
key: field.id,
|
|
463
|
-
field: field,
|
|
464
|
-
width: widthAndFieldId.width,
|
|
465
|
-
renderInvalidCellValue: renderInvalidCellValue
|
|
466
|
-
}, record instanceof _record.default ? {
|
|
467
|
-
record
|
|
468
|
-
} : {
|
|
469
|
-
cellValue: record[field.id]
|
|
470
|
-
}));
|
|
471
|
-
});
|
|
370
|
+
return widthAndFieldIdArray;
|
|
371
|
+
}
|
|
372
|
+
/** @internal */
|
|
373
|
+
_getRecord() {
|
|
374
|
+
const {
|
|
375
|
+
record
|
|
376
|
+
} = this.props;
|
|
377
|
+
if (record && record instanceof _record.default) {
|
|
378
|
+
return record;
|
|
379
|
+
} else {
|
|
380
|
+
return null;
|
|
472
381
|
}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
382
|
+
}
|
|
383
|
+
/** @internal */
|
|
384
|
+
_renderCellsAndFieldLabels(attachmentSize, fieldsToUse) {
|
|
385
|
+
const {
|
|
386
|
+
record,
|
|
387
|
+
width,
|
|
388
|
+
renderInvalidCellValue
|
|
389
|
+
} = this.props;
|
|
390
|
+
(0, _error_utils.invariant)(typeof width === 'number', 'width in defaultProps');
|
|
391
|
+
const cellContainerWidth = width - CARD_PADDING - attachmentSize;
|
|
392
|
+
const widthAndFieldIdArray = this._getWidthAndFieldIdArray(cellContainerWidth, fieldsToUse);
|
|
393
|
+
const fieldsById = (0, _private_utils.keyBy)(fieldsToUse, o => o.id);
|
|
394
|
+
return widthAndFieldIdArray.map(widthAndFieldId => {
|
|
395
|
+
const field = fieldsById[widthAndFieldId.fieldId];
|
|
396
|
+
return /*#__PURE__*/React.createElement(CellValueAndFieldLabel, _extends({
|
|
397
|
+
key: field.id,
|
|
398
|
+
field: field,
|
|
399
|
+
width: widthAndFieldId.width,
|
|
400
|
+
renderInvalidCellValue: renderInvalidCellValue
|
|
401
|
+
}, record instanceof _record.default ? {
|
|
402
|
+
record
|
|
403
|
+
} : {
|
|
404
|
+
cellValue: record[field.id]
|
|
405
|
+
}));
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
/** @hidden */
|
|
409
|
+
render() {
|
|
410
|
+
const {
|
|
411
|
+
record,
|
|
412
|
+
view,
|
|
413
|
+
width,
|
|
414
|
+
height,
|
|
415
|
+
onClick,
|
|
416
|
+
onMouseEnter,
|
|
417
|
+
onMouseLeave,
|
|
418
|
+
className,
|
|
419
|
+
style
|
|
420
|
+
} = this.props;
|
|
421
|
+
if (record && record instanceof _record.default && record.isDeleted) {
|
|
422
|
+
return null;
|
|
423
|
+
}
|
|
424
|
+
const allFields = this._getFields();
|
|
425
|
+
const fieldsToUse = this._getPossibleFieldsForCard();
|
|
426
|
+
const attachmentObjIfAvailable = this._getAttachmentCover(fieldsToUse);
|
|
427
|
+
const hasAttachment = !!attachmentObjIfAvailable;
|
|
428
|
+
const hasOnClick = !!onClick || !!this._getRecord();
|
|
429
|
+
const containerClasses = (0, _emotion.cx)((0, _baymax_utils.baymax)('white rounded relative block overflow-hidden'), {
|
|
430
|
+
[(0, _baymax_utils.baymax)('pointer cardBoxShadow')]: hasOnClick,
|
|
431
|
+
[(0, _baymax_utils.baymax)('stroked1')]: !hasOnClick
|
|
432
|
+
}, className);
|
|
499
433
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
}
|
|
514
|
-
} else {
|
|
515
|
-
var primaryField = allFields.length > 0 ? allFields[0].parentTable.primaryField : null;
|
|
516
|
-
var primaryCellValue = primaryField ? record[primaryField.id] : null;
|
|
517
|
-
recordName = primaryCellValue === null || primaryCellValue === undefined ? null : String(primaryCellValue);
|
|
434
|
+
// use height as size in order to get square attachment
|
|
435
|
+
(0, _error_utils.invariant)(typeof height === 'number', 'height in defaultProps');
|
|
436
|
+
const attachmentSize = hasAttachment ? height : 0;
|
|
437
|
+
let primaryValue;
|
|
438
|
+
let isUnnamed;
|
|
439
|
+
let recordName;
|
|
440
|
+
let recordUrl;
|
|
441
|
+
let recordColor;
|
|
442
|
+
if (record instanceof _record.default) {
|
|
443
|
+
recordUrl = record.url;
|
|
444
|
+
recordName = record.name;
|
|
445
|
+
if (view) {
|
|
446
|
+
recordColor = record.getColorInView(view);
|
|
518
447
|
}
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
primaryValue = recordName;
|
|
524
|
-
isUnnamed = false;
|
|
525
|
-
}
|
|
526
|
-
var attachmentDimensionsAndPosition = calculateAttachmentDimensionsAndMargin(attachmentObjIfAvailable, attachmentSize);
|
|
527
|
-
return /*#__PURE__*/React.createElement("a", {
|
|
528
|
-
href: onClick === undefined && recordUrl ? recordUrl : undefined,
|
|
529
|
-
className: containerClasses,
|
|
530
|
-
style: _objectSpread(_objectSpread({}, style), {}, {
|
|
531
|
-
width,
|
|
532
|
-
height
|
|
533
|
-
}),
|
|
534
|
-
onClick: this._onClick,
|
|
535
|
-
onMouseEnter: onMouseEnter || undefined,
|
|
536
|
-
onMouseLeave: onMouseLeave || undefined
|
|
537
|
-
}, /*#__PURE__*/React.createElement(_box.default, {
|
|
538
|
-
right: "".concat(attachmentSize, "px"),
|
|
539
|
-
backgroundColor: "transparent",
|
|
540
|
-
padding: "".concat(CARD_PADDING, "px"),
|
|
541
|
-
position: "absolute",
|
|
542
|
-
top: 0,
|
|
543
|
-
bottom: 0,
|
|
544
|
-
left: 0,
|
|
545
|
-
textColor: "dark"
|
|
546
|
-
}, /*#__PURE__*/React.createElement(_box.default, {
|
|
547
|
-
className: (0, _emotion.cx)({
|
|
548
|
-
unnamed: isUnnamed
|
|
549
|
-
}),
|
|
550
|
-
fontWeight: 500,
|
|
551
|
-
position: "relative",
|
|
552
|
-
marginTop: 0,
|
|
553
|
-
display: "flex",
|
|
554
|
-
alignItems: "center",
|
|
555
|
-
lineHeight: 1.5,
|
|
556
|
-
height: "18px",
|
|
557
|
-
fontSize: "14px"
|
|
558
|
-
}, recordColor && /*#__PURE__*/React.createElement(_box.default, {
|
|
559
|
-
width: "6px",
|
|
560
|
-
height: "20px",
|
|
561
|
-
flex: "none",
|
|
562
|
-
marginRight: 1,
|
|
563
|
-
borderRadius: "circle",
|
|
564
|
-
backgroundColor: _color_utils.default.getHexForColor(recordColor)
|
|
565
|
-
}), /*#__PURE__*/React.createElement(_box.default, {
|
|
566
|
-
className: (0, _baymax_utils.baymax)('truncate'),
|
|
567
|
-
flex: "auto"
|
|
568
|
-
}, primaryValue)), /*#__PURE__*/React.createElement(_box.default, {
|
|
569
|
-
textColor: "#555555",
|
|
570
|
-
position: "absolute",
|
|
571
|
-
marginTop: "3px"
|
|
572
|
-
}, this._renderCellsAndFieldLabels(attachmentSize, fieldsToUse))), attachmentObjIfAvailable && attachmentObjIfAvailable.thumbnails && attachmentObjIfAvailable.thumbnails.large && /*#__PURE__*/React.createElement(_box.default, {
|
|
573
|
-
className: (0, _baymax_utils.baymax)('noevents'),
|
|
574
|
-
style: {
|
|
575
|
-
borderTopRightRadius: 2,
|
|
576
|
-
borderBottomRightRadius: 2
|
|
577
|
-
},
|
|
578
|
-
height: "".concat(attachmentSize, "px"),
|
|
579
|
-
width: "".concat(attachmentSize, "px"),
|
|
580
|
-
position: "absolute",
|
|
581
|
-
right: "0",
|
|
582
|
-
overflow: "hidden"
|
|
583
|
-
}, /*#__PURE__*/React.createElement("img", {
|
|
584
|
-
draggable: false,
|
|
585
|
-
height: attachmentDimensionsAndPosition.height,
|
|
586
|
-
width: attachmentDimensionsAndPosition.width,
|
|
587
|
-
style: {
|
|
588
|
-
marginTop: attachmentDimensionsAndPosition.marginTop,
|
|
589
|
-
marginLeft: attachmentDimensionsAndPosition.marginLeft
|
|
590
|
-
},
|
|
591
|
-
src: attachmentObjIfAvailable.thumbnails.large.url
|
|
592
|
-
})));
|
|
448
|
+
} else {
|
|
449
|
+
const primaryField = allFields.length > 0 ? allFields[0].parentTable.primaryField : null;
|
|
450
|
+
const primaryCellValue = primaryField ? record[primaryField.id] : null;
|
|
451
|
+
recordName = primaryCellValue === null || primaryCellValue === undefined ? null : String(primaryCellValue);
|
|
593
452
|
}
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
}
|
|
453
|
+
if ((0, _private_utils.isNullOrUndefinedOrEmpty)(recordName)) {
|
|
454
|
+
primaryValue = FALLBACK_RECORD_NAME_FOR_DISPLAY;
|
|
455
|
+
isUnnamed = true;
|
|
456
|
+
} else {
|
|
457
|
+
primaryValue = recordName;
|
|
458
|
+
isUnnamed = false;
|
|
459
|
+
}
|
|
460
|
+
const attachmentDimensionsAndPosition = calculateAttachmentDimensionsAndMargin(attachmentObjIfAvailable, attachmentSize);
|
|
461
|
+
return /*#__PURE__*/React.createElement("a", {
|
|
462
|
+
href: onClick === undefined && recordUrl ? recordUrl : undefined,
|
|
463
|
+
className: containerClasses,
|
|
464
|
+
style: {
|
|
465
|
+
...style,
|
|
466
|
+
width,
|
|
467
|
+
height
|
|
468
|
+
},
|
|
469
|
+
onClick: this._onClick,
|
|
470
|
+
onMouseEnter: onMouseEnter || undefined,
|
|
471
|
+
onMouseLeave: onMouseLeave || undefined
|
|
472
|
+
}, /*#__PURE__*/React.createElement(_box.default, {
|
|
473
|
+
right: `${attachmentSize}px`,
|
|
474
|
+
backgroundColor: "transparent",
|
|
475
|
+
padding: `${CARD_PADDING}px`,
|
|
476
|
+
position: "absolute",
|
|
477
|
+
top: 0,
|
|
478
|
+
bottom: 0,
|
|
479
|
+
left: 0,
|
|
480
|
+
textColor: "dark"
|
|
481
|
+
}, /*#__PURE__*/React.createElement(_box.default, {
|
|
482
|
+
className: (0, _emotion.cx)({
|
|
483
|
+
unnamed: isUnnamed
|
|
484
|
+
}),
|
|
485
|
+
fontWeight: 500,
|
|
486
|
+
position: "relative",
|
|
487
|
+
marginTop: 0,
|
|
488
|
+
display: "flex",
|
|
489
|
+
alignItems: "center",
|
|
490
|
+
lineHeight: 1.5,
|
|
491
|
+
height: "18px",
|
|
492
|
+
fontSize: "14px"
|
|
493
|
+
}, recordColor && /*#__PURE__*/React.createElement(_box.default, {
|
|
494
|
+
width: "6px",
|
|
495
|
+
height: "20px",
|
|
496
|
+
flex: "none",
|
|
497
|
+
marginRight: 1,
|
|
498
|
+
borderRadius: "circle",
|
|
499
|
+
backgroundColor: _color_utils.default.getHexForColor(recordColor)
|
|
500
|
+
}), /*#__PURE__*/React.createElement(_box.default, {
|
|
501
|
+
className: (0, _baymax_utils.baymax)('truncate'),
|
|
502
|
+
flex: "auto"
|
|
503
|
+
}, primaryValue)), /*#__PURE__*/React.createElement(_box.default, {
|
|
504
|
+
textColor: "#555555",
|
|
505
|
+
position: "absolute",
|
|
506
|
+
marginTop: "3px"
|
|
507
|
+
}, this._renderCellsAndFieldLabels(attachmentSize, fieldsToUse))), attachmentObjIfAvailable && attachmentObjIfAvailable.thumbnails && attachmentObjIfAvailable.thumbnails.large && /*#__PURE__*/React.createElement(_box.default, {
|
|
508
|
+
className: (0, _baymax_utils.baymax)('noevents'),
|
|
509
|
+
style: {
|
|
510
|
+
borderTopRightRadius: 2,
|
|
511
|
+
borderBottomRightRadius: 2
|
|
512
|
+
},
|
|
513
|
+
height: `${attachmentSize}px`,
|
|
514
|
+
width: `${attachmentSize}px`,
|
|
515
|
+
position: "absolute",
|
|
516
|
+
right: "0",
|
|
517
|
+
overflow: "hidden"
|
|
518
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
519
|
+
draggable: false,
|
|
520
|
+
height: attachmentDimensionsAndPosition.height,
|
|
521
|
+
width: attachmentDimensionsAndPosition.width,
|
|
522
|
+
style: {
|
|
523
|
+
marginTop: attachmentDimensionsAndPosition.marginTop,
|
|
524
|
+
marginLeft: attachmentDimensionsAndPosition.marginLeft
|
|
525
|
+
},
|
|
526
|
+
src: attachmentObjIfAvailable.thumbnails.large.url
|
|
527
|
+
})));
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
exports.RecordCard = RecordCard;
|
|
623
531
|
var _default = exports.default = (0, _with_hooks.default)(RecordCard, props => {
|
|
624
|
-
|
|
625
|
-
styleProps
|
|
626
|
-
nonStyleProps
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
532
|
+
const {
|
|
533
|
+
styleProps,
|
|
534
|
+
nonStyleProps
|
|
535
|
+
} = (0, _with_styled_system.splitStyleProps)(props, styleParser.propNames);
|
|
536
|
+
const {
|
|
537
|
+
record,
|
|
538
|
+
fields,
|
|
539
|
+
view,
|
|
540
|
+
className
|
|
541
|
+
} = nonStyleProps;
|
|
542
|
+
const classNameForStyledProps = (0, _use_styled_system.default)(styleProps, styleParser);
|
|
543
|
+
const recordModel = record && record instanceof _record.default ? record : null;
|
|
544
|
+
let parentTable = null;
|
|
634
545
|
if (recordModel) {
|
|
635
546
|
parentTable = recordModel.parentTable;
|
|
636
547
|
} else if (fields && fields.length > 0) {
|
|
@@ -638,13 +549,13 @@ var _default = exports.default = (0, _with_hooks.default)(RecordCard, props => {
|
|
|
638
549
|
} else if (view) {
|
|
639
550
|
parentTable = view.parentTable;
|
|
640
551
|
}
|
|
641
|
-
(0, _use_watchable.default)(recordModel, ['name', view ?
|
|
552
|
+
(0, _use_watchable.default)(recordModel, ['name', view ? `colorInView:${view.id}` : null]);
|
|
642
553
|
// It's safe to watch the record's parentTable since a record's parent table never changes.
|
|
643
554
|
(0, _use_watchable.default)(parentTable, ['fields']);
|
|
644
555
|
|
|
645
556
|
// if a view is supplied, we need to load the field order to use it for rendering the card
|
|
646
|
-
|
|
647
|
-
|
|
557
|
+
const viewMetadata = (0, _use_view_metadata.default)(view);
|
|
558
|
+
const sdk = (0, _sdk_context.useSdk)();
|
|
648
559
|
return {
|
|
649
560
|
viewMetadata,
|
|
650
561
|
className: (0, _emotion.cx)(classNameForStyledProps, className),
|