@veritree/ui 0.57.0 → 0.58.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": "@veritree/ui",
3
- "version": "0.57.0",
3
+ "version": "0.58.0",
4
4
  "description": "veritree ui library",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -29,7 +29,7 @@ export default {
29
29
 
30
30
  provide() {
31
31
  return {
32
- api: () => {
32
+ apiDrawer: () => {
33
33
  const id = this.id;
34
34
  const isDark = this.dark;
35
35
  const isHeadless = this.headless;
@@ -2,8 +2,8 @@
2
2
  <VTButton
3
3
  variant="icon"
4
4
  :class="{
5
- 'Drawer-close': headless,
6
- 'ml-auto -mr-2 text-inherit': !headless,
5
+ 'drawer-close': headless,
6
+ '-mr-2 ml-auto shrink-0 text-inherit': !headless,
7
7
  }"
8
8
  :theme="theme"
9
9
  @click.prevent="hide"
@@ -20,19 +20,19 @@ export default {
20
20
 
21
21
  components: { IconLeft, VTButton },
22
22
 
23
- inject: ['api'],
23
+ inject: ['apiDrawer'],
24
24
 
25
25
  computed: {
26
26
  dark() {
27
- return this.api().isDark;
27
+ return this.apiDrawer().isDark;
28
28
  },
29
29
 
30
30
  headless() {
31
- return this.api().isHeadless;
31
+ return this.apiDrawer().isHeadless;
32
32
  },
33
33
 
34
34
  right() {
35
- return this.api().isRight;
35
+ return this.apiDrawer().isRight;
36
36
  },
37
37
 
38
38
  // temporary till button theme is implemented
@@ -43,7 +43,7 @@ export default {
43
43
 
44
44
  methods: {
45
45
  hide() {
46
- this.api().hide();
46
+ this.apiDrawer().hide();
47
47
  },
48
48
  },
49
49
  };
@@ -11,8 +11,8 @@
11
11
  <div
12
12
  v-show="visible"
13
13
  :class="{
14
- 'Drawer-content': headless,
15
- 'fixed z-20 flex h-screen max-h-full max-w-full flex-col overflow-auto p-5 outline-0 sm:px-10 sm:py-6':
14
+ 'drawer-content': headless,
15
+ 'fixed z-20 flex h-screen max-h-full max-w-full flex-col overflow-auto outline-0':
16
16
  !headless,
17
17
  'bg-white text-gray-600': !dark,
18
18
  'bg-fd-600': dark,
@@ -33,7 +33,14 @@
33
33
  export default {
34
34
  name: 'VTDrawerContent',
35
35
 
36
- inject: ['api'],
36
+ inject: ['apiDrawer'],
37
+
38
+ props: {
39
+ headless: {
40
+ type: Boolean,
41
+ default: false,
42
+ },
43
+ },
37
44
 
38
45
  data() {
39
46
  return {
@@ -43,15 +50,11 @@ export default {
43
50
 
44
51
  computed: {
45
52
  dark() {
46
- return this.api().isDark;
47
- },
48
-
49
- headless() {
50
- return this.api().isHeadless;
53
+ return this.apiDrawer().isDark;
51
54
  },
52
55
 
53
56
  position() {
54
- return this.api().position;
57
+ return this.apiDrawer().position;
55
58
  },
56
59
 
57
60
  activeClass() {
@@ -73,6 +76,7 @@ export default {
73
76
  default:
74
77
  translateClass = '-translate-x-full';
75
78
  }
79
+
76
80
  return `opacity-0 ${translateClass}`;
77
81
  },
78
82
 
@@ -91,6 +95,7 @@ export default {
91
95
  default:
92
96
  translateClass = 'translate-x-0';
93
97
  }
98
+
94
99
  return `opacity-100 ${translateClass}`;
95
100
  },
96
101
 
@@ -109,6 +114,7 @@ export default {
109
114
  default:
110
115
  translateClass = 'translate-x-0';
111
116
  }
117
+
112
118
  return `opacity-100 ${translateClass}`;
113
119
  },
114
120
 
@@ -127,12 +133,13 @@ export default {
127
133
  default:
128
134
  translateClass = '-translate-x-full';
129
135
  }
136
+
130
137
  return `opacity-0 ${translateClass}`;
131
138
  },
132
139
  },
133
140
 
134
141
  mounted() {
135
- this.api().registerContent(this);
142
+ this.apiDrawer().registerContent(this);
136
143
  this.show();
137
144
 
138
145
  this.$nextTick(() => this.$el.focus());
@@ -148,7 +155,7 @@ export default {
148
155
  },
149
156
 
150
157
  hideDrawer() {
151
- this.api().emit();
158
+ this.apiDrawer().emit();
152
159
  },
153
160
  },
154
161
  };
@@ -0,0 +1,16 @@
1
+ <template>
2
+ <div :class="[headless ? 'drawer-divider' : 'h-[1px] bg-gray-200']" />
3
+ </template>
4
+
5
+ <script>
6
+ export default {
7
+ name: 'VTDrawerDivider',
8
+
9
+ props: {
10
+ headless: {
11
+ type: Boolean,
12
+ default: false,
13
+ },
14
+ },
15
+ };
16
+ </script>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <component :is="as" :class="{ 'dialog-footer': headless }">
2
+ <component :is="as" :class="[headless ? 'dialog-footer' : 'px-5 py-4']">
3
3
  <slot></slot>
4
4
  </component>
5
5
  </template>
@@ -8,22 +8,16 @@
8
8
  export default {
9
9
  name: 'VTDrawerFooter',
10
10
 
11
- inject: ['api'],
11
+ inject: ['apiDrawer'],
12
12
 
13
13
  props: {
14
14
  as: {
15
15
  type: String,
16
16
  default: 'footer',
17
17
  },
18
- },
19
-
20
- computed: {
21
- dark() {
22
- return this.api().isDark;
23
- },
24
-
25
- headless() {
26
- return this.api().isHeadless;
18
+ headless: {
19
+ type: Boolean,
20
+ default: false,
27
21
  },
28
22
  },
29
23
  };
@@ -3,8 +3,8 @@
3
3
  :is="as"
4
4
  :id="id"
5
5
  :class="{
6
- 'Drawer-header': headless,
7
- 'mb-8 flex items-center justify-between gap-3': !headless,
6
+ 'drawer-header': headless,
7
+ 'flex items-center justify-between gap-3 px-5 py-4': !headless,
8
8
  }"
9
9
  >
10
10
  <slot></slot>
@@ -15,26 +15,22 @@
15
15
  export default {
16
16
  name: 'VTDrawerHeader',
17
17
 
18
- inject: ['api'],
18
+ inject: ['apiDrawer'],
19
19
 
20
20
  props: {
21
21
  as: {
22
22
  type: String,
23
23
  default: 'header',
24
24
  },
25
+ headless: {
26
+ type: Boolean,
27
+ default: false,
28
+ },
25
29
  },
26
30
 
27
31
  computed: {
28
- dark() {
29
- return this.api().isDark;
30
- },
31
-
32
- headless() {
33
- return this.api().isHeadless;
34
- },
35
-
36
32
  id() {
37
- return `${this.api().id}-header`;
33
+ return `${this.apiDrawer().id}-header`;
38
34
  },
39
35
  },
40
36
  };
@@ -2,7 +2,10 @@
2
2
  <component
3
3
  :is="as"
4
4
  :id="id"
5
- :class="{ 'Drawer-body': headless, 'flex-1': !headless }"
5
+ :class="{
6
+ 'drawer-body': headless,
7
+ 'grow overflow-hidden overflow-y-auto px-5 py-6': !headless,
8
+ }"
6
9
  >
7
10
  <slot></slot>
8
11
  </component>
@@ -12,26 +15,22 @@
12
15
  export default {
13
16
  name: 'VTDrawerMain',
14
17
 
15
- inject: ['api'],
18
+ inject: ['apiDrawer'],
16
19
 
17
20
  props: {
18
21
  as: {
19
22
  type: String,
20
23
  default: 'main',
21
24
  },
25
+ headless: {
26
+ type: Boolean,
27
+ default: false,
28
+ },
22
29
  },
23
30
 
24
31
  computed: {
25
- dark() {
26
- return this.api().isDark;
27
- },
28
-
29
- headless() {
30
- return this.api().isHeadless;
31
- },
32
-
33
32
  id() {
34
- return `${this.api().id}-desc`;
33
+ return `${this.apiDrawer().id}-desc`;
35
34
  },
36
35
  },
37
36
 
@@ -42,7 +41,7 @@ export default {
42
41
  methods: {
43
42
  // In here because if there is no body, the dialog will not be described by
44
43
  setDialogDescribedby() {
45
- const dialog = document.getElementById(this.api().id);
44
+ const dialog = document.getElementById(this.apiDrawer().id);
46
45
 
47
46
  if (dialog) {
48
47
  dialog.setAttribute('aria-describedby', this.id);
@@ -4,22 +4,22 @@
4
4
  v-if="visible"
5
5
  :id="id"
6
6
  :class="{
7
- 'Drawer-overlay': headless,
8
- 'fixed inset-0 z-10 bg-fd-450/80': !headless,
7
+ 'drawer-overlay': headless,
8
+ 'bg-fd-450/80 fixed inset-0 z-10': !headless,
9
9
  }"
10
10
  ></div>
11
11
  </FadeInOut>
12
12
  </template>
13
13
 
14
14
  <script>
15
- import FadeInOut from "../Transitions/FadeInOut.vue";
15
+ import FadeInOut from '../Transitions/FadeInOut.vue';
16
16
 
17
17
  export default {
18
18
  components: {
19
19
  FadeInOut,
20
20
  },
21
21
 
22
- inject: ["api"],
22
+ inject: ['apiDrawer'],
23
23
 
24
24
  data() {
25
25
  return {
@@ -29,21 +29,21 @@ export default {
29
29
 
30
30
  computed: {
31
31
  dark() {
32
- return this.api().isDark;
32
+ return this.apiDrawer().isDark;
33
33
  },
34
34
 
35
35
  headless() {
36
- return this.api().isHeadless;
36
+ return this.apiDrawer().isHeadless;
37
37
  },
38
38
 
39
39
  id() {
40
- return `${this.api().id}-overlay`;
40
+ return `${this.apiDrawer().id}-overlay`;
41
41
  },
42
42
  },
43
43
 
44
44
  mounted() {
45
45
  this.visible = true;
46
- this.api().registerOverlay(this);
46
+ this.apiDrawer().registerOverlay(this);
47
47
  },
48
48
 
49
49
  methods: {
@@ -3,7 +3,7 @@
3
3
  :is="as"
4
4
  :id="id"
5
5
  :class="{
6
- 'Drawer-title': headless,
6
+ 'drawer-title': headless,
7
7
  'text-2xl font-semibold': !headless,
8
8
  }"
9
9
  >
@@ -15,7 +15,7 @@
15
15
  export default {
16
16
  name: 'VTDrawerTitle',
17
17
 
18
- inject: ['api'],
18
+ inject: ['apiDrawer'],
19
19
 
20
20
  props: {
21
21
  as: {
@@ -26,15 +26,15 @@ export default {
26
26
 
27
27
  computed: {
28
28
  dark() {
29
- return this.api().isDark;
29
+ return this.apiDrawer().isDark;
30
30
  },
31
31
 
32
32
  headless() {
33
- return this.api().isHeadless;
33
+ return this.apiDrawer().isHeadless;
34
34
  },
35
35
 
36
36
  id() {
37
- return `${this.api().id}-title`;
37
+ return `${this.apiDrawer().id}-title`;
38
38
  },
39
39
  },
40
40
 
@@ -45,7 +45,7 @@ export default {
45
45
  methods: {
46
46
  // In here because if there is no header, the dialog will not be labelled by
47
47
  setDialogLabelledby() {
48
- const dialog = document.getElementById(this.api().id);
48
+ const dialog = document.getElementById(this.apiDrawer().id);
49
49
 
50
50
  if (dialog) {
51
51
  dialog.setAttribute('aria-labelledby', this.id);
@@ -83,9 +83,13 @@ export default {
83
83
  * is also only used when the prop multiple is true.
84
84
  */
85
85
  const removeValueFromValueComputed = (value) => {
86
- this.valueComputed = this.valueComputed.filter(
87
- (valueComputed) => valueComputed !== value
88
- );
86
+ this.valueComputed = this.valueComputed.filter((valueComputed) => {
87
+ if (typeof valueComputed === 'object') {
88
+ return JSON.stringify(valueComputed) !== JSON.stringify(value);
89
+ }
90
+
91
+ return valueComputed !== value;
92
+ });
89
93
  };
90
94
 
91
95
  return {