sard 1.1.0 → 1.2.1
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/.DS_Store +0 -0
- package/README.md +1 -2
- package/all-components.js +2 -0
- package/components/action-sheet/action-sheet-item.vue.js +1 -1
- package/components/action-sheet/common.d.ts +1 -1
- package/components/button/button.vue.js +1 -1
- package/components/calendar-popout/common.d.ts +1 -1
- package/components/cascader-popout/common.d.ts +1 -1
- package/components/checkbox-popout/common.d.ts +1 -1
- package/components/color-picker-popout/common.d.ts +1 -1
- package/components/crop-image/common.d.ts +1 -1
- package/components/danmaku/index.css +1 -1
- package/components/datetime-picker-popout/common.d.ts +1 -1
- package/components/datetime-range-picker-popout/common.d.ts +1 -1
- package/components/descriptions/common.d.ts +8 -3
- package/components/descriptions/descriptions-item.vue.d.ts +0 -2
- package/components/descriptions/descriptions-item.vue.js +20 -21
- package/components/descriptions/descriptions.vue.js +56 -28
- package/components/descriptions/index.css +1 -1
- package/components/dialog/common.d.ts +1 -1
- package/components/dnd/dnd-item.vue.js +19 -9
- package/components/dnd/index.css +1 -1
- package/components/dropdown/common.d.ts +1 -1
- package/components/ellipsis/ellipsis.vue.js +62 -58
- package/components/ellipsis/index.css +1 -1
- package/components/image/image.vue.d.ts +1 -1
- package/components/index.d.ts +1 -0
- package/components/index.js +2 -1
- package/components/keyboard/keyboard.vue.d.ts +1 -1
- package/components/keyboard-popout/common.d.ts +1 -1
- package/components/keyboard-popout/keyboard-popout.vue.d.ts +1 -1
- package/components/list/index.css +1 -1
- package/components/load-more/load-more.vue.js +2 -2
- package/components/loading/loading.vue.js +1 -1
- package/components/motion/motion.vue.js +1 -1
- package/components/notify/common.d.ts +1 -1
- package/components/overlay/overlay.vue.js +6 -5
- package/components/picker/picker.vue.js +8 -5
- package/components/picker-popout/common.d.ts +1 -1
- package/components/picker-view/common.d.ts +22 -2
- package/components/picker-view/index.d.ts +2 -2
- package/components/picker-view/index.js +2 -2
- package/components/picker-view/picker-view-column.vue.d.ts +19 -0
- package/components/picker-view/picker-view-column.vue.js +167 -0
- package/components/picker-view/picker-view.vue.d.ts +55 -0
- package/components/picker-view/picker-view.vue.js +60 -0
- package/components/popout/common.d.ts +1 -1
- package/components/popout/popout.vue.js +2 -4
- package/components/popover/popover.vue.js +11 -10
- package/components/popup/popup.vue.js +1 -1
- package/components/preview-image/common.d.ts +1 -1
- package/components/preview-image/preview-image.vue.js +4 -4
- package/components/pull-down-refresh/pull-down-refresh.vue.js +4 -7
- package/components/radio-popout/common.d.ts +1 -1
- package/components/rate/rate.vue.js +2 -2
- package/components/select-popout/common.d.ts +1 -1
- package/components/share-sheet/common.d.ts +1 -1
- package/components/skeleton/skeleton.vue.js +1 -1
- package/components/swiper/index.d.ts +2 -2
- package/components/swiper/index.js +2 -2
- package/components/swiper/swiper-item.vue.d.ts +11 -0
- package/components/swiper/swiper-item.vue.js +32 -0
- package/components/swiper/swiper.vue.d.ts +147 -0
- package/components/swiper/swiper.vue.js +51 -0
- package/components/swiper/useSwiper.d.ts +1 -2
- package/components/swiper/useSwiper.js +12 -12
- package/components/table/table.vue.js +1 -2
- package/components/text-shrink/common.d.ts +28 -0
- package/components/text-shrink/common.js +8 -0
- package/components/text-shrink/index.css +1 -0
- package/components/text-shrink/index.d.ts +5 -0
- package/components/text-shrink/index.js +6 -0
- package/components/text-shrink/text-shrink.vue.d.ts +16 -0
- package/components/text-shrink/text-shrink.vue.js +252 -0
- package/components/toast/common.d.ts +1 -1
- package/global.d.ts +1 -0
- package/index.css +1 -1
- package/index.js +2 -2
- package/package.json +1 -1
- package/utils/createImperativeComponent.d.ts +12 -5
- package/utils/createImperativeComponent.js +13 -37
- package/utils/imperative/agent-runtime.d.ts +28 -0
- package/utils/imperative/agent-runtime.js +33 -0
- package/utils/imperative/imperative-agent.vue.d.ts +35 -0
- package/utils/imperative/imperative-agent.vue.js +60 -0
- package/utils/index.d.ts +0 -1
- package/utils/index.js +1 -2
- package/utils/is.d.ts +4 -1
- package/utils/is.js +5 -3
- package/utils/number.d.ts +1 -1
- package/utils/number.js +20 -19
- package/components/picker-view/picker-view-column.d.ts +0 -3
- package/components/picker-view/picker-view-column.js +0 -139
- package/components/picker-view/picker-view.d.ts +0 -21
- package/components/picker-view/picker-view.js +0 -57
- package/components/swiper/swiper-item.d.ts +0 -3
- package/components/swiper/swiper-item.js +0 -34
- package/components/swiper/swiper.d.ts +0 -57
- package/components/swiper/swiper.js +0 -43
- package/utils/vnode.d.ts +0 -9
- package/utils/vnode.js +0 -69
package/.DS_Store
ADDED
|
Binary file
|
package/README.md
CHANGED
package/all-components.js
CHANGED
|
@@ -113,6 +113,7 @@ import { Table } from "./components/table/index.js";
|
|
|
113
113
|
import { Tab, Tabs } from "./components/tabs/index.js";
|
|
114
114
|
import { Tag } from "./components/tag/index.js";
|
|
115
115
|
import { Text } from "./components/text/index.js";
|
|
116
|
+
import { TextShrink } from "./components/text-shrink/index.js";
|
|
116
117
|
import { Timeline, TimelineItem } from "./components/timeline/index.js";
|
|
117
118
|
import { Toast } from "./components/toast/index.js";
|
|
118
119
|
import { Tree, TreeBranch, TreeNode } from "./components/tree/index.js";
|
|
@@ -273,6 +274,7 @@ var all_components_default = {
|
|
|
273
274
|
Tabs,
|
|
274
275
|
Tag,
|
|
275
276
|
Text,
|
|
277
|
+
TextShrink,
|
|
276
278
|
Timeline,
|
|
277
279
|
TimelineItem,
|
|
278
280
|
Toast,
|
|
@@ -57,7 +57,7 @@ var action_sheet_item_default = /*@__PURE__*/ defineComponent({
|
|
|
57
57
|
unref(bem).is("loading", props.loading)
|
|
58
58
|
]),
|
|
59
59
|
onClick
|
|
60
|
-
}, [!props.loading ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [slots.default ? renderSlot(_ctx.$slots, "default", {
|
|
60
|
+
}, [!props.loading ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [slots.default ? renderSlot(_ctx.$slots, "default", {}, void 0, void 0, 0) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createElementVNode("div", {
|
|
61
61
|
class: normalizeClass(unref(bem).e("item-label")),
|
|
62
62
|
style: normalizeStyle(labelStyle.value)
|
|
63
63
|
}, [renderSlot(_ctx.$slots, "label", {}, () => [createTextVNode(toDisplayString(props.label), 1)])], 6), props.description || slots.description ? (openBlock(), createElementBlock("div", {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type DefaultProps } from '../config';
|
|
2
|
-
import type { MotionEmits } from '../motion';
|
|
2
|
+
import type { MotionEmits } from '../motion/common';
|
|
3
3
|
import { type UseActionSheetReturn } from './context';
|
|
4
4
|
export interface ActionSheetBeforeClose {
|
|
5
5
|
(type: 'close' | 'cancel', loading: {
|
|
@@ -110,7 +110,7 @@ var button_default = /*@__PURE__*/ defineComponent({
|
|
|
110
110
|
}, [__props.loading ? (openBlock(), createBlock(loading_default, {
|
|
111
111
|
key: 0,
|
|
112
112
|
type: __props.loadingType
|
|
113
|
-
}, null, 8, ["type"])) : renderSlot(_ctx.$slots, "icon", {
|
|
113
|
+
}, null, 8, ["type"])) : renderSlot(_ctx.$slots, "icon", {}, void 0, void 0, 1)], 2)) : createCommentVNode("v-if", true), renderSlot(_ctx.$slots, "default")], 42, _hoisted_1);
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
116
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type CalendarProps } from '../calendar/common';
|
|
2
2
|
import { type DefaultProps } from '../config';
|
|
3
3
|
import { type FormPopoutProps } from '../popout/useFormPopout';
|
|
4
|
-
import type { MotionEmits } from '../motion';
|
|
4
|
+
import type { MotionEmits } from '../motion/common';
|
|
5
5
|
export interface CalendarPopoutProps extends FormPopoutProps, CalendarProps {
|
|
6
6
|
}
|
|
7
7
|
export declare const defaultCalendarPopoutProps: DefaultProps<CalendarPopoutProps>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type CascaderOption, type CascaderProps } from '../cascader/common';
|
|
2
2
|
import { type DefaultProps } from '../config';
|
|
3
3
|
import { type FormPopoutProps } from '../popout/useFormPopout';
|
|
4
|
-
import type { MotionEmits } from '../motion';
|
|
4
|
+
import type { MotionEmits } from '../motion/common';
|
|
5
5
|
export interface CascaderPopoutProps extends FormPopoutProps, CascaderProps {
|
|
6
6
|
}
|
|
7
7
|
export declare const defaultCascaderPopoutProps: DefaultProps<CascaderPopoutProps>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type CheckboxGroupProps } from '../checkbox/common';
|
|
2
2
|
import { type DefaultProps } from '../config';
|
|
3
3
|
import { type FormPopoutProps } from '../popout/useFormPopout';
|
|
4
|
-
import type { MotionEmits } from '../motion';
|
|
4
|
+
import type { MotionEmits } from '../motion/common';
|
|
5
5
|
export interface CheckboxPopoutProps extends FormPopoutProps, CheckboxGroupProps {
|
|
6
6
|
searchable?: boolean;
|
|
7
7
|
filterPlaceholder?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type DefaultProps } from '../config';
|
|
2
2
|
import { type FormPopoutProps } from '../popout/useFormPopout';
|
|
3
3
|
import { type ColorPickerProps } from '../color-picker/common';
|
|
4
|
-
import type { MotionEmits } from '../motion';
|
|
4
|
+
import type { MotionEmits } from '../motion/common';
|
|
5
5
|
export interface ColorPickerPopoutProps extends FormPopoutProps, ColorPickerProps {
|
|
6
6
|
}
|
|
7
7
|
export declare const defaultColorPickerPopoutProps: DefaultProps<ColorPickerPopoutProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:root{--s-danmaku-row-height:34px}.s-danmaku{position:relative;overflow:hidden}.s-danmaku__track{position:relative;height:var(--s-danmaku-row-height)}.s-danmaku__item{position:absolute;top:50%;left:0;white-space:nowrap;will-change:transform;transform:translate3d(100vw, -50%, 0)}:root[dir=rtl] .s-danmaku__item{transform:translate3d(-100vw, -50%, 0)}
|
|
1
|
+
:root{--s-danmaku-row-height:34px}.s-danmaku{position:relative;overflow:hidden}.s-danmaku__track{position:relative;height:var(--s-danmaku-row-height)}.s-danmaku__item{position:absolute;top:50%;left:0;white-space:nowrap;will-change:transform;transform:translate3d(100vw, -50%, 0);opacity:0;animation:s-danmaku-item-reveal .12s linear .15s forwards}:root[dir=rtl] .s-danmaku__item{transform:translate3d(-100vw, -50%, 0)}@keyframes s-danmaku-item-reveal{to{opacity:1}}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type DatetimePickerProps, type DatetimePickerSlots } from '../datetime-picker/common';
|
|
2
2
|
import { type DefaultProps } from '../config';
|
|
3
3
|
import { type FormPopoutProps } from '../popout/useFormPopout';
|
|
4
|
-
import type { MotionEmits } from '../motion';
|
|
4
|
+
import type { MotionEmits } from '../motion/common';
|
|
5
5
|
export interface DatetimePickerPopoutProps extends FormPopoutProps, DatetimePickerProps {
|
|
6
6
|
}
|
|
7
7
|
export declare const defaultDatetimePickerPopoutProps: DefaultProps<DatetimePickerPopoutProps>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type DatetimeRangePickerProps, type DatetimeRangePickerSlots } from '../datetime-range-picker/common';
|
|
2
2
|
import { type DefaultProps } from '../config';
|
|
3
3
|
import { type FormPopoutProps } from '../popout/useFormPopout';
|
|
4
|
-
import type { MotionEmits } from '../motion';
|
|
4
|
+
import type { MotionEmits } from '../motion/common';
|
|
5
5
|
export interface DatetimeRangePickerPopoutProps extends FormPopoutProps, DatetimeRangePickerProps {
|
|
6
6
|
}
|
|
7
7
|
export declare const defaultDatetimeRangePickerPopoutProps: DefaultProps<DatetimeRangePickerPopoutProps>;
|
|
@@ -14,21 +14,26 @@ export interface DescriptionsSlots {
|
|
|
14
14
|
}
|
|
15
15
|
export interface DescriptionsEmits {
|
|
16
16
|
}
|
|
17
|
+
export interface DescriptionsItemMeta {
|
|
18
|
+
colspan: () => number;
|
|
19
|
+
rowspan: () => number;
|
|
20
|
+
}
|
|
17
21
|
export interface DescriptionsContext {
|
|
18
22
|
bordered?: boolean;
|
|
19
23
|
colon?: boolean;
|
|
20
24
|
labelWidth?: string;
|
|
21
25
|
labelAlign?: DescriptionsAlign;
|
|
26
|
+
/** 注册一个描述项,返回注销函数 */
|
|
27
|
+
registerItem: (meta: DescriptionsItemMeta) => () => void;
|
|
28
|
+
/** 获取某个描述项内容格的列跨度 */
|
|
29
|
+
getContentSpan: (meta: DescriptionsItemMeta) => number | undefined;
|
|
22
30
|
}
|
|
23
31
|
export declare const descriptionsContextKey: InjectionKey<DescriptionsContext>;
|
|
24
32
|
export interface DescriptionsItemProps {
|
|
25
33
|
label?: string;
|
|
26
34
|
colspan?: number;
|
|
27
35
|
rowspan?: number;
|
|
28
|
-
labelWidth?: string;
|
|
29
36
|
labelAlign?: DescriptionsAlign;
|
|
30
|
-
/** @internal set by Descriptions for last item in incomplete rows */
|
|
31
|
-
contentColspan?: number;
|
|
32
37
|
}
|
|
33
38
|
export declare const defaultDescriptionsItemProps: DefaultProps<DescriptionsItemProps>;
|
|
34
39
|
export interface DescriptionsItemSlots {
|
|
@@ -3,10 +3,8 @@ type __VLS_Slots = DescriptionsItemSlots;
|
|
|
3
3
|
declare const __VLS_base: import("vue").DefineComponent<DescriptionsItemProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<DescriptionsItemProps> & Readonly<{}>, {
|
|
4
4
|
label: string;
|
|
5
5
|
colspan: number;
|
|
6
|
-
labelWidth: string;
|
|
7
6
|
labelAlign: import("./common").DescriptionsAlign;
|
|
8
7
|
rowspan: number;
|
|
9
|
-
contentColspan: number;
|
|
10
8
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
11
9
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
12
10
|
declare const _default: typeof __VLS_export;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { createBem } from "../../utils/bem.js";
|
|
2
2
|
import { defaultDescriptionsItemProps, descriptionsContextKey } from "./common.js";
|
|
3
|
-
import { Fragment, computed, createElementBlock, createElementVNode, createTextVNode, defineComponent, inject, mergeDefaults, normalizeClass, normalizeStyle, openBlock, renderSlot, toDisplayString } from "vue";
|
|
3
|
+
import { Fragment, computed, createElementBlock, createElementVNode, createTextVNode, defineComponent, inject, mergeDefaults, normalizeClass, normalizeStyle, onUnmounted, openBlock, renderSlot, toDisplayString } from "vue";
|
|
4
4
|
//#region packages/sard/components/descriptions/descriptions-item.vue
|
|
5
|
-
const _hoisted_1 = ["rowspan"];
|
|
6
|
-
const _hoisted_2 = ["colspan", "rowspan"];
|
|
7
5
|
var descriptions_item_default = /*@__PURE__*/ defineComponent({
|
|
8
6
|
__name: "descriptions-item",
|
|
9
7
|
props: /*@__PURE__*/ mergeDefaults({
|
|
@@ -19,17 +17,9 @@ var descriptions_item_default = /*@__PURE__*/ defineComponent({
|
|
|
19
17
|
type: Number,
|
|
20
18
|
required: false
|
|
21
19
|
},
|
|
22
|
-
labelWidth: {
|
|
23
|
-
type: String,
|
|
24
|
-
required: false
|
|
25
|
-
},
|
|
26
20
|
labelAlign: {
|
|
27
21
|
type: String,
|
|
28
22
|
required: false
|
|
29
|
-
},
|
|
30
|
-
contentColspan: {
|
|
31
|
-
type: Number,
|
|
32
|
-
required: false
|
|
33
23
|
}
|
|
34
24
|
}, defaultDescriptionsItemProps),
|
|
35
25
|
setup(__props) {
|
|
@@ -39,15 +29,27 @@ var descriptions_item_default = /*@__PURE__*/ defineComponent({
|
|
|
39
29
|
if (!context) throw new Error("DescriptionsItem must be included in Descriptions.");
|
|
40
30
|
const colspan = computed(() => props.colspan ?? 1);
|
|
41
31
|
const rowspan = computed(() => props.rowspan ?? 1);
|
|
42
|
-
const
|
|
43
|
-
|
|
32
|
+
const meta = {
|
|
33
|
+
colspan: () => colspan.value,
|
|
34
|
+
rowspan: () => rowspan.value
|
|
35
|
+
};
|
|
36
|
+
onUnmounted(context.registerItem(meta));
|
|
37
|
+
const contentSpan = computed(() => {
|
|
38
|
+
return context.getContentSpan(meta) ?? colspan.value * 2 - 1;
|
|
39
|
+
});
|
|
44
40
|
const effectiveLabelAlign = computed(() => props.labelAlign ?? context.labelAlign);
|
|
45
41
|
const labelStyle = computed(() => {
|
|
46
42
|
const style = {};
|
|
47
|
-
if (
|
|
43
|
+
if (context.labelWidth) style.width = context.labelWidth;
|
|
48
44
|
if (effectiveLabelAlign.value) style.textAlign = effectiveLabelAlign.value;
|
|
45
|
+
if (rowspan.value > 1) style.gridRow = `span ${rowspan.value}`;
|
|
49
46
|
return Object.keys(style).length ? style : void 0;
|
|
50
47
|
});
|
|
48
|
+
const contentStyle = computed(() => {
|
|
49
|
+
const style = { "--s-descriptions-content-span": String(contentSpan.value) };
|
|
50
|
+
if (rowspan.value > 1) style.gridRow = `span ${rowspan.value}`;
|
|
51
|
+
return style;
|
|
52
|
+
});
|
|
51
53
|
const labelCellClass = computed(() => {
|
|
52
54
|
return [
|
|
53
55
|
bem.e("item-label"),
|
|
@@ -59,16 +61,13 @@ var descriptions_item_default = /*@__PURE__*/ defineComponent({
|
|
|
59
61
|
return [bem.e("item-content"), bem.is("bordered", context.bordered)];
|
|
60
62
|
});
|
|
61
63
|
return (_ctx, _cache) => {
|
|
62
|
-
return openBlock(), createElementBlock(Fragment, null, [createElementVNode("
|
|
64
|
+
return openBlock(), createElementBlock(Fragment, null, [createElementVNode("div", {
|
|
63
65
|
class: normalizeClass(labelCellClass.value),
|
|
64
|
-
colspan: "1",
|
|
65
|
-
rowspan: rowspan.value,
|
|
66
66
|
style: normalizeStyle(labelStyle.value)
|
|
67
|
-
}, [renderSlot(_ctx.$slots, "label", {}, () => [createTextVNode(toDisplayString(__props.label), 1)])],
|
|
67
|
+
}, [renderSlot(_ctx.$slots, "label", {}, () => [createTextVNode(toDisplayString(__props.label), 1)])], 6), createElementVNode("div", {
|
|
68
68
|
class: normalizeClass(contentCellClass.value),
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}, [renderSlot(_ctx.$slots, "default")], 10, _hoisted_2)], 64);
|
|
69
|
+
style: normalizeStyle(contentStyle.value)
|
|
70
|
+
}, [renderSlot(_ctx.$slots, "default")], 6)], 64);
|
|
72
71
|
};
|
|
73
72
|
}
|
|
74
73
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createBem } from "../../utils/bem.js";
|
|
2
|
-
import { flatVNode } from "../../utils/vnode.js";
|
|
3
2
|
import { defaultDescriptionsProps, descriptionsContextKey } from "./common.js";
|
|
4
|
-
import {
|
|
3
|
+
import { computed, createElementBlock, defineComponent, mergeDefaults, normalizeClass, normalizeStyle, openBlock, provide, reactive, ref, renderSlot, toRef } from "vue";
|
|
5
4
|
//#region packages/sard/components/descriptions/descriptions.vue
|
|
6
5
|
var descriptions_default = /*@__PURE__*/ defineComponent({
|
|
7
6
|
__name: "descriptions",
|
|
@@ -30,24 +29,36 @@ var descriptions_default = /*@__PURE__*/ defineComponent({
|
|
|
30
29
|
setup(__props) {
|
|
31
30
|
const props = __props;
|
|
32
31
|
const bem = createBem("descriptions");
|
|
33
|
-
provide(descriptionsContextKey, reactive({
|
|
34
|
-
bordered: toRef(() => props.bordered),
|
|
35
|
-
colon: toRef(() => props.colon),
|
|
36
|
-
labelWidth: toRef(() => props.labelWidth),
|
|
37
|
-
labelAlign: toRef(() => props.labelAlign)
|
|
38
|
-
}));
|
|
39
|
-
const slots = useSlots();
|
|
40
32
|
const columns = computed(() => props.columns ?? 1);
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
const items = [];
|
|
34
|
+
const registeredVersion = ref(0);
|
|
35
|
+
function registerItem(meta) {
|
|
36
|
+
items.push(meta);
|
|
37
|
+
registeredVersion.value++;
|
|
38
|
+
return () => {
|
|
39
|
+
const index = items.indexOf(meta);
|
|
40
|
+
if (index !== -1) {
|
|
41
|
+
items.splice(index, 1);
|
|
42
|
+
registeredVersion.value++;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 计算每个描述项内容格的列跨度。
|
|
48
|
+
* 一个描述项占 `colspan * 2` 列(标签 1 列 + 内容 `colspan * 2 - 1` 列),
|
|
49
|
+
* 最后一项的内容会填满当前行剩余列。
|
|
50
|
+
*/
|
|
51
|
+
const contentSpans = computed(() => {
|
|
52
|
+
registeredVersion.value;
|
|
53
|
+
const spans = /* @__PURE__ */ new Map();
|
|
54
|
+
const columnCount = columns.value;
|
|
44
55
|
const result = [];
|
|
45
56
|
let temp = [];
|
|
46
|
-
let count =
|
|
57
|
+
let count = columnCount;
|
|
47
58
|
const rowspanTemp = [];
|
|
48
|
-
|
|
49
|
-
const nodeColspan =
|
|
50
|
-
const nodeRowspan =
|
|
59
|
+
items.forEach((meta, index) => {
|
|
60
|
+
const nodeColspan = meta.colspan();
|
|
61
|
+
const nodeRowspan = meta.rowspan();
|
|
51
62
|
let rowNo = result.length;
|
|
52
63
|
rowspanTemp[rowNo] ||= 0;
|
|
53
64
|
if (nodeRowspan > 1) for (let i = 1; i < nodeRowspan; i++) {
|
|
@@ -60,28 +71,42 @@ var descriptions_default = /*@__PURE__*/ defineComponent({
|
|
|
60
71
|
if (count <= 0) {
|
|
61
72
|
result.push(temp);
|
|
62
73
|
temp = [];
|
|
63
|
-
count =
|
|
74
|
+
count = columnCount;
|
|
64
75
|
rowNo++;
|
|
65
76
|
}
|
|
66
77
|
}
|
|
67
|
-
if (index ===
|
|
68
|
-
|
|
78
|
+
if (index === items.length - 1) {
|
|
79
|
+
spans.set(meta, (nodeColspan < count ? count : nodeColspan) * 2 - 1);
|
|
80
|
+
temp.push(index);
|
|
69
81
|
result.push(temp);
|
|
70
82
|
return;
|
|
71
83
|
}
|
|
72
84
|
if (nodeColspan < count) {
|
|
73
85
|
count -= nodeColspan;
|
|
74
|
-
|
|
86
|
+
spans.set(meta, nodeColspan * 2 - 1);
|
|
87
|
+
temp.push(index);
|
|
75
88
|
} else {
|
|
76
89
|
const span = Math.min(nodeColspan, count);
|
|
77
|
-
|
|
90
|
+
spans.set(meta, span * 2 - 1);
|
|
91
|
+
temp.push(index);
|
|
78
92
|
result.push(temp);
|
|
79
|
-
count =
|
|
93
|
+
count = columnCount;
|
|
80
94
|
temp = [];
|
|
81
95
|
}
|
|
82
96
|
});
|
|
83
|
-
return
|
|
97
|
+
return spans;
|
|
84
98
|
});
|
|
99
|
+
function getContentSpan(meta) {
|
|
100
|
+
return contentSpans.value.get(meta);
|
|
101
|
+
}
|
|
102
|
+
provide(descriptionsContextKey, reactive({
|
|
103
|
+
bordered: toRef(() => props.bordered),
|
|
104
|
+
colon: toRef(() => props.colon),
|
|
105
|
+
labelWidth: toRef(() => props.labelWidth),
|
|
106
|
+
labelAlign: toRef(() => props.labelAlign),
|
|
107
|
+
registerItem,
|
|
108
|
+
getContentSpan
|
|
109
|
+
}));
|
|
85
110
|
const descriptionsClass = computed(() => {
|
|
86
111
|
return [
|
|
87
112
|
bem.b(),
|
|
@@ -89,12 +114,15 @@ var descriptions_default = /*@__PURE__*/ defineComponent({
|
|
|
89
114
|
bem.has("colon", props.colon)
|
|
90
115
|
];
|
|
91
116
|
});
|
|
117
|
+
const descriptionsStyle = computed(() => {
|
|
118
|
+
const labelWidth = props.labelWidth;
|
|
119
|
+
return { gridTemplateColumns: labelWidth ? `repeat(${columns.value}, ${labelWidth} minmax(0, 1fr))` : `repeat(${columns.value * 2}, minmax(0, 1fr))` };
|
|
120
|
+
});
|
|
92
121
|
return (_ctx, _cache) => {
|
|
93
|
-
return openBlock(), createElementBlock("
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}), 128))])], 2);
|
|
122
|
+
return openBlock(), createElementBlock("div", {
|
|
123
|
+
class: normalizeClass(descriptionsClass.value),
|
|
124
|
+
style: normalizeStyle(descriptionsStyle.value)
|
|
125
|
+
}, [renderSlot(_ctx.$slots, "default")], 6);
|
|
98
126
|
};
|
|
99
127
|
}
|
|
100
128
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:root{--s-descriptions-label-color:var(--s-text-color-tertiary);--s-descriptions-label-font-size:var(--s-font-size);--s-descriptions-label-bg:var(--s-fill-color-fourth);--s-descriptions-content-color:var(--s-text-color-primary);--s-descriptions-content-font-size:var(--s-font-size);--s-descriptions-item-padding-y:var(--s-size-xs);--s-descriptions-item-padding-x:var(--s-size-sm);--s-descriptions-border-color:var(--s-border-color)}.s-descriptions{width:100%;
|
|
1
|
+
:root{--s-descriptions-label-color:var(--s-text-color-tertiary);--s-descriptions-label-font-size:var(--s-font-size);--s-descriptions-label-bg:var(--s-fill-color-fourth);--s-descriptions-content-color:var(--s-text-color-primary);--s-descriptions-content-font-size:var(--s-font-size);--s-descriptions-item-padding-y:var(--s-size-xs);--s-descriptions-item-padding-x:var(--s-size-sm);--s-descriptions-border-color:var(--s-border-color)}.s-descriptions{display:grid;width:100%;column-gap:var(--s-descriptions-item-padding-x);row-gap:var(--s-descriptions-item-padding-y)}.s-descriptions:is(.is-bordered){column-gap:0;row-gap:0;border-block-start:var(--s-border-width) solid var(--s-descriptions-border-color);border-inline-start:var(--s-border-width) solid var(--s-descriptions-border-color)}.s-descriptions__item-label{color:var(--s-descriptions-label-color);font-size:var(--s-descriptions-label-font-size);word-break:break-word}.s-descriptions__item-label:is(.is-bordered){padding:var(--s-descriptions-item-padding-y) var(--s-descriptions-item-padding-x);border-inline-end:var(--s-border-width) solid var(--s-descriptions-border-color);border-block-end:var(--s-border-width) solid var(--s-descriptions-border-color);background:var(--s-descriptions-label-bg)}.s-descriptions__item-label:is(.has-colon)::after{content:":"}.s-descriptions__item-content{grid-column:span var(--s-descriptions-content-span, 1);color:var(--s-descriptions-content-color);font-size:var(--s-descriptions-content-font-size);word-break:break-word}.s-descriptions__item-content:is(.is-bordered){padding:var(--s-descriptions-item-padding-y) var(--s-descriptions-item-padding-x);border-inline-end:var(--s-border-width) solid var(--s-descriptions-border-color);border-block-end:var(--s-border-width) solid var(--s-descriptions-border-color)}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type DefaultProps } from '../config';
|
|
2
2
|
import { type ButtonProps } from '../button';
|
|
3
|
-
import type { MotionEmits } from '../motion';
|
|
3
|
+
import type { MotionEmits } from '../motion/common';
|
|
4
4
|
export type DialogBeforeClose = (type: 'close' | 'cancel' | 'confirm', loading: {
|
|
5
5
|
readonly cancel: boolean;
|
|
6
6
|
readonly confirm: boolean;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createBem } from "../../utils/bem.js";
|
|
2
|
-
import { OnlyChild } from "../../utils/vnode.js";
|
|
3
2
|
import { dndContextKey, dndItemContextKey } from "./common.js";
|
|
4
|
-
import { computed,
|
|
3
|
+
import { computed, createElementBlock, defineComponent, inject, normalizeClass, onBeforeUnmount, onMounted, onUpdated, openBlock, provide, ref, renderSlot, shallowRef, useAttrs, useTemplateRef, watchPostEffect } from "vue";
|
|
5
4
|
//#region packages/sard/components/dnd/dnd-item.vue
|
|
6
5
|
var dnd_item_default = /*@__PURE__*/ defineComponent({
|
|
7
6
|
__name: "dnd-item",
|
|
@@ -14,9 +13,19 @@ var dnd_item_default = /*@__PURE__*/ defineComponent({
|
|
|
14
13
|
const bem = createBem("dnd-item");
|
|
15
14
|
const dndContext = inject(dndContextKey);
|
|
16
15
|
if (!dndContext) throw new Error("DndItem must be included in Dnd.");
|
|
16
|
+
const wrapperRef = useTemplateRef("wrapperRef");
|
|
17
17
|
const elRef = shallowRef(null);
|
|
18
|
-
const
|
|
18
|
+
const attrs = useAttrs();
|
|
19
|
+
let forwardedClass = "";
|
|
20
|
+
const syncElRef = () => {
|
|
21
|
+
const wrapper = wrapperRef.value;
|
|
22
|
+
const el = wrapper?.firstElementChild ?? wrapper ?? null;
|
|
19
23
|
elRef.value = el;
|
|
24
|
+
if (!el) return;
|
|
25
|
+
const next = normalizeClass(attrs.class);
|
|
26
|
+
for (const name of forwardedClass.split(" ")) if (name) el.classList.remove(name);
|
|
27
|
+
for (const name of next.split(" ")) if (name) el.classList.add(name);
|
|
28
|
+
forwardedClass = next;
|
|
20
29
|
};
|
|
21
30
|
let dropItemInfo = null;
|
|
22
31
|
let currentIndex = -1;
|
|
@@ -26,8 +35,10 @@ var dnd_item_default = /*@__PURE__*/ defineComponent({
|
|
|
26
35
|
return elRef.value.getBoundingClientRect();
|
|
27
36
|
};
|
|
28
37
|
onMounted(() => {
|
|
38
|
+
syncElRef();
|
|
29
39
|
dndContext.addRectItem(getNodeRect);
|
|
30
40
|
});
|
|
41
|
+
onUpdated(syncElRef);
|
|
31
42
|
onBeforeUnmount(() => {
|
|
32
43
|
dndContext.removeRectItem(getNodeRect);
|
|
33
44
|
});
|
|
@@ -117,13 +128,12 @@ var dnd_item_default = /*@__PURE__*/ defineComponent({
|
|
|
117
128
|
});
|
|
118
129
|
__expose({});
|
|
119
130
|
return (_ctx, _cache) => {
|
|
120
|
-
return openBlock(),
|
|
131
|
+
return openBlock(), createElementBlock("span", {
|
|
132
|
+
ref_key: "wrapperRef",
|
|
133
|
+
ref: wrapperRef,
|
|
121
134
|
class: normalizeClass(dndItemClass.value),
|
|
122
|
-
|
|
123
|
-
},
|
|
124
|
-
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
125
|
-
_: 3
|
|
126
|
-
}, 8, ["class"]);
|
|
135
|
+
style: { "display": "contents" }
|
|
136
|
+
}, [renderSlot(_ctx.$slots, "default")], 2);
|
|
127
137
|
};
|
|
128
138
|
}
|
|
129
139
|
});
|
package/components/dnd/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.s-dnd-item{position:relative}.s-dnd-item--active{z-index:1;box-shadow:var(--s-box-shadow-secondary)}.s-dnd-item--passive{transition:transform var(--s-duration)}.s-dnd-handle{cursor:pointer;-webkit-user-select:none;user-select:none}.s-dnd-handle--dragging{touch-action:none}
|
|
1
|
+
.s-dnd-item{border-radius:inherit}.s-dnd-item>*{position:relative}.s-dnd-item--active>*{z-index:1;box-shadow:var(--s-box-shadow-secondary)}.s-dnd-item--passive>*{transition:transform var(--s-duration)}.s-dnd-handle{cursor:pointer;-webkit-user-select:none;user-select:none}.s-dnd-handle--dragging{touch-action:none}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type InjectionKey } from 'vue';
|
|
2
2
|
import { type DefaultProps } from '../config';
|
|
3
|
-
import type { MotionEmits } from '../motion';
|
|
3
|
+
import type { MotionEmits } from '../motion/common';
|
|
4
4
|
export interface DropdownProps {
|
|
5
5
|
direction?: 'down' | 'up';
|
|
6
6
|
disabled?: boolean;
|