@sdata/web-vue 2.3.1 → 2.8.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.
Files changed (119) hide show
  1. package/README.md +1 -1
  2. package/dist/sd.css +133 -187
  3. package/dist/sd.min.css +1 -1
  4. package/es/_hooks/use-responsive.d.ts +2 -2
  5. package/es/_hooks/use-theme-mode.d.ts +3 -0
  6. package/es/{calendar/hooks/use-calendar-theme.js → _hooks/use-theme-mode.js} +14 -10
  7. package/es/_utils/responsive-observe.d.ts +5 -4
  8. package/es/_utils/responsive-observe.js +2 -1
  9. package/es/alert/index.d.ts +3 -3
  10. package/es/anchor/index.d.ts +3 -3
  11. package/es/avatar/index.d.ts +20 -20
  12. package/es/border-beam/border-beam.js +5 -0
  13. package/es/border-beam/border-beam.vue.d.ts +52 -0
  14. package/es/border-beam/border-beam.vue_vue_type_script_setup_true_lang.js +623 -0
  15. package/es/border-beam/index.d.ts +106 -0
  16. package/es/border-beam/index.js +10 -0
  17. package/es/border-beam/pulseDriver.d.ts +2 -0
  18. package/es/border-beam/pulseDriver.js +74 -0
  19. package/es/border-beam/style/css.js +2 -0
  20. package/es/border-beam/style/index.css +21 -0
  21. package/es/border-beam/style/index.d.ts +2 -0
  22. package/es/border-beam/style/index.js +2 -0
  23. package/es/border-beam/style/index.scss +12 -0
  24. package/es/border-beam/style/token.scss +12 -0
  25. package/es/border-beam/styles.d.ts +42 -0
  26. package/es/border-beam/styles.js +3545 -0
  27. package/es/border-beam/types.d.ts +27 -0
  28. package/es/button/index.d.ts +24 -24
  29. package/es/calendar/components/index.vue.d.ts +1 -1
  30. package/es/calendar/components/index.vue_vue_type_script_setup_true_lang.js +3 -2
  31. package/es/calendar/index.d.ts +5 -5
  32. package/es/carousel/index.d.ts +3 -3
  33. package/es/checkbox/checkbox.d.ts +3 -3
  34. package/es/collapse/collapse-item.d.ts +5 -5
  35. package/es/collapse/index.d.ts +3 -3
  36. package/es/components.d.ts +1 -0
  37. package/es/config-provider/index.d.ts +21 -21
  38. package/es/date-picker/index.d.ts +14 -14
  39. package/es/date-picker/picker.vue.d.ts +2 -2
  40. package/es/date-picker/range-picker.vue.d.ts +2 -2
  41. package/es/descriptions/index.d.ts +24 -24
  42. package/es/drawer/index.d.ts +16 -15
  43. package/es/dropdown/index.d.ts +15 -15
  44. package/es/form/form-item.vue_vue_type_script_setup_true_lang.js +3 -3
  45. package/es/form/index.d.ts +3 -3
  46. package/es/grid/grid-col.vue_vue_type_script_setup_true_lang.js +2 -2
  47. package/es/grid/grid.vue_vue_type_script_setup_true_lang.js +10 -10
  48. package/es/icon/icon-menu/icon-menu.js +5 -0
  49. package/es/icon/icon-menu/icon-menu.vue_vue_type_script_setup_true_lang.js +52 -0
  50. package/es/icon/icon-menu/index.js +9 -0
  51. package/es/index.css +133 -187
  52. package/es/index.d.ts +4 -2
  53. package/es/index.js +3 -2
  54. package/es/index.scss +1 -0
  55. package/es/input/index.d.ts +7 -7
  56. package/es/json-form/index.d.ts +9 -9
  57. package/es/json-form/json-form-item.vue_vue_type_script_setup_true_lang.js +1 -1
  58. package/es/json-form/json-form.vue.d.ts +3 -3
  59. package/es/layout/content.vue.d.ts +2 -2
  60. package/es/layout/content.vue_vue_type_script_setup_true_lang.js +8 -3
  61. package/es/layout/context.d.ts +12 -9
  62. package/es/layout/context.js +11 -3
  63. package/es/layout/footer.vue.d.ts +2 -2
  64. package/es/layout/footer.vue_vue_type_script_setup_true_lang.js +8 -3
  65. package/es/layout/header.vue.d.ts +3 -30
  66. package/es/layout/header.vue_vue_type_script_setup_true_lang.js +9 -339
  67. package/es/layout/hooks/use-has-sider.d.ts +2 -0
  68. package/es/layout/hooks/use-has-sider.js +38 -0
  69. package/es/layout/index.d.ts +120 -371
  70. package/es/layout/index.js +2 -2
  71. package/es/layout/interface.d.ts +16 -46
  72. package/es/layout/layout.vue.d.ts +4 -2
  73. package/es/layout/layout.vue_vue_type_script_setup_true_lang.js +38 -14
  74. package/es/layout/sider.vue.d.ts +68 -178
  75. package/es/layout/sider.vue_vue_type_script_setup_true_lang.js +243 -363
  76. package/es/layout/style/index.css +128 -186
  77. package/es/layout/style/index.scss +146 -234
  78. package/es/layout/style/token.scss +46 -26
  79. package/es/link/index.d.ts +6 -6
  80. package/es/list/index.d.ts +18 -18
  81. package/es/menu/base-menu.vue.d.ts +1 -1
  82. package/es/menu/base-menu.vue_vue_type_script_setup_true_lang.js +14 -14
  83. package/es/menu/item.d.ts +1 -1
  84. package/es/menu/menu.d.ts +12 -12
  85. package/es/menu/menu.js +3 -3
  86. package/es/modal/index.d.ts +15 -15
  87. package/es/popconfirm/index.d.ts +12 -12
  88. package/es/popover/index.d.ts +12 -12
  89. package/es/progress/index.d.ts +6 -6
  90. package/es/qr-code/index.d.ts +3 -3
  91. package/es/radio/radio.d.ts +3 -3
  92. package/es/resize-box/resize-box.vue_vue_type_script_setup_true_lang.js +7 -7
  93. package/es/result/index.d.ts +3 -3
  94. package/es/scrollbar/style/index.css +1 -1
  95. package/es/scrollbar/style/index.scss +4 -1
  96. package/es/sd-vue.js +3 -1
  97. package/es/select/select.d.ts +17 -17
  98. package/es/slider/index.d.ts +3 -3
  99. package/es/split/split.vue_vue_type_script_setup_true_lang.js +6 -6
  100. package/es/steps/index.d.ts +6 -6
  101. package/es/tabs/index.d.ts +6 -6
  102. package/es/tag/index.d.ts +6 -6
  103. package/es/textarea/textarea.vue_vue_type_script_setup_true_lang.js +2 -2
  104. package/es/theme-provider/index.d.ts +9 -9
  105. package/es/time-picker/index.d.ts +6 -6
  106. package/es/timeline/index.d.ts +3 -3
  107. package/es/timeline/timeline.d.ts +1 -1
  108. package/es/tooltip/index.d.ts +3 -3
  109. package/es/tour/index.d.ts +3 -3
  110. package/es/tour/tour.vue_vue_type_script_setup_true_lang.js +6 -6
  111. package/es/tree/node-switcher.vue.d.ts +1 -1
  112. package/es/tree/tree.vue_vue_type_script_setup_true_lang.js +23 -23
  113. package/json/vetur-attributes.json +27 -153
  114. package/json/vetur-tags.json +13 -43
  115. package/json/web-types.json +43 -293
  116. package/package.json +10 -10
  117. package/es/calendar/hooks/use-calendar-theme.d.ts +0 -4
  118. package/es/layout/utils.d.ts +0 -1
  119. package/es/layout/utils.js +0 -11
