@sqrzro/ui 4.0.0-alpha.0 → 4.0.0-alpha.2
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 +7 -0
- package/dist/components/buttons/ActionButton/index.js +33 -0
- package/dist/components/buttons/Button/index.d.ts +65 -0
- package/dist/components/buttons/Button/index.js +50 -0
- package/dist/components/buttons/ConfirmableButton/index.d.ts +7 -0
- package/dist/components/buttons/ConfirmableButton/index.js +13 -0
- package/dist/components/buttons/TextButton/index.d.ts +5 -0
- package/dist/components/buttons/TextButton/index.js +6 -0
- package/dist/components/collections/Collection/index.d.ts +15 -0
- package/dist/components/collections/Collection/index.js +45 -0
- package/dist/components/collections/EmptyMessage/index.d.ts +26 -0
- package/dist/components/collections/EmptyMessage/index.js +17 -0
- package/dist/components/collections/EmptyMessageAction/index.d.ts +6 -0
- package/dist/components/collections/EmptyMessageAction/index.js +19 -0
- package/dist/components/collections/List/index.d.ts +6 -0
- package/dist/components/collections/List/index.js +13 -0
- package/dist/components/collections/ListClientComponent/index.d.ts +7 -0
- package/dist/components/collections/ListClientComponent/index.js +9 -0
- package/dist/components/collections/ListItem/index.d.ts +14 -0
- package/dist/components/collections/ListItem/index.js +28 -0
- package/dist/components/collections/ListItemMeta/index.d.ts +11 -0
- package/dist/components/collections/ListItemMeta/index.js +22 -0
- package/dist/components/collections/ListItemSecondary/index.d.ts +6 -0
- package/dist/components/collections/ListItemSecondary/index.js +16 -0
- package/dist/components/collections/Pagination/index.d.ts +19 -0
- package/dist/components/collections/Pagination/index.js +17 -0
- package/dist/components/collections/Table/index.d.ts +9 -0
- package/dist/components/collections/Table/index.js +13 -0
- package/dist/components/collections/TableClientComponent/index.d.ts +14 -0
- package/dist/components/collections/TableClientComponent/index.js +30 -0
- package/dist/components/collections/interfaces.d.ts +57 -0
- package/dist/components/collections/interfaces.js +1 -0
- package/dist/components/collections/lang.d.ts +4 -0
- package/dist/components/collections/lang.js +4 -0
- package/dist/components/collections/utility/filter-columns.d.ts +3 -0
- package/dist/components/collections/utility/filter-columns.js +8 -0
- package/dist/components/collections/utility/get-selected-from-search-params.d.ts +2 -0
- package/dist/components/collections/utility/get-selected-from-search-params.js +5 -0
- package/dist/components/collections/utility/is-paginated.d.ts +3 -0
- package/dist/components/collections/utility/is-paginated.js +4 -0
- package/dist/components/collections/utility/set-selected-to-search-params.d.ts +2 -0
- package/dist/components/collections/utility/set-selected-to-search-params.js +4 -0
- package/dist/components/index.d.ts +16 -0
- package/dist/components/index.js +9 -0
- package/dist/components/modals/ConfirmModal/index.d.ts +7 -0
- package/dist/components/modals/ConfirmModal/index.js +23 -0
- package/dist/components/modals/Modal/index.d.ts +19 -0
- package/dist/components/modals/Modal/index.js +17 -0
- package/dist/components/modals/ModalActions/index.d.ts +9 -0
- package/dist/components/modals/ModalActions/index.js +8 -0
- package/dist/components/modals/ModalLauncher/index.d.ts +5 -0
- package/dist/components/modals/ModalLauncher/index.js +14 -0
- package/dist/components/utility/ActionList/index.d.ts +12 -0
- package/dist/components/utility/ActionList/index.js +9 -0
- package/dist/components/utility/Assistive/index.d.ts +8 -0
- package/dist/components/utility/Assistive/index.js +8 -0
- package/dist/components/utility/ClassNames/index.d.ts +6 -0
- package/dist/components/utility/ClassNames/index.js +7 -0
- package/dist/components/utility/Container/index.d.ts +9 -0
- package/dist/components/utility/Container/index.js +8 -0
- package/dist/components/utility/Link/index.d.ts +19 -0
- package/dist/components/utility/Link/index.js +33 -0
- package/dist/components/utility/Loader/index.d.ts +8 -0
- package/dist/components/utility/Loader/index.js +9 -0
- package/dist/components/utility/Page/index.d.ts +18 -0
- package/dist/components/utility/Page/index.js +34 -0
- package/dist/components/utility/Popover/index.d.ts +14 -0
- package/dist/components/utility/Popover/index.js +71 -0
- package/dist/components/utility/RootLayout/index.d.ts +12 -0
- package/dist/components/utility/RootLayout/index.js +14 -0
- package/dist/components/utility/Toast/index.d.ts +11 -0
- package/dist/components/utility/Toast/index.js +11 -0
- package/dist/components/utility/Toaster/index.d.ts +8 -0
- package/dist/components/utility/Toaster/index.js +57 -0
- package/dist/filters/components/FilterBar/index.d.ts +9 -0
- package/dist/filters/components/FilterBar/index.js +9 -0
- package/dist/filters/components/FilterBarClientComponent/index.d.ts +12 -0
- package/dist/filters/components/FilterBarClientComponent/index.js +68 -0
- package/dist/filters/components/FilterClearButton/index.d.ts +5 -0
- package/dist/filters/components/FilterClearButton/index.js +6 -0
- package/dist/filters/components/FilterControl/index.d.ts +12 -0
- package/dist/filters/components/FilterControl/index.js +10 -0
- package/dist/filters/components/FilterItem/index.d.ts +14 -0
- package/dist/filters/components/FilterItem/index.js +43 -0
- package/dist/filters/components/FilterPanel/index.d.ts +19 -0
- package/dist/filters/components/FilterPanel/index.js +36 -0
- package/dist/filters/filters/BooleanFilter/index.d.ts +3 -0
- package/dist/filters/filters/BooleanFilter/index.js +10 -0
- package/dist/filters/filters/CalendarFilter/index.d.ts +3 -0
- package/dist/filters/filters/CalendarFilter/index.js +10 -0
- package/dist/filters/filters/DateFilter/index.d.ts +3 -0
- package/dist/filters/filters/DateFilter/index.js +21 -0
- package/dist/filters/filters/DropdownFilter/index.d.ts +3 -0
- package/dist/filters/filters/DropdownFilter/index.js +10 -0
- package/dist/filters/filters/Filter/index.d.ts +16 -0
- package/dist/filters/filters/Filter/index.js +13 -0
- package/dist/filters/filters/MultiFilter/index.d.ts +3 -0
- package/dist/filters/filters/MultiFilter/index.js +9 -0
- package/dist/filters/filters/SearchFilter/index.d.ts +4 -0
- package/dist/filters/filters/SearchFilter/index.js +30 -0
- package/dist/filters/filters/interfaces.d.ts +10 -0
- package/dist/filters/filters/interfaces.js +1 -0
- package/dist/filters/hooks/useFilters.d.ts +5 -0
- package/dist/filters/hooks/useFilters.js +25 -0
- package/dist/filters/index.d.ts +2 -0
- package/dist/filters/index.js +2 -0
- package/dist/filters/interfaces.d.ts +28 -0
- package/dist/filters/interfaces.js +1 -0
- package/dist/filters/lang.d.ts +1 -0
- package/dist/filters/lang.js +1 -0
- package/dist/filters/utility/check-has-filters.d.ts +2 -0
- package/dist/filters/utility/check-has-filters.js +8 -0
- package/dist/filters/utility/create-client-filter-map.d.ts +3 -0
- package/dist/filters/utility/create-client-filter-map.js +14 -0
- package/dist/filters/utility/filter.d.ts +16 -0
- package/dist/filters/utility/filter.js +120 -0
- package/dist/filters/utility/get-quick-dates.d.ts +3 -0
- package/dist/filters/utility/get-quick-dates.js +90 -0
- package/dist/filters/utility/parse-filters.d.ts +3 -0
- package/dist/filters/utility/parse-filters.js +16 -0
- package/dist/filters/utility/parse-page.d.ts +2 -0
- package/dist/filters/utility/parse-page.js +8 -0
- package/dist/filters/utility/render-value.d.ts +3 -0
- package/dist/filters/utility/render-value.js +57 -0
- package/dist/filters/utility/transform-boolean.d.ts +2 -0
- package/dist/filters/utility/transform-boolean.js +10 -0
- package/dist/filters/utility/transform-date.d.ts +2 -0
- package/dist/filters/utility/transform-date.js +29 -0
- package/dist/filters/utility/transform-multi.d.ts +2 -0
- package/dist/filters/utility/transform-multi.js +9 -0
- package/dist/forms/components/Dropdown/index.d.ts +22 -0
- package/dist/forms/components/Dropdown/index.js +41 -0
- package/dist/forms/components/DropdownList/index.d.ts +8 -0
- package/dist/forms/components/DropdownList/index.js +20 -0
- package/dist/forms/components/EditableForm/index.d.ts +24 -0
- package/dist/forms/components/EditableForm/index.js +23 -0
- package/dist/forms/components/EditableFormField/index.d.ts +14 -0
- package/dist/forms/components/EditableFormField/index.js +37 -0
- package/dist/forms/components/EditableFormFields/index.d.ts +7 -0
- package/dist/forms/components/EditableFormFields/index.js +20 -0
- package/dist/forms/components/Form/index.d.ts +12 -0
- package/dist/forms/components/Form/index.js +9 -0
- package/dist/forms/components/FormError/index.d.ts +9 -0
- package/dist/forms/components/FormError/index.js +8 -0
- package/dist/forms/components/FormField/index.d.ts +25 -0
- package/dist/forms/components/FormField/index.js +37 -0
- package/dist/forms/components/FormFields/index.d.ts +10 -0
- package/dist/forms/components/FormFields/index.js +22 -0
- package/dist/forms/components/FormLabel/index.d.ts +10 -0
- package/dist/forms/components/FormLabel/index.js +8 -0
- package/dist/forms/components/FormSubmit/index.d.ts +4 -0
- package/dist/forms/components/FormSubmit/index.js +9 -0
- package/dist/forms/components/ModalForm/index.d.ts +13 -0
- package/dist/forms/components/ModalForm/index.js +25 -0
- package/dist/forms/components/PasswordInput/index.d.ts +11 -0
- package/dist/forms/components/PasswordInput/index.js +17 -0
- package/dist/forms/components/StaticTextInput/index.d.ts +22 -0
- package/dist/forms/components/StaticTextInput/index.js +22 -0
- package/dist/forms/components/Switch/index.d.ts +11 -0
- package/dist/forms/components/Switch/index.js +17 -0
- package/dist/forms/components/TextInput/index.d.ts +34 -0
- package/dist/forms/components/TextInput/index.js +30 -0
- package/dist/forms/hooks/useDropdown.d.ts +10 -0
- package/dist/forms/hooks/useDropdown.js +14 -0
- package/dist/forms/hooks/useEditableForm.d.ts +24 -0
- package/dist/forms/hooks/useEditableForm.js +34 -0
- package/dist/forms/hooks/useForm.d.ts +136 -0
- package/dist/forms/hooks/useForm.js +209 -0
- package/dist/forms/hooks/useModalForm.d.ts +14 -0
- package/dist/forms/hooks/useModalForm.js +29 -0
- package/dist/forms/index.d.ts +27 -0
- package/dist/forms/index.js +17 -0
- package/dist/forms/interfaces.d.ts +32 -0
- package/dist/forms/interfaces.js +1 -0
- package/dist/forms/utility/extract-editable-input-props.d.ts +8 -0
- package/dist/forms/utility/extract-editable-input-props.js +19 -0
- package/dist/forms/utility/extract-input-props.d.ts +9 -0
- package/dist/forms/utility/extract-input-props.js +37 -0
- package/dist/hooks/index.d.ts +0 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useClickOutside.d.ts +93 -0
- package/dist/hooks/useClickOutside.js +124 -0
- package/dist/hooks/usePagination.d.ts +17 -0
- package/dist/hooks/usePagination.js +46 -0
- package/dist/hooks/useSearchParamsHref.d.ts +6 -0
- package/dist/hooks/useSearchParamsHref.js +33 -0
- package/dist/hooks/useToast.d.ts +18 -0
- package/dist/hooks/useToast.js +25 -0
- package/dist/navigation/components/AppNavigation/index.d.ts +13 -0
- package/dist/navigation/components/AppNavigation/index.js +15 -0
- package/dist/navigation/components/AppNavigationItem/index.d.ts +6 -0
- package/dist/navigation/components/AppNavigationItem/index.js +9 -0
- package/dist/navigation/components/Tabs/index.d.ts +7 -0
- package/dist/navigation/components/Tabs/index.js +9 -0
- package/dist/navigation/hooks/useNavigation.d.ts +10 -0
- package/dist/navigation/hooks/useNavigation.js +38 -0
- package/dist/navigation/index.d.ts +5 -0
- package/dist/navigation/index.js +3 -0
- package/dist/navigation/interfaces.d.ts +7 -0
- package/dist/navigation/interfaces.js +1 -0
- package/dist/styles/config.d.ts +64 -0
- package/dist/styles/config.js +43 -0
- package/dist/styles/icons.d.ts +15 -0
- package/dist/styles/icons.js +7 -0
- package/dist/styles/index.d.ts +2 -0
- package/dist/styles/index.js +1 -0
- package/dist/styles/interfaces.d.ts +41 -0
- package/dist/styles/interfaces.js +1 -0
- package/dist/styles/tw.d.ts +9 -0
- package/dist/styles/tw.js +15 -0
- package/dist/utility/index.d.ts +1 -0
- package/dist/utility/index.js +1 -0
- package/dist/utility/interfaces.d.ts +35 -0
- package/dist/utility/interfaces.js +1 -1
- package/package.json +55 -8
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -1
- package/dist/lists/List/index.d.ts +0 -5
- package/dist/lists/List/index.js +0 -6
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Action, StyleVariant } from '../../utility/interfaces';
|
|
2
|
+
export interface CollectionFunctionConfig<Filters = null> {
|
|
3
|
+
filters?: Partial<Filters> | null;
|
|
4
|
+
params?: Record<string, string> | null;
|
|
5
|
+
page?: number | null;
|
|
6
|
+
}
|
|
7
|
+
export type ListFunctionConfig<Filters = null> = CollectionFunctionConfig<Filters>;
|
|
8
|
+
export interface ListItemObject<Data extends object | null = null> {
|
|
9
|
+
$data?: Data;
|
|
10
|
+
actions?: Action[];
|
|
11
|
+
description?: React.ReactNode | null;
|
|
12
|
+
href?: string;
|
|
13
|
+
id: string;
|
|
14
|
+
isMinimal?: boolean;
|
|
15
|
+
image?: string | null;
|
|
16
|
+
imageHref?: string | null;
|
|
17
|
+
isLoading?: boolean;
|
|
18
|
+
meta?: {
|
|
19
|
+
data?: React.ReactNode[] | Record<string, React.ReactNode>;
|
|
20
|
+
id: string;
|
|
21
|
+
};
|
|
22
|
+
permission?: string;
|
|
23
|
+
secondary?: {
|
|
24
|
+
data?: React.ReactElement | {
|
|
25
|
+
description?: string;
|
|
26
|
+
meta?: {
|
|
27
|
+
data?: React.ReactNode[] | Record<string, React.ReactNode>;
|
|
28
|
+
id: string;
|
|
29
|
+
};
|
|
30
|
+
title?: string;
|
|
31
|
+
} | null;
|
|
32
|
+
variant?: StyleVariant | null;
|
|
33
|
+
};
|
|
34
|
+
tertiary?: React.ReactNode;
|
|
35
|
+
title?: React.ReactNode;
|
|
36
|
+
variant?: StyleVariant | null;
|
|
37
|
+
}
|
|
38
|
+
export type TableFunctionConfig<Filters = null> = CollectionFunctionConfig<Filters>;
|
|
39
|
+
export interface TableItemObject {
|
|
40
|
+
[key: string]: React.ReactNode;
|
|
41
|
+
id: string;
|
|
42
|
+
}
|
|
43
|
+
export type TableColumnType = 'date' | 'decimal' | 'id' | 'link' | 'money' | 'number' | 'percentage' | 'reference' | 'selectable' | 'string';
|
|
44
|
+
export interface TableColumnObject {
|
|
45
|
+
isSortable?: boolean;
|
|
46
|
+
id: string;
|
|
47
|
+
title?: string;
|
|
48
|
+
type?: TableColumnType;
|
|
49
|
+
}
|
|
50
|
+
export interface Paginated<T> {
|
|
51
|
+
data: T[];
|
|
52
|
+
meta: {
|
|
53
|
+
limit: number;
|
|
54
|
+
page: number;
|
|
55
|
+
total: number;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './collections/interfaces';
|
|
2
|
+
export { default as ActionButton } from './buttons/ActionButton';
|
|
3
|
+
export type { ListProps } from './collections/List';
|
|
4
|
+
export { default as List } from './collections/List';
|
|
5
|
+
export type { TableProps } from './collections/Table';
|
|
6
|
+
export { default as Table } from './collections/Table';
|
|
7
|
+
export type { ModalLauncherProps } from './modals/ModalLauncher';
|
|
8
|
+
export { default as ModalLauncher } from './modals/ModalLauncher';
|
|
9
|
+
export type { ContainerProps } from './utility/Container';
|
|
10
|
+
export { default as Container } from './utility/Container';
|
|
11
|
+
export type { LinkProps } from './utility/Link';
|
|
12
|
+
export { default as Link } from './utility/Link';
|
|
13
|
+
export type { PageProps } from './utility/Page';
|
|
14
|
+
export { default as Page } from './utility/Page';
|
|
15
|
+
export type { RootLayoutProps } from './utility/RootLayout';
|
|
16
|
+
export { default as RootLayout } from './utility/RootLayout';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './collections/interfaces';
|
|
2
|
+
export { default as ActionButton } from './buttons/ActionButton';
|
|
3
|
+
export { default as List } from './collections/List';
|
|
4
|
+
export { default as Table } from './collections/Table';
|
|
5
|
+
export { default as ModalLauncher } from './modals/ModalLauncher';
|
|
6
|
+
export { default as Container } from './utility/Container';
|
|
7
|
+
export { default as Link } from './utility/Link';
|
|
8
|
+
export { default as Page } from './utility/Page';
|
|
9
|
+
export { default as RootLayout } from './utility/RootLayout';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConfirmableObject } from '../../../utility/interfaces';
|
|
2
|
+
import type { ModalProps } from '../Modal';
|
|
3
|
+
export type ConfirmModalProps = Omit<ModalProps, 'children' | 'icon' | 'title'> & {
|
|
4
|
+
confirmable: ConfirmableObject;
|
|
5
|
+
};
|
|
6
|
+
declare function ConfirmModal({ confirmable, ...modalProps }: Readonly<ConfirmModalProps>): React.ReactElement;
|
|
7
|
+
export default ConfirmModal;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Fragment, useState } from 'react';
|
|
4
|
+
import TextInput from '../../../forms/components/TextInput';
|
|
5
|
+
import Modal from '../Modal';
|
|
6
|
+
function ConfirmModal({ confirmable, ...modalProps }) {
|
|
7
|
+
const [confirmText, setConfirmText] = useState('');
|
|
8
|
+
function handleChange(event) {
|
|
9
|
+
setConfirmText(event.target.value?.toUpperCase() || '');
|
|
10
|
+
}
|
|
11
|
+
return (_jsxs(Modal, { ...modalProps, actions: [
|
|
12
|
+
{ label: 'Cancel', variant: 'link' },
|
|
13
|
+
...(confirmable.actions || []),
|
|
14
|
+
{
|
|
15
|
+
isDisabled: Boolean(confirmable.confirmText &&
|
|
16
|
+
confirmText !== confirmable.confirmText.toUpperCase()),
|
|
17
|
+
label: confirmable.submitLabel || 'Confirm',
|
|
18
|
+
onClick: confirmable.onConfirm,
|
|
19
|
+
variant: 'primary',
|
|
20
|
+
},
|
|
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] }));
|
|
22
|
+
}
|
|
23
|
+
export default ConfirmModal;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
2
|
+
import { Action } from '../../../utility/interfaces';
|
|
3
|
+
export interface ModalClassNames {
|
|
4
|
+
actions: string;
|
|
5
|
+
content: string;
|
|
6
|
+
icon: string;
|
|
7
|
+
panel: string;
|
|
8
|
+
root: string;
|
|
9
|
+
title: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ModalProps extends ClassNameProps<ModalClassNames> {
|
|
12
|
+
actions?: Action[];
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
icon?: React.ReactNode;
|
|
15
|
+
isLoading?: boolean;
|
|
16
|
+
title?: string;
|
|
17
|
+
}
|
|
18
|
+
declare function Modal({ actions, children, classNames, classNameProps, icon, isLoading, title, }: Readonly<ModalProps>): React.ReactElement | null;
|
|
19
|
+
export default Modal;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
|
+
import { getClassNames } from '../../../styles/config';
|
|
5
|
+
import tw from '../../../styles/tw';
|
|
6
|
+
import ModalActions from '../ModalActions';
|
|
7
|
+
function Modal({ actions, children, classNames, classNameProps, icon, isLoading, title, }) {
|
|
8
|
+
const componentClassNames = classNames || getClassNames('modal')?.(classNameProps);
|
|
9
|
+
const ref = useRef(null);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (ref.current) {
|
|
12
|
+
ref.current.showModal();
|
|
13
|
+
}
|
|
14
|
+
}, []);
|
|
15
|
+
return (_jsx("dialog", { ref: ref, className: tw('m-0 h-full max-h-none w-full max-w-none bg-transparent p-0', componentClassNames?.root), children: _jsxs("div", { className: componentClassNames?.panel, children: [title ? (_jsxs("h3", { className: componentClassNames?.title, children: [icon ? _jsx("span", { className: componentClassNames?.icon, children: icon }) : null, _jsx("span", { children: title })] })) : null, _jsx("div", { className: componentClassNames?.content, children: children }), actions ? (_jsx(ModalActions, { actions: actions, classNameProps: classNameProps, isLoading: isLoading })) : null] }) }));
|
|
16
|
+
}
|
|
17
|
+
export default Modal;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
2
|
+
import { Action } from '../../../utility/interfaces';
|
|
3
|
+
import type { ModalClassNames } from '../Modal';
|
|
4
|
+
export interface ModalActionsProps extends ClassNameProps<ModalClassNames> {
|
|
5
|
+
actions: (Action | null)[];
|
|
6
|
+
isLoading?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare function ModalActions({ actions, classNameProps, classNames, isLoading, }: Readonly<ModalActionsProps>): React.ReactElement;
|
|
9
|
+
export default ModalActions;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import ActionList from '../../../components/utility/ActionList';
|
|
3
|
+
import { getClassNames } from '../../../styles/config';
|
|
4
|
+
function ModalActions({ actions, classNameProps, classNames, isLoading, }) {
|
|
5
|
+
const componentClassNames = classNames || getClassNames('modal')?.(classNameProps);
|
|
6
|
+
return (_jsx("footer", { className: componentClassNames?.actions, children: _jsx(ActionList, { actions: actions, classNameProps: { ...(classNameProps || {}), isModal: true }, isLoading: isLoading }) }));
|
|
7
|
+
}
|
|
8
|
+
export default ModalActions;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* eslint-disable react/no-multi-comp */
|
|
2
|
+
'use client';
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
import { Suspense } from 'react';
|
|
5
|
+
import { useSearchParams } from 'next/navigation';
|
|
6
|
+
function ModalLauncherComponent({ data }) {
|
|
7
|
+
const searchParams = useSearchParams();
|
|
8
|
+
const action = searchParams.get('action');
|
|
9
|
+
return action && action in data ? data[action] : null;
|
|
10
|
+
}
|
|
11
|
+
function ModalLauncher(props) {
|
|
12
|
+
return (_jsx(Suspense, { children: _jsx(ModalLauncherComponent, { ...props }) }));
|
|
13
|
+
}
|
|
14
|
+
export default ModalLauncher;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
2
|
+
import { Action } from '../../../utility/interfaces';
|
|
3
|
+
export interface ActionListClassNames {
|
|
4
|
+
root: string;
|
|
5
|
+
item: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ActionListProps extends ClassNameProps<ActionListClassNames> {
|
|
8
|
+
actions: (Action | null)[];
|
|
9
|
+
isLoading?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare function ActionList({ actions, classNameProps, classNames, isLoading, }: Readonly<ActionListProps>): React.ReactElement;
|
|
12
|
+
export default ActionList;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { filterNull } from '@sqrzro/utility';
|
|
3
|
+
import ActionButton from '../../../components/buttons/ActionButton';
|
|
4
|
+
import { getClassNames } from '../../../styles/config';
|
|
5
|
+
function ActionList({ actions, classNameProps, classNames, isLoading, }) {
|
|
6
|
+
const componentClassNames = classNames || getClassNames('actionList')?.(classNameProps);
|
|
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
|
+
}
|
|
9
|
+
export default ActionList;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
2
|
+
export interface ContainerClassNames {
|
|
3
|
+
root: string;
|
|
4
|
+
}
|
|
5
|
+
export interface ContainerProps extends ClassNameProps<ContainerClassNames> {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
declare function Container({ children, classNameProps, classNames, }: Readonly<ContainerProps>): React.ReactElement;
|
|
9
|
+
export default Container;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { getClassNames } from '../../../styles/config';
|
|
4
|
+
function Container({ children, classNameProps, classNames, }) {
|
|
5
|
+
const componentClassNames = classNames || getClassNames('container')?.(classNameProps);
|
|
6
|
+
return _jsx("div", { className: componentClassNames?.root, children: children });
|
|
7
|
+
}
|
|
8
|
+
export default Container;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
2
|
+
interface DataProps {
|
|
3
|
+
'data-test-id'?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface LinkClassNames {
|
|
6
|
+
root: string;
|
|
7
|
+
}
|
|
8
|
+
export interface LinkProps extends ClassNameProps<LinkClassNames>, DataProps {
|
|
9
|
+
className?: string;
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
href?: string | null;
|
|
12
|
+
id?: string;
|
|
13
|
+
isNewWindow?: boolean;
|
|
14
|
+
onClick?: React.MouseEventHandler<HTMLAnchorElement>;
|
|
15
|
+
scroll?: boolean;
|
|
16
|
+
style?: React.CSSProperties;
|
|
17
|
+
}
|
|
18
|
+
declare function Link({ children, className, classNames, classNameProps, isNewWindow, href, id, onClick, scroll, style, ...dataProps }: Readonly<LinkProps>): React.ReactElement;
|
|
19
|
+
export default Link;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import NextLink from 'next/link';
|
|
3
|
+
import { getClassNames } from '../../../styles/config';
|
|
4
|
+
import tw from '../../../styles/tw';
|
|
5
|
+
function normalizeHref(href) {
|
|
6
|
+
if (!href) {
|
|
7
|
+
return '';
|
|
8
|
+
}
|
|
9
|
+
if (href.startsWith('#')) {
|
|
10
|
+
return href;
|
|
11
|
+
}
|
|
12
|
+
return /^\//u.exec(href) ? href : `/${href}`;
|
|
13
|
+
}
|
|
14
|
+
function Link({ children, className, classNames, classNameProps, isNewWindow, href = '/', id, onClick, scroll, style, ...dataProps }) {
|
|
15
|
+
const componentClassNames = classNames || getClassNames('link')?.(classNameProps);
|
|
16
|
+
const newWindowProps = isNewWindow
|
|
17
|
+
? { rel: 'noopener noreferrer', target: '_blank' }
|
|
18
|
+
: {};
|
|
19
|
+
const props = {
|
|
20
|
+
...newWindowProps,
|
|
21
|
+
...dataProps,
|
|
22
|
+
className: tw(componentClassNames?.root, className),
|
|
23
|
+
id,
|
|
24
|
+
onClick,
|
|
25
|
+
scroll,
|
|
26
|
+
style,
|
|
27
|
+
};
|
|
28
|
+
if (!href || /^http/u.exec(href) || /^mailto:/u.exec(href) || /^tel:/u.exec(href)) {
|
|
29
|
+
return (_jsx("a", { ...props, href: href ?? undefined, children: children }));
|
|
30
|
+
}
|
|
31
|
+
return (_jsx(NextLink, { ...props, href: normalizeHref(href), children: children }));
|
|
32
|
+
}
|
|
33
|
+
export default Link;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ClassNameProps, SizableClassName } from '../../../styles/interfaces';
|
|
2
|
+
export interface LoaderClassNames {
|
|
3
|
+
root?: SizableClassName;
|
|
4
|
+
inner?: SizableClassName;
|
|
5
|
+
}
|
|
6
|
+
export type LoaderProps = ClassNameProps<LoaderClassNames>;
|
|
7
|
+
declare function Loader({ classNameProps, classNames }: Readonly<LoaderProps>): React.ReactElement;
|
|
8
|
+
export default Loader;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getClassNames } from '../../../styles/config';
|
|
3
|
+
import tw from '../../../styles/tw';
|
|
4
|
+
import Assistive from '../Assistive';
|
|
5
|
+
function Loader({ classNameProps, classNames }) {
|
|
6
|
+
const componentClassNames = classNames || getClassNames('loader')?.(classNameProps);
|
|
7
|
+
return (_jsxs("div", { className: tw(componentClassNames?.root?.default), children: [_jsx("div", { className: tw(componentClassNames?.inner?.default) }), _jsx(Assistive, { children: "Loading..." })] }));
|
|
8
|
+
}
|
|
9
|
+
export default Loader;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { NavigationObject } from '../../../navigation/interfaces';
|
|
3
|
+
import type { NextPageProps } from '../../../utility/interfaces';
|
|
4
|
+
interface PageTemplateProps {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
tabs: NavigationObject[] | null;
|
|
7
|
+
title: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export interface PageProps<T> {
|
|
10
|
+
readonly children: React.ReactNode | ((data: T) => React.ReactNode);
|
|
11
|
+
readonly fn?: (params?: Promise<Record<string, string>> | null) => Promise<T>;
|
|
12
|
+
readonly pageProps?: NextPageProps;
|
|
13
|
+
readonly tabs?: NavigationObject[] | ((data: T) => NavigationObject[] | null);
|
|
14
|
+
readonly template?: (props: PageTemplateProps) => React.ReactElement;
|
|
15
|
+
readonly title?: React.ReactNode | ((data: T) => React.ReactNode);
|
|
16
|
+
}
|
|
17
|
+
declare function Page<T>(props: PageProps<T>): React.ReactElement;
|
|
18
|
+
export default Page;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Suspense } from 'react';
|
|
3
|
+
function getChildren(props, data) {
|
|
4
|
+
if (typeof props.children === 'function') {
|
|
5
|
+
return data ? props.children(data) : null;
|
|
6
|
+
}
|
|
7
|
+
return props.children;
|
|
8
|
+
}
|
|
9
|
+
function getTabs(props, data) {
|
|
10
|
+
if (typeof props.tabs === 'function') {
|
|
11
|
+
return data ? props.tabs(data) : null;
|
|
12
|
+
}
|
|
13
|
+
return props.tabs ?? null;
|
|
14
|
+
}
|
|
15
|
+
function getTitle(props, data) {
|
|
16
|
+
if (typeof props.title === 'function') {
|
|
17
|
+
return data ? props.title(data) : null;
|
|
18
|
+
}
|
|
19
|
+
return props.title;
|
|
20
|
+
}
|
|
21
|
+
async function PageComponent(props) {
|
|
22
|
+
const data = props.fn ? await props.fn(props.pageProps?.params) : null;
|
|
23
|
+
const children = getChildren(props, data);
|
|
24
|
+
const tabs = getTabs(props, data);
|
|
25
|
+
const title = getTitle(props, data);
|
|
26
|
+
if (props.template) {
|
|
27
|
+
return props.template({ children, tabs, title });
|
|
28
|
+
}
|
|
29
|
+
return children;
|
|
30
|
+
}
|
|
31
|
+
function Page(props) {
|
|
32
|
+
return (_jsx(Suspense, { fallback: props.template?.({ children: null, tabs: null, title: '•••' }), children: _jsx(PageComponent, { ...props }) }));
|
|
33
|
+
}
|
|
34
|
+
export default Page;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ClassNameProps, FocusableClassName } from '../../../styles/interfaces';
|
|
2
|
+
export interface PopoverClassNames {
|
|
3
|
+
root: FocusableClassName;
|
|
4
|
+
scroll: string;
|
|
5
|
+
}
|
|
6
|
+
export interface PopoverProps extends ClassNameProps<PopoverClassNames> {
|
|
7
|
+
align?: 'center' | 'left' | 'right';
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
isOpen?: boolean;
|
|
10
|
+
isScrollable?: boolean;
|
|
11
|
+
vAlign?: 'top' | 'bottom';
|
|
12
|
+
}
|
|
13
|
+
declare function Popover({ align: initialAlign, children, classNames, classNameProps, isOpen, isScrollable, vAlign: initialVAlign, }: Readonly<PopoverProps>): React.ReactElement;
|
|
14
|
+
export default Popover;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { getClassNames } from '../../../styles/config';
|
|
5
|
+
import tw from '../../../styles/tw';
|
|
6
|
+
const HORIZONTAL_THRESHOLD = 40;
|
|
7
|
+
const VERTICAL_THRESHOLD = 40;
|
|
8
|
+
function getPositionStyles(align = 'left', vAlign = 'top') {
|
|
9
|
+
if (align === 'left') {
|
|
10
|
+
return vAlign === 'top'
|
|
11
|
+
? 'left-0 origin-bottom-left bottom-full'
|
|
12
|
+
: 'left-0 origin-top-left top-full';
|
|
13
|
+
}
|
|
14
|
+
if (align === 'right') {
|
|
15
|
+
return vAlign === 'top'
|
|
16
|
+
? 'right-0 origin-bottom-right bottom-full'
|
|
17
|
+
: 'right-0 origin-top-right top-full';
|
|
18
|
+
}
|
|
19
|
+
// If neither left or right, assume it is center
|
|
20
|
+
return vAlign === 'top'
|
|
21
|
+
? 'left-1/2 -translate-x-1/2 origin-bottom bottom-full'
|
|
22
|
+
: 'left-1/2 -translate-x-1/2 origin-top top-full';
|
|
23
|
+
}
|
|
24
|
+
function Popover({ align: initialAlign = 'left', children, classNames, classNameProps, isOpen, isScrollable, vAlign: initialVAlign = 'bottom', }) {
|
|
25
|
+
const componentClassNames = classNames || getClassNames('popover')?.(classNameProps);
|
|
26
|
+
const [align, setAlign] = useState(initialAlign);
|
|
27
|
+
const [vAlign, setVAlign] = useState(initialVAlign);
|
|
28
|
+
const ref = useRef(null);
|
|
29
|
+
const shadowRef = useRef(null);
|
|
30
|
+
function initShadow() {
|
|
31
|
+
if (shadowRef.current) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
shadowRef.current = document.createElement('div');
|
|
35
|
+
shadowRef.current.classList = ref.current?.classList.value || '';
|
|
36
|
+
shadowRef.current.style.height = `${ref.current?.offsetHeight}px`;
|
|
37
|
+
shadowRef.current.style.width = `${ref.current?.offsetWidth}px`;
|
|
38
|
+
shadowRef.current.style.pointerEvents = 'none';
|
|
39
|
+
ref.current?.parentElement?.appendChild(shadowRef.current);
|
|
40
|
+
}
|
|
41
|
+
function handleResize() {
|
|
42
|
+
const rect = shadowRef.current?.getBoundingClientRect();
|
|
43
|
+
if ((rect?.right || 0) > window.innerWidth - HORIZONTAL_THRESHOLD) {
|
|
44
|
+
setAlign('right');
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
setAlign(initialAlign);
|
|
48
|
+
}
|
|
49
|
+
if ((rect?.bottom || 0) > window.innerHeight - VERTICAL_THRESHOLD &&
|
|
50
|
+
(rect?.top || 0) - (rect?.height || 0) > VERTICAL_THRESHOLD) {
|
|
51
|
+
setVAlign('top');
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
setVAlign(initialVAlign);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
setTimeout(() => {
|
|
59
|
+
initShadow();
|
|
60
|
+
handleResize();
|
|
61
|
+
}, 1);
|
|
62
|
+
window.addEventListener('resize', handleResize);
|
|
63
|
+
window.addEventListener('scroll', handleResize);
|
|
64
|
+
return () => {
|
|
65
|
+
window.removeEventListener('resize', handleResize);
|
|
66
|
+
window.removeEventListener('scroll', handleResize);
|
|
67
|
+
};
|
|
68
|
+
}, []);
|
|
69
|
+
return (_jsx("div", { ref: ref, className: tw('absolute', getPositionStyles(align, vAlign), componentClassNames?.root?.default, isOpen ? componentClassNames?.root?.focused : null), style: { display: isOpen ? 'block' : 'none' }, children: isScrollable ? (_jsx("div", { className: componentClassNames?.scroll, children: children })) : (children) }));
|
|
70
|
+
}
|
|
71
|
+
export default Popover;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type RegisteredClassNames } from '../../../styles/config';
|
|
2
|
+
import type { ClassNameProps } from '../../../styles/interfaces';
|
|
3
|
+
export interface RootLayoutClassNames {
|
|
4
|
+
root: string;
|
|
5
|
+
content: string;
|
|
6
|
+
}
|
|
7
|
+
export interface RootLayoutProps extends ClassNameProps<RootLayoutClassNames> {
|
|
8
|
+
readonly children: React.ReactNode;
|
|
9
|
+
readonly classNameConfig?: RegisteredClassNames;
|
|
10
|
+
}
|
|
11
|
+
declare function RootLayout({ children, classNameConfig, classNameProps, classNames, }: RootLayoutProps): React.ReactElement;
|
|
12
|
+
export default RootLayout;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getClassNames, registerClassNames } from '../../../styles/config';
|
|
3
|
+
import ClassNames from '../ClassNames';
|
|
4
|
+
import Toaster from '../Toaster';
|
|
5
|
+
function RootLayout({ children, classNameConfig, classNameProps, classNames, }) {
|
|
6
|
+
if (classNameConfig) {
|
|
7
|
+
registerClassNames(classNameConfig);
|
|
8
|
+
}
|
|
9
|
+
const componentClassNames = classNames || getClassNames('rootLayout')?.(classNameProps);
|
|
10
|
+
return (_jsxs("html", { lang: "en", children: [_jsx("head", { children: _jsx("link", { href: "/images/favicon.svg", rel: "icon" }) }), _jsxs("body", { className: componentClassNames?.root, children: [_jsx("script", { dangerouslySetInnerHTML: {
|
|
11
|
+
__html: "(function(d){var v=d.createElement('div'),t=d.createElement('style'),s=v.style;s.overflowY='scroll';s.width='50';s.height='50';d.body.append(v);t.innerHTML='body:has([data-modal][open]){padding-right:'+(v.offsetWidth-v.clientWidth)+'px}';d.body.append(t);v.remove()}(document))",
|
|
12
|
+
} }), classNameConfig ? _jsx(ClassNames, { data: classNameConfig }) : null, _jsx("div", { className: componentClassNames?.content, children: children }), _jsx(Toaster, {})] })] }));
|
|
13
|
+
}
|
|
14
|
+
export default RootLayout;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ClassNameProps, StylableClassName } from '../../../styles/interfaces';
|
|
2
|
+
import type { StyleVariant } from '../../../utility/interfaces';
|
|
3
|
+
export interface ToastClassNames {
|
|
4
|
+
root: StylableClassName;
|
|
5
|
+
}
|
|
6
|
+
export interface ToastProps extends ClassNameProps<ToastClassNames> {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
variant?: StyleVariant | null;
|
|
9
|
+
}
|
|
10
|
+
declare function Toast({ children, classNames, classNameProps, }: Readonly<ToastProps>): React.ReactElement | null;
|
|
11
|
+
export default Toast;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { getClassNames } from '../../../styles/config';
|
|
4
|
+
function Toast({ children, classNames, classNameProps, }) {
|
|
5
|
+
const componentClassNames = classNames || getClassNames('toast')?.(classNameProps);
|
|
6
|
+
if (!children) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
return _jsx("dialog", { open: true, children: children });
|
|
10
|
+
}
|
|
11
|
+
export default Toast;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ToastProps } from '../Toast';
|
|
2
|
+
interface ToasterProps {
|
|
3
|
+
channel?: string;
|
|
4
|
+
duration?: number;
|
|
5
|
+
render?: (props: ToastProps) => React.ReactElement | null;
|
|
6
|
+
}
|
|
7
|
+
declare function Toaster(props: Readonly<ToasterProps>): React.ReactElement | null;
|
|
8
|
+
export default Toaster;
|