@univerjs/design 0.24.0 → 0.25.0-insiders.20260608-e4336f7

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 (171) hide show
  1. package/lib/cjs/index.js +197 -62
  2. package/lib/cjs/locale/ar-SA.js +55 -0
  3. package/lib/cjs/locale/ca-ES.js +2 -1
  4. package/lib/cjs/locale/de-DE.js +55 -0
  5. package/lib/cjs/locale/en-US.js +2 -1
  6. package/lib/cjs/locale/es-ES.js +2 -1
  7. package/lib/cjs/locale/fa-IR.js +2 -1
  8. package/lib/cjs/locale/fr-FR.js +2 -1
  9. package/lib/cjs/locale/id-ID.js +55 -0
  10. package/lib/cjs/locale/it-IT.js +55 -0
  11. package/lib/cjs/locale/ja-JP.js +2 -1
  12. package/lib/cjs/locale/ko-KR.js +2 -1
  13. package/lib/cjs/locale/pl-PL.js +55 -0
  14. package/lib/cjs/locale/pt-BR.js +55 -0
  15. package/lib/cjs/locale/ru-RU.js +2 -1
  16. package/lib/cjs/locale/sk-SK.js +2 -1
  17. package/lib/cjs/locale/vi-VN.js +2 -1
  18. package/lib/cjs/locale/zh-CN.js +2 -1
  19. package/lib/cjs/locale/zh-HK.js +55 -0
  20. package/lib/cjs/locale/zh-TW.js +2 -1
  21. package/lib/es/index.js +197 -62
  22. package/lib/es/locale/ar-SA.js +54 -0
  23. package/lib/es/locale/ca-ES.js +2 -1
  24. package/lib/es/locale/de-DE.js +54 -0
  25. package/lib/es/locale/en-US.js +2 -1
  26. package/lib/es/locale/es-ES.js +2 -1
  27. package/lib/es/locale/fa-IR.js +2 -1
  28. package/lib/es/locale/fr-FR.js +2 -1
  29. package/lib/es/locale/id-ID.js +54 -0
  30. package/lib/es/locale/it-IT.js +54 -0
  31. package/lib/es/locale/ja-JP.js +2 -1
  32. package/lib/es/locale/ko-KR.js +2 -1
  33. package/lib/es/locale/pl-PL.js +54 -0
  34. package/lib/es/locale/pt-BR.js +54 -0
  35. package/lib/es/locale/ru-RU.js +2 -1
  36. package/lib/es/locale/sk-SK.js +2 -1
  37. package/lib/es/locale/vi-VN.js +2 -1
  38. package/lib/es/locale/zh-CN.js +2 -1
  39. package/lib/es/locale/zh-HK.js +54 -0
  40. package/lib/es/locale/zh-TW.js +2 -1
  41. package/lib/index.css +58 -0
  42. package/lib/index.js +197 -62
  43. package/lib/locale/ar-SA.js +54 -0
  44. package/lib/locale/ca-ES.js +2 -1
  45. package/lib/locale/de-DE.js +54 -0
  46. package/lib/locale/en-US.js +2 -1
  47. package/lib/locale/es-ES.js +2 -1
  48. package/lib/locale/fa-IR.js +2 -1
  49. package/lib/locale/fr-FR.js +2 -1
  50. package/lib/locale/id-ID.js +54 -0
  51. package/lib/locale/it-IT.js +54 -0
  52. package/lib/locale/ja-JP.js +2 -1
  53. package/lib/locale/ko-KR.js +2 -1
  54. package/lib/locale/pl-PL.js +54 -0
  55. package/lib/locale/pt-BR.js +54 -0
  56. package/lib/locale/ru-RU.js +2 -1
  57. package/lib/locale/sk-SK.js +2 -1
  58. package/lib/locale/vi-VN.js +2 -1
  59. package/lib/locale/zh-CN.js +2 -1
  60. package/lib/locale/zh-HK.js +54 -0
  61. package/lib/locale/zh-TW.js +2 -1
  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 +1 -1
  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 +1 -1
  142. package/lib/types/locale/ar-SA.d.ts +18 -0
  143. package/lib/types/locale/de-DE.d.ts +18 -0
  144. package/lib/types/locale/en-US.d.ts +1 -0
  145. package/lib/types/locale/id-ID.d.ts +18 -0
  146. package/lib/types/locale/it-IT.d.ts +18 -0
  147. package/lib/types/locale/pl-PL.d.ts +18 -0
  148. package/lib/types/locale/pt-BR.d.ts +18 -0
  149. package/lib/types/locale/zh-HK.d.ts +18 -0
  150. package/lib/umd/index.js +28 -5
  151. package/lib/umd/locale/ar-SA.js +1 -0
  152. package/lib/umd/locale/ca-ES.js +1 -1
  153. package/lib/umd/locale/de-DE.js +1 -0
  154. package/lib/umd/locale/en-US.js +1 -1
  155. package/lib/umd/locale/es-ES.js +1 -1
  156. package/lib/umd/locale/fa-IR.js +1 -1
  157. package/lib/umd/locale/fr-FR.js +1 -1
  158. package/lib/umd/locale/id-ID.js +1 -0
  159. package/lib/umd/locale/it-IT.js +1 -0
  160. package/lib/umd/locale/ja-JP.js +1 -1
  161. package/lib/umd/locale/ko-KR.js +1 -1
  162. package/lib/umd/locale/pl-PL.js +1 -0
  163. package/lib/umd/locale/pt-BR.js +1 -0
  164. package/lib/umd/locale/ru-RU.js +1 -1
  165. package/lib/umd/locale/sk-SK.js +1 -1
  166. package/lib/umd/locale/vi-VN.js +1 -1
  167. package/lib/umd/locale/zh-CN.js +1 -1
  168. package/lib/umd/locale/zh-HK.js +1 -0
  169. package/lib/umd/locale/zh-TW.js +1 -1
  170. package/package.json +5 -5
  171. package/LICENSE +0 -176
