datocms-plugin-sdk 2.1.0-alpha.1 → 2.1.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.
Files changed (56) hide show
  1. package/dist/cjs/connect.js +4 -0
  2. package/dist/cjs/connect.js.map +1 -1
  3. package/dist/cjs/guardUtils.js +12 -0
  4. package/dist/cjs/guardUtils.js.map +1 -1
  5. package/dist/cjs/hooks/mainNavigationTabs.js +4 -1
  6. package/dist/cjs/hooks/mainNavigationTabs.js.map +1 -1
  7. package/dist/cjs/hooks/renderInspector.js +11 -0
  8. package/dist/cjs/hooks/renderInspector.js.map +1 -0
  9. package/dist/cjs/hooks/renderInspectorPanel.js +11 -0
  10. package/dist/cjs/hooks/renderInspectorPanel.js.map +1 -0
  11. package/dist/cjs/icon.js +12 -5
  12. package/dist/cjs/icon.js.map +1 -1
  13. package/dist/cjs/index.js +2 -0
  14. package/dist/cjs/index.js.map +1 -1
  15. package/dist/cjs/manifest.js +134 -0
  16. package/dist/cjs/manifest.js.map +1 -1
  17. package/dist/esm/connect.d.ts +3 -1
  18. package/dist/esm/connect.js +4 -0
  19. package/dist/esm/connect.js.map +1 -1
  20. package/dist/esm/guardUtils.d.ts +4 -0
  21. package/dist/esm/guardUtils.js +8 -0
  22. package/dist/esm/guardUtils.js.map +1 -1
  23. package/dist/esm/hooks/mainNavigationTabs.d.ts +15 -1
  24. package/dist/esm/hooks/mainNavigationTabs.js +4 -1
  25. package/dist/esm/hooks/mainNavigationTabs.js.map +1 -1
  26. package/dist/esm/hooks/renderInspector.d.ts +147 -0
  27. package/dist/esm/hooks/renderInspector.js +8 -0
  28. package/dist/esm/hooks/renderInspector.js.map +1 -0
  29. package/dist/esm/hooks/renderInspectorPanel.d.ts +20 -0
  30. package/dist/esm/hooks/renderInspectorPanel.js +8 -0
  31. package/dist/esm/hooks/renderInspectorPanel.js.map +1 -0
  32. package/dist/esm/icon.d.ts +23 -2
  33. package/dist/esm/icon.js +11 -6
  34. package/dist/esm/icon.js.map +1 -1
  35. package/dist/esm/index.d.ts +2 -0
  36. package/dist/esm/index.js +2 -0
  37. package/dist/esm/index.js.map +1 -1
  38. package/dist/esm/manifest.js +134 -0
  39. package/dist/esm/manifest.js.map +1 -1
  40. package/dist/types/connect.d.ts +3 -1
  41. package/dist/types/guardUtils.d.ts +4 -0
  42. package/dist/types/hooks/mainNavigationTabs.d.ts +15 -1
  43. package/dist/types/hooks/renderInspector.d.ts +147 -0
  44. package/dist/types/hooks/renderInspectorPanel.d.ts +20 -0
  45. package/dist/types/icon.d.ts +23 -2
  46. package/dist/types/index.d.ts +2 -0
  47. package/manifest.json +134 -0
  48. package/package.json +4 -3
  49. package/src/connect.ts +12 -0
  50. package/src/guardUtils.ts +13 -0
  51. package/src/hooks/mainNavigationTabs.ts +24 -5
  52. package/src/hooks/renderInspector.ts +176 -0
  53. package/src/hooks/renderInspectorPanel.ts +38 -0
  54. package/src/icon.ts +36 -8
  55. package/src/index.ts +2 -0
  56. package/src/manifest.ts +145 -0
package/src/manifest.ts CHANGED
@@ -1231,6 +1231,151 @@ export const manifest: Manifest = {
1231
1231
  lineNumber: 14,
1232
1232
  },
1233
1233
  },
