@mrcaktuz/sds-react 0.1.0 → 0.2.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/dist/grid.d.cts CHANGED
@@ -1,11 +1,32 @@
1
- import * as React from 'react';
2
- import React__default, { Ref, ReactNode, CSSProperties } from 'react';
3
- import { GridProps, GridElement } from '@vaadin/react-components/Grid.js';
1
+ import * as react from 'react';
2
+ import { Ref } from 'react';
3
+ import { GridProps, GridElement, GridDefaultItem } from '@vaadin/react-components/Grid.js';
4
4
  export { GridDataProvider as SDSGridDataProvider, GridElement as SDSGridElement } from '@vaadin/react-components/Grid.js';
5
- export { GridColumn as SDSGridColumn } from '@vaadin/react-components/GridColumn.js';
6
- export { GridFilterColumn as SDSGridFilterColumn } from '@vaadin/react-components/GridFilterColumn.js';
5
+ import { GridColumnProps, GridColumnElement } from '@vaadin/react-components/GridColumn.js';
6
+ import { GridFilterColumnProps, GridFilterColumnElement } from '@vaadin/react-components/GridFilterColumn.js';
7
+ import { GridSortColumnProps, GridSortColumnElement } from '@vaadin/react-components/GridSortColumn.js';
8
+ export { GridFilter as SDSGridFilter } from '@vaadin/react-components/GridFilter.js';
7
9
  export { GridSelectionColumn as SDSGridSelectionColumn } from '@vaadin/react-components/GridSelectionColumn.js';
8
- export { GridSortColumn as SDSGridSortColumn } from '@vaadin/react-components/GridSortColumn.js';
10
+ export { GridSorter as SDSGridSorter } from '@vaadin/react-components/GridSorter.js';
11
+
12
+ type SDSGridEditorType = 'text' | 'number' | 'checkbox' | 'select';
13
+ type SDSGridEditorOption = string | {
14
+ label: string;
15
+ value: string;
16
+ };
17
+ type SDSGridEditableColumnProps<TItem> = {
18
+ /** The cells of the column can be edited in the grid (needs `path`). A function decides row by row */
19
+ editable?: boolean | ((item: TItem) => boolean);
20
+ /** Editor shown in the cell being edited */
21
+ editorType?: SDSGridEditorType;
22
+ /** Choices of the `select` editor */
23
+ editorOptions?: SDSGridEditorOption[];
24
+ };
25
+ type SDSGridItemPropertyChange<TItem> = {
26
+ item: TItem;
27
+ path: string;
28
+ value: unknown;
29
+ };
9
30
 
