@univerjs/design 1.0.0-alpha.8 → 1.0.0-beta.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.
package/lib/cjs/index.js CHANGED
@@ -26,10 +26,9 @@ function clsx$1(...inputs) {
26
26
  //#endregion
27
27
  //#region src/components/accordion/Accordion.tsx
28
28
  function Accordion(props) {
29
- var _props$openIndex;
30
29
  const { className, defaultOpenIndex = null, items, onOpenIndexChange } = props;
31
30
  const [innerOpenIndex, setInnerOpenIndex] = (0, react.useState)(defaultOpenIndex);
32
- const openIndex = (_props$openIndex = props.openIndex) !== null && _props$openIndex !== void 0 ? _props$openIndex : innerOpenIndex;
31
+ const openIndex = props.openIndex ?? innerOpenIndex;
33
32
  const toggleItem = (index) => {
34
33
  const nextOpenIndex = openIndex === index ? null : index;
35
34
  if (props.openIndex === void 0) setInnerOpenIndex(nextOpenIndex);
@@ -38,30 +37,27 @@ function Accordion(props) {
38
37
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
39
38
  "data-u-comp": "accordion",
40
39
  className: clsx$1("univer-divide-x-0 univer-divide-y univer-divide-solid univer-divide-gray-200 dark:!univer-divide-gray-600", className),
41
- children: items.map((item, index) => {
42
- var _item$id;
43
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
44
- className: "univer-box-border univer-flex univer-w-full univer-cursor-pointer univer-items-center univer-gap-1.5 univer-border-none univer-bg-transparent univer-p-4 univer-text-left univer-text-gray-700 hover:univer-text-gray-900 focus:univer-outline-none dark:!univer-text-gray-200 dark:hover:!univer-text-white",
45
- type: "button",
46
- onClick: () => toggleItem(index),
47
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DownIcon, { className: clsx$1("univer-size-2.5 univer-flex-shrink-0 univer-transition-transform", {
48
- "-univer-rotate-90": openIndex !== index,
49
- "univer-rotate-0": openIndex === index
50
- }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
51
- className: "univer-font-medium",
52
- children: item.label
53
- })]
54
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
55
- className: clsx$1("univer-overflow-hidden univer-transition-[max-height,opacity] univer-duration-500 univer-ease-in-out", {
56
- "univer-max-h-screen": openIndex === index,
57
- "univer-max-h-0": openIndex !== index
58
- }),
59
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
60
- className: "univer-box-border univer-px-4 univer-py-1.5",
61
- children: item.children
62
- })
63
- })] }, (_item$id = item.id) !== null && _item$id !== void 0 ? _item$id : index);
64
- })
40
+ children: items.map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
41
+ className: "univer-box-border univer-flex univer-w-full univer-cursor-pointer univer-items-center univer-gap-1.5 univer-border-none univer-bg-transparent univer-p-4 univer-text-left univer-text-gray-700 hover:univer-text-gray-900 focus:univer-outline-none dark:!univer-text-gray-200 dark:hover:!univer-text-white",
42
+ type: "button",
43
+ onClick: () => toggleItem(index),
44
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DownIcon, { className: clsx$1("univer-size-2.5 univer-flex-shrink-0 univer-transition-transform", {
45
+ "-univer-rotate-90": openIndex !== index,
46
+ "univer-rotate-0": openIndex === index
47
+ }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
48
+ className: "univer-font-medium",
49
+ children: item.label
50
+ })]
51
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
52
+ className: clsx$1("univer-overflow-hidden univer-transition-[max-height,opacity] univer-duration-500 univer-ease-in-out", {
53
+ "univer-max-h-screen": openIndex === index,
54
+ "univer-max-h-0": openIndex !== index
55
+ }),
56
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
57
+ className: "univer-box-border univer-px-4 univer-py-1.5",
58
+ children: item.children
59
+ })
60
+ })] }, item.id ?? index))
65
61
  });
66
62
  }
67
63
 
@@ -159,7 +155,7 @@ function ConfigProvider(props) {
159
155
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConfigContext.Provider, {
160
156
  value,
161
157
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_direction.DirectionProvider, {
162
- dir: direction !== null && direction !== void 0 ? direction : "ltr",
158
+ dir: direction ?? "ltr",
163
159
  children
164
160
  })
165
161
  });
@@ -540,7 +536,7 @@ function pad(value, length = 2) {
540
536
  return String(value).padStart(length, "0");
541
537
  }
