@slicemachine/adapter-next 0.3.65 → 0.3.66-alpha.aa-adapter-nextjs-support-react-19-types.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/dist/AlternateGrid/typescript.tsx +22 -24
- package/dist/CallToAction/typescript.tsx +12 -14
- package/dist/CustomerLogos/typescript.tsx +10 -12
- package/dist/Hero/typescript.tsx +22 -24
- package/dist/hooks/slice-create.cjs +3 -2
- package/dist/hooks/slice-create.cjs.map +1 -1
- package/dist/hooks/slice-create.js +3 -2
- package/dist/hooks/slice-create.js.map +1 -1
- package/dist/simulator/SliceSimulator.cjs +4 -21
- package/dist/simulator/SliceSimulator.cjs.map +1 -1
- package/dist/simulator/SliceSimulator.d.ts +3 -3
- package/dist/simulator/SliceSimulator.js +4 -4
- package/dist/simulator/SliceSimulator.js.map +1 -1
- package/dist/simulator/SliceSimulatorWrapper.cjs.map +1 -1
- package/dist/simulator/SliceSimulatorWrapper.d.ts +2 -2
- package/dist/simulator/SliceSimulatorWrapper.js.map +1 -1
- package/dist/simulator/react-server/SliceSimulator.cjs +3 -20
- package/dist/simulator/react-server/SliceSimulator.cjs.map +1 -1
- package/dist/simulator/react-server/SliceSimulator.d.ts +2 -2
- package/dist/simulator/react-server/SliceSimulator.js +3 -3
- package/dist/simulator/react-server/SliceSimulator.js.map +1 -1
- package/package.json +6 -5
- package/src/hooks/slice-create.ts +3 -2
- package/src/simulator/SliceSimulator.tsx +7 -7
- package/src/simulator/SliceSimulatorWrapper.tsx +3 -3
- package/src/simulator/react-server/SliceSimulator.tsx +5 -5
|
@@ -5,9 +5,7 @@ import { SliceComponentProps, PrismicRichText } from "@prismicio/react";
|
|
|
5
5
|
export type PascalNameToReplaceProps =
|
|
6
6
|
SliceComponentProps<Content.PascalNameToReplaceSlice>;
|
|
7
7
|
|
|
8
|
-
const PascalNameToReplace = ({
|
|
9
|
-
slice,
|
|
10
|
-
}: PascalNameToReplaceProps): JSX.Element => {
|
|
8
|
+
const PascalNameToReplace = ({ slice }: PascalNameToReplaceProps) => {
|
|
11
9
|
return (
|
|
12
10
|
<section
|
|
13
11
|
data-slice-type={slice.slice_type}
|
|
@@ -90,32 +88,32 @@ const PascalNameToReplace = ({
|
|
|
90
88
|
background-color: #fff;
|
|
91
89
|
color: #333;
|
|
92
90
|
}
|
|
93
|
-
|
|
91
|
+
|
|
94
92
|
.es-alternate-grid__content {
|
|
95
93
|
display: grid;
|
|
96
94
|
gap: 1.5rem;
|
|
97
95
|
grid-auto-flow: dense;
|
|
98
96
|
}
|
|
99
|
-
|
|
97
|
+
|
|
100
98
|
@media (min-width: 640px) {
|
|
101
99
|
.es-alternate-grid__content--with-image {
|
|
102
100
|
grid-template-columns: repeat(2, 1fr);
|
|
103
101
|
}
|
|
104
102
|
}
|
|
105
|
-
|
|
103
|
+
|
|
106
104
|
@media (min-width: 1200px) {
|
|
107
105
|
.es-alternate-grid__content--with-image {
|
|
108
106
|
grid-template-columns: repeat(2, 1fr);
|
|
109
107
|
}
|
|
110
108
|
}
|
|
111
|
-
|
|
109
|
+
|
|
112
110
|
.es-alternate-grid__image {
|
|
113
111
|
width: auto;
|
|
114
112
|
height: auto;
|
|
115
113
|
max-width: 100%;
|
|
116
114
|
align-self: center;
|
|
117
115
|
}
|
|
118
|
-
|
|
116
|
+
|
|
119
117
|
.es-alternate-grid__image--left {
|
|
120
118
|
order: 1;
|
|
121
119
|
}
|
|
@@ -123,7 +121,7 @@ const PascalNameToReplace = ({
|
|
|
123
121
|
.es-alternate-grid__image--left + div {
|
|
124
122
|
order: 2;
|
|
125
123
|
}
|
|
126
|
-
|
|
124
|
+
|
|
127
125
|
.es-alternate-grid__image--right{
|
|
128
126
|
order: 2;
|
|
129
127
|
}
|
|
@@ -131,24 +129,24 @@ const PascalNameToReplace = ({
|
|
|
131
129
|
.es-alternate-grid__image--right + div {
|
|
132
130
|
order: 1;
|
|
133
131
|
}
|
|
134
|
-
|
|
132
|
+
|
|
135
133
|
.es-alternate-grid__primary-content {
|
|
136
134
|
display: grid;
|
|
137
135
|
gap: 2rem;
|
|
138
136
|
}
|
|
139
|
-
|
|
137
|
+
|
|
140
138
|
.es-alternate-grid__primary-content__intro {
|
|
141
139
|
display: grid;
|
|
142
140
|
gap: 0.5rem;
|
|
143
141
|
}
|
|
144
|
-
|
|
142
|
+
|
|
145
143
|
.es-alternate-grid__primary-content__intro__eyebrow {
|
|
146
144
|
color: #8592e0;
|
|
147
145
|
font-size: 1.15rem;
|
|
148
146
|
font-weight: 500;
|
|
149
147
|
margin: 0;
|
|
150
148
|
}
|
|
151
|
-
|
|
149
|
+
|
|
152
150
|
.es-alternate-grid__primary-content__intro__headline {
|
|
153
151
|
font-size: 1.625rem;
|
|
154
152
|
font-weight: 700;
|
|
@@ -157,25 +155,25 @@ const PascalNameToReplace = ({
|
|
|
157
155
|
.es-alternate-grid__primary-content__intro__headline * {
|
|
158
156
|
margin: 0;
|
|
159
157
|
}
|
|
160
|
-
|
|
158
|
+
|
|
161
159
|
@media (min-width: 640px) {
|
|
162
160
|
.es-alternate-grid__primary-content__intro__headline {
|
|
163
161
|
font-size: 2rem;
|
|
164
162
|
}
|
|
165
163
|
}
|
|
166
|
-
|
|
164
|
+
|
|
167
165
|
@media (min-width: 1024px) {
|
|
168
166
|
.es-alternate-grid__primary-content__intro__headline {
|
|
169
167
|
font-size: 2.5rem;
|
|
170
168
|
}
|
|
171
169
|
}
|
|
172
|
-
|
|
170
|
+
|
|
173
171
|
@media (min-width: 1200px) {
|
|
174
172
|
.es-alternate-grid__primary-content__intro__headline {
|
|
175
173
|
font-size: 2.75rem;
|
|
176
174
|
}
|
|
177
175
|
}
|
|
178
|
-
|
|
176
|
+
|
|
179
177
|
.es-alternate-grid__primary-content__intro__description {
|
|
180
178
|
font-size: 1.15rem;
|
|
181
179
|
max-width: 38rem;
|
|
@@ -184,29 +182,29 @@ const PascalNameToReplace = ({
|
|
|
184
182
|
.es-alternate-grid__primary-content__intro__description > p {
|
|
185
183
|
margin: 0;
|
|
186
184
|
}
|
|
187
|
-
|
|
185
|
+
|
|
188
186
|
@media (min-width: 1200px) {
|
|
189
187
|
.es-alternate-grid__primary-content__intro__description {
|
|
190
188
|
font-size: 1.4rem;
|
|
191
189
|
}
|
|
192
190
|
}
|
|
193
|
-
|
|
191
|
+
|
|
194
192
|
.es-alternate-grid__primary-content__items {
|
|
195
193
|
display: grid;
|
|
196
194
|
gap: 2rem;
|
|
197
195
|
}
|
|
198
|
-
|
|
196
|
+
|
|
199
197
|
@media (min-width: 640px) {
|
|
200
198
|
.es-alternate-grid__primary-content__items {
|
|
201
199
|
grid-template-columns: repeat(2, 1fr);
|
|
202
200
|
}
|
|
203
201
|
}
|
|
204
|
-
|
|
202
|
+
|
|
205
203
|
.es-alternate-grid__item {
|
|
206
204
|
display: grid;
|
|
207
205
|
align-content: start;
|
|
208
206
|
}
|
|
209
|
-
|
|
207
|
+
|
|
210
208
|
.es-alternate-grid__item__heading {
|
|
211
209
|
font-weight: 700;
|
|
212
210
|
font-size: 1.17rem;
|
|
@@ -217,11 +215,11 @@ const PascalNameToReplace = ({
|
|
|
217
215
|
.es-alternate-grid__item__heading * {
|
|
218
216
|
margin: 0;
|
|
219
217
|
}
|
|
220
|
-
|
|
218
|
+
|
|
221
219
|
.es-alternate-grid__item__description {
|
|
222
220
|
font-size: 0.9rem;
|
|
223
221
|
}
|
|
224
|
-
|
|
222
|
+
|
|
225
223
|
.es-alternate-grid__item__description * {
|
|
226
224
|
margin: 0;
|
|
227
225
|
}
|
|
@@ -5,9 +5,7 @@ import { PrismicRichText, SliceComponentProps } from "@prismicio/react";
|
|
|
5
5
|
export type PascalNameToReplaceProps =
|
|
6
6
|
SliceComponentProps<Content.PascalNameToReplaceSlice>;
|
|
7
7
|
|
|
8
|
-
const PascalNameToReplace = ({
|
|
9
|
-
slice,
|
|
10
|
-
}: PascalNameToReplaceProps): JSX.Element => {
|
|
8
|
+
const PascalNameToReplace = ({ slice }: PascalNameToReplaceProps) => {
|
|
11
9
|
const alignment = slice.variation === "alignLeft" ? "left" : "center";
|
|
12
10
|
|
|
13
11
|
return (
|
|
@@ -46,49 +44,49 @@ const PascalNameToReplace = ({
|
|
|
46
44
|
.es-bounded {
|
|
47
45
|
padding: 8vw 2rem;
|
|
48
46
|
}
|
|
49
|
-
|
|
47
|
+
|
|
50
48
|
.es-bounded__content {
|
|
51
49
|
margin-left: auto;
|
|
52
50
|
margin-right: auto;
|
|
53
51
|
}
|
|
54
|
-
|
|
52
|
+
|
|
55
53
|
@media screen and (min-width: 640px) {
|
|
56
54
|
.es-bounded__content {
|
|
57
55
|
max-width: 90%;
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
|
-
|
|
58
|
+
|
|
61
59
|
@media screen and (min-width: 896px) {
|
|
62
60
|
.es-bounded__content {
|
|
63
61
|
max-width: 80%;
|
|
64
62
|
}
|
|
65
63
|
}
|
|
66
|
-
|
|
64
|
+
|
|
67
65
|
@media screen and (min-width: 1280px) {
|
|
68
66
|
.es-bounded__content {
|
|
69
67
|
max-width: 75%;
|
|
70
68
|
}
|
|
71
69
|
}
|
|
72
|
-
|
|
70
|
+
|
|
73
71
|
.es-call-to-action {
|
|
74
72
|
font-family: system-ui, sans-serif;
|
|
75
73
|
background-color: #fff;
|
|
76
74
|
color: #333;
|
|
77
75
|
}
|
|
78
|
-
|
|
76
|
+
|
|
79
77
|
.es-call-to-action__image {
|
|
80
78
|
max-width: 14rem;
|
|
81
79
|
height: auto;
|
|
82
80
|
width: auto;
|
|
83
81
|
justify-self: ${alignment};
|
|
84
82
|
}
|
|
85
|
-
|
|
83
|
+
|
|
86
84
|
.es-call-to-action__content {
|
|
87
85
|
display: grid;
|
|
88
86
|
gap: 1rem;
|
|
89
87
|
justify-items: ${alignment};
|
|
90
88
|
}
|
|
91
|
-
|
|
89
|
+
|
|
92
90
|
.es-call-to-action__content__heading {
|
|
93
91
|
font-size: 2rem;
|
|
94
92
|
font-weight: 700;
|
|
@@ -98,13 +96,13 @@ const PascalNameToReplace = ({
|
|
|
98
96
|
.es-call-to-action__content__heading * {
|
|
99
97
|
margin: 0;
|
|
100
98
|
}
|
|
101
|
-
|
|
99
|
+
|
|
102
100
|
.es-call-to-action__content__paragraph {
|
|
103
101
|
font-size: 1.15rem;
|
|
104
102
|
max-width: 38rem;
|
|
105
103
|
text-align: ${alignment};
|
|
106
104
|
}
|
|
107
|
-
|
|
105
|
+
|
|
108
106
|
.es-call-to-action__button {
|
|
109
107
|
justify-self: ${alignment};
|
|
110
108
|
border-radius: 0.25rem;
|
|
@@ -117,7 +115,7 @@ const PascalNameToReplace = ({
|
|
|
117
115
|
background-color: #16745f;
|
|
118
116
|
color: #fff;
|
|
119
117
|
}
|
|
120
|
-
|
|
118
|
+
|
|
121
119
|
.es-call-to-action__button:hover {
|
|
122
120
|
background-color: #0d5e4c;
|
|
123
121
|
}
|
|
@@ -5,9 +5,7 @@ import { PrismicNextLink, PrismicNextImage } from "@prismicio/next";
|
|
|
5
5
|
export type PascalNameToReplaceProps =
|
|
6
6
|
SliceComponentProps<Content.PascalNameToReplaceSlice>;
|
|
7
7
|
|
|
8
|
-
const PascalNameToReplace = ({
|
|
9
|
-
slice,
|
|
10
|
-
}: PascalNameToReplaceProps): JSX.Element => {
|
|
8
|
+
const PascalNameToReplace = ({ slice }: PascalNameToReplaceProps) => {
|
|
11
9
|
return (
|
|
12
10
|
<section
|
|
13
11
|
data-slice-type={slice.slice_type}
|
|
@@ -65,13 +63,13 @@ const PascalNameToReplace = ({
|
|
|
65
63
|
background-color: #f4f0ec;
|
|
66
64
|
color: #333;
|
|
67
65
|
}
|
|
68
|
-
|
|
66
|
+
|
|
69
67
|
.es-customer-logos__content {
|
|
70
68
|
display: grid;
|
|
71
69
|
gap: 2rem;
|
|
72
70
|
justify-items: center;
|
|
73
71
|
}
|
|
74
|
-
|
|
72
|
+
|
|
75
73
|
.es-customer-logos__heading {
|
|
76
74
|
color: #8592e0;
|
|
77
75
|
font-size: 1.5rem;
|
|
@@ -81,8 +79,8 @@ const PascalNameToReplace = ({
|
|
|
81
79
|
|
|
82
80
|
.es-customer-logos__heading * {
|
|
83
81
|
margin: 0;
|
|
84
|
-
}
|
|
85
|
-
|
|
82
|
+
}
|
|
83
|
+
|
|
86
84
|
.es-customer-logos__logos {
|
|
87
85
|
display: grid;
|
|
88
86
|
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
|
|
@@ -92,29 +90,29 @@ const PascalNameToReplace = ({
|
|
|
92
90
|
list-style-type: none;
|
|
93
91
|
width: 100%;
|
|
94
92
|
}
|
|
95
|
-
|
|
93
|
+
|
|
96
94
|
@media (min-width: 1200px) {
|
|
97
95
|
.es-customer-logos__logos {
|
|
98
96
|
margin-left: -3rem;
|
|
99
97
|
}
|
|
100
98
|
}
|
|
101
|
-
|
|
99
|
+
|
|
102
100
|
.es-customer-logos__logo {
|
|
103
101
|
margin: 0;
|
|
104
102
|
display: flex;
|
|
105
103
|
justify-content: center;
|
|
106
104
|
}
|
|
107
|
-
|
|
105
|
+
|
|
108
106
|
@media (min-width: 1200px) {
|
|
109
107
|
.es-customer-logos__logo {
|
|
110
108
|
margin-left: 3rem;
|
|
111
109
|
}
|
|
112
110
|
}
|
|
113
|
-
|
|
111
|
+
|
|
114
112
|
.es-customer-logos__logo__link__image {
|
|
115
113
|
max-width: 10rem;
|
|
116
114
|
}
|
|
117
|
-
|
|
115
|
+
|
|
118
116
|
.es-customer-logos__button {
|
|
119
117
|
justify-self: center;
|
|
120
118
|
text-decoration: underline;
|
package/dist/Hero/typescript.tsx
CHANGED
|
@@ -5,9 +5,7 @@ import { SliceComponentProps, PrismicRichText } from "@prismicio/react";
|
|
|
5
5
|
export type PascalNameToReplaceProps =
|
|
6
6
|
SliceComponentProps<Content.PascalNameToReplaceSlice>;
|
|
7
7
|
|
|
8
|
-
const PascalNameToReplace = ({
|
|
9
|
-
slice,
|
|
10
|
-
}: PascalNameToReplaceProps): JSX.Element => {
|
|
8
|
+
const PascalNameToReplace = ({ slice }: PascalNameToReplaceProps) => {
|
|
11
9
|
return (
|
|
12
10
|
<section
|
|
13
11
|
data-slice-type={slice.slice_type}
|
|
@@ -64,106 +62,106 @@ const PascalNameToReplace = ({
|
|
|
64
62
|
min-width: 0px;
|
|
65
63
|
position: relative;
|
|
66
64
|
}
|
|
67
|
-
|
|
65
|
+
|
|
68
66
|
.es-fullpage-hero {
|
|
69
67
|
font-family: system-ui, sans-serif;
|
|
70
68
|
background-color: #fff;
|
|
71
69
|
color: #333;
|
|
72
70
|
}
|
|
73
|
-
|
|
71
|
+
|
|
74
72
|
.es-fullpage-hero__image {
|
|
75
73
|
max-width: 100%;
|
|
76
74
|
height: auto;
|
|
77
75
|
align-self: center;
|
|
78
76
|
}
|
|
79
|
-
|
|
77
|
+
|
|
80
78
|
.es-fullpage-hero__image--left > div:first-child {
|
|
81
79
|
order: 1;
|
|
82
80
|
}
|
|
83
|
-
|
|
81
|
+
|
|
84
82
|
.es-fullpage-hero__image--left > div:nth-child(2) {
|
|
85
83
|
order: 2;
|
|
86
84
|
}
|
|
87
|
-
|
|
85
|
+
|
|
88
86
|
.es-fullpage-hero__image--right > div:first-child {
|
|
89
87
|
order: 2;
|
|
90
88
|
}
|
|
91
|
-
|
|
89
|
+
|
|
92
90
|
.es-fullpage-hero__image--right > div:nth-child(2) {
|
|
93
91
|
order: 1;
|
|
94
92
|
}
|
|
95
|
-
|
|
93
|
+
|
|
96
94
|
.es-fullpage-hero__content {
|
|
97
95
|
display: flex;
|
|
98
96
|
flex-direction: column;
|
|
99
97
|
gap: 2rem;
|
|
100
98
|
}
|
|
101
|
-
|
|
99
|
+
|
|
102
100
|
.es-fullpage-hero__content-right {
|
|
103
101
|
display: flex;
|
|
104
102
|
flex-direction: column;
|
|
105
103
|
justify-content: space-around;
|
|
106
104
|
padding: 1.5rem;
|
|
107
105
|
}
|
|
108
|
-
|
|
106
|
+
|
|
109
107
|
@media (min-width: 1080px) {
|
|
110
108
|
.es-fullpage-hero__content {
|
|
111
109
|
flex-direction: row;
|
|
112
110
|
}
|
|
113
|
-
|
|
111
|
+
|
|
114
112
|
.es-fullpage-hero__content > div {
|
|
115
113
|
width: 50%;
|
|
116
114
|
}
|
|
117
115
|
}
|
|
118
|
-
|
|
116
|
+
|
|
119
117
|
.es-fullpage-hero__content__intro {
|
|
120
118
|
display: grid;
|
|
121
119
|
gap: 1rem;
|
|
122
120
|
}
|
|
123
|
-
|
|
121
|
+
|
|
124
122
|
.es-fullpage-hero__content__intro__eyebrow {
|
|
125
123
|
color: #47C1AF;
|
|
126
124
|
font-size: 1.15rem;
|
|
127
125
|
font-weight: 500;
|
|
128
126
|
margin: 0;
|
|
129
127
|
}
|
|
130
|
-
|
|
128
|
+
|
|
131
129
|
.es-fullpage-hero__content__intro__headline {
|
|
132
130
|
font-size: 1.625rem;
|
|
133
131
|
font-weight: 700;
|
|
134
132
|
}
|
|
135
|
-
|
|
133
|
+
|
|
136
134
|
.es-fullpage-hero__content__intro__headline * {
|
|
137
135
|
margin: 0;
|
|
138
136
|
}
|
|
139
|
-
|
|
137
|
+
|
|
140
138
|
@media (min-width: 640px) {
|
|
141
139
|
.es-fullpage-hero__content__intro__headline {
|
|
142
140
|
font-size: 2rem;
|
|
143
141
|
}
|
|
144
142
|
}
|
|
145
|
-
|
|
143
|
+
|
|
146
144
|
@media (min-width: 1024px) {
|
|
147
145
|
.es-fullpage-hero__content__intro__headline {
|
|
148
146
|
font-size: 2.5rem;
|
|
149
147
|
}
|
|
150
148
|
}
|
|
151
|
-
|
|
149
|
+
|
|
152
150
|
@media (min-width: 1200px) {
|
|
153
151
|
.es-fullpage-hero__content__intro__headline {
|
|
154
152
|
font-size: 2.75rem;
|
|
155
153
|
}
|
|
156
154
|
}
|
|
157
|
-
|
|
155
|
+
|
|
158
156
|
.es-fullpage-hero__content__intro__description {
|
|
159
157
|
font-size: 1.15rem;
|
|
160
158
|
max-width: 38rem;
|
|
161
159
|
}
|
|
162
|
-
|
|
160
|
+
|
|
163
161
|
.es-fullpage-hero__content__intro__description > p {
|
|
164
162
|
margin: 0;
|
|
165
163
|
}
|
|
166
|
-
|
|
164
|
+
|
|
167
165
|
@media (min-width: 1200px) {
|
|
168
166
|
.es-fullpage-hero__content__intro__description {
|
|
169
167
|
font-size: 1.4rem;
|
|
@@ -180,7 +178,7 @@ const PascalNameToReplace = ({
|
|
|
180
178
|
background-color: #16745f;
|
|
181
179
|
color: #fff;
|
|
182
180
|
}
|
|
183
|
-
|
|
181
|
+
|
|
184
182
|
.es-call-to-action__link:hover {
|
|
185
183
|
background-color: #0d5e4c;
|
|
186
184
|
}
|
|
@@ -20,6 +20,7 @@ const createComponentFile = async ({ data, helpers, actions, options }) => {
|
|
|
20
20
|
contents = data.componentContents;
|
|
21
21
|
} else if (isTypeScriptProject) {
|
|
22
22
|
contents = commonTags.stripIndent`
|
|
23
|
+
import { FC } from "react";
|
|
23
24
|
import { Content } from "@prismicio/client";
|
|
24
25
|
import { SliceComponentProps } from "@prismicio/react";
|
|
25
26
|
|
|
@@ -31,7 +32,7 @@ const createComponentFile = async ({ data, helpers, actions, options }) => {
|
|
|
31
32
|
/**
|
|
32
33
|
* Component for "${data.model.name}" Slices.
|
|
33
34
|
*/
|
|
34
|
-
const ${pascalName} = ({ slice }
|
|
35
|
+
const ${pascalName}: FC<${pascalName}Props> = ({ slice }) => {
|
|
35
36
|
return (
|
|
36
37
|
<section
|
|
37
38
|
data-slice-type={slice.slice_type}
|
|
@@ -49,7 +50,7 @@ const createComponentFile = async ({ data, helpers, actions, options }) => {
|
|
|
49
50
|
/**
|
|
50
51
|
* @typedef {import("@prismicio/client").Content.${pascalName}Slice} ${pascalName}Slice
|
|
51
52
|
* @typedef {import("@prismicio/react").SliceComponentProps<${pascalName}Slice>} ${pascalName}Props
|
|
52
|
-
* @
|
|
53
|
+
* @type {import("react").FC<${pascalName}Props>}
|
|
53
54
|
*/
|
|
54
55
|
const ${pascalName} = ({ slice }) => {
|
|
55
56
|
return (
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-create.cjs","sources":["../../../src/hooks/slice-create.ts"],"sourcesContent":["import type {\n\tSliceCreateHook,\n\tSliceCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tupsertGlobalTypeScriptTypes,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { stripIndent } from \"common-tags\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { getJSFileExtension } from \"../lib/getJSFileExtension\";\nimport { pascalCase } from \"../lib/pascalCase\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdata: SliceCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createComponentFile = async ({\n\tdata,\n\thelpers,\n\tactions,\n\toptions,\n}: Args) => {\n\tconst extension = await getJSFileExtension({ helpers, options, jsx: true });\n\tconst filename = `index.${extension}`;\n\tconst pascalName = pascalCase(data.model.name);\n\n\tlet contents: string;\n\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tif (data.componentContents) {\n\t\tcontents = data.componentContents;\n\t} else if (isTypeScriptProject) {\n\t\tcontents = stripIndent`\n\t\t\timport { Content } from \"@prismicio/client\";\n\t\t\timport { SliceComponentProps } from \"@prismicio/react\";\n\n\t\t\t/**\n\t\t\t * Props for \\`${pascalName}\\`.\n\t\t\t */\n\t\t\texport type ${pascalName}Props = SliceComponentProps<Content.${pascalName}Slice>;\n\n\t\t\t/**\n\t\t\t * Component for \"${data.model.name}\" Slices.\n\t\t\t */\n\t\t\tconst ${pascalName} = ({ slice }
|
|
1
|
+
{"version":3,"file":"slice-create.cjs","sources":["../../../src/hooks/slice-create.ts"],"sourcesContent":["import type {\n\tSliceCreateHook,\n\tSliceCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tupsertGlobalTypeScriptTypes,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { stripIndent } from \"common-tags\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { getJSFileExtension } from \"../lib/getJSFileExtension\";\nimport { pascalCase } from \"../lib/pascalCase\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdata: SliceCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createComponentFile = async ({\n\tdata,\n\thelpers,\n\tactions,\n\toptions,\n}: Args) => {\n\tconst extension = await getJSFileExtension({ helpers, options, jsx: true });\n\tconst filename = `index.${extension}`;\n\tconst pascalName = pascalCase(data.model.name);\n\n\tlet contents: string;\n\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tif (data.componentContents) {\n\t\tcontents = data.componentContents;\n\t} else if (isTypeScriptProject) {\n\t\tcontents = stripIndent`\n\t\t\timport { FC } from \"react\";\n\t\t\timport { Content } from \"@prismicio/client\";\n\t\t\timport { SliceComponentProps } from \"@prismicio/react\";\n\n\t\t\t/**\n\t\t\t * Props for \\`${pascalName}\\`.\n\t\t\t */\n\t\t\texport type ${pascalName}Props = SliceComponentProps<Content.${pascalName}Slice>;\n\n\t\t\t/**\n\t\t\t * Component for \"${data.model.name}\" Slices.\n\t\t\t */\n\t\t\tconst ${pascalName}: FC<${pascalName}Props> = ({ slice }) => {\n\t\t\t\treturn (\n\t\t\t\t\t<section\n\t\t\t\t\t\tdata-slice-type={slice.slice_type}\n\t\t\t\t\t\tdata-slice-variation={slice.variation}\n\t\t\t\t\t>\n\t\t\t\t\t\tPlaceholder component for ${data.model.id} (variation: {slice.variation}) Slices\n\t\t\t\t\t</section>\n\t\t\t\t);\n\t\t\t};\n\n\t\t\texport default ${pascalName}\n\t\t`;\n\t} else {\n\t\tcontents = stripIndent`\n\t\t\t/**\n\t\t\t * @typedef {import(\"@prismicio/client\").Content.${pascalName}Slice} ${pascalName}Slice\n\t\t\t * @typedef {import(\"@prismicio/react\").SliceComponentProps<${pascalName}Slice>} ${pascalName}Props\n\t\t\t * @type {import(\"react\").FC<${pascalName}Props>}\n\t\t\t */\n\t\t\tconst ${pascalName} = ({ slice }) => {\n\t\t\t\treturn (\n\t\t\t\t\t<section\n\t\t\t\t\t\tdata-slice-type={slice.slice_type}\n\t\t\t\t\t\tdata-slice-variation={slice.variation}\n\t\t\t\t\t>\n\t\t\t\t\t\tPlaceholder component for ${data.model.id} (variation: {slice.variation}) Slices\n\t\t\t\t\t</section>\n\t\t\t\t);\n\t\t\t};\n\n\t\t\texport default ${pascalName};\n\t\t`;\n\t}\n\n\tawait writeSliceFile({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\tactions,\n\t\thelpers,\n\t});\n};\n\nexport const sliceCreate: SliceCreateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\twriteSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t}),\n\t\t\tcreateComponentFile({ data, ...context }),\n\t\t]),\n\t);\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t...context,\n\t\t\t}),\n\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t\tactions: context.actions,\n\t\t\t}),\n\t\t]),\n\t);\n};\n"],"names":["getJSFileExtension","pascalCase","checkIsTypeScriptProject","stripIndent","writeSliceFile","rejectIfNecessary","writeSliceModel","upsertSliceLibraryIndexFile","upsertGlobalTypeScriptTypes"],"mappings":";;;;;;;;;AAwBA,MAAM,sBAAsB,OAAO,EAClC,MACA,SACA,SACA,cACU;AACJ,QAAA,YAAY,MAAMA,mBAAAA,mBAAmB,EAAE,SAAS,SAAS,KAAK,MAAM;AAC1E,QAAM,WAAW,SAAS;AAC1B,QAAM,aAAaC,WAAA,WAAW,KAAK,MAAM,IAAI;AAEzC,MAAA;AAEE,QAAA,sBAAsB,MAAMC,kDAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAED,MAAI,KAAK,mBAAmB;AAC3B,eAAW,KAAK;AAAA,aACN,qBAAqB;AACpB,eAAAC,WAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,oBAMO;AAAA;AAAA,iBAEH,iDAAiD;AAAA;AAAA;AAAA,uBAG3C,KAAK,MAAM;AAAA;AAAA,WAEvB,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kCAMK,KAAK,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKzB;AAAA;AAAA,EAAA,OAEZ;AACK,eAAAA,WAAAA;AAAAA;AAAAA,sDAEyC,oBAAoB;AAAA,iEACT,qBAAqB;AAAA,kCACpD;AAAA;AAAA,WAEvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kCAMuB,KAAK,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKzB;AAAA;AAAA,EAEnB;AAEA,QAAMC,kBAAe;AAAA,IACpB,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ;AAAA,IACA;AAAA,IACA,QAAQ,QAAQ;AAAA,IAChB;AAAA,IACA;AAAA,EAAA,CACA;AACF;AAEa,MAAA,cAA8C,OAC1D,MACA,YACG;AAEFC,sCAAA,MAAM,QAAQ,WAAW;AAAA,IACxBC,mBAAgB;AAAA,MACf,WAAW,KAAK;AAAA,MAChB,OAAO,KAAK;AAAA,MACZ,QAAQ,QAAQ,QAAQ;AAAA,MACxB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,IACD,oBAAoB,EAAE,MAAM,GAAG,SAAS;AAAA,EACxC,CAAA,CAAC;AAIFD,sCAAA,MAAM,QAAQ,WAAW;AAAA,IACxBE,wDAA4B;AAAA,MAC3B,WAAW,KAAK;AAAA,MAChB,GAAG;AAAA,IAAA,CACH;AAAA,IACDC,+BAA4B;AAAA,MAC3B,UAAU,QAAQ,QAAQ;AAAA,MAC1B,QAAQ,QAAQ,QAAQ;AAAA,MACxB,SAAS,QAAQ;AAAA,MACjB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,EACD,CAAA,CAAC;AAEJ;;"}
|
|
@@ -18,6 +18,7 @@ const createComponentFile = async ({ data, helpers, actions, options }) => {
|
|
|
18
18
|
contents = data.componentContents;
|
|
19
19
|
} else if (isTypeScriptProject) {
|
|
20
20
|
contents = stripIndent`
|
|
21
|
+
import { FC } from "react";
|
|
21
22
|
import { Content } from "@prismicio/client";
|
|
22
23
|
import { SliceComponentProps } from "@prismicio/react";
|
|
23
24
|
|
|
@@ -29,7 +30,7 @@ const createComponentFile = async ({ data, helpers, actions, options }) => {
|
|
|
29
30
|
/**
|
|
30
31
|
* Component for "${data.model.name}" Slices.
|
|
31
32
|
*/
|
|
32
|
-
const ${pascalName} = ({ slice }
|
|
33
|
+
const ${pascalName}: FC<${pascalName}Props> = ({ slice }) => {
|
|
33
34
|
return (
|
|
34
35
|
<section
|
|
35
36
|
data-slice-type={slice.slice_type}
|
|
@@ -47,7 +48,7 @@ const createComponentFile = async ({ data, helpers, actions, options }) => {
|
|
|
47
48
|
/**
|
|
48
49
|
* @typedef {import("@prismicio/client").Content.${pascalName}Slice} ${pascalName}Slice
|
|
49
50
|
* @typedef {import("@prismicio/react").SliceComponentProps<${pascalName}Slice>} ${pascalName}Props
|
|
50
|
-
* @
|
|
51
|
+
* @type {import("react").FC<${pascalName}Props>}
|
|
51
52
|
*/
|
|
52
53
|
const ${pascalName} = ({ slice }) => {
|
|
53
54
|
return (
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-create.js","sources":["../../../src/hooks/slice-create.ts"],"sourcesContent":["import type {\n\tSliceCreateHook,\n\tSliceCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tupsertGlobalTypeScriptTypes,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { stripIndent } from \"common-tags\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { getJSFileExtension } from \"../lib/getJSFileExtension\";\nimport { pascalCase } from \"../lib/pascalCase\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdata: SliceCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createComponentFile = async ({\n\tdata,\n\thelpers,\n\tactions,\n\toptions,\n}: Args) => {\n\tconst extension = await getJSFileExtension({ helpers, options, jsx: true });\n\tconst filename = `index.${extension}`;\n\tconst pascalName = pascalCase(data.model.name);\n\n\tlet contents: string;\n\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tif (data.componentContents) {\n\t\tcontents = data.componentContents;\n\t} else if (isTypeScriptProject) {\n\t\tcontents = stripIndent`\n\t\t\timport { Content } from \"@prismicio/client\";\n\t\t\timport { SliceComponentProps } from \"@prismicio/react\";\n\n\t\t\t/**\n\t\t\t * Props for \\`${pascalName}\\`.\n\t\t\t */\n\t\t\texport type ${pascalName}Props = SliceComponentProps<Content.${pascalName}Slice>;\n\n\t\t\t/**\n\t\t\t * Component for \"${data.model.name}\" Slices.\n\t\t\t */\n\t\t\tconst ${pascalName} = ({ slice }
|
|
1
|
+
{"version":3,"file":"slice-create.js","sources":["../../../src/hooks/slice-create.ts"],"sourcesContent":["import type {\n\tSliceCreateHook,\n\tSliceCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tupsertGlobalTypeScriptTypes,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { stripIndent } from \"common-tags\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { getJSFileExtension } from \"../lib/getJSFileExtension\";\nimport { pascalCase } from \"../lib/pascalCase\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdata: SliceCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createComponentFile = async ({\n\tdata,\n\thelpers,\n\tactions,\n\toptions,\n}: Args) => {\n\tconst extension = await getJSFileExtension({ helpers, options, jsx: true });\n\tconst filename = `index.${extension}`;\n\tconst pascalName = pascalCase(data.model.name);\n\n\tlet contents: string;\n\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tif (data.componentContents) {\n\t\tcontents = data.componentContents;\n\t} else if (isTypeScriptProject) {\n\t\tcontents = stripIndent`\n\t\t\timport { FC } from \"react\";\n\t\t\timport { Content } from \"@prismicio/client\";\n\t\t\timport { SliceComponentProps } from \"@prismicio/react\";\n\n\t\t\t/**\n\t\t\t * Props for \\`${pascalName}\\`.\n\t\t\t */\n\t\t\texport type ${pascalName}Props = SliceComponentProps<Content.${pascalName}Slice>;\n\n\t\t\t/**\n\t\t\t * Component for \"${data.model.name}\" Slices.\n\t\t\t */\n\t\t\tconst ${pascalName}: FC<${pascalName}Props> = ({ slice }) => {\n\t\t\t\treturn (\n\t\t\t\t\t<section\n\t\t\t\t\t\tdata-slice-type={slice.slice_type}\n\t\t\t\t\t\tdata-slice-variation={slice.variation}\n\t\t\t\t\t>\n\t\t\t\t\t\tPlaceholder component for ${data.model.id} (variation: {slice.variation}) Slices\n\t\t\t\t\t</section>\n\t\t\t\t);\n\t\t\t};\n\n\t\t\texport default ${pascalName}\n\t\t`;\n\t} else {\n\t\tcontents = stripIndent`\n\t\t\t/**\n\t\t\t * @typedef {import(\"@prismicio/client\").Content.${pascalName}Slice} ${pascalName}Slice\n\t\t\t * @typedef {import(\"@prismicio/react\").SliceComponentProps<${pascalName}Slice>} ${pascalName}Props\n\t\t\t * @type {import(\"react\").FC<${pascalName}Props>}\n\t\t\t */\n\t\t\tconst ${pascalName} = ({ slice }) => {\n\t\t\t\treturn (\n\t\t\t\t\t<section\n\t\t\t\t\t\tdata-slice-type={slice.slice_type}\n\t\t\t\t\t\tdata-slice-variation={slice.variation}\n\t\t\t\t\t>\n\t\t\t\t\t\tPlaceholder component for ${data.model.id} (variation: {slice.variation}) Slices\n\t\t\t\t\t</section>\n\t\t\t\t);\n\t\t\t};\n\n\t\t\texport default ${pascalName};\n\t\t`;\n\t}\n\n\tawait writeSliceFile({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\tactions,\n\t\thelpers,\n\t});\n};\n\nexport const sliceCreate: SliceCreateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\twriteSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t}),\n\t\t\tcreateComponentFile({ data, ...context }),\n\t\t]),\n\t);\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t...context,\n\t\t\t}),\n\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\thelpers: context.helpers,\n\t\t\t\tactions: context.actions,\n\t\t\t}),\n\t\t]),\n\t);\n};\n"],"names":[],"mappings":";;;;;;;AAwBA,MAAM,sBAAsB,OAAO,EAClC,MACA,SACA,SACA,cACU;AACJ,QAAA,YAAY,MAAM,mBAAmB,EAAE,SAAS,SAAS,KAAK,MAAM;AAC1E,QAAM,WAAW,SAAS;AAC1B,QAAM,aAAa,WAAW,KAAK,MAAM,IAAI;AAEzC,MAAA;AAEE,QAAA,sBAAsB,MAAM,yBAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAED,MAAI,KAAK,mBAAmB;AAC3B,eAAW,KAAK;AAAA,aACN,qBAAqB;AACpB,eAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAMO;AAAA;AAAA,iBAEH,iDAAiD;AAAA;AAAA;AAAA,uBAG3C,KAAK,MAAM;AAAA;AAAA,WAEvB,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kCAMK,KAAK,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKzB;AAAA;AAAA,EAAA,OAEZ;AACK,eAAA;AAAA;AAAA,sDAEyC,oBAAoB;AAAA,iEACT,qBAAqB;AAAA,kCACpD;AAAA;AAAA,WAEvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kCAMuB,KAAK,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKzB;AAAA;AAAA,EAEnB;AAEA,QAAM,eAAe;AAAA,IACpB,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ;AAAA,IACA;AAAA,IACA,QAAQ,QAAQ;AAAA,IAChB;AAAA,IACA;AAAA,EAAA,CACA;AACF;AAEa,MAAA,cAA8C,OAC1D,MACA,YACG;AAEF,oBAAA,MAAM,QAAQ,WAAW;AAAA,IACxB,gBAAgB;AAAA,MACf,WAAW,KAAK;AAAA,MAChB,OAAO,KAAK;AAAA,MACZ,QAAQ,QAAQ,QAAQ;AAAA,MACxB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,IACD,oBAAoB,EAAE,MAAM,GAAG,SAAS;AAAA,EACxC,CAAA,CAAC;AAIF,oBAAA,MAAM,QAAQ,WAAW;AAAA,IACxB,4BAA4B;AAAA,MAC3B,WAAW,KAAK;AAAA,MAChB,GAAG;AAAA,IAAA,CACH;AAAA,IACD,4BAA4B;AAAA,MAC3B,UAAU,QAAQ,QAAQ;AAAA,MAC1B,QAAQ,QAAQ,QAAQ;AAAA,MACxB,SAAS,QAAQ;AAAA,MACjB,SAAS,QAAQ;AAAA,IAAA,CACjB;AAAA,EACD,CAAA,CAAC;AAEJ;"}
|
|
@@ -3,34 +3,17 @@
|
|
|
3
3
|
"use strict";
|
|
4
4
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
5
5
|
const jsxRuntime = require("react/jsx-runtime");
|
|
6
|
-
const
|
|
6
|
+
const react = require("react");
|
|
7
7
|
const kit = require("@prismicio/simulator/kit");
|
|
8
8
|
const SliceSimulatorWrapper = require("./SliceSimulatorWrapper.cjs");
|
|
9
|
-
function _interopNamespaceDefault(e) {
|
|
10
|
-
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
11
|
-
if (e) {
|
|
12
|
-
for (const k in e) {
|
|
13
|
-
if (k !== "default") {
|
|
14
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: () => e[k]
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
n.default = e;
|
|
23
|
-
return Object.freeze(n);
|
|
24
|
-
}
|
|
25
|
-
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
26
9
|
const simulatorManager = new kit.SimulatorManager();
|
|
27
10
|
const SliceSimulator = ({ background, zIndex, className, ...restProps }) => {
|
|
28
11
|
if (!("sliceZone" in restProps)) {
|
|
29
12
|
throw new Error("A sliceZone prop must be provided when <SliceZone> is rendered in a Client Component. Add a sliceZone prop or convert your simulator to a Server Component with the getSlices helper.");
|
|
30
13
|
}
|
|
31
|
-
const [slices, setSlices] =
|
|
32
|
-
const [message, setMessage] =
|
|
33
|
-
|
|
14
|
+
const [slices, setSlices] = react.useState(() => kit.getDefaultSlices());
|
|
15
|
+
const [message, setMessage] = react.useState(() => kit.getDefaultMessage());
|
|
16
|
+
react.useEffect(() => {
|
|
34
17
|
simulatorManager.state.on(kit.StateEventType.Slices, (_slices) => {
|
|
35
18
|
setSlices(_slices);
|
|
36
19
|
}, "simulator-slices");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceSimulator.cjs","sources":["../../../src/simulator/SliceSimulator.tsx"],"sourcesContent":["\"use client\";\n\nimport
|
|
1
|
+
{"version":3,"file":"SliceSimulator.cjs","sources":["../../../src/simulator/SliceSimulator.tsx"],"sourcesContent":["\"use client\";\n\nimport { ComponentType, FC, useEffect, useState } from \"react\";\n\nimport {\n\tSliceSimulatorProps as BaseSliceSimulatorProps,\n\tSimulatorManager,\n\tSliceSimulatorState,\n\tStateEventType,\n\tgetDefaultMessage,\n\tgetDefaultSlices,\n} from \"@prismicio/simulator/kit\";\n\nimport { SliceSimulatorWrapper } from \"./SliceSimulatorWrapper\";\n\nconst simulatorManager = new SimulatorManager();\n\nexport type SliceSimulatorSliceZoneProps = {\n\tslices: SliceSimulatorState[\"slices\"];\n};\n\nexport type SliceSimulatorProps = {\n\tclassName?: string;\n} & Omit<BaseSliceSimulatorProps, \"state\"> &\n\t(\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * React component to render simulated Slices.\n\t\t\t\t *\n\t\t\t\t * @example\n\t\t\t\t *\n\t\t\t\t * ```tsx\n\t\t\t\t * import { SliceSimulator } from \"@slicemachine/adapter-next/simulator\";\n\t\t\t\t * import { SliceZone } from \"@prismicio/react\";\n\t\t\t\t *\n\t\t\t\t * import { components } from \"../slices\";\n\t\t\t\t *\n\t\t\t\t * <SliceSimulator\n\t\t\t\t * \tsliceZone={({ slices }) => (\n\t\t\t\t * \t\t<SliceZone slices={slices} components={components} />\n\t\t\t\t * \t)}\n\t\t\t\t * />;\n\t\t\t\t * ```\n\t\t\t\t */\n\t\t\t\tsliceZone: ComponentType<SliceSimulatorSliceZoneProps>;\n\t\t }\n\t\t| {\n\t\t\t\tchildren: React.ReactNode;\n\t\t }\n\t);\n\n/**\n * Simulate slices in isolation. The slice simulator enables live slice\n * development in Slice Machine and live previews in the Page Builder.\n */\nexport const SliceSimulator: FC<SliceSimulatorProps> = ({\n\tbackground,\n\tzIndex,\n\tclassName,\n\t...restProps\n}) => {\n\tif (!(\"sliceZone\" in restProps)) {\n\t\tthrow new Error(\n\t\t\t\"A sliceZone prop must be provided when <SliceZone> is rendered in a Client Component. Add a sliceZone prop or convert your simulator to a Server Component with the getSlices helper.\",\n\t\t);\n\t}\n\n\tconst [slices, setSlices] = useState(() => getDefaultSlices());\n\tconst [message, setMessage] = useState(() => getDefaultMessage());\n\n\tuseEffect(() => {\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Slices,\n\t\t\t(_slices) => {\n\t\t\t\tsetSlices(_slices);\n\t\t\t},\n\t\t\t\"simulator-slices\",\n\t\t);\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Message,\n\t\t\t(_message) => {\n\t\t\t\tsetMessage(_message);\n\t\t\t},\n\t\t\t\"simulator-message\",\n\t\t);\n\n\t\tsimulatorManager.init();\n\n\t\treturn () => {\n\t\t\tsimulatorManager.state.off(StateEventType.Slices, \"simulator-slices\");\n\n\t\t\tsimulatorManager.state.off(StateEventType.Message, \"simulator-message\");\n\t\t};\n\t}, []);\n\n\tconst SliceZoneComp = restProps.sliceZone;\n\n\treturn (\n\t\t<SliceSimulatorWrapper\n\t\t\tmessage={message}\n\t\t\thasSlices={slices.length > 0}\n\t\t\tbackground={background}\n\t\t\tzIndex={zIndex}\n\t\t\tclassName={className}\n\t\t>\n\t\t\t<SliceZoneComp slices={slices} />\n\t\t</SliceSimulatorWrapper>\n\t);\n};\n"],"names":["useEffect"],"mappings":";;;;;;;;AAeA;AAwCa;AAMR;AACG;AACkL;AAIzL;AACA;AAEAA;AACC;AAGE;AAAiB;AAInB;AAGE;AAAmB;AAKrB;AAEA;AACC;AAEA;AAAsE;AAAA;AAIxE;AAEA;AAWD;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ComponentType, FC } from "react";
|
|
2
2
|
import { SliceSimulatorProps as BaseSliceSimulatorProps, SliceSimulatorState } from "@prismicio/simulator/kit";
|
|
3
3
|
export type SliceSimulatorSliceZoneProps = {
|
|
4
4
|
slices: SliceSimulatorState["slices"];
|
|
@@ -24,7 +24,7 @@ export type SliceSimulatorProps = {
|
|
|
24
24
|
* />;
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
|
-
sliceZone:
|
|
27
|
+
sliceZone: ComponentType<SliceSimulatorSliceZoneProps>;
|
|
28
28
|
} | {
|
|
29
29
|
children: React.ReactNode;
|
|
30
30
|
});
|
|
@@ -32,4 +32,4 @@ export type SliceSimulatorProps = {
|
|
|
32
32
|
* Simulate slices in isolation. The slice simulator enables live slice
|
|
33
33
|
* development in Slice Machine and live previews in the Page Builder.
|
|
34
34
|
*/
|
|
35
|
-
export declare const SliceSimulator:
|
|
35
|
+
export declare const SliceSimulator: FC<SliceSimulatorProps>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
'use client';
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
import
|
|
4
|
+
import { useState, useEffect } from "react";
|
|
5
5
|
import { SimulatorManager, getDefaultSlices, getDefaultMessage, StateEventType } from "@prismicio/simulator/kit";
|
|
6
6
|
import { SliceSimulatorWrapper } from "./SliceSimulatorWrapper.js";
|
|
7
7
|
const simulatorManager = new SimulatorManager();
|
|
@@ -9,9 +9,9 @@ const SliceSimulator = ({ background, zIndex, className, ...restProps }) => {
|
|
|
9
9
|
if (!("sliceZone" in restProps)) {
|
|
10
10
|
throw new Error("A sliceZone prop must be provided when <SliceZone> is rendered in a Client Component. Add a sliceZone prop or convert your simulator to a Server Component with the getSlices helper.");
|
|
11
11
|
}
|
|
12
|
-
const [slices, setSlices] =
|
|
13
|
-
const [message, setMessage] =
|
|
14
|
-
|
|
12
|
+
const [slices, setSlices] = useState(() => getDefaultSlices());
|
|
13
|
+
const [message, setMessage] = useState(() => getDefaultMessage());
|
|
14
|
+
useEffect(() => {
|
|
15
15
|
simulatorManager.state.on(StateEventType.Slices, (_slices) => {
|
|
16
16
|
setSlices(_slices);
|
|
17
17
|
}, "simulator-slices");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceSimulator.js","sources":["../../../src/simulator/SliceSimulator.tsx"],"sourcesContent":["\"use client\";\n\nimport
|
|
1
|
+
{"version":3,"file":"SliceSimulator.js","sources":["../../../src/simulator/SliceSimulator.tsx"],"sourcesContent":["\"use client\";\n\nimport { ComponentType, FC, useEffect, useState } from \"react\";\n\nimport {\n\tSliceSimulatorProps as BaseSliceSimulatorProps,\n\tSimulatorManager,\n\tSliceSimulatorState,\n\tStateEventType,\n\tgetDefaultMessage,\n\tgetDefaultSlices,\n} from \"@prismicio/simulator/kit\";\n\nimport { SliceSimulatorWrapper } from \"./SliceSimulatorWrapper\";\n\nconst simulatorManager = new SimulatorManager();\n\nexport type SliceSimulatorSliceZoneProps = {\n\tslices: SliceSimulatorState[\"slices\"];\n};\n\nexport type SliceSimulatorProps = {\n\tclassName?: string;\n} & Omit<BaseSliceSimulatorProps, \"state\"> &\n\t(\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * React component to render simulated Slices.\n\t\t\t\t *\n\t\t\t\t * @example\n\t\t\t\t *\n\t\t\t\t * ```tsx\n\t\t\t\t * import { SliceSimulator } from \"@slicemachine/adapter-next/simulator\";\n\t\t\t\t * import { SliceZone } from \"@prismicio/react\";\n\t\t\t\t *\n\t\t\t\t * import { components } from \"../slices\";\n\t\t\t\t *\n\t\t\t\t * <SliceSimulator\n\t\t\t\t * \tsliceZone={({ slices }) => (\n\t\t\t\t * \t\t<SliceZone slices={slices} components={components} />\n\t\t\t\t * \t)}\n\t\t\t\t * />;\n\t\t\t\t * ```\n\t\t\t\t */\n\t\t\t\tsliceZone: ComponentType<SliceSimulatorSliceZoneProps>;\n\t\t }\n\t\t| {\n\t\t\t\tchildren: React.ReactNode;\n\t\t }\n\t);\n\n/**\n * Simulate slices in isolation. The slice simulator enables live slice\n * development in Slice Machine and live previews in the Page Builder.\n */\nexport const SliceSimulator: FC<SliceSimulatorProps> = ({\n\tbackground,\n\tzIndex,\n\tclassName,\n\t...restProps\n}) => {\n\tif (!(\"sliceZone\" in restProps)) {\n\t\tthrow new Error(\n\t\t\t\"A sliceZone prop must be provided when <SliceZone> is rendered in a Client Component. Add a sliceZone prop or convert your simulator to a Server Component with the getSlices helper.\",\n\t\t);\n\t}\n\n\tconst [slices, setSlices] = useState(() => getDefaultSlices());\n\tconst [message, setMessage] = useState(() => getDefaultMessage());\n\n\tuseEffect(() => {\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Slices,\n\t\t\t(_slices) => {\n\t\t\t\tsetSlices(_slices);\n\t\t\t},\n\t\t\t\"simulator-slices\",\n\t\t);\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Message,\n\t\t\t(_message) => {\n\t\t\t\tsetMessage(_message);\n\t\t\t},\n\t\t\t\"simulator-message\",\n\t\t);\n\n\t\tsimulatorManager.init();\n\n\t\treturn () => {\n\t\t\tsimulatorManager.state.off(StateEventType.Slices, \"simulator-slices\");\n\n\t\t\tsimulatorManager.state.off(StateEventType.Message, \"simulator-message\");\n\t\t};\n\t}, []);\n\n\tconst SliceZoneComp = restProps.sliceZone;\n\n\treturn (\n\t\t<SliceSimulatorWrapper\n\t\t\tmessage={message}\n\t\t\thasSlices={slices.length > 0}\n\t\t\tbackground={background}\n\t\t\tzIndex={zIndex}\n\t\t\tclassName={className}\n\t\t>\n\t\t\t<SliceZoneComp slices={slices} />\n\t\t</SliceSimulatorWrapper>\n\t);\n};\n"],"names":[],"mappings":";;;;;;AAeA;AAwCa;AAMR;AACG;AACkL;AAIzL;AACA;AAEA;AACC;AAGE;AAAiB;AAInB;AAGE;AAAmB;AAKrB;AAEA;AACC;AAEA;AAAsE;AAAA;AAIxE;AAEA;AAWD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceSimulatorWrapper.cjs","sources":["../../../src/simulator/SliceSimulatorWrapper.tsx"],"sourcesContent":["import { ReactNode } from \"react\";\nimport {\n\tSliceSimulatorProps,\n\tdisableEventHandler,\n\tgetDefaultProps,\n\tonClickHandler,\n\tsimulatorClass,\n\tsimulatorRootClass,\n} from \"@prismicio/simulator/kit\";\n\ntype SliceSimulatorWrapperProps = {\n\tchildren: ReactNode;\n\tclassName?: string;\n\tmessage?: string;\n\thasSlices: boolean;\n} & Omit<SliceSimulatorProps, \"state\">;\n\n/**\n * A wrapper for the slice simulator that isolates the given children from the\n * page's layout.\n */\nexport const SliceSimulatorWrapper = ({\n\tclassName,\n\tchildren,\n\tzIndex,\n\tbackground,\n\tmessage,\n\thasSlices,\n}
|
|
1
|
+
{"version":3,"file":"SliceSimulatorWrapper.cjs","sources":["../../../src/simulator/SliceSimulatorWrapper.tsx"],"sourcesContent":["import { FC, ReactNode } from \"react\";\nimport {\n\tSliceSimulatorProps,\n\tdisableEventHandler,\n\tgetDefaultProps,\n\tonClickHandler,\n\tsimulatorClass,\n\tsimulatorRootClass,\n} from \"@prismicio/simulator/kit\";\n\ntype SliceSimulatorWrapperProps = {\n\tchildren: ReactNode;\n\tclassName?: string;\n\tmessage?: string;\n\thasSlices: boolean;\n} & Omit<SliceSimulatorProps, \"state\">;\n\n/**\n * A wrapper for the slice simulator that isolates the given children from the\n * page's layout.\n */\nexport const SliceSimulatorWrapper: FC<SliceSimulatorWrapperProps> = ({\n\tclassName,\n\tchildren,\n\tzIndex,\n\tbackground,\n\tmessage,\n\thasSlices,\n}) => {\n\tconst defaultProps = getDefaultProps();\n\n\treturn (\n\t\t<div\n\t\t\tclassName={[simulatorClass, className].filter(Boolean).join(\" \")}\n\t\t\tstyle={{\n\t\t\t\tzIndex:\n\t\t\t\t\ttypeof zIndex === \"undefined\"\n\t\t\t\t\t\t? defaultProps.zIndex\n\t\t\t\t\t\t: zIndex ?? undefined,\n\t\t\t\tposition: \"fixed\",\n\t\t\t\ttop: 0,\n\t\t\t\tleft: 0,\n\t\t\t\twidth: \"100%\",\n\t\t\t\theight: \"100vh\",\n\t\t\t\toverflow: \"auto\",\n\t\t\t\tbackground:\n\t\t\t\t\ttypeof background === \"undefined\"\n\t\t\t\t\t\t? defaultProps.background\n\t\t\t\t\t\t: background ?? undefined,\n\t\t\t}}\n\t\t>\n\t\t\t{message ? (\n\t\t\t\t<article dangerouslySetInnerHTML={{ __html: message }} />\n\t\t\t) : hasSlices ? (\n\t\t\t\t<div\n\t\t\t\t\tid=\"root\"\n\t\t\t\t\tclassName={simulatorRootClass}\n\t\t\t\t\tonClickCapture={onClickHandler as unknown as React.MouseEventHandler}\n\t\t\t\t\tonSubmitCapture={\n\t\t\t\t\t\tdisableEventHandler as unknown as React.FormEventHandler\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</div>\n\t\t\t) : null}\n\t\t</div>\n\t);\n};\n"],"names":["getDefaultProps","_jsx","simulatorClass","simulatorRootClass","onClickHandler","disableEventHandler"],"mappings":";;;;AAqBa,MAAA,wBAAwD,CAAC,EACrE,WACA,UACA,QACA,YACA,SACA,gBACI;AACJ,QAAM,eAAeA,IAAAA;AAErB,SACCC,wBACC,WAAW,CAACC,IAAAA,gBAAgB,SAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,GAC/D,OAAO;AAAA,IACN,QACC,OAAO,WAAW,cACf,aAAa,SACb,UAAU;AAAA,IACd,UAAU;AAAA,IACV,KAAK;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,YACC,OAAO,eAAe,cACnB,aAAa,aACb,cAAc;AAAA,EAGlB,GAAA,UAAA,UACAD,WAAA,IAAS,WAAA,EAAA,yBAAyB,EAAE,QAAQ,QAAS,EAAA,CAAA,IAClD,YACHA,WAAAA,IAAA,OAAA,EACC,IAAG,QACH,WAAWE,IAAAA,oBACX,gBAAgBC,IAAAA,gBAChB,iBACCC,IAAwD,qBAAA,SAAA,CAGhD,IAEP,KACC,CAAA;AAER;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
1
|
+
import { FC, ReactNode } from "react";
|
|
2
2
|
import { SliceSimulatorProps } from "@prismicio/simulator/kit";
|
|
3
3
|
type SliceSimulatorWrapperProps = {
|
|
4
4
|
children: ReactNode;
|
|
@@ -10,5 +10,5 @@ type SliceSimulatorWrapperProps = {
|
|
|
10
10
|
* A wrapper for the slice simulator that isolates the given children from the
|
|
11
11
|
* page's layout.
|
|
12
12
|
*/
|
|
13
|
-
export declare const SliceSimulatorWrapper:
|
|
13
|
+
export declare const SliceSimulatorWrapper: FC<SliceSimulatorWrapperProps>;
|
|
14
14
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceSimulatorWrapper.js","sources":["../../../src/simulator/SliceSimulatorWrapper.tsx"],"sourcesContent":["import { ReactNode } from \"react\";\nimport {\n\tSliceSimulatorProps,\n\tdisableEventHandler,\n\tgetDefaultProps,\n\tonClickHandler,\n\tsimulatorClass,\n\tsimulatorRootClass,\n} from \"@prismicio/simulator/kit\";\n\ntype SliceSimulatorWrapperProps = {\n\tchildren: ReactNode;\n\tclassName?: string;\n\tmessage?: string;\n\thasSlices: boolean;\n} & Omit<SliceSimulatorProps, \"state\">;\n\n/**\n * A wrapper for the slice simulator that isolates the given children from the\n * page's layout.\n */\nexport const SliceSimulatorWrapper = ({\n\tclassName,\n\tchildren,\n\tzIndex,\n\tbackground,\n\tmessage,\n\thasSlices,\n}
|
|
1
|
+
{"version":3,"file":"SliceSimulatorWrapper.js","sources":["../../../src/simulator/SliceSimulatorWrapper.tsx"],"sourcesContent":["import { FC, ReactNode } from \"react\";\nimport {\n\tSliceSimulatorProps,\n\tdisableEventHandler,\n\tgetDefaultProps,\n\tonClickHandler,\n\tsimulatorClass,\n\tsimulatorRootClass,\n} from \"@prismicio/simulator/kit\";\n\ntype SliceSimulatorWrapperProps = {\n\tchildren: ReactNode;\n\tclassName?: string;\n\tmessage?: string;\n\thasSlices: boolean;\n} & Omit<SliceSimulatorProps, \"state\">;\n\n/**\n * A wrapper for the slice simulator that isolates the given children from the\n * page's layout.\n */\nexport const SliceSimulatorWrapper: FC<SliceSimulatorWrapperProps> = ({\n\tclassName,\n\tchildren,\n\tzIndex,\n\tbackground,\n\tmessage,\n\thasSlices,\n}) => {\n\tconst defaultProps = getDefaultProps();\n\n\treturn (\n\t\t<div\n\t\t\tclassName={[simulatorClass, className].filter(Boolean).join(\" \")}\n\t\t\tstyle={{\n\t\t\t\tzIndex:\n\t\t\t\t\ttypeof zIndex === \"undefined\"\n\t\t\t\t\t\t? defaultProps.zIndex\n\t\t\t\t\t\t: zIndex ?? undefined,\n\t\t\t\tposition: \"fixed\",\n\t\t\t\ttop: 0,\n\t\t\t\tleft: 0,\n\t\t\t\twidth: \"100%\",\n\t\t\t\theight: \"100vh\",\n\t\t\t\toverflow: \"auto\",\n\t\t\t\tbackground:\n\t\t\t\t\ttypeof background === \"undefined\"\n\t\t\t\t\t\t? defaultProps.background\n\t\t\t\t\t\t: background ?? undefined,\n\t\t\t}}\n\t\t>\n\t\t\t{message ? (\n\t\t\t\t<article dangerouslySetInnerHTML={{ __html: message }} />\n\t\t\t) : hasSlices ? (\n\t\t\t\t<div\n\t\t\t\t\tid=\"root\"\n\t\t\t\t\tclassName={simulatorRootClass}\n\t\t\t\t\tonClickCapture={onClickHandler as unknown as React.MouseEventHandler}\n\t\t\t\t\tonSubmitCapture={\n\t\t\t\t\t\tdisableEventHandler as unknown as React.FormEventHandler\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</div>\n\t\t\t) : null}\n\t\t</div>\n\t);\n};\n"],"names":["_jsx"],"mappings":";;AAqBa,MAAA,wBAAwD,CAAC,EACrE,WACA,UACA,QACA,YACA,SACA,gBACI;AACJ,QAAM,eAAe;AAErB,SACCA,aACC,WAAW,CAAC,gBAAgB,SAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,GAC/D,OAAO;AAAA,IACN,QACC,OAAO,WAAW,cACf,aAAa,SACb,UAAU;AAAA,IACd,UAAU;AAAA,IACV,KAAK;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,YACC,OAAO,eAAe,cACnB,aAAa,aACb,cAAc;AAAA,EAGlB,GAAA,UAAA,UACAA,IAAS,WAAA,EAAA,yBAAyB,EAAE,QAAQ,QAAS,EAAA,CAAA,IAClD,YACHA,IAAA,OAAA,EACC,IAAG,QACH,WAAW,oBACX,gBAAgB,gBAChB,iBACC,qBAAwD,SAAA,CAGhD,IAEP,KACC,CAAA;AAER;"}
|
|
@@ -3,37 +3,20 @@
|
|
|
3
3
|
"use strict";
|
|
4
4
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
5
5
|
const jsxRuntime = require("react/jsx-runtime");
|
|
6
|
-
const
|
|
6
|
+
const react = require("react");
|
|
7
7
|
const navigation = require("next/navigation");
|
|
8
8
|
const kit = require("@prismicio/simulator/kit");
|
|
9
9
|
const lzString = require("lz-string");
|
|
10
10
|
const SliceSimulatorWrapper = require("../SliceSimulatorWrapper.cjs");
|
|
11
11
|
const getSlices = require("./getSlices.cjs");
|
|
12
|
-
function _interopNamespaceDefault(e) {
|
|
13
|
-
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
14
|
-
if (e) {
|
|
15
|
-
for (const k in e) {
|
|
16
|
-
if (k !== "default") {
|
|
17
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
18
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: () => e[k]
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
n.default = e;
|
|
26
|
-
return Object.freeze(n);
|
|
27
|
-
}
|
|
28
|
-
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
29
12
|
const STATE_PARAMS_KEY = "state";
|
|
30
13
|
const simulatorManager = new kit.SimulatorManager();
|
|
31
14
|
const SliceSimulator = ({ children, background, zIndex, className }) => {
|
|
32
|
-
const [message, setMessage] =
|
|
15
|
+
const [message, setMessage] = react.useState(() => kit.getDefaultMessage());
|
|
33
16
|
const router = navigation.useRouter();
|
|
34
17
|
const state = typeof window !== "undefined" ? new URL(window.location.href).searchParams.get(STATE_PARAMS_KEY) : void 0;
|
|
35
18
|
const hasSlices = getSlices.getSlices(state).length > 0;
|
|
36
|
-
|
|
19
|
+
react.useEffect(() => {
|
|
37
20
|
simulatorManager.state.on(kit.StateEventType.Slices, (newSlices) => {
|
|
38
21
|
const url = new URL(window.location.href);
|
|
39
22
|
url.searchParams.set(STATE_PARAMS_KEY, lzString.compressToEncodedURIComponent(JSON.stringify(newSlices)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceSimulator.cjs","sources":["../../../../src/simulator/react-server/SliceSimulator.tsx"],"sourcesContent":["// This `<SliceSimulator>` is only accessible from Server Components.\n\n\"use client\";\n\nimport
|
|
1
|
+
{"version":3,"file":"SliceSimulator.cjs","sources":["../../../../src/simulator/react-server/SliceSimulator.tsx"],"sourcesContent":["// This `<SliceSimulator>` is only accessible from Server Components.\n\n\"use client\";\n\nimport { FC, useEffect, useState } from \"react\";\n\nimport { useRouter } from \"next/navigation\";\nimport {\n\tSliceSimulatorProps as BaseSliceSimulatorProps,\n\tSimulatorManager,\n\tStateEventType,\n\tgetDefaultMessage,\n} from \"@prismicio/simulator/kit\";\nimport { compressToEncodedURIComponent } from \"lz-string\";\n\nimport { SliceSimulatorWrapper } from \"../SliceSimulatorWrapper\";\nimport { getSlices } from \"./getSlices\";\n\nconst STATE_PARAMS_KEY = \"state\";\n\nconst simulatorManager = new SimulatorManager();\n\nexport type SliceSimulatorProps = Omit<BaseSliceSimulatorProps, \"state\"> & {\n\tchildren: React.ReactNode;\n\tclassName?: string;\n};\n\nexport const SliceSimulator: FC<SliceSimulatorProps> = ({\n\tchildren,\n\tbackground,\n\tzIndex,\n\tclassName,\n}) => {\n\tconst [message, setMessage] = useState(() => getDefaultMessage());\n\tconst router = useRouter();\n\n\tconst state =\n\t\ttypeof window !== \"undefined\"\n\t\t\t? new URL(window.location.href).searchParams.get(STATE_PARAMS_KEY)\n\t\t\t: undefined;\n\tconst hasSlices = getSlices(state).length > 0;\n\n\tuseEffect(() => {\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Slices,\n\t\t\t(newSlices) => {\n\t\t\t\tconst url = new URL(window.location.href);\n\t\t\t\turl.searchParams.set(\n\t\t\t\t\tSTATE_PARAMS_KEY,\n\t\t\t\t\tcompressToEncodedURIComponent(JSON.stringify(newSlices)),\n\t\t\t\t);\n\n\t\t\t\twindow.history.replaceState(null, \"\", url);\n\t\t\t\t// Wait until the next tick to prevent URL state race conditions.\n\t\t\t\tsetTimeout(() => router.refresh(), 0);\n\t\t\t},\n\t\t\t\"simulator-slices\",\n\t\t);\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Message,\n\t\t\t(newMessage) => setMessage(newMessage),\n\t\t\t\"simulator-message\",\n\t\t);\n\n\t\tsimulatorManager.init();\n\n\t\treturn () => {\n\t\t\tsimulatorManager.state.off(StateEventType.Slices, \"simulator-slices\");\n\n\t\t\tsimulatorManager.state.off(StateEventType.Message, \"simulator-message\");\n\t\t};\n\t}, []);\n\n\treturn (\n\t\t<SliceSimulatorWrapper\n\t\t\tmessage={message}\n\t\t\thasSlices={hasSlices}\n\t\t\tbackground={background}\n\t\t\tzIndex={zIndex}\n\t\t\tclassName={className}\n\t\t>\n\t\t\t{children}\n\t\t</SliceSimulatorWrapper>\n\t);\n};\n"],"names":["useEffect"],"mappings":";;;;;;;;;;;AAkBA;AAEA;AAOO;AAMN;AACA;AAEA;AAIA;AAEAA;AACC;AAGE;AACI;AAKJ;AAEA;AAAoC;AAIrB;AAMjB;AAEA;AACC;AAEA;AAAsE;AAAA;AAKvE;AAUF;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC } from "react";
|
|
2
2
|
import { SliceSimulatorProps as BaseSliceSimulatorProps } from "@prismicio/simulator/kit";
|
|
3
3
|
export type SliceSimulatorProps = Omit<BaseSliceSimulatorProps, "state"> & {
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
className?: string;
|
|
6
6
|
};
|
|
7
|
-
export declare const SliceSimulator:
|
|
7
|
+
export declare const SliceSimulator: FC<SliceSimulatorProps>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
'use client';
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
import
|
|
4
|
+
import { useState, useEffect } from "react";
|
|
5
5
|
import { useRouter } from "next/navigation";
|
|
6
6
|
import { SimulatorManager, getDefaultMessage, StateEventType } from "@prismicio/simulator/kit";
|
|
7
7
|
import { compressToEncodedURIComponent } from "lz-string";
|
|
@@ -10,11 +10,11 @@ import { getSlices } from "./getSlices.js";
|
|
|
10
10
|
const STATE_PARAMS_KEY = "state";
|
|
11
11
|
const simulatorManager = new SimulatorManager();
|
|
12
12
|
const SliceSimulator = ({ children, background, zIndex, className }) => {
|
|
13
|
-
const [message, setMessage] =
|
|
13
|
+
const [message, setMessage] = useState(() => getDefaultMessage());
|
|
14
14
|
const router = useRouter();
|
|
15
15
|
const state = typeof window !== "undefined" ? new URL(window.location.href).searchParams.get(STATE_PARAMS_KEY) : void 0;
|
|
16
16
|
const hasSlices = getSlices(state).length > 0;
|
|
17
|
-
|
|
17
|
+
useEffect(() => {
|
|
18
18
|
simulatorManager.state.on(StateEventType.Slices, (newSlices) => {
|
|
19
19
|
const url = new URL(window.location.href);
|
|
20
20
|
url.searchParams.set(STATE_PARAMS_KEY, compressToEncodedURIComponent(JSON.stringify(newSlices)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceSimulator.js","sources":["../../../../src/simulator/react-server/SliceSimulator.tsx"],"sourcesContent":["// This `<SliceSimulator>` is only accessible from Server Components.\n\n\"use client\";\n\nimport
|
|
1
|
+
{"version":3,"file":"SliceSimulator.js","sources":["../../../../src/simulator/react-server/SliceSimulator.tsx"],"sourcesContent":["// This `<SliceSimulator>` is only accessible from Server Components.\n\n\"use client\";\n\nimport { FC, useEffect, useState } from \"react\";\n\nimport { useRouter } from \"next/navigation\";\nimport {\n\tSliceSimulatorProps as BaseSliceSimulatorProps,\n\tSimulatorManager,\n\tStateEventType,\n\tgetDefaultMessage,\n} from \"@prismicio/simulator/kit\";\nimport { compressToEncodedURIComponent } from \"lz-string\";\n\nimport { SliceSimulatorWrapper } from \"../SliceSimulatorWrapper\";\nimport { getSlices } from \"./getSlices\";\n\nconst STATE_PARAMS_KEY = \"state\";\n\nconst simulatorManager = new SimulatorManager();\n\nexport type SliceSimulatorProps = Omit<BaseSliceSimulatorProps, \"state\"> & {\n\tchildren: React.ReactNode;\n\tclassName?: string;\n};\n\nexport const SliceSimulator: FC<SliceSimulatorProps> = ({\n\tchildren,\n\tbackground,\n\tzIndex,\n\tclassName,\n}) => {\n\tconst [message, setMessage] = useState(() => getDefaultMessage());\n\tconst router = useRouter();\n\n\tconst state =\n\t\ttypeof window !== \"undefined\"\n\t\t\t? new URL(window.location.href).searchParams.get(STATE_PARAMS_KEY)\n\t\t\t: undefined;\n\tconst hasSlices = getSlices(state).length > 0;\n\n\tuseEffect(() => {\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Slices,\n\t\t\t(newSlices) => {\n\t\t\t\tconst url = new URL(window.location.href);\n\t\t\t\turl.searchParams.set(\n\t\t\t\t\tSTATE_PARAMS_KEY,\n\t\t\t\t\tcompressToEncodedURIComponent(JSON.stringify(newSlices)),\n\t\t\t\t);\n\n\t\t\t\twindow.history.replaceState(null, \"\", url);\n\t\t\t\t// Wait until the next tick to prevent URL state race conditions.\n\t\t\t\tsetTimeout(() => router.refresh(), 0);\n\t\t\t},\n\t\t\t\"simulator-slices\",\n\t\t);\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Message,\n\t\t\t(newMessage) => setMessage(newMessage),\n\t\t\t\"simulator-message\",\n\t\t);\n\n\t\tsimulatorManager.init();\n\n\t\treturn () => {\n\t\t\tsimulatorManager.state.off(StateEventType.Slices, \"simulator-slices\");\n\n\t\t\tsimulatorManager.state.off(StateEventType.Message, \"simulator-message\");\n\t\t};\n\t}, []);\n\n\treturn (\n\t\t<SliceSimulatorWrapper\n\t\t\tmessage={message}\n\t\t\thasSlices={hasSlices}\n\t\t\tbackground={background}\n\t\t\tzIndex={zIndex}\n\t\t\tclassName={className}\n\t\t>\n\t\t\t{children}\n\t\t</SliceSimulatorWrapper>\n\t);\n};\n"],"names":[],"mappings":";;;;;;;;;AAkBA;AAEA;AAOO;AAMN;AACA;AAEA;AAIA;AAEA;AACC;AAGE;AACI;AAKJ;AAEA;AAAoC;AAIrB;AAMjB;AAEA;AACC;AAEA;AAAsE;AAAA;AAKvE;AAUF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slicemachine/adapter-next",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.66-alpha.aa-adapter-nextjs-support-react-19-types.1",
|
|
4
4
|
"description": "Slice Machine adapter for Next.js.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@prismicio/simulator": "^0.1.4",
|
|
70
70
|
"@prismicio/types-internal": "3.3.0",
|
|
71
|
-
"@slicemachine/plugin-kit": "0.4.
|
|
71
|
+
"@slicemachine/plugin-kit": "0.4.65-alpha.aa-adapter-nextjs-support-react-19-types.1",
|
|
72
72
|
"common-tags": "^1.8.2",
|
|
73
73
|
"fp-ts": "^2.13.1",
|
|
74
74
|
"io-ts": "^2.2.20",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"@prismicio/mock": "0.2.0",
|
|
83
83
|
"@size-limit/preset-small-lib": "8.2.4",
|
|
84
84
|
"@types/common-tags": "1.8.1",
|
|
85
|
-
"@types/react": "
|
|
85
|
+
"@types/react": "19.0.8",
|
|
86
86
|
"@typescript-eslint/eslint-plugin": "5.55.0",
|
|
87
87
|
"@typescript-eslint/parser": "5.55.0",
|
|
88
88
|
"@vitejs/plugin-react": "3.1.0",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"prettier": "3.0.3",
|
|
97
97
|
"prettier-plugin-jsdoc": "1.1.1",
|
|
98
98
|
"prismic-ts-codegen": "0.1.23",
|
|
99
|
-
"react": "
|
|
99
|
+
"react": "19.0.0",
|
|
100
100
|
"rollup-plugin-preserve-directives": "0.2.0",
|
|
101
101
|
"size-limit": "8.2.4",
|
|
102
102
|
"typescript": "4.9.5",
|
|
@@ -113,5 +113,6 @@
|
|
|
113
113
|
},
|
|
114
114
|
"publishConfig": {
|
|
115
115
|
"access": "public"
|
|
116
|
-
}
|
|
116
|
+
},
|
|
117
|
+
"stableVersion": "0.3.65"
|
|
117
118
|
}
|
|
@@ -43,6 +43,7 @@ const createComponentFile = async ({
|
|
|
43
43
|
contents = data.componentContents;
|
|
44
44
|
} else if (isTypeScriptProject) {
|
|
45
45
|
contents = stripIndent`
|
|
46
|
+
import { FC } from "react";
|
|
46
47
|
import { Content } from "@prismicio/client";
|
|
47
48
|
import { SliceComponentProps } from "@prismicio/react";
|
|
48
49
|
|
|
@@ -54,7 +55,7 @@ const createComponentFile = async ({
|
|
|
54
55
|
/**
|
|
55
56
|
* Component for "${data.model.name}" Slices.
|
|
56
57
|
*/
|
|
57
|
-
const ${pascalName} = ({ slice }
|
|
58
|
+
const ${pascalName}: FC<${pascalName}Props> = ({ slice }) => {
|
|
58
59
|
return (
|
|
59
60
|
<section
|
|
60
61
|
data-slice-type={slice.slice_type}
|
|
@@ -72,7 +73,7 @@ const createComponentFile = async ({
|
|
|
72
73
|
/**
|
|
73
74
|
* @typedef {import("@prismicio/client").Content.${pascalName}Slice} ${pascalName}Slice
|
|
74
75
|
* @typedef {import("@prismicio/react").SliceComponentProps<${pascalName}Slice>} ${pascalName}Props
|
|
75
|
-
* @
|
|
76
|
+
* @type {import("react").FC<${pascalName}Props>}
|
|
76
77
|
*/
|
|
77
78
|
const ${pascalName} = ({ slice }) => {
|
|
78
79
|
return (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { ComponentType, FC, useEffect, useState } from "react";
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
SliceSimulatorProps as BaseSliceSimulatorProps,
|
|
@@ -42,7 +42,7 @@ export type SliceSimulatorProps = {
|
|
|
42
42
|
* />;
|
|
43
43
|
* ```
|
|
44
44
|
*/
|
|
45
|
-
sliceZone:
|
|
45
|
+
sliceZone: ComponentType<SliceSimulatorSliceZoneProps>;
|
|
46
46
|
}
|
|
47
47
|
| {
|
|
48
48
|
children: React.ReactNode;
|
|
@@ -53,22 +53,22 @@ export type SliceSimulatorProps = {
|
|
|
53
53
|
* Simulate slices in isolation. The slice simulator enables live slice
|
|
54
54
|
* development in Slice Machine and live previews in the Page Builder.
|
|
55
55
|
*/
|
|
56
|
-
export const SliceSimulator = ({
|
|
56
|
+
export const SliceSimulator: FC<SliceSimulatorProps> = ({
|
|
57
57
|
background,
|
|
58
58
|
zIndex,
|
|
59
59
|
className,
|
|
60
60
|
...restProps
|
|
61
|
-
}
|
|
61
|
+
}) => {
|
|
62
62
|
if (!("sliceZone" in restProps)) {
|
|
63
63
|
throw new Error(
|
|
64
64
|
"A sliceZone prop must be provided when <SliceZone> is rendered in a Client Component. Add a sliceZone prop or convert your simulator to a Server Component with the getSlices helper.",
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
const [slices, setSlices] =
|
|
69
|
-
const [message, setMessage] =
|
|
68
|
+
const [slices, setSlices] = useState(() => getDefaultSlices());
|
|
69
|
+
const [message, setMessage] = useState(() => getDefaultMessage());
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
useEffect(() => {
|
|
72
72
|
simulatorManager.state.on(
|
|
73
73
|
StateEventType.Slices,
|
|
74
74
|
(_slices) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
1
|
+
import { FC, ReactNode } from "react";
|
|
2
2
|
import {
|
|
3
3
|
SliceSimulatorProps,
|
|
4
4
|
disableEventHandler,
|
|
@@ -19,14 +19,14 @@ type SliceSimulatorWrapperProps = {
|
|
|
19
19
|
* A wrapper for the slice simulator that isolates the given children from the
|
|
20
20
|
* page's layout.
|
|
21
21
|
*/
|
|
22
|
-
export const SliceSimulatorWrapper = ({
|
|
22
|
+
export const SliceSimulatorWrapper: FC<SliceSimulatorWrapperProps> = ({
|
|
23
23
|
className,
|
|
24
24
|
children,
|
|
25
25
|
zIndex,
|
|
26
26
|
background,
|
|
27
27
|
message,
|
|
28
28
|
hasSlices,
|
|
29
|
-
}
|
|
29
|
+
}) => {
|
|
30
30
|
const defaultProps = getDefaultProps();
|
|
31
31
|
|
|
32
32
|
return (
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
"use client";
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import { FC, useEffect, useState } from "react";
|
|
6
6
|
|
|
7
7
|
import { useRouter } from "next/navigation";
|
|
8
8
|
import {
|
|
@@ -25,13 +25,13 @@ export type SliceSimulatorProps = Omit<BaseSliceSimulatorProps, "state"> & {
|
|
|
25
25
|
className?: string;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
export const SliceSimulator = ({
|
|
28
|
+
export const SliceSimulator: FC<SliceSimulatorProps> = ({
|
|
29
29
|
children,
|
|
30
30
|
background,
|
|
31
31
|
zIndex,
|
|
32
32
|
className,
|
|
33
|
-
}
|
|
34
|
-
const [message, setMessage] =
|
|
33
|
+
}) => {
|
|
34
|
+
const [message, setMessage] = useState(() => getDefaultMessage());
|
|
35
35
|
const router = useRouter();
|
|
36
36
|
|
|
37
37
|
const state =
|
|
@@ -40,7 +40,7 @@ export const SliceSimulator = ({
|
|
|
40
40
|
: undefined;
|
|
41
41
|
const hasSlices = getSlices(state).length > 0;
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
useEffect(() => {
|
|
44
44
|
simulatorManager.state.on(
|
|
45
45
|
StateEventType.Slices,
|
|
46
46
|
(newSlices) => {
|