@sqrzro/admin 2.1.0-bz.27 → 2.1.0-bz.28

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.
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export interface DataTableProps {
3
+ data: Record<string, string>;
4
+ }
5
+ declare function DataTable({ data }: Readonly<DataTableProps>): React.ReactElement;
6
+ export default DataTable;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ function DataTable({ data }) {
3
+ return (_jsx("table", { children: _jsx("tbody", { children: Object.entries(data).map(([key, value]) => (_jsxs("tr", { className: "odd:bg-slate-100", children: [_jsx("th", { className: "p-2 font-normal", children: key }), _jsx("td", { className: "p-2 text-right", children: value })] }, key))) }) }));
4
+ }
5
+ export default DataTable;
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import type { StyleVariant } from '@sqrzro/interfaces';
2
3
  export interface ListObject<Data = Record<string, unknown>> {
3
4
  $data?: Data;
4
5
  actions?: (data: Data) => React.ReactNode;
@@ -17,7 +18,8 @@ export interface ListObject<Data = Record<string, unknown>> {
17
18
  };
18
19
  tertiary?: React.ReactNode;
19
20
  title?: React.ReactNode;
21
+ variant?: StyleVariant;
20
22
  }
21
23
  export declare function renderMeta(id: string, meta: ListObject['meta']): React.ReactElement | null;
22
- declare function ListItem<Data = Record<string, unknown>>({ $data, actions, description, href, id, isMinimal, meta, secondary, tertiary, title, }: Readonly<ListObject<Data>>): React.ReactElement;
24
+ declare function ListItem<Data = Record<string, unknown>>({ $data, actions, description, href, id, isMinimal, meta, secondary, tertiary, title, variant, }: Readonly<ListObject<Data>>): React.ReactElement;
23
25
  export default ListItem;
@@ -2,6 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { isValidElement } from 'react';
3
3
  import { Link, tw } from '@sqrzro/components';
4
4
  import { filterNull } from '@sqrzro/utility';
5
+ const variantMap = {
6
+ danger: 'text-red-700',
7
+ };
5
8
  function getKey(item) {
6
9
  if (isValidElement(item)) {
7
10
  return item.key;
@@ -17,9 +20,9 @@ export function renderMeta(id, meta) {
17
20
  }
18
21
  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))) }) }));
19
22
  }
20
- function ListItem({ $data, actions, description, href, id, isMinimal, meta, secondary, tertiary, title, }) {
23
+ function ListItem({ $data, actions, description, href, id, isMinimal, meta, secondary, tertiary, title, variant, }) {
21
24
  return (_jsx("li", { children: _jsx("article", { className: tw('', isMinimal
22
25
  ? 'border-b border-slate-200 pb-4'
23
- : '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('mt-1', isMinimal ? '' : '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: "mt-1 text-xs text-slate-500", children: secondary.description })) : null, secondary.meta ? (_jsx("ul", { className: "mt-1 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, typeof actions === 'function' ? actions($data) : null] }) }) }));
26
+ : '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)]', variant ? variantMap[variant] : ''), "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: tw('text-base font-semibold', variant === 'danger' ? 'line-through' : ''), "data-testid": `list-item-title--${id}`, children: href ? _jsx(Link, { href: href, children: title }) : title })) : null, description, meta ? (_jsx("div", { className: tw('mt-1', isMinimal ? '' : '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: tw('text-base font-semibold', variant === 'danger' ? 'line-through' : ''), children: secondary.title })) : null, secondary.description ? (_jsx("div", { className: "mt-1 text-xs text-slate-500", children: secondary.description })) : null, secondary.meta ? (_jsx("ul", { className: "mt-1 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, typeof actions === 'function' ? actions($data) : null] }) }) }));
24
27
  }
25
28
  export default ListItem;
@@ -6,6 +6,8 @@ export type { BadgeProps } from './Badge';
6
6
  export { default as Badge } from './Badge';
7
7
  export type { DashboardProps } from './Dashboard';
8
8
  export { default as Dashboard } from './Dashboard';
9
+ export type { DataTableProps } from './DataTable';
10
+ export { default as DataTable } from './DataTable';
9
11
  export type { FilterBarProps, FilterObject } from './FilterBar';
10
12
  export { default as FilterBar } from './FilterBar';
11
13
  export type { GridListProps } from './GridList';
@@ -3,6 +3,7 @@ export { Autocomplete, AutocompleteFormField, Button, CalendarInput, CheckboxInp
3
3
  export { default as AppLayout } from './AppLayout';
4
4
  export { default as Badge } from './Badge';
5
5
  export { default as Dashboard } from './Dashboard';
6
+ export { default as DataTable } from './DataTable';
6
7
  export { default as FilterBar } from './FilterBar';
7
8
  export { default as GridList } from './GridList';
8
9
  export { default as InfoPanel } from './InfoPanel';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sqrzro/admin",
3
3
  "type": "module",
4
- "version": "2.1.0-bz.27",
4
+ "version": "2.1.0-bz.28",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "ISC",