@sdata/web-vue 1.7.0 → 1.7.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.
@@ -1,5 +1,5 @@
1
1
  import { ComponentPublicInstance } from 'vue';
2
2
  export declare const useComponentRef: (name: string) => {
3
- componentRef: import("vue").Ref<ComponentPublicInstance | HTMLElement | undefined, ComponentPublicInstance | HTMLElement | undefined>;
3
+ componentRef: import("vue").Ref<HTMLElement | ComponentPublicInstance | undefined, HTMLElement | ComponentPublicInstance | undefined>;
4
4
  elementRef: import("vue").Ref<any, any>;
5
5
  };
@@ -1,10 +1,10 @@
1
1
  import { Ref } from 'vue';
2
2
  export declare const useTeleportContainer: ({ popupContainer, visible, defaultContainer, documentContainer, }: {
3
- popupContainer: Ref<string | HTMLElement | undefined>;
3
+ popupContainer: Ref<string | HTMLElement | null | undefined>;
4
4
  visible: Ref<boolean>;
5
5
  defaultContainer?: string;
6
6
  documentContainer?: boolean;
7
7
  }) => {
8
- teleportContainer: Ref<string | HTMLElement | undefined, string | HTMLElement | undefined>;
8
+ teleportContainer: Ref<string | HTMLElement | null | undefined, string | HTMLElement | null | undefined>;
9
9
  containerRef: Ref<HTMLElement | undefined, HTMLElement | undefined>;
10
10
  };
