@airtable/blocks 0.0.0-experimental-20e3506bd-20250428 → 0.0.0-experimental-d5ee5e823-20250501

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 (128) hide show
  1. package/dist/cjs/base/models/base.js +1 -1
  2. package/dist/cjs/base/models/create_aggregators.js +1 -1
  3. package/dist/cjs/base/models/cursor.js +2 -2
  4. package/dist/cjs/base/models/field.js +2 -2
  5. package/dist/cjs/base/models/record_coloring.js +2 -2
  6. package/dist/cjs/base/models/record_query_result.js +1 -1
  7. package/dist/cjs/base/models/session.js +4 -4
  8. package/dist/cjs/base/models/table.js +2 -2
  9. package/dist/cjs/base/models/view.js +1 -1
  10. package/dist/cjs/base/perform_record_action.js +1 -1
  11. package/dist/cjs/base/sdk.js +4 -1
  12. package/dist/cjs/base/settings_button.js +2 -2
  13. package/dist/cjs/base/types/view.js +1 -1
  14. package/dist/cjs/base/ui/base_provider.js +1 -1
  15. package/dist/cjs/base/ui/expand_record.js +1 -1
  16. package/dist/cjs/base/ui/expand_record_list.js +1 -1
  17. package/dist/cjs/base/ui/expand_record_picker_async.js +1 -1
  18. package/dist/cjs/base/ui/global_alert.js +1 -1
  19. package/dist/cjs/base/ui/initialize_block.js +18 -5
  20. package/dist/cjs/base/ui/progress_bar.js +1 -1
  21. package/dist/cjs/base/ui/ui.js +1 -1
  22. package/dist/cjs/base/ui/use_base.js +1 -1
  23. package/dist/cjs/base/ui/use_cursor.js +1 -1
  24. package/dist/cjs/{shared → base}/ui/use_loadable.js +6 -6
  25. package/dist/cjs/base/ui/use_record_action_data.js +2 -2
  26. package/dist/cjs/base/ui/use_records.js +5 -5
  27. package/dist/cjs/base/ui/use_session.js +1 -1
  28. package/dist/cjs/base/ui/use_settings_button.js +1 -1
  29. package/dist/cjs/base/ui/use_view_metadata.js +2 -2
  30. package/dist/cjs/base/ui/use_viewport.js +1 -1
  31. package/dist/cjs/base/ui/viewport_constraint.js +2 -2
  32. package/dist/cjs/base/viewport.js +1 -1
  33. package/dist/cjs/interface/models/models.js +53 -0
  34. package/dist/cjs/interface/sdk.js +0 -15
  35. package/dist/cjs/interface/ui/expand_record.js +2 -1
  36. package/dist/cjs/interface/ui/initialize_block.js +14 -4
  37. package/dist/cjs/interface/ui/ui.js +20 -8
  38. package/dist/cjs/interface/ui/use_custom_properties.js +52 -5
  39. package/dist/cjs/shared/colors.js +2 -2
  40. package/dist/cjs/shared/global_config.js +45 -40
  41. package/dist/cjs/shared/models/base_core.js +34 -11
  42. package/dist/cjs/shared/models/field_core.js +1 -1
  43. package/dist/cjs/shared/models/record_core.js +1 -1
  44. package/dist/cjs/shared/models/session_core.js +1 -1
  45. package/dist/cjs/shared/models/table_core.js +1 -1
  46. package/dist/cjs/shared/sdk_core.js +5 -5
  47. package/dist/cjs/shared/types/field.js +1 -1
  48. package/dist/cjs/shared/ui/remote_utils.js +3 -3
  49. package/dist/cjs/shared/ui/use_global_config.js +13 -8
  50. package/dist/cjs/shared/ui/use_synced.js +1 -1
  51. package/dist/cjs/shared/ui/use_watchable.js +3 -22
  52. package/dist/cjs/shared/ui/with_hooks.js +3 -3
  53. package/dist/types/src/base/models/base.d.ts +1 -1
  54. package/dist/types/src/base/models/create_aggregators.d.ts +1 -1
  55. package/dist/types/src/base/models/cursor.d.ts +2 -2
  56. package/dist/types/src/base/models/field.d.ts +2 -2
  57. package/dist/types/src/base/models/record_coloring.d.ts +2 -2
  58. package/dist/types/src/base/models/record_query_result.d.ts +1 -1
  59. package/dist/types/src/base/models/session.d.ts +4 -4
  60. package/dist/types/src/base/models/table.d.ts +2 -2
  61. package/dist/types/src/base/models/view.d.ts +1 -1
  62. package/dist/types/src/base/perform_record_action.d.ts +1 -1
  63. package/dist/types/src/base/sdk.d.ts.map +1 -1
  64. package/dist/types/src/base/settings_button.d.ts +2 -2
  65. package/dist/types/src/base/types/view.d.ts +1 -1
  66. package/dist/types/src/base/ui/base_provider.d.ts +1 -1
  67. package/dist/types/src/base/ui/expand_record.d.ts +1 -1
  68. package/dist/types/src/base/ui/expand_record_list.d.ts +1 -1
  69. package/dist/types/src/base/ui/expand_record_picker_async.d.ts +1 -1
  70. package/dist/types/src/base/ui/global_alert.d.ts +1 -1
  71. package/dist/types/src/base/ui/initialize_block.d.ts +1 -1
  72. package/dist/types/src/base/ui/initialize_block.d.ts.map +1 -1
  73. package/dist/types/src/base/ui/progress_bar.d.ts +1 -1
  74. package/dist/types/src/base/ui/types/tooltip_anchor_props.d.ts +1 -0
  75. package/dist/types/src/base/ui/types/tooltip_anchor_props.d.ts.map +1 -1
  76. package/dist/types/src/base/ui/ui.d.ts +1 -1
  77. package/dist/types/src/base/ui/ui.d.ts.map +1 -1
  78. package/dist/types/src/base/ui/use_base.d.ts +1 -1
  79. package/dist/types/src/base/ui/use_cursor.d.ts +1 -1
  80. package/dist/types/src/{shared → base}/ui/use_loadable.d.ts +3 -3
  81. package/dist/types/src/base/ui/use_loadable.d.ts.map +1 -0
  82. package/dist/types/src/base/ui/use_record_action_data.d.ts +1 -1
  83. package/dist/types/src/base/ui/use_session.d.ts +1 -1
  84. package/dist/types/src/base/ui/use_settings_button.d.ts +1 -1
  85. package/dist/types/src/base/ui/use_viewport.d.ts +1 -1
  86. package/dist/types/src/base/ui/viewport_constraint.d.ts +2 -2
  87. package/dist/types/src/base/viewport.d.ts +1 -1
  88. package/dist/types/src/interface/models/models.d.ts +8 -0
  89. package/dist/types/src/interface/models/models.d.ts.map +1 -0
  90. package/dist/types/src/interface/sdk.d.ts.map +1 -1
  91. package/dist/types/src/interface/ui/expand_record.d.ts +2 -1
  92. package/dist/types/src/interface/ui/expand_record.d.ts.map +1 -1
  93. package/dist/types/src/interface/ui/initialize_block.d.ts +30 -0
  94. package/dist/types/src/interface/ui/initialize_block.d.ts.map +1 -1
  95. package/dist/types/src/interface/ui/ui.d.ts +1 -1
  96. package/dist/types/src/interface/ui/ui.d.ts.map +1 -1
  97. package/dist/types/src/interface/ui/use_custom_properties.d.ts +52 -5
  98. package/dist/types/src/interface/ui/use_custom_properties.d.ts.map +1 -1
  99. package/dist/types/src/shared/color_utils.d.ts +3 -3
  100. package/dist/types/src/shared/colors.d.ts +2 -2
  101. package/dist/types/src/shared/global_config.d.ts +45 -40
  102. package/dist/types/src/shared/global_config.d.ts.map +1 -1
  103. package/dist/types/src/shared/models/base_core.d.ts +34 -11
  104. package/dist/types/src/shared/models/base_core.d.ts.map +1 -1
  105. package/dist/types/src/shared/models/field_core.d.ts +1 -1
  106. package/dist/types/src/shared/models/session_core.d.ts +1 -1
  107. package/dist/types/src/shared/private_utils.d.ts +1 -1
  108. package/dist/types/src/shared/private_utils.d.ts.map +1 -1
  109. package/dist/types/src/shared/sdk_core.d.ts +4 -4
  110. package/dist/types/src/shared/types/field.d.ts +1 -1
  111. package/dist/types/src/shared/ui/remote_utils.d.ts +3 -3
  112. package/dist/types/src/shared/ui/use_global_config.d.ts +13 -8
  113. package/dist/types/src/shared/ui/use_global_config.d.ts.map +1 -1
  114. package/dist/types/src/shared/ui/use_synced.d.ts +1 -1
  115. package/dist/types/src/shared/ui/use_watchable.d.ts +3 -22
  116. package/dist/types/src/shared/ui/use_watchable.d.ts.map +1 -1
  117. package/dist/types/src/shared/ui/with_hooks.d.ts +3 -3
  118. package/dist/types/stories/collaborator_token.stories.d.ts.map +1 -1
  119. package/package.json +16 -12
  120. package/dist/types/src/shared/ui/use_loadable.d.ts.map +0 -1
  121. package/ui.d.ts +0 -1
  122. package/ui.js +0 -1
  123. package/unstable_private_utils.d.ts +0 -1
  124. package/unstable_private_utils.js +0 -1
  125. package/unstable_standalone_ui.d.ts +0 -1
  126. package/unstable_standalone_ui.js +0 -1
  127. package/unstable_testing_utils.d.ts +0 -1
  128. package/unstable_testing_utils.js +0 -1
