@veritree/ui 0.82.0-9 → 0.82.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.82.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>
@@ -15,7 +15,6 @@ export default {
15
15
  const contents = this.contents;
16
16
  const accordion = this.accordion;
17
17
  const headers = this.headers;
18
- const icons = this.icons;
19
18
 
20
19
  const register = (objKey, item) => {
21
20
  if (!item) return;
@@ -31,7 +30,6 @@ export default {
31
30
  details,
32
31
  contents,
33
32
  headers,
34
- icons,
35
33
  accordion,
36
34
  register,
37
35
  unregister,
@@ -52,7 +50,7 @@ export default {
52
50
  details: [],
53
51
  contents: [],
54
52
  headers: [],
55
- icons: [],
53
+ // icons: [],
56
54
  };
57
55
  },
58
56
  };
@@ -53,6 +53,10 @@ export default {
53
53
  },
54
54
 
55
55
  mounted() {
56
+ if (this.expanded) {
57
+ this.apiDetails().setVisible(this.expanded);
58
+ }
59
+
56
60
  const content = {
57
61
  id: this.id,
58
62
  idGroup: this.idGroup,
@@ -76,6 +80,7 @@ export default {
76
80
  collapse() {
77
81
  this.expanded = false;
78
82
  },
83
+
79
84
  isVisible() {
80
85
  return this.expanded;
81
86
  },
@@ -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
  };
@@ -81,6 +84,10 @@ export default {
81
84
  isVisible() {
82
85
  return this.visible;
83
86
  },
87
+
88
+ setVisible(visible) {
89
+ this.visible = visible;
90
+ },
84
91
  },
85
92
  };
86
93
  </script>
@@ -57,10 +57,6 @@ export default {
57
57
  return this.apiDisclosure().headers;
58
58
  },
59
59
 
60
- icons() {
61
- return this.apiDisclosure().icons;
62
- },
63
-
64
60
  contents() {
65
61
  return this.apiDisclosure().contents;
66
62
  },
@@ -87,7 +83,6 @@ export default {
87
83
  this.toggleDetails();
88
84
  this.toggleHeaders();
89
85
  this.toggleContents();
90
- this.toggleIcons();
91
86
  },
92
87
 
93
88
  isExpanded() {
@@ -127,10 +122,6 @@ export default {
127
122
  toggleHeaders() {
128
123
  this.headers.forEach((summary) => summary.isExpanded());
129
124
  },
130
-
131
- toggleIcons() {
132
- this.icons.forEach((icon) => icon.isExpanded());
133
- },
134
125
  },
135
126
  };
136
127
  </script>
@@ -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
+ };