@vonage/vivid 3.39.0 → 3.40.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 (147) hide show
  1. package/accordion/index.js +1 -1
  2. package/accordion-item/index.js +1 -1
  3. package/alert/index.js +3 -2
  4. package/banner/index.js +2 -1
  5. package/breadcrumb-item/index.js +1 -1
  6. package/button/index.js +2 -1
  7. package/card/index.js +1 -1
  8. package/checkbox/index.js +1 -1
  9. package/combobox/index.js +5 -3
  10. package/custom-elements.json +512 -0
  11. package/data-grid/index.js +1 -0
  12. package/date-picker/index.js +6 -4
  13. package/date-range-picker/index.js +5 -3
  14. package/dialog/index.js +6 -2
  15. package/elevation/index.js +1 -1
  16. package/fab/index.js +1 -1
  17. package/file-picker/index.js +2 -1
  18. package/focus/index.js +1 -1
  19. package/header/index.js +1 -1
  20. package/index.js +23 -19
  21. package/lib/checkbox/checkbox.d.ts +1 -0
  22. package/lib/components.d.ts +1 -0
  23. package/lib/dialog/dialog.d.ts +4 -0
  24. package/lib/dialog/locale.d.ts +3 -0
  25. package/lib/menu/menu.d.ts +1 -0
  26. package/lib/number-field/locale.d.ts +4 -0
  27. package/lib/number-field/number-field.d.ts +4 -2
  28. package/lib/progress/progress.d.ts +1 -0
  29. package/lib/progress-ring/progress-ring.d.ts +1 -0
  30. package/lib/radio/radio.d.ts +1 -0
  31. package/lib/selectable-box/definition.d.ts +3 -0
  32. package/lib/selectable-box/selectable-box.d.ts +13 -0
  33. package/lib/selectable-box/selectable-box.template.d.ts +4 -0
  34. package/lib/slider/definition.d.ts +1 -0
  35. package/lib/slider/slider.d.ts +5 -0
  36. package/lib/text-area/text-area.d.ts +3 -0
  37. package/lib/text-field/text-field.d.ts +5 -2
  38. package/listbox/index.js +3 -2
  39. package/locales/en-GB.js +7 -0
  40. package/locales/en-US.js +7 -0
  41. package/locales/ja-JP.js +7 -0
  42. package/locales/zh-CN.js +7 -0
  43. package/menu/index.js +4 -3
  44. package/menu-item/index.js +1 -1
  45. package/nav-disclosure/index.js +1 -1
  46. package/nav-item/index.js +1 -1
  47. package/number-field/index.js +3 -1
  48. package/option/index.js +1 -1
  49. package/package.json +1 -1
  50. package/pagination/index.js +2 -1
  51. package/popup/index.js +4 -3
  52. package/radio/index.js +1 -1
  53. package/select/index.js +5 -3
  54. package/selectable-box/index.js +23 -0
  55. package/shared/Reflector.js +65 -0
  56. package/shared/date-picker/calendar/segment.d.ts +21 -0
  57. package/shared/date-picker/date-picker-base.d.ts +1 -0
  58. package/shared/definition.js +2 -2
  59. package/shared/definition10.js +4 -73
  60. package/shared/definition11.js +1 -1
  61. package/shared/definition12.js +1 -1
  62. package/shared/definition13.js +2 -2
  63. package/shared/definition14.js +12 -5
  64. package/shared/definition15.js +3 -3
  65. package/shared/definition16.js +22 -8
  66. package/shared/definition17.js +5 -5
  67. package/shared/definition18.js +15 -8
  68. package/shared/definition19.js +18 -10
  69. package/shared/definition2.js +2 -2
  70. package/shared/definition20.js +1 -1
  71. package/shared/definition21.js +1 -1
  72. package/shared/definition22.js +2 -2
  73. package/shared/definition23.js +4 -3
  74. package/shared/definition24.js +2 -2
  75. package/shared/definition27.js +13 -4
  76. package/shared/definition28.js +2 -2
  77. package/shared/definition29.js +2 -2
  78. package/shared/definition3.js +1 -1
  79. package/shared/definition30.js +2 -2
  80. package/shared/definition32.js +1 -1
  81. package/shared/definition33.js +19 -4
  82. package/shared/definition34.js +2 -2
  83. package/shared/definition35.js +3 -2
  84. package/shared/definition36.js +11 -3
  85. package/shared/definition37.js +13 -9
  86. package/shared/definition38.js +2 -2
  87. package/shared/definition39.js +5 -4
  88. package/shared/definition4.js +4 -3
  89. package/shared/definition40.js +4 -4
  90. package/shared/definition41.js +111 -76
  91. package/shared/definition42.js +77 -557
  92. package/shared/definition43.js +568 -102
  93. package/shared/definition44.js +104 -135
  94. package/shared/definition45.js +153 -17
  95. package/shared/definition46.js +16 -79
  96. package/shared/definition47.js +53 -475
  97. package/shared/definition48.js +493 -25
  98. package/shared/definition49.js +22 -121
  99. package/shared/definition5.js +1 -1
  100. package/shared/definition50.js +114 -261
  101. package/shared/definition51.js +258 -119
  102. package/shared/definition52.js +258 -109
  103. package/shared/definition53.js +84 -74
  104. package/shared/definition54.js +114 -69
  105. package/shared/definition55.js +81 -292
  106. package/shared/definition56.js +302 -13
  107. package/shared/definition57.js +11 -41
  108. package/shared/definition58.js +20 -154
  109. package/shared/definition59.js +181 -0
  110. package/shared/definition6.js +1 -1
  111. package/shared/definition7.js +3 -2
  112. package/shared/definition8.js +2 -2
  113. package/shared/enums.js +71 -0
  114. package/shared/icon.js +1 -1
  115. package/shared/index2.js +28 -1
  116. package/shared/key-codes.js +1 -1
  117. package/shared/key-codes2.js +9 -0
  118. package/shared/listbox.js +2 -7
  119. package/shared/localization/Locale.d.ts +4 -0
  120. package/shared/presentationDate.js +194 -141
  121. package/shared/radio.js +7 -0
  122. package/shared/text-field.js +1 -1
  123. package/shared/utils/Reflector.d.ts +8 -0
  124. package/shared/utils/randomId.d.ts +1 -0
  125. package/side-drawer/index.js +1 -1
  126. package/slider/index.js +2 -2
  127. package/split-button/index.js +2 -2
  128. package/style.css +686 -559
  129. package/styles/core/all.css +1 -1
  130. package/styles/core/theme.css +1 -1
  131. package/styles/core/typography.css +1 -1
  132. package/styles/tokens/theme-dark.css +4 -4
  133. package/styles/tokens/theme-light.css +4 -4
  134. package/styles/tokens/vivid-2-compat.css +1 -1
  135. package/switch/index.js +2 -2
  136. package/tab/index.js +2 -2
  137. package/tab-panel/index.js +1 -1
  138. package/tabs/index.js +4 -4
  139. package/tag/index.js +2 -2
  140. package/tag-group/index.js +1 -1
  141. package/text-area/index.js +3 -2
  142. package/text-field/index.js +3 -2
  143. package/toggletip/index.js +5 -4
  144. package/tooltip/index.js +5 -4
  145. package/tree-item/index.js +2 -2
  146. package/tree-view/index.js +1 -1
  147. package/vivid.api.json +141 -0
