@airtable/blocks 1.18.0 → 1.18.2

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.
Files changed (481) hide show
  1. package/CHANGELOG.md +552 -0
  2. package/dist/cjs/color_utils.js +21 -23
  3. package/dist/cjs/colors.js +4 -60
  4. package/dist/cjs/error_utils.js +15 -25
  5. package/dist/cjs/event_tracker.js +5 -11
  6. package/dist/cjs/global_config.js +107 -188
  7. package/dist/cjs/index.js +16 -40
  8. package/dist/cjs/injected/airtable_interface.js +1 -6
  9. package/dist/cjs/models/abstract_model.js +50 -81
  10. package/dist/cjs/models/abstract_model_with_async_data.js +102 -177
  11. package/dist/cjs/models/base.js +211 -374
  12. package/dist/cjs/models/create_aggregators.js +53 -47
  13. package/dist/cjs/models/cursor.js +125 -201
  14. package/dist/cjs/models/field.js +256 -303
  15. package/dist/cjs/models/grouped_record_query_result.js +210 -286
  16. package/dist/cjs/models/linked_records_query_result.js +276 -454
  17. package/dist/cjs/models/models.js +36 -50
  18. package/dist/cjs/models/mutation_constants.js +5 -9
  19. package/dist/cjs/models/mutations.js +125 -338
  20. package/dist/cjs/models/object_pool.js +37 -94
  21. package/dist/cjs/models/record.js +132 -226
  22. package/dist/cjs/models/record_coloring.js +14 -19
  23. package/dist/cjs/models/record_query_result.js +323 -282
  24. package/dist/cjs/models/record_store.js +355 -688
  25. package/dist/cjs/models/session.js +99 -158
  26. package/dist/cjs/models/table.js +361 -549
  27. package/dist/cjs/models/table_or_view_query_result.js +410 -765
  28. package/dist/cjs/models/view.js +161 -204
  29. package/dist/cjs/models/view_data_store.js +177 -282
  30. package/dist/cjs/models/view_metadata_query_result.js +96 -127
  31. package/dist/cjs/perform_record_action.js +69 -103
  32. package/dist/cjs/private_utils.js +133 -223
  33. package/dist/cjs/sdk.js +97 -142
  34. package/dist/cjs/settings_button.js +30 -57
  35. package/dist/cjs/stats/block_stats.js +3 -15
  36. package/dist/cjs/testing/abstract_mock_airtable_interface.js +53 -97
  37. package/dist/cjs/types/airtable_interface.js +36 -8
  38. package/dist/cjs/types/field.js +66 -12
  39. package/dist/cjs/types/mutations.js +99 -6
  40. package/dist/cjs/types/permission_levels.js +2 -4
  41. package/dist/cjs/types/undo_redo.js +2 -3
  42. package/dist/cjs/types/view.js +16 -11
  43. package/dist/cjs/ui/base_provider.js +14 -9
  44. package/dist/cjs/ui/baymax_utils.js +107 -1102
  45. package/dist/cjs/ui/block_wrapper.js +30 -68
  46. package/dist/cjs/ui/box.js +52 -56
  47. package/dist/cjs/ui/button.js +60 -77
  48. package/dist/cjs/ui/cell_renderer.js +78 -139
  49. package/dist/cjs/ui/choice_token.js +45 -47
  50. package/dist/cjs/ui/collaborator_token.js +33 -54
  51. package/dist/cjs/ui/color_palette.js +58 -106
  52. package/dist/cjs/ui/color_palette_synced.js +41 -52
  53. package/dist/cjs/ui/confirmation_dialog.js +53 -69
  54. package/dist/cjs/ui/control_sizes.js +21 -46
  55. package/dist/cjs/ui/create_detect_element_resize.js +16 -50
  56. package/dist/cjs/ui/css_helpers.js +3 -10
  57. package/dist/cjs/ui/dialog.js +44 -71
  58. package/dist/cjs/ui/dialog_close_button.js +52 -72
  59. package/dist/cjs/ui/expand_record.js +4 -11
  60. package/dist/cjs/ui/expand_record_list.js +6 -11
  61. package/dist/cjs/ui/expand_record_picker_async.js +18 -35
  62. package/dist/cjs/ui/field_icon.js +25 -28
  63. package/dist/cjs/ui/field_picker.js +47 -81
  64. package/dist/cjs/ui/field_picker_synced.js +33 -44
  65. package/dist/cjs/ui/form_field.js +45 -64
  66. package/dist/cjs/ui/geometry/geometry.js +6 -10
  67. package/dist/cjs/ui/geometry/point.js +5 -13
  68. package/dist/cjs/ui/geometry/rect.js +7 -29
  69. package/dist/cjs/ui/geometry/size.js +5 -13
  70. package/dist/cjs/ui/global_alert.js +35 -61
  71. package/dist/cjs/ui/global_config_synced_component_helpers.js +4 -13
  72. package/dist/cjs/ui/heading.js +63 -92
  73. package/dist/cjs/ui/icon.js +44 -66
  74. package/dist/cjs/ui/icon_config.js +13 -24
  75. package/dist/cjs/ui/initialize_block.js +23 -36
  76. package/dist/cjs/ui/input.js +74 -87
  77. package/dist/cjs/ui/input_synced.js +34 -43
  78. package/dist/cjs/ui/key_codes.js +4 -9
  79. package/dist/cjs/ui/label.js +45 -50
  80. package/dist/cjs/ui/link.js +74 -89
  81. package/dist/cjs/ui/loader.js +26 -42
  82. package/dist/cjs/ui/modal.js +63 -89
  83. package/dist/cjs/ui/model_picker_select.js +29 -47
  84. package/dist/cjs/ui/popover.js +98 -180
  85. package/dist/cjs/ui/progress_bar.js +45 -51
  86. package/dist/cjs/ui/record_card.js +143 -278
  87. package/dist/cjs/ui/record_card_list.js +117 -165
  88. package/dist/cjs/ui/remote_utils.js +5 -13
  89. package/dist/cjs/ui/sdk_context.js +7 -9
  90. package/dist/cjs/ui/select.js +84 -118
  91. package/dist/cjs/ui/select_and_select_buttons_helpers.js +27 -45
  92. package/dist/cjs/ui/select_buttons.js +54 -90
  93. package/dist/cjs/ui/select_buttons_synced.js +32 -41
  94. package/dist/cjs/ui/select_synced.js +32 -42
  95. package/dist/cjs/ui/switch.js +66 -84
  96. package/dist/cjs/ui/switch_synced.js +32 -38
  97. package/dist/cjs/ui/synced.js +16 -43
  98. package/dist/cjs/ui/system/all_styles_set.js +89 -22
  99. package/dist/cjs/ui/system/appearance/appearance_set.js +15 -26
  100. package/dist/cjs/ui/system/appearance/background_color.js +6 -12
  101. package/dist/cjs/ui/system/appearance/border.js +6 -12
  102. package/dist/cjs/ui/system/appearance/border_radius.js +6 -12
  103. package/dist/cjs/ui/system/appearance/box_shadow.js +6 -12
  104. package/dist/cjs/ui/system/appearance/opacity.js +5 -11
  105. package/dist/cjs/ui/system/dimensions/dimensions_set.js +15 -27
  106. package/dist/cjs/ui/system/dimensions/height.js +5 -11
  107. package/dist/cjs/ui/system/dimensions/max_height.js +5 -11
  108. package/dist/cjs/ui/system/dimensions/max_width.js +5 -11
  109. package/dist/cjs/ui/system/dimensions/min_height.js +5 -11
  110. package/dist/cjs/ui/system/dimensions/min_width.js +5 -11
  111. package/dist/cjs/ui/system/dimensions/width.js +5 -11
  112. package/dist/cjs/ui/system/display.js +8 -9
  113. package/dist/cjs/ui/system/flex_container/align_content.js +6 -12
  114. package/dist/cjs/ui/system/flex_container/align_items.js +6 -12
  115. package/dist/cjs/ui/system/flex_container/flex_container_set.js +15 -27
  116. package/dist/cjs/ui/system/flex_container/flex_direction.js +5 -11
  117. package/dist/cjs/ui/system/flex_container/flex_wrap.js +5 -11
  118. package/dist/cjs/ui/system/flex_container/justify_content.js +5 -11
  119. package/dist/cjs/ui/system/flex_container/justify_items.js +5 -11
  120. package/dist/cjs/ui/system/flex_item/align_self.js +6 -12
  121. package/dist/cjs/ui/system/flex_item/flex.js +5 -11
  122. package/dist/cjs/ui/system/flex_item/flex_basis.js +5 -11
  123. package/dist/cjs/ui/system/flex_item/flex_grow.js +5 -11
  124. package/dist/cjs/ui/system/flex_item/flex_item_set.js +15 -28
  125. package/dist/cjs/ui/system/flex_item/flex_shrink.js +5 -11
  126. package/dist/cjs/ui/system/flex_item/justify_self.js +5 -11
  127. package/dist/cjs/ui/system/flex_item/order.js +5 -11
  128. package/dist/cjs/ui/system/index.js +310 -362
  129. package/dist/cjs/ui/system/overflow.js +8 -9
  130. package/dist/cjs/ui/system/position/bottom.js +6 -13
  131. package/dist/cjs/ui/system/position/left.js +5 -12
  132. package/dist/cjs/ui/system/position/position.js +5 -11
  133. package/dist/cjs/ui/system/position/position_set.js +15 -27
  134. package/dist/cjs/ui/system/position/right.js +5 -12
  135. package/dist/cjs/ui/system/position/top.js +5 -12
  136. package/dist/cjs/ui/system/position/z_index.js +5 -11
  137. package/dist/cjs/ui/system/spacing/margin.js +5 -12
  138. package/dist/cjs/ui/system/spacing/padding.js +5 -12
  139. package/dist/cjs/ui/system/spacing/spacing_set.js +15 -23
  140. package/dist/cjs/ui/system/typography/font_family.js +5 -11
  141. package/dist/cjs/ui/system/typography/font_size.js +5 -11
  142. package/dist/cjs/ui/system/typography/font_style.js +5 -11
  143. package/dist/cjs/ui/system/typography/font_weight.js +5 -11
  144. package/dist/cjs/ui/system/typography/letter_spacing.js +5 -11
  145. package/dist/cjs/ui/system/typography/line_height.js +5 -11
  146. package/dist/cjs/ui/system/typography/text_align.js +5 -11
  147. package/dist/cjs/ui/system/typography/text_color.js +5 -11
  148. package/dist/cjs/ui/system/typography/text_decoration.js +5 -11
  149. package/dist/cjs/ui/system/typography/text_transform.js +5 -11
  150. package/dist/cjs/ui/system/typography/typography_set.js +15 -31
  151. package/dist/cjs/ui/system/utils/create_responsive_prop_type.js +2 -4
  152. package/dist/cjs/ui/system/utils/create_style_prop_types.js +5 -13
  153. package/dist/cjs/ui/system/utils/ensure_numbers_are_within_scale.js +2 -14
  154. package/dist/cjs/ui/system/utils/get_style_props_for_responsive_prop.js +30 -70
  155. package/dist/cjs/ui/table_picker.js +26 -43
  156. package/dist/cjs/ui/table_picker_synced.js +33 -42
  157. package/dist/cjs/ui/text.js +59 -71
  158. package/dist/cjs/ui/text_button.js +80 -97
  159. package/dist/cjs/ui/theme/default_theme/button_variants.js +1 -5
  160. package/dist/cjs/ui/theme/default_theme/control_sizes.js +29 -42
  161. package/dist/cjs/ui/theme/default_theme/heading_styles.js +4 -5
  162. package/dist/cjs/ui/theme/default_theme/index.js +15 -32
  163. package/dist/cjs/ui/theme/default_theme/input_variants.js +1 -5
  164. package/dist/cjs/ui/theme/default_theme/link_variants.js +1 -5
  165. package/dist/cjs/ui/theme/default_theme/select_buttons_variants.js +1 -5
  166. package/dist/cjs/ui/theme/default_theme/select_variants.js +10 -21
  167. package/dist/cjs/ui/theme/default_theme/switch_variants.js +8 -20
  168. package/dist/cjs/ui/theme/default_theme/text_button_variants.js +1 -5
  169. package/dist/cjs/ui/theme/default_theme/text_styles.js +1 -2
  170. package/dist/cjs/ui/theme/default_theme/tokens.js +33 -35
  171. package/dist/cjs/ui/theme/theme_context.js +3 -6
  172. package/dist/cjs/ui/theme/use_theme.js +1 -7
  173. package/dist/cjs/ui/tooltip.js +38 -79
  174. package/dist/cjs/ui/types/aria_props.js +3 -7
  175. package/dist/cjs/ui/types/data_attributes_prop.js +8 -6
  176. package/dist/cjs/ui/types/tooltip_anchor_props.js +4 -5
  177. package/dist/cjs/ui/ui.js +89 -130
  178. package/dist/cjs/ui/unstable_standalone_ui.js +18 -42
  179. package/dist/cjs/ui/use_array_identity.js +0 -4
  180. package/dist/cjs/ui/use_base.js +4 -13
  181. package/dist/cjs/ui/use_cursor.js +3 -12
  182. package/dist/cjs/ui/use_form_field.js +4 -6
  183. package/dist/cjs/ui/use_global_config.js +3 -10
  184. package/dist/cjs/ui/use_loadable.js +59 -132
  185. package/dist/cjs/ui/use_record_action_data.js +6 -12
  186. package/dist/cjs/ui/use_records.js +23 -24
  187. package/dist/cjs/ui/use_session.js +6 -15
  188. package/dist/cjs/ui/use_settings_button.js +4 -11
  189. package/dist/cjs/ui/use_styled_system.js +12 -21
  190. package/dist/cjs/ui/use_synced.js +0 -7
  191. package/dist/cjs/ui/use_text_color_for_background_color.js +1 -5
  192. package/dist/cjs/ui/use_view_metadata.js +5 -8
  193. package/dist/cjs/ui/use_viewport.js +1 -7
  194. package/dist/cjs/ui/use_watchable.js +36 -74
  195. package/dist/cjs/ui/view_picker.js +44 -78
  196. package/dist/cjs/ui/view_picker_synced.js +33 -44
  197. package/dist/cjs/ui/viewport_constraint.js +37 -64
  198. package/dist/cjs/ui/with_hooks.js +17 -22
  199. package/dist/cjs/ui/with_styled_system.js +33 -60
  200. package/dist/cjs/undo_redo.js +12 -32
  201. package/dist/cjs/unstable_private_utils.js +6 -8
  202. package/dist/cjs/unstable_testing_utils.js +44 -57
  203. package/dist/cjs/viewport.js +127 -189
  204. package/dist/cjs/warning.js +5 -6
  205. package/dist/cjs/watchable.js +66 -148
  206. package/dist/types/src/colors.d.ts +1 -1
  207. package/dist/types/src/colors.d.ts.map +1 -1
  208. package/dist/types/src/global_config.d.ts +1 -1
  209. package/dist/types/src/global_config.d.ts.map +1 -1
  210. package/dist/types/src/models/base.d.ts +1 -1
  211. package/dist/types/src/models/base.d.ts.map +1 -1
  212. package/dist/types/src/models/cursor.d.ts +1 -1
  213. package/dist/types/src/models/cursor.d.ts.map +1 -1
  214. package/dist/types/src/models/field.d.ts +1 -1
  215. package/dist/types/src/models/field.d.ts.map +1 -1
  216. package/dist/types/src/models/linked_records_query_result.d.ts.map +1 -1
  217. package/dist/types/src/models/models.d.ts.map +1 -1
  218. package/dist/types/src/models/record.d.ts +1 -1
  219. package/dist/types/src/models/record.d.ts.map +1 -1
  220. package/dist/types/src/models/record_coloring.d.ts +2 -2
  221. package/dist/types/src/models/record_coloring.d.ts.map +1 -1
  222. package/dist/types/src/models/record_query_result.d.ts +3 -3
  223. package/dist/types/src/models/record_query_result.d.ts.map +1 -1
  224. package/dist/types/src/models/session.d.ts +1 -1
  225. package/dist/types/src/models/session.d.ts.map +1 -1
  226. package/dist/types/src/models/table.d.ts +1 -1
  227. package/dist/types/src/models/table.d.ts.map +1 -1
  228. package/dist/types/src/models/view.d.ts +1 -1
  229. package/dist/types/src/models/view.d.ts.map +1 -1
  230. package/dist/types/src/models/view_metadata_query_result.d.ts +2 -2
  231. package/dist/types/src/models/view_metadata_query_result.d.ts.map +1 -1
  232. package/dist/types/src/perform_record_action.d.ts +1 -1
  233. package/dist/types/src/perform_record_action.d.ts.map +1 -1
  234. package/dist/types/src/private_utils.d.ts +8 -8
  235. package/dist/types/src/private_utils.d.ts.map +1 -1
  236. package/dist/types/src/sdk.d.ts +1 -1
  237. package/dist/types/src/sdk.d.ts.map +1 -1
  238. package/dist/types/src/settings_button.d.ts +1 -1
  239. package/dist/types/src/settings_button.d.ts.map +1 -1
  240. package/dist/types/src/types/aggregators.d.ts +1 -1
  241. package/dist/types/src/types/aggregators.d.ts.map +1 -1
  242. package/dist/types/src/types/airtable_interface.d.ts +6 -6
  243. package/dist/types/src/types/airtable_interface.d.ts.map +1 -1
  244. package/dist/types/src/types/attachment.d.ts +1 -1
  245. package/dist/types/src/types/attachment.d.ts.map +1 -1
  246. package/dist/types/src/types/base.d.ts +1 -1
  247. package/dist/types/src/types/base.d.ts.map +1 -1
  248. package/dist/types/src/types/block.d.ts +1 -1
  249. package/dist/types/src/types/block.d.ts.map +1 -1
  250. package/dist/types/src/types/collaborator.d.ts +1 -1
  251. package/dist/types/src/types/collaborator.d.ts.map +1 -1
  252. package/dist/types/src/types/field.d.ts +5 -5
  253. package/dist/types/src/types/field.d.ts.map +1 -1
  254. package/dist/types/src/types/global_config.d.ts +6 -6
  255. package/dist/types/src/types/global_config.d.ts.map +1 -1
  256. package/dist/types/src/types/mutations.d.ts +4 -4
  257. package/dist/types/src/types/mutations.d.ts.map +1 -1
  258. package/dist/types/src/types/permission_levels.d.ts +1 -1
  259. package/dist/types/src/types/permission_levels.d.ts.map +1 -1
  260. package/dist/types/src/types/record.d.ts +2 -2
  261. package/dist/types/src/types/record.d.ts.map +1 -1
  262. package/dist/types/src/types/record_action_data.d.ts +1 -1
  263. package/dist/types/src/types/record_action_data.d.ts.map +1 -1
  264. package/dist/types/src/types/table.d.ts +3 -3
  265. package/dist/types/src/types/table.d.ts.map +1 -1
  266. package/dist/types/src/types/undo_redo.d.ts +1 -1
  267. package/dist/types/src/types/undo_redo.d.ts.map +1 -1
  268. package/dist/types/src/types/view.d.ts +4 -4
  269. package/dist/types/src/types/view.d.ts.map +1 -1
  270. package/dist/types/src/ui/base_provider.d.ts +1 -1
  271. package/dist/types/src/ui/base_provider.d.ts.map +1 -1
  272. package/dist/types/src/ui/block_wrapper.d.ts +2 -2
  273. package/dist/types/src/ui/button.d.ts +1 -1
  274. package/dist/types/src/ui/button.d.ts.map +1 -1
  275. package/dist/types/src/ui/cell_renderer.d.ts +2 -2
  276. package/dist/types/src/ui/choice_token.d.ts +3 -3
  277. package/dist/types/src/ui/choice_token.d.ts.map +1 -1
  278. package/dist/types/src/ui/collaborator_token.d.ts +5 -5
  279. package/dist/types/src/ui/collaborator_token.d.ts.map +1 -1
  280. package/dist/types/src/ui/color_palette.d.ts +2 -2
  281. package/dist/types/src/ui/color_palette_synced.d.ts +2 -2
  282. package/dist/types/src/ui/confirmation_dialog.d.ts +1 -1
  283. package/dist/types/src/ui/control_sizes.d.ts +2 -2
  284. package/dist/types/src/ui/control_sizes.d.ts.map +1 -1
  285. package/dist/types/src/ui/dialog.d.ts +2 -2
  286. package/dist/types/src/ui/dialog.d.ts.map +1 -1
  287. package/dist/types/src/ui/dialog_close_button.d.ts +1 -1
  288. package/dist/types/src/ui/field_icon.d.ts +3 -3
  289. package/dist/types/src/ui/field_icon.d.ts.map +1 -1
  290. package/dist/types/src/ui/field_picker.d.ts +1 -1
  291. package/dist/types/src/ui/global_alert.d.ts +1 -1
  292. package/dist/types/src/ui/global_alert.d.ts.map +1 -1
  293. package/dist/types/src/ui/global_config_synced_component_helpers.d.ts +1 -1
  294. package/dist/types/src/ui/global_config_synced_component_helpers.d.ts.map +1 -1
  295. package/dist/types/src/ui/heading.d.ts +3 -3
  296. package/dist/types/src/ui/heading.d.ts.map +1 -1
  297. package/dist/types/src/ui/icon.d.ts +1 -1
  298. package/dist/types/src/ui/icon_config.d.ts +39 -39
  299. package/dist/types/src/ui/icon_config.d.ts.map +1 -1
  300. package/dist/types/src/ui/initialize_block.d.ts +3 -3
  301. package/dist/types/src/ui/initialize_block.d.ts.map +1 -1
  302. package/dist/types/src/ui/input.d.ts +15 -15
  303. package/dist/types/src/ui/input.d.ts.map +1 -1
  304. package/dist/types/src/ui/link.d.ts +1 -1
  305. package/dist/types/src/ui/link.d.ts.map +1 -1
  306. package/dist/types/src/ui/loader.d.ts +1 -1
  307. package/dist/types/src/ui/loader.d.ts.map +1 -1
  308. package/dist/types/src/ui/model_picker_select.d.ts +1 -1
  309. package/dist/types/src/ui/model_picker_select.d.ts.map +1 -1
  310. package/dist/types/src/ui/popover.d.ts +5 -5
  311. package/dist/types/src/ui/popover.d.ts.map +1 -1
  312. package/dist/types/src/ui/progress_bar.d.ts +1 -1
  313. package/dist/types/src/ui/progress_bar.d.ts.map +1 -1
  314. package/dist/types/src/ui/record_card.d.ts +2 -2
  315. package/dist/types/src/ui/record_card.d.ts.map +1 -1
  316. package/dist/types/src/ui/record_card_list.d.ts +1 -1
  317. package/dist/types/src/ui/select.d.ts +4 -4
  318. package/dist/types/src/ui/select_and_select_buttons_helpers.d.ts +4 -4
  319. package/dist/types/src/ui/select_and_select_buttons_helpers.d.ts.map +1 -1
  320. package/dist/types/src/ui/select_buttons.d.ts +4 -4
  321. package/dist/types/src/ui/switch.d.ts +1 -1
  322. package/dist/types/src/ui/switch.d.ts.map +1 -1
  323. package/dist/types/src/ui/synced.d.ts +3 -3
  324. package/dist/types/src/ui/system/all_styles_set.d.ts +0 -1
  325. package/dist/types/src/ui/system/all_styles_set.d.ts.map +1 -1
  326. package/dist/types/src/ui/system/appearance/appearance_set.d.ts +0 -1
  327. package/dist/types/src/ui/system/appearance/appearance_set.d.ts.map +1 -1
  328. package/dist/types/src/ui/system/appearance/background_color.d.ts +0 -1
  329. package/dist/types/src/ui/system/appearance/background_color.d.ts.map +1 -1
  330. package/dist/types/src/ui/system/appearance/border.d.ts +0 -1
  331. package/dist/types/src/ui/system/appearance/border.d.ts.map +1 -1
  332. package/dist/types/src/ui/system/appearance/border_radius.d.ts +0 -1
  333. package/dist/types/src/ui/system/appearance/border_radius.d.ts.map +1 -1
  334. package/dist/types/src/ui/system/appearance/box_shadow.d.ts +0 -1
  335. package/dist/types/src/ui/system/appearance/box_shadow.d.ts.map +1 -1
  336. package/dist/types/src/ui/system/appearance/opacity.d.ts +0 -1
  337. package/dist/types/src/ui/system/appearance/opacity.d.ts.map +1 -1
  338. package/dist/types/src/ui/system/dimensions/dimensions_set.d.ts +0 -1
  339. package/dist/types/src/ui/system/dimensions/dimensions_set.d.ts.map +1 -1
  340. package/dist/types/src/ui/system/dimensions/height.d.ts +0 -1
  341. package/dist/types/src/ui/system/dimensions/height.d.ts.map +1 -1
  342. package/dist/types/src/ui/system/dimensions/max_height.d.ts +0 -1
  343. package/dist/types/src/ui/system/dimensions/max_height.d.ts.map +1 -1
  344. package/dist/types/src/ui/system/dimensions/max_width.d.ts +0 -1
  345. package/dist/types/src/ui/system/dimensions/max_width.d.ts.map +1 -1
  346. package/dist/types/src/ui/system/dimensions/min_height.d.ts +0 -1
  347. package/dist/types/src/ui/system/dimensions/min_height.d.ts.map +1 -1
  348. package/dist/types/src/ui/system/dimensions/min_width.d.ts +0 -1
  349. package/dist/types/src/ui/system/dimensions/min_width.d.ts.map +1 -1
  350. package/dist/types/src/ui/system/dimensions/width.d.ts +0 -1
  351. package/dist/types/src/ui/system/dimensions/width.d.ts.map +1 -1
  352. package/dist/types/src/ui/system/display.d.ts +0 -1
  353. package/dist/types/src/ui/system/display.d.ts.map +1 -1
  354. package/dist/types/src/ui/system/flex_container/align_content.d.ts +0 -1
  355. package/dist/types/src/ui/system/flex_container/align_content.d.ts.map +1 -1
  356. package/dist/types/src/ui/system/flex_container/align_items.d.ts +0 -1
  357. package/dist/types/src/ui/system/flex_container/align_items.d.ts.map +1 -1
  358. package/dist/types/src/ui/system/flex_container/flex_container_set.d.ts +0 -1
  359. package/dist/types/src/ui/system/flex_container/flex_container_set.d.ts.map +1 -1
  360. package/dist/types/src/ui/system/flex_container/flex_direction.d.ts +0 -1
  361. package/dist/types/src/ui/system/flex_container/flex_direction.d.ts.map +1 -1
  362. package/dist/types/src/ui/system/flex_container/flex_wrap.d.ts +0 -1
  363. package/dist/types/src/ui/system/flex_container/flex_wrap.d.ts.map +1 -1
  364. package/dist/types/src/ui/system/flex_container/justify_content.d.ts +0 -1
  365. package/dist/types/src/ui/system/flex_container/justify_content.d.ts.map +1 -1
  366. package/dist/types/src/ui/system/flex_container/justify_items.d.ts +0 -1
  367. package/dist/types/src/ui/system/flex_container/justify_items.d.ts.map +1 -1
  368. package/dist/types/src/ui/system/flex_item/align_self.d.ts +0 -1
  369. package/dist/types/src/ui/system/flex_item/align_self.d.ts.map +1 -1
  370. package/dist/types/src/ui/system/flex_item/flex.d.ts +0 -1
  371. package/dist/types/src/ui/system/flex_item/flex.d.ts.map +1 -1
  372. package/dist/types/src/ui/system/flex_item/flex_basis.d.ts +0 -1
  373. package/dist/types/src/ui/system/flex_item/flex_basis.d.ts.map +1 -1
  374. package/dist/types/src/ui/system/flex_item/flex_grow.d.ts +0 -1
  375. package/dist/types/src/ui/system/flex_item/flex_grow.d.ts.map +1 -1
  376. package/dist/types/src/ui/system/flex_item/flex_item_set.d.ts +0 -1
  377. package/dist/types/src/ui/system/flex_item/flex_item_set.d.ts.map +1 -1
  378. package/dist/types/src/ui/system/flex_item/flex_shrink.d.ts +0 -1
  379. package/dist/types/src/ui/system/flex_item/flex_shrink.d.ts.map +1 -1
  380. package/dist/types/src/ui/system/flex_item/justify_self.d.ts +0 -1
  381. package/dist/types/src/ui/system/flex_item/justify_self.d.ts.map +1 -1
  382. package/dist/types/src/ui/system/flex_item/order.d.ts +0 -1
  383. package/dist/types/src/ui/system/flex_item/order.d.ts.map +1 -1
  384. package/dist/types/src/ui/system/overflow.d.ts +0 -1
  385. package/dist/types/src/ui/system/overflow.d.ts.map +1 -1
  386. package/dist/types/src/ui/system/position/bottom.d.ts +0 -1
  387. package/dist/types/src/ui/system/position/bottom.d.ts.map +1 -1
  388. package/dist/types/src/ui/system/position/left.d.ts +0 -1
  389. package/dist/types/src/ui/system/position/left.d.ts.map +1 -1
  390. package/dist/types/src/ui/system/position/position.d.ts +0 -1
  391. package/dist/types/src/ui/system/position/position.d.ts.map +1 -1
  392. package/dist/types/src/ui/system/position/position_set.d.ts +0 -1
  393. package/dist/types/src/ui/system/position/position_set.d.ts.map +1 -1
  394. package/dist/types/src/ui/system/position/right.d.ts +0 -1
  395. package/dist/types/src/ui/system/position/right.d.ts.map +1 -1
  396. package/dist/types/src/ui/system/position/top.d.ts +0 -1
  397. package/dist/types/src/ui/system/position/top.d.ts.map +1 -1
  398. package/dist/types/src/ui/system/position/z_index.d.ts +0 -1
  399. package/dist/types/src/ui/system/position/z_index.d.ts.map +1 -1
  400. package/dist/types/src/ui/system/spacing/margin.d.ts +0 -1
  401. package/dist/types/src/ui/system/spacing/margin.d.ts.map +1 -1
  402. package/dist/types/src/ui/system/spacing/padding.d.ts +0 -1
  403. package/dist/types/src/ui/system/spacing/padding.d.ts.map +1 -1
  404. package/dist/types/src/ui/system/spacing/spacing_set.d.ts +0 -1
  405. package/dist/types/src/ui/system/spacing/spacing_set.d.ts.map +1 -1
  406. package/dist/types/src/ui/system/typography/font_family.d.ts +0 -1
  407. package/dist/types/src/ui/system/typography/font_family.d.ts.map +1 -1
  408. package/dist/types/src/ui/system/typography/font_size.d.ts +0 -1
  409. package/dist/types/src/ui/system/typography/font_size.d.ts.map +1 -1
  410. package/dist/types/src/ui/system/typography/font_style.d.ts +0 -1
  411. package/dist/types/src/ui/system/typography/font_style.d.ts.map +1 -1
  412. package/dist/types/src/ui/system/typography/font_weight.d.ts +0 -1
  413. package/dist/types/src/ui/system/typography/font_weight.d.ts.map +1 -1
  414. package/dist/types/src/ui/system/typography/letter_spacing.d.ts +0 -1
  415. package/dist/types/src/ui/system/typography/letter_spacing.d.ts.map +1 -1
  416. package/dist/types/src/ui/system/typography/line_height.d.ts +0 -1
  417. package/dist/types/src/ui/system/typography/line_height.d.ts.map +1 -1
  418. package/dist/types/src/ui/system/typography/text_align.d.ts +0 -1
  419. package/dist/types/src/ui/system/typography/text_align.d.ts.map +1 -1
  420. package/dist/types/src/ui/system/typography/text_color.d.ts +0 -1
  421. package/dist/types/src/ui/system/typography/text_color.d.ts.map +1 -1
  422. package/dist/types/src/ui/system/typography/text_decoration.d.ts +0 -1
  423. package/dist/types/src/ui/system/typography/text_decoration.d.ts.map +1 -1
  424. package/dist/types/src/ui/system/typography/text_transform.d.ts +0 -1
  425. package/dist/types/src/ui/system/typography/text_transform.d.ts.map +1 -1
  426. package/dist/types/src/ui/system/typography/typography_set.d.ts +0 -1
  427. package/dist/types/src/ui/system/typography/typography_set.d.ts.map +1 -1
  428. package/dist/types/src/ui/system/utils/create_style_prop_types.d.ts +1 -1
  429. package/dist/types/src/ui/system/utils/create_style_prop_types.d.ts.map +1 -1
  430. package/dist/types/src/ui/system/utils/csstype.d.ts +578 -578
  431. package/dist/types/src/ui/system/utils/csstype.d.ts.map +1 -1
  432. package/dist/types/src/ui/system/utils/types.d.ts +4 -4
  433. package/dist/types/src/ui/system/utils/types.d.ts.map +1 -1
  434. package/dist/types/src/ui/text.d.ts +3 -3
  435. package/dist/types/src/ui/text.d.ts.map +1 -1
  436. package/dist/types/src/ui/text_button.d.ts +1 -1
  437. package/dist/types/src/ui/text_button.d.ts.map +1 -1
  438. package/dist/types/src/ui/theme/default_theme/heading_styles.d.ts +2 -2
  439. package/dist/types/src/ui/theme/default_theme/heading_styles.d.ts.map +1 -1
  440. package/dist/types/src/ui/theme/default_theme/index.d.ts +1 -1
  441. package/dist/types/src/ui/theme/theme_context.d.ts +1 -3
  442. package/dist/types/src/ui/theme/theme_context.d.ts.map +1 -1
  443. package/dist/types/src/ui/theme/use_theme.d.ts +1 -1
  444. package/dist/types/src/ui/tooltip.d.ts +3 -3
  445. package/dist/types/src/ui/types/data_attributes_prop.d.ts.map +1 -1
  446. package/dist/types/src/ui/types/tooltip_anchor_props.d.ts +0 -1
  447. package/dist/types/src/ui/types/tooltip_anchor_props.d.ts.map +1 -1
  448. package/dist/types/src/ui/use_base.d.ts.map +1 -1
  449. package/dist/types/src/ui/use_cursor.d.ts.map +1 -1
  450. package/dist/types/src/ui/use_form_field.d.ts +0 -2
  451. package/dist/types/src/ui/use_form_field.d.ts.map +1 -1
  452. package/dist/types/src/ui/use_records.d.ts +2 -2
  453. package/dist/types/src/ui/use_records.d.ts.map +1 -1
  454. package/dist/types/src/ui/use_session.d.ts.map +1 -1
  455. package/dist/types/src/ui/view_picker.d.ts +2 -2
  456. package/dist/types/src/ui/view_picker.d.ts.map +1 -1
  457. package/dist/types/src/ui/viewport_constraint.d.ts +3 -3
  458. package/dist/types/src/ui/viewport_constraint.d.ts.map +1 -1
  459. package/dist/types/src/viewport.d.ts +2 -2
  460. package/dist/types/src/viewport.d.ts.map +1 -1
  461. package/dist/types/src/warning.d.ts +1 -1
  462. package/dist/types/src/warning.d.ts.map +1 -1
  463. package/dist/types/stories/helpers/code_block.d.ts +2 -2
  464. package/dist/types/stories/helpers/code_block.d.ts.map +1 -1
  465. package/dist/types/stories/helpers/example.d.ts +5 -5
  466. package/dist/types/stories/helpers/example.d.ts.map +1 -1
  467. package/dist/types/stories/helpers/example_code_panel.d.ts +2 -2
  468. package/dist/types/stories/helpers/example_code_panel.d.ts.map +1 -1
  469. package/dist/types/stories/helpers/fake_cell_renderer.d.ts +2 -2
  470. package/dist/types/stories/helpers/fake_cell_renderer.d.ts.map +1 -1
  471. package/dist/types/stories/helpers/fake_foreign_record.d.ts +1 -1
  472. package/dist/types/stories/helpers/fake_foreign_record.d.ts.map +1 -1
  473. package/dist/types/stories/helpers/fake_record_card.d.ts +2 -2
  474. package/dist/types/stories/helpers/fake_record_card.d.ts.map +1 -1
  475. package/dist/types/stories/helpers/style_prop_list.d.ts +2 -2
  476. package/dist/types/stories/helpers/style_prop_list.d.ts.map +1 -1
  477. package/dist/types/stories/icon_example.d.ts +2 -2
  478. package/dist/types/stories/icon_example.d.ts.map +1 -1
  479. package/dist/types/test/airtable_interface_mocks/mock_airtable_interface.d.ts +0 -1
  480. package/dist/types/test/airtable_interface_mocks/mock_airtable_interface.d.ts.map +1 -1
  481. package/package.json +26 -25
