slice-machine-ui 2.8.1-beta.1 → 2.8.1-beta.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.
Files changed (55) hide show
  1. package/out/404.html +1 -1
  2. package/out/_next/static/9odHTDRwqbGU-9wLdN7o7/_buildManifest.js +1 -0
  3. package/out/_next/static/chunks/150-e3d2b02540447045.js +1 -0
  4. package/out/_next/static/chunks/{183-1298bf7953a6f2a0.js → 183-b1a9f55f45cb8d8e.js} +1 -1
  5. package/out/_next/static/chunks/{18539003-9b393c900c89e552.js → 18539003-c65c99f4e1d8f6a8.js} +3 -3
  6. package/out/_next/static/chunks/{372-cfee53700e416e09.js → 372-295e09136ef6fd8c.js} +1 -1
  7. package/out/_next/static/chunks/{441-76bd8e7cf8cc22da.js → 441-29739f872f8d0039.js} +6 -6
  8. package/out/_next/static/chunks/{627-092c9e4c99442c08.js → 479-6205c85aa978fc0b.js} +2 -2
  9. package/out/_next/static/chunks/50-586dc7ab5e584e76.js +1 -0
  10. package/out/_next/static/chunks/764-e040bcebe6027fea.js +1 -0
  11. package/out/_next/static/chunks/{772-db5f72095641ec1d.js → 772-58d0c8f8ae1c6791.js} +1 -1
  12. package/out/_next/static/chunks/{882-32959ffa63fa455c.js → 882-0286cc56ae67376e.js} +1 -1
  13. package/out/_next/static/chunks/{591-a272f15a4bf9830a.js → 918-38ab72e6ee071fec.js} +2 -2
  14. package/out/_next/static/chunks/pages/{_app-be6b83d484e3ae6f.js → _app-23712efc496c1618.js} +157 -157
  15. package/out/_next/static/chunks/pages/{changelog-86f30b15d852e710.js → changelog-f9055af0d38a0c24.js} +1 -1
  16. package/out/_next/static/chunks/pages/{changes-6c05ef623617785e.js → changes-5f02b3fe08918de1.js} +1 -1
  17. package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-fd2416081ef2ffca.js → [customTypeId]-2eb64c9ea82fcd0a.js} +1 -1
  18. package/out/_next/static/chunks/pages/{custom-types-5de2dd7b9b93236e.js → custom-types-ddc20cfdd8049c04.js} +1 -1
  19. package/out/_next/static/chunks/pages/{index-2d7f95201a656c12.js → index-17f953c11b46cb20.js} +1 -1
  20. package/out/_next/static/chunks/pages/{labs-81cf5c5f09fa0bda.js → labs-867606e5aff179cd.js} +1 -1
  21. package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-59e143620505f73f.js → [pageTypeId]-e5a5e6b345081e0a.js} +1 -1
  22. package/out/_next/static/chunks/pages/settings-80b9910a0643abb5.js +1 -0
  23. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/{simulator-908e779f6d24760d.js → simulator-783b6577bd4e3728.js} +1 -1
  24. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/{[variation]-0b6162eb591ee324.js → [variation]-743fc5c3feab52f8.js} +1 -1
  25. package/out/_next/static/chunks/pages/{slices-317ec2bd3451566e.js → slices-0f6e50acfb5957ed.js} +1 -1
  26. package/out/_next/static/css/{4840a6c8541a6625.css → aeaa4dcbac2fb8d0.css} +1 -1
  27. package/out/_next/static/css/cc25c43805d5a292.css +1 -0
  28. package/out/changelog.html +1 -1
  29. package/out/changes.html +1 -1
  30. package/out/custom-types/[customTypeId].html +1 -1
  31. package/out/custom-types.html +1 -1
  32. package/out/index.html +1 -1
  33. package/out/labs.html +1 -1
  34. package/out/page-types/[pageTypeId].html +1 -1
  35. package/out/settings.html +1 -1
  36. package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
  37. package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
  38. package/out/slices.html +1 -1
  39. package/package.json +4 -4
  40. package/src/features/settings/git/GitRepositoryConnectDialog.tsx +2 -0
  41. package/src/features/slices/convertLegacySlice/ConvertLegacySliceAsNewSliceDialog.tsx +111 -114
  42. package/src/features/slices/convertLegacySlice/ConvertLegacySliceAsNewVariationDialog.tsx +134 -140
  43. package/src/features/slices/convertLegacySlice/ConvertLegacySliceMergeWithIdenticalDialog.tsx +75 -72
  44. package/src/legacy/components/Forms/RenameVariationModal/RenameVariationModal.tsx +91 -71
  45. package/src/legacy/components/Forms/formsValidator.ts +1 -1
  46. package/src/theme.ts +0 -4
  47. package/out/_next/static/3qbqGvjPz_LCGtwI1SVmH/_buildManifest.js +0 -1
  48. package/out/_next/static/chunks/150-96a0c443c430ec4b.js +0 -1
  49. package/out/_next/static/chunks/588-d017e0fe2a651a87.js +0 -1
  50. package/out/_next/static/chunks/750-aa35f21031ee1f96.js +0 -1
  51. package/out/_next/static/chunks/pages/settings-80e0d6f1c79282d3.js +0 -1
  52. package/out/_next/static/css/e5c7f63f02ff4d0f.css +0 -1
  53. package/src/legacy/components/Forms/RenameVariationModal/RenameVariationModal.module.css +0 -5
  54. package/src/legacy/components/Forms/RenameVariationModal/RenameVariationModal.module.css.d.ts +0 -5
  55. /package/out/_next/static/{3qbqGvjPz_LCGtwI1SVmH → 9odHTDRwqbGU-9wLdN7o7}/_ssgManifest.js +0 -0
