@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
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
:host {
|
|
2
2
|
display: block;
|
|
3
|
-
font-family: var(--pg-font-family);
|
|
3
|
+
font-family: var(--pg-font-family, system-ui);
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
[part=
|
|
6
|
+
[part=input] {
|
|
7
7
|
border: 1px solid var(--pg-input-text-border-color, #453C4F);
|
|
8
8
|
border-radius: 0.125rem;
|
|
9
|
-
padding: calc(0.5rem - 1px) 0.75rem;
|
|
10
|
-
font-family: var(--pg-font-family);
|
|
9
|
+
padding: var(--pg-input-text-padding, calc(0.5rem - 1px) 0.75rem);
|
|
10
|
+
font-family: var(--pg-input-text-font-family, var(--pg-font-family));
|
|
11
11
|
font-size: 1rem;
|
|
12
12
|
outline: none;
|
|
13
|
-
|
|
13
|
+
field-sizing: content;
|
|
14
|
+
min-width: calc(100% - 0.5rem - 2px);
|
|
15
|
+
max-width: calc(var(--pg-input-text-max-width, 100%) - 0.5rem - 2px);
|
|
16
|
+
background-color: transparent;
|
|
14
17
|
}
|
|
15
18
|
|
|
16
|
-
[part=
|
|
19
|
+
[part=input]:read-only {
|
|
20
|
+
border-color: transparent;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
[part=input]:active {
|
|
17
24
|
box-shadow: 0 0 0 3px var(--pg-input-text-active-glow, rgb(79, 143, 249, 0.6));
|
|
18
25
|
}
|
|
19
|
-
[part=
|
|
26
|
+
[part=input]:focus {
|
|
20
27
|
box-shadow: 0 0 0 3px var(--pg-input-text-focus-glow, rgb(79, 143, 249, 0.5));
|
|
21
28
|
}
|
|
@@ -12,6 +12,7 @@ export default class PgInputText extends HTMLElement {
|
|
|
12
12
|
@Prop() name: string = '';
|
|
13
13
|
@Prop() value: string = '';
|
|
14
14
|
@Prop() placeholder: string = '';
|
|
15
|
+
@Prop() readOnly: boolean = false;
|
|
15
16
|
|
|
16
17
|
@Part() $input: HTMLInputElement;
|
|
17
18
|
|
|
@@ -29,6 +30,9 @@ export default class PgInputText extends HTMLElement {
|
|
|
29
30
|
if (changes.placeholder) {
|
|
30
31
|
this.$input.placeholder = this.placeholder;
|
|
31
32
|
}
|
|
33
|
+
if (changes.readOnly) {
|
|
34
|
+
this.$input.readOnly = this.readOnly;
|
|
35
|
+
}
|
|
32
36
|
this.skipValue = false;
|
|
33
37
|
}
|
|
34
38
|
|
|
@@ -56,4 +60,4 @@ export default class PgInputText extends HTMLElement {
|
|
|
56
60
|
})
|
|
57
61
|
);
|
|
58
62
|
}
|
|
59
|
-
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# `<pg-json>`
|
|
2
|
+
|
|
3
|
+
The `pg-json` component renders json and allows values to be modified. The default data type rendering is below.
|
|
4
|
+
|
|
5
|
+
- `PgJsonArray`
|
|
6
|
+
- `PgJsonObject` - `null` is hardcoded
|
|
7
|
+
- `PgJsonString`
|
|
8
|
+
- `PgJsonBoolean`
|
|
9
|
+
- `PgJsonNumber`
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import '@pictogrammers/components/pg/json';
|
|
13
|
+
import PgIcon from '@pictogrammers/components/pg/json';
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```html
|
|
17
|
+
<pg-json part="json"></pg-json>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
| Attributes | Tested | Default | Description |
|
|
21
|
+
| ---------- | -------- | ------- | ----------- |
|
|
22
|
+
| value | | `{}` | Set json data |
|
|
23
|
+
| root | | `[]` | Root of object to render |
|
|
24
|
+
| schema | | `null` | JSON Schema |
|
|
25
|
+
| expand | | `0` | Default level to expand |
|
|
26
|
+
| limit | | `10` | Arrays max items "...{total - max} view more" |
|
|
27
|
+
| loadMore | | `10` | Amount to render after clicking load more |
|
|
28
|
+
|
|
29
|
+
For a root array type set `root: ['items']` and value `{ items: [] }`.
|
|
30
|
+
|
|
31
|
+
## Event
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
this.$json.value = {
|
|
35
|
+
users: [{
|
|
36
|
+
name: 'Dipper Pines',
|
|
37
|
+
age: 12,
|
|
38
|
+
}]
|
|
39
|
+
}; // Array or Object
|
|
40
|
+
this.$json.addEventListener('change', (e: any) => {
|
|
41
|
+
const { parent, key, path, value } = e.detail;
|
|
42
|
+
if (value !== parent[key]) {
|
|
43
|
+
parent[key] = value;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The `path` array gives the deep nesting for the record being modified.
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
// Modifying Dipper's name for instance
|
|
52
|
+
path = ['users', 0, 'name'];
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Schema
|
|
56
|
+
|
|
57
|
+
Not required if simply editing existing data. To allow complex editing add a defined schema object.
|
|
58
|
+
|
|
59
|
+
See https://json-schema.org for tutorials on writing your own schema.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Component, Part, Prop } from '@pictogrammers/element';
|
|
2
|
+
|
|
3
|
+
import PgJson from '../../json';
|
|
4
|
+
|
|
5
|
+
import template from './basic.html';
|
|
6
|
+
|
|
7
|
+
@Component({
|
|
8
|
+
selector: 'x-pg-json-basic',
|
|
9
|
+
template
|
|
10
|
+
})
|
|
11
|
+
export default class XPgJsonBasic extends HTMLElement {
|
|
12
|
+
@Part() $json: PgJson;
|
|
13
|
+
@Part() $output: HTMLPreElement;
|
|
14
|
+
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
this.$json.value = {
|
|
17
|
+
users: [{
|
|
18
|
+
name: 'Dipper Pines',
|
|
19
|
+
age: 12,
|
|
20
|
+
selected: false,
|
|
21
|
+
}]
|
|
22
|
+
}; // Array or Object
|
|
23
|
+
this.$json.addEventListener('change', (e: any) => {
|
|
24
|
+
const { parent, key, value } = e.detail;
|
|
25
|
+
if (value !== parent[key]) {
|
|
26
|
+
parent[key] = value;
|
|
27
|
+
}
|
|
28
|
+
this.$output.textContent = JSON.stringify(this.$json.value);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
package/pg/json/json.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<div part="container"></div>
|
package/pg/json/json.ts
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Component, Prop, Part } from '@pictogrammers/element';
|
|
2
|
+
|
|
3
|
+
import PgJsonArray from '../jsonArray/jsonArray';
|
|
4
|
+
import PgJsonObject from '../jsonObject/jsonObject';
|
|
5
|
+
import PgJsonString from '../jsonString/jsonString';
|
|
6
|
+
import PgJsonBoolean from '../jsonBoolean/jsonBoolean';
|
|
7
|
+
import PgJsonNumber from '../jsonNumber/jsonNumber';
|
|
8
|
+
|
|
9
|
+
import template from './json.html';
|
|
10
|
+
import style from './json.css';
|
|
11
|
+
|
|
12
|
+
function getType(value) {
|
|
13
|
+
if (typeof value === 'string') {
|
|
14
|
+
return PgJsonString;
|
|
15
|
+
}
|
|
16
|
+
if (typeof value === 'boolean') {
|
|
17
|
+
return PgJsonBoolean;
|
|
18
|
+
}
|
|
19
|
+
if (typeof value === 'number') {
|
|
20
|
+
return PgJsonNumber;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function unwrapObject(obj: any) {
|
|
25
|
+
return Object.keys(obj).map((key) => {
|
|
26
|
+
if (Array.isArray(obj[key])) {
|
|
27
|
+
return {
|
|
28
|
+
key,
|
|
29
|
+
value: unwrapArray(obj[key]),
|
|
30
|
+
type: PgJsonArray,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (typeof obj[key] === 'object') {
|
|
34
|
+
return {
|
|
35
|
+
key,
|
|
36
|
+
value: unwrapObject(obj[key]),
|
|
37
|
+
type: PgJsonObject,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
key,
|
|
42
|
+
value: obj[key],
|
|
43
|
+
type: getType(obj[key]),
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function unwrapArray(items: any) {
|
|
49
|
+
return items.map((item, i) => {
|
|
50
|
+
if (Array.isArray(item)) {
|
|
51
|
+
return {
|
|
52
|
+
key: i.toString(),
|
|
53
|
+
value: unwrapArray(item),
|
|
54
|
+
type: PgJsonArray,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (typeof item === 'object') {
|
|
58
|
+
return {
|
|
59
|
+
key: i.toString(),
|
|
60
|
+
value: unwrapObject(item),
|
|
61
|
+
type: PgJsonObject,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
key: i.toString(),
|
|
66
|
+
value: item,
|
|
67
|
+
type: getType(item),
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@Component({
|
|
73
|
+
selector: 'pg-json',
|
|
74
|
+
style,
|
|
75
|
+
template,
|
|
76
|
+
})
|
|
77
|
+
export default class PgJson extends HTMLElement {
|
|
78
|
+
@Prop() value: any = null;
|
|
79
|
+
@Prop() root = [];
|
|
80
|
+
@Prop() schema: any = null;
|
|
81
|
+
|
|
82
|
+
@Part() $container: HTMLElement;
|
|
83
|
+
|
|
84
|
+
render(changes) {
|
|
85
|
+
if (changes.value && this.value !== null) {
|
|
86
|
+
if (this.$container.children.length === 1) {
|
|
87
|
+
this.$container.children[0].remove();
|
|
88
|
+
}
|
|
89
|
+
if (typeof this.value === 'object') {
|
|
90
|
+
const $object = document.createElement('pg-json-object') as PgJsonObject;
|
|
91
|
+
$object.value = unwrapObject(this.value);
|
|
92
|
+
$object.addEventListener('update', this.handleUpdate.bind(this));
|
|
93
|
+
this.$container.appendChild($object);
|
|
94
|
+
} else if (Array.isArray(this.value)) {
|
|
95
|
+
const $array = document.createElement('pg-json-array') as PgJsonArray;
|
|
96
|
+
$array.value = unwrapArray(this.value);
|
|
97
|
+
$array.addEventListener('update', this.handleUpdate.bind(this));
|
|
98
|
+
this.$container.appendChild($array);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
getParent(path: string[], parent) {
|
|
104
|
+
const key = path.pop();
|
|
105
|
+
if (key && (typeof parent[key] === 'object' || parent[key] instanceof Array)) {
|
|
106
|
+
return this.getParent(path, parent[key]);
|
|
107
|
+
}
|
|
108
|
+
return parent;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
handleUpdate(e: any) {
|
|
112
|
+
const { path, key, value } = e.detail;
|
|
113
|
+
const parent = this.getParent(path, this.value);
|
|
114
|
+
this.dispatchEvent(
|
|
115
|
+
new CustomEvent('change', {
|
|
116
|
+
detail: {
|
|
117
|
+
parent,
|
|
118
|
+
key,
|
|
119
|
+
value,
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Component, Prop, Part, forEach } from '@pictogrammers/element';
|
|
2
|
+
|
|
3
|
+
import PgJsonObject from '../jsonObject/jsonObject';
|
|
4
|
+
import PgJsonString from '../jsonString/jsonString';
|
|
5
|
+
import PgJsonBoolean from '../jsonBoolean/jsonBoolean';
|
|
6
|
+
import PgJsonNumber from '../jsonNumber/jsonNumber';
|
|
7
|
+
|
|
8
|
+
import template from './jsonArray.html';
|
|
9
|
+
import style from './jsonArray.css';
|
|
10
|
+
|
|
11
|
+
@Component({
|
|
12
|
+
selector: 'pg-json-array',
|
|
13
|
+
style,
|
|
14
|
+
template,
|
|
15
|
+
})
|
|
16
|
+
export default class PgJsonArray extends HTMLElement {
|
|
17
|
+
@Prop() key: string = '';
|
|
18
|
+
@Prop() value: any[] = [];
|
|
19
|
+
@Prop() expanded: boolean = false;
|
|
20
|
+
|
|
21
|
+
@Part() $key: HTMLDivElement;
|
|
22
|
+
@Part() $seperator: HTMLDivElement;
|
|
23
|
+
@Part() $items: HTMLDivElement;
|
|
24
|
+
|
|
25
|
+
connectedCallback() {
|
|
26
|
+
forEach({
|
|
27
|
+
container: this.$items,
|
|
28
|
+
items: this.value,
|
|
29
|
+
type: (item) => item.type,
|
|
30
|
+
create: ($item, item) => {
|
|
31
|
+
$item.addEventListener('update', (e: any) => {
|
|
32
|
+
const { path, key, value } = e.detail;
|
|
33
|
+
this.key && path.push(this.key);
|
|
34
|
+
this.dispatchEvent(
|
|
35
|
+
new CustomEvent('update', {
|
|
36
|
+
detail: {
|
|
37
|
+
path,
|
|
38
|
+
key,
|
|
39
|
+
value,
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
render(changes) {
|
|
49
|
+
if (changes.key) {
|
|
50
|
+
this.$key.classList.toggle('hide', this.key === '');
|
|
51
|
+
this.$seperator.classList.toggle('hide', this.key === '');
|
|
52
|
+
this.$key.textContent = this.key;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: flex;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
[part=key],
|
|
6
|
+
[part=seperator] {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
[part=value] {
|
|
12
|
+
margin: 0 -0.25rem;
|
|
13
|
+
background-color: transparent;
|
|
14
|
+
border: 0;
|
|
15
|
+
font-size: 1rem;
|
|
16
|
+
padding: 0.125rem 0.25rem;
|
|
17
|
+
vertical-align: middle;
|
|
18
|
+
font-family: inherit;
|
|
19
|
+
z-index: 1;
|
|
20
|
+
position: relative;
|
|
21
|
+
outline: 0;
|
|
22
|
+
border-radius: 0.125rem;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
[part=value]:focus-visible {
|
|
26
|
+
box-shadow: 0 0 0 3px var(--pg-input-text-focus-glow, rgb(79, 143, 249, 0.5));
|
|
27
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Component, Prop, Part } from '@pictogrammers/element';
|
|
2
|
+
|
|
3
|
+
import PgOverlaySelectMenu from '../overlaySelectMenu/overlaySelectMenu';
|
|
4
|
+
|
|
5
|
+
import template from './jsonBoolean.html';
|
|
6
|
+
import style from './jsonBoolean.css';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'pg-json-boolean',
|
|
10
|
+
style,
|
|
11
|
+
template,
|
|
12
|
+
})
|
|
13
|
+
export default class PgJsonBoolean extends HTMLElement {
|
|
14
|
+
@Prop() key: string = '';
|
|
15
|
+
@Prop() value: boolean = false;
|
|
16
|
+
|
|
17
|
+
@Part() $key: HTMLDivElement;
|
|
18
|
+
@Part() $value: HTMLButtonElement;
|
|
19
|
+
|
|
20
|
+
connectedCallback() {
|
|
21
|
+
this.$value.addEventListener('click', this.#handleClick.bind(this));
|
|
22
|
+
// this.$value.value = e.detail.value;
|
|
23
|
+
// this.dispatchEvent(
|
|
24
|
+
// new CustomEvent('update', {
|
|
25
|
+
// detail: {
|
|
26
|
+
// path: [this.key],
|
|
27
|
+
// value: e.detail.value,
|
|
28
|
+
// }
|
|
29
|
+
// })
|
|
30
|
+
// );
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
render(changes) {
|
|
34
|
+
if (changes.key) {
|
|
35
|
+
this.$key.textContent = this.key;
|
|
36
|
+
}
|
|
37
|
+
if (changes.value) {
|
|
38
|
+
this.$value.textContent = this.value ? 'true' : 'false';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
options = [
|
|
43
|
+
{ label: 'true', value: 'true' },
|
|
44
|
+
{ label: 'false', value: 'false' },
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
#menuOpen = false;
|
|
48
|
+
async #handleClick() {
|
|
49
|
+
if (this.#menuOpen) { return; }
|
|
50
|
+
this.#menuOpen = true;
|
|
51
|
+
const result = await PgOverlaySelectMenu.open({
|
|
52
|
+
source: this.$value,
|
|
53
|
+
value: this.options.find(x => x.value === `${this.value}`) ?? 'false',
|
|
54
|
+
items: this.options,
|
|
55
|
+
});
|
|
56
|
+
if (result !== undefined) {
|
|
57
|
+
this.dispatchEvent(new CustomEvent('update', {
|
|
58
|
+
detail: {
|
|
59
|
+
path: [this.key],
|
|
60
|
+
key: this.key,
|
|
61
|
+
value: result.value === 'true'
|
|
62
|
+
}
|
|
63
|
+
}));
|
|
64
|
+
this.$value.textContent = result.label;
|
|
65
|
+
this.value = result.value === 'true';
|
|
66
|
+
}
|
|
67
|
+
this.#menuOpen = false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: flex;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
[part=key],
|
|
6
|
+
[part=seperator] {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
[part=value] {
|
|
12
|
+
user-select: text;
|
|
13
|
+
--pg-input-text-padding: 0 0.25rem;
|
|
14
|
+
--pg-input-text-border-color: transparent;
|
|
15
|
+
--pg-input-number-font-family: var(--pg-json-font-family);
|
|
16
|
+
display: inline-flex;
|
|
17
|
+
vertical-align: middle;
|
|
18
|
+
margin: 0 -0.25rem;
|
|
19
|
+
z-index: 1;
|
|
20
|
+
position: relative;
|
|
21
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Component, Prop, Part } from '@pictogrammers/element';
|
|
2
|
+
|
|
3
|
+
import PgInputNumber from '../inputNumber/inputNumber';
|
|
4
|
+
|
|
5
|
+
import template from './jsonNumber.html';
|
|
6
|
+
import style from './jsonNumber.css';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'pg-json-number',
|
|
10
|
+
style,
|
|
11
|
+
template,
|
|
12
|
+
})
|
|
13
|
+
export default class PgJsonNumber extends HTMLElement {
|
|
14
|
+
@Prop() key: string = '';
|
|
15
|
+
@Prop() value: number = 0;
|
|
16
|
+
|
|
17
|
+
@Part() $key: HTMLDivElement;
|
|
18
|
+
@Part() $value: PgInputNumber;
|
|
19
|
+
|
|
20
|
+
connectedCallback() {
|
|
21
|
+
this.$value.addEventListener('input', (e: any) => {
|
|
22
|
+
this.dispatchEvent(
|
|
23
|
+
new CustomEvent('update', {
|
|
24
|
+
detail: {
|
|
25
|
+
path: [this.key],
|
|
26
|
+
key: this.key,
|
|
27
|
+
value: Number.parseInt(e.detail.value, 10),
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
render(changes) {
|
|
35
|
+
if (changes.key) {
|
|
36
|
+
this.$key.textContent = this.key;
|
|
37
|
+
}
|
|
38
|
+
if (changes.value) {
|
|
39
|
+
this.$value.value = `${this.value}`;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Component, Prop, Part, forEach } from '@pictogrammers/element';
|
|
2
|
+
|
|
3
|
+
import PgJsonArray from '../jsonArray/jsonArray';
|
|
4
|
+
import PgJsonString from '../jsonString/jsonString';
|
|
5
|
+
import PgJsonBoolean from '../jsonBoolean/jsonBoolean';
|
|
6
|
+
import PgJsonNumber from '../jsonNumber/jsonNumber';
|
|
7
|
+
|
|
8
|
+
import template from './jsonObject.html';
|
|
9
|
+
import style from './jsonObject.css';
|
|
10
|
+
|
|
11
|
+
@Component({
|
|
12
|
+
selector: 'pg-json-object',
|
|
13
|
+
style,
|
|
14
|
+
template,
|
|
15
|
+
})
|
|
16
|
+
export default class PgJsonObject extends HTMLElement {
|
|
17
|
+
@Prop() key: string = '';
|
|
18
|
+
@Prop() value: any[] = [];
|
|
19
|
+
@Prop() expanded: boolean = false;
|
|
20
|
+
|
|
21
|
+
@Part() $key: HTMLDivElement;
|
|
22
|
+
@Part() $seperator: HTMLDivElement;
|
|
23
|
+
@Part() $items: HTMLDivElement;
|
|
24
|
+
|
|
25
|
+
connectedCallback() {
|
|
26
|
+
forEach({
|
|
27
|
+
container: this.$items,
|
|
28
|
+
items: this.value,
|
|
29
|
+
type: (item) => item.type,
|
|
30
|
+
create: ($item, item) => {
|
|
31
|
+
$item.addEventListener('update', (e: any) => {
|
|
32
|
+
const { path, key, value } = e.detail;
|
|
33
|
+
this.key && path.push(this.key);
|
|
34
|
+
this.dispatchEvent(
|
|
35
|
+
new CustomEvent('update', {
|
|
36
|
+
detail: {
|
|
37
|
+
path,
|
|
38
|
+
key,
|
|
39
|
+
value,
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
render(changes) {
|
|
49
|
+
if (changes.key) {
|
|
50
|
+
this.$key.classList.toggle('hide', this.key === '' || !isNaN(this.key as any));
|
|
51
|
+
this.$seperator.classList.toggle('hide', this.key === '' || !isNaN(this.key as any));
|
|
52
|
+
this.$key.textContent = this.key;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: flex;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
[part=key],
|
|
6
|
+
[part=seperator] {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
[part=value] {
|
|
12
|
+
user-select: text;
|
|
13
|
+
--pg-input-text-padding: 0 0.25rem;
|
|
14
|
+
--pg-input-text-border-color: transparent;
|
|
15
|
+
--pg-input-text-font-family: var(--pg-json-font-family);
|
|
16
|
+
display: inline-flex;
|
|
17
|
+
vertical-align: middle;
|
|
18
|
+
margin: 0 -0.25rem;
|
|
19
|
+
z-index: 1;
|
|
20
|
+
position: relative;
|
|
21
|
+
}
|