@delmaredigital/payload-puck 0.1.0 → 0.1.2

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 (65) hide show
  1. package/README.md +32 -4
  2. package/dist/AccordionClient.d.mts +1 -1
  3. package/dist/AccordionClient.d.ts +1 -1
  4. package/dist/AccordionClient.js +2 -2
  5. package/dist/AccordionClient.mjs +2 -2
  6. package/dist/AnimatedWrapper.d.mts +1 -1
  7. package/dist/AnimatedWrapper.d.ts +1 -1
  8. package/dist/components/index.d.mts +1 -1
  9. package/dist/components/index.d.ts +1 -1
  10. package/dist/components/index.js +196 -217
  11. package/dist/components/index.mjs +200 -221
  12. package/dist/config/config.editor.d.mts +1 -1
  13. package/dist/config/config.editor.d.ts +1 -1
  14. package/dist/config/config.editor.js +199 -220
  15. package/dist/config/config.editor.mjs +203 -224
  16. package/dist/config/index.js +33 -16
  17. package/dist/config/index.mjs +33 -16
  18. package/dist/editor/index.js +56 -39
  19. package/dist/editor/index.mjs +56 -39
  20. package/dist/fields/index.d.mts +4 -4
  21. package/dist/fields/index.d.ts +4 -4
  22. package/dist/fields/index.js +201 -222
  23. package/dist/fields/index.mjs +205 -226
  24. package/dist/render/index.js +33 -16
  25. package/dist/render/index.mjs +33 -16
  26. package/dist/{shared-DMAF1AcH.d.mts → shared-DeNKN95N.d.mts} +7 -6
  27. package/dist/{shared-DMAF1AcH.d.ts → shared-DeNKN95N.d.ts} +7 -6
  28. package/examples/README.md +9 -2
  29. package/examples/app/(manage)/layout.tsx +31 -0
  30. package/package.json +13 -10
  31. package/dist/AccordionClient.js.map +0 -1
  32. package/dist/AccordionClient.mjs.map +0 -1
  33. package/dist/AnimatedWrapper.js.map +0 -1
  34. package/dist/AnimatedWrapper.mjs.map +0 -1
  35. package/dist/admin/client.js.map +0 -1
  36. package/dist/admin/client.mjs.map +0 -1
  37. package/dist/admin/index.js.map +0 -1
  38. package/dist/admin/index.mjs.map +0 -1
  39. package/dist/api/index.js.map +0 -1
  40. package/dist/api/index.mjs.map +0 -1
  41. package/dist/components/index.css.map +0 -1
  42. package/dist/components/index.js.map +0 -1
  43. package/dist/components/index.mjs.map +0 -1
  44. package/dist/config/config.editor.css.map +0 -1
  45. package/dist/config/config.editor.js.map +0 -1
  46. package/dist/config/config.editor.mjs.map +0 -1
  47. package/dist/config/index.js.map +0 -1
  48. package/dist/config/index.mjs.map +0 -1
  49. package/dist/editor/index.js.map +0 -1
  50. package/dist/editor/index.mjs.map +0 -1
  51. package/dist/fields/index.css.map +0 -1
  52. package/dist/fields/index.js.map +0 -1
  53. package/dist/fields/index.mjs.map +0 -1
  54. package/dist/index.js.map +0 -1
  55. package/dist/index.mjs.map +0 -1
  56. package/dist/layouts/index.js.map +0 -1
  57. package/dist/layouts/index.mjs.map +0 -1
  58. package/dist/plugin/index.js.map +0 -1
  59. package/dist/plugin/index.mjs.map +0 -1
  60. package/dist/render/index.js.map +0 -1
  61. package/dist/render/index.mjs.map +0 -1
  62. package/dist/theme/index.js.map +0 -1
  63. package/dist/theme/index.mjs.map +0 -1
  64. package/dist/utils/index.js.map +0 -1
  65. package/dist/utils/index.mjs.map +0 -1
@@ -4,7 +4,7 @@ var puck = require('@measured/puck');
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
5
  var AnimatedWrapper = require('../AnimatedWrapper');
6
6
  var React = require('react');
7
- var iconsReact = require('@tabler/icons-react');
7
+ var lucideReact = require('lucide-react');
8
8
  var reactSlot = require('@radix-ui/react-slot');
9
9
  var classVarianceAuthority = require('class-variance-authority');
10
10
  var clsx = require('clsx');
@@ -480,7 +480,7 @@ function transformValueToCSS(transform) {
480
480
  return Object.keys(style).length > 0 ? style : void 0;
481
481
  }
