@fastkit/vui 0.7.41 → 0.7.44

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
@@ -2753,8 +2753,8 @@ const VForm = vue.defineComponent({
2753
2753
  name: 'VForm',
2754
2754
  props: { ...props,
2755
2755
  ...createControlProps(),
2756
- ...vueKit.defineSlotsProps(),
2757
- disableAutoScroll: Boolean
2756
+ ...vueKit.defineSlotsProps() // disableAutoScroll: Boolean,
2757
+
2758
2758
  },
2759
2759
  emits,
2760
2760
 
@@ -2762,13 +2762,9 @@ const VForm = vue.defineComponent({
2762
2762
  const vui = useVui();
2763
2763
  const nodeControl = vueKit.useForm(props, ctx, {
2764
2764
  nodeType: VUI_FORM_SYMBOL,
2765
- onAutoValidateError: () => {
2766
- if (props.disableAutoScroll) return;
2765
+ scrollToElement: el => {
2767
2766
  const scroller = vueKit.getDocumentScroller();
2768
- const {
2769
- firstInvalidEl
2770
- } = nodeControl;
2771
- firstInvalidEl && scroller.toElement(firstInvalidEl, {
2767
+ return scroller.toElement(el, {
2772
2768
  offset: vui.getAutoScrollToElementOffsetTop()
2773
2769
  });
2774
2770
  }
@@ -2906,7 +2902,8 @@ const VTabs = vue.defineComponent({
2906
2902
  */
2907
2903
  withQuery: Boolean,
2908
2904
  ...vueUtils.defineSlotsProps(),
2909
- color: String
2905
+ color: String,
2906
+ onBeforeChange: Function
2910
2907
  },
2911
2908
  emits: {
2912
2909
  'update:modelValue': newValue => true,
@@ -3003,7 +3000,33 @@ const VTabs = vue.defineComponent({
3003
3000
  }
3004
3001
  }
3005
3002
 
3006
- function to(value) {
3003
+ async function to(value) {
3004
+ const {
3005
+ value: currentValue
3006
+ } = currentRef;
3007
+
3008
+ if (currentValue === value) {
3009
+ return;
3010
+ }
3011
+
3012
+ const {
3013
+ onBeforeChange
3014
+ } = props;
3015
+
3016
+ if (onBeforeChange) {
3017
+ let result = onBeforeChange(value, currentRef.value);
3018
+
3019
+ if (helpers.isPromise(result)) {
3020
+ result = await result;
3021
+ }
3022
+
3023
+ console.log(result);
3024
+
3025
+ if (result === false) {
3026
+ return;
3027
+ }
3028
+ }
3029
+
3007
3030
  currentRef.value = value;
3008
3031
  }
3009
3032
 
@@ -2753,8 +2753,8 @@ const VForm = vue.defineComponent({
2753
2753
  name: 'VForm',
2754
2754
  props: { ...props,
2755
2755
  ...createControlProps(),
2756
- ...vueKit.defineSlotsProps(),
2757
- disableAutoScroll: Boolean
2756
+ ...vueKit.defineSlotsProps() // disableAutoScroll: Boolean,
2757
+
2758
2758
  },
2759
2759
  emits,
2760
2760
 
@@ -2762,13 +2762,9 @@ const VForm = vue.defineComponent({
2762
2762
  const vui = useVui();
2763
2763
  const nodeControl = vueKit.useForm(props, ctx, {
2764
2764
  nodeType: VUI_FORM_SYMBOL,
2765
- onAutoValidateError: () => {
2766
- if (props.disableAutoScroll) return;
2765
+ scrollToElement: el => {
2767
2766
  const scroller = vueKit.getDocumentScroller();
2768
- const {
2769
- firstInvalidEl
2770
- } = nodeControl;
2771
- firstInvalidEl && scroller.toElement(firstInvalidEl, {
2767
+ return scroller.toElement(el, {
2772
2768
  offset: vui.getAutoScrollToElementOffsetTop()
2773
2769
  });
2774
2770
  }
@@ -2906,7 +2902,8 @@ const VTabs = vue.defineComponent({
2906
2902
  */
2907
2903
  withQuery: Boolean,
2908
2904
  ...vueUtils.defineSlotsProps(),
2909
- color: String
2905
+ color: String,
2906
+ onBeforeChange: Function
2910
2907
  },
2911
2908
  emits: {
2912
2909
  'update:modelValue': newValue => true,
@@ -3003,7 +3000,33 @@ const VTabs = vue.defineComponent({
3003
3000
  }
3004
3001
  }
3005
3002
 
3006
- function to(value) {
3003
+ async function to(value) {
3004
+ const {
3005
+ value: currentValue
3006
+ } = currentRef;
3007
+
3008
+ if (currentValue === value) {
3009
+ return;
3010
+ }
3011
+
3012
+ const {
3013
+ onBeforeChange
3014
+ } = props;
3015
+
3016
+ if (onBeforeChange) {
3017
+ let result = onBeforeChange(value, currentRef.value);
3018
+
3019
+ if (helpers.isPromise(result)) {
3020
+ result = await result;
3021
+ }
3022
+
3023
+ console.log(result);
3024
+
3025
+ if (result === false) {
3026
+ return;
3027
+ }
3028
+ }
3029
+
3007
3030
  currentRef.value = value;
3008
3031
  }
3009
3032
 
package/dist/vui.d.ts CHANGED
@@ -4000,7 +4000,6 @@ export declare const VDrawerLayout: DefineComponent<{
4000
4000
  }>;
4001
4001
 
4002
4002
  export declare const VForm: DefineComponent<{
4003
- disableAutoScroll: BooleanConstructor;
4004
4003
  'v-slots': PropType<ResolveRawSlots<VFormSlots>>;
4005
4004
  size: {
4006
4005
  type: PropType<"sm" | "md" | "lg">;
@@ -4012,6 +4011,7 @@ export declare const VForm: DefineComponent<{
4012
4011
  default: boolean;
4013
4012
  };
4014
4013
  submiting: BooleanConstructor;
4014
+ disableAutoScroll: BooleanConstructor;
4015
4015
  name: StringConstructor;
4016
4016
  modelValue: Prop<unknown, unknown>;
4017
4017
  tabindex: {
@@ -4047,6 +4047,7 @@ export declare const VForm: DefineComponent<{
4047
4047
  form: VueForm_2;
4048
4048
  formRef: () => Ref<HTMLFormElement | null>;
4049
4049
  nativeAction: ComputedRef<string | undefined>;
4050
+ disableAutoScroll: ComputedRef<boolean>;
4050
4051
  nodeControl: FormNodeControl<any, any>;
4051
4052
  currentValue: WritableComputedRef<any>;
4052
4053
  computedTabindex: ComputedRef<number>;
@@ -4087,7 +4088,6 @@ export declare const VForm: DefineComponent<{
4087
4088
  focus: (ev: FocusEvent) => boolean;
4088
4089
  blur: (ev: FocusEvent) => boolean;
4089
4090
  }, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
4090
- disableAutoScroll: BooleanConstructor;
4091
4091
  'v-slots': PropType<ResolveRawSlots<VFormSlots>>;
4092
4092
  size: {
4093
4093
  type: PropType<"sm" | "md" | "lg">;
@@ -4099,6 +4099,7 @@ export declare const VForm: DefineComponent<{
4099
4099
  default: boolean;
4100
4100
  };
4101
4101
  submiting: BooleanConstructor;
4102
+ disableAutoScroll: BooleanConstructor;
4102
4103
  name: StringConstructor;
4103
4104
  modelValue: Prop<unknown, unknown>;
4104
4105
  tabindex: {
@@ -4143,8 +4144,8 @@ export declare const VForm: DefineComponent<{
4143
4144
  validateTiming: ValidateTiming;
4144
4145
  rules: RecursiveArray<Rule<any>>;
4145
4146
  submiting: boolean;
4146
- autoValidate: boolean;
4147
4147
  disableAutoScroll: boolean;
4148
+ autoValidate: boolean;
4148
4149
  }>;
4149
4150
 
4150
4151
  export declare const VFormControl: DefineComponent<{
@@ -7121,6 +7122,7 @@ export declare const VSwitchGroup: DefineComponent<{
7121
7122
 
7122
7123
  export declare const VTabs: DefineComponent<{
7123
7124
  color: PropType<ScopeName>;
7125
+ onBeforeChange: PropType<VTabsGuard>;
7124
7126
  'v-slots': PropType<ResolveRawSlots_2<{
7125
7127
  item: VTabsItemLabelSlotCtx;
7126
7128
  }>>;
@@ -7150,6 +7152,7 @@ export declare const VTabs: DefineComponent<{
7150
7152
  change: (newValue: string) => true;
7151
7153
  }, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
7152
7154
  color: PropType<ScopeName>;
7155
+ onBeforeChange: PropType<VTabsGuard>;
7153
7156
  'v-slots': PropType<ResolveRawSlots_2<{
7154
7157
  item: VTabsItemLabelSlotCtx;
7155
7158
  }>>;
@@ -7182,6 +7185,8 @@ export declare const VTabs: DefineComponent<{
7182
7185
  withQuery: boolean;
7183
7186
  }>;
7184
7187
 
7188
+ export declare type VTabsGuard = (nextValue: string, oldValue: string) => boolean | void | undefined | Promise<boolean | void | undefined>;
7189
+
7185
7190
  export declare interface VTabsItem {
7186
7191
  value: string;
7187
7192
  icon?: RawIconProp;
package/dist/vui.mjs CHANGED
@@ -2748,8 +2748,8 @@ const VForm = defineComponent({
2748
2748
  name: 'VForm',
2749
2749
  props: { ...props,
2750
2750
  ...createControlProps(),
2751
- ...defineSlotsProps(),
2752
- disableAutoScroll: Boolean
2751
+ ...defineSlotsProps() // disableAutoScroll: Boolean,
2752
+
2753
2753
  },
2754
2754
  emits,
2755
2755
 
@@ -2757,13 +2757,9 @@ const VForm = defineComponent({
2757
2757
  const vui = useVui();
2758
2758
  const nodeControl = useForm(props, ctx, {
2759
2759
  nodeType: VUI_FORM_SYMBOL,
2760
- onAutoValidateError: () => {
2761
- if (props.disableAutoScroll) return;
2760
+ scrollToElement: el => {
2762
2761
  const scroller = getDocumentScroller();
2763
- const {
2764
- firstInvalidEl
2765
- } = nodeControl;
2766
- firstInvalidEl && scroller.toElement(firstInvalidEl, {
2762
+ return scroller.toElement(el, {
2767
2763
  offset: vui.getAutoScrollToElementOffsetTop()
2768
2764
  });
2769
2765
  }
@@ -2901,7 +2897,8 @@ const VTabs = defineComponent({
2901
2897
  */
2902
2898
  withQuery: Boolean,
2903
2899
  ...defineSlotsProps$1(),
2904
- color: String
2900
+ color: String,
2901
+ onBeforeChange: Function
2905
2902
  },
2906
2903
  emits: {
2907
2904
  'update:modelValue': newValue => true,
@@ -2998,7 +2995,33 @@ const VTabs = defineComponent({
2998
2995
  }
2999
2996
  }
3000
2997
 
3001
- function to(value) {
2998
+ async function to(value) {
2999
+ const {
3000
+ value: currentValue
3001
+ } = currentRef;
3002
+
3003
+ if (currentValue === value) {
3004
+ return;
3005
+ }
3006
+
3007
+ const {
3008
+ onBeforeChange
3009
+ } = props;
3010
+
3011
+ if (onBeforeChange) {
3012
+ let result = onBeforeChange(value, currentRef.value);
3013
+
3014
+ if (isPromise(result)) {
3015
+ result = await result;
3016
+ }
3017
+
3018
+ console.log(result);
3019
+
3020
+ if (result === false) {
3021
+ return;
3022
+ }
3023
+ }
3024
+
3002
3025
  currentRef.value = value;
3003
3026
  }
3004
3027
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastkit/vui",
3
- "version": "0.7.41",
3
+ "version": "0.7.44",
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.41",
36
- "@fastkit/icon-font": "0.7.41",
37
- "@fastkit/tiny-logger": "0.7.41",
38
- "@fastkit/vite-kit": "0.7.41",
39
- "@fastkit/vue-kit": "0.7.41",
35
+ "@fastkit/color-scheme": "0.7.44",
36
+ "@fastkit/icon-font": "0.7.44",
37
+ "@fastkit/tiny-logger": "0.7.44",
38
+ "@fastkit/vite-kit": "0.7.44",
39
+ "@fastkit/vue-kit": "0.7.44",
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",
@@ -24,21 +24,18 @@ export const VForm = defineComponent({
24
24
  ...props,
25
25
  ...createControlProps(),
26
26
  ...defineSlotsProps<VFormSlots>(),
27
- disableAutoScroll: Boolean,
27
+ // disableAutoScroll: Boolean,
28
28
  },
29
29
  emits,
30
30
  setup(props, ctx) {
31
31
  const vui = useVui();
32
32
  const nodeControl = useForm(props, ctx as any, {
33
33
  nodeType: VUI_FORM_SYMBOL,
34
- onAutoValidateError: () => {
35
- if (props.disableAutoScroll) return;
34
+ scrollToElement: (el) => {
36
35
  const scroller = getDocumentScroller();
37
- const { firstInvalidEl } = nodeControl;
38
- firstInvalidEl &&
39
- scroller.toElement(firstInvalidEl, {
40
- offset: vui.getAutoScrollToElementOffsetTop(),
41
- });
36
+ return scroller.toElement(el, {
37
+ offset: vui.getAutoScrollToElementOffsetTop(),
38
+ });
42
39
  },
43
40
  });
44
41
  const classes = computed(() => {
@@ -19,6 +19,7 @@ import { VTab, VTabRef } from './VTab';
19
19
  import { VScroller, useVScrollerRef } from '@fastkit/vue-kit';
20
20
  import { ScrollResult } from '@fastkit/scroller';
21
21
  import { useScopeColorClass, ScopeName } from '@fastkit/vue-color-scheme';
22
+ import { isPromise } from '@fastkit/helpers';
22
23
 
23
24
  export interface VTabsItemLabelSlotCtx {
24
25
  value: string;
@@ -30,6 +31,11 @@ export type VTabsItemLabelSlot = (ctx: VTabsItemLabelSlotCtx) => VNodeChild;
30
31
 
31
32
  export type VTabsRouterHandler = (value: string) => RouteLocationRaw;
32
33
 
34
+ export type VTabsGuard = (
35
+ nextValue: string,
36
+ oldValue: string,
37
+ ) => boolean | void | undefined | Promise<boolean | void | undefined>;
38
+
33
39
  export interface VTabsItem {
34
40
  value: string;
35
41
  icon?: RawIconProp;
@@ -72,6 +78,7 @@ export const VTabs = defineComponent({
72
78
  }>(),
73
79
 
74
80
  color: String as PropType<ScopeName>,
81
+ onBeforeChange: Function as PropType<VTabsGuard>,
75
82
  },
76
83
  emits: {
77
84
  'update:modelValue': (newValue: string) => true,
@@ -167,7 +174,22 @@ export const VTabs = defineComponent({
167
174
  }
168
175
  }
169
176
 
170
- function to(value: string) {
177
+ async function to(value: string) {
178
+ const { value: currentValue } = currentRef;
179
+ if (currentValue === value) {
180
+ return;
181
+ }
182
+ const { onBeforeChange } = props;
183
+ if (onBeforeChange) {
184
+ let result = onBeforeChange(value, currentRef.value);
185
+ if (isPromise(result)) {
186
+ result = await result;
187
+ }
188
+ console.log(result);
189
+ if (result === false) {
190
+ return;
191
+ }
192
+ }
171
193
  currentRef.value = value;
172
194
  }
173
195