@vonage/vivid 4.4.0 → 4.6.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 (235) hide show
  1. package/custom-elements.json +7181 -6876
  2. package/elevation/index.cjs +1 -1
  3. package/elevation/index.js +1 -1
  4. package/index.cjs +80 -74
  5. package/index.js +23 -22
  6. package/lib/components.d.ts +1 -0
  7. package/lib/fab/fab.d.ts +1 -1
  8. package/lib/icon/icon.d.ts +1 -1
  9. package/lib/menu/menu.d.ts +2 -1
  10. package/lib/number-field/number-field.d.ts +3 -1
  11. package/lib/searchable-select/definition.d.ts +4 -0
  12. package/lib/searchable-select/locale.d.ts +6 -0
  13. package/lib/searchable-select/option-tag.d.ts +14 -0
  14. package/lib/searchable-select/option-tag.template.d.ts +4 -0
  15. package/lib/searchable-select/searchable-select.d.ts +29 -0
  16. package/lib/searchable-select/searchable-select.form-associated.d.ts +10 -0
  17. package/lib/searchable-select/searchable-select.template.d.ts +4 -0
  18. package/lib/select/select.d.ts +4 -1
  19. package/lib/tab/locale.d.ts +3 -0
  20. package/lib/tab/tab.d.ts +5 -1
  21. package/lib/tabs/tabs.d.ts +2 -0
  22. package/lib/tag/definition.d.ts +1 -0
  23. package/lib/text-field/text-field.d.ts +3 -1
  24. package/lib/video-player/video-player.d.ts +0 -1
  25. package/listbox/index.cjs +1 -1
  26. package/listbox/index.js +1 -1
  27. package/locales/de-DE.cjs +12 -0
  28. package/locales/de-DE.js +12 -0
  29. package/locales/en-GB.cjs +12 -0
  30. package/locales/en-GB.js +12 -0
  31. package/locales/en-US.cjs +12 -0
  32. package/locales/en-US.js +12 -0
  33. package/locales/ja-JP.cjs +12 -0
  34. package/locales/ja-JP.js +12 -0
  35. package/locales/zh-CN.cjs +12 -0
  36. package/locales/zh-CN.js +12 -0
  37. package/package.json +6 -1
  38. package/popup/index.cjs +1 -1
  39. package/popup/index.js +1 -1
  40. package/searchable-select/index.cjs +5 -0
  41. package/searchable-select/index.js +3 -0
  42. package/select/index.cjs +1 -1
  43. package/select/index.js +1 -1
  44. package/selectable-box/index.cjs +1 -1
  45. package/selectable-box/index.js +1 -1
  46. package/shared/anchored.js +1 -1
  47. package/shared/calendar-event.js +1 -1
  48. package/shared/definition.cjs +2 -2
  49. package/shared/definition.js +2 -2
  50. package/shared/definition11.cjs +1 -1
  51. package/shared/definition11.js +1 -1
  52. package/shared/definition12.cjs +1 -1
  53. package/shared/definition12.js +1 -1
  54. package/shared/definition13.js +1 -1
  55. package/shared/definition14.cjs +1 -1
  56. package/shared/definition14.js +1 -1
  57. package/shared/definition15.cjs +7 -8
  58. package/shared/definition15.js +2 -3
  59. package/shared/definition16.cjs +11 -7
  60. package/shared/definition16.js +10 -6
  61. package/shared/definition17.cjs +2 -2
  62. package/shared/definition17.js +2 -2
  63. package/shared/definition18.cjs +5 -6
  64. package/shared/definition18.js +3 -4
  65. package/shared/definition19.cjs +5 -6
  66. package/shared/definition19.js +3 -4
  67. package/shared/definition20.cjs +16 -38
  68. package/shared/definition20.js +17 -39
  69. package/shared/definition21.cjs +7 -6
  70. package/shared/definition21.js +8 -7
  71. package/shared/definition23.cjs +1 -1
  72. package/shared/definition23.js +2 -2
  73. package/shared/definition24.cjs +2 -2
  74. package/shared/definition24.js +2 -2
  75. package/shared/definition25.cjs +6 -7
  76. package/shared/definition25.js +2 -3
  77. package/shared/definition26.cjs +1 -1
  78. package/shared/definition26.js +2 -2
  79. package/shared/definition27.cjs +1 -1
  80. package/shared/definition27.js +1 -1
  81. package/shared/definition28.js +1 -1
  82. package/shared/definition29.cjs +8 -4
  83. package/shared/definition29.js +8 -4
  84. package/shared/definition3.cjs +1 -1
  85. package/shared/definition3.js +2 -2
  86. package/shared/definition30.cjs +4 -2
  87. package/shared/definition30.js +4 -2
  88. package/shared/definition31.cjs +1 -1
  89. package/shared/definition31.js +2 -2
  90. package/shared/definition32.cjs +1 -1
  91. package/shared/definition32.js +1 -1
  92. package/shared/definition34.cjs +2 -3
  93. package/shared/definition34.js +2 -3
  94. package/shared/definition35.cjs +21 -16
  95. package/shared/definition35.js +16 -11
  96. package/shared/definition36.cjs +50 -207
  97. package/shared/definition36.js +51 -207
  98. package/shared/definition37.js +1 -1
  99. package/shared/definition38.cjs +1 -1
  100. package/shared/definition38.js +1 -1
  101. package/shared/definition4.cjs +6 -4
  102. package/shared/definition4.js +7 -5
  103. package/shared/definition41.cjs +1 -1
  104. package/shared/definition41.js +1 -1
  105. package/shared/definition42.cjs +6 -7
  106. package/shared/definition42.js +6 -7
  107. package/shared/definition43.cjs +998 -643
  108. package/shared/definition43.js +992 -638
  109. package/shared/definition44.cjs +723 -112
  110. package/shared/definition44.js +722 -111
  111. package/shared/definition45.cjs +121 -79
  112. package/shared/definition45.js +120 -78
  113. package/shared/definition46.cjs +81 -616
  114. package/shared/definition46.js +80 -614
  115. package/shared/definition47.cjs +609 -116
  116. package/shared/definition47.js +607 -115
  117. package/shared/definition48.cjs +116 -134
  118. package/shared/definition48.js +115 -133
  119. package/shared/definition49.cjs +149 -19
  120. package/shared/definition49.js +148 -18
  121. package/shared/definition5.cjs +5 -6
  122. package/shared/definition5.js +5 -6
  123. package/shared/definition50.cjs +21 -82
  124. package/shared/definition50.js +20 -81
  125. package/shared/definition51.cjs +78 -494
  126. package/shared/definition51.js +77 -493
  127. package/shared/definition52.cjs +568 -28
  128. package/shared/definition52.js +567 -27
  129. package/shared/definition53.cjs +28 -123
  130. package/shared/definition53.js +27 -123
  131. package/shared/definition54.cjs +115 -296
  132. package/shared/definition54.js +114 -295
  133. package/shared/definition55.cjs +258 -318
  134. package/shared/definition55.js +252 -312
  135. package/shared/definition56.cjs +303 -784
  136. package/shared/definition56.js +298 -779
  137. package/shared/definition57.cjs +802 -95
  138. package/shared/definition57.js +801 -94
  139. package/shared/definition58.cjs +95 -60
  140. package/shared/definition58.js +94 -59
  141. package/shared/definition59.cjs +117 -75
  142. package/shared/definition59.js +116 -74
  143. package/shared/definition6.cjs +1 -1
  144. package/shared/definition6.js +1 -1
  145. package/shared/definition60.cjs +70 -285
  146. package/shared/definition60.js +71 -286
  147. package/shared/definition61.cjs +296 -325
  148. package/shared/definition61.js +295 -324
  149. package/shared/definition62.cjs +66160 -27
  150. package/shared/definition62.js +66159 -26
  151. package/shared/definition63.cjs +24 -1952
  152. package/shared/definition63.js +23 -1950
  153. package/shared/definition64.cjs +1976 -0
  154. package/shared/definition64.js +1971 -0
  155. package/shared/definition7.cjs +1 -1
  156. package/shared/definition7.js +1 -1
  157. package/shared/definition8.cjs +2 -3
  158. package/shared/definition8.js +3 -4
  159. package/shared/definition9.cjs +1 -1
  160. package/shared/definition9.js +1 -1
  161. package/shared/dialog/index.d.ts +1 -0
  162. package/shared/form-elements.cjs +236 -0
  163. package/shared/form-elements.js +229 -0
  164. package/shared/icon.js +1 -1
  165. package/shared/index2.cjs +6 -256
  166. package/shared/index2.js +6 -249
  167. package/shared/listbox-option.cjs +204 -0
  168. package/shared/listbox-option.js +201 -0
  169. package/shared/listbox.cjs +3 -3
  170. package/shared/listbox.js +1 -1
  171. package/shared/localization/Locale.d.ts +4 -0
  172. package/shared/localized.cjs +26 -2
  173. package/shared/localized.js +25 -2
  174. package/shared/playbackRates.cjs +13 -0
  175. package/shared/playbackRates.js +11 -0
  176. package/shared/presentationDate.cjs +11 -11
  177. package/shared/presentationDate.js +11 -11
  178. package/shared/scrollIntoView.cjs +51 -0
  179. package/shared/scrollIntoView.js +49 -0
  180. package/shared/slider.template.cjs +1 -1
  181. package/shared/slider.template.js +1 -1
  182. package/shared/text-anchor.cjs +1 -1
  183. package/shared/text-anchor.js +1 -1
  184. package/shared/text-field.cjs +1 -1
  185. package/shared/text-field.js +1 -1
  186. package/shared/utils/playbackRates.d.ts +1 -0
  187. package/shared/utils/scrollIntoView.d.ts +1 -0
  188. package/side-drawer/index.cjs +1 -1
  189. package/side-drawer/index.js +1 -1
  190. package/slider/index.cjs +1 -1
  191. package/slider/index.js +1 -1
  192. package/split-button/index.cjs +1 -1
  193. package/split-button/index.js +1 -1
  194. package/styles/core/all.css +1 -1
  195. package/styles/core/theme.css +1 -1
  196. package/styles/core/typography.css +1 -1
  197. package/styles/tokens/theme-dark.css +4 -4
  198. package/styles/tokens/theme-light.css +4 -4
  199. package/styles/tokens/vivid-2-compat.css +1 -1
  200. package/switch/index.cjs +1 -1
  201. package/switch/index.js +1 -1
  202. package/tab/index.cjs +1 -1
  203. package/tab/index.js +1 -1
  204. package/tab-panel/index.cjs +1 -1
  205. package/tab-panel/index.js +1 -1
  206. package/tabs/index.cjs +1 -1
  207. package/tabs/index.js +1 -1
  208. package/tag/index.cjs +1 -1
  209. package/tag/index.js +1 -1
  210. package/tag-group/index.cjs +1 -1
  211. package/tag-group/index.js +1 -1
  212. package/text-area/index.cjs +1 -1
  213. package/text-area/index.js +1 -1
  214. package/text-field/index.cjs +1 -1
  215. package/text-field/index.js +1 -1
  216. package/time-picker/index.cjs +1 -1
  217. package/time-picker/index.js +1 -1
  218. package/toggletip/index.cjs +1 -1
  219. package/toggletip/index.js +1 -1
  220. package/tooltip/index.cjs +1 -1
  221. package/tooltip/index.js +1 -1
  222. package/tree-item/index.cjs +1 -1
  223. package/tree-item/index.js +1 -1
  224. package/tree-view/index.cjs +1 -1
  225. package/tree-view/index.js +1 -1
  226. package/video-player/index.cjs +1 -1
  227. package/video-player/index.js +1 -1
  228. package/vivid.api.json +312 -8
  229. package/appearance-ui/index.cjs +0 -102
  230. package/appearance-ui/index.js +0 -100
  231. package/lib/appearance-ui/appearance-ui.d.ts +0 -12
  232. package/lib/appearance-ui/appearance-ui.template.d.ts +0 -4
  233. package/lib/appearance-ui/definition.d.ts +0 -3
  234. package/shared/video-player.cjs +0 -65860
  235. package/shared/video-player.js +0 -65857
