@vonage/vivid 4.8.0 → 4.10.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.
Files changed (52) hide show
  1. package/custom-elements.json +255 -3
  2. package/lib/breadcrumb/breadcrumb.d.ts +4 -1
  3. package/lib/breadcrumb-item/breadcrumb-item.d.ts +5 -3
  4. package/lib/checkbox/checkbox.d.ts +4 -0
  5. package/lib/dialog/dialog.d.ts +4 -0
  6. package/lib/divider/divider.d.ts +11 -2
  7. package/lib/icon/icon.d.ts +2 -1
  8. package/lib/text-field/text-field.d.ts +1 -0
  9. package/package.json +1 -1
  10. package/shared/breadcrumb-item.cjs +162 -20
  11. package/shared/breadcrumb-item.js +163 -21
  12. package/shared/definition10.cjs +52 -68
  13. package/shared/definition10.js +54 -70
  14. package/shared/definition11.cjs +1 -1
  15. package/shared/definition11.js +1 -1
  16. package/shared/definition15.cjs +17 -1
  17. package/shared/definition15.js +17 -1
  18. package/shared/definition20.cjs +88 -64
  19. package/shared/definition20.js +88 -64
  20. package/shared/definition21.cjs +59 -14
  21. package/shared/definition21.js +59 -14
  22. package/shared/definition22.cjs +32 -51
  23. package/shared/definition22.js +33 -52
  24. package/shared/definition29.cjs +1 -1
  25. package/shared/definition29.js +1 -1
  26. package/shared/definition30.cjs +1 -1
  27. package/shared/definition30.js +1 -1
  28. package/shared/definition46.cjs +24 -9
  29. package/shared/definition46.js +24 -9
  30. package/shared/definition5.cjs +1 -1
  31. package/shared/definition5.js +1 -1
  32. package/shared/definition56.cjs +4 -0
  33. package/shared/definition56.js +4 -0
  34. package/shared/definition9.cjs +1 -19
  35. package/shared/definition9.js +2 -20
  36. package/shared/icon.cjs +11 -5
  37. package/shared/icon.js +11 -5
  38. package/shared/patterns/anchor.d.ts +18 -0
  39. package/shared/patterns/anchored.d.ts +4 -4
  40. package/shared/patterns/aria-global.d.ts +21 -0
  41. package/shared/patterns/form-elements/form-elements.d.ts +6 -6
  42. package/shared/text-anchor.cjs +84 -2
  43. package/shared/text-anchor.js +84 -2
  44. package/styles/core/all.css +1 -1
  45. package/styles/core/theme.css +1 -1
  46. package/styles/core/typography.css +1 -1
  47. package/styles/tokens/theme-dark.css +35 -14
  48. package/styles/tokens/theme-light.css +35 -14
  49. package/styles/tokens/vivid-2-compat.css +1 -1
  50. package/vivid.api.json +10 -1
  51. package/shared/anchor.cjs +0 -90
  52. package/shared/anchor.js +0 -87