@@ -46,7 +46,6 @@ var hasBeenInitialized = false;
46
46
  * initializeBlock({interface: () => <App />});
47
47
  * ```
48
48
  * @docsPath UI/utils/initializeBlock
49
- * @internal
50
49
  */
51
50
  function initializeBlock(entryPoints) {
52
51
  var body = typeof document !== 'undefined' ? document.body : null;
@@ -80,9 +79,20 @@ function initializeBlock(entryPoints) {
80
79
  }
81
80
  var container = document.createElement('div');
82
81
  body.appendChild(container);
83
- _reactDom.default.render( /*#__PURE__*/React.createElement(_block_wrapper.BlockWrapper, {
84
- sdk: sdk
85
- }, entryElement), container);
82
+
83
+ // Try to use createRoot API (React 18+)
84
+ try {
85
+ var _require = require('react-dom/client'),
86
+ createRoot = _require.createRoot;
87
+ createRoot(container).render( /*#__PURE__*/React.createElement(_block_wrapper.BlockWrapper, {
88
+ sdk: sdk
89
+ }, entryElement));
90
+ } catch (e) {
91
+ // Fallback to legacy render for React 16/17
92
+ _reactDom.default.render( /*#__PURE__*/React.createElement(_block_wrapper.BlockWrapper, {
93
+ sdk: sdk
94
+ }, entryElement), container);
95
+ }
86
96
  }
87
97
  var sdk;
88
98
 
@@ -28,6 +28,24 @@ Object.defineProperty(exports, "initializeBlock", {
28
28
  return _initialize_block.initializeBlock;
29
29
  }
30
30
  });
31
+ Object.defineProperty(exports, "loadCSSFromString", {
32
+ enumerable: true,
33
+ get: function get() {
34
+ return _remote_utils.loadCSSFromString;
35
+ }
36
+ });
37
+ Object.defineProperty(exports, "loadCSSFromURLAsync", {
38
+ enumerable: true,
39
+ get: function get() {
40
+ return _remote_utils.loadCSSFromURLAsync;
41
+ }
42
+ });
43
+ Object.defineProperty(exports, "loadScriptFromURLAsync", {
44
+ enumerable: true,
45
+ get: function get() {
46
+ return _remote_utils.loadScriptFromURLAsync;
47
+ }
48
+ });
31
49
  Object.defineProperty(exports, "useBase", {
32
50
  enumerable: true,
33
51
  get: function get() {
@@ -46,12 +64,6 @@ Object.defineProperty(exports, "useGlobalConfig", {
46
64
  return _use_global_config.default;
47
65
  }
48
66
  });
49
- Object.defineProperty(exports, "useLoadable", {
50
- enumerable: true,
51
- get: function get() {
52
- return _use_loadable.default;
53
- }
54
- });
55
67
  Object.defineProperty(exports, "useRecords", {
56
68
  enumerable: true,
57
69
  get: function get() {
@@ -97,9 +109,9 @@ var _use_records = require("./use_records");
97
109
  var _use_run_info = require("./use_run_info");
98
110
  var _use_session = require("./use_session");
99
111
  var _use_global_config = _interopRequireDefault(require("../../shared/ui/use_global_config"));
100
- var _use_loadable = _interopRequireDefault(require("../../shared/ui/use_loadable"));
101
112
  var _use_synced = _interopRequireDefault(require("../../shared/ui/use_synced"));
102
113
  var _use_watchable = _interopRequireDefault(require("../../shared/ui/use_watchable"));
103
114
  var _with_hooks = _interopRequireDefault(require("../../shared/ui/with_hooks"));
104
115
  var _colors = _interopRequireDefault(require("../../shared/colors"));
105
- var _color_utils = _interopRequireDefault(require("../../shared/color_utils"));
116
+ var _color_utils = _interopRequireDefault(require("../../shared/color_utils"));
117
+ var _remote_utils = require("../../shared/ui/remote_utils");
@@ -27,14 +27,61 @@ var _error_utils = require("../../shared/error_utils");
27
27
  // passes a Table model instance, and then we transform that to be a fieldId custom
28
28
  // property with a tableId before we pass it to hyperbase.
29
29
  /**
30
- * TODO document
31
- * @hidden
30
+ * An object that represents a custom property that a block can set.
31
+ *
32
+ * ```
33
+ * type BlockPageElementCustomProperty = {key: string; label: string} & (
34
+ * | {type: 'boolean'; defaultValue: boolean}
35
+ * | {type: 'string'; defaultValue?: string}
36
+ * | {
37
+ * type: 'enum';
38
+ * possibleValues: Array<{value: string; label: string}>;
39
+ * defaultValue?: string;
40
+ * }
41
+ * | {
42
+ * type: 'field';
43
+ * table: Table;
44
+ * possibleValues?: Array<Field>; // If not provided, all visible fields in the table will be shown in the dropdown.
45
+ * defaultValue?: Field;
46
+ * }
47
+ * );
48
+ * ```
32
49
  */
33
50
 
34
51
  /**
35
- * TODO document. Make sure to describe that getCustomProperties
36
- * should be wrapped in useCallback.
37
- * @hidden
52
+ * A hook for integrating configuration settings for your block with the Interface Designer properties
53
+ * panel. Under the hood, this uses {@link GlobalConfig} to store the custom property values.
54
+ *
55
+ * Returns an object with:
56
+ * - `customPropertyValueByKey`: an object mapping custom property keys to their current value.
57
+ * - `errorState`: an object with an `error` property if there was an error setting the custom properties
58
+ *
59
+ * @param getCustomProperties A function that returns an array of {@link BlockPageElementCustomProperty}.
60
+ * This function should have a stable identity, so it should either be defined at the top level of the
61
+ * file or wrapped in useCallback. It will receive an instance of {@link Base} as an argument.
62
+ *
63
+ * @example
64
+ * ```js
65
+ * import {useCustomProperties} from '@airtable/blocks/interface/ui';
66
+ *
67
+ * function getCustomProperties(base: Base) {
68
+ * const table = base.tables[0];
69
+ * const numberFields = table.fields.filter(field => field.type === FieldType.NUMBER);
70
+ * return [
71
+ * {key: 'title', label: 'Title', type: 'string', defaultValue: 'Chart'},
72
+ * {key: 'xAxis', label: 'X-axis', type: 'field', table, possibleValues: numberFields},
73
+ * {key: 'yAxis', label: 'Y-axis', type: 'field', table, possibleValues: numberFields},
74
+ * {key: 'color', label: 'Color', type: 'enum', possibleValues: ['red', 'blue', 'green'], defaultValue: 'red'},
75
+ * {key: 'showLegend', label: 'Show Legend', type: 'boolean', defaultValue: true},
76
+ * ];
77
+ * }
78
+ *
79
+ * function MyApp() {
80
+ * const {customPropertyValueByKey, errorState} = useCustomProperties(getCustomProperties);
81
+ * }
82
+ * ```
83
+ * @docsPath UI/hooks/useCustomProperties
84
+ * @hook
38
85
  */
39
86
  function useCustomProperties(getCustomProperties) {
40
87
  var sdk = (0, _sdk_context.useSdk)();
@@ -16,9 +16,9 @@ exports.rgbTuplesByColor = exports.default = void 0;
16
16
  *
17
17
  * @example
18
18
  * ```js
