@sqrzro/admin 2.1.0-bz.9 → 2.1.0-r19.3

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 (126) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +8 -5
  3. package/assets/images/check-white.svg +3 -0
  4. package/assets/images/chevron.svg +3 -0
  5. package/assets/images/close.svg +3 -0
  6. package/assets/images/danger.svg +3 -0
  7. package/assets/images/eye.svg +12 -0
  8. package/assets/images/info.svg +3 -0
  9. package/assets/images/success.svg +3 -0
  10. package/assets/images/warning.svg +3 -0
  11. package/dist/components/AppLayout/index.d.ts +2 -2
  12. package/dist/components/AppLayout/index.js +7 -5
  13. package/dist/components/AppNavigation/index.d.ts +4 -2
  14. package/dist/components/AppNavigation/index.js +4 -13
  15. package/dist/components/AppNavigationComponent/index.d.ts +11 -0
  16. package/dist/components/AppNavigationComponent/index.js +19 -0
  17. package/dist/components/AppNavigationSub/index.d.ts +11 -0
  18. package/dist/components/AppNavigationSub/index.js +12 -0
  19. package/dist/components/Auth/index.d.ts +10 -0
  20. package/dist/components/Auth/index.js +10 -0
  21. package/dist/components/Badge/index.d.ts +1 -2
  22. package/dist/components/Badge/index.js +16 -7
  23. package/dist/components/BooleanFilter/index.d.ts +0 -1
  24. package/dist/components/Dashboard/index.d.ts +0 -1
  25. package/dist/components/Dashboard/index.js +1 -1
  26. package/dist/components/DataTable/index.d.ts +5 -0
  27. package/dist/components/DataTable/index.js +5 -0
  28. package/dist/components/DateFilter/index.d.ts +0 -1
  29. package/dist/components/DateFilter/index.js +24 -1
  30. package/dist/components/DropdownFilter/index.d.ts +0 -1
  31. package/dist/components/FilterBar/index.d.ts +4 -3
  32. package/dist/components/FilterBar/index.js +30 -3
  33. package/dist/components/FilterBarClearButton/index.d.ts +5 -0
  34. package/dist/components/FilterBarClearButton/index.js +5 -0
  35. package/dist/components/FilterBarItem/index.d.ts +4 -3
  36. package/dist/components/FilterBarItem/index.js +6 -5
  37. package/dist/components/GridList/index.d.ts +2 -3
  38. package/dist/components/GridListItem/index.d.ts +1 -2
  39. package/dist/components/GridListItem/index.js +3 -2
  40. package/dist/components/InfoPanel/index.d.ts +2 -2
  41. package/dist/components/InfoPanel/index.js +18 -6
  42. package/dist/components/List/index.d.ts +4 -20
  43. package/dist/components/List/index.js +13 -17
  44. package/dist/components/ListActions/index.d.ts +6 -4
  45. package/dist/components/ListActions/index.js +16 -3
  46. package/dist/components/ListClientComponent/index.d.ts +13 -0
  47. package/dist/components/ListClientComponent/index.js +14 -0
  48. package/dist/components/ListComponent/index.d.ts +13 -0
  49. package/dist/components/ListComponent/index.js +21 -0
  50. package/dist/components/ListItem/index.d.ts +19 -10
  51. package/dist/components/ListItem/index.js +18 -5
  52. package/dist/components/ListSkeleton/index.d.ts +4 -0
  53. package/dist/components/ListSkeleton/index.js +5 -0
  54. package/dist/components/MeActions/index.d.ts +4 -2
  55. package/dist/components/MeActions/index.js +4 -11
  56. package/dist/components/MePanel/index.d.ts +3 -2
  57. package/dist/components/MePanel/index.js +3 -2
  58. package/dist/components/Menu/index.d.ts +7 -0
  59. package/dist/components/Menu/index.js +7 -0
  60. package/dist/components/MenuItem/index.d.ts +4 -0
  61. package/dist/components/MenuItem/index.js +20 -0
  62. package/dist/components/Page/index.d.ts +4 -3
  63. package/dist/components/Page/index.js +6 -3
  64. package/dist/components/PageActions/index.d.ts +0 -1
  65. package/dist/components/PaginatedList/index.d.ts +8 -0
  66. package/dist/components/PaginatedList/index.js +18 -0
  67. package/dist/components/PaginatedListComponent/index.d.ts +13 -0
  68. package/dist/components/PaginatedListComponent/index.js +20 -0
  69. package/dist/components/Pagination/index.d.ts +7 -0
  70. package/dist/components/Pagination/index.js +40 -0
  71. package/dist/components/PaginationItem/index.d.ts +9 -0
  72. package/dist/components/PaginationItem/index.js +16 -0
  73. package/dist/components/Panel/index.d.ts +3 -2
  74. package/dist/components/Panel/index.js +13 -2
  75. package/dist/components/RootLayout/index.d.ts +2 -2
  76. package/dist/components/RootLayout/index.js +6 -12
  77. package/dist/components/SettingsForm/index.d.ts +6 -0
  78. package/dist/components/SettingsForm/index.js +14 -0
  79. package/dist/components/SettingsPage/index.d.ts +2 -0
  80. package/dist/components/SettingsPage/index.js +9 -0
  81. package/dist/components/Table/index.d.ts +6 -7
  82. package/dist/components/Table/index.js +16 -14
  83. package/dist/components/TableClientComponent/index.d.ts +0 -1
  84. package/dist/components/TableClientComponent/index.js +2 -11
  85. package/dist/components/TableComponent/index.d.ts +11 -0
  86. package/dist/components/TableComponent/index.js +17 -0
  87. package/dist/components/Tabs/index.d.ts +2 -7
  88. package/dist/components/Tabs/index.js +5 -22
  89. package/dist/components/TabsComponent/index.d.ts +7 -0
  90. package/dist/components/TabsComponent/index.js +9 -0
  91. package/dist/components/index.d.ts +12 -5
  92. package/dist/components/index.js +5 -2
  93. package/dist/hooks/useNavigation.d.ts +11 -0
  94. package/dist/hooks/useNavigation.js +27 -0
  95. package/dist/index.cjs +1266 -0
  96. package/dist/index.cjs.map +1 -0
  97. package/dist/index.js.map +1 -0
  98. package/dist/interfaces.d.ts +8 -2
  99. package/dist/services/ConfigService.d.ts +8 -3
  100. package/dist/services/ConfigService.js +6 -6
  101. package/dist/services/PermissionService.d.ts +3 -0
  102. package/dist/services/PermissionService.js +30 -0
  103. package/dist/services/SettingsService.d.ts +8 -0
  104. package/dist/services/SettingsService.js +9 -0
  105. package/dist/styles/config.js +119 -47
  106. package/dist/styles/tailwind.d.ts +9 -1
  107. package/dist/styles/tailwind.js +16 -3
  108. package/package.json +46 -45
  109. package/dist/components/Icon/index.d.ts +0 -8
  110. package/dist/components/Icon/index.js +0 -22
  111. package/dist/components/LoginForm/index.d.ts +0 -8
  112. package/dist/components/LoginForm/index.js +0 -7
  113. package/dist/icons/ErrorIcon/index.d.ts +0 -3
  114. package/dist/icons/ErrorIcon/index.js +0 -5
  115. package/dist/icons/InfoIcon/index.d.ts +0 -3
  116. package/dist/icons/InfoIcon/index.js +0 -5
  117. package/dist/icons/SuccessIcon/index.d.ts +0 -3
  118. package/dist/icons/SuccessIcon/index.js +0 -5
  119. package/dist/icons/WarningIcon/index.d.ts +0 -3
  120. package/dist/icons/WarningIcon/index.js +0 -5
  121. package/dist/services/AuthService.d.ts +0 -1
  122. package/dist/services/AuthService.js +0 -5
  123. package/dist/utility/formatters.d.ts +0 -1
  124. package/dist/utility/formatters.js +0 -8
  125. /package/{postcss.js → postcss.cjs} +0 -0
  126. /package/{tailwind.js → tailwind.cjs} +0 -0
