@vonage/vivid 3.40.0 → 3.41.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 (160) hide show
  1. package/accordion/index.js +2 -2
  2. package/accordion-item/index.js +2 -2
  3. package/alert/index.js +6 -5
  4. package/audio-player/index.js +33 -0
  5. package/avatar/index.js +2 -2
  6. package/badge/index.js +2 -2
  7. package/banner/index.js +8 -5
  8. package/breadcrumb/index.js +1 -1
  9. package/breadcrumb-item/index.js +3 -3
  10. package/button/index.js +4 -4
  11. package/calendar/index.js +1 -1
  12. package/calendar-event/index.js +1 -1
  13. package/card/index.js +4 -3
  14. package/checkbox/index.js +3 -3
  15. package/combobox/index.js +8 -8
  16. package/custom-elements.json +330 -38
  17. package/data-grid/index.js +2 -2
  18. package/date-picker/index.js +9 -9
  19. package/date-range-picker/index.js +8 -8
  20. package/dialog/index.js +6 -6
  21. package/divider/index.js +1 -1
  22. package/elevation/index.js +1 -1
  23. package/empty-state/index.js +2 -2
  24. package/fab/index.js +3 -3
  25. package/file-picker/index.js +5 -5
  26. package/focus/index.js +1 -1
  27. package/header/index.js +2 -2
  28. package/icon/index.js +1 -1
  29. package/index.js +57 -56
  30. package/layout/index.js +1 -1
  31. package/lib/alert/alert.d.ts +3 -1
  32. package/lib/alert/locale.d.ts +3 -0
  33. package/lib/audio-player/audio-player.d.ts +17 -0
  34. package/lib/audio-player/audio-player.template.d.ts +4 -0
  35. package/lib/audio-player/definition.d.ts +4 -0
  36. package/lib/audio-player/locale.d.ts +5 -0
  37. package/lib/banner/banner.d.ts +3 -1
  38. package/lib/banner/locale.d.ts +3 -0
  39. package/lib/card/card.d.ts +3 -0
  40. package/lib/card/card.template.d.ts +1 -1
  41. package/lib/card/definition.d.ts +1 -0
  42. package/lib/checkbox/checkbox.d.ts +1 -0
  43. package/lib/components.d.ts +1 -0
  44. package/lib/enums.d.ts +2 -1
  45. package/lib/selectable-box/selectable-box.d.ts +1 -2
  46. package/lib/split-button/locale.d.ts +3 -0
  47. package/lib/split-button/split-button.d.ts +3 -1
  48. package/listbox/index.js +4 -4
  49. package/locales/en-GB.js +14 -0
  50. package/locales/en-US.js +14 -0
  51. package/locales/ja-JP.js +14 -0
  52. package/locales/zh-CN.js +14 -0
  53. package/menu/index.js +8 -8
  54. package/menu-item/index.js +3 -3
  55. package/nav/index.js +1 -1
  56. package/nav-disclosure/index.js +3 -3
  57. package/nav-item/index.js +3 -3
  58. package/note/index.js +2 -2
  59. package/number-field/index.js +6 -6
  60. package/option/index.js +3 -3
  61. package/package.json +1 -1
  62. package/pagination/index.js +5 -5
  63. package/popup/index.js +6 -6
  64. package/progress/index.js +1 -1
  65. package/progress-ring/index.js +1 -1
  66. package/radio/index.js +2 -2
  67. package/radio-group/index.js +2 -2
  68. package/select/index.js +8 -8
  69. package/selectable-box/index.js +5 -5
  70. package/shared/definition.js +3 -3
  71. package/shared/definition10.js +90 -159
  72. package/shared/definition11.js +151 -29
  73. package/shared/definition12.js +37 -766
  74. package/shared/definition13.js +747 -106
  75. package/shared/definition14.js +121 -198
  76. package/shared/definition15.js +156 -664
  77. package/shared/definition16.js +576 -1137
  78. package/shared/definition17.js +1278 -143
  79. package/shared/definition18.js +64 -305
  80. package/shared/definition19.js +357 -218
  81. package/shared/definition2.js +1 -1
  82. package/shared/definition20.js +259 -67
  83. package/shared/definition21.js +66 -58
  84. package/shared/definition22.js +43 -84
  85. package/shared/definition23.js +76 -2353
  86. package/shared/definition24.js +2362 -45
  87. package/shared/definition25.js +63 -27
  88. package/shared/definition26.js +24 -51
  89. package/shared/definition27.js +36 -822
  90. package/shared/definition28.js +837 -49
  91. package/shared/definition29.js +52 -89
  92. package/shared/definition3.js +1 -1
  93. package/shared/definition30.js +88 -24
  94. package/shared/definition31.js +25 -12
  95. package/shared/definition32.js +12 -52
  96. package/shared/definition33.js +28 -502
  97. package/shared/definition34.js +442 -197
  98. package/shared/definition35.js +260 -186
  99. package/shared/definition36.js +186 -75
  100. package/shared/definition37.js +70 -54
  101. package/shared/definition38.js +65 -421
  102. package/shared/definition39.js +437 -38
  103. package/shared/definition4.js +43 -16
  104. package/shared/definition40.js +32 -680
  105. package/shared/definition41.js +654 -105
  106. package/shared/definition42.js +105 -77
  107. package/shared/definition43.js +74 -567
  108. package/shared/definition44.js +568 -102
  109. package/shared/definition45.js +110 -135
  110. package/shared/definition46.js +153 -17
  111. package/shared/definition47.js +16 -79
  112. package/shared/definition48.js +53 -475
  113. package/shared/definition49.js +493 -25
  114. package/shared/definition5.js +160 -44
  115. package/shared/definition50.js +22 -121
  116. package/shared/definition51.js +113 -271
  117. package/shared/definition52.js +249 -243
  118. package/shared/definition53.js +270 -109
  119. package/shared/definition54.js +84 -74
  120. package/shared/definition55.js +114 -69
  121. package/shared/definition56.js +81 -292
  122. package/shared/definition57.js +302 -13
  123. package/shared/definition58.js +11 -41
  124. package/shared/definition59.js +20 -154
  125. package/shared/definition6.js +43 -33
  126. package/shared/definition60.js +181 -0
  127. package/shared/definition7.js +39 -106
  128. package/shared/definition8.js +122 -38
  129. package/shared/definition9.js +56 -89
  130. package/shared/enums.js +1 -0
  131. package/shared/icon.js +2 -2
  132. package/shared/index2.js +1 -1
  133. package/shared/listbox.js +1 -1
  134. package/shared/localization/Locale.d.ts +8 -0
  135. package/shared/patterns/form-elements/form-elements.d.ts +6 -6
  136. package/shared/presentationDate.js +5 -5
  137. package/shared/text-field.js +1 -1
  138. package/side-drawer/index.js +1 -1
  139. package/slider/index.js +3 -3
  140. package/split-button/index.js +6 -3
  141. package/style.css +248 -208
  142. package/styles/core/all.css +1 -1
  143. package/styles/core/theme.css +1 -1
  144. package/styles/core/typography.css +1 -1
  145. package/styles/tokens/theme-dark.css +4 -4
  146. package/styles/tokens/theme-light.css +4 -4
  147. package/styles/tokens/vivid-2-compat.css +1 -1
  148. package/switch/index.js +3 -3
  149. package/tab/index.js +3 -3
  150. package/tab-panel/index.js +1 -1
  151. package/tabs/index.js +5 -5
  152. package/tag/index.js +3 -3
  153. package/tag-group/index.js +1 -1
  154. package/text-area/index.js +3 -3
  155. package/text-field/index.js +3 -3
  156. package/toggletip/index.js +7 -7
  157. package/tooltip/index.js +7 -7
  158. package/tree-item/index.js +3 -3
  159. package/tree-view/index.js +1 -1
  160. package/vivid.api.json +251 -0
