@serkonda7/solid-components 0.3.2 → 0.4.0

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/README.md CHANGED
@@ -34,9 +34,11 @@ export default defineConfig({ plugins: [tablerIcons(), solid()] })
34
34
  ```
35
35
 
36
36
  These components are available:
37
- - `DataTable` - generic table with optional sorting, actions, loading, empty states, and column customizer.
37
+ - `DataTable` - generic table with optional sorting, actions, loading and empty states, column customizer, resizable columns, sticky header and actions, and server-side pagination.
38
38
  - `FilterTable` - `DataTable` with filtering: quick search, a grouped filter form, and removable filter pills.
39
39
  - `Combobox` - searchable, accessible dropdown with keyboard navigation, option icons and previews, a detail column, and an optional "Add …" entry.
40
+ - `ColorInput` - hex color input with a native color picker swatch.
41
+ - `Modal` - controlled modal dialog with focus trapping and restore, a close button, Escape and backdrop-click closing.
40
42
  - `SearchBar` - search input with clear button and a global Ctrl/Cmd+K focus shortcut.
41
43
 
42
44
  For the full API, examples, and agent notes, see [docs.md](docs.md).
@@ -0,0 +1,18 @@
1
+ import type { JSX } from 'solid-js';
2
+ export interface ColorInputProps {
3
+ /** Hex color, `#rrggbb` or `#rgb`. */
4
+ value: string;
5
+ /** Receives valid colors only, normalized to lowercase `#rrggbb`. */
6
+ onInput: (value: string) => void;
7
+ /** Accessible name of the hex input. Defaults to `Color`. */
8
+ ariaLabel?: string;
9
+ /** Accessible name of the color picker. Defaults to `Pick color`. */
10
+ pickerLabel?: string;
11
+ disabled?: boolean;
12
+ class?: string;
13
+ }
14
+ /**
15
+ * Hex text input with a native color picker swatch. Text that isn't a valid color
16
+ * yet is kept while typing and reverts to `value` on blur.
17
+ */
18
+ export declare function ColorInput(props: ColorInputProps): JSX.Element;
@@ -23,6 +23,27 @@ export interface DataTableColumn<TRow> {
23
23
  /** Whether the column can be hidden via the column customizer. Defaults to `true`. Non-toggleable columns are always shown. */
24
24
  toggleable?: boolean;
25
25
  }
