@sqrzro/admin 2.1.0-bz.17 → 2.1.0-bz.18

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.
Files changed (89) hide show
  1. package/dist/index.cjs +205 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +169 -0
  4. package/dist/index.d.ts +169 -3
  5. package/dist/index.js +16 -3
  6. package/dist/index.js.map +1 -0
  7. package/package.json +28 -14
  8. package/dist/components/AppLayout/index.d.ts +0 -9
  9. package/dist/components/AppLayout/index.js +0 -14
  10. package/dist/components/AppNavigation/index.d.ts +0 -6
  11. package/dist/components/AppNavigation/index.js +0 -16
  12. package/dist/components/Auth/index.d.ts +0 -5
  13. package/dist/components/Auth/index.js +0 -15
  14. package/dist/components/Badge/index.d.ts +0 -8
  15. package/dist/components/Badge/index.js +0 -20
  16. package/dist/components/BooleanFilter/index.d.ts +0 -5
  17. package/dist/components/BooleanFilter/index.js +0 -19
  18. package/dist/components/Config/index.d.ts +0 -6
  19. package/dist/components/Config/index.js +0 -9
  20. package/dist/components/Dashboard/index.d.ts +0 -7
  21. package/dist/components/Dashboard/index.js +0 -5
  22. package/dist/components/DateFilter/index.d.ts +0 -6
  23. package/dist/components/DateFilter/index.js +0 -31
  24. package/dist/components/DropdownFilter/index.d.ts +0 -6
  25. package/dist/components/DropdownFilter/index.js +0 -9
  26. package/dist/components/FilterBar/index.d.ts +0 -9
  27. package/dist/components/FilterBar/index.js +0 -26
  28. package/dist/components/FilterBarItem/index.d.ts +0 -15
  29. package/dist/components/FilterBarItem/index.js +0 -31
  30. package/dist/components/GridList/index.d.ts +0 -5
  31. package/dist/components/GridList/index.js +0 -7
  32. package/dist/components/GridListItem/index.d.ts +0 -4
  33. package/dist/components/GridListItem/index.js +0 -8
  34. package/dist/components/Icon/index.d.ts +0 -8
  35. package/dist/components/Icon/index.js +0 -23
  36. package/dist/components/InfoPanel/index.d.ts +0 -8
  37. package/dist/components/InfoPanel/index.js +0 -22
  38. package/dist/components/List/index.d.ts +0 -25
  39. package/dist/components/List/index.js +0 -39
  40. package/dist/components/ListAction/index.d.ts +0 -7
  41. package/dist/components/ListAction/index.js +0 -9
  42. package/dist/components/ListActions/index.d.ts +0 -8
  43. package/dist/components/ListActions/index.js +0 -12
  44. package/dist/components/ListItem/index.d.ts +0 -18
  45. package/dist/components/ListItem/index.js +0 -16
  46. package/dist/components/MeActions/index.d.ts +0 -3
  47. package/dist/components/MeActions/index.js +0 -6
  48. package/dist/components/MePanel/index.d.ts +0 -8
  49. package/dist/components/MePanel/index.js +0 -6
  50. package/dist/components/Page/index.d.ts +0 -12
  51. package/dist/components/Page/index.js +0 -12
  52. package/dist/components/PageActions/index.d.ts +0 -6
  53. package/dist/components/PageActions/index.js +0 -13
  54. package/dist/components/Panel/index.d.ts +0 -7
  55. package/dist/components/Panel/index.js +0 -5
  56. package/dist/components/RootLayout/index.d.ts +0 -9
  57. package/dist/components/RootLayout/index.js +0 -21
  58. package/dist/components/SettingsForm/index.d.ts +0 -9
  59. package/dist/components/SettingsForm/index.js +0 -14
  60. package/dist/components/SettingsPage/index.d.ts +0 -3
  61. package/dist/components/SettingsPage/index.js +0 -9
  62. package/dist/components/Table/index.d.ts +0 -9
  63. package/dist/components/Table/index.js +0 -17
  64. package/dist/components/TableClientComponent/index.d.ts +0 -16
  65. package/dist/components/TableClientComponent/index.js +0 -57
  66. package/dist/components/Tabs/index.d.ts +0 -8
  67. package/dist/components/Tabs/index.js +0 -11
  68. package/dist/components/index.d.ts +0 -33
  69. package/dist/components/index.js +0 -17
  70. package/dist/icons/ErrorIcon/index.d.ts +0 -3
  71. package/dist/icons/ErrorIcon/index.js +0 -5
  72. package/dist/icons/InfoIcon/index.d.ts +0 -3
  73. package/dist/icons/InfoIcon/index.js +0 -5
  74. package/dist/icons/SuccessIcon/index.d.ts +0 -3
  75. package/dist/icons/SuccessIcon/index.js +0 -5
  76. package/dist/icons/WarningIcon/index.d.ts +0 -3
  77. package/dist/icons/WarningIcon/index.js +0 -5
  78. package/dist/interfaces.d.ts +0 -4
  79. package/dist/interfaces.js +0 -1
  80. package/dist/services/ConfigService.d.ts +0 -11
  81. package/dist/services/ConfigService.js +0 -14
  82. package/dist/services/LayoutService.d.ts +0 -7
  83. package/dist/services/LayoutService.js +0 -9
  84. package/dist/styles/config.d.ts +0 -3
  85. package/dist/styles/config.js +0 -148
  86. package/dist/styles/postcss.d.ts +0 -6
  87. package/dist/styles/postcss.js +0 -4
  88. package/dist/styles/tailwind.d.ts +0 -10
  89. package/dist/styles/tailwind.js +0 -72
