@firecms/ui 3.0.0-canary.254 → 3.0.0-canary.256

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.
@@ -15,6 +15,10 @@ export type DialogProps = {
15
15
  onEscapeKeyDown?: (e: KeyboardEvent) => void;
16
16
  onPointerDownOutside?: (e: Event) => void;
17
17
  onInteractOutside?: (e: Event) => void;
18
+ /**
19
+ * If `true`, the dialog will not focus the first focusable element when opened.
20
+ */
21
+ disableInitialFocus?: boolean;
18
22
  };
19
23
  declare const widthClasses: {
20
24
  xs: string;
@@ -30,5 +34,5 @@ declare const widthClasses: {
30
34
  "7xl": string;
31
35
  full: string;
32
36
  };
33
- export declare const Dialog: ({ open, onOpenChange, children, className, containerClassName, fullWidth, fullHeight, fullScreen, scrollable, maxWidth, modal, onOpenAutoFocus, onEscapeKeyDown, onPointerDownOutside, onInteractOutside }: DialogProps) => import("react/jsx-runtime").JSX.Element;
37
+ export declare const Dialog: ({ open, onOpenChange, children, className, containerClassName, fullWidth, fullHeight, fullScreen, scrollable, maxWidth, modal, onOpenAutoFocus, onEscapeKeyDown, onPointerDownOutside, onInteractOutside, disableInitialFocus }: DialogProps) => import("react/jsx-runtime").JSX.Element;
34
38
  export {};
package/dist/index.es.js CHANGED
@@ -732,18 +732,22 @@ const BooleanSwitch = React__default.forwardRef(function BooleanSwitch2({
732
732
  } else {
733
733
  onValueChange?.(!value);
734
734
  }
735
- }, className: cls(size === "small" ? "w-[38px] h-[22px] min-w-[38px] min-h-[22px]" : "w-[42px] h-[26px] min-w-[42px] min-h-[26px]", "outline-none rounded-full relative shadow-sm", value ? disabled ? "bg-white bg-opacity-54 dark:bg-surface-accent-950 border-surface-accent-100 dark:border-surface-accent-700 ring-1 ring-surface-accent-200 dark:ring-surface-accent-700" : "ring-secondary ring-1 bg-secondary dark:bg-secondary" : "bg-white bg-opacity-54 dark:bg-surface-accent-900 ring-1 ring-surface-accent-200 dark:ring-surface-accent-700", className), ...props, children: [
735
+ }, className: cls(size === "smallest" ? "w-[34px] h-[18px] min-w-[34px] min-h-[18px]" : size === "small" ? "w-[38px] h-[22px] min-w-[38px] min-h-[22px]" : "w-[42px] h-[26px] min-w-[42px] min-h-[26px]", "outline-none rounded-full relative shadow-sm", value ? disabled ? "bg-white bg-opacity-54 dark:bg-surface-accent-950 border-surface-accent-100 dark:border-surface-accent-700 ring-1 ring-surface-accent-200 dark:ring-surface-accent-700" : "ring-secondary ring-1 bg-secondary dark:bg-secondary" : "bg-white bg-opacity-54 dark:bg-surface-accent-900 ring-1 ring-surface-accent-200 dark:ring-surface-accent-700", className), ...props, children: [
736
736
  allowIndeterminate && (value === null || value === void 0) && /* @__PURE__ */ jsx("div", { className: cls("block rounded-full transition-transform duration-100 transform will-change-auto", disabled ? "bg-surface-accent-400 dark:bg-surface-accent-600" : "bg-surface-accent-400 dark:bg-surface-accent-600", {
737
737
  "w-[21px] h-[10px]": size === "medium" || size === "large",
738
738
  "w-[19px] h-[8px]": size === "small",
739
+ "w-[16px] h-[6px]": size === "smallest",
739
740
  "translate-x-[10px]": size === "medium" || size === "large",
740
- "translate-x-[9px]": size === "small"
741
+ "translate-x-[9px]": size === "small",
742
+ "translate-x-[8px]": size === "smallest"
741
743
  }) }, "knob"),
742
744
  !(allowIndeterminate && (value === null || value === void 0)) && /* @__PURE__ */ jsx("div", { className: cls("block rounded-full transition-transform duration-100 transform will-change-auto", disabled ? "bg-surface-accent-300 dark:bg-surface-accent-700" : value ? "bg-white" : "bg-surface-accent-600 dark:bg-surface-accent-400", {
743
745
  "w-[21px] h-[21px]": size === "medium" || size === "large",
744
746
  "w-[19px] h-[19px]": size === "small",
747
+ "w-[16px] h-[16px]": size === "smallest",
745
748
  [value ? "translate-x-[19px]" : "translate-x-[3px]"]: size === "medium" || size === "large",
746
- [value ? "translate-x-[17px]" : "translate-x-[2px]"]: size === "small"
749
+ [value ? "translate-x-[17px]" : "translate-x-[2px]"]: size === "small",
750
+ [value ? "translate-x-[16px]" : "translate-x-[1px]"]: size === "smallest"
747
751
  }) }, "knob")
748
752
  ] });
