@sanity/personalization-plugin 2.1.0-field-names.1 → 2.1.0

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
@@ -6507,6 +6507,14 @@ const useAddExperimentAction = (props) => {
6507
6507
  [patch, subValues, aditionalChangePath]
6508
6508
  );
6509
6509
  return experiments.length ? /* @__PURE__ */ jsx(Select, { ...props, listOptions: formatlistOptions(experiments), handleChange }) : /* @__PURE__ */ jsx(Fragment, {});
6510
+ }, VariantInput = (props) => {
6511
+ const defaultValue = useFormValue([props.path[0], "default"]), handleClick = () => {
6512
+ props.onChange(set(defaultValue, ["value"]));
6513
+ };
6514
+ return /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
6515
+ props.renderDefault(props),
6516
+ /* @__PURE__ */ jsx(Inline, { space: 1, children: /* @__PURE__ */ jsx(Button, { text: "Copy default", mode: "ghost", onClick: () => handleClick() }) })
6517
+ ] });
6510
6518
  }, VariantPreview = (props) => {
6511
6519
  const [subtitle, setSubtitle] = useState(void 0), [title, setTitle] = useState(void 0), [media, setMedia] = useState(void 0), client = useClient({ apiVersion: "2025-01-01" }), { experiments } = useExperimentContext(), { experiment, variant, value } = props, selectedExperiment = experiments.find((experimentItem) => experimentItem.id === experiment), selectedVariant = selectedExperiment?.variants.find((variantItem) => variantItem.id === variant);
6512
6520
  useEffect(() => {
@@ -6639,7 +6647,8 @@ const createExperimentType = ({
6639
6647
  title: `${variantNameOverride} array ${usedName}`,
6640
6648
  type: "object",
6641
6649
  components: {
6642
- preview: VariantPreview
6650
+ preview: VariantPreview,
6651
+ input: VariantInput
6643
6652
  },
6644
6653
  fields: [
6645
6654
  {