@@ -1,31 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useRef } from 'react';
4
- import { tw } from '@sqrzro/components';
5
- import BooleanFilter, { renderBooleanValue } from '../BooleanFilter';
6
- import DateFilter, { renderDateValue, transformDateValue } from '../DateFilter';
7
- import DropdownFilter, { renderDropdownValue } from '../DropdownFilter';
8
- const map = {
9
- boolean: { component: BooleanFilter, renderValue: renderBooleanValue },
10
- date: {
11
- component: DateFilter,
12
- renderValue: renderDateValue,
13
- size: 'w-96',
14
- transformValue: transformDateValue,
15
- },
16
- dropdown: { component: DropdownFilter, renderValue: renderDropdownValue },
17
- };
18
- const DEFAULT_SIZE = 'w-56';
19
- function FilterBarItem({ data, label, name, onChange, type, value, }) {
20
- const panel = useRef(null);
21
- function handleChange(event) {
22
- onChange(name, event.target.value);
23
- panel.current?.hidePopover();
24
- }
25
- function handleClear() {
26
- onChange(name, '');
27
- }
28
- const { component: FilterComponent, renderValue, size, transformValue } = map[type];
29
- return (_jsxs("li", { className: tw('relative inline-flex gap-2 rounded-full border px-5 py-2 text-xs text-white', value ? 'border-solid border-slate-400' : 'border-dashed border-slate-400', value ? 'bg-slate-700 pr-10' : 'text-slate-300'), children: [_jsx("p", { className: "", children: label }), value ? (_jsx("p", { className: "border-l border-l-slate-300 pl-2 font-semibold", children: renderValue(value, data) })) : null, _jsx("button", { className: tw('absolute left-0 top-0 h-full select-none text-transparent', value ? 'right-10' : 'right-0'), id: `${name}-control`, popovertarget: `${name}-target`, type: "button", children: "Edit" }), value ? (_jsxs("button", { className: "absolute right-0 top-0 flex h-full w-10 select-none items-center justify-center", onClick: handleClear, type: "button", children: [_jsx("span", { className: "sr-only", children: "Remove" }), _jsx("span", { className: "flex h-4 w-4 items-center justify-center rounded-full bg-white leading-none text-slate-800", children: "\u00D7" })] })) : null, _jsx("div", { ref: panel, anchor: `${name}-control`, className: tw('show left-[anchor(left)] top-[anchor(bottom)] -ml-px mt-2 origin-top-left origin-top-left rounded bg-white shadow-lg', size || DEFAULT_SIZE), id: `${name}-target`, popover: "auto", children: _jsx("div", { className: "py-1", role: "none", children: _jsx(FilterComponent, { data: data, name: name, onChange: handleChange, value: transformValue ? transformValue(value) : value }) }) })] }));
30
- }
31
- export default FilterBarItem;
@@ -1,5 +0,0 @@
1
- /// <reference types="react" />
2
- import type { ListProps } from '../List';
3
- export type GridListProps<Item, Params> = Omit<ListProps<Item, Params>, 'renderItem'>;
4
- declare function GridList<Item extends object, Params>(props: GridListProps<Item, Params>): React.ReactElement;
5
- export default GridList;
@@ -1,7 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import GridListItem from '../GridListItem';
3
- import List from '../List';
4
- function GridList(props) {
5
- return _jsx(List, { ...props, columns: 3, renderItem: GridListItem });
6
- }
7
- export default GridList;
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- import type { ListObject } from '../ListItem';
3
- declare function GridListItem({ actions: Actions, href, id, image, imageHref, meta, subtitle, title, }: Readonly<ListObject>): React.ReactElement;
4
- export default GridListItem;
@@ -1,8 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Fragment } from 'react';
3
- import { Link } from '@sqrzro/components';
4
- import { renderMeta } from '../ListItem';
5
- function GridListItem({ actions: Actions, href, id, image, imageHref, meta, subtitle, title, }) {
6
- return (_jsx("li", { children: _jsxs("article", { className: "bg-panel overflow-hidden rounded p-4 shadow", children: [_jsx("div", { className: "relative mb-4 h-64 rounded border border border-slate-300 bg-slate-50 p-4", children: image ? (_jsxs(Fragment, { children: [_jsx("img", { alt: "", className: "h-full w-full object-contain", src: image }), imageHref ? (_jsx(Link, { className: "absolute inset-0", href: imageHref, scroll: false, children: _jsx("span", { className: "sr-only", children: "Edit Image" }) })) : null] })) : imageHref ? (_jsxs(Link, { className: "absolute inset-0 flex flex-col items-center justify-center gap-3 font-semibold text-slate-500", href: imageHref, scroll: false, children: [_jsx("i", { className: "block h-12 w-12 rounded-full border-2 border-slate-300" }), "Add Image"] })) : null }), _jsx("h2", { className: "text-base font-semibold", children: href ? _jsx(Link, { href: href, children: title }) : title }), subtitle ? _jsx("p", { className: "text-xs text-slate-500", children: subtitle }) : null, meta ? (_jsxs(Fragment, { children: [_jsx("hr", { className: "my-4" }), _jsx("div", { className: "flex items-center justify-between", children: meta ? renderMeta(meta) : null })] })) : null, href ? (_jsxs(Fragment, { children: [_jsx("hr", { className: "my-4" }), _jsx(Link, { href: href, scroll: false, children: "Edit" })] })) : null] }) }));
7
- }
8
- export default GridListItem;
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- export type IconType = 'danger' | 'error' | 'info' | 'success' | 'warning';
3
- declare const icons: Record<IconType, () => React.ReactElement>;
4
- export interface IconProps {
5
- type?: keyof typeof icons;
6
- }
7
- declare function Icon({ type }: Readonly<IconProps>): React.ReactElement | null;
8
- export default Icon;
@@ -1,23 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import ErrorIcon from '../../icons/ErrorIcon';
3
- import InfoIcon from '../../icons/InfoIcon';
4
- import SuccessIcon from '../../icons/SuccessIcon';
5
- import WarningIcon from '../../icons/WarningIcon';
6
- const icons = {
7
- danger: ErrorIcon,
8
- error: ErrorIcon,
9
- info: InfoIcon,
10
- success: SuccessIcon,
11
- warning: WarningIcon,
12
- };
13
- function Icon({ type }) {
14
- if (!type) {
15
- return null;
16
- }
17
- const IconComponent = icons[type];
18
- if (!IconComponent) {
19
- return null;
20
- }
21
- return _jsx(IconComponent, {});
22
- }
23
- export default Icon;
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- import type { StyleVariant } from '@sqrzro/interfaces';
3
- export interface InfoPanelProps {
4
- children: React.ReactNode;
5
- variant?: StyleVariant;
6
- }
7
- declare function InfoPanel({ children, variant }: Readonly<InfoPanelProps>): React.ReactElement;
8
- export default InfoPanel;
@@ -1,22 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { tw } from '@sqrzro/components';
3
- import Icon from '../Icon';
4
- const iconTypeMap = {
5
- danger: 'danger',
6
- info: 'info',
7
- success: 'success',
8
- warning: 'warning',
9
- };
10
- const classMap = {
11
- danger: 'bg-red-50 text-red-700',
12
- info: 'bg-sky-50 text-sky-700',
13
- success: 'bg-green-50 text-green-700',
14
- warning: 'bg-yellow-50 text-yellow-700',
15
- };
16
- function mapVariantToIconType(variant) {
17
- return iconTypeMap[variant] || 'info';
18
- }
19
- function InfoPanel({ children, variant = 'info' }) {
20
- return (_jsxs("aside", { className: tw('grid grid-cols-[1rem_auto] gap-4 rounded p-4', classMap[variant]), children: [_jsx(Icon, { type: mapVariantToIconType(variant) }), _jsx("div", { children: children })] }));
21
- }
22
- export default InfoPanel;
@@ -1,25 +0,0 @@
1
- /// <reference types="react" />
2
- import type { EmptyMessageProps } from '@sqrzro/components';
3
- import type { Errorable } from '@sqrzro/interfaces';
4
- import type { FilterObject } from '../FilterBar';
5
- import type { ListObject } from '../ListItem';
6
- export interface ListComponentProps {
7
- params?: Record<string, string>;
8
- searchParams?: Record<string, string>;
9
- }
10
- export interface ListProps<Item, Params> {
11
- actions?: ({ id }: {
12
- readonly id: number;
13
- }) => React.ReactElement;
14
- columns?: number;
15
- emptyMessageProps?: EmptyMessageProps;
16
- filters?: FilterObject[];
17
- fn: (params?: Params, searchParams?: URLSearchParams) => Promise<Errorable<Item[]>>;
18
- hasSearch?: boolean;
19
- isMinimal?: boolean;
20
- renderItem?: (props: ListObject) => React.ReactElement;
21
- params?: Params;
22
- transformer?: (item: Item) => ListObject;
23
- }
24
- declare function List<Item extends object, Params>({ actions, columns, emptyMessageProps, filters, fn, hasSearch, isMinimal, params, renderItem, transformer, }: Readonly<ListProps<Item, Params>>): Promise<React.ReactElement>;
25
- export default List;
@@ -1,39 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Fragment } from 'react';
3
- import { EmptyMessage, tw } from '@sqrzro/components';
4
- import FilterBar from '../FilterBar';
5
- import ListItem from '../ListItem';
6
- function defaultTransformer() {
7
- return {
8
- id: 0,
9
- title: '',
10
- };
11
- }
12
- const reservedSearchParams = ['action'];
13
- function checkHasFilters(searchParams) {
14
- return Array.from(searchParams.entries()).some(([key, value]) => !reservedSearchParams.includes(key) && Boolean(value));
15
- }
16
- async function List({ actions, columns, emptyMessageProps, filters, fn, hasSearch, isMinimal, params, renderItem = ListItem, transformer, }) {
17
- let searchParams;
18
- try {
19
- const { headers } = await import('next/headers');
20
- searchParams = new URLSearchParams(headers().get('x-search-params') || '');
21
- }
22
- catch (err) {
23
- searchParams = new URLSearchParams();
24
- }
25
- const [response, error] = await fn(params, searchParams);
26
- if (error) {
27
- return _jsx("div", { children: "Error" });
28
- }
29
- const data = response.map(transformer || defaultTransformer);
30
- const hasFilters = checkHasFilters(searchParams);
31
- const componentEmptyMessageProps = hasFilters
32
- ? {
33
- children: 'Try adjusting the filters above. If you think this is a mistake, please contact your site administrator.',
34
- title: 'No results match the current filters',
35
- }
36
- : emptyMessageProps;
37
- return (_jsxs(Fragment, { children: [(filters || hasSearch) && (data.length || hasFilters) ? (_jsx(FilterBar, { hasSearch: hasSearch, map: filters })) : null, data.length ? (_jsx("ul", { className: tw('relative', columns ? 'grid grid-cols-3 gap-6' : 'flex flex-col gap-4'), children: data.map((item) => renderItem({ actions, ...item })) })) : (_jsx(EmptyMessage, { ...componentEmptyMessageProps, classNameProps: { isMinimal } }))] }));
38
- }
39
- export default List;
@@ -1,7 +0,0 @@
1
- /// <reference types="react" />
2
- import type { ConfirmableAction } from '@sqrzro/interfaces';
3
- interface ListActionProps extends ConfirmableAction<number> {
4
- id: number;
5
- }
6
- declare function ListAction({ id, onClick, label, variant, }: Readonly<ListActionProps>): React.ReactElement;
7
- export default ListAction;
@@ -1,9 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { ConfirmableButton } from '@sqrzro/components';
3
- function ListAction({ id, onClick, label, variant, }) {
4
- function handleClick() {
5
- onClick(id);
6
- }
7
- return (_jsx(ConfirmableButton, { onClick: handleClick, variant: variant, isText: true, children: label }));
8
- }
9
- export default ListAction;
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- import type { ConfirmableAction } from '@sqrzro/interfaces';
3
- export interface ListActionsProps {
4
- actions: ConfirmableAction<number>[];
5
- id: number;
6
- }
7
- declare function ListActions({ actions, id }: Readonly<ListActionsProps>): React.ReactElement;
8
- export default ListActions;
@@ -1,12 +0,0 @@
1
- 'use client';
2
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
3
- import { useClickOutside } from '@sqrzro/hooks';
4
- import ListAction from '../ListAction';
5
- function ListActions({ actions, id }) {
6
- const [isOpen, setIsOpen, ref] = useClickOutside();
7
- function toggleIsOpen() {
8
- setIsOpen(!isOpen);
9
- }
10
- return (_jsxs("div", { ref: ref, className: "flex flex-row-reverse items-center gap-4", children: [_jsxs("button", { className: "h-4 rotate-90 text-xs leading-[1em] tracking-tighter text-slate-500", onClick: toggleIsOpen, type: "button", children: ["\u2022\u2022\u2022", _jsxs("span", { className: "sr-only", children: [isOpen ? 'Close' : 'Open', " Actions"] })] }), isOpen ? (_jsx("ul", { className: "show relative flex origin-right gap-4 bg-white before:absolute before:left-[-999em] before:right-full before:h-full before:bg-white/80", children: actions.map(({ label, onClick, variant }) => (_jsx("li", { children: _jsx(ListAction, { id: id, label: label, onClick: onClick, variant: variant }) }, label))) })) : null] }));
11
- }
12
- export default ListActions;
@@ -1,18 +0,0 @@
1
- /// <reference types="react" />
2
- export interface ListObject {
3
- actions?: ({ id }: {
4
- id: number | string;
5
- }) => React.ReactElement;
6
- description?: React.ReactNode | null;
7
- href?: string;
8
- id: number | string;
9
- image?: string | null;
10
- imageHref?: string | null;
11
- meta?: React.ReactNode[] | Record<string, React.ReactNode>;
12
- subtitle?: React.ReactNode | null;
13
- title?: string;
14
- }
15
- export declare function renderMeta(meta: ListObject['meta']): React.ReactElement | null;
16
- declare function ListItem({ actions: Actions, // eslint-disable-line @typescript-eslint/naming-convention
17
- description, href, id, meta, title, }: Readonly<ListObject>): React.ReactElement;
18
- export default ListItem;
@@ -1,16 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Link } from '@sqrzro/components';
3
- export function renderMeta(meta) {
4
- if (!meta) {
5
- return null;
6
- }
7
- if (Array.isArray(meta)) {
8
- return (_jsx("ul", { className: "flex items-center gap-4 text-xs text-slate-600", children: meta.map((item, index) => (_jsx("li", { children: item }, index))) }));
9
- }
10
- return (_jsx("table", { className: "w-full text-xs", children: _jsx("tbody", { children: Object.entries(meta).map(([key, value]) => (_jsxs("tr", { className: "odd:bg-slate-100", children: [_jsx("th", { className: "p-2 font-semibold", children: key }), _jsx("td", { className: "p-2 text-right", children: value || '-' })] }, key))) }) }));
11
- }
12
- function ListItem({ actions: Actions, // eslint-disable-line @typescript-eslint/naming-convention
13
- description, href, id, meta, title, }) {
14
- return (_jsx("li", { children: _jsxs("article", { className: "bg-panel overflow-hidden rounded p-4 shadow-[0px_0px_0px_1px_rgba(9,9,11,0.07),0px_2px_2px_0px_rgba(9,9,11,0.05)]", children: [title ? (_jsx("h2", { className: "border-b border-slate-200 pb-3 text-lg font-semibold", children: href ? _jsx(Link, { href: href, children: title }) : title })) : null, description ? (_jsx("div", { className: "border-b border-slate-200 pb-3 ", children: description })) : null, _jsxs("div", { className: "mt-4 flex items-center justify-between", children: [meta ? renderMeta(meta) : null, Actions ? _jsx(Actions, { id: id }) : null] })] }) }));
15
- }
16
- export default ListItem;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- declare function MeActions(): React.ReactElement;
3
- export default MeActions;
@@ -1,6 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Link, LogoutButton } from '@sqrzro/components';
3
- function MeActions() {
4
- return (_jsxs("ul", { className: "flex gap-2 text-xs text-slate-300", children: [_jsx("li", { children: _jsx(Link, { href: "/settings", children: "Settings" }) }), _jsx("li", { children: _jsx(LogoutButton, {}) })] }));
5
- }
6
- export default MeActions;
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- interface MePanelProps {
3
- user?: {
4
- name: string;
5
- } | null;
6
- }
7
- declare function MePanel({ user }: Readonly<MePanelProps>): React.ReactElement;
8
- export default MePanel;
@@ -1,6 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import MeActions from '../MeActions';
3
- function MePanel({ user }) {
4
- return (_jsxs("div", { className: "ml-auto flex items-center gap-3", children: [_jsxs("div", { className: "flex flex-col items-end gap-0.5 text-white", children: [_jsx("strong", { children: user?.name }), _jsx(MeActions, {})] }), _jsx("div", { className: "h-9 w-9 flex-none rounded-full border-4 border-slate-500" })] }));
5
- }
6
- export default MePanel;
@@ -1,12 +0,0 @@
1
- /// <reference types="react" />
2
- import type { LinkableAction } from '@sqrzro/interfaces';
3
- export interface PageProps {
4
- actions?: LinkableAction[];
5
- basePath?: string;
6
- children: React.ReactNode;
7
- isFullWidth?: boolean;
8
- tabs?: LinkableAction[];
9
- title: string;
10
- }
11
- declare function Page({ basePath, children, isFullWidth, tabs, title, }: Readonly<PageProps>): Promise<React.ReactElement>;
12
- export default Page;
@@ -1,12 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Fragment } from 'react';
3
- import { Container, tw } from '@sqrzro/components';
4
- import { getLayout } from '../../services/LayoutService';
5
- import Tabs from '../Tabs';
6
- async function Page({ basePath, children, isFullWidth, tabs, title, }) {
7
- const layout = await getLayout();
8
- return (_jsxs(Fragment, { children: [_jsx("header", { className: tw('', layout === 'sidebar'
9
- ? 'border-b border-slate-200 bg-white'
10
- : 'bg-slate-800 pb-16 text-white'), children: _jsxs(Container, { isFullWidth: layout === 'sidebar' || isFullWidth, children: [_jsxs("div", { className: "flex items-center justify-between py-10", children: [_jsx("h1", { className: "min-h-10 text-3xl font-semibold", children: title }), _jsx("div", { className: "flex gap-2", id: "page-actions" })] }), tabs ? (_jsx("div", { className: "-mt-4 mb-8", children: _jsx(Tabs, { basePath: basePath, data: tabs }) })) : null] }) }), _jsx(Container, { isFullWidth: layout === 'sidebar' || isFullWidth, children: _jsx("div", { className: tw('flex flex-col gap-8', layout === 'sidebar' ? 'mt-8' : '-mt-16'), children: children }) })] }));
11
- }
12
- export default Page;
@@ -1,6 +0,0 @@
1
- /// <reference types="react" />
2
- export interface PageActionsProps {
3
- children: React.ReactNode;
4
- }
5
- declare function PageActions({ children }: Readonly<PageActionsProps>): React.ReactElement | null;
6
- export default PageActions;
@@ -1,13 +0,0 @@
1
- 'use client';
2
- import { useEffect, useRef, useState } from 'react';
3
- import { createPortal } from 'react-dom';
4
- function PageActions({ children }) {
5
- const ref = useRef(null);
6
- const [mounted, setMounted] = useState(false);
7
- useEffect(() => {
8
- ref.current = document.getElementById('page-actions');
9
- setMounted(true);
10
- }, []);
11
- return mounted && ref.current ? createPortal(children, ref.current) : null;
12
- }
13
- export default PageActions;
@@ -1,7 +0,0 @@
1
- /// <reference types="react" />
2
- export interface PanelProps {
3
- children: React.ReactNode;
4
- title?: string;
5
- }
6
- declare function Panel({ children, title }: Readonly<PanelProps>): React.ReactElement;
7
- export default Panel;
@@ -1,5 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- function Panel({ children, title }) {
3
- return (_jsxs("article", { className: "bg-panel relative overflow-hidden rounded p-6 shadow-[0px_0px_0px_1px_rgba(9,9,11,0.07),0px_2px_2px_0px_rgba(9,9,11,0.05)]", children: [title ? (_jsx("h3", { className: "mb-4 border-b border-slate-200 pb-3 text-lg font-semibold leading-none", children: title })) : null, children] }));
4
- }
5
- export default Panel;
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- import type { Config as ConfigObject } from '../../services/ConfigService';
3
- export interface RootLayoutProps {
4
- children: React.ReactNode;
5
- config?: ConfigObject;
6
- logo?: () => React.ReactElement;
7
- }
8
- declare function RootLayout({ children, config, logo }: Readonly<RootLayoutProps>): React.ReactElement;
9
- export default RootLayout;
@@ -1,21 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- /* eslint-disable react/no-danger */
3
- import { Suspense } from 'react';
4
- import { Inter as getInter } from 'next/font/google';
5
- import { ClassNames, Toaster, tw } from '@sqrzro/components';
6
- import { setConfig } from '../../services/ConfigService';
7
- import classNames from '../../styles/config';
8
- import Config from '../Config';
9
- const inter = getInter({
10
- subsets: ['latin'],
11
- variable: '--font-inter',
12
- });
13
- function RootLayout({ children, config, logo }) {
14
- if (config) {
15
- setConfig(config, logo);
16
- }
17
- return (_jsxs("html", { lang: "en", children: [_jsx("head", {}), _jsxs("body", { className: tw(inter.variable, 'overflow-x-hidden overflow-y-scroll bg-slate-50 font-sans text-sm text-slate-800 has-[[data-modal][open]]:overflow-hidden'), children: [_jsx("script", { dangerouslySetInnerHTML: {
18
- __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))",
19
- } }), _jsx(Config, { data: config }), _jsx(ClassNames, { data: classNames }), children, _jsx(Suspense, { fallback: null, children: _jsx(Toaster, {}) })] })] }));
20
- }
21
- export default RootLayout;
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- interface SettingsFormFields {
3
- layout: string;
4
- }
5
- interface SettingsFormProps {
6
- defaults: Partial<SettingsFormFields>;
7
- }
8
- declare function SettingsForm({ defaults }: Readonly<SettingsFormProps>): JSX.Element;
9
- export default SettingsForm;
@@ -1,14 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { EditableForm, EditableRadioFormField } from '@sqrzro/components';
4
- import { useEditableForm } from '@sqrzro/hooks';
5
- import { submitLayoutForm } from '../../services/LayoutService';
6
- const options = { sidebar: 'Side bar', topbar: 'Top bar' };
7
- function SettingsForm({ defaults }) {
8
- const { fieldProps, formProps } = useEditableForm({
9
- defaults,
10
- onSubmit: submitLayoutForm,
11
- });
12
- return (_jsx(EditableForm, { title: "Appearance", ...formProps, children: _jsx(EditableRadioFormField, { ...fieldProps('layout'), options: options, renderValue: (value) => (value ? options[value] || '-' : '-') }) }));
13
- }
14
- export default SettingsForm;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- declare function SettingsPage(): Promise<JSX.Element>;
3
- export default SettingsPage;
@@ -1,9 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { getLayout } from '../../services/LayoutService';
3
- import Page from '../Page';
4
- import SettingsForm from '../SettingsForm';
5
- async function SettingsPage() {
6
- const layout = await getLayout();
7
- return (_jsx(Page, { title: "Settings", children: _jsx(SettingsForm, { defaults: { layout } }) }));
8
- }
9
- export default SettingsPage;
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- import type { Errorable } from '@sqrzro/interfaces';
3
- import type { TableClientComponentProps } from '../TableClientComponent';
4
- export interface TableProps<T> extends Omit<TableClientComponentProps, 'data'> {
5
- fn: (filters?: Record<string, string>) => Promise<Errorable<T[]>>;
6
- searchParams?: Record<string, string>;
7
- }
8
- declare function Table<T>({ columns, fn, searchParams, }: Readonly<TableProps<T>>): Promise<React.ReactElement>;
9
- export default Table;
@@ -1,17 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import TableClientComponent from '../TableClientComponent';
3
- function defaultTransformer(item) {
4
- return {
5
- id: item.id,
6
- ...item,
7
- };
8
- }
9
- async function Table({ columns, fn, searchParams, }) {
10
- const [response, error] = await fn(searchParams);
11
- if (error) {
12
- return _jsx("div", { children: "Error" });
13
- }
14
- const data = response.map(defaultTransformer);
15
- return _jsx(TableClientComponent, { columns: columns, data: data });
16
- }
17
- export default Table;
@@ -1,16 +0,0 @@
1
- /// <reference types="react" />
2
- export interface TableItemObject {
3
- [key: string]: string;
4
- id: string;
5
- }
6
- export interface TableColumnObject {
7
- key: string;
8
- title?: string;
9
- type?: 'number' | 'string';
10
- }
11
- export interface TableClientComponentProps {
12
- columns: string[] | TableColumnObject[];
13
- data: TableItemObject[];
14
- }
15
- declare function TableClientComponent({ columns, data, }: Readonly<TableClientComponentProps>): React.ReactElement;
16
- export default TableClientComponent;
@@ -1,57 +0,0 @@
1
- 'use client';
2
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
3
- import { useState } from 'react';
4
- import { Link, tw } from '@sqrzro/components';
5
- import { usePathname, useSearchParams } from 'next/navigation';
6
- function toggleArrayItem(array, item) {
7
- if (array.includes(item)) {
8
- return array.filter((itm) => itm !== item);
9
- }
10
- return [...array, item];
11
- }
12
- function createFilterLink(pathname, searchParams, filters) {
13
- const updatedSearchParams = new URLSearchParams({
14
- ...Object.fromEntries(searchParams),
15
- ...filters,
16
- });
17
- return `${pathname}?${updatedSearchParams.toString()}`;
18
- }
19
- function getDir(currentDir, isSortActive) {
20
- if (isSortActive) {
21
- return currentDir === 'asc' ? 'desc' : 'asc';
22
- }
23
- return 'asc';
24
- }
25
- function createSortLink(pathname, searchParams, sort) {
26
- const dir = getDir(searchParams.get('dir'), searchParams.get('sort') === sort);
27
- return createFilterLink(pathname, searchParams, { sort, dir });
28
- }
29
- function getSortIconProps(searchParams, sort) {
30
- if (searchParams.get('sort') === sort) {
31
- return { dir: searchParams.get('dir') };
32
- }
33
- return { dir: null };
34
- }
35
- function isStringArray(array) {
36
- return array.every((item) => typeof item === 'string');
37
- }
38
- function parseColumns(columns) {
39
- if (columns.length === 0) {
40
- return [];
41
- }
42
- if (isStringArray(columns)) {
43
- return columns.map((key) => ({ key }));
44
- }
45
- return columns;
46
- }
47
- function TableClientComponent({ columns, data, }) {
48
- const pathname = usePathname();
49
- const searchParams = useSearchParams();
50
- const [selected, setSelected] = useState([]);
51
- const parsedColumns = parseColumns(columns);
52
- const hasTitles = parsedColumns.some((column) => column.title);
53
- return (_jsx("div", { className: "bg-white shadow-sm", children: _jsxs("table", { className: "w-full", children: [hasTitles ? (_jsx("thead", { children: _jsx("tr", { children: parsedColumns.map((column) => (_jsx("th", { className: tw('p-4', column.type === 'number' ? 'text-right' : 'text-left'), children: column.title ? (_jsxs(Link, { href: createSortLink(pathname, searchParams, column.key), children: [column.title, ' '] })) : null }, column.key))) }) })) : null, _jsx("tbody", { children: data.map((item) => (_jsx("tr", { className: "odd:bg-slate-100", children: parsedColumns.map((column) => (_jsx("td", { className: tw('border-x border-transparent p-4', getSortIconProps(searchParams, column.key).dir
54
- ? 'border-sky-300 bg-sky-300/10'
55
- : '', column.type === 'number' ? 'text-right' : 'text-left'), children: item[column.key] }, column.key))) }, item.id))) })] }) }));
56
- }
57
- export default TableClientComponent;
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- import type { LinkableAction } from '@sqrzro/interfaces';
3
- interface TabBarProps {
4
- basePath?: string;
5
- data: LinkableAction[];
6
- }
7
- declare function Tabs({ basePath, data }: Readonly<TabBarProps>): React.ReactElement;
8
- export default Tabs;
@@ -1,11 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { Link, tw } from '@sqrzro/components';
4
- import { useNavigation } from '@sqrzro/hooks';
5
- function Tabs({ basePath = '', data }) {
6
- const navigation = useNavigation([basePath, data]);
7
- return (_jsx("nav", { className: "border-b border-slate-700", children: _jsx("ul", { className: "flex gap-4", children: navigation.map(({ href, isActive, label }) => (_jsx("li", { children: _jsx(Link, { className: tw('block px-1 pb-2 font-semibold', isActive
8
- ? 'border-primary border-b-4 text-white'
9
- : 'text-white/80 hover:text-white'), href: href, children: label }) }, href))) }) }));
10
- }
11
- export default Tabs;
@@ -1,33 +0,0 @@
1
- export { Autocomplete, AutocompleteFormField, Button, CalendarInput, ConnectedDropdown, ConfirmableButton, DateFormField, DateInput, Dropdown, DropdownFormField, EditableDateFormField, EditableDropdownFormField, EditableForm, EditableFormField, EditableMultiFormField, EditableNumberFormField, EditableSwitchFormField, EditableTextAreaFormField, EditableTextFormField, EmptyMessage, Fieldset, Form, FormField, FormSubmit, ImageInput, ImageFormField, Link, ModalForm, MultiFormField, NumberFormField, NumberInput, RadioInput, Switch, SwitchFormField, TextArea, TextAreaFormField, TextFormField, TextInput, Toaster, } from '@sqrzro/components';
2
- export type { DropdownItem } from '@sqrzro/components';
3
- export type { AppLayoutProps } from './AppLayout';
4
- export { default as AppLayout } from './AppLayout';
5
- export type { AuthProps } from './Auth';
6
- export { default as Auth } from './Auth';
7
- export type { BadgeProps } from './Badge';
8
- export { default as Badge } from './Badge';
9
- export type { DashboardProps } from './Dashboard';
10
- export { default as Dashboard } from './Dashboard';
11
- export type { FilterBarProps, FilterObject } from './FilterBar';
12
- export { default as FilterBar } from './FilterBar';
13
- export type { GridListProps } from './GridList';
14
- export { default as GridList } from './GridList';
15
- export type { InfoPanelProps } from './InfoPanel';
16
- export { default as InfoPanel } from './InfoPanel';
17
- export type { ListComponentProps, ListProps } from './List';
18
- export { default as List } from './List';
19
- export type { ListObject } from './ListItem';
20
- export type { ListActionsProps } from './ListActions';
21
- export { default as ListActions } from './ListActions';
22
- export type { PageProps } from './Page';
23
- export { default as Page } from './Page';
24
- export type { PanelProps } from './Panel';
25
- export { default as Panel } from './Panel';
26
- export type { PageActionsProps } from './PageActions';
27
- export { default as PageActions } from './PageActions';
28
- export type { RootLayoutProps } from './RootLayout';
29
- export { default as RootLayout } from './RootLayout';
30
- export { default as SettingsPage } from './SettingsPage';
31
- export type { TableColumnObject } from './TableClientComponent';
32
- export type { TableProps } from './Table';
33
- export { default as Table } from './Table';