@robosystems/core 0.17.1 → 0.18.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/README.md +2 -2
- package/auth-components/AppSwitcher.js +2 -3
- package/components/EntitySelector.js +1 -1
- package/components/RepositoryGuard.js +1 -1
- package/components/console/ConsoleContent.js +1 -1
- package/components/report-chat/ReportChat.d.ts +13 -0
- package/components/report-chat/ReportChat.js +1 -1
- package/components/repositories/ActiveSubscriptions.js +1 -1
- package/components/repositories/BrowseRepositories.js +1 -1
- package/components/search/SearchBar.js +1 -1
- package/components/search/SearchContent.js +1 -1
- package/components/search/SearchHitCard.js +1 -1
- package/components/search/SearchPagination.js +1 -1
- package/hooks/use-toast.d.ts +1 -1
- package/hooks/use-toast.js +2 -2
- package/library/components/ElementBrowser.js +1 -1
- package/library/components/ElementDetail.js +1 -1
- package/library/components/LibraryHierarchy.js +1 -1
- package/library/components/TaxonomySidebar.js +1 -1
- package/package.json +2 -2
- package/styles/forms.css +478 -0
- package/styles/palette.css +265 -0
- package/theme/flowbite-theme.d.ts +638 -638
- package/theme/flowbite-theme.js +16 -21
- package/ui/Alert.d.ts +66 -0
- package/ui/Alert.js +24 -0
- package/ui/Badge.d.ts +50 -0
- package/ui/Badge.js +21 -0
- package/ui/Breadcrumb.d.ts +10 -0
- package/ui/Breadcrumb.js +31 -0
- package/ui/Button.d.ts +76 -0
- package/ui/Button.js +26 -0
- package/ui/Card.d.ts +32 -0
- package/ui/Card.js +26 -0
- package/ui/Checkbox.d.ts +33 -0
- package/ui/Checkbox.js +21 -0
- package/ui/Dropdown.d.ts +67 -0
- package/ui/Dropdown.js +134 -0
- package/ui/FileInput.d.ts +23 -0
- package/ui/FileInput.js +21 -0
- package/ui/Floating.d.ts +96 -0
- package/ui/Floating.js +92 -0
- package/ui/HelperText.d.ts +19 -0
- package/ui/HelperText.js +21 -0
- package/ui/Label.d.ts +21 -0
- package/ui/Label.js +21 -0
- package/ui/Modal.d.ts +85 -0
- package/ui/Modal.js +73 -0
- package/ui/Navbar.d.ts +14 -0
- package/ui/Navbar.js +35 -0
- package/ui/Progress.d.ts +40 -0
- package/ui/Progress.js +26 -0
- package/ui/Radio.d.ts +31 -0
- package/ui/Radio.js +21 -0
- package/ui/Select.d.ts +49 -0
- package/ui/Select.js +21 -0
- package/ui/Sidebar.d.ts +114 -0
- package/ui/Sidebar.js +76 -0
- package/ui/Spinner.d.ts +60 -0
- package/ui/Spinner.js +22 -0
- package/ui/Table.d.ts +23 -0
- package/ui/Table.js +57 -0
- package/ui/Tabs.d.ts +78 -0
- package/ui/Tabs.js +64 -0
- package/ui/TextInput.d.ts +58 -0
- package/ui/TextInput.js +21 -0
- package/ui/Textarea.d.ts +22 -0
- package/ui/Textarea.js +21 -0
- package/ui/ThemeModeScript.d.ts +21 -0
- package/ui/ThemeModeScript.js +74 -0
- package/ui/Toast.d.ts +24 -0
- package/ui/Toast.js +58 -0
- package/ui/ToggleSwitch.d.ts +54 -0
- package/ui/ToggleSwitch.js +26 -0
- package/ui/Tooltip.d.ts +3 -0
- package/ui/Tooltip.js +19 -0
- package/ui/cn.d.ts +6 -0
- package/ui/cn.js +19 -0
- package/ui/icons.d.ts +8 -0
- package/ui/icons.js +22 -0
- package/ui/index.d.ts +37 -0
- package/ui/index.js +36 -0
- package/ui/merge-theme.d.ts +15 -0
- package/ui/merge-theme.js +26 -0
- package/ui/theme-defaults.d.ts +821 -0
- package/ui/theme-defaults.js +824 -0
- package/ui/theme-mode.d.ts +15 -0
- package/ui/theme-mode.js +92 -0
- package/ui/types.d.ts +6 -0
- package/ui/types.js +1 -0
- package/ui-components/ConfirmModal.js +1 -1
- package/ui-components/StatCard.js +1 -1
- package/ui-components/api-keys/ApiKeyDisplay.d.ts +0 -1
- package/ui-components/api-keys/ApiKeyDisplay.js +3 -3
- package/ui-components/api-keys/CreateApiKeyModal.d.ts +0 -1
- package/ui-components/api-keys/CreateApiKeyModal.js +4 -4
- package/ui-components/api-keys/SecureApiKeyField.js +1 -1
- package/ui-components/chat/ChatInputArea.js +1 -1
- package/ui-components/chat/ChatMessage.js +1 -1
- package/ui-components/chat/DeepResearchToggle.js +1 -1
- package/ui-components/forms/CategoryInput.js +1 -1
- package/ui-components/forms/SettingsCard.d.ts +0 -1
- package/ui-components/forms/SettingsCard.js +3 -3
- package/ui-components/forms/SettingsFormField.d.ts +0 -1
- package/ui-components/forms/SettingsFormField.js +3 -3
- package/ui-components/forms/StatusAlert.d.ts +0 -1
- package/ui-components/forms/StatusAlert.js +3 -3
- package/ui-components/forms/TagInput.d.ts +1 -1
- package/ui-components/forms/TagInput.js +1 -1
- package/ui-components/layout/CoreNavbar.js +7 -8
- package/ui-components/layout/CoreSidebar.js +12 -13
- package/ui-components/layout/ThemeToggle.js +1 -1
- package/ui-components/settings/GeneralInformationCard.d.ts +0 -1
- package/ui-components/settings/GeneralInformationCard.js +3 -3
- package/ui-components/settings/PasswordInformationCard.d.ts +0 -1
- package/ui-components/settings/PasswordInformationCard.js +4 -4
- package/ui-components/settings/SettingsPageHeader.js +1 -1
- package/ui-components/support/SupportModal.js +1 -1
package/ui/Dropdown.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { FloatingFocusManager, FloatingList, useListItem, useListNavigation, useMergeRefs, useTypeahead, } from '@floating-ui/react';
|
|
15
|
+
import { cloneElement, createContext, createElement, forwardRef, useCallback, useContext, useEffect, useMemo, useRef, useState, } from 'react';
|
|
16
|
+
import { Button } from './Button';
|
|
17
|
+
import { cn } from './cn';
|
|
18
|
+
import { useBaseFloating, useFloatingInteractions, } from './Floating';
|
|
19
|
+
import { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, } from './icons';
|
|
20
|
+
import { themeDefaults } from './theme-defaults';
|
|
21
|
+
const t = themeDefaults.dropdown;
|
|
22
|
+
const DropdownContext = createContext(undefined);
|
|
23
|
+
function useDropdownContext() {
|
|
24
|
+
const context = useContext(DropdownContext);
|
|
25
|
+
if (!context)
|
|
26
|
+
throw new Error('useDropdownContext should be used within the DropdownContext provider!');
|
|
27
|
+
return context;
|
|
28
|
+
}
|
|
29
|
+
const icons = {
|
|
30
|
+
top: ChevronUpIcon,
|
|
31
|
+
right: ChevronRightIcon,
|
|
32
|
+
bottom: ChevronDownIcon,
|
|
33
|
+
left: ChevronLeftIcon,
|
|
34
|
+
};
|
|
35
|
+
function Trigger(_a) {
|
|
36
|
+
var { refs, children, inline, disabled, setButtonWidth, getReferenceProps, renderTrigger } = _a, buttonProps = __rest(_a, ["refs", "children", "inline", "disabled", "setButtonWidth", "getReferenceProps", "renderTrigger"]);
|
|
37
|
+
const ref = refs.reference;
|
|
38
|
+
const a11yProps = getReferenceProps();
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (ref.current)
|
|
41
|
+
setButtonWidth(ref.current.clientWidth);
|
|
42
|
+
}, [ref, setButtonWidth]);
|
|
43
|
+
if (renderTrigger) {
|
|
44
|
+
const triggerElement = renderTrigger(t);
|
|
45
|
+
return cloneElement(triggerElement, Object.assign(Object.assign({ ref: refs.setReference, disabled }, a11yProps), triggerElement.props));
|
|
46
|
+
}
|
|
47
|
+
return inline ? (_jsx("button", Object.assign({ type: "button", ref: refs.setReference, className: t.inlineWrapper, disabled: disabled }, a11yProps, { children: children }))) : (_jsx(Button, Object.assign({}, buttonProps, { disabled: disabled, type: "button", ref: refs.setReference }, a11yProps, { children: children })));
|
|
48
|
+
}
|
|
49
|
+
const DropdownRoot = function Dropdown(_a) {
|
|
50
|
+
var { children, className, dismissOnClick = true, enableTypeAhead = true, renderTrigger, inline, placement = inline ? 'bottom-start' : 'bottom', trigger = 'click', label, arrowIcon = true } = _a, buttonProps = __rest(_a, ["children", "className", "dismissOnClick", "enableTypeAhead", "renderTrigger", "inline", "placement", "trigger", "label", "arrowIcon"]);
|
|
51
|
+
const [open, setOpen] = useState(false);
|
|
52
|
+
const [activeIndex, setActiveIndex] = useState(null);
|
|
53
|
+
const [selectedIndex, setSelectedIndex] = useState(null);
|
|
54
|
+
const [buttonWidth, setButtonWidth] = useState(undefined);
|
|
55
|
+
const elementsRef = useRef([]);
|
|
56
|
+
const labelsRef = useRef([]);
|
|
57
|
+
const dataTestId = buttonProps['data-testid'] || 'flowbite-dropdown-target';
|
|
58
|
+
const handleSelect = useCallback((index) => {
|
|
59
|
+
setSelectedIndex(index);
|
|
60
|
+
setOpen(false);
|
|
61
|
+
}, []);
|
|
62
|
+
const handleTypeaheadMatch = useCallback((index) => {
|
|
63
|
+
if (open)
|
|
64
|
+
setActiveIndex(index);
|
|
65
|
+
else
|
|
66
|
+
handleSelect(index);
|
|
67
|
+
}, [open, handleSelect]);
|
|
68
|
+
const { context, floatingStyles, refs } = useBaseFloating({
|
|
69
|
+
open,
|
|
70
|
+
setOpen,
|
|
71
|
+
placement,
|
|
72
|
+
});
|
|
73
|
+
const listNav = useListNavigation(context, {
|
|
74
|
+
listRef: elementsRef,
|
|
75
|
+
activeIndex,
|
|
76
|
+
selectedIndex,
|
|
77
|
+
onNavigate: setActiveIndex,
|
|
78
|
+
});
|
|
79
|
+
const typeahead = useTypeahead(context, {
|
|
80
|
+
listRef: labelsRef,
|
|
81
|
+
activeIndex,
|
|
82
|
+
selectedIndex,
|
|
83
|
+
onMatch: handleTypeaheadMatch,
|
|
84
|
+
enabled: enableTypeAhead,
|
|
85
|
+
});
|
|
86
|
+
const { getReferenceProps, getFloatingProps, getItemProps } = useFloatingInteractions({
|
|
87
|
+
context,
|
|
88
|
+
role: 'menu',
|
|
89
|
+
trigger,
|
|
90
|
+
interactions: [listNav, typeahead],
|
|
91
|
+
});
|
|
92
|
+
const Icon = useMemo(() => {
|
|
93
|
+
var _a;
|
|
94
|
+
const [p] = placement.split('-');
|
|
95
|
+
return (_a = icons[p]) !== null && _a !== void 0 ? _a : ChevronDownIcon;
|
|
96
|
+
}, [placement]);
|
|
97
|
+
return (_jsxs(DropdownContext.Provider, { value: { activeIndex, dismissOnClick, getItemProps, handleSelect }, children: [_jsxs(Trigger, Object.assign({}, buttonProps, { refs: refs, inline: inline, "data-testid": dataTestId, className: cn(t.floating.target, className), setButtonWidth: setButtonWidth, getReferenceProps: getReferenceProps, renderTrigger: renderTrigger, children: [label, arrowIcon && _jsx(Icon, { className: t.arrowIcon })] })), open && (_jsx(FloatingFocusManager, { context: context, modal: false, children: _jsx("div", Object.assign({ ref: refs.setFloating, style: Object.assign(Object.assign({}, floatingStyles), { minWidth: buttonWidth }), "data-testid": "flowbite-dropdown", "aria-expanded": open }, getFloatingProps({
|
|
98
|
+
className: cn(t.floating.base, t.floating.animation, 'duration-100', !open && t.floating.hidden, t.floating.style.auto, className),
|
|
99
|
+
}), { children: _jsx(FloatingList, { elementsRef: elementsRef, labelsRef: labelsRef, children: _jsx("ul", { className: t.content, tabIndex: -1, children: children }) }) })) }))] }));
|
|
100
|
+
};
|
|
101
|
+
export const DropdownItem = forwardRef(function DropdownItem(_a, forwardedRef) {
|
|
102
|
+
var { children, className, icon: Icon, onClick, as: Component, href, type = 'button' } = _a, rest = __rest(_a, ["children", "className", "icon", "onClick", "as", "href", "type"]);
|
|
103
|
+
const { activeIndex, dismissOnClick, getItemProps, handleSelect } = useDropdownContext();
|
|
104
|
+
const { ref: listItemRef, index } = useListItem({
|
|
105
|
+
label: typeof children === 'string' ? children : undefined,
|
|
106
|
+
});
|
|
107
|
+
const ref = useMergeRefs([forwardedRef, listItemRef]);
|
|
108
|
+
const isActive = activeIndex === index;
|
|
109
|
+
const Base = Component !== null && Component !== void 0 ? Component : (href ? 'a' : 'button');
|
|
110
|
+
return (_jsx("li", { role: "menuitem", className: t.floating.item.container, children: createElement(Base, Object.assign(Object.assign(Object.assign({ ref,
|
|
111
|
+
href,
|
|
112
|
+
type, className: cn(t.floating.item.base, className) }, rest), getItemProps({
|
|
113
|
+
onClick: () => {
|
|
114
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
115
|
+
if (dismissOnClick)
|
|
116
|
+
handleSelect(null);
|
|
117
|
+
},
|
|
118
|
+
})), { tabIndex: isActive ? 0 : -1 }), Icon && _jsx(Icon, { className: t.floating.item.icon }), children) }));
|
|
119
|
+
});
|
|
120
|
+
export const DropdownHeader = forwardRef(function DropdownHeader(_a, ref) {
|
|
121
|
+
var { className } = _a, rest = __rest(_a, ["className"]);
|
|
122
|
+
useDropdownContext();
|
|
123
|
+
return (_jsx("div", Object.assign({ ref: ref, className: cn(t.floating.header, className) }, rest)));
|
|
124
|
+
});
|
|
125
|
+
export const DropdownDivider = forwardRef(function DropdownDivider(_a, ref) {
|
|
126
|
+
var { className } = _a, rest = __rest(_a, ["className"]);
|
|
127
|
+
useDropdownContext();
|
|
128
|
+
return (_jsx("div", Object.assign({ ref: ref, className: cn(t.floating.divider, className) }, rest)));
|
|
129
|
+
});
|
|
130
|
+
export const Dropdown = Object.assign(DropdownRoot, {
|
|
131
|
+
Item: DropdownItem,
|
|
132
|
+
Header: DropdownHeader,
|
|
133
|
+
Divider: DropdownDivider,
|
|
134
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
import type { DynamicStringEnumKeysOf } from './types';
|
|
3
|
+
declare const t: {
|
|
4
|
+
readonly base: "block w-full cursor-pointer rounded-lg border file:-ms-4 file:me-4 file:cursor-pointer file:border-none file:bg-gray-800 file:py-2.5 file:pe-4 file:ps-8 file:text-sm file:font-medium file:leading-[inherit] file:text-white hover:file:bg-gray-700 focus:outline-none focus:ring-1 dark:file:bg-gray-600 dark:hover:file:bg-gray-500";
|
|
5
|
+
readonly sizes: {
|
|
6
|
+
readonly sm: "text-xs";
|
|
7
|
+
readonly md: "text-sm";
|
|
8
|
+
readonly lg: "text-lg";
|
|
9
|
+
};
|
|
10
|
+
readonly colors: {
|
|
11
|
+
readonly gray: "border-gray-300 bg-gray-50 text-gray-900 focus:border-primary-500 focus:ring-primary-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-400 dark:placeholder-gray-400 dark:focus:border-primary-500 dark:focus:ring-primary-500";
|
|
12
|
+
readonly info: "border-cyan-500 bg-cyan-50 text-cyan-900 placeholder-cyan-700 focus:border-cyan-500 focus:ring-cyan-500 dark:border-cyan-400 dark:bg-cyan-100 dark:focus:border-cyan-500 dark:focus:ring-cyan-500";
|
|
13
|
+
readonly failure: "border-red-500 bg-red-50 text-red-900 placeholder-red-700 focus:border-red-500 focus:ring-red-500 dark:border-red-400 dark:bg-red-100 dark:focus:border-red-500 dark:focus:ring-red-500";
|
|
14
|
+
readonly warning: "border-yellow-500 bg-yellow-50 text-yellow-900 placeholder-yellow-700 focus:border-yellow-500 focus:ring-yellow-500 dark:border-yellow-400 dark:bg-yellow-100 dark:focus:border-yellow-500 dark:focus:ring-yellow-500";
|
|
15
|
+
readonly success: "border-green-500 bg-green-50 text-green-900 placeholder-green-700 focus:border-green-500 focus:ring-green-500 dark:border-green-400 dark:bg-green-100 dark:focus:border-green-500 dark:focus:ring-green-500";
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export interface FileInputProps extends Omit<ComponentPropsWithoutRef<'input'>, 'type' | 'color'> {
|
|
19
|
+
color?: DynamicStringEnumKeysOf<typeof t.colors>;
|
|
20
|
+
sizing?: DynamicStringEnumKeysOf<typeof t.sizes>;
|
|
21
|
+
}
|
|
22
|
+
export declare const FileInput: import("react").ForwardRefExoticComponent<FileInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
23
|
+
export {};
|
package/ui/FileInput.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { forwardRef } from 'react';
|
|
15
|
+
import { cn } from './cn';
|
|
16
|
+
import { themeDefaults } from './theme-defaults';
|
|
17
|
+
const t = themeDefaults.fileInput;
|
|
18
|
+
export const FileInput = forwardRef(function FileInput(_a, ref) {
|
|
19
|
+
var { className, color = 'gray', sizing = 'md' } = _a, rest = __rest(_a, ["className", "color", "sizing"]);
|
|
20
|
+
return (_jsx("input", Object.assign({ ref: ref, type: "file", className: cn(t.base, t.colors[color], t.sizes[sizing], className) }, rest)));
|
|
21
|
+
});
|
package/ui/Floating.d.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { useInteractions, type FloatingContext, type Placement } from '@floating-ui/react';
|
|
2
|
+
import { type ComponentPropsWithoutRef, type ReactNode, type RefObject } from 'react';
|
|
3
|
+
export type FloatingPlacement = 'auto' | Placement;
|
|
4
|
+
export type FloatingTrigger = 'hover' | 'click';
|
|
5
|
+
export type FloatingStyle = 'dark' | 'light' | 'auto';
|
|
6
|
+
/** The theme shape Tooltip and Dropdown's floating layer share. */
|
|
7
|
+
export interface FloatingTheme {
|
|
8
|
+
target: string;
|
|
9
|
+
base: string;
|
|
10
|
+
animation: string;
|
|
11
|
+
hidden: string;
|
|
12
|
+
style: {
|
|
13
|
+
dark: string;
|
|
14
|
+
light: string;
|
|
15
|
+
auto: string;
|
|
16
|
+
};
|
|
17
|
+
content: string;
|
|
18
|
+
arrow: {
|
|
19
|
+
base: string;
|
|
20
|
+
style: {
|
|
21
|
+
dark: string;
|
|
22
|
+
light: string;
|
|
23
|
+
auto: string;
|
|
24
|
+
};
|
|
25
|
+
placement: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export declare function getMiddleware({ arrowRef, placement, }: {
|
|
29
|
+
arrowRef?: RefObject<HTMLDivElement | null>;
|
|
30
|
+
placement: FloatingPlacement;
|
|
31
|
+
}): {
|
|
32
|
+
name: string;
|
|
33
|
+
options?: any;
|
|
34
|
+
fn: (state: import("@floating-ui/dom").MiddlewareState) => import("@floating-ui/dom").MiddlewareReturn | Promise<import("@floating-ui/dom").MiddlewareReturn>;
|
|
35
|
+
}[];
|
|
36
|
+
export declare function useBaseFloating({ open, arrowRef, placement, setOpen, }: {
|
|
37
|
+
open: boolean;
|
|
38
|
+
arrowRef?: RefObject<HTMLDivElement | null>;
|
|
39
|
+
placement?: FloatingPlacement;
|
|
40
|
+
setOpen: (open: boolean) => void;
|
|
41
|
+
}): {
|
|
42
|
+
placement: Placement;
|
|
43
|
+
strategy: import("@floating-ui/utils").Strategy;
|
|
44
|
+
middlewareData: import("@floating-ui/dom").MiddlewareData;
|
|
45
|
+
x: number;
|
|
46
|
+
y: number;
|
|
47
|
+
isPositioned: boolean;
|
|
48
|
+
update: () => void;
|
|
49
|
+
floatingStyles: React.CSSProperties;
|
|
50
|
+
refs: {
|
|
51
|
+
reference: import("react").MutableRefObject<import("@floating-ui/react-dom").ReferenceType>;
|
|
52
|
+
floating: React.MutableRefObject<HTMLElement | null>;
|
|
53
|
+
setReference: (node: import("@floating-ui/react-dom").ReferenceType) => void;
|
|
54
|
+
setFloating: (node: HTMLElement | null) => void;
|
|
55
|
+
} & import("@floating-ui/react").ExtendedRefs<import("@floating-ui/react").ReferenceType>;
|
|
56
|
+
elements: {
|
|
57
|
+
reference: import("@floating-ui/react-dom").ReferenceType;
|
|
58
|
+
floating: HTMLElement | null;
|
|
59
|
+
} & import("@floating-ui/react").ExtendedElements<import("@floating-ui/react").ReferenceType>;
|
|
60
|
+
context: {
|
|
61
|
+
strategy: import("@floating-ui/utils").Strategy;
|
|
62
|
+
x: number;
|
|
63
|
+
y: number;
|
|
64
|
+
placement: Placement;
|
|
65
|
+
middlewareData: import("@floating-ui/dom").MiddlewareData;
|
|
66
|
+
isPositioned: boolean;
|
|
67
|
+
update: () => void;
|
|
68
|
+
floatingStyles: React.CSSProperties;
|
|
69
|
+
open: boolean;
|
|
70
|
+
onOpenChange: (open: boolean, event?: Event, reason?: import("@floating-ui/react").OpenChangeReason) => void;
|
|
71
|
+
events: import("@floating-ui/react").FloatingEvents;
|
|
72
|
+
dataRef: React.MutableRefObject<import("@floating-ui/react").ContextData>;
|
|
73
|
+
nodeId: string | undefined;
|
|
74
|
+
floatingId: string | undefined;
|
|
75
|
+
refs: import("@floating-ui/react").ExtendedRefs<import("@floating-ui/react").ReferenceType>;
|
|
76
|
+
elements: import("@floating-ui/react").ExtendedElements<import("@floating-ui/react").ReferenceType>;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
export declare function useFloatingInteractions({ context, trigger, role, interactions, }: {
|
|
80
|
+
context: FloatingContext;
|
|
81
|
+
trigger: FloatingTrigger;
|
|
82
|
+
role?: 'tooltip' | 'menu';
|
|
83
|
+
interactions?: Parameters<typeof useInteractions>[0];
|
|
84
|
+
}): import("@floating-ui/react").UseInteractionsReturn;
|
|
85
|
+
export declare function getArrowPlacement(placement: Placement): "right" | "bottom" | "left" | "top";
|
|
86
|
+
export interface FloatingProps extends Omit<ComponentPropsWithoutRef<'div'>, 'content' | 'style'> {
|
|
87
|
+
animation?: false | `duration-${number}`;
|
|
88
|
+
arrow?: boolean;
|
|
89
|
+
content: ReactNode;
|
|
90
|
+
placement?: FloatingPlacement;
|
|
91
|
+
style?: FloatingStyle;
|
|
92
|
+
theme: FloatingTheme;
|
|
93
|
+
trigger?: FloatingTrigger;
|
|
94
|
+
minWidth?: number;
|
|
95
|
+
}
|
|
96
|
+
export declare function Floating({ animation, arrow, children, className, content, placement, style, theme, trigger, minWidth, ...props }: FloatingProps): import("react").JSX.Element;
|
package/ui/Floating.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
+
import { arrow, autoPlacement, autoUpdate, flip, offset, safePolygon, shift, useClick, useDismiss, useFloating, useFocus, useHover, useInteractions, useRole, } from '@floating-ui/react';
|
|
15
|
+
import { useEffect, useRef, useState, } from 'react';
|
|
16
|
+
import { cn } from './cn';
|
|
17
|
+
export function getMiddleware({ arrowRef, placement, }) {
|
|
18
|
+
const middleware = [
|
|
19
|
+
offset(8),
|
|
20
|
+
placement === 'auto' ? autoPlacement() : flip(),
|
|
21
|
+
shift({ padding: 8 }),
|
|
22
|
+
];
|
|
23
|
+
if (arrowRef === null || arrowRef === void 0 ? void 0 : arrowRef.current)
|
|
24
|
+
middleware.push(arrow({ element: arrowRef.current }));
|
|
25
|
+
return middleware;
|
|
26
|
+
}
|
|
27
|
+
export function useBaseFloating({ open, arrowRef, placement = 'top', setOpen, }) {
|
|
28
|
+
return useFloating({
|
|
29
|
+
placement: placement === 'auto' ? undefined : placement,
|
|
30
|
+
open,
|
|
31
|
+
onOpenChange: setOpen,
|
|
32
|
+
whileElementsMounted: autoUpdate,
|
|
33
|
+
middleware: getMiddleware({ placement, arrowRef }),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export function useFloatingInteractions({ context, trigger, role = 'tooltip', interactions = [], }) {
|
|
37
|
+
return useInteractions([
|
|
38
|
+
useClick(context, { enabled: trigger === 'click' }),
|
|
39
|
+
useHover(context, {
|
|
40
|
+
enabled: trigger === 'hover',
|
|
41
|
+
handleClose: safePolygon(),
|
|
42
|
+
}),
|
|
43
|
+
useDismiss(context),
|
|
44
|
+
useRole(context, { role }),
|
|
45
|
+
...interactions,
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
const arrowSide = {
|
|
49
|
+
top: 'bottom',
|
|
50
|
+
right: 'left',
|
|
51
|
+
bottom: 'top',
|
|
52
|
+
left: 'right',
|
|
53
|
+
};
|
|
54
|
+
export function getArrowPlacement(placement) {
|
|
55
|
+
return arrowSide[placement.split('-')[0]];
|
|
56
|
+
}
|
|
57
|
+
export function Floating(_a) {
|
|
58
|
+
var { animation = 'duration-300', arrow = true, children, className, content, placement = 'top', style = 'dark', theme, trigger = 'hover', minWidth } = _a, props = __rest(_a, ["animation", "arrow", "children", "className", "content", "placement", "style", "theme", "trigger", "minWidth"]);
|
|
59
|
+
const arrowRef = useRef(null);
|
|
60
|
+
const [open, setOpen] = useState(false);
|
|
61
|
+
const floatingProperties = useBaseFloating({
|
|
62
|
+
open,
|
|
63
|
+
placement,
|
|
64
|
+
arrowRef,
|
|
65
|
+
setOpen,
|
|
66
|
+
});
|
|
67
|
+
const { context, middlewareData: { arrow: { x: arrowX, y: arrowY } = {} }, refs, strategy, update, x, y, } = floatingProperties;
|
|
68
|
+
const focus = useFocus(context);
|
|
69
|
+
const { getFloatingProps, getReferenceProps } = useFloatingInteractions({
|
|
70
|
+
context,
|
|
71
|
+
role: 'tooltip',
|
|
72
|
+
trigger,
|
|
73
|
+
interactions: [focus],
|
|
74
|
+
});
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (refs.reference.current && refs.floating.current && open) {
|
|
77
|
+
return autoUpdate(refs.reference.current, refs.floating.current, update);
|
|
78
|
+
}
|
|
79
|
+
}, [open, refs.floating, refs.reference, update]);
|
|
80
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", Object.assign({ ref: refs.setReference, className: theme.target, "data-testid": "flowbite-tooltip-target" }, getReferenceProps(), { children: children })), _jsxs("div", Object.assign({ ref: refs.setFloating, "data-testid": "flowbite-tooltip" }, getFloatingProps(Object.assign({ className: cn(theme.base, animation && `${theme.animation} ${animation}`, !open && theme.hidden, theme.style[style], className), style: {
|
|
81
|
+
position: strategy,
|
|
82
|
+
top: y !== null && y !== void 0 ? y : ' ',
|
|
83
|
+
left: x !== null && x !== void 0 ? x : ' ',
|
|
84
|
+
minWidth,
|
|
85
|
+
} }, props)), { children: [_jsx("div", { className: theme.content, children: content }), arrow && (_jsx("div", { className: cn(theme.arrow.base, style === 'dark' && theme.arrow.style.dark, style === 'light' && theme.arrow.style.light, style === 'auto' && theme.arrow.style.auto), "data-testid": "flowbite-tooltip-arrow", ref: arrowRef, style: {
|
|
86
|
+
top: arrowY !== null && arrowY !== void 0 ? arrowY : ' ',
|
|
87
|
+
left: arrowX !== null && arrowX !== void 0 ? arrowX : ' ',
|
|
88
|
+
right: ' ',
|
|
89
|
+
bottom: ' ',
|
|
90
|
+
[getArrowPlacement(floatingProperties.placement)]: theme.arrow.placement,
|
|
91
|
+
}, children: "\u00A0" }))] }))] }));
|
|
92
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
import type { DynamicStringEnumKeysOf } from './types';
|
|
3
|
+
declare const t: {
|
|
4
|
+
readonly root: {
|
|
5
|
+
readonly base: "mt-2 text-sm";
|
|
6
|
+
readonly colors: {
|
|
7
|
+
readonly gray: "text-gray-500 dark:text-gray-300";
|
|
8
|
+
readonly info: "text-cyan-700 dark:text-cyan-800";
|
|
9
|
+
readonly success: "text-green-600 dark:text-green-500";
|
|
10
|
+
readonly failure: "text-red-600 dark:text-red-500";
|
|
11
|
+
readonly warning: "text-yellow-500 dark:text-yellow-600";
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export interface HelperTextProps extends Omit<ComponentPropsWithoutRef<'p'>, 'color'> {
|
|
16
|
+
color?: DynamicStringEnumKeysOf<typeof t.root.colors>;
|
|
17
|
+
}
|
|
18
|
+
export declare const HelperText: import("react").ForwardRefExoticComponent<HelperTextProps & import("react").RefAttributes<HTMLParagraphElement>>;
|
|
19
|
+
export {};
|
package/ui/HelperText.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { forwardRef } from 'react';
|
|
15
|
+
import { cn } from './cn';
|
|
16
|
+
import { themeDefaults } from './theme-defaults';
|
|
17
|
+
const t = themeDefaults.helperText;
|
|
18
|
+
export const HelperText = forwardRef(function HelperText(_a, ref) {
|
|
19
|
+
var { className, color = 'gray' } = _a, rest = __rest(_a, ["className", "color"]);
|
|
20
|
+
return (_jsx("p", Object.assign({ ref: ref, className: cn(t.root.base, t.root.colors[color], className) }, rest)));
|
|
21
|
+
});
|
package/ui/Label.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
import type { DynamicStringEnumKeysOf } from './types';
|
|
3
|
+
declare const t: {
|
|
4
|
+
readonly root: {
|
|
5
|
+
readonly base: "text-sm font-medium";
|
|
6
|
+
readonly disabled: "opacity-50";
|
|
7
|
+
readonly colors: {
|
|
8
|
+
readonly default: "text-gray-900 dark:text-white";
|
|
9
|
+
readonly info: "text-primary-500 dark:text-primary-400";
|
|
10
|
+
readonly failure: "text-red-700 dark:text-red-500";
|
|
11
|
+
readonly warning: "text-amber-500 dark:text-amber-400";
|
|
12
|
+
readonly success: "text-green-600 dark:text-green-400";
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export interface LabelProps extends Omit<ComponentPropsWithoutRef<'label'>, 'color'> {
|
|
17
|
+
color?: DynamicStringEnumKeysOf<typeof t.root.colors>;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare const Label: import("react").ForwardRefExoticComponent<LabelProps & import("react").RefAttributes<HTMLLabelElement>>;
|
|
21
|
+
export {};
|
package/ui/Label.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { forwardRef } from 'react';
|
|
15
|
+
import { cn } from './cn';
|
|
16
|
+
import { themeDefaults } from './theme-defaults';
|
|
17
|
+
const t = themeDefaults.label;
|
|
18
|
+
export const Label = forwardRef(function Label(_a, ref) {
|
|
19
|
+
var { className, color = 'default', disabled = false } = _a, rest = __rest(_a, ["className", "color", "disabled"]);
|
|
20
|
+
return (_jsx("label", Object.assign({ ref: ref, className: cn(t.root.base, t.root.colors[color], disabled && t.root.disabled, className), "data-testid": "flowbite-label" }, rest)));
|
|
21
|
+
});
|
package/ui/Modal.d.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef, type ElementType, type MutableRefObject } from 'react';
|
|
2
|
+
import { type DeepPartial } from './merge-theme';
|
|
3
|
+
import type { DynamicStringEnumKeysOf } from './types';
|
|
4
|
+
declare const defaults: {
|
|
5
|
+
readonly root: {
|
|
6
|
+
readonly base: "fixed inset-x-0 top-0 z-50 h-screen overflow-y-auto overflow-x-hidden md:inset-0 md:h-full right-0 left-0";
|
|
7
|
+
readonly show: {
|
|
8
|
+
readonly on: "flex bg-zinc-900/50 backdrop-blur-sm dark:bg-zinc-900/80";
|
|
9
|
+
readonly off: "hidden";
|
|
10
|
+
};
|
|
11
|
+
readonly sizes: {
|
|
12
|
+
readonly sm: "max-w-sm";
|
|
13
|
+
readonly md: "max-w-md";
|
|
14
|
+
readonly lg: "max-w-lg";
|
|
15
|
+
readonly xl: "max-w-xl";
|
|
16
|
+
readonly '2xl': "max-w-2xl";
|
|
17
|
+
readonly '3xl': "max-w-3xl";
|
|
18
|
+
readonly '4xl': "max-w-4xl";
|
|
19
|
+
readonly '5xl': "max-w-5xl";
|
|
20
|
+
readonly '6xl': "max-w-6xl";
|
|
21
|
+
readonly '7xl': "max-w-7xl";
|
|
22
|
+
};
|
|
23
|
+
readonly positions: {
|
|
24
|
+
readonly 'top-left': "items-start justify-start";
|
|
25
|
+
readonly 'top-center': "items-start justify-center";
|
|
26
|
+
readonly 'top-right': "items-start justify-end";
|
|
27
|
+
readonly 'center-left': "items-center justify-start";
|
|
28
|
+
readonly center: "items-center justify-center";
|
|
29
|
+
readonly 'center-right': "items-center justify-end";
|
|
30
|
+
readonly 'bottom-right': "items-end justify-end";
|
|
31
|
+
readonly 'bottom-center': "items-end justify-center";
|
|
32
|
+
readonly 'bottom-left': "items-end justify-start";
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
readonly content: {
|
|
36
|
+
readonly base: "relative h-full w-full p-4 md:h-auto";
|
|
37
|
+
readonly inner: "relative flex flex-col bg-white max-h-[90vh] rounded-2xl shadow-2xl dark:bg-zinc-800";
|
|
38
|
+
};
|
|
39
|
+
readonly body: {
|
|
40
|
+
readonly base: "flex-1 overflow-auto p-6";
|
|
41
|
+
readonly popup: "pt-0";
|
|
42
|
+
};
|
|
43
|
+
readonly header: {
|
|
44
|
+
readonly base: "flex items-start justify-between border-b p-5 rounded-t-2xl dark:border-gray-700";
|
|
45
|
+
readonly popup: "border-b-0 p-2";
|
|
46
|
+
readonly title: "text-xl text-gray-900 dark:text-white font-semibold";
|
|
47
|
+
readonly close: {
|
|
48
|
+
readonly base: "ms-auto inline-flex items-center rounded-lg bg-transparent p-1.5 text-sm text-gray-400 hover:text-gray-900 dark:hover:text-white ml-auto hover:bg-zinc-200 dark:hover:bg-zinc-700";
|
|
49
|
+
readonly icon: "h-5 w-5";
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
readonly footer: {
|
|
53
|
+
readonly base: "flex items-center gap-2 border-gray-200 p-6 space-x-2 rounded-b-2xl dark:border-gray-700";
|
|
54
|
+
readonly popup: "border-t";
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export type ModalTheme = DeepPartial<typeof defaults>;
|
|
58
|
+
export type ModalPosition = DynamicStringEnumKeysOf<typeof defaults.root.positions>;
|
|
59
|
+
export type ModalSize = DynamicStringEnumKeysOf<typeof defaults.root.sizes>;
|
|
60
|
+
export interface ModalProps extends ComponentPropsWithoutRef<'div'> {
|
|
61
|
+
dismissible?: boolean;
|
|
62
|
+
onClose?: () => void;
|
|
63
|
+
popup?: boolean;
|
|
64
|
+
position?: ModalPosition;
|
|
65
|
+
root?: HTMLElement | null;
|
|
66
|
+
show?: boolean;
|
|
67
|
+
size?: ModalSize;
|
|
68
|
+
initialFocus?: number | MutableRefObject<HTMLElement | null>;
|
|
69
|
+
/** Per-call override merged over the defaults (strings merge with cn). */
|
|
70
|
+
theme?: ModalTheme;
|
|
71
|
+
}
|
|
72
|
+
export interface ModalHeaderProps extends ComponentPropsWithoutRef<'div'> {
|
|
73
|
+
as?: ElementType;
|
|
74
|
+
}
|
|
75
|
+
export declare const ModalHeader: import("react").ForwardRefExoticComponent<ModalHeaderProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
76
|
+
export type ModalBodyProps = ComponentPropsWithoutRef<'div'>;
|
|
77
|
+
export declare const ModalBody: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
78
|
+
export type ModalFooterProps = ComponentPropsWithoutRef<'div'>;
|
|
79
|
+
export declare const ModalFooter: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
80
|
+
export declare const Modal: import("react").ForwardRefExoticComponent<ModalProps & import("react").RefAttributes<HTMLDivElement>> & {
|
|
81
|
+
Header: import("react").ForwardRefExoticComponent<ModalHeaderProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
82
|
+
Body: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
83
|
+
Footer: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
84
|
+
};
|
|
85
|
+
export {};
|
package/ui/Modal.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { FloatingFocusManager, FloatingOverlay, FloatingPortal, useClick, useDismiss, useFloating, useInteractions, useMergeRefs, useRole, } from '@floating-ui/react';
|
|
15
|
+
import { createContext, forwardRef, useContext, useId, useLayoutEffect, useState, } from 'react';
|
|
16
|
+
import { cn } from './cn';
|
|
17
|
+
import { OutlineXIcon } from './icons';
|
|
18
|
+
import { mergeTheme } from './merge-theme';
|
|
19
|
+
import { themeDefaults } from './theme-defaults';
|
|
20
|
+
const defaults = themeDefaults.modal;
|
|
21
|
+
const ModalContext = createContext(undefined);
|
|
22
|
+
function useModalContext() {
|
|
23
|
+
const context = useContext(ModalContext);
|
|
24
|
+
if (!context)
|
|
25
|
+
throw new Error('useModalContext should be used within the ModalContext provider!');
|
|
26
|
+
return context;
|
|
27
|
+
}
|
|
28
|
+
const ModalRoot = forwardRef(function Modal(_a, ref) {
|
|
29
|
+
var { children, className, dismissible = false, onClose, popup, position = 'center', root, show, size = '2xl', initialFocus, theme } = _a, rest = __rest(_a, ["children", "className", "dismissible", "onClose", "popup", "position", "root", "show", "size", "initialFocus", "theme"]);
|
|
30
|
+
const t = mergeTheme(defaults, theme);
|
|
31
|
+
const [headerId, setHeaderId] = useState(undefined);
|
|
32
|
+
const { context } = useFloating({
|
|
33
|
+
open: show,
|
|
34
|
+
onOpenChange: () => onClose === null || onClose === void 0 ? void 0 : onClose(),
|
|
35
|
+
});
|
|
36
|
+
const mergedRef = useMergeRefs([context.refs.setFloating, ref]);
|
|
37
|
+
const click = useClick(context);
|
|
38
|
+
const dismiss = useDismiss(context, {
|
|
39
|
+
outsidePressEvent: 'mousedown',
|
|
40
|
+
enabled: dismissible,
|
|
41
|
+
});
|
|
42
|
+
const role = useRole(context);
|
|
43
|
+
const { getFloatingProps } = useInteractions([click, dismiss, role]);
|
|
44
|
+
if (!show)
|
|
45
|
+
return null;
|
|
46
|
+
return (_jsx(ModalContext.Provider, { value: { t, popup, dismissible, onClose, setHeaderId }, children: _jsx(FloatingPortal, { root: root, children: _jsx(FloatingOverlay, Object.assign({ lockScroll: true, "data-testid": "modal-overlay", className: cn(t.root.base, t.root.positions[position], show ? t.root.show.on : t.root.show.off, className) }, rest, { children: _jsx(FloatingFocusManager, { context: context, initialFocus: initialFocus, children: _jsx("div", Object.assign({ ref: mergedRef }, getFloatingProps(rest), { "aria-labelledby": headerId, className: cn(t.content.base, t.root.sizes[size]), children: _jsx("div", { className: t.content.inner, children: children }) })) }) })) }) }));
|
|
47
|
+
});
|
|
48
|
+
export const ModalHeader = forwardRef(function ModalHeader(_a, ref) {
|
|
49
|
+
var { as: Component = 'h3', children, className, id } = _a, rest = __rest(_a, ["as", "children", "className", "id"]);
|
|
50
|
+
const { t, popup, dismissible, onClose, setHeaderId } = useModalContext();
|
|
51
|
+
const innerHeaderId = useId();
|
|
52
|
+
const headerId = id || innerHeaderId;
|
|
53
|
+
useLayoutEffect(() => {
|
|
54
|
+
setHeaderId(headerId);
|
|
55
|
+
return () => setHeaderId(undefined);
|
|
56
|
+
}, [headerId, setHeaderId]);
|
|
57
|
+
return (_jsxs("div", Object.assign({ ref: ref, className: cn(t.header.base, popup && t.header.popup, className) }, rest, { children: [_jsx(Component, { id: headerId, className: t.header.title, children: children }), dismissible && (_jsx("button", { "aria-label": "Close", className: t.header.close.base, type: "button", onClick: onClose, children: _jsx(OutlineXIcon, { "aria-hidden": true, className: t.header.close.icon }) }))] })));
|
|
58
|
+
});
|
|
59
|
+
export const ModalBody = forwardRef(function ModalBody(_a, ref) {
|
|
60
|
+
var { className } = _a, rest = __rest(_a, ["className"]);
|
|
61
|
+
const { t, popup } = useModalContext();
|
|
62
|
+
return (_jsx("div", Object.assign({ ref: ref, className: cn(t.body.base, popup && t.body.popup, className) }, rest)));
|
|
63
|
+
});
|
|
64
|
+
export const ModalFooter = forwardRef(function ModalFooter(_a, ref) {
|
|
65
|
+
var { className } = _a, rest = __rest(_a, ["className"]);
|
|
66
|
+
const { t, popup } = useModalContext();
|
|
67
|
+
return (_jsx("div", Object.assign({ ref: ref, className: cn(t.footer.base, !popup && t.footer.popup, className) }, rest)));
|
|
68
|
+
});
|
|
69
|
+
export const Modal = Object.assign(ModalRoot, {
|
|
70
|
+
Header: ModalHeader,
|
|
71
|
+
Body: ModalBody,
|
|
72
|
+
Footer: ModalFooter,
|
|
73
|
+
});
|
package/ui/Navbar.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef, type ElementType } from 'react';
|
|
2
|
+
export interface NavbarProps extends ComponentPropsWithoutRef<'nav'> {
|
|
3
|
+
border?: boolean;
|
|
4
|
+
fluid?: boolean;
|
|
5
|
+
menuOpen?: boolean;
|
|
6
|
+
rounded?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface NavbarBrandProps extends ComponentPropsWithoutRef<'a'> {
|
|
9
|
+
as?: ElementType;
|
|
10
|
+
}
|
|
11
|
+
export declare const NavbarBrand: import("react").ForwardRefExoticComponent<NavbarBrandProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
12
|
+
export declare const Navbar: import("react").ForwardRefExoticComponent<NavbarProps & import("react").RefAttributes<HTMLElement>> & {
|
|
13
|
+
Brand: import("react").ForwardRefExoticComponent<NavbarBrandProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
14
|
+
};
|