@momentum-design/components 0.4.13 → 0.4.15
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 +86 -31
- package/dist/browser/index.js.map +4 -4
- package/dist/components/avatar/avatar.component.js +38 -32
- package/dist/components/avatar/avatar.constants.js +3 -9
- package/dist/components/avatar/avatar.styles.js +3 -5
- package/dist/components/avatar/avatar.types.js +1 -2
- package/dist/components/avatar/index.js +4 -7
- package/dist/components/badge/badge.component.d.ts +74 -29
- package/dist/components/badge/badge.component.js +182 -88
- package/dist/components/badge/badge.constants.d.ts +28 -4
- package/dist/components/badge/badge.constants.js +30 -12
- package/dist/components/badge/badge.styles.js +59 -19
- package/dist/components/badge/index.d.ts +2 -0
- package/dist/components/badge/index.js +6 -7
- package/dist/components/icon/icon.component.js +46 -40
- package/dist/components/icon/icon.constants.js +3 -8
- package/dist/components/icon/icon.styles.js +5 -7
- package/dist/components/icon/icon.utils.js +1 -4
- package/dist/components/icon/index.js +4 -7
- package/dist/components/iconprovider/iconprovider.component.js +39 -33
- package/dist/components/iconprovider/iconprovider.constants.js +3 -10
- package/dist/components/iconprovider/iconprovider.context.js +4 -6
- package/dist/components/iconprovider/index.js +4 -7
- package/dist/components/text/fonts.styles.js +2 -5
- package/dist/components/text/index.js +4 -7
- package/dist/components/text/text.component.js +35 -29
- package/dist/components/text/text.constants.js +3 -9
- package/dist/components/text/text.styles.js +5 -7
- package/dist/components/text/text.types.js +1 -2
- package/dist/components/themeprovider/index.js +4 -7
- package/dist/components/themeprovider/themeprovider.component.js +27 -21
- package/dist/components/themeprovider/themeprovider.constants.js +3 -8
- package/dist/components/themeprovider/themeprovider.context.js +4 -6
- package/dist/components/themeprovider/themeprovider.styles.js +3 -5
- package/dist/custom-elements.json +230 -51
- package/dist/index.js +7 -16
- package/dist/models/component/component.component.js +5 -8
- package/dist/models/component/component.styles.js +2 -4
- package/dist/models/component/component.types.js +1 -2
- package/dist/models/component/index.js +2 -5
- package/dist/models/index.js +3 -8
- package/dist/models/provider/index.js +2 -5
- package/dist/models/provider/provider.component.js +9 -12
- package/dist/models/provider/provider.styles.js +3 -5
- package/dist/react/avatar/index.js +8 -11
- package/dist/react/badge/index.d.ts +6 -3
- package/dist/react/badge/index.js +14 -14
- package/dist/react/icon/index.js +8 -11
- package/dist/react/iconprovider/index.js +8 -11
- package/dist/react/index.js +6 -18
- package/dist/react/text/index.js +8 -11
- package/dist/react/themeprovider/index.js +8 -11
- package/dist/utils/mixins/DisabledMixin.js +14 -10
- package/dist/utils/mixins/TabIndexMixin.js +14 -10
- package/dist/utils/provider/index.js +3 -5
- package/dist/utils/styles/index.js +4 -8
- package/dist/utils/tag-name/constants.js +1 -3
- package/dist/utils/tag-name/index.js +3 -6
- package/dist/utils/types.js +1 -2
- package/package.json +1 -1
- package/dist/components/badge/badge.types.d.ts +0 -1
- package/dist/components/badge/badge.types.js +0 -2
@@ -1,11 +1,17 @@
|
|
1
|
-
|
2
|
-
Object.
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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 styles from './text.styles';
|
13
|
+
import { Component } from '../../models';
|
14
|
+
import { DEFAULTS } from './text.constants';
|
9
15
|
/**
|
10
16
|
* Text component for creating styled text elements.
|
11
17
|
* It has to be mounted within the ThemeProvider to access color and font tokens.
|
@@ -24,7 +30,7 @@ const text_constants_1 = require("./text.constants");
|
|
24
30
|
*
|
25
31
|
* @csspart text - The text element
|
26
32
|
*/
|
27
|
-
class Text extends
|
33
|
+
class Text extends Component {
|
28
34
|
constructor() {
|
29
35
|
super(...arguments);
|
30
36
|
/**
|
@@ -62,7 +68,7 @@ class Text extends models_1.Component {
|
|
62
68
|
* - 'headline-small-light'
|
63
69
|
* - 'headline-small-regular'
|
64
70
|
*/
|
65
|
-
this.type =
|
71
|
+
this.type = DEFAULTS.TYPE;
|
66
72
|
/**
|
67
73
|
* Specifies the HTML tag name for the text element. The default tag name is `p`.
|
68
74
|
* This attribute is optional. When set, it changes the tag name of the text element.
|
@@ -83,33 +89,33 @@ class Text extends models_1.Component {
|
|
83
89
|
* For instance, setting this attribute to `h2` will render the text element as an `h2` element.
|
84
90
|
* Note that the styling is determined by the `type` attribute.
|
85
91
|
*/
|
86
|
-
this.tagname =
|
92
|
+
this.tagname = DEFAULTS.TEXT_ELEMENT_TAGNAME;
|
87
93
|
}
|
88
94
|
render() {
|
89
95
|
// Lit does not support dynamically changing values for the tag name of a custom element.
|
90
96
|
// Read more: https://lit.dev/docs/templates/expressions/#invalid-locations
|
91
97
|
switch (this.tagname) {
|
92
|
-
case 'h1': return
|
93
|
-
case 'h2': return
|
94
|
-
case 'h3': return
|
95
|
-
case 'h4': return
|
96
|
-
case 'h5': return
|
97
|
-
case 'h6': return
|
98
|
-
case 'div': return
|
99
|
-
case 'span': return
|
100
|
-
case 'small': return
|
98
|
+
case 'h1': return html `<h1 part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></h1>`;
|
99
|
+
case 'h2': return html `<h2 part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></h2>`;
|
100
|
+
case 'h3': return html `<h3 part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></h3>`;
|
101
|
+
case 'h4': return html `<h4 part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></h4>`;
|
102
|
+
case 'h5': return html `<h5 part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></h5>`;
|
103
|
+
case 'h6': return html `<h6 part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></h6>`;
|
104
|
+
case 'div': return html `<div part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></div>`;
|
105
|
+
case 'span': return html `<span part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></span>`;
|
106
|
+
case 'small': return html `<small part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></small>`;
|
101
107
|
case 'p':
|
102
|
-
default: return
|
108
|
+
default: return html `<p part=${DEFAULTS.CSS_PART_TEXT}><slot></slot></p>`;
|
103
109
|
}
|
104
110
|
}
|
105
111
|
}
|
106
|
-
Text.styles = [...
|
107
|
-
|
108
|
-
|
109
|
-
|
112
|
+
Text.styles = [...Component.styles, ...styles];
|
113
|
+
__decorate([
|
114
|
+
property({ attribute: 'type', reflect: true, type: String }),
|
115
|
+
__metadata("design:type", String)
|
110
116
|
], Text.prototype, "type", void 0);
|
111
|
-
|
112
|
-
|
113
|
-
|
117
|
+
__decorate([
|
118
|
+
property({ attribute: 'tagname', reflect: true, type: String }),
|
119
|
+
__metadata("design:type", String)
|
114
120
|
], Text.prototype, "tagname", void 0);
|
115
|
-
|
121
|
+
export default Text;
|
@@ -1,10 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
exports.VALUES = exports.DEFAULTS = exports.TAG_NAME = void 0;
|
4
|
-
const tslib_1 = require("tslib");
|
5
|
-
const tag_name_1 = tslib_1.__importDefault(require("../../utils/tag-name"));
|
6
|
-
const TAG_NAME = tag_name_1.default.constructTagName('text');
|
7
|
-
exports.TAG_NAME = TAG_NAME;
|
1
|
+
import utils from '../../utils/tag-name';
|
2
|
+
const TAG_NAME = utils.constructTagName('text');
|
8
3
|
const VALUES = {
|
9
4
|
TYPE: [
|
10
5
|
'body-small-regular',
|
@@ -50,10 +45,9 @@ const VALUES = {
|
|
50
45
|
'div',
|
51
46
|
],
|
52
47
|
};
|
53
|
-
exports.VALUES = VALUES;
|
54
48
|
const DEFAULTS = {
|
55
49
|
TYPE: 'body-midsize-regular',
|
56
50
|
TEXT_ELEMENT_TAGNAME: 'p',
|
57
51
|
CSS_PART_TEXT: 'text',
|
58
52
|
};
|
59
|
-
|
53
|
+
export { TAG_NAME, DEFAULTS, VALUES };
|
@@ -1,9 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
const lit_1 = require("lit");
|
4
|
-
const fonts_styles_1 = require("./fonts.styles");
|
1
|
+
import { css } from 'lit';
|
2
|
+
import { fontsStyles } from './fonts.styles';
|
5
3
|
const styles = [
|
6
|
-
|
4
|
+
css `
|
7
5
|
:host {
|
8
6
|
--mdc-text-font-family: var(--mdc-themeprovider-font-family);
|
9
7
|
|
@@ -12,6 +10,6 @@ const styles = [
|
|
12
10
|
}
|
13
11
|
`,
|
14
12
|
// type specific font styles:
|
15
|
-
|
13
|
+
fontsStyles,
|
16
14
|
];
|
17
|
-
|
15
|
+
export default styles;
|
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
1
|
+
export {};
|
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
const themeprovider_constants_1 = require("./themeprovider.constants");
|
6
|
-
themeprovider_component_1.default.register(themeprovider_constants_1.TAG_NAME);
|
7
|
-
exports.default = themeprovider_component_1.default;
|
1
|
+
import ThemeProvider from './themeprovider.component';
|
2
|
+
import { TAG_NAME } from './themeprovider.constants';
|
3
|
+
ThemeProvider.register(TAG_NAME);
|
4
|
+
export default ThemeProvider;
|
@@ -1,11 +1,17 @@
|
|
1
|
-
|
2
|
-
Object.
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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 { property, state } from 'lit/decorators.js';
|
11
|
+
import { DEFAULTS } from './themeprovider.constants';
|
12
|
+
import { Provider } from '../../models';
|
13
|
+
import ThemeProviderContext from './themeprovider.context';
|
14
|
+
import styles from './themeprovider.styles';
|
9
15
|
/**
|
10
16
|
* ThemeProvider component, which sets the passed in themeclass as class.
|
11
17
|
* If the themeclass switches, the existing themeclass will be removed as a class
|
@@ -30,11 +36,11 @@ const themeprovider_styles_1 = tslib_1.__importDefault(require("./themeprovider.
|
|
30
36
|
* @cssproperty --mdc-themeprovider-letter-spacing-adjustment - Option to override the default letter-spacing,
|
31
37
|
* default: `-0.25px` (this is to match the old CiscoSans)
|
32
38
|
*/
|
33
|
-
class ThemeProvider extends
|
39
|
+
class ThemeProvider extends Provider {
|
34
40
|
constructor() {
|
35
41
|
super({
|
36
|
-
context:
|
37
|
-
initialValue: new
|
42
|
+
context: ThemeProviderContext.context,
|
43
|
+
initialValue: new ThemeProviderContext(DEFAULTS.THEMECLASS),
|
38
44
|
});
|
39
45
|
/**
|
40
46
|
* Current theme class
|
@@ -45,13 +51,13 @@ class ThemeProvider extends models_1.Provider {
|
|
45
51
|
*
|
46
52
|
* Default: 'mds-theme-stable-darkWebex'
|
47
53
|
*/
|
48
|
-
this.themeclass =
|
54
|
+
this.themeclass = DEFAULTS.THEMECLASS;
|
49
55
|
}
|
50
56
|
/**
|
51
57
|
* Context object of the ThemeProvider, to be consumed by child components
|
52
58
|
*/
|
53
59
|
static get Context() {
|
54
|
-
return
|
60
|
+
return ThemeProviderContext.context;
|
55
61
|
}
|
56
62
|
updated(changedProperties) {
|
57
63
|
super.updated(changedProperties);
|
@@ -87,13 +93,13 @@ class ThemeProvider extends models_1.Provider {
|
|
87
93
|
}
|
88
94
|
}
|
89
95
|
}
|
90
|
-
ThemeProvider.styles = [...
|
91
|
-
|
92
|
-
|
93
|
-
|
96
|
+
ThemeProvider.styles = [...Provider.styles, ...styles];
|
97
|
+
__decorate([
|
98
|
+
state(),
|
99
|
+
__metadata("design:type", String)
|
94
100
|
], ThemeProvider.prototype, "currentThemeClass", void 0);
|
95
|
-
|
96
|
-
|
97
|
-
|
101
|
+
__decorate([
|
102
|
+
property({ type: String }),
|
103
|
+
__metadata("design:type", String)
|
98
104
|
], ThemeProvider.prototype, "themeclass", void 0);
|
99
|
-
|
105
|
+
export default ThemeProvider;
|
@@ -1,12 +1,7 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.TAG_NAME = exports.DEFAULTS = void 0;
|
4
|
-
const tslib_1 = require("tslib");
|
5
1
|
/* eslint-disable implicit-arrow-linebreak */
|
6
|
-
|
7
|
-
const TAG_NAME =
|
8
|
-
exports.TAG_NAME = TAG_NAME;
|
2
|
+
import utils from '../../utils/tag-name';
|
3
|
+
const TAG_NAME = utils.constructTagName('themeprovider');
|
9
4
|
const DEFAULTS = {
|
10
5
|
THEMECLASS: 'mds-theme-stable-darkWebex',
|
11
6
|
};
|
12
|
-
|
7
|
+
export { DEFAULTS, TAG_NAME };
|
@@ -1,7 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
const context_1 = require("@lit/context");
|
4
|
-
const themeprovider_constants_1 = require("./themeprovider.constants");
|
1
|
+
import { createContext } from '@lit/context';
|
2
|
+
import { TAG_NAME } from './themeprovider.constants';
|
5
3
|
class ThemeProviderContext {
|
6
4
|
// constructor to allow setting the defaultThemeClass
|
7
5
|
constructor(defaultThemeClass) {
|
@@ -9,5 +7,5 @@ class ThemeProviderContext {
|
|
9
7
|
}
|
10
8
|
}
|
11
9
|
// create typed lit context as part of the ThemeProviderContext
|
12
|
-
ThemeProviderContext.context =
|
13
|
-
|
10
|
+
ThemeProviderContext.context = createContext(TAG_NAME);
|
11
|
+
export default ThemeProviderContext;
|
@@ -1,7 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
const lit_1 = require("lit");
|
4
|
-
const styles = (0, lit_1.css) `
|
1
|
+
import { css } from 'lit';
|
2
|
+
const styles = css `
|
5
3
|
:host {
|
6
4
|
--mdc-themeprovider-color-default: var(--mds-color-theme-text-primary-normal);
|
7
5
|
--mdc-themeprovider-font-family: var(--mds-font-family-primary);
|
@@ -15,4 +13,4 @@ const styles = (0, lit_1.css) `
|
|
15
13
|
letter-spacing: var(--mdc-themeprovider-letter-spacing-adjustment);
|
16
14
|
}
|
17
15
|
`;
|
18
|
-
|
16
|
+
export default [styles];
|