10
31
  type SDSGridProps<TItem> = Omit<GridProps<TItem>, 'theme'> & {
11
32
  /** Background on every other row (Figma "Content alt") */
@@ -14,30 +35,24 @@ type SDSGridProps<TItem> = Omit<GridProps<TItem>, 'theme'> & {
14
35
  columnBorders?: boolean;
15
36
  /** No outer border nor radius */
16
37
  noBorder?: boolean;
38
+ /** Editable cells start editing on a single click (default: double-click, Enter or F2) */
39
+ editOnClick?: boolean;
40
+ /** An editable cell was changed: the item already holds the new value, save it */
41
+ onItemPropertyChanged?: (change: SDSGridItemPropertyChange<TItem>) => void;
17
42
  ref?: Ref<GridElement<TItem>>;
18
43
  };
19
- declare function SDSGrid<TItem>({ stripes, columnBorders, noBorder, className, ...props }: SDSGridProps<TItem>): React.JSX.Element;
20
-
21
- /** DOM cell renderer: no React inside the cells of the fork */
22
- type SDSGridForkBodyRenderer<TItem = unknown> = (root: HTMLElement, column: HTMLElement, model: {
23
- item: TItem;
24
- index: number;
25
- }) => void;
26
- type LooseProps = {
27
- children?: ReactNode;
28
- className?: string;
29
- style?: CSSProperties;
30
- [property: string]: unknown;
44
+ declare function SDSGrid<TItem>({ stripes, columnBorders, noBorder, editOnClick, onItemPropertyChanged, className, ref, ...props }: SDSGridProps<TItem>): react.JSX.Element;
45
+ type SDSGridColumnProps<TItem> = GridColumnProps<TItem> & SDSGridEditableColumnProps<TItem> & {
46
+ ref?: Ref<GridColumnElement<TItem>>;
31
47
  };
32
- type SDSGridForkProps = LooseProps & {
33
- stripes?: boolean;
34
- columnBorders?: boolean;
35
- noBorder?: boolean;
48
+ declare function SDSGridColumn<TItem = GridDefaultItem>(props: SDSGridColumnProps<TItem>): react.JSX.Element;
49
+ type SDSGridSortColumnProps<TItem> = GridSortColumnProps<TItem> & SDSGridEditableColumnProps<TItem> & {
50
+ ref?: Ref<GridSortColumnElement<TItem>>;
51
+ };
52
+ declare function SDSGridSortColumn<TItem = GridDefaultItem>(props: SDSGridSortColumnProps<TItem>): react.JSX.Element;
53
+ type SDSGridFilterColumnProps<TItem> = GridFilterColumnProps<TItem> & SDSGridEditableColumnProps<TItem> & {
54
+ ref?: Ref<GridFilterColumnElement<TItem>>;
36
55
  };
37
- declare function SDSGridFork({ stripes, columnBorders, noBorder, className, ...props }: SDSGridForkProps): React__default.JSX.Element;
38
- declare const SDSGridForkColumn: React__default.FC<LooseProps>;
39
- declare const SDSGridForkSortColumn: React__default.FC<LooseProps>;
40
- declare const SDSGridForkFilterColumn: React__default.FC<LooseProps>;
41
- declare const SDSGridForkSelectionColumn: React__default.FC<LooseProps>;
56
+ declare function SDSGridFilterColumn<TItem = GridDefaultItem>(props: SDSGridFilterColumnProps<TItem>): react.JSX.Element;
42
57
 
43
- export { SDSGrid, SDSGridFork, type SDSGridForkBodyRenderer, SDSGridForkColumn, SDSGridForkFilterColumn, type SDSGridForkProps, SDSGridForkSelectionColumn, SDSGridForkSortColumn, type SDSGridProps };
58
+ export { SDSGrid, SDSGridColumn, type SDSGridColumnProps, type SDSGridEditableColumnProps, type SDSGridEditorOption, type SDSGridEditorType, SDSGridFilterColumn, type SDSGridFilterColumnProps, type SDSGridItemPropertyChange, type SDSGridProps, SDSGridSortColumn, type SDSGridSortColumnProps };
package/dist/grid.d.ts CHANGED
@@ -1,11 +1,32 @@
1
- import * as React from 'react';
2
- import React__default, { Ref, ReactNode, CSSProperties } from 'react';
3
- import { GridProps, GridElement } from '@vaadin/react-components/Grid.js';
1
+ import * as react from 'react';
2
+ import { Ref } from 'react';
3
+ import { GridProps, GridElement, GridDefaultItem } from '@vaadin/react-components/Grid.js';
4
4
  export { GridDataProvider as SDSGridDataProvider, GridElement as SDSGridElement } from '@vaadin/react-components/Grid.js';
5
- export { GridColumn as SDSGridColumn } from '@vaadin/react-components/GridColumn.js';
6
- export { GridFilterColumn as SDSGridFilterColumn } from '@vaadin/react-components/GridFilterColumn.js';
5
+ import { GridColumnProps, GridColumnElement } from '@vaadin/react-components/GridColumn.js';
6
+ import { GridFilterColumnProps, GridFilterColumnElement } from '@vaadin/react-components/GridFilterColumn.js';
7
+ import { GridSortColumnProps, GridSortColumnElement } from '@vaadin/react-components/GridSortColumn.js';
8
+ export { GridFilter as SDSGridFilter } from '@vaadin/react-components/GridFilter.js';
7
9
  export { GridSelectionColumn as SDSGridSelectionColumn } from '@vaadin/react-components/GridSelectionColumn.js';
8
- export { GridSortColumn as SDSGridSortColumn } from '@vaadin/react-components/GridSortColumn.js';
10
+ export { GridSorter as SDSGridSorter } from '@vaadin/react-components/GridSorter.js';
11
+
12
+ type SDSGridEditorType = 'text' | 'number' | 'checkbox' | 'select';
13
+ type SDSGridEditorOption = string | {
14
+ label: string;
15
+ value: string;
16
+ };
17
+ type SDSGridEditableColumnProps<TItem> = {
18
+ /** The cells of the column can be edited in the grid (needs `path`). A function decides row by row */
19
+ editable?: boolean | ((item: TItem) => boolean);
20
+ /** Editor shown in the cell being edited */
21
+ editorType?: SDSGridEditorType;
22
+ /** Choices of the `select` editor */
23
+ editorOptions?: SDSGridEditorOption[];
24
+ };
25
+ type SDSGridItemPropertyChange<TItem> = {
26
+ item: TItem;
27
+ path: string;
28
+ value: unknown;
29
+ };
9
30
 
10
31
  type SDSGridProps<TItem> = Omit<GridProps<TItem>, 'theme'> & {
11
32
  /** Background on every other row (Figma "Content alt") */
@@ -14,30 +35,24 @@ type SDSGridProps<TItem> = Omit<GridProps<TItem>, 'theme'> & {
14
35
  columnBorders?: boolean;
15
36
  /** No outer border nor radius */
16
37
  noBorder?: boolean;
38
+ /** Editable cells start editing on a single click (default: double-click, Enter or F2) */
39
+ editOnClick?: boolean;
40
+ /** An editable cell was changed: the item already holds the new value, save it */
41
+ onItemPropertyChanged?: (change: SDSGridItemPropertyChange<TItem>) => void;
17
42
  ref?: Ref<GridElement<TItem>>;
18
43
  };
19
- declare function SDSGrid<TItem>({ stripes, columnBorders, noBorder, className, ...props }: SDSGridProps<TItem>): React.JSX.Element;
20
-
21
- /** DOM cell renderer: no React inside the cells of the fork */
22
- type SDSGridForkBodyRenderer<TItem = unknown> = (root: HTMLElement, column: HTMLElement, model: {
23
- item: TItem;
24
- index: number;
25
- }) => void;
26
- type LooseProps = {
27
- children?: ReactNode;
28
- className?: string;
29
- style?: CSSProperties;
30
- [property: string]: unknown;
44
+ declare function SDSGrid<TItem>({ stripes, columnBorders, noBorder, editOnClick, onItemPropertyChanged, className, ref, ...props }: SDSGridProps<TItem>): react.JSX.Element;
45
+ type SDSGridColumnProps<TItem> = GridColumnProps<TItem> & SDSGridEditableColumnProps<TItem> & {
46
+ ref?: Ref<GridColumnElement<TItem>>;
31
47
  };
32
- type SDSGridForkProps = LooseProps & {
33
- stripes?: boolean;
34
- columnBorders?: boolean;
35
- noBorder?: boolean;
48
+ declare function SDSGridColumn<TItem = GridDefaultItem>(props: SDSGridColumnProps<TItem>): react.JSX.Element;
49
+ type SDSGridSortColumnProps<TItem> = GridSortColumnProps<TItem> & SDSGridEditableColumnProps<TItem> & {
50
+ ref?: Ref<GridSortColumnElement<TItem>>;
51
+ };
52
+ declare function SDSGridSortColumn<TItem = GridDefaultItem>(props: SDSGridSortColumnProps<TItem>): react.JSX.Element;
53
+ type SDSGridFilterColumnProps<TItem> = GridFilterColumnProps<TItem> & SDSGridEditableColumnProps<TItem> & {
54
+ ref?: Ref<GridFilterColumnElement<TItem>>;
36
55
  };
37
- declare function SDSGridFork({ stripes, columnBorders, noBorder, className, ...props }: SDSGridForkProps): React__default.JSX.Element;
38
- declare const SDSGridForkColumn: React__default.FC<LooseProps>;
39
- declare const SDSGridForkSortColumn: React__default.FC<LooseProps>;
40
- declare const SDSGridForkFilterColumn: React__default.FC<LooseProps>;
41
- declare const SDSGridForkSelectionColumn: React__default.FC<LooseProps>;
56
+ declare function SDSGridFilterColumn<TItem = GridDefaultItem>(props: SDSGridFilterColumnProps<TItem>): react.JSX.Element;
42
57
 
43
- export { SDSGrid, SDSGridFork, type SDSGridForkBodyRenderer, SDSGridForkColumn, SDSGridForkFilterColumn, type SDSGridForkProps, SDSGridForkSelectionColumn, SDSGridForkSortColumn, type SDSGridProps };
58
+ export { SDSGrid, SDSGridColumn, type SDSGridColumnProps, type SDSGridEditableColumnProps, type SDSGridEditorOption, type SDSGridEditorType, SDSGridFilterColumn, type SDSGridFilterColumnProps, type SDSGridItemPropertyChange, type SDSGridProps, SDSGridSortColumn, type SDSGridSortColumnProps };