@@ -0,0 +1,14 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { EditableForm, EditableRadioFormField, EditableSwitchFormField } from '@sqrzro/components';
4
+ import { useEditableForm } from '@sqrzro/hooks';
5
+ import { submitSettingsForm } from '../../services/SettingsService';
6
+ const options = { sidebar: 'Side bar', topbar: 'Top bar' };
7
+ function SettingsForm({ defaults }) {
8
+ const { fieldProps, formProps } = useEditableForm({
9
+ defaults,
10
+ onSubmit: submitSettingsForm,
11
+ });
12
+ return (_jsxs(EditableForm, { title: "Appearance", ...formProps, children: [_jsx(EditableRadioFormField, { ...fieldProps('layout'), options: options, renderValue: (value) => (value ? options[value] || '-' : '-') }), _jsx(EditableSwitchFormField, { ...fieldProps('isDark'), label: "Dark mode" })] }));
13
+ }
14
+ export default SettingsForm;
@@ -0,0 +1,2 @@
1
+ declare function SettingsPage(): Promise<React.ReactElement>;
2
+ export default SettingsPage;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { getLayout } from '../../services/SettingsService';
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("div", { className: "flex flex-col gap-6", children: _jsx(SettingsForm, { defaults: { layout } }) }) }));
8
+ }
9
+ export default SettingsPage;
@@ -1,9 +1,8 @@
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>;
1
+ import type { FilterObject } from '../FilterBar';
2
+ import type { TableComponentProps } from '../TableComponent';
3
+ export interface TableProps<Item extends object, Params> extends Omit<TableComponentProps<Item, Params>, 'actions'> {
4
+ actions?: (data: Record<string, unknown>) => React.ReactNode;
5
+ filters?: FilterObject[];
7
6
  }
