@delmaredigital/payload-puck 0.1.3 → 0.2.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.
@@ -810,25 +810,23 @@ function responsiveValueToCSS(value, converter, uniqueId) {
810
810
  mediaQueryCSS: ""
811
811
  };
812
812
  }
813
- const mediaQueries = [];
814
- let baseStyles = {};
813
+ const cssRules = [];
815
814
  BREAKPOINTS.forEach((bp) => {
816
815
  const bpValue = value[bp.key];
817
816
  if (bpValue === void 0) return;
818
817
  const cssProps = converter(bpValue);
819
818
  if (!cssProps) return;
819
+ const styleString = cssPropertiesToString(cssProps);
820
+ if (!styleString) return;
820
821
  if (bp.key === "xs") {
821
- baseStyles = cssProps;
822
+ cssRules.push(`.${uniqueId} { ${styleString} }`);
822
823
  } else {
823
- const styleString = cssPropertiesToString(cssProps);
824
- if (styleString) {
825
- mediaQueries.push(
826
- `@media (min-width: ${bp.minWidth}px) { .${uniqueId} { ${styleString} } }`
827
- );
828
- }
824
+ cssRules.push(
825
+ `@media (min-width: ${bp.minWidth}px) { .${uniqueId} { ${styleString} } }`
826
+ );
829
827
  }
830
828
  });
831
- return { baseStyles, mediaQueryCSS: mediaQueries.join("\n") };
829
+ return { baseStyles: {}, mediaQueryCSS: cssRules.join("\n") };
832
830
  }
