slice-machine-ui 2.16.2-beta.9 → 2.17.1-alpha.jp-cr-ui-nested-ct-remove-section.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/out/404.html +1 -1
- package/out/_next/static/0SPBnBOIdcPusg2ceVdAq/_buildManifest.js +1 -0
- package/out/_next/static/chunks/248-03446cd9e9f13730.js +1 -0
- package/out/_next/static/chunks/268-6a9214b97195af9c.js +1 -0
- package/out/_next/static/chunks/33641354.3864aefb6106ae71.js +28 -0
- package/out/_next/static/chunks/34-e684c5fd75cc9dd0.js +1 -0
- package/out/_next/static/chunks/630-4a8f19a6a113700f.js +1 -0
- package/out/_next/static/chunks/647-7b9b5aa9468f9e4b.js +1 -0
- package/out/_next/static/chunks/882-151468121d542ed6.js +1 -0
- package/out/_next/static/chunks/pages/_app-15912b10c760cd68.js +708 -0
- package/out/_next/static/chunks/pages/changelog-063c5e11dfc8fd55.js +1 -0
- package/out/_next/static/chunks/pages/changes-564336edb0ed18b0.js +1 -0
- package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-389d1b7a492fb3e7.js → [customTypeId]-a408f5a660e096a6.js} +1 -1
- package/out/_next/static/chunks/pages/{custom-types-2a5fd94ee42ba593.js → custom-types-5acd56959b60346f.js} +1 -1
- package/out/_next/static/chunks/pages/{index-02dd147957c8b40f.js → index-0d8cb369de720a35.js} +1 -1
- package/out/_next/static/chunks/pages/labs-9630bfb1005be02b.js +1 -0
- package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-3589bd1f9138a97b.js → [pageTypeId]-f5e851ebe35049a8.js} +1 -1
- package/out/_next/static/chunks/pages/settings-01f4aeb9112a1f87.js +1 -0
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-5008e29008aa04f4.js +1 -0
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-bd5e45632c419567.js +1 -0
- package/out/_next/static/chunks/pages/slices-4a60cd5f2c71327e.js +1 -0
- package/out/_next/static/chunks/webpack-b3522fdebabf510a.js +1 -0
- package/out/_next/static/css/cc9b10286400c2b9.css +1 -0
- package/out/changelog.html +1 -1
- package/out/changes.html +1 -1
- package/out/custom-types/[customTypeId].html +1 -1
- package/out/custom-types.html +1 -1
- package/out/index.html +1 -1
- package/out/labs.html +1 -1
- package/out/page-types/[pageTypeId].html +1 -1
- package/out/settings.html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
- package/out/slices.html +1 -1
- package/package.json +8 -8
- package/src/features/builder/fields/contentRelationship/ContentRelationshipFieldPicker.tsx +1498 -0
- package/src/features/builder/fields/contentRelationship/Hint.tsx +28 -0
- package/src/features/builder/fields/contentRelationship/__tests__/ContentRelationshipFieldPicker.test.ts +1323 -0
- package/src/features/customTypes/customTypesTable/CustomTypesTable.tsx +2 -4
- package/src/features/customTypes/customTypesTable/{useCustomTypes.ts → useCustomTypesAutoRevalidation.tsx} +1 -34
- package/src/features/customTypes/useCustomTypes.ts +48 -0
- package/src/legacy/lib/builders/common/Zone/Card/components/Hints/index.tsx +12 -1
- package/src/legacy/lib/models/common/widgets/ContentRelationship/Form.tsx +35 -77
- package/src/legacy/lib/models/common/widgets/ContentRelationship/index.ts +46 -15
- package/src/legacy/lib/models/common/widgets/Link/index.ts +1 -1
- package/src/utils/isValidObject.ts +32 -0
- package/src/utils/tracking/getLinkTrackingProperties.ts +28 -0
- package/src/utils/tracking/trackFieldAdded.ts +2 -5
- package/src/utils/tracking/trackFieldUpdated.ts +2 -5
- package/out/_next/static/atP3j_itxjBtvIysQoCxK/_buildManifest.js +0 -1
- package/out/_next/static/chunks/268-6d5fc7642a1b87c8.js +0 -1
- package/out/_next/static/chunks/34-2911c905c8a6e9d9.js +0 -1
- package/out/_next/static/chunks/630-93339694ef30b82d.js +0 -1
- package/out/_next/static/chunks/867-8164160c810122c6.js +0 -1
- package/out/_next/static/chunks/882-28837678beff7e51.js +0 -1
- package/out/_next/static/chunks/895-8c214ba470a4e23c.js +0 -1
- package/out/_next/static/chunks/pages/_app-2400eb8f7c5ef3cb.js +0 -657
- package/out/_next/static/chunks/pages/changelog-80a618708f44f25f.js +0 -1
- package/out/_next/static/chunks/pages/changes-d40c17939854b984.js +0 -1
- package/out/_next/static/chunks/pages/labs-c6df252ea5d8fb6f.js +0 -1
- package/out/_next/static/chunks/pages/settings-170379902605f38a.js +0 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-063fa88ba75f483e.js +0 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-6de02b8ed13b680d.js +0 -1
- package/out/_next/static/chunks/pages/slices-071bb494907adf0f.js +0 -1
- package/out/_next/static/chunks/webpack-2f903acb0cccbf9e.js +0 -1
- package/out/_next/static/css/9c9a7de81f9ac811.css +0 -1
- /package/out/_next/static/{atP3j_itxjBtvIysQoCxK → 0SPBnBOIdcPusg2ceVdAq}/_ssgManifest.js +0 -0
|
@@ -29,10 +29,8 @@ import { SingleIcon } from "@/icons/SingleIcon";
|
|
|
29
29
|
|
|
30
30
|
import { CUSTOM_TYPES_CONFIG } from "../customTypesConfig";
|
|
31
31
|
import { EditDropdown } from "../EditDropdown";
|
|
32
|
-
import {
|
|
33
|
-
|
|
34
|
-
useCustomTypesAutoRevalidation,
|
|
35
|
-
} from "./useCustomTypes";
|
|
32
|
+
import { useCustomTypes } from "../useCustomTypes";
|
|
33
|
+
import { useCustomTypesAutoRevalidation } from "./useCustomTypesAutoRevalidation";
|
|
36
34
|
|
|
37
35
|
type CustomTypesTableProps = {
|
|
38
36
|
format: CustomTypeFormat;
|
|
@@ -1,46 +1,13 @@
|
|
|
1
|
-
import { updateData, useRequest } from "@prismicio/editor-support/Suspense";
|
|
2
1
|
import type { CustomType } from "@prismicio/types-internal/lib/customtypes";
|
|
3
2
|
import type { CustomTypeFormat } from "@slicemachine/manager";
|
|
4
|
-
import {
|
|
3
|
+
import { useEffect } from "react";
|
|
5
4
|
import { useSelector } from "react-redux";
|
|
6
5
|
|
|
7
6
|
import { CustomTypes } from "@/legacy/lib/models/common/CustomType";
|
|
8
7
|
import { hasLocal } from "@/legacy/lib/models/common/ModelData";
|
|
9
|
-
import { managerClient } from "@/managerClient";
|
|
10
8
|
import { selectAllCustomTypes } from "@/modules/availableCustomTypes";
|
|
11
9
|
import type { SliceMachineStoreType } from "@/redux/type";
|
|
12
10
|
|
|
13
|
-
type UseCustomTypesReturnType = {
|
|
14
|
-
customTypes: CustomType[];
|
|
15
|
-
updateCustomTypes: (customTypes: CustomType[]) => void;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export function useCustomTypes(
|
|
19
|
-
format: CustomTypeFormat,
|
|
20
|
-
): UseCustomTypesReturnType {
|
|
21
|
-
const updateCustomTypes = useCallback(
|
|
22
|
-
(data: CustomType[]) => updateData(getCustomTypes, [format], data),
|
|
23
|
-
[format],
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
customTypes: useRequest(getCustomTypes, [format]),
|
|
28
|
-
updateCustomTypes,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async function getCustomTypes(format: CustomTypeFormat): Promise<CustomType[]> {
|
|
33
|
-
const { errors, models } = await managerClient.customTypes.readAllCustomTypes(
|
|
34
|
-
{ format },
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
if (errors.length > 0) {
|
|
38
|
-
throw errors;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return models.map(({ model }) => model);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
11
|
/**
|
|
45
12
|
* TODO: DT-1363 - Update the way to have new data without Redux by revalidating
|
|
46
13
|
* Suspense
|
|
@@ -0,0 +1,48 @@
|
|
|
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,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import useSWR from "swr";
|
|
3
3
|
|
|
4
|
+
import { Hint as ContentRelationshipHint } from "@/features/builder/fields/contentRelationship/Hint";
|
|
4
5
|
import { managerClient } from "@/managerClient";
|
|
5
6
|
|
|
6
7
|
import CodeBlock, { Item, RenderHintBaseFN } from "./CodeBlock";
|
|
@@ -12,7 +13,7 @@ interface HintProps {
|
|
|
12
13
|
hintItemName?: string;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
const
|
|
16
|
+
const RegularHint: React.FC<HintProps> = ({
|
|
16
17
|
show,
|
|
17
18
|
renderHintBase,
|
|
18
19
|
item,
|
|
@@ -62,4 +63,14 @@ const Hint: React.FC<HintProps> = ({
|
|
|
62
63
|
);
|
|
63
64
|
};
|
|
64
65
|
|
|
66
|
+
const Hint: React.FC<HintProps> = (props) => {
|
|
67
|
+
const { item } = props;
|
|
68
|
+
|
|
69
|
+
if (item.value.type === "Link" && item.value.config?.select === "document") {
|
|
70
|
+
return <ContentRelationshipHint show={props.show} />;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return <RegularHint {...props} />;
|
|
74
|
+
};
|
|
75
|
+
|
|
65
76
|
export default Hint;
|
|
@@ -1,105 +1,63 @@
|
|
|
1
|
+
import { LinkConfig } from "@prismicio/types-internal/lib/customtypes";
|
|
1
2
|
import { FormikProps } from "formik";
|
|
2
|
-
import {
|
|
3
|
-
import Select from "react-select";
|
|
4
|
-
import { Box, Label } from "theme-ui";
|
|
3
|
+
import { Box } from "theme-ui";
|
|
5
4
|
import * as yup from "yup";
|
|
6
5
|
|
|
6
|
+
import { ContentRelationshipFieldPicker } from "@/features/builder/fields/contentRelationship/ContentRelationshipFieldPicker";
|
|
7
7
|
import { Col, Flex as FlexGrid } from "@/legacy/components/Flex";
|
|
8
8
|
import WidgetFormField from "@/legacy/lib/builders/common/EditModal/Field";
|
|
9
9
|
import { createFieldNameFromKey } from "@/legacy/lib/forms";
|
|
10
10
|
import { DefaultFields } from "@/legacy/lib/forms/defaults";
|
|
11
|
-
import { selectAllCustomTypes } from "@/modules/availableCustomTypes";
|
|
12
|
-
|
|
13
|
-
import { hasLocal } from "../../ModelData";
|
|
14
11
|
|
|
15
12
|
const FormFields = {
|
|
16
13
|
label: DefaultFields.label,
|
|
17
14
|
id: DefaultFields.id,
|
|
18
15
|
customtypes: {
|
|
19
|
-
validate: () => yup.array()
|
|
16
|
+
validate: () => yup.array(),
|
|
20
17
|
},
|
|
21
18
|
};
|
|
22
19
|
|
|
23
20
|
type FormProps = {
|
|
24
|
-
config: {
|
|
21
|
+
config: {
|
|
22
|
+
label: string;
|
|
23
|
+
select: string;
|
|
24
|
+
customtypes?: LinkConfig["customtypes"];
|
|
25
|
+
};
|
|
25
26
|
id: string;
|
|
26
|
-
//
|
|
27
|
+
// TODO: this exists in the yup schema but this doesn't seem to be validated by formik
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
const WidgetForm = ({
|
|
30
31
|
initialValues,
|
|
31
|
-
values
|
|
32
|
-
fields,
|
|
32
|
+
values,
|
|
33
33
|
setFieldValue,
|
|
34
|
+
fields,
|
|
34
35
|
}: FormikProps<FormProps> & { fields: Record<string, unknown> }) => {
|
|
35
|
-
const customTypes = useSelector(selectAllCustomTypes).filter(hasLocal);
|
|
36
|
-
|
|
37
|
-
const options = customTypes.map((ct) => ({
|
|
38
|
-
value: ct.local.id,
|
|
39
|
-
label: ct.local.label,
|
|
40
|
-
}));
|
|
41
|
-
|
|
42
|
-
const selectValues = formValues.config.customtypes
|
|
43
|
-
? formValues.config.customtypes.map((id) => {
|
|
44
|
-
const ct = customTypes.find(
|
|
45
|
-
(frontendCustomType) => frontendCustomType.local.id === id,
|
|
46
|
-
);
|
|
47
|
-
return { value: ct?.local.id, label: ct?.local.label };
|
|
48
|
-
})
|
|
49
|
-
: null;
|
|
50
|
-
|
|
51
36
|
return (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
<
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
37
|
+
<>
|
|
38
|
+
<FlexGrid>
|
|
39
|
+
{Object.entries(FormFields)
|
|
40
|
+
.filter((e) => e[0] !== "customtypes")
|
|
41
|
+
.map(([key, field]) => (
|
|
42
|
+
<Col key={key}>
|
|
43
|
+
<WidgetFormField
|
|
44
|
+
fieldName={createFieldNameFromKey(key)}
|
|
45
|
+
formField={field}
|
|
46
|
+
fields={fields}
|
|
47
|
+
initialValues={initialValues}
|
|
48
|
+
/>
|
|
49
|
+
</Col>
|
|
50
|
+
))}
|
|
51
|
+
</FlexGrid>
|
|
52
|
+
<Box mt={20}>
|
|
53
|
+
<ContentRelationshipFieldPicker
|
|
54
|
+
value={values.config.customtypes}
|
|
55
|
+
onChange={(fields) => {
|
|
56
|
+
void setFieldValue("config.customtypes", fields);
|
|
70
57
|
}}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
</Label>
|
|
75
|
-
<Select
|
|
76
|
-
isMulti
|
|
77
|
-
name="origin"
|
|
78
|
-
options={options}
|
|
79
|
-
onChange={(v) => {
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
81
|
-
if (v) {
|
|
82
|
-
void setFieldValue(
|
|
83
|
-
"config.customtypes",
|
|
84
|
-
v.map(({ value }) => value),
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
}}
|
|
88
|
-
value={selectValues}
|
|
89
|
-
theme={(theme) => {
|
|
90
|
-
return {
|
|
91
|
-
...theme,
|
|
92
|
-
colors: {
|
|
93
|
-
...theme.colors,
|
|
94
|
-
text: "text",
|
|
95
|
-
primary: "background",
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
}}
|
|
99
|
-
/>
|
|
100
|
-
</Box>
|
|
101
|
-
</Col>
|
|
102
|
-
</FlexGrid>
|
|
58
|
+
/>
|
|
59
|
+
</Box>
|
|
60
|
+
</>
|
|
103
61
|
);
|
|
104
62
|
};
|
|
105
63
|
|
|
@@ -7,17 +7,44 @@ import { Widget } from "../Widget";
|
|
|
7
7
|
import Form, { FormFields } from "./Form";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
+
* Legacy:
|
|
11
|
+
* {
|
|
12
|
+
* "type": "Link",
|
|
13
|
+
* "config": {
|
|
14
|
+
* "select": "document",
|
|
15
|
+
* "label": "relationship"
|
|
16
|
+
* "customtypes": [
|
|
17
|
+
* "page"
|
|
18
|
+
* ],
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* Current format (field picking):
|
|
10
23
|
* {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
* "type": "Link",
|
|
25
|
+
* "config": {
|
|
26
|
+
* "select": "document",
|
|
27
|
+
* "label": "relationship"
|
|
28
|
+
* "customtypes": [
|
|
29
|
+
* {
|
|
30
|
+
* "id": "page",
|
|
31
|
+
* "fields": [
|
|
32
|
+
* "category",
|
|
33
|
+
* {
|
|
34
|
+
* "id": "countryRelation",
|
|
35
|
+
* "customtypes": [
|
|
36
|
+
* {
|
|
37
|
+
* "id": "country",
|
|
38
|
+
* "fields": ["name"]
|
|
39
|
+
* }
|
|
40
|
+
* ]
|
|
41
|
+
* }
|
|
42
|
+
* ]
|
|
43
|
+
* }
|
|
44
|
+
* ],
|
|
45
|
+
* }
|
|
46
|
+
* }
|
|
47
|
+
*/
|
|
21
48
|
|
|
22
49
|
const Meta = {
|
|
23
50
|
icon: MdSettingsEthernet,
|
|
@@ -30,7 +57,7 @@ const contentRelationShipConfigSchema = linkConfigSchema.shape({
|
|
|
30
57
|
.string()
|
|
31
58
|
.required()
|
|
32
59
|
.matches(/^document$/, { excludeEmptyString: true }),
|
|
33
|
-
customtypes: yup.array(
|
|
60
|
+
customtypes: yup.array().optional(),
|
|
34
61
|
});
|
|
35
62
|
|
|
36
63
|
const schema = yup.object().shape({
|
|
@@ -43,12 +70,13 @@ const schema = yup.object().shape({
|
|
|
43
70
|
});
|
|
44
71
|
|
|
45
72
|
export const ContentRelationshipWidget: Widget<Link, typeof schema> = {
|
|
46
|
-
create: (label: string) => ({
|
|
73
|
+
create: (label: string): Link => ({
|
|
47
74
|
type: "Link",
|
|
48
75
|
config: {
|
|
49
76
|
label,
|
|
50
77
|
select: "document",
|
|
51
78
|
repeat: false,
|
|
79
|
+
customtypes: [],
|
|
52
80
|
},
|
|
53
81
|
}),
|
|
54
82
|
Meta,
|
|
@@ -65,9 +93,12 @@ export const ContentRelationshipWidget: Widget<Link, typeof schema> = {
|
|
|
65
93
|
return {
|
|
66
94
|
...initialValues,
|
|
67
95
|
customtypes: initialValues.customtypes.filter((ct) =>
|
|
68
|
-
customTypes.find(
|
|
69
|
-
(
|
|
70
|
-
|
|
96
|
+
customTypes.find((frontendCustomType) => {
|
|
97
|
+
if (typeof ct === "string") {
|
|
98
|
+
return frontendCustomType.local.id === ct;
|
|
99
|
+
}
|
|
100
|
+
return frontendCustomType.local.id === ct.id;
|
|
101
|
+
}),
|
|
71
102
|
),
|
|
72
103
|
};
|
|
73
104
|
},
|
|
@@ -72,7 +72,7 @@ export const linkConfigSchema = yup
|
|
|
72
72
|
.optional()
|
|
73
73
|
.oneOf(["media", "document", "web", null])
|
|
74
74
|
.nullable(),
|
|
75
|
-
customtypes: yup.array(
|
|
75
|
+
customtypes: yup.array().strict().optional(),
|
|
76
76
|
masks: yup.array(yup.string()).optional(),
|
|
77
77
|
tags: yup.array(yup.string()).optional(),
|
|
78
78
|
allowTargetBlank: yup.boolean().strict().optional(),
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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({
|
|
19
|
+
linkCustomtypes: field.config?.customtypes,
|
|
20
|
+
}),
|
|
21
|
+
);
|
|
22
|
+
return {
|
|
23
|
+
linkPickedFields: pickedFields,
|
|
24
|
+
linkNestedPickedFields: nestedPickedFields,
|
|
25
|
+
};
|
|
26
|
+
})()),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -8,6 +8,7 @@ import { telemetry } from "@/apiClient";
|
|
|
8
8
|
import { SlicePrimaryFieldSM } from "@/legacy/lib/models/common/Slice";
|
|
9
9
|
|
|
10
10
|
import { getContentTypeForTracking } from "./getContentTypeForTracking";
|
|
11
|
+
import { getLinkTrackingProperties } from "./getLinkTrackingProperties";
|
|
11
12
|
|
|
12
13
|
type TrackFieldAddedArgs = {
|
|
13
14
|
id: string;
|
|
@@ -25,10 +26,6 @@ export function trackFieldAdded(args: TrackFieldAddedArgs) {
|
|
|
25
26
|
type: field.type,
|
|
26
27
|
isInAGroup,
|
|
27
28
|
contentType: getContentTypeForTracking(window.location.pathname),
|
|
28
|
-
...(field.type === "Link" &&
|
|
29
|
-
allowText: field.config?.allowText,
|
|
30
|
-
repeat: field.config?.repeat,
|
|
31
|
-
variants: field.config?.variants,
|
|
32
|
-
}),
|
|
29
|
+
...(field.type === "Link" && getLinkTrackingProperties(field)),
|
|
33
30
|
});
|
|
34
31
|
}
|
|
@@ -8,6 +8,7 @@ import { telemetry } from "@/apiClient";
|
|
|
8
8
|
import { SlicePrimaryFieldSM } from "@/legacy/lib/models/common/Slice";
|
|
9
9
|
|
|
10
10
|
import { getContentTypeForTracking } from "./getContentTypeForTracking";
|
|
11
|
+
import { getLinkTrackingProperties } from "./getLinkTrackingProperties";
|
|
11
12
|
|
|
12
13
|
type TrackFieldUpdatedArgs = {
|
|
13
14
|
id: string;
|
|
@@ -28,10 +29,6 @@ export function trackFieldUpdated(args: TrackFieldUpdatedArgs) {
|
|
|
28
29
|
type: field.type,
|
|
29
30
|
isInAGroup,
|
|
30
31
|
contentType: getContentTypeForTracking(window.location.pathname),
|
|
31
|
-
...(field.type === "Link" &&
|
|
32
|
-
allowText: field.config?.allowText,
|
|
33
|
-
repeat: field.config?.repeat,
|
|
34
|
-
variants: field.config?.variants,
|
|
35
|
-
}),
|
|
32
|
+
...(field.type === "Link" && getLinkTrackingProperties(field)),
|
|
36
33
|
});
|
|
37
34
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
self.__BUILD_MANIFEST=function(s,c,a,e,t,i,b,n,d,u,f,h,l,k,j,p,g,o,r,m){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/":[s,e,p,g,"static/chunks/pages/index-02dd147957c8b40f.js"],"/_error":["static/chunks/pages/_error-fedd2c6ebd3d27b9.js"],"/changelog":[c,t,"static/chunks/870-a72b74312773efea.js","static/chunks/pages/changelog-80a618708f44f25f.js"],"/changes":[c,i,"static/chunks/8eec4907-b712959d9f984b68.js","static/chunks/918-fa4f2563cb5fd014.js",a,n,"static/css/d98ebc475f8423a3.css","static/chunks/pages/changes-d40c17939854b984.js"],"/custom-types":[s,e,p,g,"static/chunks/pages/custom-types-2a5fd94ee42ba593.js"],"/custom-types/[customTypeId]":[c,d,u,f,h,s,t,b,l,o,a,e,k,j,r,m,"static/chunks/pages/custom-types/[customTypeId]-389d1b7a492fb3e7.js"],"/labs":["static/chunks/pages/labs-c6df252ea5d8fb6f.js"],"/page-types/[pageTypeId]":[c,d,u,f,h,s,t,b,l,o,a,e,k,j,r,m,"static/chunks/pages/page-types/[pageTypeId]-3589bd1f9138a97b.js"],"/settings":[s,"static/css/e5f781f20e24a5ea.css","static/chunks/pages/settings-170379902605f38a.js"],"/slices":[c,i,s,b,a,n,j,"static/css/efa5152b7c0f35c0.css","static/chunks/pages/slices-071bb494907adf0f.js"],"/slices/[lib]/[sliceName]/[variation]":[c,i,d,u,f,h,s,t,b,l,a,k,n,"static/css/cdee5b195444f185.css","static/chunks/pages/slices/[lib]/[sliceName]/[variation]-6de02b8ed13b680d.js"],"/slices/[lib]/[sliceName]/[variation]/simulator":[i,"static/chunks/72585f70-28b4d7d5384b3703.js","static/chunks/157-54b8336d20b41933.js","static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-063fa88ba75f483e.js"],sortedPages:["/","/_app","/_error","/changelog","/changes","/custom-types","/custom-types/[customTypeId]","/labs","/page-types/[pageTypeId]","/settings","/slices","/slices/[lib]/[sliceName]/[variation]","/slices/[lib]/[sliceName]/[variation]/simulator"]}}("static/chunks/397-e6c340070a3bcb41.js","static/chunks/59b4e022-ef680789f7cc9b11.js","static/chunks/34-2911c905c8a6e9d9.js","static/chunks/867-8164160c810122c6.js","static/chunks/183-4ea255b867ff171b.js","static/chunks/c8eae200-966ce352f7b5d2b9.js","static/chunks/44-a2056f993381ad0f.js","static/chunks/658-8231c0b729e0124a.js","static/chunks/f36c6662-1f3a854183168b10.js","static/chunks/4c744e84-480e426e4b1cfef3.js","static/chunks/065a3ddb-9a38ca0d60f0bf2f.js","static/chunks/1cc2734a-09fb3b997ad1eb70.js","static/chunks/349-7118116b93278f73.js","static/chunks/630-93339694ef30b82d.js","static/chunks/268-6d5fc7642a1b87c8.js","static/chunks/895-8c214ba470a4e23c.js","static/css/4e475d945cf8a890.css","static/chunks/385-b949173dfa03dd3e.js","static/chunks/882-28837678beff7e51.js","static/css/56f2a6684a524374.css"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[268],{22654:function(e,t,a){a.d(t,{l:function(){return n}});var r=a(96317);function n(){let e=(0,r.L)("slicemachine-image-to-slice");return{eligible:(null==e?void 0:e.value)==="on"}}},91589:function(e,t,a){a.d(t,{S:function(){return x}});var r=a(52322),n=a(7729),i=a(2784),l=a(88932),s=a(94160),c=a(34166),o=a(63470),u=a(98250),d=a(68968),m=a(80148),g=a(54597),p=a(31860),h=a(62434);function f(e){let{slice:t}=e,a="uploading"===t.status||"generating"===t.status,i="uploadError"===t.status||"generateError"===t.status,l="generateError"===t.status||"generating"===t.status||"success"===t.status;return(0,r.jsxs)(h.Zb,{disabled:a,children:[l?(0,r.jsx)(h.ZB,{src:t.thumbnailUrl}):(0,r.jsx)(h.ZB,{component:"div"}),(0,r.jsx)(h.eW,{loading:a,startIcon:function(e){switch(e){case"uploadError":case"generateError":return"close";case"success":return"check";default:return}}(t.status),title:"success"===t.status?t.model.name:t.image.name,subtitle:function(e){switch(e){case"uploading":return"Uploading...";case"uploadError":return"Unable to upload image";case"generating":return"Generating...";case"generateError":return"Something went wrong";case"success":return"Generated"}}(t.status),error:i,action:i?(0,r.jsx)(n.zxk,{startIcon:"refresh",color:"grey",onClick:t.onRetry,children:"Retry"}):void 0})]})}function x(e){let{open:t,location:a,onSuccess:h,onClose:x}=e,[w,b]=(0,i.useState)([]),[C,A]=(0,i.useState)(!1),{syncChanges:I}=(0,d.g)(),{createSliceSuccess:k}=(0,g.Z)(),{completeStep:E}=(0,u.k)(),U=(0,o.k)(),L=(0,i.useRef)(crypto.randomUUID()),N=e=>{let{index:t,slice:a}=e;b(e=>e.map((e,r)=>r===t?a(e):e))},Z=e=>{if(e.length>10){l.Am.error("You can only upload ".concat(10," images at a time."));return}b(e.map(e=>({status:"uploading",image:e}))),e.forEach((e,t)=>_({index:t,image:e}))},_=e=>{let{index:t,image:a}=e,r=L.current;N({index:t,slice:e=>({...e,status:"uploading"})}),v({image:a}).then(e=>{r===L.current&&D({index:t,imageUrl:e})},()=>{r===L.current&&N({index:t,slice:e=>({...e,status:"uploadError",onRetry:()=>_({index:t,image:a})})})})},z=function(e){let{open:t}=e,a=(0,i.useRef)([]);return(0,i.useEffect)(()=>{t&&(a.current=[],m.managerClient.slices.readAllSlices().then(e=>{a.current=e.models.map(e=>{let{model:t}=e;return t})}).catch(()=>null))},[t]),a}({open:t}),D=e=>{let{index:t,imageUrl:a}=e,r=L.current;N({index:t,slice:e=>({...e,status:"generating",thumbnailUrl:a})}),m.managerClient.customTypes.inferSlice({imageUrl:a}).then(e=>{let{slice:n,langSmithUrl:i}=e;r===L.current&&b(e=>e.map((r,l)=>l===t?{...r,status:"success",thumbnailUrl:a,model:function(e){let{existingSlices:t,newSlices:a,slice:r}=e,n=new Set,i=new Set;for(let{id:e,name:a}of t)n.add(e),i.add(a.toLowerCase());for(let e of a)"success"===e.status&&(n.add(e.model.id),i.add(e.model.name.toLowerCase()));let l=r.id,s=2;for(;n.has(l);)l="".concat(r.id,"_").concat(s),s++;let c=r.name;for(s=2;i.has(c.toLowerCase());)c="".concat(r.name).concat(s),s++;return{...r,id:l,name:c}}({existingSlices:z.current,newSlices:e,slice:n}),langSmithUrl:i}:r))},()=>{r===L.current&&N({index:t,slice:e=>({...e,status:"generateError",thumbnailUrl:a,onRetry:()=>D({index:t,imageUrl:a})})})})},F=w.some(e=>"uploading"===e.status||"generating"===e.status),R=w.filter(e=>"success"===e.status),B=R.length>0;return(0,r.jsxs)(n.VqE,{open:t,onOpenChange:e=>{e||C||(x(),L.current=crypto.randomUUID(),b([]))},children:[(0,r.jsx)(n.fKu,{title:"Generate from image"}),(0,r.jsxs)(n.cZJ,{gap:0,children:[(0,r.jsxs)(n.BeV,{hidden:!0,children:["Upload images to generate ",(0,p._)(U.value)," ","with AI"]}),0===w.length?(0,r.jsx)(n.xuv,{padding:16,height:"100%",children:(0,r.jsx)(n.Zzl,{onFilesSelected:Z,assetType:"image",maxFiles:10,overlay:(0,r.jsx)(y,{onFilesSelected:Z,droppingFiles:!0}),children:(0,r.jsx)(y,{onFilesSelected:Z})})}):(0,r.jsx)(n.xrM,{stableScrollbar:!1,children:(0,r.jsx)(n.xuv,{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,padding:16,children:w.map((e,t)=>(0,r.jsx)(f,{slice:e},"slice-".concat(t)))})}),(0,r.jsxs)(n.kXR,{children:[(0,r.jsx)(n.POh,{disabled:C}),(0,r.jsxs)(n._dX,{disabled:!B||F,loading:C,onClick:()=>{let e=w.reduce((e,t)=>("success"===t.status&&e.push(t),e),[]);if(!e.length)return;let t=L.current;A(!0),j(e).then(async e=>{let{slices:r,library:n}=e;if(t===L.current)for(let{model:e,langSmithUrl:t}of(k((await (0,s.y0)()).libraries),I(),h({slices:r,library:n}),A(!1),L.current=crypto.randomUUID(),b([]),E("createSlice"),r))s.Xe.track({event:"slice:created",id:e.id,name:e.name,library:n,location:a,mode:"ai",langSmithUrl:t}),(0,c.nZ)({type:"model",library:n,sliceId:e.id,variationId:e.variations[0].id,langSmithUrl:t})}).catch(()=>{t===L.current&&(A(!1),l.Am.error("An unexpected error happened while adding slices."))})},children:[S({location:a,sectionsNamingExperiment:U})," (",R.length,")"]})]})]})]})}function y(e){let t=(0,o.k)(),{droppingFiles:a=!1,onFilesSelected:i}=e;return(0,r.jsx)(n.xuv,{justifyContent:"center",flexDirection:"column",height:"100%",backgroundColor:a?"purple2":"grey2",border:!0,borderStyle:"dashed",borderColor:a?"purple9":"grey6",children:(0,r.jsxs)(n.R$c,{children:[(0,r.jsx)(n.avq,{lineColor:"purple11",backgroundColor:"purple5",name:"cloudUpload",size:"large"}),(0,r.jsx)(n._T6,{children:"Upload your design images."}),(0,r.jsxs)(n.nfr,{children:["Once uploaded, you can generate"," ",(0,p._)(t.value)," automatically using AI."]}),(0,r.jsx)(n.QjJ,{children:(0,r.jsx)(n.KH,{startIcon:"attachFile",onFilesSelected:i,color:"grey",children:"Add images"})})]})})}async function v(e){let{image:t}=e,a=[await m.managerClient.project.getResolvedRepositoryName(),"shared-slices","prismic-inferred-slices",crypto.randomUUID()].join("/");await m.managerClient.screenshots.initS3ACL();let{url:r}=await m.managerClient.screenshots.uploadScreenshot({keyPrefix:a,data:t});return r}async function j(e){let{libraries:t=[]}=await m.managerClient.project.getSliceMachineConfig(),a=t[0];if(!a)throw Error("No library found in the config.");for(let{model:t}of e){let{errors:e}=await m.managerClient.slices.createSlice({libraryID:a,model:t});if(e.length)throw Error("Failed to create slice ".concat(t.id,"."))}let r=await Promise.all(e.map(async e=>{let{model:t,image:r,langSmithUrl:n}=e;return await m.managerClient.slices.updateSliceScreenshot({libraryID:a,sliceID:t.id,variationID:t.variations[0].id,data:r}),{model:t,langSmithUrl:n}}));return{library:a,slices:r}}let S=e=>{let{location:t,sectionsNamingExperiment:a}=e;switch(t){case"custom_type":return"Add to type";case"page_type":return"Add to page";case"slices":return"Add to ".concat((0,p._)(a.value))}}},27213:function(e,t,a){a.d(t,{F:function(){return l}});var r=a(52322),n=a(7729),i=a(31860);let l=e=>{let{menuType:t,sectionsNamingExperiment:a}=e;return{fromImage:{BackgroundIcon:(0,r.jsx)(n.AZf,{name:"autoFixHigh",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"purple",variant:"solid",radius:6}),title:"Generate from image",description:"Build a ".concat(a.value," based on your design image.")},fromScratch:{BackgroundIcon:(0,r.jsx)(n.AZf,{name:"add",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"white",variant:"solid",radius:6}),title:"Start from scratch",description:"Build a custom ".concat(a.value," your way.")},fromTemplate:{BackgroundIcon:(0,r.jsx)(n.AZf,{name:"contentCopy",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"white",variant:"solid",radius:6}),title:"Use a template",description:"Choose from ready-made examples."},fromExisting:{BackgroundIcon:(0,r.jsx)(n.AZf,{name:"folder",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"white",variant:"solid",radius:6}),title:"Reuse an existing ".concat(a.value),description:"Select from your created ".concat((0,i._)(a.value))}}}},6256:function(e,t,a){a.d(t,{c:function(){return S}});var r=a(52322),n=a(2784),i=a(36131),l=a(75289),s=a(94160),c=a(63470),o=a(98250),u=a(88932),d=a(63908),m=a(358),g=a(80148);async function p(e){let{sliceName:t,libraryName:a,location:r,onSuccess:n}=e;try{let e=(0,d.fo)(t),{errors:i}=await g.managerClient.slices.createSlice({libraryID:a,model:e});if(i.length>0)throw i;s.Xe.track({event:"slice:created",id:(0,m.MP)(t),name:t,library:a,location:r,mode:"manual"}),await n(e)}catch(a){let e="An unexpected error happened while creating slice ".concat(t,".");console.error(e,a),u.Am.error(e)}}var h=a(68968),f=a(59532),x=a(54597),y=a(31860),v=a(46999),j=a(63019);let S=e=>{let{onClose:t,onSuccess:a,localLibraries:u,location:d,remoteSlices:m}=e,{createSliceSuccess:g}=(0,x.Z)(),[S,w]=(0,n.useState)(!1),{syncChanges:b}=(0,h.g)(),{completeStep:C}=(0,o.k)(),A=(0,c.k)(),I=async e=>{let t=e.sliceName,r=e.from;w(!0),await p({sliceName:t,libraryName:r,location:d,onSuccess:async e=>{g((await (0,s.y0)()).libraries),a(e,r),b(),C("createSlice")}})};return(0,r.jsx)(f.Z,{testId:"create-slice-modal",isOpen:!0,widthInPx:"530px",isLoading:S,formId:"create-new-slice",close:t,buttonLabel:"Create",onSubmit:e=>{I(e)},initialValues:{sliceName:"",from:u[0].name},validate:e=>(0,j.h)(e,u,m),content:{title:"Create a new ".concat(A.value)},children:e=>{let{touched:t,values:a,setFieldValue:n,errors:s}=e;return(0,r.jsxs)(l.xu,{children:[(0,r.jsx)(v.W,{name:"sliceName",label:"".concat((0,y.f)(A.value)," name"),placeholder:"Pascalised ".concat(A.value," API ID (e.g. TextBlock)"),error:t.sliceName?s.sliceName:void 0,testId:"slice-name-input"}),(0,r.jsx)(l.__,{htmlFor:"from",sx:{mb:2},children:"Target Library"}),(0,r.jsx)(i.ZP,{name:"from",options:u.map(e=>({value:e.name,label:e.name})),onChange:e=>e?void n("from",e.value):null,defaultValue:{value:a.from,label:a.from},styles:{option:e=>({...e,color:"#161618"})},theme:e=>({...e,colors:{...e.colors,primary:"#E9E8EA"}}),menuPortalTarget:document.body})]})}})}},63019:function(e,t,a){a.d(t,{h:function(){return c}});var r=a(96009),n=a.n(r),i=a(74600),l=a.n(i),s=a(7974);function c(e,t,a){let{sliceName:r}=e;return r?s.lS.includes(r.toLowerCase())?{sliceName:'Name "'.concat(r,'" is reserved for Slice Machine use.')}:s.xo.exec(r)?l()(n()(r)).replace(/\s/gm,"")!==r.trim()?{sliceName:"Value has to be PascalCased."}:r.match(/^\d/)?{sliceName:"Value cannot start with a number."}:[...t.flatMap(e=>e.components.map(e=>e.model.name)),...a.map(e=>e.name)].includes(r)?{sliceName:"Slice name is already taken."}:void 0:{sliceName:"No special characters allowed."}:{sliceName:"Cannot be empty"}}},21151:function(e,t,a){var r=a(52322),n=a(75289);t.Z=function(e){let{elems:t,renderElem:a,defineElementKey:i,gridTemplateMinPx:l="320px",gridGap:s="16px",sx:c}=e;return(0,r.jsx)(n.xu,{as:"section",sx:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(".concat(l,", 1fr))"),gridGap:s,pt:2,...c},children:t.map((e,t)=>e?(0,r.jsx)("span",{children:a(e,t)},"".concat(i(e),"-").concat(t+1)):null)})}}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[34],{62434:function(e,t,n){"use strict";n.d(t,{Zb:function(){return c},T$:function(){return m},eW:function(){return _},ZB:function(){return u},Lm:function(){return h}});var o=n(52322),r=n(50002),i=n(7729),a=n(6277),l=n(2784),d=n(67968),s=n.n(d);let c=e=>{let{checked:t=!1,size:n="medium",variant:i="solid",interactive:d,disabled:c,onClick:u,href:m,component:_="a",replace:h,...C}=e,x={...C,className:(0,a.W)(s().root,s()["size-".concat(n)],s()[i],{[s().interactive]:e.interactive}),"data-state":!0===t?"checked":void 0,"data-disabled":!0===e.disabled?"":void 0};return!0===e.interactive&&void 0===e.href?(0,o.jsx)("div",{...x,onClick:t=>{if(!0===e.disabled||void 0===e.onClick)return;let n=t.target;(0,r.JY)(n)===t.currentTarget&&e.onClick(t)},tabIndex:!0===e.disabled?void 0:0}):!0===e.interactive?(0,l.createElement)(_,{...x,href:e.href,onClick:e=>{let t=e.target;(0,r.JY)(t)!==e.currentTarget&&e.preventDefault()},..."a"===_?{}:{replace:e.replace}}):(0,o.jsx)("div",{...x})},u=e=>{let{className:t,component:n="img",overlay:r,...i}=e;return(0,o.jsxs)("div",{className:s().media,children:[(0,l.createElement)(n,{...i,className:(0,a.W)(s()["mediaComponent-".concat(n)],t)}),r?(0,o.jsx)("div",{className:s().mediaOverlay,children:r}):void 0]})},m=e=>(0,o.jsx)("div",{...e,className:s().actions}),_=e=>{let{action:t,loading:n=!1,startIcon:r,subtitle:a,title:l,error:d=!1,...c}=e,u=d?"tomato11":"grey11";return(0,o.jsxs)("div",{...c,className:s().footer,children:[(r||n)&&(0,o.jsxs)("div",{className:s().startIconBox,children:[n&&(0,o.jsx)(i._3P,{color:"grey11"}),!n&&r&&(0,o.jsx)(i.JO$,{name:r,size:"small",color:u})]}),(0,o.jsxs)("div",{className:s().footerTexts,children:[(0,o.jsx)(i.xvT,{component:"span",noWrap:!0,variant:"bold",children:l}),(0,o.jsx)(i.xvT,{color:u,component:"span",noWrap:!0,variant:"small",children:a})]}),t]})},h=e=>{let{children:t,...n}=e;return(0,o.jsx)("div",{...n,className:s().status,children:(0,o.jsx)(i.xvT,{align:"center",color:"inherit",component:"span",noWrap:!0,variant:"smallBold",children:t})})}},99195:function(e,t,n){"use strict";n.d(t,{O:function(){return l}});var o=n(52322),r=n(7729),i=n(56448),a=n(93671);let l=e=>{let{badgeColor:t,badgeTitle:n,tooltipContent:l}=function(e){let t=d[e.modelType];switch(e.modelStatus){case i.GJ.New:return{badgeColor:"green",badgeTitle:"New",tooltipContent:"This ".concat(t," exists only locally. Upon sync, it will be pushed to your remote repository.")};case i.GJ.Modified:return{badgeColor:"amber",badgeTitle:"Modified",tooltipContent:"This ".concat(t," has been modified locally. Upon sync, changes will be pushed to your remote repository.")};case i.GJ.Synced:return{badgeColor:"purple",badgeTitle:"Synced",tooltipContent:"This ".concat(t," is in sync with the remote repository.")};case i.GJ.Deleted:return{badgeColor:"tomato",badgeTitle:"Deleted",tooltipContent:"This ".concat(t," has been deleted locally.")};case i.GJ.Unknown:if(!e.isOnline)return{badgeColor:"grey",badgeTitle:"Unknown",tooltipContent:"Data from the remote repository could not be fetched (no internet connection)."};if(e.authStatus===a.t.UNAUTHORIZED)return{badgeColor:"grey",badgeTitle:"Unknown",tooltipContent:"Data from the remote repository could not be fetched (not connected to Prismic)."};if(e.authStatus===a.t.FORBIDDEN)return{badgeColor:"grey",badgeTitle:"Unknown",tooltipContent:"Data from the remote repository could not be fetched (you don't have access to the repository)."};default:return{badgeColor:"grey",badgeTitle:"Unknown",tooltipContent:"Data from the remote repository could not be fetched (unknown error)."}}}(e);return(0,o.jsx)(r.ua7,{content:l,side:"bottom",children:(0,o.jsx)(r.Cts,{color:t,title:n})})},d={CustomType:"type",Slice:"slice"}},51507:function(e,t,n){"use strict";n.d(t,{b:function(){return C}});var o=n(52322),r=n(7729),i=n(39097),a=n.n(i),l=n(62434),d=n(63908),s=n(99195),c=n(27763);let u=e=>(0,o.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,o.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 5.5C4 4.67157 4.67157 4 5.5 4H18.5C19.3284 4 20 4.67157 20 5.5V12.4413C20 12.4512 19.9997 12.461 19.9991 12.4707C20.0072 12.6083 19.9586 12.7485 19.8536 12.8536C19.6583 13.0488 19.3417 13.0488 19.1464 12.8536L16.3536 10.0607C16.1583 9.8654 15.8417 9.8654 15.6464 10.0607L11.8536 13.8536C11.6583 14.0488 11.3417 14.0488 11.1464 13.8536L9.35355 12.0607C9.15829 11.8654 8.84171 11.8654 8.64645 12.0607L5 15.7071V18.5C5 18.7761 5.22386 19 5.5 19H12.5C12.7761 19 13 19.2239 13 19.5C13 19.7761 12.7761 20 12.5 20H5.5C4.67157 20 4 19.3284 4 18.5V15.5003V15.4997V5.5ZM11.5 12.7929L14.9393 9.35355C15.5251 8.76777 16.4749 8.76777 17.0607 9.35355L19 11.2929V5.5C19 5.22386 18.7761 5 18.5 5H5.5C5.22386 5 5 5.22386 5 5.5V14.2929L7.93934 11.3536C8.52513 10.7678 9.47487 10.7678 10.0607 11.3536L11.5 12.7929ZM16.5 13C16.7761 13 17 13.2239 17 13.5V16H19.5C19.7761 16 20 16.2239 20 16.5C20 16.7761 19.7761 17 19.5 17H17V19.5C17 19.7761 16.7761 20 16.5 20C16.2239 20 16 19.7761 16 19.5V17H13.5C13.2239 17 13 16.7761 13 16.5C13 16.2239 13.2239 16 13.5 16H16V13.5C16 13.2239 16.2239 13 16.5 13Z",fill:"currentColor"})}),m=e=>({hash:e.hash}),_=e=>e?Object.entries(e).reduce((e,t)=>{let[n,o]=t;return o.hash?{...e,[n]:{...o,...m(o)}}:e},{}):{},h={build:e=>({...e,screenshots:_(e.screenshots)}),variation(e,t){if(e.model.variations.length)return t?e.model.variations.find(e=>e.id===t):e.model.variations[0]}},C=e=>{let t;let{action:n,isComingSoon:i=!1,isDeleted:m=!1,onUpdateScreenshot:_,selected:C=!1,slice:p,variant:b,variationId:f}=e,g=h.variation(p,f);if(!g)return null;let j=(0,d.d7)(p,g),y=i||m,k=!y&&!!_,S="outlined"===b,T=void 0!==f;return t="selection"===e.mode?{disabled:y,interactive:!0,onClick:()=>{e.onSelectedChange(!C)}}:y?{interactive:!1}:{component:a(),href:c.Y.getBuilderPagePathname({libraryName:p.href,sliceName:p.model.name,variationId:g.id}),interactive:!0,replace:e.replace},(0,o.jsxs)(l.Zb,{"aria-label":"".concat(p.model.name," ").concat(g.name," slice card"),checked:C,"data-testid":"shared-slice-card",...t,..."outlined"===b?{size:"small",variant:"outlined"}:{},children:[void 0!==j?(0,o.jsx)(l.ZB,{alt:"Preview image",overlay:k&&!S?(0,o.jsx)(r.xuv,{alignItems:"center",justifyContent:"center",children:(0,o.jsx)(x,{onClick:_})}):void 0,src:j}):(0,o.jsx)(l.ZB,{component:"div",children:(0,o.jsxs)(r.xuv,{alignItems:"center",flexDirection:"column",gap:8,justifyContent:"center",children:[(0,o.jsx)(r.xvT,{color:"grey11",component:"span",children:"No screenshot available"}),k&&!S?(0,o.jsx)(x,{onClick:_}):void 0]})}),(0,o.jsx)(l.eW,{action:"checkbox"===n.type&&"selection"===e.mode?(0,o.jsx)("div",{onClick:e=>e.stopPropagation(),children:(0,o.jsx)(r.XZJ,{checked:C,disabled:y,onCheckedChange:e.onSelectedChange})}):"menu"===n.type?(0,o.jsxs)(r.h_2,{modal:!0,children:[(0,o.jsx)(r.$FS,{disabled:y,children:(0,o.jsx)(r.hU,{hiddenLabel:"Slice actions",icon:"moreVert"})}),(0,o.jsxs)(r.AWV,{align:"end","data-testid":"slice-action-icon-dropdown",children:[k&&S?(0,o.jsx)(r.Xiv,{onSelect:_,startIcon:(0,o.jsx)(u,{}),children:"Update screenshot"}):void 0,(0,o.jsx)(r.Xiv,{onSelect:n.onRename,startIcon:(0,o.jsx)(r.JO$,{name:"edit"}),children:"Rename"}),!0===n.removeDisabled&&T?(0,o.jsx)(r.ua7,{content:"The slice needs to have at least one variation.",side:"bottom",stableMount:!0,children:(0,o.jsx)(v,{disabled:!0,onSelect:n.onRemove})}):(0,o.jsx)(v,{disabled:!0===n.removeDisabled,onSelect:n.onRemove})]})]}):"remove"===n.type?(0,o.jsx)(r.hU,{icon:"close",onClick:()=>!y&&n.onRemove(),hiddenLabel:"Remove slice"}):"status"===n.type?(0,o.jsx)(s.O,{authStatus:n.authStatus,isOnline:n.isOnline,modelStatus:n.modelStatus,modelType:"Slice"}):void 0,subtitle:(0,o.jsxs)(o.Fragment,{children:[T?g.id:"".concat(p.model.variations.length," variation").concat(p.model.variations.length>1?"s":""),i?(0,o.jsxs)(r.xvT,{color:"purple11",component:"span",variant:"small",children:[" ","• (coming soon)"]}):void 0]}),title:T?g.name:p.model.name}),k&&!T&&(0,d.cx)(p)>0?(0,o.jsx)(l.Lm,{children:"Missing screenshot"}):void 0]})},x=e=>(0,o.jsx)(r.zxk,{onClick:e.onClick,renderStartIcon:()=>(0,o.jsx)(u,{color:r.rSc.color.grey11}),color:"grey",children:"Update screenshot"}),v=e=>(0,o.jsx)(r.Xiv,{...e,color:"tomato",startIcon:(0,o.jsx)(r.JO$,{name:"delete"}),children:"Delete"})},27763:function(e,t,n){"use strict";n.d(t,{Y:function(){return o}});let o={getBuilderPagePathname:e=>"/slices/".concat(e.libraryName.replaceAll("/","--"),"/").concat(e.sliceName,"/").concat(e.variationId)}},30527:function(e,t,n){"use strict";n.d(t,{Z:function(){return s},W:function(){return d}});var o=n(52322),r=n(2784),i=n(75289);let a=e=>{let{bg:t,background:n,sx:r,withRadius:a,radius:l,children:d}=e;return(0,o.jsx)(i.xu,{sx:{p:4,bg:t||n,...a?{borderBottomLeftRadius:l,borderBottomRightRadius:l}:null,...r},children:d})},l=(0,r.createContext)("6px"),d=()=>(0,r.useContext)(l),s=e=>{let{Header:t=null,SubHeader:n=null,Body:r=null,Footer:d=null,borderFooter:s=!1,radius:c="6px",bodySx:u={},footerSx:m={},sx:_=null,bg:h,background:C,children:x,...v}=e;return(0,o.jsx)(l.Provider,{value:c,children:(0,o.jsxs)(i.Zb,{sx:{border:e=>{var t;return"1px solid ".concat(String(null===(t=e.colors)||void 0===t?void 0:t.borders))},borderRadius:c,..._},...v,children:[t||null,n||null,(0,o.jsxs)(a,{bg:h,background:C,sx:u,withRadius:!d,children:[r?(0,o.jsx)(r,{}):null,x||null]}),d?(0,o.jsx)(a,{bg:h,background:C,sx:{...s?{borderTop:e=>{let{colors:t}=e;return"1px solid ".concat(String(null==t?void 0:t.borders))}}:null,...m},radius:c,withRadius:!0,children:"object"==typeof d?d:(0,o.jsx)(d,{})}):null]})})}},7974:function(e,t,n){"use strict";n.d(t,{Sn:function(){return l},lS:function(){return o},nG:function(){return r},pq:function(){return d},rd:function(){return a},xo:function(){return i}});let o=["components","update","insert"],r=["png","jpg","jpeg"],i=/^[A-Za-z0-9]+(?:_[A-Za-z0-9]+)*$/,a="placeholders/What_are_Slices_mrvome",l="SM_HELP_VIDEOS/mock_data",d="slice-machine-simulator"},67968:function(e){e.exports={flex:"Card_flex__opby1",grid:"Card_grid__VAvIS",column:"Card_column__W4ACG Card_flex__opby1",root:"Card_root__YVuvU Card_column__W4ACG Card_flex__opby1","size-small":"Card_size-small__aIlxd","size-medium":"Card_size-medium__xegz0",solid:"Card_solid__GNGar",outlined:"Card_outlined__W_dxI",interactive:"Card_interactive__rXw5L",media:"Card_media__l0kHL Card_column__W4ACG Card_flex__opby1","mediaComponent-div":"Card_mediaComponent-div__Y2_PZ Card_grid__VAvIS","mediaComponent-img":"Card_mediaComponent-img__ezOTu",mediaOverlay:"Card_mediaOverlay__Aa__Q Card_grid__VAvIS",nonMedia:"Card_nonMedia__Fv3Mz Card_flex__opby1",actions:"Card_actions__XdhOt Card_nonMedia__Fv3Mz Card_flex__opby1",footer:"Card_footer__U0HS1 Card_nonMedia__Fv3Mz Card_flex__opby1",footerTexts:"Card_footerTexts__rTXup Card_column__W4ACG Card_flex__opby1",status:"Card_status__PNN2a Card_column__W4ACG Card_flex__opby1",startIconBox:"Card_startIconBox__1_L4u"}}}]);
|