@lemonadejs/switch 1.1.3 → 1.3.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 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/v4/)
107
+ - [jSuites](https://jsuites.net/docs)
73
108
  - [Jspreadsheet Data Grid](https://jspreadsheet.com)
package/dist/index.d.ts CHANGED
@@ -30,4 +30,11 @@ declare namespace Switch {
30
30
  }
31
31
  }
32
32
 
33
+ // Extend the global custom elements map
34
+ declare global {
35
+ interface HTMLElementTagNameMap {
36
+ 'lm-switch': Switch.Options;
37
+ }
38
+ }
39
+
33
40
  export default Switch;
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
 
@@ -14,7 +15,7 @@ if (!lemonade && typeof (require) === 'function') {
14
15
 
15
16
  self.onchange = function(prop, elements, s, oldValue, newValue) {
16
17
  if (oldValue !== newValue && typeof(onchange) === 'function') {
17
- onchange.call(self, self.value);
18
+ onchange.call(self, self, self.value);
18
19
  }
19
20
  }
20
21
 
@@ -23,7 +24,10 @@ if (!lemonade && typeof (require) === 'function') {
23
24
  </label>`
24
25
  }
25
26
 
27
+ // Create LemonadeJS references
26
28
  lemonade.setComponents({ Switch: Switch });
29
+ // Create web-component
30
+ lemonade.createWebComponent('switch', Switch);
27
31
 
28
32
  return function (root, options) {
29
33
  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
- declare function Switch<Switch>(props: Component.Options): any;
14
+ type SwitchProps = IntrinsicAttributes & Component.Options & Switch;
14
15
 
15
- export default Switch;
16
+ declare function Switch<Switch>(props: SwitchProps): any;
17
+
18
+ export default Switch;
package/dist/style.css CHANGED
@@ -63,15 +63,15 @@
63
63
 
64
64
  .lm-switch > input:checked {
65
65
  left: 6px;
66
- background-color: rgb(var(--pure-material-primary-rgb, 33,150,243));
66
+ background-color: var(--lm-main-color, #2196f3);
67
67
  }
68
68
 
69
69
  .lm-switch > input:checked + span::before {
70
- background-color: rgba(var(--pure-material-primary-rgb, 33,150,243), 0.6);
70
+ background-color: var(--lm-main-color-alpha, #2196f388);
71
71
  }
72
72
 
73
73
  .lm-switch > input:checked + span::after {
74
- background-color: rgb(var(--pure-material-primary-rgb, 33,150,243));
74
+ background-color: var(--lm-main-color, #2196f3);
75
75
  transform: translateX(16px);
76
76
  }
77
77
 
@@ -95,11 +95,11 @@
95
95
  }
96
96
 
97
97
  .lm-switch > input:active + span::before {
98
- background-color: rgba(var(--pure-material-primary-rgb, 33,150,243), 0.6);
98
+ background-color: var(--lm-main-color-alpha, #2196f388);
99
99
  }
100
100
 
101
101
  .lm-switch > input:checked:active + span::before {
102
- background-color: rgba(var(--lm-switch-front-color, 0,0,0), 0.38);
102
+ background-color: rgba(var(--lm-front-color, 0,0,0), 0.38);
103
103
  }
104
104
 
105
105
  .lm-switch > input:disabled {
@@ -107,17 +107,17 @@
107
107
  }
108
108
 
109
109
  .lm-switch > input:disabled + span {
110
- color: rgb(var(--lm-switch-front-color,0,0,0));
111
- opacity: 0.38;
110
+ color: rgb(var(--lm-front-color,0,0,0));
111
+ opacity: 0.50;
112
112
  cursor: default;
113
113
  }
114
114
 
115
115
  .lm-switch > input:disabled + span::before {
116
- background-color: rgba(var(--lm-switch-front-color,0,0,0), 0.38);
116
+ background-color: rgba(var(--lm-front-color,0,0,0), 0.38);
117
117
  }
118
118
 
119
119
  .lm-switch > input:checked:disabled + span::before {
120
- background-color: rgba(var(--pure-material-primary-rgb,33,150,243), 0.6);
120
+ background-color: var(--lm-main-color-alpha, #2196f388);
121
121
  }
122
122
 
123
123
  .lm-switch[position="right"] > span {
package/package.json CHANGED
@@ -13,8 +13,9 @@
13
13
  "switch js"
14
14
  ],
15
15
  "dependencies": {
16
- "lemonadejs": "^4.1.1"
16
+ "lemonadejs": "^4.3.0"
17
17
  },
18
18
  "main": "dist/index.js",
19
- "version": "1.1.3"
19
+ "types": "dist/index.d.ts",
20
+ "version": "1.3.0"
20
21
  }