@una-ui/nuxt-edge 0.66.0-29414839.2a6b00f → 0.67.1-29488065.a37ccec

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/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@una-ui/nuxt-edge",
3
3
  "configKey": "una",
4
- "version": "0.66.0-29414839.2a6b00f",
4
+ "version": "0.67.1-29488065.a37ccec",
5
5
  "compatibility": {
6
6
  "nuxt": ">=3.0.0"
7
7
  },
package/dist/module.mjs CHANGED
@@ -8,7 +8,7 @@ import 'unocss';
8
8
  import 'unocss-preset-animations';
9
9
 
10
10
  const name = "@una-ui/nuxt-edge";
11
- const version = "0.66.0-29414839.2a6b00f";
11
+ const version = "0.67.1-29488065.a37ccec";
12
12
 
13
13
  const module = defineNuxtModule({
14
14
  meta: {
@@ -19,9 +19,10 @@ import ComboboxTrigger from "./ComboboxTrigger.vue";
19
19
  import ComboboxViewport from "./ComboboxViewport.vue";
20
20
  const props = defineProps({
21
21
  modelValue: { type: null, required: false },
22
+ defaultValue: { type: null, required: false },
22
23
  items: { type: Array, required: false },
23
- labelKey: { type: null, required: false },
24
- valueKey: { type: null, required: false },
24
+ labelKey: { type: null, required: false, default: "label" },
25
+ valueKey: { type: null, required: false, default: "value" },
25
26
  groupSeparator: { type: Boolean, required: false },
26
27
  textEmpty: { type: String, required: false, default: "No items found." },
27
28
  label: { type: String, required: false },
@@ -49,7 +50,6 @@ const props = defineProps({
49
50
  openOnClick: { type: Boolean, required: false },
50
51
  ignoreFilter: { type: Boolean, required: false },
51
52
  resetModelValueOnClear: { type: Boolean, required: false },
52
- defaultValue: { type: null, required: false },
53
53
  dir: { type: String, required: false },
54
54
  disabled: { type: Boolean, required: false },
55
55
  highlightOnHover: { type: Boolean, required: false },
@@ -87,8 +87,6 @@ const rootProps = reactiveOmit(props, [
87
87
  "_comboboxCheckbox"
88
88
  ]);
89
89
  const forwarded = useForwardPropsEmits(rootProps, emits);
90
- const labelKey = computed(() => props.labelKey?.toString() ?? "label");
91
- const valueKey = computed(() => props.valueKey?.toString() ?? "value");
92
90
  const hasGroups = computed(() => {
93
91
  return Array.isArray(props.items) && props.items.length > 0 && typeof props.items[0] === "object" && "items" in props.items[0];
94
92
  });
@@ -97,46 +95,44 @@ function getItemProperty(item, key) {
97
95
  return "";
98
96
  return typeof item !== "object" ? item : item[key];
99
97
  }
100
- function findItemByValue(value) {
101
- if (!props.items)
102
- return void 0;
103
- if (hasGroups.value) {
104
- for (const group of props.items) {
105
- const found = group.items?.find((item) => getItemProperty(item, valueKey.value) === value);
106
- if (found)
107
- return found;
108
- }
109
- return void 0;
110
- } else {
111
- return props.items.find((item) => getItemProperty(item, valueKey.value) === value);
112
- }
113
- }
114
98
  function getDisplayValue(val) {
115
- if (!val || Array.isArray(val) && val.length === 0)
99
+ if (val == null || Array.isArray(val) && val.length === 0)
116
100
  return "";
117
- if (props.multiple && Array.isArray(val)) {
101
+ if (Array.isArray(val)) {
118
102
  return val.map((v) => {
119
103
  if (typeof v !== "object" || v === null) {
120
- const item = findItemByValue(v);
121
- return item ? getItemProperty(item, labelKey.value) : v;
104
+ return String(v);
122
105
  }
123
- return getItemProperty(v, labelKey.value) || getItemProperty(v, valueKey.value) || "";
124
- }).filter(Boolean).join(", ");
106
+ return getItemProperty(v, props.labelKey) || getItemProperty(v, props.valueKey) || "";
107
+ }).filter((v) => v !== null && v !== void 0).join(", ");
125
108
  }
126
109
  if (typeof val !== "object" || val === null) {
127
- const item = findItemByValue(val);
128
- return item ? getItemProperty(item, labelKey.value) : String(val || "");
110
+ return String(val);
129
111
  }
130
- return getItemProperty(val, labelKey.value) || getItemProperty(val, valueKey.value) || "";
112
+ return getItemProperty(val, props.labelKey) || getItemProperty(val, props.valueKey) || "";
131
113
  }
132
114
  function isItemSelected(item) {
133
- if (item == null)
115
+ if (item == null || !props.modelValue)
134
116
  return false;
135
- const itemValue = getItemProperty(item, valueKey.value);
136
- if (props.multiple && Array.isArray(props.modelValue)) {
137
- return props.modelValue.includes(itemValue);
117
+ if (typeof item !== "object") {
118
+ if (Array.isArray(props.modelValue)) {
119
+ return props.modelValue.includes(item);
120
+ }
121
+ return props.modelValue === item;
122
+ }
123
+ const itemValue = getItemProperty(item, props.valueKey);
124
+ if (Array.isArray(props.modelValue)) {
125
+ return props.modelValue.some((v) => {
126
+ if (typeof v !== "object" || v === null) {
127
+ return v === itemValue;
128
+ }
129
+ return getItemProperty(v, props.valueKey) === itemValue;
130
+ });
131
+ }
132
+ if (typeof props.modelValue !== "object" || props.modelValue === null) {
133
+ return props.modelValue === itemValue;
138
134
  }
139
- return typeof props.modelValue === "object" && props.modelValue !== null ? getItemProperty(props.modelValue, valueKey.value) === itemValue : props.modelValue === itemValue;
135
+ return getItemProperty(props.modelValue, props.valueKey) === itemValue;
140
136
  }
141
137
  </script>
142
138
 
@@ -253,8 +249,8 @@ function isItemSelected(item) {
253
249
  <slot name="group">
254
250
  <ComboboxItem
255
251
  v-for="item in items"
256
- :key="getItemProperty(item, valueKey)"
257
- :value="props.multiple ? getItemProperty(item, valueKey) : item"
252
+ :key="getItemProperty(item, props.valueKey)"
253
+ :value="item"
258
254
  :size
259
255
  v-bind="props._comboboxItem"
260
256
  :class="cn(
@@ -264,7 +260,7 @@ function isItemSelected(item) {
264
260
  >
265
261
  <slot name="item" :item="item" :selected="isItemSelected(item)">
266
262
  <slot name="label" :item="item">
267
- {{ getItemProperty(item, labelKey) }}
263
+ {{ getItemProperty(item, props.labelKey) }}
268
264
  </slot>
269
265
 
270
266
  <ComboboxItemIndicator
@@ -299,8 +295,8 @@ function isItemSelected(item) {
299
295
  <slot name="group" :group="group">
300
296
  <ComboboxItem
301
297
  v-for="item in group.items"
302
- :key="getItemProperty(item, valueKey)"
303
- :value="props.multiple ? getItemProperty(item, valueKey) : item"
298
+ :key="getItemProperty(item, props.valueKey)"
299
+ :value="item"
304
300
  :size
305
301
  v-bind="{ ...props._comboboxItem, ...group._comboboxItem }"
306
302
  :class="cn(
@@ -310,7 +306,7 @@ function isItemSelected(item) {
310
306
  >
311
307
  <slot name="item" :item="item" :group="group" :selected="isItemSelected(item)">
312
308
  <slot name="label" :item="item">
313
- {{ getItemProperty(item, labelKey) }}
309
+ {{ getItemProperty(item, props.labelKey) }}
314
310
  </slot>
315
311
 
316
312
  <ComboboxItemIndicator
@@ -7,7 +7,7 @@ defineOptions({
7
7
  inheritAttrs: false
8
8
  });
9
9
  const props = defineProps({
10
- displayValue: { type: Function, required: false },
10
+ displayValue: { type: Function, required: false, default: () => "" },
11
11
  modelValue: { type: String, required: false },
12
12
  autoFocus: { type: Boolean, required: false },
13
13
  disabled: { type: Boolean, required: false },
@@ -1,16 +1,38 @@
1
+ import type { NComboboxInputProps } from '../../types/index.js';
1
2
  declare var __VLS_12: any, __VLS_13: any;
2
3
  type __VLS_Slots = {} & {
3
4
  [K in NonNullable<typeof __VLS_12>]?: (props: typeof __VLS_13) => any;
4
5
  };
5
- declare const __VLS_component: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
+ declare const __VLS_component: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<NComboboxInputProps>, {
7
+ displayValue: () => "";
8
+ }>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
9
  "update:modelValue": (args_0: string) => any;
7
- }, string, import("vue").PublicProps, Readonly<{}> & Readonly<{
10
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<NComboboxInputProps>, {
11
+ displayValue: () => "";
12
+ }>>> & Readonly<{
8
13
  "onUpdate:modelValue"?: ((args_0: string) => any) | undefined;
9
14
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
15
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
11
16
  export default _default;
17
+ type __VLS_WithDefaults<P, D> = {
18
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
19
+ default: D[K];
20
+ }> : P[K];
21
+ };
22
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
23
+ type __VLS_TypePropsToOption<T> = {
24
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
25
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
26
+ } : {
27
+ type: import('vue').PropType<T[K]>;
28
+ required: true;
29
+ };
30
+ };
12
31
  type __VLS_WithSlots<T, S> = T & {
13
32
  new (): {
14
33
  $slots: S;
15
34
  };
16
35
  };
36
+ type __VLS_PrettifyLocal<T> = {
37
+ [K in keyof T]: T[K];
38
+ } & {};
@@ -42,7 +42,7 @@ const delegatedProps = reactiveOmit(props, ["class"]);
42
42
  'progress-indicator',
43
43
  props.una?.progressIndicator
44
44
  )"
45
- :style="`transform: translateX(-${100 - (modelValue ?? 0)}%);`"
45
+ :style="`transform: translateX(-${100 - (modelValue ?? 0) / (props.max || 100) * 100}%)`"
46
46
  />
47
47
  <template
48
48
  v-else
@@ -14,8 +14,8 @@ import SelectTrigger from "./SelectTrigger.vue";
14
14
  import SelectValue from "./SelectValue.vue";
15
15
  const props = defineProps({
16
16
  items: { type: null, required: false },
17
- itemKey: { type: null, required: false },
18
- valueKey: { type: null, required: false },
17
+ labelKey: { type: null, required: false, default: "label" },
18
+ valueKey: { type: null, required: false, default: "value" },
19
19
  label: { type: String, required: false },
20
20
  groupSeparator: { type: Boolean, required: false },
21
21
  defaultValue: { type: null, required: false },
@@ -56,16 +56,25 @@ const forwarded = useForwardPropsEmits(props, emits);
56
56
  function formatSelectedValue(value) {
57
57
  if (!value || Array.isArray(value) && value.length === 0)
58
58
  return null;
59
- if (props.multiple && Array.isArray(value)) {
59
+ const findItemByValue = (val) => {
60
+ const allItems = hasGroups.value ? props.items.flatMap((group) => group.items) : props.items;
61
+ return allItems?.find((item2) => {
62
+ const itemValue = props.valueKey && typeof item2 === "object" ? item2[props.valueKey] : item2;
63
+ return itemValue === val;
64
+ });
65
+ };
66
+ if (Array.isArray(value)) {
60
67
  return value.map((val) => {
61
- if (props.valueKey && typeof val === "object") {
62
- return val[props.valueKey];
68
+ const item2 = findItemByValue(val);
69
+ if (item2 && props.labelKey && typeof item2 === "object") {
70
+ return item2[props.labelKey];
63
71
  }
64
72
  return val;
65
73
  }).join(", ");
66
74
  }
67
- if (props.valueKey && typeof value === "object") {
68
- return value[props.valueKey];
75
+ const item = findItemByValue(value);
76
+ if (item && props.labelKey && typeof item === "object") {
77
+ return item[props.labelKey];
69
78
  }
70
79
  return value;
71
80
  }
@@ -73,6 +82,7 @@ function formatSelectedValue(value) {
73
82
 
74
83
  <template>
75
84
  <SelectRoot
85
+ v-slot="{ modelValue, open }"
76
86
  :class="cn(
77
87
  props.una?.select,
78
88
  props.class
@@ -131,14 +141,14 @@ function formatSelectedValue(value) {
131
141
  :key="item"
132
142
  >
133
143
  <SelectItem
134
- :value="item"
144
+ :value="props.valueKey && typeof item === 'object' ? item[props.valueKey] : item"
135
145
  :size
136
146
  :select-item
137
147
  v-bind="props._selectItem"
138
148
  :una
139
149
  >
140
150
  <slot name="item" :item="item">
141
- {{ props.itemKey && item ? item[props.itemKey] : item }}
151
+ {{ props.labelKey && typeof item === "object" ? item[props.labelKey] : item }}
142
152
  </slot>
143
153
  <template #indicator>
144
154
  <slot name="indicator" :item="item" />
@@ -177,14 +187,14 @@ function formatSelectedValue(value) {
177
187
  :key="item"
178
188
  >
179
189
  <SelectItem
180
- :value="item"
190
+ :value="props.valueKey && typeof item === 'object' ? item[props.valueKey] : item"
181
191
  :size
182
192
  :select-item
183
193
  v-bind="{ ..._selectItem, ...group._selectItem }"
184
194
  :una
185
195
  >
186
196
  <slot name="item" :item="item">
187
- {{ props.itemKey ? item[props.itemKey] : item }}
197
+ {{ props.labelKey && typeof item === "object" ? item[props.labelKey] : item }}
188
198
  </slot>
189
199
  <template #indicator>
190
200
  <slot name="indicator" :item="item" />
@@ -10,12 +10,17 @@ interface BaseExtensions {
10
10
  export type ExtractItemType<T> = T extends {
11
11
  items: infer I extends AcceptableValue[];
12
12
  } ? I[number] : T;
13
- export interface NComboboxProps<T extends AcceptableValue, M extends boolean> extends Omit<ComboboxRootProps<ExtractItemType<T>>, 'modelValue'>, Pick<NComboboxInputProps, 'status' | 'id'>, BaseExtensions {
13
+ export interface NComboboxProps<T extends AcceptableValue, M extends boolean> extends Omit<ComboboxRootProps<ExtractItemType<T>>, 'modelValue' | 'defaultValue'>, Pick<NComboboxInputProps, 'status' | 'id'>, BaseExtensions {
14
14
  /**
15
15
  * The model value for the combobox.
16
- * When using grouped items, this will be the item type from within the groups.
16
+ * Stores the full item object(s), not extracted values.
17
17
  */
18
- modelValue?: (M extends true ? ExtractItemType<T>[] : ExtractItemType<T>) | null;
18
+ modelValue?: M extends true ? ExtractItemType<T>[] | null : ExtractItemType<T> | null;
19
+ /**
20
+ * The default value for the combobox.
21
+ * Should be the full item object(s), not extracted values.
22
+ */
23
+ defaultValue?: M extends true ? ExtractItemType<T>[] | null : ExtractItemType<T> | null;
19
24
  /**
20
25
  * The items to display in the combobox.
21
26
  *
@@ -23,17 +28,17 @@ export interface NComboboxProps<T extends AcceptableValue, M extends boolean> ex
23
28
  */
24
29
  items?: T[] | NComboboxGroupProps<ExtractItemType<T>>[];
25
30
  /**
26
- * The key name to use to display in the select items.
31
+ * The key name to use to display in the combobox items.
27
32
  *
28
33
  * @default 'label'
29
34
  */
30
- labelKey?: keyof ExtractItemType<T>;
35
+ labelKey?: keyof ExtractItemType<T> | string;
31
36
  /**
32
- * The key name to use to display in the selected value.
37
+ * The key name to use for comparing items (used for selection matching).
33
38
  *
34
39
  * @default 'value'
35
40
  */
36
- valueKey?: keyof ExtractItemType<T>;
41
+ valueKey?: keyof ExtractItemType<T> | string;
37
42
  /**
38
43
  * Whether to show a separator between groups.
39
44
  *
@@ -22,7 +22,7 @@ export interface SelectGroup<T extends AcceptableValue> {
22
22
  _selectLabel?: Partial<NSelectLabelProps>;
23
23
  _selectItem?: Partial<NSelectItemProps>;
24
24
  }
25
- export interface NSelectProps<T extends AcceptableValue, Items extends Array<T | SelectGroup<T>>, M extends boolean = false> extends SelectExtensions<T> {
25
+ export interface NSelectProps<T extends AcceptableValue, Items extends Array<T | SelectGroup<T>>, M extends boolean = false> extends Omit<SelectExtensions<T>, 'modelValue' | 'defaultValue'> {
26
26
  /**
27
27
  * The items to display in the select.
28
28
  */
@@ -30,11 +30,11 @@ export interface NSelectProps<T extends AcceptableValue, Items extends Array<T |
30
30
  /**
31
31
  * The key name to use to display in the select items.
32
32
  */
33
- itemKey?: keyof T;
33
+ labelKey?: keyof T | string;
34
34
  /**
35
35
  * The key name to use to display in the selected value.
36
36
  */
37
- valueKey?: keyof T;
37
+ valueKey?: keyof T | string;
38
38
  /**
39
39
  * The label to display above the select items.
40
40
  */
@@ -45,8 +45,8 @@ export interface NSelectProps<T extends AcceptableValue, Items extends Array<T |
45
45
  * @default false
46
46
  */
47
47
  groupSeparator?: boolean;
48
- defaultValue?: M extends true ? T[] : T;
49
- modelValue?: M extends true ? T[] : T;
48
+ defaultValue?: M extends true ? any[] : any;
49
+ modelValue?: M extends true ? any[] : any;
50
50
  multiple?: M;
51
51
  /**
52
52
  * Sub-component configurations
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@una-ui/nuxt-edge",
3
3
  "type": "module",
4
- "version": "0.66.0-29414839.2a6b00f",
4
+ "version": "0.67.1-29488065.a37ccec",
5
5
  "description": "Nuxt module for @una-ui",
6
6
  "author": "Phojie Rengel <phojrengel@gmail.com>",
7
7
  "license": "MIT",
@@ -40,8 +40,8 @@
40
40
  "@nuxt/kit": "^3.19.2",
41
41
  "@nuxtjs/color-mode": "^3.5.2",
42
42
  "@tanstack/vue-table": "^8.21.3",
43
- "@una-ui/extractor-vue-script": "npm:@una-ui/extractor-vue-script-edge@0.66.0-29414839.2a6b00f",
44
- "@una-ui/preset": "npm:@una-ui/preset-edge@0.66.0-29414839.2a6b00f",
43
+ "@una-ui/extractor-vue-script": "npm:@una-ui/extractor-vue-script-edge@0.67.1-29488065.a37ccec",
44
+ "@una-ui/preset": "npm:@una-ui/preset-edge@0.67.1-29488065.a37ccec",
45
45
  "@unocss/core": "^66.5.10",
46
46
  "@unocss/nuxt": "^66.5.10",
47
47
  "@unocss/preset-attributify": "^66.5.10",
@@ -62,9 +62,9 @@
62
62
  "vaul-vue": "^0.4.1"
63
63
  },
64
64
  "devDependencies": {
65
- "@iconify-json/lucide": "^1.2.78",
66
- "@iconify-json/radix-icons": "^1.2.5",
67
- "@iconify-json/tabler": "^1.2.23",
65
+ "@iconify-json/lucide": "^1.2.86",
66
+ "@iconify-json/radix-icons": "^1.2.6",
67
+ "@iconify-json/tabler": "^1.2.26",
68
68
  "@nuxt/module-builder": "^1.0.2",
69
69
  "@nuxt/schema": "^3.19.2",
70
70
  "nuxt": "^3.19.2",