litecms 0.2.1 → 0.2.3

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.
@@ -12,7 +12,7 @@ import {
12
12
  set,
13
13
  useCmsLanguageOptional,
14
14
  useForm
15
- } from "../index-c9btr14k.js";
15
+ } from "../index-xscpb89q.js";
16
16
  import {
17
17
  $ZodError,
18
18
  parse,
@@ -156,7 +156,7 @@ function a(o2, a2, u) {
156
156
  }
157
157
 
158
158
  // src/components/CmsForm.tsx
159
- import { jsxDEV } from "react/jsx-dev-runtime";
159
+ import { jsx } from "react/jsx-runtime";
160
160
  var CmsFormContext = React.createContext(null);
161
161
  function CmsForm({
162
162
  schema,
@@ -219,21 +219,21 @@ function CmsForm({
219
219
  setIsPending(false);
220
220
  }
221
221
  };
222
- return /* @__PURE__ */ jsxDEV(FormProvider, {
222
+ return /* @__PURE__ */ jsx(FormProvider, {
223
223
  ...form,
224
- children: /* @__PURE__ */ jsxDEV(CmsFormContext.Provider, {
224
+ children: /* @__PURE__ */ jsx(CmsFormContext.Provider, {
225
225
  value: {
226
226
  isPending,
227
227
  formError: state.errors?.formError,
228
228
  showSuccess
229
229
  },
230
- children: /* @__PURE__ */ jsxDEV("form", {
230
+ children: /* @__PURE__ */ jsx("form", {
231
231
  onSubmit: handleSubmit,
232
232
  className,
233
233
  children
234
- }, undefined, false, undefined, this)
235
- }, undefined, false, undefined, this)
236
- }, undefined, false, undefined, this);
234
+ })
235
+ })
236
+ });
237
237
  }
238
238
  function useCmsForm() {
239
239
  const context = React.useContext(CmsFormContext);
@@ -258,22 +258,22 @@ function CmsSubmitButton({
258
258
  });
259
259
  const resolvedChildren = children ?? t2("save");
260
260
  const resolvedPendingText = pendingText ?? t2("saving");
261
- return /* @__PURE__ */ jsxDEV("button", {
261
+ return /* @__PURE__ */ jsx("button", {
262
262
  type: "submit",
263
263
  disabled: isPending,
264
264
  className,
265
265
  children: isPending ? resolvedPendingText : resolvedChildren
266
- }, undefined, false, undefined, this);
266
+ });
267
267
  }
268
268
  function CmsFormError({ className }) {
269
269
  const { formError } = useCmsForm();
270
270
  if (!formError)
271
271
  return null;
272
- return /* @__PURE__ */ jsxDEV("div", {
272
+ return /* @__PURE__ */ jsx("div", {
273
273
  role: "alert",
274
274
  className,
275
275
  children: formError
276
- }, undefined, false, undefined, this);
276
+ });
277
277
  }
278
278
  function CmsFormSuccess({
279
279
  children,
@@ -290,14 +290,14 @@ function CmsFormSuccess({
290
290
  const resolvedChildren = children ?? t2("savedSuccessfully");
291
291
  if (!showSuccess)
292
292
  return null;
293
- return /* @__PURE__ */ jsxDEV("div", {
293
+ return /* @__PURE__ */ jsx("div", {
294
294
  role: "status",
295
295
  className,
296
296
  children: resolvedChildren
297
- }, undefined, false, undefined, this);
297
+ });
298
298
  }
299
299
  // src/components/CmsAutoForm.tsx
300
- import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
300
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
301
301
  function CmsAutoForm({
302
302
  definition,
303
303
  action,
@@ -323,44 +323,44 @@ function CmsAutoForm({
323
323
  const editableFields = getEditableFields(definition);
324
324
  const defaultValues = { ...definition.defaults, ...values };
325
325
  const groupedFields = groupFields(editableFields);
326
- return /* @__PURE__ */ jsxDEV2(CmsForm, {
326
+ return /* @__PURE__ */ jsx2(CmsForm, {
327
327
  schema: definition.schema,
328
328
  action,
329
329
  defaultValues,
330
330
  onSuccess,
331
- children: /* @__PURE__ */ jsxDEV2("div", {
331
+ children: /* @__PURE__ */ jsxs("div", {
332
332
  className: styles.wrapper ?? "",
333
333
  children: [
334
- /* @__PURE__ */ jsxDEV2("div", {
334
+ /* @__PURE__ */ jsxs("div", {
335
335
  className: "space-y-8",
336
336
  children: [
337
- groupedFields.map((group) => /* @__PURE__ */ jsxDEV2(FieldGroup, {
337
+ groupedFields.map((group) => /* @__PURE__ */ jsx2(FieldGroup, {
338
338
  group,
339
339
  styles
340
- }, group.name ?? "__ungrouped", false, undefined, this)),
341
- /* @__PURE__ */ jsxDEV2(CmsFormError, {
340
+ }, group.name ?? "__ungrouped")),
341
+ /* @__PURE__ */ jsx2(CmsFormError, {
342
342
  className: styles.formError ?? "flex items-center gap-3 rounded-lg px-4 py-3 text-sm"
343
- }, undefined, false, undefined, this),
344
- /* @__PURE__ */ jsxDEV2(CmsFormSuccess, {
343
+ }),
344
+ /* @__PURE__ */ jsx2(CmsFormSuccess, {
345
345
  className: styles.formSuccess ?? "flex items-center gap-3 rounded-lg px-4 py-3 text-sm",
346
346
  children: resolvedSuccessMessage
347
- }, undefined, false, undefined, this)
347
+ })
348
348
  ]
349
- }, undefined, true, undefined, this),
350
- /* @__PURE__ */ jsxDEV2("div", {
349
+ }),
350
+ /* @__PURE__ */ jsx2("div", {
351
351
  className: "mt-8 flex items-center justify-end gap-4 pt-6",
352
352
  style: {
353
353
  borderTop: "1px solid var(--cms-border, rgba(255, 255, 255, 0.06))"
354
354
  },
355
- children: /* @__PURE__ */ jsxDEV2(CmsSubmitButton, {
355
+ children: /* @__PURE__ */ jsx2(CmsSubmitButton, {
356
356
  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",
357
357
  pendingText: resolvedSubmitPendingText,
358
358
  children: resolvedSubmitText
359
- }, undefined, false, undefined, this)
360
- }, undefined, false, undefined, this)
359
+ })
360
+ })
361
361
  ]
362
- }, undefined, true, undefined, this)
363
- }, undefined, false, undefined, this);
362
+ })
363
+ });
364
364
  }
365
365
  function FieldGroup({
366
366
  group,
@@ -379,32 +379,32 @@ function FieldGroup({
379
379
  border: "1px solid var(--cms-border, rgba(255, 255, 255, 0.06))"
380
380
  };
381
381
  if (group.name) {
382
- return /* @__PURE__ */ jsxDEV2("fieldset", {
382
+ return /* @__PURE__ */ jsxs("fieldset", {
383
383
  className: styles.group ?? "p-6",
384
384
  style: fieldsetStyle,
385
385
  children: [
386
- /* @__PURE__ */ jsxDEV2("legend", {
386
+ /* @__PURE__ */ jsx2("legend", {
387
387
  className: styles.groupTitle ?? "text-sm font-semibold mb-4",
388
388
  style: legendStyle,
389
389
  children: group.name
390
- }, undefined, false, undefined, this),
391
- /* @__PURE__ */ jsxDEV2("div", {
390
+ }),
391
+ /* @__PURE__ */ jsx2("div", {
392
392
  className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",
393
- children: group.fields.map((field) => /* @__PURE__ */ jsxDEV2(AutoField, {
393
+ children: group.fields.map((field) => /* @__PURE__ */ jsx2(AutoField, {
394
394
  field,
395
395
  styles
396
- }, field.name, false, undefined, this))
397
- }, undefined, false, undefined, this)
396
+ }, field.name))
397
+ })
398
398
  ]
399
- }, undefined, true, undefined, this);
399
+ });
400
400
  }
401
- return /* @__PURE__ */ jsxDEV2("div", {
401
+ return /* @__PURE__ */ jsx2("div", {
402
402
  className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",
403
- children: group.fields.map((field) => /* @__PURE__ */ jsxDEV2(AutoField, {
403
+ children: group.fields.map((field) => /* @__PURE__ */ jsx2(AutoField, {
404
404
  field,
405
405
  styles
406
- }, field.name, false, undefined, this))
407
- }, undefined, false, undefined, this);
406
+ }, field.name))
407
+ });
408
408
  }
409
409
  function AutoField({
410
410
  field,
@@ -414,9 +414,9 @@ function AutoField({
414
414
  const isFullWidth = meta.type === "textarea" || meta.type === "image";
415
415
  const colSpan = isFullWidth ? "col-span-1 md:col-span-2 lg:col-span-3" : "col-span-1";
416
416
  if (meta.type === "checkbox") {
417
- return /* @__PURE__ */ jsxDEV2("div", {
417
+ return /* @__PURE__ */ jsx2("div", {
418
418
  className: colSpan,
419
- children: /* @__PURE__ */ jsxDEV2(CmsCheckbox, {
419
+ children: /* @__PURE__ */ jsx2(CmsCheckbox, {
420
420
  name,
421
421
  label: meta.label,
422
422
  helpText: meta.helpText,
@@ -425,13 +425,13 @@ function AutoField({
425
425
  inputClassName: styles.input,
426
426
  errorClassName: styles.error,
427
427
  helpClassName: styles.help
428
- }, undefined, false, undefined, this)
429
- }, undefined, false, undefined, this);
428
+ })
429
+ });
430
430
  }
431
431
  if (meta.type === "image") {
432
- return /* @__PURE__ */ jsxDEV2("div", {
432
+ return /* @__PURE__ */ jsx2("div", {
433
433
  className: colSpan,
434
- children: /* @__PURE__ */ jsxDEV2(CmsImageField, {
434
+ children: /* @__PURE__ */ jsx2(CmsImageField, {
435
435
  name,
436
436
  label: meta.label,
437
437
  helpText: meta.helpText,
@@ -441,12 +441,12 @@ function AutoField({
441
441
  labelClassName: styles.label,
442
442
  errorClassName: styles.error,
443
443
  helpClassName: styles.help
444
- }, undefined, false, undefined, this)
445
- }, undefined, false, undefined, this);
444
+ })
445
+ });
446
446
  }
447
- return /* @__PURE__ */ jsxDEV2("div", {
447
+ return /* @__PURE__ */ jsx2("div", {
448
448
  className: colSpan,
449
- children: /* @__PURE__ */ jsxDEV2(CmsField, {
449
+ children: /* @__PURE__ */ jsx2(CmsField, {
450
450
  name,
451
451
  label: meta.label,
452
452
  type: meta.type ?? "text",
@@ -460,8 +460,8 @@ function AutoField({
460
460
  inputClassName: styles.input,
461
461
  errorClassName: styles.error,
462
462
  helpClassName: styles.help
463
- }, undefined, false, undefined, this)
464
- }, undefined, false, undefined, this);
463
+ })
464
+ });
465
465
  }
466
466
 
467
467
  // src/components/index.ts