@@ -1,135 +1,96 @@
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.slice.js");
7
+ require("core-js/modules/es.regexp.exec.js");
8
+ require("core-js/modules/es.regexp.to-string.js");
3
9
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- require("core-js/modules/es.symbol");
6
-
7
- require("core-js/modules/es.symbol.description");
8
-
9
- require("core-js/modules/es.array.filter");
10
-
11
- require("core-js/modules/es.array.iterator");
12
-
13
- require("core-js/modules/es.array.map");
14
-
15
- require("core-js/modules/es.object.entries");
16
-
17
- require("core-js/modules/es.object.to-string");
18
-
19
- require("core-js/modules/es.promise");
20
-
21
- require("core-js/modules/es.string.starts-with");
22
-
23
- require("core-js/modules/web.dom-collections.iterator");
24
-
25
10
  Object.defineProperty(exports, "__esModule", {
26
11
  value: true
27
12
  });
28
13
  exports.default = exports.WatchableRecordStoreKeys = void 0;
29
-
30
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
31
-
32
14
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
33
-
34
- require("regenerator-runtime/runtime");
35
-
15
+ require("core-js/modules/es.array.filter.js");
16
+ require("core-js/modules/es.array.iterator.js");
17
+ require("core-js/modules/es.array.map.js");
18
+ require("core-js/modules/es.object.entries.js");
19
+ require("core-js/modules/es.object.to-string.js");
20
+ require("core-js/modules/es.promise.js");
21
+ require("core-js/modules/es.string.starts-with.js");
22
+ require("core-js/modules/web.dom-collections.iterator.js");
23
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
24
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
36
25
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
37
-
26
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
38
27
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
39
-
40
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
41
-
42
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
43
-
44
28
  var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
