@brightsideoy/kama 1.0.0-alpha.32 → 1.0.0-alpha.33
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/content/definitions/blocks/form.yaml +4 -4
- package/dist/assets/AssetEditor-Vu5cl6lr.js +1 -0
- package/dist/assets/CmsFieldTaxonomy-DRTQyTPC.js +1 -0
- package/dist/assets/CmsHelp-PptHvDLD.js +1 -0
- package/dist/assets/CmsImagePreview-DLYdN_0R.js +1 -0
- package/dist/assets/CmsListItem-B6mUoOIw.js +1 -0
- package/dist/assets/{preload-helper-BxFQpwa9.css → CmsListItem-BxVd9_U4.css} +1 -1
- package/dist/assets/CmsPublisher-CR5-YF5j.js +3 -0
- package/dist/assets/EditorSplitPreview-D4gkVuhL.js +1 -0
- package/dist/assets/FormsWorkspace-BgGgVexq.css +1 -0
- package/dist/assets/FormsWorkspace-DtjET7gT.js +2 -0
- package/dist/assets/NodeContextMenu-CP45tlaT.js +1 -0
- package/dist/assets/NodeEditor-CPH0rWvI.css +1 -0
- package/dist/assets/NodeEditor-otvWuidQ.js +4 -0
- package/dist/assets/RteFloatingToolbar-Dvaqq7Vr.js +158 -0
- package/dist/assets/RteFloatingToolbar-mfTSuSyi.css +1 -0
- package/dist/assets/TrashWorkspace-D42-jimc.js +1 -0
- package/dist/assets/{plus-7rv1C56N.js → arrow-right-C5IFL4zO.js} +1 -1
- package/dist/assets/clock-ChD9Pw4R.js +1 -0
- package/dist/assets/external-link-BR6PVQJR.js +1 -0
- package/dist/assets/{globe-TuZP0v6A.js → folder-tree-C9FLiwU1.js} +1 -1
- package/dist/assets/globe-Cc-HpKJl.js +1 -0
- package/dist/assets/{rotate-ccw-DvjWccJd.js → image-CG70efEv.js} +1 -1
- package/dist/assets/index-CGcczV4D.js +14 -0
- package/dist/assets/info-CG1rlb3x.js +1 -0
- package/dist/assets/plus-8qyrJDmU.js +1 -0
- package/dist/assets/preload-helper-Bjj569kd.js +1 -0
- package/dist/assets/preload-helper-CsLomdVG.css +1 -0
- package/dist/assets/refresh-cw-ldhcYUWO.js +1 -0
- package/dist/assets/rotate-ccw-aSXT_vpV.js +1 -0
- package/dist/assets/send-CIIg_931.js +1 -0
- package/dist/assets/useNodes-CoHDhaah.js +1 -0
- package/dist/assets/useTaxonomies-_-T_4Iu-.js +1 -0
- package/dist/assets/x-Ds3gRwZk.js +1 -0
- package/dist/{dist-CpYaG9eL.js → dist-DHy8KsJ-.js} +200 -116
- package/dist/index.html +22 -12
- package/dist/index.js +203 -117
- package/dist/schema-compiler.js +1 -1
- package/documentation/FORMS.md +59 -25
- package/package.json +1 -1
- package/templates/astro-starter/src/components/blocks/Form.astro +48 -4
- package/templates/astro-starter/src/pages/api/forms/[...path].ts +23 -4
- package/dist/assets/AssetEditor-CAvQEsBT.js +0 -1
- package/dist/assets/CmsAccordion-91I5Rx5D.css +0 -1
- package/dist/assets/CmsAccordion-BgdaB8QZ.js +0 -1
- package/dist/assets/CmsFieldTaxonomy-CNY3-MbD.js +0 -1
- package/dist/assets/CmsHelp-DtPeURCv.js +0 -1
- package/dist/assets/CmsImagePreview-BhM7S_v8.js +0 -1
- package/dist/assets/CmsPublisher-DiQhfPID.js +0 -3
- package/dist/assets/EditorSplitPreview-BfGni85I.js +0 -1
- package/dist/assets/FormsWorkspace-CGs6eUjz.css +0 -1
- package/dist/assets/FormsWorkspace-CUK-y2dR.js +0 -2
- package/dist/assets/NodeContextMenu-C5RTK0sr.js +0 -1
- package/dist/assets/NodeEditor-C2meZIvc.css +0 -1
- package/dist/assets/NodeEditor-C5VQu52a.js +0 -161
- package/dist/assets/TrashWorkspace-t0lOrFRK.js +0 -1
- package/dist/assets/index-DTHhZNC5.js +0 -14
- package/dist/assets/preload-helper-BB8Wl1va.js +0 -1
- package/dist/assets/send-Bs4eROle.js +0 -1
- package/dist/assets/useNodes-D-Vuwq5_.js +0 -1
- package/dist/assets/x-DOWbsdzd.js +0 -1
package/documentation/FORMS.md
CHANGED
|
@@ -26,23 +26,32 @@ id: contact
|
|
|
26
26
|
title: Contact us
|
|
27
27
|
description: Send our team a message.
|
|
28
28
|
fields:
|
|
29
|
-
-
|
|
30
|
-
label:
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
- type: fieldset
|
|
30
|
+
label: Your details
|
|
31
|
+
fields:
|
|
32
|
+
- name: email
|
|
33
|
+
label: Email
|
|
34
|
+
type: email
|
|
35
|
+
required: true
|
|
33
36
|
- name: message
|
|
34
37
|
label: Message
|
|
35
38
|
type: textarea
|
|
36
39
|
required: true
|
|
37
40
|
settings:
|
|
41
|
+
submitLabel: Send message
|
|
38
42
|
successMessage: Thanks for getting in touch.
|
|
39
43
|
requireTurnstile: false
|
|
40
44
|
```
|
|
41
45
|
|
|
46
|
+
Fields can be mixed with visual `fieldset` groups. Each group has a `label`
|
|
47
|
+
shown as its legend and a `fields` list; fields inside it are validated and
|
|
48
|
+
included in emails just like other fields. `settings.submitLabel` sets the
|
|
49
|
+
default button text.
|
|
50
|
+
|
|
42
51
|
## Add a form to a page
|
|
43
52
|
|
|
44
|
-
Add the **Form** block to a page and select the form.
|
|
45
|
-
|
|
53
|
+
Add the **Form** block to a page and select the form. Its optional **Submit
|
|
54
|
+
Button Label** overrides the form's button text. The selected
|
|
46
55
|
form and block settings are saved as part of the page draft. Draft preview shows
|
|
47
56
|
the selection after autosave; it does not become public until you publish the
|
|
48
57
|
page. Form definitions themselves are shared YAML configuration, not page
|
|
@@ -51,8 +60,8 @@ displays its ID rather than silently selecting a different form.
|
|
|
51
60
|
|
|
52
61
|
## Submissions
|
|
53
62
|
|
|
54
|
-
|
|
55
|
-
|
|
63
|
+
Database and email finishers are disabled by default. A valid submission with
|
|
64
|
+
no side-effect finisher enabled is not saved or emailed.
|
|
56
65
|
|
|
57
66
|
Select a form in the Forms sidebar, then use the **Finishers** tab in the main
|
|
58
67
|
workspace to enable **Save submissions to database**. Saved entries are
|
|
@@ -76,9 +85,11 @@ section shows its enabled state while collapsed.
|
|
|
76
85
|
|
|
77
86
|
## Finishers
|
|
78
87
|
|
|
79
|
-
Finishers run after field validation and Turnstile verification,
|
|
80
|
-
|
|
81
|
-
|
|
88
|
+
Finishers run after field validation and Turnstile verification. Database,
|
|
89
|
+
email and custom side effects run in the order listed. Success message and
|
|
90
|
+
redirect finishers control the response after those side effects succeed. You
|
|
91
|
+
can configure finishers on the form or override them on an individual Form
|
|
92
|
+
block. Disabled finishers retain their settings when saved and can be re-enabled.
|
|
82
93
|
|
|
83
94
|
### Configure finishers on a form
|
|
84
95
|
|
|
@@ -102,21 +113,30 @@ finishers:
|
|
|
102
113
|
When finisher settings are saved in the CMS, they override the YAML settings.
|
|
103
114
|
Registered custom finishers are preserved when built-in settings are edited.
|
|
104
115
|
|
|
105
|
-
|
|
116
|
+
Use **Success message** to edit the visitor-facing message with the rich-text
|
|
117
|
+
editor, or disable it to hide the message. **Redirect after submission** lets
|
|
118
|
+
you select a page or HTTP(S) URL and set a delay in seconds. When both are
|
|
119
|
+
enabled, the message appears before the redirect. These finishers are
|
|
120
|
+
independent of email delivery. Existing forms without a message finisher retain
|
|
121
|
+
their legacy `settings.successMessage` and saved block message behavior.
|
|
106
122
|
|
|
107
|
-
|
|
108
|
-
enabling or disabling database storage, adding or removing email finishers, and
|
|
109
|
-
setting their recipient, sender email, subject, sender name, reply-to, and
|
|
110
|
-
message templates. Registered custom finishers can also be added, enabled,
|
|
111
|
-
removed, or edited as JSON. Email transport is configured once for the KAMA
|
|
112
|
-
package environment, not per form or block.
|
|
123
|
+
### Override finishers on a Form block
|
|
113
124
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
125
|
+
The block editor lists the form's finishers individually. Select a finisher to
|
|
126
|
+
override it for that block; unselected finishers continue to use the form's
|
|
127
|
+
current settings. An override has its own enable/disable control and keeps its
|
|
128
|
+
settings when disabled. Built-in finishers use the same named settings as the
|
|
129
|
+
form editor. Registered custom finishers can also be overridden or added at the
|
|
130
|
+
block level, enabled or disabled, and edited as JSON.
|
|
131
|
+
|
|
132
|
+
Block overrides are saved with the page and merged with the form's current
|
|
133
|
+
finishers on submission. KAMA validates the published block configuration
|
|
134
|
+
instead of trusting settings sent by the visitor. Transport credentials cannot
|
|
135
|
+
be changed in the block editor. Sender addresses must be authorized by the
|
|
136
|
+
configured email provider. Custom finisher JSON is validated for size and
|
|
137
|
+
type; each custom handler must validate its own settings. Existing blocks with
|
|
138
|
+
legacy full-list overrides retain that behavior until edited in the block
|
|
139
|
+
editor.
|
|
120
140
|
|
|
121
141
|
### Add a custom finisher
|
|
122
142
|
|
|
@@ -200,10 +220,18 @@ email field. Keep the sender address fixed; use `replyToField` when replies
|
|
|
200
220
|
should go to the submitter. Subject text and optional `text` or `html` bodies
|
|
201
221
|
support `{{field}}` placeholders. Interpolated HTML values are escaped.
|
|
202
222
|
|
|
203
|
-
|
|
223
|
+
The rich-text email template editor starts with a simple template containing
|
|
224
|
+
the form title and a `{{fieldName}}` placeholder for each field. Edit this
|
|
225
|
+
template as needed. If no body template is set, the generated default includes
|
|
226
|
+
all submitted fields.
|
|
204
227
|
`FORMS_EMAIL_FROM` is the sender fallback, and `FORMS_EMAIL_FROM_NAME` provides
|
|
205
228
|
an optional deployment-wide sender-name fallback.
|
|
206
229
|
|
|
230
|
+
Rich-text templates and success messages are authored HTML: grant form and
|
|
231
|
+
block editing privileges only to trusted CMS users. With JavaScript disabled,
|
|
232
|
+
the Astro starter shows explicit messages and redirects on a minimal response
|
|
233
|
+
page, with a link back or onward.
|
|
234
|
+
|
|
207
235
|
If an email finisher fails, the submission fails and KAMA does not return a
|
|
208
236
|
success response. Email delivery and database writes cannot be rolled back
|
|
209
237
|
atomically, so earlier finishers may already have run. Retrying can repeat
|
|
@@ -263,3 +291,9 @@ loopback.
|
|
|
263
291
|
| `GET` | `/api/cms/forms/:formId/submissions` | Fetch saved submissions and field labels. |
|
|
264
292
|
| `DELETE` | `/api/cms/forms/:formId/submissions/:submissionId` | Delete one saved submission. |
|
|
265
293
|
| `DELETE` | `/api/cms/forms/:formId/submissions` | Delete selected submissions; send `{ "ids": [1, 2] }` as JSON. |
|
|
294
|
+
|
|
295
|
+
The public definition includes flattened `fields` for compatibility and
|
|
296
|
+
`layout` for rendering fieldsets. Successful submissions may include
|
|
297
|
+
`notification` (HTML, or `null` when explicitly disabled) and `redirect`
|
|
298
|
+
(`{ url, delay }`, with delay in seconds). The existing `message` remains
|
|
299
|
+
available when no notification finisher is configured.
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
// src/components/blocks/Form.astro
|
|
3
3
|
import { fetchCmsRequest, getCmsApiUrl } from '../../lib/cms-fetch';
|
|
4
|
+
import { getChannelId } from '../../lib/cms';
|
|
4
5
|
|
|
5
6
|
interface Props {
|
|
6
7
|
data: {
|
|
7
8
|
formId: string;
|
|
8
9
|
successMessage?: string;
|
|
10
|
+
submitLabel?: string;
|
|
9
11
|
};
|
|
10
12
|
blockId: number | string;
|
|
11
13
|
contentId: number | string;
|
|
@@ -83,7 +85,33 @@ const submissionMessage = Astro.url.searchParams.get('formMessage');
|
|
|
83
85
|
method="post"
|
|
84
86
|
action={`/api/forms/${encodeURIComponent(formId)}/submissions`}
|
|
85
87
|
>
|
|
86
|
-
{
|
|
88
|
+
<input type="hidden" name="_kamaFinisherBlockId" value={String(blockId)} />
|
|
89
|
+
<input type="hidden" name="_kamaFinisherContentId" value={String(contentId)} />
|
|
90
|
+
<input type="hidden" name="_kamaChannelId" value={safeEnv.PUBLIC_CHANNEL_ID || getChannelId()} />
|
|
91
|
+
<input type="hidden" name="_kamaSuccessMessage" value={data?.successMessage || ''} />
|
|
92
|
+
{(schema.layout || schema.fields)?.map((field: any) => field.type === 'fieldset' ? (
|
|
93
|
+
<fieldset class="form-fieldset">
|
|
94
|
+
{field.label && <legend>{field.label}</legend>}
|
|
95
|
+
{field.fields?.map((item: any) => (
|
|
96
|
+
<div class="form-group">
|
|
97
|
+
<label for={`field-${item.name}`}>
|
|
98
|
+
{item.label}
|
|
99
|
+
{item.required && <span class="required" aria-hidden="true"> *</span>}
|
|
100
|
+
</label>
|
|
101
|
+
{item.type === 'textarea' ? (
|
|
102
|
+
<textarea id={`field-${item.name}`} name={item.name} placeholder={item.placeholder || ''} required={item.required} rows="4" />
|
|
103
|
+
) : item.type === 'select' ? (
|
|
104
|
+
<select id={`field-${item.name}`} name={item.name} required={item.required}>
|
|
105
|
+
<option value="" disabled selected>{item.placeholder || 'Select...'}</option>
|
|
106
|
+
{item.options?.map((opt: any) => <option value={opt.value}>{opt.label}</option>)}
|
|
107
|
+
</select>
|
|
108
|
+
) : (
|
|
109
|
+
<input type={item.type || 'text'} id={`field-${item.name}`} name={item.name} placeholder={item.placeholder || ''} required={item.required} />
|
|
110
|
+
)}
|
|
111
|
+
</div>
|
|
112
|
+
))}
|
|
113
|
+
</fieldset>
|
|
114
|
+
) : (
|
|
87
115
|
<div class="form-group">
|
|
88
116
|
<label for={`field-${field.name}`}>
|
|
89
117
|
{field.label}
|
|
@@ -118,7 +146,7 @@ const submissionMessage = Astro.url.searchParams.get('formMessage');
|
|
|
118
146
|
</p>
|
|
119
147
|
)}
|
|
120
148
|
|
|
121
|
-
<button type="submit" class="submit-btn">Submit</button>
|
|
149
|
+
<button type="submit" class="submit-btn">{data?.submitLabel || schema.settings?.submitLabel || 'Submit'}</button>
|
|
122
150
|
</form>
|
|
123
151
|
</div>
|
|
124
152
|
) : (
|
|
@@ -151,6 +179,12 @@ const submissionMessage = Astro.url.searchParams.get('formMessage');
|
|
|
151
179
|
min-width: 0;
|
|
152
180
|
}
|
|
153
181
|
|
|
182
|
+
.form-fieldset {
|
|
183
|
+
display: grid;
|
|
184
|
+
gap: 1.25rem;
|
|
185
|
+
min-width: 0;
|
|
186
|
+
}
|
|
187
|
+
|
|
154
188
|
.form-group label {
|
|
155
189
|
color: #0f172a;
|
|
156
190
|
font-weight: 600;
|
|
@@ -293,10 +327,20 @@ const submissionMessage = Astro.url.searchParams.get('formMessage');
|
|
|
293
327
|
throw new Error(result.error || 'Form submission failed.');
|
|
294
328
|
}
|
|
295
329
|
|
|
296
|
-
|
|
297
|
-
|
|
330
|
+
if (typeof result.notification === 'string') {
|
|
331
|
+
successBox.innerHTML = result.notification;
|
|
332
|
+
successBox.style.display = 'block';
|
|
333
|
+
} else if (result.notification !== null) {
|
|
334
|
+
successBox.textContent = container.getAttribute('data-success-message') || result.message || 'Form submitted successfully!';
|
|
335
|
+
successBox.style.display = 'block';
|
|
336
|
+
}
|
|
298
337
|
form.reset();
|
|
299
338
|
if (window.turnstile) window.turnstile.reset();
|
|
339
|
+
if (result.redirect?.url) {
|
|
340
|
+
const target = new URL(result.redirect.url, window.location.href);
|
|
341
|
+
if (!['http:', 'https:'].includes(target.protocol)) throw new Error('Invalid redirect destination.');
|
|
342
|
+
window.setTimeout(() => window.location.assign(target.href), Math.max(0, Number(result.redirect.delay) || 0) * 1000);
|
|
343
|
+
}
|
|
300
344
|
} catch (error) {
|
|
301
345
|
errorBox.textContent = error instanceof Error ? error.message : 'Form submission failed.';
|
|
302
346
|
errorBox.style.display = 'block';
|
|
@@ -32,11 +32,30 @@ export const POST: APIRoute = async ({ params, request, locals }) => {
|
|
|
32
32
|
);
|
|
33
33
|
const response = await fetchCmsRequest(backendRequest, cmsWorker);
|
|
34
34
|
if (request.headers.get("accept")?.includes("text/html")) {
|
|
35
|
-
const result = await response.clone().json()
|
|
36
|
-
|
|
35
|
+
const result = await response.clone().json();
|
|
36
|
+
let redirectUrl = new URL(request.headers.get("referer") || "/", request.url);
|
|
37
37
|
if (redirectUrl.origin !== new URL(request.url).origin) {
|
|
38
|
-
redirectUrl
|
|
39
|
-
|
|
38
|
+
redirectUrl = new URL("/", request.url);
|
|
39
|
+
}
|
|
40
|
+
if (response.ok && result.success && (result.notification !== undefined || result.redirect)) {
|
|
41
|
+
const escape = (value: string) => value.replaceAll("&", "&").replaceAll('"', """)
|
|
42
|
+
.replaceAll("<", "<").replaceAll(">", ">");
|
|
43
|
+
const target = result.redirect?.url ? new URL(result.redirect.url, request.url) : null;
|
|
44
|
+
if (target && !["http:", "https:"].includes(target.protocol)) throw new Error("Invalid redirect destination");
|
|
45
|
+
const targetHref = target && typeof result.redirect.url === "string" && /^\/(?!\/)/.test(result.redirect.url)
|
|
46
|
+
&& !result.redirect.url.includes("\\") ? result.redirect.url : target?.href;
|
|
47
|
+
const delay = Number(result.redirect?.delay ?? 0);
|
|
48
|
+
if (!Number.isFinite(delay) || delay < 0 || delay > 2147483) throw new Error("Invalid redirect delay");
|
|
49
|
+
const message = typeof result.notification === "string"
|
|
50
|
+
? result.notification
|
|
51
|
+
: result.notification === null ? "" : escape(String(JSON.parse(payload)._kamaSuccessMessage || result.message || "Form submitted successfully!"));
|
|
52
|
+
const refresh = targetHref ? `<meta http-equiv="refresh" content="${delay};url=${escape(targetHref)}">` : "";
|
|
53
|
+
const link = targetHref
|
|
54
|
+
? `<a href="${escape(targetHref)}">Continue</a>`
|
|
55
|
+
: `<a href="${escape(redirectUrl.pathname + redirectUrl.search + redirectUrl.hash)}">Back</a>`;
|
|
56
|
+
return new Response(`<!doctype html><html><head><meta charset="utf-8">${refresh}</head><body><main>${message}${link}</main></body></html>`, {
|
|
57
|
+
headers: { "content-type": "text/html; charset=utf-8", "cache-control": "no-store" },
|
|
58
|
+
});
|
|
40
59
|
}
|
|
41
60
|
redirectUrl.searchParams.set("formId", path[0]);
|
|
42
61
|
redirectUrl.searchParams.set("formStatus", response.ok && result.success ? "success" : "error");
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{B as e,E as t,I as n,K as r,O as i,Q as a,R as o,S as s,T as c,Tt as l,Y as u,b as d,ct as f,et as p,f as m,g as h,j as g,o as _,q as v,t as y,v as b,x,xt as ee,y as S}from"./_plugin-vue_export-helper-BK_c4R_m.js";import{i as te}from"./useNodes-D-Vuwq5_.js";import{n as ne,s as re}from"./useCmsState-CDENPbKL.js";import{n as C,r as ie,t as ae}from"./NodeContextMenu-C5RTK0sr.js";import{a as oe,i as se,n as ce,r as le,t as w}from"./CmsImagePreview-BhM7S_v8.js";import{t as ue}from"./file-U7h4eOhG.js";import{t as de}from"./layers-BwACvD_U.js";import{t as fe}from"./panel-left-close-Cpq52HZy.js";import{t as pe}from"./save-Dwhm8QNL.js";import{t as T}from"./trash-2-BbKTm8cC.js";import{t as E}from"./CmsButton-DnhPsHXA.js";import{n as D,t as O}from"./CmsBadge-BT2jTJUu.js";import{t as me}from"./CmsFieldTaxonomy-CNY3-MbD.js";g(),f(),u(),_();var he={class:`asset-editor-wrapper canvas`},k={class:`entity-header`},A={class:`top-row`},j={class:`node-info`},M={class:`dynamic-title-group`},N={class:`inline-title-input`},P={key:0},F={key:1},I={class:`meta-row`},L={key:0,class:`slug-badge`},R={class:`actions-group`},ge={class:`btn-text`},_e={class:`editor-body`},ve={key:0,class:`loading-state`},ye={key:1,class:`asset-content-scroll`},be={class:`main-preview-section`},xe={key:1,class:`doc-preview`},Se={class:`preview-footer`},Ce=[`href`],we={class:`data-column`},Te={class:`data-header`},Ee={class:`data-content`},De={class:`form-group`},Oe={class:`form-group`},ke={class:`form-group`},Ae={class:`form-group`},je={class:`usage-and-crops-section`},Me={class:`usage-section-container`},Ne={class:`gallery-header-row`},Pe={key:0,class:`usage-empty standalone-empty`},Fe={key:1,class:`list-container`},Ie={class:`node-title`},Le={class:`meta-stack`},Re={class:`node-field`},ze={key:0,class:`crop-showcase`},Be={class:`crop-name`},Ve={key:0,class:`usage-section-container`,style:{"margin-top":`40px`}},He={class:`gallery-header-row`},Ue={class:`list-container`},We={class:`meta-stack`},Ge={class:`node-field`},Ke={key:0,class:`crop-showcase`},qe={class:`crop-item`},Je={class:`crop-name`},Ye=[`onClick`],z=y(i({__name:`AssetEditor`,props:{assetId:{}},setup(i){let u=i,{activeView:f,nodeSchemas:g}=ne(),{confirmDiscard:_}=re(),{navigateToNodeById:y}=te(),z=a(null),B=a(!0),V=a(!1),H=a({filename:``,title:``,alt:``,tags:[]}),U=a({filename:``,title:``,alt:``,tags:[]}),W=a(!1),G=a(null),K=a(null),Xe=()=>{if(W.value){W.value=!1;return}G.value&&(K.value=G.value.getBoundingClientRect()),W.value=!0},Ze=b(()=>{let e=[{key:`copy-url`,label:`Copy Public URL`,icon:ie},{key:`open-tab`,label:`Open in New Tab`,icon:C}];return z.value&&z.value.connectedNodes?.length>0&&(e.push({key:`div-nodes`,label:``,divider:!0}),e.push({key:`show-nodes`,label:`Connected Nodes (${z.value.connectedNodes.length})`,icon:ce})),e.push({key:`div-1`,label:``,divider:!0},{key:`delete`,label:`Delete Asset`,icon:T}),e}),Qe=async e=>{W.value=!1,z.value&&(e===`copy-url`&&z.value.url?await navigator.clipboard.writeText(z.value.url):e===`open-tab`&&z.value.url?window.open(z.value.url,`_blank`):e===`delete`?await _(`Are you sure you want to delete "${z.value.filename||`this asset`}"?`,`Delete Asset?`,`Delete`,`Cancel`)&&await $e():e===`show-nodes`&&Y())},$e=async()=>{try{(await fetch(`/api/admin/assets/${u.assetId}`,{method:`DELETE`})).ok&&(window.dispatchEvent(new CustomEvent(`cms-assets-updated`)),f.value={type:`dashboard`})}catch{}},et=b(()=>H.value.filename!==U.value.filename||H.value.title!==U.value.title||H.value.alt!==U.value.alt||JSON.stringify(H.value.tags)!==JSON.stringify(U.value.tags)),q=async()=>{B.value=!0;try{let e=await fetch(`/api/admin/assets/${u.assetId}/details`);if(e.ok){let t=await e.json();z.value=t;let n={filename:t.filename||``,title:t.title||``,alt:t.alt||``,tags:t.tags||[]};H.value={...n},U.value={...n}}}catch{}finally{B.value=!1}},tt=async()=>{V.value=!0;try{(await fetch(`/api/admin/assets/${u.assetId}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(H.value)})).ok&&(U.value=JSON.parse(JSON.stringify(H.value)),window.dispatchEvent(new CustomEvent(`cms-assets-updated`)))}catch{}finally{V.value=!1}},nt=async e=>{let t=`Permanently delete orphaned crop "${z.value?.variants?.find(t=>String(t.id)===String(e))?.filename||`variant`}"?`;if(await _(t,`Delete Crop`,`Delete`,`Cancel`))try{(await fetch(`/api/admin/assets/purge/${e}`,{method:`DELETE`})).ok&&(z.value?.variants&&(z.value.variants=z.value.variants.filter(t=>String(t.id)!==String(e))),window.dispatchEvent(new CustomEvent(`cms-assets-updated`)),await q())}catch{}},J=async()=>{let e=$.value;if(e.length===0)return;let t=`Are you sure you want to permanently delete all ${e.length} orphaned crops?`;if(await _(t,`Purge All Orphaned Crops`,`Purge All`,`Cancel`))try{for(let t of e)await fetch(`/api/admin/assets/purge/${t.id}`,{method:`DELETE`});window.dispatchEvent(new CustomEvent(`cms-assets-updated`)),await q()}catch(e){console.error(`Failed to purge crops`,e)}},rt=e=>{f.value={type:`node`},y(String(e)),window.dispatchEvent(new CustomEvent(`cms-switch-sidebar-tab`,{detail:`vault`}))},Y=()=>{sessionStorage.setItem(`cms-vault-asset-filter`,u.assetId),window.dispatchEvent(new CustomEvent(`cms-filter-vault-by-asset`,{detail:u.assetId})),window.dispatchEvent(new CustomEvent(`cms-switch-sidebar-tab`,{detail:`vault`}))},X=b(()=>z.value&&(z.value.mimeType?.startsWith(`image/`)||/\.(jpg|jpeg|png|webp|gif|svg)$/i.test(z.value.filename))),Z=e=>{if(!e)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**r).toFixed(1))+` `+n[r]},it=(e,t)=>{if(!t||t===`Original`||t===`Unknown Crop`)return t||`Original Image`;try{let n=g.value[e];if(!n)return t;let r=null,i=e=>{if(!(!e||r))for(let n of Object.values(e))n.crop&&t===`standard`&&n.crop.label&&(r=n.crop.label),n.crops&&n.crops[t]&&n.crops[t].label&&(r=n.crops[t].label)};return i(n.fields),n.tabs&&Object.values(n.tabs).forEach(e=>i(e.fields)),r||t}catch{return t}},Q=b(()=>{if(!z.value||!z.value.connectedNodes)return[];let e=new Map;for(let t of z.value.connectedNodes){let n=String(t.id),r=t.contentType||t.nodeType,i=t.fieldKey?.split(`.`)[0]||`Content Area`,a=t.fieldKey?.match(/^blocks\[(\d+)\]/);a&&(i=`Block ${parseInt(a[1],10)+1}`);let o=String(t.assetId)!==String(z.value.id),s=null;if(o){let e=z.value.variants?.find(e=>String(e.id)===String(t.assetId));if(e){let n=`Unknown Crop`,i=t.fieldKey?.match(/\.variants\.([^.]+)/);if(i)n=i[1];else{let t=e.filename?.match(/^(.+?)_ast_/);t&&(n=t[1])}s={id:e.id,url:e.url,label:it(r,n)}}}else s={id:z.value.id,url:z.value.url,label:`Original Image`};if(!e.has(n))e.set(n,{id:t.id,title:t.title,nodeType:r,fieldKeys:new Set([i]),usedAssets:s?[s]:[]});else{let t=e.get(n);t.fieldKeys.add(i),s&&!t.usedAssets.some(e=>e.id===s.id)&&t.usedAssets.push(s)}}return Array.from(e.values()).map(e=>({...e,fieldKey:Array.from(e.fieldKeys).join(`, `)}))}),$=b(()=>{if(!z.value||!z.value.variants)return[];let e=new Set(z.value.connectedNodes?.map(e=>String(e.assetId))||[]);return z.value.variants.filter(t=>!e.has(String(t.id)))}),at=e=>{let t=e?.match(/^(.+?)_ast_/);return t?t[1]:`Unknown Crop`};return n(()=>q()),(n,i)=>(o(),s(`div`,he,[S(`header`,k,[S(`div`,A,[S(`div`,j,[S(`div`,M,[S(`span`,N,[z.value?(o(),s(`span`,P,l(z.value.filename),1)):(o(),s(`span`,F,`Loading Asset...`))])]),S(`div`,I,[z.value?(o(),s(`span`,L,l(Z(z.value.sizeBytes))+` • `+l(z.value.mimeType),1)):x(``,!0)])]),S(`div`,R,[z.value?(o(),s(`div`,{key:0,class:`context-wrapper`,ref_key:`contextTriggerRef`,ref:G},[t(E,{variant:`secondary`,title:`More Options`,onClick:Xe,disabled:V.value,class:`transparent-btn icon-only-btn`},{default:r(()=>[t(p(se),{size:16})]),_:1},8,[`disabled`]),t(ae,{show:W.value,items:Ze.value,"anchor-rect":K.value,onSelect:Qe,onClose:i[0]||=e=>W.value=!1},null,8,[`show`,`items`,`anchor-rect`])],512)):x(``,!0),t(E,{variant:`primary`,class:`save-btn`,disabled:V.value||!et.value,onClick:tt},{default:r(()=>[t(p(pe),{size:14,class:`save-icon`}),S(`span`,ge,l(V.value?`Saving...`:`Save Metadata`),1)]),_:1},8,[`disabled`])])])]),S(`div`,_e,[B.value?(o(),s(`div`,ve,`Loading asset details...`)):z.value?(o(),s(`div`,ye,[S(`div`,be,[S(`div`,{class:ee([`preview-container`,{"is-doc":!X.value}])},[X.value?(o(),d(w,{key:0,url:z.value.url,alt:z.value.alt||z.value.filename,width:1200,quality:85,class:`main-preview-wrapper`},null,8,[`url`,`alt`])):(o(),s(`div`,xe,[t(p(ue),{size:64}),i[5]||=S(`span`,null,`Preview not available for this file type`,-1)]))],2),S(`div`,Se,[S(`span`,null,`Original Upload: `+l(new Date(z.value.createdAt).toLocaleString()),1),S(`a`,{href:z.value.url,target:`_blank`,class:`ext-link`},[i[6]||=c(`Open original file `,-1),t(p(C),{size:12})],8,Ce)])]),S(`div`,we,[S(`div`,Te,[S(`h3`,null,[t(p(le),{size:14,class:`inline-icon`}),i[7]||=c(` Metadata `,-1)])]),S(`div`,Ee,[S(`div`,De,[i[8]||=S(`label`,null,`Filename`,-1),v(S(`input`,{"onUpdate:modelValue":i[1]||=e=>H.value.filename=e,type:`text`,class:`cms-input`},null,512),[[m,H.value.filename]]),i[9]||=S(`span`,{class:`help-text`},`Changing this does not break the permanent CDN link.`,-1)]),S(`div`,Oe,[i[10]||=S(`label`,null,`Media Tags`,-1),t(me,{modelValue:H.value.tags,"onUpdate:modelValue":i[2]||=e=>H.value.tags=e,fieldKey:`media-tag`,config:{taxonomy:`media-tag`,multiple:!0}},null,8,[`modelValue`]),i[11]||=S(`span`,{class:`help-text`},`Used to organize and filter assets in the media library.`,-1)]),S(`div`,ke,[i[12]||=S(`label`,null,`Title (Internal/SEO)`,-1),v(S(`input`,{"onUpdate:modelValue":i[3]||=e=>H.value.title=e,type:`text`,class:`cms-input`},null,512),[[m,H.value.title]])]),S(`div`,Ae,[i[13]||=S(`label`,null,`Alt Text (Accessibility)`,-1),v(S(`textarea`,{"onUpdate:modelValue":i[4]||=e=>H.value.alt=e,class:`cms-input cms-textarea`},null,512),[[m,H.value.alt]])])])]),S(`div`,je,[S(`div`,Me,[S(`div`,Ne,[S(`h3`,null,[t(p(de),{size:16,class:`inline-icon`}),i[14]||=c(` Node Usage `,-1)]),Q.value.length>0?(o(),s(`button`,{key:0,class:`action-btn outline`,onClick:Y,title:`Show these nodes in the left Vault pane`},[t(p(fe),{size:13}),i[15]||=c(` Vault Filter `,-1)])):x(``,!0)]),Q.value.length===0?(o(),s(`div`,Pe,[...i[16]||=[S(`span`,{class:`status-dot warning`},null,-1),S(`span`,null,`Asset is not currently used on any nodes.`,-1)]])):(o(),s(`div`,Fe,[(o(!0),s(h,null,e(Q.value,n=>(o(),d(D,{key:n.id,clickable:``,onClick:e=>rt(n.id)},{title:r(()=>[i[17]||=S(`span`,{class:`status-dot success`},null,-1),S(`span`,Ie,l(n.title||`Untitled`),1),t(O,{variant:`type`},{default:r(()=>[c(l(n.nodeType||`page`),1)]),_:2},1024)]),meta:r(()=>[S(`div`,Le,[S(`span`,Re,`Used in field: `+l(n.fieldKey),1),X.value?(o(),s(`div`,ze,[(o(!0),s(h,null,e(n.usedAssets,e=>(o(),s(`div`,{key:e.id,class:`crop-item`},[t(w,{url:e.url,alt:e.label,width:200,quality:75,class:`crop-img-fixed-height`},null,8,[`url`,`alt`]),S(`span`,Be,l(e.label),1)]))),128))])):x(``,!0)])]),_:2},1032,[`onClick`]))),128))]))]),$.value.length>0?(o(),s(`div`,Ve,[S(`div`,He,[S(`h3`,null,[t(p(oe),{size:16,class:`inline-icon`}),c(` Orphaned Crops (`+l($.value.length)+`) `,1)]),S(`button`,{class:`action-btn outline text-danger`,onClick:J},[t(p(T),{size:13}),i[18]||=c(` Purge All `,-1)])]),i[21]||=S(`p`,{class:`gallery-desc`},`These crops were generated previously but are no longer attached to any nodes. You can safely delete them to save storage space.`,-1),S(`div`,Ue,[(o(!0),s(h,null,e($.value,e=>(o(),d(D,{key:e.id},{title:r(()=>[i[19]||=S(`span`,{class:`node-title`},`Orphaned Crop`,-1),t(O,{variant:`type`},{default:r(()=>[c(l(Z(e.sizeBytes)),1)]),_:2},1024)]),meta:r(()=>[S(`div`,We,[S(`span`,Ge,`Generated: `+l(new Date(e.createdAt).toLocaleDateString()),1),X.value?(o(),s(`div`,Ke,[S(`div`,qe,[t(w,{url:e.url,alt:e.filename,width:200,quality:75,class:`crop-img-fixed-height`},null,8,[`url`,`alt`]),S(`span`,Je,l(at(e.filename)),1)])])):x(``,!0)])]),actions:r(()=>[S(`button`,{class:`action-btn outline text-danger`,style:{border:`none`},onClick:t=>nt(e.id)},[t(p(T),{size:13}),i[20]||=c(` Purge `,-1)],8,Ye)]),_:2},1024))),128))])])):x(``,!0)])])):x(``,!0)])]))}}),[[`__scopeId`,`data-v-51249bd0`]]);export{z as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.cms-accordion[data-v-9e48572d]{border:1px solid var(--cms-color-border,#e2e8f0);border-radius:var(--cms-radius-md,8px);background:var(--cms-color-surface,#fff);transition:border-color var(--cms-transition-fast,.15s ease), box-shadow var(--cms-transition-fast,.15s ease);display:block;overflow:hidden}.cms-accordion+.cms-accordion[data-v-9e48572d]{margin-top:10px}.cms-accordion[data-v-9e48572d]:hover{border-color:var(--cms-color-border-dark,#cbd5e1)}.accordion-summary[data-v-9e48572d]{min-height:48px;color:var(--cms-color-text-main,#0f172a);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:12px;padding:10px 14px;list-style:none;display:flex}.accordion-summary[data-v-9e48572d]::-webkit-details-marker{display:none}.accordion-summary[data-v-9e48572d]:focus-visible{outline:2px solid var(--cms-color-primary,#2563eb);outline-offset:-2px}.accordion-title[data-v-9e48572d]{flex:1;min-width:0;font-size:13px;font-weight:600;line-height:1.4}.accordion-leading[data-v-9e48572d]{flex-shrink:0;align-items:center;display:flex}.accordion-status[data-v-9e48572d]{border:1px solid #0000;border-radius:999px;flex-shrink:0;padding:3px 8px;font-size:11px;font-weight:600;line-height:1.2}.accordion-status.is-success[data-v-9e48572d]{border-color:var(--cms-color-success-border,#bbf7d0);background:var(--cms-color-success-light,#f0fdf4);color:var(--cms-color-success,#15803d)}.accordion-status.is-muted[data-v-9e48572d]{border-color:var(--cms-color-border,#e2e8f0);background:var(--cms-color-surface-hover,#f1f5f9);color:var(--cms-color-text-muted,#64748b)}.accordion-status.is-warning[data-v-9e48572d]{border-color:var(--cms-color-warning-border,#fde68a);background:var(--cms-color-warning-light,#fffbeb);color:var(--cms-color-warning,#a16207)}.accordion-status.is-danger[data-v-9e48572d]{border-color:var(--cms-color-danger-border,#fecaca);background:var(--cms-color-danger-light,#fef2f2);color:var(--cms-color-danger,#b91c1c)}.accordion-meta[data-v-9e48572d]{color:var(--cms-color-text-muted,#64748b);flex-shrink:0;font-size:12px}.accordion-chevron[data-v-9e48572d]{color:var(--cms-color-text-muted,#64748b);transition:transform var(--cms-transition-fast,.15s ease);flex-shrink:0}.cms-accordion[open]>.accordion-summary[data-v-9e48572d]{border-bottom:1px solid var(--cms-color-border,#e2e8f0);background:var(--cms-color-surface-hover,#f8fafc)}.cms-accordion[open]>.accordion-summary .accordion-chevron[data-v-9e48572d]{transform:rotate(180deg)}.accordion-content[data-v-9e48572d]{padding:14px}.is-compact>.accordion-summary[data-v-9e48572d]{gap:8px;min-height:40px;padding:8px 12px}.is-compact>.accordion-content[data-v-9e48572d]{padding:10px 12px}@media (width<=600px){.accordion-summary[data-v-9e48572d]{gap:8px;padding-left:10px;padding-right:10px}.accordion-meta[data-v-9e48572d]{font-size:11px}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{E as e,H as t,O as n,R as r,S as i,Tt as a,V as o,ct as s,j as c,t as l,x as u,xt as d,y as f}from"./_plugin-vue_export-helper-BK_c4R_m.js";c(),s();var p=[`open`],m={class:`accordion-summary`},h={key:0,class:`accordion-leading`},g={class:`accordion-title`},_={key:2,class:`accordion-meta`},v={class:`accordion-content`},y=l(n({__name:`CmsAccordion`,props:{title:{},status:{},statusVariant:{default:`muted`},defaultOpen:{type:Boolean,default:!1},compact:{type:Boolean,default:!1}},setup(n){return(s,c)=>{let l=t(`KamaIcon`);return r(),i(`details`,{class:d([`cms-accordion`,{"is-compact":n.compact}]),open:n.defaultOpen},[f(`summary`,m,[s.$slots.leading?(r(),i(`span`,h,[o(s.$slots,`leading`,{},void 0,!0)])):u(``,!0),f(`span`,g,a(n.title),1),n.status?(r(),i(`span`,{key:1,class:d([`accordion-status`,`is-${n.statusVariant}`])},a(n.status),3)):u(``,!0),s.$slots.meta?(r(),i(`span`,_,[o(s.$slots,`meta`,{},void 0,!0)])):u(``,!0),e(l,{name:`ChevronDown`,size:`16`,class:`accordion-chevron`})]),f(`div`,v,[o(s.$slots,`default`,{},void 0,!0)])],10,p)}}}),[[`__scopeId`,`data-v-9e48572d`]]);export{y as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{B as e,E as t,I as n,O as r,R as i,S as a,T as o,Tt as s,Y as c,ct as l,et as u,g as d,h as f,j as p,o as m,t as h,v as g,xt as _,y as v}from"./_plugin-vue_export-helper-BK_c4R_m.js";import{s as y}from"./useNodes-D-Vuwq5_.js";import{t as b}from"./loader-circle-DYEFqbD4.js";p(),c(),l(),m();var x={key:0,class:`loading-state`},S={key:1,class:`empty-state`},C={key:2,class:`taxonomy-pills`},w=[`disabled`,`onClick`],T=[`disabled`,`value`],E={value:``,disabled:``},D=[`value`],O=h(r({__name:`CmsFieldTaxonomy`,props:{modelValue:{},fieldKey:{},config:{},disabled:{type:Boolean},invalid:{type:Boolean}},emits:[`update:modelValue`],setup(r,{emit:c}){let l=r,p=c,{termsMap:m,fetchTerms:h,isLoading:O}=y(),k=g(()=>l.config.taxonomy||l.config.taxonomyKey||l.fieldKey),A=g(()=>{let e=k.value;return!e||!m.value||!m.value[e]?[]:m.value[e]}),j=g(()=>l.modelValue?(Array.isArray(l.modelValue)?l.modelValue:[l.modelValue]).map(e=>{let t=``;return t=typeof e==`string`?e:typeof e==`object`&&e&&e.id?String(e.id):String(e),t.startsWith(`trm_`)&&(t=t.replace(`trm_`,``)),parseInt(t,10)}).filter(e=>!isNaN(e)):[]),M=g(()=>l.config.multiple===!0);n(async()=>{let e=k.value;e&&(!m.value||!m.value[e])&&await h(e)});let N=e=>{if(!l.disabled){if(M.value){let t=[...j.value],n=t.indexOf(e);n>=0?t.splice(n,1):t.push(e),p(`update:modelValue`,t.map(e=>`trm_${e}`))}else p(`update:modelValue`,`trm_${e}`)}},P=e=>e.label||e.title||e.name||`Term #${e.id}`;return(n,c)=>(i(),a(`div`,{class:_([`cms-field-taxonomy`,{"is-invalid":r.invalid,"is-disabled":r.disabled}])},[u(O)&&A.value.length===0?(i(),a(`div`,x,[t(u(b),{size:14,class:`spinner`}),o(` Loading `+s(r.config.taxonomy||r.fieldKey)+`... `,1)])):A.value.length===0?(i(),a(`div`,S,` No terms found for `+s(r.config.taxonomy||r.fieldKey)+`. `,1)):M.value?(i(),a(`div`,C,[(i(!0),a(d,null,e(A.value,e=>(i(),a(`button`,{key:e.id,type:`button`,class:_([`tax-pill`,{"is-active":j.value.includes(e.id)}]),disabled:r.disabled,onClick:f(t=>N(e.id),[`prevent`])},s(P(e)),11,w))),128))])):(i(),a(`select`,{key:3,class:`taxonomy-select`,disabled:r.disabled,value:j.value.length>0?j.value[0]:``,onChange:c[0]||=e=>N(parseInt(e.target.value,10))},[v(`option`,E,`Select `+s(r.config.label||r.config.taxonomy||r.fieldKey)+`...`,1),(i(!0),a(d,null,e(A.value,e=>(i(),a(`option`,{key:e.id,value:e.id},s(P(e)),9,D))),128))],40,T))],2))}}),[[`__scopeId`,`data-v-1a55cb97`]]);export{O as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{E as e,O as t,R as n,S as r,T as i,Y as a,et as o,j as s,t as c,y as l}from"./_plugin-vue_export-helper-BK_c4R_m.js";import{a as u,i as d}from"./useNodes-D-Vuwq5_.js";import{n as f,r as p,t as m}from"./plus-7rv1C56N.js";import{t as h}from"./database--QlkzG9u.js";import{n as g,t as _}from"./globe-TuZP0v6A.js";import{t as v}from"./layers-BwACvD_U.js";s(),a();var y={class:`help-canvas`},b={class:`help-container`},x={class:`steps-grid`},S={class:`step-card`},C={class:`card-header`},w={class:`card-icon channel-icon`},T={class:`step-card`},E={class:`card-header`},D={class:`card-icon tree-icon`},O={class:`step-card`},k={class:`card-header`},A={class:`card-icon vault-icon`},j={class:`architecture-guide`},M={class:`guide-header`},N={class:`guide-columns`},P={class:`guide-col-arrow`},F={class:`guide-col-arrow`},I={class:`guide-col-arrow`},L=c(t({__name:`CmsHelp`,setup(t){let{handleAddNewChannel:a}=p(),{handleAddNewTree:s}=u(),{handleAddNewNode:c}=d();return(t,u)=>(n(),r(`main`,y,[l(`div`,b,[u[17]||=l(`header`,{class:`help-header`},[l(`h1`,null,`KAMA`),l(`p`,null,`Build modular content in the Vault, organize it into Navigation Trees, and expose it to your channels via API.`)],-1),l(`div`,x,[l(`div`,S,[l(`div`,C,[l(`div`,w,[e(o(_),{size:20})]),u[3]||=l(`div`,{class:`step-badge`},`Step 1`,-1)]),u[5]||=l(`div`,{class:`card-content`},[l(`h3`,null,`Channels`),l(`p`,null,`Delivery targets that consume your headless API.`)],-1),l(`button`,{class:`card-action-btn`,onClick:u[0]||=(...e)=>o(a)&&o(a)(...e)},[e(o(m),{size:16}),u[4]||=i(` Create Channel `,-1)])]),l(`div`,T,[l(`div`,E,[l(`div`,D,[e(o(g),{size:20})]),u[6]||=l(`div`,{class:`step-badge`},`Step 2`,-1)]),u[8]||=l(`div`,{class:`card-content`},[l(`h3`,null,`Trees`),l(`p`,null,`Decoupled structural hierarchies and navigation menus.`)],-1),l(`button`,{class:`card-action-btn`,onClick:u[1]||=(...e)=>o(s)&&o(s)(...e)},[e(o(m),{size:16}),u[7]||=i(` Create Tree `,-1)])]),l(`div`,O,[l(`div`,k,[l(`div`,A,[e(o(h),{size:20})]),u[9]||=l(`div`,{class:`step-badge`},`Step 3`,-1)]),u[11]||=l(`div`,{class:`card-content`},[l(`h3`,null,`Vault`),l(`p`,null,`Flat, headless content store for reusable content items.`)],-1),l(`button`,{class:`card-action-btn`,onClick:u[2]||=e=>o(c)()},[e(o(m),{size:16}),u[10]||=i(` Create Content `,-1)])])]),l(`section`,j,[l(`div`,M,[e(o(v),{size:18,class:`guide-icon`}),u[12]||=l(`h4`,null,`Architecture Flow`,-1)]),l(`div`,N,[u[13]||=l(`div`,{class:`guide-col`},[l(`strong`,null,`1. Content Vault`),l(`p`,null,`Raw content entities existing independently of routing.`)],-1),l(`div`,P,[e(o(f),{size:16})]),u[14]||=l(`div`,{class:`guide-col`},[l(`strong`,null,`2. Navigation Trees`),l(`p`,null,`Decoupled structures mapping content items to URL hierarchies.`)],-1),l(`div`,F,[e(o(f),{size:16})]),u[15]||=l(`div`,{class:`guide-col`},[l(`strong`,null,`3. Channels`),l(`p`,null,`Delivery targets binding trees and languages to specific contexts.`)],-1),l(`div`,I,[e(o(f),{size:16})]),u[16]||=l(`div`,{class:`guide-col`},[l(`strong`,null,`4. Headless API`),l(`p`,null,`Endpoints serving structured JSON to your frontends.`)],-1)])])])]))}}),[[`__scopeId`,`data-v-c739c397`]]);export{L as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{E as e,O as t,Q as n,R as r,S as i,W as a,Y as o,ct as s,et as c,j as l,n as u,t as d,v as f,x as p,xt as m}from"./_plugin-vue_export-helper-BK_c4R_m.js";import{t as h}from"./loader-circle-DYEFqbD4.js";var g=u(`crop`,[[`path`,{d:`M6 2v14a2 2 0 0 0 2 2h14`,key:`ron5a4`}],[`path`,{d:`M18 22V8a2 2 0 0 0-2-2H2`,key:`7s9ehn`}]]),_=u(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),v=u(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),y=u(`link`,[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]);function b(e,t){if(!e)return``;if(!e.includes(`/media/`))return e;try{let n=new URL(e,window.location.origin);return n.pathname.toLowerCase().endsWith(`.svg`)?n.pathname+n.search:(t.w&&n.searchParams.set(`w`,String(t.w)),t.h&&n.searchParams.set(`h`,String(t.h)),n.searchParams.set(`q`,String(t.q||75)),n.searchParams.set(`f`,String(t.f||`auto`)),n.pathname+n.search)}catch{return e}}l(),s(),o();var x={class:`cms-image-preview`},S=[`src`,`alt`],C={key:1,class:`loading-overlay`},w=d(t({__name:`CmsImagePreview`,props:{url:{},alt:{default:`Image preview`},width:{default:800},quality:{default:85},isProcessing:{type:Boolean,default:!1}},setup(t){let o=t,s=n(!1),l=n(null),u=f(()=>{if(!o.url)return!1;let e=o.url.toLowerCase();return e.endsWith(`.svg`)||e.includes(`image/svg+xml`)||e.includes(`.svg?`)});a(()=>o.url,(e,t)=>{e&&e!==t&&(s.value=!0,l.value=null)});let d=()=>{s.value=!1},g=()=>{if(l.value!==o.url&&_.value!==o.url){l.value=o.url,s.value=!0;return}s.value=!1},_=f(()=>o.url?u.value||l.value===o.url?o.url:b(o.url,{w:o.width,q:o.quality}):``);return(n,a)=>(r(),i(`div`,x,[_.value?(r(),i(`img`,{key:0,src:_.value,alt:t.alt,class:m([`preview-img`,{"is-blurring":t.isProcessing||s.value,"is-svg":u.value}]),onLoad:d,onError:g},null,42,S)):p(``,!0),t.isProcessing||s.value?(r(),i(`div`,C,[e(c(h),{size:16,class:`spinner`})])):p(``,!0)]))}}),[[`__scopeId`,`data-v-2d18a75f`]]);export{g as a,_ as i,y as n,v as r,w as t};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{B as e,E as t,I as n,K as r,O as i,Q as a,R as o,S as s,T as c,Tt as l,Y as u,b as d,ct as f,et as p,g as m,h,j as g,o as _,t as v,v as y,x as b,y as x}from"./_plugin-vue_export-helper-BK_c4R_m.js";import{c as S,i as ee}from"./useNodes-D-Vuwq5_.js";import{a as C,i as w,n as te,r as T}from"./useCmsState-CDENPbKL.js";import{t as E}from"./circle-check-CksZGUB7.js";import{n as ne,t as D}from"./send-Bs4eROle.js";import{n as re,t as ie}from"./globe-TuZP0v6A.js";import{t as O}from"./history-CIbqkRx3.js";import{t as k}from"./loader-circle-DYEFqbD4.js";import{t as A}from"./CmsButton-DnhPsHXA.js";import{n as j,t as M}from"./CmsBadge-BT2jTJUu.js";g(),u(),f(),_();var ae={class:`publisher-canvas full-width`},oe={class:`publisher-container full-width`},se={class:`publisher-header`},ce={class:`header-actions`},le={key:0,class:`empty-publisher-state`},ue={key:1,class:`empty-publisher-state`},de={key:2,class:`channel-groups-list`},fe={class:`group-header`},N={class:`group-title`},P=[`checked`,`indeterminate`,`onChange`],F={class:`count-badge`},I={class:`nodes-table`},L=[`checked`,`onChange`],R={class:`node-title`},z={key:3,class:`history-section`},B={class:`history-header`},V={class:`history-card`},pe={class:`node-title`},me={class:`history-time`},H=v(i({__name:`CmsPublisher`,setup(i){let u=te(),{loadNodeContent:f}=ee(),g=a(!1),_=a(new Set),v=a(null),H=a(!1),U=a([]),W=a([]),G=a(new Set),he=async()=>{if(u.hasLoadedStats.value){U.value=u.vaultStats.value?.pendingNodes||[],W.value=u.vaultStats.value?.recentActivity||[];return}g.value=!0;try{let e=await fetch(`/api/cms/stats`);if(e.ok){let t=await e.json();u.vaultStats.value=t,u.hasLoadedStats.value=!0,U.value=t.pendingNodes||[],W.value=t.recentActivity||[]}}catch{}finally{g.value=!1}},K=y(()=>{let e=new Map;if(U.value.forEach(t=>{let n=String(u.activeNode.value?.id)===String(t.id),r=S(t),i=n&&u.hasUnpublishedChanges.value||r.hasUnpublishedChanges;e.set(String(t.id),{...t,evalState:{...r,hasUnpublishedChanges:i}})}),u.activeNode.value?.id){let t=String(u.activeNode.value.id),n=S(u.activeNode.value),r=u.hasUnpublishedChanges.value||n.hasUnpublishedChanges;(n.isDraft||n.isUnpublishedDraft||r)&&(e.has(t)||e.set(t,{...u.activeNode.value,evalState:{...n,hasUnpublishedChanges:r}}))}return Array.from(e.values())}),ge=y(()=>{let e=new Map,t=`Unassigned / Vault Only`;return e.set(t,{channelName:t,nodes:[]}),K.value.forEach(n=>{let r=n.channelNames||[];r.length===0?e.get(t).nodes.push(n):r.forEach(t=>{e.has(t)||e.set(t,{channelName:t,nodes:[]}),e.get(t).nodes.push(n)})}),Array.from(e.values()).filter(e=>e.nodes.length>0)}),q=e=>G.value.has(e),_e=e=>{let t=new Set(G.value);t.has(e)?t.delete(e):t.add(e),G.value=t},J=e=>e.filter(e=>G.value.has(e.id)).length,Y=e=>e.length>0&&e.every(e=>G.value.has(e.id)),ve=e=>J(e)>0&&J(e)<e.length,ye=e=>{let t=new Set(G.value),n=Y(e);e.forEach(e=>{n?t.delete(e.id):t.add(e.id)}),G.value=t},X=y(()=>G.value.size),Z=e=>{f({id:e.id,title:e.title,slug:e.slug,nodeType:e.contentType||e.nodeType,channelId:e.channelId||``,language:e.language||`en`,children:[]})},Q=e=>{W.value=[{id:e.id,title:e.title||`Untitled Document`,slug:e.slug,contentType:e.contentType||e.nodeType||`page`,updatedAt:new Date().toISOString()},...W.value.filter(t=>String(t.id)!==String(e.id))].slice(0,10)},be=async e=>{_.value.add(e);try{let t=K.value.find(t=>String(t.id)===String(e)),n=await T.publishNode(e),r=await C(n);u.updateNodeInState(e,{status:`published`,hasUnpublishedChanges:!1}),U.value=U.value.filter(t=>String(t.id)!==String(e));let i=new Set(G.value);for(let t of i)String(t)===String(e)&&i.delete(t);G.value=i,t&&Q(t),u.invalidateStats(),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`cms-node-updated`)),r.published&&w(`Node published, but cache invalidation failed. The site may show stale content; check the server logs.`,`warning`)}catch(e){w(e instanceof Error?e.message:`Failed to publish node.`,`error`)}finally{_.value.delete(e)}},$=async e=>{if(e.length===0)return;let t=e.map(e=>e.id);t.forEach(e=>_.value.add(e));try{let e=await T.publishNodesBatch(t),n=await C(e);if(!Array.isArray(n.publishedIds))throw Error(`Publish response did not include published node IDs.`);let r=n.publishedIds,i=new Set(r.map(String));for(let e of r)u.updateNodeInState(e,{status:`published`,hasUnpublishedChanges:!1});K.value.filter(e=>i.has(String(e.id))).forEach(e=>Q(e)),U.value=U.value.filter(e=>!i.has(String(e.id)));let a=new Set(G.value);for(let e of a)i.has(String(e))&&a.delete(e);G.value=a,u.invalidateStats(),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`cms-node-updated`)),n.published&&w(`Nodes published, but cache invalidation failed. The site may show stale content; check the server logs.`,`warning`)}catch(e){w(e instanceof Error?e.message:`Failed to publish nodes.`,`error`)}finally{t.forEach(e=>_.value.delete(e))}},xe=async(e,t)=>{v.value=e;let n=J(t)>0?t.filter(e=>G.value.has(e.id)):t;await $(n),v.value=null},Se=async()=>{H.value=!0;let e=X.value>0?K.value.filter(e=>G.value.has(e.id)):K.value;await $(e),H.value=!1},Ce=e=>{if(!e)return``;try{return new Date(e).toLocaleString([],{dateStyle:`medium`,timeStyle:`short`})}catch{return e}};return n(()=>he()),(n,i)=>(o(),s(`main`,ae,[x(`div`,oe,[x(`header`,se,[i[2]||=x(`div`,{class:`header-title-group`},[x(`h1`,null,`Publishing Center`),x(`p`,null,`Review and release pending drafts or bulk-publish updates across your distribution channels.`)],-1),x(`div`,ce,[K.value.length>0?(o(),d(A,{key:0,variant:`primary`,class:`publish-all-btn`,disabled:H.value||_.value.size>0,onClick:Se},{default:r(()=>[H.value?(o(),d(p(k),{key:0,size:16,class:`spin`})):(o(),d(p(D),{key:1,size:16})),x(`span`,null,l(X.value>0?`Publish Selected (${X.value})`:`Publish All
|
|
2
|
-
(${K.value.length})`),1)]),_:1},8,[`disabled`])):b(``,!0)])]),g.value&&K.value.length===0?(o(),s(`div`,le,[t(p(k),{size:28,class:`spin empty-icon`}),i[3]||=x(`p`,null,`Gathering pending content updates...`,-1)])):K.value.length===0?(o(),s(`div`,ue,[t(p(E),{size:36,class:`success-icon`}),i[4]||=x(`h3`,null,`All Content Published!`,-1),i[5]||=x(`p`,null,`No draft changes or pending revisions found. Your delivery channels are fully up to date.`,-1)])):(o(),s(`div`,de,[(o(!0),s(m,null,e(ge.value,n=>(o(),s(`section`,{key:n.channelName,class:`channel-group-card`},[x(`div`,fe,[x(`div`,N,[x(`label`,{class:`checkbox-container`,onClick:i[0]||=h(()=>{},[`stop`])},[x(`input`,{type:`checkbox`,checked:Y(n.nodes),indeterminate:ve(n.nodes),onChange:e=>ye(n.nodes)},null,40,P),i[6]||=x(`span`,{class:`checkmark`},null,-1)]),t(p(ie),{size:18,class:`channel-icon`}),x(`h2`,null,l(n.channelName),1),x(`span`,F,l(n.nodes.length)+` Pending`,1)]),t(A,{variant:`secondary`,size:`sm`,disabled:v.value===n.channelName||H.value,onClick:e=>xe(n.channelName,n.nodes)},{default:r(()=>[v.value===n.channelName?(o(),d(p(k),{key:0,size:14,class:`spin`})):(o(),d(p(D),{key:1,size:14})),x(`span`,null,l(J(n.nodes)>0?`Publish Selected
|
|
3
|
-
(${J(n.nodes)})`:`Publish Channel Items`),1)]),_:2},1032,[`disabled`,`onClick`])]),x(`div`,I,[(o(!0),s(m,null,e(n.nodes,n=>(o(),d(j,{key:n.id,"is-selected":q(n.id),clickable:``,onClick:e=>Z(n)},{prefix:r(()=>[x(`label`,{class:`checkbox-container`,onClick:i[1]||=h(()=>{},[`stop`])},[x(`input`,{type:`checkbox`,checked:q(n.id),onChange:e=>_e(n.id)},null,40,L),i[7]||=x(`span`,{class:`checkmark`},null,-1)])]),title:r(()=>[x(`span`,R,l(n.title||`Untitled Draft`),1),t(M,{variant:`type`},{default:r(()=>[c(l(n.contentType||n.nodeType||`page`),1)]),_:2},1024)]),meta:r(()=>[t(M,{variant:`slug`},{default:r(()=>[c(`/`+l(n.slug),1)]),_:2},1024),(o(!0),s(m,null,e(n.treeNames,e=>(o(),d(M,{variant:`tree`,key:e},{default:r(()=>[t(p(re),{size:11}),c(` `+l(e),1)]),_:2},1024))),128))]),actions:r(()=>[t(A,{variant:`secondary`,size:`sm`,class:`icon-only-btn`,title:`Publish Item`,disabled:_.value.has(n.id)||H.value,onClick:h(e=>be(n.id),[`stop`])},{default:r(()=>[_.value.has(n.id)?(o(),d(p(k),{key:0,size:14,class:`spin`})):(o(),d(p(D),{key:1,size:14}))]),_:2},1032,[`disabled`,`onClick`])]),_:2},1032,[`is-selected`,`onClick`]))),128))])]))),128))])),W.value.length>0?(o(),s(`section`,z,[x(`div`,B,[t(p(O),{size:18,class:`history-icon`}),i[8]||=x(`h2`,null,`Recently Published`,-1)]),x(`div`,V,[(o(!0),s(m,null,e(W.value,e=>(o(),d(j,{key:e.id,clickable:``,onClick:t=>Z(e)},{prefix:r(()=>[t(p(E),{size:16,class:`published-check`})]),title:r(()=>[x(`span`,pe,l(e.title||`Untitled Document`),1),t(M,{variant:`type`},{default:r(()=>[c(l(e.contentType||e.nodeType||`page`),1)]),_:2},1024)]),meta:r(()=>[t(M,{variant:`slug`},{default:r(()=>[c(`/`+l(e.slug),1)]),_:2},1024)]),actions:r(()=>[x(`div`,me,[t(p(ne),{size:12}),x(`span`,null,l(Ce(e.updatedAt)),1)])]),_:2},1032,[`onClick`]))),128))])])):b(``,!0)])]))}}),[[`__scopeId`,`data-v-a33a389d`]]);export{H as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{E as e,F as t,I as n,K as r,O as i,P as a,Q as o,R as s,S as c,St as l,T as ee,Tt as u,U as te,W as d,Y as f,b as p,ct as m,et as h,g as ne,j as g,t as _,v,x as y,xt as b,y as x}from"./_plugin-vue_export-helper-BK_c4R_m.js";import{n as re}from"./useCmsState-CDENPbKL.js";import{t as ie}from"./schema-helpers-uuDCw8Rb.js";import{a as S,i as ae,n as oe,r as se,t as ce}from"./x-DOWbsdzd.js";import{n as le,r as ue,t as de}from"./NodeContextMenu-C5RTK0sr.js";import{t as fe}from"./history-CIbqkRx3.js";import{i as pe,n as me,r as he,t as ge}from"./smartphone-i429gh5p.js";import{t as _e}from"./StatusPill-HY1gCP9c.js";g(),f(),m();var ve={class:`split-preview-pane`},ye={class:`preview-toolbar`},be={class:`segmented-control`},xe={class:`segmented-control`},Se={key:0,class:`device-controls-group`},Ce=[`title`],we={class:`trigger-label`},Te=[`title`],Ee={class:`toolbar-right`},De=[`title`,`disabled`],Oe=[`href`],ke=[`src`,`title`],Ae={key:1,class:`payload-stage`},je={key:0,class:`payload-state`},Me={key:1,class:`payload-state payload-error`},Ne={key:2,class:`payload-code`},C=_(i({__name:`EditorSplitPreview`,props:{paneWidthPx:{}},emits:[`close`],setup(i,{emit:f}){let m=i,g=f,{activeNode:_,selectedChannelId:C,selectedLanguage:w,allChannels:T,activeSnapshotVersion:E,nodeSchemas:Pe}=re(),D=o(null),O=o(!1),k=o(null),A=o(null),Fe=0,j=S(`kama_preview_mode`,`draft`),M=S(`kama_preview_content_mode`,`web`),N=S(`kama_preview_device`,`desktop`),P=S(`kama_preview_orientation`,`portrait`),F=S(`kama_preview_autofit`,!0),I=o({w:800,h:800}),L=o(``),R=o(``),z=o(!1),B=o(!1),V=o(Date.now()),H=o(``),Ie=async()=>{let e=_.value?.id;if(!e)return;let t=T.value.find(e=>String(e.id)===String(C.value)),n=!1;if(t)try{let r=t.channelRoot;!r&&t.dataJson&&(r=(typeof t.dataJson==`string`?JSON.parse(t.dataJson):t.dataJson)?.channelRoot),typeof r==`string`&&(r=JSON.parse(r));let i=r?.nodeId??r?.id;i&&String(i)===String(e)&&(n=!0)}catch{}if(n){H.value=`/`;return}try{let n=t?.id||C.value||``,r=await fetch(`/api/cms/nodes.json?id=${e}&channelId=${n}`);if(r.ok){let e=await r.json();if(e.node?.path){H.value=e.node.path;return}}}catch(e){console.error(`Failed to fetch live canonical route`,e)}let r=_.value?.slug||``;H.value=r===`index`?`/`:`/${r.replace(/^\/+|\/+$/g,``)}`};d(()=>_.value?.id,Ie,{immediate:!0});let U={desktop:{label:`Desktop (100% Fluid)`,width:null,height:null},desktop_4k:{label:`4K UHD (3840 × 2160)`,width:3840,height:2160},desktop_fhd:{label:`Full HD (1920 × 1080)`,width:1920,height:1080},macbook_air:{label:`MacBook Air (1440 × 900)`,width:1440,height:900},laptop_std:{label:`Laptop (1366 × 768)`,width:1366,height:768},ipad_pro:{label:`iPad Pro 12.9" (1024 × 1366)`,width:1024,height:1366},ipad_air:{label:`iPad Air / Mini (820 × 1180)`,width:820,height:1180},ipad_standard:{label:`iPad 10th Gen (810 × 1080)`,width:810,height:1080},iphone_15_pro_max:{label:`iPhone 15 Pro Max (430 × 932)`,width:430,height:932},iphone_15_pro:{label:`iPhone 15 Pro (393 × 852)`,width:393,height:852},iphone_se:{label:`iPhone SE (375 × 667)`,width:375,height:667},samsung_s23:{label:`Samsung Galaxy S23 (360 × 780)`,width:360,height:780}},Le=v(()=>{let e=0;return Object.values(U).forEach(t=>{t.label.length>e&&(e=t.label.length)}),`${Math.ceil(e*7.2)+48}px`}),W=o(!1),G=o(null),Re=o(null),ze=v(()=>Object.entries(U).map(([e,t])=>({key:e,label:t.label,title:t.label,isActive:N.value===e}))),Be=()=>{if(W.value){W.value=!1;return}G.value&&(Re.value=G.value.getBoundingClientRect()),W.value=!0},Ve=e=>{N.value=String(e),W.value=!1,Z()},He=v(()=>U[N.value]?.label||`Select Device`),Ue=v(()=>{if(!_.value)return`Untitled`;let e=Pe.value?.[_.value.nodeType||``];return ie(e,_.value)}),K=v(()=>{let e=T.value.find(e=>String(e.id)===String(C.value)),t=e?.baseUrl||e?.url||(typeof window<`u`?window.location.origin:``);if((t.includes(`localhost:8787`)||t.includes(`127.0.0.1:8787`))&&(t=t.replace(`8787`,`4321`)),t=t.replace(/\/$/,``),!_.value?.id)return t;let n=H.value;n.startsWith(`/`)||(n=`/${n}`);let r=n===`/`?``:n,i=w.value?`/${w.value}`:``,a=`${t}${i}${r}`,o=`_cb=${V.value}`;if(!(j.value===`draft`||E.value))return`${a}?${o}`;let s=new URLSearchParams({channelId:String(C.value),path:`${i}${r}`||`/`});return s.set(`_cb`,String(V.value)),E.value&&s.set(`revisionId`,String(E.value)),`/api/cms/preview-site/${encodeURIComponent(String(_.value.id))}?${s.toString()}`}),We=v(()=>{if(!_.value)return`#`;let e=H.value;e.startsWith(`/`)||(e=`/${e}`);let t=e===`/`?``:e,n=w.value?`&lang=${encodeURIComponent(w.value)}`:``,r=E.value?`&revisionId=${encodeURIComponent(String(E.value))}`:``,i=j.value===`draft`||!!E.value;return`/api/cms/preview-payload${t}?channelId=${encodeURIComponent(C.value)}&preview=${i}${n}${r}`}),Ge=async()=>{if(!(M.value!==`json`||!_.value?.id)){z.value=!0,R.value=``;try{let e=await fetch(We.value,{headers:{Accept:`application/json`},cache:`no-store`}),t=await e.json();if(!e.ok)throw Error(t.error||`Failed to load JSON payload (${e.status})`);L.value=JSON.stringify(t,null,2)}catch(e){R.value=e instanceof Error?e.message:`Failed to load JSON payload`,L.value=``}finally{z.value=!1}}},Ke=async()=>{try{await navigator.clipboard.writeText(L.value),B.value=!0,setTimeout(()=>{B.value=!1},2e3)}catch(e){R.value=e instanceof Error?e.message:`Failed to copy JSON payload`}},q=v(()=>N.value!==`desktop`),J=v(()=>{let e=U[N.value];if(!e||!e.width||!e.height)return{w:null,h:null};let t=P.value===`landscape`;return{w:t?e.height:e.width,h:t?e.width:e.height}}),qe=v(()=>{let{w:e,h:t}=J.value;return!e||!t||e>t?`landscape`:`portrait`}),Y=v(()=>{if(!q.value||!F.value)return 1;let{w:e,h:t}=J.value;if(!e||!t)return 1;let n=Math.max(100,I.value.w-48),r=Math.max(100,I.value.h-48),i=n/e,a=r/t;return Math.max(.15,Math.min(i,a))}),X=()=>{if(A.value){let e=A.value.clientWidth,t=A.value.clientHeight;if(e>0&&t>0)I.value={w:e,h:t};else{let e=A.value.getBoundingClientRect();e.width>0&&e.height>0&&(I.value={w:e.width,h:e.height})}}},Z=()=>{a(()=>{requestAnimationFrame(()=>{X()})})},Je=()=>{P.value=P.value===`portrait`?`landscape`:`portrait`,Z()},Ye=()=>{F.value=!F.value,Z()},Xe=()=>{V.value=Date.now(),Ge()},Ze=e=>{let t=D.value?.contentWindow;if(!t||!O.value){k.value=e;return}t.postMessage({type:`kama-preview-update`,html:e},`*`)},Qe=()=>{if(O.value=!0,Z(),k.value!==null){let e=k.value;k.value=null,Ze(e)}},Q=async e=>{let t=e.detail;if(t?.nodeId!=null&&String(t.nodeId)!==String(_.value?.id))return;let n=++Fe,r=K.value;if((t?.routeChanged||t?.action===`create`)&&await Ie(),r===K.value&&D.value?.contentWindow){let e=new URL(K.value,window.location.origin);if(e.pathname.startsWith(`/api/cms/preview-site/`)){try{let t=await fetch(e,{headers:{Accept:`text/html`},cache:`no-store`});if(!t.ok)throw Error(`Preview refresh failed (${t.status}).`);let r=await t.text();if(n!==Fe)return;Ze(r)}catch(e){console.error(`[Preview] Failed to fetch updated draft HTML:`,e)}return}D.value.contentWindow.postMessage({type:`kama-preview-update`,url:e.toString()},e.origin)}};d(K,()=>{O.value=!1,k.value=null}),d(E,e=>{e&&(j.value=`draft`)}),d([M,We,()=>_.value?.id],()=>{Ge()},{immediate:!0}),d(M,e=>{e===`web`&&Z()}),d(()=>m.paneWidthPx,()=>{X()});let $=null;return n(()=>{typeof window<`u`&&window.addEventListener(`cms-node-updated`,Q),A.value&&(X(),$=new ResizeObserver(()=>X()),$.observe(A.value)),Z()}),t(()=>{typeof window<`u`&&window.removeEventListener(`cms-node-updated`,Q),$&&$.disconnect()}),(t,n)=>(s(),c(`div`,ve,[x(`header`,ye,[x(`div`,be,[x(`button`,{type:`button`,class:b([`segmented-btn text-btn`,{active:h(M)===`web`}]),onClick:n[0]||=e=>M.value=`web`},` Web `,2),x(`button`,{type:`button`,class:b([`segmented-btn text-btn`,{active:h(M)===`json`}]),onClick:n[1]||=e=>M.value=`json`},` JSON `,2)]),x(`div`,xe,[h(E)?(s(),p(_e,{key:0,variant:`warning`,icon:h(fe),title:`Viewing Historical Snapshot`},{default:r(()=>[ee(` v`+u(h(E)),1)]),_:1},8,[`icon`])):(s(),c(ne,{key:1},[x(`button`,{type:`button`,class:b([`segmented-btn text-btn`,{active:h(j)===`draft`}]),onClick:n[2]||=e=>j.value=`draft`},` Draft `,2),x(`button`,{type:`button`,class:b([`segmented-btn text-btn`,{active:h(j)===`live`}]),onClick:n[3]||=e=>j.value=`live`},` Public `,2)],64))]),h(M)===`web`?(s(),c(`div`,Se,[q.value?(s(),c(`button`,{key:0,type:`button`,class:b([`icon-btn zoom-btn`,{active:h(F)}]),title:h(F)?`Auto-Fit Active (Click for 1:1 Real Size)`:`1:1 Real Size Active (Click to Auto-Fit)`,onClick:Ye},[(s(),p(te(h(F)?h(he):h(pe)),{size:14}))],10,Ce)):y(``,!0),x(`div`,{class:`device-menu-wrapper`,ref_key:`deviceTriggerRef`,ref:G,style:l({width:Le.value})},[x(`button`,{type:`button`,class:`device-trigger-btn`,onClick:Be},[e(h(me),{size:13,class:`trigger-icon`}),x(`span`,we,u(He.value),1),e(h(se),{size:12,class:`chevron-icon`})]),e(de,{show:W.value,items:ze.value,"anchor-rect":Re.value,"min-width":Le.value,onSelect:Ve,onClose:n[4]||=e=>W.value=!1},null,8,[`show`,`items`,`anchor-rect`,`min-width`])],4),q.value?(s(),c(`button`,{key:1,type:`button`,class:`icon-btn orientation-btn`,title:`Switch to ${qe.value===`portrait`?`Landscape`:`Portrait`}`,onClick:Je},[e(h(ge),{size:14,style:l({transform:qe.value===`landscape`?`rotate(90deg)`:`rotate(0deg)`,transition:`transform 0.2s`})},null,8,[`style`])],8,Te)):y(``,!0)])):y(``,!0),x(`div`,Ee,[x(`button`,{type:`button`,class:`icon-btn`,title:`Refresh Preview`,onClick:Xe},[e(h(oe),{size:13})]),h(M)===`json`?(s(),c(`button`,{key:0,type:`button`,class:`icon-btn`,title:B.value?`Copied`:`Copy JSON`,disabled:!L.value,onClick:Ke},[B.value?(s(),p(h(ae),{key:0,size:13})):(s(),p(h(ue),{key:1,size:13}))],8,De)):y(``,!0),h(M)===`web`?(s(),c(`a`,{key:1,href:K.value,target:`_blank`,class:`icon-btn`,title:`Open Preview in New Tab`},[e(h(le),{size:13})],8,Oe)):y(``,!0),x(`button`,{type:`button`,class:`icon-btn close-btn`,title:`Close Split View`,onClick:n[5]||=e=>g(`close`)},[e(h(ce),{size:14})])])]),h(M)===`web`?(s(),c(`div`,{key:0,ref_key:`stageRef`,ref:A,class:b([`preview-stage`,{"is-fixed-frame":q.value}])},[x(`div`,{class:`device-frame-wrapper`,style:l(q.value&&J.value.w&&J.value.h?{width:`${J.value.w*Y.value}px`,height:`${J.value.h*Y.value}px`}:{width:`100%`,height:`100%`})},[x(`div`,{class:`device-frame`,style:l(q.value&&J.value.w&&J.value.h?{width:`${J.value.w}px`,height:`${J.value.h}px`,transform:`scale(${Y.value})`,transformOrigin:`top left`}:{width:`100%`,height:`100%`})},[(s(),c(`iframe`,{key:K.value,ref_key:`previewIframeRef`,ref:D,src:K.value,class:`preview-iframe`,title:Ue.value,onLoad:Qe},null,40,ke))],4)],4)],2)):(s(),c(`div`,Ae,[z.value?(s(),c(`div`,je,`Loading JSON payload...`)):R.value?(s(),c(`div`,Me,u(R.value),1)):(s(),c(`pre`,Ne,[x(`code`,null,u(L.value),1)]))]))]))}}),[[`__scopeId`,`data-v-0e7e709e`]]);export{C as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.email-finisher-settings[data-v-acc8ebe5]{flex-direction:column;gap:8px;margin:4px 0 14px;display:flex}.field-label[data-v-acc8ebe5]{color:var(--cms-color-text-muted,#64748b);font-family:var(--cms-font-sans);letter-spacing:.06em;text-transform:uppercase;flex-direction:column;gap:6px;margin-bottom:8px;font-size:11px;font-weight:700;display:flex}.field-label input[data-v-acc8ebe5],.field-label select[data-v-acc8ebe5],.field-label textarea[data-v-acc8ebe5]{box-sizing:border-box;border:1px solid var(--cms-color-border-dark,#cbd5e1);border-radius:var(--cms-radius-sm,4px);background:var(--cms-color-surface,#fff);width:100%;color:var(--cms-color-text-main,#0f172a);font-family:var(--cms-font-sans);transition:all var(--cms-transition-fast,.15s ease);outline:none;padding:8.5px 11px;font-size:14px}.field-label input[data-v-acc8ebe5]:focus:not(:disabled),.field-label select[data-v-acc8ebe5]:focus:not(:disabled),.field-label textarea[data-v-acc8ebe5]:focus:not(:disabled){border-color:var(--cms-color-primary,#2563eb)}.template-help[data-v-acc8ebe5]{margin:0;font-size:10px;line-height:1.4}.field-label input[data-v-acc8ebe5]:disabled,.field-label select[data-v-acc8ebe5]:disabled,.field-label textarea[data-v-acc8ebe5]:disabled{opacity:.6;background:var(--cms-color-surface-hover,#f8fafc);border-color:var(--cms-color-border,#e2e8f0);cursor:not-allowed}.cms-toggle[data-v-477f63a5]{color:var(--cms-color-text-main,#0f172a);cursor:pointer;justify-content:space-between;align-items:center;gap:12px;margin:10px 0;font-size:13px;line-height:1.4;display:flex}.cms-toggle.is-disabled[data-v-477f63a5]{cursor:not-allowed}.toggle-switch[data-v-477f63a5]{flex-shrink:0;width:42px;height:22px;display:inline-block;position:relative}.toggle-switch input[data-v-477f63a5]{z-index:1;opacity:0;width:100%;height:100%;cursor:inherit;margin:0;position:absolute;inset:0}.slider[data-v-477f63a5]{border:1px solid var(--cms-color-border-dark,#cbd5e1);border-radius:var(--cms-radius-full,999px);background:var(--cms-color-surface-active,#cbd5e1);pointer-events:none;transition:var(--cms-transition-fast,.15s ease);position:absolute;inset:0}.slider[data-v-477f63a5]:before{border-radius:var(--cms-radius-full,999px);content:"";width:16px;height:16px;transition:var(--cms-transition-fast,.15s ease);background:#fff;position:absolute;bottom:2px;left:2px}.toggle-switch input:checked+.slider[data-v-477f63a5]:before{transform:translate(20px)}.toggle-switch input:focus-visible+.slider[data-v-477f63a5]{outline:2px solid var(--cms-color-primary,#2563eb);outline-offset:2px}.toggle-switch input:disabled+.slider[data-v-477f63a5]{opacity:.6}.variant-primary input:checked+.slider[data-v-477f63a5]{border-color:var(--cms-color-primary-hover,#1d4ed8);background:var(--cms-color-primary,#2563eb)}.variant-success input:checked+.slider[data-v-477f63a5]{border-color:var(--cms-color-success,#15803d);background:var(--cms-color-success,#15803d)}.variant-danger input:checked+.slider[data-v-477f63a5]{border-color:var(--cms-color-danger-hover,#b91c1c);background:var(--cms-color-danger,#dc2626)}.finishers-workspace[data-v-05865a8c]{height:100%;padding:8px 4px;overflow:auto}.finishers-workspace[data-v-05865a8c] .finisher-accordion>.accordion-summary>.accordion-title{font-weight:700}.settings-note[data-v-05865a8c],.settings-error[data-v-05865a8c],.settings-success[data-v-05865a8c]{margin:10px 0;font-size:12px;line-height:1.45}.settings-note[data-v-05865a8c]{color:var(--cms-color-text-muted,#64748b)}.settings-error[data-v-05865a8c],.state-error[data-v-05865a8c]{color:var(--cms-color-danger,#b91c1c)}.state-error[data-v-05865a8c],.state-loading[data-v-05865a8c]{padding:16px}.state-loading[data-v-05865a8c]{color:var(--cms-color-text-muted,#64748b)}.retry-settings-btn[data-v-05865a8c]{border:1px solid var(--cms-color-border,#cbd5e1);border-radius:var(--cms-radius-sm,4px);background:var(--cms-color-surface,#fff);color:var(--cms-color-text-main,#0f172a);cursor:pointer;font:inherit;padding:6px 10px}.settings-success[data-v-05865a8c]{color:var(--cms-color-success,#15803d)}.workspace-view[data-v-0db272e9]{box-sizing:border-box;background:var(--cms-color-bg,#f8fafc);flex-direction:column;height:100%;padding:0;display:flex;overflow:hidden}.workspace-header[data-v-0db272e9]{z-index:100;background:var(--cms-color-bg,#f8fafc);border-bottom:1px solid var(--cms-color-border,#e2e8f0);flex-direction:column;flex-shrink:0;display:flex;position:sticky;top:0}.top-row[data-v-0db272e9]{justify-content:space-between;align-items:center;padding:10px 20px 6px;display:flex}.header-titles[data-v-0db272e9]{flex-direction:column;align-items:flex-start;gap:4px;display:flex}.header-titles h2[data-v-0db272e9]{color:var(--cms-color-text-main,#0f172a);margin:0;font-size:17px;font-weight:700}.header-actions[data-v-0db272e9]{align-items:center;gap:10px;display:flex}.form-id-badge[data-v-0db272e9]{background:var(--cms-color-surface-hover,#e2e8f0);color:var(--cms-color-text-muted,#64748b);border-radius:4px;padding:2px 8px;font-family:monospace;font-size:11px}.bottom-row[data-v-0db272e9]{box-sizing:border-box;align-items:center;height:44px;display:flex}.tab-navigation[data-v-0db272e9]{scrollbar-width:none;align-items:center;gap:4px;width:100%;height:100%;padding:0 10px 0 15px;display:flex;overflow-x:auto}.tab-navigation[data-v-0db272e9]::-webkit-scrollbar{display:none}.tab-navigation button[data-v-0db272e9]{height:100%;color:var(--cms-color-text-muted,#64748b);font-family:var(--cms-font-sans);white-space:nowrap;cursor:pointer;background:0 0;border:none;padding:0 16px;font-size:13px;font-weight:600;position:relative}.tab-navigation button[data-v-0db272e9]:hover,.tab-navigation button.active[data-v-0db272e9]{color:var(--cms-color-primary,#2563eb)}.tab-navigation button.active[data-v-0db272e9]:after{border-radius:var(--cms-radius-xs,2px) var(--cms-radius-xs,2px) 0 0;background:var(--cms-color-primary,#2563eb);content:"";height:2px;position:absolute;bottom:-1px;left:0;right:0}.btn-refresh[data-v-0db272e9]{background:var(--cms-color-surface,#fff);border:1px solid var(--cms-color-border,#cbd5e1);border-radius:var(--cms-radius-sm,4px);cursor:pointer;color:var(--cms-color-text-main,#0f172a);align-items:center;gap:6px;padding:6px 12px;font-size:12px;font-weight:500;display:inline-flex}.save-btn[data-v-0db272e9]{align-items:center;gap:6px;display:flex}.save-icon[data-v-0db272e9]{margin-top:-1px}.tab-panel[data-v-0db272e9]{flex-direction:column;flex:1;min-height:0;margin:0 24px 24px;display:flex}.submissions-content[data-v-0db272e9]{flex-direction:column;flex:1;min-height:0;display:flex}.submissions-toolbar[data-v-0db272e9]{color:var(--cms-color-text-muted,#64748b);align-items:center;gap:12px;padding:10px 0;font-size:12px;display:flex}.select-all[data-v-0db272e9],.submission-select[data-v-0db272e9]{align-items:center;gap:7px;display:inline-flex}.select-all[data-v-0db272e9]{margin-left:12px}.select-all input[data-v-0db272e9],.submission-select input[data-v-0db272e9]{margin:0}.selection-count[data-v-0db272e9]{white-space:nowrap}.submission-actions[data-v-0db272e9]{gap:8px;margin-left:auto;display:flex}.download-btn[data-v-0db272e9],.delete-selected-btn[data-v-0db272e9]{border:1px solid var(--cms-color-border,#cbd5e1);border-radius:var(--cms-radius-sm,4px);background:var(--cms-color-surface,#fff);color:var(--cms-color-text-main,#0f172a);font:inherit;cursor:pointer;justify-content:center;align-items:center;gap:6px;padding:7px 10px;display:inline-flex}.delete-selected-btn[data-v-0db272e9]{color:var(--cms-color-danger,#b91c1c)}.download-btn[data-v-0db272e9]:disabled,.delete-selected-btn[data-v-0db272e9]:disabled{opacity:.5;cursor:not-allowed}.delete-error[data-v-0db272e9]{color:var(--cms-color-danger,#b91c1c);margin:10px 0 0;font-size:13px}.submission-list[data-v-0db272e9]{flex-direction:column;flex:1;gap:8px;min-height:0;display:flex;overflow:auto}.submission-row[data-v-0db272e9]{min-width:0}.submission-select[data-v-0db272e9]{justify-content:center}.submission-accordion[data-v-0db272e9]{min-width:0}.submission-accordion[data-v-0db272e9] time{white-space:nowrap}.submission-fields-table[data-v-0db272e9]{border-collapse:collapse;text-align:left;width:100%;margin:8px 0 0;font-size:13px}.submission-fields-table th[data-v-0db272e9],.submission-fields-table td[data-v-0db272e9]{border-bottom:1px solid var(--cms-color-border,#e2e8f0);vertical-align:top;padding:9px 12px}.submission-fields-table thead th[data-v-0db272e9]{background:var(--cms-color-surface-hover,#f1f5f9);color:var(--cms-color-text-muted,#475569);font-weight:600}.submission-fields-table tbody th[data-v-0db272e9]{width:28%;color:var(--cms-color-text-main,#0f172a);font-weight:600}.submission-fields-table tbody td[data-v-0db272e9]{color:var(--cms-color-text-main,#0f172a);white-space:pre-wrap;overflow-wrap:anywhere}.state-empty[data-v-0db272e9],.state-loading[data-v-0db272e9],.state-error[data-v-0db272e9]{color:var(--cms-color-text-muted,#64748b);flex-direction:column;flex:1;justify-content:center;align-items:center;gap:12px;font-size:14px;display:flex}.state-error[data-v-0db272e9]{color:var(--cms-color-danger,#b91c1c)}.empty-icon[data-v-0db272e9]{opacity:.4}@media (width<=690px){.top-row[data-v-0db272e9]{padding-left:12px;padding-right:12px}.tab-panel[data-v-0db272e9]{margin-left:12px;margin-right:12px}.tab-navigation[data-v-0db272e9]{padding-left:7px}.submission-actions[data-v-0db272e9]{flex-wrap:wrap}}@media (width<=600px){.select-all[data-v-0db272e9]{margin-left:10px}}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{B as e,E as t,H as n,I as r,K as i,L as a,O as o,Q as s,R as c,S as l,T as u,Tt as d,W as f,Y as p,b as ee,ct as m,et as h,g,h as _,j as v,o as y,t as b,v as x,x as S,xt as C,y as w}from"./_plugin-vue_export-helper-BK_c4R_m.js";import{n as T,s as E}from"./useCmsState-CDENPbKL.js";import{t as D}from"./save-Dwhm8QNL.js";import{t as O}from"./CmsButton-DnhPsHXA.js";import{t as k}from"./CmsAccordion-BgdaB8QZ.js";v(),m();var A={class:`email-finisher-settings`},j={key:0,class:`field-label`},M=[`value`],N={key:1,class:`field-label`},P=[`value`],F=[`value`],I={class:`field-label`},L=[`value`],R={class:`field-label`},z=[`value`,`disabled`],B={class:`field-label`},V=[`value`],H=[`value`],U={class:`field-label`},W=[`value`,`disabled`],G={class:`field-label`},K=[`value`],q=[`value`],J={class:`field-label`},Y=[`value`,`disabled`],X={class:`field-label`},Z=[`value`],Q=[`value`],te={class:`field-label`},ne=[`value`],re={class:`field-label`},ie=[`value`],ae=b(o({__name:`FormEmailFinisherSettings`,props:{modelValue:{},fields:{},recipientMode:{}},emits:[`update:modelValue`],setup(n,{emit:r}){let a=n,o=r,s=x(()=>a.fields),f=x(()=>a.fields.filter(e=>e.type===`email`));function p(e,t,n){let r={...a.modelValue,[e]:t};n&&(r[n]=void 0),o(`update:modelValue`,r)}return(r,a)=>(c(),l(`div`,A,[n.recipientMode===`fixed`?(c(),l(`label`,j,[a[11]||=u(` Recipient email `,-1),w(`input`,{value:n.modelValue.to||``,type:`email`,placeholder:`team@example.com`,onInput:a[0]||=e=>p(`to`,e.target.value)},null,40,M)])):(c(),l(`label`,N,[a[13]||=u(` Send to email field `,-1),w(`select`,{value:n.modelValue.toField||``,onChange:a[1]||=e=>p(`toField`,e.target.value)},[a[12]||=w(`option`,{value:``,disabled:``},`Select an email field`,-1),(c(!0),l(g,null,e(f.value,e=>(c(),l(`option`,{key:e.name,value:e.name},d(e.label),9,F))),128))],40,P)])),w(`label`,I,[a[14]||=u(` Sender email `,-1),w(`input`,{value:n.modelValue.from||``,type:`email`,placeholder:`Use package default`,onInput:a[2]||=e=>p(`from`,e.target.value)},null,40,L)]),w(`label`,R,[a[15]||=u(` Subject `,-1),w(`input`,{value:n.modelValue.subject||``,type:`text`,placeholder:`New form submission`,disabled:!!n.modelValue.subjectField,onInput:a[3]||=e=>p(`subject`,e.target.value,`subjectField`)},null,40,z)]),w(`label`,B,[a[17]||=u(` Or use a form field `,-1),w(`select`,{value:n.modelValue.subjectField||``,onChange:a[4]||=e=>p(`subjectField`,e.target.value||void 0,`subject`)},[a[16]||=w(`option`,{value:``},`Use subject above or default`,-1),(c(!0),l(g,null,e(s.value,e=>(c(),l(`option`,{key:e.name,value:e.name},d(e.label),9,H))),128))],40,V)]),w(`label`,U,[a[18]||=u(` Sender display name `,-1),w(`input`,{value:n.modelValue.fromName||``,type:`text`,placeholder:`KAMA`,disabled:!!n.modelValue.fromNameField,onInput:a[5]||=e=>p(`fromName`,e.target.value,`fromNameField`)},null,40,W)]),w(`label`,G,[a[20]||=u(` Or use a form field `,-1),w(`select`,{value:n.modelValue.fromNameField||``,onChange:a[6]||=e=>p(`fromNameField`,e.target.value||void 0,`fromName`)},[a[19]||=w(`option`,{value:``},`Use name above or server default`,-1),(c(!0),l(g,null,e(s.value,e=>(c(),l(`option`,{key:e.name,value:e.name},d(e.label),9,q))),128))],40,K)]),w(`label`,J,[a[21]||=u(` Reply-to address `,-1),w(`input`,{value:n.modelValue.replyTo||``,type:`email`,placeholder:`Optional`,disabled:!!n.modelValue.replyToField,onInput:a[7]||=e=>p(`replyTo`,e.target.value,`replyToField`)},null,40,Y)]),w(`label`,X,[a[23]||=u(` Or use an email field `,-1),w(`select`,{value:n.modelValue.replyToField||``,onChange:a[8]||=e=>p(`replyToField`,e.target.value||void 0,`replyTo`)},[a[22]||=w(`option`,{value:``},`Use address above or no reply-to`,-1),(c(!0),l(g,null,e(f.value,e=>(c(),l(`option`,{key:e.name,value:e.name},d(e.label),9,Q))),128))],40,Z)]),t(k,{title:`Message body templates`,compact:``,class:`body-settings`},{default:i(()=>[w(`label`,te,[a[24]||=u(` Plain text body `,-1),w(`textarea`,{value:n.modelValue.text||``,rows:`4`,placeholder:`Leave blank to include all submitted fields`,onInput:a[9]||=e=>p(`text`,e.target.value)},null,40,ne)]),w(`label`,re,[a[25]||=u(` HTML body `,-1),w(`textarea`,{value:n.modelValue.html||``,rows:`4`,placeholder:`Optional HTML message`,onInput:a[10]||=e=>p(`html`,e.target.value)},null,40,ie)]),a[26]||=w(`p`,{class:`template-help`},[u(`Use `),w(`code`,null,`{{field}}`),u(` placeholders. Values inserted into HTML are escaped.`)],-1)]),_:1})]))}}),[[`__scopeId`,`data-v-acc8ebe5`]]);v(),m();var oe={class:`toggle-label`},se=[`checked`,`disabled`],$=b(o({__name:`CmsToggle`,props:{modelValue:{type:Boolean},label:{},disabled:{type:Boolean,default:!1},variant:{default:`success`}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=t;return(t,r)=>(c(),l(`label`,{class:C([`cms-toggle`,{"is-disabled":e.disabled}])},[w(`span`,oe,d(e.label),1),w(`span`,{class:C([`toggle-switch`,`variant-${e.variant}`])},[w(`input`,{type:`checkbox`,role:`switch`,checked:e.modelValue,disabled:e.disabled,onChange:r[0]||=e=>n(`update:modelValue`,e.target.checked)},null,40,se),r[1]||=w(`span`,{class:`slider`,"aria-hidden":`true`},null,-1)],2)],2))}}),[[`__scopeId`,`data-v-477f63a5`]]);v(),m(),p();var ce={class:`finishers-workspace`},le={key:0,class:`state-loading`},ue={key:1,class:`state-error`},de={class:`settings-note`},fe={class:`settings-note`},pe={class:`settings-note`},me={key:1,class:`settings-note`},he={key:2,class:`settings-error`},ge={key:3,class:`settings-success`},_e=b(o({__name:`FormFinishersWorkspace`,props:{formId:{}},setup(e,{expose:n}){let r=e,a=s([]),o=s(!1),p=s(!1),m=s(!1),h=s({id:`notify-team`,type:`email`}),_=s({id:`submitter-confirmation`,type:`email`}),v=s([]),y=s({provider:`auto`,cloudflare:!1,smtp:!1,senderConfigured:!1}),b=s(!1),C=s(!1),T=s(!1),E=s(``),D=s(``),O=0,A=x(()=>y.value.senderConfigured?y.value.provider===`cloudflare`?y.value.cloudflare:y.value.provider===`smtp`?y.value.smtp:y.value.provider===`auto`&&(y.value.cloudflare||y.value.smtp):!1),j=x(()=>v.value.length>0),M=x(()=>C.value&&!T.value&&!(p.value&&!h.value.to?.trim())&&!(m.value&&!_.value.toField));async function N(e){let t=++O;if(C.value=!1,E.value=``,D.value=``,!e){b.value=!1;return}b.value=!0;try{let n=await fetch(`/api/cms/forms/${encodeURIComponent(e)}/finishers`),r=await n.json();if(!n.ok)throw Error(r.error||`Failed to load settings (${n.status})`);if(t!==O)return;let i=r.finishers||[],s=i.find(e=>e.id===`notify-team`),c=i.find(e=>e.id===`submitter-confirmation`);v.value=i.filter(e=>e.type!==`database`&&(e.type!==`email`||e.id!==`notify-team`&&e.id!==`submitter-confirmation`)),a.value=r.fields||[],o.value=i.some(e=>e.type===`database`),p.value=!!s,h.value={id:`notify-team`,type:`email`,...s},m.value=!!c,_.value={id:`submitter-confirmation`,type:`email`,toField:a.value.find(e=>e.type===`email`)?.name,...c},y.value=r.emailTransport||{provider:`auto`,cloudflare:!1,smtp:!1,senderConfigured:!1},C.value=!0}catch(e){t===O&&(E.value=e instanceof Error?e.message:`Failed to load form settings`)}finally{t===O&&(b.value=!1)}}async function P(){if(!r.formId||T.value)return;T.value=!0,E.value=``,D.value=``;let e=[...v.value];o.value&&e.push({id:`save-submission`,type:`database`}),p.value&&e.push({...h.value,to:h.value.to?.trim()}),m.value&&e.push(_.value);try{let t=await fetch(`/api/cms/forms/${encodeURIComponent(r.formId)}/finishers`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({finishers:e})}),n=await t.json();if(!t.ok)throw Error(n.error||`Failed to save settings (${t.status})`);D.value=`Form settings saved.`,window.dispatchEvent(new CustomEvent(`forms-settings-updated`,{detail:r.formId}))}catch(e){E.value=e instanceof Error?e.message:`Failed to save form settings`}finally{T.value=!1}}return f(()=>r.formId,e=>{N(e)},{immediate:!0}),n({saveSettings:P,canSaveSettings:M}),(n,r)=>(c(),l(`section`,ce,[b.value?(c(),l(`div`,le,`Loading finisher settings...`)):C.value?(c(),l(g,{key:2},[t(k,{title:`Submission storage`,class:`finisher-accordion`,status:o.value?`Enabled`:`Disabled`,"status-variant":o.value?`success`:`muted`,"default-open":``},{default:i(()=>[t($,{modelValue:o.value,"onUpdate:modelValue":r[1]||=e=>o.value=e,label:`Save submissions to database`},null,8,[`modelValue`])]),_:1},8,[`status`,`status-variant`]),t(k,{title:`Email the team`,class:`finisher-accordion`,status:p.value?`Enabled`:`Disabled`,"status-variant":p.value?`success`:`muted`},{default:i(()=>[t($,{modelValue:p.value,"onUpdate:modelValue":r[2]||=e=>p.value=e,label:`Enable this finisher`},null,8,[`modelValue`]),t(ae,{modelValue:h.value,"onUpdate:modelValue":r[3]||=e=>h.value=e,fields:a.value,"recipient-mode":`fixed`},null,8,[`modelValue`,`fields`]),w(`p`,de,[A.value?(c(),l(g,{key:0},[u(` Email is sent using the server's configured provider. `)],64)):(c(),l(g,{key:1},[u(` Configure a Cloudflare Email Sending binding or Node SMTP, plus a package default sender or a sender address on this finisher, before enabling email. `)],64))])]),_:1},8,[`status`,`status-variant`]),t(k,{title:`Send confirmation to submitter`,class:`finisher-accordion`,status:m.value?`Enabled`:`Disabled`,"status-variant":m.value?`success`:`muted`},{default:i(()=>[t($,{modelValue:m.value,"onUpdate:modelValue":r[4]||=e=>m.value=e,label:`Enable this finisher`,disabled:!a.value.some(e=>e.type===`email`)},null,8,[`modelValue`,`disabled`]),t(ae,{modelValue:_.value,"onUpdate:modelValue":r[5]||=e=>_.value=e,fields:a.value,"recipient-mode":`field`},null,8,[`modelValue`,`fields`]),w(`p`,fe,[A.value?(c(),l(g,{key:0},[u(` Email is sent using the server's configured provider. `)],64)):(c(),l(g,{key:1},[u(` Configure a Cloudflare Email Sending binding or Node SMTP, plus a package default sender or a sender address on this finisher, before enabling email. `)],64))])]),_:1},8,[`status`,`status-variant`]),j.value?(c(),ee(k,{key:0,title:`Custom finishers`,class:`finisher-accordion`,status:`${v.value.length} enabled`,"status-variant":`success`},{default:i(()=>[w(`p`,pe,d(v.value.length)+` custom finisher(s) are enabled and managed by the server configuration. `,1)]),_:1},8,[`status`])):S(``,!0),!o.value&&!p.value&&!m.value&&!j.value?(c(),l(`p`,me,` No finishers are enabled. Form submissions will not be stored or emailed. `)):S(``,!0),E.value?(c(),l(`p`,he,d(E.value),1)):D.value?(c(),l(`p`,ge,d(D.value),1)):S(``,!0)],64)):(c(),l(`div`,ue,[w(`p`,null,d(E.value||`Finisher settings could not be loaded.`),1),w(`button`,{type:`button`,class:`retry-settings-btn`,onClick:r[0]||=t=>N(e.formId)},`Retry`)]))]))}}),[[`__scopeId`,`data-v-05865a8c`]]);function ve(e){let t=e==null?``:typeof e==`string`?e:typeof e==`object`?JSON.stringify(e)||``:String(e);return/^\s*[=+\-@]/.test(t)&&(t=`'${t}`),`"${t.replaceAll(`"`,`""`)}"`}function ye(e,t){let n=new Map(e.map(e=>[e.name,e]));for(let e of t)for(let t of Object.keys(e.data))n.has(t)||n.set(t,{name:t,label:t});let r=[...n.values()];return`\uFEFF${[[`Submission ID`,`Submitted At`,...r.map(e=>e.label||e.name)],...t.map(e=>[e.id,e.createdAt,...r.map(t=>e.data[t.name])])].map(e=>e.map(ve).join(`,`)).join(`\r
|
|
2
|
-
`)}`}v(),m(),p(),y();var be={class:`workspace-view`},xe={class:`workspace-header`},Se={class:`top-row`},Ce={class:`header-titles`},we={key:0,class:`form-id-badge`},Te={key:0,class:`header-actions`},Ee={key:0,class:`bottom-row`},De={class:`tab-navigation`,role:`tablist`,"aria-label":`Form workspace`},Oe=[`aria-selected`],ke=[`aria-selected`],Ae={key:0,class:`state-empty`},je={key:1,id:`forms-finishers-panel`,class:`tab-panel`,role:`tabpanel`,"aria-labelledby":`forms-finishers-tab`,tabindex:`0`},Me={key:2,id:`forms-submissions-panel`,class:`tab-panel`,role:`tabpanel`,"aria-labelledby":`forms-submissions-tab`,tabindex:`0`},Ne={key:0,class:`state-loading`},Pe={key:1,class:`state-error`},Fe={key:2,class:`state-empty`},Ie={key:3,class:`submissions-content`},Le={class:`submissions-toolbar`},Re={class:`select-all`},ze=[`checked`,`disabled`],Be={class:`selection-count`},Ve={class:`submission-actions`},He=[`disabled`],Ue=[`disabled`],We={key:0,class:`delete-error`,role:`alert`},Ge={class:`submission-list`},Ke=[`aria-label`,`checked`,`disabled`,`onChange`],qe=[`datetime`],Je={class:`submission-fields-table`},Ye={scope:`row`},Xe=b(o({__name:`FormsWorkspace`,setup(o){let p=s(``),m=s(``),v=s([]),y=s([]),b=s(new Set),A=s(!0),j=s(!1),M=s(``),N=s(``),P=s(!1),F=s(!1),I=s(`submissions`),L=s(null),{activeView:R}=T(),{confirmDiscard:z}=E(),B=x(()=>b.value.size),V=x(()=>v.value.length>0&&v.value.every(e=>b.value.has(e.id))),H=()=>{L.value?.saveSettings()},U=e=>{let t=e.detail;t&&t===p.value&&G(t)},W=0,G=async e=>{if(!e)return;let t=++W;p.value=e,j.value=!0,M.value=``;try{let n=await fetch(`/api/cms/forms/${encodeURIComponent(e)}/submissions`),r=await n.json();if(!n.ok)throw Error(r.error||`Failed to fetch submissions (${n.status})`);if(t!==W)return;v.value=r.submissions||[],y.value=r.fields||[],A.value=r.storageEnabled!==!1,m.value=r.formTitle||e;let i=new Set(v.value.map(e=>e.id));b.value=new Set([...b.value].filter(e=>i.has(e))),!A.value&&I.value===`submissions`&&(I.value=`finishers`)}catch(e){t===W&&(M.value=e instanceof Error?e.message:`Failed to fetch form submissions`)}finally{t===W&&(j.value=!1)}};function K(e){let t=[...y.value],n=new Set(t.map(e=>e.name));for(let r of Object.keys(e.data))n.has(r)||t.push({name:r,label:r});return t}function q(e){return e==null||e===``?`—`:typeof e==`object`?JSON.stringify(e,null,2)||``:String(e)}function J(e){let t=e.target.checked;b.value=t?new Set(v.value.map(e=>e.id)):new Set}function Y(e){let t=new Set(b.value);t.has(e)?t.delete(e):t.add(e),b.value=t}async function X(e,t){if(P.value||F.value)return!1;F.value=!0;try{return await z(e,t,`Delete`,`Cancel`)}finally{F.value=!1}}async function Z(){let e=p.value,t=[...b.value];if(t.length&&!(!await X(`Permanently delete ${t.length} selected submissions? This cannot be undone.`,`Delete selected submissions?`)||e!==p.value)){P.value=!0,N.value=``;try{let n=await fetch(`/api/cms/forms/${encodeURIComponent(e)}/submissions`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({ids:t})}),r=await n.json();if(!n.ok)throw Error(r.error||`Failed to delete submissions (${n.status})`);p.value===e&&await G(e)}catch(t){p.value===e&&(N.value=t instanceof Error?t.message:`Failed to delete submissions`)}finally{P.value=!1}}}function Q(){let e=ye(y.value,v.value),t=URL.createObjectURL(new Blob([e],{type:`text/csv;charset=utf-8`})),n=document.createElement(`a`),r=p.value.replace(/[^a-zA-Z0-9_-]/g,`-`)||`form`;n.href=t,n.download=`${r}-submissions.csv`,document.body.append(n),n.click(),n.remove(),window.setTimeout(()=>URL.revokeObjectURL(t),0)}return f(()=>R.value.type===`forms`?R.value.id:void 0,e=>{W++,p.value=e||``,v.value=[],y.value=[],b.value.clear(),A.value=!0,I.value=`submissions`,m.value=``,M.value=``,N.value=``,e&&G(e)},{immediate:!0}),r(()=>window.addEventListener(`forms-settings-updated`,U)),a(()=>window.removeEventListener(`forms-settings-updated`,U)),(r,a)=>{let o=n(`KamaIcon`);return c(),l(`div`,be,[w(`header`,xe,[w(`div`,Se,[w(`div`,Ce,[w(`h2`,null,d(m.value||`Forms`),1),p.value?(c(),l(`span`,we,`ID: `+d(p.value),1)):S(``,!0)]),p.value?(c(),l(`div`,Te,[I.value===`finishers`?(c(),ee(O,{key:0,variant:`primary`,class:`save-btn`,disabled:!L.value?.canSaveSettings,title:`Save finishers`,onClick:H},{default:i(()=>[t(h(D),{size:14,class:`save-icon`}),a[4]||=w(`span`,null,`Save finishers`,-1)]),_:1},8,[`disabled`])):A.value&&!j.value?(c(),l(`button`,{key:1,class:`btn-refresh`,onClick:a[0]||=e=>G(p.value)},[t(o,{name:`RotateCw`,size:`14`}),a[5]||=w(`span`,null,`Refresh`,-1)])):S(``,!0)])):S(``,!0)]),p.value?(c(),l(`div`,Ee,[w(`div`,De,[A.value?(c(),l(`button`,{key:0,id:`forms-submissions-tab`,type:`button`,role:`tab`,"aria-controls":`forms-submissions-panel`,"aria-selected":I.value===`submissions`,class:C({active:I.value===`submissions`}),onClick:a[1]||=e=>I.value=`submissions`},` Submissions `,10,Oe)):S(``,!0),w(`button`,{id:`forms-finishers-tab`,type:`button`,role:`tab`,"aria-controls":`forms-finishers-panel`,"aria-selected":I.value===`finishers`,class:C({active:I.value===`finishers`}),onClick:a[2]||=e=>I.value=`finishers`},` Finishers `,10,ke)])])):S(``,!0)]),p.value?I.value===`finishers`?(c(),l(`div`,je,[t(_e,{ref_key:`finisherWorkspace`,ref:L,"form-id":p.value},null,8,[`form-id`])])):(c(),l(`div`,Me,[j.value?(c(),l(`div`,Ne,[...a[7]||=[w(`p`,null,`Loading submissions...`,-1)]])):M.value?(c(),l(`div`,Pe,[w(`p`,null,d(M.value),1)])):v.value.length===0?(c(),l(`div`,Fe,[t(o,{name:`Inbox`,size:`32`,class:`empty-icon`}),w(`p`,null,[a[8]||=u(`No submissions recorded for `,-1),w(`strong`,null,d(m.value),1),a[9]||=u(` yet.`,-1)])])):(c(),l(`div`,Ie,[w(`div`,Le,[w(`label`,Re,[w(`input`,{type:`checkbox`,checked:V.value,disabled:P.value||F.value,onChange:J},null,40,ze),a[10]||=w(`span`,null,`Select all`,-1)]),w(`span`,Be,d(B.value)+` selected`,1),w(`div`,Ve,[w(`button`,{type:`button`,class:`download-btn`,disabled:!v.value.length||P.value,onClick:Q},[t(o,{name:`Download`,size:`14`}),a[11]||=u(` Download CSV `,-1)],8,He),w(`button`,{type:`button`,class:`delete-selected-btn`,disabled:!B.value||P.value||F.value,onClick:Z},d(P.value?`Deleting...`:`Delete selected (${B.value})`),9,Ue)])]),N.value?(c(),l(`p`,We,d(N.value),1)):S(``,!0),w(`div`,Ge,[(c(!0),l(g,null,e(v.value,n=>(c(),l(`div`,{key:n.id,class:`submission-row`},[t(k,{title:`Submission #${n.id}`,compact:``,class:`submission-accordion`},{leading:i(()=>[w(`label`,{class:`submission-select`,onClick:a[3]||=_(()=>{},[`stop`])},[w(`input`,{type:`checkbox`,"aria-label":`Select submission ${n.id}`,checked:b.value.has(n.id),disabled:P.value||F.value,onChange:e=>Y(n.id)},null,40,Ke)])]),meta:i(()=>[w(`time`,{datetime:n.createdAt},d(new Date(n.createdAt).toLocaleString()),9,qe)]),default:i(()=>[w(`table`,Je,[a[12]||=w(`thead`,null,[w(`tr`,null,[w(`th`,null,`Field`),w(`th`,null,`Value`)])],-1),w(`tbody`,null,[(c(!0),l(g,null,e(K(n),e=>(c(),l(`tr`,{key:e.name},[w(`th`,Ye,d(e.label),1),w(`td`,null,d(q(n.data[e.name])),1)]))),128))])])]),_:2},1032,[`title`])]))),128))])]))])):(c(),l(`div`,Ae,[t(o,{name:`Inbox`,size:`32`,class:`empty-icon`}),a[6]||=w(`p`,null,`Select a form from the sidebar to view submissions.`,-1)]))])}}}),[[`__scopeId`,`data-v-0db272e9`]]);export{Xe as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{B as e,L as t,O as n,P as r,Q as i,R as a,S as o,St as s,Tt as c,U as l,V as u,W as d,Y as f,_ as p,b as m,ct as h,g,h as _,j as v,n as y,o as b,v as x,x as S,xt as C,y as w}from"./_plugin-vue_export-helper-BK_c4R_m.js";var T=y(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),E=y(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]);v(),h(),b(),f();var D={key:0,class:`menu-divider`},O=[`disabled`,`onClick`],k=[`title`,`onClick`],A=n({__name:`NodeContextMenu`,props:{show:{type:Boolean},items:{default:()=>[]},x:{},y:{},anchorRect:{},minWidth:{}},emits:[`select`,`action`,`close`],setup(n,{emit:f}){let h=n,v=f,y=i(null),b=i({top:0,left:0,transformOrigin:`top left`});d(()=>[h.show,h.x,h.y,h.anchorRect],async()=>{if(!h.show)return;await r();let e=y.value,t=e?e.offsetWidth:190,n=e?e.offsetHeight:150,i=window.innerWidth,a=window.innerHeight,o=0,s=0,c,l=`top`,u=`left`;if(h.anchorRect){let e=h.anchorRect;c=`${e.width}px`,s=e.left,s+t>i-8&&(s=Math.max(8,e.right-t),u=`right`),e.bottom+6+n>a-8?(o=e.top-n-6,l=`bottom`):(o=e.bottom+6,l=`top`)}else s=h.x||0,o=h.y||0,s+t>i-8&&(s=Math.max(8,s-t),u=`right`),o+n>a-8&&(o=Math.max(8,o-n),l=`bottom`);b.value={top:Math.max(8,o),left:Math.max(8,s),width:c,transformOrigin:`${l} ${u}`}},{immediate:!0});let T=x(()=>({top:`${b.value.top}px`,left:`${b.value.left}px`,width:b.value.width||`auto`,minWidth:h.minWidth||`190px`,transformOrigin:b.value.transformOrigin})),E=e=>{if(!h.show)return;let t=e.target;if(!(t instanceof Element&&t.closest(`.modal-overlay`))&&!(y.value&&y.value.contains(t))){if(h.anchorRect){let{left:t,right:n,top:r,bottom:i}=h.anchorRect;if(e.clientX>=t&&e.clientX<=n&&e.clientY>=r&&e.clientY<=i)return}v(`close`)}};return d(()=>h.show,e=>{e?setTimeout(()=>{document.addEventListener(`click`,E,!1)},0):document.removeEventListener(`click`,E,!1)},{immediate:!0}),t(()=>{document.removeEventListener(`click`,E,!1)}),(t,r)=>(a(),m(p,{to:`body`},[n.show?(a(),o(`div`,{key:0,ref_key:`menuRef`,ref:y,class:`node-context-menu`,style:s(T.value),onClick:r[0]||=_(()=>{},[`stop`])},[u(t.$slots,`header`),(a(!0),o(g,null,e(n.items,(e,t)=>(a(),o(g,{key:e.key||t},[e.divider?(a(),o(`div`,D)):(a(),o(`div`,{key:1,class:C([`menu-item-wrapper`,{"is-active":e.isActive,"is-disabled":e.disabled}])},[w(`button`,{class:`menu-item`,disabled:e.disabled,onClick:t=>v(`select`,e.key)},[e.icon?(a(),m(l(e.icon),{key:0,size:15,class:`menu-icon`})):S(``,!0),w(`span`,null,c(e.label),1)],8,O),e.hasAction?(a(),o(`button`,{key:0,class:`action-btn`,title:e.actionTitle,onClick:_(t=>v(`action`,e.key),[`stop`])},[(a(),m(l(e.actionIcon),{size:14}))],8,k)):S(``,!0)],2))],64))),128)),u(t.$slots,`default`)],4)):S(``,!0)]))}});export{E as n,T as r,A as t};
|