8
- declare function Table<T>({ columns, fn, searchParams, }: Readonly<TableProps<T>>): Promise<React.ReactElement>;
7
+ declare function Table<Item extends object, Params>({ filters, hasSearch, ...props }: Readonly<TableProps<Item, Params>>): Promise<React.ReactElement>;
9
8
  export default Table;
@@ -1,17 +1,19 @@
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" });
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 Panel from '../Panel';
6
+ import TableComponent from '../TableComponent';
7
+ async function Table({ filters, hasSearch, ...props }) {
8
+ const layout = await getLayout();
9
+ let searchParams; // eslint-disable-line @typescript-eslint/init-declarations
10
+ try {
11
+ const { headers } = await import('next/headers');
12
+ searchParams = new URLSearchParams((await headers()).get('x-search-params') || '');
13
+ }
14
+ catch (err) {
15
+ searchParams = new URLSearchParams();
13
16
  }
14
- const data = response.map(defaultTransformer);
15
- return _jsx(TableClientComponent, { columns: columns, data: data });
17
+ return (_jsxs(Fragment, { children: [filters || hasSearch ? (_jsx(FilterBar, { hasSearch: hasSearch, layout: layout, map: filters })) : null, _jsx(Panel, { children: _jsx(Suspense, { fallback: _jsx("div", { children: "Loading..." }), children: _jsx(TableComponent, { ...props, searchParams: searchParams }) }) })] }));
16
18
  }
17
19
  export default Table;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export interface TableItemObject {
3
2
  [key: string]: string;
4
3
  id: string;
@@ -1,15 +1,7 @@
1
1
  'use client';
2
2
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
3
- import { useState } from 'react';
4
- import clsx from 'clsx';
5
- import { Link } from '@sqrzro/components';
3
+ import { Link, tw } from '@sqrzro/components';
6
4
  import { usePathname, useSearchParams } from 'next/navigation';
7
- function toggleArrayItem(array, item) {
8
- if (array.includes(item)) {
9
- return array.filter((itm) => itm !== item);
10
- }
11
- return [...array, item];
12
- }
13
5
  function createFilterLink(pathname, searchParams, filters) {
14
6
  const updatedSearchParams = new URLSearchParams({
15
7
  ...Object.fromEntries(searchParams),
@@ -48,10 +40,9 @@ function parseColumns(columns) {
48
40
  function TableClientComponent({ columns, data, }) {
49
41
  const pathname = usePathname();
50
42
  const searchParams = useSearchParams();
51
- const [selected, setSelected] = useState([]);
52
43
  const parsedColumns = parseColumns(columns);
53
44
  const hasTitles = parsedColumns.some((column) => column.title);
54
- 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: clsx('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: clsx('border-x border-transparent p-4', getSortIconProps(searchParams, column.key).dir
45
+ 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
55
46
  ? 'border-sky-300 bg-sky-300/10'
56
47
  : '', column.type === 'number' ? 'text-right' : 'text-left'), children: item[column.key] }, column.key))) }, item.id))) })] }) }));
