@sanity/assist 4.3.0 → 4.3.2
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/README.md +173 -163
- package/dist/index.d.mts +17 -2
- package/dist/index.d.ts +17 -2
- package/dist/index.esm.js +10 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/fieldActions/customFieldActions.tsx +26 -10
- package/src/helpers/misc.ts +4 -0
- package/src/helpers/typeUtils.ts +6 -0
- package/src/index.ts +2 -0
- package/src/plugin.tsx +4 -1
package/dist/index.js
CHANGED
|
@@ -204,6 +204,9 @@ function getPathKey(path) {
|
|
|
204
204
|
function getInstructionTitle(instruction2) {
|
|
205
205
|
return instruction2?.title ?? "Untitled";
|
|
206
206
|
}
|
|
207
|
+
function isDefined(t) {
|
|
208
|
+
return t != null;
|
|
209
|
+
}
|
|
207
210
|
function isPortableTextArray(type) {
|
|
208
211
|
return type.of.find((t) => isType(t, "block"));
|
|
209
212
|
}
|
|
@@ -2863,12 +2866,12 @@ function useCustomFieldActions(props) {
|
|
|
2863
2866
|
path: props.path
|
|
2864
2867
|
});
|
|
2865
2868
|
return react.useMemo(() => {
|
|
2866
|
-
const title = fieldActions?.title, customActions = configActions?.map((node) => createSafeNode({
|
|
2869
|
+
const title = fieldActions?.title, customActions = configActions?.filter(isDefined).map((node) => createSafeNode({
|
|
2867
2870
|
node,
|
|
2868
2871
|
pushToast,
|
|
2869
2872
|
addSyntheticTask,
|
|
2870
2873
|
removeSyntheticTask
|
|
2871
|
-
})), onlyGroups = customActions?.length && customActions?.every((node) => node.type === "group");
|
|
2874
|
+
})).filter(isDefined), onlyGroups = customActions?.length && customActions?.every((node) => node.type === "group");
|
|
2872
2875
|
return (customActions?.length ? onlyGroups ? customActions : [
|
|
2873
2876
|
{
|
|
2874
2877
|
type: "group",
|
|
@@ -2885,12 +2888,13 @@ function createSafeNode(args) {
|
|
|
2885
2888
|
case "action":
|
|
2886
2889
|
return createSafeAction({ ...args, action: node });
|
|
2887
2890
|
case "group":
|
|
2888
|
-
|
|
2891
|
+
const children = node.children?.filter(isDefined).map((child) => createSafeNode({ ...args, node: child })).filter(isDefined);
|
|
2892
|
+
return children?.length ? {
|
|
2889
2893
|
...node,
|
|
2890
2894
|
renderAsButton: !1,
|
|
2891
2895
|
expanded: !0,
|
|
2892
|
-
children
|
|
2893
|
-
};
|
|
2896
|
+
children
|
|
2897
|
+
} : void 0;
|
|
2894
2898
|
case "divider":
|
|
2895
2899
|
default:
|
|
2896
2900
|
return node;
|
|
@@ -4228,5 +4232,6 @@ exports.defaultLanguageOutputs = defaultLanguageOutputs;
|
|
|
4228
4232
|
exports.defineAssistFieldAction = defineAssistFieldAction;
|
|
4229
4233
|
exports.defineAssistFieldActionGroup = defineAssistFieldActionGroup;
|
|
4230
4234
|
exports.defineFieldActionDivider = defineFieldActionDivider;
|
|
4235
|
+
exports.isType = isType;
|
|
4231
4236
|
exports.useUserInput = useUserInput;
|
|
4232
4237
|
//# sourceMappingURL=index.js.map
|