1234
+ renderInspectorPanel: {
1235
+ name: 'renderInspectorPanel',
1236
+ comment: {
1237
+ markdownText:
1238
+ 'This function will be called when an inspector needs to render a specific\npanel (see the `renderInspector` and `setInspectorMode` functions).',
1239
+ tag: 'inspector',
1240
+ },
1241
+ nonCtxArguments: [
1242
+ {
1243
+ name: 'panelId',
1244
+ typeName: 'string',
1245
+ },
1246
+ ],
1247
+ ctxArgument: {
1248
+ type: 'ImposedSizePluginFrameCtx',
1249
+ additionalProperties: [
1250
+ {
1251
+ items: {
1252
+ panelId: {
1253
+ comment: {
1254
+ markdownText:
1255
+ 'The ID of the inspector panel that needs to be rendered.',
1256
+ },
1257
+ location: {
1258
+ filePath: 'src/hooks/renderInspectorPanel.ts',
1259
+ lineNumber: 18,
1260
+ },
1261
+ type: 'string',
1262
+ },
1263
+ parameters: {
1264
+ comment: {
1265
+ markdownText:
1266
+ 'The arbitrary `parameters` of the modal declared in the `setInspectorMode`\nfunction.',
1267
+ },
1268
+ location: {
1269
+ filePath: 'src/hooks/renderInspectorPanel.ts',
1270
+ lineNumber: 24,
1271
+ },
1272
+ type: 'Record<string, unknown>',
1273
+ },
1274
+ },
1275
+ },
1276
+ ],
1277
+ additionalMethods: [],
1278
+ },
1279
+ returnType: 'void',
1280
+ location: {
1281
+ filePath: 'src/hooks/renderInspectorPanel.ts',
1282
+ lineNumber: 11,
1283
+ },
1284
+ },
1285
+ renderInspector: {
1286
+ name: 'renderInspector',
1287
+ comment: {
1288
+ markdownText:
1289
+ 'This function will be called when the plugin needs to render a specific\ninspector. Inspectors provide a side panel interface for displaying and\ninteracting with content alongside a custom interface.',
1290
+ tag: 'inspector',
1291
+ example:
1292
+ "connect({\n renderInspector(inspectorId, ctx) {\n render(\n <div>\n <h1>Inspector: {inspectorId}</h1>\n <button onClick={() => ctx.setInspectorMode({\n type: 'itemEditor',\n itemId: 'some-item-id'\n })}>\n Show Item Editor\n </button>\n </div>\n );\n }\n});",
1293
+ },
1294
+ nonCtxArguments: [
1295
+ {
1296
+ name: 'inspectorId',
1297
+ typeName: 'string',
1298
+ },
1299
+ ],
1300
+ ctxArgument: {
1301
+ type: 'ImposedSizePluginFrameCtx',
1302
+ additionalProperties: [
1303
+ {
1304
+ items: {
1305
+ inspectorId: {
1306
+ comment: {
1307
+ markdownText:
1308
+ 'The ID of the inspector that needs to be rendered.',
1309
+ },
1310
+ location: {
1311
+ filePath: 'src/hooks/renderInspector.ts',
1312
+ lineNumber: 80,
1313
+ },
1314
+ type: 'string',
1315
+ },
1316
+ highlightedItemId: {
1317
+ comment: {
1318
+ markdownText:
1319
+ 'The ID of the record the currently is highlighted by the user.',
1320
+ },
1321
+ location: {
1322
+ filePath: 'src/hooks/renderInspector.ts',
1323
+ lineNumber: 83,
1324
+ },
1325
+ type: 'string | undefined',
1326
+ },
1327
+ location: {
1328
+ comment: {
1329
+ markdownText: 'Current page location.',
1330
+ },
1331
+ location: {
1332
+ filePath: 'src/hooks/renderInspector.ts',
1333
+ lineNumber: 86,
1334
+ },
1335
+ type: '{\n pathname: string;\n search: string;\n hash: string;\n }',
1336
+ },
1337
+ },
1338
+ },
1339
+ ],
1340
+ additionalMethods: [
1341
+ {
1342
+ items: {
1343
+ setInspectorMode: {
1344
+ comment: {
1345
+ markdownText:
1346
+ 'Changes the current display mode of the inspector. This allows the plugin\nto dynamically switch between showing a record list, record editor, or custom\npanel within the inspector interface.',
1347
+ example:
1348
+ "// Switch to record editor mode\nawait ctx.setInspectorMode({\n type: 'itemEditor',\n itemId: 'item-123',\n fieldPath: 'title'\n});\n\n// Switch to record list mode\nawait ctx.setInspectorMode({ type: 'itemList' });\nawait ctx.setInspectorItemListData({\n title: 'Related Records',\n itemIds: ['item-1', 'item-2', 'item-3']\n});\n\n// Switch to custom panel mode\nawait ctx.setInspectorMode({\n type: 'customPanel',\n panelId: 'my-custom-panel',\n parameters: { filter: 'active' }\n});\n\n// Low intent mode change - won't interrupt editing with unsaved changes\nawait ctx.setInspectorMode(\n { type: 'itemList' },\n { ignoreIfUnsavedChanges: true }\n);",
1349
+ },
1350
+ location: {
1351
+ filePath: 'src/hooks/renderInspector.ts',
1352
+ lineNumber: 136,
1353
+ },
1354
+ type: '(\n mode: InspectorMode,\n options?: SetInspectorModeOptions,\n ) => Promise<void>',
1355
+ },
1356
+ setInspectorItemListData: {
1357
+ comment: {
1358
+ markdownText:
1359
+ 'Sets the data for the item list inspector mode.',
1360
+ example:
1361
+ "// Set the item list data\nawait ctx.setInspectorItemListData({\n title: 'Related Records',\n itemIds: ['item-1', 'item-2', 'item-3']\n});\n\n// Switch to item list mode\nawait ctx.setInspectorMode({ type: 'itemList' });",
1362
+ },
1363
+ location: {
1364
+ filePath: 'src/hooks/renderInspector.ts',
1365
+ lineNumber: 157,
1366
+ },
1367
+ type: '(data: {\n /** The title to show in the inspector header */\n title: string;\n /** Array of record IDs to display in the list */\n itemIds: string[];\n }) => Promise<void>',
1368
+ },
1369
+ },
1370
+ },
1371
+ ],
1372
+ },
1373
+ returnType: 'void',
1374
+ location: {
1375
+ filePath: 'src/hooks/renderInspector.ts',
1376
+ lineNumber: 73,
1377
+ },
1378
+ },
1234
1379
  renderFieldExtension: {
1235
1380
  name: 'renderFieldExtension',
1236
1381
  comment: {