@sanity/personalization-plugin 2.2.0-launch-darkly.1 → 2.3.0-launch-darkly.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/personalization-plugin",
3
- "version": "2.2.0-launch-darkly.1",
3
+ "version": "2.3.0-launch-darkly.1",
4
4
  "description": "Plugin to help with personalization, a/b testing when using Sanity",
5
5
  "keywords": [
6
6
  "sanity",
@@ -79,7 +79,7 @@
79
79
  "typescript": "^5.7.3"
80
80
  },
81
81
  "peerDependencies": {
82
- "react": "^18",
82
+ "react": "^18 || ^19",
83
83
  "sanity": "^3"
84
84
  },
85
85
  "engines": {
@@ -1,3 +1,4 @@
1
+ import {Card, Text} from '@sanity/ui'
1
2
  import {FormEvent, useCallback, useMemo} from 'react'
2
3
  import {
3
4
  FormPatch,
@@ -20,7 +21,9 @@ const formatlistOptions = (experiments: ExperimentType[]): SelectOption[] =>
20
21
  value: experiment.id,
21
22
  }))
22
23
 
23
- export const ExperimentInput = (props: StringInputProps & {variantNameOverride: string}) => {
24
+ export const ExperimentInput = (
25
+ props: StringInputProps & {variantNameOverride: string; experimentNameOverride: string},
26
+ ) => {
24
27
  const {experiments} = useExperimentContext()
25
28
 
26
29
  const id = useFormValue(['_id']) as string
@@ -56,7 +59,14 @@ export const ExperimentInput = (props: StringInputProps & {variantNameOverride:
56
59
  [patch, subValues, aditionalChangePath],
57
60
  )
58
61
 
59
- if (!experiments.length) return <></>
62
+ if (!experiments.length)
63
+ return (
64
+ <Card padding={[3, 3, 4]} radius={2} shadow={1} tone="caution">
65
+ <Text align="center" size={[2, 2, 3]}>
66
+ There are no defined {props.experimentNameOverride}s
67
+ </Text>
68
+ </Card>
69
+ )
60
70
 
61
71
  return (
62
72
  <Select {...props} listOptions={formatlistOptions(experiments)} handleChange={handleChange} />
@@ -69,7 +69,11 @@ const createExperimentType = ({
69
69
  type: 'string',
70
70
  components: {
71
71
  input: (props) => (
72
- <ExperimentInput {...props} variantNameOverride={variantNameOverride} />
72
+ <ExperimentInput
73
+ {...props}
74
+ experimentNameOverride={experimentNameOverride}
75
+ variantNameOverride={variantNameOverride}
76
+ />
73
77
  ),
74
78
  },
75
79
  hidden: ({parent}) => {
@@ -41,7 +41,7 @@ export const getExperiments = async ({
41
41
  label: flag.name,
42
42
  variants: flag.variations.map((variation) => ({
43
43
  id: variation.value,
44
- label: variation.name,
44
+ label: variation.name ?? variation.value,
45
45
  })),
46
46
  }))
47
47
  featureExperiments.push(...experiments)