@@ -115,6 +115,7 @@ exports.Checkbox = class Checkbox extends Checkbox$1 {
115
115
  super(...arguments);
116
116
  this.ariaLabel = null;
117
117
  this.tabindex = null;
118
+ this.ariaChecked = null;
118
119
  /**
119
120
  * !remove method as will be implemented by fast-foundation in version after 2.46.9
120
121
  *
@@ -154,11 +155,23 @@ exports.Checkbox = class Checkbox extends Checkbox$1 {
154
155
  return false;
155
156
  };
156
157
  }
158
+ indeterminateChanged(_, next) {
159
+ this.checked = !next;
160
+ }
161
+ ariaCheckedChanged() {
162
+ if (this.ariaChecked === "mixed") {
163
+ this.indeterminate = true;
164
+ } else {
165
+ this.indeterminate = false;
166
+ this.checked = this.ariaChecked === "true" ? true : false;
167
+ }
168
+ }
157
169
  /**
158
170
  * @internal
159
171
  */
160
172
  checkedChanged(prev, next) {
161
173
  super.checkedChanged(prev, next);
174
+ this.ariaChecked = next == true ? "true" : "false";
162
175
  if (prev !== void 0) {
163
176
  this.$emit("input");
164
177
  }
@@ -173,6 +186,9 @@ __decorateClass([
173
186
  __decorateClass([
174
187
  index.attr
175
188
  ], exports.Checkbox.prototype, "connotation", 2);
189
+ __decorateClass([
190
+ index.attr({ attribute: "aria-checked" })
191
+ ], exports.Checkbox.prototype, "ariaChecked", 2);
176
192
  __decorateClass([
177
193
  index.observable
178
194
  ], exports.Checkbox.prototype, "slottedContent", 2);
@@ -213,7 +229,7 @@ const CheckboxTemplate = (context) => {
213
229
  class="${getClasses}"
214
230
  role="checkbox"
215
231
  aria-label="${(x) => x.ariaLabel}"
216
- aria-checked="${(x) => x.checked}"
232
+ aria-checked="${(x) => x.indeterminate ? "mixed" : x.checked}"
217
233
  aria-required="${(x) => x.required}"
218
234
  aria-disabled="${(x) => x.disabled}"
219
235
  aria-readonly="${(x) => x.readOnly}"
@@ -113,6 +113,7 @@ let Checkbox = class extends Checkbox$1 {
113
113
  super(...arguments);
114
114
  this.ariaLabel = null;
115
115
  this.tabindex = null;
116
+ this.ariaChecked = null;
116
117
  /**
117
118
  * !remove method as will be implemented by fast-foundation in version after 2.46.9
118
119
  *
@@ -152,11 +153,23 @@ let Checkbox = class extends Checkbox$1 {
152
153
  return false;
153
154
  };
154
155
  }
156
+ indeterminateChanged(_, next) {
157
+ this.checked = !next;
158
+ }
159
+ ariaCheckedChanged() {
160
+ if (this.ariaChecked === "mixed") {
161
+ this.indeterminate = true;
162
+ } else {
163
+ this.indeterminate = false;
164
+ this.checked = this.ariaChecked === "true" ? true : false;
165
+ }
166
+ }
155
167
  /**
156
168
  * @internal
157
169
  */
158
170
  checkedChanged(prev, next) {
159
171
  super.checkedChanged(prev, next);
172
+ this.ariaChecked = next == true ? "true" : "false";
160
173
  if (prev !== void 0) {
161
174
  this.$emit("input");
162
175
  }
@@ -171,6 +184,9 @@ __decorateClass([
171
184
  __decorateClass([
172
185
  attr
173
186
  ], Checkbox.prototype, "connotation", 2);
187
+ __decorateClass([
188
+ attr({ attribute: "aria-checked" })
189
+ ], Checkbox.prototype, "ariaChecked", 2);
174
190
  __decorateClass([
175
191
  observable
176
192
  ], Checkbox.prototype, "slottedContent", 2);
@@ -211,7 +227,7 @@ const CheckboxTemplate = (context) => {
211
227
  class="${getClasses}"
212
228
  role="checkbox"
213
229
  aria-label="${(x) => x.ariaLabel}"
214
- aria-checked="${(x) => x.checked}"
230
+ aria-checked="${(x) => x.indeterminate ? "mixed" : x.checked}"
215
231
  aria-required="${(x) => x.required}"
216
232
  aria-disabled="${(x) => x.disabled}"
217
233
  aria-readonly="${(x) => x.readOnly}"
@@ -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
@@ -53,14 +44,6 @@ class DialPad extends index.FoundationElement {
53
44
  this._onDial = () => {
54
45
  this.callActive ? this.$emit("end-call") : this.$emit("dial");
55
46
  };
56
- /**
57
- *
58
- * @internal
59
- */
60
- this._deleteLastCharacter = () => {
61
- this.value = this.value.slice(0, -1);
62
- this.$emit("change");
63
- };
64
47
  }
65
48
  valueChanged(_oldValue, newValue) {
66
49
  if (newValue !== void 0 && newValue !== null && this._textFieldEl && newValue !== this._textFieldEl.value) {
@@ -104,18 +87,55 @@ __decorateClass([
104
87
  ], DialPad.prototype, "callButtonLabel");
105
88
  applyMixins.applyMixins(DialPad, localized.Localized);
106
89
 
90
+ class DialPadButton {
91
+ constructor(value, label, ariaLabel, icon, id) {
92
+ this.value = value;
93
+ this.label = label;
94
+ this.ariaLabel = ariaLabel;
95
+ this.icon = icon;
96
+ this.id = id;
97
+ }
98
+ }
99
+ const DIAL_PAD_BUTTONS = [
100
+ new DialPadButton("1", " ", "digitOneLabel", "one-solid", "btn1"),
101
+ new DialPadButton("2", "ABC", "digitTwoLabel", "two-solid", "btn2"),
102
+ new DialPadButton("3", "DEF", "digitThreeLabel", "three-solid", "btn3"),
103
+ new DialPadButton("4", "GHI", "digitFourLabel", "four-solid", "btn4"),
104
+ new DialPadButton("5", "JKL", "digitFiveLabel", "five-solid", "btn5"),
105
+ new DialPadButton("6", "MNO", "digitSixLabel", "six-solid", "btn6"),
106
+ new DialPadButton("7", "PQRS", "digitSevenLabel", "seven-solid", "btn7"),
107
+ new DialPadButton("8", "TUV", "digitEightLabel", "eight-solid", "btn8"),
108
+ new DialPadButton("9", "WXYZ", "digitNineLabel", "nine-solid", "btn9"),
109
+ new DialPadButton(
110
+ "*",
111
+ null,
112
+ "digitAsteriskLabel",
113
+ "asterisk-2-solid",
114
+ "btnAsterisk"
115
+ ),
116
+ new DialPadButton("0", "+", "digitZeroLabel", "zero-solid", "btn0"),
117
+ new DialPadButton(
118
+ "#",
119
+ null,
120
+ "digitHashtagLabel",
121
+ "hashtag-solid",
122
+ "btnHashtag"
123
+ )
124
+ ];
107
125
  const getClasses = ({ noInput }) => classNames.classNames("base", ["no-input", Boolean(noInput)]);
108
126
  function handleKeyDown(x, e) {
109
127
  if (e.key === keyCodes.keyEnter && !x.pending && !x.disabled && !x.callActive && !x.noCall && x.value.length > 0 && e.target instanceof HTMLInputElement) {
110
128
  x._onDial();
111
129
  } else {
112
- const key = e.key === "*" ? "Asterisk" : e.key === "#" ? "Hashtag" : e.key;
113
- const digit = x.shadowRoot.querySelector(`#btn${key}`);
114
- if (digit) {
115
- digit.active = true;
116
- setTimeout(() => {
117
- digit.active = false;
118
- }, 200);
130
+ const elementIndex = DIAL_PAD_BUTTONS.findIndex((x2) => x2.value === e.key);
131
+ if (elementIndex > -1) {
132
+ const digit = x.shadowRoot.querySelector(".digits").children[elementIndex];
133
+ if (digit) {
134
+ digit.active = true;
135
+ setTimeout(() => {
136
+ digit.active = false;
137
+ }, 200);
138
+ }
119
139
  }
120
140
  }
121
141
  return true;
@@ -126,6 +146,14 @@ function syncFieldAndPadValues(x) {
126
146
  function stopPropagation(_, { event: e }) {
127
147
  e.stopImmediatePropagation();
128
148
  }
149
+ function deleteLastCharacter(dialPad) {
150
+ dialPad.value = dialPad.value.slice(0, -1);
151
+ dialPad.$emit("input");
152
+ dialPad.$emit("change");
153
+ if (dialPad.value === "") {
154
+ dialPad._textFieldEl.focus();
155
+ }
156
+ }
129
157
  function renderTextField(textFieldTag, buttonTag) {
130
158
  return index.html`<${textFieldTag} ${ref.ref(
131
159
  "_textFieldEl"
@@ -142,51 +170,47 @@ function renderTextField(textFieldTag, buttonTag) {
142
170
  ${when.when(
143
171
  (x) => x.value && x.value.length && x.value.length > 0,
144
172
  index.html`<${buttonTag}
145
- slot="action-items" size='super-condensed' icon="backspace-line" aria-label="${(x) => x.deleteAriaLabel || x.locale.dialPad.deleteLabel}"
146
- appearance='ghost' ?disabled="${(x) => x.disabled || x.callActive}" @click="${(x) => x._deleteLastCharacter()}">
173
+ slot="action-items"
174
+ size='super-condensed'
175
+ icon="backspace-line"
176
+ aria-label="${(x) => x.deleteAriaLabel || x.locale.dialPad.deleteLabel}"
177
+ appearance='ghost'
178
+ ?disabled="${(x) => x.disabled || x.callActive}"
179
+ @click="${(x) => deleteLastCharacter(x)}">
147
180
  </${buttonTag}>`
148
181
  )}
149
182
  </${textFieldTag}>`;
150
183
  }
184
+ function onDigitClick(digit, { parent: dialPad, event }) {
185
+ dialPad.value += digit.value;
186
+ dialPad.$emit("keypad-click", event.currentTarget);
187
+ dialPad.$emit("input");
188
+ dialPad.$emit("change");
189
+ }
151
190
  function renderDigits(buttonTag, iconTag) {
152
191
  return index.html`
153
- <${buttonTag} id='btn1' value='1' stacked appearance="ghost-light" shape="pill" label="&nbsp;" size='condensed' class="digit-btn" aria-label="${(x) => x.locale.dialPad.digitOneLabel}" ?disabled="${(x) => x.disabled}" @click="${(x, c) => x._onDigit(
154
- c.event
155
- )}"><${iconTag} slot='icon' name='one-solid' class='digit-btn-num'></${iconTag}></${buttonTag}>
156
- <${buttonTag} id='btn2' value='2' stacked appearance="ghost-light" shape="pill" label='ABC' size='condensed' class="digit-btn" aria-label="${(x) => x.locale.dialPad.digitTwoLabel}" ?disabled="${(x) => x.disabled}" @click="${(x, c) => x._onDigit(
157
- c.event
158
- )}"><${iconTag} slot='icon' name='two-solid' class='digit-btn-num'></${iconTag}></${buttonTag}>
159
- <${buttonTag} id='btn3' value='3' stacked appearance="ghost-light" shape="pill" label='DEF' size='condensed' class="digit-btn" aria-label="${(x) => x.locale.dialPad.digitThreeLabel}" ?disabled="${(x) => x.disabled}" @click="${(x, c) => x._onDigit(
160
- c.event
161
- )}"><${iconTag} slot='icon' name='three-solid' class='digit-btn-num'></${iconTag}></${buttonTag}>
162
- <${buttonTag} id='btn4' value='4' stacked appearance="ghost-light" shape="pill" label='GHI' size='condensed' class="digit-btn" aria-label="${(x) => x.locale.dialPad.digitFourLabel}" ?disabled="${(x) => x.disabled}" @click="${(x, c) => x._onDigit(
163
- c.event
164
- )}"><${iconTag} slot='icon' name='four-solid' class='digit-btn-num'></${iconTag}></${buttonTag}>
165
- <${buttonTag} id='btn5' value='5' stacked appearance="ghost-light" shape="pill" label='JKL' size='condensed' class="digit-btn" aria-label="${(x) => x.locale.dialPad.digitFiveLabel}" ?disabled="${(x) => x.disabled}" @click="${(x, c) => x._onDigit(
166
- c.event
167
- )}"><${iconTag} slot='icon' name='five-solid' class='digit-btn-num'></${iconTag}></${buttonTag}>
168
- <${buttonTag} id='btn6' value='6' stacked appearance="ghost-light" shape="pill" label='MNO' size='condensed' class="digit-btn" aria-label="${(x) => x.locale.dialPad.digitSixLabel}" ?disabled="${(x) => x.disabled}" @click="${(x, c) => x._onDigit(
169
- c.event
170
- )}"><${iconTag} slot='icon' name='six-solid' class='digit-btn-num'></${iconTag}></${buttonTag}>
171
- <${buttonTag} id='btn7' value='7' stacked appearance="ghost-light" shape="pill" label='PQRS' size='condensed' class="digit-btn" aria-label="${(x) => x.locale.dialPad.digitSevenLabel}" ?disabled="${(x) => x.disabled}" @click="${(x, c) => x._onDigit(
172
- c.event
173
- )}"><${iconTag} slot='icon' name='seven-solid' class='digit-btn-num'></${iconTag}></${buttonTag}>
174
- <${buttonTag} id='btn8' value='8' stacked appearance="ghost-light" shape="pill" label='TUV' size='condensed' class="digit-btn" aria-label="${(x) => x.locale.dialPad.digitEightLabel}" ?disabled="${(x) => x.disabled}" @click="${(x, c) => x._onDigit(
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
- `;
192
+ ${repeat.repeat(
193
+ (_) => DIAL_PAD_BUTTONS,
194
+ index.html`
195
+ <${buttonTag}
196
+ id="${(x) => x.id}"
197
+ value="${(x) => x.value}"
198
+ stacked
199
+ appearance="ghost-light"
200
+ shape="pill"
201
+ label="${(x) => x.label === "&nbsp;" ? " " : x.label}"
202
+ size='condensed'
203
+ class="digit-btn"
204
+ aria-label="${(x, c) => c.parent.locale.dialPad[x.ariaLabel]}"
205
+ ?disabled="${(_, c) => c.parent.disabled}"
206
+ @click="${onDigitClick}">
207
+ <${iconTag} slot="icon"
208
+ name="${(x) => x.icon}"
209
+ class="digit-btn-num"></${iconTag}>
210
+ </${buttonTag}>
211
+ `
212
+ )}
213
+ `;
190
214
  }
191
215
  function renderDialButton(buttonTag) {
192
216
  return index.html`<${buttonTag} class="call-btn"
@@ -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
@@ -51,14 +42,6 @@ class DialPad extends FoundationElement {
51
42
  this._onDial = () => {
52
43
  this.callActive ? this.$emit("end-call") : this.$emit("dial");
53
44
  };
54
- /**
55
- *
56
- * @internal
57
- */
58
- this._deleteLastCharacter = () => {
59
- this.value = this.value.slice(0, -1);
60
- this.$emit("change");
61
- };
62
45
  }
63
46
  valueChanged(_oldValue, newValue) {
64
47
  if (newValue !== void 0 && newValue !== null && this._textFieldEl && newValue !== this._textFieldEl.value) {
@@ -102,18 +85,55 @@ __decorateClass([
102
85
  ], DialPad.prototype, "callButtonLabel");
103
86
  applyMixins(DialPad, Localized);
104
87
 
88
+ class DialPadButton {
89
+ constructor(value, label, ariaLabel, icon, id) {
90
+ this.value = value;
91
+ this.label = label;
92
+ this.ariaLabel = ariaLabel;
93
+ this.icon = icon;
94
+ this.id = id;
95
+ }
96
+ }
97
+ const DIAL_PAD_BUTTONS = [
98
+ new DialPadButton("1", "&nbsp;", "digitOneLabel", "one-solid", "btn1"),
99
+ new DialPadButton("2", "ABC", "digitTwoLabel", "two-solid", "btn2"),
100
+ new DialPadButton("3", "DEF", "digitThreeLabel", "three-solid", "btn3"),
101
+ new DialPadButton("4", "GHI", "digitFourLabel", "four-solid", "btn4"),
102
+ new DialPadButton("5", "JKL", "digitFiveLabel", "five-solid", "btn5"),
103
+ new DialPadButton("6", "MNO", "digitSixLabel", "six-solid", "btn6"),
104
+ new DialPadButton("7", "PQRS", "digitSevenLabel", "seven-solid", "btn7"),
105
+ new DialPadButton("8", "TUV", "digitEightLabel", "eight-solid", "btn8"),
106
+ new DialPadButton("9", "WXYZ", "digitNineLabel", "nine-solid", "btn9"),
107
+ new DialPadButton(
108
+ "*",
109
+ null,
110
+ "digitAsteriskLabel",
111
+ "asterisk-2-solid",
112
+ "btnAsterisk"
113
+ ),
114
+ new DialPadButton("0", "+", "digitZeroLabel", "zero-solid", "btn0"),
115
+ new DialPadButton(
116
+ "#",
117
+ null,
118
+ "digitHashtagLabel",
119
+ "hashtag-solid",
120
+ "btnHashtag"
121
+ )
122
+ ];
105
123
  const getClasses = ({ noInput }) => classNames("base", ["no-input", Boolean(noInput)]);
106
124
  function handleKeyDown(x, e) {
107
125
  if (e.key === keyEnter && !x.pending && !x.disabled && !x.callActive && !x.noCall && x.value.length > 0 && e.target instanceof HTMLInputElement) {
108
126
  x._onDial();
109
127
  } else {
110
- const key = e.key === "*" ? "Asterisk" : e.key === "#" ? "Hashtag" : e.key;
111
- const digit = x.shadowRoot.querySelector(`#btn${key}`);
112
- if (digit) {
113
- digit.active = true;
114
- setTimeout(() => {
115
- digit.active = false;
116
- }, 200);
128
+ const elementIndex = DIAL_PAD_BUTTONS.findIndex((x2) => x2.value === e.key);
129
+ if (elementIndex > -1) {
130
+ const digit = x.shadowRoot.querySelector(".digits").children[elementIndex];
131
+ if (digit) {
132
+ digit.active = true;
133
+ setTimeout(() => {
134
+ digit.active = false;
135
+ }, 200);
136
+ }
117
137
  }
118
138
  }
119
139
  return true;
@@ -124,6 +144,14 @@ function syncFieldAndPadValues(x) {
124
144
  function stopPropagation(_, { event: e }) {
125
145
  e.stopImmediatePropagation();
126
146
  }
147
+ function deleteLastCharacter(dialPad) {
148
+ dialPad.value = dialPad.value.slice(0, -1);
149
+ dialPad.$emit("input");
150
+ dialPad.$emit("change");
151
+ if (dialPad.value === "") {
152
+ dialPad._textFieldEl.focus();
153
+ }
154
+ }
127
155
  function renderTextField(textFieldTag, buttonTag) {
128
156
  return html`<${textFieldTag} ${ref(
129
157
  "_textFieldEl"
@@ -140,51 +168,47 @@ function renderTextField(textFieldTag, buttonTag) {
140
168
  ${when(
141
169
  (x) => x.value && x.value.length && x.value.length > 0,
142
170
  html`<${buttonTag}
143
- slot="action-items" size='super-condensed' icon="backspace-line" aria-label="${(x) => x.deleteAriaLabel || x.locale.dialPad.deleteLabel}"
144
- appearance='ghost' ?disabled="${(x) => x.disabled || x.callActive}" @click="${(x) => x._deleteLastCharacter()}">
171
+ slot="action-items"
172
+ size='super-condensed'
173
+ icon="backspace-line"
174
+ aria-label="${(x) => x.deleteAriaLabel || x.locale.dialPad.deleteLabel}"
175
+ appearance='ghost'
176
+ ?disabled="${(x) => x.disabled || x.callActive}"
177
+ @click="${(x) => deleteLastCharacter(x)}">
145
178
  </${buttonTag}>`
146
179
  )}
147
180
  </${textFieldTag}>`;
148
181
  }
182
+ function onDigitClick(digit, { parent: dialPad, event }) {
183
+ dialPad.value += digit.value;
184
+ dialPad.$emit("keypad-click", event.currentTarget);
185
+ dialPad.$emit("input");
186
+ dialPad.$emit("change");
187
+ }
149
188
  function renderDigits(buttonTag, iconTag) {
150
189
  return html`
151
- <${buttonTag} id='btn1' value='1' stacked appearance="ghost-light" shape="pill" label="&nbsp;" size='condensed' class="digit-btn" aria-label="${(x) => x.locale.dialPad.digitOneLabel}" ?disabled="${(x) => x.disabled}" @click="${(x, c) => x._onDigit(
152
- c.event
153
- )}"><${iconTag} slot='icon' name='one-solid' class='digit-btn-num'></${iconTag}></${buttonTag}>
154
- <${buttonTag} id='btn2' value='2' stacked appearance="ghost-light" shape="pill" label='ABC' size='condensed' class="digit-btn" aria-label="${(x) => x.locale.dialPad.digitTwoLabel}" ?disabled="${(x) => x.disabled}" @click="${(x, c) => x._onDigit(
155
- c.event
156
- )}"><${iconTag} slot='icon' name='two-solid' class='digit-btn-num'></${iconTag}></${buttonTag}>
157
- <${buttonTag} id='btn3' value='3' stacked appearance="ghost-light" shape="pill" label='DEF' size='condensed' class="digit-btn" aria-label="${(x) => x.locale.dialPad.digitThreeLabel}" ?disabled="${(x) => x.disabled}" @click="${(x, c) => x._onDigit(
158
- c.event
159
- )}"><${iconTag} slot='icon' name='three-solid' class='digit-btn-num'></${iconTag}></${buttonTag}>
160
- <${buttonTag} id='btn4' value='4' stacked appearance="ghost-light" shape="pill" label='GHI' size='condensed' class="digit-btn" aria-label="${(x) => x.locale.dialPad.digitFourLabel}" ?disabled="${(x) => x.disabled}" @click="${(x, c) => x._onDigit(
161
- c.event
162
- )}"><${iconTag} slot='icon' name='four-solid' class='digit-btn-num'></${iconTag}></${buttonTag}>
163
- <${buttonTag} id='btn5' value='5' stacked appearance="ghost-light" shape="pill" label='JKL' size='condensed' class="digit-btn" aria-label="${(x) => x.locale.dialPad.digitFiveLabel}" ?disabled="${(x) => x.disabled}" @click="${(x, c) => x._onDigit(
164
- c.event
165
- )}"><${iconTag} slot='icon' name='five-solid' class='digit-btn-num'></${iconTag}></${buttonTag}>
166
- <${buttonTag} id='btn6' value='6' stacked appearance="ghost-light" shape="pill" label='MNO' size='condensed' class="digit-btn" aria-label="${(x) => x.locale.dialPad.digitSixLabel}" ?disabled="${(x) => x.disabled}" @click="${(x, c) => x._onDigit(
167
- c.event
168
- )}"><${iconTag} slot='icon' name='six-solid' class='digit-btn-num'></${iconTag}></${buttonTag}>
169
- <${buttonTag} id='btn7' value='7' stacked appearance="ghost-light" shape="pill" label='PQRS' size='condensed' class="digit-btn" aria-label="${(x) => x.locale.dialPad.digitSevenLabel}" ?disabled="${(x) => x.disabled}" @click="${(x, c) => x._onDigit(
170
- c.event
171
- )}"><${iconTag} slot='icon' name='seven-solid' class='digit-btn-num'></${iconTag}></${buttonTag}>
172
- <${buttonTag} id='btn8' value='8' stacked appearance="ghost-light" shape="pill" label='TUV' size='condensed' class="digit-btn" aria-label="${(x) => x.locale.dialPad.digitEightLabel}" ?disabled="${(x) => x.disabled}" @click="${(x, c) => x._onDigit(
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
- `;
190
+ ${repeat(
191
+ (_) => DIAL_PAD_BUTTONS,
192
+ html`
193
+ <${buttonTag}
194
+ id="${(x) => x.id}"
195
+ value="${(x) => x.value}"
196
+ stacked
197
+ appearance="ghost-light"
198
+ shape="pill"
199
+ label="${(x) => x.label === "&nbsp;" ? " " : x.label}"
200
+ size='condensed'
201
+ class="digit-btn"
202
+ aria-label="${(x, c) => c.parent.locale.dialPad[x.ariaLabel]}"
203
+ ?disabled="${(_, c) => c.parent.disabled}"
204
+ @click="${onDigitClick}">
205
+ <${iconTag} slot="icon"
206
+ name="${(x) => x.icon}"
207
+ class="digit-btn-num"></${iconTag}>
208
+ </${buttonTag}>
209
+ `
210
+ )}
211
+ `;
188
212
  }
189
213
  function renderDialButton(buttonTag) {
190
214
  return html`<${buttonTag} class="call-btn"
@@ -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');
@@ -31,15 +31,20 @@ class Dialog extends index.FoundationElement {
31
31
  this.ariaLabel = null;
32
32
  this.dismissButtonAriaLabel = null;
33
33
  this.noLightDismiss = false;
34
+ this.noDismissOnEsc = false;
35
+ this.noDismissButton = false;
36
+ this.nonDismissible = false;
34
37
  this.modal = false;
35
38
  this._openedAsModal = false;
36
39
  this.#handleScrimClick = (event) => {
37
- if (event.target !== this.#dialog || this.noLightDismiss) {
40
+ if (event.target !== this.#dialog || !this.#isDismissibleVia("light-dismiss")) {
38
41
  return;
39
42
  }
40
43
  const rect = this.#dialog.getBoundingClientRect();
41
44
  const clickedInDialog = rect.top <= event.clientY && event.clientY <= rect.top + rect.height && rect.left <= event.clientX && event.clientX <= rect.left + rect.width;
42
- this.open = clickedInDialog;
45
+ if (!clickedInDialog) {
46
+ this._handleCloseRequest();
47
+ }
43
48
  };
44
49
  this.#handleInternalFormSubmit = (event) => {
45
50
  if (event.target.method !== "dialog") {
@@ -98,8 +103,47 @@ class Dialog extends index.FoundationElement {
98
103
  this.$emit("open", void 0, { bubbles: false });
99
104
  }
100
105
  }
106
+ get _showDismissButton() {
107
+ return this.#isDismissibleVia("dismiss-button");
108
+ }
109
+ #isDismissibleVia(method) {
110
+ if (this.nonDismissible) {
111
+ return false;
112
+ }
113
+ switch (method) {
114
+ case "escape":
115
+ return !this.noDismissOnEsc;
116
+ case "dismiss-button":
117
+ return !this.noDismissButton;
118
+ case "light-dismiss":
119
+ return !this.noLightDismiss;
120
+ }
121
+ }
101
122
  #handleScrimClick;
102
123
  #handleInternalFormSubmit;
124
+ /**
125
+ * @internal
126
+ */
127
+ _onKeyDown(event) {
128
+ if (index$1.handleEscapeKeyAndStopPropogation(event) && this._openedAsModal) {
129
+ if (this.#isDismissibleVia("escape")) {
130
+ this._handleCloseRequest();
131
+ }
132
+ return false;
133
+ }
134
+ return true;
135
+ }
136
+ /**
137
+ * @internal
138
+ */
139
+ _handleCloseRequest() {
140
+ if (this.$emit("cancel", void 0, {
141
+ bubbles: false,
142
+ cancelable: true
143
+ })) {
144
+ this.open = false;
145
+ }
146
+ }
103
147
  close() {
104
148
  this.open = false;
105
149
  }
@@ -176,6 +220,15 @@ __decorateClass([
176
220
  __decorateClass([
177
221
  index.attr({ attribute: "no-light-dismiss", mode: "boolean" })
178
222
  ], Dialog.prototype, "noLightDismiss");
223
+ __decorateClass([
224
+ index.attr({ attribute: "no-dismiss-on-esc", mode: "boolean" })
225
+ ], Dialog.prototype, "noDismissOnEsc");
226
+ __decorateClass([
227
+ index.attr({ attribute: "no-dismiss-button", mode: "boolean" })
228
+ ], Dialog.prototype, "noDismissButton");
229
+ __decorateClass([
230
+ index.attr({ attribute: "non-dismissible", mode: "boolean" })
231
+ ], Dialog.prototype, "nonDismissible");
179
232
  __decorateClass([
180
233
  index.attr({ mode: "boolean" })
181
234
  ], Dialog.prototype, "modal");
@@ -227,17 +280,9 @@ function renderDismissButton(buttonTag) {
227
280
  size="condensed"
228
281
  class="dismiss-button"
229
282
  icon="close-line"
230
- @click="${(x) => x.open = false}"
283
+ @click="${(x) => x._handleCloseRequest()}"
231
284
  ></${buttonTag}>`;
232
285
  }
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
286
  const DialogTemplate = (context) => {
242
287
  const elevationTag = context.tagFor(definition.Elevation);
243
288
  const iconTag = context.tagFor(icon$1.Icon);
@@ -245,7 +290,7 @@ const DialogTemplate = (context) => {
245
290
  return index.html`
246
291
  <${elevationTag} dp="8">
247
292
  <dialog class="${getClasses}"
248
- @keydown="${(x, c) => handleEscapeKey(x, c.event)}"
293
+ @keydown="${(x, c) => x._onKeyDown(c.event)}"
249
294
  @cancel="${(_, c) => c.event.preventDefault()}"
250
295
  aria-label="${(x) => x.ariaLabel}"
251
296
  ?aria-modal="${(x) => x._openedAsModal}"
@@ -258,7 +303,7 @@ const DialogTemplate = (context) => {
258
303
  </slot>
259
304
  ${when.when((x) => x.headline, headline())}
260
305
  ${when.when((x) => x.subtitle, subtitle())}
261
- ${renderDismissButton(buttonTag)}
306
+ ${when.when((x) => x._showDismissButton, renderDismissButton(buttonTag))}
262
307
  </div>
263
308
  <div class="body ${(x) => x.fullWidthBody ? "full-width" : ""}" >
264
309
  <slot name="body" ${slotted.slotted("bodySlottedContent")}></slot>