@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
package/package.json
CHANGED
package/pg/annoy/annoy.css
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
:host {
|
|
2
2
|
display: block;
|
|
3
3
|
position: var(--pg-annoy-position, fixed);
|
|
4
|
-
font-family: var(--pg-font-family);
|
|
4
|
+
font-family: var(--pg-font-family, system-ui);
|
|
5
5
|
width: var(--pg-annoy-width, 12rem);
|
|
6
6
|
height: var(--pg-annoy-height, auto);
|
|
7
7
|
max-height: var(--pg-annoy-max-height, auto);
|
package/pg/button/button.css
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
:host {
|
|
2
|
-
display:
|
|
2
|
+
display: inline-flex;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
[part="button"] {
|
|
6
6
|
display: flex;
|
|
7
7
|
align-items: center;
|
|
8
8
|
align-content: center;
|
|
9
|
-
font-family: var(--pg-font-family);
|
|
9
|
+
font-family: var(--pg-font-family, system-ui);
|
|
10
10
|
font-size: var(--pg-button-font-size, 1rem);
|
|
11
11
|
line-height: var(--pg-button-line-height, 1.5rem);
|
|
12
|
-
border: 1px solid var(--pg-button-border-color, #453C4F);
|
|
12
|
+
border: var(--pg-button-border-width, 1px) solid var(--pg-button-border-color, #453C4F);
|
|
13
13
|
background-color: var(--pg-button-background-color, #FFFFFF);
|
|
14
14
|
color: var(--pg-button-color, #453C4F);
|
|
15
15
|
padding: var(--pg-button-padding, 0.25rem 0.5rem);
|
|
16
16
|
border-radius: var(--pg-button-border-radius, 0.25rem);
|
|
17
17
|
outline: none;
|
|
18
18
|
--pg-icon-color: var(--pg-button-color, #453C4F);
|
|
19
|
+
cursor: var(--pg-button-cursor, var(--pg-cursor-default, default));
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
[part="button"]:hover {
|
|
22
|
-
border:
|
|
23
|
+
--pg-button-border-color: var(--pg-button-hover-border-color, #453C4F);
|
|
23
24
|
background-color: var(--pg-button-hover-background-color, #453C4F);
|
|
24
25
|
color: var(--pg-button-hover-color, #FFFFFF);
|
|
25
26
|
--pg-icon-color: var(--pg-button-hover-color, #FFFFFF);
|
|
@@ -37,7 +37,7 @@ export default class XPgButtonMenuBasic extends HTMLElement {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
handleChange(e: any) {
|
|
40
|
-
const {
|
|
41
|
-
this.$value.textContent =
|
|
40
|
+
const { indexes, item } = e.detail;
|
|
41
|
+
this.$value.textContent = `indexes: ${indexes.join(',')}; item: ${JSON.stringify(item)}`;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -52,9 +52,12 @@ export default class PgButtonMenu extends HTMLElement {
|
|
|
52
52
|
});
|
|
53
53
|
this.$icon.path = IconExpand;
|
|
54
54
|
if (result !== undefined) {
|
|
55
|
+
const { indexes, item } = result;
|
|
55
56
|
this.dispatchEvent(new CustomEvent('change', {
|
|
56
57
|
detail: {
|
|
57
|
-
|
|
58
|
+
indexes,
|
|
59
|
+
item,
|
|
60
|
+
value: item.value
|
|
58
61
|
}
|
|
59
62
|
}));
|
|
60
63
|
}
|
package/pg/cardUser/cardUser.css
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { Component, Part, Prop } from '@pictogrammers/element';
|
|
2
|
-
|
|
3
|
-
import PgTooltip from 'pg/tooltip';
|
|
4
|
-
import { Icon } from '../../../shared/models/icon';
|
|
5
|
-
import PgGrid from '../../grid';
|
|
2
|
+
|
|
6
3
|
|
|
7
4
|
import template from './basic.html';
|
|
8
5
|
|
package/pg/grid/grid.css
CHANGED
package/pg/header/header.css
CHANGED
|
@@ -14,6 +14,7 @@ const PATH_CHECKED = 'M19 19L5 19V5H15V3H5C3.89 3 3 3.89 3 5V19C3 20.1 3.89 21 5
|
|
|
14
14
|
export default class PgInputCheck extends HTMLElement {
|
|
15
15
|
@Prop() value: string | boolean = false;
|
|
16
16
|
@Prop() disabled: boolean = false;
|
|
17
|
+
@Prop() readOnly: boolean = false;
|
|
17
18
|
|
|
18
19
|
@Part() $button: HTMLButtonElement;
|
|
19
20
|
@Part() $path: SVGPathElement;
|
|
@@ -38,5 +39,8 @@ export default class PgInputCheck extends HTMLElement {
|
|
|
38
39
|
if (changes.disabled) {
|
|
39
40
|
this.$button.disabled = ['', true, 'true'].includes(this.disabled);
|
|
40
41
|
}
|
|
42
|
+
if (changes.readOnly) {
|
|
43
|
+
this.$button.classList.toggle('readonly', this.readOnly);
|
|
44
|
+
}
|
|
41
45
|
}
|
|
42
46
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
display: grid;
|
|
7
7
|
grid-template-columns: 1.5rem auto;
|
|
8
8
|
grid-template-rows: auto;
|
|
9
|
-
font-family: var(--pg-font-family);
|
|
9
|
+
font-family: var(--pg-font-family, system-ui);
|
|
10
10
|
font-size: 1rem;
|
|
11
11
|
line-height: 1.5rem;
|
|
12
12
|
border: 1px solid var(--pg-button-border-color, #453C4F);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# `<pg-input-number>`
|
|
2
|
+
|
|
3
|
+
The `pg-input-number` component creates an input that accepts number input.
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
import '@pictogrammers/components/pgInputNumber';
|
|
7
|
+
import PgInputNumber from '@pictogrammers/components/pgInputText';
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```html
|
|
11
|
+
<pg-input-number value="50"></pg-input-number>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Attributes
|
|
15
|
+
|
|
16
|
+
| Attributes | Tested | Description |
|
|
17
|
+
| ----------- | -------- | ----------- |
|
|
18
|
+
| name | | Unique name in `pg-form` |
|
|
19
|
+
| value | | Field value |
|
|
20
|
+
| placeholder | | Placeholder text |
|
|
21
|
+
|
|
22
|
+
## Events
|
|
23
|
+
|
|
24
|
+
| Events | Tested | Description |
|
|
25
|
+
| ---------- | -------- | ----------- |
|
|
26
|
+
| change | | `{ detail: { value }` |
|
|
27
|
+
| input | | `{ detail: { value }` |
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Component, Part, Prop } from '@pictogrammers/element';
|
|
2
|
+
import PgInputNumber from '../../inputNumber';
|
|
3
|
+
|
|
4
|
+
import template from './basic.html';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
selector: 'x-pg-input-number-basic',
|
|
8
|
+
template
|
|
9
|
+
})
|
|
10
|
+
export default class XPgInputNumberBasic extends HTMLElement {
|
|
11
|
+
|
|
12
|
+
@Part() $input: PgInputNumber;
|
|
13
|
+
@Part() $value1: HTMLSpanElement;
|
|
14
|
+
@Part() $value2: HTMLSpanElement;
|
|
15
|
+
|
|
16
|
+
connectedCallback() {
|
|
17
|
+
this.$input.addEventListener('change', this.#handleChange.bind(this));
|
|
18
|
+
this.$input.addEventListener('input', this.#handleInput.bind(this));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
#handleChange(e: CustomEvent) {
|
|
22
|
+
const { value } = e.detail;
|
|
23
|
+
this.$value1.textContent = value;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#handleInput(e: CustomEvent) {
|
|
27
|
+
const { value } = e.detail;
|
|
28
|
+
this.$value2.textContent = value;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
font-family: var(--pg-font-family, system-ui);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
[part=input] {
|
|
7
|
+
border: 1px solid var(--pg-input-text-border-color, #453C4F);
|
|
8
|
+
border-radius: 0.125rem;
|
|
9
|
+
padding: var(--pg-input-text-padding, calc(0.5rem - 1px) 0.75rem);
|
|
10
|
+
font-family: var(--pg-input-number-font-family, var(--pg-font-family));
|
|
11
|
+
font-size: 1rem;
|
|
12
|
+
outline: none;
|
|
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;
|
|
17
|
+
appearance: textfield;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
[part=input]::-webkit-outer-spin-button,
|
|
21
|
+
[part=input]::-webkit-inner-spin-button {
|
|
22
|
+
-webkit-appearance: none;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
[part=input]:read-only {
|
|
26
|
+
border-color: transparent;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
[part=input]:active {
|
|
30
|
+
box-shadow: 0 0 0 3px var(--pg-input-text-active-glow, rgb(79, 143, 249, 0.6));
|
|
31
|
+
}
|
|
32
|
+
[part=input]:focus {
|
|
33
|
+
box-shadow: 0 0 0 3px var(--pg-input-text-focus-glow, rgb(79, 143, 249, 0.5));
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<input part="input" type="number" />
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { selectComponent, getProps } from '@pictogrammers/element';
|
|
2
|
+
|
|
3
|
+
import './inputNumber';
|
|
4
|
+
import PgInputText from './inputNumber';
|
|
5
|
+
|
|
6
|
+
const PG_INPUT_TEXT = 'pg-input-text';
|
|
7
|
+
|
|
8
|
+
describe('pg-input-text', () => {
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
var c = document.createElement(PG_INPUT_TEXT);
|
|
12
|
+
document.body.appendChild(c);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
while (document.body.firstChild) {
|
|
17
|
+
document.body.removeChild(document.body.firstChild);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should be registered', () => {
|
|
22
|
+
expect(customElements.get(PG_INPUT_TEXT)).toBeDefined();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should only expose known props', () => {
|
|
26
|
+
const props = getProps(PG_INPUT_TEXT);
|
|
27
|
+
expect(props.length).toBe(3);
|
|
28
|
+
expect(props).toContain('name');
|
|
29
|
+
expect(props).toContain('value');
|
|
30
|
+
expect(props).toContain('placeholder');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should default value to empty', () => {
|
|
34
|
+
const component = selectComponent<PgInputText>(PG_INPUT_TEXT);
|
|
35
|
+
const { $input } = component;
|
|
36
|
+
expect($input.value).toEqual('');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('should set value to "Hello World!"', () => {
|
|
40
|
+
const component = selectComponent<PgInputText>(PG_INPUT_TEXT);
|
|
41
|
+
component.value = 'Hello World!';
|
|
42
|
+
const { $input } = component;
|
|
43
|
+
expect($input.value).toEqual('Hello World!');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should default placeholder to empty', () => {
|
|
47
|
+
const component = selectComponent<PgInputText>(PG_INPUT_TEXT);
|
|
48
|
+
const { $input } = component;
|
|
49
|
+
expect($input.placeholder).toEqual('');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should set placeholder to "Hello World!"', () => {
|
|
53
|
+
const component = selectComponent<PgInputText>(PG_INPUT_TEXT);
|
|
54
|
+
component.placeholder = 'Hello World!';
|
|
55
|
+
const { $input } = component;
|
|
56
|
+
expect($input.placeholder).toEqual('Hello World!');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Component, Prop, Part } from '@pictogrammers/element';
|
|
2
|
+
|
|
3
|
+
import template from './inputNumber.html';
|
|
4
|
+
import style from './inputNumber.css';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
selector: 'pg-input-number',
|
|
8
|
+
style,
|
|
9
|
+
template,
|
|
10
|
+
})
|
|
11
|
+
export default class PgInputNumber extends HTMLElement {
|
|
12
|
+
@Prop() name: string = '';
|
|
13
|
+
@Prop() value: string = '';
|
|
14
|
+
@Prop() placeholder: string = '';
|
|
15
|
+
@Prop() readOnly: boolean = false;
|
|
16
|
+
|
|
17
|
+
@Part() $input: HTMLInputElement;
|
|
18
|
+
|
|
19
|
+
connectedCallback() {
|
|
20
|
+
this.$input.addEventListener('input', this.handleInput.bind(this));
|
|
21
|
+
this.$input.addEventListener('change', this.handleChange.bind(this));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
skipValue = false;
|
|
25
|
+
|
|
26
|
+
render(changes) {
|
|
27
|
+
if (changes.value && !this.skipValue) {
|
|
28
|
+
this.$input.value = this.value;
|
|
29
|
+
}
|
|
30
|
+
if (changes.placeholder) {
|
|
31
|
+
this.$input.placeholder = this.placeholder;
|
|
32
|
+
}
|
|
33
|
+
if (changes.readOnly) {
|
|
34
|
+
this.$input.readOnly = this.readOnly;
|
|
35
|
+
}
|
|
36
|
+
this.skipValue = false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
handleInput(e) {
|
|
40
|
+
e.stopPropagation();
|
|
41
|
+
this.skipValue = true;
|
|
42
|
+
this.value = e.target.value;
|
|
43
|
+
this.dispatchEvent(
|
|
44
|
+
new CustomEvent('input', {
|
|
45
|
+
detail: {
|
|
46
|
+
value: e.target.value,
|
|
47
|
+
name: e.name
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
handleChange(e) {
|
|
54
|
+
this.dispatchEvent(
|
|
55
|
+
new CustomEvent('change', {
|
|
56
|
+
detail: {
|
|
57
|
+
value: e.target.value,
|
|
58
|
+
name: e.name
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|