@procore/saved-views 5.0.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 +90 -0
- package/dist/legacy/index.d.mts +150 -0
- package/dist/legacy/index.d.ts +150 -0
- package/dist/legacy/index.js +14804 -0
- package/dist/legacy/index.mjs +14843 -0
- package/dist/modern/index.d.mts +150 -0
- package/dist/modern/index.d.ts +150 -0
- package/dist/modern/index.js +14799 -0
- package/dist/modern/index.mjs +14838 -0
- package/package.json +121 -0
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# @procore/saved-views
|
|
2
|
+
|
|
3
|
+
> [!WARNING]
|
|
4
|
+
> It's an initial version of this package (0.0.0) intended to demo the Saved Views capabilities. The design and API integration aren't finished yet, so please don't use it on production.
|
|
5
|
+
> The final design and API integration are going to be delivered with next version (0.0.1) soon.
|
|
6
|
+
|
|
7
|
+
Saved Views Component for integration with @procore/data-table and @procore/smart-grid-core
|
|
8
|
+
|
|
9
|
+
**✨ Latest Updates:**
|
|
10
|
+
|
|
11
|
+
- Upgraded to @tanstack/react-query v5.83.0 (latest) for better performance and modern API and made it a direct dependecy to not force our consumers
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
### In a web application, micro frontend or hydra client
|
|
16
|
+
|
|
17
|
+
```shell script
|
|
18
|
+
yarn add @procore/saved-views
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**NOTE:** Ensure that the following peer dependencies for `@procore/saved-views` are also installed:
|
|
22
|
+
|
|
23
|
+
- `@procore/core-react`: `>=11.4.0 <13`
|
|
24
|
+
- `@procore/toast-alert`: `>=5.1.0`
|
|
25
|
+
- `react`: `>=16.8`
|
|
26
|
+
- `styled-components`: `^5.3.0`
|
|
27
|
+
|
|
28
|
+
### In a npm package or library
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
yarn add -P @procore/saved-views^1.0.0 # adds the package as a peer dependency
|
|
32
|
+
yarn add -D @procore/saved-views # adds as a dev dependency, for tests, storybook, etc.
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**NOTE:** Ensure that the following peer dependencies for `@procore/saved-views` are also installed _as peer dependencies_ and as dev dependencies (for tests, storybook, etc.):
|
|
36
|
+
|
|
37
|
+
- `@procore/core-react`: `^12`
|
|
38
|
+
- `react`: `>=16.8`
|
|
39
|
+
- `styled-components`: `^5.3.0`
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
import { useSavedViews } from '@procore/saved-views';
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```jsx
|
|
48
|
+
const { SavedViews } = useSavedViews(
|
|
49
|
+
onSelect,
|
|
50
|
+
onEdit,
|
|
51
|
+
onDelete,
|
|
52
|
+
onCreate,
|
|
53
|
+
onUpdate,
|
|
54
|
+
AllItemsOptionFlag,
|
|
55
|
+
savedViewsGroups
|
|
56
|
+
:
|
|
57
|
+
savedGroups,
|
|
58
|
+
isAdmin
|
|
59
|
+
:
|
|
60
|
+
true,
|
|
61
|
+
currentFilters,
|
|
62
|
+
currentColumnState,
|
|
63
|
+
onTableConfigChange,
|
|
64
|
+
tableConfig,
|
|
65
|
+
tableApi,
|
|
66
|
+
currentRowHeight,
|
|
67
|
+
stickyViewsKey
|
|
68
|
+
:
|
|
69
|
+
'currentSavedView'
|
|
70
|
+
)
|
|
71
|
+
;
|
|
72
|
+
|
|
73
|
+
<SavedViews />
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Development
|
|
77
|
+
|
|
78
|
+
This project uses [`yarn`][yarn], and supports the following commands:
|
|
79
|
+
|
|
80
|
+
- `build`: builds and bundles the project.
|
|
81
|
+
- `format`: runs [`prettier`][prettier] on the project.
|
|
82
|
+
- `format:check`: validates that the source code conforms to the [`prettier`][prettier] configuration.
|
|
83
|
+
- `lint`: lints the source code.
|
|
84
|
+
- `storybook`: starts up the storybook development server on port 6006.
|
|
85
|
+
- `build-storybook`: generates a static version of the storybook.
|
|
86
|
+
- `test`: runs the unit test suite.
|
|
87
|
+
- `test:dev`: run the unit test suite in watch mode.
|
|
88
|
+
|
|
89
|
+
[prettier]: https://prettier.io/
|
|
90
|
+
[yarn]: https://classic.yarnpkg.com/
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { Locale, MapLocalesToTranslations } from '@procore/globalization-toolkit';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import React__default from 'react';
|
|
4
|
+
import { DataTableConfig, TableApi, ColumnDefinition } from '@procore/data-table';
|
|
5
|
+
import { ColumnState, Column, FilterModel, GridApi } from 'ag-grid-community';
|
|
6
|
+
import * as styled_components from 'styled-components';
|
|
7
|
+
|
|
8
|
+
declare function getTranslations(envLocale: Locale): Partial<MapLocalesToTranslations>;
|
|
9
|
+
|
|
10
|
+
declare const useSavedViewsPanel: (domain: string, tableName: string) => {
|
|
11
|
+
isOpen: boolean;
|
|
12
|
+
SavedViewsButton: () => React__default.JSX.Element;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
interface IQueryInputProps {
|
|
16
|
+
domain: string;
|
|
17
|
+
tableName: string;
|
|
18
|
+
enableSavedViews: boolean;
|
|
19
|
+
projectId?: number;
|
|
20
|
+
companyId?: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface ISmartGridConfig {
|
|
24
|
+
columnState: ColumnState[];
|
|
25
|
+
columnGroupState: {
|
|
26
|
+
groupId: string;
|
|
27
|
+
open: boolean;
|
|
28
|
+
}[];
|
|
29
|
+
rowGroupState: Column[];
|
|
30
|
+
rowHeight: number | undefined;
|
|
31
|
+
filterState: FilterModel;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare const VIEW_LEVELS: readonly ["company", "project", "personal"];
|
|
35
|
+
type ViewLevel = (typeof VIEW_LEVELS)[number];
|
|
36
|
+
|
|
37
|
+
interface ISavedView {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
table_config?: DataTableConfig | ISmartGridConfig;
|
|
42
|
+
view_level: ViewLevel | 'default';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type TableProvider = 'smart-grid' | 'data-table';
|
|
46
|
+
|
|
47
|
+
interface IBaseSavedViewsProps {
|
|
48
|
+
tableName: string;
|
|
49
|
+
domain: string;
|
|
50
|
+
stickyViewsKey: string;
|
|
51
|
+
enableSavedViews: boolean;
|
|
52
|
+
userId: number;
|
|
53
|
+
projectId: number;
|
|
54
|
+
companyId: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface IDataTableSavedViewsExternalConsumerProps extends IBaseSavedViewsProps {
|
|
58
|
+
tableApi: TableApi;
|
|
59
|
+
onTableConfigChange: (config: DataTableConfig) => void;
|
|
60
|
+
defaultViewName?: string;
|
|
61
|
+
defaultViewConfig?: DataTableConfig;
|
|
62
|
+
columnDefinitions: ColumnDefinition[];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface ISmartGridSavedViewsExternalConsumerProps extends IBaseSavedViewsProps {
|
|
66
|
+
gridApi: GridApi;
|
|
67
|
+
defaultViewName?: string;
|
|
68
|
+
defaultViewFilters: FilterModel | null;
|
|
69
|
+
defaultRowHeight: number;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
interface IPermissions {
|
|
73
|
+
can_create_project_saved_views: boolean;
|
|
74
|
+
can_create_company_saved_views: boolean;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
type SavedViewCollectionMenuItemProps = {
|
|
78
|
+
item: ISavedView;
|
|
79
|
+
key?: string;
|
|
80
|
+
selected: boolean;
|
|
81
|
+
canUpdate?: boolean;
|
|
82
|
+
canEditOrDelete?: boolean;
|
|
83
|
+
onUpdate?: (data: ISavedView) => void;
|
|
84
|
+
onDelete?: (data: {
|
|
85
|
+
savedView: ISavedView;
|
|
86
|
+
}) => void;
|
|
87
|
+
onEdit?: (data: {
|
|
88
|
+
savedView: ISavedView;
|
|
89
|
+
}) => void;
|
|
90
|
+
isUpdateProcessing?: boolean;
|
|
91
|
+
permissions?: IPermissions;
|
|
92
|
+
};
|
|
93
|
+
declare const SavedViewCollectionMenuItem: (props: SavedViewCollectionMenuItemProps) => React.JSX.Element;
|
|
94
|
+
|
|
95
|
+
declare const ExpandedPanel: styled_components.StyledComponent<any, any, any, any>;
|
|
96
|
+
|
|
97
|
+
declare enum ModalType {
|
|
98
|
+
CREATE = "create",
|
|
99
|
+
UPDATE = "update"
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
type PanelContentProps = {
|
|
103
|
+
openModal: (type: ModalType) => void;
|
|
104
|
+
onDelete: () => void;
|
|
105
|
+
onSelect: (data: {
|
|
106
|
+
item: ISavedView;
|
|
107
|
+
}) => void;
|
|
108
|
+
updateLocalStorage: (data: ISavedView) => void;
|
|
109
|
+
setSelectedSavedView: (data: ISavedView) => void;
|
|
110
|
+
queryInput: IQueryInputProps;
|
|
111
|
+
selectedSavedView: ISavedView | undefined;
|
|
112
|
+
tableConfig: DataTableConfig | ISmartGridConfig;
|
|
113
|
+
provider: TableProvider;
|
|
114
|
+
defaultView: ISavedView;
|
|
115
|
+
stickyViewsKey: string;
|
|
116
|
+
userId: number;
|
|
117
|
+
};
|
|
118
|
+
declare const PanelContent: (props: PanelContentProps) => React__default.JSX.Element;
|
|
119
|
+
|
|
120
|
+
declare const SmartGridSavedViews: (props: ISmartGridSavedViewsExternalConsumerProps) => React__default.JSX.Element;
|
|
121
|
+
|
|
122
|
+
interface IDataTableSavedViewsRef {
|
|
123
|
+
setTableConfig: (config: DataTableConfig) => void;
|
|
124
|
+
}
|
|
125
|
+
declare const DataTableSavedViews: React__default.ForwardRefExoticComponent<IDataTableSavedViewsExternalConsumerProps & React__default.RefAttributes<IDataTableSavedViewsRef>>;
|
|
126
|
+
|
|
127
|
+
type Props = {
|
|
128
|
+
onDelete(): void;
|
|
129
|
+
onCancel(): void;
|
|
130
|
+
open: boolean;
|
|
131
|
+
};
|
|
132
|
+
declare const SavedViewsDeleteConfirmationModalShared: React__default.FC<Props>;
|
|
133
|
+
|
|
134
|
+
type SavedViewsFormModalProps = {
|
|
135
|
+
open: boolean;
|
|
136
|
+
mode: ModalType;
|
|
137
|
+
isLoading?: boolean;
|
|
138
|
+
onCancel(): void;
|
|
139
|
+
queryInput: IQueryInputProps;
|
|
140
|
+
tableConfig: DataTableConfig | ISmartGridConfig;
|
|
141
|
+
tableName: string;
|
|
142
|
+
selectedSavedView: ISavedView | undefined;
|
|
143
|
+
setSelectedSavedView: (data: ISavedView) => void;
|
|
144
|
+
onSelect: (item: ISavedView) => void;
|
|
145
|
+
setOpenEditCreateModal: (open: boolean) => void;
|
|
146
|
+
defaultView: ISavedView;
|
|
147
|
+
};
|
|
148
|
+
declare const SavedViewsFormModal: React__default.FC<SavedViewsFormModalProps>;
|
|
149
|
+
|
|
150
|
+
export { DataTableSavedViews, ExpandedPanel, type IDataTableSavedViewsRef, PanelContent, type PanelContentProps, SavedViewCollectionMenuItem, SavedViewsDeleteConfirmationModalShared, SavedViewsFormModal, SmartGridSavedViews, getTranslations, useSavedViewsPanel };
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { Locale, MapLocalesToTranslations } from '@procore/globalization-toolkit';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import React__default from 'react';
|
|
4
|
+
import { DataTableConfig, TableApi, ColumnDefinition } from '@procore/data-table';
|
|
5
|
+
import { ColumnState, Column, FilterModel, GridApi } from 'ag-grid-community';
|
|
6
|
+
import * as styled_components from 'styled-components';
|
|
7
|
+
|
|
8
|
+
declare function getTranslations(envLocale: Locale): Partial<MapLocalesToTranslations>;
|
|
9
|
+
|
|
10
|
+
declare const useSavedViewsPanel: (domain: string, tableName: string) => {
|
|
11
|
+
isOpen: boolean;
|
|
12
|
+
SavedViewsButton: () => React__default.JSX.Element;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
interface IQueryInputProps {
|
|
16
|
+
domain: string;
|
|
17
|
+
tableName: string;
|
|
18
|
+
enableSavedViews: boolean;
|
|
19
|
+
projectId?: number;
|
|
20
|
+
companyId?: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface ISmartGridConfig {
|
|
24
|
+
columnState: ColumnState[];
|
|
25
|
+
columnGroupState: {
|
|
26
|
+
groupId: string;
|
|
27
|
+
open: boolean;
|
|
28
|
+
}[];
|
|
29
|
+
rowGroupState: Column[];
|
|
30
|
+
rowHeight: number | undefined;
|
|
31
|
+
filterState: FilterModel;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare const VIEW_LEVELS: readonly ["company", "project", "personal"];
|
|
35
|
+
type ViewLevel = (typeof VIEW_LEVELS)[number];
|
|
36
|
+
|
|
37
|
+
interface ISavedView {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
table_config?: DataTableConfig | ISmartGridConfig;
|
|
42
|
+
view_level: ViewLevel | 'default';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type TableProvider = 'smart-grid' | 'data-table';
|
|
46
|
+
|
|
47
|
+
interface IBaseSavedViewsProps {
|
|
48
|
+
tableName: string;
|
|
49
|
+
domain: string;
|
|
50
|
+
stickyViewsKey: string;
|
|
51
|
+
enableSavedViews: boolean;
|
|
52
|
+
userId: number;
|
|
53
|
+
projectId: number;
|
|
54
|
+
companyId: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface IDataTableSavedViewsExternalConsumerProps extends IBaseSavedViewsProps {
|
|
58
|
+
tableApi: TableApi;
|
|
59
|
+
onTableConfigChange: (config: DataTableConfig) => void;
|
|
60
|
+
defaultViewName?: string;
|
|
61
|
+
defaultViewConfig?: DataTableConfig;
|
|
62
|
+
columnDefinitions: ColumnDefinition[];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface ISmartGridSavedViewsExternalConsumerProps extends IBaseSavedViewsProps {
|
|
66
|
+
gridApi: GridApi;
|
|
67
|
+
defaultViewName?: string;
|
|
68
|
+
defaultViewFilters: FilterModel | null;
|
|
69
|
+
defaultRowHeight: number;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
interface IPermissions {
|
|
73
|
+
can_create_project_saved_views: boolean;
|
|
74
|
+
can_create_company_saved_views: boolean;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
type SavedViewCollectionMenuItemProps = {
|
|
78
|
+
item: ISavedView;
|
|
79
|
+
key?: string;
|
|
80
|
+
selected: boolean;
|
|
81
|
+
canUpdate?: boolean;
|
|
82
|
+
canEditOrDelete?: boolean;
|
|
83
|
+
onUpdate?: (data: ISavedView) => void;
|
|
84
|
+
onDelete?: (data: {
|
|
85
|
+
savedView: ISavedView;
|
|
86
|
+
}) => void;
|
|
87
|
+
onEdit?: (data: {
|
|
88
|
+
savedView: ISavedView;
|
|
89
|
+
}) => void;
|
|
90
|
+
isUpdateProcessing?: boolean;
|
|
91
|
+
permissions?: IPermissions;
|
|
92
|
+
};
|
|
93
|
+
declare const SavedViewCollectionMenuItem: (props: SavedViewCollectionMenuItemProps) => React.JSX.Element;
|
|
94
|
+
|
|
95
|
+
declare const ExpandedPanel: styled_components.StyledComponent<any, any, any, any>;
|
|
96
|
+
|
|
97
|
+
declare enum ModalType {
|
|
98
|
+
CREATE = "create",
|
|
99
|
+
UPDATE = "update"
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
type PanelContentProps = {
|
|
103
|
+
openModal: (type: ModalType) => void;
|
|
104
|
+
onDelete: () => void;
|
|
105
|
+
onSelect: (data: {
|
|
106
|
+
item: ISavedView;
|
|
107
|
+
}) => void;
|
|
108
|
+
updateLocalStorage: (data: ISavedView) => void;
|
|
109
|
+
setSelectedSavedView: (data: ISavedView) => void;
|
|
110
|
+
queryInput: IQueryInputProps;
|
|
111
|
+
selectedSavedView: ISavedView | undefined;
|
|
112
|
+
tableConfig: DataTableConfig | ISmartGridConfig;
|
|
113
|
+
provider: TableProvider;
|
|
114
|
+
defaultView: ISavedView;
|
|
115
|
+
stickyViewsKey: string;
|
|
116
|
+
userId: number;
|
|
117
|
+
};
|
|
118
|
+
declare const PanelContent: (props: PanelContentProps) => React__default.JSX.Element;
|
|
119
|
+
|
|
120
|
+
declare const SmartGridSavedViews: (props: ISmartGridSavedViewsExternalConsumerProps) => React__default.JSX.Element;
|
|
121
|
+
|
|
122
|
+
interface IDataTableSavedViewsRef {
|
|
123
|
+
setTableConfig: (config: DataTableConfig) => void;
|
|
124
|
+
}
|
|
125
|
+
declare const DataTableSavedViews: React__default.ForwardRefExoticComponent<IDataTableSavedViewsExternalConsumerProps & React__default.RefAttributes<IDataTableSavedViewsRef>>;
|
|
126
|
+
|
|
127
|
+
type Props = {
|
|
128
|
+
onDelete(): void;
|
|
129
|
+
onCancel(): void;
|
|
130
|
+
open: boolean;
|
|
131
|
+
};
|
|
132
|
+
declare const SavedViewsDeleteConfirmationModalShared: React__default.FC<Props>;
|
|
133
|
+
|
|
134
|
+
type SavedViewsFormModalProps = {
|
|
135
|
+
open: boolean;
|
|
136
|
+
mode: ModalType;
|
|
137
|
+
isLoading?: boolean;
|
|
138
|
+
onCancel(): void;
|
|
139
|
+
queryInput: IQueryInputProps;
|
|
140
|
+
tableConfig: DataTableConfig | ISmartGridConfig;
|
|
141
|
+
tableName: string;
|
|
142
|
+
selectedSavedView: ISavedView | undefined;
|
|
143
|
+
setSelectedSavedView: (data: ISavedView) => void;
|
|
144
|
+
onSelect: (item: ISavedView) => void;
|
|
145
|
+
setOpenEditCreateModal: (open: boolean) => void;
|
|
146
|
+
defaultView: ISavedView;
|
|
147
|
+
};
|
|
148
|
+
declare const SavedViewsFormModal: React__default.FC<SavedViewsFormModalProps>;
|
|
149
|
+
|
|
150
|
+
export { DataTableSavedViews, ExpandedPanel, type IDataTableSavedViewsRef, PanelContent, type PanelContentProps, SavedViewCollectionMenuItem, SavedViewsDeleteConfirmationModalShared, SavedViewsFormModal, SmartGridSavedViews, getTranslations, useSavedViewsPanel };
|