@@ -1,8 +1,14 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- const when = require('./when.cjs');
4
+ const definition = require('./definition15.cjs');
5
+ const definition$1 = require('./definition41.cjs');
6
+ const enums = require('./enums.cjs');
7
+ const radio$1 = require('./radio.cjs');
5
8
  const classNames = require('./class-names.cjs');
9
+ const when = require('./when.cjs');
10
+
11
+ const styles = ":host{display:flex}.base.connotation-cta{--_connotation-color-firm-all: var(--vvd-selectable-box-cta-firm-all, var(--vvd-color-cta-600));--_connotation-color-pale: var(--vvd-selectable-box-cta-pale, var(--vvd-color-cta-300));--_connotation-color-fierce: var(--vvd-selectable-box-cta-fierce, var(--vvd-color-cta-700));--_connotation-color-faint: var(--vvd-selectable-box-cta-faint, var(--vvd-color-cta-50));--_connotation-color-soft: var(--vvd-selectable-box-cta-soft, var(--vvd-color-cta-100))}.base:not(.connotation-cta){--_connotation-color-firm-all: var(--vvd-selectable-box-accent-firm-all, var(--vvd-color-neutral-600));--_connotation-color-pale: var(--vvd-selectable-box-accent-pale, var(--vvd-color-neutral-300));--_connotation-color-fierce: var(--vvd-selectable-box-accent-fierce, var(--vvd-color-neutral-700));--_connotation-color-faint: var(--vvd-selectable-box-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-selectable-box-accent-soft, var(--vvd-color-neutral-100))}.base{--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: transparent;--_appearance-color-outline: var(--_connotation-color-pale)}.base: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)}.base:where(.selected):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: var(--_connotation-color-pale)}.base:where(.selected):where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: var(--_connotation-color-firm-all)}.base{position:relative;padding:var(--selectable-box-spacing, 16px);border:1px solid var(--_appearance-color-outline);border-radius:8px;background-color:var(--_appearance-color-fill);inline-size:100%;padding-block-start:calc(var(--selectable-box-spacing, 16px) + 36px);text-align:start}.base:focus-visible{--focus-stroke-gap-color: transparent;box-shadow:inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:2px solid var(--focus-stroke-color, var(--vvd-color-canvas-text));outline-offset:calc(-2px - var(--focus-inset, 0px))}.base.tight{overflow:hidden;min-height:calc(var(--selectable-box-spacing, 16px) * 2 + 22px);padding:0}.base.clickable{cursor:pointer}.control{position:absolute;inset-block-start:var(--selectable-box-spacing, 16px);inset-inline-end:var(--selectable-box-spacing, 16px)}";
6
12
 