57
48
  }
@@ -0,0 +1,11 @@
1
+ import type { Errorable } from '@sqrzro/interfaces';
2
+ import type { TableClientComponentProps, TableItemObject } from '../TableClientComponent';
3
+ export interface TableComponentProps<Item, Params> extends Omit<TableClientComponentProps, 'data'> {
4
+ fn: (params?: Params, searchParams?: URLSearchParams) => Promise<Errorable<Item[]>>;
5
+ hasSearch?: boolean;
6
+ params?: Params;
7
+ searchParams?: URLSearchParams;
8
+ transformer?: (item: Item) => TableItemObject;
9
+ }
10
+ declare function TableComponent<Item extends object, Params>({ columns, fn, params, searchParams, transformer, }: Readonly<TableComponentProps<Item, Params>>): Promise<React.ReactElement>;
11
+ export default TableComponent;
@@ -0,0 +1,17 @@
1
+ import { jsxs as _jsxs, 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 TableComponent({ columns, fn, params, searchParams, transformer, }) {
10
+ const [response, error] = await fn(params, searchParams);
11
+ if (error) {
12
+ return _jsxs("div", { children: ["Error - ", error.message] });
13
+ }
14
+ const data = response.map(transformer || defaultTransformer);
15
+ return _jsx(TableClientComponent, { columns: columns, data: data });
16
+ }
17
+ export default TableComponent;
@@ -1,8 +1,3 @@
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;
1
+ import type { TabsComponentProps } from '../TabsComponent';
2
+ declare function Tabs({ basePath, data }: Readonly<TabsComponentProps>): Promise<React.ReactElement>;
8
3
  export default Tabs;
@@ -1,25 +1,8 @@
1
- 'use client';
2
1
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { Link } from '@sqrzro/components';
4
- import { useNavigation } from '@sqrzro/hooks';
5
- import clsx from 'clsx';
6
- function Tabs({ basePath = '', data }) {
7
- const navigation = useNavigation([basePath, data]);
8
- 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: clsx('block px-1 pb-2 font-semibold', isActive
9
- ? 'border-primary border-b-4 text-white'
10
- : 'text-white/80 hover:text-white'), href: href, children: label }) }, href))) }) }));
11
- // return (
12
- // <nav className="border-y border-slate-700">
13
- // <ul className="flex gap-4 font-semibold">
14
- // {data.map(({ href, label }) => (
15
- // <li key={href}>
16
- // <Link className="block py-2 text-white" href={`${basePath}${href || ''}`}>
17
- // {label}
18
- // </Link>
19
- // </li>
20
- // ))}
21
- // </ul>
22
- // </nav>
23
- // );
2
+ import { filterNull } from '@sqrzro/utility';
3
+ import { filterList } from '../../services/PermissionService';
4
+ import TabsComponent from '../TabsComponent';
5
+ async function Tabs({ basePath, data }) {
6
+ return _jsx(TabsComponent, { basePath: basePath, data: await filterList(filterNull(data)) });
24
7
  }
25
8
  export default Tabs;
