@lmvz-ds/components 0.22.1 → 0.24.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 (113) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/cjs/{aria-loader-Cec1zR2g.js → aria-loader-BRo2FTGh.js} +1 -0
  3. package/cjs/index.cjs.js +1 -1
  4. package/cjs/lmvz-button_3.cjs.entry.js +375 -0
  5. package/cjs/lmvz-card.cjs.entry.js +2 -2
  6. package/cjs/lmvz-checkbox.cjs.entry.js +4 -4
  7. package/cjs/lmvz-chip.cjs.entry.js +3 -3
  8. package/cjs/lmvz-components.cjs.js +1 -1
  9. package/cjs/lmvz-header_2.cjs.entry.js +3 -3
  10. package/cjs/lmvz-input.cjs.entry.js +5 -5
  11. package/cjs/lmvz-menuitem.cjs.entry.js +4 -4
  12. package/cjs/lmvz-modal.cjs.entry.js +6 -109
  13. package/cjs/lmvz-select.cjs.entry.js +4 -4
  14. package/cjs/lmvz-toggle.cjs.entry.js +4 -4
  15. package/cjs/loader.cjs.js +1 -1
  16. package/cjs/{reactive-controller-host-DnSTWHCF.js → reactive-controller-host-BOFg4vL-.js} +1 -1
  17. package/collection/collection-manifest.json +1 -0
  18. package/collection/components/lmvz-button/lmvz-button.css +60 -41
  19. package/collection/components/lmvz-button/lmvz-button.js +6 -7
  20. package/collection/components/lmvz-button-group/lmvz-button-group.css +14 -0
  21. package/collection/components/lmvz-button-group/lmvz-button-group.js +216 -0
  22. package/collection/components/lmvz-card/lmvz-card.css +59 -40
  23. package/collection/components/lmvz-card/lmvz-card.js +1 -1
  24. package/collection/components/lmvz-checkbox/lmvz-checkbox.css +12 -8
  25. package/collection/components/lmvz-checkbox/lmvz-checkbox.js +1 -1
  26. package/collection/components/lmvz-chip/lmvz-chip.js +1 -1
  27. package/collection/components/lmvz-header/lmvz-header.js +1 -1
  28. package/collection/components/lmvz-icon/lmvz-icon.js +1 -1
  29. package/collection/components/lmvz-input/lmvz-input.css +12 -8
  30. package/collection/components/lmvz-input/lmvz-input.js +2 -2
  31. package/collection/components/lmvz-menuitem/lmvz-menuitem.css +12 -8
  32. package/collection/components/lmvz-menuitem/lmvz-menuitem.js +1 -1
  33. package/collection/components/lmvz-modal/lmvz-modal.css +36 -38
  34. package/collection/components/lmvz-modal/lmvz-modal.js +4 -108
  35. package/collection/components/lmvz-select/lmvz-select.css +12 -8
  36. package/collection/components/lmvz-select/lmvz-select.js +1 -1
  37. package/collection/components/lmvz-toggle/lmvz-toggle.css +12 -8
  38. package/collection/components/lmvz-toggle/lmvz-toggle.js +1 -1
  39. package/collection/integration/header-integration/header-integration.js +1 -1
  40. package/components/index.d.ts +2 -0
  41. package/components/index.d.ts.bak +2 -0
  42. package/components/index.js +1 -1
  43. package/components/lmvz-button-group.d.ts +11 -0
  44. package/components/lmvz-button-group.d.ts.bak +11 -0
  45. package/components/lmvz-button-group.js +1 -0
  46. package/components/lmvz-button.js +1 -1
  47. package/components/lmvz-card.js +1 -1
  48. package/components/lmvz-checkbox.js +1 -1
  49. package/components/lmvz-chip.js +1 -1
  50. package/components/lmvz-header.js +1 -1
  51. package/components/lmvz-icon.js +1 -1
  52. package/components/lmvz-input.js +1 -1
  53. package/components/lmvz-menuitem.js +1 -1
  54. package/components/lmvz-modal.js +1 -1
  55. package/components/lmvz-select.js +1 -1
  56. package/components/lmvz-toggle.js +1 -1
  57. package/components/p-CcnyKhAw.js +1 -0
  58. package/components/p-CdDO7mQa.js +1 -0
  59. package/components/p-Cg2XX_J-.js +1 -0
  60. package/components/p-DSvYtVoD.js +1 -0
  61. package/components/p-slgmfnHm.js +1 -0
  62. package/esm/{aria-loader-BVolm0lC.js → aria-loader-GfsGHZHY.js} +1 -1
  63. package/esm/index.js +1 -1
  64. package/esm/lmvz-button_3.entry.js +371 -0
  65. package/esm/lmvz-card.entry.js +2 -2
  66. package/esm/lmvz-checkbox.entry.js +4 -4
  67. package/esm/lmvz-chip.entry.js +3 -3
  68. package/esm/lmvz-components.js +1 -1
  69. package/esm/lmvz-header_2.entry.js +3 -3
  70. package/esm/lmvz-input.entry.js +5 -5
  71. package/esm/lmvz-menuitem.entry.js +4 -4
  72. package/esm/lmvz-modal.entry.js +6 -109
  73. package/esm/lmvz-select.entry.js +4 -4
  74. package/esm/lmvz-toggle.entry.js +4 -4
  75. package/esm/loader.js +1 -1
  76. package/esm/{reactive-controller-host-lF2kXM1x.js → reactive-controller-host-CroMsXdS.js} +1 -1
  77. package/hydrate/index.js +273 -189
  78. package/hydrate/index.mjs +273 -189
  79. package/lmvz-components/index.esm.js +1 -1
  80. package/lmvz-components/lmvz-components.esm.js +1 -1
  81. package/lmvz-components/p-2824a56b.entry.js +1 -0
  82. package/lmvz-components/p-4263c9b2.entry.js +1 -0
  83. package/lmvz-components/p-4f5c3c4a.entry.js +1 -0
  84. package/lmvz-components/p-6f8cbc4f.entry.js +1 -0
  85. package/lmvz-components/p-88adb9fa.entry.js +1 -0
  86. package/lmvz-components/{p-DCTzMRMQ.js → p-BRl6zKXT.js} +1 -1
  87. package/lmvz-components/p-CdDO7mQa.js +1 -0
  88. package/lmvz-components/p-a7c3074a.entry.js +1 -0
  89. package/lmvz-components/p-b3b04d46.entry.js +1 -0
  90. package/lmvz-components/p-d1dacf7e.entry.js +1 -0
  91. package/lmvz-components/{p-d984e118.entry.js → p-f6d1d9df.entry.js} +1 -1
  92. package/lmvz-components/p-fefefc54.entry.js +1 -0
  93. package/manifest.json +111 -12
  94. package/package.json +5 -1
  95. package/types/components/lmvz-button/lmvz-button.d.ts +1 -1
  96. package/types/components/lmvz-button-group/lmvz-button-group.d.ts +20 -0
  97. package/types/components/lmvz-modal/lmvz-modal.d.ts +1 -16
  98. package/types/components.d.ts +27 -3
  99. package/cjs/lmvz-button_2.cjs.entry.js +0 -198
  100. package/components/p-Boj0PCdB.js +0 -1
  101. package/components/p-Cc6dOWwS.js +0 -1
  102. package/components/p-DBc1BzQb.js +0 -1
  103. package/esm/lmvz-button_2.entry.js +0 -195
  104. package/lmvz-components/p-08a08b63.entry.js +0 -1
  105. package/lmvz-components/p-1b181e90.entry.js +0 -1
  106. package/lmvz-components/p-23fb2476.entry.js +0 -1
  107. package/lmvz-components/p-6bb145e4.entry.js +0 -1
  108. package/lmvz-components/p-7a310b1e.entry.js +0 -1
  109. package/lmvz-components/p-b7940687.entry.js +0 -1
  110. package/lmvz-components/p-db8306a5.entry.js +0 -1
  111. package/lmvz-components/p-dhVSUYqd.js +0 -1
  112. package/lmvz-components/p-ea335543.entry.js +0 -1
  113. package/lmvz-components/p-f8ea0eb2.entry.js +0 -1