45
-
46
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
47
-
29
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
48
30
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
49
-
50
31
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
51
-
52
32
  var _private_utils = require("../private_utils");
53
-
54
33
  var _error_utils = require("../error_utils");
55
-
56
34
  var _abstract_model_with_async_data = _interopRequireDefault(require("./abstract_model_with_async_data"));
57
-
58
35
  var _record = _interopRequireDefault(require("./record"));
59
-
60
36
  var _view_data_store = _interopRequireDefault(require("./view_data_store"));
61
-
62
- var WatchableRecordStoreKeys = Object.freeze({
37
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
38
+ 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; } }
39
+ 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; }
40
+ 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)); }
41
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
42
+ var WatchableRecordStoreKeys = exports.WatchableRecordStoreKeys = Object.freeze({
63
43
  records: 'records',
64
44
  recordIds: 'recordIds',
65
45
  cellValues: 'cellValues'
66
46
  });
67
- exports.WatchableRecordStoreKeys = WatchableRecordStoreKeys;
68
47
  var WatchableCellValuesInFieldKeyPrefix = 'cellValuesInField:';
48
+
69
49
  /**
70
50
  * The string case is to accommodate prefix keys
71
51
  *
72
52
  * @internal
73
53
  */
74
-
75
54
  /**
76
55
  * One RecordStore exists per table, and contains all the record data associated with that table.
77
56
  * Table itself is for schema information only, so isn't the appropriate place for this data.
78
57
  *
79
58
  * @internal
80
59
  */
