@veritree/ui 0.82.0-9 → 0.83.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.
@@ -33,6 +33,10 @@ export const formControlMixin = {
33
33
  type: String,
34
34
  default: 'large',
35
35
  },
36
+ min: {
37
+ type: [String, Number],
38
+ default: null,
39
+ },
36
40
  },
37
41
 
38
42
  computed: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritree/ui",
3
- "version": "0.82.0-9",
3
+ "version": "0.83.0",
4
4
  "description": "veritree ui library",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -1,6 +1,24 @@
1
1
  <template>
2
2
  <span
3
- class="ml-auto flex min-w-5 place-content-center rounded-xl bg-gray-800 p-1 text-xs leading-none text-white"
3
+ :class="[
4
+ // default styles
5
+ headless
6
+ ? 'badge'
7
+ : 'ml-auto flex min-w-5 place-content-center rounded-xl p-1 text-xs leading-none ',
8
+ // variant styles
9
+ headless
10
+ ? `badge--${variant}`
11
+ : isDefault
12
+ ? 'bg-gray-800 text-white'
13
+ : isSuccess
14
+ ? 'bg-success-200 text-success-700'
15
+ : isError
16
+ ? 'bg-error-200 text-error-700'
17
+ : isWarning
18
+ ? 'bg-warning-200 text-warning-700'
19
+ : null,
20
+ // sizes styles
21
+ ]"
4
22
  >
5
23
  <slot />
6
24
  </span>
@@ -9,5 +27,34 @@
9
27
  <script>
10
28
  export default {
11
29
  name: 'VTBadgeNew',
30
+
31
+ props: {
32
+ headless: {
33
+ type: Boolean,
34
+ default: false,
35
+ },
36
+ variant: {
37
+ type: String,
38
+ default: 'default',
39
+ },
40
+ },
41
+
42
+ computed: {
43
+ isDefault() {
44
+ return this.variant === 'default';
45
+ },
46
+
47
+ isSuccess() {
48
+ return this.variant === 'success';
49
+ },
50
+
51
+ isError() {
52
+ return this.variant === 'error';
53
+ },
54
+
55
+ isWarning() {
56
+ return this.variant === 'warning';
57
+ },
58
+ },
12
59
  };
13
60
  </script>
@@ -11,11 +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;
18
- const icons = this.icons;
15
+ const details = this.details;
19
16
 