542
538
  function formatDateWithPattern(value, pattern) {
543
- const date = value !== null && value !== void 0 ? value : /* @__PURE__ */ new Date();
539
+ const date = value ?? /* @__PURE__ */ new Date();
544
540
  if (Number.isNaN(date.getTime())) return "Invalid Date";
545
541
  const tokenMap = {
546
542
  YYYY: String(date.getFullYear()),
@@ -550,10 +546,7 @@ function formatDateWithPattern(value, pattern) {
550
546
  mm: pad(date.getMinutes()),
551
547
  ss: pad(date.getSeconds())
552
548
  };
553
- return pattern.replace(/YYYY|MM|DD|HH|mm|ss/g, (token) => {
554
- var _tokenMap$token;
555
- return (_tokenMap$token = tokenMap[token]) !== null && _tokenMap$token !== void 0 ? _tokenMap$token : token;
556
- });
549
+ return pattern.replace(/YYYY|MM|DD|HH|mm|ss/g, (token) => tokenMap[token] ?? token);
557
550
  }
558
551
 
559
552
  //#endregion
@@ -562,7 +555,7 @@ function TimeInput(props) {
562
555
  const { className, value, onValueChange } = props;
563
556
  function handleChangeTime(event) {
564
557
  const [hours, minutes, seconds] = event.target.value.split(":").map(Number);
565
- const newValue = new Date(value !== null && value !== void 0 ? value : Date.now());
558
+ const newValue = new Date(value ?? Date.now());
566
559
  newValue.setHours(hours, minutes, seconds, 0);
567
560
  onValueChange === null || onValueChange === void 0 || onValueChange(newValue);
568
561
  }
@@ -660,8 +653,8 @@ function Calendar(props) {
660
653
  const { direction = "ltr", locale } = (0, react.useContext)(ConfigContext);
661
654
  const { ariaLabels, year, weekDays, months } = locale === null || locale === void 0 ? void 0 : locale.Calendar;
662
655
  const today = /* @__PURE__ */ new Date();
663
- const [currentYear, setCurrentYear] = (0, react.useState)((value !== null && value !== void 0 ? value : today).getFullYear());
664
- const [currentMonth, setCurrentMonth] = (0, react.useState)((value !== null && value !== void 0 ? value : today).getMonth());
656
+ const [currentYear, setCurrentYear] = (0, react.useState)((value ?? today).getFullYear());
657
+ const [currentMonth, setCurrentMonth] = (0, react.useState)((value ?? today).getMonth());
665
658
  const [yearDropdownOpen, setYearDropdownOpen] = (0, react.useState)(false);
666
659
  function prevMonth() {
667
660
  setCurrentMonth((prev) => {
@@ -689,9 +682,8 @@ function Calendar(props) {
689
682
  setYearDropdownOpen(false);
690
683
  }
691
684
  const yearOptions = (0, react.useMemo)(() => {
692
- var _min$getFullYear, _max$getFullYear;
693
- const startYear = (_min$getFullYear = min === null || min === void 0 ? void 0 : min.getFullYear()) !== null && _min$getFullYear !== void 0 ? _min$getFullYear : currentYear - DEFAULT_YEAR_RANGE;
694
- const endYear = (_max$getFullYear = max === null || max === void 0 ? void 0 : max.getFullYear()) !== null && _max$getFullYear !== void 0 ? _max$getFullYear : currentYear + DEFAULT_YEAR_RANGE;
685
+ const startYear = (min === null || min === void 0 ? void 0 : min.getFullYear()) ?? currentYear - DEFAULT_YEAR_RANGE;
686
+ const endYear = (max === null || max === void 0 ? void 0 : max.getFullYear()) ?? currentYear + DEFAULT_YEAR_RANGE;
695
687
  return Array.from({ length: Math.max(0, endYear - startYear + 1) }, (_, index) => ({ year: startYear + index }));
696
688
  }, [
697
689
  currentYear,
@@ -724,31 +716,28 @@ function Calendar(props) {
724
716
  return day && currentYear === today.getFullYear() && currentMonth === today.getMonth() && day === today.getDate();
725
717
  }
726
718
  function isDisabled(day) {
727
- var _value$getHours, _value$getMinutes, _value$getSeconds;
728
719
  if (!day) return false;
729
- const hours = (_value$getHours = value === null || value === void 0 ? void 0 : value.getHours()) !== null && _value$getHours !== void 0 ? _value$getHours : today.getHours();
730
- const minutes = (_value$getMinutes = value === null || value === void 0 ? void 0 : value.getMinutes()) !== null && _value$getMinutes !== void 0 ? _value$getMinutes : today.getMinutes();
731
- const seconds = (_value$getSeconds = value === null || value === void 0 ? void 0 : value.getSeconds()) !== null && _value$getSeconds !== void 0 ? _value$getSeconds : today.getSeconds();
720
+ const hours = (value === null || value === void 0 ? void 0 : value.getHours()) ?? today.getHours();
721
+ const minutes = (value === null || value === void 0 ? void 0 : value.getMinutes()) ?? today.getMinutes();
722
+ const seconds = (value === null || value === void 0 ? void 0 : value.getSeconds()) ?? today.getSeconds();
732
723
  const d = new Date(currentYear, currentMonth, day, hours, minutes, seconds);
733
724
  if (min && d < min) return true;
734
725
  if (max && d > max) return true;
735
726
  return false;
736
727
  }
737
728
  function handleChangeDate(day) {
738
- var _value$getHours2, _value$getMinutes2, _value$getSeconds2;
739
729
  if (isDisabled(day)) return;
740
- const hours = (_value$getHours2 = value === null || value === void 0 ? void 0 : value.getHours()) !== null && _value$getHours2 !== void 0 ? _value$getHours2 : today.getHours();
741
- const minutes = (_value$getMinutes2 = value === null || value === void 0 ? void 0 : value.getMinutes()) !== null && _value$getMinutes2 !== void 0 ? _value$getMinutes2 : today.getMinutes();
742
- const seconds = (_value$getSeconds2 = value === null || value === void 0 ? void 0 : value.getSeconds()) !== null && _value$getSeconds2 !== void 0 ? _value$getSeconds2 : today.getSeconds();
730
+ const hours = (value === null || value === void 0 ? void 0 : value.getHours()) ?? today.getHours();
731
+ const minutes = (value === null || value === void 0 ? void 0 : value.getMinutes()) ?? today.getMinutes();
732
+ const seconds = (value === null || value === void 0 ? void 0 : value.getSeconds()) ?? today.getSeconds();
743
733
  const selectedDate = new Date(currentYear, currentMonth, day, hours, minutes, seconds);
744
734
  onValueChange === null || onValueChange === void 0 || onValueChange(selectedDate);
745
735
  }
746
736
  function handleChangeTime(time) {
747
- var _value$getDate;
748
737
  const hours = time.getHours();
749
738
  const minutes = time.getMinutes();
750
739
  const seconds = time.getSeconds();
751
- const updatedDate = new Date(currentYear, currentMonth, (_value$getDate = value === null || value === void 0 ? void 0 : value.getDate()) !== null && _value$getDate !== void 0 ? _value$getDate : today.getDate(), hours, minutes, seconds);
740
+ const updatedDate = new Date(currentYear, currentMonth, (value === null || value === void 0 ? void 0 : value.getDate()) ?? today.getDate(), hours, minutes, seconds);
752
741
  onValueChange === null || onValueChange === void 0 || onValueChange(updatedDate);
753
742
  }
754
743
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -926,7 +915,7 @@ function CheckboxGroup(props) {
926
915
  key: index,
927
916
  children: child.props.children,
928
917
  checked: child.props.value ? value.includes(child.props.value) : false,
929
- disabled: disabled !== null && disabled !== void 0 ? disabled : child.props.disabled,
918
+ disabled: disabled ?? child.props.disabled,
930
919
  onChange: handleChange
931
920
  });
932
921
  return child;
@@ -947,8 +936,8 @@ function Checkbox(props) {
947
936
  if (!onChange || disabled) return;
948
937
  if (typeof value !== "undefined") onChange === null || onChange === void 0 || onChange(value);
949
938
  else {
950
- var _inputRef$current$che, _inputRef$current;
951
- const checked = (_inputRef$current$che = inputRef === null || inputRef === void 0 || (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.checked) !== null && _inputRef$current$che !== void 0 ? _inputRef$current$che : false;
939
+ var _inputRef$current;
940
+ const checked = (inputRef === null || inputRef === void 0 || (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.checked) ?? false;
952
941
  onChange === null || onChange === void 0 || onChange(checked);
953
942
  }
954
943
  }
@@ -994,7 +983,7 @@ const DialogOverlay = (0, react.forwardRef)(({ className, ...props }, ref) => /*
994
983
  }));
995
984
  DialogOverlay.displayName = _radix_ui_react_dialog.Overlay.displayName;
996
985
  const DialogContent = (0, react.forwardRef)(({ className, children, closable = true, onClickClose, mountContainer, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DialogPortal, {
997
- container: mountContainer !== null && mountContainer !== void 0 ? mountContainer : void 0,
986
+ container: mountContainer ?? void 0,
998
987
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(DialogOverlay, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_radix_ui_react_dialog.Content, {
999
988
  ref,
1000
989
  className: clsx$1("data-[state=open]:univer-animate-in data-[state=open]:univer-fade-in-0 data-[state=open]:univer-zoom-in-95 data-[state=open]:univer-slide-in-from-left-1/2 data-[state=open]:univer-slide-in-from-top-[48%] data-[state=closed]:univer-animate-out data-[state=closed]:univer-fade-out-0 data-[state=closed]:univer-zoom-out-95 data-[state=closed]:univer-slide-out-to-left-1/2 data-[state=closed]:univer-slide-out-to-top-[48%] univer-fixed univer-left-1/2 univer-top-1/2 univer-z-[1080] univer-box-border univer-grid univer-w-full univer-max-w-lg -univer-translate-x-1/2 -univer-translate-y-1/2 univer-gap-4 univer-bg-white univer-p-4 univer-text-gray-500 univer-shadow-md univer-duration-200 sm:!univer-rounded-lg dark:!univer-bg-gray-700 dark:!univer-text-gray-400", borderClassName, className),
@@ -1161,7 +1150,7 @@ function Dialog(props) {
1161
1150
  defaultPosition,
1162
1151
  enabled: draggable
1163
1152
  });
1164
- const footer = propFooter !== null && propFooter !== void 0 ? propFooter : showOk || showCancel ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1153
+ const footer = propFooter ?? (showOk || showCancel ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1165
1154
  className: "univer-flex univer-justify-end univer-gap-2",
1166
1155
  children: [showCancel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
1167
1156
  onClick: onCancel,
@@ -1171,7 +1160,7 @@ function Dialog(props) {
1171
1160
  onClick: onOk,
1172
1161
  children: locale === null || locale === void 0 ? void 0 : locale.Confirm.confirm
1173
1162
  })]
1174
- }) : null;
1163
+ }) : null);
1175
1164
  const handleContentRef = (0, react.useCallback)((node) => {
1176
1165
  if (node && draggable) setElementRef(node);
1177
1166
  }, [draggable, setElementRef]);
@@ -1367,10 +1356,10 @@ function AlphaSlider({ hsv, alpha, onChange, onChanged }) {
1367
1356
  const thumbRef = (0, react.useRef)(null);
1368
1357
  const alphaRef = (0, react.useRef)(alpha);
1369
1358
  const calculateAlpha = (0, react.useCallback)((clientX) => {
1370
- var _thumbRef$current$cli, _thumbRef$current;
1359
+ var _thumbRef$current;
1371
1360
  const slider = sliderRef.current;
1372
1361
  if (!slider) return;
1373
- const thumbSize = (_thumbRef$current$cli = (_thumbRef$current = thumbRef.current) === null || _thumbRef$current === void 0 ? void 0 : _thumbRef$current.clientWidth) !== null && _thumbRef$current$cli !== void 0 ? _thumbRef$current$cli : 0;
1362
+ const thumbSize = ((_thumbRef$current = thumbRef.current) === null || _thumbRef$current === void 0 ? void 0 : _thumbRef$current.clientWidth) ?? 0;
1374
1363
  const rect = slider.getBoundingClientRect();
1375
1364
  const maxX = rect.width - thumbSize;
1376
1365
  if (maxX <= 0) {
@@ -1408,10 +1397,10 @@ function AlphaSlider({ hsv, alpha, onChange, onChanged }) {
1408
1397
  handlePointerUp
1409
1398
  ]);
1410
1399
  const getThumbPosition = () => {
1411
- var _thumbRef$current$cli2, _thumbRef$current2, _sliderRef$current$cl, _sliderRef$current;
1400
+ var _thumbRef$current2, _sliderRef$current;
1412
1401
  const safeAlpha = Math.min(Math.max(alpha * 100, 0), 100);
1413
- const thumbSize = (_thumbRef$current$cli2 = (_thumbRef$current2 = thumbRef.current) === null || _thumbRef$current2 === void 0 ? void 0 : _thumbRef$current2.clientWidth) !== null && _thumbRef$current$cli2 !== void 0 ? _thumbRef$current$cli2 : 0;
1414
- const sliderWidth = (_sliderRef$current$cl = (_sliderRef$current = sliderRef.current) === null || _sliderRef$current === void 0 ? void 0 : _sliderRef$current.clientWidth) !== null && _sliderRef$current$cl !== void 0 ? _sliderRef$current$cl : 0;
1402
+ const thumbSize = ((_thumbRef$current2 = thumbRef.current) === null || _thumbRef$current2 === void 0 ? void 0 : _thumbRef$current2.clientWidth) ?? 0;
1403
+ const sliderWidth = ((_sliderRef$current = sliderRef.current) === null || _sliderRef$current === void 0 ? void 0 : _sliderRef$current.clientWidth) ?? 0;
1415
1404
  const thumbOffsetPercent = sliderWidth > 0 ? thumbSize / sliderWidth * 100 : 0;
1416
1405
  return `${safeAlpha / 100 * (100 - thumbOffsetPercent)}%`;
1417
1406
  };
@@ -1498,7 +1487,7 @@ function RgbInput({ hsv, alpha, format, onChange }) {
1498
1487
  r: Math.round(r),
1499
1488
  g: Math.round(g),
1500
1489
  b: Math.round(b),
1501
- a: alpha !== null && alpha !== void 0 ? alpha : 1
1490
+ a: alpha ?? 1
1502
1491
  });
1503
1492
  }, [hsv, alpha]);
1504
1493
  const handleChange = (color, value) => {
@@ -1530,7 +1519,7 @@ function RgbInput({ hsv, alpha, format, onChange }) {
1530
1519
  r: Math.round(r),
1531
1520
  g: Math.round(g),
1532
1521
  b: Math.round(b),
1533
- a: alpha !== null && alpha !== void 0 ? alpha : 1
1522
+ a: alpha ?? 1
1534
1523
  });
1535
1524
  };
1536
1525
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -1749,10 +1738,10 @@ function ColorSpectrum({ hsv, onChange, onChanged }) {
1749
1738
  };
1750
1739
  }, [hsv]);
1751
1740
  const getIndicatorStyles = () => {
1752
- var _containerRef$current3, _containerRef$current4, _containerRef$current5, _containerRef$current6;
1741
+ var _containerRef$current3, _containerRef$current4;
1753
1742
  const halfIndicatorSize = 16 / 2;
1754
- const w = (_containerRef$current3 = (_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.clientWidth) !== null && _containerRef$current3 !== void 0 ? _containerRef$current3 : 0;
1755
- const h = (_containerRef$current5 = (_containerRef$current6 = containerRef.current) === null || _containerRef$current6 === void 0 ? void 0 : _containerRef$current6.clientHeight) !== null && _containerRef$current5 !== void 0 ? _containerRef$current5 : 0;
1743
+ const w = ((_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.clientWidth) ?? 0;
1744
+ const h = ((_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.clientHeight) ?? 0;
1756
1745
  return {
1757
1746
  transform: `translate(${hsv[1] / 100 * w - halfIndicatorSize}px, ${(100 - hsv[2]) / 100 * h - halfIndicatorSize}px)`,
1758
1747
  transition: isDragging ? "none" : "transform 0.1s ease-out"
@@ -1812,10 +1801,10 @@ function HueSlider({ hsv, onChange, onChanged }) {
1812
1801
  const thumbRef = (0, react.useRef)(null);
1813
1802
  const hsvRef = (0, react.useRef)(hsv);
1814
1803
  const calculateHue = (0, react.useCallback)((clientX) => {
1815
- var _thumbRef$current$cli, _thumbRef$current;
1804
+ var _thumbRef$current;
1816
1805
  const slider = sliderRef.current;
1817
1806
  if (!slider) return;
1818
- const thumbSize = (_thumbRef$current$cli = (_thumbRef$current = thumbRef.current) === null || _thumbRef$current === void 0 ? void 0 : _thumbRef$current.clientWidth) !== null && _thumbRef$current$cli !== void 0 ? _thumbRef$current$cli : 0;
1807
+ const thumbSize = ((_thumbRef$current = thumbRef.current) === null || _thumbRef$current === void 0 ? void 0 : _thumbRef$current.clientWidth) ?? 0;
1819
1808
  const rect = slider.getBoundingClientRect();
1820
1809
  const maxX = rect.width - thumbSize;
1821
1810
  if (maxX <= 0) {
@@ -1855,10 +1844,10 @@ function HueSlider({ hsv, onChange, onChanged }) {
1855
1844
  handlePointerUp
1856
1845
  ]);
1857
1846
  const getThumbPosition = () => {
1858
- var _thumbRef$current$cli2, _thumbRef$current2, _sliderRef$current$cl, _sliderRef$current;
1847
+ var _thumbRef$current2, _sliderRef$current;
1859
1848
  const safeHue = Math.min(Math.max(hsv[0], 0), 360);
1860
- const thumbSize = (_thumbRef$current$cli2 = (_thumbRef$current2 = thumbRef.current) === null || _thumbRef$current2 === void 0 ? void 0 : _thumbRef$current2.clientWidth) !== null && _thumbRef$current$cli2 !== void 0 ? _thumbRef$current$cli2 : 0;
1861
- const sliderWidth = (_sliderRef$current$cl = (_sliderRef$current = sliderRef.current) === null || _sliderRef$current === void 0 ? void 0 : _sliderRef$current.clientWidth) !== null && _sliderRef$current$cl !== void 0 ? _sliderRef$current$cl : 0;
1849
+ const thumbSize = ((_thumbRef$current2 = thumbRef.current) === null || _thumbRef$current2 === void 0 ? void 0 : _thumbRef$current2.clientWidth) ?? 0;
1850
+ const sliderWidth = ((_sliderRef$current = sliderRef.current) === null || _sliderRef$current === void 0 ? void 0 : _sliderRef$current.clientWidth) ?? 0;
1862
1851
  const thumbOffsetPercent = sliderWidth > 0 ? thumbSize / sliderWidth * 100 : 0;
1863
1852
  return `${safeHue / 360 * (100 - thumbOffsetPercent)}%`;
1864
1853
  };
@@ -2135,11 +2124,11 @@ function Footer(props) {
2135
2124
  className: "univer-flex univer-items-center univer-justify-end univer-gap-2",
2136
2125
  children: [closable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
2137
2126
  onClick: onClose,
2138
- children: cancelText !== null && cancelText !== void 0 ? cancelText : locale === null || locale === void 0 ? void 0 : locale.Confirm.cancel
2127
+ children: cancelText ?? (locale === null || locale === void 0 ? void 0 : locale.Confirm.cancel)
2139
2128
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
2140
2129
  variant: "primary",
2141
2130
  onClick: onConfirm,
2142
- children: confirmText !== null && confirmText !== void 0 ? confirmText : locale === null || locale === void 0 ? void 0 : locale.Confirm.confirm
2131
+ children: confirmText ?? (locale === null || locale === void 0 ? void 0 : locale.Confirm.confirm)
2143
2132
  })]
2144
2133
  });
2145
2134
  }
@@ -2508,7 +2497,7 @@ const FormDualColumnLayout = (props) => {
2508
2497
  */
2509
2498
  function Pager(props) {
2510
2499
  const { className, value: current = 0, total: count = 0, loop, text: propText, onChange } = props;
2511
- const text = propText !== null && propText !== void 0 ? propText : `${current}/${count}`;
2500
+ const text = propText ?? `${current}/${count}`;
2512
2501
  const hasValue = count > 0;
2513
2502
  const onClickLeftArrow = () => {
2514
2503
  if (current === 1) {
@@ -2654,7 +2643,7 @@ function Gallery(props) {
2654
2643
  })
2655
2644
  }),
2656
2645
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("footer", {
2657
- className: "univer-absolute univer-bottom-6 univer-left-1/2 univer-flex -univer-translate-x-1/2 univer-items-center univer-gap-3 univer-rounded-full univer-bg-gray-800 univer-px-6 univer-py-3 univer-text-gray-400",
2646
+ className: "univer-absolute univer-bottom-6 univer-left-1/2 univer-flex -univer-translate-x-1/2 univer-items-center univer-gap-3 univer-rounded-full univer-bg-gray-800 univer-px-6 univer-py-3 univer-text-gray-400 rtl:univer-flex-row-reverse",
2658
2647
  children: [
2659
2648
  hasPagination && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Pager, {
2660
2649
  className: "!univer-text-gray-400 [&_[data-u-comp=pager-left-arrow]:hover]:!univer-bg-gray-600 [&_[data-u-comp=pager-right-arrow]:hover]:!univer-bg-gray-600",
@@ -3171,50 +3160,47 @@ function Tooltip(props) {
3171
3160
  children
3172
3161
  });
3173
3162
  let tooltipNode = null;
3174
- if (typeof document !== "undefined" && visible && title && document.body) {
3175
- var _coords$top, _coords$left;
3176
- tooltipNode = (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3177
- ref: tooltipRef,
3178
- dir: direction,
3179
- role: "tooltip",
3180
- className: clsx$1("univer-animate-in univer-fade-in-0 univer-zoom-in-95 univer-pointer-events-auto univer-absolute univer-z-[1081] univer-box-border univer-w-fit univer-max-w-sm univer-text-balance univer-rounded-lg univer-bg-gray-700 univer-px-2.5 univer-py-2 univer-text-xs univer-font-medium univer-text-white univer-shadow-lg univer-drop-shadow-sm dark:!univer-bg-gray-100 dark:!univer-text-gray-900", className),
3163
+ if (typeof document !== "undefined" && visible && title && document.body) tooltipNode = (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3164
+ ref: tooltipRef,
3165
+ dir: direction,
3166
+ role: "tooltip",
3167
+ className: clsx$1("univer-animate-in univer-fade-in-0 univer-zoom-in-95 univer-pointer-events-auto univer-absolute univer-z-[1081] univer-box-border univer-w-fit univer-max-w-sm univer-text-balance univer-rounded-lg univer-bg-gray-700 univer-px-2.5 univer-py-2 univer-text-xs univer-font-medium univer-text-white univer-shadow-lg univer-drop-shadow-sm dark:!univer-bg-gray-100 dark:!univer-text-gray-900", className),
3168
+ style: {
3169
+ top: (coords === null || coords === void 0 ? void 0 : coords.top) ?? -9999,
3170
+ left: (coords === null || coords === void 0 ? void 0 : coords.left) ?? -9999
3171
+ },
3172
+ onMouseEnter: () => showTooltip(),
3173
+ onMouseLeave: () => hideTooltip(),
3174
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3175
+ className: "univer-break-words",
3176
+ children: title
3177
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3178
+ ref: arrowRef,
3179
+ className: "univer-absolute univer-size-2.5 univer-rotate-45 univer-rounded-sm univer-bg-gray-700 dark:!univer-bg-gray-100",
3181
3180
  style: {
3182
- top: (_coords$top = coords === null || coords === void 0 ? void 0 : coords.top) !== null && _coords$top !== void 0 ? _coords$top : -9999,
3183
- left: (_coords$left = coords === null || coords === void 0 ? void 0 : coords.left) !== null && _coords$left !== void 0 ? _coords$left : -9999
3184
- },
3185
- onMouseEnter: () => showTooltip(),
3186
- onMouseLeave: () => hideTooltip(),
3187
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3188
- className: "univer-break-words",
3189
- children: title
3190
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3191
- ref: arrowRef,
3192
- className: "univer-absolute univer-size-2.5 univer-rotate-45 univer-rounded-sm univer-bg-gray-700 dark:!univer-bg-gray-100",
3193
- style: {
3194
- ...currentPlacement === "bottom" && {
3195
- top: -5,
3196
- left: "50%",
3197
- transform: "translateX(-50%) rotate(45deg)"
3198
- },
3199
- ...currentPlacement === "top" && {
3200
- bottom: -5,
3201
- left: "50%",
3202
- transform: "translateX(-50%) rotate(45deg)"
3203
- },
3204
- ...currentPlacement === "left" && {
3205
- right: -5,
3206
- top: "50%",
3207
- transform: "translateY(-50%) rotate(45deg)"
3208
- },
3209
- ...currentPlacement === "right" && {
3210
- left: -5,
3211
- top: "50%",
3212
- transform: "translateY(-50%) rotate(45deg)"
3213
- }
3181
+ ...currentPlacement === "bottom" && {
3182
+ top: -5,
3183
+ left: "50%",
3184
+ transform: "translateX(-50%) rotate(45deg)"
3185
+ },
3186
+ ...currentPlacement === "top" && {
3187
+ bottom: -5,
3188
+ left: "50%",
3189
+ transform: "translateX(-50%) rotate(45deg)"
3190
+ },
3191
+ ...currentPlacement === "left" && {
3192
+ right: -5,
3193
+ top: "50%",
3194
+ transform: "translateY(-50%) rotate(45deg)"
3195
+ },
3196
+ ...currentPlacement === "right" && {
3197
+ left: -5,
3198
+ top: "50%",
3199
+ transform: "translateY(-50%) rotate(45deg)"
3214
3200
  }
3215
- })]
3216
- }), document.body);
3217
- }
3201
+ }
3202
+ })]
3203
+ }), document.body);
3218
3204
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [triggerElement, tooltipNode] });
3219
3205
  }
