@exmg/exm-radio 0.0.2-alpha.0

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/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # `<exm-radio>` [![Published on npm](https://img.shields.io/npm/v/@exmg/exm-radio-group.svg)](https://www.npmjs.com/package/@exmg/exm-radio)
2
+
3
+ # @exmg/exm-radio
4
+
5
+ This package provides radio functionality.
@@ -0,0 +1,16 @@
1
+ import { Radio } from '@material/web/radio/internal/radio.js';
2
+ /**
3
+ * exm-radio-item
4
+ * Material 3 radio item
5
+ */
6
+ export declare class ExmRadioItem extends Radio {
7
+ private readonly maskIdOverride;
8
+ static styles: import("lit").CSSResult[];
9
+ radio: boolean;
10
+ protected render(): import("lit-html").TemplateResult<1>;
11
+ }
12
+ declare global {
13
+ interface HTMLElementTagNameMap {
14
+ 'exm-radio-item': ExmRadioItem;
15
+ }
16
+ }
@@ -0,0 +1,67 @@
1
+ import { __decorate } from "tslib";
2
+ import { html } from 'lit';
3
+ import { customElement, property } from 'lit/decorators.js';
4
+ import { Radio } from '@material/web/radio/internal/radio.js';
5
+ import { classMap } from 'lit/directives/class-map.js';
6
+ import { styles } from '@material/web/radio/internal/radio-styles.js';
7
+ import { style as radioStyle } from './styles/exm-radio-item-css.js';
8
+ let maskId = 0;
9
+ /**
10
+ * exm-radio-item
11
+ * Material 3 radio item
12
+ */
13
+ let ExmRadioItem = class ExmRadioItem extends Radio {
14
+ constructor() {
15
+ super(...arguments);
16
+ // Unique maskId is required because of a Safari bug that fail to persist
17
+ // reference to the mask. This should be removed once the bug is fixed.
18
+ this.maskIdOverride = `cutout${++maskId}`;
19
+ this.radio = false;
20
+ }
21
+ render() {
22
+ const classes = { checked: this.checked, disabled: this.disabled };
23
+ const showRadioMap = classMap({ 'show-radio': this.radio });
24
+ return html `
25
+ <div class="container ${classMap(classes)}" aria-hidden="true">
26
+ <md-ripple part="ripple" .control=${this} ?disabled=${this.disabled}></md-ripple>
27
+ <md-focus-ring part="focus-ring" .control=${this}></md-focus-ring>
28
+ <div class="radio-container ${showRadioMap}">
29
+ <svg class="icon ${showRadioMap}" viewBox="0 0 20 20">
30
+ <mask id="${this.maskIdOverride}">
31
+ <rect width="100%" height="100%" fill="white" />
32
+ <circle cx="10" cy="10" r="8" fill="black" />
33
+ </mask>
34
+ <circle class="outer circle" cx="10" cy="10" r="10" mask="url(#${this.maskIdOverride})" />
35
+ <circle class="inner circle" cx="10" cy="10" r="5" />
36
+ </svg>
37
+ </div>
38
+ <div class="content-container">
39
+ <div class="image-container">
40
+ <slot name="image"></slot>
41
+ </div>
42
+ <div class="content">
43
+ <slot name="title"></slot>
44
+ <slot name="content"></slot>
45
+ </div>
46
+ </div>
47
+ <input
48
+ id="input"
49
+ type="radio"
50
+ tabindex="-1"
51
+ .checked=${this.checked}
52
+ .value=${this.value}
53
+ ?disabled=${this.disabled}
54
+ />
55
+ </div>
56
+ `;
57
+ }
58
+ };
59
+ ExmRadioItem.styles = [styles, radioStyle];
60
+ __decorate([
61
+ property({ type: Boolean })
62
+ ], ExmRadioItem.prototype, "radio", void 0);
63
+ ExmRadioItem = __decorate([
64
+ customElement('exm-radio-item')
65
+ ], ExmRadioItem);
66
+ export { ExmRadioItem };
67
+ //# sourceMappingURL=exm-radio-item.js.map
@@ -0,0 +1 @@
1
+ export { ExmRadioItem } from './exm-radio-item.js';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { ExmRadioItem } from './exm-radio-item.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ export declare const style: import("lit").CSSResult;
@@ -0,0 +1,100 @@
1
+ import { css } from 'lit';
2
+ export const style = css `
3
+ :host {
4
+ display: block;
5
+ background: rgba(0, 0, 0, 0);
6
+ height: 100%;
7
+ width: 100%;
8
+ box-sizing: border-box;
9
+ --md-radio-disabled-icon-color: grey;
10
+ }
11
+
12
+ .container {
13
+ border-top-left-radius: var(--exm-radio-table-top-left-radius, var(--exm-surface-border-radius, 16px));
14
+ border-top-right-radius: var(--exm-radio-table-top-right-radius, var(--exm-surface-border-radius, 16px));
15
+ border-bottom-left-radius: var(--exm-radio-table-bottom-left-radius, var(--exm-surface-border-radius, 16px));
16
+ border-bottom-right-radius: var(--exm-radio-table-bottom-right-radius, var(--exm-surface-border-radius, 16px));
17
+ box-sizing: border-box;
18
+ border: 1px solid var(--md-radio-icon-color, var(--md-sys-color-on-surface-variant, #49454f));
19
+ display: flex;
20
+ position: relative;
21
+ justify-content: center;
22
+ align-items: center;
23
+ padding: 1rem 1px;
24
+ }
25
+
26
+ .container.disabled {
27
+ border: 1px solid var(--md-radio-disabled-icon-color, var(--md-sys-color-on-surface-variant, #49454f));
28
+ color: var(--md-radio-disabled-icon-color, var(--md-sys-color-on-surface-variant, #49454f));
29
+ }
30
+
31
+ .container.checked {
32
+ border: 2px solid var(--md-radio-selected-icon-color, var(--md-sys-color-primary, #6750a4));
33
+ padding: calc(1rem - 1px) 0;
34
+ }
35
+
36
+ :host([left-align]) .container {
37
+ justify-content: flex-start;
38
+ }
39
+
40
+ :host([right-align]) .container {
41
+ justify-content: flex-end;
42
+ }
43
+
44
+ md-ripple {
45
+ border-radius: unset;
46
+ width: 100%;
47
+ height: 100%;
48
+ }
49
+
50
+ #input {
51
+ display: none;
52
+ }
53
+
54
+ svg {
55
+ display: none;
56
+ }
57
+
58
+ svg.show-radio {
59
+ display: block;
60
+ position: relative;
61
+ width: 20px;
62
+ height: 20px;
63
+ }
64
+
65
+ slot[name='title'] {
66
+ font-size: var(--exm-radio-title-font-size, 24px);
67
+ }
68
+
69
+ slot[name='content'] {
70
+ font-size: var(--exm-radio-content-font-size, 16px);
71
+ }
72
+
73
+ slot[name='image'] {
74
+ margin-right: 1rem;
75
+ }
76
+
77
+ .radio-container {
78
+ height: 100%;
79
+ }
80
+
81
+ .image-container {
82
+ display: flex;
83
+ }
84
+
85
+ .image-container > ::slotted(*) {
86
+ margin-right: 1rem;
87
+ }
88
+
89
+ .content-container {
90
+ display: flex;
91
+ align-items: center;
92
+ padding: 0 1rem;
93
+ }
94
+
95
+ .content {
96
+ display: flex;
97
+ flex-direction: column;
98
+ }
99
+ `;
100
+ //# sourceMappingURL=exm-radio-item-css.js.map
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@exmg/exm-radio",
3
+ "version": "0.0.2-alpha.0+df24e0c",
4
+ "description": "Material style radio element",
5
+ "contributors": [
6
+ "Ex Machina"
7
+ ],
8
+ "keywords": [
9
+ "web-components",
10
+ "lit",
11
+ "material",
12
+ "radio",
13
+ "radio-button"
14
+ ],
15
+ "type": "module",
16
+ "main": "dist/index.js",
17
+ "types": "dist/index.d.ts",
18
+ "module": "dist/index.js",
19
+ "exports": {
20
+ ".": "./dist/index.js",
21
+ "./exm-radio-item.js": "./dist/exm-radio-item.js"
22
+ },
23
+ "files": [
24
+ "**/*.scss",
25
+ "**/*.js",
26
+ "**/*.d.ts"
27
+ ],
28
+ "homepage": "https://bitbucket.org/exmachina/exm-web-components",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git@bitbucket.org:exmachina/exm-web-components.git",
32
+ "directory": "packages/exm-radio"
33
+ },
34
+ "license": "MIT",
35
+ "peerDependencies": {
36
+ "@material/web": "^2.2.0",
37
+ "lit": "3.2.1",
38
+ "tslib": "^2.6.2"
39
+ },
40
+ "scripts": {
41
+ "build:styles": "exmg-lit-cli sass -f \"./**/*.scss\"",
42
+ "tsc": "tsc"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "gitHead": "df24e0c74a76a7e1c258f69386036e24e7860256"
48
+ }