@univerjs/design 0.25.1 → 1.0.0-alpha.1

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 (165) hide show
  1. package/lib/cjs/index.js +757 -603
  2. package/lib/cjs/locale/ar-SA.js +9 -2
  3. package/lib/cjs/locale/ca-ES.js +9 -2
  4. package/lib/cjs/locale/de-DE.js +9 -2
  5. package/lib/cjs/locale/en-US.js +9 -2
  6. package/lib/cjs/locale/es-ES.js +9 -2
  7. package/lib/cjs/locale/fa-IR.js +9 -2
  8. package/lib/cjs/locale/fr-FR.js +9 -2
  9. package/lib/cjs/locale/id-ID.js +9 -2
  10. package/lib/cjs/locale/it-IT.js +9 -2
  11. package/lib/cjs/locale/ja-JP.js +9 -2
  12. package/lib/cjs/locale/ko-KR.js +9 -2
  13. package/lib/cjs/locale/pl-PL.js +9 -2
  14. package/lib/cjs/locale/pt-BR.js +9 -2
  15. package/lib/cjs/locale/ru-RU.js +9 -2
  16. package/lib/cjs/locale/sk-SK.js +9 -2
  17. package/lib/cjs/locale/vi-VN.js +9 -2
  18. package/lib/cjs/locale/zh-CN.js +9 -2
  19. package/lib/cjs/locale/zh-HK.js +9 -2
  20. package/lib/cjs/locale/zh-TW.js +9 -2
  21. package/lib/es/index.js +764 -618
  22. package/lib/es/locale/ar-SA.js +9 -2
  23. package/lib/es/locale/ca-ES.js +9 -2
  24. package/lib/es/locale/de-DE.js +9 -2
  25. package/lib/es/locale/en-US.js +9 -2
  26. package/lib/es/locale/es-ES.js +9 -2
  27. package/lib/es/locale/fa-IR.js +9 -2
  28. package/lib/es/locale/fr-FR.js +9 -2
  29. package/lib/es/locale/id-ID.js +9 -2
  30. package/lib/es/locale/it-IT.js +9 -2
  31. package/lib/es/locale/ja-JP.js +9 -2
  32. package/lib/es/locale/ko-KR.js +9 -2
  33. package/lib/es/locale/pl-PL.js +9 -2
  34. package/lib/es/locale/pt-BR.js +9 -2
  35. package/lib/es/locale/ru-RU.js +9 -2
  36. package/lib/es/locale/sk-SK.js +9 -2
  37. package/lib/es/locale/vi-VN.js +9 -2
  38. package/lib/es/locale/zh-CN.js +9 -2
  39. package/lib/es/locale/zh-HK.js +9 -2
  40. package/lib/es/locale/zh-TW.js +9 -2
  41. package/lib/index.css +95 -8
  42. package/lib/index.js +764 -618
  43. package/lib/locale/ar-SA.js +9 -2
  44. package/lib/locale/ca-ES.js +9 -2
  45. package/lib/locale/de-DE.js +9 -2
  46. package/lib/locale/en-US.js +9 -2
  47. package/lib/locale/es-ES.js +9 -2
  48. package/lib/locale/fa-IR.js +9 -2
  49. package/lib/locale/fr-FR.js +9 -2
  50. package/lib/locale/id-ID.js +9 -2
  51. package/lib/locale/it-IT.js +9 -2
  52. package/lib/locale/ja-JP.js +9 -2
  53. package/lib/locale/ko-KR.js +9 -2
  54. package/lib/locale/pl-PL.js +9 -2
  55. package/lib/locale/pt-BR.js +9 -2
  56. package/lib/locale/ru-RU.js +9 -2
  57. package/lib/locale/sk-SK.js +9 -2
  58. package/lib/locale/vi-VN.js +9 -2
  59. package/lib/locale/zh-CN.js +9 -2
  60. package/lib/locale/zh-HK.js +9 -2
  61. package/lib/locale/zh-TW.js +9 -2
  62. package/lib/types/components/accordion/Accordion.d.ts +1 -1
  63. package/lib/types/components/accordion/Accordion.stories.d.ts +1 -1
  64. package/lib/types/components/avatar/Avatar.d.ts +1 -1
  65. package/lib/types/components/avatar/Avatar.stories.d.ts +3 -3
  66. package/lib/types/components/badge/Badge.d.ts +1 -1
  67. package/lib/types/components/badge/Badge.stories.d.ts +1 -1
  68. package/lib/types/components/button/Button.stories.d.ts +3 -3
  69. package/lib/types/components/button/ButtonGroup.d.ts +1 -1
  70. package/lib/types/components/button/ButtonGroup.stories.d.ts +1 -1
  71. package/lib/types/components/calendar/Calendar.d.ts +1 -1
  72. package/lib/types/components/calendar/Calendar.stories.d.ts +1 -1
  73. package/lib/types/components/cascader-list/CascaderList.d.ts +1 -1
  74. package/lib/types/components/cascader-list/CascaderList.stories.d.ts +1 -1
  75. package/lib/types/components/checkbox/Checkbox.d.ts +1 -1
  76. package/lib/types/components/checkbox/Checkbox.stories.d.ts +3 -3
  77. package/lib/types/components/checkbox-group/CheckboxGroup.d.ts +1 -1
  78. package/lib/types/components/checkbox-group/CheckboxGroup.stories.d.ts +2 -2
  79. package/lib/types/components/color-picker/AlphaSlider.d.ts +1 -1
  80. package/lib/types/components/color-picker/ColorInput.d.ts +1 -1
  81. package/lib/types/components/color-picker/ColorPicker.d.ts +1 -1
  82. package/lib/types/components/color-picker/ColorPicker.stories.d.ts +2 -2
  83. package/lib/types/components/color-picker/ColorPresets.d.ts +1 -1
  84. package/lib/types/components/color-picker/ColorSpectrum.d.ts +1 -1
  85. package/lib/types/components/color-picker/HueSlider.d.ts +1 -1
  86. package/lib/types/components/config-provider/ConfigProvider.d.ts +1 -1
  87. package/lib/types/components/config-provider/ConfigProvider.stories.d.ts +1 -1
  88. package/lib/types/components/confirm/Confirm.d.ts +1 -1
  89. package/lib/types/components/confirm/Confirm.stories.d.ts +1 -1
  90. package/lib/types/components/date-picker/DatePicker.d.ts +1 -1
  91. package/lib/types/components/date-picker/DatePicker.stories.d.ts +1 -1
  92. package/lib/types/components/date-range-picker/DateRangePicker.d.ts +1 -1
  93. package/lib/types/components/date-range-picker/DateRangePicker.stories.d.ts +1 -1
  94. package/lib/types/components/dialog/Dialog.d.ts +1 -1
  95. package/lib/types/components/dialog/Dialog.stories.d.ts +2 -2
  96. package/lib/types/components/dialog/DialogPrimitive.d.ts +2 -2
  97. package/lib/types/components/draggable-list/DraggableList.d.ts +1 -1
  98. package/lib/types/components/draggable-list/DraggableList.stories.d.ts +1 -1
  99. package/lib/types/components/dropdown/Dropdown.d.ts +1 -1
  100. package/lib/types/components/dropdown/Dropdown.stories.d.ts +1 -1
  101. package/lib/types/components/dropdown/PopoverPrimitive.d.ts +4 -4
  102. package/lib/types/components/dropdown-menu/DropdownMenu.d.ts +8 -2
  103. package/lib/types/components/dropdown-menu/DropdownMenuPrimitive.d.ts +15 -15
  104. package/lib/types/components/form-layout/FormLayout.d.ts +2 -2
  105. package/lib/types/components/form-layout/FormLayout.stories.d.ts +1 -1
  106. package/lib/types/components/gallery/Gallery.stories.d.ts +1 -1
  107. package/lib/types/components/gradient-color-picker/GradientColorPicker.d.ts +3 -1
  108. package/lib/types/components/gradient-color-picker/GradientColorPicker.stories.d.ts +1 -1
  109. package/lib/types/components/hover-card/HoverCard.d.ts +1 -1
  110. package/lib/types/components/hover-card/HoverCard.stories.d.ts +1 -1
  111. package/lib/types/components/input/Input.stories.d.ts +5 -5
  112. package/lib/types/components/input-number/InputNumber.stories.d.ts +4 -4
  113. package/lib/types/components/kbd/Kbd.d.ts +1 -1
  114. package/lib/types/components/kbd/Kbd.stories.d.ts +1 -1
  115. package/lib/types/components/message/Message.d.ts +1 -1
  116. package/lib/types/components/message/Message.stories.d.ts +4 -4
  117. package/lib/types/components/pager/Pager.d.ts +1 -1
  118. package/lib/types/components/pager/Pager.stories.d.ts +1 -1
  119. package/lib/types/components/panel/Panel.d.ts +3 -3
  120. package/lib/types/components/panel/Panel.stories.d.ts +1 -1
  121. package/lib/types/components/popup/Popup.stories.d.ts +1 -1
  122. package/lib/types/components/radio/Radio.d.ts +1 -1
  123. package/lib/types/components/radio/Radio.stories.d.ts +2 -2
  124. package/lib/types/components/radio-group/RadioGroup.d.ts +1 -1
  125. package/lib/types/components/radio-group/RadioGroup.stories.d.ts +2 -2
  126. package/lib/types/components/segmented/Segmented.d.ts +1 -1
  127. package/lib/types/components/segmented/Segmented.stories.d.ts +1 -1
  128. package/lib/types/components/select/MultipleSelect.d.ts +1 -1
  129. package/lib/types/components/select/Select.d.ts +1 -1
  130. package/lib/types/components/select/Select.stories.d.ts +5 -5
  131. package/lib/types/components/select-list/SelectList.d.ts +1 -1
  132. package/lib/types/components/select-list/SelectList.stories.d.ts +1 -1
  133. package/lib/types/components/separator/Separator.d.ts +1 -1
  134. package/lib/types/components/switch/Switch.d.ts +1 -1
  135. package/lib/types/components/time-input/TimeInput.d.ts +1 -1
  136. package/lib/types/components/toaster/Toaster.d.ts +1 -1
  137. package/lib/types/components/tooltip/Tooltip.d.ts +1 -1
  138. package/lib/types/components/tooltip/Tooltip.stories.d.ts +1 -1
  139. package/lib/types/components/tree/Tree.d.ts +1 -1
  140. package/lib/types/components/tree/Tree.stories.d.ts +1 -1
  141. package/lib/types/components/virtual-list/VirtualList.d.ts +2 -1
  142. package/lib/types/helper/class-utilities.d.ts +1 -0
  143. package/lib/types/index.d.ts +71 -35
  144. package/lib/types/locale/en-US.d.ts +7 -0
  145. package/lib/umd/index.js +15 -81
  146. package/lib/umd/locale/ar-SA.js +1 -1
  147. package/lib/umd/locale/ca-ES.js +1 -1
  148. package/lib/umd/locale/de-DE.js +1 -1
  149. package/lib/umd/locale/en-US.js +1 -1
  150. package/lib/umd/locale/es-ES.js +1 -1
  151. package/lib/umd/locale/fa-IR.js +1 -1
  152. package/lib/umd/locale/fr-FR.js +1 -1
  153. package/lib/umd/locale/id-ID.js +1 -1
  154. package/lib/umd/locale/it-IT.js +1 -1
  155. package/lib/umd/locale/ja-JP.js +1 -1
  156. package/lib/umd/locale/ko-KR.js +1 -1
  157. package/lib/umd/locale/pl-PL.js +1 -1
  158. package/lib/umd/locale/pt-BR.js +1 -1
  159. package/lib/umd/locale/ru-RU.js +1 -1
  160. package/lib/umd/locale/sk-SK.js +1 -1
  161. package/lib/umd/locale/vi-VN.js +1 -1
  162. package/lib/umd/locale/zh-CN.js +1 -1
  163. package/lib/umd/locale/zh-HK.js +1 -1
  164. package/lib/umd/locale/zh-TW.js +1 -1
  165. package/package.json +11 -11
package/lib/cjs/index.js CHANGED
@@ -7,10 +7,10 @@ let react_jsx_runtime = require("react/jsx-runtime");
7
7
  let class_variance_authority = require("class-variance-authority");
8
8
  let _radix_ui_react_slot = require("@radix-ui/react-slot");
9
9
  let _radix_ui_react_direction = require("@radix-ui/react-direction");
10
- let _radix_ui_react_dialog = require("@radix-ui/react-dialog");
10
+ let _radix_ui_react_dropdown_menu = require("@radix-ui/react-dropdown-menu");
11
11
  let _radix_ui_react_popover = require("@radix-ui/react-popover");
12
+ let _radix_ui_react_dialog = require("@radix-ui/react-dialog");
12
13
  let react_dom = require("react-dom");
13
- let _radix_ui_react_dropdown_menu = require("@radix-ui/react-dropdown-menu");
14
14
  let _radix_ui_react_hover_card = require("@radix-ui/react-hover-card");
15
15
  let sonner = require("sonner");
16
16
  let react_transition_group = require("react-transition-group");
