@momentum-design/components 0.134.5 → 0.134.7

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.
@@ -3,7 +3,8 @@ import { CSSResult } from 'lit';
3
3
  import { AssociatedFormControl } from '../../utils/mixins/FormInternalsMixin';
4
4
  import FormfieldWrapper from '../formfieldwrapper/formfieldwrapper.component';
5
5
  import type { PopoverStrategy } from '../popover/popover.types';
6
- import type { Placement, TimeFormat } from './timepicker.types';
6
+ import type { IconNames } from '../icon/icon.types';
7
+ import type { OptionLabelFormatter, Placement, TimeFormat } from './timepicker.types';
7
8
  declare const TimePicker_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
8
9
  /**
9
10
  * mdc-timepicker is a component that allows users to select a specific time
@@ -61,6 +62,7 @@ declare const TimePicker_base: import("../../utils/mixins/index.types").Construc
61
62
  * @csspart separator - The colon separator between spinbuttons.
62
63
  * @csspart period - The AM/PM period spinbutton.
63
64
  * @csspart icon-container - The dropdown arrow button container.
65
+ * @csspart leading-icon - The prefix icon element displayed before spinbuttons.
64
66
  * @csspart native-input - The hidden native input for form participation.
65
67
  * @csspart listbox - The dropdown list container.
66
68
  */
@@ -152,6 +154,16 @@ declare class TimePicker extends TimePicker_base implements AssociatedFormContro
152
154
  * Consumers must provide a translated string.
153
155
  */
154
156
  localePmLabel: string;
157
+ /**
158
+ * The icon name to display as a prefix icon in the timepicker input.
159
+ */
160
+ prefixIcon?: IconNames;
161
+ /**
162
+ * A callback function to format the label of each dropdown option.
163
+ * Receives the default label string and the 24h value string, and should return a formatted label.
164
+ * When not set, the default time formatting is used.
165
+ */
166
+ optionLabelFormatter?: OptionLabelFormatter;
155
167
  /**
156
168
  * Accessible label for the dropdown toggle button.
157
169
  * Consumers must provide a translated string.
@@ -73,6 +73,7 @@ import styles from './timepicker.styles';
73
73
  * @csspart separator - The colon separator between spinbuttons.
74
74
  * @csspart period - The AM/PM period spinbutton.
75
75
  * @csspart icon-container - The dropdown arrow button container.
76
+ * @csspart leading-icon - The prefix icon element displayed before spinbuttons.
76
77
  * @csspart native-input - The hidden native input for form participation.
77
78
  * @csspart listbox - The dropdown list container.
78
79
  */
@@ -770,7 +771,7 @@ class TimePicker extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)
770
771
  const currentValue = this.internalToValue();