81
- var RecordStore =
82
- /*#__PURE__*/
83
- function (_AbstractModelWithAsy) {
84
- (0, _inherits2.default)(RecordStore, _AbstractModelWithAsy);
85
- (0, _createClass2.default)(RecordStore, null, [{
86
- key: "_isWatchableKey",
87
- value: function _isWatchableKey(key) {
88
- return (0, _private_utils.isEnumValue)(WatchableRecordStoreKeys, key) || key.startsWith(WatchableCellValuesInFieldKeyPrefix);
89
- }
90
- }, {
91
- key: "_shouldLoadDataForKey",
92
- value: function _shouldLoadDataForKey(key) {
93
- // "Data" means *all* cell values in the table. If only watching records/recordIds,
94
- // we'll just load record metadata (id, createdTime, commentCount).
95
- // If only watching specific fields, we'll just load cell values in those
96
- // fields. Both of those scenarios are handled manually by this class,
97
- // instead of relying on AbstractModelWithAsyncData.
98
- return key === WatchableRecordStoreKeys.cellValues;
99
- }
100
- }]);
101
-
60
+ var RecordStore = /*#__PURE__*/function (_AbstractModelWithAsy) {
102
61
  function RecordStore(sdk, tableId) {
103
62
  var _this;
104
-
105
63
  (0, _classCallCheck2.default)(this, RecordStore);
106
- _this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(RecordStore).call(this, sdk, "".concat(tableId, "-RecordStore")));
107
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "tableId", void 0);
108
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_recordModelsById", {});
109
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_primaryFieldId", void 0);
110
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_airtableInterface", void 0);
111
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_viewDataStoresByViewId", {});
112
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_areCellValuesLoadedByFieldId", {});
113
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_pendingCellValuesLoadPromiseByFieldId", {});
114
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_cellValuesRetainCountByFieldId", {});
115
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_timeoutForRemovingFieldIds", null);
64
+ _this = _callSuper(this, RecordStore, [sdk, "".concat(tableId, "-RecordStore")]);
65
+ (0, _defineProperty2.default)(_this, "tableId", void 0);
66
+ (0, _defineProperty2.default)(_this, "_recordModelsById", {});
67
+ (0, _defineProperty2.default)(_this, "_primaryFieldId", void 0);
68
+ (0, _defineProperty2.default)(_this, "_airtableInterface", void 0);
69
+ (0, _defineProperty2.default)(_this, "_viewDataStoresByViewId", {});
70
+ // There is a lot of duplication here and in AbstractModelWithAsyncData.
71
+ // Alternatively, phase out AbstractModelWithAsyncData as a superclass
72
+ // and instead create a helper class for managing each part of the data
73
+ // tree that is loaded.
74
+ (0, _defineProperty2.default)(_this, "_areCellValuesLoadedByFieldId", {});
75
+ (0, _defineProperty2.default)(_this, "_pendingCellValuesLoadPromiseByFieldId", {});
76
+ (0, _defineProperty2.default)(_this, "_cellValuesRetainCountByFieldId", {});
77
+ (0, _defineProperty2.default)(_this, "_timeoutForRemovingFieldIds", null);
116
78
  _this._airtableInterface = sdk.__airtableInterface;
117
- _this.tableId = tableId; // A bit of a hack, but we use the primary field ID to load record
79
+ _this.tableId = tableId;
80
+ // A bit of a hack, but we use the primary field ID to load record
118
81
  // metadata (see _getFieldIdForCausingRecordMetadataToLoad). We copy the
119
82
  // ID here instead of calling this.primaryField.id since that would crash
120
83
  // when the table is getting unloaded after being deleted.
121
-
122
84
  _this._primaryFieldId = _this._data.primaryFieldId;
123
85
  return _this;
124
86
  }
