@fastkit/vui 0.7.33 → 0.7.36

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 CHANGED
@@ -4332,24 +4332,19 @@ class VuiService {
4332
4332
  return this.stack.snackbar(...args);
4333
4333
  }
4334
4334
 
4335
- prompt(rawOptions = {}) {
4336
- const options = typeof rawOptions === 'string' ? {
4337
- input: {
4338
- label: rawOptions
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
- } = options.input;
4351
- delete options.input.initialValue;
4352
- let form;
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, {
@@ -4366,29 +4361,57 @@ class VuiService {
4366
4361
  return vue.createVNode(VForm, {
4367
4362
  "disableAutoScroll": true,
4368
4363
  "size": size,
4369
- "onVnodeMounted": vnode => {
4370
- form = vnode.component.ctx.form;
4371
- },
4372
4364
  "onVnodeBeforeUnmount": () => {
4373
4365
  form = undefined;
4374
4366
  },
4375
4367
  "onSubmit": ev => {
4376
- stack.resolve(value);
4368
+ stack.resolve(_state);
4377
4369
  }
4378
4370
  }, {
4379
- default: () => [vue.createVNode(VTextField, vue.mergeProps(options.input, {
4380
- "modelValue": value,
4381
- "onChange": ev => {
4382
- stack.value = ev;
4383
- value = ev;
4384
- }
4385
- }), null)]
4371
+ default: _form => {
4372
+ form = _form;
4373
+ return slot(_state, {
4374
+ form,
4375
+ stack
4376
+ });
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) {
@@ -4332,24 +4332,19 @@ class VuiService {
4332
4332
  return this.stack.snackbar(...args);
4333
4333
  }
4334
4334
 
4335
- prompt(rawOptions = {}) {
4336
- const options = typeof rawOptions === 'string' ? {
4337
- input: {
4338
- label: rawOptions
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
- } = options.input;
4351
- delete options.input.initialValue;
4352
- let form;
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, {
@@ -4366,29 +4361,57 @@ class VuiService {
4366
4361
  return vue.createVNode(VForm, {
4367
4362
  "disableAutoScroll": true,
4368
4363
  "size": size,
4369
- "onVnodeMounted": vnode => {
4370
- form = vnode.component.ctx.form;
4371
- },
4372
4364
  "onVnodeBeforeUnmount": () => {
4373
4365
  form = undefined;
4374
4366
  },
4375
4367
  "onSubmit": ev => {
4376
- stack.resolve(value);
4368
+ stack.resolve(_state);
4377
4369
  }
4378
4370
  }, {
4379
- default: () => [vue.createVNode(VTextField, vue.mergeProps(options.input, {
4380
- "modelValue": value,
4381
- "onChange": ev => {
4382
- stack.value = ev;
4383
- value = ev;
4384
- }
4385
- }), null)]
4371
+ default: _form => {
4372
+ form = _form;
4373
+ return slot(_state, {
4374
+ form,
4375
+ stack
4376
+ });
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-kit';
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: VueForm;
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: VueForm, ev: Event) => boolean;
4648
- 'update:submiting': (submiting: boolean, form: VueForm) => boolean;
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: VueForm, ev: Event) => any) | undefined;
4701
- "onUpdate:submiting"?: ((submiting: boolean, form: VueForm) => any) | undefined;
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: VueForm;
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
- prompt(rawOptions?: RawVuiPromptOptions): Promise<any>;
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
- prompt(rawOptions = {}) {
4331
- const options = typeof rawOptions === 'string' ? {
4332
- input: {
4333
- label: rawOptions
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
- } = options.input;
4346
- delete options.input.initialValue;
4347
- let form;
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, {
@@ -4361,29 +4356,57 @@ class VuiService {
4361
4356
  return createVNode(VForm, {
4362
4357
  "disableAutoScroll": true,
4363
4358
  "size": size,
4364
- "onVnodeMounted": vnode => {
4365
- form = vnode.component.ctx.form;
4366
- },
4367
4359
  "onVnodeBeforeUnmount": () => {
4368
4360
  form = undefined;
4369
4361
  },
4370
4362
  "onSubmit": ev => {
4371
- stack.resolve(value);
4363
+ stack.resolve(_state);
4372
4364
  }
4373
4365
  }, {
4374
- default: () => [createVNode(VTextField, mergeProps(options.input, {
4375
- "modelValue": value,
4376
- "onChange": ev => {
4377
- stack.value = ev;
4378
- value = ev;
4379
- }
4380
- }), null)]
4366
+ default: _form => {
4367
+ form = _form;
4368
+ return slot(_state, {
4369
+ form,
4370
+ stack
4371
+ });
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.33",
3
+ "version": "0.7.36",
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.33",
36
- "@fastkit/icon-font": "0.7.33",
37
- "@fastkit/tiny-logger": "0.7.33",
38
- "@fastkit/vite-kit": "0.7.33",
39
- "@fastkit/vue-kit": "0.7.33",
35
+ "@fastkit/color-scheme": "0.7.36",
36
+ "@fastkit/icon-font": "0.7.36",
37
+ "@fastkit/tiny-logger": "0.7.36",
38
+ "@fastkit/vite-kit": "0.7.36",
39
+ "@fastkit/vue-kit": "0.7.36",
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
- prompt(rawOptions: RawVuiPromptOptions = {}) {
249
- const options: VuiPromptOptions =
250
- typeof rawOptions === 'string'
251
- ? {
252
- input: {
253
- label: rawOptions,
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.input = {
261
- ...options.input,
266
+ const options = {
267
+ dense: true,
268
+ ...settings,
262
269
  };
263
270
 
264
- options.dense = true;
271
+ const { size, state } = options;
265
272
 
266
- let { initialValue: value = '' } = options.input;
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 }),
@@ -290,28 +292,63 @@ export class VuiService {
290
292
  <VForm
291
293
  disableAutoScroll
292
294
  size={size}
293
- onVnodeMounted={(vnode) => {
294
- form = (vnode.component as any).ctx.form as VueForm;
295
- }}
295
+ // onVnodeMounted={(vnode) => {
296
+ // form = (vnode.component as any).ctx.form as VueForm;
297
+ // }}
296
298
  onVnodeBeforeUnmount={() => {
297
299
  form = undefined;
298
300
  }}
299
301
  onSubmit={(ev) => {
300
- stack.resolve(value);
301
- }}>
302
- <VTextField
303
- {...options.input}
304
- modelValue={value}
305
- onChange={(ev) => {
306
- stack.value = ev;
307
- value = ev;
308
- }}
309
- />
310
- </VForm>
302
+ stack.resolve(_state);
303
+ }}
304
+ v-slots={{
305
+ default: (_form) => {
306
+ form = _form;
307
+ return slot(_state, { form, stack });
308
+ },
309
+ }}
310
+ />
311
311
  );
312
312
  },
313
313
  });
314
314
 
315
315
  return this.dialog(resolved);
316
316
  }
317
+
318
+ prompt(rawOptions: RawVuiPromptOptions = {}) {
319
+ const options: VuiPromptOptions =
320
+ typeof rawOptions === 'string'
321
+ ? {
322
+ input: {
323
+ label: rawOptions,
324
+ },
325
+ }
326
+ : {
327
+ ...rawOptions,
328
+ };
329
+
330
+ options.input = {
331
+ ...options.input,
332
+ };
333
+
334
+ options.dense = true;
335
+
336
+ const { initialValue: value = '' } = options.input;
337
+ const { size } = options.input;
338
+
339
+ delete options.input.initialValue;
340
+
341
+ return this.formPrompt(
342
+ {
343
+ size,
344
+ ...options,
345
+ state: {
346
+ input: value,
347
+ },
348
+ },
349
+ (state) => <VTextField {...options.input} v-model={state.input} />,
350
+ ).then((result) => {
351
+ return result ? result.input : result;
352
+ });
353
+ }
317
354
  }