jazz-tools 0.17.12 → 0.17.14

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 (38) hide show
  1. package/.turbo/turbo-build.log +38 -38
  2. package/CHANGELOG.md +23 -0
  3. package/dist/{chunk-SFP5PBPX.js → chunk-LZOF6WP5.js} +25 -3
  4. package/dist/{chunk-SFP5PBPX.js.map → chunk-LZOF6WP5.js.map} +1 -1
  5. package/dist/expo/auth/clerk/index.d.ts.map +1 -1
  6. package/dist/expo/index.js +6 -2
  7. package/dist/expo/index.js.map +1 -1
  8. package/dist/index.js +4 -2
  9. package/dist/index.js.map +1 -1
  10. package/dist/inspector/{custom-element-I7L56H6B.js → custom-element-ZSNTCECD.js} +50 -9
  11. package/dist/inspector/{custom-element-I7L56H6B.js.map → custom-element-ZSNTCECD.js.map} +1 -1
  12. package/dist/inspector/index.js +49 -8
  13. package/dist/inspector/index.js.map +1 -1
  14. package/dist/inspector/register-custom-element.js +1 -1
  15. package/dist/inspector/viewer/page.d.ts.map +1 -1
  16. package/dist/inspector/viewer/table-viewer.d.ts +2 -1
  17. package/dist/inspector/viewer/table-viewer.d.ts.map +1 -1
  18. package/dist/react/auth/Clerk.d.ts.map +1 -1
  19. package/dist/react/index.js +6 -2
  20. package/dist/react/index.js.map +1 -1
  21. package/dist/testing.js +1 -1
  22. package/dist/tools/auth/clerk/index.d.ts +2 -1
  23. package/dist/tools/auth/clerk/index.d.ts.map +1 -1
  24. package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
  25. package/package.json +5 -5
  26. package/src/expo/auth/clerk/index.tsx +6 -2
  27. package/src/inspector/viewer/page.tsx +30 -2
  28. package/src/inspector/viewer/table-viewer.tsx +26 -1
  29. package/src/react/auth/Clerk.tsx +6 -2
  30. package/src/react-core/tests/useCoState.test.ts +1 -1
  31. package/src/tools/auth/clerk/index.ts +2 -0
  32. package/src/tools/auth/clerk/tests/JazzClerkAuth.test.ts +56 -6
  33. package/src/tools/implementation/zodSchema/zodCo.ts +45 -8
  34. package/src/tools/tests/account.test.ts +15 -5
  35. package/src/tools/tests/coMap.test.ts +18 -6
  36. package/src/tools/tests/exportImport.test.ts +6 -6
  37. package/src/tools/tests/load.test.ts +6 -4
  38. package/src/tools/tests/subscribe.test.ts +10 -6