7
13
  var __defProp = Object.defineProperty;
8
14
  var __decorateClass = (decorators, target, key, kind) => {
@@ -13,97 +19,133 @@ var __decorateClass = (decorators, target, key, kind) => {
13
19
  if (result) __defProp(target, key, result);
14
20
  return result;
15
21
  };
16
- class SideDrawer extends index.FoundationElement {
22
+ class SelectableBox extends index.FoundationElement {
17
23
  constructor() {
18
24
  super(...arguments);
19
- this.alternate = false;
20
- this.modal = false;
21
- this.open = false;
22
- this.trailing = false;
25
+ this.ariaLabel = null;
26
+ this.checked = false;
27
+ this.clickable = false;
28
+ this.clickableBox = false;
29
+ this.tight = false;
23
30
  }
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
- }
31
+ /**
32
+ * @internal
33
+ */
34
+ _handleCheckedChange() {
35
+ if (this.controlType === "radio" && this.checked) return;
36
+ this.checked = !this.checked;
37
+ if (this.clickableBox || this.clickable) this.$emit("change");
31
38
  }
32
- #close() {
33
- this.$emit("close", void 0, { bubbles: false });
34
- }
35
- #open() {
36
- this.$emit("open", void 0, { bubbles: false });
39
+ /**
40
+ * @internal
41
+ */
42
+ _handleKeydown(event) {
43
+ if ((event.code === "Space" || event.code === "Enter") && (this.clickableBox || this.clickable))
44
+ return this._handleCheckedChange();
45
+ return true;
37
46
  }
38
47
  }