@@ -1,104 +1,13 @@
1
- import { F as FoundationElement, _ as __decorate, a as attr, o as observable, h as html, r as registerFactory } from './index.js';
2
- import { a as iconRegistries } from './definition25.js';
3
- import { f as focusRegistries } from './definition57.js';
4
- import './affix.js';
5
- import { e as errorText, f as formElements, F as FormElementSuccessText, a as FormElementHelperText, g as getFeedbackTemplate } from './index2.js';
6
- import { C as CheckableFormAssociated } from './form-associated.js';
7
- import { a as keySpace$1 } from './key-codes.js';
8
- import { a as applyMixins } from './apply-mixins.js';
9
- import { f as focusTemplateFactory } from './focus2.js';
1
+ import { F as FoundationElement, a as attr, o as observable, h as html, r as registerFactory } from './index.js';
2
+ import { a as iconRegistries } from './definition26.js';
3
+ import { E as Elevation, e as elevationRegistries } from './definition59.js';
4
+ import { A as Appearance } from './enums.js';
10
5
  import { I as Icon } from './icon.js';
11
6
  import { w as when } from './when.js';
12
7
  import { s as slotted } from './slotted.js';
13
8
  import { c as classNames } from './class-names.js';
14
9
 
15
- class _Checkbox extends FoundationElement {
16
- }
17
- /**
18
- * A form-associated base class for the {@link @microsoft/fast-foundation#(Checkbox:class)} component.
19
- *
20
- * @internal
21
- */
22
- class FormAssociatedCheckbox extends CheckableFormAssociated(_Checkbox) {
23
- constructor() {
24
- super(...arguments);
25
- this.proxy = document.createElement("input");
26
- }
27
- }
28
-
29
- /**
30
- * A Checkbox Custom HTML Element.
31
- * Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#checkbox | ARIA checkbox }.
32
- *
33
- * @slot checked-indicator - The checked indicator
34
- * @slot indeterminate-indicator - The indeterminate indicator
35
- * @slot - The default slot for the label
36
- * @csspart control - The element representing the visual checkbox control
37
- * @csspart label - The label
38
- * @fires change - Emits a custom change event when the checked state changes
39
- *
40
- * @public
41
- */
42
- let Checkbox$1 = class Checkbox extends FormAssociatedCheckbox {
43
- constructor() {
44
- super();
45
- /**
46
- * The element's value to be included in form submission when checked.
47
- * Default to "on" to reach parity with input[type="checkbox"]
48
- *
49
- * @internal
50
- */
51
- this.initialValue = "on";
52
- /**
53
- * The indeterminate state of the control
54
- */
55
- this.indeterminate = false;
56
- /**
57
- * @internal
58
- */
59
- this.keypressHandler = (e) => {
60
- if (this.readOnly) {
61
- return;
62
- }
63
- switch (e.key) {
64
- case keySpace$1:
65
- if (this.indeterminate) {
66
- this.indeterminate = false;
67
- }
68
- this.checked = !this.checked;
69
- break;
70
- }
71
- };
72
- /**
73
- * @internal
74
- */
75
- this.clickHandler = (e) => {
76
- if (!this.disabled && !this.readOnly) {
77
- if (this.indeterminate) {
78
- this.indeterminate = false;
79
- }
80
- this.checked = !this.checked;
81
- }
82
- };
83
- this.proxy.setAttribute("type", "checkbox");
84
- }
85
- readOnlyChanged() {
86
- if (this.proxy instanceof HTMLInputElement) {
87
- this.proxy.readOnly = this.readOnly;
88
- }
89
- }
90
- };
91
- __decorate([
92
- attr({ attribute: "readonly", mode: "boolean" })
93
- ], Checkbox$1.prototype, "readOnly", void 0);
94
- __decorate([
95
- observable
96
- ], Checkbox$1.prototype, "defaultSlottedNodes", void 0);
97
- __decorate([
98
- observable
99
- ], Checkbox$1.prototype, "indeterminate", void 0);
100
-
101
- const styles = "/**\n * Do not edit directly\n * Generated on Wed, 01 Nov 2023 12:16:28 GMT\n */\n:host {\n display: inline-flex;\n flex-direction: column;\n vertical-align: middle;\n}\n\n:host([disabled]) {\n cursor: not-allowed;\n}\n\n.base {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n vertical-align: middle;\n}\n.base.connotation-cta {\n /* @cssprop [--vvd-checkbox-cta-primary=var(--vvd-color-cta-500)] */\n --_connotation-color-primary: var(--vvd-checkbox-cta-primary, var(--vvd-color-cta-500));\n /* @cssprop [--vvd-checkbox-cta-primary-text=var(--vvd-color-canvas)] */\n --_connotation-color-primary-text: var(--vvd-checkbox-cta-primary-text, var(--vvd-color-canvas));\n /* @cssprop [--vvd-checkbox-cta-primary-increment=var(--vvd-color-cta-600)] */\n --_connotation-color-primary-increment: var(--vvd-checkbox-cta-primary-increment, var(--vvd-color-cta-600));\n /* @cssprop [--vvd-checkbox-cta-intermediate=var(--vvd-color-cta-500)] */\n --_connotation-color-intermediate: var(--vvd-checkbox-cta-intermediate, var(--vvd-color-cta-500));\n /* @cssprop [--vvd-checkbox-cta-backdrop=var(--vvd-color-cta-50)] */\n --_connotation-color-backdrop: var(--vvd-checkbox-cta-backdrop, var(--vvd-color-cta-50));\n /* @cssprop [--vvd-checkbox-cta-firm=var(--vvd-color-cta-600)] */\n --_connotation-color-firm: var(--vvd-checkbox-cta-firm, var(--vvd-color-cta-600));\n}\n.base:not(.connotation-cta) {\n /* @cssprop [--vvd-checkbox-accent-primary=var(--vvd-color-canvas-text)] */\n --_connotation-color-primary: var(--vvd-checkbox-accent-primary, var(--vvd-color-canvas-text));\n /* @cssprop [--vvd-checkbox-accent-primary-text=var(--vvd-color-canvas)] */\n --_connotation-color-primary-text: var(--vvd-checkbox-accent-primary-text, var(--vvd-color-canvas));\n /* @cssprop [--vvd-checkbox-accent-primary-increment=var(--vvd-color-neutral-800)] */\n --_connotation-color-primary-increment: var(--vvd-checkbox-accent-primary-increment, var(--vvd-color-neutral-800));\n /* @cssprop [--vvd-checkbox-accent-intermediate=var(--vvd-color-neutral-500)] */\n --_connotation-color-intermediate: var(--vvd-checkbox-accent-intermediate, var(--vvd-color-neutral-500));\n /* @cssprop [--vvd-checkbox-accent-backdrop=var(--vvd-color-canvas)] */\n --_connotation-color-backdrop: var(--vvd-checkbox-accent-backdrop, var(--vvd-color-canvas));\n /* @cssprop [--vvd-checkbox-accent-firm=var(--vvd-color-canvas-text)] */\n --_connotation-color-firm: var(--vvd-checkbox-accent-firm, var(--vvd-color-canvas-text));\n}\n.base {\n --_appearance-color-text: var(--vvd-color-canvas-text);\n --_appearance-color-fill: var(--_connotation-color-backdrop);\n --_appearance-color-outline: var(--_connotation-color-intermediate);\n}\n.base:where(:hover, .hover):where(:not(:disabled, .disabled, .readonly)) {\n --_appearance-color-text: var(--vvd-color-canvas-text);\n --_appearance-color-fill: var(--_connotation-color-backdrop);\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-primary-text);\n --_appearance-color-fill: var(--_connotation-color-primary);\n --_appearance-color-outline: var(--_connotation-color-primary);\n}\n.base:where(:checked, .checked):where(:hover, .hover):where(:not(:disabled, .disabled, .readonly)) {\n --_appearance-color-text: var(--_connotation-color-primary-text);\n --_appearance-color-fill: var(--_connotation-color-primary-increment);\n --_appearance-color-outline: var(--_connotation-color-primary);\n}\n.base:where(:disabled, .disabled) {\n --_appearance-color-text: var(--vvd-color-neutral-300);\n --_appearance-color-fill: var(--vvd-color-neutral-100);\n --_appearance-color-outline: var(--vvd-color-neutral-300);\n}\n.base:where(.readonly):where(:not(:disabled, .disabled)) {\n --_appearance-color-text: var(--vvd-color-canvas-text);\n --_appearance-color-fill: var(--vvd-color-neutral-200);\n --_appearance-color-outline: var(--vvd-color-neutral-400);\n}\n@supports selector(:focus-visible) {\n .base:focus-visible {\n outline: none;\n }\n}\n@supports (user-select: none) {\n .base {\n user-select: none;\n }\n}\n.base:not(.disabled) {\n cursor: pointer;\n}\n.base.disabled {\n pointer-events: none;\n}\n\n.control {\n position: relative;\n display: flex;\n flex-shrink: 0;\n align-items: center;\n justify-content: center;\n background-color: var(--_appearance-color-fill);\n block-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 20));\n border-radius: 5px;\n box-shadow: inset 0 0 0 2px var(--_appearance-color-outline);\n color: var(--_appearance-color-text);\n inline-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 20));\n}\n\n.indicator {\n font-size: calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 20)) - 4px);\n}\n.base:not(.checked) .indicator.checkmark {\n display: none;\n}\n\n.base.checked .indicator.minus, .base:not(.indeterminate) .indicator.minus {\n display: none;\n}\n\nlabel {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n color: var(--vvd-color-canvas-text);\n column-gap: 4px;\n cursor: pointer;\n font: var(--vvd-typography-base);\n}\n.hide-label label {\n display: none;\n}\n\n.focus-indicator {\n --focus-inset: -3px;\n --focus-stroke-gap-color: transparent;\n border-radius: 6px;\n}\n.base:not(:focus-visible) .focus-indicator {\n display: none;\n}\n\n.icon {\n font-size: calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 20)) * 0.6);\n line-height: 1;\n}\n\n.message {\n margin-block-start: 4px;\n --_low-ink-color: var(--vvd-color-neutral-600);\n}";
10
+ const styles = "/**\n * Do not edit directly\n * Generated on Wed, 22 Nov 2023 16:09:43 GMT\n */\n:host {\n display: flex;\n}\n\n.base {\n border-radius: 6px;\n inline-size: 100%;\n text-align: start;\n}\n\n.wrapper {\n display: flex;\n overflow: hidden;\n flex-flow: column;\n block-size: 100%;\n border-radius: inherit;\n color: var(--vvd-color-canvas-text);\n}\n\n.main-content {\n display: flex;\n flex-flow: column;\n padding: 24px;\n}\n\n.header {\n display: flex;\n flex: 1;\n align-items: flex-start;\n gap: 8px;\n}\n.header-content {\n flex: 1;\n}\n.header-wrapper {\n display: flex;\n gap: 8px;\n}\n.header-headline, .header-subtitle {\n /* stylelint-disable value-no-vendor-prefix */\n display: -webkit-box;\n /* stylelint-enable value-no-vendor-prefix */\n overflow: hidden;\n -webkit-box-orient: vertical;\n}\n.header-headline {\n font: var(--vvd-typography-heading-4);\n -webkit-line-clamp: var(--headline-line-clamp);\n}\n.header-subtitle {\n font: var(--vvd-typography-base);\n -webkit-line-clamp: var(--subtitle-line-clamp);\n}\n.hide-header .header {\n display: none;\n}\n\n.header-subtitle,\n.text {\n color: var(--vvd-color-neutral-600);\n font: var(--vvd-typography-base);\n}\n\n.text {\n padding-right: 8px;\n margin-top: 12px;\n}\n\n.footer {\n display: inline-flex;\n flex-direction: column;\n align-items: flex-end;\n padding-bottom: 24px;\n margin-top: auto;\n padding-inline: 24px;\n}\n.hide-footer .footer {\n display: none;\n}\n\n::slotted([slot=graphic i]),\n.icon {\n flex-shrink: 0;\n align-self: baseline;\n margin-block-start: 4px;\n}\n\n.icon {\n font-size: 20px;\n}\n\n::slotted([slot=meta i]) {\n flex-shrink: 0;\n align-self: flex-start;\n margin-block-start: -8px;\n margin-inline-end: -8px;\n margin-inline-start: auto;\n}";
102
11
 
