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

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 (101) hide show
  1. package/dist/components/AppLayout/index.d.ts +9 -0
  2. package/dist/components/AppLayout/index.js +14 -0
  3. package/dist/components/AppNavigation/index.d.ts +6 -0
  4. package/dist/components/AppNavigation/index.js +8 -0
  5. package/dist/components/AppNavigationComponent/index.d.ts +12 -0
  6. package/dist/components/AppNavigationComponent/index.js +19 -0
  7. package/dist/components/Auth/index.d.ts +10 -0
  8. package/dist/components/Auth/index.js +10 -0
  9. package/dist/components/Badge/index.d.ts +8 -0
  10. package/dist/components/Badge/index.js +20 -0
  11. package/dist/components/BooleanFilter/index.d.ts +5 -0
  12. package/dist/components/BooleanFilter/index.js +19 -0
  13. package/dist/components/Config/index.d.ts +6 -0
  14. package/dist/components/Config/index.js +9 -0
  15. package/dist/components/Dashboard/index.d.ts +7 -0
  16. package/dist/components/Dashboard/index.js +5 -0
  17. package/dist/components/DateFilter/index.d.ts +6 -0
  18. package/dist/components/DateFilter/index.js +31 -0
  19. package/dist/components/DropdownFilter/index.d.ts +6 -0
  20. package/dist/components/DropdownFilter/index.js +9 -0
  21. package/dist/components/FilterBar/index.d.ts +10 -0
  22. package/dist/components/FilterBar/index.js +39 -0
  23. package/dist/components/FilterBarClearButton/index.d.ts +6 -0
  24. package/dist/components/FilterBarClearButton/index.js +5 -0
  25. package/dist/components/FilterBarItem/index.d.ts +17 -0
  26. package/dist/components/FilterBarItem/index.js +32 -0
  27. package/dist/components/GridList/index.d.ts +5 -0
  28. package/dist/components/GridList/index.js +7 -0
  29. package/dist/components/GridListItem/index.d.ts +4 -0
  30. package/dist/components/GridListItem/index.js +8 -0
  31. package/dist/components/InfoPanel/index.d.ts +8 -0
  32. package/dist/components/InfoPanel/index.js +18 -0
  33. package/dist/components/List/index.d.ts +8 -0
  34. package/dist/components/List/index.js +23 -0
  35. package/dist/components/ListAction/index.d.ts +7 -0
  36. package/dist/components/ListAction/index.js +9 -0
  37. package/dist/components/ListActions/index.d.ts +11 -0
  38. package/dist/components/ListActions/index.js +19 -0
  39. package/dist/components/ListClientComponent/index.d.ts +15 -0
  40. package/dist/components/ListClientComponent/index.js +14 -0
  41. package/dist/components/ListComponent/index.d.ts +14 -0
  42. package/dist/components/ListComponent/index.js +21 -0
  43. package/dist/components/ListItem/index.d.ts +23 -0
  44. package/dist/components/ListItem/index.js +26 -0
  45. package/dist/components/ListSkeleton/index.d.ts +5 -0
  46. package/dist/components/ListSkeleton/index.js +5 -0
  47. package/dist/components/MeActions/index.d.ts +3 -0
  48. package/dist/components/MeActions/index.js +6 -0
  49. package/dist/components/MePanel/index.d.ts +9 -0
  50. package/dist/components/MePanel/index.js +7 -0
  51. package/dist/components/Menu/index.d.ts +8 -0
  52. package/dist/components/Menu/index.js +7 -0
  53. package/dist/components/MenuItem/index.d.ts +5 -0
  54. package/dist/components/MenuItem/index.js +20 -0
  55. package/dist/components/Page/index.d.ts +14 -0
  56. package/dist/components/Page/index.js +11 -0
  57. package/dist/components/PageActions/index.d.ts +6 -0
  58. package/dist/components/PageActions/index.js +13 -0
  59. package/dist/components/Panel/index.d.ts +9 -0
  60. package/dist/components/Panel/index.js +6 -0
  61. package/dist/components/RootLayout/index.d.ts +10 -0
  62. package/dist/components/RootLayout/index.js +15 -0
  63. package/dist/components/SettingsForm/index.d.ts +7 -0
  64. package/dist/components/SettingsForm/index.js +14 -0
  65. package/dist/components/SettingsPage/index.d.ts +3 -0
  66. package/dist/components/SettingsPage/index.js +9 -0
  67. package/dist/components/Table/index.d.ts +9 -0
  68. package/dist/components/Table/index.js +17 -0
  69. package/dist/components/TableClientComponent/index.d.ts +16 -0
  70. package/dist/components/TableClientComponent/index.js +49 -0
  71. package/dist/components/Tabs/index.d.ts +4 -0
  72. package/dist/components/Tabs/index.js +8 -0
  73. package/dist/components/TabsComponent/index.d.ts +8 -0
  74. package/dist/components/TabsComponent/index.js +9 -0
  75. package/dist/components/index.d.ts +33 -0
  76. package/dist/components/index.js +17 -0
  77. package/dist/hooks/useNavigation.d.ts +11 -0
  78. package/dist/hooks/useNavigation.js +27 -0
  79. package/dist/index.cjs +1166 -105
  80. package/dist/index.cjs.map +1 -1
  81. package/dist/index.d.ts +3 -169
  82. package/dist/index.js +3 -16
  83. package/dist/index.js.map +1 -1
  84. package/dist/interfaces.d.ts +10 -0
  85. package/dist/interfaces.js +1 -0
  86. package/dist/services/ConfigService.d.ts +17 -0
  87. package/dist/services/ConfigService.js +14 -0
  88. package/dist/services/PermissionService.d.ts +3 -0
  89. package/dist/services/PermissionService.js +25 -0
  90. package/dist/services/SettingsService.d.ts +8 -0
  91. package/dist/services/SettingsService.js +9 -0
  92. package/dist/styles/config.d.ts +3 -0
  93. package/dist/styles/config.js +184 -0
  94. package/dist/styles/postcss.d.ts +6 -0
  95. package/dist/styles/postcss.js +4 -0
  96. package/dist/styles/tailwind.d.ts +10 -0
  97. package/dist/styles/tailwind.js +76 -0
  98. package/package.json +18 -21
  99. package/dist/index.d.cts +0 -169
  100. /package/{postcss.js → postcss.cjs} +0 -0
  101. /package/{tailwind.js → tailwind.cjs} +0 -0
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ export interface AppLayoutProps {
3
+ children: React.ReactNode;
4
+ user?: {
5
+ name: string;
6
+ } | null;
7
+ }
8
+ declare function AppLayout({ children, user }: Readonly<AppLayoutProps>): Promise<JSX.Element>;
9
+ export default AppLayout;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Link, tw } from '@sqrzro/components';
3
+ import { getConfig } from '../../services/ConfigService';
4
+ import { getLayout } from '../../services/SettingsService';
5
+ import AppNavigation from '../AppNavigation';
6
+ import MePanel from '../MePanel';
7
+ async function AppLayout({ children, user }) {
8
+ const config = getConfig();
9
+ const layout = await getLayout();
10
+ return (_jsxs("div", { className: tw('', layout === 'sidebar' ? 'grid grid-cols-[12rem_1fr]' : null), children: [_jsx("header", { className: "bg-slate-800", children: _jsxs("div", { className: tw('flex items-center', layout === 'sidebar'
11
+ ? 'h-screen flex-col'
12
+ : 'h-16 border-b border-slate-700 px-4'), children: [_jsxs(Link, { className: tw(layout === 'sidebar' ? 'my-7 h-12 w-12' : 'h-9 w-9'), href: "/", children: [config.logo?.(), _jsx("span", { className: "sr-only", children: config.app.name })] }), _jsx(AppNavigation, { layout: layout }), _jsx(MePanel, { layout: layout, user: user })] }) }), _jsx("main", { className: "mb-10 block", children: children })] }));
13
+ }
14
+ export default AppLayout;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ interface AppNavigationProps {
3
+ layout?: string;
4
+ }
5
+ declare function AppNavigation({ layout, }: Readonly<AppNavigationProps>): Promise<React.ReactElement>;
6
+ export default AppNavigation;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { getConfig } from '../../services/ConfigService';
3
+ import { filterList } from '../../services/PermissionService';
4
+ import AppNavigationComponent from '../AppNavigationComponent';
5
+ async function AppNavigation({ layout, }) {
6
+ return (_jsx(AppNavigationComponent, { data: await filterList(getConfig().navigation), layout: layout }));
7
+ }
8
+ export default AppNavigation;
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ interface ConfigNavigationObject {
3
+ href: string;
4
+ label: string;
5
+ permission?: string;
6
+ }
7
+ interface AppNavigationComponentProps {
8
+ data: ConfigNavigationObject[];
9
+ layout?: string;
10
+ }
11
+ declare function AppNavigationComponent({ data, layout, }: Readonly<AppNavigationComponentProps>): React.ReactElement;
12
+ export default AppNavigationComponent;
@@ -0,0 +1,19 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { Link, tw } from '@sqrzro/components';
4
+ import useNavigation from '../../hooks/useNavigation';
5
+ function getActiveClassNames(layout) {
6
+ if (layout === 'sidebar') {
7
+ return 'bg-slate-700 text-white';
8
+ }
9
+ return 'before:bg-primary text-white before:absolute before:bottom-0 before:left-0 before:right-0 before:h-1';
10
+ }
11
+ function AppNavigationComponent({ data, layout, }) {
12
+ const navigation = useNavigation(data);
13
+ return (_jsx("nav", { className: tw('h-full', layout === 'sidebar' ? 'w-full' : 'pl-6'), children: _jsx("ul", { className: tw('flex h-full gap-4', layout === 'sidebar' ? 'flex-col items-start' : 'items-center'), children: navigation.map(({ href, isActive, label }) => (_jsx("li", { className: tw(layout === 'sidebar' ? 'w-full' : 'h-full'), children: _jsx(Link, { className: tw(layout === 'sidebar'
14
+ ? 'block px-4 py-3'
15
+ : 'relative flex h-full items-center px-1 font-semibold', isActive
16
+ ? getActiveClassNames(layout)
17
+ : 'text-white/80 hover:text-white'), href: href, children: label }) }, href))) }) }));
18
+ }
19
+ export default AppNavigationComponent;
@@ -0,0 +1,10 @@
1
+ declare const classNames: {
2
+ root: string;
3
+ logo: string;
4
+ panel: string;
5
+ title: string;
6
+ link: string;
7
+ actions: string;
8
+ footer: string;
9
+ };
10
+ export default classNames;
@@ -0,0 +1,10 @@
1
+ const classNames = {
2
+ root: 'bg-slate-800 gap-8',
3
+ logo: 'mx-auto flex h-12 w-32 items-end',
4
+ panel: 'rounded bg-white p-8 shadow-lg pb-10',
5
+ title: 'text-lg font-semibold mb-6 leading-none',
6
+ link: 'font-semibold text-link',
7
+ actions: 'pt-2 w-full',
8
+ footer: '-mb-2',
9
+ };
10
+ export default classNames;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import type { StyleVariant } from '@sqrzro/interfaces';
3
+ export interface BadgeProps {
4
+ children: React.ReactNode;
5
+ variant?: StyleVariant | null;
6
+ }
7
+ declare function Badge({ children, variant }: Readonly<BadgeProps>): React.ReactElement;
8
+ export default Badge;
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { tw } from '@sqrzro/components';
3
+ const classMap = {
4
+ danger: 'bg-red-100 text-red-700',
5
+ error: 'bg-red-100 text-red-700',
6
+ info: 'bg-sky-100 text-sky-700',
7
+ warning: 'bg-yellow-100 text-yellow-700',
8
+ success: 'bg-green-100 text-green-700',
9
+ };
10
+ const dotMap = {
11
+ danger: 'fill-red-400',
12
+ error: 'fill-red-400',
13
+ info: 'fill-sky-400',
14
+ warning: 'fill-yellow-400',
15
+ success: 'fill-green-400',
16
+ };
17
+ function Badge({ children, variant }) {
18
+ return (_jsxs("strong", { className: tw('inline-flex items-center gap-1.5 rounded-full bg-slate-100 px-2 py-1 text-xs font-medium text-slate-600', variant ? classMap[variant] : null), "data-testid": "badge-root", children: [_jsx("svg", { "aria-hidden": "true", className: tw('h-1.5 w-1.5 fill-slate-400', variant ? dotMap[variant] : null), viewBox: "0 0 6 6", children: _jsx("circle", { cx: "3", cy: "3", r: "3" }) }), children] }));
19
+ }
20
+ export default Badge;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import type { FilterComponentProps } from '../../interfaces';
3
+ declare function BooleanFilter({ name, onChange, value, }: Readonly<FilterComponentProps>): React.ReactElement;
4
+ export declare function renderBooleanValue(value: string): string;
5
+ export default BooleanFilter;
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Dropdown } from '@sqrzro/components';
3
+ const data = [
4
+ {
5
+ id: '0',
6
+ name: 'No',
7
+ },
8
+ {
9
+ id: '1',
10
+ name: 'Yes',
11
+ },
12
+ ];
13
+ function BooleanFilter({ name, onChange, value, }) {
14
+ return _jsx(Dropdown, { data: data, name: name, onChange: onChange, value: value, isPanelOnly: true });
15
+ }
16
+ export function renderBooleanValue(value) {
17
+ return data.find((item) => item.id === value)?.name || '';
18
+ }
19
+ export default BooleanFilter;
@@ -0,0 +1,6 @@
1
+ import type { Config as ConfigObject } from '../../services/ConfigService';
2
+ interface ConfigProps {
3
+ data?: ConfigObject;
4
+ }
5
+ declare function Config({ data }: Readonly<ConfigProps>): null;
6
+ export default Config;
@@ -0,0 +1,9 @@
1
+ 'use client';
2
+ import { setConfig } from '../../services/ConfigService';
3
+ function Config({ data }) {
4
+ if (data) {
5
+ setConfig(data);
6
+ }
7
+ return null;
8
+ }
9
+ export default Config;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ export interface DashboardProps {
3
+ children?: React.ReactNode;
4
+ title: string;
5
+ }
6
+ declare function Dashboard({ children, title }: Readonly<DashboardProps>): React.ReactElement;
7
+ export default Dashboard;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ function Dashboard({ children, title }) {
3
+ return (_jsxs("div", { className: "py-8", children: [_jsx("h1", { className: "mx-auto text-center text-4xl font-semibold", children: title }), children] }));
4
+ }
5
+ export default Dashboard;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import type { FilterComponentProps } from '../../interfaces';
3
+ declare function DateFilter({ name, onChange, value }: Readonly<FilterComponentProps>): React.ReactElement;
4
+ export declare function transformDateValue(value?: string | null): string;
5
+ export declare function renderDateValue(value: string): string;
6
+ export default DateFilter;
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { CalendarInput } from '@sqrzro/components';
3
+ function DateFilter({ name, onChange, value }) {
4
+ return _jsx(CalendarInput, { name: name, onChange: onChange, value: value, isPanelOnly: true, isRange: true });
5
+ }
6
+ export function transformDateValue(value) {
7
+ return value || '';
8
+ }
9
+ const LENGTH_OF_YEAR = 4;
10
+ function renderDateString(value, noYear) {
11
+ const date = new Date(value);
12
+ if (Number.isNaN(date.getTime())) {
13
+ return '';
14
+ }
15
+ const day = date.getDate().toString().padStart(2, '0');
16
+ const month = (date.getMonth() + 1).toString().padStart(2, '0');
17
+ const year = date.getFullYear();
18
+ return `${day}/${month}${noYear ? '' : `/${year}`}`;
19
+ }
20
+ export function renderDateValue(value) {
21
+ if (value.includes(',')) {
22
+ const values = value.split(',');
23
+ const years = values.map((item) => parseInt(item.substring(0, LENGTH_OF_YEAR), 10));
24
+ return value
25
+ .split(',')
26
+ .map((item) => renderDateString(item, years[0] === years[1] && years[0] === new Date().getFullYear()))
27
+ .join(' - ');
28
+ }
29
+ return renderDateString(value);
30
+ }
31
+ export default DateFilter;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import type { SimpleObject } from '@sqrzro/interfaces';
3
+ import type { FilterComponentProps } from '../../interfaces';
4
+ declare function DropdownFilter({ data, name, onChange, value, }: Readonly<FilterComponentProps>): React.ReactElement;
5
+ export declare function renderDropdownValue(value: string, data?: SimpleObject[]): string;
6
+ export default DropdownFilter;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Dropdown } from '@sqrzro/components';
3
+ function DropdownFilter({ data, name, onChange, value, }) {
4
+ return _jsx(Dropdown, { data: data, name: name, onChange: onChange, value: value, isPanelOnly: true });
5
+ }
6
+ export function renderDropdownValue(value, data) {
7
+ return data?.find((item) => item.id === value)?.name || '';
8
+ }
9
+ export default DropdownFilter;
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import type { FilterObject } from '../FilterBarItem';
3
+ export type { FilterObject } from '../FilterBarItem';
4
+ export interface FilterBarProps {
5
+ hasSearch?: boolean;
6
+ layout?: string;
7
+ map?: FilterObject[];
8
+ }
9
+ declare function FilterBar({ hasSearch, layout, map }: Readonly<FilterBarProps>): React.ReactElement;
10
+ export default FilterBar;
@@ -0,0 +1,39 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useState } from 'react';
4
+ import { TextInput, tw } from '@sqrzro/components';
5
+ import { useFilters } from '@sqrzro/hooks';
6
+ import { useRouter } from 'next/navigation';
7
+ import FilterBarClearButton from '../FilterBarClearButton';
8
+ import FilterBarItem from '../FilterBarItem';
9
+ function FilterBar({ hasSearch, layout, map }) {
10
+ const router = useRouter();
11
+ const [filters, setFilter] = useFilters();
12
+ const [search, setSearch] = useState(filters.get('search') || '');
13
+ function handleChange(name, value) {
14
+ setFilter(name, value);
15
+ router.refresh();
16
+ }
17
+ function handleSearchChange(event) {
18
+ setSearch(event.target.value || '');
19
+ }
20
+ function handleSearchClear() {
21
+ setSearch('');
22
+ setFilter('search', '');
23
+ }
24
+ function handleSearchKeyDown(event) {
25
+ if (event.key === 'Enter') {
26
+ setFilter('search', event.currentTarget.value);
27
+ }
28
+ }
29
+ return (_jsxs("ul", { className: tw('flex gap-2', layout === 'sidebar'
30
+ ? ''
31
+ : 'relative before:absolute before:left-[calc(50%-50vw)] before:top-full before:h-24 before:w-screen before:bg-slate-800'), children: [hasSearch ? (_jsxs("li", { className: "relative", children: [_jsx(TextInput, { classNames: {
32
+ root: {
33
+ default: tw('h-8 w-56 rounded-full border border-slate-400 px-3 text-xs text-white placeholder:text-slate-300', filters.get('search')
34
+ ? 'bg-slate-700'
35
+ : 'bg-transparent focus:bg-slate-700'),
36
+ },
37
+ }, name: "search", onChange: handleSearchChange, onKeyDown: handleSearchKeyDown, placeholder: "Search...", value: search }), filters.get('search') ? (_jsx(FilterBarClearButton, { onClick: handleSearchClear })) : null] })) : null, (map || []).map((filter) => (_jsx(FilterBarItem, { onChange: handleChange, value: filters.get(filter.name) || '', ...filter }, filter.name)))] }));
38
+ }
39
+ export default FilterBar;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ interface FilterBarClearButtonProps {
3
+ onClick: () => void;
4
+ }
5
+ declare function FilterBarClearButton({ onClick, }: Readonly<FilterBarClearButtonProps>): React.ReactElement;
6
+ export default FilterBarClearButton;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ function FilterBarClearButton({ onClick, }) {
3
+ return (_jsxs("button", { className: "absolute right-0 top-0 flex h-full w-10 select-none items-center justify-center", onClick: onClick, 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" })] }));
4
+ }
5
+ export default FilterBarClearButton;
@@ -0,0 +1,17 @@
1
+ /// <reference types="react" />
2
+ export type FilterType = 'boolean' | 'date' | 'dropdown';
3
+ export interface FilterObject {
4
+ data?: {
5
+ id: string;
6
+ name: string;
7
+ }[];
8
+ label: string;
9
+ name: string;
10
+ type: FilterType;
11
+ }
12
+ interface FilterBarItemProps extends FilterObject {
13
+ onChange: (name: string, value?: string) => void;
14
+ value?: string;
15
+ }
16
+ declare function FilterBarItem({ data, label, name, onChange, type, value, }: Readonly<FilterBarItemProps>): React.ReactElement;
17
+ export default FilterBarItem;
@@ -0,0 +1,32 @@
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
+ import FilterBarClearButton from '../FilterBarClearButton';
9
+ const map = {
10
+ boolean: { component: BooleanFilter, renderValue: renderBooleanValue },
11
+ date: {
12
+ component: DateFilter,
13
+ renderValue: renderDateValue,
14
+ size: 'w-96',
15
+ transformValue: transformDateValue,
16
+ },
17
+ dropdown: { component: DropdownFilter, renderValue: renderDropdownValue },
18
+ };
19
+ const DEFAULT_SIZE = 'w-56';
20
+ function FilterBarItem({ data, label, name, onChange, type, value, }) {
21
+ const panel = useRef(null);
22
+ function handleChange(event) {
23
+ onChange(name, event.target.value);
24
+ panel.current?.hidePopover();
25
+ }
26
+ function handleClear() {
27
+ onChange(name, '');
28
+ }
29
+ const { component: FilterComponent, renderValue, size, transformValue } = map[type];
30
+ return (_jsxs("li", { className: tw('relative inline-flex h-8 items-center gap-2 rounded-full border px-5 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 ? _jsx(FilterBarClearButton, { onClick: handleClear }) : 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 }) }) })] }));
31
+ }
32
+ export default FilterBarItem;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import type { ListProps } from '../List';
3
+ export type GridListProps<Item extends object, Params> = Omit<ListProps<Item, Params>, 'renderItem'>;
4
+ declare function GridList<Item extends object, Params>(props: GridListProps<Item, Params>): React.ReactElement;
5
+ export default GridList;
@@ -0,0 +1,7 @@
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;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import type { ListObject } from '../ListItem';
3
+ declare function GridListItem({ description, href, id, image, imageHref, meta, title, }: Readonly<ListObject>): React.ReactElement;
4
+ export default GridListItem;
@@ -0,0 +1,8 @@
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({ description, href, id, image, imageHref, meta, 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 }), description ? _jsx("p", { className: "text-xs text-slate-500", children: description }) : null, meta ? (_jsxs(Fragment, { children: [_jsx("hr", { className: "my-4" }), _jsx("div", { className: "flex items-center justify-between", children: meta ? renderMeta(id, 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;
@@ -0,0 +1,8 @@
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;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { tw } from '@sqrzro/components';
3
+ const iconClassMap = {
4
+ danger: 'bg-[url(/admin/images/danger.svg)]',
5
+ info: 'bg-[url(/admin/images/info.svg)]',
6
+ success: 'bg-[url(/admin/images/success.svg)]',
7
+ warning: 'bg-[url(/admin/images/warning.svg)]',
8
+ };
9
+ const classMap = {
10
+ danger: 'bg-red-100 text-red-700',
11
+ info: 'bg-sky-100 text-sky-700',
12
+ success: 'bg-green-100 text-green-700',
13
+ warning: 'bg-yellow-100 text-yellow-700',
14
+ };
15
+ function InfoPanel({ children, variant = 'info' }) {
16
+ return (_jsxs("aside", { className: tw('flex gap-2 rounded p-4', classMap[variant]), children: [_jsx("i", { className: tw('aspect-square w-5 flex-none bg-contain bg-no-repeat', iconClassMap[variant]) }), _jsx("div", { children: children })] }));
17
+ }
18
+ export default InfoPanel;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import type { FilterObject } from '../FilterBar';
3
+ import type { ListComponentProps } from '../ListComponent';
4
+ export interface ListProps<Item extends object, Params> extends ListComponentProps<Item, Params> {
5
+ filters?: FilterObject[];
6
+ }
7
+ declare function List<Item extends object, Params>({ filters, hasSearch, ...props }: Readonly<ListProps<Item, Params>>): Promise<React.ReactElement>;
8
+ export default List;
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Fragment, Suspense } from 'react';
3
+ import { getLayout } from '../../services/SettingsService';
4
+ import FilterBar from '../FilterBar';
5
+ import ListComponent from '../ListComponent';
6
+ import ListSkeleton from '../ListSkeleton';
7
+ const reservedSearchParams = ['action'];
8
+ function checkHasFilters(searchParams) {
9
+ return Array.from(searchParams.entries()).some(([key, value]) => !reservedSearchParams.includes(key) && Boolean(value));
10
+ }
11
+ async function List({ filters, hasSearch, ...props }) {
12
+ const layout = await getLayout();
13
+ let searchParams; // eslint-disable-line @typescript-eslint/init-declarations
14
+ try {
15
+ const { headers } = await import('next/headers');
16
+ searchParams = new URLSearchParams(headers().get('x-search-params') || '');
17
+ }
18
+ catch (err) {
19
+ searchParams = new URLSearchParams();
20
+ }
21
+ return (_jsxs(Fragment, { children: [filters || hasSearch ? (_jsx(FilterBar, { hasSearch: hasSearch, layout: layout, map: filters })) : null, _jsx(Suspense, { fallback: _jsx(ListSkeleton, {}), children: _jsx(ListComponent, { ...props, searchParams: searchParams }) })] }));
22
+ }
23
+ export default List;
@@ -0,0 +1,7 @@
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;
@@ -0,0 +1,9 @@
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;
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import type { ConfirmableAction, LinkableAction } from '@sqrzro/interfaces';
3
+ export interface ListAction extends Omit<ConfirmableAction & LinkableAction, 'onClick'> {
4
+ onClick?: (id: string) => void;
5
+ }
6
+ export interface ListActionsProps {
7
+ actions: ListAction[];
8
+ id: string;
9
+ }
10
+ declare function ListActions({ actions, id }: Readonly<ListActionsProps>): React.ReactElement;
11
+ export default ListActions;
@@ -0,0 +1,19 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useClickOutside } from '@sqrzro/hooks';
4
+ import Menu from '../Menu';
5
+ function ListActions({ actions, id }) {
6
+ const [isOpen, setIsOpen, ref] = useClickOutside();
7
+ function handleClick(item) {
8
+ item.onClick?.(id);
9
+ }
10
+ function toggleIsOpen() {
11
+ setIsOpen(!isOpen);
12
+ }
13
+ const transformedActions = actions.map((item) => ({
14
+ ...item,
15
+ onClick: () => handleClick(item),
16
+ }));
17
+ return (_jsxs("div", { ref: ref, className: "relative h-5", children: [_jsx("button", { onClick: toggleIsOpen, type: "button", children: _jsx("svg", { "aria-hidden": "true", className: "h-5 w-5 fill-slate-500", viewBox: "0 0 20 20", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M10 3a1.5 1.5 0 110 3 1.5 1.5 0 010-3zM10 8.5a1.5 1.5 0 110 3 1.5 1.5 0 010-3zM11.5 15.5a1.5 1.5 0 10-3 0 1.5 1.5 0 003 0z" }) }) }), isOpen ? _jsx(Menu, { actions: transformedActions, align: "right" }) : null] }));
18
+ }
19
+ export default ListActions;
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ import type { EmptyMessageProps } from '@sqrzro/components';
3
+ import type { ListAction } from '../ListActions';
4
+ import type { ListObject } from '../ListItem';
5
+ export interface ListClientComponentProps {
6
+ actions?: ListAction[];
7
+ columns?: number;
8
+ data: ListObject[];
9
+ emptyMessageProps?: EmptyMessageProps;
10
+ hasFilters?: boolean;
11
+ isMinimal?: boolean;
12
+ renderItem?: (props: ListObject) => JSX.Element;
13
+ }
14
+ declare function ListClientComponent({ actions, columns, data, emptyMessageProps, hasFilters, isMinimal, renderItem, }: Readonly<ListClientComponentProps>): React.ReactElement;
15
+ export default ListClientComponent;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Fragment } from 'react';
3
+ import { EmptyMessage, tw } from '@sqrzro/components';
4
+ import ListItem from '../ListItem';
5
+ function ListClientComponent({ actions, columns, data, emptyMessageProps, hasFilters, isMinimal, renderItem = ListItem, }) {
6
+ const componentEmptyMessageProps = hasFilters
7
+ ? {
8
+ children: 'Try adjusting the filters above. If you think this is a mistake, please contact your site administrator.',
9
+ title: 'No results match the current filters',
10
+ }
11
+ : emptyMessageProps;
12
+ return data.length ? (_jsx("ul", { className: tw('relative', columns ? 'grid grid-cols-3 gap-6' : 'flex flex-col gap-4'), children: data.map((item) => (_jsx(Fragment, { children: renderItem({ actions, isMinimal, ...item }) }, item.id))) })) : (_jsx(EmptyMessage, { ...componentEmptyMessageProps, classNameProps: { isMinimal } }));
13
+ }
14
+ export default ListClientComponent;
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ import type { Errorable } from '@sqrzro/interfaces';
3
+ import type { ListObject } from '../ListItem';
4
+ import type { ListClientComponentProps } from '../ListClientComponent';
5
+ export interface ListComponentProps<Item, Params> extends Omit<ListClientComponentProps, 'data' | 'hasFilters'> {
6
+ fn: (params?: Params, searchParams?: URLSearchParams) => Promise<Errorable<Item[]>>;
7
+ hasFilters?: boolean;
8
+ hasSearch?: boolean;
9
+ params?: Params;
10
+ searchParams?: URLSearchParams;
11
+ transformer?: (item: Item) => ListObject;
12
+ }
13
+ declare function ListComponent<Item extends object, Params>({ fn, hasFilters, params, searchParams, transformer, ...clientProps }: Readonly<ListComponentProps<Item, Params>>): Promise<React.ReactElement>;
14
+ export default ListComponent;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { filterList } from '../../services/PermissionService';
3
+ import ListClientComponent from '../ListClientComponent';
4
+ function defaultTransformer() {
5
+ return {
6
+ id: '',
7
+ title: '',
8
+ };
9
+ }
10
+ async function ListComponent({ fn, hasFilters, params, searchParams, transformer, ...clientProps }) {
11
+ const [response, error] = await fn(params, searchParams);
12
+ if (!Array.isArray(response)) {
13
+ throw new Error('Response is not an array. Did you forget to return an Errorable object in the function?');
14
+ }
15
+ if (error) {
16
+ return _jsx("div", { children: "Error" });
17
+ }
18
+ const data = await filterList(response.map(transformer || defaultTransformer));
19
+ return _jsx(ListClientComponent, { data: data, hasFilters: hasFilters, ...clientProps });
20
+ }
21
+ export default ListComponent;
@@ -0,0 +1,23 @@
1
+ /// <reference types="react" />
2
+ import type { ListAction } from '../ListActions';
3
+ export interface ListObject {
4
+ actions?: ListAction[];
5
+ description?: React.ReactNode | null;
6
+ href?: string;
7
+ id: string;
8
+ isMinimal?: boolean;
9
+ image?: string | null;
10
+ imageHref?: string | null;
11
+ meta?: React.ReactNode[] | Record<string, React.ReactNode>;
12
+ permission?: string;
13
+ secondary?: {
14
+ description?: string;
15
+ meta?: React.ReactNode[];
16
+ title?: string;
17
+ };
18
+ tertiary?: React.ReactNode;
19
+ title?: React.ReactNode;
20
+ }
21
+ export declare function renderMeta(id: string, meta: ListObject['meta']): React.ReactElement | null;
22
+ declare function ListItem({ actions, description, href, id, isMinimal, meta, secondary, tertiary, title, }: Readonly<ListObject>): React.ReactElement;
23
+ export default ListItem;