@sanity/personalization-plugin 2.3.0-growthbook.1 → 2.3.0-growthbook.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/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useClient, useWorkspace, useFormValue, defineDocumentFieldAction, set, unset, useDocumentOperation, isReference, isImage, isDocumentSchemaType, definePlugin, isObjectInputProps, defineType, defineField } from "sanity";
|
|
2
|
+
import { useClient, useWorkspace, useFormValue, defineDocumentFieldAction, set, unset, useDocumentOperation, getPublishedId, isReference, isImage, isDocumentSchemaType, definePlugin, isObjectInputProps, defineType, defineField } from "sanity";
|
|
3
3
|
import { Stack, Inline, Button, Select as Select$1, Card, Text } from "@sanity/ui";
|
|
4
4
|
import { uuid } from "@sanity/uuid";
|
|
5
5
|
import { createContext, useMemo, useContext, useCallback, forwardRef, useState, useEffect } from "react";
|
|
@@ -6505,20 +6505,20 @@ const useAddExperimentAction = (props) => {
|
|
|
6505
6505
|
title: experiment.label,
|
|
6506
6506
|
value: experiment.id
|
|
6507
6507
|
})), ExperimentInput = (props) => {
|
|
6508
|
-
const { experiments } = useExperimentContext(), id = useFormValue(["_id"]),
|
|
6508
|
+
const { experiments } = useExperimentContext(), id = useFormValue(["_id"]), additionalChangePath = useMemo(
|
|
6509
6509
|
() => [...props.path.slice(0, -1), `${props.variantNameOverride}s`],
|
|
6510
6510
|
[props.variantNameOverride, props.path]
|
|
6511
|
-
), subValues = useFormValue(
|
|
6511
|
+
), subValues = useFormValue(additionalChangePath), { patch } = useDocumentOperation(getPublishedId(id), props.schemaType.name), handleChange = useCallback(
|
|
6512
6512
|
(event, onChange) => {
|
|
6513
6513
|
const inputValue = event.currentTarget.value;
|
|
6514
6514
|
if (onChange(inputValue ? set(inputValue) : unset()), subValues) {
|
|
6515
6515
|
const patchEvent = {
|
|
6516
|
-
unset: [
|
|
6516
|
+
unset: [additionalChangePath.join(".")]
|
|
6517
6517
|
};
|
|
6518
6518
|
patch.execute([patchEvent]);
|
|
6519
6519
|
}
|
|
6520
6520
|
},
|
|
6521
|
-
[patch, subValues,
|
|
6521
|
+
[patch, subValues, additionalChangePath]
|
|
6522
6522
|
);
|
|
6523
6523
|
return experiments.length ? /* @__PURE__ */ jsx(Select, { ...props, listOptions: formatlistOptions(experiments), handleChange }) : /* @__PURE__ */ jsx(Card, { padding: [3, 3, 4], radius: 2, shadow: 1, tone: "caution", children: /* @__PURE__ */ jsxs(Text, { align: "center", size: [2, 2, 3], children: [
|
|
6524
6524
|
"There are no defined ",
|