@sqrzro/admin 2.1.0-bz.16 → 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.
- package/dist/index.cjs +205 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +169 -0
- package/dist/index.d.ts +169 -3
- package/dist/index.js +16 -3
- package/dist/index.js.map +1 -0
- package/package.json +28 -14
- package/dist/components/AppLayout/index.d.ts +0 -9
- package/dist/components/AppLayout/index.js +0 -14
- package/dist/components/AppNavigation/index.d.ts +0 -6
- package/dist/components/AppNavigation/index.js +0 -16
- package/dist/components/Auth/index.d.ts +0 -5
- package/dist/components/Auth/index.js +0 -15
- package/dist/components/Badge/index.d.ts +0 -8
- package/dist/components/Badge/index.js +0 -11
- package/dist/components/BooleanFilter/index.d.ts +0 -5
- package/dist/components/BooleanFilter/index.js +0 -19
- package/dist/components/Config/index.d.ts +0 -6
- package/dist/components/Config/index.js +0 -9
- package/dist/components/Dashboard/index.d.ts +0 -7
- package/dist/components/Dashboard/index.js +0 -5
- package/dist/components/DateFilter/index.d.ts +0 -6
- package/dist/components/DateFilter/index.js +0 -31
- package/dist/components/DropdownFilter/index.d.ts +0 -6
- package/dist/components/DropdownFilter/index.js +0 -9
- package/dist/components/FilterBar/index.d.ts +0 -9
- package/dist/components/FilterBar/index.js +0 -21
- package/dist/components/FilterBarItem/index.d.ts +0 -15
- package/dist/components/FilterBarItem/index.js +0 -31
- package/dist/components/GridList/index.d.ts +0 -5
- package/dist/components/GridList/index.js +0 -7
- package/dist/components/GridListItem/index.d.ts +0 -4
- package/dist/components/GridListItem/index.js +0 -8
- package/dist/components/Icon/index.d.ts +0 -8
- package/dist/components/Icon/index.js +0 -23
- package/dist/components/InfoPanel/index.d.ts +0 -8
- package/dist/components/InfoPanel/index.js +0 -22
- package/dist/components/List/index.d.ts +0 -25
- package/dist/components/List/index.js +0 -39
- package/dist/components/ListAction/index.d.ts +0 -7
- package/dist/components/ListAction/index.js +0 -9
- package/dist/components/ListActions/index.d.ts +0 -8
- package/dist/components/ListActions/index.js +0 -12
- package/dist/components/ListItem/index.d.ts +0 -18
- package/dist/components/ListItem/index.js +0 -16
- package/dist/components/MeActions/index.d.ts +0 -3
- package/dist/components/MeActions/index.js +0 -6
- package/dist/components/MePanel/index.d.ts +0 -8
- package/dist/components/MePanel/index.js +0 -6
- package/dist/components/Page/index.d.ts +0 -12
- package/dist/components/Page/index.js +0 -12
- package/dist/components/PageActions/index.d.ts +0 -6
- package/dist/components/PageActions/index.js +0 -13
- package/dist/components/Panel/index.d.ts +0 -7
- package/dist/components/Panel/index.js +0 -5
- package/dist/components/RootLayout/index.d.ts +0 -9
- package/dist/components/RootLayout/index.js +0 -21
- package/dist/components/SettingsForm/index.d.ts +0 -9
- package/dist/components/SettingsForm/index.js +0 -14
- package/dist/components/SettingsPage/index.d.ts +0 -3
- package/dist/components/SettingsPage/index.js +0 -9
- package/dist/components/Table/index.d.ts +0 -9
- package/dist/components/Table/index.js +0 -17
- package/dist/components/TableClientComponent/index.d.ts +0 -16
- package/dist/components/TableClientComponent/index.js +0 -57
- package/dist/components/Tabs/index.d.ts +0 -8
- package/dist/components/Tabs/index.js +0 -11
- package/dist/components/index.d.ts +0 -33
- package/dist/components/index.js +0 -17
- package/dist/icons/ErrorIcon/index.d.ts +0 -3
- package/dist/icons/ErrorIcon/index.js +0 -5
- package/dist/icons/InfoIcon/index.d.ts +0 -3
- package/dist/icons/InfoIcon/index.js +0 -5
- package/dist/icons/SuccessIcon/index.d.ts +0 -3
- package/dist/icons/SuccessIcon/index.js +0 -5
- package/dist/icons/WarningIcon/index.d.ts +0 -3
- package/dist/icons/WarningIcon/index.js +0 -5
- package/dist/interfaces.d.ts +0 -4
- package/dist/interfaces.js +0 -1
- package/dist/services/ConfigService.d.ts +0 -11
- package/dist/services/ConfigService.js +0 -14
- package/dist/services/LayoutService.d.ts +0 -7
- package/dist/services/LayoutService.js +0 -9
- package/dist/styles/config.d.ts +0 -3
- package/dist/styles/config.js +0 -145
- package/dist/styles/postcss.d.ts +0 -6
- package/dist/styles/postcss.js +0 -4
- package/dist/styles/tailwind.d.ts +0 -10
- package/dist/styles/tailwind.js +0 -72
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { AuthProps as AuthProps$1, EmptyMessageProps } from '@sqrzro/components';
|
|
2
|
+
export { Autocomplete, AutocompleteFormField, Button, CalendarInput, CheckboxInput, ConfirmableButton, ConnectedDropdown, ContentFormField, DateFormField, DateInput, DefinitionList, Dropdown, DropdownFormField, DropdownItem, EditableDateFormField, EditableDropdownFormField, EditableForm, EditableFormField, EditableMultiFormField, EditableNumberFormField, EditableSwitchFormField, EditableTextAreaFormField, EditableTextFormField, EmptyMessage, Fieldset, Form, FormField, FormSubmit, ImageFormField, ImageInput, Link, LoadingModal, ModalForm, MultiFormField, NumberFormField, NumberInput, RadioInput, Switch, SwitchFormField, TextArea, TextAreaFormField, TextFormField, TextInput, Toaster } from '@sqrzro/components';
|
|
3
|
+
import { StyleVariant, SimpleObject, Errorable, ConfirmableAction, InputProps, LinkableAction } from '@sqrzro/interfaces';
|
|
4
|
+
|
|
5
|
+
interface AppLayoutProps {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
user?: {
|
|
8
|
+
name: string;
|
|
9
|
+
} | null;
|
|
10
|
+
}
|
|
11
|
+
declare function AppLayout({ children, user }: Readonly<AppLayoutProps>): Promise<JSX.Element>;
|
|
12
|
+
|
|
13
|
+
type AuthProps = AuthProps$1;
|
|
14
|
+
declare function Auth(props: AuthProps$1): JSX.Element;
|
|
15
|
+
|
|
16
|
+
interface BadgeProps {
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
variant?: StyleVariant | null;
|
|
19
|
+
}
|
|
20
|
+
declare function Badge({ children, variant }: Readonly<BadgeProps>): React.ReactElement;
|
|
21
|
+
|
|
22
|
+
interface DashboardProps {
|
|
23
|
+
children?: React.ReactNode;
|
|
24
|
+
title: string;
|
|
25
|
+
}
|
|
26
|
+
declare function Dashboard({ children, title }: Readonly<DashboardProps>): React.ReactElement;
|
|
27
|
+
|
|
28
|
+
type FilterType = 'boolean' | 'date' | 'dropdown';
|
|
29
|
+
interface FilterObject {
|
|
30
|
+
data?: SimpleObject[];
|
|
31
|
+
label: string;
|
|
32
|
+
name: string;
|
|
33
|
+
type: FilterType;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface FilterBarProps {
|
|
37
|
+
hasSearch?: boolean;
|
|
38
|
+
map?: FilterObject[];
|
|
39
|
+
}
|
|
40
|
+
declare function FilterBar({ hasSearch, map }: Readonly<FilterBarProps>): React.ReactElement;
|
|
41
|
+
|
|
42
|
+
interface ListObject {
|
|
43
|
+
actions?: ({ id }: {
|
|
44
|
+
id: number | string;
|
|
45
|
+
}) => React.ReactElement;
|
|
46
|
+
description?: React.ReactNode | null;
|
|
47
|
+
href?: string;
|
|
48
|
+
id: number | string;
|
|
49
|
+
image?: string | null;
|
|
50
|
+
imageHref?: string | null;
|
|
51
|
+
meta?: React.ReactNode[] | Record<string, React.ReactNode>;
|
|
52
|
+
permission?: string;
|
|
53
|
+
subtitle?: React.ReactNode | null;
|
|
54
|
+
title?: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface ListComponentProps {
|
|
58
|
+
params?: Record<string, string>;
|
|
59
|
+
searchParams?: Record<string, string>;
|
|
60
|
+
}
|
|
61
|
+
interface ListProps<Item, Params> {
|
|
62
|
+
actions?: ({ id }: {
|
|
63
|
+
readonly id: number;
|
|
64
|
+
}) => React.ReactElement;
|
|
65
|
+
columns?: number;
|
|
66
|
+
emptyMessageProps?: EmptyMessageProps;
|
|
67
|
+
filters?: FilterObject[];
|
|
68
|
+
fn: (params?: Params, searchParams?: URLSearchParams) => Promise<Errorable<Item[]>>;
|
|
69
|
+
hasSearch?: boolean;
|
|
70
|
+
isMinimal?: boolean;
|
|
71
|
+
renderItem?: (props: ListObject) => JSX.Element;
|
|
72
|
+
params?: Params;
|
|
73
|
+
transformer?: (item: Item) => ListObject;
|
|
74
|
+
}
|
|
75
|
+
declare function List<Item extends object, Params>({ actions, columns, emptyMessageProps, filters, fn, hasSearch, isMinimal, params, renderItem, transformer, }: Readonly<ListProps<Item, Params>>): Promise<React.ReactElement>;
|
|
76
|
+
|
|
77
|
+
type GridListProps<Item, Params> = Omit<ListProps<Item, Params>, 'renderItem'>;
|
|
78
|
+
declare function GridList<Item extends object, Params>(props: GridListProps<Item, Params>): React.ReactElement;
|
|
79
|
+
|
|
80
|
+
interface InfoPanelProps {
|
|
81
|
+
children: React.ReactNode;
|
|
82
|
+
variant?: StyleVariant;
|
|
83
|
+
}
|
|
84
|
+
declare function InfoPanel({ children, variant }: Readonly<InfoPanelProps>): React.ReactElement;
|
|
85
|
+
|
|
86
|
+
interface ListActionsProps {
|
|
87
|
+
actions: ConfirmableAction<number>[];
|
|
88
|
+
id: number;
|
|
89
|
+
}
|
|
90
|
+
declare function ListActions({ actions, id }: Readonly<ListActionsProps>): React.ReactElement;
|
|
91
|
+
|
|
92
|
+
type FilterComponentProps = InputProps<string> & {
|
|
93
|
+
data?: SimpleObject[];
|
|
94
|
+
};
|
|
95
|
+
interface NavigationAction extends LinkableAction {
|
|
96
|
+
permission?: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
interface PageProps {
|
|
100
|
+
actions?: LinkableAction[];
|
|
101
|
+
basePath?: string;
|
|
102
|
+
children: React.ReactNode;
|
|
103
|
+
isFullWidth?: boolean;
|
|
104
|
+
tabs?: (NavigationAction | null)[];
|
|
105
|
+
title: string;
|
|
106
|
+
}
|
|
107
|
+
declare function Page({ basePath, children, isFullWidth, tabs, title, }: Readonly<PageProps>): Promise<React.ReactElement>;
|
|
108
|
+
|
|
109
|
+
interface PanelProps {
|
|
110
|
+
action?: LinkableAction;
|
|
111
|
+
children: React.ReactNode;
|
|
112
|
+
title?: string;
|
|
113
|
+
}
|
|
114
|
+
declare function Panel({ action, children, title }: Readonly<PanelProps>): React.ReactElement;
|
|
115
|
+
|
|
116
|
+
interface PageActionsProps {
|
|
117
|
+
children: React.ReactNode;
|
|
118
|
+
}
|
|
119
|
+
declare function PageActions({ children }: Readonly<PageActionsProps>): React.ReactElement | null;
|
|
120
|
+
|
|
121
|
+
interface ConfigNavigationObject {
|
|
122
|
+
href: string;
|
|
123
|
+
label: string;
|
|
124
|
+
permission?: string;
|
|
125
|
+
}
|
|
126
|
+
interface Config {
|
|
127
|
+
app: {
|
|
128
|
+
name: string;
|
|
129
|
+
url: string;
|
|
130
|
+
};
|
|
131
|
+
logo?: () => React.ReactElement;
|
|
132
|
+
navigation: ConfigNavigationObject[];
|
|
133
|
+
}
|
|
134
|
+
declare function setConfig(cfg: Config, logo?: () => React.ReactElement): Config;
|
|
135
|
+
declare function getConfig(): Config;
|
|
136
|
+
|
|
137
|
+
interface RootLayoutProps {
|
|
138
|
+
children: React.ReactNode;
|
|
139
|
+
config?: Config;
|
|
140
|
+
logo?: () => React.ReactElement;
|
|
141
|
+
}
|
|
142
|
+
declare function RootLayout({ children, config, logo }: Readonly<RootLayoutProps>): React.ReactElement;
|
|
143
|
+
|
|
144
|
+
interface SettingsPageProps {
|
|
145
|
+
children: React.ReactNode;
|
|
146
|
+
}
|
|
147
|
+
declare function SettingsPage({ children, }: Readonly<SettingsPageProps>): Promise<React.ReactElement>;
|
|
148
|
+
|
|
149
|
+
interface TableItemObject {
|
|
150
|
+
[key: string]: string;
|
|
151
|
+
id: string;
|
|
152
|
+
}
|
|
153
|
+
interface TableColumnObject {
|
|
154
|
+
key: string;
|
|
155
|
+
title?: string;
|
|
156
|
+
type?: 'number' | 'string';
|
|
157
|
+
}
|
|
158
|
+
interface TableClientComponentProps {
|
|
159
|
+
columns: string[] | TableColumnObject[];
|
|
160
|
+
data: TableItemObject[];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
interface TableProps<T> extends Omit<TableClientComponentProps, 'data'> {
|
|
164
|
+
fn: (filters?: Record<string, string>) => Promise<Errorable<T[]>>;
|
|
165
|
+
searchParams?: Record<string, string>;
|
|
166
|
+
}
|
|
167
|
+
declare function Table<T>({ columns, fn, searchParams, }: Readonly<TableProps<T>>): Promise<React.ReactElement>;
|
|
168
|
+
|
|
169
|
+
export { AppLayout, type AppLayoutProps, Auth, type AuthProps, Badge, type BadgeProps, type Config, Dashboard, type DashboardProps, FilterBar, type FilterBarProps, type FilterComponentProps, type FilterObject, GridList, type GridListProps, InfoPanel, type InfoPanelProps, List, ListActions, type ListActionsProps, type ListComponentProps, type ListObject, type ListProps, type NavigationAction, Page, PageActions, type PageActionsProps, type PageProps, Panel, type PanelProps, RootLayout, type RootLayoutProps, SettingsPage, Table, type TableColumnObject, type TableProps, getConfig, setConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,169 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
1
|
+
import { AuthProps as AuthProps$1, EmptyMessageProps } from '@sqrzro/components';
|
|
2
|
+
export { Autocomplete, AutocompleteFormField, Button, CalendarInput, CheckboxInput, ConfirmableButton, ConnectedDropdown, ContentFormField, DateFormField, DateInput, DefinitionList, Dropdown, DropdownFormField, DropdownItem, EditableDateFormField, EditableDropdownFormField, EditableForm, EditableFormField, EditableMultiFormField, EditableNumberFormField, EditableSwitchFormField, EditableTextAreaFormField, EditableTextFormField, EmptyMessage, Fieldset, Form, FormField, FormSubmit, ImageFormField, ImageInput, Link, LoadingModal, ModalForm, MultiFormField, NumberFormField, NumberInput, RadioInput, Switch, SwitchFormField, TextArea, TextAreaFormField, TextFormField, TextInput, Toaster } from '@sqrzro/components';
|
|
3
|
+
import { StyleVariant, SimpleObject, Errorable, ConfirmableAction, InputProps, LinkableAction } from '@sqrzro/interfaces';
|
|
4
|
+
|
|
5
|
+
interface AppLayoutProps {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
user?: {
|
|
8
|
+
name: string;
|
|
9
|
+
} | null;
|
|
10
|
+
}
|
|
11
|
+
declare function AppLayout({ children, user }: Readonly<AppLayoutProps>): Promise<JSX.Element>;
|
|
12
|
+
|
|
13
|
+
type AuthProps = AuthProps$1;
|
|
14
|
+
declare function Auth(props: AuthProps$1): JSX.Element;
|
|
15
|
+
|
|
16
|
+
interface BadgeProps {
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
variant?: StyleVariant | null;
|
|
19
|
+
}
|
|
20
|
+
declare function Badge({ children, variant }: Readonly<BadgeProps>): React.ReactElement;
|
|
21
|
+
|
|
22
|
+
interface DashboardProps {
|
|
23
|
+
children?: React.ReactNode;
|
|
24
|
+
title: string;
|
|
25
|
+
}
|
|
26
|
+
declare function Dashboard({ children, title }: Readonly<DashboardProps>): React.ReactElement;
|
|
27
|
+
|
|
28
|
+
type FilterType = 'boolean' | 'date' | 'dropdown';
|
|
29
|
+
interface FilterObject {
|
|
30
|
+
data?: SimpleObject[];
|
|
31
|
+
label: string;
|
|
32
|
+
name: string;
|
|
33
|
+
type: FilterType;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface FilterBarProps {
|
|
37
|
+
hasSearch?: boolean;
|
|
38
|
+
map?: FilterObject[];
|
|
39
|
+
}
|
|
40
|
+
declare function FilterBar({ hasSearch, map }: Readonly<FilterBarProps>): React.ReactElement;
|
|
41
|
+
|
|
42
|
+
interface ListObject {
|
|
43
|
+
actions?: ({ id }: {
|
|
44
|
+
id: number | string;
|
|
45
|
+
}) => React.ReactElement;
|
|
46
|
+
description?: React.ReactNode | null;
|
|
47
|
+
href?: string;
|
|
48
|
+
id: number | string;
|
|
49
|
+
image?: string | null;
|
|
50
|
+
imageHref?: string | null;
|
|
51
|
+
meta?: React.ReactNode[] | Record<string, React.ReactNode>;
|
|
52
|
+
permission?: string;
|
|
53
|
+
subtitle?: React.ReactNode | null;
|
|
54
|
+
title?: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface ListComponentProps {
|
|
58
|
+
params?: Record<string, string>;
|
|
59
|
+
searchParams?: Record<string, string>;
|
|
60
|
+
}
|
|
61
|
+
interface ListProps<Item, Params> {
|
|
62
|
+
actions?: ({ id }: {
|
|
63
|
+
readonly id: number;
|
|
64
|
+
}) => React.ReactElement;
|
|
65
|
+
columns?: number;
|
|
66
|
+
emptyMessageProps?: EmptyMessageProps;
|
|
67
|
+
filters?: FilterObject[];
|
|
68
|
+
fn: (params?: Params, searchParams?: URLSearchParams) => Promise<Errorable<Item[]>>;
|
|
69
|
+
hasSearch?: boolean;
|
|
70
|
+
isMinimal?: boolean;
|
|
71
|
+
renderItem?: (props: ListObject) => JSX.Element;
|
|
72
|
+
params?: Params;
|
|
73
|
+
transformer?: (item: Item) => ListObject;
|
|
74
|
+
}
|
|
75
|
+
declare function List<Item extends object, Params>({ actions, columns, emptyMessageProps, filters, fn, hasSearch, isMinimal, params, renderItem, transformer, }: Readonly<ListProps<Item, Params>>): Promise<React.ReactElement>;
|
|
76
|
+
|
|
77
|
+
type GridListProps<Item, Params> = Omit<ListProps<Item, Params>, 'renderItem'>;
|
|
78
|
+
declare function GridList<Item extends object, Params>(props: GridListProps<Item, Params>): React.ReactElement;
|
|
79
|
+
|
|
80
|
+
interface InfoPanelProps {
|
|
81
|
+
children: React.ReactNode;
|
|
82
|
+
variant?: StyleVariant;
|
|
83
|
+
}
|
|
84
|
+
declare function InfoPanel({ children, variant }: Readonly<InfoPanelProps>): React.ReactElement;
|
|
85
|
+
|
|
86
|
+
interface ListActionsProps {
|
|
87
|
+
actions: ConfirmableAction<number>[];
|
|
88
|
+
id: number;
|
|
89
|
+
}
|
|
90
|
+
declare function ListActions({ actions, id }: Readonly<ListActionsProps>): React.ReactElement;
|
|
91
|
+
|
|
92
|
+
type FilterComponentProps = InputProps<string> & {
|
|
93
|
+
data?: SimpleObject[];
|
|
94
|
+
};
|
|
95
|
+
interface NavigationAction extends LinkableAction {
|
|
96
|
+
permission?: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
interface PageProps {
|
|
100
|
+
actions?: LinkableAction[];
|
|
101
|
+
basePath?: string;
|
|
102
|
+
children: React.ReactNode;
|
|
103
|
+
isFullWidth?: boolean;
|
|
104
|
+
tabs?: (NavigationAction | null)[];
|
|
105
|
+
title: string;
|
|
106
|
+
}
|
|
107
|
+
declare function Page({ basePath, children, isFullWidth, tabs, title, }: Readonly<PageProps>): Promise<React.ReactElement>;
|
|
108
|
+
|
|
109
|
+
interface PanelProps {
|
|
110
|
+
action?: LinkableAction;
|
|
111
|
+
children: React.ReactNode;
|
|
112
|
+
title?: string;
|
|
113
|
+
}
|
|
114
|
+
declare function Panel({ action, children, title }: Readonly<PanelProps>): React.ReactElement;
|
|
115
|
+
|
|
116
|
+
interface PageActionsProps {
|
|
117
|
+
children: React.ReactNode;
|
|
118
|
+
}
|
|
119
|
+
declare function PageActions({ children }: Readonly<PageActionsProps>): React.ReactElement | null;
|
|
120
|
+
|
|
121
|
+
interface ConfigNavigationObject {
|
|
122
|
+
href: string;
|
|
123
|
+
label: string;
|
|
124
|
+
permission?: string;
|
|
125
|
+
}
|
|
126
|
+
interface Config {
|
|
127
|
+
app: {
|
|
128
|
+
name: string;
|
|
129
|
+
url: string;
|
|
130
|
+
};
|
|
131
|
+
logo?: () => React.ReactElement;
|
|
132
|
+
navigation: ConfigNavigationObject[];
|
|
133
|
+
}
|
|
134
|
+
declare function setConfig(cfg: Config, logo?: () => React.ReactElement): Config;
|
|
135
|
+
declare function getConfig(): Config;
|
|
136
|
+
|
|
137
|
+
interface RootLayoutProps {
|
|
138
|
+
children: React.ReactNode;
|
|
139
|
+
config?: Config;
|
|
140
|
+
logo?: () => React.ReactElement;
|
|
141
|
+
}
|
|
142
|
+
declare function RootLayout({ children, config, logo }: Readonly<RootLayoutProps>): React.ReactElement;
|
|
143
|
+
|
|
144
|
+
interface SettingsPageProps {
|
|
145
|
+
children: React.ReactNode;
|
|
146
|
+
}
|
|
147
|
+
declare function SettingsPage({ children, }: Readonly<SettingsPageProps>): Promise<React.ReactElement>;
|
|
148
|
+
|
|
149
|
+
interface TableItemObject {
|
|
150
|
+
[key: string]: string;
|
|
151
|
+
id: string;
|
|
152
|
+
}
|
|
153
|
+
interface TableColumnObject {
|
|
154
|
+
key: string;
|
|
155
|
+
title?: string;
|
|
156
|
+
type?: 'number' | 'string';
|
|
157
|
+
}
|
|
158
|
+
interface TableClientComponentProps {
|
|
159
|
+
columns: string[] | TableColumnObject[];
|
|
160
|
+
data: TableItemObject[];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
interface TableProps<T> extends Omit<TableClientComponentProps, 'data'> {
|
|
164
|
+
fn: (filters?: Record<string, string>) => Promise<Errorable<T[]>>;
|
|
165
|
+
searchParams?: Record<string, string>;
|
|
166
|
+
}
|
|
167
|
+
declare function Table<T>({ columns, fn, searchParams, }: Readonly<TableProps<T>>): Promise<React.ReactElement>;
|
|
168
|
+
|
|
169
|
+
export { AppLayout, type AppLayoutProps, Auth, type AuthProps, Badge, type BadgeProps, type Config, Dashboard, type DashboardProps, FilterBar, type FilterBarProps, type FilterComponentProps, type FilterObject, GridList, type GridListProps, InfoPanel, type InfoPanelProps, List, ListActions, type ListActionsProps, type ListComponentProps, type ListObject, type ListProps, type NavigationAction, Page, PageActions, type PageActionsProps, type PageProps, Panel, type PanelProps, RootLayout, type RootLayoutProps, SettingsPage, Table, type TableColumnObject, type TableProps, getConfig, setConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
1
|
+
import { twx, tw, Container, Link, Auth, TextInput, EmptyMessage, Button, ClassNames, Toaster, ConfirmableButton, EditableForm, EditableRadioFormField, EditableSwitchFormField, LogoutButton, Dropdown, CalendarInput } from '@sqrzro/components';
|
|
2
|
+
export { Autocomplete, AutocompleteFormField, Button, CalendarInput, CheckboxInput, ConfirmableButton, ConnectedDropdown, ContentFormField, DateFormField, DateInput, DefinitionList, Dropdown, DropdownFormField, EditableDateFormField, EditableDropdownFormField, EditableForm, EditableFormField, EditableMultiFormField, EditableNumberFormField, EditableSwitchFormField, EditableTextAreaFormField, EditableTextFormField, EmptyMessage, Fieldset, Form, FormField, FormSubmit, ImageFormField, ImageInput, Link, LoadingModal, ModalForm, MultiFormField, NumberFormField, NumberInput, RadioInput, Switch, SwitchFormField, TextArea, TextAreaFormField, TextFormField, TextInput, Toaster } from '@sqrzro/components';
|
|
3
|
+
import { cookies } from 'next/headers';
|
|
4
|
+
import { useState, Fragment, useRef, useEffect } from 'react';
|
|
5
|
+
import { filterNull, joinUrl } from '@sqrzro/utility';
|
|
6
|
+
import { useRouter, usePathname, useSearchParams } from 'next/navigation';
|
|
7
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
8
|
+
import { useFilters, useClickOutside, useEditableForm } from '@sqrzro/hooks';
|
|
9
|
+
import { createPortal } from 'react-dom';
|
|
10
|
+
import { Inter } from 'next/font/google';
|
|
11
|
+
|
|
12
|
+
var D={app:{name:"Square Zero",url:"http://localhost:8080"},navigation:[]};function L(e,t){return D={...e,logo:t},D}function E(){return D}async function x(){return Promise.resolve(cookies().get("layout")?.value||"topbar")}async function te(e){return cookies().set("layout",e.layout),Promise.resolve([!0,null])}async function h(e){if(process.env.APP_ENV!=="production"&&process.env.DANGEROUSLY_DISABLE_PERMISSIONS)return Promise.resolve(e);let t=cookies().get("permissions")?.value;if(!t)return Promise.resolve([]);let r=[];try{r=JSON.parse(t);}catch{return Promise.resolve([])}return Promise.resolve(e.filter(({permission:o})=>o?(Array.isArray(o)?o:[o]).every(a=>r.includes(a)):!0))}function Ye(e,t){return t.filter(r=>r&&e.startsWith(`/${r.replace(/^\//u,"")}`)).sort((r,o)=>!r||!o?0:o.length-r.length)[0]||""}function Je(e,t){let[r,o]=useState(""),n=usePathname(),a=e.map(({href:i})=>joinUrl(t?.basePath,i));return useEffect(()=>{o(Ye(n,a));},[n]),e.map(({href:i,label:s})=>({href:joinUrl(t?.basePath,i),isActive:joinUrl(t?.basePath,i)===r,label:s}))}var k=Je;function Ke({data:e,layout:t}){let r=k(e);return jsx("nav",{className:tw("h-full",t==="sidebar"?"w-full":"pl-6"),children:jsx("ul",{className:tw("flex h-full gap-2",t==="sidebar"?"flex-col items-start":"items-center"),children:r.map(({href:o,isActive:n,label:a})=>jsx("li",{className:tw(t==="sidebar"?null:"h-full"),children:jsx(Link,{className:tw("relative flex h-full items-center px-1 font-semibold",n?"before:bg-primary text-white before:absolute before:bottom-0 before:left-0 before:right-0 before:h-1":"text-white/80 hover:text-white"),href:o,children:a})},o))})})}var re=Ke;async function Ze({layout:e}){return jsx(re,{data:await h(E().navigation),layout:e})}var oe=Ze;function rt(){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,{})})]})}var ae=rt;function nt({layout:e,user:t}){return jsxs("div",{className:tw("ml-auto flex items-center gap-3",e==="sidebar"?"flex-row-reverse":null),children:[jsxs("div",{className:"flex flex-col items-end gap-0.5 text-white",children:[jsx("strong",{children:t?.name}),jsx(ae,{})]}),jsx("div",{className:"h-9 w-9 flex-none rounded-full border-4 border-slate-500"})]})}var ie=nt;async function st({children:e,user:t}){let r=E(),o=await x();return jsxs("div",{className:tw("",o==="sidebar"?"grid grid-cols-[12rem_1fr]":null),children:[jsx("header",{className:"bg-slate-800",children:jsx(Container,{isFullWidth:!0,children:jsxs("div",{className:tw("flex items-center",o==="sidebar"?"-mx-4 h-screen flex-col py-4":"h-16 border-b border-slate-700"),children:[jsxs(Link,{className:tw(o==="sidebar"?"h-12 w-12":"h-9 w-9"),href:"/",children:[r.logo?.(),jsx("span",{className:"sr-only",children:r.app.name})]}),jsx(oe,{layout:o}),jsx(ie,{layout:o,user:t})]})})}),jsx("main",{className:"mb-10 block",children:e})]})}var mt=st;var pt={root:"bg-slate-800 gap-8",logo:"mx-auto flex h-12 w-32 items-end",panel:"rounded bg-white p-8 shadow-lg pb-10",title:"text-lg font-semibold mb-6 leading-none",link:"font-semibold text-link",actions:"pt-2 w-full",footer:"-mb-2"};function ct(e){return jsx(Auth,{...e,classNames:pt})}var ft=ct;var bt={danger:"bg-red-100 text-red-700",error:"bg-red-100 text-red-700",info:"bg-sky-100 text-sky-700",warning:"bg-yellow-100 text-yellow-700",success:"bg-green-100 text-green-700"},gt={danger:"fill-red-400",error:"fill-red-400",info:"fill-sky-400",warning:"fill-yellow-400",success:"fill-green-400"};function xt({children:e,variant:t}){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",t?bt[t]:null),children:[jsx("svg",{"aria-hidden":"true",className:tw("h-1.5 w-1.5 fill-slate-400",t?gt[t]:null),viewBox:"0 0 6 6",children:jsx("circle",{cx:"3",cy:"3",r:"3"})}),e]})}var ht=xt;function Pt({children:e,title:t}){return jsxs("div",{className:"py-8",children:[jsx("h1",{className:"mx-auto text-center text-4xl font-semibold",children:t}),e]})}var vt=Pt;function Ft({onClick:e}){return jsxs("button",{className:"absolute right-0 top-0 flex h-full w-10 select-none items-center justify-center",onClick:e,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:"\xD7"})]})}var T=Ft;var de=[{id:"0",name:"No"},{id:"1",name:"Yes"}];function Lt({name:e,onChange:t,value:r}){return jsx(Dropdown,{data:de,name:e,onChange:t,value:r,isPanelOnly:!0})}function pe(e){return de.find(t=>t.id===e)?.name||""}var ce=Lt;function St({name:e,onChange:t,value:r}){return jsx(CalendarInput,{name:e,onChange:t,value:r,isPanelOnly:!0,isRange:!0})}function ue(e){return e||""}var At=4;function fe(e,t){let r=new Date(e);if(Number.isNaN(r.getTime()))return "";let o=r.getDate().toString().padStart(2,"0"),n=(r.getMonth()+1).toString().padStart(2,"0"),a=r.getFullYear();return `${o}/${n}${t?"":`/${a}`}`}function be(e){if(e.includes(",")){let r=e.split(",").map(o=>parseInt(o.substring(0,At),10));return e.split(",").map(o=>fe(o,r[0]===r[1]&&r[0]===new Date().getFullYear())).join(" - ")}return fe(e)}var ge=St;function Ot({data:e,name:t,onChange:r,value:o}){return jsx(Dropdown,{data:e,name:t,onChange:r,value:o,isPanelOnly:!0})}function xe(e,t){return t?.find(r=>r.id===e)?.name||""}var he=Ot;var jt={boolean:{component:ce,renderValue:pe},date:{component:ge,renderValue:be,size:"w-96",transformValue:ue},dropdown:{component:he,renderValue:xe}},Mt="w-56";function _t({data:e,label:t,name:r,onChange:o,type:n,value:a}){let i=useRef(null);function s(v){o(r,v.target.value),i.current?.hidePopover();}function c(){o(r,"");}let{component:P,renderValue:p,size:l,transformValue:g}=jt[n];return jsxs("li",{className:tw("relative inline-flex h-8 items-center gap-2 rounded-full border px-5 text-xs text-white",a?"border-solid border-slate-400":"border-dashed border-slate-400",a?"bg-slate-700 pr-10":"text-slate-300"),children:[jsx("p",{className:"",children:t}),a?jsx("p",{className:"border-l border-l-slate-300 pl-2 font-semibold",children:p(a,e)}):null,jsx("button",{className:tw("absolute left-0 top-0 h-full select-none text-transparent",a?"right-10":"right-0"),id:`${r}-control`,popovertarget:`${r}-target`,type:"button",children:"Edit"}),a?jsx(T,{onClick:c}):null,jsx("div",{ref:i,anchor:`${r}-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",l||Mt),id:`${r}-target`,popover:"auto",children:jsx("div",{className:"py-1",role:"none",children:jsx(P,{data:e,name:r,onChange:s,value:g?g(a):a})})})]})}var ye=_t;function Ht({hasSearch:e,map:t}){let r=useRouter(),[o,n]=useFilters(),[a,i]=useState(o.get("search")||"");function s(l,g){n(l,g),r.refresh();}function c(l){i(l.target.value||"");}function P(){i(""),n("search","");}function p(l){l.key==="Enter"&&n("search",l.currentTarget.value);}return jsxs("ul",{className:"relative flex gap-2 before:absolute before:left-[calc(50%-50vw)] before:top-full before:h-24 before:w-screen before:bg-slate-800",children:[e?jsxs("li",{className:"relative",children:[jsx(TextInput,{classNames:{root:{default:tw("h-8 w-56 rounded-full border border-slate-400 px-3 text-xs text-white placeholder:text-slate-300",o.get("search")?"bg-slate-700":"bg-transparent focus:bg-slate-700")}},name:"search",onChange:c,onKeyDown:p,placeholder:"Search...",value:a}),o.get("search")?jsx(T,{onClick:P}):null]}):null,(t||[]).map(l=>jsx(ye,{onChange:s,value:o.get(l.name)||"",...l},l.name))]})}var U=Ht;function G(e){return e?Array.isArray(e)?jsx("ul",{className:"flex items-center gap-4 text-xs text-slate-600",children:e.map(t=>jsx("li",{children:t},String(t)))}):jsx("table",{className:"w-full text-xs",children:jsx("tbody",{children:Object.entries(e).map(([t,r])=>jsxs("tr",{className:"odd:bg-slate-100",children:[jsx("th",{className:"p-2 font-semibold",children:t}),jsx("td",{className:"p-2 text-right",children:r||"-"})]},t))})}):null}function Yt({actions:e,description:t,href:r,id:o,meta:n,title:a}){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:[a?jsx("h2",{className:"text-lg font-semibold",children:r?jsx(Link,{href:r,children:a}):a}):null,t?jsx("div",{children:t}):null,n||e?jsxs("div",{className:"mt-4 flex items-center justify-between border-t border-slate-200 pt-3",children:[n?G(n):null,e?jsx(e,{id:o}):null]}):null]})})}var ve=Yt;function Jt({href:e,image:t,imageHref:r,meta:o,subtitle:n,title:a}){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:t?jsxs(Fragment,{children:[jsx("img",{alt:"",className:"h-full w-full object-contain",src:t}),r?jsx(Link,{className:"absolute inset-0",href:r,scroll:!1,children:jsx("span",{className:"sr-only",children:"Edit Image"})}):null]}):r?jsxs(Link,{className:"absolute inset-0 flex flex-col items-center justify-center gap-3 font-semibold text-slate-500",href:r,scroll:!1,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:e?jsx(Link,{href:e,children:a}):a}),n?jsx("p",{className:"text-xs text-slate-500",children:n}):null,o?jsxs(Fragment,{children:[jsx("hr",{className:"my-4"}),jsx("div",{className:"flex items-center justify-between",children:o?G(o):null})]}):null,e?jsxs(Fragment,{children:[jsx("hr",{className:"my-4"}),jsx(Link,{href:e,scroll:!1,children:"Edit"})]}):null]})})}var Re=Jt;function Zt(){return {id:0,title:""}}var Qt=["action"];function er(e){return Array.from(e.entries()).some(([t,r])=>!Qt.includes(t)&&!!r)}async function tr({actions:e,columns:t,emptyMessageProps:r,filters:o,fn:n,hasSearch:a,isMinimal:i,params:s,renderItem:c=ve,transformer:P}){let p;try{let{headers:R}=await import('next/headers');p=new URLSearchParams(R().get("x-search-params")||"");}catch{p=new URLSearchParams;}let[l,g]=await n(s,p);if(!Array.isArray(l))throw new Error("Response is not an array. Did you forget to return an Errorable object in the function?");if(g)return jsx("div",{children:"Error"});let v=await h(l.map(P||Zt)),Q=er(p),Ue=Q?{children:"Try adjusting the filters above. If you think this is a mistake, please contact your site administrator.",title:"No results match the current filters"}:r;return jsxs(Fragment,{children:[(o||a)&&(v.length||Q)?jsx(U,{hasSearch:a,map:o}):null,v.length?jsx("ul",{className:tw("relative",t?"grid grid-cols-3 gap-6":"flex flex-col gap-4"),children:v.map(R=>jsx(Fragment,{children:c({actions:e,...R})},R.id))}):jsx(EmptyMessage,{...Ue,classNameProps:{isMinimal:i}})]})}var W=tr;function or(e){return jsx(W,{...e,columns:3,renderItem:Re})}var ar=or;var ir={danger:"bg-[url(/admin/images/danger.svg)]",info:"bg-[url(/admin/images/info.svg)]",success:"bg-[url(/admin/images/success.svg)]",warning:"bg-[url(/admin/images/warning.svg)]"},lr={danger:"bg-red-50 text-red-700",info:"bg-sky-50 text-sky-700",success:"bg-green-50 text-green-700",warning:"bg-yellow-50 text-yellow-700"};function sr({children:e,variant:t="info"}){return jsxs("aside",{className:tw("grid grid-cols-[1rem_auto] gap-4 rounded p-4",lr[t]),children:[jsx("i",{className:tw("aspect-square bg-contain bg-no-repeat",ir[t])}),jsx("div",{children:e})]})}var mr=sr;function cr({id:e,onClick:t,label:r,variant:o}){function n(){t(e);}return jsx(ConfirmableButton,{onClick:n,variant:o,isText:!0,children:r})}var Ce=cr;function br({actions:e,id:t}){let[r,o,n]=useClickOutside();function a(){o(!r);}return jsxs("div",{ref:n,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:a,type:"button",children:["\u2022\u2022\u2022",jsxs("span",{className:"sr-only",children:[r?"Close":"Open"," Actions"]})]}),r?jsx("ul",{className:"show relative flex origin-right gap-4 bg-white before:absolute before:-bottom-2 before:-top-2 before:left-[-999em] before:right-full before:bg-white/80",children:e.map(({label:i,onClick:s,variant:c})=>jsx("li",{children:jsx(Ce,{id:t,label:i,onClick:s,variant:c})},i))}):null]})}var gr=br;function yr({basePath:e="",data:t}){let r=k(t,{basePath:e});return jsx("nav",{children:jsx("ul",{className:"flex gap-4",children:r.map(({href:o,isActive:n,label:a})=>jsx("li",{children:jsx(Link,{className:tw("block border-b-4 border-transparent px-1 pb-2 font-semibold",n?"border-primary":"opacity-80 hover:opacity-100"),href:o,children:a})},o))})})}var Le=yr;async function vr({basePath:e,data:t}){return jsx(Le,{basePath:e,data:await h(filterNull(t))})}var Ee=vr;async function Nr({basePath:e,children:t,isFullWidth:r,tabs:o,title:n}){let a=await x();return jsxs(Fragment,{children:[jsx("header",{className:tw("",a==="sidebar"?"bg-slate-200":"bg-slate-800 pb-16 text-white"),children:jsxs(Container,{isFullWidth:a==="sidebar"||r,children:[jsxs("div",{className:"flex items-center justify-between py-10",children:[jsx("h1",{className:"min-h-10 text-3xl font-semibold",children:n}),jsx("div",{className:"flex gap-2",id:"page-actions"})]}),o?jsx("div",{className:tw("-mt-4",a==="sidebar"?"":"mb-8 border-b border-slate-700"),children:jsx(Ee,{basePath:e,data:filterNull(o)})}):null]})}),jsx(Container,{isFullWidth:a==="sidebar"||r,children:jsx("div",{className:tw("flex flex-col gap-8",a==="sidebar"?"mt-8":"-mt-16"),children:t})})]})}var Z=Nr;function Lr({action:e,children:t,title:r}){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:[r?jsxs("header",{children:[jsx("h3",{className:"mb-4 border-b border-slate-200 pb-3 text-lg font-semibold leading-none",children:r}),e?jsx(Button,{href:e.href,children:e.label}):null]}):null,t]})}var Er=Lr;function Tr({children:e}){let t=useRef(null),[r,o]=useState(!1);return useEffect(()=>{t.current=document.getElementById("page-actions"),o(!0);},[]),r&&t.current?createPortal(e,t.current):null}var Or=Tr;var Dr=twx({actionList:()=>({root:"flex gap-2"}),button:e=>({root:{danger:"border-red-500 bg-red-500 text-white",default:tw("text-md h-10 rounded border border-slate-300 bg-white px-5 text-slate-600",e?.isFullWidth?"w-full":null),primary:"bg-button-bg text-button-text border-none font-semibold"}}),calendar:()=>({root:"p-4 pb-3 text-sm text-slate-600",head:"pb-2 text-center text-xs text-slate-400",month:"w-full table-fixed",day:{default:"h-10 border border-slate-200",highlighted:"bg-slate-100",selected:"bg-slate-200"}}),calendarNavigation:()=>({root:"mb-6 flex items-center justify-between",title:"text-base font-semibold",control:"h-6 w-6 rounded-full border border-slate-300",previous:"-order-1"}),checkboxInput:e=>({root:tw("flex",e?.isInline?"gap-6":"flex-col gap-2"),icon:{default:"h-6 w-6 rounded border border-slate-300",checked:"bg-green-500"},label:"pl-2 font-semibold"}),codeInput:()=>({input:{default:"focus:border-primary h-10 rounded border border-slate-300 text-center",error:"border-red-500"}}),definitionList:()=>({root:"flex flex-col gap-4",row:"border-b border-slate-200 pb-4",term:"pb-1 text-slate-500"}),dropdown:()=>({list:"overflow-hidden rounded",item:{default:"block p-3 text-sm text-slate-700",selected:"bg-slate-100"},title:"block leading-none",meta:"mt-1 block text-xs leading-none text-slate-500",icon:"mr-2 h-5 w-5 bg-[url(/admin/images/chevron.svg)] bg-contain bg-center bg-no-repeat",clear:"mr-2 h-4 w-4 bg-[url(/admin/images/close.svg)] bg-contain bg-center bg-no-repeat"}),editableFieldset:()=>({root:"bg-panel grid grid-cols-[30%_1fr] gap-8 rounded p-8 shadow",title:"mb-8 text-lg font-semibold leading-none text-slate-700",description:"text-slate-600",actions:"flex justify-end gap-2 border-t border-slate-200 pt-4"}),editableFormField:()=>({root:"grid grid-cols-[25%_1fr] border-t border-slate-200 py-4",label:"flex items-center font-semibold leading-none",field:"flex min-h-10 items-center"}),emptyMessage:e=>({root:tw("relative mx-auto mt-4 w-full max-w-2xl p-16 text-center text-slate-500",e?.isMinimal?null:"rounded bg-white shadow before:pointer-events-none before:absolute before:inset-2 before:border-2 before:border-dashed"),title:"mb-2 text-pretty text-xl font-semibold leading-tight",description:"text-pretty",action:"mt-6 flex justify-center"}),fieldset:()=>({root:"rounded bg-white p-8 shadow",title:"mb-8 text-lg font-semibold leading-none text-slate-700"}),form:()=>({root:"flex flex-col gap-6"}),formField:e=>({root:{default:e?.isEditable?"grid grid-cols-[25%_1fr] border-t border-slate-200 py-4":""},label:tw("flex font-semibold leading-none",e?.isEditable?"items-center":"mb-2 justify-between"),details:"mb-2 text-xs font-normal leading-none text-slate-500",optional:"pl-2 text-xs font-normal leading-none text-slate-500",error:tw("mt-2 flex items-center gap-1.5 text-red-600 before:h-4 before:w-4 before:rounded-full before:bg-[url(/admin/images/danger.svg)] before:bg-contain",e?.isEditable?"col-start-2":"")}),imageInput:()=>({root:"h-64 rounded border border-slate-300 bg-slate-50 p-8",icon:"mx-auto mb-2 block h-12 w-12 rounded-full border-2 border-slate-300",title:"mb-1 font-semibold",description:"text-xs italic text-slate-700"}),inputPanel:()=>({root:"show my-1 origin-top rounded border border-slate-300 bg-white shadow-md"}),loadingModal:()=>({root:"open:backdrop:fade py-16 backdrop:bg-slate-700/50 backdrop:backdrop-blur-sm",panel:"text-center text-lg font-semibold text-white"}),modal:()=>({root:"open:backdrop:fade py-16 backdrop:bg-slate-700/50 backdrop:backdrop-blur-sm",panel:"show bg-panel row-start-2 mx-auto w-full max-w-lg rounded p-6 text-left shadow-xl",title:"mb-6 text-lg font-semibold",actions:"flex justify-end"}),multiInput:()=>({root:"flex flex-col gap-2 pt-2",row:"grid grid-cols-[1fr_auto] has-[>_button]:gap-2"}),objectInput:()=>({root:"flex flex-col gap-2"}),passwordInput:()=>({action:{default:"mr-2 h-6 w-6 overflow-hidden bg-[url(/admin/images/eye.svg)] bg-no-repeat indent-12",selected:"bg-bottom"}}),staticTextInput:()=>({root:{default:"text-md flex min-h-10 flex-col justify-center rounded border border-slate-300 bg-white p-3",error:"border-red-500"},label:"block leading-none",meta:"mt-1 block text-xs leading-none text-slate-500",placeholder:"block leading-none text-slate-500"}),switch:()=>({root:"flex gap-4",input:{default:"h-6 w-10 flex-none cursor-pointer rounded-full bg-slate-300 p-1 transition-colors",checked:"bg-green-500"},control:{default:"h-4 w-4 translate-x-0 transform rounded-full bg-white shadow-md transition-transform",checked:"translate-x-full"},label:"font-semibold",details:"block text-xs text-slate-500"}),textArea:()=>({root:{default:"text-md focus:border-primary rounded border border-slate-300 px-3 py-2",error:"border-red-500"}}),textButton:()=>({root:{danger:"text-red-600"}}),textInput:()=>({root:{default:"text-md focus:border-primary h-10 rounded border border-slate-300 px-3",error:"border-red-500"},prefix:{default:"peer-focus:border-primary relative -mr-1 rounded-l border border-slate-300 bg-white px-3 text-sm text-slate-600"}}),toast:()=>({root:{default:"rounded border px-4 py-2",success:"border-green-300 bg-green-100 text-green-700",error:"border-red-300 bg-red-100 text-red-700"}})}),Ie=Dr;function jr({data:e}){return e&&L(e),null}var Te=jr;var qr=Inter({subsets:["latin"],variable:"--font-inter"});function Ur({children:e,config:t,logo:r}){return t&&L(t,r),jsxs("html",{lang:"en",children:[jsx("head",{}),jsxs("body",{className:tw(qr.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:{__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))"}}),jsx(Te,{data:t}),jsx(ClassNames,{data:Ie}),e,jsx(Toaster,{})]})]})}var $r=Ur;var Be={sidebar:"Side bar",topbar:"Top bar"};function Jr({defaults:e}){let{fieldProps:t,formProps:r}=useEditableForm({defaults:e,onSubmit:te});return jsxs(EditableForm,{title:"Appearance",...r,children:[jsx(EditableRadioFormField,{...t("layout"),options:Be,renderValue:o=>o&&Be[o]||"-"}),jsx(EditableSwitchFormField,{...t("isDark"),label:"Dark mode"})]})}var je=Jr;async function Kr({children:e}){let t=await x();return jsx(Z,{title:"Settings",children:jsxs("div",{className:"flex flex-col gap-6",children:[jsx(je,{defaults:{layout:t}}),e]})})}var Zr=Kr;function oo(e,t,r){let o=new URLSearchParams({...Object.fromEntries(t),...r});return `${e}?${o.toString()}`}function ao(e,t){return t&&e==="asc"?"desc":"asc"}function no(e,t,r){let o=ao(t.get("dir"),t.get("sort")===r);return oo(e,t,{sort:r,dir:o})}function io(e,t){return e.get("sort")===t?{dir:e.get("dir")}:{dir:null}}function lo(e){return e.every(t=>typeof t=="string")}function so(e){return e.length===0?[]:lo(e)?e.map(t=>({key:t})):e}function mo({columns:e,data:t}){let r=usePathname(),o=useSearchParams(),n=so(e),a=n.some(i=>i.title);return jsx("div",{className:"bg-white shadow-sm",children:jsxs("table",{className:"w-full",children:[a?jsx("thead",{children:jsx("tr",{children:n.map(i=>jsx("th",{className:tw("p-4",i.type==="number"?"text-right":"text-left"),children:i.title?jsxs(Link,{href:no(r,o,i.key),children:[i.title," "]}):null},i.key))})}):null,jsx("tbody",{children:t.map(i=>jsx("tr",{className:"odd:bg-slate-100",children:n.map(s=>jsx("td",{className:tw("border-x border-transparent p-4",io(o,s.key).dir?"border-sky-300 bg-sky-300/10":"",s.type==="number"?"text-right":"text-left"),children:i[s.key]},s.key))},i.id))})]})})}var ze=mo;function po(e){return {id:e.id,...e}}async function co({columns:e,fn:t,searchParams:r}){let[o,n]=await t(r);if(n)return jsx("div",{children:"Error"});let a=o.map(po);return jsx(ze,{columns:e,data:a})}var fo=co;
|
|
13
|
+
|
|
14
|
+
export { mt as AppLayout, ft as Auth, ht as Badge, vt as Dashboard, U as FilterBar, ar as GridList, mr as InfoPanel, W as List, gr as ListActions, Z as Page, Or as PageActions, Er as Panel, $r as RootLayout, Zr as SettingsPage, fo as Table, E as getConfig, L as setConfig };
|
|
15
|
+
//# sourceMappingURL=out.js.map
|
|
16
|
+
//# sourceMappingURL=index.js.map
|