3220
3206
 
@@ -3250,8 +3236,7 @@ function clamp(value, min, max) {
3250
3236
  return Math.max(min, Math.min(max, value));
3251
3237
  }
3252
3238
  function getStopOpacity(stop) {
3253
- var _stop$opacity;
3254
- return clamp((_stop$opacity = stop === null || stop === void 0 ? void 0 : stop.opacity) !== null && _stop$opacity !== void 0 ? _stop$opacity : 1, 0, 1);
3239
+ return clamp((stop === null || stop === void 0 ? void 0 : stop.opacity) ?? 1, 0, 1);
3255
3240
  }
3256
3241
  function getColorWithOpacity(color, opacity) {
3257
3242
  if (opacity >= 1) return color;
@@ -3274,8 +3259,7 @@ function getStopColor(stop) {
3274
3259
  return getColorWithOpacity(stop.color, getStopOpacity(stop));
3275
3260
  }
3276
3261
  function getGradientAngle(value) {
3277
- var _ref, _value$angle;
3278
- return (_ref = (_value$angle = value.angle) !== null && _value$angle !== void 0 ? _value$angle : DEFAULT_VALUE.angle) !== null && _ref !== void 0 ? _ref : 0;
3262
+ return value.angle ?? DEFAULT_VALUE.angle ?? 0;
3279
3263
  }
3280
3264
  function getCssLinearGradientAngle(value) {
3281
3265
  return (getGradientAngle(value) + 90) % 360;
@@ -3324,7 +3308,7 @@ function GradientColorPicker(props) {
3324
3308
  const handleAngleChange = (angle) => {
3325
3309
  emitChange({
3326
3310
  ...valueRef.current,
3327
- angle: angle !== null && angle !== void 0 ? angle : 0
3311
+ angle: angle ?? 0
3328
3312
  });
3329
3313
  };
3330
3314
  const handleStopColorChange = (color) => {
@@ -3351,7 +3335,7 @@ function GradientColorPicker(props) {
3351
3335
  });
3352
3336
  };
3353
3337
  const handleStopTransparencyChange = (transparency) => {
3354
- const nextTransparency = clamp(transparency !== null && transparency !== void 0 ? transparency : 0, 0, 100);
3338
+ const nextTransparency = clamp(transparency ?? 0, 0, 100);
3355
3339
  const newStops = [...valueRef.current.stops];
3356
3340
  newStops[selectedIndex] = {
3357
3341
  ...newStops[selectedIndex],
@@ -3733,7 +3717,7 @@ const Messager = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runt
3733
3717
  ...props
3734
3718
  });
3735
3719
  const message = ({ content, duration, id, onClose, type = "info" }) => {
3736
- const messageId = id !== null && id !== void 0 ? id : createMessageId();
3720
+ const messageId = id ?? createMessageId();
3737
3721
  const method = resolveToastMethod(type);
3738
3722
  let closed = false;
3739
3723
  const handleClose = () => {
@@ -3745,7 +3729,7 @@ const message = ({ content, duration, id, onClose, type = "info" }) => {
3745
3729
  method(content, {
3746
3730
  id: messageId,
3747
3731
  toasterId: MESSAGE_TOASTER_ID,
3748
- duration: duration !== null && duration !== void 0 ? duration : DEFAULT_MESSAGE_DURATION,
3732
+ duration: duration ?? DEFAULT_MESSAGE_DURATION,
3749
3733
  icon: type === "loading" ? void 0 : iconMap[type],
3750
3734
  onDismiss: handleClose,
3751
3735
  onAutoClose: handleClose
@@ -3927,7 +3911,7 @@ function RadioGroup(props) {
3927
3911
  children: child.props.children,
3928
3912
  value: child.props.value,
3929
3913
  checked: value === child.props.value,
3930
- disabled: disabled !== null && disabled !== void 0 ? disabled : child.props.disabled,
3914
+ disabled: disabled ?? child.props.disabled,
3931
3915
  onChange: handleChange
3932
3916
  });
3933
3917
  return child;
@@ -4116,7 +4100,11 @@ function MultipleSelect(props) {
4116
4100
  }
4117
4101
  };
4118
4102
  });
4119
- }, [options]);
4103
+ }, [
4104
+ onChange,
4105
+ options,
4106
+ value
4107
+ ]);
4120
4108
  function handleClose(item) {
4121
4109
  const newValue = value.filter((v) => v !== item);
4122
4110
  onChange(newValue);
@@ -4270,7 +4258,7 @@ function Toaster({ visibleToasts, ...props }) {
4270
4258
  error: "[&_[data-icon]]:univer-text-red-500",
4271
4259
  warning: "[&_[data-icon]]:univer-text-yellow-500"
4272
4260
  } },
4273
- visibleToasts: visibleToasts !== null && visibleToasts !== void 0 ? visibleToasts : 5,
4261
+ visibleToasts: visibleToasts ?? 5,
4274
4262
  ...props
4275
4263
  });
4276
4264
  }
@@ -4292,7 +4280,7 @@ const findNodePathFromTree = (tree, key) => {
4292
4280
  return result;
4293
4281
  };
4294
4282
  const createCacheWithFindNodePathFromTree = (tree, defaultCache) => {
4295
- const cache = defaultCache !== null && defaultCache !== void 0 ? defaultCache : /* @__PURE__ */ new Map();
4283
+ const cache = defaultCache ?? /* @__PURE__ */ new Map();
4296
4284
  let cacheTree = tree;
4297
4285
  return {
4298
4286
  findNodePathFromTreeWithCache: (key) => {