@@ -1,6 +1,14 @@
1
1
  import { a as attr, F as FoundationElement, h as html, r as registerFactory } from './index.js';
2
- import { w as when } from './when.js';
2
+ import { C as Checkbox, a as checkboxRegistries } from './definition14.js';
3
+ import { f as focusRegistries } from './definition57.js';
4
+ import { a as radioRegistries } from './definition39.js';
5
+ import { f as focusTemplateFactory } from './focus2.js';
6
+ import { C as Connotation } from './enums.js';
7
+ import { R as Radio } from './radio.js';
3
8
  import { c as classNames } from './class-names.js';
9
+ import { w as when } from './when.js';
10
+
11
+ const styles = "/**\n * Do not edit directly\n * Generated on Wed, 01 Nov 2023 12:16:28 GMT\n */\n@supports selector(:focus-visible) {\n .base:focus-visible {\n outline: none;\n }\n}\n:host {\n display: flex;\n}\n\n.base {\n position: relative;\n padding: var(--selectable-box-spacing, 16px);\n border: 1px solid var(--_appearance-color-outline);\n background-color: var(--_appearance-color-fill);\n border-radius: 6px;\n inline-size: 100%;\n padding-block-start: calc(var(--selectable-box-spacing, 16px) + 36px);\n text-align: start;\n}\n.base.connotation-cta {\n /* @cssprop [--vvd-selectable-box-cta-firm=var(--vvd-color-cta-600)] */\n --_connotation-color-firm: var(--vvd-selectable-box-cta-firm, var(--vvd-color-cta-600));\n /* @cssprop [--vvd-selectable-box-cta-pale=var(--vvd-color-cta-300)] */\n --_connotation-color-pale: var(--vvd-selectable-box-cta-pale, var(--vvd-color-cta-300));\n /* @cssprop [--vvd-selectable-box-cta-soft=var(--vvd-color-cta-100)] */\n --_connotation-color-soft: var(--vvd-selectable-box-cta-soft, var(--vvd-color-cta-100));\n}\n.base:not(.connotation-cta) {\n /* @cssprop [--vvd-selectable-box-accent-firm=var(--vvd-color-canvas-text)] */\n --_connotation-color-firm: var(--vvd-selectable-box-accent-firm, var(--vvd-color-canvas-text));\n /* @cssprop [--vvd-selectable-box-accent-pale=var(--vvd-color-neutral-300)] */\n --_connotation-color-pale: var(--vvd-selectable-box-accent-pale, var(--vvd-color-neutral-300));\n /* @cssprop [--vvd-selectable-box-accent-soft=var(--vvd-color-neutral-100)] */\n --_connotation-color-soft: var(--vvd-selectable-box-accent-soft, var(--vvd-color-neutral-100));\n}\n.base {\n --_appearance-color-text: var(--_connotation-color-firm);\n --_appearance-color-fill: var(--vvd-color-canvas);\n --_appearance-color-outline: var(--_connotation-color-pale);\n}\n.base:where(:hover, .hover):where(:not(:disabled, .disabled, .readonly)) {\n --_appearance-color-text: var(--_connotation-color-firm);\n --_appearance-color-fill: var(--vvd-color-canvas);\n --_appearance-color-outline: var(--_connotation-color-firm);\n}\n.base:where(:checked, .checked):where(:not(:disabled, .disabled)) {\n --_appearance-color-text: var(--_connotation-color-firm);\n --_appearance-color-fill: var(--_connotation-color-soft);\n --_appearance-color-outline: var(--_connotation-color-pale);\n}\n.base:where(:checked, .checked):where(:hover, .hover):where(:not(:disabled, .disabled, .readonly)) {\n --_appearance-color-text: var(--_connotation-color-firm);\n --_appearance-color-fill: var(--_connotation-color-soft);\n --_appearance-color-outline: var(--_connotation-color-firm);\n}\n.base.tight {\n overflow: hidden;\n min-height: calc(var(--selectable-box-spacing, 16px) * 2 + 22px);\n padding: 0;\n}\n.base.clickable {\n cursor: pointer;\n}\n\n.focus-indicator {\n --focus-stroke-gap-color: transparent;\n --focus-inset: -1px;\n pointer-events: none;\n}\n.base:not(:focus-visible) > .focus-indicator {\n display: none;\n}\n\n.control {\n position: absolute;\n inset-block-start: var(--selectable-box-spacing, 16px);\n inset-inline-end: var(--selectable-box-spacing, 16px);\n}";
4
12
 
