@pictogrammers/components 0.3.2 → 0.4.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 +11 -12
- package/favicon.svg +20 -0
- package/index.html +67 -49
- package/main.js +2 -0
- package/main.js.LICENSE.txt +10 -0
- package/package.json +6 -6
- package/pg/annoy/README.md +0 -5
- package/pg/annoy/__examples__/basic/basic.css +3 -0
- package/pg/annoy/__examples__/basic/basic.html +4 -7
- package/pg/annoy/__examples__/basic/basic.ts +3 -1
- package/pg/annoy/annoy.css +29 -198
- package/pg/annoy/annoy.html +5 -56
- package/pg/annoy/annoy.ts +4 -25
- package/pg/app/README.md +11 -0
- package/pg/app/__examples__/basic/basic.css +8 -0
- package/pg/app/__examples__/basic/basic.html +15 -0
- package/pg/app/__examples__/basic/basic.ts +13 -0
- package/pg/app/app.css +108 -0
- package/pg/app/app.html +16 -0
- package/pg/app/app.ts +45 -0
- package/pg/app/index.ts +3 -0
- package/pg/avatar/__examples__/basic/basic.ts +5 -3
- package/pg/button/README.md +3 -0
- package/pg/button/button.css +13 -12
- package/pg/button/button.spec.ts +35 -0
- package/pg/button/button.ts +17 -12
- package/pg/buttonLink/buttonLink.css +3 -2
- package/pg/buttonMenu/README.md +54 -0
- package/pg/buttonMenu/__examples__/basic/basic.html +6 -0
- package/pg/buttonMenu/__examples__/basic/basic.ts +43 -0
- package/pg/buttonMenu/buttonMenu.css +12 -0
- package/pg/buttonMenu/buttonMenu.html +4 -0
- package/pg/buttonMenu/buttonMenu.ts +63 -0
- package/pg/buttonMenu/index.ts +3 -0
- package/pg/buttonToggle/__examples__/basic/basic.ts +2 -2
- package/pg/buttonToggle/__examples__/persist/persist.html +10 -0
- package/pg/buttonToggle/__examples__/persist/persist.ts +35 -0
- package/pg/cardUser/__examples__/basic/basic.ts +0 -1
- package/pg/cardUser/cardUser.css +2 -10
- package/pg/cardUser/cardUser.html +0 -5
- package/pg/cardUser/cardUser.ts +0 -6
- package/pg/database/README.md +1 -1
- package/pg/database/__examples__/basic/basic.html +2 -1
- package/pg/database/__examples__/basic/basic.ts +3 -3
- package/pg/dropdown/dropdown.ts +0 -19
- package/pg/grid/__examples__/basic/basic.html +2 -2
- package/pg/grid/__examples__/basic/basic.ts +3 -2
- package/pg/grid/grid.ts +0 -1
- package/pg/icon/README.md +6 -5
- package/pg/icon/__examples__/basic/basic.html +2 -2
- package/pg/icon/__examples__/basic/basic.ts +1 -1
- package/pg/icon/icon.ts +6 -0
- package/pg/inputCheckList/__examples__/basic/basic.ts +5 -5
- package/pg/inputCheckList/inputCheckList.ts +2 -0
- package/pg/inputFileLocal/inputFileLocal.css +3 -2
- package/pg/inputPixelEditor/README.md +132 -0
- package/pg/inputPixelEditor/__examples__/basic/basic.css +29 -0
- package/pg/inputPixelEditor/__examples__/basic/basic.html +63 -0
- package/pg/inputPixelEditor/__examples__/basic/basic.ts +200 -0
- package/pg/inputPixelEditor/__examples__/basic/openUtils.ts +41 -0
- package/pg/inputPixelEditor/__examples__/basic/saveUtil.ts +35 -0
- package/pg/inputPixelEditor/index.ts +3 -0
- package/pg/inputPixelEditor/inputPixelEditor.css +27 -0
- package/pg/inputPixelEditor/inputPixelEditor.html +3 -0
- package/pg/inputPixelEditor/inputPixelEditor.ts +839 -0
- package/pg/inputPixelEditor/utils/bitmapToMask.ts +202 -0
- package/pg/inputPixelEditor/utils/cloneGrid.ts +17 -0
- package/pg/inputPixelEditor/utils/constants.ts +1 -0
- package/pg/inputPixelEditor/utils/createLayer.ts +8 -0
- package/pg/inputPixelEditor/utils/debounce.ts +5 -0
- package/pg/inputPixelEditor/utils/diffGrid.ts +26 -0
- package/pg/inputPixelEditor/utils/fillGrid.ts +11 -0
- package/pg/inputPixelEditor/utils/getEllipseOutlinePixels.ts +105 -0
- package/pg/inputPixelEditor/utils/getEllipsePixels.ts +28 -0
- package/pg/inputPixelEditor/utils/getGuides.ts +232 -0
- package/pg/inputPixelEditor/utils/getLinePixels.ts +18 -0
- package/pg/inputPixelEditor/utils/getRectangleOutlinePixels.ts +20 -0
- package/pg/inputPixelEditor/utils/getRectanglePixels.ts +15 -0
- package/pg/inputPixelEditor/utils/inputMode.ts +8 -0
- package/pg/inputPixelEditor/utils/interateGrid.ts +7 -0
- package/pg/inputPixelEditor/utils/isEmptyGrid.ts +3 -0
- package/pg/inputPixelEditor/utils/maskToBitmap.ts +66 -0
- package/pg/inputRange/__examples__/basic/basic.ts +4 -4
- package/pg/inputRange/inputRange.ts +6 -4
- package/pg/inputSelect/README.md +1 -1
- package/pg/inputSelect/__examples__/basic/basic.ts +7 -5
- package/pg/inputSelect/inputSelect.css +15 -12
- package/pg/inputSelect/inputSelect.html +3 -3
- package/pg/inputSelect/inputSelect.ts +33 -30
- package/pg/inputText/__examples__/basic/basic.ts +6 -6
- package/pg/inputText/inputText.css +1 -0
- package/pg/inputUserSelect/README.md +1 -1
- package/pg/inputUserSelect/inputUserSelect.ts +1 -1
- package/pg/listTag/__examples__/basic/basic.ts +4 -5
- package/pg/markdown/README.md +17 -3
- package/pg/markdown/__examples__/basic/basic.ts +2 -2
- package/pg/markdown/__examples__/basic/constants.ts +1 -1
- package/pg/markdown/markdown.css +11 -0
- package/pg/menu/README.md +46 -0
- package/pg/menu/__examples__/basic/basic.html +6 -0
- package/pg/menu/__examples__/basic/basic.ts +46 -0
- package/pg/menu/index.ts +3 -0
- package/pg/menu/menu.css +19 -0
- package/pg/menu/menu.html +1 -0
- package/pg/menu/menu.ts +119 -0
- package/pg/menuDivider/README.md +7 -0
- package/pg/menuDivider/__examples__/basic/basic.html +3 -0
- package/pg/menuDivider/__examples__/basic/basic.ts +28 -0
- package/pg/menuDivider/index.ts +3 -0
- package/pg/menuDivider/menuDivider.css +9 -0
- package/pg/menuDivider/menuDivider.html +1 -0
- package/pg/menuDivider/menuDivider.ts +22 -0
- package/pg/menuIcon/menuIcon.ts +43 -36
- package/pg/menuItem/README.md +32 -0
- package/pg/menuItem/__examples__/basic/basic.html +26 -0
- package/pg/menuItem/__examples__/basic/basic.ts +41 -0
- package/pg/menuItem/index.ts +3 -0
- package/pg/menuItem/menuItem.css +97 -0
- package/pg/menuItem/menuItem.html +1 -0
- package/pg/menuItem/menuItem.ts +77 -0
- package/pg/menuItemIcon/README.md +32 -0
- package/pg/menuItemIcon/__examples__/basic/basic.html +34 -0
- package/pg/menuItemIcon/__examples__/basic/basic.ts +55 -0
- package/pg/menuItemIcon/index.ts +3 -0
- package/pg/menuItemIcon/menuItemIcon.css +106 -0
- package/pg/menuItemIcon/menuItemIcon.html +4 -0
- package/pg/menuItemIcon/menuItemIcon.ts +156 -0
- package/pg/modalAlert/__examples__/basic/basic.ts +1 -1
- package/pg/modalAlert/modalAlert.css +1 -4
- package/pg/modalAlert/modalAlert.ts +18 -4
- package/pg/modification/__examples__/basic/basic.ts +1 -2
- package/pg/modification/__examples__/basic/constants.ts +25 -50
- package/pg/modification/modification.ts +1 -1
- package/pg/overlay/overlay.ts +13 -12
- package/pg/overlayContextMenu/README.md +35 -0
- package/pg/overlayContextMenu/__examples__/basic/basic.css +23 -0
- package/pg/overlayContextMenu/__examples__/basic/basic.html +7 -0
- package/pg/overlayContextMenu/__examples__/basic/basic.ts +87 -0
- package/pg/overlayContextMenu/index.ts +3 -0
- package/pg/overlayContextMenu/overlayContextMenu.css +16 -0
- package/pg/overlayContextMenu/overlayContextMenu.html +3 -0
- package/pg/overlayContextMenu/overlayContextMenu.ts +98 -0
- package/pg/overlayMenu/README.md +33 -0
- package/pg/overlayMenu/__examples__/basic/basic.css +3 -0
- package/pg/overlayMenu/__examples__/basic/basic.html +5 -0
- package/pg/overlayMenu/__examples__/basic/basic.ts +62 -0
- package/pg/overlayMenu/index.ts +3 -0
- package/pg/overlayMenu/overlayMenu.css +16 -0
- package/pg/overlayMenu/overlayMenu.html +3 -0
- package/pg/overlayMenu/overlayMenu.ts +67 -0
- package/pg/overlaySelectMenu/README.md +33 -0
- package/pg/overlaySelectMenu/__examples__/basic/basic.css +3 -0
- package/pg/overlaySelectMenu/__examples__/basic/basic.html +5 -0
- package/pg/overlaySelectMenu/__examples__/basic/basic.ts +62 -0
- package/pg/overlaySelectMenu/index.ts +3 -0
- package/pg/overlaySelectMenu/overlaySelectMenu.css +17 -0
- package/pg/overlaySelectMenu/overlaySelectMenu.html +3 -0
- package/pg/overlaySelectMenu/overlaySelectMenu.ts +96 -0
- package/pg/overlaySubMenu/README.md +35 -0
- package/pg/overlaySubMenu/index.ts +3 -0
- package/pg/overlaySubMenu/overlaySubMenu.css +27 -0
- package/pg/overlaySubMenu/overlaySubMenu.html +3 -0
- package/pg/overlaySubMenu/overlaySubMenu.ts +103 -0
- package/pg/picker/picker.ts +1 -19
- package/pg/scroll/__examples__/basic/basic.ts +1 -1
- package/pg/search/__examples__/basic/basic.ts +10 -7
- package/pg/search/search.css +2 -2
- package/pg/shared/models/user.ts +0 -2
- package/pg/tab/tab.ts +0 -10
- package/pg/tabs/partials/tab.css +42 -0
- package/pg/tabs/partials/tab.ts +70 -0
- package/pg/tabs/tabs.css +0 -53
- package/pg/tabs/tabs.ts +54 -70
- package/pg/toast/README.md +35 -6
- package/pg/toast/__examples__/basic/basic.html +7 -0
- package/pg/toast/__examples__/basic/basic.ts +76 -0
- package/pg/toast/toast.css +3 -0
- package/pg/toast/toast.ts +20 -4
- package/pg/tooltip/addTooltip.ts +3 -1
- package/pg/tooltip/tooltip.ts +1 -1
- package/pg/tree/README.md +67 -0
- package/pg/tree/__examples__/basic/basic.html +10 -0
- package/pg/tree/__examples__/basic/basic.ts +162 -0
- package/pg/tree/index.ts +3 -0
- package/pg/tree/tree.css +28 -0
- package/pg/tree/tree.html +1 -0
- package/pg/tree/tree.ts +217 -0
- package/pg/treeButtonIcon/README.md +39 -0
- package/pg/treeButtonIcon/index.ts +3 -0
- package/pg/treeButtonIcon/treeButtonIcon.css +18 -0
- package/pg/treeButtonIcon/treeButtonIcon.html +3 -0
- package/pg/treeButtonIcon/treeButtonIcon.ts +42 -0
- package/pg/treeItem/README.md +3 -0
- package/pg/treeItem/index.ts +3 -0
- package/pg/treeItem/treeItem.css +263 -0
- package/pg/treeItem/treeItem.html +16 -0
- package/pg/treeItem/treeItem.ts +558 -0
- package/pgAnnoy.js +1 -0
- package/pgApp.js +1 -0
- package/pgAvatar.js +1 -0
- package/pgButton.js +1 -0
- package/pgButtonGroup.js +1 -0
- package/pgButtonLink.js +1 -0
- package/pgButtonMenu.js +1 -0
- package/pgButtonToggle.js +1 -0
- package/pgCard.js +1 -0
- package/pgCardUser.js +1 -0
- package/pgColor.js +1 -0
- package/pgDatabase.js +1 -0
- package/pgDropdown.js +1 -0
- package/pgGrid.js +1 -0
- package/pgHeader.js +1 -0
- package/pgIcon.js +1 -0
- package/pgInputCheck.js +1 -0
- package/pgInputCheckList.js +1 -0
- package/pgInputFileLocal.js +1 -0
- package/pgInputHexRgb.js +1 -0
- package/pgInputPixelEditor.js +1 -0
- package/pgInputRange.js +1 -0
- package/pgInputSelect.js +1 -0
- package/pgInputText.js +1 -0
- package/pgInputTextIcon.js +1 -0
- package/pgInputUserSelect.js +1 -0
- package/pgListTag.js +1 -0
- package/pgMarkdown.js +2 -0
- package/pgMarkdown.js.LICENSE.txt +10 -0
- package/pgMenu.js +1 -0
- package/pgMenuDivider.js +1 -0
- package/pgMenuIcon.js +1 -0
- package/pgMenuItem.js +1 -0
- package/pgMenuItemIcon.js +1 -0
- package/pgModalAlert.js +1 -0
- package/pgModification.js +1 -0
- package/pgNav.js +1 -0
- package/pgOverlay.js +1 -0
- package/pgOverlayContextMenu.js +1 -0
- package/pgOverlayMenu.js +1 -0
- package/pgOverlaySelectMenu.js +1 -0
- package/pgOverlaySubMenu.js +1 -0
- package/pgPicker.js +1 -0
- package/pgPreview.js +1 -0
- package/pgScroll.js +1 -0
- package/pgSearch.js +1 -0
- package/pgTab.js +1 -0
- package/pgTabs.js +1 -0
- package/pgToast.js +1 -0
- package/pgToasts.js +1 -0
- package/pgTooltip.js +1 -0
- package/pgTree.js +1 -0
- package/pgTreeButtonIcon.js +1 -0
- package/pgTreeItem.js +1 -0
- package/theme-ui3.css +31 -0
- package/@types/css.d.ts +0 -4
- package/@types/html.d.ts +0 -4
- package/dist/main.js +0 -3819
- package/dist/pgAnnoy.js +0 -116
- package/dist/pgAvatar.js +0 -136
- package/dist/pgButton.js +0 -116
- package/dist/pgButtonGroup.js +0 -116
- package/dist/pgButtonLink.js +0 -116
- package/dist/pgButtonToggle.js +0 -146
- package/dist/pgCard.js +0 -116
- package/dist/pgCardUser.js +0 -196
- package/dist/pgColor.js +0 -136
- package/dist/pgDatabase.js +0 -236
- package/dist/pgDropdown.js +0 -686
- package/dist/pgGrid.js +0 -126
- package/dist/pgHeader.js +0 -116
- package/dist/pgIcon.js +0 -116
- package/dist/pgInputCheck.js +0 -116
- package/dist/pgInputCheckList.js +0 -126
- package/dist/pgInputFileLocal.js +0 -116
- package/dist/pgInputHexRgb.js +0 -126
- package/dist/pgInputRange.js +0 -116
- package/dist/pgInputSelect.js +0 -116
- package/dist/pgInputText.js +0 -116
- package/dist/pgInputTextIcon.js +0 -176
- package/dist/pgInputUserSelect.js +0 -116
- package/dist/pgListTag.js +0 -136
- package/dist/pgMarkdown.js +0 -346
- package/dist/pgMenuIcon.js +0 -206
- package/dist/pgModalAlert.js +0 -126
- package/dist/pgModification.js +0 -396
- package/dist/pgNav.js +0 -116
- package/dist/pgOverlay.js +0 -96
- package/dist/pgPicker.js +0 -116
- package/dist/pgPreview.js +0 -116
- package/dist/pgScroll.js +0 -266
- package/dist/pgSearch.js +0 -146
- package/dist/pgTab.js +0 -116
- package/dist/pgTabs.js +0 -136
- package/dist/pgToast.js +0 -136
- package/dist/pgToasts.js +0 -136
- package/dist/pgTooltip.js +0 -126
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export function maskToBitmap(pathData: string, width: number, height: number) {
|
|
2
|
+
const grid: number[][] = Array(height).fill(0).map(() => Array(width).fill(0));
|
|
3
|
+
|
|
4
|
+
// Store only the vertical edges
|
|
5
|
+
const verticalEdges: { x: number, y: number[] }[] = [];
|
|
6
|
+
|
|
7
|
+
const paths = pathData.match(/M[^Z]*Z/g) || [];
|
|
8
|
+
for (const path of paths) {
|
|
9
|
+
let x0;
|
|
10
|
+
let y0;
|
|
11
|
+
let x;
|
|
12
|
+
let y;
|
|
13
|
+
// Split the path data into commands
|
|
14
|
+
const commands = path.match(/[MHVZ][\d, ]*/g) || [];
|
|
15
|
+
|
|
16
|
+
for (const cmd of commands) {
|
|
17
|
+
const type = cmd[0];
|
|
18
|
+
const value = cmd.slice(1);
|
|
19
|
+
let newY;
|
|
20
|
+
|
|
21
|
+
switch (type) {
|
|
22
|
+
case 'M': {
|
|
23
|
+
const [vX, vY] = value.split(/,| /).map(v => parseInt(v, 10));
|
|
24
|
+
x = vX;
|
|
25
|
+
y = vY;
|
|
26
|
+
x0 = vX;
|
|
27
|
+
y0 = vY;
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
case 'H':
|
|
31
|
+
x = parseInt(value, 10);
|
|
32
|
+
break;
|
|
33
|
+
case 'V':
|
|
34
|
+
newY = parseInt(value, 10);
|
|
35
|
+
verticalEdges.push({ x, y: [y, newY].sort((a, b) => a - b) });
|
|
36
|
+
y = newY;
|
|
37
|
+
break;
|
|
38
|
+
case 'Z':
|
|
39
|
+
if (x0 === x) {
|
|
40
|
+
verticalEdges.push({ x, y: [y, y0].sort((a, b) => a - b) });
|
|
41
|
+
}
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Fill the shape using scan-line algorithm
|
|
48
|
+
for (let y = 0; y < height; ++y) {
|
|
49
|
+
let inside = false;
|
|
50
|
+
|
|
51
|
+
for (let x = 0; x < width; ++x) {
|
|
52
|
+
// Check if we cross a vertical edge
|
|
53
|
+
for (const verticalEdge of verticalEdges) {
|
|
54
|
+
if (verticalEdge.x === x && y >= verticalEdge.y[0] && y < verticalEdge.y[1]) {
|
|
55
|
+
inside = !inside;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (inside) {
|
|
60
|
+
grid[y][x] = 1;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return grid;
|
|
66
|
+
}
|
|
@@ -14,16 +14,16 @@ export default class XPgInputRangeBasic extends HTMLElement {
|
|
|
14
14
|
@Part() $value2: HTMLSpanElement;
|
|
15
15
|
|
|
16
16
|
connectedCallback() {
|
|
17
|
-
this.$input.addEventListener('change', this
|
|
18
|
-
this.$input.addEventListener('input', this
|
|
17
|
+
this.$input.addEventListener('change', this.#handleChange.bind(this));
|
|
18
|
+
this.$input.addEventListener('input', this.#handleInput.bind(this));
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
handleChange(e: CustomEvent) {
|
|
21
|
+
#handleChange(e: CustomEvent) {
|
|
22
22
|
const { value } = e.detail;
|
|
23
23
|
this.$value1.innerText = value;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
handleInput(e: CustomEvent) {
|
|
26
|
+
#handleInput(e: CustomEvent) {
|
|
27
27
|
const { value } = e.detail;
|
|
28
28
|
this.$value2.innerText = value;
|
|
29
29
|
}
|
|
@@ -23,11 +23,12 @@ export default class PgInputRange extends HTMLElement {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
connectedCallback() {
|
|
26
|
-
this.$input.addEventListener('change', this
|
|
27
|
-
this.$input.addEventListener('input', this
|
|
26
|
+
this.$input.addEventListener('change', this.#handleChange.bind(this));
|
|
27
|
+
this.$input.addEventListener('input', this.#handleInput.bind(this));
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
handleChange(e) {
|
|
30
|
+
#handleChange(e: any) {
|
|
31
|
+
e.stopPropagation();
|
|
31
32
|
const { value } = e.target;
|
|
32
33
|
this.dispatchEvent(
|
|
33
34
|
new CustomEvent('change', {
|
|
@@ -39,7 +40,8 @@ export default class PgInputRange extends HTMLElement {
|
|
|
39
40
|
);
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
handleInput(e) {
|
|
43
|
+
#handleInput(e: any) {
|
|
44
|
+
e.stopPropagation();
|
|
43
45
|
const { value } = e.target;
|
|
44
46
|
this.dispatchEvent(
|
|
45
47
|
new CustomEvent('input', {
|
package/pg/inputSelect/README.md
CHANGED
|
@@ -4,7 +4,7 @@ The `pg-input-select` component creates an select drop down.
|
|
|
4
4
|
|
|
5
5
|
```typescript
|
|
6
6
|
import '@pictogrammers/components/pgInputSelect';
|
|
7
|
-
import { PgInputSelect } '@
|
|
7
|
+
import { PgInputSelect } '@pictogrammers/components/pgInputSelect';
|
|
8
8
|
```
|
|
9
9
|
|
|
10
10
|
```html
|
|
@@ -13,18 +13,20 @@ export default class XPgInputSelectBasic extends HTMLElement {
|
|
|
13
13
|
@Part() $value: HTMLSpanElement;
|
|
14
14
|
|
|
15
15
|
connectedCallback() {
|
|
16
|
-
this.$input.options
|
|
16
|
+
this.$input.options.push(
|
|
17
17
|
{ label: 'Option 1', value: 'option1' },
|
|
18
18
|
{ label: 'Option 2', value: 'option2' },
|
|
19
19
|
{ label: 'Option 3', value: 'option3' },
|
|
20
20
|
{ label: 'Option 4', value: 'option4' }
|
|
21
|
-
|
|
22
|
-
this.$input.
|
|
23
|
-
this.$input.
|
|
21
|
+
);
|
|
22
|
+
this.$input.default = { label: 'None', value: '', disabled: true };
|
|
23
|
+
//this.$input.value = this.$input.options[1].value;
|
|
24
|
+
this.$input.addEventListener('change', this.#handleChange.bind(this));
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
handleChange(e) {
|
|
27
|
+
#handleChange(e) {
|
|
27
28
|
const { value } = e.detail;
|
|
29
|
+
this.$input.value = value;
|
|
28
30
|
this.$value.innerText = `${value}`;
|
|
29
31
|
}
|
|
30
32
|
}
|
|
@@ -1,31 +1,34 @@
|
|
|
1
1
|
:host {
|
|
2
|
-
display:
|
|
3
|
-
font-family: var(--pg-font-family);
|
|
2
|
+
display: contents;
|
|
4
3
|
}
|
|
5
4
|
|
|
6
|
-
[part=
|
|
5
|
+
[part=button] {
|
|
6
|
+
font-family: var(--pg-font-family);
|
|
7
|
+
background: var(--pg-input-select-background, #FFFFFF);
|
|
8
|
+
text-align: left;
|
|
7
9
|
display: grid;
|
|
8
10
|
grid-template-rows: auto;
|
|
9
11
|
grid-template-columns: 100% 0;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
[part="select"] {
|
|
13
|
-
grid-row: 1;
|
|
14
|
-
grid-column: 1;
|
|
15
12
|
border: 1px solid var(--pg-input-select-border-color, #453C4F);
|
|
16
13
|
border-radius: 0.25rem;
|
|
17
|
-
padding: 0
|
|
14
|
+
padding: 0;
|
|
18
15
|
width: 100%;
|
|
19
16
|
font-size: 1rem;
|
|
20
17
|
outline: 0;
|
|
21
|
-
-webkit-appearance: none;
|
|
22
18
|
}
|
|
23
19
|
|
|
24
|
-
[part=
|
|
20
|
+
[part=button]:focus {
|
|
25
21
|
box-shadow: 0 0 0 3px rgba(79, 143, 249, 0.5);
|
|
26
22
|
}
|
|
27
23
|
|
|
28
|
-
[part=
|
|
24
|
+
[part=label] {
|
|
25
|
+
grid-row: 1;
|
|
26
|
+
grid-column: 1;
|
|
27
|
+
padding: 0.5rem 0.75rem;
|
|
28
|
+
font-size: var(--pg-input-select-font-size, 1rem);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
[part=chevron] {
|
|
29
32
|
grid-row: 1;
|
|
30
33
|
grid-column: 2;
|
|
31
34
|
pointer-events: none;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<
|
|
2
|
-
<
|
|
1
|
+
<button part="button">
|
|
2
|
+
<span part="label"></span>
|
|
3
3
|
<svg part="chevron" viewBox="0 0 24 24"><path d="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z" /></svg>
|
|
4
|
-
</
|
|
4
|
+
</button>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Component, Prop, Part } from '@pictogrammers/element';
|
|
1
|
+
import { Component, Prop, Part, forEach } from '@pictogrammers/element';
|
|
2
|
+
import PgOverlaySelectMenu from '../overlaySelectMenu/overlaySelectMenu';
|
|
2
3
|
|
|
3
4
|
import template from './inputSelect.html';
|
|
4
5
|
import style from './inputSelect.css';
|
|
@@ -15,43 +16,45 @@ interface InputSelectItem {
|
|
|
15
16
|
})
|
|
16
17
|
export default class PgInputSelect extends HTMLElement {
|
|
17
18
|
@Prop() options: InputSelectItem[] = [];
|
|
18
|
-
@Prop() value: string;
|
|
19
|
+
@Prop() value: string = '';
|
|
19
20
|
@Prop() name: string = '';
|
|
21
|
+
@Prop() default: any = null;
|
|
20
22
|
|
|
21
|
-
@Part() $
|
|
23
|
+
@Part() $button: HTMLButtonElement;
|
|
24
|
+
@Part() $label: HTMLSpanElement;
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.options.forEach(o => {
|
|
26
|
-
const option = document.createElement('option');
|
|
27
|
-
option.innerText = o.label;
|
|
28
|
-
option.value = o.value;
|
|
29
|
-
this.$select.appendChild(option);
|
|
30
|
-
});
|
|
31
|
-
if (this.$select.value !== this.value) {
|
|
32
|
-
this.$select.value = this.value;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (changes.value) {
|
|
36
|
-
if (this.$select.value !== this.value) {
|
|
37
|
-
this.$select.value = this.value;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
26
|
+
connectedCallback() {
|
|
27
|
+
this.$button.addEventListener('click', this.#handleClick.bind(this));
|
|
40
28
|
}
|
|
41
29
|
|
|
42
|
-
|
|
43
|
-
|
|
30
|
+
render(changes) {
|
|
31
|
+
if (changes.value || changes.default) {
|
|
32
|
+
this.$label.textContent = this.value
|
|
33
|
+
? this.value
|
|
34
|
+
: this.default
|
|
35
|
+
? this.default.label
|
|
36
|
+
: '\u00A0'; // nbsp
|
|
37
|
+
}
|
|
44
38
|
}
|
|
45
39
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
this
|
|
49
|
-
|
|
40
|
+
#menuOpen = false;
|
|
41
|
+
async #handleClick() {
|
|
42
|
+
if (this.#menuOpen) { return; }
|
|
43
|
+
this.#menuOpen = true;
|
|
44
|
+
const result = await PgOverlaySelectMenu.open({
|
|
45
|
+
source: this.$button,
|
|
46
|
+
default: this.default,
|
|
47
|
+
value: this.options.find(x => x.value === this.value) ?? null,
|
|
48
|
+
items: this.options
|
|
49
|
+
});
|
|
50
|
+
if (result !== undefined) {
|
|
51
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
50
52
|
detail: {
|
|
51
|
-
value
|
|
52
|
-
name: this.name
|
|
53
|
+
value: result.value
|
|
53
54
|
}
|
|
54
|
-
})
|
|
55
|
-
|
|
55
|
+
}));
|
|
56
|
+
this.$label.textContent = result.label;
|
|
57
|
+
}
|
|
58
|
+
this.#menuOpen = false;
|
|
56
59
|
}
|
|
57
60
|
}
|
|
@@ -14,17 +14,17 @@ export default class XPgInputTextBasic extends HTMLElement {
|
|
|
14
14
|
@Part() $value2: HTMLSpanElement;
|
|
15
15
|
|
|
16
16
|
connectedCallback() {
|
|
17
|
-
this.$input.addEventListener('change', this
|
|
18
|
-
this.$input.addEventListener('input', this
|
|
17
|
+
this.$input.addEventListener('change', this.#handleChange.bind(this));
|
|
18
|
+
this.$input.addEventListener('input', this.#handleInput.bind(this));
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
handleChange(e: CustomEvent) {
|
|
21
|
+
#handleChange(e: CustomEvent) {
|
|
22
22
|
const { value } = e.detail;
|
|
23
|
-
this.$value1.
|
|
23
|
+
this.$value1.textContent = value;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
handleInput(e: CustomEvent) {
|
|
26
|
+
#handleInput(e: CustomEvent) {
|
|
27
27
|
const { value } = e.detail;
|
|
28
|
-
this.$value2.
|
|
28
|
+
this.$value2.textContent = value;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -4,7 +4,7 @@ The `pg-input-user-select` component creates an select drop down.
|
|
|
4
4
|
|
|
5
5
|
```typescript
|
|
6
6
|
import '@pictogrammers/components/pgInputUserSelect';
|
|
7
|
-
import { PgInputUserSelect } '@
|
|
7
|
+
import { PgInputUserSelect } '@pictogrammers/components/pgInputUserSelect';
|
|
8
8
|
```
|
|
9
9
|
|
|
10
10
|
```html
|
|
@@ -34,7 +34,7 @@ const mdiShape = 'M11,13.5V21.5H3V13.5H11M12,2L17.5,11H6.5L12,2M17.5,13C20,13 22
|
|
|
34
34
|
template
|
|
35
35
|
})
|
|
36
36
|
export default class PgInputUserSelect extends HTMLElement {
|
|
37
|
-
@Prop() options: User[]
|
|
37
|
+
@Prop() options: User[] = [];
|
|
38
38
|
@Prop() value: User | null = null;
|
|
39
39
|
@Prop() clear: boolean = false;
|
|
40
40
|
@Prop() noDataText: string = 'Empty Users List';
|
|
@@ -21,25 +21,24 @@ export default class XPgIconBasic extends HTMLElement {
|
|
|
21
21
|
this.$buttonAdd.addEventListener('click', this.handleAdd.bind(this));
|
|
22
22
|
this.$buttonRemove.addEventListener('click', this.handleRemove.bind(this));
|
|
23
23
|
this.$buttonEdit.addEventListener('click', this.handleEdit.bind(this));
|
|
24
|
-
this.$tags.items
|
|
24
|
+
this.$tags.items.push(...tags);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
handleClear() {
|
|
28
|
-
this.$tags.items
|
|
28
|
+
this.$tags.items.splice(0, this.$tags.items.length)
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
uuid = 4;
|
|
32
32
|
|
|
33
33
|
handleAdd() {
|
|
34
|
-
this.$tags.items
|
|
35
|
-
...this.$tags.items,
|
|
34
|
+
this.$tags.items.push(
|
|
36
35
|
new Tag().from({
|
|
37
36
|
id: `uuid${this.uuid++}`,
|
|
38
37
|
count: 42,
|
|
39
38
|
name: 'Foo Bar',
|
|
40
39
|
url: 'foo-bar'
|
|
41
40
|
})
|
|
42
|
-
|
|
41
|
+
);
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
handleRemove() {
|
package/pg/markdown/README.md
CHANGED
|
@@ -8,6 +8,20 @@ import '@pictogrammers/components/pg/markdown';
|
|
|
8
8
|
|
|
9
9
|
## Usage
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
All markdown formatting is supported. Code blocks support:
|
|
12
|
+
|
|
13
|
+
- css
|
|
14
|
+
- groovy
|
|
15
|
+
- javascript
|
|
16
|
+
- json
|
|
17
|
+
- jsx
|
|
18
|
+
- tsx
|
|
19
|
+
- java
|
|
20
|
+
- markup (aka html, xml)
|
|
21
|
+
- typescript
|
|
22
|
+
- sass
|
|
23
|
+
- scss
|
|
24
|
+
- yaml (with a custom viewer)
|
|
25
|
+
- php
|
|
26
|
+
- bash
|
|
27
|
+
- markdown
|
|
@@ -12,7 +12,7 @@ export default class XPgMarkdownBasic extends HTMLElement {
|
|
|
12
12
|
@Part() $markdown: PgMarkdown;
|
|
13
13
|
|
|
14
14
|
connectedCallback() {
|
|
15
|
-
this.$markdown.replace
|
|
15
|
+
this.$markdown.replace.push({
|
|
16
16
|
find: new RegExp('(\\\\mdi|mdi|icon):([a-z0-9-]+):?([#a-z0-9-]+)?', 'g'),
|
|
17
17
|
replace: (m, type, icon, color) => {
|
|
18
18
|
if (type == '\\mdi') { return `mdi:${icon}`; }
|
|
@@ -36,7 +36,7 @@ export default class XPgMarkdownBasic extends HTMLElement {
|
|
|
36
36
|
}
|
|
37
37
|
return m;
|
|
38
38
|
}
|
|
39
|
-
}
|
|
39
|
+
});
|
|
40
40
|
|
|
41
41
|
this.$markdown.text = example;
|
|
42
42
|
|
package/pg/markdown/markdown.css
CHANGED
|
@@ -221,6 +221,17 @@ table code {
|
|
|
221
221
|
transform: translateY(-1px);
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
+
h1 > code,
|
|
225
|
+
h2 > code,
|
|
226
|
+
h3 > code,
|
|
227
|
+
h4 > code,
|
|
228
|
+
h5 > code {
|
|
229
|
+
border: 1px solid #DDD;
|
|
230
|
+
padding: 0.25rem 0.5rem;
|
|
231
|
+
border-radius: 0.5rem;
|
|
232
|
+
background: #F1F1F1;
|
|
233
|
+
}
|
|
234
|
+
|
|
224
235
|
p > svg.icon,
|
|
225
236
|
blockquote > svg.icon,
|
|
226
237
|
p > a.icon > svg.icon,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# `<pg-menu>`
|
|
2
|
+
|
|
3
|
+
The `pg-menu` component renders a menu list. Menus can be used inline, but are usually created by a parent component. For example:
|
|
4
|
+
|
|
5
|
+
- `pg-button-menu` - Button Menu
|
|
6
|
+
- Default item `type` is `PgMenuItem`
|
|
7
|
+
- `pg-button-icon-menu` - Button Icon Menu
|
|
8
|
+
- Default item `type` is `PgMenuItem`
|
|
9
|
+
- `PgMenuOverlay` Utility overlay for menus.
|
|
10
|
+
- The item `type` is required.
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import '@pictogrammers/components/pg/menu';
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```html
|
|
17
|
+
<pg-menu part="menu"></pg-menu>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
| Attributes | Tested | Description |
|
|
21
|
+
| ---------- | -------- | ----------- |
|
|
22
|
+
| `items` | | Set items list. Ex: `{ type: PgMenuItem }` |
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import PgMenuItem from '@pictogrammers/components/pg/menuItem';
|
|
26
|
+
|
|
27
|
+
// ...
|
|
28
|
+
@Part() $menu: PgMenu;
|
|
29
|
+
|
|
30
|
+
connectedCallback() {
|
|
31
|
+
this.$menu.items = [{
|
|
32
|
+
label: 'Item 1',
|
|
33
|
+
value: 'item1',
|
|
34
|
+
type: PgMenuItem
|
|
35
|
+
}];
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## CSS Variables
|
|
40
|
+
|
|
41
|
+
| Variable | Default |
|
|
42
|
+
| -------- | ------- |
|
|
43
|
+
| `--pg-menu-padding` | `0.25rem` |
|
|
44
|
+
| `--pg-menu-border-width` | `0` |
|
|
45
|
+
| `--pg-menu-background-color` | `transparent` |
|
|
46
|
+
| `--pg-menu-box-shadow` | `none` |
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Component, Part, Prop } from '@pictogrammers/element';
|
|
2
|
+
import PgMenu from '../../menu';
|
|
3
|
+
|
|
4
|
+
import PgMenuDivider from '../../../menuDivider/menuDivider';
|
|
5
|
+
|
|
6
|
+
import template from './basic.html';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'x-pg-menu-basic',
|
|
10
|
+
template
|
|
11
|
+
})
|
|
12
|
+
export default class XPgMenuBasic extends HTMLElement {
|
|
13
|
+
@Part() $menu: PgMenu;
|
|
14
|
+
@Part() $result: HTMLSpanElement;
|
|
15
|
+
|
|
16
|
+
connectedCallback() {
|
|
17
|
+
this.$menu.items = [{
|
|
18
|
+
label: 'Item 1',
|
|
19
|
+
value: 'item1'
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
label: 'Item 2',
|
|
23
|
+
value: 'item2'
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: PgMenuDivider
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
label: 'Item 3',
|
|
30
|
+
value: 'item3'
|
|
31
|
+
}];
|
|
32
|
+
this.$menu.addEventListener('select', this.#handleSelect.bind(this));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
previousItem: any = null;
|
|
36
|
+
#handleSelect(e: any) {
|
|
37
|
+
const { item } = e.detail;
|
|
38
|
+
if (this.previousItem !== null) {
|
|
39
|
+
this.previousItem.checked = false;
|
|
40
|
+
}
|
|
41
|
+
item.checked = true;
|
|
42
|
+
this.previousItem = item;
|
|
43
|
+
// update clicked result
|
|
44
|
+
this.$result.textContent = JSON.stringify(e.detail);
|
|
45
|
+
}
|
|
46
|
+
}
|
package/pg/menu/index.ts
ADDED
package/pg/menu/menu.css
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: contents;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
[part=items] {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
padding: var(--pg-menu-padding, 0.25rem);
|
|
9
|
+
border-width: var(--pg-menu-border-width, 1px);
|
|
10
|
+
border-color: var(--pg-menu-border-color, #453C4F);
|
|
11
|
+
border-style: solid;
|
|
12
|
+
border-radius: 0.5rem;
|
|
13
|
+
background-color: var(--pg-menu-background-color, #FFFFFF);
|
|
14
|
+
box-shadow: var(--pg-menu-box-shadow, none);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
[part=items].check {
|
|
18
|
+
--pg-menu-_has-check: true;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<div part="items"></div>
|