749
753
  });
@@ -775,7 +779,7 @@ const BooleanSwitchWithLabel = function BooleanSwitchWithLabel2({
775
779
  "min-h-[32px]": size === "small",
776
780
  "min-h-[42px]": size === "medium",
777
781
  "min-h-[64px]": size === "large"
778
- }, size === "small" ? "pl-2" : "pl-4", size === "small" ? "pr-4" : "pr-6", position === "end" ? "flex-row-reverse" : "flex-row", fullWidth ? "w-full" : "", className), onClick: disabled ? void 0 : (e) => {
782
+ }, size === "small" || size === "smallest" ? "pl-2" : "pl-4", size === "small" || size === "smallest" ? "pr-4" : "pr-6", position === "end" ? "flex-row-reverse" : "flex-row", fullWidth ? "w-full" : "", className), onClick: disabled ? void 0 : (e) => {
779
783
  if (props.allowIndeterminate) {
780
784
  if (value === null || value === void 0) onValueChange?.(true);
781
785
  else if (value) onValueChange?.(false);
@@ -785,7 +789,7 @@ const BooleanSwitchWithLabel = function BooleanSwitchWithLabel2({
785
789
  }
786
790
  }, children: [
787
791
  /* @__PURE__ */ jsx(BooleanSwitch, { value, ref: refInput, size, className: cls(invisible && focus ? focusedClasses : "", inputClassName), disabled, ...props }),
788
- /* @__PURE__ */ jsx("div", { className: cls("flex-grow", position === "end" ? "mr-4" : "ml-4", size === "small" ? "text-sm" : "text-base"), children: label })
792
+ /* @__PURE__ */ jsx("div", { className: cls("flex-grow", position === "end" ? "mr-4" : "ml-4", size === "small" || size === "smallest" ? "text-sm" : "text-base"), children: label })
789
793
  ] });
790
794
  };
