@thinkpixellab-public/px-vue 5.3.7 → 5.3.9

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.
@@ -1,19 +1,23 @@
1
1
  <script>
2
+ import { useId } from 'vue';
3
+
2
4
  export default {
3
5
  beforeCreate() {
4
- const id = this.$.uid || Math.floor(Math.random() * 1000);
5
- this.$__uniqueId = String(id).padStart(4, '0');
6
+ // useId() (Vue 3.5+) yields an id that is stable across SSR and client
7
+ // renders, avoiding hydration mismatches. The old source (this.$.uid) is
8
+ // a per-render-pass counter that differs between server and client.
9
+ this.$__uniqueId = useId();
6
10
  },
7
11
  methods: {
8
12
  /**
9
- * Get a unique id derived from vue's unique component identifier (this.$.uid) for use when
10
- * an id is required for an inputs, labels, etc.
13
+ * Get a unique, SSR-stable id for use when an id is required for inputs,
14
+ * labels, etc. Optionally prefixed.
11
15
  *
12
16
  * @param {string} prefix = null
13
17
  * @returns {string}
14
18
  *
15
19
  * @example
16
- * this.uniqueId('label') => 'label-0003'
20
+ * this.uniqueId('label') => 'label-v-3-0'
17
21
  */
18
22
 
19
23
  uniqueId(prefix = null) {
@@ -129,21 +129,19 @@ export default {
129
129
  }
130
130
 
131
131
  const refName = this.getTabContentRefName(this.selectedItem);
132
+ const selected = this.$refs[refName]?.[0];
132
133
 
133
- if (!this.$refs[refName]) {
134
+ // the selected tab may not be rendered yet (the items/selectedKeys
135
+ // watchers re-run this once it is)
136
+ if (!selected) {
137
+ this.selectorVisible = false;
134
138
  return;
135
139
  }
136
140
 
137
- const selected = this.$refs[refName][0];
138
141
  const selectedRect = getClientRect(selected, this.$refs.tabs);
139
-
140
- if (selected) {
141
- this.selectorVisible = true;
142
- this.selectorOffset = selectedRect.left;
143
- this.selectorWidth = selectedRect.width;
144
- } else {
145
- this.selectorVisible = false;
146
- }
142
+ this.selectorVisible = true;
143
+ this.selectorOffset = selectedRect.left;
144
+ this.selectorWidth = selectedRect.width;
147
145
 
148
146
  if (this.scrolls && this.animated) {
149
147
  selected.scrollIntoView({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkpixellab-public/px-vue",
3
- "version": "5.3.7",
3
+ "version": "5.3.9",
4
4
  "description": "General purpose Vue components and helpers that can be used across projects.",
5
5
  "author": {
6
6
  "name": "Pixel Lab"
@@ -69,14 +69,14 @@
69
69
  "@vitejs/plugin-vue": "^6.0.7",
70
70
  "@vue/test-utils": "^2.4.11",
71
71
  "@vueless/storybook-dark-mode": "^10.0.8",
72
- "chromatic": "^17.7.2",
72
+ "chromatic": "^18.0.0",
73
73
  "jsdom": "^29.1.1",
74
- "oxfmt": "^0.56.0",
75
- "oxlint": "^1.71.0",
74
+ "oxfmt": "^0.57.0",
75
+ "oxlint": "^1.72.0",
76
76
  "sass": "^1.101.0",
77
77
  "storybook": "^10.4.6",
78
78
  "storybook-addon-pseudo-states": "^10.4.6",
79
- "vite": "^8.1.0",
79
+ "vite": "^8.1.3",
80
80
  "vitest": "^4.1.9",
81
81
  "vue": "^3.5.39"
82
82
  },
package/plugins/common.js CHANGED
@@ -17,7 +17,6 @@ import slug from './filters/slug.js';
17
17
  import spacenator from './filters/spacenator.js';
18
18
  import date from './filters/date.js';
19
19
  import isServer from '../utils/isServer.js';
20
- import uniqueId from '../utils/uniqueId.js';
21
20
 
22
21
  import { nextTick } from 'vue';
23
22
 
@@ -36,7 +35,6 @@ export default {
36
35
  app.config.globalProperties.cssToNull = cssToNull;
37
36
  app.config.globalProperties.hasSlot = hasSlot;
38
37
  app.config.globalProperties.isServer = isServer;
39
- app.config.globalProperties.uniqueId = uniqueId;
40
38
 
41
39
  /**
42
40
  * Collection of common filters.
package/utils/uniqueId.js DELETED
@@ -1,17 +0,0 @@
1
- /**
2
- * Get a unique id derived from vue's unique component identifier (this._uid) for use when
3
- * an id is required for an inputs, labels, etc.
4
- *
5
- * @example
6
- * uniqueId('label') => 'label-0003'
7
- */
8
-
9
- function uniqueId(prefix = null) {
10
- let id = this?.$?.uid;
11
- if (prefix) {
12
- return prefix + '-' + id;
13
- }
14
- return id.toString();
15
- }
16
-
17
- export default uniqueId;