@momentum-design/components 0.120.33 → 0.120.35

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.
@@ -66,6 +66,7 @@ const styles = [
66
66
  position: relative;
67
67
  display: grid;
68
68
  place-items: center;
69
+ flex-shrink: 0;
69
70
  }
70
71
  :host::part(photo) {
71
72
  border-radius: 100vh;
@@ -1,6 +1,7 @@
1
1
  import { CSSResult, PropertyValueMap, PropertyValues } from 'lit';
2
2
  import { AssociatedFormControl } from '../../utils/mixins/FormInternalsMixin';
3
3
  import FormfieldWrapper from '../formfieldwrapper/formfieldwrapper.component';
4
+ import type { CheckboxValidationType } from './checkbox.types';
4
5
  declare const Checkbox_base: import("../../utils/mixins/index.types").Constructor<import("../../models").Component & import("../../utils/mixins/AutoFocusOnMountMixin").AutoFocusOnMountMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
5
6
  /**
6
7
  * Checkboxes allow users to select multiple options from a list or turn an item/feature on or off.
@@ -74,7 +75,11 @@ declare class Checkbox extends Checkbox_base implements AssociatedFormControl {
74
75
  * @default false
75
76
  */
76
77
  autofocus: boolean;
77
- connectedCallback(): void;
78
+ /**
79
+ * The type of help text/validation. It can be 'default' or 'error'.
80
+ * @default 'default'
81
+ */
82
+ helpTextType: CheckboxValidationType;
78
83
  protected firstUpdated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
79
84
  /**
80
85
  * Updates the form value to reflect the current state of the checkbox.
@@ -17,6 +17,7 @@ import { FormInternalsMixin } from '../../utils/mixins/FormInternalsMixin';
17
17
  import FormfieldWrapper from '../formfieldwrapper/formfieldwrapper.component';
18
18
  import { DEFAULTS as FORMFIELD_DEFAULTS } from '../formfieldwrapper/formfieldwrapper.constants';
19
19
  import styles from './checkbox.styles';
20
+ import { CHECKBOX_VALIDATION } from './checkbox.constants';
20
21
  /**
21
22
  * Checkboxes allow users to select multiple options from a list or turn an item/feature on or off.
22
23
  * These are often used in forms, settings, and selections in lists.
@@ -91,17 +92,17 @@ class Checkbox extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMix
91
92
  * @default false
92
93
  */
93
94
  this.autofocus = false;
95
+ /**
96
+ * The type of help text/validation. It can be 'default' or 'error'.
97
+ * @default 'default'
98
+ */
99
+ this.helpTextType = CHECKBOX_VALIDATION.DEFAULT;
94
100
  this.renderLabelAndHelperText = () => {
95
101
  if (!this.label)
96
102
  return nothing;
97
103
  return html `<div part="text-container">${this.renderLabel()} ${this.renderHelperText()}</div>`;
98
104
  };
99
105
  }
