@genesislcap/pbc-documents-ui 0.0.1 → 0.0.2

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 (29) hide show
  1. package/package.json +3 -3
  2. package/src/components/components.ts +0 -49
  3. package/src/components/foundation-document-manager/component/document-grid/column-config.ts +0 -108
  4. package/src/components/foundation-document-manager/component/document-grid/document-grid.styles.ts +0 -10
  5. package/src/components/foundation-document-manager/component/document-grid/document-grid.template.ts +0 -14
  6. package/src/components/foundation-document-manager/component/document-grid/document-grid.ts +0 -39
  7. package/src/components/foundation-document-manager/component/document-tile/document-tile.styles.ts +0 -137
  8. package/src/components/foundation-document-manager/component/document-tile/document-tile.template.ts +0 -71
  9. package/src/components/foundation-document-manager/component/document-tile/document-tile.ts +0 -119
  10. package/src/components/foundation-document-manager/component/document-upload/document-upload.styles.ts +0 -157
  11. package/src/components/foundation-document-manager/component/document-upload/document-upload.template.ts +0 -82
  12. package/src/components/foundation-document-manager/component/document-upload/document-upload.ts +0 -146
  13. package/src/components/foundation-document-manager/document-manager.styles.ts +0 -245
  14. package/src/components/foundation-document-manager/document-manager.template.ts +0 -111
  15. package/src/components/foundation-document-manager/document-manager.ts +0 -128
  16. package/src/components/foundation-document-manager/index.ts +0 -1
  17. package/src/components/foundation-document-manager/utils/action-cell-renderer.ts +0 -55
  18. package/src/components/foundation-document-manager/utils/file-type-cell-renderer.ts +0 -33
  19. package/src/components/foundation-document-manager/utils/icons.ts +0 -251
  20. package/src/components/index.ts +0 -1
  21. package/src/index.federated.ts +0 -1
  22. package/src/index.ts +0 -3
  23. package/src/services/document.service.ts +0 -83
  24. package/src/utils/dataserver.ts +0 -42
  25. package/src/utils/endpoint.ts +0 -19
  26. package/src/utils/formatting.ts +0 -59
  27. package/src/utils/index.ts +0 -1
  28. package/src/utils/logger.ts +0 -2
  29. package/src/utils/types.ts +0 -11
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@genesislcap/pbc-documents-ui",
3
3
  "description": "Genesis Document Management UI",
4
- "version": "0.0.1",
4
+ "version": "0.0.2",
5
5
  "private": false,
6
6
  "license": "SEE LICENSE IN license.txt",
7
- "main": "src/index.ts",
7
+ "main": "dist/esm/index.js",
8
8
  "types": "dist/foundation-file-server.d.ts",