@@ -59,10 +59,7 @@ function Accordion(props) {
59
59
 
60
60
  //#endregion
61
61
  //#region src/components/avatar/Avatar.tsx
62
- const avatarVariants = (0, class_variance_authority.cva)(`
63
- univer-relative univer-inline-block univer-overflow-hidden univer-whitespace-nowrap univer-bg-gray-200
64
- univer-text-center univer-align-middle univer-text-white
65
- `, {
62
+ const avatarVariants = (0, class_variance_authority.cva)("univer-relative univer-inline-block univer-overflow-hidden univer-whitespace-nowrap univer-bg-gray-200 univer-text-center univer-align-middle univer-text-white", {
66
63
  variants: {
67
64
  /**
68
65
  * The shape of the avatar
@@ -136,55 +133,15 @@ function Badge(props) {
136
133
 
137
134
  //#endregion
138
135
  //#region src/components/button/Button.tsx
139
- const buttonVariants = (0, class_variance_authority.cva)(`
140
- univer-box-border univer-inline-flex univer-cursor-pointer univer-select-none univer-items-center
141
- univer-justify-center univer-gap-2 univer-whitespace-nowrap univer-rounded-md univer-border univer-border-solid
142
- univer-text-sm univer-font-medium univer-transition-colors
143
- disabled:univer-pointer-events-none disabled:univer-cursor-not-allowed disabled:univer-opacity-50
144
- [&_svg]:univer-pointer-events-none [&_svg]:univer-size-4 [&_svg]:univer-shrink-0
145
- `, {
136
+ const buttonVariants = (0, class_variance_authority.cva)("univer-box-border univer-inline-flex univer-cursor-pointer univer-select-none univer-items-center univer-justify-center univer-gap-2 univer-whitespace-nowrap univer-rounded-md univer-border univer-border-solid univer-text-sm univer-font-medium univer-transition-colors disabled:univer-pointer-events-none disabled:univer-cursor-not-allowed disabled:univer-opacity-50 [&_svg]:univer-pointer-events-none [&_svg]:univer-size-4 [&_svg]:univer-shrink-0", {
146
137
  variants: {
147
138
  variant: {
148
- default: `
149
- univer-border-gray-200 univer-bg-white univer-text-gray-700
150
- hover:univer-bg-gray-100
151
- active:univer-bg-gray-200
152
- dark:!univer-border-gray-600 dark:!univer-bg-gray-700 dark:!univer-text-white
153
- dark:hover:!univer-bg-gray-600
154
- dark:active:!univer-bg-gray-700
155
- `,
156
- primary: `
157
- univer-border-primary-600 univer-bg-primary-600 univer-text-white
158
- hover:univer-bg-primary-500
159
- active:univer-bg-primary-700
160
- `,
161
- danger: `
162
- univer-border-red-500 univer-bg-red-500 univer-text-white
163
- hover:univer-border-red-400 hover:univer-bg-red-400
164
- active:univer-border-red-600 active:univer-bg-red-600
165
- `,
166
- text: `
167
- univer-border-transparent univer-bg-transparent univer-text-gray-900
168
- hover:univer-bg-gray-100
169
- active:univer-bg-gray-200
170
- dark:!univer-text-white
171
- dark:hover:!univer-bg-gray-700
172
- dark:active:!univer-bg-gray-600
173
- `,
174
- link: `
175
- univer-underline-current univer-border-transparent univer-bg-transparent univer-text-primary-600
176
- univer-underline-offset-4
177
- hover:univer-text-primary-500 hover:univer-underline
178
- active:univer-text-primary-700
179
- `,
180
- ghost: `
181
- univer-border-transparent univer-bg-transparent univer-text-gray-900
182
- hover:univer-bg-gray-100
183
- active:univer-bg-gray-200
184
- dark:!univer-text-white
185
- dark:hover:!univer-bg-gray-700
186
- dark:active:!univer-bg-gray-600
187
- `
139
+ default: "univer-border-gray-200 univer-bg-white univer-text-gray-700 hover:univer-bg-gray-100 active:univer-bg-gray-200 dark:!univer-border-gray-600 dark:!univer-bg-gray-700 dark:!univer-text-white dark:hover:!univer-bg-gray-600 dark:active:!univer-bg-gray-700",
140
+ primary: "univer-border-primary-600 univer-bg-primary-600 univer-text-white hover:univer-bg-primary-500 active:univer-bg-primary-700",
141
+ danger: "univer-border-red-500 univer-bg-red-500 univer-text-white hover:univer-border-red-400 hover:univer-bg-red-400 active:univer-border-red-600 active:univer-bg-red-600",
142
+ text: "univer-border-transparent univer-bg-transparent univer-text-gray-900 hover:univer-bg-gray-100 active:univer-bg-gray-200 dark:!univer-text-white dark:hover:!univer-bg-gray-700 dark:active:!univer-bg-gray-600",
143
+ link: "univer-underline-current univer-border-transparent univer-bg-transparent univer-text-primary-600 univer-underline-offset-4 hover:univer-text-primary-500 hover:univer-underline active:univer-text-primary-700",
144
+ ghost: "univer-border-transparent univer-bg-transparent univer-text-gray-900 hover:univer-bg-gray-100 active:univer-bg-gray-200 dark:!univer-text-white dark:hover:!univer-bg-gray-700 dark:active:!univer-bg-gray-600"
188
145
  },
189
146
  size: {
190
147
  small: "univer-h-6 univer-rounded-md univer-px-1.5 univer-text-xs",
@@ -311,6 +268,243 @@ const borderBottomClassName = clsx$1(borderBasicClassName, "univer-border-l-0 un
311
268
  const borderRightClassName = clsx$1(borderBasicClassName, "univer-border-l-0 univer-border-b-0 univer-border-t-0 univer-border-r");
312
269
  const divideYClassName = "univer-divide-gray-200 dark:!univer-divide-gray-600 univer-divide-y univer-divide-x-0 univer-divide-solid";
313
270
  const divideXClassName = "univer-divide-gray-200 dark:!univer-divide-gray-600 univer-divide-x univer-divide-y-0 univer-divide-solid";
271
+ const resetButtonClassName = "univer-m-0 univer-flex univer-appearance-none univer-items-center univer-justify-center univer-border-0 univer-bg-transparent univer-p-0 univer-leading-none univer-outline-none univer-cursor-pointer";
272
+
273
+ //#endregion
274
+ //#region src/components/dropdown-menu/DropdownMenuPrimitive.tsx
275
+ function DropdownMenuPrimitive({ ...props }) {
276
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.Root, {
277
+ "data-slot": "dropdown-menu",
278
+ ...props
279
+ });
280
+ }
281
+ function DropdownMenuPortal({ ...props }) {
282
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.Portal, {
283
+ "data-slot": "dropdown-menu-portal",
284
+ ...props
285
+ });
286
+ }
287
+ function DropdownMenuTrigger({ ...props }) {
288
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.Trigger, {
289
+ "data-slot": "dropdown-menu-trigger",
290
+ ...props
291
+ });
292
+ }
293
+ function DropdownMenuSub({ ...props }) {
294
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.Sub, {
295
+ "data-slot": "dropdown-menu-sub",
296
+ ...props
297
+ });
298
+ }
299
+ function DropdownMenuRadioGroup({ ...props }) {
300
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.RadioGroup, {
301
+ "data-slot": "dropdown-menu-radio-group",
302
+ ...props
303
+ });
304
+ }
305
+ function DropdownMenuSubTrigger({ className, inset, children, ...props }) {
306
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_radix_ui_react_dropdown_menu.SubTrigger, {
307
+ "data-slot": "dropdown-menu-sub-trigger",
308
+ "data-inset": inset,
309
+ className: clsx$1("univer-flex univer-cursor-default univer-select-none univer-items-center univer-justify-between univer-gap-2 univer-rounded univer-px-2 univer-py-1.5 univer-text-sm univer-outline-none data-[state=open]:univer-bg-gray-100 focus:univer-bg-gray-100 dark:data-[state=open]:!univer-bg-gray-600 dark:focus:!univer-bg-gray-600 [&_svg]:univer-pointer-events-none [&_svg]:univer-size-4 [&_svg]:univer-shrink-0", className),
310
+ ...props,
311
+ children: [children, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreRightIcon, { className: "ml-auto" })]
312
+ });
313
+ }
314
+ function DropdownMenuSubContent({ className, ...props }) {
315
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.SubContent, {
316
+ "data-slot": "dropdown-menu-sub-content",
317
+ 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=closed]:univer-animate-out data-[state=closed]:univer-fade-out-0 data-[state=closed]:univer-zoom-out-95 data-[side=bottom]:univer-slide-in-from-top-2 data-[side=left]:univer-slide-in-from-right-2 data-[side=right]:univer-slide-in-from-left-2 data-[side=top]:univer-slide-in-from-bottom-2 univer-z-[1080] univer-box-border univer-max-h-[--radix-popper-available-height] univer-overflow-y-auto univer-rounded-md univer-bg-white univer-p-1.5 univer-text-gray-900 univer-shadow-md dark:!univer-bg-gray-700 dark:!univer-text-white", borderClassName, scrollbarClassName, className),
318
+ ...props
319
+ });
320
+ }
321
+ function DropdownMenuContent({ className, sideOffset = 4, ...props }) {
322
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.Portal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.Content, {
323
+ "data-slot": "dropdown-menu-content",
324
+ sideOffset,
325
+ 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=closed]:univer-animate-out data-[state=closed]:univer-fade-out-0 data-[state=closed]:univer-zoom-out-95 data-[side=bottom]:univer-slide-in-from-top-2 data-[side=left]:univer-slide-in-from-right-2 data-[side=right]:univer-slide-in-from-left-2 data-[side=top]:univer-slide-in-from-bottom-2 univer-z-[1080] univer-box-border univer-max-h-[--radix-popper-available-height] univer-overflow-y-auto univer-rounded-md univer-bg-white univer-p-1.5 univer-text-gray-900 univer-shadow-md dark:!univer-bg-gray-700 dark:!univer-text-white", borderClassName, scrollbarClassName, className),
326
+ ...props
327
+ }) });
328
+ }
329
+ function DropdownMenuItem({ className, inset, variant = "default", ...props }) {
330
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.Item, {
331
+ "data-slot": "dropdown-menu-item",
332
+ "data-inset": inset,
333
+ "data-variant": variant,
334
+ className: clsx$1("univer-relative univer-flex univer-cursor-default univer-select-none univer-items-center univer-gap-2 univer-rounded univer-px-2 univer-py-1.5 univer-text-sm univer-outline-none univer-transition-colors data-[disabled]:univer-pointer-events-none data-[variant=destructive]:univer-text-red-600 data-[disabled]:univer-opacity-50 focus:univer-bg-gray-100 data-[variant=destructive]:focus:univer-bg-red-50 dark:data-[variant=destructive]:!univer-text-red-400 dark:focus:!univer-bg-gray-600 dark:data-[variant=destructive]:focus:!univer-bg-red-900 [&>svg]:univer-size-4 [&>svg]:univer-shrink-0", className),
335
+ ...props
336
+ });
337
+ }
338
+ function DropdownMenuCheckboxItem({ className, children, hideIndicator, checked, ...props }) {
339
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_radix_ui_react_dropdown_menu.CheckboxItem, {
340
+ "data-slot": "dropdown-menu-checkbox-item",
341
+ className: clsx$1("univer-relative univer-flex univer-cursor-default univer-select-none univer-items-center univer-rounded univer-py-1.5 univer-pr-2 univer-text-sm univer-outline-none univer-transition-colors data-[disabled]:univer-pointer-events-none data-[disabled]:univer-opacity-50 focus:univer-bg-gray-100 dark:focus:!univer-bg-gray-600", {
342
+ "univer-pl-8": !hideIndicator,
343
+ "univer-pl-2": hideIndicator
344
+ }, className),
345
+ checked,
346
+ ...props,
347
+ children: [!hideIndicator && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
348
+ className: "univer-absolute univer-left-2 univer-flex univer-size-3.5 univer-items-center univer-justify-center",
349
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.ItemIndicator, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.CheckMarkIcon, { className: "univer-block univer-size-4 univer-fill-current univer-text-primary-600" }) })
350
+ }), children]
351
+ });
352
+ }
353
+ function DropdownMenuRadioItem({ className, children, hideIndicator, ...props }) {
354
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_radix_ui_react_dropdown_menu.RadioItem, {
355
+ "data-slot": "dropdown-menu-radio-item",
356
+ className: clsx$1("univer-relative univer-flex univer-cursor-default univer-select-none univer-items-center univer-rounded univer-py-1.5 univer-pr-2 univer-text-sm univer-outline-none univer-transition-colors data-[disabled]:univer-pointer-events-none data-[disabled]:univer-opacity-50 focus:univer-bg-gray-100 dark:focus:!univer-bg-gray-600", {
357
+ "univer-pl-8": !hideIndicator,
358
+ "univer-pl-2": hideIndicator
359
+ }, className),
360
+ ...props,
361
+ children: [!hideIndicator && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
362
+ className: "univer-absolute univer-left-2 univer-flex univer-size-3.5 univer-items-center univer-justify-center",
363
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.ItemIndicator, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.CheckMarkIcon, { className: "univer-block univer-size-4 univer-fill-current univer-text-primary-600" }) })
364
+ }), children]
365
+ });
366
+ }
367
+ function DropdownMenuSeparator({ className, ...props }) {
368
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.Separator, {
369
+ className: clsx$1("-univer-mx-1 univer-my-1 univer-h-px univer-bg-gray-200 dark:!univer-bg-gray-600", className),
370
+ ...props
371
+ });
372
+ }
373
+
374
+ //#endregion
375
+ //#region src/components/dropdown-menu/DropdownMenu.tsx
376
+ function DropdownMenu(props) {
377
+ const { children, items, disabled, open: controlledOpen, onOpenChange: controlledOnOpenChange, ...restProps } = props;
378
+ const [uncontrolledOpen, setUncontrolledOpen] = (0, react.useState)(false);
379
+ const isControlled = controlledOpen !== void 0;
380
+ const open = isControlled ? controlledOpen : uncontrolledOpen;
381
+ function handleChangeOpen(newOpen) {
382
+ if (disabled) return;
383
+ if (!isControlled) setUncontrolledOpen(newOpen);
384
+ controlledOnOpenChange === null || controlledOnOpenChange === void 0 || controlledOnOpenChange(newOpen);
385
+ }
386
+ function renderMenuItem(item, index) {
387
+ const { className, type } = item;
388
+ if (type === "separator") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuSeparator, { className }, index);
389
+ else if (type === "custom") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
390
+ className,
391
+ children: item.children
392
+ }, index);
393
+ else if (type === "radio") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuRadioGroup, {
394
+ className,
395
+ value: item.value,
396
+ onValueChange: item.onSelect,
397
+ children: item.options.map((option, index) => {
398
+ if ("type" in option) {
399
+ if (option.type === "separator") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuSeparator, { className: option.className }, index);
400
+ } else {
401
+ if (option.value === void 0) throw new Error("[DropdownMenu]: `value` is required");
402
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuRadioItem, {
403
+ value: option.value,
404
+ disabled: option.disabled,
405
+ hideIndicator: item.hideIndicator,
406
+ children: option.label
407
+ }, option.value);
408
+ }
409
+ return null;
410
+ })
411
+ }, index);
412
+ else if (type === "checkbox") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuCheckboxItem, {
413
+ className,
414
+ disabled: item.disabled,
415
+ checked: item.checked,
416
+ onSelect: () => {
417
+ var _item$onSelect;
418
+ (_item$onSelect = item.onSelect) === null || _item$onSelect === void 0 || _item$onSelect.call(item, item.value);
419
+ },
420
+ children: item.label
421
+ }, index);
422
+ else if (type === "item") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuItem, {
423
+ className,
424
+ disabled: item.disabled,
425
+ variant: item.variant,
426
+ onSelect: () => {
427
+ var _item$onSelect2;
428
+ (_item$onSelect2 = item.onSelect) === null || _item$onSelect2 === void 0 || _item$onSelect2.call(item, item);
429
+ },
430
+ children: item.children
431
+ }, index);
432
+ else if (type === "subItem") {
433
+ var _item$options;
434
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DropdownMenuSub, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuSubTrigger, { children: item.children }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuPortal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuSubContent, {
435
+ sideOffset: 12,
436
+ children: (_item$options = item.options) === null || _item$options === void 0 ? void 0 : _item$options.map((subItem, subIndex) => renderMenuItem(subItem, subIndex))
437
+ }) })] }, index);
438
+ }
439
+ }
440
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DropdownMenuPrimitive, {
441
+ modal: false,
442
+ open,
443
+ onOpenChange: handleChangeOpen,
444
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuTrigger, {
445
+ asChild: true,
446
+ children
447
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuContent, {
448
+ className: "univer-text-sm",
449
+ collisionPadding: {
450
+ top: 12,
451
+ bottom: 12
452
+ },
453
+ onWheel: (e) => e.stopPropagation(),
454
+ ...restProps,
455
+ children: items.map((item, index) => renderMenuItem(item, index))
456
+ })]
457
+ });
458
+ }
459
+
460
+ //#endregion
461
+ //#region src/components/dropdown/PopoverPrimitive.tsx
462
+ function PopoverPrimitive({ ...props }) {
463
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_popover.Root, {
464
+ "data-slot": "popover",
465
+ ...props
466
+ });
467
+ }
468
+ function PopoverTrigger({ ...props }) {
469
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_popover.Trigger, {
470
+ "data-slot": "popover-trigger",
471
+ ...props
472
+ });
473
+ }
474
+ function PopoverContent({ className, align = "center", sideOffset = 4, ...props }) {
475
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_popover.Portal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_popover.Content, {
476
+ "data-slot": "popover-content",
477
+ align,
478
+ sideOffset,
479
+ className: clsx$1("univer-outline-hidden data-[state=open]:univer-animate-in data-[state=open]:univer-fade-in-0 data-[state=open]:univer-zoom-in-95 data-[state=closed]:univer-animate-out data-[state=closed]:univer-fade-out-0 data-[state=closed]:univer-zoom-out-95 data-[side=bottom]:univer-slide-in-from-top-2 data-[side=left]:univer-slide-in-from-right-2 data-[side=right]:univer-slide-in-from-left-2 data-[side=top]:univer-slide-in-from-bottom-2 univer-z-[1080] univer-max-h-[--radix-popper-available-height] univer-overflow-y-auto univer-rounded-md univer-bg-white univer-text-gray-900 univer-shadow-md dark:!univer-bg-gray-900 dark:!univer-text-white dark:focus-visible:!univer-border-gray-600", borderClassName, scrollbarClassName, className),
480
+ ...props
481
+ }) });
482
+ }
483
+
484
+ //#endregion
485
+ //#region src/components/dropdown/Dropdown.tsx
486
+ function Dropdown(props) {
487
+ const { children, overlay, disabled, open: controlledOpen, onOpenChange: controlledOnOpenChange, ...restProps } = props;
488
+ const [uncontrolledOpen, setUncontrolledOpen] = (0, react.useState)(false);
489
+ const isControlled = controlledOpen !== void 0;
490
+ const open = isControlled ? controlledOpen : uncontrolledOpen;
491
+ function handleChangeOpen(newOpen) {
492
+ if (disabled) return;
493
+ if (!isControlled) setUncontrolledOpen(newOpen);
494
+ controlledOnOpenChange === null || controlledOnOpenChange === void 0 || controlledOnOpenChange(newOpen);
495
+ }
496
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PopoverPrimitive, {
497
+ open,
498
+ onOpenChange: handleChangeOpen,
499
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(PopoverTrigger, {
500
+ asChild: true,
501
+ children
502
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PopoverContent, {
503
+ ...restProps,
504
+ children: overlay
505
+ })]
506
+ });
507
+ }
314
508
 
315
509
  //#endregion
316
510
  //#region src/helper/date.ts
@@ -373,28 +567,89 @@ function TimeInput(props) {
373
567
  }
374
568
 
375
569
  //#endregion
376
- //#region src/components/calendar/Calendar.tsx
377
- function getDaysInMonth(year, month) {
378
- return new Date(year, month + 1, 0).getDate();
379
- }
380
- function getFirstDayOfWeek(year, month) {
381
- return new Date(year, month, 1).getDay();
382
- }
383
- function DayButton(props) {
384
- const { className, ...restProps } = props;
385
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
386
- className: clsx$1("univer-size-7 univer-rounded-md univer-border-none univer-bg-transparent univer-p-1 univer-transition-all hover:univer-bg-gray-200 dark:hover:!univer-bg-gray-600", className),
387
- type: "button",
388
- ...restProps
389
- });
570
+ //#region src/components/virtual-list/VirtualList.tsx
571
+ function VirtualList(props) {
572
+ const { data, itemKey, children, height, itemHeight, initialScrollIndex = 0, overscan = 2, className, style } = props;
573
+ const initialScrollTop = height && itemHeight ? initialScrollIndex * itemHeight : 0;
574
+ const scrollerRef = (0, react.useRef)(null);
575
+ const [scrollTop, setScrollTop] = (0, react.useState)(initialScrollTop);
576
+ (0, react.useEffect)(() => {
577
+ const scroller = scrollerRef.current;
578
+ if (!scroller || !height || !itemHeight) return;
579
+ const nextScrollTop = initialScrollIndex * itemHeight;
580
+ scroller.scrollTop = nextScrollTop;
581
+ setScrollTop(nextScrollTop);
582
+ }, [
583
+ height,
584
+ initialScrollIndex,
585
+ itemHeight
586
+ ]);
587
+ if (!height || !itemHeight || itemHeight <= 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
588
+ className,
589
+ style,
590
+ children: data.map((item, index) => {
591
+ const key = typeof itemKey === "function" ? itemKey(item) : item[itemKey];
592
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: children(item, index) }, key);
593
+ })
594
+ });
595
+ const start = Math.max(0, Math.floor(scrollTop / itemHeight) - overscan);
596
+ const visibleCount = Math.ceil(height / itemHeight) + overscan * 2;
597
+ const end = Math.min(data.length, start + visibleCount);
598
+ const offsetY = start * itemHeight;
599
+ const totalHeight = data.length * itemHeight;
600
+ const visibleItems = data.slice(start, end);
601
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
602
+ ref: scrollerRef,
603
+ className,
604
+ style: {
605
+ ...style,
606
+ height,
607
+ overflowY: "auto"
608
+ },
609
+ onScroll: (e) => setScrollTop(e.currentTarget.scrollTop),
610
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
611
+ style: {
612
+ height: totalHeight,
613
+ position: "relative"
614
+ },
615
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
616
+ style: { transform: `translateY(${offsetY}px)` },
617
+ children: visibleItems.map((item, index) => {
618
+ const key = typeof itemKey === "function" ? itemKey(item) : item[itemKey];
619
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: children(item, start + index) }, key);
620
+ })
621
+ })
622
+ })
623
+ });
624
+ }
625
+
626
+ //#endregion
627
+ //#region src/components/calendar/Calendar.tsx
628
+ const DEFAULT_YEAR_RANGE = 100;
629
+ const YEAR_ITEM_HEIGHT = 32;
630
+ const YEAR_LIST_HEIGHT = 224;
631
+ function getDaysInMonth(year, month) {
632
+ return new Date(year, month + 1, 0).getDate();
633
+ }
634
+ function getFirstDayOfWeek(year, month) {
635
+ return new Date(year, month, 1).getDay();
636
+ }
637
+ function DayButton(props) {
638
+ const { className, ...restProps } = props;
639
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
640
+ className: clsx$1("univer-size-7 univer-rounded-md univer-border-none univer-bg-transparent univer-p-1 univer-transition-all hover:univer-bg-gray-200 dark:hover:!univer-bg-gray-600", className),
641
+ type: "button",
642
+ ...restProps
643
+ });
390
644
  }
391
645
  function Calendar(props) {
392
646
  const { className, max, min, showTime = false, value, onValueChange } = props;
393
647
  const { locale } = (0, react.useContext)(ConfigContext);
394
- const { year, weekDays, months } = locale === null || locale === void 0 ? void 0 : locale.Calendar;
648
+ const { ariaLabels, year, weekDays, months } = locale === null || locale === void 0 ? void 0 : locale.Calendar;
395
649
  const today = /* @__PURE__ */ new Date();
396
650
  const [currentYear, setCurrentYear] = (0, react.useState)((value !== null && value !== void 0 ? value : today).getFullYear());
397
651
  const [currentMonth, setCurrentMonth] = (0, react.useState)((value !== null && value !== void 0 ? value : today).getMonth());
652
+ const [yearDropdownOpen, setYearDropdownOpen] = (0, react.useState)(false);
398
653
  function prevMonth() {
399
654
  setCurrentMonth((prev) => {
400
655
  if (prev === 0) {
@@ -413,6 +668,34 @@ function Calendar(props) {
413
668
  return prev + 1;
414
669
  });
415
670
  }
671
+ function handleChangeMonth(month) {
672
+ setCurrentMonth(Number(month));
673
+ }
674
+ function handleChangeYear(year) {
675
+ setCurrentYear(year);
676
+ setYearDropdownOpen(false);
677
+ }
678
+ const yearOptions = (0, react.useMemo)(() => {
679
+ var _min$getFullYear, _max$getFullYear;
680
+ const startYear = (_min$getFullYear = min === null || min === void 0 ? void 0 : min.getFullYear()) !== null && _min$getFullYear !== void 0 ? _min$getFullYear : currentYear - DEFAULT_YEAR_RANGE;
681
+ const endYear = (_max$getFullYear = max === null || max === void 0 ? void 0 : max.getFullYear()) !== null && _max$getFullYear !== void 0 ? _max$getFullYear : currentYear + DEFAULT_YEAR_RANGE;
682
+ return Array.from({ length: Math.max(0, endYear - startYear + 1) }, (_, index) => ({ year: startYear + index }));
683
+ }, [
684
+ currentYear,
685
+ max,
686
+ min
687
+ ]);
688
+ const currentYearIndex = Math.max(0, yearOptions.findIndex((item) => item.year === currentYear));
689
+ const monthMenuItems = (0, react.useMemo)(() => [{
690
+ type: "radio",
691
+ value: String(currentMonth),
692
+ hideIndicator: true,
693
+ options: months.map((month, index) => ({
694
+ label: month,
695
+ value: String(index)
696
+ })),
697
+ onSelect: handleChangeMonth
698
+ }], [currentMonth, months]);
416
699
  const daysInMonth = getDaysInMonth(currentYear, currentMonth);
417
700
  const firstDay = getFirstDayOfWeek(currentYear, currentMonth);
418
701
  const days = (0, react.useMemo)(() => {
@@ -464,21 +747,52 @@ function Calendar(props) {
464
747
  children: [
465
748
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DayButton, {
466
749
  className: "univer-text-lg univer-text-gray-500 dark:!univer-text-gray-200",
467
- "aria-label": "Previous Month",
750
+ "aria-label": ariaLabels.previousMonth,
468
751
  onClick: prevMonth,
469
752
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreRightIcon, { className: "univer-rotate-180" })
470
753
  }),
471
754
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
472
- className: "univer-flex univer-gap-0.5 univer-text-sm univer-font-medium",
473
- children: [
474
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: currentYear }),
475
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: year }),
476
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: months[currentMonth] })
477
- ]
755
+ className: "univer-flex univer-items-center univer-gap-0.5 univer-text-sm univer-font-medium",
756
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Dropdown, {
757
+ align: "center",
758
+ className: "univer-w-24 univer-p-1.5",
759
+ open: yearDropdownOpen,
760
+ overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VirtualList, {
761
+ className: "univer-rounded",
762
+ data: yearOptions,
763
+ height: YEAR_LIST_HEIGHT,
764
+ initialScrollIndex: currentYearIndex,
765
+ itemHeight: YEAR_ITEM_HEIGHT,
766
+ itemKey: "year",
767
+ children: (item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
768
+ className: clsx$1("univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-center univer-rounded univer-border-none univer-bg-transparent univer-px-2 univer-text-sm univer-text-gray-900 univer-transition-colors hover:univer-bg-gray-100 dark:!univer-text-white dark:hover:!univer-bg-gray-600", { "univer-bg-gray-200 dark:!univer-bg-gray-500": item.year === currentYear }),
769
+ type: "button",
770
+ onClick: () => handleChangeYear(item.year),
771
+ children: item.year
772
+ })
773
+ }),
774
+ onOpenChange: setYearDropdownOpen,
775
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Button, {
776
+ variant: "text",
777
+ type: "button",
778
+ "aria-label": ariaLabels.selectYear,
779
+ children: [currentYear, year]
780
+ })
781
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenu, {
782
+ align: "center",
783
+ className: "univer-max-h-80 univer-min-w-28 univer-overflow-auto",
784
+ items: monthMenuItems,
785
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
786
+ variant: "text",
787
+ type: "button",
788
+ "aria-label": ariaLabels.selectMonth,
789
+ children: months[currentMonth]
790
+ })
791
+ })]
478
792
  }),
