@lemonadejs/tabs 2.0.4 → 2.2.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
@@ -1,88 +1,129 @@
1
- # LemonadeJS Tabs
2
-
3
- [Official website and documentation is here](https://lemonadejs.net/components/tabs)
4
-
5
- Compatible with Vanilla JavaScript, LemonadeJS, React, Vue or Angular.
6
-
7
- The LemonadeJS JavaScript Tabs is a responsive and reactive component that creates selected tabs.
8
-
9
- ## Features
10
-
11
- - Lightweight: The JavaScript Tabs is only about 2 KBytes;
12
- - Integration: It can be used as a standalone library or integrated with any modern framework;
13
-
14
- ## Getting Started
15
-
16
- You can install using NPM or using directly from a CDN.
17
-
18
- ### npm Installation
19
-
20
- To install it in your project using npm, run the following command:
21
-
22
- ```bash
23
- $ npm install @lemonadejs/tabs
24
- ```
25
-
26
- ### CDN
27
-
28
- To use tabs via a CDN, include the following script tags in your HTML file:
29
-
30
- ```html
31
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/lemonadejs/dist/lemonade.min.js"></script>
32
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@lemonadejs/tabs/dist/index.min.js"></script>
33
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@lemonadejs/tabs/dist/style.min.css" />
34
- ```
35
-
36
- ### Usage
37
-
38
- Quick example with Lemonade
39
-
40
- ```javascript
41
- import lemonade from 'lemonadejs'
42
- import Tabs from '@lemonadejs/tabs';
43
- import '@lemonadejs/tabs/dist/style.css';
44
-
45
- export default function App() {
46
- const self = this;
47
-
48
- return `<div>
49
- <Tabs :selected="0">
50
- <div title="Tab 1">Content of the first tab</div>
51
- <div title="Tab 2">Content of the second tab</div>
52
- </Tabs>
53
- </div>`
54
- }
55
- ```
56
-
57
- [You can find more examples here in the official documentation.](https://lemonadejs.net/components/tabs)
58
-
59
- ### Configuration
60
-
61
- You can configure things such as tabs titles, tabs contents and selected tab.
62
-
63
- #### Settings
64
-
65
- | Property | Type | Description |
66
- | -------- | ---- | ----------- |
67
- | selected? | number | The index of the initially selected tab. Starts from 0. |
68
- | position? | string | The position of the tabs bar within the parent element. Use 'center' to center-align the tabs. |
69
- | data? | tabItem[] | An optional alternative method to provide the title and content that will serve as the basis for rendering the tabs. See more about the `tabItem` object in the Tab Item section below. |
70
- | round? | boolean | Dictates whether the tab style will feature rounded corners. |
71
- | onopen? | function | When a new tabs is opened. |
72
-
73
- #### Tab Item
74
-
75
- | Property | Description |
76
- | -------- | ----------- |
77
- | title | The title of the tab, serving as the label displayed on the tab options. |
78
- | content | The HTML content intended for this specific tab. |
79
-
80
-
81
- ## License
82
-
83
- The [LemonadeJS](https://lemonadejs.net) Tabs is released under the MIT.
84
-
85
- ## Other Tools
86
-
87
- - [jSuites](https://jsuites.net)
88
- - [Jspreadsheet Data Grid](https://jspreadsheet.com)
1
+ # LemonadeJS Tabs
2
+
3
+ [Official website and documentation is here](https://lemonadejs.net/components/tabs)
4
+
5
+ Compatible with Vanilla JavaScript, LemonadeJS, React, Vue or Angular.
6
+
7
+ The LemonadeJS JavaScript Tabs is a responsive and reactive component that creates selected tabs.
8
+
9
+ ## Features
10
+
11
+ - Lightweight: The JavaScript Tabs is only about 2 KBytes;
12
+ - Integration: It can be used as a standalone library or integrated with any modern framework;
13
+
14
+ ## Getting Started
15
+
16
+ You can install using NPM or using directly from a CDN.
17
+
18
+ ### npm Installation
19
+
20
+ To install it in your project using npm, run the following command:
21
+
22
+ ```bash
23
+ $ npm install @lemonadejs/tabs
24
+ ```
25
+
26
+ ### CDN
27
+
28
+ To use tabs via a CDN, include the following script tags in your HTML file:
29
+
30
+ ```html
31
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/lemonadejs/dist/lemonade.min.js"></script>
32
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@lemonadejs/tabs/dist/index.min.js"></script>
33
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@lemonadejs/tabs/dist/style.min.css" />
34
+ ```
35
+
36
+ ### Usage
37
+
38
+ Quick example with Lemonade
39
+
40
+ ```javascript
41
+ import lemonade from 'lemonadejs'
42
+ import Tabs from '@lemonadejs/tabs';
43
+ import '@lemonadejs/tabs/dist/style.css';
44
+
45
+ export default function App() {
46
+ const self = this;
47
+
48
+ return `<div>
49
+ <Tabs :selected="0">
50
+ <div title="Tab 1">Content of the first tab</div>
51
+ <div title="Tab 2">Content of the second tab</div>
52
+ </Tabs>
53
+ </div>`
54
+ }
55
+ ```
56
+
57
+ Quick example with React
58
+
59
+ ```jsx
60
+ import React, { useRef } from "react";
61
+ import Tabs from "@lemonadejs/tabs/dist/react";
62
+ import '@lemonadejs/tabs/dist/style.css';
63
+
64
+ const data = [{ title: 'Tab 1', content: 'Content of first tab' }, { title: 'Tab 2', content: 'Content of second tab' }]
65
+ export default function App() {
66
+ const tabs = useRef();
67
+ return (
68
+ <>
69
+ <Tabs selected={0} ref={tabs} data={data}/>
70
+ </>
71
+ );
72
+ }
73
+ ```
74
+
75
+ Quick example with React
76
+
77
+ ```vue
78
+ <template>
79
+ <Tabs :selected="0">
80
+ <div title="Tab 1">Content of the first tab</div>
81
+ <div title="Tab 2">Content of the second tab</div>
82
+ </Tabs>
83
+ </template>
84
+
85
+ <script>
86
+ import Tabs from '@lemonadejs/tabs/dist/vue';
87
+ import '@lemonadejs/tabs/dist/style.css';
88
+
89
+ export default {
90
+ name: 'App',
91
+ components: {
92
+ Tabs,
93
+ },
94
+ };
95
+ </script>
96
+ ```
97
+
98
+ [You can find more examples here in the official documentation.](https://lemonadejs.net/components/tabs)
99
+
100
+ ### Configuration
101
+
102
+ You can configure things such as tabs titles, tabs contents and selected tab.
103
+
104
+ #### Settings
105
+
106
+ | Property | Type | Description |
107
+ | -------- | ---- | ----------- |
108
+ | selected? | number | The index of the initially selected tab. Starts from 0. |
109
+ | position? | string | The position of the tabs bar within the parent element. Use 'center' to center-align the tabs. |
110
+ | data? | tabItem[] | An optional alternative method to provide the title and content that will serve as the basis for rendering the tabs. See more about the `tabItem` object in the Tab Item section below. |
111
+ | round? | boolean | Dictates whether the tab style will feature rounded corners. |
112
+ | onopen? | function | When a new tabs is opened. |
113
+
114
+ #### Tab Item
115
+
116
+ | Property | Description |
117
+ | -------- | ----------- |
118
+ | title | The title of the tab, serving as the label displayed on the tab options. |
119
+ | content | The HTML content intended for this specific tab. |
120
+
121
+
122
+ ## License
123
+
124
+ The [LemonadeJS](https://lemonadejs.net) Tabs is released under the MIT.
125
+
126
+ ## Other Tools
127
+
128
+ - [jSuites](https://jsuites.net)
129
+ - [Jspreadsheet Data Grid](https://jspreadsheet.com)
package/dist/index.d.ts CHANGED
@@ -1,42 +1,42 @@
1
- /**
2
- * Official Type definitions for LemonadeJS plugins
3
- * https://lemonadejs.net
4
- * Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
- */
6
- declare function Tabs(el: HTMLElement, options?: Tabs.Options): Tabs.Instance;
7
-
8
- declare namespace Tabs {
9
-
10
- interface Items {
11
- title: string,
12
- content: string,
13
- }
14
-
15
- interface Options {
16
- /** Programmatically content */
17
- data?: Items[];
18
- /** Selected tab */
19
- selected?: number;
20
- /** Tabs position */
21
- position?: 'center' | undefined;
22
- /** Activate round borders */
23
- round?: boolean;
24
- /** On open event */
25
- onopen?: (index: number) => void;
26
- }
27
-
28
- interface Instance {
29
- /** Programmatically content */
30
- data?: Items[];
31
- /** Selected tab */
32
- selected: number;
33
- /** Tabs position */
34
- position?: 'center' | undefined;
35
- /** Activate round borders */
36
- round?: boolean;
37
- /** On open event */
38
- onopen?: (index: number) => void;
39
- }
40
- }
41
-
1
+ /**
2
+ * Official Type definitions for LemonadeJS plugins
3
+ * https://lemonadejs.net
4
+ * Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
+ */
6
+ declare function Tabs(el: HTMLElement, options?: Tabs.Options): Tabs.Instance;
7
+
8
+ declare namespace Tabs {
9
+
10
+ interface Items {
11
+ title: string,
12
+ content: string,
13
+ }
14
+
15
+ interface Options {
16
+ /** Programmatically content */
17
+ data?: Items[];
18
+ /** Selected tab */
19
+ selected?: number;
20
+ /** Tabs position */
21
+ position?: 'center' | undefined;
22
+ /** Activate round borders */
23
+ round?: boolean;
24
+ /** On open event */
25
+ onopen?: (index: number) => void;
26
+ }
27
+
28
+ interface Instance {
29
+ /** Programmatically content */
30
+ data?: Items[];
31
+ /** Selected tab */
32
+ selected: number;
33
+ /** Tabs position */
34
+ position?: 'center' | undefined;
35
+ /** Activate round borders */
36
+ round?: boolean;
37
+ /** On open event */
38
+ onopen?: (index: number) => void;
39
+ }
40
+ }
41
+
42
42
  export default Tabs;
package/dist/index.js CHANGED
@@ -1,85 +1,145 @@
1
- if (!lemonade && typeof (require) === 'function') {
2
- var lemonade = require('lemonadejs');
3
- }
4
-
5
- ; (function (global, factory) {
6
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
7
- typeof define === 'function' && define.amd ? define(factory) :
8
- global.Tabs = factory();
9
- }(this, (function () {
10
-
11
- const Tabs = function (html) {
12
- let self = this
13
-
14
- let content = html;
15
-
16
- if (self.data) {
17
- for (let i = 0; i < self.data.length; i++) {
18
- content += `<div title="${self.data[i].title}">${self.data[i].content}</div>`;
19
- }
20
- }
21
-
22
- self.tabs = [];
23
-
24
- const select = function (index) {
25
- index = parseInt(index);
26
-
27
- for (let i = 0; i < self.content.children.length; i++) {
28
- self.headers.children[i].classList.remove('selected');
29
- self.content.children[i].classList.remove('selected');
30
- }
31
- self.headers.children[index].classList.add('selected');
32
- self.content.children[index].classList.add('selected');
33
- }
34
-
35
- self.onload = function () {
36
- for (let i = 0; i < self.content.children.length; i++) {
37
- self.tabs.push({ title: self.content.children[i].title });
38
- }
39
- self.refresh('tabs');
40
-
41
- let index = 0;
42
- if (! isNaN(parseInt(self.selected))) {
43
- index = parseInt(self.selected);
44
- }
45
- select(index);
46
- }
47
-
48
- self.onchange = function (property) {
49
- if (property === 'selected') {
50
- select(self.selected);
51
-
52
- if (typeof(self.onopen) === 'function') {
53
- self.onopen.call(self, self.selected);
54
- }
55
- }
56
- }
57
-
58
- self.click = function (e) {
59
- if (e.target.tagName === 'LI') {
60
- self.selected = Array.prototype.indexOf.call(e.target.parentNode.children, e.target);
61
- }
62
- }
63
-
64
- return `<div class="lm-tabs" data-position="{{self.position}}" data-round="{{self.round}}">
65
- <ul :ref="self.headers" :loop="self.tabs" :selected="self.selected" onclick="self.click"><li class="lm-tab-list-item">{{self.title}}</li></ul>
66
- <div :ref="self.content" class="lm-tabs-content">${content}</div>
67
- </div>`
68
- }
69
-
70
- lemonade.setComponents({ Tabs: Tabs });
71
-
72
- return function (root, options) {
73
- if (typeof (root) === 'object') {
74
- // Get HTML inside the wrapper element then empty it
75
- const template = root.innerHTML
76
- root.innerHTML = ''
77
-
78
- // Send Template as a parameter for the Lemonade component
79
- lemonade.render(Tabs, root, options, template)
80
- return options;
81
- } else {
82
- return Tabs.call(this, root);
83
- }
84
- }
1
+ if (! lemonade && typeof (require) === 'function') {
2
+ var lemonade = require('lemonadejs');
3
+ }
4
+
5
+ ; (function (global, factory) {
6
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
7
+ typeof define === 'function' && define.amd ? define(factory) :
8
+ global.Tabs = factory();
9
+ }(this, (function () {
10
+
11
+ // Dispatcher
12
+ const Dispatch = function(type){
13
+ if (typeof this[type] === 'function') {
14
+ let args = Array.from(arguments);
15
+ args.shift();
16
+ this[type](...args)
17
+ }
18
+ }
19
+
20
+ const Tabs = function (html) {
21
+ let self = this
22
+ let elements = [];
23
+
24
+ if (this.tagName) {
25
+ // Remove elements from the DOM
26
+ elements = removeElements(this);
27
+ }
28
+
29
+ if (self.data) {
30
+ for (let i = 0; i < self.data.length; i++) {
31
+ let d = document.createElement('div');
32
+ d.title = self.data[i].title;
33
+ d.innerHTML = self.data[i].content;
34
+ elements.push(d);
35
+ }
36
+ }
37
+
38
+ if (! html) {
39
+ html = '';
40
+ }
41
+
42
+ self.tabs = [];
43
+
44
+ const select = function (index) {
45
+ index = parseInt(index);
46
+
47
+ // Do not select tabs that does not exist
48
+ if (index >= 0 && index < self.tabs.length) {
49
+ for (let i = 0; i < self.content.children.length; i++) {
50
+ self.headers.children[i].classList.remove('selected');
51
+ self.content.children[i].classList.remove('selected');
52
+ }
53
+ self.headers.children[index].classList.add('selected');
54
+ self.content.children[index].classList.add('selected');
55
+ }
56
+ }
57
+
58
+ self.onload = function () {
59
+ // Append elements to the container
60
+ appendElements(self.el.children[1], elements);
61
+
62
+ for (let i = 0; i < self.content.children.length; i++) {
63
+ self.tabs.push({ title: self.content.children[i].title });
64
+ }
65
+ self.refresh('tabs');
66
+
67
+ let index = 0;
68
+ if (! isNaN(parseInt(self.selected))) {
69
+ index = parseInt(self.selected);
70
+ }
71
+ select(index);
72
+ }
73
+
74
+
75
+ self.onchange = function (property) {
76
+ if (property === 'selected') {
77
+ select(self.selected);
78
+
79
+ Dispatch.call(self, 'onopen', self, self.selected);
80
+ }
81
+ }
82
+
83
+ self.keydown = function(e) {
84
+ if (e.key === 'Enter') {
85
+ self.click(e);
86
+ }
87
+ }
88
+
89
+ self.click = function (e) {
90
+ if (e.target.tagName === 'LI') {
91
+ // Avoid select something already selected
92
+ let index = Array.prototype.indexOf.call(e.target.parentNode.children, e.target);
93
+ if (index !== self.selected) {
94
+ self.selected = index;
95
+ }
96
+ }
97
+ }
98
+
99
+ return `<div class="lm-tabs" data-position="{{self.position}}" data-round="{{self.round}}">
100
+ <ul :ref="self.headers" :loop="self.tabs" :selected="self.selected" onclick="self.click" onkeydown="self.keydown" role="tabs"><li class="lm-tab-list-item" tabindex="0" role="tab">{{self.title}}</li></ul>
101
+ <div :ref="self.content" class="lm-tabs-content">${html}</div>
102
+ </div>`
103
+ }
104
+
105
+ const removeElements = function(root) {
106
+ // Keep the DOM elements
107
+ let elements = [];
108
+ if (root) {
109
+ while (root.firstChild) {
110
+ elements.push(root.firstChild);
111
+ root.firstChild.remove();
112
+ }
113
+ }
114
+ return elements;
115
+ }
116
+
117
+ const appendElements = function(root, elements) {
118
+ if (elements && elements.length) {
119
+ while (elements[0]) {
120
+ root.appendChild(elements.shift());
121
+ }
122
+ }
123
+ }
124
+
125
+ const Component = function (root, options) {
126
+ if (typeof (root) === 'object') {
127
+ // Remove elements from the DOM
128
+ let elements = removeElements(root);
129
+ // Create the modal
130
+ let e = lemonade.render(Tabs, root, options);
131
+ // Add elements to the container
132
+ appendElements(e.children[1], elements);
133
+
134
+ return options;
135
+ } else {
136
+ return Tabs.call(this);
137
+ }
138
+ }
139
+
140
+ lemonade.setComponents({ Tabs: Tabs });
141
+
142
+ lemonade.createWebComponent('tabs', Tabs);
143
+
144
+ return Component;
85
145
  })));
package/dist/react.d.ts CHANGED
@@ -1,15 +1,18 @@
1
- /**
2
- * Official Type definitions for the LemonadeJS plugins
3
- * https://lemonadejs.net
4
- * Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
- */
6
- import Component from './index';
7
-
8
- interface Tabs {
9
- (): any
10
- [key: string]: any
11
- }
12
-
13
- declare function Tabs<Tabs>(props: Component.Options): any;
14
-
15
- export default Tabs;
1
+ /**
2
+ * Official Type definitions for the LemonadeJS plugins
3
+ * https://lemonadejs.net
4
+ * Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
+ */
6
+ import Component from './index';
7
+
8
+ interface Tabs {
9
+ ref?: MutableRefObject<undefined>;
10
+ (): any
11
+ [key: string]: any
12
+ }
13
+
14
+ type Props = IntrinsicAttributes & Component.Options & Tabs;
15
+
16
+ declare function Tabs<Tabs>(props: Props): any;
17
+
18
+ export default Tabs;
package/dist/react.js CHANGED
@@ -1,37 +1,37 @@
1
- import React, { useRef, useEffect } from "react";
2
- import { renderToStaticMarkup } from 'react-dom/server';
3
- import Component from './index';
4
-
5
-
6
- export default React.forwardRef((props, mainReference) => {
7
- // Dom element
8
- const Ref = useRef(null);
9
-
10
- const template = renderToStaticMarkup(props.children)
11
-
12
- // Get the properties for the spreadsheet
13
- let options = { ...props };
14
-
15
- useEffect(() => {
16
- if (!Ref.current.innerHTML) {
17
- mainReference.current = Component(Ref.current, options, template);
18
- }
19
- }, []);
20
-
21
- useEffect(() => {
22
- for (let key in props) {
23
- if (props.hasOwnProperty(key) && mainReference.current.hasOwnProperty(key)) {
24
- if (props[key] !== mainReference.current[key]) {
25
- mainReference.current[key] = props[key];
26
- }
27
- }
28
- }
29
- }, [props])
30
-
31
- let prop = {
32
- ref: Ref,
33
- style: { height: '100%', width: '100%' }
34
- };
35
-
36
- return React.createElement("div", prop);
1
+ import React, { useRef, useEffect } from "react";
2
+ import { renderToStaticMarkup } from 'react-dom/server';
3
+ import Component from './index';
4
+
5
+
6
+ export default React.forwardRef((props, mainReference) => {
7
+ // Dom element
8
+ const Ref = useRef(null);
9
+
10
+ const template = renderToStaticMarkup(props.children)
11
+
12
+ // Get the properties for the spreadsheet
13
+ let options = { ...props };
14
+
15
+ useEffect(() => {
16
+ if (!Ref.current.innerHTML) {
17
+ mainReference.current = Component(Ref.current, options, template);
18
+ }
19
+ }, []);
20
+
21
+ useEffect(() => {
22
+ for (let key in props) {
23
+ if (props.hasOwnProperty(key) && mainReference.current.hasOwnProperty(key)) {
24
+ if (props[key] !== mainReference.current[key]) {
25
+ mainReference.current[key] = props[key];
26
+ }
27
+ }
28
+ }
29
+ }, [props])
30
+
31
+ let prop = {
32
+ ref: Ref,
33
+ style: { height: '100%', width: '100%' }
34
+ };
35
+
36
+ return React.createElement("div", prop);
37
37
  })
package/dist/style.css CHANGED
@@ -1,61 +1,62 @@
1
- .lm-tabs .lm-tabs-content > div {
2
- padding: 10px;
3
- }
4
-
5
- .lm-tabs > ul {
6
- list-style-type: none;
7
- display: flex;
8
- margin: 0;
9
- padding: 0;
10
- width: 100%;
11
- }
12
-
13
- .lm-tabs > ul > li {
14
- cursor: pointer;
15
- user-select: none;
16
- padding: 4px 12px 4px 12px;
17
- border: 1px solid #ccc;
18
- background-position: center;
19
- transition: background 0.8s;
20
- }
21
-
22
- .lm-tabs > ul > li.selected {
23
- background-color: #eee;
24
- }
25
-
26
- .lm-tabs[data-round="true"] > ul > li:first-child {
27
- border-top-left-radius: 3px;
28
- border-bottom-left-radius: 3px;
29
- }
30
-
31
- .lm-tabs[data-round="true"] > ul > li:last-child {
32
- border-top-right-radius: 3px;
33
- border-bottom-right-radius: 3px;
34
- }
35
-
36
- .lm-tabs > ul > li:not(:first-child) {
37
- border-left: 0;
38
- }
39
-
40
- .lm-tabs > ul > li:hover {
41
- background: #eee radial-gradient(circle, transparent 1%, #eee 1%) center/15000%;
42
- }
43
-
44
- .lm-tabs > ul > li:active {
45
- background-color: #ddd;
46
- background-size: 100%;
47
- transition: background 0s;
48
- }
49
-
50
- .lm-tabs .lm-tabs-content > div {
51
- display: none;
52
- }
53
-
54
- .lm-tabs .lm-tabs-content > div.selected {
55
- display: block;
56
- }
57
-
58
- .lm-tabs[data-position="center"] > ul {
59
- margin: 0 auto;
60
- justify-content: center;
1
+ .lm-tabs .lm-tabs-content > div {
2
+ padding: 15px 5px;
3
+ }
4
+
5
+ .lm-tabs > ul {
6
+ list-style-type: none;
7
+ display: flex;
8
+ margin: 0;
9
+ padding: 0;
10
+ width: 100%;
11
+ }
12
+
13
+ .lm-tabs > ul > li {
14
+ cursor: pointer;
15
+ user-select: none;
16
+ padding: 6px 24px;
17
+ border: 1px solid #ccc;
18
+ background-position: center;
19
+ transition: background 0.8s;
20
+ }
21
+
22
+ .lm-tabs > ul > li.selected {
23
+ background-color: #eee;
24
+ color: #000;
25
+ }
26
+
27
+ .lm-tabs[data-round="true"] > ul > li:first-child {
28
+ border-top-left-radius: 3px;
29
+ border-bottom-left-radius: 3px;
30
+ }
31
+
32
+ .lm-tabs[data-round="true"] > ul > li:last-child {
33
+ border-top-right-radius: 3px;
34
+ border-bottom-right-radius: 3px;
35
+ }
36
+
37
+ .lm-tabs > ul > li:not(:first-child) {
38
+ border-left: 0;
39
+ }
40
+
41
+ .lm-tabs > ul > li:hover {
42
+ background: #eee radial-gradient(circle, transparent 1%, #eee 1%) center/15000%;
43
+ }
44
+
45
+ .lm-tabs > ul > li:active {
46
+ background-color: #ddd;
47
+ background-size: 100%;
48
+ transition: background 0s;
49
+ }
50
+
51
+ .lm-tabs .lm-tabs-content > div {
52
+ display: none;
53
+ }
54
+
55
+ .lm-tabs .lm-tabs-content > div.selected {
56
+ display: block;
57
+ }
58
+
59
+ .lm-tabs[data-position="center"] > ul {
60
+ margin: 0 auto;
61
+ justify-content: center;
61
62
  }
package/dist/vue.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- /**
2
- * Official Type definitions for the LemonadeJS plugins
3
- * https://lemonadejs.net
4
- * Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
- */
6
- import Component from './index';
7
-
8
- interface Tabs {
9
- (): any
10
- [key: string]: any
11
- }
12
-
13
- declare function Tabs<Tabs>(props: Component.Options): any;
14
-
15
- export default Tabs;
1
+ /**
2
+ * Official Type definitions for the LemonadeJS plugins
3
+ * https://lemonadejs.net
4
+ * Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
+ */
6
+ import Component from './index';
7
+
8
+ interface Tabs {
9
+ (): any
10
+ [key: string]: any
11
+ }
12
+
13
+ declare function Tabs<Tabs>(props: Component.Options): any;
14
+
15
+ export default Tabs;
package/dist/vue.js CHANGED
@@ -1,54 +1,54 @@
1
- import { h } from 'vue';
2
- import component from "./index.js";
3
-
4
- export const Tabs = {
5
- inheritAttrs: false,
6
- mounted() {
7
- let options = {
8
- ...this.$attrs
9
- };
10
-
11
- this.el = this.$refs.container;
12
-
13
- this.current = component(this.el, options);
14
-
15
- },
16
- setup(_, context) {
17
- let containerProps = {
18
- ref: 'container',
19
- style: {
20
- width: '100%',
21
- height: '100%',
22
- }
23
- };
24
-
25
- let vnode = [];
26
-
27
- if (context.slots.default && typeof(context.slots.default) === 'function') {
28
- vnode = context.slots.default()
29
- }
30
-
31
- return () => h('div', containerProps, vnode);
32
- },
33
- watch: {
34
- $attrs: {
35
- deep: true,
36
- handler() {
37
- this.updateState();
38
- }
39
- }
40
- },
41
- methods: {
42
- updateState() {
43
- for (let key in this.$attrs) {
44
- if (this.$attrs.hasOwnProperty(key) && this.current.hasOwnProperty(key)) {
45
- if (this.$attrs[key] !== this.current[key]) {
46
- this.current[key] = this.$attrs[key];
47
- }
48
- }
49
- }
50
- }
51
- }
52
- };
53
-
1
+ import { h } from 'vue';
2
+ import component from "./index.js";
3
+
4
+ export const Tabs = {
5
+ inheritAttrs: false,
6
+ mounted() {
7
+ let options = {
8
+ ...this.$attrs
9
+ };
10
+
11
+ this.el = this.$refs.container;
12
+
13
+ this.current = component(this.el, options);
14
+
15
+ },
16
+ setup(_, context) {
17
+ let containerProps = {
18
+ ref: 'container',
19
+ style: {
20
+ width: '100%',
21
+ height: '100%',
22
+ }
23
+ };
24
+
25
+ let vnode = [];
26
+
27
+ if (context.slots.default && typeof(context.slots.default) === 'function') {
28
+ vnode = context.slots.default()
29
+ }
30
+
31
+ return () => h('div', containerProps, vnode);
32
+ },
33
+ watch: {
34
+ $attrs: {
35
+ deep: true,
36
+ handler() {
37
+ this.updateState();
38
+ }
39
+ }
40
+ },
41
+ methods: {
42
+ updateState() {
43
+ for (let key in this.$attrs) {
44
+ if (this.$attrs.hasOwnProperty(key) && this.current.hasOwnProperty(key)) {
45
+ if (this.$attrs[key] !== this.current[key]) {
46
+ this.current[key] = this.$attrs[key];
47
+ }
48
+ }
49
+ }
50
+ }
51
+ }
52
+ };
53
+
54
54
  export default Tabs;
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
- {
2
- "name": "@lemonadejs/tabs",
3
- "title": "JavaScript Tabs",
4
- "description": "LemonadeJS tabs is a JavaScript component to create tabs.",
5
- "author": {
6
- "name": "Contact <contact@lemonadejs.net>",
7
- "url": "https://lemonadejs.net"
8
- },
9
- "keywords": [
10
- "javascript tabs",
11
- "lemonadejs tabs",
12
- "js tabs",
13
- "tabs js"
14
- ],
15
- "dependencies": {
16
- "lemonadejs": "^4.0.7"
17
- },
18
- "main": "dist/index.js",
19
- "version": "2.0.4"
20
- }
1
+ {
2
+ "name": "@lemonadejs/tabs",
3
+ "title": "JavaScript Tabs",
4
+ "description": "LemonadeJS tabs is a JavaScript component to create tabs.",
5
+ "author": {
6
+ "name": "Contact <contact@lemonadejs.net>",
7
+ "url": "https://lemonadejs.net"
8
+ },
9
+ "keywords": [
10
+ "javascript tabs",
11
+ "lemonadejs tabs",
12
+ "js tabs",
13
+ "tabs js"
14
+ ],
15
+ "dependencies": {
16
+ "lemonadejs": "^4.3.3"
17
+ },
18
+ "main": "dist/index.js",
19
+ "version": "2.2.0"
20
+ }