@douyinfe/semi-foundation 2.77.0-beta.0 → 2.78.0-alpha.2

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,6 +1,6 @@
1
1
  import BaseFoundation, { DefaultAdapter } from '../base/foundation';
2
2
  import { MDXProps } from 'mdx/types';
3
- import { type PluggableList } from "@mdx-js/mdx/lib/core";
3
+ import type { PluggableList } from 'unified';
4
4
  export interface MarkdownRenderAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
5
5
  getRuntime: () => any;
6
6
  }
@@ -59,6 +59,7 @@ export interface PopupContainerDOMRect extends DOMRectLikeType {
59
59
  export default class Tooltip<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<TooltipAdapter<P, S>, P, S> {
60
60
  _timer: ReturnType<typeof setTimeout>;
61
61
  _mounted: boolean;
62
+ anchorName: string;
62
63
  constructor(adapter: TooltipAdapter<P, S>);
63
64
  init(): void;
64
65
  destroy(): void;
@@ -76,6 +77,10 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
76
77
  _reducePos(position?: string): string;
77
78
  clearDelayTimer(): void;
78
79
  updateStateIfCursorOnTrigger: (trigger: HTMLElement) => void;
80
+ getNativeAnchorStyle: () => {
81
+ positionAnchor: string;
82
+ position: string;
83
+ };
79
84
  _generateEvent(types: ArrayElement<typeof strings.TRIGGER_SET>): {
80
85
  triggerEventSet: {
81
86
  [x: string]: (event: any) => void;
@@ -8,6 +8,7 @@ var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
8
8
  var _get2 = _interopRequireDefault(require("lodash/get"));
9
9
  var _foundation = _interopRequireDefault(require("../base/foundation"));
10
10
  var _a11y = require("../utils/a11y");
11
+ var _uuid = require("../utils/uuid");
11
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
13
  const REGS = {
13
14
  TOP: /top/i,
@@ -28,6 +29,7 @@ class Tooltip extends _foundation.default {
28
29
  var _this;
29
30
  super(Object.assign({}, adapter));
30
31
  _this = this;
32
+ this.anchorName = `--native-semi-anchor-${(0, _uuid.getUuidShort)()}`;
31
33
  this.removePortal = () => {
32
34
  this._adapter.removePortal();
33
35
  };
@@ -42,6 +44,26 @@ class Tooltip extends _foundation.default {
42
44
  (_b = triggerEventSet[eventNames.mouseEnter]) === null || _b === void 0 ? void 0 : _b.call(triggerEventSet);
43
45
  }
44
46
  };
47
+ this.getNativeAnchorStyle = () => {
48
+ const style = {
49
+ positionAnchor: this.anchorName,
50
+ position: "fixed"
51
+ };
52
+ const position = this._adapter.getProp("position");
53
+ const spacing = this._adapter.getProp("spacing");
54
+ if (position === "top") {
55
+ style['bottom'] = `anchor(top)`;
56
+ style['justifySelf'] = "anchor-center";
57
+ style["transform"] = `translateY(-${spacing}px)`;
58
+ } else if (position === "bottom") {
59
+ style['top'] = `anchor(bottom)`;
60
+ style['justifySelf'] = "anchor-center";
61
+ style["transform"] = `translateY(${spacing}px)`;
62
+ } else {
63
+ throw new Error(`Currently, not support position ${position} when enable native anchor ability, only 'top' 'bottom'.`);
64
+ }
65
+ return style;
66
+ };
45
67
  this.onResize = () => {
46
68
  // this.log('resize');
47
69
  // rePosition when window resize
@@ -1,6 +1,6 @@
1
1
  import BaseFoundation, { DefaultAdapter } from '../base/foundation';
2
2
  import { MDXProps } from 'mdx/types';
3
- import { type PluggableList } from "@mdx-js/mdx/lib/core";
3
+ import type { PluggableList } from 'unified';
4
4
  export interface MarkdownRenderAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
5
5
  getRuntime: () => any;
6
6
  }
@@ -59,6 +59,7 @@ export interface PopupContainerDOMRect extends DOMRectLikeType {
59
59
  export default class Tooltip<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<TooltipAdapter<P, S>, P, S> {
60
60
  _timer: ReturnType<typeof setTimeout>;
61
61
  _mounted: boolean;
62
+ anchorName: string;
62
63
  constructor(adapter: TooltipAdapter<P, S>);
63
64
  init(): void;
64
65
  destroy(): void;
@@ -76,6 +77,10 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
76
77
  _reducePos(position?: string): string;
77
78
  clearDelayTimer(): void;
78
79
  updateStateIfCursorOnTrigger: (trigger: HTMLElement) => void;
80
+ getNativeAnchorStyle: () => {
81
+ positionAnchor: string;
82
+ position: string;
83
+ };
79
84
  _generateEvent(types: ArrayElement<typeof strings.TRIGGER_SET>): {
80
85
  triggerEventSet: {
81
86
  [x: string]: (event: any) => void;
@@ -2,6 +2,7 @@ import _isEmpty from "lodash/isEmpty";
2
2
  import _get from "lodash/get";
3
3
  import BaseFoundation from '../base/foundation';
4
4
  import { handlePrevent } from '../utils/a11y';
5
+ import { getUuidShort } from "../utils/uuid";
5
6
  const REGS = {
6
7
  TOP: /top/i,
7
8
  RIGHT: /right/i,
@@ -21,6 +22,7 @@ export default class Tooltip extends BaseFoundation {
21
22
  var _this;
22
23
  super(Object.assign({}, adapter));
23
24
  _this = this;
25
+ this.anchorName = `--native-semi-anchor-${getUuidShort()}`;
24
26
  this.removePortal = () => {
25
27
  this._adapter.removePortal();
26
28
  };
@@ -35,6 +37,26 @@ export default class Tooltip extends BaseFoundation {
35
37
  (_b = triggerEventSet[eventNames.mouseEnter]) === null || _b === void 0 ? void 0 : _b.call(triggerEventSet);
36
38
  }
37
39
  };
40
+ this.getNativeAnchorStyle = () => {
41
+ const style = {
42
+ positionAnchor: this.anchorName,
43
+ position: "fixed"
44
+ };
45
+ const position = this._adapter.getProp("position");
46
+ const spacing = this._adapter.getProp("spacing");
47
+ if (position === "top") {
48
+ style['bottom'] = `anchor(top)`;
49
+ style['justifySelf'] = "anchor-center";
50
+ style["transform"] = `translateY(-${spacing}px)`;
51
+ } else if (position === "bottom") {
52
+ style['top'] = `anchor(bottom)`;
53
+ style['justifySelf'] = "anchor-center";
54
+ style["transform"] = `translateY(${spacing}px)`;
55
+ } else {
56
+ throw new Error(`Currently, not support position ${position} when enable native anchor ability, only 'top' 'bottom'.`);
57
+ }
58
+ return style;
59
+ };
38
60
  this.onResize = () => {
39
61
  // this.log('resize');
40
62
  // rePosition when window resize
@@ -2,7 +2,8 @@ import BaseFoundation, { DefaultAdapter } from '../base/foundation';
2
2
  import { CompileOptions, evaluate, compile, EvaluateOptions, evaluateSync, RunOptions } from '@mdx-js/mdx';
3
3
  import { MDXProps } from 'mdx/types';
4
4
  import remarkGfm from 'remark-gfm';
5
- import { type PluggableList } from "@mdx-js/mdx/lib/core";
5
+ import type { PluggableList } from 'unified';
6
+
6
7
  export interface MarkdownRenderAdapter <P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
7
8
  getRuntime: () => any
8
9
 
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-foundation",
3
- "version": "2.77.0-beta.0",
3
+ "version": "2.78.0-alpha.2",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build:lib": "node ./scripts/compileLib.js",
7
7
  "prepublishOnly": "npm run build:lib"
8
8
  },
9
9
  "dependencies": {
10
- "@douyinfe/semi-animation": "2.77.0-beta.0",
11
- "@douyinfe/semi-json-viewer-core": "2.77.0-beta.0",
10
+ "@douyinfe/semi-animation": "2.78.0-alpha.2",
11
+ "@douyinfe/semi-json-viewer-core": "2.78.0-alpha.2",
12
12
  "@mdx-js/mdx": "^3.0.1",
13
13
  "async-validator": "^3.5.0",
14
14
  "classnames": "^2.2.6",
@@ -29,7 +29,7 @@
29
29
  "*.scss",
30
30
  "*.css"
31
31
  ],
32
- "gitHead": "f492bd51b129470e049f08b074ad962d2804a5c3",
32
+ "gitHead": "8f2966f2472daa5369f886b2c246ceccf59ed94e",
33
33
  "devDependencies": {
34
34
  "@babel/plugin-transform-runtime": "^7.15.8",
35
35
  "@babel/preset-env": "^7.15.8",
@@ -4,6 +4,7 @@ import BaseFoundation, { DefaultAdapter } from '../base/foundation';
4
4
  import { ArrayElement } from '../utils/type';
5
5
  import { strings } from './constants';
6
6
  import { handlePrevent } from '../utils/a11y';
7
+ import { getUuidShort } from "../utils/uuid";
7
8
 
8
9
  const REGS = {
9
10
  TOP: /top/i,
@@ -81,7 +82,7 @@ export interface PopupContainerDOMRect extends DOMRectLikeType {
81
82
  export default class Tooltip<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<TooltipAdapter<P, S>, P, S> {
82
83
  _timer: ReturnType<typeof setTimeout>;
83
84
  _mounted: boolean;
84
-
85
+ anchorName = `--native-semi-anchor-${getUuidShort()}`
85
86
  constructor(adapter: TooltipAdapter<P, S>) {
86
87
  super({ ...adapter });
87
88
  this._timer = null;
@@ -135,7 +136,7 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
135
136
  unBindResizeEvent() {
136
137
  this._adapter.unregisterResizeHandler(this.onResize);
137
138
  }
138
-
139
+
139
140
  removePortal = () => {
140
141
  this._adapter.removePortal();
141
142
  }
@@ -199,6 +200,29 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
199
200
  }
200
201
  }
201
202
 
203
+ getNativeAnchorStyle = () => {
204
+ const style = {
205
+ positionAnchor: this.anchorName,
206
+ position: "fixed",
207
+ };
208
+ const position = this._adapter.getProp("position");
209
+ const spacing = this._adapter.getProp("spacing");
210
+ if (position === "top") {
211
+ style['bottom'] = `anchor(top)`;
212
+ style['justifySelf'] = "anchor-center";
213
+ style["transform"] = `translateY(-${spacing}px)`;
214
+
215
+ } else if (position === "bottom") {
216
+ style['top'] = `anchor(bottom)`;
217
+ style['justifySelf'] = "anchor-center";
218
+ style["transform"] = `translateY(${spacing}px)`;
219
+
220
+ } else {
221
+ throw new Error(`Currently, not support position ${position} when enable native anchor ability, only 'top' 'bottom'.`);
222
+ }
223
+ return style;
224
+ }
225
+
202
226
  _generateEvent(types: ArrayElement<typeof strings.TRIGGER_SET>) {
203
227
  const eventNames = this._adapter.getEventName();
204
228
  const triggerEventSet = {