479
793
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DayButton, {
480
794
  className: "univer-text-lg univer-text-gray-500 dark:!univer-text-gray-200",
481
- "aria-label": "Next Month",
795
+ "aria-label": ariaLabels.nextMonth,
482
796
  onClick: nextMonth,
483
797
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreRightIcon, {})
484
798
  })
@@ -1765,55 +2079,6 @@ function Confirm(props) {
1765
2079
  });
1766
2080
  }
1767
2081
 
1768
- //#endregion
1769
- //#region src/components/dropdown/PopoverPrimitive.tsx
1770
- function PopoverPrimitive({ ...props }) {
1771
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_popover.Root, {
1772
- "data-slot": "popover",
1773
- ...props
1774
- });
1775
- }
1776
- function PopoverTrigger({ ...props }) {
1777
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_popover.Trigger, {
1778
- "data-slot": "popover-trigger",
1779
- ...props
1780
- });
1781
- }
1782
- function PopoverContent({ className, align = "center", sideOffset = 4, ...props }) {
1783
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_popover.Portal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_popover.Content, {
1784
- "data-slot": "popover-content",
1785
- align,
1786
- sideOffset,
1787
- className: clsx$1("univer-outline-hidden data-[state=open]:univer-animate-in data-[state=open]:univer-fade-in-0 data-[state=open]:univer-zoom-in-95 data-[state=closed]:univer-animate-out data-[state=closed]:univer-fade-out-0 data-[state=closed]:univer-zoom-out-95 data-[side=bottom]:univer-slide-in-from-top-2 data-[side=left]:univer-slide-in-from-right-2 data-[side=right]:univer-slide-in-from-left-2 data-[side=top]:univer-slide-in-from-bottom-2 univer-z-[1080] univer-max-h-[--radix-popper-available-height] univer-overflow-y-auto univer-rounded-md univer-bg-white univer-text-gray-900 univer-shadow-md dark:!univer-bg-gray-900 dark:!univer-text-white dark:focus-visible:!univer-border-gray-600", borderClassName, scrollbarClassName, className),
1788
- ...props
1789
- }) });
1790
- }
1791
-
1792
- //#endregion
1793
- //#region src/components/dropdown/Dropdown.tsx
1794
- function Dropdown(props) {
1795
- const { children, overlay, disabled, open: controlledOpen, onOpenChange: controlledOnOpenChange, ...restProps } = props;
1796
- const [uncontrolledOpen, setUncontrolledOpen] = (0, react.useState)(false);
1797
- const isControlled = controlledOpen !== void 0;
1798
- const open = isControlled ? controlledOpen : uncontrolledOpen;
1799
- function handleChangeOpen(newOpen) {
1800
- if (disabled) return;
1801
- if (!isControlled) setUncontrolledOpen(newOpen);
1802
- controlledOnOpenChange === null || controlledOnOpenChange === void 0 || controlledOnOpenChange(newOpen);
1803
- }
1804
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PopoverPrimitive, {
1805
- open,
1806
- onOpenChange: handleChangeOpen,
1807
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(PopoverTrigger, {
1808
- asChild: true,
1809
- children
1810
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PopoverContent, {
1811
- ...restProps,
1812
- children: overlay
1813
- })]
1814
- });
1815
- }
1816
-
1817
2082
  //#endregion
