@sqrzro/ui 4.0.0-alpha.5 → 4.0.0-alpha.7

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.
@@ -2,14 +2,16 @@ import type { FilterMap } from '../../../filters/interfaces';
2
2
  import type { NextPageProps } from '../../../utility/interfaces';
3
3
  import type { EmptyMessageProps } from '../EmptyMessage';
4
4
  import type { ListFunctionConfig, Paginated } from '../interfaces';
5
- export interface CollectionProps<Item, Transformed, Filters = null> {
5
+ export interface CollectionComponentProps<Item, Transformed, Filters = null> {
6
6
  readonly data?: Item[] | Paginated<Item>;
7
7
  readonly emptyMessageProps?: EmptyMessageProps;
8
8
  readonly filterMap?: FilterMap<Filters>;
9
9
  readonly fn?: (config: ListFunctionConfig<Filters>) => Promise<Item[]> | Promise<Paginated<Item>>;
10
10
  readonly pageProps?: NextPageProps;
11
- readonly render: (data: Transformed[]) => React.ReactElement;
12
11
  readonly transformer: (item: Item) => Transformed;
13
12
  }
13
+ export interface CollectionProps<Item, Transformed, Filters = null> extends CollectionComponentProps<Item, Transformed, Filters> {
14
+ readonly render: (data: Transformed[]) => React.ReactElement;
15
+ }
14
16
  declare function Collection<Item extends object, Transformed, Filters>({ filterMap, ...props }: CollectionProps<Item, Transformed, Filters>): React.ReactElement;
15
17
  export default Collection;
@@ -1,6 +1,5 @@
1
- import { CollectionProps } from '../Collection';
1
+ import { CollectionComponentProps } from '../Collection';
2
2
  import type { ListItemObject } from '../interfaces';
3
- export interface ListProps<Item, Filters = null, Data extends object | null = null> extends Omit<CollectionProps<Item, ListItemObject<Data>, Filters>, 'render'> {
4
- }
3
+ export type ListProps<Item, Filters = null, Data extends object | null = null> = CollectionComponentProps<Item, ListItemObject<Data>, Filters>;
5
4
  declare function List<Item extends object, Filters, Data extends object | null = null>(props: ListProps<Item, Filters, Data>): React.ReactElement;
6
5
  export default List;
@@ -1,7 +1,7 @@
1
- import { CollectionProps } from '../Collection';
1
+ import { CollectionComponentProps } from '../Collection';
2
2
  import type { TableColumnObject, TableItemObject } from '../interfaces';
3
3
  export type { TableClassNames } from '../TableClientComponent';
4
- export interface TableProps<Item, Filters = null> extends CollectionProps<Item, TableItemObject, Filters> {
4
+ export interface TableProps<Item, Filters = null> extends CollectionComponentProps<Item, TableItemObject, Filters> {
5
5
  readonly columns: TableColumnObject[];
6
6
  readonly isSelectable?: boolean;
7
7
  }
@@ -7,6 +7,9 @@ export interface RootLayoutClassNames {
7
7
  export interface RootLayoutProps extends ClassNameProps<RootLayoutClassNames> {
8
8
  readonly children: React.ReactNode;
9
9
  readonly classNameConfig?: RegisteredClassNames;
10
+ readonly font?: {
11
+ variable: string;
12
+ };
10
13
  }
11
- declare function RootLayout({ children, classNameConfig, classNameProps, classNames, }: RootLayoutProps): React.ReactElement;
14
+ declare function RootLayout({ children, classNameConfig, classNameProps, classNames, font, }: RootLayoutProps): React.ReactElement;
12
15
  export default RootLayout;
@@ -2,12 +2,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { getClassNames, registerClassNames } from '../../../styles/config';
3
3
  import ClassNames from '../ClassNames';
4
4
  import Toaster from '../Toaster';
5
- function RootLayout({ children, classNameConfig, classNameProps, classNames, }) {
5
+ function RootLayout({ children, classNameConfig, classNameProps, classNames, font, }) {
6
6
  if (classNameConfig) {
7
7
  registerClassNames(classNameConfig);
8
8
  }
9
9
  const componentClassNames = classNames || getClassNames('rootLayout')?.(classNameProps);
10
- return (_jsxs("html", { lang: "en", children: [_jsx("head", { children: _jsx("link", { href: "/images/favicon.svg", rel: "icon" }) }), _jsxs("body", { className: componentClassNames?.root, children: [_jsx("script", { dangerouslySetInnerHTML: {
10
+ return (_jsxs("html", { lang: "en", className: font?.variable, children: [_jsx("head", { children: _jsx("link", { href: "/images/favicon.svg", rel: "icon" }) }), _jsxs("body", { className: componentClassNames?.root, children: [_jsx("script", { dangerouslySetInnerHTML: {
11
11
  __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))",
12
12
  } }), classNameConfig ? _jsx(ClassNames, { data: classNameConfig }) : null, _jsx("div", { className: componentClassNames?.content, children: children }), _jsx(Toaster, {})] })] }));
13
13
  }
@@ -21,8 +21,8 @@ export type ClientFilterMap<T> = {
21
21
  [K in keyof T]?: ClientFilterObject<FilterType>;
22
22
  };
23
23
  export interface FilterObject<T, F extends FilterType> extends ClientFilterObject<F> {
24
- transformer: (value: string) => T;
24
+ transformer: (value: string | null) => T | null;
25
25
  }
26
26
  export type FilterMap<T> = {
27
- [K in keyof T]?: FilterObject<T[K], FilterType>;
27
+ [K in keyof T]?: FilterObject<T[K] | null, FilterType>;
28
28
  };
@@ -1,3 +1,3 @@
1
- import type { FilterMap } from "../interfaces";
1
+ import type { FilterMap } from '../interfaces';
2
2
  declare function parseFilters<T>(searchParams: Record<string, string> | null, map?: FilterMap<T> | null): Partial<T> | null;
3
3
  export default parseFilters;
@@ -6,8 +6,9 @@ function parseFilters(searchParams, map) {
6
6
  for (const key in map) {
7
7
  if (Object.hasOwn(map, key) && typeof map[key] !== 'undefined') {
8
8
  const value = searchParams[key];
9
- if (value) {
10
- out[key] = map[key].transformer(value);
9
+ const transformed = map[key].transformer(value);
10
+ if (transformed) {
11
+ out[key] = transformed;
11
12
  }
12
13
  }
13
14
  }
@@ -1,2 +1,2 @@
1
1
  export declare function transformFromBoolean(value?: boolean): string;
2
- export declare function transformToBoolean(value?: string): boolean;
2
+ export declare function transformToBoolean(value?: string | null): boolean;
@@ -1,2 +1,2 @@
1
1
  export declare function transformFromDate(value?: [Date, Date] | null): string;
2
- export declare function transformToDate(value?: string): [Date, Date] | null;
2
+ export declare function transformToDate(value?: string | null): [Date, Date] | null;
@@ -1,2 +1,2 @@
1
1
  export declare function transformFromMulti(value?: string[] | null): string;
2
- export declare function transformToMulti(value?: string): string[] | null;
2
+ export declare function transformToMulti(value?: string | null): string[] | null;
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.5",
4
+ "version": "4.0.0-alpha.7",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "ISC",