@momentum-design/components 0.0.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/.eslintrc.js +16 -0
- package/CONTRIBUTING.md +5 -0
- package/README.md +39 -0
- package/SCRIPTS.md +15 -0
- package/TESTING.md +38 -0
- package/config/api-extractor.json +33 -0
- package/config/custom-elements-manifest.config.js +28 -0
- package/config/esbuild/configs/browser.js +21 -0
- package/config/esbuild/configs/e2e.js +10 -0
- package/config/esbuild/esbuild-e2e.config.js +22 -0
- package/config/esbuild/esbuild.config.js +9 -0
- package/config/playwright/playwright.config.ts +107 -0
- package/config/playwright/public/index.css +43 -0
- package/config/playwright/public/index.html +26 -0
- package/config/playwright/setup/Components.page.ts +163 -0
- package/config/playwright/setup/constants.ts +27 -0
- package/config/playwright/setup/index.ts +42 -0
- package/config/playwright/setup/steps/accessibility.ts +9 -0
- package/config/playwright/setup/types.ts +5 -0
- package/config/playwright/setup/utils/accessibility.ts +70 -0
- package/config/playwright/setup/utils/visual-regression.ts +35 -0
- package/config/plop/actions/AddComponent.ts +21 -0
- package/config/plop/actions/AddToComponentExports.ts +16 -0
- package/config/plop/actions/AddToComponentImports.ts +16 -0
- package/config/plop/constants/index.ts +31 -0
- package/config/plop/esbuild.config.plop.js +4 -0
- package/config/plop/generators/component/index.ts +25 -0
- package/config/plop/plopfile.ts +6 -0
- package/config/plop/prompts/index.ts +8 -0
- package/config/plop/templates/add/component/index.ts.hbs +12 -0
- package/config/plop/templates/add/component/{{componentName}}.component.ts.hbs +22 -0
- package/config/plop/templates/add/component/{{componentName}}.constants.ts.hbs +5 -0
- package/config/plop/templates/add/component/{{componentName}}.e2e-test.ts.hbs +67 -0
- package/config/plop/templates/add/component/{{componentName}}.fixtures.ts.hbs +13 -0
- package/config/plop/templates/add/component/{{componentName}}.stories.ts.hbs +18 -0
- package/config/plop/templates/add/component/{{componentName}}.styles.ts.hbs +8 -0
- package/config/plop/tsconfig.plop.json +11 -0
- package/config/storybook/MomentumStorybookTheme.js +41 -0
- package/config/storybook/main.js +21 -0
- package/config/storybook/manager.js +17 -0
- package/config/storybook/preview.js +63 -0
- package/config/storybook/provider/iconProvider.js +8 -0
- package/config/storybook/provider/themeProvider.js +31 -0
- package/config/storybook/public/background-graphic.png +0 -0
- package/config/storybook/public/fonts/Inter.var.woff2 +0 -0
- package/config/storybook/public/momentum-logo.png +0 -0
- package/config/storybook/themes/index.js +14 -0
- package/config/storybook/themes/themes.css +15 -0
- package/data/custom-elements.json +677 -0
- package/dist/browser/index.js +366 -0
- package/dist/browser/index.js.map +7 -0
- package/dist/components/avatar/avatar.component.d.ts +28 -0
- package/dist/components/avatar/avatar.component.js +79 -0
- package/dist/components/avatar/avatar.constants.d.ts +7 -0
- package/dist/components/avatar/avatar.constants.js +14 -0
- package/dist/components/avatar/avatar.styles.d.ts +2 -0
- package/dist/components/avatar/avatar.styles.js +20 -0
- package/dist/components/avatar/avatar.types.d.ts +1 -0
- package/dist/components/avatar/avatar.types.js +2 -0
- package/dist/components/avatar/index.d.ts +7 -0
- package/dist/components/avatar/index.js +7 -0
- package/dist/components/badge/badge.component.d.ts +51 -0
- package/dist/components/badge/badge.component.js +114 -0
- package/dist/components/badge/badge.constants.d.ts +8 -0
- package/dist/components/badge/badge.constants.js +15 -0
- package/dist/components/badge/badge.styles.d.ts +2 -0
- package/dist/components/badge/badge.styles.js +26 -0
- package/dist/components/badge/badge.types.d.ts +1 -0
- package/dist/components/badge/badge.types.js +2 -0
- package/dist/components/badge/index.d.ts +7 -0
- package/dist/components/badge/index.js +7 -0
- package/dist/components/icon/icon.component.d.ts +63 -0
- package/dist/components/icon/icon.component.js +158 -0
- package/dist/components/icon/icon.constants.d.ts +6 -0
- package/dist/components/icon/icon.constants.js +12 -0
- package/dist/components/icon/icon.styles.d.ts +2 -0
- package/dist/components/icon/icon.styles.js +15 -0
- package/dist/components/icon/icon.utils.d.ts +2 -0
- package/dist/components/icon/icon.utils.js +13 -0
- package/dist/components/icon/index.d.ts +7 -0
- package/dist/components/icon/index.js +7 -0
- package/dist/components/iconprovider/iconprovider.component.d.ts +34 -0
- package/dist/components/iconprovider/iconprovider.component.js +71 -0
- package/dist/components/iconprovider/iconprovider.constants.d.ts +7 -0
- package/dist/components/iconprovider/iconprovider.constants.js +14 -0
- package/dist/components/iconprovider/iconprovider.context.d.ts +9 -0
- package/dist/components/iconprovider/iconprovider.context.js +9 -0
- package/dist/components/iconprovider/index.d.ts +7 -0
- package/dist/components/iconprovider/index.js +7 -0
- package/dist/components/text/fonts.styles.d.ts +1 -0
- package/dist/components/text/fonts.styles.js +100 -0
- package/dist/components/text/index.d.ts +7 -0
- package/dist/components/text/index.js +7 -0
- package/dist/components/text/text.component.d.ts +29 -0
- package/dist/components/text/text.component.js +41 -0
- package/dist/components/text/text.constants.d.ts +9 -0
- package/dist/components/text/text.constants.js +28 -0
- package/dist/components/text/text.styles.d.ts +2 -0
- package/dist/components/text/text.styles.js +17 -0
- package/dist/components/text/text.types.d.ts +1 -0
- package/dist/components/text/text.types.js +2 -0
- package/dist/components/text/text.utils.d.ts +20 -0
- package/dist/components/text/text.utils.js +50 -0
- package/dist/components/themeprovider/index.d.ts +7 -0
- package/dist/components/themeprovider/index.js +7 -0
- package/dist/components/themeprovider/themeprovider.component.d.ts +48 -0
- package/dist/components/themeprovider/themeprovider.component.js +86 -0
- package/dist/components/themeprovider/themeprovider.constants.d.ts +10 -0
- package/dist/components/themeprovider/themeprovider.constants.js +31 -0
- package/dist/components/themeprovider/themeprovider.context.d.ts +9 -0
- package/dist/components/themeprovider/themeprovider.context.js +13 -0
- package/dist/components/themeprovider/themeprovider.styles.d.ts +2 -0
- package/dist/components/themeprovider/themeprovider.styles.js +13 -0
- package/dist/components/themeprovider/themeprovider.types.d.ts +5 -0
- package/dist/components/themeprovider/themeprovider.types.js +2 -0
- package/dist/components/themeprovider/themeprovider.utils.d.ts +9 -0
- package/dist/components/themeprovider/themeprovider.utils.js +10 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +19 -0
- package/dist/models/component/component.component.d.ts +38 -0
- package/dist/models/component/component.component.js +45 -0
- package/dist/models/component/component.types.d.ts +15 -0
- package/dist/models/component/component.types.js +2 -0
- package/dist/models/component/index.d.ts +3 -0
- package/dist/models/component/index.js +5 -0
- package/dist/models/index.d.ts +4 -0
- package/dist/models/index.js +8 -0
- package/dist/models/provider/index.d.ts +2 -0
- package/dist/models/provider/index.js +5 -0
- package/dist/models/provider/provider.component.d.ts +70 -0
- package/dist/models/provider/provider.component.js +56 -0
- package/dist/models/provider/provider.styles.d.ts +2 -0
- package/dist/models/provider/provider.styles.js +14 -0
- package/dist/utils/provider/index.d.ts +13 -0
- package/dist/utils/provider/index.js +14 -0
- package/dist/utils/styles/index.d.ts +2 -0
- package/dist/utils/styles/index.js +14 -0
- package/dist/utils/tag-name/constants.d.ts +7 -0
- package/dist/utils/tag-name/constants.js +10 -0
- package/dist/utils/tag-name/index.d.ts +4 -0
- package/dist/utils/tag-name/index.js +10 -0
- package/dist/utils/types.d.ts +1 -0
- package/dist/utils/types.js +2 -0
- package/jest.config.js +3 -0
- package/package.json +78 -0
- package/scripts/copyFonts.js +31 -0
- package/scripts/copyIcons.js +31 -0
- package/scripts/copyTokens.js +24 -0
- package/src/components/avatar/__screenshots__/mdc-avatar.png +0 -0
- package/src/components/avatar/avatar.component.ts +74 -0
- package/src/components/avatar/avatar.constants.ts +12 -0
- package/src/components/avatar/avatar.e2e-test.ts +70 -0
- package/src/components/avatar/avatar.stories.ts +25 -0
- package/src/components/avatar/avatar.styles.ts +20 -0
- package/src/components/avatar/avatar.types.ts +1 -0
- package/src/components/avatar/index.ts +12 -0
- package/src/components/badge/__screenshots__/mdc-badge.png +0 -0
- package/src/components/badge/badge.component.ts +121 -0
- package/src/components/badge/badge.constants.ts +13 -0
- package/src/components/badge/badge.e2e-test.ts +68 -0
- package/src/components/badge/badge.stories.ts +33 -0
- package/src/components/badge/badge.styles.ts +26 -0
- package/src/components/badge/badge.types.ts +1 -0
- package/src/components/badge/index.ts +12 -0
- package/src/components/icon/__screenshots__/mdc-icon-default.png +0 -0
- package/src/components/icon/__screenshots__/mdc-icon-scale.png +0 -0
- package/src/components/icon/icon.component.ts +155 -0
- package/src/components/icon/icon.constants.ts +10 -0
- package/src/components/icon/icon.e2e-test.ts +101 -0
- package/src/components/icon/icon.stories.ts +34 -0
- package/src/components/icon/icon.styles.ts +15 -0
- package/src/components/icon/icon.utils.ts +13 -0
- package/src/components/icon/index.ts +12 -0
- package/src/components/iconprovider/__screenshots__/mdc-iconprovider.png +0 -0
- package/src/components/iconprovider/iconprovider.component.ts +76 -0
- package/src/components/iconprovider/iconprovider.constants.ts +12 -0
- package/src/components/iconprovider/iconprovider.context.ts +16 -0
- package/src/components/iconprovider/iconprovider.e2e-test.ts +65 -0
- package/src/components/iconprovider/iconprovider.stories.ts +27 -0
- package/src/components/iconprovider/iconprovider.stories.utils.ts +27 -0
- package/src/components/iconprovider/index.ts +12 -0
- package/src/components/text/__screenshots__/mdc-text-body-large.png +0 -0
- package/src/components/text/__screenshots__/mdc-text-body-regular.png +0 -0
- package/src/components/text/__screenshots__/mdc-text-body-small.png +0 -0
- package/src/components/text/__screenshots__/mdc-text-heading-1.png +0 -0
- package/src/components/text/__screenshots__/mdc-text-heading-2.png +0 -0
- package/src/components/text/__screenshots__/mdc-text-heading-3.png +0 -0
- package/src/components/text/__screenshots__/mdc-text-heading-4.png +0 -0
- package/src/components/text/__screenshots__/mdc-text-heading-5.png +0 -0
- package/src/components/text/__screenshots__/mdc-text-heading-6.png +0 -0
- package/src/components/text/__screenshots__/mdc-text-heading-7.png +0 -0
- package/src/components/text/__screenshots__/mdc-text-image-title.png +0 -0
- package/src/components/text/__screenshots__/mdc-text-label.png +0 -0
- package/src/components/text/fonts.styles.ts +99 -0
- package/src/components/text/index.ts +12 -0
- package/src/components/text/text.component.ts +51 -0
- package/src/components/text/text.constants.ts +27 -0
- package/src/components/text/text.e2e-test.ts +76 -0
- package/src/components/text/text.stories.ts +29 -0
- package/src/components/text/text.styles.ts +17 -0
- package/src/components/text/text.types.ts +13 -0
- package/src/components/text/text.utils.ts +51 -0
- package/src/components/themeprovider/__screenshots__/mdc-themeprovider-darkWebex.png +0 -0
- package/src/components/themeprovider/__screenshots__/mdc-themeprovider-lightWebex.png +0 -0
- package/src/components/themeprovider/index.ts +12 -0
- package/src/components/themeprovider/themeprovider.component.ts +91 -0
- package/src/components/themeprovider/themeprovider.constants.ts +32 -0
- package/src/components/themeprovider/themeprovider.context.ts +18 -0
- package/src/components/themeprovider/themeprovider.e2e-test.ts +89 -0
- package/src/components/themeprovider/themeprovider.stories.styles.css +22 -0
- package/src/components/themeprovider/themeprovider.stories.ts +38 -0
- package/src/components/themeprovider/themeprovider.stories.utils.ts +23 -0
- package/src/components/themeprovider/themeprovider.styles.ts +13 -0
- package/src/components/themeprovider/themeprovider.types.ts +7 -0
- package/src/components/themeprovider/themeprovider.utils.ts +16 -0
- package/src/index.ts +22 -0
- package/src/models/component/component.component.ts +46 -0
- package/src/models/component/component.types.ts +16 -0
- package/src/models/component/index.ts +7 -0
- package/src/models/index.ts +11 -0
- package/src/models/provider/index.ts +3 -0
- package/src/models/provider/provider.component.ts +87 -0
- package/src/models/provider/provider.styles.ts +14 -0
- package/src/stories/colors.mdx +32 -0
- package/src/stories/icons.mdx +13 -0
- package/src/stories/typography.mdx +20 -0
- package/src/utils/mixins/DisabledMixin.ts +19 -0
- package/src/utils/mixins/TabIndexMixin.ts +19 -0
- package/src/utils/provider/index.ts +21 -0
- package/src/utils/styles/index.ts +13 -0
- package/src/utils/tag-name/constants.ts +10 -0
- package/src/utils/tag-name/index.ts +15 -0
- package/src/utils/types.ts +1 -0
- package/tsconfig.json +45 -0
- package/tsconfig.module.json +47 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const decorators_js_1 = require("lit/decorators.js");
|
|
5
|
+
const themeprovider_constants_1 = require("./themeprovider.constants");
|
|
6
|
+
const models_1 = require("../../models");
|
|
7
|
+
const themeprovider_context_1 = tslib_1.__importDefault(require("./themeprovider.context"));
|
|
8
|
+
const themeprovider_styles_1 = tslib_1.__importDefault(require("./themeprovider.styles"));
|
|
9
|
+
/**
|
|
10
|
+
* ThemeProvider component, which sets the theme css variables
|
|
11
|
+
* for the child dom nodes and allows to be consumed from sub components
|
|
12
|
+
* (see providerUtils.consume for how to consume)
|
|
13
|
+
*
|
|
14
|
+
* ThemeProvider also includes the different font faces available
|
|
15
|
+
* for Text components.
|
|
16
|
+
*
|
|
17
|
+
* @tag mdc-themeprovider
|
|
18
|
+
* @tagname mdc-themeprovider
|
|
19
|
+
*/
|
|
20
|
+
class ThemeProvider extends models_1.Provider {
|
|
21
|
+
constructor() {
|
|
22
|
+
// initialise the context by running the Provider constructor:
|
|
23
|
+
super({
|
|
24
|
+
context: themeprovider_context_1.default.context,
|
|
25
|
+
initialValue: new themeprovider_context_1.default(themeprovider_constants_1.DEFAULTS.THEME),
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Available themes to switch to
|
|
29
|
+
*
|
|
30
|
+
* Has to be a space separated string, like className
|
|
31
|
+
* e.g.: `mds-theme-stable-darkWebex mds-theme-stable-lightWebex`
|
|
32
|
+
*/
|
|
33
|
+
this.themes = themeprovider_constants_1.THEMES.join(' ');
|
|
34
|
+
/**
|
|
35
|
+
* Current theme attribute
|
|
36
|
+
*
|
|
37
|
+
* Has to be fully qualified, such that
|
|
38
|
+
* the theme name matches the className of the respective
|
|
39
|
+
* theme stylesheet
|
|
40
|
+
*/
|
|
41
|
+
this.theme = themeprovider_constants_1.DEFAULTS.THEME;
|
|
42
|
+
}
|
|
43
|
+
static get Context() {
|
|
44
|
+
return themeprovider_context_1.default.context;
|
|
45
|
+
}
|
|
46
|
+
updated(changedProperties) {
|
|
47
|
+
super.updated(changedProperties);
|
|
48
|
+
if (changedProperties.has('theme')) {
|
|
49
|
+
this.updateActiveThemeClass();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Update all observing components of this
|
|
54
|
+
* provider to update the theme
|
|
55
|
+
*/
|
|
56
|
+
updateContext() {
|
|
57
|
+
let shouldUpdateConsumers = false;
|
|
58
|
+
if (this.context.value.theme !== this.theme) {
|
|
59
|
+
this.context.value.theme = this.theme;
|
|
60
|
+
shouldUpdateConsumers = true;
|
|
61
|
+
}
|
|
62
|
+
if (shouldUpdateConsumers) {
|
|
63
|
+
this.context.updateObservers();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Function to update the active theme classname to update the theme tokens
|
|
68
|
+
* as CSS variables on the web component.
|
|
69
|
+
*/
|
|
70
|
+
updateActiveThemeClass() {
|
|
71
|
+
// remove all existing theme classes from the classList:
|
|
72
|
+
this.classList.remove(...this.themes.split(' '));
|
|
73
|
+
// add current theme class to classList:
|
|
74
|
+
this.classList.add(this.theme);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
ThemeProvider.styles = themeprovider_styles_1.default;
|
|
78
|
+
tslib_1.__decorate([
|
|
79
|
+
(0, decorators_js_1.property)({ type: String }),
|
|
80
|
+
tslib_1.__metadata("design:type", String)
|
|
81
|
+
], ThemeProvider.prototype, "themes", void 0);
|
|
82
|
+
tslib_1.__decorate([
|
|
83
|
+
(0, decorators_js_1.property)({ type: String }),
|
|
84
|
+
tslib_1.__metadata("design:type", String)
|
|
85
|
+
], ThemeProvider.prototype, "theme", void 0);
|
|
86
|
+
exports.default = ThemeProvider;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const TAG_NAME: "mdc-themeprovider";
|
|
2
|
+
declare const THEME_NAMES: {
|
|
3
|
+
DARK_WEBEX: "darkWebex";
|
|
4
|
+
LIGHT_WEBEX: "lightWebex";
|
|
5
|
+
};
|
|
6
|
+
declare const THEMES: ("mds-theme-stable-darkWebex" | "mds-theme-stable-lightWebex")[];
|
|
7
|
+
declare const DEFAULTS: {
|
|
8
|
+
THEME: "mds-theme-stable-darkWebex";
|
|
9
|
+
};
|
|
10
|
+
export { DEFAULTS, THEME_NAMES, THEMES, TAG_NAME };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TAG_NAME = exports.THEMES = exports.THEME_NAMES = exports.DEFAULTS = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
/* eslint-disable implicit-arrow-linebreak */
|
|
6
|
+
const tag_name_1 = tslib_1.__importDefault(require("../../utils/tag-name"));
|
|
7
|
+
const themeprovider_utils_1 = tslib_1.__importDefault(require("./themeprovider.utils"));
|
|
8
|
+
const TAG_NAME = tag_name_1.default.constructTagName('themeprovider');
|
|
9
|
+
exports.TAG_NAME = TAG_NAME;
|
|
10
|
+
// Some themes are disabled until tokens are available for those themes
|
|
11
|
+
const THEME_NAMES = {
|
|
12
|
+
// DARK_BRONZE: 'darkBronze' as const,
|
|
13
|
+
// DARK_INDIGO: 'darkIndigo' as const,
|
|
14
|
+
// DARK_JADE: 'darkJade' as const,
|
|
15
|
+
// DARK_LAVENDER: 'darkLavender' as const,
|
|
16
|
+
// DARK_ROSE: 'darkRose' as const,
|
|
17
|
+
DARK_WEBEX: 'darkWebex',
|
|
18
|
+
// LIGHT_BRONZE: 'lightBronze' as const,
|
|
19
|
+
// LIGHT_INDIGO: 'lightIndigo' as const,
|
|
20
|
+
// LIGHT_JADE: 'lightJade' as const,
|
|
21
|
+
// LIGHT_LAVENDER: 'lightLavender' as const,
|
|
22
|
+
// LIGHT_ROSE: 'lightRose' as const,
|
|
23
|
+
LIGHT_WEBEX: 'lightWebex',
|
|
24
|
+
};
|
|
25
|
+
exports.THEME_NAMES = THEME_NAMES;
|
|
26
|
+
const THEMES = Object.values(THEME_NAMES).map((themeName) => themeprovider_utils_1.default.getFullQualifiedTheme(themeName));
|
|
27
|
+
exports.THEMES = THEMES;
|
|
28
|
+
const DEFAULTS = {
|
|
29
|
+
THEME: themeprovider_utils_1.default.getFullQualifiedTheme(THEME_NAMES.DARK_WEBEX),
|
|
30
|
+
};
|
|
31
|
+
exports.DEFAULTS = DEFAULTS;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const context_1 = require("@lit-labs/context");
|
|
4
|
+
const themeprovider_constants_1 = require("./themeprovider.constants");
|
|
5
|
+
class ThemeProviderContext {
|
|
6
|
+
// constructor to allow setting the defaultTheme
|
|
7
|
+
constructor(defaultTheme) {
|
|
8
|
+
this.theme = defaultTheme;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
// create typed lit context as part of the ThemeProviderContext
|
|
12
|
+
ThemeProviderContext.context = (0, context_1.createContext)(themeprovider_constants_1.TAG_NAME);
|
|
13
|
+
exports.default = ThemeProviderContext;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const lit_1 = require("lit");
|
|
4
|
+
const styles = (0, lit_1.css) `
|
|
5
|
+
:host {
|
|
6
|
+
--mdc-themeprovider-font-family: "Momentum";
|
|
7
|
+
--mdc-themeprovider-color-default: var(--mds-color-theme-text-primary-normal);
|
|
8
|
+
|
|
9
|
+
font-family: var(--mdc-themeprovider-font-family);
|
|
10
|
+
color: var(--mdc-themeprovider-color-default);
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
exports.default = styles;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ValueOf } from '../../utils/types';
|
|
2
|
+
import { THEME_NAMES } from './themeprovider.constants';
|
|
3
|
+
import type { ThemeClassPrefix, ThemeClassSeparator } from './themeprovider.utils';
|
|
4
|
+
export type ThemeName = ValueOf<typeof THEME_NAMES>;
|
|
5
|
+
export type Theme<T extends ThemeName = ThemeName> = `${ThemeClassPrefix}${ThemeClassSeparator}${T}`;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Theme, ThemeName } from './themeprovider.types';
|
|
2
|
+
declare const THEME_CLASS_PREFIX: "mds-theme-stable";
|
|
3
|
+
export declare const THEME_CLASS_SEPARATOR: "-";
|
|
4
|
+
declare const utils: {
|
|
5
|
+
getFullQualifiedTheme: <T extends ThemeName>(themeName: T) => Theme;
|
|
6
|
+
};
|
|
7
|
+
export default utils;
|
|
8
|
+
export type ThemeClassPrefix = typeof THEME_CLASS_PREFIX;
|
|
9
|
+
export type ThemeClassSeparator = typeof THEME_CLASS_SEPARATOR;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.THEME_CLASS_SEPARATOR = void 0;
|
|
4
|
+
const THEME_CLASS_PREFIX = 'mds-theme-stable';
|
|
5
|
+
exports.THEME_CLASS_SEPARATOR = '-';
|
|
6
|
+
const getFullQualifiedTheme = (themeName) => [THEME_CLASS_PREFIX, themeName].join(exports.THEME_CLASS_SEPARATOR);
|
|
7
|
+
const utils = {
|
|
8
|
+
getFullQualifiedTheme,
|
|
9
|
+
};
|
|
10
|
+
exports.default = utils;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Component, Provider } from './models';
|
|
2
|
+
import ThemeProvider from './components/themeprovider';
|
|
3
|
+
import Icon from './components/icon';
|
|
4
|
+
import IconProvider from './components/iconprovider';
|
|
5
|
+
import Avatar from './components/avatar';
|
|
6
|
+
import Badge from './components/badge';
|
|
7
|
+
import Text from './components/text';
|
|
8
|
+
export { Component, Provider, ThemeProvider, Icon, IconProvider, Avatar, Badge, Text, };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Text = exports.Badge = exports.Avatar = exports.IconProvider = exports.Icon = exports.ThemeProvider = exports.Provider = exports.Component = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const models_1 = require("./models");
|
|
6
|
+
Object.defineProperty(exports, "Component", { enumerable: true, get: function () { return models_1.Component; } });
|
|
7
|
+
Object.defineProperty(exports, "Provider", { enumerable: true, get: function () { return models_1.Provider; } });
|
|
8
|
+
const themeprovider_1 = tslib_1.__importDefault(require("./components/themeprovider"));
|
|
9
|
+
exports.ThemeProvider = themeprovider_1.default;
|
|
10
|
+
const icon_1 = tslib_1.__importDefault(require("./components/icon"));
|
|
11
|
+
exports.Icon = icon_1.default;
|
|
12
|
+
const iconprovider_1 = tslib_1.__importDefault(require("./components/iconprovider"));
|
|
13
|
+
exports.IconProvider = iconprovider_1.default;
|
|
14
|
+
const avatar_1 = tslib_1.__importDefault(require("./components/avatar"));
|
|
15
|
+
exports.Avatar = avatar_1.default;
|
|
16
|
+
const badge_1 = tslib_1.__importDefault(require("./components/badge"));
|
|
17
|
+
exports.Badge = badge_1.default;
|
|
18
|
+
const text_1 = tslib_1.__importDefault(require("./components/text"));
|
|
19
|
+
exports.Text = text_1.default;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* Core Component class to ultimately be inherited by all Web Components within
|
|
4
|
+
* this package.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
declare class Component extends LitElement {
|
|
9
|
+
/**
|
|
10
|
+
* Register `this` extended `Component` Class as a custom element within the
|
|
11
|
+
* DOM's custom elements registry.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* This method must be called in order for this component to be consumable
|
|
15
|
+
* within the DOM.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import CustomComponent from './custom-component';
|
|
20
|
+
*
|
|
21
|
+
* // Standard registration.
|
|
22
|
+
* CustomComponent.register();
|
|
23
|
+
*
|
|
24
|
+
* // Custom registration.
|
|
25
|
+
* CustomComponent.register({
|
|
26
|
+
* name: 'custom-component',
|
|
27
|
+
* prefix: 'prefix',
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* export default CustomComponent;
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
*
|
|
34
|
+
* @returns - Void.
|
|
35
|
+
*/
|
|
36
|
+
static register(namespace: string): void;
|
|
37
|
+
}
|
|
38
|
+
export default Component;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const lit_1 = require("lit");
|
|
4
|
+
/**
|
|
5
|
+
* Core Component class to ultimately be inherited by all Web Components within
|
|
6
|
+
* this package.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
class Component extends lit_1.LitElement {
|
|
11
|
+
/**
|
|
12
|
+
* Register `this` extended `Component` Class as a custom element within the
|
|
13
|
+
* DOM's custom elements registry.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* This method must be called in order for this component to be consumable
|
|
17
|
+
* within the DOM.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import CustomComponent from './custom-component';
|
|
22
|
+
*
|
|
23
|
+
* // Standard registration.
|
|
24
|
+
* CustomComponent.register();
|
|
25
|
+
*
|
|
26
|
+
* // Custom registration.
|
|
27
|
+
* CustomComponent.register({
|
|
28
|
+
* name: 'custom-component',
|
|
29
|
+
* prefix: 'prefix',
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* export default CustomComponent;
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
*
|
|
36
|
+
* @returns - Void.
|
|
37
|
+
*/
|
|
38
|
+
static register(namespace) {
|
|
39
|
+
if (customElements.get(namespace)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
customElements.define(namespace, this);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.default = Component;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `Component` Class' static `registration()` method options.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface RegisterOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Name to use when registering this `Component` Class' to within DOM.
|
|
9
|
+
*/
|
|
10
|
+
name: string;
|
|
11
|
+
/**
|
|
12
|
+
* Name to use when registering this `Component` Class' to within DOM.
|
|
13
|
+
*/
|
|
14
|
+
prefix?: string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Provider = exports.Component = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const component_1 = tslib_1.__importDefault(require("./component"));
|
|
6
|
+
exports.Component = component_1.default;
|
|
7
|
+
const provider_1 = tslib_1.__importDefault(require("./provider"));
|
|
8
|
+
exports.Provider = provider_1.default;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ContextProvider } from '@lit-labs/context';
|
|
2
|
+
import { CSSResult } from 'lit';
|
|
3
|
+
import Component from '../component';
|
|
4
|
+
type ConstructorOptions<C> = {
|
|
5
|
+
context: {
|
|
6
|
+
__context__: C;
|
|
7
|
+
};
|
|
8
|
+
initialValue?: C;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Provider Component class to ultimately be inherited by all Provider-type Web
|
|
12
|
+
* Components within this package.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
declare abstract class Provider<C> extends Component {
|
|
17
|
+
/**
|
|
18
|
+
* Constructor of the Provider.
|
|
19
|
+
*
|
|
20
|
+
* Execute in the constructor of the provider implementation,
|
|
21
|
+
* like so
|
|
22
|
+
*
|
|
23
|
+
* ```
|
|
24
|
+
* constructor() {
|
|
25
|
+
* super(TAG_NAME, {initialValue: new ContextClass(defaultValues)});
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
* @param host - host of where the context will be hooked onto, e.g. this
|
|
29
|
+
* @param context - context (returned by createContext)
|
|
30
|
+
* @param initialValue - initialValue of the ContextClass, like `new ContextClass(defaultValues)`
|
|
31
|
+
*/
|
|
32
|
+
constructor({ context, initialValue }: ConstructorOptions<C>);
|
|
33
|
+
/**
|
|
34
|
+
* Context associated with this provider.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* Providing a Context type as a generic when creating extended Provider Class
|
|
38
|
+
* definitions will help enforce the property validation.
|
|
39
|
+
*/
|
|
40
|
+
protected context: ContextProvider<{
|
|
41
|
+
__context__: C;
|
|
42
|
+
}>;
|
|
43
|
+
/**
|
|
44
|
+
* Styles associated with this Provider Component.
|
|
45
|
+
*/
|
|
46
|
+
static styles: CSSResult | Array<CSSResult>;
|
|
47
|
+
/**
|
|
48
|
+
* Update the context of this Provider and trigger its consumers to update.
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* This method is called every time this Provider is re-rendered and should
|
|
52
|
+
* be used to update the local Context based on any deltas between this
|
|
53
|
+
* Provider's attributes and this Provider's context that caused the
|
|
54
|
+
* re-render. If the `render()` method is overwritten, this call must be made
|
|
55
|
+
* manually.
|
|
56
|
+
*/
|
|
57
|
+
protected abstract updateContext(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Render this Provider.
|
|
60
|
+
*
|
|
61
|
+
* @remarks
|
|
62
|
+
* This method calls `updateContext()` then validates whether or not to
|
|
63
|
+
* update all consumers based on the results of the `shouldUpdateConsumers`
|
|
64
|
+
* getter.
|
|
65
|
+
*
|
|
66
|
+
* @returns - This Provider as an HTML Element.
|
|
67
|
+
*/
|
|
68
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
69
|
+
}
|
|
70
|
+
export default Provider;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const context_1 = require("@lit-labs/context");
|
|
5
|
+
const lit_1 = require("lit");
|
|
6
|
+
const component_1 = tslib_1.__importDefault(require("../component"));
|
|
7
|
+
const provider_styles_1 = tslib_1.__importDefault(require("./provider.styles"));
|
|
8
|
+
/**
|
|
9
|
+
* Provider Component class to ultimately be inherited by all Provider-type Web
|
|
10
|
+
* Components within this package.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
class Provider extends component_1.default {
|
|
15
|
+
/**
|
|
16
|
+
* Constructor of the Provider.
|
|
17
|
+
*
|
|
18
|
+
* Execute in the constructor of the provider implementation,
|
|
19
|
+
* like so
|
|
20
|
+
*
|
|
21
|
+
* ```
|
|
22
|
+
* constructor() {
|
|
23
|
+
* super(TAG_NAME, {initialValue: new ContextClass(defaultValues)});
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
* @param host - host of where the context will be hooked onto, e.g. this
|
|
27
|
+
* @param context - context (returned by createContext)
|
|
28
|
+
* @param initialValue - initialValue of the ContextClass, like `new ContextClass(defaultValues)`
|
|
29
|
+
*/
|
|
30
|
+
constructor({ context, initialValue }) {
|
|
31
|
+
super();
|
|
32
|
+
this.context = new context_1.ContextProvider(this, {
|
|
33
|
+
context,
|
|
34
|
+
initialValue,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Render this Provider.
|
|
39
|
+
*
|
|
40
|
+
* @remarks
|
|
41
|
+
* This method calls `updateContext()` then validates whether or not to
|
|
42
|
+
* update all consumers based on the results of the `shouldUpdateConsumers`
|
|
43
|
+
* getter.
|
|
44
|
+
*
|
|
45
|
+
* @returns - This Provider as an HTML Element.
|
|
46
|
+
*/
|
|
47
|
+
render() {
|
|
48
|
+
this.updateContext();
|
|
49
|
+
return (0, lit_1.html) `<slot></slot>`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Styles associated with this Provider Component.
|
|
54
|
+
*/
|
|
55
|
+
Provider.styles = provider_styles_1.default;
|
|
56
|
+
exports.default = Provider;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const lit_1 = require("lit");
|
|
4
|
+
const styles = (0, lit_1.css) `
|
|
5
|
+
:host {
|
|
6
|
+
border: 0;
|
|
7
|
+
display: block;
|
|
8
|
+
height: 100%;
|
|
9
|
+
margin: 0;
|
|
10
|
+
padding: 0;
|
|
11
|
+
width: 100%;
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
exports.default = styles;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ContextConsumer } from '@lit-labs/context';
|
|
2
|
+
import { ReactiveElement } from 'lit';
|
|
3
|
+
type ConsumeOptions<C> = {
|
|
4
|
+
host: ReactiveElement;
|
|
5
|
+
context: C;
|
|
6
|
+
subscribe?: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare const providerUtils: {
|
|
9
|
+
consume: <C extends {
|
|
10
|
+
__context__: unknown;
|
|
11
|
+
}>(options: ConsumeOptions<C>) => ContextConsumer<C, ReactiveElement>;
|
|
12
|
+
};
|
|
13
|
+
export default providerUtils;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const context_1 = require("@lit-labs/context");
|
|
4
|
+
const consume = (options) => {
|
|
5
|
+
const { host, context, subscribe } = options;
|
|
6
|
+
return new context_1.ContextConsumer(host, {
|
|
7
|
+
context,
|
|
8
|
+
subscribe: subscribe !== null && subscribe !== void 0 ? subscribe : true,
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
const providerUtils = {
|
|
12
|
+
consume,
|
|
13
|
+
};
|
|
14
|
+
exports.default = providerUtils;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hostFitContentStyles = void 0;
|
|
4
|
+
const lit_1 = require("lit");
|
|
5
|
+
const hostFitContentStyles = (0, lit_1.css) `
|
|
6
|
+
:host {
|
|
7
|
+
align-items: center;
|
|
8
|
+
display: flex;
|
|
9
|
+
height: fit-content;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
width: fit-content;
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
exports.hostFitContentStyles = hostFitContentStyles;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
/* eslint-disable implicit-arrow-linebreak */
|
|
5
|
+
/* eslint-disable max-len */
|
|
6
|
+
const constants_1 = tslib_1.__importDefault(require("./constants"));
|
|
7
|
+
const constructTagName = (componentName) => [constants_1.default.NAMESPACE.PREFIX, componentName].join(constants_1.default.NAMESPACE.SEPARATOR);
|
|
8
|
+
exports.default = {
|
|
9
|
+
constructTagName,
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ValueOf<T> = T[keyof T];
|
package/jest.config.js
ADDED