5
13
  var __defProp = Object.defineProperty;
6
14
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -13,97 +21,124 @@ var __decorateClass = (decorators, target, key, kind) => {
13
21
  __defProp(target, key, result);
14
22
  return result;
15
23
  };
16
- class SideDrawer extends FoundationElement {
24
+ class SelectableBox extends FoundationElement {
17
25
  constructor() {
18
26
  super(...arguments);
19
- this.alternate = false;
20
- this.modal = false;
21
- this.open = false;
22
- this.trailing = false;
27
+ this.checked = false;
28
+ this.clickable = false;
29
+ this.controlAriaLabel = null;
30
+ this.controlAriaLabelledby = null;
31
+ this.tight = false;
23
32
  }
24
- attributeChangedCallback(name, oldValue, newValue) {
25
- super.attributeChangedCallback(name, oldValue, newValue);
26
- switch (name) {
27
- case "open": {
28
- this.open ? this.#open() : this.#close();
29
- }
30
- }
33
+ /**
34
+ * @internal
35
+ */
36
+ _handleCheckedChange() {
37
+ if (this.controlType === "radio" && this.checked)
38
+ return;
39
+ this.checked = !this.checked;
40
+ this.$emit("change");
31
41
  }
32
- #close() {
33
- this.$emit("close", void 0, { bubbles: false });
34
- }
35
- #open() {
36
- this.$emit("open", void 0, { bubbles: false });
42
+ /**
43
+ * @internal
44
+ */
45
+ _handleKeydown(event) {
46
+ if (event.code === "Space" || event.code === "Enter" && this.clickable)
47
+ this._handleCheckedChange();
48
+ return true;
37
49
  }
38
50
  }
39
51
  __decorateClass([
40
- attr({
41
- mode: "boolean"
42
- })
43
- ], SideDrawer.prototype, "alternate", 2);
52
+ attr({ mode: "boolean" })
53
+ ], SelectableBox.prototype, "checked", 2);
44
54
  __decorateClass([
45
- attr({
46
- mode: "boolean"
47
- })
48
- ], SideDrawer.prototype, "modal", 2);
55
+ attr({ mode: "boolean" })
56
+ ], SelectableBox.prototype, "clickable", 2);
49
57
  __decorateClass([
50
- attr({
51
- mode: "boolean"
52
- })
53
- ], SideDrawer.prototype, "open", 2);
58
+ attr
59
+ ], SelectableBox.prototype, "connotation", 2);
54
60
  __decorateClass([
55
- attr({
56
- mode: "boolean"
57
- })
58
- ], SideDrawer.prototype, "trailing", 2);
59
-
60
- const styles = "/**\n * Do not edit directly\n * Generated on Tue, 17 Oct 2023 15:27:52 GMT\n */\n.control {\n position: fixed;\n z-index: 1;\n background-color: var(--vvd-color-canvas);\n color: var(--vvd-color-canvas-text);\n inline-size: 280px;\n inset-block: 0;\n overflow-y: auto;\n}\n.control[part~=vvd-theme-alternate] {\n background-color: var(--vvd-color-canvas);\n color: var(--vvd-color-canvas-text);\n color-scheme: var(--vvd-color-scheme);\n}\n.control.trailing {\n inset-inline-end: 0;\n}\n.control:not(.open).trailing {\n transform: translateX(100%);\n}\n.control:not(.open):not(.trailing) {\n transform: translateX(-100%);\n}\n.control.open:not(.modal).trailing + .side-drawer-app-content {\n margin-inline-end: var(--side-drawer-app-content-offset, 280px);\n}\n.control.open:not(.modal):not(.trailing) + .side-drawer-app-content {\n margin-inline-start: var(--side-drawer-app-content-offset, 280px);\n}\n@media (prefers-reduced-motion: no-preference) {\n .control {\n transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);\n }\n}\n\n.scrim {\n background-color: var(--vvd-color-canvas-text, currentColor);\n opacity: 0.5;\n position: fixed;\n inset: 0;\n}\n.scrim:not(.open) {\n display: none;\n}";
61
+ attr({ attribute: "control-aria-label" })
62
+ ], SelectableBox.prototype, "controlAriaLabel", 2);
63
+ __decorateClass([
64
+ attr({ attribute: "control-aria-labelledby" })
65
+ ], SelectableBox.prototype, "controlAriaLabelledby", 2);
66
+ __decorateClass([
67
+ attr({ attribute: "control-type" })
68
+ ], SelectableBox.prototype, "controlType", 2);
69
+ __decorateClass([
70
+ attr({ mode: "boolean" })
71
+ ], SelectableBox.prototype, "tight", 2);
61
72
 
