@momentum-design/components 0.133.26 → 0.133.28

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.
@@ -125,8 +125,13 @@ declare class ListItem extends ListItem_base {
125
125
  * @default undefined
126
126
  */
127
127
  active?: boolean;
128
+ private wasSpacePressed;
128
129
  constructor();
129
130
  connectedCallback(): void;
131
+ /**
132
+ * Handles the blur event on the list item. It resets the `wasSpacePressed` flag to false.
133
+ */
134
+ private handleBlur;
130
135
  /**
131
136
  * Handles the click event on the list item.
132
137
  * Prevents click when listitem is disabled
@@ -85,14 +85,22 @@ class ListItem extends KeyDownHandledMixin(KeyToActionMixin(DisabledMixin(TabInd
85
85
  * @default 'full-width'
86
86
  */
87
87
  this.variant = DEFAULTS.VARIANT;
88
+ this.wasSpacePressed = false;
88
89
  this.addEventListener('keydown', this.handleKeyDown.bind(this));
89
90
  this.addEventListener('keyup', this.handleKeyUp.bind(this));
90
91
  this.addEventListener('click', this.handleClick.bind(this));
92
+ this.addEventListener('blur', this.handleBlur.bind(this));
91
93
  }
92
94
  connectedCallback() {
93
95
  super.connectedCallback();
94
96
  this.role = this.role || ROLE.LISTITEM;
95
97
  }
98
+ /**
99
+ * Handles the blur event on the list item. It resets the `wasSpacePressed` flag to false.
100
+ */
101
+ handleBlur() {
102
+ this.wasSpacePressed = false;
103
+ }
96
104
  /**
97
105
  * Handles the click event on the list item.
98
106
  * Prevents click when listitem is disabled
@@ -113,21 +121,26 @@ class ListItem extends KeyDownHandledMixin(KeyToActionMixin(DisabledMixin(TabInd
113
121
  */
114
122
  handleKeyDown(event) {
115
123
  const action = this.getActionForKeyEvent(event);
124
+ if (this.isEventFromInsideListItem(event)) {
125
+ return;
126
+ }
116
127
  if (!event.defaultPrevented && action === ACTIONS.ENTER) {
117
- if (!this.isEventFromInsideListItem(event)) {
118
- this.keyDownEventHandled();
119
- event.preventDefault();
120
- this.triggerClickEvent(event);
121
- }
128
+ this.keyDownEventHandled();
129
+ event.preventDefault();
130
+ this.triggerClickEvent(event);
131
+ }
132
+ else if (action === ACTIONS.SPACE) {
133
+ this.wasSpacePressed = true;
122
134
  }
123
135
  }
