@firecms/ui 3.1.0 → 3.2.0-canary.9c3d298

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.
package/dist/index.es.js CHANGED
@@ -32933,7 +32933,7 @@ const DateTimeField = ({
32933
32933
  const [focused, setFocused] = useState(false);
32934
32934
  const [internalValue, setInternalValue] = useState("");
32935
32935
  const [isTyping, setIsTyping] = useState(false);
32936
- const invalidValue = value !== void 0 && value !== null && !(value instanceof Date);
32936
+ const invalidValue = value !== void 0 && value !== null && (!(value instanceof Date) || isNaN(value.getTime()));
32937
32937
  useInjectStyles("DateTimeField", inputStyles);
32938
32938
  const handleClear = (e) => {
32939
32939
  e.preventDefault();
@@ -32956,7 +32956,12 @@ const DateTimeField = ({
32956
32956
  // undefined = local timezone
32957
32957
  };
32958
32958
  const formatter = new Intl.DateTimeFormat("en-CA", options);
32959
- const parts = formatter.formatToParts(dateValue);
32959
+ let parts;
32960
+ try {
32961
+ parts = formatter.formatToParts(dateValue);
32962
+ } catch {
32963
+ return "";
32964
+ }
32960
32965
  const getPart = (type) => parts.find((p) => p.type === type)?.value ?? "";
32961
32966
  const year = getPart("year");
32962
32967
  const month = getPart("month");
@@ -37010,7 +37015,7 @@ const TextField = forwardRef(({
37010
37015
  });
37011
37016
  TextField.displayName = "TextField";
37012
37017
  function Tabs(t0) {
37013
- const $ = c(10);
37018
+ const $ = c(26);
37014
37019
  const {
37015
37020
  value,
37016
37021
  onValueChange,
@@ -37018,35 +37023,149 @@ function Tabs(t0) {
37018
37023
  innerClassName,
37019
37024
  children
37020
37025
  } = t0;
37026
+ const scrollContainerRef = useRef(null);
37027
+ const [showLeftScroll, setShowLeftScroll] = useState(false);
37028
+ const [showRightScroll, setShowRightScroll] = useState(false);
37029
+ const [isScrollable, setIsScrollable] = useState(false);
37021
37030
  let t1;
37022
- if ($[0] !== innerClassName) {
37023
- t1 = cls("border", defaultBorderMixin, "gap-2", "inline-flex h-10 items-center justify-center rounded-md bg-surface-50 p-1 text-surface-600 dark:bg-surface-900 dark:text-surface-400", innerClassName);
37024
- $[0] = innerClassName;
37025
- $[1] = t1;
37031
+ if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
37032
+ t1 = () => {
37033
+ if (scrollContainerRef.current) {
37034
+ const {
37035
+ scrollLeft,
37036
+ scrollWidth,
37037
+ clientWidth
37038
+ } = scrollContainerRef.current;
37039
+ setShowLeftScroll(scrollLeft > 0);
37040
+ setShowRightScroll(Math.ceil(scrollLeft + clientWidth) < scrollWidth);
37041
+ setIsScrollable(scrollWidth > clientWidth);
37042
+ }
37043
+ };
37044
+ $[0] = t1;
37026
37045
  } else {
37027
- t1 = $[1];
37046
+ t1 = $[0];
37028
37047
  }
37048
+ const checkScroll = t1;
37029
37049
  let t2;
37030
- if ($[2] !== children || $[3] !== t1) {
37031
- t2 = /* @__PURE__ */ jsx(TabsPrimitive.List, { className: t1, children });
37032
- $[2] = children;
37033
- $[3] = t1;
37034
- $[4] = t2;
37050
+ if ($[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
37051
+ t2 = () => {
37052
+ checkScroll();
37053
+ window.addEventListener("resize", checkScroll);
37054
+ let observer;
37055
+ if (scrollContainerRef.current) {
37056
+ observer = new ResizeObserver(checkScroll);
37057
+ observer.observe(scrollContainerRef.current);
37058
+ if (scrollContainerRef.current.firstElementChild) {
37059
+ observer.observe(scrollContainerRef.current.firstElementChild);
37060
+ }
37061
+ }
37062
+ return () => {
37063
+ window.removeEventListener("resize", checkScroll);
37064
+ observer?.disconnect();
37065
+ };
37066
+ };
37067
+ $[1] = t2;
37035
37068
  } else {
37036
- t2 = $[4];
37069
+ t2 = $[1];
37037
37070
  }
37038
37071
  let t3;
37039
- if ($[5] !== className || $[6] !== onValueChange || $[7] !== t2 || $[8] !== value) {
37040
- t3 = /* @__PURE__ */ jsx(TabsPrimitive.Root, { value, onValueChange, className, children: t2 });
37072
+ if ($[2] !== children) {
37073
+ t3 = [children];
37074
+ $[2] = children;
37075
+ $[3] = t3;
37076
+ } else {
37077
+ t3 = $[3];
37078
+ }
37079
+ useEffect(t2, t3);
37080
+ let t4;
37081
+ if ($[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
37082
+ t4 = (direction) => {
37083
+ if (scrollContainerRef.current) {
37084
+ const container = scrollContainerRef.current;
37085
+ const scrollAmount = Math.max(container.clientWidth / 2, 200);
37086
+ const targetScroll = container.scrollLeft + (direction === "left" ? -scrollAmount : scrollAmount);
37087
+ container.scrollTo({
37088
+ left: targetScroll,
37089
+ behavior: "smooth"
37090
+ });
37091
+ }
37092
+ };
37093
+ $[4] = t4;
37094
+ } else {
37095
+ t4 = $[4];
37096
+ }
37097
+ const scroll = t4;
37098
+ let t5;
37099
+ if ($[5] !== className) {
37100
+ t5 = cls("flex flex-row items-center min-w-0", className);
37041
37101
  $[5] = className;
37042
- $[6] = onValueChange;
37043
- $[7] = t2;
37044
- $[8] = value;
37045
- $[9] = t3;
37102
+ $[6] = t5;
37046
37103
  } else {
37047
- t3 = $[9];
37104
+ t5 = $[6];
37048
37105
  }
37049
- return t3;
37106
+ let t6;
37107
+ if ($[7] !== isScrollable || $[8] !== showLeftScroll) {
37108
+ t6 = isScrollable && /* @__PURE__ */ jsx("button", { type: "button", disabled: !showLeftScroll, onClick: () => scroll("left"), className: cls("flex-shrink-0 z-10 flex items-center justify-center rounded-md px-0.5 py-1.5 transition-all h-10 w-6", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-surface-400", "disabled:pointer-events-none disabled:opacity-0", "text-surface-600 dark:text-surface-400 hover:bg-surface-200 dark:hover:bg-surface-800", "mr-1 bg-surface-50 dark:bg-surface-900 border", defaultBorderMixin), children: /* @__PURE__ */ jsx(ChevronLeftIcon, { size: "small" }) });
37109
+ $[7] = isScrollable;
37110
+ $[8] = showLeftScroll;
37111
+ $[9] = t6;
37112
+ } else {
37113
+ t6 = $[9];
37114
+ }
37115
+ let t7;
37116
+ if ($[10] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
37117
+ t7 = {
37118
+ scrollbarWidth: "none",
37119
+ msOverflowStyle: "none"
37120
+ };
37121
+ $[10] = t7;
37122
+ } else {
37123
+ t7 = $[10];
37124
+ }
37125
+ let t8;
37126
+ if ($[11] !== innerClassName) {
37127
+ t8 = cls("border", defaultBorderMixin, "gap-2", "inline-flex h-10 items-center justify-center rounded-md bg-surface-50 p-1 text-surface-600 dark:bg-surface-900 dark:text-surface-400", innerClassName);
37128
+ $[11] = innerClassName;
37129
+ $[12] = t8;
37130
+ } else {
37131
+ t8 = $[12];
37132
+ }
37133
+ let t9;
37134
+ if ($[13] !== children || $[14] !== t8) {
37135
+ t9 = /* @__PURE__ */ jsx("div", { ref: scrollContainerRef, className: "flex-1 overflow-x-auto no-scrollbar min-w-0", onScroll: checkScroll, style: t7, children: /* @__PURE__ */ jsx(TabsPrimitive.List, { className: t8, children }) });
37136
+ $[13] = children;
37137
+ $[14] = t8;
37138
+ $[15] = t9;
37139
+ } else {
37140
+ t9 = $[15];
37141
+ }
37142
+ let t10;
37143
+ if ($[16] !== isScrollable || $[17] !== showRightScroll) {
37144
+ t10 = isScrollable && /* @__PURE__ */ jsx("button", { type: "button", disabled: !showRightScroll, onClick: () => scroll("right"), className: cls("flex-shrink-0 z-10 flex items-center justify-center rounded-md px-0.5 py-1.5 transition-all h-10 w-6", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-surface-400", "disabled:pointer-events-none disabled:opacity-0", "text-surface-600 dark:text-surface-400 hover:bg-surface-200 dark:hover:bg-surface-800", "ml-1 bg-surface-50 dark:bg-surface-900 border", defaultBorderMixin), children: /* @__PURE__ */ jsx(ChevronRightIcon, { size: "small" }) });
37145
+ $[16] = isScrollable;
37146
+ $[17] = showRightScroll;
37147
+ $[18] = t10;
37148
+ } else {
37149
+ t10 = $[18];
37150
+ }
37151
+ let t11;
37152
+ if ($[19] !== onValueChange || $[20] !== t10 || $[21] !== t5 || $[22] !== t6 || $[23] !== t9 || $[24] !== value) {
37153
+ t11 = /* @__PURE__ */ jsxs(TabsPrimitive.Root, { value, onValueChange, className: t5, children: [
37154
+ t6,
37155
+ t9,
37156
+ t10
37157
+ ] });
37158
+ $[19] = onValueChange;
37159
+ $[20] = t10;
37160
+ $[21] = t5;
37161
+ $[22] = t6;
37162
+ $[23] = t9;
37163
+ $[24] = value;
37164
+ $[25] = t11;
37165
+ } else {
37166
+ t11 = $[25];
37167
+ }
37168
+ return t11;
37050
37169
  }
37051
37170
  function Tab(t0) {
37052
37171
  const $ = c(8);