@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/locale/zh-HK.js
CHANGED
package/lib/cjs/locale/zh-TW.js
CHANGED
package/lib/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CalendarIcon, CheckMarkIcon, ClockIcon, CloseIcon, DeleteIcon, DownIcon, ErrorIcon, InfoIcon, LoadingMultiIcon, MoreDownIcon, MoreLeftIcon, MoreRightIcon, MoreUpIcon, OneToOneIcon, SearchIcon, SuccessIcon, WarningIcon, ZoomInIcon, ZoomOutIcon } from "@univerjs/icons";
|
|
2
|
-
import { Children, cloneElement, createContext, forwardRef, isValidElement, memo, useCallback, useContext, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
1
|
+
import { CalendarIcon, CheckMarkIcon, ClockIcon, CloseIcon, DeleteIcon, DownIcon, ErrorIcon, IncreaseIcon, InfoIcon, LoadingMultiIcon, MoreDownIcon, MoreLeftIcon, MoreRightIcon, MoreUpIcon, OneToOneIcon, SearchIcon, SuccessIcon, WarningIcon, ZoomInIcon, ZoomOutIcon } from "@univerjs/icons";
|
|
2
|
+
import { Children, cloneElement, createContext, forwardRef, isValidElement, memo, useCallback, useContext, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState } from "react";
|
|
3
3
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { cva, cva as cva$1 } from "class-variance-authority";
|
|
5
5
|
import { DirectionProvider } from "@radix-ui/react-direction";
|
|
@@ -1959,16 +1959,18 @@ function isBrowser() {
|
|
|
1959
1959
|
//#region src/components/config-provider/ConfigProvider.tsx
|
|
1960
1960
|
const ConfigContext = createContext({ mountContainer: isBrowser() ? document.body : null });
|
|
1961
1961
|
function ConfigProvider(props) {
|
|
1962
|
-
const { children, locale, mountContainer, direction } = props;
|
|
1962
|
+
const { children, locale, mountContainer, direction, mobileKeyboardViewport } = props;
|
|
1963
1963
|
const value = useMemo(() => {
|
|
1964
1964
|
return {
|
|
1965
1965
|
locale,
|
|
1966
1966
|
direction,
|
|
1967
|
-
mountContainer
|
|
1967
|
+
mountContainer,
|
|
1968
|
+
mobileKeyboardViewport
|
|
1968
1969
|
};
|
|
1969
1970
|
}, [
|
|
1970
1971
|
locale,
|
|
1971
1972
|
direction,
|
|
1973
|
+
mobileKeyboardViewport,
|
|
1972
1974
|
mountContainer
|
|
1973
1975
|
]);
|
|
1974
1976
|
return /* @__PURE__ */ jsx(ConfigContext.Provider, {
|
|
@@ -3969,6 +3971,7 @@ function ColorPickerPanel({ value = "#000000", confirmText, onConfirm }) {
|
|
|
3969
3971
|
function MobileDialog(props) {
|
|
3970
3972
|
var _globalThis$CSS;
|
|
3971
3973
|
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;
|
|
3974
|
+
const contentRef = useRef(null);
|
|
3972
3975
|
const { locale, mountContainer, direction } = useContext(ConfigContext);
|
|
3973
3976
|
const maxHeight = ((_globalThis$CSS = globalThis.CSS) === null || _globalThis$CSS === void 0 ? void 0 : _globalThis$CSS.supports("height", "1dvh")) ? "80dvh" : "80vh";
|
|
3974
3977
|
const footer = propFooter ?? (showOk || showCancel ? /* @__PURE__ */ jsxs("div", {
|
|
@@ -3996,7 +3999,13 @@ function MobileDialog(props) {
|
|
|
3996
3999
|
onOpenChange: handleOpenChange,
|
|
3997
4000
|
modal: mask !== false,
|
|
3998
4001
|
children: /* @__PURE__ */ jsxs(DialogContent, {
|
|
3999
|
-
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-
|
|
4002
|
+
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),
|
|
4003
|
+
ref: contentRef,
|
|
4004
|
+
onOpenAutoFocus: (event) => {
|
|
4005
|
+
var _contentRef$current;
|
|
4006
|
+
event.preventDefault();
|
|
4007
|
+
(_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 || _contentRef$current.focus({ preventScroll: true });
|
|
4008
|
+
},
|
|
4000
4009
|
style: {
|
|
4001
4010
|
...style,
|
|
4002
4011
|
position: "fixed",
|
|
@@ -4013,7 +4022,6 @@ function MobileDialog(props) {
|
|
|
4013
4022
|
mountContainer,
|
|
4014
4023
|
overlayClassName,
|
|
4015
4024
|
dir: direction,
|
|
4016
|
-
onClickClose: close,
|
|
4017
4025
|
onEscapeKeyDown: (event) => {
|
|
4018
4026
|
if (keyboard) close();
|
|
4019
4027
|
event.preventDefault();
|
|
@@ -4024,45 +4032,70 @@ function MobileDialog(props) {
|
|
|
4024
4032
|
},
|
|
4025
4033
|
children: [
|
|
4026
4034
|
/* @__PURE__ */ jsxs(DialogHeader, {
|
|
4027
|
-
className: title ?
|
|
4035
|
+
className: title ? "univer-shrink-0 univer-px-10" : "!univer-hidden",
|
|
4028
4036
|
children: [/* @__PURE__ */ jsx(DialogTitle, { children: title }), /* @__PURE__ */ jsx(DialogDescription, { className: "univer-hidden" })]
|
|
4029
4037
|
}),
|
|
4030
|
-
|
|
4031
|
-
|
|
4038
|
+
/* @__PURE__ */ jsx("div", {
|
|
4039
|
+
className: "univer-min-h-0 univer-min-w-0 univer-overflow-y-auto",
|
|
4040
|
+
children
|
|
4041
|
+
}),
|
|
4042
|
+
footer && /* @__PURE__ */ jsx(DialogFooter, {
|
|
4043
|
+
className: "univer-shrink-0",
|
|
4044
|
+
children: footer
|
|
4045
|
+
})
|
|
4032
4046
|
]
|
|
4033
4047
|
})
|
|
4034
4048
|
});
|
|
4035
4049
|
}
|
|
4036
4050
|
|
|
4051
|
+
//#endregion
|
|
4052
|
+
//#region src/components/dropdown/mobile-overlay-context.ts
|
|
4053
|
+
/** The host supplies layout and focus behavior for nested mobile surfaces. */
|
|
4054
|
+
const MobileOverlayContext = createContext(null);
|
|
4055
|
+
|
|
4037
4056
|
//#endregion
|
|
4038
4057
|
//#region src/components/dropdown/MobileDropdownSurface.tsx
|
|
4039
4058
|
function MobileDropdownSurface(props) {
|
|
4040
4059
|
var _globalThis$CSS;
|
|
4041
4060
|
const { children, content, open, disabled, onOpenChange } = props;
|
|
4042
4061
|
const { locale, mountContainer } = useContext(ConfigContext);
|
|
4043
|
-
const
|
|
4062
|
+
const mobileOverlay = useContext(MobileOverlayContext);
|
|
4063
|
+
const [surface, setSurface] = useState(null);
|
|
4064
|
+
const modal = (mobileOverlay === null || mobileOverlay === void 0 ? void 0 : mobileOverlay.modal) ?? true;
|
|
4065
|
+
useLayoutEffect(() => {
|
|
4066
|
+
if (open && surface) return mobileOverlay === null || mobileOverlay === void 0 ? void 0 : mobileOverlay.onMount(surface);
|
|
4067
|
+
}, [
|
|
4068
|
+
open,
|
|
4069
|
+
surface,
|
|
4070
|
+
mobileOverlay
|
|
4071
|
+
]);
|
|
4072
|
+
const viewportHeightUnit = ((_globalThis$CSS = globalThis.CSS) === null || _globalThis$CSS === void 0 ? void 0 : _globalThis$CSS.supports("height", "1dvh")) ? "dvh" : "vh";
|
|
4044
4073
|
return /* @__PURE__ */ jsxs(Dialog$1, {
|
|
4045
4074
|
open,
|
|
4046
4075
|
onOpenChange,
|
|
4047
|
-
modal
|
|
4076
|
+
modal,
|
|
4048
4077
|
children: [/* @__PURE__ */ jsx(DialogTrigger, {
|
|
4049
4078
|
asChild: true,
|
|
4050
4079
|
disabled,
|
|
4051
4080
|
children
|
|
4052
4081
|
}), /* @__PURE__ */ jsxs(DialogContent, {
|
|
4082
|
+
ref: setSurface,
|
|
4053
4083
|
mountContainer,
|
|
4054
4084
|
overlayClassName: "!univer-z-[1390]",
|
|
4055
|
-
className: "!univer-
|
|
4085
|
+
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",
|
|
4056
4086
|
style: {
|
|
4057
4087
|
position: "fixed",
|
|
4058
4088
|
insetInline: 0,
|
|
4059
4089
|
top: "auto",
|
|
4060
4090
|
bottom: 0,
|
|
4091
|
+
maxHeight: `80${viewportHeightUnit}`,
|
|
4061
4092
|
width: "100%",
|
|
4062
|
-
maxHeight,
|
|
4063
4093
|
maxWidth: "none",
|
|
4064
|
-
transform: "none"
|
|
4094
|
+
transform: "none",
|
|
4095
|
+
...mobileOverlay === null || mobileOverlay === void 0 ? void 0 : mobileOverlay.contentProps.style
|
|
4065
4096
|
},
|
|
4097
|
+
onOpenAutoFocus: mobileOverlay === null || mobileOverlay === void 0 ? void 0 : mobileOverlay.contentProps.onOpenAutoFocus,
|
|
4098
|
+
onCloseAutoFocus: mobileOverlay === null || mobileOverlay === void 0 ? void 0 : mobileOverlay.contentProps.onCloseAutoFocus,
|
|
4066
4099
|
children: [
|
|
4067
4100
|
/* @__PURE__ */ jsx("div", {
|
|
4068
4101
|
"aria-hidden": "true",
|
|
@@ -5191,8 +5224,10 @@ const InputNumber = forwardRef(({ value, defaultValue, size = "small", min = Num
|
|
|
5191
5224
|
const longPressTimerRef = useRef(null);
|
|
5192
5225
|
const longPressIntervalRef = useRef(null);
|
|
5193
5226
|
const mergedRef = (node) => {
|
|
5194
|
-
if (ref)
|
|
5195
|
-
|
|
5227
|
+
if (ref) {
|
|
5228
|
+
if (typeof ref === "function") ref(node);
|
|
5229
|
+
else ref.current = node;
|
|
5230
|
+
}
|
|
5196
5231
|
inputRef.current = node;
|
|
5197
5232
|
};
|
|
5198
5233
|
useEffect(() => {
|
|
@@ -5262,7 +5297,8 @@ const InputNumber = forwardRef(({ value, defaultValue, size = "small", min = Num
|
|
|
5262
5297
|
onChange === null || onChange === void 0 || onChange(parsedValue);
|
|
5263
5298
|
}
|
|
5264
5299
|
function handleBlur(e) {
|
|
5265
|
-
|
|
5300
|
+
const currentValue = value !== void 0 ? value : internalValue;
|
|
5301
|
+
if (currentValue === null) {
|
|
5266
5302
|
if (inputValue === "" && allowEmpty) {
|
|
5267
5303
|
if (onChange) onChange(null);
|
|
5268
5304
|
} else {
|
|
@@ -5274,14 +5310,17 @@ const InputNumber = forwardRef(({ value, defaultValue, size = "small", min = Num
|
|
|
5274
5310
|
onBlur === null || onBlur === void 0 || onBlur(e);
|
|
5275
5311
|
return;
|
|
5276
5312
|
}
|
|
5277
|
-
let valueInRange =
|
|
5313
|
+
let valueInRange = currentValue;
|
|
5278
5314
|
if (max !== void 0 && valueInRange > max) valueInRange = max;
|
|
5279
5315
|
if (min !== void 0 && valueInRange < min) valueInRange = min;
|
|
5280
|
-
if (valueInRange !==
|
|
5316
|
+
if (valueInRange !== currentValue) {
|
|
5281
5317
|
setInternalValue(valueInRange);
|
|
5282
5318
|
setInputValue(formatValue(valueInRange));
|
|
5283
5319
|
onChange === null || onChange === void 0 || onChange(valueInRange);
|
|
5284
|
-
} else
|
|
5320
|
+
} else {
|
|
5321
|
+
setInternalValue(currentValue);
|
|
5322
|
+
setInputValue(formatValue(currentValue));
|
|
5323
|
+
}
|
|
5285
5324
|
onBlur === null || onBlur === void 0 || onBlur(e);
|
|
5286
5325
|
}
|
|
5287
5326
|
function handleStep(isUp) {
|
|
@@ -5811,7 +5850,7 @@ function GradientColorPicker(props) {
|
|
|
5811
5850
|
label: locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.diamond,
|
|
5812
5851
|
value: "diamond"
|
|
5813
5852
|
}
|
|
5814
|
-
].map((item) => {
|
|
5853
|
+
].filter((item) => !props.types || props.types.some((type) => type === item.value)).map((item) => {
|
|
5815
5854
|
const selected = draftValue.type === item.value;
|
|
5816
5855
|
return /* @__PURE__ */ jsxs("button", {
|
|
5817
5856
|
type: "button",
|
|
@@ -5839,7 +5878,7 @@ function GradientColorPicker(props) {
|
|
|
5839
5878
|
label: locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.diamond,
|
|
5840
5879
|
value: "diamond"
|
|
5841
5880
|
}
|
|
5842
|
-
],
|
|
5881
|
+
].filter((item) => !props.types || props.types.some((type) => type === item.value)),
|
|
5843
5882
|
value: draftValue.type,
|
|
5844
5883
|
onChange: (v) => handleTypeChange(v)
|
|
5845
5884
|
}),
|
|
@@ -5971,6 +6010,182 @@ function GradientColorPicker(props) {
|
|
|
5971
6010
|
});
|
|
5972
6011
|
}
|
|
5973
6012
|
|
|
6013
|
+
//#endregion
|
|
6014
|
+
//#region src/components/mobile-action-row/MobileActionRow.tsx
|
|
6015
|
+
function MobileActionRow(props) {
|
|
6016
|
+
const { title, icon, value, valueType = "color", trailing, bordered, variant = "surface", className, type = "button", ...buttonProps } = props;
|
|
6017
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
6018
|
+
type,
|
|
6019
|
+
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", {
|
|
6020
|
+
"univer-bg-gray-0 active:univer-bg-gray-100 dark:!univer-bg-gray-800 dark:active:!univer-bg-gray-700": variant === "surface",
|
|
6021
|
+
"univer-bg-gray-100 active:univer-bg-gray-200 dark:!univer-bg-gray-800 dark:active:!univer-bg-gray-700": variant === "subtle"
|
|
6022
|
+
}, bordered && borderBottomClassName, className),
|
|
6023
|
+
...buttonProps,
|
|
6024
|
+
children: [
|
|
6025
|
+
icon,
|
|
6026
|
+
/* @__PURE__ */ jsx("span", {
|
|
6027
|
+
className: "univer-flex-1",
|
|
6028
|
+
children: title
|
|
6029
|
+
}),
|
|
6030
|
+
value && valueType === "color" && /* @__PURE__ */ jsx("span", {
|
|
6031
|
+
className: "univer-size-6 univer-rounded-md univer-border univer-border-solid univer-border-gray-200 dark:!univer-border-gray-600",
|
|
6032
|
+
style: { backgroundColor: value }
|
|
6033
|
+
}),
|
|
6034
|
+
value && valueType === "text" && /* @__PURE__ */ jsx("span", {
|
|
6035
|
+
className: "univer-max-w-32 univer-truncate univer-text-sm univer-font-normal univer-text-gray-500 dark:!univer-text-gray-400",
|
|
6036
|
+
children: value
|
|
6037
|
+
}),
|
|
6038
|
+
trailing
|
|
6039
|
+
]
|
|
6040
|
+
});
|
|
6041
|
+
}
|
|
6042
|
+
|
|
6043
|
+
//#endregion
|
|
6044
|
+
//#region src/components/gradient-color-picker/MobileGradientColorPicker.tsx
|
|
6045
|
+
const GRADIENT_TYPES = [
|
|
6046
|
+
"linear",
|
|
6047
|
+
"radial",
|
|
6048
|
+
"angular",
|
|
6049
|
+
"diamond"
|
|
6050
|
+
];
|
|
6051
|
+
const NUMBER_CLASS = "univer-w-full [&_input]:!univer-h-12 [&_input]:!univer-text-base";
|
|
6052
|
+
function MobileGradientColorPicker({ value = {
|
|
6053
|
+
type: "linear",
|
|
6054
|
+
stops: [{
|
|
6055
|
+
color: "#ffffff",
|
|
6056
|
+
offset: 0
|
|
6057
|
+
}, {
|
|
6058
|
+
color: "#000000",
|
|
6059
|
+
offset: 100
|
|
6060
|
+
}],
|
|
6061
|
+
angle: 0
|
|
6062
|
+
}, onChange, types = GRADIENT_TYPES, className }) {
|
|
6063
|
+
const { locale } = useContext(ConfigContext);
|
|
6064
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
6065
|
+
const index = Math.min(selectedIndex, Math.max(0, value.stops.length - 1));
|
|
6066
|
+
const selectedStop = value.stops[index];
|
|
6067
|
+
function updateStop(patch) {
|
|
6068
|
+
onChange === null || onChange === void 0 || onChange({
|
|
6069
|
+
...value,
|
|
6070
|
+
stops: value.stops.map((stop, stopIndex) => stopIndex === index ? {
|
|
6071
|
+
...stop,
|
|
6072
|
+
...patch
|
|
6073
|
+
} : stop)
|
|
6074
|
+
});
|
|
6075
|
+
}
|
|
6076
|
+
function addStop() {
|
|
6077
|
+
const stop = selectedStop ?? {
|
|
6078
|
+
color: "#ffffff",
|
|
6079
|
+
offset: 0
|
|
6080
|
+
};
|
|
6081
|
+
const nextOffset = value.stops.filter((item) => item.offset > stop.offset).reduce((offset, item) => Math.min(offset, item.offset), 100);
|
|
6082
|
+
onChange === null || onChange === void 0 || onChange({
|
|
6083
|
+
...value,
|
|
6084
|
+
stops: [...value.stops, {
|
|
6085
|
+
...stop,
|
|
6086
|
+
offset: Math.round((stop.offset + nextOffset) / 2)
|
|
6087
|
+
}]
|
|
6088
|
+
});
|
|
6089
|
+
setSelectedIndex(value.stops.length);
|
|
6090
|
+
}
|
|
6091
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
6092
|
+
className: clsx("univer-grid univer-w-full univer-min-w-0 univer-gap-4", className),
|
|
6093
|
+
children: [
|
|
6094
|
+
types.length > 1 && /* @__PURE__ */ jsx("div", {
|
|
6095
|
+
className: "univer-grid univer-grid-cols-2 univer-gap-2",
|
|
6096
|
+
children: types.map((type) => /* @__PURE__ */ jsx(MobileActionRow, {
|
|
6097
|
+
title: locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker[type],
|
|
6098
|
+
"aria-pressed": value.type === type,
|
|
6099
|
+
className: value.type === type ? "!univer-bg-primary-50 !univer-text-primary-600" : void 0,
|
|
6100
|
+
onClick: () => onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
6101
|
+
...value,
|
|
6102
|
+
type
|
|
6103
|
+
})
|
|
6104
|
+
}, type))
|
|
6105
|
+
}),
|
|
6106
|
+
(value.type === "linear" || value.type === "angular") && /* @__PURE__ */ jsxs("label", {
|
|
6107
|
+
className: "univer-grid univer-gap-2 univer-text-base",
|
|
6108
|
+
children: [locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.angle, /* @__PURE__ */ jsx(InputNumber, {
|
|
6109
|
+
className: NUMBER_CLASS,
|
|
6110
|
+
controls: false,
|
|
6111
|
+
value: value.angle ?? 0,
|
|
6112
|
+
min: 0,
|
|
6113
|
+
max: 360,
|
|
6114
|
+
onChange: (angle) => onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
6115
|
+
...value,
|
|
6116
|
+
angle: angle ?? 0
|
|
6117
|
+
})
|
|
6118
|
+
})]
|
|
6119
|
+
}),
|
|
6120
|
+
/* @__PURE__ */ jsxs("div", {
|
|
6121
|
+
className: "univer-flex univer-flex-wrap univer-gap-2",
|
|
6122
|
+
children: [
|
|
6123
|
+
value.stops.map((stop, stopIndex) => /* @__PURE__ */ jsxs("button", {
|
|
6124
|
+
type: "button",
|
|
6125
|
+
"aria-label": `${locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.offset} ${stop.offset}%`,
|
|
6126
|
+
"aria-pressed": index === stopIndex,
|
|
6127
|
+
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"),
|
|
6128
|
+
onClick: () => setSelectedIndex(stopIndex),
|
|
6129
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
6130
|
+
className: "univer-size-6 univer-shrink-0 univer-rounded",
|
|
6131
|
+
style: {
|
|
6132
|
+
backgroundColor: stop.color,
|
|
6133
|
+
opacity: stop.opacity ?? 1
|
|
6134
|
+
}
|
|
6135
|
+
}), `${stop.offset}%`]
|
|
6136
|
+
}, stopIndex)),
|
|
6137
|
+
/* @__PURE__ */ jsx(Button, {
|
|
6138
|
+
className: "univer-size-12",
|
|
6139
|
+
"aria-label": locale === null || locale === void 0 ? void 0 : locale.Accessibility.increment,
|
|
6140
|
+
onClick: addStop,
|
|
6141
|
+
children: /* @__PURE__ */ jsx(IncreaseIcon, {})
|
|
6142
|
+
}),
|
|
6143
|
+
/* @__PURE__ */ jsx(Button, {
|
|
6144
|
+
className: "univer-size-12",
|
|
6145
|
+
"aria-label": locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.delete,
|
|
6146
|
+
disabled: value.stops.length <= 2,
|
|
6147
|
+
onClick: () => {
|
|
6148
|
+
onChange === null || onChange === void 0 || onChange({
|
|
6149
|
+
...value,
|
|
6150
|
+
stops: value.stops.filter((_, stopIndex) => stopIndex !== index)
|
|
6151
|
+
});
|
|
6152
|
+
setSelectedIndex(0);
|
|
6153
|
+
},
|
|
6154
|
+
children: /* @__PURE__ */ jsx(DeleteIcon, {})
|
|
6155
|
+
})
|
|
6156
|
+
]
|
|
6157
|
+
}),
|
|
6158
|
+
selectedStop && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
6159
|
+
className: "univer-grid univer-grid-cols-2 univer-gap-3",
|
|
6160
|
+
children: [/* @__PURE__ */ jsxs("label", {
|
|
6161
|
+
className: "univer-grid univer-gap-2 univer-text-base",
|
|
6162
|
+
children: [locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.offset, /* @__PURE__ */ jsx(InputNumber, {
|
|
6163
|
+
className: NUMBER_CLASS,
|
|
6164
|
+
controls: false,
|
|
6165
|
+
value: selectedStop.offset,
|
|
6166
|
+
min: 0,
|
|
6167
|
+
max: 100,
|
|
6168
|
+
onChange: (offset) => updateStop({ offset: offset ?? 0 })
|
|
6169
|
+
})]
|
|
6170
|
+
}), /* @__PURE__ */ jsxs("label", {
|
|
6171
|
+
className: "univer-grid univer-gap-2 univer-text-base",
|
|
6172
|
+
children: [locale === null || locale === void 0 ? void 0 : locale.GradientColorPicker.transparency, /* @__PURE__ */ jsx(InputNumber, {
|
|
6173
|
+
className: NUMBER_CLASS,
|
|
6174
|
+
controls: false,
|
|
6175
|
+
value: Math.round((1 - (selectedStop.opacity ?? 1)) * 100),
|
|
6176
|
+
min: 0,
|
|
6177
|
+
max: 100,
|
|
6178
|
+
onChange: (transparency) => updateStop({ opacity: 1 - (transparency ?? 0) / 100 })
|
|
6179
|
+
})]
|
|
6180
|
+
})]
|
|
6181
|
+
}), /* @__PURE__ */ jsx(MobileColorPicker, {
|
|
6182
|
+
value: selectedStop.color,
|
|
6183
|
+
onChange: (color) => updateStop({ color })
|
|
6184
|
+
})] })
|
|
6185
|
+
]
|
|
6186
|
+
});
|
|
6187
|
+
}
|
|
6188
|
+
|
|
5974
6189
|
//#endregion
|
|
5975
6190
|
//#region src/components/hover-card/HoverCardPrimitive.tsx
|
|
5976
6191
|
const HoverCardPrimitive = Root$3;
|
|
@@ -6150,36 +6365,6 @@ const removeMessage = (id) => {
|
|
|
6150
6365
|
activeMessageIds.clear();
|
|
6151
6366
|
};
|
|
6152
6367
|
|
|
6153
|
-
//#endregion
|
|
6154
|
-
//#region src/components/mobile-action-row/MobileActionRow.tsx
|
|
6155
|
-
function MobileActionRow(props) {
|
|
6156
|
-
const { title, icon, value, valueType = "color", trailing, bordered, variant = "surface", className, type = "button", ...buttonProps } = props;
|
|
6157
|
-
return /* @__PURE__ */ jsxs("button", {
|
|
6158
|
-
type,
|
|
6159
|
-
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", {
|
|
6160
|
-
"univer-bg-gray-0 active:univer-bg-gray-100 dark:!univer-bg-gray-800 dark:active:!univer-bg-gray-700": variant === "surface",
|
|
6161
|
-
"univer-bg-gray-100 active:univer-bg-gray-200 dark:!univer-bg-gray-800 dark:active:!univer-bg-gray-700": variant === "subtle"
|
|
6162
|
-
}, bordered && borderBottomClassName, className),
|
|
6163
|
-
...buttonProps,
|
|
6164
|
-
children: [
|
|
6165
|
-
icon,
|
|
6166
|
-
/* @__PURE__ */ jsx("span", {
|
|
6167
|
-
className: "univer-flex-1",
|
|
6168
|
-
children: title
|
|
6169
|
-
}),
|
|
6170
|
-
value && valueType === "color" && /* @__PURE__ */ jsx("span", {
|
|
6171
|
-
className: "univer-size-6 univer-rounded-md univer-border univer-border-solid univer-border-gray-200 dark:!univer-border-gray-600",
|
|
6172
|
-
style: { backgroundColor: value }
|
|
6173
|
-
}),
|
|
6174
|
-
value && valueType === "text" && /* @__PURE__ */ jsx("span", {
|
|
6175
|
-
className: "univer-max-w-32 univer-truncate univer-text-sm univer-font-normal univer-text-gray-500 dark:!univer-text-gray-400",
|
|
6176
|
-
children: value
|
|
6177
|
-
}),
|
|
6178
|
-
trailing
|
|
6179
|
-
]
|
|
6180
|
-
});
|
|
6181
|
-
}
|
|
6182
|
-
|
|
6183
6368
|
//#endregion
|
|
6184
6369
|
//#region src/components/panel/Panel.tsx
|
|
6185
6370
|
function Panel(props) {
|
|
@@ -6419,9 +6604,10 @@ function SelectList(props) {
|
|
|
6419
6604
|
const value = Array.isArray(_value) ? _value : [_value];
|
|
6420
6605
|
function handleSelect(newValue) {
|
|
6421
6606
|
const index = value.indexOf(newValue);
|
|
6422
|
-
if (!multiple)
|
|
6423
|
-
|
|
6424
|
-
|
|
6607
|
+
if (!multiple) {
|
|
6608
|
+
if (index > -1) onChange(void 0);
|
|
6609
|
+
else onChange(newValue);
|
|
6610
|
+
} else if (index > -1) onChange(value.filter((i) => i === newValue));
|
|
6425
6611
|
else onChange([...value, newValue]);
|
|
6426
6612
|
}
|
|
6427
6613
|
return /* @__PURE__ */ jsx("ul", {
|
|
@@ -6558,16 +6744,19 @@ function MobileSelect(props) {
|
|
|
6558
6744
|
items,
|
|
6559
6745
|
disabled,
|
|
6560
6746
|
onOpenChange: setOpen,
|
|
6561
|
-
children: /* @__PURE__ */ jsxs("
|
|
6747
|
+
children: /* @__PURE__ */ jsxs("button", {
|
|
6748
|
+
type: "button",
|
|
6749
|
+
disabled,
|
|
6750
|
+
"aria-expanded": open,
|
|
6562
6751
|
"data-u-comp": "mobile-select",
|
|
6563
|
-
className: clsx(selectClassName, {
|
|
6752
|
+
className: clsx(selectClassName, "!univer-h-auto !univer-min-h-12 univer-text-left", {
|
|
6564
6753
|
"univer-border-primary-600 univer-outline-none univer-ring-2 univer-ring-primary-50 dark:!univer-ring-primary-900": open && !borderless,
|
|
6565
6754
|
"univer-border-transparent univer-bg-transparent": borderless,
|
|
6566
6755
|
"univer-cursor-not-allowed": disabled,
|
|
6567
6756
|
"univer-cursor-pointer": !disabled
|
|
6568
6757
|
}, className),
|
|
6569
6758
|
children: [/* @__PURE__ */ jsx("div", {
|
|
6570
|
-
className: "univer-flex-1 univer-truncate univer-text-
|
|
6759
|
+
className: "univer-flex-1 univer-truncate univer-text-base univer-text-gray-500 dark:!univer-text-gray-0",
|
|
6571
6760
|
children: displayValue
|
|
6572
6761
|
}), /* @__PURE__ */ jsx(MoreDownIcon, { className: "univer-flex-shrink-0 dark:!univer-text-gray-0" })]
|
|
6573
6762
|
})
|
|
@@ -7017,4 +7206,89 @@ function unmount(container) {
|
|
|
7017
7206
|
}
|
|
7018
7207
|
|
|
7019
7208
|
//#endregion
|
|
7020
|
-
|
|
7209
|
+
//#region src/hooks/use-mobile-keyboard-viewport.ts
|
|
7210
|
+
function resolveMobileKeyboardViewportLayout(containingBlockTop, containingBlockBottom, viewport, heightRatio) {
|
|
7211
|
+
const visibleTop = Math.max(containingBlockTop, viewport.top);
|
|
7212
|
+
const visibleBottom = Math.min(containingBlockBottom, viewport.bottom);
|
|
7213
|
+
const availableHeight = Math.max(0, visibleBottom - visibleTop);
|
|
7214
|
+
return {
|
|
7215
|
+
availableHeight,
|
|
7216
|
+
bottom: Math.max(0, containingBlockBottom - visibleBottom),
|
|
7217
|
+
height: heightRatio == null ? void 0 : Math.min(viewport.stableHeight * heightRatio, availableHeight)
|
|
7218
|
+
};
|
|
7219
|
+
}
|
|
7220
|
+
function revealFocusedElementInMobileViewport(container, viewport) {
|
|
7221
|
+
const activeElement = document.activeElement;
|
|
7222
|
+
if (!(activeElement instanceof HTMLElement) || !container.contains(activeElement)) return false;
|
|
7223
|
+
const margin = 12;
|
|
7224
|
+
const targetRect = activeElement.getBoundingClientRect();
|
|
7225
|
+
let scrollContainer = activeElement.parentElement;
|
|
7226
|
+
while (scrollContainer && scrollContainer !== container) {
|
|
7227
|
+
const overflowY = getComputedStyle(scrollContainer).overflowY;
|
|
7228
|
+
if ((overflowY === "auto" || overflowY === "scroll") && scrollContainer.scrollHeight > scrollContainer.clientHeight) {
|
|
7229
|
+
const scrollRect = scrollContainer.getBoundingClientRect();
|
|
7230
|
+
const safeTop = Math.max(scrollRect.top, viewport.top) + margin;
|
|
7231
|
+
const safeBottom = Math.min(scrollRect.bottom, viewport.bottom) - margin;
|
|
7232
|
+
if (targetRect.bottom > safeBottom) {
|
|
7233
|
+
const previousScrollTop = scrollContainer.scrollTop;
|
|
7234
|
+
scrollContainer.scrollTop += targetRect.bottom - safeBottom;
|
|
7235
|
+
if (targetRect.bottom - (scrollContainer.scrollTop - previousScrollTop) <= safeBottom) return true;
|
|
7236
|
+
break;
|
|
7237
|
+
}
|
|
7238
|
+
if (targetRect.top < safeTop) {
|
|
7239
|
+
const previousScrollTop = scrollContainer.scrollTop;
|
|
7240
|
+
scrollContainer.scrollTop -= safeTop - targetRect.top;
|
|
7241
|
+
if (targetRect.top + (previousScrollTop - scrollContainer.scrollTop) >= safeTop) return true;
|
|
7242
|
+
break;
|
|
7243
|
+
}
|
|
7244
|
+
return false;
|
|
7245
|
+
}
|
|
7246
|
+
scrollContainer = scrollContainer.parentElement;
|
|
7247
|
+
}
|
|
7248
|
+
const safeTop = viewport.top + margin;
|
|
7249
|
+
const safeBottom = viewport.bottom - margin;
|
|
7250
|
+
if (targetRect.bottom > safeBottom || targetRect.top < safeTop) {
|
|
7251
|
+
activeElement.scrollIntoView({
|
|
7252
|
+
block: "nearest",
|
|
7253
|
+
inline: "nearest"
|
|
7254
|
+
});
|
|
7255
|
+
return true;
|
|
7256
|
+
}
|
|
7257
|
+
return false;
|
|
7258
|
+
}
|
|
7259
|
+
function useMobileKeyboardViewportLayout(elementRef, heightRatio) {
|
|
7260
|
+
const { mobileKeyboardViewport } = useContext(ConfigContext);
|
|
7261
|
+
const [layout, updateLayout] = useReducer((_current, next) => next, null);
|
|
7262
|
+
const layoutRef = useRef(null);
|
|
7263
|
+
const measure = useCallback(() => {
|
|
7264
|
+
const element = elementRef.current;
|
|
7265
|
+
if (!element || !mobileKeyboardViewport) {
|
|
7266
|
+
if (layoutRef.current !== null) {
|
|
7267
|
+
layoutRef.current = null;
|
|
7268
|
+
updateLayout(null);
|
|
7269
|
+
}
|
|
7270
|
+
return;
|
|
7271
|
+
}
|
|
7272
|
+
const containingBlock = element.offsetParent;
|
|
7273
|
+
const fixedToViewport = getComputedStyle(element).position === "fixed" || !containingBlock;
|
|
7274
|
+
const containingBlockRect = containingBlock === null || containingBlock === void 0 ? void 0 : containingBlock.getBoundingClientRect();
|
|
7275
|
+
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);
|
|
7276
|
+
const previous = layoutRef.current;
|
|
7277
|
+
if ((previous === null || previous === void 0 ? void 0 : previous.availableHeight) === nextLayout.availableHeight && previous.bottom === nextLayout.bottom && previous.height === nextLayout.height) return;
|
|
7278
|
+
layoutRef.current = nextLayout;
|
|
7279
|
+
updateLayout(nextLayout);
|
|
7280
|
+
}, [
|
|
7281
|
+
elementRef,
|
|
7282
|
+
heightRatio,
|
|
7283
|
+
mobileKeyboardViewport
|
|
7284
|
+
]);
|
|
7285
|
+
useLayoutEffect(() => {
|
|
7286
|
+
measure();
|
|
7287
|
+
const frame = requestAnimationFrame(measure);
|
|
7288
|
+
return () => cancelAnimationFrame(frame);
|
|
7289
|
+
});
|
|
7290
|
+
return layout;
|
|
7291
|
+
}
|
|
7292
|
+
|
|
7293
|
+
//#endregion
|
|
7294
|
+
export { Accordion, ActionRow, Avatar, Badge, Button, ButtonGroup, Calendar, CascaderList, Checkbox, CheckboxGroup, ColorPicker, ColorPickerPanel, ColorPresets, Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ConfigContext, ConfigProvider, Confirm, DatePicker, DateRangePicker, Dialog, DraggableList, Dropdown, DropdownMenu, FormDualColumnLayout, FormLayout, Gallery, GradientColorPicker, HoverCard, Input, InputNumber, KBD, MessageType, Messager, MobileActionRow, MobileActionRowGroup, MobileColorPicker, MobileColorPresets, MobileConfirm, MobileDialog, MobileDropdown, MobileDropdownMenu, MobileGradientColorPicker, MobileOverlayContext, MobileSelect, MultipleSelect, Pager, Panel, PanelField, PanelSection, Popup, Radio, RadioGroup, Segmented, Select, SelectList, Separator, StateIconButton, 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, resolveMobileKeyboardViewportLayout, revealFocusedElementInMobileViewport, scrollbarClassName, selectClassName, toast, unmount, useMobileKeyboardViewportLayout };
|
package/lib/index.css
CHANGED
|
@@ -337,6 +337,10 @@
|
|
|
337
337
|
display: inline-block;
|
|
338
338
|
}
|
|
339
339
|
|
|
340
|
+
.\!univer-flex {
|
|
341
|
+
display: flex !important;
|
|
342
|
+
}
|
|
343
|
+
|
|
340
344
|
.univer-flex {
|
|
341
345
|
display: flex;
|
|
342
346
|
}
|
|
@@ -371,6 +375,11 @@
|
|
|
371
375
|
height: 2.5rem;
|
|
372
376
|
}
|
|
373
377
|
|
|
378
|
+
.univer-size-12 {
|
|
379
|
+
width: 3rem;
|
|
380
|
+
height: 3rem;
|
|
381
|
+
}
|
|
382
|
+
|
|
374
383
|
.univer-size-2 {
|
|
375
384
|
width: .5rem;
|
|
376
385
|
height: .5rem;
|
|
@@ -430,6 +439,10 @@
|
|
|
430
439
|
height: 2.75rem !important;
|
|
431
440
|
}
|
|
432
441
|
|
|
442
|
+
.\!univer-h-auto {
|
|
443
|
+
height: auto !important;
|
|
444
|
+
}
|
|
445
|
+
|
|
433
446
|
.univer-h-0\.5 {
|
|
434
447
|
height: .125rem;
|
|
435
448
|
}
|
|
@@ -542,6 +555,10 @@
|
|
|
542
555
|
max-height: 100vh;
|
|
543
556
|
}
|
|
544
557
|
|
|
558
|
+
.\!univer-min-h-12 {
|
|
559
|
+
min-height: 3rem !important;
|
|
560
|
+
}
|
|
561
|
+
|
|
545
562
|
.univer-min-h-0 {
|
|
546
563
|
min-height: 0;
|
|
547
564
|
}
|
|
@@ -642,6 +659,10 @@
|
|
|
642
659
|
min-width: 0;
|
|
643
660
|
}
|
|
644
661
|
|
|
662
|
+
.univer-min-w-12 {
|
|
663
|
+
min-width: 3rem;
|
|
664
|
+
}
|
|
665
|
+
|
|
645
666
|
.univer-min-w-28 {
|
|
646
667
|
min-width: 7rem;
|
|
647
668
|
}
|
|
@@ -862,6 +883,10 @@
|
|
|
862
883
|
grid-template-columns: repeat(7, minmax(0, 1fr));
|
|
863
884
|
}
|
|
864
885
|
|
|
886
|
+
.\!univer-flex-col {
|
|
887
|
+
flex-direction: column !important;
|
|
888
|
+
}
|
|
889
|
+
|
|
865
890
|
.univer-flex-col {
|
|
866
891
|
flex-direction: column;
|
|
867
892
|
}
|
|
@@ -1014,6 +1039,10 @@
|
|
|
1014
1039
|
overflow: auto;
|
|
1015
1040
|
}
|
|
1016
1041
|
|
|
1042
|
+
.\!univer-overflow-hidden {
|
|
1043
|
+
overflow: hidden !important;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1017
1046
|
.univer-overflow-hidden {
|
|
1018
1047
|
overflow: hidden;
|
|
1019
1048
|
}
|
|
@@ -1459,6 +1488,11 @@
|
|
|
1459
1488
|
padding-right: .375rem;
|
|
1460
1489
|
}
|
|
1461
1490
|
|
|
1491
|
+
.univer-px-10 {
|
|
1492
|
+
padding-left: 2.5rem;
|
|
1493
|
+
padding-right: 2.5rem;
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1462
1496
|
.univer-px-2 {
|
|
1463
1497
|
padding-left: .5rem;
|
|
1464
1498
|
padding-right: .5rem;
|
|
@@ -3294,6 +3328,10 @@
|
|
|
3294
3328
|
display: flex;
|
|
3295
3329
|
}
|
|
3296
3330
|
|
|
3331
|
+
.\[\&_input\]\:\!univer-h-12 input {
|
|
3332
|
+
height: 3rem !important;
|
|
3333
|
+
}
|
|
3334
|
+
|
|
3297
3335
|
.\[\&_input\]\:univer-h-7 input {
|
|
3298
3336
|
height: 1.75rem;
|
|
3299
3337
|
}
|
|
@@ -3331,6 +3369,11 @@
|
|
|
3331
3369
|
padding-right: .375rem;
|
|
3332
3370
|
}
|
|
3333
3371
|
|
|
3372
|
+
.\[\&_input\]\:\!univer-text-base input {
|
|
3373
|
+
font-size: 1rem !important;
|
|
3374
|
+
line-height: 1.5rem !important;
|
|
3375
|
+
}
|
|
3376
|
+
|
|
3334
3377
|
.\[\&_input\]\:univer-text-sm input {
|
|
3335
3378
|
font-size: .875rem;
|
|
3336
3379
|
line-height: 1.25rem;
|