103
12
  var __defProp = Object.defineProperty;
104
13
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -111,120 +20,134 @@ var __decorateClass = (decorators, target, key, kind) => {
111
20
  __defProp(target, key, result);
112
21
  return result;
113
22
  };
114
- const keySpace = " ";
115
- let Checkbox = class extends Checkbox$1 {
116
- constructor() {
117
- super(...arguments);
118
- this.ariaLabel = null;
119
- /**
120
- * !remove method as will be implemented by fast-foundation in version after 2.46.9
121
- *
122
- * @internal
123
- */
124
- this.keypressHandler = (event) => {
125
- if (event.target instanceof HTMLAnchorElement) {
126
- return true;
127
- }
128
- switch (event.key) {
129
- case keySpace:
130
- if (this.indeterminate) {
131
- this.indeterminate = false;
132
- }
133
- this.checked = !this.checked;
134
- break;
135
- }
136
- return false;
137
- };
138
- /**
139
- * !remove method as will be implemented by fast-foundation in version after 2.46.9
140
- *
141
- * @internal
142
- */
143
- this.clickHandler = (event) => {
144
- if (event.target instanceof HTMLAnchorElement) {
145
- return true;
146
- }
147
- if (!this.disabled && !this.readOnly) {
148
- if (this.indeterminate) {
149
- this.indeterminate = false;
150
- }
151
- this.checked = !this.checked;
152
- }
153
- return false;
154
- };
155
- }
156
- };
23
+ class Card extends FoundationElement {
24
+ }
25
+ __decorateClass([
26
+ attr
27
+ ], Card.prototype, "appearance", 2);
28
+ __decorateClass([
29
+ attr
30
+ ], Card.prototype, "headline", 2);
31
+ __decorateClass([
32
+ attr
33
+ ], Card.prototype, "subtitle", 2);
34
+ __decorateClass([
35
+ attr
36
+ ], Card.prototype, "text", 2);
157
37
  __decorateClass([
158
- attr({ attribute: "aria-label" })
159
- ], Checkbox.prototype, "ariaLabel", 2);
38
+ attr
39
+ ], Card.prototype, "icon", 2);
160
40
  __decorateClass([
161
41
  attr
162
- ], Checkbox.prototype, "connotation", 2);
42
+ ], Card.prototype, "elevation", 2);
163
43
  __decorateClass([
164
44
  observable
165
- ], Checkbox.prototype, "slottedContent", 2);
166
- Checkbox = __decorateClass([
167
- errorText,
168
- formElements
169
- ], Checkbox);
170
- applyMixins(Checkbox, FormElementHelperText, FormElementSuccessText);
45
+ ], Card.prototype, "footerSlottedContent", 2);
46
+ __decorateClass([
47
+ observable
48
+ ], Card.prototype, "graphicSlottedContent", 2);
49
+ __decorateClass([
50
+ observable
51
+ ], Card.prototype, "hasMetaSlottedContent", 2);
171
52
 
