@fastkit/vui 0.7.42 → 0.7.46
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 +50 -18
- package/dist/vui.cjs.prod.js +50 -18
- package/dist/vui.d.ts +11 -3
- package/dist/vui.mjs +50 -18
- package/package.json +6 -6
- package/src/components/VForm/VForm.tsx +5 -8
- package/src/components/VTabs/VTabs.tsx +23 -1
- package/src/composables/form-selector.tsx +16 -5
package/dist/vui.cjs.js
CHANGED
|
@@ -355,6 +355,9 @@ function defineFormSelectorComponent(opts) {
|
|
|
355
355
|
},
|
|
356
356
|
|
|
357
357
|
render() {
|
|
358
|
+
const {
|
|
359
|
+
selectorControl
|
|
360
|
+
} = this;
|
|
358
361
|
return vue.createVNode(VFormControl, {
|
|
359
362
|
"nodeControl": this.nodeControl,
|
|
360
363
|
"focused": this.nodeControl.focused,
|
|
@@ -369,14 +372,20 @@ function defineFormSelectorComponent(opts) {
|
|
|
369
372
|
}, { ...this.$slots,
|
|
370
373
|
default: () => vue.createVNode("div", {
|
|
371
374
|
"class": "v-form-selector__body"
|
|
372
|
-
}, [this.propItems.map(attrs =>
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
375
|
+
}, [this.propItems.map(attrs => {
|
|
376
|
+
const selected = selectorControl.isSelected(attrs.value);
|
|
377
|
+
return itemRenderer({
|
|
378
|
+
selected,
|
|
379
|
+
control: selectorControl,
|
|
380
|
+
attrs: { ...attrs,
|
|
381
|
+
modelValue: selected,
|
|
382
|
+
key: attrs.value
|
|
383
|
+
},
|
|
384
|
+
slots: {
|
|
385
|
+
default: () => attrs.label(this.selectorControl)
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
}), vueKit.renderSlotOrEmpty(this.$slots, 'default')])
|
|
380
389
|
});
|
|
381
390
|
}
|
|
382
391
|
|
|
@@ -2753,8 +2762,8 @@ const VForm = vue.defineComponent({
|
|
|
2753
2762
|
name: 'VForm',
|
|
2754
2763
|
props: { ...props,
|
|
2755
2764
|
...createControlProps(),
|
|
2756
|
-
...vueKit.defineSlotsProps(),
|
|
2757
|
-
|
|
2765
|
+
...vueKit.defineSlotsProps() // disableAutoScroll: Boolean,
|
|
2766
|
+
|
|
2758
2767
|
},
|
|
2759
2768
|
emits,
|
|
2760
2769
|
|
|
@@ -2762,13 +2771,9 @@ const VForm = vue.defineComponent({
|
|
|
2762
2771
|
const vui = useVui();
|
|
2763
2772
|
const nodeControl = vueKit.useForm(props, ctx, {
|
|
2764
2773
|
nodeType: VUI_FORM_SYMBOL,
|
|
2765
|
-
|
|
2766
|
-
if (props.disableAutoScroll) return;
|
|
2774
|
+
scrollToElement: el => {
|
|
2767
2775
|
const scroller = vueKit.getDocumentScroller();
|
|
2768
|
-
|
|
2769
|
-
firstInvalidEl
|
|
2770
|
-
} = nodeControl;
|
|
2771
|
-
firstInvalidEl && scroller.toElement(firstInvalidEl, {
|
|
2776
|
+
return scroller.toElement(el, {
|
|
2772
2777
|
offset: vui.getAutoScrollToElementOffsetTop()
|
|
2773
2778
|
});
|
|
2774
2779
|
}
|
|
@@ -2906,7 +2911,8 @@ const VTabs = vue.defineComponent({
|
|
|
2906
2911
|
*/
|
|
2907
2912
|
withQuery: Boolean,
|
|
2908
2913
|
...vueUtils.defineSlotsProps(),
|
|
2909
|
-
color: String
|
|
2914
|
+
color: String,
|
|
2915
|
+
onBeforeChange: Function
|
|
2910
2916
|
},
|
|
2911
2917
|
emits: {
|
|
2912
2918
|
'update:modelValue': newValue => true,
|
|
@@ -3003,7 +3009,33 @@ const VTabs = vue.defineComponent({
|
|
|
3003
3009
|
}
|
|
3004
3010
|
}
|
|
3005
3011
|
|
|
3006
|
-
function to(value) {
|
|
3012
|
+
async function to(value) {
|
|
3013
|
+
const {
|
|
3014
|
+
value: currentValue
|
|
3015
|
+
} = currentRef;
|
|
3016
|
+
|
|
3017
|
+
if (currentValue === value) {
|
|
3018
|
+
return;
|
|
3019
|
+
}
|
|
3020
|
+
|
|
3021
|
+
const {
|
|
3022
|
+
onBeforeChange
|
|
3023
|
+
} = props;
|
|
3024
|
+
|
|
3025
|
+
if (onBeforeChange) {
|
|
3026
|
+
let result = onBeforeChange(value, currentRef.value);
|
|
3027
|
+
|
|
3028
|
+
if (helpers.isPromise(result)) {
|
|
3029
|
+
result = await result;
|
|
3030
|
+
}
|
|
3031
|
+
|
|
3032
|
+
console.log(result);
|
|
3033
|
+
|
|
3034
|
+
if (result === false) {
|
|
3035
|
+
return;
|
|
3036
|
+
}
|
|
3037
|
+
}
|
|
3038
|
+
|
|
3007
3039
|
currentRef.value = value;
|
|
3008
3040
|
}
|
|
3009
3041
|
|
package/dist/vui.cjs.prod.js
CHANGED
|
@@ -355,6 +355,9 @@ function defineFormSelectorComponent(opts) {
|
|
|
355
355
|
},
|
|
356
356
|
|
|
357
357
|
render() {
|
|
358
|
+
const {
|
|
359
|
+
selectorControl
|
|
360
|
+
} = this;
|
|
358
361
|
return vue.createVNode(VFormControl, {
|
|
359
362
|
"nodeControl": this.nodeControl,
|
|
360
363
|
"focused": this.nodeControl.focused,
|
|
@@ -369,14 +372,20 @@ function defineFormSelectorComponent(opts) {
|
|
|
369
372
|
}, { ...this.$slots,
|
|
370
373
|
default: () => vue.createVNode("div", {
|
|
371
374
|
"class": "v-form-selector__body"
|
|
372
|
-
}, [this.propItems.map(attrs =>
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
375
|
+
}, [this.propItems.map(attrs => {
|
|
376
|
+
const selected = selectorControl.isSelected(attrs.value);
|
|
377
|
+
return itemRenderer({
|
|
378
|
+
selected,
|
|
379
|
+
control: selectorControl,
|
|
380
|
+
attrs: { ...attrs,
|
|
381
|
+
modelValue: selected,
|
|
382
|
+
key: attrs.value
|
|
383
|
+
},
|
|
384
|
+
slots: {
|
|
385
|
+
default: () => attrs.label(this.selectorControl)
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
}), vueKit.renderSlotOrEmpty(this.$slots, 'default')])
|
|
380
389
|
});
|
|
381
390
|
}
|
|
382
391
|
|
|
@@ -2753,8 +2762,8 @@ const VForm = vue.defineComponent({
|
|
|
2753
2762
|
name: 'VForm',
|
|
2754
2763
|
props: { ...props,
|
|
2755
2764
|
...createControlProps(),
|
|
2756
|
-
...vueKit.defineSlotsProps(),
|
|
2757
|
-
|
|
2765
|
+
...vueKit.defineSlotsProps() // disableAutoScroll: Boolean,
|
|
2766
|
+
|
|
2758
2767
|
},
|
|
2759
2768
|
emits,
|
|
2760
2769
|
|
|
@@ -2762,13 +2771,9 @@ const VForm = vue.defineComponent({
|
|
|
2762
2771
|
const vui = useVui();
|
|
2763
2772
|
const nodeControl = vueKit.useForm(props, ctx, {
|
|
2764
2773
|
nodeType: VUI_FORM_SYMBOL,
|
|
2765
|
-
|
|
2766
|
-
if (props.disableAutoScroll) return;
|
|
2774
|
+
scrollToElement: el => {
|
|
2767
2775
|
const scroller = vueKit.getDocumentScroller();
|
|
2768
|
-
|
|
2769
|
-
firstInvalidEl
|
|
2770
|
-
} = nodeControl;
|
|
2771
|
-
firstInvalidEl && scroller.toElement(firstInvalidEl, {
|
|
2776
|
+
return scroller.toElement(el, {
|
|
2772
2777
|
offset: vui.getAutoScrollToElementOffsetTop()
|
|
2773
2778
|
});
|
|
2774
2779
|
}
|
|
@@ -2906,7 +2911,8 @@ const VTabs = vue.defineComponent({
|
|
|
2906
2911
|
*/
|
|
2907
2912
|
withQuery: Boolean,
|
|
2908
2913
|
...vueUtils.defineSlotsProps(),
|
|
2909
|
-
color: String
|
|
2914
|
+
color: String,
|
|
2915
|
+
onBeforeChange: Function
|
|
2910
2916
|
},
|
|
2911
2917
|
emits: {
|
|
2912
2918
|
'update:modelValue': newValue => true,
|
|
@@ -3003,7 +3009,33 @@ const VTabs = vue.defineComponent({
|
|
|
3003
3009
|
}
|
|
3004
3010
|
}
|
|
3005
3011
|
|
|
3006
|
-
function to(value) {
|
|
3012
|
+
async function to(value) {
|
|
3013
|
+
const {
|
|
3014
|
+
value: currentValue
|
|
3015
|
+
} = currentRef;
|
|
3016
|
+
|
|
3017
|
+
if (currentValue === value) {
|
|
3018
|
+
return;
|
|
3019
|
+
}
|
|
3020
|
+
|
|
3021
|
+
const {
|
|
3022
|
+
onBeforeChange
|
|
3023
|
+
} = props;
|
|
3024
|
+
|
|
3025
|
+
if (onBeforeChange) {
|
|
3026
|
+
let result = onBeforeChange(value, currentRef.value);
|
|
3027
|
+
|
|
3028
|
+
if (helpers.isPromise(result)) {
|
|
3029
|
+
result = await result;
|
|
3030
|
+
}
|
|
3031
|
+
|
|
3032
|
+
console.log(result);
|
|
3033
|
+
|
|
3034
|
+
if (result === false) {
|
|
3035
|
+
return;
|
|
3036
|
+
}
|
|
3037
|
+
}
|
|
3038
|
+
|
|
3007
3039
|
currentRef.value = value;
|
|
3008
3040
|
}
|
|
3009
3041
|
|
package/dist/vui.d.ts
CHANGED
|
@@ -1164,7 +1164,10 @@ export declare interface DefineFormSelectorComponentOptions {
|
|
|
1164
1164
|
nodeType: string;
|
|
1165
1165
|
className: string;
|
|
1166
1166
|
itemRenderer: (ctx: {
|
|
1167
|
+
control: FormSelectorControl;
|
|
1168
|
+
selected: boolean;
|
|
1167
1169
|
attrs: ResolvedFormSelectorItemData & {
|
|
1170
|
+
modelValue: boolean;
|
|
1168
1171
|
key: string | number;
|
|
1169
1172
|
};
|
|
1170
1173
|
slots: {
|
|
@@ -4000,7 +4003,6 @@ export declare const VDrawerLayout: DefineComponent<{
|
|
|
4000
4003
|
}>;
|
|
4001
4004
|
|
|
4002
4005
|
export declare const VForm: DefineComponent<{
|
|
4003
|
-
disableAutoScroll: BooleanConstructor;
|
|
4004
4006
|
'v-slots': PropType<ResolveRawSlots<VFormSlots>>;
|
|
4005
4007
|
size: {
|
|
4006
4008
|
type: PropType<"sm" | "md" | "lg">;
|
|
@@ -4012,6 +4014,7 @@ export declare const VForm: DefineComponent<{
|
|
|
4012
4014
|
default: boolean;
|
|
4013
4015
|
};
|
|
4014
4016
|
submiting: BooleanConstructor;
|
|
4017
|
+
disableAutoScroll: BooleanConstructor;
|
|
4015
4018
|
name: StringConstructor;
|
|
4016
4019
|
modelValue: Prop<unknown, unknown>;
|
|
4017
4020
|
tabindex: {
|
|
@@ -4047,6 +4050,7 @@ export declare const VForm: DefineComponent<{
|
|
|
4047
4050
|
form: VueForm_2;
|
|
4048
4051
|
formRef: () => Ref<HTMLFormElement | null>;
|
|
4049
4052
|
nativeAction: ComputedRef<string | undefined>;
|
|
4053
|
+
disableAutoScroll: ComputedRef<boolean>;
|
|
4050
4054
|
nodeControl: FormNodeControl<any, any>;
|
|
4051
4055
|
currentValue: WritableComputedRef<any>;
|
|
4052
4056
|
computedTabindex: ComputedRef<number>;
|
|
@@ -4087,7 +4091,6 @@ export declare const VForm: DefineComponent<{
|
|
|
4087
4091
|
focus: (ev: FocusEvent) => boolean;
|
|
4088
4092
|
blur: (ev: FocusEvent) => boolean;
|
|
4089
4093
|
}, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
|
|
4090
|
-
disableAutoScroll: BooleanConstructor;
|
|
4091
4094
|
'v-slots': PropType<ResolveRawSlots<VFormSlots>>;
|
|
4092
4095
|
size: {
|
|
4093
4096
|
type: PropType<"sm" | "md" | "lg">;
|
|
@@ -4099,6 +4102,7 @@ export declare const VForm: DefineComponent<{
|
|
|
4099
4102
|
default: boolean;
|
|
4100
4103
|
};
|
|
4101
4104
|
submiting: BooleanConstructor;
|
|
4105
|
+
disableAutoScroll: BooleanConstructor;
|
|
4102
4106
|
name: StringConstructor;
|
|
4103
4107
|
modelValue: Prop<unknown, unknown>;
|
|
4104
4108
|
tabindex: {
|
|
@@ -4143,8 +4147,8 @@ export declare const VForm: DefineComponent<{
|
|
|
4143
4147
|
validateTiming: ValidateTiming;
|
|
4144
4148
|
rules: RecursiveArray<Rule<any>>;
|
|
4145
4149
|
submiting: boolean;
|
|
4146
|
-
autoValidate: boolean;
|
|
4147
4150
|
disableAutoScroll: boolean;
|
|
4151
|
+
autoValidate: boolean;
|
|
4148
4152
|
}>;
|
|
4149
4153
|
|
|
4150
4154
|
export declare const VFormControl: DefineComponent<{
|
|
@@ -7121,6 +7125,7 @@ export declare const VSwitchGroup: DefineComponent<{
|
|
|
7121
7125
|
|
|
7122
7126
|
export declare const VTabs: DefineComponent<{
|
|
7123
7127
|
color: PropType<ScopeName>;
|
|
7128
|
+
onBeforeChange: PropType<VTabsGuard>;
|
|
7124
7129
|
'v-slots': PropType<ResolveRawSlots_2<{
|
|
7125
7130
|
item: VTabsItemLabelSlotCtx;
|
|
7126
7131
|
}>>;
|
|
@@ -7150,6 +7155,7 @@ export declare const VTabs: DefineComponent<{
|
|
|
7150
7155
|
change: (newValue: string) => true;
|
|
7151
7156
|
}, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
|
|
7152
7157
|
color: PropType<ScopeName>;
|
|
7158
|
+
onBeforeChange: PropType<VTabsGuard>;
|
|
7153
7159
|
'v-slots': PropType<ResolveRawSlots_2<{
|
|
7154
7160
|
item: VTabsItemLabelSlotCtx;
|
|
7155
7161
|
}>>;
|
|
@@ -7182,6 +7188,8 @@ export declare const VTabs: DefineComponent<{
|
|
|
7182
7188
|
withQuery: boolean;
|
|
7183
7189
|
}>;
|
|
7184
7190
|
|
|
7191
|
+
export declare type VTabsGuard = (nextValue: string, oldValue: string) => boolean | void | undefined | Promise<boolean | void | undefined>;
|
|
7192
|
+
|
|
7185
7193
|
export declare interface VTabsItem {
|
|
7186
7194
|
value: string;
|
|
7187
7195
|
icon?: RawIconProp;
|
package/dist/vui.mjs
CHANGED
|
@@ -350,6 +350,9 @@ function defineFormSelectorComponent(opts) {
|
|
|
350
350
|
},
|
|
351
351
|
|
|
352
352
|
render() {
|
|
353
|
+
const {
|
|
354
|
+
selectorControl
|
|
355
|
+
} = this;
|
|
353
356
|
return createVNode(VFormControl, {
|
|
354
357
|
"nodeControl": this.nodeControl,
|
|
355
358
|
"focused": this.nodeControl.focused,
|
|
@@ -364,14 +367,20 @@ function defineFormSelectorComponent(opts) {
|
|
|
364
367
|
}, { ...this.$slots,
|
|
365
368
|
default: () => createVNode("div", {
|
|
366
369
|
"class": "v-form-selector__body"
|
|
367
|
-
}, [this.propItems.map(attrs =>
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
370
|
+
}, [this.propItems.map(attrs => {
|
|
371
|
+
const selected = selectorControl.isSelected(attrs.value);
|
|
372
|
+
return itemRenderer({
|
|
373
|
+
selected,
|
|
374
|
+
control: selectorControl,
|
|
375
|
+
attrs: { ...attrs,
|
|
376
|
+
modelValue: selected,
|
|
377
|
+
key: attrs.value
|
|
378
|
+
},
|
|
379
|
+
slots: {
|
|
380
|
+
default: () => attrs.label(this.selectorControl)
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
}), renderSlotOrEmpty(this.$slots, 'default')])
|
|
375
384
|
});
|
|
376
385
|
}
|
|
377
386
|
|
|
@@ -2748,8 +2757,8 @@ const VForm = defineComponent({
|
|
|
2748
2757
|
name: 'VForm',
|
|
2749
2758
|
props: { ...props,
|
|
2750
2759
|
...createControlProps(),
|
|
2751
|
-
...defineSlotsProps(),
|
|
2752
|
-
|
|
2760
|
+
...defineSlotsProps() // disableAutoScroll: Boolean,
|
|
2761
|
+
|
|
2753
2762
|
},
|
|
2754
2763
|
emits,
|
|
2755
2764
|
|
|
@@ -2757,13 +2766,9 @@ const VForm = defineComponent({
|
|
|
2757
2766
|
const vui = useVui();
|
|
2758
2767
|
const nodeControl = useForm(props, ctx, {
|
|
2759
2768
|
nodeType: VUI_FORM_SYMBOL,
|
|
2760
|
-
|
|
2761
|
-
if (props.disableAutoScroll) return;
|
|
2769
|
+
scrollToElement: el => {
|
|
2762
2770
|
const scroller = getDocumentScroller();
|
|
2763
|
-
|
|
2764
|
-
firstInvalidEl
|
|
2765
|
-
} = nodeControl;
|
|
2766
|
-
firstInvalidEl && scroller.toElement(firstInvalidEl, {
|
|
2771
|
+
return scroller.toElement(el, {
|
|
2767
2772
|
offset: vui.getAutoScrollToElementOffsetTop()
|
|
2768
2773
|
});
|
|
2769
2774
|
}
|
|
@@ -2901,7 +2906,8 @@ const VTabs = defineComponent({
|
|
|
2901
2906
|
*/
|
|
2902
2907
|
withQuery: Boolean,
|
|
2903
2908
|
...defineSlotsProps$1(),
|
|
2904
|
-
color: String
|
|
2909
|
+
color: String,
|
|
2910
|
+
onBeforeChange: Function
|
|
2905
2911
|
},
|
|
2906
2912
|
emits: {
|
|
2907
2913
|
'update:modelValue': newValue => true,
|
|
@@ -2998,7 +3004,33 @@ const VTabs = defineComponent({
|
|
|
2998
3004
|
}
|
|
2999
3005
|
}
|
|
3000
3006
|
|
|
3001
|
-
function to(value) {
|
|
3007
|
+
async function to(value) {
|
|
3008
|
+
const {
|
|
3009
|
+
value: currentValue
|
|
3010
|
+
} = currentRef;
|
|
3011
|
+
|
|
3012
|
+
if (currentValue === value) {
|
|
3013
|
+
return;
|
|
3014
|
+
}
|
|
3015
|
+
|
|
3016
|
+
const {
|
|
3017
|
+
onBeforeChange
|
|
3018
|
+
} = props;
|
|
3019
|
+
|
|
3020
|
+
if (onBeforeChange) {
|
|
3021
|
+
let result = onBeforeChange(value, currentRef.value);
|
|
3022
|
+
|
|
3023
|
+
if (isPromise(result)) {
|
|
3024
|
+
result = await result;
|
|
3025
|
+
}
|
|
3026
|
+
|
|
3027
|
+
console.log(result);
|
|
3028
|
+
|
|
3029
|
+
if (result === false) {
|
|
3030
|
+
return;
|
|
3031
|
+
}
|
|
3032
|
+
}
|
|
3033
|
+
|
|
3002
3034
|
currentRef.value = value;
|
|
3003
3035
|
}
|
|
3004
3036
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastkit/vui",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.46",
|
|
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.46",
|
|
36
|
+
"@fastkit/icon-font": "0.7.46",
|
|
37
|
+
"@fastkit/tiny-logger": "0.7.46",
|
|
38
|
+
"@fastkit/vite-kit": "0.7.46",
|
|
39
|
+
"@fastkit/vue-kit": "0.7.46",
|
|
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
|
-
|
|
35
|
-
if (props.disableAutoScroll) return;
|
|
34
|
+
scrollToElement: (el) => {
|
|
36
35
|
const scroller = getDocumentScroller();
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
createFormSelectorSettings,
|
|
8
8
|
FormControlSlots,
|
|
9
9
|
useFormSelectorControl,
|
|
10
|
+
FormSelectorControl,
|
|
10
11
|
ResolvedFormSelectorItemData,
|
|
11
12
|
FormNodeControl,
|
|
12
13
|
renderSlotOrEmpty,
|
|
@@ -20,7 +21,12 @@ export interface DefineFormSelectorComponentOptions {
|
|
|
20
21
|
nodeType: string;
|
|
21
22
|
className: string;
|
|
22
23
|
itemRenderer: (ctx: {
|
|
23
|
-
|
|
24
|
+
control: FormSelectorControl;
|
|
25
|
+
selected: boolean;
|
|
26
|
+
attrs: ResolvedFormSelectorItemData & {
|
|
27
|
+
modelValue: boolean;
|
|
28
|
+
key: string | number;
|
|
29
|
+
};
|
|
24
30
|
slots: {
|
|
25
31
|
default: TypedSlot<FormNodeControl>;
|
|
26
32
|
};
|
|
@@ -60,6 +66,7 @@ export function defineFormSelectorComponent(
|
|
|
60
66
|
};
|
|
61
67
|
},
|
|
62
68
|
render() {
|
|
69
|
+
const { selectorControl } = this;
|
|
63
70
|
return (
|
|
64
71
|
<VFormControl
|
|
65
72
|
nodeControl={this.nodeControl}
|
|
@@ -81,17 +88,21 @@ export function defineFormSelectorComponent(
|
|
|
81
88
|
...this.$slots,
|
|
82
89
|
default: () => (
|
|
83
90
|
<div class="v-form-selector__body">
|
|
84
|
-
{this.propItems.map((attrs) =>
|
|
85
|
-
|
|
91
|
+
{this.propItems.map((attrs) => {
|
|
92
|
+
const selected = selectorControl.isSelected(attrs.value);
|
|
93
|
+
return itemRenderer({
|
|
94
|
+
selected,
|
|
95
|
+
control: selectorControl,
|
|
86
96
|
attrs: {
|
|
87
97
|
...attrs,
|
|
98
|
+
modelValue: selected,
|
|
88
99
|
key: attrs.value,
|
|
89
100
|
},
|
|
90
101
|
slots: {
|
|
91
102
|
default: () => attrs.label(this.selectorControl),
|
|
92
103
|
},
|
|
93
|
-
})
|
|
94
|
-
)}
|
|
104
|
+
});
|
|
105
|
+
})}
|
|
95
106
|
{renderSlotOrEmpty(this.$slots, 'default')}
|
|
96
107
|
</div>
|
|
97
108
|
),
|