@@ -0,0 +1,7 @@
1
+ import type { NavigationAction } from '../../interfaces';
2
+ export interface TabsComponentProps {
3
+ basePath?: string;
4
+ data: NavigationAction[];
5
+ }
6
+ declare function TabsComponent({ basePath, data }: Readonly<TabsComponentProps>): React.ReactElement;
7
+ export default TabsComponent;
@@ -0,0 +1,9 @@
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 TabsComponent({ basePath = '', data }) {
6
+ const navigation = useNavigation(data, { basePath });
7
+ return (_jsx("nav", { children: _jsx("ul", { className: "flex gap-4", children: navigation.map(({ href, isActive, label }) => (_jsx("li", { children: _jsx(Link, { className: tw('block border-b-4 border-transparent px-1 pb-2 font-semibold', isActive ? 'border-primary' : 'opacity-80 hover:opacity-100'), href: href, children: label }) }, href))) }) }));
8
+ }
9
+ export default TabsComponent;
@@ -1,31 +1,38 @@
1
- export { Button, CalendarInput, ConnectedDropdown, DateFormField, DateInput, Dropdown, DropdownFormField, EditableDateFormField, EditableDropdownFormField, EditableForm, EditableFormField, EditableMultiFormField, EditableNumberFormField, EditableSwitchFormField, EditableTextFormField, Fieldset, Form, FormField, FormSubmit, ImageInput, ImageFormField, Link, ModalForm, MultiFormField, NumberFormField, NumberInput, Switch, TextFormField, TextInput, Toaster, } from '@sqrzro/components';
1
+ export { Autocomplete, AutocompleteFormField, Button, CalendarInput, CheckboxInput, ConfirmableButton, ConfirmableForm, ContentFormField, DateFormField, DateInput, DefinitionList, Dropdown, DropdownFormField, EditableAutocompleteFormField, EditableContentFormField, EditableDateFormField, EditableDropdownFormField, EditableForm, EditableFormField, EditableMoneyFormField, EditableMultiFormField, EditableNumberFormField, EditableSwitchFormField, EditableTextAreaFormField, EditableTextFormField, EmptyMessage, Fieldset, Form, FormField, FormSubmit, ImageInput, ImageFormField, Link, LoadingModal, Mail, MailBlock, MailButton, Modal, ModalActions, ModalForm, MoneyFormField, MoneyInput, MultiFormField, NumberFormField, NumberInput, ObjectFormField, RadioInput, Switch, SwitchFormField, TextArea, TextAreaFormField, TextFormField, TextInput, Toaster, } from '@sqrzro/components';
2
+ export type { DropdownItem, EditableFormFieldProps, FormFieldProps, LinkProps, MailProps, MailBlockProps, MailButtonProps, NumberInputProps, } from '@sqrzro/components';
2
3
  export type { AppLayoutProps } from './AppLayout';
3
4
  export { default as AppLayout } from './AppLayout';
4
5
  export type { BadgeProps } from './Badge';
5
6
  export { default as Badge } from './Badge';
6
7
  export type { DashboardProps } from './Dashboard';
7
8
  export { default as Dashboard } from './Dashboard';
9
+ export type { DataTableProps } from './DataTable';
10
+ export { default as DataTable } from './DataTable';
8
11
  export type { FilterBarProps, FilterObject } from './FilterBar';
9
12
  export { default as FilterBar } from './FilterBar';
10
13
  export type { GridListProps } from './GridList';
11
14
  export { default as GridList } from './GridList';
12
15
  export type { InfoPanelProps } from './InfoPanel';
13
16
  export { default as InfoPanel } from './InfoPanel';
14
- export type { ListComponentProps, ListProps } from './List';
17
+ export type { ListProps } from './List';
15
18
  export { default as List } from './List';
19
+ export type { ListClientComponentProps } from './ListClientComponent';
20
+ export { default as ListClientComponent } from './ListClientComponent';
16
21
  export type { ListObject } from './ListItem';
17
- export type { ListActionsProps } from './ListActions';
22
+ export type { ListAction, ListActionsProps } from './ListActions';
18
23
  export { default as ListActions } from './ListActions';
19
- export type { LoginFormProps } from './LoginForm';
20
- export { default as LoginForm } from './LoginForm';
21
24
  export type { PageProps } from './Page';
22
25
  export { default as Page } from './Page';
26
+ export type { PaginatedListProps } from './PaginatedList';
27
+ export { default as PaginatedList } from './PaginatedList';
23
28
  export type { PanelProps } from './Panel';
24
29
  export { default as Panel } from './Panel';
25
30
  export type { PageActionsProps } from './PageActions';
26
31
  export { default as PageActions } from './PageActions';
27
32
  export type { RootLayoutProps } from './RootLayout';
28
33
  export { default as RootLayout } from './RootLayout';
34
+ export { default as SettingsPage } from './SettingsPage';
29
35
  export type { TableColumnObject } from './TableClientComponent';
30
36
  export type { TableProps } from './Table';
31
37
  export { default as Table } from './Table';
38
+ export type { TableItemObject } from './TableClientComponent';
@@ -1,16 +1,19 @@
1
1
  // Exported from @sqrzro/components