125
-
126
- (0, _createClass2.default)(RecordStore, [{
87
+ (0, _inherits2.default)(RecordStore, _AbstractModelWithAsy);
88
+ return (0, _createClass2.default)(RecordStore, [{
127
89
  key: "getViewDataStore",
128
90
  value: function getViewDataStore(viewId) {
129
91
  if (this._viewDataStoresByViewId[viewId]) {
130
92
  return this._viewDataStoresByViewId[viewId];
131
93
  }
132
-
133
94
  (0, _error_utils.invariant)(this._data.viewsById[viewId], 'view must exist');
134
95
  var viewDataStore = new _view_data_store.default(this._sdk, this, viewId);
135
96
  this._viewDataStoresByViewId[viewId] = viewDataStore;
@@ -139,40 +100,31 @@ function (_AbstractModelWithAsy) {
139
100
  key: "watch",
140
101
  value: function watch(keys, callback, context) {
141
102
  var validKeys = (0, _get2.default)((0, _getPrototypeOf2.default)(RecordStore.prototype), "watch", this).call(this, keys, callback, context);
142
-
143
103
  var fieldIdsToLoad = this._getFieldIdsToLoadFromWatchableKeys(validKeys);
144
-
145
104
  if (fieldIdsToLoad.length > 0) {
146
105
  (0, _private_utils.fireAndForgetPromise)(this.loadCellValuesInFieldIdsAsync.bind(this, fieldIdsToLoad));
147
106
  }
148
-
149
107
  return validKeys;
150
108
  }
151
109
  }, {
152
110
  key: "unwatch",
153
111
  value: function unwatch(keys, callback, context) {
154
112
  var validKeys = (0, _get2.default)((0, _getPrototypeOf2.default)(RecordStore.prototype), "unwatch", this).call(this, keys, callback, context);
155
-
156
113
  var fieldIdsToUnload = this._getFieldIdsToLoadFromWatchableKeys(validKeys);
157
-
158
114
  if (fieldIdsToUnload.length > 0) {
159
115
  this.unloadCellValuesInFieldIds(fieldIdsToUnload);
160
116
  }
161
-
162
117
  return validKeys;
163
118
  }
164
119
  }, {
165
120
  key: "_getFieldIdsToLoadFromWatchableKeys",
166
121
  value: function _getFieldIdsToLoadFromWatchableKeys(keys) {
167
122
  var fieldIdsToLoad = [];
168
- var _iteratorNormalCompletion = true;
169
- var _didIteratorError = false;
170
- var _iteratorError = undefined;
171
-
123
+ var _iterator = _createForOfIteratorHelper(keys),
124
+ _step;
172
125
  try {
173
- for (var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
126
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
174
127
  var key = _step.value;
175
-
176
128
  if (key.startsWith(WatchableCellValuesInFieldKeyPrefix)) {
177
129
  var fieldId = key.substring(WatchableCellValuesInFieldKeyPrefix.length);
178
130
  fieldIdsToLoad.push(fieldId);
@@ -181,45 +133,64 @@ function (_AbstractModelWithAsy) {
181
133
  }
182
134
  }
183
135
  } catch (err) {
184
- _didIteratorError = true;
185
- _iteratorError = err;
136
+ _iterator.e(err);
186
137
  } finally {
187
- try {
188
- if (!_iteratorNormalCompletion && _iterator.return != null) {
189
- _iterator.return();
190
- }
191
- } finally {
192
- if (_didIteratorError) {
193
- throw _iteratorError;
194
- }
195
- }
138
+ _iterator.f();
196
139
  }
197
-
198
140
  return fieldIdsToLoad;
199
141
  }
142
+ }, {
143
+ key: "_dataOrNullIfDeleted",
144
+ get: function get() {
145
+ var _this$_baseData$table;
146
+ return (_this$_baseData$table = this._baseData.tablesById[this.tableId]) !== null && _this$_baseData$table !== void 0 ? _this$_baseData$table : null;
147
+ }
200
148
  }, {
201
149
  key: "_onChangeIsDataLoaded",
202
- value: function _onChangeIsDataLoaded() {} // noop
150
+ value: function _onChangeIsDataLoaded() {
151
+ // noop
152
+ }
203
153
 
204
154
  /**
205
155
  * The records in this table. The order is arbitrary since records are
206
156
  * only ordered in the context of a specific view.
207
157
  */
158
+ }, {
159
+ key: "records",
160
+ get: function get() {
161
+ var recordsById = this._data.recordsById;
162
+ (0, _error_utils.invariant)(recordsById, 'Record metadata is not loaded');
163
+ var records = Object.keys(recordsById).map(recordId => {
164
+ var record = this.getRecordByIdIfExists(recordId);
165
+ (0, _error_utils.invariant)(record, 'record');
166
+ return record;
167
+ });
168
+ return records;
169
+ }
208
170
 
171
+ /**
172
+ * The record IDs in this table. The order is arbitrary since records are
173
+ * only ordered in the context of a specific view.
174
+ */
175
+ }, {
176
+ key: "recordIds",
177
+ get: function get() {
178
+ var recordsById = this._data.recordsById;
179
+ (0, _error_utils.invariant)(recordsById, 'Record metadata is not loaded');
180
+ return Object.keys(recordsById);
181
+ }
209
182
  }, {
210
183
  key: "getRecordByIdIfExists",
211
184
  value: function getRecordByIdIfExists(recordId) {
212
185
  var recordsById = this._data.recordsById;
213
186
  (0, _error_utils.invariant)(recordsById, 'Record metadata is not loaded');
214
187
  (0, _error_utils.invariant)(typeof recordId === 'string', 'getRecordById expects a string');
215
-
216
188
  if (!recordsById[recordId]) {
217
189
  return null;
218
190
  } else {
219
191
  if (this._recordModelsById[recordId]) {
220
192
  return this._recordModelsById[recordId];
221
193
  }
222
-
223
194
  var newRecord = new _record.default(this._sdk, this, this._sdk.base.getTableById(this.tableId), recordId);
224
195
  this._recordModelsById[recordId] = newRecord;
225
196
  return newRecord;
@@ -233,66 +204,59 @@ function (_AbstractModelWithAsy) {
233
204
  // to the cell values and it will refuse a request for new subscription
234
205
  for (var _i = 0, _Object$keys = Object.keys(this._cellValuesRetainCountByFieldId); _i < _Object$keys.length; _i++) {
235
206
  var fieldId = _Object$keys[_i];
236
-
237
207
  while (this._cellValuesRetainCountByFieldId[fieldId] && this._cellValuesRetainCountByFieldId[fieldId] > 0) {
238
208
  this.unloadCellValuesInFieldIds([fieldId]);
239
209
  }
240
210
  }
211
+ this._forceUnload();
241
212
 
242
- this._forceUnload(); // similarly unsubscribe from the view data.
213
+ // similarly unsubscribe from the view data.
243
214
  // this comes after _forceUnload to avoid over releasing the table data.
244
-
245
-
246
- var _iteratorNormalCompletion2 = true;
247
- var _didIteratorError2 = false;
248
- var _iteratorError2 = undefined;
249
-
215
+ var _iterator2 = _createForOfIteratorHelper((0, _private_utils.values)(this._viewDataStoresByViewId)),
216
+ _step2;
250
217
  try {
251
- for (var _iterator2 = (0, _private_utils.values)(this._viewDataStoresByViewId)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
218
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
252
219
  var viewDataStore = _step2.value;
253
-
254
220
  viewDataStore.__onDataDeletion();
255
221
  }
256
222
  } catch (err) {
257
- _didIteratorError2 = true;
258
- _iteratorError2 = err;
223
+ _iterator2.e(err);
259
224
  } finally {
260
- try {
261
- if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
262
- _iterator2.return();
263
- }
264
- } finally {
265
- if (_didIteratorError2) {
266
- throw _iteratorError2;
267
- }
268
- }
225
+ _iterator2.f();
269
226
  }
270
227
  }
228
+
271
229
  /**
272
230
  * Record metadata means record IDs, createdTime, and commentCount are loaded.
273
231
  * Record metadata must be loaded before creating, deleting, or updating records.
274
232
  */
275
-
233
+ }, {
234
+ key: "isRecordMetadataLoaded",
235
+ get: function get() {
236
+ return !!this._data.recordsById;
237
+ }
276
238
  }, {
277
239
  key: "loadRecordMetadataAsync",
278
- value: function loadRecordMetadataAsync() {
279
- return _regenerator.default.async(function loadRecordMetadataAsync$(_context) {
280
- while (1) {
281
- switch (_context.prev = _context.next) {
240
+ value: function () {
241
+ var _loadRecordMetadataAsync = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
242
+ return _regenerator.default.wrap(function _callee$(_context) {
243
+ while (1) switch (_context.prev = _context.next) {
282
244
  case 0:
283
245
  _context.next = 2;
284
- return _regenerator.default.awrap(this.loadCellValuesInFieldIdsAsync([this._getFieldIdForCausingRecordMetadataToLoad()]));
285
-
246
+ return this.loadCellValuesInFieldIdsAsync([this._getFieldIdForCausingRecordMetadataToLoad()]);
286
247
  case 2:
287
248
  return _context.abrupt("return", _context.sent);
288
-
289
249
  case 3:
290
250
  case "end":
291
251
  return _context.stop();
292
252
  }
293
- }
294
- }, null, this);
295
- }
253
+ }, _callee, this);
254
+ }));
255
+ function loadRecordMetadataAsync() {
256
+ return _loadRecordMetadataAsync.apply(this, arguments);
257
+ }
258
+ return loadRecordMetadataAsync;
259
+ }()
296
260
  }, {
297
261
  key: "unloadRecordMetadata",
298
262
  value: function unloadRecordMetadata() {
@@ -314,404 +278,249 @@ function (_AbstractModelWithAsy) {
314
278
  }
315
279
  }, {
316
280
  key: "loadCellValuesInFieldIdsAsync",
317
- value: function loadCellValuesInFieldIdsAsync(fieldIds) {
318
- var fieldIdsWhichAreNotAlreadyLoadedOrLoading, pendingLoadPromises, _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, _fieldId, pendingLoadPromise, loadFieldsWhichAreNotAlreadyLoadedOrLoadingPromise, _iteratorNormalCompletion4, _didIteratorError4, _iteratorError4, _iterator4, _step4, fieldId;
319
-
320
- return _regenerator.default.async(function loadCellValuesInFieldIdsAsync$(_context2) {
321
- while (1) {
322
- switch (_context2.prev = _context2.next) {
281
+ value: function () {
282
+ var _loadCellValuesInFieldIdsAsync2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(fieldIds) {
283
+ var fieldIdsWhichAreNotAlreadyLoadedOrLoading, pendingLoadPromises, _iterator3, _step3, _fieldId, pendingLoadPromise, loadFieldsWhichAreNotAlreadyLoadedOrLoadingPromise, _iterator4, _step4, fieldId;
284
+ return _regenerator.default.wrap(function _callee2$(_context2) {
285
+ while (1) switch (_context2.prev = _context2.next) {
323
286
  case 0:
324
287
  this._assertNotForceUnloaded();
325
-
326
288
  fieldIdsWhichAreNotAlreadyLoadedOrLoading = [];
327
289
  pendingLoadPromises = [];
328
- _iteratorNormalCompletion3 = true;
329
- _didIteratorError3 = false;
330
- _iteratorError3 = undefined;
331
- _context2.prev = 6;
332
-
333
- for (_iterator3 = fieldIds[Symbol.iterator](); !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
334
- _fieldId = _step3.value;
335
-
336
- if (this._cellValuesRetainCountByFieldId[_fieldId] !== undefined) {
337
- this._cellValuesRetainCountByFieldId[_fieldId]++;
338
- } else {
339
- this._cellValuesRetainCountByFieldId[_fieldId] = 1;
340
- } // NOTE: we don't use this.areCellValuesLoadedForFieldId() here because
341
- // that will return true if the cell values are loaded as a result
342
- // of the entire table being loaded. In that scenario, we still
343
- // want to separately load the cell values for the field so there
344
- // is a separate subscription. Otherwise, when the table data unloads,
345
- // the field data would unload as well. This can be improved by just
346
- // subscribing to the field data without fetching it, since the cell
347
- // values are already in the block frame.
348
-
349
-
350
- if (!this._areCellValuesLoadedByFieldId[_fieldId]) {
351
- pendingLoadPromise = this._pendingCellValuesLoadPromiseByFieldId[_fieldId];
352
-
353
- if (pendingLoadPromise) {
354
- pendingLoadPromises.push(pendingLoadPromise);
290
+ _iterator3 = _createForOfIteratorHelper(fieldIds);
291
+ try {
292
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
293
+ _fieldId = _step3.value;
294
+ if (this._cellValuesRetainCountByFieldId[_fieldId] !== undefined) {
295
+ this._cellValuesRetainCountByFieldId[_fieldId]++;
355
296
  } else {
356
- fieldIdsWhichAreNotAlreadyLoadedOrLoading.push(_fieldId);
297
+ this._cellValuesRetainCountByFieldId[_fieldId] = 1;
357
298
  }
358
- }
359
- }
360
-
361
- _context2.next = 14;
362
- break;
363
-
364
- case 10:
365
- _context2.prev = 10;
366
- _context2.t0 = _context2["catch"](6);
367
- _didIteratorError3 = true;
368
- _iteratorError3 = _context2.t0;
369
-
370
- case 14:
371
- _context2.prev = 14;
372
- _context2.prev = 15;
373
-
374
- if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
375
- _iterator3.return();
376
- }
377
-
378
- case 17:
379
- _context2.prev = 17;
380
-
381
- if (!_didIteratorError3) {
382
- _context2.next = 20;
383
- break;
384
- }
385
299
 
386
- throw _iteratorError3;
387
-
388
- case 20:
389
- return _context2.finish(17);
390
-
391
- case 21:
392
- return _context2.finish(14);
393
-
394
- case 22:
395
- if (!(fieldIdsWhichAreNotAlreadyLoadedOrLoading.length > 0)) {
396
- _context2.next = 45;
397
- break;
398
- }
399
-
400
- // Could inline _loadCellValuesInFieldIdsAsync, but following the
401
- // pattern from AbstractModelWithAsyncData where the public method
402
- // is responsible for updating retain counts and the private method
403
- // actually fetches data.
404
- loadFieldsWhichAreNotAlreadyLoadedOrLoadingPromise = this._loadCellValuesInFieldIdsAsync(fieldIdsWhichAreNotAlreadyLoadedOrLoading);
405
- pendingLoadPromises.push(loadFieldsWhichAreNotAlreadyLoadedOrLoadingPromise);
406
- _iteratorNormalCompletion4 = true;
407
- _didIteratorError4 = false;
408
- _iteratorError4 = undefined;
409
- _context2.prev = 28;
410
-
411
- for (_iterator4 = fieldIdsWhichAreNotAlreadyLoadedOrLoading[Symbol.iterator](); !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
412
- fieldId = _step4.value;
413
- this._pendingCellValuesLoadPromiseByFieldId[fieldId] = loadFieldsWhichAreNotAlreadyLoadedOrLoadingPromise;
414
- } // Doing `.then` instead of performing these actions directly in
415
- // _loadCellValuesInFieldIdsAsync so this is similar to
416
- // AbstractModelWithAsyncData. The idea is to refactor to avoid code
417
- // duplication, so keeping them similar for now hopefully will make the
418
- // refactor simpler.
419
-
420
-
421
- _context2.next = 36;
422
- break;
423
-
424
- case 32:
425
- _context2.prev = 32;
426
- _context2.t1 = _context2["catch"](28);
427
- _didIteratorError4 = true;
428
- _iteratorError4 = _context2.t1;
429
-
430
- case 36:
431
- _context2.prev = 36;
432
- _context2.prev = 37;
433
-
434
- if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
435
- _iterator4.return();
436
- }
437
-
438
- case 39:
439
- _context2.prev = 39;
440
-
441
- if (!_didIteratorError4) {
442
- _context2.next = 42;
443
- break;
300
+ // NOTE: we don't use this.areCellValuesLoadedForFieldId() here because
301
+ // that will return true if the cell values are loaded as a result
302
+ // of the entire table being loaded. In that scenario, we still
303
+ // want to separately load the cell values for the field so there
304
+ // is a separate subscription. Otherwise, when the table data unloads,
305
+ // the field data would unload as well. This can be improved by just
306
+ // subscribing to the field data without fetching it, since the cell
307
+ // values are already in the block frame.
308
+ if (!this._areCellValuesLoadedByFieldId[_fieldId]) {
309
+ pendingLoadPromise = this._pendingCellValuesLoadPromiseByFieldId[_fieldId];
310
+ if (pendingLoadPromise) {
311
+ pendingLoadPromises.push(pendingLoadPromise);
312
+ } else {
313
+ fieldIdsWhichAreNotAlreadyLoadedOrLoading.push(_fieldId);
314
+ }
315
+ }
316
+ }
317
+ } catch (err) {
318
+ _iterator3.e(err);
319
+ } finally {
320
+ _iterator3.f();
444
321
  }
445
-
446
- throw _iteratorError4;
447
-
448
- case 42:
449
- return _context2.finish(39);
450
-
451
- case 43:
452
- return _context2.finish(36);
453
-
454
- case 44:
455
- loadFieldsWhichAreNotAlreadyLoadedOrLoadingPromise.then(changedKeys => {
456
- var _iteratorNormalCompletion5 = true;
457
- var _didIteratorError5 = false;
458
- var _iteratorError5 = undefined;
459
-
322
+ if (fieldIdsWhichAreNotAlreadyLoadedOrLoading.length > 0) {
323
+ // Could inline _loadCellValuesInFieldIdsAsync, but following the
324
+ // pattern from AbstractModelWithAsyncData where the public method
325
+ // is responsible for updating retain counts and the private method
326
+ // actually fetches data.
327
+ loadFieldsWhichAreNotAlreadyLoadedOrLoadingPromise = this._loadCellValuesInFieldIdsAsync(fieldIdsWhichAreNotAlreadyLoadedOrLoading);
328
+ pendingLoadPromises.push(loadFieldsWhichAreNotAlreadyLoadedOrLoadingPromise);
329
+ _iterator4 = _createForOfIteratorHelper(fieldIdsWhichAreNotAlreadyLoadedOrLoading);
460
330
  try {
461
- for (var _iterator5 = fieldIdsWhichAreNotAlreadyLoadedOrLoading[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
462
- var fieldId = _step5.value;
463
- this._areCellValuesLoadedByFieldId[fieldId] = true;
464
- this._pendingCellValuesLoadPromiseByFieldId[fieldId] = undefined;
331
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
332
+ fieldId = _step4.value;
333
+ this._pendingCellValuesLoadPromiseByFieldId[fieldId] = loadFieldsWhichAreNotAlreadyLoadedOrLoadingPromise;
465
334
  }
335
+ // Doing `.then` instead of performing these actions directly in
336
+ // _loadCellValuesInFieldIdsAsync so this is similar to
337
+ // AbstractModelWithAsyncData. The idea is to refactor to avoid code
338
+ // duplication, so keeping them similar for now hopefully will make the
339
+ // refactor simpler.
466
340
  } catch (err) {
467
- _didIteratorError5 = true;
468
- _iteratorError5 = err;
341
+ _iterator4.e(err);
469
342
  } finally {
343
+ _iterator4.f();
344
+ }
345
+ loadFieldsWhichAreNotAlreadyLoadedOrLoadingPromise.then(changedKeys => {
346
+ var _iterator5 = _createForOfIteratorHelper(fieldIdsWhichAreNotAlreadyLoadedOrLoading),
347
+ _step5;
470
348
  try {
471
- if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
472
- _iterator5.return();
349
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
350
+ var fieldId = _step5.value;
351
+ this._areCellValuesLoadedByFieldId[fieldId] = true;
352
+ this._pendingCellValuesLoadPromiseByFieldId[fieldId] = undefined;
473
353
  }
354
+ } catch (err) {
355
+ _iterator5.e(err);
474
356
  } finally {
475
- if (_didIteratorError5) {
476
- throw _iteratorError5;
477
- }
478
- }
479
- }
480
-
481
- var _iteratorNormalCompletion6 = true;
482
- var _didIteratorError6 = false;
483
- var _iteratorError6 = undefined;
484
-
485
- try {
486
- for (var _iterator6 = changedKeys[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
487
- var key = _step6.value;
488
-
489
- this._onChange(key);
357
+ _iterator5.f();
490
358
  }
491
- } catch (err) {
492
- _didIteratorError6 = true;
493
- _iteratorError6 = err;
494
- } finally {
359
+ var _iterator6 = _createForOfIteratorHelper(changedKeys),
360
+ _step6;
495
361
  try {
496
- if (!_iteratorNormalCompletion6 && _iterator6.return != null) {
497
- _iterator6.return();
362
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
363
+ var key = _step6.value;
364
+ this._onChange(key);
498
365
  }
366
+ } catch (err) {
367
+ _iterator6.e(err);
499
368
  } finally {
500
- if (_didIteratorError6) {
501
- throw _iteratorError6;
502
- }
369
+ _iterator6.f();
503
370
  }
504
- }
505
- });
506
-
507
- case 45:
371
+ });
372
+ }
508
373
  // Since we are incrementing fieldIds, it's necessary to restart any pending timeouts
509
374
  // to unload data. This is because it's possible for a timeout to fire while a queryResult
510
375
  // is actively unloading, and erroneously unload data. Data must be unloaded _after_ the queryResult.
511
376
  this._restartTimeoutToUnloadFieldIdsIfTimeoutIsActive();
512
-
513
- _context2.next = 48;
514
- return _regenerator.default.awrap(Promise.all(pendingLoadPromises));
515
-
516
- case 48:
377
+ _context2.next = 9;
378
+ return Promise.all(pendingLoadPromises);
379
+ case 9:
517
380
  case "end":
518
381
  return _context2.stop();
519
382
  }
520
- }
521
- }, null, this, [[6, 10, 14, 22], [15,, 17, 21], [28, 32, 36, 44], [37,, 39, 43]]);
522
- }
383
+ }, _callee2, this);
384
+ }));
385
+ function loadCellValuesInFieldIdsAsync(_x) {
386
+ return _loadCellValuesInFieldIdsAsync2.apply(this, arguments);
387
+ }
388
+ return loadCellValuesInFieldIdsAsync;
389
+ }()
523
390
  }, {
524
391
  key: "_loadCellValuesInFieldIdsAsync",
525
- value: function _loadCellValuesInFieldIdsAsync(fieldIds) {
526
- var _ref, newRecordsById, existingRecordsById, _iteratorNormalCompletion7, _didIteratorError7, _iteratorError7, _iterator7, _step7, _step7$value, recordId, newRecordObj, existingRecordObj, isCommentCountTypesSame, isCreatedTimeTypesSame, existingCellValuesByFieldId, i, fieldId, changedKeys;
527
-
528
- return _regenerator.default.async(function _loadCellValuesInFieldIdsAsync$(_context3) {
529
- while (1) {
530
- switch (_context3.prev = _context3.next) {
392
+ value: function () {
393
+ var _loadCellValuesInFieldIdsAsync3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(fieldIds) {
394
+ var _yield$this$_airtable, newRecordsById, existingRecordsById, _iterator7, _step7, _step7$value, recordId, newRecordObj, existingRecordObj, isCommentCountTypesSame, isCreatedTimeTypesSame, existingCellValuesByFieldId, i, fieldId, changedKeys;
395
+ return _regenerator.default.wrap(function _callee3$(_context3) {
396
+ while (1) switch (_context3.prev = _context3.next) {
531
397
  case 0:
532
398
  _context3.next = 2;
533
- return _regenerator.default.awrap(this._airtableInterface.fetchAndSubscribeToCellValuesInFieldsAsync(this.tableId, fieldIds));
534
-
399
+ return this._airtableInterface.fetchAndSubscribeToCellValuesInFieldsAsync(this.tableId, fieldIds);
535
400
  case 2:
536
- _ref = _context3.sent;
537
- newRecordsById = _ref.recordsById;
538
-
401
+ _yield$this$_airtable = _context3.sent;
402
+ newRecordsById = _yield$this$_airtable.recordsById;
539
403
  // Merge with existing data.
540
404
  if (!this._data.recordsById) {
541
405
  this._data.recordsById = {};
542
406
  }
543
-
544
407
  existingRecordsById = this._data.recordsById;
545
- _iteratorNormalCompletion7 = true;
546
- _didIteratorError7 = false;
547
- _iteratorError7 = undefined;
548
- _context3.prev = 9;
549
-
550
- for (_iterator7 = (0, _private_utils.entries)((0, _private_utils.cast)(newRecordsById))[Symbol.iterator](); !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
551
- _step7$value = (0, _slicedToArray2.default)(_step7.value, 2), recordId = _step7$value[0], newRecordObj = _step7$value[1];
552
-
553
- if (!(0, _private_utils.has)(existingRecordsById, recordId)) {
554
- existingRecordsById[recordId] = newRecordObj;
555
- } else {
556
- existingRecordObj = existingRecordsById[recordId]; // Metadata (createdTime, commentCount) should generally be up to date,
557
- // but can be out of date in the rare scenario where realtime
558
- // data has not yet been delivered to the SDK, but is populated in hyperbase
559
- // at the time this new fetch is executed.
560
- // istanbul ignore next
561
-
562
- if (existingRecordObj.commentCount !== newRecordObj.commentCount) {
563
- isCommentCountTypesSame = typeof existingRecordObj.commentCount !== typeof newRecordObj.commentCount;
564
- (0, _error_utils.logErrorToSentry)('comment count out of sync - types are same: %s', {
565
- isCommentCountTypesSame
566
- });
567
- } // istanbul ignore next
568
-
569
-
570
- if (existingRecordObj.createdTime !== newRecordObj.createdTime) {
571
- isCreatedTimeTypesSame = typeof existingRecordObj.createdTime !== typeof newRecordObj.createdTime;
572
- (0, _error_utils.logErrorToSentry)('created time out of sync - types are same: %s', {
573
- isCreatedTimeTypesSame
574
- });
575
- }
576
-
577
- if (!existingRecordObj.cellValuesByFieldId) {
578
- existingRecordObj.cellValuesByFieldId = {};
579
- }
580
-
581
- existingCellValuesByFieldId = existingRecordObj.cellValuesByFieldId;
408
+ _iterator7 = _createForOfIteratorHelper((0, _private_utils.entries)((0, _private_utils.cast)(newRecordsById)));
409
+ try {
410
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
411
+ _step7$value = (0, _slicedToArray2.default)(_step7.value, 2), recordId = _step7$value[0], newRecordObj = _step7$value[1];
412
+ if (!(0, _private_utils.has)(existingRecordsById, recordId)) {
413
+ existingRecordsById[recordId] = newRecordObj;
414
+ } else {
415
+ existingRecordObj = existingRecordsById[recordId]; // Metadata (createdTime, commentCount) should generally be up to date,
416
+ // but can be out of date in the rare scenario where realtime
417
+ // data has not yet been delivered to the SDK, but is populated in hyperbase
418
+ // at the time this new fetch is executed.
419
+ // istanbul ignore next
420
+ if (existingRecordObj.commentCount !== newRecordObj.commentCount) {
421
+ isCommentCountTypesSame = typeof existingRecordObj.commentCount !== typeof newRecordObj.commentCount;
422
+ (0, _error_utils.logErrorToSentry)('comment count out of sync - types are same: %s', {
423
+ isCommentCountTypesSame
424
+ });
425
+ }
582
426
 
583
- for (i = 0; i < fieldIds.length; i++) {
584
- fieldId = fieldIds[i];
585
- existingCellValuesByFieldId[fieldId] = newRecordObj.cellValuesByFieldId ? newRecordObj.cellValuesByFieldId[fieldId] : undefined;
427
+ // istanbul ignore next
428
+ if (existingRecordObj.createdTime !== newRecordObj.createdTime) {
429
+ isCreatedTimeTypesSame = typeof existingRecordObj.createdTime !== typeof newRecordObj.createdTime;
430
+ (0, _error_utils.logErrorToSentry)('created time out of sync - types are same: %s', {
431
+ isCreatedTimeTypesSame
432
+ });
433
+ }
434
+ if (!existingRecordObj.cellValuesByFieldId) {
435
+ existingRecordObj.cellValuesByFieldId = {};
436
+ }
437
+ existingCellValuesByFieldId = existingRecordObj.cellValuesByFieldId;
438
+ for (i = 0; i < fieldIds.length; i++) {
439
+ fieldId = fieldIds[i];
440
+ existingCellValuesByFieldId[fieldId] = newRecordObj.cellValuesByFieldId ? newRecordObj.cellValuesByFieldId[fieldId] : undefined;
441
+ }
586
442
  }
587
443
  }
444
+ } catch (err) {
445
+ _iterator7.e(err);
446
+ } finally {
447
+ _iterator7.f();
588
448
  }
589
-
590
- _context3.next = 17;
591
- break;
592
-
593
- case 13:
594
- _context3.prev = 13;
595
- _context3.t0 = _context3["catch"](9);
596
- _didIteratorError7 = true;
597
- _iteratorError7 = _context3.t0;
598
-
599
- case 17:
600
- _context3.prev = 17;
601
- _context3.prev = 18;
602
-
603
- if (!_iteratorNormalCompletion7 && _iterator7.return != null) {
604
- _iterator7.return();
605
- }
606
-
607
- case 20:
608
- _context3.prev = 20;
609
-
610
- if (!_didIteratorError7) {
611
- _context3.next = 23;
612
- break;
613
- }
614
-
615
- throw _iteratorError7;
616
-
617
- case 23:
618
- return _context3.finish(20);
619
-
620
- case 24:
621
- return _context3.finish(17);
622
-
623
- case 25:
624
449
  changedKeys = fieldIds.map(fieldId => WatchableCellValuesInFieldKeyPrefix + fieldId); // Need to trigger onChange for records and recordIds since watching either
625
450
  // of those causes record metadata to be loaded (via _getFieldIdForCausingRecordMetadataToLoad)
626
451
  // and by convention we trigger a change event when data loads.
627
-
628
452
  changedKeys.push(WatchableRecordStoreKeys.records);
629
- changedKeys.push(WatchableRecordStoreKeys.recordIds); // Also trigger cellValues changes since the cell values in the fields
453
+ changedKeys.push(WatchableRecordStoreKeys.recordIds);
454
+ // Also trigger cellValues changes since the cell values in the fields
630
455
  // are now loaded.
631
-
632
456
  changedKeys.push(WatchableRecordStoreKeys.cellValues);
633
457
  return _context3.abrupt("return", changedKeys);
634
-
635
- case 30:
458
+ case 13:
636
459
  case "end":
637
460
  return _context3.stop();
638
461
  }
639
- }
640
- }, null, this, [[9, 13, 17, 25], [18,, 20, 24]]);
641
- }
462
+ }, _callee3, this);
463
+ }));
464
+ function _loadCellValuesInFieldIdsAsync(_x2) {
465
+ return _loadCellValuesInFieldIdsAsync3.apply(this, arguments);
466
+ }
467
+ return _loadCellValuesInFieldIdsAsync;
468
+ }()
642
469
  }, {
643
470
  key: "unloadCellValuesInFieldIds",
644
471
  value: function unloadCellValuesInFieldIds(fieldIds) {
645
472
  if (this._isForceUnloaded) {
646
473
  return;
647
474
  }
648
-
649
- var _iteratorNormalCompletion8 = true;
650
- var _didIteratorError8 = false;
651
- var _iteratorError8 = undefined;
652
-
475
+ var _iterator8 = _createForOfIteratorHelper(fieldIds),
476
+ _step8;
653
477
  try {
654
- for (var _iterator8 = fieldIds[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
478
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
655
479
  var fieldId = _step8.value;
656
480
  var fieldRetainCount = this._cellValuesRetainCountByFieldId[fieldId] || 0;
657
481
  fieldRetainCount--;
658
-
659
482
  if (fieldRetainCount < 0) {
660
483
  console.log('Field data over-released'); // eslint-disable-line no-console
661
-
662
484
  fieldRetainCount = 0;
663
485
  }
664
-
665
486
  this._cellValuesRetainCountByFieldId[fieldId] = fieldRetainCount;
666
- } // Don't unload immediately. Wait a while in case something else
487
+ }
488
+ // Don't unload immediately. Wait a while in case something else
667
489
  // requests the data, so we can avoid going back to liveapp or
668
490
  // the network.
669
-
670
491
  } catch (err) {
671
- _didIteratorError8 = true;
672
- _iteratorError8 = err;
492
+ _iterator8.e(err);
673
493
  } finally {
674
- try {
675
- if (!_iteratorNormalCompletion8 && _iterator8.return != null) {
676
- _iterator8.return();
677
- }
678
- } finally {
679
- if (_didIteratorError8) {
680
- throw _iteratorError8;
681
- }
682
- }
494
+ _iterator8.f();
683
495
  }
684
-
685
496
  this._startTimeoutToUnloadForFieldIdsIfNeeded();
686
- } // This unloads all fields where the retain count is at zero, and if any other
497
+ }
498
+
499
+ // This unloads all fields where the retain count is at zero, and if any other
687
500
  // request to unload fields is pending - cancels it and restarts it.
688
501
  // This is important because fields must always be unloaded at least __DATA_UNLOAD_DELAY_MS
689
502
  // after the unload is requested so that any QueryResults relying on them properly
690
503
  // unload either first, or at the same time
691
-
692
504
  }, {
693
505
  key: "_startTimeoutToUnloadForFieldIdsIfNeeded",
694
506
  value: function _startTimeoutToUnloadForFieldIdsIfNeeded() {
695
507
  var fieldIdsWithZeroRetainCount = [];
696
-
697
508
  for (var _i2 = 0, _Object$entries = Object.entries(this._cellValuesRetainCountByFieldId); _i2 < _Object$entries.length; _i2++) {
698
509
  var _Object$entries$_i = (0, _slicedToArray2.default)(_Object$entries[_i2], 2),
699
- fieldId = _Object$entries$_i[0],
700
- retainCount = _Object$entries$_i[1];
701
-
510
+ fieldId = _Object$entries$_i[0],
511
+ retainCount = _Object$entries$_i[1];
702
512
  if (retainCount === 0) {
703
513
  fieldIdsWithZeroRetainCount.push(fieldId);
704
514
  }
705
- } // Cancel any pending timeouts before proceeding
515
+ }
516
+
517
+ // Cancel any pending timeouts before proceeding
706
518
  // This should be canceled even if there aren't any fields to unload as that means
707
519
  // that there has been loading that's occured that makes the pending request invalid
708
-
709
-
710
520
  if (this._timeoutForRemovingFieldIds) {
711
521
  clearTimeout(this._timeoutForRemovingFieldIds);
712
522
  this._timeoutForRemovingFieldIds = null;
713
523
  }
714
-
715
524
  if (fieldIdsWithZeroRetainCount.length > 0) {
716
525
  this._timeoutForRemovingFieldIds = setTimeout(() => {
717
526
  // Make sure the retain count is still zero, since it may
@@ -720,42 +529,29 @@ function (_AbstractModelWithAsy) {
720
529
  // It's necessary to also check that the field is loaded, as it's possible
721
530
  // for an unload to trigger with fields that have already been removed.
722
531
  return this._cellValuesRetainCountByFieldId[fieldId] === 0 && this._areCellValuesLoadedByFieldId[fieldId];
723
- }); // istanbul ignore else
724
-
532
+ });
533
+ // istanbul ignore else
725
534
  if (fieldIdsToUnload.length > 0) {
726
535
  // Set _areCellValuesLoadedByFieldId to false before calling _unloadCellValuesInFieldIds
727
536
  // since _unloadCellValuesInFieldIds will check if *any* fields are still loaded.
728
- var _iteratorNormalCompletion9 = true;
729
- var _didIteratorError9 = false;
730
- var _iteratorError9 = undefined;
731
-
537
+ var _iterator9 = _createForOfIteratorHelper(fieldIdsToUnload),
538
+ _step9;
732
539
  try {
733
- for (var _iterator9 = fieldIdsToUnload[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
734
- var fieldId = _step9.value;
735
- this._areCellValuesLoadedByFieldId[fieldId] = false;
540
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
541
+ var _fieldId2 = _step9.value;
542
+ this._areCellValuesLoadedByFieldId[_fieldId2] = false;
736
543
  }
737
544
  } catch (err) {
738
- _didIteratorError9 = true;
739
- _iteratorError9 = err;
545
+ _iterator9.e(err);
740
546
  } finally {
741
- try {
742
- if (!_iteratorNormalCompletion9 && _iterator9.return != null) {
743
- _iterator9.return();
744
- }
745
- } finally {
746
- if (_didIteratorError9) {
747
- throw _iteratorError9;
748
- }
749
- }
547
+ _iterator9.f();
750
548
  }
751
-
752
549
  this._unloadCellValuesInFieldIds(fieldIdsToUnload);
753
550
  } else {
754
551
  // This shouldn't be possible because we always cancel the timer if fieldIds loadedness
755
552
  // status ever changes
756
553
  (0, _error_utils.logErrorToSentry)('fieldIdsToUnload is empty, this likely means the unload timer is not properly reset.');
757
554
  }
758
-
759
555
  this._timeoutForRemovingFieldIds = null;
760
556
  }, _abstract_model_with_async_data.default.__DATA_UNLOAD_DELAY_MS);
761
557
  }
@@ -771,99 +567,64 @@ function (_AbstractModelWithAsy) {
771
567
  key: "_unloadCellValuesInFieldIds",
772
568
  value: function _unloadCellValuesInFieldIds(fieldIds) {
773
569
  this._airtableInterface.unsubscribeFromCellValuesInFields(this.tableId, fieldIds);
774
-
775
570
  this._afterUnloadDataOrUnloadCellValuesInFieldIds(fieldIds);
776
571
  }
777
572
  }, {
778
573
  key: "_loadDataAsync",
779
- value: function _loadDataAsync() {
780
- var tableData, changedKeys, _iteratorNormalCompletion10, _didIteratorError10, _iteratorError10, _iterator10, _step10, fieldId;
781
-
782
- return _regenerator.default.async(function _loadDataAsync$(_context4) {
783
- while (1) {
784
- switch (_context4.prev = _context4.next) {
574
+ value: function () {
575
+ var _loadDataAsync2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
576
+ var tableData, changedKeys, _iterator10, _step10, fieldId;
577
+ return _regenerator.default.wrap(function _callee4$(_context4) {
578
+ while (1) switch (_context4.prev = _context4.next) {
785
579
  case 0:
786
580
  _context4.next = 2;
787
- return _regenerator.default.awrap(this._airtableInterface.fetchAndSubscribeToTableDataAsync(this.tableId));
788
-
581
+ return this._airtableInterface.fetchAndSubscribeToTableDataAsync(this.tableId);
789
582
  case 2:
790
583
  tableData = _context4.sent;
791
584
  this._data.recordsById = tableData.recordsById;
792
585
  changedKeys = [WatchableRecordStoreKeys.records, WatchableRecordStoreKeys.recordIds, WatchableRecordStoreKeys.cellValues];
793
- _iteratorNormalCompletion10 = true;
794
- _didIteratorError10 = false;
795
- _iteratorError10 = undefined;
796
- _context4.prev = 8;
797
-
798
- for (_iterator10 = (0, _private_utils.keys)(this._data.fieldsById)[Symbol.iterator](); !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {
799
- fieldId = _step10.value;
800
- changedKeys.push(WatchableCellValuesInFieldKeyPrefix + fieldId);
801
- }
802
-
803
- _context4.next = 16;
804
- break;
805
-
806
- case 12:
807
- _context4.prev = 12;
808
- _context4.t0 = _context4["catch"](8);
809
- _didIteratorError10 = true;
810
- _iteratorError10 = _context4.t0;
811
-
812
- case 16:
813
- _context4.prev = 16;
814
- _context4.prev = 17;
815
-
816
- if (!_iteratorNormalCompletion10 && _iterator10.return != null) {
817
- _iterator10.return();
818
- }
819
-
820
- case 19:
821
- _context4.prev = 19;
822
-
823
- if (!_didIteratorError10) {
824
- _context4.next = 22;
825
- break;
586
+ _iterator10 = _createForOfIteratorHelper((0, _private_utils.keys)(this._data.fieldsById));
587
+ try {
588
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
589
+ fieldId = _step10.value;
590
+ changedKeys.push(WatchableCellValuesInFieldKeyPrefix + fieldId);
591
+ }
592
+ } catch (err) {
593
+ _iterator10.e(err);
594
+ } finally {
595
+ _iterator10.f();
826
596
  }
827
-
828
- throw _iteratorError10;
829
-
830
- case 22:
831
- return _context4.finish(19);
832
-
833
- case 23:
834
- return _context4.finish(16);
835
-
836
- case 24:
837
597
  return _context4.abrupt("return", changedKeys);
838
-
839
- case 25:
598
+ case 8:
840
599
  case "end":
841
600
  return _context4.stop();
842
601
  }
843
- }
844
- }, null, this, [[8, 12, 16, 24], [17,, 19, 23]]);
845
- }
602
+ }, _callee4, this);
603
+ }));
604
+ function _loadDataAsync() {
605
+ return _loadDataAsync2.apply(this, arguments);
606
+ }
607
+ return _loadDataAsync;
608
+ }()
846
609
  }, {
847
610
  key: "_unloadData",
848
611
  value: function _unloadData() {
849
612
  this._airtableInterface.unsubscribeFromTableData(this.tableId);
850
-
851
613
  this._afterUnloadDataOrUnloadCellValuesInFieldIds();
852
614
  }
853
615
  }, {
854
616
  key: "_afterUnloadDataOrUnloadCellValuesInFieldIds",
855
617
  value: function _afterUnloadDataOrUnloadCellValuesInFieldIds(unloadedFieldIds) {
856
618
  var areAnyFieldsLoaded = this.isDataLoaded || (0, _private_utils.values)(this._areCellValuesLoadedByFieldId).some(isLoaded => isLoaded);
857
-
858
619
  if (!this.isDeleted) {
859
620
  if (!areAnyFieldsLoaded) {
860
621
  this._data.recordsById = undefined;
861
622
  } else if (!this.isDataLoaded) {
862
- var fieldIdsToClear; // This should be impossible - for fields should always be loaded
623
+ var fieldIdsToClear;
624
+ // This should be impossible - for fields should always be loaded
863
625
  // when attempting to unload specific fields. This codepath was previously possible
864
626
  // due to a bug. It could be converted to an invariant, but that is higher risk.
865
627
  // istanbul ignore if
866
-
867
628
  if (unloadedFieldIds) {
868
629
  // Specific fields were unloaded, so clear out the cell values for those fields.
869
630
  fieldIdsToClear = unloadedFieldIds;
@@ -875,41 +636,26 @@ function (_AbstractModelWithAsy) {
875
636
  var fieldIds = Object.keys(this._data.fieldsById);
876
637
  fieldIdsToClear = fieldIds.filter(fieldId => !this._areCellValuesLoadedByFieldId[fieldId]);
877
638
  }
878
-
879
639
  var recordsById = this._data.recordsById;
880
- var _iteratorNormalCompletion11 = true;
881
- var _didIteratorError11 = false;
882
- var _iteratorError11 = undefined;
883
-
640
+ var _iterator11 = _createForOfIteratorHelper((0, _private_utils.values)(recordsById || {})),
641
+ _step11;
884
642
  try {
885
- for (var _iterator11 = (0, _private_utils.values)(recordsById || {})[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) {
643
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
886
644
  var recordObj = _step11.value;
887
-
888
645
  for (var i = 0; i < fieldIdsToClear.length; i++) {
889
646
  var fieldId = fieldIdsToClear[i];
890
-
891
647
  if (recordObj.cellValuesByFieldId) {
892
648
  recordObj.cellValuesByFieldId[fieldId] = undefined;
893
649
  }
894
650
  }
895
651
  }
896
652
  } catch (err) {
897
- _didIteratorError11 = true;
898
- _iteratorError11 = err;
653
+ _iterator11.e(err);
899
654
  } finally {
900
- try {
901
- if (!_iteratorNormalCompletion11 && _iterator11.return != null) {
902
- _iterator11.return();
903
- }
904
- } finally {
905
- if (_didIteratorError11) {
906
- throw _iteratorError11;
907
- }
908
- }
655
+ _iterator11.f();
909
656
  }
910
657
  }
911
658
  }
912
-
913
659
  if (!areAnyFieldsLoaded) {
914
660
  this._recordModelsById = {};
915
661
  }
@@ -923,76 +669,52 @@ function (_AbstractModelWithAsy) {
923
669
  var dirtyFieldIdsSet = {};
924
670
  var addedRecordIds = [];
925
671
  var removedRecordIds = [];
926
- var _iteratorNormalCompletion12 = true;
927
- var _didIteratorError12 = false;
928
- var _iteratorError12 = undefined;
929
-
930
- try {
931
- for (var _iterator12 = (0, _private_utils.entries)(dirtyPaths.recordsById)[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {
932
- var _step12$value = (0, _slicedToArray2.default)(_step12.value, 2),
933
- recordId = _step12$value[0],
934
- dirtyRecordPaths = _step12$value[1];
935
-
936
- if (dirtyRecordPaths && dirtyRecordPaths._isDirty) {
937
- // If the entire record is dirty, it was either created or deleted.
938
- (0, _error_utils.invariant)(this._data.recordsById, 'No recordsById');
939
-
940
- if ((0, _private_utils.has)(this._data.recordsById, recordId)) {
941
- addedRecordIds.push(recordId);
942
- } else {
943
- removedRecordIds.push(recordId);
944
- var recordModel = this._recordModelsById[recordId];
945
-
946
- if (recordModel) {
947
- // Remove the Record model if it was deleted.
948
- delete this._recordModelsById[recordId];
949
- }
950
- }
672
+ for (var _i3 = 0, _arr = (0, _private_utils.entries)(dirtyPaths.recordsById); _i3 < _arr.length; _i3++) {
673
+ var _arr$_i = (0, _slicedToArray2.default)(_arr[_i3], 2),
674
+ recordId = _arr$_i[0],
675
+ dirtyRecordPaths = _arr$_i[1];
676
+ if (dirtyRecordPaths && dirtyRecordPaths._isDirty) {
677
+ // If the entire record is dirty, it was either created or deleted.
678
+ (0, _error_utils.invariant)(this._data.recordsById, 'No recordsById');
679
+ if ((0, _private_utils.has)(this._data.recordsById, recordId)) {
680
+ addedRecordIds.push(recordId);
951
681
  } else {
952
- var _recordModel = this._recordModelsById[recordId];
953
-
954
- if (_recordModel) {
955
- _recordModel.__triggerOnChangeForDirtyPaths(dirtyRecordPaths);
956
- }
957
- }
958
-
959
- var cellValuesByFieldId = dirtyRecordPaths.cellValuesByFieldId;
960
-
961
- if (cellValuesByFieldId) {
962
- for (var _i3 = 0, _Object$keys2 = Object.keys(cellValuesByFieldId); _i3 < _Object$keys2.length; _i3++) {
963
- var fieldId = _Object$keys2[_i3];
964
- dirtyFieldIdsSet[fieldId] = true;
682
+ removedRecordIds.push(recordId);
683
+ var recordModel = this._recordModelsById[recordId];
684
+ if (recordModel) {
685
+ // Remove the Record model if it was deleted.
686
+ delete this._recordModelsById[recordId];
965
687
  }
966
688
  }
967
- } // Now that we've composed our created/deleted record ids arrays, let's fire
968
- // the records onChange event if any records were created or deleted.
969
-
970
- } catch (err) {
971
- _didIteratorError12 = true;
972
- _iteratorError12 = err;
973
- } finally {
974
- try {
975
- if (!_iteratorNormalCompletion12 && _iterator12.return != null) {
976
- _iterator12.return();
689
+ } else {
690
+ var _recordModel = this._recordModelsById[recordId];
691
+ if (_recordModel) {
692
+ _recordModel.__triggerOnChangeForDirtyPaths(dirtyRecordPaths);
977
693
  }
978
- } finally {
979
- if (_didIteratorError12) {
980
- throw _iteratorError12;
694
+ }
695
+ var cellValuesByFieldId = dirtyRecordPaths.cellValuesByFieldId;
696
+ if (cellValuesByFieldId) {
697
+ for (var _i4 = 0, _Object$keys2 = Object.keys(cellValuesByFieldId); _i4 < _Object$keys2.length; _i4++) {
698
+ var fieldId = _Object$keys2[_i4];
699
+ dirtyFieldIdsSet[fieldId] = true;
981
700
  }
982
701
  }
983
702
  }
984
703
 
704
+ // Now that we've composed our created/deleted record ids arrays, let's fire
705
+ // the records onChange event if any records were created or deleted.
985
706
  if (addedRecordIds.length > 0 || removedRecordIds.length > 0) {
986
707
  this._onChange(WatchableRecordStoreKeys.records, {
987
708
  addedRecordIds,
988
709
  removedRecordIds
989
710
  });
990
-
991
711
  this._onChange(WatchableRecordStoreKeys.recordIds, {
992
712
  addedRecordIds,
993
713
  removedRecordIds
994
714
  });
995
- } // NOTE: this is an experimental (and somewhat messy) way to watch
715
+ }
716
+
717
+ // NOTE: this is an experimental (and somewhat messy) way to watch
996
718
  // for changes to cells in a table, as an alternative to implementing
997
719
  // full event bubbling. For now, it unblocks the things we want to
998
720
  // build, but we may replace it.
@@ -1001,120 +723,65 @@ function (_AbstractModelWithAsy) {
1001
723
  // TODO: don't trigger changes for fields that aren't supposed to be loaded
1002
724
  // (in some cases, e.g. record created, liveapp will send cell values
1003
725
  // that we're not subscribed to).
1004
-
1005
-
1006
726
  var fieldIds = Object.freeze(Object.keys(dirtyFieldIdsSet));
1007
727
  var recordIds = Object.freeze(Object.keys(dirtyPaths.recordsById));
1008
-
1009
728
  if (fieldIds.length > 0 && recordIds.length > 0) {
1010
729
  this._onChange(WatchableRecordStoreKeys.cellValues, {
1011
730
  recordIds,
1012
731
  fieldIds
1013
732
  });
1014
733
  }
1015
-
1016
- var _iteratorNormalCompletion13 = true;
1017
- var _didIteratorError13 = false;
1018
- var _iteratorError13 = undefined;
1019
-
734
+ var _iterator12 = _createForOfIteratorHelper(fieldIds),
735
+ _step12;
1020
736
  try {
1021
- for (var _iterator13 = fieldIds[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) {
1022
- var _fieldId2 = _step13.value;
1023
-
1024
- this._onChange(WatchableCellValuesInFieldKeyPrefix + _fieldId2, recordIds, _fieldId2);
737
+ for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
738
+ var _fieldId3 = _step12.value;
739
+ this._onChange(WatchableCellValuesInFieldKeyPrefix + _fieldId3, recordIds, _fieldId3);
1025
740
  }
1026
741
  } catch (err) {
1027
- _didIteratorError13 = true;
1028
- _iteratorError13 = err;
742
+ _iterator12.e(err);
1029
743
  } finally {
1030
- try {
1031
- if (!_iteratorNormalCompletion13 && _iterator13.return != null) {
1032
- _iterator13.return();
1033
- }
1034
- } finally {
1035
- if (_didIteratorError13) {
1036
- throw _iteratorError13;
1037
- }
1038
- }
744
+ _iterator12.f();
1039
745
  }
1040
746
  }
1041
-
1042
747
  if (dirtyPaths.viewOrder) {
1043
748
  // clean up deleted views
1044
- var _iteratorNormalCompletion14 = true;
1045
- var _didIteratorError14 = false;
1046
- var _iteratorError14 = undefined;
1047
-
749
+ var _iterator13 = _createForOfIteratorHelper((0, _private_utils.entries)(this._viewDataStoresByViewId)),
750
+ _step13;
1048
751
  try {
1049
- for (var _iterator14 = (0, _private_utils.entries)(this._viewDataStoresByViewId)[Symbol.iterator](), _step14; !(_iteratorNormalCompletion14 = (_step14 = _iterator14.next()).done); _iteratorNormalCompletion14 = true) {
1050
- var _step14$value = (0, _slicedToArray2.default)(_step14.value, 2),
1051
- viewId = _step14$value[0],
1052
- viewDataStore = _step14$value[1];
1053
-
752
+ for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
753
+ var _step13$value = (0, _slicedToArray2.default)(_step13.value, 2),
754
+ viewId = _step13$value[0],
755
+ viewDataStore = _step13$value[1];
1054
756
  if (viewDataStore.isDeleted) {
1055
757
  viewDataStore.__onDataDeletion();
1056
-
1057
758
  delete this._viewDataStoresByViewId[viewId];
1058
759
  }
1059
760
  }
1060
761
  } catch (err) {
1061
- _didIteratorError14 = true;
1062
- _iteratorError14 = err;
762
+ _iterator13.e(err);
1063
763
  } finally {
1064
- try {
1065
- if (!_iteratorNormalCompletion14 && _iterator14.return != null) {
1066
- _iterator14.return();
1067
- }
1068
- } finally {
1069
- if (_didIteratorError14) {
1070
- throw _iteratorError14;
1071
- }
1072
- }
764
+ _iterator13.f();
1073
765
  }
1074
766
  }
1075
767
  }
1076
- }, {
1077
- key: "_dataOrNullIfDeleted",
1078
- get: function get() {
1079
- var _this$_baseData$table;
1080
-
1081
- return (_this$_baseData$table = this._baseData.tablesById[this.tableId]) !== null && _this$_baseData$table !== void 0 ? _this$_baseData$table : null;
1082
- }
1083
- }, {
1084
- key: "records",
1085
- get: function get() {
1086
- var recordsById = this._data.recordsById;
1087
- (0, _error_utils.invariant)(recordsById, 'Record metadata is not loaded');
1088
- var records = Object.keys(recordsById).map(recordId => {
1089
- var record = this.getRecordByIdIfExists(recordId);
1090
- (0, _error_utils.invariant)(record, 'record');
1091
- return record;
1092
- });
1093
- return records;
1094
- }
1095
- /**
1096
- * The record IDs in this table. The order is arbitrary since records are
1097
- * only ordered in the context of a specific view.
1098
- */
1099
-
1100
- }, {
1101
- key: "recordIds",
1102
- get: function get() {
1103
- var recordsById = this._data.recordsById;
1104
- (0, _error_utils.invariant)(recordsById, 'Record metadata is not loaded');
1105
- return Object.keys(recordsById);
768
+ }], [{
769
+ key: "_isWatchableKey",
770
+ value: function _isWatchableKey(key) {
771
+ return (0, _private_utils.isEnumValue)(WatchableRecordStoreKeys, key) || key.startsWith(WatchableCellValuesInFieldKeyPrefix);
1106
772
  }
1107
773
  }, {
1108
- key: "isRecordMetadataLoaded",
1109
- get: function get() {
1110
- return !!this._data.recordsById;
774
+ key: "_shouldLoadDataForKey",
775
+ value: function _shouldLoadDataForKey(key) {
776
+ // "Data" means *all* cell values in the table. If only watching records/recordIds,
777
+ // we'll just load record metadata (id, createdTime, commentCount).
778
+ // If only watching specific fields, we'll just load cell values in those
779
+ // fields. Both of those scenarios are handled manually by this class,
780
+ // instead of relying on AbstractModelWithAsyncData.
781
+ return key === WatchableRecordStoreKeys.cellValues;
1111
782
  }
1112
783
  }]);
1113
- return RecordStore;
1114
784
  }(_abstract_model_with_async_data.default);
1115
785
  /** @internal */
1116
-
1117
-
1118
786
  (0, _defineProperty2.default)(RecordStore, "_className", 'RecordStore');
1119
- var _default = RecordStore;
1120
- exports.default = _default;
787
+ var _default = exports.default = RecordStore;