@fibery/ui-kit 2.0.0 → 2.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/.oxlintrc.json +24 -0
- package/CHANGELOG.md +7 -0
- package/eslint.config.mjs +1 -1
- package/jest.config.cjs +36 -0
- package/package.json +10 -50
- package/src/@types/css.d.ts +1 -0
- package/src/actions-menu/actions-menu-checkbox-item.tsx +74 -0
- package/src/actions-menu/contexts/actions-menu-context.tsx +1 -0
- package/src/actions-menu/index.tsx +1 -0
- package/src/animated-number.tsx +2 -2
- package/src/antd/AutoComplete.d.ts +1 -0
- package/src/app-icon-with-fallback.tsx +4 -4
- package/src/app-icon.tsx +4 -4
- package/src/appIcons.json +1227 -1227
- package/src/avatar.tsx +44 -5
- package/src/box.tsx +10 -17
- package/src/button/make-button-colors.ts +13 -13
- package/src/checkbox.tsx +3 -3
- package/src/collapsible-section.tsx +1 -1
- package/src/context-menu/index.tsx +4 -0
- package/src/date-picker/date-range-picker.tsx +1 -1
- package/src/date-picker/relative-date-picker.tsx +3 -0
- package/src/date-picker/single-date-picker.tsx +10 -9
- package/src/design-system/alpha.ts +9 -0
- package/src/design-system/colors-css.test.ts +1 -9
- package/src/design-system/colors-css.ts +1 -1
- package/src/design-system/colors.ts +351 -313
- package/src/design-system/layout.ts +1 -1
- package/src/design-system/theme.ts +4 -1
- package/src/design-system/vars.test.ts +4 -0
- package/src/design-system.test.ts +1 -0
- package/src/design-system.ts +1 -1
- package/src/dropdown-menu/index.tsx +4 -0
- package/src/emoji-picker/primitives/emoji.tsx +12 -0
- package/src/emoji-picker/primitives/grid.tsx +100 -104
- package/src/emoji.tsx +1 -0
- package/src/file-item.tsx +308 -265
- package/src/icons/ast/AddDatabase.ts +1 -1
- package/src/icons/ast/AddIntegration.ts +1 -1
- package/src/icons/ast/ArrowsRightLeft.ts +1 -1
- package/src/icons/ast/ChatBubble.ts +1 -1
- package/src/icons/ast/ChatFloat.ts +1 -1
- package/src/icons/ast/ChatSidebar.ts +1 -1
- package/src/icons/ast/Clean.ts +1 -1
- package/src/icons/ast/Create.ts +1 -1
- package/src/icons/ast/ItemsTimeline.ts +1 -1
- package/src/icons/ast/Key.ts +1 -1
- package/src/icons/ast/NetworkAdd.ts +1 -1
- package/src/icons/ast/Print.ts +1 -1
- package/src/icons/ast/Success.ts +1 -1
- package/src/icons/ast/SuggestIntegration.ts +1 -1
- package/src/icons/ast/WarningTriangle.ts +1 -1
- package/src/icons/ast/Windows.ts +1 -1
- package/src/icons/svg/add-database.svg +1 -1
- package/src/icons/svg/add-integration.svg +1 -1
- package/src/icons/svg/arrows-right-left.svg +1 -1
- package/src/icons/svg/chat-bubble.svg +1 -1
- package/src/icons/svg/chat-float.svg +1 -1
- package/src/icons/svg/chat-sidebar.svg +3 -3
- package/src/icons/svg/clean.svg +1 -1
- package/src/icons/svg/create.svg +1 -1
- package/src/icons/svg/items-timeline.svg +1 -1
- package/src/icons/svg/key.svg +1 -1
- package/src/icons/svg/network-add.svg +1 -1
- package/src/icons/svg/print.svg +1 -1
- package/src/icons/svg/success.svg +1 -1
- package/src/icons/svg/suggest-integration.svg +1 -1
- package/src/icons/svg/warning-triangle.svg +1 -1
- package/src/icons/svg/windows.svg +1 -1
- package/src/images-gallery/images-gallery.tsx +24 -0
- package/src/lists/actions-menu-row-surface.tsx +2 -1
- package/src/logo.tsx +14 -13
- package/src/modal-menu/index.tsx +1 -0
- package/src/modal-menu/modal-menu-checkbox-item.tsx +50 -0
- package/src/online-users.tsx +45 -46
- package/src/palettes/slate-arch.colors-snapshot.test.ts +7 -7
- package/src/palettes/slate-user.colors-snapshot.test.ts +11 -11
- package/src/palettes/warm-arch.colors-snapshot.test.ts +7 -7
- package/src/palettes/warm-user.colors-snapshot.test.ts +7 -7
- package/src/popover/index.tsx +91 -203
- package/src/popover/popover-old.tsx +113 -0
- package/src/popover/popup-modifiers-context.ts +1 -1
- package/src/scale-generator.ts +2 -2
- package/src/select/components/clear-indicator.tsx +1 -1
- package/src/select/components/drop-down-indicator.tsx +2 -2
- package/src/select/components/group-heading.tsx +2 -2
- package/src/select/components/menu-list-virtualized.tsx +1 -1
- package/src/select/components/option.tsx +1 -1
- package/src/select/index.tsx +34 -37
- package/src/select/select-in-popover.tsx +34 -202
- package/src/select/select.tsx +5 -4
- package/src/select/styles.ts +3 -0
- package/src/thematic-state.ts +1 -1
- package/src/theme-provider.tsx +14 -2
- package/src/theme-styles.ts +14 -7
- package/src/toggle-button/toggle-button.tsx +48 -35
- package/src/tree-utils.test.ts +166 -0
- package/src/tree-utils.ts +107 -0
- package/src/file-item/use-register-in-image-gallery.tsx +0 -70
- package/src/file-item-2.tsx +0 -357
package/src/popover/index.tsx
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable max-lines */
|
|
2
1
|
import {stopPropagation} from "@fibery/react/src/stop-propagation";
|
|
3
2
|
import {useControllableState} from "@fibery/react/src/use-controllable-state";
|
|
4
3
|
import {usePointerDownOutside} from "@fibery/react/src/use-pointer-down-outside";
|
|
@@ -8,7 +7,6 @@ import {Options as FlipOptions} from "@popperjs/core/lib/modifiers/flip";
|
|
|
8
7
|
import {Options as PreventOverflowOptions} from "@popperjs/core/lib/modifiers/preventOverflow";
|
|
9
8
|
import cx from "classnames";
|
|
10
9
|
import compact from "lodash/compact";
|
|
11
|
-
import noop from "lodash/noop";
|
|
12
10
|
import {
|
|
13
11
|
cloneElement,
|
|
14
12
|
CSSProperties,
|
|
@@ -36,13 +34,13 @@ import {MobilePopoverProvider} from "./mobile-popover-context";
|
|
|
36
34
|
import {usePopupStackContext} from "./popup-stack-context";
|
|
37
35
|
import {composeRefs, useComposedRefs} from "@fibery/react/src/use-composed-refs";
|
|
38
36
|
import {createContext} from "@fibery/react/src/create-context";
|
|
39
|
-
import {Wrap} from "@fibery/react/src/wrap";
|
|
40
37
|
import {composeEventHandlers} from "@fibery/react/src/compose-event-handlers";
|
|
41
38
|
import {getElementRef} from "./get-element-ref";
|
|
42
39
|
import {MobilePopover} from "./mobile-popover";
|
|
43
40
|
import {FocusScope, FocusScopeProps} from "@radix-ui/react-focus-scope";
|
|
44
41
|
|
|
45
42
|
type PopoverContextValue = {
|
|
43
|
+
contentId: string;
|
|
46
44
|
open: boolean;
|
|
47
45
|
disabled?: boolean;
|
|
48
46
|
onOpen?: () => unknown;
|
|
@@ -55,7 +53,7 @@ type PopoverContextValue = {
|
|
|
55
53
|
|
|
56
54
|
const [PopoverProvider, usePopoverContext] = createContext<PopoverContextValue>("PopoverContext");
|
|
57
55
|
|
|
58
|
-
type
|
|
56
|
+
type PopoverRootProps = {
|
|
59
57
|
children: ReactNode;
|
|
60
58
|
open: boolean;
|
|
61
59
|
disabled?: boolean;
|
|
@@ -68,9 +66,9 @@ type RootProps = {
|
|
|
68
66
|
setPopupElement?: (value: HTMLDivElement | null) => void;
|
|
69
67
|
};
|
|
70
68
|
|
|
71
|
-
const Root = (
|
|
72
|
-
const
|
|
73
|
-
const
|
|
69
|
+
const Root = (props: PopoverRootProps) => {
|
|
70
|
+
const {children, open, disabled = false, onOpen, onClose, ...rest} = props;
|
|
71
|
+
const contentId = useId();
|
|
74
72
|
|
|
75
73
|
const [triggerElement, setTriggerElement] = useControllableState<Reference>({
|
|
76
74
|
value: rest.triggerElement,
|
|
@@ -84,55 +82,9 @@ const Root = ({children, open, disabled = false, onOpen, onClose, ...rest}: Root
|
|
|
84
82
|
const composedSetTriggerElement = useComposedRefs(setTriggerElement, rest.setTriggerElement);
|
|
85
83
|
const composedSetPopupElement = useComposedRefs(setPopupElement, rest.setPopupElement);
|
|
86
84
|
|
|
87
|
-
useEffect(() => {
|
|
88
|
-
let unregister: () => void;
|
|
89
|
-
if (registerPopup && open) {
|
|
90
|
-
unregister = registerPopup(id);
|
|
91
|
-
}
|
|
92
|
-
return () => {
|
|
93
|
-
unregister?.();
|
|
94
|
-
};
|
|
95
|
-
}, [registerPopup, id, open]);
|
|
96
|
-
|
|
97
|
-
useEffect(() => {
|
|
98
|
-
if (triggerElement && open) {
|
|
99
|
-
// Note: We don't check defaultPrevented because react-select and similar
|
|
100
|
-
// components call preventDefault() on all keydown events. We also don't
|
|
101
|
-
// expose onEscapeKeyDown prop to let consumers prevent default close behavior.
|
|
102
|
-
const onKeyDown = (evt: KeyboardEvent) => {
|
|
103
|
-
if (evt.key === "Escape") {
|
|
104
|
-
onClose?.(evt);
|
|
105
|
-
if (isElementReference(triggerElement)) {
|
|
106
|
-
triggerElement.focus();
|
|
107
|
-
}
|
|
108
|
-
evt.preventDefault();
|
|
109
|
-
evt.stopPropagation();
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
if (registerEscapeCallback) {
|
|
114
|
-
registerEscapeCallback(id, onKeyDown);
|
|
115
|
-
} else {
|
|
116
|
-
document.addEventListener("keydown", onKeyDown);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// if popup was opened but nothing was focused inside it we should catch 'Escape' key from trigger as well
|
|
120
|
-
// otherwise it can be caught by navigation panel
|
|
121
|
-
"addEventListener" in triggerElement && triggerElement.addEventListener("keydown", onKeyDown);
|
|
122
|
-
|
|
123
|
-
return () => {
|
|
124
|
-
if (!registerEscapeCallback) {
|
|
125
|
-
document.removeEventListener("keydown", onKeyDown);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
"removeEventListener" in triggerElement && triggerElement.removeEventListener("keydown", onKeyDown);
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
return () => {};
|
|
132
|
-
}, [onClose, open, triggerElement, registerEscapeCallback, id]);
|
|
133
|
-
|
|
134
85
|
const contextValue = useMemo(() => {
|
|
135
86
|
return {
|
|
87
|
+
contentId,
|
|
136
88
|
disabled,
|
|
137
89
|
triggerElement,
|
|
138
90
|
setTriggerElement: composedSetTriggerElement,
|
|
@@ -143,6 +95,7 @@ const Root = ({children, open, disabled = false, onOpen, onClose, ...rest}: Root
|
|
|
143
95
|
onOpen,
|
|
144
96
|
};
|
|
145
97
|
}, [
|
|
98
|
+
contentId,
|
|
146
99
|
disabled,
|
|
147
100
|
triggerElement,
|
|
148
101
|
composedSetTriggerElement,
|
|
@@ -173,18 +126,18 @@ const Backdrop = ({className}: {className?: string}) => {
|
|
|
173
126
|
);
|
|
174
127
|
};
|
|
175
128
|
|
|
176
|
-
type
|
|
129
|
+
type PopoverPortalProps = {
|
|
177
130
|
getPopupContainer?: () => HTMLElement;
|
|
178
131
|
children: ReactNode;
|
|
179
132
|
};
|
|
180
133
|
|
|
181
|
-
const Portal = ({getPopupContainer, children}:
|
|
134
|
+
const Portal = ({getPopupContainer, children}: PopoverPortalProps) => {
|
|
182
135
|
const popupModifiers = usePopupModifiers();
|
|
183
136
|
const getPopupContainerResult = getPopupContainer ?? popupModifiers.getPopupContainer;
|
|
184
137
|
return createPortal(children, getPopupContainerResult());
|
|
185
138
|
};
|
|
186
139
|
|
|
187
|
-
type
|
|
140
|
+
type PopoverTriggerProps = {
|
|
188
141
|
asChild?: boolean;
|
|
189
142
|
/** Custom reference element for popover positioning. Use when the trigger element differs from the anchor point (e.g., virtual/detached elements). */
|
|
190
143
|
reference?: Reference;
|
|
@@ -192,16 +145,9 @@ type TriggerProps = {
|
|
|
192
145
|
triggerEvent?: "mousedown" | "click";
|
|
193
146
|
} & React.ComponentPropsWithoutRef<"div">;
|
|
194
147
|
|
|
195
|
-
const Trigger = ({
|
|
196
|
-
asChild = false,
|
|
197
|
-
|
|
198
|
-
children,
|
|
199
|
-
triggerEvent = "mousedown",
|
|
200
|
-
onMouseDown,
|
|
201
|
-
onClick,
|
|
202
|
-
...props
|
|
203
|
-
}: TriggerProps) => {
|
|
204
|
-
const {setTriggerElement, disabled, open, onOpen, onClose} = usePopoverContext();
|
|
148
|
+
const Trigger = forwardRef<HTMLDivElement, PopoverTriggerProps>((props, ref) => {
|
|
149
|
+
const {asChild = false, reference, children, triggerEvent = "mousedown", onMouseDown, onClick, ...rest} = props;
|
|
150
|
+
const {contentId, setTriggerElement, disabled, open, onOpen, onClose} = usePopoverContext();
|
|
205
151
|
|
|
206
152
|
const onToggle = (e: React.MouseEvent<HTMLElement>) => {
|
|
207
153
|
if (disabled) {
|
|
@@ -229,6 +175,8 @@ const Trigger = ({
|
|
|
229
175
|
}
|
|
230
176
|
}, [reference, setTriggerElement]);
|
|
231
177
|
|
|
178
|
+
const composedRef = useComposedRefs(ref, setTriggerElement);
|
|
179
|
+
|
|
232
180
|
// Reference is passed
|
|
233
181
|
if (reference !== undefined) {
|
|
234
182
|
return null;
|
|
@@ -238,23 +186,24 @@ const Trigger = ({
|
|
|
238
186
|
const childrenRef = getElementRef(children);
|
|
239
187
|
|
|
240
188
|
return cloneElement(children, {
|
|
189
|
+
"aria-haspopup": "dialog",
|
|
241
190
|
"aria-expanded": open,
|
|
242
|
-
"aria-
|
|
243
|
-
...
|
|
244
|
-
ref: composeRefs(
|
|
245
|
-
className: cx(children.props.className,
|
|
191
|
+
"aria-controls": contentId,
|
|
192
|
+
...rest,
|
|
193
|
+
ref: composeRefs(composedRef, childrenRef),
|
|
194
|
+
className: cx(children.props.className, rest.className),
|
|
246
195
|
...triggerEventHandlers,
|
|
247
196
|
});
|
|
248
197
|
}
|
|
249
198
|
|
|
250
199
|
return (
|
|
251
|
-
<div ref={
|
|
200
|
+
<div ref={composedRef} {...triggerEventHandlers} {...rest}>
|
|
252
201
|
{children}
|
|
253
202
|
</div>
|
|
254
203
|
);
|
|
255
|
-
};
|
|
204
|
+
});
|
|
256
205
|
|
|
257
|
-
type
|
|
206
|
+
type PopoverContentProps = {
|
|
258
207
|
children: ReactNode;
|
|
259
208
|
placement?: Placement;
|
|
260
209
|
popupStyle?: $TSFixMe;
|
|
@@ -296,12 +245,12 @@ type ContentProps = {
|
|
|
296
245
|
* Can be prevented.
|
|
297
246
|
*/
|
|
298
247
|
onCloseAutoFocus?: FocusScopeProps["onUnmountAutoFocus"];
|
|
299
|
-
}
|
|
248
|
+
} & React.ComponentProps<"div">;
|
|
300
249
|
|
|
301
250
|
export type ContentRef = {update: (() => Promise<unknown>) | null};
|
|
302
251
|
|
|
303
|
-
const Content = forwardRef<ContentRef,
|
|
304
|
-
{
|
|
252
|
+
const Content = forwardRef<ContentRef, PopoverContentProps>((props, ref) => {
|
|
253
|
+
const {
|
|
305
254
|
children,
|
|
306
255
|
placement,
|
|
307
256
|
popupStyle,
|
|
@@ -323,16 +272,62 @@ const Content = forwardRef<ContentRef, ContentProps>(function PopoverContent(
|
|
|
323
272
|
fixStackingContextAfterOpen = false,
|
|
324
273
|
transform,
|
|
325
274
|
onFirstUpdate,
|
|
326
|
-
onMouseLeave,
|
|
327
275
|
onOpenAutoFocus,
|
|
328
276
|
onCloseAutoFocus,
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
const {open, onClose, triggerElement, popupElement, setPopupElement} = usePopoverContext();
|
|
277
|
+
...rest
|
|
278
|
+
} = props;
|
|
279
|
+
const {contentId, open, onClose, triggerElement, popupElement, setPopupElement} = usePopoverContext();
|
|
333
280
|
|
|
334
281
|
const popupModifiers = usePopupModifiers();
|
|
335
282
|
const isPhone = useIsPhone();
|
|
283
|
+
const {registerEscapeCallback, registerPopup} = usePopupStackContext();
|
|
284
|
+
|
|
285
|
+
useEffect(() => {
|
|
286
|
+
let unregister: () => void;
|
|
287
|
+
if (registerPopup && open) {
|
|
288
|
+
unregister = registerPopup(contentId);
|
|
289
|
+
}
|
|
290
|
+
return () => {
|
|
291
|
+
unregister?.();
|
|
292
|
+
};
|
|
293
|
+
}, [registerPopup, contentId, open]);
|
|
294
|
+
|
|
295
|
+
useEffect(() => {
|
|
296
|
+
if (triggerElement && open) {
|
|
297
|
+
// Note: We don't check defaultPrevented because react-select and similar
|
|
298
|
+
// components call preventDefault() on all keydown events. We also don't
|
|
299
|
+
// expose onEscapeKeyDown prop to let consumers prevent default close behavior.
|
|
300
|
+
const onKeyDown = (evt: KeyboardEvent) => {
|
|
301
|
+
if (evt.key === "Escape") {
|
|
302
|
+
onClose?.(evt);
|
|
303
|
+
if (isElementReference(triggerElement)) {
|
|
304
|
+
triggerElement.focus();
|
|
305
|
+
}
|
|
306
|
+
evt.preventDefault();
|
|
307
|
+
evt.stopPropagation();
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
if (registerEscapeCallback) {
|
|
312
|
+
registerEscapeCallback(contentId, onKeyDown);
|
|
313
|
+
} else {
|
|
314
|
+
document.addEventListener("keydown", onKeyDown);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// if popup was opened but nothing was focused inside it we should catch 'Escape' key from trigger as well
|
|
318
|
+
// otherwise it can be caught by navigation panel
|
|
319
|
+
"addEventListener" in triggerElement && triggerElement.addEventListener("keydown", onKeyDown);
|
|
320
|
+
|
|
321
|
+
return () => {
|
|
322
|
+
if (!registerEscapeCallback) {
|
|
323
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
"removeEventListener" in triggerElement && triggerElement.removeEventListener("keydown", onKeyDown);
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
return () => {};
|
|
330
|
+
}, [onClose, open, triggerElement, registerEscapeCallback, contentId]);
|
|
336
331
|
|
|
337
332
|
// We get infinite popup renders if this is not in a separate memo
|
|
338
333
|
const shrinkableModifiers = useMemo(() => {
|
|
@@ -418,9 +413,7 @@ const Content = forwardRef<ContentRef, ContentProps>(function PopoverContent(
|
|
|
418
413
|
}
|
|
419
414
|
};
|
|
420
415
|
|
|
421
|
-
const contentStyles = useMemo(() => {
|
|
422
|
-
return {...styles.popper, ...popupStyle};
|
|
423
|
-
}, [popupStyle, styles.popper]);
|
|
416
|
+
const contentStyles = useMemo(() => ({...styles.popper, ...popupStyle}), [popupStyle, styles.popper]);
|
|
424
417
|
|
|
425
418
|
if (!open) {
|
|
426
419
|
return null;
|
|
@@ -469,13 +462,15 @@ const Content = forwardRef<ContentRef, ContentProps>(function PopoverContent(
|
|
|
469
462
|
>
|
|
470
463
|
<div
|
|
471
464
|
role="dialog"
|
|
465
|
+
id={contentId}
|
|
472
466
|
ref={setPopupElement}
|
|
467
|
+
{...rest}
|
|
473
468
|
className={cx(
|
|
469
|
+
rest.className,
|
|
474
470
|
basicPopupContainerClassName,
|
|
475
471
|
hidePopupWhenTriggerIsHidden && hidePopupWhenTriggerIsHiddenClassName,
|
|
476
472
|
popupContainerClassName
|
|
477
473
|
)}
|
|
478
|
-
onMouseLeave={onMouseLeave}
|
|
479
474
|
onClick={stopPropagation}
|
|
480
475
|
{...attributes.popper}
|
|
481
476
|
onPointerDownCapture={onPointerDownCapture}
|
|
@@ -490,123 +485,16 @@ const Content = forwardRef<ContentRef, ContentProps>(function PopoverContent(
|
|
|
490
485
|
);
|
|
491
486
|
});
|
|
492
487
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
export type {Placement, State, Reference, RootProps, TriggerProps, ContentProps};
|
|
496
|
-
|
|
497
|
-
export const Popover = {
|
|
498
|
-
Root,
|
|
499
|
-
Trigger,
|
|
500
|
-
Portal,
|
|
501
|
-
Content,
|
|
502
|
-
};
|
|
488
|
+
const Popover = {Root, Trigger, Portal, Content};
|
|
503
489
|
|
|
504
|
-
export
|
|
505
|
-
ContentProps &
|
|
506
|
-
Pick<PortalProps, "getPopupContainer"> & {
|
|
507
|
-
trigger?: ReactNode;
|
|
508
|
-
triggerDomElement?: Reference;
|
|
509
|
-
renderInPortal?: boolean;
|
|
510
|
-
};
|
|
490
|
+
export {createPopper, Popover};
|
|
511
491
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
* // Instead of PopoverOld:
|
|
521
|
-
* <PopoverOld
|
|
522
|
-
* trigger={<button>Click me</button>}
|
|
523
|
-
* open={isOpen}
|
|
524
|
-
* onOpen={() => setIsOpen(true)}
|
|
525
|
-
* onClose={() => setIsOpen(false)}
|
|
526
|
-
* >
|
|
527
|
-
* <div>Popover content</div>
|
|
528
|
-
* </PopoverOld>
|
|
529
|
-
*
|
|
530
|
-
* // Use Popover compound components:
|
|
531
|
-
* <Popover.Root
|
|
532
|
-
* open={isOpen}
|
|
533
|
-
* onOpen={() => setIsOpen(true)}
|
|
534
|
-
* onClose={() => setIsOpen(false)}
|
|
535
|
-
* >
|
|
536
|
-
* <Popover.Trigger asChild triggerEvent="click">
|
|
537
|
-
* <button>Click me</button>
|
|
538
|
-
* </Popover.Trigger>
|
|
539
|
-
* <Popover.Portal>
|
|
540
|
-
* <Popover.Content>
|
|
541
|
-
* <div>Popover content</div>
|
|
542
|
-
* </Popover.Content>
|
|
543
|
-
* </Popover.Portal>
|
|
544
|
-
* </Popover.Root>
|
|
545
|
-
* ```
|
|
546
|
-
*/
|
|
547
|
-
export const PopoverOld = ({
|
|
548
|
-
trigger,
|
|
549
|
-
triggerDomElement,
|
|
550
|
-
children,
|
|
551
|
-
placement,
|
|
552
|
-
open,
|
|
553
|
-
popupStyle,
|
|
554
|
-
popupContainerClassName,
|
|
555
|
-
popupClassName,
|
|
556
|
-
renderInPortal,
|
|
557
|
-
offset = [0, 0],
|
|
558
|
-
disabled = false,
|
|
559
|
-
onMouseLeave,
|
|
560
|
-
renderBackdrop,
|
|
561
|
-
backdropClassName,
|
|
562
|
-
preventOverflowOptions = {},
|
|
563
|
-
flipOptions = {},
|
|
564
|
-
additionalModifiers = [],
|
|
565
|
-
hidePopupWhenTriggerIsHidden = true,
|
|
566
|
-
shrinkable,
|
|
567
|
-
onOpen = noop,
|
|
568
|
-
onClose = noop,
|
|
569
|
-
supportMobile = false,
|
|
570
|
-
title = "",
|
|
571
|
-
mobilePopupStyle,
|
|
572
|
-
mobilePopupContentClassName,
|
|
573
|
-
getPopupContainer,
|
|
574
|
-
fixStackingContextAfterOpen = false,
|
|
575
|
-
onFirstUpdate,
|
|
576
|
-
transform,
|
|
577
|
-
}: PopoverOldProps) => {
|
|
578
|
-
return (
|
|
579
|
-
<Popover.Root open={open} disabled={disabled} onOpen={onOpen} onClose={onClose}>
|
|
580
|
-
{triggerDomElement ? (
|
|
581
|
-
<Popover.Trigger reference={triggerDomElement}></Popover.Trigger>
|
|
582
|
-
) : (
|
|
583
|
-
<Popover.Trigger>{trigger}</Popover.Trigger>
|
|
584
|
-
)}
|
|
585
|
-
<Wrap with={Popover.Portal} if={renderInPortal} getPopupContainer={getPopupContainer}>
|
|
586
|
-
<Popover.Content
|
|
587
|
-
children={children}
|
|
588
|
-
placement={placement}
|
|
589
|
-
popupStyle={popupStyle}
|
|
590
|
-
popupContainerClassName={popupContainerClassName}
|
|
591
|
-
popupClassName={popupClassName}
|
|
592
|
-
offset={offset}
|
|
593
|
-
onMouseLeave={onMouseLeave}
|
|
594
|
-
renderBackdrop={renderBackdrop}
|
|
595
|
-
backdropClassName={backdropClassName}
|
|
596
|
-
preventOverflowOptions={preventOverflowOptions}
|
|
597
|
-
flipOptions={flipOptions}
|
|
598
|
-
additionalModifiers={additionalModifiers}
|
|
599
|
-
hidePopupWhenTriggerIsHidden={hidePopupWhenTriggerIsHidden}
|
|
600
|
-
shrinkable={shrinkable}
|
|
601
|
-
supportMobile={supportMobile}
|
|
602
|
-
title={title}
|
|
603
|
-
mobilePopupStyle={mobilePopupStyle}
|
|
604
|
-
mobilePopupContentClassName={mobilePopupContentClassName}
|
|
605
|
-
fixStackingContextAfterOpen={fixStackingContextAfterOpen}
|
|
606
|
-
onFirstUpdate={onFirstUpdate}
|
|
607
|
-
transform={transform}
|
|
608
|
-
/>
|
|
609
|
-
</Wrap>
|
|
610
|
-
</Popover.Root>
|
|
611
|
-
);
|
|
492
|
+
export type {
|
|
493
|
+
Placement,
|
|
494
|
+
State,
|
|
495
|
+
Reference,
|
|
496
|
+
PopoverRootProps,
|
|
497
|
+
PopoverTriggerProps,
|
|
498
|
+
PopoverContentProps,
|
|
499
|
+
PopoverPortalProps,
|
|
612
500
|
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import noop from "lodash/noop";
|
|
2
|
+
import {Wrap} from "@fibery/react/src/wrap";
|
|
3
|
+
import {Popover, PopoverContentProps, PopoverPortalProps, PopoverRootProps, Reference} from "./index";
|
|
4
|
+
import {ReactNode} from "react";
|
|
5
|
+
|
|
6
|
+
export type PopoverOldProps = Pick<PopoverRootProps, "children" | "open" | "onOpen" | "onClose" | "disabled"> &
|
|
7
|
+
PopoverContentProps &
|
|
8
|
+
Pick<PopoverPortalProps, "getPopupContainer"> & {
|
|
9
|
+
trigger?: ReactNode;
|
|
10
|
+
triggerDomElement?: Reference;
|
|
11
|
+
renderInPortal?: boolean;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use the new `Popover` compound component instead.
|
|
15
|
+
*
|
|
16
|
+
* The `PopoverOld` component is deprecated and will be removed in a future version.
|
|
17
|
+
* Please migrate to the new `Popover` API which provides better composition and flexibility:
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* // Instead of PopoverOld:
|
|
22
|
+
* <PopoverOld
|
|
23
|
+
* trigger={<button>Click me</button>}
|
|
24
|
+
* open={isOpen}
|
|
25
|
+
* onOpen={() => setIsOpen(true)}
|
|
26
|
+
* onClose={() => setIsOpen(false)}
|
|
27
|
+
* >
|
|
28
|
+
* <div>Popover content</div>
|
|
29
|
+
* </PopoverOld>
|
|
30
|
+
*
|
|
31
|
+
* // Use Popover compound components:
|
|
32
|
+
* <Popover.Root
|
|
33
|
+
* open={isOpen}
|
|
34
|
+
* onOpen={() => setIsOpen(true)}
|
|
35
|
+
* onClose={() => setIsOpen(false)}
|
|
36
|
+
* >
|
|
37
|
+
* <Popover.Trigger asChild triggerEvent="click">
|
|
38
|
+
* <button>Click me</button>
|
|
39
|
+
* </Popover.Trigger>
|
|
40
|
+
* <Popover.Portal>
|
|
41
|
+
* <Popover.Content>
|
|
42
|
+
* <div>Popover content</div>
|
|
43
|
+
* </Popover.Content>
|
|
44
|
+
* </Popover.Portal>
|
|
45
|
+
* </Popover.Root>
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export const PopoverOld = ({
|
|
49
|
+
trigger,
|
|
50
|
+
triggerDomElement,
|
|
51
|
+
children,
|
|
52
|
+
placement,
|
|
53
|
+
open,
|
|
54
|
+
popupStyle,
|
|
55
|
+
popupContainerClassName,
|
|
56
|
+
popupClassName,
|
|
57
|
+
renderInPortal,
|
|
58
|
+
offset = [0, 0],
|
|
59
|
+
disabled = false,
|
|
60
|
+
onMouseLeave,
|
|
61
|
+
renderBackdrop,
|
|
62
|
+
backdropClassName,
|
|
63
|
+
preventOverflowOptions = {},
|
|
64
|
+
flipOptions = {},
|
|
65
|
+
additionalModifiers = [],
|
|
66
|
+
hidePopupWhenTriggerIsHidden = true,
|
|
67
|
+
shrinkable,
|
|
68
|
+
onOpen = noop,
|
|
69
|
+
onClose = noop,
|
|
70
|
+
supportMobile = false,
|
|
71
|
+
title = "",
|
|
72
|
+
mobilePopupStyle,
|
|
73
|
+
mobilePopupContentClassName,
|
|
74
|
+
getPopupContainer,
|
|
75
|
+
fixStackingContextAfterOpen = false,
|
|
76
|
+
onFirstUpdate,
|
|
77
|
+
transform,
|
|
78
|
+
}: PopoverOldProps) => {
|
|
79
|
+
return (
|
|
80
|
+
<Popover.Root open={open} disabled={disabled} onOpen={onOpen} onClose={onClose}>
|
|
81
|
+
{triggerDomElement ? (
|
|
82
|
+
<Popover.Trigger reference={triggerDomElement}></Popover.Trigger>
|
|
83
|
+
) : (
|
|
84
|
+
<Popover.Trigger>{trigger}</Popover.Trigger>
|
|
85
|
+
)}
|
|
86
|
+
<Wrap with={Popover.Portal} if={renderInPortal} getPopupContainer={getPopupContainer}>
|
|
87
|
+
<Popover.Content
|
|
88
|
+
children={children}
|
|
89
|
+
placement={placement}
|
|
90
|
+
popupStyle={popupStyle}
|
|
91
|
+
popupContainerClassName={popupContainerClassName}
|
|
92
|
+
popupClassName={popupClassName}
|
|
93
|
+
offset={offset}
|
|
94
|
+
onMouseLeave={onMouseLeave}
|
|
95
|
+
renderBackdrop={renderBackdrop}
|
|
96
|
+
backdropClassName={backdropClassName}
|
|
97
|
+
preventOverflowOptions={preventOverflowOptions}
|
|
98
|
+
flipOptions={flipOptions}
|
|
99
|
+
additionalModifiers={additionalModifiers}
|
|
100
|
+
hidePopupWhenTriggerIsHidden={hidePopupWhenTriggerIsHidden}
|
|
101
|
+
shrinkable={shrinkable}
|
|
102
|
+
supportMobile={supportMobile}
|
|
103
|
+
title={title}
|
|
104
|
+
mobilePopupStyle={mobilePopupStyle}
|
|
105
|
+
mobilePopupContentClassName={mobilePopupContentClassName}
|
|
106
|
+
fixStackingContextAfterOpen={fixStackingContextAfterOpen}
|
|
107
|
+
onFirstUpdate={onFirstUpdate}
|
|
108
|
+
transform={transform}
|
|
109
|
+
/>
|
|
110
|
+
</Wrap>
|
|
111
|
+
</Popover.Root>
|
|
112
|
+
);
|
|
113
|
+
};
|
|
@@ -2,7 +2,7 @@ import {createContext} from "@fibery/react/src/create-context";
|
|
|
2
2
|
import {getPopupContainerElement} from "../utils-dom";
|
|
3
3
|
import {$TSFixMe} from "../tsfixme";
|
|
4
4
|
import {Modifier} from "react-popper";
|
|
5
|
-
import {PopoverOldProps} from "./
|
|
5
|
+
import {PopoverOldProps} from "./popover-old";
|
|
6
6
|
|
|
7
7
|
export const [PopupModifiersProvider, usePopupModifiers] = createContext<{
|
|
8
8
|
getPopupContainer: () => HTMLElement;
|
package/src/scale-generator.ts
CHANGED
|
@@ -14,7 +14,7 @@ export type OneBasedScale<T> = readonly [
|
|
|
14
14
|
step09: T,
|
|
15
15
|
step10: T,
|
|
16
16
|
step11: T,
|
|
17
|
-
step12: T
|
|
17
|
+
step12: T,
|
|
18
18
|
];
|
|
19
19
|
|
|
20
20
|
export type ZeroBasedScale<T> = readonly [
|
|
@@ -29,7 +29,7 @@ export type ZeroBasedScale<T> = readonly [
|
|
|
29
29
|
step09: T,
|
|
30
30
|
step10: T,
|
|
31
31
|
step11: T,
|
|
32
|
-
step12: T
|
|
32
|
+
step12: T,
|
|
33
33
|
];
|
|
34
34
|
|
|
35
35
|
export function zeroBasedFromOneBased<T>(scale: OneBasedScale<T>) {
|
|
@@ -5,7 +5,7 @@ import RemoveIcon from "../../icons/react/Remove";
|
|
|
5
5
|
export function ClearIndicator<
|
|
6
6
|
TOption,
|
|
7
7
|
IsMulti extends boolean = boolean,
|
|
8
|
-
Group extends GroupBase<TOption> = GroupBase<TOption
|
|
8
|
+
Group extends GroupBase<TOption> = GroupBase<TOption>,
|
|
9
9
|
>({
|
|
10
10
|
innerProps,
|
|
11
11
|
selectProps,
|
|
@@ -14,7 +14,7 @@ const expanderStyle = css`
|
|
|
14
14
|
export function AlwaysVisibleDropdownIndicator<
|
|
15
15
|
TOption,
|
|
16
16
|
IsMulti extends boolean = boolean,
|
|
17
|
-
Group extends GroupBase<TOption> = GroupBase<TOption
|
|
17
|
+
Group extends GroupBase<TOption> = GroupBase<TOption>,
|
|
18
18
|
>(props: DropdownIndicatorProps<TOption, IsMulti, Group>) {
|
|
19
19
|
return (
|
|
20
20
|
<div className={cn(expanderStyle, props.selectProps.menuIsOpen && expanderExpandedStyle)}>
|
|
@@ -26,7 +26,7 @@ export function AlwaysVisibleDropdownIndicator<
|
|
|
26
26
|
export function DropdownIndicator<
|
|
27
27
|
TOption,
|
|
28
28
|
IsMulti extends boolean = boolean,
|
|
29
|
-
Group extends GroupBase<TOption> = GroupBase<TOption
|
|
29
|
+
Group extends GroupBase<TOption> = GroupBase<TOption>,
|
|
30
30
|
>(props: DropdownIndicatorProps<TOption, IsMulti, Group>) {
|
|
31
31
|
if (props.selectProps.isDisabled) {
|
|
32
32
|
return null;
|
|
@@ -59,7 +59,7 @@ const GroupDivider = () => (
|
|
|
59
59
|
export function GroupHeading<
|
|
60
60
|
Option,
|
|
61
61
|
IsMulti extends boolean = false,
|
|
62
|
-
Group extends GroupBase<Option> = GroupBase<Option
|
|
62
|
+
Group extends GroupBase<Option> = GroupBase<Option>,
|
|
63
63
|
>({children, ...props}: GroupHeadingProps<Option, IsMulti, Group>) {
|
|
64
64
|
if (props.data.separator) {
|
|
65
65
|
return <GroupDivider />;
|
|
@@ -91,7 +91,7 @@ export function GroupHeading<
|
|
|
91
91
|
export function GroupSeparator<
|
|
92
92
|
Option,
|
|
93
93
|
IsMulti extends boolean = false,
|
|
94
|
-
Group extends GroupBase<Option> = GroupBase<Option
|
|
94
|
+
Group extends GroupBase<Option> = GroupBase<Option>,
|
|
95
95
|
>({...props}: GroupHeadingProps<Option, IsMulti, Group>) {
|
|
96
96
|
// Hide separators when searching
|
|
97
97
|
if (!props.data.separator || props.selectProps.inputValue) {
|
|
@@ -67,7 +67,7 @@ const drawListElement: ItemContent<ReactNode, never> = (index, child) => child;
|
|
|
67
67
|
export function MenuListVirtualized<
|
|
68
68
|
Option,
|
|
69
69
|
IsMulti extends boolean = boolean,
|
|
70
|
-
Group extends GroupBase<Option> = GroupBase<Option
|
|
70
|
+
Group extends GroupBase<Option> = GroupBase<Option>,
|
|
71
71
|
>(props: MenuListProps<Option, IsMulti, Group>) {
|
|
72
72
|
const {children, focusedOption, innerRef, maxHeight, theme, getStyles, cx, selectProps} = props;
|
|
73
73
|
const isPhone = useIsPhone();
|
|
@@ -51,7 +51,7 @@ const OptionWithTextContent = css`
|
|
|
51
51
|
export function OptionSlow<
|
|
52
52
|
Option,
|
|
53
53
|
IsMulti extends boolean = false,
|
|
54
|
-
Group extends GroupBase<Option> = GroupBase<Option
|
|
54
|
+
Group extends GroupBase<Option> = GroupBase<Option>,
|
|
55
55
|
>({children, ...rest}: OptionProps<Option, IsMulti, Group>) {
|
|
56
56
|
const {isDisabled, isSelected, isFocused} = rest;
|
|
57
57
|
const isPureText = useMemo(() => isPureTextChildren(children), [children]);
|