@sqrzro/admin 2.1.0-bz.20 → 2.1.0-bz.22
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/AppNavigationSub/index.d.ts +11 -0
- package/dist/components/AppNavigationSub/index.js +12 -0
- package/dist/components/List/index.js +1 -2
- package/dist/components/ListActions/index.d.ts +1 -1
- package/dist/components/ListActions/index.js +5 -1
- package/dist/components/ListItem/index.d.ts +1 -1
- package/dist/components/ListItem/index.js +2 -2
- package/dist/components/MenuItem/index.js +1 -1
- package/dist/components/Panel/index.d.ts +1 -1
- package/dist/components/Panel/index.js +11 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +1 -1
- package/dist/styles/config.js +3 -0
- package/dist/styles/tailwind.d.ts +1 -1
- package/dist/styles/tailwind.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface ConfigNavigationObject {
|
|
3
|
+
href: string;
|
|
4
|
+
label: string;
|
|
5
|
+
permission?: string;
|
|
6
|
+
}
|
|
7
|
+
interface AppNavigationSubProps {
|
|
8
|
+
data: ConfigNavigationObject[];
|
|
9
|
+
}
|
|
10
|
+
declare function AppNavigationSub({ data }: Readonly<AppNavigationSubProps>): React.ReactElement;
|
|
11
|
+
export default AppNavigationSub;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Fragment, useState } from 'react';
|
|
4
|
+
import { Link } from '@sqrzro/components';
|
|
5
|
+
function AppNavigationSub({ data }) {
|
|
6
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
7
|
+
function toggleIsOpen() {
|
|
8
|
+
setIsOpen((prev) => !prev);
|
|
9
|
+
}
|
|
10
|
+
return (_jsxs(Fragment, { children: [_jsx("button", { onClick: toggleIsOpen, type: "button", children: "Open" }), isOpen ? (_jsx("ul", { children: data.map(({ href, label }) => (_jsx("li", { children: _jsx(Link, { href: href, children: label }) }, href))) })) : null] }));
|
|
11
|
+
}
|
|
12
|
+
export default AppNavigationSub;
|
|
@@ -3,7 +3,6 @@ import { Fragment, Suspense } from 'react';
|
|
|
3
3
|
import { getLayout } from '../../services/SettingsService';
|
|
4
4
|
import FilterBar from '../FilterBar';
|
|
5
5
|
import ListComponent from '../ListComponent';
|
|
6
|
-
import ListSkeleton from '../ListSkeleton';
|
|
7
6
|
const reservedSearchParams = ['action'];
|
|
8
7
|
function checkHasFilters(searchParams) {
|
|
9
8
|
return Array.from(searchParams.entries()).some(([key, value]) => !reservedSearchParams.includes(key) && Boolean(value));
|
|
@@ -18,6 +17,6 @@ async function List({ filters, hasSearch, ...props }) {
|
|
|
18
17
|
catch (err) {
|
|
19
18
|
searchParams = new URLSearchParams();
|
|
20
19
|
}
|
|
21
|
-
return (_jsxs(Fragment, { children: [filters || hasSearch ? (_jsx(FilterBar, { hasSearch: hasSearch, layout: layout, map: filters })) : null, _jsx(Suspense, { fallback: _jsx(
|
|
20
|
+
return (_jsxs(Fragment, { children: [filters || hasSearch ? (_jsx(FilterBar, { hasSearch: hasSearch, layout: layout, map: filters })) : null, _jsx(Suspense, { fallback: _jsx("div", { children: "Loading..." }), children: _jsx(ListComponent, { ...props, searchParams: searchParams }) })] }));
|
|
22
21
|
}
|
|
23
22
|
export default List;
|
|
@@ -4,7 +4,7 @@ export interface ListAction extends Omit<ConfirmableAction & LinkableAction, 'on
|
|
|
4
4
|
onClick?: (id: string) => void;
|
|
5
5
|
}
|
|
6
6
|
export interface ListActionsProps {
|
|
7
|
-
actions: ListAction[];
|
|
7
|
+
actions?: ListAction[] | ((id: string) => ListAction[]);
|
|
8
8
|
id: string;
|
|
9
9
|
}
|
|
10
10
|
declare function ListActions({ actions, id }: Readonly<ListActionsProps>): React.ReactElement;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useClickOutside } from '@sqrzro/hooks';
|
|
4
4
|
import Menu from '../Menu';
|
|
5
|
+
function parseHref(href, id) {
|
|
6
|
+
return href.replace(':id', id);
|
|
7
|
+
}
|
|
5
8
|
function ListActions({ actions, id }) {
|
|
6
9
|
const [isOpen, setIsOpen, ref] = useClickOutside();
|
|
7
10
|
function handleClick(item) {
|
|
@@ -10,8 +13,9 @@ function ListActions({ actions, id }) {
|
|
|
10
13
|
function toggleIsOpen() {
|
|
11
14
|
setIsOpen(!isOpen);
|
|
12
15
|
}
|
|
13
|
-
const transformedActions = actions.map((item) => ({
|
|
16
|
+
const transformedActions = (typeof actions === 'function' ? actions(id) : actions).map((item) => ({
|
|
14
17
|
...item,
|
|
18
|
+
href: item.href ? parseHref(item.href, id) : undefined, // eslint-disable-line no-undefined
|
|
15
19
|
onClick: () => handleClick(item),
|
|
16
20
|
}));
|
|
17
21
|
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] }));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { ListAction } from '../ListActions';
|
|
3
3
|
export interface ListObject {
|
|
4
|
-
actions?: ListAction[];
|
|
4
|
+
actions?: ListAction[] | ((id: string) => ListAction[]);
|
|
5
5
|
description?: React.ReactNode | null;
|
|
6
6
|
href?: string;
|
|
7
7
|
id: string;
|
|
@@ -19,8 +19,8 @@ export function renderMeta(id, meta) {
|
|
|
19
19
|
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))) }) }));
|
|
20
20
|
}
|
|
21
21
|
function ListItem({ actions, description, href, id, isMinimal, meta, secondary, tertiary, title, }) {
|
|
22
|
-
return (_jsx("li", { children: _jsx("article", { className: tw('
|
|
22
|
+
return (_jsx("li", { children: _jsx("article", { className: tw('', isMinimal
|
|
23
23
|
? 'border-b border-slate-200 pb-4'
|
|
24
|
-
: 'bg-panel rounded p-4 shadow-[0px_0px_0px_1px_rgba(9,9,11,0.07),0px_2px_2px_0px_rgba(9,9,11,0.05)]'), "data-testid": `list-item-root--${id}`, children: _jsxs("div", { className: "grid grid-cols-[3fr_2fr_2fr_auto]", children: [_jsxs("div", { children: [title ? (_jsx("h2", { className: "text-base font-semibold", "data-testid": `list-item-title--${id}`, children: href ? _jsx(Link, { href: href, children: title }) : title })) : null, description, meta ? (_jsx("div", { className: tw(isMinimal ? 'mt-1' : 'mt-2 flex items-center justify-between'), children: meta ? renderMeta(id, meta) : null })) : null] }), tertiary ? (_jsx("div", { className: "flex h-full flex-col justify-center", children: tertiary })) : null, secondary ? (_jsxs("div", { className: "col-start-3 text-right", children: [secondary.title ? (_jsx("p", { className: "text-base font-semibold", children: secondary.title })) : null, secondary.description ? (_jsx("div", { className: "text-xs text-slate-500", children: secondary.description })) : null, secondary.meta ? (_jsx("ul", { className: "flex items-center justify-end gap-4 text-xs text-slate-500", children: filterNull(secondary.meta).map((item) => (_jsx("li", { children: item }, getKey(item)))) })) : null] })) : null, actions ? (_jsx("div", { className: "h-5 self-center pl-6", children: _jsx(ListActions, { actions: actions, id: id }) })) : null] }) }) }));
|
|
24
|
+
: 'bg-panel rounded p-4 shadow-[0px_0px_0px_1px_rgba(9,9,11,0.07),0px_2px_2px_0px_rgba(9,9,11,0.05)]'), "data-testid": `list-item-root--${id}`, children: _jsxs("div", { className: "grid grid-cols-[3fr_2fr_2fr_auto]", children: [_jsxs("div", { children: [title ? (_jsx("h2", { className: "text-base font-semibold", "data-testid": `list-item-title--${id}`, children: href ? _jsx(Link, { href: href, children: title }) : title })) : null, description, meta ? (_jsx("div", { className: tw(isMinimal ? 'mt-1' : 'mt-2 flex items-center justify-between'), children: meta ? renderMeta(id, meta) : null })) : null] }), tertiary ? (_jsx("div", { className: "flex h-full flex-col justify-center", children: tertiary })) : null, secondary ? (_jsxs("div", { className: "col-start-3 text-right", children: [secondary.title ? (_jsx("p", { className: "text-base font-semibold", children: secondary.title })) : null, secondary.description ? (_jsx("div", { className: "text-xs text-slate-500", children: secondary.description })) : null, secondary.meta ? (_jsx("ul", { className: "flex items-center justify-end gap-4 text-xs text-slate-500", children: filterNull(secondary.meta).map((item) => (_jsx("li", { children: item }, getKey(item)))) })) : null] })) : null, actions ? (_jsx("div", { className: "col-start-4 h-5 self-center pl-6", children: _jsx(ListActions, { actions: actions, id: id }) })) : null] }) }) }));
|
|
25
25
|
}
|
|
26
26
|
export default ListItem;
|
|
@@ -8,7 +8,7 @@ const classMap = {
|
|
|
8
8
|
success: 'text-green-700',
|
|
9
9
|
};
|
|
10
10
|
function MenuItem({ href, isConfirmable, label, onClick, variant, }) {
|
|
11
|
-
const classNames = tw('whitespace-nowrap p-2 px-3 text-sm text-slate-700', variant ? classMap[variant] : null);
|
|
11
|
+
const classNames = tw('block whitespace-nowrap p-2 px-3 text-sm text-slate-700', variant ? classMap[variant] : null);
|
|
12
12
|
if (!href) {
|
|
13
13
|
if (isConfirmable) {
|
|
14
14
|
return (_jsx(ConfirmableButton, { classNames: { root: { default: classNames } }, onClick: onClick, type: "button", children: label }));
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Button } from '@sqrzro/components';
|
|
3
|
+
import { isValidElement } from 'react';
|
|
4
|
+
function renderAction(action) {
|
|
5
|
+
if (typeof action === 'object' && 'href' in action && 'label' in action) {
|
|
6
|
+
return _jsx(Button, { href: action.href, children: action.label });
|
|
7
|
+
}
|
|
8
|
+
if (isValidElement(action)) {
|
|
9
|
+
return action;
|
|
10
|
+
}
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
3
13
|
function Panel({ action, children, title }) {
|
|
4
|
-
return (_jsxs("article", { className: "@container bg-panel relative 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: [title ? (_jsxs("header", { className: "mb-4 flex justify-between border-b border-slate-200", children: [_jsx("h3", { className: "
|
|
14
|
+
return (_jsxs("article", { className: "@container bg-panel relative 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: [title ? (_jsxs("header", { className: "-mt-6 mb-4 flex h-16 items-center justify-between border-b border-slate-200", children: [_jsx("h3", { className: "text-lg font-semibold leading-none", children: title }), action ? renderAction(action) : null] })) : null, children] }));
|
|
5
15
|
}
|
|
6
16
|
export default Panel;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Autocomplete, AutocompleteFormField, Button, CalendarInput, CheckboxInput, ConfirmableButton, ConfirmableForm, ContentFormField, DateFormField, DateInput, DefinitionList, Dropdown, DropdownFormField, EditableAutocompleteFormField, EditableDateFormField, EditableDropdownFormField, EditableForm, EditableFormField, EditableMultiFormField, EditableNumberFormField, EditableSwitchFormField, EditableTextAreaFormField, EditableTextFormField, EmptyMessage, Fieldset, Form, FormField, FormSubmit, ImageInput, ImageFormField, Link, LoadingModal, Modal, ModalActions, ModalForm, MoneyFormField, MoneyInput, MultiFormField, NumberFormField, NumberInput, ObjectFormField, RadioInput, Switch, SwitchFormField, TextArea, TextAreaFormField, 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, EditableMultiFormField, EditableNumberFormField, EditableSwitchFormField, EditableTextAreaFormField, EditableTextFormField, EmptyMessage, Fieldset, Form, FormField, FormSubmit, ImageInput, ImageFormField, Link, LoadingModal, Modal, ModalActions, ModalForm, MoneyFormField, MoneyInput, MultiFormField, NumberFormField, NumberInput, ObjectFormField, RadioInput, Switch, SwitchFormField, TextArea, TextAreaFormField, TextFormField, TextInput, Toaster, } from '@sqrzro/components';
|
|
2
2
|
export type { DropdownItem, EditableFormFieldProps, FormFieldProps, LinkProps, NumberInputProps, } 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, AutocompleteFormField, Button, CalendarInput, CheckboxInput, ConfirmableButton, ConfirmableForm, ContentFormField, DateFormField, DateInput, DefinitionList, Dropdown, DropdownFormField, EditableAutocompleteFormField, EditableDateFormField, EditableDropdownFormField, EditableForm, EditableFormField, EditableMultiFormField, EditableNumberFormField, EditableSwitchFormField, EditableTextAreaFormField, EditableTextFormField, EmptyMessage, Fieldset, Form, FormField, FormSubmit, ImageInput, ImageFormField, Link, LoadingModal, Modal, ModalActions, ModalForm, MoneyFormField, MoneyInput, MultiFormField, NumberFormField, NumberInput, ObjectFormField, RadioInput, Switch, SwitchFormField, TextArea, TextAreaFormField, 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, EditableMultiFormField, EditableNumberFormField, EditableSwitchFormField, EditableTextAreaFormField, EditableTextFormField, EmptyMessage, Fieldset, Form, FormField, FormSubmit, ImageInput, ImageFormField, Link, LoadingModal, 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';
|
package/dist/styles/config.js
CHANGED
|
@@ -172,6 +172,9 @@ const classNames = twx({
|
|
|
172
172
|
prefix: {
|
|
173
173
|
default: 'peer-focus:border-primary relative -mr-1 rounded-l border border-slate-300 bg-white px-3 text-sm text-slate-600',
|
|
174
174
|
},
|
|
175
|
+
suffix: {
|
|
176
|
+
default: 'peer-focus:border-primary relative -ml-1 rounded-r border border-slate-300 bg-white px-3 text-sm text-slate-600',
|
|
177
|
+
},
|
|
175
178
|
}),
|
|
176
179
|
toast: () => ({
|
|
177
180
|
root: {
|
|
@@ -6,5 +6,5 @@ interface Theme {
|
|
|
6
6
|
primary: string;
|
|
7
7
|
}>;
|
|
8
8
|
}
|
|
9
|
-
declare function config(resolves: string[], customization: Theme, plugins
|
|
9
|
+
declare function config(resolves: string[], customization: Theme, plugins?: unknown[]): Record<string, unknown>;
|
|
10
10
|
export default config;
|
package/dist/styles/tailwind.js
CHANGED