@sqrzro/admin 2.1.0-r19.39 → 2.1.0-r19.41

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.
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ export interface ConfigNavigationObject {
3
+ children?: ConfigNavigationObject[];
4
+ href: string;
5
+ label: string;
6
+ permission?: string;
7
+ }
8
+ interface AppNavigationItemProps extends ConfigNavigationObject {
9
+ isActive?: boolean;
10
+ layout?: string;
11
+ }
12
+ declare function AppNavigationItem({ children, href, isActive, label, layout, }: Readonly<AppNavigationItemProps>): React.ReactElement;
13
+ export default AppNavigationItem;
@@ -0,0 +1,18 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Link, tw } from '@sqrzro/components';
4
+ import { useClickOutside } from '@sqrzro/hooks';
5
+ import Menu from '../Menu';
6
+ function getActiveClassNames(layout) {
7
+ if (layout === 'sidebar') {
8
+ return 'bg-slate-700 text-white';
9
+ }
10
+ return 'before:bg-primary text-white before:absolute before:bottom-0 before:left-0 before:right-0 before:h-1';
11
+ }
12
+ function AppNavigationItem({ children, href, isActive, label, layout, }) {
13
+ const [isOpen, setIsOpen, node] = useClickOutside();
14
+ return (_jsxs("li", { ref: node, className: tw('relative', layout === 'sidebar' ? 'w-full' : 'h-full'), children: [_jsx(Link, { className: tw(layout === 'sidebar'
15
+ ? 'block px-4 py-3'
16
+ : 'relative flex h-full items-center px-1 font-semibold', isActive ? getActiveClassNames(layout) : 'text-white/80 hover:text-white'), href: children?.length ? undefined : href, onClick: children?.length ? () => setIsOpen(!isOpen) : undefined, children: label }), children?.length && isOpen ? _jsx(Menu, { actions: children, align: "left" }) : null] }, href));
17
+ }
18
+ export default AppNavigationItem;
@@ -0,0 +1,6 @@
1
+ export interface BooleanBadgeProps {
2
+ condition: boolean;
3
+ labels?: [string, string];
4
+ }
5
+ declare function BooleanBadge({ condition, labels, }: Readonly<BooleanBadgeProps>): React.ReactElement;
6
+ export default BooleanBadge;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import Badge from '../Badge';
3
+ const DEFAULT_LABELS = ['Yes', 'No'];
4
+ function BooleanBadge({ condition, labels = DEFAULT_LABELS, }) {
5
+ return (_jsx(Badge, { variant: condition ? 'success' : 'error', children: condition ? labels[0] : labels[1] }));
6
+ }
7
+ export default BooleanBadge;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { StyleVariant } from '@sqrzro/interfaces';
3
2
  type InfoPanelVariant = StyleVariant | 'mail';
4
3
  export interface InfoPanelProps {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { ConfirmableAction } from '@sqrzro/interfaces';
3
2
  interface ListActionProps extends ConfirmableAction<number> {
4
3
  id: number;
@@ -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;
@@ -3,9 +3,8 @@ export interface RootLayoutProps {
3
3
  bodyClass?: string;
4
4
  children: React.ReactNode;
5
5
  config?: ConfigObject;
6
- font?: string;
7
6
  logo?: () => React.ReactElement;
8
7
  message?: React.ReactNode;
9
8
  }
10
- declare function RootLayout({ bodyClass, children, config, font, logo, message, }: Readonly<RootLayoutProps>): React.ReactElement;
9
+ declare function RootLayout({ bodyClass, children, config, logo, message, }: Readonly<RootLayoutProps>): React.ReactElement;
11
10
  export default RootLayout;
@@ -1,14 +1,19 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /* eslint-disable react/no-danger */
3
3
  import { ClassNames, Toaster, tw } from '@sqrzro/components';
4
+ import { Inter as getFont } from 'next/font/google';
4
5
  import { setConfig } from '../../services/ConfigService';
5
6
  import classNames from '../../styles/config';
6
7
  import Config from '../Config';
7
- function RootLayout({ bodyClass, children, config, font, logo, message, }) {
8
+ const font = getFont({
9
+ subsets: ['latin'],
10
+ variable: '--font-sans',
11
+ });
12
+ function RootLayout({ bodyClass, children, config, logo, message, }) {
8
13
  if (config) {
9
14
  setConfig(config, logo);
10
15
  }
11
- return (_jsxs("html", { lang: "en", children: [_jsx("head", { children: _jsx("link", { href: "/images/favicon.svg", rel: "icon" }) }), _jsxs("body", { className: tw(font, 'overflow-x-hidden overflow-y-scroll bg-slate-50 font-sans text-sm text-slate-800 has-[[data-modal][open]]:overflow-hidden', bodyClass), children: [_jsx("script", { dangerouslySetInnerHTML: {
16
+ return (_jsxs("html", { className: font.variable, lang: "en", children: [_jsx("head", { children: _jsx("link", { href: "/images/favicon.svg", rel: "icon" }) }), _jsxs("body", { className: tw('overflow-x-hidden overflow-y-scroll bg-slate-50 font-sans text-sm text-slate-800 has-[[data-modal][open]]:overflow-hidden', bodyClass), children: [_jsx("script", { dangerouslySetInnerHTML: {
12
17
  __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))",
13
18
  } }), _jsx(Config, { data: config }), _jsx(ClassNames, { data: classNames }), _jsxs("div", { className: "flex min-h-screen flex-col", children: [message ? (_jsxs("div", { className: "sticky left-0 right-0 top-0 z-50 flex gap-2 bg-amber-500 px-4 py-2", children: [_jsx("i", { className: "h-5 w-5 bg-[url(/admin/images/warning-dark.svg)] bg-contain" }), message] })) : null, children] }), _jsx(Toaster, {})] })] }));
14
19
  }
@@ -7,6 +7,8 @@ export { default as AppLayout } from './AppLayout';
7
7
  export { default as AppPageNotFound } from './AppPageNotFound';
8
8
  export type { BadgeProps } from './Badge';
9
9
  export { default as Badge } from './Badge';
10
+ export type { BooleanBadgeProps } from './BooleanBadge';
11
+ export { default as BooleanBadge } from './BooleanBadge';
10
12
  export type { DashboardProps } from './Dashboard';
11
13
  export { default as Dashboard } from './Dashboard';
12
14
  export type { DataTableProps } from './DataTable';
@@ -4,6 +4,7 @@ export { default as AppError } from './AppError';
4
4
  export { default as AppLayout } from './AppLayout';
5
5
  export { default as AppPageNotFound } from './AppPageNotFound';
6
6
  export { default as Badge } from './Badge';
7
+ export { default as BooleanBadge } from './BooleanBadge';
7
8
  export { default as Dashboard } from './Dashboard';
8
9
  export { default as DataTable } from './DataTable';
9
10
  export { default as FilterBar } from './FilterBar';