@neovici/cosmoz-input 5.1.4 → 5.2.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/dist/cosmoz-toggle.d.ts +1 -0
- package/dist/cosmoz-toggle.js +81 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const toggleStyles: string;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { component, css, html, useCallback } from '@pionjs/pion';
|
|
2
|
+
import { live } from 'lit-html/directives/live.js';
|
|
3
|
+
import { when } from 'lit-html/directives/when.js';
|
|
4
|
+
const CosmozToggle = (host) => {
|
|
5
|
+
const { label, value, disabled, error } = host;
|
|
6
|
+
const onChange = useCallback((e) => host.dispatchEvent(new CustomEvent('change', {
|
|
7
|
+
detail: e.target.checked,
|
|
8
|
+
})), []);
|
|
9
|
+
return html `<input
|
|
10
|
+
id="toggle"
|
|
11
|
+
class="toggle"
|
|
12
|
+
part="toggle"
|
|
13
|
+
type="checkbox"
|
|
14
|
+
.checked=${live(!!value)}
|
|
15
|
+
?disabled=${disabled}
|
|
16
|
+
@change=${onChange}
|
|
17
|
+
/>
|
|
18
|
+
${when(label, () => html `<label for="toggle">${label}</label>`)}
|
|
19
|
+
<slot name="suffix"></slot>
|
|
20
|
+
${when(error, (error) => html `<div class="failure">${error}</div>`)} `;
|
|
21
|
+
};
|
|
22
|
+
export const toggleStyles = css `
|
|
23
|
+
.toggle {
|
|
24
|
+
appearance: none;
|
|
25
|
+
width: 35px;
|
|
26
|
+
height: 18px;
|
|
27
|
+
display: inline-block;
|
|
28
|
+
position: relative;
|
|
29
|
+
border-radius: 18px;
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
outline: none;
|
|
32
|
+
border: none;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
background: var(--cz-toggle-color, #101010);
|
|
35
|
+
transition: background-color ease 0.25s;
|
|
36
|
+
margin: 0;
|
|
37
|
+
}
|
|
38
|
+
.toggle::before {
|
|
39
|
+
content: '';
|
|
40
|
+
display: block;
|
|
41
|
+
position: absolute;
|
|
42
|
+
z-index: 2;
|
|
43
|
+
width: 14px;
|
|
44
|
+
height: 14px;
|
|
45
|
+
background: var(--cz-toggle-thumb-color, #15b0d3);
|
|
46
|
+
left: 2px;
|
|
47
|
+
top: 2px;
|
|
48
|
+
border-radius: 50%;
|
|
49
|
+
transition: all cubic-bezier(0.3, 1.5, 0.7, 1) 0.25s;
|
|
50
|
+
}
|
|
51
|
+
.toggle:checked {
|
|
52
|
+
background: var(--cz-toggle-checked-color, #66d7f0);
|
|
53
|
+
}
|
|
54
|
+
.toggle:checked::before {
|
|
55
|
+
left: 19px;
|
|
56
|
+
}
|
|
57
|
+
.toggle + label {
|
|
58
|
+
padding-left: 16px;
|
|
59
|
+
font-size: 14px;
|
|
60
|
+
line-height: 18px;
|
|
61
|
+
cursor: pointer;
|
|
62
|
+
}
|
|
63
|
+
.toggle[disabled] {
|
|
64
|
+
opacity: 0.6;
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
67
|
+
const style = css `
|
|
68
|
+
:host {
|
|
69
|
+
display: block;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
:host > * {
|
|
73
|
+
vertical-align: middle;
|
|
74
|
+
line-height: 0px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
::slotted(*) {
|
|
78
|
+
margin-left: 5px;
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
81
|
+
customElements.define('cosmoz-toggle', component(CosmozToggle, { styleSheets: [style, toggleStyles] }));
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neovici/cosmoz-input",
|
|
3
|
-
"version": "5.1
|
|
3
|
+
"version": "5.2.1",
|
|
4
4
|
"description": "A input web component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lit-html",
|
|
@@ -66,7 +66,8 @@
|
|
|
66
66
|
".": "./dist/index.js",
|
|
67
67
|
"./use-input": "./dist/use-input.js",
|
|
68
68
|
"./input": "./dist/cosmoz-input.js",
|
|
69
|
-
"./textarea": "./dist/cosmoz-textarea.js"
|
|
69
|
+
"./textarea": "./dist/cosmoz-textarea.js",
|
|
70
|
+
"./toggle": "./dist/cosmoz-toggle.js"
|
|
70
71
|
},
|
|
71
72
|
"dependencies": {
|
|
72
73
|
"@neovici/cosmoz-utils": "^6.0.0",
|