@nexxtmove/ui 1.6.0 → 1.7.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,7 +1,7 @@
1
1
  {
2
2
  "name": "@nexxtmove/ui",
3
3
  "type": "module",
4
- "version": "1.6.0",
4
+ "version": "1.7.0",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.ts",
@@ -1,11 +1,29 @@
1
1
  <script setup lang="ts">
2
- import { computed, getCurrentInstance, useTemplateRef } from 'vue'
2
+ import { computed, getCurrentInstance, useAttrs, useTemplateRef } from 'vue'
3
3
  import Icon from '../Icon/Icon.vue'
4
4
 
5
5
  const INPUT_ID = 'input-field-' + Math.random().toString(36).slice(2, 10)
6
6
 
7
+ const attrs = useAttrs()
8
+
9
+ // `class` and `style` describe where the field sits in the consumer's layout,
10
+ // so they belong on the outer wrapper. Everything else -- id, name, type,
11
+ // placeholder, data-* , aria-* -- describes the control, so it goes to the
12
+ // input. Nothing lands on both any more.
13
+ const inputAttrs = computed(() => {
14
+ const rest: Record<string, unknown> = { ...attrs }
15
+ delete rest.class
16
+ delete rest.style
17
+ return rest
18
+ })
19
+
7
20
  defineOptions({
8
21
  name: 'NexxtInputField',
22
+ // Attributes used to land twice: Vue applied them to the root *and* the
23
+ // explicit v-bind put them on the input. `id` was therefore duplicated across
24
+ // two elements, and a consumer's layout class ended up on an input that
25
+ // already carries `w-full` itself. Routing is now explicit: see the template.
26
+ inheritAttrs: false,
9
27
  })
10
28
 
11
29
  export interface NexxtInputFieldProps {
@@ -50,7 +68,7 @@ const decrement = () => {
50
68
  </script>
51
69
 
52
70
  <template>
53
- <div class="inline-flex flex-col gap-1">
71
+ <div class="inline-flex flex-col gap-1" :class="attrs.class" :style="attrs.style">
54
72
  <label v-if="label" class="justify-start small-normal text-gray-700" :for="INPUT_ID">
55
73
  {{ label }}
56
74
  <span v-if="required" class="text-brick-500">*</span>
@@ -69,7 +87,7 @@ const decrement = () => {
69
87
  :id="INPUT_ID"
70
88
  v-model="modelValue"
71
89
  :placeholder="placeholder"
72
- v-bind="$attrs"
90
+ v-bind="inputAttrs"
73
91
  class="bg-transparant h-10 w-full min-w-60 text-sm text-gray-900 placeholder-gray-400 focus:outline-none [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"
74
92
  :class="{ 'pl-3': !leftIcon, 'pr-3': !rightIcon }"
75
93
  />
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" setup>
2
- import { computed } from 'vue'
2
+ import { computed, useAttrs } from 'vue'
3
3
  import NexxtIcon from '../Icon/Icon.vue'
4
4
  import NexxtFloatingPanel from '../FloatingPanel/FloatingPanel.vue'
5
5
  import type Icon from '../Icon/Icon.vue'
@@ -11,7 +11,24 @@ const generateId = () => 'input-select-' + Math.random().toString(36).slice(2, 1
11
11
  const fieldId = generateId()
12
12
  const selectId = generateId()
13
13
 
14
- defineOptions({ name: 'NexxtInputSelect' })
14
+ const attrs = useAttrs()
15
+
16
+ // `class` and `style` position the field in the consumer's layout and belong on
17
+ // the wrapper; everything else describes the control and goes to the input.
18
+ const inputAttrs = computed(() => {
19
+ const rest: Record<string, unknown> = { ...attrs }
20
+ delete rest.class
21
+ delete rest.style
22
+ return rest
23
+ })
24
+
25
+ defineOptions({
26
+ name: 'NexxtInputSelect',
27
+ // Same routing as NexxtInputField: attributes used to land on the root and
28
+ // the input at once, duplicating `id` and putting layout classes on a control
29
+ // that is already full-width. See the template.
30
+ inheritAttrs: false,
31
+ })
15
32
 
16
33
  export interface NexxtInputSelectProps {
17
34
  options: SelectOption[]
@@ -49,7 +66,7 @@ const select = (opt: SelectOption, close: () => void) => {
49
66
  </script>
50
67
 
51
68
  <template>
52
- <div class="inline-flex flex-col gap-1">
69
+ <div class="inline-flex flex-col gap-1" :class="attrs.class" :style="attrs.style">
53
70
  <label v-if="label" class="justify-start small-normal text-gray-700" :for="fieldId">
54
71
  {{ label }}
55
72
  <span v-if="required" class="text-brick-500">*</span>
@@ -114,7 +131,7 @@ const select = (opt: SelectOption, close: () => void) => {
114
131
  :id="fieldId"
115
132
  v-model="inputModel"
116
133
  :placeholder="placeholder"
117
- v-bind="$attrs"
134
+ v-bind="inputAttrs"
118
135
  class="bg-transparant h-10 w-full min-w-40 px-3 text-sm text-gray-900 placeholder-gray-400 focus:outline-none"
119
136
  />
120
137
  </div>