@chaibuilder/sdk 2.0.0-beta.90 → 2.0.0-beta.91
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.
- package/dist/core.cjs +16 -19
- package/dist/core.js +16 -19
- package/package.json +1 -1
package/dist/core.cjs
CHANGED
|
@@ -1248,33 +1248,30 @@ const useRemoveBlocks = () => {
|
|
|
1248
1248
|
[presentBlocks, setSelectedIds, ids2]
|
|
1249
1249
|
);
|
|
1250
1250
|
};
|
|
1251
|
+
const writeAtomValue = jotai.atom(
|
|
1252
|
+
null,
|
|
1253
|
+
// it's a convention to pass `null` for the first argument
|
|
1254
|
+
(get, set, { id, props }) => {
|
|
1255
|
+
const blockAsAtoms = get(pageBlocksAtom);
|
|
1256
|
+
console.log("From Atom callback", blockAsAtoms);
|
|
1257
|
+
const blockAtom = lodashEs.find(blockAsAtoms, (b) => b._id === id);
|
|
1258
|
+
if (!blockAtom) {
|
|
1259
|
+
throw new Error(`Block with id ${id} not found`);
|
|
1260
|
+
}
|
|
1261
|
+
return set(blockAtom._atom, { ...get(blockAtom._atom), ...props });
|
|
1262
|
+
}
|
|
1263
|
+
);
|
|
1251
1264
|
const useUpdateBlockAtom = () => {
|
|
1252
|
-
|
|
1253
|
-
console.log("Default Blocks: ", blocks);
|
|
1254
|
-
return useAtomCallback(
|
|
1255
|
-
React.useCallback(
|
|
1256
|
-
(get, set, { id, props }) => {
|
|
1257
|
-
const blockAsAtoms = get(pageBlocksAtom);
|
|
1258
|
-
console.log("From Atom callback", blocks);
|
|
1259
|
-
const blockAtom = lodashEs.find(blockAsAtoms, (b) => b._id === id);
|
|
1260
|
-
if (!blockAtom) {
|
|
1261
|
-
console.warn(`Block with id ${id} not found`);
|
|
1262
|
-
return;
|
|
1263
|
-
}
|
|
1264
|
-
return set(blockAtom._atom, { ...get(blockAtom._atom), ...props });
|
|
1265
|
-
},
|
|
1266
|
-
[pageBlocksAtom]
|
|
1267
|
-
)
|
|
1268
|
-
);
|
|
1265
|
+
return jotai.useSetAtom(writeAtomValue);
|
|
1269
1266
|
};
|
|
1270
1267
|
const useGetBlockAtomValue = () => {
|
|
1271
1268
|
return useAtomCallback(
|
|
1272
1269
|
React.useCallback((get, _set, id) => {
|
|
1273
1270
|
const blockAsAtoms = get(pageBlocksAtom);
|
|
1271
|
+
console.log("Block As Atoms", blockAsAtoms);
|
|
1274
1272
|
const blockAtom = lodashEs.find(blockAsAtoms, (b) => b._id === id);
|
|
1275
1273
|
if (!blockAtom) {
|
|
1276
|
-
|
|
1277
|
-
return;
|
|
1274
|
+
throw new Error(`Block with id ${id} not found`);
|
|
1278
1275
|
}
|
|
1279
1276
|
return get(blockAtom._atom);
|
|
1280
1277
|
}, [])
|
package/dist/core.js
CHANGED
|
@@ -1233,33 +1233,30 @@ const useRemoveBlocks = () => {
|
|
|
1233
1233
|
[presentBlocks, setSelectedIds, ids2]
|
|
1234
1234
|
);
|
|
1235
1235
|
};
|
|
1236
|
+
const writeAtomValue = atom$1(
|
|
1237
|
+
null,
|
|
1238
|
+
// it's a convention to pass `null` for the first argument
|
|
1239
|
+
(get2, set2, { id, props }) => {
|
|
1240
|
+
const blockAsAtoms = get2(pageBlocksAtom);
|
|
1241
|
+
console.log("From Atom callback", blockAsAtoms);
|
|
1242
|
+
const blockAtom = find(blockAsAtoms, (b) => b._id === id);
|
|
1243
|
+
if (!blockAtom) {
|
|
1244
|
+
throw new Error(`Block with id ${id} not found`);
|
|
1245
|
+
}
|
|
1246
|
+
return set2(blockAtom._atom, { ...get2(blockAtom._atom), ...props });
|
|
1247
|
+
}
|
|
1248
|
+
);
|
|
1236
1249
|
const useUpdateBlockAtom = () => {
|
|
1237
|
-
|
|
1238
|
-
console.log("Default Blocks: ", blocks);
|
|
1239
|
-
return useAtomCallback(
|
|
1240
|
-
useCallback(
|
|
1241
|
-
(get2, set2, { id, props }) => {
|
|
1242
|
-
const blockAsAtoms = get2(pageBlocksAtom);
|
|
1243
|
-
console.log("From Atom callback", blocks);
|
|
1244
|
-
const blockAtom = find(blockAsAtoms, (b) => b._id === id);
|
|
1245
|
-
if (!blockAtom) {
|
|
1246
|
-
console.warn(`Block with id ${id} not found`);
|
|
1247
|
-
return;
|
|
1248
|
-
}
|
|
1249
|
-
return set2(blockAtom._atom, { ...get2(blockAtom._atom), ...props });
|
|
1250
|
-
},
|
|
1251
|
-
[pageBlocksAtom]
|
|
1252
|
-
)
|
|
1253
|
-
);
|
|
1250
|
+
return useSetAtom$1(writeAtomValue);
|
|
1254
1251
|
};
|
|
1255
1252
|
const useGetBlockAtomValue = () => {
|
|
1256
1253
|
return useAtomCallback(
|
|
1257
1254
|
useCallback((get2, _set, id) => {
|
|
1258
1255
|
const blockAsAtoms = get2(pageBlocksAtom);
|
|
1256
|
+
console.log("Block As Atoms", blockAsAtoms);
|
|
1259
1257
|
const blockAtom = find(blockAsAtoms, (b) => b._id === id);
|
|
1260
1258
|
if (!blockAtom) {
|
|
1261
|
-
|
|
1262
|
-
return;
|
|
1259
|
+
throw new Error(`Block with id ${id} not found`);
|
|
1263
1260
|
}
|
|
1264
1261
|
return get2(blockAtom._atom);
|
|
1265
1262
|
}, [])
|