@@ -88,6 +88,11 @@ const props = defineProps({
8888 type: Boolean ,
8989 default: false ,
9090 },
91+ /** Extra values to be provided through the context. */
92+ provide: {
93+ type: Object ,
94+ default : () => ({})
95+ },
9196});
9297
9398const parentContainer = injectContainerContext (containerContextKey);
@@ -176,6 +181,7 @@ watch(
176181
177182const avoidTrackingDirtyState = ref (false );
178183const trackingDirtyState = computed (() => props .trackDirtyState && ! avoidTrackingDirtyState .value )
184+ const isDirty = computed (() => Statamic .$dirty .has (props .name ));
179185
180186function dirty () {
181187 if (trackingDirtyState .value ) Statamic .$dirty .add (props .name );
@@ -236,7 +242,11 @@ function pushComponent(name, { props }) {
236242 return component;
237243}
238244
239- const provided = {
245+ const additionalProvides = Object .fromEntries (
246+ Object .entries (props .provide ).map (([key ]) => [key, toRef (() => props .provide [key])])
247+ );
248+
249+ const builtInProvides = {
240250 name: toRef (() => props .name ),
241251 parentContainer,
242252 blueprint: toRef (() => props .blueprint ),
@@ -268,9 +278,20 @@ const provided = {
268278 setRevealerField,
269279 unsetRevealerField,
270280 setHiddenField,
281+ isDirty,
271282 withoutDirtying,
272283};
273284
285+ if (import .meta.env.DEV) {
286+ for (const key of Object .keys (additionalProvides )) {
287+ if (key in builtInProvides ) {
288+ console .warn (`PublishContainer : provide key "${key }" collides with a built-in context key, which takes precedence.`);
289+ }
290+ }
291+ }
292+
293+ const provided = { ...additionalProvides, ...builtInProvides };
294+
274295provideContainerContext({ ...provided, container: provided });
275296
276297defineExpose({
0 commit comments