@@ -1,5 +1,13 @@
1
1
  //#region components/layout/context.ts
2
- var LayoutSiderInjectionKey = Symbol("LayoutSiderInjectionKey");
3
- var SiderInjectionKey = Symbol("SiderInjectionKey");
2
+ /**
3
+ * @zh Layout 上下文注入键
4
+ * @en Layout context injection key
5
+ */
6
+ var LayoutContextInjectionKey = Symbol("LayoutContext");
7
+ /**
8
+ * @zh Sider 上下文注入键
9
+ * @en Sider context injection key
10
+ */
11
+ var SiderContextInjectionKey = Symbol("SiderContext");
4
12
  //#endregion
5
- export { LayoutSiderInjectionKey, SiderInjectionKey };
13
+ export { LayoutContextInjectionKey, SiderContextInjectionKey };
@@ -1,6 +1,6 @@
1
- declare var __VLS_1: {};
1
+ declare var __VLS_8: {};
2
2
  type __VLS_Slots = {} & {
3
- default?: (props: typeof __VLS_1) => any;
3
+ default?: (props: typeof __VLS_8) => any;
4
4
  };
5
5
  declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
6
6
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -1,13 +1,18 @@
1
1
  import { _objectSpread2 } from "../_virtual/_@oxc-project_runtime@0.133.0/helpers/esm/objectSpread2.js";
