nuxt-ui-tools 1.10.0 → 1.10.1

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.10.0",
8
+ "version": "1.10.1",
9
9
  "builder": {
10
10
  "@nuxt/module-builder": "1.0.3",
11
11
  "unbuild": "unknown"
@@ -30,7 +30,7 @@ export declare function useFieldControl<TField extends FormField>(field: () => T
30
30
  activate: () => void;
31
31
  add: (option: FormValue) => import("../utils/options.js").ResolvedFormOption;
32
32
  creatable: import("vue").ComputedRef<boolean>;
33
- create: (label: string) => Promise<import("../utils/options.js").ResolvedFormOption | null>;
33
+ create: (label?: string) => Promise<import("../utils/options.js").ResolvedFormOption | null>;
34
34
  createLabel: import("vue").ComputedRef<string | undefined>;
35
35
  creating: import("vue").ComputedRef<boolean>;
36
36
  disableOnLoading: import("vue").ComputedRef<boolean>;
@@ -12,7 +12,7 @@ export declare function useFieldOptions(params: {
12
12
  activate: () => void;
13
13
  add: (option: FormValue) => ResolvedFormOption;
14
14
  creatable: ComputedRef<boolean>;
15
- create: (label: string) => Promise<ResolvedFormOption | null>;
15
+ create: (label?: string) => Promise<ResolvedFormOption | null>;
16
16
  createLabel: ComputedRef<string | undefined>;
17
17
  creating: ComputedRef<boolean>;
18
18
  disableOnLoading: ComputedRef<boolean>;
@@ -46,7 +46,10 @@ export function useFieldOptions(params) {
46
46
  }
47
47
  return resolveTrackedOptionSource(params.field(), params.callbackParams.value);
48
48
  });
49
- const resolvedSource = computed(() => trackedOptionSource.value.source);
49
+ const resolvedSource = computed(() => {
50
+ const { source } = trackedOptionSource.value;
51
+ return isRuntimeQueryOptions(source) && isDisabledQueryOptions(source) ? [] : source;
52
+ });
50
53
  const contextResources = computed(() => {
51
54
  const { ctx } = params.callbackParams.value;
52
55
  if (!isRecord(ctx)) {
@@ -260,8 +263,8 @@ export function useFieldOptions(params) {
260
263
  return normalized;
261
264
  }
262
265
  async function create(label) {
263
- const normalizedLabel = label.trim();
264
- if (!normalizedLabel || creating.value) {
266
+ const normalizedLabel = label?.trim() ?? "";
267
+ if (!isUndefined(label) && !normalizedLabel || creating.value) {
265
268
  return null;
266
269
  }
267
270
  const createOption = optionConfig.value?.create;
@@ -435,6 +438,9 @@ function trackContextAccess(ctx, contextKeys) {
435
438
  }
436
439
  });
437
440
  }
441
+ function isDisabledQueryOptions(source) {
442
+ return Object.getOwnPropertyDescriptor(source, "enabled")?.value === false;
443
+ }
438
444
  function isRuntimeQueryOptions(value) {
439
445
  if (!isRecord(value)) {
440
446
  return false;
@@ -77,7 +77,7 @@ async function handleCreate(label) {
77
77
  await options.create(label);
78
78
  }
79
79
  async function handleCreateAction() {
80
- await handleCreate(searchTerm.value);
80
+ await options.create(searchTerm.value.trim() || void 0);
81
81
  }
82
82
  async function handleNativeCreate(label) {
83
83
  const normalizedLabel = label.trim();
@@ -85,7 +85,7 @@ async function handleCreate(label) {
85
85
  await options.create(label);
86
86
  }
87
87
  async function handleCreateAction() {
88
- await handleCreate(searchTerm.value);
88
+ await options.create(searchTerm.value.trim() || void 0);
89
89
  }
90
90
  async function handleNativeCreate(label) {
91
91
  const normalizedLabel = label.trim();
@@ -86,8 +86,11 @@ export interface FormFieldOptionsApi<TOption = FormValue> {
86
86
  error: () => FormValue | null;
87
87
  /** Refreshes the option source when it is async or query-backed. */
88
88
  refresh: () => Promise<void>;
89
- /** Creates a new option when the field configured an option creation handler. */
90
- create: (label: string) => Promise<TOption | null>;
89
+ /**
90
+ * Creates a new option when the field configured an option creation handler. A blank typed label
91
+ * creates nothing; calling it without a label runs the handler with an empty one.
92
+ */
93
+ create: (label?: string) => Promise<TOption | null>;
91
94
  /** Returns hydrated options for the current selection, including values outside loaded pages. */
92
95
  selected: () => readonly TOption[];
93
96
  /** True when the field loads options remotely. */
@@ -49,5 +49,6 @@ export interface FormOptionRuntimeState {
49
49
  /** Loads the direct children of a remote tree option. */
50
50
  loadChildren: (option: ResolvedFormOption) => Promise<void>;
51
51
  add: (option: FormValue) => void;
52
- create: (label: string) => Promise<ResolvedFormOption | null>;
52
+ /** Creates an option; a blank typed label creates nothing, and no label runs the handler with an empty one. */
53
+ create: (label?: string) => Promise<ResolvedFormOption | null>;
53
54
  }
@@ -33,7 +33,10 @@ export type FormOptionsSource<TOption, TContext = NonNullable<unknown>, TDeps =
33
33
  * Option creation hook for fields that can create a missing option from user input.
34
34
  */
35
35
  export interface FormCreateOptionParams<TContext = NonNullable<unknown>, TDeps = FormDependencies, TValue = FormValue, TOption = FormValue> extends FormFieldCallbackParams<TContext, TDeps, TValue, TOption> {
36
- /** User-entered label that should be converted into a concrete option. */
36
+ /**
37
+ * User-entered label that should be converted into a concrete option. Empty when the explicit
38
+ * create action runs without a search term, such as a creator that opens its own form.
39
+ */
37
40
  label: string;
38
41
  }
39
42
  export interface FormCreateOption<TOption, TContext = NonNullable<unknown>, TDeps = FormDependencies, TValue = FormValue> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-ui-tools",
3
- "version": "1.10.0",
3
+ "version": "1.10.1",
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",