litecms 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1387 -0
  3. package/dist/admin/CmsAdminLayout.d.ts +27 -0
  4. package/dist/admin/CmsAdminLayout.d.ts.map +1 -0
  5. package/dist/admin/CmsAdminPage.d.ts +31 -0
  6. package/dist/admin/CmsAdminPage.d.ts.map +1 -0
  7. package/dist/admin/config.d.ts +83 -0
  8. package/dist/admin/config.d.ts.map +1 -0
  9. package/dist/admin/config.js +53 -0
  10. package/dist/admin/exports.d.ts +7 -0
  11. package/dist/admin/exports.d.ts.map +1 -0
  12. package/dist/admin/exports.js +452 -0
  13. package/dist/admin/index.d.ts +147 -0
  14. package/dist/admin/index.d.ts.map +1 -0
  15. package/dist/components/CmsAutoForm.d.ts +73 -0
  16. package/dist/components/CmsAutoForm.d.ts.map +1 -0
  17. package/dist/components/CmsField.d.ts +50 -0
  18. package/dist/components/CmsField.d.ts.map +1 -0
  19. package/dist/components/CmsForm.d.ts +74 -0
  20. package/dist/components/CmsForm.d.ts.map +1 -0
  21. package/dist/components/CmsImageField.d.ts +33 -0
  22. package/dist/components/CmsImageField.d.ts.map +1 -0
  23. package/dist/components/CmsNavSection.d.ts +7 -0
  24. package/dist/components/CmsNavSection.d.ts.map +1 -0
  25. package/dist/components/CmsSimpleForm.d.ts +54 -0
  26. package/dist/components/CmsSimpleForm.d.ts.map +1 -0
  27. package/dist/components/index.d.ts +43 -0
  28. package/dist/components/index.d.ts.map +1 -0
  29. package/dist/components/index.js +619 -0
  30. package/dist/domain/index.d.ts +1 -0
  31. package/dist/domain/index.d.ts.map +1 -0
  32. package/dist/index-8zcd33mx.js +39 -0
  33. package/dist/index-pmb5m3ek.js +4135 -0
  34. package/dist/index.d.ts +4 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +32 -0
  37. package/dist/schema/index.d.ts +80 -0
  38. package/dist/schema/index.d.ts.map +1 -0
  39. package/dist/schema/index.js +46 -0
  40. package/dist/server/index.d.ts +79 -0
  41. package/dist/server/index.d.ts.map +1 -0
  42. package/dist/server/index.js +117 -0
  43. package/dist/shared/utils.d.ts +23 -0
  44. package/dist/shared/utils.d.ts.map +1 -0
  45. package/dist/storage/index.d.ts +86 -0
  46. package/dist/storage/index.d.ts.map +1 -0
  47. package/dist/storage/index.js +86 -0
  48. package/dist/stores/index.d.ts +1 -0
  49. package/dist/stores/index.d.ts.map +1 -0
  50. package/package.json +90 -0