19
- * import {Box, colors} from '@airtable/blocks/ui';
19
+ * import {colors, colorUtils} from '@airtable/blocks/[placeholder-path]/ui';
20
20
  *
21
- * <Box backgroundColor={colors.BLUE} />
21
+ * <div style={{backgroundColor: colorUtils.getHexForColor(colors.BLUE)}}>Hello world</div>
22
22
  * ```
23
23
  *
24
24
  * @docsPath UI/utils/colors
@@ -58,10 +58,6 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
58
58
  * The maximum allowed size for a given GlobalConfig instance is 150kB.
59
59
  * The maximum number of keys for a given GlobalConfig instance is 1000.
60
60
  *
61
- * @example
62
- * ```js
63
- * import {globalConfig} from '@airtable/blocks';
64
- * ```
65
61
  * @docsPath models/GlobalConfig
66
62
  */
67
63
  var GlobalConfig = /*#__PURE__*/function (_Watchable) {
@@ -136,10 +132,13 @@ var GlobalConfig = /*#__PURE__*/function (_Watchable) {
136
132
  * @param key A string for the top-level key, or an array of strings describing the path to the value.
137
133
  * @example
138
134
  * ```js
139
- * import {globalConfig} from '@airtable/blocks';
135
+ * import {useGlobalConfig} from '@airtable/blocks/[placeholder-path]/ui';
140
136
  *
