@veritree/ui 0.82.0 → 0.83.1

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": "@veritree/ui",
3
- "version": "0.82.0",
3
+ "version": "0.83.1",
4
4
  "description": "veritree ui library",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -8,11 +8,7 @@
8
8
  :disabled="isDisabled"
9
9
  :class="[
10
10
  // default styles
11
- headless
12
- ? 'button'
13
- : isIcon
14
- ? 'relative inline-flex items-center justify-center rounded-full [&_svg]:max-h-full [&_svg]:max-w-full'
15
- : 'button-base',
11
+ headless ? 'button' : isIcon ? null : 'button-base',
16
12
  // variant styles
17
13
  headless
18
14
  ? `button--${variant}`
@@ -23,11 +19,11 @@
23
19
  ? 'border-gray-500 text-gray-100 hover:bg-white hover:text-gray-700'
24
20
  : 'button--secondary'
25
21
  : isTertiary
26
- ? 'border-transparent text-gray-600 hover:text-gray-800 focus:text-gray-800 active:text-gray-800 disabled:text-gray-400'
22
+ ? 'button--tertiary'
27
23
  : isDark
28
- ? 'border-transparent bg-gray-800 text-white hover:bg-gray-700 active:bg-gray-600 disabled:bg-gray-200 disabled:text-gray-400'
24
+ ? 'button--dark'
29
25
  : isIcon
30
- ? 'text-primary-100 focus-within:bg-gray-200 hover:bg-gray-200 active:bg-gray-300 disabled:bg-gray-200 disabled:text-gray-400'
26
+ ? 'button--icon'
31
27
  : null,
32
28
  // sizes styles
33
29
  headless