172
- const getClasses = ({
173
- connotation,
174
- readOnly,
175
- checked,
176
- disabled,
177
- indeterminate,
178
- errorValidationMessage,
179
- successText,
180
- label,
181
- slottedContent
182
- }) => classNames(
53
+ const getClasses = (_) => classNames(
183
54
  "base",
184
- [`connotation-${connotation}`, Boolean(connotation)],
185
- ["readonly", Boolean(readOnly)],
186
- ["checked", Boolean(checked) || Boolean(indeterminate)],
187
- ["disabled", Boolean(disabled)],
188
- ["error connotation-alert", Boolean(errorValidationMessage)],
189
- ["success connotation-success", !!successText],
190
- ["hide-label", !label && !slottedContent?.length]
55
+ ["hide-footer", !_.footerSlottedContent || !_.footerSlottedContent.length],
56
+ ["hide-header", shouldHideHeader(_)]
191
57
  );
192
- const CheckboxTemplate = (context) => {
193
- const focusTemplate = focusTemplateFactory(context);
58
+ function renderHeaderIcon(iconTag) {
59
+ return html`
60
+ <${iconTag} class="icon" inline name="${(x) => x.icon}"></${iconTag}>`;
61
+ }
62
+ function Headline() {
63
+ return html`
64
+ <div class="header-headline">${(x) => x.headline}</div>
65
+ `;
66
+ }
67
+ function Subtitle() {
68
+ return html`
69
+ <div class="header-subtitle">${(x) => x.subtitle}</div>
70
+ `;
71
+ }
72
+ function headerContent() {
73
+ return html`
74
+ <div class="header-content">
75
+ ${when((x) => x.headline, Headline())}
76
+ ${when((x) => x.subtitle, Subtitle())}
77
+ </div>
78
+ `;
79
+ }
80
+ function renderHeader(iconTag) {
81
+ return html`
82
+ <header class="header">
83
+ <slot name="graphic" ${slotted("graphicSlottedContent")}>${when((x) => x.icon, renderHeaderIcon(iconTag))}</slot>
84
+ ${when((x) => x.headline || x.subtitle, headerContent())}
85
+ </header>`;
86
+ }
87
+ function shouldHideHeader(card) {
88
+ return !card.headline && !card.subtitle && !card.icon && (!card.graphicSlottedContent || !card.graphicSlottedContent.length);
89
+ }
90
+ function renderMetaSlot() {
91
+ return html`
92
+ <slot name="meta" ${slotted("metaSlottedContent")}></slot>
93
+ `;
94
+ }
95
+ function text() {
96
+ return html`
97
+ <div class="text">${(x) => x.text}</div>
98
+ `;
99
+ }
100
+ function renderCardContent(context) {
194
101
  const iconTag = context.tagFor(Icon);
195
- return html`<template role="${(x) => x.ariaLabel ? "presentation" : null}">
196
- <div class="${getClasses}"
197
- role="checkbox"
198
- aria-label="${(x) => x.ariaLabel}"
199
- aria-checked="${(x) => x.checked}"
200
- aria-required="${(x) => x.required}"
201
- aria-disabled="${(x) => x.disabled}"
202
- aria-readonly="${(x) => x.readOnly}"
203
- tabindex="${(x) => x.disabled ? null : 0}"
204
- @keypress="${(x, c) => x.keypressHandler(c.event)}"
205
- @click="${(x, c) => x.clickHandler(c.event)}">
206
- <div class="control">
207
- ${when((x) => x.checked, html`<${iconTag} name="check-solid" class="icon"></${iconTag}>`)}
208
- ${when((x) => x.indeterminate, html`<${iconTag} name="minus-solid" class="icon"></${iconTag}>`)}
209
- ${() => focusTemplate}
102
+ return html`
103
+ <div class="${getClasses}">
104
+ <div class="wrapper">
105
+ <div class="vwc-card-media">
106
+ <slot name="media"></slot>
107
+ </div>
108
+ <slot name="main">
109
+ <div class="main-content">
110
+ <div class="header-wrapper">
111
+ ${renderHeader(iconTag)}
112
+ ${renderMetaSlot()}
113
+ </div>
114
+ ${when((x) => x.text, text())}
115
+ </div>
116
+ </slot>
117
+ <div class="footer">
118
+ <slot name="footer" ${slotted("footerSlottedContent")}></slot>
119
+ </div>
210
120
  </div>
211
- ${html`<label>${(x) => x.label}<slot ${slotted("slottedContent")}></slot></label>`}
212
121
  </div>
213
- ${when((x) => x.helperText?.length, getFeedbackTemplate("helper", context))}
214
- ${when((x) => !x.successText && x.errorValidationMessage, getFeedbackTemplate("error", context))}
215
- ${when((x) => x.successText, getFeedbackTemplate("success", context))}
216
- </template>`;
122
+ `;
123
+ }
124
+ const CardTemplate = (context) => {
125
+ const elevationTag = context.tagFor(Elevation);
126
+ return html`
127
+ ${when((x) => x.appearance !== Appearance.Ghost && x.appearance !== Appearance.Outlined, html`
128
+ <${elevationTag} dp=${(x) => x.elevation ?? "4"}>
129
+ ${renderCardContent(context)}
130
+ </${elevationTag}>
131
+ `)}
132
+
133
+ ${when((x) => x.appearance === Appearance.Outlined, html`
134
+ <${elevationTag} dp='0')}>
135
+ ${renderCardContent(context)}
136
+ </${elevationTag}>
137
+ `)}
138
+
139
+ ${when((x) => x.appearance === Appearance.Ghost, html`
140
+ ${renderCardContent(context)}
141
+ `)}
142
+ `;
217
143
  };
218
144
 
219
- const checkboxDefinition = Checkbox.compose({
220
- baseName: "checkbox",
221
- template: CheckboxTemplate,
222
- styles,
223
- shadowOptions: {
224
- delegatesFocus: true
225
- }
145
+ const cardDefinition = Card.compose({
146
+ baseName: "card",
147
+ template: CardTemplate,
148
+ styles
226
149
  });
227
- const checkboxRegistries = [checkboxDefinition(), ...iconRegistries, ...focusRegistries];
228
- const registerCheckbox = registerFactory(checkboxRegistries);
150
+ const cardRegistries = [cardDefinition(), ...iconRegistries, ...elevationRegistries];
151
+ const registerCard = registerFactory(cardRegistries);
229
152
 
230
- export { Checkbox as C, checkboxRegistries as a, checkboxDefinition as c, registerCheckbox as r };
153
+ export { cardRegistries as a, cardDefinition as c, registerCard as r };