833
831
  var DEFAULT_VISIBILITY = {
834
832
  xs: true,
@@ -4196,12 +4194,12 @@ var Checkbox = React12__namespace.forwardRef(
4196
4194
  );
4197
4195
  Checkbox.displayName = "Checkbox";
4198
4196
  var DEFAULT_VALUE5 = {
4199
- mode: "contained",
4197
+ mode: "full",
4200
4198
  alignment: "center",
4201
4199
  maxWidth: {
4202
- value: 1200,
4200
+ value: 0,
4203
4201
  unit: "px",
4204
- enabled: true
4202
+ enabled: false
4205
4203
  },
4206
4204
  advancedMode: false
4207
4205
  };
@@ -4428,11 +4426,13 @@ function DimensionsFieldInner({
4428
4426
  const handleAdvancedToggle = React12.useCallback(() => {
4429
4427
  const newAdvancedMode = !advancedMode;
4430
4428
  setAdvancedMode(newAdvancedMode);
4431
- onChange({
4432
- ...currentValue,
4433
- advancedMode: newAdvancedMode
4434
- });
4435
- }, [advancedMode, currentValue, onChange]);
4429
+ if (value !== null) {
4430
+ onChange({
4431
+ ...currentValue,
4432
+ advancedMode: newAdvancedMode
4433
+ });
4434
+ }
4435
+ }, [advancedMode, currentValue, onChange, value]);
4436
4436
  const modeConfig = [
4437
4437
  { mode: "full", icon: lucideReact.MoveHorizontal, label: "Full", title: "Full width (100%)" },
4438
4438
  { mode: "contained", icon: lucideReact.Square, label: "Contain", title: "Contained (centered with max-width)" },
@@ -6434,7 +6434,7 @@ function ResponsiveFieldInner({
6434
6434
  }) {
6435
6435
  const [activeBreakpoint, setActiveBreakpoint] = React12.useState("xs");
6436
6436
  const getCurrentValue = React12.useCallback(() => {
6437
- if (!value) return defaultValue ?? null;
6437
+ if (!value) return null;
6438
6438
  if (activeBreakpoint === "xs") {
6439
6439
  return value.xs ?? defaultValue ?? null;
6440
6440
  }
@@ -6456,21 +6456,35 @@ function ResponsiveFieldInner({
6456
6456
  const hasOverride = React12.useCallback(
6457
6457
  (breakpoint) => {
6458
6458
  if (!value) return false;
6459
- if (breakpoint === "xs") return value.xs !== void 0;
6459
+ if (breakpoint === "xs") return false;
6460
6460
  return value[breakpoint] !== void 0;
6461
6461
  },
6462
6462
  [value]
6463
6463
  );
6464
+ const getInheritanceSource = React12.useCallback(() => {
6465
+ if (!value || activeBreakpoint === "xs") return null;
6466
+ if (value[activeBreakpoint] !== void 0) return null;
6467
+ const breakpointOrder = ["xl", "lg", "md", "sm", "xs"];
6468
+ const activeIndex = breakpointOrder.indexOf(activeBreakpoint);
6469
+ for (let i = activeIndex + 1; i < breakpointOrder.length; i++) {
6470
+ const bp = breakpointOrder[i];
6471
+ if (value[bp] !== void 0) {
6472
+ return bp;
6473
+ }
6474
+ }
6475
+ return null;
6476
+ }, [value, activeBreakpoint]);
6464
6477
  const handleInnerChange = React12.useCallback(
6465
6478
  (newValue) => {
6466
6479
  if (activeBreakpoint === "xs") {
6467
- if (newValue === null && defaultValue !== void 0) {
6468
- onChange({ ...value, xs: defaultValue });
6469
- } else if (newValue !== null) {
6480
+ if (newValue === null) {
6481
+ onChange(null);
6482
+ } else {
6470
6483
  onChange({ ...value, xs: newValue });
6471
6484
  }
6472
6485
  } else {
6473
6486
  if (newValue === null) {
6487
+ if (!value) return;
6474
6488
  const newResponsive = { ...value };
6475
6489
  delete newResponsive[activeBreakpoint];
6476
6490
  onChange(newResponsive);
@@ -6499,6 +6513,7 @@ function ResponsiveFieldInner({
6499
6513
  const currentValue = getCurrentValue();
6500
6514
  const isOverrideBreakpoint = activeBreakpoint !== "xs";
6501
6515
  const currentHasOverride = hasOverride(activeBreakpoint);
6516
+ const inheritanceSource = getInheritanceSource();
6502
6517
  const overrideCount = value ? ["sm", "md", "lg", "xl"].filter((bp) => value[bp] !== void 0).length : 0;
6503
6518
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "puck-field space-y-3", children: [
6504
6519
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
@@ -6540,7 +6555,11 @@ function ResponsiveFieldInner({
6540
6555
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: activeBreakpoint === "xs" ? "Extra small screens (0-639px)" : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6541
6556
  BREAKPOINTS.find((bp) => bp.key === activeBreakpoint)?.minWidth,
6542
6557
  "px and up",
6543
- !currentHasOverride && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground/60", children: " (inheriting from xs)" })
6558
+ !currentHasOverride && inheritanceSource && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground/60", children: [
6559
+ " (inheriting from ",
6560
+ inheritanceSource.toUpperCase(),
6561
+ ")"
6562
+ ] })
6544
6563
  ] }) }),
6545
6564
  isOverrideBreakpoint && currentHasOverride && !readOnly && /* @__PURE__ */ jsxRuntime.jsx(
6546
6565
  Button,
@@ -779,25 +779,23 @@ function responsiveValueToCSS(value, converter, uniqueId) {
779
779
  mediaQueryCSS: ""
780
780
  };
781
781
  }
782
- const mediaQueries = [];
783
- let baseStyles = {};
782
+ const cssRules = [];
784
783
  BREAKPOINTS.forEach((bp) => {
785
784
  const bpValue = value[bp.key];
786
785
  if (bpValue === void 0) return;
787
786
  const cssProps = converter(bpValue);
788
787
  if (!cssProps) return;
788
+ const styleString = cssPropertiesToString(cssProps);
789
+ if (!styleString) return;
789
790
  if (bp.key === "xs") {
790
- baseStyles = cssProps;
791
+ cssRules.push(`.${uniqueId} { ${styleString} }`);
791
792
  } else {
792
- const styleString = cssPropertiesToString(cssProps);
793
- if (styleString) {
794
- mediaQueries.push(
795
- `@media (min-width: ${bp.minWidth}px) { .${uniqueId} { ${styleString} } }`
796
- );
797
- }
793
+ cssRules.push(
794
+ `@media (min-width: ${bp.minWidth}px) { .${uniqueId} { ${styleString} } }`
795
+ );
798
796
  }
799
797
  });
800
- return { baseStyles, mediaQueryCSS: mediaQueries.join("\n") };
798
+ return { baseStyles: {}, mediaQueryCSS: cssRules.join("\n") };
801
799
  }
802
800
  var DEFAULT_VISIBILITY = {
803
801
  xs: true,
@@ -4165,12 +4163,12 @@ var Checkbox = React12.forwardRef(
4165
4163
  );
4166
4164
  Checkbox.displayName = "Checkbox";
4167
4165
  var DEFAULT_VALUE5 = {
4168
- mode: "contained",
4166
+ mode: "full",
4169
4167
  alignment: "center",
4170
4168
  maxWidth: {
4171
- value: 1200,
4169
+ value: 0,
4172
4170
  unit: "px",
4173
- enabled: true
4171
+ enabled: false
4174
4172
  },
4175
4173
  advancedMode: false
4176
4174
  };
@@ -4397,11 +4395,13 @@ function DimensionsFieldInner({
4397
4395
  const handleAdvancedToggle = useCallback(() => {
4398
4396
  const newAdvancedMode = !advancedMode;
4399
4397
  setAdvancedMode(newAdvancedMode);
4400
- onChange({
4401
- ...currentValue,
4402
- advancedMode: newAdvancedMode
4403
- });
4404
- }, [advancedMode, currentValue, onChange]);
4398
+ if (value !== null) {
4399
+ onChange({
4400
+ ...currentValue,
4401
+ advancedMode: newAdvancedMode
4402
+ });
4403
+ }
4404
+ }, [advancedMode, currentValue, onChange, value]);
4405
4405
  const modeConfig = [
4406
4406
  { mode: "full", icon: MoveHorizontal, label: "Full", title: "Full width (100%)" },
4407
4407
  { mode: "contained", icon: Square, label: "Contain", title: "Contained (centered with max-width)" },
@@ -6403,7 +6403,7 @@ function ResponsiveFieldInner({
6403
6403
  }) {
6404
6404
  const [activeBreakpoint, setActiveBreakpoint] = useState("xs");
6405
6405
  const getCurrentValue = useCallback(() => {
6406
- if (!value) return defaultValue ?? null;
6406
+ if (!value) return null;
6407
6407
  if (activeBreakpoint === "xs") {
6408
6408
  return value.xs ?? defaultValue ?? null;
6409
6409
  }
@@ -6425,21 +6425,35 @@ function ResponsiveFieldInner({
6425
6425
  const hasOverride = useCallback(
6426
6426
  (breakpoint) => {
6427
6427
  if (!value) return false;
6428
- if (breakpoint === "xs") return value.xs !== void 0;
6428
+ if (breakpoint === "xs") return false;
6429
6429
  return value[breakpoint] !== void 0;
6430
6430
  },
6431
6431
  [value]
6432
6432
  );
6433
+ const getInheritanceSource = useCallback(() => {
6434
+ if (!value || activeBreakpoint === "xs") return null;
6435
+ if (value[activeBreakpoint] !== void 0) return null;
6436
+ const breakpointOrder = ["xl", "lg", "md", "sm", "xs"];
6437
+ const activeIndex = breakpointOrder.indexOf(activeBreakpoint);
6438
+ for (let i = activeIndex + 1; i < breakpointOrder.length; i++) {
6439
+ const bp = breakpointOrder[i];
6440
+ if (value[bp] !== void 0) {
6441
+ return bp;
6442
+ }
6443
+ }
6444
+ return null;
6445
+ }, [value, activeBreakpoint]);
6433
6446
  const handleInnerChange = useCallback(
6434
6447
  (newValue) => {
6435
6448
  if (activeBreakpoint === "xs") {
6436
- if (newValue === null && defaultValue !== void 0) {
6437
- onChange({ ...value, xs: defaultValue });
6438
- } else if (newValue !== null) {
6449
+ if (newValue === null) {
6450
+ onChange(null);
6451
+ } else {
6439
6452
  onChange({ ...value, xs: newValue });
6440
6453
  }
6441
6454
  } else {
6442
6455
  if (newValue === null) {
6456
+ if (!value) return;
6443
6457
  const newResponsive = { ...value };
6444
6458
  delete newResponsive[activeBreakpoint];
6445
6459
  onChange(newResponsive);
@@ -6468,6 +6482,7 @@ function ResponsiveFieldInner({
6468
6482
  const currentValue = getCurrentValue();
6469
6483
  const isOverrideBreakpoint = activeBreakpoint !== "xs";
6470
6484
  const currentHasOverride = hasOverride(activeBreakpoint);
6485
+ const inheritanceSource = getInheritanceSource();
6471
6486
  const overrideCount = value ? ["sm", "md", "lg", "xl"].filter((bp) => value[bp] !== void 0).length : 0;
6472
6487
  return /* @__PURE__ */ jsxs("div", { className: "puck-field space-y-3", children: [
6473
6488
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
@@ -6509,7 +6524,11 @@ function ResponsiveFieldInner({
6509
6524
  /* @__PURE__ */ jsx("span", { children: activeBreakpoint === "xs" ? "Extra small screens (0-639px)" : /* @__PURE__ */ jsxs(Fragment, { children: [
6510
6525
  BREAKPOINTS.find((bp) => bp.key === activeBreakpoint)?.minWidth,
6511
6526
  "px and up",
6512
- !currentHasOverride && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground/60", children: " (inheriting from xs)" })
6527
+ !currentHasOverride && inheritanceSource && /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground/60", children: [
6528
+ " (inheriting from ",
6529
+ inheritanceSource.toUpperCase(),
6530
+ ")"
6531
+ ] })
6513
6532
  ] }) }),
6514
6533
  isOverrideBreakpoint && currentHasOverride && !readOnly && /* @__PURE__ */ jsx(
6515
6534
  Button,