jazz-tools 0.17.11 → 0.17.13

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 (32) hide show
  1. package/.turbo/turbo-build.log +38 -38
  2. package/CHANGELOG.md +24 -0
  3. package/dist/expo/auth/clerk/index.d.ts.map +1 -1
  4. package/dist/expo/index.js +6 -2
  5. package/dist/expo/index.js.map +1 -1
  6. package/dist/index.js +3 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/inspector/{custom-element-I7L56H6B.js → custom-element-ZSNTCECD.js} +50 -9
  9. package/dist/inspector/{custom-element-I7L56H6B.js.map → custom-element-ZSNTCECD.js.map} +1 -1
  10. package/dist/inspector/index.js +49 -8
  11. package/dist/inspector/index.js.map +1 -1
  12. package/dist/inspector/register-custom-element.js +1 -1
  13. package/dist/inspector/viewer/page.d.ts.map +1 -1
  14. package/dist/inspector/viewer/table-viewer.d.ts +2 -1
  15. package/dist/inspector/viewer/table-viewer.d.ts.map +1 -1
  16. package/dist/react/auth/Clerk.d.ts.map +1 -1
  17. package/dist/react/index.js +6 -2
  18. package/dist/react/index.js.map +1 -1
  19. package/dist/tools/auth/clerk/index.d.ts +2 -1
  20. package/dist/tools/auth/clerk/index.d.ts.map +1 -1
  21. package/package.json +10 -10
  22. package/src/expo/auth/clerk/index.tsx +6 -2
  23. package/src/inspector/viewer/page.tsx +30 -2
  24. package/src/inspector/viewer/table-viewer.tsx +26 -1
  25. package/src/react/auth/Clerk.tsx +6 -2
  26. package/src/react-core/tests/useCoState.test.ts +1 -1
  27. package/src/tools/auth/clerk/index.ts +2 -0
  28. package/src/tools/auth/clerk/tests/JazzClerkAuth.test.ts +56 -6
  29. package/src/tools/tests/coMap.test.ts +10 -6
  30. package/src/tools/tests/exportImport.test.ts +6 -6
  31. package/src/tools/tests/load.test.ts +6 -4
  32. package/src/tools/tests/subscribe.test.ts +10 -6
@@ -33133,7 +33133,8 @@ var PaginationContainer = styled13("div")`
33133
33133
  function CoValuesTableView({
33134
33134
  data,
33135
33135
  node,
33136
- onNavigate
33136
+ onNavigate,
33137
+ onRemove
33137
33138
  }) {
33138
33139
  const [visibleRowsCount, setVisibleRowsCount] = (0, import_react11.useState)(10);
33139
33140
  const [coIdArray, visibleRows] = (0, import_react11.useMemo)(() => {
@@ -33157,7 +33158,10 @@ function CoValuesTableView({
33157
33158
  };
33158
33159
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
33159
33160
  /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(Table, { children: [
33160
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TableHead, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TableRow, { children: [...keys, "Action"].map((key) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TableHeader, { children: key }, key)) }) }),
33161
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TableHead, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(TableRow, { children: [
33162
+ [...keys, "Action"].map((key) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TableHeader, { children: key }, key)),
33163
+ onRemove && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TableHeader, {})
33164
+ ] }) }),
33161
33165
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TableBody, { children: resolvedRows.slice(0, visibleRowsCount).map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(TableRow, { children: [
33162
33166
  keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TableCell, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
33163
33167
  ValueRenderer,
@@ -33192,7 +33196,8 @@ function CoValuesTableView({
33192
33196
  ]),
33193
33197
  children: "View"
33194
33198
  }
33195
- ) })
33199
+ ) }),
33200
+ onRemove && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TableCell, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Button, { variant: "secondary", onClick: () => onRemove(index), children: "Remove" }) })
33196
33201
  ] }, index)) })
33197
33202
  ] }),
33198
33203
  /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(PaginationContainer, { children: [
@@ -33210,22 +33215,33 @@ function CoValuesTableView({
33210
33215
  function TableView({
33211
33216
  data,
33212
33217
  node,
33213
- onNavigate
33218
+ onNavigate,
33219
+ onRemove
33214
33220
  }) {
33215
33221
  const isListOfCoValues = (0, import_react11.useMemo)(() => {
33216
33222
  return Array.isArray(data) && data.every((k) => isCoId(k));
33217
33223
  }, [data]);
33218
33224
  if (isListOfCoValues) {
33219
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(CoValuesTableView, { data, node, onNavigate });
33225
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
33226
+ CoValuesTableView,
33227
+ {
33228
+ data,
33229
+ node,
33230
+ onNavigate,
33231
+ onRemove
33232
+ }
33233
+ );
33220
33234
  }
33221
33235
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(Table, { children: [
33222
33236
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TableHead, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(TableRow, { children: [
33223
33237
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TableHeader, { style: { width: "5rem" }, children: "Index" }),
33224
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TableHeader, { children: "Value" })
33238
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TableHeader, { children: "Value" }),
33239
+ onRemove && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TableHeader, { children: "Action" })
33225
33240
  ] }) }),
33226
33241
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TableBody, { children: Array.isArray(data) && data?.map((value, index) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(TableRow, { children: [
33227
33242
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TableCell, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Text, { mono: true, children: index }) }),
33228
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TableCell, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ValueRenderer, { json: value }) })
33243
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TableCell, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ValueRenderer, { json: value }) }),
33244
+ onRemove && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TableCell, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Button, { variant: "secondary", onClick: () => onRemove(index), children: "Remove" }) })
33229
33245
  ] }, index)) })
33230
33246
  ] });
33231
33247
  }
@@ -33279,6 +33295,14 @@ var ContentContainer = styled14("div")`
33279
33295
  gap: 1rem;
33280
33296
  padding-bottom: 2rem;
33281
33297
  `;
33298
+ function canEdit(value) {
33299
+ try {
33300
+ const myRole = value.group.myRole();
33301
+ return myRole === "writer" || myRole === "admin";
33302
+ } catch (e) {
33303
+ return false;
33304
+ }
33305
+ }
33282
33306
  function View(props) {
33283
33307
  const { type, extendedType } = props.coValue;
33284
33308
  const { snapshot, value } = props.coValue;
@@ -33304,7 +33328,24 @@ function View(props) {
33304
33328
  if (type === "coplaintext") {
33305
33329
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(CoPlainTextView, { data: snapshot });
33306
33330
  }
33307
- if (type === "colist" || extendedType === "record") {
33331
+ if (type === "colist") {
33332
+ const handleRemove = (index) => {
33333
+ if (confirm("Are you sure you want to remove this item?")) {
33334
+ const list = value;
33335
+ list.delete(index);
33336
+ }
33337
+ };
33338
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
33339
+ TableView,
33340
+ {
33341
+ data: snapshot,
33342
+ node,
33343
+ onNavigate,
33344
+ onRemove: canEdit(value) ? handleRemove : void 0
33345
+ }
33346
+ );
33347
+ }
33348
+ if (extendedType === "record") {
33308
33349
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(TableView, { data: snapshot, node, onNavigate });
33309
33350
  }
33310
33351
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(GridView, { data: snapshot, onNavigate, node });
@@ -33982,4 +34023,4 @@ react/cjs/react-jsx-runtime.development.js:
33982
34023
  * LICENSE file in the root directory of this source tree.
33983
34024
  *)
33984
34025
  */
33985
- //# sourceMappingURL=custom-element-I7L56H6B.js.map
34026
+ //# sourceMappingURL=custom-element-ZSNTCECD.js.map