@neovici/cosmoz-tabs 8.4.0 → 8.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-tabs",
3
- "version": "8.4.0",
3
+ "version": "8.5.0",
4
4
  "description": "A multi views container element that allow navigation between the views using tabs or an accordion.",
5
5
  "keywords": [
6
6
  "web-components"
@@ -31,7 +31,7 @@
31
31
  "test:watch": "wtr --watch",
32
32
  "storybook:build": "build-storybook",
33
33
  "storybook:deploy": "storybook-to-ghpages",
34
- "prepare": "husky install"
34
+ "prepare": "husky"
35
35
  },
36
36
  "release": {
37
37
  "plugins": [
@@ -74,7 +74,7 @@
74
74
  "@pionjs/pion": "^2.0.0",
75
75
  "@polymer/iron-icon": "^3.0.0",
76
76
  "@polymer/iron-icons": "^3.0.0",
77
- "compute-scroll-into-view": "^1.0.17",
77
+ "compute-scroll-into-view": "^3.0.0",
78
78
  "lit-html": "^2.0.0 || ^3.0.0"
79
79
  },
80
80
  "devDependencies": {
@@ -87,7 +87,7 @@
87
87
  "@semantic-release/git": "^10.0.0",
88
88
  "@storybook/storybook-deployer": "^2.8.0",
89
89
  "@web/dev-server-storybook": "^2.0.0",
90
- "husky": "^8.0.0",
90
+ "husky": "^9.0.0",
91
91
  "semantic-release": "^23.0.0",
92
92
  "sinon": "^17.0.0",
93
93
  "typescript": "^5.0.0"
@@ -45,7 +45,7 @@ const CosmozTabCard = (host) => {
45
45
  host.toggleAttribute('collapsed', collapsed);
46
46
  }, [collapsed]);
47
47
 
48
- return html`<div id="header" part="header">
48
+ return html`<div class="header" part="header">
49
49
  ${when(
50
50
  collapsable,
51
51
  () => html`
@@ -64,8 +64,8 @@ const CosmozTabCard = (host) => {
64
64
  <slot name="card-actions"></slot>
65
65
  </div>
66
66
 
67
- <cosmoz-collapse ?opened=${!collapsed}>
68
- <div id="content" part="content">
67
+ <cosmoz-collapse class="collapse" ?opened=${!collapsed}>
68
+ <div class="content" part="content">
69
69
  <slot></slot>
70
70
  </div>
71
71
  </cosmoz-collapse> `;
@@ -88,12 +88,17 @@ const style = css`
88
88
  );
89
89
  }
90
90
 
91
- #content {
91
+ .collapse {
92
+ display: flex:;
93
+ flex: auto;
94
+ }
95
+
96
+ .content {
92
97
  line-height: var(--cosmoz-tab-card-content-line-height, initial);
93
98
  padding: var(--cosmoz-tab-card-content-padding, initial);
94
99
  }
95
100
 
96
- #header {
101
+ .header {
97
102
  display: flex;
98
103
  align-items: center;
99
104
  gap: 8px;
@@ -1,7 +1,7 @@
1
1
  import { component, useEffect, useLayoutEffect } from '@pionjs/pion';
2
2
  import { html, nothing } from 'lit-html';
3
3
  import { ifDefined } from 'lit-html/directives/if-defined.js';
4
- import computeScroll from 'compute-scroll-into-view';
4
+ import { compute } from 'compute-scroll-into-view';
5
5
 
6
6
  import style from './cosmoz-tab.css';
7
7
 
@@ -22,12 +22,12 @@ const Tab = (host) => {
22
22
  if (!active) {
23
23
  return;
24
24
  }
25
- computeScroll(el, {
25
+ compute(el, {
26
26
  block: 'nearest',
27
27
  inline: 'center',
28
28
  boundary: el.parentElement,
29
29
  }).forEach(({ el, top, left }) =>
30
- el.scroll({ top, left, behavior: 'smooth' })
30
+ el.scroll({ top, left, behavior: 'smooth' }),
31
31
  );
32
32
  }, [active]);
33
33
 
@@ -49,5 +49,5 @@ customElements.define(
49
49
  'cosmoz-tab-next',
50
50
  component(Tab, {
51
51
  observedAttributes: ['active', 'badge', 'href'],
52
- })
52
+ }),
53
53
  );
package/src/use-tabs.js CHANGED
@@ -3,7 +3,7 @@ import { notifyProperty } from '@neovici/cosmoz-utils/hooks/use-notify-property'
3
3
  /* eslint-disable-next-line import/no-unresolved */
4
4
  import { useHashParam, link } from '@neovici/cosmoz-router/use-hash-param';
5
5
  import { choose, collect, getName, isValid } from './utils';
6
- import computeScroll from 'compute-scroll-into-view';
6
+ import { compute } from 'compute-scroll-into-view';
7
7
 
8
8
  const useTabSelectedEffect = (host, selectedTab) => {
9
9
  useEffect(() => {
@@ -19,7 +19,7 @@ const useTabSelectedEffect = (host, selectedTab) => {
19
19
  const eventOpts = { composed: true };
20
20
  if (!selectedTab._active) {
21
21
  selectedTab.dispatchEvent(
22
- new CustomEvent('tab-first-select', eventOpts)
22
+ new CustomEvent('tab-first-select', eventOpts),
23
23
  );
24
24
  selectedTab._active = true;
25
25
  }
@@ -39,12 +39,12 @@ const useTabSelectedEffect = (host, selectedTab) => {
39
39
  if (!el) {
40
40
  return;
41
41
  }
42
- computeScroll(el, {
42
+ compute(el, {
43
43
  block: 'nearest',
44
44
  inline: 'center',
45
45
  boundary: el.parentElement,
46
46
  }).forEach(({ el, top, left }) =>
47
- el.scroll({ top, left, behavior: 'smooth' })
47
+ el.scroll({ top, left, behavior: 'smooth' }),
48
48
  );
49
49
  }, [selectedTab]);
50
50
  },
@@ -82,7 +82,7 @@ const useTabSelectedEffect = (host, selectedTab) => {
82
82
 
83
83
  const href = useCallback(
84
84
  (tab) => (isValid(tab) ? link(hashParam, getName(tab)) : undefined),
85
- [hashParam]
85
+ [hashParam],
86
86
  );
87
87
 
88
88
  return {
@@ -90,7 +90,7 @@ const useTabSelectedEffect = (host, selectedTab) => {
90
90
  selectedTab,
91
91
  onSlot: useCallback(
92
92
  ({ target }) => requestAnimationFrame(() => setTabs(collect(target))),
93
- []
93
+ [],
94
94
  ),
95
95
  onSelect: useCallback((e) => {
96
96
  if (e.button !== 0 || e.metaKey || e.ctrlKey) {
@@ -106,7 +106,7 @@ const useTabSelectedEffect = (host, selectedTab) => {
106
106
  e.preventDefault();
107
107
  window.history.pushState({}, '', href(tab));
108
108
  requestAnimationFrame(() =>
109
- window.dispatchEvent(new CustomEvent('hashchange'))
109
+ window.dispatchEvent(new CustomEvent('hashchange')),
110
110
  );
111
111
  }, []),
112
112
  href,