@@ -5,31 +5,35 @@
5
5
  * Important: Always import this file _before_ layering your own styles!
6
6
  */
7
7
  @layer lmvz-ds.theme {
8
+ /**
9
+ * !CAUTION: Changes to this file have to be manually synced into `/packages/styles/src/no-transform/router-font.css`
10
+ */
11
+
8
12
  @font-face {
9
13
  font-family: Router;
10
14
  src:
15
+ local('RouterBook-Regular'),
11
16
  local('Router-Book'),
12
- url('/assets/fonts/Router-Book.woff') format('woff'),
13
- local('Router');
14
- font-weight: 400 normal;
17
+ url('/assets/fonts/Router-Book.woff') format('woff');
18
+ font-weight: 400;
15
19
  }
16
20
 
17
21
  @font-face {
18
22
  font-family: Router;
19
23
  src:
24
+ local('RouterMedium-Regular'),
20
25
  local('Router-Medium'),
21
- url('/assets/fonts/Router-Medium.woff') format('woff'),
22
- local('Router');
26
+ url('/assets/fonts/Router-Medium.woff') format('woff');
23
27
  font-weight: 500;
24
28
  }
25
29
 
26
30
  @font-face {
27
31
  font-family: Router;
28
32
  src:
33
+ local('RouterBold-Regular'),
29
34
  local('Router-Bold'),
30
- url('/assets/fonts/Router-Bold.woff') format('woff'),
31
- local('Router');
32
- font-weight: 700 bold;
35
+ url('/assets/fonts/Router-Bold.woff') format('woff');
36
+ font-weight: 700;
33
37
  }
34
38
 
35
39
  }
