slice-machine-ui 2.16.2-beta.17 → 2.16.2-beta.3

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 (68) hide show
  1. package/out/404.html +1 -1
  2. package/out/_next/static/WcTCr5PY9CMXQCakT6VQd/_buildManifest.js +1 -0
  3. package/out/_next/static/chunks/268-6d5fc7642a1b87c8.js +1 -0
  4. package/out/_next/static/chunks/34-2911c905c8a6e9d9.js +1 -0
  5. package/out/_next/static/chunks/630-93339694ef30b82d.js +1 -0
  6. package/out/_next/static/chunks/867-8164160c810122c6.js +1 -0
  7. package/out/_next/static/chunks/882-28837678beff7e51.js +1 -0
  8. package/out/_next/static/chunks/895-8c214ba470a4e23c.js +1 -0
  9. package/out/_next/static/chunks/{main-c46f4dcf6e3174bd.js → main-1c0e53194ff2e726.js} +1 -1
  10. package/out/_next/static/chunks/pages/_app-3fd13526dea9f1d4.js +657 -0
  11. package/out/_next/static/chunks/pages/changelog-80a618708f44f25f.js +1 -0
  12. package/out/_next/static/chunks/pages/changes-d40c17939854b984.js +1 -0
  13. package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-a408f5a660e096a6.js → [customTypeId]-389d1b7a492fb3e7.js} +1 -1
  14. package/out/_next/static/chunks/pages/{custom-types-5acd56959b60346f.js → custom-types-2a5fd94ee42ba593.js} +1 -1
  15. package/out/_next/static/chunks/pages/{index-0d8cb369de720a35.js → index-02dd147957c8b40f.js} +1 -1
  16. package/out/_next/static/chunks/pages/labs-c6df252ea5d8fb6f.js +1 -0
  17. package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-f5e851ebe35049a8.js → [pageTypeId]-3589bd1f9138a97b.js} +1 -1
  18. package/out/_next/static/chunks/pages/settings-170379902605f38a.js +1 -0
  19. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-063fa88ba75f483e.js +1 -0
  20. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-6de02b8ed13b680d.js +1 -0
  21. package/out/_next/static/chunks/pages/slices-071bb494907adf0f.js +1 -0
  22. package/out/_next/static/chunks/webpack-2f903acb0cccbf9e.js +1 -0
  23. package/out/_next/static/css/9c9a7de81f9ac811.css +1 -0
  24. package/out/changelog.html +1 -1
  25. package/out/changes.html +1 -1
  26. package/out/custom-types/[customTypeId].html +1 -1
  27. package/out/custom-types.html +1 -1
  28. package/out/index.html +1 -1
  29. package/out/labs.html +1 -1
  30. package/out/page-types/[pageTypeId].html +1 -1
  31. package/out/settings.html +1 -1
  32. package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
  33. package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
  34. package/out/slices.html +1 -1
  35. package/package.json +8 -8
  36. package/src/features/customTypes/customTypesTable/CustomTypesTable.tsx +4 -2
  37. package/src/features/customTypes/customTypesTable/{useCustomTypesAutoRevalidation.tsx → useCustomTypes.ts} +34 -1
  38. package/src/legacy/lib/builders/common/Zone/Card/components/Hints/index.tsx +1 -12
  39. package/src/legacy/lib/models/common/widgets/ContentRelationship/Form.tsx +77 -35
  40. package/src/legacy/lib/models/common/widgets/ContentRelationship/index.ts +15 -46
  41. package/src/legacy/lib/models/common/widgets/Link/index.ts +1 -1
  42. package/src/utils/tracking/trackFieldAdded.ts +5 -2
  43. package/src/utils/tracking/trackFieldUpdated.ts +5 -2
  44. package/out/_next/static/YlBfAcqDSP3Tctj3WT7xv/_buildManifest.js +0 -1
  45. package/out/_next/static/chunks/248-03446cd9e9f13730.js +0 -1
  46. package/out/_next/static/chunks/268-6a9214b97195af9c.js +0 -1
  47. package/out/_next/static/chunks/33641354.3864aefb6106ae71.js +0 -28
  48. package/out/_next/static/chunks/34-e684c5fd75cc9dd0.js +0 -1
  49. package/out/_next/static/chunks/630-a8b2c2d022cc9450.js +0 -1
  50. package/out/_next/static/chunks/647-7b9b5aa9468f9e4b.js +0 -1
  51. package/out/_next/static/chunks/882-151468121d542ed6.js +0 -1
  52. package/out/_next/static/chunks/pages/_app-e3fa2a0a57c571ce.js +0 -708
  53. package/out/_next/static/chunks/pages/changelog-063c5e11dfc8fd55.js +0 -1
  54. package/out/_next/static/chunks/pages/changes-564336edb0ed18b0.js +0 -1
  55. package/out/_next/static/chunks/pages/labs-9630bfb1005be02b.js +0 -1
  56. package/out/_next/static/chunks/pages/settings-01f4aeb9112a1f87.js +0 -1
  57. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-5008e29008aa04f4.js +0 -1
  58. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-bd5e45632c419567.js +0 -1
  59. package/out/_next/static/chunks/pages/slices-4a60cd5f2c71327e.js +0 -1
  60. package/out/_next/static/chunks/webpack-b3522fdebabf510a.js +0 -1
  61. package/out/_next/static/css/cc9b10286400c2b9.css +0 -1
  62. package/src/features/builder/fields/contentRelationship/ContentRelationshipFieldPicker.tsx +0 -1279
  63. package/src/features/builder/fields/contentRelationship/Hint.tsx +0 -28
  64. package/src/features/builder/fields/contentRelationship/__tests__/ContentRelationshipFieldPicker.test.ts +0 -265
  65. package/src/features/customTypes/useCustomTypes.ts +0 -48
  66. package/src/utils/isValidObject.ts +0 -32
  67. package/src/utils/tracking/getLinkTrackingProperties.ts +0 -26
  68. /package/out/_next/static/{YlBfAcqDSP3Tctj3WT7xv → WcTCr5PY9CMXQCakT6VQd}/_ssgManifest.js +0 -0