124
136
  handleKeyUp(event) {
125
137
  const action = this.getActionForKeyEvent(event);
126
- if (!event.defaultPrevented && action === ACTIONS.SPACE) {
127
- if (!this.isEventFromInsideListItem(event)) {
138
+ if (action === ACTIONS.SPACE) {
139
+ if (!this.isEventFromInsideListItem(event) && !event.defaultPrevented && this.wasSpacePressed) {
128
140
  event.preventDefault();
129
141
  this.triggerClickEvent(event);
130
142
  }
143
+ this.wasSpacePressed = false;
131
144
  }
132
145
  }
133
146
  /**
@@ -1,6 +1,6 @@
1
1
  import { CSSResult, PropertyValues } from 'lit';
2
2
  import Buttonsimple from '../buttonsimple/buttonsimple.component';
3
- import type { Variant } from './tab.types';
3
+ import type { TabSize, Variant } from './tab.types';
4
4
  declare const Tab_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/IconNameMixin").IconNameMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/lifecycle/LifeCycleMixin").LifeCycleMixinInterface> & typeof Buttonsimple;
5
5
  /**
6
6
  * `mdc-tab` is Tab component to be used within the Tabgroup.
@@ -89,6 +89,13 @@ declare class Tab extends Tab_base {
89
89
  * @default pill
90
90
  */
91
91
  variant: Variant;
92
+ /**
93
+ * Size of the tab in pixels.
94
+ * - `32`: Default size (2rem)
95
+ * - `28`: Compact size (1.75rem)
96
+ * @default 32
97
+ */
98
+ size: TabSize;
92
99
  /**
93
100
  * Id of the tab (used as a identificator when used in the tablist)
94
101
  * Note: has to be unique!
@@ -105,6 +112,14 @@ declare class Tab extends Tab_base {
105
112
  * @param variant - The variant to set.
106
113
  */
107
114
  private setVariant;
115
+ /**
116
+ * Sets the size attribute for the tab component.
117
+ * If the provided size is not included in TAB_SIZES,
118
+ * it defaults to the value specified in DEFAULTS.SIZE.
119
+ *
120
+ * @param size - The size to set.
121
+ */
122
+ private setSize;
108
123
  /**
109
124
  * Dispatch the activechange event.
110
125
  *
@@ -16,7 +16,7 @@ import { TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
16
16
  import { IconNameMixin } from '../../utils/mixins/IconNameMixin';
17
17
  import { ROLE } from '../../utils/roles';
18
18
  import { LifeCycleMixin } from '../../utils/mixins/lifecycle/LifeCycleMixin';
19
- import { DEFAULTS, TAB_VARIANTS } from './tab.constants';
19
+ import { DEFAULTS, TAB_SIZES, TAB_VARIANTS } from './tab.constants';
20
20
  import styles from './tab.styles';
21
21
  /**
22
22
  * `mdc-tab` is Tab component to be used within the Tabgroup.
@@ -101,6 +101,13 @@ class Tab extends IconNameMixin(LifeCycleMixin(Buttonsimple)) {
101
101
  * @default pill
102
102
  */
103
103
  this.variant = DEFAULTS.VARIANT;
104
+ /**
105
+ * Size of the tab in pixels.
106
+ * - `32`: Default size (2rem)
107
+ * - `28`: Compact size (1.75rem)
108
+ * @default 32
109
+ */
110
+ this.size = DEFAULTS.SIZE;
104
111
  /**
105
112
  * Dispatch the activechange event.
106
113
  *
@@ -118,7 +125,6 @@ class Tab extends IconNameMixin(LifeCycleMixin(Buttonsimple)) {
118
125
  connectedCallback() {
119
126
  super.connectedCallback();
120
127
  this.role = ROLE.TAB;
121
- this.size = undefined;
122
128
  this.type = undefined;
123
129
  this.ariaStateKey = 'aria-selected';
124
130
  if (!this.tabId && this.onerror) {
@@ -135,6 +141,16 @@ class Tab extends IconNameMixin(LifeCycleMixin(Buttonsimple)) {
135
141
  setVariant(variant) {
136
142
  this.setAttribute('variant', Object.values(TAB_VARIANTS).includes(variant) ? variant : DEFAULTS.VARIANT);
137
143
  }
144
+ /**
145
+ * Sets the size attribute for the tab component.
146
+ * If the provided size is not included in TAB_SIZES,
147
+ * it defaults to the value specified in DEFAULTS.SIZE.
148
+ *
149
+ * @param size - The size to set.
150
+ */
151
+ setSize(size) {
152
+ this.setAttribute('size', Object.values(TAB_SIZES).includes(size) ? `${size}` : DEFAULTS.SIZE.toString());
153
+ }
138
154
  getFilledIconName() {
139
155
  if (!this.iconName) {
140
156
  return undefined;
@@ -152,6 +168,9 @@ class Tab extends IconNameMixin(LifeCycleMixin(Buttonsimple)) {
152
168
  }
153
169
  update(changedProperties) {
154
170
  super.update(changedProperties);
171
+ if (changedProperties.has('size')) {
172
+ this.setSize(this.size);
173
+ }
155
174
  if (changedProperties.has('variant')) {
156
175
  this.setVariant(this.variant);
157
176
  }
@@ -209,6 +228,10 @@ __decorate([
209
228
  property({ type: String, reflect: true }),
210
229
  __metadata("design:type", String)
211
230
  ], Tab.prototype, "variant", void 0);
231
+ __decorate([
232
+ property({ type: Number, reflect: true }),
233
+ __metadata("design:type", Number)
234
+ ], Tab.prototype, "size", void 0);
212
235
  __decorate([
213
236
  property({ type: String, reflect: true, attribute: 'tab-id' }),
214
237
  __metadata("design:type", String)
@@ -4,8 +4,13 @@ declare const TAB_VARIANTS: {
4
4
  readonly LINE: "line";
5
5
  readonly PILL: "pill";
6
6
  };
7
+ declare const TAB_SIZES: {
8
+ readonly 32: 32;
9
+ readonly 28: 28;
10
+ };
7
11
  declare const DEFAULTS: {
8
12
  readonly VARIANT: "pill";
9
13
  readonly ACTIVE: false;
14
+ readonly SIZE: 32;
10
15
  };
11
- export { DEFAULTS, TAG_NAME, TAB_VARIANTS };
16
+ export { DEFAULTS, TAG_NAME, TAB_VARIANTS, TAB_SIZES };
@@ -5,8 +5,13 @@ const TAB_VARIANTS = {
5
5
  LINE: 'line',
6
6
  PILL: 'pill',
7
7
  };
8
+ const TAB_SIZES = {
9
+ 32: 32,
10
+ 28: 28,
11
+ };
8
12
  const DEFAULTS = {
9
13
  VARIANT: TAB_VARIANTS.PILL,
10
14
  ACTIVE: false,
15
+ SIZE: TAB_SIZES[32],
11
16
  };
12
- export { DEFAULTS, TAG_NAME, TAB_VARIANTS };
17
+ export { DEFAULTS, TAG_NAME, TAB_VARIANTS, TAB_SIZES };
@@ -35,6 +35,10 @@ const styles = [
35
35
  border-radius: var(--mdc-tab-border-radius);
36
36
  }
37
37
 
38
+ :host([size='28']) {
39
+ --mdc-tab-height: 1.75rem;
40
+ }
41
+
38
42
  :host::part(container) {
39
43
  display: flex;
40
44
  width: 100%;
@@ -1,11 +1,12 @@
1
1
  import { TypedCustomEvent, ValueOf } from '../../utils/types';
2
2
  import type Tab from './tab.component';
3
- import { TAB_VARIANTS } from './tab.constants';
3
+ import { TAB_SIZES, TAB_VARIANTS } from './tab.constants';
4
4
  type Variant = ValueOf<typeof TAB_VARIANTS>;
5
+ type TabSize = ValueOf<typeof TAB_SIZES>;
5
6
  interface Events {
6
7
  onActiveChangeEvent: TypedCustomEvent<Tab, {
7
8
  tabId: string;
8
9
  active: boolean;
9
10
  }>;
10
11
  }
11
- export type { Variant, Events };
12
+ export type { Variant, TabSize, Events };
@@ -23857,6 +23857,17 @@
23857
23857
  ],
23858
23858
  "description": "Generates a template for a text slot with the specified content."
23859
23859
  },
23860
+ {
23861
+ "kind": "method",
23862
+ "name": "handleBlur",
23863
+ "privacy": "private",
23864
+ "return": {
23865
+ "type": {
23866
+ "text": "void"
23867
+ }
23868
+ },
23869
+ "description": "Handles the blur event on the list item. It resets the `wasSpacePressed` flag to false."
23870
+ },
23860
23871
  {
23861
23872
  "kind": "method",
23862
23873
  "name": "handleClick",
@@ -24063,6 +24074,15 @@
24063
24074
  "default": "'full-width'",
24064
24075
  "attribute": "variant",
24065
24076
  "reflects": true
24077
+ },
24078
+ {
24079
+ "kind": "field",
24080
+ "name": "wasSpacePressed",
24081
+ "type": {
24082
+ "text": "boolean"
24083
+ },
24084
+ "privacy": "private",
24085
+ "default": "false"
24066
24086
  }
24067
24087
  ],
24068
24088
  "events": [
@@ -24917,6 +24937,21 @@
24917
24937
  "module": "components/listitem/listitem.component.js"
24918
24938
  }
24919
24939
  },
24940
+ {
24941
+ "kind": "method",
24942
+ "name": "handleBlur",
24943
+ "privacy": "private",
24944
+ "return": {
24945
+ "type": {
24946
+ "text": "void"
24947
+ }
24948
+ },
24949
+ "description": "Handles the blur event on the list item. It resets the `wasSpacePressed` flag to false.",
24950
+ "inheritedFrom": {
24951
+ "name": "ListItem",
24952
+ "module": "components/listitem/listitem.component.js"
24953
+ }
24954
+ },
24920
24955
  {
24921
24956
  "kind": "method",
24922
24957
  "name": "handleClick",
@@ -25201,6 +25236,19 @@
25201
25236
  "name": "ListItem",
25202
25237
  "module": "components/listitem/listitem.component.js"
25203
25238
  }
25239
+ },
25240
+ {
25241
+ "kind": "field",
25242
+ "name": "wasSpacePressed",
25243
+ "type": {
25244
+ "text": "boolean"
25245
+ },
25246
+ "privacy": "private",
25247
+ "default": "false",
25248
+ "inheritedFrom": {
25249
+ "name": "ListItem",
25250
+ "module": "components/listitem/listitem.component.js"
25251
+ }
25204
25252
  }
25205
25253
  ],
25206
25254
  "events": [
@@ -25991,6 +26039,21 @@
25991
26039
  "module": "components/listitem/listitem.component.js"
25992
26040
  }
25993
26041
  },
26042
+ {
26043
+ "kind": "method",
26044
+ "name": "handleBlur",
26045
+ "privacy": "private",
26046
+ "return": {
26047
+ "type": {
26048
+ "text": "void"
26049
+ }
26050
+ },
26051
+ "description": "Handles the blur event on the list item. It resets the `wasSpacePressed` flag to false.",
26052
+ "inheritedFrom": {
26053
+ "name": "ListItem",
26054
+ "module": "components/listitem/listitem.component.js"
26055
+ }
26056
+ },
25994
26057
  {
25995
26058
  "kind": "method",
25996
26059
  "name": "handleClick",
@@ -26322,6 +26385,19 @@
26322
26385
  "name": "ListItem",
26323
26386
  "module": "components/listitem/listitem.component.js"
26324
26387
  }
26388
+ },
26389
+ {
26390
+ "kind": "field",
26391
+ "name": "wasSpacePressed",
26392
+ "type": {
26393
+ "text": "boolean"
26394
+ },
26395
+ "privacy": "private",
26396
+ "default": "false",
26397
+ "inheritedFrom": {
26398
+ "name": "ListItem",
26399
+ "module": "components/listitem/listitem.component.js"
26400
+ }
26325
26401
  }