20
17
  const register = (objKey, item) => {
21
18
  if (!item) return;
@@ -28,11 +25,8 @@ export default {
28
25
  };
29
26
 
30
27
  return {
31
- details,
32
- contents,
33
- headers,
34
- icons,
35
28
  accordion,
29
+ details,
36
30
  register,
37
31
  unregister,
38
32
  };
@@ -50,9 +44,6 @@ export default {
50
44
  data() {
51
45
  return {
52
46
  details: [],
53
- contents: [],
54
- headers: [],
55
- icons: [],
56
47
  };
57
48
  },
58
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,35 +47,23 @@ export default {
50
47
  id() {
51
48
  return `disclosure-content-${this.idGroup}`;
52
49
  },
53
- },
54
-
55
- mounted() {
56
- const content = {
57
- id: this.id,
58
- idGroup: this.idGroup,
59
- collapse: this.collapse,
60
- expand: this.expand,
61
- isVisible: this.isVisible,
62
- };
63
50
 
64
- this.apiDisclosure().register('contents', content);
65
- },
66
-
67
- beforeDestroy() {
68
- this.apiDisclosure().unregister('contents', this.id);
51
+ isVisible() {
52
+ return this.apiDetails().isVisible();
53
+ },
69
54
  },
70
55
 
71
- methods: {
72
- expand() {
73
- this.expanded = true;
56
+ watch: {
57
+ open(value) {
58
+ this.apiDetails().setVisible(value);
59
+ this.expand = value;
74
60
  },
61
+ },
75
62
 
76
- collapse() {
77
- this.expanded = false;
78
- },
79
- isVisible() {
80
- return this.expanded;
81
- },
63
+ mounted() {
64
+ if (this.open) {
65
+ this.apiDetails().setVisible(this.open);
66
+ }
82
67
  },
83
68
  };
84
69
  </script>
@@ -26,6 +26,7 @@ export default {
26
26
  const idContent = `details-content-${idGroup}`;
27
27
 
28
28
  const isVisible = () => this.isVisible();
29
+ const setVisible = (visible) => this.setVisible(visible);
29
30
 
30
31
  return {
31
32
  idGroup,
@@ -33,6 +34,8 @@ export default {
33
34
  idIcon,
34
35
  idContent,
35
36
  isVisible,
37
+ setVisible,
38
+ visible: this.visible,
36
39
  };
37
40
  },
38
41
  };
@@ -52,6 +55,18 @@ export default {
52
55
  };
53
56
  },
54
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
+
55
70
  mounted() {
56
71
  const detail = {
57
72
  idGroup: this.idGroup,
@@ -81,6 +96,10 @@ export default {
81
96
  isVisible() {
82
97
  return this.visible;
83
98
  },
99
+
100
+ setVisible(visible) {
101
+ this.visible = visible;
102
+ },
84
103
  },
85
104
  };
86
105
  </script>
@@ -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,106 +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
- icons() {
61
- return this.apiDisclosure().icons;
45
+ ariaExpanded() {
46
+ return String(this.isVisible);
62
47
  },
63
-
64
- contents() {
65
- return this.apiDisclosure().contents;
66
- },
67
- },
68
-
69
- mounted() {
70
- this.isExpanded();
71
-
72
- const header = {
73
- id: this.id,
74
- idGroup: this.idGroup,
75
- isExpanded: this.isExpanded,
76
- };
77
-
78
- this.apiDisclosure().register('headers', header);
79
- },
80
-
81
- beforeDestroy() {
82
- this.apiDisclosure().unregister('headers', this.id);
83
48
  },
84
49
 
85
50
  methods: {
86
51
  toggle() {
87
- this.toggleDetails();
88
- this.toggleHeaders();
89
- this.toggleContents();
90
- this.toggleIcons();
91
- },
92
-
93
- isExpanded() {
94
- this.ariaExpanded = this.apiDetails().isVisible();
95
- },
96
-
97
- toggleDetails() {
98
- this.details.forEach((detail) => {
99
- const isSameGroup = detail.idGroup === this.idGroup;
100
- const isAccordion = this.apiDisclosure().accordion;
101
-
102
- if (isSameGroup) {
103
- detail.isVisible() ? detail.hide() : detail.show();
104
- }
105
-
106
- if (isAccordion && !isSameGroup) {
107
- detail.hide();
108
- }
109
- });
110
- },
111
-
112
- toggleContents() {
113
- this.contents.forEach((content) => {
114
- const isSameGroup = content.idGroup === this.idGroup;
115
- const isAccordion = this.apiDisclosure().accordion;
116
-
117
- if (isSameGroup) {
118
- content.isVisible() ? content.collapse() : content.expand();
119
- }
120
-
121
- if (isAccordion && !isSameGroup) {
122
- content.collapse();
123
- }
124
- });
125
- },
126
-
127
- toggleHeaders() {
128
- this.headers.forEach((summary) => summary.isExpanded());
129
- },
130
-
131
- toggleIcons() {
132
- this.icons.forEach((icon) => icon.isExpanded());
52
+ this.apiDetails().setVisible(!this.isVisible);
133
53
  },
134
54
  },
135
55
  };
@@ -22,42 +22,36 @@ export default {
22
22
  },
23
23
  },
24
24
 
25
- data() {
26
- return {
27
- expanded: false,
28
- };
29
- },
25
+ // data() {
26
+ // return {
27
+ // expanded: false,
28
+ // };
29
+ // },
30
30
 
31
31
  computed: {
32
- id() {
33
- return this.apiDetails().idIcon;
34
- },
32
+ // id() {
33
+ // return this.apiDetails().idIcon;
34
+ // },
35
35
 
36
- idGroup() {
37
- return this.apiDetails().idGroup;
36
+ // idGroup() {
37
+ // return this.apiDetails().idGroup;
38
+ // },
39
+
40
+ expanded() {
41
+ return this.apiDetails().visible;
38
42
  },
39
43
  },
40
44
 
41
45
  mounted() {
42
- this.isExpanded();
43
-
44
- const icon = {
45
- id: this.id,
46
- idGroup: this.idGroup,
47
- isExpanded: this.isExpanded,
48
- };
49
-
50
- this.apiDisclosure().register('icons', icon);
46
+ // const icon = {
47
+ // id: this.id,
48
+ // idGroup: this.idGroup,
49
+ // };
50
+ // this.apiDisclosure().register('icons', icon);
51
51
  },
52
52
 
53
53
  beforeDestroy() {
54
- this.apiDisclosure().unregister('icons', this.id);
55
- },
56
-
57
- methods: {
58
- isExpanded() {
59
- this.expanded = this.apiDetails().isVisible();
60
- },
54
+ // this.apiDisclosure().unregister('icons', this.id);
61
55
  },
62
56
  };
63
57
  </script>
@@ -56,10 +56,10 @@ export default {
56
56
  this.headless
57
57
  ? `form-feedback__icon--${this.variant}`
58
58
  : this.isError
59
- ? 'text-error-500'
60
- : this.isSuccess
61
- ? 'text-success-500'
62
- : null,
59
+ ? 'text-error-500'
60
+ : this.isSuccess
61
+ ? 'text-success-500'
62
+ : null,
63
63
  ];
64
64
  },