771
772
  return options.map(option => html `
772
773
  <mdc-option
773
- label="${option.label}"
774
+ label="${this.optionLabelFormatter ? this.optionLabelFormatter(option.label, option.value) : option.label}"
774
775
  ?selected="${option.value === currentValue}"
775
776
  aria-selected="${option.value === currentValue ? 'true' : 'false'}"
776
777
  @click="${() => this.handleOptionClick(option.value)}"
@@ -791,6 +792,9 @@ class TimePicker extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)
791
792
  @click="${this.handleBaseContainerClick}"
792
793
  @keydown="${this.handleBaseKeydown}"
793
794
  >
795
+ ${this.prefixIcon
796
+ ? html `<mdc-icon part="leading-icon" name="${this.prefixIcon}" size="1"></mdc-icon>`
797
+ : nothing}
794
798
  <div part="spinbutton-group">
795
799
  <input
796
800
  id="hours-spinbutton"
@@ -984,6 +988,14 @@ __decorate([
984
988
  property({ type: String, attribute: 'locale-pm-label' }),
985
989
  __metadata("design:type", Object)
986
990
  ], TimePicker.prototype, "localePmLabel", void 0);
991
+ __decorate([
992
+ property({ type: String, reflect: true, attribute: 'prefix-icon' }),
993
+ __metadata("design:type", String)
994
+ ], TimePicker.prototype, "prefixIcon", void 0);
995
+ __decorate([
996
+ property({ attribute: false }),
997
+ __metadata("design:type", Function)
998
+ ], TimePicker.prototype, "optionLabelFormatter", void 0);
987
999
  __decorate([
988
1000
  property({ type: String, attribute: 'locale-show-time-picker-label' }),
989
1001
  __metadata("design:type", Object)
@@ -18,4 +18,11 @@ interface Events {
18
18
  onHiddenEvent: PopoverHiddenEvent;
19
19
  }
20
20
  type Placement = Extract<PopoverPlacement, 'bottom-start' | 'top-start'>;
21
- export type { Events, Placement, TimeFormat, TimePickerChangeEvent, TimePickerInputEvent };
21
+ /**
22
+ * A callback function to format the label of each dropdown option.
23
+ * @param label - The default formatted label string (e.g., "1:30 PM" or "13:30").
24
+ * @param value - The 24-hour time value string (e.g., "13:30").
25
+ * @returns The formatted label string to display.
26
+ */
27
+ type OptionLabelFormatter = (label: string, value: string) => string;
28
+ export type { Events, OptionLabelFormatter, Placement, TimeFormat, TimePickerChangeEvent, TimePickerInputEvent };
@@ -49111,6 +49111,10 @@
49111
49111
  "description": "The dropdown arrow button container.",
49112
49112
  "name": "icon-container"
49113
49113
  },
49114
+ {
49115
+ "description": "The prefix icon element displayed before spinbuttons.",
49116
+ "name": "leading-icon"
49117
+ },
49114
49118
  {
49115
49119
  "description": "The hidden native input for form participation.",
49116
49120
  "name": "native-input"
@@ -49442,6 +49446,14 @@
49442
49446
  "module": "utils/mixins/FormInternalsMixin.js"
49443
49447
  }
49444
49448
  },
49449
+ {
49450
+ "kind": "field",
49451
+ "name": "optionLabelFormatter",
49452
+ "type": {
49453
+ "text": "OptionLabelFormatter | undefined"
49454
+ },
49455
+ "description": "A callback function to format the label of each dropdown option.\nReceives the default label string and the 24h value string, and should return a formatted label.\nWhen not set, the default time formatting is used."
49456
+ },
49445
49457
  {
49446
49458
  "kind": "field",
49447
49459
  "name": "placement",
@@ -49453,6 +49465,16 @@
49453
49465
  "attribute": "placement",
49454
49466
  "reflects": true
49455
49467
  },
49468
+ {
49469
+ "kind": "field",
49470
+ "name": "prefixIcon",
49471
+ "type": {
49472
+ "text": "IconNames | undefined"
49473
+ },
49474
+ "description": "The icon name to display as a prefix icon in the timepicker input.",
49475
+ "attribute": "prefix-icon",
49476
+ "reflects": true
49477
+ },
49456
49478
  {
49457
49479
  "kind": "field",
49458
49480
  "name": "readonly",
@@ -49890,6 +49912,14 @@
49890
49912
  "description": "Label for the PM period.\nConsumers must provide a translated string.",
49891
49913
  "fieldName": "localePmLabel"
49892
49914
  },
49915
+ {
49916
+ "name": "prefix-icon",
49917
+ "type": {
49918
+ "text": "IconNames | undefined"
49919
+ },
49920
+ "description": "The icon name to display as a prefix icon in the timepicker input.",
49921
+ "fieldName": "prefixIcon"
49922
+ },
49893
49923
  {
49894
49924
  "name": "locale-show-time-picker-label",
49895
49925
  "type": {
@@ -50123,7 +50153,7 @@
50123
50153
  "module": "/src/components/formfieldwrapper/formfieldwrapper.component"
50124
50154
  },
50125
50155
  "tagName": "mdc-timepicker",
50126
- "jsDoc": "/**\n * mdc-timepicker is a component that allows users to select a specific time\n * or enter a time manually. It supports both 12-hour and 24-hour formats.\n *\n * The component consists of:\n * - label - describes the time picker field\n * - input field - made up of 2-3 spinbuttons (hours, minutes, optional AM/PM period)\n * - dropdown arrow button - opens a flyout menu with predefined time intervals\n * - helper text - displayed below the input field\n *\n * Users can input values by:\n * - Manually entering numbers/characters in spinbuttons\n * - Navigating using arrow keys to increment/decrement values\n * - Selecting a predefined time from the dropdown menu\n *\n * @tagname mdc-timepicker\n *\n * @dependency mdc-button\n * @dependency mdc-icon\n * @dependency mdc-option\n * @dependency mdc-popover\n * @dependency mdc-text\n * @dependency mdc-toggletip\n *\n * @event input - (React: onInput) This event is dispatched when the time value changes.\n * @event change - (React: onChange) This event is dispatched when the time value is committed.\n * @event focus - (React: onFocus) This event is dispatched when the timepicker receives focus.\n * @event blur - (React: onBlur) This event is dispatched when the timepicker loses focus.\n *\n * @slot label - Slot for the label element.\n * @slot toggletip - Slot for the toggletip info icon button.\n * @slot help-icon - Slot for the helper/validation icon.\n * @slot help-text - Slot for the helper/validation text.\n *\n * @cssproperty --mdc-timepicker-background-color - Background color of the timepicker input.\n * @cssproperty --mdc-timepicker-border-color - Border color of the timepicker input.\n * @cssproperty --mdc-timepicker-text-color - Text color of the timepicker input.\n * @cssproperty --mdc-timepicker-height - The height of the timepicker trigger control.\n * @cssproperty --mdc-timepicker-width - Width of the timepicker component.\n * @cssproperty --mdc-timepicker-listbox-height - The max-height of the dropdown listbox. Default shows ~6 items.\n *\n * @csspart label - The label element.\n * @csspart label-text - The container for the label and required indicator elements.\n * @csspart required-indicator - The required indicator element.\n * @csspart info-icon-btn - The info icon button element.\n * @csspart label-toggletip - The toggletip element.\n * @csspart help-text - The helper/validation text element.\n * @csspart helper-icon - The helper/validation icon element.\n * @csspart help-text-container - The container for helper/validation elements.\n * @csspart container - The outer container for the input and popover.\n * @csspart base-container - The input container with border and background.\n * @csspart spinbutton-group - The container for spinbutton elements.\n * @csspart spinbutton - A spinbutton input element.\n * @csspart separator - The colon separator between spinbuttons.\n * @csspart period - The AM/PM period spinbutton.\n * @csspart icon-container - The dropdown arrow button container.\n * @csspart native-input - The hidden native input for form participation.\n * @csspart listbox - The dropdown list container.\n */",
50156
+ "jsDoc": "/**\n * mdc-timepicker is a component that allows users to select a specific time\n * or enter a time manually. It supports both 12-hour and 24-hour formats.\n *\n * The component consists of:\n * - label - describes the time picker field\n * - input field - made up of 2-3 spinbuttons (hours, minutes, optional AM/PM period)\n * - dropdown arrow button - opens a flyout menu with predefined time intervals\n * - helper text - displayed below the input field\n *\n * Users can input values by:\n * - Manually entering numbers/characters in spinbuttons\n * - Navigating using arrow keys to increment/decrement values\n * - Selecting a predefined time from the dropdown menu\n *\n * @tagname mdc-timepicker\n *\n * @dependency mdc-button\n * @dependency mdc-icon\n * @dependency mdc-option\n * @dependency mdc-popover\n * @dependency mdc-text\n * @dependency mdc-toggletip\n *\n * @event input - (React: onInput) This event is dispatched when the time value changes.\n * @event change - (React: onChange) This event is dispatched when the time value is committed.\n * @event focus - (React: onFocus) This event is dispatched when the timepicker receives focus.\n * @event blur - (React: onBlur) This event is dispatched when the timepicker loses focus.\n *\n * @slot label - Slot for the label element.\n * @slot toggletip - Slot for the toggletip info icon button.\n * @slot help-icon - Slot for the helper/validation icon.\n * @slot help-text - Slot for the helper/validation text.\n *\n * @cssproperty --mdc-timepicker-background-color - Background color of the timepicker input.\n * @cssproperty --mdc-timepicker-border-color - Border color of the timepicker input.\n * @cssproperty --mdc-timepicker-text-color - Text color of the timepicker input.\n * @cssproperty --mdc-timepicker-height - The height of the timepicker trigger control.\n * @cssproperty --mdc-timepicker-width - Width of the timepicker component.\n * @cssproperty --mdc-timepicker-listbox-height - The max-height of the dropdown listbox. Default shows ~6 items.\n *\n * @csspart label - The label element.\n * @csspart label-text - The container for the label and required indicator elements.\n * @csspart required-indicator - The required indicator element.\n * @csspart info-icon-btn - The info icon button element.\n * @csspart label-toggletip - The toggletip element.\n * @csspart help-text - The helper/validation text element.\n * @csspart helper-icon - The helper/validation icon element.\n * @csspart help-text-container - The container for helper/validation elements.\n * @csspart container - The outer container for the input and popover.\n * @csspart base-container - The input container with border and background.\n * @csspart spinbutton-group - The container for spinbutton elements.\n * @csspart spinbutton - A spinbutton input element.\n * @csspart separator - The colon separator between spinbuttons.\n * @csspart period - The AM/PM period spinbutton.\n * @csspart icon-container - The dropdown arrow button container.\n * @csspart leading-icon - The prefix icon element displayed before spinbuttons.\n * @csspart native-input - The hidden native input for form participation.\n * @csspart listbox - The dropdown list container.\n */",
50127
50157
  "customElement": true
50128
50158
  }
50129
50159
  ],
@@ -57,6 +57,7 @@ import type { Events } from '../../components/timepicker/timepicker.types';
57
57
  * @csspart separator - The colon separator between spinbuttons.
58
58
  * @csspart period - The AM/PM period spinbutton.
59
59
  * @csspart icon-container - The dropdown arrow button container.
60
+ * @csspart leading-icon - The prefix icon element displayed before spinbuttons.
60
61
  * @csspart native-input - The hidden native input for form participation.
61
62
  * @csspart listbox - The dropdown list container.
62
63
  */
@@ -58,6 +58,7 @@ import { TAG_NAME } from '../../components/timepicker/timepicker.constants';
58
58
  * @csspart separator - The colon separator between spinbuttons.
59
59
  * @csspart period - The AM/PM period spinbutton.
60
60
  * @csspart icon-container - The dropdown arrow button container.
61
+ * @csspart leading-icon - The prefix icon element displayed before spinbuttons.
61
62
  * @csspart native-input - The hidden native input for form participation.
62
63
  * @csspart listbox - The dropdown list container.
63
64
  */
@@ -18,8 +18,7 @@ export const OverflowMixin = (superClass) => {
18
18
  return el.scrollWidth > el.clientWidth;
19
19
  }
20
20
  isHeightOverflowing() {
21
- const el = this.overflowElement;
22
- return el.scrollHeight > el.clientHeight;
21
+ return this.scrollHeight > this.clientHeight;
23
22
  }
24
23
  }
25
24
  // Cast return type to your mixin's interface intersected with the superClass 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.134.5",
4
+ "version": "0.134.7",
5
5
  "engines": {
6
6
  "node": ">=20.0.0",
7
7
  "npm": ">=8.0.0"