2
2
  import { getPrefixCls } from "../_utils/global-config.js";
3
- import { createElementBlock, defineComponent, normalizeClass, openBlock, renderSlot } from "vue";
3
+ import { computed, createBlock, defineComponent, normalizeClass, openBlock, renderSlot, resolveDynamicComponent, withCtx } from "vue";
4
4
  //#region components/layout/footer.vue?vue&type=script&setup=true&lang.ts
5
+ var tagName = "footer";
5
6
  var footer_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent(_objectSpread2(_objectSpread2({}, { name: "LayoutFooter" }), {}, {
6
7
  __name: "footer",
7
8
  setup(__props) {
8
- const classNames = [getPrefixCls("layout-footer")];
9
+ const prefixCls = getPrefixCls("layout");
10
+ const classNames = computed(() => [`${prefixCls}-footer`]);
9
11
  return (_ctx, _cache) => {
10
- return openBlock(), createElementBlock("footer", { class: normalizeClass(classNames) }, [renderSlot(_ctx.$slots, "default")]);
12
+ return openBlock(), createBlock(resolveDynamicComponent(tagName), { class: normalizeClass(classNames.value) }, {
13
+ default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
14
+ _: 3
15
+ }, 8, ["class"]);
11
16
  };
12
17
  }
13
18
  }));
@@ -1,35 +1,8 @@
1
- import type { LayoutHeaderDensity, LayoutHeaderProps } from './interface';
2
- declare var __VLS_1: {}, __VLS_3: {}, __VLS_5: {}, __VLS_7: {}, __VLS_9: {}, __VLS_11: {};
1
+ declare var __VLS_8: {};
3
2
  type __VLS_Slots = {} & {
4
- image?: (props: typeof __VLS_1) => any;
5
- } & {
6
- prepend?: (props: typeof __VLS_3) => any;
7
- } & {
8
- title?: (props: typeof __VLS_5) => any;
9
- } & {
10
- default?: (props: typeof __VLS_7) => any;
11
- } & {
12
- append?: (props: typeof __VLS_9) => any;
13
- } & {
14
- extension?: (props: typeof __VLS_11) => any;
3
+ default?: (props: typeof __VLS_8) => any;
15
4
  };