65
65
 
@@ -76,6 +76,14 @@ export default {
76
76
  },
77
77
  },
78
78
 
79
+ destroyed() {
80
+ this.$emit('destroyed');
81
+ },
82
+
83
+ mounted() {
84
+ this.$emit('mounted');
85
+ },
86
+
79
87
  methods: {
80
88
  onClick() {
81
89
  this.$emit('click');
@@ -3,6 +3,7 @@
3
3
  :class="classComputed"
4
4
  :value="value"
5
5
  :disabled="disabled"
6
+ :min="min"
6
7
  v-on="listeners"
7
8
  />
8
9
  </template>
@@ -85,10 +85,6 @@ export default {
85
85
 
86
86
  valueFormatted: {
87
87
  get() {
88
- if (this.value === 0 && this.event === 'blur') {
89
- return null;
90
- }
91
-
92
88
  let options = {};
93
89
 
94
90
  // only add the fraction digits on blur because on input it won't behave nicely
@@ -1,21 +1,34 @@
1
+ /**
2
+ * Resizes an image by adjusting its width and returns the modified URL.
3
+ *
4
+ * This method processes image URLs from CloudFront CDN. If the URL is a valid
5
+ * string or object, it decodes the URL, adjusts the width in the `resize` edits,
6
+ * and returns the updated encoded URL. If no width is provided, a default value
7
+ * of 450 is used. If an error occurs, the original CDN URL is returned.
8
+ *
9
+ * @param {(string|object)} url - The URL of the image, either as a string or object.
10
+ * @param {number} [width=450] - The width to resize the image to (default is 450 if not specified).
11
+ *
12
+ * @returns {string} The updated image URL with the resized width, or the original URL if an error occurs.
13
+ */
1
14
  export const handleImageResizing = (url, width) => {
2
15
  // early exit if url is null for whatever reason
3
16
  if (!url) {
4
17
  return '';
5
18
  }
6
-
19
+
7
20
  let cdn;
8
-
21
+
9
22
  try {
10
23
  // new code
11
- if(typeof url === 'string' && url.includes('cloudfront.net/')) {
24
+ if (typeof url === 'string' && url.includes('cloudfront.net/')) {
12
25
  cdn = url;
13
26
  } else {
14
27
  // old code
15
28
  if (typeof url === 'object') {
16
29
  cdn = url.cdn_url;
17
30
  }
18
-
31
+
19
32
  if (typeof url === 'string') {
20
33
  cdn = JSON.parse(url).cdn_url;
21
34
  }
@@ -29,7 +42,7 @@ export const handleImageResizing = (url, width) => {
29
42
  // browsers.
30
43
  //
31
44
  // Details: https://developer.mozilla.org/en-US/docs/Web/API/atob
32
- const decodedString = JSON.parse(atob(base64String[1]));
45
+ const decodedString = JSON.parse(atob(base64String[1]));
33
46
 
34
47
  width
35
48
  ? (decodedString.edits.resize.width = width)
@@ -43,8 +56,8 @@ export const handleImageResizing = (url, width) => {
43
56
  const encodedString = btoa(JSON.stringify(decodedString));
44
57
  const encodedUrl = `${firstPart}net/${encodedString}`;
45
58
 
46
- return encodedUrl
47
- } catch(error) {
48
- console.error(`${error} in ${cdn}`);
59
+ return encodedUrl;
60
+ } catch (error) {
61
+ return cdn;
49
62
  }
50
- };
63
+ };