@@ -5,15 +5,18 @@ var useTeleportContainer = ({ popupContainer, visible, defaultContainer = "body"
5
5
  const teleportContainer = ref(popupContainer.value);
6
6
  const containerRef = ref();
7
7
  const getContainer = () => {
8
- const element = getElement(popupContainer.value);
9
- const _teleportContainer = element ? popupContainer.value : defaultContainer;
8
+ var _popupContainer$value;
9
+ const resolvedPopupContainer = (_popupContainer$value = popupContainer.value) !== null && _popupContainer$value !== void 0 ? _popupContainer$value : void 0;
10
+ const element = getElement(resolvedPopupContainer);
11
+ const _teleportContainer = element ? resolvedPopupContainer : defaultContainer;
10
12
  const _containerElement = element !== null && element !== void 0 ? element : documentContainer ? document.documentElement : getElement(defaultContainer);
11
13
  if (_teleportContainer !== teleportContainer.value) teleportContainer.value = _teleportContainer;
12
14
  if (_containerElement !== containerRef.value) containerRef.value = _containerElement;
13
15
  };
14
16
  onMounted(() => getContainer());
15
- watch(visible, (visible) => {
16
- if (teleportContainer.value !== popupContainer.value && visible) getContainer();
17
+ watch([popupContainer, visible], ([nextPopupContainer, nextVisible]) => {
18
+ if (!nextVisible) return;
19
+ if (teleportContainer.value !== nextPopupContainer) getContainer();
17
20
  });
18
21
  return {
19
22
  teleportContainer,
@@ -1,4 +1,4 @@
1
- import { InjectionKey, Slots } from 'vue';
1
+ import { InjectionKey, Ref, Slots } from 'vue';
2
2
  import { Size } from '../_utils/constant';
3
3
  import { SDLang } from '../locale/interface';
4
4
  import { SDThemeNormalized } from './theme';
@@ -14,3 +14,4 @@ export interface ConfigProvider {
14
14
  theme?: SDThemeNormalized;
15
15
  }
16
16
  export declare const configProviderInjectionKey: InjectionKey<ConfigProvider>;
17
+ export declare const themePopupContainerInjectionKey: InjectionKey<Ref<HTMLElement | null>>;
@@ -1,4 +1,5 @@
1
1
  //#region components/config-provider/context.ts
2
2
  var configProviderInjectionKey = Symbol("SDConfigProvider");
3
+ var themePopupContainerInjectionKey = Symbol("SDThemePopupContainer");
3
4
  //#endregion
4
- export { configProviderInjectionKey };
5
+ export { configProviderInjectionKey, themePopupContainerInjectionKey };
@@ -0,0 +1 @@
1
+ import "./index.css";
@@ -0,0 +1,29 @@
1
+ /******** borderSize *******/
2
+ /******** borderStyle *******/
3
+ /******** radius *******/
4
+ /******** shadow distance *******/
5
+ /******** size *******/
6
+ /******** spacing *******/
7
+ /******** shadow *******/
8
+ /******** opacity *******/
9
+ /******** fontSize *******/
10
+ /******** fontWeight ********/
11
+ /******** Primary *******/
12
+ /******** success *******/
13
+ /******** warning *******/
14
+ /******** danger *******/
15
+ /******** link *******/
16
+ /******** radius *******/
17
+ /********* icon hover *********/
18
+ .sd-theme-provider {
19
+ min-width: 0;
20
+ }
21
+
22
+ .sd-theme-popup-container {
23
+ position: fixed;
24
+ top: 0;
25
+ left: 0;
26
+ width: 100vw;
27
+ height: 0;
28
+ pointer-events: none;
29
+ }
@@ -1 +1 @@
1
- export {};
1
+ import './index.scss';
@@ -0,0 +1 @@
1
+ import "./index.scss";
@@ -0,0 +1,17 @@
1
+ @use '@style/theme/index.scss' as theme;
2
+ @use 'sass:string';
3
+
4
+ $theme-prefix-cls: string.unquote('#{theme.$prefix}-theme');
5
+
6
+ .#{$theme-prefix-cls}-provider {
7
+ min-width: 0;
8
+ }
9
+
10
+ .#{$theme-prefix-cls}-popup-container {
11
+ position: fixed;
12
+ top: 0;
13
+ left: 0;
14
+ width: 100vw;
15
+ height: 0;
16
+ pointer-events: none;
17
+ }
@@ -1,7 +1,5 @@
1
- import _plugin_vue_export_helper_default from "../_virtual/_plugin-vue_export-helper.js";
2
1
  import theme_provider_vue_vue_type_script_setup_true_lang_default from "./theme-provider.vue_vue_type_script_setup_true_lang.js";
3
- /* empty css */
4
2
  //#region components/config-provider/theme-provider.vue
5
- var theme_provider_default = /* @__PURE__ */ _plugin_vue_export_helper_default(theme_provider_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-a0a91a8a"]]);
3
+ var theme_provider_default = theme_provider_vue_vue_type_script_setup_true_lang_default;
6
4
  //#endregion
7
5
  export { theme_provider_default as default };
@@ -1,6 +1,9 @@
1
+ import { themePopupContainerInjectionKey } from "./context.js";
1
2
  import { _objectSpread2 } from "../_virtual/_@oxc-project_runtime@0.124.0/helpers/objectSpread2.js";
3
+ import { getPrefixCls } from "../_utils/global-config.js";
4
+ import usePopupManager from "../_hooks/use-popup-manager.js";
2
5
  import { applyThemeCSSVariables, clearThemeCSSVariables, normalizeTheme } from "./theme.js";
3
- import { computed, createBlock, defineComponent, onBeforeUnmount, openBlock, renderSlot, resolveDynamicComponent, shallowRef, watch, withCtx } from "vue";
6
+ import { computed, createBlock, defineComponent, normalizeClass, onBeforeUnmount, openBlock, provide, renderSlot, resolveDynamicComponent, shallowRef, unref, watch, withCtx } from "vue";
4
7
  //#region components/config-provider/theme-provider.vue?vue&type=script&setup=true&lang.ts
5
8
  var theme_provider_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent(_objectSpread2(_objectSpread2({}, { name: "ThemeProvider" }), {}, {
6
9
  __name: "theme-provider",
@@ -16,14 +19,48 @@ var theme_provider_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
16
19
  setup(__props) {
17
20
  const props = __props;
18
21
  const rootElement = shallowRef(null);
22
+ const popupContainer = shallowRef(null);
23
+ provide(themePopupContainerInjectionKey, popupContainer);
19
24
  const normalizedTheme = computed(() => normalizeTheme(props.theme));
20
25
  const usesLocalThemeContainer = computed(() => {
21
26
  if (props.global) return false;
22
27
  return Boolean(props.themeMode) || Object.keys(normalizedTheme.value.tokens).length > 0 || Object.keys(normalizedTheme.value.components).length > 0;
23
28
  });
29
+ const themePopupContainerPrefixCls = getPrefixCls("theme-popup-container");
30
+ const { zIndex } = usePopupManager("popup", { visible: usesLocalThemeContainer });
24
31
  let appliedThemeKeys = /* @__PURE__ */ new Set();
32
+ let appliedPopupThemeKeys = /* @__PURE__ */ new Set();
25
33
  let activeTarget = null;
26
34
  let previousGlobalThemeMode;
35
+ function cleanupPopupContainer() {
36
+ if (!popupContainer.value) return;
37
+ clearThemeCSSVariables(popupContainer.value, appliedPopupThemeKeys);
38
+ appliedPopupThemeKeys = /* @__PURE__ */ new Set();
39
+ popupContainer.value.removeAttribute("sd-theme");
40
+ if (popupContainer.value.parentNode) popupContainer.value.parentNode.removeChild(popupContainer.value);
41
+ popupContainer.value = null;
42
+ }
43
+ function ensurePopupContainer() {
44
+ if (popupContainer.value || typeof document === "undefined") return;
45
+ const containerElement = document.createElement("div");
46
+ containerElement.className = themePopupContainerPrefixCls;
47
+ document.body.appendChild(containerElement);
48
+ popupContainer.value = containerElement;
49
+ }
50
+ function syncPopupContainerTheme(target) {
51
+ var _target$closest;
52
+ if (props.global || !target || !usesLocalThemeContainer.value) {
53
+ cleanupPopupContainer();
54
+ return;
55
+ }
56
+ ensurePopupContainer();
57
+ if (!popupContainer.value) return;
58
+ popupContainer.value.style.zIndex = String(zIndex.value);
59
+ appliedPopupThemeKeys = applyThemeCSSVariables(popupContainer.value, normalizedTheme.value, appliedPopupThemeKeys);
60
+ const inheritedThemeMode = (_target$closest = target.closest("[sd-theme]")) === null || _target$closest === void 0 ? void 0 : _target$closest.getAttribute("sd-theme");
61
+ if (inheritedThemeMode) popupContainer.value.setAttribute("sd-theme", inheritedThemeMode);
62
+ else popupContainer.value.removeAttribute("sd-theme");
63
+ }
27
64
  function resolveThemeTarget() {
28
65
  if (typeof document === "undefined") return null;
29
66
  if (props.global) return document.body || document.documentElement;
@@ -68,6 +105,7 @@ var theme_provider_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
68
105
  const nextTarget = resolveThemeTarget();
69
106
  if (!nextTarget) {
70
107
  resetActiveTarget();
108
+ cleanupPopupContainer();
71
109
  return;
72
110
  }
73
111
  if (activeTarget && activeTarget !== nextTarget) cleanupTarget(activeTarget);
@@ -75,6 +113,7 @@ var theme_provider_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
75
113
  appliedThemeKeys = applyThemeCSSVariables(nextTarget, normalizedTheme.value, appliedThemeKeys);
76
114
  restoreThemeMode(nextTarget);
77
115
  activeTarget = nextTarget;
116
+ syncPopupContainerTheme(nextTarget);
78
117
  }
79
118
  watch([
80
119
  normalizedTheme,
@@ -89,6 +128,7 @@ var theme_provider_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
89
128
  });
90
129
  onBeforeUnmount(() => {
91
130
  cleanupTarget(activeTarget);
131
+ cleanupPopupContainer();
92
132
  activeTarget = null;
93
133
  });
94
134
  return (_ctx, _cache) => {
@@ -96,11 +136,11 @@ var theme_provider_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
96
136
  key: 0,
97
137
  ref_key: "rootElement",
98
138
  ref: rootElement,
99
- class: "sd-theme-provider"
139
+ class: normalizeClass(unref(getPrefixCls)("theme-provider"))
100
140
  }, {
101
- default: withCtx(() => [renderSlot(_ctx.$slots, "default", {}, void 0, true)]),
141
+ default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
102
142
  _: 3
103
- }, 512)) : renderSlot(_ctx.$slots, "default", { key: 1 }, void 0, true);
143
+ }, 8, ["class"])) : renderSlot(_ctx.$slots, "default", { key: 1 });
104
144
  };
105
145
  }
106
146
  }));
