@momentum-design/components 0.101.4 → 0.102.1
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.
- package/dist/browser/index.js +431 -399
- package/dist/browser/index.js.map +4 -4
- package/dist/components/listitem/listitem.component.d.ts +7 -1
- package/dist/components/listitem/listitem.component.js +22 -14
- package/dist/components/listitem/listitem.styles.js +10 -5
- package/dist/components/typewriter/index.d.ts +7 -0
- package/dist/components/typewriter/index.js +4 -0
- package/dist/components/typewriter/typewriter.component.d.ts +192 -0
- package/dist/components/typewriter/typewriter.component.js +454 -0
- package/dist/components/typewriter/typewriter.constants.d.ts +20 -0
- package/dist/components/typewriter/typewriter.constants.js +22 -0
- package/dist/components/typewriter/typewriter.styles.d.ts +2 -0
- package/dist/components/typewriter/typewriter.styles.js +19 -0
- package/dist/components/typewriter/typewriter.types.d.ts +21 -0
- package/dist/components/typewriter/typewriter.types.js +1 -0
- package/dist/custom-elements.json +1543 -987
- package/dist/index.d.ts +4 -2
- package/dist/index.js +2 -1
- package/dist/react/index.d.ts +3 -2
- package/dist/react/index.js +3 -2
- package/dist/react/listitem/index.d.ts +7 -1
- package/dist/react/listitem/index.js +7 -1
- package/dist/react/typewriter/index.d.ts +51 -0
- package/dist/react/typewriter/index.js +59 -0
- package/package.json +1 -1
@@ -32,6 +32,8 @@ declare const ListItem_base: import("../../utils/mixins/index.types").Constructo
|
|
32
32
|
* @slot trailing-text-side-header - slot for list item side header text.
|
33
33
|
* @slot trailing-text-subline - slot for list item subline text.
|
34
34
|
* @slot trailing-controls - slot for list item controls to appear of trailing end.
|
35
|
+
* @slot content - content slot can be used to override the content completely. Be aware that
|
36
|
+
* this will override the default content of the list item.
|
35
37
|
*
|
36
38
|
* @cssproperty --mdc-listitem-default-background-color - Allows customization of the default background color.
|
37
39
|
* @cssproperty --mdc-listitem-background-color-hover - Allows customization of the background color on hover.
|
@@ -42,7 +44,11 @@ declare const ListItem_base: import("../../utils/mixins/index.types").Constructo
|
|
42
44
|
* - Allows customization of the secondary and tertiary label text slot color.
|
43
45
|
* @cssproperty --mdc-listitem-disabled-color - Allows customization of the disabled color.
|
44
46
|
* @cssproperty --mdc-listitem-column-gap - Allows customization of column gap.
|
45
|
-
* @cssproperty --mdc-listitem-padding-left-
|
47
|
+
* @cssproperty --mdc-listitem-padding-left-right - Allows customization of padding left and right.
|
48
|
+
* @cssproperty --mdc-listitem-padding-top-bottom - Allows customization of padding top and bottom.
|
49
|
+
* @cssproperty --mdc-listitem-cursor - Allows customization of the cursor.
|
50
|
+
* @cssproperty --mdc-listitem-width - Allows customization of the width of the list item.
|
51
|
+
* @cssproperty --mdc-listitem-height - Allows customization of the height of the list item.
|
46
52
|
*
|
47
53
|
* @event click - (React: onClick) This event is dispatched when the listitem is clicked.
|
48
54
|
* @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the listitem.
|
@@ -48,6 +48,8 @@ import { ListItemEventManager } from './listitem.events';
|
|
48
48
|
* @slot trailing-text-side-header - slot for list item side header text.
|
49
49
|
* @slot trailing-text-subline - slot for list item subline text.
|
50
50
|
* @slot trailing-controls - slot for list item controls to appear of trailing end.
|
51
|
+
* @slot content - content slot can be used to override the content completely. Be aware that
|
52
|
+
* this will override the default content of the list item.
|
51
53
|
*
|
52
54
|
* @cssproperty --mdc-listitem-default-background-color - Allows customization of the default background color.
|
53
55
|
* @cssproperty --mdc-listitem-background-color-hover - Allows customization of the background color on hover.
|
@@ -58,7 +60,11 @@ import { ListItemEventManager } from './listitem.events';
|
|
58
60
|
* - Allows customization of the secondary and tertiary label text slot color.
|
59
61
|
* @cssproperty --mdc-listitem-disabled-color - Allows customization of the disabled color.
|
60
62
|
* @cssproperty --mdc-listitem-column-gap - Allows customization of column gap.
|
61
|
-
* @cssproperty --mdc-listitem-padding-left-
|
63
|
+
* @cssproperty --mdc-listitem-padding-left-right - Allows customization of padding left and right.
|
64
|
+
* @cssproperty --mdc-listitem-padding-top-bottom - Allows customization of padding top and bottom.
|
65
|
+
* @cssproperty --mdc-listitem-cursor - Allows customization of the cursor.
|
66
|
+
* @cssproperty --mdc-listitem-width - Allows customization of the width of the list item.
|
67
|
+
* @cssproperty --mdc-listitem-height - Allows customization of the height of the list item.
|
62
68
|
*
|
63
69
|
* @event click - (React: onClick) This event is dispatched when the listitem is clicked.
|
64
70
|
* @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the listitem.
|
@@ -252,21 +258,23 @@ class ListItem extends DisabledMixin(TabIndexMixin(Component)) {
|
|
252
258
|
}
|
253
259
|
render() {
|
254
260
|
return html `
|
255
|
-
<
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
+
<slot name="content">
|
262
|
+
<div part="leading">
|
263
|
+
${this.renderLeadingControls()}
|
264
|
+
<div part="leading-text">
|
265
|
+
${this.getText('leading-text-primary-label', TYPE.BODY_MIDSIZE_REGULAR, this.label)}
|
266
|
+
${this.getText('leading-text-secondary-label', TYPE.BODY_SMALL_REGULAR, this.secondaryLabel)}
|
267
|
+
${this.getText('leading-text-tertiary-label', TYPE.BODY_SMALL_REGULAR, this.tertiaryLabel)}
|
268
|
+
</div>
|
261
269
|
</div>
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
270
|
+
<div part="trailing">
|
271
|
+
<div part="trailing-text">
|
272
|
+
${this.getText('trailing-text-side-header', TYPE.BODY_MIDSIZE_REGULAR, this.sideHeaderText)}
|
273
|
+
${this.getText('trailing-text-subline', TYPE.BODY_SMALL_REGULAR, this.sublineText)}
|
274
|
+
</div>
|
275
|
+
${this.renderTrailingControls()}
|
267
276
|
</div>
|
268
|
-
|
269
|
-
</div>
|
277
|
+
</slot>
|
270
278
|
`;
|
271
279
|
}
|
272
280
|
}
|
@@ -9,16 +9,21 @@ const styles = css `
|
|
9
9
|
--mdc-listitem-secondary-label-color: var(--mds-color-theme-text-secondary-normal);
|
10
10
|
--mdc-listitem-disabled-color: var(--mds-color-theme-text-primary-disabled);
|
11
11
|
--mdc-listitem-column-gap: 0.75rem;
|
12
|
-
--mdc-listitem-padding-left-
|
12
|
+
--mdc-listitem-padding-left-right: 0.75rem;
|
13
|
+
--mdc-listitem-padding-top-bottom: 0.5rem;
|
14
|
+
--mdc-listitem-cursor: pointer;
|
15
|
+
--mdc-listitem-width: 100%;
|
16
|
+
--mdc-listitem-height: auto;
|
13
17
|
}
|
14
18
|
:host {
|
15
19
|
background-color: var(--mdc-listitem-default-background-color);
|
16
20
|
column-gap: var(--mdc-listitem-column-gap);
|
17
|
-
cursor: pointer;
|
18
21
|
display: flex;
|
19
22
|
flex-direction: row;
|
20
|
-
|
21
|
-
|
23
|
+
cursor: var(--mdc-listitem-cursor);
|
24
|
+
padding: var(--mdc-listitem-padding-top-bottom) var(--mdc-listitem-padding-left-right);
|
25
|
+
width: var(--mdc-listitem-width);
|
26
|
+
height: var(--mdc-listitem-height);
|
22
27
|
}
|
23
28
|
:host([variant='inset-rectangle']) {
|
24
29
|
border-radius: 0.5rem;
|
@@ -29,7 +34,7 @@ const styles = css `
|
|
29
34
|
:host::part(leading-text) {
|
30
35
|
flex: 1;
|
31
36
|
/** 2x of column gap on both ends of the listitem - 100% width */
|
32
|
-
width: calc(100% - (2 * var(--mdc-listitem-padding-left-
|
37
|
+
width: calc(100% - (2 * var(--mdc-listitem-padding-left-right)));
|
33
38
|
}
|
34
39
|
:host::part(leading-text-primary-label),
|
35
40
|
:host::part(leading-text-secondary-label),
|
@@ -0,0 +1,192 @@
|
|
1
|
+
import { CSSResult, PropertyValues } from 'lit';
|
2
|
+
import { Component } from '../../models';
|
3
|
+
import '../text';
|
4
|
+
import type { TextType, TagName, TypewriterSpeed } from './typewriter.types';
|
5
|
+
/**
|
6
|
+
* Typewriter component that creates a typewriter effect on text content.
|
7
|
+
* It uses the Text component internally, adding a progressive typing effect.
|
8
|
+
*
|
9
|
+
* The `type` attribute allows changing the text style (passed to the internal Text component).
|
10
|
+
* The `tagname` attribute allows changing the tag name of the text element (passed to the internal Text component).
|
11
|
+
* The default tag name is `p`.
|
12
|
+
*
|
13
|
+
* The `speed` attribute controls typing speed in milliseconds per character:
|
14
|
+
* - 'very-slow' = 240ms per character
|
15
|
+
* - 'slow' = 120ms per character
|
16
|
+
* - 'normal' = 60ms per character (default)
|
17
|
+
* - 'fast' = 20ms per character
|
18
|
+
* - 'very-fast' = 1ms per character
|
19
|
+
* - Or any numeric string representing milliseconds
|
20
|
+
*
|
21
|
+
* Advanced features:
|
22
|
+
* - Dynamic speed adjustment during typing
|
23
|
+
* - Chunked text addition via addTextChunk() method
|
24
|
+
* - Instant text addition via addInstantTextChunk() method or instant parameter
|
25
|
+
* - Mixed instant and animated chunks in queue
|
26
|
+
* - Continues typing in background tabs
|
27
|
+
* - Performance optimized for large text
|
28
|
+
* - maxQueueSize to limit memory usage from excessive queuing
|
29
|
+
* - event handling for typing completion and content changes
|
30
|
+
*
|
31
|
+
* The component includes accessibility features:
|
32
|
+
* - Screen readers announce the complete text, not character by character
|
33
|
+
* - Uses aria-live="polite" for dynamic content updates
|
34
|
+
* - Sets aria-busy during typing animation
|
35
|
+
*
|
36
|
+
* @dependency mdc-text
|
37
|
+
*
|
38
|
+
* @tagname mdc-typewriter
|
39
|
+
* @slot - Default slot for text content
|
40
|
+
*
|
41
|
+
* @csspart container - Container for the text element
|
42
|
+
* @csspart text - The text element (forwarded to mdc-text)
|
43
|
+
*
|
44
|
+
* @event typing-complete - (React: onTypingComplete) Fired when the typewriter finishes typing all content.
|
45
|
+
* Detail: \{ finalContent: string \}
|
46
|
+
* @event change - (React: onChange) Fired when the content of the typewriter changes.
|
47
|
+
* Detail: \{ content: string, isTyping: boolean \}
|
48
|
+
*/
|
49
|
+
declare class Typewriter extends Component {
|
50
|
+
/**
|
51
|
+
* Specifies the text style to be applied to the internal text component.
|
52
|
+
* Uses the same types as the Text component.
|
53
|
+
* @default body-large-regular
|
54
|
+
*/
|
55
|
+
type: TextType;
|
56
|
+
/**
|
57
|
+
* Specifies the HTML tag name for the text element. The default tag name is `p`.
|
58
|
+
* This attribute is optional. When set, it changes the tag name of the internal text element.
|
59
|
+
*
|
60
|
+
* Acceptable values include all valid tag names from the Text component.
|
61
|
+
*/
|
62
|
+
tagname?: TagName;
|
63
|
+
/**
|
64
|
+
* Speed of the typewriter effect in milliseconds per character.
|
65
|
+
* Can be a string preset or a numeric string in milliseconds.
|
66
|
+
* - 'very-slow' = 240ms per character
|
67
|
+
* - 'slow' = 120ms per character
|
68
|
+
* - 'normal' = 60ms per character (default)
|
69
|
+
* - 'fast' = 20ms per character
|
70
|
+
* - 'very-fast' = 1ms per character
|
71
|
+
* - Or any numeric string representing milliseconds (e.g., '100')
|
72
|
+
* @default 'normal' (60ms per character)
|
73
|
+
*/
|
74
|
+
speed: TypewriterSpeed;
|
75
|
+
/**
|
76
|
+
* Maximum number of text chunks that can be queued before oldest chunks are dropped.
|
77
|
+
* Set to prevent memory accumulation from excessive queuing.
|
78
|
+
* @default Number.MAX_SAFE_INTEGER (effectively unlimited)
|
79
|
+
*/
|
80
|
+
maxQueueSize: number;
|
81
|
+
/**
|
82
|
+
* Internal state for the displayed text
|
83
|
+
* @internal
|
84
|
+
*/
|
85
|
+
private displayedText;
|
86
|
+
/**
|
87
|
+
* Internal state to track the original text
|
88
|
+
* @internal
|
89
|
+
*/
|
90
|
+
private originalText;
|
91
|
+
/**
|
92
|
+
* Character index for typing animation
|
93
|
+
* @internal
|
94
|
+
*/
|
95
|
+
private currentIndex;
|
96
|
+
/**
|
97
|
+
* Typing animation timeout id
|
98
|
+
* @internal
|
99
|
+
*/
|
100
|
+
private typingTimeout;
|
101
|
+
/**
|
102
|
+
* Set of pending setTimeout IDs for cleanup
|
103
|
+
* @internal
|
104
|
+
*/
|
105
|
+
private pendingTimeouts;
|
106
|
+
/**
|
107
|
+
* Queue of text chunks to be added (limited to prevent memory issues)
|
108
|
+
* @internal
|
109
|
+
*/
|
110
|
+
private textChunkQueue;
|
111
|
+
/**
|
112
|
+
* Stores previous text content for comparison
|
113
|
+
* @internal
|
114
|
+
*/
|
115
|
+
private previousTextContent;
|
116
|
+
/**
|
117
|
+
* Whether the typing animation has completed
|
118
|
+
* @internal
|
119
|
+
*/
|
120
|
+
private typingComplete;
|
121
|
+
/**
|
122
|
+
* Called when the element is first connected to the document
|
123
|
+
*/
|
124
|
+
connectedCallback(): void;
|
125
|
+
/**
|
126
|
+
* Called when the element is disconnected from the document
|
127
|
+
*/
|
128
|
+
disconnectedCallback(): void;
|
129
|
+
/**
|
130
|
+
* Helper to create tracked setTimeout that will be cleaned up on disconnect
|
131
|
+
*/
|
132
|
+
private createTimeout;
|
133
|
+
/**
|
134
|
+
* Clear all pending timeouts
|
135
|
+
*/
|
136
|
+
private clearAllTimeouts;
|
137
|
+
/**
|
138
|
+
* Clears the text chunk queue and stops processing
|
139
|
+
* Useful for resetting the component state
|
140
|
+
*/
|
141
|
+
clearQueue(): void;
|
142
|
+
/**
|
143
|
+
* Adds a chunk of text to be typed out, optionally with a different speed
|
144
|
+
* @param text - The text to add
|
145
|
+
* @param speed - Optional speed override for this chunk
|
146
|
+
* @param instant - If true, text appears instantly without animation
|
147
|
+
*/
|
148
|
+
addTextChunk(text: string, speed?: TypewriterSpeed, instant?: boolean): void;
|
149
|
+
/**
|
150
|
+
* Adds a chunk of text instantly without typing animation
|
151
|
+
* @param text - The text to add instantly
|
152
|
+
*/
|
153
|
+
addInstantTextChunk(text: string): void;
|
154
|
+
/**
|
155
|
+
* Processes all chunks in the queue
|
156
|
+
*/
|
157
|
+
private processChunkQueue;
|
158
|
+
/**
|
159
|
+
* Processes the next chunk in the queue
|
160
|
+
*/
|
161
|
+
private processNextChunk;
|
162
|
+
/**
|
163
|
+
* Gets the typing delay in milliseconds per character
|
164
|
+
*/
|
165
|
+
private getTypingDelayMs;
|
166
|
+
/**
|
167
|
+
* Responds to property changes
|
168
|
+
*/
|
169
|
+
updated(changedProperties: PropertyValues): void;
|
170
|
+
/**
|
171
|
+
* Captures slot content and starts typewriter animation
|
172
|
+
*/
|
173
|
+
private captureAndProcessContent;
|
174
|
+
/**
|
175
|
+
* Starts the typewriter animation
|
176
|
+
*/
|
177
|
+
private startTypingAnimation;
|
178
|
+
/**
|
179
|
+
* Clears the typing animation timeout
|
180
|
+
*/
|
181
|
+
private clearTypingAnimation;
|
182
|
+
/**
|
183
|
+
* Handler for slotchange event
|
184
|
+
*/
|
185
|
+
private handleSlotChange;
|
186
|
+
/**
|
187
|
+
* Render method that uses mdc-text component internally with accessibility features
|
188
|
+
*/
|
189
|
+
render(): import("lit-html").TemplateResult<1>;
|
190
|
+
static styles: Array<CSSResult>;
|
191
|
+
}
|
192
|
+
export default Typewriter;
|