1818
2083
  //#region src/components/date-picker/DatePicker.tsx
1819
2084
  /**
@@ -1919,363 +2184,176 @@ function DateRangePicker(props) {
1919
2184
  }
1920
2185
 
1921
2186
  //#endregion
1922
- //#region src/components/draggable-list/DraggableList.tsx
1923
- function moveItemByIndex(list, fromIndex, toIndex) {
1924
- if (fromIndex === toIndex || fromIndex < 0 || toIndex < 0 || fromIndex >= list.length || toIndex >= list.length) return list;
1925
- const next = [...list];
1926
- const [item] = next.splice(fromIndex, 1);
1927
- next.splice(toIndex, 0, item);
1928
- return next;
1929
- }
1930
- function DraggableList(props) {
1931
- const { list, onListChange, idKey, itemRender, className, style, draggableHandle, rowHeight, margin = [0, 0], onDragStart, onDragStop, ...restProps } = props;
1932
- const [displayList, setDisplayList] = (0, react.useState)(list);
1933
- const displayListRef = (0, react.useRef)(list);
1934
- const [draggingId, setDraggingId] = (0, react.useState)(null);
1935
- const [dragOverId, setDragOverId] = (0, react.useState)(null);
1936
- const [ghostElement, setGhostElement] = (0, react.useState)(null);
1937
- const [ghostPosition, setGhostPosition] = (0, react.useState)(null);
1938
- const [canUsePortal, setCanUsePortal] = (0, react.useState)(false);
1939
- const pointerIdRef = (0, react.useRef)(null);
1940
- const dragPointerOffsetRef = (0, react.useRef)({
1941
- x: 0,
1942
- y: 0
1943
- });
1944
- const dragItemSizeRef = (0, react.useRef)({
1945
- width: 0,
1946
- height: 0
1947
- });
1948
- const ghostContainerRef = (0, react.useRef)(null);
1949
- const pressedHandleIdRef = (0, react.useRef)(null);
1950
- const dragSourceIdRef = (0, react.useRef)(null);
1951
- const dragStartIndexRef = (0, react.useRef)(-1);
1952
- const { direction } = (0, react.useContext)(ConfigContext);
1953
- (0, react.useEffect)(() => {
1954
- if (!draggingId) {
1955
- setDisplayList(list);
1956
- displayListRef.current = list;
1957
- }
1958
- }, [draggingId, list]);
1959
- (0, react.useEffect)(() => {
1960
- setCanUsePortal(typeof document !== "undefined");
1961
- }, []);
1962
- (0, react.useEffect)(() => {
1963
- const container = ghostContainerRef.current;
1964
- if (!container) return;
1965
- container.replaceChildren();
1966
- if (ghostElement) container.appendChild(ghostElement);
1967
- }, [ghostElement]);
1968
- (0, react.useEffect)(() => {
1969
- if (!draggingId) return;
1970
- const handlePointerMove = (evt) => {
1971
- const sourceId = dragSourceIdRef.current;
1972
- if (!sourceId || pointerIdRef.current !== evt.pointerId) return;
1973
- setGhostPosition({
1974
- x: evt.clientX - dragPointerOffsetRef.current.x,
1975
- y: evt.clientY - dragPointerOffsetRef.current.y
1976
- });
1977
- const element = document.elementFromPoint(evt.clientX, evt.clientY);
1978
- const itemElement = element === null || element === void 0 ? void 0 : element.closest("[data-draggable-list-item-id]");
1979
- const targetId = itemElement === null || itemElement === void 0 ? void 0 : itemElement.dataset.draggableListItemId;
1980
- if (!targetId || targetId === sourceId) return;
1981
- setDragOverId(targetId);
1982
- setDisplayList((prev) => {
1983
- const fromIndex = prev.findIndex((it) => getItemId(it) === sourceId);
1984
- const toIndex = prev.findIndex((it) => getItemId(it) === targetId);
1985
- if (fromIndex < 0 || toIndex < 0 || fromIndex === toIndex) return prev;
1986
- const next = moveItemByIndex(prev, fromIndex, toIndex);
1987
- displayListRef.current = next;
1988
- return next;
1989
- });
1990
- };
1991
- const handlePointerUp = (evt) => {
1992
- if (pointerIdRef.current !== evt.pointerId) return;
1993
- const sourceId = dragSourceIdRef.current;
1994
- const startIndex = dragStartIndexRef.current;
1995
- const currentList = displayListRef.current;
1996
- if (sourceId) {
1997
- const finalIndex = currentList.findIndex((it) => getItemId(it) === sourceId);
1998
- onDragStop === null || onDragStop === void 0 || onDragStop(void 0, { y: startIndex }, { y: finalIndex });
1999
- if (startIndex >= 0) onListChange([...currentList]);
2000
- }
2001
- pointerIdRef.current = null;
2002
- pressedHandleIdRef.current = null;
2003
- dragSourceIdRef.current = null;
2004
- dragStartIndexRef.current = -1;
2005
- setDragOverId(null);
2006
- setGhostElement(null);
2007
- setGhostPosition(null);
2008
- setDraggingId(null);
2009
- };
2010
- window.addEventListener("pointermove", handlePointerMove);
2011
- window.addEventListener("pointerup", handlePointerUp);
2012
- window.addEventListener("pointercancel", handlePointerUp);
2013
- return () => {
2014
- window.removeEventListener("pointermove", handlePointerMove);
2015
- window.removeEventListener("pointerup", handlePointerUp);
2016
- window.removeEventListener("pointercancel", handlePointerUp);
2017
- };
2018
- }, [
2019
- draggingId,
2020
- onDragStop,
2021
- onListChange
2022
- ]);
2023
- const gapStyle = (0, react.useMemo)(() => {
2024
- const [horizontal, vertical] = margin;
2025
- return {
2026
- rowGap: `${vertical}px`,
2027
- paddingLeft: horizontal ? `${horizontal}px` : void 0,
2028
- paddingRight: horizontal ? `${horizontal}px` : void 0,
2029
- ...style
2030
- };
2031
- }, [margin, style]);
2032
- const getItemId = (item) => String(item[idKey]);
2033
- const draggingItem = draggingId ? displayList.find((item) => getItemId(item) === draggingId) : null;
2034
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2035
- ...restProps,
2036
- className: clsx$1("univer-flex univer-flex-col", draggingId && "univer-cursor-grabbing univer-select-none", className),
2037
- style: gapStyle,
2038
- children: displayList.map((item, index) => {
2039
- const itemId = getItemId(item);
2040
- const isDraggingItem = draggingId === itemId;
2041
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2042
- "data-draggable-list-item-id": itemId,
2043
- className: clsx$1("univer-relative univer-transition-all univer-duration-150", isDraggingItem && "univer-opacity-0", dragOverId === itemId && !isDraggingItem && `
2044
- univer-bg-primary-50/60
2045
- dark:!univer-bg-primary-900/20
2046
- univer-rounded univer-border univer-border-primary-200
2047
- dark:!univer-border-primary-700
2048
- `),
2049
- onPointerDownCapture: (e) => {
2050
- if (pointerIdRef.current !== null) return;
2051
- if (!draggableHandle) pressedHandleIdRef.current = itemId;
2052
- else pressedHandleIdRef.current = !!e.target.closest(draggableHandle) ? itemId : null;
2053
- if (pressedHandleIdRef.current !== itemId) return;
2054
- const rect = e.currentTarget.getBoundingClientRect();
2055
- dragPointerOffsetRef.current = {
2056
- x: e.clientX - rect.left,
2057
- y: e.clientY - rect.top
2058
- };
2059
- dragItemSizeRef.current = {
2060
- width: rect.width,
2061
- height: rect.height
2062
- };
2063
- setGhostPosition({
2064
- x: rect.left,
2065
- y: rect.top
2066
- });
2067
- setGhostElement(e.currentTarget.cloneNode(true));
2068
- pointerIdRef.current = e.pointerId;
2069
- dragSourceIdRef.current = itemId;
2070
- dragStartIndexRef.current = index;
2071
- setDraggingId(itemId);
2072
- displayListRef.current = displayList;
2073
- onDragStart === null || onDragStart === void 0 || onDragStart(void 0, { y: index });
2074
- e.preventDefault();
2075
- e.currentTarget.setPointerCapture(e.pointerId);
2076
- },
2077
- style: {
2078
- ...rowHeight ? { minHeight: `${rowHeight}px` } : void 0,
2079
- cursor: draggingId ? "grabbing" : void 0
2080
- },
2081
- children: [isDraggingItem && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "\n univer-bg-primary-50/50 univer-absolute univer-inset-0 univer-rounded\n univer-border univer-border-dashed univer-border-primary-300\n " }), itemRender(item, index)]
2082
- }, itemId);
2083
- })
2084
- }), canUsePortal && draggingItem && ghostPosition && (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2085
- dir: direction,
2086
- className: clsx$1("univer-pointer-events-none univer-fixed univer-rounded-md univer-border univer-border-gray-200 univer-bg-white univer-shadow-lg dark:!univer-border-gray-700 dark:!univer-bg-gray-800"),
2087
- style: {
2088
- zIndex: 2147483647,
2089
- left: `${ghostPosition.x}px`,
2090
- top: `${ghostPosition.y}px`,
2091
- width: `${dragItemSizeRef.current.width}px`,
2092
- height: `${dragItemSizeRef.current.height}px`,
2093
- opacity: .95
2094
- },
2095
- children: ghostElement ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { ref: ghostContainerRef }) : itemRender(draggingItem, displayList.findIndex((item) => getItemId(item) === getItemId(draggingItem)))
2096
- }), document.body)] });
2097
- }
2098
-
2099
- //#endregion
2100
- //#region src/components/dropdown-menu/DropdownMenuPrimitive.tsx
2101
- function DropdownMenuPrimitive({ ...props }) {
2102
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.Root, {
2103
- "data-slot": "dropdown-menu",
2104
- ...props
2105
- });
2106
- }
2107
- function DropdownMenuPortal({ ...props }) {
2108
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.Portal, {
2109
- "data-slot": "dropdown-menu-portal",
2110
- ...props
2111
- });
2112
- }
2113
- function DropdownMenuTrigger({ ...props }) {
2114
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.Trigger, {
2115
- "data-slot": "dropdown-menu-trigger",
2116
- ...props
2117
- });
2118
- }
2119
- function DropdownMenuSub({ ...props }) {
2120
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.Sub, {
2121
- "data-slot": "dropdown-menu-sub",
2122
- ...props
2123
- });
2124
- }
2125
- function DropdownMenuRadioGroup({ ...props }) {
2126
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.RadioGroup, {
2127
- "data-slot": "dropdown-menu-radio-group",
2128
- ...props
2129
- });
2130
- }
2131
- function DropdownMenuSubTrigger({ className, inset, children, ...props }) {
2132
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_radix_ui_react_dropdown_menu.SubTrigger, {
2133
- "data-slot": "dropdown-menu-sub-trigger",
2134
- "data-inset": inset,
2135
- className: clsx$1("univer-flex univer-cursor-default univer-select-none univer-items-center univer-justify-between univer-gap-2 univer-rounded univer-px-2 univer-py-1.5 univer-text-sm univer-outline-none data-[state=open]:univer-bg-gray-100 focus:univer-bg-gray-100 dark:data-[state=open]:!univer-bg-gray-600 dark:focus:!univer-bg-gray-600 [&_svg]:univer-pointer-events-none [&_svg]:univer-size-4 [&_svg]:univer-shrink-0", className),
2136
- ...props,
2137
- children: [children, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreRightIcon, { className: "ml-auto" })]
2138
- });
2139
- }
2140
- function DropdownMenuSubContent({ className, ...props }) {
2141
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.SubContent, {
2142
- "data-slot": "dropdown-menu-sub-content",
2143
- 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=closed]:univer-animate-out data-[state=closed]:univer-fade-out-0 data-[state=closed]:univer-zoom-out-95 data-[side=bottom]:univer-slide-in-from-top-2 data-[side=left]:univer-slide-in-from-right-2 data-[side=right]:univer-slide-in-from-left-2 data-[side=top]:univer-slide-in-from-bottom-2 univer-z-[1080] univer-box-border univer-max-h-[--radix-popper-available-height] univer-overflow-y-auto univer-rounded-md univer-bg-white univer-p-1.5 univer-text-gray-900 univer-shadow-md dark:!univer-bg-gray-700 dark:!univer-text-white", borderClassName, scrollbarClassName, className),
2144
- ...props
2145
- });
2146
- }
2147
- function DropdownMenuContent({ className, sideOffset = 4, ...props }) {
2148
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.Portal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.Content, {
2149
- "data-slot": "dropdown-menu-content",
2150
- sideOffset,
2151
- 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=closed]:univer-animate-out data-[state=closed]:univer-fade-out-0 data-[state=closed]:univer-zoom-out-95 data-[side=bottom]:univer-slide-in-from-top-2 data-[side=left]:univer-slide-in-from-right-2 data-[side=right]:univer-slide-in-from-left-2 data-[side=top]:univer-slide-in-from-bottom-2 univer-z-[1080] univer-box-border univer-max-h-[--radix-popper-available-height] univer-overflow-y-auto univer-rounded-md univer-bg-white univer-p-1.5 univer-text-gray-900 univer-shadow-md dark:!univer-bg-gray-700 dark:!univer-text-white", borderClassName, scrollbarClassName, className),
2152
- ...props
2153
- }) });
2154
- }
2155
- function DropdownMenuItem({ className, inset, variant = "default", ...props }) {
2156
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.Item, {
2157
- "data-slot": "dropdown-menu-item",
2158
- "data-inset": inset,
2159
- "data-variant": variant,
2160
- className: clsx$1("univer-relative univer-flex univer-cursor-default univer-select-none univer-items-center univer-gap-2 univer-rounded univer-px-2 univer-py-1.5 univer-text-sm univer-outline-none univer-transition-colors data-[disabled]:univer-pointer-events-none data-[disabled]:univer-opacity-50 focus:univer-bg-gray-100 dark:focus:!univer-bg-gray-600 [&>svg]:univer-size-4 [&>svg]:univer-shrink-0", className),
2161
- ...props
2162
- });
2163
- }
2164
- function DropdownMenuCheckboxItem({ className, children, hideIndicator, checked, ...props }) {
2165
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_radix_ui_react_dropdown_menu.CheckboxItem, {
2166
- "data-slot": "dropdown-menu-checkbox-item",
2167
- className: clsx$1("univer-relative univer-flex univer-cursor-default univer-select-none univer-items-center univer-rounded univer-py-1.5 univer-pr-2 univer-text-sm univer-outline-none univer-transition-colors data-[disabled]:univer-pointer-events-none data-[disabled]:univer-opacity-50 focus:univer-bg-gray-100 dark:focus:!univer-bg-gray-600", {
2168
- "univer-pl-8": !hideIndicator,
2169
- "univer-pl-2": hideIndicator
2170
- }, className),
2171
- checked,
2172
- ...props,
2173
- children: [!hideIndicator && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2174
- className: "univer-absolute univer-left-2 univer-flex univer-size-3.5 univer-items-center univer-justify-center",
2175
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.ItemIndicator, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.CheckMarkIcon, { className: "univer-block univer-size-4 univer-fill-current univer-text-primary-600" }) })
2176
- }), children]
2177
- });
2178
- }
2179
- function DropdownMenuRadioItem({ className, children, hideIndicator, ...props }) {
2180
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_radix_ui_react_dropdown_menu.RadioItem, {
2181
- "data-slot": "dropdown-menu-radio-item",
2182
- className: clsx$1("univer-relative univer-flex univer-cursor-default univer-select-none univer-items-center univer-rounded univer-py-1.5 univer-pr-2 univer-text-sm univer-outline-none univer-transition-colors data-[disabled]:univer-pointer-events-none data-[disabled]:univer-opacity-50 focus:univer-bg-gray-100 dark:focus:!univer-bg-gray-600", {
2183
- "univer-pl-8": !hideIndicator,
2184
- "univer-pl-2": hideIndicator
2185
- }, className),
2186
- ...props,
2187
- children: [!hideIndicator && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2188
- className: "univer-absolute univer-left-2 univer-flex univer-size-3.5 univer-items-center univer-justify-center",
2189
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.ItemIndicator, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.CheckMarkIcon, { className: "univer-block univer-size-4 univer-fill-current univer-text-primary-600" }) })
2190
- }), children]
2191
- });
2192
- }
2193
- function DropdownMenuSeparator({ className, ...props }) {
2194
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.Separator, {
2195
- className: clsx$1("-univer-mx-1 univer-my-1 univer-h-px univer-bg-gray-200 dark:!univer-bg-gray-600", className),
2196
- ...props
2197
- });
2198
- }
2199
-
2200
- //#endregion
2201
- //#region src/components/dropdown-menu/DropdownMenu.tsx
2202
- function DropdownMenu(props) {
2203
- const { children, items, disabled, open: controlledOpen, onOpenChange: controlledOnOpenChange, ...restProps } = props;
2204
- const [uncontrolledOpen, setUncontrolledOpen] = (0, react.useState)(false);
2205
- const isControlled = controlledOpen !== void 0;
2206
- const open = isControlled ? controlledOpen : uncontrolledOpen;
2207
- function handleChangeOpen(newOpen) {
2208
- if (disabled) return;
2209
- if (!isControlled) setUncontrolledOpen(newOpen);
2210
- controlledOnOpenChange === null || controlledOnOpenChange === void 0 || controlledOnOpenChange(newOpen);
2211
- }
2212
- function renderMenuItem(item, index) {
2213
- const { className, type } = item;
2214
- if (type === "separator") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuSeparator, { className }, index);
2215
- else if (type === "radio") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuRadioGroup, {
2216
- className,
2217
- value: item.value,
2218
- onValueChange: item.onSelect,
2219
- children: item.options.map((option, index) => {
2220
- if ("type" in option) {
2221
- if (option.type === "separator") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuSeparator, { className: option.className }, index);
2222
- } else {
2223
- if (option.value === void 0) throw new Error("[DropdownMenu]: `value` is required");
2224
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuRadioItem, {
2225
- value: option.value,
2226
- disabled: option.disabled,
2227
- hideIndicator: item.hideIndicator,
2228
- children: option.label
2229
- }, option.value);
2230
- }
2231
- return null;
2232
- })
2233
- }, index);
2234
- else if (type === "checkbox") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuCheckboxItem, {
2235
- className,
2236
- disabled: item.disabled,
2237
- checked: item.checked,
2238
- onSelect: () => {
2239
- var _item$onSelect;
2240
- (_item$onSelect = item.onSelect) === null || _item$onSelect === void 0 || _item$onSelect.call(item, item.value);
2241
- },
2242
- children: item.label
2243
- }, index);
2244
- else if (type === "item") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuItem, {
2245
- className,
2246
- disabled: item.disabled,
2247
- onSelect: () => {
2248
- var _item$onSelect2;
2249
- (_item$onSelect2 = item.onSelect) === null || _item$onSelect2 === void 0 || _item$onSelect2.call(item, item);
2250
- },
2251
- children: item.children
2252
- }, index);
2253
- else if (type === "subItem") {
2254
- var _item$options;
2255
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DropdownMenuSub, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuSubTrigger, { children: item.children }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuPortal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuSubContent, {
2256
- sideOffset: 12,
2257
- children: (_item$options = item.options) === null || _item$options === void 0 ? void 0 : _item$options.map((subItem, subIndex) => renderMenuItem(subItem, subIndex))
2258
- }) })] }, index);
2259
- }
2260
- }
2261
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DropdownMenuPrimitive, {
2262
- modal: false,
2263
- open,
2264
- onOpenChange: handleChangeOpen,
2265
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuTrigger, {
2266
- asChild: true,
2267
- children
2268
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuContent, {
2269
- className: "univer-text-sm",
2270
- collisionPadding: {
2271
- top: 12,
2272
- bottom: 12
2273
- },
2274
- onWheel: (e) => e.stopPropagation(),
2275
- ...restProps,
2276
- children: items.map((item, index) => renderMenuItem(item, index))
2277
- })]
2187
+ //#region src/components/draggable-list/DraggableList.tsx
2188
+ function moveItemByIndex(list, fromIndex, toIndex) {
2189
+ if (fromIndex === toIndex || fromIndex < 0 || toIndex < 0 || fromIndex >= list.length || toIndex >= list.length) return list;
2190
+ const next = [...list];
2191
+ const [item] = next.splice(fromIndex, 1);
2192
+ next.splice(toIndex, 0, item);
2193
+ return next;
2194
+ }
2195
+ function DraggableList(props) {
2196
+ const { list, onListChange, idKey, itemRender, className, style, draggableHandle, rowHeight, margin = [0, 0], onDragStart, onDragStop, ...restProps } = props;
2197
+ const [displayList, setDisplayList] = (0, react.useState)(list);
2198
+ const displayListRef = (0, react.useRef)(list);
2199
+ const [draggingId, setDraggingId] = (0, react.useState)(null);
2200
+ const [dragOverId, setDragOverId] = (0, react.useState)(null);
2201
+ const [ghostElement, setGhostElement] = (0, react.useState)(null);
2202
+ const [ghostPosition, setGhostPosition] = (0, react.useState)(null);
2203
+ const [canUsePortal, setCanUsePortal] = (0, react.useState)(false);
2204
+ const pointerIdRef = (0, react.useRef)(null);
2205
+ const dragPointerOffsetRef = (0, react.useRef)({
2206
+ x: 0,
2207
+ y: 0
2208
+ });
2209
+ const dragItemSizeRef = (0, react.useRef)({
2210
+ width: 0,
2211
+ height: 0
2278
2212
  });
2213
+ const ghostContainerRef = (0, react.useRef)(null);
2214
+ const pressedHandleIdRef = (0, react.useRef)(null);
2215
+ const dragSourceIdRef = (0, react.useRef)(null);
2216
+ const dragStartIndexRef = (0, react.useRef)(-1);
2217
+ const { direction } = (0, react.useContext)(ConfigContext);
2218
+ (0, react.useEffect)(() => {
2219
+ if (!draggingId) {
2220
+ setDisplayList(list);
2221
+ displayListRef.current = list;
2222
+ }
2223
+ }, [draggingId, list]);
2224
+ (0, react.useEffect)(() => {
2225
+ setCanUsePortal(typeof document !== "undefined");
2226
+ }, []);
2227
+ (0, react.useEffect)(() => {
2228
+ const container = ghostContainerRef.current;
2229
+ if (!container) return;
2230
+ container.replaceChildren();
2231
+ if (ghostElement) container.appendChild(ghostElement);
2232
+ }, [ghostElement]);
2233
+ (0, react.useEffect)(() => {
2234
+ if (!draggingId) return;
2235
+ const handlePointerMove = (evt) => {
2236
+ const sourceId = dragSourceIdRef.current;
2237
+ if (!sourceId || pointerIdRef.current !== evt.pointerId) return;
2238
+ setGhostPosition({
2239
+ x: evt.clientX - dragPointerOffsetRef.current.x,
2240
+ y: evt.clientY - dragPointerOffsetRef.current.y
2241
+ });
2242
+ const element = document.elementFromPoint(evt.clientX, evt.clientY);
2243
+ const itemElement = element === null || element === void 0 ? void 0 : element.closest("[data-draggable-list-item-id]");
2244
+ const targetId = itemElement === null || itemElement === void 0 ? void 0 : itemElement.dataset.draggableListItemId;
2245
+ if (!targetId || targetId === sourceId) return;
2246
+ setDragOverId(targetId);
2247
+ setDisplayList((prev) => {
2248
+ const fromIndex = prev.findIndex((it) => getItemId(it) === sourceId);
2249
+ const toIndex = prev.findIndex((it) => getItemId(it) === targetId);
2250
+ if (fromIndex < 0 || toIndex < 0 || fromIndex === toIndex) return prev;
2251
+ const next = moveItemByIndex(prev, fromIndex, toIndex);
2252
+ displayListRef.current = next;
2253
+ return next;
2254
+ });
2255
+ };
2256
+ const handlePointerUp = (evt) => {
2257
+ if (pointerIdRef.current !== evt.pointerId) return;
2258
+ const sourceId = dragSourceIdRef.current;
2259
+ const startIndex = dragStartIndexRef.current;
2260
+ const currentList = displayListRef.current;
2261
+ if (sourceId) {
2262
+ const finalIndex = currentList.findIndex((it) => getItemId(it) === sourceId);
2263
+ onDragStop === null || onDragStop === void 0 || onDragStop(void 0, { y: startIndex }, { y: finalIndex });
2264
+ if (startIndex >= 0) onListChange([...currentList]);
2265
+ }
2266
+ pointerIdRef.current = null;
2267
+ pressedHandleIdRef.current = null;
2268
+ dragSourceIdRef.current = null;
2269
+ dragStartIndexRef.current = -1;
2270
+ setDragOverId(null);
2271
+ setGhostElement(null);
2272
+ setGhostPosition(null);
2273
+ setDraggingId(null);
2274
+ };
2275
+ window.addEventListener("pointermove", handlePointerMove);
2276
+ window.addEventListener("pointerup", handlePointerUp);
2277
+ window.addEventListener("pointercancel", handlePointerUp);
2278
+ return () => {
2279
+ window.removeEventListener("pointermove", handlePointerMove);
2280
+ window.removeEventListener("pointerup", handlePointerUp);
2281
+ window.removeEventListener("pointercancel", handlePointerUp);
2282
+ };
2283
+ }, [
2284
+ draggingId,
2285
+ onDragStop,
2286
+ onListChange
2287
+ ]);
2288
+ const gapStyle = (0, react.useMemo)(() => {
2289
+ const [horizontal, vertical] = margin;
2290
+ return {
2291
+ rowGap: `${vertical}px`,
2292
+ paddingLeft: horizontal ? `${horizontal}px` : void 0,
2293
+ paddingRight: horizontal ? `${horizontal}px` : void 0,
2294
+ ...style
2295
+ };
2296
+ }, [margin, style]);
2297
+ const getItemId = (item) => String(item[idKey]);
2298
+ const draggingItem = draggingId ? displayList.find((item) => getItemId(item) === draggingId) : null;
2299
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2300
+ ...restProps,
2301
+ className: clsx$1("univer-flex univer-flex-col", draggingId && "univer-cursor-grabbing univer-select-none", className),
2302
+ style: gapStyle,
2303
+ children: displayList.map((item, index) => {
2304
+ const itemId = getItemId(item);
2305
+ const isDraggingItem = draggingId === itemId;
2306
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2307
+ "data-draggable-list-item-id": itemId,
2308
+ className: clsx$1("univer-relative univer-transition-all univer-duration-150", isDraggingItem && "univer-opacity-0", dragOverId === itemId && !isDraggingItem && "univer-bg-primary-50/60 dark:!univer-bg-primary-900/20 univer-rounded univer-border univer-border-primary-200 dark:!univer-border-primary-700"),
2309
+ onPointerDownCapture: (e) => {
2310
+ if (pointerIdRef.current !== null) return;
2311
+ if (!draggableHandle) pressedHandleIdRef.current = itemId;
2312
+ else pressedHandleIdRef.current = !!e.target.closest(draggableHandle) ? itemId : null;
2313
+ if (pressedHandleIdRef.current !== itemId) return;
2314
+ const rect = e.currentTarget.getBoundingClientRect();
2315
+ dragPointerOffsetRef.current = {
2316
+ x: e.clientX - rect.left,
2317
+ y: e.clientY - rect.top
2318
+ };
2319
+ dragItemSizeRef.current = {
2320
+ width: rect.width,
2321
+ height: rect.height
2322
+ };
2323
+ setGhostPosition({
2324
+ x: rect.left,
2325
+ y: rect.top
2326
+ });
2327
+ setGhostElement(e.currentTarget.cloneNode(true));
2328
+ pointerIdRef.current = e.pointerId;
2329
+ dragSourceIdRef.current = itemId;
2330
+ dragStartIndexRef.current = index;
2331
+ setDraggingId(itemId);
2332
+ displayListRef.current = displayList;
2333
+ onDragStart === null || onDragStart === void 0 || onDragStart(void 0, { y: index });
2334
+ e.preventDefault();
2335
+ e.currentTarget.setPointerCapture(e.pointerId);
2336
+ },
2337
+ style: {
2338
+ ...rowHeight ? { minHeight: `${rowHeight}px` } : void 0,
2339
+ cursor: draggingId ? "grabbing" : void 0
2340
+ },
2341
+ children: [isDraggingItem && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "univer-bg-primary-50/50 univer-absolute univer-inset-0 univer-rounded univer-border univer-border-dashed univer-border-primary-300" }), itemRender(item, index)]
2342
+ }, itemId);
2343
+ })
2344
+ }), canUsePortal && draggingItem && ghostPosition && (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2345
+ dir: direction,
2346
+ className: clsx$1("univer-pointer-events-none univer-fixed univer-rounded-md univer-border univer-border-gray-200 univer-bg-white univer-shadow-lg dark:!univer-border-gray-700 dark:!univer-bg-gray-800"),
2347
+ style: {
2348
+ zIndex: 2147483647,
2349
+ left: `${ghostPosition.x}px`,
2350
+ top: `${ghostPosition.y}px`,
2351
+ width: `${dragItemSizeRef.current.width}px`,
2352
+ height: `${dragItemSizeRef.current.height}px`,
2353
+ opacity: .95
2354
+ },
2355
+ children: ghostElement ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { ref: ghostContainerRef }) : itemRender(draggingItem, displayList.findIndex((item) => getItemId(item) === getItemId(draggingItem)))
2356
+ }), document.body)] });
2279
2357
  }
2280
2358
 
2281
2359
  //#endregion
@@ -2469,7 +2547,7 @@ function Gallery(props) {
2469
2547
  "aria-label": "Image gallery",
2470
2548
  tabIndex: -1,
2471
2549
  ref: dialogRef,
2472
- className: clsx$1("univer-absolute univer-inset-0 univer-z-[1080] univer-flex univer-size-full univer-select-none univer-items-center univer-justify-center", {
2550
+ className: clsx$1("univer-fixed univer-inset-0 univer-z-[1080] univer-flex univer-h-screen univer-w-screen univer-select-none univer-items-center univer-justify-center", {
2473
2551
  "univer-animate-in univer-fade-in": open,
2474
2552
  "univer-animate-out univer-fade-out": !open
2475
2553
  }, className),
@@ -2480,9 +2558,9 @@ function Gallery(props) {
2480
2558
  onClick: () => onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(false)
2481
2559
  }),
2482
2560
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2483
- className: "univer-relative",
2561
+ className: "univer-relative univer-flex univer-w-fit univer-items-center univer-justify-center",
2484
2562
  children: activeImage && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
2485
- className: "univer-max-h-[40vh] univer-max-w-[60vw] univer-transition-transform univer-duration-300 univer-ease-out",
2563
+ className: "univer-h-full univer-w-full univer-object-contain univer-transition-transform univer-duration-300 univer-ease-out",
2486
2564
  style: { transform: `scale(${zoomLevel})` },
2487
2565
  src: activeImage,
2488
2566
  alt: `Image ${activeImageIndex + 1} of ${images.length}`,
@@ -2527,13 +2605,7 @@ function Gallery(props) {
2527
2605
 
2528
2606
  //#endregion
2529
2607
  //#region src/components/input/Input.tsx
2530
- const inputVariants = (0, class_variance_authority.cva)(`
2531
- univer-box-border univer-w-full univer-rounded-md univer-bg-white univer-transition-colors univer-duration-200
2532
- placeholder:univer-text-gray-400
2533
- focus:univer-border-primary-600 focus:univer-outline-none focus:univer-ring-2 focus:univer-ring-primary-50
2534
- dark:!univer-bg-gray-700 dark:!univer-text-white
2535
- dark:focus:!univer-ring-primary-900
2536
- `, {
2608
+ const inputVariants = (0, class_variance_authority.cva)("univer-box-border univer-w-full univer-rounded-md univer-bg-white univer-transition-colors univer-duration-200 placeholder:univer-text-gray-400 focus:univer-border-primary-600 focus:univer-outline-none focus:univer-ring-2 focus:univer-ring-primary-50 dark:!univer-bg-gray-700 dark:!univer-text-white dark:focus:!univer-ring-primary-900", {
2537
2609
  variants: { size: {
2538
2610
  mini: "univer-h-7 univer-px-1.5 univer-text-sm",
2539
2611
  small: "univer-h-8 univer-px-2 univer-text-sm",
@@ -2584,10 +2656,7 @@ const Input = (0, react.forwardRef)(({ autoFocus = false, className, style, type
2584
2656
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2585
2657
  ref,
2586
2658
  type,
2587
- className: clsx$1(inputVariants({ size }), borderClassName, disabled && `
2588
- univer-cursor-not-allowed univer-bg-gray-50 univer-text-gray-400
2589
- dark:!univer-text-gray-500
2590
- `, allowClear && !slot && "univer-pr-8", inputClass),
2659
+ className: clsx$1(inputVariants({ size }), borderClassName, disabled && "univer-cursor-not-allowed univer-bg-gray-50 univer-text-gray-400 dark:!univer-text-gray-500", allowClear && !slot && "univer-pr-8", inputClass),
2591
2660
  placeholder,
2592
2661
  value,
2593
2662
  disabled,
@@ -2652,7 +2721,7 @@ const InputNumber = (0, react.forwardRef)(({ value, defaultValue, size = "small"
2652
2721
  if (formatter) return formatter(formattedValue);
2653
2722
  return String(formattedValue);
2654
2723
  }
2655
- function parseValue(val) {
2724
+ function parseNumberValue(val) {
2656
2725
  if (!val) return null;
2657
2726
  let parsedValue = val;
2658
2727
  if (parser) parsedValue = parser(val);
@@ -2671,21 +2740,27 @@ const InputNumber = (0, react.forwardRef)(({ value, defaultValue, size = "small"
2671
2740
  else result = roundedNum;
2672
2741
  } else if (num.toString().includes("e")) result = Number.parseFloat(num.toFixed(16).replace(/\.?0+$/, ""));
2673
2742
  else result = num;
2674
- if (max !== void 0 && result > max) result = max;
2675
- if (min !== void 0 && result < min) result = min;
2676
2743
  return result;
2677
2744
  } catch (e) {
2678
2745
  return null;
2679
2746
  }
2680
2747
  }
2748
+ function clampValue(val) {
2749
+ if (val === null) return null;
2750
+ if (max !== void 0 && val > max) return max;
2751
+ if (min !== void 0 && val < min) return min;
2752
+ return val;
2753
+ }
2681
2754
  function handleInputChange(value) {
2682
- setInputValue(value);
2683
2755
  if (allowEmpty && value === "") {
2756
+ setInputValue(value);
2684
2757
  setInternalValue(null);
2685
2758
  onChange === null || onChange === void 0 || onChange(null);
2686
2759
  return;
2687
2760
  }
2688
- const parsedValue = parseValue(value);
2761
+ const parsedNumber = parseNumberValue(value);
2762
+ const parsedValue = clampValue(parsedNumber);
2763
+ setInputValue(parsedNumber !== null && parsedValue !== parsedNumber ? formatValue(parsedValue) : value);
2689
2764
  setInternalValue(parsedValue);
2690
2765
  onChange === null || onChange === void 0 || onChange(parsedValue);
2691
2766
  }
@@ -2834,7 +2909,7 @@ function Segmented({ items, value, defaultValue, onChange, className = "" }) {
2834
2909
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2835
2910
  "data-u-comp": "segmented",
2836
2911
  ref: containerRef,
2837
- className: clsx$1("univer-relative univer-box-border univer-flex univer-gap-4 univer-rounded-lg univer-bg-gray-100 univer-p-1 dark:!univer-bg-gray-800", className),
2912
+ className: clsx$1("univer-relative univer-box-border univer-flex univer-min-w-0 univer-gap-1 univer-rounded-lg univer-bg-gray-100 univer-p-1 dark:!univer-bg-gray-800", className),
2838
2913
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2839
2914
  className: "univer-animate-univer-slide univer-absolute univer-h-6 univer-rounded-md univer-bg-white univer-shadow-sm univer-transition-all univer-duration-200 dark:!univer-bg-gray-700 dark:!univer-text-gray-400",
2840
2915
  style: slideStyle
@@ -2842,7 +2917,7 @@ function Segmented({ items, value, defaultValue, onChange, className = "" }) {
2842
2917
  ref: (el) => {
2843
2918
  if (el) itemRefs.current.set(item.value, el);
2844
2919
  },
2845
- className: clsx$1("univer-relative univer-box-border univer-flex-1 univer-cursor-pointer univer-border-none univer-bg-transparent univer-px-3 univer-py-1 univer-text-xs univer-font-medium univer-transition-colors", {
2920
+ className: clsx$1("univer-relative univer-box-border univer-min-w-0 univer-flex-1 univer-cursor-pointer univer-truncate univer-border-none univer-bg-transparent univer-px-3 univer-py-1 univer-text-xs univer-font-medium univer-transition-colors", {
2846
2921
  "univer-text-gray-900 dark:!univer-text-white": selectedItem === item.value,
2847
2922
  "univer-text-gray-500 hover:univer-text-gray-900 dark:hover:!univer-text-white": selectedItem !== item.value
2848
2923
  }),
@@ -2988,7 +3063,7 @@ function Tooltip(props) {
2988
3063
  };
2989
3064
  const triggerElement = asChild ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2990
3065
  ...commonProps,
2991
- className: "univer-inline-block univer-max-w-full univer-truncate",
3066
+ className: "univer-inline-flex univer-max-w-full univer-items-center univer-truncate",
2992
3067
  children
2993
3068
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2994
3069
  type: "button",
@@ -3069,21 +3144,68 @@ const DEFAULT_VALUE = {
3069
3144
  color: "#000000",
3070
3145
  offset: 100
3071
3146
  }],
3072
- angle: 90
3147
+ angle: 0
3073
3148
  };
3149
+ function clamp(value, min, max) {
3150
+ return Math.max(min, Math.min(max, value));
3151
+ }
3152
+ function getStopOpacity(stop) {
3153
+ var _stop$opacity;
3154
+ return clamp((_stop$opacity = stop === null || stop === void 0 ? void 0 : stop.opacity) !== null && _stop$opacity !== void 0 ? _stop$opacity : 1, 0, 1);
3155
+ }
3156
+ function getColorWithOpacity(color, opacity) {
3157
+ if (opacity >= 1) return color;
3158
+ const value = color.trim();
3159
+ if (/^#[0-9a-f]{3}$/i.test(value)) {
3160
+ const [, r, g, b] = value;
3161
+ return `rgba(${Number.parseInt(r + r, 16)}, ${Number.parseInt(g + g, 16)}, ${Number.parseInt(b + b, 16)}, ${opacity})`;
3162
+ }
3163
+ if (/^#[0-9a-f]{6}$/i.test(value)) return `rgba(${Number.parseInt(value.slice(1, 3), 16)}, ${Number.parseInt(value.slice(3, 5), 16)}, ${Number.parseInt(value.slice(5, 7), 16)}, ${opacity})`;
3164
+ const rgba = /^rgba?\(([^)]+)\)$/i.exec(value);
3165
+ if (rgba) {
3166
+ const parts = rgba[1].split(",").map((part) => part.trim());
3167
+ const baseAlpha = parts[3] === void 0 ? 1 : Number.parseFloat(parts[3]);
3168
+ const alpha = Number.isFinite(baseAlpha) ? clamp(baseAlpha * opacity, 0, 1) : opacity;
3169
+ return `rgba(${parts[0]}, ${parts[1]}, ${parts[2]}, ${alpha})`;
3170
+ }
3171
+ return color;
3172
+ }
3173
+ function getStopColor(stop) {
3174
+ return getColorWithOpacity(stop.color, getStopOpacity(stop));
3175
+ }
3176
+ function getGradientAngle(value) {
3177
+ var _ref, _value$angle;
3178
+ return (_ref = (_value$angle = value.angle) !== null && _value$angle !== void 0 ? _value$angle : DEFAULT_VALUE.angle) !== null && _ref !== void 0 ? _ref : 0;
3179
+ }
3180
+ function getCssLinearGradientAngle(value) {
3181
+ return (getGradientAngle(value) + 90) % 360;
3182
+ }
3074
3183
  function GradientColorPicker(props) {
3075
- var _value$stops$selected, _value$stops$selected2;
3076
- const { className, value = DEFAULT_VALUE, onChange } = props;
3184
+ var _draftValue$stops$sel, _locale$GradientColor, _draftValue$stops$sel2;
3185
+ const { className, compact = false, value = DEFAULT_VALUE, onChange } = props;
3077
3186
  const { locale } = (0, react.useContext)(ConfigContext);
3187
+ const [draftValue, setDraftValue] = (0, react.useState)(value);
3078
3188
  const [selectedIndex, setSelectedIndex] = (0, react.useState)(0);
3079
3189
  const barRef = (0, react.useRef)(null);
3190
+ const valueRef = (0, react.useRef)(value);
3080
3191
  const cleanupRef = (0, react.useRef)(null);
3192
+ (0, react.useEffect)(() => {
3193
+ valueRef.current = draftValue;
3194
+ }, [draftValue]);
3195
+ (0, react.useEffect)(() => {
3196
+ setDraftValue(value);
3197
+ }, [value]);
3198
+ const emitChange = (nextValue) => {
3199
+ valueRef.current = nextValue;
3200
+ setDraftValue(nextValue);
3201
+ onChange === null || onChange === void 0 || onChange(nextValue);
3202
+ };
3081
3203
  (0, react.useEffect)(() => {
3082
3204
  setSelectedIndex((prev) => {
3083
- if (prev >= value.stops.length) return Math.max(0, value.stops.length - 1);
3205
+ if (prev >= draftValue.stops.length) return Math.max(0, draftValue.stops.length - 1);
3084
3206
  return prev;
3085
3207
  });
3086
- }, [value.stops.length]);
3208
+ }, [draftValue.stops.length]);
3087
3209
  (0, react.useEffect)(() => {
3088
3210
  return () => {
3089
3211
  var _cleanupRef$current;
@@ -3091,40 +3213,52 @@ function GradientColorPicker(props) {
3091
3213
  };
3092
3214
  }, []);
3093
3215
  const stops = (0, react.useMemo)(() => {
3094
- return [...value.stops].sort((a, b) => a.offset - b.offset);
3095
- }, [value.stops]);
3216
+ return [...draftValue.stops].sort((a, b) => a.offset - b.offset);
3217
+ }, [draftValue.stops]);
3096
3218
  const handleTypeChange = (type) => {
3097
- onChange === null || onChange === void 0 || onChange({
3098
- ...value,
3219
+ emitChange({
3220
+ ...valueRef.current,
3099
3221
  type
3100
3222
  });
3101
3223
  };
3102
3224
  const handleAngleChange = (angle) => {
3103
- onChange === null || onChange === void 0 || onChange({
3104
- ...value,
3225
+ emitChange({
3226
+ ...valueRef.current,
3105
3227
  angle: angle !== null && angle !== void 0 ? angle : 0
3106
3228
  });
3107
3229
  };
3108
3230
  const handleStopColorChange = (color) => {
3109
- const newStops = [...value.stops];
3231
+ const newStops = [...valueRef.current.stops];
3110
3232
  newStops[selectedIndex] = {
3111
3233
  ...newStops[selectedIndex],
3112
3234
  color
3113
3235
  };
3114
- onChange === null || onChange === void 0 || onChange({
3115
- ...value,
3236
+ emitChange({
3237
+ ...valueRef.current,
3116
3238
  stops: newStops
3117
3239
  });
3118
3240
  };
3119
3241
  const handleStopOffsetChange = (offset) => {
3120
3242
  if (offset === null) return;
3121
- const newStops = [...value.stops];
3243
+ const newStops = [...valueRef.current.stops];
3122
3244
  newStops[selectedIndex] = {
3123
3245
  ...newStops[selectedIndex],
3124
3246
  offset
3125
3247
  };
3126
- onChange === null || onChange === void 0 || onChange({
3127
- ...value,
3248
+ emitChange({
3249
+ ...valueRef.current,
3250
+ stops: newStops
3251
+ });
3252
+ };
3253
+ const handleStopTransparencyChange = (transparency) => {
3254
+ const nextTransparency = clamp(transparency !== null && transparency !== void 0 ? transparency : 0, 0, 100);
3255
+ const newStops = [...valueRef.current.stops];
3256
+ newStops[selectedIndex] = {
3257
+ ...newStops[selectedIndex],
3258
+ opacity: (100 - nextTransparency) / 100
3259
+ };
3260
+ emitChange({
3261
+ ...valueRef.current,
3128
3262
  stops: newStops
3129
3263
  });
3130
3264
  };
@@ -3132,43 +3266,77 @@ function GradientColorPicker(props) {
3132
3266
  if (!barRef.current) return;
3133
3267
  const rect = barRef.current.getBoundingClientRect();
3134
3268
  const offset = Math.round((e.clientX - rect.left) / rect.width * 100);
3269
+ const leftStop = [...stops].reverse().find((s) => s.offset <= offset) || stops[0];
3135
3270
  const newStop = {
3136
- color: ([...stops].reverse().find((s) => s.offset <= offset) || stops[0]).color,
3137
- offset
3271
+ color: leftStop.color,
3272
+ offset,
3273
+ opacity: getStopOpacity(leftStop)
3138
3274
  };
3139
- const newStops = [...value.stops, newStop];
3140
- onChange === null || onChange === void 0 || onChange({
3141
- ...value,
3275
+ const newStops = [...valueRef.current.stops, newStop];
3276
+ emitChange({
3277
+ ...valueRef.current,
3142
3278
  stops: newStops
3143
3279
  });
3144
3280
  setSelectedIndex(newStops.length - 1);
3145
3281
  };
3146
3282
  const handleRemoveStop = () => {
3147
- if (value.stops.length <= 2) return;
3148
- const newStops = value.stops.filter((_, i) => i !== selectedIndex);
3149
- onChange === null || onChange === void 0 || onChange({
3150
- ...value,
3283
+ if (draftValue.stops.length <= 2) return;
3284
+ const newStops = valueRef.current.stops.filter((_, i) => i !== selectedIndex);
3285
+ emitChange({
3286
+ ...valueRef.current,
3151
3287
  stops: newStops
3152
3288
  });
3153
3289
  setSelectedIndex(0);
3154
3290
  };
3155
3291
  const gradientPreview = (0, react.useMemo)(() => {
3156
- return `linear-gradient(to right, ${stops.map((s) => `${s.color} ${s.offset}%`).join(", ")})`;
3292
+ return `linear-gradient(to right, ${stops.map((s) => `${getStopColor(s)} ${s.offset}%`).join(", ")})`;
3157
3293
  }, [stops]);
3158
3294
  const mainPreview = (0, react.useMemo)(() => {
3159
- const stopsStr = stops.map((s) => `${s.color} ${s.offset}%`).join(", ");
3160
- switch (value.type) {
3161
- case "linear": return `linear-gradient(${value.angle}deg, ${stopsStr})`;
3295
+ const stopsStr = stops.map((s) => `${getStopColor(s)} ${s.offset}%`).join(", ");
3296
+ switch (draftValue.type) {
3297
+ case "linear": return `linear-gradient(${getCssLinearGradientAngle(draftValue)}deg, ${stopsStr})`;
3162
3298
  case "radial": return `radial-gradient(circle, ${stopsStr})`;
3163
- case "angular": return `conic-gradient(from ${value.angle}deg, ${stopsStr})`;
3299
+ case "angular": return `conic-gradient(from ${getGradientAngle(draftValue)}deg, ${stopsStr})`;
3164
3300
  case "diamond": return `radial-gradient(circle, ${stopsStr})`;
3165
- default: return `linear-gradient(${value.angle}deg, ${stopsStr})`;
3301
+ default: return `linear-gradient(${getCssLinearGradientAngle(draftValue)}deg, ${stopsStr})`;
3166
3302
  }
3167
- }, [value, stops]);
3303
+ }, [draftValue, stops]);
3304
+ const showAngleEditor = draftValue.type === "linear" || draftValue.type === "angular";
3168
3305
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3169
- className: clsx$1("univer-flex univer-w-64 univer-flex-col univer-gap-4 univer-rounded-lg univer-bg-white univer-p-4 univer-shadow-lg dark:!univer-bg-gray-800", className),
3306
+ className: clsx$1(compact ? "univer-flex univer-w-full univer-min-w-0 univer-flex-col univer-gap-3 univer-rounded-md univer-bg-transparent univer-p-0 dark:!univer-bg-transparent" : "univer-flex univer-w-full univer-min-w-0 univer-max-w-80 univer-flex-col univer-gap-4 univer-rounded-lg univer-bg-white univer-p-4 univer-shadow-lg dark:!univer-bg-gray-800", className),
3307
+ onClick: (e) => e.stopPropagation(),
3308
+ onPointerDown: (e) => e.stopPropagation(),
3170
3309
  children: [
3171
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Segmented, {
3310
+ compact ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3311
+ className: "univer-flex univer-min-w-0 univer-items-center univer-gap-4 univer-border-b univer-border-gray-100 dark:!univer-border-gray-700",
3312
+ children: [
3313
+ {
3314
+ label: locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.linear,
3315
+ value: "linear"
3316
+ },
3317
+ {
3318
+ label: locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.radial,
3319
+ value: "radial"
3320
+ },
3321
+ {
3322
+ label: locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.angular,
3323
+ value: "angular"
3324
+ },
3325
+ {
3326
+ label: locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.diamond,
3327
+ value: "diamond"
3328
+ }
3329
+ ].map((item) => {
3330
+ const selected = draftValue.type === item.value;
3331
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
3332
+ type: "button",
3333
+ className: clsx$1("univer-relative univer-min-w-0 univer-flex-1 univer-cursor-pointer univer-truncate univer-border-none univer-bg-transparent univer-px-0 univer-pb-2 univer-pt-0 univer-text-xs univer-transition-colors", selected ? "univer-font-medium univer-text-primary-600 dark:!univer-text-primary-300" : "univer-text-gray-500 hover:univer-text-gray-900 dark:hover:!univer-text-white"),
3334
+ onClick: () => handleTypeChange(item.value),
3335
+ children: [item.label, selected && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "univer-absolute univer-inset-x-2 -univer-bottom-px univer-h-0.5 univer-rounded-full univer-bg-primary-600 dark:!univer-bg-primary-300" })]
3336
+ }, item.value);
3337
+ })
3338
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Segmented, {
3339
+ className: "univer-w-full univer-min-w-0 univer-gap-1 univer-overflow-hidden",
3172
3340
  items: [
3173
3341
  {
3174
3342
  label: locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.linear,
@@ -3187,49 +3355,67 @@ function GradientColorPicker(props) {
3187
3355
  value: "diamond"
3188
3356
  }
3189
3357
  ],
3190
- value: value.type,
3358
+ value: draftValue.type,
3191
3359
  onChange: (v) => handleTypeChange(v)
3192
3360
  }),
3361
+ showAngleEditor && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3362
+ "data-u-comp": "gradient-color-picker-angle",
3363
+ className: "univer-flex univer-items-center univer-justify-between univer-gap-3",
3364
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3365
+ className: "univer-text-xs univer-text-gray-500",
3366
+ children: locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.angle
3367
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InputNumber, {
3368
+ className: "univer-w-24",
3369
+ value: getGradientAngle(draftValue),
3370
+ min: 0,
3371
+ max: 360,
3372
+ onChange: handleAngleChange
3373
+ })]
3374
+ }),
3193
3375
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3194
3376
  "data-u-comp": "gradient-color-picker-preview",
3195
- className: "univer-h-32 univer-w-full univer-rounded-md univer-border univer-border-gray-200 dark:!univer-border-gray-600",
3377
+ className: clsx$1("univer-w-full univer-rounded-md univer-border univer-border-gray-200 dark:!univer-border-gray-600", compact ? "univer-h-20" : "univer-h-32"),
3196
3378
  style: { background: mainPreview }
3197
3379
  }),
3198
3380
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3199
- className: "univer-relative univer-mt-4 univer-h-6",
3381
+ className: clsx$1("univer-relative univer-h-6", compact ? "univer-mt-1" : "univer-mt-4"),
3200
3382
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3201
3383
  ref: barRef,
3202
3384
  "data-u-comp": "gradient-color-picker-bar",
3203
3385
  className: "univer-absolute univer-inset-x-0 univer-top-1/2 univer-h-2 -univer-translate-y-1/2 univer-cursor-crosshair univer-rounded-full",
3204
3386
  style: { background: gradientPreview },
3205
3387
  onClick: handleAddStop
3206
- }), value.stops.map((stop, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3388
+ }), draftValue.stops.map((stop, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3207
3389
  "data-u-comp": "gradient-color-picker-stop",
3208
3390
  "data-selected": selectedIndex === index,
3209
3391
  className: clsx$1("univer-absolute univer-top-1/2 univer-size-4 -univer-translate-x-1/2 -univer-translate-y-1/2 univer-cursor-pointer univer-rounded-full univer-border-2 univer-border-white univer-shadow-md", selectedIndex === index ? "univer-z-10 univer-ring-2 univer-ring-primary-500" : "univer-z-0"),
3210
3392
  style: {
3211
3393
  left: `${stop.offset}%`,
3212
- backgroundColor: stop.color
3394
+ backgroundColor: getStopColor(stop)
3213
3395
  },
3214
3396
  onClick: (e) => {
3215
3397
  e.stopPropagation();
3216
3398
  setSelectedIndex(index);
3217
3399
  },
3218
3400
  onPointerDown: (e) => {
3401
+ e.preventDefault();
3402
+ e.stopPropagation();
3219
3403
  const startX = e.clientX;
3220
3404
  const startOffset = stop.offset;
3405
+ setSelectedIndex(index);
3221
3406
  const handlePointerMove = (moveEvent) => {
3222
3407
  if (!barRef.current) return;
3408
+ moveEvent.preventDefault();
3223
3409
  const rect = barRef.current.getBoundingClientRect();
3224
3410
  const deltaOffset = (moveEvent.clientX - startX) / rect.width * 100;
3225
3411
  const newOffset = Math.max(0, Math.min(100, Math.round(startOffset + deltaOffset)));
3226
- const newStops = [...value.stops];
3412
+ const newStops = [...valueRef.current.stops];
3227
3413
  newStops[index] = {
3228
3414
  ...newStops[index],
3229
3415
  offset: newOffset
3230
3416
  };
3231
- onChange === null || onChange === void 0 || onChange({
3232
- ...value,
3417
+ emitChange({
3418
+ ...valueRef.current,
3233
3419
  stops: newStops
3234
3420
  });
3235
3421
  };
@@ -3250,25 +3436,28 @@ function GradientColorPicker(props) {
3250
3436
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3251
3437
  className: "univer-flex-1",
3252
3438
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3253
- className: "univer-mb-1 univer-text-xs univer-text-gray-500",
3439
+ className: "univer-mb-0.5 univer-text-xs univer-text-gray-500",
3254
3440
  children: locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.offset
3255
3441
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InputNumber, {
3256
- value: (_value$stops$selected = value.stops[selectedIndex]) === null || _value$stops$selected === void 0 ? void 0 : _value$stops$selected.offset,
3442
+ value: (_draftValue$stops$sel = draftValue.stops[selectedIndex]) === null || _draftValue$stops$sel === void 0 ? void 0 : _draftValue$stops$sel.offset,
3257
3443
  min: 0,
3258
3444
  max: 100,
3259
3445
  onChange: handleStopOffsetChange
3260
3446
  })]
3261
3447
  }),
3262
- (value.type === "linear" || value.type === "angular") && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3448
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3263
3449
  className: "univer-flex-1",
3264
3450
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3265
- className: "univer-mb-1 univer-text-xs univer-text-gray-500",
3266
- children: locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.angle
3451
+ className: "univer-mb-0.5 univer-text-xs univer-text-gray-500",
3452
+ children: (_locale$GradientColor = locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.transparency) !== null && _locale$GradientColor !== void 0 ? _locale$GradientColor : "Transparency"
3267
3453
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InputNumber, {
3268
- value: value.angle,
3454
+ value: Math.round((1 - getStopOpacity(draftValue.stops[selectedIndex])) * 100),
3269
3455
  min: 0,
3270
- max: 360,
3271
- onChange: handleAngleChange
3456
+ max: 100,
3457
+ step: 10,
3458
+ formatter: (v) => `${v}%`,
3459
+ parser: (v) => (v === null || v === void 0 ? void 0 : v.replace(/%/g, "")) || "",
3460
+ onChange: handleStopTransparencyChange
3272
3461
  })]
3273
3462
  }),
3274
3463
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -3279,7 +3468,7 @@ function GradientColorPicker(props) {
3279
3468
  "data-u-comp": "gradient-color-picker-delete",
3280
3469
  variant: "danger",
3281
3470
  onClick: handleRemoveStop,
3282
- disabled: value.stops.length <= 2,
3471
+ disabled: draftValue.stops.length <= 2,
3283
3472
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DeleteIcon, {})
3284
3473
  })
3285
3474
  })
@@ -3287,9 +3476,9 @@ function GradientColorPicker(props) {
3287
3476
  ]
3288
3477
  }),
3289
3478
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3290
- className: "univer-border-t univer-border-gray-100 univer-pt-4 dark:!univer-border-gray-700",
3479
+ className: clsx$1("univer-border-t univer-border-gray-100 dark:!univer-border-gray-700", compact ? "univer-pt-3" : "univer-pt-4"),
3291
3480
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ColorPicker, {
3292
- value: (_value$stops$selected2 = value.stops[selectedIndex]) === null || _value$stops$selected2 === void 0 ? void 0 : _value$stops$selected2.color,
3481
+ value: (_draftValue$stops$sel2 = draftValue.stops[selectedIndex]) === null || _draftValue$stops$sel2 === void 0 ? void 0 : _draftValue$stops$sel2.color,
3293
3482
  onChange: handleStopColorChange
3294
3483
  })
3295
3484
  })
@@ -3793,7 +3982,7 @@ function Select(props) {
3793
3982
  return label || value;
3794
3983
  }, [options, value]);
3795
3984
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenu, {
3796
- className: "max-h univer-w-[--radix-popper-anchor-width] univer-min-w-36",
3985
+ className: "univer-max-h-80 univer-w-[--radix-popper-anchor-width] univer-min-w-36 univer-overflow-auto",
3797
3986
  align: "start",
3798
3987
  open,
3799
3988
  items,
@@ -3995,49 +4184,6 @@ function Toaster({ visibleToasts, ...props }) {
3995
4184
  });
3996
4185
  }
3997
4186
 
3998
- //#endregion
3999
- //#region src/components/virtual-list/VirtualList.tsx
4000
- function VirtualList(props) {
4001
- const { data, itemKey, children, height, itemHeight, overscan = 2, className, style } = props;
4002
- const [scrollTop, setScrollTop] = (0, react.useState)(0);
4003
- if (!height || !itemHeight || itemHeight <= 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4004
- className,
4005
- style,
4006
- children: data.map((item, index) => {
4007
- const key = typeof itemKey === "function" ? itemKey(item) : item[itemKey];
4008
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: children(item, index) }, key);
4009
- })
4010
- });
4011
- const start = Math.max(0, Math.floor(scrollTop / itemHeight) - overscan);
4012
- const visibleCount = Math.ceil(height / itemHeight) + overscan * 2;
4013
- const end = Math.min(data.length, start + visibleCount);
4014
- const offsetY = start * itemHeight;
4015
- const totalHeight = data.length * itemHeight;
4016
- const visibleItems = data.slice(start, end);
4017
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4018
- className,
4019
- style: {
4020
- ...style,
4021
- height,
4022
- overflowY: "auto"
4023
- },
4024
- onScroll: (e) => setScrollTop(e.currentTarget.scrollTop),
4025
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4026
- style: {
4027
- height: totalHeight,
4028
- position: "relative"
4029
- },
4030
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4031
- style: { transform: `translateY(${offsetY}px)` },
4032
- children: visibleItems.map((item, index) => {
4033
- const key = typeof itemKey === "function" ? itemKey(item) : item[itemKey];
4034
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: children(item, start + index) }, key);
4035
- })
4036
- })
4037
- })
4038
- });
4039
- }
4040
-
4041
4187
  //#endregion
4042
4188
  //#region src/components/tree/util.ts
4043
4189
  const findNodePathFromTree = (tree, key) => {
@@ -4238,7 +4384,7 @@ function Tree(props) {
4238
4384
  }
4239
4385
  }),
4240
4386
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4241
- className: "\n univer-mx-1 univer-flex univer-h-full univer-shrink univer-items-center univer-overflow-hidden\n univer-text-ellipsis univer-whitespace-nowrap\n ",
4387
+ className: "univer-mx-1 univer-flex univer-h-full univer-shrink univer-items-center univer-overflow-hidden univer-text-ellipsis univer-whitespace-nowrap",
4242
4388
  onClick: (e) => {
4243
4389
  e.stopPropagation();
4244
4390
  handleExpendItem(treeItem);
@@ -4260,7 +4406,7 @@ function Tree(props) {
4260
4406
  }, key);
4261
4407
  }
4262
4408
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
4263
- className: "\n univer-relative univer-select-none univer-text-gray-900\n dark:!univer-text-white\n ",
4409
+ className: "univer-relative univer-select-none univer-text-gray-900 dark:!univer-text-white",
4264
4410
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4265
4411
  className: "univer-m-0 univer-h-full univer-list-none univer-p-0",
4266
4412
  style,
@@ -4344,6 +4490,7 @@ exports.CascaderList = CascaderList;
4344
4490
  exports.Checkbox = Checkbox;
4345
4491
  exports.CheckboxGroup = CheckboxGroup;
4346
4492
  exports.ColorPicker = ColorPicker;
4493
+ exports.ColorPresets = ColorPresets;
4347
4494
  exports.ConfigContext = ConfigContext;
4348
4495
  exports.ConfigProvider = ConfigProvider;
4349
4496
  exports.Confirm = Confirm;
@@ -4389,6 +4536,12 @@ exports.borderLeftClassName = borderLeftClassName;
4389
4536
  exports.borderRightClassName = borderRightClassName;
4390
4537
  exports.borderTopClassName = borderTopClassName;
4391
4538
  exports.clsx = clsx$1;
4539
+ Object.defineProperty(exports, 'cva', {
4540
+ enumerable: true,
4541
+ get: function () {
4542
+ return class_variance_authority.cva;
4543
+ }
4544
+ });
4392
4545
  exports.divideXClassName = divideXClassName;
4393
4546
  exports.divideYClassName = divideYClassName;
4394
4547
  exports.filterLeafNode = filterLeafNode;
@@ -4399,6 +4552,7 @@ exports.mergeTreeSelected = mergeTreeSelected;
4399
4552
  exports.message = message;
4400
4553
  exports.removeMessage = removeMessage;
4401
4554
  exports.render = render;
4555
+ exports.resetButtonClassName = resetButtonClassName;
4402
4556
  exports.resizeObserverCtor = resizeObserverCtor;
4403
4557
  exports.scrollbarClassName = scrollbarClassName;
4404
4558
  exports.toast = sonner.toast;