39
48
  __decorateClass([
40
- index.attr({
41
- mode: "boolean"
42
- })
43
- ], SideDrawer.prototype, "alternate");
49
+ index.attr({ attribute: "aria-label" })
50
+ ], SelectableBox.prototype, "ariaLabel");
44
51
  __decorateClass([
45
- index.attr({
46
- mode: "boolean"
47
- })
48
- ], SideDrawer.prototype, "modal");
52
+ index.attr({ mode: "boolean" })
53
+ ], SelectableBox.prototype, "checked");
49
54
  __decorateClass([
50
- index.attr({
51
- mode: "boolean"
52
- })
53
- ], SideDrawer.prototype, "open");
55
+ index.attr({ mode: "boolean" })
56
+ ], SelectableBox.prototype, "clickable");
54
57
  __decorateClass([
55
- index.attr({
56
- mode: "boolean"
57
- })
58
- ], SideDrawer.prototype, "trailing");
59
-
60
- const styles = ":host{display:block}.side-drawer-app-content{block-size:100%}.control{position:fixed;z-index:1;background-color:var(--vvd-color-canvas);color:var(--vvd-color-canvas-text);inline-size:280px;inset-block:0;overflow-y:auto}.control[part~=vvd-theme-alternate]{background-color:var(--vvd-color-canvas);color:var(--vvd-color-canvas-text);color-scheme:var(--vvd-color-scheme)}.control.trailing{inset-inline-end:0}.control:not(.open).trailing{transform:translate(100%)}.control:not(.open):not(.trailing){transform:translate(-100%)}.control.open:not(.modal).trailing+.side-drawer-app-content{margin-inline-end:var(--side-drawer-app-content-offset, 280px)}.control.open:not(.modal):not(.trailing)+.side-drawer-app-content{margin-inline-start:var(--side-drawer-app-content-offset, 280px)}@media (prefers-reduced-motion: no-preference){.control{transition:transform .2s cubic-bezier(.4,0,.2,1)}}.scrim{background-color:var(--vvd-color-canvas-text, currentColor);opacity:.5;position:fixed;inset:0}.scrim:not(.open){display:none}";
58
+ index.attr({ attribute: "clickable-box", mode: "boolean" })
59
+ ], SelectableBox.prototype, "clickableBox");
60
+ __decorateClass([
61
+ index.attr
62
+ ], SelectableBox.prototype, "connotation");
63
+ __decorateClass([
64
+ index.attr({ attribute: "control-type" })
65
+ ], SelectableBox.prototype, "controlType");
66
+ __decorateClass([
67
+ index.attr({ mode: "boolean" })
68
+ ], SelectableBox.prototype, "tight");
61
69
 