package/lib/cjs/index.js CHANGED
@@ -2652,7 +2652,7 @@ const InputNumber = (0, react.forwardRef)(({ value, defaultValue, size = "small"
2652
2652
  if (formatter) return formatter(formattedValue);
2653
2653
  return String(formattedValue);
2654
2654
  }
2655
- function parseValue(val) {
2655
+ function parseNumberValue(val) {
2656
2656
  if (!val) return null;
2657
2657
  let parsedValue = val;
2658
2658
  if (parser) parsedValue = parser(val);
@@ -2671,21 +2671,27 @@ const InputNumber = (0, react.forwardRef)(({ value, defaultValue, size = "small"
2671
2671
  else result = roundedNum;
2672
2672
  } else if (num.toString().includes("e")) result = Number.parseFloat(num.toFixed(16).replace(/\.?0+$/, ""));
2673
2673
  else result = num;
2674
- if (max !== void 0 && result > max) result = max;
2675
- if (min !== void 0 && result < min) result = min;
2676
2674
  return result;
2677
2675
  } catch (e) {
2678
2676
  return null;
2679
2677
  }
2680
2678
  }
2679
+ function clampValue(val) {
2680
+ if (val === null) return null;
2681
+ if (max !== void 0 && val > max) return max;
2682
+ if (min !== void 0 && val < min) return min;
2683
+ return val;
2684
+ }
2681
2685
  function handleInputChange(value) {
2682
- setInputValue(value);
2683
2686
  if (allowEmpty && value === "") {
2687
+ setInputValue(value);
2684
2688
  setInternalValue(null);
2685
2689
  onChange === null || onChange === void 0 || onChange(null);
2686
2690
  return;
2687
2691
  }
2688
- const parsedValue = parseValue(value);
2692
+ const parsedNumber = parseNumberValue(value);
2693
+ const parsedValue = clampValue(parsedNumber);
2694
+ setInputValue(parsedNumber !== null && parsedValue !== parsedNumber ? formatValue(parsedValue) : value);
2689
2695
  setInternalValue(parsedValue);
2690
2696
  onChange === null || onChange === void 0 || onChange(parsedValue);
2691
2697
  }
@@ -2834,7 +2840,7 @@ function Segmented({ items, value, defaultValue, onChange, className = "" }) {
2834
2840
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2835
2841
  "data-u-comp": "segmented",
2836
2842
  ref: containerRef,
2837
- className: clsx$1("univer-relative univer-box-border univer-flex univer-gap-4 univer-rounded-lg univer-bg-gray-100 univer-p-1 dark:!univer-bg-gray-800", className),
2843
+ className: clsx$1("univer-relative univer-box-border univer-flex univer-min-w-0 univer-gap-1 univer-rounded-lg univer-bg-gray-100 univer-p-1 dark:!univer-bg-gray-800", className),
2838
2844
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2839
2845
  className: "univer-animate-univer-slide univer-absolute univer-h-6 univer-rounded-md univer-bg-white univer-shadow-sm univer-transition-all univer-duration-200 dark:!univer-bg-gray-700 dark:!univer-text-gray-400",
2840
2846
  style: slideStyle
@@ -2842,7 +2848,7 @@ function Segmented({ items, value, defaultValue, onChange, className = "" }) {
2842
2848
  ref: (el) => {
2843
2849
  if (el) itemRefs.current.set(item.value, el);
2844
2850
  },
2845
- className: clsx$1("univer-relative univer-box-border univer-flex-1 univer-cursor-pointer univer-border-none univer-bg-transparent univer-px-3 univer-py-1 univer-text-xs univer-font-medium univer-transition-colors", {
2851
+ className: clsx$1("univer-relative univer-box-border univer-min-w-0 univer-flex-1 univer-cursor-pointer univer-truncate univer-border-none univer-bg-transparent univer-px-3 univer-py-1 univer-text-xs univer-font-medium univer-transition-colors", {
2846
2852
  "univer-text-gray-900 dark:!univer-text-white": selectedItem === item.value,
2847
2853
  "univer-text-gray-500 hover:univer-text-gray-900 dark:hover:!univer-text-white": selectedItem !== item.value
2848
2854
  }),
@@ -3069,21 +3075,68 @@ const DEFAULT_VALUE = {
3069
3075
  color: "#000000",
3070
3076
  offset: 100
3071
3077
  }],
3072
- angle: 90
3078
+ angle: 0
3073
3079
  };
3080
+ function clamp(value, min, max) {
3081
+ return Math.max(min, Math.min(max, value));
3082
+ }
3083
+ function getStopOpacity(stop) {
3084
+ var _stop$opacity;
3085
+ return clamp((_stop$opacity = stop === null || stop === void 0 ? void 0 : stop.opacity) !== null && _stop$opacity !== void 0 ? _stop$opacity : 1, 0, 1);
3086
+ }
3087
+ function getColorWithOpacity(color, opacity) {
3088
+ if (opacity >= 1) return color;
3089
+ const value = color.trim();
3090
+ if (/^#[0-9a-f]{3}$/i.test(value)) {
3091
+ const [, r, g, b] = value;
3092
+ return `rgba(${Number.parseInt(r + r, 16)}, ${Number.parseInt(g + g, 16)}, ${Number.parseInt(b + b, 16)}, ${opacity})`;
3093
+ }
3094
+ 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})`;
3095
+ const rgba = /^rgba?\(([^)]+)\)$/i.exec(value);
3096
+ if (rgba) {
3097
+ const parts = rgba[1].split(",").map((part) => part.trim());
3098
+ const baseAlpha = parts[3] === void 0 ? 1 : Number.parseFloat(parts[3]);
3099
+ const alpha = Number.isFinite(baseAlpha) ? clamp(baseAlpha * opacity, 0, 1) : opacity;
3100
+ return `rgba(${parts[0]}, ${parts[1]}, ${parts[2]}, ${alpha})`;
3101
+ }
3102
+ return color;
3103
+ }
3104
+ function getStopColor(stop) {
3105
+ return getColorWithOpacity(stop.color, getStopOpacity(stop));
3106
+ }
3107
+ function getGradientAngle(value) {
3108
+ var _ref, _value$angle;
3109
+ return (_ref = (_value$angle = value.angle) !== null && _value$angle !== void 0 ? _value$angle : DEFAULT_VALUE.angle) !== null && _ref !== void 0 ? _ref : 0;
3110
+ }
3111
+ function getCssLinearGradientAngle(value) {
3112
+ return (getGradientAngle(value) + 90) % 360;
3113
+ }
3074
3114
  function GradientColorPicker(props) {
3075
- var _value$stops$selected, _value$stops$selected2;
3076
- const { className, value = DEFAULT_VALUE, onChange } = props;
3115
+ var _draftValue$stops$sel, _locale$GradientColor, _draftValue$stops$sel2;
3116
+ const { className, compact = false, value = DEFAULT_VALUE, onChange } = props;
3077
3117
  const { locale } = (0, react.useContext)(ConfigContext);
3118
+ const [draftValue, setDraftValue] = (0, react.useState)(value);
3078
3119
  const [selectedIndex, setSelectedIndex] = (0, react.useState)(0);
3079
3120
  const barRef = (0, react.useRef)(null);
3121
+ const valueRef = (0, react.useRef)(value);
3080
3122
  const cleanupRef = (0, react.useRef)(null);
3123
+ (0, react.useEffect)(() => {
3124
+ valueRef.current = draftValue;
3125
+ }, [draftValue]);
3126
+ (0, react.useEffect)(() => {
3127
+ setDraftValue(value);
3128
+ }, [value]);
3129
+ const emitChange = (nextValue) => {
3130
+ valueRef.current = nextValue;
3131
+ setDraftValue(nextValue);
3132
+ onChange === null || onChange === void 0 || onChange(nextValue);
3133
+ };
3081
3134
  (0, react.useEffect)(() => {
3082
3135
  setSelectedIndex((prev) => {
3083
- if (prev >= value.stops.length) return Math.max(0, value.stops.length - 1);
3136
+ if (prev >= draftValue.stops.length) return Math.max(0, draftValue.stops.length - 1);
3084
3137
  return prev;
3085
3138
  });
3086
- }, [value.stops.length]);
3139
+ }, [draftValue.stops.length]);
3087
3140
  (0, react.useEffect)(() => {
3088
3141
  return () => {
3089
3142
  var _cleanupRef$current;
@@ -3091,40 +3144,52 @@ function GradientColorPicker(props) {
3091
3144
  };
3092
3145
  }, []);
3093
3146
  const stops = (0, react.useMemo)(() => {
3094
- return [...value.stops].sort((a, b) => a.offset - b.offset);
3095
- }, [value.stops]);
3147
+ return [...draftValue.stops].sort((a, b) => a.offset - b.offset);
3148
+ }, [draftValue.stops]);
3096
3149
  const handleTypeChange = (type) => {
3097
- onChange === null || onChange === void 0 || onChange({
3098
- ...value,
3150
+ emitChange({
3151
+ ...valueRef.current,
3099
3152
  type
3100
3153
  });
3101
3154
  };
3102
3155
  const handleAngleChange = (angle) => {
3103
- onChange === null || onChange === void 0 || onChange({
3104
- ...value,
3156
+ emitChange({
3157
+ ...valueRef.current,
3105
3158
  angle: angle !== null && angle !== void 0 ? angle : 0
3106
3159
  });
3107
3160
  };
3108
3161
  const handleStopColorChange = (color) => {
3109
- const newStops = [...value.stops];
3162
+ const newStops = [...valueRef.current.stops];
3110
3163
  newStops[selectedIndex] = {
3111
3164
  ...newStops[selectedIndex],
3112
3165
  color
3113
3166
  };
3114
- onChange === null || onChange === void 0 || onChange({
3115
- ...value,
3167
+ emitChange({
3168
+ ...valueRef.current,
3116
3169
  stops: newStops
3117
3170
  });
3118
3171
  };
3119
3172
  const handleStopOffsetChange = (offset) => {
3120
3173
  if (offset === null) return;
3121
- const newStops = [...value.stops];
3174
+ const newStops = [...valueRef.current.stops];
3122
3175
  newStops[selectedIndex] = {
3123
3176
  ...newStops[selectedIndex],
3124
3177
  offset
3125
3178
  };
3126
- onChange === null || onChange === void 0 || onChange({
3127
- ...value,
3179
+ emitChange({
3180
+ ...valueRef.current,
3181
+ stops: newStops
3182
+ });
3183
+ };
3184
+ const handleStopTransparencyChange = (transparency) => {
3185
+ const nextTransparency = clamp(transparency !== null && transparency !== void 0 ? transparency : 0, 0, 100);
3186
+ const newStops = [...valueRef.current.stops];
3187
+ newStops[selectedIndex] = {
3188
+ ...newStops[selectedIndex],
3189
+ opacity: (100 - nextTransparency) / 100
3190
+ };
3191
+ emitChange({
3192
+ ...valueRef.current,
3128
3193
  stops: newStops
3129
3194
  });
3130
3195
  };
@@ -3132,43 +3197,92 @@ function GradientColorPicker(props) {
3132
3197
  if (!barRef.current) return;
3133
3198
  const rect = barRef.current.getBoundingClientRect();
3134
3199
  const offset = Math.round((e.clientX - rect.left) / rect.width * 100);
3200
+ const leftStop = [...stops].reverse().find((s) => s.offset <= offset) || stops[0];
3135
3201
  const newStop = {
3136
- color: ([...stops].reverse().find((s) => s.offset <= offset) || stops[0]).color,
3137
- offset
3202
+ color: leftStop.color,
3203
+ offset,
3204
+ opacity: getStopOpacity(leftStop)
3138
3205
  };
3139
- const newStops = [...value.stops, newStop];
3140
- onChange === null || onChange === void 0 || onChange({
3141
- ...value,
3206
+ const newStops = [...valueRef.current.stops, newStop];
3207
+ emitChange({
3208
+ ...valueRef.current,
3142
3209
  stops: newStops
3143
3210
  });
3144
3211
  setSelectedIndex(newStops.length - 1);
3145
3212
  };
3146
3213
  const handleRemoveStop = () => {
3147
- if (value.stops.length <= 2) return;
3148
- const newStops = value.stops.filter((_, i) => i !== selectedIndex);
3149
- onChange === null || onChange === void 0 || onChange({
3150
- ...value,
3214
+ if (draftValue.stops.length <= 2) return;
3215
+ const newStops = valueRef.current.stops.filter((_, i) => i !== selectedIndex);
3216
+ emitChange({
3217
+ ...valueRef.current,
3151
3218
  stops: newStops
3152
3219
  });
3153
3220
  setSelectedIndex(0);
3154
3221
  };
3155
3222
  const gradientPreview = (0, react.useMemo)(() => {
3156
- return `linear-gradient(to right, ${stops.map((s) => `${s.color} ${s.offset}%`).join(", ")})`;
3223
+ return `linear-gradient(to right, ${stops.map((s) => `${getStopColor(s)} ${s.offset}%`).join(", ")})`;
3157
3224
  }, [stops]);
3158
3225
  const mainPreview = (0, react.useMemo)(() => {
3159
- const stopsStr = stops.map((s) => `${s.color} ${s.offset}%`).join(", ");
3160
- switch (value.type) {
3161
- case "linear": return `linear-gradient(${value.angle}deg, ${stopsStr})`;
3226
+ const stopsStr = stops.map((s) => `${getStopColor(s)} ${s.offset}%`).join(", ");
3227
+ switch (draftValue.type) {
3228
+ case "linear": return `linear-gradient(${getCssLinearGradientAngle(draftValue)}deg, ${stopsStr})`;
3162
3229
  case "radial": return `radial-gradient(circle, ${stopsStr})`;
3163
- case "angular": return `conic-gradient(from ${value.angle}deg, ${stopsStr})`;
3230
+ case "angular": return `conic-gradient(from ${getGradientAngle(draftValue)}deg, ${stopsStr})`;
3164
3231
  case "diamond": return `radial-gradient(circle, ${stopsStr})`;
3165
- default: return `linear-gradient(${value.angle}deg, ${stopsStr})`;
3232
+ default: return `linear-gradient(${getCssLinearGradientAngle(draftValue)}deg, ${stopsStr})`;
3166
3233
  }
3167
- }, [value, stops]);
3234
+ }, [draftValue, stops]);
3235
+ const showAngleEditor = draftValue.type === "linear" || draftValue.type === "angular";
3168
3236
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3169
- className: clsx$1("univer-flex univer-w-64 univer-flex-col univer-gap-4 univer-rounded-lg univer-bg-white univer-p-4 univer-shadow-lg dark:!univer-bg-gray-800", className),
3237
+ className: clsx$1(compact ? `
3238
+ univer-flex univer-w-full univer-min-w-0 univer-flex-col univer-gap-3 univer-rounded-md
3239
+ univer-bg-transparent univer-p-0
3240
+ dark:!univer-bg-transparent
3241
+ ` : `
3242
+ univer-flex univer-w-full univer-min-w-0 univer-max-w-80 univer-flex-col univer-gap-4
3243
+ univer-rounded-lg univer-bg-white univer-p-4 univer-shadow-lg
3244
+ dark:!univer-bg-gray-800
3245
+ `, className),
3246
+ onClick: (e) => e.stopPropagation(),
3247
+ onPointerDown: (e) => e.stopPropagation(),
3170
3248
  children: [
3171
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Segmented, {
3249
+ compact ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3250
+ className: "\n univer-flex univer-min-w-0 univer-items-center univer-gap-4 univer-border-b\n univer-border-gray-100\n dark:!univer-border-gray-700\n ",
3251
+ children: [
3252
+ {
3253
+ label: locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.linear,
3254
+ value: "linear"
3255
+ },
3256
+ {
3257
+ label: locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.radial,
3258
+ value: "radial"
3259
+ },
3260
+ {
3261
+ label: locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.angular,
3262
+ value: "angular"
3263
+ },
3264
+ {
3265
+ label: locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.diamond,
3266
+ value: "diamond"
3267
+ }
3268
+ ].map((item) => {
3269
+ const selected = draftValue.type === item.value;
3270
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
3271
+ type: "button",
3272
+ className: clsx$1("univer-relative univer-min-w-0 univer-flex-1 univer-cursor-pointer univer-truncate univer-border-none univer-bg-transparent univer-px-0 univer-pb-2 univer-pt-0 univer-text-xs univer-transition-colors", selected ? `
3273
+ univer-font-medium univer-text-primary-600
3274
+ dark:!univer-text-primary-300
3275
+ ` : `
3276
+ univer-text-gray-500
3277
+ hover:univer-text-gray-900
3278
+ dark:hover:!univer-text-white
3279
+ `),
3280
+ onClick: () => handleTypeChange(item.value),
3281
+ children: [item.label, selected && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "\n univer-absolute univer-inset-x-2 -univer-bottom-px univer-h-0.5\n univer-rounded-full univer-bg-primary-600\n dark:!univer-bg-primary-300\n " })]
3282
+ }, item.value);
3283
+ })
3284
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Segmented, {
3285
+ className: "univer-w-full univer-min-w-0 univer-gap-1 univer-overflow-hidden",
3172
3286
  items: [
3173
3287
  {
3174
3288
  label: locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.linear,
@@ -3187,49 +3301,67 @@ function GradientColorPicker(props) {
3187
3301
  value: "diamond"
3188
3302
  }
3189
3303
  ],
3190
- value: value.type,
3304
+ value: draftValue.type,
3191
3305
  onChange: (v) => handleTypeChange(v)
3192
3306
  }),
3307
+ showAngleEditor && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3308
+ "data-u-comp": "gradient-color-picker-angle",
3309
+ className: "univer-flex univer-items-center univer-justify-between univer-gap-3",
3310
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3311
+ className: "univer-text-xs univer-text-gray-500",
3312
+ children: locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.angle
3313
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InputNumber, {
3314
+ className: "univer-w-24",
3315
+ value: getGradientAngle(draftValue),
3316
+ min: 0,
3317
+ max: 360,
3318
+ onChange: handleAngleChange
3319
+ })]
3320
+ }),
3193
3321
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3194
3322
  "data-u-comp": "gradient-color-picker-preview",
3195
- className: "univer-h-32 univer-w-full univer-rounded-md univer-border univer-border-gray-200 dark:!univer-border-gray-600",
3323
+ className: clsx$1("univer-w-full univer-rounded-md univer-border univer-border-gray-200 dark:!univer-border-gray-600", compact ? "univer-h-20" : "univer-h-32"),
3196
3324
  style: { background: mainPreview }
3197
3325
  }),
3198
3326
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3199
- className: "univer-relative univer-mt-4 univer-h-6",
3327
+ className: clsx$1("univer-relative univer-h-6", compact ? "univer-mt-1" : "univer-mt-4"),
3200
3328
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3201
3329
  ref: barRef,
3202
3330
  "data-u-comp": "gradient-color-picker-bar",
3203
3331
  className: "univer-absolute univer-inset-x-0 univer-top-1/2 univer-h-2 -univer-translate-y-1/2 univer-cursor-crosshair univer-rounded-full",
3204
3332
  style: { background: gradientPreview },
3205
3333
  onClick: handleAddStop
3206
- }), value.stops.map((stop, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3334
+ }), draftValue.stops.map((stop, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3207
3335
  "data-u-comp": "gradient-color-picker-stop",
3208
3336
  "data-selected": selectedIndex === index,
3209
3337
  className: clsx$1("univer-absolute univer-top-1/2 univer-size-4 -univer-translate-x-1/2 -univer-translate-y-1/2 univer-cursor-pointer univer-rounded-full univer-border-2 univer-border-white univer-shadow-md", selectedIndex === index ? "univer-z-10 univer-ring-2 univer-ring-primary-500" : "univer-z-0"),
3210
3338
  style: {
3211
3339
  left: `${stop.offset}%`,
3212
- backgroundColor: stop.color
3340
+ backgroundColor: getStopColor(stop)
3213
3341
  },
3214
3342
  onClick: (e) => {
3215
3343
  e.stopPropagation();
3216
3344
  setSelectedIndex(index);
3217
3345
  },
3218
3346
  onPointerDown: (e) => {
3347
+ e.preventDefault();
3348
+ e.stopPropagation();
3219
3349
  const startX = e.clientX;
3220
3350
  const startOffset = stop.offset;
3351
+ setSelectedIndex(index);
3221
3352
  const handlePointerMove = (moveEvent) => {
3222
3353
  if (!barRef.current) return;
3354
+ moveEvent.preventDefault();
3223
3355
  const rect = barRef.current.getBoundingClientRect();
3224
3356
  const deltaOffset = (moveEvent.clientX - startX) / rect.width * 100;
3225
3357
  const newOffset = Math.max(0, Math.min(100, Math.round(startOffset + deltaOffset)));
3226
- const newStops = [...value.stops];
3358
+ const newStops = [...valueRef.current.stops];
3227
3359
  newStops[index] = {
3228
3360
  ...newStops[index],
3229
3361
  offset: newOffset
3230
3362
  };
3231
- onChange === null || onChange === void 0 || onChange({
3232
- ...value,
3363
+ emitChange({
3364
+ ...valueRef.current,
3233
3365
  stops: newStops
3234
3366
  });
3235
3367
  };
@@ -3250,25 +3382,28 @@ function GradientColorPicker(props) {
3250
3382
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3251
3383
  className: "univer-flex-1",
3252
3384
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3253
- className: "univer-mb-1 univer-text-xs univer-text-gray-500",
3385
+ className: "univer-mb-0.5 univer-text-xs univer-text-gray-500",
3254
3386
  children: locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.offset
3255
3387
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InputNumber, {
3256
- value: (_value$stops$selected = value.stops[selectedIndex]) === null || _value$stops$selected === void 0 ? void 0 : _value$stops$selected.offset,
3388
+ value: (_draftValue$stops$sel = draftValue.stops[selectedIndex]) === null || _draftValue$stops$sel === void 0 ? void 0 : _draftValue$stops$sel.offset,
3257
3389
  min: 0,
3258
3390
  max: 100,
3259
3391
  onChange: handleStopOffsetChange
3260
3392
  })]
3261
3393
  }),
3262
- (value.type === "linear" || value.type === "angular") && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3394
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3263
3395
  className: "univer-flex-1",
3264
3396
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3265
- className: "univer-mb-1 univer-text-xs univer-text-gray-500",
3266
- children: locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.angle
3397
+ className: "univer-mb-0.5 univer-text-xs univer-text-gray-500",
3398
+ children: (_locale$GradientColor = locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.transparency) !== null && _locale$GradientColor !== void 0 ? _locale$GradientColor : "Transparency"
3267
3399
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InputNumber, {
3268
- value: value.angle,
3400
+ value: Math.round((1 - getStopOpacity(draftValue.stops[selectedIndex])) * 100),
3269
3401
  min: 0,
3270
- max: 360,
3271
- onChange: handleAngleChange
3402
+ max: 100,
3403
+ step: 10,
3404
+ formatter: (v) => `${v}%`,
3405
+ parser: (v) => (v === null || v === void 0 ? void 0 : v.replace(/%/g, "")) || "",
3406
+ onChange: handleStopTransparencyChange
3272
3407
  })]
3273
3408
  }),
3274
3409
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -3279,7 +3414,7 @@ function GradientColorPicker(props) {
3279
3414
  "data-u-comp": "gradient-color-picker-delete",
3280
3415
  variant: "danger",
3281
3416
  onClick: handleRemoveStop,
3282
- disabled: value.stops.length <= 2,
3417
+ disabled: draftValue.stops.length <= 2,
3283
3418
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DeleteIcon, {})
3284
3419
  })
3285
3420
  })
@@ -3287,9 +3422,9 @@ function GradientColorPicker(props) {
3287
3422
  ]
3288
3423
  }),
3289
3424
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3290
- className: "univer-border-t univer-border-gray-100 univer-pt-4 dark:!univer-border-gray-700",
3425
+ className: clsx$1("univer-border-t univer-border-gray-100 dark:!univer-border-gray-700", compact ? "univer-pt-3" : "univer-pt-4"),
3291
3426
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ColorPicker, {
3292
- value: (_value$stops$selected2 = value.stops[selectedIndex]) === null || _value$stops$selected2 === void 0 ? void 0 : _value$stops$selected2.color,
3427
+ value: (_draftValue$stops$sel2 = draftValue.stops[selectedIndex]) === null || _draftValue$stops$sel2 === void 0 ? void 0 : _draftValue$stops$sel2.color,
3293
3428
  onChange: handleStopColorChange
3294
3429
  })
3295
3430
  })
@@ -3793,7 +3928,7 @@ function Select(props) {
3793
3928
  return label || value;
3794
3929
  }, [options, value]);
3795
3930
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenu, {
3796
- className: "max-h univer-w-[--radix-popper-anchor-width] univer-min-w-36",
3931
+ className: "univer-max-h-80 univer-w-[--radix-popper-anchor-width] univer-min-w-36 univer-overflow-auto",
3797
3932
  align: "start",
3798
3933
  open,
3799
3934
  items,
@@ -0,0 +1,55 @@
1
+
2
+ //#region src/locale/ar-SA.ts
3
+ const locale = { design: {
4
+ Confirm: {
5
+ cancel: "إلغاء",
6
+ confirm: "موافق"
7
+ },
8
+ CascaderList: { empty: "لا شيء" },
9
+ Calendar: {
10
+ year: "",
11
+ weekDays: [
12
+ "ح",
13
+ "ن",
14
+ "ث",
15
+ "ر",
16
+ "خ",
17
+ "ج",
18
+ "س"
19
+ ],
20
+ months: [
21
+ "يناير",
22
+ "فبراير",
23
+ "مارس",
24
+ "أبريل",
25
+ "مايو",
26
+ "يونيو",
27
+ "يوليو",
28
+ "أغسطس",
29
+ "سبتمبر",
30
+ "أكتوبر",
31
+ "نوفمبر",
32
+ "ديسمبر"
33
+ ]
34
+ },
35
+ Select: { empty: "لا شيء" },
36
+ ColorPicker: {
37
+ more: "المزيد من الألوان",
38
+ cancel: "إلغاء",
39
+ confirm: "موافق"
40
+ },
41
+ GradientColorPicker: {
42
+ linear: "خطي",
43
+ radial: "شعاعي",
44
+ angular: "زاوي",
45
+ diamond: "ماسي",
46
+ offset: "إزاحة",
47
+ angle: "زاوية",
48
+ flip: "قلب",
49
+ delete: "حذف",
50
+ transparency: "Transparency"
51
+ }
52
+ } };
53
+
54
+ //#endregion
55
+ module.exports = locale;
@@ -46,7 +46,8 @@ const locale = { design: {
46
46
  offset: "Desplaçament",
47
47
  angle: "Angle",
48
48
  flip: "Girar",
49
- delete: "Eliminar"
49
+ delete: "Eliminar",
50
+ transparency: "Transparency"
50
51
  }
51
52
  } };
52
53
 
@@ -0,0 +1,55 @@
1
+
2
+ //#region src/locale/de-DE.ts
3
+ const locale = { design: {
4
+ Confirm: {
5
+ cancel: "Abbrechen",
6
+ confirm: "OK"
7
+ },
8
+ CascaderList: { empty: "Keine" },
9
+ Calendar: {
10
+ year: "",
11
+ weekDays: [
12
+ "So",
13
+ "Mo",
14
+ "Di",
15
+ "Mi",
16
+ "Do",
17
+ "Fr",
18
+ "Sa"
19
+ ],
20
+ months: [
21
+ "Jan",
22
+ "Feb",
23
+ "Mär",
24
+ "Apr",
25
+ "Mai",
26
+ "Jun",
27
+ "Jul",
28
+ "Aug",
29
+ "Sep",
30
+ "Okt",
31
+ "Nov",
32
+ "Dez"
33
+ ]
34
+ },
35
+ Select: { empty: "Keine" },
36
+ ColorPicker: {
37
+ more: "Mehr Farben",
38
+ cancel: "Abbrechen",
39
+ confirm: "OK"
40
+ },
41
+ GradientColorPicker: {
42
+ linear: "Linear",
43
+ radial: "Radial",
44
+ angular: "Winkel",
45
+ diamond: "Diamant",
46
+ offset: "Versatz",
47
+ angle: "Winkel",
48
+ flip: "Umkehren",
49
+ delete: "Löschen",
50
+ transparency: "Transparency"
51
+ }
52
+ } };
53
+
54
+ //#endregion
55
+ module.exports = locale;
@@ -61,7 +61,8 @@ const locale = { design: {
61
61
  offset: "Offset",
62
62
  angle: "Angle",
63
63
  flip: "Flip",
64
- delete: "Delete"
64
+ delete: "Delete",
65
+ transparency: "Transparency"
65
66
  }
66
67
  } };
67
68
 
@@ -46,7 +46,8 @@ const locale = { design: {
46
46
  offset: "Desplaçament",
47
47
  angle: "Angle",
48
48
  flip: "Girar",
49
- delete: "Eliminar"
49
+ delete: "Eliminar",
50
+ transparency: "Transparency"
50
51
  }
51
52
  } };
52
53
 
@@ -46,7 +46,8 @@ const locale = { design: {
46
46
  offset: "افست",
47
47
  angle: "زاویه",
48
48
  flip: "برگردان",
49
- delete: "حذف"
49
+ delete: "حذف",
50
+ transparency: "Transparency"
50
51
  }
51
52
  } };
52
53
 
@@ -46,7 +46,8 @@ const locale = { design: {
46
46
  offset: "Décalage",
47
47
  angle: "Angle",
48
48
  flip: "Retourner",
49
- delete: "Supprimer"
49
+ delete: "Supprimer",
50
+ transparency: "Transparency"
50
51
  }
51
52
  } };
52
53
 
@@ -0,0 +1,55 @@
1
+
2
+ //#region src/locale/id-ID.ts
3
+ const locale = { design: {
4
+ Confirm: {
5
+ cancel: "Batal",
6
+ confirm: "OK"
7
+ },
8
+ CascaderList: { empty: "Tidak ada" },
9
+ Calendar: {
10
+ year: "",
11
+ weekDays: [
12
+ "Min",
13
+ "Sen",
14
+ "Sel",
15
+ "Rab",
16
+ "Kam",
17
+ "Jum",
18
+ "Sab"
19
+ ],
20
+ months: [
21
+ "Jan",
22
+ "Feb",
23
+ "Mar",
24
+ "Apr",
25
+ "Mei",
26
+ "Jun",
27
+ "Jul",
28
+ "Agu",
29
+ "Sep",
30
+ "Okt",
31
+ "Nov",
32
+ "Des"
33
+ ]
34
+ },
35
+ Select: { empty: "Tidak ada" },
36
+ ColorPicker: {
37
+ more: "Warna Lainnya",
38
+ cancel: "Batal",
39
+ confirm: "OK"
40
+ },
41
+ GradientColorPicker: {
42
+ linear: "Linear",
43
+ radial: "Radial",
44
+ angular: "Angular",
45
+ diamond: "Berlian",
46
+ offset: "Offset",
47
+ angle: "Sudut",
48
+ flip: "Balik",
49
+ delete: "Hapus",
50
+ transparency: "Transparency"
51
+ }
52
+ } };
53
+
54
+ //#endregion
55
+ module.exports = locale;