@@ -108,7 +108,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
108
108
  handleClose: () => void;
109
109
  handleMask: (e: Event) => void;
110
110
  isFixed: import("vue").ComputedRef<boolean>;
111
- teleportContainer: import("vue").Ref<string | HTMLElement | undefined, string | HTMLElement | undefined>;
111
+ teleportContainer: import("vue").Ref<string | HTMLElement | null | undefined, string | HTMLElement | null | undefined>;
112
112
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
113
113
  'update:visible': (_visible: boolean) => true;
114
114
  ok: (_e: Event) => true;
@@ -115,7 +115,7 @@ declare const Drawer: {
115
115
  handleClose: () => void;
116
116
  handleMask: (e: Event) => void;
117
117
  isFixed: import("vue").ComputedRef<boolean>;
118
- teleportContainer: import("vue").Ref<string | HTMLElement | undefined, string | HTMLElement | undefined>;
118
+ teleportContainer: import("vue").Ref<string | HTMLElement | null | undefined, string | HTMLElement | null | undefined>;
119
119
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
120
120
  'update:visible': (_visible: boolean) => true;
121
121
  ok: (_e: Event) => true;
@@ -850,7 +850,7 @@ declare const Drawer: {
850
850
  handleClose: () => void;
851
851
  handleMask: (e: Event) => void;
852
852
  isFixed: import("vue").ComputedRef<boolean>;
853
- teleportContainer: import("vue").Ref<string | HTMLElement | undefined, string | HTMLElement | undefined>;
853
+ teleportContainer: import("vue").Ref<string | HTMLElement | null | undefined, string | HTMLElement | null | undefined>;
854
854
  }, {}, {}, {}, {
855
855
  footer: boolean;
856
856
  header: boolean;
@@ -984,7 +984,7 @@ declare const Drawer: {
984
984
  handleClose: () => void;
985
985
  handleMask: (e: Event) => void;
986
986
  isFixed: import("vue").ComputedRef<boolean>;
987
- teleportContainer: import("vue").Ref<string | HTMLElement | undefined, string | HTMLElement | undefined>;
987
+ teleportContainer: import("vue").Ref<string | HTMLElement | null | undefined, string | HTMLElement | null | undefined>;
988
988
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
989
989
  'update:visible': (_visible: boolean) => true;
990
990
  ok: (_e: Event) => true;
package/es/index.css CHANGED
@@ -17868,4 +17868,17 @@ body {
17868
17868
  .sd-affix {
17869
17869
  position: fixed;
17870
17870
  z-index: 999;
17871
+ }
17872
+
17873
+ .sd-theme-provider {
17874
+ min-width: 0;
17875
+ }
17876
+
17877
+ .sd-theme-popup-container {
17878
+ position: fixed;
17879
+ top: 0;
17880
+ left: 0;
17881
+ width: 100vw;
17882
+ height: 0;
17883
+ pointer-events: none;
17871
17884
  }
package/es/index.scss CHANGED
@@ -75,3 +75,4 @@
75
75
  @use '@components/anchor/style/index.scss' as *;
76
76
  @use '@components/alert/style/index.scss' as *;
77
77
  @use '@components/affix/style/index.scss' as *;
78
+ @use '@components/config-provider/style/index.scss' as *;
@@ -153,7 +153,7 @@ declare const Modal: {
153
153
  modalCls: import("vue").ComputedRef<(string | any[] | {
154
154
  [x: string]: boolean;
155
155
  } | undefined)[]>;
156
- teleportContainer: import("vue").Ref<string | HTMLElement | undefined, string | HTMLElement | undefined>;
156
+ teleportContainer: import("vue").Ref<string | HTMLElement | null | undefined, string | HTMLElement | null | undefined>;
157
157
  handleMoveDown: (ev: MouseEvent) => void;
158
158
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
159
159
  'update:visible': (_visible: boolean) => true;
@@ -1404,7 +1404,7 @@ declare const Modal: {
1404
1404
  modalCls: import("vue").ComputedRef<(string | any[] | {
1405
1405
  [x: string]: boolean;
1406
1406
  } | undefined)[]>;
1407
- teleportContainer: import("vue").Ref<string | HTMLElement | undefined, string | HTMLElement | undefined>;
1407
+ teleportContainer: import("vue").Ref<string | HTMLElement | null | undefined, string | HTMLElement | null | undefined>;
1408
1408
  handleMoveDown: (ev: MouseEvent) => void;
1409
1409
  }, {}, {}, {}, {
1410
1410
  footer: boolean;
@@ -1582,7 +1582,7 @@ declare const Modal: {
1582
1582
  modalCls: import("vue").ComputedRef<(string | any[] | {
1583
1583
  [x: string]: boolean;
1584
1584
  } | undefined)[]>;
1585
- teleportContainer: import("vue").Ref<string | HTMLElement | undefined, string | HTMLElement | undefined>;
1585
+ teleportContainer: import("vue").Ref<string | HTMLElement | null | undefined, string | HTMLElement | null | undefined>;
1586
1586
  handleMoveDown: (ev: MouseEvent) => void;
1587
1587
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
1588
1588
  'update:visible': (_visible: boolean) => true;
@@ -146,7 +146,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
146
146
  modalCls: import("vue").ComputedRef<(string | any[] | {
147
147
  [x: string]: boolean;
148
148
  } | undefined)[]>;
149
- teleportContainer: import("vue").Ref<string | HTMLElement | undefined, string | HTMLElement | undefined>;
149
+ teleportContainer: import("vue").Ref<string | HTMLElement | null | undefined, string | HTMLElement | null | undefined>;
150
150
  handleMoveDown: (ev: MouseEvent) => void;
151
151
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
152
152
  'update:visible': (_visible: boolean) => true;
@@ -38,7 +38,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
38
38
  [x: string]: boolean;
39
39
  })[]>;
40
40
  wrapperRef: import("vue").Ref<any, any>;
41
- wrapperComRef: import("vue").Ref<import("vue").ComponentPublicInstance | HTMLElement | undefined, import("vue").ComponentPublicInstance | HTMLElement | undefined>;
41
+ wrapperComRef: import("vue").Ref<HTMLElement | import("vue").ComponentPublicInstance | undefined, HTMLElement | import("vue").ComponentPublicInstance | undefined>;
42
42
  handleScroll: (e: Event) => void;
43
43
  displayScrollbar: import("vue").ComputedRef<boolean>;
44
44
  scrollbarProps: import("vue").ComputedRef<ScrollbarProps | undefined>;
@@ -1,4 +1,4 @@
1
- import { configProviderInjectionKey } from "../config-provider/context.js";
1
+ import { configProviderInjectionKey, themePopupContainerInjectionKey } from "../config-provider/context.js";
2
2
  import { _objectSpread2 } from "../_virtual/_@oxc-project_runtime@0.124.0/helpers/objectSpread2.js";
3
3
  import { getPrefixCls } from "../_utils/global-config.js";
4
4
  import { isEmptyChildren, mergeFirstChild } from "../_utils/vue-utils.js";
@@ -14,7 +14,7 @@ import { useResizeObserver } from "../_hooks/use-resize-observer.js";
14
14
  import { useTeleportContainer } from "../_hooks/use-teleport-container.js";
15
15
  import { triggerInjectionKey } from "./context.js";
16
16
  import { getArrowStyle, getElementScrollRect, getPopupStyle, getScrollElements, getTransformOrigin } from "./utils.js";
17
- import { Fragment, Teleport, Transition, computed, createVNode, defineComponent, inject, mergeProps, nextTick, onBeforeUnmount, onDeactivated, onMounted, onUpdated, provide, reactive, ref, toRefs, vShow, watch, withDirectives } from "vue";
17
+ import { Fragment, Teleport, Transition, computed, createVNode, defineComponent, inject, mergeProps, nextTick, onBeforeUnmount, onDeactivated, onMounted, onUpdated, provide, reactive, ref, vShow, watch, withDirectives } from "vue";
18
18
  //#region components/trigger/trigger.tsx
19
19
  var TRIGGER_EVENTS = [
20
20
  "onClick",
@@ -170,10 +170,14 @@ var trigger_default = /* @__PURE__ */ defineComponent({
170
170
  "resize": () => true
171
171
  },
172
172
  setup(props, { emit, slots, attrs }) {
173
- const { popupContainer } = toRefs(props);
174
173
  const prefixCls = getPrefixCls("trigger");
175
174
  const popupAttrs = computed(() => omit(attrs, TRIGGER_EVENTS));
176
175
  const configCtx = inject(configProviderInjectionKey, void 0);
176
+ const themePopupContainer = inject(themePopupContainerInjectionKey, void 0);
177
+ const mergedPopupContainer = computed(() => {
178
+ var _props$popupContainer;
179
+ return (_props$popupContainer = props.popupContainer) !== null && _props$popupContainer !== void 0 ? _props$popupContainer : themePopupContainer === null || themePopupContainer === void 0 ? void 0 : themePopupContainer.value;
180
+ });
177
181
  const triggerMethods = computed(() => [].concat(props.trigger));
178
182
  const childrenRefs = /* @__PURE__ */ new Set();
179
183
  const triggerCtx = inject(triggerInjectionKey, void 0);
@@ -196,7 +200,7 @@ var trigger_default = /* @__PURE__ */ defineComponent({
196
200
  return (_props$popupVisible = props.popupVisible) !== null && _props$popupVisible !== void 0 ? _props$popupVisible : popupVisible.value;
197
201
  });
198
202
  const { teleportContainer, containerRef } = useTeleportContainer({
199
- popupContainer,
203
+ popupContainer: mergedPopupContainer,
200
204
  visible: computedVisible,
201
205
  documentContainer: true
202
206
  });
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "framework": "vue",
4
4
  "name": "@sdata/web-vue",
5
- "version": "1.6.0",
5
+ "version": "1.7.0",
6
6
  "contributions": {
7
7
  "html": {
8
8
  "types-syntax": "typescript",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdata/web-vue",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "SD Design Vue: A Vue.js 3 UI Library",
5
5
  "keywords": [
6
6
  "sd",
package/es/web-vue.css DELETED
@@ -1,5 +0,0 @@
1
-
2
- .sd-theme-provider[data-v-a0a91a8a] {
3
- min-width: 0;
4
- }
5
- /*$vite$:1*/