@@ -47,21 +51,27 @@ h6 {
47
51
  margin: 0;
48
52
  }
49
53
 
54
+ *[hidden] {
55
+ display: none !important;
56
+ }
57
+
50
58
  }
51
59
  :host {
52
60
  /* * the (invalid nested) import will be handled by postcss */
53
61
  /* stylelint-disable-next-line no-invalid-position-at-import-rule */
54
62
  button {
55
- --lmvz-button-color: var(--lmvz-component-color, var(--lmvz-semantic-color-int-on-primary, #ffffff));
56
- --lmvz-button-padding-inline: var(--lmvz-button-padding, var(--lmvz-component-input-md-padding-x, clamp(0.75rem, 0.69rem + 0.26vw, 1rem)));
57
- --lmvz-button-padding-block: var(--lmvz-button-padding, var(--lmvz-component-input-md-padding-y, clamp(0.75rem, 0.69rem + 0.26vw, 1rem)));
58
- --lmvz-button-gap: var(--lmvz-component-input-md-gap-x, clamp(0.25rem, 0.16rem + 0.39vw, 0.63rem));
59
- --lmvz-button-font: var(--lmvz-typography-body-lg, 400 clamp(1rem, 0.97rem + 0.13vw, 1.13rem) / 1.4
63
+ /* secondary styling is default, primary is explicit */
64
+ --lmvz-button-color: var(--lmvz-component-color, var(--lmvz-semantic-color-int-on-secondary, #000000));
65
+ --lmvz-button-padding-inline: var(--lmvz-button-padding, var(--lmvz-component-input-padding-md, clamp(0.88rem, 0.84rem + 0.13vw, 1rem)));
66
+ --lmvz-button-padding-block: var(--lmvz-button-padding, var(--lmvz-component-input-padding-md, clamp(0.88rem, 0.84rem + 0.13vw, 1rem)));
67
+ --lmvz-button-gap: var(--lmvz-component-input-gap-md, clamp(0.5rem, 0.44rem + 0.26vw, 0.75rem));
68
+ --lmvz-button-min-height: var(--lmvz-component-input-size-md, clamp(2.5rem, 2.44rem + 0.26vw, 2.75rem));
69
+ --lmvz-button-font: var(--lmvz-typography-body-md-strong, 500 clamp(0.88rem, 0.84rem + 0.13vw, 1rem) / 1.4
60
70
  Router);
61
71
  --lmvz-button-radius: var(--lmvz-component-input-radius-default, 999px);
62
72
  --lmvz-button-border-width: 0;
63
73
  --lmvz-button-border-color: transparent;
64
- --lmvz-button-background: var(--lmvz-semantic-color-int-primary, #000000);
74
+ --lmvz-button-background: var(--lmvz-semantic-color-int-secondary, #f0f0f0);
65
75
 
66
76
  display: inline-flex;
67
77
  align-items: center;
@@ -69,6 +79,7 @@ h6 {
69
79
  gap: var(--lmvz-button-gap);
70
80
  padding-block: var(--lmvz-button-padding-block);
71
81
  padding-inline: var(--lmvz-button-padding-inline);
82
+ min-height: var(--lmvz-button-min-height);
72
83
  border-radius: var(--lmvz-button-radius);
73
84
  border: var(--lmvz-button-border-width) solid var(--lmvz-button-border-color);
74
85
  background-color: var(--lmvz-button-background);
@@ -91,8 +102,8 @@ button > * {
91
102
  }
92
103
 
93
104
  button:focus-visible {
94
- outline: var(--lmvz-semantic-border-width-default, 1px) solid var(--lmvz-semantic-color-status-on-active, #0e7ab4);
95
- outline-offset: var(--lmvz-component-input-sm-padding-x, clamp(0.5rem, 0.44rem + 0.26vw, 0.75rem));
105
+ outline: 2px solid var(--lmvz-semantic-color-border-active, #0f8acc);
106
+ outline-offset: 2px;
96
107
  }
97
108
 
98
109
  button:is([disabled], .disabled) {
@@ -108,36 +119,45 @@ button:is([disabled], .disabled) {
108
119
  }
109
120
 
110
121
  button:not([disabled]):hover {
111
- --lmvz-button-background: var(--lmvz-semantic-color-int-primary-hover, #2e2e2e);
122
+ --lmvz-button-background: var(--lmvz-semantic-color-int-secondary-hover, #e0e0e0);
112
123
  }
113
124
 
114
125
  button:not([disabled]):active {
126
+ --lmvz-button-background: var(--lmvz-semantic-color-int-secondary-active, #d4d4d4);
127
+ }
128
+
129
+ button.primary {
130
+ --lmvz-button-background: var(--lmvz-semantic-color-int-primary, #000000);
131
+ --lmvz-button-color: var(--lmvz-semantic-color-int-on-primary, #ffffff);
132
+ --lmvz-button-border-width: 0;
133
+ --lmvz-button-border-color: transparent;
134
+ }
135
+
136
+ button.primary:not([disabled], .disabled):hover {
137
+ --lmvz-button-background: var(--lmvz-semantic-color-int-primary-hover, #2e2e2e);
138
+ }
139
+
140
+ button.primary:not([disabled], .disabled):active {
115
141
  --lmvz-button-background: var(--lmvz-semantic-color-int-primary-active, #545454);
116
142
  }
117
143
 
118
144
  button.secondary {
119
145
  --lmvz-button-background: var(--lmvz-semantic-color-int-secondary, #f0f0f0);
120
146
  --lmvz-button-color: var(--lmvz-semantic-color-int-on-secondary, #000000);
121
- --lmvz-button-border-width: var(--lmvz-semantic-border-width-default, 1px);
122
- --lmvz-button-border-color: var(--lmvz-semantic-color-border-default, #e0e0e0);
147
+ --lmvz-button-border-width: 0;
148
+ --lmvz-button-border-color: transparent;
123
149
  }
124
150
 
125
151
  button.secondary:not([disabled], .disabled):hover {
126
152
  --lmvz-button-background: var(--lmvz-semantic-color-int-secondary-hover, #e0e0e0);
127
- --lmvz-button-border-color: var(--lmvz-semantic-color-border-hover, #c7c7c7);
153
+ --lmvz-button-color: var(--lmvz-semantic-color-int-on-secondary-hover, #000000);
128
154
  }
129
155
 
130
156
  button.secondary:not([disabled], .disabled):active {
131
157
  --lmvz-button-background: var(--lmvz-semantic-color-int-secondary-active, #d4d4d4);
132
- --lmvz-button-border-color: var(--lmvz-semantic-color-border-active, #0f8acc);
158
+ --lmvz-button-color: var(--lmvz-semantic-color-int-on-secondary-active, #000000);
133
159
  }
134
160
 
135
- /* button.secondary:is([disabled], .disabled) {
136
- --lmvz-button-background: var(--lmvz-global-color-neutral-200);
137
- --lmvz-button-border-color: var(--lmvz-global-color-neutral-400);
138
- --lmvz-button-color: var(--lmvz-global-color-neutral-700);
139
- } */
140
-
141
161
  button.tertiary {
142
162
  --lmvz-button-background: var(--lmvz-semantic-color-int-tertiary, #ffffff);
143
163
  --lmvz-button-color: var(--lmvz-semantic-color-int-on-tertiary, #545454);
@@ -145,35 +165,34 @@ button.tertiary {
145
165
 
146
166
  button.tertiary:not([disabled], .disabled):hover {
147
167
  --lmvz-button-background: var(--lmvz-semantic-color-int-tertiary-hover, #f0f0f0);
168
+ --lmvz-button-color: var(--lmvz-semantic-color-int-on-tertiary-hover, #000000);
148
169
  }
149
170
 
150
171
  button.tertiary:not([disabled], .disabled):active {
151
172
  --lmvz-button-background: var(--lmvz-semantic-color-int-tertiary-active, #e0e0e0);
173
+ --lmvz-button-color: var(--lmvz-semantic-color-int-on-tertiary-active, #000000);
152
174
  }
153
175
 
154
- /* button.tertiary:is([disabled], .disabled) {
155
- --lmvz-button-background: var(--lmvz-global-color-neutral-100);
156
- --lmvz-button-color: var(--lmvz-global-color-neutral-600);
157
- } */
158
-
159
176
  button.small {
160
- --lmvz-button-padding-inline: var(--lmvz-component-input-sm-padding-x, clamp(0.5rem, 0.44rem + 0.26vw, 0.75rem));
161
- --lmvz-button-padding-block: var(--lmvz-component-input-sm-padding-y, clamp(0.5rem, 0.44rem + 0.26vw, 0.75rem));
162
- --lmvz-button-gap: var(--lmvz-component-input-sm-gap-x, clamp(0.25rem, 0.16rem + 0.39vw, 0.63rem));
163
- --lmvz-button-font: var(--lmvz-typography-body-md, 400 clamp(0.88rem, 0.84rem + 0.13vw, 1rem) / 1.4
177
+ --lmvz-button-padding-inline: var(--lmvz-component-input-padding-sm, clamp(0.75rem, 0.72rem + 0.13vw, 0.88rem));
178
+ --lmvz-button-padding-block: var(--lmvz-component-input-padding-sm, clamp(0.75rem, 0.72rem + 0.13vw, 0.88rem));
179
+ --lmvz-button-gap: var(--lmvz-component-input-gap-sm, clamp(0.38rem, 0.34rem + 0.13vw, 0.5rem));
180
+ --lmvz-button-min-height: var(--lmvz-component-input-size-sm, clamp(2rem, 1.94rem + 0.26vw, 2.25rem));
181
+ --lmvz-button-font: var(--lmvz-typography-body-sm-strong, 500 clamp(0.75rem, 0.73rem + 0.06vw, 0.81rem) / 1.4
164
182
  Router);
165
183
  }
166
184
 
167
185
  button.large {
168
- --lmvz-button-padding-inline: var(--lmvz-component-input-lg-padding-x, clamp(0.88rem, 0.78rem + 0.39vw, 1.25rem));
169
- --lmvz-button-padding-block: var(--lmvz-component-input-lg-padding-y, clamp(0.88rem, 0.78rem + 0.39vw, 1.25rem));
170
- --lmvz-button-gap: var(--lmvz-component-input-lg-gap-x, clamp(0.25rem, 0.16rem + 0.39vw, 0.63rem));
171
- --lmvz-button-font: var(--lmvz-typography-body-lg, 400 clamp(1rem, 0.97rem + 0.13vw, 1.13rem) / 1.4
186
+ --lmvz-button-padding-inline: var(--lmvz-component-input-padding-lg, clamp(1rem, 0.94rem + 0.26vw, 1.25rem));
187
+ --lmvz-button-padding-block: var(--lmvz-component-input-padding-lg, clamp(1rem, 0.94rem + 0.26vw, 1.25rem));
188
+ --lmvz-button-gap: var(--lmvz-component-input-gap-lg, clamp(0.75rem, 0.72rem + 0.13vw, 0.88rem));
189
+ --lmvz-button-min-height: var(--lmvz-component-input-size-lg, clamp(2.75rem, 2.69rem + 0.26vw, 3rem));
190
+ --lmvz-button-font: var(--lmvz-typography-body-lg-strong, 500 clamp(1rem, 0.97rem + 0.13vw, 1.13rem) / 1.4
172
191
  Router);
173
192
  }
174
193
 
175
194
 
176
- display: contents;
195
+ display: inline-block;
177
196
  }
178
197
  ::slotted(*) {
179
198
  --lmvz-component-color: var(--lmvz-button-color);
@@ -15,7 +15,7 @@ export class LmvzButton extends ReactiveControllerHost {
15
15
  return 0;
16
16
  }
17
17
  scale = 'default';
18
- variant = 'secondary';
18
+ variant;
19
19
  disabled = false;
20
20
  type = 'button';
21
21
  form;
@@ -88,7 +88,7 @@ export class LmvzButton extends ReactiveControllerHost {
88
88
  };
89
89
  render() {
90
90
  this.renderHiddenButton();
91
- return (h(Host, { key: '6c44aa8a4b40927313461b5139e88066b855dca6', "aria-disabled": this.disabled ? 'true' : null }, h("button", { key: '3696f0ad46a03fe9573571b46a56772def87bf53', ref: (e) => (this.validationEl = e), disabled: this.disabled, type: this.type, class: classNames(this.variant, { [this.scale ?? '']: !!this.scale, disabled: this.disabled }), ...this.inheritedAttributes }, h("slot", { key: '3ecce9c6ae978b72b14a807d93248a4566a13f4b' }))));
91
+ return (h(Host, { key: '8196de85afc3878c6f38e582d7c031f5d19bcd36', "aria-disabled": this.disabled ? 'true' : null }, h("button", { key: '8d73f979fa227de22a03403a2a3938684911060a', ref: (e) => (this.validationEl = e), part: "button", disabled: this.disabled, type: this.type, class: classNames(this.variant ?? 'secondary', { [this.scale ?? '']: !!this.scale, disabled: this.disabled }), ...this.inheritedAttributes }, h("slot", { key: '18e91a2f94ba0d7e5cf13150191003e2f0b2a03a' }))));
92
92
  }
93
93
  static get is() { return "lmvz-button"; }
94
94
  static get encapsulation() { return "shadow"; }
@@ -160,7 +160,7 @@ export class LmvzButton extends ReactiveControllerHost {
160
160
  "mutable": false,
161
161
  "complexType": {
162
162
  "original": "Button.Variant",
163
- "resolved": "\"primary\" | \"secondary\" | \"tertiary\"",
163
+ "resolved": "\"primary\" | \"secondary\" | \"tertiary\" | undefined",
164
164
  "references": {
165
165
  "Button": {
166
166
  "location": "import",
@@ -171,19 +171,18 @@ export class LmvzButton extends ReactiveControllerHost {
171
171
  }
172
172
  },
173
173
  "required": false,
174
- "optional": false,
174
+ "optional": true,
175
175
  "docs": {
176
176
  "tags": [{
177
177
  "name": "default",
178
- "text": "'secondary', since the primary button should be marked as such in context"
178
+ "text": "'secondary'"
179
179
  }],
180
180
  "text": "Variant of the button"
181
181
  },
182
182
  "getter": false,
183
183
  "setter": false,
184
184
  "reflect": true,
185
- "attribute": "variant",
186
- "defaultValue": "'secondary'"
185
+ "attribute": "variant"
187
186
  },
188
187
  "disabled": {
189
188
  "type": "boolean",
@@ -0,0 +1,14 @@
1
+ :host {
2
+ display: flex;
3
+ justify-content: flex-end;
4
+ gap: var(--lmvz-component-input-gap-md, clamp(0.5rem, 0.44rem + 0.26vw, 0.75rem));
5
+ font: var(--lmvz-typography-body-md, 400 clamp(0.88rem, 0.84rem + 0.13vw, 1rem) / 1.4
6
+ Router);
7
+
8
+ /* TODO(LDHCID-135): Action wrapping threshold remains an assumption and currently follows intrinsic content width */
9
+ flex-wrap: wrap;
10
+ }
11
+
12
+ ::slotted([hidden]) {
13
+ display: none !important;
14
+ }
@@ -0,0 +1,216 @@
1
+ import { h, Host } from "@stencil/core";
2
+ import { negate } from "@lmvz-ds/lib-ts/stream/negate.js";
3
+ import { isAriaValidationEnabled } from "../..";
4
+ import { canReceiveFocus } from "../../utils/component";
5
+ export class LmvzButtonGroup {
6
+ actionsSlot;
7
+ validationMessageCache = [];
8
+ actionsStateObserver;
9
+ get primaryEnabledAction() {
10
+ return this.enabledButtons.find(isPrimaryAction) ?? this.enabledButtons[0];
11
+ }
12
+ get hasActions() {
13
+ return this.assignedButtons.some((element) => isVisible(element) && isActionButton(element) && !isDisabledButton(element));
14
+ }
15
+ componentDidLoad() {
16
+ this.handleActionsSlotChange();
17
+ }
18
+ disconnectedCallback() {
19
+ this.actionsStateObserver?.disconnect();
20
+ }
21
+ get assignedElements() {
22
+ return this.actionsSlot?.assignedElements({ flatten: true }) ?? [];
23
+ }
24
+ get assignedButtons() {
25
+ return this.assignedElements.filter(isActionButton);
26
+ }
27
+ get visibleButtons() {
28
+ return this.assignedButtons.filter(isVisible);
29
+ }
30
+ get enabledButtons() {
31
+ return this.visibleButtons.filter(negate(isDisabledButton));
32
+ }
33
+ getActionValidationResult() {
34
+ if (!this.visibleButtons.length) {
35
+ return [];
36
+ }
37
+ const primaryActions = this.visibleButtons.filter(isPrimaryAction);
38
+ const secondaryActions = this.visibleButtons.filter(isSecondaryAction);
39
+ const issues = [];
40
+ const order = this.visibleButtons.toReversed();
41
+ if (primaryActions.length !== 1)
42
+ issues.push('LmvzModal actions slot must contain exactly one primary action.');
43
+ if (secondaryActions.length > 1)
44
+ issues.push(`LmvzModal actions slot must contain at most one secondary action (received ${secondaryActions.length})`);
45
+ if (primaryActions.length) {
46
+ const primaryAction = primaryActions[0];
47
+ const secondaryAction = secondaryActions[0];
48
+ if (order.indexOf(primaryAction) !== 0)
49
+ issues.push('Primary action must be the last focusable element in the actions slot (i.e. rightmost button).');
50
+ if (secondaryAction && order.indexOf(secondaryAction) !== 1)
51
+ issues.push('Secondary action must be the second-to-last focusable element in the actions slot (i.e. left of primary button).');
52
+ }
53
+ else if (secondaryActions.length) {
54
+ const secondaryAction = secondaryActions[0];
55
+ if (order.indexOf(secondaryAction) !== 0)
56
+ issues.push('Secondary action must be the last focusable element in the actions slot when no primary action is present (i.e. rightmost button).');
57
+ }
58
+ return issues;
59
+ }
60
+ handleActionsSlotChange = () => {
61
+ this.observeActionState();
62
+ this.syncActionsState();
63
+ };
64
+ observeActionState() {
65
+ if (typeof MutationObserver === 'undefined')
66
+ return;
67
+ this.actionsStateObserver?.disconnect();
68
+ if (!this.assignedButtons.length)
69
+ return;
70
+ this.actionsStateObserver = new MutationObserver(() => {
71
+ this.syncActionsState();
72
+ });
73
+ this.assignedButtons.forEach((element) => {
74
+ this.actionsStateObserver?.observe(element, {
75
+ attributes: true,
76
+ attributeFilter: ['disabled', 'hidden', 'variant'],
77
+ });
78
+ });
79
+ }
80
+ syncActionsState() {
81
+ const assignedElements = this.assignedElements;
82
+ assignedElements.forEach((element) => {
83
+ const isAllowedAction = ['LMVZ-BUTTON', 'BUTTON'].includes(element.tagName.toUpperCase());
84
+ if (isAllowedAction)
85
+ return;
86
+ if (!element.hasAttribute('hidden')) {
87
+ element.setAttribute('hidden', '');
88
+ }
89
+ if (element.getAttribute('aria-hidden') !== 'true') {
90
+ element.setAttribute('aria-hidden', 'true');
91
+ }
92
+ });
93
+ this.checkActions();
94
+ const length = this.visibleButtons.length;
95
+ for (let i = 0; i < length; i++) {
96
+ const variant = i === length - 1 ? 'primary' : i === length - 2 ? 'secondary' : 'tertiary';
97
+ const element = this.visibleButtons.at(i);
98
+ if (!element)
99
+ continue;
100
+ if (isLmvzButton(element)) {
101
+ if (!element.getAttribute('variant'))
102
+ element.setAttribute('variant', variant);
103
+ }
104
+ else {
105
+ element.classList.add(variant);
106
+ }
107
+ }
108
+ this.focusPrimaryAction();
109
+ }
110
+ focusPrimaryAction() {
111
+ const focusTarget = this.primaryEnabledAction;
112
+ if (!focusTarget || typeof window === 'undefined')
113
+ return;
114
+ window.requestAnimationFrame(() => {
115
+ if (canReceiveFocus(focusTarget)) {
116
+ focusTarget.focus();
117
+ }
118
+ });
119
+ }
120
+ checkActions() {
121
+ if (!isAriaValidationEnabled())
122
+ return;
123
+ const issues = this.getActionValidationResult();
124
+ if (!issues.length) {
125
+ return;
126
+ }
127
+ issues.forEach((issue) => {
128
+ if (this.validationMessageCache.includes(issue))
129
+ return;
130
+ console.warn(issue);
131
+ this.validationMessageCache.push(issue);
132
+ });
133
+ }
134
+ render() {
135
+ return (h(Host, { key: '56b60821ecaa2301d13e78d621e873aa74cd170e' }, h("slot", { key: 'e6a1422950fa5b0026356b7788a607a690116186', ref: (element) => (this.actionsSlot = element), onSlotchange: this.handleActionsSlotChange })));
136
+ }
137
+ static get is() { return "lmvz-button-group"; }
138
+ static get encapsulation() { return "shadow"; }
139
+ static get originalStyleUrls() {
140
+ return {
141
+ "$": ["lmvz-button-group.css"]
142
+ };
143
+ }
144
+ static get styleUrls() {
145
+ return {
146
+ "$": ["lmvz-button-group.css"]
147
+ };
148
+ }
149
+ static get properties() {
150
+ return {
151
+ "primaryEnabledAction": {
152
+ "type": "unknown",
153
+ "mutable": false,
154
+ "complexType": {
155
+ "original": "HTMLButtonElement | undefined",
156
+ "resolved": "HTMLButtonElement | undefined",
157
+ "references": {
158
+ "HTMLButtonElement": {
159
+ "location": "global",
160
+ "id": "global::HTMLButtonElement"
161
+ }
162
+ }
163
+ },
164
+ "required": false,
165
+ "optional": false,
166
+ "docs": {
167
+ "tags": [],
168
+ "text": ""
169
+ },
170
+ "getter": true,
171
+ "setter": false
172
+ },
173
+ "hasActions": {
174
+ "type": "boolean",
175
+ "mutable": false,
176
+ "complexType": {
177
+ "original": "boolean",
178
+ "resolved": "boolean",
179
+ "references": {}
180
+ },
181
+ "required": false,
182
+ "optional": false,
183
+ "docs": {
184
+ "tags": [],
185
+ "text": ""
186
+ },
187
+ "getter": true,
188
+ "setter": false,
189
+ "reflect": false,
190
+ "attribute": "has-actions"
191
+ }
192
+ };
193
+ }
194
+ }
195
+ function isActionButton(element) {
196
+ return ['LMVZ-BUTTON', 'BUTTON'].includes(element.tagName.toUpperCase());
197
+ }
198
+ function isLmvzButton(element) {
199
+ return element?.tagName.toUpperCase() === 'LMVZ-BUTTON';
200
+ }
201
+ function isDisabledButton(element) {
202
+ return element.hasAttribute('disabled') || element.disabled === true;
203
+ }
204
+ function isVisible(element) {
205
+ return !element.hasAttribute('hidden');
206
+ }
207
+ function getActionVariant(element) {
208
+ const variant = element.getAttribute('variant') ?? element.variant;
209
+ return variant === 'primary' || variant === 'secondary' || variant === 'tertiary' ? variant : 'secondary';
210
+ }
211
+ function isPrimaryAction(element) {
212
+ return getActionVariant(element) === 'primary';
213
+ }
214
+ function isSecondaryAction(element) {
215
+ return getActionVariant(element) === 'secondary';
216
+ }