@univerjs/ui 1.0.0-alpha.1 → 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 +93 -47
- package/lib/es/index.js +93 -48
- package/lib/index.css +52 -0
- package/lib/index.js +93 -48
- package/lib/types/common/menu-hidden-observable.d.ts +2 -1
- package/lib/types/index.d.ts +6 -4
- package/lib/types/views/font-family/FontFamily.d.ts +10 -2
- package/lib/types/views/font-family/FontFamilyDropdown.d.ts +32 -0
- package/lib/types/views/font-family/FontFamilyItem.d.ts +5 -3
- package/lib/types/views/font-family/index.d.ts +6 -2
- package/lib/types/views/font-family/{interface.d.ts → use-font-list.d.ts} +6 -9
- package/lib/umd/index.js +14 -14
- package/package.json +8 -8
package/lib/index.css
CHANGED
|
@@ -284,6 +284,10 @@
|
|
|
284
284
|
height: 100%;
|
|
285
285
|
}
|
|
286
286
|
|
|
287
|
+
.univer-max-h-72 {
|
|
288
|
+
max-height: 18rem;
|
|
289
|
+
}
|
|
290
|
+
|
|
287
291
|
.univer-max-h-\[80vh\] {
|
|
288
292
|
max-height: 80vh;
|
|
289
293
|
}
|
|
@@ -388,6 +392,10 @@
|
|
|
388
392
|
min-width: 0;
|
|
389
393
|
}
|
|
390
394
|
|
|
395
|
+
.univer-min-w-44 {
|
|
396
|
+
min-width: 11rem;
|
|
397
|
+
}
|
|
398
|
+
|
|
391
399
|
.univer-min-w-52 {
|
|
392
400
|
min-width: 13rem;
|
|
393
401
|
}
|
|
@@ -566,6 +574,10 @@
|
|
|
566
574
|
grid-template-rows: auto 1fr auto;
|
|
567
575
|
}
|
|
568
576
|
|
|
577
|
+
.univer-flex-row {
|
|
578
|
+
flex-direction: row;
|
|
579
|
+
}
|
|
580
|
+
|
|
569
581
|
.univer-flex-col {
|
|
570
582
|
flex-direction: column;
|
|
571
583
|
}
|
|
@@ -1386,10 +1398,50 @@
|
|
|
1386
1398
|
}
|
|
1387
1399
|
}
|
|
1388
1400
|
|
|
1401
|
+
.rtl\:univer-left-0:where([dir="rtl"], [dir="rtl"] *) {
|
|
1402
|
+
left: 0;
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
.rtl\:univer-left-2:where([dir="rtl"], [dir="rtl"] *) {
|
|
1406
|
+
left: .5rem;
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
.rtl\:univer-right-auto:where([dir="rtl"], [dir="rtl"] *) {
|
|
1410
|
+
right: auto;
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
.rtl\:univer-divide-x-reverse:where([dir="rtl"], [dir="rtl"] *) > :not([hidden]) ~ :not([hidden]) {
|
|
1414
|
+
--univer-tw-divide-x-reverse: 1;
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
.rtl\:univer-rounded-l:where([dir="rtl"], [dir="rtl"] *) {
|
|
1418
|
+
border-top-left-radius: .25rem;
|
|
1419
|
+
border-bottom-left-radius: .25rem;
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
.rtl\:univer-rounded-l-none:where([dir="rtl"], [dir="rtl"] *) {
|
|
1423
|
+
border-top-left-radius: 0;
|
|
1424
|
+
border-bottom-left-radius: 0;
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
.rtl\:univer-rounded-r:where([dir="rtl"], [dir="rtl"] *) {
|
|
1428
|
+
border-top-right-radius: .25rem;
|
|
1429
|
+
border-bottom-right-radius: .25rem;
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
.rtl\:univer-rounded-r-none:where([dir="rtl"], [dir="rtl"] *) {
|
|
1433
|
+
border-top-right-radius: 0;
|
|
1434
|
+
border-bottom-right-radius: 0;
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1389
1437
|
.rtl\:univer-pl-1\.5:where([dir="rtl"], [dir="rtl"] *) {
|
|
1390
1438
|
padding-left: .375rem;
|
|
1391
1439
|
}
|
|
1392
1440
|
|
|
1441
|
+
.rtl\:univer-pl-5:where([dir="rtl"], [dir="rtl"] *) {
|
|
1442
|
+
padding-left: 1.25rem;
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1393
1445
|
.rtl\:univer-pr-0:where([dir="rtl"], [dir="rtl"] *) {
|
|
1394
1446
|
padding-right: 0;
|
|
1395
1447
|
}
|
package/lib/index.js
CHANGED
|
@@ -306,11 +306,11 @@ function getHeaderFooterMenuHiddenObservable(accessor) {
|
|
|
306
306
|
return new Observable((subscriber) => {
|
|
307
307
|
const subscription = univerInstanceService.focused$.subscribe((unitId) => {
|
|
308
308
|
if (unitId == null) return subscriber.next(true);
|
|
309
|
-
const docDataModel = univerInstanceService.
|
|
309
|
+
const docDataModel = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
|
|
310
310
|
const documentFlavor = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSnapshot().documentStyle.documentFlavor;
|
|
311
311
|
subscriber.next(documentFlavor !== DocumentFlavor.TRADITIONAL);
|
|
312
312
|
});
|
|
313
|
-
const docDataModel = univerInstanceService.
|
|
313
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
314
314
|
if (docDataModel == null) subscriber.next(true);
|
|
315
315
|
else {
|
|
316
316
|
const documentFlavor = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSnapshot().documentStyle.documentFlavor;
|
|
@@ -2667,14 +2667,14 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
2667
2667
|
//#endregion
|
|
2668
2668
|
//#region src/views/components/ribbon/ToolbarItem.tsx
|
|
2669
2669
|
const toolbarDisabledClassName = "univer-pointer-events-none univer-cursor-not-allowed univer-text-gray-300 dark:!univer-text-gray-600";
|
|
2670
|
-
const toolbarButtonSelectorRootVariants = cva("univer-toolbar-button-selector-root univer-animate-in univer-fade-in univer-group univer-relative univer-flex univer-h-6 univer-cursor-pointer univer-items-center univer-rounded univer-pr-5 univer-text-sm univer-transition-colors hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700", {
|
|
2670
|
+
const toolbarButtonSelectorRootVariants = cva("univer-toolbar-button-selector-root univer-animate-in univer-fade-in univer-group univer-relative univer-flex univer-h-6 univer-cursor-pointer univer-items-center univer-rounded univer-pr-5 univer-text-sm univer-transition-colors hover:univer-bg-gray-100 rtl:univer-pl-5 rtl:univer-pr-0 dark:hover:!univer-bg-gray-700", {
|
|
2671
2671
|
variants: { disabled: {
|
|
2672
2672
|
true: toolbarDisabledClassName,
|
|
2673
2673
|
false: "univer-text-gray-900 dark:!univer-text-white"
|
|
2674
2674
|
} },
|
|
2675
2675
|
defaultVariants: { disabled: false }
|
|
2676
2676
|
});
|
|
2677
|
-
const toolbarButtonSelectorMainVariants = cva("univer-toolbar-button-selector-main univer-relative univer-z-[1] univer-flex univer-h-full univer-items-center univer-rounded-l univer-px-1 univer-transition-colors hover:univer-bg-gray-200 dark:hover:!univer-bg-gray-600", {
|
|
2677
|
+
const toolbarButtonSelectorMainVariants = cva("univer-toolbar-button-selector-main univer-relative univer-z-[1] univer-flex univer-h-full univer-items-center univer-rounded-l univer-px-1 univer-transition-colors hover:univer-bg-gray-200 rtl:univer-rounded-l-none rtl:univer-rounded-r dark:hover:!univer-bg-gray-600", {
|
|
2678
2678
|
variants: {
|
|
2679
2679
|
active: {
|
|
2680
2680
|
true: "univer-bg-gray-200 dark:!univer-bg-gray-500",
|
|
@@ -2695,7 +2695,7 @@ const toolbarButtonSelectorMainVariants = cva("univer-toolbar-button-selector-ma
|
|
|
2695
2695
|
disabled: false
|
|
2696
2696
|
}
|
|
2697
2697
|
});
|
|
2698
|
-
const toolbarButtonSelectorTriggerVariants = cva("univer-toolbar-button-selector-trigger univer-absolute univer-right-0 univer-top-0 univer-box-border univer-flex univer-h-6 univer-w-5 univer-items-center univer-justify-center univer-rounded-r univer-transition-colors hover:univer-bg-gray-200 dark:hover:!univer-bg-gray-600", {
|
|
2698
|
+
const toolbarButtonSelectorTriggerVariants = cva("univer-toolbar-button-selector-trigger univer-absolute univer-right-0 univer-top-0 univer-box-border univer-flex univer-h-6 univer-w-5 univer-items-center univer-justify-center univer-rounded-r univer-transition-colors hover:univer-bg-gray-200 rtl:univer-left-0 rtl:univer-right-auto rtl:univer-rounded-l rtl:univer-rounded-r-none dark:hover:!univer-bg-gray-600", {
|
|
2699
2699
|
variants: {
|
|
2700
2700
|
disabled: {
|
|
2701
2701
|
true: toolbarDisabledClassName,
|
|
@@ -3027,7 +3027,7 @@ function Ribbon(props) {
|
|
|
3027
3027
|
activatedTab,
|
|
3028
3028
|
onSelectTab: handleSelectTab
|
|
3029
3029
|
}), headerMenu && headerMenuComponents && headerMenuComponents.size > 0 && /* @__PURE__ */ jsx("div", {
|
|
3030
|
-
className: "univer-absolute univer-right-2 univer-top-0 univer-flex univer-h-full univer-items-center univer-gap-2 [&>*]:univer-inline-flex [&>*]:univer-h-6 [&>*]:univer-items-center [&>*]:univer-rounded [&>*]:univer-px-1 [&>*]:univer-transition-colors hover:[&>*]:univer-bg-gray-100",
|
|
3030
|
+
className: "univer-absolute univer-right-2 univer-top-0 univer-flex univer-h-full univer-flex-row univer-items-center univer-gap-2 rtl:univer-left-2 rtl:univer-right-auto [&>*]:univer-inline-flex [&>*]:univer-h-6 [&>*]:univer-items-center [&>*]:univer-rounded [&>*]:univer-px-1 [&>*]:univer-transition-colors hover:[&>*]:univer-bg-gray-100",
|
|
3031
3031
|
children: /* @__PURE__ */ jsx(ComponentContainer, { components: headerMenuComponents })
|
|
3032
3032
|
})]
|
|
3033
3033
|
}),
|
|
@@ -3043,7 +3043,7 @@ function Ribbon(props) {
|
|
|
3043
3043
|
}), /* @__PURE__ */ jsxs("div", {
|
|
3044
3044
|
"data-u-comp": "ribbon-toolbar",
|
|
3045
3045
|
ref: containerRef,
|
|
3046
|
-
className: clsx("univer-flex univer-overflow-hidden", divideXClassName, { "univer-justify-center": ribbonType === "classic" }),
|
|
3046
|
+
className: clsx("univer-flex univer-overflow-hidden rtl:univer-divide-x-reverse", divideXClassName, { "univer-justify-center": ribbonType === "classic" }),
|
|
3047
3047
|
role: "toolbar",
|
|
3048
3048
|
"aria-label": localeService.t(activatedTabTitle),
|
|
3049
3049
|
children: [activeGroup.visibleGroups.map((groupItem) => {
|
|
@@ -4198,7 +4198,9 @@ function ContextMenuMenuItem(props) {
|
|
|
4198
4198
|
const submenuRect = submenuElement.getBoundingClientRect();
|
|
4199
4199
|
const rightLeft = menuItemRect.right - submenuOverlapOffset;
|
|
4200
4200
|
const leftLeft = menuItemRect.left - submenuRect.width + submenuOverlapOffset;
|
|
4201
|
-
const
|
|
4201
|
+
const hasLeftSpace = leftLeft >= menuViewportPadding;
|
|
4202
|
+
const hasRightSpace = rightLeft + submenuRect.width + menuViewportPadding <= window.innerWidth;
|
|
4203
|
+
const useLeft = direction === "rtl" ? hasLeftSpace || !hasRightSpace : !hasRightSpace && hasLeftSpace;
|
|
4202
4204
|
const left = useLeft ? leftLeft : rightLeft;
|
|
4203
4205
|
setSubmenuPlacement(useLeft ? "left" : "right");
|
|
4204
4206
|
const maxTop = window.innerHeight - menuViewportPadding - submenuRect.height;
|
|
@@ -4217,6 +4219,7 @@ function ContextMenuMenuItem(props) {
|
|
|
4217
4219
|
window.removeEventListener("scroll", updateSubmenuPosition, true);
|
|
4218
4220
|
};
|
|
4219
4221
|
}, [
|
|
4222
|
+
direction,
|
|
4220
4223
|
submenuVisible,
|
|
4221
4224
|
hasSelectionSubmenu,
|
|
4222
4225
|
hasSubItemSubmenu
|
|
@@ -5257,7 +5260,7 @@ const IUIController = createIdentifier("univer.ui.ui-controller");
|
|
|
5257
5260
|
//#endregion
|
|
5258
5261
|
//#region package.json
|
|
5259
5262
|
var name = "@univerjs/ui";
|
|
5260
|
-
var version = "1.0.0-alpha.
|
|
5263
|
+
var version = "1.0.0-alpha.2";
|
|
5261
5264
|
|
|
5262
5265
|
//#endregion
|
|
5263
5266
|
//#region src/views/color-picker/interface.ts
|
|
@@ -20557,14 +20560,10 @@ let FontService = class FontService {
|
|
|
20557
20560
|
FontService = __decorate([__decorateParam(0, IConfigService)], FontService);
|
|
20558
20561
|
|
|
20559
20562
|
//#endregion
|
|
20560
|
-
//#region src/views/font-family/
|
|
20561
|
-
|
|
20562
|
-
const disabled = useObservable(disabled$);
|
|
20563
|
-
const commandService = useDependency(ICommandService);
|
|
20564
|
-
const localeService = useDependency(LocaleService);
|
|
20563
|
+
//#region src/views/font-family/use-font-list.ts
|
|
20564
|
+
function useFontList() {
|
|
20565
20565
|
const fontService = useDependency(IFontService);
|
|
20566
|
-
const [
|
|
20567
|
-
const [fonts, setFonts] = useState([]);
|
|
20566
|
+
const [fonts, setFonts] = useState(() => fontService.getFonts());
|
|
20568
20567
|
useEffect(() => {
|
|
20569
20568
|
const subscription = fontService.fonts$.subscribe((fonts) => {
|
|
20570
20569
|
setFonts(fonts);
|
|
@@ -20572,7 +20571,22 @@ const FontFamily = ({ id, value, disabled$ }) => {
|
|
|
20572
20571
|
return () => {
|
|
20573
20572
|
subscription.unsubscribe();
|
|
20574
20573
|
};
|
|
20575
|
-
}, []);
|
|
20574
|
+
}, [fontService]);
|
|
20575
|
+
return {
|
|
20576
|
+
fonts,
|
|
20577
|
+
fontService
|
|
20578
|
+
};
|
|
20579
|
+
}
|
|
20580
|
+
|
|
20581
|
+
//#endregion
|
|
20582
|
+
//#region src/views/font-family/FontFamily.tsx
|
|
20583
|
+
const FONT_FAMILY_COMPONENT = "UI_FONT_FAMILY_COMPONENT";
|
|
20584
|
+
const FontFamily = ({ className, disabled: disabledProp, value, disabled$, onChange }) => {
|
|
20585
|
+
const disabledObservableValue = useObservable(disabled$);
|
|
20586
|
+
const disabled = Boolean(disabledProp || disabledObservableValue);
|
|
20587
|
+
const localeService = useDependency(LocaleService);
|
|
20588
|
+
const { fonts } = useFontList();
|
|
20589
|
+
const [draftValue, setDraftValue] = useState(null);
|
|
20576
20590
|
const viewValue = useMemo(() => {
|
|
20577
20591
|
if (value == null) return "";
|
|
20578
20592
|
const font = fonts.find((font) => {
|
|
@@ -20585,14 +20599,12 @@ const FontFamily = ({ id, value, disabled$ }) => {
|
|
|
20585
20599
|
fonts,
|
|
20586
20600
|
localeService
|
|
20587
20601
|
]);
|
|
20588
|
-
|
|
20589
|
-
setInputValue(viewValue);
|
|
20590
|
-
}, [value]);
|
|
20602
|
+
const inputValue = draftValue !== null && draftValue !== void 0 ? draftValue : viewValue;
|
|
20591
20603
|
function resetValue() {
|
|
20592
|
-
|
|
20604
|
+
setDraftValue(null);
|
|
20593
20605
|
}
|
|
20594
20606
|
function handleChangeSelection(e) {
|
|
20595
|
-
|
|
20607
|
+
setDraftValue(e.target.value);
|
|
20596
20608
|
}
|
|
20597
20609
|
function handleKeyDown(e) {
|
|
20598
20610
|
e.stopPropagation();
|
|
@@ -20604,7 +20616,7 @@ const FontFamily = ({ id, value, disabled$ }) => {
|
|
|
20604
20616
|
}
|
|
20605
20617
|
}
|
|
20606
20618
|
function handleBlur() {
|
|
20607
|
-
if (inputValue !==
|
|
20619
|
+
if (draftValue !== null && inputValue !== viewValue) resetValue();
|
|
20608
20620
|
}
|
|
20609
20621
|
function confirm() {
|
|
20610
20622
|
const font = fonts.find((item) => {
|
|
@@ -20616,11 +20628,12 @@ const FontFamily = ({ id, value, disabled$ }) => {
|
|
|
20616
20628
|
}
|
|
20617
20629
|
handleSelectFont(font.value);
|
|
20618
20630
|
}
|
|
20619
|
-
function handleSelectFont(
|
|
20620
|
-
|
|
20631
|
+
function handleSelectFont(nextValue) {
|
|
20632
|
+
resetValue();
|
|
20633
|
+
onChange(nextValue);
|
|
20621
20634
|
}
|
|
20622
20635
|
return /* @__PURE__ */ jsx("div", {
|
|
20623
|
-
className: "univer-w-32 univer-truncate univer-text-sm",
|
|
20636
|
+
className: clsx("univer-w-32 univer-truncate univer-text-sm", className),
|
|
20624
20637
|
style: { fontFamily: value },
|
|
20625
20638
|
children: /* @__PURE__ */ jsx("input", {
|
|
20626
20639
|
className: "univer-block univer-h-6 univer-border-none univer-bg-transparent univer-leading-6 focus:univer-outline-none dark:!univer-text-white [&_input:focus]:!univer-ring-0 [&_input]:univer-h-6 [&_input]:univer-w-7 [&_input]:univer-border-none [&_input]:!univer-bg-transparent [&_input]:univer-p-0 [&_input]:univer-text-sm",
|
|
@@ -20636,23 +20649,12 @@ const FontFamily = ({ id, value, disabled$ }) => {
|
|
|
20636
20649
|
|
|
20637
20650
|
//#endregion
|
|
20638
20651
|
//#region src/views/font-family/FontFamilyItem.tsx
|
|
20639
|
-
const
|
|
20640
|
-
|
|
20641
|
-
const fontService = useDependency(IFontService);
|
|
20642
|
-
const layoutService = useDependency(ILayoutService);
|
|
20643
|
-
const [fonts, setFonts] = useState([]);
|
|
20644
|
-
useEffect(() => {
|
|
20645
|
-
const subscription = fontService.fonts$.subscribe((fonts) => {
|
|
20646
|
-
setFonts(fonts);
|
|
20647
|
-
});
|
|
20648
|
-
return () => {
|
|
20649
|
-
subscription.unsubscribe();
|
|
20650
|
-
};
|
|
20651
|
-
}, []);
|
|
20652
|
+
const FONT_FAMILY_ITEM_COMPONENT = "UI_FONT_FAMILY_ITEM_COMPONENT";
|
|
20653
|
+
const FontFamilyItem = ({ value, onChange }) => {
|
|
20652
20654
|
const localeService = useDependency(LocaleService);
|
|
20653
|
-
|
|
20654
|
-
|
|
20655
|
-
|
|
20655
|
+
const { fonts, fontService } = useFontList();
|
|
20656
|
+
function handleSelectFont(nextValue) {
|
|
20657
|
+
onChange(nextValue);
|
|
20656
20658
|
}
|
|
20657
20659
|
return /* @__PURE__ */ jsx("ul", {
|
|
20658
20660
|
className: "univer-m-0 univer-list-none univer-p-0 univer-text-sm",
|
|
@@ -20671,9 +20673,48 @@ const FontFamilyItem = ({ id, value }) => {
|
|
|
20671
20673
|
};
|
|
20672
20674
|
|
|
20673
20675
|
//#endregion
|
|
20674
|
-
//#region src/views/font-family/
|
|
20675
|
-
|
|
20676
|
-
const
|
|
20676
|
+
//#region src/views/font-family/FontFamilyDropdown.tsx
|
|
20677
|
+
function FontFamilyDropdown(props) {
|
|
20678
|
+
const { value, onChange, ariaLabel, className, disabled: disabledProp, disabled$, inputClassName, popupClassName, popupDataComponent, title, onMouseDown, onPointerDown } = props;
|
|
20679
|
+
const disabledObservableValue = useObservable(disabled$);
|
|
20680
|
+
const disabled = Boolean(disabledProp || disabledObservableValue);
|
|
20681
|
+
const [open, setOpen] = useState(false);
|
|
20682
|
+
const popupDataAttributes = popupDataComponent ? { "data-u-comp": popupDataComponent } : void 0;
|
|
20683
|
+
function handleChange(nextValue) {
|
|
20684
|
+
setOpen(false);
|
|
20685
|
+
onChange(nextValue);
|
|
20686
|
+
}
|
|
20687
|
+
return /* @__PURE__ */ jsx(Dropdown, {
|
|
20688
|
+
disabled,
|
|
20689
|
+
open,
|
|
20690
|
+
onOpenChange: setOpen,
|
|
20691
|
+
overlay: /* @__PURE__ */ jsx("div", {
|
|
20692
|
+
className: clsx("univer-max-h-72 univer-min-w-44 univer-overflow-y-auto univer-rounded-lg univer-border univer-border-solid univer-border-gray-200 univer-bg-white univer-p-1 univer-shadow-lg dark:!univer-border-gray-700 dark:!univer-bg-gray-900", popupClassName),
|
|
20693
|
+
...popupDataAttributes,
|
|
20694
|
+
children: /* @__PURE__ */ jsx(FontFamilyItem, {
|
|
20695
|
+
value,
|
|
20696
|
+
onChange: handleChange
|
|
20697
|
+
})
|
|
20698
|
+
}),
|
|
20699
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
20700
|
+
"aria-disabled": disabled,
|
|
20701
|
+
"aria-expanded": open,
|
|
20702
|
+
"aria-label": ariaLabel,
|
|
20703
|
+
className: clsx("univer-flex univer-h-6 univer-min-w-0 univer-cursor-default univer-items-center univer-justify-between univer-gap-1 univer-rounded-md univer-px-1.5 univer-text-sm univer-text-gray-900 hover:univer-bg-gray-100 dark:!univer-text-gray-100 dark:hover:!univer-bg-gray-700", { "univer-cursor-not-allowed univer-opacity-60": disabled }, className),
|
|
20704
|
+
role: "combobox",
|
|
20705
|
+
tabIndex: disabled ? -1 : 0,
|
|
20706
|
+
title: typeof title === "string" ? title : void 0,
|
|
20707
|
+
onMouseDown,
|
|
20708
|
+
onPointerDown,
|
|
20709
|
+
children: [/* @__PURE__ */ jsx(FontFamily, {
|
|
20710
|
+
className: clsx("univer-min-w-0 univer-flex-1", inputClassName),
|
|
20711
|
+
value,
|
|
20712
|
+
disabled,
|
|
20713
|
+
onChange: handleChange
|
|
20714
|
+
}), /* @__PURE__ */ jsx(MoreDownIcon, { className: "univer-flex-shrink-0 univer-text-xs univer-text-gray-500" })]
|
|
20715
|
+
})
|
|
20716
|
+
});
|
|
20717
|
+
}
|
|
20677
20718
|
|
|
20678
20719
|
//#endregion
|
|
20679
20720
|
//#region src/views/font-size/FontSize.tsx
|
|
@@ -20833,7 +20874,9 @@ const DRAG_COMMIT_INTERVAL = 50;
|
|
|
20833
20874
|
function Slider(props) {
|
|
20834
20875
|
var _getSliderOffset;
|
|
20835
20876
|
const iconManager = useDependency(IconManager);
|
|
20877
|
+
const localeService = useDependency(LocaleService);
|
|
20836
20878
|
const { value, min = 0, max = 400, disabled = false, resetPoint = 100, shortcuts, onChange } = props;
|
|
20879
|
+
const isRtl = useObservable(localeService.direction$, localeService.getDirection()) === "rtl";
|
|
20837
20880
|
const sliderInnerRailRef = useRef(null);
|
|
20838
20881
|
const isEditingZoomRef = useRef(false);
|
|
20839
20882
|
const dragValueRef = useRef(value);
|
|
@@ -20877,6 +20920,7 @@ function Slider(props) {
|
|
|
20877
20920
|
let offsetX = clientX - railRect.x;
|
|
20878
20921
|
if (offsetX <= 0) offsetX = 0;
|
|
20879
20922
|
else if (offsetX >= railWidth) offsetX = railWidth;
|
|
20923
|
+
if (isRtl) offsetX = railWidth - offsetX;
|
|
20880
20924
|
const ratio = offsetX / railWidth;
|
|
20881
20925
|
if (ratio <= .5) return min + ratio * (resetPoint - min) * 2;
|
|
20882
20926
|
return resetPoint + (ratio - .5) * (max - resetPoint) * 2;
|
|
@@ -20995,6 +21039,7 @@ function Slider(props) {
|
|
|
20995
21039
|
}];
|
|
20996
21040
|
const visualValue = isDragging ? dragValue : value;
|
|
20997
21041
|
const sliderOffset = Math.min(Math.max((_getSliderOffset = getSliderOffset(visualValue)) !== null && _getSliderOffset !== void 0 ? _getSliderOffset : 0, 0), 100);
|
|
21042
|
+
const handleOffset = isRtl ? 100 - sliderOffset : sliderOffset;
|
|
20998
21043
|
const ReduceIcon = iconManager.get("ReduceIcon");
|
|
20999
21044
|
const IncreaseIcon = iconManager.get("IncreaseIcon");
|
|
21000
21045
|
const MoreDownIcon = iconManager.get("MoreDownIcon");
|
|
@@ -21021,7 +21066,7 @@ function Slider(props) {
|
|
|
21021
21066
|
onPointerDown: handlePointerDown,
|
|
21022
21067
|
children: [
|
|
21023
21068
|
/* @__PURE__ */ jsx("div", {
|
|
21024
|
-
className: "univer-bg-primary-500/60 univer-absolute univer-
|
|
21069
|
+
className: clsx("univer-bg-primary-500/60 univer-absolute univer-top-0 univer-h-full univer-rounded-full", isRtl ? "univer-right-0" : "univer-left-0"),
|
|
21025
21070
|
style: { width: `${sliderOffset}%` }
|
|
21026
21071
|
}),
|
|
21027
21072
|
/* @__PURE__ */ jsx("a", {
|
|
@@ -21040,7 +21085,7 @@ function Slider(props) {
|
|
|
21040
21085
|
"aria-valuemax": max,
|
|
21041
21086
|
"aria-valuenow": visualValue,
|
|
21042
21087
|
type: "button",
|
|
21043
|
-
style: { left: `${
|
|
21088
|
+
style: { left: `${handleOffset}%` },
|
|
21044
21089
|
onPointerDown: handlePointerDown
|
|
21045
21090
|
})
|
|
21046
21091
|
]
|
|
@@ -24026,4 +24071,4 @@ function ProgressBar(props) {
|
|
|
24026
24071
|
}
|
|
24027
24072
|
|
|
24028
24073
|
//#endregion
|
|
24029
|
-
export { AnchoredContextMenu, BrowserClipboardService, BuiltInUIPart, COLOR_PICKER_COMPONENT, COMMON_LABEL_COMPONENT, CanvasFloatDomService, CanvasPopup, CanvasPopupService, CommonLabel, ComponentContainer, ComponentManager, DesktopContextMenu as ContextMenu, ContextMenuGroup, ContextMenuHostService, ContextMenuPanel, ContextMenuPosition, ContextMenuService, CopyCommand, CopyShortcutItem, CustomLabel, CutCommand, CutShortcutItem, DISABLE_AUTO_FOCUS_KEY, DesktopBeforeCloseService, DesktopConfirmService, DesktopDialogService, DesktopGalleryService, DesktopLayoutService, DesktopLocalFileService, DesktopLocalStorageService, DesktopMessageService, DesktopNotificationService, DesktopRibbonService, DesktopSidebarService, DesktopUIController, EMOJI_CATEGORIES, EMOJI_PICKER_COMPONENT, EMOJI_RECENT_LIMIT, EmojiPicker, ErrorController, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE_SVG_XML_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, FloatDom, FloatDomSingle, FontFamily, FontFamilyItem, FontService, FontSize, HEADING_ITEM_COMPONENT, HEADING_LIST, HTML_CLIPBOARD_MIME_TYPE, HeadingItem, IBeforeCloseService, ICanvasPopupService, IClipboardInterfaceService, IContextMenuHostService, IContextMenuService, IDialogService, IFontService, IGalleryService, ILayoutService, ILeftSidebarService, ILocalFileService, IMenuManagerService, IMessageService, INotificationService, IPlatformService, IRibbonService, IShortcutService, ISidebarService, IUIController, IUIPartsService, IconManager, KeyCode, MenuItemType, MenuManagerPosition, MenuManagerService, MetaKeys, MobileContextMenu, MockMessageService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, PlatformService, PrintFloatDomSingle, ProgressBar, RectPopup, RediConsumer, RediContext, RediProvider, RedoShortcutItem, Ribbon, RibbonDataGroup, RibbonFormulasGroup, RibbonInsertGroup, RibbonOthersGroup, RibbonPosition, RibbonStartGroup, RibbonViewGroup, SharedController, SheetPasteShortKeyCommandName, ShortcutPanelController, ShortcutPanelService, ShortcutService, Sidebar, SingleCanvasPopup, SingleUnitUIController, Slider, ThemeSwitcherService, ToggleShortcutPanelOperation, ToolbarButton, ToolbarItem, menuSchema as UIMenuSchema, UIPartsService, UI_PLUGIN_CONFIG_KEY, UNI_DISABLE_CHANGING_FOCUS_KEY, UndoShortcutItem, UniverMobileUIPlugin, UniverUIPlugin, WithDependency, ZIndexManager, connectDependencies, connectInjector, getAllEmojis, getDefaultRecentEmojis, getEmojiLocaleData, getHeaderFooterMenuHiddenObservable, getLocalizedEmojiTitle, getMenuHiddenObservable, getRandomEmoji, handelExcelToJson, handelTableToJson, handleDomToJson, handlePlainToJson, handleStringToStyle, handleTableColgroup, handleTableMergeData, handleTableRowGroup, imageMimeTypeSet, mergeMenuConfigs, parseHtmlDocument, parseHtmlFragment, parseStoredRecentEmojis, promoteRecentEmoji, sanitizeParsedHtml, searchEmojis, splitSpanText, supportClipboardAPI, textTrim, useClickOutSide, useComponentsOfPart, useConfigValue, useDebounceFn, useDependency, useEvent, useInjector, useObservable, useObservableRef, useScrollYOverContainer, useSidebarClick, useToolbarItemStatus, useUpdateBinder, useUpdateEffect, useVirtualList };
|
|
24074
|
+
export { AnchoredContextMenu, BrowserClipboardService, BuiltInUIPart, COLOR_PICKER_COMPONENT, COMMON_LABEL_COMPONENT, CanvasFloatDomService, CanvasPopup, CanvasPopupService, CommonLabel, ComponentContainer, ComponentManager, DesktopContextMenu as ContextMenu, ContextMenuGroup, ContextMenuHostService, ContextMenuPanel, ContextMenuPosition, ContextMenuService, CopyCommand, CopyShortcutItem, CustomLabel, CutCommand, CutShortcutItem, DISABLE_AUTO_FOCUS_KEY, DesktopBeforeCloseService, DesktopConfirmService, DesktopDialogService, DesktopGalleryService, DesktopLayoutService, DesktopLocalFileService, DesktopLocalStorageService, DesktopMessageService, DesktopNotificationService, DesktopRibbonService, DesktopSidebarService, DesktopUIController, EMOJI_CATEGORIES, EMOJI_PICKER_COMPONENT, EMOJI_RECENT_LIMIT, EmojiPicker, ErrorController, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE_SVG_XML_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, FloatDom, FloatDomSingle, FontFamily, FontFamilyDropdown, FontFamilyItem, FontService, FontSize, HEADING_ITEM_COMPONENT, HEADING_LIST, HTML_CLIPBOARD_MIME_TYPE, HeadingItem, IBeforeCloseService, ICanvasPopupService, IClipboardInterfaceService, IContextMenuHostService, IContextMenuService, IDialogService, IFontService, IGalleryService, ILayoutService, ILeftSidebarService, ILocalFileService, IMenuManagerService, IMessageService, INotificationService, IPlatformService, IRibbonService, IShortcutService, ISidebarService, IUIController, IUIPartsService, IconManager, KeyCode, MenuItemType, MenuManagerPosition, MenuManagerService, MetaKeys, MobileContextMenu, MockMessageService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, PlatformService, PrintFloatDomSingle, ProgressBar, RectPopup, RediConsumer, RediContext, RediProvider, RedoShortcutItem, Ribbon, RibbonDataGroup, RibbonFormulasGroup, RibbonInsertGroup, RibbonOthersGroup, RibbonPosition, RibbonStartGroup, RibbonViewGroup, SharedController, SheetPasteShortKeyCommandName, ShortcutPanelController, ShortcutPanelService, ShortcutService, Sidebar, SingleCanvasPopup, SingleUnitUIController, Slider, ThemeSwitcherService, ToggleShortcutPanelOperation, ToolbarButton, ToolbarItem, menuSchema as UIMenuSchema, UIPartsService, UI_PLUGIN_CONFIG_KEY, UNI_DISABLE_CHANGING_FOCUS_KEY, UndoShortcutItem, UniverMobileUIPlugin, UniverUIPlugin, WithDependency, ZIndexManager, connectDependencies, connectInjector, getAllEmojis, getDefaultRecentEmojis, getEmojiLocaleData, getHeaderFooterMenuHiddenObservable, getLocalizedEmojiTitle, getMenuHiddenObservable, getRandomEmoji, handelExcelToJson, handelTableToJson, handleDomToJson, handlePlainToJson, handleStringToStyle, handleTableColgroup, handleTableMergeData, handleTableRowGroup, imageMimeTypeSet, mergeMenuConfigs, parseHtmlDocument, parseHtmlFragment, parseStoredRecentEmojis, promoteRecentEmoji, sanitizeParsedHtml, searchEmojis, splitSpanText, supportClipboardAPI, textTrim, useClickOutSide, useComponentsOfPart, useConfigValue, useDebounceFn, useDependency, useEvent, useInjector, useObservable, useObservableRef, useScrollYOverContainer, useSidebarClick, useToolbarItemStatus, useUpdateBinder, useUpdateEffect, useVirtualList };
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type { IAccessor
|
|
16
|
+
import type { IAccessor } from '@univerjs/core';
|
|
17
|
+
import { UniverInstanceType } from '@univerjs/core';
|
|
17
18
|
import { Observable } from 'rxjs';
|
|
18
19
|
export declare function getMenuHiddenObservable(accessor: IAccessor, targetUniverType: UniverInstanceType, matchUnitId?: string, needHideUnitId?: string | string[]): Observable<boolean>;
|
|
19
20
|
export declare function getHeaderFooterMenuHiddenObservable(accessor: IAccessor): Observable<boolean>;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -100,10 +100,12 @@ export { ToolbarButton } from './views/components/ribbon/ToolbarButton';
|
|
|
100
100
|
export { ToolbarItem } from './views/components/ribbon/ToolbarItem';
|
|
101
101
|
export { Sidebar } from './views/components/sidebar/Sidebar';
|
|
102
102
|
export type { ISidebarMethodOptions } from './views/components/sidebar/Sidebar';
|
|
103
|
-
export { FontFamily } from './views/font-family/FontFamily';
|
|
104
|
-
export {
|
|
105
|
-
export {
|
|
106
|
-
export type {
|
|
103
|
+
export { FONT_FAMILY_COMPONENT, FontFamily } from './views/font-family/FontFamily';
|
|
104
|
+
export type { IFontFamilyProps } from './views/font-family/FontFamily';
|
|
105
|
+
export { FontFamilyDropdown } from './views/font-family/FontFamilyDropdown';
|
|
106
|
+
export type { IFontFamilyDropdownProps } from './views/font-family/FontFamilyDropdown';
|
|
107
|
+
export { FONT_FAMILY_ITEM_COMPONENT, FontFamilyItem } from './views/font-family/FontFamilyItem';
|
|
108
|
+
export type { IFontFamilyItemProps } from './views/font-family/FontFamilyItem';
|
|
107
109
|
export { FontSize } from './views/font-size/FontSize';
|
|
108
110
|
export { FONT_SIZE_COMPONENT, FONT_SIZE_LIST, HEADING_LIST } from './views/font-size/interface';
|
|
109
111
|
export * from './views/hooks/index';
|
|
@@ -13,5 +13,13 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type {
|
|
17
|
-
|
|
16
|
+
import type { Observable } from 'rxjs';
|
|
17
|
+
import type { ICustomComponentProps } from '../../services/menu/menu';
|
|
18
|
+
export interface IFontFamilyProps extends ICustomComponentProps<string> {
|
|
19
|
+
className?: string;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
value: string;
|
|
22
|
+
disabled$?: Observable<boolean>;
|
|
23
|
+
}
|
|
24
|
+
export declare const FONT_FAMILY_COMPONENT = "UI_FONT_FAMILY_COMPONENT";
|
|
25
|
+
export declare const FontFamily: ({ className, disabled: disabledProp, value, disabled$, onChange }: IFontFamilyProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { MouseEvent, PointerEvent, ReactNode } from 'react';
|
|
17
|
+
import type { Observable } from 'rxjs';
|
|
18
|
+
export interface IFontFamilyDropdownProps {
|
|
19
|
+
value: string;
|
|
20
|
+
onChange: (value: string) => void;
|
|
21
|
+
ariaLabel?: string;
|
|
22
|
+
className?: string;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
disabled$?: Observable<boolean>;
|
|
25
|
+
inputClassName?: string;
|
|
26
|
+
popupClassName?: string;
|
|
27
|
+
popupDataComponent?: string;
|
|
28
|
+
title?: ReactNode;
|
|
29
|
+
onMouseDown?: (event: MouseEvent<HTMLElement>) => void;
|
|
30
|
+
onPointerDown?: (event: PointerEvent<HTMLElement>) => void;
|
|
31
|
+
}
|
|
32
|
+
export declare function FontFamilyDropdown(props: IFontFamilyDropdownProps): import("react").JSX.Element;
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
import type { ICustomComponentProps } from '../../services/menu/menu';
|
|
17
|
+
export interface IFontFamilyItemProps extends ICustomComponentProps<string> {
|
|
18
18
|
value: string;
|
|
19
|
-
}
|
|
19
|
+
}
|
|
20
|
+
export declare const FONT_FAMILY_ITEM_COMPONENT = "UI_FONT_FAMILY_ITEM_COMPONENT";
|
|
21
|
+
export declare const FontFamilyItem: ({ value, onChange }: IFontFamilyItemProps) => import("react").JSX.Element;
|
|
@@ -13,5 +13,9 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export { FontFamily } from './FontFamily';
|
|
17
|
-
export {
|
|
16
|
+
export { FONT_FAMILY_COMPONENT, FontFamily } from './FontFamily';
|
|
17
|
+
export type { IFontFamilyProps } from './FontFamily';
|
|
18
|
+
export { FontFamilyDropdown } from './FontFamilyDropdown';
|
|
19
|
+
export type { IFontFamilyDropdownProps } from './FontFamilyDropdown';
|
|
20
|
+
export { FONT_FAMILY_ITEM_COMPONENT, FontFamilyItem } from './FontFamilyItem';
|
|
21
|
+
export type { IFontFamilyItemProps } from './FontFamilyItem';
|
|
@@ -13,12 +13,9 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type {
|
|
17
|
-
import
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
export declare const FONT_FAMILY_COMPONENT = "UI_FONT_FAMILY_COMPONENT";
|
|
24
|
-
export declare const FONT_FAMILY_ITEM_COMPONENT = "UI_FONT_FAMILY_ITEM_COMPONENT";
|
|
16
|
+
import type { IFontConfig } from '../../services/font.service';
|
|
17
|
+
import { IFontService } from '../../services/font.service';
|
|
18
|
+
export declare function useFontList(): {
|
|
19
|
+
fonts: IFontConfig[];
|
|
20
|
+
fontService: IFontService;
|
|
21
|
+
};
|