@telperion/elements 4.2.0 → 5.0.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/.build-manifest.json +12 -1
- package/README.md +42 -0
- package/button/button.element.cjs +216 -0
- package/button/button.element.cjs.map +1 -0
- package/button/button.element.js +216 -0
- package/button/button.element.js.map +1 -0
- package/button/index.cjs +11 -0
- package/button/index.cjs.map +1 -0
- package/button/index.d.cts +139 -0
- package/button/index.d.ts +139 -0
- package/button/index.js +2 -0
- package/button/index.js.map +1 -0
- package/fesm/elements.mjs +325 -1
- package/fesm/elements.mjs.map +1 -1
- package/iife/button/index.js +146 -0
- package/iife/button/index.js.map +1 -0
- package/iife/elements.js +133 -22
- package/iife/elements.js.map +1 -1
- package/index.cjs +5 -0
- package/index.cjs.map +1 -1
- package/index.d.cts +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/package.json +27 -3
- package/utils/shade-mixer-lit-element.cjs +123 -0
- package/utils/shade-mixer-lit-element.cjs.map +1 -0
- package/utils/shade-mixer-lit-element.js +121 -0
- package/utils/shade-mixer-lit-element.js.map +1 -0
package/index.cjs
CHANGED
|
@@ -16,6 +16,7 @@ var select_element = require('./select/select.element.cjs');
|
|
|
16
16
|
var option_element = require('./select/option.element.cjs');
|
|
17
17
|
var selectedContent_element = require('./select/selected-content.element.cjs');
|
|
18
18
|
var selectChangeEvent = require('./select/select-change-event.cjs');
|
|
19
|
+
var button_element = require('./button/button.element.cjs');
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
|
|
@@ -77,4 +78,8 @@ Object.defineProperty(exports, "SelectedContentElement", {
|
|
|
77
78
|
get: function () { return selectedContent_element.SelectedContentElement; }
|
|
78
79
|
});
|
|
79
80
|
exports.SelectChangeEvent = selectChangeEvent.SelectChangeEvent;
|
|
81
|
+
Object.defineProperty(exports, "ButtonElement", {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function () { return button_element.ButtonElement; }
|
|
84
|
+
});
|
|
80
85
|
//# sourceMappingURL=index.cjs.map
|
package/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/index.d.cts
CHANGED
|
@@ -3,6 +3,7 @@ export { DragElement, DragElementEventTypes, DragHandleElement, DropElementEvent
|
|
|
3
3
|
export { DetailsSetElement } from './details-set/index.cjs';
|
|
4
4
|
export { PopoverElement } from './popover/index.cjs';
|
|
5
5
|
export { OptionElement, SelectChangeEvent, SelectElement, SelectedContentElement } from './select/index.cjs';
|
|
6
|
+
export { ButtonElement, ButtonType, ButtonVariant } from './button/index.cjs';
|
|
6
7
|
import './_chunks/signal-watcher-lit-element-B9xodkLt.cjs';
|
|
7
8
|
import 'lit';
|
|
8
9
|
import '@lit-labs/signals';
|
package/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { DragElement, DragElementEventTypes, DragHandleElement, DropElementEvent
|
|
|
3
3
|
export { DetailsSetElement } from './details-set/index.js';
|
|
4
4
|
export { PopoverElement } from './popover/index.js';
|
|
5
5
|
export { OptionElement, SelectChangeEvent, SelectElement, SelectedContentElement } from './select/index.js';
|
|
6
|
+
export { ButtonElement, ButtonType, ButtonVariant } from './button/index.js';
|
|
6
7
|
import './_chunks/signal-watcher-lit-element-B9xodkLt.js';
|
|
7
8
|
import 'lit';
|
|
8
9
|
import '@lit-labs/signals';
|
package/index.js
CHANGED
|
@@ -14,4 +14,5 @@ export { SelectElement } from './select/select.element.js';
|
|
|
14
14
|
export { OptionElement } from './select/option.element.js';
|
|
15
15
|
export { SelectedContentElement } from './select/selected-content.element.js';
|
|
16
16
|
export { SelectChangeEvent } from './select/select-change-event.js';
|
|
17
|
+
export { ButtonElement } from './button/button.element.js';
|
|
17
18
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telperion/elements",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Framework-agnostic web components built with Lit: Material Symbols / Simple Icons / theSVG icons, declarative client-side router, drag-and-drop primitives, details accordion with FIFO open caps, a CSS-anchored popover,
|
|
3
|
+
"version": "5.0.0",
|
|
4
|
+
"description": "Framework-agnostic web components built with Lit: Material Symbols / Simple Icons / theSVG icons, declarative client-side router, drag-and-drop primitives, details accordion with FIFO open caps, a CSS-anchored popover, a form-associated selectbox with single/multi-select, and a form-associated button.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web-components",
|
|
7
7
|
"custom-elements",
|
|
@@ -26,7 +26,9 @@
|
|
|
26
26
|
"select",
|
|
27
27
|
"selectbox",
|
|
28
28
|
"multi-select",
|
|
29
|
-
"
|
|
29
|
+
"button",
|
|
30
|
+
"form-associated",
|
|
31
|
+
"themeable"
|
|
30
32
|
],
|
|
31
33
|
"homepage": "https://open-source.telperion.tr/elements",
|
|
32
34
|
"repository": {
|
|
@@ -189,6 +191,28 @@
|
|
|
189
191
|
"script": "./iife/select/index.js",
|
|
190
192
|
"default": "./select/index.js"
|
|
191
193
|
},
|
|
194
|
+
"./button/index": {
|
|
195
|
+
"types": {
|
|
196
|
+
"import": "./button/index.d.ts",
|
|
197
|
+
"require": "./button/index.d.cts"
|
|
198
|
+
},
|
|
199
|
+
"node": "./button/index.cjs",
|
|
200
|
+
"import": "./button/index.js",
|
|
201
|
+
"require": "./button/index.cjs",
|
|
202
|
+
"script": "./iife/button/index.js",
|
|
203
|
+
"default": "./button/index.js"
|
|
204
|
+
},
|
|
205
|
+
"./button": {
|
|
206
|
+
"types": {
|
|
207
|
+
"import": "./button/index.d.ts",
|
|
208
|
+
"require": "./button/index.d.cts"
|
|
209
|
+
},
|
|
210
|
+
"node": "./button/index.cjs",
|
|
211
|
+
"import": "./button/index.js",
|
|
212
|
+
"require": "./button/index.cjs",
|
|
213
|
+
"script": "./iife/button/index.js",
|
|
214
|
+
"default": "./button/index.js"
|
|
215
|
+
},
|
|
192
216
|
"./icon/material-symbols.css": "./icon/material-symbols.css"
|
|
193
217
|
},
|
|
194
218
|
"bugs": "https://github.com/telperiontech/telperion/issues",
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var lit = require('lit');
|
|
5
|
+
var decorators_js = require('lit/decorators.js');
|
|
6
|
+
var uniquify = require('@telperion/js-utils/array/uniquify');
|
|
7
|
+
var minMax = require('@telperion/js-utils/math/min-max');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Base class that powers Telperion's shared color/design system.
|
|
11
|
+
*
|
|
12
|
+
* Elements that extend `ShadeMixerLitElement` participate in a fully themable
|
|
13
|
+
* palette driven entirely by CSS custom properties. The class:
|
|
14
|
+
*
|
|
15
|
+
* 1. Auto-injects a default palette onto `:root` — `--tp-color-white`,
|
|
16
|
+
* `--tp-color-black`, `--tp-color-contrast`, `--tp-color-primary`,
|
|
17
|
+
* `--tp-color-secondary`, `--tp-color-tertiary`, `--tp-color-quaternary`,
|
|
18
|
+
* `--tp-color-success`, `--tp-color-danger`, `--tp-color-warning`, and
|
|
19
|
+
* `--tp-color-neutral`. Override any of them at `:root` or any ancestor to
|
|
20
|
+
* re-theme every shade-mixer-aware element underneath.
|
|
21
|
+
* 2. Exposes `shadedElementStyles` — a `css` block that resolves the
|
|
22
|
+
* selected `color` to `--tp-element-color`, applies the `shade`/`mixer`
|
|
23
|
+
* math, and exposes the result as `--tp-calc-element-color` and
|
|
24
|
+
* `--tp-calc-contrast-color` for consumers (variants, hover, focus, …).
|
|
25
|
+
* Subclasses include it once in their own host rule.
|
|
26
|
+
* 3. Provides three reflected attributes that drive the math:
|
|
27
|
+
* - `color` — palette token name (predefined or custom).
|
|
28
|
+
* - `shade` (`0`–`1000`, default `500`) — lighten/darken the
|
|
29
|
+
* resolved color (`<500` mixes white, `>500` mixes black).
|
|
30
|
+
* - `mixer` (`none` / `black` / `white`) — read-only output, auto-set
|
|
31
|
+
* whenever `shade` changes.
|
|
32
|
+
*
|
|
33
|
+
* **Adding custom color tokens.** If the predefined names are not enough,
|
|
34
|
+
* declare a new selector that supplies `--tp-element-color`:
|
|
35
|
+
*
|
|
36
|
+
* ```css
|
|
37
|
+
* tp-button[color="brand"] {
|
|
38
|
+
* --tp-element-color: hsl(265 75% 45%);
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* The shade math, hover/focus styles, and contrast color all derive from this
|
|
43
|
+
* one variable, so the new token "just works" with `shade`, `variant`, etc.
|
|
44
|
+
*/
|
|
45
|
+
class ShadeMixerLitElement extends lit.LitElement {
|
|
46
|
+
constructor() {
|
|
47
|
+
super(...arguments);
|
|
48
|
+
this.color = "contrast";
|
|
49
|
+
this.shade = 500;
|
|
50
|
+
this.mixer = "none";
|
|
51
|
+
}
|
|
52
|
+
static { this.rootStyles = (() => {
|
|
53
|
+
const style = lit.css `
|
|
54
|
+
:root {
|
|
55
|
+
--tp-color-white: hsl(0 0% 100%);
|
|
56
|
+
--tp-color-black: hsl(0 0% 0%);
|
|
57
|
+
--tp-color-contrast: var(--tp-color-black);
|
|
58
|
+
--tp-color-primary: hsl(220 90% 56%);
|
|
59
|
+
--tp-color-secondary: hsl(340 82% 52%);
|
|
60
|
+
--tp-color-tertiary: hsl(50 100% 50%);
|
|
61
|
+
--tp-color-quaternary: hsl(120 100% 40%);
|
|
62
|
+
--tp-color-success: hsl(140 70% 40%);
|
|
63
|
+
--tp-color-danger: hsl(0 70% 50%);
|
|
64
|
+
--tp-color-warning: hsl(45 100% 50%);
|
|
65
|
+
--tp-color-neutral: color-mix(in xyz, var(--tp-color-white) 50%, var(--tp-color-black) 50%);
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
document.adoptedStyleSheets = uniquify.uniquify([...document.adoptedStyleSheets, style.styleSheet]);
|
|
69
|
+
return style;
|
|
70
|
+
})(); }
|
|
71
|
+
static { this.shadedElementStyles = lit.css `
|
|
72
|
+
--tp-element-color: var(--tp-color-primary);
|
|
73
|
+
--tp-shade-attr: attr(shade type(<number>));
|
|
74
|
+
--tp-shade-mixer-type: attr(mixer type(*));
|
|
75
|
+
--tp-shade-mixer-color: if(
|
|
76
|
+
style(--tp-shade-mixer-type: black): var(--tp-color-black);
|
|
77
|
+
else: var(--tp-color-white)
|
|
78
|
+
);
|
|
79
|
+
--tp-shade-mixer-percent: if(
|
|
80
|
+
style(--tp-shade-mixer-type: black): calc(100% - ((var(--tp-shade-attr) - 500) / 500 * 100%));
|
|
81
|
+
else: calc(100% - ((500 - var(--tp-shade-attr)) / 500 * 100%))
|
|
82
|
+
);
|
|
83
|
+
--tp-calc-element-color: color-mix(in xyz, var(--tp-element-color) var(--tp-shade-mixer-percent), var(--tp-shade-mixer-color) calc(100% - var(--tp-shade-mixer-percent)));
|
|
84
|
+
--tp-calc-contrast-color: contrast-color(var(--tp-calc-element-color));
|
|
85
|
+
--tp-contrast-color: if(
|
|
86
|
+
style(--tp-calc-contrast-color: white): var(--tp-color-white);
|
|
87
|
+
else: var(--tp-color-black);
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
&[color="contrast"] { --tp-element-color: var(--tp-color-contrast); }
|
|
91
|
+
&[color="primary"] { --tp-element-color: var(--tp-color-primary); }
|
|
92
|
+
&[color="secondary"] { --tp-element-color: var(--tp-color-secondary); }
|
|
93
|
+
&[color="tertiary"] { --tp-element-color: var(--tp-color-tertiary); }
|
|
94
|
+
&[color="quaternary"] { --tp-element-color: var(--tp-color-quaternary); }
|
|
95
|
+
&[color="success"] { --tp-element-color: var(--tp-color-success); }
|
|
96
|
+
&[color="danger"] { --tp-element-color: var(--tp-color-danger); }
|
|
97
|
+
&[color="warning"] { --tp-element-color: var(--tp-color-warning); }
|
|
98
|
+
&[color="neutral"] { --tp-element-color: var(--tp-color-neutral); }
|
|
99
|
+
`; }
|
|
100
|
+
willUpdate(changed) {
|
|
101
|
+
if (changed.has("shade")) {
|
|
102
|
+
this.mixer = this.shade === 500 ? "none" : this.shade > 500 ? "black" : "white";
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
tslib.__decorate([
|
|
107
|
+
decorators_js.property({ type: String, reflect: true }),
|
|
108
|
+
tslib.__metadata("design:type", String)
|
|
109
|
+
], ShadeMixerLitElement.prototype, "color", void 0);
|
|
110
|
+
tslib.__decorate([
|
|
111
|
+
decorators_js.property({ type: Number, reflect: true, converter(value, type) {
|
|
112
|
+
const num = Number(value);
|
|
113
|
+
return isNaN(num) ? 500 : minMax.minMax(0, 1000, num);
|
|
114
|
+
} }),
|
|
115
|
+
tslib.__metadata("design:type", Number)
|
|
116
|
+
], ShadeMixerLitElement.prototype, "shade", void 0);
|
|
117
|
+
tslib.__decorate([
|
|
118
|
+
decorators_js.property({ type: String, reflect: true }),
|
|
119
|
+
tslib.__metadata("design:type", String)
|
|
120
|
+
], ShadeMixerLitElement.prototype, "mixer", void 0);
|
|
121
|
+
|
|
122
|
+
exports.ShadeMixerLitElement = ShadeMixerLitElement;
|
|
123
|
+
//# sourceMappingURL=shade-mixer-lit-element.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shade-mixer-lit-element.cjs","sources":["../../../../libs/elements/src/utils/shade-mixer-lit-element.ts"],"sourcesContent":[null],"names":["LitElement","css","uniquify","__decorate","property","minMax"],"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GAAG,MAAM,CAAC,KAAK,CAAC;AACzB,YAAA,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,GAAG,GAAGC,aAAM,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC;AAChD,QAAA,CAAC,EAAC,CAAC;;AACiB,CAAA,EAAA,oBAAA,CAAA,SAAA,EAAA,OAAA,EAAA,MAAA,CAAA;AAGpBF,gBAAA,CAAA;IADCC,sBAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;AACX,CAAA,EAAA,oBAAA,CAAA,SAAA,EAAA,OAAA,EAAA,MAAA,CAAA;;;;"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { __decorate, __metadata } from 'tslib';
|
|
2
|
+
import { LitElement, css } from 'lit';
|
|
3
|
+
import { property } from 'lit/decorators.js';
|
|
4
|
+
import { uniquify } from '@telperion/js-utils/array/uniquify';
|
|
5
|
+
import { minMax } from '@telperion/js-utils/math/min-max';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Base class that powers Telperion's shared color/design system.
|
|
9
|
+
*
|
|
10
|
+
* Elements that extend `ShadeMixerLitElement` participate in a fully themable
|
|
11
|
+
* palette driven entirely by CSS custom properties. The class:
|
|
12
|
+
*
|
|
13
|
+
* 1. Auto-injects a default palette onto `:root` — `--tp-color-white`,
|
|
14
|
+
* `--tp-color-black`, `--tp-color-contrast`, `--tp-color-primary`,
|
|
15
|
+
* `--tp-color-secondary`, `--tp-color-tertiary`, `--tp-color-quaternary`,
|
|
16
|
+
* `--tp-color-success`, `--tp-color-danger`, `--tp-color-warning`, and
|
|
17
|
+
* `--tp-color-neutral`. Override any of them at `:root` or any ancestor to
|
|
18
|
+
* re-theme every shade-mixer-aware element underneath.
|
|
19
|
+
* 2. Exposes `shadedElementStyles` — a `css` block that resolves the
|
|
20
|
+
* selected `color` to `--tp-element-color`, applies the `shade`/`mixer`
|
|
21
|
+
* math, and exposes the result as `--tp-calc-element-color` and
|
|
22
|
+
* `--tp-calc-contrast-color` for consumers (variants, hover, focus, …).
|
|
23
|
+
* Subclasses include it once in their own host rule.
|
|
24
|
+
* 3. Provides three reflected attributes that drive the math:
|
|
25
|
+
* - `color` — palette token name (predefined or custom).
|
|
26
|
+
* - `shade` (`0`–`1000`, default `500`) — lighten/darken the
|
|
27
|
+
* resolved color (`<500` mixes white, `>500` mixes black).
|
|
28
|
+
* - `mixer` (`none` / `black` / `white`) — read-only output, auto-set
|
|
29
|
+
* whenever `shade` changes.
|
|
30
|
+
*
|
|
31
|
+
* **Adding custom color tokens.** If the predefined names are not enough,
|
|
32
|
+
* declare a new selector that supplies `--tp-element-color`:
|
|
33
|
+
*
|
|
34
|
+
* ```css
|
|
35
|
+
* tp-button[color="brand"] {
|
|
36
|
+
* --tp-element-color: hsl(265 75% 45%);
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* The shade math, hover/focus styles, and contrast color all derive from this
|
|
41
|
+
* one variable, so the new token "just works" with `shade`, `variant`, etc.
|
|
42
|
+
*/
|
|
43
|
+
class ShadeMixerLitElement extends LitElement {
|
|
44
|
+
constructor() {
|
|
45
|
+
super(...arguments);
|
|
46
|
+
this.color = "contrast";
|
|
47
|
+
this.shade = 500;
|
|
48
|
+
this.mixer = "none";
|
|
49
|
+
}
|
|
50
|
+
static { this.rootStyles = (() => {
|
|
51
|
+
const style = css `
|
|
52
|
+
:root {
|
|
53
|
+
--tp-color-white: hsl(0 0% 100%);
|
|
54
|
+
--tp-color-black: hsl(0 0% 0%);
|
|
55
|
+
--tp-color-contrast: var(--tp-color-black);
|
|
56
|
+
--tp-color-primary: hsl(220 90% 56%);
|
|
57
|
+
--tp-color-secondary: hsl(340 82% 52%);
|
|
58
|
+
--tp-color-tertiary: hsl(50 100% 50%);
|
|
59
|
+
--tp-color-quaternary: hsl(120 100% 40%);
|
|
60
|
+
--tp-color-success: hsl(140 70% 40%);
|
|
61
|
+
--tp-color-danger: hsl(0 70% 50%);
|
|
62
|
+
--tp-color-warning: hsl(45 100% 50%);
|
|
63
|
+
--tp-color-neutral: color-mix(in xyz, var(--tp-color-white) 50%, var(--tp-color-black) 50%);
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
document.adoptedStyleSheets = uniquify([...document.adoptedStyleSheets, style.styleSheet]);
|
|
67
|
+
return style;
|
|
68
|
+
})(); }
|
|
69
|
+
static { this.shadedElementStyles = css `
|
|
70
|
+
--tp-element-color: var(--tp-color-primary);
|
|
71
|
+
--tp-shade-attr: attr(shade type(<number>));
|
|
72
|
+
--tp-shade-mixer-type: attr(mixer type(*));
|
|
73
|
+
--tp-shade-mixer-color: if(
|
|
74
|
+
style(--tp-shade-mixer-type: black): var(--tp-color-black);
|
|
75
|
+
else: var(--tp-color-white)
|
|
76
|
+
);
|
|
77
|
+
--tp-shade-mixer-percent: if(
|
|
78
|
+
style(--tp-shade-mixer-type: black): calc(100% - ((var(--tp-shade-attr) - 500) / 500 * 100%));
|
|
79
|
+
else: calc(100% - ((500 - var(--tp-shade-attr)) / 500 * 100%))
|
|
80
|
+
);
|
|
81
|
+
--tp-calc-element-color: color-mix(in xyz, var(--tp-element-color) var(--tp-shade-mixer-percent), var(--tp-shade-mixer-color) calc(100% - var(--tp-shade-mixer-percent)));
|
|
82
|
+
--tp-calc-contrast-color: contrast-color(var(--tp-calc-element-color));
|
|
83
|
+
--tp-contrast-color: if(
|
|
84
|
+
style(--tp-calc-contrast-color: white): var(--tp-color-white);
|
|
85
|
+
else: var(--tp-color-black);
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
&[color="contrast"] { --tp-element-color: var(--tp-color-contrast); }
|
|
89
|
+
&[color="primary"] { --tp-element-color: var(--tp-color-primary); }
|
|
90
|
+
&[color="secondary"] { --tp-element-color: var(--tp-color-secondary); }
|
|
91
|
+
&[color="tertiary"] { --tp-element-color: var(--tp-color-tertiary); }
|
|
92
|
+
&[color="quaternary"] { --tp-element-color: var(--tp-color-quaternary); }
|
|
93
|
+
&[color="success"] { --tp-element-color: var(--tp-color-success); }
|
|
94
|
+
&[color="danger"] { --tp-element-color: var(--tp-color-danger); }
|
|
95
|
+
&[color="warning"] { --tp-element-color: var(--tp-color-warning); }
|
|
96
|
+
&[color="neutral"] { --tp-element-color: var(--tp-color-neutral); }
|
|
97
|
+
`; }
|
|
98
|
+
willUpdate(changed) {
|
|
99
|
+
if (changed.has("shade")) {
|
|
100
|
+
this.mixer = this.shade === 500 ? "none" : this.shade > 500 ? "black" : "white";
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
__decorate([
|
|
105
|
+
property({ type: String, reflect: true }),
|
|
106
|
+
__metadata("design:type", String)
|
|
107
|
+
], ShadeMixerLitElement.prototype, "color", void 0);
|
|
108
|
+
__decorate([
|
|
109
|
+
property({ type: Number, reflect: true, converter(value, type) {
|
|
110
|
+
const num = Number(value);
|
|
111
|
+
return isNaN(num) ? 500 : minMax(0, 1000, num);
|
|
112
|
+
} }),
|
|
113
|
+
__metadata("design:type", Number)
|
|
114
|
+
], ShadeMixerLitElement.prototype, "shade", void 0);
|
|
115
|
+
__decorate([
|
|
116
|
+
property({ type: String, reflect: true }),
|
|
117
|
+
__metadata("design:type", String)
|
|
118
|
+
], ShadeMixerLitElement.prototype, "mixer", void 0);
|
|
119
|
+
|
|
120
|
+
export { ShadeMixerLitElement };
|
|
121
|
+
//# sourceMappingURL=shade-mixer-lit-element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shade-mixer-lit-element.js","sources":["../../../../libs/elements/src/utils/shade-mixer-lit-element.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCG;AACG,MAAO,oBAAqB,SAAQ,UAAU,CAAA;AAApD,IAAA,WAAA,GAAA;;QAsDE,IAAA,CAAA,KAAK,GAA8B,UAAU;QAM7C,IA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