100
- connectedCallback() {
101
- super.connectedCallback();
102
- // Checkbox does not contain helpTextType property.
103
- this.helpTextType = undefined;
104
- }
105
106
  firstUpdated(_changedProperties) {
106
107
  // set the element to auto focus if autoFocusOnMount is set to true
107
108
  // before running the super method, so that the AutoFocusOnMountMixin can use it
@@ -247,4 +248,8 @@ __decorate([
247
248
  property({ type: Boolean, reflect: true }),
248
249
  __metadata("design:type", Object)
249
250
  ], Checkbox.prototype, "autofocus", void 0);
251
+ __decorate([
252
+ property({ type: String, reflect: true, attribute: 'help-text-type' }),
253
+ __metadata("design:type", String)
254
+ ], Checkbox.prototype, "helpTextType", void 0);
250
255
  export default Checkbox;
@@ -4,4 +4,8 @@ declare const ICON_NAME: {
4
4
  readonly CHECKED: Extract<IconNames, "check-bold">;
5
5
  readonly INDETERMINATE: Extract<IconNames, "minus-bold">;
6
6
  };
7
- export { TAG_NAME, ICON_NAME };
7
+ declare const CHECKBOX_VALIDATION: {
8
+ readonly ERROR: "error";
9
+ readonly DEFAULT: "default";
10
+ };
11
+ export { TAG_NAME, ICON_NAME, CHECKBOX_VALIDATION };
@@ -1,7 +1,12 @@
1
1
  import utils from '../../utils/tag-name';
2
+ import { VALIDATION } from '../formfieldwrapper/formfieldwrapper.constants';
2
3
  const TAG_NAME = utils.constructTagName('checkbox');
3
4
  const ICON_NAME = {
4
5
  CHECKED: 'check-bold',
5
6
  INDETERMINATE: 'minus-bold',
6
7
  };
7
- export { TAG_NAME, ICON_NAME };
8
+ const CHECKBOX_VALIDATION = {
9
+ ERROR: VALIDATION.ERROR,
10
+ DEFAULT: VALIDATION.DEFAULT,
11
+ };
12
+ export { TAG_NAME, ICON_NAME, CHECKBOX_VALIDATION };
@@ -62,6 +62,10 @@ const styles = [
62
62
  --mdc-checkbox-background-color: var(--mds-color-theme-control-active-pressed);
63
63
  }
64
64
 
65
+ :host([help-text-type='error'])::part(static-checkbox) {
66
+ --mdc-checkbox-border-color: var(--mds-color-theme-outline-cancel-normal);
67
+ }
68
+
65
69
  :host([readonly]),
66
70
  :host([disabled]),
67
71
  :host([soft-disabled]) {
@@ -1,7 +1,9 @@
1
- import type { OverrideEventTarget, TypedCustomEvent } from "../../utils/types";
2
- import type Checkbox from "./checkbox.component";
1
+ import type { OverrideEventTarget, TypedCustomEvent, ValueOf } from '../../utils/types';
2
+ import type Checkbox from './checkbox.component';
3
+ import { CHECKBOX_VALIDATION } from './checkbox.constants';
4
+ type CheckboxValidationType = ValueOf<typeof CHECKBOX_VALIDATION>;
3
5
  interface Events {
4
6
  onChangeEvent: TypedCustomEvent<Checkbox>;
5
7
  onFocusEvent: OverrideEventTarget<FocusEvent, Checkbox>;
6
8
  }
7
- export type { Events };
9
+ export type { Events, CheckboxValidationType };
@@ -5,6 +5,7 @@ declare const InputChip_base: import("../../utils/mixins/index.types").Construct
5
5
  * mdc-inputchip component is an interactive chip that consumers can use to represent an input.
6
6
  *
7
7
  * - It supports a leading icon along with label.
8
+ * - It supports a prefix slot for avatars (takes precedence over icon-name).
8
9
  * - It supports an error state for validation.
9
10
  * - It supports a close button to remove the chip.
10
11
  *
@@ -16,6 +17,8 @@ declare const InputChip_base: import("../../utils/mixins/index.types").Construct
16
17
  *
17
18
  * @event remove - This event is dispatched when the close button is activated. It bubbles and is composed.
18
19
  *
20
+ * @slot prefix - A slot for prefix content such as avatars.
21
+ *
19
22
  * @csspart label - The label part of the chip.
20
23
  * @csspart icon - The icon part of the chip.
21
24
  * @csspart close-icon - The close icon part of the chip.
@@ -44,10 +47,10 @@ declare class InputChip extends InputChip_base {
44
47
  */
45
48
  clearAriaLabel: string;
46
49
  /**
47
- * Renders the icon element if available.
48
- * @returns The icon element if available, otherwise nothing.
50
+ * Renders the prefix content, supporting both icons and slot content.
51
+ * @returns The prefix content if available, otherwise nothing.
49
52
  */
50
- private renderIcon;
53
+ private renderPrefix;
51
54
  /**
52
55
  * Handles the behavior of the close button on click event.
53
56
  * @param event - The event object.
@@ -18,6 +18,7 @@ import { DEFAULTS } from './inputchip.constants';
18
18
  * mdc-inputchip component is an interactive chip that consumers can use to represent an input.
19
19
  *
20
20
  * - It supports a leading icon along with label.
21
+ * - It supports a prefix slot for avatars (takes precedence over icon-name).
21
22
  * - It supports an error state for validation.
22
23
  * - It supports a close button to remove the chip.
23
24
  *
@@ -29,6 +30,8 @@ import { DEFAULTS } from './inputchip.constants';
29
30
  *
30
31
  * @event remove - This event is dispatched when the close button is activated. It bubbles and is composed.
31
32
  *
33
+ * @slot prefix - A slot for prefix content such as avatars.
34
+ *
32
35
  * @csspart label - The label part of the chip.
33
36
  * @csspart icon - The icon part of the chip.
34
37
  * @csspart close-icon - The close icon part of the chip.
@@ -60,13 +63,17 @@ class InputChip extends IconNameMixin(DisabledMixin(Component)) {
60
63
  this.clearAriaLabel = '';
61
64
  }
62
65
  /**
63
- * Renders the icon element if available.
64
- * @returns The icon element if available, otherwise nothing.
66
+ * Renders the prefix content, supporting both icons and slot content.
67
+ * @returns The prefix content if available, otherwise nothing.
65
68
  */
66
- renderIcon() {
67
- if (!this.iconName)
68
- return nothing;
69
- return html ` <mdc-icon part="icon" name="${this.iconName}" length-unit="rem" size="1"></mdc-icon> `;
69
+ renderPrefix() {
70
+ return html `
71
+ <slot name="prefix">
72
+ ${this.iconName
73
+ ? html `<mdc-icon part="icon" name="${this.iconName}" length-unit="rem" size="1"></mdc-icon>`
74
+ : nothing}
75
+ </slot>
76
+ `;
70
77
  }
71
78
  /**
72
79
  * Handles the behavior of the close button on click event.
@@ -77,7 +84,7 @@ class InputChip extends IconNameMixin(DisabledMixin(Component)) {
77
84
  }
78
85
  render() {
79
86
  return html `
80
- ${this.renderIcon()}
87
+ ${this.renderPrefix()}
81
88
  ${this.label
82
89
  ? html `<mdc-text part="label" type="${DEFAULTS.TEXT_TYPE}" tagname="${DEFAULTS.TAG_NAME}"
83
90
  >${this.label}</mdc-text
@@ -31,5 +31,10 @@ const styles = css `
31
31
  --mdc-chip-color: var(--mds-color-theme-text-primary-disabled);
32
32
  cursor: auto;
33
33
  }
34
+
35
+ ::slotted(mdc-avatar[slot='prefix']){
36
+ width: 1.25rem;
37
+ height: 1.25rem;
38
+ }
34
39
  `;
35
40
  export default [hostFitContentStyles, styles];