791
795
  const ButtonInner = React__default.forwardRef((t0, ref) => {
@@ -27997,7 +28001,7 @@ const widthClasses = {
27997
28001
  full: "max-w-full min-w-full w-full"
27998
28002
  };
27999
28003
  const Dialog = (t0) => {
28000
- const $ = c(39);
28004
+ const $ = c(42);
28001
28005
  const {
28002
28006
  open,
28003
28007
  onOpenChange,
@@ -28013,17 +28017,19 @@ const Dialog = (t0) => {
28013
28017
  onOpenAutoFocus,
28014
28018
  onEscapeKeyDown,
28015
28019
  onPointerDownOutside,
28016
- onInteractOutside
28020
+ onInteractOutside,
28021
+ disableInitialFocus: t5
28017
28022
  } = t0;
28018
28023
  const fullWidth = t1 === void 0 ? true : t1;
28019
28024
  const scrollable = t2 === void 0 ? true : t2;
28020
28025
  const maxWidth = t3 === void 0 ? "lg" : t3;
28021
28026
  const modal = t4 === void 0 ? true : t4;
28027
+ const disableInitialFocus = t5 === void 0 ? true : t5;
28022
28028
  const [displayed, setDisplayed] = useState(false);
28023
- let t5;
28024
28029
  let t6;
28030
+ let t7;
28025
28031
  if ($[0] !== open) {
28026
- t5 = () => {
28032
+ t6 = () => {
28027
28033
  if (!open) {
28028
28034
  const timeout = setTimeout(() => {
28029
28035
  setDisplayed(false);
@@ -28034,126 +28040,140 @@ const Dialog = (t0) => {
28034
28040
  return _temp$2;
28035
28041
  }
28036
28042
  };
28037
- t6 = [open];
28043
+ t7 = [open];
28038
28044
  $[0] = open;
28039
- $[1] = t5;
28040
- $[2] = t6;
28045
+ $[1] = t6;
28046
+ $[2] = t7;
28041
28047
  } else {
28042
- t5 = $[1];
28043
- t6 = $[2];
28048
+ t6 = $[1];
28049
+ t7 = $[2];
28044
28050
  }
28045
- useEffect(t5, t6);
28046
- const t7 = displayed || open;
28047
- let t8;
28051
+ useEffect(t6, t7);
28052
+ const t8 = displayed || open;
28053
+ let t9;
28048
28054
  if ($[3] !== containerClassName) {
28049
- t8 = cls("fixed inset-0 z-30", containerClassName);
28055
+ t9 = cls("fixed inset-0 z-30", containerClassName);
28050
28056
  $[3] = containerClassName;
28051
- $[4] = t8;
28057
+ $[4] = t9;
28052
28058
  } else {
28053
- t8 = $[4];
28059
+ t9 = $[4];
28054
28060
  }
28055
- const t9 = displayed && open ? "opacity-100" : "opacity-0";
28056
- let t10;
28057
- if ($[5] !== t9) {
28058
- t10 = cls("fixed inset-0 transition-opacity z-20 ease-in-out duration-200 bg-black bg-opacity-50 dark:bg-opacity-60 backdrop-blur-sm ", t9, "z-20 fixed top-0 left-0 w-full h-full flex justify-center items-center");
28059
- $[5] = t9;
28060
- $[6] = t10;
28061
+ const t10 = displayed && open ? "opacity-100" : "opacity-0";
28062
+ let t11;
28063
+ if ($[5] !== t10) {
28064
+ t11 = cls("fixed inset-0 transition-opacity z-20 ease-in-out duration-200 bg-black bg-opacity-50 dark:bg-opacity-60 backdrop-blur-sm ", t10, "z-20 fixed top-0 left-0 w-full h-full flex justify-center items-center");
28065
+ $[5] = t10;
28066
+ $[6] = t11;
28061
28067
  } else {
28062
- t10 = $[6];
28068
+ t11 = $[6];
28063
28069
  }
28064
- const t11 = displayed ? "auto" : "none";
28065
- let t12;
28066
- if ($[7] !== t11) {
28067
- t12 = {
28068
- pointerEvents: t11
28070
+ const t12 = displayed ? "auto" : "none";
28071
+ let t13;
28072
+ if ($[7] !== t12) {
28073
+ t13 = {
28074
+ pointerEvents: t12
28069
28075
  };
28070
- $[7] = t11;
28071
- $[8] = t12;
28076
+ $[7] = t12;
28077
+ $[8] = t13;
28072
28078
  } else {
28073
- t12 = $[8];
28079
+ t13 = $[8];
28074
28080
  }
28075
- let t13;
28076
- if ($[9] !== t10 || $[10] !== t12) {
28077
- t13 = /* @__PURE__ */ jsx(DialogPrimitive.Overlay, { className: t10, style: t12 });
28078
- $[9] = t10;
28079
- $[10] = t12;
28080
- $[11] = t13;
28081
+ let t14;
28082
+ if ($[9] !== t11 || $[10] !== t13) {
28083
+ t14 = /* @__PURE__ */ jsx(DialogPrimitive.Overlay, { className: t11, style: t13 });
28084
+ $[9] = t11;
28085
+ $[10] = t13;
28086
+ $[11] = t14;
28081
28087
  } else {
28082
- t13 = $[11];
28088
+ t14 = $[11];
28083
28089
  }
28084
- let t14;
28085
- if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
28086
- t14 = cls("h-full outline-none flex justify-center items-center z-40 opacity-100 transition-all duration-200 ease-in-out");
28087
- $[12] = t14;
28088
- } else {
28089
- t14 = $[12];
28090
- }
28091
- const t15 = fullWidth && !fullScreen ? "w-11/12" : void 0;
28092
- const t16 = fullHeight && !fullScreen ? "h-full" : void 0;
28093
- const t17 = fullScreen ? "h-screen w-screen" : "max-h-[90vh] shadow-xl";
28094
- const t18 = scrollable && "overflow-y-auto";
28095
- const t19 = displayed && open ? "opacity-100" : "opacity-0";
28096
- const t20 = maxWidth && !fullScreen ? widthClasses[maxWidth] : void 0;
28097
- let t21;
28098
- if ($[13] !== className || $[14] !== t15 || $[15] !== t16 || $[16] !== t17 || $[17] !== t18 || $[18] !== t19 || $[19] !== t20) {
28099
- t21 = cls(paperMixin, "z-30", "relative", "outline-none focus:outline-none", t15, t16, "text-surface-accent-900 dark:text-white", "justify-center items-center", t17, "ease-in-out duration-200", t18, t19, t20, className);
28100
- $[13] = className;
28090
+ let t15;
28091
+ if ($[12] !== disableInitialFocus || $[13] !== onOpenAutoFocus) {
28092
+ t15 = (e) => {
28093
+ if (disableInitialFocus) {
28094
+ e.preventDefault();
28095
+ }
28096
+ onOpenAutoFocus?.(e);
28097
+ };
28098
+ $[12] = disableInitialFocus;
28099
+ $[13] = onOpenAutoFocus;
28101
28100
  $[14] = t15;
28102
- $[15] = t16;
28103
- $[16] = t17;
28104
- $[17] = t18;
28105
- $[18] = t19;
28106
- $[19] = t20;
28107
- $[20] = t21;
28108
28101
  } else {
28109
- t21 = $[20];
28102
+ t15 = $[14];
28110
28103
  }
28111
- let t22;
28112
- if ($[21] !== children || $[22] !== t21) {
28113
- t22 = /* @__PURE__ */ jsx("div", { className: t21, children });
28114
- $[21] = children;
28115
- $[22] = t21;
28116
- $[23] = t22;
28104
+ let t16;
28105
+ if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
28106
+ t16 = cls("h-full outline-none flex justify-center items-center z-40 opacity-100 transition-all duration-200 ease-in-out");
28107
+ $[15] = t16;
28117
28108
  } else {
28118
- t22 = $[23];
28109
+ t16 = $[15];
28119
28110
  }
28111
+ const t17 = fullWidth && !fullScreen ? "w-11/12" : void 0;
28112
+ const t18 = fullHeight && !fullScreen ? "h-full" : void 0;
28113
+ const t19 = fullScreen ? "h-screen w-screen" : "max-h-[90vh] shadow-xl";
28114
+ const t20 = scrollable && "overflow-y-auto";
28115
+ const t21 = displayed && open ? "opacity-100" : "opacity-0";
28116
+ const t22 = maxWidth && !fullScreen ? widthClasses[maxWidth] : void 0;
28120
28117
  let t23;
28121
- if ($[24] !== onEscapeKeyDown || $[25] !== onInteractOutside || $[26] !== onOpenAutoFocus || $[27] !== onPointerDownOutside || $[28] !== t22) {
28122
- t23 = /* @__PURE__ */ jsx(DialogPrimitive.Content, { onEscapeKeyDown, onOpenAutoFocus, onPointerDownOutside, onInteractOutside, className: t14, children: t22 });
28123
- $[24] = onEscapeKeyDown;
28124
- $[25] = onInteractOutside;
28125
- $[26] = onOpenAutoFocus;
28126
- $[27] = onPointerDownOutside;
28127
- $[28] = t22;
28128
- $[29] = t23;
28129
- } else {
28130
- t23 = $[29];
28118
+ if ($[16] !== className || $[17] !== t17 || $[18] !== t18 || $[19] !== t19 || $[20] !== t20 || $[21] !== t21 || $[22] !== t22) {
28119
+ t23 = cls(paperMixin, "z-30", "relative", "outline-none focus:outline-none", t17, t18, "text-surface-accent-900 dark:text-white", "justify-center items-center", t19, "ease-in-out duration-200", t20, t21, t22, className);
28120
+ $[16] = className;
28121
+ $[17] = t17;
28122
+ $[18] = t18;
28123
+ $[19] = t19;
28124
+ $[20] = t20;
28125
+ $[21] = t21;
28126
+ $[22] = t22;
28127
+ $[23] = t23;
28128
+ } else {
28129
+ t23 = $[23];
28131
28130
  }
28132
28131
  let t24;
28133
- if ($[30] !== t13 || $[31] !== t23 || $[32] !== t8) {
28134
- t24 = /* @__PURE__ */ jsx(DialogPrimitive.Portal, { children: /* @__PURE__ */ jsxs("div", { className: t8, children: [
28135
- t13,
28136
- t23
28137
- ] }) });
28138
- $[30] = t13;
28139
- $[31] = t23;
28140
- $[32] = t8;
28141
- $[33] = t24;
28132
+ if ($[24] !== children || $[25] !== t23) {
28133
+ t24 = /* @__PURE__ */ jsx("div", { className: t23, children });
28134
+ $[24] = children;
28135
+ $[25] = t23;
28136
+ $[26] = t24;
28142
28137
  } else {
28143
- t24 = $[33];
28138
+ t24 = $[26];
28144
28139
  }
28145
28140
  let t25;
28146
- if ($[34] !== modal || $[35] !== onOpenChange || $[36] !== t24 || $[37] !== t7) {
28147
- t25 = /* @__PURE__ */ jsx(DialogPrimitive.Root, { open: t7, modal, onOpenChange, children: t24 });
28148
- $[34] = modal;
28149
- $[35] = onOpenChange;
28150
- $[36] = t24;
28151
- $[37] = t7;
28152
- $[38] = t25;
28141
+ if ($[27] !== onEscapeKeyDown || $[28] !== onInteractOutside || $[29] !== onPointerDownOutside || $[30] !== t15 || $[31] !== t24) {
28142
+ t25 = /* @__PURE__ */ jsx(DialogPrimitive.Content, { onEscapeKeyDown, onOpenAutoFocus: t15, onPointerDownOutside, onInteractOutside, className: t16, children: t24 });
28143
+ $[27] = onEscapeKeyDown;
28144
+ $[28] = onInteractOutside;
28145
+ $[29] = onPointerDownOutside;
28146
+ $[30] = t15;
28147
+ $[31] = t24;
28148
+ $[32] = t25;
28149
+ } else {
28150
+ t25 = $[32];
28151
+ }
28152
+ let t26;
28153
+ if ($[33] !== t14 || $[34] !== t25 || $[35] !== t9) {
28154
+ t26 = /* @__PURE__ */ jsx(DialogPrimitive.Portal, { children: /* @__PURE__ */ jsxs("div", { className: t9, children: [
28155
+ t14,
28156
+ t25
28157
+ ] }) });
28158
+ $[33] = t14;
28159
+ $[34] = t25;
28160
+ $[35] = t9;
28161
+ $[36] = t26;
28162
+ } else {
28163
+ t26 = $[36];
28164
+ }
28165
+ let t27;
28166
+ if ($[37] !== modal || $[38] !== onOpenChange || $[39] !== t26 || $[40] !== t8) {
28167
+ t27 = /* @__PURE__ */ jsx(DialogPrimitive.Root, { open: t8, modal, onOpenChange, children: t26 });
28168
+ $[37] = modal;
28169
+ $[38] = onOpenChange;
28170
+ $[39] = t26;
28171
+ $[40] = t8;
28172
+ $[41] = t27;
28153
28173
  } else {
28154
- t25 = $[38];
28174
+ t27 = $[41];
28155
28175
  }
28156
- return t25;
28176
+ return t27;
28157
28177
  };
28158
28178
  function _temp$2() {
28159
28179
  }