@@ -1,28 +0,0 @@
1
- import { Box, Text } from "@prismicio/editor-ui";
2
-
3
- export function Hint(args: { show: boolean }) {
4
- if (!args.show) return null;
5
-
6
- return (
7
- <Box
8
- padding={{ block: 8, inline: 16 }}
9
- border={{ top: true }}
10
- borderColor="grey6"
11
- >
12
- <Text variant="normal" color="grey11">
13
- No code snippet for this field.{" "}
14
- <Text
15
- component="a"
16
- href="https://prismic.io/docs/fields/content-relationship"
17
- rel="noopener noreferrer"
18
- target="_blank"
19
- color="grey11"
20
- underline
21
- >
22
- Check the docs
23
- </Text>{" "}
24
- for an example.
25
- </Text>
26
- </Box>
27
- );
28
- }
@@ -1,265 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
-
3
- import {
4
- convertLinkCustomtypesToFieldCheckMap,
5
- countPickedFields,
6
- } from "../ContentRelationshipFieldPicker";
7
-
8
- describe("ContentRelationshipFieldPicker", () => {
9
- it("should count picked fields with a custom type as string", () => {
10
- const customtypes = ["ct1"];
11
-
12
- const result = countPickedFields(
13
- convertLinkCustomtypesToFieldCheckMap(customtypes),
14
- );
15
-
16
- expect(result).toEqual({
17
- pickedFields: 0,
18
- nestedPickedFields: 0,
19
- });
20
- });
21
-
22
- it("should count picked fields with multiple custom types as string", () => {
23
- const customtypes = ["ct1", "ct2"];
24
-
25
- const result = countPickedFields(
26
- convertLinkCustomtypesToFieldCheckMap(customtypes),
27
- );
28
-
29
- expect(result).toEqual({
30
- pickedFields: 0,
31
- nestedPickedFields: 0,
32
- });
33
- });
34
-
35
- it("should count picked fields with custom type as object and one field", () => {
36
- const customtypes = [
37
- {
38
- id: "ct1",
39
- fields: ["f1"],
40
- },
41
- ];
42
-
43
- const result = countPickedFields(
44
- convertLinkCustomtypesToFieldCheckMap(customtypes),
45
- );
46
-
47
- expect(result).toEqual({
48
- pickedFields: 1,
49
- nestedPickedFields: 0,
50
- });
51
- });
52
-
53
- it("should count picked fields with custom type as object and one nested field", () => {
54
- const customtypes = [
55
- {
56
- id: "ct1",
57
- fields: [
58
- {
59
- id: "f1",
60
- customtypes: [
61
- {
62
- id: "ct2",
63
- fields: ["f1"],
64
- },
65
- ],
66
- },
67
- ],
68
- },
69
- ];
70
-
71
- const result = countPickedFields(
72
- convertLinkCustomtypesToFieldCheckMap(customtypes),
73
- );
74
-
75
- expect(result).toEqual({
76
- pickedFields: 1,
77
- nestedPickedFields: 1,
78
- });
79
- });
80
-
81
- it("should count picked fields with custom type as object with group field", () => {
82
- const customtypes = [
83
- {
84
- id: "ct1",
85
- fields: [
86
- {
87
- id: "g1",
88
- fields: ["f1", "f2"],
89
- },
90
- ],
91
- },
92
- ];
93
-
94
- const result = countPickedFields(
95
- convertLinkCustomtypesToFieldCheckMap(customtypes),
96
- );
97
-
98
- expect(result).toEqual({
99
- pickedFields: 2,
100
- nestedPickedFields: 0,
101
- });
102
- });
103
-
104
- it("should count picked fields with custom type as object with group field and nested custom type", () => {
105
- const customtypes = [
106
- {
107
- id: "ct1",
108
- fields: [
109
- {
110
- id: "g1",
111
- fields: [
112
- "f1",
113
- {
114
- id: "f2",
115
- customtypes: [
116
- {
117
- id: "ct2",
118
- fields: ["f1"],
119
- },
120
- ],
121
- },
122
- ],
123
- },
124
- ],
125
- },
126
- ];
127
-
128
- const result = countPickedFields(
129
- convertLinkCustomtypesToFieldCheckMap(customtypes),
130
- );
131
-
132
- expect(result).toEqual({
133
- pickedFields: 2,
134
- nestedPickedFields: 1,
135
- });
136
- });
137
-
138
- it("should count picked fields with custom type as object with group field, nested custom type and nested group field", () => {
139
- const customtypes = [
140
- {
141
- id: "ct1",
142
- fields: [
143
- {
144
- id: "g1",
145
- fields: [
146
- "f1",
147
- {
148
- id: "f2",
149
- customtypes: [
150
- {
151
- id: "ct2",
152
- fields: [
153
- "f1",
154
- {
155
- id: "g2",
156
- fields: ["f1", "f2"],
157
- },
158
- ],
159
- },
160
- ],
161
- },
162
- ],
163
- },
164
- ],
165
- },
166
- ];
167
-
168
- const result = countPickedFields(
169
- convertLinkCustomtypesToFieldCheckMap(customtypes),
170
- );
171
-
172
- expect(result).toEqual({
173
- pickedFields: 4,
174
- nestedPickedFields: 3,
175
- });
176
- });
177
-
178
- it("should count picked fields with custom type as object with nested custom type and nested group field", () => {
179
- const customtypes = [
180
- {
181
- id: "ct1",
182
- fields: [
183
- "f1",
184
- {
185
- id: "f2",
186
- customtypes: [
187
- {
188
- id: "ct2",
189
- fields: [
190
- "f1",
191
- {
192
- id: "g2",
193
- fields: ["f1", "f2"],
194
- },
195
- ],
196
- },
197
- ],
198
- },
199
- ],
200
- },
201
- ];
202
-
203
- const result = countPickedFields(
204
- convertLinkCustomtypesToFieldCheckMap(customtypes),
205
- );
206
-
207
- expect(result).toEqual({
208
- pickedFields: 4,
209
- nestedPickedFields: 3,
210
- });
211
- });
212
-
213
- it("should count picked fields with custom type as object with nested custom type without fields", () => {
214
- const customtypes = [
215
- {
216
- id: "ct1",
217
- fields: [
218
- "f1",
219
- {
220
- id: "f2",
221
- customtypes: [
222
- {
223
- id: "ct2",
224
- fields: [],
225
- },
226
- ],
227
- },
228
- ],
229
- },
230
- ];
231
-
232
- const result = countPickedFields(
233
- convertLinkCustomtypesToFieldCheckMap(customtypes),
234
- );
235
-
236
- expect(result).toEqual({
237
- pickedFields: 1,
238
- nestedPickedFields: 0,
239
- });
240
- });
241
-
242
- it("should count picked fields with custom type as object with group field without fields", () => {
243
- const customtypes = [
244
- {
245
- id: "ct1",
246
- fields: [
247
- "f1",
248
- {
249
- id: "g1",
250
- fields: [],
251
- },
252
- ],
253
- },
254
- ];
255
-
256
- const result = countPickedFields(
257
- convertLinkCustomtypesToFieldCheckMap(customtypes),
258
- );
259
-
260
- expect(result).toEqual({
261
- pickedFields: 1,
262
- nestedPickedFields: 0,
263
- });
264
- });
265
- });
@@ -1,48 +0,0 @@
1
- import {
2
- revalidateData,
3
- updateData,
4
- useRequest,
5
- } from "@prismicio/editor-support/Suspense";
6
- import type { CustomType } from "@prismicio/types-internal/lib/customtypes";
7
- import type { CustomTypeFormat } from "@slicemachine/manager";
8
- import { useCallback } from "react";
9
-
10
- import { managerClient } from "@/managerClient";
11
-
12
- type UseCustomTypesReturnType = {
13
- customTypes: CustomType[];
14
- updateCustomTypes: (customTypes: CustomType[]) => void;
15
- };
16
-
17
- export function useCustomTypes(
18
- format?: CustomTypeFormat,
19
- ): UseCustomTypesReturnType {
20
- const updateCustomTypes = useCallback(
21
- (data: CustomType[]) => updateData(getCustomTypes, [format], data),
22
- [format],
23
- );
24
-
25
- return {
26
- customTypes: useRequest(getCustomTypes, [format]),
27
- updateCustomTypes,
28
- };
29
- }
30
-
31
- export async function getCustomTypes(
32
- format?: CustomTypeFormat,
33
- ): Promise<CustomType[]> {
34
- const { errors, models } = await managerClient.customTypes.readAllCustomTypes(
35
- format ? { format } : undefined,
36
- );
37
-
38
- if (errors.length > 0) {
39
- throw errors;
40
- }
41
-
42
- return models.map(({ model }) => model);
43
- }
44
-
45
- export function revalidateGetCustomTypes(format?: CustomTypeFormat) {
46
- void revalidateData(getCustomTypes, []);
47
- void revalidateData(getCustomTypes, [format]);
48
- }
@@ -1,32 +0,0 @@
1
- /**
2
- * Ensure that the value is an record/object with string keys and existing
3
- * properties. Accepts empty objects and objects created with
4
- * `Object.create(null)`.
5
- */
6
- export function isValidObject(
7
- value: unknown,
8
- ): value is Record<string, unknown> {
9
- if (typeof value !== "object" || value === null) return false;
10
-
11
- if (Array.isArray(value)) return false;
12
-
13
- if (
14
- value instanceof Date ||
15
- value instanceof RegExp ||
16
- value instanceof Error
17
- ) {
18
- return false;
19
- }
20
-
21
- // Check if all keys are strings and all values are valid
22
- for (const key in value) {
23
- if (
24
- typeof key !== "string" ||
25
- !Object.prototype.hasOwnProperty.call(value, key)
26
- ) {
27
- return false;
28
- }
29
- }
30
-
31
- return true;
32
- }
@@ -1,26 +0,0 @@
1
- import { Link } from "@prismicio/types-internal/lib/customtypes/widgets";
2
-
3
- import {
4
- convertLinkCustomtypesToFieldCheckMap,
5
- countPickedFields,
6
- } from "@/features/builder/fields/contentRelationship/ContentRelationshipFieldPicker";
7
-
8
- export function getLinkTrackingProperties(field: Link) {
9
- return {
10
- allowText: field.config?.allowText,
11
- repeat: field.config?.repeat,
12
- variants: field.config?.variants,
13
- linkSelect: field.config?.select,
14
- ...(field.config?.select === "document" &&
15
- field.config?.customtypes &&
16
- (() => {
17
- const { pickedFields, nestedPickedFields } = countPickedFields(
18
- convertLinkCustomtypesToFieldCheckMap(field.config?.customtypes),
19
- );
20
- return {
21
- linkPickedFields: pickedFields,
22
- linkNestedPickedFields: nestedPickedFields,
23
- };
24
- })()),
25
- };
26
- }