@momentum-design/components 0.96.3 → 0.96.4
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 +294 -253
- package/dist/browser/index.js.map +4 -4
- package/dist/components/stepper/index.d.ts +7 -0
- package/dist/components/stepper/index.js +4 -0
- package/dist/components/stepper/stepper.component.d.ts +46 -0
- package/dist/components/stepper/stepper.component.js +85 -0
- package/dist/components/stepper/stepper.constants.d.ts +6 -0
- package/dist/components/stepper/stepper.constants.js +9 -0
- package/dist/components/stepper/stepper.context.d.ts +11 -0
- package/dist/components/stepper/stepper.context.js +10 -0
- package/dist/components/stepper/stepper.styles.d.ts +2 -0
- package/dist/components/stepper/stepper.styles.js +41 -0
- package/dist/components/stepperconnector/stepperconnector.component.d.ts +4 -0
- package/dist/components/stepperconnector/stepperconnector.component.js +11 -0
- package/dist/components/stepperitem/stepperitem.component.d.ts +5 -0
- package/dist/components/stepperitem/stepperitem.component.js +14 -0
- package/dist/components/stepperitem/stepperitem.styles.js +5 -1
- package/dist/custom-elements.json +866 -769
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.js +2 -1
- package/dist/react/stepper/index.d.ts +12 -0
- package/dist/react/stepper/index.js +21 -0
- package/package.json +1 -1
@@ -0,0 +1,46 @@
|
|
1
|
+
import type { CSSResult, PropertyValueMap } from 'lit';
|
2
|
+
import { Provider } from '../../models';
|
3
|
+
import type { OrientationType } from '../stepperconnector/stepperconnector.types';
|
4
|
+
import type { VariantType } from '../stepperitem/stepperitem.types';
|
5
|
+
import StepperContext from './stepper.context';
|
6
|
+
/**
|
7
|
+
* Stepper component, which orchestrates stepperitem and stepperconnector components, is a wrapper for the stepper functionality.
|
8
|
+
* It provides the context for the stepper items and connectors, allowing them to adapt to the stepper's orientation and variant.
|
9
|
+
*
|
10
|
+
* @tagname mdc-stepper
|
11
|
+
*
|
12
|
+
* @slot default - Pass the list of `mdc-stepperitem` and `mdc-stepperconnector` elements to be rendered inside the stepper.
|
13
|
+
*
|
14
|
+
*/
|
15
|
+
declare class Stepper extends Provider<StepperContext> {
|
16
|
+
/**
|
17
|
+
* The orientation of the stepperconnector (vertical or horizontal)
|
18
|
+
* @default "horizontal"
|
19
|
+
*/
|
20
|
+
orientation: OrientationType;
|
21
|
+
/**
|
22
|
+
* The variant of the stepper item, which can be `inline` or `stacked`.
|
23
|
+
* @default 'inline'
|
24
|
+
*/
|
25
|
+
variant: VariantType;
|
26
|
+
constructor();
|
27
|
+
connectedCallback(): void;
|
28
|
+
/**
|
29
|
+
* Get the context for the stepper component.
|
30
|
+
* This context provides the orientation and variant for the stepper items and connectors.
|
31
|
+
*/
|
32
|
+
static get Context(): {
|
33
|
+
__context__: StepperContext;
|
34
|
+
};
|
35
|
+
protected updated(changedProperties: PropertyValueMap<Stepper>): void;
|
36
|
+
/**
|
37
|
+
* Update all observing components of this
|
38
|
+
* provider to update the values
|
39
|
+
*
|
40
|
+
* Is called on every re-render, see Provider class
|
41
|
+
*/
|
42
|
+
protected updateContext(): void;
|
43
|
+
render(): import("lit-html").TemplateResult<1>;
|
44
|
+
static styles: Array<CSSResult>;
|
45
|
+
}
|
46
|
+
export default Stepper;
|
@@ -0,0 +1,85 @@
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
+
};
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
9
|
+
};
|
10
|
+
import { html } from 'lit';
|
11
|
+
import { property } from 'lit/decorators.js';
|
12
|
+
import { Component, Provider } from '../../models';
|
13
|
+
import { ROLE } from '../../utils/roles';
|
14
|
+
import { DEFAULTS } from './stepper.constants';
|
15
|
+
import StepperContext from './stepper.context';
|
16
|
+
import styles from './stepper.styles';
|
17
|
+
/**
|
18
|
+
* Stepper component, which orchestrates stepperitem and stepperconnector components, is a wrapper for the stepper functionality.
|
19
|
+
* It provides the context for the stepper items and connectors, allowing them to adapt to the stepper's orientation and variant.
|
20
|
+
*
|
21
|
+
* @tagname mdc-stepper
|
22
|
+
*
|
23
|
+
* @slot default - Pass the list of `mdc-stepperitem` and `mdc-stepperconnector` elements to be rendered inside the stepper.
|
24
|
+
*
|
25
|
+
*/
|
26
|
+
class Stepper extends Provider {
|
27
|
+
constructor() {
|
28
|
+
super({
|
29
|
+
context: StepperContext.context,
|
30
|
+
initialValue: new StepperContext(DEFAULTS.ORIENTATION, DEFAULTS.VARIANT),
|
31
|
+
});
|
32
|
+
/**
|
33
|
+
* The orientation of the stepperconnector (vertical or horizontal)
|
34
|
+
* @default "horizontal"
|
35
|
+
*/
|
36
|
+
this.orientation = DEFAULTS.ORIENTATION;
|
37
|
+
/**
|
38
|
+
* The variant of the stepper item, which can be `inline` or `stacked`.
|
39
|
+
* @default 'inline'
|
40
|
+
*/
|
41
|
+
this.variant = DEFAULTS.VARIANT;
|
42
|
+
}
|
43
|
+
connectedCallback() {
|
44
|
+
super.connectedCallback();
|
45
|
+
this.role = ROLE.LIST;
|
46
|
+
}
|
47
|
+
/**
|
48
|
+
* Get the context for the stepper component.
|
49
|
+
* This context provides the orientation and variant for the stepper items and connectors.
|
50
|
+
*/
|
51
|
+
static get Context() {
|
52
|
+
return StepperContext.context;
|
53
|
+
}
|
54
|
+
updated(changedProperties) {
|
55
|
+
if (changedProperties.has('orientation') || changedProperties.has('variant')) {
|
56
|
+
this.updateContext();
|
57
|
+
}
|
58
|
+
}
|
59
|
+
/**
|
60
|
+
* Update all observing components of this
|
61
|
+
* provider to update the values
|
62
|
+
*
|
63
|
+
* Is called on every re-render, see Provider class
|
64
|
+
*/
|
65
|
+
updateContext() {
|
66
|
+
if (this.context.value.variant !== this.variant || this.context.value.orientation !== this.orientation) {
|
67
|
+
this.context.value.variant = this.variant;
|
68
|
+
this.context.value.orientation = this.orientation;
|
69
|
+
this.context.updateObservers();
|
70
|
+
}
|
71
|
+
}
|
72
|
+
render() {
|
73
|
+
return html ` <slot></slot> `;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
Stepper.styles = [...Component.styles, ...styles];
|
77
|
+
__decorate([
|
78
|
+
property({ type: String, reflect: true }),
|
79
|
+
__metadata("design:type", String)
|
80
|
+
], Stepper.prototype, "orientation", void 0);
|
81
|
+
__decorate([
|
82
|
+
property({ type: String, reflect: true }),
|
83
|
+
__metadata("design:type", String)
|
84
|
+
], Stepper.prototype, "variant", void 0);
|
85
|
+
export default Stepper;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import utils from '../../utils/tag-name';
|
2
|
+
import { ORIENTATION } from '../stepperconnector/stepperconnector.constants';
|
3
|
+
import { VARIANT } from '../stepperitem/stepperitem.constants';
|
4
|
+
const TAG_NAME = utils.constructTagName('stepper');
|
5
|
+
const DEFAULTS = {
|
6
|
+
ORIENTATION: ORIENTATION.HORIZONTAL,
|
7
|
+
VARIANT: VARIANT.INLINE,
|
8
|
+
};
|
9
|
+
export { TAG_NAME, DEFAULTS };
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import type { OrientationType } from '../stepperconnector/stepperconnector.types';
|
2
|
+
import type { VariantType } from '../stepperitem/stepperitem.types';
|
3
|
+
declare class StepperContext {
|
4
|
+
orientation?: OrientationType;
|
5
|
+
variant?: VariantType;
|
6
|
+
static context: {
|
7
|
+
__context__: StepperContext;
|
8
|
+
};
|
9
|
+
constructor(defaultOrientation?: OrientationType, defaultVariant?: VariantType);
|
10
|
+
}
|
11
|
+
export default StepperContext;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { createContext } from '@lit/context';
|
2
|
+
import { TAG_NAME } from './stepper.constants';
|
3
|
+
class StepperContext {
|
4
|
+
constructor(defaultOrientation, defaultVariant) {
|
5
|
+
this.orientation = defaultOrientation;
|
6
|
+
this.variant = defaultVariant;
|
7
|
+
}
|
8
|
+
}
|
9
|
+
StepperContext.context = createContext(TAG_NAME);
|
10
|
+
export default StepperContext;
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { css } from 'lit';
|
2
|
+
import { hostFitContentStyles } from '../../utils/styles';
|
3
|
+
const styles = css `
|
4
|
+
:host {
|
5
|
+
gap: 0.5rem;
|
6
|
+
}
|
7
|
+
|
8
|
+
::slotted(mdc-stepperitem) {
|
9
|
+
flex-shrink: 0;
|
10
|
+
}
|
11
|
+
|
12
|
+
:host([orientation='horizontal']) {
|
13
|
+
width: 100%;
|
14
|
+
}
|
15
|
+
|
16
|
+
:host([orientation='vertical']) {
|
17
|
+
flex-direction: column;
|
18
|
+
height: 100%;
|
19
|
+
}
|
20
|
+
|
21
|
+
:host([orientation='vertical'][variant='inline']),
|
22
|
+
:host([orientation='horizontal'][variant='stacked']) {
|
23
|
+
align-items: flex-start;
|
24
|
+
}
|
25
|
+
|
26
|
+
:host([orientation='vertical'][variant='stacked']) ::slotted(mdc-stepperconnector) {
|
27
|
+
display: flex;
|
28
|
+
justify-content: center;
|
29
|
+
}
|
30
|
+
|
31
|
+
:host([orientation='vertical'][variant='inline']) ::slotted(mdc-stepperconnector) {
|
32
|
+
display: flex;
|
33
|
+
padding-left: 0.875rem;
|
34
|
+
}
|
35
|
+
|
36
|
+
:host([orientation='horizontal'][variant='stacked']) ::slotted(mdc-stepperconnector) {
|
37
|
+
padding-top: 0.9375rem;
|
38
|
+
margin: 0 -3rem;
|
39
|
+
}
|
40
|
+
`;
|
41
|
+
export default [hostFitContentStyles, styles];
|
@@ -24,6 +24,10 @@ declare class StepperConnector extends Component {
|
|
24
24
|
* @default "horizontal"
|
25
25
|
*/
|
26
26
|
orientation: OrientationType;
|
27
|
+
/**
|
28
|
+
* @internal
|
29
|
+
*/
|
30
|
+
private readonly stepperContext;
|
27
31
|
updated(changedProperties: Map<string, unknown>): void;
|
28
32
|
render(): import("lit-html").TemplateResult<1>;
|
29
33
|
static styles: Array<CSSResult>;
|
@@ -10,6 +10,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
10
10
|
import { html } from 'lit';
|
11
11
|
import { property } from 'lit/decorators.js';
|
12
12
|
import { Component } from '../../models';
|
13
|
+
import providerUtils from '../../utils/provider';
|
14
|
+
import Stepper from '../stepper/stepper.component';
|
13
15
|
import { DEFAULTS } from './stepperconnector.constants';
|
14
16
|
import styles from './stepperconnector.styles';
|
15
17
|
/**
|
@@ -37,12 +39,21 @@ class StepperConnector extends Component {
|
|
37
39
|
* @default "horizontal"
|
38
40
|
*/
|
39
41
|
this.orientation = DEFAULTS.ORIENTATION;
|
42
|
+
/**
|
43
|
+
* @internal
|
44
|
+
*/
|
45
|
+
this.stepperContext = providerUtils.consume({ host: this, context: Stepper.Context });
|
40
46
|
}
|
41
47
|
updated(changedProperties) {
|
48
|
+
var _a;
|
42
49
|
super.updated(changedProperties);
|
43
50
|
if (changedProperties.has('orientation')) {
|
44
51
|
this.ariaOrientation = this.orientation;
|
45
52
|
}
|
53
|
+
const context = (_a = this.stepperContext) === null || _a === void 0 ? void 0 : _a.value;
|
54
|
+
if (!context || !context.orientation)
|
55
|
+
return;
|
56
|
+
this.orientation = context.orientation;
|
46
57
|
}
|
47
58
|
render() {
|
48
59
|
return html ` <div part="connector"></div> `;
|
@@ -63,6 +63,11 @@ declare class StepperItem extends StepperItem_base {
|
|
63
63
|
* @default ''
|
64
64
|
*/
|
65
65
|
stepNumber?: number;
|
66
|
+
/**
|
67
|
+
* @internal
|
68
|
+
*/
|
69
|
+
private readonly stepperContext;
|
70
|
+
updated(changedProperties: Map<string, unknown>): void;
|
66
71
|
connectedCallback(): void;
|
67
72
|
constructor();
|
68
73
|
/**
|
@@ -14,6 +14,8 @@ import { TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
|
|
14
14
|
import { TabIndexMixin } from '../../utils/mixins/TabIndexMixin';
|
15
15
|
import { ROLE } from '../../utils/roles';
|
16
16
|
import { KEYS } from '../../utils/keys';
|
17
|
+
import providerUtils from '../../utils/provider';
|
18
|
+
import Stepper from '../stepper/stepper.component';
|
17
19
|
import styles from './stepperitem.styles';
|
18
20
|
import { DEFAULT, STATUS, STATUS_ICON } from './stepperitem.constants';
|
19
21
|
/**
|
@@ -49,6 +51,14 @@ import { DEFAULT, STATUS, STATUS_ICON } from './stepperitem.constants';
|
|
49
51
|
* @cssproperty --mdc-stepperitem-label-container-background - The background color of the label container.
|
50
52
|
*/
|
51
53
|
class StepperItem extends TabIndexMixin(Component) {
|
54
|
+
updated(changedProperties) {
|
55
|
+
var _a;
|
56
|
+
super.updated(changedProperties);
|
57
|
+
const context = (_a = this.stepperContext) === null || _a === void 0 ? void 0 : _a.value;
|
58
|
+
if (!context || !context.variant)
|
59
|
+
return;
|
60
|
+
this.variant = context.variant;
|
61
|
+
}
|
52
62
|
connectedCallback() {
|
53
63
|
super.connectedCallback();
|
54
64
|
this.role = ROLE.LISTITEM;
|
@@ -71,6 +81,10 @@ class StepperItem extends TabIndexMixin(Component) {
|
|
71
81
|
* @default ''
|
72
82
|
*/
|
73
83
|
this.label = '';
|
84
|
+
/**
|
85
|
+
* @internal
|
86
|
+
*/
|
87
|
+
this.stepperContext = providerUtils.consume({ host: this, context: Stepper.Context });
|
74
88
|
this.addEventListener('keydown', this.handleKeyDown.bind(this));
|
75
89
|
this.addEventListener('keyup', this.handleKeyUp.bind(this));
|
76
90
|
}
|
@@ -47,8 +47,10 @@ const styles = css `
|
|
47
47
|
}
|
48
48
|
|
49
49
|
:host([variant='stacked'])::part(label-container) {
|
50
|
-
|
50
|
+
width: 8.75rem;
|
51
|
+
padding: 0.25rem 0;
|
51
52
|
}
|
53
|
+
|
52
54
|
:host([variant='stacked'])::part(label),
|
53
55
|
:host([variant='stacked'])::part(help-text) {
|
54
56
|
overflow: hidden;
|
@@ -66,6 +68,7 @@ const styles = css `
|
|
66
68
|
:host([status='error-incomplete'])::part(help-text-container) {
|
67
69
|
display: flex;
|
68
70
|
align-items: center;
|
71
|
+
justify-content: center;
|
69
72
|
gap: 0.25rem;
|
70
73
|
}
|
71
74
|
|
@@ -91,6 +94,7 @@ const styles = css `
|
|
91
94
|
:host([status='error-current'])::part(help-icon),
|
92
95
|
:host([status='error-incomplete'])::part(help-icon) {
|
93
96
|
--mdc-icon-fill-color: var(--mds-color-theme-text-error-normal);
|
97
|
+
flex-shrink: 0;
|
94
98
|
}
|
95
99
|
|
96
100
|
:host(:hover) {
|