@vonage/vivid 4.8.0 → 4.9.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/custom-elements.json +75 -1
- package/lib/breadcrumb/breadcrumb.d.ts +4 -1
- package/lib/breadcrumb-item/breadcrumb-item.d.ts +5 -3
- package/package.json +1 -1
- package/shared/breadcrumb-item.cjs +162 -20
- package/shared/breadcrumb-item.js +163 -21
- package/shared/definition10.cjs +52 -68
- package/shared/definition10.js +54 -70
- package/shared/definition20.cjs +73 -54
- package/shared/definition20.js +73 -54
- package/shared/definition21.cjs +27 -12
- package/shared/definition21.js +27 -12
- package/shared/definition46.cjs +24 -9
- package/shared/definition46.js +24 -9
- package/shared/definition9.cjs +1 -19
- package/shared/definition9.js +2 -20
- package/shared/patterns/anchor.d.ts +18 -0
- package/shared/patterns/anchored.d.ts +4 -4
- package/shared/patterns/aria-global.d.ts +21 -0
- package/shared/text-anchor.cjs +84 -2
- package/shared/text-anchor.js +84 -2
- package/styles/core/all.css +1 -1
- package/styles/core/theme.css +1 -1
- package/styles/core/typography.css +1 -1
- package/styles/tokens/theme-dark.css +4 -4
- package/styles/tokens/theme-light.css +4 -4
- package/styles/tokens/vivid-2-compat.css +1 -1
- package/shared/anchor.cjs +0 -90
- package/shared/anchor.js +0 -87
package/shared/definition10.js
CHANGED
|
@@ -1,73 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as html, F as FoundationElement, o as observable, r as registerFactory } from './index.js';
|
|
2
2
|
import { s as slotted, e as elements } from './slotted.js';
|
|
3
|
-
import { B as BreadcrumbItem
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A Breadcrumb Custom HTML Element.
|
|
7
|
-
* @slot - The default slot for the breadcrumb items
|
|
8
|
-
* @csspart list - The element wrapping the slotted items
|
|
9
|
-
*
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
let Breadcrumb$1 = class Breadcrumb extends FoundationElement {
|
|
13
|
-
slottedBreadcrumbItemsChanged() {
|
|
14
|
-
if (this.$fastController.isConnected) {
|
|
15
|
-
if (this.slottedBreadcrumbItems === undefined ||
|
|
16
|
-
this.slottedBreadcrumbItems.length === 0) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
const lastNode = this.slottedBreadcrumbItems[this.slottedBreadcrumbItems.length - 1];
|
|
20
|
-
this.slottedBreadcrumbItems.forEach((item) => {
|
|
21
|
-
const itemIsLastNode = item === lastNode;
|
|
22
|
-
this.setItemSeparator(item, itemIsLastNode);
|
|
23
|
-
this.setAriaCurrent(item, itemIsLastNode);
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
setItemSeparator(item, isLastNode) {
|
|
28
|
-
if (item instanceof BreadcrumbItem$1) {
|
|
29
|
-
item.separator = !isLastNode;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Finds href on childnodes in the light DOM or shadow DOM.
|
|
34
|
-
* We look in the shadow DOM because we insert an anchor when breadcrumb-item has an href.
|
|
35
|
-
*/
|
|
36
|
-
findChildWithHref(node) {
|
|
37
|
-
var _a, _b;
|
|
38
|
-
if (node.childElementCount > 0) {
|
|
39
|
-
return node.querySelector("a[href]");
|
|
40
|
-
}
|
|
41
|
-
else if ((_a = node.shadowRoot) === null || _a === void 0 ? void 0 : _a.childElementCount) {
|
|
42
|
-
return (_b = node.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector("a[href]");
|
|
43
|
-
}
|
|
44
|
-
else
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Sets ARIA Current for the current node
|
|
49
|
-
* If child node with an anchor tag and with href is found then set aria-current to correct value for the child node,
|
|
50
|
-
* otherwise apply aria-current to the host element, with an href
|
|
51
|
-
*/
|
|
52
|
-
setAriaCurrent(item, isLastNode) {
|
|
53
|
-
const childNodeWithHref = this.findChildWithHref(item);
|
|
54
|
-
if (childNodeWithHref === null &&
|
|
55
|
-
item.hasAttribute("href") &&
|
|
56
|
-
item instanceof BreadcrumbItem$1) {
|
|
57
|
-
isLastNode
|
|
58
|
-
? item.setAttribute("aria-current", "page")
|
|
59
|
-
: item.removeAttribute("aria-current");
|
|
60
|
-
}
|
|
61
|
-
else if (childNodeWithHref !== null) {
|
|
62
|
-
isLastNode
|
|
63
|
-
? childNodeWithHref.setAttribute("aria-current", "page")
|
|
64
|
-
: childNodeWithHref.removeAttribute("aria-current");
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
__decorate([
|
|
69
|
-
observable
|
|
70
|
-
], Breadcrumb$1.prototype, "slottedBreadcrumbItems", void 0);
|
|
3
|
+
import { B as BreadcrumbItem } from './breadcrumb-item.js';
|
|
71
4
|
|
|
72
5
|
const breadcrumbTemplate = () => html`
|
|
73
6
|
<nav aria-label="breadcrumbs" class="base">
|
|
@@ -84,8 +17,59 @@ const breadcrumbTemplate = () => html`
|
|
|
84
17
|
|
|
85
18
|
const styles = ".list{display:flex}";
|
|
86
19
|
|
|
87
|
-
|
|
20
|
+
var __defProp = Object.defineProperty;
|
|
21
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
22
|
+
var result = void 0 ;
|
|
23
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
24
|
+
if (decorator = decorators[i])
|
|
25
|
+
result = (decorator(target, key, result) ) || result;
|
|
26
|
+
if (result) __defProp(target, key, result);
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
29
|
+
class Breadcrumb extends FoundationElement {
|
|
30
|
+
/**
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
slottedBreadcrumbItemsChanged(_, newItems) {
|
|
34
|
+
if (newItems) {
|
|
35
|
+
newItems.forEach((item, index) => {
|
|
36
|
+
const itemIsLastNode = index === newItems.length - 1;
|
|
37
|
+
this.setItemSeparator(item, itemIsLastNode);
|
|
38
|
+
this.setAriaCurrent(item, itemIsLastNode);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
setItemSeparator(item, isLastNode) {
|
|
43
|
+
if (item instanceof BreadcrumbItem) {
|
|
44
|
+
item.separator = !isLastNode;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Finds href on childnodes in the light DOM or shadow DOM.
|
|
49
|
+
* We look in the shadow DOM because we insert an anchor when breadcrumb-item has an href.
|
|
50
|
+
*/
|
|
51
|
+
findChildWithHref(node) {
|
|
52
|
+
if (node.childElementCount > 0) {
|
|
53
|
+
return node.querySelector("a[href]");
|
|
54
|
+
} else if (node.shadowRoot) {
|
|
55
|
+
return node.shadowRoot.querySelector("a[href]");
|
|
56
|
+
} else return null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Sets ARIA Current for the current node
|
|
60
|
+
* If child node with an anchor tag and with href is found then set aria-current to correct value for the child node,
|
|
61
|
+
* otherwise apply aria-current to the host element, with an href
|
|
62
|
+
*/
|
|
63
|
+
setAriaCurrent(item, isLastNode) {
|
|
64
|
+
const childNodeWithHref = this.findChildWithHref(item);
|
|
65
|
+
if (childNodeWithHref !== null) {
|
|
66
|
+
isLastNode ? childNodeWithHref.setAttribute("aria-current", "page") : childNodeWithHref.removeAttribute("aria-current");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
88
69
|
}
|
|
70
|
+
__decorateClass([
|
|
71
|
+
observable
|
|
72
|
+
], Breadcrumb.prototype, "slottedBreadcrumbItems");
|
|
89
73
|
|
|
90
74
|
const breadcrumbDefinition = Breadcrumb.compose({
|
|
91
75
|
baseName: "breadcrumb",
|
package/shared/definition20.cjs
CHANGED
|
@@ -9,6 +9,7 @@ const icon = require('./icon.cjs');
|
|
|
9
9
|
const when = require('./when.cjs');
|
|
10
10
|
const classNames = require('./class-names.cjs');
|
|
11
11
|
const ref = require('./ref.cjs');
|
|
12
|
+
const repeat = require('./repeat.cjs');
|
|
12
13
|
const keyCodes = require('./key-codes2.cjs');
|
|
13
14
|
|
|
14
15
|
const styles = ":host{display:inline-block;margin:16px;inline-size:230px}.base{display:grid;box-sizing:border-box;grid-template-rows:80px 1fr auto}.base.no-input{grid-template-rows:1fr auto}.digits{display:grid;gap:16px;grid-template-columns:repeat(3,1fr);grid-template-rows:repeat(4,1fr);inline-size:100%}.phone-field{align-self:flex-start;grid-column:1/-1}.digit-btn{--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: transparent;--_appearance-color-outline: var(--_connotation-color-pale)}.digit-btn:where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: transparent;--_appearance-color-outline: var(--_connotation-color-firm-all)}.digit-btn:where(.disabled,:disabled){--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: transparent;--_appearance-color-outline: var(--vvd-color-neutral-100)}.digit-btn{--_connotation-color-contrast: var(--vvd-dial-pad-accent-contrast, var(--vvd-color-neutral-800));--_connotation-color-soft: var(--vvd-dial-pad-accent-soft, var(--vvd-color-neutral-100));--_connotation-color-pale: var(--vvd-dial-pad-accent-pale, var(--vvd-color-neutral-300));--_connotation-color-fierce: var(--vvd-dial-pad-accent-fierce, var(--vvd-color-neutral-700));--_connotation-color-firm-all: var(--vvd-dial-pad-accent-firm-all, var(--vvd-color-neutral-600));--_connotation-color-faint: var(--vvd-dial-pad-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-dim: var(--vvd-dial-pad-accent-dim, var(--vvd-color-neutral-200))}.digit-btn{--vvd-button-accent-firm: var(--_appearance-color-text);display:flex;overflow:hidden;flex-direction:column;border-radius:16px;box-shadow:0 0 0 1px var(--_appearance-color-outline);inline-size:100%}.digit-btn:not(.disabled) .digit-btn-num{color:var(--vvd-color-canvas-text)}.call-btn{margin-top:32px;grid-column:1/-1}";
|
|
@@ -36,16 +37,6 @@ class DialPad extends index.FoundationElement {
|
|
|
36
37
|
this.noInput = false;
|
|
37
38
|
this.endCallButtonLabel = null;
|
|
38
39
|
this.callButtonLabel = null;
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
41
|
-
* @internal
|
|
42
|
-
*/
|
|
43
|
-
this._onDigit = (e) => {
|
|
44
|
-
this.value += e.currentTarget.value;
|
|
45
|
-
this.$emit("keypad-click", e.currentTarget);
|
|
46
|
-
this.$emit("input");
|
|
47
|
-
this.$emit("change");
|
|
48
|
-
};
|
|
49
40
|
/**
|
|
50
41
|
*
|
|
51
42
|
* @internal
|
|
@@ -104,18 +95,55 @@ __decorateClass([
|
|
|
104
95
|
], DialPad.prototype, "callButtonLabel");
|
|
105
96
|
applyMixins.applyMixins(DialPad, localized.Localized);
|
|
106
97
|
|
|
98
|
+
class DialPadButton {
|
|
99
|
+
constructor(value, label, ariaLabel, icon, id) {
|
|
100
|
+
this.value = value;
|
|
101
|
+
this.label = label;
|
|
102
|
+
this.ariaLabel = ariaLabel;
|
|
103
|
+
this.icon = icon;
|
|
104
|
+
this.id = id;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const DIAL_PAD_BUTTONS = [
|
|
108
|
+
new DialPadButton("1", " ", "digitOneLabel", "one-solid", "btn1"),
|
|
109
|
+
new DialPadButton("2", "ABC", "digitTwoLabel", "two-solid", "btn2"),
|
|
110
|
+
new DialPadButton("3", "DEF", "digitThreeLabel", "three-solid", "btn3"),
|
|
111
|
+
new DialPadButton("4", "GHI", "digitFourLabel", "four-solid", "btn4"),
|
|
112
|
+
new DialPadButton("5", "JKL", "digitFiveLabel", "five-solid", "btn5"),
|
|
113
|
+
new DialPadButton("6", "MNO", "digitSixLabel", "six-solid", "btn6"),
|
|
114
|
+
new DialPadButton("7", "PQRS", "digitSevenLabel", "seven-solid", "btn7"),
|
|
115
|
+
new DialPadButton("8", "TUV", "digitEightLabel", "eight-solid", "btn8"),
|
|
116
|
+
new DialPadButton("9", "WXYZ", "digitNineLabel", "nine-solid", "btn9"),
|
|
117
|
+
new DialPadButton(
|
|
118
|
+
"*",
|
|
119
|
+
null,
|
|
120
|
+
"digitAsteriskLabel",
|
|
121
|
+
"asterisk-2-solid",
|
|
122
|
+
"btnAsterisk"
|
|
123
|
+
),
|
|
124
|
+
new DialPadButton("0", "+", "digitZeroLabel", "zero-solid", "btn0"),
|
|
125
|
+
new DialPadButton(
|
|
126
|
+
"#",
|
|
127
|
+
null,
|
|
128
|
+
"digitHashtagLabel",
|
|
129
|
+
"hashtag-solid",
|
|
130
|
+
"btnHashtag"
|
|
131
|
+
)
|
|
132
|
+
];
|
|
107
133
|
const getClasses = ({ noInput }) => classNames.classNames("base", ["no-input", Boolean(noInput)]);
|
|
108
134
|
function handleKeyDown(x, e) {
|
|
109
135
|
if (e.key === keyCodes.keyEnter && !x.pending && !x.disabled && !x.callActive && !x.noCall && x.value.length > 0 && e.target instanceof HTMLInputElement) {
|
|
110
136
|
x._onDial();
|
|
111
137
|
} else {
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
digit
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
138
|
+
const elementIndex = DIAL_PAD_BUTTONS.findIndex((x2) => x2.value === e.key);
|
|
139
|
+
if (elementIndex > -1) {
|
|
140
|
+
const digit = x.shadowRoot.querySelector(".digits").children[elementIndex];
|
|
141
|
+
if (digit) {
|
|
142
|
+
digit.active = true;
|
|
143
|
+
setTimeout(() => {
|
|
144
|
+
digit.active = false;
|
|
145
|
+
}, 200);
|
|
146
|
+
}
|
|
119
147
|
}
|
|
120
148
|
}
|
|
121
149
|
return true;
|
|
@@ -148,45 +176,36 @@ function renderTextField(textFieldTag, buttonTag) {
|
|
|
148
176
|
)}
|
|
149
177
|
</${textFieldTag}>`;
|
|
150
178
|
}
|
|
179
|
+
function onDigitClick(digit, { parent: dialPad, event }) {
|
|
180
|
+
dialPad.value += digit.value;
|
|
181
|
+
dialPad.$emit("keypad-click", event.currentTarget);
|
|
182
|
+
dialPad.$emit("input");
|
|
183
|
+
dialPad.$emit("change");
|
|
184
|
+
}
|
|
151
185
|
function renderDigits(buttonTag, iconTag) {
|
|
152
186
|
return index.html`
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
)}
|
|
174
|
-
|
|
175
|
-
c.event
|
|
176
|
-
)}"><${iconTag} slot='icon' name='eight-solid' class='digit-btn-num'></${iconTag}></${buttonTag}>
|
|
177
|
-
<${buttonTag} id='btn9' value='9' stacked appearance="ghost-light" shape="pill" label='WXYZ' size='condensed' class="digit-btn" aria-label="${(x) => x.locale.dialPad.digitNineLabel}" ?disabled="${(x) => x.disabled}" @click="${(x, c) => x._onDigit(
|
|
178
|
-
c.event
|
|
179
|
-
)}"><${iconTag} slot='icon' name='nine-solid' class='digit-btn-num'></${iconTag}></${buttonTag}>
|
|
180
|
-
<${buttonTag} id='btnAsterisk' value='*' appearance="ghost-light" shape="pill" stacked size='condensed' class="digit-btn" aria-label="${(x) => x.locale.dialPad.digitAsteriskLabel}" ?disabled="${(x) => x.disabled}" @click="${(x, c) => x._onDigit(
|
|
181
|
-
c.event
|
|
182
|
-
)}"><${iconTag} slot='icon' name='asterisk-2-solid' class='digit-btn-num'></${iconTag}></${buttonTag}>
|
|
183
|
-
<${buttonTag} id='btn0' value='0' stacked appearance="ghost-light" shape="pill" label='+' size='condensed' class="digit-btn" aria-label=${(x) => x.locale.dialPad.digitZeroLabel} ?disabled="${(x) => x.disabled}" @click="${(x, c) => x._onDigit(
|
|
184
|
-
c.event
|
|
185
|
-
)}"><${iconTag} slot='icon' name='zero-solid' class='digit-btn-num'></${iconTag}></${buttonTag}>
|
|
186
|
-
<${buttonTag} id='btnHashtag' value='#' stacked appearance="ghost-light" shape="pill" size='condensed' class="digit-btn" aria-label=${(x) => x.locale.dialPad.digitHashtagLabel} ?disabled="${(x) => x.disabled}" @click="${(x, c) => x._onDigit(
|
|
187
|
-
c.event
|
|
188
|
-
)}"><${iconTag} slot='icon' name='hashtag-solid' class='digit-btn-num'></${iconTag}></${buttonTag}>
|
|
189
|
-
`;
|
|
187
|
+
${repeat.repeat(
|
|
188
|
+
(_) => DIAL_PAD_BUTTONS,
|
|
189
|
+
index.html`
|
|
190
|
+
<${buttonTag}
|
|
191
|
+
id="${(x) => x.id}"
|
|
192
|
+
value="${(x) => x.value}"
|
|
193
|
+
stacked
|
|
194
|
+
appearance="ghost-light"
|
|
195
|
+
shape="pill"
|
|
196
|
+
label="${(x) => x.label === " " ? " " : x.label}"
|
|
197
|
+
size='condensed'
|
|
198
|
+
class="digit-btn"
|
|
199
|
+
aria-label="${(x, c) => c.parent.locale.dialPad[x.ariaLabel]}"
|
|
200
|
+
?disabled="${(_, c) => c.parent.disabled}"
|
|
201
|
+
@click="${onDigitClick}">
|
|
202
|
+
<${iconTag} slot="icon"
|
|
203
|
+
name="${(x) => x.icon}"
|
|
204
|
+
class="digit-btn-num"></${iconTag}>
|
|
205
|
+
</${buttonTag}>
|
|
206
|
+
`
|
|
207
|
+
)}
|
|
208
|
+
`;
|
|
190
209
|
}
|
|
191
210
|
function renderDialButton(buttonTag) {
|
|
192
211
|
return index.html`<${buttonTag} class="call-btn"
|
package/shared/definition20.js
CHANGED
|
@@ -7,6 +7,7 @@ import { I as Icon } from './icon.js';
|
|
|
7
7
|
import { w as when } from './when.js';
|
|
8
8
|
import { c as classNames } from './class-names.js';
|
|
9
9
|
import { r as ref } from './ref.js';
|
|
10
|
+
import { r as repeat } from './repeat.js';
|
|
10
11
|
import { b as keyEnter } from './key-codes2.js';
|
|
11
12
|
|
|
12
13
|
const styles = ":host{display:inline-block;margin:16px;inline-size:230px}.base{display:grid;box-sizing:border-box;grid-template-rows:80px 1fr auto}.base.no-input{grid-template-rows:1fr auto}.digits{display:grid;gap:16px;grid-template-columns:repeat(3,1fr);grid-template-rows:repeat(4,1fr);inline-size:100%}.phone-field{align-self:flex-start;grid-column:1/-1}.digit-btn{--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: transparent;--_appearance-color-outline: var(--_connotation-color-pale)}.digit-btn:where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: transparent;--_appearance-color-outline: var(--_connotation-color-firm-all)}.digit-btn:where(.disabled,:disabled){--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: transparent;--_appearance-color-outline: var(--vvd-color-neutral-100)}.digit-btn{--_connotation-color-contrast: var(--vvd-dial-pad-accent-contrast, var(--vvd-color-neutral-800));--_connotation-color-soft: var(--vvd-dial-pad-accent-soft, var(--vvd-color-neutral-100));--_connotation-color-pale: var(--vvd-dial-pad-accent-pale, var(--vvd-color-neutral-300));--_connotation-color-fierce: var(--vvd-dial-pad-accent-fierce, var(--vvd-color-neutral-700));--_connotation-color-firm-all: var(--vvd-dial-pad-accent-firm-all, var(--vvd-color-neutral-600));--_connotation-color-faint: var(--vvd-dial-pad-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-dim: var(--vvd-dial-pad-accent-dim, var(--vvd-color-neutral-200))}.digit-btn{--vvd-button-accent-firm: var(--_appearance-color-text);display:flex;overflow:hidden;flex-direction:column;border-radius:16px;box-shadow:0 0 0 1px var(--_appearance-color-outline);inline-size:100%}.digit-btn:not(.disabled) .digit-btn-num{color:var(--vvd-color-canvas-text)}.call-btn{margin-top:32px;grid-column:1/-1}";
|
|
@@ -34,16 +35,6 @@ class DialPad extends FoundationElement {
|
|
|
34
35
|
this.noInput = false;
|
|
35
36
|
this.endCallButtonLabel = null;
|
|
36
37
|
this.callButtonLabel = null;
|
|
37
|
-
/**
|
|
38
|
-
*
|
|
39
|
-
* @internal
|
|
40
|
-
*/
|
|
41
|
-
this._onDigit = (e) => {
|
|
42
|
-
this.value += e.currentTarget.value;
|
|
43
|
-
this.$emit("keypad-click", e.currentTarget);
|
|
44
|
-
this.$emit("input");
|
|
45
|
-
this.$emit("change");
|
|
46
|
-
};
|
|
47
38
|
/**
|
|
48
39
|
*
|
|
49
40
|
* @internal
|
|
@@ -102,18 +93,55 @@ __decorateClass([
|
|
|
102
93
|
], DialPad.prototype, "callButtonLabel");
|
|
103
94
|
applyMixins(DialPad, Localized);
|
|
104
95
|
|
|
96
|
+
class DialPadButton {
|
|
97
|
+
constructor(value, label, ariaLabel, icon, id) {
|
|
98
|
+
this.value = value;
|
|
99
|
+
this.label = label;
|
|
100
|
+
this.ariaLabel = ariaLabel;
|
|
101
|
+
this.icon = icon;
|
|
102
|
+
this.id = id;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const DIAL_PAD_BUTTONS = [
|
|
106
|
+
new DialPadButton("1", " ", "digitOneLabel", "one-solid", "btn1"),
|
|
107
|
+
new DialPadButton("2", "ABC", "digitTwoLabel", "two-solid", "btn2"),
|
|
108
|
+
new DialPadButton("3", "DEF", "digitThreeLabel", "three-solid", "btn3"),
|
|
109
|
+
new DialPadButton("4", "GHI", "digitFourLabel", "four-solid", "btn4"),
|
|
110
|
+
new DialPadButton("5", "JKL", "digitFiveLabel", "five-solid", "btn5"),
|
|
111
|
+
new DialPadButton("6", "MNO", "digitSixLabel", "six-solid", "btn6"),
|
|
112
|
+
new DialPadButton("7", "PQRS", "digitSevenLabel", "seven-solid", "btn7"),
|
|
113
|
+
new DialPadButton("8", "TUV", "digitEightLabel", "eight-solid", "btn8"),
|
|
114
|
+
new DialPadButton("9", "WXYZ", "digitNineLabel", "nine-solid", "btn9"),
|
|
115
|
+
new DialPadButton(
|
|
116
|
+
"*",
|
|
117
|
+
null,
|
|
118
|
+
"digitAsteriskLabel",
|
|
119
|
+
"asterisk-2-solid",
|
|
120
|
+
"btnAsterisk"
|
|
121
|
+
),
|
|
122
|
+
new DialPadButton("0", "+", "digitZeroLabel", "zero-solid", "btn0"),
|
|
123
|
+
new DialPadButton(
|
|
124
|
+
"#",
|
|
125
|
+
null,
|
|
126
|
+
"digitHashtagLabel",
|
|
127
|
+
"hashtag-solid",
|
|
128
|
+
"btnHashtag"
|
|
129
|
+
)
|
|
130
|
+
];
|
|
105
131
|
const getClasses = ({ noInput }) => classNames("base", ["no-input", Boolean(noInput)]);
|
|
106
132
|
function handleKeyDown(x, e) {
|
|
107
133
|
if (e.key === keyEnter && !x.pending && !x.disabled && !x.callActive && !x.noCall && x.value.length > 0 && e.target instanceof HTMLInputElement) {
|
|
108
134
|
x._onDial();
|
|
109
135
|
} else {
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
digit
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
136
|
+
const elementIndex = DIAL_PAD_BUTTONS.findIndex((x2) => x2.value === e.key);
|
|
137
|
+
if (elementIndex > -1) {
|
|
138
|
+
const digit = x.shadowRoot.querySelector(".digits").children[elementIndex];
|
|
139
|
+
if (digit) {
|
|
140
|
+
digit.active = true;
|
|
141
|
+
setTimeout(() => {
|
|
142
|
+
digit.active = false;
|
|
143
|
+
}, 200);
|
|
144
|
+
}
|
|
117
145
|
}
|
|
118
146
|
}
|
|
119
147
|
return true;
|
|
@@ -146,45 +174,36 @@ function renderTextField(textFieldTag, buttonTag) {
|
|
|
146
174
|
)}
|
|
147
175
|
</${textFieldTag}>`;
|
|
148
176
|
}
|
|
177
|
+
function onDigitClick(digit, { parent: dialPad, event }) {
|
|
178
|
+
dialPad.value += digit.value;
|
|
179
|
+
dialPad.$emit("keypad-click", event.currentTarget);
|
|
180
|
+
dialPad.$emit("input");
|
|
181
|
+
dialPad.$emit("change");
|
|
182
|
+
}
|
|
149
183
|
function renderDigits(buttonTag, iconTag) {
|
|
150
184
|
return html`
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
)}
|
|
172
|
-
|
|
173
|
-
c.event
|
|
174
|
-
)}"><${iconTag} slot='icon' name='eight-solid' class='digit-btn-num'></${iconTag}></${buttonTag}>
|
|
175
|
-
<${buttonTag} id='btn9' value='9' stacked appearance="ghost-light" shape="pill" label='WXYZ' size='condensed' class="digit-btn" aria-label="${(x) => x.locale.dialPad.digitNineLabel}" ?disabled="${(x) => x.disabled}" @click="${(x, c) => x._onDigit(
|
|
176
|
-
c.event
|
|
177
|
-
)}"><${iconTag} slot='icon' name='nine-solid' class='digit-btn-num'></${iconTag}></${buttonTag}>
|
|
178
|
-
<${buttonTag} id='btnAsterisk' value='*' appearance="ghost-light" shape="pill" stacked size='condensed' class="digit-btn" aria-label="${(x) => x.locale.dialPad.digitAsteriskLabel}" ?disabled="${(x) => x.disabled}" @click="${(x, c) => x._onDigit(
|
|
179
|
-
c.event
|
|
180
|
-
)}"><${iconTag} slot='icon' name='asterisk-2-solid' class='digit-btn-num'></${iconTag}></${buttonTag}>
|
|
181
|
-
<${buttonTag} id='btn0' value='0' stacked appearance="ghost-light" shape="pill" label='+' size='condensed' class="digit-btn" aria-label=${(x) => x.locale.dialPad.digitZeroLabel} ?disabled="${(x) => x.disabled}" @click="${(x, c) => x._onDigit(
|
|
182
|
-
c.event
|
|
183
|
-
)}"><${iconTag} slot='icon' name='zero-solid' class='digit-btn-num'></${iconTag}></${buttonTag}>
|
|
184
|
-
<${buttonTag} id='btnHashtag' value='#' stacked appearance="ghost-light" shape="pill" size='condensed' class="digit-btn" aria-label=${(x) => x.locale.dialPad.digitHashtagLabel} ?disabled="${(x) => x.disabled}" @click="${(x, c) => x._onDigit(
|
|
185
|
-
c.event
|
|
186
|
-
)}"><${iconTag} slot='icon' name='hashtag-solid' class='digit-btn-num'></${iconTag}></${buttonTag}>
|
|
187
|
-
`;
|
|
185
|
+
${repeat(
|
|
186
|
+
(_) => DIAL_PAD_BUTTONS,
|
|
187
|
+
html`
|
|
188
|
+
<${buttonTag}
|
|
189
|
+
id="${(x) => x.id}"
|
|
190
|
+
value="${(x) => x.value}"
|
|
191
|
+
stacked
|
|
192
|
+
appearance="ghost-light"
|
|
193
|
+
shape="pill"
|
|
194
|
+
label="${(x) => x.label === " " ? " " : x.label}"
|
|
195
|
+
size='condensed'
|
|
196
|
+
class="digit-btn"
|
|
197
|
+
aria-label="${(x, c) => c.parent.locale.dialPad[x.ariaLabel]}"
|
|
198
|
+
?disabled="${(_, c) => c.parent.disabled}"
|
|
199
|
+
@click="${onDigitClick}">
|
|
200
|
+
<${iconTag} slot="icon"
|
|
201
|
+
name="${(x) => x.icon}"
|
|
202
|
+
class="digit-btn-num"></${iconTag}>
|
|
203
|
+
</${buttonTag}>
|
|
204
|
+
`
|
|
205
|
+
)}
|
|
206
|
+
`;
|
|
188
207
|
}
|
|
189
208
|
function renderDialButton(buttonTag) {
|
|
190
209
|
return html`<${buttonTag} class="call-btn"
|
package/shared/definition21.cjs
CHANGED
|
@@ -4,10 +4,10 @@ const index = require('./index.cjs');
|
|
|
4
4
|
const definition$2 = require('./definition27.cjs');
|
|
5
5
|
const definition$1 = require('./definition11.cjs');
|
|
6
6
|
const definition = require('./definition63.cjs');
|
|
7
|
+
const index$1 = require('./index2.cjs');
|
|
7
8
|
const applyMixins = require('./apply-mixins.cjs');
|
|
8
9
|
const localized = require('./localized.cjs');
|
|
9
10
|
const icon$1 = require('./icon.cjs');
|
|
10
|
-
const index$1 = require('./index2.cjs');
|
|
11
11
|
const when = require('./when.cjs');
|
|
12
12
|
const slotted = require('./slotted.cjs');
|
|
13
13
|
const classNames = require('./class-names.cjs');
|
|
@@ -39,7 +39,9 @@ class Dialog extends index.FoundationElement {
|
|
|
39
39
|
}
|
|
40
40
|
const rect = this.#dialog.getBoundingClientRect();
|
|
41
41
|
const clickedInDialog = rect.top <= event.clientY && event.clientY <= rect.top + rect.height && rect.left <= event.clientX && event.clientX <= rect.left + rect.width;
|
|
42
|
-
|
|
42
|
+
if (!clickedInDialog) {
|
|
43
|
+
this._handleCloseRequest();
|
|
44
|
+
}
|
|
43
45
|
};
|
|
44
46
|
this.#handleInternalFormSubmit = (event) => {
|
|
45
47
|
if (event.target.method !== "dialog") {
|
|
@@ -100,6 +102,27 @@ class Dialog extends index.FoundationElement {
|
|
|
100
102
|
}
|
|
101
103
|
#handleScrimClick;
|
|
102
104
|
#handleInternalFormSubmit;
|
|
105
|
+
/**
|
|
106
|
+
* @internal
|
|
107
|
+
*/
|
|
108
|
+
_onKeyDown(event) {
|
|
109
|
+
if (index$1.handleEscapeKeyAndStopPropogation(event) && this._openedAsModal) {
|
|
110
|
+
this._handleCloseRequest();
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* @internal
|
|
117
|
+
*/
|
|
118
|
+
_handleCloseRequest() {
|
|
119
|
+
if (this.$emit("cancel", void 0, {
|
|
120
|
+
bubbles: false,
|
|
121
|
+
cancelable: true
|
|
122
|
+
})) {
|
|
123
|
+
this.open = false;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
103
126
|
close() {
|
|
104
127
|
this.open = false;
|
|
105
128
|
}
|
|
@@ -227,17 +250,9 @@ function renderDismissButton(buttonTag) {
|
|
|
227
250
|
size="condensed"
|
|
228
251
|
class="dismiss-button"
|
|
229
252
|
icon="close-line"
|
|
230
|
-
@click="${(x) => x.
|
|
253
|
+
@click="${(x) => x._handleCloseRequest()}"
|
|
231
254
|
></${buttonTag}>`;
|
|
232
255
|
}
|
|
233
|
-
function handleEscapeKey(dialog, event) {
|
|
234
|
-
if (index$1.handleEscapeKeyAndStopPropogation(event) && dialog._openedAsModal) {
|
|
235
|
-
dialog.open = false;
|
|
236
|
-
return false;
|
|
237
|
-
} else {
|
|
238
|
-
return true;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
256
|
const DialogTemplate = (context) => {
|
|
242
257
|
const elevationTag = context.tagFor(definition.Elevation);
|
|
243
258
|
const iconTag = context.tagFor(icon$1.Icon);
|
|
@@ -245,7 +260,7 @@ const DialogTemplate = (context) => {
|
|
|
245
260
|
return index.html`
|
|
246
261
|
<${elevationTag} dp="8">
|
|
247
262
|
<dialog class="${getClasses}"
|
|
248
|
-
@keydown="${(x, c) =>
|
|
263
|
+
@keydown="${(x, c) => x._onKeyDown(c.event)}"
|
|
249
264
|
@cancel="${(_, c) => c.event.preventDefault()}"
|
|
250
265
|
aria-label="${(x) => x.ariaLabel}"
|
|
251
266
|
?aria-modal="${(x) => x._openedAsModal}"
|
package/shared/definition21.js
CHANGED
|
@@ -2,10 +2,10 @@ import { F as FoundationElement, a as attr, o as observable, h as html, r as reg
|
|
|
2
2
|
import { a as iconRegistries } from './definition27.js';
|
|
3
3
|
import { B as Button, a as buttonRegistries } from './definition11.js';
|
|
4
4
|
import { E as Elevation, e as elevationRegistries } from './definition63.js';
|
|
5
|
+
import { h as handleEscapeKeyAndStopPropogation } from './index2.js';
|
|
5
6
|
import { a as applyMixins } from './apply-mixins.js';
|
|
6
7
|
import { L as Localized } from './localized.js';
|
|
7
8
|
import { I as Icon } from './icon.js';
|
|
8
|
-
import { h as handleEscapeKeyAndStopPropogation } from './index2.js';
|
|
9
9
|
import { w as when } from './when.js';
|
|
10
10
|
import { s as slotted } from './slotted.js';
|
|
11
11
|
import { c as classNames } from './class-names.js';
|
|
@@ -37,7 +37,9 @@ class Dialog extends FoundationElement {
|
|
|
37
37
|
}
|
|
38
38
|
const rect = this.#dialog.getBoundingClientRect();
|
|
39
39
|
const clickedInDialog = rect.top <= event.clientY && event.clientY <= rect.top + rect.height && rect.left <= event.clientX && event.clientX <= rect.left + rect.width;
|
|
40
|
-
|
|
40
|
+
if (!clickedInDialog) {
|
|
41
|
+
this._handleCloseRequest();
|
|
42
|
+
}
|
|
41
43
|
};
|
|
42
44
|
this.#handleInternalFormSubmit = (event) => {
|
|
43
45
|
if (event.target.method !== "dialog") {
|
|
@@ -98,6 +100,27 @@ class Dialog extends FoundationElement {
|
|
|
98
100
|
}
|
|
99
101
|
#handleScrimClick;
|
|
100
102
|
#handleInternalFormSubmit;
|
|
103
|
+
/**
|
|
104
|
+
* @internal
|
|
105
|
+
*/
|
|
106
|
+
_onKeyDown(event) {
|
|
107
|
+
if (handleEscapeKeyAndStopPropogation(event) && this._openedAsModal) {
|
|
108
|
+
this._handleCloseRequest();
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* @internal
|
|
115
|
+
*/
|
|
116
|
+
_handleCloseRequest() {
|
|
117
|
+
if (this.$emit("cancel", void 0, {
|
|
118
|
+
bubbles: false,
|
|
119
|
+
cancelable: true
|
|
120
|
+
})) {
|
|
121
|
+
this.open = false;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
101
124
|
close() {
|
|
102
125
|
this.open = false;
|
|
103
126
|
}
|
|
@@ -225,17 +248,9 @@ function renderDismissButton(buttonTag) {
|
|
|
225
248
|
size="condensed"
|
|
226
249
|
class="dismiss-button"
|
|
227
250
|
icon="close-line"
|
|
228
|
-
@click="${(x) => x.
|
|
251
|
+
@click="${(x) => x._handleCloseRequest()}"
|
|
229
252
|
></${buttonTag}>`;
|
|
230
253
|
}
|
|
231
|
-
function handleEscapeKey(dialog, event) {
|
|
232
|
-
if (handleEscapeKeyAndStopPropogation(event) && dialog._openedAsModal) {
|
|
233
|
-
dialog.open = false;
|
|
234
|
-
return false;
|
|
235
|
-
} else {
|
|
236
|
-
return true;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
254
|
const DialogTemplate = (context) => {
|
|
240
255
|
const elevationTag = context.tagFor(Elevation);
|
|
241
256
|
const iconTag = context.tagFor(Icon);
|
|
@@ -243,7 +258,7 @@ const DialogTemplate = (context) => {
|
|
|
243
258
|
return html`
|
|
244
259
|
<${elevationTag} dp="8">
|
|
245
260
|
<dialog class="${getClasses}"
|
|
246
|
-
@keydown="${(x, c) =>
|
|
261
|
+
@keydown="${(x, c) => x._onKeyDown(c.event)}"
|
|
247
262
|
@cancel="${(_, c) => c.event.preventDefault()}"
|
|
248
263
|
aria-label="${(x) => x.ariaLabel}"
|
|
249
264
|
?aria-modal="${(x) => x._openedAsModal}"
|