@@ -1348,7 +1348,8 @@ var PaginationContainer = styled13("div")`
1348
1348
  function CoValuesTableView({
1349
1349
  data,
1350
1350
  node,
1351
- onNavigate
1351
+ onNavigate,
1352
+ onRemove
1352
1353
  }) {
1353
1354
  const [visibleRowsCount, setVisibleRowsCount] = useState6(10);
1354
1355
  const [coIdArray, visibleRows] = useMemo(() => {
@@ -1372,7 +1373,10 @@ function CoValuesTableView({
1372
1373
  };
1373
1374
  return /* @__PURE__ */ jsxs12(Fragment8, { children: [
1374
1375
  /* @__PURE__ */ jsxs12(Table, { children: [
1375
- /* @__PURE__ */ jsx22(TableHead, { children: /* @__PURE__ */ jsx22(TableRow, { children: [...keys, "Action"].map((key) => /* @__PURE__ */ jsx22(TableHeader, { children: key }, key)) }) }),
1376
+ /* @__PURE__ */ jsx22(TableHead, { children: /* @__PURE__ */ jsxs12(TableRow, { children: [
1377
+ [...keys, "Action"].map((key) => /* @__PURE__ */ jsx22(TableHeader, { children: key }, key)),
1378
+ onRemove && /* @__PURE__ */ jsx22(TableHeader, {})
1379
+ ] }) }),
1376
1380
  /* @__PURE__ */ jsx22(TableBody, { children: resolvedRows.slice(0, visibleRowsCount).map((item, index) => /* @__PURE__ */ jsxs12(TableRow, { children: [
1377
1381
  keys.map((key) => /* @__PURE__ */ jsx22(TableCell, { children: /* @__PURE__ */ jsx22(
1378
1382
  ValueRenderer,
@@ -1407,7 +1411,8 @@ function CoValuesTableView({
1407
1411
  ]),
1408
1412
  children: "View"
1409
1413
  }
1410
- ) })
1414
+ ) }),
1415
+ onRemove && /* @__PURE__ */ jsx22(TableCell, { children: /* @__PURE__ */ jsx22(Button, { variant: "secondary", onClick: () => onRemove(index), children: "Remove" }) })
1411
1416
  ] }, index)) })
1412
1417
  ] }),
1413
1418
  /* @__PURE__ */ jsxs12(PaginationContainer, { children: [
@@ -1425,22 +1430,33 @@ function CoValuesTableView({
1425
1430
  function TableView({
1426
1431
  data,
1427
1432
  node,
1428
- onNavigate
1433
+ onNavigate,
1434
+ onRemove
1429
1435
  }) {
1430
1436
  const isListOfCoValues = useMemo(() => {
1431
1437
  return Array.isArray(data) && data.every((k) => isCoId(k));
1432
1438
  }, [data]);
1433
1439
  if (isListOfCoValues) {
1434
- return /* @__PURE__ */ jsx22(CoValuesTableView, { data, node, onNavigate });
1440
+ return /* @__PURE__ */ jsx22(
1441
+ CoValuesTableView,
1442
+ {
1443
+ data,
1444
+ node,
1445
+ onNavigate,
1446
+ onRemove
1447
+ }
1448
+ );
1435
1449
  }
1436
1450
  return /* @__PURE__ */ jsxs12(Table, { children: [
1437
1451
  /* @__PURE__ */ jsx22(TableHead, { children: /* @__PURE__ */ jsxs12(TableRow, { children: [
1438
1452
  /* @__PURE__ */ jsx22(TableHeader, { style: { width: "5rem" }, children: "Index" }),
1439
- /* @__PURE__ */ jsx22(TableHeader, { children: "Value" })
1453
+ /* @__PURE__ */ jsx22(TableHeader, { children: "Value" }),
1454
+ onRemove && /* @__PURE__ */ jsx22(TableHeader, { children: "Action" })
1440
1455
  ] }) }),
1441
1456
  /* @__PURE__ */ jsx22(TableBody, { children: Array.isArray(data) && data?.map((value, index) => /* @__PURE__ */ jsxs12(TableRow, { children: [
1442
1457
  /* @__PURE__ */ jsx22(TableCell, { children: /* @__PURE__ */ jsx22(Text, { mono: true, children: index }) }),
1443
- /* @__PURE__ */ jsx22(TableCell, { children: /* @__PURE__ */ jsx22(ValueRenderer, { json: value }) })
1458
+ /* @__PURE__ */ jsx22(TableCell, { children: /* @__PURE__ */ jsx22(ValueRenderer, { json: value }) }),
1459
+ onRemove && /* @__PURE__ */ jsx22(TableCell, { children: /* @__PURE__ */ jsx22(Button, { variant: "secondary", onClick: () => onRemove(index), children: "Remove" }) })
1444
1460
  ] }, index)) })
1445
1461
  ] });
1446
1462
  }
@@ -1494,6 +1510,14 @@ var ContentContainer = styled14("div")`
1494
1510
  gap: 1rem;
1495
1511
  padding-bottom: 2rem;
1496
1512
  `;
1513
+ function canEdit(value) {
1514
+ try {
1515
+ const myRole = value.group.myRole();
1516
+ return myRole === "writer" || myRole === "admin";
1517
+ } catch (e) {
1518
+ return false;
1519
+ }
1520
+ }
1497
1521
  function View(props) {
1498
1522
  const { type, extendedType } = props.coValue;
1499
1523
  const { snapshot, value } = props.coValue;
@@ -1519,7 +1543,24 @@ function View(props) {
1519
1543
  if (type === "coplaintext") {
1520
1544
  return /* @__PURE__ */ jsx23(CoPlainTextView, { data: snapshot });
1521
1545
  }
1522
- if (type === "colist" || extendedType === "record") {
1546
+ if (type === "colist") {
1547
+ const handleRemove = (index) => {
1548
+ if (confirm("Are you sure you want to remove this item?")) {
1549
+ const list = value;
1550
+ list.delete(index);
1551
+ }
1552
+ };
1553
+ return /* @__PURE__ */ jsx23(
1554
+ TableView,
1555
+ {
1556
+ data: snapshot,
1557
+ node,
1558
+ onNavigate,
1559
+ onRemove: canEdit(value) ? handleRemove : void 0
1560
+ }
1561
+ );
1562
+ }
1563
+ if (extendedType === "record") {
1523
1564
  return /* @__PURE__ */ jsx23(TableView, { data: snapshot, node, onNavigate });
1524
1565
  }
1525
1566
  return /* @__PURE__ */ jsx23(GridView, { data: snapshot, onNavigate, node });