@optiaxiom/proteus 0.1.4 → 0.1.6

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.
@@ -3,7 +3,7 @@ import { jsx } from 'react/jsx-runtime';
3
3
  import { Button } from '@optiaxiom/react';
4
4
  import { useState } from 'react';
5
5
  import { useProteusDocumentContext } from '../proteus-document/ProteusDocumentContext.js';
6
- import { useResolvedProteusProps } from '../proteus-document/useResolvedProteusProps.js';
6
+ import { useResolveProteusValues } from '../proteus-document/useResolveProteusValues.js';
7
7
 
8
8
  function ProteusAction({
9
9
  children,
@@ -13,7 +13,7 @@ function ProteusAction({
13
13
  const { onEvent, valid } = useProteusDocumentContext(
14
14
  "@optiaxiom/proteus/ProteusAction"
15
15
  );
16
- const resolvedOnClick = useResolvedProteusProps(
16
+ const resolvedOnClick = useResolveProteusValues(
17
17
  onClick ?? {}
18
18
  );
19
19
  const [loading, setLoading] = useState(false);
@@ -61,6 +61,15 @@ function ProteusDocumentShell({
61
61
  } else if (event.action === "download") {
62
62
  if (typeof event.url === "string") {
63
63
  await downloadFile(event.url);
64
+ } else if (Array.isArray(event.url)) {
65
+ await Promise.all(
66
+ event.url.map((u) => {
67
+ if (typeof u !== "string") {
68
+ throw new Error("Invalid URL in download array");
69
+ }
70
+ return downloadFile(u);
71
+ })
72
+ );
64
73
  } else {
65
74
  throw new Error("Invalid URL for download action");
66
75
  }
@@ -131,7 +140,7 @@ function ProteusDocumentShell({
131
140
  ]
132
141
  }
133
142
  ),
134
- /* @__PURE__ */ jsx(Group, { asChild: true, flexDirection: "column", gap: "16", children: /* @__PURE__ */ jsx(
143
+ /* @__PURE__ */ jsx(Group, { asChild: true, flexDirection: "column", gap: "16", children: /* @__PURE__ */ jsxs(
135
144
  "form",
136
145
  {
137
146
  onChange: (event) => {
@@ -140,11 +149,16 @@ function ProteusDocumentShell({
140
149
  setValid(form.checkValidity());
141
150
  });
142
151
  },
152
+ onSubmit: (event) => {
153
+ event.preventDefault();
154
+ },
143
155
  ref: formRef,
144
- children: element.body
156
+ children: [
157
+ element.body,
158
+ element.actions && !readOnly && /* @__PURE__ */ jsx(Group, { gap: "16", justifyContent: "end", w: "full", children: element.actions })
159
+ ]
145
160
  }
146
- ) }),
147
- element.actions && !readOnly && /* @__PURE__ */ jsx(Group, { gap: "16", justifyContent: "end", w: "full", children: element.actions })
161
+ ) })
148
162
  ]
149
163
  }
150
164
  )
@@ -12,6 +12,20 @@ function resolveProteusValue(value, data, parentPath) {
12
12
  parentPath
13
13
  );
14
14
  }
15
+ if ("$type" in value && value.$type === "Map" && "path" in value && typeof value.path === "string" && "children" in value) {
16
+ const array = getProteusValue(
17
+ data,
18
+ { path: value.path },
19
+ parentPath
20
+ );
21
+ if (!Array.isArray(array)) {
22
+ return value;
23
+ }
24
+ const resolvedPath = value.path.startsWith("/") ? value.path : `${parentPath}/${value.path}`;
25
+ return array.map(
26
+ (_, index) => resolveProteusValue(value.children, data, `${resolvedPath}/${index}`)
27
+ );
28
+ }
15
29
  return value;
16
30
  }
17
31
 
@@ -2,7 +2,7 @@ import { useProteusDocumentContext } from './ProteusDocumentContext.js';
2
2
  import { useProteusDocumentPathContext } from './ProteusDocumentPathContext.js';
3
3
  import { resolveProteusValue } from './resolveProteusValue.js';
4
4
 
5
- function useResolvedProteusProps(props) {
5
+ function useResolveProteusValues(props) {
6
6
  const { data } = useProteusDocumentContext(
7
7
  "@optiaxiom/react/useResolvedProteusProps"
8
8
  );
@@ -16,4 +16,4 @@ function useResolvedProteusProps(props) {
16
16
  return resolved;
17
17
  }
18
18
 
19
- export { useResolvedProteusProps };
19
+ export { useResolveProteusValues };
@@ -93,8 +93,6 @@ const ProteusElement = ({
93
93
  return /* @__PURE__ */ jsx(Group, { ...resolve(element) });
94
94
  case "Heading":
95
95
  return /* @__PURE__ */ jsx(Heading, { ...resolve(element) });
96
- case "Icon":
97
- return /* @__PURE__ */ jsx(Box, { asChild: true, ...resolve(element), children: /* @__PURE__ */ jsx("img", {}) });
98
96
  case "IconCalendar":
99
97
  return /* @__PURE__ */ jsx(Box, { asChild: true, ...resolve(element), children: /* @__PURE__ */ jsx(IconCalendar, {}) });
100
98
  case "Image":
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import { Box, Spinner, Dialog, DialogTrigger, DialogContent, DialogHeader, DialogBody, DialogFooter, DialogClose, Button } from '@optiaxiom/react';
4
4
  import { useState, useRef } from 'react';
5
5
  import { downloadFile } from './downloadFile.js';
@@ -9,6 +9,9 @@ function ProteusImage(props) {
9
9
  const [isDownloading, setIsDownloading] = useState(false);
10
10
  const [isLoaded, setIsLoaded] = useState(false);
11
11
  const imgRef = useRef(null);
12
+ if (props.objectFit === "cover") {
13
+ return /* @__PURE__ */ jsx(Box, { asChild: true, objectFit: "cover", overflow: "hidden", ...props, children: /* @__PURE__ */ jsx("img", { alt: props.alt, src: props.src }) });
14
+ }
12
15
  return /* @__PURE__ */ jsxs(Fragment, { children: [
13
16
  !isLoaded && /* @__PURE__ */ jsx(
14
17
  Box,
@@ -2677,9 +2677,6 @@ var definitions = {
2677
2677
  {
2678
2678
  $ref: "#/definitions/ProteusHeading"
2679
2679
  },
2680
- {
2681
- $ref: "#/definitions/ProteusIcon"
2682
- },
2683
2680
  {
2684
2681
  $ref: "#/definitions/ProteusIconCalendar"
2685
2682
  },
@@ -2775,6 +2772,9 @@ var definitions = {
2775
2772
  },
2776
2773
  url: {
2777
2774
  anyOf: [
2775
+ {
2776
+ $ref: "#/definitions/ProteusMap"
2777
+ },
2778
2778
  {
2779
2779
  $ref: "#/definitions/ProteusValue"
2780
2780
  },
@@ -2782,7 +2782,7 @@ var definitions = {
2782
2782
  type: "string"
2783
2783
  }
2784
2784
  ],
2785
- description: "URL to download"
2785
+ description: "URL to download, or a Map expression resolving to multiple URLs"
2786
2786
  }
2787
2787
  },
2788
2788
  required: [
@@ -5292,203 +5292,6 @@ var definitions = {
5292
5292
  ],
5293
5293
  type: "object"
5294
5294
  },
5295
- ProteusIcon: {
5296
- additionalProperties: false,
5297
- properties: {
5298
- $type: {
5299
- "const": "Icon"
5300
- },
5301
- alignItems: {
5302
- $ref: "#/definitions/SprinkleProp_alignItems"
5303
- },
5304
- alignSelf: {
5305
- $ref: "#/definitions/SprinkleProp_alignSelf"
5306
- },
5307
- animation: {
5308
- $ref: "#/definitions/SprinkleProp_animation"
5309
- },
5310
- backgroundImage: {
5311
- $ref: "#/definitions/SprinkleProp_backgroundImage"
5312
- },
5313
- bg: {
5314
- $ref: "#/definitions/SprinkleProp_bg"
5315
- },
5316
- border: {
5317
- $ref: "#/definitions/SprinkleProp_border"
5318
- },
5319
- borderB: {
5320
- $ref: "#/definitions/SprinkleProp_borderB"
5321
- },
5322
- borderColor: {
5323
- $ref: "#/definitions/SprinkleProp_borderColor"
5324
- },
5325
- borderL: {
5326
- $ref: "#/definitions/SprinkleProp_borderL"
5327
- },
5328
- borderR: {
5329
- $ref: "#/definitions/SprinkleProp_borderR"
5330
- },
5331
- borderT: {
5332
- $ref: "#/definitions/SprinkleProp_borderT"
5333
- },
5334
- color: {
5335
- $ref: "#/definitions/SprinkleProp_color"
5336
- },
5337
- cursor: {
5338
- $ref: "#/definitions/SprinkleProp_cursor"
5339
- },
5340
- display: {
5341
- $ref: "#/definitions/SprinkleProp_display"
5342
- },
5343
- flex: {
5344
- $ref: "#/definitions/SprinkleProp_flex"
5345
- },
5346
- flexDirection: {
5347
- $ref: "#/definitions/SprinkleProp_flexDirection"
5348
- },
5349
- flexWrap: {
5350
- $ref: "#/definitions/SprinkleProp_flexWrap"
5351
- },
5352
- fontFamily: {
5353
- $ref: "#/definitions/SprinkleProp_fontFamily"
5354
- },
5355
- fontSize: {
5356
- $ref: "#/definitions/SprinkleProp_fontSize"
5357
- },
5358
- fontWeight: {
5359
- $ref: "#/definitions/SprinkleProp_fontWeight"
5360
- },
5361
- gap: {
5362
- $ref: "#/definitions/SprinkleProp_gap"
5363
- },
5364
- gridAutoRows: {
5365
- $ref: "#/definitions/SprinkleProp_gridAutoRows"
5366
- },
5367
- gridColumn: {
5368
- $ref: "#/definitions/SprinkleProp_gridColumn"
5369
- },
5370
- gridTemplateColumns: {
5371
- $ref: "#/definitions/SprinkleProp_gridTemplateColumns"
5372
- },
5373
- h: {
5374
- $ref: "#/definitions/SprinkleProp_h"
5375
- },
5376
- justifyContent: {
5377
- $ref: "#/definitions/SprinkleProp_justifyContent"
5378
- },
5379
- justifyItems: {
5380
- $ref: "#/definitions/SprinkleProp_justifyItems"
5381
- },
5382
- m: {
5383
- $ref: "#/definitions/SprinkleProp_m"
5384
- },
5385
- maxH: {
5386
- $ref: "#/definitions/SprinkleProp_maxH"
5387
- },
5388
- maxW: {
5389
- $ref: "#/definitions/SprinkleProp_maxW"
5390
- },
5391
- mb: {
5392
- $ref: "#/definitions/SprinkleProp_mb"
5393
- },
5394
- ml: {
5395
- $ref: "#/definitions/SprinkleProp_ml"
5396
- },
5397
- mr: {
5398
- $ref: "#/definitions/SprinkleProp_mr"
5399
- },
5400
- mt: {
5401
- $ref: "#/definitions/SprinkleProp_mt"
5402
- },
5403
- mx: {
5404
- $ref: "#/definitions/SprinkleProp_mx"
5405
- },
5406
- my: {
5407
- $ref: "#/definitions/SprinkleProp_my"
5408
- },
5409
- objectFit: {
5410
- $ref: "#/definitions/SprinkleProp_objectFit"
5411
- },
5412
- overflow: {
5413
- $ref: "#/definitions/SprinkleProp_overflow"
5414
- },
5415
- overflowX: {
5416
- $ref: "#/definitions/SprinkleProp_overflowX"
5417
- },
5418
- overflowY: {
5419
- $ref: "#/definitions/SprinkleProp_overflowY"
5420
- },
5421
- p: {
5422
- $ref: "#/definitions/SprinkleProp_p"
5423
- },
5424
- pb: {
5425
- $ref: "#/definitions/SprinkleProp_pb"
5426
- },
5427
- pl: {
5428
- $ref: "#/definitions/SprinkleProp_pl"
5429
- },
5430
- placeItems: {
5431
- $ref: "#/definitions/SprinkleProp_placeItems"
5432
- },
5433
- pointerEvents: {
5434
- $ref: "#/definitions/SprinkleProp_pointerEvents"
5435
- },
5436
- pr: {
5437
- $ref: "#/definitions/SprinkleProp_pr"
5438
- },
5439
- pt: {
5440
- $ref: "#/definitions/SprinkleProp_pt"
5441
- },
5442
- px: {
5443
- $ref: "#/definitions/SprinkleProp_px"
5444
- },
5445
- py: {
5446
- $ref: "#/definitions/SprinkleProp_py"
5447
- },
5448
- rounded: {
5449
- $ref: "#/definitions/SprinkleProp_rounded"
5450
- },
5451
- shadow: {
5452
- $ref: "#/definitions/SprinkleProp_shadow"
5453
- },
5454
- size: {
5455
- $ref: "#/definitions/SprinkleProp_size"
5456
- },
5457
- textAlign: {
5458
- $ref: "#/definitions/SprinkleProp_textAlign"
5459
- },
5460
- textTransform: {
5461
- $ref: "#/definitions/SprinkleProp_textTransform"
5462
- },
5463
- transition: {
5464
- $ref: "#/definitions/SprinkleProp_transition"
5465
- },
5466
- w: {
5467
- $ref: "#/definitions/SprinkleProp_w"
5468
- },
5469
- whiteSpace: {
5470
- $ref: "#/definitions/SprinkleProp_whiteSpace"
5471
- },
5472
- z: {
5473
- $ref: "#/definitions/SprinkleProp_z"
5474
- },
5475
- src: {
5476
- anyOf: [
5477
- {
5478
- $ref: "#/definitions/ProteusValue"
5479
- },
5480
- {
5481
- type: "string"
5482
- }
5483
- ],
5484
- description: "The icon source URL"
5485
- }
5486
- },
5487
- required: [
5488
- "$type"
5489
- ],
5490
- type: "object"
5491
- },
5492
5295
  ProteusIconCalendar: {
5493
5296
  additionalProperties: false,
5494
5297
  properties: {
@@ -2666,9 +2666,6 @@ var definitions = {
2666
2666
  {
2667
2667
  $ref: "#/definitions/ProteusHeading"
2668
2668
  },
2669
- {
2670
- $ref: "#/definitions/ProteusIcon"
2671
- },
2672
2669
  {
2673
2670
  $ref: "#/definitions/ProteusIconCalendar"
2674
2671
  },
@@ -2761,6 +2758,9 @@ var definitions = {
2761
2758
  },
2762
2759
  url: {
2763
2760
  anyOf: [
2761
+ {
2762
+ $ref: "#/definitions/ProteusMap"
2763
+ },
2764
2764
  {
2765
2765
  $ref: "#/definitions/ProteusValue"
2766
2766
  },
@@ -2768,7 +2768,7 @@ var definitions = {
2768
2768
  type: "string"
2769
2769
  }
2770
2770
  ],
2771
- description: "URL to download"
2771
+ description: "URL to download, or a Map expression resolving to multiple URLs"
2772
2772
  }
2773
2773
  },
2774
2774
  required: [
@@ -5261,202 +5261,6 @@ var definitions = {
5261
5261
  ],
5262
5262
  type: "object"
5263
5263
  },
5264
- ProteusIcon: {
5265
- properties: {
5266
- $type: {
5267
- "const": "Icon"
5268
- },
5269
- alignItems: {
5270
- $ref: "#/definitions/SprinkleProp_alignItems"
5271
- },
5272
- alignSelf: {
5273
- $ref: "#/definitions/SprinkleProp_alignSelf"
5274
- },
5275
- animation: {
5276
- $ref: "#/definitions/SprinkleProp_animation"
5277
- },
5278
- backgroundImage: {
5279
- $ref: "#/definitions/SprinkleProp_backgroundImage"
5280
- },
5281
- bg: {
5282
- $ref: "#/definitions/SprinkleProp_bg"
5283
- },
5284
- border: {
5285
- $ref: "#/definitions/SprinkleProp_border"
5286
- },
5287
- borderB: {
5288
- $ref: "#/definitions/SprinkleProp_borderB"
5289
- },
5290
- borderColor: {
5291
- $ref: "#/definitions/SprinkleProp_borderColor"
5292
- },
5293
- borderL: {
5294
- $ref: "#/definitions/SprinkleProp_borderL"
5295
- },
5296
- borderR: {
5297
- $ref: "#/definitions/SprinkleProp_borderR"
5298
- },
5299
- borderT: {
5300
- $ref: "#/definitions/SprinkleProp_borderT"
5301
- },
5302
- color: {
5303
- $ref: "#/definitions/SprinkleProp_color"
5304
- },
5305
- cursor: {
5306
- $ref: "#/definitions/SprinkleProp_cursor"
5307
- },
5308
- display: {
5309
- $ref: "#/definitions/SprinkleProp_display"
5310
- },
5311
- flex: {
5312
- $ref: "#/definitions/SprinkleProp_flex"
5313
- },
5314
- flexDirection: {
5315
- $ref: "#/definitions/SprinkleProp_flexDirection"
5316
- },
5317
- flexWrap: {
5318
- $ref: "#/definitions/SprinkleProp_flexWrap"
5319
- },
5320
- fontFamily: {
5321
- $ref: "#/definitions/SprinkleProp_fontFamily"
5322
- },
5323
- fontSize: {
5324
- $ref: "#/definitions/SprinkleProp_fontSize"
5325
- },
5326
- fontWeight: {
5327
- $ref: "#/definitions/SprinkleProp_fontWeight"
5328
- },
5329
- gap: {
5330
- $ref: "#/definitions/SprinkleProp_gap"
5331
- },
5332
- gridAutoRows: {
5333
- $ref: "#/definitions/SprinkleProp_gridAutoRows"
5334
- },
5335
- gridColumn: {
5336
- $ref: "#/definitions/SprinkleProp_gridColumn"
5337
- },
5338
- gridTemplateColumns: {
5339
- $ref: "#/definitions/SprinkleProp_gridTemplateColumns"
5340
- },
5341
- h: {
5342
- $ref: "#/definitions/SprinkleProp_h"
5343
- },
5344
- justifyContent: {
5345
- $ref: "#/definitions/SprinkleProp_justifyContent"
5346
- },
5347
- justifyItems: {
5348
- $ref: "#/definitions/SprinkleProp_justifyItems"
5349
- },
5350
- m: {
5351
- $ref: "#/definitions/SprinkleProp_m"
5352
- },
5353
- maxH: {
5354
- $ref: "#/definitions/SprinkleProp_maxH"
5355
- },
5356
- maxW: {
5357
- $ref: "#/definitions/SprinkleProp_maxW"
5358
- },
5359
- mb: {
5360
- $ref: "#/definitions/SprinkleProp_mb"
5361
- },
5362
- ml: {
5363
- $ref: "#/definitions/SprinkleProp_ml"
5364
- },
5365
- mr: {
5366
- $ref: "#/definitions/SprinkleProp_mr"
5367
- },
5368
- mt: {
5369
- $ref: "#/definitions/SprinkleProp_mt"
5370
- },
5371
- mx: {
5372
- $ref: "#/definitions/SprinkleProp_mx"
5373
- },
5374
- my: {
5375
- $ref: "#/definitions/SprinkleProp_my"
5376
- },
5377
- objectFit: {
5378
- $ref: "#/definitions/SprinkleProp_objectFit"
5379
- },
5380
- overflow: {
5381
- $ref: "#/definitions/SprinkleProp_overflow"
5382
- },
5383
- overflowX: {
5384
- $ref: "#/definitions/SprinkleProp_overflowX"
5385
- },
5386
- overflowY: {
5387
- $ref: "#/definitions/SprinkleProp_overflowY"
5388
- },
5389
- p: {
5390
- $ref: "#/definitions/SprinkleProp_p"
5391
- },
5392
- pb: {
5393
- $ref: "#/definitions/SprinkleProp_pb"
5394
- },
5395
- pl: {
5396
- $ref: "#/definitions/SprinkleProp_pl"
5397
- },
5398
- placeItems: {
5399
- $ref: "#/definitions/SprinkleProp_placeItems"
5400
- },
5401
- pointerEvents: {
5402
- $ref: "#/definitions/SprinkleProp_pointerEvents"
5403
- },
5404
- pr: {
5405
- $ref: "#/definitions/SprinkleProp_pr"
5406
- },
5407
- pt: {
5408
- $ref: "#/definitions/SprinkleProp_pt"
5409
- },
5410
- px: {
5411
- $ref: "#/definitions/SprinkleProp_px"
5412
- },
5413
- py: {
5414
- $ref: "#/definitions/SprinkleProp_py"
5415
- },
5416
- rounded: {
5417
- $ref: "#/definitions/SprinkleProp_rounded"
5418
- },
5419
- shadow: {
5420
- $ref: "#/definitions/SprinkleProp_shadow"
5421
- },
5422
- size: {
5423
- $ref: "#/definitions/SprinkleProp_size"
5424
- },
5425
- textAlign: {
5426
- $ref: "#/definitions/SprinkleProp_textAlign"
5427
- },
5428
- textTransform: {
5429
- $ref: "#/definitions/SprinkleProp_textTransform"
5430
- },
5431
- transition: {
5432
- $ref: "#/definitions/SprinkleProp_transition"
5433
- },
5434
- w: {
5435
- $ref: "#/definitions/SprinkleProp_w"
5436
- },
5437
- whiteSpace: {
5438
- $ref: "#/definitions/SprinkleProp_whiteSpace"
5439
- },
5440
- z: {
5441
- $ref: "#/definitions/SprinkleProp_z"
5442
- },
5443
- src: {
5444
- anyOf: [
5445
- {
5446
- $ref: "#/definitions/ProteusValue"
5447
- },
5448
- {
5449
- type: "string"
5450
- }
5451
- ],
5452
- description: "The icon source URL"
5453
- }
5454
- },
5455
- required: [
5456
- "$type"
5457
- ],
5458
- type: "object"
5459
- },
5460
5264
  ProteusIconCalendar: {
5461
5265
  properties: {
5462
5266
  $type: {
package/dist/index.d.ts CHANGED
@@ -222,7 +222,7 @@ type ProteusEventHandler = {
222
222
  action: "download";
223
223
  url: (ProteusValueProps & {
224
224
  $type: "Value";
225
- }) | string;
225
+ }) | string | string[];
226
226
  } | {
227
227
  action: "message-from";
228
228
  path: string;