2
- export { Button, CalendarInput, ConnectedDropdown, DateFormField, DateInput, Dropdown, DropdownFormField, EditableDateFormField, EditableDropdownFormField, EditableForm, EditableFormField, EditableMultiFormField, EditableNumberFormField, EditableSwitchFormField, EditableTextFormField, Fieldset, Form, FormField, FormSubmit, ImageInput, ImageFormField, Link, ModalForm, MultiFormField, NumberFormField, NumberInput, Switch, TextFormField, TextInput, Toaster, } from '@sqrzro/components';
2
+ export { Autocomplete, AutocompleteFormField, Button, CalendarInput, CheckboxInput, ConfirmableButton, ConfirmableForm, ContentFormField, DateFormField, DateInput, DefinitionList, Dropdown, DropdownFormField, EditableAutocompleteFormField, EditableContentFormField, EditableDateFormField, EditableDropdownFormField, EditableForm, EditableFormField, EditableMoneyFormField, EditableMultiFormField, EditableNumberFormField, EditableSwitchFormField, EditableTextAreaFormField, EditableTextFormField, EmptyMessage, Fieldset, Form, FormField, FormSubmit, ImageInput, ImageFormField, Link, LoadingModal, Mail, MailBlock, MailButton, Modal, ModalActions, ModalForm, MoneyFormField, MoneyInput, MultiFormField, NumberFormField, NumberInput, ObjectFormField, RadioInput, Switch, SwitchFormField, TextArea, TextAreaFormField, TextFormField, TextInput, Toaster, } from '@sqrzro/components';
3
3
  export { default as AppLayout } from './AppLayout';
4
4
  export { default as Badge } from './Badge';
5
5
  export { default as Dashboard } from './Dashboard';
6
+ export { default as DataTable } from './DataTable';
6
7
  export { default as FilterBar } from './FilterBar';
7
8
  export { default as GridList } from './GridList';
8
9
  export { default as InfoPanel } from './InfoPanel';
9
10
  export { default as List } from './List';
11
+ export { default as ListClientComponent } from './ListClientComponent';
10
12
  export { default as ListActions } from './ListActions';
11
- export { default as LoginForm } from './LoginForm';
12
13
  export { default as Page } from './Page';
14
+ export { default as PaginatedList } from './PaginatedList';
13
15
  export { default as Panel } from './Panel';
14
16
  export { default as PageActions } from './PageActions';
15
17
  export { default as RootLayout } from './RootLayout';
18
+ export { default as SettingsPage } from './SettingsPage';
16
19
  export { default as Table } from './Table';
@@ -0,0 +1,11 @@
1
+ import type { NavigationAction } from '../interfaces';
2
+ interface NavigationObject {
3
+ href: string;
4
+ isActive: boolean;
5
+ label: string;
6
+ }
7
+ interface UseNavigationOptions {
8
+ basePath?: string;
9
+ }
10
+ declare function useNavigation(data: NavigationAction[], options?: UseNavigationOptions): NavigationObject[];
11
+ export default useNavigation;
@@ -0,0 +1,27 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { joinUrl } from '@sqrzro/utility';
3
+ import { usePathname } from 'next/navigation';
4
+ function getActiveHref(pathname, hrefs) {
5
+ return (hrefs
6
+ .filter((href) => href && pathname.startsWith(`/${href.replace(/^\//u, '')}`))
7
+ .sort((first, second) => {
8
+ if (!first || !second) {
9
+ return 0;
10
+ }
11
+ return second.length - first.length;
12
+ })[0] || '');
13
+ }
14
+ function useNavigation(data, options) {
15
+ const [activeHref, setActiveHref] = useState('');
16
+ const pathname = usePathname();
17
+ const hrefs = data.map(({ href }) => joinUrl(options?.basePath, href));
18
+ useEffect(() => {
19
+ setActiveHref(getActiveHref(pathname, hrefs));
20
+ }, [pathname]);
21
+ return data.map(({ href, label }) => ({
22
+ href: joinUrl(options?.basePath, href),
23
+ isActive: joinUrl(options?.basePath, href) === activeHref,
24
+ label,
25
+ }));
26
+ }
27
+ export default useNavigation;