@btst/stack 1.1.4 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/node_modules/.pnpm/@radix-ui_react-alert-dialog@1.1.15_@types_react-dom@19.2.2_@types_react@19.2.2__@types_ec789942cd38340bd7362c09e7d34384/node_modules/@radix-ui/react-alert-dialog/dist/index.cjs +182 -0
  2. package/dist/node_modules/.pnpm/@radix-ui_react-alert-dialog@1.1.15_@types_react-dom@19.2.2_@types_react@19.2.2__@types_ec789942cd38340bd7362c09e7d34384/node_modules/@radix-ui/react-alert-dialog/dist/index.mjs +149 -0
  3. package/dist/packages/better-stack/src/plugins/blog/api/plugin.cjs +14 -7
  4. package/dist/packages/better-stack/src/plugins/blog/api/plugin.mjs +14 -7
  5. package/dist/packages/better-stack/src/plugins/blog/client/components/forms/post-forms.cjs +64 -14
  6. package/dist/packages/better-stack/src/plugins/blog/client/components/forms/post-forms.mjs +66 -16
  7. package/dist/packages/better-stack/src/plugins/blog/client/components/pages/edit-post-page.internal.cjs +5 -1
  8. package/dist/packages/better-stack/src/plugins/blog/client/components/pages/edit-post-page.internal.mjs +5 -1
  9. package/dist/packages/better-stack/src/plugins/blog/client/hooks/blog-hooks.cjs +31 -0
  10. package/dist/packages/better-stack/src/plugins/blog/client/hooks/blog-hooks.mjs +31 -1
  11. package/dist/packages/better-stack/src/plugins/blog/client/localization/blog-forms.cjs +8 -0
  12. package/dist/packages/better-stack/src/plugins/blog/client/localization/blog-forms.mjs +8 -0
  13. package/dist/packages/ui/src/components/alert-dialog.cjs +149 -0
  14. package/dist/packages/ui/src/components/alert-dialog.mjs +137 -0
  15. package/dist/plugins/blog/client/hooks/index.cjs +1 -0
  16. package/dist/plugins/blog/client/hooks/index.d.cts +7 -1
  17. package/dist/plugins/blog/client/hooks/index.d.mts +7 -1
  18. package/dist/plugins/blog/client/hooks/index.d.ts +7 -1
  19. package/dist/plugins/blog/client/hooks/index.mjs +1 -1
  20. package/dist/plugins/blog/client/index.d.cts +171 -177
  21. package/dist/plugins/blog/client/index.d.mts +171 -177
  22. package/dist/plugins/blog/client/index.d.ts +171 -177
  23. package/dist/plugins/blog/query-keys.d.cts +1 -0
  24. package/dist/plugins/blog/query-keys.d.mts +1 -0
  25. package/dist/plugins/blog/query-keys.d.ts +1 -0
  26. package/dist/plugins/client/index.d.cts +3 -2
  27. package/dist/plugins/client/index.d.mts +3 -2
  28. package/dist/plugins/client/index.d.ts +3 -2
  29. package/package.json +5 -3
  30. package/src/plugins/blog/api/plugin.ts +14 -6
  31. package/src/plugins/blog/client/components/forms/post-forms.tsx +92 -14
  32. package/src/plugins/blog/client/components/pages/edit-post-page.internal.tsx +6 -0
  33. package/src/plugins/blog/client/hooks/blog-hooks.tsx +38 -0
  34. package/src/plugins/blog/client/localization/blog-forms.ts +10 -0
  35. package/src/plugins/client/index.ts +7 -3