62
- const getClasses = ({ modal, open, trailing }) => classNames.classNames(
63
- "control",
64
- ["modal", modal],
65
- ["open", open],
66
- ["trailing", trailing]
70
+ const getClasses = ({
71
+ connotation,
72
+ tight,
73
+ checked,
74
+ clickableBox,
75
+ clickable
76
+ }) => classNames.classNames(
77
+ "base",
78
+ [`connotation-${connotation}`, Boolean(connotation)],
79
+ ["tight", tight],
80
+ ["selected", checked],
81
+ ["clickable", clickableBox || clickable],
82
+ ["readonly", !clickableBox && !clickable]
67
83
  );
68
- const getScrimClasses = ({ open }) => classNames.classNames("scrim", ["open", open]);
69
- const sideDrawerTemplate = () => index.html`
70
- <div
71
- class="${getClasses}"
72
- ?inert="${(x) => !x.open}"
73
- part="base ${(x) => x.alternate ? "vvd-theme-alternate" : ""}"
74
- @keydown="${(x, c) => handleKeydown(x, c.event)}"
75
- >
76
- <slot></slot>
77
- </div>
78
-
79
- <div class="side-drawer-app-content" ?inert="${(x) => x.open && x.modal}">
80
- <slot name="app-content"></slot>
81
- </div>
82
-
83
- ${when.when(
84
- (x) => x.modal,
85
- index.html`<div
86
- class="${getScrimClasses}"
87
- @click="${(x) => x.open = false}"
88
- ></div>`
89
- )}
90
- `;
91
- const handleKeydown = (x, { key }) => {
92
- if (key === "Escape") {
93
- x.open = false;
94
- } else {
95
- return true;
96
- }
84
+ function handleControlChange(x) {
85
+ if (!x.clickableBox) x._handleCheckedChange();
86
+ }
87
+ function checkbox(context) {
88
+ const checkboxTag = context.tagFor(definition.Checkbox);
89
+ return index.html`${when.when(
90
+ (x) => x.controlType !== "radio",
91
+ index.html`
92
+ <${checkboxTag}
93
+ aria-label="${(x) => !x.clickableBox && !x.clickable && x.ariaLabel ? x.ariaLabel : null}"
94
+ @change="${(x) => handleControlChange(x)}"
95
+ class="control checkbox"
96
+ connotation="${(x) => x.connotation === "cta" ? enums.Connotation.CTA : enums.Connotation.Accent}"
97
+ :checked="${(x) => x.checked}"
98
+ inert="${(x) => x.clickableBox || x.clickable ? true : null}"
99
+ ></${checkboxTag}>`
100
+ )} `;
101
+ }
102
+ function radio(context) {
103
+ const radioTag = context.tagFor(radio$1.Radio);
104
+ return index.html`${when.when(
105
+ (x) => x.controlType === "radio",
106
+ index.html`
107
+ <${radioTag}
108
+ aria-label="${(x) => !x.clickableBox && !x.clickable && x.ariaLabel ? x.ariaLabel : null}"
109
+ @change="${(x) => handleControlChange(x)}"
110
+ class="control radio"
111
+ connotation="${(x) => x.connotation === "cta" ? enums.Connotation.CTA : enums.Connotation.Accent}"
112
+ :checked="${(x) => x.checked}"
113
+ inert="${(x) => x.clickableBox || x.clickable ? true : null}"
114
+ ></${radioTag}>`
115
+ )} `;
116
+ }
117
+ const SelectableBoxTemplate = (context) => {
118
+ return index.html`<template role="presentation">
119
+ <div
120
+ class="${getClasses}"
121
+ tabindex="${(x) => x.clickableBox || x.clickable ? "0" : null}"
122
+ role="${(x) => x.clickableBox || x.clickable ? "button" : null}"
123
+ aria-pressed="${(x) => x.clickableBox || x.clickable ? x.checked ? "true" : "false" : null}"
124
+ aria-label="${(x) => x.clickableBox || x.clickable ? x.ariaLabel : null}"
125
+ @keydown="${(x, c) => x._handleKeydown(c.event)}"
126
+ @click="${(x) => x.clickableBox || x.clickable ? x._handleCheckedChange() : null}"
127
+ >
128
+ ${checkbox(context)} ${radio(context)}
129
+ <slot></slot>
130
+ </div>
131
+ </template>`;
97
132
  };
98
133
 
99
- const sideDrawerDefinition = SideDrawer.compose({
100
- baseName: "side-drawer",
101
- template: sideDrawerTemplate,
102
- styles
134
+ const selectableBoxDefinition = SelectableBox.compose({
135
+ baseName: "selectable-box",
136
+ template: SelectableBoxTemplate,
137
+ styles,
138
+ shadowOptions: {
139
+ delegatesFocus: true
140
+ }
103
141
  });
104
- const sideDrawerRegistries = [sideDrawerDefinition()];
105
- const registerSideDrawer = index.registerFactory(sideDrawerRegistries);
142
+ const selectableBoxRegistries = [
143
+ selectableBoxDefinition(),
144
+ ...definition.checkboxRegistries,
145
+ ...definition$1.radioRegistries
146
+ ];
147
+ const registerSelectableBox = index.registerFactory(selectableBoxRegistries);
106
148
 
107
- exports.registerSideDrawer = registerSideDrawer;
108
- exports.sideDrawerDefinition = sideDrawerDefinition;
109
- exports.sideDrawerRegistries = sideDrawerRegistries;
149
+ exports.registerSelectableBox = registerSelectableBox;
150
+ exports.selectableBoxDefinition = selectableBoxDefinition;
151
+ exports.selectableBoxRegistries = selectableBoxRegistries;
@@ -1,6 +1,12 @@
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';
1
+ import { F as FoundationElement, a as attr, h as html, r as registerFactory } from './index.js';
2
+ import { C as Checkbox, a as checkboxRegistries } from './definition15.js';
3
+ import { a as radioRegistries } from './definition41.js';
4
+ import { C as Connotation } from './enums.js';
5
+ import { R as Radio } from './radio.js';
3
6
  import { c as classNames } from './class-names.js';
7
+ import { w as when } from './when.js';
8
+
9
+ const styles = ":host{display:flex}.base.connotation-cta{--_connotation-color-firm-all: var(--vvd-selectable-box-cta-firm-all, var(--vvd-color-cta-600));--_connotation-color-pale: var(--vvd-selectable-box-cta-pale, var(--vvd-color-cta-300));--_connotation-color-fierce: var(--vvd-selectable-box-cta-fierce, var(--vvd-color-cta-700));--_connotation-color-faint: var(--vvd-selectable-box-cta-faint, var(--vvd-color-cta-50));--_connotation-color-soft: var(--vvd-selectable-box-cta-soft, var(--vvd-color-cta-100))}.base:not(.connotation-cta){--_connotation-color-firm-all: var(--vvd-selectable-box-accent-firm-all, var(--vvd-color-neutral-600));--_connotation-color-pale: var(--vvd-selectable-box-accent-pale, var(--vvd-color-neutral-300));--_connotation-color-fierce: var(--vvd-selectable-box-accent-fierce, var(--vvd-color-neutral-700));--_connotation-color-faint: var(--vvd-selectable-box-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-selectable-box-accent-soft, var(--vvd-color-neutral-100))}.base{--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: transparent;--_appearance-color-outline: var(--_connotation-color-pale)}.base: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)}.base:where(.selected):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: var(--_connotation-color-pale)}.base:where(.selected):where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: var(--_connotation-color-firm-all)}.base{position:relative;padding:var(--selectable-box-spacing, 16px);border:1px solid var(--_appearance-color-outline);border-radius:8px;background-color:var(--_appearance-color-fill);inline-size:100%;padding-block-start:calc(var(--selectable-box-spacing, 16px) + 36px);text-align:start}.base:focus-visible{--focus-stroke-gap-color: transparent;box-shadow:inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:2px solid var(--focus-stroke-color, var(--vvd-color-canvas-text));outline-offset:calc(-2px - var(--focus-inset, 0px))}.base.tight{overflow:hidden;min-height:calc(var(--selectable-box-spacing, 16px) * 2 + 22px);padding:0}.base.clickable{cursor:pointer}.control{position:absolute;inset-block-start:var(--selectable-box-spacing, 16px);inset-inline-end:var(--selectable-box-spacing, 16px)}";
4
10
 
5
11
  var __defProp = Object.defineProperty;
6
12
  var __decorateClass = (decorators, target, key, kind) => {
@@ -11,95 +17,131 @@ var __decorateClass = (decorators, target, key, kind) => {
11
17
  if (result) __defProp(target, key, result);
12
18
  return result;
13
19
  };
14
- class SideDrawer extends FoundationElement {
20
+ class SelectableBox extends FoundationElement {
15
21
  constructor() {
16
22
  super(...arguments);
17
- this.alternate = false;
18
- this.modal = false;
19
- this.open = false;
20
- this.trailing = false;
23
+ this.ariaLabel = null;
24
+ this.checked = false;
25
+ this.clickable = false;
26
+ this.clickableBox = false;
27
+ this.tight = false;
21
28
  }
22
- attributeChangedCallback(name, oldValue, newValue) {
23
- super.attributeChangedCallback(name, oldValue, newValue);
24
- switch (name) {
25
- case "open": {
26
- this.open ? this.#open() : this.#close();
27
- }
28
- }
29
+ /**
30
+ * @internal
31
+ */
32
+ _handleCheckedChange() {
33
+ if (this.controlType === "radio" && this.checked) return;
34
+ this.checked = !this.checked;
35
+ if (this.clickableBox || this.clickable) this.$emit("change");
29
36
  }
30
- #close() {
31
- this.$emit("close", void 0, { bubbles: false });
32
- }
33
- #open() {
34
- this.$emit("open", void 0, { bubbles: false });
37
+ /**
38
+ * @internal
39
+ */
40
+ _handleKeydown(event) {
41
+ if ((event.code === "Space" || event.code === "Enter") && (this.clickableBox || this.clickable))
42
+ return this._handleCheckedChange();
43
+ return true;
35
44
  }
36
45
  }
37
46
  __decorateClass([
38
- attr({
39
- mode: "boolean"
40
- })
41
- ], SideDrawer.prototype, "alternate");
47
+ attr({ attribute: "aria-label" })
48
+ ], SelectableBox.prototype, "ariaLabel");
42
49
  __decorateClass([
43
- attr({
44
- mode: "boolean"
45
- })
46
- ], SideDrawer.prototype, "modal");
50
+ attr({ mode: "boolean" })
51
+ ], SelectableBox.prototype, "checked");
47
52
  __decorateClass([
48
- attr({
49
- mode: "boolean"
50
- })
51
- ], SideDrawer.prototype, "open");
53
+ attr({ mode: "boolean" })
54
+ ], SelectableBox.prototype, "clickable");
52
55
  __decorateClass([
53
- attr({
54
- mode: "boolean"
55
- })
56
- ], SideDrawer.prototype, "trailing");
57
-
58
- const styles = ":host{display:block}.side-drawer-app-content{block-size:100%}.control{position:fixed;z-index:1;background-color:var(--vvd-color-canvas);color:var(--vvd-color-canvas-text);inline-size:280px;inset-block:0;overflow-y:auto}.control[part~=vvd-theme-alternate]{background-color:var(--vvd-color-canvas);color:var(--vvd-color-canvas-text);color-scheme:var(--vvd-color-scheme)}.control.trailing{inset-inline-end:0}.control:not(.open).trailing{transform:translate(100%)}.control:not(.open):not(.trailing){transform:translate(-100%)}.control.open:not(.modal).trailing+.side-drawer-app-content{margin-inline-end:var(--side-drawer-app-content-offset, 280px)}.control.open:not(.modal):not(.trailing)+.side-drawer-app-content{margin-inline-start:var(--side-drawer-app-content-offset, 280px)}@media (prefers-reduced-motion: no-preference){.control{transition:transform .2s cubic-bezier(.4,0,.2,1)}}.scrim{background-color:var(--vvd-color-canvas-text, currentColor);opacity:.5;position:fixed;inset:0}.scrim:not(.open){display:none}";
56
+ attr({ attribute: "clickable-box", mode: "boolean" })
57
+ ], SelectableBox.prototype, "clickableBox");
58
+ __decorateClass([
59
+ attr
60
+ ], SelectableBox.prototype, "connotation");
61
+ __decorateClass([
62
+ attr({ attribute: "control-type" })
63
+ ], SelectableBox.prototype, "controlType");
64
+ __decorateClass([
65
+ attr({ mode: "boolean" })
66
+ ], SelectableBox.prototype, "tight");
59
67
 