@@ -1,3 +1,4 @@
1
+ import { useOnChange } from "@prismicio/editor-support/React";
1
2
  import {
2
3
  Box,
3
4
  Dialog,
@@ -6,13 +7,13 @@ import {
6
7
  DialogCancelButton,
7
8
  DialogContent,
8
9
  DialogHeader,
10
+ Form,
9
11
  FormInput,
10
12
  ScrollArea,
11
13
  Select,
12
14
  SelectItem,
13
15
  Text,
14
16
  } from "@prismicio/editor-ui";
15
- import { Formik } from "formik";
16
17
  import { camelCase } from "lodash";
17
18
  import { type FC, useState } from "react";
18
19
 
@@ -38,7 +39,37 @@ export const ConvertLegacySliceAsNewVariationDialog: FC<DialogProps> = ({
38
39
  libraries,
39
40
  localSharedSlices,
40
41
  }) => {
42
+ const defaultValues = {
43
+ libraryID: localSharedSlices[0]?.from,
44
+ sliceID: localSharedSlices[0]?.model.id,
45
+ variationID: camelCase(slice.key),
46
+ variationName: sliceName,
47
+ };
41
48
  const [inferIDFromName, setInferIDFromName] = useState(true);
49
+ const [values, setValues] = useState<FormValues>(defaultValues);
50
+ const [errors, setErrors] = useState<
51
+ Partial<Record<keyof FormValues, string>>
52
+ >({});
53
+
54
+ useOnChange(isOpen, () => {
55
+ if (!isOpen) {
56
+ setValues(defaultValues);
57
+ setErrors({});
58
+ }
59
+ });
60
+
61
+ function handleValueChange(values: FormValues) {
62
+ setValues(values);
63
+ setErrors(validateAsNewVariationValues(values, libraries));
64
+ }
65
+
66
+ function handleSubmit() {
67
+ if (Object.keys(errors).length > 0) {
68
+ return;
69
+ }
70
+
71
+ onSubmit(values);
72
+ }
42
73
 
43
74
  return (
44
75
  <Dialog
@@ -48,147 +79,110 @@ export const ConvertLegacySliceAsNewVariationDialog: FC<DialogProps> = ({
48
79
  >
49
80
  <DialogHeader title="Convert to slice variation" />
50
81
  <DialogContent>
51
- <Formik
52
- initialValues={{
53
- libraryID: localSharedSlices[0]?.from,
54
- sliceID: localSharedSlices[0]?.model.id,
55
- variationID: camelCase(slice.key),
56
- variationName: sliceName,
57
- }}
58
- validate={(values) => {
59
- return validateAsNewVariationValues(values, libraries);
60
- }}
61
- onSubmit={(values) => {
62
- onSubmit(values);
63
- }}
64
- >
65
- {(formik) => {
66
- return (
67
- <form id="convert-legacy-slice-as-new-variation-dialog">
68
- <Box display="flex" flexDirection="column">
69
- <ScrollArea
70
- className={styles.scrollArea}
71
- style={{ width: 448 }}
72
- >
73
- <Text variant="normal" color="grey11">
74
- If you have multiple slices that are similar, you can
75
- combine them as variations of the same slice.
82
+ <Form onSubmit={handleSubmit}>
83
+ <Box display="flex" flexDirection="column">
84
+ <ScrollArea className={styles.scrollArea}>
85
+ <Text variant="normal" color="grey11">
86
+ If you have multiple slices that are similar, you can combine
87
+ them as variations of the same slice.
88
+ </Text>
89
+ <Box display="flex" flexDirection="column" gap={4}>
90
+ <label className={styles.label}>
91
+ <Text variant="bold">Target slice *</Text>
92
+ {typeof errors.libraryID === "string" ? (
93
+ <Text variant="small" color="tomato10">
94
+ {errors.libraryID}
95
+ </Text>
96
+ ) : null}
97
+ {typeof errors.sliceID === "string" ? (
98
+ <Text variant="small" color="tomato10">
99
+ {errors.sliceID}
76
100
  </Text>
77
- <Box display="flex" flexDirection="column" gap={4}>
78
- <label className={styles.label}>
79
- <Text variant="bold">Target slice*</Text>
80
- {typeof formik.errors.libraryID === "string" ? (
81
- <Text variant="small" color="tomato10">
82
- {formik.errors.libraryID}
83
- </Text>
84
- ) : null}
85
- {typeof formik.errors.sliceID === "string" ? (
86
- <Text variant="small" color="tomato10">
87
- {formik.errors.sliceID}
88
- </Text>
89
- ) : null}
90
- </label>
91
- <Select
92
- size="medium"
93
- color="grey"
94
- startIcon="viewDay"
95
- flexContent={true}
96
- value={`${formik.values.libraryID}::${formik.values.sliceID}`}
97
- onValueChange={(value) => {
98
- if (value) {
99
- const [libraryID, sliceID] = value.split("::");
100
- void formik.setFieldValue("libraryID", libraryID);
101
- void formik.setFieldValue("sliceID", sliceID);
102
- }
103
- }}
104
- >
105
- {localSharedSlices.map((slice) => (
106
- <SelectItem
107
- key={`${slice.from}::${slice.model.id}`}
108
- value={`${slice.from}::${slice.model.id}`}
109
- >
110
- {slice.from} {">"} {slice.model.name} (
111
- {slice.model.id})
112
- </SelectItem>
113
- ))}
114
- </Select>
115
- <Text variant="normal" color="grey11">
116
- Choose the slice to which you would like to add this
117
- variation.
118
- </Text>
119
- </Box>
120
- <Box display="flex" flexDirection="column" gap={4}>
121
- <label className={styles.label}>
122
- <Text variant="bold">Variation name*</Text>
123
- {typeof formik.errors.variationName === "string" ? (
124
- <Text variant="small" color="tomato10">
125
- {formik.errors.variationName}
126
- </Text>
127
- ) : null}
128
- </label>
129
- <FormInput
130
- placeholder={sliceName}
131
- error={typeof formik.errors.variationName === "string"}
132
- value={formik.values.variationName}
133
- onValueChange={(value) => {
134
- const values = {
135
- ...formik.values,
136
- variationName: value.slice(0, 30),
137
- };
138
-
139
- if (inferIDFromName) {
140
- values.variationID = camelCase(
141
- values.variationName,
142
- );
143
- }
144
-
145
- formik.setValues(values, true);
146
- }}
147
- data-testid="variation-name-input"
148
- />
149
- </Box>
150
- <Box display="flex" flexDirection="column" gap={4}>
151
- <label className={styles.label}>
152
- <Text variant="bold">ID*</Text>
153
- {typeof formik.errors.variationID === "string" ? (
154
- <Text variant="small" color="tomato10">
155
- {formik.errors.variationID}
156
- </Text>
157
- ) : null}
158
- </label>
159
- <FormInput
160
- placeholder={camelCase(slice.key)}
161
- error={typeof formik.errors.variationID === "string"}
162
- value={formik.values.variationID}
163
- onValueChange={(value) => {
164
- setInferIDFromName(false);
165
- void formik.setFieldValue(
166
- "variationID",
167
- camelCase(value.slice(0, 30)),
168
- );
169
- }}
170
- data-testid="variation-id-input"
171
- />
172
- </Box>
173
- </ScrollArea>
174
- <DialogActions>
175
- <DialogCancelButton size="medium" />
176
- <DialogActionButton
177
- size="medium"
178
- loading={isLoading}
179
- onClick={() => {
180
- void formik.submitForm();
181
- }}
182
- disabled={!formik.isValid}
101
+ ) : null}
102
+ </label>
103
+ <Select
104
+ size="medium"
105
+ color="grey"
106
+ startIcon="viewDay"
107
+ flexContent={true}
108
+ value={`${values.libraryID}::${values.sliceID}`}
109
+ onValueChange={(value) => {
110
+ if (value) {
111
+ const [libraryID, sliceID] = value.split("::");
112
+ handleValueChange({
113
+ ...values,
114
+ libraryID,
115
+ sliceID,
116
+ });
117
+ }
118
+ }}
119
+ >
120
+ {localSharedSlices.map((slice) => (
121
+ <SelectItem
122
+ key={`${slice.from}::${slice.model.id}`}
123
+ value={`${slice.from}::${slice.model.id}`}
183
124
  >
184
- Convert
185
- </DialogActionButton>
186
- </DialogActions>
187
- </Box>
188
- </form>
189
- );
190
- }}
191
- </Formik>
125
+ {slice.from} {">"} {slice.model.name} ({slice.model.id})
126
+ </SelectItem>
127
+ ))}
128
+ </Select>
129
+ <Text variant="normal" color="grey11">
130
+ Choose the slice to which you would like to add this
131
+ variation.
132
+ </Text>
133
+ </Box>
134
+ <Box display="flex" flexDirection="column" gap={4}>
135
+ <FormInput
136
+ label="Variation name *"
137
+ placeholder={sliceName}
138
+ error={errors.variationName}
139
+ value={values.variationName}
140
+ onValueChange={(value) => {
141
+ const newValues = {
142
+ ...values,
143
+ variationName: value.slice(0, 30),
144
+ };
145
+
146
+ if (inferIDFromName) {
147
+ newValues.variationID = camelCase(
148
+ newValues.variationName,
149
+ );
150
+ }
151
+
152
+ handleValueChange(newValues);
153
+ }}
154
+ data-testid="variation-name-input"
155
+ />
156
+ </Box>
157
+ <Box display="flex" flexDirection="column" gap={4}>
158
+ <FormInput
159
+ label="ID *"
160
+ placeholder={camelCase(slice.key)}
161
+ error={errors.variationID}
162
+ value={values.variationID}
163
+ onValueChange={(value) => {
164
+ setInferIDFromName(false);
165
+ handleValueChange({
166
+ ...values,
167
+ variationID: value.slice(0, 30),
168
+ });
169
+ }}
170
+ data-testid="variation-id-input"
171
+ />
172
+ </Box>
173
+ </ScrollArea>
174
+ <DialogActions>
175
+ <DialogCancelButton size="medium" />
176
+ <DialogActionButton
177
+ size="medium"
178
+ loading={isLoading}
179
+ disabled={Object.keys(errors).length > 0}
180
+ >
181
+ Convert
182
+ </DialogActionButton>
183
+ </DialogActions>
184
+ </Box>
185
+ </Form>
192
186
  </DialogContent>
193
187
  </Dialog>
194
188
  );
@@ -1,3 +1,4 @@
1
+ import { useOnChange } from "@prismicio/editor-support/React";
1
2
  import {
2
3
  Box,
3
4
  Dialog,
@@ -6,13 +7,13 @@ import {
6
7
  DialogCancelButton,
7
8
  DialogContent,
8
9
  DialogHeader,
10
+ Form,
9
11
  ScrollArea,
10
12
  Select,
11
13
  SelectItem,
12
14
  Text,
13
15
  } from "@prismicio/editor-ui";
14
- import { Formik } from "formik";
15
- import type { FC } from "react";
16
+ import { type FC, useState } from "react";
16
17
 
17
18
  import styles from "./ConvertLegacySliceButton.module.css";
18
19
  import { DialogProps } from "./types";
@@ -24,6 +25,32 @@ export const ConvertLegacySliceMergeWithIdenticalDialog: FC<DialogProps> = ({
24
25
  isLoading,
25
26
  identicalSlices,
26
27
  }) => {
28
+ const defaultPath = identicalSlices[0]?.path ?? "";
29
+ const [path, setPath] = useState<string>(defaultPath);
30
+ const [error, setError] = useState<string | undefined>();
31
+
32
+ useOnChange(isOpen, () => {
33
+ if (!isOpen) {
34
+ setPath(defaultPath);
35
+ setError(undefined);
36
+ }
37
+ });
38
+
39
+ function handleValueChange(value: string) {
40
+ setPath(value);
41
+
42
+ if (!value) setError("Cannot be empty.");
43
+ }
44
+
45
+ function handleSubmit() {
46
+ if (Boolean(error)) {
47
+ return;
48
+ }
49
+
50
+ const [libraryID, sliceID, variationID] = path.split("::");
51
+ onSubmit({ libraryID, sliceID, variationID });
52
+ }
53
+
27
54
  return (
28
55
  <Dialog
29
56
  open={isOpen}
@@ -32,77 +59,53 @@ export const ConvertLegacySliceMergeWithIdenticalDialog: FC<DialogProps> = ({
32
59
  >
33
60
  <DialogHeader title="Merge with an existing slice" />
34
61
  <DialogContent>
35
- <Formik
36
- initialValues={{
37
- path: identicalSlices[0]?.path ?? "",
38
- }}
39
- validate={(values) => {
40
- if (!values.path) {
41
- return { path: "Cannot be empty." };
42
- }
43
- }}
44
- onSubmit={(values) => {
45
- const [libraryID, sliceID, variationID] = values.path.split("::");
46
- onSubmit({ libraryID, sliceID, variationID });
47
- }}
48
- >
49
- {(formik) => {
50
- return (
51
- <form id="convert-legacy-slice-merge-with-identical-dialog">
52
- <Box display="flex" flexDirection="column">
53
- <ScrollArea className={styles.scrollArea}>
54
- <Text variant="normal" color="grey11">
55
- If you have multiple identical slices, you can merge them.
56
- All of your content will be remapped to the target slice.
62
+ <Form onSubmit={handleSubmit}>
63
+ <Box display="flex" flexDirection="column">
64
+ <ScrollArea className={styles.scrollArea}>
65
+ <Text variant="normal" color="grey11">
66
+ If you have multiple identical slices, you can merge them. All
67
+ of your content will be remapped to the target slice.
68
+ </Text>
69
+ <Box display="flex" flexDirection="column" gap={4}>
70
+ <label className={styles.label}>
71
+ <Text variant="bold">Target slice*</Text>
72
+ {typeof error === "string" ? (
73
+ <Text variant="small" color="tomato10">
74
+ {error}
57
75
  </Text>
58
- <Box display="flex" flexDirection="column" gap={4}>
59
- <label className={styles.label}>
60
- <Text variant="bold">Target slice*</Text>
61
- {typeof formik.errors.path === "string" ? (
62
- <Text variant="small" color="tomato10">
63
- {formik.errors.path}
64
- </Text>
65
- ) : null}
66
- </label>
67
- <Select
68
- size="medium"
69
- color="grey"
70
- startIcon="viewDay"
71
- flexContent={true}
72
- value={formik.values.path}
73
- onValueChange={(value) => {
74
- value
75
- ? void formik.setFieldValue("path", value)
76
- : null;
77
- }}
78
- >
79
- {identicalSlices.map((slice) => (
80
- <SelectItem key={slice.path} value={slice.path}>
81
- {slice.path.split("::").join(" > ")}
82
- </SelectItem>
83
- ))}
84
- </Select>
85
- <Text variant="normal" color="grey11">
86
- Choose a slice that you would like to merge this into.
87
- </Text>
88
- </Box>
89
- </ScrollArea>
90
- <DialogActions>
91
- <DialogCancelButton size="medium" />
92
- <DialogActionButton
93
- size="medium"
94
- loading={isLoading}
95
- disabled={!formik.isValid}
96
- onClick={() => void formik.submitForm()}
97
- >
98
- Merge
99
- </DialogActionButton>
100
- </DialogActions>
101
- </Box>
102
- </form>
103
- );
104
- }}
105
- </Formik>
76
+ ) : null}
77
+ </label>
78
+ <Select
79
+ size="medium"
80
+ color="grey"
81
+ startIcon="viewDay"
82
+ flexContent={true}
83
+ value={path}
84
+ onValueChange={handleValueChange}
85
+ >
86
+ {identicalSlices.map((slice) => (
87
+ <SelectItem key={slice.path} value={slice.path}>
88
+ {slice.path.split("::").join(" > ")}
89
+ </SelectItem>
90
+ ))}
91
+ </Select>
92
+ <Text variant="normal" color="grey11">
93
+ Choose a slice that you would like to merge this into.
94
+ </Text>
95
+ </Box>
96
+ </ScrollArea>
97
+ <DialogActions>
98
+ <DialogCancelButton size="medium" />
99
+ <DialogActionButton
100
+ size="medium"
101
+ loading={isLoading}
102
+ disabled={Boolean(error)}
103
+ >
104
+ Merge
105
+ </DialogActionButton>
106
+ </DialogActions>
107
+ </Box>
108
+ </Form>
106
109
  </DialogContent>
107
110
  </Dialog>
108
111
  );