@fibery/ui-kit 3.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 +18 -0
- package/esfint.config.mjs +0 -17
- package/package.json +18 -13
- package/scripts/generate-icons.mjs +45 -44
- package/src/actions-menu/actions-menu-item.tsx +2 -1
- package/src/actions-menu/actions-menu.tsx +1 -3
- package/src/actions-menu/context-actions-menu.tsx +1 -1
- package/src/animated-height-container.tsx +1 -1
- package/src/antd/ant-modal.tsx +158 -9
- package/src/antd/ant-upload.tsx +285 -27
- package/src/antd/auto-complete.tsx +145 -0
- package/src/antd/auto-width-transparent-textarea.tsx +9 -2
- package/src/antd/global-overrides.ts +352 -0
- package/src/antd/index.tsx +3 -2
- package/src/antd/input-number.tsx +97 -11
- package/src/antd/input.tsx +127 -8
- package/src/antd/styles.ts +92 -32
- package/src/antd/tabs.tsx +139 -27
- package/src/app-icon-with-fallback.tsx +3 -7
- package/src/app-icon-wrapper.tsx +1 -13
- package/src/avatar.tsx +2 -56
- package/src/breadcrumb.tsx +5 -1
- package/src/color-adjuster.ts +24 -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/count-badge.tsx +10 -1
- package/src/date-picker/contexts.ts +6 -3
- package/src/date-picker/date-range-picker.tsx +7 -8
- package/src/date-picker/single-date-picker.tsx +3 -5
- package/src/date-picker/types.ts +1 -1
- package/src/date-picker/with-popup-control.tsx +3 -9
- package/src/day-select/iso-week-day-select.tsx +2 -2
- package/src/design-system/colors-callout.warm-dark.test.ts +22 -22
- package/src/design-system/colors-callout.warm-light.test.ts +19 -19
- package/src/design-system/colors-css.ts +1 -1
- package/src/design-system/colors-enum.dark.warm.test.ts +63 -63
- package/src/design-system/colors-enum.light.warm.test.ts +54 -54
- package/src/design-system/colors-highlight.warm-dark.test.ts +21 -21
- package/src/design-system/colors-highlight.warm-light.test.ts +21 -21
- package/src/design-system/colors.ts +4 -4
- package/src/design-system/fns.badge.dark.warm.test.ts +34 -34
- package/src/design-system/fns.badge.light.warm.test.ts +31 -31
- package/src/design-system/fns.deneutralize.test.ts +44 -0
- package/src/design-system/fns.icon.dark.warm.test.ts +21 -21
- package/src/design-system/fns.icon.light.warm.test.ts +17 -17
- package/src/design-system/fns.icon.ts +21 -13
- package/src/design-system/fns.ts +27 -3
- package/src/design-system/typography.ts +1 -1
- package/src/design-system.ts +1 -1
- package/src/emoji-picker/icon-emoji-picker.tsx +3 -3
- package/src/fibermoji-placeholder.tsx +2 -3
- package/src/icons/ast/index.tsx +446 -446
- package/src/icons/icon.tsx +23 -1
- package/src/icons/icons-integrity.test.ts +145 -0
- package/src/icons/react/index.tsx +446 -446
- package/src/icons/types.ts +1 -1
- package/src/images-gallery/images-gallery.tsx +2 -2
- package/src/images-gallery/slide-buttons.tsx +2 -4
- package/src/layout-styles.ts +5 -1
- package/src/link-input/components/ant-text-area-with-custom-read-state.tsx +2 -1
- package/src/lists/actions-menu-row-surface.tsx +1 -1
- package/src/media-query-utils.ts +5 -14
- 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 +141 -141
- package/src/palettes/inspect.defs.colors.warm-user.test.ts +141 -141
- package/src/palettes/warm.ts +2 -0
- 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/root-theme-provider.test.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 +4 -4
- package/src/select/reflection.ts +4 -5
- package/src/select/select-in-popover.tsx +34 -51
- package/src/select/select.tsx +5 -5
- package/src/select/styles.ts +1 -7
- package/src/select/util.ts +2 -2
- package/src/theme-provider.test.tsx +1 -1
- package/src/theme-provider.tsx +3 -9
- package/src/theme-snapshots.test.ts +9 -13
- package/src/{theming/build.ts → theming.build.ts} +6 -9
- package/src/{theming/theming-fibery.snapshot.css → theming.generated.css} +60 -60
- package/src/{theming/theming-fibery.snapshot.ts → theming.generated.ts} +60 -60
- package/src/type-badge.tsx +1 -2
- package/src/{themed-ink.tsx → type-label.tsx} +2 -5
- package/src/use-on-screen-keyboard-data.tsx +1 -1
- package/src/with-data.tsx +1 -1
- package/src/antd/auto-complete.d.ts +0 -2
- package/src/antd/auto-complete.ts +0 -37
- package/src/antd/tabs.d.ts +0 -5
- package/src/theming/index.ts +0 -20
- package/src/theming/theming-vzdbery.snapshot.css +0 -2001
- package/src/theming/theming-vzdbery.snapshot.ts +0 -2519
|
@@ -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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {css, cx} from "@linaria/core";
|
|
2
|
-
import type
|
|
2
|
+
import {type ForwardedRef} from "react";
|
|
3
3
|
import React, {forwardRef} from "react";
|
|
4
4
|
|
|
5
5
|
import type {$TSFixMe} from "../tsfixme";
|
|
6
6
|
import {useIsPhone} from "../use-is-phone";
|
|
7
7
|
import type {GroupBase, SelectInstance, SelectProps} from "./select";
|
|
8
|
-
import {
|
|
8
|
+
import {composeStyles, SelectComponent} from "./select";
|
|
9
9
|
import {SelectInPopover} from "./select-in-popover";
|
|
10
10
|
import {makeSingleLineStyles} from "./styles";
|
|
11
11
|
|
|
@@ -31,7 +31,7 @@ export type {
|
|
|
31
31
|
|
|
32
32
|
export {components, MenuListVirtualized, MenuListVirtua, createFilter} from "./select";
|
|
33
33
|
|
|
34
|
-
export {
|
|
34
|
+
export {composeStyles} from "./select";
|
|
35
35
|
|
|
36
36
|
const emptyComponents = {
|
|
37
37
|
Menu: () => null,
|
|
@@ -134,7 +134,7 @@ export function SingleRowSelect<T = unknown, U extends boolean = boolean, V exte
|
|
|
134
134
|
styles = {},
|
|
135
135
|
...rest
|
|
136
136
|
}: SelectProps<T, U, V>) {
|
|
137
|
-
return <Select {...rest} styles={
|
|
137
|
+
return <Select {...rest} styles={composeStyles([makeSingleLineStyles<T, U, V>(), styles])} />;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
export {CreatableSelect} from "./select";
|
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
|
}
|
|
@@ -11,16 +11,8 @@ import {Popover} from "../popover";
|
|
|
11
11
|
import {useIsPhone} from "../use-is-phone";
|
|
12
12
|
import {MenuTransparent} from "./components/menu";
|
|
13
13
|
import {SELECT_IN_POPOVER_VALUE_MAX_HEIGHT} from "./constants";
|
|
14
|
-
import type {
|
|
15
|
-
|
|
16
|
-
GroupBase,
|
|
17
|
-
OnChangeValue,
|
|
18
|
-
OptionsOrGroups,
|
|
19
|
-
PropsValue,
|
|
20
|
-
SelectProps,
|
|
21
|
-
StylesConfig,
|
|
22
|
-
} from "./select";
|
|
23
|
-
import {combineStyles, SelectComponent as ReactSelect} from "./select";
|
|
14
|
+
import type {ActionMeta, GroupBase, OnChangeValue, SelectProps, StylesConfig} from "./select";
|
|
15
|
+
import {composeStyles, SelectComponent as ReactSelect} from "./select";
|
|
24
16
|
import {SelectControlSettingsProvider} from "./select-control-settings-context";
|
|
25
17
|
import {makeSelectInPopoverStyles} from "./styles";
|
|
26
18
|
|
|
@@ -66,16 +58,12 @@ export type SelectInPopoverRef<T, U extends boolean, V extends GroupBase<T>> = {
|
|
|
66
58
|
};
|
|
67
59
|
|
|
68
60
|
type Props<T, U extends boolean, V extends GroupBase<T>> = {
|
|
69
|
-
value?: PropsValue<T>;
|
|
70
|
-
isSearchable?: boolean;
|
|
71
61
|
menuIsOpen?: boolean;
|
|
72
|
-
options: OptionsOrGroups<T, V>;
|
|
73
62
|
disabled?: boolean;
|
|
74
63
|
isCollectionMode?: U;
|
|
75
64
|
isClearable?: boolean;
|
|
76
65
|
trigger?: ReactNode;
|
|
77
66
|
title?: string;
|
|
78
|
-
maxMenuHeight?: number;
|
|
79
67
|
hideOnChange?: boolean | ((newValue: OnChangeValue<T, U>, actionMeta: ActionMeta<T>) => boolean);
|
|
80
68
|
renderInPortal?: boolean;
|
|
81
69
|
popupContainerClassName?: string;
|
|
@@ -89,6 +77,8 @@ type Props<T, U extends boolean, V extends GroupBase<T>> = {
|
|
|
89
77
|
popoverPlacement?: Placement;
|
|
90
78
|
} & Pick<
|
|
91
79
|
SelectProps<T, U, V>,
|
|
80
|
+
| "value"
|
|
81
|
+
| "options"
|
|
92
82
|
| "placeholder"
|
|
93
83
|
| "autoFocus"
|
|
94
84
|
| "inputValue"
|
|
@@ -104,16 +94,15 @@ type Props<T, U extends boolean, V extends GroupBase<T>> = {
|
|
|
104
94
|
| "onChange"
|
|
105
95
|
| "onFocus"
|
|
106
96
|
| "components"
|
|
97
|
+
| "isSearchable"
|
|
107
98
|
>;
|
|
108
99
|
|
|
109
100
|
function SelectInPopoverInner<T, U extends boolean, V extends GroupBase<T>>(
|
|
110
|
-
props:
|
|
101
|
+
props: Props<T, U, V>,
|
|
111
102
|
forwardedRef: ForwardedRef<SelectInPopoverRef<T, U, V>>
|
|
112
103
|
) {
|
|
113
104
|
const {
|
|
114
|
-
value,
|
|
115
105
|
menuIsOpen,
|
|
116
|
-
options,
|
|
117
106
|
disabled,
|
|
118
107
|
isCollectionMode,
|
|
119
108
|
isClearable = true,
|
|
@@ -131,7 +120,6 @@ function SelectInPopoverInner<T, U extends boolean, V extends GroupBase<T>>(
|
|
|
131
120
|
getPopupContainer,
|
|
132
121
|
onSelectKeyDown,
|
|
133
122
|
otherSelectProps,
|
|
134
|
-
isSearchable = true,
|
|
135
123
|
popoverPlacement = "bottom-start",
|
|
136
124
|
...rest
|
|
137
125
|
} = props;
|
|
@@ -151,41 +139,42 @@ function SelectInPopoverInner<T, U extends boolean, V extends GroupBase<T>>(
|
|
|
151
139
|
selectRef,
|
|
152
140
|
}));
|
|
153
141
|
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
142
|
+
const onOpenChange = useCallback(
|
|
143
|
+
(value: boolean) => {
|
|
144
|
+
if (value) {
|
|
145
|
+
if (disabled) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
setVisible(true);
|
|
149
|
+
onMenuOpen?.();
|
|
150
|
+
} else {
|
|
151
|
+
const wasClosed = onMenuClose?.();
|
|
152
|
+
if (wasClosed === false) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
setVisible(false);
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
[disabled, onMenuOpen, setVisible, onMenuClose]
|
|
159
|
+
);
|
|
172
160
|
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
161
|
+
const composedStyles = useMemo(
|
|
162
|
+
() => composeStyles<T, U, V>([makeSelectInPopoverStyles(isPhone), selectStyles]),
|
|
163
|
+
[selectStyles, isPhone]
|
|
164
|
+
);
|
|
176
165
|
|
|
177
166
|
const handleChange = useCallback(
|
|
178
167
|
(newValue: OnChangeValue<T, U>, actionMeta: ActionMeta<T>) => {
|
|
179
168
|
if (typeof hideOnChange === "function") {
|
|
180
169
|
if (hideOnChange(newValue, actionMeta)) {
|
|
181
|
-
|
|
170
|
+
onOpenChange(false);
|
|
182
171
|
}
|
|
183
172
|
} else if (hideOnChange) {
|
|
184
|
-
|
|
173
|
+
onOpenChange(false);
|
|
185
174
|
}
|
|
186
175
|
onChange?.(newValue, actionMeta);
|
|
187
176
|
},
|
|
188
|
-
[hideOnChange, onChange,
|
|
177
|
+
[hideOnChange, onChange, onOpenChange]
|
|
189
178
|
);
|
|
190
179
|
|
|
191
180
|
const paddingPopup = popupPaddingTop + popupPaddingBottom;
|
|
@@ -206,7 +195,7 @@ function SelectInPopoverInner<T, U extends boolean, V extends GroupBase<T>>(
|
|
|
206
195
|
};
|
|
207
196
|
|
|
208
197
|
return (
|
|
209
|
-
<Popover.Root open={visible}
|
|
198
|
+
<Popover.Root open={visible} onOpenChange={onOpenChange}>
|
|
210
199
|
<Popover.Trigger ref={setTriggerElement} asChild triggerEvent="click">
|
|
211
200
|
{trigger}
|
|
212
201
|
</Popover.Trigger>
|
|
@@ -228,21 +217,15 @@ function SelectInPopoverInner<T, U extends boolean, V extends GroupBase<T>>(
|
|
|
228
217
|
<ReactSelect<T, U, V>
|
|
229
218
|
{...rest}
|
|
230
219
|
ref={selectRef}
|
|
231
|
-
styles={
|
|
232
|
-
isSearchable={isSearchable}
|
|
220
|
+
styles={composedStyles}
|
|
233
221
|
onKeyDown={onSelectKeyDown}
|
|
234
|
-
value={value}
|
|
235
|
-
controlShouldRenderValue
|
|
236
|
-
closeMenuOnScroll={false}
|
|
237
222
|
closeMenuOnSelect={false}
|
|
238
223
|
onChange={handleChange}
|
|
239
|
-
options={options || []}
|
|
240
224
|
menuIsOpen
|
|
241
225
|
maxMenuHeight={maxMenuHeight}
|
|
242
226
|
disabled={disabled}
|
|
243
227
|
isCollectionMode={isCollectionMode}
|
|
244
228
|
isClearable={!isCollectionMode && isClearable}
|
|
245
|
-
menuShouldBlockScroll={false}
|
|
246
229
|
{...otherSelectProps}
|
|
247
230
|
components={selectComponents}
|
|
248
231
|
inline
|
|
@@ -255,7 +238,7 @@ function SelectInPopoverInner<T, U extends boolean, V extends GroupBase<T>>(
|
|
|
255
238
|
}
|
|
256
239
|
|
|
257
240
|
type SelectInPopoverType = <T, U extends boolean, V extends GroupBase<T>>(
|
|
258
|
-
props:
|
|
241
|
+
props: Props<T, U, V> & {ref?: ForwardedRef<SelectInPopoverRef<T, U, V>>}
|
|
259
242
|
) => ReturnType<typeof SelectInPopoverInner>;
|
|
260
243
|
|
|
261
244
|
export const SelectInPopover = forwardRef(SelectInPopoverInner) as SelectInPopoverType;
|
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 {
|
|
@@ -62,7 +62,7 @@ function GroupVirtualized() {
|
|
|
62
62
|
return null;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
export function
|
|
65
|
+
export function composeStyles<T, U extends boolean, V extends GroupBase<T>>(styles: StylesConfig<T, U, V>[]) {
|
|
66
66
|
return styles.reduce(mergeStyles, {});
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -127,13 +127,13 @@ function useSelectStyles<T, U extends boolean, V extends GroupBase<T>>({
|
|
|
127
127
|
styles?: SelectProps<T, U, V>["styles"];
|
|
128
128
|
}) {
|
|
129
129
|
return useMemo(() => {
|
|
130
|
-
return
|
|
131
|
-
|
|
130
|
+
return composeStyles<T, U, V>(
|
|
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>>(
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
useThemeStyles,
|
|
12
12
|
} from "./theme-provider";
|
|
13
13
|
import {locateThemeBundle} from "./theme-styles";
|
|
14
|
-
import {neutralStyles, prefix as themePrefix} from "./theming";
|
|
14
|
+
import {neutralStyles, prefix as themePrefix} from "./theming.generated";
|
|
15
15
|
|
|
16
16
|
const {
|
|
17
17
|
palette,
|
package/src/theme-provider.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import invariant from "invariant";
|
|
|
3
3
|
import type {PropsWithChildren, ReactNode} from "react";
|
|
4
4
|
import {createContext, forwardRef, useContext, useEffect, useLayoutEffect, useMemo, useState} from "react";
|
|
5
5
|
|
|
6
|
+
import {globalOverrides} from "./antd/global-overrides";
|
|
6
7
|
import type {Styles, Theme} from "./design-system/theme";
|
|
7
8
|
import {stylesFromTheme, themeFromPalette} from "./design-system/theme";
|
|
8
9
|
import type {ThemePalette} from "./design-system/types";
|
|
@@ -11,7 +12,7 @@ import {selectPalette} from "./palette-generator";
|
|
|
11
12
|
import type {ThemeMode, ThemePreference} from "./theme-settings";
|
|
12
13
|
import {subscribeOnThemeModeChange, subscribeOnThemePreferenceChange, useWarmPreference} from "./theme-settings";
|
|
13
14
|
import {locateThemeBundle} from "./theme-styles";
|
|
14
|
-
import {neutralStyles, prefix as themePrefix, warmStyles} from "./theming";
|
|
15
|
+
import {neutralStyles, prefix as themePrefix, warmStyles} from "./theming.generated";
|
|
15
16
|
|
|
16
17
|
const darkClassName = "dark-theme";
|
|
17
18
|
const warmClassName = "warm-palette";
|
|
@@ -50,6 +51,7 @@ function chooseGlobalStyles(themeMode: ThemeMode, warm: boolean) {
|
|
|
50
51
|
colorSchemeMeta?.setAttribute("content", colorScheme);
|
|
51
52
|
|
|
52
53
|
htmlElement.classList.add(globals);
|
|
54
|
+
htmlElement.classList.add(globalOverrides);
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
const ThemePreferenceContext = createContext<ThemePreference | null>(null);
|
|
@@ -76,14 +78,6 @@ export function useThemeMode(): ThemeMode {
|
|
|
76
78
|
return theme.mode;
|
|
77
79
|
}
|
|
78
80
|
|
|
79
|
-
/** @deprecated Use `useThemedColor` instead */
|
|
80
|
-
export const useNeutralColor = useThemedColor;
|
|
81
|
-
|
|
82
|
-
export function useThemedColor(color: string) {
|
|
83
|
-
const theme = useTheme();
|
|
84
|
-
return theme.fns.deneutralize(color);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
81
|
const RootThemeStylesContext = createContext<Styles>(coolLightThemeStyles);
|
|
88
82
|
const ThemeStylesContext = createContext<Styles>(coolLightThemeStyles);
|
|
89
83
|
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import {format, type FormatConfig} from "oxfmt";
|
|
2
2
|
|
|
3
3
|
import oxfmtConfig from "../../../.oxfmtrc.json" with {type: "json"};
|
|
4
|
-
import {buildThemingSnapshot} from "./theming
|
|
5
|
-
|
|
6
|
-
const PREFIXES = ["fibery", "vzdbery"] as const;
|
|
4
|
+
import {buildThemingSnapshot} from "./theming.build";
|
|
7
5
|
|
|
8
6
|
async function renderTs(prefix: string): Promise<string> {
|
|
9
7
|
const s = buildThemingSnapshot(prefix);
|
|
@@ -49,14 +47,12 @@ async function renderCss(prefix: string): Promise<string> {
|
|
|
49
47
|
return code;
|
|
50
48
|
}
|
|
51
49
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
});
|
|
50
|
+
test(`theming-fibery.generated.ts`, async () => {
|
|
51
|
+
const source = await renderTs("fibery");
|
|
52
|
+
await expect(source).toMatchFileSnapshot(`./theming.generated.ts`);
|
|
53
|
+
});
|
|
57
54
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
55
|
+
test(`theming-fibery.generated.css`, async () => {
|
|
56
|
+
const source = await renderCss("fibery");
|
|
57
|
+
await expect(source).toMatchFileSnapshot(`./theming.generated.css`);
|
|
58
|
+
});
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
// Builder for prefix-baked theming snapshots. Internal to ui-kit
|
|
2
|
-
// not re-exported through ./theming/index.ts. The snapshot test in
|
|
3
|
-
// theme-snapshots.test.ts is the only intended caller — it freezes
|
|
4
|
-
// the output into theming-<prefix>.snapshot.{ts,css} files.
|
|
1
|
+
// Builder for prefix-baked theming snapshots. Internal to ui-kit.
|
|
5
2
|
|
|
6
|
-
import type {Theme} from "
|
|
7
|
-
import {stylesFromTheme} from "
|
|
8
|
-
import type {LayoutVarNames, LayoutVars, ThemeVars} from "
|
|
9
|
-
import {layoutVarNamesFromPrefix, layoutVarsFromPrefix, varsFromTheme} from "
|
|
10
|
-
import {locateThemeBundle} from "
|
|
3
|
+
import type {Theme} from "./design-system/theme";
|
|
4
|
+
import {stylesFromTheme} from "./design-system/theme";
|
|
5
|
+
import type {LayoutVarNames, LayoutVars, ThemeVars} from "./design-system/vars";
|
|
6
|
+
import {layoutVarNamesFromPrefix, layoutVarsFromPrefix, varsFromTheme} from "./design-system/vars";
|
|
7
|
+
import {locateThemeBundle} from "./theme-styles";
|
|
11
8
|
|
|
12
9
|
export type ThemingSnapshot = LayoutVarNames & {
|
|
13
10
|
prefix: string;
|