@@ -11,10 +11,8 @@ export default {
11
11
  provide() {
12
12
  return {
13
13
  apiDisclosure: () => {
14
- const details = this.details;
15
- const contents = this.contents;
16
14
  const accordion = this.accordion;
17
- const headers = this.headers;
15
+ const details = this.details;
18
16
 
19
17
  const register = (objKey, item) => {
20
18
  if (!item) return;
@@ -27,10 +25,8 @@ export default {
27
25
  };
28
26
 
29
27
  return {
30
- details,
31
- contents,
32
- headers,
33
28
  accordion,
29
+ details,
34
30
  register,
35
31
  unregister,
36
32
  };
@@ -48,9 +44,6 @@ export default {
48
44
  data() {
49
45
  return {
50
46
  details: [],
51
- contents: [],
52
- headers: [],
53
- // icons: [],
54
47
  };
55
48
  },
56
49
  };
@@ -6,10 +6,10 @@
6
6
  ? 'details-content'
7
7
  : 'grid transition-[grid-template-rows] duration-300 ease-linear',
8
8
  headless
9
- ? expanded
9
+ ? isVisible
10
10
  ? 'details-content--expanded'
11
11
  : null
12
- : expanded
12
+ : isVisible
13
13
  ? 'grid-rows-[1fr]'
14
14
  : 'grid-rows-[0fr]',
15
15
  ]"
@@ -40,9 +40,6 @@ export default {
40
40
  data() {
41
41
  return {
42
42
  idGroup: this.apiDetails().idGroup,
43
- expanded: this.open,
44
- expandedHeight: null,
45
- invisible: false,
46
43
  };
47
44
  },
48
45
 
@@ -50,40 +47,23 @@ export default {
50
47
  id() {
51
48
  return `disclosure-content-${this.idGroup}`;
52
49
  },
53
- },
54
50
 
55
- mounted() {
56
- if (this.expanded) {
57
- this.apiDetails().setVisible(this.expanded);
58
- }
59
-
60
- const content = {
61
- id: this.id,
62
- idGroup: this.idGroup,
63
- collapse: this.collapse,
64
- expand: this.expand,
65
- isVisible: this.isVisible,
66
- };
67
-
68
- this.apiDisclosure().register('contents', content);
69
- },
70
-
71
- beforeDestroy() {
72
- this.apiDisclosure().unregister('contents', this.id);
73
- },
74
-
75
- methods: {
76
- expand() {
77
- this.expanded = true;
51
+ isVisible() {
52
+ return this.apiDetails().isVisible();
78
53
  },
54
+ },
79
55
 
80
- collapse() {
81
- this.expanded = false;
56
+ watch: {
57
+ open(value) {
58
+ this.apiDetails().setVisible(value);
59
+ this.expand = value;
82
60
  },
61
+ },
83
62
 
84
- isVisible() {
85
- return this.expanded;
86
- },
63
+ mounted() {
64
+ if (this.open) {
65
+ this.apiDetails().setVisible(this.open);
66
+ }
87
67
  },
88
68
  };
89
69
  </script>
@@ -55,6 +55,18 @@ export default {
55
55
  };
56
56
  },
57
57
 
58
+ watch: {
59
+ visible(value) {
60
+ if (value && this.apiDisclosure().accordion) {
61
+ this.apiDisclosure().details.forEach((detail) => {
62
+ if (detail.idGroup !== this.idGroup) {
63
+ detail.hide();
64
+ }
65
+ });
66
+ }
67
+ },
68
+ },
69
+
58
70
  mounted() {
59
71
  const detail = {
60
72
  idGroup: this.idGroup,
@@ -7,7 +7,7 @@
7
7
  : 'flex cursor-pointer justify-between gap-3 text-body font-semibold',
8
8
  ]"
9
9
  :aria-controls="ariaControls"
10
- :aria-expanded="String(ariaExpanded)"
10
+ :aria-expanded="ariaExpanded"
11
11
  role="button"
12
12
  tabindex="0"
13
13
  @click.prevent="toggle"
@@ -30,97 +30,26 @@ export default {
30
30
  },
31
31
  },
32
32
 
33
- data() {
34
- return {
35
- ariaExpanded: false,
36
- };
37
- },
38
-
39
33
  computed: {
40
34
  id() {
41
35
  return this.apiDetails().idSummary;
42
36
  },
43
-
44
- idGroup() {
45
- return this.apiDetails().idGroup;
46
- },
47
-
48
37
  ariaControls() {
49
38
  return this.apiDetails().idContent;
50
39
  },
51
40
 
52
- details() {
53
- return this.apiDisclosure().details;
54
- },
55
-
56
- headers() {
57
- return this.apiDisclosure().headers;
41
+ isVisible() {
42
+ return this.apiDetails().isVisible();
58
43
  },
59
44
 
60
- contents() {
61
- return this.apiDisclosure().contents;
45
+ ariaExpanded() {
46
+ return String(this.isVisible);
62
47
  },
63
48
  },
64
49
 
65
- mounted() {
66
- this.isExpanded();
67
-
68
- const header = {
69
- id: this.id,
70
- idGroup: this.idGroup,
71
- isExpanded: this.isExpanded,
72
- };
73
-
74
- this.apiDisclosure().register('headers', header);
75
- },
76
-
77
- beforeDestroy() {
78
- this.apiDisclosure().unregister('headers', this.id);
79
- },
80
-
81
50
  methods: {
82
51
  toggle() {
83
- this.toggleDetails();
84
- this.toggleHeaders();
85
- this.toggleContents();
86
- },
87
-
88
- isExpanded() {
89
- this.ariaExpanded = this.apiDetails().isVisible();
90
- },
91
-
92
- toggleDetails() {
93
- this.details.forEach((detail) => {
94
- const isSameGroup = detail.idGroup === this.idGroup;
95
- const isAccordion = this.apiDisclosure().accordion;
96
-
97
- if (isSameGroup) {
98
- detail.isVisible() ? detail.hide() : detail.show();
99
- }
100
-
101
- if (isAccordion && !isSameGroup) {
102
- detail.hide();
103
- }
104
- });
105
- },
106
-
107
- toggleContents() {
108
- this.contents.forEach((content) => {
109
- const isSameGroup = content.idGroup === this.idGroup;
110
- const isAccordion = this.apiDisclosure().accordion;
111
-
112
- if (isSameGroup) {
113
- content.isVisible() ? content.collapse() : content.expand();
114
- }
115
-
116
- if (isAccordion && !isSameGroup) {
117
- content.collapse();
118
- }
119
- });
120
- },
121
-
122
- toggleHeaders() {
123
- this.headers.forEach((summary) => summary.isExpanded());
52
+ this.apiDetails().setVisible(!this.isVisible);
124
53
  },
125
54
  },
126
55
  };