@@ -0,0 +1,182 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ const React = require('react');
5
+ const index$1 = require('../../../../../@radix-ui_react-context@1.1.2_@types_react@19.2.2_react@19.2.0/node_modules/@radix-ui/react-context/dist/index.cjs');
6
+ const index = require('../../../../../@radix-ui_react-compose-refs@1.1.2_@types_react@19.2.2_react@19.2.0/node_modules/@radix-ui/react-compose-refs/dist/index.cjs');
7
+ const DialogPrimitive = require('@radix-ui/react-dialog');
8
+ const index$2 = require('../../../../../@radix-ui_primitive@1.1.3/node_modules/@radix-ui/primitive/dist/index.cjs');
9
+ const reactSlot = require('@radix-ui/react-slot');
10
+ const jsxRuntime = require('react/jsx-runtime');
11
+
12
+ function _interopNamespaceCompat(e) {
13
+ if (e && typeof e === 'object' && 'default' in e) return e;
14
+ const n = Object.create(null);
15
+ if (e) {
16
+ for (const k in e) {
17
+ n[k] = e[k];
18
+ }
19
+ }
20
+ n.default = e;
21
+ return n;
22
+ }
23
+
24
+ const React__namespace = /*#__PURE__*/_interopNamespaceCompat(React);
25
+ const DialogPrimitive__namespace = /*#__PURE__*/_interopNamespaceCompat(DialogPrimitive);
26
+
27
+ var ROOT_NAME = "AlertDialog";
28
+ var [createAlertDialogContext] = index$1.createContextScope(ROOT_NAME, [
29
+ DialogPrimitive.createDialogScope
30
+ ]);
31
+ var useDialogScope = DialogPrimitive.createDialogScope();
32
+ var AlertDialog = (props) => {
33
+ const { __scopeAlertDialog, ...alertDialogProps } = props;
34
+ const dialogScope = useDialogScope(__scopeAlertDialog);
35
+ return /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Root, { ...dialogScope, ...alertDialogProps, modal: true });
36
+ };
37
+ AlertDialog.displayName = ROOT_NAME;
38
+ var TRIGGER_NAME = "AlertDialogTrigger";
39
+ var AlertDialogTrigger = React__namespace.forwardRef(
40
+ (props, forwardedRef) => {
41
+ const { __scopeAlertDialog, ...triggerProps } = props;
42
+ const dialogScope = useDialogScope(__scopeAlertDialog);
43
+ return /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Trigger, { ...dialogScope, ...triggerProps, ref: forwardedRef });
44
+ }
45
+ );
46
+ AlertDialogTrigger.displayName = TRIGGER_NAME;
47
+ var PORTAL_NAME = "AlertDialogPortal";
48
+ var AlertDialogPortal = (props) => {
49
+ const { __scopeAlertDialog, ...portalProps } = props;
50
+ const dialogScope = useDialogScope(__scopeAlertDialog);
51
+ return /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Portal, { ...dialogScope, ...portalProps });
52
+ };
53
+ AlertDialogPortal.displayName = PORTAL_NAME;
54
+ var OVERLAY_NAME = "AlertDialogOverlay";
55
+ var AlertDialogOverlay = React__namespace.forwardRef(
56
+ (props, forwardedRef) => {
57
+ const { __scopeAlertDialog, ...overlayProps } = props;
58
+ const dialogScope = useDialogScope(__scopeAlertDialog);
59
+ return /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Overlay, { ...dialogScope, ...overlayProps, ref: forwardedRef });
60
+ }
61
+ );
62
+ AlertDialogOverlay.displayName = OVERLAY_NAME;
63
+ var CONTENT_NAME = "AlertDialogContent";
64
+ var [AlertDialogContentProvider, useAlertDialogContentContext] = createAlertDialogContext(CONTENT_NAME);
65
+ var Slottable = reactSlot.createSlottable("AlertDialogContent");
66
+ var AlertDialogContent = React__namespace.forwardRef(
67
+ (props, forwardedRef) => {
68
+ const { __scopeAlertDialog, children, ...contentProps } = props;
69
+ const dialogScope = useDialogScope(__scopeAlertDialog);
70
+ const contentRef = React__namespace.useRef(null);
71
+ const composedRefs = index.useComposedRefs(forwardedRef, contentRef);
72
+ const cancelRef = React__namespace.useRef(null);
73
+ return /* @__PURE__ */ jsxRuntime.jsx(
74
+ DialogPrimitive__namespace.WarningProvider,
75
+ {
76
+ contentName: CONTENT_NAME,
77
+ titleName: TITLE_NAME,
78
+ docsSlug: "alert-dialog",
79
+ children: /* @__PURE__ */ jsxRuntime.jsx(AlertDialogContentProvider, { scope: __scopeAlertDialog, cancelRef, children: /* @__PURE__ */ jsxRuntime.jsxs(
80
+ DialogPrimitive__namespace.Content,
81
+ {
82
+ role: "alertdialog",
83
+ ...dialogScope,
84
+ ...contentProps,
85
+ ref: composedRefs,
86
+ onOpenAutoFocus: index$2.composeEventHandlers(contentProps.onOpenAutoFocus, (event) => {
87
+ event.preventDefault();
88
+ cancelRef.current?.focus({ preventScroll: true });
89
+ }),
90
+ onPointerDownOutside: (event) => event.preventDefault(),
91
+ onInteractOutside: (event) => event.preventDefault(),
92
+ children: [
93
+ /* @__PURE__ */ jsxRuntime.jsx(Slottable, { children }),
94
+ /* @__PURE__ */ jsxRuntime.jsx(DescriptionWarning, { contentRef })
95
+ ]
96
+ }
97
+ ) })
98
+ }
99
+ );
100
+ }
101
+ );
102
+ AlertDialogContent.displayName = CONTENT_NAME;
103
+ var TITLE_NAME = "AlertDialogTitle";
104
+ var AlertDialogTitle = React__namespace.forwardRef(
105
+ (props, forwardedRef) => {
106
+ const { __scopeAlertDialog, ...titleProps } = props;
107
+ const dialogScope = useDialogScope(__scopeAlertDialog);
108
+ return /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Title, { ...dialogScope, ...titleProps, ref: forwardedRef });
109
+ }
110
+ );
111
+ AlertDialogTitle.displayName = TITLE_NAME;
112
+ var DESCRIPTION_NAME = "AlertDialogDescription";
113
+ var AlertDialogDescription = React__namespace.forwardRef((props, forwardedRef) => {
114
+ const { __scopeAlertDialog, ...descriptionProps } = props;
115
+ const dialogScope = useDialogScope(__scopeAlertDialog);
116
+ return /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Description, { ...dialogScope, ...descriptionProps, ref: forwardedRef });
117
+ });
118
+ AlertDialogDescription.displayName = DESCRIPTION_NAME;
119
+ var ACTION_NAME = "AlertDialogAction";
120
+ var AlertDialogAction = React__namespace.forwardRef(
121
+ (props, forwardedRef) => {
122
+ const { __scopeAlertDialog, ...actionProps } = props;
123
+ const dialogScope = useDialogScope(__scopeAlertDialog);
124
+ return /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Close, { ...dialogScope, ...actionProps, ref: forwardedRef });
125
+ }
126
+ );
127
+ AlertDialogAction.displayName = ACTION_NAME;
128
+ var CANCEL_NAME = "AlertDialogCancel";
129
+ var AlertDialogCancel = React__namespace.forwardRef(
130
+ (props, forwardedRef) => {
131
+ const { __scopeAlertDialog, ...cancelProps } = props;
132
+ const { cancelRef } = useAlertDialogContentContext(CANCEL_NAME, __scopeAlertDialog);
133
+ const dialogScope = useDialogScope(__scopeAlertDialog);
134
+ const ref = index.useComposedRefs(forwardedRef, cancelRef);
135
+ return /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Close, { ...dialogScope, ...cancelProps, ref });
136
+ }
137
+ );
138
+ AlertDialogCancel.displayName = CANCEL_NAME;
139
+ var DescriptionWarning = ({ contentRef }) => {
140
+ const MESSAGE = `\`${CONTENT_NAME}\` requires a description for the component to be accessible for screen reader users.
141
+
142
+ You can add a description to the \`${CONTENT_NAME}\` by passing a \`${DESCRIPTION_NAME}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
143
+
144
+ Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${CONTENT_NAME}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
145
+
146
+ For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;
147
+ React__namespace.useEffect(() => {
148
+ const hasDescription = document.getElementById(
149
+ contentRef.current?.getAttribute("aria-describedby")
150
+ );
151
+ if (!hasDescription) console.warn(MESSAGE);
152
+ }, [MESSAGE, contentRef]);
153
+ return null;
154
+ };
155
+ var Root2 = AlertDialog;
156
+ var Trigger2 = AlertDialogTrigger;
157
+ var Portal2 = AlertDialogPortal;
158
+ var Overlay2 = AlertDialogOverlay;
159
+ var Content2 = AlertDialogContent;
160
+ var Action = AlertDialogAction;
161
+ var Cancel = AlertDialogCancel;
162
+ var Title2 = AlertDialogTitle;
163
+ var Description2 = AlertDialogDescription;
164
+
165
+ exports.Action = Action;
166
+ exports.AlertDialog = AlertDialog;
167
+ exports.AlertDialogAction = AlertDialogAction;
168
+ exports.AlertDialogCancel = AlertDialogCancel;
169
+ exports.AlertDialogContent = AlertDialogContent;
170
+ exports.AlertDialogDescription = AlertDialogDescription;
171
+ exports.AlertDialogOverlay = AlertDialogOverlay;
172
+ exports.AlertDialogPortal = AlertDialogPortal;
173
+ exports.AlertDialogTitle = AlertDialogTitle;
174
+ exports.AlertDialogTrigger = AlertDialogTrigger;
175
+ exports.Cancel = Cancel;
176
+ exports.Content = Content2;
177
+ exports.Description = Description2;
178
+ exports.Overlay = Overlay2;
179
+ exports.Portal = Portal2;
180
+ exports.Root = Root2;
181
+ exports.Title = Title2;
182
+ exports.Trigger = Trigger2;
@@ -0,0 +1,149 @@
1
+ "use client";
2
+ import * as React from 'react';
3
+ import { createContextScope } from '../../../../../@radix-ui_react-context@1.1.2_@types_react@19.2.2_react@19.2.0/node_modules/@radix-ui/react-context/dist/index.mjs';
4
+ import { useComposedRefs } from '../../../../../@radix-ui_react-compose-refs@1.1.2_@types_react@19.2.2_react@19.2.0/node_modules/@radix-ui/react-compose-refs/dist/index.mjs';
5
+ import * as DialogPrimitive from '@radix-ui/react-dialog';
6
+ import { createDialogScope } from '@radix-ui/react-dialog';
7
+ import { composeEventHandlers } from '../../../../../@radix-ui_primitive@1.1.3/node_modules/@radix-ui/primitive/dist/index.mjs';
8
+ import { createSlottable } from '@radix-ui/react-slot';
9
+ import { jsx, jsxs } from 'react/jsx-runtime';
10
+
11
+ var ROOT_NAME = "AlertDialog";
12
+ var [createAlertDialogContext] = createContextScope(ROOT_NAME, [
13
+ createDialogScope
14
+ ]);
15
+ var useDialogScope = createDialogScope();
16
+ var AlertDialog = (props) => {
17
+ const { __scopeAlertDialog, ...alertDialogProps } = props;
18
+ const dialogScope = useDialogScope(__scopeAlertDialog);
19
+ return /* @__PURE__ */ jsx(DialogPrimitive.Root, { ...dialogScope, ...alertDialogProps, modal: true });
20
+ };
21
+ AlertDialog.displayName = ROOT_NAME;
22
+ var TRIGGER_NAME = "AlertDialogTrigger";
23
+ var AlertDialogTrigger = React.forwardRef(
24
+ (props, forwardedRef) => {
25
+ const { __scopeAlertDialog, ...triggerProps } = props;
26
+ const dialogScope = useDialogScope(__scopeAlertDialog);
27
+ return /* @__PURE__ */ jsx(DialogPrimitive.Trigger, { ...dialogScope, ...triggerProps, ref: forwardedRef });
28
+ }
29
+ );
30
+ AlertDialogTrigger.displayName = TRIGGER_NAME;
31
+ var PORTAL_NAME = "AlertDialogPortal";
32
+ var AlertDialogPortal = (props) => {
33
+ const { __scopeAlertDialog, ...portalProps } = props;
34
+ const dialogScope = useDialogScope(__scopeAlertDialog);
35
+ return /* @__PURE__ */ jsx(DialogPrimitive.Portal, { ...dialogScope, ...portalProps });
36
+ };
37
+ AlertDialogPortal.displayName = PORTAL_NAME;
38
+ var OVERLAY_NAME = "AlertDialogOverlay";
39
+ var AlertDialogOverlay = React.forwardRef(
40
+ (props, forwardedRef) => {
41
+ const { __scopeAlertDialog, ...overlayProps } = props;
42
+ const dialogScope = useDialogScope(__scopeAlertDialog);
43
+ return /* @__PURE__ */ jsx(DialogPrimitive.Overlay, { ...dialogScope, ...overlayProps, ref: forwardedRef });
44
+ }
45
+ );
46
+ AlertDialogOverlay.displayName = OVERLAY_NAME;
47
+ var CONTENT_NAME = "AlertDialogContent";
48
+ var [AlertDialogContentProvider, useAlertDialogContentContext] = createAlertDialogContext(CONTENT_NAME);
49
+ var Slottable = createSlottable("AlertDialogContent");
50
+ var AlertDialogContent = React.forwardRef(
51
+ (props, forwardedRef) => {
52
+ const { __scopeAlertDialog, children, ...contentProps } = props;
53
+ const dialogScope = useDialogScope(__scopeAlertDialog);
54
+ const contentRef = React.useRef(null);
55
+ const composedRefs = useComposedRefs(forwardedRef, contentRef);
56
+ const cancelRef = React.useRef(null);
57
+ return /* @__PURE__ */ jsx(
58
+ DialogPrimitive.WarningProvider,
59
+ {
60
+ contentName: CONTENT_NAME,
61
+ titleName: TITLE_NAME,
62
+ docsSlug: "alert-dialog",
63
+ children: /* @__PURE__ */ jsx(AlertDialogContentProvider, { scope: __scopeAlertDialog, cancelRef, children: /* @__PURE__ */ jsxs(
64
+ DialogPrimitive.Content,
65
+ {
66
+ role: "alertdialog",
67
+ ...dialogScope,
68
+ ...contentProps,
69
+ ref: composedRefs,
70
+ onOpenAutoFocus: composeEventHandlers(contentProps.onOpenAutoFocus, (event) => {
71
+ event.preventDefault();
72
+ cancelRef.current?.focus({ preventScroll: true });
73
+ }),
74
+ onPointerDownOutside: (event) => event.preventDefault(),
75
+ onInteractOutside: (event) => event.preventDefault(),
76
+ children: [
77
+ /* @__PURE__ */ jsx(Slottable, { children }),
78
+ /* @__PURE__ */ jsx(DescriptionWarning, { contentRef })
79
+ ]
80
+ }
81
+ ) })
82
+ }
83
+ );
84
+ }
85
+ );
86
+ AlertDialogContent.displayName = CONTENT_NAME;
87
+ var TITLE_NAME = "AlertDialogTitle";
88
+ var AlertDialogTitle = React.forwardRef(
89
+ (props, forwardedRef) => {
90
+ const { __scopeAlertDialog, ...titleProps } = props;
91
+ const dialogScope = useDialogScope(__scopeAlertDialog);
92
+ return /* @__PURE__ */ jsx(DialogPrimitive.Title, { ...dialogScope, ...titleProps, ref: forwardedRef });
93
+ }
94
+ );
95
+ AlertDialogTitle.displayName = TITLE_NAME;
96
+ var DESCRIPTION_NAME = "AlertDialogDescription";
97
+ var AlertDialogDescription = React.forwardRef((props, forwardedRef) => {
98
+ const { __scopeAlertDialog, ...descriptionProps } = props;
99
+ const dialogScope = useDialogScope(__scopeAlertDialog);
100
+ return /* @__PURE__ */ jsx(DialogPrimitive.Description, { ...dialogScope, ...descriptionProps, ref: forwardedRef });
101
+ });
102
+ AlertDialogDescription.displayName = DESCRIPTION_NAME;
103
+ var ACTION_NAME = "AlertDialogAction";
104
+ var AlertDialogAction = React.forwardRef(
105
+ (props, forwardedRef) => {
106
+ const { __scopeAlertDialog, ...actionProps } = props;
107
+ const dialogScope = useDialogScope(__scopeAlertDialog);
108
+ return /* @__PURE__ */ jsx(DialogPrimitive.Close, { ...dialogScope, ...actionProps, ref: forwardedRef });
109
+ }
110
+ );
111
+ AlertDialogAction.displayName = ACTION_NAME;
112
+ var CANCEL_NAME = "AlertDialogCancel";
113
+ var AlertDialogCancel = React.forwardRef(
114
+ (props, forwardedRef) => {
115
+ const { __scopeAlertDialog, ...cancelProps } = props;
116
+ const { cancelRef } = useAlertDialogContentContext(CANCEL_NAME, __scopeAlertDialog);
117
+ const dialogScope = useDialogScope(__scopeAlertDialog);
118
+ const ref = useComposedRefs(forwardedRef, cancelRef);
119
+ return /* @__PURE__ */ jsx(DialogPrimitive.Close, { ...dialogScope, ...cancelProps, ref });
120
+ }
121
+ );
122
+ AlertDialogCancel.displayName = CANCEL_NAME;
123
+ var DescriptionWarning = ({ contentRef }) => {
124
+ const MESSAGE = `\`${CONTENT_NAME}\` requires a description for the component to be accessible for screen reader users.
125
+
126
+ You can add a description to the \`${CONTENT_NAME}\` by passing a \`${DESCRIPTION_NAME}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
127
+
128
+ Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${CONTENT_NAME}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
129
+
130
+ For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;
131
+ React.useEffect(() => {
132
+ const hasDescription = document.getElementById(
133
+ contentRef.current?.getAttribute("aria-describedby")
134
+ );
135
+ if (!hasDescription) console.warn(MESSAGE);
136
+ }, [MESSAGE, contentRef]);
137
+ return null;
138
+ };
139
+ var Root2 = AlertDialog;
140
+ var Trigger2 = AlertDialogTrigger;
141
+ var Portal2 = AlertDialogPortal;
142
+ var Overlay2 = AlertDialogOverlay;
143
+ var Content2 = AlertDialogContent;
144
+ var Action = AlertDialogAction;
145
+ var Cancel = AlertDialogCancel;
146
+ var Title2 = AlertDialogTitle;
147
+ var Description2 = AlertDialogDescription;
148
+
149
+ export { Action, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, Cancel, Content2 as Content, Description2 as Description, Overlay2 as Overlay, Portal2 as Portal, Root2 as Root, Title2 as Title, Trigger2 as Trigger };
@@ -162,8 +162,8 @@ const blogBackendPlugin = (hooks) => api.defineBackendPlugin({
162
162
  query: PostListQuerySchema
163
163
  },
164
164
  async (ctx) => {
165
- const { query } = ctx;
166
- const context = { query };
165
+ const { query, headers } = ctx;
166
+ const context = { query, headers };
167
167
  const tagCache = createTagCache();
168
168
  const postTagCache = createPostTagCache();
169
169
  try {
@@ -258,7 +258,10 @@ const blogBackendPlugin = (hooks) => api.defineBackendPlugin({
258
258
  body: schemas.createPostSchema
259
259
  },
260
260
  async (ctx) => {
261
- const context = { body: ctx.body };
261
+ const context = {
262
+ body: ctx.body,
263
+ headers: ctx.headers
264
+ };
262
265
  const tagCache = createTagCache();
263
266
  try {
264
267
  if (hooks?.onBeforeCreatePost) {
@@ -322,7 +325,8 @@ const blogBackendPlugin = (hooks) => api.defineBackendPlugin({
322
325
  async (ctx) => {
323
326
  const context = {
324
327
  body: ctx.body,
325
- params: ctx.params
328
+ params: ctx.params,
329
+ headers: ctx.headers
326
330
  };
327
331
  const tagCache = createTagCache();
328
332
  try {
@@ -416,7 +420,10 @@ const blogBackendPlugin = (hooks) => api.defineBackendPlugin({
416
420
  method: "DELETE"
417
421
  },
418
422
  async (ctx) => {
419
- const context = { params: ctx.params };
423
+ const context = {
424
+ params: ctx.params,
425
+ headers: ctx.headers
426
+ };
420
427
  try {
421
428
  if (hooks?.onBeforeDeletePost) {
422
429
  const canDelete = await hooks.onBeforeDeletePost(
@@ -458,8 +465,8 @@ const blogBackendPlugin = (hooks) => api.defineBackendPlugin({
458
465
  query: NextPreviousPostsQuerySchema
459
466
  },
460
467
  async (ctx) => {
461
- const { query } = ctx;
462
- const context = { query };
468
+ const { query, headers } = ctx;
469
+ const context = { query, headers };
463
470
  const tagCache = createTagCache();
464
471
  const postTagCache = createPostTagCache();
465
472
  try {
@@ -160,8 +160,8 @@ const blogBackendPlugin = (hooks) => defineBackendPlugin({
160
160
  query: PostListQuerySchema
161
161
  },
162
162
  async (ctx) => {
163
- const { query } = ctx;
164
- const context = { query };
163
+ const { query, headers } = ctx;
164
+ const context = { query, headers };
165
165
  const tagCache = createTagCache();
166
166
  const postTagCache = createPostTagCache();
167
167
  try {
@@ -256,7 +256,10 @@ const blogBackendPlugin = (hooks) => defineBackendPlugin({
256
256
  body: createPostSchema
257
257
  },
258
258
  async (ctx) => {
259
- const context = { body: ctx.body };
259
+ const context = {
260
+ body: ctx.body,
261
+ headers: ctx.headers
262
+ };
260
263
  const tagCache = createTagCache();
261
264
  try {
262
265
  if (hooks?.onBeforeCreatePost) {
@@ -320,7 +323,8 @@ const blogBackendPlugin = (hooks) => defineBackendPlugin({
320
323
  async (ctx) => {
321
324
  const context = {
322
325
  body: ctx.body,
323
- params: ctx.params
326
+ params: ctx.params,
327
+ headers: ctx.headers
324
328
  };
325
329
  const tagCache = createTagCache();
326
330
  try {
@@ -414,7 +418,10 @@ const blogBackendPlugin = (hooks) => defineBackendPlugin({
414
418
  method: "DELETE"
415
419
  },
416
420
  async (ctx) => {
417
- const context = { params: ctx.params };
421
+ const context = {
422
+ params: ctx.params,
423
+ headers: ctx.headers
424
+ };
418
425
  try {
419
426
  if (hooks?.onBeforeDeletePost) {
420
427
  const canDelete = await hooks.onBeforeDeletePost(
@@ -456,8 +463,8 @@ const blogBackendPlugin = (hooks) => defineBackendPlugin({
456
463
  query: NextPreviousPostsQuerySchema
457
464
  },
458
465
  async (ctx) => {
459
- const { query } = ctx;
460
- const context = { query };
466
+ const { query, headers } = ctx;
467
+ const context = { query, headers };
461
468
  const tagCache = createTagCache();
462
469
  const postTagCache = createPostTagCache();
463
470
  try {
@@ -10,6 +10,7 @@ const _switch = require('../../../../../../../ui/src/components/switch.cjs');
10
10
  const textarea = require('../../../../../../../ui/src/components/textarea.cjs');
11
11
  const blogHooks = require('../../hooks/blog-hooks.cjs');
12
12
  const utils = require('../../../utils.cjs');
13
+ const alertDialog = require('../../../../../../../ui/src/components/alert-dialog.cjs');
13
14
  const zod = require('@hookform/resolvers/zod');
14
15
  const lucideReact = require('lucide-react');
15
16
  const React = require('react');
@@ -307,14 +308,17 @@ const editPostFormPropsAreEqual = (prevProps, nextProps) => {
307
308
  if (prevProps.postSlug !== nextProps.postSlug) return false;
308
309
  if (prevProps.onClose !== nextProps.onClose) return false;
309
310
  if (prevProps.onSuccess !== nextProps.onSuccess) return false;
311
+ if (prevProps.onDelete !== nextProps.onDelete) return false;
310
312
  return true;
311
313
  };
312
314
  const EditPostFormComponent = ({
313
315
  postSlug,
314
316
  onClose,
315
- onSuccess
317
+ onSuccess,
318
+ onDelete
316
319
  }) => {
317
320
  const [featuredImageUploading, setFeaturedImageUploading] = React.useState(false);
321
+ const [deleteDialogOpen, setDeleteDialogOpen] = React.useState(false);
318
322
  const { localization } = context.usePluginOverrides("blog", {
319
323
  localization: index.BLOG_LOCALIZATION
320
324
  });
@@ -341,6 +345,7 @@ const EditPostFormComponent = ({
341
345
  isPending: isUpdatingPost,
342
346
  error: updatePostError
343
347
  } = blogHooks.useUpdatePost();
348
+ const { mutateAsync: deletePost, isPending: isDeletingPost } = blogHooks.useDeletePost();
344
349
  const onSubmit = async (data) => {
345
350
  const updatedPost = await updatePost({
346
351
  id: post.id,
@@ -362,6 +367,17 @@ const EditPostFormComponent = ({
362
367
  published: updatedPost?.published ?? false
363
368
  });
364
369
  };
370
+ const handleDelete = async () => {
371
+ if (!post?.id) return;
372
+ await deletePost({ id: post.id });
373
+ sonner.toast.success(localization.BLOG_FORMS_TOAST_DELETE_SUCCESS);
374
+ setDeleteDialogOpen(false);
375
+ if (onDelete) {
376
+ onDelete();
377
+ } else {
378
+ onClose();
379
+ }
380
+ };
365
381
  const form = reactHookForm.useForm({
366
382
  resolver: zod.zodResolver(schema),
367
383
  defaultValues: {
@@ -378,19 +394,53 @@ const EditPostFormComponent = ({
378
394
  if (!post) {
379
395
  return /* @__PURE__ */ jsxRuntime.jsx(emptyList.EmptyList, { message: localization.BLOG_PAGE_NOT_FOUND_DESCRIPTION });
380
396
  }
381
- return /* @__PURE__ */ jsxRuntime.jsx(
382
- PostFormBody,
383
- {
384
- form,
385
- onSubmit,
386
- submitLabel: isUpdatingPost ? localization.BLOG_FORMS_SUBMIT_UPDATE_PENDING : localization.BLOG_FORMS_SUBMIT_UPDATE_IDLE,
387
- onCancel: onClose,
388
- disabled: isUpdatingPost || featuredImageUploading,
389
- errorMessage: updatePostError?.message,
390
- setFeaturedImageUploading,
391
- initialSlugTouched: !!post?.slug
392
- }
393
- );
397
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
398
+ /* @__PURE__ */ jsxRuntime.jsx(
399
+ PostFormBody,
400
+ {
401
+ form,
402
+ onSubmit,
403
+ submitLabel: isUpdatingPost ? localization.BLOG_FORMS_SUBMIT_UPDATE_PENDING : localization.BLOG_FORMS_SUBMIT_UPDATE_IDLE,
404
+ onCancel: onClose,
405
+ disabled: isUpdatingPost || featuredImageUploading,
406
+ errorMessage: updatePostError?.message,
407
+ setFeaturedImageUploading,
408
+ initialSlugTouched: !!post?.slug
409
+ }
410
+ ),
411
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxRuntime.jsxs(alertDialog.AlertDialog, { open: deleteDialogOpen, onOpenChange: setDeleteDialogOpen, children: [
412
+ /* @__PURE__ */ jsxRuntime.jsx(alertDialog.AlertDialogTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
413
+ button.Button,
414
+ {
415
+ variant: "destructive",
416
+ type: "button",
417
+ disabled: isUpdatingPost || featuredImageUploading || isDeletingPost,
418
+ className: "mt-4",
419
+ children: localization.BLOG_FORMS_DELETE_BUTTON
420
+ }
421
+ ) }),
422
+ /* @__PURE__ */ jsxRuntime.jsxs(alertDialog.AlertDialogContent, { children: [
423
+ /* @__PURE__ */ jsxRuntime.jsxs(alertDialog.AlertDialogHeader, { children: [
424
+ /* @__PURE__ */ jsxRuntime.jsx(alertDialog.AlertDialogTitle, { children: localization.BLOG_FORMS_DELETE_DIALOG_TITLE }),
425
+ /* @__PURE__ */ jsxRuntime.jsx(alertDialog.AlertDialogDescription, { children: localization.BLOG_FORMS_DELETE_DIALOG_DESCRIPTION })
426
+ ] }),
427
+ /* @__PURE__ */ jsxRuntime.jsxs(alertDialog.AlertDialogFooter, { children: [
428
+ /* @__PURE__ */ jsxRuntime.jsx(alertDialog.AlertDialogCancel, { disabled: isDeletingPost, children: localization.BLOG_FORMS_DELETE_DIALOG_CANCEL }),
429
+ /* @__PURE__ */ jsxRuntime.jsx(
430
+ alertDialog.AlertDialogAction,
431
+ {
432
+ onClick: (e) => {
433
+ e.preventDefault();
434
+ void handleDelete();
435
+ },
436
+ disabled: isDeletingPost,
437
+ children: isDeletingPost ? localization.BLOG_FORMS_DELETE_PENDING : localization.BLOG_FORMS_DELETE_DIALOG_CONFIRM
438
+ }
439
+ )
440
+ ] })
441
+ ] })
442
+ ] }) })
443
+ ] });
394
444
  };
395
445
  const EditPostForm = React.memo(
396
446
  EditPostFormComponent,