@sqrzro/admin 2.1.0-bz.16 → 2.1.0-bz.17
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/components/Badge/index.js +12 -3
- package/dist/components/FilterBar/index.js +10 -5
- package/dist/components/GridList/index.d.ts +2 -2
- package/dist/components/List/index.d.ts +4 -4
- package/dist/components/List/index.js +1 -1
- package/dist/components/ListItem/index.js +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +1 -1
- package/dist/styles/config.js +4 -1
- package/package.json +1 -1
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { tw } from '@sqrzro/components';
|
|
3
|
-
const
|
|
3
|
+
const classMap = {
|
|
4
|
+
danger: 'bg-red-100 text-red-700',
|
|
5
|
+
error: 'bg-red-100 text-red-700',
|
|
4
6
|
info: 'bg-sky-100 text-sky-700',
|
|
5
7
|
warning: 'bg-yellow-100 text-yellow-700',
|
|
6
|
-
success: 'bg-
|
|
8
|
+
success: 'bg-green-100 text-green-700',
|
|
9
|
+
};
|
|
10
|
+
const dotMap = {
|
|
11
|
+
danger: 'fill-red-500',
|
|
12
|
+
error: 'fill-red-500',
|
|
13
|
+
info: 'fill-sky-500',
|
|
14
|
+
warning: 'fill-yellow-500',
|
|
15
|
+
success: 'fill-green-500',
|
|
7
16
|
};
|
|
8
17
|
function Badge({ children, variant }) {
|
|
9
|
-
return (_jsxs("strong", { className: tw('inline-flex items-center gap-1.5 rounded-full
|
|
18
|
+
return (_jsxs("strong", { className: tw('inline-flex items-center gap-1.5 rounded-full px-2 py-1 text-xs font-medium', classMap[variant]), children: [_jsx("svg", { "aria-hidden": "true", className: tw('h-1.5 w-1.5', dotMap[variant]), viewBox: "0 0 6 6", children: _jsx("circle", { cx: "3", cy: "3", r: "3" }) }), children] }));
|
|
10
19
|
}
|
|
11
20
|
export default Badge;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
+
import { TextInput } from '@sqrzro/components';
|
|
4
5
|
import { useFilters } from '@sqrzro/hooks';
|
|
5
6
|
import { useRouter } from 'next/navigation';
|
|
6
7
|
import FilterBarItem from '../FilterBarItem';
|
|
@@ -12,10 +13,14 @@ function FilterBar({ hasSearch, map }) {
|
|
|
12
13
|
setFilter(name, value);
|
|
13
14
|
router.refresh();
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
function handleSearchChange(event) {
|
|
17
|
+
setSearch(event.target.value || '');
|
|
18
|
+
}
|
|
19
|
+
function handleSearchKeyDown(event) {
|
|
20
|
+
if (event.key === 'Enter') {
|
|
21
|
+
setFilter('search', event.currentTarget.value);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
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: [hasSearch ? (_jsx("li", { children: _jsx(TextInput, { name: "search", onChange: handleSearchChange, onKeyDown: handleSearchKeyDown, value: search }) })) : null, (map || []).map((filter) => (_jsx(FilterBarItem, { onChange: handleChange, value: filters.get(filter.name) || '', ...filter }, filter.name)))] }));
|
|
20
25
|
}
|
|
21
26
|
export default FilterBar;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { ListProps } from '../List';
|
|
3
|
-
export type GridListProps<Item> = Omit<ListProps<Item>, 'renderItem'>;
|
|
4
|
-
declare function GridList<Item extends object>(props: GridListProps<Item>): React.ReactElement;
|
|
3
|
+
export type GridListProps<Item, Params> = Omit<ListProps<Item, Params>, 'renderItem'>;
|
|
4
|
+
declare function GridList<Item extends object, Params>(props: GridListProps<Item, Params>): React.ReactElement;
|
|
5
5
|
export default GridList;
|
|
@@ -7,19 +7,19 @@ export interface ListComponentProps {
|
|
|
7
7
|
params?: Record<string, string>;
|
|
8
8
|
searchParams?: Record<string, string>;
|
|
9
9
|
}
|
|
10
|
-
export interface ListProps<Item> {
|
|
10
|
+
export interface ListProps<Item, Params> {
|
|
11
11
|
actions?: ({ id }: {
|
|
12
12
|
readonly id: number;
|
|
13
13
|
}) => React.ReactElement;
|
|
14
14
|
columns?: number;
|
|
15
15
|
emptyMessageProps?: EmptyMessageProps;
|
|
16
16
|
filters?: FilterObject[];
|
|
17
|
-
fn: (params
|
|
17
|
+
fn: (params?: Params, searchParams?: URLSearchParams) => Promise<Errorable<Item[]>>;
|
|
18
18
|
hasSearch?: boolean;
|
|
19
19
|
isMinimal?: boolean;
|
|
20
20
|
renderItem?: (props: ListObject) => React.ReactElement;
|
|
21
|
-
params?:
|
|
21
|
+
params?: Params;
|
|
22
22
|
transformer?: (item: Item) => ListObject;
|
|
23
23
|
}
|
|
24
|
-
declare function List<Item extends object>({ actions, columns, emptyMessageProps, filters, fn, hasSearch, isMinimal, params, renderItem, transformer, }: Readonly<ListProps<Item>>): Promise<React.ReactElement>;
|
|
24
|
+
declare function List<Item extends object, Params>({ actions, columns, emptyMessageProps, filters, fn, hasSearch, isMinimal, params, renderItem, transformer, }: Readonly<ListProps<Item, Params>>): Promise<React.ReactElement>;
|
|
25
25
|
export default List;
|
|
@@ -22,7 +22,7 @@ async function List({ actions, columns, emptyMessageProps, filters, fn, hasSearc
|
|
|
22
22
|
catch (err) {
|
|
23
23
|
searchParams = new URLSearchParams();
|
|
24
24
|
}
|
|
25
|
-
const [response, error] = await fn(params
|
|
25
|
+
const [response, error] = await fn(params, searchParams);
|
|
26
26
|
if (error) {
|
|
27
27
|
return _jsx("div", { children: "Error" });
|
|
28
28
|
}
|
|
@@ -5,7 +5,7 @@ export function renderMeta(meta) {
|
|
|
5
5
|
return null;
|
|
6
6
|
}
|
|
7
7
|
if (Array.isArray(meta)) {
|
|
8
|
-
return (_jsx("ul", { className: "flex items-center gap-4 text-xs text-slate-600", children: meta.map((item) => (_jsx("li", { children: item },
|
|
8
|
+
return (_jsx("ul", { className: "flex items-center gap-4 text-xs text-slate-600", children: meta.map((item, index) => (_jsx("li", { children: item }, index))) }));
|
|
9
9
|
}
|
|
10
10
|
return (_jsx("table", { className: "w-full text-xs", children: _jsx("tbody", { children: Object.entries(meta).map(([key, value]) => (_jsxs("tr", { className: "odd:bg-slate-100", children: [_jsx("th", { className: "p-2 font-semibold", children: key }), _jsx("td", { className: "p-2 text-right", children: value || '-' })] }, key))) }) }));
|
|
11
11
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Autocomplete, Button, CalendarInput, ConnectedDropdown, ConfirmableButton, DateFormField, DateInput, Dropdown, DropdownFormField, EditableDateFormField, EditableDropdownFormField, EditableForm, EditableFormField, EditableMultiFormField, EditableNumberFormField, EditableSwitchFormField, EditableTextAreaFormField, EditableTextFormField, EmptyMessage, Fieldset, Form, FormField, FormSubmit, ImageInput, ImageFormField, Link, ModalForm, MultiFormField, NumberFormField, NumberInput, RadioInput, Switch, SwitchFormField, TextArea, TextAreaFormField, TextFormField, TextInput, Toaster, } from '@sqrzro/components';
|
|
1
|
+
export { Autocomplete, AutocompleteFormField, Button, CalendarInput, ConnectedDropdown, ConfirmableButton, DateFormField, DateInput, Dropdown, DropdownFormField, EditableDateFormField, EditableDropdownFormField, EditableForm, EditableFormField, EditableMultiFormField, EditableNumberFormField, EditableSwitchFormField, EditableTextAreaFormField, EditableTextFormField, EmptyMessage, Fieldset, Form, FormField, FormSubmit, ImageInput, ImageFormField, Link, ModalForm, MultiFormField, NumberFormField, NumberInput, RadioInput, Switch, SwitchFormField, TextArea, TextAreaFormField, TextFormField, TextInput, Toaster, } from '@sqrzro/components';
|
|
2
2
|
export type { DropdownItem } from '@sqrzro/components';
|
|
3
3
|
export type { AppLayoutProps } from './AppLayout';
|
|
4
4
|
export { default as AppLayout } from './AppLayout';
|
package/dist/components/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Exported from @sqrzro/components
|
|
2
|
-
export { Autocomplete, Button, CalendarInput, ConnectedDropdown, ConfirmableButton, DateFormField, DateInput, Dropdown, DropdownFormField, EditableDateFormField, EditableDropdownFormField, EditableForm, EditableFormField, EditableMultiFormField, EditableNumberFormField, EditableSwitchFormField, EditableTextAreaFormField, EditableTextFormField, EmptyMessage, Fieldset, Form, FormField, FormSubmit, ImageInput, ImageFormField, Link, ModalForm, MultiFormField, NumberFormField, NumberInput, RadioInput, Switch, SwitchFormField, TextArea, TextAreaFormField, TextFormField, TextInput, Toaster, } from '@sqrzro/components';
|
|
2
|
+
export { Autocomplete, AutocompleteFormField, Button, CalendarInput, ConnectedDropdown, ConfirmableButton, DateFormField, DateInput, Dropdown, DropdownFormField, EditableDateFormField, EditableDropdownFormField, EditableForm, EditableFormField, EditableMultiFormField, EditableNumberFormField, EditableSwitchFormField, EditableTextAreaFormField, EditableTextFormField, EmptyMessage, Fieldset, Form, FormField, FormSubmit, ImageInput, ImageFormField, Link, ModalForm, MultiFormField, NumberFormField, NumberInput, RadioInput, Switch, SwitchFormField, TextArea, TextAreaFormField, TextFormField, TextInput, Toaster, } from '@sqrzro/components';
|
|
3
3
|
export { default as AppLayout } from './AppLayout';
|
|
4
4
|
export { default as Auth } from './Auth';
|
|
5
5
|
export { default as Badge } from './Badge';
|
package/dist/styles/config.js
CHANGED
|
@@ -73,7 +73,7 @@ const classNames = twx({
|
|
|
73
73
|
label: tw('flex font-semibold leading-none', props?.isEditable ? 'items-center' : 'mb-2 justify-between'),
|
|
74
74
|
details: 'mb-2 text-xs font-normal leading-none text-slate-500',
|
|
75
75
|
optional: 'pl-2 text-xs font-normal leading-none text-slate-500',
|
|
76
|
-
error: 'mt-2 flex items-center gap-2 text-red-700 before:h-4 before:w-4 before:rounded-full before:bg-[url(/admin/images/error.svg)]',
|
|
76
|
+
error: tw('mt-2 flex items-center gap-2 text-red-700 before:h-4 before:w-4 before:rounded-full before:bg-[url(/admin/images/error.svg)]', props?.isEditable ? 'col-start-2' : ''),
|
|
77
77
|
}),
|
|
78
78
|
imageInput: () => ({
|
|
79
79
|
root: 'h-64 rounded border border-slate-300 bg-slate-50 p-8',
|
|
@@ -94,6 +94,9 @@ const classNames = twx({
|
|
|
94
94
|
root: 'flex flex-col gap-2',
|
|
95
95
|
row: 'grid grid-cols-[1fr_auto] has-[>_button]:gap-2',
|
|
96
96
|
}),
|
|
97
|
+
objectInput: () => ({
|
|
98
|
+
root: 'flex flex-col gap-2',
|
|
99
|
+
}),
|
|
97
100
|
passwordInput: () => ({
|
|
98
101
|
action: {
|
|
99
102
|
default: 'mr-2 h-6 w-6 overflow-hidden bg-[url(/admin/images/eye.svg)] bg-no-repeat indent-12',
|