@lemonadejs/tabs 1.0.2 → 1.1.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
@@ -44,7 +44,11 @@ import "@lemonadejs/tabs/dist/style.css"
44
44
  export default function Component() {
45
45
  const self = this;
46
46
 
47
- return `<Tabs>
47
+ self.open = (index) => {
48
+ console.log(index)
49
+ }
50
+
51
+ return `<Tabs :onopen="self.open">
48
52
  <div title="Tab 1">Content of the first tab</div>
49
53
  <div title="Tab 2">Content of the second tab</div>
50
54
  </Tabs>`;
@@ -59,17 +63,18 @@ You can configure things such as tabs titles, tabs contents and selected tab.
59
63
 
60
64
  #### Tabs Properties
61
65
 
62
- | Property | Type | Description |
63
- | -------- | ---- | ----------- |
64
- | data? | array | An optional alternative method to provide the title and content that will serve as the basis for rendering the tabs. |
65
- | selected? | number | The index of the initially selected tab. Starts from 0. |
66
- | position? | string | The position of the tabs bar within the parent element. Use 'center' to center-align the tabs. |
66
+ | Property | Type | Description |
67
+ |-----------|----------|----------------------------------------------------------------------------------------------------------------------|
68
+ | data? | array | An optional alternative method to provide the title and content that will serve as the basis for rendering the tabs. |
69
+ | selected? | number | The index of the initially selected tab. Starts from 0. |
70
+ | position? | string | The position of the tabs bar within the parent element. Use 'center' to center-align the tabs. |
71
+ | onopen? | function | When a new tabs is opened. |
67
72
 
68
73
  ## License
69
74
 
70
- The [LemonadeJS](https://lemonadejs.net) tabs is released under the MIT.
75
+ The [LemonadeJS](https://lemonadejs.net) Tabs is released under the MIT.
71
76
 
72
77
  ## Other Tools
73
78
 
74
79
  - [jSuites](https://jsuites.net/v4/)
75
- - [Jspreadsheet](https://jspreadsheet.com)
80
+ - [Jspreadsheet Data Grid](https://jspreadsheet.com)
package/dist/index.d.ts CHANGED
@@ -13,6 +13,7 @@ interface options {
13
13
  data?: object[];
14
14
  selected?: number;
15
15
  position?: number;
16
+ onopen?: (index: number) => void;
16
17
  }
17
18
 
18
19
  interface instance {
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- if (!lemonade && typeof (require) === 'function') {
1
+ if (! lemonade && typeof(require) === 'function') {
2
2
  var lemonade = require('lemonadejs');
3
3
  }
4
4
 
@@ -46,6 +46,10 @@ if (!lemonade && typeof (require) === 'function') {
46
46
  self.onchange = function (property) {
47
47
  if (property === 'selected') {
48
48
  select(self.selected);
49
+
50
+ if (typeof(self.onopen) === 'function') {
51
+ self.onopen.call(self, self.selected);
52
+ }
49
53
  }
50
54
  }
51
55
 
@@ -55,8 +59,8 @@ if (!lemonade && typeof (require) === 'function') {
55
59
  }
56
60
  }
57
61
 
58
- return `<div class="lm-tabs" position="{{self.position||''}}">
59
- <ul :ref="self.headers" :loop="self.tabs" onclick="self.click(e, this)" :selected="self.selected"><li class="lm-tab-list-item">{{self.title}}</li></ul>
62
+ return `<div class="lm-tabs" :position="self.position">
63
+ <ul :ref="self.headers" :loop="self.tabs" :selected="self.selected" onclick="self.click(e, this)"><li class="lm-tab-list-item">{{self.title}}</li></ul>
60
64
  <div :ref="self.content" class="lm-tabs-content">${content}</div>
61
65
  </div>`
62
66
  }
@@ -65,7 +69,12 @@ if (!lemonade && typeof (require) === 'function') {
65
69
 
66
70
  return function (root, options) {
67
71
  if (typeof (root) === 'object') {
68
- lemonade.render(Tabs, root, options)
72
+ // Get HTML inside the wrapper element then empty it
73
+ const template = root.innerHTML
74
+ root.innerHTML = ''
75
+
76
+ // Send Template as a parameter for the Lemonade component
77
+ lemonade.render(Tabs, root, options, template)
69
78
  return options;
70
79
  } else {
71
80
  return Tabs.call(this, root)
package/dist/style.css CHANGED
@@ -1,6 +1,3 @@
1
- .lm-tabs {
2
- }
3
-
4
1
  .lm-tabs .lm-tabs-content > div {
5
2
  padding: 10px;
6
3
  }
package/package.json CHANGED
@@ -13,8 +13,8 @@
13
13
  "tabs js"
14
14
  ],
15
15
  "dependencies": {
16
- "lemonadejs": "^3.3.1"
16
+ "lemonadejs": "^3.4.0"
17
17
  },
18
18
  "main": "dist/index.js",
19
- "version": "1.0.2"
19
+ "version": "1.1.0"
20
20
  }
package/src/index.html ADDED
@@ -0,0 +1,16 @@
1
+ <script src="https://cdn.jsdelivr.net/npm/lemonadejs@3.3.1/dist/lemonade.min.js"></script>
2
+ <script src="../dist/index.js"></script>
3
+ <link rel="stylesheet" href="../dist/style.css" />
4
+
5
+ <div id="tabs">
6
+ <div title="Tab 1">Content of the first tab</div>
7
+ <div title="Tab 2">Content of the second tab</div>
8
+ </div>
9
+
10
+ <script>
11
+ const root = document.getElementById("tabs");
12
+
13
+ Tabs(root, {
14
+ selected: 0
15
+ });
16
+ </script>