26
+ export interface DataTablePagination {
27
+ /** Current page, starting at 1. */
28
+ page: number;
29
+ pageSize: number;
30
+ /** Total rows across all pages. */
31
+ rowCount: number;
32
+ /** Choices of the rows-per-page select; hidden when omitted. */
33
+ pageSizeOptions?: number[];
34
+ }
35
+ export interface DataTablePaginationLabels {
36
+ /** Accessible name of the pagination landmark. Defaults to `Pagination`. */
37
+ navigation?: string;
38
+ /** Defaults to `Previous page`. */
39
+ previous?: string;
40
+ /** Defaults to `Next page`. */
41
+ next?: string;
42
+ /** Defaults to `Rows per page`. */
43
+ pageSize?: string;
44
+ /** Defaults to `1–25 of 120`. */
45
+ range?: (first: number, last: number, rowCount: number) => string;
46
+ }
26
47
  export interface DataTableProps<TRow> {
27
48
  rows: TRow[] | Accessor<TRow[]>;
28
49
  columns: DataTableColumn<TRow>[];
@@ -44,7 +65,9 @@ export interface DataTableProps<TRow> {
44
65
  onColumnOrderChange?: (orderedKeys: string[]) => void;
45
66
  /** Shows a drag handle between column headers to resize columns. */
46
67
  resizableColumns?: boolean;
47
- /** Called with all current pixel widths (by column key) after a resize. */
68
+ /** Restores pixel widths (by column key); a new value replaces the current widths, `{}` clears them. */
69
+ columnWidths?: Record<string, number> | Accessor<Record<string, number>>;
70
+ /** Called with all current pixel widths (by column key) after a resize, and with `{}` on reset. */
48
71
  onColumnWidthsChange?: (widths: Record<string, number>) => void;
49
72
  showColumnCustomizer?: boolean | Accessor<boolean>;
50
73
  columnCustomizerLabel?: string;
@@ -53,9 +76,23 @@ export interface DataTableProps<TRow> {
53
76
  columnCustomizerResetLabel?: string;
54
77
  /** Content rendered at the start of the toolbar, before the column customizer. */
55
78
  toolbar?: JSX.Element;
79
+ /** Keeps the header visible while the rows scroll, inside a viewport capped by `--data-table-max-height`. */
80
+ stickyHeader?: boolean;
81
+ /** Keeps the `rowActions` column visible while the columns scroll horizontally. */
82
+ stickyActions?: boolean;
83
+ /** Renders a pager for server-side pagination; `rows` must hold only the current page. */
84
+ pagination?: DataTablePagination | Accessor<DataTablePagination>;
85
+ onPaginationChange?: (pagination: {
86
+ page: number;
87
+ pageSize: number;
88
+ }) => void;
89
+ paginationLabels?: DataTablePaginationLabels;
56
90
  loading?: boolean | Accessor<boolean>;
57
91
  empty?: boolean | Accessor<boolean>;
92
+ /** Replaces the skeleton rows and the loading text. */
58
93
  loadingContent?: JSX.Element;
94
+ /** Skeleton rows shown while loading without rows. Defaults to 5. */
95
+ skeletonRows?: number;
59
96
  emptyContent?: JSX.Element;
60
97
  class?: string;
61
98
  }
@@ -1,8 +1,12 @@
1
1
  import type { Accessor, JSX } from 'solid-js';
2
2
  import { type ComboboxOption } from './combobox';
3
3
  import { type DataTableProps } from './data-table';
4
- export type FilterTableFilterType = 'text' | 'select' | 'boolean';
5
- /** A filter's value: text for `text`/`boolean` (`'true'`/`'false'`), a list for `select`. */
4
+ export type FilterTableFilterType = 'text' | 'select' | 'boolean' | 'number-range' | 'date-range';
5
+ /**
6
+ * A filter's value: text for `text`/`boolean` (`'true'`/`'false'`), a list for
7
+ * `select`, and `min..max` for ranges, with either bound left empty (`10..`, `..20`).
8
+ * Date bounds are `YYYY-MM-DD`. Read ranges with `parseFilterTableRange`.
9
+ */
6
10
  export type FilterTableValue = string | string[];
7
11
  /**
8
12
  * Applied filters by filter key, plus the quick search under `q`. Inactive
@@ -27,6 +31,8 @@ export interface FilterTableFilter<TRow> {
27
31
  /** Choices of a `select` filter; derived from the row values when omitted. */
28
32
  options?: ComboboxOption[];
29
33
  placeholder?: string;
34
+ /** Formats a range bound in the filter pills; defaults to the raw value. */
35
+ formatValue?: (value: string) => string;
30
36
  }
31
37
  export interface FilterTableProps<TRow> extends Omit<DataTableProps<TRow>, 'toolbar'> {
32
38
  filters: FilterTableFilter<TRow>[];
@@ -43,8 +49,12 @@ export interface FilterTableProps<TRow> extends Omit<DataTableProps<TRow>, 'tool
43
49
  onSavedFiltersChange?: (savedFilters: FilterTableSavedFilter[]) => void;
44
50
  /** Pass `rows` through unfiltered, e.g. when the server applies `filterValues`. */
45
51
  manualFiltering?: boolean;
52
+ /** Results badge count; defaults to `pagination.rowCount`, then the rows shown. */
53
+ totalCount?: number | Accessor<number | undefined>;
46
54
  /** Shows the quick search input above the table. Defaults to `true`. */
47
55
  quickSearch?: boolean;
56
+ /** Milliseconds to wait after typing before searching. Defaults to 300 with `manualFiltering`, else 0. */
57
+ quickSearchDebounce?: number;
48
58
  /** Text matched by the quick search; defaults to the row's column values. */
49
59
  getSearchText?: (row: TRow) => string;
50
60
  quickSearchLabel?: string;
@@ -56,12 +66,19 @@ export interface FilterTableProps<TRow> extends Omit<DataTableProps<TRow>, 'tool
56
66
  anyLabel?: string;
57
67
  yesLabel?: string;
58
68
  noLabel?: string;
69
+ fromLabel?: string;
70
+ toLabel?: string;
59
71
  savedFiltersLabel?: string;
60
72
  saveLabel?: string;
61
73
  saveNameLabel?: string;
62
74
  cancelLabel?: string;
63
75
  clearSavedFilterLabel?: string;
64
76
  }
77
+ /** Splits a `min..max` filter value; an open bound is `''`. */
78
+ export declare function parseFilterTableRange(value: string): {
79
+ min: string;
80
+ max: string;
81
+ };
65
82
  /**
66
83
  * `DataTable` with filtering: a Results tab with a quick search and
67
84
  * removable pills for the applied filters, and a Filters tab with a grouped form
package/dist/index.d.ts CHANGED
@@ -4,7 +4,9 @@
4
4
  * Add components here as they are implemented so consumers can import them
5
5
  * from the package root.
6
6
  */
7
+ export { ColorInput, type ColorInputProps, } from './color-input';
7
8
  export { Combobox, type ComboboxIcon, type ComboboxOption, type ComboboxProps, } from './combobox';
8
- export { DataTable, type DataTableColumn, type DataTableProps, type DataTableSort, type DataTableSortDirection, } from './data-table';
9
- export { FilterTable, type FilterTableFilter, type FilterTableFilterType, type FilterTableProps, type FilterTableSavedFilter, type FilterTableValue, type FilterTableValues, } from './filter-table';
9
+ export { DataTable, type DataTableColumn, type DataTablePagination, type DataTablePaginationLabels, type DataTableProps, type DataTableSort, type DataTableSortDirection, } from './data-table';
10
+ export { FilterTable, type FilterTableFilter, type FilterTableFilterType, type FilterTableProps, type FilterTableSavedFilter, type FilterTableValue, type FilterTableValues, parseFilterTableRange, } from './filter-table';
11
+ export { Modal, type ModalProps, } from './modal';
10
12
  export { SearchBar, type SearchBarProps, } from './search-bar';