@optiaxiom/proteus 3.0.6 → 3.2.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 (30) hide show
  1. package/dist/esm/assets/src/proteus-chart/{ProteusChart.css.ts.vanilla-ByPSKREp.css → ProteusChart.css.ts.vanilla-BcGBUwbD.css} +2 -2
  2. package/dist/esm/assets/src/proteus-chart/{ProteusChartTooltipContent.css.ts.vanilla-DnR_C5ly.css → ProteusChartTooltipContent.css.ts.vanilla-BthlShlk.css} +2 -2
  3. package/dist/esm/assets/src/proteus-document/{ProteusDocumentShell.css.ts.vanilla-CVOes7es.css → ProteusDocumentShell.css.ts.vanilla-BugeP59E.css} +2 -2
  4. package/dist/esm/assets/src/proteus-image-carousel/{ProteusImageCarousel.css.ts.vanilla-DXF3wHYt.css → ProteusImageCarousel.css.ts.vanilla-DhXdg25-.css} +2 -2
  5. package/dist/esm/assets/src/proteus-markdown/{ProteusMarkdown.css.ts.vanilla-Cjmk3X5z.css → ProteusMarkdown.css.ts.vanilla-BM9-lPyj.css} +2 -2
  6. package/dist/esm/assets/src/proteus-question/{ProteusQuestion.css.ts.vanilla-DVFRsIPp.css → ProteusQuestion.css.ts.vanilla-1u353vmb.css} +2 -2
  7. package/dist/esm/index.js +2 -1
  8. package/dist/esm/proteus-action/ProteusAction.js +1 -1
  9. package/dist/esm/proteus-chart/ProteusChart-css.js +1 -1
  10. package/dist/esm/proteus-chart/ProteusChartTooltipContent-css.js +1 -1
  11. package/dist/esm/proteus-data-table/ProteusDataTable.js +3 -1
  12. package/dist/esm/proteus-data-table-row/ProteusDataTableRow.js +26 -0
  13. package/dist/esm/proteus-document/ProteusDataTableRowContext.js +12 -0
  14. package/dist/esm/proteus-document/ProteusDocumentShell-css.js +1 -1
  15. package/dist/esm/proteus-document/ProteusDocumentShell.js +70 -49
  16. package/dist/esm/proteus-document/isSafeUrl.js +22 -0
  17. package/dist/esm/proteus-document/resolveProteusProp.js +5 -6
  18. package/dist/esm/proteus-document/resolveProteusValue.js +26 -23
  19. package/dist/esm/proteus-document/useResolveProteusValues.js +3 -1
  20. package/dist/esm/proteus-element/ProteusElement.js +41 -3
  21. package/dist/esm/proteus-image-carousel/ProteusImageCarousel-css.js +1 -1
  22. package/dist/esm/proteus-markdown/ProteusMarkdown-css.js +1 -1
  23. package/dist/esm/proteus-question/ProteusQuestion-css.js +1 -1
  24. package/dist/esm/proteus-script/useProteusScripts.js +176 -0
  25. package/dist/esm/proteus-script/workerScript.js +149 -0
  26. package/dist/esm/proteus-show/ProteusShow.js +4 -3
  27. package/dist/esm/schema/public-schema.js +100 -0
  28. package/dist/esm/schema/runtime-schema.js +97 -0
  29. package/dist/index.d.ts +42 -2
  30. package/package.json +3 -3
