@fbkworks/adapter-vant 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +33 -2
- package/dist/dark.css +4 -0
- package/dist/feedback.d.ts +2 -0
- package/dist/feedback.mjs +37 -0
- package/dist/feedback.mjs.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.mjs +79 -0
- package/dist/index.mjs.map +1 -0
- package/dist/primitives/Button.d.ts +53 -0
- package/dist/primitives/Button.mjs +58 -0
- package/dist/primitives/Button.mjs.map +1 -0
- package/dist/primitives/Checkbox.d.ts +33 -0
- package/dist/primitives/Checkbox.mjs +39 -0
- package/dist/primitives/Checkbox.mjs.map +1 -0
- package/dist/primitives/DataGrid.d.ts +100 -0
- package/dist/primitives/DataGrid.mjs +129 -0
- package/dist/primitives/DataGrid.mjs.map +1 -0
- package/dist/primitives/DatePicker.d.ts +66 -0
- package/dist/primitives/DatePicker.mjs +114 -0
- package/dist/primitives/DatePicker.mjs.map +1 -0
- package/dist/primitives/Dialog.d.ts +51 -0
- package/dist/primitives/Dialog.mjs +59 -0
- package/dist/primitives/Dialog.mjs.map +1 -0
- package/dist/primitives/Drawer.d.ts +57 -0
- package/dist/primitives/Drawer.mjs +72 -0
- package/dist/primitives/Drawer.mjs.map +1 -0
- package/dist/primitives/Empty.d.ts +13 -0
- package/dist/primitives/Empty.mjs +26 -0
- package/dist/primitives/Empty.mjs.map +1 -0
- package/dist/primitives/Form.d.ts +86 -0
- package/dist/primitives/Form.mjs +119 -0
- package/dist/primitives/Form.mjs.map +1 -0
- package/dist/primitives/Input.d.ts +50 -0
- package/dist/primitives/Input.mjs +49 -0
- package/dist/primitives/Input.mjs.map +1 -0
- package/dist/primitives/Pagination.d.ts +65 -0
- package/dist/primitives/Pagination.mjs +57 -0
- package/dist/primitives/Pagination.mjs.map +1 -0
- package/dist/primitives/Radio.d.ts +40 -0
- package/dist/primitives/Radio.mjs +54 -0
- package/dist/primitives/Radio.mjs.map +1 -0
- package/dist/primitives/Select.d.ts +58 -0
- package/dist/primitives/Select.mjs +118 -0
- package/dist/primitives/Select.mjs.map +1 -0
- package/dist/primitives/Spin.d.ts +15 -0
- package/dist/primitives/Spin.mjs +29 -0
- package/dist/primitives/Spin.mjs.map +1 -0
- package/dist/primitives/Tag.d.ts +25 -0
- package/dist/primitives/Tag.mjs +44 -0
- package/dist/primitives/Tag.mjs.map +1 -0
- package/dist/root-provider.d.ts +47 -0
- package/dist/root-provider.mjs +53 -0
- package/dist/root-provider.mjs.map +1 -0
- package/dist/style.css +246 -0
- package/dist/theme.d.ts +7 -0
- package/dist/theme.mjs +54 -0
- package/dist/theme.mjs.map +1 -0
- package/package.json +57 -3
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { defineComponent, ref, createVNode } from "vue";
|
|
2
|
+
import { Form as Form$1, Field } from "vant";
|
|
3
|
+
function toVantLabelWidth(width) {
|
|
4
|
+
return width === "auto" ? void 0 : width;
|
|
5
|
+
}
|
|
6
|
+
function toVantRules(rules) {
|
|
7
|
+
if (!rules?.length) return void 0;
|
|
8
|
+
return rules.map((rule) => ({
|
|
9
|
+
required: rule.required,
|
|
10
|
+
pattern: rule.pattern,
|
|
11
|
+
message: rule.message,
|
|
12
|
+
trigger: rule.trigger === "submit" || rule.trigger === void 0 ? void 0 : rule.trigger === "change" ? "onChange" : "onBlur",
|
|
13
|
+
validator: rule.validator && ((value) => {
|
|
14
|
+
const result = rule.validator(value, {});
|
|
15
|
+
if (result instanceof Promise) return result.then((message) => message === true || !message);
|
|
16
|
+
return result === true || result === void 0;
|
|
17
|
+
})
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
const Form = /* @__PURE__ */ defineComponent({
|
|
21
|
+
name: "FbkVantForm",
|
|
22
|
+
props: {
|
|
23
|
+
model: {
|
|
24
|
+
type: Object,
|
|
25
|
+
required: true
|
|
26
|
+
},
|
|
27
|
+
rules: {
|
|
28
|
+
type: Object,
|
|
29
|
+
default: void 0
|
|
30
|
+
},
|
|
31
|
+
labelWidth: {
|
|
32
|
+
type: [String, Number],
|
|
33
|
+
default: void 0
|
|
34
|
+
},
|
|
35
|
+
labelPosition: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: "right"
|
|
38
|
+
},
|
|
39
|
+
disabled: Boolean,
|
|
40
|
+
size: String,
|
|
41
|
+
scrollToError: Boolean
|
|
42
|
+
},
|
|
43
|
+
setup(props, {
|
|
44
|
+
expose,
|
|
45
|
+
slots
|
|
46
|
+
}) {
|
|
47
|
+
const formRef = ref();
|
|
48
|
+
let pending = null;
|
|
49
|
+
const validate = () => new Promise((resolve, reject) => {
|
|
50
|
+
pending = {
|
|
51
|
+
resolve,
|
|
52
|
+
reject
|
|
53
|
+
};
|
|
54
|
+
formRef.value?.submit();
|
|
55
|
+
});
|
|
56
|
+
expose({
|
|
57
|
+
validate,
|
|
58
|
+
validateField: async () => true,
|
|
59
|
+
resetFields: () => formRef.value?.resetValidation(),
|
|
60
|
+
clearValidate: () => formRef.value?.resetValidation()
|
|
61
|
+
});
|
|
62
|
+
return () => createVNode(Form$1, {
|
|
63
|
+
"ref": formRef,
|
|
64
|
+
"labelWidth": toVantLabelWidth(props.labelWidth),
|
|
65
|
+
"labelAlign": props.labelPosition === "top" ? "top" : props.labelPosition === "left" ? "left" : "right",
|
|
66
|
+
"disabled": props.disabled,
|
|
67
|
+
"onSubmit": () => {
|
|
68
|
+
pending?.resolve(true);
|
|
69
|
+
pending = null;
|
|
70
|
+
},
|
|
71
|
+
"onFailed": (errors) => {
|
|
72
|
+
pending?.reject(errors);
|
|
73
|
+
pending = null;
|
|
74
|
+
}
|
|
75
|
+
}, {
|
|
76
|
+
default: () => [slots.default?.()]
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
const FormItem = /* @__PURE__ */ defineComponent({
|
|
81
|
+
name: "FbkVantFormItem",
|
|
82
|
+
props: {
|
|
83
|
+
label: String,
|
|
84
|
+
prop: String,
|
|
85
|
+
required: Boolean,
|
|
86
|
+
rules: {
|
|
87
|
+
type: Array,
|
|
88
|
+
default: void 0
|
|
89
|
+
},
|
|
90
|
+
help: String,
|
|
91
|
+
labelWidth: {
|
|
92
|
+
type: [String, Number],
|
|
93
|
+
default: void 0
|
|
94
|
+
},
|
|
95
|
+
span: Number
|
|
96
|
+
},
|
|
97
|
+
setup(props, {
|
|
98
|
+
slots
|
|
99
|
+
}) {
|
|
100
|
+
return () => createVNode(Field, {
|
|
101
|
+
"name": props.prop,
|
|
102
|
+
"label": props.label,
|
|
103
|
+
"required": props.required,
|
|
104
|
+
"rules": toVantRules(props.rules),
|
|
105
|
+
"labelWidth": toVantLabelWidth(props.labelWidth)
|
|
106
|
+
}, {
|
|
107
|
+
default: () => [props.help ? createVNode("div", {
|
|
108
|
+
"class": "fbk-form-item__help"
|
|
109
|
+
}, [props.help]) : null],
|
|
110
|
+
input: slots.default,
|
|
111
|
+
default: slots.default
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
export {
|
|
116
|
+
Form,
|
|
117
|
+
FormItem
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=Form.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Form.mjs","sources":["../../src/primitives/Form.tsx"],"sourcesContent":["import { defineComponent, ref, type PropType } from 'vue'\nimport { Form as VanForm, Field } from 'vant'\nimport type { FieldRule } from 'vant'\nimport type { FbkRule, FormProps } from '@fbkworks/adapter-core'\n\n/**\n * vant 没有「按最宽标签统一」的能力。\n *\n * `labelWidth=\"auto\"` 会被 vant 的 addUnit 原样写成 `width: auto`,\n * 而 .van-field__label 是 flex:none,`auto` 会让它重新按内容收缩 ——\n * 恰好是我们要避免的效果。所以这里把 `auto` 翻译成「不传」:\n * vant 的默认值 --van-field-label-width 是 6.2em,本来就对所有行一致。\n *\n * 换句话说:契约里的 `auto` 语义是「各行标签等宽」,\n * element-plus / naive-ui 用「量最宽的那个」实现,\n * vant 用「固定 em」实现。三者对调用方是同一个承诺。\n */\nfunction toVantLabelWidth(width: string | number | undefined) {\n return width === 'auto' ? undefined : width\n}\n\nfunction toVantRules(rules: FbkRule[] | undefined) {\n if (!rules?.length) return undefined\n return rules.map((rule) => ({\n required: rule.required,\n pattern: rule.pattern,\n message: rule.message,\n trigger:\n rule.trigger === 'submit' || rule.trigger === undefined\n ? undefined\n : rule.trigger === 'change'\n ? 'onChange'\n : 'onBlur',\n validator:\n rule.validator &&\n ((value: unknown) => {\n const result = rule.validator!(value, {})\n if (result instanceof Promise) return result.then((message) => message === true || !message)\n return result === true || result === undefined\n }),\n }))\n}\n\n/**\n * van-form 没有命令式 validate() Promise。\n * 用 @submit / @failed 事件桥接,契约只承诺 validate(): Promise<true>。\n */\nexport const Form = defineComponent({\n name: 'FbkVantForm',\n props: {\n model: { type: Object as PropType<Record<string, any>>, required: true },\n rules: { type: Object as PropType<FormProps['rules']>, default: undefined },\n labelWidth: { type: [String, Number] as PropType<string | number>, default: undefined },\n labelPosition: { type: String as PropType<FormProps['labelPosition']>, default: 'right' },\n disabled: Boolean,\n size: String,\n scrollToError: Boolean,\n },\n setup(props, { expose, slots }) {\n // van-form 没有官方 TS 类型暴露 submit/resetValidation,但它们确实存在\n const formRef = ref<any>()\n let pending: { resolve: (value: true) => void; reject: (reason: unknown) => void } | null = null\n\n const validate = () =>\n new Promise<true>((resolve, reject) => {\n pending = { resolve, reject }\n formRef.value?.submit()\n })\n\n expose({\n validate,\n validateField: async () => true as const,\n resetFields: () => formRef.value?.resetValidation(),\n clearValidate: () => formRef.value?.resetValidation(),\n })\n\n return () => (\n <VanForm\n ref={formRef}\n labelWidth={toVantLabelWidth(props.labelWidth)}\n labelAlign={props.labelPosition === 'top' ? 'top' : props.labelPosition === 'left' ? 'left' : 'right'}\n disabled={props.disabled}\n onSubmit={() => {\n pending?.resolve(true)\n pending = null\n }}\n onFailed={(errors: unknown) => {\n pending?.reject(errors)\n pending = null\n }}\n >\n {slots.default?.()}\n </VanForm>\n )\n },\n})\n\nexport const FormItem = defineComponent({\n name: 'FbkVantFormItem',\n props: {\n label: String,\n prop: String,\n required: Boolean,\n rules: { type: Array as PropType<FbkRule[]>, default: undefined },\n help: String,\n labelWidth: { type: [String, Number] as PropType<string | number>, default: undefined },\n span: Number,\n },\n setup(props, { slots }) {\n return () => (\n <Field\n name={props.prop}\n label={props.label}\n required={props.required}\n rules={toVantRules(props.rules) as FieldRule[] | undefined}\n labelWidth={toVantLabelWidth(props.labelWidth)}\n v-slots={{ input: slots.default, default: slots.default }}\n >\n {props.help ? <div class=\"fbk-form-item__help\">{props.help}</div> : null}\n </Field>\n )\n },\n})\n"],"names":["toVantLabelWidth","width","undefined","toVantRules","rules","length","map","rule","required","pattern","message","trigger","validator","value","result","Promise","then","Form","defineComponent","name","props","model","type","Object","default","labelWidth","String","Number","labelPosition","disabled","Boolean","size","scrollToError","setup","expose","slots","formRef","ref","pending","validate","resolve","reject","submit","validateField","resetFields","resetValidation","clearValidate","_createVNode","VanForm","onSubmit","errors","FormItem","label","prop","Array","help","span","Field","input"],"mappings":"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"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { PropType } from 'vue';
|
|
2
|
+
import { InputProps } from '@fbkworks/adapter-core';
|
|
3
|
+
export declare const Input: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
4
|
+
modelValue: {
|
|
5
|
+
type: PropType<string | number>;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
type: {
|
|
9
|
+
type: PropType<InputProps["type"]>;
|
|
10
|
+
default: string;
|
|
11
|
+
};
|
|
12
|
+
placeholder: StringConstructor;
|
|
13
|
+
disabled: BooleanConstructor;
|
|
14
|
+
readonly: BooleanConstructor;
|
|
15
|
+
clearable: {
|
|
16
|
+
type: BooleanConstructor;
|
|
17
|
+
default: boolean;
|
|
18
|
+
};
|
|
19
|
+
rows: NumberConstructor;
|
|
20
|
+
size: StringConstructor;
|
|
21
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("change" | "blur" | "focus" | "update:modelValue")[], "change" | "blur" | "focus" | "update:modelValue", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
22
|
+
modelValue: {
|
|
23
|
+
type: PropType<string | number>;
|
|
24
|
+
default: string;
|
|
25
|
+
};
|
|
26
|
+
type: {
|
|
27
|
+
type: PropType<InputProps["type"]>;
|
|
28
|
+
default: string;
|
|
29
|
+
};
|
|
30
|
+
placeholder: StringConstructor;
|
|
31
|
+
disabled: BooleanConstructor;
|
|
32
|
+
readonly: BooleanConstructor;
|
|
33
|
+
clearable: {
|
|
34
|
+
type: BooleanConstructor;
|
|
35
|
+
default: boolean;
|
|
36
|
+
};
|
|
37
|
+
rows: NumberConstructor;
|
|
38
|
+
size: StringConstructor;
|
|
39
|
+
}>> & Readonly<{
|
|
40
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
41
|
+
onBlur?: ((...args: any[]) => any) | undefined;
|
|
42
|
+
onFocus?: ((...args: any[]) => any) | undefined;
|
|
43
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
44
|
+
}>, {
|
|
45
|
+
type: "number" | "text" | "email" | "textarea" | "password" | "tel" | undefined;
|
|
46
|
+
disabled: boolean;
|
|
47
|
+
readonly: boolean;
|
|
48
|
+
modelValue: string | number;
|
|
49
|
+
clearable: boolean;
|
|
50
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { defineComponent, createVNode, mergeProps } from "vue";
|
|
2
|
+
import { Field } from "vant";
|
|
3
|
+
const Input = /* @__PURE__ */ defineComponent({
|
|
4
|
+
name: "FbkVantInput",
|
|
5
|
+
inheritAttrs: false,
|
|
6
|
+
props: {
|
|
7
|
+
modelValue: {
|
|
8
|
+
type: [String, Number],
|
|
9
|
+
default: ""
|
|
10
|
+
},
|
|
11
|
+
type: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: "text"
|
|
14
|
+
},
|
|
15
|
+
placeholder: String,
|
|
16
|
+
disabled: Boolean,
|
|
17
|
+
readonly: Boolean,
|
|
18
|
+
clearable: {
|
|
19
|
+
type: Boolean,
|
|
20
|
+
default: true
|
|
21
|
+
},
|
|
22
|
+
rows: Number,
|
|
23
|
+
size: String
|
|
24
|
+
},
|
|
25
|
+
emits: ["update:modelValue", "change", "blur", "focus"],
|
|
26
|
+
setup(props, {
|
|
27
|
+
attrs,
|
|
28
|
+
emit,
|
|
29
|
+
slots
|
|
30
|
+
}) {
|
|
31
|
+
return () => createVNode(Field, mergeProps(attrs, {
|
|
32
|
+
"modelValue": String(props.modelValue ?? ""),
|
|
33
|
+
"type": props.type === "password" ? "password" : props.type === "number" ? "digit" : "text",
|
|
34
|
+
"rows": props.type === "textarea" ? props.rows ?? 3 : void 0,
|
|
35
|
+
"autosize": props.type === "textarea",
|
|
36
|
+
"clearable": props.clearable,
|
|
37
|
+
"readonly": props.readonly,
|
|
38
|
+
"disabled": props.disabled,
|
|
39
|
+
"placeholder": props.placeholder,
|
|
40
|
+
"onUpdate:modelValue": (value) => emit("update:modelValue", value),
|
|
41
|
+
"onBlur": (event) => emit("blur", event),
|
|
42
|
+
"onFocus": (event) => emit("focus", event)
|
|
43
|
+
}), slots);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
export {
|
|
47
|
+
Input
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=Input.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Input.mjs","sources":["../../src/primitives/Input.tsx"],"sourcesContent":["import { defineComponent, type PropType } from 'vue'\nimport { Field } from 'vant'\nimport type { InputProps } from '@fbkworks/adapter-core'\n\nexport const Input = defineComponent({\n name: 'FbkVantInput',\n inheritAttrs: false,\n props: {\n modelValue: { type: [String, Number] as PropType<string | number>, default: '' },\n type: { type: String as PropType<InputProps['type']>, default: 'text' },\n placeholder: String,\n disabled: Boolean,\n readonly: Boolean,\n clearable: { type: Boolean, default: true },\n rows: Number,\n size: String,\n },\n emits: ['update:modelValue', 'change', 'blur', 'focus'],\n setup(props, { attrs, emit, slots }) {\n return () => (\n <Field\n {...attrs}\n modelValue={String(props.modelValue ?? '')}\n type={props.type === 'password' ? 'password' : props.type === 'number' ? 'digit' : 'text'}\n rows={props.type === 'textarea' ? (props.rows ?? 3) : undefined}\n autosize={props.type === 'textarea'}\n clearable={props.clearable}\n readonly={props.readonly}\n disabled={props.disabled}\n placeholder={props.placeholder}\n onUpdate:modelValue={(value: string) => emit('update:modelValue', value)}\n onBlur={(event: Event) => emit('blur', event)}\n onFocus={(event: Event) => emit('focus', event)}\n v-slots={slots}\n />\n )\n },\n})\n"],"names":["Input","defineComponent","name","inheritAttrs","props","modelValue","type","String","Number","default","placeholder","disabled","Boolean","readonly","clearable","rows","size","emits","setup","attrs","emit","slots","_createVNode","Field","_mergeProps","undefined","value","event"],"mappings":";;AAIO,MAAMA,QAAQC,gCAAgB;AAAA,EACnCC,MAAM;AAAA,EACNC,cAAc;AAAA,EACdC,OAAO;AAAA,IACLC,YAAY;AAAA,MAAEC,MAAM,CAACC,QAAQC,MAAM;AAAA,MAAgCC,SAAS;AAAA;IAC5EH,MAAM;AAAA,MAAEA,MAAMC;AAAAA,MAAwCE,SAAS;AAAA;IAC/DC,aAAaH;AAAAA,IACbI,UAAUC;AAAAA,IACVC,UAAUD;AAAAA,IACVE,WAAW;AAAA,MAAER,MAAMM;AAAAA,MAASH,SAAS;AAAA;IACrCM,MAAMP;AAAAA,IACNQ,MAAMT;AAAAA;EAERU,OAAO,CAAC,qBAAqB,UAAU,QAAQ,OAAO;AAAA,EACtDC,MAAMd,OAAO;AAAA,IAAEe;AAAAA,IAAOC;AAAAA,IAAMC;AAAAA,EAAM,GAAG;AACnC,WAAO,MAAAC,YAAAC,OAAAC,WAECL,OAAK;AAAA,MAAA,cACGZ,OAAOH,MAAMC,cAAc,EAAE;AAAA,MAAC,QACpCD,MAAME,SAAS,aAAa,aAAaF,MAAME,SAAS,WAAW,UAAU;AAAA,MAAM,QACnFF,MAAME,SAAS,aAAcF,MAAMW,QAAQ,IAAKU;AAAAA,MAAS,YACrDrB,MAAME,SAAS;AAAA,MAAU,aACxBF,MAAMU;AAAAA,MAAS,YAChBV,MAAMS;AAAAA,MAAQ,YACdT,MAAMO;AAAAA,MAAQ,eACXP,MAAMM;AAAAA,MAAW,uBACRgB,WAAkBN,KAAK,qBAAqBM,KAAK;AAAA,MAAC,UAC/DC,WAAiBP,KAAK,QAAQO,KAAK;AAAA,MAAC,WACnCA,WAAiBP,KAAK,SAASO,KAAK;AAAA,IAAC,CAAA,GACtCN,KAAK;AAAA,EAGpB;AACF,CAAC;"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { PropType } from 'vue';
|
|
2
|
+
/** 移动端默认使用无限滚动;只有显式需要分页时才渲染 van-pagination。 */
|
|
3
|
+
export declare const Pagination: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
4
|
+
page: {
|
|
5
|
+
type: NumberConstructor;
|
|
6
|
+
default: number;
|
|
7
|
+
};
|
|
8
|
+
pageSize: {
|
|
9
|
+
type: NumberConstructor;
|
|
10
|
+
default: number;
|
|
11
|
+
};
|
|
12
|
+
total: {
|
|
13
|
+
type: NumberConstructor;
|
|
14
|
+
default: number;
|
|
15
|
+
};
|
|
16
|
+
pageSizes: {
|
|
17
|
+
type: PropType<number[]>;
|
|
18
|
+
default: () => never[];
|
|
19
|
+
};
|
|
20
|
+
showTotal: BooleanConstructor;
|
|
21
|
+
showJumper: BooleanConstructor;
|
|
22
|
+
size: StringConstructor;
|
|
23
|
+
disabled: BooleanConstructor;
|
|
24
|
+
mode: {
|
|
25
|
+
type: PropType<"pages" | "infinite">;
|
|
26
|
+
default: string;
|
|
27
|
+
};
|
|
28
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("update:page" | "update:pageSize")[], "update:page" | "update:pageSize", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
29
|
+
page: {
|
|
30
|
+
type: NumberConstructor;
|
|
31
|
+
default: number;
|
|
32
|
+
};
|
|
33
|
+
pageSize: {
|
|
34
|
+
type: NumberConstructor;
|
|
35
|
+
default: number;
|
|
36
|
+
};
|
|
37
|
+
total: {
|
|
38
|
+
type: NumberConstructor;
|
|
39
|
+
default: number;
|
|
40
|
+
};
|
|
41
|
+
pageSizes: {
|
|
42
|
+
type: PropType<number[]>;
|
|
43
|
+
default: () => never[];
|
|
44
|
+
};
|
|
45
|
+
showTotal: BooleanConstructor;
|
|
46
|
+
showJumper: BooleanConstructor;
|
|
47
|
+
size: StringConstructor;
|
|
48
|
+
disabled: BooleanConstructor;
|
|
49
|
+
mode: {
|
|
50
|
+
type: PropType<"pages" | "infinite">;
|
|
51
|
+
default: string;
|
|
52
|
+
};
|
|
53
|
+
}>> & Readonly<{
|
|
54
|
+
"onUpdate:page"?: ((...args: any[]) => any) | undefined;
|
|
55
|
+
"onUpdate:pageSize"?: ((...args: any[]) => any) | undefined;
|
|
56
|
+
}>, {
|
|
57
|
+
mode: "pages" | "infinite";
|
|
58
|
+
disabled: boolean;
|
|
59
|
+
showTotal: boolean;
|
|
60
|
+
showJumper: boolean;
|
|
61
|
+
page: number;
|
|
62
|
+
pageSize: number;
|
|
63
|
+
total: number;
|
|
64
|
+
pageSizes: number[];
|
|
65
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { defineComponent, computed, createVNode } from "vue";
|
|
2
|
+
import { Loading, Pagination as Pagination$1 } from "vant";
|
|
3
|
+
const Pagination = /* @__PURE__ */ defineComponent({
|
|
4
|
+
name: "FbkVantPagination",
|
|
5
|
+
inheritAttrs: false,
|
|
6
|
+
props: {
|
|
7
|
+
page: {
|
|
8
|
+
type: Number,
|
|
9
|
+
default: 1
|
|
10
|
+
},
|
|
11
|
+
pageSize: {
|
|
12
|
+
type: Number,
|
|
13
|
+
default: 20
|
|
14
|
+
},
|
|
15
|
+
total: {
|
|
16
|
+
type: Number,
|
|
17
|
+
default: 0
|
|
18
|
+
},
|
|
19
|
+
pageSizes: {
|
|
20
|
+
type: Array,
|
|
21
|
+
default: () => []
|
|
22
|
+
},
|
|
23
|
+
showTotal: Boolean,
|
|
24
|
+
showJumper: Boolean,
|
|
25
|
+
size: String,
|
|
26
|
+
disabled: Boolean,
|
|
27
|
+
mode: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: "pages"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
emits: ["update:page", "update:pageSize"],
|
|
33
|
+
setup(props, {
|
|
34
|
+
attrs,
|
|
35
|
+
emit
|
|
36
|
+
}) {
|
|
37
|
+
const pageCount = computed(() => Math.max(1, Math.ceil(props.total / props.pageSize)));
|
|
38
|
+
return () => createVNode("div", attrs, [props.mode === "infinite" ? createVNode("div", {
|
|
39
|
+
"class": "fbk-vant-pagination__infinite",
|
|
40
|
+
"data-fbk-part": "pagination"
|
|
41
|
+
}, [createVNode(Loading, {
|
|
42
|
+
"size": "20"
|
|
43
|
+
}, {
|
|
44
|
+
default: () => [props.page >= pageCount.value ? "没有更多了" : "上拉加载更多"]
|
|
45
|
+
})]) : createVNode(Pagination$1, {
|
|
46
|
+
"data-fbk-part": "pagination",
|
|
47
|
+
"modelValue": props.page,
|
|
48
|
+
"totalItems": props.total,
|
|
49
|
+
"itemsPerPage": props.pageSize,
|
|
50
|
+
"onUpdate:modelValue": (page) => emit("update:page", page)
|
|
51
|
+
}, null)]);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
export {
|
|
55
|
+
Pagination
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=Pagination.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pagination.mjs","sources":["../../src/primitives/Pagination.tsx"],"sourcesContent":["import { computed, defineComponent, type PropType } from 'vue'\nimport { Pagination as VanPagination, Loading } from 'vant'\n\n/** 移动端默认使用无限滚动;只有显式需要分页时才渲染 van-pagination。 */\nexport const Pagination = defineComponent({\n name: 'FbkVantPagination',\n inheritAttrs: false,\n props: {\n page: { type: Number, default: 1 },\n pageSize: { type: Number, default: 20 },\n total: { type: Number, default: 0 },\n pageSizes: { type: Array as PropType<number[]>, default: () => [] },\n showTotal: Boolean,\n showJumper: Boolean,\n size: String,\n disabled: Boolean,\n mode: { type: String as PropType<'pages' | 'infinite'>, default: 'pages' },\n },\n emits: ['update:page', 'update:pageSize'],\n setup(props, { attrs, emit }) {\n const pageCount = computed(() => Math.max(1, Math.ceil(props.total / props.pageSize)))\n return () => (\n <div {...attrs}>\n {props.mode === 'infinite' ? (\n <div class=\"fbk-vant-pagination__infinite\" data-fbk-part=\"pagination\">\n <Loading size=\"20\">{props.page >= pageCount.value ? '没有更多了' : '上拉加载更多'}</Loading>\n </div>\n ) : (\n <VanPagination\n data-fbk-part=\"pagination\"\n modelValue={props.page}\n totalItems={props.total}\n itemsPerPage={props.pageSize}\n onUpdate:modelValue={(page: number) => emit('update:page', page)}\n />\n )}\n </div>\n )\n },\n})\n"],"names":["Pagination","defineComponent","name","inheritAttrs","props","page","type","Number","default","pageSize","total","pageSizes","Array","showTotal","Boolean","showJumper","size","String","disabled","mode","emits","setup","attrs","emit","pageCount","computed","Math","max","ceil","_createVNode","Loading","value","VanPagination"],"mappings":";;AAIO,MAAMA,aAAaC,gCAAgB;AAAA,EACxCC,MAAM;AAAA,EACNC,cAAc;AAAA,EACdC,OAAO;AAAA,IACLC,MAAM;AAAA,MAAEC,MAAMC;AAAAA,MAAQC,SAAS;AAAA;IAC/BC,UAAU;AAAA,MAAEH,MAAMC;AAAAA,MAAQC,SAAS;AAAA;IACnCE,OAAO;AAAA,MAAEJ,MAAMC;AAAAA,MAAQC,SAAS;AAAA;IAChCG,WAAW;AAAA,MAAEL,MAAMM;AAAAA,MAA6BJ,SAASA,MAAM,CAAA;AAAA;IAC/DK,WAAWC;AAAAA,IACXC,YAAYD;AAAAA,IACZE,MAAMC;AAAAA,IACNC,UAAUJ;AAAAA,IACVK,MAAM;AAAA,MAAEb,MAAMW;AAAAA,MAA0CT,SAAS;AAAA,IAAQ;AAAA;EAE3EY,OAAO,CAAC,eAAe,iBAAiB;AAAA,EACxCC,MAAMjB,OAAO;AAAA,IAAEkB;AAAAA,IAAOC;AAAAA,EAAK,GAAG;AAC5B,UAAMC,YAAYC,SAAS,MAAMC,KAAKC,IAAI,GAAGD,KAAKE,KAAKxB,MAAMM,QAAQN,MAAMK,QAAQ,CAAC,CAAC;AACrF,WAAO,MAAAoB,YAAA,OACIP,OAAK,CACXlB,MAAMe,SAAS,aAAUU,YAAA,OAAA;AAAA,MAAA,SAAA;AAAA,MAAA,iBAAA;AAAA,OAAA,CAAAA,YAAAC,SAAA;AAAA,MAAA,QAAA;AAAA,IAAA,GAAA;AAAA,MAAAtB,SAAAA,MAAA,CAEFJ,MAAMC,QAAQmB,UAAUO,QAAQ,UAAU,QAAQ;AAAA,KAAA,CAAA,CAAA,IAAAF,YAAAG,cAAA;AAAA,MAAA,iBAAA;AAAA,MAAA,cAK1D5B,MAAMC;AAAAA,MAAI,cACVD,MAAMM;AAAAA,MAAK,gBACTN,MAAMK;AAAAA,MAAQ,uBACNJ,UAAiBkB,KAAK,eAAelB,IAAI;AAAA,IAAC,GAAA,IAAA,CAEnE,CAAA;AAAA,EAGP;AACF,CAAC;"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PropType } from 'vue';
|
|
2
|
+
import { RadioProps, Size } from '@fbkworks/adapter-core';
|
|
3
|
+
/** 单选组(移动端)。vant 的 RadioGroup 用 `modelValue` + `update:modelValue`。 */
|
|
4
|
+
export declare const Radio: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
5
|
+
modelValue: {
|
|
6
|
+
type: PropType<string | number | null>;
|
|
7
|
+
default: undefined;
|
|
8
|
+
};
|
|
9
|
+
options: {
|
|
10
|
+
type: PropType<RadioProps["options"]>;
|
|
11
|
+
default: () => never[];
|
|
12
|
+
};
|
|
13
|
+
disabled: BooleanConstructor;
|
|
14
|
+
size: {
|
|
15
|
+
type: PropType<Size>;
|
|
16
|
+
default: string;
|
|
17
|
+
};
|
|
18
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("change" | "update:modelValue")[], "change" | "update:modelValue", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
19
|
+
modelValue: {
|
|
20
|
+
type: PropType<string | number | null>;
|
|
21
|
+
default: undefined;
|
|
22
|
+
};
|
|
23
|
+
options: {
|
|
24
|
+
type: PropType<RadioProps["options"]>;
|
|
25
|
+
default: () => never[];
|
|
26
|
+
};
|
|
27
|
+
disabled: BooleanConstructor;
|
|
28
|
+
size: {
|
|
29
|
+
type: PropType<Size>;
|
|
30
|
+
default: string;
|
|
31
|
+
};
|
|
32
|
+
}>> & Readonly<{
|
|
33
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
34
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
35
|
+
}>, {
|
|
36
|
+
size: Size;
|
|
37
|
+
disabled: boolean;
|
|
38
|
+
modelValue: string | number | null;
|
|
39
|
+
options: import('@fbkworks/adapter-core').RadioOption<string | number>[];
|
|
40
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { defineComponent, createVNode, mergeProps, isVNode } from "vue";
|
|
2
|
+
import { RadioGroup, Radio as Radio$1 } from "vant";
|
|
3
|
+
function _isSlot(s) {
|
|
4
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
5
|
+
}
|
|
6
|
+
const Radio = /* @__PURE__ */ defineComponent({
|
|
7
|
+
name: "FbkVantRadio",
|
|
8
|
+
inheritAttrs: false,
|
|
9
|
+
props: {
|
|
10
|
+
modelValue: {
|
|
11
|
+
type: [String, Number],
|
|
12
|
+
default: void 0
|
|
13
|
+
},
|
|
14
|
+
options: {
|
|
15
|
+
type: Array,
|
|
16
|
+
default: () => []
|
|
17
|
+
},
|
|
18
|
+
disabled: Boolean,
|
|
19
|
+
size: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: "md"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
emits: ["update:modelValue", "change"],
|
|
25
|
+
setup(props, {
|
|
26
|
+
attrs,
|
|
27
|
+
emit
|
|
28
|
+
}) {
|
|
29
|
+
return () => {
|
|
30
|
+
let _slot;
|
|
31
|
+
return createVNode(RadioGroup, mergeProps(attrs, {
|
|
32
|
+
"modelValue": props.modelValue ?? null,
|
|
33
|
+
"disabled": props.disabled,
|
|
34
|
+
"iconSize": props.size === "sm" ? 16 : props.size === "lg" ? 22 : 18,
|
|
35
|
+
"onUpdate:modelValue": (value) => {
|
|
36
|
+
emit("update:modelValue", value);
|
|
37
|
+
emit("change", value);
|
|
38
|
+
}
|
|
39
|
+
}), _isSlot(_slot = props.options.map((option) => createVNode(Radio$1, {
|
|
40
|
+
"key": String(option.value),
|
|
41
|
+
"name": option.value,
|
|
42
|
+
"disabled": option.disabled
|
|
43
|
+
}, {
|
|
44
|
+
default: () => [option.label]
|
|
45
|
+
}))) ? _slot : {
|
|
46
|
+
default: () => [_slot]
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
export {
|
|
52
|
+
Radio
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=Radio.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Radio.mjs","sources":["../../src/primitives/Radio.tsx"],"sourcesContent":["import { defineComponent, type PropType } from 'vue'\nimport { RadioGroup, Radio as VanRadio } from 'vant'\nimport type { RadioProps, Size } from '@fbkworks/adapter-core'\n\n/** 单选组(移动端)。vant 的 RadioGroup 用 `modelValue` + `update:modelValue`。 */\nexport const Radio = defineComponent({\n name: 'FbkVantRadio',\n inheritAttrs: false,\n props: {\n modelValue: { type: [String, Number] as PropType<string | number | null>, default: undefined },\n options: { type: Array as PropType<RadioProps['options']>, default: () => [] },\n disabled: Boolean,\n size: { type: String as PropType<Size>, default: 'md' },\n },\n emits: ['update:modelValue', 'change'],\n setup(props, { attrs, emit }) {\n return () => (\n <RadioGroup\n {...attrs}\n modelValue={props.modelValue ?? null}\n disabled={props.disabled}\n iconSize={props.size === 'sm' ? 16 : props.size === 'lg' ? 22 : 18}\n onUpdate:modelValue={(value: string | number) => {\n emit('update:modelValue', value)\n emit('change', value)\n }}\n >\n {props.options.map((option) => (\n <VanRadio key={String(option.value)} name={option.value} disabled={option.disabled}>\n {option.label}\n </VanRadio>\n ))}\n </RadioGroup>\n )\n },\n})\n"],"names":["_isSlot","s","Object","prototype","toString","call","_isVNode","Radio","defineComponent","name","inheritAttrs","props","modelValue","type","String","Number","default","undefined","options","Array","disabled","Boolean","size","emits","setup","attrs","emit","_slot","_createVNode","RadioGroup","_mergeProps","value","map","option","VanRadio","label"],"mappings":";;AACoD,SAAAA,QAAAC,GAAA;AAAA,SAAA,OAAAA,MAAA,cAAAC,OAAAC,UAAAC,SAAAC,KAAAJ,CAAA,MAAA,qBAAA,CAAAK,QAAAL,CAAA;AAAA;AAI7C,MAAMM,QAAQC,gCAAgB;AAAA,EACnCC,MAAM;AAAA,EACNC,cAAc;AAAA,EACdC,OAAO;AAAA,IACLC,YAAY;AAAA,MAAEC,MAAM,CAACC,QAAQC,MAAM;AAAA,MAAuCC,SAASC;AAAAA;IACnFC,SAAS;AAAA,MAAEL,MAAMM;AAAAA,MAA0CH,SAASA,MAAM,CAAA;AAAA;IAC1EI,UAAUC;AAAAA,IACVC,MAAM;AAAA,MAAET,MAAMC;AAAAA,MAA0BE,SAAS;AAAA,IAAK;AAAA;EAExDO,OAAO,CAAC,qBAAqB,QAAQ;AAAA,EACrCC,MAAMb,OAAO;AAAA,IAAEc;AAAAA,IAAOC;AAAAA,EAAK,GAAG;AAC5B,WAAO,MAAA;AAAA,UAAAC;AAAA,aAAAC,YAAAC,YAAAC,WAECL,OAAK;AAAA,QAAA,cACGd,MAAMC,cAAc;AAAA,QAAI,YAC1BD,MAAMS;AAAAA,QAAQ,YACdT,MAAMW,SAAS,OAAO,KAAKX,MAAMW,SAAS,OAAO,KAAK;AAAA,QAAE,uBAC5CS,WAA2B;AAC/CL,eAAK,qBAAqBK,KAAK;AAC/BL,eAAK,UAAUK,KAAK;AAAA,QACtB;AAAA,MAAC,CAAA,GAAA/B,QAAA2B,QAEAhB,MAAMO,QAAQc,IAAKC,YAAML,YAAAM,SAAA;AAAA,QAAA,OACTpB,OAAOmB,OAAOF,KAAK;AAAA,QAAC,QAAQE,OAAOF;AAAAA,QAAK,YAAYE,OAAOb;AAAAA,MAAQ,GAAA;AAAA,QAAAJ,SAAAA,MAAA,CAC/EiB,OAAOE,KAAK;AAAA,OAAA,CAEhB,CAAC,IAAAR,QAAA;AAAA,QAAAX,SAAAA,MAAA,CAAAW,KAAA;AAAA,MAAA,CAAA;AAAA,IAAA;AAAA,EAGR;AACF,CAAC;"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { PropType } from 'vue';
|
|
2
|
+
import { SelectOption, SelectProps } from '@fbkworks/adapter-core';
|
|
3
|
+
/**
|
|
4
|
+
* vant 没有 select:用 只读 Field + Popup + Picker(单选)/ CheckboxGroup(多选)组合。
|
|
5
|
+
* 业务侧只传 options + modelValue —— 这正是适配层存在的意义。
|
|
6
|
+
*/
|
|
7
|
+
export declare const Select: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
8
|
+
modelValue: {
|
|
9
|
+
type: PropType<SelectProps["modelValue"]>;
|
|
10
|
+
default: undefined;
|
|
11
|
+
};
|
|
12
|
+
options: {
|
|
13
|
+
type: PropType<SelectOption[]>;
|
|
14
|
+
default: () => never[];
|
|
15
|
+
};
|
|
16
|
+
multiple: BooleanConstructor;
|
|
17
|
+
filterable: BooleanConstructor;
|
|
18
|
+
clearable: {
|
|
19
|
+
type: BooleanConstructor;
|
|
20
|
+
default: boolean;
|
|
21
|
+
};
|
|
22
|
+
placeholder: StringConstructor;
|
|
23
|
+
title: StringConstructor;
|
|
24
|
+
size: StringConstructor;
|
|
25
|
+
disabled: BooleanConstructor;
|
|
26
|
+
loading: BooleanConstructor;
|
|
27
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("change" | "update:modelValue")[], "change" | "update:modelValue", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
28
|
+
modelValue: {
|
|
29
|
+
type: PropType<SelectProps["modelValue"]>;
|
|
30
|
+
default: undefined;
|
|
31
|
+
};
|
|
32
|
+
options: {
|
|
33
|
+
type: PropType<SelectOption[]>;
|
|
34
|
+
default: () => never[];
|
|
35
|
+
};
|
|
36
|
+
multiple: BooleanConstructor;
|
|
37
|
+
filterable: BooleanConstructor;
|
|
38
|
+
clearable: {
|
|
39
|
+
type: BooleanConstructor;
|
|
40
|
+
default: boolean;
|
|
41
|
+
};
|
|
42
|
+
placeholder: StringConstructor;
|
|
43
|
+
title: StringConstructor;
|
|
44
|
+
size: StringConstructor;
|
|
45
|
+
disabled: BooleanConstructor;
|
|
46
|
+
loading: BooleanConstructor;
|
|
47
|
+
}>> & Readonly<{
|
|
48
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
49
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
50
|
+
}>, {
|
|
51
|
+
disabled: boolean;
|
|
52
|
+
loading: boolean;
|
|
53
|
+
modelValue: string | number | (string | number)[] | null | undefined;
|
|
54
|
+
clearable: boolean;
|
|
55
|
+
multiple: boolean;
|
|
56
|
+
filterable: boolean;
|
|
57
|
+
options: SelectOption<string | number>[];
|
|
58
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { defineComponent, ref, computed, createVNode, mergeProps, createTextVNode, isVNode } from "vue";
|
|
2
|
+
import { Field, Popup, Cell, CheckboxGroup, Checkbox, Picker } from "vant";
|
|
3
|
+
function _isSlot(s) {
|
|
4
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
5
|
+
}
|
|
6
|
+
const Select = /* @__PURE__ */ defineComponent({
|
|
7
|
+
name: "FbkVantSelect",
|
|
8
|
+
inheritAttrs: false,
|
|
9
|
+
props: {
|
|
10
|
+
modelValue: {
|
|
11
|
+
type: [String, Number, Array],
|
|
12
|
+
default: void 0
|
|
13
|
+
},
|
|
14
|
+
options: {
|
|
15
|
+
type: Array,
|
|
16
|
+
default: () => []
|
|
17
|
+
},
|
|
18
|
+
multiple: Boolean,
|
|
19
|
+
filterable: Boolean,
|
|
20
|
+
clearable: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: true
|
|
23
|
+
},
|
|
24
|
+
placeholder: String,
|
|
25
|
+
title: String,
|
|
26
|
+
size: String,
|
|
27
|
+
disabled: Boolean,
|
|
28
|
+
loading: Boolean
|
|
29
|
+
},
|
|
30
|
+
emits: ["update:modelValue", "change"],
|
|
31
|
+
setup(props, {
|
|
32
|
+
attrs,
|
|
33
|
+
emit
|
|
34
|
+
}) {
|
|
35
|
+
const show = ref(false);
|
|
36
|
+
const tempValue = ref(props.modelValue);
|
|
37
|
+
const selectedLabels = computed(() => {
|
|
38
|
+
const values = Array.isArray(props.modelValue) ? props.modelValue : [props.modelValue];
|
|
39
|
+
return props.options.filter((option) => values.includes(option.value)).map((option) => option.label).join(", ");
|
|
40
|
+
});
|
|
41
|
+
const pickerColumns = computed(() => props.options.map((option) => ({
|
|
42
|
+
text: option.label,
|
|
43
|
+
value: option.value
|
|
44
|
+
})));
|
|
45
|
+
const open = () => {
|
|
46
|
+
if (props.disabled) return;
|
|
47
|
+
tempValue.value = props.modelValue;
|
|
48
|
+
show.value = true;
|
|
49
|
+
};
|
|
50
|
+
const confirmSingle = ({
|
|
51
|
+
selectedOptions
|
|
52
|
+
}) => {
|
|
53
|
+
const value = selectedOptions[0]?.value;
|
|
54
|
+
emit("update:modelValue", value);
|
|
55
|
+
emit("change", value);
|
|
56
|
+
show.value = false;
|
|
57
|
+
};
|
|
58
|
+
const confirmMultiple = () => {
|
|
59
|
+
emit("update:modelValue", tempValue.value);
|
|
60
|
+
emit("change", tempValue.value);
|
|
61
|
+
show.value = false;
|
|
62
|
+
};
|
|
63
|
+
return () => {
|
|
64
|
+
let _slot;
|
|
65
|
+
return createVNode("div", mergeProps({
|
|
66
|
+
"class": "fbk-vant-select"
|
|
67
|
+
}, attrs), [createVNode(Field, {
|
|
68
|
+
"readonly": true,
|
|
69
|
+
"isLink": true,
|
|
70
|
+
"modelValue": selectedLabels.value,
|
|
71
|
+
"placeholder": props.placeholder ?? "请选择",
|
|
72
|
+
"disabled": props.disabled,
|
|
73
|
+
"onClick": open
|
|
74
|
+
}, null), createVNode(Popup, {
|
|
75
|
+
"show": show.value,
|
|
76
|
+
"onUpdate:show": ($event) => show.value = $event,
|
|
77
|
+
"position": "bottom",
|
|
78
|
+
"round": true,
|
|
79
|
+
"teleport": "body"
|
|
80
|
+
}, {
|
|
81
|
+
default: () => [props.multiple ? createVNode("div", {
|
|
82
|
+
"class": "fbk-vant-select__multiple"
|
|
83
|
+
}, [createVNode(Cell, {
|
|
84
|
+
"title": props.title ?? "请选择"
|
|
85
|
+
}, null), createVNode(CheckboxGroup, {
|
|
86
|
+
"modelValue": tempValue.value,
|
|
87
|
+
"onUpdate:modelValue": (value) => tempValue.value = value
|
|
88
|
+
}, _isSlot(_slot = props.options.map((option) => createVNode(Cell, {
|
|
89
|
+
"key": String(option.value),
|
|
90
|
+
"title": option.label
|
|
91
|
+
}, {
|
|
92
|
+
rightIcon: () => createVNode(Checkbox, {
|
|
93
|
+
"name": option.value,
|
|
94
|
+
"disabled": option.disabled,
|
|
95
|
+
"shape": "square"
|
|
96
|
+
}, null)
|
|
97
|
+
}))) ? _slot : {
|
|
98
|
+
default: () => [_slot]
|
|
99
|
+
}), createVNode("div", {
|
|
100
|
+
"class": "fbk-vant-select__actions"
|
|
101
|
+
}, [createVNode("button", {
|
|
102
|
+
"type": "button",
|
|
103
|
+
"onClick": confirmMultiple
|
|
104
|
+
}, [createTextVNode("确定")])])]) : createVNode(Picker, {
|
|
105
|
+
"title": props.title ?? "请选择",
|
|
106
|
+
"columns": pickerColumns.value,
|
|
107
|
+
"modelValue": tempValue.value,
|
|
108
|
+
"onConfirm": confirmSingle,
|
|
109
|
+
"onCancel": () => show.value = false
|
|
110
|
+
}, null)]
|
|
111
|
+
})]);
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
export {
|
|
116
|
+
Select
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=Select.mjs.map
|