@fibery/ui-kit 4.0.0 → 4.1.0
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/CHANGELOG.md +12 -0
- package/esfint.config.mjs +0 -17
- package/package.json +5 -6
- package/scripts/generate-icons.mjs +45 -44
- package/src/actions-menu/actions-menu-item.tsx +1 -1
- package/src/actions-menu/context-actions-menu.tsx +1 -1
- package/src/animated-height-container.tsx +1 -1
- package/src/antd/ant-modal.tsx +21 -21
- package/src/antd/styles.ts +2 -0
- package/src/app-icon-with-fallback.tsx +3 -7
- package/src/app-icon-wrapper.tsx +1 -13
- package/src/breadcrumb.tsx +5 -1
- package/src/color-utils.test.ts +2 -2
- package/src/color-utils.ts +2 -2
- package/src/copy-to-clipboard.ts +14 -3
- package/src/date-picker/contexts.ts +6 -3
- package/src/date-picker/date-range-picker.tsx +1 -2
- package/src/date-picker/single-date-picker.tsx +1 -2
- package/src/day-select/iso-week-day-select.tsx +2 -2
- package/src/design-system/colors.ts +3 -3
- package/src/emoji-picker/icon-emoji-picker.tsx +3 -3
- package/src/icons/ast/index.tsx +446 -446
- package/src/icons/icon.tsx +14 -2
- package/src/icons/icons-integrity.test.ts +145 -0
- package/src/icons/react/index.tsx +446 -446
- package/src/images-gallery/images-gallery.tsx +2 -2
- package/src/images-gallery/slide-buttons.tsx +2 -4
- package/src/lists/actions-menu-row-surface.tsx +1 -1
- package/src/media-query-utils.ts +1 -1
- package/src/mobile-keyboard-aware-popup.tsx +1 -1
- package/src/number-input/decimal.ts +6 -9
- package/src/number-input/number-input-inline-with-autosize.tsx +1 -1
- package/src/online-users.tsx +4 -5
- package/src/palettes/inspect.defs.colors.neutral-arch.test.ts +4 -4
- package/src/palettes/inspect.defs.colors.neutral-user.test.ts +4 -4
- package/src/palettes/inspect.defs.colors.warm-arch.test.ts +4 -4
- package/src/palettes/inspect.defs.colors.warm-user.test.ts +4 -4
- package/src/popover/index.tsx +4 -4
- package/src/popover/mobile-popover-context.tsx +1 -1
- package/src/popover/modifiers.tsx +1 -1
- package/src/rich-input-loader.tsx +1 -1
- package/src/select/components/menu-list-virtua.tsx +15 -16
- package/src/select/components/menu-list-virtualized.tsx +26 -29
- package/src/select/components/menu.tsx +3 -3
- package/src/select/index.tsx +1 -1
- package/src/select/reflection.ts +4 -5
- package/src/select/select.tsx +3 -3
- package/src/select/styles.ts +1 -7
- package/src/select/util.ts +2 -2
- package/src/theming.generated.css +8 -8
- package/src/theming.generated.ts +8 -8
- package/src/type-badge.tsx +1 -2
- package/src/use-on-screen-keyboard-data.tsx +1 -1
- package/src/with-data.tsx +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {noop} from "@fibery/helpers/src/_";
|
|
2
2
|
|
|
3
3
|
import "photoswipe/style.css";
|
|
4
|
+
import {createContext} from "@fibery/react/src/create-context";
|
|
4
5
|
import {css} from "@linaria/core";
|
|
5
|
-
import noop from "lodash/noop";
|
|
6
6
|
/* eslint-disable max-lines */
|
|
7
7
|
import PhotoSwipeLightbox, {type PhotoSwipeEventsMap, type PhotoSwipeOptions} from "photoswipe/lightbox";
|
|
8
8
|
import type {PropsWithChildren} from "react";
|
|
@@ -245,11 +245,9 @@ function CopyURLButton({pswp, showUI}: {pswp: PhotoSwipe; showUI: () => void}) {
|
|
|
245
245
|
if (src) {
|
|
246
246
|
copyUrlToClipboard({url: src, label: pswp.currSlide.data.label})
|
|
247
247
|
.then(() => {
|
|
248
|
-
toast.success({title: "
|
|
248
|
+
toast.success({title: "Link copied to clipboard"});
|
|
249
249
|
})
|
|
250
|
-
.catch(() => {
|
|
251
|
-
toast.error({title: "Unable to copy."});
|
|
252
|
-
});
|
|
250
|
+
.catch((error) => toast.error({title: "Unable to copy link to clipboard", subTitle: error.message}));
|
|
253
251
|
}
|
|
254
252
|
}}
|
|
255
253
|
size={isPhone ? "large" : "medium"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import {noop} from "@fibery/helpers/src/_";
|
|
1
2
|
import {stopPropagation} from "@fibery/react/src/stop-propagation";
|
|
2
3
|
import {useCallbackRef} from "@fibery/react/src/use-callback-ref";
|
|
3
4
|
import {css, cx} from "@linaria/core";
|
|
4
|
-
import noop from "lodash/noop";
|
|
5
5
|
import {forwardRef, useId} from "react";
|
|
6
6
|
|
|
7
7
|
import {useActionsMenuContext} from "../actions-menu";
|
package/src/media-query-utils.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import trimEnd from "lodash/trimEnd";
|
|
1
|
+
import {truthy} from "@fibery/helpers/src/_";
|
|
3
2
|
|
|
4
3
|
type NumericValue = string | number | null | undefined;
|
|
5
4
|
|
|
6
|
-
const isEmpty = (value: NumericValue): value is null | undefined | "" => isNil(value) || value === "";
|
|
7
|
-
|
|
8
5
|
const getPrecision = (value: NumericValue) => {
|
|
9
|
-
if (
|
|
6
|
+
if (!truthy(value)) {
|
|
10
7
|
return 0;
|
|
11
8
|
}
|
|
12
9
|
const [, decimalPart = ""] = String(value).split(".");
|
|
@@ -14,11 +11,11 @@ const getPrecision = (value: NumericValue) => {
|
|
|
14
11
|
};
|
|
15
12
|
|
|
16
13
|
const removeTrailingZeros = (value: string) => {
|
|
17
|
-
if (
|
|
14
|
+
if (!truthy(value)) {
|
|
18
15
|
return value;
|
|
19
16
|
}
|
|
20
17
|
const hasDecimalPart = value.indexOf(".") > 0;
|
|
21
|
-
return hasDecimalPart ?
|
|
18
|
+
return hasDecimalPart ? value.replace(/\.?0+$/, "") : value;
|
|
22
19
|
};
|
|
23
20
|
|
|
24
21
|
export const add = (first: NumericValue, second: NumericValue) => {
|
|
@@ -32,7 +29,7 @@ export const sub = (first: NumericValue, second: NumericValue) => {
|
|
|
32
29
|
};
|
|
33
30
|
|
|
34
31
|
export const multiplyByHundred = (value: NumericValue) => {
|
|
35
|
-
if (
|
|
32
|
+
if (!truthy(value)) {
|
|
36
33
|
return value;
|
|
37
34
|
}
|
|
38
35
|
const result = Number(value) * 100;
|
|
@@ -41,7 +38,7 @@ export const multiplyByHundred = (value: NumericValue) => {
|
|
|
41
38
|
};
|
|
42
39
|
|
|
43
40
|
export const divideByHundred = (value: NumericValue) => {
|
|
44
|
-
if (
|
|
41
|
+
if (!truthy(value)) {
|
|
45
42
|
return value;
|
|
46
43
|
}
|
|
47
44
|
const result = Number(value) / 100;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import {identity} from "@fibery/helpers/src/_";
|
|
1
2
|
import {stopPropagation} from "@fibery/react/src/stop-propagation";
|
|
2
3
|
import {css, cx} from "@linaria/core";
|
|
3
|
-
import identity from "lodash/identity";
|
|
4
4
|
import InputNumber from "rc-input-number";
|
|
5
5
|
import {useCallback, useMemo, useRef, useState} from "react";
|
|
6
6
|
|
package/src/online-users.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {css, cx} from "@linaria/core";
|
|
2
|
-
import take from "lodash/take";
|
|
3
2
|
import {useEffect, useRef, useState} from "react";
|
|
4
3
|
|
|
5
4
|
import {AvatarImage} from "./avatar";
|
|
@@ -151,8 +150,9 @@ export function OnlineUsers({
|
|
|
151
150
|
</Tooltip>
|
|
152
151
|
</div>
|
|
153
152
|
|
|
154
|
-
{
|
|
155
|
-
(
|
|
153
|
+
{users
|
|
154
|
+
.slice(0, users.length === maxVisibleUsers ? maxVisibleUsers : maxVisibleUsers - 1)
|
|
155
|
+
.map(({id, avatarUrl, hasAccess, name, callBack, isFollowed}, index) => {
|
|
156
156
|
const tooltipDescription = callBack ? "Click to follow" : "";
|
|
157
157
|
const tooltipTitle = hasAccess ? name : "Private User";
|
|
158
158
|
const userBorderColor = theme.fns.deneutralize(getObjectColorMemoized(name));
|
|
@@ -187,8 +187,7 @@ export function OnlineUsers({
|
|
|
187
187
|
</Tooltip>
|
|
188
188
|
</div>
|
|
189
189
|
);
|
|
190
|
-
}
|
|
191
|
-
)}
|
|
190
|
+
})}
|
|
192
191
|
</div>
|
|
193
192
|
{Boolean(triggerElement) && users.length > maxVisibleUsers && (
|
|
194
193
|
<Popover.Root open={visible} onOpen={() => onShow()} onClose={() => onHide()}>
|
|
@@ -741,19 +741,19 @@ test("snapshot", () => {
|
|
|
741
741
|
"#292929 | hsl(none 0% 16%) | oklch(0.28 0 none)",
|
|
742
742
|
],
|
|
743
743
|
"colorBgListItemGeneralSelected": [
|
|
744
|
-
"#
|
|
745
|
-
"#
|
|
744
|
+
"#F7E0D3 | hsl( 22 69% 90%) | oklch(0.92 0.03 52 )",
|
|
745
|
+
"#4C2A16 | hsl( 22 55% 19%) | oklch(0.32 0.06 50 )",
|
|
746
746
|
],
|
|
747
747
|
"colorBgListItemGeneralSelectedDisabled": [
|
|
748
748
|
"#F7E0D3 | hsl( 22 69% 90%) | oklch(0.92 0.03 52 )",
|
|
749
749
|
"#4C2A16 | hsl( 22 55% 19%) | oklch(0.32 0.06 50 )",
|
|
750
750
|
],
|
|
751
751
|
"colorBgListItemGeneralSelectedFocus": [
|
|
752
|
-
"#
|
|
752
|
+
"#F1D1C0 | hsl( 21 64% 85%) | oklch(0.88 0.04 50 )",
|
|
753
753
|
"#58321C | hsl( 22 52% 23%) | oklch(0.36 0.06 50 )",
|
|
754
754
|
],
|
|
755
755
|
"colorBgListItemGeneralSelectedHover": [
|
|
756
|
-
"#
|
|
756
|
+
"#F1D1C0 | hsl( 21 64% 85%) | oklch(0.88 0.04 50 )",
|
|
757
757
|
"#58321C | hsl( 22 52% 23%) | oklch(0.36 0.06 50 )",
|
|
758
758
|
],
|
|
759
759
|
"colorBgLogoCardDark": [
|
|
@@ -741,19 +741,19 @@ test("snapshot", () => {
|
|
|
741
741
|
"#292929 | hsl(none 0% 16%) | oklch(0.28 0 none)",
|
|
742
742
|
],
|
|
743
743
|
"colorBgListItemGeneralSelected": [
|
|
744
|
-
"#
|
|
745
|
-
"#
|
|
744
|
+
"#DBE5FA | hsl( 221 76% 92%) | oklch(0.92 0.03 265 )",
|
|
745
|
+
"#223259 | hsl( 223 45% 24%) | oklch(0.32 0.07 266 )",
|
|
746
746
|
],
|
|
747
747
|
"colorBgListItemGeneralSelectedDisabled": [
|
|
748
748
|
"#DBE5FA | hsl( 221 76% 92%) | oklch(0.92 0.03 265 )",
|
|
749
749
|
"#223259 | hsl( 223 45% 24%) | oklch(0.32 0.07 266 )",
|
|
750
750
|
],
|
|
751
751
|
"colorBgListItemGeneralSelectedFocus": [
|
|
752
|
-
"#
|
|
752
|
+
"#CAD9F6 | hsl( 220 71% 88%) | oklch(0.88 0.04 264 )",
|
|
753
753
|
"#293B66 | hsl( 222 43% 28%) | oklch(0.36 0.08 266 )",
|
|
754
754
|
],
|
|
755
755
|
"colorBgListItemGeneralSelectedHover": [
|
|
756
|
-
"#
|
|
756
|
+
"#CAD9F6 | hsl( 220 71% 88%) | oklch(0.88 0.04 264 )",
|
|
757
757
|
"#293B66 | hsl( 222 43% 28%) | oklch(0.36 0.08 266 )",
|
|
758
758
|
],
|
|
759
759
|
"colorBgLogoCardDark": [
|
|
@@ -743,19 +743,19 @@ test("snapshot", () => {
|
|
|
743
743
|
"#2D2826 | hsl( 17 8% 16%) | oklch(0.28 0.01 43 )",
|
|
744
744
|
],
|
|
745
745
|
"colorBgListItemGeneralSelected": [
|
|
746
|
-
"#
|
|
747
|
-
"#
|
|
746
|
+
"#FBDFCA | hsl( 26 86% 89%) | oklch(0.92 0.04 59 )",
|
|
747
|
+
"#522609 | hsl( 24 80% 18%) | oklch(0.32 0.08 50 )",
|
|
748
748
|
],
|
|
749
749
|
"colorBgListItemGeneralSelectedDisabled": [
|
|
750
750
|
"#FBDFCA | hsl( 26 86% 89%) | oklch(0.92 0.04 59 )",
|
|
751
751
|
"#522609 | hsl( 24 80% 18%) | oklch(0.32 0.08 50 )",
|
|
752
752
|
],
|
|
753
753
|
"colorBgListItemGeneralSelectedFocus": [
|
|
754
|
-
"#
|
|
754
|
+
"#F7D0B2 | hsl( 26 81% 83%) | oklch(0.88 0.06 59 )",
|
|
755
755
|
"#5E2E0E | hsl( 24 74% 21%) | oklch(0.36 0.08 50 )",
|
|
756
756
|
],
|
|
757
757
|
"colorBgListItemGeneralSelectedHover": [
|
|
758
|
-
"#
|
|
758
|
+
"#F7D0B2 | hsl( 26 81% 83%) | oklch(0.88 0.06 59 )",
|
|
759
759
|
"#5E2E0E | hsl( 24 74% 21%) | oklch(0.36 0.08 50 )",
|
|
760
760
|
],
|
|
761
761
|
"colorBgLogoCardDark": [
|
|
@@ -743,19 +743,19 @@ test("snapshot", () => {
|
|
|
743
743
|
"#2D2826 | hsl( 17 8% 16%) | oklch(0.28 0.01 43 )",
|
|
744
744
|
],
|
|
745
745
|
"colorBgListItemGeneralSelected": [
|
|
746
|
-
"#
|
|
747
|
-
"#
|
|
746
|
+
"#D5E9F0 | hsl( 196 47% 89%) | oklch(0.92 0.02 221 )",
|
|
747
|
+
"#043A48 | hsl( 192 89% 15%) | oklch(0.32 0.06 221 )",
|
|
748
748
|
],
|
|
749
749
|
"colorBgListItemGeneralSelectedDisabled": [
|
|
750
750
|
"#D5E9F0 | hsl( 196 47% 89%) | oklch(0.92 0.02 221 )",
|
|
751
751
|
"#043A48 | hsl( 192 89% 15%) | oklch(0.32 0.06 221 )",
|
|
752
752
|
],
|
|
753
753
|
"colorBgListItemGeneralSelectedFocus": [
|
|
754
|
-
"#
|
|
754
|
+
"#C2DEE8 | hsl( 196 45% 84%) | oklch(0.88 0.03 221 )",
|
|
755
755
|
"#074453 | hsl( 192 84% 18%) | oklch(0.36 0.06 220 )",
|
|
756
756
|
],
|
|
757
757
|
"colorBgListItemGeneralSelectedHover": [
|
|
758
|
-
"#
|
|
758
|
+
"#C2DEE8 | hsl( 196 45% 84%) | oklch(0.88 0.03 221 )",
|
|
759
759
|
"#074453 | hsl( 192 84% 18%) | oklch(0.36 0.06 220 )",
|
|
760
760
|
],
|
|
761
761
|
"colorBgLogoCardDark": [
|
package/src/popover/index.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {truthy} from "@fibery/helpers/src/_";
|
|
1
2
|
import {composeEventHandlers} from "@fibery/react/src/compose-event-handlers";
|
|
2
3
|
import {createContext} from "@fibery/react/src/create-context";
|
|
3
4
|
// oxlint-disable max-lines
|
|
@@ -13,7 +14,6 @@ import type {Options as PreventOverflowOptions} from "@popperjs/core/lib/modifie
|
|
|
13
14
|
import type {FocusScopeProps} from "@radix-ui/react-focus-scope";
|
|
14
15
|
import {FocusScope} from "@radix-ui/react-focus-scope";
|
|
15
16
|
import cx from "classnames";
|
|
16
|
-
import compact from "lodash/compact";
|
|
17
17
|
import type {CSSProperties, MouseEvent, ReactNode} from "react";
|
|
18
18
|
import {
|
|
19
19
|
cloneElement,
|
|
@@ -369,7 +369,7 @@ const Content = forwardRef<ContentRef, PopoverContentProps>((props, ref) => {
|
|
|
369
369
|
}, [padding, preventOverflowOptions, shrinkable]);
|
|
370
370
|
|
|
371
371
|
const modifiers = useMemo(() => {
|
|
372
|
-
return
|
|
372
|
+
return [
|
|
373
373
|
{
|
|
374
374
|
name: "flip",
|
|
375
375
|
options: {
|
|
@@ -399,7 +399,7 @@ const Content = forwardRef<ContentRef, PopoverContentProps>((props, ref) => {
|
|
|
399
399
|
...shrinkableModifiers,
|
|
400
400
|
...additionalModifiers,
|
|
401
401
|
...(popupModifiers.additionalModifiers ?? []),
|
|
402
|
-
]);
|
|
402
|
+
].filter(truthy);
|
|
403
403
|
}, [
|
|
404
404
|
additionalModifiers,
|
|
405
405
|
flipOptions,
|
|
@@ -424,7 +424,7 @@ const Content = forwardRef<ContentRef, PopoverContentProps>((props, ref) => {
|
|
|
424
424
|
}
|
|
425
425
|
const target = event.target;
|
|
426
426
|
if (target instanceof Node) {
|
|
427
|
-
const ignoreElements =
|
|
427
|
+
const ignoreElements = [isElementReference(triggerElement) && triggerElement].filter(truthy);
|
|
428
428
|
if (ignoreElements.some((element) => element.contains(target))) {
|
|
429
429
|
return;
|
|
430
430
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import {noop} from "@fibery/helpers/src/_";
|
|
1
2
|
import {getResizeListener} from "@fibery/helpers/utils/resize-listener";
|
|
2
3
|
import type {Modifier, ModifierArguments, Placement, Boundary, RootBoundary, Padding, Context} from "@popperjs/core";
|
|
3
4
|
import type {Options as PreventOverflowOptions} from "@popperjs/core/lib/modifiers/preventOverflow";
|
|
4
|
-
import noop from "lodash/noop";
|
|
5
5
|
import maxSize from "popper-max-size-modifier";
|
|
6
6
|
|
|
7
7
|
import {isElementReference} from "./reference";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import {noop} from "@fibery/helpers/src/_";
|
|
1
2
|
import {css, cx} from "@linaria/core";
|
|
2
3
|
import {styled} from "@linaria/react";
|
|
3
|
-
import noop from "lodash/noop";
|
|
4
4
|
import {memo, createContext, useContext, useState, useEffect, useMemo} from "react";
|
|
5
5
|
|
|
6
6
|
import {regularRichEditorHTMLStyles} from "./html-styles";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {truthy} from "@fibery/helpers/src/_";
|
|
2
2
|
import type {ComponentType, CSSProperties, ReactNode} from "react";
|
|
3
3
|
import {Children, useContext, useEffect, useMemo, useRef, useState} from "react";
|
|
4
4
|
import type {GroupHeadingProps, GroupProps, MenuListProps} from "react-select";
|
|
@@ -15,22 +15,21 @@ function flattenGroupChildren(
|
|
|
15
15
|
children: ReactNode,
|
|
16
16
|
renderGroup: (Component: ComponentType<GroupHeadingProps>, props: GroupProps["headingProps"]) => ReactNode
|
|
17
17
|
): ReactNode[] {
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return [];
|
|
26
|
-
}
|
|
27
|
-
const heading = renderGroup(props.Heading, props.headingProps);
|
|
28
|
-
return [heading, ...groupChildren];
|
|
18
|
+
return Children.toArray(children)
|
|
19
|
+
.map((child) => {
|
|
20
|
+
if (isReactElementWithProps(child) && isGroupChild(child)) {
|
|
21
|
+
const {props} = child;
|
|
22
|
+
const groupChildren = Children.toArray(props.children).filter(truthy);
|
|
23
|
+
if (!groupChildren.length) {
|
|
24
|
+
return [];
|
|
29
25
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
const heading = renderGroup(props.Heading, props.headingProps);
|
|
27
|
+
return [heading, ...groupChildren];
|
|
28
|
+
}
|
|
29
|
+
return child;
|
|
30
|
+
})
|
|
31
|
+
.flat()
|
|
32
|
+
.filter(truthy);
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
/**
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import isFunction from "lodash/isFunction";
|
|
3
|
-
import isObject from "lodash/isObject";
|
|
1
|
+
import {isRecord, truthy} from "@fibery/helpers/src/_";
|
|
4
2
|
import type {ComponentType, CSSProperties, ReactNode} from "react";
|
|
5
3
|
import {Children, useContext, useEffect, useMemo, useRef, useState} from "react";
|
|
6
4
|
import type {GroupHeadingProps, GroupProps, MenuListProps} from "react-select";
|
|
@@ -20,12 +18,12 @@ function isGroupChild<Option, isMulty extends boolean, Group extends GroupBase<O
|
|
|
20
18
|
props: unknown
|
|
21
19
|
): props is GroupProps<Option, isMulty, Group> {
|
|
22
20
|
return (
|
|
23
|
-
|
|
21
|
+
isRecord(props) &&
|
|
24
22
|
"options" in props &&
|
|
25
23
|
"Heading" in props &&
|
|
26
|
-
|
|
24
|
+
typeof props.Heading === "function" &&
|
|
27
25
|
"headingProps" in props &&
|
|
28
|
-
|
|
26
|
+
isRecord(props.headingProps)
|
|
29
27
|
);
|
|
30
28
|
}
|
|
31
29
|
|
|
@@ -33,27 +31,26 @@ const flattenGroupChildren: (
|
|
|
33
31
|
children: ReactNode,
|
|
34
32
|
renderGroup: (Component: ComponentType<GroupHeadingProps>, props: GroupProps["headingProps"]) => ReactNode
|
|
35
33
|
) => ReactNode[] = (children, renderGroup) => {
|
|
36
|
-
return
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return [];
|
|
47
|
-
}
|
|
48
|
-
const heading = renderGroup(props.Heading, props.headingProps);
|
|
49
|
-
return [heading, ...children];
|
|
34
|
+
return Children.toArray(children)
|
|
35
|
+
.map((child) => {
|
|
36
|
+
if (isRecord(child) && "props" in child && isRecord(child.props)) {
|
|
37
|
+
const {props} = child;
|
|
38
|
+
if (isGroupChild(props)) {
|
|
39
|
+
//well, it's a group
|
|
40
|
+
const children = Children.toArray(props.children).filter(truthy);
|
|
41
|
+
if (!children.length) {
|
|
42
|
+
// do not render empty groups
|
|
43
|
+
return [];
|
|
50
44
|
}
|
|
45
|
+
const heading = renderGroup(props.Heading, props.headingProps);
|
|
46
|
+
return [heading, ...children];
|
|
51
47
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
}
|
|
49
|
+
//if not a group, just keep child as is
|
|
50
|
+
return child;
|
|
51
|
+
})
|
|
52
|
+
.flat()
|
|
53
|
+
.filter(truthy);
|
|
57
54
|
};
|
|
58
55
|
|
|
59
56
|
const drawListElement: ItemContent<ReactNode, never> = (index, child) => child;
|
|
@@ -111,7 +108,7 @@ export function MenuListVirtualized<
|
|
|
111
108
|
return -1;
|
|
112
109
|
}
|
|
113
110
|
return flattenChildren.findIndex((child) => {
|
|
114
|
-
if (
|
|
111
|
+
if (isRecord(child) && "props" in child && isRecord(child.props) && "data" in child.props) {
|
|
115
112
|
return child.props.data === focusedOption;
|
|
116
113
|
}
|
|
117
114
|
return false;
|
|
@@ -128,14 +125,14 @@ export function MenuListVirtualized<
|
|
|
128
125
|
for (let i = 0; i < flattenChildren.length; i++) {
|
|
129
126
|
const child = flattenChildren[i];
|
|
130
127
|
if (
|
|
131
|
-
|
|
128
|
+
isRecord(child) &&
|
|
132
129
|
"props" in child &&
|
|
133
|
-
|
|
130
|
+
isRecord(child.props) &&
|
|
134
131
|
"type" in child.props &&
|
|
135
132
|
child.props.type === "option" &&
|
|
136
133
|
"isSelected" in child.props
|
|
137
134
|
) {
|
|
138
|
-
if ("data" in child.props &&
|
|
135
|
+
if ("data" in child.props && isRecord(child.props.data)) {
|
|
139
136
|
if ("isSelected" in child.props && child.props.isSelected) {
|
|
140
137
|
selectedOption = child.props.data;
|
|
141
138
|
break;
|
|
@@ -13,12 +13,12 @@ export const MenuListNulledStyles: CSSObjectWithLabel = {
|
|
|
13
13
|
};
|
|
14
14
|
export const MenuNulledStyles: CSSObjectWithLabel = {
|
|
15
15
|
backgroundColor: "",
|
|
16
|
-
borderRadius: "",
|
|
17
16
|
boxShadow: "",
|
|
18
17
|
marginTop: 0,
|
|
19
18
|
marginBottom: 0,
|
|
20
|
-
paddingTop: space.
|
|
21
|
-
paddingBottom: space.
|
|
19
|
+
paddingTop: space.s6,
|
|
20
|
+
paddingBottom: space.s6,
|
|
21
|
+
borderRadius: border.radius8,
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
const menuCss = css`
|
package/src/select/index.tsx
CHANGED
package/src/select/reflection.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import isObject from "lodash/isObject";
|
|
1
|
+
import {isRecord} from "@fibery/helpers/src/_";
|
|
3
2
|
import type {GroupProps} from "react-select/dist/declarations/src";
|
|
4
3
|
|
|
5
4
|
import type {GroupBase} from "./util";
|
|
@@ -7,7 +6,7 @@ import type {GroupBase} from "./util";
|
|
|
7
6
|
type ReactElementWithProps<P = object> = {props: P};
|
|
8
7
|
|
|
9
8
|
export function isReactElementWithProps(node: unknown): node is ReactElementWithProps {
|
|
10
|
-
return
|
|
9
|
+
return isRecord(node) && "props" in node && isRecord(node.props);
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
export function isGroupChild<Option, IsMulti extends boolean, Group extends GroupBase<Option> = GroupBase<Option>>(
|
|
@@ -16,8 +15,8 @@ export function isGroupChild<Option, IsMulti extends boolean, Group extends Grou
|
|
|
16
15
|
return (
|
|
17
16
|
"options" in node.props &&
|
|
18
17
|
"Heading" in node.props &&
|
|
19
|
-
|
|
18
|
+
typeof node.props.Heading === "function" &&
|
|
20
19
|
"headingProps" in node.props &&
|
|
21
|
-
|
|
20
|
+
isRecord(node.props.headingProps)
|
|
22
21
|
);
|
|
23
22
|
}
|
package/src/select/select.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import {truthy} from "@fibery/helpers/src/_";
|
|
1
2
|
import {composeEventHandlers} from "@fibery/react/src/compose-event-handlers";
|
|
2
3
|
import {useComposedRefs} from "@fibery/react/src/use-composed-refs";
|
|
3
|
-
import compact from "lodash/compact";
|
|
4
4
|
import type {ForwardedRef, RefObject} from "react";
|
|
5
5
|
import {forwardRef, useCallback, useMemo, useRef, useState} from "react";
|
|
6
6
|
import type {
|
|
@@ -128,12 +128,12 @@ function useSelectStyles<T, U extends boolean, V extends GroupBase<T>>({
|
|
|
128
128
|
}) {
|
|
129
129
|
return useMemo(() => {
|
|
130
130
|
return composeStyles<T, U, V>(
|
|
131
|
-
|
|
131
|
+
[
|
|
132
132
|
makeComponentsStyles<T, U, V>(),
|
|
133
133
|
virtualized ? makeVirtualizedStyles<T, U, V>() : makeNonVirtualizedStyles<T, U, V>(),
|
|
134
134
|
zIndex ? makeZIndexStyles<T, U, V>(zIndex) : null,
|
|
135
135
|
styles,
|
|
136
|
-
])
|
|
136
|
+
].filter(truthy)
|
|
137
137
|
);
|
|
138
138
|
}, [styles, virtualized, zIndex]);
|
|
139
139
|
}
|
package/src/select/styles.ts
CHANGED
|
@@ -53,13 +53,7 @@ export const makeVirtualizedStyles = <T, U extends boolean, V extends GroupBase<
|
|
|
53
53
|
}),
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
export const makeNonVirtualizedStyles = <T, U extends boolean, V extends GroupBase<T>>(): StylesConfig<T, U, V> => ({
|
|
57
|
-
menuList: (provided) => ({
|
|
58
|
-
...provided,
|
|
59
|
-
paddingTop: 6,
|
|
60
|
-
paddingBottom: 6,
|
|
61
|
-
}),
|
|
62
|
-
});
|
|
56
|
+
export const makeNonVirtualizedStyles = <T, U extends boolean, V extends GroupBase<T>>(): StylesConfig<T, U, V> => ({});
|
|
63
57
|
|
|
64
58
|
export const makeZIndexStyles = <T, U extends boolean, V extends GroupBase<T>>(
|
|
65
59
|
zIndex: number
|
package/src/select/util.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {isRecord} from "@fibery/helpers/src/_";
|
|
2
2
|
import type {ReactNode, RefObject} from "react";
|
|
3
3
|
import {Children, createContext} from "react";
|
|
4
4
|
import type {GroupBase as ReactSelectGroupBase, OptionsOrGroups, SelectInstance} from "react-select";
|
|
@@ -11,7 +11,7 @@ export type GroupBase<T> = ReactSelectGroupBase<T> & {separator?: boolean; separ
|
|
|
11
11
|
export function isGroup<Option, Group extends GroupBase<Option>>(
|
|
12
12
|
optionOrGroup: Option | Group
|
|
13
13
|
): optionOrGroup is Group {
|
|
14
|
-
return
|
|
14
|
+
return isRecord(optionOrGroup) && "options" in optionOrGroup;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export function countOptions<Option, Group extends GroupBase<Option>>(
|
|
@@ -160,9 +160,9 @@
|
|
|
160
160
|
--fibery-color-colorBgListItemGeneral: rgba(255, 255, 255, 0);
|
|
161
161
|
--fibery-color-colorBgListItemGeneralHover: rgb(245, 245, 245);
|
|
162
162
|
--fibery-color-colorBgListItemGeneralFocus: rgb(237, 237, 237);
|
|
163
|
-
--fibery-color-colorBgListItemGeneralSelected: #
|
|
164
|
-
--fibery-color-colorBgListItemGeneralSelectedHover: #
|
|
165
|
-
--fibery-color-colorBgListItemGeneralSelectedFocus: #
|
|
163
|
+
--fibery-color-colorBgListItemGeneralSelected: #dbe5fa;
|
|
164
|
+
--fibery-color-colorBgListItemGeneralSelectedHover: #cad9f6;
|
|
165
|
+
--fibery-color-colorBgListItemGeneralSelectedFocus: #cad9f6;
|
|
166
166
|
--fibery-color-colorBgListItemGeneralDisabled: rgba(255, 255, 255, 0);
|
|
167
167
|
--fibery-color-colorTextListItemGeneralDisabled: rgb(158, 158, 158);
|
|
168
168
|
--fibery-color-colorBgListItemGeneralSelectedDisabled: #dbe5fa;
|
|
@@ -661,7 +661,7 @@
|
|
|
661
661
|
--fibery-color-colorBgListItemGeneral: rgba(255, 255, 255, 0);
|
|
662
662
|
--fibery-color-colorBgListItemGeneralHover: rgb(41, 41, 41);
|
|
663
663
|
--fibery-color-colorBgListItemGeneralFocus: rgb(51, 51, 51);
|
|
664
|
-
--fibery-color-colorBgListItemGeneralSelected: #
|
|
664
|
+
--fibery-color-colorBgListItemGeneralSelected: #223259;
|
|
665
665
|
--fibery-color-colorBgListItemGeneralSelectedHover: #293b66;
|
|
666
666
|
--fibery-color-colorBgListItemGeneralSelectedFocus: #293b66;
|
|
667
667
|
--fibery-color-colorBgListItemGeneralDisabled: rgba(255, 255, 255, 0);
|
|
@@ -1160,9 +1160,9 @@
|
|
|
1160
1160
|
--fibery-color-colorBgListItemGeneral: rgba(255, 255, 255, 0);
|
|
1161
1161
|
--fibery-color-colorBgListItemGeneralHover: rgb(250, 244, 236);
|
|
1162
1162
|
--fibery-color-colorBgListItemGeneralFocus: rgb(243, 236, 229);
|
|
1163
|
-
--fibery-color-colorBgListItemGeneralSelected: rgb(
|
|
1164
|
-
--fibery-color-colorBgListItemGeneralSelectedHover: rgb(
|
|
1165
|
-
--fibery-color-colorBgListItemGeneralSelectedFocus: rgb(
|
|
1163
|
+
--fibery-color-colorBgListItemGeneralSelected: rgb(213, 233, 240);
|
|
1164
|
+
--fibery-color-colorBgListItemGeneralSelectedHover: rgb(194, 222, 232);
|
|
1165
|
+
--fibery-color-colorBgListItemGeneralSelectedFocus: rgb(194, 222, 232);
|
|
1166
1166
|
--fibery-color-colorBgListItemGeneralDisabled: rgba(255, 255, 255, 0);
|
|
1167
1167
|
--fibery-color-colorTextListItemGeneralDisabled: rgb(163, 157, 150);
|
|
1168
1168
|
--fibery-color-colorBgListItemGeneralSelectedDisabled: rgb(213, 233, 240);
|
|
@@ -1659,7 +1659,7 @@
|
|
|
1659
1659
|
--fibery-color-colorBgListItemGeneral: rgba(255, 255, 255, 0);
|
|
1660
1660
|
--fibery-color-colorBgListItemGeneralHover: rgb(45, 40, 38);
|
|
1661
1661
|
--fibery-color-colorBgListItemGeneralFocus: rgb(55, 50, 48);
|
|
1662
|
-
--fibery-color-colorBgListItemGeneralSelected: rgb(
|
|
1662
|
+
--fibery-color-colorBgListItemGeneralSelected: rgb(4, 58, 72);
|
|
1663
1663
|
--fibery-color-colorBgListItemGeneralSelectedHover: rgb(7, 68, 83);
|
|
1664
1664
|
--fibery-color-colorBgListItemGeneralSelectedFocus: rgb(7, 68, 83);
|
|
1665
1665
|
--fibery-color-colorBgListItemGeneralDisabled: rgba(255, 255, 255, 0);
|