@lemonadejs/switch 1.1.4 → 1.3.2
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 +36 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +10 -0
- package/dist/react.d.ts +6 -3
- package/dist/style.css +16 -11
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -51,6 +51,41 @@ export default function App() {
|
|
|
51
51
|
}
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
+
```jsx
|
|
55
|
+
import React, { useRef } from "react";
|
|
56
|
+
import Switch from "@lemonadejs/switch/dist/react";
|
|
57
|
+
import '@lemonadejs/switch/dist/style.css';
|
|
58
|
+
|
|
59
|
+
export default function App() {
|
|
60
|
+
const switchRef = useRef();
|
|
61
|
+
return (
|
|
62
|
+
<>
|
|
63
|
+
<Switch text='On/Off' ref={switchRef} />
|
|
64
|
+
</>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Quick example with Lemonade
|
|
70
|
+
|
|
71
|
+
```vue
|
|
72
|
+
<template>
|
|
73
|
+
<Switch text='On/Off' />
|
|
74
|
+
</template>
|
|
75
|
+
|
|
76
|
+
<script>
|
|
77
|
+
import Switch from '@lemonadejs/switch/dist/vue';
|
|
78
|
+
import '@lemonadejs/switch/dist/style.css';
|
|
79
|
+
|
|
80
|
+
export default {
|
|
81
|
+
name: 'App',
|
|
82
|
+
components: {
|
|
83
|
+
Switch,
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
</script>
|
|
87
|
+
```
|
|
88
|
+
|
|
54
89
|
[You can find more examples here in the official documentation.](https://lemonadejs.net/components/switch)
|
|
55
90
|
|
|
56
91
|
#### Settings
|
|
@@ -69,5 +104,5 @@ The [LemonadeJS](https://lemonadejs.net) Switch is released under the MIT.
|
|
|
69
104
|
|
|
70
105
|
## Other Tools
|
|
71
106
|
|
|
72
|
-
- [jSuites](https://jsuites.net/
|
|
107
|
+
- [jSuites](https://jsuites.net/docs)
|
|
73
108
|
- [Jspreadsheet Data Grid](https://jspreadsheet.com)
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ if (!lemonade && typeof (require) === 'function') {
|
|
|
7
7
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
8
8
|
global.Switch = factory();
|
|
9
9
|
}(this, (function () {
|
|
10
|
+
|
|
10
11
|
const Switch = function () {
|
|
11
12
|
let self = this;
|
|
12
13
|
|
|
@@ -18,12 +19,21 @@ if (!lemonade && typeof (require) === 'function') {
|
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
self.onload = function() {
|
|
23
|
+
if (self.width) {
|
|
24
|
+
self.el.style.width = self.width;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
21
28
|
return `<label class="lm-switch" position="{{self.position}}">
|
|
22
29
|
<input type="checkbox" name="{{self.name}}" disabled="{{self.disabled}}" :bind="self.value" /> <span>{{self.text}}</span>
|
|
23
30
|
</label>`
|
|
24
31
|
}
|
|
25
32
|
|
|
33
|
+
// Create LemonadeJS references
|
|
26
34
|
lemonade.setComponents({ Switch: Switch });
|
|
35
|
+
// Create web-component
|
|
36
|
+
lemonade.createWebComponent('switch', Switch);
|
|
27
37
|
|
|
28
38
|
return function (root, options) {
|
|
29
39
|
if (typeof (root) === 'object') {
|
package/dist/react.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Official Type definitions for the LemonadeJS plugins
|
|
3
|
-
* https://lemonadejs.net
|
|
3
|
+
* https://lemonadejs.net/docs/plugins/switch
|
|
4
4
|
* Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
5
5
|
*/
|
|
6
6
|
import Component from './index';
|
|
7
7
|
|
|
8
8
|
interface Switch {
|
|
9
|
+
ref?: MutableRefObject<undefined>;
|
|
9
10
|
(): any
|
|
10
11
|
[key: string]: any
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
type Props = IntrinsicAttributes & Component.Options & Switch;
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
declare function Switch<Switch>(props: Props): any;
|
|
17
|
+
|
|
18
|
+
export default Switch;
|
package/dist/style.css
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
.lm-switch {
|
|
2
|
-
position: relative
|
|
3
|
-
display: inline-flex
|
|
2
|
+
position: relative;
|
|
3
|
+
display: inline-flex;
|
|
4
4
|
z-index: 0;
|
|
5
5
|
align-items: center;
|
|
6
6
|
}
|
|
@@ -63,15 +63,20 @@
|
|
|
63
63
|
|
|
64
64
|
.lm-switch > input:checked {
|
|
65
65
|
left: 6px;
|
|
66
|
-
background-color:
|
|
66
|
+
background-color: var(--lm-main-color, #2196f3);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.lm-switch > input:not(:checked) {
|
|
70
|
+
left: -10px;
|
|
71
|
+
background-color: var(--lm-secondary-color, #6A6A6A);
|
|
67
72
|
}
|
|
68
73
|
|
|
69
74
|
.lm-switch > input:checked + span::before {
|
|
70
|
-
background-color:
|
|
75
|
+
background-color: var(--lm-main-color-alpha, #2196f388);
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
.lm-switch > input:checked + span::after {
|
|
74
|
-
background-color:
|
|
79
|
+
background-color: var(--lm-main-color, #2196f3);
|
|
75
80
|
transform: translateX(16px);
|
|
76
81
|
}
|
|
77
82
|
|
|
@@ -95,11 +100,11 @@
|
|
|
95
100
|
}
|
|
96
101
|
|
|
97
102
|
.lm-switch > input:active + span::before {
|
|
98
|
-
background-color:
|
|
103
|
+
background-color: var(--lm-main-color-alpha, #2196f388);
|
|
99
104
|
}
|
|
100
105
|
|
|
101
106
|
.lm-switch > input:checked:active + span::before {
|
|
102
|
-
background-color: rgba(var(--lm-
|
|
107
|
+
background-color: rgba(var(--lm-front-color, 0,0,0), 0.38);
|
|
103
108
|
}
|
|
104
109
|
|
|
105
110
|
.lm-switch > input:disabled {
|
|
@@ -107,17 +112,17 @@
|
|
|
107
112
|
}
|
|
108
113
|
|
|
109
114
|
.lm-switch > input:disabled + span {
|
|
110
|
-
color: rgb(var(--lm-
|
|
111
|
-
opacity: 0.
|
|
115
|
+
color: rgb(var(--lm-front-color,0,0,0));
|
|
116
|
+
opacity: 0.50;
|
|
112
117
|
cursor: default;
|
|
113
118
|
}
|
|
114
119
|
|
|
115
120
|
.lm-switch > input:disabled + span::before {
|
|
116
|
-
background-color: rgba(var(--lm-
|
|
121
|
+
background-color: rgba(var(--lm-front-color,0,0,0), 0.38);
|
|
117
122
|
}
|
|
118
123
|
|
|
119
124
|
.lm-switch > input:checked:disabled + span::before {
|
|
120
|
-
background-color:
|
|
125
|
+
background-color: var(--lm-main-color-alpha, #2196f388);
|
|
121
126
|
}
|
|
122
127
|
|
|
123
128
|
.lm-switch[position="right"] > span {
|