@@ -0,0 +1,619 @@
1
+ "use client";
2
+ import {
3
+ CmsCheckbox,
4
+ CmsField,
5
+ CmsHiddenField,
6
+ CmsImageField,
7
+ FormProvider,
8
+ appendErrors,
9
+ get,
10
+ groupFields,
11
+ set,
12
+ useForm
13
+ } from "../index-pmb5m3ek.js";
14
+ import {
15
+ getEditableFields
16
+ } from "../schema/index.js";
17
+
18
+ // src/components/CmsForm.tsx
19
+ import * as React from "react";
20
+
21
+ // node_modules/@hookform/resolvers/dist/resolvers.mjs
22
+ var r = (t, r2, o) => {
23
+ if (t && "reportValidity" in t) {
24
+ const s = get(o, r2);
25
+ t.setCustomValidity(s && s.message || ""), t.reportValidity();
26
+ }
27
+ };
28
+ var o = (e, t) => {
29
+ for (const o2 in t.fields) {
30
+ const s = t.fields[o2];
31
+ s && s.ref && "reportValidity" in s.ref ? r(s.ref, o2, e) : s && s.refs && s.refs.forEach((t2) => r(t2, o2, e));
32
+ }
33
+ };
34
+ var s = (r2, s2) => {
35
+ s2.shouldUseNativeValidation && o(r2, s2);
36
+ const n = {};
37
+ for (const o2 in r2) {
38
+ const f = get(s2.fields, o2), c = Object.assign(r2[o2] || {}, { ref: f && f.ref });
39
+ if (i(s2.names || Object.keys(r2), o2)) {
40
+ const r3 = Object.assign({}, get(n, o2));
41
+ set(r3, "root", c), set(n, o2, r3);
42
+ } else
43
+ set(n, o2, c);
44
+ }
45
+ return n;
46
+ };
47
+ var i = (e, t) => {
48
+ const r2 = n(t);
49
+ return e.some((e2) => n(e2).match(`^${r2}\\.\\d+`));
50
+ };
51
+ function n(e) {
52
+ return e.replace(/\]|\[/g, "");
53
+ }
54
+
55
+ // node_modules/zod/v4/core/core.js
56
+ var NEVER = Object.freeze({
57
+ status: "aborted"
58
+ });
59
+ function $constructor(name, initializer, params) {
60
+ function init(inst, def) {
61
+ if (!inst._zod) {
62
+ Object.defineProperty(inst, "_zod", {
63
+ value: {
64
+ def,
65
+ constr: _,
66
+ traits: new Set
67
+ },
68
+ enumerable: false
69
+ });
70
+ }
71
+ if (inst._zod.traits.has(name)) {
72
+ return;
73
+ }
74
+ inst._zod.traits.add(name);
75
+ initializer(inst, def);
76
+ const proto = _.prototype;
77
+ const keys = Object.keys(proto);
78
+ for (let i2 = 0;i2 < keys.length; i2++) {
79
+ const k = keys[i2];
80
+ if (!(k in inst)) {
81
+ inst[k] = proto[k].bind(inst);
82
+ }
83
+ }
84
+ }
85
+ const Parent = params?.Parent ?? Object;
86
+
87
+ class Definition extends Parent {
88
+ }
89
+ Object.defineProperty(Definition, "name", { value: name });
90
+ function _(def) {
91
+ var _a;
92
+ const inst = params?.Parent ? new Definition : this;
93
+ init(inst, def);
94
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
95
+ for (const fn of inst._zod.deferred) {
96
+ fn();
97
+ }
98
+ return inst;
99
+ }
100
+ Object.defineProperty(_, "init", { value: init });
101
+ Object.defineProperty(_, Symbol.hasInstance, {
102
+ value: (inst) => {
103
+ if (params?.Parent && inst instanceof params.Parent)
104
+ return true;
105
+ return inst?._zod?.traits?.has(name);
106
+ }
107
+ });
108
+ Object.defineProperty(_, "name", { value: name });
109
+ return _;
110
+ }
111
+ var $brand = Symbol("zod_brand");
112
+
113
+ class $ZodAsyncError extends Error {
114
+ constructor() {
115
+ super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
116
+ }
117
+ }
118
+ var globalConfig = {};
119
+ function config(newConfig) {
120
+ if (newConfig)
121
+ Object.assign(globalConfig, newConfig);
122
+ return globalConfig;
123
+ }
124
+
125
+ // node_modules/zod/v4/core/util.js
126
+ function jsonStringifyReplacer(_, value) {
127
+ if (typeof value === "bigint")
128
+ return value.toString();
129
+ return value;
130
+ }
131
+ function cached(getter) {
132
+ const set2 = false;
133
+ return {
134
+ get value() {
135
+ if (!set2) {
136
+ const value = getter();
137
+ Object.defineProperty(this, "value", { value });
138
+ return value;
139
+ }
140
+ throw new Error("cached value already set");
141
+ }
142
+ };
143
+ }
144
+ var EVALUATING = Symbol("evaluating");
145
+ var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
146
+ var allowsEval = cached(() => {
147
+ if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
148
+ return false;
149
+ }
150
+ try {
151
+ const F = Function;
152
+ new F("");
153
+ return true;
154
+ } catch (_) {
155
+ return false;
156
+ }
157
+ });
158
+ var propertyKeyTypes = new Set(["string", "number", "symbol"]);
159
+ var primitiveTypes = new Set(["string", "number", "bigint", "boolean", "symbol", "undefined"]);
160
+ var NUMBER_FORMAT_RANGES = {
161
+ safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
162
+ int32: [-2147483648, 2147483647],
163
+ uint32: [0, 4294967295],
164
+ float32: [-340282346638528860000000000000000000000, 340282346638528860000000000000000000000],
165
+ float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
166
+ };
167
+ function unwrapMessage(message) {
168
+ return typeof message === "string" ? message : message?.message;
169
+ }
170
+ function finalizeIssue(iss, ctx, config2) {
171
+ const full = { ...iss, path: iss.path ?? [] };
172
+ if (!iss.message) {
173
+ const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config2.customError?.(iss)) ?? unwrapMessage(config2.localeError?.(iss)) ?? "Invalid input";
174
+ full.message = message;
175
+ }
176
+ delete full.inst;
177
+ delete full.continue;
178
+ if (!ctx?.reportInput) {
179
+ delete full.input;
180
+ }
181
+ return full;
182
+ }
183
+
184
+ // node_modules/zod/v4/core/errors.js
185
+ var initializer = (inst, def) => {
186
+ inst.name = "$ZodError";
187
+ Object.defineProperty(inst, "_zod", {
188
+ value: inst._zod,
189
+ enumerable: false
190
+ });
191
+ Object.defineProperty(inst, "issues", {
192
+ value: def,
193
+ enumerable: false
194
+ });
195
+ inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
196
+ Object.defineProperty(inst, "toString", {
197
+ value: () => inst.message,
198
+ enumerable: false
199
+ });
200
+ };
201
+ var $ZodError = $constructor("$ZodError", initializer);
202
+ var $ZodRealError = $constructor("$ZodError", initializer, { Parent: Error });
203
+
204
+ // node_modules/zod/v4/core/parse.js
205
+ var _parse = (_Err) => (schema, value, _ctx, _params) => {
206
+ const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
207
+ const result = schema._zod.run({ value, issues: [] }, ctx);
208
+ if (result instanceof Promise) {
209
+ throw new $ZodAsyncError;
210
+ }
211
+ if (result.issues.length) {
212
+ const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
213
+ captureStackTrace(e, _params?.callee);
214
+ throw e;
215
+ }
216
+ return result.value;
217
+ };
218
+ var parse = /* @__PURE__ */ _parse($ZodRealError);
219
+ var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
220
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
221
+ let result = schema._zod.run({ value, issues: [] }, ctx);
222
+ if (result instanceof Promise)
223
+ result = await result;
224
+ if (result.issues.length) {
225
+ const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
226
+ captureStackTrace(e, params?.callee);
227
+ throw e;
228
+ }
229
+ return result.value;
230
+ };
231
+ var parseAsync = /* @__PURE__ */ _parseAsync($ZodRealError);
232
+
233
+ // node_modules/@hookform/resolvers/zod/dist/zod.mjs
234
+ function t(r2, e) {
235
+ try {
236
+ var o2 = r2();
237
+ } catch (r3) {
238
+ return e(r3);
239
+ }
240
+ return o2 && o2.then ? o2.then(undefined, e) : o2;
241
+ }
242
+ function s2(r2, e) {
243
+ for (var n2 = {};r2.length; ) {
244
+ var t2 = r2[0], s3 = t2.code, i2 = t2.message, a = t2.path.join(".");
245
+ if (!n2[a])
246
+ if ("unionErrors" in t2) {
247
+ var u = t2.unionErrors[0].errors[0];
248
+ n2[a] = { message: u.message, type: u.code };
249
+ } else
250
+ n2[a] = { message: i2, type: s3 };
251
+ if ("unionErrors" in t2 && t2.unionErrors.forEach(function(e2) {
252
+ return e2.errors.forEach(function(e3) {
253
+ return r2.push(e3);
254
+ });
255
+ }), e) {
256
+ var c = n2[a].types, f = c && c[t2.code];
257
+ n2[a] = appendErrors(a, e, n2, s3, f ? [].concat(f, t2.message) : t2.message);
258
+ }
259
+ r2.shift();
260
+ }
261
+ return n2;
262
+ }
263
+ function i2(r2, e) {
264
+ for (var n2 = {};r2.length; ) {
265
+ var t2 = r2[0], s3 = t2.code, i3 = t2.message, a = t2.path.join(".");
266
+ if (!n2[a])
267
+ if (t2.code === "invalid_union" && t2.errors.length > 0) {
268
+ var u = t2.errors[0][0];
269
+ n2[a] = { message: u.message, type: u.code };
270
+ } else
271
+ n2[a] = { message: i3, type: s3 };
272
+ if (t2.code === "invalid_union" && t2.errors.forEach(function(e2) {
273
+ return e2.forEach(function(e3) {
274
+ return r2.push(e3);
275
+ });
276
+ }), e) {
277
+ var c = n2[a].types, f = c && c[t2.code];
278
+ n2[a] = appendErrors(a, e, n2, s3, f ? [].concat(f, t2.message) : t2.message);
279
+ }
280
+ r2.shift();
281
+ }
282
+ return n2;
283
+ }
284
+ function a(o2, a2, u) {
285
+ if (u === undefined && (u = {}), function(r2) {
286
+ return "_def" in r2 && typeof r2._def == "object" && "typeName" in r2._def;
287
+ }(o2))
288
+ return function(n2, i3, c) {
289
+ try {
290
+ return Promise.resolve(t(function() {
291
+ return Promise.resolve(o2[u.mode === "sync" ? "parse" : "parseAsync"](n2, a2)).then(function(e) {
292
+ return c.shouldUseNativeValidation && o({}, c), { errors: {}, values: u.raw ? Object.assign({}, n2) : e };
293
+ });
294
+ }, function(r2) {
295
+ if (function(r3) {
296
+ return Array.isArray(r3 == null ? undefined : r3.issues);
297
+ }(r2))
298
+ return { values: {}, errors: s(s2(r2.errors, !c.shouldUseNativeValidation && c.criteriaMode === "all"), c) };
299
+ throw r2;
300
+ }));
301
+ } catch (r2) {
302
+ return Promise.reject(r2);
303
+ }
304
+ };
305
+ if (function(r2) {
306
+ return "_zod" in r2 && typeof r2._zod == "object";
307
+ }(o2))
308
+ return function(s3, c, f) {
309
+ try {
310
+ return Promise.resolve(t(function() {
311
+ return Promise.resolve((u.mode === "sync" ? parse : parseAsync)(o2, s3, a2)).then(function(e) {
312
+ return f.shouldUseNativeValidation && o({}, f), { errors: {}, values: u.raw ? Object.assign({}, s3) : e };
313
+ });
314
+ }, function(r2) {
315
+ if (function(r3) {
316
+ return r3 instanceof $ZodError;
317
+ }(r2))
318
+ return { values: {}, errors: s(i2(r2.issues, !f.shouldUseNativeValidation && f.criteriaMode === "all"), f) };
319
+ throw r2;
320
+ }));
321
+ } catch (r2) {
322
+ return Promise.reject(r2);
323
+ }
324
+ };
325
+ throw new Error("Invalid input: not a Zod schema");
326
+ }
327
+
328
+ // src/components/CmsForm.tsx
329
+ import { jsxDEV } from "react/jsx-dev-runtime";
330
+ var CmsFormContext = React.createContext(null);
331
+ function CmsForm({
332
+ schema,
333
+ action,
334
+ defaultValues,
335
+ onSuccess,
336
+ onError,
337
+ children,
338
+ className,
339
+ resetOnSuccess = false
340
+ }) {
341
+ const [state, setState] = React.useState({
342
+ success: false
343
+ });
344
+ const [isPending, setIsPending] = React.useState(false);
345
+ const [showSuccess, setShowSuccess] = React.useState(false);
346
+ const form = useForm({
347
+ resolver: a(schema),
348
+ defaultValues
349
+ });
350
+ React.useEffect(() => {
351
+ if (state.success && state.data) {
352
+ setShowSuccess(true);
353
+ onSuccess?.(state.data);
354
+ const timer = setTimeout(() => setShowSuccess(false), 3000);
355
+ if (resetOnSuccess) {
356
+ form.reset(defaultValues);
357
+ }
358
+ return () => clearTimeout(timer);
359
+ } else if (state.errors) {
360
+ setShowSuccess(false);
361
+ onError?.(state.errors);
362
+ if (state.errors.fieldErrors) {
363
+ for (const [field, messages] of Object.entries(state.errors.fieldErrors)) {
364
+ form.setError(field, {
365
+ type: "server",
366
+ message: messages[0]
367
+ });
368
+ }
369
+ }
370
+ }
371
+ }, [state, onSuccess, onError, form, resetOnSuccess, defaultValues]);
372
+ const handleSubmit = async (event) => {
373
+ event.preventDefault();
374
+ setIsPending(true);
375
+ setShowSuccess(false);
376
+ try {
377
+ const formData = new FormData(event.currentTarget);
378
+ const result = await action(state, formData);
379
+ setState(result);
380
+ } catch (error) {
381
+ console.error("[litecms] Form submission error:", error);
382
+ setState({
383
+ success: false,
384
+ errors: {
385
+ formError: error instanceof Error ? error.message : "An unexpected error occurred"
386
+ }
387
+ });
388
+ } finally {
389
+ setIsPending(false);
390
+ }
391
+ };
392
+ return /* @__PURE__ */ jsxDEV(FormProvider, {
393
+ ...form,
394
+ children: /* @__PURE__ */ jsxDEV(CmsFormContext.Provider, {
395
+ value: {
396
+ isPending,
397
+ formError: state.errors?.formError,
398
+ showSuccess
399
+ },
400
+ children: /* @__PURE__ */ jsxDEV("form", {
401
+ onSubmit: handleSubmit,
402
+ className,
403
+ children
404
+ }, undefined, false, undefined, this)
405
+ }, undefined, false, undefined, this)
406
+ }, undefined, false, undefined, this);
407
+ }
408
+ function useCmsForm() {
409
+ const context = React.useContext(CmsFormContext);
410
+ if (!context) {
411
+ throw new Error("useCmsForm must be used within a CmsForm");
412
+ }
413
+ return context;
414
+ }
415
+ function CmsSubmitButton({
416
+ children = "Save",
417
+ className,
418
+ pendingText = "Saving..."
419
+ }) {
420
+ const { isPending } = useCmsForm();
421
+ return /* @__PURE__ */ jsxDEV("button", {
422
+ type: "submit",
423
+ disabled: isPending,
424
+ className,
425
+ children: isPending ? pendingText : children
426
+ }, undefined, false, undefined, this);
427
+ }
428
+ function CmsFormError({ className }) {
429
+ const { formError } = useCmsForm();
430
+ if (!formError)
431
+ return null;
432
+ return /* @__PURE__ */ jsxDEV("div", {
433
+ role: "alert",
434
+ className,
435
+ children: formError
436
+ }, undefined, false, undefined, this);
437
+ }
438
+ function CmsFormSuccess({
439
+ children = "Saved successfully!",
440
+ className
441
+ }) {
442
+ const { showSuccess } = useCmsForm();
443
+ if (!showSuccess)
444
+ return null;
445
+ return /* @__PURE__ */ jsxDEV("div", {
446
+ role: "status",
447
+ className,
448
+ children
449
+ }, undefined, false, undefined, this);
450
+ }
451
+ // src/components/CmsAutoForm.tsx
452
+ import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
453
+ function CmsAutoForm({
454
+ definition,
455
+ action,
456
+ values,
457
+ styles = {},
458
+ submitText = "Save changes",
459
+ submitPendingText = "Saving...",
460
+ successMessage = "Changes saved successfully",
461
+ onSuccess
462
+ }) {
463
+ const editableFields = getEditableFields(definition);
464
+ const defaultValues = { ...definition.defaults, ...values };
465
+ const groupedFields = groupFields(editableFields);
466
+ return /* @__PURE__ */ jsxDEV2(CmsForm, {
467
+ schema: definition.schema,
468
+ action,
469
+ defaultValues,
470
+ onSuccess,
471
+ children: /* @__PURE__ */ jsxDEV2("div", {
472
+ className: styles.wrapper ?? "",
473
+ children: [
474
+ /* @__PURE__ */ jsxDEV2("div", {
475
+ className: "space-y-8",
476
+ children: [
477
+ groupedFields.map((group) => /* @__PURE__ */ jsxDEV2(FieldGroup, {
478
+ group,
479
+ styles
480
+ }, group.name ?? "__ungrouped", false, undefined, this)),
481
+ /* @__PURE__ */ jsxDEV2(CmsFormError, {
482
+ className: styles.formError ?? "flex items-center gap-3 rounded-lg px-4 py-3 text-sm"
483
+ }, undefined, false, undefined, this),
484
+ /* @__PURE__ */ jsxDEV2(CmsFormSuccess, {
485
+ className: styles.formSuccess ?? "flex items-center gap-3 rounded-lg px-4 py-3 text-sm",
486
+ children: successMessage
487
+ }, undefined, false, undefined, this)
488
+ ]
489
+ }, undefined, true, undefined, this),
490
+ /* @__PURE__ */ jsxDEV2("div", {
491
+ className: "mt-8 flex items-center justify-end gap-4 pt-6",
492
+ style: {
493
+ borderTop: "1px solid var(--cms-border, rgba(255, 255, 255, 0.06))"
494
+ },
495
+ children: /* @__PURE__ */ jsxDEV2(CmsSubmitButton, {
496
+ className: styles.submitButton ?? "inline-flex h-9 items-center justify-center gap-2 rounded-lg px-6 py-2 text-sm font-medium text-white transition-all duration-180 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
497
+ pendingText: submitPendingText,
498
+ children: submitText
499
+ }, undefined, false, undefined, this)
500
+ }, undefined, false, undefined, this)
501
+ ]
502
+ }, undefined, true, undefined, this)
503
+ }, undefined, false, undefined, this);
504
+ }
505
+ function FieldGroup({
506
+ group,
507
+ styles
508
+ }) {
509
+ const fieldsetStyle = {
510
+ background: "var(--cms-bg-surface-1, #141416)",
511
+ border: "1px solid var(--cms-border, rgba(255, 255, 255, 0.06))",
512
+ borderRadius: "12px"
513
+ };
514
+ const legendStyle = {
515
+ color: "var(--cms-text-primary, #e8e8ec)",
516
+ background: "var(--cms-bg-surface-2, #1a1a1e)",
517
+ padding: "4px 12px",
518
+ borderRadius: "6px",
519
+ border: "1px solid var(--cms-border, rgba(255, 255, 255, 0.06))"
520
+ };
521
+ if (group.name) {
522
+ return /* @__PURE__ */ jsxDEV2("fieldset", {
523
+ className: styles.group ?? "p-6",
524
+ style: fieldsetStyle,
525
+ children: [
526
+ /* @__PURE__ */ jsxDEV2("legend", {
527
+ className: styles.groupTitle ?? "text-sm font-semibold mb-4",
528
+ style: legendStyle,
529
+ children: group.name
530
+ }, undefined, false, undefined, this),
531
+ /* @__PURE__ */ jsxDEV2("div", {
532
+ className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",
533
+ children: group.fields.map((field) => /* @__PURE__ */ jsxDEV2(AutoField, {
534
+ field,
535
+ styles
536
+ }, field.name, false, undefined, this))
537
+ }, undefined, false, undefined, this)
538
+ ]
539
+ }, undefined, true, undefined, this);
540
+ }
541
+ return /* @__PURE__ */ jsxDEV2("div", {
542
+ className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",
543
+ children: group.fields.map((field) => /* @__PURE__ */ jsxDEV2(AutoField, {
544
+ field,
545
+ styles
546
+ }, field.name, false, undefined, this))
547
+ }, undefined, false, undefined, this);
548
+ }
549
+ function AutoField({
550
+ field,
551
+ styles
552
+ }) {
553
+ const { name, meta, required } = field;
554
+ const isFullWidth = meta.type === "textarea" || meta.type === "image";
555
+ const colSpan = isFullWidth ? "col-span-1 md:col-span-2 lg:col-span-3" : "col-span-1";
556
+ if (meta.type === "checkbox") {
557
+ return /* @__PURE__ */ jsxDEV2("div", {
558
+ className: colSpan,
559
+ children: /* @__PURE__ */ jsxDEV2(CmsCheckbox, {
560
+ name,
561
+ label: meta.label,
562
+ helpText: meta.helpText,
563
+ className: styles.field,
564
+ labelClassName: styles.label,
565
+ inputClassName: styles.input,
566
+ errorClassName: styles.error,
567
+ helpClassName: styles.help
568
+ }, undefined, false, undefined, this)
569
+ }, undefined, false, undefined, this);
570
+ }
571
+ if (meta.type === "image") {
572
+ return /* @__PURE__ */ jsxDEV2("div", {
573
+ className: colSpan,
574
+ children: /* @__PURE__ */ jsxDEV2(CmsImageField, {
575
+ name,
576
+ label: meta.label,
577
+ helpText: meta.helpText,
578
+ required,
579
+ accept: meta.accept,
580
+ className: styles.field,
581
+ labelClassName: styles.label,
582
+ errorClassName: styles.error,
583
+ helpClassName: styles.help
584
+ }, undefined, false, undefined, this)
585
+ }, undefined, false, undefined, this);
586
+ }
587
+ return /* @__PURE__ */ jsxDEV2("div", {
588
+ className: colSpan,
589
+ children: /* @__PURE__ */ jsxDEV2(CmsField, {
590
+ name,
591
+ label: meta.label,
592
+ type: meta.type ?? "text",
593
+ placeholder: meta.placeholder,
594
+ helpText: meta.helpText,
595
+ options: meta.options,
596
+ rows: meta.rows,
597
+ required,
598
+ className: styles.field,
599
+ labelClassName: styles.label,
600
+ inputClassName: styles.input,
601
+ errorClassName: styles.error,
602
+ helpClassName: styles.help
603
+ }, undefined, false, undefined, this)
604
+ }, undefined, false, undefined, this);
605
+ }
606
+
607
+ // src/components/index.ts
608
+ export {
609
+ useCmsForm,
610
+ CmsSubmitButton,
611
+ CmsImageField,
612
+ CmsHiddenField,
613
+ CmsFormSuccess,
614
+ CmsFormError,
615
+ CmsForm,
616
+ CmsField,
617
+ CmsCheckbox,
618
+ CmsAutoForm
619
+ };
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/domain/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,39 @@
1
+ // src/admin/index.ts
2
+ var globalConfig = null;
3
+ function createCmsConfig(config) {
4
+ const sortedPages = [...config.pages].sort((a, b) => (a.order ?? 999) - (b.order ?? 999));
5
+ const fullConfig = {
6
+ siteName: config.siteName ?? "CMS",
7
+ adminTitle: config.adminTitle ?? "Admin Panel",
8
+ basePath: config.basePath ?? "/admin",
9
+ publicSiteUrl: config.publicSiteUrl ?? "/",
10
+ pages: sortedPages,
11
+ storage: config.storage
12
+ };
13
+ globalConfig = fullConfig;
14
+ return fullConfig;
15
+ }
16
+ function getCmsConfig() {
17
+ if (!globalConfig) {
18
+ throw new Error("CMS not configured. Call createCmsConfig() before using CMS components.");
19
+ }
20
+ return globalConfig;
21
+ }
22
+ function getPageBySlug(slug) {
23
+ const config = getCmsConfig();
24
+ return config.pages.find((p) => p.slug === slug);
25
+ }
26
+ function getNavPages() {
27
+ const config = getCmsConfig();
28
+ return config.pages.map((p) => ({
29
+ slug: p.slug,
30
+ title: p.title,
31
+ href: `${config.basePath}/${p.slug}`,
32
+ group: p.group
33
+ }));
34
+ }
35
+ function definePage(config) {
36
+ return config;
37
+ }
38
+
39
+ export { createCmsConfig, getCmsConfig, getPageBySlug, getNavPages, definePage };