Skip to content

Commit dca7c52

Browse files
committed
Fixes array issues.
1 parent f431afb commit dca7c52

File tree

16 files changed

+184
-24
lines changed

16 files changed

+184
-24
lines changed

src/pg/grid/__examples__/basic/basic.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ export default class XPgGridBasic extends HTMLElement {
7777
if (count === -1) {
7878
this.$grid.icons = this.icons;
7979
}
80-
this.$grid.icons = this.icons.slice(0, count);
80+
// update array, fix later
81+
this.$grid.icons.push(...this.icons.slice(0, count));
8182
}
8283

8384
async handleSync(e: CustomEvent) {

src/pg/inputCheckList/__examples__/basic/basic.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ export default class XPgInputCheckListBasic extends HTMLElement {
1313
@Part() $value: HTMLSpanElement;
1414

1515
connectedCallback() {
16-
this.$input.value = ['uuid1', 'uuid3'];
17-
this.$input.options = [
16+
this.$input.value.push('uuid1', 'uuid3');
17+
this.$input.options.push(
1818
{ value: 'uuid1', label: 'Item 1' },
1919
{ value: 'uuid2', label: 'Item 2' },
2020
{ value: 'uuid3', label: 'Item 3', disabled: true },
2121
{ value: 'uuid4', label: 'Item 4' }
22-
];
22+
);
2323
this.$value.innerText = this.$input.value.join(',');
2424
this.$input.addEventListener('change', this.handleChange.bind(this));
2525
}

src/pg/inputSelect/__examples__/basic/basic.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ export default class XPgInputSelectBasic extends HTMLElement {
1313
@Part() $value: HTMLSpanElement;
1414

1515
connectedCallback() {
16-
this.$input.options = [
16+
this.$input.options.push(
1717
{ label: 'Option 1', value: 'option1' },
1818
{ label: 'Option 2', value: 'option2' },
1919
{ label: 'Option 3', value: 'option3' },
2020
{ label: 'Option 4', value: 'option4' }
21-
];
21+
);
2222
this.$input.value = this.$input.options[1].value;
2323
this.$input.addEventListener('change', this.handleChange.bind(this));
2424
}

src/pg/listTag/__examples__/basic/basic.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,24 @@ export default class XPgIconBasic extends HTMLElement {
2121
this.$buttonAdd.addEventListener('click', this.handleAdd.bind(this));
2222
this.$buttonRemove.addEventListener('click', this.handleRemove.bind(this));
2323
this.$buttonEdit.addEventListener('click', this.handleEdit.bind(this));
24-
this.$tags.items = tags;
24+
this.$tags.items.push(...tags);
2525
}
2626

2727
handleClear() {
28-
this.$tags.items = [];
28+
this.$tags.items.splice(0, this.$tags.items.length)
2929
}
3030

3131
uuid = 4;
3232

3333
handleAdd() {
34-
this.$tags.items = [
35-
...this.$tags.items,
34+
this.$tags.items.push(
3635
new Tag().from({
3736
id: `uuid${this.uuid++}`,
3837
count: 42,
3938
name: 'Foo Bar',
4039
url: 'foo-bar'
4140
})
42-
];
41+
);
4342
}
4443

4544
handleRemove() {

src/pg/markdown/__examples__/basic/basic.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default class XPgMarkdownBasic extends HTMLElement {
1212
@Part() $markdown: PgMarkdown;
1313

1414
connectedCallback() {
15-
this.$markdown.replace = [{
15+
this.$markdown.replace.push({
1616
find: new RegExp('(\\\\mdi|mdi|icon):([a-z0-9-]+):?([#a-z0-9-]+)?', 'g'),
1717
replace: (m, type, icon, color) => {
1818
if (type == '\\mdi') { return `mdi:${icon}`; }
@@ -36,7 +36,7 @@ export default class XPgMarkdownBasic extends HTMLElement {
3636
}
3737
return m;
3838
}
39-
}];
39+
});
4040

4141
this.$markdown.text = example;
4242

src/pg/search/__examples__/basic/basic.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import PgSearch from '../../search';
33
import { mdiAccount, mdiAccountBox, mdiAccountCircle } from './constants';
44

55
import template from './basic.html';
6+
import { Alias } from '../../../shared/models/alias';
7+
import { Icon } from '../../../shared/models/icon';
68

79
@Component({
810
selector: 'x-pg-search-basic',
@@ -12,18 +14,19 @@ export default class XPgSearchBasic extends HTMLElement {
1214
@Part() $search: PgSearch;
1315

1416
connectedCallback() {
15-
this.$search.items = [
17+
this.$search.items.push(
1618
{ type: 'Documentation', name: 'Android', url: '/getting-started/android' },
1719
{ type: 'Documentation', name: 'Angular', url: '/getting-started/angular' },
1820
{ type: 'Documentation', name: 'AngularJS', url: '/getting-started/angularjs' },
1921
{ type: 'Documentation', name: 'Bootstrap', url: '/getting-started/bootstrap' },
2022
{ type: 'Documentation', name: 'How to Play Football', url: '/getting-started/football' },
2123
{ type: 'Documentation', name: 'Foo Angular Foo Angular', url: '/getting-started/bootstraps' }
22-
];
23-
this.$search.icons = [
24-
{ name: 'account', data: mdiAccount, aliases: [{ name: 'user' }] },
25-
{ name: 'account-box', data: mdiAccountBox, aliases: [{ name: 'user-box' }] },
26-
{ name: 'account-circle', data: mdiAccountCircle, aliases: [{ name: 'user-circle' }] }
27-
] as any;
24+
);
25+
// fix types later
26+
this.$search.icons.push(
27+
//(new Icon()).from({ name: 'account', data: mdiAccount, aliases: [(new Alias()).from({ name: 'user' })] }),
28+
//{ name: 'account-box', data: mdiAccountBox, aliases: [(new Alias()).from({ name: 'user-box' })] },
29+
//{ name: 'account-circle', data: mdiAccountCircle, aliases: [(new Alias()).from({ name: 'user-circle' })] }
30+
);
2831
}
2932
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
<div>
22
<pg-tree part="tree"></pg-tree>
3+
<h2>Tools</h2>
4+
<button part="addItem">Add Item</button>
35
</div>

src/pg/tree/__examples__/basic/basic.ts

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,61 @@ import { Component, Part, Prop } from '@pictogrammers/element';
22
import PgTree from '../../tree';
33

44
import template from './basic.html';
5+
import PgTreeButtonIcon from '../../../treeButtonIcon/treeButtonIcon';
6+
7+
const IconEye = 'M12,9A3,3 0 0,0 9,12A3,3 0 0,0 12,15A3,3 0 0,0 15,12A3,3 0 0,0 12,9M12,17A5,5 0 0,1 7,12A5,5 0 0,1 12,7A5,5 0 0,1 17,12A5,5 0 0,1 12,17M12,4.5C7,4.5 2.73,7.61 1,12C2.73,16.39 7,19.5 12,19.5C17,19.5 21.27,16.39 23,12C21.27,7.61 17,4.5 12,4.5Z';
58

69
@Component({
710
selector: 'x-pg-tree-basic',
811
template
912
})
1013
export default class XPgTreeBasic extends HTMLElement {
1114
@Part() $tree: PgTree;
15+
@Part() $addItem: HTMLButtonElement;
1216

1317
connectedCallback() {
14-
this.$tree.items = [{
18+
this.$tree.addEventListener('action', (e) => {
19+
// action clicked
20+
console.log('action')
21+
});
22+
this.$tree.addEventListener('rename', (e) => {
23+
// action clicked
24+
});
25+
this.$tree.addEventListener('menu', (e) => {
26+
// action clicked
27+
});
28+
this.$tree.items.push({
1529
key: 1,
30+
icon: {
31+
path: IconEye
32+
},
1633
label: 'Item 1',
34+
actions: [{
35+
type: PgTreeButtonIcon,
36+
icon: {
37+
path: IconEye
38+
}
39+
},
40+
{
41+
type: PgTreeButtonIcon,
42+
label: 'Delete',
43+
icon: {
44+
path: IconEye
45+
}
46+
}]
1747
},
1848
{
1949
key: 2,
2050
label: 'Item 2'
21-
}]
51+
});
52+
53+
let next: number = 2;
54+
this.$addItem.addEventListener('click', () => {
55+
next++;
56+
this.$tree.items.push({
57+
key: `${next}`,
58+
label: `Item ${next}`
59+
});
60+
});
2261
}
2362
}

src/pg/tree/tree.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
:host {
2+
display: contents;
3+
}
4+
5+
[part="items"] {
6+
display: flex;
7+
flex-direction: column;
8+
}

src/pg/treeButtonIcon/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Tree Button Icon

0 commit comments

Comments
 (0)