@robosystems/core 0.17.1 → 0.18.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/README.md +4 -3
- 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/index.d.ts +0 -1
- package/index.js +0 -1
- 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/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/theme/flowbite-theme.d.ts +0 -758
- package/theme/flowbite-theme.js +0 -769
- package/theme/index.d.ts +0 -1
- package/theme/index.js +0 -1
package/ui/Spinner.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
import type { DynamicStringEnumKeysOf } from './types';
|
|
3
|
+
declare const t: {
|
|
4
|
+
readonly base: "inline animate-spin text-gray-200 dark:text-gray-600";
|
|
5
|
+
readonly color: {
|
|
6
|
+
readonly default: "fill-primary-600";
|
|
7
|
+
readonly failure: "fill-red-600 dark:fill-red-500";
|
|
8
|
+
readonly gray: "fill-gray-600 dark:fill-gray-500";
|
|
9
|
+
readonly info: "fill-cyan-600 dark:fill-cyan-500";
|
|
10
|
+
readonly pink: "fill-pink-600 dark:fill-pink-500";
|
|
11
|
+
readonly purple: "fill-purple-600 dark:fill-purple-500";
|
|
12
|
+
readonly success: "fill-green-500 dark:fill-green-400";
|
|
13
|
+
readonly warning: "fill-amber-400 dark:fill-amber-300";
|
|
14
|
+
readonly primary: "fill-primary-600 dark:fill-primary-500";
|
|
15
|
+
readonly secondary: "fill-secondary-600 dark:fill-secondary-500";
|
|
16
|
+
readonly accent: "fill-accent-600 dark:fill-accent-500";
|
|
17
|
+
};
|
|
18
|
+
readonly light: {
|
|
19
|
+
readonly off: {
|
|
20
|
+
readonly base: "text-gray-600 dark:text-gray-400";
|
|
21
|
+
readonly color: {
|
|
22
|
+
readonly default: "";
|
|
23
|
+
readonly failure: "";
|
|
24
|
+
readonly gray: "dark:fill-gray-300";
|
|
25
|
+
readonly info: "";
|
|
26
|
+
readonly pink: "";
|
|
27
|
+
readonly purple: "";
|
|
28
|
+
readonly success: "";
|
|
29
|
+
readonly warning: "";
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
readonly on: {
|
|
33
|
+
readonly base: "";
|
|
34
|
+
readonly color: {
|
|
35
|
+
readonly default: "";
|
|
36
|
+
readonly failure: "text-red-600 dark:text-red-500";
|
|
37
|
+
readonly gray: "dark:text-gray-500";
|
|
38
|
+
readonly info: "text-cyan-600 dark:text-cyan-500";
|
|
39
|
+
readonly pink: "text-pink-600 dark:text-pink-500";
|
|
40
|
+
readonly purple: "text-purple-600 dark:text-purple-500";
|
|
41
|
+
readonly success: "text-green-600 dark:text-green-500";
|
|
42
|
+
readonly warning: "text-amber-600 dark:text-amber-500";
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
readonly size: {
|
|
47
|
+
readonly xs: "h-3 w-3";
|
|
48
|
+
readonly sm: "h-4 w-4";
|
|
49
|
+
readonly md: "h-6 w-6";
|
|
50
|
+
readonly lg: "h-8 w-8";
|
|
51
|
+
readonly xl: "h-10 w-10";
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
export interface SpinnerProps extends Omit<ComponentPropsWithoutRef<'span'>, 'color'> {
|
|
55
|
+
color?: DynamicStringEnumKeysOf<typeof t.color>;
|
|
56
|
+
light?: boolean;
|
|
57
|
+
size?: DynamicStringEnumKeysOf<typeof t.size>;
|
|
58
|
+
}
|
|
59
|
+
export declare const Spinner: import("react").ForwardRefExoticComponent<SpinnerProps & import("react").RefAttributes<HTMLSpanElement>>;
|
|
60
|
+
export {};
|
package/ui/Spinner.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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 { forwardRef } from 'react';
|
|
15
|
+
import { cn } from './cn';
|
|
16
|
+
import { themeDefaults } from './theme-defaults';
|
|
17
|
+
const t = themeDefaults.spinner;
|
|
18
|
+
export const Spinner = forwardRef(function Spinner(_a, ref) {
|
|
19
|
+
var { className, color = 'default', light, size = 'lg' } = _a, rest = __rest(_a, ["className", "color", "light", "size"]);
|
|
20
|
+
const mode = light ? 'on' : 'off';
|
|
21
|
+
return (_jsx("span", Object.assign({ ref: ref, role: "status" }, rest, { children: _jsxs("svg", { fill: "none", viewBox: "0 0 100 101", className: cn(t.base, t.color[color], t.light[mode].base, t.light[mode].color[color], t.size[size], className), children: [_jsx("path", { d: "M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z", fill: "currentColor" }), _jsx("path", { d: "M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z", fill: "currentFill" })] }) })));
|
|
22
|
+
});
|
package/ui/Table.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
export interface TableProps extends ComponentPropsWithoutRef<'table'> {
|
|
3
|
+
striped?: boolean;
|
|
4
|
+
hoverable?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export type TableHeadProps = ComponentPropsWithoutRef<'thead'>;
|
|
7
|
+
export declare const TableHead: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "ref"> & import("react").RefAttributes<HTMLTableSectionElement>>;
|
|
8
|
+
export type TableHeadCellProps = ComponentPropsWithoutRef<'th'>;
|
|
9
|
+
export declare const TableHeadCell: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>, "ref"> & import("react").RefAttributes<HTMLTableCellElement>>;
|
|
10
|
+
export type TableBodyProps = ComponentPropsWithoutRef<'tbody'>;
|
|
11
|
+
export declare const TableBody: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "ref"> & import("react").RefAttributes<HTMLTableSectionElement>>;
|
|
12
|
+
export type TableRowProps = ComponentPropsWithoutRef<'tr'>;
|
|
13
|
+
export declare const TableRow: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>, "ref"> & import("react").RefAttributes<HTMLTableRowElement>>;
|
|
14
|
+
export type TableCellProps = ComponentPropsWithoutRef<'td'>;
|
|
15
|
+
export declare const TableCell: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>, "ref"> & import("react").RefAttributes<HTMLTableCellElement>>;
|
|
16
|
+
/** Table with the compound aliases (`Table.Head`, …) a few call sites still use. */
|
|
17
|
+
export declare const Table: import("react").ForwardRefExoticComponent<TableProps & import("react").RefAttributes<HTMLTableElement>> & {
|
|
18
|
+
Head: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "ref"> & import("react").RefAttributes<HTMLTableSectionElement>>;
|
|
19
|
+
HeadCell: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>, "ref"> & import("react").RefAttributes<HTMLTableCellElement>>;
|
|
20
|
+
Body: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "ref"> & import("react").RefAttributes<HTMLTableSectionElement>>;
|
|
21
|
+
Row: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>, "ref"> & import("react").RefAttributes<HTMLTableRowElement>>;
|
|
22
|
+
Cell: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>, "ref"> & import("react").RefAttributes<HTMLTableCellElement>>;
|
|
23
|
+
};
|
package/ui/Table.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
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 { createContext, forwardRef, useContext, } from 'react';
|
|
15
|
+
import { cn } from './cn';
|
|
16
|
+
import { themeDefaults } from './theme-defaults';
|
|
17
|
+
const t = themeDefaults.table;
|
|
18
|
+
const TableContext = createContext(undefined);
|
|
19
|
+
function useTableContext() {
|
|
20
|
+
const context = useContext(TableContext);
|
|
21
|
+
if (!context)
|
|
22
|
+
throw new Error('useTableContext should be used within the TableContext provider!');
|
|
23
|
+
return context;
|
|
24
|
+
}
|
|
25
|
+
const TableRoot = forwardRef(function Table(_a, ref) {
|
|
26
|
+
var { className, striped, hoverable } = _a, rest = __rest(_a, ["className", "striped", "hoverable"]);
|
|
27
|
+
return (_jsx("div", { "data-testid": "table-element", className: cn(t.root.wrapper), children: _jsxs(TableContext.Provider, { value: { striped, hoverable }, children: [_jsx("div", { className: cn(t.root.shadow, className) }), _jsx("table", Object.assign({ ref: ref, className: cn(t.root.base, className) }, rest))] }) }));
|
|
28
|
+
});
|
|
29
|
+
export const TableHead = forwardRef(function TableHead(_a, ref) {
|
|
30
|
+
var { className } = _a, rest = __rest(_a, ["className"]);
|
|
31
|
+
return _jsx("thead", Object.assign({ ref: ref, className: cn(t.head.base, className) }, rest));
|
|
32
|
+
});
|
|
33
|
+
export const TableHeadCell = forwardRef(function TableHeadCell(_a, ref) {
|
|
34
|
+
var { className } = _a, rest = __rest(_a, ["className"]);
|
|
35
|
+
return _jsx("th", Object.assign({ ref: ref, className: cn(t.head.cell.base, className) }, rest));
|
|
36
|
+
});
|
|
37
|
+
export const TableBody = forwardRef(function TableBody(_a, ref) {
|
|
38
|
+
var { className } = _a, rest = __rest(_a, ["className"]);
|
|
39
|
+
return _jsx("tbody", Object.assign({ ref: ref, className: cn(t.body.base, className) }, rest));
|
|
40
|
+
});
|
|
41
|
+
export const TableRow = forwardRef(function TableRow(_a, ref) {
|
|
42
|
+
var { className } = _a, rest = __rest(_a, ["className"]);
|
|
43
|
+
const { hoverable, striped } = useTableContext();
|
|
44
|
+
return (_jsx("tr", Object.assign({ ref: ref, "data-testid": "table-row-element", className: cn(t.row.base, striped && t.row.striped, hoverable && t.row.hovered, className) }, rest)));
|
|
45
|
+
});
|
|
46
|
+
export const TableCell = forwardRef(function TableCell(_a, ref) {
|
|
47
|
+
var { className } = _a, rest = __rest(_a, ["className"]);
|
|
48
|
+
return (_jsx("td", Object.assign({ ref: ref, className: cn(t.body.cell.base, className) }, rest)));
|
|
49
|
+
});
|
|
50
|
+
/** Table with the compound aliases (`Table.Head`, …) a few call sites still use. */
|
|
51
|
+
export const Table = Object.assign(TableRoot, {
|
|
52
|
+
Head: TableHead,
|
|
53
|
+
HeadCell: TableHeadCell,
|
|
54
|
+
Body: TableBody,
|
|
55
|
+
Row: TableRow,
|
|
56
|
+
Cell: TableCell,
|
|
57
|
+
});
|
package/ui/Tabs.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef, type FC, type ReactNode } from 'react';
|
|
2
|
+
import type { DynamicStringEnumKeysOf } from './types';
|
|
3
|
+
declare const t: {
|
|
4
|
+
readonly base: "flex flex-col gap-2";
|
|
5
|
+
readonly tablist: {
|
|
6
|
+
readonly base: "flex text-center";
|
|
7
|
+
readonly variant: {
|
|
8
|
+
readonly default: "flex-wrap border-b border-gray-200 dark:border-gray-700";
|
|
9
|
+
readonly underline: "-mb-px flex-wrap border-b border-gray-200 dark:border-gray-700";
|
|
10
|
+
readonly pills: "flex-wrap space-x-2 text-sm font-medium text-gray-500 dark:text-gray-400";
|
|
11
|
+
readonly fullWidth: "grid w-full grid-flow-col divide-x divide-gray-200 rounded-none text-sm font-medium dark:divide-gray-700 dark:text-gray-400 shadow";
|
|
12
|
+
};
|
|
13
|
+
readonly tabitem: {
|
|
14
|
+
readonly base: "flex items-center justify-center rounded-t-lg p-4 text-sm font-medium first:ml-0 focus:outline-none disabled:cursor-not-allowed disabled:text-gray-400 disabled:dark:text-gray-500 focus:ring-primary-300 mx-1 px-4 py-3 focus:ring-4";
|
|
15
|
+
readonly variant: {
|
|
16
|
+
readonly default: {
|
|
17
|
+
readonly base: "rounded-t-lg";
|
|
18
|
+
readonly active: {
|
|
19
|
+
readonly on: "text-primary-600 dark:text-primary-400 bg-white dark:bg-zinc-800";
|
|
20
|
+
readonly off: "text-gray-500 hover:text-gray-600 dark:text-gray-400 dark:hover:text-gray-300 hover:bg-zinc-50 dark:hover:bg-zinc-700";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
readonly underline: {
|
|
24
|
+
readonly base: "rounded-t-lg";
|
|
25
|
+
readonly active: {
|
|
26
|
+
readonly on: "rounded-t-lg border-b-2 border-primary-600 text-primary-600 active dark:border-primary-400 dark:text-primary-400";
|
|
27
|
+
readonly off: "border-b-2 border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-600 dark:text-gray-400 dark:hover:text-gray-300";
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
readonly pills: {
|
|
31
|
+
readonly base: "";
|
|
32
|
+
readonly active: {
|
|
33
|
+
readonly on: "rounded-lg bg-primary-600 text-white";
|
|
34
|
+
readonly off: "rounded-lg hover:text-gray-900 dark:hover:text-white hover:bg-zinc-100 dark:hover:bg-zinc-700";
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
readonly fullWidth: {
|
|
38
|
+
readonly base: "ml-0 flex w-full rounded-none first:ml-0";
|
|
39
|
+
readonly active: {
|
|
40
|
+
readonly on: "rounded-none p-4 text-gray-900 dark:text-white active bg-white dark:bg-zinc-700";
|
|
41
|
+
readonly off: "rounded-none bg-white hover:text-gray-700 dark:hover:text-white hover:bg-zinc-50 dark:bg-zinc-800 dark:hover:bg-zinc-700";
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
readonly icon: "mr-2 h-5 w-5";
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
readonly tabitemcontainer: {
|
|
49
|
+
readonly base: "";
|
|
50
|
+
readonly variant: {
|
|
51
|
+
readonly default: "";
|
|
52
|
+
readonly underline: "";
|
|
53
|
+
readonly pills: "";
|
|
54
|
+
readonly fullWidth: "";
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
readonly tabpanel: "py-3";
|
|
58
|
+
};
|
|
59
|
+
export interface TabItemProps extends Omit<ComponentPropsWithoutRef<'div'>, 'title'> {
|
|
60
|
+
active?: boolean;
|
|
61
|
+
disabled?: boolean;
|
|
62
|
+
icon?: FC<ComponentPropsWithoutRef<'svg'>>;
|
|
63
|
+
title: ReactNode;
|
|
64
|
+
}
|
|
65
|
+
/** The tab definition; Tabs reads its props and renders the panel itself. */
|
|
66
|
+
export declare const TabItem: import("react").ForwardRefExoticComponent<TabItemProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
67
|
+
export interface TabsRef {
|
|
68
|
+
setActiveTab: (activeTab: number) => void;
|
|
69
|
+
}
|
|
70
|
+
export interface TabsProps extends Omit<ComponentPropsWithoutRef<'div'>, 'ref'> {
|
|
71
|
+
onActiveTabChange?: (activeTab: number) => void;
|
|
72
|
+
variant?: DynamicStringEnumKeysOf<typeof t.tablist.variant>;
|
|
73
|
+
}
|
|
74
|
+
/** Tabs with the `Tabs.Item` alias the apps use. */
|
|
75
|
+
export declare const Tabs: import("react").ForwardRefExoticComponent<TabsProps & import("react").RefAttributes<TabsRef>> & {
|
|
76
|
+
Item: import("react").ForwardRefExoticComponent<TabItemProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
77
|
+
};
|
|
78
|
+
export {};
|
package/ui/Tabs.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
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 { Children, forwardRef, useEffect, useId, useImperativeHandle, useMemo, useRef, useState, } from 'react';
|
|
15
|
+
import { cn } from './cn';
|
|
16
|
+
import { themeDefaults } from './theme-defaults';
|
|
17
|
+
const t = themeDefaults.tabs;
|
|
18
|
+
/** The tab definition; Tabs reads its props and renders the panel itself. */
|
|
19
|
+
export const TabItem = forwardRef(function TabItem(_a, ref) {
|
|
20
|
+
var { title: _title } = _a, rest = __rest(_a, ["title"]);
|
|
21
|
+
return _jsx("div", Object.assign({ ref: ref }, rest));
|
|
22
|
+
});
|
|
23
|
+
const TabsRoot = forwardRef(function Tabs(_a, ref) {
|
|
24
|
+
var { children, className, onActiveTabChange, variant = 'default' } = _a, rest = __rest(_a, ["children", "className", "onActiveTabChange", "variant"]);
|
|
25
|
+
const id = useId();
|
|
26
|
+
const tabs = useMemo(() => {
|
|
27
|
+
var _a;
|
|
28
|
+
return (_a = Children.map(Children.toArray(children), ({ props }) => props)) !== null && _a !== void 0 ? _a : [];
|
|
29
|
+
}, [children]);
|
|
30
|
+
const tabRefs = useRef([]);
|
|
31
|
+
const [activeTab, setActiveTab] = useState(Math.max(0, tabs.findIndex((tab) => tab.active)));
|
|
32
|
+
const [focusedTab, setFocusedTab] = useState(-1);
|
|
33
|
+
function setActiveTabWithCallback(next) {
|
|
34
|
+
setActiveTab(next);
|
|
35
|
+
onActiveTabChange === null || onActiveTabChange === void 0 ? void 0 : onActiveTabChange(next);
|
|
36
|
+
}
|
|
37
|
+
function handleClick(target) {
|
|
38
|
+
setActiveTabWithCallback(target);
|
|
39
|
+
setFocusedTab(target);
|
|
40
|
+
}
|
|
41
|
+
function handleKeyboard(event, target) {
|
|
42
|
+
if (event.key === 'ArrowLeft')
|
|
43
|
+
setFocusedTab(Math.max(0, focusedTab - 1));
|
|
44
|
+
if (event.key === 'ArrowRight')
|
|
45
|
+
setFocusedTab(Math.min(tabs.length - 1, focusedTab + 1));
|
|
46
|
+
if (event.key === 'Enter') {
|
|
47
|
+
setActiveTabWithCallback(target);
|
|
48
|
+
setFocusedTab(target);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const v = variant;
|
|
52
|
+
const tabItemStyle = t.tablist.tabitem.variant[v];
|
|
53
|
+
const tabItemContainerStyle = t.tabitemcontainer.variant[v];
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
var _a;
|
|
56
|
+
(_a = tabRefs.current[focusedTab]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
57
|
+
}, [focusedTab]);
|
|
58
|
+
useImperativeHandle(ref, () => ({ setActiveTab: setActiveTabWithCallback }));
|
|
59
|
+
return (_jsxs("div", { className: cn(t.base, className), children: [_jsx("div", Object.assign({ "aria-label": "Tabs", role: "tablist", className: cn(t.tablist.base, t.tablist.variant[v], className) }, rest, { children: tabs.map((tab, index) => (_jsxs("button", { type: "button", "aria-controls": `${id}-tabpanel-${index}`, "aria-selected": index === activeTab, className: cn(t.tablist.tabitem.base, tabItemStyle.base, index === activeTab && tabItemStyle.active.on, index !== activeTab && !tab.disabled && tabItemStyle.active.off), disabled: tab.disabled, id: `${id}-tab-${index}`, onClick: () => handleClick(index), onKeyDown: (event) => handleKeyboard(event, index), ref: (element) => {
|
|
60
|
+
tabRefs.current[index] = element;
|
|
61
|
+
}, role: "tab", tabIndex: index === focusedTab ? 0 : -1, style: { zIndex: index === focusedTab ? 2 : 1 }, children: [tab.icon && _jsx(tab.icon, { className: t.tablist.tabitem.icon }), tab.title] }, index))) })), _jsx("div", { className: cn(t.tabitemcontainer.base, tabItemContainerStyle), children: tabs.map((tab, index) => (_jsx("div", { "aria-labelledby": `${id}-tab-${index}`, className: t.tabpanel, hidden: index !== activeTab, id: `${id}-tabpanel-${index}`, role: "tabpanel", tabIndex: 0, children: tab.children }, index))) })] }));
|
|
62
|
+
});
|
|
63
|
+
/** Tabs with the `Tabs.Item` alias the apps use. */
|
|
64
|
+
export const Tabs = Object.assign(TabsRoot, { Item: TabItem });
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef, type FC, type ReactNode } from 'react';
|
|
2
|
+
import type { DynamicStringEnumKeysOf } from './types';
|
|
3
|
+
declare const t: {
|
|
4
|
+
readonly base: "flex";
|
|
5
|
+
readonly addon: "inline-flex items-center rounded-l-md border border-r-0 border-gray-300 px-3 text-sm dark:border-gray-600 dark:text-gray-400 bg-zinc-50 text-gray-500 dark:bg-zinc-700";
|
|
6
|
+
readonly field: {
|
|
7
|
+
readonly base: "relative w-full";
|
|
8
|
+
readonly icon: {
|
|
9
|
+
readonly base: "pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3";
|
|
10
|
+
readonly svg: "h-5 w-5 text-gray-500 dark:text-gray-400";
|
|
11
|
+
};
|
|
12
|
+
readonly rightIcon: {
|
|
13
|
+
readonly base: "pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3";
|
|
14
|
+
readonly svg: "h-5 w-5 text-gray-500 dark:text-gray-400";
|
|
15
|
+
};
|
|
16
|
+
readonly input: {
|
|
17
|
+
readonly base: "block w-full border focus:outline-none focus:ring-1 disabled:cursor-not-allowed disabled:opacity-50 outline-hidden";
|
|
18
|
+
readonly sizes: {
|
|
19
|
+
readonly sm: "p-2 sm:text-xs";
|
|
20
|
+
readonly md: "p-2.5 text-sm sm:text-sm";
|
|
21
|
+
readonly lg: "p-4 sm:text-base";
|
|
22
|
+
};
|
|
23
|
+
readonly colors: {
|
|
24
|
+
readonly gray: "border-gray-300 text-gray-900 placeholder-gray-500 focus:border-primary-500 focus:ring-primary-500 dark:border-gray-600 dark:text-white dark:placeholder-gray-400 dark:focus:border-primary-500 dark:focus:ring-primary-500 bg-zinc-50 dark:bg-zinc-700";
|
|
25
|
+
readonly info: "border-primary-500 bg-primary-50 text-primary-900 placeholder-primary-700 focus:border-primary-500 focus:ring-primary-500 dark:border-primary-400 dark:bg-primary-100 dark:focus:border-primary-500 dark:focus:ring-primary-500";
|
|
26
|
+
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";
|
|
27
|
+
readonly warning: "border-amber-500 bg-amber-50 text-amber-900 placeholder-amber-700 focus:border-amber-500 focus:ring-amber-500 dark:border-amber-400 dark:bg-amber-100 dark:focus:border-amber-500 dark:focus:ring-amber-500";
|
|
28
|
+
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";
|
|
29
|
+
};
|
|
30
|
+
readonly withRightIcon: {
|
|
31
|
+
readonly on: "pr-10";
|
|
32
|
+
readonly off: "";
|
|
33
|
+
};
|
|
34
|
+
readonly withIcon: {
|
|
35
|
+
readonly on: "pl-10";
|
|
36
|
+
readonly off: "";
|
|
37
|
+
};
|
|
38
|
+
readonly withAddon: {
|
|
39
|
+
readonly on: "rounded-r-lg";
|
|
40
|
+
readonly off: "rounded-lg";
|
|
41
|
+
};
|
|
42
|
+
readonly withShadow: {
|
|
43
|
+
readonly on: "shadow-xs dark:shadow-sm-light";
|
|
44
|
+
readonly off: "";
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export interface TextInputProps extends Omit<ComponentPropsWithoutRef<'input'>, 'color'> {
|
|
50
|
+
addon?: ReactNode;
|
|
51
|
+
color?: DynamicStringEnumKeysOf<typeof t.field.input.colors>;
|
|
52
|
+
icon?: FC<ComponentPropsWithoutRef<'svg'>>;
|
|
53
|
+
rightIcon?: FC<ComponentPropsWithoutRef<'svg'>>;
|
|
54
|
+
shadow?: boolean;
|
|
55
|
+
sizing?: DynamicStringEnumKeysOf<typeof t.field.input.sizes>;
|
|
56
|
+
}
|
|
57
|
+
export declare const TextInput: import("react").ForwardRefExoticComponent<TextInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
58
|
+
export {};
|
package/ui/TextInput.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, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { forwardRef, } from 'react';
|
|
15
|
+
import { cn } from './cn';
|
|
16
|
+
import { themeDefaults } from './theme-defaults';
|
|
17
|
+
const t = themeDefaults.textInput;
|
|
18
|
+
export const TextInput = forwardRef(function TextInput(_a, ref) {
|
|
19
|
+
var { addon, className, color = 'gray', icon: Icon, rightIcon: RightIcon, shadow, sizing = 'md', type = 'text' } = _a, rest = __rest(_a, ["addon", "className", "color", "icon", "rightIcon", "shadow", "sizing", "type"]);
|
|
20
|
+
return (_jsxs("div", { className: cn(t.base, className), children: [addon && _jsx("span", { className: t.addon, children: addon }), _jsxs("div", { className: t.field.base, children: [Icon && (_jsx("div", { className: t.field.icon.base, children: _jsx(Icon, { className: t.field.icon.svg }) })), RightIcon && (_jsx("div", { "data-testid": "right-icon", className: t.field.rightIcon.base, children: _jsx(RightIcon, { className: t.field.rightIcon.svg }) })), _jsx("input", Object.assign({ className: cn(t.field.input.base, t.field.input.colors[color], t.field.input.sizes[sizing], t.field.input.withIcon[Icon ? 'on' : 'off'], t.field.input.withRightIcon[RightIcon ? 'on' : 'off'], t.field.input.withAddon[addon ? 'on' : 'off'], t.field.input.withShadow[shadow ? 'on' : 'off']), type: type }, rest, { ref: ref }))] })] }));
|
|
21
|
+
});
|
package/ui/Textarea.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
import type { DynamicStringEnumKeysOf } from './types';
|
|
3
|
+
declare const t: {
|
|
4
|
+
readonly base: "block w-full rounded-lg border text-sm focus:outline-none focus:ring-1 disabled:cursor-not-allowed disabled:opacity-50 p-4";
|
|
5
|
+
readonly colors: {
|
|
6
|
+
readonly gray: "border-gray-300 bg-gray-50 text-gray-900 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-400 focus:border-secondary-500 focus:ring-secondary-500 dark:focus:border-secondary-500 dark:focus:ring-secondary-500 text-base sm:text-sm";
|
|
7
|
+
readonly info: "border-primary-500 bg-primary-50 text-primary-900 placeholder-primary-700 focus:border-primary-500 focus:ring-primary-500 dark:border-primary-400 dark:bg-primary-100 dark:focus:border-primary-500 dark:focus:ring-primary-500";
|
|
8
|
+
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";
|
|
9
|
+
readonly warning: "border-amber-500 bg-amber-50 text-amber-900 placeholder-amber-700 focus:border-amber-500 focus:ring-amber-500 dark:border-amber-400 dark:bg-amber-100 dark:focus:border-amber-500 dark:focus:ring-amber-500";
|
|
10
|
+
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";
|
|
11
|
+
};
|
|
12
|
+
readonly withShadow: {
|
|
13
|
+
readonly on: "shadow-xs dark:shadow-sm-light";
|
|
14
|
+
readonly off: "";
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export interface TextareaProps extends Omit<ComponentPropsWithoutRef<'textarea'>, 'color'> {
|
|
18
|
+
color?: DynamicStringEnumKeysOf<typeof t.colors>;
|
|
19
|
+
shadow?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare const Textarea: import("react").ForwardRefExoticComponent<TextareaProps & import("react").RefAttributes<HTMLTextAreaElement>>;
|
|
22
|
+
export {};
|
package/ui/Textarea.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.textarea;
|
|
18
|
+
export const Textarea = forwardRef(function Textarea(_a, ref) {
|
|
19
|
+
var { className, color = 'gray', shadow } = _a, rest = __rest(_a, ["className", "color", "shadow"]);
|
|
20
|
+
return (_jsx("textarea", Object.assign({ ref: ref, className: cn(t.base, t.colors[color], t.withShadow[shadow ? 'on' : 'off'], className) }, rest)));
|
|
21
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
export type ThemeMode = 'light' | 'dark' | 'auto';
|
|
3
|
+
/** The storage key flowbite-react used; kept so no user's choice resets on upgrade. */
|
|
4
|
+
export declare const THEME_MODE_STORAGE_KEY = "flowbite-theme-mode";
|
|
5
|
+
export declare const DEFAULT_THEME_MODE: ThemeMode;
|
|
6
|
+
export interface ThemeModeScriptProps extends ComponentPropsWithoutRef<'script'> {
|
|
7
|
+
/** Force a mode regardless of storage. */
|
|
8
|
+
mode?: ThemeMode;
|
|
9
|
+
/** Mode when storage holds nothing valid (default `auto`). */
|
|
10
|
+
defaultMode?: ThemeMode;
|
|
11
|
+
localStorageKey?: string;
|
|
12
|
+
/** CSP nonce, when the app serves one. */
|
|
13
|
+
nonce?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Applies the stored (or system) color scheme before first paint by toggling
|
|
17
|
+
* `dark` on the root element, and keeps it in sync with the system preference
|
|
18
|
+
* and with other tabs. Render it in `<head>`; no client JS is needed for it.
|
|
19
|
+
*/
|
|
20
|
+
export declare function ThemeModeScript({ mode, defaultMode, localStorageKey, ...others }: ThemeModeScriptProps): import("react").JSX.Element;
|
|
21
|
+
export declare function getThemeModeScript({ mode, defaultMode, localStorageKey, }?: Pick<ThemeModeScriptProps, 'mode' | 'defaultMode' | 'localStorageKey'>): string;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
/** The storage key flowbite-react used; kept so no user's choice resets on upgrade. */
|
|
14
|
+
export const THEME_MODE_STORAGE_KEY = 'flowbite-theme-mode';
|
|
15
|
+
export const DEFAULT_THEME_MODE = 'auto';
|
|
16
|
+
/**
|
|
17
|
+
* Applies the stored (or system) color scheme before first paint by toggling
|
|
18
|
+
* `dark` on the root element, and keeps it in sync with the system preference
|
|
19
|
+
* and with other tabs. Render it in `<head>`; no client JS is needed for it.
|
|
20
|
+
*/
|
|
21
|
+
export function ThemeModeScript(_a) {
|
|
22
|
+
var { mode, defaultMode = DEFAULT_THEME_MODE, localStorageKey = THEME_MODE_STORAGE_KEY } = _a, others = __rest(_a, ["mode", "defaultMode", "localStorageKey"]);
|
|
23
|
+
return (_jsx("script", Object.assign({}, others, { "data-theme-mode-script": true, dangerouslySetInnerHTML: {
|
|
24
|
+
__html: getThemeModeScript({ mode, defaultMode, localStorageKey }),
|
|
25
|
+
} })));
|
|
26
|
+
}
|
|
27
|
+
export function getThemeModeScript({ mode, defaultMode = DEFAULT_THEME_MODE, localStorageKey = THEME_MODE_STORAGE_KEY, } = {}) {
|
|
28
|
+
return `
|
|
29
|
+
try {
|
|
30
|
+
const storageMode = window.localStorage.getItem("${localStorageKey}");
|
|
31
|
+
const isStorageModeValid = storageMode === "light" || storageMode === "dark" || storageMode === "auto";
|
|
32
|
+
const resolvedMode = (isStorageModeValid ? storageMode : null) ?? ${mode ? `"${mode}"` : undefined} ?? "${defaultMode}";
|
|
33
|
+
const computedMode =
|
|
34
|
+
resolvedMode === "auto" ? (window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light") : resolvedMode;
|
|
35
|
+
const className = "dark";
|
|
36
|
+
|
|
37
|
+
if (computedMode === "dark") {
|
|
38
|
+
document.documentElement.classList.add(className);
|
|
39
|
+
} else {
|
|
40
|
+
document.documentElement.classList.remove(className);
|
|
41
|
+
}
|
|
42
|
+
localStorage.setItem("${localStorageKey}", resolvedMode);
|
|
43
|
+
|
|
44
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
45
|
+
mediaQuery.addEventListener("change", (e) => {
|
|
46
|
+
const storageMode = window.localStorage.getItem("${localStorageKey}");
|
|
47
|
+
const isStorageModeValid = storageMode === "light" || storageMode === "dark" || storageMode === "auto";
|
|
48
|
+
const resolvedMode = isStorageModeValid ? storageMode : "${defaultMode}";
|
|
49
|
+
|
|
50
|
+
if (resolvedMode === "auto") {
|
|
51
|
+
if (e.matches) {
|
|
52
|
+
document.documentElement.classList.add(className);
|
|
53
|
+
} else {
|
|
54
|
+
document.documentElement.classList.remove(className);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
window.addEventListener("storage", (e) => {
|
|
60
|
+
if (e.key === "${localStorageKey}") {
|
|
61
|
+
const newMode = e.newValue;
|
|
62
|
+
const isStorageModeValid = newMode === "light" || newMode === "dark" || newMode === "auto";
|
|
63
|
+
const resolvedMode = isStorageModeValid ? newMode : "${defaultMode}";
|
|
64
|
+
|
|
65
|
+
if (resolvedMode === "dark" || (resolvedMode === "auto" && window.matchMedia("(prefers-color-scheme: dark)").matches)) {
|
|
66
|
+
document.documentElement.classList.add(className);
|
|
67
|
+
} else {
|
|
68
|
+
document.documentElement.classList.remove(className);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
} catch (e) {}
|
|
73
|
+
`;
|
|
74
|
+
}
|
package/ui/Toast.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef, type FC } from 'react';
|
|
2
|
+
declare const durationClasses: {
|
|
3
|
+
readonly 75: "duration-75";
|
|
4
|
+
readonly 100: "duration-100";
|
|
5
|
+
readonly 150: "duration-150";
|
|
6
|
+
readonly 200: "duration-200";
|
|
7
|
+
readonly 300: "duration-300";
|
|
8
|
+
readonly 500: "duration-500";
|
|
9
|
+
readonly 700: "duration-700";
|
|
10
|
+
readonly 1000: "duration-1000";
|
|
11
|
+
};
|
|
12
|
+
export type ToastDuration = keyof typeof durationClasses;
|
|
13
|
+
export interface ToastProps extends ComponentPropsWithoutRef<'div'> {
|
|
14
|
+
duration?: ToastDuration;
|
|
15
|
+
}
|
|
16
|
+
export interface ToastToggleProps extends ComponentPropsWithoutRef<'button'> {
|
|
17
|
+
onDismiss?: () => void;
|
|
18
|
+
xIcon?: FC<ComponentPropsWithoutRef<'svg'>>;
|
|
19
|
+
}
|
|
20
|
+
export declare const ToastToggle: import("react").ForwardRefExoticComponent<ToastToggleProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
21
|
+
export declare const Toast: import("react").ForwardRefExoticComponent<ToastProps & import("react").RefAttributes<HTMLDivElement>> & {
|
|
22
|
+
Toggle: import("react").ForwardRefExoticComponent<ToastToggleProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
23
|
+
};
|
|
24
|
+
export {};
|
package/ui/Toast.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
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 { createContext, forwardRef, useContext, useState, } from 'react';
|
|
15
|
+
import { cn } from './cn';
|
|
16
|
+
import { XIcon } from './icons';
|
|
17
|
+
import { themeDefaults } from './theme-defaults';
|
|
18
|
+
const t = themeDefaults.toast;
|
|
19
|
+
const durationClasses = {
|
|
20
|
+
75: 'duration-75',
|
|
21
|
+
100: 'duration-100',
|
|
22
|
+
150: 'duration-150',
|
|
23
|
+
200: 'duration-200',
|
|
24
|
+
300: 'duration-300',
|
|
25
|
+
500: 'duration-500',
|
|
26
|
+
700: 'duration-700',
|
|
27
|
+
1000: 'duration-1000',
|
|
28
|
+
};
|
|
29
|
+
const ToastContext = createContext(undefined);
|
|
30
|
+
function useToastContext() {
|
|
31
|
+
const context = useContext(ToastContext);
|
|
32
|
+
if (!context)
|
|
33
|
+
throw new Error('useToastContext should be used within the ToastContext provider!');
|
|
34
|
+
return context;
|
|
35
|
+
}
|
|
36
|
+
const ToastRoot = forwardRef(function Toast(_a, ref) {
|
|
37
|
+
var { className, duration = 300 } = _a, rest = __rest(_a, ["className", "duration"]);
|
|
38
|
+
const [isClosed, setIsClosed] = useState(false);
|
|
39
|
+
const [isRemoved, setIsRemoved] = useState(false);
|
|
40
|
+
if (isRemoved)
|
|
41
|
+
return null;
|
|
42
|
+
return (_jsx(ToastContext.Provider, { value: { duration, isClosed, isRemoved, setIsClosed, setIsRemoved }, children: _jsx("div", Object.assign({ ref: ref, "data-testid": "flowbite-toast", role: "alert", className: cn(t.root.base, durationClasses[duration], isClosed && t.root.closed, className) }, rest)) }));
|
|
43
|
+
});
|
|
44
|
+
export const ToastToggle = forwardRef(function ToastToggle(_a, ref) {
|
|
45
|
+
var { className, onClick, onDismiss, xIcon: Icon = XIcon } = _a, rest = __rest(_a, ["className", "onClick", "onDismiss", "xIcon"]);
|
|
46
|
+
const { duration, isClosed, isRemoved, setIsClosed, setIsRemoved } = useToastContext();
|
|
47
|
+
function handleClick(e) {
|
|
48
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
49
|
+
if (onDismiss) {
|
|
50
|
+
onDismiss();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
setIsClosed(!isClosed);
|
|
54
|
+
setTimeout(() => setIsRemoved(!isRemoved), duration);
|
|
55
|
+
}
|
|
56
|
+
return (_jsx("button", Object.assign({ ref: ref, "aria-label": "Close", onClick: handleClick, type: "button", className: cn(t.toggle.base, className) }, rest, { children: _jsx(Icon, { "aria-hidden": true, className: t.toggle.icon }) })));
|
|
57
|
+
});
|
|
58
|
+
export const Toast = Object.assign(ToastRoot, { Toggle: ToastToggle });
|