141
- * const topLevelValue = globalConfig.get('topLevelKey');
142
- * const nestedValue = globalConfig.get(['topLevelKey', 'nested', 'deeply']);
137
+ * function MyApp() {
138
+ * const globalConfig = useGlobalConfig();
139
+ * const topLevelValue = globalConfig.get('topLevelKey');
140
+ * const nestedValue = globalConfig.get(['topLevelKey', 'nested', 'deeply']);
141
+ * }
143
142
  * ```
144
143
  */
145
144
  }, {
@@ -238,23 +237,26 @@ var GlobalConfig = /*#__PURE__*/function (_Watchable) {
238
237
  * @param value The value to set at the specified path. Use `undefined` to delete the value at the given path.
239
238
  * @example
240
239
  * ```js
241
- * import {globalConfig} from '@airtable/blocks';
242
- *
243
- * function updateFavoriteColorIfPossible(color) {
244
- * if (globalConfig.hasPermissionToSetPaths('favoriteColor', color)) {
245
- * globalConfig.setAsync('favoriteColor', color);
240
+ * import {useGlobalConfig} from '@airtable/blocks/[placeholder-path]/ui';
241
+ *
242
+ * function MyApp() {
243
+ * const globalConfig = useGlobalConfig();
244
+ * const updateFavoriteColorIfPossible = (color) => {
245
+ * if (globalConfig.hasPermissionToSet('favoriteColor', color)) {
246
+ * globalConfig.setAsync('favoriteColor', color);
247
+ * }
248
+ * // The update is now applied within your extension (eg will be
249
+ * // reflected in globalConfig) but are still being saved to
250
+ * // Airtable servers (e.g. may not be updated for other users yet)
246
251
  * }
247
- * // The update is now applied within your extension (eg will be
248
- * // reflected in globalConfig) but are still being saved to
249
- * // Airtable servers (e.g. may not be updated for other users yet)
250
- * }
251
252
  *
252
- * async function updateFavoriteColorIfPossibleAsync(color) {
253
- * if (globalConfig.hasPermissionToSet('favoriteColor', color)) {
254
- * await globalConfig.setAsync('favoriteColor', color);
253
+ * const updateFavoriteColorIfPossibleAsync = async (color) => {
254
+ * if (globalConfig.hasPermissionToSet('favoriteColor', color)) {
255
+ * await globalConfig.setAsync('favoriteColor', color);
256
+ * }
257
+ * // globalConfig updates have been saved to Airtable servers.
258
+ * alert('favoriteColor has been updated');
255
259
  * }
256
- * // globalConfig updates have been saved to Airtable servers.
257
- * alert('favoriteColor has been updated');
258
260
  * }
259
261
  * ```
260
262
  */
@@ -370,28 +372,31 @@ var GlobalConfig = /*#__PURE__*/function (_Watchable) {
370
372
  * @param updates The paths and values to set.
371
373
  * @example
372
374
  * ```js
373
- * import {globalConfig} from '@airtable/blocks';
374
- *
375
- * const updates = [
376
- * {path: ['topLevelKey1', 'nestedKey1'], value: 'foo'},
377
- * {path: ['topLevelKey2', 'nestedKey2'], value: 'bar'},
378
- * ];
379
- *
380
- * function applyUpdatesIfPossible() {
381
- * if (globalConfig.hasPermissionToSetPaths(updates)) {
382
- * globalConfig.setPathsAsync(updates);
375
+ * import {useGlobalConfig} from '@airtable/blocks/[placeholder-path]/ui';
376
+ *
377
+ * function MyApp() {
378
+ * const globalConfig = useGlobalConfig();
379
+ * const updates = [
380
+ * {path: ['topLevelKey1', 'nestedKey1'], value: 'foo'},
381
+ * {path: ['topLevelKey2', 'nestedKey2'], value: 'bar'},
382
+ * ];
383
+ *
384
+ * const applyUpdatesIfPossible = () => {
385
+ * if (globalConfig.hasPermissionToSetPaths(updates)) {
386
+ * globalConfig.setPathsAsync(updates);
387
+ * }
388
+ * // The updates are now applied within your extension (eg will be reflected in
389
+ * // globalConfig) but are still being saved to Airtable servers (e.g. they
390
+ * // may not be updated for other users yet)
383
391
  * }
384
- * // The updates are now applied within your extension (eg will be reflected in
385
- * // globalConfig) but are still being saved to Airtable servers (e.g. they
386
- * // may not be updated for other users yet)
387
- * }
388
392
  *
389
- * async function applyUpdatesIfPossibleAsync() {
390
- * if (globalConfig.hasPermissionToSetPaths(updates)) {
391
- * await globalConfig.setPathsAsync(updates);
393
+ * const applyUpdatesIfPossibleAsync = async () => {
394
+ * if (globalConfig.hasPermissionToSetPaths(updates)) {
395
+ * await globalConfig.setPathsAsync(updates);
396
+ * }
397
+ * // globalConfig updates have been saved to Airtable servers.
398
+ * alert('globalConfig has been updated');
392
399
  * }
393
- * // globalConfig updates have been saved to Airtable servers.
394
- * alert('globalConfig has been updated');
395
400
  * }
396
401
  * ```
397
402
  */
@@ -111,8 +111,12 @@ var BaseCore = exports.BaseCore = /*#__PURE__*/function (_AbstractModel) {
111
111
  *
112
112
  * @example
113
113
  * ```js
114
- * import {base} from '@airtable/blocks';
115
- * console.log('The name of your base is', base.name);
114
+ * import {useBase} from '@airtable/blocks/[placeholder-path]/ui';
115
+ *
116
+ * function MyApp() {
117
+ * const base = useBase();
118
+ * console.log('The name of your base is', base.name);
119
+ * }
116
120
  * ```
117
121
  */
118
122
  }, {
@@ -126,8 +130,12 @@ var BaseCore = exports.BaseCore = /*#__PURE__*/function (_AbstractModel) {
126
130
  *
127
131
  * @example
128
132
  * ```js
129
- * import {base} from '@airtable/blocks';
130
- * console.log('The workspace id of your base is', base.workspaceId);
133
+ * import {useBase} from '@airtable/blocks/[placeholder-path]/ui';
134
+ *
135
+ * function MyApp() {
136
+ * const base = useBase();
137
+ * console.log('The workspace id of your base is', base.workspaceId);
138
+ * }
131
139
  * ```
132
140
  */
133
141
  }, {
@@ -141,9 +149,16 @@ var BaseCore = exports.BaseCore = /*#__PURE__*/function (_AbstractModel) {
141
149
  *
142
150
  * @example
143
151
  * ```js
144
- * import {base} from '@airtable/blocks';
145
- * import {Box} from '@airtable/blocks/ui';
146
- * const exampleBox = <Box backgroundColor={base.color}> This box's background is the same color as the base background</Box>
152
+ * import {colorUtils, useBase} from '@airtable/blocks/[placeholder-path]/ui';
153
+ *
154
+ * function MyApp() {
155
+ * const base = useBase();
156
+ * return (
157
+ * <div style={{backgroundColor: colorUtils.getHexForColor(base.color)}}>
158
+ * This div's background is the same color as the base background
159
+ * </div>
160
+ * );
161
+ * }
147
162
  * ```
148
163
  */
149
164
  }, {
@@ -157,8 +172,12 @@ var BaseCore = exports.BaseCore = /*#__PURE__*/function (_AbstractModel) {
157
172
  *
158
173
  * @example
159
174
  * ```js
160
- * import {base} from '@airtable/blocks';
161
- * console.log(`You have ${base.tables.length} tables`);
175
+ * import {useBase} from '@airtable/blocks/[placeholder-path]/ui';
176
+ *
177
+ * function MyApp() {
178
+ * const base = useBase();
179
+ * console.log(`You have ${base.tables.length} tables`);
180
+ * }
162
181
  * ```
163
182
  */
164
183
  }, {
@@ -197,8 +216,12 @@ var BaseCore = exports.BaseCore = /*#__PURE__*/function (_AbstractModel) {
197
216
  *
198
217
  * @example
199
218
  * ```js
200
- * import {base} from '@airtable/blocks';
201
- * console.log(base.activeCollaborators[0].email);
219
+ * import {useBase} from '@airtable/blocks/[placeholder-path]/ui';
220
+ *
221
+ * function MyApp() {
222
+ * const base = useBase();
223
+ * console.log(base.activeCollaborators[0].email);
224
+ * }
202
225
  * ```
203
226
  */
204
227
  function get() {
@@ -127,7 +127,7 @@ var FieldCore = exports.FieldCore = /*#__PURE__*/function (_AbstractModel) {
127
127
  * @see {@link FieldType}
128
128
  * @example
129
129
  * ```js
130
- * import {FieldType} from '@airtable/blocks/models';
130
+ * import {FieldType} from '@airtable/blocks/[placeholder-path]/models';
131
131
  *
132
132
  * if (myField.type === FieldType.CURRENCY) {
133
133
  * console.log(myField.options.symbol);
@@ -79,7 +79,7 @@ var RecordCore = exports.RecordCore = /*#__PURE__*/function (_AbstractModel) {
79
79
  * @internal (since we may not be able to return parent model instances in the immutable models world)
80
80
  * @example
81
81
  * ```js
82
- * import {useRecords} from '@airtable/blocks/ui';
82
+ * import {useRecords} from '@airtable/blocks/base/ui';
83
83
  * const records = useRecords(myTable);
84
84
  * console.log(records[0].parentTable.id === myTable.id);
85
85
  * // => true
@@ -86,7 +86,7 @@ var SessionCore = exports.SessionCore = /*#__PURE__*/function (_AbstractModel) {
86
86
  *
87
87
  * @example
88
88
  * ```js
89
- * import {useSession} from '@airtable/blocks/ui';
89
+ * import {useSession} from '@airtable/blocks/[placeholder-path]/ui';
90
90
  *
91
91
  * function CurrentUser() {
92
92
  * const session = useSession();
@@ -81,7 +81,7 @@ var TableCore = exports.TableCore = /*#__PURE__*/function (_AbstractModel) {
81
81
  * @internal (since we may not be able to return parent model instances in the immutable models world)
82
82
  * @example
83
83
  * ```js
84
- * import {base} from '@airtable/blocks';
84
+ * import {base} from '@airtable/blocks/base';
85
85
  * const table = base.getTableByName('Table 1');
86
86
  * console.log(table.parentBase.id === base.id);
87
87
  * // => true
@@ -13,7 +13,7 @@ var _global_config = _interopRequireDefault(require("./global_config"));
13
13
  * @hidden
14
14
  * @example
15
15
  * ```js
16
- * import {runInfo} from '@airtable/blocks';
16
+ * import {runInfo} from '@airtable/blocks/base';
17
17
  * if (runInfo.isFirstRun) {
18
18
  * // The current user just installed this block.
19
19
  * // Take the opportunity to show any onboarding and set
@@ -39,7 +39,7 @@ var BlockSdkCore = exports.BlockSdkCore = /*#__PURE__*/function () {
39
39
  *
40
40
  * @example
41
41
  * ```js
42
- * import {installationId} from '@airtable/blocks';
42
+ * import {installationId} from '@airtable/blocks/base';
43
43
  * console.log(installationId);
44
44
  * // => 'blifDutUr92OKwnUn'
45
45
  * ```
@@ -69,7 +69,7 @@ var BlockSdkCore = exports.BlockSdkCore = /*#__PURE__*/function () {
69
69
 
70
70
  // Bind the public methods on this class so users can import
71
71
  // just the method, e.g.
72
- // import {reload} from '@airtable/blocks';
72
+ // import {reload} from '@airtable/blocks/base';
73
73
  this.reload = this.reload.bind(this);
74
74
  }
75
75
 
@@ -83,8 +83,8 @@ var BlockSdkCore = exports.BlockSdkCore = /*#__PURE__*/function () {
83
83
  * @example
84
84
  * ```js
85
85
  * import React from 'react';
86
- * import {reload} from '@airtable/blocks';
87
- * import {Button, initializeBlock} from '@airtable/blocks/ui';
86
+ * import {reload} from '@airtable/blocks/base';
87
+ * import {Button, initializeBlock} from '@airtable/blocks/base/ui';
88
88
  * function MyBlock() {
89
89
  * return <Button onClick={() => reload()}>Reload</Button>;
90
90
  * }
@@ -12,7 +12,7 @@ exports.FieldType = void 0;
12
12
  *
13
13
  * @example
14
14
  * ```js
15
- * import {FieldType} from '@airtable/blocks/models';
15
+ * import {FieldType} from '@airtable/blocks/[placeholder-path]/models';
16
16
  * const numberFields = myTable.fields.filter(field => (
17
17
  * field.type === FieldType.NUMBER
18
18
  * ));
@@ -17,7 +17,7 @@ var _error_utils = require("../error_utils");
17
17
  * @param css The CSS string.
18
18
  * @example
19
19
  * ```js
20
- * import {loadCSSFromString} from '@airtable/blocks/ui';
20
+ * import {loadCSSFromString} from '@airtable/blocks/[placeholder-path]/ui';
21
21
  * loadCSSFromString('body { background: red; }');
22
22
  * ```
23
23
  * @docsPath UI/utils/loadCSSFromString
@@ -38,7 +38,7 @@ function loadCSSFromString(css) {
38
38
  * @param url The URL of the stylesheet.
39
39
  * @example
40
40
  * ```js
41
- * import {loadCSSFromURLAsync} from '@airtable/blocks/ui';
41
+ * import {loadCSSFromURLAsync} from '@airtable/blocks/[placeholder-path]/ui';
42
42
  * loadCSSFromURLAsync('https://example.com/style.css');
43
43
  * ```
44
44
  * @docsPath UI/utils/loadCSSFromURLAsync
@@ -69,7 +69,7 @@ function loadCSSFromURLAsync(url) {
69
69
  * @param url The URL of the script.
70
70
  * @example
71
71
  * ```js
72
- * import {loadScriptFromURLAsync} from '@airtable/blocks/ui';
72
+ * import {loadScriptFromURLAsync} from '@airtable/blocks/[placeholder-path]/ui';
73
73
  * loadScriptFromURLAsync('https://example.com/script.js');
74
74
  * ```
75
75
  * @docsPath UI/utils/loadScriptFromURLAsync
@@ -15,9 +15,10 @@ var _sdk_context = require("./sdk_context");
15
15
  *
16
16
  * @example
17
17
  * ```js
18
- * import {Button, useGlobalConfig} from '@airtable/blocks/ui';
18
+ * import {useGlobalConfig, useRunInfo} from '@airtable/blocks/[placeholder-path]/ui';
19
19
  *
20
20
  * function SyncedCounter() {
21
+ * const runInfo = useRunInfo();
21
22
  * const globalConfig = useGlobalConfig();
22
23
  * const count = globalConfig.get('count');
23
24
  *
@@ -25,13 +26,17 @@ var _sdk_context = require("./sdk_context");
25
26
  * const decrement = () => globalConfig.setAsync('count', count - 1);
26
27
  * const isEnabled = globalConfig.hasPermissionToSet('count');
27
28
  *
28
- * return (
29
- * <React.Fragment>
30
- * <Button icon="minus" onClick={decrement} disabled={!isEnabled} ariaLabel="decrease"/>
31
- * {count}
32
- * <Button icon="plus" onClick={increment} disabled={!isEnabled} ariaLabel="increase"/>
33
- * </React.Fragment>
34
- * );
29
+ * if (runInfo.isPageElementInEditMode) {
30
+ * return (
31
+ * <div>
32
+ * <button onClick={decrement} disabled={!isEnabled} ariaLabel="decrease">-</button>
33
+ * {count}
34
+ * <button onClick={increment} disabled={!isEnabled} ariaLabel="increase">+</button>
35
+ * </div>
36
+ * );
37
+ * } else {
38
+ * return <div>{count}</div>;
39
+ * }
35
40
  * }
36
41
  * ```
37
42
  * @docsPath UI/hooks/useGlobalConfig
@@ -14,7 +14,7 @@ var _sdk_context = require("./sdk_context");
14
14
  * @param globalConfigKey
15
15
  * @example
16
16
  * ```js
17
- * import {useBase, useSynced} from '@airtable/blocks/ui';
17
+ * import {useBase, useSynced} from '@airtable/blocks/[placeholder-path]/ui';
18
18
  *
19
19
  * function CustomInputSynced() {
20
20
  * const [value, setValue, canSetValue] = useSynced('myGlobalConfigKey');
@@ -45,39 +45,20 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
45
45
  *
46
46
  * @example
47
47
  * ```js
48
- * import {useWatchable} from '@airtable/blocks/ui';
48
+ * import {useWatchable} from '@airtable/blocks/[placeholder-path]/ui';
49
49
  *
50
50
  * function TableName({table}) {
51
51
  * useWatchable(table, 'name');
52
52
  * return <span>The table name is {table.name}</span>;
53
53
  * }
54
54
  *
55
- * function ViewNameAndType({view}) {
56
- * useWatchable(view, ['name', 'type']);
57
- * return <span>The view name is {view.name} and the type is {view.type}</span>;
58
- * }
59
- *
60
- * function RecordValuesAndColorInViewIfExists({record, field, view}) {
61
- * useWatchable(record, ['cellValues', view ? `colorInView:${view.id}` : null]);
55
+ * function RecordValues({record, field}) {
56
+ * useWatchable(record, ['cellValues']);
62
57
  * return <span>
63
58
  * The record has cell value {record.getCellValue(field)} in {field.name}.
64
- * {view ? `The record has color ${record.getColorInView(view)} in ${view.name}.` : null}
65
59
  * </span>
66
60
  * }
67
61
  * ```
68
- *
69
- * @example
70
- * ```js
71
- * import {useWatchable} from '@airtable/blocks/ui';
72
- *
73
- * function ActiveView({cursor}) {
74
- * useWatchable(cursor, 'activeViewId', () => {
75
- * alert('active view changed!!!')
76
- * });
77
- *
78
- * return <span>Active view id: {cursor.activeViewId}</span>;
79
- * }
80
- * ```
81
62
  * @docsPath UI/hooks/useWatchable
82
63
  * @hook
83
64
  */
@@ -31,7 +31,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
31
31
  * @example
32
32
  * ```js
33
33
  * import React from 'react';
34
- * import {useRecords, withHooks} from '@airtable/blocks/ui';
34
+ * import {useRecords, withHooks} from '@airtable/blocks/base/ui';
35
35
  *
36
36
  * // RecordList takes a list of records and renders it
37
37
  * class RecordList extends React.Component {
@@ -67,8 +67,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
67
67
  * @example
68
68
  * ```js
69
69
  * import React from 'react';
70
- * import {Record, Table} from '@airtable/blocks/models';
71
- * import {withHooks, useRecords} from '@airtable/blocks/ui';
70
+ * import {Record, Table} from '@airtable/blocks/[placeholder-path]/models';
71
+ * import {withHooks, useRecords} from '@airtable/blocks/[placeholder-path]/ui';
72
72
  * // with typescript, things are a little more complex: we need to provide some type annotations to
73
73
  * // indicate which props are injected:
74
74
  *
@@ -13,7 +13,7 @@ import Table from './table';
13
13
  *
14
14
  * @example
15
15
  * ```js
16
- * import {base} from '@airtable/blocks';
16
+ * import {base} from '@airtable/blocks/base';
17
17
  *
18
18
  * console.log('The name of your base is', base.name);
19
19
  * ```
@@ -8,7 +8,7 @@ import Field from './field';
8
8
  *
9
9
  * @example
10
10
  * ```js
11
- * import {aggregators} from '@airtable/blocks/models';
11
+ * import {aggregators} from '@airtable/blocks/base/models';
12
12
  *
13
13
  * // To get a list of aggregators supported for a specific field:
14
14
  * const fieldAggregators = myField.availableAggregators;
@@ -36,7 +36,7 @@ interface CursorData {
36
36
  * {@link useLoadable} to access them.
37
37
  *
38
38
  * ```js
39
- * import {useCursor, useWatchable} from '@airtable/blocks/ui';
39
+ * import {useCursor, useWatchable} from '@airtable/blocks/base/ui';
40
40
  *
41
41
  * function ActiveTableAndView() {
42
42
  * const cursor = useCursor();
@@ -52,7 +52,7 @@ interface CursorData {
52
52
  * ```
53
53
  *
54
54
  * ```js
55
- * import {useCursor, useLoadable, useWatchable} from '@airtable/blocks/ui';
55
+ * import {useCursor, useLoadable, useWatchable} from '@airtable/blocks/base/ui';
56
56
  *
57
57
  * function SelectedRecordAndFieldIds() {
58
58
  * const cursor = useCursor();
@@ -11,7 +11,7 @@ import { Aggregator } from './create_aggregators';
11
11
  *
12
12
  * @example
13
13
  * ```js
14
- * import {base} from '@airtable/blocks';
14
+ * import {base} from '@airtable/blocks/base';
15
15
  *
16
16
  * const table = base.getTableByName('Table 1');
17
17
  * const field = table.getFieldByName('Name');
@@ -35,7 +35,7 @@ declare class Field extends FieldCore<BaseSdkMode> {
35
35
  * @param aggregator The aggregator object or aggregator key.
36
36
  * @example
37
37
  * ```js
38
- * import {aggregators} from '@airtable/blocks/models';
38
+ * import {aggregators} from '@airtable/blocks/base/models';
39
39
  * const aggregator = aggregators.totalAttachmentSize;
40
40
  *
41
41
  * // Using an aggregator object