@pictogrammers/components 0.4.8 → 0.5.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/package.json +1 -1
- package/pg/annoy/annoy.css +1 -1
- package/pg/button/button.css +5 -4
- package/pg/buttonLink/buttonLink.css +1 -1
- package/pg/buttonMenu/__examples__/basic/basic.ts +2 -2
- package/pg/buttonMenu/buttonMenu.ts +4 -1
- package/pg/cardUser/cardUser.css +1 -1
- package/pg/database/__examples__/basic/basic.ts +0 -1
- package/pg/grid/__examples__/basic/basic.ts +1 -4
- package/pg/grid/grid.css +1 -1
- package/pg/header/header.css +1 -1
- package/pg/icon/__examples__/basic/basic.ts +1 -1
- package/pg/inputCheck/__examples__/basic/basic.ts +1 -1
- package/pg/inputCheck/inputCheck.css +5 -0
- package/pg/inputCheck/inputCheck.ts +4 -0
- package/pg/inputCheckList/__examples__/basic/basic.ts +1 -1
- package/pg/inputFileLocal/inputFileLocal.css +1 -1
- package/pg/inputNumber/README.md +27 -0
- package/pg/inputNumber/__examples__/basic/basic.html +9 -0
- package/pg/inputNumber/__examples__/basic/basic.ts +30 -0
- package/pg/inputNumber/inputNumber.css +34 -0
- package/pg/inputNumber/inputNumber.html +1 -0
- package/pg/inputNumber/inputNumber.spec.ts +59 -0
- package/pg/inputNumber/inputNumber.ts +63 -0
- package/pg/inputPixelEditor/README.md +211 -29
- package/pg/inputPixelEditor/__examples__/basic/basic.css +8 -0
- package/pg/inputPixelEditor/__examples__/basic/basic.html +29 -7
- package/pg/inputPixelEditor/__examples__/basic/basic.ts +274 -13
- package/pg/inputPixelEditor/__examples__/basic/constants.ts +62 -0
- package/pg/inputPixelEditor/inputPixelEditor.css +37 -2
- package/pg/inputPixelEditor/inputPixelEditor.html +22 -0
- package/pg/inputPixelEditor/inputPixelEditor.ts +822 -82
- package/pg/inputPixelEditor/utils/bitmapToMask.ts +22 -8
- package/pg/inputPixelEditor/utils/blobToImage.ts +11 -0
- package/pg/inputPixelEditor/utils/canvasToPngBuffer.ts +12 -0
- package/pg/inputPixelEditor/utils/constants.ts +55 -1
- package/pg/inputPixelEditor/utils/crc32.ts +116 -0
- package/pg/inputPixelEditor/utils/diffMap.ts +32 -0
- package/pg/inputPixelEditor/utils/generateGradient.ts +112 -0
- package/pg/inputPixelEditor/utils/getEllipsePixels.ts +131 -19
- package/pg/inputPixelEditor/utils/getFloodFill.ts +83 -0
- package/pg/inputPixelEditor/utils/getGridColorIndexes.ts +13 -0
- package/pg/inputPixelEditor/utils/getOutline.ts +92 -0
- package/pg/inputPixelEditor/utils/inputMode.ts +7 -1
- package/pg/inputPixelEditor/utils/pixelSizes.ts +47 -0
- package/pg/inputPixelEditor/utils/pngMetadata.ts +487 -0
- package/pg/inputSelect/inputSelect.css +4 -4
- package/pg/inputText/inputText.css +14 -7
- package/pg/inputText/inputText.ts +5 -1
- package/pg/json/README.md +59 -0
- package/pg/json/__examples__/basic/basic.html +4 -0
- package/pg/json/__examples__/basic/basic.ts +31 -0
- package/pg/json/json.css +9 -0
- package/pg/json/json.html +1 -0
- package/pg/json/json.ts +124 -0
- package/pg/jsonArray/README.md +3 -0
- package/pg/jsonArray/jsonArray.css +15 -0
- package/pg/jsonArray/jsonArray.html +7 -0
- package/pg/jsonArray/jsonArray.ts +55 -0
- package/pg/jsonBoolean/README.md +3 -0
- package/pg/jsonBoolean/jsonBoolean.css +27 -0
- package/pg/jsonBoolean/jsonBoolean.html +5 -0
- package/pg/jsonBoolean/jsonBoolean.ts +69 -0
- package/pg/jsonNumber/README.md +3 -0
- package/pg/jsonNumber/jsonNumber.css +21 -0
- package/pg/jsonNumber/jsonNumber.html +5 -0
- package/pg/jsonNumber/jsonNumber.ts +42 -0
- package/pg/jsonObject/README.md +3 -0
- package/pg/jsonObject/jsonObject.css +11 -0
- package/pg/jsonObject/jsonObject.html +5 -0
- package/pg/jsonObject/jsonObject.ts +55 -0
- package/pg/jsonString/README.md +3 -0
- package/pg/jsonString/jsonString.css +21 -0
- package/pg/jsonString/jsonString.html +5 -0
- package/pg/jsonString/jsonString.ts +42 -0
- package/pg/menu/menu.ts +6 -5
- package/pg/menuItem/README.md +13 -2
- package/pg/menuItem/menuItem.css +17 -22
- package/pg/menuItem/menuItem.ts +8 -3
- package/pg/menuItemIcon/__examples__/basic/basic.html +1 -1
- package/pg/menuItemIcon/__examples__/basic/basic.ts +7 -0
- package/pg/menuItemIcon/menuItemIcon.css +18 -15
- package/pg/menuItemIcon/menuItemIcon.ts +8 -4
- package/pg/modal/README.md +29 -0
- package/pg/modal/__examples__/basic/basic.html +4 -0
- package/pg/modal/__examples__/basic/basic.ts +42 -0
- package/pg/modal/index.ts +3 -0
- package/pg/modal/modal.css +40 -0
- package/pg/modal/modal.html +9 -0
- package/pg/modal/modal.ts +14 -0
- package/pg/modification/__examples__/basic/basic.ts +1 -1
- package/pg/overlayMenu/overlayMenu.ts +6 -2
- package/pg/overlaySelectMenu/overlaySelectMenu.ts +6 -0
- package/pg/overlaySubMenu/overlaySubMenu.ts +6 -2
- package/pg/scroll/__examples__/basic/basic.ts +1 -1
- package/pg/search/search.css +1 -1
- package/pg/table/README.md +108 -0
- package/pg/table/__examples__/basic/basic.css +0 -0
- package/pg/table/__examples__/basic/basic.html +10 -0
- package/pg/table/__examples__/basic/basic.ts +111 -0
- package/pg/table/table.css +20 -0
- package/pg/table/table.html +6 -0
- package/pg/table/table.ts +86 -0
- package/pg/tableCellButtonIcon/README.md +3 -0
- package/pg/tableCellButtonIcon/tableCellButtonIcon.css +16 -0
- package/pg/tableCellButtonIcon/tableCellButtonIcon.html +5 -0
- package/pg/tableCellButtonIcon/tableCellButtonIcon.ts +34 -0
- package/pg/tableCellCheck/README.md +3 -0
- package/pg/tableCellCheck/tableCellCheck.css +15 -0
- package/pg/tableCellCheck/tableCellCheck.html +3 -0
- package/pg/tableCellCheck/tableCellCheck.ts +43 -0
- package/pg/tableCellNumber/README.md +3 -0
- package/pg/tableCellNumber/tableCellNumber.css +11 -0
- package/pg/tableCellNumber/tableCellNumber.html +3 -0
- package/pg/tableCellNumber/tableCellNumber.ts +40 -0
- package/pg/tableCellText/README.md +3 -0
- package/pg/tableCellText/tableCellText.css +11 -0
- package/pg/tableCellText/tableCellText.html +3 -0
- package/pg/tableCellText/tableCellText.ts +62 -0
- package/pg/tableColumn/README.md +3 -0
- package/pg/tableColumn/tableColumn.css +12 -0
- package/pg/tableColumn/tableColumn.html +1 -0
- package/pg/tableColumn/tableColumn.ts +29 -0
- package/pg/tableRow/README.md +3 -0
- package/pg/tableRow/tableRow.css +11 -0
- package/pg/tableRow/tableRow.html +1 -0
- package/pg/tableRow/tableRow.ts +77 -0
- package/pg/tabs/tabs.css +1 -1
- package/pg/tree/README.md +10 -4
- package/pg/tree/__examples__/basic/basic.html +1 -0
- package/pg/tree/__examples__/basic/basic.ts +6 -1
- package/pg/tree/tree.css +1 -0
- package/pg/treeItem/treeItem.css +3 -3
- package/favicon.svg +0 -20
- package/index.html +0 -321
- package/main.js +0 -2
- package/main.js.LICENSE.txt +0 -10
- package/pgAnnoy.js +0 -1
- package/pgApp.js +0 -1
- package/pgAvatar.js +0 -1
- package/pgButton.js +0 -1
- package/pgButtonGroup.js +0 -1
- package/pgButtonLink.js +0 -1
- package/pgButtonMenu.js +0 -1
- package/pgButtonToggle.js +0 -1
- package/pgCard.js +0 -1
- package/pgCardUser.js +0 -1
- package/pgColor.js +0 -1
- package/pgDatabase.js +0 -1
- package/pgDropdown.js +0 -1
- package/pgGrid.js +0 -1
- package/pgHeader.js +0 -1
- package/pgIcon.js +0 -1
- package/pgInputCheck.js +0 -1
- package/pgInputCheckList.js +0 -1
- package/pgInputFileLocal.js +0 -1
- package/pgInputHexRgb.js +0 -1
- package/pgInputPixelEditor.js +0 -1
- package/pgInputRange.js +0 -1
- package/pgInputSelect.js +0 -1
- package/pgInputText.js +0 -1
- package/pgInputTextIcon.js +0 -1
- package/pgInputUserSelect.js +0 -1
- package/pgListTag.js +0 -1
- package/pgMarkdown.js +0 -2
- package/pgMarkdown.js.LICENSE.txt +0 -10
- package/pgMenu.js +0 -1
- package/pgMenuDivider.js +0 -1
- package/pgMenuIcon.js +0 -1
- package/pgMenuItem.js +0 -1
- package/pgMenuItemIcon.js +0 -1
- package/pgModalAlert.js +0 -1
- package/pgModification.js +0 -1
- package/pgNav.js +0 -1
- package/pgOverlay.js +0 -1
- package/pgOverlayContextMenu.js +0 -1
- package/pgOverlayMenu.js +0 -1
- package/pgOverlaySelectMenu.js +0 -1
- package/pgOverlaySubMenu.js +0 -1
- package/pgPicker.js +0 -1
- package/pgPreview.js +0 -1
- package/pgScroll.js +0 -1
- package/pgSearch.js +0 -1
- package/pgTab.js +0 -1
- package/pgTabs.js +0 -1
- package/pgToast.js +0 -1
- package/pgToasts.js +0 -1
- package/pgTooltip.js +0 -1
- package/pgTree.js +0 -1
- package/pgTreeButtonIcon.js +0 -1
- package/pgTreeItem.js +0 -1
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# `<pg-preview>`
|
|
2
|
+
|
|
3
|
+
The `pg-table` component allows a standard way to create static tables. While it has features like the datatable it is much more lightweight lacking features like column resize and edit.
|
|
4
|
+
|
|
5
|
+
- `PgTableHeaderText`
|
|
6
|
+
- `PgTableCellText` - default `string` cell type
|
|
7
|
+
- `PgTableCellNumber` - default `number` cell type
|
|
8
|
+
- `PgTableCellCheck` - default `boolean` cell type
|
|
9
|
+
- `PgTableCellButton`
|
|
10
|
+
- `PgTableCellButtonIcon`
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import '@pictogrammers/components/pg/table';
|
|
14
|
+
import PgTable, { createTableItem } from '@pictogrammers/components/pg/table';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<pg-table part="table"></pg-table>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
| Attributes | Tested | Default | Description |
|
|
22
|
+
| ---------- | -------- | ------- | ----------- |
|
|
23
|
+
| columns | | [] | Column definition. |
|
|
24
|
+
| data | | [] | Data |
|
|
25
|
+
|
|
26
|
+
| CSS Variable | Default | Description |
|
|
27
|
+
| ------------------- | --------- | ----------- |
|
|
28
|
+
| `--pg-table-font-size` | `inherit` | Font size |
|
|
29
|
+
| `--pg-table-row-background-color` | `#f1f1f1` | Row background |
|
|
30
|
+
|
|
31
|
+
## Columns
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
// type: TableHeaderText
|
|
35
|
+
this.$table.columns = [{
|
|
36
|
+
label: 'Check All',
|
|
37
|
+
key: 'check',
|
|
38
|
+
hideLabel: true,
|
|
39
|
+
type: TableHeaderCheck,
|
|
40
|
+
editable: true
|
|
41
|
+
}, {
|
|
42
|
+
label: 'Name',
|
|
43
|
+
key: 'name'
|
|
44
|
+
}, {
|
|
45
|
+
label: 'Age',
|
|
46
|
+
key: 'age'
|
|
47
|
+
}, {
|
|
48
|
+
label: 'Favorite',
|
|
49
|
+
key: 'favorite',
|
|
50
|
+
hideLabel: true,
|
|
51
|
+
}];
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Adding `editable: true` to any data types will enable editing and trigger the `action` event (see Events below).
|
|
55
|
+
|
|
56
|
+
## Data
|
|
57
|
+
|
|
58
|
+
The `createTableItem` unrolls the `{ key: value }` shorthand to `items: [{ key, value}]` object to support the mutable data.
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
const IconStar = 'M12,17.27L18.18,21L16.54,13.97L22,9.24L14.81,8.62L12,2L9.19,8.62L2,9.24L7.45,13.97L5.82,21L12,17.27Z';
|
|
62
|
+
const IconStarOutline = 'M12,15.39L8.24,17.66L9.23,13.38L5.91,10.5L10.29,10.13L12,6.09L13.71,10.13L18.09,10.5L14.77,13.38L15.76,17.66M22,9.24L14.81,8.63L12,2L9.19,8.63L2,9.24L7.45,13.97L5.82,21L12,17.27L18.18,21L16.54,13.97L22,9.24Z';
|
|
63
|
+
this.$table.data = [
|
|
64
|
+
createTableItem({
|
|
65
|
+
name: 'Dipper Pines',
|
|
66
|
+
age: 12,
|
|
67
|
+
favorite: {
|
|
68
|
+
type: TableCellButtonIcon,
|
|
69
|
+
icon: IconStar,
|
|
70
|
+
}
|
|
71
|
+
}),
|
|
72
|
+
createTableItem({
|
|
73
|
+
name: 'Mabel Pines',
|
|
74
|
+
age: 12,
|
|
75
|
+
favorite: {
|
|
76
|
+
type: TableCellButtonIcon,
|
|
77
|
+
icon: IconStar,
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
];
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Events
|
|
84
|
+
|
|
85
|
+
All events dispatched will be the same `action` name. This allows the insert of `index` as it bubbles to the parent `this.$table` element.
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
this.$table.addEventListener('action', (e: any) => {
|
|
89
|
+
const { getColumn, value, key } = e.detail;
|
|
90
|
+
switch(key) {
|
|
91
|
+
case 'selected':
|
|
92
|
+
getColumn(key).value = value;
|
|
93
|
+
break;
|
|
94
|
+
default:
|
|
95
|
+
throw `unhandled action event for key ${key}`;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
From a custom cell component...
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
this.dispatchEvent(new CustomEvent('action', {
|
|
104
|
+
detail {
|
|
105
|
+
other: 'other data',
|
|
106
|
+
},
|
|
107
|
+
}))
|
|
108
|
+
```
|
|
File without changes
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Component, Part, Prop } from '@pictogrammers/element';
|
|
2
|
+
|
|
3
|
+
import PgTable, { createTableItem } from '../../table';
|
|
4
|
+
import PgTableCellButtonIcon from '../../../tableCellButtonIcon/tableCellButtonIcon';
|
|
5
|
+
|
|
6
|
+
import style from './basic.css';
|
|
7
|
+
import template from './basic.html';
|
|
8
|
+
|
|
9
|
+
const IconStar = 'M12,17.27L18.18,21L16.54,13.97L22,9.24L14.81,8.62L12,2L9.19,8.62L2,9.24L7.45,13.97L5.82,21L12,17.27Z';
|
|
10
|
+
const IconStarOutline = 'M12,15.39L8.24,17.66L9.23,13.38L5.91,10.5L10.29,10.13L12,6.09L13.71,10.13L18.09,10.5L14.77,13.38L15.76,17.66M22,9.24L14.81,8.63L12,2L9.19,8.63L2,9.24L7.45,13.97L5.82,21L12,17.27L18.18,21L16.54,13.97L22,9.24Z';
|
|
11
|
+
|
|
12
|
+
@Component({
|
|
13
|
+
selector: 'x-pg-table-basic',
|
|
14
|
+
style,
|
|
15
|
+
template
|
|
16
|
+
})
|
|
17
|
+
export default class XPgTableBasic extends HTMLElement {
|
|
18
|
+
|
|
19
|
+
@Part() $table: PgTable;
|
|
20
|
+
@Part() $pushData: HTMLButtonElement;
|
|
21
|
+
@Part() $deleteLast: HTMLButtonElement;
|
|
22
|
+
@Part() $output: HTMLPreElement;
|
|
23
|
+
|
|
24
|
+
connectedCallback() {
|
|
25
|
+
// this.$table.addEventListener('click', this.handleClick.bind(this));
|
|
26
|
+
this.$table.columns = [{
|
|
27
|
+
label: 'Select',
|
|
28
|
+
key: 'selected',
|
|
29
|
+
hideLabel: true,
|
|
30
|
+
editable: true,
|
|
31
|
+
}, {
|
|
32
|
+
label: 'Name',
|
|
33
|
+
key: 'name',
|
|
34
|
+
editable: true,
|
|
35
|
+
maxWidth: '12rem',
|
|
36
|
+
}, {
|
|
37
|
+
label: 'Age',
|
|
38
|
+
key: 'age'
|
|
39
|
+
}, {
|
|
40
|
+
label: 'Favorite',
|
|
41
|
+
key: 'favorite',
|
|
42
|
+
hideLabel: true,
|
|
43
|
+
}];
|
|
44
|
+
this.$table.data = [
|
|
45
|
+
createTableItem({
|
|
46
|
+
selected: true,
|
|
47
|
+
name: 'Dipper Pines',
|
|
48
|
+
age: 12,
|
|
49
|
+
favorite: {
|
|
50
|
+
type: PgTableCellButtonIcon,
|
|
51
|
+
icon: IconStarOutline,
|
|
52
|
+
value: false,
|
|
53
|
+
}
|
|
54
|
+
}),
|
|
55
|
+
createTableItem({
|
|
56
|
+
selected: false,
|
|
57
|
+
name: 'Mabel Pines',
|
|
58
|
+
age: 12,
|
|
59
|
+
favorite: {
|
|
60
|
+
type: PgTableCellButtonIcon,
|
|
61
|
+
icon: IconStarOutline,
|
|
62
|
+
value: false,
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
];
|
|
66
|
+
this.$pushData.addEventListener('click', this.handlePushData.bind(this));
|
|
67
|
+
this.$deleteLast.addEventListener('click', this.handleDeleteLast.bind(this));
|
|
68
|
+
this.$table.addEventListener('action', (e: any) => {
|
|
69
|
+
const { getColumn, key } = e.detail;
|
|
70
|
+
switch(key) {
|
|
71
|
+
case 'name':
|
|
72
|
+
getColumn(key).value = e.detail.value;
|
|
73
|
+
break;
|
|
74
|
+
case 'favorite':
|
|
75
|
+
getColumn(key).value = !getColumn(key).value;
|
|
76
|
+
if (getColumn(key).value) {
|
|
77
|
+
getColumn(key).icon = IconStar;
|
|
78
|
+
} else {
|
|
79
|
+
getColumn(key).icon = IconStarOutline;
|
|
80
|
+
}
|
|
81
|
+
break;
|
|
82
|
+
case 'selected':
|
|
83
|
+
getColumn(key).value = e.detail.value;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
// CSV
|
|
87
|
+
this.$output.textContent = this.$table.getCSV();
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
newCount = 0;
|
|
92
|
+
handlePushData() {
|
|
93
|
+
this.$table.data.push(createTableItem({
|
|
94
|
+
name: `new ${this.newCount++}`,
|
|
95
|
+
age: this.newCount,
|
|
96
|
+
favorite: {
|
|
97
|
+
type: PgTableCellButtonIcon,
|
|
98
|
+
icon: IconStarOutline,
|
|
99
|
+
},
|
|
100
|
+
}));
|
|
101
|
+
// CSV
|
|
102
|
+
this.$output.textContent = this.$table.getCSV();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
handleDeleteLast() {
|
|
106
|
+
this.$table.data.pop();
|
|
107
|
+
// CSV
|
|
108
|
+
this.$output.textContent = this.$table.getCSV();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
[part=table] {
|
|
6
|
+
display: table;
|
|
7
|
+
border-spacing: 2px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
[part=header] {
|
|
11
|
+
display: table-header-group;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
[part=columns] {
|
|
15
|
+
display: table-row;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
[part=rows] {
|
|
19
|
+
display: table-row-group;
|
|
20
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Component, Prop, Part, forEach } from '@pictogrammers/element';
|
|
2
|
+
|
|
3
|
+
import PgTableColumn from '../tableColumn/tableColumn';
|
|
4
|
+
import PgTableRow from '../tableRow/tableRow';
|
|
5
|
+
|
|
6
|
+
import template from './table.html';
|
|
7
|
+
import style from './table.css';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Create a table data item that can react to data changes. While cumbersome
|
|
11
|
+
* this greatly increases performance and uses less memory.
|
|
12
|
+
*
|
|
13
|
+
* @param obj ex: { field1: 'value', field2: 42 }
|
|
14
|
+
* @returns formatted object
|
|
15
|
+
*/
|
|
16
|
+
export function createTableItem(obj: object) {
|
|
17
|
+
const keys = Object.keys(obj);
|
|
18
|
+
const items: any[] = [];
|
|
19
|
+
keys.forEach((key) => {
|
|
20
|
+
if (typeof obj[key] === 'object' && obj[key] !== null) {
|
|
21
|
+
items.push({
|
|
22
|
+
key,
|
|
23
|
+
...obj[key],
|
|
24
|
+
});
|
|
25
|
+
} else {
|
|
26
|
+
items.push({
|
|
27
|
+
key,
|
|
28
|
+
value: obj[key],
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return { items };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@Component({
|
|
36
|
+
selector: 'pg-table',
|
|
37
|
+
style,
|
|
38
|
+
template
|
|
39
|
+
})
|
|
40
|
+
export default class PgTable extends HTMLElement {
|
|
41
|
+
@Prop() columns: any[] = [];
|
|
42
|
+
@Prop() data: any[] = [];
|
|
43
|
+
|
|
44
|
+
@Part() $columns: HTMLDivElement;
|
|
45
|
+
@Part() $rows: HTMLDivElement;
|
|
46
|
+
|
|
47
|
+
trackedData = [];
|
|
48
|
+
|
|
49
|
+
connectedCallback() {
|
|
50
|
+
forEach({
|
|
51
|
+
container: this.$columns,
|
|
52
|
+
items: this.columns,
|
|
53
|
+
type: () => PgTableColumn,
|
|
54
|
+
});
|
|
55
|
+
forEach({
|
|
56
|
+
container: this.$rows,
|
|
57
|
+
items: this.data,
|
|
58
|
+
type: () => PgTableRow,
|
|
59
|
+
create: ($item: PgTableRow, item) => {
|
|
60
|
+
if (this.columns.length === 0) {
|
|
61
|
+
throw 'columns must be set before data';
|
|
62
|
+
}
|
|
63
|
+
$item.columns = this.columns;
|
|
64
|
+
$item.addEventListener('action', (e: any) => {
|
|
65
|
+
e.stopPropagation();
|
|
66
|
+
this.dispatchEvent(new CustomEvent('action', {
|
|
67
|
+
detail: e.detail,
|
|
68
|
+
}));
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
getCSV() {
|
|
75
|
+
let text = this.columns.map((column) => {
|
|
76
|
+
return column.label;
|
|
77
|
+
}).join(',');
|
|
78
|
+
text += '\n';
|
|
79
|
+
text += this.data.map(({ items }) => {
|
|
80
|
+
return items.map((item) => {
|
|
81
|
+
return item.value;
|
|
82
|
+
}).join(',')
|
|
83
|
+
}).join('\n');
|
|
84
|
+
return text;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: contents;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
[part=cell] {
|
|
6
|
+
display: table-cell;
|
|
7
|
+
padding: 0 0.5rem;
|
|
8
|
+
background-color: var(--pg-table-row-background-color);
|
|
9
|
+
border-top: 0;
|
|
10
|
+
border-radius: 0.125rem;
|
|
11
|
+
vertical-align: middle;
|
|
12
|
+
justify-items: center;
|
|
13
|
+
--pg-button-background-color: transparent;
|
|
14
|
+
--pg-button-padding: 0;
|
|
15
|
+
--pg-button-border-width: 0;
|
|
16
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Component, Prop, Part } from '@pictogrammers/element';
|
|
2
|
+
|
|
3
|
+
import PgButton from '../button/button';
|
|
4
|
+
import PgIcon from '../icon/icon';
|
|
5
|
+
|
|
6
|
+
import template from './tableCellButtonIcon.html';
|
|
7
|
+
import style from './tableCellButtonIcon.css';
|
|
8
|
+
|
|
9
|
+
@Component({
|
|
10
|
+
selector: 'pg-table-cell-button-icon',
|
|
11
|
+
style,
|
|
12
|
+
template
|
|
13
|
+
})
|
|
14
|
+
export default class PgTableCellButtonIcon extends HTMLElement {
|
|
15
|
+
@Prop() value: any = null;
|
|
16
|
+
@Prop() icon: string = '';
|
|
17
|
+
|
|
18
|
+
@Part() $button: PgButton;
|
|
19
|
+
@Part() $icon: PgIcon;
|
|
20
|
+
|
|
21
|
+
connectedCallback() {
|
|
22
|
+
this.$button.addEventListener('click', () => {
|
|
23
|
+
this.dispatchEvent(new CustomEvent('action', {
|
|
24
|
+
detail: {},
|
|
25
|
+
}));
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
render(changes) {
|
|
30
|
+
if (changes.icon) {
|
|
31
|
+
this.$icon.path = this.icon;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: contents;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
[part=cell] {
|
|
6
|
+
display: table-cell;
|
|
7
|
+
padding: 0.125rem;
|
|
8
|
+
background-color: var(--pg-table-row-background-color);
|
|
9
|
+
border-top: 0;
|
|
10
|
+
border-radius: 0.125rem;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
[part=input] {
|
|
14
|
+
vertical-align: middle;
|
|
15
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Component, Prop, Part } from '@pictogrammers/element';
|
|
2
|
+
|
|
3
|
+
import PgInputCheck from '../inputCheck/inputCheck';
|
|
4
|
+
|
|
5
|
+
import template from './tableCellCheck.html';
|
|
6
|
+
import style from './tableCellCheck.css';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'pg-table-cell-check',
|
|
10
|
+
style,
|
|
11
|
+
template,
|
|
12
|
+
})
|
|
13
|
+
export default class PgTableCellCheck extends HTMLElement {
|
|
14
|
+
@Prop() value: boolean = false;
|
|
15
|
+
@Prop() editable: boolean = false;
|
|
16
|
+
@Prop() key: string = '';
|
|
17
|
+
|
|
18
|
+
@Part() $input: PgInputCheck;
|
|
19
|
+
|
|
20
|
+
connectedCallback() {
|
|
21
|
+
this.$input.addEventListener('change', this.handleChange.bind(this));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
render(changes) {
|
|
25
|
+
if (changes.value) {
|
|
26
|
+
this.$input.value = this.value;
|
|
27
|
+
}
|
|
28
|
+
if (changes.editable) {
|
|
29
|
+
this.$input.readOnly = !this.editable;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
handleChange(e: any) {
|
|
34
|
+
const { value } = e.target;
|
|
35
|
+
this.dispatchEvent(
|
|
36
|
+
new CustomEvent('action', {
|
|
37
|
+
detail: {
|
|
38
|
+
value,
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: contents;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
[part=cell] {
|
|
6
|
+
display: table-cell;
|
|
7
|
+
background-color: var(--pg-table-row-background-color);
|
|
8
|
+
--pg-input-text-padding: 0.125rem 0.25rem;
|
|
9
|
+
--pg-input-text-border-color: rgb(69, 60, 79, 0.5);
|
|
10
|
+
vertical-align: middle;
|
|
11
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Component, Prop, Part } from '@pictogrammers/element';
|
|
2
|
+
|
|
3
|
+
import PgInputText from '../inputText/inputText';
|
|
4
|
+
|
|
5
|
+
import template from './tableCellNumber.html';
|
|
6
|
+
import style from './tableCellNumber.css';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'pg-table-cell-number',
|
|
10
|
+
style,
|
|
11
|
+
template
|
|
12
|
+
})
|
|
13
|
+
export default class PgTableCellNumber extends HTMLElement {
|
|
14
|
+
@Prop() value: number = 0;
|
|
15
|
+
@Prop() key: string = '';
|
|
16
|
+
@Prop() editable: boolean = false;
|
|
17
|
+
|
|
18
|
+
@Part() $input: PgInputText;
|
|
19
|
+
|
|
20
|
+
connectedCallback() {
|
|
21
|
+
this.$input.addEventListener('change', (e: any) => {
|
|
22
|
+
this.dispatchEvent(
|
|
23
|
+
new CustomEvent('action', {
|
|
24
|
+
detail: {
|
|
25
|
+
value: e.detail.value,
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
render(changes) {
|
|
33
|
+
if (changes.value) {
|
|
34
|
+
this.$input.value = `${this.value}`;
|
|
35
|
+
}
|
|
36
|
+
if (changes.editable) {
|
|
37
|
+
this.$input.readOnly = !this.editable;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: contents;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
[part=cell] {
|
|
6
|
+
display: table-cell;
|
|
7
|
+
background-color: var(--pg-table-row-background-color);
|
|
8
|
+
--pg-input-text-padding: 0.125rem 0.25rem;
|
|
9
|
+
--pg-input-text-border-color: rgb(69, 60, 79, 0.5);
|
|
10
|
+
vertical-align: middle;
|
|
11
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Component, Prop, Part } from '@pictogrammers/element';
|
|
2
|
+
|
|
3
|
+
import PgInputText from '../inputText/inputText';
|
|
4
|
+
|
|
5
|
+
import template from './tableCellText.html';
|
|
6
|
+
import style from './tableCellText.css';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'pg-table-cell-text',
|
|
10
|
+
style,
|
|
11
|
+
template
|
|
12
|
+
})
|
|
13
|
+
export default class PgTableCellText extends HTMLElement {
|
|
14
|
+
@Prop() value: string = '';
|
|
15
|
+
@Prop() key: string = '';
|
|
16
|
+
@Prop() editable: boolean = false;
|
|
17
|
+
@Prop() maxWidth: number | string | null = null;
|
|
18
|
+
|
|
19
|
+
@Part() $input: PgInputText;
|
|
20
|
+
|
|
21
|
+
connectedCallback() {
|
|
22
|
+
this.$input.addEventListener('input', (e: any) => {
|
|
23
|
+
this.dispatchEvent(
|
|
24
|
+
new CustomEvent('action', {
|
|
25
|
+
detail: {
|
|
26
|
+
value: e.detail.value,
|
|
27
|
+
event: 'input',
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
this.$input.addEventListener('change', (e: any) => {
|
|
33
|
+
this.dispatchEvent(
|
|
34
|
+
new CustomEvent('action', {
|
|
35
|
+
detail: {
|
|
36
|
+
value: e.detail.value,
|
|
37
|
+
event: 'change',
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
render(changes) {
|
|
45
|
+
if (changes.value) {
|
|
46
|
+
this.$input.value = this.value;
|
|
47
|
+
}
|
|
48
|
+
if (changes.editable) {
|
|
49
|
+
this.$input.readOnly = !this.editable;
|
|
50
|
+
}
|
|
51
|
+
if (changes.maxWidth) {
|
|
52
|
+
if (this.maxWidth === null) {
|
|
53
|
+
this.$input.style.removeProperty('--pg-input-text-max-width');
|
|
54
|
+
} else {
|
|
55
|
+
this.$input.style.setProperty(
|
|
56
|
+
'--pg-input-text-max-width',
|
|
57
|
+
`${typeof this.maxWidth === 'string' ? this.maxWidth : this.maxWidth + 'px'}`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<div part="label"></div>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Component, Prop, Part, forEach } from '@pictogrammers/element';
|
|
2
|
+
|
|
3
|
+
import template from './tableColumn.html';
|
|
4
|
+
import style from './tableColumn.css';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
selector: 'pg-table-column',
|
|
8
|
+
style,
|
|
9
|
+
template
|
|
10
|
+
})
|
|
11
|
+
export default class PgTableColumn extends HTMLElement {
|
|
12
|
+
@Prop() label: string = '';
|
|
13
|
+
@Prop() hideLabel: boolean = false;
|
|
14
|
+
@Prop() key: string = '';
|
|
15
|
+
|
|
16
|
+
@Part() $label: HTMLDivElement;
|
|
17
|
+
|
|
18
|
+
render(changes: { [key: string ]: boolean}) {
|
|
19
|
+
if (changes.label || changes.hideLabel) {
|
|
20
|
+
if (this.hideLabel) {
|
|
21
|
+
this.$label.ariaLabel = this.label;
|
|
22
|
+
this.$label.textContent = '';
|
|
23
|
+
} else {
|
|
24
|
+
this.$label.ariaLabel = null;
|
|
25
|
+
this.$label.textContent = this.label;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|