@fibery/ui-kit 1.29.2 → 1.29.5
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/package.json +5 -4
- package/src/actions-menu/actions-menu-item.tsx +3 -1
- package/src/actions-menu/actions-menu-sub-command-menu.tsx +14 -6
- package/src/button/button-base.tsx +1 -1
- package/src/button/button.tsx +1 -1
- package/src/design-system.ts +78 -23
- package/src/emoji-picker/primitives/footer.tsx +1 -1
- package/src/icons/ast/Abort.ts +8 -0
- package/src/icons/ast/AiAssistant.ts +1 -1
- package/src/icons/ast/AiAvatar.ts +1 -1
- package/src/icons/ast/Clear.ts +8 -0
- package/src/icons/ast/Database.ts +1 -1
- package/src/icons/ast/DatabaseStroke.ts +8 -0
- package/src/icons/ast/ExtensionComments.ts +1 -1
- package/src/icons/ast/FieldUnit.ts +1 -1
- package/src/icons/ast/InfoCircle.ts +8 -0
- package/src/icons/ast/Key.ts +8 -0
- package/src/icons/ast/MoveBottom.ts +1 -1
- package/src/icons/ast/MoveLeft.ts +1 -1
- package/src/icons/ast/MoveRight.ts +1 -1
- package/src/icons/ast/MoveTop.ts +1 -1
- package/src/icons/ast/Pin.ts +1 -1
- package/src/icons/ast/RicheditorCommentCreate.ts +1 -1
- package/src/icons/ast/SendArrow.ts +8 -0
- package/src/icons/ast/UnitsAvatar.ts +8 -0
- package/src/icons/ast/UnitsCollection.ts +8 -0
- package/src/icons/ast/UnitsCounter.ts +8 -0
- package/src/icons/ast/UnitsDbBadgeAbbr.ts +8 -0
- package/src/icons/ast/UnitsDbBadgeFull.ts +8 -0
- package/src/icons/ast/UnitsDbIcon.ts +8 -0
- package/src/icons/ast/UnitsField.ts +8 -0
- package/src/icons/ast/UnitsInput.ts +8 -0
- package/src/icons/ast/UnitsProgressBar.ts +8 -0
- package/src/icons/ast/UnitsRichText.ts +8 -0
- package/src/icons/ast/UnitsSnippet.ts +8 -0
- package/src/icons/ast/index.tsx +17 -0
- package/src/icons/react/Abort.tsx +12 -0
- package/src/icons/react/Clear.tsx +12 -0
- package/src/icons/react/DatabaseStroke.tsx +12 -0
- package/src/icons/react/InfoCircle.tsx +12 -0
- package/src/icons/react/Key.tsx +12 -0
- package/src/icons/react/SendArrow.tsx +12 -0
- package/src/icons/react/UnitsAvatar.tsx +12 -0
- package/src/icons/react/UnitsCollection.tsx +12 -0
- package/src/icons/react/UnitsCounter.tsx +12 -0
- package/src/icons/react/UnitsDbBadgeAbbr.tsx +12 -0
- package/src/icons/react/UnitsDbBadgeFull.tsx +12 -0
- package/src/icons/react/UnitsDbIcon.tsx +12 -0
- package/src/icons/react/UnitsField.tsx +12 -0
- package/src/icons/react/UnitsInput.tsx +12 -0
- package/src/icons/react/UnitsProgressBar.tsx +12 -0
- package/src/icons/react/UnitsRichText.tsx +12 -0
- package/src/icons/react/UnitsSnippet.tsx +12 -0
- package/src/icons/react/index.tsx +17 -0
- package/src/select/custom-select-partials/menu.tsx +1 -1
- package/src/select/select-in-popover.tsx +56 -10
- package/src/theme-settings.ts +10 -8
- package/src/toggle.tsx +3 -1
- package/src/tooltip.tsx +4 -2
|
@@ -2,6 +2,7 @@ import {css, cx} from "@linaria/core";
|
|
|
2
2
|
import {border, space, textStyles} from "../design-system";
|
|
3
3
|
import {inputOverrides} from "../antd/styles";
|
|
4
4
|
import React, {
|
|
5
|
+
ComponentProps,
|
|
5
6
|
ComponentType,
|
|
6
7
|
forwardRef,
|
|
7
8
|
ReactNode,
|
|
@@ -26,16 +27,32 @@ import {
|
|
|
26
27
|
StylesConfig,
|
|
27
28
|
} from "./index";
|
|
28
29
|
import {SelectControlSettingsProvider} from "./select-control-settings-context";
|
|
30
|
+
import {Menu} from "./custom-select-partials/menu";
|
|
29
31
|
|
|
30
32
|
const offset = [0, space.s4] as [number, number];
|
|
33
|
+
const popupHeightVH = 45;
|
|
34
|
+
const popupMinHeightPx = 300;
|
|
35
|
+
const popupPaddingTop = space.s8;
|
|
36
|
+
const popupPaddingBottom = space.s8;
|
|
31
37
|
const popupContainerClassName = css`
|
|
32
38
|
z-index: 1050;
|
|
39
|
+
height: max(${popupHeightVH}vh, ${popupMinHeightPx}px);
|
|
40
|
+
display: flex;
|
|
41
|
+
flex-direction: row;
|
|
42
|
+
|
|
43
|
+
&:is([data-popper-placement="bottom-start"], [data-popper-placement="bottom-end"]) {
|
|
44
|
+
align-items: flex-start;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&:is([data-popper-placement="top-start"], [data-popper-placement="top-end"]) {
|
|
48
|
+
align-items: flex-end;
|
|
49
|
+
}
|
|
33
50
|
`;
|
|
34
51
|
const popupClassName = css`
|
|
35
52
|
min-width: 320px;
|
|
36
53
|
max-width: 440px;
|
|
37
|
-
padding-top: ${
|
|
38
|
-
padding-bottom: ${
|
|
54
|
+
padding-top: ${popupPaddingTop}px;
|
|
55
|
+
padding-bottom: ${popupPaddingBottom}px;
|
|
39
56
|
padding-left: ${space.s8}px;
|
|
40
57
|
padding-right: ${space.s8}px;
|
|
41
58
|
`;
|
|
@@ -67,6 +84,8 @@ const titleClassName = css`
|
|
|
67
84
|
padding-bottom: ${space.s12}px;
|
|
68
85
|
`;
|
|
69
86
|
|
|
87
|
+
export const valueMaxHeight = 116;
|
|
88
|
+
|
|
70
89
|
export const selectInPopupStyles = {
|
|
71
90
|
container: (props: $TSFixMe) => ({
|
|
72
91
|
...props,
|
|
@@ -80,6 +99,11 @@ export const selectInPopupStyles = {
|
|
|
80
99
|
paddingLeft: 0,
|
|
81
100
|
paddingRight: 0,
|
|
82
101
|
}),
|
|
102
|
+
control: (props: $TSFixMe) => ({
|
|
103
|
+
...props,
|
|
104
|
+
maxHeight: valueMaxHeight,
|
|
105
|
+
overflow: "auto",
|
|
106
|
+
}),
|
|
83
107
|
menu: (props: $TSFixMe) => ({
|
|
84
108
|
...props,
|
|
85
109
|
minWidth: 100,
|
|
@@ -96,6 +120,7 @@ export type TriggerProps = {
|
|
|
96
120
|
children: ReactNode;
|
|
97
121
|
onClick: React.MouseEventHandler;
|
|
98
122
|
onKeyDown: React.KeyboardEventHandler;
|
|
123
|
+
disabled?: boolean;
|
|
99
124
|
};
|
|
100
125
|
|
|
101
126
|
const Trigger = ({innerRef, children, onClick, onKeyDown}: TriggerProps) => {
|
|
@@ -106,11 +131,14 @@ const Trigger = ({innerRef, children, onClick, onKeyDown}: TriggerProps) => {
|
|
|
106
131
|
);
|
|
107
132
|
};
|
|
108
133
|
|
|
109
|
-
type Components = {
|
|
134
|
+
type Components = {
|
|
135
|
+
Trigger: ComponentType<TriggerProps>;
|
|
136
|
+
Menu: ComponentType<ComponentProps<typeof Menu>>;
|
|
137
|
+
};
|
|
110
138
|
|
|
111
139
|
export type ComponentsConfig = Partial<Components>;
|
|
112
140
|
|
|
113
|
-
const defaultComponents = {Trigger};
|
|
141
|
+
const defaultComponents = {Trigger, Menu};
|
|
114
142
|
|
|
115
143
|
type Ref = {
|
|
116
144
|
valueRef: HTMLDivElement | null;
|
|
@@ -146,10 +174,11 @@ type Props<Option, IsMulti extends boolean, Group extends GroupBase<Option>> = {
|
|
|
146
174
|
onChange: (newValue: OnChangeValue<Option, IsMulti>, actionMeta: ActionMeta<Option>) => void;
|
|
147
175
|
onMenuOpen?: () => void;
|
|
148
176
|
onMenuClose?: () => void | boolean;
|
|
177
|
+
getPopupContainer?: () => HTMLElement;
|
|
149
178
|
};
|
|
150
179
|
|
|
151
180
|
function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends GroupBase<Option>>(
|
|
152
|
-
props: Props<Option, IsMulti, Group>,
|
|
181
|
+
props: Omit<Props<Option, IsMulti, Group>, "maxMenuHeight">,
|
|
153
182
|
forwardedRef: React.ForwardedRef<Ref>
|
|
154
183
|
) {
|
|
155
184
|
const {
|
|
@@ -168,7 +197,6 @@ function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends Gro
|
|
|
168
197
|
isClearable = true,
|
|
169
198
|
renderValue,
|
|
170
199
|
title,
|
|
171
|
-
maxMenuHeight,
|
|
172
200
|
hideOnChange = true,
|
|
173
201
|
renderInPortal = true,
|
|
174
202
|
popupStyles,
|
|
@@ -181,12 +209,14 @@ function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends Gro
|
|
|
181
209
|
onChange,
|
|
182
210
|
onMenuOpen,
|
|
183
211
|
onMenuClose,
|
|
212
|
+
getPopupContainer,
|
|
184
213
|
} = props;
|
|
185
214
|
const [triggerElement, setTriggerElement] = useState<HTMLDivElement | null>(null);
|
|
186
215
|
const [visible, setVisible] = useState(menuIsOpen);
|
|
187
216
|
const blurTimeoutRef = useRef<ReturnType<typeof setTimeout>>();
|
|
188
217
|
const selectRef = useRef<{focus: () => void}>(null);
|
|
189
218
|
const ref = useRef<HTMLDivElement | null>(null);
|
|
219
|
+
|
|
190
220
|
useImperativeHandle(
|
|
191
221
|
forwardedRef,
|
|
192
222
|
() =>
|
|
@@ -269,12 +299,23 @@ function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends Gro
|
|
|
269
299
|
},
|
|
270
300
|
[onShow, visible]
|
|
271
301
|
);
|
|
272
|
-
|
|
302
|
+
const paddingPopup = popupPaddingTop + popupPaddingBottom;
|
|
303
|
+
const paddingMenu = 6 + 6 + 6;
|
|
304
|
+
const maxMenuHeight =
|
|
305
|
+
Math.max((document.body.clientHeight / 100) * popupHeightVH, popupMinHeightPx) -
|
|
306
|
+
valueMaxHeight -
|
|
307
|
+
paddingPopup -
|
|
308
|
+
paddingMenu;
|
|
273
309
|
const mergedComponents = {...defaultComponents, ...components};
|
|
274
310
|
|
|
275
311
|
return (
|
|
276
312
|
<>
|
|
277
|
-
<mergedComponents.Trigger
|
|
313
|
+
<mergedComponents.Trigger
|
|
314
|
+
innerRef={ref}
|
|
315
|
+
onClick={onTriggerClick}
|
|
316
|
+
onKeyDown={onTriggerKeyDown}
|
|
317
|
+
disabled={disabled}
|
|
318
|
+
>
|
|
278
319
|
{renderValue ? renderValue() : null}
|
|
279
320
|
</mergedComponents.Trigger>
|
|
280
321
|
{Boolean(triggerElement) && (
|
|
@@ -289,6 +330,7 @@ function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends Gro
|
|
|
289
330
|
onClose={() => onHide()}
|
|
290
331
|
trigger={<></>}
|
|
291
332
|
triggerDomElement={triggerElement}
|
|
333
|
+
getPopupContainer={getPopupContainer}
|
|
292
334
|
>
|
|
293
335
|
{title && <div className={titleClassName}>{title}</div>}
|
|
294
336
|
{/*Usually we set popupContainerElement for react-select via context (SelectControlSettingsProvider). But here we render react-select in popover.*/}
|
|
@@ -338,7 +380,11 @@ function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends Gro
|
|
|
338
380
|
isClearable={!isCollectionMode && isClearable}
|
|
339
381
|
formatGroupLabel={formatGroupLabel}
|
|
340
382
|
formatOptionLabel={formatOptionLabel}
|
|
341
|
-
components={{
|
|
383
|
+
components={{
|
|
384
|
+
DropdownIndicator: null,
|
|
385
|
+
IndicatorSeparator: null,
|
|
386
|
+
Menu: mergedComponents.Menu as $TSFixMe,
|
|
387
|
+
}}
|
|
342
388
|
/>
|
|
343
389
|
</SelectControlSettingsProvider>
|
|
344
390
|
</Popup>
|
|
@@ -348,7 +394,7 @@ function SelectInPopoverInner<Option, IsMulti extends boolean, Group extends Gro
|
|
|
348
394
|
}
|
|
349
395
|
|
|
350
396
|
type SelectInPopoverType = <Option, IsMulti extends boolean, Group extends GroupBase<Option>>(
|
|
351
|
-
props: Props<Option, IsMulti, Group> & {ref?: React.ForwardedRef<Ref>}
|
|
397
|
+
props: Omit<Props<Option, IsMulti, Group>, "maxMenuHeight"> & {ref?: React.ForwardedRef<Ref>}
|
|
352
398
|
) => ReturnType<typeof SelectInPopoverInner>;
|
|
353
399
|
|
|
354
400
|
// Explicit type assertion to specify that component accepts generic props because forwardRef breaks it
|
package/src/theme-settings.ts
CHANGED
|
@@ -13,17 +13,19 @@ export type ThemeMenuPreference = "dark" | "auto";
|
|
|
13
13
|
export type ThemeMode = "dark" | "light" | "light2";
|
|
14
14
|
|
|
15
15
|
export function getThemePreference(): ThemePreference {
|
|
16
|
+
const allowedValues = ["dark", "light", "auto"];
|
|
16
17
|
try {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
19
|
+
const itemInUrl = urlParams.get("force-theme");
|
|
20
|
+
if (itemInUrl && allowedValues.includes(itemInUrl)) {
|
|
21
|
+
return itemInUrl as ThemePreference;
|
|
22
|
+
}
|
|
23
|
+
const itemInStorage = localStorage.getItem(themePreferenceKey);
|
|
24
|
+
if (itemInStorage && allowedValues.includes(itemInStorage)) {
|
|
25
|
+
return itemInStorage as ThemePreference;
|
|
24
26
|
}
|
|
25
27
|
} catch (e) {
|
|
26
|
-
return
|
|
28
|
+
// Just return the default below
|
|
27
29
|
}
|
|
28
30
|
return "light";
|
|
29
31
|
}
|
package/src/toggle.tsx
CHANGED
|
@@ -81,6 +81,7 @@ interface ToggleProps extends Omit<ComponentProps<"input">, "value"> {
|
|
|
81
81
|
value?: boolean;
|
|
82
82
|
label?: ReactNode;
|
|
83
83
|
labelTitle?: string;
|
|
84
|
+
labelMutedWhenDisabled?: boolean;
|
|
84
85
|
backgroundColor: string;
|
|
85
86
|
labelPosition?: "first" | "last";
|
|
86
87
|
wrapperClassName?: string;
|
|
@@ -95,6 +96,7 @@ export const Toggle: FC<ToggleProps> = ({
|
|
|
95
96
|
size = 16,
|
|
96
97
|
onChange,
|
|
97
98
|
labelPosition = "last",
|
|
99
|
+
labelMutedWhenDisabled = true,
|
|
98
100
|
className,
|
|
99
101
|
wrapperClassName,
|
|
100
102
|
...rest
|
|
@@ -149,7 +151,7 @@ export const Toggle: FC<ToggleProps> = ({
|
|
|
149
151
|
</CircleContainer>
|
|
150
152
|
|
|
151
153
|
{label && (
|
|
152
|
-
<Label disabled={disabled} labelPosition={labelPosition}>
|
|
154
|
+
<Label disabled={disabled && labelMutedWhenDisabled} labelPosition={labelPosition}>
|
|
153
155
|
{label}
|
|
154
156
|
</Label>
|
|
155
157
|
)}
|
package/src/tooltip.tsx
CHANGED
|
@@ -20,7 +20,7 @@ const descriptionStyle = css`
|
|
|
20
20
|
font-weight: ${fontWeight.regular};
|
|
21
21
|
`;
|
|
22
22
|
|
|
23
|
-
const tooltipStyle = css`
|
|
23
|
+
export const tooltipStyle = css`
|
|
24
24
|
font-size: 13px;
|
|
25
25
|
color: ${themeVars.whiteColor};
|
|
26
26
|
z-index: 100000;
|
|
@@ -96,6 +96,7 @@ export const TooltipProvider: React.FC<TooltipPrimitive.TooltipProviderProps> =
|
|
|
96
96
|
export type TooltipProps = Omit<TooltipPrimitive.TooltipTriggerProps, "title"> & {
|
|
97
97
|
title?: ReactNode;
|
|
98
98
|
description?: ReactNode;
|
|
99
|
+
tooltipContentStyle?: string;
|
|
99
100
|
setContentElement?: (el: HTMLDivElement | null) => void;
|
|
100
101
|
content?: ReactNode;
|
|
101
102
|
container?: HTMLElement | null | undefined;
|
|
@@ -146,6 +147,7 @@ export const Tooltip = forwardRef<HTMLButtonElement, TooltipProps>(
|
|
|
146
147
|
disabled,
|
|
147
148
|
setContentElement,
|
|
148
149
|
container,
|
|
150
|
+
tooltipContentStyle,
|
|
149
151
|
...triggerProps
|
|
150
152
|
},
|
|
151
153
|
ref
|
|
@@ -179,7 +181,7 @@ export const Tooltip = forwardRef<HTMLButtonElement, TooltipProps>(
|
|
|
179
181
|
sideOffset={sideOffset}
|
|
180
182
|
align={align}
|
|
181
183
|
alignOffset={alignOffset}
|
|
182
|
-
className={cx(tooltipStyle, whiteBg && whiteBgStyle)}
|
|
184
|
+
className={cx(tooltipStyle, whiteBg && whiteBgStyle, tooltipContentStyle)}
|
|
183
185
|
>
|
|
184
186
|
{content}
|
|
185
187
|
</TooltipPrimitive.Content>
|