@univerjs/design 1.0.0-rc.0 → 1.0.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.
- package/lib/cjs/index.js +336 -57
- package/lib/cjs/locale/ar-SA.js +0 -1
- package/lib/cjs/locale/ca-ES.js +0 -1
- package/lib/cjs/locale/de-DE.js +0 -1
- package/lib/cjs/locale/en-US.js +0 -1
- package/lib/cjs/locale/es-ES.js +0 -1
- package/lib/cjs/locale/fa-IR.js +0 -1
- package/lib/cjs/locale/fr-FR.js +0 -1
- package/lib/cjs/locale/id-ID.js +0 -1
- package/lib/cjs/locale/it-IT.js +0 -1
- package/lib/cjs/locale/ja-JP.js +0 -1
- package/lib/cjs/locale/ko-KR.js +0 -1
- package/lib/cjs/locale/pl-PL.js +0 -1
- package/lib/cjs/locale/pt-BR.js +0 -1
- package/lib/cjs/locale/ru-RU.js +0 -1
- package/lib/cjs/locale/sk-SK.js +0 -1
- package/lib/cjs/locale/vi-VN.js +0 -1
- package/lib/cjs/locale/zh-CN.js +0 -1
- package/lib/cjs/locale/zh-HK.js +0 -1
- package/lib/cjs/locale/zh-TW.js +0 -1
- package/lib/es/index.js +333 -59
- package/lib/index.css +43 -0
- package/lib/index.js +333 -59
- package/lib/types/components/config-provider/ConfigProvider.d.ts +7 -0
- package/lib/types/components/dropdown/mobile-overlay-context.d.ts +23 -0
- package/lib/types/components/gradient-color-picker/GradientColorPicker.d.ts +1 -0
- package/lib/types/components/gradient-color-picker/MobileGradientColorPicker.d.ts +17 -0
- package/lib/types/hooks/use-mobile-keyboard-viewport.d.ts +25 -0
- package/lib/types/index.d.ts +5 -1
- package/lib/umd/index.js +16 -16
- package/package.json +8 -8
package/lib/cjs/index.js
CHANGED
|
@@ -1960,16 +1960,18 @@ function isBrowser() {
|
|
|
1960
1960
|
//#region src/components/config-provider/ConfigProvider.tsx
|
|
1961
1961
|
const ConfigContext = (0, react.createContext)({ mountContainer: isBrowser() ? document.body : null });
|
|
1962
1962
|
function ConfigProvider(props) {
|
|
1963
|
-
const { children, locale, mountContainer, direction } = props;
|
|
1963
|
+
const { children, locale, mountContainer, direction, mobileKeyboardViewport } = props;
|
|
1964
1964
|
const value = (0, react.useMemo)(() => {
|
|
1965
1965
|
return {
|
|
1966
1966
|
locale,
|
|
1967
1967
|
direction,
|
|
1968
|
-
mountContainer
|
|
1968
|
+
mountContainer,
|
|
1969
|
+
mobileKeyboardViewport
|
|
1969
1970
|
};
|
|
1970
1971
|
}, [
|
|
1971
1972
|
locale,
|
|
1972
1973
|
direction,
|
|
1974
|
+
mobileKeyboardViewport,
|
|
1973
1975
|
mountContainer
|
|
1974
1976
|
]);
|
|
1975
1977
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConfigContext.Provider, {
|
|
@@ -3970,6 +3972,7 @@ function ColorPickerPanel({ value = "#000000", confirmText, onConfirm }) {
|
|
|
3970
3972
|
function MobileDialog(props) {
|
|
3971
3973
|
var _globalThis$CSS;
|
|
3972
3974
|
const { className, overlayClassName, children, style, open = false, title, footer: propFooter, mask = true, keyboard = true, closable = true, maskClosable = true, showOk, showCancel, onOpenChange, onClose, onOk, onCancel } = props;
|
|
3975
|
+
const contentRef = (0, react.useRef)(null);
|
|
3973
3976
|
const { locale, mountContainer, direction } = (0, react.useContext)(ConfigContext);
|
|
3974
3977
|
const maxHeight = ((_globalThis$CSS = globalThis.CSS) === null || _globalThis$CSS === void 0 ? void 0 : _globalThis$CSS.supports("height", "1dvh")) ? "80dvh" : "80vh";
|
|
3975
3978
|
const footer = propFooter ?? (showOk || showCancel ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -3997,7 +4000,13 @@ function MobileDialog(props) {
|
|
|
3997
4000
|
onOpenChange: handleOpenChange,
|
|
3998
4001
|
modal: mask !== false,
|
|
3999
4002
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DialogContent, {
|
|
4000
|
-
className: clsx("!univer-bottom-0 !univer-left-0 !univer-right-0 !univer-top-auto !univer-max-w-none !univer-translate-x-0 !univer-translate-y-0 !univer-gap-4 !univer-overflow-
|
|
4003
|
+
className: clsx("!univer-bottom-0 !univer-left-0 !univer-right-0 !univer-top-auto !univer-flex !univer-max-w-none !univer-translate-x-0 !univer-translate-y-0 !univer-flex-col !univer-gap-4 !univer-overflow-hidden !univer-rounded-t-2xl !univer-p-4 [&_[data-slot='dialog-footer']]:!univer-flex-row [&_[data-slot='dialog-footer']]:!univer-gap-3 [&_[data-slot='dialog-footer']_button]:!univer-h-12 [&_[data-slot='dialog-footer']_button]:!univer-flex-1 [&_button[data-slot='close']]:!univer-right-3 [&_button[data-slot='close']]:!univer-top-3 [&_button[data-slot='close']]:!univer-size-10", className),
|
|
4004
|
+
ref: contentRef,
|
|
4005
|
+
onOpenAutoFocus: (event) => {
|
|
4006
|
+
var _contentRef$current;
|
|
4007
|
+
event.preventDefault();
|
|
4008
|
+
(_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 || _contentRef$current.focus({ preventScroll: true });
|
|
4009
|
+
},
|
|
4001
4010
|
style: {
|
|
4002
4011
|
...style,
|
|
4003
4012
|
position: "fixed",
|
|
@@ -4014,7 +4023,6 @@ function MobileDialog(props) {
|
|
|
4014
4023
|
mountContainer,
|
|
4015
4024
|
overlayClassName,
|
|
4016
4025
|
dir: direction,
|
|
4017
|
-
onClickClose: close,
|
|
4018
4026
|
onEscapeKeyDown: (event) => {
|
|
4019
4027
|
if (keyboard) close();
|
|
4020
4028
|
event.preventDefault();
|
|
@@ -4025,45 +4033,70 @@ function MobileDialog(props) {
|
|
|
4025
4033
|
},
|
|
4026
4034
|
children: [
|
|
4027
4035
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DialogHeader, {
|
|
4028
|
-
className: title ?
|
|
4036
|
+
className: title ? "univer-shrink-0 univer-px-10" : "!univer-hidden",
|
|
4029
4037
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(DialogTitle, { children: title }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DialogDescription, { className: "univer-hidden" })]
|
|
4030
4038
|
}),
|
|
4031
|
-
|
|
4032
|
-
|
|
4039
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4040
|
+
className: "univer-min-h-0 univer-min-w-0 univer-overflow-y-auto",
|
|
4041
|
+
children
|
|
4042
|
+
}),
|
|
4043
|
+
footer && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DialogFooter, {
|
|
4044
|
+
className: "univer-shrink-0",
|
|
4045
|
+
children: footer
|
|
4046
|
+
})
|
|
4033
4047
|
]
|
|
4034
4048
|
})
|
|
4035
4049
|
});
|
|
4036
4050
|
}
|
|
4037
4051
|
|
|
4052
|
+
//#endregion
|
|
4053
|
+
//#region src/components/dropdown/mobile-overlay-context.ts
|
|
4054
|
+
/** The host supplies layout and focus behavior for nested mobile surfaces. */
|
|
4055
|
+
const MobileOverlayContext = (0, react.createContext)(null);
|
|
4056
|
+
|
|
4038
4057
|
//#endregion
|
|
4039
4058
|
//#region src/components/dropdown/MobileDropdownSurface.tsx
|
|
4040
4059
|
function MobileDropdownSurface(props) {
|
|
4041
4060
|
var _globalThis$CSS;
|
|
4042
4061
|
const { children, content, open, disabled, onOpenChange } = props;
|
|
4043
4062
|
const { locale, mountContainer } = (0, react.useContext)(ConfigContext);
|
|
4044
|
-
const
|
|
4063
|
+
const mobileOverlay = (0, react.useContext)(MobileOverlayContext);
|
|
4064
|
+
const [surface, setSurface] = (0, react.useState)(null);
|
|
4065
|
+
const modal = (mobileOverlay === null || mobileOverlay === void 0 ? void 0 : mobileOverlay.modal) ?? true;
|
|
4066
|
+
(0, react.useLayoutEffect)(() => {
|
|
4067
|
+
if (open && surface) return mobileOverlay === null || mobileOverlay === void 0 ? void 0 : mobileOverlay.onMount(surface);
|
|
4068
|
+
}, [
|
|
4069
|
+
open,
|
|
4070
|
+
surface,
|
|
4071
|
+
mobileOverlay
|
|
4072
|
+
]);
|
|
4073
|
+
const viewportHeightUnit = ((_globalThis$CSS = globalThis.CSS) === null || _globalThis$CSS === void 0 ? void 0 : _globalThis$CSS.supports("height", "1dvh")) ? "dvh" : "vh";
|
|
4045
4074
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Dialog$1, {
|
|
4046
4075
|
open,
|
|
4047
4076
|
onOpenChange,
|
|
4048
|
-
modal
|
|
4077
|
+
modal,
|
|
4049
4078
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(DialogTrigger, {
|
|
4050
4079
|
asChild: true,
|
|
4051
4080
|
disabled,
|
|
4052
4081
|
children
|
|
4053
4082
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DialogContent, {
|
|
4083
|
+
ref: setSurface,
|
|
4054
4084
|
mountContainer,
|
|
4055
4085
|
overlayClassName: "!univer-z-[1390]",
|
|
4056
|
-
className: "!univer-
|
|
4086
|
+
className: "!univer-left-0 !univer-right-0 !univer-top-auto !univer-z-[1400] !univer-block !univer-w-full !univer-max-w-none !univer-translate-x-0 !univer-translate-y-0 !univer-overflow-y-auto !univer-rounded-t-2xl !univer-border-0 !univer-bg-gray-50 !univer-p-4 !univer-pt-14 dark:!univer-bg-gray-900 [&_button[data-slot='close']]:!univer-right-3 [&_button[data-slot='close']]:!univer-top-3 [&_button[data-slot='close']]:!univer-size-10 [&_button]:!univer-min-h-11",
|
|
4057
4087
|
style: {
|
|
4058
4088
|
position: "fixed",
|
|
4059
4089
|
insetInline: 0,
|
|
4060
4090
|
top: "auto",
|
|
4061
4091
|
bottom: 0,
|
|
4092
|
+
maxHeight: `80${viewportHeightUnit}`,
|
|
4062
4093
|
width: "100%",
|
|
4063
|
-
maxHeight,
|
|
4064
4094
|
maxWidth: "none",
|
|
4065
|
-
transform: "none"
|
|
4095
|
+
transform: "none",
|
|
4096
|
+
...mobileOverlay === null || mobileOverlay === void 0 ? void 0 : mobileOverlay.contentProps.style
|
|
4066
4097
|
},
|
|
4098
|
+
onOpenAutoFocus: mobileOverlay === null || mobileOverlay === void 0 ? void 0 : mobileOverlay.contentProps.onOpenAutoFocus,
|
|
4099
|
+
onCloseAutoFocus: mobileOverlay === null || mobileOverlay === void 0 ? void 0 : mobileOverlay.contentProps.onCloseAutoFocus,
|
|
4067
4100
|
children: [
|
|
4068
4101
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4069
4102
|
"aria-hidden": "true",
|
|
@@ -5192,8 +5225,10 @@ const InputNumber = (0, react.forwardRef)(({ value, defaultValue, size = "small"
|
|
|
5192
5225
|
const longPressTimerRef = (0, react.useRef)(null);
|
|
5193
5226
|
const longPressIntervalRef = (0, react.useRef)(null);
|
|
5194
5227
|
const mergedRef = (node) => {
|
|
5195
|
-
if (ref)
|
|
5196
|
-
|
|
5228
|
+
if (ref) {
|
|
5229
|
+
if (typeof ref === "function") ref(node);
|
|
5230
|
+
else ref.current = node;
|
|
5231
|
+
}
|
|
5197
5232
|
inputRef.current = node;
|
|
5198
5233
|
};
|
|
5199
5234
|
(0, react.useEffect)(() => {
|
|
@@ -5263,7 +5298,8 @@ const InputNumber = (0, react.forwardRef)(({ value, defaultValue, size = "small"
|
|
|
5263
5298
|
onChange === null || onChange === void 0 || onChange(parsedValue);
|
|
5264
5299
|
}
|
|
5265
5300
|
function handleBlur(e) {
|
|
5266
|
-
|
|
5301
|
+
const currentValue = value !== void 0 ? value : internalValue;
|
|
5302
|
+
if (currentValue === null) {
|
|
5267
5303
|
if (inputValue === "" && allowEmpty) {
|
|
5268
5304
|
if (onChange) onChange(null);
|
|
5269
5305
|
} else {
|
|
@@ -5275,14 +5311,17 @@ const InputNumber = (0, react.forwardRef)(({ value, defaultValue, size = "small"
|
|
|
5275
5311
|
onBlur === null || onBlur === void 0 || onBlur(e);
|
|
5276
5312
|
return;
|
|
5277
5313
|
}
|
|
5278
|
-
let valueInRange =
|
|
5314
|
+
let valueInRange = currentValue;
|
|
5279
5315
|
if (max !== void 0 && valueInRange > max) valueInRange = max;
|
|
5280
5316
|
if (min !== void 0 && valueInRange < min) valueInRange = min;
|
|
5281
|
-
if (valueInRange !==
|
|
5317
|
+
if (valueInRange !== currentValue) {
|
|
5282
5318
|
setInternalValue(valueInRange);
|
|
5283
5319
|
setInputValue(formatValue(valueInRange));
|
|
5284
5320
|
onChange === null || onChange === void 0 || onChange(valueInRange);
|
|
5285
|
-
} else
|
|
5321
|
+
} else {
|
|
5322
|
+
setInternalValue(currentValue);
|
|
5323
|
+
setInputValue(formatValue(currentValue));
|
|
5324
|
+
}
|
|
5286
5325
|
onBlur === null || onBlur === void 0 || onBlur(e);
|
|
5287
5326
|
}
|
|
5288
5327
|
function handleStep(isUp) {
|
|
@@ -5812,7 +5851,7 @@ function GradientColorPicker(props) {
|
|
|
5812
5851
|
label: locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.diamond,
|
|
5813
5852
|
value: "diamond"
|
|
5814
5853
|
}
|
|
5815
|
-
].map((item) => {
|
|
5854
|
+
].filter((item) => !props.types || props.types.some((type) => type === item.value)).map((item) => {
|
|
5816
5855
|
const selected = draftValue.type === item.value;
|
|
5817
5856
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
5818
5857
|
type: "button",
|
|
@@ -5840,7 +5879,7 @@ function GradientColorPicker(props) {
|
|
|
5840
5879
|
label: locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.diamond,
|
|
5841
5880
|
value: "diamond"
|
|
5842
5881
|
}
|
|
5843
|
-
],
|
|
5882
|
+
].filter((item) => !props.types || props.types.some((type) => type === item.value)),
|
|
5844
5883
|
value: draftValue.type,
|
|
5845
5884
|
onChange: (v) => handleTypeChange(v)
|
|
5846
5885
|
}),
|
|
@@ -5972,6 +6011,182 @@ function GradientColorPicker(props) {
|
|
|
5972
6011
|
});
|
|
5973
6012
|
}
|
|
5974
6013
|
|
|
6014
|
+
//#endregion
|
|
6015
|
+
//#region src/components/mobile-action-row/MobileActionRow.tsx
|
|
6016
|
+
function MobileActionRow(props) {
|
|
6017
|
+
const { title, icon, value, valueType = "color", trailing, bordered, variant = "surface", className, type = "button", ...buttonProps } = props;
|
|
6018
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
6019
|
+
type,
|
|
6020
|
+
className: clsx(resetButtonClassName, "univer-flex univer-min-h-12 univer-w-full univer-items-center univer-gap-3 univer-rounded-xl univer-px-4 univer-text-left univer-text-base univer-font-medium univer-text-gray-900 disabled:univer-opacity-40 dark:!univer-text-gray-100 [&>svg]:univer-size-5", {
|
|
6021
|
+
"univer-bg-gray-0 active:univer-bg-gray-100 dark:!univer-bg-gray-800 dark:active:!univer-bg-gray-700": variant === "surface",
|
|
6022
|
+
"univer-bg-gray-100 active:univer-bg-gray-200 dark:!univer-bg-gray-800 dark:active:!univer-bg-gray-700": variant === "subtle"
|
|
6023
|
+
}, bordered && borderBottomClassName, className),
|
|
6024
|
+
...buttonProps,
|
|
6025
|
+
children: [
|
|
6026
|
+
icon,
|
|
6027
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6028
|
+
className: "univer-flex-1",
|
|
6029
|
+
children: title
|
|
6030
|
+
}),
|
|
6031
|
+
value && valueType === "color" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6032
|
+
className: "univer-size-6 univer-rounded-md univer-border univer-border-solid univer-border-gray-200 dark:!univer-border-gray-600",
|
|
6033
|
+
style: { backgroundColor: value }
|
|
6034
|
+
}),
|
|
6035
|
+
value && valueType === "text" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6036
|
+
className: "univer-max-w-32 univer-truncate univer-text-sm univer-font-normal univer-text-gray-500 dark:!univer-text-gray-400",
|
|
6037
|
+
children: value
|
|
6038
|
+
}),
|
|
6039
|
+
trailing
|
|
6040
|
+
]
|
|
6041
|
+
});
|
|
6042
|
+
}
|
|
6043
|
+
|
|
6044
|
+
//#endregion
|
|
6045
|
+
//#region src/components/gradient-color-picker/MobileGradientColorPicker.tsx
|
|
6046
|
+
const GRADIENT_TYPES = [
|
|
6047
|
+
"linear",
|
|
6048
|
+
"radial",
|
|
6049
|
+
"angular",
|
|
6050
|
+
"diamond"
|
|
6051
|
+
];
|
|
6052
|
+
const NUMBER_CLASS = "univer-w-full [&_input]:!univer-h-12 [&_input]:!univer-text-base";
|
|
6053
|
+
function MobileGradientColorPicker({ value = {
|
|
6054
|
+
type: "linear",
|
|
6055
|
+
stops: [{
|
|
6056
|
+
color: "#ffffff",
|
|
6057
|
+
offset: 0
|
|
6058
|
+
}, {
|
|
6059
|
+
color: "#000000",
|
|
6060
|
+
offset: 100
|
|
6061
|
+
}],
|
|
6062
|
+
angle: 0
|
|
6063
|
+
}, onChange, types = GRADIENT_TYPES, className }) {
|
|
6064
|
+
const { locale } = (0, react.useContext)(ConfigContext);
|
|
6065
|
+
const [selectedIndex, setSelectedIndex] = (0, react.useState)(0);
|
|
6066
|
+
const index = Math.min(selectedIndex, Math.max(0, value.stops.length - 1));
|
|
6067
|
+
const selectedStop = value.stops[index];
|
|
6068
|
+
function updateStop(patch) {
|
|
6069
|
+
onChange === null || onChange === void 0 || onChange({
|
|
6070
|
+
...value,
|
|
6071
|
+
stops: value.stops.map((stop, stopIndex) => stopIndex === index ? {
|
|
6072
|
+
...stop,
|
|
6073
|
+
...patch
|
|
6074
|
+
} : stop)
|
|
6075
|
+
});
|
|
6076
|
+
}
|
|
6077
|
+
function addStop() {
|
|
6078
|
+
const stop = selectedStop ?? {
|
|
6079
|
+
color: "#ffffff",
|
|
6080
|
+
offset: 0
|
|
6081
|
+
};
|
|
6082
|
+
const nextOffset = value.stops.filter((item) => item.offset > stop.offset).reduce((offset, item) => Math.min(offset, item.offset), 100);
|
|
6083
|
+
onChange === null || onChange === void 0 || onChange({
|
|
6084
|
+
...value,
|
|
6085
|
+
stops: [...value.stops, {
|
|
6086
|
+
...stop,
|
|
6087
|
+
offset: Math.round((stop.offset + nextOffset) / 2)
|
|
6088
|
+
}]
|
|
6089
|
+
});
|
|
6090
|
+
setSelectedIndex(value.stops.length);
|
|
6091
|
+
}
|
|
6092
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6093
|
+
className: clsx("univer-grid univer-w-full univer-min-w-0 univer-gap-4", className),
|
|
6094
|
+
children: [
|
|
6095
|
+
types.length > 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6096
|
+
className: "univer-grid univer-grid-cols-2 univer-gap-2",
|
|
6097
|
+
children: types.map((type) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileActionRow, {
|
|
6098
|
+
title: locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker[type],
|
|
6099
|
+
"aria-pressed": value.type === type,
|
|
6100
|
+
className: value.type === type ? "!univer-bg-primary-50 !univer-text-primary-600" : void 0,
|
|
6101
|
+
onClick: () => onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
6102
|
+
...value,
|
|
6103
|
+
type
|
|
6104
|
+
})
|
|
6105
|
+
}, type))
|
|
6106
|
+
}),
|
|
6107
|
+
(value.type === "linear" || value.type === "angular") && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
6108
|
+
className: "univer-grid univer-gap-2 univer-text-base",
|
|
6109
|
+
children: [locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.angle, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InputNumber, {
|
|
6110
|
+
className: NUMBER_CLASS,
|
|
6111
|
+
controls: false,
|
|
6112
|
+
value: value.angle ?? 0,
|
|
6113
|
+
min: 0,
|
|
6114
|
+
max: 360,
|
|
6115
|
+
onChange: (angle) => onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
6116
|
+
...value,
|
|
6117
|
+
angle: angle ?? 0
|
|
6118
|
+
})
|
|
6119
|
+
})]
|
|
6120
|
+
}),
|
|
6121
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6122
|
+
className: "univer-flex univer-flex-wrap univer-gap-2",
|
|
6123
|
+
children: [
|
|
6124
|
+
value.stops.map((stop, stopIndex) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
6125
|
+
type: "button",
|
|
6126
|
+
"aria-label": `${locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.offset} ${stop.offset}%`,
|
|
6127
|
+
"aria-pressed": index === stopIndex,
|
|
6128
|
+
className: clsx("univer-flex univer-h-12 univer-min-w-12 univer-appearance-none univer-items-center univer-justify-center univer-gap-2 univer-rounded-lg univer-border univer-border-solid univer-bg-transparent univer-px-2 univer-text-sm", index === stopIndex ? "univer-border-primary-600 univer-text-primary-600" : "univer-border-gray-200"),
|
|
6129
|
+
onClick: () => setSelectedIndex(stopIndex),
|
|
6130
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6131
|
+
className: "univer-size-6 univer-shrink-0 univer-rounded",
|
|
6132
|
+
style: {
|
|
6133
|
+
backgroundColor: stop.color,
|
|
6134
|
+
opacity: stop.opacity ?? 1
|
|
6135
|
+
}
|
|
6136
|
+
}), `${stop.offset}%`]
|
|
6137
|
+
}, stopIndex)),
|
|
6138
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
6139
|
+
className: "univer-size-12",
|
|
6140
|
+
"aria-label": locale === null || locale === void 0 ? void 0 : locale.Accessibility.increment,
|
|
6141
|
+
onClick: addStop,
|
|
6142
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.IncreaseIcon, {})
|
|
6143
|
+
}),
|
|
6144
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
6145
|
+
className: "univer-size-12",
|
|
6146
|
+
"aria-label": locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.delete,
|
|
6147
|
+
disabled: value.stops.length <= 2,
|
|
6148
|
+
onClick: () => {
|
|
6149
|
+
onChange === null || onChange === void 0 || onChange({
|
|
6150
|
+
...value,
|
|
6151
|
+
stops: value.stops.filter((_, stopIndex) => stopIndex !== index)
|
|
6152
|
+
});
|
|
6153
|
+
setSelectedIndex(0);
|
|
6154
|
+
},
|
|
6155
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DeleteIcon, {})
|
|
6156
|
+
})
|
|
6157
|
+
]
|
|
6158
|
+
}),
|
|
6159
|
+
selectedStop && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6160
|
+
className: "univer-grid univer-grid-cols-2 univer-gap-3",
|
|
6161
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
6162
|
+
className: "univer-grid univer-gap-2 univer-text-base",
|
|
6163
|
+
children: [locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.offset, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InputNumber, {
|
|
6164
|
+
className: NUMBER_CLASS,
|
|
6165
|
+
controls: false,
|
|
6166
|
+
value: selectedStop.offset,
|
|
6167
|
+
min: 0,
|
|
6168
|
+
max: 100,
|
|
6169
|
+
onChange: (offset) => updateStop({ offset: offset ?? 0 })
|
|
6170
|
+
})]
|
|
6171
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
6172
|
+
className: "univer-grid univer-gap-2 univer-text-base",
|
|
6173
|
+
children: [locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.transparency, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InputNumber, {
|
|
6174
|
+
className: NUMBER_CLASS,
|
|
6175
|
+
controls: false,
|
|
6176
|
+
value: Math.round((1 - (selectedStop.opacity ?? 1)) * 100),
|
|
6177
|
+
min: 0,
|
|
6178
|
+
max: 100,
|
|
6179
|
+
onChange: (transparency) => updateStop({ opacity: 1 - (transparency ?? 0) / 100 })
|
|
6180
|
+
})]
|
|
6181
|
+
})]
|
|
6182
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileColorPicker, {
|
|
6183
|
+
value: selectedStop.color,
|
|
6184
|
+
onChange: (color) => updateStop({ color })
|
|
6185
|
+
})] })
|
|
6186
|
+
]
|
|
6187
|
+
});
|
|
6188
|
+
}
|
|
6189
|
+
|
|
5975
6190
|
//#endregion
|
|
5976
6191
|
//#region src/components/hover-card/HoverCardPrimitive.tsx
|
|
5977
6192
|
const HoverCardPrimitive = _radix_ui_react_hover_card.Root;
|
|
@@ -6151,36 +6366,6 @@ const removeMessage = (id) => {
|
|
|
6151
6366
|
activeMessageIds.clear();
|
|
6152
6367
|
};
|
|
6153
6368
|
|
|
6154
|
-
//#endregion
|
|
6155
|
-
//#region src/components/mobile-action-row/MobileActionRow.tsx
|
|
6156
|
-
function MobileActionRow(props) {
|
|
6157
|
-
const { title, icon, value, valueType = "color", trailing, bordered, variant = "surface", className, type = "button", ...buttonProps } = props;
|
|
6158
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
6159
|
-
type,
|
|
6160
|
-
className: clsx(resetButtonClassName, "univer-flex univer-min-h-12 univer-w-full univer-items-center univer-gap-3 univer-rounded-xl univer-px-4 univer-text-left univer-text-base univer-font-medium univer-text-gray-900 disabled:univer-opacity-40 dark:!univer-text-gray-100 [&>svg]:univer-size-5", {
|
|
6161
|
-
"univer-bg-gray-0 active:univer-bg-gray-100 dark:!univer-bg-gray-800 dark:active:!univer-bg-gray-700": variant === "surface",
|
|
6162
|
-
"univer-bg-gray-100 active:univer-bg-gray-200 dark:!univer-bg-gray-800 dark:active:!univer-bg-gray-700": variant === "subtle"
|
|
6163
|
-
}, bordered && borderBottomClassName, className),
|
|
6164
|
-
...buttonProps,
|
|
6165
|
-
children: [
|
|
6166
|
-
icon,
|
|
6167
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6168
|
-
className: "univer-flex-1",
|
|
6169
|
-
children: title
|
|
6170
|
-
}),
|
|
6171
|
-
value && valueType === "color" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6172
|
-
className: "univer-size-6 univer-rounded-md univer-border univer-border-solid univer-border-gray-200 dark:!univer-border-gray-600",
|
|
6173
|
-
style: { backgroundColor: value }
|
|
6174
|
-
}),
|
|
6175
|
-
value && valueType === "text" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6176
|
-
className: "univer-max-w-32 univer-truncate univer-text-sm univer-font-normal univer-text-gray-500 dark:!univer-text-gray-400",
|
|
6177
|
-
children: value
|
|
6178
|
-
}),
|
|
6179
|
-
trailing
|
|
6180
|
-
]
|
|
6181
|
-
});
|
|
6182
|
-
}
|
|
6183
|
-
|
|
6184
6369
|
//#endregion
|
|
6185
6370
|
//#region src/components/panel/Panel.tsx
|
|
6186
6371
|
function Panel(props) {
|
|
@@ -6420,9 +6605,10 @@ function SelectList(props) {
|
|
|
6420
6605
|
const value = Array.isArray(_value) ? _value : [_value];
|
|
6421
6606
|
function handleSelect(newValue) {
|
|
6422
6607
|
const index = value.indexOf(newValue);
|
|
6423
|
-
if (!multiple)
|
|
6424
|
-
|
|
6425
|
-
|
|
6608
|
+
if (!multiple) {
|
|
6609
|
+
if (index > -1) onChange(void 0);
|
|
6610
|
+
else onChange(newValue);
|
|
6611
|
+
} else if (index > -1) onChange(value.filter((i) => i === newValue));
|
|
6426
6612
|
else onChange([...value, newValue]);
|
|
6427
6613
|
}
|
|
6428
6614
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
@@ -6559,16 +6745,19 @@ function MobileSelect(props) {
|
|
|
6559
6745
|
items,
|
|
6560
6746
|
disabled,
|
|
6561
6747
|
onOpenChange: setOpen,
|
|
6562
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("
|
|
6748
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
6749
|
+
type: "button",
|
|
6750
|
+
disabled,
|
|
6751
|
+
"aria-expanded": open,
|
|
6563
6752
|
"data-u-comp": "mobile-select",
|
|
6564
|
-
className: clsx(selectClassName, {
|
|
6753
|
+
className: clsx(selectClassName, "!univer-h-auto !univer-min-h-12 univer-text-left", {
|
|
6565
6754
|
"univer-border-primary-600 univer-outline-none univer-ring-2 univer-ring-primary-50 dark:!univer-ring-primary-900": open && !borderless,
|
|
6566
6755
|
"univer-border-transparent univer-bg-transparent": borderless,
|
|
6567
6756
|
"univer-cursor-not-allowed": disabled,
|
|
6568
6757
|
"univer-cursor-pointer": !disabled
|
|
6569
6758
|
}, className),
|
|
6570
6759
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6571
|
-
className: "univer-flex-1 univer-truncate univer-text-
|
|
6760
|
+
className: "univer-flex-1 univer-truncate univer-text-base univer-text-gray-500 dark:!univer-text-gray-0",
|
|
6572
6761
|
children: displayValue
|
|
6573
6762
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { className: "univer-flex-shrink-0 dark:!univer-text-gray-0" })]
|
|
6574
6763
|
})
|
|
@@ -7017,6 +7206,91 @@ function unmount(container) {
|
|
|
7017
7206
|
}
|
|
7018
7207
|
}
|
|
7019
7208
|
|
|
7209
|
+
//#endregion
|
|
7210
|
+
//#region src/hooks/use-mobile-keyboard-viewport.ts
|
|
7211
|
+
function resolveMobileKeyboardViewportLayout(containingBlockTop, containingBlockBottom, viewport, heightRatio) {
|
|
7212
|
+
const visibleTop = Math.max(containingBlockTop, viewport.top);
|
|
7213
|
+
const visibleBottom = Math.min(containingBlockBottom, viewport.bottom);
|
|
7214
|
+
const availableHeight = Math.max(0, visibleBottom - visibleTop);
|
|
7215
|
+
return {
|
|
7216
|
+
availableHeight,
|
|
7217
|
+
bottom: Math.max(0, containingBlockBottom - visibleBottom),
|
|
7218
|
+
height: heightRatio == null ? void 0 : Math.min(viewport.stableHeight * heightRatio, availableHeight)
|
|
7219
|
+
};
|
|
7220
|
+
}
|
|
7221
|
+
function revealFocusedElementInMobileViewport(container, viewport) {
|
|
7222
|
+
const activeElement = document.activeElement;
|
|
7223
|
+
if (!(activeElement instanceof HTMLElement) || !container.contains(activeElement)) return false;
|
|
7224
|
+
const margin = 12;
|
|
7225
|
+
const targetRect = activeElement.getBoundingClientRect();
|
|
7226
|
+
let scrollContainer = activeElement.parentElement;
|
|
7227
|
+
while (scrollContainer && scrollContainer !== container) {
|
|
7228
|
+
const overflowY = getComputedStyle(scrollContainer).overflowY;
|
|
7229
|
+
if ((overflowY === "auto" || overflowY === "scroll") && scrollContainer.scrollHeight > scrollContainer.clientHeight) {
|
|
7230
|
+
const scrollRect = scrollContainer.getBoundingClientRect();
|
|
7231
|
+
const safeTop = Math.max(scrollRect.top, viewport.top) + margin;
|
|
7232
|
+
const safeBottom = Math.min(scrollRect.bottom, viewport.bottom) - margin;
|
|
7233
|
+
if (targetRect.bottom > safeBottom) {
|
|
7234
|
+
const previousScrollTop = scrollContainer.scrollTop;
|
|
7235
|
+
scrollContainer.scrollTop += targetRect.bottom - safeBottom;
|
|
7236
|
+
if (targetRect.bottom - (scrollContainer.scrollTop - previousScrollTop) <= safeBottom) return true;
|
|
7237
|
+
break;
|
|
7238
|
+
}
|
|
7239
|
+
if (targetRect.top < safeTop) {
|
|
7240
|
+
const previousScrollTop = scrollContainer.scrollTop;
|
|
7241
|
+
scrollContainer.scrollTop -= safeTop - targetRect.top;
|
|
7242
|
+
if (targetRect.top + (previousScrollTop - scrollContainer.scrollTop) >= safeTop) return true;
|
|
7243
|
+
break;
|
|
7244
|
+
}
|
|
7245
|
+
return false;
|
|
7246
|
+
}
|
|
7247
|
+
scrollContainer = scrollContainer.parentElement;
|
|
7248
|
+
}
|
|
7249
|
+
const safeTop = viewport.top + margin;
|
|
7250
|
+
const safeBottom = viewport.bottom - margin;
|
|
7251
|
+
if (targetRect.bottom > safeBottom || targetRect.top < safeTop) {
|
|
7252
|
+
activeElement.scrollIntoView({
|
|
7253
|
+
block: "nearest",
|
|
7254
|
+
inline: "nearest"
|
|
7255
|
+
});
|
|
7256
|
+
return true;
|
|
7257
|
+
}
|
|
7258
|
+
return false;
|
|
7259
|
+
}
|
|
7260
|
+
function useMobileKeyboardViewportLayout(elementRef, heightRatio) {
|
|
7261
|
+
const { mobileKeyboardViewport } = (0, react.useContext)(ConfigContext);
|
|
7262
|
+
const [layout, updateLayout] = (0, react.useReducer)((_current, next) => next, null);
|
|
7263
|
+
const layoutRef = (0, react.useRef)(null);
|
|
7264
|
+
const measure = (0, react.useCallback)(() => {
|
|
7265
|
+
const element = elementRef.current;
|
|
7266
|
+
if (!element || !mobileKeyboardViewport) {
|
|
7267
|
+
if (layoutRef.current !== null) {
|
|
7268
|
+
layoutRef.current = null;
|
|
7269
|
+
updateLayout(null);
|
|
7270
|
+
}
|
|
7271
|
+
return;
|
|
7272
|
+
}
|
|
7273
|
+
const containingBlock = element.offsetParent;
|
|
7274
|
+
const fixedToViewport = getComputedStyle(element).position === "fixed" || !containingBlock;
|
|
7275
|
+
const containingBlockRect = containingBlock === null || containingBlock === void 0 ? void 0 : containingBlock.getBoundingClientRect();
|
|
7276
|
+
const nextLayout = resolveMobileKeyboardViewportLayout(fixedToViewport ? 0 : (containingBlockRect === null || containingBlockRect === void 0 ? void 0 : containingBlockRect.top) ?? 0, fixedToViewport ? window.innerHeight : (containingBlockRect === null || containingBlockRect === void 0 ? void 0 : containingBlockRect.bottom) ?? window.innerHeight, mobileKeyboardViewport, heightRatio);
|
|
7277
|
+
const previous = layoutRef.current;
|
|
7278
|
+
if ((previous === null || previous === void 0 ? void 0 : previous.availableHeight) === nextLayout.availableHeight && previous.bottom === nextLayout.bottom && previous.height === nextLayout.height) return;
|
|
7279
|
+
layoutRef.current = nextLayout;
|
|
7280
|
+
updateLayout(nextLayout);
|
|
7281
|
+
}, [
|
|
7282
|
+
elementRef,
|
|
7283
|
+
heightRatio,
|
|
7284
|
+
mobileKeyboardViewport
|
|
7285
|
+
]);
|
|
7286
|
+
(0, react.useLayoutEffect)(() => {
|
|
7287
|
+
measure();
|
|
7288
|
+
const frame = requestAnimationFrame(measure);
|
|
7289
|
+
return () => cancelAnimationFrame(frame);
|
|
7290
|
+
});
|
|
7291
|
+
return layout;
|
|
7292
|
+
}
|
|
7293
|
+
|
|
7020
7294
|
//#endregion
|
|
7021
7295
|
exports.Accordion = Accordion;
|
|
7022
7296
|
exports.ActionRow = ActionRow;
|
|
@@ -7066,6 +7340,8 @@ exports.MobileConfirm = MobileConfirm;
|
|
|
7066
7340
|
exports.MobileDialog = MobileDialog;
|
|
7067
7341
|
exports.MobileDropdown = MobileDropdown;
|
|
7068
7342
|
exports.MobileDropdownMenu = MobileDropdownMenu;
|
|
7343
|
+
exports.MobileGradientColorPicker = MobileGradientColorPicker;
|
|
7344
|
+
exports.MobileOverlayContext = MobileOverlayContext;
|
|
7069
7345
|
exports.MobileSelect = MobileSelect;
|
|
7070
7346
|
exports.MultipleSelect = MultipleSelect;
|
|
7071
7347
|
exports.Pager = Pager;
|
|
@@ -7111,7 +7387,10 @@ exports.message = message;
|
|
|
7111
7387
|
exports.removeMessage = removeMessage;
|
|
7112
7388
|
exports.render = render;
|
|
7113
7389
|
exports.resetButtonClassName = resetButtonClassName;
|
|
7390
|
+
exports.resolveMobileKeyboardViewportLayout = resolveMobileKeyboardViewportLayout;
|
|
7391
|
+
exports.revealFocusedElementInMobileViewport = revealFocusedElementInMobileViewport;
|
|
7114
7392
|
exports.scrollbarClassName = scrollbarClassName;
|
|
7115
7393
|
exports.selectClassName = selectClassName;
|
|
7116
7394
|
exports.toast = sonner.toast;
|
|
7117
|
-
exports.unmount = unmount;
|
|
7395
|
+
exports.unmount = unmount;
|
|
7396
|
+
exports.useMobileKeyboardViewportLayout = useMobileKeyboardViewportLayout;
|
package/lib/cjs/locale/ar-SA.js
CHANGED
package/lib/cjs/locale/ca-ES.js
CHANGED
package/lib/cjs/locale/de-DE.js
CHANGED
package/lib/cjs/locale/en-US.js
CHANGED
package/lib/cjs/locale/es-ES.js
CHANGED
package/lib/cjs/locale/fa-IR.js
CHANGED
package/lib/cjs/locale/fr-FR.js
CHANGED
package/lib/cjs/locale/id-ID.js
CHANGED
package/lib/cjs/locale/it-IT.js
CHANGED
package/lib/cjs/locale/ja-JP.js
CHANGED
package/lib/cjs/locale/ko-KR.js
CHANGED
package/lib/cjs/locale/pl-PL.js
CHANGED
package/lib/cjs/locale/pt-BR.js
CHANGED
package/lib/cjs/locale/ru-RU.js
CHANGED
package/lib/cjs/locale/sk-SK.js
CHANGED
package/lib/cjs/locale/vi-VN.js
CHANGED
package/lib/cjs/locale/zh-CN.js
CHANGED