@sqrzro/ui 4.0.0-alpha.14 → 4.0.0-alpha.16
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/buttons/Button/index.d.ts +4 -4
- package/dist/components/buttons/Button/index.js +2 -1
- package/dist/components/collections/Collection/index.d.ts +5 -1
- package/dist/components/collections/Collection/index.js +4 -4
- package/dist/components/collections/DataTable/index.d.ts +1 -1
- package/dist/components/collections/DataTable/index.js +2 -1
- package/dist/components/collections/List/index.d.ts +2 -1
- package/dist/components/collections/ListClientComponent/index.d.ts +6 -2
- package/dist/components/collections/ListClientComponent/index.js +4 -2
- package/dist/components/collections/ListItem/index.js +1 -1
- package/dist/components/collections/ListItemMeta/index.d.ts +5 -3
- package/dist/components/collections/ListItemMeta/index.js +10 -4
- package/dist/components/collections/ListItemSecondary/index.js +1 -1
- package/dist/components/collections/interfaces.d.ts +5 -12
- package/dist/components/collections/utility/is-data-table-array.d.ts +3 -0
- package/dist/components/collections/utility/is-data-table-array.js +5 -0
- package/dist/components/collections/utility/is-data-table-object.d.ts +3 -0
- package/dist/components/collections/utility/is-data-table-object.js +4 -0
- package/dist/components/modals/ConfirmModal/index.js +1 -1
- package/dist/filters/index.d.ts +1 -0
- package/dist/filters/index.js +1 -0
- package/dist/forms/components/ModalForm/index.js +1 -1
- package/dist/styles/classnames/apply-variants.d.ts +3 -0
- package/dist/styles/classnames/apply-variants.js +25 -0
- package/dist/styles/classnames/config.d.ts +2 -0
- package/dist/styles/classnames/interfaces.d.ts +11 -2
- package/dist/styles/styles.css +59 -0
- package/dist/utility/interfaces.d.ts +1 -2
- package/package.json +9 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ClassNameProps
|
|
2
|
-
import {
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
2
|
+
import { StyleVariant } from '../../../utility/interfaces';
|
|
3
3
|
export interface ButtonClassNames {
|
|
4
|
-
root:
|
|
4
|
+
root: string;
|
|
5
5
|
icon: string;
|
|
6
6
|
}
|
|
7
7
|
export interface ButtonProps extends ClassNameProps<ButtonClassNames> {
|
|
@@ -40,7 +40,7 @@ export interface ButtonProps extends ClassNameProps<ButtonClassNames> {
|
|
|
40
40
|
/** Used in situations where a button value needs to be submitted with a form */
|
|
41
41
|
readonly value?: string;
|
|
42
42
|
/** A set of predefined variants that can be passed to the classNames config to customize the button's appearance */
|
|
43
|
-
readonly variant?:
|
|
43
|
+
readonly variant?: StyleVariant[] | StyleVariant;
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Either a `Link` component or a `button` element, depending on whether a `href` prop is specified.
|
|
@@ -4,6 +4,7 @@ import { useRef } from 'react';
|
|
|
4
4
|
import Link from '../../../components/utility/Link';
|
|
5
5
|
import Loader from '../../../components/utility/Loader';
|
|
6
6
|
import { getClassNames } from '../../../styles/classnames';
|
|
7
|
+
import applyVariants from '../../../styles/classnames/apply-variants';
|
|
7
8
|
import tw from '../../../styles/classnames/tw';
|
|
8
9
|
/**
|
|
9
10
|
* Either a `Link` component or a `button` element, depending on whether a `href` prop is specified.
|
|
@@ -26,7 +27,7 @@ import tw from '../../../styles/classnames/tw';
|
|
|
26
27
|
*/
|
|
27
28
|
function Button({ children, classNames, classNameProps, form, hasAssistiveLabel, href, icon, id, isDisabled, isFullWidth, isLoading, isNewWindow, isText, name, onClick, popoverTarget, scroll, style, type, value, variant, }) {
|
|
28
29
|
const ref = useRef(null);
|
|
29
|
-
const componentClassNames = getClassNames(isText ? 'textButton' : 'button', { props: { ...classNameProps } }, classNames);
|
|
30
|
+
const componentClassNames = getClassNames(isText ? 'textButton' : 'button', { props: { ...classNameProps, ...applyVariants(variant) } }, classNames);
|
|
30
31
|
const className = tw('flex cursor-pointer items-center justify-center whitespace-nowrap', isDisabled || isLoading ? 'pointer-events-none opacity-30' : null, isFullWidth ? 'w-full' : null, componentClassNames?.root);
|
|
31
32
|
/*
|
|
32
33
|
* Link uses classNames, whereas button uses className. This is because Link can also be used
|
|
@@ -4,14 +4,18 @@ import type { EmptyMessageProps } from '../EmptyMessage';
|
|
|
4
4
|
import type { ListFunctionConfig, Paginated } from '../interfaces';
|
|
5
5
|
export interface CollectionComponentProps<Item, Transformed, Filters = null> {
|
|
6
6
|
readonly data?: Item[] | Paginated<Item>;
|
|
7
|
+
readonly defaultFilters?: Partial<Filters>;
|
|
7
8
|
readonly emptyMessageProps?: EmptyMessageProps;
|
|
8
9
|
readonly filterMap?: FilterMap<Filters>;
|
|
9
10
|
readonly fn?: (config: ListFunctionConfig<Filters>) => Promise<Item[]> | Promise<Paginated<Item>>;
|
|
10
11
|
readonly pageProps?: NextPageProps;
|
|
12
|
+
readonly renderFilters?: (props: {
|
|
13
|
+
map: FilterMap<Filters>;
|
|
14
|
+
}) => React.ReactElement;
|
|
11
15
|
readonly transformer: (item: Item) => Transformed;
|
|
12
16
|
}
|
|
13
17
|
export interface CollectionProps<Item, Transformed, Filters = null> extends CollectionComponentProps<Item, Transformed, Filters> {
|
|
14
18
|
readonly render: (data: Transformed[]) => React.ReactElement;
|
|
15
19
|
}
|
|
16
|
-
declare function Collection<Item extends object, Transformed, Filters>({ filterMap, ...props }: CollectionProps<Item, Transformed, Filters>): React.ReactElement;
|
|
20
|
+
declare function Collection<Item extends object, Transformed, Filters>({ filterMap, renderFilters, ...props }: CollectionProps<Item, Transformed, Filters>): React.ReactElement;
|
|
17
21
|
export default Collection;
|
|
@@ -10,7 +10,7 @@ import EmptyMessage from '../EmptyMessage';
|
|
|
10
10
|
import Pagination from '../Pagination';
|
|
11
11
|
import isPaginated from '../utility/is-paginated';
|
|
12
12
|
import { messages } from '../lang';
|
|
13
|
-
async function CollectionComponent({ data, emptyMessageProps, filterMap, fn, pageProps, render, transformer, }) {
|
|
13
|
+
async function CollectionComponent({ data, defaultFilters, emptyMessageProps, filterMap, fn, pageProps, render, transformer, }) {
|
|
14
14
|
const EmptyIcon = getIcon('collection.empty');
|
|
15
15
|
const awaitedParams = pageProps?.params ? await pageProps.params : null;
|
|
16
16
|
const awaitedSearchParams = pageProps?.searchParams ? await pageProps.searchParams : null;
|
|
@@ -23,7 +23,7 @@ async function CollectionComponent({ data, emptyMessageProps, filterMap, fn, pag
|
|
|
23
23
|
}
|
|
24
24
|
const filters = parseFilters(awaitedSearchParams, filterMap);
|
|
25
25
|
const page = parsePage(awaitedSearchParams);
|
|
26
|
-
return fn({ filters, page, params: awaitedParams });
|
|
26
|
+
return fn({ filters: { ...defaultFilters, ...filters }, page, params: awaitedParams });
|
|
27
27
|
}
|
|
28
28
|
const response = await getResponse();
|
|
29
29
|
const dynamicData = (isPaginated(response) ? response.data : response).map(transformer);
|
|
@@ -39,7 +39,7 @@ async function CollectionComponent({ data, emptyMessageProps, filterMap, fn, pag
|
|
|
39
39
|
}
|
|
40
40
|
return (_jsxs(Fragment, { children: [render(dynamicData), isPaginated(response) ? (_jsx(Pagination, { ...response.meta, nextLabel: "Next \u2192", previousLabel: "\u2190 Previous" })) : null] }));
|
|
41
41
|
}
|
|
42
|
-
function Collection({ filterMap, ...props }) {
|
|
43
|
-
return (_jsxs(Fragment, { children: [filterMap ?
|
|
42
|
+
function Collection({ filterMap, renderFilters = FilterBar, ...props }) {
|
|
43
|
+
return (_jsxs(Fragment, { children: [filterMap ? renderFilters({ map: filterMap }) : null, _jsx(Suspense, { fallback: _jsx("div", { className: "flex justify-center p-16", children: _jsx(Loader, {}) }), children: _jsx(CollectionComponent, { ...props, filterMap: filterMap }) })] }));
|
|
44
44
|
}
|
|
45
45
|
export default Collection;
|
|
@@ -8,7 +8,7 @@ export interface DataTableClassNames {
|
|
|
8
8
|
value: string;
|
|
9
9
|
}
|
|
10
10
|
export interface DataTableProps extends ClassNameProps<DataTableClassNames> {
|
|
11
|
-
readonly data: DataTableObject[];
|
|
11
|
+
readonly data: (DataTableObject | null)[];
|
|
12
12
|
}
|
|
13
13
|
declare function DataTable({ classNameProps, classNames, data }: DataTableProps): React.ReactElement;
|
|
14
14
|
export default DataTable;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { filterNull } from '@sqrzro/utility';
|
|
2
3
|
import { getClassNames } from '../../../styles/classnames';
|
|
3
4
|
import tw from '../../../styles/classnames/tw';
|
|
4
5
|
function DataTable({ classNameProps, classNames, data }) {
|
|
5
6
|
const componentClassNames = getClassNames('dataTable', { props: classNameProps }, classNames);
|
|
6
|
-
return (_jsx("table", { className: tw('w-full', componentClassNames?.root), children: _jsx("tbody", { children: data.map(({ label, value }, index) => (_jsxs("tr", { className: componentClassNames?.row, children: [_jsx("th", { className: tw(componentClassNames?.cell, componentClassNames?.label), children: label }), _jsx("td", { className: tw(componentClassNames?.cell, componentClassNames?.value), children: value })] }, index))) }) }));
|
|
7
|
+
return (_jsx("table", { className: tw('w-full', componentClassNames?.root), children: _jsx("tbody", { children: filterNull(data).map(({ label, value }, index) => (_jsxs("tr", { className: componentClassNames?.row, children: [_jsx("th", { className: tw(componentClassNames?.cell, componentClassNames?.label), children: label }), _jsx("td", { className: tw(componentClassNames?.cell, componentClassNames?.value), children: value })] }, index))) }) }));
|
|
7
8
|
}
|
|
8
9
|
export default DataTable;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CollectionComponentProps } from '../Collection';
|
|
2
2
|
import type { ListItemObject } from '../interfaces';
|
|
3
|
+
export type { ListClassNames } from '../ListClientComponent';
|
|
3
4
|
export type ListProps<Item, Filters = null, Data extends object | null = null> = CollectionComponentProps<Item, ListItemObject<Data>, Filters>;
|
|
4
|
-
declare function List<Item extends object, Filters, Data extends object | null = null>(props: ListProps<Item, Filters, Data>): React.ReactElement;
|
|
5
|
+
declare function List<Item extends object, Filters = null, Data extends object | null = null>(props: ListProps<Item, Filters, Data>): React.ReactElement;
|
|
5
6
|
export default List;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import type { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
1
2
|
import type { ListItemObject } from '../interfaces';
|
|
2
|
-
export interface
|
|
3
|
+
export interface ListClassNames {
|
|
4
|
+
root: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ListClientComponentProps<Data extends object | null = null> extends ClassNameProps<ListClassNames> {
|
|
3
7
|
data: ListItemObject<Data>[];
|
|
4
8
|
renderItem?: (props: ListItemObject<Data>) => React.ReactElement;
|
|
5
9
|
}
|
|
6
|
-
declare function ListClientComponent<Data extends object | null = null>({ data, renderItem, }: Readonly<ListClientComponentProps<Data>>): React.ReactElement;
|
|
10
|
+
declare function ListClientComponent<Data extends object | null = null>({ classNameProps, classNames, data, renderItem, }: Readonly<ListClientComponentProps<Data>>): React.ReactElement;
|
|
7
11
|
export default ListClientComponent;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Fragment } from 'react';
|
|
3
|
+
import { getClassNames } from '../../../styles/classnames';
|
|
3
4
|
import ListItem from '../ListItem';
|
|
4
5
|
function ListClientComponent({
|
|
5
6
|
// actions,
|
|
6
|
-
data, renderItem = ListItem, }) {
|
|
7
|
-
|
|
7
|
+
classNameProps, classNames, data, renderItem = ListItem, }) {
|
|
8
|
+
const componentClassNames = getClassNames('list', { props: classNameProps }, classNames);
|
|
9
|
+
return (_jsx("ul", { className: componentClassNames?.root, children: data.map((item) => (_jsx(Fragment, { children: renderItem({ /*actions,*/ ...item }) }, item.id))) }));
|
|
8
10
|
}
|
|
9
11
|
export default ListClientComponent;
|
|
@@ -23,6 +23,6 @@ classNames, classNameProps, description, href, id, isLoading, meta, secondary, t
|
|
|
23
23
|
const hasTertiary = Boolean(tertiary);
|
|
24
24
|
return (_jsx("li", { className: tw('@container relative grid', componentClassNames?.root, isLoading ? 'pointer-events-none animate-pulse' : null
|
|
25
25
|
// typeof actions === 'function' ? 'grid-cols-[1fr_auto] gap-4' : 'grid-cols-1'
|
|
26
|
-
), children: _jsx("article", { className: "contents", children: _jsxs("div", { className: tw('grid gap-x-6 gap-y-4', getLayout([hasPrimary, hasSecondary, hasTertiary])), children: [_jsxs("div", { className: componentClassNames?.primary, children: [title ? (_jsx("h2", { className: componentClassNames?.title, children: href ? (_jsx(Link, { className: "hover:text-link", href: href, children: title })) : (title) })) : null, description ? (_jsx("div", { className: componentClassNames?.description, children: description })) : null, _jsx(ListItemMeta, { classNameProps: classNameProps, data: meta
|
|
26
|
+
), children: _jsx("article", { className: "contents", children: _jsxs("div", { className: tw('grid gap-x-6 gap-y-4', getLayout([hasPrimary, hasSecondary, hasTertiary])), children: [_jsxs("div", { className: componentClassNames?.primary, children: [title ? (_jsx("h2", { className: componentClassNames?.title, children: href ? (_jsx(Link, { className: "hover:text-link", href: href, children: title })) : (title) })) : null, description ? (_jsx("div", { className: componentClassNames?.description, children: description })) : null, _jsx(ListItemMeta, { classNameProps: classNameProps, data: meta })] }), tertiary ? (_jsx("div", { className: componentClassNames?.tertiary, children: tertiary })) : null, _jsx(ListItemSecondary, { classNameProps: classNameProps, classNames: classNames, data: secondary?.data, variant: variant })] }) }) }));
|
|
27
27
|
}
|
|
28
28
|
export default ListItem;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { ClassNameProps } from '../../../styles/classnames/interfaces';
|
|
2
|
-
import type {
|
|
2
|
+
import type { DataTableObject } from '../interfaces';
|
|
3
3
|
export interface ListItemMetaClassNames {
|
|
4
4
|
root: string;
|
|
5
5
|
row: string;
|
|
6
6
|
title: string;
|
|
7
7
|
value: string;
|
|
8
8
|
}
|
|
9
|
-
export type ListItemMetaProps = ClassNameProps<ListItemMetaClassNames> &
|
|
10
|
-
|
|
9
|
+
export type ListItemMetaProps = ClassNameProps<ListItemMetaClassNames> & {
|
|
10
|
+
data?: React.ReactNode[] | (DataTableObject | null)[];
|
|
11
|
+
};
|
|
12
|
+
declare function ListItemMeta({ classNameProps, classNames, data, }: Readonly<ListItemMetaProps>): React.ReactElement | null;
|
|
11
13
|
export default ListItemMeta;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { isValidElement } from 'react';
|
|
3
3
|
import { filterNull } from '@sqrzro/utility';
|
|
4
4
|
import { getClassNames } from '../../../styles/classnames';
|
|
5
|
+
import DataTable from '../DataTable';
|
|
6
|
+
import isDataTableArray from '../utility/is-data-table-array';
|
|
5
7
|
function getKey(item) {
|
|
6
8
|
if (isValidElement(item)) {
|
|
7
9
|
return item.key || '-';
|
|
@@ -11,11 +13,15 @@ function getKey(item) {
|
|
|
11
13
|
}
|
|
12
14
|
return String(item);
|
|
13
15
|
}
|
|
14
|
-
function ListItemMeta({ classNameProps, classNames,
|
|
16
|
+
function ListItemMeta({ classNameProps, classNames, data, }) {
|
|
15
17
|
const componentClassNames = getClassNames('listItemMeta', { props: classNameProps }, classNames);
|
|
16
|
-
if (!data) {
|
|
18
|
+
if (!data?.length) {
|
|
17
19
|
return null;
|
|
18
20
|
}
|
|
19
|
-
|
|
21
|
+
const filteredData = filterNull(data);
|
|
22
|
+
if (isDataTableArray(filteredData)) {
|
|
23
|
+
return _jsx(DataTable, { data: filteredData });
|
|
24
|
+
}
|
|
25
|
+
return (_jsx("ul", { className: componentClassNames?.root, children: filteredData.map((item) => (_jsx("li", { className: "whitespace-nowrap", children: item }, getKey(item)))) }));
|
|
20
26
|
}
|
|
21
27
|
export default ListItemMeta;
|
|
@@ -10,6 +10,6 @@ function ListItemSecondary({ classNameProps, classNames, data, variant, }) {
|
|
|
10
10
|
if (isValidElement(data)) {
|
|
11
11
|
return _jsx("div", { className: componentClassNames?.secondary, children: data });
|
|
12
12
|
}
|
|
13
|
-
return (_jsxs("div", { className: componentClassNames?.secondary, children: [data.title ? _jsx("p", { className: componentClassNames?.title, children: data.title }) : null, data.description ? (_jsx("div", { className: componentClassNames?.description, children: data.description })) : null, _jsx(ListItemMeta, { classNameProps: { ...classNameProps, isSecondary: true }, data: data.meta
|
|
13
|
+
return (_jsxs("div", { className: componentClassNames?.secondary, children: [data.title ? _jsx("p", { className: componentClassNames?.title, children: data.title }) : null, data.description ? (_jsx("div", { className: componentClassNames?.description, children: data.description })) : null, _jsx(ListItemMeta, { classNameProps: { ...classNameProps, isSecondary: true }, data: data.meta })] }));
|
|
14
14
|
}
|
|
15
15
|
export default ListItemSecondary;
|
|
@@ -8,26 +8,19 @@ export type ListFunctionConfig<Filters = null> = CollectionFunctionConfig<Filter
|
|
|
8
8
|
export interface ListItemObject<Data extends object | null = null> {
|
|
9
9
|
$data?: Data;
|
|
10
10
|
actions?: Action[];
|
|
11
|
-
description?: React.ReactNode
|
|
11
|
+
description?: React.ReactNode;
|
|
12
12
|
href?: string;
|
|
13
13
|
id: string;
|
|
14
|
-
isMinimal?: boolean;
|
|
15
14
|
image?: string | null;
|
|
16
15
|
imageHref?: string | null;
|
|
17
16
|
isLoading?: boolean;
|
|
18
|
-
meta?:
|
|
19
|
-
data?: React.ReactNode[] | Record<string, React.ReactNode>;
|
|
20
|
-
id: string;
|
|
21
|
-
};
|
|
17
|
+
meta?: React.ReactNode[] | (DataTableObject | null)[];
|
|
22
18
|
permission?: string;
|
|
23
19
|
secondary?: {
|
|
24
20
|
data?: React.ReactElement | {
|
|
25
|
-
description?:
|
|
26
|
-
meta?:
|
|
27
|
-
|
|
28
|
-
id: string;
|
|
29
|
-
};
|
|
30
|
-
title?: string;
|
|
21
|
+
description?: React.ReactNode;
|
|
22
|
+
meta?: React.ReactNode[] | (DataTableObject | null)[];
|
|
23
|
+
title?: React.ReactNode;
|
|
31
24
|
} | null;
|
|
32
25
|
variant?: StyleVariant | null;
|
|
33
26
|
};
|
|
@@ -9,7 +9,7 @@ function ConfirmModal({ confirmable, ...modalProps }) {
|
|
|
9
9
|
setConfirmText(event.target.value?.toUpperCase() || '');
|
|
10
10
|
}
|
|
11
11
|
return (_jsxs(Modal, { ...modalProps, actions: [
|
|
12
|
-
{ label: 'Cancel'
|
|
12
|
+
{ label: 'Cancel' },
|
|
13
13
|
...(confirmable.actions || []),
|
|
14
14
|
{
|
|
15
15
|
isDisabled: Boolean(confirmable.confirmText &&
|
package/dist/filters/index.d.ts
CHANGED
package/dist/filters/index.js
CHANGED
|
@@ -10,7 +10,7 @@ function ModalForm({ children, formProps, hasServerError, hasSubmit = true, isDi
|
|
|
10
10
|
setSearchParamsHref('action', null);
|
|
11
11
|
}
|
|
12
12
|
return (_jsx(Modal, { ...modalProps, children: _jsxs(Form, { ...formProps, children: [children, hasServerError ? _jsx("div", { children: "SERVER ERROR" }) : null, _jsx(ModalActions, { actions: [
|
|
13
|
-
{ label: 'Cancel', onClick: handleCancel
|
|
13
|
+
{ label: 'Cancel', onClick: handleCancel },
|
|
14
14
|
...(modalProps.actions || []),
|
|
15
15
|
hasSubmit
|
|
16
16
|
? {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const keyMap = {
|
|
2
|
+
bordered: 'isBordered',
|
|
3
|
+
danger: 'isDanger',
|
|
4
|
+
error: 'isError',
|
|
5
|
+
info: 'isInfo',
|
|
6
|
+
primary: 'isPrimary',
|
|
7
|
+
secondary: 'isSecondary',
|
|
8
|
+
success: 'isSuccess',
|
|
9
|
+
tertiary: 'isTertiary',
|
|
10
|
+
warning: 'isWarning',
|
|
11
|
+
};
|
|
12
|
+
function applyVariants(variants) {
|
|
13
|
+
if (!variants) {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
const variantArray = Array.isArray(variants) ? variants : [variants];
|
|
17
|
+
return variantArray.reduce((acc, variant) => {
|
|
18
|
+
const key = keyMap[variant];
|
|
19
|
+
if (key) {
|
|
20
|
+
acc[key] = true;
|
|
21
|
+
}
|
|
22
|
+
return acc;
|
|
23
|
+
}, {});
|
|
24
|
+
}
|
|
25
|
+
export default applyVariants;
|
|
@@ -2,6 +2,7 @@ import type { ButtonClassNames } from '../../components/buttons/Button';
|
|
|
2
2
|
import type { TextButtonClassNames } from '../../components/buttons/TextButton';
|
|
3
3
|
import type { DataTableClassNames } from '../../components/collections/DataTable';
|
|
4
4
|
import type { EmptyMessageClassNames } from '../../components/collections/EmptyMessage';
|
|
5
|
+
import type { ListClassNames } from '../../components/collections/ListClientComponent';
|
|
5
6
|
import type { ListItemClassNames } from '../../components/collections/ListItem';
|
|
6
7
|
import type { ListItemMetaClassNames } from '../../components/collections/ListItemMeta';
|
|
7
8
|
import type { PaginationClassNames } from '../../components/collections/Pagination';
|
|
@@ -47,6 +48,7 @@ export interface RegisteredClassNames {
|
|
|
47
48
|
form?: ComponentClassNames<FormClassNames>;
|
|
48
49
|
formField?: ComponentClassNames<FormFieldClassNames>;
|
|
49
50
|
link?: ComponentClassNames<LinkClassNames>;
|
|
51
|
+
list?: ComponentClassNames<ListClassNames>;
|
|
50
52
|
listItem?: ComponentClassNames<ListItemClassNames>;
|
|
51
53
|
listItemMeta?: ComponentClassNames<ListItemMetaClassNames>;
|
|
52
54
|
loader?: ComponentClassNames<LoaderClassNames>;
|
|
@@ -42,6 +42,15 @@ export type SizableClassName = string | StatefulClassName<{
|
|
|
42
42
|
isMedium?: string;
|
|
43
43
|
isSmall?: string;
|
|
44
44
|
}>;
|
|
45
|
-
export type StylableClassName = string | StatefulClassName
|
|
46
|
-
|
|
45
|
+
export type StylableClassName = string | StatefulClassName<{
|
|
46
|
+
isBordered?: string;
|
|
47
|
+
isDanger?: string;
|
|
48
|
+
isError?: string;
|
|
49
|
+
isInfo?: string;
|
|
50
|
+
isPrimary?: string;
|
|
51
|
+
isSecondary?: string;
|
|
52
|
+
isSuccess?: string;
|
|
53
|
+
isTertiary?: string;
|
|
54
|
+
isWarning?: string;
|
|
55
|
+
}>;
|
|
47
56
|
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
@theme {
|
|
2
|
+
/* These are defaults that will (probably) be overwritten by the consuming application */
|
|
3
|
+
--color-primary: var(--color-teal-600);
|
|
4
|
+
--color-primary-dark: var(--color-teal-700);
|
|
5
|
+
--color-on-primary: var(--color-white);
|
|
6
|
+
/* End defaults */
|
|
7
|
+
|
|
8
|
+
--color-button-bg: var(--color-primary);
|
|
9
|
+
--color-button-bg-hover: var(--color-primary-dark);
|
|
10
|
+
--color-button-text: var(--color-on-primary);
|
|
11
|
+
--color-link: var(--color-primary);
|
|
12
|
+
--color-panel: var(--color-white);
|
|
13
|
+
|
|
14
|
+
--color-error: var(--color-red-600);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@layer base {
|
|
18
|
+
button {
|
|
19
|
+
@apply cursor-pointer;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
hr {
|
|
23
|
+
@apply border-slate-200;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
input::-webkit-inner-spin-button {
|
|
27
|
+
@apply appearance-none m-0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
input[type=number] {
|
|
31
|
+
-moz-appearance: textfield;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
small {
|
|
35
|
+
@apply text-xs;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
strong {
|
|
39
|
+
@apply font-semibold;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@layer utilities {
|
|
44
|
+
.fade-closed {
|
|
45
|
+
@apply invisible opacity-0 ease-in-out;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.fade-open {
|
|
49
|
+
@apply transition-discrete transition-all duration-100 starting:opacity-0 visible opacity-100;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.show-closed {
|
|
53
|
+
@apply invisible opacity-0 ease-in-out scale-90;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.show-open {
|
|
57
|
+
@apply transition-discrete transition-all duration-100 starting:opacity-0 starting:scale-90 visible opacity-100 scale-100;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -21,7 +21,7 @@ export interface Action {
|
|
|
21
21
|
isSubmittable?: boolean;
|
|
22
22
|
label: React.ReactNode;
|
|
23
23
|
onClick?: () => void;
|
|
24
|
-
variant?:
|
|
24
|
+
variant?: StyleVariant[] | StyleVariant;
|
|
25
25
|
}
|
|
26
26
|
export interface NextLayoutProps {
|
|
27
27
|
children: React.ReactNode;
|
|
@@ -32,4 +32,3 @@ export interface NextPageProps {
|
|
|
32
32
|
searchParams?: Promise<Record<string, string>> | null;
|
|
33
33
|
}
|
|
34
34
|
export type StyleVariant = 'bordered' | 'danger' | 'error' | 'info' | 'primary' | 'secondary' | 'success' | 'tertiary' | 'warning';
|
|
35
|
-
export type ButtonVariant = StyleVariant | 'link';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqrzro/ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.0-alpha.
|
|
4
|
+
"version": "4.0.0-alpha.16",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "ISC",
|
|
@@ -30,6 +30,9 @@
|
|
|
30
30
|
"types": "./dist/styles/index.d.ts",
|
|
31
31
|
"default": "./dist/styles/index.js"
|
|
32
32
|
},
|
|
33
|
+
"./styles.css": {
|
|
34
|
+
"default": "./dist/styles/styles.css"
|
|
35
|
+
},
|
|
33
36
|
"./utility": {
|
|
34
37
|
"types": "./dist/utility/index.d.ts",
|
|
35
38
|
"default": "./dist/utility/index.js"
|
|
@@ -45,7 +48,7 @@
|
|
|
45
48
|
"react-dom": "^19.2.1",
|
|
46
49
|
"tailwind-merge": "^3.4.0",
|
|
47
50
|
"use-deep-compare-effect": "^1.8.1",
|
|
48
|
-
"@sqrzro/utility": "^4.0.0-alpha.
|
|
51
|
+
"@sqrzro/utility": "^4.0.0-alpha.4"
|
|
49
52
|
},
|
|
50
53
|
"devDependencies": {
|
|
51
54
|
"@storybook/addon-a11y": "^10.1.7",
|
|
@@ -56,6 +59,7 @@
|
|
|
56
59
|
"@types/react": "^19.2.7",
|
|
57
60
|
"@types/react-dom": "^19.2.3",
|
|
58
61
|
"concurrently": "^9.2.1",
|
|
62
|
+
"cpx": "^1.5.0",
|
|
59
63
|
"next-router-mock": "^1.0.4",
|
|
60
64
|
"prettier": "^3.7.4",
|
|
61
65
|
"rimraf": "^6.1.2",
|
|
@@ -66,9 +70,10 @@
|
|
|
66
70
|
"@sqrzro/prettier-config": "^4.0.0-alpha.1"
|
|
67
71
|
},
|
|
68
72
|
"scripts": {
|
|
69
|
-
"build": "pnpm clean && tsc -p tsconfig.build.json && tsc-alias",
|
|
73
|
+
"build": "pnpm clean && tsc -p tsconfig.build.json && tsc-alias && pnpm build:css",
|
|
74
|
+
"build:css": "cpx \"./src/**/*.css\" ./dist",
|
|
70
75
|
"clean": "rimraf ./dist",
|
|
71
|
-
"dev": "(concurrently \"tsc -p tsconfig.build.json --watch\" \"tsc-alias -w\")",
|
|
76
|
+
"dev": "pnpm build:css && (concurrently \"tsc -p tsconfig.build.json --watch\" \"tsc-alias -w\")",
|
|
72
77
|
"docs:start": "storybook dev -p 6006",
|
|
73
78
|
"docs:build": "storybook build",
|
|
74
79
|
"lint": "tsc --noEmit && eslint \"./src/**/*.ts\"",
|