@atom-learning/components 2.5.1 → 2.6.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +25 -2
  2. package/dist/components/data-table/DataTable.d.ts +71 -0
  3. package/dist/components/data-table/DataTable.js +1 -0
  4. package/dist/components/data-table/DataTableBody.d.ts +5 -0
  5. package/dist/components/data-table/DataTableBody.js +1 -0
  6. package/dist/components/data-table/DataTableContext.d.ts +20 -0
  7. package/dist/components/data-table/DataTableContext.js +1 -0
  8. package/dist/components/data-table/DataTableDataCell.d.ts +7 -0
  9. package/dist/components/data-table/DataTableDataCell.js +1 -0
  10. package/dist/components/data-table/DataTableGlobalFilter.d.ts +8 -0
  11. package/dist/components/data-table/DataTableGlobalFilter.js +1 -0
  12. package/dist/components/data-table/DataTableHead.d.ts +7 -0
  13. package/dist/components/data-table/DataTableHead.js +1 -0
  14. package/dist/components/data-table/DataTableHeaderCell.d.ts +8 -0
  15. package/dist/components/data-table/DataTableHeaderCell.js +1 -0
  16. package/dist/components/data-table/DataTableRow.d.ts +8 -0
  17. package/dist/components/data-table/DataTableRow.js +1 -0
  18. package/dist/components/data-table/DataTableTable.d.ts +6 -0
  19. package/dist/components/data-table/DataTableTable.js +1 -0
  20. package/dist/components/data-table/index.d.ts +2 -0
  21. package/dist/components/data-table/pagination/Pagination.d.ts +273 -0
  22. package/dist/components/data-table/pagination/Pagination.js +1 -0
  23. package/dist/components/data-table/pagination/PaginationButtons.d.ts +21 -0
  24. package/dist/components/data-table/pagination/PaginationButtons.js +1 -0
  25. package/dist/components/data-table/pagination/index.d.ts +1 -0
  26. package/dist/components/index.d.ts +1 -0
  27. package/dist/components/select/Select.js +1 -1
  28. package/dist/components/table/TableHeader.d.ts +6 -1
  29. package/dist/components/table/TableHeader.js +1 -1
  30. package/dist/docgen.json +1 -1
  31. package/dist/docs/DataTable.mdx +160 -0
  32. package/dist/index.cjs.js +1 -1
  33. package/dist/index.js +1 -1
  34. package/dist/utilities/optionally-visually-hidden-container/OptionallyVisuallyHiddenContainer.d.ts +4 -0
  35. package/dist/utilities/optionally-visually-hidden-container/OptionallyVisuallyHiddenContainer.js +1 -0
  36. package/dist/utilities/optionally-visually-hidden-container/index.d.ts +1 -0
  37. package/package.json +2 -1
package/CHANGELOG.md CHANGED
@@ -1,9 +1,32 @@
1
- ## [2.5.1](https://github.com/Atom-Learning/components/compare/v2.5.0...v2.5.1) (2022-09-29)
1
+ # [2.6.0](https://github.com/Atom-Learning/components/compare/v2.5.1...v2.6.0) (2022-09-29)
2
2
 
3
3
 
4
4
  ### Bug Fixes
5
5
 