62
- const getClasses = ({
63
- modal,
64
- open,
65
- trailing
66
- }) => classNames(
67
- "control",
68
- ["modal", modal],
69
- ["open", open],
70
- ["trailing", trailing]
73
+ const getClasses = ({ connotation, tight, checked, clickable }) => classNames(
74
+ "base",
75
+ [`connotation-${connotation}`, Boolean(connotation)],
76
+ ["tight", tight],
77
+ ["checked", checked],
78
+ ["clickable", clickable],
79
+ ["readonly", !clickable]
71
80
  );
72
- const getScrimClasses = ({
73
- open
74
- }) => classNames(
75
- "scrim",
76
- ["open", open]
77
- );
78
- const sideDrawerTemplate = () => html`
79
- <aside class="${getClasses}" part="base ${(x) => x.alternate ? "vvd-theme-alternate" : ""}"
80
- @keydown="${(x, c) => handleKeydown(x, c.event)}">
81
- <slot></slot>
82
- </aside>
83
-
84
- <div class="side-drawer-app-content" ?inert="${(x) => x.open && x.modal}">
85
- <slot name="app-content"></slot>
81
+ function handleControlChange(x) {
82
+ if (!x.clickable)
83
+ x._handleCheckedChange();
84
+ }
85
+ function checkbox(context) {
86
+ const checkboxTag = context.tagFor(Checkbox);
87
+ return html`${when((x) => x.controlType !== "radio", html`
88
+ <${checkboxTag}
89
+ aria-label="${(x) => !x.clickable && x.controlAriaLabel ? x.controlAriaLabel : null}"
90
+ aria-labelledby="${(x) => !x.clickable && x.controlAriaLabelledby ? x.controlAriaLabelledby : null}"
91
+ tabindex="${(x) => x.clickable ? "-1" : "0"}"
92
+ aria-hidden="${(x) => x.clickable}"
93
+ @change="${(x) => handleControlChange(x)}"
94
+ class="control checkbox"
95
+ connotation="${(x) => x.connotation === "cta" ? Connotation.CTA : Connotation.Accent}"
96
+ :checked="${(x) => x.checked}"
97
+ ></${checkboxTag}>`)}
98
+ `;
99
+ }
100
+ function radio(context) {
101
+ const radioTag = context.tagFor(Radio);
102
+ return html`${when((x) => x.controlType === "radio", html`
103
+ <${radioTag}
104
+ aria-label="${(x) => !x.clickable && x.controlAriaLabel ? x.controlAriaLabel : null}"
105
+ aria-labelledby="${(x) => !x.clickable && x.controlAriaLabelledby ? x.controlAriaLabelledby : ""}"
106
+ tabindex="${(x) => x.clickable ? "-1" : "0"}"
107
+ aria-hidden="${(x) => x.clickable}"
108
+ @change="${(x) => handleControlChange(x)}"
109
+ class="control radio"
110
+ connotation="${(x) => x.connotation === "cta" ? Connotation.CTA : Connotation.Accent}"
111
+ :checked="${(x) => x.checked}"
112
+ ></${radioTag}>`)}
113
+ `;
114
+ }
115
+ const SelectableBoxTemplate = (context) => {
116
+ const focusTemplate = focusTemplateFactory(context);
117
+ return html`
118
+ <div
119
+ class="${getClasses}"
120
+ tabindex="${(x) => x.clickable ? "0" : null}"
121
+ role="${(x) => x.clickable ? "button" : null}"
122
+ aria-pressed="${(x) => x.clickable && x.checked ? x.checked : null}"
123
+ aria-label="${(x) => x.clickable ? x.controlAriaLabel : null}"
124
+ aria-labelledby="${(x) => x.clickable ? x.controlAriaLabelledby : null}"
125
+ @keydown="${(x, c) => x._handleKeydown(c.event)}"
126
+ @click="${(x) => x.clickable ? x._handleCheckedChange() : null}"
127
+ >
128
+ ${(x) => x.clickable ? focusTemplate : ""}
129
+ ${checkbox(context)}
130
+ ${radio(context)}
131
+ <slot></slot>
86
132
  </div>
87
-
88
- ${when(
89
- (x) => x.modal,
90
- html`<div class="${getScrimClasses}" @click="${(x) => x.open = false}"></div>`
91
- )}
92
133
  `;
93
- const handleKeydown = (x, { key }) => {
94
- if (key === "Escape") {
95
- x.open = false;
96
- } else {
97
- return true;
98
- }
99
134
  };
100
135
 
101
- const sideDrawerDefinition = SideDrawer.compose({
102
- baseName: "side-drawer",
103
- template: sideDrawerTemplate,
136
+ const selectableBoxDefinition = SelectableBox.compose({
137
+ baseName: "selectable-box",
138
+ template: SelectableBoxTemplate,
104
139
  styles
105
140
  });
106
- const sideDrawerRegistries = [sideDrawerDefinition()];
107
- const registerSideDrawer = registerFactory(sideDrawerRegistries);
141
+ const selectableBoxRegistries = [selectableBoxDefinition(), ...checkboxRegistries, ...focusRegistries, ...radioRegistries];
142
+ const registerSelectableBox = registerFactory(selectableBoxRegistries);
108
143
 
109
- export { sideDrawerRegistries as a, registerSideDrawer as r, sideDrawerDefinition as s };
144
+ export { selectableBoxRegistries as a, registerSelectableBox as r, selectableBoxDefinition as s };