@fibery/ui-kit 14.0.0 → 14.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/actions-menu/actions-menu-sub-command-menu.d.ts +2 -0
- package/lib/actions-menu/actions-menu-sub-command-menu.js +3 -2
- package/lib/reactions/get-word-divider.d.ts +1 -1
- package/lib/reactions/get-word-divider.js +7 -6
- package/lib/select/components/menu-list-virtualized.js +19 -33
- package/lib/unit/labeled-unit.d.ts +2 -0
- package/lib/unit/labeled-unit.js +3 -3
- package/lib/unit/labeled-unit.wyw-in-js.css +1 -1
- package/package.json +3 -3
|
@@ -6,6 +6,8 @@ type ActionsMenuSubCommandMenuProps = React.PropsWithChildren<{
|
|
|
6
6
|
trigger?: React.ReactNode;
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
Icon?: FunctionComponent<IconBaseProps>;
|
|
9
|
+
container?: HTMLElement | null;
|
|
10
|
+
contentClassName?: string;
|
|
9
11
|
}>;
|
|
10
12
|
export declare const ActionsMenuSubCommandMenu: React.FC<ActionsMenuSubCommandMenuProps>;
|
|
11
13
|
export declare const ActionsMenuSubCommandMenuRoot: React.FC<React.ComponentPropsWithoutRef<typeof CommandMenuRoot>>;
|
|
@@ -12,7 +12,7 @@ import { composeEventHandlers } from "@fibery/react/src/compose-event-handlers";
|
|
|
12
12
|
import { stopPropagation } from "@fibery/react/src/stop-propagation";
|
|
13
13
|
//#region src/actions-menu/actions-menu-sub-command-menu.tsx
|
|
14
14
|
var [ActionsMenuSubCommandMenuProvider, useActionsMenuSubCommandMenuCtx] = createContext$1("ActionsMenuSubCommandMenu");
|
|
15
|
-
var ActionsMenuSubCommandMenu = ({ disabled, trigger, children, Icon }) => {
|
|
15
|
+
var ActionsMenuSubCommandMenu = ({ disabled, trigger, children, Icon, container, contentClassName }) => {
|
|
16
16
|
const [open, onOpenChange] = useState(false);
|
|
17
17
|
const triggerRef = useRef(null);
|
|
18
18
|
const openRef = useRef(false);
|
|
@@ -30,7 +30,8 @@ var ActionsMenuSubCommandMenu = ({ disabled, trigger, children, Icon }) => {
|
|
|
30
30
|
trigger,
|
|
31
31
|
Icon,
|
|
32
32
|
triggerRef,
|
|
33
|
-
|
|
33
|
+
container,
|
|
34
|
+
contentClassName: cx("c199nm2d-content", contentClassName),
|
|
34
35
|
children: jsx(ActionsMenuSubCommandMenuProvider, {
|
|
35
36
|
value: ctx,
|
|
36
37
|
children
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
//#region src/reactions/get-word-divider.d.ts
|
|
2
|
-
export declare function getWordDivider(length: number, index: number, trailDivider?: string):
|
|
2
|
+
export declare function getWordDivider(length: number, index: number, trailDivider?: string): "" | import("react").JSX.Element;
|
|
3
3
|
//#endregion
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Text } from "../text.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
3
|
//#region src/reactions/get-word-divider.tsx
|
|
3
4
|
function getWordDivider(length, index, trailDivider = " ") {
|
|
4
|
-
if (length === 1) return trailDivider;
|
|
5
|
-
if (length === 2 && index === 0) return /* @__PURE__ */ jsx(
|
|
6
|
-
if (length > 2 && length === index + 2) return /* @__PURE__ */ jsx(
|
|
7
|
-
if (length === index + 1) return trailDivider;
|
|
8
|
-
return ", ";
|
|
5
|
+
if (length === 1) return trailDivider && /* @__PURE__ */ jsx(Text, { children: trailDivider });
|
|
6
|
+
if (length === 2 && index === 0) return /* @__PURE__ */ jsx(Text, { children: "\xA0and " });
|
|
7
|
+
if (length > 2 && length === index + 2) return /* @__PURE__ */ jsx(Text, { children: ",\xA0and " });
|
|
8
|
+
if (length === index + 1) return trailDivider && /* @__PURE__ */ jsx(Text, { children: trailDivider });
|
|
9
|
+
return /* @__PURE__ */ jsx(Text, { children: ", " });
|
|
9
10
|
}
|
|
10
11
|
//#endregion
|
|
11
12
|
export { getWordDivider };
|
|
@@ -4,7 +4,7 @@ import { ReactSelectRefContext, VirtualizedMenuListContext } from "../util.js";
|
|
|
4
4
|
import { fitMenuListHeight } from "./menu.js";
|
|
5
5
|
import { useSelectControlSettings } from "../select-control-settings-context.js";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
import { Children, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
7
|
+
import { Children, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
8
8
|
import { isRecord, truthy } from "@fibery/helpers/src/_";
|
|
9
9
|
import { Virtuoso } from "react-virtuoso";
|
|
10
10
|
//#region src/select/components/menu-list-virtualized.tsx
|
|
@@ -33,7 +33,6 @@ function MenuListVirtualized(props) {
|
|
|
33
33
|
const virtuoso = useRef(null);
|
|
34
34
|
const select = useContext(ReactSelectRefContext);
|
|
35
35
|
const [initialFocusedOption, setInitialFocusedOption] = useState(null);
|
|
36
|
-
const scrollTimeoutRef = useRef(void 0);
|
|
37
36
|
const itemHeight = isPhone ? layout.mobileMenuItemHeight : layout.menuItemHeight;
|
|
38
37
|
const scrollThreshold = itemHeight * MINIMAL_VISIBLE_PORTION_TO_SCROLL_INTO_VIEW;
|
|
39
38
|
const renderGroup = useMemo(() => (Component, headingProps) => {
|
|
@@ -99,39 +98,25 @@ function MenuListVirtualized(props) {
|
|
|
99
98
|
initialFocusedOption,
|
|
100
99
|
select
|
|
101
100
|
]);
|
|
102
|
-
|
|
103
|
-
if (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
align: "start",
|
|
120
|
-
behavior: "auto"
|
|
121
|
-
});
|
|
122
|
-
else if (isBottomCutOff && visibleHeight < itemHeight - scrollThreshold) virtuoso.current?.scrollToIndex({
|
|
123
|
-
index: focusedIndex,
|
|
124
|
-
align: "end",
|
|
125
|
-
behavior: "auto"
|
|
126
|
-
});
|
|
101
|
+
useLayoutEffect(() => {
|
|
102
|
+
if (!initialFocusedOption || focusedOptionValue === null || focusedIndex < 0 || !virtuoso.current) return;
|
|
103
|
+
virtuoso.current.getState((state) => {
|
|
104
|
+
const focusedItemTop = focusedIndex * itemHeight;
|
|
105
|
+
const focusedItemBottom = focusedItemTop + itemHeight;
|
|
106
|
+
const viewportTop = state.scrollTop;
|
|
107
|
+
const viewportBottom = state.scrollTop + menuHeight;
|
|
108
|
+
const hiddenEnough = Math.max(0, Math.min(focusedItemBottom, viewportBottom) - Math.max(focusedItemTop, viewportTop)) < itemHeight - scrollThreshold;
|
|
109
|
+
if (focusedItemTop < viewportTop && hiddenEnough) virtuoso.current?.scrollToIndex({
|
|
110
|
+
index: focusedIndex,
|
|
111
|
+
align: "start",
|
|
112
|
+
behavior: "auto"
|
|
113
|
+
});
|
|
114
|
+
else if (focusedItemBottom > viewportBottom && hiddenEnough) virtuoso.current?.scrollToIndex({
|
|
115
|
+
index: focusedIndex,
|
|
116
|
+
align: "end",
|
|
117
|
+
behavior: "auto"
|
|
127
118
|
});
|
|
128
119
|
});
|
|
129
|
-
return () => {
|
|
130
|
-
if (scrollTimeoutRef.current) {
|
|
131
|
-
window.cancelAnimationFrame(scrollTimeoutRef.current);
|
|
132
|
-
scrollTimeoutRef.current = void 0;
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
120
|
}, [
|
|
136
121
|
focusedOptionValue,
|
|
137
122
|
inputValue,
|
|
@@ -151,6 +136,7 @@ function MenuListVirtualized(props) {
|
|
|
151
136
|
scrollerRef: innerRef,
|
|
152
137
|
style: isPhone && inPopover ? void 0 : { height: menuHeight },
|
|
153
138
|
fixedItemHeight: itemHeight,
|
|
139
|
+
overscan: itemHeight * 3,
|
|
154
140
|
data: flattenChildren,
|
|
155
141
|
totalCount: flattenChildren.length,
|
|
156
142
|
itemContent: drawListElement
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
//#region src/unit/labeled-unit.d.ts
|
|
2
|
+
export declare const unitLabelCss: import("@linaria/core").LinariaClassName;
|
|
3
|
+
export declare const labeledUnitCss: import("@linaria/core").LinariaClassName;
|
|
2
4
|
export declare const UnitLabel: ({ children }: {
|
|
3
5
|
children: React.ReactNode;
|
|
4
6
|
}) => import("react").JSX.Element;
|
package/lib/unit/labeled-unit.js
CHANGED
|
@@ -4,10 +4,10 @@ import { textClasses } from "../design-system/typography.js";
|
|
|
4
4
|
import { cx } from "@linaria/core";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
//#region src/unit/labeled-unit.tsx
|
|
7
|
-
var
|
|
7
|
+
var unitLabelCss = "ufktfg3-unitLabel";
|
|
8
8
|
var labeledUnitCss = "l3ngueb-labeledUnit";
|
|
9
9
|
var UnitLabel = ({ children }) => /* @__PURE__ */ jsx("div", {
|
|
10
|
-
className: cx(textClasses.heading7,
|
|
10
|
+
className: cx(textClasses.heading7, unitLabelCss),
|
|
11
11
|
children
|
|
12
12
|
});
|
|
13
13
|
var LabeledUnit = ({ label, children }) => /* @__PURE__ */ jsxs("div", {
|
|
@@ -15,4 +15,4 @@ var LabeledUnit = ({ label, children }) => /* @__PURE__ */ jsxs("div", {
|
|
|
15
15
|
children: [/* @__PURE__ */ jsx(UnitLabel, { children: label }), children]
|
|
16
16
|
});
|
|
17
17
|
//#endregion
|
|
18
|
-
export { LabeledUnit, UnitLabel };
|
|
18
|
+
export { LabeledUnit, UnitLabel, labeledUnitCss, unitLabelCss };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.
|
|
1
|
+
.ufktfg3-unitLabel{padding-bottom:2px;padding-top:6px;}
|
|
2
2
|
.l3ngueb-labeledUnit{display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;line-height:1.2;width:100%;}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/ui-kit",
|
|
3
|
-
"version": "14.0.
|
|
3
|
+
"version": "14.0.1",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib"
|
|
@@ -85,9 +85,9 @@
|
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
87
|
"@fibery/emoji-data": "4.0.0",
|
|
88
|
-
"@fibery/helpers": "5.
|
|
88
|
+
"@fibery/helpers": "5.3.0",
|
|
89
89
|
"@fibery/icons": "0.1.0",
|
|
90
|
-
"@fibery/react": "3.1.
|
|
90
|
+
"@fibery/react": "3.1.3",
|
|
91
91
|
"@linaria/core": "8.2.0",
|
|
92
92
|
"@linaria/react": "8.2.0",
|
|
93
93
|
"@popperjs/core": "2.11.6",
|