@pictogrammers/components 0.5.4 → 0.5.6
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/inputText/inputText.ts +4 -0
- package/pg/modalConfirm/index.ts +3 -0
- package/pg/modalConfirm/modalConfirm.ts +6 -0
- package/pg/overlay/overlay.ts +5 -1
- package/pg/modalAlert copy/modalAlert.css +0 -40
- package/pg/modalAlert copy/modalAlert.html +0 -22
- package/pg/modalAlert copy/modalAlert.ts +0 -59
package/package.json
CHANGED
|
@@ -57,5 +57,11 @@ export default class PgModalConfirm extends PgOverlay {
|
|
|
57
57
|
if (changes.message) {
|
|
58
58
|
this.$message.textContent = this.message;
|
|
59
59
|
}
|
|
60
|
+
if (changes.okay) {
|
|
61
|
+
this.$okay.textContent = this.okay;
|
|
62
|
+
}
|
|
63
|
+
if (changes.cancel) {
|
|
64
|
+
this.$cancel.textContent = this.cancel;
|
|
65
|
+
}
|
|
60
66
|
}
|
|
61
67
|
}
|
package/pg/overlay/overlay.ts
CHANGED
|
@@ -3,9 +3,13 @@ import { Component, Prop } from '@pictogrammers/element';
|
|
|
3
3
|
const layers: Set<HTMLElement> = new Set();
|
|
4
4
|
const promises: Map<HTMLElement, (value: any) => void> = new Map();
|
|
5
5
|
|
|
6
|
+
type OmitByPrefix<T, Prefix extends string> = {
|
|
7
|
+
[K in keyof T as K extends `${Prefix}${string}` ? never : K]: T[K];
|
|
8
|
+
};
|
|
9
|
+
|
|
6
10
|
@Component()
|
|
7
11
|
export default class PgOverlay extends HTMLElement {
|
|
8
|
-
static open<T extends typeof PgOverlay>(this: T, props: Partial<Omit<InstanceType<T>, keyof PgOverlay>>): Promise<any> {
|
|
12
|
+
static open<T extends typeof PgOverlay>(this: T, props: Partial<OmitByPrefix<Omit<InstanceType<T>, keyof PgOverlay>, '$'>>): Promise<any> {
|
|
9
13
|
var ele = document.createElement(this.name);
|
|
10
14
|
props && Object.assign(ele, props);
|
|
11
15
|
document.body.appendChild(ele);
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
.backdrop {
|
|
2
|
-
display: flex;
|
|
3
|
-
position: fixed;
|
|
4
|
-
top: 0;
|
|
5
|
-
left: 0;
|
|
6
|
-
right: 0;
|
|
7
|
-
bottom: 0;
|
|
8
|
-
background: rgba(0, 0, 0, 0.6);
|
|
9
|
-
justify-content: center;
|
|
10
|
-
align-items: center;
|
|
11
|
-
}
|
|
12
|
-
.dialog {
|
|
13
|
-
background: #fff;
|
|
14
|
-
border-radius: 0.5rem;
|
|
15
|
-
box-shadow: 0 1px 1rem rgba(0, 0, 0, 0.5);
|
|
16
|
-
overflow: hidden;
|
|
17
|
-
min-width: 15rem;
|
|
18
|
-
}
|
|
19
|
-
header {
|
|
20
|
-
border-bottom: 1px solid #ccc;
|
|
21
|
-
background: #f1f1f1;
|
|
22
|
-
padding: 0.75rem 1rem;
|
|
23
|
-
}
|
|
24
|
-
header h2 {
|
|
25
|
-
font-size: 1.25rem;
|
|
26
|
-
margin: 0;
|
|
27
|
-
font-weight: normal;
|
|
28
|
-
}
|
|
29
|
-
main {
|
|
30
|
-
padding: 0.5rem 1rem;
|
|
31
|
-
}
|
|
32
|
-
footer {
|
|
33
|
-
display: flex;
|
|
34
|
-
flex-direction: row;
|
|
35
|
-
padding: 0.75rem 1rem;
|
|
36
|
-
border-top: 1px solid #ccc;
|
|
37
|
-
background: #f1f1f1;
|
|
38
|
-
justify-content: flex-end;
|
|
39
|
-
gap: 0.5rem;
|
|
40
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<div class="backdrop">
|
|
2
|
-
<div class="dialog"
|
|
3
|
-
role="dialog"
|
|
4
|
-
id="dialog1"
|
|
5
|
-
aria-labelledby="dialog_label"
|
|
6
|
-
aria-modal="true">
|
|
7
|
-
<header part="header">
|
|
8
|
-
<h2 id="dialog_label"
|
|
9
|
-
class="dialog_label"
|
|
10
|
-
part="headerText">
|
|
11
|
-
Add Delivery Address
|
|
12
|
-
</h2>
|
|
13
|
-
</header>
|
|
14
|
-
<main>
|
|
15
|
-
<p part="message"></p>
|
|
16
|
-
</main>
|
|
17
|
-
<footer>
|
|
18
|
-
<pg-button part="no">No</pg-button>
|
|
19
|
-
<pg-button part="yes" variant="brand">Yes</pg-button>
|
|
20
|
-
</footer>
|
|
21
|
-
</div>
|
|
22
|
-
</div>
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { Component, Prop, Part } from '@pictogrammers/element';
|
|
2
|
-
|
|
3
|
-
import template from './modalAlert.html';
|
|
4
|
-
import style from './modalAlert.css';
|
|
5
|
-
|
|
6
|
-
import PgOverlay from '../overlay/overlay';
|
|
7
|
-
import PgButton from '../button/button';
|
|
8
|
-
|
|
9
|
-
@Component({
|
|
10
|
-
selector: 'pg-modal-alert',
|
|
11
|
-
template,
|
|
12
|
-
style
|
|
13
|
-
})
|
|
14
|
-
export default class PgModalAlert extends PgOverlay {
|
|
15
|
-
@Prop() header: string = 'Are you sure?';
|
|
16
|
-
@Prop() message: string = 'Are you sure?';
|
|
17
|
-
|
|
18
|
-
@Part() $header: HTMLDivElement;
|
|
19
|
-
@Part() $headerText: HTMLHeadingElement;
|
|
20
|
-
@Part() $message: HTMLDivElement;
|
|
21
|
-
@Part() $yes: PgButton;
|
|
22
|
-
@Part() $no: PgButton;
|
|
23
|
-
|
|
24
|
-
#cacheKeydownHandler: any;
|
|
25
|
-
|
|
26
|
-
connectedCallback() {
|
|
27
|
-
this.$yes.addEventListener('click', this.#handleYes.bind(this));
|
|
28
|
-
this.$no.addEventListener('click', this.#handleNo.bind(this));
|
|
29
|
-
this.#cacheKeydownHandler ??= this.#handleKeyDown.bind(this);
|
|
30
|
-
document.addEventListener('keydown', this.#cacheKeydownHandler);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
disconnectedCallback() {
|
|
34
|
-
document.removeEventListener('keydown', this.#cacheKeydownHandler);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
#handleKeyDown(e: KeyboardEvent) {
|
|
38
|
-
if (e.key === 'Escape') {
|
|
39
|
-
this.close(null);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
#handleYes() {
|
|
44
|
-
this.close(true);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
#handleNo() {
|
|
48
|
-
this.close(false);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
render(changes) {
|
|
52
|
-
if (changes.header) {
|
|
53
|
-
this.$headerText.innerText = this.header;
|
|
54
|
-
}
|
|
55
|
-
if (changes.message) {
|
|
56
|
-
this.$message.innerText = this.message;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|