@ceed/ads 0.0.179-2 → 0.1.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.
@@ -7,33 +7,26 @@ import Input from "../Input";
7
7
  import Textarea from "../Textarea";
8
8
  import Autocomplete from "../Autocomplete";
9
9
  import Select from "../Select";
10
- type IndexType = keyof any;
11
- export type ClassOrRecord<V = any> = Record<IndexType, V> | {
12
- [key: IndexType]: V;
10
+ export type ClassOrRecord<V = any> = Record<PropertyKey, V> | {
11
+ [key: PropertyKey]: V;
13
12
  };
14
- export type RenderCellHandler<T extends ClassOrRecord, V = any> = (params: {
13
+ type Handler<T extends ClassOrRecord, V = any, R = any> = (params: {
15
14
  row: T;
16
15
  value?: V;
17
- id: IndexType;
18
- }) => ReactNode;
19
- export type CellEditableHandler<T extends ClassOrRecord, V = any> = (params: {
20
- row: T;
21
- value?: V;
22
- id: IndexType;
23
- }) => boolean;
24
- export type CellEditStartEvent<T extends ClassOrRecord, V = any> = (params: {
25
- originalRow: T;
26
- row: T;
27
- value?: V;
28
- id: IndexType;
29
- }) => void;
30
- export type CellEditStopEvent<T extends ClassOrRecord, V = any> = (params: {
16
+ id: PropertyKey;
17
+ }) => R;
18
+ type EventHandler<T extends ClassOrRecord, V = any> = (params: {
31
19
  originalRow: T;
32
20
  row: T;
33
21
  value?: V;
34
- id: IndexType;
22
+ id: PropertyKey;
35
23
  }) => void;
36
- export type BaseColumnDef<T extends Record<IndexType, V>, V> = {
24
+ type ComponentProperties<C extends React.ElementType, T extends ClassOrRecord, V = any> = ComponentProps<C> | Handler<T, V, ComponentProps<C>>;
25
+ export type RenderCellHandler<T extends ClassOrRecord, V = any> = Handler<T, V, ReactNode>;
26
+ export type CellEditableHandler<T extends ClassOrRecord, V = any> = Handler<T, V, boolean>;
27
+ export type CellEditStartEvent<T extends ClassOrRecord, V = any> = EventHandler<T, V>;
28
+ export type CellEditStopEvent<T extends ClassOrRecord, V = any> = EventHandler<T, V>;
29
+ export type BaseColumnDef<T extends Record<PropertyKey, V>, V> = {
37
30
  field: keyof T;
38
31
  headerName?: string;
39
32
  width?: string;
@@ -46,73 +39,41 @@ export type BaseColumnDef<T extends Record<IndexType, V>, V> = {
46
39
  onCellEditStart?: CellEditStartEvent<T, V>;
47
40
  onCellEditStop?: CellEditStopEvent<T, V>;
48
41
  };
49
- export type AutocompleteColumnDef<T extends Record<IndexType, string>> = BaseColumnDef<T, string> & {
42
+ export type AutocompleteColumnDef<T extends Record<PropertyKey, string>> = BaseColumnDef<T, string> & {
50
43
  type: "autocomplete";
51
- componentProps?: ComponentProps<typeof Autocomplete> | ((params: {
52
- row: T;
53
- value?: string;
54
- id: string;
55
- }) => ComponentProps<typeof Autocomplete>);
44
+ componentProps?: ComponentProperties<typeof Autocomplete, T, string>;
56
45
  };
57
- export type CurrencyColumnDef<T extends Record<IndexType, number>> = BaseColumnDef<T, number> & {
46
+ export type CurrencyColumnDef<T extends Record<PropertyKey, number>> = BaseColumnDef<T, number> & {
58
47
  type: "currency";
59
- componentProps?: ComponentProps<typeof CurrencyInput> | ((params: {
60
- row: T;
61
- value?: number;
62
- id: string;
63
- }) => ComponentProps<typeof CurrencyInput>);
48
+ componentProps?: ComponentProperties<typeof CurrencyInput, T, number>;
64
49
  };
65
- export type DateColumnDef<T extends Record<IndexType, string>> = BaseColumnDef<T, string> & {
50
+ export type DateColumnDef<T extends Record<PropertyKey, string>> = BaseColumnDef<T, string> & {
66
51
  type: "date";
67
- componentProps?: ComponentProps<typeof DatePicker> | ((params: {
68
- row: T;
69
- value?: string;
70
- id: string;
71
- }) => ComponentProps<typeof DatePicker>);
52
+ componentProps?: ComponentProperties<typeof DatePicker, T, string>;
72
53
  };
73
- export type NumberColumnDef<T extends Record<IndexType, number>> = BaseColumnDef<T, number> & {
54
+ export type NumberColumnDef<T extends Record<PropertyKey, number>> = BaseColumnDef<T, number> & {
74
55
  type: "number";
75
- componentProps?: ComponentProps<typeof Input> | ((params: {
76
- row: T;
77
- value?: number;
78
- id: string;
79
- }) => ComponentProps<typeof Input>);
56
+ componentProps?: ComponentProperties<typeof Input, T, number>;
80
57
  };
81
- export type TextColumnDef<T extends Record<IndexType, string>> = BaseColumnDef<T, string> & {
58
+ export type TextColumnDef<T extends Record<PropertyKey, string>> = BaseColumnDef<T, string> & {
82
59
  type?: "text";
83
- componentProps?: ComponentProps<typeof Input> | ((params: {
84
- row: T;
85
- value?: string;
86
- id: string;
87
- }) => ComponentProps<typeof Input>);
60
+ componentProps?: ComponentProperties<typeof Input, T, string>;
88
61
  };
89
- export type LongTextColumnDef<T extends Record<IndexType, string>> = BaseColumnDef<T, string> & {
62
+ export type LongTextColumnDef<T extends Record<PropertyKey, string>> = BaseColumnDef<T, string> & {
90
63
  type: "longText";
91
- componentProps?: ComponentProps<typeof Textarea> | ((params: {
92
- row: T;
93
- value?: string;
94
- id: string;
95
- }) => ComponentProps<typeof Textarea>);
64
+ componentProps?: ComponentProperties<typeof Textarea, T, string>;
96
65
  };
97
- export type SelectColumnDef<T extends Record<IndexType, string>> = BaseColumnDef<T, string> & {
66
+ export type SelectColumnDef<T extends Record<PropertyKey, string>> = BaseColumnDef<T, string> & {
98
67
  type: "select";
99
- componentProps?: ComponentProps<typeof Select<string, false>> | ((params: {
100
- row: T;
101
- value?: string;
102
- id: string;
103
- }) => ComponentProps<typeof Select<string, false>>);
68
+ componentProps?: ComponentProperties<typeof Select<string, false>, T, string>;
104
69
  };
105
- export type LinkColumnDef<T extends Record<IndexType, string>, C extends React.ElementType = typeof Link> = BaseColumnDef<T, string> & {
70
+ export type LinkColumnDef<T extends Record<PropertyKey, string>, C extends React.ElementType = typeof Link> = BaseColumnDef<T, string> & {
106
71
  type: "link";
107
72
  component?: C;
108
- componentProps?: ComponentProps<C> | ((params: {
109
- row: T;
110
- value?: string;
111
- id: string;
112
- }) => ComponentProps<C>);
73
+ componentProps?: ComponentProperties<C, T, string>;
113
74
  };
114
- export type ColumnDef<T extends Record<IndexType, any>> = AutocompleteColumnDef<T> | CurrencyColumnDef<T> | DateColumnDef<T> | NumberColumnDef<T> | TextColumnDef<T> | LongTextColumnDef<T> | LinkColumnDef<T> | SelectColumnDef<T>;
115
- export type DataTableProps<T extends Record<IndexType, any>> = {
75
+ export type ColumnDef<T extends Record<PropertyKey, any>> = AutocompleteColumnDef<T> | CurrencyColumnDef<T> | DateColumnDef<T> | NumberColumnDef<T> | TextColumnDef<T> | LongTextColumnDef<T> | LinkColumnDef<T> | SelectColumnDef<T>;
76
+ export type DataTableProps<T extends Record<PropertyKey, any>> = {
116
77
  rows: T[];
117
78
  checkboxSelection?: boolean;
118
79
  columns: ColumnDef<T>[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ceed/ads",
3
- "version": "0.0.179-2",
3
+ "version": "0.1.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -71,6 +71,5 @@
71
71
  "type": "git",
72
72
  "url": "git+ssh://git@github.com/Ecube-Labs/hds.git"
73
73
  },
74
- "packageManager": "yarn@4.1.0",
75
- "stableVersion": "0.0.178"
74
+ "packageManager": "yarn@4.1.0"
76
75
  }