@asd20/ui-next 2.0.2 → 2.0.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.0.3](https://github.com/academydistrict20/asd20-ui-next/compare/ui-next-v2.0.2...ui-next-v2.0.3) (2026-03-27)
4
+
3
5
  ## [2.0.2](https://github.com/academydistrict20/asd20-ui-next/compare/ui-next-v2.0.1...ui-next-v2.0.2) (2026-03-27)
4
6
 
5
7
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asd20/ui-next",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "private": false,
5
5
  "description": "ASD20 UI component library for Vue 3.",
6
6
  "license": "MIT",
@@ -50,20 +50,14 @@ export function shouldOpenInNewWindow(href, options) {
50
50
  return !isAsd20Hostname(url.hostname, options)
51
51
  }
52
52
 
53
- export function resolveCurrentHostname(vm, options) {
53
+ export function resolveCurrentHostname(_vm, options = {}) {
54
54
  if (typeof window !== 'undefined' && window.location) {
55
55
  return normalizeHostname(window.location.hostname, options)
56
56
  }
57
57
 
58
- const requestHost =
59
- vm &&
60
- vm.$ssrContext &&
61
- vm.$ssrContext.req &&
62
- vm.$ssrContext.req.headers &&
63
- (vm.$ssrContext.req.headers['x-forwarded-host'] ||
64
- vm.$ssrContext.req.headers.host)
65
-
66
- return normalizeHostname(requestHost, options)
58
+ // Server renders should stay deterministic and avoid reaching through the
59
+ // component proxy for SSR internals that are not part of the Vue 3 public API.
60
+ return normalizeHostname(options.currentHostname || '', options)
67
61
  }
68
62
 
69
63
  export function shouldShowExternalIcon(href, currentHostname, options) {
@@ -1,6 +1,12 @@
1
1
  import kebabCase from 'lodash/kebabCase'
2
+ import createComponentInstanceId from '../utils/createComponentInstanceId'
2
3
 
3
4
  const INPUT_MODEL_LISTENER_KEYS = ['onInput', 'onUpdate:modelValue']
5
+ const DEFAULT_INPUT_COMPONENT_NAME = 'asd20-input'
6
+
7
+ function resolveKebabComponentName(componentName = DEFAULT_INPUT_COMPONENT_NAME) {
8
+ return kebabCase(componentName).replace(/-([0-9])/g, '$1')
9
+ }
4
10
 
5
11
  function omitKeys(source, keys) {
6
12
  const target = { ...(source || {}) }
@@ -46,18 +52,23 @@ export default {
46
52
  reversed: { type: Boolean, default: false },
47
53
  taggable: { type: Boolean, default: true },
48
54
  },
49
- data: () => ({
50
- isDirty: false,
51
- isActive: false,
52
- validationErrors: [],
53
- }),
55
+ data() {
56
+ return {
57
+ isDirty: false,
58
+ isActive: false,
59
+ validationErrors: [],
60
+ generatedInputId: createComponentInstanceId(
61
+ resolveKebabComponentName(this.$options.name)
62
+ ),
63
+ }
64
+ },
54
65
  mounted() {
55
66
  this.validate(this.resolvedValue)
56
67
  },
57
68
 
58
69
  computed: {
59
70
  kebabComponentName() {
60
- return kebabCase(this.$options.name).replace(/-([0-9])/g, '$1')
71
+ return resolveKebabComponentName(this.$options.name)
61
72
  },
62
73
  classes() {
63
74
  let classes = {}
@@ -92,11 +103,7 @@ export default {
92
103
  },
93
104
 
94
105
  computedId() {
95
- return this.$attrs.id
96
- ? this.$attrs.id
97
- : `${this.kebabComponentName}_${Math.round(
98
- Math.random() * 10000000000000000
99
- )}`
106
+ return this.$attrs.id ? this.$attrs.id : this.generatedInputId
100
107
  },
101
108
 
102
109
  selectedItem() {
@@ -1,6 +1,9 @@
1
- let nextComponentInstanceId = 0
1
+ import { getCurrentInstance, useId } from 'vue'
2
2
 
3
3
  export default function createComponentInstanceId(prefix = 'asd20-component') {
4
- nextComponentInstanceId += 1
5
- return `${prefix}-${nextComponentInstanceId}`
4
+ if (getCurrentInstance()) {
5
+ return `${prefix}-${useId()}`
6
+ }
7
+
8
+ return `${prefix}-detached`
6
9
  }