@univerjs/design 1.0.0-alpha.0 → 1.0.0-alpha.2
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 +60 -47
- package/lib/es/index.js +60 -47
- package/lib/index.css +34 -0
- package/lib/index.js +60 -47
- package/lib/types/components/dialog/DialogPrimitive.d.ts +1 -0
- package/lib/umd/index.js +14 -18
- package/package.json +10 -10
package/lib/index.js
CHANGED
|
@@ -167,32 +167,6 @@ const Button = forwardRef(({ className, variant, size, asChild = false, ...props
|
|
|
167
167
|
});
|
|
168
168
|
Button.displayName = "Button";
|
|
169
169
|
|
|
170
|
-
//#endregion
|
|
171
|
-
//#region src/components/button/ButtonGroup.tsx
|
|
172
|
-
const ButtonGroup = ({ className, orientation = "horizontal", children }) => {
|
|
173
|
-
const totalButtons = Children.count(children);
|
|
174
|
-
const isHorizontal = orientation === "horizontal";
|
|
175
|
-
const isVertical = orientation === "vertical";
|
|
176
|
-
return /* @__PURE__ */ jsx("div", {
|
|
177
|
-
className: clsx("univer-grid", {
|
|
178
|
-
"univer-grid-flow-row": isVertical,
|
|
179
|
-
"univer-w-fit": isVertical
|
|
180
|
-
}, className),
|
|
181
|
-
children: Children.map(children, (child, index) => {
|
|
182
|
-
const isFirst = index === 0;
|
|
183
|
-
const isLast = index === totalButtons - 1;
|
|
184
|
-
return cloneElement(child, { className: clsx({
|
|
185
|
-
"!univer-rounded-l-none": isHorizontal && !isFirst,
|
|
186
|
-
"!univer-rounded-r-none": isHorizontal && !isLast,
|
|
187
|
-
"!univer-border-l-0": isHorizontal && !isFirst,
|
|
188
|
-
"!univer-rounded-t-none": isVertical && !isFirst,
|
|
189
|
-
"!univer-rounded-b-none": isVertical && !isLast,
|
|
190
|
-
"!univer-border-t-0": isVertical && !isFirst
|
|
191
|
-
}, child.props.className) });
|
|
192
|
-
})
|
|
193
|
-
});
|
|
194
|
-
};
|
|
195
|
-
|
|
196
170
|
//#endregion
|
|
197
171
|
//#region src/helper/is-browser.ts
|
|
198
172
|
/**
|
|
@@ -239,6 +213,35 @@ function ConfigProvider(props) {
|
|
|
239
213
|
});
|
|
240
214
|
}
|
|
241
215
|
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region src/components/button/ButtonGroup.tsx
|
|
218
|
+
const ButtonGroup = ({ className, orientation = "horizontal", children }) => {
|
|
219
|
+
const { direction } = useContext(ConfigContext);
|
|
220
|
+
const totalButtons = Children.count(children);
|
|
221
|
+
const isHorizontal = orientation === "horizontal";
|
|
222
|
+
const isVertical = orientation === "vertical";
|
|
223
|
+
const isRtl = direction === "rtl";
|
|
224
|
+
return /* @__PURE__ */ jsx("div", {
|
|
225
|
+
className: clsx("univer-grid", {
|
|
226
|
+
"univer-grid-flow-row": isVertical,
|
|
227
|
+
"univer-w-fit": isVertical
|
|
228
|
+
}, className),
|
|
229
|
+
children: Children.map(children, (child, index) => {
|
|
230
|
+
const isFirst = index === 0;
|
|
231
|
+
const isLast = index === totalButtons - 1;
|
|
232
|
+
return cloneElement(child, { className: clsx({
|
|
233
|
+
"!univer-rounded-l-none": isHorizontal && (isRtl ? !isLast : !isFirst),
|
|
234
|
+
"!univer-rounded-r-none": isHorizontal && (isRtl ? !isFirst : !isLast),
|
|
235
|
+
"!univer-border-l-0": isHorizontal && !isRtl && !isFirst,
|
|
236
|
+
"!univer-border-r-0": isHorizontal && isRtl && !isFirst,
|
|
237
|
+
"!univer-rounded-t-none": isVertical && !isFirst,
|
|
238
|
+
"!univer-rounded-b-none": isVertical && !isLast,
|
|
239
|
+
"!univer-border-t-0": isVertical && !isFirst
|
|
240
|
+
}, child.props.className) });
|
|
241
|
+
})
|
|
242
|
+
});
|
|
243
|
+
};
|
|
244
|
+
|
|
242
245
|
//#endregion
|
|
243
246
|
//#region src/helper/class-utilities.ts
|
|
244
247
|
/**
|
|
@@ -978,22 +981,27 @@ const DialogOverlay = forwardRef(({ className, ...props }, ref) => /* @__PURE__
|
|
|
978
981
|
...props
|
|
979
982
|
}));
|
|
980
983
|
DialogOverlay.displayName = Overlay.displayName;
|
|
981
|
-
const DialogContent = forwardRef(({ className, children, closable = true, onClickClose, ...props }, ref) => /* @__PURE__ */ jsxs(DialogPortal, {
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
className: "univer-
|
|
990
|
-
|
|
984
|
+
const DialogContent = forwardRef(({ className, children, closable = true, onClickClose, mountContainer, ...props }, ref) => /* @__PURE__ */ jsxs(DialogPortal, {
|
|
985
|
+
container: mountContainer !== null && mountContainer !== void 0 ? mountContainer : void 0,
|
|
986
|
+
children: [/* @__PURE__ */ jsx(DialogOverlay, {}), /* @__PURE__ */ jsxs(Content$2, {
|
|
987
|
+
ref,
|
|
988
|
+
className: clsx("data-[state=open]:univer-animate-in data-[state=open]:univer-fade-in-0 data-[state=open]:univer-zoom-in-95 data-[state=open]:univer-slide-in-from-left-1/2 data-[state=open]:univer-slide-in-from-top-[48%] data-[state=closed]:univer-animate-out data-[state=closed]:univer-fade-out-0 data-[state=closed]:univer-zoom-out-95 data-[state=closed]:univer-slide-out-to-left-1/2 data-[state=closed]:univer-slide-out-to-top-[48%] univer-fixed univer-left-1/2 univer-top-1/2 univer-z-[1080] univer-box-border univer-grid univer-w-full univer-max-w-lg -univer-translate-x-1/2 -univer-translate-y-1/2 univer-gap-4 univer-bg-white univer-p-4 univer-text-gray-500 univer-shadow-md univer-duration-200 sm:!univer-rounded-lg dark:!univer-bg-gray-700 dark:!univer-text-gray-400", borderClassName, className),
|
|
989
|
+
...props,
|
|
990
|
+
children: [children, closable && /* @__PURE__ */ jsxs(Close, {
|
|
991
|
+
"data-slot": "close",
|
|
992
|
+
className: "univer-absolute univer-right-4 univer-top-4 univer-size-6 univer-cursor-pointer univer-rounded-sm univer-border-none univer-bg-transparent univer-p-0 univer-transition-opacity hover:univer-opacity-100 disabled:univer-pointer-events-none rtl:univer-left-4 rtl:univer-right-auto",
|
|
993
|
+
onClick: onClickClose,
|
|
994
|
+
children: [/* @__PURE__ */ jsx(CloseIcon, { className: "univer-size-4 univer-text-gray-400" }), /* @__PURE__ */ jsx("span", {
|
|
995
|
+
className: "univer-sr-only",
|
|
996
|
+
children: "Close"
|
|
997
|
+
})]
|
|
991
998
|
})]
|
|
992
999
|
})]
|
|
993
|
-
})
|
|
1000
|
+
}));
|
|
994
1001
|
DialogContent.displayName = Content$2.displayName;
|
|
995
1002
|
const DialogHeader = ({ className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
996
|
-
|
|
1003
|
+
"data-slot": "dialog-header",
|
|
1004
|
+
className: clsx("univer-flex univer-flex-col univer-space-y-1.5 univer-text-center sm:!univer-text-left sm:rtl:!univer-text-right", className),
|
|
997
1005
|
...props
|
|
998
1006
|
});
|
|
999
1007
|
DialogHeader.displayName = "DialogHeader";
|
|
@@ -1136,7 +1144,7 @@ function useDraggable(options = {}) {
|
|
|
1136
1144
|
function Dialog(props) {
|
|
1137
1145
|
var _locale$Confirm$cance, _locale$Confirm, _locale$Confirm$confi, _locale$Confirm2;
|
|
1138
1146
|
const { className, children, style, open = false, title, width, draggable = false, defaultPosition, footer: propFooter, mask = true, keyboard = true, closable = true, maskClosable = true, showOk, showCancel, onOpenChange, onClose, onOk, onCancel } = props;
|
|
1139
|
-
const { locale } = useContext(ConfigContext);
|
|
1147
|
+
const { locale, mountContainer, direction } = useContext(ConfigContext);
|
|
1140
1148
|
const { position, isDragging, setElementRef, handleMouseDown } = useDraggable({
|
|
1141
1149
|
defaultPosition,
|
|
1142
1150
|
enabled: draggable
|
|
@@ -1186,6 +1194,8 @@ function Dialog(props) {
|
|
|
1186
1194
|
} : {}
|
|
1187
1195
|
},
|
|
1188
1196
|
closable,
|
|
1197
|
+
mountContainer,
|
|
1198
|
+
dir: direction,
|
|
1189
1199
|
onClickClose: handleClickClose,
|
|
1190
1200
|
onEscapeKeyDown: (e) => {
|
|
1191
1201
|
if (keyboard) handleClickClose();
|
|
@@ -1452,14 +1462,14 @@ function HexInput({ hsv, onChange }) {
|
|
|
1452
1462
|
if (!isValidHex(inputValue)) setInputValue(hexValue.replace(/^#/, ""));
|
|
1453
1463
|
};
|
|
1454
1464
|
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("input", {
|
|
1455
|
-
className: clsx("univer-w-full univer-px-2 !univer-pl-4 univer-uppercase focus:univer-border-primary-500 focus:univer-outline-none dark:!univer-text-white", borderClassName),
|
|
1465
|
+
className: clsx("univer-w-full univer-px-2 !univer-pl-4 univer-uppercase focus:univer-border-primary-500 focus:univer-outline-none rtl:!univer-pl-2 rtl:!univer-pr-4 dark:!univer-text-white", borderClassName),
|
|
1456
1466
|
value: inputValue,
|
|
1457
1467
|
onChange: handleChange,
|
|
1458
1468
|
onBlur: handleBlur,
|
|
1459
1469
|
maxLength: 6,
|
|
1460
1470
|
spellCheck: false
|
|
1461
1471
|
}), /* @__PURE__ */ jsx("span", {
|
|
1462
|
-
className: "univer-absolute univer-left-1.5 univer-top-1/2 -univer-translate-y-1/2 univer-text-sm univer-text-gray-400",
|
|
1472
|
+
className: "univer-absolute univer-left-1.5 univer-top-1/2 -univer-translate-y-1/2 univer-text-sm univer-text-gray-400 rtl:univer-left-auto rtl:univer-right-1.5",
|
|
1463
1473
|
children: "#"
|
|
1464
1474
|
})] });
|
|
1465
1475
|
}
|
|
@@ -1895,7 +1905,7 @@ const MemoizedColorInput = memo(ColorInput);
|
|
|
1895
1905
|
const MemoizedColorPresets = memo(ColorPresets);
|
|
1896
1906
|
function ColorPicker({ format = "hex", value, onChange }) {
|
|
1897
1907
|
if (!isBrowser) return null;
|
|
1898
|
-
const { locale } = useContext(ConfigContext);
|
|
1908
|
+
const { direction, locale } = useContext(ConfigContext);
|
|
1899
1909
|
const [hsv, setHsv] = useState([
|
|
1900
1910
|
0,
|
|
1901
1911
|
100,
|
|
@@ -1964,6 +1974,7 @@ function ColorPicker({ format = "hex", value, onChange }) {
|
|
|
1964
1974
|
}
|
|
1965
1975
|
return /* @__PURE__ */ jsxs("div", {
|
|
1966
1976
|
"data-u-comp": "color-picker",
|
|
1977
|
+
dir: direction,
|
|
1967
1978
|
className: "univer-cursor-default univer-space-y-2 univer-rounded-lg",
|
|
1968
1979
|
onClick: (e) => e.stopPropagation(),
|
|
1969
1980
|
children: [
|
|
@@ -1984,7 +1995,7 @@ function ColorPicker({ format = "hex", value, onChange }) {
|
|
|
1984
1995
|
})
|
|
1985
1996
|
}),
|
|
1986
1997
|
/* @__PURE__ */ jsx(Dialog, {
|
|
1987
|
-
className: "!univer-w-fit !univer-p-2.5",
|
|
1998
|
+
className: "!univer-z-[1090] !univer-w-fit !univer-p-2.5",
|
|
1988
1999
|
closable: false,
|
|
1989
2000
|
maskClosable: false,
|
|
1990
2001
|
open: visible,
|
|
@@ -2614,6 +2625,7 @@ const inputVariants = cva$1("univer-box-border univer-w-full univer-rounded-md u
|
|
|
2614
2625
|
defaultVariants: { size: "small" }
|
|
2615
2626
|
});
|
|
2616
2627
|
const Input = forwardRef(({ autoFocus = false, className, style, type = "text", placeholder, value, size = "small", allowClear = false, disabled = false, onClick, onKeyDown, onChange, onFocus, onBlur, slot, inputClass, inputStyle, ...props }, ref) => {
|
|
2628
|
+
const { direction } = useContext(ConfigContext);
|
|
2617
2629
|
const handleClear = (e) => {
|
|
2618
2630
|
e.stopPropagation();
|
|
2619
2631
|
onChange === null || onChange === void 0 || onChange("");
|
|
@@ -2648,6 +2660,10 @@ const Input = forwardRef(({ autoFocus = false, className, style, type = "text",
|
|
|
2648
2660
|
useEffect(() => {
|
|
2649
2661
|
if (allowClear && !(slot && slotRef.current)) setPaddingRight(26);
|
|
2650
2662
|
}, []);
|
|
2663
|
+
const mergedInputStyle = direction === "rtl" && paddingRight === 0 ? inputStyle : {
|
|
2664
|
+
...inputStyle,
|
|
2665
|
+
paddingRight
|
|
2666
|
+
};
|
|
2651
2667
|
return /* @__PURE__ */ jsxs("div", {
|
|
2652
2668
|
"data-u-comp": "input",
|
|
2653
2669
|
className: clsx("univer-relative univer-inline-flex univer-w-full univer-items-center univer-rounded-md", disabled && "univer-cursor-not-allowed", className),
|
|
@@ -2665,10 +2681,7 @@ const Input = forwardRef(({ autoFocus = false, className, style, type = "text",
|
|
|
2665
2681
|
onChange: handleChange,
|
|
2666
2682
|
onFocus,
|
|
2667
2683
|
onBlur,
|
|
2668
|
-
style:
|
|
2669
|
-
...inputStyle,
|
|
2670
|
-
paddingRight
|
|
2671
|
-
},
|
|
2684
|
+
style: mergedInputStyle,
|
|
2672
2685
|
...props
|
|
2673
2686
|
}), hasSlotContent && /* @__PURE__ */ jsxs("div", {
|
|
2674
2687
|
className: "univer-absolute univer-right-2 univer-flex univer-items-center univer-gap-1 univer-rounded-full",
|
|
@@ -22,6 +22,7 @@ declare const DialogOverlay: import("react").ForwardRefExoticComponent<Omit<impo
|
|
|
22
22
|
interface IDialogContentProps {
|
|
23
23
|
closable?: boolean;
|
|
24
24
|
onClickClose?: () => void;
|
|
25
|
+
mountContainer?: HTMLElement | null;
|
|
25
26
|
}
|
|
26
27
|
declare const DialogContent: import("react").ForwardRefExoticComponent<Omit<import("@radix-ui/react-dialog").DialogContentProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & IDialogContentProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
27
28
|
declare const DialogHeader: {
|