482
482
  var BREAKPOINTS = [
483
- { key: "base", label: "Base", minWidth: null },
483
+ { key: "xs", label: "XS", minWidth: null },
484
484
  { key: "sm", label: "SM", minWidth: 640 },
485
485
  { key: "md", label: "MD", minWidth: 768 },
486
486
  { key: "lg", label: "LG", minWidth: 1024 },
@@ -488,7 +488,7 @@ var BREAKPOINTS = [
488
488
  ];
489
489
  function isResponsiveValue(value) {
490
490
  if (!value || typeof value !== "object") return false;
491
- return "base" in value;
491
+ return "xs" in value;
492
492
  }
493
493
  function camelToKebab(str) {
494
494
  return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
@@ -514,7 +514,7 @@ function responsiveValueToCSS(value, converter, uniqueId) {
514
514
  if (bpValue === void 0) return;
515
515
  const cssProps = converter(bpValue);
516
516
  if (!cssProps) return;
517
- if (bp.key === "base") {
517
+ if (bp.key === "xs") {
518
518
  baseStyles = cssProps;
519
519
  } else {
520
520
  const styleString = cssPropertiesToString(cssProps);
@@ -530,24 +530,41 @@ function responsiveValueToCSS(value, converter, uniqueId) {
530
530
  function visibilityValueToCSS(visibility, uniqueId) {
531
531
  if (!visibility) return "";
532
532
  const mediaQueries = [];
533
- if (visibility.base === false) {
534
- mediaQueries.push(`.${uniqueId} { display: none; }`);
533
+ const breakpointWidths = {
534
+ xs: null,
535
+ // 0px
536
+ sm: 640,
537
+ md: 768,
538
+ lg: 1024,
539
+ xl: 1280
540
+ };
541
+ const getNextBreakpointWidth = (bp) => {
542
+ const order = ["xs", "sm", "md", "lg", "xl"];
543
+ const index = order.indexOf(bp);
544
+ if (index === -1 || index === order.length - 1) return null;
545
+ return breakpointWidths[order[index + 1]];
546
+ };
547
+ if (visibility.xs === false) {
548
+ const nextWidth = getNextBreakpointWidth("xs");
549
+ if (nextWidth) {
550
+ mediaQueries.push(`@media (max-width: ${nextWidth - 1}px) { .${uniqueId} { display: none; } }`);
551
+ } else {
552
+ mediaQueries.push(`.${uniqueId} { display: none; }`);
553
+ }
535
554
  }
536
- let lastVisibility = visibility.base;
537
555
  BREAKPOINTS.slice(1).forEach((bp) => {
538
- const bpValue = visibility[bp.key];
539
- if (bpValue === void 0) return;
540
- if (bpValue !== lastVisibility) {
541
- if (bpValue === false) {
556
+ if (visibility[bp.key] === false) {
557
+ const minWidth = breakpointWidths[bp.key];
558
+ const maxWidth = getNextBreakpointWidth(bp.key);
559
+ if (minWidth && maxWidth) {
542
560
  mediaQueries.push(
543
- `@media (min-width: ${bp.minWidth}px) { .${uniqueId} { display: none; } }`
561
+ `@media (min-width: ${minWidth}px) and (max-width: ${maxWidth - 1}px) { .${uniqueId} { display: none; } }`
544
562
  );
545
- } else {
563
+ } else if (minWidth) {
546
564
  mediaQueries.push(
547
- `@media (min-width: ${bp.minWidth}px) { .${uniqueId} { display: block; } }`
565
+ `@media (min-width: ${minWidth}px) { .${uniqueId} { display: none; } }`
548
566
  );
549
567
  }
550
- lastVisibility = bpValue;
551
568
  }
552
569
  });
553
570
  return mediaQueries.join("\n");
@@ -1585,7 +1602,7 @@ function SizeFieldInner({
1585
1602
  onClick: handleClear,
1586
1603
  className: "text-muted-foreground hover:text-destructive",
1587
1604
  title: "Reset to default",
1588
- children: /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconX, { className: "h-4 w-4" })
1605
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-4 w-4" })
1589
1606
  }
1590
1607
  )
1591
1608
  ] }),
@@ -3,7 +3,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import { AnimatedWrapper } from '../AnimatedWrapper';
4
4
  import * as React from 'react';
5
5
  import { memo, useCallback, createElement } from 'react';
6
- import { IconX } from '@tabler/icons-react';
6
+ import { X } from 'lucide-react';
7
7
  import { Slot } from '@radix-ui/react-slot';
8
8
  import { cva } from 'class-variance-authority';
9
9
  import { clsx } from 'clsx';
@@ -458,7 +458,7 @@ function transformValueToCSS(transform) {
458
458
  return Object.keys(style).length > 0 ? style : void 0;
459
459
  }
460
460
  var BREAKPOINTS = [
461
- { key: "base", label: "Base", minWidth: null },
461
+ { key: "xs", label: "XS", minWidth: null },
462
462
  { key: "sm", label: "SM", minWidth: 640 },
463
463
  { key: "md", label: "MD", minWidth: 768 },
464
464
  { key: "lg", label: "LG", minWidth: 1024 },
@@ -466,7 +466,7 @@ var BREAKPOINTS = [
466
466
  ];
467
467
  function isResponsiveValue(value) {
468
468
  if (!value || typeof value !== "object") return false;
469
- return "base" in value;
469
+ return "xs" in value;
470
470
  }
471
471
  function camelToKebab(str) {
472
472
  return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
@@ -492,7 +492,7 @@ function responsiveValueToCSS(value, converter, uniqueId) {
492
492
  if (bpValue === void 0) return;
493
493
  const cssProps = converter(bpValue);
494
494
  if (!cssProps) return;
495
- if (bp.key === "base") {
495
+ if (bp.key === "xs") {
496
496
  baseStyles = cssProps;
497
497
  } else {
498
498
  const styleString = cssPropertiesToString(cssProps);
@@ -508,24 +508,41 @@ function responsiveValueToCSS(value, converter, uniqueId) {
508
508
  function visibilityValueToCSS(visibility, uniqueId) {
509
509
  if (!visibility) return "";
510
510
  const mediaQueries = [];
511
- if (visibility.base === false) {
512
- mediaQueries.push(`.${uniqueId} { display: none; }`);
511
+ const breakpointWidths = {
512
+ xs: null,
513
+ // 0px
514
+ sm: 640,
515
+ md: 768,
516
+ lg: 1024,
517
+ xl: 1280
518
+ };
519
+ const getNextBreakpointWidth = (bp) => {
520
+ const order = ["xs", "sm", "md", "lg", "xl"];
521
+ const index = order.indexOf(bp);
522
+ if (index === -1 || index === order.length - 1) return null;
523
+ return breakpointWidths[order[index + 1]];
524
+ };
525
+ if (visibility.xs === false) {
526
+ const nextWidth = getNextBreakpointWidth("xs");
527
+ if (nextWidth) {
528
+ mediaQueries.push(`@media (max-width: ${nextWidth - 1}px) { .${uniqueId} { display: none; } }`);
529
+ } else {
530
+ mediaQueries.push(`.${uniqueId} { display: none; }`);
531
+ }
513
532
  }
514
- let lastVisibility = visibility.base;
515
533
  BREAKPOINTS.slice(1).forEach((bp) => {
516
- const bpValue = visibility[bp.key];
517
- if (bpValue === void 0) return;
518
- if (bpValue !== lastVisibility) {
519
- if (bpValue === false) {
534
+ if (visibility[bp.key] === false) {
535
+ const minWidth = breakpointWidths[bp.key];
536
+ const maxWidth = getNextBreakpointWidth(bp.key);
537
+ if (minWidth && maxWidth) {
520
538
  mediaQueries.push(
521
- `@media (min-width: ${bp.minWidth}px) { .${uniqueId} { display: none; } }`
539
+ `@media (min-width: ${minWidth}px) and (max-width: ${maxWidth - 1}px) { .${uniqueId} { display: none; } }`
522
540
  );
523
- } else {
541
+ } else if (minWidth) {
524
542
  mediaQueries.push(
525
- `@media (min-width: ${bp.minWidth}px) { .${uniqueId} { display: block; } }`
543
+ `@media (min-width: ${minWidth}px) { .${uniqueId} { display: none; } }`
526
544
  );
527
545
  }
528
- lastVisibility = bpValue;
529
546
  }
530
547
  });
531
548
  return mediaQueries.join("\n");
@@ -1563,7 +1580,7 @@ function SizeFieldInner({
1563
1580
  onClick: handleClear,
1564
1581
  className: "text-muted-foreground hover:text-destructive",
1565
1582
  title: "Reset to default",
1566
- children: /* @__PURE__ */ jsx(IconX, { className: "h-4 w-4" })
1583
+ children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
1567
1584
  }
1568
1585
  )
1569
1586
  ] }),
@@ -340,13 +340,13 @@ declare const DEFAULT_TRANSFORM: TransformValue;
340
340
  * Convert TransformValue to CSS properties object
341
341
  */
342
342
  declare function transformValueToCSS(transform: TransformValue | null | undefined): React__default.CSSProperties | undefined;
343
- type Breakpoint = 'base' | 'sm' | 'md' | 'lg' | 'xl';
343
+ type Breakpoint = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
344
344
  /**
345
345
  * Responsive value that can have different values at different breakpoints.
346
- * Base is required, other breakpoints are optional overrides.
346
+ * XS (extra small) is required, other breakpoints are optional overrides.
347
347
  */
348
348
  interface ResponsiveValue<T> {
349
- base: T;
349
+ xs: T;
350
350
  sm?: T;
351
351
  md?: T;
352
352
  lg?: T;
@@ -407,9 +407,9 @@ declare function responsiveValueToCSS<T>(value: ResponsiveValue<T> | T | null |
407
407
  * Visibility value for show/hide per breakpoint
408
408
  */
409
409
  interface VisibilityValue {
410
- /** Base visibility - true = visible, false = hidden (default: true) */
411
- base: boolean;
412
- /** Override for small screens (640px+) */
410
+ /** XS (extra small) visibility - true = visible, false = hidden (default: true) */
411
+ xs: boolean;
412
+ /** Small screens (640px+) */
413
413
  sm?: boolean;
414
414
  /** Override for medium screens (768px+) */
415
415
  md?: boolean;
@@ -424,6 +424,7 @@ interface VisibilityValue {
424
424
  declare const DEFAULT_VISIBILITY: VisibilityValue;
425
425
  /**
426
426
  * Converts a VisibilityValue to CSS with display: none media queries.
427
+ * Each breakpoint is independent - generates targeted media queries for hidden breakpoints.
427
428
  *
428
429
  * @param visibility - The visibility settings per breakpoint
429
430
  * @param uniqueId - Unique class name for targeting in media queries
@@ -340,13 +340,13 @@ declare const DEFAULT_TRANSFORM: TransformValue;
340
340
  * Convert TransformValue to CSS properties object
341
341
  */
342
342
  declare function transformValueToCSS(transform: TransformValue | null | undefined): React__default.CSSProperties | undefined;
343
- type Breakpoint = 'base' | 'sm' | 'md' | 'lg' | 'xl';
343
+ type Breakpoint = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
344
344
  /**
345
345
  * Responsive value that can have different values at different breakpoints.
346
- * Base is required, other breakpoints are optional overrides.
346
+ * XS (extra small) is required, other breakpoints are optional overrides.
347
347
  */
348
348
  interface ResponsiveValue<T> {
349
- base: T;
349
+ xs: T;
350
350
  sm?: T;
351
351
  md?: T;
352
352
  lg?: T;
@@ -407,9 +407,9 @@ declare function responsiveValueToCSS<T>(value: ResponsiveValue<T> | T | null |
407
407
  * Visibility value for show/hide per breakpoint
408
408
  */
409
409
  interface VisibilityValue {
410
- /** Base visibility - true = visible, false = hidden (default: true) */
411
- base: boolean;
412
- /** Override for small screens (640px+) */
410
+ /** XS (extra small) visibility - true = visible, false = hidden (default: true) */
411
+ xs: boolean;
412
+ /** Small screens (640px+) */
413
413
  sm?: boolean;
414
414
  /** Override for medium screens (768px+) */
415
415
  md?: boolean;
@@ -424,6 +424,7 @@ interface VisibilityValue {
424
424
  declare const DEFAULT_VISIBILITY: VisibilityValue;
425
425
  /**
426
426
  * Converts a VisibilityValue to CSS with display: none media queries.
427
+ * Each breakpoint is independent - generates targeted media queries for hidden breakpoints.
427
428
  *
428
429
  * @param visibility - The visibility settings per breakpoint
429
430
  * @param uniqueId - Unique class name for targeting in media queries
@@ -17,6 +17,8 @@ examples/
17
17
  ├── app/
18
18
  │ ├── (frontend)/
19
19
  │ │ └── page.tsx # Homepage route (root "/")
20
+ │ ├── (manage)/
21
+ │ │ └── layout.tsx # Editor layout (imports Tailwind CSS)
20
22
  │ ├── pages/
21
23
  │ │ └── [id]/
22
24
  │ │ └── edit/
@@ -65,14 +67,19 @@ export default buildConfig({
65
67
  cp -r node_modules/@delmaredigital/payload-puck/examples/api/puck src/app/api/
66
68
  ```
67
69
 
68
- ### 3. Copy Editor Page
70
+ ### 3. Copy Editor Page & Layout
69
71
 
70
72
  ```bash
71
- # Adjust the destination path as needed for your route structure
73
+ # Create route group and copy layout (REQUIRED for Tailwind styles)
72
74
  mkdir -p src/app/\(manage\)/pages/\[id\]/edit
75
+ cp node_modules/@delmaredigital/payload-puck/examples/app/\(manage\)/layout.tsx src/app/\(manage\)/
76
+
77
+ # Copy editor page
73
78
  cp node_modules/@delmaredigital/payload-puck/examples/app/pages/\[id\]/edit/page.tsx src/app/\(manage\)/pages/\[id\]/edit/
74
79
  ```
75
80
 
81
+ > **Important:** The layout file imports Tailwind CSS. Without it, the editor will be completely unstyled. Update the CSS import path in `layout.tsx` to match your project's globals.css location.
82
+
76
83
  ### 4. Copy Frontend Routes
77
84
 
78
85
  ```bash
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Layout for Puck Editor routes
3
+ *
4
+ * IMPORTANT: This layout must import your Tailwind CSS for the editor to be styled.
5
+ * Update the import path to match your project's globals.css location.
6
+ */
7
+
8
+ // Import your Tailwind CSS - adjust path as needed
9
+ import '@/app/(frontend)/globals.css'
10
+ // Or if your globals.css is elsewhere:
11
+ // import '@/styles/globals.css'
12
+ // import '../globals.css'
13
+
14
+ export const metadata = {
15
+ title: 'Puck Editor',
16
+ description: 'Visual page editor',
17
+ }
18
+
19
+ export default function ManageLayout({
20
+ children,
21
+ }: {
22
+ children: React.ReactNode
23
+ }) {
24
+ return (
25
+ // NOTE: data-theme="light" is required if your CSS uses opacity:0 until theme is set
26
+ // (common FOUC prevention pattern). Adjust to match your theme system.
27
+ <html lang="en" data-theme="light">
28
+ <body>{children}</body>
29
+ </html>
30
+ )
31
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@delmaredigital/payload-puck",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Puck visual page builder plugin for Payload CMS",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -79,13 +79,20 @@
79
79
  },
80
80
  "files": [
81
81
  "dist",
82
+ "!dist/**/*.map",
82
83
  "examples",
83
84
  "README.md"
84
85
  ],
86
+ "scripts": {
87
+ "build": "tsup",
88
+ "dev": "tsup --watch",
89
+ "typecheck": "tsc --noEmit",
90
+ "prepublishOnly": "pnpm build"
91
+ },
85
92
  "peerDependencies": {
86
93
  "@measured/puck": ">=0.20.0",
87
94
  "@payloadcms/ui": ">=3.0.0",
88
- "next": ">=15.4.0",
95
+ "next": ">=15.4.8",
89
96
  "payload": ">=3.0.0",
90
97
  "react": ">=18.0.0"
91
98
  },
@@ -96,11 +103,12 @@
96
103
  },
97
104
  "dependencies": {
98
105
  "@measured/puck-plugin-heading-analyzer": "^0.20.2",
106
+ "@radix-ui/react-checkbox": "^1.3.2",
99
107
  "@radix-ui/react-dialog": "^1.1.15",
100
108
  "@radix-ui/react-label": "^2.1.8",
101
109
  "@radix-ui/react-select": "^2.2.6",
102
110
  "@radix-ui/react-slot": "^1.2.4",
103
- "@tabler/icons-react": "^3.36.1",
111
+ "lucide-react": "^0.469.0",
104
112
  "@tiptap/core": "^3.14.0",
105
113
  "@tiptap/extension-color": "^3.14.0",
106
114
  "@tiptap/extension-highlight": "^3.14.0",
@@ -148,10 +156,5 @@
148
156
  "bugs": {
149
157
  "url": "https://github.com/delmaredigital/payload-puck/issues"
150
158
  },
151
- "homepage": "https://delmaredigital.com/developers",
152
- "scripts": {
153
- "build": "tsup",
154
- "dev": "tsup --watch",
155
- "typecheck": "tsc --noEmit"
156
- }
157
- }
159
+ "homepage": "https://delmaredigital.com/developers"
160
+ }