nuxt-ui-tools 1.16.3 → 1.16.5

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
@@ -5,7 +5,7 @@
5
5
  "configKey": "nuxtUiTools",
6
6
  "docs": "https://ui.nuxt.com/docs/getting-started/installation/nuxt",
7
7
  "name": "nuxt-ui-tools",
8
- "version": "1.16.3",
8
+ "version": "1.16.5",
9
9
  "builder": {
10
10
  "@nuxt/module-builder": "1.0.3",
11
11
  "unbuild": "unknown"
@@ -230,8 +230,9 @@ export function useFieldOptions(params) {
230
230
  watch(
231
231
  sourceItems,
232
232
  (nextOptions, previousOptions) => {
233
- if (optionConfig.value?.onOptionsChange) {
234
- optionConfig.value.onOptionsChange(nextOptions, {
233
+ const config = optionConfig.value;
234
+ if (config && "onOptionsChange" in config && config.onOptionsChange) {
235
+ config.onOptionsChange(nextOptions, {
235
236
  ...params.callbackParams.value,
236
237
  previousOptions: previousOptions ?? []
237
238
  });
@@ -455,7 +456,7 @@ function isAsyncResource(value) {
455
456
  return "pending" in value && "fetching" in value && "refresh" in value && isFunction(value.refresh);
456
457
  }
457
458
  function isFormOptionConfig(value) {
458
- return isRecord(value) && "source" in value;
459
+ return isRecord(value) && ("source" in value || value.mode === "remote");
459
460
  }
460
461
  function hasCreateHandler(value) {
461
462
  if (!isRecord(value)) {
@@ -31,6 +31,7 @@ const {
31
31
  { omit: ["createItem", "max", "searchable", "clearable"] }
32
32
  );
33
33
  const searchTerm = ref("");
34
+ const open = ref(false);
34
35
  const model = computed({
35
36
  get: () => {
36
37
  const value = form.getValue(props.path);
@@ -76,8 +77,9 @@ watch(searchTerm, (term) => {
76
77
  options.setSearch(term);
77
78
  }
78
79
  });
79
- function handleOpen(open) {
80
- if (open) {
80
+ function handleOpen(next) {
81
+ open.value = next;
82
+ if (next) {
81
83
  options.activate();
82
84
  }
83
85
  }
@@ -85,7 +87,11 @@ async function handleCreate(label) {
85
87
  await options.create(label);
86
88
  }
87
89
  async function handleCreateAction() {
88
- await options.create(searchTerm.value.trim() || void 0);
90
+ const label = searchTerm.value.trim() || void 0;
91
+ if (!fieldProps.value.multiple) {
92
+ open.value = false;
93
+ }
94
+ await options.create(label);
89
95
  }
90
96
  async function handleNativeCreate(label) {
91
97
  const normalizedLabel = label.trim();
@@ -107,6 +113,7 @@ function isOptionValue(value) {
107
113
  v-if="bare"
108
114
  v-model="model"
109
115
  v-model:search-term="searchTerm"
116
+ :open="open"
110
117
  v-bind="controlProps"
111
118
  class="w-full"
112
119
  value-key="value"
@@ -152,6 +159,7 @@ function isOptionValue(value) {
152
159
  <USelectMenu
153
160
  v-model="model"
154
161
  v-model:search-term="searchTerm"
162
+ :open="open"
155
163
  v-bind="controlProps"
156
164
  class="w-full"
157
165
  value-key="value"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-ui-tools",
3
- "version": "1.16.3",
3
+ "version": "1.16.5",
4
4
  "description": "Nuxt module and runtime toolkit for UI-heavy Nuxt applications",
5
5
  "homepage": "https://github.com/ChronicStone/nuxt-ui-tools#readme",
6
6
  "bugs": "https://github.com/ChronicStone/nuxt-ui-tools/issues",