@airtable/blocks 1.11.1-experimental-68738f2-20220526 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cjs/error_utils.js +1 -19
- package/dist/cjs/global_config.js +3 -3
- package/dist/cjs/injected/airtable_interface.js +1 -1
- package/dist/cjs/models/base.js +9 -9
- package/dist/cjs/models/cursor.js +3 -3
- package/dist/cjs/models/field.js +3 -3
- package/dist/cjs/models/grouped_record_query_result.js +14 -5
- package/dist/cjs/models/linked_records_query_result.js +27 -78
- package/dist/cjs/models/mutations.js +163 -18
- package/dist/cjs/models/record.js +55 -310
- package/dist/cjs/models/record_query_result.js +2 -5
- package/dist/cjs/models/record_store.js +829 -555
- package/dist/cjs/models/session.js +3 -3
- package/dist/cjs/models/table.js +31 -31
- package/dist/cjs/models/table_or_view_query_result.js +419 -526
- package/dist/cjs/models/view.js +23 -1
- package/dist/cjs/models/view_data_store.js +295 -255
- package/dist/cjs/private_utils.js +0 -40
- package/dist/cjs/sdk.js +9 -12
- package/dist/cjs/settings_button.js +1 -1
- package/dist/cjs/testing/abstract_mock_airtable_interface.js +11 -57
- package/dist/cjs/types/airtable_interface.js +2 -17
- package/dist/cjs/ui/block_wrapper.js +2 -5
- package/dist/cjs/ui/expand_record_picker_async.js +1 -1
- package/dist/cjs/ui/global_config_synced_component_helpers.js +6 -0
- package/dist/cjs/ui/initialize_block.js +3 -3
- package/dist/cjs/ui/use_global_config.js +1 -1
- package/dist/cjs/ui/use_loadable.js +3 -3
- package/dist/cjs/ui/use_record_action_data.js +11 -11
- package/dist/cjs/ui/use_records.js +1 -5
- package/dist/cjs/ui/use_settings_button.js +1 -1
- package/dist/cjs/ui/viewport_constraint.js +1 -1
- package/dist/cjs/unstable_testing_utils.js +1 -61
- package/dist/cjs/viewport.js +9 -9
- package/dist/cjs/watchable.js +1 -15
- package/dist/types/src/error_utils.d.ts +1 -2
- package/dist/types/src/error_utils.d.ts.map +1 -1
- package/dist/types/src/global_config.d.ts +3 -3
- package/dist/types/src/models/base.d.ts +9 -9
- package/dist/types/src/models/cursor.d.ts +3 -3
- package/dist/types/src/models/field.d.ts +3 -3
- package/dist/types/src/models/grouped_record_query_result.d.ts +3 -3
- package/dist/types/src/models/grouped_record_query_result.d.ts.map +1 -1
- package/dist/types/src/models/linked_records_query_result.d.ts.map +1 -1
- package/dist/types/src/models/mutations.d.ts.map +1 -1
- package/dist/types/src/models/record.d.ts +3 -12
- package/dist/types/src/models/record.d.ts.map +1 -1
- package/dist/types/src/models/record_query_result.d.ts +4 -5
- package/dist/types/src/models/record_query_result.d.ts.map +1 -1
- package/dist/types/src/models/record_store.d.ts.map +1 -1
- package/dist/types/src/models/session.d.ts +3 -3
- package/dist/types/src/models/table.d.ts +25 -25
- package/dist/types/src/models/table_or_view_query_result.d.ts +5 -3
- package/dist/types/src/models/table_or_view_query_result.d.ts.map +1 -1
- package/dist/types/src/models/view.d.ts +11 -0
- package/dist/types/src/models/view.d.ts.map +1 -1
- package/dist/types/src/models/view_data_store.d.ts +1 -0
- package/dist/types/src/models/view_data_store.d.ts.map +1 -1
- package/dist/types/src/models/view_metadata_query_result.d.ts +1 -1
- package/dist/types/src/models/view_metadata_query_result.d.ts.map +1 -1
- package/dist/types/src/private_utils.d.ts +1 -24
- package/dist/types/src/private_utils.d.ts.map +1 -1
- package/dist/types/src/sdk.d.ts +3 -1
- package/dist/types/src/sdk.d.ts.map +1 -1
- package/dist/types/src/settings_button.d.ts +1 -1
- package/dist/types/src/testing/abstract_mock_airtable_interface.d.ts +11 -11
- package/dist/types/src/testing/abstract_mock_airtable_interface.d.ts.map +1 -1
- package/dist/types/src/types/airtable_interface.d.ts +20 -59
- package/dist/types/src/types/airtable_interface.d.ts.map +1 -1
- package/dist/types/src/types/field.d.ts +10 -5
- package/dist/types/src/types/field.d.ts.map +1 -1
- package/dist/types/src/types/table.d.ts +2 -0
- package/dist/types/src/types/table.d.ts.map +1 -1
- package/dist/types/src/types/view.d.ts +9 -3
- package/dist/types/src/types/view.d.ts.map +1 -1
- package/dist/types/src/ui/block_wrapper.d.ts.map +1 -1
- package/dist/types/src/ui/expand_record_picker_async.d.ts +1 -1
- package/dist/types/src/ui/global_config_synced_component_helpers.d.ts.map +1 -1
- package/dist/types/src/ui/initialize_block.d.ts +1 -1
- package/dist/types/src/ui/record_card.d.ts +1 -1
- package/dist/types/src/ui/use_global_config.d.ts +1 -1
- package/dist/types/src/ui/use_loadable.d.ts +2 -2
- package/dist/types/src/ui/use_record_action_data.d.ts +11 -11
- package/dist/types/src/ui/use_settings_button.d.ts +1 -1
- package/dist/types/src/ui/viewport_constraint.d.ts +3 -3
- package/dist/types/src/ui/viewport_constraint.d.ts.map +1 -1
- package/dist/types/src/unstable_testing_utils.d.ts +1 -4
- package/dist/types/src/unstable_testing_utils.d.ts.map +1 -1
- package/dist/types/src/viewport.d.ts +9 -9
- package/dist/types/src/watchable.d.ts.map +1 -1
- package/dist/types/{src/testing → test/airtable_interface_mocks}/fixture_data.d.ts +25 -44
- package/dist/types/test/airtable_interface_mocks/fixture_data.d.ts.map +1 -0
- package/dist/types/test/airtable_interface_mocks/linked_records.d.ts +1 -1
- package/dist/types/test/airtable_interface_mocks/linked_records.d.ts.map +1 -1
- package/dist/types/test/airtable_interface_mocks/mock_airtable_interface.d.ts +12 -19
- package/dist/types/test/airtable_interface_mocks/mock_airtable_interface.d.ts.map +1 -1
- package/dist/types/test/airtable_interface_mocks/project_tracker.d.ts +1 -1
- package/dist/types/test/airtable_interface_mocks/project_tracker.d.ts.map +1 -1
- package/dist/types/test/test_helpers.d.ts +0 -2
- package/dist/types/test/test_helpers.d.ts.map +1 -1
- package/package.json +2 -3
- package/dist/cjs/models/query_manager.js +0 -328
- package/dist/cjs/testing/fixture_data.js +0 -271
- package/dist/cjs/testing/mock_base_data_stores.js +0 -891
- package/dist/cjs/types/block_query_spec.js +0 -85
- package/dist/types/src/models/query_manager.d.ts +0 -2
- package/dist/types/src/models/query_manager.d.ts.map +0 -1
- package/dist/types/src/testing/fixture_data.d.ts.map +0 -1
- package/dist/types/src/testing/mock_base_data_stores.d.ts +0 -59
- package/dist/types/src/testing/mock_base_data_stores.d.ts.map +0 -1
- package/dist/types/src/types/block_query_spec.d.ts +0 -139
- package/dist/types/src/types/block_query_spec.d.ts.map +0 -1
- package/dist/types/test/testing/fixture_data.test.d.ts +0 -2
- package/dist/types/test/testing/fixture_data.test.d.ts.map +0 -1
|
@@ -22,10 +22,6 @@ require("core-js/modules/es.object.to-string");
|
|
|
22
22
|
|
|
23
23
|
require("core-js/modules/es.object.values");
|
|
24
24
|
|
|
25
|
-
require("core-js/modules/es.regexp.constructor");
|
|
26
|
-
|
|
27
|
-
require("core-js/modules/es.regexp.to-string");
|
|
28
|
-
|
|
29
25
|
require("core-js/modules/es.set");
|
|
30
26
|
|
|
31
27
|
require("core-js/modules/es.weak-map");
|
|
@@ -61,7 +57,6 @@ exports.getValueAtOwnPath = getValueAtOwnPath;
|
|
|
61
57
|
exports.arrayDifference = arrayDifference;
|
|
62
58
|
exports.debounce = debounce;
|
|
63
59
|
exports.isBlockDevelopmentRestrictionEnabled = isBlockDevelopmentRestrictionEnabled;
|
|
64
|
-
exports.isFieldId = isFieldId;
|
|
65
60
|
Object.defineProperty(exports, "isDeepEqual", {
|
|
66
61
|
enumerable: true,
|
|
67
62
|
get: function get() {
|
|
@@ -145,16 +140,10 @@ function cast(x) {
|
|
|
145
140
|
return x;
|
|
146
141
|
}
|
|
147
142
|
/**
|
|
148
|
-
* Used to turn a readonly type into a mutable copy: https://stackoverflow.com/a/50769802
|
|
149
|
-
* (used in the cloneDeep function)
|
|
150
|
-
*
|
|
151
143
|
* @hidden
|
|
152
144
|
*/
|
|
153
145
|
|
|
154
146
|
|
|
155
|
-
/**
|
|
156
|
-
* @hidden
|
|
157
|
-
*/
|
|
158
147
|
function cloneDeep(obj) {
|
|
159
148
|
var jsonString = JSON.stringify(obj);
|
|
160
149
|
|
|
@@ -564,33 +553,4 @@ function debounce(fn, timeoutMs) {
|
|
|
564
553
|
|
|
565
554
|
function isBlockDevelopmentRestrictionEnabled() {
|
|
566
555
|
return (0, _airtable_interface.default)().sdkInitData.baseData.isBlockDevelopmentRestrictionEnabled;
|
|
567
|
-
} // This is copied from hyper_id_generator in hyperbase
|
|
568
|
-
|
|
569
|
-
/**
|
|
570
|
-
* Airtable id format. All object ids to have this format:
|
|
571
|
-
* <3 char prefix (lower-case)> + <14 random chars (upper/lower-case & numbers)>
|
|
572
|
-
* e.g. app4iu8QmuwcCbWCE
|
|
573
|
-
*
|
|
574
|
-
* We call it an "objectId" rather than "modelId" because not everything with an id is a model,
|
|
575
|
-
* e.g. worker access tokens.
|
|
576
|
-
*/
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
var ALPHA_NUMERIC_CHAR_PATTERN = '[A-Za-z0-9]';
|
|
580
|
-
var OBJECT_ID_PREFIX_LENGTH = 3; // We allow shorter objectIds because our tests use non-standard AirtableIds
|
|
581
|
-
|
|
582
|
-
var OBJECT_ID_MIN_SUFFIX_LENGTH = 1;
|
|
583
|
-
var OBJECT_ID_SUFFIX_LENGTH = 14;
|
|
584
|
-
var OBJECT_ID_SUFFIX_PATTERN = ALPHA_NUMERIC_CHAR_PATTERN + '{' + OBJECT_ID_MIN_SUFFIX_LENGTH + ',' + OBJECT_ID_SUFFIX_LENGTH + '}';
|
|
585
|
-
var OBJECT_ID_PATTERN = '[a-z]{' + OBJECT_ID_PREFIX_LENGTH + '}' + OBJECT_ID_SUFFIX_PATTERN;
|
|
586
|
-
var OBJECT_ID_REGEX = new RegExp('^' + OBJECT_ID_PATTERN + '$');
|
|
587
|
-
|
|
588
|
-
function _isStringAnObjectId(str) {
|
|
589
|
-
return OBJECT_ID_REGEX.test(str);
|
|
590
|
-
}
|
|
591
|
-
/** @internal */
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
function isFieldId(str) {
|
|
595
|
-
return typeof str === 'string' && _isStringAnObjectId(str) && str.substr(0, 3) === 'fld';
|
|
596
556
|
}
|
package/dist/cjs/sdk.js
CHANGED
|
@@ -45,8 +45,6 @@ var _undo_redo = _interopRequireDefault(require("./undo_redo"));
|
|
|
45
45
|
|
|
46
46
|
var _perform_record_action = require("./perform_record_action");
|
|
47
47
|
|
|
48
|
-
var _query_manager = require("./models/query_manager");
|
|
49
|
-
|
|
50
48
|
/** @hidden */
|
|
51
49
|
|
|
52
50
|
/** */
|
|
@@ -103,12 +101,6 @@ function () {
|
|
|
103
101
|
|
|
104
102
|
/** Represents the current Airtable {@link Base}. */
|
|
105
103
|
|
|
106
|
-
/**
|
|
107
|
-
* Represents active queries and their state
|
|
108
|
-
*
|
|
109
|
-
* @internal
|
|
110
|
-
*/
|
|
111
|
-
|
|
112
104
|
/** Contains information about the current session. */
|
|
113
105
|
|
|
114
106
|
/** @internal */
|
|
@@ -160,7 +152,6 @@ function () {
|
|
|
160
152
|
(0, _defineProperty2.default)(this, "__airtableInterface", void 0);
|
|
161
153
|
(0, _defineProperty2.default)(this, "globalConfig", void 0);
|
|
162
154
|
(0, _defineProperty2.default)(this, "base", void 0);
|
|
163
|
-
(0, _defineProperty2.default)(this, "_queryManager", void 0);
|
|
164
155
|
(0, _defineProperty2.default)(this, "session", void 0);
|
|
165
156
|
(0, _defineProperty2.default)(this, "__mutations", void 0);
|
|
166
157
|
(0, _defineProperty2.default)(this, "installationId", void 0);
|
|
@@ -176,7 +167,6 @@ function () {
|
|
|
176
167
|
var sdkInitData = airtableInterface.sdkInitData;
|
|
177
168
|
this.globalConfig = new _global_config.default(sdkInitData.initialKvValuesByKey, this);
|
|
178
169
|
this.base = new _base.default(this);
|
|
179
|
-
this._queryManager = new _query_manager.QueryManager(this);
|
|
180
170
|
this.installationId = sdkInitData.blockInstallationId; // Bind the public methods on this class so users can import
|
|
181
171
|
// just the method, e.g.
|
|
182
172
|
// import {reload} from '@airtable/blocks';
|
|
@@ -186,7 +176,7 @@ function () {
|
|
|
186
176
|
this.viewport = new _viewport.default(sdkInitData.isFullscreen, airtableInterface);
|
|
187
177
|
this.cursor = new _cursor.default(this);
|
|
188
178
|
this.session = new _session.default(this);
|
|
189
|
-
this.__mutations = new _mutations.default(this, this.session, this.base, updates => this.__applyGlobalConfigUpdates(updates));
|
|
179
|
+
this.__mutations = new _mutations.default(this, this.session, this.base, changes => this.__applyModelChanges(changes), updates => this.__applyGlobalConfigUpdates(updates));
|
|
190
180
|
this.settingsButton = new _settings_button.default(airtableInterface);
|
|
191
181
|
this.undoRedo = new _undo_redo.default(airtableInterface);
|
|
192
182
|
this.performRecordAction = new _perform_record_action.PerformRecordAction(this, airtableInterface);
|
|
@@ -330,6 +320,13 @@ function () {
|
|
|
330
320
|
}
|
|
331
321
|
}, null, this);
|
|
332
322
|
}
|
|
323
|
+
/** @hidden */
|
|
324
|
+
|
|
325
|
+
}, {
|
|
326
|
+
key: "getBlockRunContext",
|
|
327
|
+
value: function getBlockRunContext() {
|
|
328
|
+
return this.__airtableInterface.sdkInitData.runContext;
|
|
329
|
+
}
|
|
333
330
|
}, {
|
|
334
331
|
key: "__appInterface",
|
|
335
332
|
get: function get() {
|
|
@@ -340,4 +337,4 @@ function () {
|
|
|
340
337
|
}();
|
|
341
338
|
|
|
342
339
|
exports.default = BlockSdk;
|
|
343
|
-
(0, _defineProperty2.default)(BlockSdk, "VERSION", "1.
|
|
340
|
+
(0, _defineProperty2.default)(BlockSdk, "VERSION", "1.13.0");
|
|
@@ -39,7 +39,7 @@ var WatchableSettingsButtonKeys = Object.freeze({
|
|
|
39
39
|
*/
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* Interface to the settings button that lives outside the
|
|
42
|
+
* Interface to the settings button that lives outside the extension's viewport.
|
|
43
43
|
*
|
|
44
44
|
* The {@link useSettingsButton} hook is the recommended way to use the settings button, but you can
|
|
45
45
|
* also use it with {@link useWatchable} if you want more granular control (for example, to only
|
|
@@ -4,23 +4,17 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
|
|
5
5
|
require("core-js/modules/es.array.concat");
|
|
6
6
|
|
|
7
|
-
require("core-js/modules/es.array.
|
|
7
|
+
require("core-js/modules/es.array.map");
|
|
8
8
|
|
|
9
9
|
require("core-js/modules/es.object.to-string");
|
|
10
10
|
|
|
11
11
|
require("core-js/modules/es.promise");
|
|
12
12
|
|
|
13
|
-
require("core-js/modules/web.dom-collections.iterator");
|
|
14
|
-
|
|
15
13
|
Object.defineProperty(exports, "__esModule", {
|
|
16
14
|
value: true
|
|
17
15
|
});
|
|
18
16
|
exports.AbstractMockAirtableInterface = void 0;
|
|
19
17
|
|
|
20
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
21
|
-
|
|
22
|
-
require("regenerator-runtime/runtime");
|
|
23
|
-
|
|
24
18
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
25
19
|
|
|
26
20
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -161,8 +155,7 @@ var globalConfigHelpers = {
|
|
|
161
155
|
var idGenerator = {
|
|
162
156
|
generateRecordId: () => 'recGeneratedMockId',
|
|
163
157
|
generateFieldId: () => 'fldGeneratedMockId',
|
|
164
|
-
generateTableId: () => 'tblGeneratedMockId'
|
|
165
|
-
generateViewId: () => 'viwGeneratedMockId'
|
|
158
|
+
generateTableId: () => 'tblGeneratedMockId'
|
|
166
159
|
};
|
|
167
160
|
/**
|
|
168
161
|
* An abstract base class with a common interface exposed to both Blocks SDK's
|
|
@@ -221,15 +214,18 @@ function (_EventEmitter) {
|
|
|
221
214
|
};
|
|
222
215
|
}
|
|
223
216
|
}, {
|
|
224
|
-
key: "
|
|
225
|
-
value: function
|
|
217
|
+
key: "createVisList",
|
|
218
|
+
value: function createVisList(appInterface, recordDatas, fieldDatas, sorts) {
|
|
226
219
|
return {
|
|
227
|
-
removeRecordIds(
|
|
220
|
+
removeRecordIds(recordIds) {},
|
|
228
221
|
|
|
229
|
-
|
|
222
|
+
addRecordData(recordData) {},
|
|
230
223
|
|
|
231
224
|
getOrderedRecordIds() {
|
|
232
|
-
return
|
|
225
|
+
return recordDatas.map((_ref) => {
|
|
226
|
+
var id = _ref.id;
|
|
227
|
+
return id;
|
|
228
|
+
});
|
|
233
229
|
}
|
|
234
230
|
|
|
235
231
|
};
|
|
@@ -241,49 +237,7 @@ function (_EventEmitter) {
|
|
|
241
237
|
}
|
|
242
238
|
}, {
|
|
243
239
|
key: "setActiveViewOrTable",
|
|
244
|
-
value: function setActiveViewOrTable(tableId, viewId) {}
|
|
245
|
-
}, {
|
|
246
|
-
key: "subscribeToQueryAndPopulateStoresAsync",
|
|
247
|
-
value: function subscribeToQueryAndPopulateStoresAsync(query, options) {
|
|
248
|
-
return _regenerator.default.async(function subscribeToQueryAndPopulateStoresAsync$(_context) {
|
|
249
|
-
while (1) {
|
|
250
|
-
switch (_context.prev = _context.next) {
|
|
251
|
-
case 0:
|
|
252
|
-
throw (0, _error_utils.spawnError)('subscribeToQueryAndPopulateStoresAsync unimplemented');
|
|
253
|
-
|
|
254
|
-
case 1:
|
|
255
|
-
case "end":
|
|
256
|
-
return _context.stop();
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
}, {
|
|
262
|
-
key: "unsubscribeFromQueryIdsAsync",
|
|
263
|
-
value: function unsubscribeFromQueryIdsAsync(querySpecIds) {
|
|
264
|
-
return _regenerator.default.async(function unsubscribeFromQueryIdsAsync$(_context2) {
|
|
265
|
-
while (1) {
|
|
266
|
-
switch (_context2.prev = _context2.next) {
|
|
267
|
-
case 0:
|
|
268
|
-
throw (0, _error_utils.spawnError)('unsubscribeFromQueryIdsAsync unimplemented');
|
|
269
|
-
|
|
270
|
-
case 1:
|
|
271
|
-
case "end":
|
|
272
|
-
return _context2.stop();
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
}, {
|
|
278
|
-
key: "getTableRecordStoreIfExists",
|
|
279
|
-
value: function getTableRecordStoreIfExists(tableId) {
|
|
280
|
-
throw (0, _error_utils.spawnError)('getTableRecordStoreIfExists unimplemented');
|
|
281
|
-
}
|
|
282
|
-
}, {
|
|
283
|
-
key: "getViewMetadataStoreIfExists",
|
|
284
|
-
value: function getViewMetadataStoreIfExists(tableId, viewId) {
|
|
285
|
-
throw (0, _error_utils.spawnError)('getViewMetadataStoreIfExists unimplemented');
|
|
286
|
-
} // TODO(jugglinmike): Implement
|
|
240
|
+
value: function setActiveViewOrTable(tableId, viewId) {} // TODO(jugglinmike): Implement
|
|
287
241
|
|
|
288
242
|
}, {
|
|
289
243
|
key: "subscribeToGlobalConfigUpdates",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.BlockRunContextType = void 0;
|
|
7
7
|
// BlockRunContextType, BlockInstallationPageBlockRunContext, ViewBlockRunContext, BlockRunContext
|
|
8
8
|
// must be kept in sync with block_run_context.tsx in hyperbase repo
|
|
9
9
|
|
|
@@ -16,19 +16,4 @@ exports.BlockRunContextType = BlockRunContextType;
|
|
|
16
16
|
(function (BlockRunContextType) {
|
|
17
17
|
BlockRunContextType["DASHBOARD_APP"] = "dashboardApp";
|
|
18
18
|
BlockRunContextType["VIEW"] = "view";
|
|
19
|
-
})(BlockRunContextType || (exports.BlockRunContextType = BlockRunContextType = {}));
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Callback priority - SDK priority is called before Block Code priority
|
|
23
|
-
*
|
|
24
|
-
* @hidden
|
|
25
|
-
*/
|
|
26
|
-
var BlockQueryCallbackPriority;
|
|
27
|
-
/** @hidden */
|
|
28
|
-
|
|
29
|
-
exports.BlockQueryCallbackPriority = BlockQueryCallbackPriority;
|
|
30
|
-
|
|
31
|
-
(function (BlockQueryCallbackPriority) {
|
|
32
|
-
BlockQueryCallbackPriority["SDK"] = "sdk";
|
|
33
|
-
BlockQueryCallbackPriority["BLOCK_CODE"] = "blockCode";
|
|
34
|
-
})(BlockQueryCallbackPriority || (exports.BlockQueryCallbackPriority = BlockQueryCallbackPriority = {}));
|
|
19
|
+
})(BlockRunContextType || (exports.BlockRunContextType = BlockRunContextType = {}));
|
|
@@ -129,10 +129,7 @@ function (_React$Component) {
|
|
|
129
129
|
}, {
|
|
130
130
|
key: "render",
|
|
131
131
|
value: function render() {
|
|
132
|
-
var
|
|
133
|
-
viewport = _this$props$sdk.viewport,
|
|
134
|
-
session = _this$props$sdk.session;
|
|
135
|
-
var blockNoun = session.__isFeatureEnabled('blocks.appsRename') ? 'app' : 'block';
|
|
132
|
+
var viewport = this.props.sdk.viewport;
|
|
136
133
|
var globalAlertInfo = _ui.globalAlert.__alertInfo;
|
|
137
134
|
|
|
138
135
|
if (globalAlertInfo) {
|
|
@@ -166,7 +163,7 @@ function (_React$Component) {
|
|
|
166
163
|
}
|
|
167
164
|
}, React.createElement("span", {
|
|
168
165
|
className: (0, _baymax_utils.baymax)('center line-height-4 quiet strong')
|
|
169
|
-
}, React.createElement("span", null, "Please make this
|
|
166
|
+
}, React.createElement("span", null, "Please make this extension bigger or "), React.createElement("span", {
|
|
170
167
|
className: (0, _baymax_utils.baymax)('pointer understroke link-unquiet'),
|
|
171
168
|
onClick: () => viewport.enterFullscreenIfPossible()
|
|
172
169
|
}, "fullscreen"))));
|
|
@@ -25,7 +25,7 @@ var _error_utils = require("../error_utils");
|
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Expands a list of records in the Airtable UI, and prompts the user to pick
|
|
28
|
-
* one. The selected record is returned to the
|
|
28
|
+
* one. The selected record is returned to the extension, and the modal is
|
|
29
29
|
* automatically closed.
|
|
30
30
|
*
|
|
31
31
|
* If the user dismisses the modal, or another one is opened before this one
|
|
@@ -9,6 +9,8 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
+
var _airtable_interface = require("../types/airtable_interface");
|
|
13
|
+
|
|
12
14
|
var _use_watchable = _interopRequireDefault(require("./use_watchable"));
|
|
13
15
|
|
|
14
16
|
var _sdk_context = require("./sdk_context");
|
|
@@ -21,8 +23,12 @@ var globalConfigSyncedComponentHelpers = {
|
|
|
21
23
|
var sdk = (0, _sdk_context.useSdk)();
|
|
22
24
|
var globalConfig = sdk.globalConfig,
|
|
23
25
|
session = sdk.session;
|
|
26
|
+
var runContext = sdk.getBlockRunContext();
|
|
24
27
|
(0, _use_watchable.default)(globalConfig, [globalConfig.__getTopLevelKey(globalConfigKey)]);
|
|
25
28
|
(0, _use_watchable.default)(session, ['permissionLevel']);
|
|
29
|
+
var viewIfInViewContext = runContext.type === _airtable_interface.BlockRunContextType.VIEW ? sdk.base.getTableById(runContext.tableId).getViewById(runContext.viewId) : null; // We can't conditionally watch, but if it's not a viewContext the model will be null.
|
|
30
|
+
|
|
31
|
+
(0, _use_watchable.default)(viewIfInViewContext, ['isLockedView']);
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
};
|
|
@@ -30,7 +30,7 @@ var hasBeenInitialized = false;
|
|
|
30
30
|
/** */
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
* `initializeBlock` takes the top-level React component in your tree and renders it. It is conceptually similar to `ReactDOM.render`, but takes care of some
|
|
33
|
+
* `initializeBlock` takes the top-level React component in your tree and renders it. It is conceptually similar to `ReactDOM.render`, but takes care of some Extensions-specific things.
|
|
34
34
|
*
|
|
35
35
|
* @param getEntryElement A function that returns your React Node.
|
|
36
36
|
*
|
|
@@ -78,7 +78,7 @@ function initializeBlock(getEntryElement) {
|
|
|
78
78
|
case _airtable_interface2.BlockRunContextType.DASHBOARD_APP:
|
|
79
79
|
{
|
|
80
80
|
if (entryPoints.dashboard === undefined) {
|
|
81
|
-
throw (0, _error_utils.spawnError)('If running an
|
|
81
|
+
throw (0, _error_utils.spawnError)('If running an extension within the dashboard, it must have a dashboard initialization function');
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
if (typeof entryPoints.dashboard !== 'function') {
|
|
@@ -92,7 +92,7 @@ function initializeBlock(getEntryElement) {
|
|
|
92
92
|
case _airtable_interface2.BlockRunContextType.VIEW:
|
|
93
93
|
{
|
|
94
94
|
if (entryPoints.view === undefined) {
|
|
95
|
-
throw (0, _error_utils.spawnError)('If running an
|
|
95
|
+
throw (0, _error_utils.spawnError)('If running an extension within a view, it must have a view initialization function');
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
if (typeof entryPoints.view !== 'function') {
|
|
@@ -16,7 +16,7 @@ var _sdk_context = require("./sdk_context");
|
|
|
16
16
|
/** */
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* Returns the
|
|
19
|
+
* Returns the extension's {@link GlobalConfig} and updates whenever any key in {@link GlobalConfig}
|
|
20
20
|
* changes.
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
@@ -42,7 +42,7 @@ var SUSPENSE_CLEAN_UP_MS = 60000;
|
|
|
42
42
|
*/
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
* When you're writing an
|
|
45
|
+
* When you're writing an extension, not all of the data in your base is available to work with straight
|
|
46
46
|
* away. We need to load it from Airtable first. This hook is a low-level tool for managing that.
|
|
47
47
|
* You might not need to use it directly though - if you're working with a {@link RecordQueryResult}, try
|
|
48
48
|
* {@link useRecords}, {@link useRecordIds}, or {@link useRecordById} first.
|
|
@@ -51,7 +51,7 @@ var SUSPENSE_CLEAN_UP_MS = 60000;
|
|
|
51
51
|
* loaded when your component mounts, and unloaded when your component unmounts. By default, you
|
|
52
52
|
* don't need to worry about waiting for the data to load - the hook uses React Suspense to make
|
|
53
53
|
* sure the rest of your component doesn't run until the data is loaded. Whilst the data is
|
|
54
|
-
* loading, the entire
|
|
54
|
+
* loading, the entire extension will show a loading indicator. If you want to change where that
|
|
55
55
|
* indicator shows or how it looks, use [`<React.Suspense />`](https://reactjs.org/docs/react-api.html#reactsuspense|)
|
|
56
56
|
* around the component that uses the hook.
|
|
57
57
|
*
|
|
@@ -164,7 +164,7 @@ function useLoadable(models) {
|
|
|
164
164
|
// lifecycle and use that to unload it. Instead, we load it and keep it loaded for a long
|
|
165
165
|
// enough time that it can resolve and then be rendered successfully. After the timeout has
|
|
166
166
|
// passed, we unload it, allowing the data to be released as long as it's not used anywhere
|
|
167
|
-
// else in the
|
|
167
|
+
// else in the extension.
|
|
168
168
|
setTimeout(() => {
|
|
169
169
|
var _iteratorNormalCompletion2 = true;
|
|
170
170
|
var _didIteratorError2 = false;
|
|
@@ -20,29 +20,29 @@ var _sdk_context = require("./sdk_context");
|
|
|
20
20
|
/** */
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* A hook to watch "open
|
|
23
|
+
* A hook to watch "open extension" / "perform record action" events (from button field). Returns
|
|
24
24
|
* the data corresponding to the latest action, or `null` if no actions have occurred yet. If there
|
|
25
|
-
* was a pending event for the
|
|
26
|
-
* clicked while the
|
|
25
|
+
* was a pending event for the extension (for example, because a button that opens this extension was
|
|
26
|
+
* clicked while the extensions dashboard was closed) it will be returned as the initial value.
|
|
27
27
|
*
|
|
28
|
-
* Like {@link useLoadable}, this hook puts the
|
|
28
|
+
* Like {@link useLoadable}, this hook puts the extension in suspense while subscribing to events and
|
|
29
29
|
* fetching the initial data.
|
|
30
30
|
*
|
|
31
31
|
* Also see {@link registerRecordActionDataCallback}, which subscribes to the same events in an
|
|
32
32
|
* asynchronous (callback based) way. An advantage of using this hook over the callback is that you
|
|
33
|
-
* immediately can handle any pending events when your
|
|
33
|
+
* immediately can handle any pending events when your extension opens - with a callback, your extension
|
|
34
34
|
* will finish it's initial render before handling the event.
|
|
35
35
|
*
|
|
36
|
-
* Like {@link registerRecordActionDataCallback}, your
|
|
36
|
+
* Like {@link registerRecordActionDataCallback}, your extension won't receive events until this hook is
|
|
37
37
|
* used for the first time. Because of that, we recommend only using this hook once, in the top
|
|
38
|
-
* level component of your
|
|
38
|
+
* level component of your extension. Similarly, using both `registerRecordActionDataCallback` and
|
|
39
39
|
* `useRecordActionData` is not supported.
|
|
40
40
|
*
|
|
41
|
-
* You can test your
|
|
42
|
-
* in the "Advanced" panel of the
|
|
41
|
+
* You can test your extension in development by sending "perform record action" events to your extension
|
|
42
|
+
* in the "Advanced" panel of the extension developer tools.
|
|
43
43
|
*
|
|
44
|
-
* After releasing your
|
|
45
|
-
*
|
|
44
|
+
* After releasing your extension, you can use it with a button field by choosing the "Open custom
|
|
45
|
+
* extension" action and selecting your extension.
|
|
46
46
|
*
|
|
47
47
|
* @example
|
|
48
48
|
* ```js
|
|
@@ -4,10 +4,6 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
|
|
|
4
4
|
|
|
5
5
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
6
|
|
|
7
|
-
require("core-js/modules/es.array.iterator");
|
|
8
|
-
|
|
9
|
-
require("core-js/modules/web.dom-collections.iterator");
|
|
10
|
-
|
|
11
7
|
Object.defineProperty(exports, "__esModule", {
|
|
12
8
|
value: true
|
|
13
9
|
});
|
|
@@ -108,7 +104,7 @@ function useRecordIds(tableOrViewOrQueryResult, opts) {
|
|
|
108
104
|
var queryResult = _useUnwatchedRecordQueryResult(tableOrViewOrQueryResult, 'useRecordIds', generatedOpts);
|
|
109
105
|
|
|
110
106
|
(0, _use_watchable.default)(queryResult, ['recordIds']);
|
|
111
|
-
return queryResult ?
|
|
107
|
+
return queryResult ? queryResult.recordIds : null;
|
|
112
108
|
}
|
|
113
109
|
/** */
|
|
114
110
|
|
|
@@ -18,7 +18,7 @@ var _sdk_context = require("./sdk_context");
|
|
|
18
18
|
/** */
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* A hook for using the settings button that lives outside the
|
|
21
|
+
* A hook for using the settings button that lives outside the extension's viewport. It will show
|
|
22
22
|
* the settings button (hidden by default) and call the provided callback whenever the settings
|
|
23
23
|
* button is clicked. It will also re-render your component when the settings button is clicked.
|
|
24
24
|
*
|
|
@@ -44,7 +44,7 @@ var _with_hooks = _interopRequireDefault(require("./with_hooks"));
|
|
|
44
44
|
var didSizeChange = (prev, next) => (prev && prev.width) !== (next && next.width) || (prev && prev.height) !== (next && next.height);
|
|
45
45
|
/**
|
|
46
46
|
* When mounted, this wrapper component applies size constraints to the {@link Viewport}.
|
|
47
|
-
* Like {@link addMinSize}, this will fullscreen the
|
|
47
|
+
* Like {@link addMinSize}, this will fullscreen the extension if necessary and possible when
|
|
48
48
|
* `minSize` is updated.
|
|
49
49
|
*
|
|
50
50
|
* @example
|
|
@@ -53,36 +53,6 @@ Object.defineProperty(exports, "PartialViewData", {
|
|
|
53
53
|
return _airtable_interface.PartialViewData;
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
|
-
Object.defineProperty(exports, "BlockQuerySubscriptionOptions", {
|
|
57
|
-
enumerable: true,
|
|
58
|
-
get: function get() {
|
|
59
|
-
return _airtable_interface.BlockQuerySubscriptionOptions;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
Object.defineProperty(exports, "BlockQuerySpec", {
|
|
63
|
-
enumerable: true,
|
|
64
|
-
get: function get() {
|
|
65
|
-
return _block_query_spec.BlockQuerySpec;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
Object.defineProperty(exports, "BlockQueryId", {
|
|
69
|
-
enumerable: true,
|
|
70
|
-
get: function get() {
|
|
71
|
-
return _block_query_spec.BlockQueryId;
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
Object.defineProperty(exports, "QuerySpecsResponse", {
|
|
75
|
-
enumerable: true,
|
|
76
|
-
get: function get() {
|
|
77
|
-
return _block_query_spec.QuerySpecsResponse;
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
Object.defineProperty(exports, "BlockQuerySubscriptionOnChangeCallback", {
|
|
81
|
-
enumerable: true,
|
|
82
|
-
get: function get() {
|
|
83
|
-
return _block_query_spec.BlockQuerySubscriptionOnChangeCallback;
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
56
|
Object.defineProperty(exports, "RecordData", {
|
|
87
57
|
enumerable: true,
|
|
88
58
|
get: function get() {
|
|
@@ -167,30 +137,6 @@ Object.defineProperty(exports, "AbstractMockAirtableInterface", {
|
|
|
167
137
|
return _abstract_mock_airtable_interface.AbstractMockAirtableInterface;
|
|
168
138
|
}
|
|
169
139
|
});
|
|
170
|
-
Object.defineProperty(exports, "FixtureData", {
|
|
171
|
-
enumerable: true,
|
|
172
|
-
get: function get() {
|
|
173
|
-
return _fixture_data.FixtureData;
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
Object.defineProperty(exports, "convertFixtureDataToSdkInitData", {
|
|
177
|
-
enumerable: true,
|
|
178
|
-
get: function get() {
|
|
179
|
-
return _fixture_data.convertFixtureDataToSdkInitData;
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
Object.defineProperty(exports, "MockBaseDataStore", {
|
|
183
|
-
enumerable: true,
|
|
184
|
-
get: function get() {
|
|
185
|
-
return _mock_base_data_stores.MockBaseDataStore;
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
Object.defineProperty(exports, "TestRecordStoreForTable", {
|
|
189
|
-
enumerable: true,
|
|
190
|
-
get: function get() {
|
|
191
|
-
return _mock_base_data_stores.TestRecordStoreForTable;
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
140
|
|
|
195
141
|
var _base = require("./types/base");
|
|
196
142
|
|
|
@@ -198,8 +144,6 @@ var _mutations = require("./types/mutations");
|
|
|
198
144
|
|
|
199
145
|
var _airtable_interface = require("./types/airtable_interface");
|
|
200
146
|
|
|
201
|
-
var _block_query_spec = require("./types/block_query_spec");
|
|
202
|
-
|
|
203
147
|
var _record = require("./types/record");
|
|
204
148
|
|
|
205
149
|
var _cursor = require("./types/cursor");
|
|
@@ -216,8 +160,4 @@ var _backend_fetch_types = require("./types/backend_fetch_types");
|
|
|
216
160
|
|
|
217
161
|
var _sdk = _interopRequireDefault(require("./sdk"));
|
|
218
162
|
|
|
219
|
-
var _abstract_mock_airtable_interface = require("./testing/abstract_mock_airtable_interface");
|
|
220
|
-
|
|
221
|
-
var _fixture_data = require("./testing/fixture_data");
|
|
222
|
-
|
|
223
|
-
var _mock_base_data_stores = require("./testing/mock_base_data_stores");
|
|
163
|
+
var _abstract_mock_airtable_interface = require("./testing/abstract_mock_airtable_interface");
|
package/dist/cjs/viewport.js
CHANGED
|
@@ -139,7 +139,7 @@ function (_Watchable) {
|
|
|
139
139
|
/**
|
|
140
140
|
* Request to enter fullscreen mode.
|
|
141
141
|
*
|
|
142
|
-
* May fail if another
|
|
142
|
+
* May fail if another extension is fullscreen or this extension doesn't have
|
|
143
143
|
* permission to fullscreen itself. Watch `isFullscreen` to know if the
|
|
144
144
|
* request succeeded.
|
|
145
145
|
*/
|
|
@@ -158,7 +158,7 @@ function (_Watchable) {
|
|
|
158
158
|
this._airtableInterface.exitFullscreen();
|
|
159
159
|
}
|
|
160
160
|
/**
|
|
161
|
-
* The maximum dimensions of the
|
|
161
|
+
* The maximum dimensions of the extension when it is in
|
|
162
162
|
* fullscreen mode. Returns the smallest set of dimensions added with
|
|
163
163
|
* {@link addMaxFullscreenSize}.
|
|
164
164
|
*
|
|
@@ -203,8 +203,8 @@ function (_Watchable) {
|
|
|
203
203
|
};
|
|
204
204
|
}
|
|
205
205
|
/**
|
|
206
|
-
* The minimum dimensions of the
|
|
207
|
-
* size, an overlay will be shown asking the user to resize the
|
|
206
|
+
* The minimum dimensions of the extension - if the viewport gets smaller than this
|
|
207
|
+
* size, an overlay will be shown asking the user to resize the extension to be bigger.
|
|
208
208
|
*
|
|
209
209
|
* The largest set of dimensions added with addMinSize. If `width` or `height` is null, it means
|
|
210
210
|
* there is no minSize constraint on that dimension.
|
|
@@ -217,8 +217,8 @@ function (_Watchable) {
|
|
|
217
217
|
* Add a minimum frame size constraint. Use `.minSize`` to get the aggregate
|
|
218
218
|
* of all added constraints.
|
|
219
219
|
*
|
|
220
|
-
* Upon adding a constraint, if the
|
|
221
|
-
* minimum size, the
|
|
220
|
+
* Upon adding a constraint, if the extension is focused and the frame is smaller than the
|
|
221
|
+
* minimum size, the extension will enter fullscreen mode.
|
|
222
222
|
*
|
|
223
223
|
* Returns a function that can be called to remove the size constraint that was added.
|
|
224
224
|
*
|
|
@@ -261,7 +261,7 @@ function (_Watchable) {
|
|
|
261
261
|
};
|
|
262
262
|
}
|
|
263
263
|
/**
|
|
264
|
-
* `true` if the
|
|
264
|
+
* `true` if the extension frame is smaller than `minSize`, `false` otherwise.
|
|
265
265
|
*/
|
|
266
266
|
|
|
267
267
|
}, {
|
|
@@ -428,7 +428,7 @@ function (_Watchable) {
|
|
|
428
428
|
return isWidthTooSmall || isHeightTooSmall;
|
|
429
429
|
}
|
|
430
430
|
/**
|
|
431
|
-
* `true` if the
|
|
431
|
+
* `true` if the extension is fullscreen, `false` otherwise.
|
|
432
432
|
*/
|
|
433
433
|
|
|
434
434
|
}, {
|
|
@@ -437,7 +437,7 @@ function (_Watchable) {
|
|
|
437
437
|
return this._isFullscreen;
|
|
438
438
|
}
|
|
439
439
|
/**
|
|
440
|
-
* The current size of the
|
|
440
|
+
* The current size of the extension frame.
|
|
441
441
|
*
|
|
442
442
|
* Can be watched.
|
|
443
443
|
*/
|