26326
26402
  ],
26327
26403
  "events": [
@@ -27075,6 +27151,21 @@
27075
27151
  "module": "components/listitem/listitem.component.js"
27076
27152
  }
27077
27153
  },
27154
+ {
27155
+ "kind": "method",
27156
+ "name": "handleBlur",
27157
+ "privacy": "private",
27158
+ "return": {
27159
+ "type": {
27160
+ "text": "void"
27161
+ }
27162
+ },
27163
+ "description": "Handles the blur event on the list item. It resets the `wasSpacePressed` flag to false.",
27164
+ "inheritedFrom": {
27165
+ "name": "ListItem",
27166
+ "module": "components/listitem/listitem.component.js"
27167
+ }
27168
+ },
27078
27169
  {
27079
27170
  "kind": "method",
27080
27171
  "name": "handleClick",
@@ -27417,6 +27508,19 @@
27417
27508
  "name": "ListItem",
27418
27509
  "module": "components/listitem/listitem.component.js"
27419
27510
  }
27511
+ },
27512
+ {
27513
+ "kind": "field",
27514
+ "name": "wasSpacePressed",
27515
+ "type": {
27516
+ "text": "boolean"
27517
+ },
27518
+ "privacy": "private",
27519
+ "default": "false",
27520
+ "inheritedFrom": {
27521
+ "name": "ListItem",
27522
+ "module": "components/listitem/listitem.component.js"
27523
+ }
27420
27524
  }