9
9
  "engines": {
10
10
  "node": ">=20.0.0"
@@ -15,7 +15,7 @@
15
15
  "exports": {
16
16
  ".": {
17
17
  "types": "./dist/foundation-file-server.d.ts",
18
- "default": "./src/index.ts"
18
+ "default": "./dist/esm/index.js"
19
19
  },
20
20
  "./e2e": {
21
21
  "default": "./test/e2e/index.ts"
@@ -1,49 +0,0 @@
1
- import { logger } from '../utils';
2
- import { foundationLayoutComponents } from '@genesislcap/foundation-layout';
3
- import { FoundationDocumentManager } from './foundation-document-manager/document-manager';
4
- import { zeroDesignSystemProvider } from '@genesislcap/foundation-zero';
5
- import { zeroGridComponents, zeroGridPro } from '@genesislcap/foundation-zero-grid-pro';
6
- import { allComponents, provideFASTDesignSystem } from '@microsoft/fast-components';
7
-
8
- // Components
9
- FoundationDocumentManager;
10
-
11
- enum ResourceType {
12
- LOCAL = 'LOCAL',
13
- REMOTE = 'REMOTE',
14
- }
15
-
16
- // TODO: Think about sharing import functions across micro frontends.
17
- function loadZeroFallback() {
18
- return import(
19
- /* webpackMode: "lazy" */
20
- '@genesislcap/foundation-zero'
21
- );
22
- }
23
-
24
- // Granular
25
- async function loadZeroDesignSystem() {
26
- let type = ResourceType.REMOTE;
27
- try {
28
- // @ts-ignore
29
- return await import('foundationZero/ZeroDesignSystem');
30
- } catch (e) {
31
- type = ResourceType.LOCAL;
32
- return await loadZeroFallback();
33
- } finally {
34
- logger.debug(`Using '${type}' version of foundationZero/ZeroDesignSystem`);
35
- }
36
- }
37
-
38
- export async function loadRemotes() {
39
- const { registerZeroDesignSystem, provideDesignSystem } = await loadZeroDesignSystem();
40
-
41
- return {
42
- ZeroDesignSystem: {
43
- ...registerZeroDesignSystem(),
44
- ...provideDesignSystem().register(foundationLayoutComponents),
45
- },
46
- };
47
- }
48
-
49
- provideFASTDesignSystem().register(allComponents, zeroGridComponents, zeroDesignSystemProvider());
@@ -1,108 +0,0 @@
1
- import { GridProRendererTypes, getActionsMenuDef } from '@genesislcap/grid-pro';
2
- import { formatBytes, formatDateLong, getFileType } from '../../../../utils/formatting';
3
- import { FileTypeCellRenderer } from '../../utils/file-type-cell-renderer';
4
- import { ActionCellRenderer } from '../../utils/action-cell-renderer';
5
- import { DocumentGrid } from './document-grid';
6
- import { downloadIcon, optionsIcon } from '../../utils/icons';
7
-
8
- export enum COLUMN_FIELDS {
9
- FILE_STORAGE_ID = 'FILE_STORAGE_ID',
10
- STORAGE_MANAGER = 'STORAGE_MANAGER',
11
- FILE_NAME = 'FILE_NAME',
12
- FILE_SIZE = 'FILE_SIZE',
13
- MODIFIED_AT = 'MODIFIED_AT',
14
- MODIFIED_BY = 'MODIFIED_BY',
15
- CREATED_BY = 'CREATED_BY',
16
- CREATED_AT = 'CREATED_AT',
17
- LOCATION_DETAILS = 'LOCATION_DETAILS',
18
- }
19
-
20
- export function DOCUMENT_COLUMNS(context: DocumentGrid) {
21
- return [
22
- {
23
- headerName: 'Type',
24
- suppressMenu: true,
25
- width: 90,
26
- flex: 1,
27
- valueGetter: (props) => {
28
- return getFileType(props.data.FILE_NAME);
29
- },
30
- cellStyle: () => ({
31
- display: 'flex',
32
- alignItems: 'center',
33
- }),
34
- cellRenderer: FileTypeCellRenderer,
35
- cellRendererParams: (params) => {
36
- const hyperlinkParams = {
37
- data: params.data,
38
- };
39
- return hyperlinkParams;
40
- },
41
- },
42
-
43
- {
44
- field: COLUMN_FIELDS.FILE_NAME,
45
- headerName: 'Name',
46
- suppressMenu: true,
47
- flex: 3,
48
- },
49
- {
50
- field: COLUMN_FIELDS.CREATED_BY,
51
- headerName: 'Owner',
52
- suppressMenu: true,
53
- flex: 2,
54
- },
55
- {
56
- field: COLUMN_FIELDS.MODIFIED_AT,
57
- headerName: 'Last Modified',
58
- suppressMenu: true,
59
- flex: 2,
60
- valueFormatter: (props) => {
61
- return formatDateLong(props?.data?.MODIFIED_AT);
62
- },
63
- },
64
- {
65
- field: COLUMN_FIELDS.FILE_SIZE,
66
- headerName: 'Size',
67
- suppressMenu: true,
68
- flex: 2,
69
- valueFormatter: (props) => {
70
- return formatBytes(props?.data?.FILE_SIZE, 0);
71
- },
72
- },
73
- {
74
- headerName: '',
75
- suppressMenu: true,
76
- flex: 1,
77
- resizable: false,
78
- sortable: false,
79
- cellStyle: () => ({
80
- display: 'flex',
81
- alignItems: 'center',
82
- }),
83
- cellRenderer: ActionCellRenderer,
84
- cellRendererParams: (params) => {
85
- const downloadBtn = {
86
- name: downloadIcon,
87
- callback: (detail) => {
88
- context.$emit('download-document', detail.FILE_STORAGE_ID);
89
- },
90
- actionName: 'Download',
91
- };
92
- const removeBtn = {
93
- name: optionsIcon,
94
- callback: (detail) => {
95
- context.$emit('remove-document', detail.FILE_STORAGE_ID);
96
- },
97
- actionName: 'remove',
98
- };
99
- const actions = [downloadBtn, removeBtn];
100
- const enabled = true;
101
- return {
102
- actions,
103
- enabled,
104
- };
105
- },
106
- },
107
- ];
108
- }
@@ -1,10 +0,0 @@
1
- import { ElementStyles, css } from '@microsoft/fast-element';
2
-
3
- export const DocumentGridStyles: ElementStyles = css`
4
- :host {
5
- height: 100%;
6
- width: 100%;
7
- position: absolute;
8
- display: flex;
9
- }
10
- `;
@@ -1,14 +0,0 @@
1
- import { html, ref, repeat } from '@microsoft/fast-element';
2
- import { DocumentGrid } from './document-grid';
3
- import { DOCUMENT_COLUMNS } from './column-config';
4
-
5
- export const DocumentGridTemplate = html<DocumentGrid>`
6
- <zero-grid-pro ${ref('documentGrid')} @onGridReady="${(x) => x.onGridReady()}">
7
- ${repeat(
8
- (x) => DOCUMENT_COLUMNS(x),
9
- html`
10
- <grid-pro-column :definition="${(x) => x}"></grid-pro-column>
11
- `,
12
- )}
13
- </zero-grid-pro>
14
- `;
@@ -1,39 +0,0 @@
1
- import { FASTElement, attr, customElement } from '@microsoft/fast-element';
2
- import { DocumentGridTemplate } from './document-grid.template';
3
- import { DocumentGridStyles } from './document-grid.styles';
4
- import { GridPro } from '@genesislcap/grid-pro';
5
- import { IFileStorage } from '../../../../utils/types';
6
-
7
- @customElement({
8
- name: 'document-grid',
9
- template: DocumentGridTemplate,
10
- styles: DocumentGridStyles,
11
- })
12
- export class DocumentGrid extends FASTElement {
13
- @attr data: IFileStorage[] = [];
14
-
15
- public documentGrid!: GridPro;
16
-
17
- connectedCallback() {
18
- super.connectedCallback();
19
- const gridOptions = {
20
- animateRows: true,
21
- scrollbarWidth: 10,
22
- suppressHorizontalScroll: true,
23
- suppressCellFocus: true,
24
- getRowId: (params) => params.data.FILE_STORAGE_ID,
25
- };
26
-
27
- this.documentGrid.gridOptions = gridOptions;
28
- }
29
-
30
- onGridReady() {
31
- this.documentGrid.gridApi.setRowData(this.data);
32
- }
33
-
34
- dataChanged() {
35
- if (this.documentGrid?.gridApi) {
36
- this.documentGrid.gridApi.setRowData(this.data);
37
- }
38
- }
39
- }
@@ -1,137 +0,0 @@
1
- import { ElementStyles, css } from '@microsoft/fast-element';
2
-
3
- export const DocumentTileStyles: ElementStyles = css`
4
- :host {
5
- height: 100%;
6
- width: 100%;
7
- position: absolute;
8
- overflow: hidden auto;
9
- background-color: var(--neutral-layer-4);
10
- box-sizing: border-box;
11
- }
12
-
13
- .file-icon {
14
- display: flex;
15
- justify-content: center;
16
- fill: var(--neutral-foreground-hint);
17
- }
18
-
19
- .file-name {
20
- position: absolute;
21
- bottom: 60px;
22
- font-size: var(--type-ramp-minus-1-font-size);
23
- color: var(--neutral-foreground-rest);
24
- text-align: left;
25
- line-height: normal;
26
- }
27
-
28
- .file-type {
29
- height: fit-content;
30
- width: fit-content;
31
- padding: calc(var(--design-unit) * 1px) calc(var(--design-unit) * 2px);
32
- border-radius: calc(var(--control-corner-radius) * 1px);
33
- font-size: 10px;
34
- font-weight: 700;
35
- color: rgba(20, 20, 20, 0.89);
36
- text-align: center;
37
- line-height: normal;
38
- }
39
-
40
- .footer-actions {
41
- display: flex;
42
- flex-direction: row;
43
- gap: calc(var(--design-unit) * 2px);
44
- position: absolute;
45
- right: 10px;
46
- bottom: 10px;
47
- fill: var(--neutral-foreground-hint);
48
- }
49
-
50
- .footer-actions > span,
51
- .top-section > zero-icon {
52
- cursor: pointer;
53
- }
54
-
55
- .footer-actions > span:hover,
56
- .top-section > zero-icon:hover {
57
- fill: var(--neutral-foreground-rest);
58
- }
59
-
60
- .footer-left {
61
- display: flex;
62
- flex-direction: column;
63
- position: absolute;
64
- bottom: 10px;
65
- left: 10px;
66
- }
67
-
68
- .footer-left > a {
69
- box-sizing: border-box;
70
- color: var(--neutral-foreground-hint);
71
- text-align: left;
72
- line-height: normal;
73
- font-size: var(--type-ramp-minus-2-font-size);
74
- }
75
-
76
- .options-icon {
77
- fill: var(--neutral-foreground-hint);
78
- cursor: pointer;
79
- }
80
-
81
- .options-icon:hover {
82
- fill: var(--neutral-foreground-rest);
83
- }
84
-
85
- .tile {
86
- position: relative;
87
- width: 251px;
88
- height: 192px;
89
- padding: calc(var(--design-unit) * 3px);
90
- border-radius: calc((var(--control-corner-radius) - 1) * 2px);
91
- border: calc(var(--stroke-width) * 1px) solid var(--neutral-stroke-divider-rest);
92
- background-color: var(--neutral-layer-3);
93
- box-sizing: border-box;
94
- display: flex;
95
- flex-direction: column;
96
- gap: calc(var(--design-unit) * 3px);
97
- }
98
-
99
- .tile > .top-section {
100
- display: flex;
101
- justify-content: space-between;
102
- align-items: center;
103
- }
104
-
105
- .tile:hover {
106
- background-color: var(--neutral-layer-2);
107
- }
108
-
109
- .tile-container,
110
- .tile-container-temp {
111
- position: relative;
112
- min-height: inherit;
113
- display: grid;
114
- padding: calc(var(--design-unit) * 3px);
115
- gap: calc(var(--design-unit) * 2px);
116
- grid-template-columns: repeat(auto-fill, 252px);
117
- grid-template-rows: repeat(auto-fill, 192px);
118
- align-items: center;
119
- justify-items: center;
120
- }
121
-
122
- .tile-container-temp {
123
- pointer-events: none;
124
- position: absolute;
125
- top: 0px;
126
- left: 0px;
127
- width: 100%;
128
- }
129
-
130
- .tile-container-temp > .tile {
131
- opacity: 0;
132
- }
133
-
134
- zero-icon::part(icon-ellipsis-vertical-md-solid > svg > path):hover {
135
- fill: var(--neutral-foreground-rest);
136
- }
137
- `;
@@ -1,71 +0,0 @@
1
- import { html, ref, repeat } from '@microsoft/fast-element';
2
- import { DocumentTile } from './document-tile';
3
- import { IFileStorage } from '../../../../utils/types';
4
- import {
5
- formatBytes,
6
- formatDateLong,
7
- getFileColor,
8
- getFileType,
9
- } from '../../../../utils/formatting';
10
- import { downloadIcon, optionsIcon } from '../../utils/icons';
11
-
12
- const tileTemplate = (hidden = false) => html<IFileStorage>`
13
- <div class="tile" id="id-${(x) => x.FILE_STORAGE_ID}${() => (hidden ? '-temp' : '')}">
14
- <div class="top-section">
15
- <div
16
- class="file-type"
17
- style="background-color: ${(x) => getFileColor(getFileType(x.FILE_NAME))}"
18
- >
19
- ${(x) => getFileType(x.FILE_NAME)}
20
- </div>
21
- <span
22
- class="options-icon"
23
- title="Options"
24
- @click=${(x, c) => c.parent.$emit('remove-document', x.FILE_STORAGE_ID)}
25
- >
26
- ${optionsIcon}
27
- </span>
28
- </div>
29
- <div class="file-icon">${(x, c) => c.parent.getFileIcon(getFileType(x.FILE_NAME))}</div>
30
- <a class="file-name">${(x) => x.FILE_NAME}</a>
31
- <div class="footer">
32
- <div class="footer-left">
33
- <a>${(x) => x.CREATED_BY}</a>
34
- <a>${(x) => formatDateLong(x.CREATED_AT)}</a>
35
- <a>${(x) => formatBytes(x.FILE_SIZE, 0)}</a>
36
- </div>
37
- <div class="footer-actions">
38
- <span
39
- title="Download"
40
- @click=${(x, c) => c.parent.$emit('download-document', x.FILE_STORAGE_ID)}
41
- >
42
- ${downloadIcon}
43
- </span>
44
- </div>
45
- </div>
46
- </div>
47
- `;
48
-
49
- export const DocumentTileTemplate = html<DocumentTile>`
50
- <div ${ref('tileContainer')} class="tile-container">
51
- ${repeat(
52
- (x) => x.dataAfterTransition,
53
- html<IFileStorage>`
54
- ${tileTemplate()}
55
- `,
56
- { recycle: false },
57
- )}
58
- </div>
59
- <div ${ref('tileContainerTemp')} class="tile-container-temp">
60
- ${repeat(
61
- (x) => x.tempData,
62
- html<IFileStorage>`
63
- ${tileTemplate(true)}
64
- `,
65
- { recycle: true },
66
- )}
67
- </div>
68
- <zero-anchored-region vertical-positioning-mode="right" vertical-default-position="top">
69
- <zero-button>Click me</zero-button>
70
- </zero-anchored-region>
71
- `;
@@ -1,119 +0,0 @@
1
- import { FASTElement, attr, customElement, observable } from '@microsoft/fast-element';
2
- import { DocumentTileTemplate } from './document-tile.template';
3
- import { DocumentTileStyles } from './document-tile.styles';
4
- import { IFileStorage } from '../../../../utils/types';
5
- import { csvIcon, jpgIcon, pdfIcon } from '../../utils/icons';
6
-
7
- @customElement({
8
- name: 'document-tile',
9
- template: DocumentTileTemplate,
10
- styles: DocumentTileStyles,
11
- })
12
- export class DocumentTile extends FASTElement {
13
- public tileContainer: HTMLElement;
14
- public tileContainerTemp: HTMLElement;
15
-
16
- @attr data: IFileStorage[] = [];
17
- @observable tempData: IFileStorage[] = [];
18
- @observable dataAfterTransition: IFileStorage[] = [];
19
-
20
- connectedCallback() {
21
- super.connectedCallback();
22
- }
23
-
24
- public dataChanged(old: IFileStorage[], newData: IFileStorage[]) {
25
- if (old && old.length > 0) {
26
- this.tempData = newData;
27
- const animationTime = 500;
28
-
29
- const tempnewData = newData.filter(
30
- (x) => old.findIndex((y) => y.FILE_STORAGE_ID === x.FILE_STORAGE_ID) == -1,
31
- );
32
-
33
- setTimeout(() => {
34
- const map = new Map<string, any>();
35
- Array.from(this.tileContainer.children).forEach((x: HTMLElement) =>
36
- map.set(x.id, { left: x.offsetLeft, top: x.offsetTop }),
37
- );
38
- Array.from(this.tileContainer.children).forEach(async (x: HTMLElement) => {
39
- const position = map.get(x.id);
40
- x.setAttribute(
41
- 'style',
42
- `position: absolute; left: ${position.left}px; top: ${position.top}px`,
43
- );
44
- });
45
-
46
- old.forEach((doc, index) => {
47
- const newIndex = newData.findIndex((x) => x.FILE_STORAGE_ID === doc.FILE_STORAGE_ID);
48
- const element: HTMLElement = this.tileContainer.querySelector(
49
- `#id-${doc.FILE_STORAGE_ID}`,
50
- );
51
- const newEle: HTMLElement = this.tileContainerTemp.querySelector(
52
- `#id-${doc.FILE_STORAGE_ID}-temp`,
53
- );
54
-
55
- if (newIndex === -1) {
56
- const animation = element.animate({ opacity: [1, 0] }, { duration: animationTime });
57
- if (index === old.length - 1 && tempnewData.length === 0) {
58
- animation.onfinish = () => {
59
- this.animationFinish(newData);
60
- };
61
- }
62
- } else if (index != newIndex) {
63
- const animation = element.animate(
64
- [
65
- {
66
- left: `${element.offsetLeft}px`,
67
- top: `${element.offsetTop}px`,
68
- },
69
- {
70
- left: `${newEle.offsetLeft}px`,
71
- top: `${newEle.offsetTop}px`,
72
- },
73
- ],
74
- { duration: animationTime },
75
- );
76
- if (index === old.length - 1 && tempnewData.length === 0) {
77
- animation.onfinish = () => {
78
- this.animationFinish(newData);
79
- };
80
- }
81
- }
82
- });
83
-
84
- tempnewData.forEach((doc, index) => {
85
- const newEle: HTMLElement = this.tileContainerTemp.querySelector(
86
- `#id-${doc.FILE_STORAGE_ID}-temp`,
87
- );
88
- const animation = newEle.animate({ opacity: [0, 1] }, { duration: animationTime });
89
- if (index === tempnewData.length - 1) {
90
- animation.onfinish = () => {
91
- this.animationFinish(newData);
92
- };
93
- }
94
- });
95
- }, 0);
96
- } else {
97
- this.dataAfterTransition = newData;
98
- this.tempData = [];
99
- }
100
- }
101
-
102
- private animationFinish(newData) {
103
- this.dataAfterTransition = newData;
104
- this.tempData = [];
105
- }
106
-
107
- public getFileIcon(fileType: string) {
108
- switch (fileType) {
109
- case 'CSV':
110
- return csvIcon;
111
- case 'JPG':
112
- return jpgIcon;
113
- case 'PDF':
114
- return pdfIcon;
115
- default:
116
- return '';
117
- }
118
- }
119
- }