60
- const getClasses = ({ modal, open, trailing }) => classNames(
61
- "control",
62
- ["modal", modal],
63
- ["open", open],
64
- ["trailing", trailing]
68
+ const getClasses = ({
69
+ connotation,
70
+ tight,
71
+ checked,
72
+ clickableBox,
73
+ clickable
74
+ }) => classNames(
75
+ "base",
76
+ [`connotation-${connotation}`, Boolean(connotation)],
77
+ ["tight", tight],
78
+ ["selected", checked],
79
+ ["clickable", clickableBox || clickable],
80
+ ["readonly", !clickableBox && !clickable]
65
81
  );
66
- const getScrimClasses = ({ open }) => classNames("scrim", ["open", open]);
67
- const sideDrawerTemplate = () => html`
68
- <div
69
- class="${getClasses}"
70
- ?inert="${(x) => !x.open}"
71
- part="base ${(x) => x.alternate ? "vvd-theme-alternate" : ""}"
72
- @keydown="${(x, c) => handleKeydown(x, c.event)}"
73
- >
74
- <slot></slot>
75
- </div>
76
-
77
- <div class="side-drawer-app-content" ?inert="${(x) => x.open && x.modal}">
78
- <slot name="app-content"></slot>
79
- </div>
80
-
81
- ${when(
82
- (x) => x.modal,
83
- html`<div
84
- class="${getScrimClasses}"
85
- @click="${(x) => x.open = false}"
86
- ></div>`
87
- )}
88
- `;
89
- const handleKeydown = (x, { key }) => {
90
- if (key === "Escape") {
91
- x.open = false;
92
- } else {
93
- return true;
94
- }
82
+ function handleControlChange(x) {
83
+ if (!x.clickableBox) x._handleCheckedChange();
84
+ }
85
+ function checkbox(context) {
86
+ const checkboxTag = context.tagFor(Checkbox);
87
+ return html`${when(
88
+ (x) => x.controlType !== "radio",
89
+ html`
90
+ <${checkboxTag}
91
+ aria-label="${(x) => !x.clickableBox && !x.clickable && x.ariaLabel ? x.ariaLabel : null}"
92
+ @change="${(x) => handleControlChange(x)}"
93
+ class="control checkbox"
94
+ connotation="${(x) => x.connotation === "cta" ? Connotation.CTA : Connotation.Accent}"
95
+ :checked="${(x) => x.checked}"
96
+ inert="${(x) => x.clickableBox || x.clickable ? true : null}"
97
+ ></${checkboxTag}>`
98
+ )} `;
99
+ }
100
+ function radio(context) {
101
+ const radioTag = context.tagFor(Radio);
102
+ return html`${when(
103
+ (x) => x.controlType === "radio",
104
+ html`
105
+ <${radioTag}
106
+ aria-label="${(x) => !x.clickableBox && !x.clickable && x.ariaLabel ? x.ariaLabel : null}"
107
+ @change="${(x) => handleControlChange(x)}"
108
+ class="control radio"
109
+ connotation="${(x) => x.connotation === "cta" ? Connotation.CTA : Connotation.Accent}"
110
+ :checked="${(x) => x.checked}"
111
+ inert="${(x) => x.clickableBox || x.clickable ? true : null}"
112
+ ></${radioTag}>`
113
+ )} `;
114
+ }
115
+ const SelectableBoxTemplate = (context) => {
116
+ return html`<template role="presentation">
117
+ <div
118
+ class="${getClasses}"
119
+ tabindex="${(x) => x.clickableBox || x.clickable ? "0" : null}"
120
+ role="${(x) => x.clickableBox || x.clickable ? "button" : null}"
121
+ aria-pressed="${(x) => x.clickableBox || x.clickable ? x.checked ? "true" : "false" : null}"
122
+ aria-label="${(x) => x.clickableBox || x.clickable ? x.ariaLabel : null}"
123
+ @keydown="${(x, c) => x._handleKeydown(c.event)}"
124
+ @click="${(x) => x.clickableBox || x.clickable ? x._handleCheckedChange() : null}"
125
+ >
126
+ ${checkbox(context)} ${radio(context)}
127
+ <slot></slot>
128
+ </div>
129
+ </template>`;
95
130
  };
96
131
 
97
- const sideDrawerDefinition = SideDrawer.compose({
98
- baseName: "side-drawer",
99
- template: sideDrawerTemplate,
100
- styles
132
+ const selectableBoxDefinition = SelectableBox.compose({
133
+ baseName: "selectable-box",
134
+ template: SelectableBoxTemplate,
135
+ styles,
136
+ shadowOptions: {
137
+ delegatesFocus: true
138
+ }
101
139
  });
102
- const sideDrawerRegistries = [sideDrawerDefinition()];
103
- const registerSideDrawer = registerFactory(sideDrawerRegistries);
140
+ const selectableBoxRegistries = [
141
+ selectableBoxDefinition(),
142
+ ...checkboxRegistries,
143
+ ...radioRegistries
144
+ ];
145
+ const registerSelectableBox = registerFactory(selectableBoxRegistries);
104
146
 
105
- export { sideDrawerRegistries as a, registerSideDrawer as r, sideDrawerDefinition as s };
147
+ export { selectableBoxRegistries as a, registerSelectableBox as r, selectableBoxDefinition as s };