27421
27525
  ],
27422
27526
  "events": [
@@ -30026,6 +30130,21 @@
30026
30130
  "module": "components/listitem/listitem.component.js"
30027
30131
  }
30028
30132
  },
30133
+ {
30134
+ "kind": "method",
30135
+ "name": "handleBlur",
30136
+ "privacy": "private",
30137
+ "return": {
30138
+ "type": {
30139
+ "text": "void"
30140
+ }
30141
+ },
30142
+ "description": "Handles the blur event on the list item. It resets the `wasSpacePressed` flag to false.",
30143
+ "inheritedFrom": {
30144
+ "name": "ListItem",
30145
+ "module": "components/listitem/listitem.component.js"
30146
+ }
30147
+ },
30029
30148
  {
30030
30149
  "kind": "method",
30031
30150
  "name": "handleClick",
@@ -30479,6 +30598,19 @@
30479
30598
  "name": "ListItem",
30480
30599
  "module": "components/listitem/listitem.component.js"
30481
30600
  }
30601
+ },
30602
+ {
30603
+ "kind": "field",
30604
+ "name": "wasSpacePressed",
30605
+ "type": {
30606
+ "text": "boolean"
30607
+ },
30608
+ "privacy": "private",
30609
+ "default": "false",
30610
+ "inheritedFrom": {
30611
+ "name": "ListItem",
30612
+ "module": "components/listitem/listitem.component.js"
30613
+ }
30482
30614
  }
30483
30615
  ],
30484
30616
  "events": [
@@ -31394,6 +31526,21 @@
31394
31526
  "module": "components/listitem/listitem.component.js"
31395
31527
  }
31396
31528
  },
