@sqrzro/ui 4.0.0-alpha.2 → 4.0.0-alpha.21
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/dist/components/buttons/ActionButton/index.d.ts +6 -6
- package/dist/components/buttons/ActionButton/index.js +3 -27
- package/dist/components/buttons/Button/index.d.ts +5 -5
- package/dist/components/buttons/Button/index.js +6 -16
- package/dist/components/collections/Collection/index.d.ts +9 -3
- package/dist/components/collections/Collection/index.js +4 -4
- package/dist/components/collections/DataTable/index.d.ts +14 -0
- package/dist/components/collections/DataTable/index.js +9 -0
- package/dist/components/collections/EmptyMessage/index.d.ts +1 -1
- package/dist/components/collections/EmptyMessage/index.js +3 -4
- package/dist/components/collections/EmptyMessageAction/index.d.ts +2 -2
- package/dist/components/collections/EmptyMessageAction/index.js +1 -1
- package/dist/components/collections/List/index.d.ts +5 -3
- package/dist/components/collections/List/index.js +8 -2
- package/dist/components/collections/ListItem/index.d.ts +2 -2
- package/dist/components/collections/ListItem/index.js +6 -10
- package/dist/components/collections/ListItemMenu/index.d.ts +7 -0
- package/dist/components/collections/ListItemMenu/index.js +7 -0
- package/dist/components/collections/ListItemMeta/index.d.ts +6 -4
- package/dist/components/collections/ListItemMeta/index.js +12 -7
- package/dist/components/collections/ListItemSecondary/index.d.ts +1 -1
- package/dist/components/collections/ListItemSecondary/index.js +3 -4
- package/dist/components/collections/Pagination/index.d.ts +1 -1
- package/dist/components/collections/Pagination/index.js +5 -6
- package/dist/components/collections/PaginationLink/index.d.ts +9 -0
- package/dist/components/collections/PaginationLink/index.js +8 -0
- package/dist/components/collections/Table/index.d.ts +3 -3
- package/dist/components/collections/Table/index.js +1 -1
- package/dist/components/collections/TableClientComponent/index.d.ts +4 -4
- package/dist/components/collections/TableClientComponent/index.js +5 -10
- package/dist/components/collections/TableRow/index.d.ts +13 -0
- package/dist/components/collections/TableRow/index.js +9 -0
- package/dist/components/collections/interfaces.d.ts +19 -17
- package/dist/components/collections/utility/is-data-table-array.d.ts +3 -0
- package/dist/components/collections/utility/is-data-table-array.js +5 -0
- package/dist/components/collections/utility/is-data-table-object.d.ts +3 -0
- package/dist/components/collections/utility/is-data-table-object.js +4 -0
- package/dist/components/errors/AppError/index.d.ts +19 -0
- package/dist/components/errors/AppError/index.js +8 -0
- package/dist/components/errors/AppForbiddenError/index.d.ts +7 -0
- package/dist/components/errors/AppForbiddenError/index.js +6 -0
- package/dist/components/errors/AppNotFoundError/index.d.ts +7 -0
- package/dist/components/errors/AppNotFoundError/index.js +6 -0
- package/dist/components/errors/AppServerError/index.d.ts +8 -0
- package/dist/components/errors/AppServerError/index.js +17 -0
- package/dist/components/index.d.ts +19 -0
- package/dist/components/index.js +9 -0
- package/dist/components/modals/ConfirmModal/index.d.ts +3 -1
- package/dist/components/modals/ConfirmModal/index.js +3 -3
- package/dist/components/modals/Modal/index.d.ts +4 -4
- package/dist/components/modals/Modal/index.js +3 -3
- package/dist/components/modals/ModalActions/index.d.ts +3 -3
- package/dist/components/modals/ModalActions/index.js +3 -3
- package/dist/components/utility/Action/index.d.ts +11 -0
- package/dist/components/utility/Action/index.js +44 -0
- package/dist/components/utility/ActionList/index.d.ts +3 -3
- package/dist/components/utility/ActionList/index.js +3 -3
- package/dist/components/utility/ClassNamesClientComponent/index.d.ts +6 -0
- package/dist/components/utility/ClassNamesClientComponent/index.js +7 -0
- package/dist/components/utility/Confirmable/index.d.ts +9 -0
- package/dist/components/utility/Confirmable/index.js +14 -0
- package/dist/components/utility/Container/index.d.ts +1 -1
- package/dist/components/utility/Container/index.js +2 -2
- package/dist/components/utility/Link/index.d.ts +1 -1
- package/dist/components/utility/Link/index.js +3 -3
- package/dist/components/utility/Loader/index.d.ts +1 -1
- package/dist/components/utility/Loader/index.js +4 -4
- package/dist/components/utility/Menu/index.d.ts +11 -0
- package/dist/components/utility/Menu/index.js +15 -0
- package/dist/components/utility/MenuItem/index.d.ts +4 -0
- package/dist/components/utility/MenuItem/index.js +9 -0
- package/dist/components/utility/Popover/index.d.ts +1 -1
- package/dist/components/utility/Popover/index.js +4 -4
- package/dist/components/utility/Reference/index.d.ts +9 -0
- package/dist/components/utility/Reference/index.js +15 -0
- package/dist/components/utility/RootLayout/index.d.ts +6 -3
- package/dist/components/utility/RootLayout/index.js +7 -6
- package/dist/components/utility/Toast/index.d.ts +1 -1
- package/dist/components/utility/Toast/index.js +2 -2
- package/dist/filters/components/FilterBarClientComponent/index.d.ts +1 -1
- package/dist/filters/components/FilterBarClientComponent/index.js +2 -2
- package/dist/filters/components/FilterControl/index.d.ts +1 -1
- package/dist/filters/components/FilterControl/index.js +7 -4
- package/dist/filters/components/FilterItem/index.d.ts +1 -1
- package/dist/filters/components/FilterItem/index.js +2 -2
- package/dist/filters/components/FilterPanel/index.d.ts +1 -1
- package/dist/filters/filters/Filter/index.d.ts +1 -1
- package/dist/filters/filters/Filter/index.js +3 -4
- package/dist/filters/filters/SearchFilter/index.js +1 -1
- package/dist/filters/index.d.ts +1 -0
- package/dist/filters/index.js +1 -0
- package/dist/filters/interfaces.d.ts +2 -2
- package/dist/filters/utility/parse-filters.d.ts +1 -1
- package/dist/filters/utility/parse-filters.js +3 -2
- package/dist/filters/utility/transform-boolean.d.ts +1 -1
- package/dist/filters/utility/transform-date.d.ts +1 -1
- package/dist/filters/utility/transform-multi.d.ts +1 -1
- package/dist/forms/components/Autocomplete/index.d.ts +11 -0
- package/dist/forms/components/Autocomplete/index.js +37 -0
- package/dist/forms/components/Dropdown/index.d.ts +1 -1
- package/dist/forms/components/Dropdown/index.js +8 -5
- package/dist/forms/components/DropdownItem/index.d.ts +9 -0
- package/dist/forms/components/DropdownItem/index.js +8 -0
- package/dist/forms/components/DropdownList/index.d.ts +1 -1
- package/dist/forms/components/DropdownList/index.js +5 -8
- package/dist/forms/components/EditableForm/index.d.ts +3 -3
- package/dist/forms/components/EditableForm/index.js +3 -4
- package/dist/forms/components/EditableFormField/index.d.ts +1 -1
- package/dist/forms/components/EditableFormField/index.js +2 -2
- package/dist/forms/components/Form/index.d.ts +3 -2
- package/dist/forms/components/Form/index.js +5 -5
- package/dist/forms/components/FormError/index.d.ts +1 -1
- package/dist/forms/components/FormError/index.js +3 -3
- package/dist/forms/components/FormField/index.d.ts +4 -4
- package/dist/forms/components/FormField/index.js +7 -6
- package/dist/forms/components/FormFields/index.d.ts +9 -0
- package/dist/forms/components/FormFields/index.js +18 -0
- package/dist/forms/components/FormLabel/index.d.ts +1 -1
- package/dist/forms/components/FormLabel/index.js +3 -3
- package/dist/forms/components/ModalForm/index.js +1 -1
- package/dist/forms/components/NumberInput/index.d.ts +7 -0
- package/dist/forms/components/NumberInput/index.js +27 -0
- package/dist/forms/components/PasswordComplexity/index.d.ts +9 -0
- package/dist/forms/components/PasswordComplexity/index.js +10 -0
- package/dist/forms/components/PasswordInput/index.d.ts +1 -1
- package/dist/forms/components/PasswordInput/index.js +4 -5
- package/dist/forms/components/PointsInput/index.d.ts +5 -0
- package/dist/forms/components/PointsInput/index.js +22 -0
- package/dist/forms/components/StaticTextInput/index.d.ts +2 -3
- package/dist/forms/components/StaticTextInput/index.js +5 -8
- package/dist/forms/components/Switch/index.d.ts +1 -1
- package/dist/forms/components/Switch/index.js +4 -4
- package/dist/forms/components/TextInput/index.d.ts +2 -2
- package/dist/forms/components/TextInput/index.js +6 -6
- package/dist/forms/hooks/useAutocomplete.d.ts +9 -0
- package/dist/forms/hooks/useAutocomplete.js +31 -0
- package/dist/forms/hooks/useDropdown.d.ts +2 -2
- package/dist/forms/hooks/useForm.d.ts +1 -1
- package/dist/forms/hooks/useForm.js +5 -4
- package/dist/forms/hooks/useModalForm.d.ts +2 -2
- package/dist/forms/index.d.ts +18 -2
- package/dist/forms/index.js +7 -2
- package/dist/forms/interfaces.d.ts +1 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +2 -1
- package/dist/hooks/useConfirmable.d.ts +21 -0
- package/dist/hooks/useConfirmable.js +58 -0
- package/dist/hooks/usePopover.d.ts +11 -0
- package/dist/hooks/usePopover.js +17 -0
- package/dist/hooks/useServerAction.d.ts +9 -0
- package/dist/hooks/useServerAction.js +15 -0
- package/dist/navigation/components/AppNavigation/index.d.ts +2 -1
- package/dist/navigation/components/AppNavigation/index.js +4 -4
- package/dist/navigation/components/AppNavigationItem/index.d.ts +5 -3
- package/dist/navigation/components/AppNavigationItem/index.js +13 -6
- package/dist/navigation/components/Tabs/index.js +1 -4
- package/dist/navigation/hooks/useNavigation.d.ts +3 -3
- package/dist/navigation/hooks/useNavigation.js +5 -5
- package/dist/styles/classnames/apply-variants.d.ts +3 -0
- package/dist/styles/classnames/apply-variants.js +25 -0
- package/dist/styles/classnames/config.d.ts +69 -0
- package/dist/styles/classnames/index.d.ts +7 -0
- package/dist/styles/classnames/index.js +37 -0
- package/dist/styles/classnames/interfaces.d.ts +56 -0
- package/dist/styles/classnames/interfaces.js +1 -0
- package/dist/styles/classnames/utility/is-classname-object.d.ts +3 -0
- package/dist/styles/classnames/utility/is-classname-object.js +7 -0
- package/dist/styles/icons/config.d.ts +9 -0
- package/dist/styles/icons/config.js +1 -0
- package/dist/styles/icons/index.d.ts +4 -0
- package/dist/styles/icons/interfaces.d.ts +4 -0
- package/dist/styles/icons/interfaces.js +1 -0
- package/dist/styles/index.d.ts +2 -2
- package/dist/styles/index.js +1 -1
- package/dist/styles/styles.css +59 -0
- package/dist/utility/interfaces.d.ts +19 -8
- package/package.json +9 -4
- package/dist/components/buttons/ConfirmableButton/index.d.ts +0 -7
- package/dist/components/buttons/ConfirmableButton/index.js +0 -13
- package/dist/components/collections/ListClientComponent/index.d.ts +0 -7
- package/dist/components/collections/ListClientComponent/index.js +0 -9
- package/dist/components/collections/utility/filter-columns.d.ts +0 -3
- package/dist/components/collections/utility/filter-columns.js +0 -8
- package/dist/components/utility/ClassNames/index.d.ts +0 -6
- package/dist/components/utility/ClassNames/index.js +0 -7
- package/dist/styles/config.d.ts +0 -64
- package/dist/styles/config.js +0 -43
- package/dist/styles/icons.d.ts +0 -15
- package/dist/styles/interfaces.d.ts +0 -41
- /package/dist/styles/{interfaces.js → classnames/config.js} +0 -0
- /package/dist/styles/{tw.d.ts → classnames/tw.d.ts} +0 -0
- /package/dist/styles/{tw.js → classnames/tw.js} +0 -0
- /package/dist/styles/{icons.js → icons/index.js} +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Switch from '../../../forms/components/Switch';
|
|
3
|
+
import { getClassNames } from '../../../styles/classnames';
|
|
4
|
+
import ListItemMenu from '../ListItemMenu';
|
|
5
|
+
function TableRow({ classNameProps, classNames, columns, data, isSelected, onSelect, }) {
|
|
6
|
+
const componentClassNames = getClassNames('table', { props: classNameProps, states: { isSelected } }, classNames);
|
|
7
|
+
return (_jsxs("tr", { className: componentClassNames?.row, children: [data.isSelectable ? (_jsx("td", { children: _jsx(Switch, { name: data.id, onChange: onSelect, value: isSelected }) })) : null, columns.map((column) => (_jsx("td", { className: componentClassNames?.cell, children: data.row[column.id] }, column.id))), data.actions ? (_jsx("td", { children: _jsx(ListItemMenu, { actions: data.actions, data: data.$data }) })) : null] }));
|
|
8
|
+
}
|
|
9
|
+
export default TableRow;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ActionObject, StyleVariant } from '../../utility/interfaces';
|
|
2
2
|
export interface CollectionFunctionConfig<Filters = null> {
|
|
3
3
|
filters?: Partial<Filters> | null;
|
|
4
4
|
params?: Record<string, string> | null;
|
|
@@ -7,27 +7,20 @@ export interface CollectionFunctionConfig<Filters = null> {
|
|
|
7
7
|
export type ListFunctionConfig<Filters = null> = CollectionFunctionConfig<Filters>;
|
|
8
8
|
export interface ListItemObject<Data extends object | null = null> {
|
|
9
9
|
$data?: Data;
|
|
10
|
-
actions?:
|
|
11
|
-
description?: React.ReactNode
|
|
10
|
+
actions?: ActionObject<Data>[];
|
|
11
|
+
description?: React.ReactNode;
|
|
12
12
|
href?: string;
|
|
13
13
|
id: string;
|
|
14
|
-
isMinimal?: boolean;
|
|
15
14
|
image?: string | null;
|
|
16
15
|
imageHref?: string | null;
|
|
17
16
|
isLoading?: boolean;
|
|
18
|
-
meta?:
|
|
19
|
-
data?: React.ReactNode[] | Record<string, React.ReactNode>;
|
|
20
|
-
id: string;
|
|
21
|
-
};
|
|
17
|
+
meta?: React.ReactNode[] | (DataTableObject | null)[];
|
|
22
18
|
permission?: string;
|
|
23
19
|
secondary?: {
|
|
24
20
|
data?: React.ReactElement | {
|
|
25
|
-
description?:
|
|
26
|
-
meta?:
|
|
27
|
-
|
|
28
|
-
id: string;
|
|
29
|
-
};
|
|
30
|
-
title?: string;
|
|
21
|
+
description?: React.ReactNode;
|
|
22
|
+
meta?: React.ReactNode[] | (DataTableObject | null)[];
|
|
23
|
+
title?: React.ReactNode;
|
|
31
24
|
} | null;
|
|
32
25
|
variant?: StyleVariant | null;
|
|
33
26
|
};
|
|
@@ -36,11 +29,16 @@ export interface ListItemObject<Data extends object | null = null> {
|
|
|
36
29
|
variant?: StyleVariant | null;
|
|
37
30
|
}
|
|
38
31
|
export type TableFunctionConfig<Filters = null> = CollectionFunctionConfig<Filters>;
|
|
39
|
-
export interface TableItemObject {
|
|
40
|
-
|
|
32
|
+
export interface TableItemObject<Data extends object | null = null> {
|
|
33
|
+
$data?: Data;
|
|
34
|
+
actions?: ActionObject<Data>[];
|
|
41
35
|
id: string;
|
|
36
|
+
isSelectable?: boolean;
|
|
37
|
+
row: {
|
|
38
|
+
[key: string]: React.ReactNode;
|
|
39
|
+
};
|
|
42
40
|
}
|
|
43
|
-
export type TableColumnType = 'date' | 'decimal' | '
|
|
41
|
+
export type TableColumnType = 'date' | 'decimal' | 'link' | 'money' | 'number' | 'percentage' | 'points' | 'raw' | 'reference' | 'string';
|
|
44
42
|
export interface TableColumnObject {
|
|
45
43
|
isSortable?: boolean;
|
|
46
44
|
id: string;
|
|
@@ -55,3 +53,7 @@ export interface Paginated<T> {
|
|
|
55
53
|
total: number;
|
|
56
54
|
};
|
|
57
55
|
}
|
|
56
|
+
export interface DataTableObject {
|
|
57
|
+
label: React.ReactNode;
|
|
58
|
+
value: React.ReactNode;
|
|
59
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
2
|
+
import type { ActionObject } from '../../../utility/interfaces';
|
|
3
|
+
export interface AppErrorClassNames {
|
|
4
|
+
root: string;
|
|
5
|
+
panel: string;
|
|
6
|
+
title: string;
|
|
7
|
+
description: string;
|
|
8
|
+
action: string;
|
|
9
|
+
}
|
|
10
|
+
export interface AppErrorProps extends ClassNameProps<AppErrorClassNames> {
|
|
11
|
+
action?: ActionObject;
|
|
12
|
+
description: React.ReactNode;
|
|
13
|
+
error: Error & {
|
|
14
|
+
digest?: string;
|
|
15
|
+
};
|
|
16
|
+
title: React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
declare function AppError({ action, classNameProps, classNames, description, error, title, }: Readonly<AppErrorProps>): React.ReactElement;
|
|
19
|
+
export default AppError;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import ActionButton from '../../../components/buttons/ActionButton';
|
|
3
|
+
import { getClassNames } from '../../../styles/classnames';
|
|
4
|
+
function AppError({ action, classNameProps, classNames, description, error, title, }) {
|
|
5
|
+
const componentClassNames = getClassNames('appError', { props: classNameProps }, classNames);
|
|
6
|
+
return (_jsx("div", { className: componentClassNames?.root, children: _jsxs("section", { className: componentClassNames?.panel, children: [_jsx("h2", { className: componentClassNames?.title, children: title }), _jsxs("div", { className: componentClassNames?.description, children: [description, error?.digest ? _jsxs("small", { children: ["Error code: ", error.digest] }) : null] }), action ? (_jsx("footer", { className: componentClassNames?.action, children: _jsx(ActionButton, { ...action }) })) : null] }) }));
|
|
7
|
+
}
|
|
8
|
+
export default AppError;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AppErrorProps } from '../AppError';
|
|
2
|
+
export interface AppForbiddenErrorProps extends Omit<AppErrorProps, 'action' | 'description' | 'title'> {
|
|
3
|
+
description?: React.ReactNode;
|
|
4
|
+
title?: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
declare function AppForbiddenError({ description, title, ...props }: AppForbiddenErrorProps): React.ReactElement;
|
|
7
|
+
export default AppForbiddenError;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import AppError from '../AppError';
|
|
3
|
+
function AppForbiddenError({ description = 'You do not have permission to access this resource. If you think this is a mistake, please contact your site administrator.', title = 'Forbidden', ...props }) {
|
|
4
|
+
return (_jsx(AppError, { ...props, action: { href: '/', label: 'Go to Homepage' }, description: description, title: title }));
|
|
5
|
+
}
|
|
6
|
+
export default AppForbiddenError;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AppErrorProps } from '../AppError';
|
|
2
|
+
export interface AppNotFoundErrorProps extends Omit<AppErrorProps, 'action' | 'description' | 'title'> {
|
|
3
|
+
description?: React.ReactNode;
|
|
4
|
+
title?: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
declare function AppNotFoundError({ description, title, ...props }: AppNotFoundErrorProps): React.ReactElement;
|
|
7
|
+
export default AppNotFoundError;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import AppError from '../AppError';
|
|
3
|
+
function AppNotFoundError({ description = 'The requested resource could not be found. This might be because it has been moved or deleted. If you think this is a mistake, please contact your site administrator.', title = 'Not Found', ...props }) {
|
|
4
|
+
return (_jsx(AppError, { ...props, action: { href: '/', label: 'Go to Homepage' }, description: description, title: title }));
|
|
5
|
+
}
|
|
6
|
+
export default AppNotFoundError;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AppErrorProps } from '../AppError';
|
|
2
|
+
interface AppServerErrorProps extends Omit<AppErrorProps, 'action' | 'description' | 'title'> {
|
|
3
|
+
description?: React.ReactNode;
|
|
4
|
+
reset: () => void;
|
|
5
|
+
title?: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
declare function AppServerError({ description, reset, title, ...props }: AppServerErrorProps): React.ReactElement;
|
|
8
|
+
export default AppServerError;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import AppError from '../AppError';
|
|
5
|
+
const WAIT_TIME = 500;
|
|
6
|
+
function AppServerError({ description = 'The server encountered an error and could not complete your request. If the problem persists, please contact your site administrator.', reset, title = 'Something Went Wrong', ...props }) {
|
|
7
|
+
const [isResetting, setIsResetting] = useState(false);
|
|
8
|
+
function handleReset() {
|
|
9
|
+
setIsResetting(true);
|
|
10
|
+
setTimeout(() => {
|
|
11
|
+
reset();
|
|
12
|
+
setIsResetting(false);
|
|
13
|
+
}, WAIT_TIME);
|
|
14
|
+
}
|
|
15
|
+
return (_jsx(AppError, { ...props, action: { isDisabled: isResetting, onClick: handleReset, label: 'Try Again' }, description: description, title: title }));
|
|
16
|
+
}
|
|
17
|
+
export default AppServerError;
|
|
@@ -1,16 +1,35 @@
|
|
|
1
1
|
export * from './collections/interfaces';
|
|
2
|
+
export type { ActionButtonProps } from './buttons/ActionButton';
|
|
2
3
|
export { default as ActionButton } from './buttons/ActionButton';
|
|
4
|
+
export type { ButtonProps } from './buttons/Button';
|
|
5
|
+
export { default as Button } from './buttons/Button';
|
|
6
|
+
export type { DataTableProps } from './collections/DataTable';
|
|
7
|
+
export { default as DataTable } from './collections/DataTable';
|
|
3
8
|
export type { ListProps } from './collections/List';
|
|
4
9
|
export { default as List } from './collections/List';
|
|
5
10
|
export type { TableProps } from './collections/Table';
|
|
6
11
|
export { default as Table } from './collections/Table';
|
|
12
|
+
export type { AppErrorProps } from './errors/AppError';
|
|
13
|
+
export { default as AppError } from './errors/AppError';
|
|
14
|
+
export type { AppForbiddenErrorProps } from './errors/AppForbiddenError';
|
|
15
|
+
export { default as AppForbiddenError } from './errors/AppForbiddenError';
|
|
16
|
+
export type { AppNotFoundErrorProps } from './errors/AppNotFoundError';
|
|
17
|
+
export { default as AppNotFoundError } from './errors/AppNotFoundError';
|
|
18
|
+
export type { ModalProps } from './modals/Modal';
|
|
19
|
+
export { default as Modal } from './modals/Modal';
|
|
7
20
|
export type { ModalLauncherProps } from './modals/ModalLauncher';
|
|
8
21
|
export { default as ModalLauncher } from './modals/ModalLauncher';
|
|
9
22
|
export type { ContainerProps } from './utility/Container';
|
|
10
23
|
export { default as Container } from './utility/Container';
|
|
11
24
|
export type { LinkProps } from './utility/Link';
|
|
12
25
|
export { default as Link } from './utility/Link';
|
|
26
|
+
export type { MenuProps } from './utility/Menu';
|
|
27
|
+
export { default as Menu } from './utility/Menu';
|
|
13
28
|
export type { PageProps } from './utility/Page';
|
|
14
29
|
export { default as Page } from './utility/Page';
|
|
30
|
+
export type { PopoverProps } from './utility/Popover';
|
|
31
|
+
export { default as Popover } from './utility/Popover';
|
|
32
|
+
export type { ReferenceProps } from './utility/Reference';
|
|
33
|
+
export { default as Reference } from './utility/Reference';
|
|
15
34
|
export type { RootLayoutProps } from './utility/RootLayout';
|
|
16
35
|
export { default as RootLayout } from './utility/RootLayout';
|
package/dist/components/index.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
export * from './collections/interfaces';
|
|
2
2
|
export { default as ActionButton } from './buttons/ActionButton';
|
|
3
|
+
export { default as Button } from './buttons/Button';
|
|
4
|
+
export { default as DataTable } from './collections/DataTable';
|
|
3
5
|
export { default as List } from './collections/List';
|
|
4
6
|
export { default as Table } from './collections/Table';
|
|
7
|
+
export { default as AppError } from './errors/AppError';
|
|
8
|
+
export { default as AppForbiddenError } from './errors/AppForbiddenError';
|
|
9
|
+
export { default as AppNotFoundError } from './errors/AppNotFoundError';
|
|
10
|
+
export { default as Modal } from './modals/Modal';
|
|
5
11
|
export { default as ModalLauncher } from './modals/ModalLauncher';
|
|
6
12
|
export { default as Container } from './utility/Container';
|
|
7
13
|
export { default as Link } from './utility/Link';
|
|
14
|
+
export { default as Menu } from './utility/Menu';
|
|
8
15
|
export { default as Page } from './utility/Page';
|
|
16
|
+
export { default as Popover } from './utility/Popover';
|
|
17
|
+
export { default as Reference } from './utility/Reference';
|
|
9
18
|
export { default as RootLayout } from './utility/RootLayout';
|
|
@@ -2,6 +2,8 @@ import { ConfirmableObject } from '../../../utility/interfaces';
|
|
|
2
2
|
import type { ModalProps } from '../Modal';
|
|
3
3
|
export type ConfirmModalProps = Omit<ModalProps, 'children' | 'icon' | 'title'> & {
|
|
4
4
|
confirmable: ConfirmableObject;
|
|
5
|
+
onCancel: () => void;
|
|
6
|
+
onConfirm: () => void;
|
|
5
7
|
};
|
|
6
|
-
declare function ConfirmModal({ confirmable, ...modalProps }: Readonly<ConfirmModalProps>): React.ReactElement;
|
|
8
|
+
declare function ConfirmModal({ confirmable, onCancel, onConfirm, ...modalProps }: Readonly<ConfirmModalProps>): React.ReactElement;
|
|
7
9
|
export default ConfirmModal;
|
|
@@ -3,19 +3,19 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { Fragment, useState } from 'react';
|
|
4
4
|
import TextInput from '../../../forms/components/TextInput';
|
|
5
5
|
import Modal from '../Modal';
|
|
6
|
-
function ConfirmModal({ confirmable, ...modalProps }) {
|
|
6
|
+
function ConfirmModal({ confirmable, onCancel, onConfirm, ...modalProps }) {
|
|
7
7
|
const [confirmText, setConfirmText] = useState('');
|
|
8
8
|
function handleChange(event) {
|
|
9
9
|
setConfirmText(event.target.value?.toUpperCase() || '');
|
|
10
10
|
}
|
|
11
11
|
return (_jsxs(Modal, { ...modalProps, actions: [
|
|
12
|
-
{ label: 'Cancel',
|
|
12
|
+
{ label: 'Cancel', onClick: onCancel },
|
|
13
13
|
...(confirmable.actions || []),
|
|
14
14
|
{
|
|
15
15
|
isDisabled: Boolean(confirmable.confirmText &&
|
|
16
16
|
confirmText !== confirmable.confirmText.toUpperCase()),
|
|
17
17
|
label: confirmable.submitLabel || 'Confirm',
|
|
18
|
-
onClick:
|
|
18
|
+
onClick: onConfirm,
|
|
19
19
|
variant: 'primary',
|
|
20
20
|
},
|
|
21
21
|
], title: confirmable.title || 'Are you sure?', children: [confirmable.description || 'This action cannot be undone.', confirmable.confirmText ? (_jsxs(Fragment, { children: [_jsxs("p", { children: ["Please type ", _jsx("strong", { children: confirmable.confirmText.toUpperCase() }), " to confirm"] }), _jsx(TextInput, { name: "confirm", onChange: handleChange, value: confirmText })] })) : null] }));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
2
|
-
import {
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
2
|
+
import { ActionObject } from '../../../utility/interfaces';
|
|
3
3
|
export interface ModalClassNames {
|
|
4
4
|
actions: string;
|
|
5
5
|
content: string;
|
|
@@ -9,11 +9,11 @@ export interface ModalClassNames {
|
|
|
9
9
|
title: string;
|
|
10
10
|
}
|
|
11
11
|
export interface ModalProps extends ClassNameProps<ModalClassNames> {
|
|
12
|
-
actions?:
|
|
12
|
+
actions?: ActionObject[];
|
|
13
13
|
children: React.ReactNode;
|
|
14
14
|
icon?: React.ReactNode;
|
|
15
15
|
isLoading?: boolean;
|
|
16
|
-
title?:
|
|
16
|
+
title?: React.ReactNode;
|
|
17
17
|
}
|
|
18
18
|
declare function Modal({ actions, children, classNames, classNameProps, icon, isLoading, title, }: Readonly<ModalProps>): React.ReactElement | null;
|
|
19
19
|
export default Modal;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useRef } from 'react';
|
|
4
|
-
import { getClassNames } from '../../../styles/
|
|
5
|
-
import tw from '../../../styles/tw';
|
|
4
|
+
import { getClassNames } from '../../../styles/classnames';
|
|
5
|
+
import tw from '../../../styles/classnames/tw';
|
|
6
6
|
import ModalActions from '../ModalActions';
|
|
7
7
|
function Modal({ actions, children, classNames, classNameProps, icon, isLoading, title, }) {
|
|
8
|
-
const componentClassNames =
|
|
8
|
+
const componentClassNames = getClassNames('modal', { props: classNameProps }, classNames);
|
|
9
9
|
const ref = useRef(null);
|
|
10
10
|
useEffect(() => {
|
|
11
11
|
if (ref.current) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
2
|
-
import {
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
2
|
+
import { ActionObject } from '../../../utility/interfaces';
|
|
3
3
|
import type { ModalClassNames } from '../Modal';
|
|
4
4
|
export interface ModalActionsProps extends ClassNameProps<ModalClassNames> {
|
|
5
|
-
actions: (
|
|
5
|
+
actions: (ActionObject | null)[];
|
|
6
6
|
isLoading?: boolean;
|
|
7
7
|
}
|
|
8
8
|
declare function ModalActions({ actions, classNameProps, classNames, isLoading, }: Readonly<ModalActionsProps>): React.ReactElement;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import ActionList from '../../../components/utility/ActionList';
|
|
3
|
-
import { getClassNames } from '../../../styles/
|
|
3
|
+
import { getClassNames } from '../../../styles/classnames';
|
|
4
4
|
function ModalActions({ actions, classNameProps, classNames, isLoading, }) {
|
|
5
|
-
const componentClassNames =
|
|
6
|
-
return (_jsx("footer", { className: componentClassNames?.actions, children: _jsx(ActionList, { actions: actions, classNameProps: { ...
|
|
5
|
+
const componentClassNames = getClassNames('modal', { props: classNameProps }, classNames);
|
|
6
|
+
return (_jsx("footer", { className: componentClassNames?.actions, children: _jsx(ActionList, { actions: actions, classNameProps: { ...classNameProps, isModal: true }, isLoading: isLoading }) }));
|
|
7
7
|
}
|
|
8
8
|
export default ModalActions;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ActionObject } from '../../../utility/interfaces';
|
|
2
|
+
export interface ActionProps<Data extends object | null = null> extends Omit<ActionObject<Data>, 'details' | 'label'> {
|
|
3
|
+
readonly children?: React.ReactNode;
|
|
4
|
+
readonly label?: React.ReactNode;
|
|
5
|
+
readonly render: (props: ActionComponentProps<Data>) => React.ReactElement;
|
|
6
|
+
}
|
|
7
|
+
export interface ActionComponentProps<Data extends object | null = null> extends Pick<ActionProps<Data>, 'href' | 'icon' | 'isDisabled' | 'isLoading' | 'isSubmittable' | 'onClick' | 'searchParams' | 'variant'> {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
declare function Action<Data extends object | null = null>(props: ActionProps<Data>): React.ReactElement;
|
|
11
|
+
export default Action;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Suspense } from 'react';
|
|
4
|
+
import useSearchParamsHref from '../../../hooks/useSearchParamsHref';
|
|
5
|
+
import useServerAction from '../../../hooks/useServerAction';
|
|
6
|
+
import Confirmable from '../Confirmable';
|
|
7
|
+
function ActionComponent({ action, children, confirmable, data, href, icon, isDisabled, isLoading, isSubmittable, label, onClick, searchParams, render, variant, }) {
|
|
8
|
+
const { setSearchParamsHref } = useSearchParamsHref();
|
|
9
|
+
async function handleAction() {
|
|
10
|
+
await action?.(data);
|
|
11
|
+
}
|
|
12
|
+
const { handleClick: handleActionClick, isLoading: isActionLoading } = useServerAction(handleAction, {
|
|
13
|
+
onSuccess: onClick,
|
|
14
|
+
});
|
|
15
|
+
function handleClick() {
|
|
16
|
+
if (action) {
|
|
17
|
+
handleActionClick();
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
onClick?.();
|
|
21
|
+
}
|
|
22
|
+
if (searchParams) {
|
|
23
|
+
setSearchParamsHref(searchParams);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const componentProps = {
|
|
27
|
+
children: children ?? label,
|
|
28
|
+
href,
|
|
29
|
+
icon,
|
|
30
|
+
isDisabled: Boolean(isDisabled || isLoading || isActionLoading),
|
|
31
|
+
isLoading: isLoading || isActionLoading,
|
|
32
|
+
isSubmittable: Boolean(isSubmittable),
|
|
33
|
+
onClick: handleClick,
|
|
34
|
+
variant,
|
|
35
|
+
};
|
|
36
|
+
if (confirmable) {
|
|
37
|
+
return (_jsx(Confirmable, { confirmable: confirmable, renderProps: componentProps, render: render }));
|
|
38
|
+
}
|
|
39
|
+
return render(componentProps);
|
|
40
|
+
}
|
|
41
|
+
function Action(props) {
|
|
42
|
+
return (_jsx(Suspense, { children: _jsx(ActionComponent, { ...props }) }));
|
|
43
|
+
}
|
|
44
|
+
export default Action;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
2
|
-
import {
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
2
|
+
import { ActionObject } from '../../../utility/interfaces';
|
|
3
3
|
export interface ActionListClassNames {
|
|
4
4
|
root: string;
|
|
5
5
|
item: string;
|
|
6
6
|
}
|
|
7
7
|
export interface ActionListProps extends ClassNameProps<ActionListClassNames> {
|
|
8
|
-
actions: (
|
|
8
|
+
actions: (ActionObject | null)[];
|
|
9
9
|
isLoading?: boolean;
|
|
10
10
|
}
|
|
11
11
|
declare function ActionList({ actions, classNameProps, classNames, isLoading, }: Readonly<ActionListProps>): React.ReactElement;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { filterNull } from '@sqrzro/utility';
|
|
3
3
|
import ActionButton from '../../../components/buttons/ActionButton';
|
|
4
|
-
import { getClassNames } from '../../../styles/
|
|
4
|
+
import { getClassNames } from '../../../styles/classnames';
|
|
5
5
|
function ActionList({ actions, classNameProps, classNames, isLoading, }) {
|
|
6
|
-
const componentClassNames =
|
|
7
|
-
return (_jsx("ul", { className: componentClassNames?.root, children: filterNull(actions).map((action, index) => (_jsx("li", { className: componentClassNames?.item, children: _jsx(ActionButton, { ...action, isLoading: Boolean(isLoading || action.
|
|
6
|
+
const componentClassNames = getClassNames('actionList', { props: classNameProps }, classNames);
|
|
7
|
+
return (_jsx("ul", { className: componentClassNames?.root, children: filterNull(actions).map((action, index) => (_jsx("li", { className: componentClassNames?.item, children: _jsx(ActionButton, { ...action, isLoading: Boolean(isLoading || action.isLoading) }) }, index))) }));
|
|
8
8
|
}
|
|
9
9
|
export default ActionList;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RegisteredClassNames } from '../../../styles/classnames/config';
|
|
2
|
+
export interface ClassNamesClientComponentProps {
|
|
3
|
+
data: RegisteredClassNames;
|
|
4
|
+
}
|
|
5
|
+
declare function ClassNamesClientComponent({ data }: ClassNamesClientComponentProps): null;
|
|
6
|
+
export default ClassNamesClientComponent;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ButtonProps } from '../../../components/buttons/Button';
|
|
2
|
+
import type { ConfirmableObject } from '../../../utility/interfaces';
|
|
3
|
+
export type ConfirmableProps = {
|
|
4
|
+
confirmable: ConfirmableObject;
|
|
5
|
+
renderProps: ButtonProps;
|
|
6
|
+
render: (props: ButtonProps) => React.ReactElement;
|
|
7
|
+
};
|
|
8
|
+
declare function Confirmable({ confirmable, renderProps, render, }: Readonly<ConfirmableProps>): React.ReactElement;
|
|
9
|
+
export default Confirmable;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Fragment } from 'react';
|
|
4
|
+
import useConfirmable from '../../../hooks/useConfirmable';
|
|
5
|
+
import ConfirmModal from '../../modals/ConfirmModal';
|
|
6
|
+
function Confirmable({ confirmable, renderProps, render, }) {
|
|
7
|
+
const { handle, isOpen, modalProps } = useConfirmable({
|
|
8
|
+
isLoading: renderProps.isLoading,
|
|
9
|
+
onConfirm: (event) => renderProps.onClick?.(event),
|
|
10
|
+
refreshOnSuccess: true,
|
|
11
|
+
});
|
|
12
|
+
return (_jsxs(Fragment, { children: [render({ ...renderProps, isLoading: renderProps.isLoading, onClick: handle }), isOpen ? _jsx(ConfirmModal, { confirmable: confirmable, ...modalProps }) : null] }));
|
|
13
|
+
}
|
|
14
|
+
export default Confirmable;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { getClassNames } from '../../../styles/
|
|
3
|
+
import { getClassNames } from '../../../styles/classnames';
|
|
4
4
|
function Container({ children, classNameProps, classNames, }) {
|
|
5
|
-
const componentClassNames =
|
|
5
|
+
const componentClassNames = getClassNames('container', { props: classNameProps }, classNames);
|
|
6
6
|
return _jsx("div", { className: componentClassNames?.root, children: children });
|
|
7
7
|
}
|
|
8
8
|
export default Container;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import NextLink from 'next/link';
|
|
3
|
-
import { getClassNames } from '../../../styles/
|
|
4
|
-
import tw from '../../../styles/tw';
|
|
3
|
+
import { getClassNames } from '../../../styles/classnames';
|
|
4
|
+
import tw from '../../../styles/classnames/tw';
|
|
5
5
|
function normalizeHref(href) {
|
|
6
6
|
if (!href) {
|
|
7
7
|
return '';
|
|
@@ -12,7 +12,7 @@ function normalizeHref(href) {
|
|
|
12
12
|
return /^\//u.exec(href) ? href : `/${href}`;
|
|
13
13
|
}
|
|
14
14
|
function Link({ children, className, classNames, classNameProps, isNewWindow, href = '/', id, onClick, scroll, style, ...dataProps }) {
|
|
15
|
-
const componentClassNames =
|
|
15
|
+
const componentClassNames = getClassNames('link', { props: classNameProps }, classNames);
|
|
16
16
|
const newWindowProps = isNewWindow
|
|
17
17
|
? { rel: 'noopener noreferrer', target: '_blank' }
|
|
18
18
|
: {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClassNameProps, SizableClassName } from '../../../styles/interfaces';
|
|
1
|
+
import type { ClassNameProps, SizableClassName } from '../../../styles/classnames/interfaces';
|
|
2
2
|
export interface LoaderClassNames {
|
|
3
3
|
root?: SizableClassName;
|
|
4
4
|
inner?: SizableClassName;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { getClassNames } from '../../../styles/
|
|
3
|
-
import tw from '../../../styles/tw';
|
|
2
|
+
import { getClassNames } from '../../../styles/classnames';
|
|
3
|
+
import tw from '../../../styles/classnames/tw';
|
|
4
4
|
import Assistive from '../Assistive';
|
|
5
5
|
function Loader({ classNameProps, classNames }) {
|
|
6
|
-
const componentClassNames =
|
|
7
|
-
return (_jsxs("div", { className: tw(componentClassNames?.root
|
|
6
|
+
const componentClassNames = getClassNames('loader', { props: classNameProps }, classNames);
|
|
7
|
+
return (_jsxs("div", { className: tw(componentClassNames?.root), children: [_jsx("div", { className: tw(componentClassNames?.inner) }), _jsx(Assistive, { children: "Loading..." })] }));
|
|
8
8
|
}
|
|
9
9
|
export default Loader;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ActionObject } from '../../../utility/interfaces';
|
|
2
|
+
import { PopoverProps } from '../Popover';
|
|
3
|
+
export interface MenuProps<Data extends object | null = null> {
|
|
4
|
+
actions: ActionObject<Data>[];
|
|
5
|
+
align?: PopoverProps['align'];
|
|
6
|
+
data?: Data;
|
|
7
|
+
label: React.ReactNode;
|
|
8
|
+
vAlign?: PopoverProps['vAlign'];
|
|
9
|
+
}
|
|
10
|
+
declare function Menu<Data extends object | null = null>({ actions, align, data, label, vAlign, }: MenuProps<Data>): React.ReactElement;
|
|
11
|
+
export default Menu;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import Button from '../../../components/buttons/Button';
|
|
4
|
+
import useClickOutside from '../../../hooks/useClickOutside';
|
|
5
|
+
import Action from '../Action';
|
|
6
|
+
import MenuItem from '../MenuItem';
|
|
7
|
+
import Popover from '../Popover';
|
|
8
|
+
function Menu({ actions, align, data, label, vAlign, }) {
|
|
9
|
+
const [isOpen, setIsOpen, ref] = useClickOutside();
|
|
10
|
+
function toggleIsOpen() {
|
|
11
|
+
setIsOpen(!isOpen);
|
|
12
|
+
}
|
|
13
|
+
return (_jsxs("div", { className: "relative", ref: ref, children: [_jsx(Button, { onClick: toggleIsOpen, children: label }), _jsx(Popover, { align: align, isOpen: isOpen, vAlign: vAlign, children: _jsx("ul", { children: actions.map((item, index) => (_jsx("li", { children: _jsx(Action, { ...item, data: data, render: MenuItem }) }, index))) }) })] }));
|
|
14
|
+
}
|
|
15
|
+
export default Menu;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ActionComponentProps } from '../Action';
|
|
2
|
+
type MenuItemProps<Data extends object | null = null> = ActionComponentProps<Data>;
|
|
3
|
+
declare function MenuItem<Data extends object | null = null>({ children, href, onClick, }: MenuItemProps<Data>): React.ReactElement;
|
|
4
|
+
export default MenuItem;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import Link from '../Link';
|
|
3
|
+
function MenuItem({ children, href, onClick, }) {
|
|
4
|
+
if (href) {
|
|
5
|
+
return (_jsx(Link, { href: href, onClick: onClick, children: children }));
|
|
6
|
+
}
|
|
7
|
+
return (_jsx("button", { onClick: onClick, type: "button", children: children }));
|
|
8
|
+
}
|
|
9
|
+
export default MenuItem;
|