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