@silver-formily/element-plus 4.0.3 → 5.0.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/esm/__builtins__/shared/loading.mjs.map +1 -1
- package/esm/__builtins__/shared/transform-component.mjs +1 -1
- package/esm/__builtins__/shared/transform-component.mjs.map +1 -1
- package/esm/__builtins__/shared/utils.mjs +7 -5
- package/esm/__builtins__/shared/utils.mjs.map +1 -1
- package/esm/array-base/array-base-inner.mjs.map +1 -1
- package/esm/array-base/array-base-move-down.mjs +1 -1
- package/esm/array-base/array-base-move-down.mjs.map +1 -1
- package/esm/array-base/array-base-move-up.mjs +1 -1
- package/esm/array-base/array-base-move-up.mjs.map +1 -1
- package/esm/array-base/array-base-remove.mjs +1 -1
- package/esm/array-base/array-base-remove.mjs.map +1 -1
- package/esm/array-base/types.d.ts +2 -2
- package/esm/array-base/utils.d.ts +1 -1
- package/esm/array-base/utils.mjs +1 -1
- package/esm/array-base/utils.mjs.map +1 -1
- package/esm/array-cards/array-cards.mjs +1 -1
- package/esm/array-cards/array-cards.mjs.map +1 -1
- package/esm/array-collapse/array-collapse-item.mjs +1 -1
- package/esm/array-collapse/array-collapse-item.mjs.map +1 -1
- package/esm/array-collapse/array-collapse.mjs +3 -4
- package/esm/array-collapse/array-collapse.mjs.map +1 -1
- package/esm/array-items/array-items.mjs +3 -8
- package/esm/array-items/array-items.mjs.map +1 -1
- package/esm/array-list-tabs/array-list-tabs.mjs +57 -51
- package/esm/array-list-tabs/array-list-tabs.mjs.map +1 -1
- package/esm/array-list-tabs/utils.mjs.map +1 -1
- package/esm/array-table/array-table.mjs +4 -18
- package/esm/array-table/array-table.mjs.map +1 -1
- package/esm/array-table/utils.mjs.map +1 -1
- package/esm/array-tabs/array-tabs.mjs +1 -1
- package/esm/array-tabs/array-tabs.mjs.map +1 -1
- package/esm/autocomplete/autocomplete.mjs.map +1 -1
- package/esm/autocomplete/index.d.ts +3 -4
- package/esm/checkbox/checkbox-group.mjs +1 -1
- package/esm/checkbox/checkbox-group.mjs.map +1 -1
- package/esm/checkbox/index.d.ts +117 -117
- package/esm/color-picker/index.d.ts +28 -28
- package/esm/color-picker-panel/index.d.ts +18 -18
- package/esm/date-picker-panel/index.d.ts +1 -1
- package/esm/editable/editable-popover.mjs +1 -1
- package/esm/editable/editable-popover.mjs.map +1 -1
- package/esm/editable/editable.mjs +1 -1
- package/esm/editable/editable.mjs.map +1 -1
- package/esm/form/form.mjs.map +1 -1
- package/esm/form/form.vue.d.ts +1 -1
- package/esm/form-collapse/form-collapse.mjs +1 -1
- package/esm/form-collapse/form-collapse.mjs.map +1 -1
- package/esm/form-collapse/index.d.ts +3 -3
- package/esm/form-collapse/utils.d.ts +2 -2
- package/esm/form-collapse/utils.mjs +2 -2
- package/esm/form-collapse/utils.mjs.map +1 -1
- package/esm/form-dialog/dialog-content.mjs +1 -1
- package/esm/form-dialog/dialog-content.mjs.map +1 -1
- package/esm/form-dialog/index.mjs +3 -3
- package/esm/form-dialog/index.mjs.map +1 -1
- package/esm/form-dialog/types.d.ts +2 -2
- package/esm/form-drawer/drawer-content.mjs +1 -1
- package/esm/form-drawer/drawer-content.mjs.map +1 -1
- package/esm/form-drawer/index.mjs +3 -3
- package/esm/form-drawer/index.mjs.map +1 -1
- package/esm/form-drawer/types.d.ts +2 -2
- package/esm/form-item/form-item.mjs +1 -1
- package/esm/form-item/form-item.mjs.map +1 -1
- package/esm/form-item/index.mjs +1 -1
- package/esm/form-item/index.mjs.map +1 -1
- package/esm/form-item/utils.mjs +1 -1
- package/esm/form-item/utils.mjs.map +1 -1
- package/esm/form-layout/form-layout.mjs +1 -1
- package/esm/form-layout/form-layout.mjs.map +1 -1
- package/esm/form-layout/form-layout.vue.d.ts +1 -1
- package/esm/form-layout/utils.mjs +1 -1
- package/esm/form-layout/utils.mjs.map +1 -1
- package/esm/form-step/form-step.mjs +1 -1
- package/esm/form-step/form-step.mjs.map +1 -1
- package/esm/form-step/types.d.ts +1 -1
- package/esm/form-step/utils.d.ts +1 -1
- package/esm/form-step/utils.mjs +1 -1
- package/esm/form-step/utils.mjs.map +1 -1
- package/esm/form-tab/hooks.mjs.map +1 -1
- package/esm/form-tab/utils.mjs +1 -1
- package/esm/form-tab/utils.mjs.map +1 -1
- package/esm/input-number/index.d.ts +39 -39
- package/esm/input-tag/index.d.ts +1 -2
- package/esm/input-tag/input-tag.mjs.map +1 -1
- package/esm/mention/index.d.ts +3 -4
- package/esm/mention/mention.mjs.map +1 -1
- package/esm/pagination/components/pager2.mjs.map +1 -1
- package/esm/pagination/components/sizes2.mjs +1 -1
- package/esm/pagination/components/sizes2.mjs.map +1 -1
- package/esm/picker-select/picker-select.mjs +1 -1
- package/esm/picker-select/picker-select.mjs.map +1 -1
- package/esm/picker-select/types.d.ts +1 -1
- package/esm/preview-text/cascader.mjs.map +1 -1
- package/esm/preview-text/color-picker.mjs +1 -1
- package/esm/preview-text/color-picker.mjs.map +1 -1
- package/esm/preview-text/input.mjs +1 -1
- package/esm/preview-text/input.mjs.map +1 -1
- package/esm/preview-text/rate.mjs +1 -1
- package/esm/preview-text/rate.mjs.map +1 -1
- package/esm/preview-text/select.mjs +1 -1
- package/esm/preview-text/select.mjs.map +1 -1
- package/esm/preview-text/time-picker.mjs +1 -1
- package/esm/preview-text/time-picker.mjs.map +1 -1
- package/esm/preview-text/tree.mjs.map +1 -1
- package/esm/query-form/hooks.mjs +1 -1
- package/esm/query-form/hooks.mjs.map +1 -1
- package/esm/query-form/index.d.ts +5 -5
- package/esm/query-form/query-form-light.mjs +1 -1
- package/esm/query-form/query-form-light.mjs.map +1 -1
- package/esm/query-form/query-form.mjs +1 -1
- package/esm/query-form/query-form.mjs.map +1 -1
- package/esm/query-form/types.d.ts +2 -2
- package/esm/query-form-item/index.d.ts +4 -4
- package/esm/query-form-item/query-form-item.mjs +2 -2
- package/esm/query-form-item/query-form-item.mjs.map +1 -1
- package/esm/query-form-item/types.d.ts +2 -2
- package/esm/radio/index.d.ts +72 -72
- package/esm/radio/radio-group.mjs +1 -1
- package/esm/radio/radio-group.mjs.map +1 -1
- package/esm/rate/index.d.ts +10 -10
- package/esm/select/index.d.ts +14 -14
- package/esm/select-table/index.d.ts +3 -3
- package/esm/select-table/select-table.mjs +1 -1
- package/esm/select-table/select-table.mjs.map +1 -1
- package/esm/select-table/types.d.ts +1 -1
- package/esm/submit/submit.mjs.map +1 -1
- package/esm/switch/index.d.ts +27 -27
- package/esm/time-select/index.d.ts +20 -20
- package/esm/transfer/index.d.ts +12 -12
- package/esm/tree/tree.mjs +1 -1
- package/esm/tree/tree.mjs.map +1 -1
- package/esm/tree-select/tree-select.mjs.map +1 -1
- package/esm/upload/upload.mjs +1 -1
- package/esm/upload/upload.mjs.map +1 -1
- package/package.json +18 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-layout.mjs","names":[],"sources":["../../src/form-layout/form-layout.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { FormContext } from 'element-plus'\nimport type { IFormLayoutProps } from './types'\nimport { isEmpty, isValid } from '@formily/shared'\nimport { useThrottleFn } from '@vueuse/core'\nimport { formContextKey, useId } from 'element-plus'\nimport { computed, provide, reactive, ref, toRef, watch } from 'vue'\nimport { stylePrefix, useCleanAttrs } from '../__builtins__'\nimport { filterValidFormLayoutProps, formLayoutDeepContext, formLayoutIdContext, formLayoutShallowContext, useFormDeepLayout, useResponsiveFormLayout } from './utils'\n\ndefineOptions({\n name: 'FFormLayout',\n inheritAttrs: false,\n})\n\nconst props = withDefaults(defineProps<IFormLayoutProps>(), {\n tag: 'form',\n colon: undefined,\n labelWrap: undefined,\n fullness: undefined,\n size: 'default',\n layout: 'horizontal',\n shallow: true,\n statusIcon: true,\n asterisk: undefined,\n})\nconst formPrefixCls = `${stylePrefix}-form`\nconst { props: attrs } = useCleanAttrs()\nconst rootHTMLRef = ref<HTMLElement>()\nconst isFormTag = props.tag === 'form'\nconst formLayoutBaseId = useId()\nconst formLayoutId = computed(() => attrs.value.id ?? `formily-${formLayoutBaseId.value}`)\nconst formLayoutDomId = computed(() => (isFormTag ? formLayoutId.value : attrs.value.id))\nif (isFormTag) {\n provide(formLayoutIdContext, formLayoutId)\n}\n\nconst formLayoutDeepConfig = useFormDeepLayout()\nconst { props: responsiveProps } = useResponsiveFormLayout(props, rootHTMLRef)\n\nconst deepLayout = ref({\n ...formLayoutDeepConfig.value,\n ...(props.shallow\n ? {\n size: props.size,\n ...(isValid(props.colon) && { colon: props.colon }),\n }\n : filterValidFormLayoutProps(props)),\n})\nprovide(formLayoutDeepContext, deepLayout)\n\nconst shallowLayout = ref(props.shallow ? filterValidFormLayoutProps(props) : {})\nprovide(formLayoutShallowContext, shallowLayout)\n\nconst updateLayout = useThrottleFn(() => {\n if (!isEmpty(responsiveProps.value)) {\n const _responsiveProps = filterValidFormLayoutProps(responsiveProps.value)\n shallowLayout.value = filterValidFormLayoutProps({ ...props, ..._responsiveProps })\n }\n}, 200, true)\n\nwatch(() => [props, responsiveProps], updateLayout, {\n deep: true,\n immediate: true,\n})\n\nconst formContext = reactive({\n size: toRef(props, 'size'),\n statusIcon: toRef(props, 'statusIcon'),\n hideRequiredAsterisk: toRef(props, 'hideRequiredAsterisk'),\n requireAsteriskPosition: toRef(props, 'requireAsteriskPosition'),\n})\nprovide(formContextKey, formContext as FormContext)\n</script>\n\n<template>\n <component\n :is=\"props.tag\"\n :id=\"formLayoutDomId\"\n ref=\"rootHTMLRef\"\n :class=\"formPrefixCls\"\n v-bind=\"attrs\"\n @submit.prevent.stop\n >\n <slot />\n </component>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAeA,MAAM,QAAQ;EAWd,MAAM,gBAAgB,GAAG,YAAY;EACrC,MAAM,EAAE,OAAO,UAAU,eAAc;EACvC,MAAM,cAAc,KAAiB;EACrC,MAAM,YAAY,MAAM,QAAQ;EAChC,MAAM,mBAAmB,OAAM;EAC/B,MA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A"}
|
|
1
|
+
{"version":3,"file":"form-layout.mjs","names":[],"sources":["../../src/form-layout/form-layout.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { FormContext } from 'element-plus'\nimport type { IFormLayoutProps } from './types'\nimport { isEmpty, isValid } from '@silver-formily/shared'\nimport { useThrottleFn } from '@vueuse/core'\nimport { formContextKey, useId } from 'element-plus'\nimport { computed, provide, reactive, ref, toRef, watch } from 'vue'\nimport { stylePrefix, useCleanAttrs } from '../__builtins__'\nimport { filterValidFormLayoutProps, formLayoutDeepContext, formLayoutIdContext, formLayoutShallowContext, useFormDeepLayout, useResponsiveFormLayout } from './utils'\n\ndefineOptions({\n name: 'FFormLayout',\n inheritAttrs: false,\n})\n\nconst props = withDefaults(defineProps<IFormLayoutProps>(), {\n tag: 'form',\n colon: undefined,\n labelWrap: undefined,\n fullness: undefined,\n size: 'default',\n layout: 'horizontal',\n shallow: true,\n statusIcon: true,\n asterisk: undefined,\n})\nconst formPrefixCls = `${stylePrefix}-form`\nconst { props: attrs } = useCleanAttrs()\nconst rootHTMLRef = ref<HTMLElement>()\nconst isFormTag = props.tag === 'form'\nconst formLayoutBaseId = useId()\nconst formLayoutId = computed(() => attrs.value.id ?? `formily-${formLayoutBaseId.value}`)\nconst formLayoutDomId = computed(() => (isFormTag ? formLayoutId.value : attrs.value.id))\nif (isFormTag) {\n provide(formLayoutIdContext, formLayoutId)\n}\n\nconst formLayoutDeepConfig = useFormDeepLayout()\nconst { props: responsiveProps } = useResponsiveFormLayout(props, rootHTMLRef)\n\nconst deepLayout = ref({\n ...formLayoutDeepConfig.value,\n ...(props.shallow\n ? {\n size: props.size,\n ...(isValid(props.colon) && { colon: props.colon }),\n }\n : filterValidFormLayoutProps(props)),\n})\nprovide(formLayoutDeepContext, deepLayout)\n\nconst shallowLayout = ref(props.shallow ? filterValidFormLayoutProps(props) : {})\nprovide(formLayoutShallowContext, shallowLayout)\n\nconst updateLayout = useThrottleFn(() => {\n if (!isEmpty(responsiveProps.value)) {\n const _responsiveProps = filterValidFormLayoutProps(responsiveProps.value)\n shallowLayout.value = filterValidFormLayoutProps({ ...props, ..._responsiveProps })\n }\n}, 200, true)\n\nwatch(() => [props, responsiveProps], updateLayout, {\n deep: true,\n immediate: true,\n})\n\nconst formContext = reactive({\n size: toRef(props, 'size'),\n statusIcon: toRef(props, 'statusIcon'),\n hideRequiredAsterisk: toRef(props, 'hideRequiredAsterisk'),\n requireAsteriskPosition: toRef(props, 'requireAsteriskPosition'),\n})\nprovide(formContextKey, formContext as FormContext)\n</script>\n\n<template>\n <component\n :is=\"props.tag\"\n :id=\"formLayoutDomId\"\n ref=\"rootHTMLRef\"\n :class=\"formPrefixCls\"\n v-bind=\"attrs\"\n @submit.prevent.stop\n >\n <slot />\n </component>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAeA,MAAM,QAAQ;EAWd,MAAM,gBAAgB,GAAG,YAAY;EACrC,MAAM,EAAE,OAAO,UAAU,eAAc;EACvC,MAAM,cAAc,KAAiB;EACrC,MAAM,YAAY,MAAM,QAAQ;EAChC,MAAM,mBAAmB,OAAM;EAC/B,MAAM,eAAe,eAAe,MAAM,MAAM,MAAM,WAAW,iBAAiB,QAAO;EACzF,MAAM,kBAAkB,eAAgB,YAAY,aAAa,QAAQ,MAAM,MAAM,GAAG;AACxF,MAAI,UACF,SAAQ,qBAAqB,aAAY;EAG3C,MAAM,uBAAuB,mBAAkB;EAC/C,MAAM,EAAE,OAAO,oBAAoB,wBAAwB,OAAO,YAAW;AAW7E,UAAQ,uBATW,IAAI;GACrB,GAAG,qBAAqB;GACxB,GAAI,MAAM,UACN;IACE,MAAM,MAAM;IACZ,GAAI,QAAQ,MAAM,MAAM,IAAI,EAAE,OAAO,MAAM,OAAO;IACpD,GACA,2BAA2B,MAAM;GACtC,CAAA,CACwC;EAEzC,MAAM,gBAAgB,IAAI,MAAM,UAAU,2BAA2B,MAAM,GAAG,EAAE,CAAA;AAChF,UAAQ,0BAA0B,cAAa;AAS/C,cAAY,CAAC,OAAO,gBAAgB,EAPf,oBAAoB;AACvC,OAAI,CAAC,QAAQ,gBAAgB,MAAM,EAAE;IACnC,MAAM,mBAAmB,2BAA2B,gBAAgB,MAAK;AACzE,kBAAc,QAAQ,2BAA2B;KAAE,GAAG;KAAO,GAAG;KAAkB,CAAA;;KAEnF,KAAK,KAAI,EAEwC;GAClD,MAAM;GACN,WAAW;GACZ,CAAA;AAQD,UAAQ,gBANY,SAAS;GAC3B,MAAM,MAAM,OAAO,OAAO;GAC1B,YAAY,MAAM,OAAO,aAAa;GACtC,sBAAsB,MAAM,OAAO,uBAAuB;GAC1D,yBAAyB,MAAM,OAAO,0BAA0B;GACjE,CAAA,CACiD;;uBAIhD,YASY,wBARL,MAAM,IAAG,EADhB,WASY;IAPT,IAAI,gBAAA;aACD;IAAJ,KAAI;IACH,OAAO;MACA,MAAA,MAAK,EAAA,EACZ,UAAM,OAAA,OAAA,OAAA,KAAA,oBAAP,IAAoB,CAAA,WAAA,OAAA,CAAA,GAAA,CAAA,EAAA;2BAEZ,CAAR,WAAQ,KAAA,QAAA,UAAA,CAAA,CAAA"}
|
|
@@ -7,8 +7,8 @@ type __VLS_Slots = {} & {
|
|
|
7
7
|
default?: (props: typeof __VLS_11) => any;
|
|
8
8
|
};
|
|
9
9
|
declare const __VLS_base: _$vue.DefineComponent<IFormLayoutProps, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<IFormLayoutProps> & Readonly<{}>, {
|
|
10
|
-
layout: "vertical" | "horizontal" | "inline" | ("vertical" | "horizontal" | "inline")[];
|
|
11
10
|
size: "small" | "default" | "large";
|
|
11
|
+
layout: "vertical" | "horizontal" | "inline" | ("vertical" | "horizontal" | "inline")[];
|
|
12
12
|
tag: string;
|
|
13
13
|
colon: boolean;
|
|
14
14
|
labelWrap: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useResizeObserver } from "@vueuse/core";
|
|
2
2
|
import { computed, inject, ref } from "vue";
|
|
3
|
-
import { isArr, isValid } from "@formily/shared";
|
|
3
|
+
import { isArr, isValid } from "@silver-formily/shared";
|
|
4
4
|
//#region src/form-layout/utils.ts
|
|
5
5
|
function calcBreakpointIndex(breakpoints, width) {
|
|
6
6
|
for (const [i, breakpoint] of breakpoints.entries()) if (width <= breakpoint) return i;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/form-layout/utils.ts"],"sourcesContent":["import type { ComputedRef, InjectionKey, Ref } from 'vue'\nimport type { IFormLayoutProps } from './types'\nimport { isArr, isValid } from '@formily/shared'\nimport { useResizeObserver } from '@vueuse/core'\nimport { computed, inject, ref } from 'vue'\n\nexport function calcBreakpointIndex(breakpoints: number[], width: number): number {\n for (const [i, breakpoint] of breakpoints.entries()) {\n if (width <= breakpoint) {\n return i\n }\n }\n return -1\n}\n\nexport function calcFactor<T>(value: T | readonly T[], breakpointIndex: number): T {\n if (!Array.isArray(value) || value.length === 0) {\n return value as T\n }\n const safeIndex = Math.max(-1, Math.min(breakpointIndex, value.length - 1))\n return value.at(safeIndex)\n}\n\nexport function factor<T>(value: T | T[], breakpointIndex: number): T {\n return isValid(value) ? calcFactor<T>(value, breakpointIndex) : value as T\n}\n\nexport function calculateProps(target: Element, props: IFormLayoutProps): IFormLayoutProps {\n const { clientWidth } = target\n const {\n breakpoints,\n layout,\n labelAlign,\n wrapperAlign,\n labelCol,\n wrapperCol,\n ...otherProps\n } = props\n const breakpointIndex = calcBreakpointIndex(\n breakpoints as number[],\n clientWidth,\n )\n\n return {\n layout: factor(layout, breakpointIndex),\n labelAlign: factor(labelAlign, breakpointIndex),\n wrapperAlign: factor(wrapperAlign, breakpointIndex),\n labelCol: factor(labelCol, breakpointIndex),\n wrapperCol: factor(wrapperCol, breakpointIndex),\n ...otherProps,\n }\n}\n\nexport function useResponsiveFormLayout(props: IFormLayoutProps, root: Ref<HTMLElement | null>) {\n const { breakpoints } = props\n if (!isArr(breakpoints)) {\n return {\n props: ref(props),\n }\n }\n\n const layoutProps = ref<IFormLayoutProps>({})\n\n useResizeObserver(root, () => {\n layoutProps.value = calculateProps(root.value, props)\n })\n\n return {\n props: layoutProps,\n }\n}\n\nexport const formLayoutDeepContext: InjectionKey<Ref<IFormLayoutProps>> = Symbol(\n 'formLayoutDeepContext',\n)\n\nexport const formLayoutShallowContext: InjectionKey<Ref<IFormLayoutProps>>\n = Symbol('formLayoutShallowContext')\n\nexport const formLayoutIdContext: InjectionKey<ComputedRef<string>>\n = Symbol('formLayoutIdContext')\n\nexport function useFormDeepLayout(): Ref<IFormLayoutProps> {\n return inject(formLayoutDeepContext, ref({}))\n}\n\nexport function useFormLayout(): Ref<IFormLayoutProps> {\n const shallowLayout = inject(formLayoutShallowContext, ref({}))\n const deepLayout = inject(formLayoutDeepContext, ref({}))\n\n const formLayout = computed(() => {\n return {\n ...deepLayout.value,\n ...shallowLayout.value,\n }\n })\n\n return formLayout\n}\n\nexport function useFormLayoutId(): ComputedRef<string> {\n return inject(formLayoutIdContext)\n}\n\nexport const FORM_LAYOUT_PROPS_KEYS: ReadonlyArray<keyof IFormLayoutProps> = [\n 'colon',\n 'labelAlign',\n 'wrapperAlign',\n 'labelWrap',\n 'labelWidth',\n 'wrapperWidth',\n 'labelCol',\n 'wrapperCol',\n 'fullness',\n 'size',\n 'layout',\n 'feedbackLayout',\n 'tooltipLayout',\n 'breakpoints',\n 'hideRequiredAsterisk',\n 'statusIcon',\n 'requireAsteriskPosition',\n] as const\n\nexport function filterValidFormLayoutProps(props: IFormLayoutProps): IFormLayoutProps {\n return Object.fromEntries(\n Object.entries(props)\n .filter(([_, value]) => isValid(value)),\n )\n}\n"],"mappings":";;;;AAMA,SAAgB,oBAAoB,aAAuB,OAAuB;AAChF,MAAK,MAAM,CAAC,GAAG,eAAe,YAAY,SAAS,CACjD,KAAI,SAAS,W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,OAAO,uBAAuB,IAAI,EAAE,CAAC,CAAC;AASzD,QAPmB,eAAe;AAChC,SAAO;GACL,GAAG,WAAW;GACd,GAAG,cAAc;GAClB;GACD;;AAKJ,SAAgB,kBAAuC;AACrD,QAAO,OAAO,oBAAoB;;AAGpC,MAAa,yBAAgE;CAC3E;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,SAAgB,2BAA2B,OAA2C;AACpF,QAAO,OAAO,YACZ,OAAO,QAAQ,MAAM,CAClB,QAAQ,CAAC,GAAG,WAAW,QAAQ,MAAM,CAAC,CAC1C"}
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/form-layout/utils.ts"],"sourcesContent":["import type { ComputedRef, InjectionKey, Ref } from 'vue'\nimport type { IFormLayoutProps } from './types'\nimport { isArr, isValid } from '@silver-formily/shared'\nimport { useResizeObserver } from '@vueuse/core'\nimport { computed, inject, ref } from 'vue'\n\nexport function calcBreakpointIndex(breakpoints: number[], width: number): number {\n for (const [i, breakpoint] of breakpoints.entries()) {\n if (width <= breakpoint) {\n return i\n }\n }\n return -1\n}\n\nexport function calcFactor<T>(value: T | readonly T[], breakpointIndex: number): T {\n if (!Array.isArray(value) || value.length === 0) {\n return value as T\n }\n const safeIndex = Math.max(-1, Math.min(breakpointIndex, value.length - 1))\n return value.at(safeIndex)\n}\n\nexport function factor<T>(value: T | T[], breakpointIndex: number): T {\n return isValid(value) ? calcFactor<T>(value, breakpointIndex) : value as T\n}\n\nexport function calculateProps(target: Element, props: IFormLayoutProps): IFormLayoutProps {\n const { clientWidth } = target\n const {\n breakpoints,\n layout,\n labelAlign,\n wrapperAlign,\n labelCol,\n wrapperCol,\n ...otherProps\n } = props\n const breakpointIndex = calcBreakpointIndex(\n breakpoints as number[],\n clientWidth,\n )\n\n return {\n layout: factor(layout, breakpointIndex),\n labelAlign: factor(labelAlign, breakpointIndex),\n wrapperAlign: factor(wrapperAlign, breakpointIndex),\n labelCol: factor(labelCol, breakpointIndex),\n wrapperCol: factor(wrapperCol, breakpointIndex),\n ...otherProps,\n }\n}\n\nexport function useResponsiveFormLayout(props: IFormLayoutProps, root: Ref<HTMLElement | null>) {\n const { breakpoints } = props\n if (!isArr(breakpoints)) {\n return {\n props: ref(props),\n }\n }\n\n const layoutProps = ref<IFormLayoutProps>({})\n\n useResizeObserver(root, () => {\n layoutProps.value = calculateProps(root.value, props)\n })\n\n return {\n props: layoutProps,\n }\n}\n\nexport const formLayoutDeepContext: InjectionKey<Ref<IFormLayoutProps>> = Symbol(\n 'formLayoutDeepContext',\n)\n\nexport const formLayoutShallowContext: InjectionKey<Ref<IFormLayoutProps>>\n = Symbol('formLayoutShallowContext')\n\nexport const formLayoutIdContext: InjectionKey<ComputedRef<string>>\n = Symbol('formLayoutIdContext')\n\nexport function useFormDeepLayout(): Ref<IFormLayoutProps> {\n return inject(formLayoutDeepContext, ref({}))\n}\n\nexport function useFormLayout(): Ref<IFormLayoutProps> {\n const shallowLayout = inject(formLayoutShallowContext, ref({}))\n const deepLayout = inject(formLayoutDeepContext, ref({}))\n\n const formLayout = computed(() => {\n return {\n ...deepLayout.value,\n ...shallowLayout.value,\n }\n })\n\n return formLayout\n}\n\nexport function useFormLayoutId(): ComputedRef<string> {\n return inject(formLayoutIdContext)\n}\n\nexport const FORM_LAYOUT_PROPS_KEYS: ReadonlyArray<keyof IFormLayoutProps> = [\n 'colon',\n 'labelAlign',\n 'wrapperAlign',\n 'labelWrap',\n 'labelWidth',\n 'wrapperWidth',\n 'labelCol',\n 'wrapperCol',\n 'fullness',\n 'size',\n 'layout',\n 'feedbackLayout',\n 'tooltipLayout',\n 'breakpoints',\n 'hideRequiredAsterisk',\n 'statusIcon',\n 'requireAsteriskPosition',\n] as const\n\nexport function filterValidFormLayoutProps(props: IFormLayoutProps): IFormLayoutProps {\n return Object.fromEntries(\n Object.entries(props)\n .filter(([_, value]) => isValid(value)),\n )\n}\n"],"m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AAC,CAAC;;AAG/C,SAAgB,gBAAuC;CACrD,MAAM,gBAAgB,OAAO,0BAA0B,IAAI,EAAE,CAAC,CAAC;CAC/D,MAAM,aAAa,OAAO,uBAAuB,IAAI,EAAE,CAAC,CAAC;AASzD,QAPmB,eAAe;AAChC,SAAO;GACL,GAAG,WAAW;GACd,GAAG,cAAc;GAClB;GACD;;AAKJ,SAAgB,kBAAuC;AACrD,QAAO,OAAO,oBAAoB;;AAGpC,MAAa,yBAAgE;CAC3E;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,SAAgB,2BAA2B,OAA2C;AACpF,QAAO,OAAO,YACZ,OAAO,QAAQ,MAAM,CAClB,QAAQ,CAAC,GAAG,WAAW,QAAQ,MAAM,CAAC,CAC1C"}
|
|
@@ -4,7 +4,7 @@ import { ElStep, ElSteps } from "element-plus";
|
|
|
4
4
|
import { useObserver } from "@silver-formily/reactive-vue";
|
|
5
5
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createSlots, createTextVNode, createVNode, defineComponent, mergeProps, normalizeClass, openBlock, renderList, resolveDynamicComponent, toDisplayString, unref, withCtx } from "vue";
|
|
6
6
|
import { RecursionField, useField, useFieldSchema } from "@silver-formily/vue";
|
|
7
|
-
import { isObj } from "@formily/shared";
|
|
7
|
+
import { isObj } from "@silver-formily/shared";
|
|
8
8
|
//#region src/form-step/form-step.vue
|
|
9
9
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
10
10
|
name: "FFormStep",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-step.mjs","names":["$attrs"],"sources":["../../src/form-step/form-step.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { VoidField } from '@formily/core'\nimport type { IFormStepProps } from './types'\nimport {
|
|
1
|
+
{"version":3,"file":"form-step.mjs","names":["$attrs"],"sources":["../../src/form-step/form-step.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { VoidField } from '@silver-formily/core'\nimport type { IFormStepProps } from './types'\nimport { useObserver } from '@silver-formily/reactive-vue'\nimport { isObj } from '@silver-formily/shared'\nimport { RecursionField, useField, useFieldSchema } from '@silver-formily/vue'\nimport { ElStep, ElSteps } from 'element-plus'\nimport { computed } from 'vue'\nimport { stylePrefix } from '../__builtins__'\nimport { createFormStep, parseSteps } from './utils'\n\ndefineOptions({\n name: 'FFormStep',\n inheritAttrs: false,\n})\n\nconst props = withDefaults(defineProps<IFormStepProps>(), {\n formStep: () => createFormStep(),\n})\n\nuseObserver()\n\nconst field = useField<VoidField>().value\nconst prefixCls = `${stylePrefix}-form-step`\nconst fieldSchemaRef = useFieldSchema()\n\nconst steps = parseSteps(fieldSchemaRef.value)\n\nprops.formStep.connect?.(steps, field)\n\nconst current = computed(() => props.active ?? props.formStep?.current ?? 0)\n</script>\n\n<template>\n <div :class=\"prefixCls\">\n <ElSteps\n v-bind=\"$attrs\"\n :active=\"current\"\n :style=\"[{ marginBottom: '10px' }]\"\n >\n <ElStep\n v-for=\"({ props: stepProps, slots: stepSlots }, key) of steps\"\n :key=\"key\"\n v-bind=\"stepProps\"\n >\n <template v-if=\"stepSlots?.title\" #title>\n <template v-if=\"isObj(stepSlots.title)\">\n <component :is=\"stepSlots.title\" />\n </template>\n <template v-else>\n {{ stepSlots.title }}\n </template>\n </template>\n <template v-if=\"stepSlots?.icon\" #icon>\n <template v-if=\"isObj(stepSlots.icon)\">\n <component :is=\"stepSlots.icon\" />\n </template>\n <template v-else>\n {{ stepSlots.icon }}\n </template>\n </template>\n <template v-if=\"stepSlots?.description\" #description>\n <template v-if=\"isObj(stepSlots.description)\">\n <component :is=\"stepSlots.description\" />\n </template>\n <template v-else>\n {{ stepSlots.description }}\n </template>\n </template>\n </ElStep>\n </ElSteps>\n\n <template v-for=\"({ name, schema }, key) of steps\" :key=\"name\">\n <RecursionField\n v-if=\"key === current\"\n :name=\"name\"\n :schema=\"schema\"\n />\n </template>\n </div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,EAAA,CAAA;;;MAGL,WAAW,cAAA;aAAc;yBAG5B,CAFK,MAAA,MAAK,CAAC,UAAU,YAAW,IAAA,WAAA,EACzC,YAAyC,wBAAzB,UAAU,YAAW,EAAA,EAAA,KAAA,GAAA,CAAA,KAAA,WAAA,EAEvC,mBAEW,UAAA,EAAA,KAAA,GAAA,EAAA,CAAA,gBAAA,gBADN,UAAU,YAAW,EAAA,EAAA,CAAA,EAAA,GAAA,EAAA,CAAA;;;;;;yCAMhC,mBAMW,UAAA,MAAA,WANiC,MAAA,MAAK,GAAA,EAA7B,MAAM,UAAU,QAAG;4DAAkB,MAAI,EAAA,CAEnD,QAAQ,QAAA,SAAA,WAAA,EADhB,YAIE,MAAA,eAAA,EAAA;;KAFO;KACE"}
|
package/esm/form-step/types.d.ts
CHANGED
package/esm/form-step/utils.d.ts
CHANGED
package/esm/form-step/utils.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/form-step/utils.ts"],"sourcesContent":["import type { Schema, SchemaKey } from '@formily/json-schema'\nimport type { Slots } from 'vue'\nimport type { FormStepEnv, IFormStep } from './types'\nimport { action, model, observable } from '@formily/reactive'\n\nexport interface SchemaStep {\n name: SchemaKey\n props: any\n schema: Schema\n slots: Slots\n}\n\nexport function createFormStep(defaultCurrent = 0): IFormStep {\n const env: FormStepEnv = observable({\n form: null,\n field: null,\n steps: [],\n })\n\n const setDisplay = action.bound((target: number) => {\n const currentStep = env.steps[target]\n for (const { name } of env.steps) {\n env.form.query(`${env.field.address}.${name}`).take((field) => {\n if (name === currentStep.name) {\n field.setDisplay('visible')\n }\n else {\n field.setDisplay('hidden')\n }\n })\n }\n })\n\n const formStep: IFormStep = model({\n connect(steps, field) {\n env.steps = steps\n env.form = field?.form\n env.field = field\n },\n current: defaultCurrent,\n setCurrent(key: number) {\n formStep.current = key\n },\n get allowNext() {\n return formStep.current < env.steps.length - 1\n },\n get allowBack() {\n return formStep.current > 0\n },\n async next() {\n try {\n await env.form.validate()\n // eslint-disable-next-line ts/no-use-before-define\n next()\n }\n catch {}\n },\n async back() {\n // eslint-disable-next-line ts/no-use-before-define\n back()\n },\n async submit(onSubmit) {\n return env.form?.submit?.(onSubmit)\n },\n })\n\n const next = action.bound(() => {\n /* istanbul ignore else -- @preserve */\n if (formStep.allowNext) {\n setDisplay(formStep.current + 1)\n formStep.setCurrent(formStep.current + 1)\n }\n })\n\n const back = action.bound(() => {\n /* istanbul ignore else -- @preserve */\n if (formStep.allowBack) {\n setDisplay(formStep.current - 1)\n formStep.setCurrent(formStep.current - 1)\n }\n })\n return formStep\n}\n\nexport function parseSteps(schema: Schema) {\n const steps: SchemaStep[] = []\n schema.mapProperties((schema, name) => {\n /* istanbul ignore else -- @preserve */\n if (schema['x-component']?.indexOf('StepPane') > -1) {\n steps.push({\n name,\n props: schema['x-component-props'],\n schema,\n slots: schema['x-content'],\n })\n }\n })\n return steps\n}\n"],"mappings":";;AAYA,SAAgB,eAAe,iBAAiB,GAAc;CAC5D,MAAM,MAAmB,WAAW;EAClC,MAAM;EACN,OAAO;EACP,OAAO,EAAE;EACV,CAAC;CAEF,MAAM,aAAa,OAAO,OAAO,WAAmB;EAClD,MAAM,cAAc,IAAI,MAAM;AAC9B,OAAK,MAAM,EAAE,UAAU,IAAI,MACzB,KAAI,KAAK,MAAM,GAAG,IAAI,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,UAAU;AAC7D,OAAI,SAAS,YAAY,KACvB,OAAM,WAAW,UAAU;OAG3B,OAAM,WAAW,SAAS;IAE5B;GAEJ;CAEF,MAAM,WAAsB,MAAM;EAChC,QAAQ,OAAO,OAAO;AACpB,OAAI,QAAQ;AACZ,OAAI,OAAO,OAAO;AAClB,OAAI,QAAQ;;EAEd,SAAS;EACT,WAAW,KAAa;AACtB,YAAS,UAAU;;EAErB,IAAI,YAAY;AACd,UAAO,SAAS,UAAU,IAAI,MAAM,SAAS;;EAE/C,IAAI,YAAY;AACd,UAAO,SAAS,UAAU;;EAE5B,MAAM,OAAO;AACX,OAAI;AACF,UAAM,IAAI,KAAK,UAAU;AAEzB,UAAM;WAEF;;EAER,MAAM,OAAO;AAEX,SAAM;;EAER,MAAM,OAAO,UAAU;AACrB,UAAO,IAAI,MAAM,SAAS,SAAS;;EAEtC,CAAC;CAEF,MAAM,OAAO,OAAO,YAAY;;AAE9B,MAAI,SAAS,WAAW;AACtB,cAAW,SAAS,UAAU,EAAE;AAChC,YAAS,WAAW,SAAS,UAAU,EAAE;;GAE3C;CAEF,MAAM,OAAO,OAAO,YAAY;;AAE9B,MAAI,SAAS,WAAW;AACtB,cAAW,SAAS,UAAU,EAAE;AAChC,YAAS,WAAW,SAAS,UAAU,EAAE;;GAE3C;AACF,QAAO;;AAGT,SAAgB,WAAW,QAAgB;CACzC,MAAM,QAAsB,EAAE;AAC9B,QAAO,eAAe,QAAQ,SAAS;;AAErC,MAAI,OAAO,gBAAgB,QAAQ,WAAW,GAAG,GAC/C,OAAM,KAAK;GACT;GACA,OAAO,OAAO;GACd;GACA,OAAO,OAAO;GACf,CAAC;GAEJ;AACF,QAAO"}
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/form-step/utils.ts"],"sourcesContent":["import type { Schema, SchemaKey } from '@silver-formily/json-schema'\nimport type { Slots } from 'vue'\nimport type { FormStepEnv, IFormStep } from './types'\nimport { action, model, observable } from '@silver-formily/reactive'\n\nexport interface SchemaStep {\n name: SchemaKey\n props: any\n schema: Schema\n slots: Slots\n}\n\nexport function createFormStep(defaultCurrent = 0): IFormStep {\n const env: FormStepEnv = observable({\n form: null,\n field: null,\n steps: [],\n })\n\n const setDisplay = action.bound((target: number) => {\n const currentStep = env.steps[target]\n for (const { name } of env.steps) {\n env.form.query(`${env.field.address}.${name}`).take((field) => {\n if (name === currentStep.name) {\n field.setDisplay('visible')\n }\n else {\n field.setDisplay('hidden')\n }\n })\n }\n })\n\n const formStep: IFormStep = model({\n connect(steps, field) {\n env.steps = steps\n env.form = field?.form\n env.field = field\n },\n current: defaultCurrent,\n setCurrent(key: number) {\n formStep.current = key\n },\n get allowNext() {\n return formStep.current < env.steps.length - 1\n },\n get allowBack() {\n return formStep.current > 0\n },\n async next() {\n try {\n await env.form.validate()\n // eslint-disable-next-line ts/no-use-before-define\n next()\n }\n catch {}\n },\n async back() {\n // eslint-disable-next-line ts/no-use-before-define\n back()\n },\n async submit(onSubmit) {\n return env.form?.submit?.(onSubmit)\n },\n })\n\n const next = action.bound(() => {\n /* istanbul ignore else -- @preserve */\n if (formStep.allowNext) {\n setDisplay(formStep.current + 1)\n formStep.setCurrent(formStep.current + 1)\n }\n })\n\n const back = action.bound(() => {\n /* istanbul ignore else -- @preserve */\n if (formStep.allowBack) {\n setDisplay(formStep.current - 1)\n formStep.setCurrent(formStep.current - 1)\n }\n })\n return formStep\n}\n\nexport function parseSteps(schema: Schema) {\n const steps: SchemaStep[] = []\n schema.mapProperties((schema, name) => {\n /* istanbul ignore else -- @preserve */\n if (schema['x-component']?.indexOf('StepPane') > -1) {\n steps.push({\n name,\n props: schema['x-component-props'],\n schema,\n slots: schema['x-content'],\n })\n }\n })\n return steps\n}\n"],"mappings":";;AAYA,SAAgB,eAAe,iBAAiB,GAAc;CAC5D,MAAM,MAAmB,WAAW;EAClC,MAAM;EACN,OAAO;EACP,OAAO,EAAE;EACV,CAAC;CAEF,MAAM,aAAa,OAAO,OAAO,WAAmB;EAClD,MAAM,cAAc,IAAI,MAAM;AAC9B,OAAK,MAAM,EAAE,UAAU,IAAI,MACzB,KAAI,KAAK,MAAM,GAAG,IAAI,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,UAAU;AAC7D,OAAI,SAAS,YAAY,KACvB,OAAM,WAAW,UAAU;OAG3B,OAAM,WAAW,SAAS;IAE5B;GAEJ;CAEF,MAAM,WAAsB,MAAM;EAChC,QAAQ,OAAO,OAAO;AACpB,OAAI,QAAQ;AACZ,OAAI,OAAO,OAAO;AAClB,OAAI,QAAQ;;EAEd,SAAS;EACT,WAAW,KAAa;AACtB,YAAS,UAAU;;EAErB,IAAI,YAAY;AACd,UAAO,SAAS,UAAU,IAAI,MAAM,SAAS;;EAE/C,IAAI,YAAY;AACd,UAAO,SAAS,UAAU;;EAE5B,MAAM,OAAO;AACX,OAAI;AACF,UAAM,IAAI,KAAK,UAAU;AAEzB,UAAM;WAEF;;EAER,MAAM,OAAO;AAEX,SAAM;;EAER,MAAM,OAAO,UAAU;AACrB,UAAO,IAAI,MAAM,SAAS,SAAS;;EAEtC,CAAC;CAEF,MAAM,OAAO,OAAO,YAAY;;AAE9B,MAAI,SAAS,WAAW;AACtB,cAAW,SAAS,UAAU,EAAE;AAChC,YAAS,WAAW,SAAS,UAAU,EAAE;;GAE3C;CAEF,MAAM,OAAO,OAAO,YAAY;;AAE9B,MAAI,SAAS,WAAW;AACtB,cAAW,SAAS,UAAU,EAAE;AAChC,YAAS,WAAW,SAAS,UAAU,EAAE;;GAE3C;AACF,QAAO;;AAGT,SAAgB,WAAW,QAAgB;CACzC,MAAM,QAAsB,EAAE;AAC9B,QAAO,eAAe,QAAQ,SAAS;;AAErC,MAAI,OAAO,gBAAgB,QAAQ,WAAW,GAAG,GAC/C,OAAM,KAAK;GACT;GACA,OAAO,OAAO;GACd;GACA,OAAO,OAAO;GACf,CAAC;GAEJ;AACF,QAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.mjs","names":[],"sources":["../../src/form-tab/hooks.ts"],"sourcesContent":["import type { GeneralField } from '@formily/core'\nimport type { Schema, SchemaKey } from '@formily/json-schema'\n\nexport type Tabs = { name: SchemaKey, props: any, schema: Schema }[]\n\nexport function useTabs(tabField: GeneralField, schema: Schema) {\n const schemaList = schema.mapProperties((item, name) => ({\n name,\n props: {\n name: item?.['x-component-props']?.name || name,\n ...item?.['x-component-props'],\n },\n schema: item,\n }))\n\n const tabs: Tabs = schemaList.filter((item) => {\n const field = tabField.query(tabField.address.concat(item.name)).take()\n const isHidden = field?.display === 'none' || field?.display === 'hidden'\n if (isHidden)\n return false\n return item?.schema?.['x-component']?.includes('TabPane') ?? false\n })\n\n return tabs\n}\n"],"mappings":";AAKA,SAAgB,QAAQ,UAAwB,QAAgB;AAkB9D,QAjBmB,OAAO,eAAe,MAAM,UAAU;EACvD;EACA,OAAO;GACL,MAAM,OAAO,sBAAsB,QAAQ;GAC3C,GAAG,OAAO;GACX;EACD,QAAQ;EACT,EAAE,CAE2B,QAAQ,SAAS;EAC7C,MAAM,QAAQ,SAAS,MAAM,SAAS,QAAQ,OAAO,KAAK,KAAK,CAAC,CAAC,MAAM;AAEvE,MADiB,OAAO,YAAY,UAAU,OAAO,YAAY,SAE/D,QAAO;AACT,SAAO,MAAM,SAAS,gBAAgB,SAAS,UAAU,IAAI;GAC7D"}
|
|
1
|
+
{"version":3,"file":"hooks.mjs","names":[],"sources":["../../src/form-tab/hooks.ts"],"sourcesContent":["import type { GeneralField } from '@silver-formily/core'\nimport type { Schema, SchemaKey } from '@silver-formily/json-schema'\n\nexport type Tabs = { name: SchemaKey, props: any, schema: Schema }[]\n\nexport function useTabs(tabField: GeneralField, schema: Schema) {\n const schemaList = schema.mapProperties((item, name) => ({\n name,\n props: {\n name: item?.['x-component-props']?.name || name,\n ...item?.['x-component-props'],\n },\n schema: item,\n }))\n\n const tabs: Tabs = schemaList.filter((item) => {\n const field = tabField.query(tabField.address.concat(item.name)).take()\n const isHidden = field?.display === 'none' || field?.display === 'hidden'\n if (isHidden)\n return false\n return item?.schema?.['x-component']?.includes('TabPane') ?? false\n })\n\n return tabs\n}\n"],"mappings":";AAKA,SAAgB,QAAQ,UAAwB,QAAgB;AAkB9D,QAjBmB,OAAO,eAAe,MAAM,UAAU;EACvD;EACA,OAAO;GACL,MAAM,OAAO,sBAAsB,QAAQ;GAC3C,GAAG,OAAO;GACX;EACD,QAAQ;EACT,EAAE,CAE2B,QAAQ,SAAS;EAC7C,MAAM,QAAQ,SAAS,MAAM,SAAS,QAAQ,OAAO,KAAK,KAAK,CAAC,CAAC,MAAM;AAEvE,MADiB,OAAO,YAAY,UAAU,OAAO,YAAY,SAE/D,QAAO;AACT,SAAO,MAAM,SAAS,gBAAgB,SAAS,UAAU,IAAI;GAC7D"}
|
package/esm/form-tab/utils.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/form-tab/utils.ts"],"sourcesContent":["import { model } from '@formily/reactive'\n\nexport function createFormTab(defaultActiveKey?: string) {\n const formTab = model({\n activeKey: defaultActiveKey,\n setActiveKey(key: string) {\n formTab.activeKey = key\n },\n })\n return formTab\n}\n"],"mappings":";;AAEA,SAAgB,cAAc,kBAA2B;CACvD,MAAM,UAAU,MAAM;EACpB,WAAW;EACX,aAAa,KAAa;AACxB,WAAQ,YAAY;;EAEvB,CAAC;AACF,QAAO"}
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/form-tab/utils.ts"],"sourcesContent":["import { model } from '@silver-formily/reactive'\n\nexport function createFormTab(defaultActiveKey?: string) {\n const formTab = model({\n activeKey: defaultActiveKey,\n setActiveKey(key: string) {\n formTab.activeKey = key\n },\n })\n return formTab\n}\n"],"mappings":";;AAEA,SAAgB,cAAc,kBAA2B;CACvD,MAAM,UAAU,MAAM;EACpB,WAAW;EACX,aAAa,KAAa;AACxB,WAAQ,YAAY;;EAEvB,CAAC;AACF,QAAO"}
|
|
@@ -6,18 +6,22 @@ import * as _$element_plus_es_utils_index_mjs0 from "element-plus/es/utils/index
|
|
|
6
6
|
type InputNumberProps = typeof ElInputNumber;
|
|
7
7
|
declare const InputNumber: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
8
8
|
new (...args: any[]): _$vue.CreateComponentPublicInstanceWithMixins<Readonly<_$vue.ExtractPropTypes<{
|
|
9
|
-
modelValue: {
|
|
10
|
-
type: _$vue.PropType<number>;
|
|
11
|
-
};
|
|
12
9
|
name: {
|
|
13
10
|
type: _$vue.PropType<string>;
|
|
14
11
|
};
|
|
12
|
+
size: {
|
|
13
|
+
type: _$vue.PropType<"" | "default" | "small" | "large">;
|
|
14
|
+
};
|
|
15
|
+
readonly: {
|
|
16
|
+
type: _$vue.PropType<boolean>;
|
|
17
|
+
default: boolean;
|
|
18
|
+
};
|
|
15
19
|
disabled: {
|
|
16
20
|
type: _$vue.PropType<boolean>;
|
|
17
21
|
default: undefined;
|
|
18
22
|
};
|
|
19
|
-
|
|
20
|
-
type: _$vue.PropType<
|
|
23
|
+
modelValue: {
|
|
24
|
+
type: _$vue.PropType<number>;
|
|
21
25
|
};
|
|
22
26
|
placeholder: {
|
|
23
27
|
type: _$vue.PropType<string>;
|
|
@@ -30,10 +34,6 @@ declare const InputNumber: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
30
34
|
type: _$vue.PropType<number | "min" | "max">;
|
|
31
35
|
default: null;
|
|
32
36
|
};
|
|
33
|
-
readonly: {
|
|
34
|
-
type: _$vue.PropType<boolean>;
|
|
35
|
-
default: boolean;
|
|
36
|
-
};
|
|
37
37
|
ariaLabel: {
|
|
38
38
|
type: _$vue.PropType<string>;
|
|
39
39
|
};
|
|
@@ -41,10 +41,6 @@ declare const InputNumber: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
41
41
|
type: _$vue.PropType<string>;
|
|
42
42
|
default: undefined;
|
|
43
43
|
};
|
|
44
|
-
inputmode: {
|
|
45
|
-
type: _$vue.PropType<"search" | "text" | "email" | "tel" | "url" | "none" | "numeric" | "decimal">;
|
|
46
|
-
default: undefined;
|
|
47
|
-
};
|
|
48
44
|
min: {
|
|
49
45
|
type: _$vue.PropType<number>;
|
|
50
46
|
default: number;
|
|
@@ -53,6 +49,10 @@ declare const InputNumber: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
53
49
|
type: _$vue.PropType<number>;
|
|
54
50
|
default: number;
|
|
55
51
|
};
|
|
52
|
+
inputmode: {
|
|
53
|
+
type: _$vue.PropType<"search" | "text" | "email" | "tel" | "url" | "none" | "numeric" | "decimal">;
|
|
54
|
+
default: undefined;
|
|
55
|
+
};
|
|
56
56
|
align: {
|
|
57
57
|
type: _$vue.PropType<"right" | "left" | "center">;
|
|
58
58
|
default: string;
|
|
@@ -116,18 +116,22 @@ declare const InputNumber: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
116
116
|
M: {};
|
|
117
117
|
Defaults: {};
|
|
118
118
|
}, Readonly<_$vue.ExtractPropTypes<{
|
|
119
|
-
modelValue: {
|
|
120
|
-
type: _$vue.PropType<number>;
|
|
121
|
-
};
|
|
122
119
|
name: {
|
|
123
120
|
type: _$vue.PropType<string>;
|
|
124
121
|
};
|
|
122
|
+
size: {
|
|
123
|
+
type: _$vue.PropType<"" | "default" | "small" | "large">;
|
|
124
|
+
};
|
|
125
|
+
readonly: {
|
|
126
|
+
type: _$vue.PropType<boolean>;
|
|
127
|
+
default: boolean;
|
|
128
|
+
};
|
|
125
129
|
disabled: {
|
|
126
130
|
type: _$vue.PropType<boolean>;
|
|
127
131
|
default: undefined;
|
|
128
132
|
};
|
|
129
|
-
|
|
130
|
-
type: _$vue.PropType<
|
|
133
|
+
modelValue: {
|
|
134
|
+
type: _$vue.PropType<number>;
|
|
131
135
|
};
|
|
132
136
|
placeholder: {
|
|
133
137
|
type: _$vue.PropType<string>;
|
|
@@ -140,10 +144,6 @@ declare const InputNumber: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
140
144
|
type: _$vue.PropType<number | "min" | "max">;
|
|
141
145
|
default: null;
|
|
142
146
|
};
|
|
143
|
-
readonly: {
|
|
144
|
-
type: _$vue.PropType<boolean>;
|
|
145
|
-
default: boolean;
|
|
146
|
-
};
|
|
147
147
|
ariaLabel: {
|
|
148
148
|
type: _$vue.PropType<string>;
|
|
149
149
|
};
|
|
@@ -151,10 +151,6 @@ declare const InputNumber: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
151
151
|
type: _$vue.PropType<string>;
|
|
152
152
|
default: undefined;
|
|
153
153
|
};
|
|
154
|
-
inputmode: {
|
|
155
|
-
type: _$vue.PropType<"search" | "text" | "email" | "tel" | "url" | "none" | "numeric" | "decimal">;
|
|
156
|
-
default: undefined;
|
|
157
|
-
};
|
|
158
154
|
min: {
|
|
159
155
|
type: _$vue.PropType<number>;
|
|
160
156
|
default: number;
|
|
@@ -163,6 +159,10 @@ declare const InputNumber: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
163
159
|
type: _$vue.PropType<number>;
|
|
164
160
|
default: number;
|
|
165
161
|
};
|
|
162
|
+
inputmode: {
|
|
163
|
+
type: _$vue.PropType<"search" | "text" | "email" | "tel" | "url" | "none" | "numeric" | "decimal">;
|
|
164
|
+
default: undefined;
|
|
165
|
+
};
|
|
166
166
|
align: {
|
|
167
167
|
type: _$vue.PropType<"right" | "left" | "center">;
|
|
168
168
|
default: string;
|
|
@@ -217,18 +217,22 @@ declare const InputNumber: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
217
217
|
__isTeleport?: never;
|
|
218
218
|
__isSuspense?: never;
|
|
219
219
|
} & _$vue.ComponentOptionsBase<Readonly<_$vue.ExtractPropTypes<{
|
|
220
|
-
modelValue: {
|
|
221
|
-
type: _$vue.PropType<number>;
|
|
222
|
-
};
|
|
223
220
|
name: {
|
|
224
221
|
type: _$vue.PropType<string>;
|
|
225
222
|
};
|
|
223
|
+
size: {
|
|
224
|
+
type: _$vue.PropType<"" | "default" | "small" | "large">;
|
|
225
|
+
};
|
|
226
|
+
readonly: {
|
|
227
|
+
type: _$vue.PropType<boolean>;
|
|
228
|
+
default: boolean;
|
|
229
|
+
};
|
|
226
230
|
disabled: {
|
|
227
231
|
type: _$vue.PropType<boolean>;
|
|
228
232
|
default: undefined;
|
|
229
233
|
};
|
|
230
|
-
|
|
231
|
-
type: _$vue.PropType<
|
|
234
|
+
modelValue: {
|
|
235
|
+
type: _$vue.PropType<number>;
|
|
232
236
|
};
|
|
233
237
|
placeholder: {
|
|
234
238
|
type: _$vue.PropType<string>;
|
|
@@ -241,10 +245,6 @@ declare const InputNumber: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
241
245
|
type: _$vue.PropType<number | "min" | "max">;
|
|
242
246
|
default: null;
|
|
243
247
|
};
|
|
244
|
-
readonly: {
|
|
245
|
-
type: _$vue.PropType<boolean>;
|
|
246
|
-
default: boolean;
|
|
247
|
-
};
|
|
248
248
|
ariaLabel: {
|
|
249
249
|
type: _$vue.PropType<string>;
|
|
250
250
|
};
|
|
@@ -252,10 +252,6 @@ declare const InputNumber: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
252
252
|
type: _$vue.PropType<string>;
|
|
253
253
|
default: undefined;
|
|
254
254
|
};
|
|
255
|
-
inputmode: {
|
|
256
|
-
type: _$vue.PropType<"search" | "text" | "email" | "tel" | "url" | "none" | "numeric" | "decimal">;
|
|
257
|
-
default: undefined;
|
|
258
|
-
};
|
|
259
255
|
min: {
|
|
260
256
|
type: _$vue.PropType<number>;
|
|
261
257
|
default: number;
|
|
@@ -264,6 +260,10 @@ declare const InputNumber: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
264
260
|
type: _$vue.PropType<number>;
|
|
265
261
|
default: number;
|
|
266
262
|
};
|
|
263
|
+
inputmode: {
|
|
264
|
+
type: _$vue.PropType<"search" | "text" | "email" | "tel" | "url" | "none" | "numeric" | "decimal">;
|
|
265
|
+
default: undefined;
|
|
266
|
+
};
|
|
267
267
|
align: {
|
|
268
268
|
type: _$vue.PropType<"right" | "left" | "center">;
|
|
269
269
|
default: string;
|
package/esm/input-tag/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as _$vue from "vue";
|
|
2
|
-
import * as _$_formily_core0 from "@formily/core";
|
|
3
2
|
|
|
4
3
|
//#region src/input-tag/index.d.ts
|
|
5
4
|
declare const InputTag: {
|
|
@@ -19,7 +18,7 @@ declare const InputTag: {
|
|
|
19
18
|
tag?: (scope: {
|
|
20
19
|
value: string;
|
|
21
20
|
index: number;
|
|
22
|
-
field:
|
|
21
|
+
field: Field | undefined;
|
|
23
22
|
}) => any;
|
|
24
23
|
prefix?: () => any;
|
|
25
24
|
suffix?: () => any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-tag.mjs","names":[],"sources":["../../src/input-tag/input-tag.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { Field } from '@formily/core'\nimport { useField } from '@silver-formily/vue'\nimport { ElInputTag } from 'element-plus'\nimport { useCleanAttrs } from '../__builtins__'\n\ndefineOptions({\n name: 'FInputTag',\n inheritAttrs: false,\n})\n\nconst slots = defineSlots<{\n tag?: (scope: { value: string, index: number, field: Field | undefined }) => any\n prefix?: () => any\n suffix?: () => any\n}>()\n\nconst { props: inputTagProps } = useCleanAttrs()\nconst fieldRef = useField<Field>()\n</script>\n\n<template>\n <ElInputTag v-bind=\"inputTagProps\">\n <template v-if=\"slots.tag\" #tag=\"slotProps\">\n <slot name=\"tag\" v-bind=\"{ ...slotProps, field: fieldRef }\" />\n </template>\n <template v-if=\"slots.prefix\" #prefix>\n <slot name=\"prefix\" />\n </template>\n <template v-if=\"slots.suffix\" #suffix>\n <slot name=\"suffix\" />\n </template>\n </ElInputTag>\n</template>\n"],"mappings":";;;;;;;;;;EAWA,MAAM,QAAQ,UAAA;EAMd,MAAM,EAAE,OAAO,kBAAkB,eAAc;EAC/C,MAAM,WAAW,UAAgB;;uBAI/B,YAUa,MAAA,WAAA,EAAA,eAAA,mBAVO,MAAA,cAAa,CAAA,CAAA,EAAA,YAAA,EAAA,GAAA,GAAA,EAAA;IACf,MAAM,MAAA;WAAM;kBAAK,cAAS,CACxC,WAA8D,KAAA,QAAA,OAAA,eAAA,mBAAA;MAAA,GAAhC;MAAS,OAAS,MAAA,SAAQ;MAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;;IAE1C,MAAM,SAAA;WAAS;uBACP,CAAtB,WAAsB,KAAA,QAAA,SAAA,CAAA,CAAA;;;IAER,MAAM,SAAA;WAAS;uBACP,CAAtB,WAAsB,KAAA,QAAA,SAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"input-tag.mjs","names":[],"sources":["../../src/input-tag/input-tag.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { Field } from '@silver-formily/core'\nimport { useField } from '@silver-formily/vue'\nimport { ElInputTag } from 'element-plus'\nimport { useCleanAttrs } from '../__builtins__'\n\ndefineOptions({\n name: 'FInputTag',\n inheritAttrs: false,\n})\n\nconst slots = defineSlots<{\n tag?: (scope: { value: string, index: number, field: Field | undefined }) => any\n prefix?: () => any\n suffix?: () => any\n}>()\n\nconst { props: inputTagProps } = useCleanAttrs()\nconst fieldRef = useField<Field>()\n</script>\n\n<template>\n <ElInputTag v-bind=\"inputTagProps\">\n <template v-if=\"slots.tag\" #tag=\"slotProps\">\n <slot name=\"tag\" v-bind=\"{ ...slotProps, field: fieldRef }\" />\n </template>\n <template v-if=\"slots.prefix\" #prefix>\n <slot name=\"prefix\" />\n </template>\n <template v-if=\"slots.suffix\" #suffix>\n <slot name=\"suffix\" />\n </template>\n </ElInputTag>\n</template>\n"],"mappings":";;;;;;;;;;EAWA,MAAM,QAAQ,UAAA;EAMd,MAAM,EAAE,OAAO,kBAAkB,eAAc;EAC/C,MAAM,WAAW,UAAgB;;uBAI/B,YAUa,MAAA,WAAA,EAAA,eAAA,mBAVO,MAAA,cAAa,CAAA,CAAA,EAAA,YAAA,EAAA,GAAA,GAAA,EAAA;IACf,MAAM,MAAA;WAAM;kBAAK,cAAS,CACxC,WAA8D,KAAA,QAAA,OAAA,eAAA,mBAAA;MAAA,GAAhC;MAAS,OAAS,MAAA,SAAQ;MAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;;IAE1C,MAAM,SAAA;WAAS;uBACP,CAAtB,WAAsB,KAAA,QAAA,SAAA,CAAA,CAAA;;;IAER,MAAM,SAAA;WAAS;uBACP,CAAtB,WAAsB,KAAA,QAAA,SAAA,CAAA,CAAA"}
|
package/esm/mention/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as _$element_plus0 from "element-plus";
|
|
2
2
|
import * as _$vue from "vue";
|
|
3
|
-
import * as _$_formily_core0 from "@formily/core";
|
|
4
3
|
|
|
5
4
|
//#region src/mention/index.d.ts
|
|
6
5
|
declare const Mention: {
|
|
@@ -20,13 +19,13 @@ declare const Mention: {
|
|
|
20
19
|
label?: (scope: {
|
|
21
20
|
item: _$element_plus0.MentionOption;
|
|
22
21
|
index: number;
|
|
23
|
-
field:
|
|
22
|
+
field: Field | undefined;
|
|
24
23
|
}) => any;
|
|
25
24
|
header?: (scope: {
|
|
26
|
-
field:
|
|
25
|
+
field: Field | undefined;
|
|
27
26
|
}) => any;
|
|
28
27
|
footer?: (scope: {
|
|
29
|
-
field:
|
|
28
|
+
field: Field | undefined;
|
|
30
29
|
}) => any;
|
|
31
30
|
loading?: () => any;
|
|
32
31
|
prefix?: () => any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mention.mjs","names":[],"sources":["../../src/mention/mention.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { Field } from '@formily/core'\nimport type { MentionOption } from 'element-plus/es/components/mention'\nimport { useField } from '@silver-formily/vue'\nimport { ElMention } from 'element-plus'\nimport { computed } from 'vue'\nimport { useCleanAttrs } from '../__builtins__'\n\ndefineOptions({\n name: 'FMention',\n inheritAttrs: false,\n})\n\nconst slots = defineSlots<{\n label?: (scope: { item: MentionOption, index: number, field: Field | undefined }) => any\n header?: (scope: { field: Field | undefined }) => any\n footer?: (scope: { field: Field | undefined }) => any\n loading?: () => any\n prefix?: () => any\n suffix?: () => any\n prepend?: () => any\n append?: () => any\n}>()\n\nconst { props: rawMentionProps } = useCleanAttrs()\nconst fieldRef = useField<Field>()\n\nconst mentionProps = computed(() => {\n const props = rawMentionProps.value\n const { onSearch } = props\n if (!onSearch) {\n return props\n }\n\n return {\n ...props,\n onSearch(pattern: string, prefix: string) {\n return (onSearch as (pattern: string, prefix: string, field?: Field) => any)(\n pattern,\n prefix,\n fieldRef.value,\n )\n },\n }\n})\n</script>\n\n<template>\n <ElMention v-bind=\"mentionProps\">\n <template v-if=\"slots.prefix\" #prefix>\n <slot name=\"prefix\" />\n </template>\n <template v-if=\"slots.suffix\" #suffix>\n <slot name=\"suffix\" />\n </template>\n <template v-if=\"slots.prepend\" #prepend>\n <slot name=\"prepend\" />\n </template>\n <template v-if=\"slots.append\" #append>\n <slot name=\"append\" />\n </template>\n <template v-if=\"slots.header\" #header>\n <slot name=\"header\" :field=\"fieldRef\" />\n </template>\n <template v-if=\"slots.footer\" #footer>\n <slot name=\"footer\" :field=\"fieldRef\" />\n </template>\n <template v-if=\"slots.label\" #label=\"slotProps\">\n <slot name=\"label\" v-bind=\"{ ...slotProps, field: fieldRef }\" />\n </template>\n <template v-if=\"slots.loading\" #loading>\n <slot name=\"loading\" />\n </template>\n </ElMention>\n</template>\n"],"mappings":";;;;;;;;;;EAaA,MAAM,QAAQ,UAAA;EAWd,MAAM,EAAE,OAAO,oBAAoB,eAAc;EACjD,MAAM,WAAW,UAAgB;EAEjC,MAAM,eAAe,eAAe;GAClC,MAAM,QAAQ,gBAAgB;GAC9B,MAAM,EAAE,aAAa;AACrB,OAAI,CAAC,SACH,QAAO;AAGT,UAAO;IACL,GAAG;IACH,SAAS,SAAiB,QAAgB;AACxC,YAAQ,SACN,SACA,QACA,SAAS,MACX;;IAEJ;IACD;;uBAIC,YAyBY,MAAA,UAAA,EAAA,eAAA,mBAzBO,aAAA,MAAY,CAAA,EAAA,YAAA,EAAA,GAAA,GAAA,EAAA;IACb,MAAM,SAAA;WAAS;uBACP,CAAtB,WAAsB,KAAA,QAAA,SAAA,CAAA,CAAA;;;IAER,MAAM,SAAA;WAAS;uBACP,CAAtB,WAAsB,KAAA,QAAA,SAAA,CAAA,CAAA;;;IAER,MAAM,UAAA;WAAU;uBACP,CAAvB,WAAuB,KAAA,QAAA,UAAA,CAAA,CAAA;;;IAET,MAAM,SAAA;WAAS;uBACP,CAAtB,WAAsB,KAAA,QAAA,SAAA,CAAA,CAAA;;;IAER,MAAM,SAAA;WAAS;uBACW,CAAxC,WAAwC,KAAA,QAAA,UAAA,EAAnB,OAAO,MAAA,SAAQ,EAAA,CAAA,CAAA,CAAA;;;IAEtB,MAAM,SAAA;WAAS;uBACW,CAAxC,WAAwC,KAAA,QAAA,UAAA,EAAnB,OAAO,MAAA,SAAQ,EAAA,CAAA,CAAA,CAAA;;;IAEtB,MAAM,QAAA;WAAQ;kBAAO,cAAS,CAC5C,WAAgE,KAAA,QAAA,SAAA,eAAA,mBAAA;MAAA,GAAhC;MAAS,OAAS,MAAA,SAAQ;MAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;;IAE5C,MAAM,UAAA;WAAU;uBACP,CAAvB,WAAuB,KAAA,QAAA,UAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"mention.mjs","names":[],"sources":["../../src/mention/mention.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { Field } from '@silver-formily/core'\nimport type { MentionOption } from 'element-plus/es/components/mention'\nimport { useField } from '@silver-formily/vue'\nimport { ElMention } from 'element-plus'\nimport { computed } from 'vue'\nimport { useCleanAttrs } from '../__builtins__'\n\ndefineOptions({\n name: 'FMention',\n inheritAttrs: false,\n})\n\nconst slots = defineSlots<{\n label?: (scope: { item: MentionOption, index: number, field: Field | undefined }) => any\n header?: (scope: { field: Field | undefined }) => any\n footer?: (scope: { field: Field | undefined }) => any\n loading?: () => any\n prefix?: () => any\n suffix?: () => any\n prepend?: () => any\n append?: () => any\n}>()\n\nconst { props: rawMentionProps } = useCleanAttrs()\nconst fieldRef = useField<Field>()\n\nconst mentionProps = computed(() => {\n const props = rawMentionProps.value\n const { onSearch } = props\n if (!onSearch) {\n return props\n }\n\n return {\n ...props,\n onSearch(pattern: string, prefix: string) {\n return (onSearch as (pattern: string, prefix: string, field?: Field) => any)(\n pattern,\n prefix,\n fieldRef.value,\n )\n },\n }\n})\n</script>\n\n<template>\n <ElMention v-bind=\"mentionProps\">\n <template v-if=\"slots.prefix\" #prefix>\n <slot name=\"prefix\" />\n </template>\n <template v-if=\"slots.suffix\" #suffix>\n <slot name=\"suffix\" />\n </template>\n <template v-if=\"slots.prepend\" #prepend>\n <slot name=\"prepend\" />\n </template>\n <template v-if=\"slots.append\" #append>\n <slot name=\"append\" />\n </template>\n <template v-if=\"slots.header\" #header>\n <slot name=\"header\" :field=\"fieldRef\" />\n </template>\n <template v-if=\"slots.footer\" #footer>\n <slot name=\"footer\" :field=\"fieldRef\" />\n </template>\n <template v-if=\"slots.label\" #label=\"slotProps\">\n <slot name=\"label\" v-bind=\"{ ...slotProps, field: fieldRef }\" />\n </template>\n <template v-if=\"slots.loading\" #loading>\n <slot name=\"loading\" />\n </template>\n </ElMention>\n</template>\n"],"mappings":";;;;;;;;;;EAaA,MAAM,QAAQ,UAAA;EAWd,MAAM,EAAE,OAAO,oBAAoB,eAAc;EACjD,MAAM,WAAW,UAAgB;EAEjC,MAAM,eAAe,eAAe;GAClC,MAAM,QAAQ,gBAAgB;GAC9B,MAAM,EAAE,aAAa;AACrB,OAAI,CAAC,SACH,QAAO;AAGT,UAAO;IACL,GAAG;IACH,SAAS,SAAiB,QAAgB;AACxC,YAAQ,SACN,SACA,QACA,SAAS,MACX;;IAEJ;IACD;;uBAIC,YAyBY,MAAA,UAAA,EAAA,eAAA,mBAzBO,aAAA,MAAY,CAAA,EAAA,YAAA,EAAA,GAAA,GAAA,EAAA;IACb,MAAM,SAAA;WAAS;uBACP,CAAtB,WAAsB,KAAA,QAAA,SAAA,CAAA,CAAA;;;IAER,MAAM,SAAA;WAAS;uBACP,CAAtB,WAAsB,KAAA,QAAA,SAAA,CAAA,CAAA;;;IAER,MAAM,UAAA;WAAU;uBACP,CAAvB,WAAuB,KAAA,QAAA,UAAA,CAAA,CAAA;;;IAET,MAAM,SAAA;WAAS;uBACP,CAAtB,WAAsB,KAAA,QAAA,SAAA,CAAA,CAAA;;;IAER,MAAM,SAAA;WAAS;uBACW,CAAxC,WAAwC,KAAA,QAAA,UAAA,EAAnB,OAAO,MAAA,SAAQ,EAAA,CAAA,CAAA,CAAA;;;IAEtB,MAAM,SAAA;WAAS;uBACW,CAAxC,WAAwC,KAAA,QAAA,UAAA,EAAnB,OAAO,MAAA,SAAQ,EAAA,CAAA,CAAA,CAAA;;;IAEtB,MAAM,QAAA;WAAQ;kBAAO,cAAS,CAC5C,WAAgE,KAAA,QAAA,SAAA,eAAA,mBAAA;MAAA,GAAhC;MAAS,OAAS,MAAA,SAAQ;MAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;;IAE5C,MAAM,UAAA;WAAU;uBACP,CAAvB,WAAuB,KAAA,QAAA,UAAA,CAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pager2.mjs","names":["pageCount","currentPage","disabled","pagerCount"],"sources":["../../../src/pagination/components/pager.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { ArrayField } from '@formily/core'\nimport { DArrowLeft, DArrowRight, MoreFilled } from '@element-plus/icons-vue'\nimport { formilyComputed, useObserver } from '@silver-formily/reactive-vue'\nimport { useField } from '@silver-formily/vue'\nimport { CHANGE_EVENT, ElBadge, useLocale, useNamespace } from 'element-plus'\nimport { computed, ref, watchEffect } from 'vue'\nimport { paginationPagerProps } from './pager'\n\ndefineOptions({\n name: 'ElPaginationPager',\n})\nconst props = defineProps(paginationPagerProps)\nconst emit = defineEmits([CHANGE_EVENT])\nconst nsPager = useNamespace('pager')\nconst nsIcon = useNamespace('icon')\nconst { t } = useLocale()\n\nconst showPrevMore = ref(false)\nconst showNextMore = ref(false)\nconst quickPrevHover = ref(false)\nconst quickNextHover = ref(false)\nconst quickPrevFocus = ref(false)\nconst quickNextFocus = ref(false)\nconst pagers = computed(() => {\n const pagerCount = props.pagerCount\n const halfPagerCount = (pagerCount - 1) / 2\n const currentPage = Number(props.currentPage)\n const pageCount = Number(props.pageCount)\n let showPrevMore = false\n let showNextMore = false\n if (pageCount > pagerCount) {\n if (currentPage > pagerCount - halfPagerCount) {\n showPrevMore = true\n }\n if (currentPage < pageCount - halfPagerCount) {\n showNextMore = true\n }\n }\n const array: number[] = []\n if (showPrevMore && !showNextMore) {\n const startPage = pageCount - (pagerCount - 2)\n for (let i = startPage; i < pageCount; i++) {\n array.push(i)\n }\n }\n else if (!showPrevMore && showNextMore) {\n for (let i = 2; i < pagerCount; i++) {\n array.push(i)\n }\n }\n else if (showPrevMore && showNextMore) {\n const offset = Math.floor(pagerCount / 2) - 1\n for (let i = currentPage - offset; i <= currentPage + offset; i++) {\n array.push(i)\n }\n }\n else {\n for (let i = 2; i < pageCount; i++) {\n array.push(i)\n }\n }\n return array\n})\n\nconst prevMoreKls = computed(() => [\n 'more',\n 'btn-quickprev',\n nsIcon.b(),\n nsPager.is('disabled', props.disabled),\n])\nconst nextMoreKls = computed(() => [\n 'more',\n 'btn-quicknext',\n nsIcon.b(),\n nsPager.is('disabled', props.disabled),\n])\n\nconst tabindex = computed(() => (props.disabled ? -1 : 0))\nwatchEffect(() => {\n const halfPagerCount = (props.pagerCount - 1) / 2\n showPrevMore.value = false\n showNextMore.value = false\n if (props.pageCount! > props.pagerCount) {\n if (props.currentPage > props.pagerCount - halfPagerCount) {\n showPrevMore.value = true\n }\n if (props.currentPage < props.pageCount! - halfPagerCount) {\n showNextMore.value = true\n }\n }\n})\nfunction onMouseEnter(forward = false) {\n if (props.disabled)\n return\n if (forward) {\n quickPrevHover.value = true\n }\n else {\n quickNextHover.value = true\n }\n}\nfunction onFocus(forward = false) {\n if (forward) {\n quickPrevFocus.value = true\n }\n else {\n quickNextFocus.value = true\n }\n}\nfunction onEnter(e: UIEvent) {\n const target = e.target as HTMLElement\n if (\n target.tagName.toLowerCase() === 'li'\n && Array.from(target.classList).includes('number')\n ) {\n const newPage = Number(target.textContent)\n if (newPage !== props.currentPage) {\n emit(CHANGE_EVENT, newPage)\n }\n }\n else if (\n target.tagName.toLowerCase() === 'li'\n && Array.from(target.classList).includes('more')\n ) {\n onPagerClick(e)\n }\n}\nfunction onPagerClick(event: UIEvent) {\n const target = event.target as HTMLElement\n if (target.tagName.toLowerCase() === 'ul' || props.disabled) {\n return\n }\n let newPage = Number(target.textContent)\n const pageCount = props.pageCount!\n const currentPage = props.currentPage\n const pagerCountOffset = props.pagerCount - 2\n if (target.className.includes('more')) {\n if (target.className.includes('quickprev')) {\n newPage = currentPage - pagerCountOffset\n }\n else if (target.className.includes('quicknext')) {\n newPage = currentPage + pagerCountOffset\n }\n }\n if (!Number.isNaN(+newPage)) {\n if (newPage < 1) {\n newPage = 1\n }\n if (newPage > pageCount) {\n newPage = pageCount\n }\n }\n if (newPage !== currentPage) {\n emit(CHANGE_EVENT, newPage)\n }\n}\n/* formily error count */\nuseObserver()\nconst fieldRef = useField<ArrayField>()\nconst field = fieldRef.value\nconst path = field.address.entire\nconst errorPageIndexList = formilyComputed(() => {\n const errorPageSet = field.form\n .queryFeedbacks({\n type: 'error',\n address: `${path}.**`,\n })\n .map(feedback => Number(feedback.path.split(`${path}.`)[1].split('.')[0]))\n .reduce((acc, cur) => {\n const pageIndex = Math.floor(cur / props.pageSize)\n acc.add(pageIndex)\n return acc\n }, new Set<number>())\n\n const errorPageList = Array.from(errorPageSet).sort((a, b) => a - b)\n return errorPageList\n})\n\nconst isPrevMoreError = formilyComputed(() => {\n return errorPageIndexList.value.some(pageIdx => (pageIdx < pagers.value[0] - 1) && pageIdx !== 0)\n})\nconst isNextMoreError = formilyComputed(() => {\n return errorPageIndexList.value.some(pageIdx => (pageIdx > pagers.value.at(-1) - 1) && pageIdx !== errorPageIndexList.value.length - 1)\n})\n</script>\n\n<template>\n <ul :class=\"nsPager.b()\" @click=\"onPagerClick\" @keyup.enter=\"onEnter\">\n <ElBadge v-if=\"pageCount > 1\" is-dot :value=\"1\" :hidden=\"errorPageIndexList[0] !== 0\">\n <li\n :class=\"[\n nsPager.is('active', currentPage === 1),\n nsPager.is('disabled', disabled),\n ]\" class=\"number\" :aria-current=\"currentPage === 1\" :aria-label=\"t('el.pagination.currentPage', { pager: 1 })\"\n :tabindex=\"tabindex\"\n >\n 1\n </li>\n </ElBadge>\n <ElBadge v-if=\"showPrevMore\" is-dot :value=\"1\" :hidden=\"!isPrevMoreError\">\n <li\n :class=\"prevMoreKls\" :tabindex=\"tabindex\"\n :aria-label=\"t('el.pagination.prevPages', { pager: pagerCount - 2 })\" @mouseenter=\"onMouseEnter(true)\"\n @mouseleave=\"quickPrevHover = false\" @focus=\"onFocus(true)\" @blur=\"quickPrevFocus = false\"\n >\n <DArrowLeft v-if=\"(quickPrevHover || quickPrevFocus) && !disabled\" />\n <MoreFilled v-else />\n </li>\n </ElBadge>\n <ElBadge\n v-for=\"pager in pagers\" :key=\"pager\" is-dot :value=\"1\"\n :hidden=\"!errorPageIndexList.includes(pager - 1)\"\n >\n <li\n :class=\"[\n nsPager.is('active', currentPage === pager),\n nsPager.is('disabled', disabled),\n ]\" class=\"number\" :aria-current=\"currentPage === pager\" :aria-label=\"t('el.pagination.currentPage', { pager })\"\n :tabindex=\"tabindex\"\n >\n {{ pager }}\n </li>\n </ElBadge>\n <ElBadge v-if=\"showNextMore\" is-dot :value=\"1\" :hidden=\"!isNextMoreError\">\n <li\n :class=\"nextMoreKls\" :tabindex=\"tabindex\"\n :aria-label=\"t('el.pagination.nextPages', { pager: pagerCount - 2 })\" @mouseenter=\"onMouseEnter()\"\n @mouseleave=\"quickNextHover = false\" @focus=\"onFocus()\" @blur=\"quickNextFocus = false\"\n >\n <DArrowRight v-if=\"(quickNextHover || quickNextFocus) && !disabled\" />\n <MoreFilled v-else />\n </li>\n </ElBadge>\n <ElBadge\n is-dot\n :value=\"1\"\n :hidden=\"errorPageIndexList[errorPageIndexList.length - 1] !== pageCount - 1\"\n >\n <li\n :class=\"[\n nsPager.is('active', currentPage === pageCount),\n nsPager.is('disabled', disabled),\n ]\" class=\"number\" :aria-current=\"currentPage === pageCount\"\n :aria-label=\"t('el.pagination.currentPage', { pager: pageCount })\" :tabindex=\"tabindex\"\n >\n {{ pageCount }}\n </li>\n </ElBadge>\n </ul>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYA,MAAM,QAAQ;EACd,MAAM,OAAO;EACb,MAAM,UAAU,aAAa,QAAO;EACpC,MAAM,SAAS,aAAa,OAAM;EAClC,MAAM,EAAE,MAAM,WAAU;EAExB,MAAM,eAAe,IAAI,MAAK;EAC9B,MAAM,eAAe,IAAI,MAAK;EAC9B,MAAM,iBAAiB,IAAI,MAAK;EAChC,MAAM,iBAAiB,IAAI,MAAK;EAChC,MAAM,iBAAiB,IAAI,MAAK;EAChC,MAAM,iBAAiB,IAAI,MAAK;EAChC,MAAM,SAAS,eAAe;GAC5B,MAAM,aAAa,MAAM;GACzB,MAAM,kBAAkB,aAAa,KAAK;GAC1C,MAAM,cAAc,OAAO,MAAM,YAAW;GAC5C,MAAM,YAAY,OAAO,MAAM,UAAS;GACxC,IAAI,eAAe;GACnB,IAAI,eAAe;AACnB,OAAI,YAAY,YAAY;AAC1B,QAAI,cAAc,aAAa,eAC7B,gBAAe;AAEjB,QAAI,cAAc,YAAY,eAC5B,gBAAe;;GAGnB,MAAM,QAAkB,EAAC;AACzB,OAAI,gBAAgB,CAAC,cAAc;IACjC,MAAM,YAAY,aAAa,aAAa;AAC5C,SAAK,IAAI,IAAI,WAAW,IAAI,WAAW,IACrC,OAAM,KAAK,EAAC;cAGP,CAAC,gBAAgB,aACxB,MAAK,IAAI,IAAI,GAAG,IAAI,YAAY,IAC9B,OAAM,KAAK,EAAC;YAGP,gBAAgB,cAAc;IACrC,MAAM,SAAS,KAAK,MAAM,aAAa,EAAE,GAAG;AAC5C,SAAK,IAAI,IAAI,cAAc,QAAQ,KAAK,cAAc,QAAQ,IAC5D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,MAAA,QAAA,EAAA;KAbR,UAAA;KACC,OAAO;KACP,QAAQ,MAAA,mBAAkB,CAAC,MAAA,mBAAkB,CAAC,SAAM,OAAUF,KAAAA,YAAS;;4BAUnE,CARL,mBAQK,MAAA;MAPF,OAAK,eAAA,CAAA,CAAc,MAAA,QAAO,CAAC,GAAE,UAAWC,KAAAA,gBAAgBD,KAAAA,UAAS,EAAa,MAAA,QAAO,CAAC,GAAE,YAAaE,KAAAA,SAAQ,CAAA,EAGrG,SAAQ,CAAA;MAAE,gBAAcD,KAAAA,gBAAgBD,KAAAA;MAChD,cAAY,MAAA,EAAC,CAAA,6BAAA,EAAA,OAAuCA,KAAAA,WAAS,CAAA;MAAM,UAAU,SAAA;wBAE3EA,KAAAA,UAAS,EAAA,IAAA,WAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"pager2.mjs","names":["pageCount","currentPage","disabled","pagerCount"],"sources":["../../../src/pagination/components/pager.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { ArrayField } from '@silver-formily/core'\nimport { DArrowLeft, DArrowRight, MoreFilled } from '@element-plus/icons-vue'\nimport { formilyComputed, useObserver } from '@silver-formily/reactive-vue'\nimport { useField } from '@silver-formily/vue'\nimport { CHANGE_EVENT, ElBadge, useLocale, useNamespace } from 'element-plus'\nimport { computed, ref, watchEffect } from 'vue'\nimport { paginationPagerProps } from './pager'\n\ndefineOptions({\n name: 'ElPaginationPager',\n})\nconst props = defineProps(paginationPagerProps)\nconst emit = defineEmits([CHANGE_EVENT])\nconst nsPager = useNamespace('pager')\nconst nsIcon = useNamespace('icon')\nconst { t } = useLocale()\n\nconst showPrevMore = ref(false)\nconst showNextMore = ref(false)\nconst quickPrevHover = ref(false)\nconst quickNextHover = ref(false)\nconst quickPrevFocus = ref(false)\nconst quickNextFocus = ref(false)\nconst pagers = computed(() => {\n const pagerCount = props.pagerCount\n const halfPagerCount = (pagerCount - 1) / 2\n const currentPage = Number(props.currentPage)\n const pageCount = Number(props.pageCount)\n let showPrevMore = false\n let showNextMore = false\n if (pageCount > pagerCount) {\n if (currentPage > pagerCount - halfPagerCount) {\n showPrevMore = true\n }\n if (currentPage < pageCount - halfPagerCount) {\n showNextMore = true\n }\n }\n const array: number[] = []\n if (showPrevMore && !showNextMore) {\n const startPage = pageCount - (pagerCount - 2)\n for (let i = startPage; i < pageCount; i++) {\n array.push(i)\n }\n }\n else if (!showPrevMore && showNextMore) {\n for (let i = 2; i < pagerCount; i++) {\n array.push(i)\n }\n }\n else if (showPrevMore && showNextMore) {\n const offset = Math.floor(pagerCount / 2) - 1\n for (let i = currentPage - offset; i <= currentPage + offset; i++) {\n array.push(i)\n }\n }\n else {\n for (let i = 2; i < pageCount; i++) {\n array.push(i)\n }\n }\n return array\n})\n\nconst prevMoreKls = computed(() => [\n 'more',\n 'btn-quickprev',\n nsIcon.b(),\n nsPager.is('disabled', props.disabled),\n])\nconst nextMoreKls = computed(() => [\n 'more',\n 'btn-quicknext',\n nsIcon.b(),\n nsPager.is('disabled', props.disabled),\n])\n\nconst tabindex = computed(() => (props.disabled ? -1 : 0))\nwatchEffect(() => {\n const halfPagerCount = (props.pagerCount - 1) / 2\n showPrevMore.value = false\n showNextMore.value = false\n if (props.pageCount! > props.pagerCount) {\n if (props.currentPage > props.pagerCount - halfPagerCount) {\n showPrevMore.value = true\n }\n if (props.currentPage < props.pageCount! - halfPagerCount) {\n showNextMore.value = true\n }\n }\n})\nfunction onMouseEnter(forward = false) {\n if (props.disabled)\n return\n if (forward) {\n quickPrevHover.value = true\n }\n else {\n quickNextHover.value = true\n }\n}\nfunction onFocus(forward = false) {\n if (forward) {\n quickPrevFocus.value = true\n }\n else {\n quickNextFocus.value = true\n }\n}\nfunction onEnter(e: UIEvent) {\n const target = e.target as HTMLElement\n if (\n target.tagName.toLowerCase() === 'li'\n && Array.from(target.classList).includes('number')\n ) {\n const newPage = Number(target.textContent)\n if (newPage !== props.currentPage) {\n emit(CHANGE_EVENT, newPage)\n }\n }\n else if (\n target.tagName.toLowerCase() === 'li'\n && Array.from(target.classList).includes('more')\n ) {\n onPagerClick(e)\n }\n}\nfunction onPagerClick(event: UIEvent) {\n const target = event.target as HTMLElement\n if (target.tagName.toLowerCase() === 'ul' || props.disabled) {\n return\n }\n let newPage = Number(target.textContent)\n const pageCount = props.pageCount!\n const currentPage = props.currentPage\n const pagerCountOffset = props.pagerCount - 2\n if (target.className.includes('more')) {\n if (target.className.includes('quickprev')) {\n newPage = currentPage - pagerCountOffset\n }\n else if (target.className.includes('quicknext')) {\n newPage = currentPage + pagerCountOffset\n }\n }\n if (!Number.isNaN(+newPage)) {\n if (newPage < 1) {\n newPage = 1\n }\n if (newPage > pageCount) {\n newPage = pageCount\n }\n }\n if (newPage !== currentPage) {\n emit(CHANGE_EVENT, newPage)\n }\n}\n/* formily error count */\nuseObserver()\nconst fieldRef = useField<ArrayField>()\nconst field = fieldRef.value\nconst path = field.address.entire\nconst errorPageIndexList = formilyComputed(() => {\n const errorPageSet = field.form\n .queryFeedbacks({\n type: 'error',\n address: `${path}.**`,\n })\n .map(feedback => Number(feedback.path.split(`${path}.`)[1].split('.')[0]))\n .reduce((acc, cur) => {\n const pageIndex = Math.floor(cur / props.pageSize)\n acc.add(pageIndex)\n return acc\n }, new Set<number>())\n\n const errorPageList = Array.from(errorPageSet).sort((a, b) => a - b)\n return errorPageList\n})\n\nconst isPrevMoreError = formilyComputed(() => {\n return errorPageIndexList.value.some(pageIdx => (pageIdx < pagers.value[0] - 1) && pageIdx !== 0)\n})\nconst isNextMoreError = formilyComputed(() => {\n return errorPageIndexList.value.some(pageIdx => (pageIdx > pagers.value.at(-1) - 1) && pageIdx !== errorPageIndexList.value.length - 1)\n})\n</script>\n\n<template>\n <ul :class=\"nsPager.b()\" @click=\"onPagerClick\" @keyup.enter=\"onEnter\">\n <ElBadge v-if=\"pageCount > 1\" is-dot :value=\"1\" :hidden=\"errorPageIndexList[0] !== 0\">\n <li\n :class=\"[\n nsPager.is('active', currentPage === 1),\n nsPager.is('disabled', disabled),\n ]\" class=\"number\" :aria-current=\"currentPage === 1\" :aria-label=\"t('el.pagination.currentPage', { pager: 1 })\"\n :tabindex=\"tabindex\"\n >\n 1\n </li>\n </ElBadge>\n <ElBadge v-if=\"showPrevMore\" is-dot :value=\"1\" :hidden=\"!isPrevMoreError\">\n <li\n :class=\"prevMoreKls\" :tabindex=\"tabindex\"\n :aria-label=\"t('el.pagination.prevPages', { pager: pagerCount - 2 })\" @mouseenter=\"onMouseEnter(true)\"\n @mouseleave=\"quickPrevHover = false\" @focus=\"onFocus(true)\" @blur=\"quickPrevFocus = false\"\n >\n <DArrowLeft v-if=\"(quickPrevHover || quickPrevFocus) && !disabled\" />\n <MoreFilled v-else />\n </li>\n </ElBadge>\n <ElBadge\n v-for=\"pager in pagers\" :key=\"pager\" is-dot :value=\"1\"\n :hidden=\"!errorPageIndexList.includes(pager - 1)\"\n >\n <li\n :class=\"[\n nsPager.is('active', currentPage === pager),\n nsPager.is('disabled', disabled),\n ]\" class=\"number\" :aria-current=\"currentPage === pager\" :aria-label=\"t('el.pagination.currentPage', { pager })\"\n :tabindex=\"tabindex\"\n >\n {{ pager }}\n </li>\n </ElBadge>\n <ElBadge v-if=\"showNextMore\" is-dot :value=\"1\" :hidden=\"!isNextMoreError\">\n <li\n :class=\"nextMoreKls\" :tabindex=\"tabindex\"\n :aria-label=\"t('el.pagination.nextPages', { pager: pagerCount - 2 })\" @mouseenter=\"onMouseEnter()\"\n @mouseleave=\"quickNextHover = false\" @focus=\"onFocus()\" @blur=\"quickNextFocus = false\"\n >\n <DArrowRight v-if=\"(quickNextHover || quickNextFocus) && !disabled\" />\n <MoreFilled v-else />\n </li>\n </ElBadge>\n <ElBadge\n is-dot\n :value=\"1\"\n :hidden=\"errorPageIndexList[errorPageIndexList.length - 1] !== pageCount - 1\"\n >\n <li\n :class=\"[\n nsPager.is('active', currentPage === pageCount),\n nsPager.is('disabled', disabled),\n ]\" class=\"number\" :aria-current=\"currentPage === pageCount\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,CAAC,SAAM,OAAUF,KAAAA,YAAS;;4BAUnE,CARL,mBAQK,MAAA;MAPF,OAAK,eAAA,CAAA,CAAc,MAAA,QAAO,CAAC,GAAE,UAAWC,KAAAA,gBAAgBD,KAAAA,UAAS,EAAa,MAAA,QAAO,CAAC,GAAE,YAAaE,KAAAA,SAAQ,CAAA,EAGrG,SAAQ,CAAA;MAAE,gBAAcD,KAAAA,gBAAgBD,KAAAA;MAChD,cAAY,MAAA,EAAC,CAAA,6BAAA,EAAA,OAAuCA,KAAAA,WAAS,CAAA;MAAM,UAAU,SAAA;wBAE3EA,KAAAA,UAAS,EAAA,IAAA,WAAA,CAAA,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { paginationSizesProps } from "./sizes.mjs";
|
|
2
2
|
import { ElOption, ElSelect, useLocale, useNamespace } from "element-plus";
|
|
3
3
|
import { Fragment, computed, createBlock, createElementBlock, createVNode, defineComponent, normalizeClass, openBlock, ref, renderList, unref, watch, withCtx } from "vue";
|
|
4
|
-
import { isArr, isEqual } from "@formily/shared";
|
|
4
|
+
import { isArr, isEqual } from "@silver-formily/shared";
|
|
5
5
|
import { usePagination } from "element-plus/es/components/pagination/src/usePagination";
|
|
6
6
|
//#region src/pagination/components/sizes.vue
|
|
7
7
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sizes2.mjs","names":["disabled","popperClass","size","teleported","appendSizeTo"],"sources":["../../../src/pagination/components/sizes.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { isArr, isEqual } from '@formily/shared'\nimport { ElOption, ElSelect, useLocale, useNamespace } from 'element-plus'\nimport { usePagination } from 'element-plus/es/components/pagination/src/usePagination'\nimport { computed, ref, watch } from 'vue'\nimport { paginationSizesProps } from './sizes'\n\ndefineOptions({\n name: 'ElPaginationSizes',\n})\n\nconst props = defineProps(paginationSizesProps)\nconst emit = defineEmits(['page-size-change'])\nconst { t } = useLocale()\nconst ns = useNamespace('pagination')\nconst pagination = usePagination()\nconst innerPageSize = ref<number>(props.pageSize!)\n\nwatch(\n () => props.pageSizes,\n (newVal, oldVal) => {\n if (isEqual(newVal, oldVal))\n return\n if (isArr(newVal)) {\n const pageSize = newVal.includes(props.pageSize!)\n ? props.pageSize\n : props.pageSizes[0]\n // eslint-disable-next-line vue/custom-event-name-casing\n emit('page-size-change', pageSize)\n }\n },\n)\n\nwatch(\n () => props.pageSize,\n (newVal) => {\n innerPageSize.value = newVal!\n },\n)\n\nconst innerPageSizes = computed(() => props.pageSizes)\nfunction handleChange(val: number) {\n if (val !== innerPageSize.value) {\n innerPageSize.value = val\n pagination.handleSizeChange?.(Number(val))\n }\n}\n</script>\n\n<template>\n <span :class=\"ns.e('sizes')\">\n <ElSelect\n :model-value=\"innerPageSize\"\n :disabled=\"disabled\"\n :popper-class=\"popperClass\"\n :size=\"size\"\n :teleported=\"teleported\"\n :validate-event=\"false\"\n :append-to=\"appendSizeTo\"\n @change=\"handleChange\"\n >\n <ElOption\n v-for=\"item in innerPageSizes\"\n :key=\"item\"\n :value=\"item\"\n :label=\"item + t('el.pagination.pagesize')\"\n />\n </ElSelect>\n </span>\n</template>\n"],"mappings":";;;;;;;;;;;;EAWA,MAAM,QAAQ;EACd,MAAM,OAAO;EACb,MAAM,EAAE,MAAM,WAAU;EACxB,MAAM,KAAK,aAAa,aAAY;EACpC,MAAM,aAAa,eAAc;EACjC,MAAM,gBAAgB,IAAY,MAAM,SAAS;AAEjD,cACQ,MAAM,YACX,QAAQ,WAAW;AAClB,OAAI,QAAQ,QAAQ,OAAO,CACzB;AACF,OAAI,MAAM,OAAO,CAKf,MAAK,oBAJY,OAAO,SAAS,MAAM,SAAS,GAC5C,MAAM,WACN,MAAM,UAAU,GAEa;IAGvC;AAEA,cACQ,MAAM,WACX,WAAW;AACV,iBAAc,QAAQ;IAE1B;EAEA,MAAM,iBAAiB,eAAe,MAAM,UAAS;EACrD,SAAS,aAAa,KAAa;AACjC,OAAI,QAAQ,cAAc,OAAO;AAC/B,kBAAc,QAAQ;AACtB,eAAW,mBAAmB,OAAO,IAAI,CAAA;;;;uBAM3C,mBAkBO,QAAA,EAlBA,OAAK,eAAE,MAAA,GAAE,CAAC,EAAC,QAAA,CAAA,EAAA,EAAA,CAChB,YAgBW,MAAA,SAAA,EAAA;IAfR,eAAa,cAAA;IACb,UAAUA,KAAAA;IACV,gBAAcC,KAAAA;IACd,MAAMC,KAAAA;IACN,YAAYC,KAAAA;IACZ,kBAAgB;IAChB,aAAWC,KAAAA;IACX,UAAQ;;2BAGuB,EAAA,UAAA,KAAA,EADhC,mBAKE,UAAA,MAAA,WAJe,eAAA,QAAR,SAAI;yBADb,YAKE,MAAA,SAAA,EAAA;MAHC,KAAK;MACL,OAAO;MACP,OAAO,OAAO,MAAA,EAAC,CAAA,yBAAA"}
|
|
1
|
+
{"version":3,"file":"sizes2.mjs","names":["disabled","popperClass","size","teleported","appendSizeTo"],"sources":["../../../src/pagination/components/sizes.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { isArr, isEqual } from '@silver-formily/shared'\nimport { ElOption, ElSelect, useLocale, useNamespace } from 'element-plus'\nimport { usePagination } from 'element-plus/es/components/pagination/src/usePagination'\nimport { computed, ref, watch } from 'vue'\nimport { paginationSizesProps } from './sizes'\n\ndefineOptions({\n name: 'ElPaginationSizes',\n})\n\nconst props = defineProps(paginationSizesProps)\nconst emit = defineEmits(['page-size-change'])\nconst { t } = useLocale()\nconst ns = useNamespace('pagination')\nconst pagination = usePagination()\nconst innerPageSize = ref<number>(props.pageSize!)\n\nwatch(\n () => props.pageSizes,\n (newVal, oldVal) => {\n if (isEqual(newVal, oldVal))\n return\n if (isArr(newVal)) {\n const pageSize = newVal.includes(props.pageSize!)\n ? props.pageSize\n : props.pageSizes[0]\n // eslint-disable-next-line vue/custom-event-name-casing\n emit('page-size-change', pageSize)\n }\n },\n)\n\nwatch(\n () => props.pageSize,\n (newVal) => {\n innerPageSize.value = newVal!\n },\n)\n\nconst innerPageSizes = computed(() => props.pageSizes)\nfunction handleChange(val: number) {\n if (val !== innerPageSize.value) {\n innerPageSize.value = val\n pagination.handleSizeChange?.(Number(val))\n }\n}\n</script>\n\n<template>\n <span :class=\"ns.e('sizes')\">\n <ElSelect\n :model-value=\"innerPageSize\"\n :disabled=\"disabled\"\n :popper-class=\"popperClass\"\n :size=\"size\"\n :teleported=\"teleported\"\n :validate-event=\"false\"\n :append-to=\"appendSizeTo\"\n @change=\"handleChange\"\n >\n <ElOption\n v-for=\"item in innerPageSizes\"\n :key=\"item\"\n :value=\"item\"\n :label=\"item + t('el.pagination.pagesize')\"\n />\n </ElSelect>\n </span>\n</template>\n"],"mappings":";;;;;;;;;;;;EAWA,MAAM,QAAQ;EACd,MAAM,OAAO;EACb,MAAM,EAAE,MAAM,WAAU;EACxB,MAAM,KAAK,aAAa,aAAY;EACpC,MAAM,aAAa,eAAc;EACjC,MAAM,gBAAgB,IAAY,MAAM,SAAS;AAEjD,cACQ,MAAM,YACX,QAAQ,WAAW;AAClB,OAAI,QAAQ,QAAQ,OAAO,CACzB;AACF,OAAI,MAAM,OAAO,CAKf,MAAK,oBAJY,OAAO,SAAS,MAAM,SAAS,GAC5C,MAAM,WACN,MAAM,UAAU,GAEa;IAGvC;AAEA,cACQ,MAAM,WACX,WAAW;AACV,iBAAc,QAAQ;IAE1B;EAEA,MAAM,iBAAiB,eAAe,MAAM,UAAS;EACrD,SAAS,aAAa,KAAa;AACjC,OAAI,QAAQ,cAAc,OAAO;AAC/B,kBAAc,QAAQ;AACtB,eAAW,mBAAmB,OAAO,IAAI,CAAA;;;;uBAM3C,mBAkBO,QAAA,EAlBA,OAAK,eAAE,MAAA,GAAE,CAAC,EAAC,QAAA,CAAA,EAAA,EAAA,CAChB,YAgBW,MAAA,SAAA,EAAA;IAfR,eAAa,cAAA;IACb,UAAUA,KAAAA;IACV,gBAAcC,KAAAA;IACd,MAAMC,KAAAA;IACN,YAAYC,KAAAA;IACZ,kBAAgB;IAChB,aAAWC,KAAAA;IACX,UAAQ;;2BAGuB,EAAA,UAAA,KAAA,EADhC,mBAKE,UAAA,MAAA,WAJe,eAAA,QAAR,SAAI;yBADb,YAKE,MAAA,SAAA,EAAA;MAHC,KAAK;MACL,OAAO;MACP,OAAO,OAAO,MAAA,EAAC,CAAA,yBAAA"}
|
|
@@ -2,7 +2,7 @@ import { useCleanAttrs } from "../__builtins__/shared/utils.mjs";
|
|
|
2
2
|
import { ElOption, ElSelect } from "element-plus";
|
|
3
3
|
import { Fragment, computed, createBlock, createElementBlock, createSlots, defineComponent, mergeProps, openBlock, ref, renderList, renderSlot, unref, useSlots, withCtx } from "vue";
|
|
4
4
|
import { useField } from "@silver-formily/vue";
|
|
5
|
-
import { isArr, isEqual, isValid } from "@formily/shared";
|
|
5
|
+
import { isArr, isEqual, isValid } from "@silver-formily/shared";
|
|
6
6
|
//#region src/picker-select/picker-select.vue
|
|
7
7
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
8
8
|
name: "FPickerSelect",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picker-select.mjs","names":[],"sources":["../../src/picker-select/picker-select.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { Field } from '@formily/core'\nimport type { PickerSelectOpenPicker, PickerSelectOption, PickerSelectProps } from './types'\nimport { isArr, isEqual, isValid } from '@formily/shared'\nimport { useField } from '@silver-formily/vue'\nimport { ElOption, ElSelect } from 'element-plus'\nimport { computed, ref } from 'vue'\nimport { useCleanAttrs } from '../__builtins__'\n\ndefineOptions({\n name: 'FPickerSelect',\n inheritAttrs: false,\n})\n\nconst props = withDefaults(defineProps<PickerSelectProps>(), {\n options: () => [],\n cacheSelectedOptions: true,\n})\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: any): void\n}>()\n\nconst slots = defineSlots<{\n empty?: () => any\n prefix?: () => any\n tag?: () => any\n loading?: () => any\n label?: () => any\n}>()\n\nconst ignoredOpenTriggerSelectors = ['.el-select__clear', '.el-tag__close']\n\nconst { props: selectProps } = useCleanAttrs()\nconst fieldRef = useField<Field>()\nconst selectRef = ref<InstanceType<typeof ElSelect>>()\nconst openingPicker = ref(false)\nconst selectedOptionCache = ref<PickerSelectOption[]>([])\nconst ignoreVisibleChangeUntil = ref(0)\n\nconst multiple = computed(() => Boolean(selectProps.value.multiple))\nconst currentValue = computed(() => selectProps.value.modelValue)\nconst baseOptions = computed<PickerSelectOption[]>(() => props.options ?? [])\n\nfunction isSameValue(left: any, right: any) {\n return isEqual(left, right)\n}\n\nfunction hasOption(optionList: PickerSelectOption[], option: PickerSelectOption) {\n return optionList.some(item => isSameValue(item.value, option.value))\n}\n\nfunction createFallbackOption(value: any): PickerSelectOption {\n return {\n label: value,\n value,\n }\n}\n\nconst normalizedValues = computed(() => {\n const value = currentValue.value\n if (multiple.value) {\n return isArr(value) ? value : []\n }\n return isValid(value) ? [value] : []\n})\n\nconst displayOptions = computed<PickerSelectOption[]>(() => {\n const merged = [...baseOptions.value]\n for (const item of selectedOptionCache.value) {\n if (!hasOption(merged, item)) {\n merged.push(item)\n }\n }\n for (const value of normalizedValues.value) {\n if (!merged.some(item => isSameValue(item.value, value))) {\n merged.push(createFallbackOption(value))\n }\n }\n return merged\n})\n\nfunction setValue(value: any) {\n fieldRef.value?.setValue?.(value)\n if (!fieldRef.value) {\n emit('update:modelValue', value)\n }\n}\n\nfunction cacheOptions(optionList: PickerSelectOption[]) {\n if (props.cacheSelectedOptions === false) {\n return\n }\n const merged = [...selectedOptionCache.value]\n for (const item of optionList) {\n const index = merged.findIndex(cacheItem => isSameValue(cacheItem.value, item.value))\n if (index >= 0) {\n merged[index] = item\n }\n else {\n merged.push(item)\n }\n }\n selectedOptionCache.value = merged\n}\n\nfunction clearValue() {\n setValue(multiple.value ? [] : undefined)\n}\n\nfunction shouldIgnoreOpenTrigger(target: EventTarget | null) {\n if (!(target instanceof HTMLElement)) {\n return false\n }\n return ignoredOpenTriggerSelectors.some(selector => target.closest(selector))\n}\n\nfunction ignoreCurrentVisibleChange() {\n ignoreVisibleChangeUntil.value = Date.now() + 200\n}\n\nasync function handleOpenPicker() {\n if (openingPicker.value || typeof props.openPicker !== 'function') {\n return\n }\n\n openingPicker.value = true\n\n try {\n const result = await Promise.resolve(\n (props.openPicker as PickerSelectOpenPicker)({\n field: fieldRef.value,\n dataSource: baseOptions.value,\n multiple: multiple.value,\n }),\n ).catch(() => undefined)\n\n if (multiple.value) {\n if (!isValid(result)) {\n return\n }\n const normalizedResult = isArr(result) ? result : [result]\n cacheOptions(normalizedResult)\n setValue(normalizedResult.map(item => item.value))\n return\n }\n\n if (!isValid(result)) {\n return\n }\n const normalizedResult = isArr(result) ? result[0] : result\n if (!normalizedResult) {\n return\n }\n cacheOptions([normalizedResult])\n setValue(normalizedResult.value)\n }\n finally {\n openingPicker.value = false\n }\n}\n\nfunction handleVisibleChange(visible: boolean) {\n if (!visible) {\n return\n }\n selectRef.value?.blur?.()\n if (Date.now() < ignoreVisibleChangeUntil.value) {\n ignoreVisibleChangeUntil.value = 0\n return\n }\n void handleOpenPicker()\n}\n\nfunction handleTriggerClick(event: MouseEvent) {\n if (typeof props.openPicker !== 'function' || selectProps.value.disabled) {\n return\n }\n if (shouldIgnoreOpenTrigger(event.target)) {\n ignoreCurrentVisibleChange()\n return\n }\n ignoreVisibleChangeUntil.value = 0\n}\n\nfunction handleRemoveTag(value: any) {\n if (!multiple.value) {\n return\n }\n setValue(normalizedValues.value.filter(item => !isSameValue(item, value)))\n}\n</script>\n\n<template>\n <ElSelect\n ref=\"selectRef\"\n v-bind=\"selectProps\"\n @click=\"handleTriggerClick\"\n @clear=\"clearValue\"\n @remove-tag=\"handleRemoveTag\"\n @visible-change=\"handleVisibleChange\"\n >\n <ElOption\n v-for=\"option of displayOptions\"\n :key=\"typeof option.value === 'object' ? JSON.stringify(option.value) : String(option.value)\"\n :label=\"option.label\"\n :value=\"option.value\"\n :disabled=\"option.disabled\"\n />\n <template v-if=\"slots.prefix\" #prefix>\n <slot name=\"prefix\" />\n </template>\n <template v-if=\"slots.empty\" #empty>\n <slot name=\"empty\" />\n </template>\n <template v-if=\"slots.tag\" #tag>\n <slot name=\"tag\" />\n </template>\n <template v-if=\"slots.loading\" #loading>\n <slot name=\"loading\" />\n </template>\n <template v-if=\"slots.label\" #label=\"{ label, value }\">\n <slot name=\"label\" :label=\"label\" :value=\"value\" />\n </template>\n </ElSelect>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;EAcA,MAAM,QAAQ;EAKd,MAAM,OAAO;EAIb,MAAM,QAAQ,UAAA;EAQd,MAAM,8BAA8B,CAAC,qBAAqB,iBAAgB;EAE1E,MAAM,EAAE,OAAO,gBAAgB,eAAc;EAC7C,MAAM,WAAW,UAAgB;EACjC,MAAM,YAAY,KAAmC;EACrD,MAAM,gBAAgB,IAAI,MAAK;EAC/B,MAAM,sBAAsB,IAA0B,EAAE,CAAA;EACxD,MAAM,2BAA2B,IAAI,EAAC;EAEtC,MAAM,WAAW,eAAe,QAAQ,YAAY,MAAM,SAAS,CAAA;EACnE,MAAM,eAAe,eAAe,YAAY,MAAM,WAAU;EAChE,MAAM,cAAc,eAAqC,MAAM,WAAW,EAAE,CAAA;EAE5E,SAAS,YAAY,MAAW,OAAY;AAC1C,UAAO,QAAQ,MAAM,MAAK;;EAG5B,SAAS,UAAU,YAAkC,QAA4B;AAC/E,UAAO,WAAW,MAAK,SAAQ,YAAY,KAAK,OAAO,OAAO,MAAM,CAAA;;EAGtE,SAAS,qBAAqB,OAAgC;AAC5D,UAAO;IACL,OAAO;IACP;IACF;;EAGF,MAAM,mBAAmB,eAAe;GACtC,MAAM,QAAQ,aAAa;AAC3B,OAAI,SAAS,MACX,QAAO,MAAM,MAAM,GAAG,QAAQ,EAAC;AAEjC,UAAO,QAAQ,MAAM,GAAG,CAAC,MAAM,GAAG,EAAC;IACpC;EAED,MAAM,iBAAiB,eAAqC;GAC1D,MAAM,SAAS,CAAC,GAAG,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BACP,CAAtB,WAAsB,KAAA,QAAA,SAAA,CAAA,CAAA;;;IAER,MAAM,QAAA;WAAQ;uBACP,CAArB,WAAqB,KAAA,QAAA,QAAA,CAAA,CAAA;;;IAEP,MAAM,MAAA;WAAM;uBACP,CAAnB,WAAmB,KAAA,QAAA,MAAA,CAAA,CAAA;;;IAEL,MAAM,UAAA;WAAU;uBACP,CAAvB,WAAuB,KAAA,QAAA,UAAA,CAAA,CAAA;;;IAET,MAAM,QAAA;WAAQ;kBACuB,EADd,OAAO,YAAK,CACjD,WAAmD,KAAA,QAAA,SAAA;MAAxB;MAAe"}
|
|
1
|
+
{"version":3,"file":"picker-select.mjs","names":[],"sources":["../../src/picker-select/picker-select.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { Field } from '@silver-formily/core'\nimport type { PickerSelectOpenPicker, PickerSelectOption, PickerSelectProps } from './types'\nimport { isArr, isEqual, isValid } from '@silver-formily/shared'\nimport { useField } from '@silver-formily/vue'\nimport { ElOption, ElSelect } from 'element-plus'\nimport { computed, ref } from 'vue'\nimport { useCleanAttrs } from '../__builtins__'\n\ndefineOptions({\n name: 'FPickerSelect',\n inheritAttrs: false,\n})\n\nconst props = withDefaults(defineProps<PickerSelectProps>(), {\n options: () => [],\n cacheSelectedOptions: true,\n})\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: any): void\n}>()\n\nconst slots = defineSlots<{\n empty?: () => any\n prefix?: () => any\n tag?: () => any\n loading?: () => any\n label?: () => any\n}>()\n\nconst ignoredOpenTriggerSelectors = ['.el-select__clear', '.el-tag__close']\n\nconst { props: selectProps } = useCleanAttrs()\nconst fieldRef = useField<Field>()\nconst selectRef = ref<InstanceType<typeof ElSelect>>()\nconst openingPicker = ref(false)\nconst selectedOptionCache = ref<PickerSelectOption[]>([])\nconst ignoreVisibleChangeUntil = ref(0)\n\nconst multiple = computed(() => Boolean(selectProps.value.multiple))\nconst currentValue = computed(() => selectProps.value.modelValue)\nconst baseOptions = computed<PickerSelectOption[]>(() => props.options ?? [])\n\nfunction isSameValue(left: any, right: any) {\n return isEqual(left, right)\n}\n\nfunction hasOption(optionList: PickerSelectOption[], option: PickerSelectOption) {\n return optionList.some(item => isSameValue(item.value, option.value))\n}\n\nfunction createFallbackOption(value: any): PickerSelectOption {\n return {\n label: value,\n value,\n }\n}\n\nconst normalizedValues = computed(() => {\n const value = currentValue.value\n if (multiple.value) {\n return isArr(value) ? value : []\n }\n return isValid(value) ? [value] : []\n})\n\nconst displayOptions = computed<PickerSelectOption[]>(() => {\n const merged = [...baseOptions.value]\n for (const item of selectedOptionCache.value) {\n if (!hasOption(merged, item)) {\n merged.push(item)\n }\n }\n for (const value of normalizedValues.value) {\n if (!merged.some(item => isSameValue(item.value, value))) {\n merged.push(createFallbackOption(value))\n }\n }\n return merged\n})\n\nfunction setValue(value: any) {\n fieldRef.value?.setValue?.(value)\n if (!fieldRef.value) {\n emit('update:modelValue', value)\n }\n}\n\nfunction cacheOptions(optionList: PickerSelectOption[]) {\n if (props.cacheSelectedOptions === false) {\n return\n }\n const merged = [...selectedOptionCache.value]\n for (const item of optionList) {\n const index = merged.findIndex(cacheItem => isSameValue(cacheItem.value, item.value))\n if (index >= 0) {\n merged[index] = item\n }\n else {\n merged.push(item)\n }\n }\n selectedOptionCache.value = merged\n}\n\nfunction clearValue() {\n setValue(multiple.value ? [] : undefined)\n}\n\nfunction shouldIgnoreOpenTrigger(target: EventTarget | null) {\n if (!(target instanceof HTMLElement)) {\n return false\n }\n return ignoredOpenTriggerSelectors.some(selector => target.closest(selector))\n}\n\nfunction ignoreCurrentVisibleChange() {\n ignoreVisibleChangeUntil.value = Date.now() + 200\n}\n\nasync function handleOpenPicker() {\n if (openingPicker.value || typeof props.openPicker !== 'function') {\n return\n }\n\n openingPicker.value = true\n\n try {\n const result = await Promise.resolve(\n (props.openPicker as PickerSelectOpenPicker)({\n field: fieldRef.value,\n dataSource: baseOptions.value,\n multiple: multiple.value,\n }),\n ).catch(() => undefined)\n\n if (multiple.value) {\n if (!isValid(result)) {\n return\n }\n const normalizedResult = isArr(result) ? result : [result]\n cacheOptions(normalizedResult)\n setValue(normalizedResult.map(item => item.value))\n return\n }\n\n if (!isValid(result)) {\n return\n }\n const normalizedResult = isArr(result) ? result[0] : result\n if (!normalizedResult) {\n return\n }\n cacheOptions([normalizedResult])\n setValue(normalizedResult.value)\n }\n finally {\n openingPicker.value = false\n }\n}\n\nfunction handleVisibleChange(visible: boolean) {\n if (!visible) {\n return\n }\n selectRef.value?.blur?.()\n if (Date.now() < ignoreVisibleChangeUntil.value) {\n ignoreVisibleChangeUntil.value = 0\n return\n }\n void handleOpenPicker()\n}\n\nfunction handleTriggerClick(event: MouseEvent) {\n if (typeof props.openPicker !== 'function' || selectProps.value.disabled) {\n return\n }\n if (shouldIgnoreOpenTrigger(event.target)) {\n ignoreCurrentVisibleChange()\n return\n }\n ignoreVisibleChangeUntil.value = 0\n}\n\nfunction handleRemoveTag(value: any) {\n if (!multiple.value) {\n return\n }\n setValue(normalizedValues.value.filter(item => !isSameValue(item, value)))\n}\n</script>\n\n<template>\n <ElSelect\n ref=\"selectRef\"\n v-bind=\"selectProps\"\n @click=\"handleTriggerClick\"\n @clear=\"clearValue\"\n @remove-tag=\"handleRemoveTag\"\n @visible-change=\"handleVisibleChange\"\n >\n <ElOption\n v-for=\"option of displayOptions\"\n :key=\"typeof option.value === 'object' ? JSON.stringify(option.value) : String(option.value)\"\n :label=\"option.label\"\n :value=\"option.value\"\n :disabled=\"option.disabled\"\n />\n <template v-if=\"slots.prefix\" #prefix>\n <slot name=\"prefix\" />\n </template>\n <template v-if=\"slots.empty\" #empty>\n <slot name=\"empty\" />\n </template>\n <template v-if=\"slots.tag\" #tag>\n <slot name=\"tag\" />\n </template>\n <template v-if=\"slots.loading\" #loading>\n <slot name=\"loading\" />\n </template>\n <template v-if=\"slots.label\" #label=\"{ label, value }\">\n <slot name=\"label\" :label=\"label\" :value=\"value\" />\n </template>\n </ElSelect>\n</template>\n"],"mapp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