6
- * **select-field:** adding hide label prop to select field ([aa41880](https://github.com/Atom-Learning/components/commit/aa41880d431f657b307a05edc41f615b74dc76b2))
6
+ * don't overwrite table components -n ([73aaf20](https://github.com/Atom-Learning/components/commit/73aaf20af1606be94cf7655683179307da935805))
7
+ * eslint-disable for fragment that eslint doesn't realise is v important ([a9bf934](https://github.com/Atom-Learning/components/commit/a9bf934d6e35fa7ebf729f758bb573f0efd8bb43))
8
+ * gloabal -> global typo ([1bfd9a7](https://github.com/Atom-Learning/components/commit/1bfd9a7fa2973074d46e00fe0aed3a817ab95d0a))
9
+ * import types explicitly ([c21af6e](https://github.com/Atom-Learning/components/commit/c21af6eaa5ad3a4ae31c8d2428319baa7b61d3ee))
10
+ * pagination select value ([81f6730](https://github.com/Atom-Learning/components/commit/81f6730aa3c265db0934599c1029fd575539969a))
11
+ * stop sort icons jumping around ([7cbef51](https://github.com/Atom-Learning/components/commit/7cbef513576c68e96d0c0f049585dca5b67e6f8d))
12
+ * stop sort icons jumping around ([b43f29b](https://github.com/Atom-Learning/components/commit/b43f29b9031192f778c14c6b32c076a561fa5c8b))
13
+
14
+
15
+ ### Features
16
+
17
+ * add global search ([d69f9ae](https://github.com/Atom-Learning/components/commit/d69f9ae90496d575f0b9922ab9c0c465a46f2d3a))
18
+ * configurable page size for Pagination component ([5389854](https://github.com/Atom-Learning/components/commit/5389854364db990cddc6bae4bb9d88a693c24368))
19
+ * configurable page size for Pagination component ([6f345a9](https://github.com/Atom-Learning/components/commit/6f345a9550acef42e2e2b47b9e078e84aa3d3c2a))
20
+ * datatable tests ([30ecbe8](https://github.com/Atom-Learning/components/commit/30ecbe8de6f7584aa82ea5a8b28ea5d95ef9cdf0))
21
+ * datatable tests ([2548b8a](https://github.com/Atom-Learning/components/commit/2548b8aadb525ca6645f58f7b5eccfe06dd3aca7))
22
+ * initial datatable tests ([2e277b8](https://github.com/Atom-Learning/components/commit/2e277b8d9b8440e783ec7344b5449474572e66c3))
23
+ * move sortable state to provider ([8ec8f9d](https://github.com/Atom-Learning/components/commit/8ec8f9d673e465973022980ab6415dc41c5ea2da))
24
+ * renaming, some doc comments ([086df58](https://github.com/Atom-Learning/components/commit/086df58eae2563fd1dd71b7eb1c35647a94b32e5))
25
+ * snapshot test ([1845725](https://github.com/Atom-Learning/components/commit/1845725cd5c267bb6525b20c68518a2de7728f60))
26
+ * update sorting API ([24369e1](https://github.com/Atom-Learning/components/commit/24369e128f4ffe5878a5c74dcf3e369eceeea418))
27
+ * update sorting API again ([7e7b2d4](https://github.com/Atom-Learning/components/commit/7e7b2d49a937f48c1334bd4c4f1b59ba5217b532))
28
+ * wip docs ([6d2ce65](https://github.com/Atom-Learning/components/commit/6d2ce657d761c1c744d8dda5dff1fe9bd81a5381))
29
+ * working Pagination component, wip context setup ([e6ac621](https://github.com/Atom-Learning/components/commit/e6ac62155459bfe4ded60869ac535e0b31b42e24))
7
30
 
8
31
  # [1.4.0](https://github.com/Atom-Learning/components/compare/v1.3.0...v1.4.0) (2022-04-11)
9
32
 
@@ -0,0 +1,71 @@
1
+ import * as React from 'react';
2
+ import { DataTableBody } from './DataTableBody';
3
+ import { DataTableDataCell } from './DataTableDataCell';
4
+ import { DataTableProvider } from './DataTableContext';
5
+ import { DataTableHead } from './DataTableHead';
6
+ import { DataTableHeaderCell } from './DataTableHeaderCell';
7
+ import { DataTableRow } from './DataTableRow';
8
+ import { DataTableGlobalFilter } from './DataTableGlobalFilter';
9
+ import { DataTableTable } from './DataTableTable';
10
+ import { Pagination } from './pagination';
11
+ declare type TDataTable = React.FC<React.ComponentProps<typeof DataTableProvider>> & {
12
+ /** Default table body implementation for `DataTable`.
13
+ *
14
+ * Can be configured with alternating colours of rows. If you need more customisation options,
15
+ * you can build your own implementation with `useDataTable()` and the UI-only `Table` components.
16
+ */
17
+ Body: typeof DataTableBody;
18
+ /** Default table data cell implementation for `DataTable`
19
+ *
20
+ *
21
+ */
22
+ DataCell: typeof DataTableDataCell;
23
+ /** Default global search implementation for `DataTable`
24
+ *
25
+ * If you need more customisation options, you can compose your own implementation with our UI-only input components and `useDataTable`.
26
+ */
27
+ GlobalFilter: typeof DataTableGlobalFilter;
28
+ /** Default table head implementation
29
+ *
30
+ * Can be configured to be sortable and with different visual themes.
31
+ * If you need more customisation options, you can build your own implementation
32
+ * with `useDataTable` and the UI-only `Table` components.
33
+ */
34
+ Head: typeof DataTableHead;
35
+ /** Default header implementation for `DataTable`
36
+ *
37
+ * Can be configured to make the column sortable. If you need more customisation options,
38
+ * you can build your own implementation with the UI-only `Table` components.
39
+ */
40
+ HeaderCell: typeof DataTableHeaderCell;
41
+ /** Default pagination implementation for `DataTable`
42
+ *
43
+ * Can navigate forward, backward, or to any specific page. If you need more customisation options,
44
+ * you can build your own implementation with `useDataTable` and other UI components.
45
+ *
46
+ */
47
+ Pagination: typeof Pagination;
48
+ /** Default row implementation for `DataTable`
49
+ *
50
+ * Renders all visible cells as `Table.Cell`. If you need more customisation options,
51
+ * you can build your own implementation with the UI-only `Table` components.
52
+ */
53
+ Row: typeof DataTableRow;
54
+ /** Default table implementation for `DataTable`.
55
+ *
56
+ * Can be configured with sortable columns and different visual themes.
57
+ *
58
+ * If you need more customisation options, you can compose your own implementation with
59
+ * lower-level `DataTable` components or build the whole thing from
60
+ * scratch with `useDataTable` and the UI-only `Table` components.
61
+ *
62
+ */
63
+ Table: typeof DataTableTable;
64
+ };
65
+ /** Context provider for DataTable state and logic.
66
+ *
67
+ * Children can call `useDataTable` to access everything provided by `@tanstack/react-table` plus
68
+ * the functionality we've built on top.
69
+ */
70
+ export declare const DataTable: TDataTable;
71
+ export {};
@@ -0,0 +1 @@
1
+ import*as e from"react";import{DataTableBody as t}from"./DataTableBody.js";import{DataTableDataCell as r}from"./DataTableDataCell.js";import{DataTableProvider as l}from"./DataTableContext.js";import{DataTableHead as m}from"./DataTableHead.js";import{DataTableHeaderCell as i}from"./DataTableHeaderCell.js";import{DataTableRow as b}from"./DataTableRow.js";import{DataTableGlobalFilter as p}from"./DataTableGlobalFilter.js";import{DataTableTable as D}from"./DataTableTable.js";import{Pagination as T}from"./pagination/Pagination.js";const a=o=>e.createElement(l,{...o});a.Body=t,a.DataCell=r,a.Head=m,a.HeaderCell=i,a.Pagination=T,a.Row=b,a.GlobalFilter=p,a.Table=D;export{a as DataTable};
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import { Table } from '../table';
3
+ declare type DataTableBodyProps = Omit<React.ComponentProps<typeof Table.Body>, 'children'>;
4
+ export declare const DataTableBody: React.FC<DataTableBodyProps>;
5
+ export {};
@@ -0,0 +1 @@
1
+ import*as o from"react";import{Table as m}from"../table/Table.js";import{useDataTable as p}from"./DataTableContext.js";import{DataTable as i}from"./DataTable.js";const l=({striped:r=!1,...t})=>{const{getRowModel:a}=p();return o.createElement(m.Body,{...t,striped:r},a().rows.map(e=>o.createElement(i.Row,{row:e,key:e.id})))};export{l as DataTableBody};
@@ -0,0 +1,20 @@
1
+ import * as React from 'react';
2
+ import type { Table } from '@tanstack/react-table';
3
+ declare type DataTableContextType<T = unknown> = Table<T> & {
4
+ setIsSortable: React.Dispatch<React.SetStateAction<boolean>>;
5
+ applyPagination: () => void;
6
+ getTotalRows: () => number;
7
+ isSortable: boolean;
8
+ };
9
+ declare type TableProviderProps = {
10
+ columns: any;
11
+ data: Array<Record<string, unknown>>;
12
+ defaultSort?: {
13
+ column: string;
14
+ direction: 'asc' | 'desc';
15
+ };
16
+ children: React.ReactNode;
17
+ };
18
+ export declare const DataTableProvider: ({ columns, data, defaultSort, children }: TableProviderProps) => JSX.Element;
19
+ export declare const useDataTable: <T extends Record<string, unknown>>() => DataTableContextType<T>;
20
+ export {};
@@ -0,0 +1 @@
1
+ import*as e from"react";import{useReactTable as R,getCoreRowModel as M,getPaginationRowModel as S,getSortedRowModel as T,getFilteredRowModel as p}from"@tanstack/react-table";const s=e.createContext(null),v=({columns:t,data:l,defaultSort:o,children:g})=>{const[u,c]=e.useState(!1),[a,w]=e.useState(!1),[r,b]=e.useState(o?[{id:o.column,desc:o.direction==="desc"}]:[]),n=e.useCallback(()=>{c(!0)},[]),d=()=>l.length,i=R({columns:t,data:l,getCoreRowModel:M(),getPaginationRowModel:u?S():void 0,getSortedRowModel:a||r.length?T():void 0,state:{sorting:r},onSortingChange:b,getFilteredRowModel:p()}),m=e.useMemo(()=>({...i,setIsSortable:w,applyPagination:n,getTotalRows:d,isSortable:a}),[i,n,d,a]);return e.createElement(s.Provider,{value:m},g)},C=()=>{const t=e.useContext(s);if(!t)throw new Error("useDataTable can only be called from inside a DataTableProvider");return t};export{v as DataTableProvider,C as useDataTable};
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import type { Cell } from '@tanstack/react-table';
3
+ declare type DataTableDataCellProps = {
4
+ cell: Cell<Record<string, unknown>, unknown>;
5
+ };
6
+ export declare const DataTableDataCell: React.FC<DataTableDataCellProps>;
7
+ export {};
@@ -0,0 +1 @@
1
+ import*as l from"react";import{Table as o}from"../table/Table.js";import{flexRender as t}from"@tanstack/react-table";const m=({cell:e})=>l.createElement(o.Cell,{key:e.id},t(e.column.columnDef.cell,e.getContext()));export{m as DataTableDataCell};
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ import { SearchInput } from '../search-input';
3
+ declare type DataTableSearchProps = React.ComponentProps<typeof SearchInput> & {
4
+ label: string;
5
+ hideLabel?: boolean;
6
+ };
7
+ export declare const DataTableGlobalFilter: React.FC<DataTableSearchProps>;
8
+ export {};
@@ -0,0 +1 @@
1
+ import*as e from"react";import{debounce as p}from"throttle-debounce";import{SearchInput as s}from"../search-input/SearchInput.js";import{useDataTable as u}from"./DataTableContext.js";import{Label as d}from"../label/Label.js";import{OptionallyVisuallyHiddenContainer as f}from"../../utilities/optionally-visually-hidden-container/OptionallyVisuallyHiddenContainer.js";const g=({onChange:l,label:t,hideLabel:r=!1,...n})=>{const{setGlobalFilter:o,getState:m}=u(),{globalFilter:i}=m(),b=p(250,a=>{const{target:{value:c}}=a;l==null||l(a),o(c)});return e.createElement(e.Fragment,null,e.createElement(f,{hidden:r},e.createElement(d,{css:{mb:"$3"},htmlFor:t},t)),e.createElement(s,{...n,value:i,onChange:b,name:t}))};export{g as DataTableGlobalFilter};
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { Table } from '../table';
3
+ declare type DataTableHeadProps = Omit<React.ComponentProps<typeof Table.Header>, 'children'> & {
4
+ sortable?: boolean;
5
+ };
6
+ export declare const DataTableHead: React.FC<DataTableHeadProps>;
7
+ export {};
@@ -0,0 +1 @@
1
+ import*as e from"react";import{Table as o}from"../table/Table.js";import{useDataTable as p}from"./DataTableContext.js";import{DataTable as b}from"./DataTable.js";const i=({sortable:t=!0,theme:l="light",...s})=>{const{getHeaderGroups:d,setIsSortable:a}=p();return e.useEffect(()=>{a(t)},[t,a]),e.createElement(o.Header,{theme:l,...s},d().map(r=>e.createElement(o.Row,{key:r.id},r.headers.map(m=>e.createElement(b.HeaderCell,{header:m,key:m.id})))))};export{i as DataTableHead};
@@ -0,0 +1,8 @@
1
+ import type { Header } from '@tanstack/react-table';
2
+ import * as React from 'react';
3
+ import { Table } from '../table';
4
+ declare type DataTableHeaderProps = React.ComponentProps<typeof Table.HeaderCell> & {
5
+ header: Header<Record<string, unknown>, unknown>;
6
+ };
7
+ export declare const DataTableHeaderCell: React.FC<DataTableHeaderProps>;
8
+ export {};
@@ -0,0 +1 @@
1
+ import{flexRender as s}from"@tanstack/react-table";import*as t from"react";import{Flex as l}from"../flex/Flex.js";import{Table as m}from"../table/Table.js";import{Icon as a}from"../icon/Icon.js";import{SortUp as d,SortDown as p}from"@atom-learning/icons";import{useDataTable as f}from"./DataTableContext.js";const u={asc:d,desc:p},g=({direction:e})=>t.createElement(a,{is:u[e],size:"sm",css:{position:"absolute",left:"$1"}}),b=({header:e,children:C,css:i,...c})=>{const r=e.column.getIsSorted(),{isSortable:o}=f(),n=e.column.getCanSort();return t.createElement(m.HeaderCell,{onClick:o&&n?e.column.getToggleSortingHandler():void 0,css:{cursor:o&&n?"pointer":"initial",...i},...c},t.createElement(l,{css:{alignItems:"center"}},s(e.column.columnDef.header,e.getContext()),r&&o&&t.createElement(l,{css:{position:"relative",alignItems:"center"}},t.createElement(g,{direction:r}))))};export{b as DataTableHeaderCell};
@@ -0,0 +1,8 @@
1
+ import type { Row } from '@tanstack/react-table';
2
+ import * as React from 'react';
3
+ import { Table } from '../table';
4
+ declare type DataTableRowProps = React.ComponentProps<typeof Table.Row> & {
5
+ row: Row<Record<string, unknown>>;
6
+ };
7
+ export declare const DataTableRow: React.FC<DataTableRowProps>;
8
+ export {};
@@ -0,0 +1 @@
1
+ import*as l from"react";import{Table as t}from"../table/Table.js";import{DataTableDataCell as o}from"./DataTableDataCell.js";const r=({row:a})=>l.createElement(t.Row,null,a.getVisibleCells().map(e=>l.createElement(o,{key:e.id,cell:e})));export{r as DataTableRow};
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ import { Table } from '../table';
3
+ import { DataTable } from './DataTable';
4
+ declare type DataTableTableProps = Omit<React.ComponentProps<typeof Table>, 'children'> & Partial<Pick<React.ComponentProps<typeof DataTable.Head>, 'theme' | 'sortable'>> & Partial<Pick<React.ComponentProps<typeof Table.Body>, 'striped'>>;
5
+ export declare const DataTableTable: React.FC<DataTableTableProps>;
6
+ export {};
@@ -0,0 +1 @@
1
+ import*as e from"react";import{Table as l}from"../table/Table.js";import{DataTable as t}from"./DataTable.js";const b=({sortable:a,striped:r,theme:o,...m})=>e.createElement(l,{...m},e.createElement(t.Head,{theme:o,sortable:a}),e.createElement(t.Body,{striped:r}));export{b as DataTableTable};
@@ -0,0 +1,2 @@
1
+ export { useDataTable } from './DataTableContext';
2
+ export { DataTable } from './DataTable';
@@ -0,0 +1,273 @@
1
+ import * as React from 'react';
2
+ declare const StyledNav: import("@stitches/react/types/styled-component").StyledComponent<"nav", {}, {
3
+ sm: string;
4
+ md: string;
5
+ lg: string;
6
+ xl: string;
7
+ reducedMotion: string;
8
+ allowMotion: string;
9
+ hover: string;
10
+ }, import("@stitches/react/types/css-util").CSS<{
11
+ sm: string;
12
+ md: string;
13
+ lg: string;
14
+ xl: string;
15
+ reducedMotion: string;
16
+ allowMotion: string;
17
+ hover: string;
18
+ }, {
19
+ colors: {
20
+ textForeground: any;
21
+ textSubtle: any;
22
+ textPlaceholder: any;
23
+ background: any;
24
+ backgroundAccent: any;
25
+ tonal50: any;
26
+ tonal100: any;
27
+ tonal200: any;
28
+ tonal300: any;
29
+ tonal400: any;
30
+ tonal500: any;
31
+ tonal600: any;
32
+ alpha100: any;
33
+ alpha150: any;
34
+ alpha200: any;
35
+ alpha250: any;
36
+ alpha600: any;
37
+ primaryLight: any;
38
+ primary: any;
39
+ primaryMid: any;
40
+ primaryDark: any;
41
+ secondary: any;
42
+ brandRed: any;
43
+ brandRedAccent: any;
44
+ brandGreen: any;
45
+ brandGreenAccent: any;
46
+ brandPurple: any;
47
+ brandPurpleAccent: any;
48
+ brandYellow: any;
49
+ brandYellowAccent: any;
50
+ successLight: any;
51
+ success: any;
52
+ successMid: any;
53
+ successDark: any;
54
+ dangerLight: any;
55
+ danger: any;
56
+ dangerMid: any;
57
+ dangerDark: any;
58
+ warningLight: any;
59
+ warning: any;
60
+ warningMid: any;
61
+ warningDark: any;
62
+ warningText: any;
63
+ subjectEnglish: any;
64
+ subjectMaths: any;
65
+ subjectScience: any;
66
+ subjectVerbalReasoning: any;
67
+ subjectNonVerbalReasoning: any;
68
+ subjectCreativeWriting: any;
69
+ subjectExamSkills: any;
70
+ };
71
+ space: {
72
+ "0": any;
73
+ "1": any;
74
+ "2": any;
75
+ "3": any;
76
+ "4": any;
77
+ "5": any;
78
+ "6": any;
79
+ "7": any;
80
+ "8": any;
81
+ "9": any;
82
+ };
83
+ fontSizes: {
84
+ xs: any;
85
+ sm: any;
86
+ md: any;
87
+ lg: any;
88
+ xl: any;
89
+ "2xl": any;
90
+ "3xl": any;
91
+ "4xl": any;
92
+ };
93
+ fonts: {
94
+ sans: any;
95
+ mono: any;
96
+ display: any;
97
+ body: any;
98
+ };
99
+ sizes: {
100
+ "0": any;
101
+ "1": any;
102
+ "2": any;
103
+ "3": any;
104
+ "4": any;
105
+ "5": any;
106
+ "6": any;
107
+ "7": any;
108
+ "8": any;
109
+ };
110
+ radii: {
111
+ "0": any;
112
+ "1": any;
113
+ "2": any;
114
+ "3": any;
115
+ round: any;
116
+ };
117
+ shadows: {
118
+ "0": any;
119
+ "1": any;
120
+ "2": any;
121
+ "3": any;
122
+ };
123
+ }, import("@stitches/react/types/config").DefaultThemeMap, {
124
+ bg: (value: {
125
+ readonly [$$PropertyValue]: "background";
126
+ }) => {
127
+ background: {
128
+ readonly [$$PropertyValue]: "background";
129
+ };
130
+ };
131
+ inset: (value: string | number | {
132
+ readonly [$$ScaleValue]: "space";
133
+ }) => {
134
+ top: string | number | {
135
+ readonly [$$ScaleValue]: "space";
136
+ };
137
+ right: string | number | {
138
+ readonly [$$ScaleValue]: "space";
139
+ };
140
+ bottom: string | number | {
141
+ readonly [$$ScaleValue]: "space";
142
+ };
143
+ left: string | number | {
144
+ readonly [$$ScaleValue]: "space";
145
+ };
146
+ };
147
+ size: (value: string | number | {
148
+ readonly [$$ScaleValue]: "size";
149
+ }) => {
150
+ height: string | number | {
151
+ readonly [$$ScaleValue]: "size";
152
+ };
153
+ width: string | number | {
154
+ readonly [$$ScaleValue]: "size";
155
+ };
156
+ };
157
+ p: (value: string | number | {
158
+ readonly [$$ScaleValue]: "space";
159
+ }) => {
160
+ padding: string | number | {
161
+ readonly [$$ScaleValue]: "space";
162
+ };
163
+ };
164
+ pt: (value: string | number | {
165
+ readonly [$$ScaleValue]: "space";
166
+ }) => {
167
+ paddingTop: string | number | {
168
+ readonly [$$ScaleValue]: "space";
169
+ };
170
+ };
171
+ pr: (value: string | number | {
172
+ readonly [$$ScaleValue]: "space";
173
+ }) => {
174
+ paddingRight: string | number | {
175
+ readonly [$$ScaleValue]: "space";
176
+ };
177
+ };
178
+ pb: (value: string | number | {
179
+ readonly [$$ScaleValue]: "space";
180
+ }) => {
181
+ paddingBottom: string | number | {
182
+ readonly [$$ScaleValue]: "space";
183
+ };
184
+ };
185
+ pl: (value: string | number | {
186
+ readonly [$$ScaleValue]: "space";
187
+ }) => {
188
+ paddingLeft: string | number | {
189
+ readonly [$$ScaleValue]: "space";
190
+ };
191
+ };
192
+ px: (value: string | number | {
193
+ readonly [$$ScaleValue]: "space";
194
+ }) => {
195
+ paddingLeft: string | number | {
196
+ readonly [$$ScaleValue]: "space";
197
+ };
198
+ paddingRight: string | number | {
199
+ readonly [$$ScaleValue]: "space";
200
+ };
201
+ };
202
+ py: (value: string | number | {
203
+ readonly [$$ScaleValue]: "space";
204
+ }) => {
205
+ paddingTop: string | number | {
206
+ readonly [$$ScaleValue]: "space";
207
+ };
208
+ paddingBottom: string | number | {
209
+ readonly [$$ScaleValue]: "space";
210
+ };
211
+ };
212
+ m: (value: string | number | {
213
+ readonly [$$ScaleValue]: "space";
214
+ }) => {
215
+ margin: string | number | {
216
+ readonly [$$ScaleValue]: "space";
217
+ };
218
+ };
219
+ mt: (value: string | number | {
220
+ readonly [$$ScaleValue]: "space";
221
+ }) => {
222
+ marginTop: string | number | {
223
+ readonly [$$ScaleValue]: "space";
224
+ };
225
+ };
226
+ mr: (value: string | number | {
227
+ readonly [$$ScaleValue]: "space";
228
+ }) => {
229
+ marginRight: string | number | {
230
+ readonly [$$ScaleValue]: "space";
231
+ };
232
+ };
233
+ mb: (value: string | number | {
234
+ readonly [$$ScaleValue]: "space";
235
+ }) => {
236
+ marginBottom: string | number | {
237
+ readonly [$$ScaleValue]: "space";
238
+ };
239
+ };
240
+ ml: (value: string | number | {
241
+ readonly [$$ScaleValue]: "space";
242
+ }) => {
243
+ marginLeft: string | number | {
244
+ readonly [$$ScaleValue]: "space";
245
+ };
246
+ };
247
+ mx: (value: string | number | {
248
+ readonly [$$ScaleValue]: "space";
249
+ }) => {
250
+ marginLeft: string | number | {
251
+ readonly [$$ScaleValue]: "space";
252
+ };
253
+ marginRight: string | number | {
254
+ readonly [$$ScaleValue]: "space";
255
+ };
256
+ };
257
+ my: (value: string | number | {
258
+ readonly [$$ScaleValue]: "space";
259
+ }) => {
260
+ marginTop: string | number | {
261
+ readonly [$$ScaleValue]: "space";
262
+ };
263
+ marginBottom: string | number | {
264
+ readonly [$$ScaleValue]: "space";
265
+ };
266
+ };
267
+ }>>;
268
+ declare type PaginationProps = React.ComponentProps<typeof StyledNav> & {
269
+ pageSize?: number;
270
+ };
271
+ /** Applies pagination to parent DataTableProvider and renders UI to switch pages etc */
272
+ export declare const Pagination: React.FC<PaginationProps>;
273
+ export {};
@@ -0,0 +1 @@
1
+ import*as e from"react";import{styled as u}from"../../../stitches.js";import{useDataTable as P}from"../DataTableContext.js";import{GotoPageSelect as E,DirectionButton as s}from"./PaginationButtons.js";import{Flex as I}from"../../flex/Flex.js";import{Text as S}from"../../text/Text.js";const C=u("nav",{display:"flex",justifyContent:"space-between",alignItems:"center"}),y=({pageSize:n=10,...g})=>{const{applyPagination:o,getState:c,getRowModel:l,getPageCount:a,previousPage:m,nextPage:p,setPageIndex:d,setPageSize:i,getTotalRows:f}=P();e.useEffect(()=>{o()},[o]),e.useEffect(()=>{i(n)},[i,n]);const{pagination:t}=c(),r=t.pageIndex*t.pageSize+1,x=r+l().rows.length-1;return e.createElement(C,{...g},e.createElement(S,{size:"sm"},`${r.toString()} - ${x.toString()} of ${f()} items`),e.createElement(E,{gotoPage:d,pageCount:a(),pageIndex:t.pageIndex}),e.createElement(I,{css:{justifyContent:"flex-end"}},e.createElement(s,{direction:"previous",disabled:t.pageIndex===0,onClick:m,css:{mr:"$4"}}),e.createElement(s,{direction:"next",disabled:t.pageIndex===a()-1,onClick:p})))};export{y as Pagination};
@@ -0,0 +1,21 @@
1
+ import type { CSS } from '../../../stitches';
2
+ import React from 'react';
3
+ import { ActionIcon } from '../../action-icon';
4
+ import { Icon } from '../../icon';
5
+ export declare const DirectionButton: React.FC<{
6
+ css?: CSS;
7
+ direction: 'next' | 'previous';
8
+ disabled: boolean;
9
+ onClick: () => void;
10
+ }>;
11
+ export declare const GotoPageSelect: React.FC<{
12
+ pageIndex: number;
13
+ pageCount: number;
14
+ gotoPage: (pageNumber: number) => void;
15
+ }>;
16
+ declare type TooltipActionIconProps = React.ComponentProps<typeof ActionIcon> & React.ComponentProps<typeof Icon> & {
17
+ icon: React.FC<React.SVGProps<SVGSVGElement>>;
18
+ iconSize?: 'sm' | 'md' | 'lg';
19
+ };
20
+ export declare const TooltipActionIcon: React.FC<Omit<TooltipActionIconProps, 'children' | 'is'>>;
21
+ export {};
@@ -0,0 +1 @@
1
+ import{ChevronRight as i,ChevronLeft as c}from"@atom-learning/icons";import e from"react";import{Flex as p}from"../../flex/Flex.js";import{Select as s}from"../../select/Select.js";import{Text as g}from"../../text/Text.js";import{ActionIcon as u}from"../../action-icon/ActionIcon.js";import{Icon as f}from"../../icon/Icon.js";import{Tooltip as a}from"../../tooltip/Tooltip.js";const E=({direction:n,...t})=>{const o=n==="next";return e.createElement(m,{appearance:"outline",icon:o?i:c,isRounded:!0,label:o?"Next page":"Previous page",name:o?"Next page":"Previous page",size:"md",...t})},x=({gotoPage:n,pageCount:t,pageIndex:o})=>e.createElement(p,{css:{alignItems:"center"}},e.createElement(s,{value:o,size:"sm",css:{mr:"$3"},onChange:r=>{n(Number(r.target.value))}},Array.from({length:t},(r,l)=>l).map(r=>e.createElement("option",{key:r,value:r},r+1))),e.createElement(g,{size:"sm",css:{flex:"none"}},`of ${t} ${t>1?"pages":"page"}`)),m=({icon:n,label:t,...o})=>e.createElement(a,null,e.createElement(a.Trigger,{asChild:!0},e.createElement(u,{label:t,...o},e.createElement(f,{is:n}))),e.createElement(a.Content,null,t));export{E as DirectionButton,x as GotoPageSelect,m as TooltipActionIcon};
@@ -0,0 +1 @@
1
+ export { Pagination } from './Pagination';
@@ -13,6 +13,7 @@ export { Chip, ChipGroup } from './chip';
13
13
  export { ChipDismissibleGroup } from './chip-dismissible-group';
14
14
  export { ChipToggleGroup } from './chip-toggle-group';
15
15
  export { Combobox } from './combobox';
16
+ export { DataTable, useDataTable } from './data-table';
16
17
  export { Dialog } from './dialog';
17
18
  export { DateInput } from './date-input';
18
19
  export { DateField } from './date-field';
@@ -1 +1 @@
1
- import*as o from"react";import{styled as d,theme as s}from"../../stitches.js";import{encodeBackgroundIcon as c}from"../../utilities/style/encode-background-icon.js";const p=d("select",{appearance:"none",backgroundColor:"white",backgroundImage:c(s.colors.tonal300.value,"chevron"),backgroundRepeat:"no-repeat, repeat",border:"1px solid $tonal300",borderRadius:"$0",color:"$tonal600",display:"block",fontFamily:"$body",fontWeight:400,lineHeight:1.4,transition:"all 75ms ease-out",width:"100%","&:hover":{cursor:"pointer"},"&:focus":{borderColor:"$primary",outline:"none"},"&::-ms-expand":{display:"none"},"&[disabled], > option[disabled]":{backgroundColor:"$tonal100",color:"$tonal400",cursor:"not-allowed"},variants:{size:{sm:{backgroundPosition:"right $space$2 top 50%, 0 0",backgroundSize:"18px auto, 100%",fontSize:"$sm",height:"$3",pl:"$2",pr:"$5"},md:{backgroundPosition:"right $space$3 top 50%, 0 0",backgroundSize:"20px auto, 100%",fontSize:"$md",height:"$4",pl:"$3",pr:"$6"}},state:{error:{border:"1px solid $danger"}}}}),t=o.forwardRef(({placeholder:r,children:n,size:l="md",...e},i)=>{const a={size:l,ref:i,...e};return!e.value&&!e.defaultValue&&(a.defaultValue=""),o.createElement(p,{...a},r&&o.createElement("option",{disabled:!0,hidden:!0,value:""},r),n)});t.displayName="Select";export{t as Select};
1
+ import*as e from"react";import{styled as s,theme as c}from"../../stitches.js";import{encodeBackgroundIcon as p}from"../../utilities/style/encode-background-icon.js";const u=s("select",{appearance:"none",backgroundColor:"white",backgroundImage:p(c.colors.tonal300.value,"chevron"),backgroundRepeat:"no-repeat, repeat",border:"1px solid $tonal300",borderRadius:"$0",color:"$tonal600",display:"block",fontFamily:"$body",fontWeight:400,lineHeight:1.4,transition:"all 75ms ease-out",width:"100%","&:hover":{cursor:"pointer"},"&:focus":{borderColor:"$primary",outline:"none"},"&::-ms-expand":{display:"none"},"&[disabled], > option[disabled]":{backgroundColor:"$tonal100",color:"$tonal400",cursor:"not-allowed"},variants:{size:{sm:{backgroundPosition:"right $space$2 top 50%, 0 0",backgroundSize:"18px auto, 100%",fontSize:"$sm",height:"$3",pl:"$2",pr:"$5"},md:{backgroundPosition:"right $space$3 top 50%, 0 0",backgroundSize:"20px auto, 100%",fontSize:"$md",height:"$4",pl:"$3",pr:"$6"}},state:{error:{border:"1px solid $danger"}}}}),t=e.forwardRef(({placeholder:r,children:n,size:l="md",...o},i)=>{const a={size:l,ref:i,...o};return[o.value,o.defaultValue].every(d=>d===void 0)&&(a.defaultValue=""),e.createElement(u,{...a},r&&e.createElement("option",{disabled:!0,hidden:!0,value:""},r),n)});t.displayName="Select";export{t as Select};
@@ -1,6 +1,11 @@
1
1
  import React from 'react';
2
+ export declare const TABLE_HEADER_THEMES: {
3
+ PRIMARY: string;
4
+ PRIMARY_DARK: string;
5
+ LIGHT: string;
6
+ };
2
7
  declare const StyledTableHeader: import("@stitches/react/types/styled-component").StyledComponent<"thead", {
3
- theme?: "primary" | "primaryDark" | "light" | undefined;
8
+ theme?: string | number | `${number}` | undefined;
4
9
  }, {
5
10
  sm: string;
6
11
  md: string;
@@ -1 +1 @@
1
- import m from"react";import{styled as l}from"../../stitches.js";import{TableHeaderCell as r}from"./TableHeaderCell.js";const o=l("thead",{variants:{theme:{primary:{[`${r}`]:{bg:"$primary"}},primaryDark:{[`${r}`]:{bg:"$primaryDark"}},light:{[`${r}`]:{bg:"$tonal50",color:"$tonal600"}}}}}),e=({theme:a="primaryDark",...t})=>m.createElement(o,{theme:a,...t});e.displayName="TableHeader";export{e as TableHeader};
1
+ import o from"react";import{styled as l}from"../../stitches.js";import{TableHeaderCell as e}from"./TableHeaderCell.js";const r={PRIMARY:"primary",PRIMARY_DARK:"primaryDark",LIGHT:"light"},i=l("thead",{variants:{theme:{[r.PRIMARY]:{[`${e}`]:{bg:"$primary"}},[r.PRIMARY_DARK]:{[`${e}`]:{bg:"$primaryDark"}},[r.LIGHT]:{[`${e}`]:{bg:"$tonal50",color:"$tonal600"}}}}}),a=({theme:t="primaryDark",...m})=>o.createElement(i,{theme:t,...m});a.displayName="TableHeader";export{r as TABLE_HEADER_THEMES,a as TableHeader};