@@ -918,6 +918,7 @@ var definitions = {
918
918
  { "type": "number" },
919
919
  { "type": "boolean" },
920
920
  { "type": "null" },
921
+ { "$ref": "#/definitions/ProteusDataTableRow" },
921
922
  { "$ref": "#/definitions/ProteusLength" },
922
923
  { "$ref": "#/definitions/ProteusMapIndex" },
923
924
  { "$ref": "#/definitions/ProteusValue" }
@@ -937,6 +938,7 @@ var definitions = {
937
938
  { "type": "number" },
938
939
  { "type": "boolean" },
939
940
  { "type": "null" },
941
+ { "$ref": "#/definitions/ProteusDataTableRow" },
940
942
  { "$ref": "#/definitions/ProteusLength" },
941
943
  { "$ref": "#/definitions/ProteusMapIndex" },
942
944
  { "$ref": "#/definitions/ProteusValue" }
@@ -956,6 +958,7 @@ var definitions = {
956
958
  { "type": "number" },
957
959
  { "type": "boolean" },
958
960
  { "type": "null" },
961
+ { "$ref": "#/definitions/ProteusDataTableRow" },
959
962
  { "$ref": "#/definitions/ProteusLength" },
960
963
  { "$ref": "#/definitions/ProteusMapIndex" },
961
964
  { "$ref": "#/definitions/ProteusValue" }
@@ -975,6 +978,7 @@ var definitions = {
975
978
  { "type": "number" },
976
979
  { "type": "boolean" },
977
980
  { "type": "null" },
981
+ { "$ref": "#/definitions/ProteusDataTableRow" },
978
982
  { "$ref": "#/definitions/ProteusLength" },
979
983
  { "$ref": "#/definitions/ProteusMapIndex" },
980
984
  { "$ref": "#/definitions/ProteusValue" }
@@ -994,6 +998,7 @@ var definitions = {
994
998
  { "type": "number" },
995
999
  { "type": "boolean" },
996
1000
  { "type": "null" },
1001
+ { "$ref": "#/definitions/ProteusDataTableRow" },
997
1002
  { "$ref": "#/definitions/ProteusLength" },
998
1003
  { "$ref": "#/definitions/ProteusMapIndex" },
999
1004
  { "$ref": "#/definitions/ProteusValue" }
@@ -1013,6 +1018,7 @@ var definitions = {
1013
1018
  { "type": "number" },
1014
1019
  { "type": "boolean" },
1015
1020
  { "type": "null" },
1021
+ { "$ref": "#/definitions/ProteusDataTableRow" },
1016
1022
  { "$ref": "#/definitions/ProteusLength" },
1017
1023
  { "$ref": "#/definitions/ProteusMapIndex" },
1018
1024
  { "$ref": "#/definitions/ProteusValue" }
@@ -1031,6 +1037,7 @@ var definitions = {
1031
1037
  { "type": "number" },
1032
1038
  { "type": "boolean" },
1033
1039
  { "type": "null" },
1040
+ { "$ref": "#/definitions/ProteusDataTableRow" },
1034
1041
  { "$ref": "#/definitions/ProteusLength" },
1035
1042
  { "$ref": "#/definitions/ProteusMapIndex" },
1036
1043
  { "$ref": "#/definitions/ProteusValue" }
@@ -1047,6 +1054,7 @@ var definitions = {
1047
1054
  { "type": "number" },
1048
1055
  { "type": "boolean" },
1049
1056
  { "type": "null" },
1057
+ { "$ref": "#/definitions/ProteusDataTableRow" },
1050
1058
  { "$ref": "#/definitions/ProteusLength" },
1051
1059
  { "$ref": "#/definitions/ProteusMapIndex" },
1052
1060
  { "$ref": "#/definitions/ProteusValue" }
@@ -1197,6 +1205,32 @@ var definitions = {
1197
1205
  "gap": "16"
1198
1206
  }],
1199
1207
  "title": "Create Test Plan"
1208
+ },
1209
+ {
1210
+ "$type": "Document",
1211
+ "actions": [{
1212
+ "$type": "Action",
1213
+ "appearance": "primary",
1214
+ "children": "Greet",
1215
+ "onClick": {
1216
+ "params": { "name": {
1217
+ "$type": "Value",
1218
+ "path": "/name"
1219
+ } },
1220
+ "script": "main:greet"
1221
+ }
1222
+ }],
1223
+ "appName": "Opal",
1224
+ "body": [{
1225
+ "$type": "Field",
1226
+ "children": {
1227
+ "$type": "Input",
1228
+ "name": "name"
1229
+ },
1230
+ "label": "Your name"
1231
+ }],
1232
+ "scripts": { "main": "register('greet', (ctx) => ctx.emit({ message: `Hello, ${ctx.params.name}!` }))" },
1233
+ "title": "Scripted Greeting"
1200
1234
  }
1201
1235
  ],
1202
1236
  "properties": {
@@ -1239,6 +1273,11 @@ var definitions = {
1239
1273
  "type": "object"
1240
1274
  },
1241
1275
  "meta": { "description": "Additional metadata not directly consumed by Proteus. Use this to pass along any extra data." },
1276
+ "scripts": {
1277
+ "additionalProperties": { "type": "string" },
1278
+ "description": "Map of module name to JavaScript source. Each module runs in a sandboxed Web Worker and registers named handlers via `register(name, fn)`. Trigger a handler from any event source with `{ script: 'module:handler', params }`; handlers receive a single `ctx` ({ emit, getValue, params }) and can only affect the document by emitting the existing Proteus events through `ctx.emit`.",
1279
+ "type": "object"
1280
+ },
1242
1281
  "subtitle": {
1243
1282
  "$ref": "#/definitions/ProteusNode",
1244
1283
  "description": "A brief description or tagline that provides additional context about the Proteus document's purpose."
@@ -1270,6 +1309,7 @@ var definitions = {
1270
1309
  { "$ref": "#/definitions/ProteusChart" },
1271
1310
  { "$ref": "#/definitions/ProteusConcat" },
1272
1311
  { "$ref": "#/definitions/ProteusDataTable" },
1312
+ { "$ref": "#/definitions/ProteusDataTableRow" },
1273
1313
  { "$ref": "#/definitions/ProteusDateInput" },
1274
1314
  { "$ref": "#/definitions/ProteusDisclosure" },
1275
1315
  { "$ref": "#/definitions/ProteusDisclosureContent" },
@@ -1324,6 +1364,22 @@ var definitions = {
1324
1364
  "required": ["interaction"],
1325
1365
  "type": "object"
1326
1366
  },
1367
+ {
1368
+ "description": "Scripted action - runs a named handler from the document's `scripts` map in a sandboxed Web Worker. The handler can emit the other Proteus events via `ctx.emit`.",
1369
+ "properties": {
1370
+ "params": {
1371
+ "additionalProperties": {},
1372
+ "description": "Parameters passed to the handler as `ctx.params`. Values can be ProteusExpressions that resolve at call time.",
1373
+ "type": "object"
1374
+ },
1375
+ "script": {
1376
+ "description": "Handler to run, addressed as `module:handler` (the module key comes from the document's `scripts` map).",
1377
+ "type": "string"
1378
+ }
1379
+ },
1380
+ "required": ["script"],
1381
+ "type": "object"
1382
+ },
1327
1383
  {
1328
1384
  "description": "Client-side message action",
1329
1385
  "properties": { "message": {
@@ -1421,12 +1477,30 @@ var definitions = {
1421
1477
  },
1422
1478
  "required": ["action", "path"],
1423
1479
  "type": "object"
1480
+ },
1481
+ {
1482
+ "description": "Runtime data operation - writes `value` at `path` in form data, replacing any existing value (e.g. `/tags/2`). Path resolves like `Value` (absolute `/x`, relative to current parentPath, or `''` for parentPath itself).",
1483
+ "properties": {
1484
+ "action": {
1485
+ "const": "setValue",
1486
+ "description": "The action type",
1487
+ "type": "string"
1488
+ },
1489
+ "path": {
1490
+ "description": "JSON pointer path to write to",
1491
+ "type": "string"
1492
+ },
1493
+ "value": { "description": "The value to write; primitives or objects" }
1494
+ },
1495
+ "required": ["action", "path"],
1496
+ "type": "object"
1424
1497
  }
1425
1498
  ],
1426
1499
  "description": "Handler for user interactions - a server-side interaction call, client-side message, or client-side component action"
1427
1500
  },
1428
1501
  "ProteusExpression": {
1429
1502
  "anyOf": [
1503
+ { "$ref": "#/definitions/ProteusDataTableRow" },
1430
1504
  { "$ref": "#/definitions/ProteusLength" },
1431
1505
  { "$ref": "#/definitions/ProteusMap" },
1432
1506
  { "$ref": "#/definitions/ProteusMapIndex" },
@@ -2447,6 +2521,10 @@ var definitions = {
2447
2521
  "description": "Key in data objects",
2448
2522
  "type": "string"
2449
2523
  },
2524
+ "cell": {
2525
+ "$ref": "#/definitions/ProteusNode",
2526
+ "description": "A Proteus node template rendered for each cell in this column. Read the current row with DataTableRow (e.g. { $type: 'DataTableRow', path: 'status' } reads the row's 'status', or omit 'path' for the whole row). Can be a single element or an array — use Show elements to conditionally render (e.g. a Badge whose intent depends on the row value). When set, takes precedence over 'format'."
2527
+ },
2450
2528
  "format": {
2451
2529
  "anyOf": [{
2452
2530
  "description": "Formatter name",
@@ -2489,6 +2567,21 @@ var definitions = {
2489
2567
  "required": ["$type"],
2490
2568
  "type": "object"
2491
2569
  },
2570
+ "ProteusDataTableRow": {
2571
+ "examples": [{
2572
+ "$type": "DataTableRow",
2573
+ "path": "status"
2574
+ }],
2575
+ "properties": {
2576
+ "$type": { "const": "DataTableRow" },
2577
+ "path": {
2578
+ "description": "JSON pointer path to a field within the current row (e.g. 'status' or '/status'). When omitted, resolves to the whole row object. Only meaningful inside a DataTable column's `cell`.",
2579
+ "type": "string"
2580
+ }
2581
+ },
2582
+ "required": ["$type"],
2583
+ "type": "object"
2584
+ },
2492
2585
  "ProteusDateInput": {
2493
2586
  "examples": [{
2494
2587
  "$type": "DateInput",
@@ -4221,6 +4314,10 @@ var definitions = {
4221
4314
  "$ref": "#/definitions/ProteusNode",
4222
4315
  "description": "Content to show when condition is true"
4223
4316
  },
4317
+ "else": {
4318
+ "$ref": "#/definitions/ProteusNode",
4319
+ "description": "Content to render when the condition is false. Omitting it renders nothing. Chain nested Show/else to express multi-way choices (e.g. mapping a value to one of several outputs)."
4320
+ },
4224
4321
  "when": {
4225
4322
  "anyOf": [{ "$ref": "#/definitions/ProteusCondition" }, {
4226
4323
  "items": { "$ref": "#/definitions/ProteusCondition" },
package/dist/index.d.ts CHANGED
@@ -64,6 +64,21 @@ declare namespace ProteusChart {
64
64
  var displayName: string;
65
65
  }
66
66
  //#endregion
67
+ //#region src/proteus-data-table-row/ProteusDataTableRow.d.ts
68
+ type ProteusDataTableRowProps = {
69
+ /**
70
+ * JSON pointer path to a field within the current row (e.g. `type` or
71
+ * `/type`). When omitted, resolves to the whole row object.
72
+ */
73
+ path?: string;
74
+ };
75
+ declare function ProteusDataTableRow({
76
+ path
77
+ }: ProteusDataTableRowProps): string | null;
78
+ declare namespace ProteusDataTableRow {
79
+ var displayName: string;
80
+ }
81
+ //#endregion
67
82
  //#region src/proteus-data-table/ProteusDataTable.d.ts
68
83
  type ProteusDataTableProps = {
69
84
  /**
@@ -77,6 +92,12 @@ type ProteusDataTableProps = {
77
92
  };
78
93
  type ColumnDef = {
79
94
  accessorKey: string;
95
+ /**
96
+ * Renders a cell for this column from the row's data. When set, takes
97
+ * precedence over `format`. Wired up from a Proteus `cell` template by
98
+ * `ProteusElement`.
99
+ */
100
+ cell?: (row: Record<string, unknown>) => ReactNode;
80
101
  format?: string | {
81
102
  options?: Record<string, unknown>;
82
103
  type: string;
@@ -348,6 +369,9 @@ type ProteusCondition = {
348
369
  or: ProteusCondition[];
349
370
  };
350
371
  type ComparisonValue = boolean | null | number | string | {
372
+ $type: "DataTableRow";
373
+ path?: string;
374
+ } | {
351
375
  $type: "Length";
352
376
  path: string;
353
377
  } | {
@@ -360,6 +384,10 @@ type ComparisonValue = boolean | null | number | string | {
360
384
  //#region src/proteus-show/ProteusShow.d.ts
361
385
  type ProteusShowProps = {
362
386
  children?: ReactNode;
387
+ /**
388
+ * Content to render when the condition is false. Omitting it renders nothing.
389
+ */
390
+ else?: ReactNode;
363
391
  /**
364
392
  * Single condition or array of conditions (AND logic). Each condition is an
365
393
  * object with one operator key.
@@ -368,8 +396,9 @@ type ProteusShowProps = {
368
396
  };
369
397
  declare function ProteusShow({
370
398
  children,
399
+ else: fallback,
371
400
  when
372
- }: ProteusShowProps): import("react/jsx-runtime").JSX.Element | null;
401
+ }: ProteusShowProps): import("react/jsx-runtime").JSX.Element;
373
402
  declare namespace ProteusShow {
374
403
  var displayName: string;
375
404
  }
@@ -432,6 +461,8 @@ type ProteusDocumentShellProps = Pick<ComponentPropsWithoutRef<typeof Disclosure
432
461
  element: ProteusDocument$2;
433
462
  /**
434
463
  * Map of icon name to React component. Referenced by `{ $type: "Icon", name }` elements.
464
+ * If `name` is not in the map but starts with `http(s)://` or `data:`, it is
465
+ * rendered as `<img src={name}>` instead.
435
466
  */
436
467
  icons?: ProteusIconMap;
437
468
  /**
@@ -492,6 +523,7 @@ type ProteusDocument$2 = {
492
523
  blocking?: boolean;
493
524
  body: ReactNode;
494
525
  compact?: boolean;
526
+ scripts?: Record<string, string>;
495
527
  subtitle?: ReactNode;
496
528
  title?: ReactNode;
497
529
  titleIcon?: string;
@@ -540,11 +572,18 @@ type ProteusEventHandler = {
540
572
  } | {
541
573
  action: "removeValue";
542
574
  path: string;
575
+ } | {
576
+ action: "setValue";
577
+ path: string;
578
+ value?: unknown;
543
579
  } | {
544
580
  interaction: string;
545
581
  params?: Record<string, unknown>;
546
582
  } | {
547
583
  message: string | StructuredMessage;
584
+ } | {
585
+ params?: Record<string, unknown>;
586
+ script: string;
548
587
  };
549
588
  type ProteusPreviewFile = {
550
589
  extension: string;
@@ -619,6 +658,7 @@ type ProteusDocument = {
619
658
  blocking?: boolean;
620
659
  body: unknown;
621
660
  compact?: boolean;
661
+ scripts?: Record<string, string>;
622
662
  subtitle?: unknown;
623
663
  title?: unknown;
624
664
  titleIcon?: string;
@@ -653,4 +693,4 @@ declare namespace ProteusTextarea {
653
693
  //#region src/use-proteus-value/useProteusValue.d.ts
654
694
  declare function useProteusValue(element: ProteusValueProps): any;
655
695
  //#endregion
656
- export { type FileUploadMetadata, ProteusAction, ProteusBridge, ProteusChart, ProteusDataTable, ProteusDateInput, ProteusDocumentRenderer, ProteusDocumentRendererProps, ProteusDocumentShell, ProteusDocumentShellProps, ProteusFederated, ProteusFileUpload, ProteusFileUploadProps, ProteusImage, ProteusImageCarousel, ProteusInput, ProteusLength, ProteusMap, ProteusMapIndex, ProteusMarkdown, ProteusPillMenu, ProteusPillMenuProps, type ProteusPreviewFile, ProteusRichTextEditor, ProteusSelect, ProteusShow, ProteusTextarea, type StructuredMessage, type UploadFile, safeParseDocument, useProteusValue };
696
+ export { type FileUploadMetadata, ProteusAction, ProteusBridge, ProteusChart, ProteusDataTable, ProteusDataTableRow, ProteusDateInput, ProteusDocumentRenderer, ProteusDocumentRendererProps, ProteusDocumentShell, ProteusDocumentShellProps, ProteusFederated, ProteusFileUpload, ProteusFileUploadProps, ProteusImage, ProteusImageCarousel, ProteusInput, ProteusLength, ProteusMap, ProteusMapIndex, ProteusMarkdown, ProteusPillMenu, ProteusPillMenuProps, type ProteusPreviewFile, ProteusRichTextEditor, ProteusSelect, ProteusShow, ProteusTextarea, type StructuredMessage, type UploadFile, safeParseDocument, useProteusValue };
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "url": "git+https://github.com/optimizely-axiom/optiaxiom.git"
8
8
  },
9
9
  "type": "module",
10
- "version": "3.0.6",
10
+ "version": "3.2.0",
11
11
  "files": [
12
12
  "dist/**",
13
13
  "LICENSE"
@@ -41,8 +41,8 @@
41
41
  "react-markdown": "^10.1.0",
42
42
  "recharts": "^3.8.1",
43
43
  "remark-gfm": "^4.0.1",
44
- "@optiaxiom/icons": "^1.3.0",
45
- "@optiaxiom/react": "^3.1.2"
44
+ "@optiaxiom/react": "^3.1.4",
45
+ "@optiaxiom/icons": "^1.3.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@emotion/hash": "^0.9.2",