16
- declare const __VLS_base: import("vue").DefineComponent<LayoutHeaderProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
17
- "update:modelValue": (value: boolean) => any;
18
- }, string, import("vue").PublicProps, Readonly<LayoutHeaderProps> & Readonly<{
19
- "onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
20
- }>, {
21
- flat: boolean;
22
- fixed: boolean;
23
- height: number | string;
24
- absolute: boolean;
25
- sticky: boolean;
26
- defaultVisible: boolean;
27
- location: "top" | "bottom";
28
- density: LayoutHeaderDensity;
29
- extensionHeight: number | string;
30
- floating: boolean;
31
- scrollThreshold: number | string;
32
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
5
+ declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
33
6
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
34
7
  declare const _default: typeof __VLS_export;
35
8
  export default _default;
@@ -1,348 +1,18 @@
1
1
  import { _objectSpread2 } from "../_virtual/_@oxc-project_runtime@0.133.0/helpers/esm/objectSpread2.js";
2
2
  import { getPrefixCls } from "../_utils/global-config.js";
3
- import { getElement, off, on } from "../_utils/dom.js";
4
- import { computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, getCurrentInstance, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, ref, renderSlot, toDisplayString, toRef, unref, useSlots, watch } from "vue";
3
+ import { computed, createBlock, defineComponent, normalizeClass, openBlock, renderSlot, resolveDynamicComponent, withCtx } from "vue";
5
4
  //#region components/layout/header.vue?vue&type=script&setup=true&lang.ts
6
- var _hoisted_1 = ["src"];
7
- var scrollbarViewportSelector = "[data-overlayscrollbars-viewport]";
5
+ var tagName = "header";
8
6
  var header_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent(_objectSpread2(_objectSpread2({}, { name: "LayoutHeader" }), {}, {
9
7
  __name: "header",
10
- props: {
11
- title: {},
12
- image: {},
13
- modelValue: { type: Boolean },
14
- defaultVisible: {
15
- type: Boolean,
16
- default: true
17
- },
18
- height: { default: 64 },
19
- density: { default: "default" },
20
- extended: { type: Boolean },
21
- extensionHeight: { default: 48 },
22
- collapse: { type: Boolean },
23
- flat: {
24
- type: Boolean,
25
- default: false
26
- },
27
- floating: {
28
- type: Boolean,
29
- default: false
30
- },
31
- fixed: {
32
- type: Boolean,
33
- default: false
34
- },
35
- sticky: {
36
- type: Boolean,
37
- default: false
38
- },
39
- absolute: {
40
- type: Boolean,
41
- default: false
42
- },
43
- location: { default: "top" },
44
- scrollBehavior: {},
45
- scrollTarget: {},
46
- scrollThreshold: { default: 300 }
47
- },
48
- emits: ["update:modelValue"],
49
- setup(__props, { emit: __emit }) {
50
- const props = __props;
51
- const emit = __emit;
52
- const slots = useSlots();
53
- const instance = getCurrentInstance();
54
- const prefixCls = getPrefixCls("layout-header");
55
- const scrollbarPrefixCls = getPrefixCls("scrollbar");
56
- const headerRef = ref();
57
- const modelValue = toRef(props, "modelValue");
58
- const localVisible = ref(props.defaultVisible);
59
- const currentScroll = ref(0);
60
- const isScrollingUp = ref(false);
61
- const isAtBottom = ref(false);
62
- const reachedBottomWhileScrollingDown = ref(false);
63
- const hasEnoughScrollableSpace = ref(true);
64
- const scrollTargetRef = ref(null);
65
- const isMounted = ref(false);
66
- let previousScroll = 0;
67
- let previousScrollHeight = 0;
68
- const hasModelValueProp = computed(() => {
69
- var _instance$vnode$props;
70
- return Object.hasOwn((_instance$vnode$props = instance === null || instance === void 0 ? void 0 : instance.vnode.props) !== null && _instance$vnode$props !== void 0 ? _instance$vnode$props : {}, "modelValue");
71
- });
72
- const hasExtendedProp = computed(() => {
73
- var _instance$vnode$props2;
74
- return Object.hasOwn((_instance$vnode$props2 = instance === null || instance === void 0 ? void 0 : instance.vnode.props) !== null && _instance$vnode$props2 !== void 0 ? _instance$vnode$props2 : {}, "extended");
75
- });
76
- const mergedVisible = computed(() => hasModelValueProp.value ? Boolean(modelValue.value) : localVisible.value);
77
- const setVisible = (nextVisible) => {
78
- if (nextVisible !== mergedVisible.value) {
79
- emit("update:modelValue", nextVisible);
80
- localVisible.value = nextVisible;
81
- }
82
- };
83
- watch(modelValue, (nextVisible) => {
84
- if (hasModelValueProp.value) localVisible.value = nextVisible;
85
- });
86
- const parseSize = (value, fallback) => {
87
- if (typeof value === "number") return value;
88
- if (!value) return fallback;
89
- const parsed = Number.parseFloat(value);
90
- return Number.isNaN(parsed) ? fallback : parsed;
91
- };
92
- const resolveDensityOffset = (density, baseHeight) => {
93
- if (density === "prominent") return baseHeight;
94
- if (density === "comfortable") return -8;
95
- if (density === "compact") return -16;
96
- return 0;
97
- };
98
- const isWindowTarget = (target) => "document" in target;
99
- const getScrollMetrics = (target) => {
100
- if (isWindowTarget(target)) return {
101
- clientHeight: window.innerHeight,
102
- scrollHeight: document.documentElement.scrollHeight
103
- };
104
- return {
105
- clientHeight: target.clientHeight,
106
- scrollHeight: target.scrollHeight
107
- };
108
- };
109
- const resolveScrollTop = (target) => {
110
- if (isWindowTarget(target)) return window.pageYOffset;
111
- return target.scrollTop;
112
- };
113
- const resolveScopedElement = (selector) => {
114
- var _headerRef$value;
115
- let scope = (_headerRef$value = headerRef.value) === null || _headerRef$value === void 0 ? void 0 : _headerRef$value.parentElement;
116
- while (scope) {
117
- if (scope.matches(selector)) return scope;
118
- const scopedTarget = getElement(selector, scope);
119
- if (scopedTarget) return scopedTarget;
120
- scope = scope.parentElement;
121
- }
122
- return getElement(selector);
123
- };
124
- const resolveScrollableElement = (target) => {
125
- if (target.matches(scrollbarViewportSelector)) return target;
126
- const viewport = getElement(scrollbarViewportSelector, target);
127
- if (viewport) return viewport;
128
- if (target.classList.contains(scrollbarPrefixCls)) return null;
129
- return target;
130
- };
131
- const resolveScrollTarget = () => {
132
- if (typeof window === "undefined") return null;
133
- if (!props.scrollTarget) return window;
134
- const resolvedTarget = resolveScopedElement(props.scrollTarget);
135
- if (!resolvedTarget) return null;
136
- return resolveScrollableElement(resolvedTarget);
137
- };
138
- const behavior = computed(() => {
139
- var _props$scrollBehavior;
140
- const items = new Set((_props$scrollBehavior = props.scrollBehavior) === null || _props$scrollBehavior === void 0 ? void 0 : _props$scrollBehavior.split(" ").filter(Boolean));
141
- return {
142
- hide: items.has("hide"),
143
- fullyHide: items.has("fully-hide"),
144
- inverted: items.has("inverted"),
145
- collapse: items.has("collapse"),
146
- elevate: items.has("elevate"),
147
- fadeImage: items.has("fade-image")
148
- };
149
- });
150
- const scrollThreshold = computed(() => parseSize(props.scrollThreshold, 300));
151
- const baseContentHeight = computed(() => parseSize(props.height, 64));
152
- const contentHeight = computed(() => baseContentHeight.value + resolveDensityOffset(props.density, baseContentHeight.value));
153
- const baseExtensionHeight = computed(() => parseSize(props.extensionHeight, 48));
154
- const extensionEnabled = computed(() => hasExtendedProp.value ? Boolean(props.extended) : Boolean(slots.extension));
155
- const measuredExtensionHeight = computed(() => {
156
- if (!extensionEnabled.value) return 0;
157
- return Math.max(0, baseExtensionHeight.value + resolveDensityOffset(props.density, baseExtensionHeight.value) / 2);
158
- });
159
- const fullHeight = computed(() => contentHeight.value + measuredExtensionHeight.value);
160
- const scrollRatio = computed(() => {
161
- if (scrollThreshold.value <= 0) return currentScroll.value === 0 ? 1 : 0;
162
- const ratio = (scrollThreshold.value - currentScroll.value) / scrollThreshold.value;
163
- return Math.min(1, Math.max(0, ratio));
164
- });
165
- const controlsVisibilityByScroll = computed(() => behavior.value.hide || behavior.value.fullyHide);
166
- const isCollapsed = computed(() => !!props.collapse || behavior.value.collapse && (behavior.value.inverted ? scrollRatio.value > 0 : scrollRatio.value === 0));
167
- const showExtension = computed(() => extensionEnabled.value && mergedVisible.value && !isCollapsed.value);
168
- const renderedHeight = computed(() => {
169
- if (!mergedVisible.value) return 0;
170
- return contentHeight.value + (showExtension.value ? measuredExtensionHeight.value : 0);
171
- });
172
- const imageOpacity = computed(() => {
173
- if (!behavior.value.fadeImage) return 1;
174
- return behavior.value.inverted ? 1 - scrollRatio.value : scrollRatio.value;
175
- });
176
- const isFlat = computed(() => props.flat || behavior.value.fullyHide && !mergedVisible.value || behavior.value.elevate && (behavior.value.inverted ? currentScroll.value > 0 : currentScroll.value === 0));
177
- const hasImage = computed(() => Boolean(props.image || slots.image));
178
- const hasTitle = computed(() => Boolean(props.title || slots.title));
179
- const wrapperClassNames = computed(() => [`${prefixCls}-wrapper`]);
180
- const classNames = computed(() => [prefixCls, {
181
- [`${prefixCls}-bottom`]: props.location === "bottom",
182
- [`${prefixCls}-fixed`]: props.fixed,
183
- [`${prefixCls}-sticky`]: props.sticky,
184
- [`${prefixCls}-absolute`]: props.absolute,
185
- [`${prefixCls}-flat`]: isFlat.value,
186
- [`${prefixCls}-floating`]: props.floating,
187
- [`${prefixCls}-hidden`]: !mergedVisible.value,
188
- [`${prefixCls}-collapsed`]: isCollapsed.value,
189
- [`${prefixCls}-with-image`]: hasImage.value,
190
- [`${prefixCls}-with-extension`]: showExtension.value,
191
- [`${prefixCls}-with-title`]: hasTitle.value
192
- }]);
193
- const wrapperStyles = computed(() => {
194
- if (!props.fixed || props.absolute) return;
195
- return { height: `${renderedHeight.value}px` };
196
- });
197
- const headerStyles = computed(() => {
198
- const styles = {
199
- "--sd-layout-header-content-height": `${contentHeight.value}px`,
200
- "--sd-layout-header-extension-height": `${measuredExtensionHeight.value}px`,
201
- "--sd-layout-header-image-opacity": String(imageOpacity.value),
202
- "height": `${renderedHeight.value}px`
203
- };
204
- if (!mergedVisible.value && (props.fixed || props.sticky || props.absolute)) styles.transform = `translateY(${props.location === "bottom" ? fullHeight.value : -fullHeight.value}px)`;
205
- if (props.fixed) {
206
- styles.position = "fixed";
207
- styles.left = "0";
208
- styles.right = "0";
209
- styles[props.location] = "0";
210
- styles.zIndex = 10;
211
- } else if (props.sticky) {
212
- styles.position = "sticky";
213
- styles[props.location] = "0";
214
- styles.zIndex = 10;
215
- } else if (props.absolute) {
216
- styles.position = "absolute";
217
- styles.left = "0";
218
- styles.right = "0";
219
- styles[props.location] = "0";
220
- styles.zIndex = 10;
221
- }
222
- return styles;
223
- });
224
- const updateScrollableSpace = () => {
225
- const target = scrollTargetRef.value;
226
- if (!target) return;
227
- const { clientHeight, scrollHeight } = getScrollMetrics(target);
228
- hasEnoughScrollableSpace.value = scrollHeight - clientHeight > scrollThreshold.value + fullHeight.value;
229
- };
230
- const handleScroll = () => {
231
- const target = scrollTargetRef.value;
232
- if (!target) return;
233
- previousScroll = currentScroll.value;
234
- currentScroll.value = resolveScrollTop(target);
235
- const currentHeight = isWindowTarget(target) ? document.documentElement.scrollHeight : target.scrollHeight;
236
- if (currentHeight > previousScrollHeight) updateScrollableSpace();
237
- previousScrollHeight = currentHeight;
238
- isScrollingUp.value = currentScroll.value < previousScroll;
239
- const { clientHeight, scrollHeight } = getScrollMetrics(target);
240
- const atBottom = currentScroll.value + clientHeight >= scrollHeight - 5;
241
- if (!isScrollingUp.value && atBottom && currentScroll.value >= scrollThreshold.value && hasEnoughScrollableSpace.value) reachedBottomWhileScrollingDown.value = true;
242
- const scrollJumped = Math.abs(currentScroll.value - previousScroll) > 100;
243
- const atTop = currentScroll.value <= 5;
244
- if (isScrollingUp.value && previousScroll - currentScroll.value > 1 && !atBottom || scrollJumped && currentScroll.value < scrollThreshold.value || atTop) reachedBottomWhileScrollingDown.value = false;
245
- isAtBottom.value = atBottom;
246
- if (!controlsVisibilityByScroll.value) return;
247
- if (behavior.value.inverted) {
248
- setVisible(currentScroll.value > scrollThreshold.value);
249
- return;
250
- }
251
- if (!hasEnoughScrollableSpace.value) {
252
- setVisible(true);
253
- return;
254
- }
255
- if (reachedBottomWhileScrollingDown.value) {
256
- setVisible(false);
257
- return;
258
- }
259
- setVisible(isScrollingUp.value && !isAtBottom.value || currentScroll.value < scrollThreshold.value);
260
- };
261
- const bindScrollTarget = (target) => {
262
- if (scrollTargetRef.value) off(scrollTargetRef.value, "scroll", handleScroll);
263
- scrollTargetRef.value = target;
264
- previousScroll = target ? resolveScrollTop(target) : 0;
265
- currentScroll.value = previousScroll;
266
- previousScrollHeight = target ? getScrollMetrics(target).scrollHeight : 0;
267
- isScrollingUp.value = false;
268
- isAtBottom.value = false;
269
- reachedBottomWhileScrollingDown.value = false;
270
- if (!scrollTargetRef.value) return;
271
- on(scrollTargetRef.value, "scroll", handleScroll, { passive: true });
272
- updateScrollableSpace();
273
- handleScroll();
274
- };
275
- const syncScrollTarget = () => {
276
- bindScrollTarget(resolveScrollTarget());
277
- };
278
- watch(() => props.scrollTarget, () => {
279
- if (typeof window === "undefined") return;
280
- if (!isMounted.value && props.scrollTarget) return;
281
- syncScrollTarget();
282
- }, { immediate: true });
283
- watch(scrollThreshold, () => {
284
- updateScrollableSpace();
285
- handleScroll();
286
- });
287
- onMounted(() => {
288
- if (typeof window === "undefined") return;
289
- isMounted.value = true;
290
- syncScrollTarget();
291
- on(window, "resize", updateScrollableSpace, { passive: true });
292
- updateScrollableSpace();
293
- handleScroll();
294
- nextTick(() => {
295
- syncScrollTarget();
296
- updateScrollableSpace();
297
- handleScroll();
298
- });
299
- });
300
- onBeforeUnmount(() => {
301
- if (scrollTargetRef.value) off(scrollTargetRef.value, "scroll", handleScroll);
302
- if (typeof window !== "undefined") off(window, "resize", updateScrollableSpace);
303
- });
8
+ setup(__props) {
9
+ const prefixCls = getPrefixCls("layout");
10
+ const classNames = computed(() => [`${prefixCls}-header`]);
304
11
  return (_ctx, _cache) => {
305
- return openBlock(), createElementBlock("div", {
306
- class: normalizeClass(wrapperClassNames.value),
307
- style: normalizeStyle(wrapperStyles.value)
308
- }, [createElementVNode("header", {
309
- ref_key: "headerRef",
310
- ref: headerRef,
311
- class: normalizeClass(classNames.value),
312
- style: normalizeStyle(headerStyles.value)
313
- }, [
314
- hasImage.value ? (openBlock(), createElementBlock("div", {
315
- key: 0,
316
- class: normalizeClass(`${unref(prefixCls)}-image`)
317
- }, [renderSlot(_ctx.$slots, "image", {}, () => [__props.image ? (openBlock(), createElementBlock("img", {
318
- key: 0,
319
- class: normalizeClass(`${unref(prefixCls)}-image-inner`),
320
- src: __props.image,
321
- alt: ""
322
- }, null, 10, _hoisted_1)) : createCommentVNode("", true)])], 2)) : createCommentVNode("", true),
323
- createElementVNode("div", { class: normalizeClass(`${unref(prefixCls)}-bar`) }, [
324
- _ctx.$slots.prepend ? (openBlock(), createElementBlock("div", {
325
- key: 0,
326
- class: normalizeClass(`${unref(prefixCls)}-prepend`)
327
- }, [renderSlot(_ctx.$slots, "prepend")], 2)) : createCommentVNode("", true),
328
- hasTitle.value ? (openBlock(), createElementBlock("div", {
329
- key: 1,
330
- class: normalizeClass(`${unref(prefixCls)}-title`)
331
- }, [renderSlot(_ctx.$slots, "title", {}, () => [createTextVNode(toDisplayString(__props.title), 1)])], 2)) : createCommentVNode("", true),
332
- _ctx.$slots.default ? (openBlock(), createElementBlock("div", {
333
- key: 2,
334
- class: normalizeClass(`${unref(prefixCls)}-content`)
335
- }, [renderSlot(_ctx.$slots, "default")], 2)) : createCommentVNode("", true),
336
- _ctx.$slots.append ? (openBlock(), createElementBlock("div", {
337
- key: 3,
338
- class: normalizeClass(`${unref(prefixCls)}-append`)
339
- }, [renderSlot(_ctx.$slots, "append")], 2)) : createCommentVNode("", true)
340
- ], 2),
341
- showExtension.value ? (openBlock(), createElementBlock("div", {
342
- key: 1,
343
- class: normalizeClass(`${unref(prefixCls)}-extension`)
344
- }, [renderSlot(_ctx.$slots, "extension")], 2)) : createCommentVNode("", true)
345
- ], 6)], 6);
12
+ return openBlock(), createBlock(resolveDynamicComponent(tagName), { class: normalizeClass(classNames.value) }, {
13
+ default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
14
+ _: 3
15
+ }, 8, ["class"]);
346
16
  };
347
17
  }
348
18
  }));
@@ -0,0 +1,2 @@
1
+ import { type ComputedRef, type Ref, type VNode } from 'vue';
2
+ export declare function useHasSider(siders: Ref<string[]>, slotVNodes: ComputedRef<VNode[] | undefined>, hasSider: Ref<boolean | undefined>): ComputedRef<boolean>;
@@ -0,0 +1,38 @@
1
+ import { computed } from "vue";
2
+ //#region components/layout/hooks/use-has-sider.ts
3
+ var SIDER_COMPONENT_NAME = "LayoutSider";
4
+ /**
5
+ * @zh 递归判断 VNode 列表中是否存在 Sider 组件
6
+ * @en Recursively detect whether a Sider component exists in the VNode list
7
+ */
8
+ function hasSiderInVNodes(vnodes) {
9
+ if (!vnodes) return false;
10
+ for (const vnode of vnodes) {
11
+ if (!vnode) continue;
12
+ const { type } = vnode;
13
+ if (type && typeof type === "object" && "name" in type && type.name === SIDER_COMPONENT_NAME) return true;
14
+ const { children } = vnode;
15
+ if (Array.isArray(children) && hasSiderInVNodes(children)) return true;
16
+ }
17
+ return false;
18
+ }
19
+ /**
20
+ * @zh 计算当前 Layout 是否包含 Sider,对齐 antd useHasSider 的优先级:
21
+ * 1. hasSider 为布尔值时直接采用;
22
+ * 2. 已有 Sider 通过上下文注册时为 true;
23
+ * 3. 否则回退到对默认插槽的静态扫描。
24
+ * @en Compute whether the current Layout contains a Sider, aligned with antd
25
+ * useHasSider precedence:
26
+ * 1. use hasSider when it is a boolean;
27
+ * 2. true when any Sider has registered via context;
28
+ * 3. otherwise fallback to static scan of the default slot.
29
+ */
30
+ function useHasSider(siders, slotVNodes, hasSider) {
31
+ return computed(() => {
32
+ if (typeof hasSider.value === "boolean") return hasSider.value;
33
+ if (siders.value.length > 0) return true;
34
+ return hasSiderInVNodes(slotVNodes.value);
35
+ });
36
+ }
37
+ //#endregion
38
+ export { useHasSider };