@sqrzro/ui 4.0.0-alpha.13 → 4.0.0-alpha.14
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/Button/index.d.ts +1 -1
- package/dist/components/buttons/Button/index.js +4 -14
- package/dist/components/collections/DataTable/index.d.ts +1 -1
- package/dist/components/collections/DataTable/index.js +3 -3
- package/dist/components/collections/EmptyMessage/index.d.ts +1 -1
- package/dist/components/collections/EmptyMessage/index.js +3 -4
- package/dist/components/collections/ListItem/index.d.ts +1 -1
- package/dist/components/collections/ListItem/index.js +5 -5
- package/dist/components/collections/ListItemMeta/index.d.ts +1 -1
- package/dist/components/collections/ListItemMeta/index.js +3 -4
- 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/TableClientComponent/index.d.ts +1 -1
- package/dist/components/collections/TableClientComponent/index.js +4 -7
- package/dist/components/collections/TableRow/index.d.ts +12 -0
- package/dist/components/collections/TableRow/index.js +9 -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 +6 -0
- package/dist/components/index.js +3 -0
- package/dist/components/modals/Modal/index.d.ts +1 -1
- package/dist/components/modals/Modal/index.js +3 -3
- package/dist/components/modals/ModalActions/index.d.ts +1 -1
- package/dist/components/modals/ModalActions/index.js +3 -3
- package/dist/components/utility/ActionList/index.d.ts +1 -1
- package/dist/components/utility/ActionList/index.js +2 -2
- package/dist/components/utility/ClassNamesClientComponent/index.d.ts +6 -0
- package/dist/components/utility/ClassNamesClientComponent/index.js +7 -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/Popover/index.d.ts +1 -1
- package/dist/components/utility/Popover/index.js +4 -4
- package/dist/components/utility/RootLayout/index.d.ts +2 -2
- package/dist/components/utility/RootLayout/index.js +6 -5
- 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/forms/components/Autocomplete/index.d.ts +1 -1
- package/dist/forms/components/Dropdown/index.d.ts +1 -1
- package/dist/forms/components/Dropdown/index.js +7 -4
- 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 -10
- package/dist/forms/components/EditableForm/index.d.ts +1 -1
- 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 +1 -1
- package/dist/forms/components/Form/index.js +3 -3
- 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 +2 -2
- package/dist/forms/components/FormField/index.js +7 -6
- package/dist/forms/components/FormLabel/index.d.ts +1 -1
- package/dist/forms/components/FormLabel/index.js +3 -3
- package/dist/forms/components/NumberInput/index.d.ts +1 -1
- 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/StaticTextInput/index.d.ts +1 -1
- package/dist/forms/components/StaticTextInput/index.js +4 -7
- 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 +1 -1
- package/dist/forms/components/TextInput/index.js +4 -4
- package/dist/forms/hooks/useForm.js +1 -1
- package/dist/forms/index.d.ts +4 -2
- package/dist/forms/index.js +2 -1
- package/dist/navigation/components/AppNavigation/index.d.ts +1 -1
- package/dist/navigation/components/AppNavigation/index.js +2 -2
- package/dist/navigation/components/AppNavigationItem/index.d.ts +1 -1
- package/dist/navigation/components/AppNavigationItem/index.js +3 -4
- package/dist/navigation/components/Tabs/index.js +2 -2
- package/dist/navigation/hooks/useNavigation.js +5 -5
- package/dist/styles/classnames/config.d.ts +65 -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 +47 -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/package.json +2 -2
- 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 -66
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClassNameProps, StylableButtonClassName } from '../../../styles/interfaces';
|
|
1
|
+
import type { ClassNameProps, StylableButtonClassName } from '../../../styles/classnames/interfaces';
|
|
2
2
|
import { ButtonVariant } from '../../../utility/interfaces';
|
|
3
3
|
export interface ButtonClassNames {
|
|
4
4
|
root: StylableButtonClassName;
|
|
@@ -3,14 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useRef } from 'react';
|
|
4
4
|
import Link from '../../../components/utility/Link';
|
|
5
5
|
import Loader from '../../../components/utility/Loader';
|
|
6
|
-
import { getClassNames } from '../../../styles/
|
|
7
|
-
import tw from '../../../styles/tw';
|
|
8
|
-
function getVariantClassName(className, variant) {
|
|
9
|
-
if (!className || !variant) {
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
return className[variant] || null;
|
|
13
|
-
}
|
|
6
|
+
import { getClassNames } from '../../../styles/classnames';
|
|
7
|
+
import tw from '../../../styles/classnames/tw';
|
|
14
8
|
/**
|
|
15
9
|
* Either a `Link` component or a `button` element, depending on whether a `href` prop is specified.
|
|
16
10
|
*
|
|
@@ -32,12 +26,8 @@ function getVariantClassName(className, variant) {
|
|
|
32
26
|
*/
|
|
33
27
|
function Button({ children, classNames, classNameProps, form, hasAssistiveLabel, href, icon, id, isDisabled, isFullWidth, isLoading, isNewWindow, isText, name, onClick, popoverTarget, scroll, style, type, value, variant, }) {
|
|
34
28
|
const ref = useRef(null);
|
|
35
|
-
const componentClassNames = classNames
|
|
36
|
-
|
|
37
|
-
...(classNameProps || {}),
|
|
38
|
-
hasAssistiveLabel,
|
|
39
|
-
});
|
|
40
|
-
const className = tw('flex cursor-pointer items-center justify-center whitespace-nowrap', isDisabled || isLoading ? 'pointer-events-none opacity-30' : null, isFullWidth ? 'w-full' : null, componentClassNames?.root?.default, getVariantClassName(componentClassNames?.root, variant));
|
|
29
|
+
const componentClassNames = getClassNames(isText ? 'textButton' : 'button', { props: { ...classNameProps } }, classNames);
|
|
30
|
+
const className = tw('flex cursor-pointer items-center justify-center whitespace-nowrap', isDisabled || isLoading ? 'pointer-events-none opacity-30' : null, isFullWidth ? 'w-full' : null, componentClassNames?.root);
|
|
41
31
|
/*
|
|
42
32
|
* Link uses classNames, whereas button uses className. This is because Link can also be used
|
|
43
33
|
* headless in other applications, and so should have consistency.
|
|
@@ -1,8 +1,8 @@
|
|
|
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
|
function DataTable({ classNameProps, classNames, data }) {
|
|
5
|
-
const componentClassNames =
|
|
5
|
+
const componentClassNames = getClassNames('dataTable', { props: classNameProps }, classNames);
|
|
6
6
|
return (_jsx("table", { className: tw('w-full', componentClassNames?.root), children: _jsx("tbody", { children: data.map(({ label, value }, index) => (_jsxs("tr", { className: componentClassNames?.row, children: [_jsx("th", { className: tw(componentClassNames?.cell, componentClassNames?.label), children: label }), _jsx("td", { className: tw(componentClassNames?.cell, componentClassNames?.value), children: value })] }, index))) }) }));
|
|
7
7
|
}
|
|
8
8
|
export default DataTable;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClassNameProps, StylableClassName } from '../../../styles/interfaces';
|
|
1
|
+
import type { ClassNameProps, StylableClassName } from '../../../styles/classnames/interfaces';
|
|
2
2
|
import { StyleVariant } from '../../../utility/interfaces';
|
|
3
3
|
import type { EmptyMessageActionProps } from '../EmptyMessageAction';
|
|
4
4
|
export interface EmptyMessageClassNames {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { getClassNames } from '../../../styles/
|
|
4
|
-
import tw from '../../../styles/tw';
|
|
3
|
+
import { getClassNames } from '../../../styles/classnames';
|
|
5
4
|
import EmptyMessageAction from '../EmptyMessageAction';
|
|
6
5
|
export const DEFAULT_TITLE = 'No results found';
|
|
7
6
|
export const DEFAULT_CHILDREN = 'If you think this is an error, please contact the site administrator.';
|
|
@@ -11,7 +10,7 @@ export const DEFAULT_CHILDREN = 'If you think this is an error, please contact t
|
|
|
11
10
|
* component to be used for any situation where a standout message is required.
|
|
12
11
|
*/
|
|
13
12
|
function EmptyMessage({ action, children = DEFAULT_CHILDREN, classNameProps, classNames, icon, title = DEFAULT_TITLE, variant, }) {
|
|
14
|
-
const componentClassNames =
|
|
15
|
-
return (_jsxs("section", { className:
|
|
13
|
+
const componentClassNames = getClassNames('emptyMessage', { props: classNameProps }, classNames);
|
|
14
|
+
return (_jsxs("section", { className: componentClassNames?.root, children: [icon ? _jsx("div", { className: componentClassNames?.icon, children: icon }) : null, _jsx("h2", { className: componentClassNames?.title, children: title }), _jsx("div", { className: componentClassNames?.description, children: children }), action ? (_jsx("div", { className: componentClassNames?.action, children: _jsx(EmptyMessageAction, { action: action }) })) : null] }));
|
|
16
15
|
}
|
|
17
16
|
export default EmptyMessage;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClassNameProps, StylableClassName } from '../../../styles/interfaces';
|
|
1
|
+
import type { ClassNameProps, StylableClassName } from '../../../styles/classnames/interfaces';
|
|
2
2
|
import type { ListItemObject } from '../interfaces';
|
|
3
3
|
export interface ListItemClassNames {
|
|
4
4
|
description: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// import type { MenuAction } from '../../elements/MenuItem';
|
|
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
|
import Link from '../../../components/utility/Link';
|
|
6
6
|
import ListItemSecondary from '../ListItemSecondary';
|
|
7
7
|
import ListItemMeta from '../ListItemMeta';
|
|
@@ -17,12 +17,12 @@ function getLayout(layout) {
|
|
|
17
17
|
function ListItem({
|
|
18
18
|
// actions,
|
|
19
19
|
classNames, classNameProps, description, href, id, isLoading, meta, secondary, tertiary, title, variant, }) {
|
|
20
|
-
const componentClassNames =
|
|
20
|
+
const componentClassNames = getClassNames('listItem', { props: classNameProps }, classNames);
|
|
21
21
|
const hasPrimary = Boolean(title || description || meta);
|
|
22
22
|
const hasSecondary = Boolean(secondary);
|
|
23
23
|
const hasTertiary = Boolean(tertiary);
|
|
24
|
-
return (_jsx("li", { className: tw('@container relative grid', componentClassNames?.root
|
|
24
|
+
return (_jsx("li", { className: tw('@container relative grid', componentClassNames?.root, isLoading ? 'pointer-events-none animate-pulse' : null
|
|
25
25
|
// typeof actions === 'function' ? 'grid-cols-[1fr_auto] gap-4' : 'grid-cols-1'
|
|
26
|
-
), children: _jsx("article", { className: "contents", children: _jsxs("div", { className: tw('grid gap-x-6 gap-y-4', getLayout([hasPrimary, hasSecondary, hasTertiary])), children: [_jsxs("div", { className: componentClassNames?.primary, children: [title ? (_jsx("h2", { className:
|
|
26
|
+
), children: _jsx("article", { className: "contents", children: _jsxs("div", { className: tw('grid gap-x-6 gap-y-4', getLayout([hasPrimary, hasSecondary, hasTertiary])), children: [_jsxs("div", { className: componentClassNames?.primary, children: [title ? (_jsx("h2", { className: componentClassNames?.title, children: href ? (_jsx(Link, { className: "hover:text-link", href: href, children: title })) : (title) })) : null, description ? (_jsx("div", { className: componentClassNames?.description, children: description })) : null, _jsx(ListItemMeta, { classNameProps: classNameProps, data: meta?.data, id: id })] }), tertiary ? (_jsx("div", { className: componentClassNames?.tertiary, children: tertiary })) : null, _jsx(ListItemSecondary, { classNameProps: classNameProps, classNames: classNames, data: secondary?.data, variant: variant })] }) }) }));
|
|
27
27
|
}
|
|
28
28
|
export default ListItem;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { isValidElement } from 'react';
|
|
3
3
|
import { filterNull } from '@sqrzro/utility';
|
|
4
|
-
import { getClassNames } from '../../../styles/
|
|
5
|
-
import tw from '../../../styles/tw';
|
|
4
|
+
import { getClassNames } from '../../../styles/classnames';
|
|
6
5
|
function getKey(item) {
|
|
7
6
|
if (isValidElement(item)) {
|
|
8
7
|
return item.key || '-';
|
|
@@ -13,10 +12,10 @@ function getKey(item) {
|
|
|
13
12
|
return String(item);
|
|
14
13
|
}
|
|
15
14
|
function ListItemMeta({ classNameProps, classNames, id, data, }) {
|
|
16
|
-
const componentClassNames =
|
|
15
|
+
const componentClassNames = getClassNames('listItemMeta', { props: classNameProps }, classNames);
|
|
17
16
|
if (!data) {
|
|
18
17
|
return null;
|
|
19
18
|
}
|
|
20
|
-
return Array.isArray(data) ? (_jsx("ul", { className:
|
|
19
|
+
return Array.isArray(data) ? (_jsx("ul", { className: componentClassNames?.root, children: filterNull(data).map((item) => (_jsx("li", { className: "whitespace-nowrap", children: item }, getKey(item)))) })) : (_jsx("table", { className: "w-full", children: _jsx("tbody", { children: Object.entries(data).map(([key, value]) => (_jsxs("tr", { className: componentClassNames?.row, children: [_jsx("th", { className: componentClassNames?.title, children: key }), _jsx("td", { className: componentClassNames?.value, children: value || '-' })] }, key))) }) }));
|
|
21
20
|
}
|
|
22
21
|
export default ListItemMeta;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
2
2
|
import type { ListItemClassNames } from '../ListItem';
|
|
3
3
|
import type { ListItemObject } from '../interfaces';
|
|
4
4
|
export type ListItemSecondaryProps = ClassNameProps<ListItemClassNames> & ListItemObject['secondary'];
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { isValidElement } from 'react';
|
|
3
|
-
import { getClassNames } from '../../../styles/
|
|
4
|
-
import tw from '../../../styles/tw';
|
|
3
|
+
import { getClassNames } from '../../../styles/classnames';
|
|
5
4
|
import ListItemMeta from '../ListItemMeta';
|
|
6
5
|
function ListItemSecondary({ classNameProps, classNames, data, variant, }) {
|
|
7
|
-
const componentClassNames =
|
|
6
|
+
const componentClassNames = getClassNames('listItem', { props: classNameProps }, classNames);
|
|
8
7
|
if (!data) {
|
|
9
8
|
return null;
|
|
10
9
|
}
|
|
11
10
|
if (isValidElement(data)) {
|
|
12
11
|
return _jsx("div", { className: componentClassNames?.secondary, children: data });
|
|
13
12
|
}
|
|
14
|
-
return (_jsxs("div", { className: componentClassNames?.secondary, children: [data.title ?
|
|
13
|
+
return (_jsxs("div", { className: componentClassNames?.secondary, children: [data.title ? _jsx("p", { className: componentClassNames?.title, children: data.title }) : null, data.description ? (_jsx("div", { className: componentClassNames?.description, children: data.description })) : null, _jsx(ListItemMeta, { classNameProps: { ...classNameProps, isSecondary: true }, data: data.meta?.data, id: "secondary" })] }));
|
|
15
14
|
}
|
|
16
15
|
export default ListItemSecondary;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import usePagination from '../../../hooks/usePagination';
|
|
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 Link from '../../../components/utility/Link';
|
|
7
|
+
import PaginationLink from '../PaginationLink';
|
|
7
8
|
function Pagination({ classNames, classNameProps, gapLabel = '•••', limit, nextLabel, page, previousLabel, total, }) {
|
|
8
|
-
const componentClassNames =
|
|
9
|
+
const componentClassNames = getClassNames('pagination', { props: classNameProps }, classNames);
|
|
9
10
|
const { links, nextLink, pageCount, previousLink } = usePagination({ limit, page, total });
|
|
10
11
|
if (pageCount <= 1) {
|
|
11
12
|
return null;
|
|
12
13
|
}
|
|
13
|
-
return (_jsxs("nav", { className:
|
|
14
|
-
? componentClassNames?.link?.highlighted
|
|
15
|
-
: null), href: link.href, children: link.label })) : (_jsx("span", { className: tw(componentClassNames?.gap), children: gapLabel })) }, index))) }), nextLabel ? (_jsx(Link, { className: tw(componentClassNames?.navigation, page >= pageCount ? 'pointer-events-none opacity-30' : null), href: nextLink, children: nextLabel })) : null] }));
|
|
14
|
+
return (_jsxs("nav", { className: componentClassNames?.root, children: [previousLabel ? (_jsx(Link, { className: tw(componentClassNames?.navigation, page <= 1 ? 'pointer-events-none opacity-30' : null), href: previousLink, children: previousLabel })) : null, _jsx("ul", { className: componentClassNames?.list, children: links.map((link, index) => (_jsx("li", { className: componentClassNames?.item, children: link ? (_jsx(PaginationLink, { ...link, isCurrent: link.label === page.toString() })) : (_jsx("span", { className: componentClassNames?.gap, children: gapLabel })) }, index))) }), nextLabel ? (_jsx(Link, { className: tw(componentClassNames?.navigation, page >= pageCount ? 'pointer-events-none opacity-30' : null), href: nextLink, children: nextLabel })) : null] }));
|
|
16
15
|
}
|
|
17
16
|
export default Pagination;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
2
|
+
import type { PaginationClassNames } from '../Pagination';
|
|
3
|
+
interface PaginationLinkProps extends ClassNameProps<PaginationClassNames> {
|
|
4
|
+
href: string;
|
|
5
|
+
isCurrent: boolean;
|
|
6
|
+
label: string;
|
|
7
|
+
}
|
|
8
|
+
declare function PaginationLink({ classNameProps, classNames, href, isCurrent, label, }: PaginationLinkProps): React.ReactElement;
|
|
9
|
+
export default PaginationLink;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import Link from '../../../components/utility/Link';
|
|
3
|
+
import { getClassNames } from '../../../styles/classnames';
|
|
4
|
+
function PaginationLink({ classNameProps, classNames, href, isCurrent, label, }) {
|
|
5
|
+
const componentClassNames = getClassNames('pagination', { props: classNameProps, states: { isHighlighted: isCurrent } }, classNames);
|
|
6
|
+
return (_jsx(Link, { className: componentClassNames?.link, href: href, children: label }));
|
|
7
|
+
}
|
|
8
|
+
export default PaginationLink;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClassNameProps, SelectableClassName } from '../../../styles/interfaces';
|
|
1
|
+
import { ClassNameProps, SelectableClassName } from '../../../styles/classnames/interfaces';
|
|
2
2
|
import type { TableColumnObject, TableItemObject } from '../interfaces';
|
|
3
3
|
export interface TableClassNames {
|
|
4
4
|
root: string;
|
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { toggleArrayItem } from '@sqrzro/utility';
|
|
4
4
|
import { useSearchParams } from 'next/navigation';
|
|
5
|
-
import Switch from '../../../forms/components/Switch';
|
|
6
5
|
import useSearchParamsHref from '../../../hooks/useSearchParamsHref';
|
|
7
|
-
import { getClassNames } from '../../../styles/
|
|
8
|
-
import tw from '../../../styles/tw';
|
|
6
|
+
import { getClassNames } from '../../../styles/classnames';
|
|
9
7
|
import filterColumns from '../utility/filter-columns';
|
|
10
8
|
import getSelectedFromSearchParams from '../utility/get-selected-from-search-params';
|
|
11
9
|
import setSelectedToSearchParams from '../utility/set-selected-to-search-params';
|
|
10
|
+
import TableRow from '../TableRow';
|
|
12
11
|
function TableClientComponent({ classNameProps, classNames, columns, data, isSelectable, }) {
|
|
13
|
-
const componentClassNames =
|
|
12
|
+
const componentClassNames = getClassNames('table', { props: classNameProps }, classNames);
|
|
14
13
|
const { setSearchParamsHref } = useSearchParamsHref();
|
|
15
14
|
const searchParams = useSearchParams();
|
|
16
15
|
const filteredColumns = filterColumns(columns, isSelectable);
|
|
@@ -23,8 +22,6 @@ function TableClientComponent({ classNameProps, classNames, columns, data, isSel
|
|
|
23
22
|
const value = selected.length === data.length ? [] : data.map((item) => item.id);
|
|
24
23
|
setSearchParamsHref({ selected: setSelectedToSearchParams(value) });
|
|
25
24
|
}
|
|
26
|
-
return (_jsx("div", { className: componentClassNames?.root, children: _jsxs("table", { className: "w-full", children: [_jsx("thead", { children: _jsx("tr", { children: filteredColumns.map((column) => (_jsx("th", { children: column.type === 'selectable' ? (_jsxs("button", { name: column.id, onClick: handleSelectAll, children: ["Select All ", selected.includes(column.id) ? '✓' : ''] })) : (column.title) }, column.id))) }) }), _jsx("tbody", { children: data.map((item) => (_jsx(
|
|
27
|
-
? componentClassNames?.row?.selected
|
|
28
|
-
: null), children: filteredColumns.map((column) => (_jsx("td", { className: tw(componentClassNames?.cell, column.type === 'selectable' ? 'w-1' : null), children: column.type === 'selectable' ? (_jsx(Switch, { name: item.id, onChange: handleSelect, value: selected.includes(item.id) })) : (item[column.id]) }, column.id))) }, item.id))) })] }) }));
|
|
25
|
+
return (_jsx("div", { className: componentClassNames?.root, children: _jsxs("table", { className: "w-full", children: [_jsx("thead", { children: _jsx("tr", { children: filteredColumns.map((column) => (_jsx("th", { children: column.type === 'selectable' ? (_jsxs("button", { name: column.id, onClick: handleSelectAll, children: ["Select All ", selected.includes(column.id) ? '✓' : ''] })) : (column.title) }, column.id))) }) }), _jsx("tbody", { children: data.map((item) => (_jsx(TableRow, { columns: filteredColumns, data: item, isSelected: selected.includes(item.id), onSelect: handleSelect }, item.id))) })] }) }));
|
|
29
26
|
}
|
|
30
27
|
export default TableClientComponent;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { InputEvent } from '../../../forms/interfaces';
|
|
2
|
+
import type { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
3
|
+
import { TableClassNames } from '../TableClientComponent';
|
|
4
|
+
import type { TableColumnObject, TableItemObject } from '../interfaces';
|
|
5
|
+
interface TableRowProps extends ClassNameProps<TableClassNames> {
|
|
6
|
+
columns: TableColumnObject[];
|
|
7
|
+
data: TableItemObject;
|
|
8
|
+
isSelected: boolean;
|
|
9
|
+
onSelect: (event: InputEvent<boolean>) => void;
|
|
10
|
+
}
|
|
11
|
+
declare function TableRow({ classNameProps, classNames, columns, data, isSelected, onSelect, }: TableRowProps): React.ReactElement;
|
|
12
|
+
export default TableRow;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import Switch from '../../../forms/components/Switch';
|
|
3
|
+
import { getClassNames } from '../../../styles/classnames';
|
|
4
|
+
import tw from '../../../styles/classnames/tw';
|
|
5
|
+
function TableRow({ classNameProps, classNames, columns, data, isSelected, onSelect, }) {
|
|
6
|
+
const componentClassNames = getClassNames('table', { props: classNameProps, states: { isSelected } }, classNames);
|
|
7
|
+
return (_jsx("tr", { className: componentClassNames?.row, children: columns.map((column) => (_jsx("td", { className: tw(componentClassNames?.cell, column.type === 'selectable' ? 'w-1' : null), children: column.type === 'selectable' ? (_jsx(Switch, { name: data.id, onChange: onSelect, value: isSelected })) : (data[column.id]) }, column.id))) }));
|
|
8
|
+
}
|
|
9
|
+
export default TableRow;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
2
|
+
import type { Action } 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?: Action;
|
|
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;
|
|
@@ -9,6 +9,12 @@ export type { ListProps } from './collections/List';
|
|
|
9
9
|
export { default as List } from './collections/List';
|
|
10
10
|
export type { TableProps } from './collections/Table';
|
|
11
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';
|
|
12
18
|
export type { ConfirmModalProps } from './modals/ConfirmModal';
|
|
13
19
|
export { default as ConfirmModal } from './modals/ConfirmModal';
|
|
14
20
|
export type { ModalProps } from './modals/Modal';
|
package/dist/components/index.js
CHANGED
|
@@ -4,6 +4,9 @@ export { default as Button } from './buttons/Button';
|
|
|
4
4
|
export { default as DataTable } from './collections/DataTable';
|
|
5
5
|
export { default as List } from './collections/List';
|
|
6
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';
|
|
7
10
|
export { default as ConfirmModal } from './modals/ConfirmModal';
|
|
8
11
|
export { default as Modal } from './modals/Modal';
|
|
9
12
|
export { default as ModalLauncher } from './modals/ModalLauncher';
|
|
@@ -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,4 +1,4 @@
|
|
|
1
|
-
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
2
2
|
import { Action } from '../../../utility/interfaces';
|
|
3
3
|
import type { ModalClassNames } from '../Modal';
|
|
4
4
|
export interface ModalActionsProps extends ClassNameProps<ModalClassNames> {
|
|
@@ -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;
|
|
@@ -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 =
|
|
6
|
+
const componentClassNames = getClassNames('actionList', { props: classNameProps }, classNames);
|
|
7
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.isDisabled) }) }, 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;
|
|
@@ -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;
|