31529
+ {
31530
+ "kind": "method",
31531
+ "name": "handleBlur",
31532
+ "privacy": "private",
31533
+ "return": {
31534
+ "type": {
31535
+ "text": "void"
31536
+ }
31537
+ },
31538
+ "description": "Handles the blur event on the list item. It resets the `wasSpacePressed` flag to false.",
31539
+ "inheritedFrom": {
31540
+ "name": "ListItem",
31541
+ "module": "components/listitem/listitem.component.js"
31542
+ }
31543
+ },
31397
31544
  {
31398
31545
  "kind": "method",
31399
31546
  "name": "handleClick",
@@ -31780,6 +31927,19 @@
31780
31927
  "module": "components/listitem/listitem.component.js"
31781
31928
  }
31782
31929
  },
31930
+ {
31931
+ "kind": "field",
31932
+ "name": "wasSpacePressed",
31933
+ "type": {
31934
+ "text": "boolean"
31935
+ },
31936
+ "privacy": "private",
31937
+ "default": "false",
31938
+ "inheritedFrom": {
31939
+ "name": "ListItem",
31940
+ "module": "components/listitem/listitem.component.js"
31941
+ }
31942
+ },
31783
31943
  {
31784
31944
  "kind": "field",
31785
31945
  "name": "willValidate",
@@ -45988,6 +46148,26 @@
45988
46148
  "module": "components/buttonsimple/buttonsimple.component.js"
45989
46149
  }
45990
46150
  },
46151
+ {
46152
+ "kind": "method",
46153
+ "name": "setSize",
46154
+ "privacy": "private",
46155
+ "return": {
46156
+ "type": {
46157
+ "text": "void"
46158
+ }
46159
+ },
46160
+ "parameters": [
46161
+ {
46162
+ "name": "size",
46163
+ "type": {
46164
+ "text": "TabSize"
46165
+ },
46166
+ "description": "The size to set."
46167
+ }
46168
+ ],
46169
+ "description": "Sets the size attribute for the tab component.\nIf the provided size is not included in TAB_SIZES,\nit defaults to the value specified in DEFAULTS.SIZE."
46170
+ },
45991
46171
  {
45992
46172
  "kind": "method",
45993
46173
  "name": "setSoftDisabled",
@@ -46041,7 +46221,7 @@
46041
46221
  "type": {
46042
46222
  "text": "ButtonSize"
46043
46223
  },
46044
- "description": "Simplebutton size is a super set of all the sizes supported by children components.",
46224
+ "description": "Size of the tab in pixels.\n- `32`: Default size (2rem)\n- `28`: Compact size (1.75rem)",
46045
46225
  "default": "32",
46046
46226
  "attribute": "size",
46047
46227
  "reflects": true,
@@ -46225,6 +46405,19 @@
46225
46405
  "default": "pill",
46226
46406
  "fieldName": "variant"
46227
46407
  },
46408
+ {
46409
+ "name": "size",
46410
+ "type": {
46411
+ "text": "ButtonSize"
46412
+ },
46413
+ "description": "Size of the tab in pixels.\n- `32`: Default size (2rem)\n- `28`: Compact size (1.75rem)",
46414
+ "default": "32",
46415
+ "fieldName": "size",
46416
+ "inheritedFrom": {
46417
+ "name": "Buttonsimple",
46418
+ "module": "src/components/buttonsimple/buttonsimple.component.ts"
46419
+ }
46420
+ },
46228
46421
  {
46229
46422
  "name": "tab-id",
46230
46423
  "type": {
@@ -46299,19 +46492,6 @@
46299
46492
  "module": "src/components/buttonsimple/buttonsimple.component.ts"
46300
46493
  }
46301
46494
  },
46302
- {
46303
- "name": "size",
46304
- "type": {
46305
- "text": "ButtonSize"
46306
- },
46307
- "description": "Simplebutton size is a super set of all the sizes supported by children components.",
46308
- "default": "32",
46309
- "fieldName": "size",
46310
- "inheritedFrom": {
46311
- "name": "Buttonsimple",
46312
- "module": "src/components/buttonsimple/buttonsimple.component.ts"
46313
- }
46314
- },
46315
46495
  {
46316
46496
  "name": "role",
46317
46497
  "type": {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@momentum-design/components",
3
3
  "packageManager": "yarn@3.2.4",
4
- "version": "0.133.26",
4
+ "version": "0.133.28",
5
5
  "engines": {
6
6
  "node": ">=20.0.0",
7
7
  "npm": ">=8.0.0"