@fastkit/vui 0.7.33 → 0.7.34
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/vui.cjs.js +47 -24
- package/dist/vui.cjs.prod.js +47 -24
- package/dist/vui.d.ts +28 -8
- package/dist/vui.mjs +48 -25
- package/package.json +6 -6
- package/src/service.tsx +66 -32
package/dist/vui.cjs.js
CHANGED
|
@@ -4332,24 +4332,19 @@ class VuiService {
|
|
|
4332
4332
|
return this.stack.snackbar(...args);
|
|
4333
4333
|
}
|
|
4334
4334
|
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
} : { ...rawOptions
|
|
4341
|
-
};
|
|
4342
|
-
options.input = { ...options.input
|
|
4335
|
+
formPrompt(settings, slot) {
|
|
4336
|
+
let form;
|
|
4337
|
+
const options = {
|
|
4338
|
+
dense: true,
|
|
4339
|
+
...settings
|
|
4343
4340
|
};
|
|
4344
|
-
options.dense = true;
|
|
4345
|
-
let {
|
|
4346
|
-
initialValue: value = ''
|
|
4347
|
-
} = options.input;
|
|
4348
4341
|
const {
|
|
4349
|
-
size
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4342
|
+
size,
|
|
4343
|
+
state
|
|
4344
|
+
} = options;
|
|
4345
|
+
|
|
4346
|
+
const _state = vue.reactive(state);
|
|
4347
|
+
|
|
4353
4348
|
options.actions = options.actions || [this.stack.action('cancel', undefined, {
|
|
4354
4349
|
size
|
|
4355
4350
|
}), this.stack.action('ok', undefined, {
|
|
@@ -4373,22 +4368,50 @@ class VuiService {
|
|
|
4373
4368
|
form = undefined;
|
|
4374
4369
|
},
|
|
4375
4370
|
"onSubmit": ev => {
|
|
4376
|
-
stack.resolve(
|
|
4371
|
+
stack.resolve(_state);
|
|
4377
4372
|
}
|
|
4378
4373
|
}, {
|
|
4379
|
-
default:
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
value = ev;
|
|
4384
|
-
}
|
|
4385
|
-
}), null)]
|
|
4374
|
+
default: form => slot(_state, {
|
|
4375
|
+
form,
|
|
4376
|
+
stack
|
|
4377
|
+
})
|
|
4386
4378
|
});
|
|
4387
4379
|
}
|
|
4388
4380
|
});
|
|
4389
4381
|
return this.dialog(resolved);
|
|
4390
4382
|
}
|
|
4391
4383
|
|
|
4384
|
+
prompt(rawOptions = {}) {
|
|
4385
|
+
const options = typeof rawOptions === 'string' ? {
|
|
4386
|
+
input: {
|
|
4387
|
+
label: rawOptions
|
|
4388
|
+
}
|
|
4389
|
+
} : { ...rawOptions
|
|
4390
|
+
};
|
|
4391
|
+
options.input = { ...options.input
|
|
4392
|
+
};
|
|
4393
|
+
options.dense = true;
|
|
4394
|
+
const {
|
|
4395
|
+
initialValue: value = ''
|
|
4396
|
+
} = options.input;
|
|
4397
|
+
const {
|
|
4398
|
+
size
|
|
4399
|
+
} = options.input;
|
|
4400
|
+
delete options.input.initialValue;
|
|
4401
|
+
return this.formPrompt({
|
|
4402
|
+
size,
|
|
4403
|
+
...options,
|
|
4404
|
+
state: {
|
|
4405
|
+
input: value
|
|
4406
|
+
}
|
|
4407
|
+
}, state => vue.createVNode(VTextField, vue.mergeProps(options.input, {
|
|
4408
|
+
"modelValue": state.input,
|
|
4409
|
+
"onUpdate:modelValue": $event => state.input = $event
|
|
4410
|
+
}), null)).then(result => {
|
|
4411
|
+
return result ? result.input : result;
|
|
4412
|
+
});
|
|
4413
|
+
}
|
|
4414
|
+
|
|
4392
4415
|
}
|
|
4393
4416
|
|
|
4394
4417
|
function mergeVuiPluginOptions(base, override) {
|
package/dist/vui.cjs.prod.js
CHANGED
|
@@ -4332,24 +4332,19 @@ class VuiService {
|
|
|
4332
4332
|
return this.stack.snackbar(...args);
|
|
4333
4333
|
}
|
|
4334
4334
|
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
} : { ...rawOptions
|
|
4341
|
-
};
|
|
4342
|
-
options.input = { ...options.input
|
|
4335
|
+
formPrompt(settings, slot) {
|
|
4336
|
+
let form;
|
|
4337
|
+
const options = {
|
|
4338
|
+
dense: true,
|
|
4339
|
+
...settings
|
|
4343
4340
|
};
|
|
4344
|
-
options.dense = true;
|
|
4345
|
-
let {
|
|
4346
|
-
initialValue: value = ''
|
|
4347
|
-
} = options.input;
|
|
4348
4341
|
const {
|
|
4349
|
-
size
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4342
|
+
size,
|
|
4343
|
+
state
|
|
4344
|
+
} = options;
|
|
4345
|
+
|
|
4346
|
+
const _state = vue.reactive(state);
|
|
4347
|
+
|
|
4353
4348
|
options.actions = options.actions || [this.stack.action('cancel', undefined, {
|
|
4354
4349
|
size
|
|
4355
4350
|
}), this.stack.action('ok', undefined, {
|
|
@@ -4373,22 +4368,50 @@ class VuiService {
|
|
|
4373
4368
|
form = undefined;
|
|
4374
4369
|
},
|
|
4375
4370
|
"onSubmit": ev => {
|
|
4376
|
-
stack.resolve(
|
|
4371
|
+
stack.resolve(_state);
|
|
4377
4372
|
}
|
|
4378
4373
|
}, {
|
|
4379
|
-
default:
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
value = ev;
|
|
4384
|
-
}
|
|
4385
|
-
}), null)]
|
|
4374
|
+
default: form => slot(_state, {
|
|
4375
|
+
form,
|
|
4376
|
+
stack
|
|
4377
|
+
})
|
|
4386
4378
|
});
|
|
4387
4379
|
}
|
|
4388
4380
|
});
|
|
4389
4381
|
return this.dialog(resolved);
|
|
4390
4382
|
}
|
|
4391
4383
|
|
|
4384
|
+
prompt(rawOptions = {}) {
|
|
4385
|
+
const options = typeof rawOptions === 'string' ? {
|
|
4386
|
+
input: {
|
|
4387
|
+
label: rawOptions
|
|
4388
|
+
}
|
|
4389
|
+
} : { ...rawOptions
|
|
4390
|
+
};
|
|
4391
|
+
options.input = { ...options.input
|
|
4392
|
+
};
|
|
4393
|
+
options.dense = true;
|
|
4394
|
+
const {
|
|
4395
|
+
initialValue: value = ''
|
|
4396
|
+
} = options.input;
|
|
4397
|
+
const {
|
|
4398
|
+
size
|
|
4399
|
+
} = options.input;
|
|
4400
|
+
delete options.input.initialValue;
|
|
4401
|
+
return this.formPrompt({
|
|
4402
|
+
size,
|
|
4403
|
+
...options,
|
|
4404
|
+
state: {
|
|
4405
|
+
input: value
|
|
4406
|
+
}
|
|
4407
|
+
}, state => vue.createVNode(VTextField, vue.mergeProps(options.input, {
|
|
4408
|
+
"modelValue": state.input,
|
|
4409
|
+
"onUpdate:modelValue": $event => state.input = $event
|
|
4410
|
+
}), null)).then(result => {
|
|
4411
|
+
return result ? result.input : result;
|
|
4412
|
+
});
|
|
4413
|
+
}
|
|
4414
|
+
|
|
4392
4415
|
}
|
|
4393
4416
|
|
|
4394
4417
|
function mergeVuiPluginOptions(base, override) {
|
package/dist/vui.d.ts
CHANGED
|
@@ -70,6 +70,7 @@ import { TextareaControl } from '@fastkit/vue-kit';
|
|
|
70
70
|
import { TextInputControl } from '@fastkit/vue-kit';
|
|
71
71
|
import { TypedSlot } from '@fastkit/vue-kit';
|
|
72
72
|
import { UnderlineOptions } from '@tiptap/extension-underline';
|
|
73
|
+
import { UnwrapNestedRefs } from 'vue';
|
|
73
74
|
import { useLink } from 'vue-router';
|
|
74
75
|
import { ValidateTiming } from '@fastkit/vue-kit';
|
|
75
76
|
import { ValidationResult } from '@fastkit/vue-kit';
|
|
@@ -81,9 +82,11 @@ import { VNodeChild } from 'vue';
|
|
|
81
82
|
import { VNodeChildOrSlot } from '@fastkit/vue-kit';
|
|
82
83
|
import { VNodeProps } from 'vue';
|
|
83
84
|
import { VSnackbar } from '@fastkit/vue-kit';
|
|
85
|
+
import { VStackControl } from '@fastkit/vue-kit';
|
|
84
86
|
import { VTooltip } from '@fastkit/vue-kit';
|
|
85
87
|
import { VueColorSchemePluginSettings } from '@fastkit/vue-kit';
|
|
86
|
-
import { VueForm } from '@fastkit/vue-
|
|
88
|
+
import { VueForm } from '@fastkit/vue-form-control';
|
|
89
|
+
import { VueForm as VueForm_2 } from '@fastkit/vue-kit';
|
|
87
90
|
import { VueStackService } from '@fastkit/vue-kit';
|
|
88
91
|
import { VueStackServiceOptions } from '@fastkit/vue-kit';
|
|
89
92
|
import { WritableComputedRef } from 'vue';
|
|
@@ -4609,7 +4612,7 @@ export declare const VForm: DefineComponent<{
|
|
|
4609
4612
|
'v-form--pending': boolean;
|
|
4610
4613
|
'v-form--submiting': boolean;
|
|
4611
4614
|
})[]>;
|
|
4612
|
-
form:
|
|
4615
|
+
form: VueForm_2;
|
|
4613
4616
|
formRef: () => Ref<HTMLFormElement | null>;
|
|
4614
4617
|
nativeAction: ComputedRef<string | undefined>;
|
|
4615
4618
|
nodeControl: FormNodeControl<any, any>;
|
|
@@ -4644,8 +4647,8 @@ export declare const VForm: DefineComponent<{
|
|
|
4644
4647
|
validateSelf: (force?: boolean | undefined) => Promise<ValidationResult>;
|
|
4645
4648
|
validate: () => Promise<boolean>;
|
|
4646
4649
|
}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
4647
|
-
submit: (form:
|
|
4648
|
-
'update:submiting': (submiting: boolean, form:
|
|
4650
|
+
submit: (form: VueForm_2, ev: Event) => boolean;
|
|
4651
|
+
'update:submiting': (submiting: boolean, form: VueForm_2) => boolean;
|
|
4649
4652
|
'update:modelValue': (value: unknown) => boolean;
|
|
4650
4653
|
'update:errors': (errors: FormNodeError[]) => boolean;
|
|
4651
4654
|
change: (value: unknown) => boolean;
|
|
@@ -4697,8 +4700,8 @@ export declare const VForm: DefineComponent<{
|
|
|
4697
4700
|
}> & {
|
|
4698
4701
|
onBlur?: ((ev: FocusEvent) => any) | undefined;
|
|
4699
4702
|
onChange?: ((value: unknown) => any) | undefined;
|
|
4700
|
-
onSubmit?: ((form:
|
|
4701
|
-
"onUpdate:submiting"?: ((submiting: boolean, form:
|
|
4703
|
+
onSubmit?: ((form: VueForm_2, ev: Event) => any) | undefined;
|
|
4704
|
+
"onUpdate:submiting"?: ((submiting: boolean, form: VueForm_2) => any) | undefined;
|
|
4702
4705
|
"onUpdate:modelValue"?: ((value: unknown) => any) | undefined;
|
|
4703
4706
|
"onUpdate:errors"?: ((errors: FormNodeError[]) => any) | undefined;
|
|
4704
4707
|
onFocus?: ((ev: FocusEvent) => any) | undefined;
|
|
@@ -4818,7 +4821,7 @@ export declare const VFormControl: DefineComponent<{
|
|
|
4818
4821
|
}>;
|
|
4819
4822
|
|
|
4820
4823
|
export declare interface VFormSlots {
|
|
4821
|
-
default:
|
|
4824
|
+
default: VueForm_2;
|
|
4822
4825
|
}
|
|
4823
4826
|
|
|
4824
4827
|
export declare const VGridContainer: DefineComponent<{
|
|
@@ -10044,6 +10047,15 @@ export declare const VuiControlInjectionKey: InjectionKey<ControlProvider>;
|
|
|
10044
10047
|
|
|
10045
10048
|
export declare type VuiElevationValue = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24;
|
|
10046
10049
|
|
|
10050
|
+
export declare interface VuiFormPromptSettings<T extends {
|
|
10051
|
+
[key: string]: any;
|
|
10052
|
+
} = {
|
|
10053
|
+
[key: string]: any;
|
|
10054
|
+
}> extends Partial<VDialogProps> {
|
|
10055
|
+
state: T;
|
|
10056
|
+
size?: ControlSize;
|
|
10057
|
+
}
|
|
10058
|
+
|
|
10047
10059
|
export declare const VuiInjectionKey: InjectionKey<VuiService>;
|
|
10048
10060
|
|
|
10049
10061
|
export declare class VuiPlugin {
|
|
@@ -10152,7 +10164,15 @@ export declare class VuiService {
|
|
|
10152
10164
|
alert(...args: Parameters<VueStackService['alert']>): Promise<any>;
|
|
10153
10165
|
confirm(...args: Parameters<VueStackService['confirm']>): Promise<any>;
|
|
10154
10166
|
snackbar(...args: Parameters<VueStackService['snackbar']>): Promise<any>;
|
|
10155
|
-
|
|
10167
|
+
formPrompt<T extends {
|
|
10168
|
+
[key: string]: any;
|
|
10169
|
+
} = {
|
|
10170
|
+
[key: string]: any;
|
|
10171
|
+
}>(settings: VuiFormPromptSettings<T>, slot: (state: UnwrapNestedRefs<T>, ctx: {
|
|
10172
|
+
form: VueForm;
|
|
10173
|
+
stack: VStackControl;
|
|
10174
|
+
}) => VNodeChild): Promise<T | false | undefined>;
|
|
10175
|
+
prompt(rawOptions?: RawVuiPromptOptions): Promise<string | false | undefined>;
|
|
10156
10176
|
}
|
|
10157
10177
|
|
|
10158
10178
|
export declare interface VuiServiceIconSettings {
|
package/dist/vui.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createPropsOptions, createFormControlSettings, defineSlotsProps, useFormControl, VTooltip, renderSlotOrEmpty, createFormSelectorSettings, createFormControlProps, useFormSelectorControl, createFormSelectorItemSettings, useFormSelectorItemControl, createFormSelectorItemGroupProps, useFormSelectorItemGroupControl, resolveVNodeChildOrSlots, useParentFormNode, VMenu, createTextInputSettings, useTextInputControl, createTextareaSettings, useTextareaControl, createFormSettings, useForm, getDocumentScroller, useVScrollerRef, VScroller, useInjectTheme, VStackRoot, resolveVStackDynamicInput, VueColorSchemePlugin, installVueStackPlugin } from '@fastkit/vue-kit';
|
|
2
2
|
export * from '@fastkit/vue-kit';
|
|
3
3
|
export { VDialog, VMenu, VSnackbar, VTooltip } from '@fastkit/vue-kit';
|
|
4
|
-
import { inject, computed, provide, createVNode, mergeProps, defineComponent, isVNode, cloneVNode, ref, watch, withDirectives, createTextVNode, Fragment, vShow, onBeforeUpdate, vModelSelect, onMounted, onBeforeUnmount, Transition } from 'vue';
|
|
4
|
+
import { inject, computed, provide, createVNode, mergeProps, defineComponent, isVNode, cloneVNode, ref, watch, withDirectives, createTextVNode, Fragment, vShow, onBeforeUpdate, vModelSelect, onMounted, onBeforeUnmount, Transition, reactive } from 'vue';
|
|
5
5
|
import { useRouter, RouterLink, useLink, useRoute } from 'vue-router';
|
|
6
6
|
import { createPropsOptions as createPropsOptions$1, htmlAttributesPropOptions, defineSlotsProps as defineSlotsProps$1, renderSlotOrEmpty as renderSlotOrEmpty$1, navigationableInheritProps, VLink, isFragment, rawNumberPropType, resolveNumberish, resizeDirectiveArgument, VExpandTransition, LocationService, setDefaultRouterLink } from '@fastkit/vue-utils';
|
|
7
7
|
import { getDocumentScroller as getDocumentScroller$1 } from '@fastkit/vue-scroller';
|
|
@@ -4327,24 +4327,19 @@ class VuiService {
|
|
|
4327
4327
|
return this.stack.snackbar(...args);
|
|
4328
4328
|
}
|
|
4329
4329
|
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
} : { ...rawOptions
|
|
4336
|
-
};
|
|
4337
|
-
options.input = { ...options.input
|
|
4330
|
+
formPrompt(settings, slot) {
|
|
4331
|
+
let form;
|
|
4332
|
+
const options = {
|
|
4333
|
+
dense: true,
|
|
4334
|
+
...settings
|
|
4338
4335
|
};
|
|
4339
|
-
options.dense = true;
|
|
4340
|
-
let {
|
|
4341
|
-
initialValue: value = ''
|
|
4342
|
-
} = options.input;
|
|
4343
4336
|
const {
|
|
4344
|
-
size
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4337
|
+
size,
|
|
4338
|
+
state
|
|
4339
|
+
} = options;
|
|
4340
|
+
|
|
4341
|
+
const _state = reactive(state);
|
|
4342
|
+
|
|
4348
4343
|
options.actions = options.actions || [this.stack.action('cancel', undefined, {
|
|
4349
4344
|
size
|
|
4350
4345
|
}), this.stack.action('ok', undefined, {
|
|
@@ -4368,22 +4363,50 @@ class VuiService {
|
|
|
4368
4363
|
form = undefined;
|
|
4369
4364
|
},
|
|
4370
4365
|
"onSubmit": ev => {
|
|
4371
|
-
stack.resolve(
|
|
4366
|
+
stack.resolve(_state);
|
|
4372
4367
|
}
|
|
4373
4368
|
}, {
|
|
4374
|
-
default:
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
value = ev;
|
|
4379
|
-
}
|
|
4380
|
-
}), null)]
|
|
4369
|
+
default: form => slot(_state, {
|
|
4370
|
+
form,
|
|
4371
|
+
stack
|
|
4372
|
+
})
|
|
4381
4373
|
});
|
|
4382
4374
|
}
|
|
4383
4375
|
});
|
|
4384
4376
|
return this.dialog(resolved);
|
|
4385
4377
|
}
|
|
4386
4378
|
|
|
4379
|
+
prompt(rawOptions = {}) {
|
|
4380
|
+
const options = typeof rawOptions === 'string' ? {
|
|
4381
|
+
input: {
|
|
4382
|
+
label: rawOptions
|
|
4383
|
+
}
|
|
4384
|
+
} : { ...rawOptions
|
|
4385
|
+
};
|
|
4386
|
+
options.input = { ...options.input
|
|
4387
|
+
};
|
|
4388
|
+
options.dense = true;
|
|
4389
|
+
const {
|
|
4390
|
+
initialValue: value = ''
|
|
4391
|
+
} = options.input;
|
|
4392
|
+
const {
|
|
4393
|
+
size
|
|
4394
|
+
} = options.input;
|
|
4395
|
+
delete options.input.initialValue;
|
|
4396
|
+
return this.formPrompt({
|
|
4397
|
+
size,
|
|
4398
|
+
...options,
|
|
4399
|
+
state: {
|
|
4400
|
+
input: value
|
|
4401
|
+
}
|
|
4402
|
+
}, state => createVNode(VTextField, mergeProps(options.input, {
|
|
4403
|
+
"modelValue": state.input,
|
|
4404
|
+
"onUpdate:modelValue": $event => state.input = $event
|
|
4405
|
+
}), null)).then(result => {
|
|
4406
|
+
return result ? result.input : result;
|
|
4407
|
+
});
|
|
4408
|
+
}
|
|
4409
|
+
|
|
4387
4410
|
}
|
|
4388
4411
|
|
|
4389
4412
|
function mergeVuiPluginOptions(base, override) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastkit/vui",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.34",
|
|
4
4
|
"description": "@fastkit/vui",
|
|
5
5
|
"buildOptions": {
|
|
6
6
|
"name": "Vui",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"vue": "^3.2.26"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@fastkit/color-scheme": "0.7.
|
|
36
|
-
"@fastkit/icon-font": "0.7.
|
|
37
|
-
"@fastkit/tiny-logger": "0.7.
|
|
38
|
-
"@fastkit/vite-kit": "0.7.
|
|
39
|
-
"@fastkit/vue-kit": "0.7.
|
|
35
|
+
"@fastkit/color-scheme": "0.7.34",
|
|
36
|
+
"@fastkit/icon-font": "0.7.34",
|
|
37
|
+
"@fastkit/tiny-logger": "0.7.34",
|
|
38
|
+
"@fastkit/vite-kit": "0.7.34",
|
|
39
|
+
"@fastkit/vue-kit": "0.7.34",
|
|
40
40
|
"@tiptap/extension-link": "^2.0.0-beta.36",
|
|
41
41
|
"@tiptap/extension-underline": "^2.0.0-beta.23",
|
|
42
42
|
"@tiptap/starter-kit": "^2.0.0-beta.183",
|
package/src/service.tsx
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export { VuiInjectionKey } from './injections';
|
|
2
2
|
|
|
3
|
-
import { VNodeChild } from 'vue';
|
|
3
|
+
import { VNodeChild, reactive, UnwrapNestedRefs } from 'vue';
|
|
4
4
|
import { ScopeName, ColorVariant } from '@fastkit/color-scheme';
|
|
5
5
|
import type { IconName, RawIconProp } from './components/VIcon';
|
|
6
6
|
import {
|
|
7
7
|
type VueColorSchemePluginSettings,
|
|
8
8
|
type VueStackService,
|
|
9
9
|
type VDialogProps,
|
|
10
|
+
type VStackControl,
|
|
10
11
|
resolveVStackDynamicInput,
|
|
11
12
|
} from '@fastkit/vue-kit';
|
|
12
13
|
import type { Router } from 'vue-router';
|
|
@@ -16,6 +17,14 @@ import { VForm } from './components/VForm';
|
|
|
16
17
|
import { VTextField, TextFieldInput } from './components/VTextField';
|
|
17
18
|
import { VueForm, FormControlHinttipDelay } from '@fastkit/vue-form-control';
|
|
18
19
|
import { getDocumentScroller } from '@fastkit/vue-scroller';
|
|
20
|
+
import { ControlSize } from './schemes';
|
|
21
|
+
|
|
22
|
+
export interface VuiFormPromptSettings<
|
|
23
|
+
T extends { [key: string]: any } = { [key: string]: any },
|
|
24
|
+
> extends Partial<VDialogProps> {
|
|
25
|
+
state: T;
|
|
26
|
+
size?: ControlSize;
|
|
27
|
+
}
|
|
19
28
|
|
|
20
29
|
export interface VuiPromptOptions extends Partial<VDialogProps> {
|
|
21
30
|
input?: Omit<TextFieldInput, 'modelValue'> & { initialValue?: string };
|
|
@@ -245,30 +254,23 @@ export class VuiService {
|
|
|
245
254
|
return this.stack.snackbar(...args);
|
|
246
255
|
}
|
|
247
256
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
: {
|
|
257
|
-
...rawOptions,
|
|
258
|
-
};
|
|
257
|
+
formPrompt<T extends { [key: string]: any } = { [key: string]: any }>(
|
|
258
|
+
settings: VuiFormPromptSettings<T>,
|
|
259
|
+
slot: (
|
|
260
|
+
state: UnwrapNestedRefs<T>,
|
|
261
|
+
ctx: { form: VueForm; stack: VStackControl },
|
|
262
|
+
) => VNodeChild,
|
|
263
|
+
): Promise<T | false | undefined> {
|
|
264
|
+
let form: VueForm | undefined;
|
|
259
265
|
|
|
260
|
-
options
|
|
261
|
-
|
|
266
|
+
const options = {
|
|
267
|
+
dense: true,
|
|
268
|
+
...settings,
|
|
262
269
|
};
|
|
263
270
|
|
|
264
|
-
|
|
271
|
+
const { size, state } = options;
|
|
265
272
|
|
|
266
|
-
|
|
267
|
-
const { size } = options.input;
|
|
268
|
-
|
|
269
|
-
delete options.input.initialValue;
|
|
270
|
-
|
|
271
|
-
let form: VueForm | undefined;
|
|
273
|
+
const _state = reactive(state);
|
|
272
274
|
|
|
273
275
|
options.actions = options.actions || [
|
|
274
276
|
this.stack.action('cancel', undefined, { size }),
|
|
@@ -297,21 +299,53 @@ export class VuiService {
|
|
|
297
299
|
form = undefined;
|
|
298
300
|
}}
|
|
299
301
|
onSubmit={(ev) => {
|
|
300
|
-
stack.resolve(
|
|
301
|
-
}}
|
|
302
|
-
|
|
303
|
-
{
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
stack.value = ev;
|
|
307
|
-
value = ev;
|
|
308
|
-
}}
|
|
309
|
-
/>
|
|
310
|
-
</VForm>
|
|
302
|
+
stack.resolve(_state);
|
|
303
|
+
}}
|
|
304
|
+
v-slots={{
|
|
305
|
+
default: (form) => slot(_state, { form, stack }),
|
|
306
|
+
}}
|
|
307
|
+
/>
|
|
311
308
|
);
|
|
312
309
|
},
|
|
313
310
|
});
|
|
314
311
|
|
|
315
312
|
return this.dialog(resolved);
|
|
316
313
|
}
|
|
314
|
+
|
|
315
|
+
prompt(rawOptions: RawVuiPromptOptions = {}) {
|
|
316
|
+
const options: VuiPromptOptions =
|
|
317
|
+
typeof rawOptions === 'string'
|
|
318
|
+
? {
|
|
319
|
+
input: {
|
|
320
|
+
label: rawOptions,
|
|
321
|
+
},
|
|
322
|
+
}
|
|
323
|
+
: {
|
|
324
|
+
...rawOptions,
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
options.input = {
|
|
328
|
+
...options.input,
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
options.dense = true;
|
|
332
|
+
|
|
333
|
+
const { initialValue: value = '' } = options.input;
|
|
334
|
+
const { size } = options.input;
|
|
335
|
+
|
|
336
|
+
delete options.input.initialValue;
|
|
337
|
+
|
|
338
|
+
return this.formPrompt(
|
|
339
|
+
{
|
|
340
|
+
size,
|
|
341
|
+
...options,
|
|
342
|
+
state: {
|
|
343
|
+
input: value,
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
(state) => <VTextField {...options.input} v-model={state.input} />,
|
|
347
|
+
).then((result) => {
|
|
348
|
+
return result ? result.input : result;
|
|
349
|
+
});
|
|
350
|
+
}
|
|
317
351
|
}
|